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