1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: shows and tests wxDC features
4 // Author: Robert Roebling
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "drawing.cpp"
22 #pragma interface "drawing.cpp"
25 // For compilers that support precompilation, includes "wx/wx.h".
26 #include "wx/wxprec.h"
32 // for all others, include the necessary headers (this file is usually all you
33 // need because it includes almost all "standard" wxWindows headers
38 #include "wx/colordlg.h"
41 // ----------------------------------------------------------------------------
43 // ----------------------------------------------------------------------------
45 // the application icon
46 #if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__)
47 #include "mondrian.xpm"
50 // ----------------------------------------------------------------------------
52 // ----------------------------------------------------------------------------
54 // what do we show on screen (there are too many shapes to put them all on
55 // screen simultaneously)
68 // ----------------------------------------------------------------------------
70 // ----------------------------------------------------------------------------
72 static wxBitmap
*gs_bmpNoMask
= NULL
,
73 *gs_bmpWithColMask
= NULL
,
75 *gs_bmpWithMask
= NULL
,
80 // ----------------------------------------------------------------------------
82 // ----------------------------------------------------------------------------
84 // Define a new application type, each program should derive a class from wxApp
85 class MyApp
: public wxApp
88 // override base class virtuals
89 // ----------------------------
91 // this one is called on application startup and is a good place for the app
92 // initialization (doing it here and not in the ctor allows to have an error
93 // return: if OnInit() returns false, the application terminates)
94 virtual bool OnInit();
96 virtual int OnExit() { DeleteBitmaps(); return 0; }
106 // Define a new frame type: this is going to be our main frame
107 class MyFrame
: public wxFrame
111 MyFrame(const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
);
113 // event handlers (these functions should _not_ be virtual)
114 void OnQuit(wxCommandEvent
& event
);
115 void OnAbout(wxCommandEvent
& event
);
116 void OnShow(wxCommandEvent
&event
);
117 void OnOption(wxCommandEvent
&event
);
119 wxColour
SelectColour();
120 void PrepareDC(wxDC
& dc
);
122 int m_backgroundMode
;
123 int m_textureBackground
;
127 int m_xLogicalOrigin
;
128 int m_yLogicalOrigin
;
129 bool m_xAxisReversed
,
131 wxColour m_colourForeground
, // these are _text_ colours
133 wxBrush m_backgroundBrush
;
137 // any class wishing to process wxWindows events must use this macro
138 DECLARE_EVENT_TABLE()
141 // define a scrollable canvas for drawing onto
142 class MyCanvas
: public wxScrolledWindow
145 MyCanvas( MyFrame
*parent
);
147 void OnPaint(wxPaintEvent
&event
);
148 void OnMouseMove(wxMouseEvent
&event
);
150 void Show(ScreenToShow show
) { m_show
= show
; Refresh(); }
153 void DrawTestPoly( int x
, int y
, wxDC
&dc
,int transparent
);
154 void DrawTestLines( int x
, int y
, int width
, wxDC
&dc
);
155 void DrawText(wxDC
& dc
);
156 void DrawImages(wxDC
& dc
);
157 void DrawWithLogicalOps(wxDC
& dc
);
158 void DrawRegions(wxDC
& dc
);
159 void DrawCircles(wxDC
& dc
);
160 void DrawDefault(wxDC
& dc
);
162 void DrawRegionsHelper(wxDC
& dc
, wxCoord x
);
168 wxBitmap m_smile_bmp
;
171 DECLARE_EVENT_TABLE()
174 // ----------------------------------------------------------------------------
176 // ----------------------------------------------------------------------------
178 // IDs for the controls and the menu commands
186 File_ShowDefault
= MenuShow_First
,
194 MenuShow_Last
= File_ShowCircles
,
198 MapMode_Text
= MenuOption_First
,
204 UserScale_StretchHoriz
,
205 UserScale_ShrinkHoriz
,
206 UserScale_StretchVertic
,
207 UserScale_ShrinkVertic
,
213 LogicalOrigin_MoveDown
,
214 LogicalOrigin_MoveUp
,
215 LogicalOrigin_MoveLeft
,
216 LogicalOrigin_MoveRight
,
218 Colour_TextForeground
,
219 Colour_TextBackground
,
221 Colour_BackgroundMode
,
222 Colour_TextureBackgound
,
224 MenuOption_Last
= Colour_TextureBackgound
227 // ----------------------------------------------------------------------------
228 // event tables and other macros for wxWindows
229 // ----------------------------------------------------------------------------
232 // Create a new application object: this macro will allow wxWindows to create
233 // the application object during program execution (it's better than using a
234 // static object for many reasons) and also declares the accessor function
235 // wxGetApp() which will return the reference of the right type (i.e. MyApp and
239 // ============================================================================
241 // ============================================================================
243 // ----------------------------------------------------------------------------
244 // the application class
245 // ----------------------------------------------------------------------------
247 bool MyApp::LoadImages()
249 gs_bmpNoMask
= new wxBitmap
;
250 gs_bmpWithColMask
= new wxBitmap
;
251 gs_bmpMask
= new wxBitmap
;
252 gs_bmpWithMask
= new wxBitmap
;
253 gs_bmp4
= new wxBitmap
;
254 gs_bmp4_mono
= new wxBitmap
;
255 gs_bmp36
= new wxBitmap
;
261 wxString path
= pathList
.FindValidPath("pat4.bmp");
265 /* 4 colour bitmap */
266 gs_bmp4
->LoadFile(path
, wxBITMAP_TYPE_BMP
);
267 /* turn into mono-bitmap */
268 gs_bmp4_mono
->LoadFile(path
, wxBITMAP_TYPE_BMP
);
269 wxMask
* mask4
= new wxMask(*gs_bmp4_mono
, *wxBLACK
);
270 gs_bmp4_mono
->SetMask(mask4
);
272 path
= pathList
.FindValidPath("pat36.bmp");
275 gs_bmp36
->LoadFile(path
, wxBITMAP_TYPE_BMP
);
276 wxMask
* mask36
= new wxMask(*gs_bmp36
, *wxBLACK
);
277 gs_bmp36
->SetMask(mask36
);
279 path
= pathList
.FindValidPath("image.bmp");
282 gs_bmpNoMask
->LoadFile(path
, wxBITMAP_TYPE_BMP
);
283 gs_bmpWithMask
->LoadFile(path
, wxBITMAP_TYPE_BMP
);
284 gs_bmpWithColMask
->LoadFile(path
, wxBITMAP_TYPE_BMP
);
286 path
= pathList
.FindValidPath("mask.bmp");
289 gs_bmpMask
->LoadFile(path
, wxBITMAP_TYPE_BMP
);
291 wxMask
*mask
= new wxMask(*gs_bmpMask
, *wxBLACK
);
292 gs_bmpWithMask
->SetMask(mask
);
294 mask
= new wxMask(*gs_bmpWithColMask
, *wxWHITE
);
295 gs_bmpWithColMask
->SetMask(mask
);
300 // `Main program' equivalent: the program execution "starts" here
303 // Create the main application window
304 MyFrame
*frame
= new MyFrame("Drawing sample",
305 wxPoint(50, 50), wxSize(550, 340));
307 // Show it and tell the application that it's our main window
313 wxLogError("Can't load one of the bitmap files needed for this sample "
314 "from the current or parent directory, please copy them "
327 void MyApp::DeleteBitmaps()
330 delete gs_bmpWithColMask
;
332 delete gs_bmpWithMask
;
338 // ----------------------------------------------------------------------------
340 // ----------------------------------------------------------------------------
342 // the event tables connect the wxWindows events with the functions (event
343 // handlers) which process them.
344 BEGIN_EVENT_TABLE(MyCanvas
, wxScrolledWindow
)
345 EVT_PAINT (MyCanvas::OnPaint
)
346 EVT_MOTION (MyCanvas::OnMouseMove
)
351 MyCanvas::MyCanvas(MyFrame
*parent
)
352 : wxScrolledWindow(parent
, -1, wxDefaultPosition
, wxDefaultSize
,
353 wxHSCROLL
| wxVSCROLL
| wxNO_FULL_REPAINT_ON_RESIZE
)
356 m_show
= Show_Default
;
357 m_smile_bmp
= wxBitmap(smile_xpm
);
358 m_std_icon
= wxTheApp
->GetStdIcon(wxICON_INFORMATION
);
361 // Draw a polygon and an overlapping rectangle
362 // If transparent is 1, the fill pattern is made transparent.
363 // If transparent is 2, the fill pattern is made transparent but inversed
364 // If is transparent is 0 the text for and background color will be used to represent/map
365 // the colors of the monochrome bitmap pixels to the fillpattern
367 // I abused the the menu items for setting so called back and fore ground color
368 // just to show how the those colors do influence the fillpatterns just play
369 // with those, and with the code variations are endless using other logical
372 void MyCanvas::DrawTestPoly( int x
, int y
,wxDC
&dc
,int transparent
)
374 // wxBrush* brush4 = new wxBrush(*gs_bmp4);
375 wxBrush
* brush4
= new wxBrush(*wxBLACK
,wxFDIAGONAL_HATCH
);
376 wxBrush
* brush4_mono
= new wxBrush(*gs_bmp4_mono
);
377 wxBrush
* brush36
= new wxBrush(*gs_bmp36
);
380 todraw
[0].x
=(long)x
+100;
381 todraw
[0].y
=(long)y
+100;
382 todraw
[1].x
=(long)x
+300;
383 todraw
[1].y
=(long)y
+100;
384 todraw
[2].x
=(long)x
+300;
385 todraw
[2].y
=(long)y
+300;
386 todraw
[3].x
=(long)x
+150;
387 todraw
[3].y
=(long)y
+350;
388 todraw
[4].x
=(long)x
+100;
389 todraw
[4].y
=(long)y
+300;
407 dc
.SetLogicalFunction(wxCOPY
);
409 dc
.SetPen( wxPen( "black", 4, wxSOLID
) );
410 dc
.SetBrush( *brush4
);
411 dc
.DrawPolygon(5,todraw
,0,0,wxWINDING_RULE
);
413 dc
.SetPen( wxPen( "red", 4, wxSOLID
) );
414 dc
.SetBrush( *brush36
);
415 dc
.SetTextForeground(*wxCYAN
);
416 dc
.SetTextBackground(m_owner
->m_colourBackground
);
417 dc
.DrawRectangle( x
+10, y
+10, 200, 200 );
419 dc
.SetPen( wxPen( "green", 4, wxSOLID
) );
420 dc
.SetBrush( *brush4_mono
);
421 dc
.SetTextForeground(*wxCYAN
);
422 dc
.SetTextBackground(m_owner
->m_colourBackground
);
423 dc
.DrawRectangle( x
+50, y
+50, 200, 200 );
425 dc
.DrawCircle( x
+400, y
+50, 130 );
427 dc
.SetBrush(wxNullBrush
);
428 dc
.SetPen(wxNullPen
);
431 case 1: //now with transparent fillpatterns
434 wxBitmap
* bmpBlit
= new wxBitmap(600,400);
435 wxMemoryDC
* memDC
= new wxMemoryDC();
436 // wxBrush _clearbrush(*wxGREEN,wxSOLID);
437 wxBrush
_clearbrush(*wxBLACK
,wxSOLID
);
438 memDC
->SelectObject(*bmpBlit
);
439 memDC
->BeginDrawing();
440 memDC
->SetBackground(_clearbrush
);
442 memDC
->SetBackground(wxNullBrush
);
444 memDC
->SetPen( wxPen( "black", 4, wxSOLID
) );
445 memDC
->SetBrush( wxNullBrush
);
446 memDC
->SetBrush( *brush4
);
447 memDC
->SetTextForeground(*wxBLACK
); // 0s --> 0x000000 (black)
448 memDC
->SetTextBackground(*wxWHITE
); // 1s --> 0xFFFFFF (white)
449 memDC
->SetLogicalFunction(wxAND_INVERT
);
451 // BLACK OUT the opaque pixels and leave the rest as is
452 memDC
->DrawPolygon(5,todraw2
,0,0,wxWINDING_RULE
);
454 // Set background and foreground colors for fill pattern
455 //the previous blacked out pixels are now merged with the layer color
456 //while the non blacked out pixels stay as they are.
457 memDC
->SetTextForeground(*wxBLACK
); // 0s --> 0x000000 (black)
459 //now define what will be the color of the fillpattern parts that are not transparent
460 // memDC->SetTextBackground(*wxBLUE);
461 memDC
->SetTextBackground(m_owner
->m_colourForeground
);
462 memDC
->SetLogicalFunction(wxOR
);
465 //don't understand how but the outline is also depending on logicalfunction
466 memDC
->SetPen( wxPen( "red", 4, wxSOLID
) );
467 memDC
->DrawPolygon(5,todraw2
,0,0,wxWINDING_RULE
);
469 memDC
->SetLogicalFunction(wxCOPY
);
471 memDC
->SetPen( wxPen( "black", 4, wxSOLID
) );
472 memDC
->SetBrush( wxNullBrush
);
473 memDC
->SetBrush( *brush36
);
474 memDC
->SetTextForeground(*wxBLACK
); // 0s --> 0x000000 (black)
475 memDC
->SetTextBackground(*wxWHITE
); // 1s --> 0xFFFFFF (white)
476 memDC
->SetLogicalFunction(wxAND_INVERT
);
478 memDC
->DrawRectangle( 10, 10, 200, 200 );
480 // Set background and foreground colors for fill pattern
481 //the previous blacked out pixels are now merged with the layer color
482 //while the non blacked out pixels stay as they are.
483 memDC
->SetTextForeground(*wxBLACK
); // 0s --> 0x000000 (black)
484 //now define what will be the color of the fillpattern parts that are not transparent
485 // memDC->SetTextBackground(*wxRED);
486 memDC
->SetTextBackground(m_owner
->m_colourBackground
);
487 memDC
->SetLogicalFunction(wxOR
);
489 //don't understand how but the outline is also depending on logicalfunction
490 memDC
->SetPen( wxPen( "yellow", 4, wxSOLID
) );
491 memDC
->DrawRectangle( 10, 10, 200, 200 );
493 memDC
->SetBrush(wxNullBrush
);
494 memDC
->SetPen(wxNullPen
);
497 dc
.Blit(x
,y
,600,400,memDC
,0,0,wxCOPY
);
502 case 2: //now with transparent inversed fillpatterns
504 wxBitmap
* bmpBlit
= new wxBitmap(600,400);
505 wxMemoryDC
* memDC
= new wxMemoryDC();
506 wxBrush
_clearbrush(*wxWHITE
,wxSOLID
);
507 memDC
->SelectObject(*bmpBlit
);
508 memDC
->BeginDrawing();
509 memDC
->SetBackground(_clearbrush
);
511 memDC
->SetBackground(wxNullBrush
);
513 memDC
->SetPen( wxPen( "black", 4, wxSOLID
) );
514 memDC
->SetBrush( *brush4
);
515 memDC
->SetTextBackground(*wxBLACK
); // 0s --> 0x000000 (black)
516 memDC
->SetTextForeground(*wxWHITE
); // 1s --> 0xFFFFFF (white)
517 memDC
->SetLogicalFunction(wxAND_INVERT
);
519 // BLACK OUT the opaque pixels and leave the rest as is
520 memDC
->DrawPolygon(5,todraw2
,0,0,wxWINDING_RULE
);
522 // Set background and foreground colors for fill pattern
523 //the previous blacked out pixels are now merged with the layer color
524 //while the non blacked out pixels stay as they are.
525 memDC
->SetTextBackground(*wxBLACK
); // 0s --> 0x000000 (black)
527 //now define what will be the color of the fillpattern parts that are not transparent
528 memDC
->SetTextForeground(m_owner
->m_colourForeground
);
529 memDC
->SetLogicalFunction(wxOR
);
532 //don't understand how but the outline is also depending on logicalfunction
533 memDC
->SetPen( wxPen( "red", 4, wxSOLID
) );
534 memDC
->DrawPolygon(5,todraw2
,0,0,wxWINDING_RULE
);
536 memDC
->SetLogicalFunction(wxCOPY
);
538 memDC
->SetPen( wxPen( "black", 4, wxSOLID
) );
539 memDC
->SetBrush( *brush36
);
540 memDC
->SetTextBackground(*wxBLACK
); // 0s --> 0x000000 (black)
541 memDC
->SetTextForeground(*wxWHITE
); // 1s --> 0xFFFFFF (white)
542 memDC
->SetLogicalFunction(wxAND_INVERT
);
544 memDC
->DrawRectangle( 10,10, 200, 200 );
546 // Set background and foreground colors for fill pattern
547 //the previous blacked out pixels are now merged with the layer color
548 //while the non blacked out pixels stay as they are.
549 memDC
->SetTextBackground(*wxBLACK
); // 0s --> 0x000000 (black)
550 //now define what will be the color of the fillpattern parts that are not transparent
551 memDC
->SetTextForeground(m_owner
->m_colourBackground
);
552 memDC
->SetLogicalFunction(wxOR
);
554 //don't understand how but the outline is also depending on logicalfunction
555 memDC
->SetPen( wxPen( "yellow", 4, wxSOLID
) );
556 memDC
->DrawRectangle( 10, 10, 200, 200 );
558 memDC
->SetBrush(wxNullBrush
);
559 memDC
->SetPen(wxNullPen
);
560 dc
.Blit(x
,y
,600,400,memDC
,0,0,wxCOPY
);
571 void MyCanvas::DrawTestLines( int x
, int y
, int width
, wxDC
&dc
)
573 dc
.SetPen( wxPen( "black", width
, wxSOLID
) );
574 dc
.SetBrush( *wxRED_BRUSH
);
575 dc
.DrawText(wxString::Format("Testing lines of width %d", width
), x
+ 10, y
- 10);
576 dc
.DrawRectangle( x
+10, y
+10, 100, 190 );
578 dc
.DrawText("Solid/dot/short dash/long dash/dot dash", x
+ 150, y
+ 10);
579 dc
.SetPen( wxPen( "black", width
, wxSOLID
) );
580 dc
.DrawLine( x
+20, y
+20, 100, y
+20 );
581 dc
.SetPen( wxPen( "black", width
, wxDOT
) );
582 dc
.DrawLine( x
+20, y
+30, 100, y
+30 );
583 dc
.SetPen( wxPen( "black", width
, wxSHORT_DASH
) );
584 dc
.DrawLine( x
+20, y
+40, 100, y
+40 );
585 dc
.SetPen( wxPen( "black", width
, wxLONG_DASH
) );
586 dc
.DrawLine( x
+20, y
+50, 100, y
+50 );
587 dc
.SetPen( wxPen( "black", width
, wxDOT_DASH
) );
588 dc
.DrawLine( x
+20, y
+60, 100, y
+60 );
590 dc
.DrawText("Misc hatches", x
+ 150, y
+ 70);
591 dc
.SetPen( wxPen( "black", width
, wxBDIAGONAL_HATCH
) );
592 dc
.DrawLine( x
+20, y
+70, 100, y
+70 );
593 dc
.SetPen( wxPen( "black", width
, wxCROSSDIAG_HATCH
) );
594 dc
.DrawLine( x
+20, y
+80, 100, y
+80 );
595 dc
.SetPen( wxPen( "black", width
, wxFDIAGONAL_HATCH
) );
596 dc
.DrawLine( x
+20, y
+90, 100, y
+90 );
597 dc
.SetPen( wxPen( "black", width
, wxCROSS_HATCH
) );
598 dc
.DrawLine( x
+20, y
+100, 100, y
+100 );
599 dc
.SetPen( wxPen( "black", width
, wxHORIZONTAL_HATCH
) );
600 dc
.DrawLine( x
+20, y
+110, 100, y
+110 );
601 dc
.SetPen( wxPen( "black", width
, wxVERTICAL_HATCH
) );
602 dc
.DrawLine( x
+20, y
+120, 100, y
+120 );
604 dc
.DrawText("User dash", x
+ 150, y
+ 140);
605 wxPen
ud( "black", width
, wxUSER_DASH
);
608 ud
.SetDashes( 1, dash1
);
609 dc
.DrawLine( x
+20, y
+140, 100, y
+140 );
611 ud
.SetDashes( 1, dash1
);
612 dc
.DrawLine( x
+20, y
+150, 100, y
+150 );
614 ud
.SetDashes( 1, dash1
);
615 dc
.DrawLine( x
+20, y
+160, 100, y
+160 );
617 ud
.SetDashes( 1, dash1
);
618 dc
.DrawLine( x
+20, y
+170, 100, y
+170 );
621 void MyCanvas::DrawDefault(wxDC
& dc
)
624 dc
.DrawCircle(0, 0, 10);
625 #if !(defined __WXGTK__) && !(defined __WXMOTIF__)
626 // not implemented in wxGTK or wxMOTIF :-(
627 dc
.FloodFill(0, 0, wxColour(255, 0, 0));
630 dc
.DrawCheckMark(5, 80, 15, 15);
631 dc
.DrawCheckMark(25, 80, 30, 30);
632 dc
.DrawCheckMark(60, 80, 60, 60);
634 // this is the test for "blitting bitmap into DC damages selected brush" bug
635 wxCoord rectSize
= m_std_icon
.GetWidth() + 10;
637 dc
.SetPen(*wxTRANSPARENT_PEN
);
638 dc
.SetBrush( *wxGREEN_BRUSH
);
639 dc
.DrawRectangle(x
, 10, rectSize
, rectSize
);
640 dc
.DrawBitmap(m_std_icon
, x
+ 5, 15, TRUE
);
642 dc
.DrawRectangle(x
, 10, rectSize
, rectSize
);
643 dc
.DrawIcon(m_std_icon
, x
+ 5, 15);
645 dc
.DrawRectangle(x
, 10, rectSize
, rectSize
);
647 // test for "transparent" bitmap drawing (it intersects with the last
649 //dc.SetBrush( *wxTRANSPARENT_BRUSH );
651 if (m_smile_bmp
.Ok())
652 dc
.DrawBitmap(m_smile_bmp
, x
+ rectSize
- 20, rectSize
- 10, TRUE
);
654 dc
.SetBrush( *wxBLACK_BRUSH
);
655 dc
.DrawRectangle( 0, 160, 1000, 300 );
658 wxBitmap
bitmap(20,70);
660 memdc
.SelectObject( bitmap
);
661 memdc
.SetBrush( *wxBLACK_BRUSH
);
662 memdc
.SetPen( *wxWHITE_PEN
);
663 memdc
.DrawRectangle(0,0,20,70);
664 memdc
.DrawLine( 10,0,10,70 );
667 wxPen pen
= *wxRED_PEN
;
669 memdc
.DrawLine( 10, 5,10, 5 );
670 memdc
.DrawLine( 10,10,11,10 );
671 memdc
.DrawLine( 10,15,12,15 );
672 memdc
.DrawLine( 10,20,13,20 );
675 memdc.SetPen(*wxRED_PEN);
676 memdc.DrawLine( 12, 5,12, 5 );
677 memdc.DrawLine( 12,10,13,10 );
678 memdc.DrawLine( 12,15,14,15 );
679 memdc.DrawLine( 12,20,15,20 );
683 memdc
.DrawLine( 10,25,10,25 );
684 memdc
.DrawLine( 10,30, 9,30 );
685 memdc
.DrawLine( 10,35, 8,35 );
686 memdc
.DrawLine( 10,40, 7,40 );
689 dc
.SetPen(*wxWHITE_PEN
);
690 memdc
.SetLogicalFunction( wxINVERT
);
691 memdc
.SetPen( *wxWHITE_PEN
);
692 memdc
.DrawLine( 10,50,10,50 );
693 memdc
.DrawLine( 10,55,11,55 );
694 memdc
.DrawLine( 10,60,12,60 );
695 memdc
.DrawLine( 10,65,13,65 );
697 memdc
.DrawLine( 12,50,12,50 );
698 memdc
.DrawLine( 12,55,13,55 );
699 memdc
.DrawLine( 12,60,14,60 );
700 memdc
.DrawLine( 12,65,15,65 );
702 memdc
.SelectObject( wxNullBitmap
);
703 dc
.DrawBitmap( bitmap
, 10, 170 );
704 wxImage
image( bitmap
);
705 image
.Rescale( 60,210 );
706 bitmap
= image
.ConvertToBitmap();
707 dc
.DrawBitmap( bitmap
, 50, 170 );
709 // test the rectangle outline drawing - there should be one pixel between
710 // the rect and the lines
711 dc
.SetPen(*wxWHITE_PEN
);
712 dc
.SetBrush( *wxTRANSPARENT_BRUSH
);
713 dc
.DrawRectangle(150, 170, 49, 29);
714 dc
.DrawRectangle(200, 170, 49, 29);
715 dc
.SetPen(*wxWHITE_PEN
);
716 dc
.DrawLine(250, 210, 250, 170);
717 dc
.DrawLine(260, 200, 150, 200);
719 // test the rectangle filled drawing - there should be one pixel between
720 // the rect and the lines
721 dc
.SetPen(*wxTRANSPARENT_PEN
);
722 dc
.SetBrush( *wxWHITE_BRUSH
);
723 dc
.DrawRectangle(300, 170, 49, 29);
724 dc
.DrawRectangle(350, 170, 49, 29);
725 dc
.SetPen(*wxWHITE_PEN
);
726 dc
.DrawLine(400, 170, 400, 210);
727 dc
.DrawLine(300, 200, 410, 200);
729 // a few more tests of this kind
730 dc
.SetPen(*wxRED_PEN
);
731 dc
.SetBrush( *wxWHITE_BRUSH
);
732 dc
.DrawRectangle(300, 220, 1, 1);
733 dc
.DrawRectangle(310, 220, 2, 2);
734 dc
.DrawRectangle(320, 220, 3, 3);
735 dc
.DrawRectangle(330, 220, 4, 4);
737 dc
.SetPen(*wxTRANSPARENT_PEN
);
738 dc
.SetBrush( *wxWHITE_BRUSH
);
739 dc
.DrawRectangle(300, 230, 1, 1);
740 dc
.DrawRectangle(310, 230, 2, 2);
741 dc
.DrawRectangle(320, 230, 3, 3);
742 dc
.DrawRectangle(330, 230, 4, 4);
744 // and now for filled rect with outline
745 dc
.SetPen(*wxRED_PEN
);
746 dc
.SetBrush( *wxWHITE_BRUSH
);
747 dc
.DrawRectangle(500, 170, 49, 29);
748 dc
.DrawRectangle(550, 170, 49, 29);
749 dc
.SetPen(*wxWHITE_PEN
);
750 dc
.DrawLine(600, 170, 600, 210);
751 dc
.DrawLine(500, 200, 610, 200);
753 // test the rectangle outline drawing - there should be one pixel between
754 // the rect and the lines
755 dc
.SetPen(*wxWHITE_PEN
);
756 dc
.SetBrush( *wxTRANSPARENT_BRUSH
);
757 dc
.DrawRoundedRectangle(150, 270, 49, 29, 6);
758 dc
.DrawRoundedRectangle(200, 270, 49, 29, 6);
759 dc
.SetPen(*wxWHITE_PEN
);
760 dc
.DrawLine(250, 270, 250, 310);
761 dc
.DrawLine(150, 300, 260, 300);
763 // test the rectangle filled drawing - there should be one pixel between
764 // the rect and the lines
765 dc
.SetPen(*wxTRANSPARENT_PEN
);
766 dc
.SetBrush( *wxWHITE_BRUSH
);
767 dc
.DrawRoundedRectangle(300, 270, 49, 29, 6);
768 dc
.DrawRoundedRectangle(350, 270, 49, 29, 6);
769 dc
.SetPen(*wxWHITE_PEN
);
770 dc
.DrawLine(400, 270, 400, 310);
771 dc
.DrawLine(300, 300, 410, 300);
773 // Added by JACS to demonstrate bizarre behaviour.
774 // With a size of 70, we get a missing red RHS,
775 // and the hight is too small, so we get yellow
776 // showing. With a size of 40, it draws as expected:
777 // it just shows a white rectangle with red outline.
779 int totalHeight
= 70;
780 wxBitmap
bitmap2(totalWidth
, totalHeight
);
783 memdc2
.SelectObject(bitmap2
);
785 wxBrush
yellowBrush(wxColour(255, 255, 0), wxSOLID
);
786 memdc2
.SetBackground(yellowBrush
);
789 wxPen
yellowPen(wxColour(255, 255, 0), 1, wxSOLID
);
791 // Now draw a white rectangle with red outline. It should
792 // entirely eclipse the yellow background.
793 memdc2
.SetPen(*wxRED_PEN
);
794 memdc2
.SetBrush(*wxWHITE_BRUSH
);
796 memdc2
.DrawRectangle(0, 0, totalWidth
, totalHeight
);
798 memdc2
.SetPen(wxNullPen
);
799 memdc2
.SetBrush(wxNullBrush
);
800 memdc2
.SelectObject(wxNullBitmap
);
802 dc
.DrawBitmap(bitmap2
, 500, 270);
804 // Repeat, but draw directly on dc
805 // Draw a yellow rectangle filling the bitmap
807 x
= 600; int y
= 270;
808 dc
.SetPen(yellowPen
);
809 dc
.SetBrush(yellowBrush
);
810 dc
.DrawRectangle(x
, y
, totalWidth
, totalHeight
);
812 // Now draw a white rectangle with red outline. It should
813 // entirely eclipse the yellow background.
814 dc
.SetPen(*wxRED_PEN
);
815 dc
.SetBrush(*wxWHITE_BRUSH
);
817 dc
.DrawRectangle(x
, y
, totalWidth
, totalHeight
);
820 void MyCanvas::DrawText(wxDC
& dc
)
822 // set underlined font for testing
823 dc
.SetFont( wxFont(12, wxMODERN
, wxNORMAL
, wxNORMAL
, TRUE
) );
824 dc
.DrawText( "This is text", 110, 10 );
825 dc
.DrawRotatedText( "That is text", 20, 10, -45 );
827 dc
.SetFont( *wxNORMAL_FONT
);
830 dc
.SetBackgroundMode(wxTRANSPARENT
);
832 for ( int n
= -180; n
< 180; n
+= 30 )
834 text
.Printf(" %d rotated text", n
);
835 dc
.DrawRotatedText(text
, 400, 400, n
);
838 dc
.SetFont( wxFont( 18, wxSWISS
, wxNORMAL
, wxNORMAL
) );
840 dc
.DrawText( "This is Swiss 18pt text.", 110, 40 );
845 dc
.GetTextExtent( "This is Swiss 18pt text.", &length
, &height
, &descent
);
846 text
.Printf( "Dimensions are length %ld, height %ld, descent %ld", length
, height
, descent
);
847 dc
.DrawText( text
, 110, 80 );
849 text
.Printf( "CharHeight() returns: %d", dc
.GetCharHeight() );
850 dc
.DrawText( text
, 110, 120 );
852 dc
.DrawRectangle( 100, 40, 4, height
);
854 // test the logical function effect
856 dc
.SetLogicalFunction(wxINVERT
);
857 dc
.DrawText( "There should be no text below", 110, 150 );
858 dc
.DrawRectangle( 110, y
, 100, height
);
860 // twice drawn inverted should result in invisible
862 dc
.DrawText( "Invisible text", 110, y
);
863 dc
.DrawRectangle( 110, y
, 100, height
);
864 dc
.DrawText( "Invisible text", 110, y
);
865 dc
.DrawRectangle( 110, y
, 100, height
);
866 dc
.SetLogicalFunction(wxCOPY
);
869 dc
.DrawRectangle( 110, y
, 100, height
);
870 dc
.DrawText( "Visible text", 110, y
);
877 } rasterOperations
[] =
880 { "wxAND_INVERT", wxAND_INVERT
},
881 { "wxAND_REVERSE", wxAND_REVERSE
},
882 { "wxCLEAR", wxCLEAR
},
883 { "wxCOPY", wxCOPY
},
884 { "wxEQUIV", wxEQUIV
},
885 { "wxINVERT", wxINVERT
},
886 { "wxNAND", wxNAND
},
887 { "wxNO_OP", wxNO_OP
},
889 { "wxOR_INVERT", wxOR_INVERT
},
890 { "wxOR_REVERSE", wxOR_REVERSE
},
892 { "wxSRC_INVERT", wxSRC_INVERT
},
896 void MyCanvas::DrawImages(wxDC
& dc
)
898 dc
.DrawText("original image", 0, 0);
899 dc
.DrawBitmap(*gs_bmpNoMask
, 0, 20, 0);
900 dc
.DrawText("with colour mask", 0, 100);
901 dc
.DrawBitmap(*gs_bmpWithColMask
, 0, 120, TRUE
);
902 dc
.DrawText("the mask image", 0, 200);
903 dc
.DrawBitmap(*gs_bmpMask
, 0, 220, 0);
904 dc
.DrawText("masked image", 0, 300);
905 dc
.DrawBitmap(*gs_bmpWithMask
, 0, 320, TRUE
);
907 int cx
= gs_bmpWithColMask
->GetWidth(),
908 cy
= gs_bmpWithColMask
->GetHeight();
911 for ( size_t n
= 0; n
< WXSIZEOF(rasterOperations
); n
++ )
913 wxCoord x
= 120 + 150*(n%4
),
916 dc
.DrawText(rasterOperations
[n
].name
, x
, y
- 20);
917 memDC
.SelectObject(*gs_bmpWithColMask
);
918 dc
.Blit(x
, y
, cx
, cy
, &memDC
, 0, 0, rasterOperations
[n
].rop
, TRUE
);
922 void MyCanvas::DrawWithLogicalOps(wxDC
& dc
)
924 static const wxCoord w
= 60;
925 static const wxCoord h
= 60;
927 // reuse the text colour here
928 dc
.SetPen(wxPen(m_owner
->m_colourForeground
, 1, wxSOLID
));
929 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
932 for ( n
= 0; n
< WXSIZEOF(rasterOperations
); n
++ )
934 wxCoord x
= 20 + 150*(n%4
),
937 dc
.DrawText(rasterOperations
[n
].name
, x
, y
- 20);
938 dc
.SetLogicalFunction(rasterOperations
[n
].rop
);
939 dc
.DrawRectangle(x
, y
, w
, h
);
940 dc
.DrawLine(x
, y
, x
+ w
, y
+ h
);
941 dc
.DrawLine(x
+ w
, y
, x
, y
+ h
);
944 // now some filled rectangles
945 dc
.SetBrush(wxBrush(m_owner
->m_colourForeground
, wxSOLID
));
947 for ( n
= 0; n
< WXSIZEOF(rasterOperations
); n
++ )
949 wxCoord x
= 20 + 150*(n%4
),
952 dc
.DrawText(rasterOperations
[n
].name
, x
, y
- 20);
953 dc
.SetLogicalFunction(rasterOperations
[n
].rop
);
954 dc
.DrawRectangle(x
, y
, w
, h
);
958 void MyCanvas::DrawCircles(wxDC
& dc
)
964 dc
.DrawText("Some circles", 0, y
);
965 dc
.DrawCircle(x
, y
, r
);
966 dc
.DrawCircle(x
+ 2*r
, y
, r
);
967 dc
.DrawCircle(x
+ 4*r
, y
, r
);
970 dc
.DrawText("And ellipses", 0, y
);
971 dc
.DrawEllipse(x
- r
, y
, 2*r
, r
);
972 dc
.DrawEllipse(x
+ r
, y
, 2*r
, r
);
973 dc
.DrawEllipse(x
+ 3*r
, y
, 2*r
, r
);
976 dc
.DrawText("And arcs", 0, y
);
977 dc
.DrawArc(x
- r
, y
, x
+ r
, y
, x
, y
);
978 dc
.DrawArc(x
+ 4*r
, y
, x
+ 2*r
, y
, x
+ 3*r
, y
);
979 dc
.DrawArc(x
+ 5*r
, y
, x
+ 5*r
, y
, x
+ 6*r
, y
);
982 dc
.DrawEllipticArc(x
- r
, y
, 2*r
, r
, 0, 90);
983 dc
.DrawEllipticArc(x
+ r
, y
, 2*r
, r
, 90, 180);
984 dc
.DrawEllipticArc(x
+ 3*r
, y
, 2*r
, r
, 180, 270);
985 dc
.DrawEllipticArc(x
+ 5*r
, y
, 2*r
, r
, 270, 360);
988 void MyCanvas::DrawRegions(wxDC
& dc
)
990 dc
.DrawText("You should see a red rect partly covered by a cyan one "
991 "on the left", 10, 5);
992 dc
.DrawText("and 5 smileys from which 4 are partially clipped on the "
993 "right (2 copies should be identical)",
994 10, 5 + dc
.GetCharHeight());
996 DrawRegionsHelper(dc
, 10);
997 DrawRegionsHelper(dc
, 350);
1000 void MyCanvas::DrawRegionsHelper(wxDC
& dc
, wxCoord x
)
1002 dc
.DestroyClippingRegion();
1003 dc
.SetBrush( *wxWHITE_BRUSH
);
1004 dc
.SetPen( *wxTRANSPARENT_PEN
);
1005 dc
.DrawRectangle( x
,50,310,310 );
1007 dc
.SetClippingRegion( x
+10,60,100,270 );
1009 dc
.SetBrush( *wxRED_BRUSH
);
1010 dc
.DrawRectangle( x
,50,310,310 );
1012 dc
.SetClippingRegion( x
+10,60,100,100 );
1014 dc
.SetBrush( *wxCYAN_BRUSH
);
1015 dc
.DrawRectangle( x
,50,310,310 );
1017 // when drawing the left half, destroy the clipping region, when drawing
1018 // the right one - leave it
1020 // normally it shouldn't make any difference as SetClippingRegion()
1021 // replaces the old clipping region
1023 dc
.DestroyClippingRegion();
1024 dc
.SetClippingRegion( x
+110,70,100,270 );
1026 dc
.SetBrush( *wxGREY_BRUSH
);
1027 dc
.DrawRectangle( x
,50,310,310 );
1029 if (m_smile_bmp
.Ok())
1031 dc
.DrawBitmap( m_smile_bmp
, x
+150, 200, TRUE
);
1032 dc
.DrawBitmap( m_smile_bmp
, x
+130, 60, TRUE
);
1033 dc
.DrawBitmap( m_smile_bmp
, x
+130, 330, TRUE
);
1034 dc
.DrawBitmap( m_smile_bmp
, x
+100, 120, TRUE
);
1035 dc
.DrawBitmap( m_smile_bmp
, x
+200, 120, TRUE
);
1039 void MyCanvas::OnPaint(wxPaintEvent
&WXUNUSED(event
))
1044 m_owner
->PrepareDC(dc
);
1046 dc
.SetBackgroundMode( m_owner
->m_backgroundMode
);
1047 if ( m_owner
->m_backgroundBrush
.Ok() )
1048 dc
.SetBackground( m_owner
->m_backgroundBrush
);
1049 if ( m_owner
->m_colourForeground
.Ok() )
1050 dc
.SetTextForeground( m_owner
->m_colourForeground
);
1051 if ( m_owner
->m_colourBackground
.Ok() )
1052 dc
.SetTextBackground( m_owner
->m_colourBackground
);
1054 if ( m_owner
->m_textureBackground
) {
1055 if ( ! m_owner
->m_backgroundBrush
.Ok() ) {
1056 wxBrush
b(wxColour(0,128,0), wxSOLID
);
1057 dc
.SetBackground(b
);
1063 if ( m_owner
->m_textureBackground
) {
1064 dc
.SetPen(*wxMEDIUM_GREY_PEN
);
1065 for (int i
=0; i
<200; i
++)
1066 dc
.DrawLine(0, i
*10, i
*10, 0);
1088 DrawTestLines( 0, 100, 0, dc
);
1089 DrawTestLines( 0, 320, 1, dc
);
1090 DrawTestLines( 0, 540, 2, dc
);
1091 DrawTestLines( 0, 760, 6, dc
);
1095 DrawTestPoly( 0, 100, dc
, 0 );
1097 DrawTestPoly( 33, 500, dc, 1 );
1098 DrawTestPoly( 43, 1000, dc, 2 );
1107 DrawWithLogicalOps(dc
);
1112 dc
.SetPen( *wxBLACK_PEN
);
1113 dc
.DrawLine( 0,0,100,100 );
1119 void MyCanvas::OnMouseMove(wxMouseEvent
&event
)
1121 wxClientDC
dc(this);
1123 m_owner
->PrepareDC(dc
);
1125 wxPoint pos
= event
.GetPosition();
1126 long x
= dc
.DeviceToLogicalX( pos
.x
);
1127 long y
= dc
.DeviceToLogicalY( pos
.y
);
1129 str
.Printf( "Current mouse position: %d,%d", (int)x
, (int)y
);
1130 m_owner
->SetStatusText( str
);
1133 // ----------------------------------------------------------------------------
1135 // ----------------------------------------------------------------------------
1137 // the event tables connect the wxWindows events with the functions (event
1138 // handlers) which process them. It can be also done at run-time, but for the
1139 // simple menu events like this the static method is much simpler.
1140 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
1141 EVT_MENU (File_Quit
, MyFrame::OnQuit
)
1142 EVT_MENU (File_About
, MyFrame::OnAbout
)
1144 EVT_MENU_RANGE(MenuShow_First
, MenuShow_Last
, MyFrame::OnShow
)
1146 EVT_MENU_RANGE(MenuOption_First
, MenuOption_Last
, MyFrame::OnOption
)
1149 // frame constructor
1150 MyFrame::MyFrame(const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
)
1151 : wxFrame((wxFrame
*)NULL
, -1, title
, pos
, size
,
1152 wxDEFAULT_FRAME_STYLE
| wxNO_FULL_REPAINT_ON_RESIZE
)
1154 // set the frame icon
1155 SetIcon(wxICON(mondrian
));
1157 wxMenu
*menuFile
= new wxMenu
;
1158 menuFile
->Append(File_ShowDefault
, "&Default screen\tF1");
1159 menuFile
->Append(File_ShowText
, "&Text screen\tF2");
1160 menuFile
->Append(File_ShowLines
, "&Lines screen\tF3");
1161 menuFile
->Append(File_ShowPolygons
, "&Polygons screen\tF4");
1162 menuFile
->Append(File_ShowMask
, "wx&Mask screen\tF5");
1163 menuFile
->Append(File_ShowOps
, "&ROP screen\tF6");
1164 menuFile
->Append(File_ShowRegions
, "Re&gions screen\tF7");
1165 menuFile
->Append(File_ShowCircles
, "&Circles screen\tF8");
1166 menuFile
->AppendSeparator();
1167 menuFile
->Append(File_About
, "&About...\tCtrl-A", "Show about dialog");
1168 menuFile
->AppendSeparator();
1169 menuFile
->Append(File_Quit
, "E&xit\tAlt-X", "Quit this program");
1171 wxMenu
*menuMapMode
= new wxMenu
;
1172 menuMapMode
->Append( MapMode_Text
, "&TEXT map mode" );
1173 menuMapMode
->Append( MapMode_Lometric
, "&LOMETRIC map mode" );
1174 menuMapMode
->Append( MapMode_Twips
, "T&WIPS map mode" );
1175 menuMapMode
->Append( MapMode_Points
, "&POINTS map mode" );
1176 menuMapMode
->Append( MapMode_Metric
, "&METRIC map mode" );
1178 wxMenu
*menuUserScale
= new wxMenu
;
1179 menuUserScale
->Append( UserScale_StretchHoriz
, "Stretch horizontally\tCtrl-H" );
1180 menuUserScale
->Append( UserScale_ShrinkHoriz
, "Shrink horizontally\tCtrl-G" );
1181 menuUserScale
->Append( UserScale_StretchVertic
, "Stretch vertically\tCtrl-V" );
1182 menuUserScale
->Append( UserScale_ShrinkVertic
, "Shrink vertically\tCtrl-W" );
1183 menuUserScale
->AppendSeparator();
1184 menuUserScale
->Append( UserScale_Restore
, "Restore to normal\tCtrl-0" );
1186 wxMenu
*menuAxis
= new wxMenu
;
1187 menuAxis
->Append( AxisMirror_Horiz
, "Mirror horizontally\tCtrl-M", "", TRUE
);
1188 menuAxis
->Append( AxisMirror_Vertic
, "Mirror vertically\tCtrl-N", "", TRUE
);
1190 wxMenu
*menuLogical
= new wxMenu
;
1191 menuLogical
->Append( LogicalOrigin_MoveDown
, "Move &down\tCtrl-D" );
1192 menuLogical
->Append( LogicalOrigin_MoveUp
, "Move &up\tCtrl-U" );
1193 menuLogical
->Append( LogicalOrigin_MoveLeft
, "Move &right\tCtrl-L" );
1194 menuLogical
->Append( LogicalOrigin_MoveRight
, "Move &left\tCtrl-R" );
1196 wxMenu
*menuColour
= new wxMenu
;
1197 menuColour
->Append( Colour_TextForeground
, "Text foreground..." );
1198 menuColour
->Append( Colour_TextBackground
, "Text background..." );
1199 menuColour
->Append( Colour_Background
, "Background colour..." );
1200 menuColour
->Append( Colour_BackgroundMode
, "Opaque/transparent\tCtrl-B", "", TRUE
);
1201 menuColour
->Append( Colour_TextureBackgound
, "Draw textured background\tCtrl-T", "", TRUE
);
1203 // now append the freshly created menu to the menu bar...
1204 wxMenuBar
*menuBar
= new wxMenuBar
;
1205 menuBar
->Append(menuFile
, "&File");
1206 menuBar
->Append(menuMapMode
, "&MapMode");
1207 menuBar
->Append(menuUserScale
, "&UserScale");
1208 menuBar
->Append(menuAxis
, "&Axis");
1209 menuBar
->Append(menuLogical
, "&LogicalOrigin");
1210 menuBar
->Append(menuColour
, "&Colours");
1212 // ... and attach this menu bar to the frame
1213 SetMenuBar(menuBar
);
1215 // create a status bar just for fun (by default with 1 pane only)
1217 SetStatusText("Welcome to wxWindows!");
1219 m_mapMode
= wxMM_TEXT
;
1222 m_xLogicalOrigin
= 0;
1223 m_yLogicalOrigin
= 0;
1225 m_yAxisReversed
= FALSE
;
1226 m_backgroundMode
= wxSOLID
;
1227 m_colourForeground
= *wxRED
;
1228 m_colourBackground
= *wxBLUE
;
1229 m_textureBackground
= FALSE
;
1231 m_canvas
= new MyCanvas( this );
1232 m_canvas
->SetScrollbars( 10, 10, 100, 240 );
1237 void MyFrame::OnQuit(wxCommandEvent
& WXUNUSED(event
))
1239 // TRUE is to force the frame to close
1243 void MyFrame::OnAbout(wxCommandEvent
& WXUNUSED(event
))
1246 msg
.Printf( wxT("This is the about dialog of the drawing sample.\n")
1247 wxT("This sample tests various primitive drawing functions\n")
1248 wxT("without any tests to prevent flicker.\n")
1249 wxT("Copyright (c) Robert Roebling 1999")
1252 wxMessageBox(msg
, "About Drawing", wxOK
| wxICON_INFORMATION
, this);
1255 void MyFrame::OnShow(wxCommandEvent
& event
)
1257 m_canvas
->Show((ScreenToShow
)(event
.GetId() - MenuShow_First
));
1260 void MyFrame::OnOption(wxCommandEvent
& event
)
1262 switch (event
.GetId())
1265 m_mapMode
= wxMM_TEXT
;
1267 case MapMode_Lometric
:
1268 m_mapMode
= wxMM_LOMETRIC
;
1271 m_mapMode
= wxMM_TWIPS
;
1273 case MapMode_Points
:
1274 m_mapMode
= wxMM_POINTS
;
1276 case MapMode_Metric
:
1277 m_mapMode
= wxMM_METRIC
;
1280 case LogicalOrigin_MoveDown
:
1281 m_yLogicalOrigin
+= 10;
1283 case LogicalOrigin_MoveUp
:
1284 m_yLogicalOrigin
-= 10;
1286 case LogicalOrigin_MoveLeft
:
1287 m_xLogicalOrigin
+= 10;
1289 case LogicalOrigin_MoveRight
:
1290 m_xLogicalOrigin
-= 10;
1293 case UserScale_StretchHoriz
:
1294 m_xUserScale
*= 1.10;
1296 case UserScale_ShrinkHoriz
:
1297 m_xUserScale
/= 1.10;
1299 case UserScale_StretchVertic
:
1300 m_yUserScale
*= 1.10;
1302 case UserScale_ShrinkVertic
:
1303 m_yUserScale
/= 1.10;
1305 case UserScale_Restore
:
1310 case AxisMirror_Vertic
:
1311 m_yAxisReversed
= !m_yAxisReversed
;
1313 case AxisMirror_Horiz
:
1314 m_xAxisReversed
= !m_xAxisReversed
;
1317 case Colour_TextForeground
:
1318 m_colourForeground
= SelectColour();
1320 case Colour_TextBackground
:
1321 m_colourBackground
= SelectColour();
1323 case Colour_Background
:
1325 wxColour col
= SelectColour();
1328 m_backgroundBrush
.SetColour(col
);
1332 case Colour_BackgroundMode
:
1333 m_backgroundMode
= m_backgroundMode
== wxSOLID
? wxTRANSPARENT
1337 case Colour_TextureBackgound
:
1338 m_textureBackground
= ! m_textureBackground
;
1346 m_canvas
->Refresh();
1349 void MyFrame::PrepareDC(wxDC
& dc
)
1351 dc
.SetMapMode( m_mapMode
);
1352 dc
.SetUserScale( m_xUserScale
, m_yUserScale
);
1353 dc
.SetLogicalOrigin( m_xLogicalOrigin
, m_yLogicalOrigin
);
1354 dc
.SetAxisOrientation( !m_xAxisReversed
, m_yAxisReversed
);
1357 wxColour
MyFrame::SelectColour()
1361 wxColourDialog
dialog(this, &data
);
1363 if ( dialog
.ShowModal() == wxID_OK
)
1365 col
= dialog
.GetColourData().GetColour();