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