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

FXColorWell.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                         C o l o r W e l l   W i d g e t                       *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1998,2006 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.35 2006/01/22 17:57:59 fox Exp $                       *
00023 ********************************************************************************/
00024 #ifndef FXCOLORWELL_H
00025 #define FXCOLORWELL_H
00026 
00027 #ifndef FXFRAME_H
00028 #include "FXFrame.h"
00029 #endif
00030 
00031 namespace FX {
00032 
00033 
00034 // Color Well Styles
00035 enum {
00036   COLORWELL_OPAQUEONLY = 0x00008000,  /// Colors must be opaque
00037   COLORWELL_SOURCEONLY = 0x00010000,  /// ColorWell is never a target
00038   COLORWELL_NORMAL     = JUSTIFY_NORMAL
00039   };
00040 
00041 
00042 
00043 /**
00044 * A color well is a widget which controls color settings.
00045 * Colors may be dragged and dropped from one color well to another.
00046 * A double-click inside a color well will bring up the standard
00047 * color dialog panel to edit the color well's color.
00048 * Colors may be also pasted by name using middle-mouse click into/out of
00049 * color wells from/to other selection-capable applications; for example,
00050 * you can highlight the word `red' and paste it into a color well.
00051 * While the color value is being changed, the color well sends a SEL_CHANGED
00052 * to its target; at the end of the change, it sends a SEL_COMMAND.
00053 * The message data represents the current color value, of the type FXColor.
00054 */
00055 class FXAPI FXColorWell : public FXFrame {
00056   FXDECLARE(FXColorWell)
00057 protected:
00058   FXColor   wellColor[2];             // Pixel value of RGBA over black and white
00059   FXColor   rgba;                     // Color with RGB and Alpha
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 onClicked(FXObject*,FXSelector,void*);
00093   long onDoubleClicked(FXObject*,FXSelector,void*);
00094   long onCmdSetValue(FXObject*,FXSelector,void*);
00095   long onCmdSetIntValue(FXObject*,FXSelector,void*);
00096   long onCmdGetIntValue(FXObject*,FXSelector,void*);
00097   long onCmdColorWell(FXObject*,FXSelector,void*);
00098   long onChgColorWell(FXObject*,FXSelector,void*);
00099   long onCmdSetHelp(FXObject*,FXSelector,void*);
00100   long onCmdGetHelp(FXObject*,FXSelector,void*);
00101   long onCmdSetTip(FXObject*,FXSelector,void*);
00102   long onCmdGetTip(FXObject*,FXSelector,void*);
00103   long onQueryHelp(FXObject*,FXSelector,void*);
00104   long onQueryTip(FXObject*,FXSelector,void*);
00105 public:
00106   enum {
00107     ID_COLORDIALOG=FXFrame::ID_LAST,
00108     ID_LAST
00109     };
00110 public:
00111 
00112   /// Construct color well with initial color clr
00113   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);
00114 
00115   /// Create server-side resources
00116   virtual void create();
00117 
00118   /// Detach server-side resources
00119   virtual void detach();
00120 
00121   /// Return default width
00122   virtual FXint getDefaultWidth();
00123 
00124   /// Return default height
00125   virtual FXint getDefaultHeight();
00126 
00127   /// Returns true because a color well can receive focus
00128   virtual bool canFocus() const;
00129 
00130   /// Move the focus to this window
00131   virtual void setFocus();
00132 
00133   /// Remove the focus from this window
00134   virtual void killFocus();
00135 
00136   /// Set color
00137   void setRGBA(FXColor clr,FXbool notify=FALSE);
00138 
00139   /// Get color
00140   FXColor getRGBA() const { return rgba; }
00141 
00142   /// Set status line help text for this color well
00143   void setHelpText(const FXString& text){ help=text; }
00144 
00145   /// Get status line help text for this color well
00146   const FXString& getHelpText() const { return help; }
00147 
00148   /// Set tool tip message for this color well
00149   void setTipText(const FXString& text){ tip=text; }
00150 
00151   /// Get tool tip message for this color well
00152   const FXString& getTipText() const { return tip; }
00153 
00154   /// Return true if only opaque colors allowed
00155   FXbool isOpaqueOnly() const;
00156 
00157   /// Change opaque only mode
00158   void setOpaqueOnly(FXbool opaque);
00159 
00160   /// Save color well to a stream
00161   virtual void save(FXStream& store) const;
00162 
00163   /// Load color well from a stream
00164   virtual void load(FXStream& store);
00165 
00166   /// Destructor
00167   virtual ~FXColorWell();
00168   };
00169 
00170 }
00171 
00172 #endif

Copyright © 1997-2005 Jeroen van der Zijp