1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/univ/themes/mono.cpp
3 // Purpose: wxUniversal theme for monochrome displays
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2006 REA Elektronik GmbH
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ===========================================================================
14 // ===========================================================================
16 // ---------------------------------------------------------------------------
18 // ---------------------------------------------------------------------------
20 // for compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
30 #include "wx/univ/renderer.h"
31 #include "wx/univ/inphand.h"
32 #include "wx/univ/colschem.h"
33 #include "wx/univ/theme.h"
35 class wxMonoColourScheme
;
37 #define wxMONO_BG_COL (*wxWHITE)
38 #define wxMONO_FG_COL (*wxBLACK)
40 // ----------------------------------------------------------------------------
41 // wxMonoRenderer: draw the GUI elements in simplest possible way
42 // ----------------------------------------------------------------------------
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
49 wxMonoRenderer(const wxColourScheme
*scheme
);
51 virtual void DrawBackground(wxDC
& dc
,
55 wxWindow
*window
= NULL
);
57 virtual void DrawLabel(wxDC
& dc
,
58 const wxString
& label
,
61 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
63 wxRect
*rectBounds
= NULL
);
65 virtual void DrawButtonLabel(wxDC
& dc
,
66 const wxString
& label
,
67 const wxBitmap
& image
,
70 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
72 wxRect
*rectBounds
= NULL
);
74 virtual void DrawBorder(wxDC
& dc
,
78 wxRect
*rectIn
= NULL
);
80 virtual void DrawTextBorder(wxDC
& dc
,
84 wxRect
*rectIn
= NULL
);
86 virtual void DrawButtonBorder(wxDC
& dc
,
89 wxRect
*rectIn
= NULL
);
91 virtual void DrawHorizontalLine(wxDC
& dc
,
92 wxCoord y
, wxCoord x1
, wxCoord x2
);
94 virtual void DrawVerticalLine(wxDC
& dc
,
95 wxCoord x
, wxCoord y1
, wxCoord y2
);
97 virtual void DrawFrame(wxDC
& dc
,
98 const wxString
& label
,
101 int alignment
= wxALIGN_LEFT
,
102 int indexAccel
= -1);
104 virtual void DrawArrow(wxDC
& dc
,
109 virtual void DrawScrollbarArrow(wxDC
& dc
,
114 virtual void DrawScrollbarThumb(wxDC
& dc
,
115 wxOrientation orient
,
119 virtual void DrawScrollbarShaft(wxDC
& dc
,
120 wxOrientation orient
,
124 virtual void DrawScrollCorner(wxDC
& dc
,
127 virtual void DrawItem(wxDC
& dc
,
128 const wxString
& label
,
132 virtual void DrawCheckItem(wxDC
& dc
,
133 const wxString
& label
,
134 const wxBitmap
& bitmap
,
138 virtual void DrawCheckButton(wxDC
& dc
,
139 const wxString
& label
,
140 const wxBitmap
& bitmap
,
143 wxAlignment align
= wxALIGN_LEFT
,
144 int indexAccel
= -1);
146 virtual void DrawRadioButton(wxDC
& dc
,
147 const wxString
& label
,
148 const wxBitmap
& bitmap
,
151 wxAlignment align
= wxALIGN_LEFT
,
152 int indexAccel
= -1);
155 virtual void DrawToolBarButton(wxDC
& dc
,
156 const wxString
& label
,
157 const wxBitmap
& bitmap
,
162 #endif // wxUSE_TOOLBAR
165 virtual void DrawTextLine(wxDC
& dc
,
166 const wxString
& text
,
172 virtual void DrawLineWrapMark(wxDC
& dc
, const wxRect
& rect
);
173 #endif // wxUSE_TEXTCTRL
176 virtual void DrawTab(wxDC
& dc
,
179 const wxString
& label
,
180 const wxBitmap
& bitmap
= wxNullBitmap
,
182 int indexAccel
= -1);
183 #endif // wxUSE_NOTEBOOK
187 virtual void DrawSliderShaft(wxDC
& dc
,
190 wxOrientation orient
,
193 wxRect
*rectShaft
= NULL
);
195 virtual void DrawSliderThumb(wxDC
& dc
,
197 wxOrientation orient
,
201 virtual void DrawSliderTicks(wxDC
& dc
,
204 wxOrientation orient
,
210 #endif // wxUSE_SLIDER
213 virtual void DrawMenuBarItem(wxDC
& dc
,
215 const wxString
& label
,
217 int indexAccel
= -1);
219 virtual void DrawMenuItem(wxDC
& dc
,
221 const wxMenuGeometryInfo
& geometryInfo
,
222 const wxString
& label
,
223 const wxString
& accel
,
224 const wxBitmap
& bitmap
= wxNullBitmap
,
226 int indexAccel
= -1);
228 virtual void DrawMenuSeparator(wxDC
& dc
,
230 const wxMenuGeometryInfo
& geomInfo
);
231 #endif // wxUSE_MENUS
234 virtual void DrawStatusField(wxDC
& dc
,
236 const wxString
& label
,
237 int flags
= 0, int style
= 0);
238 #endif // wxUSE_STATUSBAR
240 virtual void DrawFrameTitleBar(wxDC
& dc
,
242 const wxString
& title
,
245 int specialButton
= 0,
246 int specialButtonFlags
= 0);
248 virtual void DrawFrameBorder(wxDC
& dc
,
252 virtual void DrawFrameBackground(wxDC
& dc
,
256 virtual void DrawFrameTitle(wxDC
& dc
,
258 const wxString
& title
,
261 virtual void DrawFrameIcon(wxDC
& dc
,
266 virtual void DrawFrameButton(wxDC
& dc
,
267 wxCoord x
, wxCoord y
,
272 virtual void GetComboBitmaps(wxBitmap
*bmpNormal
,
274 wxBitmap
*bmpPressed
,
275 wxBitmap
*bmpDisabled
);
278 virtual wxRect
GetBorderDimensions(wxBorder border
) const;
280 virtual bool AreScrollbarsInsideBorder() const;
282 virtual void AdjustSize(wxSize
*size
, const wxWindow
*window
);
286 virtual wxSize
GetScrollbarArrowSize() const;
288 virtual wxRect
GetScrollbarRect(const wxScrollBar
*scrollbar
,
289 wxScrollBar::Element elem
,
290 int thumbPos
= -1) const;
292 virtual wxCoord
GetScrollbarSize(const wxScrollBar
*scrollbar
);
294 virtual wxHitTest
HitTestScrollbar(const wxScrollBar
*scrollbar
,
295 const wxPoint
& pt
) const;
297 virtual wxCoord
ScrollbarToPixel(const wxScrollBar
*scrollbar
,
299 virtual int PixelToScrollbar(const wxScrollBar
*scrollbar
,
302 #endif // wxUSE_SCROLLBAR
304 virtual wxCoord
GetListboxItemHeight(wxCoord fontHeight
);
306 virtual wxSize
GetCheckBitmapSize() const;
307 virtual wxSize
GetRadioBitmapSize() const;
308 virtual wxCoord
GetCheckItemMargin() const;
310 virtual wxSize
GetToolBarButtonSize(wxCoord
*separator
) const;
312 virtual wxSize
GetToolBarMargin() const;
315 virtual wxRect
GetTextTotalArea(const wxTextCtrl
*text
,
316 const wxRect
& rectText
) const;
318 virtual wxRect
GetTextClientArea(const wxTextCtrl
*text
,
319 const wxRect
& rectTotal
,
320 wxCoord
*extraSpaceBeyond
) const;
321 #endif // wxUSE_TEXTCTRL
324 virtual wxSize
GetTabIndent() const;
326 virtual wxSize
GetTabPadding() const;
327 #endif // wxUSE_NOTEBOOK
330 virtual wxCoord
GetSliderDim() const;
332 virtual wxCoord
GetSliderTickLen() const;
334 virtual wxRect
GetSliderShaftRect(const wxRect
& rect
,
336 wxOrientation orient
,
337 long style
= 0) const;
339 virtual wxSize
GetSliderThumbSize(const wxRect
& rect
,
341 wxOrientation orient
) const;
342 #endif // wxUSE_SLIDER
344 virtual wxSize
GetProgressBarStep() const;
347 virtual wxSize
GetMenuBarItemSize(const wxSize
& sizeText
) const;
349 virtual wxMenuGeometryInfo
*GetMenuGeometry(wxWindow
*win
,
350 const wxMenu
& menu
) const;
351 #endif // wxUSE_MENUS
354 virtual wxSize
GetStatusBarBorders(wxCoord
*borderBetweenFields
) const;
355 #endif // wxUSE_STATUSBAR
357 virtual wxRect
GetFrameClientArea(const wxRect
& rect
, int flags
) const;
359 virtual wxSize
GetFrameTotalSize(const wxSize
& clientSize
, int flags
) const;
361 virtual wxSize
GetFrameMinSize(int flags
) const;
363 virtual wxSize
GetFrameIconSize() const;
365 virtual int HitTestFrame(const wxRect
& rect
,
367 int flags
= 0) const;
370 // draw the background with any colour, not only the default one(s)
371 void DoDrawBackground(wxDC
& dc
,
374 wxWindow
*window
= NULL
);
376 // DrawBorder() helpers: all of them shift and clip the DC after drawing
379 // just draw a rectangle with the given pen
380 void DrawRect(wxDC
& dc
, wxRect
*rect
, const wxPen
& pen
);
382 // draw an opened rect for the arrow in given direction
383 void DrawArrowBorder(wxDC
& dc
,
387 // draw two sides of the rectangle
388 void DrawThumbBorder(wxDC
& dc
,
390 wxOrientation orient
);
393 // returns the size of the arrow for the scrollbar (depends on
395 wxSize
GetScrollbarArrowSize(const wxScrollBar
*scrollbar
) const
398 if ( scrollbar
->IsVertical() )
400 size
= m_sizeScrollbarArrow
;
404 size
.x
= m_sizeScrollbarArrow
.y
;
405 size
.y
= m_sizeScrollbarArrow
.x
;
410 #endif // wxUSE_SCROLLBAR
412 // DrawCheckBitmap and DrawRadioBitmap helpers
414 // draw the check bitmaps once and cache them for later use
415 wxBitmap
GetCheckBitmap(int flags
);
417 // draw a /\ or \/ line from (x1, y1) to (x2, y1) passing by the point
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
);
426 // draw the radio button bitmap for the given state
427 void DrawRadioBitmap(wxDC
& dc
, const wxRect
& rect
, int flags
);
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
,
438 // common part of DrawMenuItem() and DrawMenuBarItem()
439 void DoDrawMenuItem(wxDC
& dc
,
441 const wxString
& label
,
444 const wxString
& accel
= wxEmptyString
,
445 const wxBitmap
& bitmap
= wxNullBitmap
,
446 const wxMonoMenuGeometryInfo
*geometryInfo
= NULL
);
449 // initialize the combo bitmaps
450 void InitComboBitmaps();
451 #endif // wxUSE_COMBOBOX
455 wxSize m_sizeScrollbarArrow
;
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];
462 // the combobox bitmaps
472 wxBitmap m_bitmapsCombo
[ComboState_Max
];
475 // ----------------------------------------------------------------------------
476 // wxMonoInputHandler
477 // ----------------------------------------------------------------------------
479 class wxMonoInputHandler
: public wxInputHandler
482 wxMonoInputHandler(wxMonoRenderer
*renderer
);
484 virtual bool HandleKey(wxInputConsumer
*control
,
485 const wxKeyEvent
& event
,
487 virtual bool HandleMouse(wxInputConsumer
*control
,
488 const wxMouseEvent
& event
);
489 virtual bool HandleMouseMove(wxInputConsumer
*control
, const wxMouseEvent
& event
);
492 wxMonoRenderer
*m_renderer
;
495 // ----------------------------------------------------------------------------
496 // wxMonoColourScheme: uses just white and black
497 // ----------------------------------------------------------------------------
499 class wxMonoColourScheme
: public wxColourScheme
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
; }
507 // implement base class pure virtuals
508 virtual wxColour
Get(StdColour col
) const;
509 virtual wxColour
GetBackground(wxWindow
*win
) const;
512 // ----------------------------------------------------------------------------
514 // ----------------------------------------------------------------------------
516 class wxMonoArtProvider
: public wxArtProvider
519 virtual wxBitmap
CreateBitmap(const wxArtID
& id
,
520 const wxArtClient
& client
,
524 // ----------------------------------------------------------------------------
526 // ----------------------------------------------------------------------------
528 WX_DEFINE_ARRAY_PTR(wxInputHandler
*, wxArrayHandlers
);
530 class wxMonoTheme
: public wxTheme
534 virtual ~wxMonoTheme();
536 virtual wxRenderer
*GetRenderer();
537 virtual wxArtProvider
*GetArtProvider();
538 virtual wxInputHandler
*GetInputHandler(const wxString
& control
);
539 virtual wxColourScheme
*GetColourScheme();
542 wxMonoRenderer
*m_renderer
;
543 wxMonoArtProvider
*m_artProvider
;
544 wxMonoColourScheme
*m_scheme
;
546 WX_DECLARE_THEME(gtk
)
549 // ============================================================================
551 // ============================================================================
553 WX_IMPLEMENT_THEME(wxMonoTheme
, mono
, wxTRANSLATE("Simple monochrome theme"));
555 // ----------------------------------------------------------------------------
557 // ----------------------------------------------------------------------------
559 wxMonoTheme::wxMonoTheme()
563 m_artProvider
= NULL
;
566 wxMonoTheme::~wxMonoTheme()
570 wxArtProvider::RemoveProvider(m_artProvider
);
573 wxRenderer
*wxMonoTheme::GetRenderer()
577 m_renderer
= new wxMonoRenderer(GetColourScheme());
583 wxArtProvider
*wxMonoTheme::GetArtProvider()
585 if ( !m_artProvider
)
587 m_artProvider
= new wxMonoArtProvider
;
590 return m_artProvider
;
593 wxColourScheme
*wxMonoTheme::GetColourScheme()
597 m_scheme
= new wxMonoColourScheme
;
603 wxInputHandler
*wxMonoTheme::GetInputHandler(const wxString
& WXUNUSED(control
),
604 wxInputConsumer
*consumer
)
606 // no special input handlers so far
607 return consumer
->DoGetStdInputHandler(NULL
);
610 // ============================================================================
611 // wxMonoColourScheme
612 // ============================================================================
614 wxColour
wxMonoColourScheme::GetBackground(wxWindow
*win
) const
617 if ( win
->UseBgCol() )
619 // use the user specified colour
620 col
= win
->GetBackgroundColour();
623 // doesn't depend on the state
630 wxColour
wxMonoColourScheme::Get(wxMonoColourScheme::StdColour col
) const
636 case CONTROL_PRESSED
:
637 case CONTROL_CURRENT
:
639 case SCROLLBAR_PRESSED
:
643 case TITLEBAR_ACTIVE
:
649 wxFAIL_MSG(_T("invalid standard colour"));
653 case SHADOW_HIGHLIGHT
:
657 case CONTROL_TEXT_DISABLED
:
658 case CONTROL_TEXT_DISABLED_SHADOW
:
661 case TITLEBAR_ACTIVE_TEXT
:
667 // ============================================================================
669 // ============================================================================
671 // ----------------------------------------------------------------------------
673 // ----------------------------------------------------------------------------
675 wxMonoRenderer::wxMonoRenderer(const wxColourScheme
*scheme
)
676 : wxStdRenderer(scheme
)
678 m_penFg
= wxPen(wxSCHEME_COLOUR(scheme
, SHADOW_OUT
));
681 // ----------------------------------------------------------------------------
683 // ----------------------------------------------------------------------------
685 // ----------------------------------------------------------------------------
687 // ----------------------------------------------------------------------------
689 void wxMonoRenderer::DrawTextBorder(wxDC
& dc
,
691 const wxRect
& rectOrig
,
695 DrawBorder(dc
, border
, rectOrig
, flags
, rectIn
);
698 void wxMonoRenderer::DrawButtonBorder(wxDC
& dc
,
699 const wxRect
& rectTotal
,
703 DrawBorder(dc
, wxBORDER_SIMPLE
, rectOrig
, flags
, rectIn
);
706 // ----------------------------------------------------------------------------
708 // ----------------------------------------------------------------------------
711 wxMonoRenderer::DrawHorizontalLine(wxDC
& dc
, wxCoord y
, wxCoord x1
, wxCoord x2
)
714 dc
.DrawLine(x1
, y
, x2
+ 1, y
);
718 wxMonoRenderer::DrawVerticalLine(wxDC
& dc
, wxCoord x
, wxCoord y1
, wxCoord y2
)
721 dc
.DrawLine(x
, y1
, x
, y2
+ 1);
724 void wxMonoRenderer::DrawFrame(wxDC
& dc
,
725 const wxString
& label
,
731 wxCoord height
= 0; // of the label
732 wxRect rectFrame
= rect
;
733 if ( !label
.empty() )
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;
741 // TODO: the +4 should be customizable
744 rectText
.x
= rectFrame
.x
+ 4;
746 rectText
.width
= rectFrame
.width
- 8;
747 rectText
.height
= height
;
750 DrawLabel(dc
, label
, rectText
, flags
, alignment
, indexAccel
, &rectLabel
);
752 rectLabel
.width
+= 2;
754 StandardDrawFrame(dc
, rectFrame
, rectLabel
);
758 // just draw the complete frame
759 DrawShadedRect(dc
, &rectFrame
, m_penDarkGrey
, m_penHighlight
);
760 DrawShadedRect(dc
, &rectFrame
, m_penHighlight
, m_penDarkGrey
);
764 // ----------------------------------------------------------------------------
766 // ----------------------------------------------------------------------------
768 void wxMonoRenderer::DrawLabel(wxDC
& dc
,
769 const wxString
& label
,
776 DrawButtonLabel(dc
, label
, wxNullBitmap
, rect
, flags
,
777 alignment
, indexAccel
, rectBounds
);
780 void wxMonoRenderer::DrawButtonLabel(wxDC
& dc
,
781 const wxString
& label
,
782 const wxBitmap
& image
,
789 dc
.SetTextForeground(wxSCHEME_COLOUR(m_scheme
, CONTROL_TEXT
));
790 dc
.DrawLabel(label
, image
, rect
, alignment
, indexAccel
, rectBounds
);
792 if ( flags
& wxCONTROL_DISABLED
)
794 // this is ugly but I don't know how to show disabled button visually
795 // in monochrome theme otherwise
797 dc
.DrawLine(rect
.GetTopLeft(), rect
.GetBottomRight());
798 dc
.DrawLine(rect
.GetTopRight(), rect
.GetBottomLeft());
802 void wxMonoRenderer::DrawItem(wxDC
& dc
,
803 const wxString
& label
,
808 if ( flags
& wxCONTROL_SELECTED
)
810 dc
.SetBrush(wxBrush(wxSCHEME_COLOUR(m_scheme
, HIGHLIGHT
), wxSOLID
));
811 dc
.SetPen(*wxTRANSPARENT_PEN
);
812 dc
.DrawRectangle(rect
);
814 colFg
= dc
.GetTextForeground();
815 dc
.SetTextForeground(wxSCHEME_COLOUR(m_scheme
, HIGHLIGHT_TEXT
));
818 if ( flags
& wxCONTROL_FOCUSED
)
820 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
821 wxRect rectFocus
= rect
;
822 DrawRect(dc
, &rectFocus
, m_penBlack
);
825 wxRect rectText
= rect
;
828 dc
.DrawLabel(label
, wxNullBitmap
, rectText
);
830 if ( flags
& wxCONTROL_SELECTED
)
832 dc
.SetBackgroundMode(wxTRANSPARENT
);
835 // restore the text colour
838 dc
.SetTextForeground(colFg
);
842 void wxMonoRenderer::DrawCheckItem(wxDC
& dc
,
843 const wxString
& label
,
844 const wxBitmap
& bitmap
,
848 wxRect rectBitmap
= rect
;
850 rectBitmap
.width
= GetCheckBitmapSize().x
;
852 // never draw the focus rect around the check indicators here
853 DrawCheckButton(dc
, wxEmptyString
, bitmap
, rectBitmap
, flags
& ~wxCONTROL_FOCUSED
);
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
);
862 // ----------------------------------------------------------------------------
863 // check/radion buttons
864 // ----------------------------------------------------------------------------
866 void wxMonoRenderer::DrawUndeterminedBitmap(wxDC
& dc
,
867 const wxRect
& rectTotal
,
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
;
878 col1
= wxSCHEME_COLOUR(m_scheme
, SHADOW_DARK
);
879 col2
= wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
);
883 col1
= wxSCHEME_COLOUR(m_scheme
, SHADOW_DARK
);
884 col2
= wxSCHEME_COLOUR(m_scheme
, SHADOW_IN
);
887 dc
.SetPen(*wxTRANSPARENT_PEN
);
888 dc
.SetBrush(wxBrush(col1
, wxSOLID
));
889 dc
.DrawRectangle(rect
);
891 dc
.SetBrush(wxBrush(col2
, wxSOLID
));
892 dc
.DrawRectangle(rect
);
895 void wxMonoRenderer::DrawUncheckBitmap(wxDC
& dc
,
896 const wxRect
& rectTotal
,
899 wxRect rect
= rectTotal
;
900 DrawAntiRaisedBorder(dc
, &rect
);
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);
907 col
= wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
);
908 //else: it is SHADOW_IN, leave as is
910 dc
.SetPen(*wxTRANSPARENT_PEN
);
911 dc
.SetBrush(wxBrush(col
, wxSOLID
));
912 dc
.DrawRectangle(rect
);
915 void wxMonoRenderer::DrawCheckBitmap(wxDC
& dc
, const wxRect
& rectTotal
)
917 wxRect rect
= rectTotal
;
918 DrawAntiShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
919 DrawShadedRect(dc
, &rect
, m_penBlack
, m_penLightGrey
);
921 dc
.SetPen(*wxTRANSPARENT_PEN
);
922 dc
.SetBrush(wxBrush(wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
), wxSOLID
));
923 dc
.DrawRectangle(rect
);
926 void wxMonoRenderer::DrawRadioBitmap(wxDC
& dc
,
932 xRight
= rect
.GetRight(),
933 yBottom
= rect
.GetBottom();
935 wxCoord yMid
= (y
+ yBottom
) / 2;
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
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
);
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);
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
964 DrawUpZag(dc
, x
+ 2, xRight
- 2, yMid
, y
+ 2);
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);
973 if ( !(flags
& wxCONTROL_CHECKED
) )
974 drawIt
= true; // with the same pen
975 else if ( flags
& wxCONTROL_PRESSED
)
977 dc
.SetPen(wxPen(wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
), 0, wxSOLID
));
980 else // checked and unpressed
984 DrawDownZag(dc
, x
+ 2, xRight
- 2, yMid
, yBottom
- 2);
987 void wxMonoRenderer::DrawUpZag(wxDC
& dc
,
993 wxCoord xMid
= (x1
+ x2
) / 2;
994 dc
.DrawLine(x1
, y1
, xMid
, y2
);
995 dc
.DrawLine(xMid
, y2
, x2
+ 1, y1
+ 1);
998 void wxMonoRenderer::DrawDownZag(wxDC
& dc
,
1004 wxCoord xMid
= (x1
+ x2
) / 2;
1005 dc
.DrawLine(x1
+ 1, y1
+ 1, xMid
, y2
);
1006 dc
.DrawLine(xMid
, y2
, x2
, y1
);
1009 wxBitmap
wxMonoRenderer::GetCheckBitmap(int flags
)
1011 if ( !m_bitmapsCheckbox
[0][0].Ok() )
1013 // init the bitmaps once only
1015 wxSize size
= GetCheckBitmapSize();
1016 rect
.width
= size
.x
;
1017 rect
.height
= size
.y
;
1018 for ( int i
= 0; i
< 2; i
++ )
1020 for ( int j
= 0; j
< 3; j
++ )
1021 m_bitmapsCheckbox
[i
][j
].Create(rect
.width
, rect
.height
);
1027 dc
.SelectObject(m_bitmapsCheckbox
[0][0]);
1028 DrawCheckBitmap(dc
, rect
);
1031 dc
.SelectObject(m_bitmapsCheckbox
[0][1]);
1032 DrawUncheckBitmap(dc
, rect
, false);
1034 // normal undeterminated
1035 dc
.SelectObject(m_bitmapsCheckbox
[0][2]);
1036 DrawUndeterminedBitmap(dc
, rect
, false);
1039 m_bitmapsCheckbox
[1][0] = m_bitmapsCheckbox
[0][0];
1041 // pressed unchecked
1042 dc
.SelectObject(m_bitmapsCheckbox
[1][1]);
1043 DrawUncheckBitmap(dc
, rect
, true);
1045 // pressed undeterminated
1046 dc
.SelectObject(m_bitmapsCheckbox
[1][2]);
1047 DrawUndeterminedBitmap(dc
, rect
, true);
1050 int row
= flags
& wxCONTROL_PRESSED
1053 int col
= flags
& wxCONTROL_CHECKED
1055 : ( flags
& wxCONTROL_UNDETERMINED
1059 return m_bitmapsCheckbox
[row
][col
];
1062 void wxMonoRenderer::DrawCheckButton(wxDC
& dc
,
1063 const wxString
& label
,
1064 const wxBitmap
& bitmapOrig
,
1065 const wxRect
& rectTotal
,
1071 if ( bitmapOrig
.Ok() )
1073 bitmap
= bitmapOrig
;
1077 bitmap
= GetCheckBitmap(flags
);
1080 DoDrawCheckOrRadioBitmap(dc
, label
, bitmap
, rectTotal
,
1081 flags
, align
, indexAccel
);
1084 void wxMonoRenderer::DoDrawCheckOrRadioBitmap(wxDC
& dc
,
1085 const wxString
& label
,
1086 const wxBitmap
& bitmap
,
1087 const wxRect
& rectTotal
,
1092 wxRect rect
= rectTotal
;
1094 if ( flags
& wxCONTROL_FOCUSED
)
1096 // draw the focus border around everything
1097 DrawRect(dc
, &rect
, m_penBlack
);
1101 // the border does not offset the string under Mono
1105 // calculate the position of the bitmap and of the label
1107 yBmp
= rect
.y
+ (rect
.height
- bitmap
.GetHeight()) / 2;
1110 dc
.GetMultiLineTextExtent(label
, NULL
, &rectLabel
.height
);
1111 rectLabel
.y
= rect
.y
+ (rect
.height
- rectLabel
.height
) / 2;
1113 if ( align
== wxALIGN_RIGHT
)
1115 xBmp
= rect
.GetRight() - bitmap
.GetWidth();
1116 rectLabel
.x
= rect
.x
+ 2;
1117 rectLabel
.SetRight(xBmp
);
1119 else // normal (checkbox to the left of the text) case
1122 rectLabel
.x
= xBmp
+ bitmap
.GetWidth() + 4;
1123 rectLabel
.SetRight(rect
.GetRight());
1126 dc
.DrawBitmap(bitmap
, xBmp
, yBmp
, true /* use mask */);
1128 DrawLabel(dc
, label
, rectLabel
, flags
,
1129 wxALIGN_LEFT
| wxALIGN_CENTRE_VERTICAL
, indexAccel
);
1132 void wxMonoRenderer::DrawRadioButton(wxDC
& dc
,
1133 const wxString
& label
,
1134 const wxBitmap
& bitmapOrig
,
1135 const wxRect
& rectTotal
,
1141 if ( bitmapOrig
.Ok() )
1143 bitmap
= bitmapOrig
;
1148 wxSize size
= GetRadioBitmapSize();
1149 rect
.width
= size
.x
;
1150 rect
.height
= size
.y
;
1151 bitmap
.Create(rect
.width
, rect
.height
);
1153 dc
.SelectObject(bitmap
);
1154 dc
.SetBackground(*wxLIGHT_GREY_BRUSH
);
1156 DrawRadioBitmap(dc
, rect
, flags
);
1158 // must unselect the bitmap before setting a mask for it because of the
1160 dc
.SelectObject(wxNullBitmap
);
1161 bitmap
.SetMask(new wxMask(bitmap
, *wxLIGHT_GREY
));
1164 DoDrawCheckOrRadioBitmap(dc
, label
, bitmap
, rectTotal
,
1165 flags
, align
, indexAccel
);
1169 void wxMonoRenderer::DrawToolBarButton(wxDC
& dc
,
1170 const wxString
& label
,
1171 const wxBitmap
& bitmap
,
1172 const wxRect
& rectOrig
,
1174 long WXUNUSED(style
),
1177 // we don't draw the separators at all
1178 if ( !label
.empty() || bitmap
.Ok() )
1180 wxRect rect
= rectOrig
;
1181 rect
.Deflate(BORDER_THICKNESS
);
1183 if ( flags
& wxCONTROL_PRESSED
)
1185 DrawBorder(dc
, wxBORDER_SUNKEN
, rect
, flags
, &rect
);
1187 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
), rect
);
1189 else if ( flags
& wxCONTROL_CURRENT
)
1191 DrawBorder(dc
, wxBORDER_RAISED
, rect
, flags
, &rect
);
1193 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL_CURRENT
), rect
);
1196 if(tbarStyle
& wxTB_TEXT
)
1198 if(tbarStyle
& wxTB_HORIZONTAL
)
1200 dc
.DrawLabel(label
, bitmap
, rect
, wxALIGN_CENTRE
);
1204 dc
.DrawLabel(label
, bitmap
, rect
, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
);
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
);
1215 #endif // wxUSE_TOOLBAR
1217 // ----------------------------------------------------------------------------
1219 // ----------------------------------------------------------------------------
1223 wxRect
wxMonoRenderer::GetTextTotalArea(const wxTextCtrl
* WXUNUSED(text
),
1224 const wxRect
& rect
) const
1226 wxRect rectTotal
= rect
;
1227 rectTotal
.Inflate(2*BORDER_THICKNESS
);
1231 wxRect
wxMonoRenderer::GetTextClientArea(const wxTextCtrl
*text
,
1233 wxCoord
*extraSpaceBeyond
) const
1235 wxRect rectText
= rect
;
1236 rectText
.Deflate(2*BORDER_THICKNESS
);
1241 void wxMonoRenderer::DrawTextLine(wxDC
& dc
,
1242 const wxString
& text
,
1248 StandardDrawTextLine(dc
, text
, rect
, selStart
, selEnd
, flags
);
1252 wxMonoRenderer::DrawLineWrapMark(wxDC
& WXUNUSED(dc
),
1253 const wxRect
& WXUNUSED(rect
))
1255 // no line wrapping indicators
1258 #endif // wxUSE_TEXTCTRL
1260 // ----------------------------------------------------------------------------
1262 // ----------------------------------------------------------------------------
1266 void wxMonoRenderer::InitComboBitmaps()
1268 wxSize sizeArrow
= m_sizeScrollbarArrow
;
1274 for ( n
= ComboState_Normal
; n
< ComboState_Max
; n
++ )
1276 m_bitmapsCombo
[n
].Create(sizeArrow
.x
, sizeArrow
.y
);
1279 static const int comboButtonFlags
[ComboState_Max
] =
1287 wxRect
rect(sizeArrow
);
1290 for ( n
= ComboState_Normal
; n
< ComboState_Max
; n
++ )
1292 int flags
= comboButtonFlags
[n
];
1294 dc
.SelectObject(m_bitmapsCombo
[n
]);
1295 DoDrawBackground(dc
, GetBackgroundColour(flags
), rect
);
1296 DrawArrow(dc
, wxDOWN
, rect
, flags
);
1300 void wxMonoRenderer::GetComboBitmaps(wxBitmap
*bmpNormal
,
1302 wxBitmap
*bmpPressed
,
1303 wxBitmap
*bmpDisabled
)
1305 if ( !m_bitmapsCombo
[ComboState_Normal
].Ok() )
1311 *bmpNormal
= m_bitmapsCombo
[ComboState_Normal
];
1313 *bmpFocus
= m_bitmapsCombo
[ComboState_Focus
];
1315 *bmpPressed
= m_bitmapsCombo
[ComboState_Pressed
];
1317 *bmpDisabled
= m_bitmapsCombo
[ComboState_Disabled
];
1320 #endif // wxUSE_COMBOBOX
1322 // ----------------------------------------------------------------------------
1324 // ----------------------------------------------------------------------------
1326 void wxMonoRenderer::DoDrawBackground(wxDC
& dc
,
1327 const wxColour
& col
,
1329 wxWindow
* WXUNUSED(window
))
1331 wxBrush
brush(col
, wxSOLID
);
1333 dc
.SetPen(*wxTRANSPARENT_PEN
);
1334 dc
.DrawRectangle(rect
);
1337 void wxMonoRenderer::DrawBackground(wxDC
& dc
,
1338 const wxColour
& col
,
1340 int WXUNUSED(flags
),
1345 // ----------------------------------------------------------------------------
1347 // ----------------------------------------------------------------------------
1349 void wxMonoRenderer::DrawArrowBorder(wxDC
& dc
,
1353 static const wxDirection sides
[] =
1355 wxUP
, wxLEFT
, wxRIGHT
, wxDOWN
1358 wxRect rect1
, rect2
, rectInner
;
1364 rectInner
.Inflate(-2);
1366 DoDrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
), *rect
);
1368 // find the side not to draw and also adjust the rectangles to compensate
1370 wxDirection sideToOmit
;
1374 sideToOmit
= wxDOWN
;
1376 rectInner
.height
+= 1;
1384 rectInner
.height
+= 1;
1388 sideToOmit
= wxRIGHT
;
1390 rectInner
.width
+= 1;
1394 sideToOmit
= wxLEFT
;
1398 rectInner
.width
+= 1;
1402 wxFAIL_MSG(_T("unknown arrow direction"));
1406 // the outer rect first
1408 for ( n
= 0; n
< WXSIZEOF(sides
); n
++ )
1410 wxDirection side
= sides
[n
];
1411 if ( side
== sideToOmit
)
1414 DrawAntiShadedRectSide(dc
, rect1
, m_penDarkGrey
, m_penHighlight
, side
);
1417 // and then the inner one
1418 for ( n
= 0; n
< WXSIZEOF(sides
); n
++ )
1420 wxDirection side
= sides
[n
];
1421 if ( side
== sideToOmit
)
1424 DrawAntiShadedRectSide(dc
, rect2
, m_penBlack
, m_penGrey
, side
);
1430 void wxMonoRenderer::DrawScrollbarArrow(wxDC
& dc
,
1432 const wxRect
& rectArrow
,
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
);
1440 // then the arrow itself
1441 DrawArrow(dc
, dir
, rect
, flags
);
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
,
1459 wxPoint ptArrow
[Point_Max
];
1461 wxColour colInside
= GetBackgroundColour(flags
);
1463 if ( flags
& wxCONTROL_DISABLED
)
1465 penShadow
[0] = m_penDarkGrey
;
1466 penShadow
[1] = m_penDarkGrey
;
1467 penShadow
[2] = wxNullPen
;
1468 penShadow
[3] = wxNullPen
;
1470 else if ( flags
& wxCONTROL_PRESSED
)
1472 penShadow
[0] = m_penDarkGrey
;
1473 penShadow
[1] = m_penHighlight
;
1474 penShadow
[2] = wxNullPen
;
1475 penShadow
[3] = m_penBlack
;
1477 else // normal arrow
1479 penShadow
[0] = m_penHighlight
;
1480 penShadow
[1] = m_penBlack
;
1481 penShadow
[2] = m_penDarkGrey
;
1482 penShadow
[3] = wxNullPen
;
1486 if ( dir
== wxUP
|| dir
== wxDOWN
)
1489 middle
= (rect
.GetRight() + rect
.GetLeft() + 1) / 2;
1493 middle
= (rect
.GetTop() + rect
.GetBottom() + 1) / 2;
1496 // draw the arrow interior
1497 dc
.SetPen(*wxTRANSPARENT_PEN
);
1498 dc
.SetBrush(wxBrush(colInside
, wxSOLID
));
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();
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();
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();
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();
1537 wxFAIL_MSG(_T("unknown arrow direction"));
1540 dc
.DrawPolygon(WXSIZEOF(ptArrow
), ptArrow
);
1542 // draw the arrow border
1543 dc
.SetPen(penShadow
[0]);
1547 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_First
]);
1548 dc
.DrawPoint(ptArrow
[Point_First
]);
1549 if ( penShadow
[3].Ok() )
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
);
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() )
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);
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() )
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);
1581 dc
.SetPen(penShadow
[1]);
1582 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_Third
]);
1583 dc
.DrawPoint(ptArrow
[Point_Third
]);
1587 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_First
]);
1588 dc
.DrawPoint(ptArrow
[Point_First
]);
1589 if ( penShadow
[2].Ok() )
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);
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
);
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
]);
1614 wxFAIL_MSG(_T("unknown arrow direction"));
1619 void wxMonoRenderer::DrawThumbBorder(wxDC
& dc
,
1621 wxOrientation orient
)
1623 if ( orient
== wxVERTICAL
)
1625 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
1627 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
1629 rect
->Inflate(-1, 0);
1631 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
1633 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
1635 rect
->Inflate(-1, 0);
1639 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
1641 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
1643 rect
->Inflate(0, -1);
1645 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
1647 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
1649 rect
->Inflate(0, -1);
1653 void wxMonoRenderer::DrawScrollbarThumb(wxDC
& dc
,
1654 wxOrientation orient
,
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
);
1662 // we don't want the border in the direction of the scrollbar movement
1663 wxRect rectThumb
= rect
;
1664 DrawThumbBorder(dc
, &rectThumb
, orient
);
1666 DrawButtonBorder(dc
, rectThumb
, flagsThumb
, &rectThumb
);
1667 DrawBackground(dc
, wxNullColour
, rectThumb
, flagsThumb
);
1670 void wxMonoRenderer::DrawScrollbarShaft(wxDC
& dc
,
1671 wxOrientation orient
,
1673 int WXUNUSED(flags
))
1675 wxRect rectBar
= rect
;
1676 DrawThumbBorder(dc
, &rectBar
, orient
);
1677 DoDrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
), rectBar
);
1680 void wxMonoRenderer::DrawScrollCorner(wxDC
& dc
, const wxRect
& rect
)
1682 DoDrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL
), rect
);
1686 wxRect
wxMonoRenderer::GetScrollbarRect(const wxScrollBar
*scrollbar
,
1687 wxScrollBar::Element elem
,
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
1693 if ( (elem
== wxScrollBar::Element_Thumb
) && !scrollbar
->GetRange() )
1695 elem
= wxScrollBar::Element_Bar_2
;
1698 return StandardGetScrollbarRect(scrollbar
, elem
,
1700 GetScrollbarArrowSize(scrollbar
));
1703 wxCoord
wxMonoRenderer::GetScrollbarSize(const wxScrollBar
*scrollbar
)
1705 return StandardScrollBarSize(scrollbar
, GetScrollbarArrowSize(scrollbar
));
1708 wxHitTest
wxMonoRenderer::HitTestScrollbar(const wxScrollBar
*scrollbar
,
1709 const wxPoint
& pt
) const
1711 return StandardHitTestScrollbar(scrollbar
, pt
,
1712 GetScrollbarArrowSize(scrollbar
));
1715 wxCoord
wxMonoRenderer::ScrollbarToPixel(const wxScrollBar
*scrollbar
,
1718 return StandardScrollbarToPixel(scrollbar
, thumbPos
,
1719 GetScrollbarArrowSize(scrollbar
));
1722 int wxMonoRenderer::PixelToScrollbar(const wxScrollBar
*scrollbar
,
1725 return StandardPixelToScrollbar(scrollbar
, coord
,
1726 GetScrollbarArrowSize(scrollbar
));
1728 #endif // wxUSE_SCROLLBAR
1730 // ----------------------------------------------------------------------------
1732 // ----------------------------------------------------------------------------
1734 void wxMonoRenderer::AdjustSize(wxSize
*size
, const wxWindow
*window
)
1737 if ( wxDynamicCast(window
, wxBitmapButton
) )
1742 #endif // wxUSE_BMPBUTTON
1743 #if wxUSE_BUTTON || wxUSE_TOGGLEBTN
1746 || wxDynamicCast(window
, wxButton
)
1747 # endif // wxUSE_BUTTON
1748 # if wxUSE_TOGGLEBTN
1749 || wxDynamicCast(window
, wxToggleButton
)
1750 # endif // wxUSE_TOGGLEBTN
1753 if ( !(window
->GetWindowStyle() & wxBU_EXACTFIT
) )
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
;
1761 // button border width
1765 #endif // wxUSE_BUTTON || wxUSE_TOGGLEBTN
1767 if ( wxDynamicCast(window
, wxScrollBar
) )
1769 // we only set the width of vert scrollbars and height of the
1771 if ( window
->GetWindowStyle() & wxSB_HORIZONTAL
)
1772 size
->y
= m_sizeScrollbarArrow
.x
;
1774 size
->x
= m_sizeScrollbarArrow
.x
;
1777 #endif // wxUSE_SCROLLBAR
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
;
1786 // ----------------------------------------------------------------------------
1787 // top level windows
1788 // ----------------------------------------------------------------------------
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
))
1800 void wxMonoRenderer::DrawFrameBorder(wxDC
& WXUNUSED(dc
),
1801 const wxRect
& WXUNUSED(rect
),
1802 int WXUNUSED(flags
))
1806 void wxMonoRenderer::DrawFrameBackground(wxDC
& WXUNUSED(dc
),
1807 const wxRect
& WXUNUSED(rect
),
1808 int WXUNUSED(flags
))
1812 void wxMonoRenderer::DrawFrameTitle(wxDC
& WXUNUSED(dc
),
1813 const wxRect
& WXUNUSED(rect
),
1814 const wxString
& WXUNUSED(title
),
1815 int WXUNUSED(flags
))
1819 void wxMonoRenderer::DrawFrameIcon(wxDC
& WXUNUSED(dc
),
1820 const wxRect
& WXUNUSED(rect
),
1821 const wxIcon
& WXUNUSED(icon
),
1822 int WXUNUSED(flags
))
1826 void wxMonoRenderer::DrawFrameButton(wxDC
& WXUNUSED(dc
),
1827 wxCoord
WXUNUSED(x
),
1828 wxCoord
WXUNUSED(y
),
1829 int WXUNUSED(button
),
1830 int WXUNUSED(flags
))
1835 wxMonoRenderer::GetFrameClientArea(const wxRect
& rect
,
1836 int WXUNUSED(flags
)) const
1842 wxMonoRenderer::GetFrameTotalSize(const wxSize
& clientSize
,
1843 int WXUNUSED(flags
)) const
1848 wxSize
wxMonoRenderer::GetFrameMinSize(int WXUNUSED(flags
)) const
1853 wxSize
wxMonoRenderer::GetFrameIconSize() const
1855 return wxSize(wxDefaultCoord
, wxDefaultCoord
);
1859 wxMonoRenderer::HitTestFrame(const wxRect
& WXUNUSED(rect
),
1860 const wxPoint
& WXUNUSED(pt
),
1861 int WXUNUSED(flags
)) const
1863 return wxHT_TOPLEVEL_CLIENT_AREA
;
1867 // ----------------------------------------------------------------------------
1869 // ----------------------------------------------------------------------------
1871 /* Copyright (c) Julian Smart */
1872 static const char *error_xpm
[] = {
1873 /* columns rows colors chars-per-pixel */
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 ",
1930 /* Copyright (c) Julian Smart */
1931 static const char *info_xpm
[] = {
1932 /* columns rows colors chars-per-pixel */
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. ",
1994 /* Copyright (c) Julian Smart */
1995 static const char *warning_xpm
[] = {
1996 /* columns rows colors chars-per-pixel */
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 " .............................. ",
2058 /* Copyright (c) Julian Smart */
2059 static const char *question_xpm
[] = {
2060 /* columns rows colors chars-per-pixel */
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;. ",
2134 wxBitmap
wxMonoArtProvider::CreateBitmap(const wxArtID
& id
,
2135 const wxArtClient
& WXUNUSED(client
),
2136 const wxSize
& WXUNUSED(size
))
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
;
2150 // ============================================================================
2152 // ============================================================================