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