Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXColorWell.h

00001 /********************************************************************************
00002 *                                                                               *
00003 *                         C o l o r W e l l   W i d g e t                       *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1998,2002 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (at your option) any later version.            *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXColorWell.h,v 1.22 2002/01/18 22:42:51 jeroen Exp $                    *
00023 ********************************************************************************/
00024 #ifndef FXCOLORWELL_H
00025 #define FXCOLORWELL_H
00026 
00027 #ifndef FXFRAME_H
00028 #include "FXFrame.h"
00029 #endif
00030 
00031 
00032 
00033 // Color Well Styles
00034 enum {
00035   COLORWELL_OPAQUEONLY = 0x00008000,  /// Colors must be opaque
00036   COLORWELL_SOURCEONLY = 0x00010000,  /// ColorWell is never a target
00037   COLORWELL_NORMAL     = JUSTIFY_NORMAL
00038   };
00039 
00040 
00041 
00042 /**
00043 * A color well is a widget which controls color settings.
00044 * Colors may be dragged and dropped from one color well to another.
00045 * A double-click inside a color well will bring up the standard
00046 * color dialog panel to edit the color well's color.
00047 * Colors may be also pasted by name using middle-mouse click into/out of
00048 * color wells from/to other selection-capable applications; for example,
00049 * you can highlight the word `red' and paste it into a color well.
00050 * While the color value is being changed, the color well sends a SEL_CHANGED
00051 * to its target; at the end of the change, it sends a SEL_COMMAND.
00052 * The message data represents the current color value, of the type FXColor.
00053 */
00054 class FXAPI FXColorWell : public FXFrame {
00055   FXDECLARE(FXColorWell)
00056 protected:
00057   FXColor   wellColor[2];             // Pixel value of RGBA over black and white
00058   FXColor   rgba;                     // Color with RGB and Alpha
00059   FXColor   oldrgba;                  // Old color
00060   FXString  tip;                      // Tooltip value
00061   FXString  help;                     // Help value
00062 protected:
00063   FXColorWell();
00064   static FXColor rgbaoverblack(FXColor clr);
00065   static FXColor rgbaoverwhite(FXColor clr);
00066 private:
00067   FXColorWell(const FXColorWell&);
00068   FXColorWell &operator=(const FXColorWell&);
00069 public:
00070   long onPaint(FXObject*,FXSelector,void*);
00071   long onLeftBtnPress(FXObject*,FXSelector,void*);
00072   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00073   long onMiddleBtnPress(FXObject*,FXSelector,void*);
00074   long onMiddleBtnRelease(FXObject*,FXSelector,void*);
00075   long onKeyPress(FXObject*,FXSelector,void*);
00076   long onKeyRelease(FXObject*,FXSelector,void*);
00077   long onUngrabbed(FXObject*,FXSelector,void*);
00078   long onMotion(FXObject*,FXSelector,void*);
00079   long onBeginDrag(FXObject*,FXSelector,void*);
00080   long onEndDrag(FXObject*,FXSelector,void*);
00081   long onDragged(FXObject*,FXSelector,void*);
00082   long onFocusIn(FXObject*,FXSelector,void*);
00083   long onFocusOut(FXObject*,FXSelector,void*);
00084   long onDNDEnter(FXObject*,FXSelector,void*);
00085   long onDNDLeave(FXObject*,FXSelector,void*);
00086   long onDNDMotion(FXObject*,FXSelector,void*);
00087   long onDNDDrop(FXObject*,FXSelector,void*);
00088   long onDNDRequest(FXObject*,FXSelector,void*);
00089   long onSelectionLost(FXObject*,FXSelector,void*);
00090   long onSelectionGained(FXObject*,FXSelector,void*);
00091   long onSelectionRequest(FXObject*,FXSelector,void*);
00092   long onChanged(FXObject*,FXSelector,void*);
00093   long onCommand(FXObject*,FXSelector,void*);
00094   long onClicked(FXObject*,FXSelector,void*);
00095   long onDoubleClicked(FXObject*,FXSelector,void*);
00096   long onTripleClicked(FXObject*,FXSelector,void*);
00097   long onQueryHelp(FXObject*,FXSelector,void*);
00098   long onQueryTip(FXObject*,FXSelector,void*);
00099   long onCmdSetValue(FXObject*,FXSelector,void*);
00100   long onCmdSetIntValue(FXObject*,FXSelector,void*);
00101   long onCmdGetIntValue(FXObject*,FXSelector,void*);
00102   long onCmdColorWell(FXObject*,FXSelector,void*);
00103   long onChgColorWell(FXObject*,FXSelector,void*);
00104 public:
00105   enum {
00106     ID_COLORDIALOG=FXFrame::ID_LAST,
00107     ID_LAST
00108     };
00109 public:
00110 
00111   /// Construct color well with initial color clr
00112   FXColorWell(FXComposite* p,FXColor clr=0,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=COLORWELL_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD);
00113 
00114   /// Create server-side resources
00115   virtual void create();
00116 
00117   /// Detach server-side resources
00118   virtual void detach();
00119 
00120   /// Return default width
00121   virtual FXint getDefaultWidth();
00122 
00123   /// Return default height
00124   virtual FXint getDefaultHeight();
00125 
00126   /// Returns true because a color well can receive focus
00127   virtual FXbool canFocus() const;
00128 
00129   /// Move the focus to this window
00130   virtual void setFocus();
00131 
00132   /// Remove the focus from this window
00133   virtual void killFocus();
00134 
00135   /// Set color
00136   void setRGBA(FXColor clr);
00137 
00138   /// Get color
00139   FXColor getRGBA() const { return rgba; }
00140 
00141   /// Set status line help text for this color well
00142   void setHelpText(const FXString& text){ help=text; }
00143 
00144   /// Get status line help text for this color well
00145   FXString getHelpText() const { return help; }
00146 
00147   /// Set tool tip message for this color well
00148   void setTipText(const FXString& text){ tip=text; }
00149 
00150   /// Get tool tip message for this color well
00151   FXString getTipText() const { return tip; }
00152 
00153   /// Return true if only opaque colors allowed
00154   FXbool isOpaqueOnly() const;
00155 
00156   /// Change opaque only mode
00157   void setOpaqueOnly(FXbool opaque);
00158 
00159   /// Save color well to a stream
00160   virtual void save(FXStream& store) const;
00161 
00162   /// Load color well from a stream
00163   virtual void load(FXStream& store);
00164 
00165   /// Destructor
00166   virtual ~FXColorWell();
00167   };
00168 
00169 
00170 #endif