]>
Commit | Line | Data |
---|---|---|
147b8a4a VZ |
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 | ||
e7637222 VS |
27 | #include "wx/univ/theme.h" |
28 | ||
29 | #if wxUSE_THEME_MONO | |
4353a8df | 30 | |
147b8a4a | 31 | #ifndef WX_PRECOMP |
341f776c | 32 | #include "wx/dc.h" |
147b8a4a VZ |
33 | #endif // WX_PRECOMP |
34 | ||
3a01afec VZ |
35 | #include "wx/artprov.h" |
36 | #include "wx/univ/stdrend.h" | |
147b8a4a VZ |
37 | #include "wx/univ/inphand.h" |
38 | #include "wx/univ/colschem.h" | |
147b8a4a VZ |
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 | ||
147b8a4a VZ |
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 | ||
b19d4eb9 VZ |
65 | virtual void DrawFocusRect(wxDC& dc, const wxRect& rect, int flags = 0); |
66 | ||
147b8a4a VZ |
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 | ||
147b8a4a VZ |
78 | virtual void DrawArrow(wxDC& dc, |
79 | wxDirection dir, | |
80 | const wxRect& rect, | |
81 | int flags = 0); | |
147b8a4a VZ |
82 | virtual void DrawScrollbarThumb(wxDC& dc, |
83 | wxOrientation orient, | |
84 | const wxRect& rect, | |
85 | int flags = 0); | |
147b8a4a VZ |
86 | virtual void DrawScrollbarShaft(wxDC& dc, |
87 | wxOrientation orient, | |
88 | const wxRect& rect, | |
89 | int flags = 0); | |
90 | ||
147b8a4a VZ |
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 | ||
147b8a4a VZ |
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 | |
147b8a4a VZ |
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 | ||
3a01afec | 158 | #if wxUSE_COMBOBOX |
147b8a4a VZ |
159 | virtual void GetComboBitmaps(wxBitmap *bmpNormal, |
160 | wxBitmap *bmpFocus, | |
161 | wxBitmap *bmpPressed, | |
162 | wxBitmap *bmpDisabled); | |
3a01afec | 163 | #endif // wxUSE_COMBOBOX |
147b8a4a VZ |
164 | |
165 | ||
166 | virtual wxRect GetBorderDimensions(wxBorder border) const; | |
167 | ||
147b8a4a | 168 | #if wxUSE_SCROLLBAR |
3a01afec | 169 | virtual wxSize GetScrollbarArrowSize() const { return GetStdBmpSize(); } |
147b8a4a VZ |
170 | #endif // wxUSE_SCROLLBAR |
171 | ||
3a01afec VZ |
172 | virtual wxSize GetCheckBitmapSize() const { return GetStdBmpSize(); } |
173 | virtual wxSize GetRadioBitmapSize() const { return GetStdBmpSize(); } | |
147b8a4a | 174 | |
2296981b | 175 | #if wxUSE_TOOLBAR |
147b8a4a VZ |
176 | virtual wxSize GetToolBarButtonSize(wxCoord *separator) const; |
177 | ||
178 | virtual wxSize GetToolBarMargin() const; | |
2296981b | 179 | #endif // wxUSE_TOOLBAR |
147b8a4a | 180 | |
147b8a4a VZ |
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 | ||
f012b534 VS |
211 | #if wxUSE_STATUSBAR |
212 | virtual wxCoord GetStatusBarBorderBetweenFields() const; | |
213 | ||
214 | virtual wxSize GetStatusBarFieldMargins() const; | |
215 | #endif // wxUSE_STATUSBAR | |
216 | ||
147b8a4a | 217 | protected: |
3a01afec VZ |
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); } | |
7419ba02 VZ |
229 | virtual void DrawBoxBorder(wxDC& dc, wxRect *rect) |
230 | { DrawSimpleBorder(dc, rect); } | |
231 | virtual void DrawStaticBorder(wxDC& dc, wxRect *rect) | |
3a01afec | 232 | { DrawSimpleBorder(dc, rect); } |
7419ba02 VZ |
233 | virtual void DrawExtraBorder(wxDC& WXUNUSED(dc), wxRect * WXUNUSED(rect)) |
234 | { /* no extra borders for us */ } | |
3a01afec VZ |
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); } | |
147b8a4a | 244 | |
249803fb | 245 | virtual wxBitmap GetFrameButtonBitmap(FrameButtonType type); |
b13862ee | 246 | virtual int GetFrameBorderWidth(int flags) const; |
249803fb | 247 | |
3a01afec VZ |
248 | private: |
249 | // the bitmaps returned by GetIndicator() | |
250 | wxBitmap m_bmpIndicators[IndicatorType_MaxCtrl] | |
251 | [IndicatorState_MaxCtrl] | |
252 | [IndicatorStatus_Max]; | |
147b8a4a | 253 | |
3a01afec VZ |
254 | static const char **ms_xpmIndicators[IndicatorType_MaxCtrl] |
255 | [IndicatorState_MaxCtrl] | |
256 | [IndicatorStatus_Max]; | |
147b8a4a | 257 | |
3a01afec VZ |
258 | // the arrow bitmaps used by DrawArrow() |
259 | wxBitmap m_bmpArrows[Arrow_Max]; | |
147b8a4a | 260 | |
3a01afec | 261 | static const char **ms_xpmArrows[Arrow_Max]; |
147b8a4a | 262 | |
249803fb VZ |
263 | // the close bitmap for the frame for GetFrameButtonBitmap() |
264 | wxBitmap m_bmpFrameClose; | |
265 | ||
3a01afec VZ |
266 | // pen used for foreground drawing |
267 | wxPen m_penFg; | |
268 | }; | |
147b8a4a | 269 | |
3a01afec VZ |
270 | // ---------------------------------------------------------------------------- |
271 | // standard bitmaps | |
272 | // ---------------------------------------------------------------------------- | |
147b8a4a | 273 | |
3a01afec VZ |
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 | }; | |
147b8a4a | 289 | |
3a01afec VZ |
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 | }; | |
147b8a4a | 305 | |
3a01afec VZ |
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 | }; | |
147b8a4a | 321 | |
3a01afec VZ |
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 | }; | |
147b8a4a | 337 | |
3a01afec VZ |
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 | |
147b8a4a | 359 | { |
3a01afec VZ |
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 | }, | |
147b8a4a VZ |
381 | }; |
382 | ||
3a01afec VZ |
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 | }; | |
147b8a4a | 398 | |
3a01afec VZ |
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 | }; | |
147b8a4a | 414 | |
3a01afec VZ |
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 | }; | |
147b8a4a | 430 | |
3a01afec VZ |
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, | |
147b8a4a VZ |
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 | ||
147b8a4a VZ |
485 | class wxMonoTheme : public wxTheme |
486 | { | |
487 | public: | |
488 | wxMonoTheme(); | |
489 | virtual ~wxMonoTheme(); | |
490 | ||
491 | virtual wxRenderer *GetRenderer(); | |
492 | virtual wxArtProvider *GetArtProvider(); | |
3a01afec VZ |
493 | virtual wxInputHandler *GetInputHandler(const wxString& control, |
494 | wxInputConsumer *consumer); | |
147b8a4a VZ |
495 | virtual wxColourScheme *GetColourScheme(); |
496 | ||
497 | private: | |
498 | wxMonoRenderer *m_renderer; | |
499 | wxMonoArtProvider *m_artProvider; | |
500 | wxMonoColourScheme *m_scheme; | |
501 | ||
3a01afec | 502 | WX_DECLARE_THEME(mono) |
147b8a4a VZ |
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; | |
571d2e0f | 526 | delete m_artProvider; |
147b8a4a VZ |
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 | } | |
3a01afec VZ |
584 | |
585 | return col; | |
147b8a4a VZ |
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: | |
147b8a4a VZ |
599 | case TITLEBAR: |
600 | case TITLEBAR_ACTIVE: | |
fc875d57 | 601 | case HIGHLIGHT_TEXT: |
147b8a4a VZ |
602 | case DESKTOP: |
603 | return GetBg(); | |
604 | ||
605 | case MAX: | |
606 | default: | |
607 | wxFAIL_MSG(_T("invalid standard colour")); | |
608 | // fall through | |
609 | ||
610 | case SHADOW_DARK: | |
611 | case SHADOW_HIGHLIGHT: | |
612 | case SHADOW_IN: | |
613 | case SHADOW_OUT: | |
614 | case CONTROL_TEXT: | |
615 | case CONTROL_TEXT_DISABLED: | |
616 | case CONTROL_TEXT_DISABLED_SHADOW: | |
147b8a4a VZ |
617 | case TITLEBAR_TEXT: |
618 | case TITLEBAR_ACTIVE_TEXT: | |
fc875d57 | 619 | case HIGHLIGHT: |
147b8a4a VZ |
620 | return GetFg(); |
621 | ||
622 | } | |
623 | } | |
624 | ||
625 | // ============================================================================ | |
626 | // wxMonoRenderer | |
627 | // ============================================================================ | |
628 | ||
629 | // ---------------------------------------------------------------------------- | |
630 | // construction | |
631 | // ---------------------------------------------------------------------------- | |
632 | ||
633 | wxMonoRenderer::wxMonoRenderer(const wxColourScheme *scheme) | |
634 | : wxStdRenderer(scheme) | |
635 | { | |
3a01afec | 636 | m_penFg = wxPen(wxMONO_FG_COL); |
147b8a4a VZ |
637 | } |
638 | ||
639 | // ---------------------------------------------------------------------------- | |
3a01afec | 640 | // borders |
147b8a4a VZ |
641 | // ---------------------------------------------------------------------------- |
642 | ||
2296981b VZ |
643 | wxRect wxMonoRenderer::GetBorderDimensions(wxBorder border) const |
644 | { | |
645 | wxCoord width; | |
646 | switch ( border ) | |
647 | { | |
648 | case wxBORDER_SIMPLE: | |
649 | case wxBORDER_STATIC: | |
650 | case wxBORDER_RAISED: | |
651 | case wxBORDER_SUNKEN: | |
652 | width = 1; | |
653 | break; | |
654 | ||
655 | case wxBORDER_DOUBLE: | |
656 | width = 2; | |
657 | break; | |
658 | ||
659 | default: | |
660 | wxFAIL_MSG(_T("unknown border type")); | |
661 | // fall through | |
662 | ||
663 | case wxBORDER_DEFAULT: | |
664 | case wxBORDER_NONE: | |
665 | width = 0; | |
666 | break; | |
667 | } | |
668 | ||
669 | wxRect rect; | |
670 | rect.x = | |
671 | rect.y = | |
672 | rect.width = | |
673 | rect.height = width; | |
674 | ||
675 | return rect; | |
676 | } | |
677 | ||
147b8a4a | 678 | void wxMonoRenderer::DrawButtonBorder(wxDC& dc, |
3a01afec | 679 | const wxRect& rect, |
147b8a4a VZ |
680 | int flags, |
681 | wxRect *rectIn) | |
682 | { | |
3a01afec | 683 | DrawBorder(dc, wxBORDER_SIMPLE, rect, flags, rectIn); |
147b8a4a VZ |
684 | } |
685 | ||
686 | // ---------------------------------------------------------------------------- | |
687 | // lines and frames | |
688 | // ---------------------------------------------------------------------------- | |
689 | ||
690 | void | |
691 | wxMonoRenderer::DrawHorizontalLine(wxDC& dc, wxCoord y, wxCoord x1, wxCoord x2) | |
692 | { | |
693 | dc.SetPen(m_penFg); | |
694 | dc.DrawLine(x1, y, x2 + 1, y); | |
695 | } | |
696 | ||
697 | void | |
698 | wxMonoRenderer::DrawVerticalLine(wxDC& dc, wxCoord x, wxCoord y1, wxCoord y2) | |
699 | { | |
700 | dc.SetPen(m_penFg); | |
701 | dc.DrawLine(x, y1, x, y2 + 1); | |
702 | } | |
703 | ||
b19d4eb9 VZ |
704 | void wxMonoRenderer::DrawFocusRect(wxDC& dc, const wxRect& rect, int flags) |
705 | { | |
706 | // no need to draw the focus rect for selected items, it would be invisible | |
707 | // anyhow | |
708 | if ( !(flags & wxCONTROL_SELECTED) ) | |
709 | { | |
710 | dc.SetPen(m_penFg); | |
711 | dc.SetBrush(*wxTRANSPARENT_BRUSH); | |
712 | dc.DrawRectangle(rect); | |
713 | } | |
714 | } | |
715 | ||
147b8a4a VZ |
716 | // ---------------------------------------------------------------------------- |
717 | // label | |
718 | // ---------------------------------------------------------------------------- | |
719 | ||
147b8a4a | 720 | void wxMonoRenderer::DrawButtonLabel(wxDC& dc, |
3a01afec VZ |
721 | const wxString& label, |
722 | const wxBitmap& image, | |
723 | const wxRect& rect, | |
724 | int flags, | |
725 | int alignment, | |
726 | int indexAccel, | |
727 | wxRect *rectBounds) | |
147b8a4a | 728 | { |
3a01afec | 729 | dc.SetTextForeground(m_penFg.GetColour()); |
147b8a4a VZ |
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 | |
3a01afec | 735 | // in monochrome theme otherwise, so cross it out |
147b8a4a VZ |
736 | dc.SetPen(m_penFg); |
737 | dc.DrawLine(rect.GetTopLeft(), rect.GetBottomRight()); | |
738 | dc.DrawLine(rect.GetTopRight(), rect.GetBottomLeft()); | |
739 | } | |
740 | } | |
741 | ||
147b8a4a | 742 | // ---------------------------------------------------------------------------- |
249803fb | 743 | // bitmaps |
147b8a4a VZ |
744 | // ---------------------------------------------------------------------------- |
745 | ||
3a01afec | 746 | wxBitmap wxMonoRenderer::GetIndicator(IndicatorType indType, int flags) |
147b8a4a | 747 | { |
3a01afec VZ |
748 | IndicatorState indState; |
749 | IndicatorStatus indStatus; | |
750 | GetIndicatorsFromFlags(flags, indState, indStatus); | |
147b8a4a | 751 | |
3a01afec VZ |
752 | wxBitmap& bmp = m_bmpIndicators[indType][indState][indStatus]; |
753 | if ( !bmp.Ok() ) | |
147b8a4a | 754 | { |
3a01afec VZ |
755 | const char **xpm = ms_xpmIndicators[indType][indState][indStatus]; |
756 | if ( xpm ) | |
147b8a4a | 757 | { |
3a01afec VZ |
758 | // create and cache it |
759 | bmp = wxBitmap(xpm); | |
147b8a4a | 760 | } |
147b8a4a VZ |
761 | } |
762 | ||
3a01afec | 763 | return bmp; |
147b8a4a VZ |
764 | } |
765 | ||
249803fb VZ |
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 | ||
3a01afec VZ |
798 | // ---------------------------------------------------------------------------- |
799 | // toolbar | |
800 | // ---------------------------------------------------------------------------- | |
147b8a4a VZ |
801 | |
802 | #if wxUSE_TOOLBAR | |
3a01afec | 803 | |
61338568 WS |
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)) | |
147b8a4a | 811 | { |
3a01afec | 812 | wxFAIL_MSG(_T("TODO")); |
147b8a4a | 813 | } |
3a01afec | 814 | |
61338568 | 815 | wxSize wxMonoRenderer::GetToolBarButtonSize(wxCoord *WXUNUSED(separator)) const |
2296981b VZ |
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 | ||
147b8a4a VZ |
829 | #endif // wxUSE_TOOLBAR |
830 | ||
831 | // ---------------------------------------------------------------------------- | |
3a01afec | 832 | // notebook |
147b8a4a VZ |
833 | // ---------------------------------------------------------------------------- |
834 | ||
3a01afec | 835 | #if wxUSE_NOTEBOOK |
147b8a4a | 836 | |
61338568 WS |
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)) | |
147b8a4a | 844 | { |
3a01afec | 845 | wxFAIL_MSG(_T("TODO")); |
147b8a4a VZ |
846 | } |
847 | ||
2296981b VZ |
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 | ||
3a01afec | 862 | #endif // wxUSE_NOTEBOOK |
147b8a4a VZ |
863 | |
864 | // ---------------------------------------------------------------------------- | |
865 | // combobox | |
866 | // ---------------------------------------------------------------------------- | |
867 | ||
868 | #if wxUSE_COMBOBOX | |
869 | ||
61338568 WS |
870 | void wxMonoRenderer::GetComboBitmaps(wxBitmap *WXUNUSED(bmpNormal), |
871 | wxBitmap *WXUNUSED(bmpFocus), | |
872 | wxBitmap *WXUNUSED(bmpPressed), | |
873 | wxBitmap *WXUNUSED(bmpDisabled)) | |
147b8a4a | 874 | { |
3a01afec | 875 | wxFAIL_MSG(_T("TODO")); |
147b8a4a VZ |
876 | } |
877 | ||
878 | #endif // wxUSE_COMBOBOX | |
879 | ||
2296981b VZ |
880 | // ---------------------------------------------------------------------------- |
881 | // menus | |
882 | // ---------------------------------------------------------------------------- | |
883 | ||
884 | #if wxUSE_MENUS | |
885 | ||
61338568 WS |
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)) | |
2296981b VZ |
891 | { |
892 | wxFAIL_MSG(_T("TODO")); | |
893 | } | |
894 | ||
61338568 WS |
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)) | |
2296981b VZ |
903 | { |
904 | wxFAIL_MSG(_T("TODO")); | |
905 | } | |
906 | ||
61338568 WS |
907 | void wxMonoRenderer::DrawMenuSeparator(wxDC& WXUNUSED(dc), |
908 | wxCoord WXUNUSED(y), | |
909 | const wxMenuGeometryInfo& WXUNUSED(geomInfo)) | |
2296981b VZ |
910 | { |
911 | wxFAIL_MSG(_T("TODO")); | |
912 | } | |
913 | ||
61338568 | 914 | wxSize wxMonoRenderer::GetMenuBarItemSize(const wxSize& WXUNUSED(sizeText)) const |
2296981b VZ |
915 | { |
916 | wxFAIL_MSG(_T("TODO")); | |
917 | ||
918 | return wxSize(); | |
919 | } | |
920 | ||
61338568 WS |
921 | wxMenuGeometryInfo *wxMonoRenderer::GetMenuGeometry(wxWindow *WXUNUSED(win), |
922 | const wxMenu& WXUNUSED(menu)) const | |
2296981b VZ |
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 | ||
61338568 WS |
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)) | |
2296981b VZ |
944 | { |
945 | wxFAIL_MSG(_T("TODO")); | |
946 | } | |
947 | ||
948 | ||
61338568 WS |
949 | void wxMonoRenderer::DrawSliderThumb(wxDC& WXUNUSED(dc), |
950 | const wxRect& WXUNUSED(rect), | |
951 | wxOrientation WXUNUSED(orient), | |
952 | int WXUNUSED(flags), | |
953 | long WXUNUSED(style)) | |
2296981b VZ |
954 | { |
955 | wxFAIL_MSG(_T("TODO")); | |
956 | } | |
957 | ||
61338568 WS |
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)) | |
2296981b VZ |
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 | ||
61338568 WS |
986 | wxRect wxMonoRenderer::GetSliderShaftRect(const wxRect& WXUNUSED(rect), |
987 | int WXUNUSED(lenThumb), | |
988 | wxOrientation WXUNUSED(orient), | |
989 | long WXUNUSED(style)) const | |
2296981b VZ |
990 | { |
991 | wxFAIL_MSG(_T("TODO")); | |
992 | ||
993 | return wxRect(); | |
994 | } | |
995 | ||
61338568 WS |
996 | wxSize wxMonoRenderer::GetSliderThumbSize(const wxRect& WXUNUSED(rect), |
997 | int WXUNUSED(lenThumb), | |
998 | wxOrientation WXUNUSED(orient)) const | |
2296981b VZ |
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 | ||
147b8a4a VZ |
1015 | // ---------------------------------------------------------------------------- |
1016 | // scrollbar | |
1017 | // ---------------------------------------------------------------------------- | |
1018 | ||
147b8a4a | 1019 | void wxMonoRenderer::DrawArrow(wxDC& dc, |
3a01afec VZ |
1020 | wxDirection dir, |
1021 | const wxRect& rect, | |
1022 | int WXUNUSED(flags)) | |
147b8a4a | 1023 | { |
3a01afec VZ |
1024 | ArrowDirection arrowDir = GetArrowDirection(dir); |
1025 | wxCHECK_RET( arrowDir != Arrow_Max, _T("invalid arrow direction") ); | |
147b8a4a | 1026 | |
3a01afec VZ |
1027 | wxBitmap& bmp = m_bmpArrows[arrowDir]; |
1028 | if ( !bmp.Ok() ) | |
147b8a4a | 1029 | { |
3a01afec | 1030 | bmp = wxBitmap(ms_xpmArrows[arrowDir]); |
147b8a4a | 1031 | } |
147b8a4a | 1032 | |
3a01afec VZ |
1033 | wxRect rectArrow(0, 0, bmp.GetWidth(), bmp.GetHeight()); |
1034 | dc.DrawBitmap(bmp, rectArrow.CentreIn(rect).GetPosition(), true /* use mask */); | |
147b8a4a VZ |
1035 | } |
1036 | ||
1037 | void wxMonoRenderer::DrawScrollbarThumb(wxDC& dc, | |
3a01afec VZ |
1038 | wxOrientation WXUNUSED(orient), |
1039 | const wxRect& rect, | |
1040 | int WXUNUSED(flags)) | |
147b8a4a | 1041 | { |
3a01afec | 1042 | DrawSolidRect(dc, wxMONO_FG_COL, rect); |
147b8a4a VZ |
1043 | } |
1044 | ||
1045 | void wxMonoRenderer::DrawScrollbarShaft(wxDC& dc, | |
3a01afec VZ |
1046 | wxOrientation WXUNUSED(orient), |
1047 | const wxRect& rect, | |
1048 | int WXUNUSED(flags)) | |
147b8a4a | 1049 | { |
3a01afec | 1050 | DrawSolidRect(dc, wxMONO_BG_COL, rect); |
147b8a4a VZ |
1051 | } |
1052 | ||
f012b534 VS |
1053 | // ---------------------------------------------------------------------------- |
1054 | // status bar | |
1055 | // ---------------------------------------------------------------------------- | |
1056 | ||
1057 | #if wxUSE_STATUSBAR | |
1058 | ||
1059 | wxCoord wxMonoRenderer::GetStatusBarBorderBetweenFields() const | |
1060 | { | |
1061 | return 1; | |
1062 | } | |
1063 | ||
1064 | wxSize wxMonoRenderer::GetStatusBarFieldMargins() const | |
1065 | { | |
1066 | return wxSize(1, 1); | |
1067 | } | |
1068 | ||
1069 | #endif // wxUSE_STATUSBAR | |
1070 | ||
147b8a4a VZ |
1071 | // ---------------------------------------------------------------------------- |
1072 | // top level windows | |
1073 | // ---------------------------------------------------------------------------- | |
1074 | ||
b13862ee VZ |
1075 | int wxMonoRenderer::GetFrameBorderWidth(int WXUNUSED(flags)) const |
1076 | { | |
1077 | // all our borders are simple | |
1078 | return 1; | |
1079 | } | |
147b8a4a VZ |
1080 | |
1081 | // ---------------------------------------------------------------------------- | |
3a01afec | 1082 | // wxMonoArtProvider |
147b8a4a VZ |
1083 | // ---------------------------------------------------------------------------- |
1084 | ||
3a01afec VZ |
1085 | wxBitmap wxMonoArtProvider::CreateBitmap(const wxArtID& WXUNUSED(id), |
1086 | const wxArtClient& WXUNUSED(client), | |
1087 | const wxSize& WXUNUSED(size)) | |
147b8a4a | 1088 | { |
147b8a4a VZ |
1089 | return wxNullBitmap; |
1090 | } | |
4353a8df | 1091 | |
e7637222 | 1092 | #endif // wxUSE_THEME_MONO |