]> git.saurik.com Git - wxWidgets.git/blob - contrib/samples/ogl/studio/view.h
Applied patch [ 1489741 ] Bugfix for wxScrolledWindow::SetScrollRate in wxUniversal
[wxWidgets.git] / contrib / samples / ogl / studio / view.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: contrib/samples/ogl/studio/view.h
3 // Purpose: View-related classes
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 12/07/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _STUDIO_VIEW_H_
13 #define _STUDIO_VIEW_H_
14
15 #include "doc.h"
16 #include "wx/ogl/ogl.h"
17
18 class csDiagramView;
19 class csCanvas: public wxShapeCanvas
20 {
21 DECLARE_CLASS(csCanvas)
22 public:
23
24 csCanvas(csDiagramView *view, wxWindow *parent = NULL, wxWindowID id = wxID_ANY,
25 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
26 long style = wxRETAINED);
27 ~csCanvas(void);
28
29 void DrawOutline(wxDC& dc, double x1, double y1, double x2, double y2);
30
31 void OnMouseEvent(wxMouseEvent& event);
32 void OnPaint(wxPaintEvent& event);
33
34 virtual void OnLeftClick(double x, double y, int keys = 0);
35 virtual void OnRightClick(double x, double y, int keys = 0);
36
37 virtual void OnDragLeft(bool draw, double x, double y, int keys=0); // Erase if draw false
38 virtual void OnBeginDragLeft(double x, double y, int keys=0);
39 virtual void OnEndDragLeft(double x, double y, int keys=0);
40
41 virtual void OnDragRight(bool draw, double x, double y, int keys=0); // Erase if draw false
42 virtual void OnBeginDragRight(double x, double y, int keys=0);
43 virtual void OnEndDragRight(double x, double y, int keys=0);
44
45 inline csDiagramView* GetView() const { return m_view; }
46 inline void SetView(csDiagramView* view) { m_view = view; }
47
48 protected:
49 csDiagramView* m_view;
50
51 DECLARE_EVENT_TABLE()
52 };
53
54 class csDiagramView: public wxView
55 {
56 DECLARE_DYNAMIC_CLASS(csDiagramView)
57 public:
58 csDiagramView(void) { canvas = NULL; frame = NULL; };
59 ~csDiagramView(void);
60
61 bool OnCreate(wxDocument *doc, long flags);
62 void OnDraw(wxDC *dc);
63 void OnUpdate(wxView *sender, wxObject *hint = NULL);
64 bool OnClose(bool deleteWindow = true);
65 void OnSelectAll(wxCommandEvent& event);
66
67 wxShape *FindFirstSelectedShape(void);
68
69 // Scans the canvas for selections (doesn't use m_selections)
70 void FindSelectedShapes(wxList& selections, wxClassInfo* toFind = NULL);
71
72 // The selections in the order in which they were selected
73 inline wxList& GetSelectionList() const { return (wxList&) m_selections; }
74
75 // Adds or removes shape from m_selections
76 void SelectShape(wxShape* shape, bool select);
77
78 // Apply point size to current shapes
79 void ApplyPointSize(int pointSize);
80
81 // Make the point size combobox reflect this
82 void ReflectPointSize(int pointSize);
83
84 // Make the arrow toggle button reflect the state of the line
85 void ReflectArrowState(wxLineShape* lineShape);
86
87 // Do a cut operation for the given list of shapes
88 void DoCut(wxList& shapes);
89
90 // Do a general command
91 void DoCmd(wxList& shapes, wxList& oldShapes, int cmd, const wxString& op);
92
93 // Select or deselect all
94 void SelectAll(bool select = true);
95
96 // Event handlers
97 void OnCut(wxCommandEvent& event);
98 void OnCopy(wxCommandEvent& event);
99 void OnPaste(wxCommandEvent& event);
100 void OnDuplicate(wxCommandEvent& event);
101 void OnClear(wxCommandEvent& event);
102 void OnChangeBackgroundColour(wxCommandEvent& event);
103 void OnEditProperties(wxCommandEvent& event);
104 void OnPointSizeComboSel(wxCommandEvent& event);
105 void OnPointSizeComboText(wxCommandEvent& event);
106 void OnToggleArrowTool(wxCommandEvent& event);
107 void OnZoomSel(wxCommandEvent& event);
108 void OnAlign(wxCommandEvent& event);
109 void OnNewLinePoint(wxCommandEvent& event);
110 void OnCutLinePoint(wxCommandEvent& event);
111 void OnStraightenLines(wxCommandEvent& event);
112
113 // UI update handles
114 void OnToggleArrowToolUpdate(wxUpdateUIEvent& event);
115 void OnEditPropertiesUpdate(wxUpdateUIEvent& event);
116 void OnCutUpdate(wxUpdateUIEvent& event);
117 void OnClearUpdate(wxUpdateUIEvent& event);
118 void OnCopyUpdate(wxUpdateUIEvent& event);
119 void OnPasteUpdate(wxUpdateUIEvent& event);
120 void OnDuplicateUpdate(wxUpdateUIEvent& event);
121 void OnAlignUpdate(wxUpdateUIEvent& event);
122 void OnNewLinePointUpdate(wxUpdateUIEvent& event);
123 void OnCutLinePointUpdate(wxUpdateUIEvent& event);
124 void OnStraightenLinesUpdate(wxUpdateUIEvent& event);
125 void OnUndoUpdate(wxUpdateUIEvent& event);
126 void OnRedoUpdate(wxUpdateUIEvent& event);
127
128 DECLARE_EVENT_TABLE()
129
130 public:
131 wxMDIChildFrame* frame;
132 csCanvas* canvas;
133 wxList m_selections;
134 };
135
136 #endif
137 // _STUDIO_VIEW_H_