00001 // $Id: colpick.h 1282 2006-06-09 09:46:49Z alex $ 00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE 00003 ================================XARAHEADERSTART=========================== 00004 00005 Xara LX, a vector drawing and manipulation program. 00006 Copyright (C) 1993-2006 Xara Group Ltd. 00007 Copyright on certain contributions may be held in joint with their 00008 respective authors. See AUTHORS file for details. 00009 00010 LICENSE TO USE AND MODIFY SOFTWARE 00011 ---------------------------------- 00012 00013 This file is part of Xara LX. 00014 00015 Xara LX is free software; you can redistribute it and/or modify it 00016 under the terms of the GNU General Public License version 2 as published 00017 by the Free Software Foundation. 00018 00019 Xara LX and its component source files are distributed in the hope 00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the 00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00022 See the GNU General Public License for more details. 00023 00024 You should have received a copy of the GNU General Public License along 00025 with Xara LX (see the file GPL in the root directory of the 00026 distribution); if not, write to the Free Software Foundation, Inc., 51 00027 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00028 00029 00030 ADDITIONAL RIGHTS 00031 ----------------- 00032 00033 Conditional upon your continuing compliance with the GNU General Public 00034 License described above, Xara Group Ltd grants to you certain additional 00035 rights. 00036 00037 The additional rights are to use, modify, and distribute the software 00038 together with the wxWidgets library, the wxXtra library, and the "CDraw" 00039 library and any other such library that any version of Xara LX relased 00040 by Xara Group Ltd requires in order to compile and execute, including 00041 the static linking of that library to XaraLX. In the case of the 00042 "CDraw" library, you may satisfy obligation under the GNU General Public 00043 License to provide source code by providing a binary copy of the library 00044 concerned and a copy of the license accompanying it. 00045 00046 Nothing in this section restricts any of the rights you have under 00047 the GNU General Public License. 00048 00049 00050 SCOPE OF LICENSE 00051 ---------------- 00052 00053 This license applies to this program (XaraLX) and its constituent source 00054 files only, and does not necessarily apply to other Xara products which may 00055 in part share the same code base, and are subject to their own licensing 00056 terms. 00057 00058 This license does not apply to files in the wxXtra directory, which 00059 are built into a separate library, and are subject to the wxWindows 00060 license contained within that directory in the file "WXXTRA-LICENSE". 00061 00062 This license does not apply to the binary libraries (if any) within 00063 the "libs" directory, which are subject to a separate license contained 00064 within that directory in the file "LIBS-LICENSE". 00065 00066 00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS 00068 ---------------------------------------------- 00069 00070 Subject to the terms of the GNU Public License (see above), you are 00071 free to do whatever you like with your modifications. However, you may 00072 (at your option) wish contribute them to Xara's source tree. You can 00073 find details of how to do this at: 00074 http://www.xaraxtreme.org/developers/ 00075 00076 Prior to contributing your modifications, you will need to complete our 00077 contributor agreement. This can be found at: 00078 http://www.xaraxtreme.org/developers/contribute/ 00079 00080 Please note that Xara will not accept modifications which modify any of 00081 the text between the start and end of this header (marked 00082 XARAHEADERSTART and XARAHEADEREND). 00083 00084 00085 MARKS 00086 ----- 00087 00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara 00089 designs are registered or unregistered trademarks, design-marks, and/or 00090 service marks of Xara Group Ltd. All rights in these marks are reserved. 00091 00092 00093 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK. 00094 http://www.xara.com/ 00095 00096 =================================XARAHEADEREND============================ 00097 */ 00098 00099 // colpick.h - The Colour Picker dialogue 00100 00101 #ifndef INC_COLPICK 00102 #define INC_COLPICK 00103 00104 //#include "colmodel.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00105 00106 class ColourList; 00107 class ColourContext; 00108 class IndexedColour; 00109 class String_8; 00110 class NewColourDlg; 00111 class ColourEditDlg; 00112 00113 /******************************************************************************************** 00114 00115 > class ColourPicker 00116 00117 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00118 Created: 13/5/95 00119 Purpose: Encapsulates OS-specific colour picker dialogue system, giving a 00120 kernel interface for using whatever colour picker(s) are available 00121 00122 Given a (named or unnamed) IndexedColour, a Colour Picker somehow 00123 provides a user interface to change it, and returns the colour, 00124 cleaner and brighter than you ever thought possible, and for only 00125 about the same price as you'd expect to pay for an inferior colour 00126 picker. 1 out of 10 home economists prefer our colour picker to 00127 all others. 00128 00129 This class also provides secrel-squirrel interfaces for doing 00130 rather horrendous direct-pokey Coloue Editor things to IndexedColours. 00131 These are only available to our friend editor dialogue classes. 00132 00133 Friends: ColourEditDlg; ColourLinkDlg 00134 SeeAlso: IndexedColour; ColourEditDlg; ColourLinkDlg 00135 00136 ********************************************************************************************/ 00137 00138 class CCAPI ColourPicker : public CCObject 00139 { 00140 CC_DECLARE_MEMDUMP(ColourPicker) 00141 00142 friend class ColourEditDlg; 00143 friend class ColourLinkDlg; 00144 friend class NewColourDlg; 00145 00146 public: 00147 ColourPicker(); 00148 ~ColourPicker(); 00149 00150 00151 public: // Entire enduser interface 00152 void EditColour(ColourList *ParentList, IndexedColour *SourceAndResult, 00153 BOOL PreferLineColour = FALSE); 00154 // Edit a specific IndexedColour 00155 00156 public: // Status line/Bubble help interface 00157 // Get status line help text for the current pointer position 00158 static BOOL GetStatusLineText(String_256 *Result); 00159 00160 // Update bubble help and mouse pointer shape (call on MouseMoves) 00161 static void UpdateBubbleHelpAndPointer(void); 00162 00163 static void SetBubbleHelp(CGadgetID * GadgetList); 00164 00165 protected: 00166 // Internal variant of the above 00167 static BOOL GetStatusLineText(ColourEditDlg *Editor, UINT32 GadgetID, String_256 *Result); 00168 00169 static TCHAR *HelpCallbackHandler(CWindowID Window, UINT32 Item, void *UserData); 00170 static BOOL GetComponentHelp(ColourContext* const pSourceContext, 00171 const UINT32 ComponentIndex, StringBase& HelpString); 00172 00173 00174 protected: // Interfaces strictly for use by the kernel ColourEditDlg/ColourLinkDlg classes 00175 00176 // Read a component from a colour, and return a decimal string 00177 // representation, in the given output colour model 00178 static BOOL GetComponentAsString(IndexedColour *Source, 00179 ColourContext *DestContext, INT32 ComponentIndex, 00180 String_8 *Result); 00181 00182 static BOOL GetComponentsAsHexString(IndexedColour *Source, 00183 ColourContext *DestContext, INT32 ComponentIndex, 00184 String_16 *Result); 00185 00186 // Set a component value from a given decimal string value 00187 // Forces the colour into the given colour model 00188 static BOOL SetComponentFromString(IndexedColour *Dest, 00189 ColourContext *SourceContext, INT32 ComponentIndex, 00190 String_8 *NewValue); 00191 00192 // Set a component value from a given hexadecimal string value 00193 // Forces the colour into the given colour model 00194 static BOOL SetComponentsFromHexString(IndexedColour *Dest, 00195 ColourContext *SourceContext, 00196 String_16 *NewValue); 00197 00198 static BOOL IsValidHexString (String_16 Hex); 00199 // private helper function for ColourPicker::SetComponentsFromHexString 00200 // DON'T CALL THIS AS IT ONLY EXISTS TO HELP THE ABOVE FUNCTION - AND I 00201 // CANNOT SEE WHY YOUR CALLING THIS FROM ELSEWHERE ANYWAY .... 00202 00203 // Set a component value from a given double value 00204 // Forces the colour into the given colour model 00205 static BOOL SetComponentFromDouble(IndexedColour *Dest, 00206 ColourContext *SourceContext, INT32 ComponentIndex, 00207 double NewValue); 00208 00209 // Force a colour to be in the given colour model 00210 static void ForceColourModel(IndexedColour *Dest, ColourContext *SourceContext); 00211 00212 // Read the tint from a colour, and return a decimal string 00213 // representation, in the given output colour model 00214 // Ensures and returns 0.0 iff the colour is not a tint. 00215 static BOOL GetTintAsString(IndexedColour *Source, StringBase *Result); 00216 00217 // Set a tint value from a given decimal string value 00218 // Ensures and does nothing further if the colour is not a tint 00219 static BOOL SetTintFromString(IndexedColour *Dest, StringBase *NewValue); 00220 00221 // Read the shade value (1=x or 2=y) from a colour, and return a decimal string 00222 // representation, as -100..+100 00223 // Ensures and returns 0.0 iff the colour is not a shade. 00224 static BOOL GetShadeValueAsString(IndexedColour *Source, INT32 ValueIndex, StringBase *Result); 00225 00226 // Set a shade from a given pair of decimal string values (-100..+100) 00227 // Ensures and does nothing further if the colour is not a shade 00228 static BOOL SetShadeFromStrings(IndexedColour *Dest, StringBase *NewValueX, StringBase *NewValueY); 00229 00230 // Set the extent of a window to barely include the given gadgets 00231 // (in the X and Y axes respectively) 00232 // (Used for folding/unfolding the colour editor dialogue) 00233 static void SetWindowExtent(CWindowID WindowID, CGadgetID XGadgetID, CGadgetID YGadgetID); 00234 00235 // Moves all gadgets in NULL-terminated Gadgets list to lie under the 00236 // given gadget (does not affect X position) (The offset to the first 00237 // gadget in the list is used to calculate the amount by which to move all) 00238 // If MoveUnder == NULL, then all gadgets are moved downwards enough to 00239 // ensure they are not visible in the window. 00240 static void SetGadgetPositions(CWindowID WindowID, 00241 CGadgetID *Gadgets, CGadgetID MoveUnder); 00242 00243 // Highly nasty. Spaces out the 4 component gadgets in an appropriate fashion 00244 static void SetComponentGadgets(CWindowID WindowID, CGadgetID *Gadgets, 00245 CGadgetID PickerGadget, 00246 ColourModel ModelToDisplay); 00247 static void SetFixedComponentGadgets(CWindowID WindowID, CGadgetID *Gadgets, 00248 CGadgetID PickerGadget, 00249 ColourModel ModelToDisplay, 00250 INT32 TextWidth[], 00251 INT32 EditWidth[]); 00252 00253 static void RelayoutDialog(CWindowID WindowID); 00254 static void OnSize(CWindowID WindowID); 00255 static void RecursiveBestSize(wxWindow * pwxWindow); 00256 static BOOL OnIdleEvent(CWindowID WindowID); 00257 static void OnCreate(CWindowID WindowID); 00258 static void ArtificialSizeEvents(CWindowID WindowID); 00259 00260 private: 00261 static wxSize s_LastSize; 00262 static wxSize s_UserSize; 00263 static wxSize s_MinSize; 00264 static BOOL s_InColourDialogLayout; 00265 static BOOL s_JustCreated; 00266 static INT32 s_IdleCounter; 00267 00268 }; 00269 00270 00271 #endif 00272 00273