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_
18 #define StartDraggingLeft 1
19 #define ContinueDraggingLeft 2
20 #define StartDraggingRight 3
21 #define ContinueDraggingRight 4
23 WXDLLIMPEXP_OGL
extern const wxChar
* wxShapeCanvasNameStr
;
25 // When drag_count reaches 0, process drag message
27 class WXDLLIMPEXP_OGL wxDiagram
;
29 class WXDLLIMPEXP_OGL wxShapeCanvas
: public wxScrolledWindow
31 DECLARE_DYNAMIC_CLASS(wxShapeCanvas
)
33 wxShapeCanvas(wxWindow
*parent
= NULL
, wxWindowID id
= wxID_ANY
,
34 const wxPoint
& pos
= wxDefaultPosition
,
35 const wxSize
& size
= wxDefaultSize
,
36 long style
= wxBORDER
| wxRETAINED
,
37 const wxString
& name
= wxShapeCanvasNameStr
);
40 inline void SetDiagram(wxDiagram
*diag
) { m_shapeDiagram
= diag
; }
41 inline wxDiagram
*GetDiagram() const { return m_shapeDiagram
; }
43 virtual void OnLeftClick(double x
, double y
, int keys
= 0);
44 virtual void OnRightClick(double x
, double y
, int keys
= 0);
46 virtual void OnDragLeft(bool draw
, double x
, double y
, int keys
=0); // Erase if draw false
47 virtual void OnBeginDragLeft(double x
, double y
, int keys
=0);
48 virtual void OnEndDragLeft(double x
, double y
, int keys
=0);
50 virtual void OnDragRight(bool draw
, double x
, double y
, int keys
=0); // Erase if draw false
51 virtual void OnBeginDragRight(double x
, double y
, int keys
=0);
52 virtual void OnEndDragRight(double x
, double y
, int keys
=0);
54 // Find object for mouse click, of given wxClassInfo (NULL for any type).
55 // If notImage is non-NULL, don't find an object that is equal to or a descendant of notImage
56 virtual wxShape
*FindShape(double x
, double y
, int *attachment
, wxClassInfo
*info
= NULL
, wxShape
*notImage
= NULL
);
57 wxShape
*FindFirstSensitiveShape(double x
, double y
, int *new_attachment
, int op
);
58 wxShape
*FindFirstSensitiveShape1(wxShape
*image
, int op
);
60 // Redirect to wxDiagram object
61 virtual void AddShape(wxShape
*object
, wxShape
*addAfter
= NULL
);
62 virtual void InsertShape(wxShape
*object
);
63 virtual void RemoveShape(wxShape
*object
);
64 virtual bool GetQuickEditMode();
65 virtual void Redraw(wxDC
& dc
);
66 void Snap(double *x
, double *y
);
69 void OnPaint(wxPaintEvent
& event
);
70 void OnMouseEvent(wxMouseEvent
& event
);
73 wxDiagram
* m_shapeDiagram
;
75 double m_oldDragX
, m_oldDragY
; // Previous drag coordinates
76 double m_firstDragX
, m_firstDragY
; // INITIAL drag coordinates
77 bool m_checkTolerance
; // Whether to check drag tolerance
78 wxShape
* m_draggedShape
;
79 int m_draggedAttachment
;