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,2009 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (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                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 *********************************************************************************
00021 * $Id: FXColorWell.h,v 1.42 2009/01/06 13:07:22 fox Exp $                       *
00022 ********************************************************************************/
00023 #ifndef FXCOLORWELL_H
00024 #define FXCOLORWELL_H
00025 
00026 #ifndef FXFRAME_H
00027 #include "FXFrame.h"
00028 #endif
00029 
00030 namespace FX {
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   FXString  tip;                      // Tooltip value
00060   FXString  help;                     // Help value
00061 protected:
00062   FXColorWell();
00063   static FXColor rgbaoverblack(FXColor clr);
00064   static FXColor rgbaoverwhite(FXColor clr);
00065 private:
00066   FXColorWell(const FXColorWell&);
00067   FXColorWell &operator=(const FXColorWell&);
00068 public:
00069   long onPaint(FXObject*,FXSelector,void*);
00070   long onLeftBtnPress(FXObject*,FXSelector,void*);
00071   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00072   long onMiddleBtnPress(FXObject*,FXSelector,void*);
00073   long onMiddleBtnRelease(FXObject*,FXSelector,void*);
00074   long onKeyPress(FXObject*,FXSelector,void*);
00075   long onKeyRelease(FXObject*,FXSelector,void*);
00076   long onUngrabbed(FXObject*,FXSelector,void*);
00077   long onMotion(FXObject*,FXSelector,void*);
00078   long onBeginDrag(FXObject*,FXSelector,void*);
00079   long onEndDrag(FXObject*,FXSelector,void*);
00080   long onDragged(FXObject*,FXSelector,void*);
00081   long onFocusIn(FXObject*,FXSelector,void*);
00082   long onFocusOut(FXObject*,FXSelector,void*);
00083   long onDNDEnter(FXObject*,FXSelector,void*);
00084   long onDNDLeave(FXObject*,FXSelector,void*);
00085   long onDNDMotion(FXObject*,FXSelector,void*);
00086   long onDNDDrop(FXObject*,FXSelector,void*);
00087   long onDNDRequest(FXObject*,FXSelector,void*);
00088   long onSelectionLost(FXObject*,FXSelector,void*);
00089   long onSelectionGained(FXObject*,FXSelector,void*);
00090   long onSelectionRequest(FXObject*,FXSelector,void*);
00091   long onClicked(FXObject*,FXSelector,void*);
00092   long onDoubleClicked(FXObject*,FXSelector,void*);
00093   long onCmdSetValue(FXObject*,FXSelector,void*);
00094   long onCmdSetIntValue(FXObject*,FXSelector,void*);
00095   long onCmdGetIntValue(FXObject*,FXSelector,void*);
00096   long onCmdSetHelp(FXObject*,FXSelector,void*);
00097   long onCmdGetHelp(FXObject*,FXSelector,void*);
00098   long onCmdSetTip(FXObject*,FXSelector,void*);
00099   long onCmdGetTip(FXObject*,FXSelector,void*);
00100   long onQueryHelp(FXObject*,FXSelector,void*);
00101   long onQueryTip(FXObject*,FXSelector,void*);
00102   long onUpdColor(FXObject*,FXSelector,void*);
00103   long onChgColor(FXObject*,FXSelector,void*);
00104   long onCmdColor(FXObject*,FXSelector,void*);
00105 public:
00106   enum {
00107     ID_COLOR=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 FXbool 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-2009 Jeroen van der Zijp