]>
Commit | Line | Data |
---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | |
2 | // Name: src/univ/themes/mono.cpp | |
3 | // Purpose: wxUniversal theme for monochrome displays | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 2006-08-27 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 2006 REA Elektronik GmbH | |
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/univ/theme.h" | |
28 | ||
29 | #if wxUSE_THEME_MONO | |
30 | ||
31 | #ifndef WX_PRECOMP | |
32 | #include "wx/dc.h" | |
33 | #endif // WX_PRECOMP | |
34 | ||
35 | #include "wx/artprov.h" | |
36 | #include "wx/univ/stdrend.h" | |
37 | #include "wx/univ/inphand.h" | |
38 | #include "wx/univ/colschem.h" | |
39 | ||
40 | class wxMonoColourScheme; | |
41 | ||
42 | #define wxMONO_BG_COL (*wxWHITE) | |
43 | #define wxMONO_FG_COL (*wxBLACK) | |
44 | ||
45 | // ---------------------------------------------------------------------------- | |
46 | // wxMonoRenderer: draw the GUI elements in simplest possible way | |
47 | // ---------------------------------------------------------------------------- | |
48 | ||
49 | // Warning: many of the methods here are not implemented, the code won't work | |
50 | // if any but a few wxUSE_XXXs are on | |
51 | class wxMonoRenderer : public wxStdRenderer | |
52 | { | |
53 | public: | |
54 | wxMonoRenderer(const wxColourScheme *scheme); | |
55 | ||
56 | virtual void DrawButtonLabel(wxDC& dc, | |
57 | const wxString& label, | |
58 | const wxBitmap& image, | |
59 | const wxRect& rect, | |
60 | int flags = 0, | |
61 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
62 | int indexAccel = -1, | |
63 | wxRect *rectBounds = NULL); | |
64 | ||
65 | virtual void DrawFocusRect(wxDC& dc, const wxRect& rect, int flags = 0); | |
66 | ||
67 | virtual void DrawButtonBorder(wxDC& dc, | |
68 | const wxRect& rect, | |
69 | int flags = 0, | |
70 | wxRect *rectIn = NULL); | |
71 | ||
72 | virtual void DrawHorizontalLine(wxDC& dc, | |
73 | wxCoord y, wxCoord x1, wxCoord x2); | |
74 | ||
75 | virtual void DrawVerticalLine(wxDC& dc, | |
76 | wxCoord x, wxCoord y1, wxCoord y2); | |
77 | ||
78 | virtual void DrawArrow(wxDC& dc, | |
79 | wxDirection dir, | |
80 | const wxRect& rect, | |
81 | int flags = 0); | |
82 | virtual void DrawScrollbarThumb(wxDC& dc, | |
83 | wxOrientation orient, | |
84 | const wxRect& rect, | |
85 | int flags = 0); | |
86 | virtual void DrawScrollbarShaft(wxDC& dc, | |
87 | wxOrientation orient, | |
88 | const wxRect& rect, | |
89 | int flags = 0); | |
90 | ||
91 | #if wxUSE_TOOLBAR | |
92 | virtual void DrawToolBarButton(wxDC& dc, | |
93 | const wxString& label, | |
94 | const wxBitmap& bitmap, | |
95 | const wxRect& rect, | |
96 | int flags = 0, | |
97 | long style = 0, | |
98 | int tbarStyle = 0); | |
99 | #endif // wxUSE_TOOLBAR | |
100 | ||
101 | #if wxUSE_NOTEBOOK | |
102 | virtual void DrawTab(wxDC& dc, | |
103 | const wxRect& rect, | |
104 | wxDirection dir, | |
105 | const wxString& label, | |
106 | const wxBitmap& bitmap = wxNullBitmap, | |
107 | int flags = 0, | |
108 | int indexAccel = -1); | |
109 | #endif // wxUSE_NOTEBOOK | |
110 | ||
111 | #if wxUSE_SLIDER | |
112 | virtual void DrawSliderShaft(wxDC& dc, | |
113 | const wxRect& rect, | |
114 | int lenThumb, | |
115 | wxOrientation orient, | |
116 | int flags = 0, | |
117 | long style = 0, | |
118 | wxRect *rectShaft = NULL); | |
119 | ||
120 | virtual void DrawSliderThumb(wxDC& dc, | |
121 | const wxRect& rect, | |
122 | wxOrientation orient, | |
123 | int flags = 0, | |
124 | long style = 0); | |
125 | ||
126 | virtual void DrawSliderTicks(wxDC& dc, | |
127 | const wxRect& rect, | |
128 | int lenThumb, | |
129 | wxOrientation orient, | |
130 | int start, | |
131 | int end, | |
132 | int step = 1, | |
133 | int flags = 0, | |
134 | long style = 0); | |
135 | #endif // wxUSE_SLIDER | |
136 | ||
137 | #if wxUSE_MENUS | |
138 | virtual void DrawMenuBarItem(wxDC& dc, | |
139 | const wxRect& rect, | |
140 | const wxString& label, | |
141 | int flags = 0, | |
142 | int indexAccel = -1); | |
143 | ||
144 | virtual void DrawMenuItem(wxDC& dc, | |
145 | wxCoord y, | |
146 | const wxMenuGeometryInfo& geometryInfo, | |
147 | const wxString& label, | |
148 | const wxString& accel, | |
149 | const wxBitmap& bitmap = wxNullBitmap, | |
150 | int flags = 0, | |
151 | int indexAccel = -1); | |
152 | ||
153 | virtual void DrawMenuSeparator(wxDC& dc, | |
154 | wxCoord y, | |
155 | const wxMenuGeometryInfo& geomInfo); | |
156 | #endif // wxUSE_MENUS | |
157 | ||
158 | #if wxUSE_COMBOBOX | |
159 | virtual void GetComboBitmaps(wxBitmap *bmpNormal, | |
160 | wxBitmap *bmpFocus, | |
161 | wxBitmap *bmpPressed, | |
162 | wxBitmap *bmpDisabled); | |
163 | #endif // wxUSE_COMBOBOX | |
164 | ||
165 | ||
166 | virtual wxRect GetBorderDimensions(wxBorder border) const; | |
167 | ||
168 | #if wxUSE_SCROLLBAR | |
169 | virtual wxSize GetScrollbarArrowSize() const { return GetStdBmpSize(); } | |
170 | #endif // wxUSE_SCROLLBAR | |
171 | ||
172 | virtual wxSize GetCheckBitmapSize() const { return GetStdBmpSize(); } | |
173 | virtual wxSize GetRadioBitmapSize() const { return GetStdBmpSize(); } | |
174 | ||
175 | #if wxUSE_TOOLBAR | |
176 | virtual wxSize GetToolBarButtonSize(wxCoord *separator) const; | |
177 | ||
178 | virtual wxSize GetToolBarMargin() const; | |
179 | #endif // wxUSE_TOOLBAR | |
180 | ||
181 | #if wxUSE_NOTEBOOK | |
182 | virtual wxSize GetTabIndent() const; | |
183 | ||
184 | virtual wxSize GetTabPadding() const; | |
185 | #endif // wxUSE_NOTEBOOK | |
186 | ||
187 | #if wxUSE_SLIDER | |
188 | virtual wxCoord GetSliderDim() const; | |
189 | ||
190 | virtual wxCoord GetSliderTickLen() const; | |
191 | ||
192 | virtual wxRect GetSliderShaftRect(const wxRect& rect, | |
193 | int lenThumb, | |
194 | wxOrientation orient, | |
195 | long style = 0) const; | |
196 | ||
197 | virtual wxSize GetSliderThumbSize(const wxRect& rect, | |
198 | int lenThumb, | |
199 | wxOrientation orient) const; | |
200 | #endif // wxUSE_SLIDER | |
201 | ||
202 | virtual wxSize GetProgressBarStep() const; | |
203 | ||
204 | #if wxUSE_MENUS | |
205 | virtual wxSize GetMenuBarItemSize(const wxSize& sizeText) const; | |
206 | ||
207 | virtual wxMenuGeometryInfo *GetMenuGeometry(wxWindow *win, | |
208 | const wxMenu& menu) const; | |
209 | #endif // wxUSE_MENUS | |
210 | ||
211 | #if wxUSE_STATUSBAR | |
212 | virtual wxCoord GetStatusBarBorderBetweenFields() const; | |
213 | ||
214 | virtual wxSize GetStatusBarFieldMargins() const; | |
215 | #endif // wxUSE_STATUSBAR | |
216 | ||
217 | protected: | |
218 | // override base class border drawing routines: we always draw just a | |
219 | // single simple border | |
220 | void DrawSimpleBorder(wxDC& dc, wxRect *rect) | |
221 | { DrawRect(dc, rect, m_penFg); } | |
222 | ||
223 | virtual void DrawRaisedBorder(wxDC& dc, wxRect *rect) | |
224 | { DrawSimpleBorder(dc, rect); } | |
225 | virtual void DrawSunkenBorder(wxDC& dc, wxRect *rect) | |
226 | { DrawSimpleBorder(dc, rect); } | |
227 | virtual void DrawAntiSunkenBorder(wxDC& dc, wxRect *rect) | |
228 | { DrawSimpleBorder(dc, rect); } | |
229 | virtual void DrawBoxBorder(wxDC& dc, wxRect *rect) | |
230 | { DrawSimpleBorder(dc, rect); } | |
231 | virtual void DrawStaticBorder(wxDC& dc, wxRect *rect) | |
232 | { DrawSimpleBorder(dc, rect); } | |
233 | virtual void DrawExtraBorder(wxDC& WXUNUSED(dc), wxRect * WXUNUSED(rect)) | |
234 | { /* no extra borders for us */ } | |
235 | ||
236 | // all our XPMs are of this size | |
237 | static wxSize GetStdBmpSize() { return wxSize(8, 8); } | |
238 | ||
239 | wxBitmap GetIndicator(IndicatorType indType, int flags); | |
240 | virtual wxBitmap GetCheckBitmap(int flags) | |
241 | { return GetIndicator(IndicatorType_Check, flags); } | |
242 | virtual wxBitmap GetRadioBitmap(int flags) | |
243 | { return GetIndicator(IndicatorType_Radio, flags); } | |
244 | ||
245 | virtual wxBitmap GetFrameButtonBitmap(FrameButtonType type); | |
246 | virtual int GetFrameBorderWidth(int flags) const; | |
247 | ||
248 | private: | |
249 | // the bitmaps returned by GetIndicator() | |
250 | wxBitmap m_bmpIndicators[IndicatorType_MaxCtrl] | |
251 | [IndicatorState_MaxCtrl] | |
252 | [IndicatorStatus_Max]; | |
253 | ||
254 | static const char **ms_xpmIndicators[IndicatorType_MaxCtrl] | |
255 | [IndicatorState_MaxCtrl] | |
256 | [IndicatorStatus_Max]; | |
257 | ||
258 | // the arrow bitmaps used by DrawArrow() | |
259 | wxBitmap m_bmpArrows[Arrow_Max]; | |
260 | ||
261 | static const char **ms_xpmArrows[Arrow_Max]; | |
262 | ||
263 | // the close bitmap for the frame for GetFrameButtonBitmap() | |
264 | wxBitmap m_bmpFrameClose; | |
265 | ||
266 | // pen used for foreground drawing | |
267 | wxPen m_penFg; | |
268 | }; | |
269 | ||
270 | // ---------------------------------------------------------------------------- | |
271 | // standard bitmaps | |
272 | // ---------------------------------------------------------------------------- | |
273 | ||
274 | static const char *xpmUnchecked[] = { | |
275 | /* columns rows colors chars-per-pixel */ | |
276 | "8 8 2 1", | |
277 | " c white", | |
278 | "X c black", | |
279 | /* pixels */ | |
280 | "XXXXXXXX", | |
281 | "X X", | |
282 | "X X", | |
283 | "X X", | |
284 | "X X", | |
285 | "X X", | |
286 | "X X", | |
287 | "XXXXXXXX", | |
288 | }; | |
289 | ||
290 | static const char *xpmChecked[] = { | |
291 | /* columns rows colors chars-per-pixel */ | |
292 | "8 8 2 1", | |
293 | " c white", | |
294 | "X c black", | |
295 | /* pixels */ | |
296 | "XXXXXXXX", | |
297 | "X X", | |
298 | "X X X X", | |
299 | "X XX X", | |
300 | "X XX X", | |
301 | "X X X X", | |
302 | "X X", | |
303 | "XXXXXXXX", | |
304 | }; | |
305 | ||
306 | static const char *xpmUndeterminate[] = { | |
307 | /* columns rows colors chars-per-pixel */ | |
308 | "8 8 2 1", | |
309 | " c white", | |
310 | "X c black", | |
311 | /* pixels */ | |
312 | "XXXXXXXX", | |
313 | "X X X XX", | |
314 | "XX X X X", | |
315 | "X X X XX", | |
316 | "XX X X X", | |
317 | "X X X XX", | |
318 | "XX X X X", | |
319 | "XXXXXXXX", | |
320 | }; | |
321 | ||
322 | static const char *xpmRadioUnchecked[] = { | |
323 | /* columns rows colors chars-per-pixel */ | |
324 | "8 8 2 1", | |
325 | " c white", | |
326 | "X c black", | |
327 | /* pixels */ | |
328 | "XXXXXXXX", | |
329 | "X X", | |
330 | "X XX X", | |
331 | "X X X X", | |
332 | "X X X X", | |
333 | "X XX X", | |
334 | "X X", | |
335 | "XXXXXXXX", | |
336 | }; | |
337 | ||
338 | static const char *xpmRadioChecked[] = { | |
339 | /* columns rows colors chars-per-pixel */ | |
340 | "8 8 2 1", | |
341 | " c white", | |
342 | "X c black", | |
343 | /* pixels */ | |
344 | "XXXXXXXX", | |
345 | "X X", | |
346 | "X XX X", | |
347 | "X XXXX X", | |
348 | "X XXXX X", | |
349 | "X XX X", | |
350 | "X X", | |
351 | "XXXXXXXX", | |
352 | }; | |
353 | ||
354 | const char **wxMonoRenderer::ms_xpmIndicators[IndicatorType_MaxCtrl] | |
355 | [IndicatorState_MaxCtrl] | |
356 | [IndicatorStatus_Max] = | |
357 | { | |
358 | // checkboxes first | |
359 | { | |
360 | // normal state | |
361 | { xpmChecked, xpmUnchecked, xpmUndeterminate }, | |
362 | ||
363 | // pressed state | |
364 | { xpmUndeterminate, xpmUndeterminate, xpmUndeterminate }, | |
365 | ||
366 | // disabled state | |
367 | { xpmUndeterminate, xpmUndeterminate, xpmUndeterminate }, | |
368 | }, | |
369 | ||
370 | // radio | |
371 | { | |
372 | // normal state | |
373 | { xpmRadioChecked, xpmRadioUnchecked, xpmUndeterminate }, | |
374 | ||
375 | // pressed state | |
376 | { xpmUndeterminate, xpmUndeterminate, xpmUndeterminate }, | |
377 | ||
378 | // disabled state | |
379 | { xpmUndeterminate, xpmUndeterminate, xpmUndeterminate }, | |
380 | }, | |
381 | }; | |
382 | ||
383 | static const char *xpmLeftArrow[] = { | |
384 | /* columns rows colors chars-per-pixel */ | |
385 | "8 8 2 1", | |
386 | " c white", | |
387 | "X c black", | |
388 | /* pixels */ | |
389 | " X ", | |
390 | " XX ", | |
391 | " XXX ", | |
392 | "XXXX ", | |
393 | "XXXX ", | |
394 | " XXX ", | |
395 | " XX ", | |
396 | " X ", | |
397 | }; | |
398 | ||
399 | static const char *xpmRightArrow[] = { | |
400 | /* columns rows colors chars-per-pixel */ | |
401 | "8 8 2 1", | |
402 | " c white", | |
403 | "X c black", | |
404 | /* pixels */ | |
405 | " X ", | |
406 | " XX ", | |
407 | " XXX ", | |
408 | " XXXX", | |
409 | " XXXX", | |
410 | " XXX ", | |
411 | " XX ", | |
412 | " X ", | |
413 | }; | |
414 | ||
415 | static const char *xpmUpArrow[] = { | |
416 | /* columns rows colors chars-per-pixel */ | |
417 | "8 8 2 1", | |
418 | " c white", | |
419 | "X c black", | |
420 | /* pixels */ | |
421 | " ", | |
422 | " XX ", | |
423 | " XXXX ", | |
424 | " XXXXXX ", | |
425 | "XXXXXXXX", | |
426 | " ", | |
427 | " ", | |
428 | " ", | |
429 | }; | |
430 | ||
431 | static const char *xpmDownArrow[] = { | |
432 | /* columns rows colors chars-per-pixel */ | |
433 | "8 8 2 1", | |
434 | " c white", | |
435 | "X c black", | |
436 | /* pixels */ | |
437 | " ", | |
438 | " ", | |
439 | " ", | |
440 | "XXXXXXXX", | |
441 | " XXXXXX ", | |
442 | " XXXX ", | |
443 | " XX ", | |
444 | " ", | |
445 | }; | |
446 | ||
447 | const char **wxMonoRenderer::ms_xpmArrows[Arrow_Max] = | |
448 | { | |
449 | xpmLeftArrow, xpmRightArrow, xpmUpArrow, xpmDownArrow, | |
450 | }; | |
451 | ||
452 | // ---------------------------------------------------------------------------- | |
453 | // wxMonoColourScheme: uses just white and black | |
454 | // ---------------------------------------------------------------------------- | |
455 | ||
456 | class wxMonoColourScheme : public wxColourScheme | |
457 | { | |
458 | public: | |
459 | // we use only 2 colours, white and black, but we avoid referring to them | |
460 | // like this, instead use the functions below | |
461 | wxColour GetFg() const { return wxMONO_FG_COL; } | |
462 | wxColour GetBg() const { return wxMONO_BG_COL; } | |
463 | ||
464 | // implement base class pure virtuals | |
465 | virtual wxColour Get(StdColour col) const; | |
466 | virtual wxColour GetBackground(wxWindow *win) const; | |
467 | }; | |
468 | ||
469 | // ---------------------------------------------------------------------------- | |
470 | // wxMonoArtProvider | |
471 | // ---------------------------------------------------------------------------- | |
472 | ||
473 | class wxMonoArtProvider : public wxArtProvider | |
474 | { | |
475 | protected: | |
476 | virtual wxBitmap CreateBitmap(const wxArtID& id, | |
477 | const wxArtClient& client, | |
478 | const wxSize& size); | |
479 | }; | |
480 | ||
481 | // ---------------------------------------------------------------------------- | |
482 | // wxMonoTheme | |
483 | // ---------------------------------------------------------------------------- | |
484 | ||
485 | class wxMonoTheme : public wxTheme | |
486 | { | |
487 | public: | |
488 | wxMonoTheme(); | |
489 | virtual ~wxMonoTheme(); | |
490 | ||
491 | virtual wxRenderer *GetRenderer(); | |
492 | virtual wxArtProvider *GetArtProvider(); | |
493 | virtual wxInputHandler *GetInputHandler(const wxString& control, | |
494 | wxInputConsumer *consumer); | |
495 | virtual wxColourScheme *GetColourScheme(); | |
496 | ||
497 | private: | |
498 | wxMonoRenderer *m_renderer; | |
499 | wxMonoArtProvider *m_artProvider; | |
500 | wxMonoColourScheme *m_scheme; | |
501 | ||
502 | WX_DECLARE_THEME(mono) | |
503 | }; | |
504 | ||
505 | // ============================================================================ | |
506 | // implementation | |
507 | // ============================================================================ | |
508 | ||
509 | WX_IMPLEMENT_THEME(wxMonoTheme, mono, wxTRANSLATE("Simple monochrome theme")); | |
510 | ||
511 | // ---------------------------------------------------------------------------- | |
512 | // wxMonoTheme | |
513 | // ---------------------------------------------------------------------------- | |
514 | ||
515 | wxMonoTheme::wxMonoTheme() | |
516 | { | |
517 | m_scheme = NULL; | |
518 | m_renderer = NULL; | |
519 | m_artProvider = NULL; | |
520 | } | |
521 | ||
522 | wxMonoTheme::~wxMonoTheme() | |
523 | { | |
524 | delete m_renderer; | |
525 | delete m_scheme; | |
526 | delete m_artProvider; | |
527 | } | |
528 | ||
529 | wxRenderer *wxMonoTheme::GetRenderer() | |
530 | { | |
531 | if ( !m_renderer ) | |
532 | { | |
533 | m_renderer = new wxMonoRenderer(GetColourScheme()); | |
534 | } | |
535 | ||
536 | return m_renderer; | |
537 | } | |
538 | ||
539 | wxArtProvider *wxMonoTheme::GetArtProvider() | |
540 | { | |
541 | if ( !m_artProvider ) | |
542 | { | |
543 | m_artProvider = new wxMonoArtProvider; | |
544 | } | |
545 | ||
546 | return m_artProvider; | |
547 | } | |
548 | ||
549 | wxColourScheme *wxMonoTheme::GetColourScheme() | |
550 | { | |
551 | if ( !m_scheme ) | |
552 | { | |
553 | m_scheme = new wxMonoColourScheme; | |
554 | } | |
555 | ||
556 | return m_scheme; | |
557 | } | |
558 | ||
559 | wxInputHandler *wxMonoTheme::GetInputHandler(const wxString& WXUNUSED(control), | |
560 | wxInputConsumer *consumer) | |
561 | { | |
562 | // no special input handlers so far | |
563 | return consumer->DoGetStdInputHandler(NULL); | |
564 | } | |
565 | ||
566 | // ============================================================================ | |
567 | // wxMonoColourScheme | |
568 | // ============================================================================ | |
569 | ||
570 | wxColour wxMonoColourScheme::GetBackground(wxWindow *win) const | |
571 | { | |
572 | wxColour col; | |
573 | if ( win->UseBgCol() ) | |
574 | { | |
575 | // use the user specified colour | |
576 | col = win->GetBackgroundColour(); | |
577 | } | |
578 | ||
579 | // doesn't depend on the state | |
580 | if ( !col.Ok() ) | |
581 | { | |
582 | col = GetBg(); | |
583 | } | |
584 | ||
585 | return col; | |
586 | } | |
587 | ||
588 | wxColour wxMonoColourScheme::Get(wxMonoColourScheme::StdColour col) const | |
589 | { | |
590 | switch ( col ) | |
591 | { | |
592 | case WINDOW: | |
593 | case CONTROL: | |
594 | case CONTROL_PRESSED: | |
595 | case CONTROL_CURRENT: | |
596 | case SCROLLBAR: | |
597 | case SCROLLBAR_PRESSED: | |
598 | case GAUGE: | |
599 | case TITLEBAR: | |
600 | case TITLEBAR_ACTIVE: | |
601 | case HIGHLIGHT_TEXT: | |
602 | case DESKTOP: | |
603 | case FRAME: | |
604 | return GetBg(); | |
605 | ||
606 | case MAX: | |
607 | default: | |
608 | wxFAIL_MSG(_T("invalid standard colour")); | |
609 | // fall through | |
610 | ||
611 | case SHADOW_DARK: | |
612 | case SHADOW_HIGHLIGHT: | |
613 | case SHADOW_IN: | |
614 | case SHADOW_OUT: | |
615 | case CONTROL_TEXT: | |
616 | case CONTROL_TEXT_DISABLED: | |
617 | case CONTROL_TEXT_DISABLED_SHADOW: | |
618 | case TITLEBAR_TEXT: | |
619 | case TITLEBAR_ACTIVE_TEXT: | |
620 | case HIGHLIGHT: | |
621 | return GetFg(); | |
622 | ||
623 | } | |
624 | } | |
625 | ||
626 | // ============================================================================ | |
627 | // wxMonoRenderer | |
628 | // ============================================================================ | |
629 | ||
630 | // ---------------------------------------------------------------------------- | |
631 | // construction | |
632 | // ---------------------------------------------------------------------------- | |
633 | ||
634 | wxMonoRenderer::wxMonoRenderer(const wxColourScheme *scheme) | |
635 | : wxStdRenderer(scheme) | |
636 | { | |
637 | m_penFg = wxPen(wxMONO_FG_COL); | |
638 | } | |
639 | ||
640 | // ---------------------------------------------------------------------------- | |
641 | // borders | |
642 | // ---------------------------------------------------------------------------- | |
643 | ||
644 | wxRect wxMonoRenderer::GetBorderDimensions(wxBorder border) const | |
645 | { | |
646 | wxCoord width; | |
647 | switch ( border ) | |
648 | { | |
649 | case wxBORDER_SIMPLE: | |
650 | case wxBORDER_STATIC: | |
651 | case wxBORDER_RAISED: | |
652 | case wxBORDER_SUNKEN: | |
653 | width = 1; | |
654 | break; | |
655 | ||
656 | case wxBORDER_DOUBLE: | |
657 | width = 2; | |
658 | break; | |
659 | ||
660 | default: | |
661 | wxFAIL_MSG(_T("unknown border type")); | |
662 | // fall through | |
663 | ||
664 | case wxBORDER_DEFAULT: | |
665 | case wxBORDER_NONE: | |
666 | width = 0; | |
667 | break; | |
668 | } | |
669 | ||
670 | wxRect rect; | |
671 | rect.x = | |
672 | rect.y = | |
673 | rect.width = | |
674 | rect.height = width; | |
675 | ||
676 | return rect; | |
677 | } | |
678 | ||
679 | void wxMonoRenderer::DrawButtonBorder(wxDC& dc, | |
680 | const wxRect& rect, | |
681 | int flags, | |
682 | wxRect *rectIn) | |
683 | { | |
684 | DrawBorder(dc, wxBORDER_SIMPLE, rect, flags, rectIn); | |
685 | } | |
686 | ||
687 | // ---------------------------------------------------------------------------- | |
688 | // lines and frames | |
689 | // ---------------------------------------------------------------------------- | |
690 | ||
691 | void | |
692 | wxMonoRenderer::DrawHorizontalLine(wxDC& dc, wxCoord y, wxCoord x1, wxCoord x2) | |
693 | { | |
694 | dc.SetPen(m_penFg); | |
695 | dc.DrawLine(x1, y, x2 + 1, y); | |
696 | } | |
697 | ||
698 | void | |
699 | wxMonoRenderer::DrawVerticalLine(wxDC& dc, wxCoord x, wxCoord y1, wxCoord y2) | |
700 | { | |
701 | dc.SetPen(m_penFg); | |
702 | dc.DrawLine(x, y1, x, y2 + 1); | |
703 | } | |
704 | ||
705 | void wxMonoRenderer::DrawFocusRect(wxDC& dc, const wxRect& rect, int flags) | |
706 | { | |
707 | // no need to draw the focus rect for selected items, it would be invisible | |
708 | // anyhow | |
709 | if ( !(flags & wxCONTROL_SELECTED) ) | |
710 | { | |
711 | dc.SetPen(m_penFg); | |
712 | dc.SetBrush(*wxTRANSPARENT_BRUSH); | |
713 | dc.DrawRectangle(rect); | |
714 | } | |
715 | } | |
716 | ||
717 | // ---------------------------------------------------------------------------- | |
718 | // label | |
719 | // ---------------------------------------------------------------------------- | |
720 | ||
721 | void wxMonoRenderer::DrawButtonLabel(wxDC& dc, | |
722 | const wxString& label, | |
723 | const wxBitmap& image, | |
724 | const wxRect& rect, | |
725 | int flags, | |
726 | int alignment, | |
727 | int indexAccel, | |
728 | wxRect *rectBounds) | |
729 | { | |
730 | dc.DrawLabel(label, image, rect, alignment, indexAccel, rectBounds); | |
731 | ||
732 | if ( flags & wxCONTROL_DISABLED ) | |
733 | { | |
734 | // this is ugly but I don't know how to show disabled button visually | |
735 | // in monochrome theme otherwise, so cross it out | |
736 | dc.SetPen(m_penFg); | |
737 | dc.DrawLine(rect.GetTopLeft(), rect.GetBottomRight()); | |
738 | dc.DrawLine(rect.GetTopRight(), rect.GetBottomLeft()); | |
739 | } | |
740 | } | |
741 | ||
742 | // ---------------------------------------------------------------------------- | |
743 | // bitmaps | |
744 | // ---------------------------------------------------------------------------- | |
745 | ||
746 | wxBitmap wxMonoRenderer::GetIndicator(IndicatorType indType, int flags) | |
747 | { | |
748 | IndicatorState indState; | |
749 | IndicatorStatus indStatus; | |
750 | GetIndicatorsFromFlags(flags, indState, indStatus); | |
751 | ||
752 | wxBitmap& bmp = m_bmpIndicators[indType][indState][indStatus]; | |
753 | if ( !bmp.Ok() ) | |
754 | { | |
755 | const char **xpm = ms_xpmIndicators[indType][indState][indStatus]; | |
756 | if ( xpm ) | |
757 | { | |
758 | // create and cache it | |
759 | bmp = wxBitmap(xpm); | |
760 | } | |
761 | } | |
762 | ||
763 | return bmp; | |
764 | } | |
765 | ||
766 | wxBitmap wxMonoRenderer::GetFrameButtonBitmap(FrameButtonType type) | |
767 | { | |
768 | if ( type == FrameButton_Close ) | |
769 | { | |
770 | if ( !m_bmpFrameClose.Ok() ) | |
771 | { | |
772 | static const char *xpmFrameClose[] = { | |
773 | /* columns rows colors chars-per-pixel */ | |
774 | "8 8 2 1", | |
775 | " c white", | |
776 | "X c black", | |
777 | /* pixels */ | |
778 | " ", | |
779 | " XX XX ", | |
780 | " X X ", | |
781 | " XX ", | |
782 | " XX ", | |
783 | " X X ", | |
784 | " XX XX ", | |
785 | " ", | |
786 | }; | |
787 | ||
788 | m_bmpFrameClose = wxBitmap(xpmFrameClose); | |
789 | } | |
790 | ||
791 | return m_bmpFrameClose; | |
792 | } | |
793 | ||
794 | // we don't show any other buttons than close | |
795 | return wxNullBitmap; | |
796 | } | |
797 | ||
798 | // ---------------------------------------------------------------------------- | |
799 | // toolbar | |
800 | // ---------------------------------------------------------------------------- | |
801 | ||
802 | #if wxUSE_TOOLBAR | |
803 | ||
804 | void wxMonoRenderer::DrawToolBarButton(wxDC& WXUNUSED(dc), | |
805 | const wxString& WXUNUSED(label), | |
806 | const wxBitmap& WXUNUSED(bitmap), | |
807 | const wxRect& WXUNUSED(rect), | |
808 | int WXUNUSED(flags), | |
809 | long WXUNUSED(style), | |
810 | int WXUNUSED(tbarStyle)) | |
811 | { | |
812 | wxFAIL_MSG(_T("TODO")); | |
813 | } | |
814 | ||
815 | wxSize wxMonoRenderer::GetToolBarButtonSize(wxCoord *WXUNUSED(separator)) const | |
816 | { | |
817 | wxFAIL_MSG(_T("TODO")); | |
818 | ||
819 | return wxSize(); | |
820 | } | |
821 | ||
822 | wxSize wxMonoRenderer::GetToolBarMargin() const | |
823 | { | |
824 | wxFAIL_MSG(_T("TODO")); | |
825 | ||
826 | return wxSize(); | |
827 | } | |
828 | ||
829 | #endif // wxUSE_TOOLBAR | |
830 | ||
831 | // ---------------------------------------------------------------------------- | |
832 | // notebook | |
833 | // ---------------------------------------------------------------------------- | |
834 | ||
835 | #if wxUSE_NOTEBOOK | |
836 | ||
837 | void wxMonoRenderer::DrawTab(wxDC& WXUNUSED(dc), | |
838 | const wxRect& WXUNUSED(rect), | |
839 | wxDirection WXUNUSED(dir), | |
840 | const wxString& WXUNUSED(label), | |
841 | const wxBitmap& WXUNUSED(bitmap), | |
842 | int WXUNUSED(flags), | |
843 | int WXUNUSED(indexAccel)) | |
844 | { | |
845 | wxFAIL_MSG(_T("TODO")); | |
846 | } | |
847 | ||
848 | wxSize wxMonoRenderer::GetTabIndent() const | |
849 | { | |
850 | wxFAIL_MSG(_T("TODO")); | |
851 | ||
852 | return wxSize(); | |
853 | } | |
854 | ||
855 | wxSize wxMonoRenderer::GetTabPadding() const | |
856 | { | |
857 | wxFAIL_MSG(_T("TODO")); | |
858 | ||
859 | return wxSize(); | |
860 | } | |
861 | ||
862 | #endif // wxUSE_NOTEBOOK | |
863 | ||
864 | // ---------------------------------------------------------------------------- | |
865 | // combobox | |
866 | // ---------------------------------------------------------------------------- | |
867 | ||
868 | #if wxUSE_COMBOBOX | |
869 | ||
870 | void wxMonoRenderer::GetComboBitmaps(wxBitmap *WXUNUSED(bmpNormal), | |
871 | wxBitmap *WXUNUSED(bmpFocus), | |
872 | wxBitmap *WXUNUSED(bmpPressed), | |
873 | wxBitmap *WXUNUSED(bmpDisabled)) | |
874 | { | |
875 | wxFAIL_MSG(_T("TODO")); | |
876 | } | |
877 | ||
878 | #endif // wxUSE_COMBOBOX | |
879 | ||
880 | // ---------------------------------------------------------------------------- | |
881 | // menus | |
882 | // ---------------------------------------------------------------------------- | |
883 | ||
884 | #if wxUSE_MENUS | |
885 | ||
886 | void wxMonoRenderer::DrawMenuBarItem(wxDC& WXUNUSED(dc), | |
887 | const wxRect& WXUNUSED(rect), | |
888 | const wxString& WXUNUSED(label), | |
889 | int WXUNUSED(flags), | |
890 | int WXUNUSED(indexAccel)) | |
891 | { | |
892 | wxFAIL_MSG(_T("TODO")); | |
893 | } | |
894 | ||
895 | void wxMonoRenderer::DrawMenuItem(wxDC& WXUNUSED(dc), | |
896 | wxCoord WXUNUSED(y), | |
897 | const wxMenuGeometryInfo& WXUNUSED(geometryInfo), | |
898 | const wxString& WXUNUSED(label), | |
899 | const wxString& WXUNUSED(accel), | |
900 | const wxBitmap& WXUNUSED(bitmap), | |
901 | int WXUNUSED(flags), | |
902 | int WXUNUSED(indexAccel)) | |
903 | { | |
904 | wxFAIL_MSG(_T("TODO")); | |
905 | } | |
906 | ||
907 | void wxMonoRenderer::DrawMenuSeparator(wxDC& WXUNUSED(dc), | |
908 | wxCoord WXUNUSED(y), | |
909 | const wxMenuGeometryInfo& WXUNUSED(geomInfo)) | |
910 | { | |
911 | wxFAIL_MSG(_T("TODO")); | |
912 | } | |
913 | ||
914 | wxSize wxMonoRenderer::GetMenuBarItemSize(const wxSize& WXUNUSED(sizeText)) const | |
915 | { | |
916 | wxFAIL_MSG(_T("TODO")); | |
917 | ||
918 | return wxSize(); | |
919 | } | |
920 | ||
921 | wxMenuGeometryInfo *wxMonoRenderer::GetMenuGeometry(wxWindow *WXUNUSED(win), | |
922 | const wxMenu& WXUNUSED(menu)) const | |
923 | { | |
924 | wxFAIL_MSG(_T("TODO")); | |
925 | ||
926 | return NULL; | |
927 | } | |
928 | ||
929 | #endif // wxUSE_MENUS | |
930 | ||
931 | // ---------------------------------------------------------------------------- | |
932 | // slider | |
933 | // ---------------------------------------------------------------------------- | |
934 | ||
935 | #if wxUSE_SLIDER | |
936 | ||
937 | void wxMonoRenderer::DrawSliderShaft(wxDC& WXUNUSED(dc), | |
938 | const wxRect& WXUNUSED(rect), | |
939 | int WXUNUSED(lenThumb), | |
940 | wxOrientation WXUNUSED(orient), | |
941 | int WXUNUSED(flags), | |
942 | long WXUNUSED(style), | |
943 | wxRect *WXUNUSED(rectShaft)) | |
944 | { | |
945 | wxFAIL_MSG(_T("TODO")); | |
946 | } | |
947 | ||
948 | ||
949 | void wxMonoRenderer::DrawSliderThumb(wxDC& WXUNUSED(dc), | |
950 | const wxRect& WXUNUSED(rect), | |
951 | wxOrientation WXUNUSED(orient), | |
952 | int WXUNUSED(flags), | |
953 | long WXUNUSED(style)) | |
954 | { | |
955 | wxFAIL_MSG(_T("TODO")); | |
956 | } | |
957 | ||
958 | void wxMonoRenderer::DrawSliderTicks(wxDC& WXUNUSED(dc), | |
959 | const wxRect& WXUNUSED(rect), | |
960 | int WXUNUSED(lenThumb), | |
961 | wxOrientation WXUNUSED(orient), | |
962 | int WXUNUSED(start), | |
963 | int WXUNUSED(end), | |
964 | int WXUNUSED(step), | |
965 | int WXUNUSED(flags), | |
966 | long WXUNUSED(style)) | |
967 | { | |
968 | wxFAIL_MSG(_T("TODO")); | |
969 | } | |
970 | ||
971 | wxCoord wxMonoRenderer::GetSliderDim() const | |
972 | { | |
973 | wxFAIL_MSG(_T("TODO")); | |
974 | ||
975 | return 0; | |
976 | } | |
977 | ||
978 | wxCoord wxMonoRenderer::GetSliderTickLen() const | |
979 | { | |
980 | wxFAIL_MSG(_T("TODO")); | |
981 | ||
982 | return 0; | |
983 | } | |
984 | ||
985 | ||
986 | wxRect wxMonoRenderer::GetSliderShaftRect(const wxRect& WXUNUSED(rect), | |
987 | int WXUNUSED(lenThumb), | |
988 | wxOrientation WXUNUSED(orient), | |
989 | long WXUNUSED(style)) const | |
990 | { | |
991 | wxFAIL_MSG(_T("TODO")); | |
992 | ||
993 | return wxRect(); | |
994 | } | |
995 | ||
996 | wxSize wxMonoRenderer::GetSliderThumbSize(const wxRect& WXUNUSED(rect), | |
997 | int WXUNUSED(lenThumb), | |
998 | wxOrientation WXUNUSED(orient)) const | |
999 | { | |
1000 | wxFAIL_MSG(_T("TODO")); | |
1001 | ||
1002 | return wxSize(); | |
1003 | } | |
1004 | ||
1005 | #endif // wxUSE_SLIDER | |
1006 | ||
1007 | wxSize wxMonoRenderer::GetProgressBarStep() const | |
1008 | { | |
1009 | wxFAIL_MSG(_T("TODO")); | |
1010 | ||
1011 | return wxSize(); | |
1012 | } | |
1013 | ||
1014 | ||
1015 | // ---------------------------------------------------------------------------- | |
1016 | // scrollbar | |
1017 | // ---------------------------------------------------------------------------- | |
1018 | ||
1019 | void wxMonoRenderer::DrawArrow(wxDC& dc, | |
1020 | wxDirection dir, | |
1021 | const wxRect& rect, | |
1022 | int WXUNUSED(flags)) | |
1023 | { | |
1024 | ArrowDirection arrowDir = GetArrowDirection(dir); | |
1025 | wxCHECK_RET( arrowDir != Arrow_Max, _T("invalid arrow direction") ); | |
1026 | ||
1027 | wxBitmap& bmp = m_bmpArrows[arrowDir]; | |
1028 | if ( !bmp.Ok() ) | |
1029 | { | |
1030 | bmp = wxBitmap(ms_xpmArrows[arrowDir]); | |
1031 | } | |
1032 | ||
1033 | wxRect rectArrow(0, 0, bmp.GetWidth(), bmp.GetHeight()); | |
1034 | dc.DrawBitmap(bmp, rectArrow.CentreIn(rect).GetPosition(), true /* use mask */); | |
1035 | } | |
1036 | ||
1037 | void wxMonoRenderer::DrawScrollbarThumb(wxDC& dc, | |
1038 | wxOrientation WXUNUSED(orient), | |
1039 | const wxRect& rect, | |
1040 | int WXUNUSED(flags)) | |
1041 | { | |
1042 | DrawSolidRect(dc, wxMONO_BG_COL, rect); | |
1043 | ||
1044 | // manually draw stipple pattern (wxDFB doesn't implement the wxSTIPPLE | |
1045 | // brush style): | |
1046 | dc.SetPen(m_penFg); | |
1047 | for ( wxCoord y = rect.GetTop(); y <= rect.GetBottom(); y++ ) | |
1048 | { | |
1049 | for ( wxCoord x = rect.GetLeft() + (y % 2); x <= rect.GetRight(); x+=2 ) | |
1050 | { | |
1051 | dc.DrawPoint(x, y); | |
1052 | } | |
1053 | } | |
1054 | } | |
1055 | ||
1056 | void wxMonoRenderer::DrawScrollbarShaft(wxDC& dc, | |
1057 | wxOrientation WXUNUSED(orient), | |
1058 | const wxRect& rect, | |
1059 | int WXUNUSED(flags)) | |
1060 | { | |
1061 | DrawSolidRect(dc, wxMONO_BG_COL, rect); | |
1062 | } | |
1063 | ||
1064 | // ---------------------------------------------------------------------------- | |
1065 | // status bar | |
1066 | // ---------------------------------------------------------------------------- | |
1067 | ||
1068 | #if wxUSE_STATUSBAR | |
1069 | ||
1070 | wxCoord wxMonoRenderer::GetStatusBarBorderBetweenFields() const | |
1071 | { | |
1072 | return 1; | |
1073 | } | |
1074 | ||
1075 | wxSize wxMonoRenderer::GetStatusBarFieldMargins() const | |
1076 | { | |
1077 | return wxSize(1, 1); | |
1078 | } | |
1079 | ||
1080 | #endif // wxUSE_STATUSBAR | |
1081 | ||
1082 | // ---------------------------------------------------------------------------- | |
1083 | // top level windows | |
1084 | // ---------------------------------------------------------------------------- | |
1085 | ||
1086 | int wxMonoRenderer::GetFrameBorderWidth(int WXUNUSED(flags)) const | |
1087 | { | |
1088 | // all our borders are simple | |
1089 | return 1; | |
1090 | } | |
1091 | ||
1092 | // ---------------------------------------------------------------------------- | |
1093 | // wxMonoArtProvider | |
1094 | // ---------------------------------------------------------------------------- | |
1095 | ||
1096 | wxBitmap wxMonoArtProvider::CreateBitmap(const wxArtID& WXUNUSED(id), | |
1097 | const wxArtClient& WXUNUSED(client), | |
1098 | const wxSize& WXUNUSED(size)) | |
1099 | { | |
1100 | return wxNullBitmap; | |
1101 | } | |
1102 | ||
1103 | #endif // wxUSE_THEME_MONO |