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