Added test for region clipping.
[wxWidgets.git] / samples / drawing / drawing.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: drawing.cpp
3 // Purpose: shows and tests wxDC features
4 // Author: Robert Roebling
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #ifdef __GNUG__
21 #pragma implementation "drawing.cpp"
22 #pragma interface "drawing.cpp"
23 #endif
24
25 // For compilers that support precompilation, includes "wx/wx.h".
26 #include "wx/wxprec.h"
27
28 #ifdef __BORLANDC__
29 #pragma hdrstop
30 #endif
31
32 // for all others, include the necessary headers (this file is usually all you
33 // need because it includes almost all "standard" wxWindows headers
34 #ifndef WX_PRECOMP
35 #include "wx/wx.h"
36 #endif
37
38 #include "wx/colordlg.h"
39 #include "wx/image.h"
40
41 // ----------------------------------------------------------------------------
42 // ressources
43 // ----------------------------------------------------------------------------
44
45 // the application icon
46 #if defined(__WXGTK__) || defined(__WXMOTIF__)
47 #include "mondrian.xpm"
48 #endif
49
50 // ----------------------------------------------------------------------------
51 // constants
52 // ----------------------------------------------------------------------------
53
54 // what do we show on screen (there are too many shapes to put them all on
55 // screen simultaneously)
56 enum ScreenToShow
57 {
58 Show_Default,
59 Show_Text,
60 Show_Lines,
61 Show_Polygons,
62 Show_Mask,
63 Show_Ops,
64 Show_Regions
65 };
66
67 // ----------------------------------------------------------------------------
68 // global variables
69 // ----------------------------------------------------------------------------
70
71 static wxBitmap gs_bmpNoMask,
72 gs_bmpWithColMask,
73 gs_bmpMask,
74 gs_bmpWithMask,
75 gs_bmp4,
76 gs_bmp36;
77
78 // ----------------------------------------------------------------------------
79 // private classes
80 // ----------------------------------------------------------------------------
81
82 // Define a new application type, each program should derive a class from wxApp
83 class MyApp : public wxApp
84 {
85 public:
86 // override base class virtuals
87 // ----------------------------
88
89 // this one is called on application startup and is a good place for the app
90 // initialization (doing it here and not in the ctor allows to have an error
91 // return: if OnInit() returns false, the application terminates)
92 virtual bool OnInit();
93
94 protected:
95 bool LoadImages();
96 };
97
98 class MyCanvas;
99
100 // Define a new frame type: this is going to be our main frame
101 class MyFrame : public wxFrame
102 {
103 public:
104 // ctor(s)
105 MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
106
107 // event handlers (these functions should _not_ be virtual)
108 void OnQuit(wxCommandEvent& event);
109 void OnAbout(wxCommandEvent& event);
110 void OnShow(wxCommandEvent &event);
111 void OnOption(wxCommandEvent &event);
112
113 wxColour SelectColour();
114 void PrepareDC(wxDC& dc);
115
116 int m_backgroundMode;
117 int m_textureBackground;
118 int m_mapMode;
119 double m_xUserScale;
120 double m_yUserScale;
121 int m_xLogicalOrigin;
122 int m_yLogicalOrigin;
123 bool m_xAxisReversed,
124 m_yAxisReversed;
125 wxColour m_colourForeground, // these are _text_ colours
126 m_colourBackground;
127 wxBrush m_backgroundBrush;
128 MyCanvas *m_canvas;
129
130 private:
131 // any class wishing to process wxWindows events must use this macro
132 DECLARE_EVENT_TABLE()
133 };
134
135 // define a scrollable canvas for drawing onto
136 class MyCanvas: public wxScrolledWindow
137 {
138 public:
139 MyCanvas( MyFrame *parent );
140
141 void OnPaint(wxPaintEvent &event);
142 void OnMouseMove(wxMouseEvent &event);
143
144 void Show(ScreenToShow show) { m_show = show; Refresh(); }
145
146 protected:
147 void DrawTestPoly( int x, int y, wxDC &dc ,int transparent );
148 void DrawTestLines( int x, int y, int width, wxDC &dc );
149 void DrawText(wxDC& dc);
150 void DrawImages(wxDC& dc);
151 void DrawWithLogicalOps(wxDC& dc);
152 void DrawRegions(wxDC& dc);
153 void DrawDefault(wxDC& dc);
154
155 private:
156 MyFrame *m_owner;
157
158 ScreenToShow m_show;
159 wxBitmap m_smile_bmp;
160 wxIcon m_std_icon;
161
162 DECLARE_EVENT_TABLE()
163 };
164
165 // ----------------------------------------------------------------------------
166 // constants
167 // ----------------------------------------------------------------------------
168
169 // IDs for the controls and the menu commands
170 enum
171 {
172 // menu items
173 File_Quit = 1,
174 File_About,
175
176 MenuShow_First,
177 File_ShowDefault = MenuShow_First,
178 File_ShowText,
179 File_ShowLines,
180 File_ShowPolygons,
181 File_ShowMask,
182 File_ShowOps,
183 File_ShowRegions,
184 MenuShow_Last = File_ShowRegions,
185
186 MenuOption_First,
187
188 MapMode_Text = MenuOption_First,
189 MapMode_Lometric,
190 MapMode_Twips,
191 MapMode_Points,
192 MapMode_Metric,
193
194 UserScale_StretchHoriz,
195 UserScale_ShrinkHoriz,
196 UserScale_StretchVertic,
197 UserScale_ShrinkVertic,
198 UserScale_Restore,
199
200 AxisMirror_Horiz,
201 AxisMirror_Vertic,
202
203 LogicalOrigin_MoveDown,
204 LogicalOrigin_MoveUp,
205 LogicalOrigin_MoveLeft,
206 LogicalOrigin_MoveRight,
207
208 Colour_TextForeground,
209 Colour_TextBackground,
210 Colour_Background,
211 Colour_BackgroundMode,
212 Colour_TextureBackgound,
213
214 MenuOption_Last = Colour_TextureBackgound
215 };
216
217 // ----------------------------------------------------------------------------
218 // event tables and other macros for wxWindows
219 // ----------------------------------------------------------------------------
220
221
222 // Create a new application object: this macro will allow wxWindows to create
223 // the application object during program execution (it's better than using a
224 // static object for many reasons) and also declares the accessor function
225 // wxGetApp() which will return the reference of the right type (i.e. MyApp and
226 // not wxApp)
227 IMPLEMENT_APP(MyApp)
228
229 // ============================================================================
230 // implementation
231 // ============================================================================
232
233 // ----------------------------------------------------------------------------
234 // the application class
235 // ----------------------------------------------------------------------------
236
237 bool MyApp::LoadImages()
238 {
239 wxPathList pathList;
240 pathList.Add(".");
241 pathList.Add("..");
242
243 wxString path = pathList.FindValidPath("pat4.bmp");
244 if ( !path )
245 return FALSE;
246 gs_bmp4.LoadFile(path, wxBITMAP_TYPE_BMP);
247 wxMask* mask4 = new wxMask(gs_bmp4, *wxBLACK);
248 gs_bmp4.SetMask(mask4);
249
250 path = pathList.FindValidPath("pat36.bmp");
251 if ( !path )
252 return FALSE;
253 gs_bmp36.LoadFile(path, wxBITMAP_TYPE_BMP);
254 wxMask* mask36 = new wxMask(gs_bmp36, *wxBLACK);
255 gs_bmp36.SetMask(mask36);
256
257 path = pathList.FindValidPath("image.bmp");
258 if ( !path )
259 return FALSE;
260 gs_bmpNoMask.LoadFile(path, wxBITMAP_TYPE_BMP);
261 gs_bmpWithMask.LoadFile(path, wxBITMAP_TYPE_BMP);
262 gs_bmpWithColMask.LoadFile(path, wxBITMAP_TYPE_BMP);
263
264 path = pathList.FindValidPath("mask.bmp");
265 if ( !path )
266 return FALSE;
267 gs_bmpMask.LoadFile(path, wxBITMAP_TYPE_BMP);
268
269 // This is so wrong, it hurts.
270 // gs_bmpMask.SetDepth(1);
271 // wxMask *mask = new wxMask(gs_bmpMask);
272
273 wxMask *mask = new wxMask(gs_bmpMask, *wxBLACK);
274 gs_bmpWithMask.SetMask(mask);
275
276 mask = new wxMask(gs_bmpWithColMask, *wxWHITE);
277 gs_bmpWithColMask.SetMask(mask);
278
279 return TRUE;
280 }
281
282 // `Main program' equivalent: the program execution "starts" here
283 bool MyApp::OnInit()
284 {
285 // Create the main application window
286 MyFrame *frame = new MyFrame("Drawing sample",
287 wxPoint(50, 50), wxSize(550, 340));
288
289 // Show it and tell the application that it's our main window
290 frame->Show(TRUE);
291 SetTopWindow(frame);
292
293 if ( !LoadImages() )
294 {
295 wxLogError("Can't load one of the bitmap files needed for this sample "
296 "from the current or parent directory, please copy them "
297 "there.");
298
299 // stop here
300 return FALSE;
301 }
302
303 // ok, continue
304 return TRUE;
305 }
306
307 // ----------------------------------------------------------------------------
308 // MyCanvas
309 // ----------------------------------------------------------------------------
310
311 // the event tables connect the wxWindows events with the functions (event
312 // handlers) which process them.
313 BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
314 EVT_PAINT (MyCanvas::OnPaint)
315 EVT_MOTION (MyCanvas::OnMouseMove)
316 END_EVENT_TABLE()
317
318 #include "../image/smile.xpm"
319
320 MyCanvas::MyCanvas( MyFrame *parent ) : wxScrolledWindow( parent )
321 {
322 m_owner = parent;
323 m_show = Show_Default;
324 m_smile_bmp = wxBitmap(smile_xpm);
325 m_std_icon = wxTheApp->GetStdIcon(wxICON_INFORMATION);
326 }
327
328 //draw a polygon and an overlapping rectangle
329 //is transparent is 1, the fill pattern are made transparent
330 //is transparent is 2, the fill pattern are made transparent but inversed
331 //is transparent is 0 the text for and background color will be used to represent/map
332 //the colors of the monochrome bitmap pixels to the fillpattern
333 //
334 //i miss_used the the menu items for setting so called back and fore ground color
335 //just to show how the those colors do influence the fillpatterns
336 //just play with those,
337 //and with the code
338 //variations are endless using other logical functions
339 void MyCanvas::DrawTestPoly( int x, int y,wxDC &dc,int transparent )
340 {
341 wxBrush* brush4 = new wxBrush(gs_bmp4);
342 wxBrush* brush36 = new wxBrush(gs_bmp36);
343
344 wxPoint todraw[5];
345 todraw[0].x=(long)x+100;
346 todraw[0].y=(long)y+100;
347 todraw[1].x=(long)x+300;
348 todraw[1].y=(long)y+100;
349 todraw[2].x=(long)x+300;
350 todraw[2].y=(long)y+300;
351 todraw[3].x=(long)x+150;
352 todraw[3].y=(long)y+350;
353 todraw[4].x=(long)x+100;
354 todraw[4].y=(long)y+300;
355
356 wxPoint todraw2[5];
357 todraw2[0].x=100;
358 todraw2[0].y=100;
359 todraw2[1].x=300;
360 todraw2[1].y=100;
361 todraw2[2].x=300;
362 todraw2[2].y=300;
363 todraw2[3].x=150;
364 todraw2[3].y=350;
365 todraw2[4].x=100;
366 todraw2[4].y=300;
367
368 switch (transparent)
369 {
370 case 0:
371 {
372 dc.SetPen( wxPen( "black", 4, wxSOLID) );
373 dc.SetBrush( *brush4 );
374 dc.SetTextForeground(*wxGREEN);
375 dc.SetTextBackground(m_owner->m_colourForeground);
376 dc.SetLogicalFunction(wxCOPY);
377 dc.DrawPolygon(5,todraw,0,0,wxWINDING_RULE);
378
379 //don't understand hwo but the outline is also depending on logicalfunction
380 dc.SetPen( wxPen( "red", 4, wxSOLID) );
381 dc.SetBrush( *brush36 );
382 dc.SetTextForeground(*wxCYAN);
383 dc.SetTextBackground(m_owner->m_colourBackground);
384 dc.SetLogicalFunction(wxCOPY);
385 dc.DrawRectangle( x+10, y+10, 200, 200 );
386 dc.SetBrush(wxNullBrush);
387 dc.SetPen(wxNullPen);
388 break;
389 }
390 case 1: //now with transparent fillpatterns
391 {
392
393 wxBitmap* bmpBlit = new wxBitmap(600,400);
394 wxMemoryDC* memDC= new wxMemoryDC();
395 // wxBrush _clearbrush(*wxGREEN,wxSOLID);
396 wxBrush _clearbrush(*wxBLACK,wxSOLID);
397 memDC->SelectObject(*bmpBlit);
398 memDC->BeginDrawing();
399 memDC->SetBackground(_clearbrush);
400 memDC->Clear();
401 memDC->SetBackground(wxNullBrush);
402
403 memDC->SetPen( wxPen( "black", 4, wxSOLID) );
404 memDC->SetBrush( wxNullBrush);
405 memDC->SetBrush( *brush4 );
406 memDC->SetTextForeground(*wxBLACK); // 0s --> 0x000000 (black)
407 memDC->SetTextBackground(*wxWHITE); // 1s --> 0xFFFFFF (white)
408 memDC->SetLogicalFunction(wxAND_INVERT);
409
410 // BLACK OUT the opaque pixels and leave the rest as is
411 memDC->DrawPolygon(5,todraw2,0,0,wxWINDING_RULE);
412
413 // Set background and foreground colors for fill pattern
414 //the previous blacked out pixels are now merged with the layer color
415 //while the non blacked out pixels stay as they are.
416 memDC->SetTextForeground(*wxBLACK); // 0s --> 0x000000 (black)
417
418 //now define what will be the color of the fillpattern parts that are not transparent
419 // memDC->SetTextBackground(*wxBLUE);
420 memDC->SetTextBackground(m_owner->m_colourForeground);
421 memDC->SetLogicalFunction(wxOR);
422
423
424 //don't understand how but the outline is also depending on logicalfunction
425 memDC->SetPen( wxPen( "red", 4, wxSOLID) );
426 memDC->DrawPolygon(5,todraw2,0,0,wxWINDING_RULE);
427
428 memDC->SetLogicalFunction(wxCOPY);
429
430 memDC->SetPen( wxPen( "black", 4, wxSOLID) );
431 memDC->SetBrush( wxNullBrush);
432 memDC->SetBrush( *brush36 );
433 memDC->SetTextForeground(*wxBLACK); // 0s --> 0x000000 (black)
434 memDC->SetTextBackground(*wxWHITE); // 1s --> 0xFFFFFF (white)
435 memDC->SetLogicalFunction(wxAND_INVERT);
436
437 memDC->DrawRectangle( 10, 10, 200, 200 );
438
439 // Set background and foreground colors for fill pattern
440 //the previous blacked out pixels are now merged with the layer color
441 //while the non blacked out pixels stay as they are.
442 memDC->SetTextForeground(*wxBLACK); // 0s --> 0x000000 (black)
443 //now define what will be the color of the fillpattern parts that are not transparent
444 // memDC->SetTextBackground(*wxRED);
445 memDC->SetTextBackground(m_owner->m_colourBackground);
446 memDC->SetLogicalFunction(wxOR);
447
448 //don't understand how but the outline is also depending on logicalfunction
449 memDC->SetPen( wxPen( "yellow", 4, wxSOLID) );
450 memDC->DrawRectangle( 10, 10, 200, 200 );
451
452 memDC->SetBrush(wxNullBrush);
453 memDC->SetPen(wxNullPen);
454
455 memDC->EndDrawing();
456 dc.Blit(x,y,600,400,memDC,0,0,wxCOPY);
457 delete bmpBlit;
458 delete memDC;
459 break;
460 }
461 case 2: //now with transparent inversed fillpatterns
462 {
463 wxBitmap* bmpBlit = new wxBitmap(600,400);
464 wxMemoryDC* memDC= new wxMemoryDC();
465 wxBrush _clearbrush(*wxWHITE,wxSOLID);
466 memDC->SelectObject(*bmpBlit);
467 memDC->BeginDrawing();
468 memDC->SetBackground(_clearbrush);
469 memDC->Clear();
470 memDC->SetBackground(wxNullBrush);
471
472 memDC->SetPen( wxPen( "black", 4, wxSOLID) );
473 memDC->SetBrush( *brush4 );
474 memDC->SetTextBackground(*wxBLACK); // 0s --> 0x000000 (black)
475 memDC->SetTextForeground(*wxWHITE); // 1s --> 0xFFFFFF (white)
476 memDC->SetLogicalFunction(wxAND_INVERT);
477
478 // BLACK OUT the opaque pixels and leave the rest as is
479 memDC->DrawPolygon(5,todraw2,0,0,wxWINDING_RULE);
480
481 // Set background and foreground colors for fill pattern
482 //the previous blacked out pixels are now merged with the layer color
483 //while the non blacked out pixels stay as they are.
484 memDC->SetTextBackground(*wxBLACK); // 0s --> 0x000000 (black)
485
486 //now define what will be the color of the fillpattern parts that are not transparent
487 memDC->SetTextForeground(m_owner->m_colourForeground);
488 memDC->SetLogicalFunction(wxOR);
489
490
491 //don't understand how but the outline is also depending on logicalfunction
492 memDC->SetPen( wxPen( "red", 4, wxSOLID) );
493 memDC->DrawPolygon(5,todraw2,0,0,wxWINDING_RULE);
494
495 memDC->SetLogicalFunction(wxCOPY);
496
497 memDC->SetPen( wxPen( "black", 4, wxSOLID) );
498 memDC->SetBrush( *brush36 );
499 memDC->SetTextBackground(*wxBLACK); // 0s --> 0x000000 (black)
500 memDC->SetTextForeground(*wxWHITE); // 1s --> 0xFFFFFF (white)
501 memDC->SetLogicalFunction(wxAND_INVERT);
502
503 memDC->DrawRectangle( 10,10, 200, 200 );
504
505 // Set background and foreground colors for fill pattern
506 //the previous blacked out pixels are now merged with the layer color
507 //while the non blacked out pixels stay as they are.
508 memDC->SetTextBackground(*wxBLACK); // 0s --> 0x000000 (black)
509 //now define what will be the color of the fillpattern parts that are not transparent
510 memDC->SetTextForeground(m_owner->m_colourBackground);
511 memDC->SetLogicalFunction(wxOR);
512
513 //don't understand how but the outline is also depending on logicalfunction
514 memDC->SetPen( wxPen( "yellow", 4, wxSOLID) );
515 memDC->DrawRectangle( 10, 10, 200, 200 );
516
517 memDC->SetBrush(wxNullBrush);
518 memDC->SetPen(wxNullPen);
519 dc.Blit(x,y,600,400,memDC,0,0,wxCOPY);
520 delete bmpBlit;
521 delete memDC;
522 }
523 }
524
525 delete brush4;
526 delete brush36;
527 }
528
529 void MyCanvas::DrawTestLines( int x, int y, int width, wxDC &dc )
530 {
531 dc.SetPen( wxPen( "black", width, wxSOLID) );
532 dc.SetBrush( *wxRED_BRUSH );
533 dc.DrawRectangle( x+10, y+10, 100, 190 );
534
535 dc.SetPen( wxPen( "black", width, wxSOLID) );
536 dc.DrawLine( x+20, y+20, 100, y+20 );
537 dc.SetPen( wxPen( "black", width, wxDOT) );
538 dc.DrawLine( x+20, y+30, 100, y+30 );
539 dc.SetPen( wxPen( "black", width, wxSHORT_DASH) );
540 dc.DrawLine( x+20, y+40, 100, y+40 );
541 dc.SetPen( wxPen( "black", width, wxLONG_DASH) );
542 dc.DrawLine( x+20, y+50, 100, y+50 );
543 dc.SetPen( wxPen( "black", width, wxDOT_DASH) );
544 dc.DrawLine( x+20, y+60, 100, y+60 );
545
546 dc.SetPen( wxPen( "black", width, wxBDIAGONAL_HATCH) );
547 dc.DrawLine( x+20, y+70, 100, y+70 );
548 dc.SetPen( wxPen( "black", width, wxCROSSDIAG_HATCH) );
549 dc.DrawLine( x+20, y+80, 100, y+80 );
550 dc.SetPen( wxPen( "black", width, wxFDIAGONAL_HATCH) );
551 dc.DrawLine( x+20, y+90, 100, y+90 );
552 dc.SetPen( wxPen( "black", width, wxCROSS_HATCH) );
553 dc.DrawLine( x+20, y+100, 100, y+100 );
554 dc.SetPen( wxPen( "black", width, wxHORIZONTAL_HATCH) );
555 dc.DrawLine( x+20, y+110, 100, y+110 );
556 dc.SetPen( wxPen( "black", width, wxVERTICAL_HATCH) );
557 dc.DrawLine( x+20, y+120, 100, y+120 );
558
559 wxPen ud( "black", width, wxUSER_DASH );
560 wxDash dash1[1];
561 dash1[0] = 0;
562 ud.SetDashes( 1, dash1 );
563 dc.DrawLine( x+20, y+140, 100, y+140 );
564 dash1[0] = 1;
565 ud.SetDashes( 1, dash1 );
566 dc.DrawLine( x+20, y+150, 100, y+150 );
567 dash1[0] = 2;
568 ud.SetDashes( 1, dash1 );
569 dc.DrawLine( x+20, y+160, 100, y+160 );
570 dash1[0] = 0xFF;
571 ud.SetDashes( 1, dash1 );
572 dc.DrawLine( x+20, y+170, 100, y+170 );
573 }
574
575 void MyCanvas::DrawDefault(wxDC& dc)
576 {
577 // mark the origin
578 dc.DrawCircle(0, 0, 10);
579 #if !(defined __WXGTK__) && !(defined __WXMOTIF__)
580 // not implemented in wxGTK or wxMOTIF :-(
581 dc.FloodFill(0, 0, wxColour(255, 0, 0));
582 #endif //
583
584 dc.DrawIcon( wxICON(mondrian), 40, 40 );
585
586 dc.DrawCheckMark(5, 80, 15, 15);
587 dc.DrawCheckMark(25, 80, 30, 30);
588 dc.DrawCheckMark(60, 80, 60, 60);
589
590 // this is the test for "blitting bitmap into DC damages selected brush" bug
591 wxIcon m_std_icon = wxTheApp->GetStdIcon(wxICON_INFORMATION);
592 wxCoord rectSize = m_std_icon.GetWidth() + 10;
593 wxCoord x = 100;
594 dc.SetPen(*wxTRANSPARENT_PEN);
595 dc.SetBrush( *wxGREEN_BRUSH );
596 dc.DrawRectangle(x, 10, rectSize, rectSize);
597 dc.DrawBitmap(m_std_icon, x + 5, 15, TRUE);
598 x += rectSize + 10;
599 dc.DrawRectangle(x, 10, rectSize, rectSize);
600 dc.DrawIcon(m_std_icon, x + 5, 15);
601 x += rectSize + 10;
602 dc.DrawRectangle(x, 10, rectSize, rectSize);
603
604 // test for "transparent" bitmap drawing (it intersects with the last
605 // rectangle above)
606 //dc.SetBrush( *wxTRANSPARENT_BRUSH );
607
608 if (m_smile_bmp.Ok())
609 dc.DrawBitmap(m_smile_bmp, x + rectSize - 20, rectSize - 10, TRUE);
610
611 dc.SetBrush( *wxBLACK_BRUSH );
612 dc.DrawRectangle( 0, 160, 1000, 300 );
613
614 // draw lines
615 wxBitmap bitmap(20,70);
616 wxMemoryDC memdc;
617 memdc.SelectObject( bitmap );
618 memdc.SetBrush( *wxBLACK_BRUSH );
619 memdc.SetPen( *wxWHITE_PEN );
620 memdc.DrawRectangle(0,0,20,70);
621 memdc.DrawLine( 10,0,10,70 );
622
623 // to the right
624 wxPen pen = *wxRED_PEN;
625 memdc.SetPen(pen);
626 memdc.DrawLine( 10, 5,10, 5 );
627 memdc.DrawLine( 10,10,11,10 );
628 memdc.DrawLine( 10,15,12,15 );
629 memdc.DrawLine( 10,20,13,20 );
630
631 /*
632 memdc.SetPen(*wxRED_PEN);
633 memdc.DrawLine( 12, 5,12, 5 );
634 memdc.DrawLine( 12,10,13,10 );
635 memdc.DrawLine( 12,15,14,15 );
636 memdc.DrawLine( 12,20,15,20 );
637 */
638
639 // same to the left
640 memdc.DrawLine( 10,25,10,25 );
641 memdc.DrawLine( 10,30, 9,30 );
642 memdc.DrawLine( 10,35, 8,35 );
643 memdc.DrawLine( 10,40, 7,40 );
644
645 // XOR draw lines
646 dc.SetPen(*wxWHITE_PEN);
647 memdc.SetLogicalFunction( wxINVERT );
648 memdc.SetPen( *wxWHITE_PEN );
649 memdc.DrawLine( 10,50,10,50 );
650 memdc.DrawLine( 10,55,11,55 );
651 memdc.DrawLine( 10,60,12,60 );
652 memdc.DrawLine( 10,65,13,65 );
653
654 memdc.DrawLine( 12,50,12,50 );
655 memdc.DrawLine( 12,55,13,55 );
656 memdc.DrawLine( 12,60,14,60 );
657 memdc.DrawLine( 12,65,15,65 );
658
659 memdc.SelectObject( wxNullBitmap );
660 dc.DrawBitmap( bitmap, 10, 170 );
661 wxImage image( bitmap );
662 image.Rescale( 60,210 );
663 bitmap = image.ConvertToBitmap();
664 dc.DrawBitmap( bitmap, 50, 170 );
665
666 // test the rectangle outline drawing - there should be one pixel between
667 // the rect and the lines
668 dc.SetPen(*wxWHITE_PEN);
669 dc.SetBrush( *wxTRANSPARENT_BRUSH );
670 dc.DrawRectangle(150, 170, 49, 29);
671 dc.DrawRectangle(200, 170, 49, 29);
672 dc.SetPen(*wxWHITE_PEN);
673 dc.DrawLine(250, 210, 250, 170);
674 dc.DrawLine(260, 200, 150, 200);
675
676 // test the rectangle filled drawing - there should be one pixel between
677 // the rect and the lines
678 dc.SetPen(*wxTRANSPARENT_PEN);
679 dc.SetBrush( *wxWHITE_BRUSH );
680 dc.DrawRectangle(300, 170, 49, 29);
681 dc.DrawRectangle(350, 170, 49, 29);
682 dc.SetPen(*wxWHITE_PEN);
683 dc.DrawLine(400, 170, 400, 210);
684 dc.DrawLine(300, 200, 410, 200);
685
686 // a few more tests of this kind
687 dc.SetPen(*wxRED_PEN);
688 dc.SetBrush( *wxWHITE_BRUSH );
689 dc.DrawRectangle(300, 220, 1, 1);
690 dc.DrawRectangle(310, 220, 2, 2);
691 dc.DrawRectangle(320, 220, 3, 3);
692 dc.DrawRectangle(330, 220, 4, 4);
693
694 dc.SetPen(*wxTRANSPARENT_PEN);
695 dc.SetBrush( *wxWHITE_BRUSH );
696 dc.DrawRectangle(300, 230, 1, 1);
697 dc.DrawRectangle(310, 230, 2, 2);
698 dc.DrawRectangle(320, 230, 3, 3);
699 dc.DrawRectangle(330, 230, 4, 4);
700
701 // and now for filled rect with outline
702 dc.SetPen(*wxRED_PEN);
703 dc.SetBrush( *wxWHITE_BRUSH );
704 dc.DrawRectangle(500, 170, 49, 29);
705 dc.DrawRectangle(550, 170, 49, 29);
706 dc.SetPen(*wxWHITE_PEN);
707 dc.DrawLine(600, 170, 600, 210);
708 dc.DrawLine(500, 200, 610, 200);
709
710 // test the rectangle outline drawing - there should be one pixel between
711 // the rect and the lines
712 dc.SetPen(*wxWHITE_PEN);
713 dc.SetBrush( *wxTRANSPARENT_BRUSH );
714 dc.DrawRoundedRectangle(150, 270, 49, 29, 6);
715 dc.DrawRoundedRectangle(200, 270, 49, 29, 6);
716 dc.SetPen(*wxWHITE_PEN);
717 dc.DrawLine(250, 270, 250, 310);
718 dc.DrawLine(150, 300, 260, 300);
719
720 // test the rectangle filled drawing - there should be one pixel between
721 // the rect and the lines
722 dc.SetPen(*wxTRANSPARENT_PEN);
723 dc.SetBrush( *wxWHITE_BRUSH );
724 dc.DrawRoundedRectangle(300, 270, 49, 29, 6);
725 dc.DrawRoundedRectangle(350, 270, 49, 29, 6);
726 dc.SetPen(*wxWHITE_PEN);
727 dc.DrawLine(400, 270, 400, 310);
728 dc.DrawLine(300, 300, 410, 300);
729
730 // Added by JACS to demonstrate bizarre behaviour.
731 // With a size of 70, we get a missing red RHS,
732 // and the hight is too small, so we get yellow
733 // showing. With a size of 40, it draws as expected:
734 // it just shows a white rectangle with red outline.
735 int totalWidth = 70;
736 int totalHeight = 70;
737 wxBitmap bitmap2(totalWidth, totalHeight);
738
739 wxMemoryDC memdc2;
740 memdc2.SelectObject(bitmap2);
741
742 wxBrush yellowBrush(wxColour(255, 255, 0), wxSOLID);
743 memdc2.SetBackground(yellowBrush);
744 memdc2.Clear();
745
746 wxPen yellowPen(wxColour(255, 255, 0), 1, wxSOLID);
747
748 // Now draw a white rectangle with red outline. It should
749 // entirely eclipse the yellow background.
750 memdc2.SetPen(*wxRED_PEN);
751 memdc2.SetBrush(*wxWHITE_BRUSH);
752
753 memdc2.DrawRectangle(0, 0, totalWidth, totalHeight);
754
755 memdc2.SetPen(wxNullPen);
756 memdc2.SetBrush(wxNullBrush);
757 memdc2.SelectObject(wxNullBitmap);
758
759 dc.DrawBitmap(bitmap2, 500, 270);
760
761 // Repeat, but draw directly on dc
762 // Draw a yellow rectangle filling the bitmap
763
764 x = 600; int y = 270;
765 dc.SetPen(yellowPen);
766 dc.SetBrush(yellowBrush);
767 dc.DrawRectangle(x, y, totalWidth, totalHeight);
768
769 // Now draw a white rectangle with red outline. It should
770 // entirely eclipse the yellow background.
771 dc.SetPen(*wxRED_PEN);
772 dc.SetBrush(*wxWHITE_BRUSH);
773
774 dc.DrawRectangle(x, y, totalWidth, totalHeight);
775 }
776
777 void MyCanvas::DrawText(wxDC& dc)
778 {
779 // set underlined font for testing
780 dc.SetFont( wxFont(12, wxMODERN, wxNORMAL, wxNORMAL, TRUE) );
781 dc.DrawText( "This is text", 110, 10 );
782 dc.DrawRotatedText( "That is text", 20, 10, -45 );
783
784 dc.SetFont( *wxNORMAL_FONT );
785
786 wxString text;
787 dc. SetBackgroundMode(wxTRANSPARENT);
788
789 for ( int n = -180; n < 180; n += 30 )
790 {
791 text.Printf(" %d rotated text", n);
792 dc.DrawRotatedText(text , 400, 400, n);
793 }
794
795 dc.SetFont( wxFont( 18, wxSWISS, wxNORMAL, wxNORMAL ) );
796
797 dc.DrawText( "This is Swiss 18pt text.", 110, 40 );
798
799 long length;
800 long height;
801 long descent;
802 dc.GetTextExtent( "This is Swiss 18pt text.", &length, &height, &descent );
803 text.Printf( "Dimensions are length %ld, height %ld, descent %ld", length, height, descent );
804 dc.DrawText( text, 110, 80 );
805
806 text.Printf( "CharHeight() returns: %d", dc.GetCharHeight() );
807 dc.DrawText( text, 110, 120 );
808
809 dc.DrawRectangle( 100, 40, 4, height );
810 }
811
812 static const struct
813 {
814 const wxChar *name;
815 int rop;
816 } rasterOperations[] =
817 {
818 { "wxAND", wxAND },
819 { "wxAND_INVERT", wxAND_INVERT },
820 { "wxAND_REVERSE", wxAND_REVERSE },
821 { "wxCLEAR", wxCLEAR },
822 { "wxCOPY", wxCOPY },
823 { "wxEQUIV", wxEQUIV },
824 { "wxINVERT", wxINVERT },
825 { "wxNAND", wxNAND },
826 { "wxNO_OP", wxNO_OP },
827 { "wxOR", wxOR },
828 { "wxOR_INVERT", wxOR_INVERT },
829 { "wxOR_REVERSE", wxOR_REVERSE },
830 { "wxSET", wxSET },
831 { "wxSRC_INVERT", wxSRC_INVERT },
832 { "wxXOR", wxXOR },
833 };
834
835 void MyCanvas::DrawImages(wxDC& dc)
836 {
837 dc.DrawText("original image", 0, 0);
838 dc.DrawBitmap(gs_bmpNoMask, 0, 20, 0);
839 dc.DrawText("with colour mask", 0, 100);
840 dc.DrawBitmap(gs_bmpWithColMask, 0, 120, TRUE);
841 dc.DrawText("the mask image", 0, 200);
842 dc.DrawBitmap(gs_bmpMask, 0, 220, 0);
843 dc.DrawText("masked image", 0, 300);
844 dc.DrawBitmap(gs_bmpWithMask, 0, 320, TRUE);
845
846 int cx = gs_bmpWithColMask.GetWidth(),
847 cy = gs_bmpWithColMask.GetHeight();
848
849 wxMemoryDC memDC;
850 for ( size_t n = 0; n < WXSIZEOF(rasterOperations); n++ )
851 {
852 wxCoord x = 120 + 150*(n%4),
853 y = 20 + 100*(n/4);
854
855 dc.DrawText(rasterOperations[n].name, x, y - 20);
856 memDC.SelectObject(gs_bmpWithColMask);
857 dc.Blit(x, y, cx, cy, &memDC, 0, 0, rasterOperations[n].rop, TRUE);
858 }
859 }
860
861 void MyCanvas::DrawWithLogicalOps(wxDC& dc)
862 {
863 static const wxCoord w = 60;
864 static const wxCoord h = 60;
865
866 // reuse the text colour here
867 dc.SetPen(wxPen(m_owner->m_colourForeground, 1, wxSOLID));
868 dc.SetBrush(*wxTRANSPARENT_BRUSH);
869
870 size_t n;
871 for ( n = 0; n < WXSIZEOF(rasterOperations); n++ )
872 {
873 wxCoord x = 20 + 150*(n%4),
874 y = 20 + 100*(n/4);
875
876 dc.DrawText(rasterOperations[n].name, x, y - 20);
877 dc.SetLogicalFunction(rasterOperations[n].rop);
878 dc.DrawRectangle(x, y, w, h);
879 dc.DrawLine(x, y, x + w, y + h);
880 dc.DrawLine(x + w, y, x, y + h);
881 }
882
883 // now some filled rectangles
884 dc.SetBrush(wxBrush(m_owner->m_colourForeground, wxSOLID));
885
886 for ( n = 0; n < WXSIZEOF(rasterOperations); n++ )
887 {
888 wxCoord x = 20 + 150*(n%4),
889 y = 500 + 100*(n/4);
890
891 dc.DrawText(rasterOperations[n].name, x, y - 20);
892 dc.SetLogicalFunction(rasterOperations[n].rop);
893 dc.DrawRectangle(x, y, w, h);
894 }
895 }
896
897 void MyCanvas::DrawRegions(wxDC& dc)
898 {
899 dc.SetBrush( *wxWHITE_BRUSH );
900 dc.SetPen( *wxTRANSPARENT_PEN );
901 dc.DrawRectangle( 10,10,310,310 );
902
903 wxRegion region( 20,20,100,270 );
904 dc.SetClippingRegion( region );
905
906 dc.SetBrush( *wxRED_BRUSH );
907 dc.DrawRectangle( 10,10,310,310 );
908
909 region = wxRegion( 120,30,100,270 );
910 dc.SetClippingRegion( region );
911
912 dc.SetBrush( *wxGREY_BRUSH );
913 dc.DrawRectangle( 10,10,310,310 );
914 }
915
916 void MyCanvas::OnPaint(wxPaintEvent &WXUNUSED(event))
917 {
918 wxPaintDC dc(this);
919 PrepareDC(dc);
920 m_owner->PrepareDC(dc);
921
922 dc.SetBackgroundMode( m_owner->m_backgroundMode );
923 if ( m_owner->m_backgroundBrush.Ok() )
924 dc.SetBackground( m_owner->m_backgroundBrush );
925 if ( m_owner->m_colourForeground.Ok() )
926 dc.SetTextForeground( m_owner->m_colourForeground );
927 if ( m_owner->m_colourBackground.Ok() )
928 dc.SetTextBackground( m_owner->m_colourBackground );
929
930 if ( m_owner->m_textureBackground) {
931 if ( ! m_owner->m_backgroundBrush.Ok() ) {
932 wxBrush b(wxColour(0,128,0), wxSOLID);
933 dc.SetBackground(b);
934 }
935 }
936
937 // dc.Clear();
938
939 if ( m_owner->m_textureBackground) {
940 dc.SetPen(*wxMEDIUM_GREY_PEN);
941 for (int i=0; i<200; i++)
942 dc.DrawLine(0, i*10, i*10, 0);
943 }
944
945 switch ( m_show )
946 {
947 case Show_Default:
948 DrawDefault(dc);
949 break;
950
951 case Show_Regions:
952 DrawRegions(dc);
953 break;
954
955 case Show_Text:
956 DrawText(dc);
957 break;
958
959 case Show_Lines:
960 DrawTestLines( 0, 100, 0, dc );
961 DrawTestLines( 0, 300, 1, dc );
962 DrawTestLines( 0, 500, 2, dc );
963 DrawTestLines( 0, 700, 6, dc );
964 break;
965
966 case Show_Polygons:
967 DrawTestPoly( 0, 100, dc, 0 );
968 DrawTestPoly( 33, 500, dc, 1 );
969 DrawTestPoly( 43, 1000, dc, 2 );
970 break;
971
972 case Show_Mask:
973 DrawImages(dc);
974 break;
975
976 case Show_Ops:
977 DrawWithLogicalOps(dc);
978 break;
979 }
980 }
981
982 void MyCanvas::OnMouseMove(wxMouseEvent &event)
983 {
984 wxClientDC dc(this);
985 PrepareDC(dc);
986 m_owner->PrepareDC(dc);
987
988 wxPoint pos = event.GetPosition();
989 long x = dc.DeviceToLogicalX( pos.x );
990 long y = dc.DeviceToLogicalY( pos.y );
991 wxString str;
992 str.Printf( "Current mouse position: %d,%d", (int)x, (int)y );
993 m_owner->SetStatusText( str );
994 }
995
996 // ----------------------------------------------------------------------------
997 // MyFrame
998 // ----------------------------------------------------------------------------
999
1000 // the event tables connect the wxWindows events with the functions (event
1001 // handlers) which process them. It can be also done at run-time, but for the
1002 // simple menu events like this the static method is much simpler.
1003 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
1004 EVT_MENU (File_Quit, MyFrame::OnQuit)
1005 EVT_MENU (File_About, MyFrame::OnAbout)
1006
1007 EVT_MENU_RANGE(MenuShow_First, MenuShow_Last, MyFrame::OnShow)
1008
1009 EVT_MENU_RANGE(MenuOption_First, MenuOption_Last, MyFrame::OnOption)
1010 END_EVENT_TABLE()
1011
1012 // frame constructor
1013 MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
1014 : wxFrame((wxFrame *)NULL, -1, title, pos, size)
1015 {
1016 // set the frame icon
1017 SetIcon(wxICON(mondrian));
1018
1019 wxMenu *menuFile = new wxMenu;
1020 menuFile->Append(File_ShowDefault, "&Default screen\tF1");
1021 menuFile->Append(File_ShowText, "&Text screen\tF2");
1022 menuFile->Append(File_ShowLines, "&Lines screen\tF3");
1023 menuFile->Append(File_ShowPolygons, "&Polygons screen\tF4");
1024 menuFile->Append(File_ShowMask, "wx&Mask screen\tF5");
1025 menuFile->Append(File_ShowOps, "&ROP screen\tF6");
1026 menuFile->Append(File_ShowRegions, "Re&gions screen\tF6");
1027 menuFile->AppendSeparator();
1028 menuFile->Append(File_About, "&About...\tCtrl-A", "Show about dialog");
1029 menuFile->AppendSeparator();
1030 menuFile->Append(File_Quit, "E&xit\tAlt-X", "Quit this program");
1031
1032 wxMenu *menuMapMode = new wxMenu;
1033 menuMapMode->Append( MapMode_Text, "&TEXT map mode" );
1034 menuMapMode->Append( MapMode_Lometric, "&LOMETRIC map mode" );
1035 menuMapMode->Append( MapMode_Twips, "T&WIPS map mode" );
1036 menuMapMode->Append( MapMode_Points, "&POINTS map mode" );
1037 menuMapMode->Append( MapMode_Metric, "&METRIC map mode" );
1038
1039 wxMenu *menuUserScale = new wxMenu;
1040 menuUserScale->Append( UserScale_StretchHoriz, "Stretch horizontally\tCtrl-H" );
1041 menuUserScale->Append( UserScale_ShrinkHoriz, "Shrink horizontally\tCtrl-G" );
1042 menuUserScale->Append( UserScale_StretchVertic, "Stretch vertically\tCtrl-V" );
1043 menuUserScale->Append( UserScale_ShrinkVertic, "Shrink vertically\tCtrl-W" );
1044 menuUserScale->AppendSeparator();
1045 menuUserScale->Append( UserScale_Restore, "Restore to normal\tCtrl-0" );
1046
1047 wxMenu *menuAxis = new wxMenu;
1048 menuAxis->Append( AxisMirror_Horiz, "Mirror horizontally\tCtrl-M", "", TRUE );
1049 menuAxis->Append( AxisMirror_Vertic, "Mirror vertically\tCtrl-N", "", TRUE );
1050
1051 wxMenu *menuLogical = new wxMenu;
1052 menuLogical->Append( LogicalOrigin_MoveDown, "Move &down\tCtrl-D" );
1053 menuLogical->Append( LogicalOrigin_MoveUp, "Move &up\tCtrl-U" );
1054 menuLogical->Append( LogicalOrigin_MoveLeft, "Move &right\tCtrl-L" );
1055 menuLogical->Append( LogicalOrigin_MoveRight, "Move &left\tCtrl-R" );
1056
1057 wxMenu *menuColour = new wxMenu;
1058 menuColour->Append( Colour_TextForeground, "Text foreground..." );
1059 menuColour->Append( Colour_TextBackground, "Text background..." );
1060 menuColour->Append( Colour_Background, "Background colour..." );
1061 menuColour->Append( Colour_BackgroundMode, "Opaque/transparent\tCtrl-B", "", TRUE );
1062 menuColour->Append( Colour_TextureBackgound, "Draw textured background\tCtrl-T", "", TRUE);
1063
1064 // now append the freshly created menu to the menu bar...
1065 wxMenuBar *menuBar = new wxMenuBar;
1066 menuBar->Append(menuFile, "&File");
1067 menuBar->Append(menuMapMode, "&MapMode");
1068 menuBar->Append(menuUserScale, "&UserScale");
1069 menuBar->Append(menuAxis, "&Axis");
1070 menuBar->Append(menuLogical, "&LogicalOrigin");
1071 menuBar->Append(menuColour, "&Colours");
1072
1073 // ... and attach this menu bar to the frame
1074 SetMenuBar(menuBar);
1075
1076 // create a status bar just for fun (by default with 1 pane only)
1077 CreateStatusBar(2);
1078 SetStatusText("Welcome to wxWindows!");
1079
1080 m_mapMode = wxMM_TEXT;
1081 m_xUserScale = 1.0;
1082 m_yUserScale = 1.0;
1083 m_xLogicalOrigin = 0;
1084 m_yLogicalOrigin = 0;
1085 m_xAxisReversed =
1086 m_yAxisReversed = FALSE;
1087 m_backgroundMode = wxSOLID;
1088 m_colourForeground = *wxRED;
1089 m_colourBackground = *wxBLUE;
1090 m_textureBackground = FALSE;
1091
1092 m_canvas = new MyCanvas( this );
1093 m_canvas->SetScrollbars( 10, 10, 100, 240 );
1094 }
1095
1096 // event handlers
1097
1098 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
1099 {
1100 // TRUE is to force the frame to close
1101 Close(TRUE);
1102 }
1103
1104 void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
1105 {
1106 wxString msg;
1107 msg.Printf( wxT("This is the about dialog of the drawing sample.\n")
1108 wxT("This sample tests various primitive drawing functions\n")
1109 wxT("without any tests to prevent flicker.\n")
1110 wxT("Copyright (c) Robert Roebling 1999")
1111 );
1112
1113 wxMessageBox(msg, "About Drawing", wxOK | wxICON_INFORMATION, this);
1114 }
1115
1116 void MyFrame::OnShow(wxCommandEvent& event)
1117 {
1118 m_canvas->Show((ScreenToShow)(event.GetInt() - MenuShow_First));
1119 }
1120
1121 void MyFrame::OnOption(wxCommandEvent& event)
1122 {
1123 switch (event.GetInt())
1124 {
1125 case MapMode_Text:
1126 m_mapMode = wxMM_TEXT;
1127 break;
1128 case MapMode_Lometric:
1129 m_mapMode = wxMM_LOMETRIC;
1130 break;
1131 case MapMode_Twips:
1132 m_mapMode = wxMM_TWIPS;
1133 break;
1134 case MapMode_Points:
1135 m_mapMode = wxMM_POINTS;
1136 break;
1137 case MapMode_Metric:
1138 m_mapMode = wxMM_METRIC;
1139 break;
1140
1141 case LogicalOrigin_MoveDown:
1142 m_yLogicalOrigin += 10;
1143 break;
1144 case LogicalOrigin_MoveUp:
1145 m_yLogicalOrigin -= 10;
1146 break;
1147 case LogicalOrigin_MoveLeft:
1148 m_xLogicalOrigin += 10;
1149 break;
1150 case LogicalOrigin_MoveRight:
1151 m_xLogicalOrigin -= 10;
1152 break;
1153
1154 case UserScale_StretchHoriz:
1155 m_xUserScale *= 1.10;
1156 break;
1157 case UserScale_ShrinkHoriz:
1158 m_xUserScale /= 1.10;
1159 break;
1160 case UserScale_StretchVertic:
1161 m_yUserScale *= 1.10;
1162 break;
1163 case UserScale_ShrinkVertic:
1164 m_yUserScale /= 1.10;
1165 break;
1166 case UserScale_Restore:
1167 m_xUserScale =
1168 m_yUserScale = 1.0;
1169 break;
1170
1171 case AxisMirror_Vertic:
1172 m_yAxisReversed = !m_yAxisReversed;
1173 break;
1174 case AxisMirror_Horiz:
1175 m_xAxisReversed = !m_xAxisReversed;
1176 break;
1177
1178 case Colour_TextForeground:
1179 m_colourForeground = SelectColour();
1180 break;
1181 case Colour_TextBackground:
1182 m_colourBackground = SelectColour();
1183 break;
1184 case Colour_Background:
1185 {
1186 wxColour col = SelectColour();
1187 if ( col.Ok() )
1188 {
1189 m_backgroundBrush.SetColour(col);
1190 }
1191 }
1192 break;
1193 case Colour_BackgroundMode:
1194 m_backgroundMode = m_backgroundMode == wxSOLID ? wxTRANSPARENT
1195 : wxSOLID;
1196 break;
1197
1198 case Colour_TextureBackgound:
1199 m_textureBackground = ! m_textureBackground;
1200 break;
1201
1202 default:
1203 // skip Refresh()
1204 return;
1205 }
1206
1207 m_canvas->Refresh();
1208 }
1209
1210 void MyFrame::PrepareDC(wxDC& dc)
1211 {
1212 dc.SetMapMode( m_mapMode );
1213 dc.SetUserScale( m_xUserScale, m_yUserScale );
1214 dc.SetLogicalOrigin( m_xLogicalOrigin, m_yLogicalOrigin );
1215 dc.SetAxisOrientation( !m_xAxisReversed, m_yAxisReversed );
1216 }
1217
1218 wxColour MyFrame::SelectColour()
1219 {
1220 wxColour col;
1221 wxColourData data;
1222 wxColourDialog dialog(this, &data);
1223
1224 if ( dialog.ShowModal() == wxID_OK )
1225 {
1226 col = dialog.GetColourData().GetColour();
1227 }
1228
1229 return col;
1230 }