Bugfix : Zooming works correct, no more errors on screen.
[xara-cairo.git] / wxOil / oilruler.h
blob916b3862bd41348cc156ddb5f5cf333ab05d2b0b
1 // $Id: oilruler.h 1459 2006-07-17 17:35:57Z phil $
2 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
3 ================================XARAHEADERSTART===========================
5 Xara LX, a vector drawing and manipulation program.
6 Copyright (C) 1993-2006 Xara Group Ltd.
7 Copyright on certain contributions may be held in joint with their
8 respective authors. See AUTHORS file for details.
10 LICENSE TO USE AND MODIFY SOFTWARE
11 ----------------------------------
13 This file is part of Xara LX.
15 Xara LX is free software; you can redistribute it and/or modify it
16 under the terms of the GNU General Public License version 2 as published
17 by the Free Software Foundation.
19 Xara LX and its component source files are distributed in the hope
20 that it will be useful, but WITHOUT ANY WARRANTY; without even the
21 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22 See the GNU General Public License for more details.
24 You should have received a copy of the GNU General Public License along
25 with Xara LX (see the file GPL in the root directory of the
26 distribution); if not, write to the Free Software Foundation, Inc., 51
27 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 ADDITIONAL RIGHTS
31 -----------------
33 Conditional upon your continuing compliance with the GNU General Public
34 License described above, Xara Group Ltd grants to you certain additional
35 rights.
37 The additional rights are to use, modify, and distribute the software
38 together with the wxWidgets library, the wxXtra library, and the "CDraw"
39 library and any other such library that any version of Xara LX relased
40 by Xara Group Ltd requires in order to compile and execute, including
41 the static linking of that library to XaraLX. In the case of the
42 "CDraw" library, you may satisfy obligation under the GNU General Public
43 License to provide source code by providing a binary copy of the library
44 concerned and a copy of the license accompanying it.
46 Nothing in this section restricts any of the rights you have under
47 the GNU General Public License.
50 SCOPE OF LICENSE
51 ----------------
53 This license applies to this program (XaraLX) and its constituent source
54 files only, and does not necessarily apply to other Xara products which may
55 in part share the same code base, and are subject to their own licensing
56 terms.
58 This license does not apply to files in the wxXtra directory, which
59 are built into a separate library, and are subject to the wxWindows
60 license contained within that directory in the file "WXXTRA-LICENSE".
62 This license does not apply to the binary libraries (if any) within
63 the "libs" directory, which are subject to a separate license contained
64 within that directory in the file "LIBS-LICENSE".
67 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
68 ----------------------------------------------
70 Subject to the terms of the GNU Public License (see above), you are
71 free to do whatever you like with your modifications. However, you may
72 (at your option) wish contribute them to Xara's source tree. You can
73 find details of how to do this at:
74 http://www.xaraxtreme.org/developers/
76 Prior to contributing your modifications, you will need to complete our
77 contributor agreement. This can be found at:
78 http://www.xaraxtreme.org/developers/contribute/
80 Please note that Xara will not accept modifications which modify any of
81 the text between the start and end of this header (marked
82 XARAHEADERSTART and XARAHEADEREND).
85 MARKS
86 -----
88 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
89 designs are registered or unregistered trademarks, design-marks, and/or
90 service marks of Xara Group Ltd. All rights in these marks are reserved.
93 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
94 http://www.xara.com/
96 =================================XARAHEADEREND============================
98 // oil ruler class
100 #ifndef INC_OILRULERS
101 #define INC_OILRULERS
103 #include "guides.h"
104 #include "camview.h"
106 class WinCoord;
107 class WinRect;
108 class DovView;
109 class RulerBase;
110 class OILHorizontalRuler;
111 class CRenderWnd;
113 #define MAX_RULER_DIGITS 3
115 enum MouseFollowerRenderType { RenderOn, RenderOff };
117 // WEBSTER - markn 15/1/97
118 // No rulers in Webster
119 #ifndef WEBSTER
120 #ifndef EXCLUDE_FROM_RALPH
122 /********************************************************************************************
123 > class LegendLabel : public wxWindow
125 Author: Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
126 Created: 4/3/94
127 Purpose: This is the class for the "set origin" gadget,
128 ********************************************************************************************/
130 class LegendLabel : public wxWindow
132 friend class OILHorizontalRuler;
133 DECLARE_DYNAMIC_CLASS(LegendLabel)
135 public:
136 LegendLabel();
137 virtual ~LegendLabel();
138 BOOL Create(OILHorizontalRuler* pHorzRuler, wxWindow* pParentWindow, INT32 id);
140 void ShowLabel(BOOL show);
141 BOOL PositionLegend();
143 wxPoint ClientToParentClient(wxPoint point);
145 BOOL GetStatusLineText(String_256* pText, WinCoord MousePos, CWindowID hWnd);
147 protected:
148 BOOL SetLegendText(StringBase* pText);
149 BOOL SetLegendSize();
151 protected:
152 // wxWindows OIL message handlers and related functions
153 void DoPaint(wxDC* pDC);
155 void OnPaint(wxPaintEvent &event);
157 void OnSize(wxSizeEvent &event);
158 void OnLButtonDown(wxMouseEvent& event);
159 void OnLButtonDblClk(wxMouseEvent& event);
160 void OnRButtonUp(wxMouseEvent& event);
161 void OnMouseMove(wxMouseEvent& event);
163 protected:
164 UINT32 LegendWidth;
165 UINT32 LegendHeight;
166 String_256 LegendText;
167 OILHorizontalRuler* m_pHorzRuler;
169 DECLARE_EVENT_TABLE()
173 /********************************************************************************************
174 > class OILRuler : public wxWindow
176 Author: Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
177 Created: 4/3/94
178 Purpose: This is the base class for Horizontal and Vertical rulers,
179 It looks after the basic's - creating windows etc..
180 and handles all mouse events fo the rulers
181 *********************************************************************************************/
183 class OILRuler : public wxWindow
185 DECLARE_DYNAMIC_CLASS(OILRuler)
187 public:
188 OILRuler();
189 virtual ~OILRuler();
190 virtual BOOL PostCreate() {return FALSE;}
191 BOOL Create(CCamView* pOwnerView, INT32 id);
192 void LinkToKernel(RulerBase* pKRuler) { pKernelRuler=pKRuler; }
194 static BOOL GetMinGraticuleSpacing(OilRect* pSpacing, DocView* pDocView);
195 static BOOL GetTextSize(OilRect* pTextSize, LPCTSTR str, DocView* pDocView);
196 static BOOL GetTextSize(WinRect* pTextSize, LPCTSTR str);
197 static void PatB(wxDC* pDC, INT32 x, INT32 y, INT32 dx, INT32 dy, wxColour rgb);
199 wxPoint ClientToOtherClient(wxWindow* pOtherCWnd, wxPoint point);
200 WinRect ClientToOtherClient(wxWindow* pOtherCWnd, WinRect WR);
202 OilCoord ClientToOil(DocView* pDocView, wxPoint point);
203 OilRect ClientToOil(DocView* pDocView, WinRect WR);
205 virtual BOOL DrawMajorGraticule(OilCoord GratOilPos, LPCTSTR str) {return FALSE;}
206 virtual BOOL DrawMinorGraticule(OilCoord GratOilPos, INT32 ExtraSize=0);
207 BOOL HighlightSection(OilCoord Lo, OilCoord Hi);
208 BOOL DrawBitmap(OilCoord Pos, ResourceID BitmapID);
209 BOOL StartToolDrag(ClickModifiers Mods, OilCoord point, String_256* OpToken, OpParam* Param);
211 BOOL PaintMouseFollower(OilCoord OilPos, DocView* pDocView, MouseFollowerRenderType RenderType);
212 BOOL DrawMouseFollower(OilCoord OilPos, DocView* pDocView, MouseFollowerRenderType RenderType, wxDC* pDC);
214 BOOL GetStatusLineText(String_256* pText, WinCoord MousePos, CWindowID hWnd);
216 virtual void ShowRuler(BOOL show);
217 void UpdateRuler();
219 static BOOL Init();
220 static void Deinit();
221 static INT32 GetRenderWidth() { return RenderWidth; }
222 static UINT32 GetWidth() { return RulerWidth; }
223 static wxFont GetRulerFont();
225 protected:
226 virtual BOOL IsHorizontal() {return FALSE;}
227 virtual BOOL StartDrag(UINT32 nFlags, wxPoint point);
228 virtual BOOL HandleRulerDragEvent(UINT32 Button, UINT32 nFlags, WinCoord point, ClickType t);
229 virtual BOOL HandleRulerUpEvent(UINT32 Button, WinCoord point);
231 CRenderWnd* GetRenderWindow() {return m_pOwnerView ? m_pOwnerView->GetRenderWindow() : NULL;}
232 void SetCurrentStates();
234 protected:
235 // wxWindows OIL message handlers and related functions
236 void DoPaint(wxDC* pDC);
238 void OnPaint(wxPaintEvent &event);
240 // void OnLButtonDown(wxMouseEvent& event);
241 // void OnLButtonDblClk(wxMouseEvent& event);
242 // void OnRButtonUp(wxMouseEvent& event);
243 void OnMouseMove(wxMouseEvent& event);
245 void OnLButtonDown( wxMouseEvent &event );
246 void OnLButtonDblClk( wxMouseEvent &event );
247 void OnLButtonUp( wxMouseEvent &event );
248 void OnMButtonDown( wxMouseEvent &event );
249 void OnMButtonDblClk( wxMouseEvent &event );
250 void OnMButtonUp( wxMouseEvent &event );
251 void OnRButtonDown( wxMouseEvent &event );
252 void OnRButtonDblClk( wxMouseEvent &event );
253 void OnRButtonUp( wxMouseEvent &event );
255 void OnFocus( wxFocusEvent& event );
257 public:
258 static String_256* FontName; // read from .ini file
259 static INT32 FontSize;
261 protected:
262 static INT32 RenderWidth; // renderable width of ruler, determined by the font specified in the .ini
263 static UINT32 RulerWidth; // offset to next bar - NOT NECESSARILY THE PHYSICAL OR LOGICAL WIDTH OF THE RULER!
264 static INT32 CharHeight;
265 static INT32 CharWidth;
267 // vars to pass info from OIL OnPaint() to low level OIL render funtions, transparent to intermediate kernel code
268 // This is a bit NASTY!
269 static wxDC* pPaintDC;
270 static DocView* pPaintDocView;
271 static wxSize RulerToDocOffset;
273 static OpGuidelineParam NewGuidelineParam;
275 CCamView* m_pOwnerView;
276 RulerBase* pKernelRuler;
278 ClickType m_LastClickType; // click type of last START_DRAG
279 UINT32 m_LastClickButton; // buttons down on last START_DRAG
280 wxPoint m_LastClickPoint; // mouse position of last START_DRAG
281 ClickModifiers m_LastClickMods; // ClickMods on last mouse event (NOT modified by button-up events!)
282 UINT32 m_FirstClickButton; // Which button started the drag (if dragging).
284 BOOL InDrag;
286 DECLARE_EVENT_TABLE()
290 /********************************************************************************************
291 > class OILHorizontalRuler : public OILRuler
292 Author: Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
293 Created: 29/3/94
294 Purpose: This class handles the OIL-specific parts of Horizontal rulers.
295 ********************************************************************************************/
297 class OILHorizontalRuler : public OILRuler
299 friend class LegendLabel;
300 DECLARE_DYNAMIC_CLASS(OILHorizontalRuler)
302 public:
303 OILHorizontalRuler();
304 ~OILHorizontalRuler();
305 virtual BOOL PostCreate();
307 void CalcPosFromParentClient(WinRect* lpRect);
308 void ScrollRuler(INT32 amount);
310 virtual void ShowRuler(BOOL show);
311 virtual BOOL DrawMajorGraticule(OilCoord GratOilPos, LPCTSTR str);
313 BOOL PositionLegend();
314 BOOL SetLegendText(StringBase* pText);
316 LegendLabel* GetpLegendLabel() { return pLegend; }
318 protected:
319 virtual BOOL StartDrag(UINT32 nFlags, wxPoint point);
320 virtual BOOL IsHorizontal(){ return TRUE ;};
322 private:
323 LegendLabel* pLegend;
327 /********************************************************************************************
328 > class OILVerticalRuler : public OILRuler
329 Author: Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
330 Created: 29/3/94
331 Purpose: This class handles the OIL-specific parts of Horizontal rulers.
332 ********************************************************************************************/
334 class OILVerticalRuler : public OILRuler
336 DECLARE_DYNAMIC_CLASS(OILVerticalRuler)
338 public:
339 OILVerticalRuler();
340 virtual BOOL PostCreate();
342 void CalcPosFromParentClient(WinRect* lpRect);
343 void ScrollRuler(INT32 amount);
345 virtual BOOL DrawMajorGraticule(OilCoord GratOilPos, LPCTSTR str);
347 protected:
348 virtual BOOL StartDrag(UINT32 nFlags, wxPoint point);
349 virtual BOOL IsHorizontal(){ return FALSE ;};
354 /********************************************************************************************
355 > class OriginGadget : public wxWindow
357 Author: Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
358 Created: 4/3/94
359 Purpose: This is the class for the "set origin" gadget,
360 ********************************************************************************************/
362 class OriginGadget : public wxWindow
364 DECLARE_DYNAMIC_CLASS(OriginGadget)
366 public:
367 OriginGadget();
368 virtual ~OriginGadget();
369 BOOL Create(CCamView* pOwnerView, INT32 id);
371 void ShowGadget(BOOL show);
372 void CalcPosFromParentClient(WinRect* lpRect);
374 BOOL GetStatusLineText(String_256* pText, WinCoord MousePos, CWindowID hWnd);
375 #if !defined(EXCLUDE_FROM_XARALX)
376 static TCHAR* BubbleHelpCallBack(CWindowID hWnd, UINT32 PaneIndex, void* UserData);
377 #endif
379 protected:
380 // Windows OIL message handlers and related functions
381 void DoPaint(wxDC* pDC);
383 void OnPaint(wxPaintEvent &event);
385 void OnLButtonDown(wxMouseEvent& event);
386 void OnLButtonDblClk(wxMouseEvent& event);
387 void OnRButtonUp(wxMouseEvent& event);
388 void OnMouseMove(wxMouseEvent& event);
390 protected:
391 CCamView* m_pOwnerView;
393 wxBitmap* pGlyph;
395 DECLARE_EVENT_TABLE()
398 #endif
399 #endif // WEBSTER
400 #endif // INC_OILRULERS