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