oilruler.h

Go to the documentation of this file.
00001 // $Id: oilruler.h 1459 2006-07-17 17:35:57Z phil $
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 // oil ruler class
00099 
00100 #ifndef INC_OILRULERS
00101 #define INC_OILRULERS
00102 
00103 #include "guides.h"
00104 #include "camview.h"
00105 
00106 class WinCoord;
00107 class WinRect;
00108 class DovView;
00109 class RulerBase;
00110 class OILHorizontalRuler;
00111 class CRenderWnd;
00112 
00113 #define MAX_RULER_DIGITS 3
00114 
00115 enum MouseFollowerRenderType { RenderOn, RenderOff }; 
00116 
00117 // WEBSTER - markn 15/1/97
00118 // No rulers in Webster
00119 #ifndef WEBSTER
00120 #ifndef EXCLUDE_FROM_RALPH
00121 
00122 /********************************************************************************************
00123 >   class LegendLabel : public wxWindow
00124 
00125     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
00126     Created:    4/3/94
00127     Purpose:    This is the class for the "set origin" gadget, 
00128 ********************************************************************************************/
00129 
00130 class LegendLabel : public wxWindow
00131 {
00132     friend class  OILHorizontalRuler;
00133     DECLARE_DYNAMIC_CLASS(LegendLabel)
00134 
00135 public:
00136     LegendLabel();
00137     virtual ~LegendLabel();
00138     BOOL Create(OILHorizontalRuler* pHorzRuler, wxWindow* pParentWindow, INT32 id);
00139     
00140     void ShowLabel(BOOL show);
00141     BOOL PositionLegend();
00142 
00143     wxPoint ClientToParentClient(wxPoint point);
00144 
00145     BOOL GetStatusLineText(String_256* pText, WinCoord MousePos, CWindowID hWnd);
00146 
00147 protected:
00148     BOOL SetLegendText(StringBase* pText);
00149     BOOL SetLegendSize();
00150 
00151 protected:
00152     // wxWindows OIL message handlers and related functions
00153     void DoPaint(wxDC* pDC);
00154 
00155     void OnPaint(wxPaintEvent &event);
00156 
00157     void OnSize(wxSizeEvent &event);
00158     void OnLButtonDown(wxMouseEvent& event);
00159     void OnLButtonDblClk(wxMouseEvent& event);
00160     void OnRButtonUp(wxMouseEvent& event);
00161     void OnMouseMove(wxMouseEvent& event);
00162 
00163 protected:
00164     UINT32 LegendWidth;
00165     UINT32 LegendHeight;
00166     String_256 LegendText;
00167     OILHorizontalRuler* m_pHorzRuler;
00168 
00169     DECLARE_EVENT_TABLE()
00170 };
00171 
00172 
00173 /********************************************************************************************
00174 >   class OILRuler : public wxWindow
00175 
00176     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
00177     Created:    4/3/94
00178     Purpose:    This is the base class for Horizontal and Vertical rulers,
00179                 It looks after the basic's - creating windows etc..
00180                 and handles all mouse events fo the rulers 
00181 *********************************************************************************************/
00182 
00183 class OILRuler : public wxWindow
00184 {
00185     DECLARE_DYNAMIC_CLASS(OILRuler)
00186 
00187 public:
00188     OILRuler();
00189     virtual ~OILRuler();
00190     virtual BOOL PostCreate() {return FALSE;}
00191     BOOL Create(CCamView* pOwnerView, INT32 id);
00192     void LinkToKernel(RulerBase* pKRuler) { pKernelRuler=pKRuler; }
00193 
00194     static BOOL GetMinGraticuleSpacing(OilRect* pSpacing, DocView* pDocView);
00195     static BOOL GetTextSize(OilRect* pTextSize, LPCTSTR str, DocView* pDocView);
00196     static BOOL GetTextSize(WinRect* pTextSize, LPCTSTR str);
00197     static void PatB(wxDC* pDC, INT32 x, INT32 y, INT32 dx, INT32 dy, wxColour rgb);
00198 
00199     wxPoint  ClientToOtherClient(wxWindow* pOtherCWnd, wxPoint point);
00200     WinRect ClientToOtherClient(wxWindow* pOtherCWnd, WinRect  WR);
00201 
00202     OilCoord ClientToOil(DocView* pDocView, wxPoint point);
00203     OilRect  ClientToOil(DocView* pDocView, WinRect  WR);
00204 
00205     virtual BOOL DrawMajorGraticule(OilCoord GratOilPos, LPCTSTR str) {return FALSE;}
00206     virtual BOOL DrawMinorGraticule(OilCoord GratOilPos, INT32 ExtraSize=0);
00207     BOOL HighlightSection(OilCoord Lo, OilCoord Hi);
00208     BOOL DrawBitmap(OilCoord Pos, ResourceID BitmapID);
00209     BOOL StartToolDrag(ClickModifiers Mods, OilCoord point, String_256* OpToken, OpParam* Param);
00210 
00211     BOOL PaintMouseFollower(OilCoord OilPos, DocView* pDocView, MouseFollowerRenderType RenderType);
00212     BOOL  DrawMouseFollower(OilCoord OilPos, DocView* pDocView, MouseFollowerRenderType RenderType, wxDC* pDC);
00213 
00214     BOOL GetStatusLineText(String_256* pText, WinCoord MousePos, CWindowID hWnd);
00215 
00216     virtual void ShowRuler(BOOL show);
00217     void UpdateRuler();
00218 
00219     static BOOL Init();
00220     static void Deinit();
00221     static INT32 GetRenderWidth() { return RenderWidth; }
00222     static UINT32 GetWidth()       { return RulerWidth; }
00223     static wxFont GetRulerFont();
00224 
00225 protected:
00226     virtual BOOL IsHorizontal() {return FALSE;}
00227     virtual BOOL StartDrag(UINT32 nFlags, wxPoint point);
00228     virtual BOOL HandleRulerDragEvent(UINT32 Button, UINT32 nFlags, WinCoord point, ClickType t);
00229     virtual BOOL HandleRulerUpEvent(UINT32 Button, WinCoord point);
00230 
00231     CRenderWnd* GetRenderWindow() {return m_pOwnerView ? m_pOwnerView->GetRenderWindow() : NULL;}
00232     void SetCurrentStates();
00233 
00234 protected:
00235     // wxWindows OIL message handlers and related functions
00236     void DoPaint(wxDC* pDC);
00237 
00238     void OnPaint(wxPaintEvent &event);
00239 
00240 //  void OnLButtonDown(wxMouseEvent& event);
00241 //  void OnLButtonDblClk(wxMouseEvent& event);
00242 //  void OnRButtonUp(wxMouseEvent& event);
00243     void OnMouseMove(wxMouseEvent& event);
00244 
00245     void    OnLButtonDown( wxMouseEvent &event );
00246     void    OnLButtonDblClk( wxMouseEvent &event );
00247     void    OnLButtonUp( wxMouseEvent &event );
00248     void    OnMButtonDown( wxMouseEvent &event );
00249     void    OnMButtonDblClk( wxMouseEvent &event );
00250     void    OnMButtonUp( wxMouseEvent &event );
00251     void    OnRButtonDown( wxMouseEvent &event );
00252     void    OnRButtonDblClk( wxMouseEvent &event );
00253     void    OnRButtonUp( wxMouseEvent &event );
00254 
00255     void    OnFocus( wxFocusEvent& event );
00256 
00257 public:
00258     static String_256*  FontName;       // read from .ini file
00259     static INT32        FontSize;
00260 
00261 protected:
00262     static INT32        RenderWidth;    // renderable width of ruler, determined by the font specified in the .ini
00263     static UINT32       RulerWidth;     // offset to next bar - NOT NECESSARILY THE PHYSICAL OR LOGICAL WIDTH OF THE RULER!
00264     static INT32        CharHeight;
00265     static INT32        CharWidth;
00266 
00267     // vars to pass info from OIL OnPaint() to low level OIL render funtions, transparent to intermediate kernel code
00268     // This is a bit NASTY!
00269     static wxDC*        pPaintDC;
00270     static DocView*     pPaintDocView;
00271     static wxSize       RulerToDocOffset;
00272 
00273     static OpGuidelineParam NewGuidelineParam;
00274 
00275     CCamView*           m_pOwnerView;
00276     RulerBase*          pKernelRuler;
00277 
00278     ClickType           m_LastClickType;        // click type of last START_DRAG
00279     UINT32              m_LastClickButton;      // buttons down on last START_DRAG
00280     wxPoint             m_LastClickPoint;       // mouse position of last START_DRAG
00281     ClickModifiers      m_LastClickMods;        // ClickMods on last mouse event (NOT modified by button-up events!)
00282     UINT32              m_FirstClickButton;     // Which button started the drag (if dragging).
00283 
00284     BOOL InDrag;
00285 
00286     DECLARE_EVENT_TABLE()
00287 };
00288 
00289 
00290 /********************************************************************************************
00291 >   class OILHorizontalRuler : public OILRuler
00292     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
00293     Created:    29/3/94
00294     Purpose:    This class handles the OIL-specific parts of Horizontal rulers.
00295 ********************************************************************************************/
00296 
00297 class OILHorizontalRuler : public OILRuler
00298 {
00299     friend class LegendLabel;
00300     DECLARE_DYNAMIC_CLASS(OILHorizontalRuler)
00301 
00302 public:
00303     OILHorizontalRuler();
00304     ~OILHorizontalRuler();
00305     virtual BOOL PostCreate();
00306 
00307     void CalcPosFromParentClient(WinRect* lpRect);
00308     void ScrollRuler(INT32 amount);
00309 
00310     virtual void ShowRuler(BOOL show);
00311     virtual BOOL DrawMajorGraticule(OilCoord GratOilPos, LPCTSTR str);
00312 
00313     BOOL PositionLegend();
00314     BOOL SetLegendText(StringBase* pText);
00315 
00316     LegendLabel* GetpLegendLabel() { return pLegend; }
00317 
00318 protected:
00319     virtual BOOL StartDrag(UINT32 nFlags, wxPoint point);
00320     virtual BOOL IsHorizontal(){ return TRUE ;};
00321 
00322 private:
00323     LegendLabel* pLegend;
00324 };
00325 
00326 
00327 /********************************************************************************************
00328 >   class OILVerticalRuler : public OILRuler
00329     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
00330     Created:    29/3/94
00331     Purpose:    This class handles the OIL-specific parts of Horizontal rulers.
00332 ********************************************************************************************/
00333 
00334 class OILVerticalRuler : public OILRuler
00335 {
00336     DECLARE_DYNAMIC_CLASS(OILVerticalRuler)
00337 
00338 public:
00339     OILVerticalRuler();
00340     virtual BOOL PostCreate();
00341 
00342     void CalcPosFromParentClient(WinRect* lpRect);
00343     void ScrollRuler(INT32 amount);
00344 
00345     virtual BOOL DrawMajorGraticule(OilCoord GratOilPos, LPCTSTR str);
00346 
00347 protected:
00348     virtual BOOL StartDrag(UINT32 nFlags, wxPoint point);
00349     virtual BOOL IsHorizontal(){ return FALSE ;};
00350 
00351 };
00352 
00353 
00354 /********************************************************************************************
00355 >   class OriginGadget : public wxWindow
00356 
00357     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
00358     Created:    4/3/94
00359     Purpose:    This is the class for the "set origin" gadget, 
00360 ********************************************************************************************/
00361 
00362 class OriginGadget : public wxWindow
00363 {
00364     DECLARE_DYNAMIC_CLASS(OriginGadget)
00365 
00366 public:
00367     OriginGadget();
00368     virtual ~OriginGadget();
00369     BOOL Create(CCamView* pOwnerView, INT32 id);
00370     
00371     void ShowGadget(BOOL show);
00372     void CalcPosFromParentClient(WinRect* lpRect);
00373 
00374     BOOL GetStatusLineText(String_256* pText, WinCoord MousePos, CWindowID hWnd);
00375 #if !defined(EXCLUDE_FROM_XARALX)
00376     static TCHAR* BubbleHelpCallBack(CWindowID hWnd, UINT32 PaneIndex, void* UserData);
00377 #endif
00378 
00379 protected:
00380     // Windows OIL message handlers and related functions
00381     void DoPaint(wxDC* pDC);
00382 
00383     void OnPaint(wxPaintEvent &event);
00384 
00385     void OnLButtonDown(wxMouseEvent& event);
00386     void OnLButtonDblClk(wxMouseEvent& event);
00387     void OnRButtonUp(wxMouseEvent& event);
00388     void OnMouseMove(wxMouseEvent& event);
00389 
00390 protected:
00391     CCamView* m_pOwnerView;
00392 
00393     wxBitmap* pGlyph;
00394 
00395     DECLARE_EVENT_TABLE()
00396 };
00397 
00398 #endif
00399 #endif  // WEBSTER
00400 #endif  // INC_OILRULERS

Generated on Sat Nov 10 03:48:43 2007 for Camelot by  doxygen 1.4.4