Make wxRenderer::DrawItemSelectionRect() draw a focus outline of wxCONTROL_CURRENT...
[wxWidgets.git] / src / generic / renderg.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/generic/renderg.cpp
3 // Purpose: generic implementation of wxRendererNative (for any platform)
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 20.07.2003
7 // RCS-ID: $Id$
8 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
9 // License: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 // for compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #include "wx/renderer.h"
28
29 #ifndef WX_PRECOMP
30 #include "wx/string.h"
31 #include "wx/dc.h"
32 #include "wx/settings.h"
33 #include "wx/gdicmn.h"
34 #include "wx/module.h"
35 #endif //WX_PRECOMP
36
37 #include "wx/splitter.h"
38 #include "wx/dcmirror.h"
39
40 #ifdef __WXMAC__
41 #include "wx/mac/private.h"
42 #endif
43
44 // ----------------------------------------------------------------------------
45 // wxRendererGeneric: our wxRendererNative implementation
46 // ----------------------------------------------------------------------------
47
48 class WXDLLEXPORT wxRendererGeneric : public wxRendererNative
49 {
50 public:
51 wxRendererGeneric();
52
53 virtual int DrawHeaderButton(wxWindow *win,
54 wxDC& dc,
55 const wxRect& rect,
56 int flags = 0,
57 wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
58 wxHeaderButtonParams* params = NULL);
59
60 virtual int DrawHeaderButtonContents(wxWindow *win,
61 wxDC& dc,
62 const wxRect& rect,
63 int flags = 0,
64 wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
65 wxHeaderButtonParams* params = NULL);
66
67 virtual int GetHeaderButtonHeight(wxWindow *win);
68
69 virtual void DrawTreeItemButton(wxWindow *win,
70 wxDC& dc,
71 const wxRect& rect,
72 int flags = 0);
73
74 virtual void DrawSplitterBorder(wxWindow *win,
75 wxDC& dc,
76 const wxRect& rect,
77 int flags = 0);
78
79 virtual void DrawSplitterSash(wxWindow *win,
80 wxDC& dc,
81 const wxSize& size,
82 wxCoord position,
83 wxOrientation orient,
84 int flags = 0);
85
86 virtual void DrawComboBoxDropButton(wxWindow *win,
87 wxDC& dc,
88 const wxRect& rect,
89 int flags = 0);
90
91 virtual void DrawDropArrow(wxWindow *win,
92 wxDC& dc,
93 const wxRect& rect,
94 int flags = 0);
95
96 virtual void DrawCheckBox(wxWindow *win,
97 wxDC& dc,
98 const wxRect& rect,
99 int flags = 0);
100
101 virtual void DrawPushButton(wxWindow *win,
102 wxDC& dc,
103 const wxRect& rect,
104 int flags = 0);
105
106 virtual void DrawItemSelectionRect(wxWindow *win,
107 wxDC& dc,
108 const wxRect& rect,
109 int flags = 0);
110
111 virtual void DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, int flags = 0);
112
113 virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win);
114
115 virtual wxRendererVersion GetVersion() const
116 {
117 return wxRendererVersion(wxRendererVersion::Current_Version,
118 wxRendererVersion::Current_Age);
119 }
120
121
122 // Cleanup by deleting standard renderer
123 static void Cleanup();
124
125 // Get the generic object
126 static wxRendererGeneric* DoGetGeneric();
127
128 protected:
129 // draw the rectange using the first pen for the left and top sides and
130 // the second one for the bottom and right ones
131 void DrawShadedRect(wxDC& dc, wxRect *rect,
132 const wxPen& pen1, const wxPen& pen2);
133
134 // the standard pens
135 wxPen m_penBlack,
136 m_penDarkGrey,
137 m_penLightGrey,
138 m_penHighlight;
139
140 static wxRendererGeneric* sm_rendererGeneric;
141 };
142
143 // ============================================================================
144 // wxRendererGeneric implementation
145 // ============================================================================
146
147 // Get the generic object
148 wxRendererGeneric* wxRendererGeneric::DoGetGeneric()
149 {
150 if (!sm_rendererGeneric)
151 sm_rendererGeneric = new wxRendererGeneric;
152 return sm_rendererGeneric;
153 }
154
155 // ----------------------------------------------------------------------------
156 // wxRendererGeneric creation
157 // ----------------------------------------------------------------------------
158
159 /* static */
160 wxRendererNative& wxRendererNative::GetGeneric()
161 {
162 return * wxRendererGeneric::DoGetGeneric();
163 }
164
165 void wxRendererGeneric::Cleanup()
166 {
167 if (sm_rendererGeneric)
168 delete sm_rendererGeneric;
169
170 sm_rendererGeneric = NULL;
171 }
172
173 wxRendererGeneric* wxRendererGeneric::sm_rendererGeneric = NULL;
174
175 wxRendererGeneric::wxRendererGeneric()
176 : m_penBlack(wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW)),
177 m_penDarkGrey(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW)),
178 m_penLightGrey(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)),
179 m_penHighlight(wxSystemSettings::GetColour(wxSYS_COLOUR_3DHIGHLIGHT))
180 {
181 }
182
183 // ----------------------------------------------------------------------------
184 // wxRendererGeneric helpers
185 // ----------------------------------------------------------------------------
186
187 void
188 wxRendererGeneric::DrawShadedRect(wxDC& dc,
189 wxRect *rect,
190 const wxPen& pen1,
191 const wxPen& pen2)
192 {
193 // draw the rectangle
194 dc.SetPen(pen1);
195 dc.DrawLine(rect->GetLeft(), rect->GetTop(),
196 rect->GetLeft(), rect->GetBottom());
197 dc.DrawLine(rect->GetLeft() + 1, rect->GetTop(),
198 rect->GetRight(), rect->GetTop());
199 dc.SetPen(pen2);
200 dc.DrawLine(rect->GetRight(), rect->GetTop(),
201 rect->GetRight(), rect->GetBottom());
202 dc.DrawLine(rect->GetLeft(), rect->GetBottom(),
203 rect->GetRight() + 1, rect->GetBottom());
204
205 // adjust the rect
206 rect->Inflate(-1);
207 }
208
209 // ----------------------------------------------------------------------------
210 // tree/list ctrl drawing
211 // ----------------------------------------------------------------------------
212
213 int
214 wxRendererGeneric::DrawHeaderButton(wxWindow* win,
215 wxDC& dc,
216 const wxRect& rect,
217 int flags,
218 wxHeaderSortIconType sortArrow,
219 wxHeaderButtonParams* params)
220 {
221 const int CORNER = 1;
222
223 const wxCoord x = rect.x,
224 y = rect.y,
225 w = rect.width,
226 h = rect.height;
227
228 dc.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)));
229 dc.SetPen(*wxTRANSPARENT_PEN);
230 dc.DrawRectangle(rect);
231
232 dc.SetBrush(*wxTRANSPARENT_BRUSH);
233
234 dc.SetPen(m_penBlack);
235 dc.DrawLine( x+w-CORNER+1, y, x+w, y+h ); // right (outer)
236 dc.DrawRectangle( x, y+h, w+1, 1 ); // bottom (outer)
237
238 dc.SetPen(m_penDarkGrey);
239 dc.DrawLine( x+w-CORNER, y, x+w-1, y+h ); // right (inner)
240 dc.DrawRectangle( x+1, y+h-1, w-2, 1 ); // bottom (inner)
241
242 dc.SetPen(m_penHighlight);
243 dc.DrawRectangle( x, y, w-CORNER+1, 1 ); // top (outer)
244 dc.DrawRectangle( x, y, 1, h ); // left (outer)
245 dc.DrawLine( x, y+h-1, x+1, y+h-1 );
246 dc.DrawLine( x+w-1, y, x+w-1, y+1 );
247
248 return DrawHeaderButtonContents(win, dc, rect, flags, sortArrow, params);
249 }
250
251
252 int
253 wxRendererGeneric::DrawHeaderButtonContents(wxWindow *win,
254 wxDC& dc,
255 const wxRect& rect,
256 int flags,
257 wxHeaderSortIconType sortArrow,
258 wxHeaderButtonParams* params)
259 {
260 int labelWidth = 0;
261
262 // Mark this item as selected. For the generic version we'll just draw an
263 // underline
264 if ( flags & wxCONTROL_SELECTED )
265 {
266 // draw a line at the bottom of the header button, overlaying the
267 // native hot-tracking line (on XP)
268 const int penwidth = 3;
269 int y = rect.y + rect.height + 1 - penwidth;
270 wxColour c = (params && params->m_selectionColour.Ok()) ?
271 params->m_selectionColour : wxColour(0x66, 0x66, 0x66);
272 wxPen pen(c, penwidth);
273 pen.SetCap(wxCAP_BUTT);
274 dc.SetPen(pen);
275 dc.DrawLine(rect.x, y, rect.x + rect.width, y);
276 }
277
278 // Draw an up or down arrow
279 int arrowSpace = 0;
280 if (sortArrow != wxHDR_SORT_ICON_NONE )
281 {
282 wxRect ar = rect;
283
284 // make a rect for the arrow
285 ar.height = 4;
286 ar.width = 8;
287 ar.y += (rect.height - ar.height)/2;
288 ar.x = ar.x + rect.width - 3*ar.width/2;
289 arrowSpace = 3*ar.width/2; // space to preserve when drawing the label
290
291 wxPoint triPt[3];
292 if ( sortArrow & wxHDR_SORT_ICON_UP )
293 {
294 triPt[0].x = ar.width / 2;
295 triPt[0].y = 0;
296 triPt[1].x = ar.width;
297 triPt[1].y = ar.height;
298 triPt[2].x = 0;
299 triPt[2].y = ar.height;
300 }
301 else
302 {
303 triPt[0].x = 0;
304 triPt[0].y = 0;
305 triPt[1].x = ar.width;
306 triPt[1].y = 0;
307 triPt[2].x = ar.width / 2;
308 triPt[2].y = ar.height;
309 }
310
311 wxColour c = (params && params->m_arrowColour.Ok()) ?
312 params->m_arrowColour : wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW);
313 dc.SetPen(wxPen(c));
314 dc.SetBrush(wxBrush(c));
315 dc.DrawPolygon( 3, triPt, ar.x, ar.y);
316 }
317 labelWidth += arrowSpace;
318
319 const int margin = 5; // number of pixels to reserve on either side of the label
320 int bmpWidth = 0;
321 int txtEnd = 0;
322
323 if ( params && params->m_labelBitmap.Ok() )
324 bmpWidth = params->m_labelBitmap.GetWidth() + 2;
325
326 labelWidth += bmpWidth + 2*margin;
327
328 // Draw a label if one is given
329 if ( params && !params->m_labelText.empty() )
330 {
331 wxFont font = params->m_labelFont.Ok() ?
332 params->m_labelFont : win->GetFont();
333 wxColour clr = params->m_labelColour.Ok() ?
334 params->m_labelColour : win->GetForegroundColour();
335
336 wxString label( params->m_labelText );
337
338 dc.SetFont(font);
339 dc.SetTextForeground(clr);
340 dc.SetBackgroundMode(wxTRANSPARENT);
341
342 int tw, th, td, x, y;
343 dc.GetTextExtent( label, &tw, &th, &td);
344 labelWidth += tw;
345 y = rect.y + wxMax(0, (rect.height - (th+td)) / 2);
346
347 // truncate and add an ellipsis (...) if the text is too wide.
348 int targetWidth = rect.width - arrowSpace - bmpWidth - 2*margin;
349 if ( tw > targetWidth )
350 {
351 int ellipsisWidth;
352 dc.GetTextExtent( wxT("..."), &ellipsisWidth, NULL);
353 do {
354 label.Truncate( label.length() - 1 );
355 dc.GetTextExtent( label, &tw, &th);
356 } while (tw + ellipsisWidth > targetWidth && label.length() );
357 label.append( wxT("...") );
358 tw += ellipsisWidth;
359 }
360
361 switch (params->m_labelAlignment)
362 {
363 default:
364 case wxALIGN_LEFT:
365 x = rect.x + margin;
366 break;
367 case wxALIGN_CENTER:
368 x = rect.x + wxMax(0, (rect.width - arrowSpace - tw - bmpWidth)/2);
369 break;
370 case wxALIGN_RIGHT:
371 x = rect.x + wxMax(0, rect.width - arrowSpace - margin - tw - bmpWidth);
372 break;
373 }
374
375 dc.DrawText(label, x, y);
376 txtEnd = x + tw + 2;
377 }
378
379 // draw the bitmap if there is one
380 if ( params && params->m_labelBitmap.Ok() )
381 {
382 int w, h, x, y;
383 w = params->m_labelBitmap.GetWidth();
384 h = params->m_labelBitmap.GetHeight();
385
386 y = rect.y + wxMax(1, (rect.height - h) / 2);
387
388 // if there is a text label, then put the bitmap at the end of the label
389 if ( txtEnd != 0 )
390 {
391 x = txtEnd;
392 }
393 // otherwise use the alignment flags
394 else
395 {
396 switch (params->m_labelAlignment)
397 {
398 default:
399 case wxALIGN_LEFT:
400 x = rect.x + margin;
401 break;
402 case wxALIGN_CENTER:
403 x = rect.x + wxMax(1, (rect.width - arrowSpace - w)/2);
404 break;
405 case wxALIGN_RIGHT:
406 x = rect.x + wxMax(1, rect.width - arrowSpace - margin - w);
407 break;
408 }
409 }
410 dc.DrawBitmap(params->m_labelBitmap, x, y, true);
411 }
412 return labelWidth;
413 }
414
415
416 int wxRendererGeneric::GetHeaderButtonHeight(wxWindow *win)
417 {
418 // Copied and adapted from src/generic/listctrl.cpp
419 const int HEADER_OFFSET_Y = 1;
420 const int EXTRA_HEIGHT = 4;
421
422 int w=0, h=14, d=0;
423 if (win)
424 win->GetTextExtent(wxT("Hg"), &w, &h, &d);
425
426 return h + d + 2 * HEADER_OFFSET_Y + EXTRA_HEIGHT;
427 }
428
429
430 // draw the plus or minus sign
431 void
432 wxRendererGeneric::DrawTreeItemButton(wxWindow * WXUNUSED(win),
433 wxDC& dc,
434 const wxRect& rect,
435 int flags)
436 {
437 // store settings
438 wxDCPenChanger penChanger(dc, *wxGREY_PEN);
439 wxDCBrushChanger brushChanger(dc, *wxWHITE_BRUSH);
440
441 dc.DrawRectangle(rect);
442
443 // black lines
444 const wxCoord xMiddle = rect.x + rect.width/2;
445 const wxCoord yMiddle = rect.y + rect.height/2;
446
447 // half of the length of the horz lines in "-" and "+"
448 const wxCoord halfWidth = rect.width/2 - 2;
449 dc.SetPen(*wxBLACK_PEN);
450 dc.DrawLine(xMiddle - halfWidth, yMiddle,
451 xMiddle + halfWidth + 1, yMiddle);
452
453 if ( !(flags & wxCONTROL_EXPANDED) )
454 {
455 // turn "-" into "+"
456 const wxCoord halfHeight = rect.height/2 - 2;
457 dc.DrawLine(xMiddle, yMiddle - halfHeight,
458 xMiddle, yMiddle + halfHeight + 1);
459 }
460 }
461
462 // ----------------------------------------------------------------------------
463 // sash drawing
464 // ----------------------------------------------------------------------------
465
466 wxSplitterRenderParams
467 wxRendererGeneric::GetSplitterParams(const wxWindow *win)
468 {
469 // see below
470 wxCoord sashWidth,
471 border;
472
473 if ( win->HasFlag(wxSP_3DSASH) )
474 sashWidth = 7;
475 else if ( win->HasFlag(wxSP_NOSASH) )
476 sashWidth = 0;
477 else // no 3D effect
478 sashWidth = 3;
479
480 if ( win->HasFlag(wxSP_3DBORDER) )
481 border = 2;
482 else // no 3D effect
483 border = 0;
484
485 return wxSplitterRenderParams(sashWidth, border, false);
486 }
487
488 void
489 wxRendererGeneric::DrawSplitterBorder(wxWindow *win,
490 wxDC& dc,
491 const wxRect& rectOrig,
492 int WXUNUSED(falgs))
493 {
494 if ( win->HasFlag(wxSP_3DBORDER) )
495 {
496 wxRect rect = rectOrig;
497 DrawShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
498 DrawShadedRect(dc, &rect, m_penBlack, m_penLightGrey);
499 }
500 }
501
502 void
503 wxRendererGeneric::DrawSplitterSash(wxWindow *win,
504 wxDC& dcReal,
505 const wxSize& sizeReal,
506 wxCoord position,
507 wxOrientation orient,
508 int WXUNUSED(flags))
509 {
510 // to avoid duplicating the same code for horizontal and vertical sashes,
511 // simply mirror the DC instead if needed (i.e. if horz splitter)
512 wxMirrorDC dc(dcReal, orient != wxVERTICAL);
513 wxSize size = dc.Reflect(sizeReal);
514
515
516 // we draw a Win32-like grey sash with possible 3D border here:
517 //
518 // ---- this is position
519 // /
520 // v
521 // dWGGGDd
522 // GWGGGDB
523 // GWGGGDB where G is light grey (face)
524 // GWGGGDB W white (light)
525 // GWGGGDB D dark grey (shadow)
526 // GWGGGDB B black (dark shadow)
527 // GWGGGDB
528 // GWGGGDB and lower letters are our border (already drawn)
529 // GWGGGDB
530 // wWGGGDd
531 //
532 // only the middle 3 columns are drawn unless wxSP_3D is specified
533
534 const wxCoord h = size.y;
535 wxCoord offset = 0;
536
537 // If we're drawing the border, draw the sash 3d lines shorter
538 if ( win->HasFlag(wxSP_3DBORDER) )
539 {
540 offset = 1;
541 }
542
543 dc.SetPen(*wxTRANSPARENT_PEN);
544 dc.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)));
545
546 if ( win->HasFlag(wxSP_3DSASH) )
547 {
548 // Draw the 3D sash
549 dc.DrawRectangle(position + 2, 0, 3, h);
550
551 dc.SetPen(m_penLightGrey);
552 dc.DrawLine(position, offset, position, h - offset);
553
554 dc.SetPen(m_penHighlight);
555 dc.DrawLine(position + 1, 0, position + 1, h);
556
557 dc.SetPen(m_penDarkGrey);
558 dc.DrawLine(position + 5, 0, position + 5, h);
559
560 dc.SetPen(m_penBlack);
561 dc.DrawLine(position + 6, offset, position + 6, h - offset);
562 }
563 else
564 {
565 // Draw a flat sash
566 dc.DrawRectangle(position, 0, 3, h);
567 }
568 }
569
570 // ----------------------------------------------------------------------------
571 // button drawing
572 // ----------------------------------------------------------------------------
573
574 void
575 wxRendererGeneric::DrawComboBoxDropButton(wxWindow *win,
576 wxDC& dc,
577 const wxRect& rect,
578 int flags)
579 {
580 DrawPushButton(win,dc,rect,flags);
581 DrawDropArrow(win,dc,rect,flags);
582 }
583
584 void
585 wxRendererGeneric::DrawDropArrow(wxWindow *win,
586 wxDC& dc,
587 const wxRect& rect,
588 int WXUNUSED(flags))
589 {
590 // This generic implementation should be good
591 // enough for Windows platforms (including XP).
592
593 int arrowHalf = rect.width/5;
594 int rectMid = rect.width / 2;
595 int arrowTopY = (rect.height/2) - (arrowHalf/2);
596
597 // This should always result in arrow with odd width.
598 wxPoint pt[] =
599 {
600 wxPoint(rectMid - arrowHalf, arrowTopY),
601 wxPoint(rectMid + arrowHalf, arrowTopY),
602 wxPoint(rectMid, arrowTopY + arrowHalf)
603 };
604 dc.SetBrush(wxBrush(win->GetForegroundColour()));
605 dc.SetPen(wxPen(win->GetForegroundColour()));
606 dc.DrawPolygon(WXSIZEOF(pt), pt, rect.x, rect.y);
607 }
608
609 void
610 wxRendererGeneric::DrawCheckBox(wxWindow *WXUNUSED(win),
611 wxDC& dc,
612 const wxRect& rect,
613 int flags)
614 {
615 dc.SetPen(*(flags & wxCONTROL_DISABLED ? wxGREY_PEN : wxBLACK_PEN));
616 dc.SetBrush( *wxTRANSPARENT_BRUSH );
617 dc.DrawRectangle(rect);
618
619 if ( flags & wxCONTROL_CHECKED )
620 {
621 dc.DrawCheckMark(rect.Deflate(2, 2));
622 }
623 }
624
625 void
626 wxRendererGeneric::DrawPushButton(wxWindow *win,
627 wxDC& dc,
628 const wxRect& rect,
629 int flags)
630 {
631 // Don't try anything too fancy. It'll just turn out looking
632 // out-of-place on most platforms.
633 wxColour bgCol = flags & wxCONTROL_DISABLED ?
634 wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE) :
635 win->GetBackgroundColour();
636 dc.SetBrush(wxBrush(bgCol));
637 dc.SetPen(wxPen(bgCol));
638 dc.DrawRectangle(rect);
639 }
640
641 void
642 #ifdef __WXMAC__
643 wxRendererGeneric::DrawItemSelectionRect(wxWindow * win,
644 wxDC& dc,
645 const wxRect& rect,
646 int flags)
647 #else
648 wxRendererGeneric::DrawItemSelectionRect(wxWindow * WXUNUSED(win),
649 wxDC& dc,
650 const wxRect& rect,
651 int flags)
652 #endif
653 {
654 wxBrush brush;
655 if ( flags & wxCONTROL_SELECTED )
656 {
657 if ( flags & wxCONTROL_FOCUSED )
658 {
659 brush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
660 }
661 else // !focused
662 {
663 brush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));
664 }
665 }
666 else // !selected
667 {
668 brush = *wxTRANSPARENT_BRUSH;
669 }
670
671 dc.SetBrush(brush);
672 if ((flags & wxCONTROL_CURRENT) && (flags & wxCONTROL_FOCUSED)
673 #ifdef __WXMAC__
674 && IsControlActive( (ControlRef)win->GetHandle() )
675 #endif
676 )
677 dc.SetPen( *wxBLACK_PEN );
678 else
679 dc.SetPen( *wxTRANSPARENT_PEN );
680
681 dc.DrawRectangle( rect );
682 }
683
684 void
685 wxRendererGeneric::DrawFocusRect(wxWindow* WXUNUSED(win), wxDC& dc, const wxRect& rect, int WXUNUSED(flags))
686 {
687 // draw the pixels manually because the "dots" in wxPen with wxDOT style
688 // may be short traits and not really dots
689 //
690 // note that to behave in the same manner as DrawRect(), we must exclude
691 // the bottom and right borders from the rectangle
692 wxCoord x1 = rect.GetLeft(),
693 y1 = rect.GetTop(),
694 x2 = rect.GetRight(),
695 y2 = rect.GetBottom();
696
697 dc.SetPen(m_penBlack);
698
699 #ifdef __WXMAC__
700 dc.SetLogicalFunction(wxCOPY);
701 #else
702 // this seems to be closer than what Windows does than wxINVERT although
703 // I'm still not sure if it's correct
704 dc.SetLogicalFunction(wxAND_REVERSE);
705 #endif
706
707 wxCoord z;
708 for ( z = x1 + 1; z < x2; z += 2 )
709 dc.DrawPoint(z, rect.GetTop());
710
711 wxCoord shift = z == x2 ? 0 : 1;
712 for ( z = y1 + shift; z < y2; z += 2 )
713 dc.DrawPoint(x2, z);
714
715 shift = z == y2 ? 0 : 1;
716 for ( z = x2 - shift; z > x1; z -= 2 )
717 dc.DrawPoint(z, y2);
718
719 shift = z == x1 ? 0 : 1;
720 for ( z = y2 - shift; z > y1; z -= 2 )
721 dc.DrawPoint(x1, z);
722
723 dc.SetLogicalFunction(wxCOPY);
724 }
725
726 // ----------------------------------------------------------------------------
727 // A module to allow cleanup of generic renderer.
728 // ----------------------------------------------------------------------------
729
730 class wxGenericRendererModule: public wxModule
731 {
732 DECLARE_DYNAMIC_CLASS(wxGenericRendererModule)
733 public:
734 wxGenericRendererModule() {}
735 bool OnInit() { return true; }
736 void OnExit() { wxRendererGeneric::Cleanup(); }
737 };
738
739 IMPLEMENT_DYNAMIC_CLASS(wxGenericRendererModule, wxModule)