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