]>
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 | ||
27 | #ifndef WX_PRECOMP | |
28 | #endif // WX_PRECOMP | |
29 | ||
30 | #include "wx/univ/renderer.h" | |
31 | #include "wx/univ/inphand.h" | |
32 | #include "wx/univ/colschem.h" | |
33 | #include "wx/univ/theme.h" | |
34 | ||
35 | class wxMonoColourScheme; | |
36 | ||
37 | #define wxMONO_BG_COL (*wxWHITE) | |
38 | #define wxMONO_FG_COL (*wxBLACK) | |
39 | ||
40 | // ---------------------------------------------------------------------------- | |
41 | // wxMonoRenderer: draw the GUI elements in simplest possible way | |
42 | // ---------------------------------------------------------------------------- | |
43 | ||
44 | // Warning: many of the methods here are not implemented, the code won't work | |
45 | // if any but a few wxUSE_XXXs are on | |
46 | class wxMonoRenderer : public wxStdRenderer | |
47 | { | |
48 | public: | |
49 | wxMonoRenderer(const wxColourScheme *scheme); | |
50 | ||
51 | virtual void DrawBackground(wxDC& dc, | |
52 | const wxColour& col, | |
53 | const wxRect& rect, | |
54 | int flags, | |
55 | wxWindow *window = NULL); | |
56 | ||
57 | virtual void DrawLabel(wxDC& dc, | |
58 | const wxString& label, | |
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 DrawButtonLabel(wxDC& dc, | |
66 | const wxString& label, | |
67 | const wxBitmap& image, | |
68 | const wxRect& rect, | |
69 | int flags = 0, | |
70 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
71 | int indexAccel = -1, | |
72 | wxRect *rectBounds = NULL); | |
73 | ||
74 | virtual void DrawBorder(wxDC& dc, | |
75 | wxBorder border, | |
76 | const wxRect& rect, | |
77 | int flags = 0, | |
78 | wxRect *rectIn = NULL); | |
79 | ||
80 | virtual void DrawTextBorder(wxDC& dc, | |
81 | wxBorder border, | |
82 | const wxRect& rect, | |
83 | int flags = 0, | |
84 | wxRect *rectIn = NULL); | |
85 | ||
86 | virtual void DrawButtonBorder(wxDC& dc, | |
87 | const wxRect& rect, | |
88 | int flags = 0, | |
89 | wxRect *rectIn = NULL); | |
90 | ||
91 | virtual void DrawHorizontalLine(wxDC& dc, | |
92 | wxCoord y, wxCoord x1, wxCoord x2); | |
93 | ||
94 | virtual void DrawVerticalLine(wxDC& dc, | |
95 | wxCoord x, wxCoord y1, wxCoord y2); | |
96 | ||
97 | virtual void DrawFrame(wxDC& dc, | |
98 | const wxString& label, | |
99 | const wxRect& rect, | |
100 | int flags = 0, | |
101 | int alignment = wxALIGN_LEFT, | |
102 | int indexAccel = -1); | |
103 | ||
104 | virtual void DrawArrow(wxDC& dc, | |
105 | wxDirection dir, | |
106 | const wxRect& rect, | |
107 | int flags = 0); | |
108 | ||
109 | virtual void DrawScrollbarArrow(wxDC& dc, | |
110 | wxDirection dir, | |
111 | const wxRect& rect, | |
112 | int flags = 0); | |
113 | ||
114 | virtual void DrawScrollbarThumb(wxDC& dc, | |
115 | wxOrientation orient, | |
116 | const wxRect& rect, | |
117 | int flags = 0); | |
118 | ||
119 | virtual void DrawScrollbarShaft(wxDC& dc, | |
120 | wxOrientation orient, | |
121 | const wxRect& rect, | |
122 | int flags = 0); | |
123 | ||
124 | virtual void DrawScrollCorner(wxDC& dc, | |
125 | const wxRect& rect); | |
126 | ||
127 | virtual void DrawItem(wxDC& dc, | |
128 | const wxString& label, | |
129 | const wxRect& rect, | |
130 | int flags = 0); | |
131 | ||
132 | virtual void DrawCheckItem(wxDC& dc, | |
133 | const wxString& label, | |
134 | const wxBitmap& bitmap, | |
135 | const wxRect& rect, | |
136 | int flags = 0); | |
137 | ||
138 | virtual void DrawCheckButton(wxDC& dc, | |
139 | const wxString& label, | |
140 | const wxBitmap& bitmap, | |
141 | const wxRect& rect, | |
142 | int flags = 0, | |
143 | wxAlignment align = wxALIGN_LEFT, | |
144 | int indexAccel = -1); | |
145 | ||
146 | virtual void DrawRadioButton(wxDC& dc, | |
147 | const wxString& label, | |
148 | const wxBitmap& bitmap, | |
149 | const wxRect& rect, | |
150 | int flags = 0, | |
151 | wxAlignment align = wxALIGN_LEFT, | |
152 | int indexAccel = -1); | |
153 | ||
154 | #if wxUSE_TOOLBAR | |
155 | virtual void DrawToolBarButton(wxDC& dc, | |
156 | const wxString& label, | |
157 | const wxBitmap& bitmap, | |
158 | const wxRect& rect, | |
159 | int flags = 0, | |
160 | long style = 0, | |
161 | int tbarStyle = 0); | |
162 | #endif // wxUSE_TOOLBAR | |
163 | ||
164 | #if wxUSE_TEXTCTRL | |
165 | virtual void DrawTextLine(wxDC& dc, | |
166 | const wxString& text, | |
167 | const wxRect& rect, | |
168 | int selStart = -1, | |
169 | int selEnd = -1, | |
170 | int flags = 0); | |
171 | ||
172 | virtual void DrawLineWrapMark(wxDC& dc, const wxRect& rect); | |
173 | #endif // wxUSE_TEXTCTRL | |
174 | ||
175 | #if wxUSE_NOTEBOOK | |
176 | virtual void DrawTab(wxDC& dc, | |
177 | const wxRect& rect, | |
178 | wxDirection dir, | |
179 | const wxString& label, | |
180 | const wxBitmap& bitmap = wxNullBitmap, | |
181 | int flags = 0, | |
182 | int indexAccel = -1); | |
183 | #endif // wxUSE_NOTEBOOK | |
184 | ||
185 | #if wxUSE_SLIDER | |
186 | ||
187 | virtual void DrawSliderShaft(wxDC& dc, | |
188 | const wxRect& rect, | |
189 | int lenThumb, | |
190 | wxOrientation orient, | |
191 | int flags = 0, | |
192 | long style = 0, | |
193 | wxRect *rectShaft = NULL); | |
194 | ||
195 | virtual void DrawSliderThumb(wxDC& dc, | |
196 | const wxRect& rect, | |
197 | wxOrientation orient, | |
198 | int flags = 0, | |
199 | long style = 0); | |
200 | ||
201 | virtual void DrawSliderTicks(wxDC& dc, | |
202 | const wxRect& rect, | |
203 | int lenThumb, | |
204 | wxOrientation orient, | |
205 | int start, | |
206 | int end, | |
207 | int step = 1, | |
208 | int flags = 0, | |
209 | long style = 0); | |
210 | #endif // wxUSE_SLIDER | |
211 | ||
212 | #if wxUSE_MENUS | |
213 | virtual void DrawMenuBarItem(wxDC& dc, | |
214 | const wxRect& rect, | |
215 | const wxString& label, | |
216 | int flags = 0, | |
217 | int indexAccel = -1); | |
218 | ||
219 | virtual void DrawMenuItem(wxDC& dc, | |
220 | wxCoord y, | |
221 | const wxMenuGeometryInfo& geometryInfo, | |
222 | const wxString& label, | |
223 | const wxString& accel, | |
224 | const wxBitmap& bitmap = wxNullBitmap, | |
225 | int flags = 0, | |
226 | int indexAccel = -1); | |
227 | ||
228 | virtual void DrawMenuSeparator(wxDC& dc, | |
229 | wxCoord y, | |
230 | const wxMenuGeometryInfo& geomInfo); | |
231 | #endif // wxUSE_MENUS | |
232 | ||
233 | #if wxUSE_STATUSBAR | |
234 | virtual void DrawStatusField(wxDC& dc, | |
235 | const wxRect& rect, | |
236 | const wxString& label, | |
237 | int flags = 0, int style = 0); | |
238 | #endif // wxUSE_STATUSBAR | |
239 | ||
240 | virtual void DrawFrameTitleBar(wxDC& dc, | |
241 | const wxRect& rect, | |
242 | const wxString& title, | |
243 | const wxIcon& icon, | |
244 | int flags, | |
245 | int specialButton = 0, | |
246 | int specialButtonFlags = 0); | |
247 | ||
248 | virtual void DrawFrameBorder(wxDC& dc, | |
249 | const wxRect& rect, | |
250 | int flags); | |
251 | ||
252 | virtual void DrawFrameBackground(wxDC& dc, | |
253 | const wxRect& rect, | |
254 | int flags); | |
255 | ||
256 | virtual void DrawFrameTitle(wxDC& dc, | |
257 | const wxRect& rect, | |
258 | const wxString& title, | |
259 | int flags); | |
260 | ||
261 | virtual void DrawFrameIcon(wxDC& dc, | |
262 | const wxRect& rect, | |
263 | const wxIcon& icon, | |
264 | int flags); | |
265 | ||
266 | virtual void DrawFrameButton(wxDC& dc, | |
267 | wxCoord x, wxCoord y, | |
268 | int button, | |
269 | int flags = 0); | |
270 | ||
271 | ||
272 | virtual void GetComboBitmaps(wxBitmap *bmpNormal, | |
273 | wxBitmap *bmpFocus, | |
274 | wxBitmap *bmpPressed, | |
275 | wxBitmap *bmpDisabled); | |
276 | ||
277 | ||
278 | virtual wxRect GetBorderDimensions(wxBorder border) const; | |
279 | ||
280 | virtual bool AreScrollbarsInsideBorder() const; | |
281 | ||
282 | virtual void AdjustSize(wxSize *size, const wxWindow *window); | |
283 | ||
284 | #if wxUSE_SCROLLBAR | |
285 | ||
286 | virtual wxSize GetScrollbarArrowSize() const; | |
287 | ||
288 | virtual wxRect GetScrollbarRect(const wxScrollBar *scrollbar, | |
289 | wxScrollBar::Element elem, | |
290 | int thumbPos = -1) const; | |
291 | ||
292 | virtual wxCoord GetScrollbarSize(const wxScrollBar *scrollbar); | |
293 | ||
294 | virtual wxHitTest HitTestScrollbar(const wxScrollBar *scrollbar, | |
295 | const wxPoint& pt) const; | |
296 | ||
297 | virtual wxCoord ScrollbarToPixel(const wxScrollBar *scrollbar, | |
298 | int thumbPos = -1); | |
299 | virtual int PixelToScrollbar(const wxScrollBar *scrollbar, | |
300 | wxCoord coord); | |
301 | ||
302 | #endif // wxUSE_SCROLLBAR | |
303 | ||
304 | virtual wxCoord GetListboxItemHeight(wxCoord fontHeight); | |
305 | ||
306 | virtual wxSize GetCheckBitmapSize() const; | |
307 | virtual wxSize GetRadioBitmapSize() const; | |
308 | virtual wxCoord GetCheckItemMargin() const; | |
309 | ||
310 | virtual wxSize GetToolBarButtonSize(wxCoord *separator) const; | |
311 | ||
312 | virtual wxSize GetToolBarMargin() const; | |
313 | ||
314 | #if wxUSE_TEXTCTRL | |
315 | virtual wxRect GetTextTotalArea(const wxTextCtrl *text, | |
316 | const wxRect& rectText) const; | |
317 | ||
318 | virtual wxRect GetTextClientArea(const wxTextCtrl *text, | |
319 | const wxRect& rectTotal, | |
320 | wxCoord *extraSpaceBeyond) const; | |
321 | #endif // wxUSE_TEXTCTRL | |
322 | ||
323 | #if wxUSE_NOTEBOOK | |
324 | virtual wxSize GetTabIndent() const; | |
325 | ||
326 | virtual wxSize GetTabPadding() const; | |
327 | #endif // wxUSE_NOTEBOOK | |
328 | ||
329 | #if wxUSE_SLIDER | |
330 | virtual wxCoord GetSliderDim() const; | |
331 | ||
332 | virtual wxCoord GetSliderTickLen() const; | |
333 | ||
334 | virtual wxRect GetSliderShaftRect(const wxRect& rect, | |
335 | int lenThumb, | |
336 | wxOrientation orient, | |
337 | long style = 0) const; | |
338 | ||
339 | virtual wxSize GetSliderThumbSize(const wxRect& rect, | |
340 | int lenThumb, | |
341 | wxOrientation orient) const; | |
342 | #endif // wxUSE_SLIDER | |
343 | ||
344 | virtual wxSize GetProgressBarStep() const; | |
345 | ||
346 | #if wxUSE_MENUS | |
347 | virtual wxSize GetMenuBarItemSize(const wxSize& sizeText) const; | |
348 | ||
349 | virtual wxMenuGeometryInfo *GetMenuGeometry(wxWindow *win, | |
350 | const wxMenu& menu) const; | |
351 | #endif // wxUSE_MENUS | |
352 | ||
353 | #if wxUSE_STATUSBAR | |
354 | virtual wxSize GetStatusBarBorders(wxCoord *borderBetweenFields) const; | |
355 | #endif // wxUSE_STATUSBAR | |
356 | ||
357 | virtual wxRect GetFrameClientArea(const wxRect& rect, int flags) const; | |
358 | ||
359 | virtual wxSize GetFrameTotalSize(const wxSize& clientSize, int flags) const; | |
360 | ||
361 | virtual wxSize GetFrameMinSize(int flags) const; | |
362 | ||
363 | virtual wxSize GetFrameIconSize() const; | |
364 | ||
365 | virtual int HitTestFrame(const wxRect& rect, | |
366 | const wxPoint& pt, | |
367 | int flags = 0) const; | |
368 | ||
369 | protected: | |
370 | // draw the background with any colour, not only the default one(s) | |
371 | void DoDrawBackground(wxDC& dc, | |
372 | const wxColour& col, | |
373 | const wxRect& rect, | |
374 | wxWindow *window = NULL); | |
375 | ||
376 | // DrawBorder() helpers: all of them shift and clip the DC after drawing | |
377 | // the border | |
378 | ||
379 | // just draw a rectangle with the given pen | |
380 | void DrawRect(wxDC& dc, wxRect *rect, const wxPen& pen); | |
381 | ||
382 | // draw an opened rect for the arrow in given direction | |
383 | void DrawArrowBorder(wxDC& dc, | |
384 | wxRect *rect, | |
385 | wxDirection dir); | |
386 | ||
387 | // draw two sides of the rectangle | |
388 | void DrawThumbBorder(wxDC& dc, | |
389 | wxRect *rect, | |
390 | wxOrientation orient); | |
391 | ||
392 | #if wxUSE_SCROLLBAR | |
393 | // returns the size of the arrow for the scrollbar (depends on | |
394 | // orientation) | |
395 | wxSize GetScrollbarArrowSize(const wxScrollBar *scrollbar) const | |
396 | { | |
397 | wxSize size; | |
398 | if ( scrollbar->IsVertical() ) | |
399 | { | |
400 | size = m_sizeScrollbarArrow; | |
401 | } | |
402 | else | |
403 | { | |
404 | size.x = m_sizeScrollbarArrow.y; | |
405 | size.y = m_sizeScrollbarArrow.x; | |
406 | } | |
407 | ||
408 | return size; | |
409 | } | |
410 | #endif // wxUSE_SCROLLBAR | |
411 | ||
412 | // DrawCheckBitmap and DrawRadioBitmap helpers | |
413 | ||
414 | // draw the check bitmaps once and cache them for later use | |
415 | wxBitmap GetCheckBitmap(int flags); | |
416 | ||
417 | // draw a /\ or \/ line from (x1, y1) to (x2, y1) passing by the point | |
418 | // ((x1 + x2)/2, y2) | |
419 | void DrawUpZag(wxDC& dc, | |
420 | wxCoord x1, wxCoord x2, | |
421 | wxCoord y1, wxCoord y2); | |
422 | void DrawDownZag(wxDC& dc, | |
423 | wxCoord x1, wxCoord x2, | |
424 | wxCoord y1, wxCoord y2); | |
425 | ||
426 | // draw the radio button bitmap for the given state | |
427 | void DrawRadioBitmap(wxDC& dc, const wxRect& rect, int flags); | |
428 | ||
429 | // draw check/radio - the bitmap must be a valid one by now | |
430 | void DoDrawCheckOrRadioBitmap(wxDC& dc, | |
431 | const wxString& label, | |
432 | const wxBitmap& bitmap, | |
433 | const wxRect& rectTotal, | |
434 | int flags, | |
435 | wxAlignment align, | |
436 | int indexAccel); | |
437 | ||
438 | // common part of DrawMenuItem() and DrawMenuBarItem() | |
439 | void DoDrawMenuItem(wxDC& dc, | |
440 | const wxRect& rect, | |
441 | const wxString& label, | |
442 | int flags, | |
443 | int indexAccel, | |
444 | const wxString& accel = wxEmptyString, | |
445 | const wxBitmap& bitmap = wxNullBitmap, | |
446 | const wxMonoMenuGeometryInfo *geometryInfo = NULL); | |
447 | ||
448 | #if wxUSE_COMBOBOX | |
449 | // initialize the combo bitmaps | |
450 | void InitComboBitmaps(); | |
451 | #endif // wxUSE_COMBOBOX | |
452 | ||
453 | private: | |
454 | // data | |
455 | wxSize m_sizeScrollbarArrow; | |
456 | ||
457 | // the checkbox bitmaps: first row is for the normal, second for the | |
458 | // pressed state and the columns are for checked, unchecked and | |
459 | // undeterminated respectively | |
460 | wxBitmap m_bitmapsCheckbox[2][3]; | |
461 | ||
462 | // the combobox bitmaps | |
463 | enum | |
464 | { | |
465 | ComboState_Normal, | |
466 | ComboState_Focus, | |
467 | ComboState_Pressed, | |
468 | ComboState_Disabled, | |
469 | ComboState_Max | |
470 | }; | |
471 | ||
472 | wxBitmap m_bitmapsCombo[ComboState_Max]; | |
473 | }; | |
474 | ||
475 | // ---------------------------------------------------------------------------- | |
476 | // wxMonoInputHandler | |
477 | // ---------------------------------------------------------------------------- | |
478 | ||
479 | class wxMonoInputHandler : public wxInputHandler | |
480 | { | |
481 | public: | |
482 | wxMonoInputHandler(wxMonoRenderer *renderer); | |
483 | ||
484 | virtual bool HandleKey(wxInputConsumer *control, | |
485 | const wxKeyEvent& event, | |
486 | bool pressed); | |
487 | virtual bool HandleMouse(wxInputConsumer *control, | |
488 | const wxMouseEvent& event); | |
489 | virtual bool HandleMouseMove(wxInputConsumer *control, const wxMouseEvent& event); | |
490 | ||
491 | protected: | |
492 | wxMonoRenderer *m_renderer; | |
493 | }; | |
494 | ||
495 | // ---------------------------------------------------------------------------- | |
496 | // wxMonoColourScheme: uses just white and black | |
497 | // ---------------------------------------------------------------------------- | |
498 | ||
499 | class wxMonoColourScheme : public wxColourScheme | |
500 | { | |
501 | public: | |
502 | // we use only 2 colours, white and black, but we avoid referring to them | |
503 | // like this, instead use the functions below | |
504 | wxColour GetFg() const { return wxMONO_FG_COL; } | |
505 | wxColour GetBg() const { return wxMONO_BG_COL; } | |
506 | ||
507 | // implement base class pure virtuals | |
508 | virtual wxColour Get(StdColour col) const; | |
509 | virtual wxColour GetBackground(wxWindow *win) const; | |
510 | }; | |
511 | ||
512 | // ---------------------------------------------------------------------------- | |
513 | // wxMonoArtProvider | |
514 | // ---------------------------------------------------------------------------- | |
515 | ||
516 | class wxMonoArtProvider : public wxArtProvider | |
517 | { | |
518 | protected: | |
519 | virtual wxBitmap CreateBitmap(const wxArtID& id, | |
520 | const wxArtClient& client, | |
521 | const wxSize& size); | |
522 | }; | |
523 | ||
524 | // ---------------------------------------------------------------------------- | |
525 | // wxMonoTheme | |
526 | // ---------------------------------------------------------------------------- | |
527 | ||
528 | WX_DEFINE_ARRAY_PTR(wxInputHandler *, wxArrayHandlers); | |
529 | ||
530 | class wxMonoTheme : public wxTheme | |
531 | { | |
532 | public: | |
533 | wxMonoTheme(); | |
534 | virtual ~wxMonoTheme(); | |
535 | ||
536 | virtual wxRenderer *GetRenderer(); | |
537 | virtual wxArtProvider *GetArtProvider(); | |
538 | virtual wxInputHandler *GetInputHandler(const wxString& control); | |
539 | virtual wxColourScheme *GetColourScheme(); | |
540 | ||
541 | private: | |
542 | wxMonoRenderer *m_renderer; | |
543 | wxMonoArtProvider *m_artProvider; | |
544 | wxMonoColourScheme *m_scheme; | |
545 | ||
546 | WX_DECLARE_THEME(gtk) | |
547 | }; | |
548 | ||
549 | // ============================================================================ | |
550 | // implementation | |
551 | // ============================================================================ | |
552 | ||
553 | WX_IMPLEMENT_THEME(wxMonoTheme, mono, wxTRANSLATE("Simple monochrome theme")); | |
554 | ||
555 | // ---------------------------------------------------------------------------- | |
556 | // wxMonoTheme | |
557 | // ---------------------------------------------------------------------------- | |
558 | ||
559 | wxMonoTheme::wxMonoTheme() | |
560 | { | |
561 | m_scheme = NULL; | |
562 | m_renderer = NULL; | |
563 | m_artProvider = NULL; | |
564 | } | |
565 | ||
566 | wxMonoTheme::~wxMonoTheme() | |
567 | { | |
568 | delete m_renderer; | |
569 | delete m_scheme; | |
570 | wxArtProvider::RemoveProvider(m_artProvider); | |
571 | } | |
572 | ||
573 | wxRenderer *wxMonoTheme::GetRenderer() | |
574 | { | |
575 | if ( !m_renderer ) | |
576 | { | |
577 | m_renderer = new wxMonoRenderer(GetColourScheme()); | |
578 | } | |
579 | ||
580 | return m_renderer; | |
581 | } | |
582 | ||
583 | wxArtProvider *wxMonoTheme::GetArtProvider() | |
584 | { | |
585 | if ( !m_artProvider ) | |
586 | { | |
587 | m_artProvider = new wxMonoArtProvider; | |
588 | } | |
589 | ||
590 | return m_artProvider; | |
591 | } | |
592 | ||
593 | wxColourScheme *wxMonoTheme::GetColourScheme() | |
594 | { | |
595 | if ( !m_scheme ) | |
596 | { | |
597 | m_scheme = new wxMonoColourScheme; | |
598 | } | |
599 | ||
600 | return m_scheme; | |
601 | } | |
602 | ||
603 | wxInputHandler *wxMonoTheme::GetInputHandler(const wxString& WXUNUSED(control), | |
604 | wxInputConsumer *consumer) | |
605 | { | |
606 | // no special input handlers so far | |
607 | return consumer->DoGetStdInputHandler(NULL); | |
608 | } | |
609 | ||
610 | // ============================================================================ | |
611 | // wxMonoColourScheme | |
612 | // ============================================================================ | |
613 | ||
614 | wxColour wxMonoColourScheme::GetBackground(wxWindow *win) const | |
615 | { | |
616 | wxColour col; | |
617 | if ( win->UseBgCol() ) | |
618 | { | |
619 | // use the user specified colour | |
620 | col = win->GetBackgroundColour(); | |
621 | } | |
622 | ||
623 | // doesn't depend on the state | |
624 | if ( !col.Ok() ) | |
625 | { | |
626 | col = GetBg(); | |
627 | } | |
628 | } | |
629 | ||
630 | wxColour wxMonoColourScheme::Get(wxMonoColourScheme::StdColour col) const | |
631 | { | |
632 | switch ( col ) | |
633 | { | |
634 | case WINDOW: | |
635 | case CONTROL: | |
636 | case CONTROL_PRESSED: | |
637 | case CONTROL_CURRENT: | |
638 | case SCROLLBAR: | |
639 | case SCROLLBAR_PRESSED: | |
640 | case GAUGE: | |
641 | case HIGHLIGHT: | |
642 | case TITLEBAR: | |
643 | case TITLEBAR_ACTIVE: | |
644 | case DESKTOP: | |
645 | return GetBg(); | |
646 | ||
647 | case MAX: | |
648 | default: | |
649 | wxFAIL_MSG(_T("invalid standard colour")); | |
650 | // fall through | |
651 | ||
652 | case SHADOW_DARK: | |
653 | case SHADOW_HIGHLIGHT: | |
654 | case SHADOW_IN: | |
655 | case SHADOW_OUT: | |
656 | case CONTROL_TEXT: | |
657 | case CONTROL_TEXT_DISABLED: | |
658 | case CONTROL_TEXT_DISABLED_SHADOW: | |
659 | case HIGHLIGHT_TEXT: | |
660 | case TITLEBAR_TEXT: | |
661 | case TITLEBAR_ACTIVE_TEXT: | |
662 | return GetFg(); | |
663 | ||
664 | } | |
665 | } | |
666 | ||
667 | // ============================================================================ | |
668 | // wxMonoRenderer | |
669 | // ============================================================================ | |
670 | ||
671 | // ---------------------------------------------------------------------------- | |
672 | // construction | |
673 | // ---------------------------------------------------------------------------- | |
674 | ||
675 | wxMonoRenderer::wxMonoRenderer(const wxColourScheme *scheme) | |
676 | : wxStdRenderer(scheme) | |
677 | { | |
678 | m_penFg = wxPen(wxSCHEME_COLOUR(scheme, SHADOW_OUT)); | |
679 | } | |
680 | ||
681 | // ---------------------------------------------------------------------------- | |
682 | // border stuff | |
683 | // ---------------------------------------------------------------------------- | |
684 | ||
685 | // ---------------------------------------------------------------------------- | |
686 | // special borders | |
687 | // ---------------------------------------------------------------------------- | |
688 | ||
689 | void wxMonoRenderer::DrawTextBorder(wxDC& dc, | |
690 | wxBorder border, | |
691 | const wxRect& rectOrig, | |
692 | int flags, | |
693 | wxRect *rectIn) | |
694 | { | |
695 | DrawBorder(dc, border, rectOrig, flags, rectIn); | |
696 | } | |
697 | ||
698 | void wxMonoRenderer::DrawButtonBorder(wxDC& dc, | |
699 | const wxRect& rectTotal, | |
700 | int flags, | |
701 | wxRect *rectIn) | |
702 | { | |
703 | DrawBorder(dc, wxBORDER_SIMPLE, rectOrig, flags, rectIn); | |
704 | } | |
705 | ||
706 | // ---------------------------------------------------------------------------- | |
707 | // lines and frames | |
708 | // ---------------------------------------------------------------------------- | |
709 | ||
710 | void | |
711 | wxMonoRenderer::DrawHorizontalLine(wxDC& dc, wxCoord y, wxCoord x1, wxCoord x2) | |
712 | { | |
713 | dc.SetPen(m_penFg); | |
714 | dc.DrawLine(x1, y, x2 + 1, y); | |
715 | } | |
716 | ||
717 | void | |
718 | wxMonoRenderer::DrawVerticalLine(wxDC& dc, wxCoord x, wxCoord y1, wxCoord y2) | |
719 | { | |
720 | dc.SetPen(m_penFg); | |
721 | dc.DrawLine(x, y1, x, y2 + 1); | |
722 | } | |
723 | ||
724 | void wxMonoRenderer::DrawFrame(wxDC& dc, | |
725 | const wxString& label, | |
726 | const wxRect& rect, | |
727 | int flags, | |
728 | int alignment, | |
729 | int indexAccel) | |
730 | { | |
731 | wxCoord height = 0; // of the label | |
732 | wxRect rectFrame = rect; | |
733 | if ( !label.empty() ) | |
734 | { | |
735 | // the text should touch the top border of the rect, so the frame | |
736 | // itself should be lower | |
737 | dc.GetTextExtent(label, NULL, &height); | |
738 | rectFrame.y += height / 2; | |
739 | rectFrame.height -= height / 2; | |
740 | ||
741 | // TODO: the +4 should be customizable | |
742 | ||
743 | wxRect rectText; | |
744 | rectText.x = rectFrame.x + 4; | |
745 | rectText.y = rect.y; | |
746 | rectText.width = rectFrame.width - 8; | |
747 | rectText.height = height; | |
748 | ||
749 | wxRect rectLabel; | |
750 | DrawLabel(dc, label, rectText, flags, alignment, indexAccel, &rectLabel); | |
751 | rectLabel.x -= 1; | |
752 | rectLabel.width += 2; | |
753 | ||
754 | StandardDrawFrame(dc, rectFrame, rectLabel); | |
755 | } | |
756 | else // no label | |
757 | { | |
758 | // just draw the complete frame | |
759 | DrawShadedRect(dc, &rectFrame, m_penDarkGrey, m_penHighlight); | |
760 | DrawShadedRect(dc, &rectFrame, m_penHighlight, m_penDarkGrey); | |
761 | } | |
762 | } | |
763 | ||
764 | // ---------------------------------------------------------------------------- | |
765 | // label | |
766 | // ---------------------------------------------------------------------------- | |
767 | ||
768 | void wxMonoRenderer::DrawLabel(wxDC& dc, | |
769 | const wxString& label, | |
770 | const wxRect& rect, | |
771 | int flags, | |
772 | int alignment, | |
773 | int indexAccel, | |
774 | wxRect *rectBounds) | |
775 | { | |
776 | DrawButtonLabel(dc, label, wxNullBitmap, rect, flags, | |
777 | alignment, indexAccel, rectBounds); | |
778 | } | |
779 | ||
780 | void wxMonoRenderer::DrawButtonLabel(wxDC& dc, | |
781 | const wxString& label, | |
782 | const wxBitmap& image, | |
783 | const wxRect& rect, | |
784 | int flags, | |
785 | int alignment, | |
786 | int indexAccel, | |
787 | wxRect *rectBounds) | |
788 | { | |
789 | dc.SetTextForeground(wxSCHEME_COLOUR(m_scheme, CONTROL_TEXT)); | |
790 | dc.DrawLabel(label, image, rect, alignment, indexAccel, rectBounds); | |
791 | ||
792 | if ( flags & wxCONTROL_DISABLED ) | |
793 | { | |
794 | // this is ugly but I don't know how to show disabled button visually | |
795 | // in monochrome theme otherwise | |
796 | dc.SetPen(m_penFg); | |
797 | dc.DrawLine(rect.GetTopLeft(), rect.GetBottomRight()); | |
798 | dc.DrawLine(rect.GetTopRight(), rect.GetBottomLeft()); | |
799 | } | |
800 | } | |
801 | ||
802 | void wxMonoRenderer::DrawItem(wxDC& dc, | |
803 | const wxString& label, | |
804 | const wxRect& rect, | |
805 | int flags) | |
806 | { | |
807 | wxColour colFg; | |
808 | if ( flags & wxCONTROL_SELECTED ) | |
809 | { | |
810 | dc.SetBrush(wxBrush(wxSCHEME_COLOUR(m_scheme, HIGHLIGHT), wxSOLID)); | |
811 | dc.SetPen(*wxTRANSPARENT_PEN); | |
812 | dc.DrawRectangle(rect); | |
813 | ||
814 | colFg = dc.GetTextForeground(); | |
815 | dc.SetTextForeground(wxSCHEME_COLOUR(m_scheme, HIGHLIGHT_TEXT)); | |
816 | } | |
817 | ||
818 | if ( flags & wxCONTROL_FOCUSED ) | |
819 | { | |
820 | dc.SetBrush(*wxTRANSPARENT_BRUSH); | |
821 | wxRect rectFocus = rect; | |
822 | DrawRect(dc, &rectFocus, m_penBlack); | |
823 | } | |
824 | ||
825 | wxRect rectText = rect; | |
826 | rectText.x += 2; | |
827 | rectText.y++; | |
828 | dc.DrawLabel(label, wxNullBitmap, rectText); | |
829 | ||
830 | if ( flags & wxCONTROL_SELECTED ) | |
831 | { | |
832 | dc.SetBackgroundMode(wxTRANSPARENT); | |
833 | } | |
834 | ||
835 | // restore the text colour | |
836 | if ( colFg.Ok() ) | |
837 | { | |
838 | dc.SetTextForeground(colFg); | |
839 | } | |
840 | } | |
841 | ||
842 | void wxMonoRenderer::DrawCheckItem(wxDC& dc, | |
843 | const wxString& label, | |
844 | const wxBitmap& bitmap, | |
845 | const wxRect& rect, | |
846 | int flags) | |
847 | { | |
848 | wxRect rectBitmap = rect; | |
849 | rectBitmap.x -= 1; | |
850 | rectBitmap.width = GetCheckBitmapSize().x; | |
851 | ||
852 | // never draw the focus rect around the check indicators here | |
853 | DrawCheckButton(dc, wxEmptyString, bitmap, rectBitmap, flags & ~wxCONTROL_FOCUSED); | |
854 | ||
855 | wxRect rectLabel = rect; | |
856 | wxCoord shift = rectBitmap.width + 2*GetCheckItemMargin(); | |
857 | rectLabel.x += shift; | |
858 | rectLabel.width -= shift; | |
859 | DrawItem(dc, label, rectLabel, flags); | |
860 | } | |
861 | ||
862 | // ---------------------------------------------------------------------------- | |
863 | // check/radion buttons | |
864 | // ---------------------------------------------------------------------------- | |
865 | ||
866 | void wxMonoRenderer::DrawUndeterminedBitmap(wxDC& dc, | |
867 | const wxRect& rectTotal, | |
868 | bool isPressed) | |
869 | { | |
870 | // FIXME: For sure it is not Mono look but it is better than nothing. | |
871 | // Show me correct look and I will immediatelly make it better (ABX) | |
872 | wxRect rect = rectTotal; | |
873 | ||
874 | wxColour col1, col2; | |
875 | ||
876 | if ( isPressed ) | |
877 | { | |
878 | col1 = wxSCHEME_COLOUR(m_scheme, SHADOW_DARK); | |
879 | col2 = wxSCHEME_COLOUR(m_scheme, CONTROL_PRESSED); | |
880 | } | |
881 | else | |
882 | { | |
883 | col1 = wxSCHEME_COLOUR(m_scheme, SHADOW_DARK); | |
884 | col2 = wxSCHEME_COLOUR(m_scheme, SHADOW_IN); | |
885 | } | |
886 | ||
887 | dc.SetPen(*wxTRANSPARENT_PEN); | |
888 | dc.SetBrush(wxBrush(col1, wxSOLID)); | |
889 | dc.DrawRectangle(rect); | |
890 | rect.Deflate(1); | |
891 | dc.SetBrush(wxBrush(col2, wxSOLID)); | |
892 | dc.DrawRectangle(rect); | |
893 | } | |
894 | ||
895 | void wxMonoRenderer::DrawUncheckBitmap(wxDC& dc, | |
896 | const wxRect& rectTotal, | |
897 | bool isPressed) | |
898 | { | |
899 | wxRect rect = rectTotal; | |
900 | DrawAntiRaisedBorder(dc, &rect); | |
901 | ||
902 | wxColour col = wxSCHEME_COLOUR(m_scheme, SHADOW_IN); | |
903 | dc.SetPen(wxPen(col, 0, wxSOLID)); | |
904 | dc.DrawPoint(rect.GetRight() - 1, rect.GetBottom() - 1); | |
905 | ||
906 | if ( isPressed ) | |
907 | col = wxSCHEME_COLOUR(m_scheme, CONTROL_PRESSED); | |
908 | //else: it is SHADOW_IN, leave as is | |
909 | ||
910 | dc.SetPen(*wxTRANSPARENT_PEN); | |
911 | dc.SetBrush(wxBrush(col, wxSOLID)); | |
912 | dc.DrawRectangle(rect); | |
913 | } | |
914 | ||
915 | void wxMonoRenderer::DrawCheckBitmap(wxDC& dc, const wxRect& rectTotal) | |
916 | { | |
917 | wxRect rect = rectTotal; | |
918 | DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight); | |
919 | DrawShadedRect(dc, &rect, m_penBlack, m_penLightGrey); | |
920 | ||
921 | dc.SetPen(*wxTRANSPARENT_PEN); | |
922 | dc.SetBrush(wxBrush(wxSCHEME_COLOUR(m_scheme, CONTROL_PRESSED), wxSOLID)); | |
923 | dc.DrawRectangle(rect); | |
924 | } | |
925 | ||
926 | void wxMonoRenderer::DrawRadioBitmap(wxDC& dc, | |
927 | const wxRect& rect, | |
928 | int flags) | |
929 | { | |
930 | wxCoord x = rect.x, | |
931 | y = rect.y, | |
932 | xRight = rect.GetRight(), | |
933 | yBottom = rect.GetBottom(); | |
934 | ||
935 | wxCoord yMid = (y + yBottom) / 2; | |
936 | ||
937 | // this looks ugly when the background colour of the control is not the | |
938 | // same ours - radiobox is not transparent as it should be | |
939 | #if 0 | |
940 | // first fill the middle: as FloodFill() is not implemented on all | |
941 | // platforms, this is the only thing to do | |
942 | wxColour colBg = flags & wxCONTROL_CURRENT | |
943 | ? wxSCHEME_COLOUR(m_scheme, CONTROL_CURRENT) | |
944 | : wxSCHEME_COLOUR(m_scheme, SHADOW_IN); | |
945 | dc.SetBrush(wxBrush(colBg, wxSOLID)); | |
946 | dc.SetPen(*wxTRANSPARENT_PEN); | |
947 | dc.DrawRectangle(rect); | |
948 | #endif // 0 | |
949 | ||
950 | // then draw the upper half | |
951 | dc.SetPen(flags & wxCONTROL_CHECKED ? m_penDarkGrey : m_penHighlight); | |
952 | DrawUpZag(dc, x, xRight, yMid, y); | |
953 | DrawUpZag(dc, x + 1, xRight - 1, yMid, y + 1); | |
954 | ||
955 | bool drawIt = true; | |
956 | if ( flags & wxCONTROL_CHECKED ) | |
957 | dc.SetPen(m_penBlack); | |
958 | else if ( flags & wxCONTROL_PRESSED ) | |
959 | dc.SetPen(wxPen(wxSCHEME_COLOUR(m_scheme, CONTROL_PRESSED), 0, wxSOLID)); | |
960 | else // unchecked and unpressed | |
961 | drawIt = false; | |
962 | ||
963 | if ( drawIt ) | |
964 | DrawUpZag(dc, x + 2, xRight - 2, yMid, y + 2); | |
965 | ||
966 | // and then the lower one | |
967 | dc.SetPen(flags & wxCONTROL_CHECKED ? m_penHighlight : m_penBlack); | |
968 | DrawDownZag(dc, x, xRight, yMid, yBottom); | |
969 | if ( !(flags & wxCONTROL_CHECKED) ) | |
970 | dc.SetPen(m_penDarkGrey); | |
971 | DrawDownZag(dc, x + 1, xRight - 1, yMid, yBottom - 1); | |
972 | ||
973 | if ( !(flags & wxCONTROL_CHECKED) ) | |
974 | drawIt = true; // with the same pen | |
975 | else if ( flags & wxCONTROL_PRESSED ) | |
976 | { | |
977 | dc.SetPen(wxPen(wxSCHEME_COLOUR(m_scheme, CONTROL_PRESSED), 0, wxSOLID)); | |
978 | drawIt = true; | |
979 | } | |
980 | else // checked and unpressed | |
981 | drawIt = false; | |
982 | ||
983 | if ( drawIt ) | |
984 | DrawDownZag(dc, x + 2, xRight - 2, yMid, yBottom - 2); | |
985 | } | |
986 | ||
987 | void wxMonoRenderer::DrawUpZag(wxDC& dc, | |
988 | wxCoord x1, | |
989 | wxCoord x2, | |
990 | wxCoord y1, | |
991 | wxCoord y2) | |
992 | { | |
993 | wxCoord xMid = (x1 + x2) / 2; | |
994 | dc.DrawLine(x1, y1, xMid, y2); | |
995 | dc.DrawLine(xMid, y2, x2 + 1, y1 + 1); | |
996 | } | |
997 | ||
998 | void wxMonoRenderer::DrawDownZag(wxDC& dc, | |
999 | wxCoord x1, | |
1000 | wxCoord x2, | |
1001 | wxCoord y1, | |
1002 | wxCoord y2) | |
1003 | { | |
1004 | wxCoord xMid = (x1 + x2) / 2; | |
1005 | dc.DrawLine(x1 + 1, y1 + 1, xMid, y2); | |
1006 | dc.DrawLine(xMid, y2, x2, y1); | |
1007 | } | |
1008 | ||
1009 | wxBitmap wxMonoRenderer::GetCheckBitmap(int flags) | |
1010 | { | |
1011 | if ( !m_bitmapsCheckbox[0][0].Ok() ) | |
1012 | { | |
1013 | // init the bitmaps once only | |
1014 | wxRect rect; | |
1015 | wxSize size = GetCheckBitmapSize(); | |
1016 | rect.width = size.x; | |
1017 | rect.height = size.y; | |
1018 | for ( int i = 0; i < 2; i++ ) | |
1019 | { | |
1020 | for ( int j = 0; j < 3; j++ ) | |
1021 | m_bitmapsCheckbox[i][j].Create(rect.width, rect.height); | |
1022 | } | |
1023 | ||
1024 | wxMemoryDC dc; | |
1025 | ||
1026 | // normal checked | |
1027 | dc.SelectObject(m_bitmapsCheckbox[0][0]); | |
1028 | DrawCheckBitmap(dc, rect); | |
1029 | ||
1030 | // normal unchecked | |
1031 | dc.SelectObject(m_bitmapsCheckbox[0][1]); | |
1032 | DrawUncheckBitmap(dc, rect, false); | |
1033 | ||
1034 | // normal undeterminated | |
1035 | dc.SelectObject(m_bitmapsCheckbox[0][2]); | |
1036 | DrawUndeterminedBitmap(dc, rect, false); | |
1037 | ||
1038 | // pressed checked | |
1039 | m_bitmapsCheckbox[1][0] = m_bitmapsCheckbox[0][0]; | |
1040 | ||
1041 | // pressed unchecked | |
1042 | dc.SelectObject(m_bitmapsCheckbox[1][1]); | |
1043 | DrawUncheckBitmap(dc, rect, true); | |
1044 | ||
1045 | // pressed undeterminated | |
1046 | dc.SelectObject(m_bitmapsCheckbox[1][2]); | |
1047 | DrawUndeterminedBitmap(dc, rect, true); | |
1048 | } | |
1049 | ||
1050 | int row = flags & wxCONTROL_PRESSED | |
1051 | ? 1 | |
1052 | : 0; | |
1053 | int col = flags & wxCONTROL_CHECKED | |
1054 | ? 0 | |
1055 | : ( flags & wxCONTROL_UNDETERMINED | |
1056 | ? 2 | |
1057 | : 1 ); | |
1058 | ||
1059 | return m_bitmapsCheckbox[row][col]; | |
1060 | } | |
1061 | ||
1062 | void wxMonoRenderer::DrawCheckButton(wxDC& dc, | |
1063 | const wxString& label, | |
1064 | const wxBitmap& bitmapOrig, | |
1065 | const wxRect& rectTotal, | |
1066 | int flags, | |
1067 | wxAlignment align, | |
1068 | int indexAccel) | |
1069 | { | |
1070 | wxBitmap bitmap; | |
1071 | if ( bitmapOrig.Ok() ) | |
1072 | { | |
1073 | bitmap = bitmapOrig; | |
1074 | } | |
1075 | else | |
1076 | { | |
1077 | bitmap = GetCheckBitmap(flags); | |
1078 | } | |
1079 | ||
1080 | DoDrawCheckOrRadioBitmap(dc, label, bitmap, rectTotal, | |
1081 | flags, align, indexAccel); | |
1082 | } | |
1083 | ||
1084 | void wxMonoRenderer::DoDrawCheckOrRadioBitmap(wxDC& dc, | |
1085 | const wxString& label, | |
1086 | const wxBitmap& bitmap, | |
1087 | const wxRect& rectTotal, | |
1088 | int flags, | |
1089 | wxAlignment align, | |
1090 | int indexAccel) | |
1091 | { | |
1092 | wxRect rect = rectTotal; | |
1093 | ||
1094 | if ( flags & wxCONTROL_FOCUSED ) | |
1095 | { | |
1096 | // draw the focus border around everything | |
1097 | DrawRect(dc, &rect, m_penBlack); | |
1098 | } | |
1099 | else | |
1100 | { | |
1101 | // the border does not offset the string under Mono | |
1102 | rect.Inflate(-1); | |
1103 | } | |
1104 | ||
1105 | // calculate the position of the bitmap and of the label | |
1106 | wxCoord xBmp, | |
1107 | yBmp = rect.y + (rect.height - bitmap.GetHeight()) / 2; | |
1108 | ||
1109 | wxRect rectLabel; | |
1110 | dc.GetMultiLineTextExtent(label, NULL, &rectLabel.height); | |
1111 | rectLabel.y = rect.y + (rect.height - rectLabel.height) / 2; | |
1112 | ||
1113 | if ( align == wxALIGN_RIGHT ) | |
1114 | { | |
1115 | xBmp = rect.GetRight() - bitmap.GetWidth(); | |
1116 | rectLabel.x = rect.x + 2; | |
1117 | rectLabel.SetRight(xBmp); | |
1118 | } | |
1119 | else // normal (checkbox to the left of the text) case | |
1120 | { | |
1121 | xBmp = rect.x + 2; | |
1122 | rectLabel.x = xBmp + bitmap.GetWidth() + 4; | |
1123 | rectLabel.SetRight(rect.GetRight()); | |
1124 | } | |
1125 | ||
1126 | dc.DrawBitmap(bitmap, xBmp, yBmp, true /* use mask */); | |
1127 | ||
1128 | DrawLabel(dc, label, rectLabel, flags, | |
1129 | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL, indexAccel); | |
1130 | } | |
1131 | ||
1132 | void wxMonoRenderer::DrawRadioButton(wxDC& dc, | |
1133 | const wxString& label, | |
1134 | const wxBitmap& bitmapOrig, | |
1135 | const wxRect& rectTotal, | |
1136 | int flags, | |
1137 | wxAlignment align, | |
1138 | int indexAccel) | |
1139 | { | |
1140 | wxBitmap bitmap; | |
1141 | if ( bitmapOrig.Ok() ) | |
1142 | { | |
1143 | bitmap = bitmapOrig; | |
1144 | } | |
1145 | else | |
1146 | { | |
1147 | wxRect rect; | |
1148 | wxSize size = GetRadioBitmapSize(); | |
1149 | rect.width = size.x; | |
1150 | rect.height = size.y; | |
1151 | bitmap.Create(rect.width, rect.height); | |
1152 | wxMemoryDC dc; | |
1153 | dc.SelectObject(bitmap); | |
1154 | dc.SetBackground(*wxLIGHT_GREY_BRUSH); | |
1155 | dc.Clear(); | |
1156 | DrawRadioBitmap(dc, rect, flags); | |
1157 | ||
1158 | // must unselect the bitmap before setting a mask for it because of the | |
1159 | // MSW limitations | |
1160 | dc.SelectObject(wxNullBitmap); | |
1161 | bitmap.SetMask(new wxMask(bitmap, *wxLIGHT_GREY)); | |
1162 | } | |
1163 | ||
1164 | DoDrawCheckOrRadioBitmap(dc, label, bitmap, rectTotal, | |
1165 | flags, align, indexAccel); | |
1166 | } | |
1167 | ||
1168 | #if wxUSE_TOOLBAR | |
1169 | void wxMonoRenderer::DrawToolBarButton(wxDC& dc, | |
1170 | const wxString& label, | |
1171 | const wxBitmap& bitmap, | |
1172 | const wxRect& rectOrig, | |
1173 | int flags, | |
1174 | long WXUNUSED(style), | |
1175 | int tbarStyle) | |
1176 | { | |
1177 | // we don't draw the separators at all | |
1178 | if ( !label.empty() || bitmap.Ok() ) | |
1179 | { | |
1180 | wxRect rect = rectOrig; | |
1181 | rect.Deflate(BORDER_THICKNESS); | |
1182 | ||
1183 | if ( flags & wxCONTROL_PRESSED ) | |
1184 | { | |
1185 | DrawBorder(dc, wxBORDER_SUNKEN, rect, flags, &rect); | |
1186 | ||
1187 | DrawBackground(dc, wxSCHEME_COLOUR(m_scheme, CONTROL_PRESSED), rect); | |
1188 | } | |
1189 | else if ( flags & wxCONTROL_CURRENT ) | |
1190 | { | |
1191 | DrawBorder(dc, wxBORDER_RAISED, rect, flags, &rect); | |
1192 | ||
1193 | DrawBackground(dc, wxSCHEME_COLOUR(m_scheme, CONTROL_CURRENT), rect); | |
1194 | } | |
1195 | ||
1196 | if(tbarStyle & wxTB_TEXT) | |
1197 | { | |
1198 | if(tbarStyle & wxTB_HORIZONTAL) | |
1199 | { | |
1200 | dc.DrawLabel(label, bitmap, rect, wxALIGN_CENTRE); | |
1201 | } | |
1202 | else | |
1203 | { | |
1204 | dc.DrawLabel(label, bitmap, rect, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); | |
1205 | } | |
1206 | } | |
1207 | else | |
1208 | { | |
1209 | int xpoint = (rect.GetLeft() + rect.GetRight() + 1 - bitmap.GetWidth()) / 2; | |
1210 | int ypoint = (rect.GetTop() + rect.GetBottom() + 1 - bitmap.GetHeight()) / 2; | |
1211 | dc.DrawBitmap(bitmap, xpoint, ypoint); | |
1212 | } | |
1213 | } | |
1214 | } | |
1215 | #endif // wxUSE_TOOLBAR | |
1216 | ||
1217 | // ---------------------------------------------------------------------------- | |
1218 | // text control | |
1219 | // ---------------------------------------------------------------------------- | |
1220 | ||
1221 | #if wxUSE_TEXTCTRL | |
1222 | ||
1223 | wxRect wxMonoRenderer::GetTextTotalArea(const wxTextCtrl * WXUNUSED(text), | |
1224 | const wxRect& rect) const | |
1225 | { | |
1226 | wxRect rectTotal = rect; | |
1227 | rectTotal.Inflate(2*BORDER_THICKNESS); | |
1228 | return rectTotal; | |
1229 | } | |
1230 | ||
1231 | wxRect wxMonoRenderer::GetTextClientArea(const wxTextCtrl *text, | |
1232 | const wxRect& rect, | |
1233 | wxCoord *extraSpaceBeyond) const | |
1234 | { | |
1235 | wxRect rectText = rect; | |
1236 | rectText.Deflate(2*BORDER_THICKNESS); | |
1237 | ||
1238 | return rectText; | |
1239 | } | |
1240 | ||
1241 | void wxMonoRenderer::DrawTextLine(wxDC& dc, | |
1242 | const wxString& text, | |
1243 | const wxRect& rect, | |
1244 | int selStart, | |
1245 | int selEnd, | |
1246 | int flags) | |
1247 | { | |
1248 | StandardDrawTextLine(dc, text, rect, selStart, selEnd, flags); | |
1249 | } | |
1250 | ||
1251 | void | |
1252 | wxMonoRenderer::DrawLineWrapMark(wxDC& WXUNUSED(dc), | |
1253 | const wxRect& WXUNUSED(rect)) | |
1254 | { | |
1255 | // no line wrapping indicators | |
1256 | } | |
1257 | ||
1258 | #endif // wxUSE_TEXTCTRL | |
1259 | ||
1260 | // ---------------------------------------------------------------------------- | |
1261 | // combobox | |
1262 | // ---------------------------------------------------------------------------- | |
1263 | ||
1264 | #if wxUSE_COMBOBOX | |
1265 | ||
1266 | void wxMonoRenderer::InitComboBitmaps() | |
1267 | { | |
1268 | wxSize sizeArrow = m_sizeScrollbarArrow; | |
1269 | sizeArrow.x -= 2; | |
1270 | sizeArrow.y -= 2; | |
1271 | ||
1272 | size_t n; | |
1273 | ||
1274 | for ( n = ComboState_Normal; n < ComboState_Max; n++ ) | |
1275 | { | |
1276 | m_bitmapsCombo[n].Create(sizeArrow.x, sizeArrow.y); | |
1277 | } | |
1278 | ||
1279 | static const int comboButtonFlags[ComboState_Max] = | |
1280 | { | |
1281 | 0, | |
1282 | wxCONTROL_CURRENT, | |
1283 | wxCONTROL_PRESSED, | |
1284 | wxCONTROL_DISABLED, | |
1285 | }; | |
1286 | ||
1287 | wxRect rect(sizeArrow); | |
1288 | ||
1289 | wxMemoryDC dc; | |
1290 | for ( n = ComboState_Normal; n < ComboState_Max; n++ ) | |
1291 | { | |
1292 | int flags = comboButtonFlags[n]; | |
1293 | ||
1294 | dc.SelectObject(m_bitmapsCombo[n]); | |
1295 | DoDrawBackground(dc, GetBackgroundColour(flags), rect); | |
1296 | DrawArrow(dc, wxDOWN, rect, flags); | |
1297 | } | |
1298 | } | |
1299 | ||
1300 | void wxMonoRenderer::GetComboBitmaps(wxBitmap *bmpNormal, | |
1301 | wxBitmap *bmpFocus, | |
1302 | wxBitmap *bmpPressed, | |
1303 | wxBitmap *bmpDisabled) | |
1304 | { | |
1305 | if ( !m_bitmapsCombo[ComboState_Normal].Ok() ) | |
1306 | { | |
1307 | InitComboBitmaps(); | |
1308 | } | |
1309 | ||
1310 | if ( bmpNormal ) | |
1311 | *bmpNormal = m_bitmapsCombo[ComboState_Normal]; | |
1312 | if ( bmpFocus ) | |
1313 | *bmpFocus = m_bitmapsCombo[ComboState_Focus]; | |
1314 | if ( bmpPressed ) | |
1315 | *bmpPressed = m_bitmapsCombo[ComboState_Pressed]; | |
1316 | if ( bmpDisabled ) | |
1317 | *bmpDisabled = m_bitmapsCombo[ComboState_Disabled]; | |
1318 | } | |
1319 | ||
1320 | #endif // wxUSE_COMBOBOX | |
1321 | ||
1322 | // ---------------------------------------------------------------------------- | |
1323 | // background | |
1324 | // ---------------------------------------------------------------------------- | |
1325 | ||
1326 | void wxMonoRenderer::DoDrawBackground(wxDC& dc, | |
1327 | const wxColour& col, | |
1328 | const wxRect& rect, | |
1329 | wxWindow * WXUNUSED(window)) | |
1330 | { | |
1331 | wxBrush brush(col, wxSOLID); | |
1332 | dc.SetBrush(brush); | |
1333 | dc.SetPen(*wxTRANSPARENT_PEN); | |
1334 | dc.DrawRectangle(rect); | |
1335 | } | |
1336 | ||
1337 | void wxMonoRenderer::DrawBackground(wxDC& dc, | |
1338 | const wxColour& col, | |
1339 | const wxRect& rect, | |
1340 | int WXUNUSED(flags), | |
1341 | wxWindow *window) | |
1342 | { | |
1343 | } | |
1344 | ||
1345 | // ---------------------------------------------------------------------------- | |
1346 | // scrollbar | |
1347 | // ---------------------------------------------------------------------------- | |
1348 | ||
1349 | void wxMonoRenderer::DrawArrowBorder(wxDC& dc, | |
1350 | wxRect *rect, | |
1351 | wxDirection dir) | |
1352 | { | |
1353 | static const wxDirection sides[] = | |
1354 | { | |
1355 | wxUP, wxLEFT, wxRIGHT, wxDOWN | |
1356 | }; | |
1357 | ||
1358 | wxRect rect1, rect2, rectInner; | |
1359 | rect1 = | |
1360 | rect2 = | |
1361 | rectInner = *rect; | |
1362 | ||
1363 | rect2.Inflate(-1); | |
1364 | rectInner.Inflate(-2); | |
1365 | ||
1366 | DoDrawBackground(dc, wxSCHEME_COLOUR(m_scheme, SCROLLBAR), *rect); | |
1367 | ||
1368 | // find the side not to draw and also adjust the rectangles to compensate | |
1369 | // for it | |
1370 | wxDirection sideToOmit; | |
1371 | switch ( dir ) | |
1372 | { | |
1373 | case wxUP: | |
1374 | sideToOmit = wxDOWN; | |
1375 | rect2.height += 1; | |
1376 | rectInner.height += 1; | |
1377 | break; | |
1378 | ||
1379 | case wxDOWN: | |
1380 | sideToOmit = wxUP; | |
1381 | rect2.y -= 1; | |
1382 | rect2.height += 1; | |
1383 | rectInner.y -= 2; | |
1384 | rectInner.height += 1; | |
1385 | break; | |
1386 | ||
1387 | case wxLEFT: | |
1388 | sideToOmit = wxRIGHT; | |
1389 | rect2.width += 1; | |
1390 | rectInner.width += 1; | |
1391 | break; | |
1392 | ||
1393 | case wxRIGHT: | |
1394 | sideToOmit = wxLEFT; | |
1395 | rect2.x -= 1; | |
1396 | rect2.width += 1; | |
1397 | rectInner.x -= 2; | |
1398 | rectInner.width += 1; | |
1399 | break; | |
1400 | ||
1401 | default: | |
1402 | wxFAIL_MSG(_T("unknown arrow direction")); | |
1403 | return; | |
1404 | } | |
1405 | ||
1406 | // the outer rect first | |
1407 | size_t n; | |
1408 | for ( n = 0; n < WXSIZEOF(sides); n++ ) | |
1409 | { | |
1410 | wxDirection side = sides[n]; | |
1411 | if ( side == sideToOmit ) | |
1412 | continue; | |
1413 | ||
1414 | DrawAntiShadedRectSide(dc, rect1, m_penDarkGrey, m_penHighlight, side); | |
1415 | } | |
1416 | ||
1417 | // and then the inner one | |
1418 | for ( n = 0; n < WXSIZEOF(sides); n++ ) | |
1419 | { | |
1420 | wxDirection side = sides[n]; | |
1421 | if ( side == sideToOmit ) | |
1422 | continue; | |
1423 | ||
1424 | DrawAntiShadedRectSide(dc, rect2, m_penBlack, m_penGrey, side); | |
1425 | } | |
1426 | ||
1427 | *rect = rectInner; | |
1428 | } | |
1429 | ||
1430 | void wxMonoRenderer::DrawScrollbarArrow(wxDC& dc, | |
1431 | wxDirection dir, | |
1432 | const wxRect& rectArrow, | |
1433 | int flags) | |
1434 | { | |
1435 | // first of all, draw the border around it - but we don't want the border | |
1436 | // on the side opposite to the arrow point | |
1437 | wxRect rect = rectArrow; | |
1438 | DrawArrowBorder(dc, &rect, dir); | |
1439 | ||
1440 | // then the arrow itself | |
1441 | DrawArrow(dc, dir, rect, flags); | |
1442 | } | |
1443 | ||
1444 | // gtk_default_draw_arrow() takes ~350 lines and we can't do much better here | |
1445 | // these people are just crazy :-( | |
1446 | void wxMonoRenderer::DrawArrow(wxDC& dc, | |
1447 | wxDirection dir, | |
1448 | const wxRect& rect, | |
1449 | int flags) | |
1450 | { | |
1451 | enum | |
1452 | { | |
1453 | Point_First, | |
1454 | Point_Second, | |
1455 | Point_Third, | |
1456 | Point_Max | |
1457 | }; | |
1458 | ||
1459 | wxPoint ptArrow[Point_Max]; | |
1460 | ||
1461 | wxColour colInside = GetBackgroundColour(flags); | |
1462 | wxPen penShadow[4]; | |
1463 | if ( flags & wxCONTROL_DISABLED ) | |
1464 | { | |
1465 | penShadow[0] = m_penDarkGrey; | |
1466 | penShadow[1] = m_penDarkGrey; | |
1467 | penShadow[2] = wxNullPen; | |
1468 | penShadow[3] = wxNullPen; | |
1469 | } | |
1470 | else if ( flags & wxCONTROL_PRESSED ) | |
1471 | { | |
1472 | penShadow[0] = m_penDarkGrey; | |
1473 | penShadow[1] = m_penHighlight; | |
1474 | penShadow[2] = wxNullPen; | |
1475 | penShadow[3] = m_penBlack; | |
1476 | } | |
1477 | else // normal arrow | |
1478 | { | |
1479 | penShadow[0] = m_penHighlight; | |
1480 | penShadow[1] = m_penBlack; | |
1481 | penShadow[2] = m_penDarkGrey; | |
1482 | penShadow[3] = wxNullPen; | |
1483 | } | |
1484 | ||
1485 | wxCoord middle; | |
1486 | if ( dir == wxUP || dir == wxDOWN ) | |
1487 | { | |
1488 | // horz middle | |
1489 | middle = (rect.GetRight() + rect.GetLeft() + 1) / 2; | |
1490 | } | |
1491 | else // horz arrow | |
1492 | { | |
1493 | middle = (rect.GetTop() + rect.GetBottom() + 1) / 2; | |
1494 | } | |
1495 | ||
1496 | // draw the arrow interior | |
1497 | dc.SetPen(*wxTRANSPARENT_PEN); | |
1498 | dc.SetBrush(wxBrush(colInside, wxSOLID)); | |
1499 | ||
1500 | switch ( dir ) | |
1501 | { | |
1502 | case wxUP: | |
1503 | ptArrow[Point_First].x = rect.GetLeft(); | |
1504 | ptArrow[Point_First].y = rect.GetBottom(); | |
1505 | ptArrow[Point_Second].x = middle; | |
1506 | ptArrow[Point_Second].y = rect.GetTop(); | |
1507 | ptArrow[Point_Third].x = rect.GetRight(); | |
1508 | ptArrow[Point_Third].y = rect.GetBottom(); | |
1509 | break; | |
1510 | ||
1511 | case wxDOWN: | |
1512 | ptArrow[Point_First] = rect.GetPosition(); | |
1513 | ptArrow[Point_Second].x = middle; | |
1514 | ptArrow[Point_Second].y = rect.GetBottom(); | |
1515 | ptArrow[Point_Third].x = rect.GetRight(); | |
1516 | ptArrow[Point_Third].y = rect.GetTop(); | |
1517 | break; | |
1518 | ||
1519 | case wxLEFT: | |
1520 | ptArrow[Point_First].x = rect.GetRight(); | |
1521 | ptArrow[Point_First].y = rect.GetTop(); | |
1522 | ptArrow[Point_Second].x = rect.GetLeft(); | |
1523 | ptArrow[Point_Second].y = middle; | |
1524 | ptArrow[Point_Third].x = rect.GetRight(); | |
1525 | ptArrow[Point_Third].y = rect.GetBottom(); | |
1526 | break; | |
1527 | ||
1528 | case wxRIGHT: | |
1529 | ptArrow[Point_First] = rect.GetPosition(); | |
1530 | ptArrow[Point_Second].x = rect.GetRight(); | |
1531 | ptArrow[Point_Second].y = middle; | |
1532 | ptArrow[Point_Third].x = rect.GetLeft(); | |
1533 | ptArrow[Point_Third].y = rect.GetBottom(); | |
1534 | break; | |
1535 | ||
1536 | default: | |
1537 | wxFAIL_MSG(_T("unknown arrow direction")); | |
1538 | } | |
1539 | ||
1540 | dc.DrawPolygon(WXSIZEOF(ptArrow), ptArrow); | |
1541 | ||
1542 | // draw the arrow border | |
1543 | dc.SetPen(penShadow[0]); | |
1544 | switch ( dir ) | |
1545 | { | |
1546 | case wxUP: | |
1547 | dc.DrawLine(ptArrow[Point_Second], ptArrow[Point_First]); | |
1548 | dc.DrawPoint(ptArrow[Point_First]); | |
1549 | if ( penShadow[3].Ok() ) | |
1550 | { | |
1551 | dc.SetPen(penShadow[3]); | |
1552 | dc.DrawLine(ptArrow[Point_First].x + 1, ptArrow[Point_First].y, | |
1553 | ptArrow[Point_Second].x, ptArrow[Point_Second].y); | |
1554 | } | |
1555 | dc.SetPen(penShadow[1]); | |
1556 | dc.DrawLine(ptArrow[Point_Second].x + 1, ptArrow[Point_Second].y + 1, | |
1557 | ptArrow[Point_Third].x, ptArrow[Point_Third].y); | |
1558 | dc.DrawPoint(ptArrow[Point_Third]); | |
1559 | dc.DrawLine(ptArrow[Point_Third].x - 2, ptArrow[Point_Third].y, | |
1560 | ptArrow[Point_First].x + 1, ptArrow[Point_First].y); | |
1561 | if ( penShadow[2].Ok() ) | |
1562 | { | |
1563 | dc.SetPen(penShadow[2]); | |
1564 | dc.DrawLine(ptArrow[Point_Third].x - 1, ptArrow[Point_Third].y, | |
1565 | ptArrow[Point_Second].x, ptArrow[Point_Second].y + 1); | |
1566 | dc.DrawLine(ptArrow[Point_Third].x - 1, ptArrow[Point_Third].y - 1, | |
1567 | ptArrow[Point_First].x + 2, ptArrow[Point_First].y - 1); | |
1568 | } | |
1569 | break; | |
1570 | ||
1571 | case wxDOWN: | |
1572 | dc.DrawLine(ptArrow[Point_First], ptArrow[Point_Second]); | |
1573 | dc.DrawLine(ptArrow[Point_First].x + 2, ptArrow[Point_First].y, | |
1574 | ptArrow[Point_Third].x - 1, ptArrow[Point_Third].y); | |
1575 | if ( penShadow[2].Ok() ) | |
1576 | { | |
1577 | dc.SetPen(penShadow[2]); | |
1578 | dc.DrawLine(ptArrow[Point_Second].x, ptArrow[Point_Second].y - 1, | |
1579 | ptArrow[Point_Third].x - 1, ptArrow[Point_Third].y - 1); | |
1580 | } | |
1581 | dc.SetPen(penShadow[1]); | |
1582 | dc.DrawLine(ptArrow[Point_Second], ptArrow[Point_Third]); | |
1583 | dc.DrawPoint(ptArrow[Point_Third]); | |
1584 | break; | |
1585 | ||
1586 | case wxLEFT: | |
1587 | dc.DrawLine(ptArrow[Point_Second], ptArrow[Point_First]); | |
1588 | dc.DrawPoint(ptArrow[Point_First]); | |
1589 | if ( penShadow[2].Ok() ) | |
1590 | { | |
1591 | dc.SetPen(penShadow[2]); | |
1592 | dc.DrawLine(ptArrow[Point_Third].x - 1, ptArrow[Point_Third].y, | |
1593 | ptArrow[Point_First].x - 1, ptArrow[Point_First].y + 2); | |
1594 | dc.DrawLine(ptArrow[Point_Third].x, ptArrow[Point_Third].y, | |
1595 | ptArrow[Point_Second].x + 2, ptArrow[Point_Second].y + 1); | |
1596 | } | |
1597 | dc.SetPen(penShadow[1]); | |
1598 | dc.DrawLine(ptArrow[Point_Third].x, ptArrow[Point_Third].y, | |
1599 | ptArrow[Point_First].x, ptArrow[Point_First].y + 1); | |
1600 | dc.DrawLine(ptArrow[Point_Second].x + 1, ptArrow[Point_Second].y + 1, | |
1601 | ptArrow[Point_Third].x - 1, ptArrow[Point_Third].y); | |
1602 | break; | |
1603 | ||
1604 | case wxRIGHT: | |
1605 | dc.DrawLine(ptArrow[Point_First], ptArrow[Point_Third]); | |
1606 | dc.DrawLine(ptArrow[Point_First].x + 2, ptArrow[Point_First].y + 1, | |
1607 | ptArrow[Point_Second].x, ptArrow[Point_Second].y); | |
1608 | dc.SetPen(penShadow[1]); | |
1609 | dc.DrawLine(ptArrow[Point_Second], ptArrow[Point_Third]); | |
1610 | dc.DrawPoint(ptArrow[Point_Third]); | |
1611 | break; | |
1612 | ||
1613 | default: | |
1614 | wxFAIL_MSG(_T("unknown arrow direction")); | |
1615 | return; | |
1616 | } | |
1617 | } | |
1618 | ||
1619 | void wxMonoRenderer::DrawThumbBorder(wxDC& dc, | |
1620 | wxRect *rect, | |
1621 | wxOrientation orient) | |
1622 | { | |
1623 | if ( orient == wxVERTICAL ) | |
1624 | { | |
1625 | DrawAntiShadedRectSide(dc, *rect, m_penDarkGrey, m_penHighlight, | |
1626 | wxLEFT); | |
1627 | DrawAntiShadedRectSide(dc, *rect, m_penDarkGrey, m_penHighlight, | |
1628 | wxRIGHT); | |
1629 | rect->Inflate(-1, 0); | |
1630 | ||
1631 | DrawAntiShadedRectSide(dc, *rect, m_penBlack, m_penGrey, | |
1632 | wxLEFT); | |
1633 | DrawAntiShadedRectSide(dc, *rect, m_penBlack, m_penGrey, | |
1634 | wxRIGHT); | |
1635 | rect->Inflate(-1, 0); | |
1636 | } | |
1637 | else | |
1638 | { | |
1639 | DrawAntiShadedRectSide(dc, *rect, m_penDarkGrey, m_penHighlight, | |
1640 | wxUP); | |
1641 | DrawAntiShadedRectSide(dc, *rect, m_penDarkGrey, m_penHighlight, | |
1642 | wxDOWN); | |
1643 | rect->Inflate(0, -1); | |
1644 | ||
1645 | DrawAntiShadedRectSide(dc, *rect, m_penBlack, m_penGrey, | |
1646 | wxUP); | |
1647 | DrawAntiShadedRectSide(dc, *rect, m_penBlack, m_penGrey, | |
1648 | wxDOWN); | |
1649 | rect->Inflate(0, -1); | |
1650 | } | |
1651 | } | |
1652 | ||
1653 | void wxMonoRenderer::DrawScrollbarThumb(wxDC& dc, | |
1654 | wxOrientation orient, | |
1655 | const wxRect& rect, | |
1656 | int flags) | |
1657 | { | |
1658 | // the thumb is never pressed never has focus border under Mono and the | |
1659 | // scrollbar background never changes at all | |
1660 | int flagsThumb = flags & ~(wxCONTROL_PRESSED | wxCONTROL_FOCUSED); | |
1661 | ||
1662 | // we don't want the border in the direction of the scrollbar movement | |
1663 | wxRect rectThumb = rect; | |
1664 | DrawThumbBorder(dc, &rectThumb, orient); | |
1665 | ||
1666 | DrawButtonBorder(dc, rectThumb, flagsThumb, &rectThumb); | |
1667 | DrawBackground(dc, wxNullColour, rectThumb, flagsThumb); | |
1668 | } | |
1669 | ||
1670 | void wxMonoRenderer::DrawScrollbarShaft(wxDC& dc, | |
1671 | wxOrientation orient, | |
1672 | const wxRect& rect, | |
1673 | int WXUNUSED(flags)) | |
1674 | { | |
1675 | wxRect rectBar = rect; | |
1676 | DrawThumbBorder(dc, &rectBar, orient); | |
1677 | DoDrawBackground(dc, wxSCHEME_COLOUR(m_scheme, SCROLLBAR), rectBar); | |
1678 | } | |
1679 | ||
1680 | void wxMonoRenderer::DrawScrollCorner(wxDC& dc, const wxRect& rect) | |
1681 | { | |
1682 | DoDrawBackground(dc, wxSCHEME_COLOUR(m_scheme, CONTROL), rect); | |
1683 | } | |
1684 | ||
1685 | #if wxUSE_SCROLLBAR | |
1686 | wxRect wxMonoRenderer::GetScrollbarRect(const wxScrollBar *scrollbar, | |
1687 | wxScrollBar::Element elem, | |
1688 | int thumbPos) const | |
1689 | { | |
1690 | // as Mono scrollbars can't be disabled, it makes no sense to remove the | |
1691 | // thumb for a scrollbar with range 0 - instead, make it fill the entire | |
1692 | // scrollbar shaft | |
1693 | if ( (elem == wxScrollBar::Element_Thumb) && !scrollbar->GetRange() ) | |
1694 | { | |
1695 | elem = wxScrollBar::Element_Bar_2; | |
1696 | } | |
1697 | ||
1698 | return StandardGetScrollbarRect(scrollbar, elem, | |
1699 | thumbPos, | |
1700 | GetScrollbarArrowSize(scrollbar)); | |
1701 | } | |
1702 | ||
1703 | wxCoord wxMonoRenderer::GetScrollbarSize(const wxScrollBar *scrollbar) | |
1704 | { | |
1705 | return StandardScrollBarSize(scrollbar, GetScrollbarArrowSize(scrollbar)); | |
1706 | } | |
1707 | ||
1708 | wxHitTest wxMonoRenderer::HitTestScrollbar(const wxScrollBar *scrollbar, | |
1709 | const wxPoint& pt) const | |
1710 | { | |
1711 | return StandardHitTestScrollbar(scrollbar, pt, | |
1712 | GetScrollbarArrowSize(scrollbar)); | |
1713 | } | |
1714 | ||
1715 | wxCoord wxMonoRenderer::ScrollbarToPixel(const wxScrollBar *scrollbar, | |
1716 | int thumbPos) | |
1717 | { | |
1718 | return StandardScrollbarToPixel(scrollbar, thumbPos, | |
1719 | GetScrollbarArrowSize(scrollbar)); | |
1720 | } | |
1721 | ||
1722 | int wxMonoRenderer::PixelToScrollbar(const wxScrollBar *scrollbar, | |
1723 | wxCoord coord) | |
1724 | { | |
1725 | return StandardPixelToScrollbar(scrollbar, coord, | |
1726 | GetScrollbarArrowSize(scrollbar)); | |
1727 | } | |
1728 | #endif // wxUSE_SCROLLBAR | |
1729 | ||
1730 | // ---------------------------------------------------------------------------- | |
1731 | // size adjustments | |
1732 | // ---------------------------------------------------------------------------- | |
1733 | ||
1734 | void wxMonoRenderer::AdjustSize(wxSize *size, const wxWindow *window) | |
1735 | { | |
1736 | #if wxUSE_BMPBUTTON | |
1737 | if ( wxDynamicCast(window, wxBitmapButton) ) | |
1738 | { | |
1739 | size->x += 4; | |
1740 | size->y += 4; | |
1741 | } else | |
1742 | #endif // wxUSE_BMPBUTTON | |
1743 | #if wxUSE_BUTTON || wxUSE_TOGGLEBTN | |
1744 | if ( 0 | |
1745 | # if wxUSE_BUTTON | |
1746 | || wxDynamicCast(window, wxButton) | |
1747 | # endif // wxUSE_BUTTON | |
1748 | # if wxUSE_TOGGLEBTN | |
1749 | || wxDynamicCast(window, wxToggleButton) | |
1750 | # endif // wxUSE_TOGGLEBTN | |
1751 | ) | |
1752 | { | |
1753 | if ( !(window->GetWindowStyle() & wxBU_EXACTFIT) ) | |
1754 | { | |
1755 | // TODO: this is ad hoc... | |
1756 | size->x += 3*window->GetCharWidth(); | |
1757 | wxCoord minBtnHeight = 18; | |
1758 | if ( size->y < minBtnHeight ) | |
1759 | size->y = minBtnHeight; | |
1760 | ||
1761 | // button border width | |
1762 | size->y += 4; | |
1763 | } | |
1764 | } else | |
1765 | #endif // wxUSE_BUTTON || wxUSE_TOGGLEBTN | |
1766 | #if wxUSE_SCROLLBAR | |
1767 | if ( wxDynamicCast(window, wxScrollBar) ) | |
1768 | { | |
1769 | // we only set the width of vert scrollbars and height of the | |
1770 | // horizontal ones | |
1771 | if ( window->GetWindowStyle() & wxSB_HORIZONTAL ) | |
1772 | size->y = m_sizeScrollbarArrow.x; | |
1773 | else | |
1774 | size->x = m_sizeScrollbarArrow.x; | |
1775 | } | |
1776 | else | |
1777 | #endif // wxUSE_SCROLLBAR | |
1778 | { | |
1779 | // take into account the border width | |
1780 | wxRect rectBorder = GetBorderDimensions(window->GetBorder()); | |
1781 | size->x += rectBorder.x + rectBorder.width; | |
1782 | size->y += rectBorder.y + rectBorder.height; | |
1783 | } | |
1784 | } | |
1785 | ||
1786 | // ---------------------------------------------------------------------------- | |
1787 | // top level windows | |
1788 | // ---------------------------------------------------------------------------- | |
1789 | ||
1790 | void wxMonoRenderer::DrawFrameTitleBar(wxDC& WXUNUSED(dc), | |
1791 | const wxRect& WXUNUSED(rect), | |
1792 | const wxString& WXUNUSED(title), | |
1793 | const wxIcon& WXUNUSED(icon), | |
1794 | int WXUNUSED(flags), | |
1795 | int WXUNUSED(specialButton), | |
1796 | int WXUNUSED(specialButtonFlag)) | |
1797 | { | |
1798 | } | |
1799 | ||
1800 | void wxMonoRenderer::DrawFrameBorder(wxDC& WXUNUSED(dc), | |
1801 | const wxRect& WXUNUSED(rect), | |
1802 | int WXUNUSED(flags)) | |
1803 | { | |
1804 | } | |
1805 | ||
1806 | void wxMonoRenderer::DrawFrameBackground(wxDC& WXUNUSED(dc), | |
1807 | const wxRect& WXUNUSED(rect), | |
1808 | int WXUNUSED(flags)) | |
1809 | { | |
1810 | } | |
1811 | ||
1812 | void wxMonoRenderer::DrawFrameTitle(wxDC& WXUNUSED(dc), | |
1813 | const wxRect& WXUNUSED(rect), | |
1814 | const wxString& WXUNUSED(title), | |
1815 | int WXUNUSED(flags)) | |
1816 | { | |
1817 | } | |
1818 | ||
1819 | void wxMonoRenderer::DrawFrameIcon(wxDC& WXUNUSED(dc), | |
1820 | const wxRect& WXUNUSED(rect), | |
1821 | const wxIcon& WXUNUSED(icon), | |
1822 | int WXUNUSED(flags)) | |
1823 | { | |
1824 | } | |
1825 | ||
1826 | void wxMonoRenderer::DrawFrameButton(wxDC& WXUNUSED(dc), | |
1827 | wxCoord WXUNUSED(x), | |
1828 | wxCoord WXUNUSED(y), | |
1829 | int WXUNUSED(button), | |
1830 | int WXUNUSED(flags)) | |
1831 | { | |
1832 | } | |
1833 | ||
1834 | wxRect | |
1835 | wxMonoRenderer::GetFrameClientArea(const wxRect& rect, | |
1836 | int WXUNUSED(flags)) const | |
1837 | { | |
1838 | return rect; | |
1839 | } | |
1840 | ||
1841 | wxSize | |
1842 | wxMonoRenderer::GetFrameTotalSize(const wxSize& clientSize, | |
1843 | int WXUNUSED(flags)) const | |
1844 | { | |
1845 | return clientSize; | |
1846 | } | |
1847 | ||
1848 | wxSize wxMonoRenderer::GetFrameMinSize(int WXUNUSED(flags)) const | |
1849 | { | |
1850 | return wxSize(0,0); | |
1851 | } | |
1852 | ||
1853 | wxSize wxMonoRenderer::GetFrameIconSize() const | |
1854 | { | |
1855 | return wxSize(wxDefaultCoord, wxDefaultCoord); | |
1856 | } | |
1857 | ||
1858 | int | |
1859 | wxMonoRenderer::HitTestFrame(const wxRect& WXUNUSED(rect), | |
1860 | const wxPoint& WXUNUSED(pt), | |
1861 | int WXUNUSED(flags)) const | |
1862 | { | |
1863 | return wxHT_TOPLEVEL_CLIENT_AREA; | |
1864 | } | |
1865 | ||
1866 | ||
1867 | // ---------------------------------------------------------------------------- | |
1868 | // standard icons | |
1869 | // ---------------------------------------------------------------------------- | |
1870 | ||
1871 | /* Copyright (c) Julian Smart */ | |
1872 | static const char *error_xpm[] = { | |
1873 | /* columns rows colors chars-per-pixel */ | |
1874 | "48 48 4 1", | |
1875 | " c None", | |
1876 | "X c #242424", | |
1877 | "o c #DCDF00", | |
1878 | ". c #C00000", | |
1879 | /* pixels */ | |
1880 | " ", | |
1881 | " ", | |
1882 | " ", | |
1883 | " ", | |
1884 | " ", | |
1885 | " ..... ", | |
1886 | " ............. ", | |
1887 | " ................. ", | |
1888 | " ................... ", | |
1889 | " ....................... ", | |
1890 | " ......................... ", | |
1891 | " ........................... ", | |
1892 | " ...........................X ", | |
1893 | " .............................X ", | |
1894 | " ............................... ", | |
1895 | " ...............................X ", | |
1896 | " .................................X ", | |
1897 | " .................................X ", | |
1898 | " .................................XX ", | |
1899 | " ...ooooooooooooooooooooooooooo...XX ", | |
1900 | " ....ooooooooooooooooooooooooooo....X ", | |
1901 | " ....ooooooooooooooooooooooooooo....X ", | |
1902 | " ....ooooooooooooooooooooooooooo....XX ", | |
1903 | " ....ooooooooooooooooooooooooooo....XX ", | |
1904 | " ....ooooooooooooooooooooooooooo....XX ", | |
1905 | " ...ooooooooooooooooooooooooooo...XXX ", | |
1906 | " ...ooooooooooooooooooooooooooo...XXX ", | |
1907 | " .................................XX ", | |
1908 | " .................................XX ", | |
1909 | " ...............................XXX ", | |
1910 | " ...............................XXX ", | |
1911 | " .............................XXX ", | |
1912 | " ...........................XXXX ", | |
1913 | " ...........................XXX ", | |
1914 | " .........................XXX ", | |
1915 | " .......................XXXX ", | |
1916 | " X...................XXXXX ", | |
1917 | " X.................XXXXX ", | |
1918 | " X.............XXXXX ", | |
1919 | " XXXX.....XXXXXXXX ", | |
1920 | " XXXXXXXXXXXXX ", | |
1921 | " XXXXX ", | |
1922 | " ", | |
1923 | " ", | |
1924 | " ", | |
1925 | " ", | |
1926 | " ", | |
1927 | " " | |
1928 | }; | |
1929 | ||
1930 | /* Copyright (c) Julian Smart */ | |
1931 | static const char *info_xpm[] = { | |
1932 | /* columns rows colors chars-per-pixel */ | |
1933 | "48 48 9 1", | |
1934 | "$ c Black", | |
1935 | "O c #FFFFFF", | |
1936 | "@ c #808080", | |
1937 | "+ c #000080", | |
1938 | "o c #E8EB01", | |
1939 | " c None", | |
1940 | "X c #FFFF40", | |
1941 | "# c #C0C0C0", | |
1942 | ". c #ABAD01", | |
1943 | /* pixels */ | |
1944 | " ", | |
1945 | " ", | |
1946 | " ", | |
1947 | " ", | |
1948 | " ", | |
1949 | " ", | |
1950 | " ", | |
1951 | " ", | |
1952 | " ", | |
1953 | " ..... ", | |
1954 | " ..XXXXX.. ", | |
1955 | " ..XXXXXXXXo.. ", | |
1956 | " .XXXOXXXXXXXoo. ", | |
1957 | " .XOOXXX+XXXXXo. ", | |
1958 | " .XOOOXX+++XXXXoo. ", | |
1959 | " .XOOXXX+++XXXXXo. ", | |
1960 | " .XOOOXXX+++XXXXXXo. ", | |
1961 | " .XOOXXXX+++XXXXXXo. ", | |
1962 | " .XXXXXXX+++XXXXXXX. ", | |
1963 | " .XXXXXXX+++XXXXXXo. ", | |
1964 | " .XXXXXXX+++XXXXXoo. ", | |
1965 | " .XXXXXX+++XXXXXo. ", | |
1966 | " .XXXXXXX+XXXXXXo. ", | |
1967 | " .XXXXXXXXXXXXo. ", | |
1968 | " .XXXXX+++XXXoo. ", | |
1969 | " .XXXX+++XXoo. ", | |
1970 | " .XXXXXXXXo. ", | |
1971 | " ..XXXXXXo.. ", | |
1972 | " .XXXXXo.. ", | |
1973 | " @#######@ ", | |
1974 | " @@@@@@@@@ ", | |
1975 | " @#######@ ", | |
1976 | " @@@@@@@@@ ", | |
1977 | " @#######@ ", | |
1978 | " @@@@@@@ ", | |
1979 | " ### ", | |
1980 | " $$$ ", | |
1981 | " ", | |
1982 | " ", | |
1983 | " ", | |
1984 | " ", | |
1985 | " ", | |
1986 | " ", | |
1987 | " ", | |
1988 | " ", | |
1989 | " ", | |
1990 | " ", | |
1991 | " " | |
1992 | }; | |
1993 | ||
1994 | /* Copyright (c) Julian Smart */ | |
1995 | static const char *warning_xpm[] = { | |
1996 | /* columns rows colors chars-per-pixel */ | |
1997 | "48 48 9 1", | |
1998 | "@ c Black", | |
1999 | "o c #A6A800", | |
2000 | "+ c #8A8C00", | |
2001 | "$ c #B8BA00", | |
2002 | " c None", | |
2003 | "O c #6E7000", | |
2004 | "X c #DCDF00", | |
2005 | ". c #C00000", | |
2006 | "# c #373800", | |
2007 | /* pixels */ | |
2008 | " ", | |
2009 | " ", | |
2010 | " ", | |
2011 | " ", | |
2012 | " ", | |
2013 | " ", | |
2014 | " ", | |
2015 | " . ", | |
2016 | " ... ", | |
2017 | " ... ", | |
2018 | " ..... ", | |
2019 | " ...X.. ", | |
2020 | " ..XXX.. ", | |
2021 | " ...XXX... ", | |
2022 | " ..XXXXX.. ", | |
2023 | " ..XXXXXX... ", | |
2024 | " ...XXoO+XX.. ", | |
2025 | " ..XXXO@#XXX.. ", | |
2026 | " ..XXXXO@#XXX... ", | |
2027 | " ...XXXXO@#XXXX.. ", | |
2028 | " ..XXXXXO@#XXXX... ", | |
2029 | " ...XXXXXo@OXXXXX.. ", | |
2030 | " ...XXXXXXo@OXXXXXX.. ", | |
2031 | " ..XXXXXXX$@OXXXXXX... ", | |
2032 | " ...XXXXXXXX@XXXXXXXX.. ", | |
2033 | " ...XXXXXXXXXXXXXXXXXX... ", | |
2034 | " ..XXXXXXXXXXOXXXXXXXXX.. ", | |
2035 | " ...XXXXXXXXXO@#XXXXXXXXX.. ", | |
2036 | " ..XXXXXXXXXXX#XXXXXXXXXX... ", | |
2037 | " ...XXXXXXXXXXXXXXXXXXXXXXX.. ", | |
2038 | " ...XXXXXXXXXXXXXXXXXXXXXXXX... ", | |
2039 | " .............................. ", | |
2040 | " .............................. ", | |
2041 | " ", | |
2042 | " ", | |
2043 | " ", | |
2044 | " ", | |
2045 | " ", | |
2046 | " ", | |
2047 | " ", | |
2048 | " ", | |
2049 | " ", | |
2050 | " ", | |
2051 | " ", | |
2052 | " ", | |
2053 | " ", | |
2054 | " ", | |
2055 | " " | |
2056 | }; | |
2057 | ||
2058 | /* Copyright (c) Julian Smart */ | |
2059 | static const char *question_xpm[] = { | |
2060 | /* columns rows colors chars-per-pixel */ | |
2061 | "48 48 21 1", | |
2062 | ". c Black", | |
2063 | "> c #696969", | |
2064 | "O c #1F1F00", | |
2065 | "+ c #181818", | |
2066 | "o c #F6F900", | |
2067 | "; c #3F3F00", | |
2068 | "$ c #111111", | |
2069 | " c None", | |
2070 | "& c #202020", | |
2071 | "X c #AAAA00", | |
2072 | "@ c #949400", | |
2073 | ": c #303030", | |
2074 | "1 c #383838", | |
2075 | "% c #2A2A00", | |
2076 | ", c #404040", | |
2077 | "= c #B4B400", | |
2078 | "- c #484848", | |
2079 | "# c #151500", | |
2080 | "< c #9F9F00", | |
2081 | "2 c #6A6A00", | |
2082 | "* c #353500", | |
2083 | /* pixels */ | |
2084 | " ", | |
2085 | " ", | |
2086 | " ", | |
2087 | " ", | |
2088 | " ......... ", | |
2089 | " ...XXXXXXX.. ", | |
2090 | " ..XXXXoooooXXXO+ ", | |
2091 | " ..XXooooooooooooX@.. ", | |
2092 | " ..XoooooooooooooooXX#. ", | |
2093 | " $%XoooooooooooooooooXX#. ", | |
2094 | " &.XoooooooXXXXXXooooooXX.. ", | |
2095 | " .XooooooXX.$...$XXoooooX*. ", | |
2096 | " $.XoooooX%.$ .*oooooo=.. ", | |
2097 | " .XooooooX.. -.XoooooX.. ", | |
2098 | " .XoooooX..+ .XoooooX;. ", | |
2099 | " ...XXXX..: .XoooooX;. ", | |
2100 | " ........ >.XoooooX;. ", | |
2101 | " +.XoooooX.. ", | |
2102 | " ,.Xoooooo<.. ", | |
2103 | " 1#XooooooXO.. ", | |
2104 | " &#XooooooX2.. ", | |
2105 | " $%XooooooXX.. ", | |
2106 | " $%XooooooXX.. ", | |
2107 | " $%XooooooXX.. ", | |
2108 | " &.XooooooXX.. ", | |
2109 | " .XooooooXX.. ", | |
2110 | " &.XoooooXX.. ", | |
2111 | " ..XooooXX.. ", | |
2112 | " ..XooooX... ", | |
2113 | " ..XXooXX..& ", | |
2114 | " ...XXXXX.. ", | |
2115 | " ........ ", | |
2116 | " ", | |
2117 | " ", | |
2118 | " ....... ", | |
2119 | " ..XXXXX.. ", | |
2120 | " ..XXoooXX.. ", | |
2121 | " ..XoooooX.. ", | |
2122 | " ..XoooooX.. ", | |
2123 | " ..XXoooXX.. ", | |
2124 | " ..XXXXX.. ", | |
2125 | " ....... ", | |
2126 | " ", | |
2127 | " ", | |
2128 | " ", | |
2129 | " ", | |
2130 | " ", | |
2131 | " " | |
2132 | }; | |
2133 | ||
2134 | wxBitmap wxMonoArtProvider::CreateBitmap(const wxArtID& id, | |
2135 | const wxArtClient& WXUNUSED(client), | |
2136 | const wxSize& WXUNUSED(size)) | |
2137 | { | |
2138 | if ( id == wxART_INFORMATION ) | |
2139 | return wxBitmap(info_xpm); | |
2140 | if ( id == wxART_ERROR ) | |
2141 | return wxBitmap(error_xpm); | |
2142 | if ( id == wxART_WARNING ) | |
2143 | return wxBitmap(warning_xpm); | |
2144 | if ( id == wxART_QUESTION ) | |
2145 | return wxBitmap(question_xpm); | |
2146 | return wxNullBitmap; | |
2147 | } | |
2148 | ||
2149 | ||
2150 | // ============================================================================ | |
2151 | // wxInputHandler | |
2152 | // ============================================================================ | |
2153 |