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