A couple of fixes to Brazilian Portuguese translations from Felipe.
[wxWidgets.git] / samples / svg / svgtest.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: svgtest.cpp
3 // Purpose: SVG sample
4 // Author: Chris Elliott
5 // Modified by:
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9 // ===========================================================================
10 // declarations
11 // ===========================================================================
12
13 // ---------------------------------------------------------------------------
14 // headers
15 // ---------------------------------------------------------------------------
16
17 // For compilers that support precompilation, includes "wx/wx.h".
18 #include "wx/wxprec.h"
19
20 #ifdef __BORLANDC__
21 #pragma hdrstop
22 #endif
23
24 #ifndef WX_PRECOMP
25 #include "wx/wx.h"
26 #include "wx/mdi.h"
27 #endif
28
29 #include "wx/toolbar.h"
30 #include "wx/dcsvg.h"
31 #include "wx/vector.h"
32
33 #include "bitmaps/new.xpm"
34 #include "bitmaps/save.xpm"
35 #include "bitmaps/help.xpm"
36 #include "SVGlogo24.xpm"
37
38 #ifndef wxHAS_IMAGES_IN_RESOURCES
39 #include "../sample.xpm"
40 #endif
41
42 #include <math.h>
43
44 class MyChild;
45 class MyCanvas;
46
47 // ---------------------------------------------------------------------------
48 // classes
49 // ---------------------------------------------------------------------------
50
51 class MyApp : public wxApp
52 {
53 public:
54 bool OnInit();
55 };
56
57 class MyFrame : public wxMDIParentFrame
58 {
59 public:
60 MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title,
61 const wxPoint& pos, const wxSize& size, const long style);
62
63 void InitToolBar(wxToolBar* toolBar);
64
65 void OnSize(wxSizeEvent& event);
66 void OnAbout(wxCommandEvent& event);
67 void OnNewWindow(wxCommandEvent& event);
68 void OnQuit(wxCommandEvent& event);
69 void FileSavePicture (wxCommandEvent& event);
70
71 unsigned int GetCountOfChildren() const
72 { return m_nWinCreated; }
73
74 private:
75 unsigned int m_nWinCreated;
76
77 DECLARE_EVENT_TABLE()
78 };
79
80 class MyChild: public wxMDIChildFrame
81 {
82 public:
83 MyChild(wxMDIParentFrame *parent, const wxString& title,
84 const wxPoint& pos = wxDefaultPosition,
85 const wxSize& size = wxDefaultSize,
86 const long style = wxDEFAULT_FRAME_STYLE);
87 ~MyChild();
88
89 void OnActivate(wxActivateEvent& event);
90 void OnQuit(wxCommandEvent& event);
91 bool OnSave(wxString filename);
92
93 MyFrame* GetFrame()
94 { return m_frame; }
95
96 private:
97 MyCanvas *m_canvas;
98 MyFrame *m_frame;
99
100 DECLARE_EVENT_TABLE()
101 };
102
103 class MyCanvas : public wxScrolledWindow
104 {
105 public:
106 MyCanvas(MyChild *parent, const wxPoint& pos, const wxSize& size);
107 virtual void OnDraw(wxDC& dc);
108
109 private:
110 int m_index;
111 MyChild* m_child;
112
113 DECLARE_EVENT_TABLE()
114 };
115
116 // ---------------------------------------------------------------------------
117 // constants
118 // ---------------------------------------------------------------------------
119
120 // menu items ids
121 enum
122 {
123 MDI_QUIT = 100,
124 MDI_NEW_WINDOW,
125 MDI_SAVE,
126 MDI_REFRESH,
127 MDI_CHILD_QUIT,
128 MDI_ABOUT
129 };
130
131 // ---------------------------------------------------------------------------
132 // event tables
133 // ---------------------------------------------------------------------------
134
135 BEGIN_EVENT_TABLE(MyFrame, wxMDIParentFrame)
136 EVT_MENU(MDI_ABOUT, MyFrame::OnAbout)
137 EVT_MENU(MDI_NEW_WINDOW, MyFrame::OnNewWindow)
138 EVT_MENU(MDI_QUIT, MyFrame::OnQuit)
139 EVT_MENU (MDI_SAVE, MyFrame::FileSavePicture)
140
141 EVT_SIZE(MyFrame::OnSize)
142 END_EVENT_TABLE()
143
144 // ===========================================================================
145 // implementation
146 // ===========================================================================
147
148 // ---------------------------------------------------------------------------
149 // MyApp
150 // ---------------------------------------------------------------------------
151
152 IMPLEMENT_APP(MyApp)
153
154 bool MyApp::OnInit()
155 {
156 // Create the main frame window
157
158 MyFrame* frame = new MyFrame((wxFrame *)NULL, -1, wxT("SVG Demo"),
159 wxDefaultPosition, wxSize(500, 400),
160 wxDEFAULT_FRAME_STYLE | wxHSCROLL | wxVSCROLL);
161
162 frame->Show(true);
163
164 return true;
165 }
166
167
168 // ---------------------------------------------------------------------------
169 // MyFrame
170 // ---------------------------------------------------------------------------
171
172 // Define my frame constructor
173 MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title,
174 const wxPoint& pos, const wxSize& size, const long style)
175 : wxMDIParentFrame(parent, id, title, pos, size, style)
176 {
177 m_nWinCreated = 0;
178
179 SetIcon(wxICON(sample));
180
181 // Make a menubar
182 wxMenu *file_menu = new wxMenu;
183
184 file_menu->Append(MDI_NEW_WINDOW, wxT("&New test\tCtrl+N"));
185 file_menu->Append(MDI_QUIT, wxT("&Exit\tAlt+X"));
186
187 wxMenu *help_menu = new wxMenu;
188 help_menu->Append(MDI_ABOUT, wxT("&About"));
189
190 wxMenuBar *menu_bar = new wxMenuBar;
191
192 menu_bar->Append(file_menu, wxT("&File"));
193 menu_bar->Append(help_menu, wxT("&Help"));
194
195 // Associate the menu bar with the frame
196 SetMenuBar(menu_bar);
197
198 #if wxUSE_STATUSBAR
199 CreateStatusBar();
200 #endif // wxUSE_STATUSBAR
201
202 CreateToolBar(wxNO_BORDER | wxTB_FLAT | wxTB_HORIZONTAL);
203 InitToolBar(GetToolBar());
204 }
205
206 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
207 {
208 Close();
209 }
210
211 void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
212 {
213 (void)wxMessageBox(wxT("wxWidgets SVG sample\n")
214 wxT("Author: Chris Elliott (c) 2002-2009\n")
215 wxT("Usage: click File|New to show tests"),
216 wxT("About SVG Test"));
217 }
218
219 void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event) )
220 {
221 // Make another frame, containing a canvas
222 MyChild *subframe = new MyChild(this, wxT("SVG Frame"));
223
224 wxString title;
225 title.Printf(wxT("SVG Test Window %d"), m_nWinCreated );
226
227 // counts number of children previously, even if now closed
228 m_nWinCreated ++;
229
230 // Give it a title and icon
231 subframe->SetTitle(title);
232 subframe->SetIcon(wxICON(sample));
233
234 // Make a menubar
235 wxMenu *file_menu = new wxMenu;
236
237 file_menu->Append(MDI_NEW_WINDOW, wxT("&Another test\tCtrl+N"));
238 file_menu->Append(MDI_SAVE, wxT("&Save\tCtrl+S"), wxT("Save in SVG format"));
239 file_menu->Append(MDI_CHILD_QUIT, wxT("&Close child\tCtrl+F4"));
240 file_menu->Append(MDI_QUIT, wxT("&Exit\tAlt+X"));
241
242 wxMenu *help_menu = new wxMenu;
243 help_menu->Append(MDI_ABOUT, wxT("&About"));
244
245 wxMenuBar *menu_bar = new wxMenuBar;
246
247 menu_bar->Append(file_menu, wxT("&File"));
248 menu_bar->Append(help_menu, wxT("&Help"));
249
250 // Associate the menu bar with the frame
251 subframe->SetMenuBar(menu_bar);
252
253 subframe->Show(true);
254 }
255
256 void MyFrame::OnSize(wxSizeEvent& event)
257 {
258 int w, h;
259 GetClientSize(&w, &h);
260
261 GetClientWindow()->SetSize(0, 0, w, h);
262 event.Skip();
263 }
264
265 void MyFrame::InitToolBar(wxToolBar* toolBar)
266 {
267 const int maxBitmaps = 3;
268 wxBitmap* bitmaps[maxBitmaps];
269
270 bitmaps[0] = new wxBitmap( new_xpm );
271 bitmaps[1] = new wxBitmap( save_xpm );
272 bitmaps[2] = new wxBitmap( help_xpm );
273
274 toolBar->AddTool(MDI_NEW_WINDOW, wxEmptyString, *(bitmaps[0]), wxS("New SVG test window"));
275 toolBar->AddTool(MDI_SAVE, wxEmptyString, *bitmaps[1], wxS("Save test in SVG format"));
276 toolBar->AddSeparator();
277 toolBar->AddTool(MDI_ABOUT, wxEmptyString, *bitmaps[2], wxS("Help"));
278
279 toolBar->Realize();
280
281 int i;
282 for (i = 0; i < maxBitmaps; i++)
283 delete bitmaps[i];
284 }
285
286 void MyFrame::FileSavePicture (wxCommandEvent & WXUNUSED(event) )
287 {
288 #if wxUSE_FILEDLG
289 MyChild * pChild = (MyChild *)GetActiveChild();
290 if (pChild == NULL)
291 {
292 return;
293 }
294
295 wxFileDialog dialog(this, wxT("Save Picture as"), wxEmptyString, pChild->GetTitle(),
296 wxT("SVG vector picture files (*.svg)|*.svg"),
297 wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
298
299 if (dialog.ShowModal() == wxID_OK)
300 {
301 if (!pChild->OnSave ( dialog.GetPath() ))
302 {
303 return;
304 }
305 }
306 return;
307 #endif // wxUSE_FILEDLG
308 }
309
310
311 // ---------------------------------------------------------------------------
312 // MyCanvas
313 // ---------------------------------------------------------------------------
314
315 BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
316 END_EVENT_TABLE()
317
318 // Define a constructor for my canvas
319 MyCanvas::MyCanvas(MyChild *parent, const wxPoint& pos, const wxSize& size)
320 : wxScrolledWindow(parent, wxID_ANY, pos, size, wxSUNKEN_BORDER|wxVSCROLL|wxHSCROLL)
321 {
322 SetBackgroundColour(*wxWHITE);
323
324 m_child = parent;
325 m_index = m_child->GetFrame()->GetCountOfChildren() % 9;
326 }
327
328 // Define the repainting behaviour
329 void MyCanvas::OnDraw(wxDC& dc)
330 {
331 // vars to use ...
332 #if wxUSE_STATUSBAR
333 wxString s;
334 #endif // wxUSE_STATUSBAR
335 wxPen wP;
336 wxBrush wB;
337 wxPoint points[6];
338 wxColour wC;
339 wxFont wF;
340
341 dc.SetFont(*wxSWISS_FONT);
342 dc.SetPen(*wxGREEN_PEN);
343
344 switch (m_index)
345 {
346 default:
347 case 0:
348 // draw lines to make a cross
349 dc.DrawLine(0, 0, 200, 200);
350 dc.DrawLine(200, 0, 0, 200);
351 // draw point colored line and spline
352 wP = *wxCYAN_PEN;
353 wP.SetWidth(3);
354 dc.SetPen(wP);
355
356 dc.DrawPoint (25,15);
357 dc.DrawLine(50, 30, 200, 30);
358 dc.DrawSpline(50, 200, 50, 100, 200, 10);
359 #if wxUSE_STATUSBAR
360 s = wxT("Green Cross, Cyan Line and spline");
361 #endif // wxUSE_STATUSBAR
362 break;
363
364 case 1:
365 // draw standard shapes
366 dc.SetBrush(*wxCYAN_BRUSH);
367 dc.SetPen(*wxRED_PEN);
368 dc.DrawRectangle(10, 10, 100, 70);
369 wB = wxBrush (wxT("DARK ORCHID"), wxBRUSHSTYLE_TRANSPARENT);
370 dc.SetBrush (wB);
371 dc.DrawRoundedRectangle(50, 50, 100, 70, 20);
372 dc.SetBrush (wxBrush(wxT("GOLDENROD")) );
373 dc.DrawEllipse(100, 100, 100, 50);
374
375 points[0].x = 100; points[0].y = 200;
376 points[1].x = 70; points[1].y = 260;
377 points[2].x = 160; points[2].y = 230;
378 points[3].x = 40; points[3].y = 230;
379 points[4].x = 130; points[4].y = 260;
380 points[5].x = 100; points[5].y = 200;
381
382 dc.DrawPolygon(5, points);
383 dc.DrawLines (6, points, 160);
384 #if wxUSE_STATUSBAR
385 s = wxT("Blue rectangle, red edge, clear rounded rectangle, gold ellipse, gold and clear stars");
386 #endif // wxUSE_STATUSBAR
387 break;
388
389 case 2:
390 // draw text in Arial or similar font
391 dc.DrawLine(50,25,50,35);
392 dc.DrawLine(45,30,55,30);
393 dc.DrawText(wxT("This is a Swiss-style string"), 50, 30);
394 wC = dc.GetTextForeground();
395 dc.SetTextForeground (wxT("FIREBRICK"));
396
397 // no effect in msw ??
398 dc.SetTextBackground (wxT("WHEAT"));
399 dc.DrawText(wxT("This is a Red string"), 50, 200);
400 dc.DrawRotatedText(wxT("This is a 45 deg string"), 50, 200, 45);
401 dc.DrawRotatedText(wxT("This is a 90 deg string"), 50, 200, 90);
402 wF = wxFont ( 18, wxROMAN, wxITALIC, wxBOLD, false, wxT("Times New Roman"));
403 dc.SetFont(wF);
404 dc.SetTextForeground (wC);
405 dc.DrawText(wxT("This is a Times-style string"), 50, 60);
406 #if wxUSE_STATUSBAR
407 s = wxT("Swiss, Times text; red text, rotated and colored orange");
408 #endif // wxUSE_STATUSBAR
409 break;
410
411 case 3 :
412 // four arcs start and end points, center
413 dc.SetBrush(*wxGREEN_BRUSH);
414 dc.DrawArc ( 200,300, 370,230, 300,300 );
415 dc.SetBrush(*wxBLUE_BRUSH);
416 dc.DrawArc ( 270-50, 270-86, 270-86, 270-50, 270,270 );
417 dc.SetDeviceOrigin(-10,-10);
418 dc.DrawArc ( 270-50, 270-86, 270-86, 270-50, 270,270 );
419 dc.SetDeviceOrigin(0,0);
420
421 wP.SetColour (wxT("CADET BLUE"));
422 dc.SetPen(wP);
423 dc.DrawArc ( 75,125, 110, 40, 75, 75 );
424
425 wP.SetColour (wxT("SALMON"));
426 dc.SetPen(wP);
427 dc.SetBrush(*wxRED_BRUSH);
428 //top left corner, width and height, start and end angle
429 // 315 same center and x-radius as last pie-arc, half Y radius
430 dc.DrawEllipticArc(25,50,100,50,180.0,45.0);
431
432 wP = *wxCYAN_PEN;
433 wP.SetWidth(3);
434 dc.SetPen(wP);
435 //wxTRANSPARENT));
436 dc.SetBrush (wxBrush (wxT("SALMON")));
437 dc.DrawEllipticArc(300, 0,200,100, 0.0,145.0);
438 //same end point
439 dc.DrawEllipticArc(300, 50,200,100,90.0,145.0);
440 dc.DrawEllipticArc(300,100,200,100,90.0,345.0);
441
442 #if wxUSE_STATUSBAR
443 s = wxT("This is an arc test page");
444 #endif // wxUSE_STATUSBAR
445 break;
446
447 case 4:
448 dc.DrawCheckMark ( 30,30,25,25);
449 dc.SetBrush (wxBrush (wxT("SALMON"),wxBRUSHSTYLE_TRANSPARENT));
450 dc.DrawCheckMark ( 80,50,75,75);
451 dc.DrawRectangle ( 80,50,75,75);
452 #if wxUSE_STATUSBAR
453 s = wxT("Two check marks");
454 #endif // wxUSE_STATUSBAR
455 break;
456
457 case 5:
458 wF = wxFont ( 18, wxROMAN, wxITALIC, wxBOLD, false, wxT("Times New Roman"));
459 dc.SetFont(wF);
460 dc.DrawLine(0, 0, 200, 200);
461 dc.DrawLine(200, 0, 0, 200);
462 dc.DrawText(wxT("This is an 18pt string"), 50, 60);
463
464 // rescale and draw in blue
465 wP = *wxCYAN_PEN;
466 dc.SetPen(wP);
467 dc.SetUserScale (2.0,0.5);
468 dc.SetDeviceOrigin(200,0);
469 dc.DrawLine(0, 0, 200, 200);
470 dc.DrawLine(200, 0, 0, 200);
471 dc.DrawText(wxT("This is an 18pt string 2 x 0.5 UserScaled"), 50, 60);
472 dc.SetUserScale (2.0,2.0);
473 dc.SetDeviceOrigin(200,200);
474 dc.DrawText(wxT("This is an 18pt string 2 x 2 UserScaled"), 50, 60);
475
476 wP = *wxRED_PEN;
477 dc.SetPen(wP);
478 dc.SetUserScale (1.0,1.0);
479 dc.SetDeviceOrigin(0,10);
480 dc.SetMapMode (wxMM_METRIC); //svg ignores this
481 dc.DrawLine(0, 0, 200, 200);
482 dc.DrawLine(200, 0, 0, 200);
483 dc.DrawText(wxT("This is an 18pt string in MapMode"), 50, 60);
484 #if wxUSE_STATUSBAR
485 s = wxT("Scaling test page");
486 #endif // wxUSE_STATUSBAR
487 break;
488
489 case 6:
490 dc.DrawIcon( wxICON(sample), 10, 10 );
491 dc.DrawBitmap ( wxBitmap(svgbitmap_xpm), 50,15);
492 #if wxUSE_STATUSBAR
493 s = wxT("Icon and Bitmap ");
494 #endif // wxUSE_STATUSBAR
495 break;
496
497 case 7:
498 dc.SetTextForeground(wxT("RED"));
499 dc.DrawText(wxT("Red = Clipping Off"), 30, 5);
500 dc.SetTextForeground(wxT("GREEN"));
501 dc.DrawText(wxT("Green = Clipping On"), 30, 25);
502
503 dc.SetTextForeground(wxT("BLACK"));
504
505 dc.SetPen(*wxRED_PEN);
506 dc.SetBrush (wxBrush (wxT("SALMON"),wxBRUSHSTYLE_TRANSPARENT));
507 dc.DrawCheckMark ( 80,50,75,75);
508 dc.DrawRectangle ( 80,50,75,75);
509
510 dc.SetPen(*wxGREEN_PEN);
511
512 // Clipped checkmarks
513 dc.DrawRectangle(180,50,75,75);
514 dc.SetClippingRegion(180,50,75,75); // x,y,width,height version
515 dc.DrawCheckMark ( 180,50,75,75);
516 dc.DestroyClippingRegion();
517
518 dc.DrawRectangle(wxRect(80,150,75,75));
519 dc.SetClippingRegion(wxPoint(80,150),wxSize(75,75)); // pt,size version
520 dc.DrawCheckMark ( 80,150,75,75);
521 dc.DestroyClippingRegion();
522
523 dc.DrawRectangle(wxRect(180,150,75,75));
524 dc.SetClippingRegion(wxRect(180,150,75,75)); // rect version
525 dc.DrawCheckMark ( 180,150,75,75);
526 dc.DestroyClippingRegion();
527
528 dc.DrawRectangle(wxRect( 80,250,50,65));
529 dc.DrawRectangle(wxRect(105,260,50,65));
530 dc.SetClippingRegion(wxRect( 80,250,50,65)); // second call to SetClippingRegion
531 dc.SetClippingRegion(wxRect(105,260,50,65)); // forms intersection with previous
532 dc.DrawCheckMark(80,250,75,75);
533 dc.DestroyClippingRegion(); // only one call to destroy (there's no stack)
534
535 /*
536 ** Clipping by wxRegion not implemented for SVG. Should be
537 ** possible, but need to access points that define the wxRegion
538 ** from inside DoSetDeviceClippingRegion() and wxRegion does not
539 ** implement anything like getPoints().
540 points[0].x = 180; points[0].y = 250;
541 points[1].x = 255; points[1].y = 250;
542 points[2].x = 180; points[2].y = 325;
543 points[3].x = 255; points[3].y = 325;
544 points[4].x = 180; points[4].y = 250;
545
546 dc.DrawLines (5, points);
547 wxRegion reg = wxRegion(5,points);
548
549 dc.SetClippingRegion(reg);
550 dc.DrawCheckMark ( 180,250,75,75);
551 dc.DestroyClippingRegion();
552 */
553
554 #if wxUSE_STATUSBAR
555 s = wxT("Clipping region");
556 #endif // wxUSE_STATUSBAR
557 break;
558
559 case 8:
560 wxString txtStr;
561 wxCoord txtX, txtY, txtW, txtH, txtDescent, txtEL;
562 wxCoord txtPad = 0;
563
564 wP = *wxRED_PEN;
565 dc.SetPen(wP);
566 //dc.SetBackgroundMode(wxBRUSHSTYLE_SOLID);
567 //dc.SetTextBackground(*wxBLUE);
568
569 // Horizontal text
570 txtStr = wxT("Horizontal string");
571 dc.GetTextExtent(txtStr, &txtW, &txtH, &txtDescent, &txtEL);
572 txtX = 50;
573 txtY = 300;
574 dc.DrawRectangle(txtX, txtY, txtW + 2*txtPad, txtH + 2*txtPad);
575 dc.DrawText(txtStr, txtX + txtPad, txtY + txtPad);
576
577 // Vertical text
578 txtStr = wxT("Vertical string");
579 dc.GetTextExtent(txtStr, &txtW, &txtH, &txtDescent, &txtEL);
580 txtX = 50;
581 txtY = 250;
582 dc.DrawRectangle(txtX, txtY - (txtW + 2*txtPad), txtH + 2*txtPad, txtW + 2*txtPad);
583 dc.DrawRotatedText(txtStr, txtX + txtPad, txtY - txtPad, 90);
584
585 // 45 degree text
586 txtStr = wxT("45 deg string");
587 dc.GetTextExtent(txtStr, &txtW, &txtH, &txtDescent, &txtEL);
588 double lenW = (double)(txtW + 2*txtPad) / sqrt(2.0);
589 double lenH = (double)(txtH + 2*txtPad) / sqrt(2.0);
590 double padding = (double)txtPad / sqrt(2.0);
591 txtX = 150;
592 txtY = 200;
593 dc.DrawLine(txtX - padding, txtY, txtX + lenW, txtY - lenW); // top
594 dc.DrawLine(txtX + lenW, txtY - lenW, txtX - padding + lenH + lenW, txtY + (lenH - lenW));
595 dc.DrawLine(txtX - padding, txtY, txtX - padding + lenH, txtY + lenH);
596 dc.DrawLine(txtX - padding + lenH, txtY + lenH, txtX - padding + lenH + lenW, txtY + (lenH - lenW)); // bottom
597 dc.DrawRotatedText(txtStr, txtX, txtY, 45);
598 #if wxUSE_STATUSBAR
599 s = wxT("Text position test page");
600 #endif // wxUSE_STATUSBAR
601 break;
602 }
603 #if wxUSE_STATUSBAR
604 m_child->SetStatusText(s);
605 #endif // wxUSE_STATUSBAR
606 }
607
608
609 // ---------------------------------------------------------------------------
610 // MyChild
611 // ---------------------------------------------------------------------------
612
613 // Note that MDI_NEW_WINDOW and MDI_ABOUT commands get passed
614 // to the parent window for processing, so no need to
615 // duplicate event handlers here.
616 BEGIN_EVENT_TABLE(MyChild, wxMDIChildFrame)
617 EVT_MENU(MDI_CHILD_QUIT, MyChild::OnQuit)
618 END_EVENT_TABLE()
619
620 MyChild::MyChild(wxMDIParentFrame *parent, const wxString& title,
621 const wxPoint& pos, const wxSize& size,
622 const long style)
623 : wxMDIChildFrame(parent, wxID_ANY, title, pos, size, style)
624 {
625 m_frame = (MyFrame *) parent;
626
627 #if wxUSE_STATUSBAR
628 CreateStatusBar();
629 SetStatusText(title);
630 #endif // wxUSE_STATUSBAR
631
632 m_canvas = new MyCanvas(this, wxPoint(0, 0), GetClientSize());
633
634 // Give it scrollbars
635 m_canvas->SetScrollbars(20, 20, 50, 50);
636 }
637
638 MyChild::~MyChild()
639 {
640 }
641
642 void MyChild::OnQuit(wxCommandEvent& WXUNUSED(event))
643 {
644 Close(true);
645 }
646
647 bool MyChild::OnSave(wxString filename)
648 {
649 wxSVGFileDC svgDC (filename, 600, 650);
650 m_canvas->OnDraw (svgDC);
651 return svgDC.IsOk();
652 }
653
654 void MyChild::OnActivate(wxActivateEvent& event)
655 {
656 if ( event.GetActive() && m_canvas )
657 m_canvas->SetFocus();
658 }
659