]>
Commit | Line | Data |
---|---|---|
957f5ab7 VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: expended.cpp | |
3 | // Purpose: Layout/foldpanelbar sample | |
4 | // Author: Jorgen Bodde | |
5 | // Modified by: | |
6 | // Created: 24/07/2004 | |
7 | // Copyright: (c) Jorgen Bodde based upon FoldPanelBarTest (c) Julian Smart | |
8 | // Licence: wxWindows license | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | // For compilers that support precompilation, includes "wx/wx.h". | |
12 | #include "wx/wxprec.h" | |
13 | ||
14 | #ifdef __BORLANDC__ | |
15 | #pragma hdrstop | |
16 | #endif | |
17 | ||
18 | #ifndef WX_PRECOMP | |
19 | #include "wx/wx.h" | |
20 | #include "wx/mdi.h" | |
21 | #endif | |
22 | ||
23 | #include "wx/toolbar.h" | |
24 | #include "wx/laywin.h" | |
25 | #include <wx/spinctrl.h> | |
26 | #include <wx/slider.h> | |
27 | ||
28 | #include "extended.h" | |
29 | ||
30 | MyFrame *frame = NULL; | |
31 | wxList my_children; | |
32 | ||
33 | IMPLEMENT_APP(MyApp) | |
34 | ||
35 | // For drawing lines in a canvas | |
36 | long xpos = -1; | |
37 | long ypos = -1; | |
38 | ||
39 | int winNumber = 1; | |
40 | ||
41 | // Initialise this in OnInit, not statically | |
42 | bool MyApp::OnInit(void) | |
43 | { | |
44 | // Create the main frame window | |
45 | ||
46 | frame = new MyFrame(NULL, -1, _T("FoldPanelBar Extended Demo"), wxPoint(-1, -1), wxSize(500, 600), | |
47 | wxDEFAULT_FRAME_STYLE | | |
48 | wxNO_FULL_REPAINT_ON_RESIZE | | |
49 | wxHSCROLL | wxVSCROLL); | |
50 | ||
51 | // Give it an icon (this is ignored in MDI mode: uses resources) | |
52 | ||
53 | #ifdef __WXMSW__ | |
54 | frame->SetIcon(wxIcon(_T("sashtest_icn"))); | |
55 | #endif | |
56 | ||
57 | // Associate the menu bar with the frame | |
58 | frame->SetMenuBar(CreateMenuBar(false)); | |
59 | ||
60 | frame->CreateStatusBar(); | |
61 | ||
62 | frame->Show(TRUE); | |
63 | ||
64 | SetTopWindow(frame); | |
65 | ||
66 | return TRUE; | |
67 | } | |
68 | ||
69 | BEGIN_EVENT_TABLE(MyFrame, wxMDIParentFrame) | |
70 | EVT_MENU(FPBTEST_ABOUT, MyFrame::OnAbout) | |
71 | EVT_MENU(FPBTEST_NEW_WINDOW, MyFrame::OnNewWindow) | |
72 | EVT_SIZE(MyFrame::OnSize) | |
73 | EVT_MENU(FPBTEST_QUIT, MyFrame::OnQuit) | |
74 | EVT_MENU(FPBTEST_TOGGLE_WINDOW, MyFrame::OnToggleWindow) | |
75 | EVT_SASH_DRAGGED_RANGE(ID_WINDOW_TOP, ID_WINDOW_BOTTOM, MyFrame::OnFoldPanelBarDrag) | |
76 | EVT_MENU(FPB_BOTTOM_STICK, MyFrame::OnCreateBottomStyle) | |
77 | EVT_MENU(FPB_SINGLE_FOLD, MyFrame::OnCreateNormalStyle) | |
78 | EVT_BUTTON(ID_COLLAPSEME, MyFrame::OnCollapseMe) | |
79 | EVT_BUTTON(ID_APPLYTOALL, MyFrame::OnExpandMe) | |
80 | EVT_SCROLL(MyFrame::OnSlideColour) | |
81 | EVT_RADIOBUTTON(ID_USE_HGRADIENT, MyFrame::OnStyleChange) | |
82 | EVT_RADIOBUTTON(ID_USE_VGRADIENT, MyFrame::OnStyleChange) | |
83 | EVT_RADIOBUTTON(ID_USE_SINGLE, MyFrame::OnStyleChange) | |
84 | EVT_RADIOBUTTON(ID_USE_RECTANGLE, MyFrame::OnStyleChange) | |
85 | EVT_RADIOBUTTON(ID_USE_FILLED_RECTANGLE, MyFrame::OnStyleChange) | |
86 | END_EVENT_TABLE() | |
87 | ||
88 | ||
89 | // Define my frame constructor | |
90 | MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, | |
91 | const long style) | |
92 | : wxMDIParentFrame(parent, id, title, pos, size, style) | |
93 | , _flags(0) | |
94 | { | |
95 | m_leftWindow1 = new wxSashLayoutWindow(this, ID_WINDOW_LEFT1, | |
96 | wxDefaultPosition, wxSize(200, 30), | |
97 | wxNO_BORDER | wxSW_3D | wxCLIP_CHILDREN); | |
98 | ||
99 | m_leftWindow1->SetDefaultSize(wxSize(160, 1000)); | |
100 | m_leftWindow1->SetOrientation(wxLAYOUT_VERTICAL); | |
101 | m_leftWindow1->SetAlignment(wxLAYOUT_LEFT); | |
102 | m_leftWindow1->SetSashVisible(wxSASH_RIGHT, TRUE); | |
103 | m_leftWindow1->SetExtraBorderSize(0); | |
104 | ||
105 | _pnl = 0; | |
106 | ReCreateFoldPanel(0); | |
107 | } | |
108 | ||
109 | void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) | |
110 | { | |
111 | Close(TRUE); | |
112 | } | |
113 | ||
114 | void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) | |
115 | { | |
116 | (void)wxMessageBox(_T("wxWidgets 2.0 FoldPanelBar Demo\nAuthor: Julian Smart (c) 1998"), _T("About FoldPanelBar Demo")); | |
117 | } | |
118 | ||
119 | void MyFrame::OnToggleWindow(wxCommandEvent& WXUNUSED(event)) | |
120 | { | |
121 | m_leftWindow1->Show(!m_leftWindow1->IsShown()); | |
122 | wxLayoutAlgorithm layout; | |
123 | layout.LayoutMDIFrame(this); | |
124 | } | |
125 | ||
126 | void MyFrame::OnFoldPanelBarDrag(wxSashEvent& event) | |
127 | { | |
128 | if (event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE) | |
129 | return; | |
130 | ||
131 | if(event.GetId() == ID_WINDOW_LEFT1) | |
132 | m_leftWindow1->SetDefaultSize(wxSize(event.GetDragRect().width, 1000)); | |
133 | ||
134 | wxLayoutAlgorithm layout; | |
135 | layout.LayoutMDIFrame(this); | |
136 | ||
137 | // Leaves bits of itself behind sometimes | |
138 | GetClientWindow()->Refresh(); | |
139 | } | |
140 | ||
141 | void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event)) | |
142 | { | |
143 | // Make another frame, containing a canvas | |
144 | MyChild *subframe = new MyChild(frame, _T("Canvas Frame"), | |
145 | wxPoint(10, 10), wxSize(300, 300), | |
146 | wxDEFAULT_FRAME_STYLE | | |
147 | wxNO_FULL_REPAINT_ON_RESIZE); | |
148 | ||
149 | subframe->SetTitle(wxString::Format(_T("Canvas Frame %d"), winNumber)); | |
150 | winNumber ++; | |
151 | ||
152 | // Give it an icon (this is ignored in MDI mode: uses resources) | |
153 | #ifdef __WXMSW__ | |
154 | subframe->SetIcon(wxIcon(_T("sashtest_icn"))); | |
155 | #endif | |
156 | ||
157 | // Give it a status line | |
158 | subframe->CreateStatusBar(); | |
159 | ||
160 | // Associate the menu bar with the frame | |
161 | subframe->SetMenuBar(CreateMenuBar(true)); | |
162 | ||
163 | int width, height; | |
164 | subframe->GetClientSize(&width, &height); | |
165 | MyCanvas *canvas = new MyCanvas(subframe, wxPoint(0, 0), wxSize(width, height)); | |
166 | canvas->SetCursor(wxCursor(wxCURSOR_PENCIL)); | |
167 | subframe->canvas = canvas; | |
168 | ||
169 | // Give it scrollbars | |
170 | canvas->SetScrollbars(20, 20, 50, 50); | |
171 | ||
172 | subframe->Show(TRUE); | |
173 | } | |
174 | ||
175 | void MyFrame::ReCreateFoldPanel(int fpb_flags) | |
176 | { | |
177 | // delete earlier panel | |
178 | m_leftWindow1->DestroyChildren(); | |
179 | ||
180 | // recreate the foldpanelbar | |
181 | ||
182 | _pnl = new wxFoldPanelBar(m_leftWindow1, -1, wxDefaultPosition, wxSize(-1,-1), wxFPB_DEFAULT_STYLE, fpb_flags); | |
183 | ||
184 | wxFoldPanel item = _pnl->AddFoldPanel("Caption colours", false); | |
185 | ||
186 | _pnl->AddFoldPanelWindow(item, new wxStaticText(item.GetParent(), -1, _T("Adjust the first colour")), | |
187 | wxFPB_ALIGN_WIDTH, 5, 20); | |
188 | ||
189 | // RED color spin control | |
190 | _rslider1 = new wxSlider(item.GetParent(), -1, 0, 0, 255); | |
191 | _pnl->AddFoldPanelWindow(item, _rslider1, wxFPB_ALIGN_WIDTH, | |
192 | 2, 20); | |
193 | ||
194 | // GREEN color spin control | |
195 | _gslider1 = new wxSlider(item.GetParent(), -1, 0, 0, 255); | |
196 | _pnl->AddFoldPanelWindow(item, _gslider1, wxFPB_ALIGN_WIDTH, | |
197 | 0, 20); | |
198 | ||
199 | // BLUE color spin control | |
200 | _bslider1 = new wxSlider(item.GetParent(), -1, 0, 0, 255); | |
201 | _pnl->AddFoldPanelWindow(item, _bslider1, wxFPB_ALIGN_WIDTH, | |
202 | 0, 20); | |
203 | ||
204 | _pnl->AddFoldPanelSeperator(item); | |
205 | ||
206 | _pnl->AddFoldPanelWindow(item, new wxStaticText(item.GetParent(), -1, _T("Adjust the second colour")), | |
207 | wxFPB_ALIGN_WIDTH, 5, 20); | |
208 | ||
209 | // RED color spin control | |
210 | _rslider2 = new wxSlider(item.GetParent(), -1, 0, 0, 255); | |
211 | _pnl->AddFoldPanelWindow(item, _rslider2, wxFPB_ALIGN_WIDTH, | |
212 | 2, 20); | |
213 | ||
214 | // GREEN color spin control | |
215 | _gslider2 = new wxSlider(item.GetParent(), -1, 0, 0, 255); | |
216 | _pnl->AddFoldPanelWindow(item, _gslider2, wxFPB_ALIGN_WIDTH, | |
217 | 0, 20); | |
218 | ||
219 | // BLUE color spin control | |
220 | _bslider2 = new wxSlider(item.GetParent(), -1, 0, 0, 255); | |
221 | _pnl->AddFoldPanelWindow(item, _bslider2, wxFPB_ALIGN_WIDTH, | |
222 | 0, 20); | |
223 | ||
224 | _pnl->AddFoldPanelSeperator(item); | |
225 | ||
226 | _btn = new wxButton(item.GetParent(), ID_APPLYTOALL, "Apply to all"); | |
227 | _pnl->AddFoldPanelWindow(item, _btn); | |
228 | ||
229 | // read back current gradients and set the sliders | |
230 | // for the colour which is now taken as default | |
231 | ||
232 | wxCaptionBarStyle style = _pnl->GetCaptionStyle(item); | |
233 | wxColour col = style.GetFirstColour(); | |
234 | _rslider1->SetValue(col.Red()); | |
235 | _gslider1->SetValue(col.Green()); | |
236 | _bslider1->SetValue(col.Blue()); | |
237 | ||
238 | col = style.GetSecondColour(); | |
239 | _rslider2->SetValue(col.Red()); | |
240 | _gslider2->SetValue(col.Green()); | |
241 | _bslider2->SetValue(col.Blue()); | |
242 | ||
243 | // put down some caption styles from which the user can | |
244 | // select to show how the current or all caption bars will look like | |
245 | ||
246 | item = _pnl->AddFoldPanel("Caption style", false); | |
247 | ||
248 | wxRadioButton *currStyle = new wxRadioButton(item.GetParent(), ID_USE_VGRADIENT, "&Vertical gradient"); | |
249 | _pnl->AddFoldPanelWindow(item, currStyle, wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_YSPACING, 10); | |
250 | currStyle->SetValue(true); | |
251 | ||
252 | _pnl->AddFoldPanelWindow(item, new wxRadioButton(item.GetParent(), ID_USE_HGRADIENT, "&Horizontal gradient"), | |
253 | wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_YSPACING, 10); | |
254 | _pnl->AddFoldPanelWindow(item, new wxRadioButton(item.GetParent(), ID_USE_SINGLE, "&Single colour"), | |
255 | wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_YSPACING, 10); | |
256 | _pnl->AddFoldPanelWindow(item, new wxRadioButton(item.GetParent(), ID_USE_RECTANGLE, "&Rectangle box"), | |
257 | wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_YSPACING, 10); | |
258 | _pnl->AddFoldPanelWindow(item, new wxRadioButton(item.GetParent(), ID_USE_FILLED_RECTANGLE, "&Filled rectangle box"), | |
259 | wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_YSPACING, 10); | |
260 | ||
261 | _pnl->AddFoldPanelSeperator(item); | |
262 | ||
263 | _single = new wxCheckBox(item.GetParent(), -1, "&Only this caption"); | |
264 | _pnl->AddFoldPanelWindow(item, _single, wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_YSPACING, 10); | |
265 | ||
266 | ||
267 | // one more panel to finish it | |
268 | ||
269 | wxCaptionBarStyle cs; | |
270 | cs.SetCaptionStyle(wxCAPTIONBAR_RECTANGLE); | |
271 | ||
272 | item = _pnl->AddFoldPanel("Misc stuff", true, cs); | |
273 | ||
274 | _pnl->AddFoldPanelWindow(item, new wxButton(item.GetParent(), ID_COLLAPSEME, "Collapse All")); | |
275 | ||
276 | _pnl->AddFoldPanelWindow(item, new wxStaticText(item.GetParent(), -1, _T("Enter some comments")), | |
277 | wxFPB_ALIGN_WIDTH, 5, 20); | |
278 | ||
279 | _pnl->AddFoldPanelWindow(item, new wxTextCtrl(item.GetParent(), -1, "Comments"), | |
280 | wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_YSPACING, 10); | |
281 | ||
282 | m_leftWindow1->SizeWindows(); | |
283 | ||
284 | } | |
285 | ||
286 | void MyFrame::OnCreateBottomStyle(wxCommandEvent& event) | |
287 | { | |
288 | // recreate with style collapse to bottom, which means | |
289 | // all panels that are collapsed are placed at the bottom, | |
290 | // or normal | |
291 | ||
292 | if(event.IsChecked()) | |
293 | _flags |= wxFPB_COLLAPSE_TO_BOTTOM; | |
294 | else | |
295 | _flags &= ~wxFPB_COLLAPSE_TO_BOTTOM; | |
296 | ||
297 | ReCreateFoldPanel(_flags); | |
298 | } | |
299 | ||
300 | void MyFrame::OnCreateNormalStyle(wxCommandEvent& event) | |
301 | { | |
302 | // receate with style where only one panel at the time is | |
303 | // allowed to be opened | |
304 | ||
305 | // TODO: Not yet implemented! | |
306 | ||
307 | if(event.IsChecked()) | |
308 | _flags |= wxFPB_SINGLE_FOLD; | |
309 | else | |
310 | _flags &= ~wxFPB_SINGLE_FOLD; | |
311 | ||
312 | ReCreateFoldPanel(_flags); | |
313 | } | |
314 | ||
315 | void MyFrame::OnCollapseMe(wxCommandEvent &event) | |
316 | { | |
317 | wxFoldPanel item(0); | |
318 | for(size_t i = 0; i < _pnl->GetCount(); i++) | |
319 | { | |
320 | item = _pnl->Item(i); | |
321 | _pnl->Collapse(item); | |
322 | } | |
323 | } | |
324 | ||
325 | void MyFrame::OnExpandMe(wxCommandEvent &event) | |
326 | { | |
327 | wxColour col1(_rslider1->GetValue(), _gslider1->GetValue(), _bslider1->GetValue()), | |
328 | col2(_rslider2->GetValue(), _gslider2->GetValue(), _bslider2->GetValue()); | |
329 | ||
330 | wxCaptionBarStyle style; | |
331 | ||
332 | style.SetFirstColour(col1); | |
333 | style.SetSecondColour(col2); | |
334 | ||
335 | _pnl->ApplyCaptionStyleAll(style); | |
336 | } | |
337 | ||
338 | wxMenuBar *CreateMenuBar(bool with_window) | |
339 | { | |
340 | // Make a menubar | |
341 | wxMenu *file_menu = new wxMenu; | |
342 | ||
343 | file_menu->Append(FPBTEST_NEW_WINDOW, _T("&New window")); | |
344 | if(with_window) | |
345 | file_menu->Append(FPBTEST_CHILD_QUIT, _T("&Close child")); | |
346 | ||
347 | file_menu->AppendSeparator(); | |
348 | file_menu->Append(FPBTEST_QUIT, _T("&Exit")); | |
349 | ||
350 | wxMenu *option_menu = 0; | |
351 | if(with_window) | |
352 | { | |
353 | // Dummy option | |
354 | option_menu = new wxMenu; | |
355 | option_menu->Append(FPBTEST_REFRESH, _T("&Refresh picture")); | |
356 | } | |
357 | ||
358 | // make fold panel menu | |
359 | ||
360 | wxMenu *fpb_menu = new wxMenu; | |
361 | fpb_menu->AppendCheckItem(FPB_BOTTOM_STICK, _T("Create with &wxFPB_COLLAPSE_TO_BOTTOM")); | |
362 | //fpb_menu->AppendCheckItem(FPB_SINGLE_FOLD, _T("Create with &wxFPB_SINGLE_FOLD")); | |
363 | ||
364 | fpb_menu->AppendSeparator(); | |
365 | fpb_menu->Append(FPBTEST_TOGGLE_WINDOW, _T("&Toggle FoldPanelBar")); | |
366 | ||
367 | wxMenu *help_menu = new wxMenu; | |
368 | help_menu->Append(FPBTEST_ABOUT, _T("&About")); | |
369 | ||
370 | wxMenuBar *menu_bar = new wxMenuBar; | |
371 | ||
372 | menu_bar->Append(file_menu, _T("&File")); | |
373 | menu_bar->Append(fpb_menu, _T("&FoldPanel")); | |
374 | if(option_menu) | |
375 | menu_bar->Append(option_menu, _T("&Options")); | |
376 | menu_bar->Append(help_menu, _T("&Help")); | |
377 | ||
378 | return menu_bar; | |
379 | } | |
380 | ||
381 | void MyFrame::OnSlideColour(wxScrollEvent &event) | |
382 | { | |
383 | wxColour col1(_rslider1->GetValue(), _gslider1->GetValue(), _bslider1->GetValue()), | |
384 | col2(_rslider2->GetValue(), _gslider2->GetValue(), _bslider2->GetValue()); | |
385 | //_btn->SetBackgroundColour(col); | |
386 | ||
387 | wxCaptionBarStyle style; | |
388 | ||
389 | style.SetFirstColour(col1); | |
390 | style.SetSecondColour(col2); | |
391 | ||
392 | wxFoldPanel item = _pnl->Item(0); | |
393 | _pnl->ApplyCaptionStyle(item, style); | |
394 | } | |
395 | ||
396 | void MyFrame::OnStyleChange(wxCommandEvent &event) | |
397 | { | |
398 | wxCaptionBarStyle style; | |
399 | switch(event.GetId()) | |
400 | { | |
401 | case ID_USE_HGRADIENT: | |
402 | style.SetCaptionStyle(wxCAPTIONBAR_GRADIENT_H); | |
403 | break; | |
404 | ||
405 | case ID_USE_VGRADIENT: | |
406 | style.SetCaptionStyle(wxCAPTIONBAR_GRADIENT_V); | |
407 | break; | |
408 | ||
409 | case ID_USE_SINGLE: | |
410 | style.SetCaptionStyle(wxCAPTIONBAR_SINGLE); | |
411 | break; | |
412 | ||
413 | case ID_USE_RECTANGLE: | |
414 | style.SetCaptionStyle(wxCAPTIONBAR_RECTANGLE); | |
415 | break; | |
416 | ||
417 | case ID_USE_FILLED_RECTANGLE: | |
418 | style.SetCaptionStyle(wxCAPTIONBAR_FILLED_RECTANGLE); | |
419 | break; | |
420 | ||
421 | default: | |
422 | break; | |
423 | } | |
424 | ||
425 | if(_single->GetValue()) | |
426 | { | |
427 | wxFoldPanel item = _pnl->Item(1); | |
428 | _pnl->ApplyCaptionStyle(item, style); | |
429 | } | |
430 | else | |
431 | _pnl->ApplyCaptionStyleAll(style); | |
432 | ||
433 | } | |
434 | ||
435 | /* ----------------------------------------------------------------------------------------------- */ | |
436 | ||
437 | BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow) | |
438 | EVT_MOUSE_EVENTS(MyCanvas::OnEvent) | |
439 | END_EVENT_TABLE() | |
440 | ||
441 | // Define a constructor for my canvas | |
442 | MyCanvas::MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size) | |
443 | : wxScrolledWindow(parent, -1, pos, size, | |
444 | wxSUNKEN_BORDER | wxNO_FULL_REPAINT_ON_RESIZE) | |
445 | { | |
446 | SetBackgroundColour(* wxWHITE); | |
447 | } | |
448 | ||
449 | // Define the repainting behaviour | |
450 | void MyCanvas::OnDraw(wxDC& dc) | |
451 | { | |
452 | dc.SetFont(*wxSWISS_FONT); | |
453 | dc.SetPen(*wxGREEN_PEN); | |
454 | dc.DrawLine(0, 0, 200, 200); | |
455 | dc.DrawLine(200, 0, 0, 200); | |
456 | ||
457 | dc.SetBrush(*wxCYAN_BRUSH); | |
458 | dc.SetPen(*wxRED_PEN); | |
459 | dc.DrawRectangle(100, 100, 100, 50); | |
460 | dc.DrawRoundedRectangle(150, 150, 100, 50, 20); | |
461 | ||
462 | dc.DrawEllipse(250, 250, 100, 50); | |
463 | #if wxUSE_SPLINES | |
464 | dc.DrawSpline(50, 200, 50, 100, 200, 10); | |
465 | #endif // wxUSE_SPLINES | |
466 | dc.DrawLine(50, 230, 200, 230); | |
467 | dc.DrawText(_T("This is a test string"), 50, 230); | |
468 | ||
469 | wxPoint points[3]; | |
470 | points[0].x = 200; points[0].y = 300; | |
471 | points[1].x = 100; points[1].y = 400; | |
472 | points[2].x = 300; points[2].y = 400; | |
473 | ||
474 | dc.DrawPolygon(3, points); | |
475 | } | |
476 | ||
477 | // This implements a tiny doodling program! Drag the mouse using | |
478 | // the left button. | |
479 | void MyCanvas::OnEvent(wxMouseEvent& event) | |
480 | { | |
481 | wxClientDC dc(this); | |
482 | PrepareDC(dc); | |
483 | ||
484 | wxPoint pt(event.GetLogicalPosition(dc)); | |
485 | ||
486 | if (xpos > -1 && ypos > -1 && event.Dragging()) | |
487 | { | |
488 | dc.SetPen(*wxBLACK_PEN); | |
489 | dc.DrawLine(xpos, ypos, pt.x, pt.y); | |
490 | } | |
491 | xpos = pt.x; | |
492 | ypos = pt.y; | |
493 | } | |
494 | ||
495 | void MyFrame::OnSize(wxSizeEvent& WXUNUSED(event)) | |
496 | { | |
497 | wxLayoutAlgorithm layout; | |
498 | layout.LayoutMDIFrame(this); | |
499 | } | |
500 | ||
501 | // Note that FPBTEST_NEW_WINDOW and FPBTEST_ABOUT commands get passed | |
502 | // to the parent window for processing, so no need to | |
503 | // duplicate event handlers here. | |
504 | ||
505 | BEGIN_EVENT_TABLE(MyChild, wxMDIChildFrame) | |
506 | EVT_MENU(FPBTEST_CHILD_QUIT, MyChild::OnQuit) | |
507 | END_EVENT_TABLE() | |
508 | ||
509 | MyChild::MyChild(wxMDIParentFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size, | |
510 | const long style): | |
511 | wxMDIChildFrame(parent, -1, title, pos, size, style) | |
512 | { | |
513 | canvas = NULL; | |
514 | my_children.Append(this); | |
515 | } | |
516 | ||
517 | MyChild::~MyChild(void) | |
518 | { | |
519 | my_children.DeleteObject(this); | |
520 | } | |
521 | ||
522 | void MyChild::OnQuit(wxCommandEvent& WXUNUSED(event)) | |
523 | { | |
524 | Close(TRUE); | |
525 | } | |
526 | ||
527 | void MyChild::OnActivate(wxActivateEvent& event) | |
528 | { | |
529 | if (event.GetActive() && canvas) | |
530 | canvas->SetFocus(); | |
531 | } | |
532 |