1 /******************************************************************************** 2 * * 3 * C o l o r W e l l W i d g e t * 4 * * 5 ********************************************************************************* 6 * Copyright (C) 1998,2005 by Jeroen van der Zijp. All Rights Reserved. * 7 ********************************************************************************* 8 * This library is free software; you can redistribute it and/or * 9 * modify it under the terms of the GNU Lesser General Public * 10 * License as published by the Free Software Foundation; either * 11 * version 2.1 of the License, or (at your option) any later version. * 12 * * 13 * This library is distributed in the hope that it will be useful, * 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 16 * Lesser General Public License for more details. * 17 * * 18 * You should have received a copy of the GNU Lesser General Public * 19 * License along with this library; if not, write to the Free Software * 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 21 ********************************************************************************* 22 * $Id: FXColorWell.h,v 1.33 2005/01/16 16:06:06 fox Exp $ * 23 ********************************************************************************/ 24 #ifndef FXCOLORWELL_H 25 #define FXCOLORWELL_H 26 27 #ifndef FXFRAME_H 28 #include "FXFrame.h" 29 #endif 30 31 namespace FX { 32 33 34 // Color Well Styles 35 enum { 36 COLORWELL_OPAQUEONLY = 0x00008000, /// Colors must be opaque 37 COLORWELL_SOURCEONLY = 0x00010000, /// ColorWell is never a target 38 COLORWELL_NORMAL = JUSTIFY_NORMAL 39 }; 40 41 42 43 /** 44 * A color well is a widget which controls color settings. 45 * Colors may be dragged and dropped from one color well to another. 46 * A double-click inside a color well will bring up the standard 47 * color dialog panel to edit the color well's color. 48 * Colors may be also pasted by name using middle-mouse click into/out of 49 * color wells from/to other selection-capable applications; for example, 50 * you can highlight the word `red' and paste it into a color well. 51 * While the color value is being changed, the color well sends a SEL_CHANGED 52 * to its target; at the end of the change, it sends a SEL_COMMAND. 53 * The message data represents the current color value, of the type FXColor. 54 */ 55 class FXAPI FXColorWell : public FXFrame { 56 FXDECLARE(FXColorWell) 57 protected: 58 FXColor wellColor[2]; // Pixel value of RGBA over black and white 59 FXColor rgba; // Color with RGB and Alpha 60 FXString tip; // Tooltip value 61 FXString help; // Help value 62 protected: 63 FXColorWell(); 64 static FXColor rgbaoverblack(FXColor clr); 65 static FXColor rgbaoverwhite(FXColor clr); 66 private: 67 FXColorWell(const FXColorWell&); 68 FXColorWell &operator=(const FXColorWell&); 69 public: 70 long onPaint(FXObject*,FXSelector,void*); 71 long onLeftBtnPress(FXObject*,FXSelector,void*); 72 long onLeftBtnRelease(FXObject*,FXSelector,void*); 73 long onMiddleBtnPress(FXObject*,FXSelector,void*); 74 long onMiddleBtnRelease(FXObject*,FXSelector,void*); 75 long onKeyPress(FXObject*,FXSelector,void*); 76 long onKeyRelease(FXObject*,FXSelector,void*); 77 long onUngrabbed(FXObject*,FXSelector,void*); 78 long onMotion(FXObject*,FXSelector,void*); 79 long onBeginDrag(FXObject*,FXSelector,void*); 80 long onEndDrag(FXObject*,FXSelector,void*); 81 long onDragged(FXObject*,FXSelector,void*); 82 long onFocusIn(FXObject*,FXSelector,void*); 83 long onFocusOut(FXObject*,FXSelector,void*); 84 long onDNDEnter(FXObject*,FXSelector,void*); 85 long onDNDLeave(FXObject*,FXSelector,void*); 86 long onDNDMotion(FXObject*,FXSelector,void*); 87 long onDNDDrop(FXObject*,FXSelector,void*); 88 long onDNDRequest(FXObject*,FXSelector,void*); 89 long onSelectionLost(FXObject*,FXSelector,void*); 90 long onSelectionGained(FXObject*,FXSelector,void*); 91 long onSelectionRequest(FXObject*,FXSelector,void*); 92 long onClicked(FXObject*,FXSelector,void*); 93 long onDoubleClicked(FXObject*,FXSelector,void*); 94 long onCmdSetValue(FXObject*,FXSelector,void*); 95 long onCmdSetIntValue(FXObject*,FXSelector,void*); 96 long onCmdGetIntValue(FXObject*,FXSelector,void*); 97 long onCmdColorWell(FXObject*,FXSelector,void*); 98 long onChgColorWell(FXObject*,FXSelector,void*); 99 long onCmdSetHelp(FXObject*,FXSelector,void*); 100 long onCmdGetHelp(FXObject*,FXSelector,void*); 101 long onCmdSetTip(FXObject*,FXSelector,void*); 102 long onCmdGetTip(FXObject*,FXSelector,void*); 103 long onQueryHelp(FXObject*,FXSelector,void*); 104 long onQueryTip(FXObject*,FXSelector,void*); 105 public: 106 enum { 107 ID_COLORDIALOG=FXFrame::ID_LAST, 108 ID_LAST 109 }; 110 public: 111 112 /// Construct color well with initial color clr 113 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); 114 115 /// Create server-side resources 116 virtual void create(); 117 118 /// Detach server-side resources 119 virtual void detach(); 120 121 /// Return default width 122 virtual FXint getDefaultWidth(); 123 124 /// Return default height 125 virtual FXint getDefaultHeight(); 126 127 /// Returns true because a color well can receive focus 128 virtual FXbool canFocus() const; 129 130 /// Move the focus to this window 131 virtual void setFocus(); 132 133 /// Remove the focus from this window 134 virtual void killFocus(); 135 136 /// Set color 137 void setRGBA(FXColor clr,FXbool notify=FALSE); 138 139 /// Get color getRGBA()140 FXColor getRGBA() const { return rgba; } 141 142 /// Set status line help text for this color well setHelpText(const FXString & text)143 void setHelpText(const FXString& text){ help=text; } 144 145 /// Get status line help text for this color well getHelpText()146 const FXString& getHelpText() const { return help; } 147 148 /// Set tool tip message for this color well setTipText(const FXString & text)149 void setTipText(const FXString& text){ tip=text; } 150 151 /// Get tool tip message for this color well getTipText()152 const FXString& getTipText() const { return tip; } 153 154 /// Return true if only opaque colors allowed 155 FXbool isOpaqueOnly() const; 156 157 /// Change opaque only mode 158 void setOpaqueOnly(FXbool opaque); 159 160 /// Save color well to a stream 161 virtual void save(FXStream& store) const; 162 163 /// Load color well from a stream 164 virtual void load(FXStream& store); 165 166 /// Destructor 167 virtual ~FXColorWell(); 168 }; 169 170 } 171 172 #endif 173