camview.h

Go to the documentation of this file.
00001 // $Id: camview.h 1688 2006-08-10 12:05:20Z gerry $
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 #ifndef INC_CAMVIEW_H
00099 #define INC_CAMVIEW_H
00100 
00101 //#include "docview.h"
00102 //#include "ink.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00103 //#include "clikmods.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00104 //#include "rendwnd.h"
00105 #include "wrkrect.h"
00106 //#include "dragtrgt.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 
00108 #include "wx/dnd.h"
00109 
00110 // Forward definitions
00111 class CRenderWnd;
00112 class CWinScroller;
00113 class CScrollerCorner;
00114 class OILHorizontalRuler;
00115 class OILVerticalRuler;
00116 class OriginGadget;
00117 class PrintView;
00118 class DocView;
00119 class ViewState;
00120 class CCPrintInfo;
00121 class PrintControl;
00122 class Rect;
00123 
00124 enum MouseOverRulerHit
00125 {
00126     OVER_NO_RULERS,
00127     OVER_HORIZONTAL,
00128     OVER_VERTICAL,
00129     OVER_ORIGIN_GADGET
00130 };
00131 
00132 
00133 #define ReflectIntoView( Class, ViewClass, Handler, Type ) void Class::Handler( Type& event ) \
00134     { ((ViewClass*)m_pView)->Handler( event ); }
00135 
00136 /*******************************************************************************
00137 >   class CCamView : public wxView
00138 
00139     Author:     Luke_Hart (Xara Group Ltd) <camelotdev@xara.com> H
00140     Created:    01/07/05
00141     Purpose:    This OIL class implements many window functions, such as
00142                 scrolling and sizing the editing windows.  As such, it acts
00143                 as an intermediary between the kernel and the host operating
00144                 system.  It is derived from the wx class wxView, which
00145                 provides comprehensive methods for managing the client area
00146                 of a window.
00147                 
00148                 On creation, a CCamView asks its Document to provide a pointer
00149                 to the DocView that is to be associated with this object.
00150                 Once that link has been made, any changes in the state of the
00151                 CCamView, eg. the user maximises it, are passed on in a
00152                 device-independent form to the DocView.  This trick is done
00153                 using a shared ViewState object.
00154 
00155 *******************************************************************************/
00156 
00157 class CCamView : public wxView
00158 {
00159 
00161 // Creation and destruction.
00162 
00163 public:
00164     CCamView();                         // default constructor
00165     virtual ~CCamView();
00166 
00167     virtual bool OnCreate( wxDocument* doc, /* TYPENOTE: Correct */ long flags );
00168     bool OnClose( bool deleteWindow = TRUE );
00169 
00170     wxMDIChildFrame *GetParentFrame() const
00171     {
00172         return m_pFrame;
00173     }
00174 
00175     static BOOL ReadViewPrefs();
00176 
00178 // Interface to the kernel's view onto a document and MFC's CDocument-derived
00179 // object.
00180 
00181 protected:
00182     void GrabKernelAttention() const;   // tells kernel this view is active
00183     void SetCurrentStates();
00184     virtual BOOL CreateNewDocView();
00185     virtual BOOL IsARalphView(){ return FALSE;};
00186 
00187 public:
00188     CCamDoc *GetDocument() const;       // returns a pointer to OIL/MFC document
00189     ViewState *GetViewState() const;    // returns a pointer to our ViewState
00190     ViewState *SetViewState( ViewState *pvs );
00191 
00192     void SetViewStateFromThis() const;  // set Status according to this view
00193     void SetThisFromViewState();        // set this view according to Status
00194 
00195 
00196 public:
00197     BOOL IsTopmost() const;
00198 
00200 // Painting.
00201 
00202 public:
00203     virtual CNativeDC *GetRenderDC() const;
00204     virtual void AllocateDC() const;
00205     virtual void DoneWithDC() const;
00206     void GetClientSize(/* TYPENOTE: Correct */ int * width, /*TYPENOTE: Correct */ int * height) const;
00207     
00208     virtual void OnDraw( wxDC *pDc );
00209 PORTNOTE("printing", "Disabled CCamView::OnPreparePrinting")
00210 #ifndef EXCLUDE_FROM_XARALX
00211     virtual BOOL OnPreparePrinting( CCPrintInfo *pInfo );
00212 #endif
00213 
00215 // Menu functions, put in at Mario's behest.
00216 
00217 public:
00218     virtual void OnFilePrint();
00219     virtual void OnFilePrintPreview();
00220 
00221 public:
00222     CRenderWnd* GetRenderWindow() const { return(RenderWindow); }
00223     void InvalidateView(const OilRect* pRect = 0, BOOL updatenow = FALSE);
00224 
00225 private:
00226     DECLARE_DYNAMIC_CLASS(CCamView)
00227     DECLARE_EVENT_TABLE()
00228 
00229 public:
00230     void    OnSize( wxSizeEvent &event );
00231     void    OnLButtonDown( wxMouseEvent &event );
00232     void    OnLButtonDblClk( wxMouseEvent &event );
00233     void    OnLButtonUp( wxMouseEvent &event );
00234     void    OnMButtonDown( wxMouseEvent &event );
00235     void    OnMButtonDblClk( wxMouseEvent &event );
00236     void    OnMButtonUp( wxMouseEvent &event );
00237     void    OnRButtonDown( wxMouseEvent &event );
00238     void    OnRButtonDblClk( wxMouseEvent &event );
00239     void    OnRButtonUp( wxMouseEvent &event );
00240     void    OnMouseMove( wxMouseEvent &event );
00241     void    OnMouseWheel( wxMouseEvent &event );
00242     void    OnScroll( wxScrollEvent &event);
00243     void    OnDragIdle( wxTimerEvent &event);       // OnTimer(DragIdleID)
00244 
00245     void    OnSetCursor( wxSetCursorEvent& event );
00246 
00247     bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames);
00248 
00249 protected:
00250     LRESULT OnRenderView( WPARAM wp, LPARAM lp );
00251     void ScrollTo(const WorkCoord& offset);
00252     void ScrollBy(INT32 dx, INT32 dy);
00253 
00254 public:
00255     static DocView* GetDocViewFromWindow(wxWindow* pWindow);
00256     static void SetUseVisibleDefaults(BOOL state){ UseVisibleDefaults = state;};
00257 
00258 //  void GetWorkAreaExtent(WorkRect* pArea) const;
00259     void SetWorkAreaExtent(const WorkRect& area, BOOL redraw = TRUE);
00260     void GetScrollOffset(WorkCoord* pOffset) const;
00261     void SetScrollOffset(const WorkCoord& pos, BOOL redraw = TRUE);
00262     void ShowScrollers(BOOL Show); 
00263     void ShowRulers(BOOL Show);
00264     WorkRect GetMaxScrollRect() const;
00265 
00266     BOOL AreRulersVisible();
00267     BOOL AreScrollersVisible();
00268     MouseOverRulerHit IsMouseOverRuler();
00269 
00270     static BOOL GetUseVisibleDefaults()              { return UseVisibleDefaults;};
00271     static BOOL GetDefaultRulersState()              { return DefaultRulersState;};
00272     static BOOL GetDefaultScrollersState()           { return DefaultScrollersState;};
00273     static void SetDefaultRulersState(BOOL State)    { DefaultRulersState = State;};
00274     static void SetDefaultScrollersState(BOOL State) { DefaultScrollersState = State;};
00275 
00277 // Drag'n'drop data and functions.
00278 
00279 protected:
00280 
00281     void HandleDragEvent(UINT32 Button, UINT32 nFlags, wxPoint point, ClickType t);
00282     void HandleDragEvent(UINT32 Button, ClickModifiers clickmods, wxPoint point, ClickType t);
00283     BOOL HandleMouseWheelEvent( wxMouseEvent &event );
00284     void HandleDragScrolling(wxPoint point);
00285     void CalcScrollDeltas(wxPoint point, WinRect wrSize, INT32* dx, INT32* dy);
00286     void HandleButtonUp(UINT32 Button, wxMouseEvent &event);
00287 //  virtual void HandleOleDragOutOfView(wxPoint point); // Used to allow derived classes to provide OLE drag and drop
00288 
00289 
00290 public:
00291     void RecaptureMouseOnNextUpdate(void);
00292 
00293     static void GetClickMods( wxMouseEvent &event, ClickModifiers *p );
00294     BOOL StartDrag(Operation* pOp, DragType type, BOOL KeepAccuracy);
00295     BOOL EndDrag(Operation* pOp);
00296     BOOL ChangeDragType(DragType Type);
00297     void ClearClickState();
00298 
00299     // Allows a drag op to be invoked from the ScreenView object, as if it had been
00300     // invoked as a result of clicking into the document.
00301     // Useful esp. for drag ops that are not connected to a particular tool and/or started
00302     // from clicks outside the view, e.g. Creating guidelines by clicking on a ruler window
00303     BOOL InvokeDragOp(String_256* pOpToken,OpParam* pParam,UINT32 Flags,wxPoint point);
00304     BOOL InvokeDragOp(String_256* pOpToken,OpParam* pParam,ClickModifiers clickmods,wxPoint point);
00305 
00306     // Function to test if there is another mouse move message in the queue
00307     BOOL IsWaitingMouseMove();
00308 
00309     // This sets the output parameter to the current mouse position within this
00310     // ScreenView.  If the cursor isn't within the view it returns FALSE.
00311     BOOL GetCurrentMousePos(OilCoord* pMousePos) const;
00312 
00313     BOOL CreateDragTarget(DragInformation * DragInfo);
00314 
00315 
00316 public:
00317     DocView* GetDocViewPtr() const
00318     {
00319         return pDocView;
00320     }
00321 //  virtual BOOL IsSelected(const CObject* pDocItem) const;
00322 
00323 protected:
00324     // Helper functions for printing.
00325     BOOL PrintPaper(wxDC *pPrintDC, CCPrintInfo *pPrintInfo, PrintControl *pPrintControl);
00326     WinRect GetPrintClipRect(wxDC *pPrintDC, CCPrintInfo *pPrintInfo);
00327     void EnumeratePagePatches(CCPrintInfo *pPrintInfo);
00328 
00329 
00330     void UpdateViewPosition() const;    // called on moves & resizes
00331 
00332 protected:
00333     virtual void OnInitialUpdate();     // called once between creation & painting
00334     virtual void OnUpdate(wxView* sender, wxObject* hint=(wxObject*)NULL);
00335     virtual void OnActivateView(bool bActivate, wxView* pActiveView,
00336                                 wxView* pDeactiveView);
00337 
00339 // Triple and quad click support
00340 
00341 public:
00342     BOOL IsSingleClickReallyTriple() const  {return ThisSingleIsTriple;}
00343     BOOL IsSingleClickReallyQuad() const    {return ThisDoubleIsQuad;}
00344 
00345 // Member variables
00346 protected:
00347     wxMDIChildFrame* m_pFrame;
00348     CRenderWnd* RenderWindow;
00349     CWinScroller* HScrollBar;               // proportional scroll bars
00350     CWinScroller* VScrollBar;
00351     CScrollerCorner* Corner;                // the "size box"
00352     OILHorizontalRuler* HRuler;
00353     OILVerticalRuler* VRuler;
00354     OriginGadget* OGadget;
00355 
00356     DocView    *pDocView;               // link to the kernel's view
00357     PrintView  *pPrintView;             // only linked during printing.
00358     ViewState  *Status;                 // shared with the above
00359 
00360     BOOL fSetupDone;                    // if TRUE then all inits done
00361     BOOL fInitialUpdate;                // Set after calling OnInitialUpdate
00362     BOOL fJustCreated;                  // this view has never been activated before, it's new
00363 
00364     WinRect CurrentSize;                // the size of this view
00365     WorkRect WorkArea;
00366     WorkCoord OldOffset;                // previous scroller position
00367 
00368     // Vars used by InvokeDragOp()
00369     String_256  DragOpToken;
00370     OpParam*    pDragOpParam;
00371     BOOL        DragOpInvoke;
00372 
00373     MonotonicTime TimeOfLastClick;
00374     wxPoint LastDoubleClickPos;
00375     BOOL ThisSingleIsTriple;
00376     BOOL ThisDoubleIsQuad;
00377 
00378     wxTimer m_DragIdleTimer;
00379     MonotonicTime m_OLELastOutTime;     // Used to time the delay before "OLE scrolling"
00380 
00381     BOOL DragKeepAccuracy;              // Used to control drag responsiveness
00382 
00383     BOOL AutoScrollExcludeRulers;       // Flag used to extend the autoscroll region to 
00384                                         // include rulers - allows guidelines to be deleted
00385 
00386     ClickType       LastClickType;      // click type of last START_DRAG
00387     UINT32          LastClickButton;    // buttons down on last START_DRAG
00388     wxPoint         LastClickPoint;     // mouse position of last START_DRAG
00389     wxPoint         CurrentMousePos;    // the mouse was here last time we looked
00390     ClickModifiers  LastClickMods;      // ClickMods on last mouse event (NOT
00391                                         // modified by button-up events!)
00392 
00393     UINT32 FirstClickButton;            // Which button started the drag (if dragging).
00394 
00395     Operation* pCurrentDragOp;          // current mouse-drag operation
00396     DragType CurrentDragType;           // what to do when dragging off-screen
00397     WinRect MouseClipRect;              // cursor was clipped against this
00398 
00399     BOOL OLERecaptureMouse;             // Used when OLE drags return to the view window - we resume our
00400                                         // drag, and we have to recapture the mouse to recover properly.
00401 
00402     // Mouse move elimination code
00403     INT32 m_LastMouseState;
00404     wxPoint m_LastMousePosition;
00405     INT32 m_LastMouseUsedTimestamp;
00406     BOOL m_CouldSkipNextMouse;
00407 
00408 public:
00409     void DontSkipNextMouse() {m_CouldSkipNextMouse=FALSE;}
00410 
00411 // Static functions
00412 protected:
00413     static void wxPoint2Coord(const wxPoint& point, Coord* pcoord);
00414     static void Coord2wxPoint(const Coord& coord, wxPoint* ppoint);
00415     static void wxRect2Rect(const wxRect& rect, Rect* pkrect);
00416     static void Rect2wxRect(const Rect& krect, wxRect* prect);
00417 
00418 public:
00419     static DocView *GetDocViewFromWindowID( CWindowID WindowID );
00420 
00421 // Static variables
00422 protected:
00423     static const INT32 WID_RENDERWINDOW = 1;
00424     static const INT32 WID_HSCROLLBAR = 2;
00425     static const INT32 WID_VSCROLLBAR = 3;
00426     static const INT32 WID_SIZECORNER = 4;
00427     static const INT32 WID_HRULER = 5;
00428     static const INT32 WID_VRULER = 6;
00429     static const INT32 WID_RULERORIGIN = 7;
00430     static const INT32 DragIdleID = 100;
00431 
00432     static INT32 PopCount;                  // how many CCamViews around
00433     static ViewState* pReadyMadeViewState;  // points to the ViewState to use on next create
00434 
00435     static BOOL DefaultScrollersState;
00436     static BOOL DefaultRulersState;
00437     static BOOL UseVisibleDefaults; 
00438 
00439     static INT32 DragLatency;           // mouse must move >= this for a drag, except:
00440     static INT32 DragDelay;             // delay before we start a drag anyway, even if
00441                                         // mouse has not moved.
00442     static MonotonicTime DragTimer;     // Used to time the drag delay above.
00443 
00444     static INT32 ScrollBarSize;         // Width of the wider of the scroll bars
00445 
00446 public:
00447     static INT32 s_MouseMoveEliminationPeriod;
00448 };
00449 
00450 
00451 /*********************************************************************************************
00452 
00453 >   class PageDropInfo : public CCObject
00454 
00455     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00456     Created:    25/3/95
00457     Purpose:    Gives info about where an drag has, or is going to be, dropped on a page.
00458 
00459     SeeAlso:    DragInformation
00460 
00461 *********************************************************************************************/
00462 
00463 class PageDropInfo : public CCObject
00464 {
00465     CC_DECLARE_DYNCREATE(PageDropInfo)
00466 
00467 public:
00468     Document*   pDoc;
00469     DocView*    pDocView;
00470     Spread*     pSpread;
00471     DocCoord    DropPos;
00472 
00473     ObjectDragTarget    TargetHit; 
00474     NodeRenderableInk*  pObjectHit;
00475 };
00476 
00477 
00478 /*********************************************************************************************
00479 >   class   ViewDragTarget : public OilDragTarget
00480 
00481     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>.
00482     Created:    2/1/95
00483 
00484     Purpose:    An instantiation of this class is created by each entity which wishes to 
00485                 provide a 'destination' to which the mouse can go to complete a drag.
00486                 WinoilDragTargets are used as a base class from which to derive drag targets
00487                 for WINOIL entities (an optional HWND)
00488 
00489     Notes:      Drag targets are destructed automatically when a drag finishes by the drag
00490                 manager with which they were registered.
00491 
00492                 To remove a drag target at any time, destruct it - it automatically deregisters
00493                 and cleans up.
00494                 
00495     SeeAlso:    DragManagerOp::StartDrag; DragInformation; DragTarget
00496 
00497     Documentation:  Docs\Specs\DragMan.doc
00498 *********************************************************************************************/
00499 
00500 class ViewDragTarget : public OilDragTarget
00501 {
00502 friend class DragManagerOp;
00503 friend class ColourDragInformation;
00504     
00505 CC_DECLARE_DYNAMIC(ViewDragTarget)
00506 
00507 
00508 public: // Public interface
00509     
00510     ViewDragTarget( wxWindow *TheWindow, wxRect *ClientArea = NULL, DragInformation* pDragInfo = NULL);
00511     
00512     virtual UINT32 GetCursorID();
00513     virtual BOOL GetStatusLineText(String_256 * TheText);
00514 
00515     virtual BOOL GetDropInfo(PageDropInfo*);
00516 
00517 protected:
00518     
00519     // Process a drag-related event
00520     BOOL ProcessEvent(DragEventType Event,
00521                         DragInformation *pDragInfo,
00522                         wxPoint *pMousePos, KeyPress* pKeyPress);
00523 
00524     DragInformation* pCurrentDragInfo;
00525 
00526     BOOL OverOutline;
00527     INT32 LineRad;
00528 
00529     DocView*    pThisDoc;
00530     Spread*     pSpread;
00531     DocCoord    DropPos;
00532 
00533     ObjectDragTarget    OverTarget;
00534     NodeRenderableInk*  OverNode;
00535 };
00536 
00537 
00538 
00539 class CViewFileDropTarget : public wxFileDropTarget
00540 {
00541 public:
00542     CViewFileDropTarget(CCamView* pView);
00543     virtual ~CViewFileDropTarget();
00544 
00545     virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames);
00546 
00547 protected:
00548     CCamView* m_pView;
00549 };
00550 
00551 
00552 #endif  // INC_CAMVIEW_H

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