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