00001 // $Id: ccolbar.h 1282 2006-06-09 09:46:49Z alex $ 00002 // CColBar.h - The CColourBar class - A status-bar like colour strip bar thing 00003 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE 00004 ================================XARAHEADERSTART=========================== 00005 00006 Xara LX, a vector drawing and manipulation program. 00007 Copyright (C) 1993-2006 Xara Group Ltd. 00008 Copyright on certain contributions may be held in joint with their 00009 respective authors. See AUTHORS file for details. 00010 00011 LICENSE TO USE AND MODIFY SOFTWARE 00012 ---------------------------------- 00013 00014 This file is part of Xara LX. 00015 00016 Xara LX is free software; you can redistribute it and/or modify it 00017 under the terms of the GNU General Public License version 2 as published 00018 by the Free Software Foundation. 00019 00020 Xara LX and its component source files are distributed in the hope 00021 that it will be useful, but WITHOUT ANY WARRANTY; without even the 00022 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00023 See the GNU General Public License for more details. 00024 00025 You should have received a copy of the GNU General Public License along 00026 with Xara LX (see the file GPL in the root directory of the 00027 distribution); if not, write to the Free Software Foundation, Inc., 51 00028 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00029 00030 00031 ADDITIONAL RIGHTS 00032 ----------------- 00033 00034 Conditional upon your continuing compliance with the GNU General Public 00035 License described above, Xara Group Ltd grants to you certain additional 00036 rights. 00037 00038 The additional rights are to use, modify, and distribute the software 00039 together with the wxWidgets library, the wxXtra library, and the "CDraw" 00040 library and any other such library that any version of Xara LX relased 00041 by Xara Group Ltd requires in order to compile and execute, including 00042 the static linking of that library to XaraLX. In the case of the 00043 "CDraw" library, you may satisfy obligation under the GNU General Public 00044 License to provide source code by providing a binary copy of the library 00045 concerned and a copy of the license accompanying it. 00046 00047 Nothing in this section restricts any of the rights you have under 00048 the GNU General Public License. 00049 00050 00051 SCOPE OF LICENSE 00052 ---------------- 00053 00054 This license applies to this program (XaraLX) and its constituent source 00055 files only, and does not necessarily apply to other Xara products which may 00056 in part share the same code base, and are subject to their own licensing 00057 terms. 00058 00059 This license does not apply to files in the wxXtra directory, which 00060 are built into a separate library, and are subject to the wxWindows 00061 license contained within that directory in the file "WXXTRA-LICENSE". 00062 00063 This license does not apply to the binary libraries (if any) within 00064 the "libs" directory, which are subject to a separate license contained 00065 within that directory in the file "LIBS-LICENSE". 00066 00067 00068 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS 00069 ---------------------------------------------- 00070 00071 Subject to the terms of the GNU Public License (see above), you are 00072 free to do whatever you like with your modifications. However, you may 00073 (at your option) wish contribute them to Xara's source tree. You can 00074 find details of how to do this at: 00075 http://www.xaraxtreme.org/developers/ 00076 00077 Prior to contributing your modifications, you will need to complete our 00078 contributor agreement. This can be found at: 00079 http://www.xaraxtreme.org/developers/contribute/ 00080 00081 Please note that Xara will not accept modifications which modify any of 00082 the text between the start and end of this header (marked 00083 XARAHEADERSTART and XARAHEADEREND). 00084 00085 00086 MARKS 00087 ----- 00088 00089 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara 00090 designs are registered or unregistered trademarks, design-marks, and/or 00091 service marks of Xara Group Ltd. All rights in these marks are reserved. 00092 00093 00094 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK. 00095 http://www.xara.com/ 00096 00097 =================================XARAHEADEREND============================ 00098 */ 00099 00100 00101 #ifndef INC_CCOLBAR 00102 #define INC_CCOLBAR 00103 00104 #include "collist.h" 00105 //#include "doccolor.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00106 #include "gbrush.h" 00107 //#include "pump.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00108 //#include "dragtrgt.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00109 00110 class CColourBar; 00111 00112 /********************************************************************************************* 00113 00114 > class EditButtonDragTarget : public OilDragTarget 00115 00116 Author: Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>. 00117 Created: 2/1/95 00118 00119 Purpose: An instantiation of this class is created by each entity which wishes to 00120 provide a 'destination' to which the mouse can go to complete a drag. 00121 WinoilDragTargets are used as a base class from which to derive drag targets 00122 for WINOIL entities (an optional wxWindow*) 00123 00124 Notes: Drag targets are destructed automatically when a drag finishes by the drag 00125 manager with which they were registered. 00126 00127 To remove a drag target at any time, destruct it - it automatically deregisters 00128 and cleans up. 00129 00130 SeeAlso: DragManagerOp::StartDrag; DragInformation; DragTarget 00131 00132 Documentation: Docs\Specs\DragMan.doc 00133 00134 *********************************************************************************************/ 00135 00136 class EditButtonDragTarget : public OilDragTarget 00137 { 00138 friend class DragManagerOp; 00139 00140 CC_DECLARE_DYNAMIC(EditButtonDragTarget) 00141 00142 public: // Public interface 00143 EditButtonDragTarget(wxWindow* TheWindow, wxRect *ClientArea = NULL); 00144 00145 virtual UINT32 GetCursorID(); 00146 virtual BOOL GetStatusLineText(String_256 * TheText); 00147 00148 protected: 00149 // Process a drag-related event 00150 BOOL ProcessEvent(DragEventType Event, 00151 DragInformation *pDragInfo, 00152 wxPoint *pMousePos, KeyPress* pKeyPress); 00153 00154 // Internal helper function 00155 BOOL CanDropHere(DragInformation *pDragInfo); 00156 }; 00157 00158 00159 00160 00161 00162 /********************************************************************************************* 00163 00164 > class ColourLineDragTarget : public OilDragTarget 00165 00166 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00167 Created: 20/11/95 00168 00169 Purpose: An instantiation of this class is created by each entity which wishes to 00170 provide a 'destination' to which the mouse can go to complete a drag. 00171 WinoilDragTargets are used as a base class from which to derive drag targets 00172 for WINOIL entities (an optional wxWindow*) 00173 00174 Notes: Drag targets are destructed automatically when a drag finishes by the drag 00175 manager with which they were registered. 00176 00177 To remove a drag target at any time, destruct it - it automatically deregisters 00178 and cleans up. 00179 00180 SeeAlso: DragManagerOp::StartDrag; DragInformation; DragTarget 00181 00182 Documentation: Docs\Specs\DragMan.doc 00183 00184 *********************************************************************************************/ 00185 00186 class ColourLineDragTarget : public OilDragTarget 00187 { 00188 friend class DragManagerOp; 00189 00190 CC_DECLARE_DYNAMIC(ColourLineDragTarget) 00191 00192 public: // Public interface 00193 ColourLineDragTarget(wxWindow* TheWindow, wxRect *ClientArea = NULL); 00194 00195 virtual UINT32 GetCursorID(); 00196 virtual BOOL GetStatusLineText(String_256 * TheText); 00197 00198 protected: 00199 // Process a drag-related event 00200 BOOL ProcessEvent(DragEventType Event, 00201 DragInformation *pDragInfo, 00202 wxPoint *pMousePos, KeyPress* pKeyPress); 00203 }; 00204 00205 00206 00207 00208 00209 /******************************************************************************************** 00210 00211 > class ColourBarMsgHandler : public MessageHandler 00212 00213 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00214 Created: 05/05/94 00215 Purpose: Intercepts messages for the Colour Bar 00216 (Keeps the Colourabout which document is selected) 00217 00218 ********************************************************************************************/ 00219 00220 class ColourBarMsgHandler : public MessageHandler 00221 { 00222 friend class CCColorBar; 00223 public: 00224 CC_DECLARE_DYNAMIC( ColourBarMsgHandler ) 00225 ColourBarMsgHandler(); // Constructor 00226 00227 protected: 00228 MsgResult Message(Msg* Msg); // Overridden message reciever 00229 }; 00230 00231 00232 00233 00234 // Colour Bar drag information storage: 00235 // Drags occur when dragging the scroll bar, and for implementing auto-repeat on buttons 00236 typedef struct 00237 { 00238 BOOL MouseCaptured; // TRUE if we have captured the mouse (are dragging) 00239 UINT32 TimerOn; // 0 or a timer ID if we have a timer event pending 00240 wxPoint LastMousePos; // The last recorded mouse position 00241 INT32 DragItem; // The cell/button/area in which the drag started 00242 UINT32 AnchorOffset; // Offset of drag anchor point (Pixel/CellIndex) 00243 BOOL Adjust; // This is an 'adjust' drag 00244 } CBDragInfo; 00245 00246 00247 typedef enum // Colour types (for drawing 'diamond' indicators) 00248 { 00249 CBCOLOUR_LINE, // Line colour 00250 CBCOLOUR_FILL, // FlatFill or GradStart colour 00251 CBCOLOUR_END, // Grad end colour 00252 00253 CBCOLOUR_START // Grad start colour - NOTE that normally we only use 00254 // line/fill/end, except when drawing diamonds in which 00255 // case Fill means full diamond while Start means a 00256 // up-arrow half-diamond shape. 00257 } CBColourType; 00258 00259 00260 // Forward declarations 00261 class Cursor; 00262 class AttrFillGeometry; 00263 class AttrStrokeColour; 00264 class ColourSGallery; 00265 class SGDisplayLibColour; 00266 00267 /******************************************************************************** 00268 00269 > class CColourBar : public CControlBar 00270 00271 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00272 Created: 17/6/94 00273 Purpose: The CColourBar window - a window like the status bar, 00274 which contains a strip of colours that can be used in the 00275 selected Document. 00276 00277 ********************************************************************************/ 00278 00279 // Hierarchy: wxWindow -> CColourBar 00280 00281 00282 class CColourBar : public wxWindow 00283 { 00284 DECLARE_DYNAMIC_CLASS(CColourBar) 00285 00286 friend class ColourBarMsgHandler; 00287 friend class ColourDragInformation; 00288 friend class EditButtonDragTarget; 00289 friend class ColourLineDragTarget; 00290 00291 public: // Construction/destruction and kernel interface 00292 CColourBar(); 00293 virtual ~CColourBar(); 00294 00295 BOOL Create(wxWindow* parent, UINT32 id); 00296 00297 virtual wxSize DoGetBestSize() const; 00298 00299 // void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHandler); 00300 00301 // winoil\gbrush.cpp interface - force a redraw when gbrush is toggled on/off 00302 static void RedrawGBrushAreas(void); 00303 00304 // Kernel interface methods 00305 void SetSizes(INT32 NewCellSize, INT32 NewScrollbarSize); // To set the colour cell/scrollbar sizes 00306 static void Show(BOOL HideOrShow = FALSE); // To hide/show the window 00307 static void SetDisplayMode(INT32 NewDisplayMode = -1); // To set new display mode 00308 00309 static BOOL GetStatusLineText(String_256 *Result); // To get status line help text 00310 00311 static CColourBar* GetColourBar() { return(TheColourBar); } 00312 00313 protected: // Windows OIL message handlers and related functions 00314 void DoPaint(wxDC* pDC); 00315 00316 void OnPaint(wxPaintEvent &event); 00317 00318 void OnSize(wxSizeEvent &event); 00319 // LRESULT OnSizeParent(WPARAM, LPARAM lParam); 00320 void OnLButtonDown(wxMouseEvent& event); 00321 void OnRButtonDown(wxMouseEvent& event); 00322 void OnLButtonDblClk(wxMouseEvent& event); 00323 void OnRButtonDblClk(wxMouseEvent& event); 00324 void OnLButtonUp(wxMouseEvent& event); 00325 void OnRButtonUp(wxMouseEvent& event); 00326 void OnMouseMove(wxMouseEvent& event); 00327 void OnTimer(wxTimerEvent& event); 00328 // void OnCancelMode(void); 00329 00330 00331 protected: // Internal data members 00332 static CColourBar *TheColourBar; // The 1 and only instantiation of this class 00333 static BOOL BarIsVisible; // TRUE if the bar thinks it is/should be visible 00334 00335 INT32 m_cxLeftBorder; 00336 INT32 m_cyTopBorder; 00337 INT32 m_cxRightBorder; 00338 INT32 m_cyBottomBorder; 00339 00340 UINT32 LeftmostColour; // Index of leftmost colour in the display 00341 UINT32 TotalNumColours; // Num of displayable cols in cur. col. list 00342 00343 INT32 LastLineCell; // Last cell we redrew line-colour diamond in 00344 INT32 LastFillCell; // Last cell we redrew (start-grad-)fill-colour diamond in 00345 INT32 LastEndCell; // Last cell we redrew end-grad-fill-colour diamond in 00346 BOOL LastDiamondShape; // Last diamond shape (plus/diamond) drawn 00347 00348 INT32 IndentedButton; // CLICKED_NOTHING or id of currently indented button 00349 00350 ColourList *m_pCurrentColourList; // Current list of colours to display 00351 00352 ColourBarMsgHandler *MsgHandler; 00353 00354 wxRect WindowRect; // whole redrawable window bounds 00355 wxRect StripRect; // The colour strip 00356 wxRect IndicatorRect; // The current colour indicator 00357 wxRect ScrollBarRect; // The proportional scroll bar 00358 wxRect EditButtonRect; // The 'edit colour' button 00359 wxRect NewButtonRect; // The 'new colour' button 00360 00361 INT32 OldBarHeight; // The last known height of the bar window 00362 00363 wxTimer m_DragTimer; 00364 00365 ColourSGallery *m_pColourGallery; // Current colour gallery storing fixed colour lists 00366 00367 public: 00368 INT32 GetNumberOfColours(); 00369 00370 static BOOL EnsureLibraryColoursPresent(); 00371 00372 // colour picker custom control interface functions .... 00373 00374 BOOL IsColourPickerOverStripRect (wxWindow* colourPicker, wxPoint mousePt); 00375 BOOL DoColourPickerColour (wxWindow* colourPicker, wxPoint mousePt, IndexedColour ** pTheCol=NULL); 00376 00377 protected: // Internal subroutine functions 00378 BOOL HasNoScrollBar(INT32 DisplayedColours, INT32 MaxColours, wxRect *pStripRect = NULL); 00379 00380 void CalculateRects(void); 00381 void CalculateRectsInternal(wxRect *pWindowRect, 00382 wxRect *pStripRect, wxRect *pIndicatorRect, wxRect *pScrollBarRect, 00383 wxRect *pEditButtonRect, wxRect *pNewButtonRect); 00384 00385 BOOL CalculateSausageRect(wxRect *Result); 00386 void CalculateNoColourCellRect(wxRect *Rect); 00387 00388 static INT32 GetCurrentBarHeight(void); 00389 INT32 CalculateNewBarHeight(wxRect *AvailableRect); 00390 00391 INT32 CalculateColourCellIndex(IndexedColour *TheColour); 00392 INT32 CalculateColourCellIndex(DocColour *TheColour); 00393 00394 void OnAnyButtonUp(const wxPoint &point); 00395 void OnAnyButtonDown(const wxPoint &point, INT32 Modifier); 00396 void OnAnyButtonDblClk(wxPoint point, INT32 Modifier); 00397 void EditAColour(ColourList *DisplayList, IndexedColour *TheColour, BOOL LineColour = FALSE); 00398 00399 INT32 WhereIsMouse(wxPoint MousePos, wxRect *TheRectItIsIn = NULL, BOOL *ToLeft = NULL); 00400 void ApplyColour(IndexedColour *TheColour, BOOL SetLineColour); 00401 void CellClicked(INT32 CellIndex, BOOL SetLineColour); 00402 static TCHAR *HelpCallbackHandler(wxWindow* Window, INT32 Item, void *This); 00403 00404 // This returns the nth document colour 00405 IndexedColour *FindColourByIndex(UINT32 Index); 00406 00407 // This is the equivalent to return the nth library colour 00408 // Index should include the document colours as these will be removed 00409 DocColour * FindLibColourByIndex(UINT32 Index, SGDisplayLibColour **ppLibColour = NULL); 00410 IndexedColour * FindLibIndexedColourByIndex(UINT32 Index); 00411 00412 protected: // Internal redraw handlers 00413 void PaintColourCell(wxDC *pDC, wxRect *Rect, DocColour *RectCol); 00414 void PaintNoColourCell(wxDC *pDC); 00415 void PaintIndicatorDiamond(wxDC *pDC, const wxRect &CellRect, CBColourType ColourType, 00416 INT32 CellIndex, BOOL DiamondType); 00417 void PaintColourStrip(wxDC *pDC, const wxRect &ClipRect); 00418 void PaintIndicators(wxDC *pDC); 00419 void PaintEditOrNewButton(wxDC *pDC, BOOL Normal, BOOL IsEditButton); 00420 void PaintScrollButton(wxDC *pDC, INT32 ButtonID, BOOL Normal); 00421 void PaintScrollBar(wxDC *pDC); 00422 void PaintLibColourCell(wxDC *pDC, wxRect *Rect, DocColour *RectCol, BOOL SpotColour = FALSE); 00423 00424 void ForceRedrawOfCell(INT32 CellIndex); 00425 void ForceRedrawOfCell(DocColour *TheColour); 00426 void ForceRedrawOfRect(const wxRect &RectToDraw); 00427 void ScrollTheStrip(INT32 ScrollBy, BOOL RedrawAlways = FALSE); 00428 00429 00430 protected: // Drag/AutoRepeat support functions 00431 CBDragInfo DragInfo; 00432 00433 void CaptureTheMouse(void); 00434 void SetATimer(BOOL Delay); 00435 void ReleaseAllClaims(void); 00436 00437 BOOL InitPrefs(void); 00438 00439 00440 protected: // Push-mode stuff 00441 Cursor *PushCursor; 00442 00443 00444 protected: // GDraw Brush stuff 00445 GBrush GDrawBrush; 00446 00447 wxBrush *GetColourBrush(COLORREF rgb); 00448 00449 00450 protected: // Interface for friend class ColourBarMsgHandler 00451 static void PaletteHasChanged(ColourList *ChangedList = NULL); 00452 static void SelectionHasChanged(void); 00453 00454 void SelectionHasChangedInternal(void); 00455 00456 DECLARE_EVENT_TABLE() 00457 }; 00458 00459 00460 #endif 00461 00462