]>
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 | ||
6d789987 | 65 | virtual void DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, int flags = 0); |
b19d4eb9 | 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 | 602 | case DESKTOP: |
9c6d8b7c | 603 | case FRAME: |
147b8a4a VZ |
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: | |
147b8a4a VZ |
618 | case TITLEBAR_TEXT: |
619 | case TITLEBAR_ACTIVE_TEXT: | |
fc875d57 | 620 | case HIGHLIGHT: |
147b8a4a VZ |
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 | { | |
3a01afec | 637 | m_penFg = wxPen(wxMONO_FG_COL); |
147b8a4a VZ |
638 | } |
639 | ||
640 | // ---------------------------------------------------------------------------- | |
3a01afec | 641 | // borders |
147b8a4a VZ |
642 | // ---------------------------------------------------------------------------- |
643 | ||
2296981b VZ |
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: | |
431e319c | 653 | case wxBORDER_THEME: |
2296981b VZ |
654 | width = 1; |
655 | break; | |
431e319c | 656 | /* |
2296981b VZ |
657 | case wxBORDER_DOUBLE: |
658 | width = 2; | |
659 | break; | |
431e319c | 660 | */ |
2296981b VZ |
661 | default: |
662 | wxFAIL_MSG(_T("unknown border type")); | |
663 | // fall through | |
664 | ||
665 | case wxBORDER_DEFAULT: | |
666 | case wxBORDER_NONE: | |
667 | width = 0; | |
668 | break; | |
669 | } | |
670 | ||
671 | wxRect rect; | |
672 | rect.x = | |
673 | rect.y = | |
674 | rect.width = | |
675 | rect.height = width; | |
676 | ||
677 | return rect; | |
678 | } | |
679 | ||
147b8a4a | 680 | void wxMonoRenderer::DrawButtonBorder(wxDC& dc, |
3a01afec | 681 | const wxRect& rect, |
147b8a4a VZ |
682 | int flags, |
683 | wxRect *rectIn) | |
684 | { | |
3a01afec | 685 | DrawBorder(dc, wxBORDER_SIMPLE, rect, flags, rectIn); |
147b8a4a VZ |
686 | } |
687 | ||
688 | // ---------------------------------------------------------------------------- | |
689 | // lines and frames | |
690 | // ---------------------------------------------------------------------------- | |
691 | ||
692 | void | |
693 | wxMonoRenderer::DrawHorizontalLine(wxDC& dc, wxCoord y, wxCoord x1, wxCoord x2) | |
694 | { | |
695 | dc.SetPen(m_penFg); | |
696 | dc.DrawLine(x1, y, x2 + 1, y); | |
697 | } | |
698 | ||
699 | void | |
700 | wxMonoRenderer::DrawVerticalLine(wxDC& dc, wxCoord x, wxCoord y1, wxCoord y2) | |
701 | { | |
702 | dc.SetPen(m_penFg); | |
703 | dc.DrawLine(x, y1, x, y2 + 1); | |
704 | } | |
705 | ||
6d789987 | 706 | void wxMonoRenderer::DrawFocusRect(wxWindow* WXUNUSED(win), wxDC& dc, const wxRect& rect, int flags) |
b19d4eb9 VZ |
707 | { |
708 | // no need to draw the focus rect for selected items, it would be invisible | |
709 | // anyhow | |
710 | if ( !(flags & wxCONTROL_SELECTED) ) | |
711 | { | |
712 | dc.SetPen(m_penFg); | |
713 | dc.SetBrush(*wxTRANSPARENT_BRUSH); | |
714 | dc.DrawRectangle(rect); | |
715 | } | |
716 | } | |
717 | ||
147b8a4a VZ |
718 | // ---------------------------------------------------------------------------- |
719 | // label | |
720 | // ---------------------------------------------------------------------------- | |
721 | ||
147b8a4a | 722 | void wxMonoRenderer::DrawButtonLabel(wxDC& dc, |
3a01afec VZ |
723 | const wxString& label, |
724 | const wxBitmap& image, | |
725 | const wxRect& rect, | |
726 | int flags, | |
727 | int alignment, | |
728 | int indexAccel, | |
729 | wxRect *rectBounds) | |
147b8a4a | 730 | { |
147b8a4a VZ |
731 | dc.DrawLabel(label, image, rect, alignment, indexAccel, rectBounds); |
732 | ||
733 | if ( flags & wxCONTROL_DISABLED ) | |
734 | { | |
735 | // this is ugly but I don't know how to show disabled button visually | |
3a01afec | 736 | // in monochrome theme otherwise, so cross it out |
147b8a4a VZ |
737 | dc.SetPen(m_penFg); |
738 | dc.DrawLine(rect.GetTopLeft(), rect.GetBottomRight()); | |
739 | dc.DrawLine(rect.GetTopRight(), rect.GetBottomLeft()); | |
740 | } | |
741 | } | |
742 | ||
147b8a4a | 743 | // ---------------------------------------------------------------------------- |
249803fb | 744 | // bitmaps |
147b8a4a VZ |
745 | // ---------------------------------------------------------------------------- |
746 | ||
3a01afec | 747 | wxBitmap wxMonoRenderer::GetIndicator(IndicatorType indType, int flags) |
147b8a4a | 748 | { |
3a01afec VZ |
749 | IndicatorState indState; |
750 | IndicatorStatus indStatus; | |
751 | GetIndicatorsFromFlags(flags, indState, indStatus); | |
147b8a4a | 752 | |
3a01afec VZ |
753 | wxBitmap& bmp = m_bmpIndicators[indType][indState][indStatus]; |
754 | if ( !bmp.Ok() ) | |
147b8a4a | 755 | { |
3a01afec VZ |
756 | const char **xpm = ms_xpmIndicators[indType][indState][indStatus]; |
757 | if ( xpm ) | |
147b8a4a | 758 | { |
3a01afec VZ |
759 | // create and cache it |
760 | bmp = wxBitmap(xpm); | |
147b8a4a | 761 | } |
147b8a4a VZ |
762 | } |
763 | ||
3a01afec | 764 | return bmp; |
147b8a4a VZ |
765 | } |
766 | ||
249803fb VZ |
767 | wxBitmap wxMonoRenderer::GetFrameButtonBitmap(FrameButtonType type) |
768 | { | |
769 | if ( type == FrameButton_Close ) | |
770 | { | |
771 | if ( !m_bmpFrameClose.Ok() ) | |
772 | { | |
773 | static const char *xpmFrameClose[] = { | |
774 | /* columns rows colors chars-per-pixel */ | |
775 | "8 8 2 1", | |
776 | " c white", | |
777 | "X c black", | |
778 | /* pixels */ | |
779 | " ", | |
780 | " XX XX ", | |
781 | " X X ", | |
782 | " XX ", | |
783 | " XX ", | |
784 | " X X ", | |
785 | " XX XX ", | |
786 | " ", | |
787 | }; | |
788 | ||
789 | m_bmpFrameClose = wxBitmap(xpmFrameClose); | |
790 | } | |
791 | ||
792 | return m_bmpFrameClose; | |
793 | } | |
794 | ||
795 | // we don't show any other buttons than close | |
796 | return wxNullBitmap; | |
797 | } | |
798 | ||
3a01afec VZ |
799 | // ---------------------------------------------------------------------------- |
800 | // toolbar | |
801 | // ---------------------------------------------------------------------------- | |
147b8a4a VZ |
802 | |
803 | #if wxUSE_TOOLBAR | |
3a01afec | 804 | |
61338568 WS |
805 | void wxMonoRenderer::DrawToolBarButton(wxDC& WXUNUSED(dc), |
806 | const wxString& WXUNUSED(label), | |
807 | const wxBitmap& WXUNUSED(bitmap), | |
808 | const wxRect& WXUNUSED(rect), | |
809 | int WXUNUSED(flags), | |
810 | long WXUNUSED(style), | |
811 | int WXUNUSED(tbarStyle)) | |
147b8a4a | 812 | { |
3a01afec | 813 | wxFAIL_MSG(_T("TODO")); |
147b8a4a | 814 | } |
3a01afec | 815 | |
61338568 | 816 | wxSize wxMonoRenderer::GetToolBarButtonSize(wxCoord *WXUNUSED(separator)) const |
2296981b VZ |
817 | { |
818 | wxFAIL_MSG(_T("TODO")); | |
819 | ||
820 | return wxSize(); | |
821 | } | |
822 | ||
823 | wxSize wxMonoRenderer::GetToolBarMargin() const | |
824 | { | |
825 | wxFAIL_MSG(_T("TODO")); | |
826 | ||
827 | return wxSize(); | |
828 | } | |
829 | ||
147b8a4a VZ |
830 | #endif // wxUSE_TOOLBAR |
831 | ||
832 | // ---------------------------------------------------------------------------- | |
3a01afec | 833 | // notebook |
147b8a4a VZ |
834 | // ---------------------------------------------------------------------------- |
835 | ||
3a01afec | 836 | #if wxUSE_NOTEBOOK |
147b8a4a | 837 | |
61338568 WS |
838 | void wxMonoRenderer::DrawTab(wxDC& WXUNUSED(dc), |
839 | const wxRect& WXUNUSED(rect), | |
840 | wxDirection WXUNUSED(dir), | |
841 | const wxString& WXUNUSED(label), | |
842 | const wxBitmap& WXUNUSED(bitmap), | |
843 | int WXUNUSED(flags), | |
844 | int WXUNUSED(indexAccel)) | |
147b8a4a | 845 | { |
3a01afec | 846 | wxFAIL_MSG(_T("TODO")); |
147b8a4a VZ |
847 | } |
848 | ||
2296981b VZ |
849 | wxSize wxMonoRenderer::GetTabIndent() const |
850 | { | |
851 | wxFAIL_MSG(_T("TODO")); | |
852 | ||
853 | return wxSize(); | |
854 | } | |
855 | ||
856 | wxSize wxMonoRenderer::GetTabPadding() const | |
857 | { | |
858 | wxFAIL_MSG(_T("TODO")); | |
859 | ||
860 | return wxSize(); | |
861 | } | |
862 | ||
3a01afec | 863 | #endif // wxUSE_NOTEBOOK |
147b8a4a VZ |
864 | |
865 | // ---------------------------------------------------------------------------- | |
866 | // combobox | |
867 | // ---------------------------------------------------------------------------- | |
868 | ||
869 | #if wxUSE_COMBOBOX | |
870 | ||
61338568 WS |
871 | void wxMonoRenderer::GetComboBitmaps(wxBitmap *WXUNUSED(bmpNormal), |
872 | wxBitmap *WXUNUSED(bmpFocus), | |
873 | wxBitmap *WXUNUSED(bmpPressed), | |
874 | wxBitmap *WXUNUSED(bmpDisabled)) | |
147b8a4a | 875 | { |
3a01afec | 876 | wxFAIL_MSG(_T("TODO")); |
147b8a4a VZ |
877 | } |
878 | ||
879 | #endif // wxUSE_COMBOBOX | |
880 | ||
2296981b VZ |
881 | // ---------------------------------------------------------------------------- |
882 | // menus | |
883 | // ---------------------------------------------------------------------------- | |
884 | ||
885 | #if wxUSE_MENUS | |
886 | ||
61338568 WS |
887 | void wxMonoRenderer::DrawMenuBarItem(wxDC& WXUNUSED(dc), |
888 | const wxRect& WXUNUSED(rect), | |
889 | const wxString& WXUNUSED(label), | |
890 | int WXUNUSED(flags), | |
891 | int WXUNUSED(indexAccel)) | |
2296981b VZ |
892 | { |
893 | wxFAIL_MSG(_T("TODO")); | |
894 | } | |
895 | ||
61338568 WS |
896 | void wxMonoRenderer::DrawMenuItem(wxDC& WXUNUSED(dc), |
897 | wxCoord WXUNUSED(y), | |
898 | const wxMenuGeometryInfo& WXUNUSED(geometryInfo), | |
899 | const wxString& WXUNUSED(label), | |
900 | const wxString& WXUNUSED(accel), | |
901 | const wxBitmap& WXUNUSED(bitmap), | |
902 | int WXUNUSED(flags), | |
903 | int WXUNUSED(indexAccel)) | |
2296981b VZ |
904 | { |
905 | wxFAIL_MSG(_T("TODO")); | |
906 | } | |
907 | ||
61338568 WS |
908 | void wxMonoRenderer::DrawMenuSeparator(wxDC& WXUNUSED(dc), |
909 | wxCoord WXUNUSED(y), | |
910 | const wxMenuGeometryInfo& WXUNUSED(geomInfo)) | |
2296981b VZ |
911 | { |
912 | wxFAIL_MSG(_T("TODO")); | |
913 | } | |
914 | ||
61338568 | 915 | wxSize wxMonoRenderer::GetMenuBarItemSize(const wxSize& WXUNUSED(sizeText)) const |
2296981b VZ |
916 | { |
917 | wxFAIL_MSG(_T("TODO")); | |
918 | ||
919 | return wxSize(); | |
920 | } | |
921 | ||
61338568 WS |
922 | wxMenuGeometryInfo *wxMonoRenderer::GetMenuGeometry(wxWindow *WXUNUSED(win), |
923 | const wxMenu& WXUNUSED(menu)) const | |
2296981b VZ |
924 | { |
925 | wxFAIL_MSG(_T("TODO")); | |
926 | ||
927 | return NULL; | |
928 | } | |
929 | ||
930 | #endif // wxUSE_MENUS | |
931 | ||
932 | // ---------------------------------------------------------------------------- | |
933 | // slider | |
934 | // ---------------------------------------------------------------------------- | |
935 | ||
936 | #if wxUSE_SLIDER | |
937 | ||
61338568 WS |
938 | void wxMonoRenderer::DrawSliderShaft(wxDC& WXUNUSED(dc), |
939 | const wxRect& WXUNUSED(rect), | |
940 | int WXUNUSED(lenThumb), | |
941 | wxOrientation WXUNUSED(orient), | |
942 | int WXUNUSED(flags), | |
943 | long WXUNUSED(style), | |
944 | wxRect *WXUNUSED(rectShaft)) | |
2296981b VZ |
945 | { |
946 | wxFAIL_MSG(_T("TODO")); | |
947 | } | |
948 | ||
949 | ||
61338568 WS |
950 | void wxMonoRenderer::DrawSliderThumb(wxDC& WXUNUSED(dc), |
951 | const wxRect& WXUNUSED(rect), | |
952 | wxOrientation WXUNUSED(orient), | |
953 | int WXUNUSED(flags), | |
954 | long WXUNUSED(style)) | |
2296981b VZ |
955 | { |
956 | wxFAIL_MSG(_T("TODO")); | |
957 | } | |
958 | ||
61338568 WS |
959 | void wxMonoRenderer::DrawSliderTicks(wxDC& WXUNUSED(dc), |
960 | const wxRect& WXUNUSED(rect), | |
961 | int WXUNUSED(lenThumb), | |
962 | wxOrientation WXUNUSED(orient), | |
963 | int WXUNUSED(start), | |
964 | int WXUNUSED(end), | |
965 | int WXUNUSED(step), | |
966 | int WXUNUSED(flags), | |
967 | long WXUNUSED(style)) | |
2296981b VZ |
968 | { |
969 | wxFAIL_MSG(_T("TODO")); | |
970 | } | |
971 | ||
972 | wxCoord wxMonoRenderer::GetSliderDim() const | |
973 | { | |
974 | wxFAIL_MSG(_T("TODO")); | |
975 | ||
976 | return 0; | |
977 | } | |
978 | ||
979 | wxCoord wxMonoRenderer::GetSliderTickLen() const | |
980 | { | |
981 | wxFAIL_MSG(_T("TODO")); | |
982 | ||
983 | return 0; | |
984 | } | |
985 | ||
986 | ||
61338568 WS |
987 | wxRect wxMonoRenderer::GetSliderShaftRect(const wxRect& WXUNUSED(rect), |
988 | int WXUNUSED(lenThumb), | |
989 | wxOrientation WXUNUSED(orient), | |
990 | long WXUNUSED(style)) const | |
2296981b VZ |
991 | { |
992 | wxFAIL_MSG(_T("TODO")); | |
993 | ||
994 | return wxRect(); | |
995 | } | |
996 | ||
61338568 WS |
997 | wxSize wxMonoRenderer::GetSliderThumbSize(const wxRect& WXUNUSED(rect), |
998 | int WXUNUSED(lenThumb), | |
999 | wxOrientation WXUNUSED(orient)) const | |
2296981b VZ |
1000 | { |
1001 | wxFAIL_MSG(_T("TODO")); | |
1002 | ||
1003 | return wxSize(); | |
1004 | } | |
1005 | ||
1006 | #endif // wxUSE_SLIDER | |
1007 | ||
1008 | wxSize wxMonoRenderer::GetProgressBarStep() const | |
1009 | { | |
1010 | wxFAIL_MSG(_T("TODO")); | |
1011 | ||
1012 | return wxSize(); | |
1013 | } | |
1014 | ||
1015 | ||
147b8a4a VZ |
1016 | // ---------------------------------------------------------------------------- |
1017 | // scrollbar | |
1018 | // ---------------------------------------------------------------------------- | |
1019 | ||
147b8a4a | 1020 | void wxMonoRenderer::DrawArrow(wxDC& dc, |
3a01afec VZ |
1021 | wxDirection dir, |
1022 | const wxRect& rect, | |
1023 | int WXUNUSED(flags)) | |
147b8a4a | 1024 | { |
3a01afec VZ |
1025 | ArrowDirection arrowDir = GetArrowDirection(dir); |
1026 | wxCHECK_RET( arrowDir != Arrow_Max, _T("invalid arrow direction") ); | |
147b8a4a | 1027 | |
3a01afec VZ |
1028 | wxBitmap& bmp = m_bmpArrows[arrowDir]; |
1029 | if ( !bmp.Ok() ) | |
147b8a4a | 1030 | { |
3a01afec | 1031 | bmp = wxBitmap(ms_xpmArrows[arrowDir]); |
147b8a4a | 1032 | } |
147b8a4a | 1033 | |
3a01afec VZ |
1034 | wxRect rectArrow(0, 0, bmp.GetWidth(), bmp.GetHeight()); |
1035 | dc.DrawBitmap(bmp, rectArrow.CentreIn(rect).GetPosition(), true /* use mask */); | |
147b8a4a VZ |
1036 | } |
1037 | ||
1038 | void wxMonoRenderer::DrawScrollbarThumb(wxDC& dc, | |
3a01afec VZ |
1039 | wxOrientation WXUNUSED(orient), |
1040 | const wxRect& rect, | |
1041 | int WXUNUSED(flags)) | |
147b8a4a | 1042 | { |
497cb543 VS |
1043 | DrawSolidRect(dc, wxMONO_BG_COL, rect); |
1044 | ||
1045 | // manually draw stipple pattern (wxDFB doesn't implement the wxSTIPPLE | |
1046 | // brush style): | |
1047 | dc.SetPen(m_penFg); | |
1048 | for ( wxCoord y = rect.GetTop(); y <= rect.GetBottom(); y++ ) | |
1049 | { | |
1050 | for ( wxCoord x = rect.GetLeft() + (y % 2); x <= rect.GetRight(); x+=2 ) | |
1051 | { | |
1052 | dc.DrawPoint(x, y); | |
1053 | } | |
1054 | } | |
147b8a4a VZ |
1055 | } |
1056 | ||
1057 | void wxMonoRenderer::DrawScrollbarShaft(wxDC& dc, | |
3a01afec VZ |
1058 | wxOrientation WXUNUSED(orient), |
1059 | const wxRect& rect, | |
1060 | int WXUNUSED(flags)) | |
147b8a4a | 1061 | { |
3a01afec | 1062 | DrawSolidRect(dc, wxMONO_BG_COL, rect); |
147b8a4a VZ |
1063 | } |
1064 | ||
f012b534 VS |
1065 | // ---------------------------------------------------------------------------- |
1066 | // status bar | |
1067 | // ---------------------------------------------------------------------------- | |
1068 | ||
1069 | #if wxUSE_STATUSBAR | |
1070 | ||
1071 | wxCoord wxMonoRenderer::GetStatusBarBorderBetweenFields() const | |
1072 | { | |
1073 | return 1; | |
1074 | } | |
1075 | ||
1076 | wxSize wxMonoRenderer::GetStatusBarFieldMargins() const | |
1077 | { | |
1078 | return wxSize(1, 1); | |
1079 | } | |
1080 | ||
1081 | #endif // wxUSE_STATUSBAR | |
1082 | ||
147b8a4a VZ |
1083 | // ---------------------------------------------------------------------------- |
1084 | // top level windows | |
1085 | // ---------------------------------------------------------------------------- | |
1086 | ||
b13862ee VZ |
1087 | int wxMonoRenderer::GetFrameBorderWidth(int WXUNUSED(flags)) const |
1088 | { | |
1089 | // all our borders are simple | |
1090 | return 1; | |
1091 | } | |
147b8a4a VZ |
1092 | |
1093 | // ---------------------------------------------------------------------------- | |
3a01afec | 1094 | // wxMonoArtProvider |
147b8a4a VZ |
1095 | // ---------------------------------------------------------------------------- |
1096 | ||
3a01afec VZ |
1097 | wxBitmap wxMonoArtProvider::CreateBitmap(const wxArtID& WXUNUSED(id), |
1098 | const wxArtClient& WXUNUSED(client), | |
1099 | const wxSize& WXUNUSED(size)) | |
147b8a4a | 1100 | { |
147b8a4a VZ |
1101 | return wxNullBitmap; |
1102 | } | |
4353a8df | 1103 | |
e7637222 | 1104 | #endif // wxUSE_THEME_MONO |