]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Program: canvas | |
3 | * | |
4 | * Author: Robert Roebling | |
5 | * | |
6 | * Copyright: (C) 1998, Robert Roebling | |
7 | * | |
8 | */ | |
9 | // For compilers that support precompilation, includes "wx/wx.h". | |
10 | ||
11 | #ifndef __test_H__ | |
12 | #define __test_H__ | |
13 | ||
14 | #ifdef __GNUG__ | |
15 | #pragma interface "test.cpp" | |
16 | #endif | |
17 | ||
18 | #ifndef WX_PRECOMP | |
19 | #include "wx/wx.h" | |
20 | #endif | |
21 | ||
22 | #include <wx/image.h> | |
23 | #include <wx/file.h> | |
24 | #include <wx/timer.h> | |
25 | #include <wx/log.h> | |
26 | #include <wx/splitter.h> | |
27 | ||
28 | #include "wx/canvas/canvas.h" | |
29 | #include "wx/canvas/polygon.h" | |
30 | ||
31 | class MyCanvas; | |
32 | ||
33 | // derived classes | |
34 | class MywxCanvasObjectRef: public wxCanvasObjectRef | |
35 | { | |
36 | DECLARE_DYNAMIC_CLASS(MywxCanvasObjectRef) | |
37 | ||
38 | public: | |
39 | MywxCanvasObjectRef(); | |
40 | MywxCanvasObjectRef(double x, double y, wxCanvasObjectGroup* group); | |
41 | ~MywxCanvasObjectRef(); | |
42 | ||
43 | void OnMouseEvent(wxMouseEvent &event); | |
44 | ||
45 | private: | |
46 | DECLARE_EVENT_TABLE() | |
47 | }; | |
48 | ||
49 | ||
50 | class MyEventHandler: public wxEvtHandler | |
51 | { | |
52 | public: | |
53 | MyEventHandler(); | |
54 | ||
55 | void OnMouseEvent(wxMouseEvent &event); | |
56 | ||
57 | private: | |
58 | ||
59 | DECLARE_EVENT_TABLE() | |
60 | }; | |
61 | ||
62 | ||
63 | class MySplitterWindow : public wxSplitterWindow | |
64 | { | |
65 | public: | |
66 | MySplitterWindow(wxFrame *parent, wxWindowID id) | |
67 | : wxSplitterWindow(parent, id, wxDefaultPosition, wxDefaultSize, wxSP_3D ) | |
68 | { | |
69 | m_frame = parent; | |
70 | } | |
71 | ||
72 | virtual bool OnSashPositionChange(int newSashPosition) | |
73 | { | |
74 | if ( !wxSplitterWindow::OnSashPositionChange(newSashPosition) ) | |
75 | return FALSE; | |
76 | ||
77 | wxString str; | |
78 | str.Printf( _T("Sash position = %d"), newSashPosition); | |
79 | m_frame->SetStatusText(str); | |
80 | ||
81 | return TRUE; | |
82 | } | |
83 | ||
84 | void SetStatusText(const wxString& str ){m_frame->SetStatusText(str);} | |
85 | ||
86 | private: | |
87 | wxFrame *m_frame; | |
88 | }; | |
89 | ||
90 | ||
91 | // MyFrame | |
92 | const int ID_ABOUT = 109; | |
93 | ||
94 | // MyFrame | |
95 | class MyFrame: public wxFrame | |
96 | { | |
97 | public: | |
98 | MyFrame(wxFrame* frame, const wxString& title, const wxPoint& pos, const wxSize& size); | |
99 | virtual ~MyFrame(); | |
100 | ||
101 | // Menu commands | |
102 | void SplitHorizontal(wxCommandEvent& event); | |
103 | void SplitVertical(wxCommandEvent& event); | |
104 | void Unsplit(wxCommandEvent& event); | |
105 | void SetMinSize(wxCommandEvent& event); | |
106 | void Quit(wxCommandEvent& event); | |
107 | ||
108 | // Menu command update functions | |
109 | void UpdateUIHorizontal(wxUpdateUIEvent& event); | |
110 | void UpdateUIVertical(wxUpdateUIEvent& event); | |
111 | void UpdateUIUnsplit(wxUpdateUIEvent& event); | |
112 | ||
113 | void OnAbout( wxCommandEvent &event ); | |
114 | void OnNewFrame( wxCommandEvent &event ); | |
115 | void OnQuit( wxCommandEvent &event ); | |
116 | void OnTimer( wxTimerEvent &event ); | |
117 | ||
118 | wxCanvasObject *m_sm1; | |
119 | wxCanvasObject *m_sm2; | |
120 | wxCanvasObject *m_sm3; | |
121 | wxCanvasObject *m_sm4; | |
122 | ||
123 | MywxCanvasObjectRef *m_ref; | |
124 | MywxCanvasObjectRef *m_ref2; | |
125 | ||
126 | wxTimer *m_timer; | |
127 | wxTextCtrl *m_log; | |
128 | ||
129 | wxBitmap gs_bmp36_mono; | |
130 | ||
131 | private: | |
132 | ||
133 | void UpdatePosition(); | |
134 | ||
135 | wxMenu* fileMenu; | |
136 | wxMenuBar* menuBar; | |
137 | MyCanvas* m_canvas1; | |
138 | MyCanvas* m_canvas2; | |
139 | MySplitterWindow* m_splitter; | |
140 | ||
141 | wxCanvasAdmin m_canvasadmin; | |
142 | ||
143 | wxCanvasObjectGroup* m_datatree; | |
144 | ||
145 | DECLARE_EVENT_TABLE() | |
146 | ||
147 | MyEventHandler* m_eventhandler; | |
148 | }; | |
149 | ||
150 | // ID for the menu commands | |
151 | enum | |
152 | { | |
153 | SPLIT_QUIT, | |
154 | SPLIT_HORIZONTAL, | |
155 | SPLIT_VERTICAL, | |
156 | SPLIT_UNSPLIT, | |
157 | SPLIT_SETMINSIZE | |
158 | }; | |
159 | ||
160 | // Window ids | |
161 | #define SPLITTER_WINDOW 100 | |
162 | #define SPLITTER_FRAME 101 | |
163 | #define CANVAS1 102 | |
164 | #define CANVAS2 103 | |
165 | ||
166 | class MyCanvas: public wxVectorCanvas | |
167 | { | |
168 | public: | |
169 | MyCanvas( wxCanvasAdmin* admin, MySplitterWindow *parent, wxWindowID id = -1, | |
170 | const wxPoint& pos = wxDefaultPosition, | |
171 | const wxSize& size = wxDefaultSize, | |
172 | long style = wxScrolledWindowStyle ); | |
173 | ||
174 | void OnMouseEvent(wxMouseEvent& event); | |
175 | ||
176 | private: | |
177 | ||
178 | //mouse position used for displaying it in the statusbar | |
179 | int m_mouse_x; | |
180 | //mouse position used for displaying it in the statusbar | |
181 | int m_mouse_y; | |
182 | //mouse position used for displaying it in the statusbar | |
183 | double m_mouse_worldx; | |
184 | //mouse position used for displaying it in the statusbar | |
185 | double m_mouse_worldy; | |
186 | ||
187 | //mouse position used for zooming | |
188 | double m_zoom_x1; | |
189 | //mouse position used for zooming | |
190 | double m_zoom_y1; | |
191 | //mouse position used for zooming | |
192 | double m_zoom_x2; | |
193 | //mouse position used for zooming | |
194 | double m_zoom_y2; | |
195 | ||
196 | //declare events | |
197 | DECLARE_EVENT_TABLE() | |
198 | ||
199 | //parent of the canvas | |
200 | MySplitterWindow *m_parent; | |
201 | }; | |
202 | ||
203 | // MyApp | |
204 | ||
205 | class MyApp: public wxApp | |
206 | { | |
207 | public: | |
208 | virtual bool OnInit(); | |
209 | ||
210 | const wxString& GetFontPath() const { return m_fontpath; } | |
211 | ||
212 | private: | |
213 | wxString m_fontpath; | |
214 | }; | |
215 | ||
216 | #endif |