1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxShapeCanvas
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _OGL_CANVAS_H_
13 #define _OGL_CANVAS_H_
15 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "canvas.h"
22 #define StartDraggingLeft 1
23 #define ContinueDraggingLeft 2
24 #define StartDraggingRight 3
25 #define ContinueDraggingRight 4
27 WXDLLIMPEXP_OGL
extern const wxChar
* wxShapeCanvasNameStr
;
29 // When drag_count reaches 0, process drag message
31 class WXDLLIMPEXP_OGL wxDiagram
;
33 class WXDLLIMPEXP_OGL wxShapeCanvas
: public wxScrolledWindow
35 DECLARE_DYNAMIC_CLASS(wxShapeCanvas
)
37 wxShapeCanvas(wxWindow
*parent
= NULL
, wxWindowID id
= -1,
38 const wxPoint
& pos
= wxDefaultPosition
,
39 const wxSize
& size
= wxDefaultSize
,
40 long style
= wxBORDER
| wxRETAINED
,
41 const wxString
& name
= wxShapeCanvasNameStr
);
44 inline void SetDiagram(wxDiagram
*diag
) { m_shapeDiagram
= diag
; }
45 inline wxDiagram
*GetDiagram() const { return m_shapeDiagram
; }
47 virtual void OnLeftClick(double x
, double y
, int keys
= 0);
48 virtual void OnRightClick(double x
, double y
, int keys
= 0);
50 virtual void OnDragLeft(bool draw
, double x
, double y
, int keys
=0); // Erase if draw false
51 virtual void OnBeginDragLeft(double x
, double y
, int keys
=0);
52 virtual void OnEndDragLeft(double x
, double y
, int keys
=0);
54 virtual void OnDragRight(bool draw
, double x
, double y
, int keys
=0); // Erase if draw false
55 virtual void OnBeginDragRight(double x
, double y
, int keys
=0);
56 virtual void OnEndDragRight(double x
, double y
, int keys
=0);
58 // Find object for mouse click, of given wxClassInfo (NULL for any type).
59 // If notImage is non-NULL, don't find an object that is equal to or a descendant of notImage
60 virtual wxShape
*FindShape(double x
, double y
, int *attachment
, wxClassInfo
*info
= NULL
, wxShape
*notImage
= NULL
);
61 wxShape
*FindFirstSensitiveShape(double x
, double y
, int *new_attachment
, int op
);
62 wxShape
*FindFirstSensitiveShape1(wxShape
*image
, int op
);
64 // Redirect to wxDiagram object
65 virtual void AddShape(wxShape
*object
, wxShape
*addAfter
= NULL
);
66 virtual void InsertShape(wxShape
*object
);
67 virtual void RemoveShape(wxShape
*object
);
68 virtual bool GetQuickEditMode();
69 virtual void Redraw(wxDC
& dc
);
70 void Snap(double *x
, double *y
);
73 void OnPaint(wxPaintEvent
& event
);
74 void OnMouseEvent(wxMouseEvent
& event
);
77 wxDiagram
* m_shapeDiagram
;
79 double m_oldDragX
, m_oldDragY
; // Previous drag coordinates
80 double m_firstDragX
, m_firstDragY
; // INITIAL drag coordinates
81 bool m_checkTolerance
; // Whether to check drag tolerance
82 wxShape
* m_draggedShape
;
83 int m_draggedAttachment
;