1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/univ/themes/gtk.cpp
3 // Purpose: wxUniversal theme implementing GTK-like LNF
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ===========================================================================
14 // ===========================================================================
16 // ---------------------------------------------------------------------------
18 // ---------------------------------------------------------------------------
20 // for compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
27 #include "wx/univ/theme.h"
34 #include "wx/dcmemory.h"
35 #include "wx/window.h"
39 #include "wx/bmpbuttn.h"
40 #include "wx/button.h"
41 #include "wx/checkbox.h"
42 #include "wx/listbox.h"
43 #include "wx/checklst.h"
44 #include "wx/combobox.h"
45 #include "wx/scrolbar.h"
46 #include "wx/slider.h"
47 #include "wx/textctrl.h"
48 #include "wx/toolbar.h"
49 #include "wx/statusbr.h"
51 #include "wx/settings.h"
52 #include "wx/toplevel.h"
56 #include "wx/notebook.h"
57 #include "wx/spinbutt.h"
58 #include "wx/artprov.h"
59 #ifdef wxUSE_TOGGLEBTN
60 #include "wx/tglbtn.h"
61 #endif // wxUSE_TOGGLEBTN
63 #include "wx/univ/stdrend.h"
64 #include "wx/univ/inpcons.h"
65 #include "wx/univ/inphand.h"
66 #include "wx/univ/colschem.h"
68 class WXDLLEXPORT wxGTKMenuGeometryInfo
;
70 // ----------------------------------------------------------------------------
72 // ----------------------------------------------------------------------------
74 // standard border size
75 static const int BORDER_THICKNESS
= 2;
77 // ----------------------------------------------------------------------------
78 // wxGTKRenderer: draw the GUI elements in GTK style
79 // ----------------------------------------------------------------------------
81 class wxGTKRenderer
: public wxStdRenderer
84 wxGTKRenderer(const wxColourScheme
*scheme
);
87 virtual void DrawFocusRect(wxDC
& dc
, const wxRect
& rect
, int flags
= 0);
88 virtual void DrawTextBorder(wxDC
& dc
,
92 wxRect
*rectIn
= NULL
);
93 virtual void DrawButtonLabel(wxDC
& dc
,
94 const wxString
& label
,
95 const wxBitmap
& image
,
101 virtual void DrawButtonBorder(wxDC
& dc
,
104 wxRect
*rectIn
= NULL
);
105 virtual void DrawArrow(wxDC
& dc
,
109 virtual void DrawScrollbarArrow(wxDC
& dc
,
113 virtual void DrawScrollbarThumb(wxDC
& dc
,
114 wxOrientation orient
,
117 virtual void DrawScrollbarShaft(wxDC
& dc
,
118 wxOrientation orient
,
123 virtual void DrawToolBarButton(wxDC
& dc
,
124 const wxString
& label
,
125 const wxBitmap
& bitmap
,
130 #endif // wxUSE_TOOLBAR
133 virtual void DrawLineWrapMark(wxDC
& dc
, const wxRect
& rect
);
134 #endif // wxUSE_TEXTCTRL
137 virtual void DrawTab(wxDC
& dc
,
140 const wxString
& label
,
141 const wxBitmap
& bitmap
= wxNullBitmap
,
143 int indexAccel
= -1);
144 #endif // wxUSE_NOTEBOOK
147 virtual void DrawSliderShaft(wxDC
& dc
,
150 wxOrientation orient
,
153 wxRect
*rectShaft
= NULL
);
154 virtual void DrawSliderThumb(wxDC
& dc
,
156 wxOrientation orient
,
159 virtual void DrawSliderTicks(wxDC
& WXUNUSED(dc
),
160 const wxRect
& WXUNUSED(rect
),
161 int WXUNUSED(lenThumb
),
162 wxOrientation
WXUNUSED(orient
),
165 int WXUNUSED(step
) = 1,
166 int WXUNUSED(flags
) = 0,
167 long WXUNUSED(style
) = 0)
169 // we don't have the ticks in GTK version
171 #endif // wxUSE_SLIDER
174 virtual void DrawMenuBarItem(wxDC
& dc
,
176 const wxString
& label
,
178 int indexAccel
= -1);
179 virtual void DrawMenuItem(wxDC
& dc
,
181 const wxMenuGeometryInfo
& geometryInfo
,
182 const wxString
& label
,
183 const wxString
& accel
,
184 const wxBitmap
& bitmap
= wxNullBitmap
,
186 int indexAccel
= -1);
187 virtual void DrawMenuSeparator(wxDC
& dc
,
189 const wxMenuGeometryInfo
& geomInfo
);
190 #endif // wxUSE_MENUS
192 virtual void GetComboBitmaps(wxBitmap
*bmpNormal
,
194 wxBitmap
*bmpPressed
,
195 wxBitmap
*bmpDisabled
);
197 virtual void AdjustSize(wxSize
*size
, const wxWindow
*window
);
199 // geometry and hit testing
200 virtual wxSize
GetScrollbarArrowSize() const
201 { return m_sizeScrollbarArrow
; }
203 virtual wxRect
GetScrollbarRect(const wxScrollBar
*scrollbar
,
204 wxScrollBar::Element elem
,
205 int thumbPos
= -1) const;
206 #endif // wxUSE_SCROLLBAR
208 virtual wxSize
GetCheckBitmapSize() const
209 { return wxSize(10, 10); }
210 virtual wxSize
GetRadioBitmapSize() const
211 { return wxSize(11, 11); }
212 virtual wxCoord
GetCheckItemMargin() const
216 virtual wxSize
GetToolBarButtonSize(wxCoord
*separator
) const
217 { if ( separator
) *separator
= 5; return wxSize(16, 15); }
218 virtual wxSize
GetToolBarMargin() const
219 { return wxSize(6, 6); }
220 #endif // wxUSE_TOOLBAR
223 virtual wxRect
GetTextClientArea(const wxTextCtrl
*text
,
225 wxCoord
*extraSpaceBeyond
) const;
226 #endif // wxUSE_TEXTCTRL
229 virtual wxSize
GetTabIndent() const { return wxSize(2, 2); }
230 virtual wxSize
GetTabPadding() const { return wxSize(6, 6); }
231 #endif // wxUSE_NOTEBOOK
234 virtual wxCoord
GetSliderDim() const { return 15; }
235 virtual wxCoord
GetSliderTickLen() const { return 0; }
236 virtual wxRect
GetSliderShaftRect(const wxRect
& rect
,
238 wxOrientation orient
,
239 long style
= 0) const;
240 virtual wxSize
GetSliderThumbSize(const wxRect
& rect
,
242 wxOrientation orient
) const;
243 #endif // wxUSE_SLIDER
245 virtual wxSize
GetProgressBarStep() const { return wxSize(16, 32); }
248 virtual wxSize
GetMenuBarItemSize(const wxSize
& sizeText
) const;
249 virtual wxMenuGeometryInfo
*GetMenuGeometry(wxWindow
*win
,
250 const wxMenu
& menu
) const;
251 #endif // wxUSE_MENUS
253 // helpers for "wxBitmap wxColourScheme::Get()"
254 void DrawCheckBitmap(wxDC
& dc
, const wxRect
& rect
);
255 void DrawUncheckBitmap(wxDC
& dc
, const wxRect
& rect
, bool isPressed
);
256 void DrawUndeterminedBitmap(wxDC
& dc
, const wxRect
& rect
, bool isPressed
);
259 // overridden wxStdRenderer methods
260 virtual void DrawSunkenBorder(wxDC
& dc
, wxRect
*rect
);
262 virtual void DrawFrameWithLabel(wxDC
& dc
,
263 const wxString
& label
,
264 const wxRect
& rectFrame
,
265 const wxRect
& rectText
,
270 virtual void DrawCheckItemBitmap(wxDC
& dc
,
271 const wxBitmap
& bitmap
,
275 // get the colour to use for background
276 wxColour
GetBackgroundColour(int flags
) const
278 if ( flags
& wxCONTROL_PRESSED
)
279 return wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
);
280 else if ( flags
& wxCONTROL_CURRENT
)
281 return wxSCHEME_COLOUR(m_scheme
, CONTROL_CURRENT
);
283 return wxSCHEME_COLOUR(m_scheme
, CONTROL
);
286 // as DrawShadedRect() but the pixels in the bottom left and upper right
287 // border are drawn with the pen1, not pen2
288 void DrawAntiShadedRect(wxDC
& dc
, wxRect
*rect
,
289 const wxPen
& pen1
, const wxPen
& pen2
);
291 // used for drawing opened rectangles - draws only one side of it at once
292 // (and doesn't adjust the rect)
293 void DrawAntiShadedRectSide(wxDC
& dc
,
299 // draw an opened rect for the arrow in given direction
300 void DrawArrowBorder(wxDC
& dc
,
304 // draw two sides of the rectangle
305 void DrawThumbBorder(wxDC
& dc
,
307 wxOrientation orient
);
309 // just as DrawRaisedBorder() except that the bottom left and up right
310 // pixels of the interior rect are drawn in another colour (i.e. the inner
311 // rect is drawn with DrawAntiShadedRect() and not DrawShadedRect())
312 void DrawAntiRaisedBorder(wxDC
& dc
, wxRect
*rect
);
314 // draw inner GTK shadow
315 void DrawInnerShadedRect(wxDC
& dc
, wxRect
*rect
);
318 // returns the size of the arrow for the scrollbar (depends on
320 wxSize
GetScrollbarArrowSize(const wxScrollBar
*scrollbar
) const
323 if ( scrollbar
->IsVertical() )
325 size
= m_sizeScrollbarArrow
;
329 size
.x
= m_sizeScrollbarArrow
.y
;
330 size
.y
= m_sizeScrollbarArrow
.x
;
335 #endif // wxUSE_SCROLLBAR
337 // get the line wrap indicator bitmap
338 wxBitmap
GetLineWrapBitmap() const;
340 virtual wxBitmap
GetCheckBitmap(int flags
);
341 virtual wxBitmap
GetRadioBitmap(int flags
);
343 // draw a /\ or \/ line from (x1, y1) to (x2, y1) passing by the point
345 void DrawUpZag(wxDC
& dc
,
346 wxCoord x1
, wxCoord x2
,
347 wxCoord y1
, wxCoord y2
);
348 void DrawDownZag(wxDC
& dc
,
349 wxCoord x1
, wxCoord x2
,
350 wxCoord y1
, wxCoord y2
);
352 // draw the radio button bitmap for the given state
353 void DrawRadioBitmap(wxDC
& dc
, const wxRect
& rect
, int flags
);
355 // common part of DrawMenuItem() and DrawMenuBarItem()
356 void DoDrawMenuItem(wxDC
& dc
,
358 const wxString
& label
,
361 const wxString
& accel
= wxEmptyString
,
362 const wxBitmap
& bitmap
= wxNullBitmap
,
363 const wxGTKMenuGeometryInfo
*geometryInfo
= NULL
);
365 // initialize the combo bitmaps
366 void InitComboBitmaps();
368 virtual wxBitmap
GetFrameButtonBitmap(FrameButtonType
WXUNUSED(type
))
375 wxSize m_sizeScrollbarArrow
;
380 // the checkbox and radio button bitmaps: first row is for the normal,
381 // second for the pressed state and the columns are for checked, unchecked
382 // and undeterminated respectively
383 wxBitmap m_bitmapsCheckbox
[IndicatorState_MaxCtrl
][IndicatorStatus_Max
],
384 m_bitmapsRadiobtn
[IndicatorState_MaxCtrl
][IndicatorStatus_Max
];
386 // the line wrap bitmap (drawn at the end of wrapped lines)
387 wxBitmap m_bmpLineWrap
;
389 // the combobox bitmaps
399 wxBitmap m_bitmapsCombo
[ComboState_Max
];
402 // ----------------------------------------------------------------------------
403 // wxGTKInputHandler and derived classes: process the keyboard and mouse
404 // messages according to GTK standards
405 // ----------------------------------------------------------------------------
407 class wxGTKInputHandler
: public wxInputHandler
410 wxGTKInputHandler() { }
412 virtual bool HandleKey(wxInputConsumer
*control
,
413 const wxKeyEvent
& event
,
415 virtual bool HandleMouse(wxInputConsumer
*control
,
416 const wxMouseEvent
& event
);
417 virtual bool HandleMouseMove(wxInputConsumer
*control
,
418 const wxMouseEvent
& event
);
423 class wxGTKScrollBarInputHandler
: public wxStdScrollBarInputHandler
426 wxGTKScrollBarInputHandler(wxRenderer
*renderer
, wxInputHandler
*handler
)
427 : wxStdScrollBarInputHandler(renderer
, handler
) { }
430 virtual void Highlight(wxScrollBar
*scrollbar
, bool doIt
)
432 // only arrows and the thumb can be highlighted
433 if ( !IsArrow() && m_htLast
!= wxHT_SCROLLBAR_THUMB
)
436 wxStdScrollBarInputHandler::Highlight(scrollbar
, doIt
);
439 virtual void Press(wxScrollBar
*scrollbar
, bool doIt
)
441 // only arrows can be pressed
445 wxStdScrollBarInputHandler::Press(scrollbar
, doIt
);
448 // any button can be used to drag the scrollbar under GTK+
449 virtual bool IsAllowedButton(int WXUNUSED(button
)) const { return true; }
453 return m_htLast
== wxHT_SCROLLBAR_ARROW_LINE_1
||
454 m_htLast
== wxHT_SCROLLBAR_ARROW_LINE_2
;
458 #endif // wxUSE_SCROLLBAR
462 class wxGTKCheckboxInputHandler
: public wxStdInputHandler
465 wxGTKCheckboxInputHandler(wxInputHandler
*handler
)
466 : wxStdInputHandler(handler
) { }
468 virtual bool HandleKey(wxInputConsumer
*control
,
469 const wxKeyEvent
& event
,
473 #endif // wxUSE_CHECKBOX
477 class wxGTKTextCtrlInputHandler
: public wxStdInputHandler
480 wxGTKTextCtrlInputHandler(wxInputHandler
*handler
)
481 : wxStdInputHandler(handler
) { }
483 virtual bool HandleKey(wxInputConsumer
*control
,
484 const wxKeyEvent
& event
,
488 #endif // wxUSE_TEXTCTRL
490 // ----------------------------------------------------------------------------
491 // wxGTKColourScheme: uses the standard GTK colours
492 // ----------------------------------------------------------------------------
494 class wxGTKColourScheme
: public wxColourScheme
497 virtual wxColour
Get(StdColour col
) const;
498 virtual wxColour
GetBackground(wxWindow
*win
) const;
501 // ----------------------------------------------------------------------------
503 // ----------------------------------------------------------------------------
505 class wxGTKArtProvider
: public wxArtProvider
508 virtual wxBitmap
CreateBitmap(const wxArtID
& id
,
509 const wxArtClient
& client
,
513 // ----------------------------------------------------------------------------
515 // ----------------------------------------------------------------------------
517 WX_DEFINE_ARRAY_PTR(wxInputHandler
*, wxArrayHandlers
);
519 class wxGTKTheme
: public wxTheme
523 virtual ~wxGTKTheme();
525 virtual wxRenderer
*GetRenderer();
526 virtual wxArtProvider
*GetArtProvider();
527 virtual wxInputHandler
*GetInputHandler(const wxString
& control
,
528 wxInputConsumer
*consumer
);
529 virtual wxColourScheme
*GetColourScheme();
532 wxGTKRenderer
*m_renderer
;
534 wxGTKArtProvider
*m_artProvider
;
536 // the names of the already created handlers and the handlers themselves
537 // (these arrays are synchronized)
538 wxSortedArrayString m_handlerNames
;
539 wxArrayHandlers m_handlers
;
541 wxGTKColourScheme
*m_scheme
;
543 WX_DECLARE_THEME(gtk
)
546 // ============================================================================
548 // ============================================================================
550 WX_IMPLEMENT_THEME(wxGTKTheme
, gtk
, wxTRANSLATE("GTK+ theme"));
552 // ----------------------------------------------------------------------------
554 // ----------------------------------------------------------------------------
556 wxGTKTheme::wxGTKTheme()
560 m_artProvider
= NULL
;
563 wxGTKTheme::~wxGTKTheme()
567 delete m_artProvider
;
570 wxRenderer
*wxGTKTheme::GetRenderer()
574 m_renderer
= new wxGTKRenderer(GetColourScheme());
580 wxArtProvider
*wxGTKTheme::GetArtProvider()
582 if ( !m_artProvider
)
584 m_artProvider
= new wxGTKArtProvider
;
587 return m_artProvider
;
590 wxColourScheme
*wxGTKTheme::GetColourScheme()
594 m_scheme
= new wxGTKColourScheme
;
599 wxInputHandler
*wxGTKTheme::GetInputHandler(const wxString
& control
,
600 wxInputConsumer
*consumer
)
602 wxInputHandler
*handler
= NULL
;
603 int n
= m_handlerNames
.Index(control
);
604 if ( n
== wxNOT_FOUND
)
606 static wxGTKInputHandler s_handlerDef
;
608 wxInputHandler
* const
609 handlerStd
= consumer
->DoGetStdInputHandler(&s_handlerDef
);
611 // create a new handler
613 if ( control
== wxINP_HANDLER_CHECKBOX
)
615 static wxGTKCheckboxInputHandler
s_handler(handlerStd
);
617 handler
= &s_handler
;
620 #endif // wxUSE_CHECKBOX
622 if ( control
== wxINP_HANDLER_SCROLLBAR
)
624 static wxGTKScrollBarInputHandler
s_handler(m_renderer
, handlerStd
);
626 handler
= &s_handler
;
629 #endif // wxUSE_SCROLLBAR
631 if ( control
== wxINP_HANDLER_TEXTCTRL
)
633 static wxGTKTextCtrlInputHandler
s_handler(handlerStd
);
635 handler
= &s_handler
;
638 #endif // wxUSE_TEXTCTRL
640 // no special handler for this control
641 handler
= handlerStd
;
644 n
= m_handlerNames
.Add(control
);
645 m_handlers
.Insert(handler
, n
);
647 else // we already have it
649 handler
= m_handlers
[n
];
655 // ============================================================================
657 // ============================================================================
659 wxColour
wxGTKColourScheme::GetBackground(wxWindow
*win
) const
662 if ( win
->UseBgCol() )
664 // use the user specified colour
665 col
= win
->GetBackgroundColour();
668 if ( !win
->ShouldInheritColours() )
670 // doesn't depend on the state
678 int flags
= win
->GetStateFlags();
680 // the colour set by the user should be used for the normal state
681 // and for the states for which we don't have any specific colours
682 if ( !col
.Ok() || (flags
!= 0) )
685 if ( wxDynamicCast(win
, wxScrollBar
) )
686 col
= Get(SCROLLBAR
);
688 #endif //wxUSE_SCROLLBAR
689 if ( (flags
& wxCONTROL_CURRENT
) && win
->CanBeHighlighted() )
690 col
= Get(CONTROL_CURRENT
);
691 else if ( flags
& wxCONTROL_PRESSED
)
692 col
= Get(CONTROL_PRESSED
);
701 wxColour
wxGTKColourScheme::Get(wxGTKColourScheme::StdColour col
) const
705 case WINDOW
: return *wxWHITE
;
707 case SHADOW_DARK
: return *wxBLACK
;
708 case SHADOW_HIGHLIGHT
: return *wxWHITE
;
709 case SHADOW_IN
: return wxColour(0xd6d6d6);
710 case SHADOW_OUT
: return wxColour(0x969696);
712 case CONTROL
: return wxColour(0xd6d6d6);
713 case CONTROL_PRESSED
: return wxColour(0xc3c3c3);
714 case CONTROL_CURRENT
: return wxColour(0xeaeaea);
716 case CONTROL_TEXT
: return *wxBLACK
;
717 case CONTROL_TEXT_DISABLED
:
718 return wxColour(0x757575);
719 case CONTROL_TEXT_DISABLED_SHADOW
:
723 case SCROLLBAR_PRESSED
: return wxColour(0xc3c3c3);
725 case HIGHLIGHT
: return wxColour(0x9c0000);
726 case HIGHLIGHT_TEXT
: return wxColour(0xffffff);
728 case GAUGE
: return Get(CONTROL_CURRENT
);
730 case TITLEBAR
: return wxColour(0xaeaaae);
731 case TITLEBAR_ACTIVE
: return wxColour(0x820300);
732 case TITLEBAR_TEXT
: return wxColour(0xc0c0c0);
733 case TITLEBAR_ACTIVE_TEXT
:
736 case DESKTOP
: return *wxBLACK
;
740 wxFAIL_MSG(_T("invalid standard colour"));
745 // ============================================================================
747 // ============================================================================
749 // ----------------------------------------------------------------------------
751 // ----------------------------------------------------------------------------
753 wxGTKRenderer::wxGTKRenderer(const wxColourScheme
*scheme
)
754 : wxStdRenderer(scheme
)
756 m_sizeScrollbarArrow
= wxSize(15, 14);
758 m_penGrey
= wxPen(wxSCHEME_COLOUR(scheme
, SCROLLBAR
));
761 // ----------------------------------------------------------------------------
763 // ----------------------------------------------------------------------------
765 void wxGTKRenderer::DrawAntiShadedRectSide(wxDC
& dc
,
771 dc
.SetPen(dir
== wxLEFT
|| dir
== wxUP
? pen1
: pen2
);
776 dc
.DrawLine(rect
.GetLeft(), rect
.GetTop(),
777 rect
.GetLeft(), rect
.GetBottom() + 1);
781 dc
.DrawLine(rect
.GetLeft(), rect
.GetTop(),
782 rect
.GetRight() + 1, rect
.GetTop());
786 dc
.DrawLine(rect
.GetRight(), rect
.GetTop(),
787 rect
.GetRight(), rect
.GetBottom() + 1);
791 dc
.DrawLine(rect
.GetLeft(), rect
.GetBottom(),
792 rect
.GetRight() + 1, rect
.GetBottom());
796 wxFAIL_MSG(_T("unknown rectangle side"));
800 void wxGTKRenderer::DrawAntiShadedRect(wxDC
& dc
, wxRect
*rect
,
801 const wxPen
& pen1
, const wxPen
& pen2
)
803 // draw the rectangle
805 dc
.DrawLine(rect
->GetLeft(), rect
->GetTop(),
806 rect
->GetLeft(), rect
->GetBottom() + 1);
807 dc
.DrawLine(rect
->GetLeft() + 1, rect
->GetTop(),
808 rect
->GetRight() + 1, rect
->GetTop());
810 dc
.DrawLine(rect
->GetRight(), rect
->GetTop() + 1,
811 rect
->GetRight(), rect
->GetBottom());
812 dc
.DrawLine(rect
->GetLeft() + 1, rect
->GetBottom(),
813 rect
->GetRight() + 1, rect
->GetBottom());
819 void wxGTKRenderer::DrawInnerShadedRect(wxDC
& dc
, wxRect
*rect
)
821 DrawAntiShadedRect(dc
, rect
, m_penDarkGrey
, m_penHighlight
);
822 DrawAntiShadedRect(dc
, rect
, m_penBlack
, m_penHighlight
);
825 void wxGTKRenderer::DrawAntiRaisedBorder(wxDC
& dc
, wxRect
*rect
)
827 DrawShadedRect(dc
, rect
, m_penHighlight
, m_penBlack
);
828 DrawAntiShadedRect(dc
, rect
, m_penLightGrey
, m_penDarkGrey
);
831 void wxGTKRenderer::DrawSunkenBorder(wxDC
& dc
, wxRect
*rect
)
833 DrawAntiShadedRect(dc
, rect
, m_penDarkGrey
, m_penHighlight
);
834 DrawShadedRect(dc
, rect
, m_penBlack
, m_penLightGrey
);
838 wxGTKRenderer::DrawFocusRect(wxDC
& dc
, const wxRect
& rect
, int WXUNUSED(flags
))
840 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
841 wxRect rectFocus
= rect
;
842 DrawRect(dc
, &rectFocus
, m_penBlack
);
845 void wxGTKRenderer::DrawTextBorder(wxDC
& dc
,
847 const wxRect
& rectOrig
,
851 wxRect rect
= rectOrig
;
853 if ( border
!= wxBORDER_NONE
)
855 if ( flags
& wxCONTROL_FOCUSED
)
857 DrawRect(dc
, &rect
, m_penBlack
);
858 DrawAntiShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
862 DrawInnerShadedRect(dc
, &rect
);
870 void wxGTKRenderer::DrawButtonLabel(wxDC
& dc
,
871 const wxString
& label
,
872 const wxBitmap
& image
,
879 // no focus rect around buttons label in GTK+
880 wxStdRenderer::DrawButtonLabel(dc
, label
, image
, rect
, flags
,
881 alignment
, indexAccel
, rectBounds
);
884 void wxGTKRenderer::DrawButtonBorder(wxDC
& dc
,
885 const wxRect
& rectTotal
,
889 wxRect rect
= rectTotal
;
891 if ( flags
& wxCONTROL_PRESSED
)
893 // button pressed: draw a black border around it and an inward shade
894 DrawRect(dc
, &rect
, m_penBlack
);
896 DrawInnerShadedRect(dc
, &rect
);
898 else // button not pressed
900 if ( flags
& wxCONTROL_ISDEFAULT
)
905 if ( flags
& wxCONTROL_FOCUSED
)
907 // button is currently default: add an extra border around it
908 DrawRect(dc
, &rect
, m_penBlack
);
911 // now draw a normal button
912 DrawShadedRect(dc
, &rect
, m_penHighlight
, m_penBlack
);
913 DrawAntiShadedRect(dc
, &rect
, GetBackgroundColour(flags
), m_penDarkGrey
);
920 // ----------------------------------------------------------------------------
922 // ----------------------------------------------------------------------------
924 void wxGTKRenderer::DrawFrameWithLabel(wxDC
& dc
,
925 const wxString
& label
,
926 const wxRect
& rectFrame
,
927 const wxRect
& rectTextOrig
,
932 wxRect
rectText(rectTextOrig
);
933 rectText
.Inflate(1, 0);
936 DrawLabel(dc
, label
, rectText
, flags
, alignment
, indexAccel
, &rectLabel
);
938 rectLabel
.width
+= 2;
940 DrawFrameWithoutLabel(dc
, rectFrame
, rectLabel
);
942 // GTK+ does it like this
943 dc
.SetPen(m_penHighlight
);
944 dc
.DrawPoint(rectText
.x
, rectFrame
.y
);
945 dc
.DrawPoint(rectText
.x
+ rectLabel
.width
- 3, rectFrame
.y
);
948 // ----------------------------------------------------------------------------
949 // check/radion buttons
950 // ----------------------------------------------------------------------------
952 void wxGTKRenderer::DrawCheckItemBitmap(wxDC
& dc
,
953 const wxBitmap
& bitmap
,
957 // never draw the focus rect around the check indicators here
958 DrawCheckButton(dc
, wxEmptyString
, bitmap
, rect
, flags
& ~wxCONTROL_FOCUSED
);
961 void wxGTKRenderer::DrawUndeterminedBitmap(wxDC
& dc
,
962 const wxRect
& rectTotal
,
965 // FIXME: For sure it is not GTK look but it is better than nothing.
966 // Show me correct look and I will immediatelly make it better (ABX)
967 wxRect rect
= rectTotal
;
973 col1
= wxSCHEME_COLOUR(m_scheme
, SHADOW_DARK
);
974 col2
= wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
);
978 col1
= wxSCHEME_COLOUR(m_scheme
, SHADOW_DARK
);
979 col2
= wxSCHEME_COLOUR(m_scheme
, SHADOW_IN
);
982 dc
.SetPen(*wxTRANSPARENT_PEN
);
984 dc
.DrawRectangle(rect
);
987 dc
.DrawRectangle(rect
);
990 void wxGTKRenderer::DrawUncheckBitmap(wxDC
& dc
,
991 const wxRect
& rectTotal
,
994 wxRect rect
= rectTotal
;
995 DrawAntiRaisedBorder(dc
, &rect
);
997 wxColour col
= wxSCHEME_COLOUR(m_scheme
, SHADOW_IN
);
998 dc
.SetPen(wxPen(col
));
999 dc
.DrawPoint(rect
.GetRight() - 1, rect
.GetBottom() - 1);
1002 col
= wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
);
1003 //else: it is SHADOW_IN, leave as is
1005 dc
.SetPen(*wxTRANSPARENT_PEN
);
1007 dc
.DrawRectangle(rect
);
1010 void wxGTKRenderer::DrawCheckBitmap(wxDC
& dc
, const wxRect
& rectTotal
)
1012 wxRect rect
= rectTotal
;
1013 DrawAntiShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
1014 DrawShadedRect(dc
, &rect
, m_penBlack
, m_penLightGrey
);
1016 dc
.SetPen(*wxTRANSPARENT_PEN
);
1017 dc
.SetBrush(wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
));
1018 dc
.DrawRectangle(rect
);
1021 void wxGTKRenderer::DrawRadioBitmap(wxDC
& dc
,
1027 xRight
= rect
.GetRight(),
1028 yBottom
= rect
.GetBottom();
1030 wxCoord yMid
= (y
+ yBottom
) / 2;
1032 // then draw the upper half
1033 dc
.SetPen(flags
& wxCONTROL_CHECKED
? m_penDarkGrey
: m_penHighlight
);
1034 DrawUpZag(dc
, x
, xRight
, yMid
, y
);
1035 DrawUpZag(dc
, x
+ 1, xRight
- 1, yMid
, y
+ 1);
1038 if ( flags
& wxCONTROL_CHECKED
)
1039 dc
.SetPen(m_penBlack
);
1040 else if ( flags
& wxCONTROL_PRESSED
)
1041 dc
.SetPen(wxPen(wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
)));
1042 else // unchecked and unpressed
1046 DrawUpZag(dc
, x
+ 2, xRight
- 2, yMid
, y
+ 2);
1048 // and then the lower one
1049 dc
.SetPen(flags
& wxCONTROL_CHECKED
? m_penHighlight
: m_penBlack
);
1050 DrawDownZag(dc
, x
, xRight
, yMid
, yBottom
);
1051 if ( !(flags
& wxCONTROL_CHECKED
) )
1052 dc
.SetPen(m_penDarkGrey
);
1053 DrawDownZag(dc
, x
+ 1, xRight
- 1, yMid
, yBottom
- 1);
1055 if ( !(flags
& wxCONTROL_CHECKED
) )
1056 drawIt
= true; // with the same pen
1057 else if ( flags
& wxCONTROL_PRESSED
)
1059 dc
.SetPen(wxPen(wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
)));
1062 else // checked and unpressed
1066 DrawDownZag(dc
, x
+ 2, xRight
- 2, yMid
, yBottom
- 2);
1069 void wxGTKRenderer::DrawUpZag(wxDC
& dc
,
1075 wxCoord xMid
= (x1
+ x2
) / 2;
1076 dc
.DrawLine(x1
, y1
, xMid
, y2
);
1077 dc
.DrawLine(xMid
, y2
, x2
+ 1, y1
+ 1);
1080 void wxGTKRenderer::DrawDownZag(wxDC
& dc
,
1086 wxCoord xMid
= (x1
+ x2
) / 2;
1087 dc
.DrawLine(x1
+ 1, y1
+ 1, xMid
, y2
);
1088 dc
.DrawLine(xMid
, y2
, x2
, y1
);
1091 wxBitmap
wxGTKRenderer::GetCheckBitmap(int flags
)
1093 if ( !m_bitmapsCheckbox
[0][0].Ok() )
1095 // init the bitmaps once only
1097 wxSize size
= GetCheckBitmapSize();
1098 rect
.width
= size
.x
;
1099 rect
.height
= size
.y
;
1100 for ( int i
= 0; i
< 2; i
++ )
1102 for ( int j
= 0; j
< 3; j
++ )
1103 m_bitmapsCheckbox
[i
][j
].Create(rect
.width
, rect
.height
);
1109 dc
.SelectObject(m_bitmapsCheckbox
[0][0]);
1110 DrawCheckBitmap(dc
, rect
);
1113 dc
.SelectObject(m_bitmapsCheckbox
[0][1]);
1114 DrawUncheckBitmap(dc
, rect
, false);
1116 // normal undeterminated
1117 dc
.SelectObject(m_bitmapsCheckbox
[0][2]);
1118 DrawUndeterminedBitmap(dc
, rect
, false);
1121 m_bitmapsCheckbox
[1][0] = m_bitmapsCheckbox
[0][0];
1123 // pressed unchecked
1124 dc
.SelectObject(m_bitmapsCheckbox
[1][1]);
1125 DrawUncheckBitmap(dc
, rect
, true);
1127 // pressed undeterminated
1128 dc
.SelectObject(m_bitmapsCheckbox
[1][2]);
1129 DrawUndeterminedBitmap(dc
, rect
, true);
1132 IndicatorState state
;
1133 IndicatorStatus status
;
1134 GetIndicatorsFromFlags(flags
, state
, status
);
1136 // disabled looks the same as normal
1137 if ( state
== IndicatorState_Disabled
)
1138 state
= IndicatorState_Normal
;
1140 return m_bitmapsCheckbox
[state
][status
];
1143 wxBitmap
wxGTKRenderer::GetRadioBitmap(int flags
)
1145 IndicatorState state
;
1146 IndicatorStatus status
;
1147 GetIndicatorsFromFlags(flags
, state
, status
);
1149 wxBitmap
& bmp
= m_bitmapsRadiobtn
[state
][status
];
1152 const wxSize size
= GetRadioBitmapSize();
1155 bmp
.Create(size
.x
, size
.y
);
1156 dc
.SelectObject(bmp
);
1158 DrawRadioBitmap(dc
, size
, flags
);
1164 wxBitmap
wxGTKRenderer::GetLineWrapBitmap() const
1166 if ( !m_bmpLineWrap
.Ok() )
1168 // the line wrap bitmap as used by GTK+
1169 #define line_wrap_width 6
1170 #define line_wrap_height 9
1171 static const char line_wrap_bits
[] =
1173 0x1e, 0x3e, 0x30, 0x30, 0x39, 0x1f, 0x0f, 0x0f, 0x1f,
1176 wxBitmap
bmpLineWrap(line_wrap_bits
, line_wrap_width
, line_wrap_height
);
1177 if ( !bmpLineWrap
.Ok() )
1179 wxFAIL_MSG( _T("Failed to create line wrap XBM") );
1183 wxConstCast(this, wxGTKRenderer
)->m_bmpLineWrap
= bmpLineWrap
;
1187 return m_bmpLineWrap
;
1191 void wxGTKRenderer::DrawToolBarButton(wxDC
& dc
,
1192 const wxString
& label
,
1193 const wxBitmap
& bitmap
,
1194 const wxRect
& rectOrig
,
1196 long WXUNUSED(style
),
1199 // we don't draw the separators at all
1200 if ( !label
.empty() || bitmap
.Ok() )
1202 wxRect rect
= rectOrig
;
1203 rect
.Deflate(BORDER_THICKNESS
);
1205 if ( flags
& wxCONTROL_PRESSED
)
1207 DrawBorder(dc
, wxBORDER_SUNKEN
, rect
, flags
, &rect
);
1209 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
), rect
);
1211 else if ( flags
& wxCONTROL_CURRENT
)
1213 DrawBorder(dc
, wxBORDER_RAISED
, rect
, flags
, &rect
);
1215 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL_CURRENT
), rect
);
1218 if(tbarStyle
& wxTB_TEXT
)
1220 if(tbarStyle
& wxTB_HORIZONTAL
)
1222 dc
.DrawLabel(label
, bitmap
, rect
, wxALIGN_CENTRE
);
1226 dc
.DrawLabel(label
, bitmap
, rect
, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
);
1231 int xpoint
= (rect
.GetLeft() + rect
.GetRight() + 1 - bitmap
.GetWidth()) / 2;
1232 int ypoint
= (rect
.GetTop() + rect
.GetBottom() + 1 - bitmap
.GetHeight()) / 2;
1233 dc
.DrawBitmap(bitmap
, xpoint
, ypoint
);
1237 #endif // wxUSE_TOOLBAR
1239 // ----------------------------------------------------------------------------
1241 // ----------------------------------------------------------------------------
1245 wxRect
wxGTKRenderer::GetTextClientArea(const wxTextCtrl
*text
,
1247 wxCoord
*extraSpaceBeyond
) const
1250 rectText
= wxStdRenderer::GetTextClientArea(text
, rect
, extraSpaceBeyond
);
1252 if ( text
->WrapLines() )
1254 // leave enough for the line wrap bitmap indicator
1255 wxCoord widthMark
= GetLineWrapBitmap().GetWidth() + 2;
1257 rectText
.width
-= widthMark
;
1259 if ( extraSpaceBeyond
)
1260 *extraSpaceBeyond
= widthMark
;
1266 void wxGTKRenderer::DrawLineWrapMark(wxDC
& dc
, const wxRect
& rect
)
1268 wxBitmap bmpLineWrap
= GetLineWrapBitmap();
1270 // for a mono bitmap he colours it appears in depends on the current text
1271 // colours, so set them correctly
1273 if ( bmpLineWrap
.GetDepth() == 1 )
1275 colFgOld
= dc
.GetTextForeground();
1277 // FIXME: I wonder what should we do if the background is black too?
1278 dc
.SetTextForeground(*wxBLACK
);
1281 dc
.DrawBitmap(bmpLineWrap
,
1282 rect
.x
, rect
.y
+ (rect
.height
- bmpLineWrap
.GetHeight())/2);
1284 if ( colFgOld
.Ok() )
1286 // restore old colour
1287 dc
.SetTextForeground(colFgOld
);
1291 #endif // wxUSE_TEXTCTRL
1293 // ----------------------------------------------------------------------------
1295 // ----------------------------------------------------------------------------
1299 void wxGTKRenderer::DrawTab(wxDC
& dc
,
1300 const wxRect
& rectOrig
,
1302 const wxString
& label
,
1303 const wxBitmap
& bitmap
,
1307 #define SELECT_FOR_VERTICAL(X,Y) ( isVertical ? Y : X )
1308 #define REVERSE_FOR_VERTICAL(X,Y) \
1309 SELECT_FOR_VERTICAL(X,Y) \
1311 SELECT_FOR_VERTICAL(Y,X)
1313 wxRect rect
= rectOrig
;
1315 bool isVertical
= ( dir
== wxLEFT
) || ( dir
== wxRIGHT
);
1317 // the current tab is drawn indented (to the top for default case) and
1318 // bigger than the other ones
1319 const wxSize indent
= GetTabIndent();
1320 if ( flags
& wxCONTROL_SELECTED
)
1322 rect
.Inflate( SELECT_FOR_VERTICAL( indent
.x
, 0),
1323 SELECT_FOR_VERTICAL( 0, indent
.y
));
1327 wxFAIL_MSG(_T("invaild notebook tab orientation"));
1334 rect
.height
+= indent
.y
;
1341 rect
.width
+= indent
.x
;
1346 // selected tab has different colour
1347 wxColour col
= flags
& wxCONTROL_SELECTED
1348 ? wxSCHEME_COLOUR(m_scheme
, SHADOW_IN
)
1349 : wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
);
1350 DrawSolidRect(dc
, col
, rect
);
1352 if ( flags
& wxCONTROL_FOCUSED
)
1354 // draw the focus rect
1355 wxRect rectBorder
= rect
;
1356 rectBorder
.Deflate(4, 3);
1357 if ( dir
== wxBOTTOM
)
1358 rectBorder
.Offset(0, -1);
1359 if ( dir
== wxRIGHT
)
1360 rectBorder
.Offset(-1, 0);
1362 DrawRect(dc
, &rectBorder
, m_penBlack
);
1365 // draw the text, image and the focus around them (if necessary)
1366 wxRect
rectLabel( REVERSE_FOR_VERTICAL(rect
.x
,rect
.y
),
1367 REVERSE_FOR_VERTICAL(rect
.width
,rect
.height
)
1369 rectLabel
.Deflate(1, 1);
1372 // draw it horizontally into memory and rotate for screen
1374 wxBitmap bitmapRotated
,
1375 bitmapMem( rectLabel
.x
+ rectLabel
.width
,
1376 rectLabel
.y
+ rectLabel
.height
);
1377 dcMem
.SelectObject(bitmapMem
);
1378 dcMem
.SetBackground(dc
.GetBackground());
1379 dcMem
.SetFont(dc
.GetFont());
1380 dcMem
.SetTextForeground(dc
.GetTextForeground());
1384 wxBitmap( wxImage( bitmap
.ConvertToImage() ).Rotate90(dir
==wxLEFT
) )
1387 #endif // wxUSE_IMAGE
1389 dcMem
.DrawLabel(label
, bitmapRotated
, rectLabel
, wxALIGN_CENTRE
, indexAccel
);
1390 dcMem
.SelectObject(wxNullBitmap
);
1391 bitmapMem
= bitmapMem
.GetSubBitmap(rectLabel
);
1393 bitmapMem
= wxBitmap(wxImage(bitmapMem
.ConvertToImage()).Rotate90(dir
==wxRIGHT
))
1397 dc
.DrawBitmap(bitmapMem
, rectLabel
.y
, rectLabel
.x
, false);
1401 dc
.DrawLabel(label
, bitmap
, rectLabel
, wxALIGN_CENTRE
, indexAccel
);
1404 // now draw the tab itself
1405 wxCoord x
= SELECT_FOR_VERTICAL(rect
.x
,rect
.y
),
1406 y
= SELECT_FOR_VERTICAL(rect
.y
,rect
.x
),
1407 x2
= SELECT_FOR_VERTICAL(rect
.GetRight(),rect
.GetBottom()),
1408 y2
= SELECT_FOR_VERTICAL(rect
.GetBottom(),rect
.GetRight());
1414 // left orientation looks like top but IsVertical makes x and y reversed
1416 // top is not vertical so use coordinates in written order
1417 dc
.SetPen(m_penHighlight
);
1418 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y2
),
1419 REVERSE_FOR_VERTICAL(x
, y
));
1420 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
),
1421 REVERSE_FOR_VERTICAL(x2
, y
));
1423 dc
.SetPen(m_penBlack
);
1424 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y2
),
1425 REVERSE_FOR_VERTICAL(x2
, y
));
1427 dc
.SetPen(m_penDarkGrey
);
1428 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
- 1, y2
),
1429 REVERSE_FOR_VERTICAL(x2
- 1, y
+ 1));
1431 if ( flags
& wxCONTROL_SELECTED
)
1433 dc
.SetPen(m_penLightGrey
);
1435 // overwrite the part of the border below this tab
1436 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
+ 1),
1437 REVERSE_FOR_VERTICAL(x2
- 1, y2
+ 1));
1439 // and the shadow of the tab to the left of us
1440 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
+ 2),
1441 REVERSE_FOR_VERTICAL(x
+ 1, y2
+ 1));
1446 // right orientation looks like bottom but IsVertical makes x and y reversed
1448 // bottom is not vertical so use coordinates in written order
1449 dc
.SetPen(m_penHighlight
);
1451 // we need to continue one pixel further to overwrite the corner of
1452 // the border for the selected tab
1453 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y
- (flags
& wxCONTROL_SELECTED
? 1 : 0)),
1454 REVERSE_FOR_VERTICAL(x
, y2
));
1456 // it doesn't work like this (TODO: implement it properly)
1458 // erase the corner of the tab to the right
1459 dc
.SetPen(m_penLightGrey
);
1460 dc
.DrawPoint(REVERSE_FOR_VERTICAL(x2
- 1, y
- 2));
1461 dc
.DrawPoint(REVERSE_FOR_VERTICAL(x2
- 2, y
- 2));
1462 dc
.DrawPoint(REVERSE_FOR_VERTICAL(x2
- 2, y
- 1));
1465 dc
.SetPen(m_penBlack
);
1466 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
),
1467 REVERSE_FOR_VERTICAL(x2
, y2
));
1468 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y
),
1469 REVERSE_FOR_VERTICAL(x2
, y2
));
1471 dc
.SetPen(m_penDarkGrey
);
1472 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 2, y2
- 1),
1473 REVERSE_FOR_VERTICAL(x2
- 1, y2
- 1));
1474 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
- 1, y
),
1475 REVERSE_FOR_VERTICAL(x2
- 1, y2
));
1477 if ( flags
& wxCONTROL_SELECTED
)
1479 dc
.SetPen(m_penLightGrey
);
1481 // overwrite the part of the (double!) border above this tab
1482 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
- 1),
1483 REVERSE_FOR_VERTICAL(x2
- 1, y
- 1));
1484 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
- 2),
1485 REVERSE_FOR_VERTICAL(x2
- 1, y
- 2));
1487 // and the shadow of the tab to the left of us
1488 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
- 1),
1489 REVERSE_FOR_VERTICAL(x
+ 1, y
- 1));
1495 #endif // wxUSE_NOTEBOOK
1497 // ----------------------------------------------------------------------------
1499 // ----------------------------------------------------------------------------
1503 wxSize
wxGTKRenderer::GetSliderThumbSize(const wxRect
& rect
,
1505 wxOrientation orient
) const
1507 static const wxCoord SLIDER_THUMB_LENGTH
= 30;
1511 wxRect rectShaft
= GetSliderShaftRect(rect
, lenThumb
, orient
);
1512 if ( orient
== wxHORIZONTAL
)
1514 size
.x
= wxMin(SLIDER_THUMB_LENGTH
, rectShaft
.width
);
1515 size
.y
= rectShaft
.height
;
1519 size
.y
= wxMin(SLIDER_THUMB_LENGTH
, rectShaft
.height
);
1520 size
.x
= rectShaft
.width
;
1526 wxRect
wxGTKRenderer::GetSliderShaftRect(const wxRect
& rect
,
1527 int WXUNUSED(lenThumb
),
1528 wxOrientation
WXUNUSED(orient
),
1529 long WXUNUSED(style
)) const
1531 return rect
.Deflate(2*BORDER_THICKNESS
, 2*BORDER_THICKNESS
);
1534 void wxGTKRenderer::DrawSliderShaft(wxDC
& dc
,
1535 const wxRect
& rectOrig
,
1536 int WXUNUSED(lenThumb
),
1537 wxOrientation
WXUNUSED(orient
),
1539 long WXUNUSED(style
),
1542 wxRect rect
= rectOrig
;
1544 // draw the border first
1545 if ( flags
& wxCONTROL_FOCUSED
)
1547 DrawRect(dc
, &rect
, m_penBlack
);
1549 else // not focused, normal
1551 DrawAntiShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
1554 DrawAntiShadedRect(dc
, &rect
, m_penBlack
, m_penLightGrey
);
1556 // and the background
1557 DrawSolidRect(dc
, wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
), rect
);
1563 void wxGTKRenderer::DrawSliderThumb(wxDC
& dc
,
1564 const wxRect
& rectOrig
,
1565 wxOrientation orient
,
1566 int WXUNUSED(flags
),
1567 long WXUNUSED(style
))
1569 // draw the thumb border
1570 wxRect rect
= rectOrig
;
1571 DrawAntiRaisedBorder(dc
, &rect
);
1573 // draw the handle in the middle
1574 if ( orient
== wxVERTICAL
)
1576 rect
.height
= 2*BORDER_THICKNESS
;
1577 rect
.y
= rectOrig
.y
+ (rectOrig
.height
- rect
.height
) / 2;
1581 rect
.width
= 2*BORDER_THICKNESS
;
1582 rect
.x
= rectOrig
.x
+ (rectOrig
.width
- rect
.width
) / 2;
1585 DrawShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
1588 #endif // wxUSE_SLIDER
1592 // ----------------------------------------------------------------------------
1594 // ----------------------------------------------------------------------------
1596 // wxGTKMenuGeometryInfo: the wxMenuGeometryInfo used by wxGTKRenderer
1597 class WXDLLEXPORT wxGTKMenuGeometryInfo
: public wxMenuGeometryInfo
1600 virtual wxSize
GetSize() const { return m_size
; }
1602 wxCoord
GetLabelOffset() const { return m_ofsLabel
; }
1603 wxCoord
GetAccelOffset() const { return m_ofsAccel
; }
1605 wxCoord
GetItemHeight() const { return m_heightItem
; }
1608 // the total size of the menu
1611 // the offset of the start of the menu item label
1614 // the offset of the start of the accel label
1617 // the height of a normal (not separator) item
1618 wxCoord m_heightItem
;
1620 friend wxMenuGeometryInfo
*
1621 wxGTKRenderer::GetMenuGeometry(wxWindow
*, const wxMenu
&) const;
1624 // FIXME: all constants are hardcoded but shouldn't be
1625 static const wxCoord MENU_LEFT_MARGIN
= 9;
1626 static const wxCoord MENU_RIGHT_MARGIN
= 6;
1628 static const wxCoord MENU_HORZ_MARGIN
= 6;
1629 static const wxCoord MENU_VERT_MARGIN
= 3;
1631 // the margin around bitmap/check marks (on each side)
1632 static const wxCoord MENU_BMP_MARGIN
= 2;
1634 // the margin between the labels and accel strings
1635 static const wxCoord MENU_ACCEL_MARGIN
= 8;
1637 // the separator height in pixels: in fact, strangely enough, the real height
1638 // is 2 but Windows adds one extra pixel in the bottom margin, so take it into
1640 static const wxCoord MENU_SEPARATOR_HEIGHT
= 3;
1642 // the size of the standard checkmark bitmap
1643 static const wxCoord MENU_CHECK_SIZE
= 9;
1645 void wxGTKRenderer::DrawMenuBarItem(wxDC
& dc
,
1647 const wxString
& label
,
1651 DoDrawMenuItem(dc
, rect
, label
, flags
, indexAccel
);
1654 void wxGTKRenderer::DrawMenuItem(wxDC
& dc
,
1656 const wxMenuGeometryInfo
& gi
,
1657 const wxString
& label
,
1658 const wxString
& accel
,
1659 const wxBitmap
& bitmap
,
1663 const wxGTKMenuGeometryInfo
& geomInfo
= (const wxGTKMenuGeometryInfo
&)gi
;
1668 rect
.width
= geomInfo
.GetSize().x
;
1669 rect
.height
= geomInfo
.GetItemHeight();
1671 DoDrawMenuItem(dc
, rect
, label
, flags
, indexAccel
, accel
, bitmap
, &geomInfo
);
1674 void wxGTKRenderer::DoDrawMenuItem(wxDC
& dc
,
1675 const wxRect
& rectOrig
,
1676 const wxString
& label
,
1679 const wxString
& accel
,
1680 const wxBitmap
& bitmap
,
1681 const wxGTKMenuGeometryInfo
*geometryInfo
)
1683 wxRect rect
= rectOrig
;
1685 // draw the selected item specially
1686 if ( flags
& wxCONTROL_SELECTED
)
1689 DrawBorder(dc
, wxBORDER_RAISED
, rect
, flags
, &rectIn
);
1691 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL_CURRENT
), rectIn
);
1694 rect
.Deflate(MENU_HORZ_MARGIN
, MENU_VERT_MARGIN
);
1696 // draw the bitmap: use the bitmap provided or the standard checkmark for
1697 // the checkable items
1700 wxBitmap bmp
= bitmap
;
1701 if ( !bmp
.Ok() && (flags
& wxCONTROL_CHECKABLE
) )
1703 bmp
= GetCheckBitmap(flags
);
1708 rect
.SetRight(geometryInfo
->GetLabelOffset());
1709 wxControlRenderer::DrawBitmap(dc
, bmp
, rect
);
1712 //else: menubar items don't have bitmaps
1717 rect
.x
= geometryInfo
->GetLabelOffset();
1718 rect
.SetRight(geometryInfo
->GetAccelOffset());
1721 DrawLabel(dc
, label
, rect
, flags
, wxALIGN_CENTRE_VERTICAL
, indexAccel
);
1723 // draw the accel string
1724 if ( !accel
.empty() )
1726 // menubar items shouldn't have them
1727 wxCHECK_RET( geometryInfo
, _T("accel strings only valid for menus") );
1729 rect
.x
= geometryInfo
->GetAccelOffset();
1730 rect
.SetRight(geometryInfo
->GetSize().x
);
1732 // NB: no accel index here
1733 DrawLabel(dc
, accel
, rect
, flags
, wxALIGN_CENTRE_VERTICAL
);
1736 // draw the submenu indicator
1737 if ( flags
& wxCONTROL_ISSUBMENU
)
1739 wxCHECK_RET( geometryInfo
, _T("wxCONTROL_ISSUBMENU only valid for menus") );
1741 rect
.x
= geometryInfo
->GetSize().x
- MENU_RIGHT_MARGIN
;
1742 rect
.width
= MENU_RIGHT_MARGIN
;
1744 DrawArrow(dc
, wxRIGHT
, rect
, flags
);
1748 void wxGTKRenderer::DrawMenuSeparator(wxDC
& dc
,
1750 const wxMenuGeometryInfo
& geomInfo
)
1752 DrawHorizontalLine(dc
, y
+ MENU_VERT_MARGIN
, 0, geomInfo
.GetSize().x
);
1755 wxSize
wxGTKRenderer::GetMenuBarItemSize(const wxSize
& sizeText
) const
1757 wxSize size
= sizeText
;
1759 // TODO: make this configurable
1760 size
.x
+= 2*MENU_HORZ_MARGIN
;
1761 size
.y
+= 2*MENU_VERT_MARGIN
;
1766 wxMenuGeometryInfo
*wxGTKRenderer::GetMenuGeometry(wxWindow
*win
,
1767 const wxMenu
& menu
) const
1769 // prepare the dc: for now we draw all the items with the system font
1771 dc
.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
1773 // the height of a normal item
1774 wxCoord heightText
= dc
.GetCharHeight();
1779 // the max length of label and accel strings: the menu width is the sum of
1780 // them, even if they're for different items (as the accels should be
1783 // the max length of the bitmap is never 0 as Windows always leaves enough
1784 // space for a check mark indicator
1785 wxCoord widthLabelMax
= 0,
1787 widthBmpMax
= MENU_LEFT_MARGIN
;
1789 for ( wxMenuItemList::compatibility_iterator node
= menu
.GetMenuItems().GetFirst();
1791 node
= node
->GetNext() )
1793 // height of this item
1796 wxMenuItem
*item
= node
->GetData();
1797 if ( item
->IsSeparator() )
1799 h
= MENU_SEPARATOR_HEIGHT
;
1801 else // not separator
1806 dc
.GetTextExtent(item
->GetLabel(), &widthLabel
, NULL
);
1807 if ( widthLabel
> widthLabelMax
)
1809 widthLabelMax
= widthLabel
;
1813 dc
.GetTextExtent(item
->GetAccelString(), &widthAccel
, NULL
);
1814 if ( widthAccel
> widthAccelMax
)
1816 widthAccelMax
= widthAccel
;
1819 const wxBitmap
& bmp
= item
->GetBitmap();
1822 wxCoord widthBmp
= bmp
.GetWidth();
1823 if ( widthBmp
> widthBmpMax
)
1824 widthBmpMax
= widthBmp
;
1826 //else if ( item->IsCheckable() ): no need to check for this as
1827 // MENU_LEFT_MARGIN is big enough to show the check mark
1830 h
+= 2*MENU_VERT_MARGIN
;
1832 // remember the item position and height
1833 item
->SetGeometry(height
, h
);
1838 // bundle the metrics into a struct and return it
1839 wxGTKMenuGeometryInfo
*gi
= new wxGTKMenuGeometryInfo
;
1841 gi
->m_ofsLabel
= widthBmpMax
+ 2*MENU_BMP_MARGIN
;
1842 gi
->m_ofsAccel
= gi
->m_ofsLabel
+ widthLabelMax
;
1843 if ( widthAccelMax
> 0 )
1845 // if we actually have any accesl, add a margin
1846 gi
->m_ofsAccel
+= MENU_ACCEL_MARGIN
;
1849 gi
->m_heightItem
= heightText
+ 2*MENU_VERT_MARGIN
;
1851 gi
->m_size
.x
= gi
->m_ofsAccel
+ widthAccelMax
+ MENU_RIGHT_MARGIN
;
1852 gi
->m_size
.y
= height
;
1857 #endif // wxUSE_MENUS
1859 // ----------------------------------------------------------------------------
1861 // ----------------------------------------------------------------------------
1863 void wxGTKRenderer::InitComboBitmaps()
1865 wxSize sizeArrow
= m_sizeScrollbarArrow
;
1871 for ( n
= ComboState_Normal
; n
< ComboState_Max
; n
++ )
1873 m_bitmapsCombo
[n
].Create(sizeArrow
.x
, sizeArrow
.y
);
1876 static const int comboButtonFlags
[ComboState_Max
] =
1884 wxRect
rect(sizeArrow
);
1887 for ( n
= ComboState_Normal
; n
< ComboState_Max
; n
++ )
1889 int flags
= comboButtonFlags
[n
];
1891 dc
.SelectObject(m_bitmapsCombo
[n
]);
1892 DrawSolidRect(dc
, GetBackgroundColour(flags
), rect
);
1893 DrawArrow(dc
, wxDOWN
, rect
, flags
);
1897 void wxGTKRenderer::GetComboBitmaps(wxBitmap
*bmpNormal
,
1899 wxBitmap
*bmpPressed
,
1900 wxBitmap
*bmpDisabled
)
1902 if ( !m_bitmapsCombo
[ComboState_Normal
].Ok() )
1908 *bmpNormal
= m_bitmapsCombo
[ComboState_Normal
];
1910 *bmpFocus
= m_bitmapsCombo
[ComboState_Focus
];
1912 *bmpPressed
= m_bitmapsCombo
[ComboState_Pressed
];
1914 *bmpDisabled
= m_bitmapsCombo
[ComboState_Disabled
];
1917 // ----------------------------------------------------------------------------
1919 // ----------------------------------------------------------------------------
1921 void wxGTKRenderer::DrawArrowBorder(wxDC
& dc
,
1925 static const wxDirection sides
[] =
1927 wxUP
, wxLEFT
, wxRIGHT
, wxDOWN
1930 wxRect rect1
, rect2
, rectInner
;
1936 rectInner
.Inflate(-2);
1938 DrawSolidRect(dc
, wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
), *rect
);
1940 // find the side not to draw and also adjust the rectangles to compensate
1942 wxDirection sideToOmit
;
1946 sideToOmit
= wxDOWN
;
1948 rectInner
.height
+= 1;
1956 rectInner
.height
+= 1;
1960 sideToOmit
= wxRIGHT
;
1962 rectInner
.width
+= 1;
1966 sideToOmit
= wxLEFT
;
1970 rectInner
.width
+= 1;
1974 wxFAIL_MSG(_T("unknown arrow direction"));
1978 // the outer rect first
1980 for ( n
= 0; n
< WXSIZEOF(sides
); n
++ )
1982 wxDirection side
= sides
[n
];
1983 if ( side
== sideToOmit
)
1986 DrawAntiShadedRectSide(dc
, rect1
, m_penDarkGrey
, m_penHighlight
, side
);
1989 // and then the inner one
1990 for ( n
= 0; n
< WXSIZEOF(sides
); n
++ )
1992 wxDirection side
= sides
[n
];
1993 if ( side
== sideToOmit
)
1996 DrawAntiShadedRectSide(dc
, rect2
, m_penBlack
, m_penGrey
, side
);
2002 void wxGTKRenderer::DrawScrollbarArrow(wxDC
& dc
,
2004 const wxRect
& rectArrow
,
2007 // first of all, draw the border around it - but we don't want the border
2008 // on the side opposite to the arrow point
2009 wxRect rect
= rectArrow
;
2010 DrawArrowBorder(dc
, &rect
, dir
);
2012 // then the arrow itself
2013 DrawArrow(dc
, dir
, rect
, flags
);
2016 // gtk_default_draw_arrow() takes ~350 lines and we can't do much better here
2017 // these people are just crazy :-(
2018 void wxGTKRenderer::DrawArrow(wxDC
& dc
,
2031 wxPoint ptArrow
[Point_Max
];
2033 wxColour colInside
= GetBackgroundColour(flags
);
2035 if ( flags
& wxCONTROL_DISABLED
)
2037 penShadow
[0] = m_penDarkGrey
;
2038 penShadow
[1] = m_penDarkGrey
;
2039 penShadow
[2] = wxNullPen
;
2040 penShadow
[3] = wxNullPen
;
2042 else if ( flags
& wxCONTROL_PRESSED
)
2044 penShadow
[0] = m_penDarkGrey
;
2045 penShadow
[1] = m_penHighlight
;
2046 penShadow
[2] = wxNullPen
;
2047 penShadow
[3] = m_penBlack
;
2049 else // normal arrow
2051 penShadow
[0] = m_penHighlight
;
2052 penShadow
[1] = m_penBlack
;
2053 penShadow
[2] = m_penDarkGrey
;
2054 penShadow
[3] = wxNullPen
;
2058 if ( dir
== wxUP
|| dir
== wxDOWN
)
2061 middle
= (rect
.GetRight() + rect
.GetLeft() + 1) / 2;
2065 middle
= (rect
.GetTop() + rect
.GetBottom() + 1) / 2;
2068 // draw the arrow interior
2069 dc
.SetPen(*wxTRANSPARENT_PEN
);
2070 dc
.SetBrush(colInside
);
2075 ptArrow
[Point_First
].x
= rect
.GetLeft();
2076 ptArrow
[Point_First
].y
= rect
.GetBottom();
2077 ptArrow
[Point_Second
].x
= middle
;
2078 ptArrow
[Point_Second
].y
= rect
.GetTop();
2079 ptArrow
[Point_Third
].x
= rect
.GetRight();
2080 ptArrow
[Point_Third
].y
= rect
.GetBottom();
2084 ptArrow
[Point_First
] = rect
.GetPosition();
2085 ptArrow
[Point_Second
].x
= middle
;
2086 ptArrow
[Point_Second
].y
= rect
.GetBottom();
2087 ptArrow
[Point_Third
].x
= rect
.GetRight();
2088 ptArrow
[Point_Third
].y
= rect
.GetTop();
2092 ptArrow
[Point_First
].x
= rect
.GetRight();
2093 ptArrow
[Point_First
].y
= rect
.GetTop();
2094 ptArrow
[Point_Second
].x
= rect
.GetLeft();
2095 ptArrow
[Point_Second
].y
= middle
;
2096 ptArrow
[Point_Third
].x
= rect
.GetRight();
2097 ptArrow
[Point_Third
].y
= rect
.GetBottom();
2101 ptArrow
[Point_First
] = rect
.GetPosition();
2102 ptArrow
[Point_Second
].x
= rect
.GetRight();
2103 ptArrow
[Point_Second
].y
= middle
;
2104 ptArrow
[Point_Third
].x
= rect
.GetLeft();
2105 ptArrow
[Point_Third
].y
= rect
.GetBottom();
2109 wxFAIL_MSG(_T("unknown arrow direction"));
2112 dc
.DrawPolygon(WXSIZEOF(ptArrow
), ptArrow
);
2114 // draw the arrow border
2115 dc
.SetPen(penShadow
[0]);
2119 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_First
]);
2120 dc
.DrawPoint(ptArrow
[Point_First
]);
2121 if ( penShadow
[3].Ok() )
2123 dc
.SetPen(penShadow
[3]);
2124 dc
.DrawLine(ptArrow
[Point_First
].x
+ 1, ptArrow
[Point_First
].y
,
2125 ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
);
2127 dc
.SetPen(penShadow
[1]);
2128 dc
.DrawLine(ptArrow
[Point_Second
].x
+ 1, ptArrow
[Point_Second
].y
+ 1,
2129 ptArrow
[Point_Third
].x
, ptArrow
[Point_Third
].y
);
2130 dc
.DrawPoint(ptArrow
[Point_Third
]);
2131 dc
.DrawLine(ptArrow
[Point_Third
].x
- 2, ptArrow
[Point_Third
].y
,
2132 ptArrow
[Point_First
].x
+ 1, ptArrow
[Point_First
].y
);
2133 if ( penShadow
[2].Ok() )
2135 dc
.SetPen(penShadow
[2]);
2136 dc
.DrawLine(ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
,
2137 ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
+ 1);
2138 dc
.DrawLine(ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
- 1,
2139 ptArrow
[Point_First
].x
+ 2, ptArrow
[Point_First
].y
- 1);
2144 dc
.DrawLine(ptArrow
[Point_First
], ptArrow
[Point_Second
]);
2145 dc
.DrawLine(ptArrow
[Point_First
].x
+ 2, ptArrow
[Point_First
].y
,
2146 ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
);
2147 if ( penShadow
[2].Ok() )
2149 dc
.SetPen(penShadow
[2]);
2150 dc
.DrawLine(ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
- 1,
2151 ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
- 1);
2153 dc
.SetPen(penShadow
[1]);
2154 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_Third
]);
2155 dc
.DrawPoint(ptArrow
[Point_Third
]);
2159 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_First
]);
2160 dc
.DrawPoint(ptArrow
[Point_First
]);
2161 if ( penShadow
[2].Ok() )
2163 dc
.SetPen(penShadow
[2]);
2164 dc
.DrawLine(ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
,
2165 ptArrow
[Point_First
].x
- 1, ptArrow
[Point_First
].y
+ 2);
2166 dc
.DrawLine(ptArrow
[Point_Third
].x
, ptArrow
[Point_Third
].y
,
2167 ptArrow
[Point_Second
].x
+ 2, ptArrow
[Point_Second
].y
+ 1);
2169 dc
.SetPen(penShadow
[1]);
2170 dc
.DrawLine(ptArrow
[Point_Third
].x
, ptArrow
[Point_Third
].y
,
2171 ptArrow
[Point_First
].x
, ptArrow
[Point_First
].y
+ 1);
2172 dc
.DrawLine(ptArrow
[Point_Second
].x
+ 1, ptArrow
[Point_Second
].y
+ 1,
2173 ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
);
2177 dc
.DrawLine(ptArrow
[Point_First
], ptArrow
[Point_Third
]);
2178 dc
.DrawLine(ptArrow
[Point_First
].x
+ 2, ptArrow
[Point_First
].y
+ 1,
2179 ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
);
2180 dc
.SetPen(penShadow
[1]);
2181 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_Third
]);
2182 dc
.DrawPoint(ptArrow
[Point_Third
]);
2186 wxFAIL_MSG(_T("unknown arrow direction"));
2191 void wxGTKRenderer::DrawThumbBorder(wxDC
& dc
,
2193 wxOrientation orient
)
2195 if ( orient
== wxVERTICAL
)
2197 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2199 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2201 rect
->Inflate(-1, 0);
2203 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2205 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2207 rect
->Inflate(-1, 0);
2211 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2213 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2215 rect
->Inflate(0, -1);
2217 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2219 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2221 rect
->Inflate(0, -1);
2225 void wxGTKRenderer::DrawScrollbarThumb(wxDC
& dc
,
2226 wxOrientation orient
,
2230 // the thumb is never pressed never has focus border under GTK and the
2231 // scrollbar background never changes at all
2232 int flagsThumb
= flags
& ~(wxCONTROL_PRESSED
| wxCONTROL_FOCUSED
);
2234 // we don't want the border in the direction of the scrollbar movement
2235 wxRect rectThumb
= rect
;
2236 DrawThumbBorder(dc
, &rectThumb
, orient
);
2238 DrawButtonBorder(dc
, rectThumb
, flagsThumb
, &rectThumb
);
2239 DrawBackground(dc
, wxNullColour
, rectThumb
, flagsThumb
);
2242 void wxGTKRenderer::DrawScrollbarShaft(wxDC
& dc
,
2243 wxOrientation orient
,
2245 int WXUNUSED(flags
))
2247 wxRect rectBar
= rect
;
2248 DrawThumbBorder(dc
, &rectBar
, orient
);
2249 DrawSolidRect(dc
, wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
), rectBar
);
2253 wxRect
wxGTKRenderer::GetScrollbarRect(const wxScrollBar
*scrollbar
,
2254 wxScrollBar::Element elem
,
2257 // as GTK scrollbars can't be disabled, it makes no sense to remove the
2258 // thumb for a scrollbar with range 0 - instead, make it fill the entire
2260 if ( (elem
== wxScrollBar::Element_Thumb
) && !scrollbar
->GetRange() )
2262 elem
= wxScrollBar::Element_Bar_2
;
2265 return wxStdRenderer::GetScrollbarRect(scrollbar
, elem
, thumbPos
);
2268 #endif // wxUSE_SCROLLBAR
2270 // ----------------------------------------------------------------------------
2272 // ----------------------------------------------------------------------------
2274 void wxGTKRenderer::AdjustSize(wxSize
*size
, const wxWindow
*window
)
2277 if ( wxDynamicCast(window
, wxBitmapButton
) )
2282 #endif // wxUSE_BMPBUTTON
2283 #if wxUSE_BUTTON || wxUSE_TOGGLEBTN
2286 || wxDynamicCast(window
, wxButton
)
2287 # endif // wxUSE_BUTTON
2288 # if wxUSE_TOGGLEBTN
2289 || wxDynamicCast(window
, wxToggleButton
)
2290 # endif // wxUSE_TOGGLEBTN
2293 if ( !(window
->GetWindowStyle() & wxBU_EXACTFIT
) )
2295 // TODO: this is ad hoc...
2296 size
->x
+= 3*window
->GetCharWidth();
2297 wxCoord minBtnHeight
= 18;
2298 if ( size
->y
< minBtnHeight
)
2299 size
->y
= minBtnHeight
;
2301 // button border width
2305 #endif // wxUSE_BUTTON || wxUSE_TOGGLEBTN
2307 if ( wxDynamicCast(window
, wxScrollBar
) )
2309 // we only set the width of vert scrollbars and height of the
2311 if ( window
->GetWindowStyle() & wxSB_HORIZONTAL
)
2312 size
->y
= m_sizeScrollbarArrow
.x
;
2314 size
->x
= m_sizeScrollbarArrow
.x
;
2317 #endif // wxUSE_SCROLLBAR
2319 // take into account the border width
2320 wxStdRenderer::AdjustSize(size
, window
);
2324 // ----------------------------------------------------------------------------
2326 // ----------------------------------------------------------------------------
2328 /* Copyright (c) Julian Smart */
2329 static const char *error_xpm
[] = {
2330 /* columns rows colors chars-per-pixel */
2344 " ................. ",
2345 " ................... ",
2346 " ....................... ",
2347 " ......................... ",
2348 " ........................... ",
2349 " ...........................X ",
2350 " .............................X ",
2351 " ............................... ",
2352 " ...............................X ",
2353 " .................................X ",
2354 " .................................X ",
2355 " .................................XX ",
2356 " ...ooooooooooooooooooooooooooo...XX ",
2357 " ....ooooooooooooooooooooooooooo....X ",
2358 " ....ooooooooooooooooooooooooooo....X ",
2359 " ....ooooooooooooooooooooooooooo....XX ",
2360 " ....ooooooooooooooooooooooooooo....XX ",
2361 " ....ooooooooooooooooooooooooooo....XX ",
2362 " ...ooooooooooooooooooooooooooo...XXX ",
2363 " ...ooooooooooooooooooooooooooo...XXX ",
2364 " .................................XX ",
2365 " .................................XX ",
2366 " ...............................XXX ",
2367 " ...............................XXX ",
2368 " .............................XXX ",
2369 " ...........................XXXX ",
2370 " ...........................XXX ",
2371 " .........................XXX ",
2372 " .......................XXXX ",
2373 " X...................XXXXX ",
2374 " X.................XXXXX ",
2375 " X.............XXXXX ",
2376 " XXXX.....XXXXXXXX ",
2387 /* Copyright (c) Julian Smart */
2388 static const char *info_xpm
[] = {
2389 /* columns rows colors chars-per-pixel */
2413 " .XXXOXXXXXXXoo. ",
2414 " .XOOXXX+XXXXXo. ",
2415 " .XOOOXX+++XXXXoo. ",
2416 " .XOOXXX+++XXXXXo. ",
2417 " .XOOOXXX+++XXXXXXo. ",
2418 " .XOOXXXX+++XXXXXXo. ",
2419 " .XXXXXXX+++XXXXXXX. ",
2420 " .XXXXXXX+++XXXXXXo. ",
2421 " .XXXXXXX+++XXXXXoo. ",
2422 " .XXXXXX+++XXXXXo. ",
2423 " .XXXXXXX+XXXXXXo. ",
2424 " .XXXXXXXXXXXXo. ",
2425 " .XXXXX+++XXXoo. ",
2451 /* Copyright (c) Julian Smart */
2452 static const char *warning_xpm
[] = {
2453 /* columns rows colors chars-per-pixel */
2483 " ..XXXXO@#XXX... ",
2484 " ...XXXXO@#XXXX.. ",
2485 " ..XXXXXO@#XXXX... ",
2486 " ...XXXXXo@OXXXXX.. ",
2487 " ...XXXXXXo@OXXXXXX.. ",
2488 " ..XXXXXXX$@OXXXXXX... ",
2489 " ...XXXXXXXX@XXXXXXXX.. ",
2490 " ...XXXXXXXXXXXXXXXXXX... ",
2491 " ..XXXXXXXXXXOXXXXXXXXX.. ",
2492 " ...XXXXXXXXXO@#XXXXXXXXX.. ",
2493 " ..XXXXXXXXXXX#XXXXXXXXXX... ",
2494 " ...XXXXXXXXXXXXXXXXXXXXXXX.. ",
2495 " ...XXXXXXXXXXXXXXXXXXXXXXXX... ",
2496 " .............................. ",
2497 " .............................. ",
2515 /* Copyright (c) Julian Smart */
2516 static const char *question_xpm
[] = {
2517 /* columns rows colors chars-per-pixel */
2547 " ..XXXXoooooXXXO+ ",
2548 " ..XXooooooooooooX@.. ",
2549 " ..XoooooooooooooooXX#. ",
2550 " $%XoooooooooooooooooXX#. ",
2551 " &.XoooooooXXXXXXooooooXX.. ",
2552 " .XooooooXX.$...$XXoooooX*. ",
2553 " $.XoooooX%.$ .*oooooo=.. ",
2554 " .XooooooX.. -.XoooooX.. ",
2555 " .XoooooX..+ .XoooooX;. ",
2556 " ...XXXX..: .XoooooX;. ",
2557 " ........ >.XoooooX;. ",
2591 wxBitmap
wxGTKArtProvider::CreateBitmap(const wxArtID
& id
,
2592 const wxArtClient
& WXUNUSED(client
),
2593 const wxSize
& WXUNUSED(size
))
2595 if ( id
== wxART_INFORMATION
)
2596 return wxBitmap(info_xpm
);
2597 if ( id
== wxART_ERROR
)
2598 return wxBitmap(error_xpm
);
2599 if ( id
== wxART_WARNING
)
2600 return wxBitmap(warning_xpm
);
2601 if ( id
== wxART_QUESTION
)
2602 return wxBitmap(question_xpm
);
2603 return wxNullBitmap
;
2607 // ============================================================================
2609 // ============================================================================
2611 // ----------------------------------------------------------------------------
2612 // wxGTKInputHandler
2613 // ----------------------------------------------------------------------------
2615 bool wxGTKInputHandler::HandleKey(wxInputConsumer
* WXUNUSED(control
),
2616 const wxKeyEvent
& WXUNUSED(event
),
2617 bool WXUNUSED(pressed
))
2622 bool wxGTKInputHandler::HandleMouse(wxInputConsumer
*control
,
2623 const wxMouseEvent
& event
)
2625 // clicking on the control gives it focus
2626 if ( event
.ButtonDown() && wxWindow::FindFocus() != control
->GetInputWindow() )
2628 control
->GetInputWindow()->SetFocus();
2636 bool wxGTKInputHandler::HandleMouseMove(wxInputConsumer
*control
,
2637 const wxMouseEvent
& event
)
2639 if ( event
.Entering() )
2641 control
->GetInputWindow()->SetCurrent(true);
2643 else if ( event
.Leaving() )
2645 control
->GetInputWindow()->SetCurrent(false);
2657 // ----------------------------------------------------------------------------
2658 // wxGTKCheckboxInputHandler
2659 // ----------------------------------------------------------------------------
2661 bool wxGTKCheckboxInputHandler::HandleKey(wxInputConsumer
*control
,
2662 const wxKeyEvent
& event
,
2667 int keycode
= event
.GetKeyCode();
2668 if ( keycode
== WXK_SPACE
|| keycode
== WXK_RETURN
)
2670 control
->PerformAction(wxACTION_CHECKBOX_TOGGLE
);
2679 #endif // wxUSE_CHECKBOX
2683 // ----------------------------------------------------------------------------
2684 // wxGTKTextCtrlInputHandler
2685 // ----------------------------------------------------------------------------
2687 bool wxGTKTextCtrlInputHandler::HandleKey(wxInputConsumer
*control
,
2688 const wxKeyEvent
& event
,
2691 // handle only GTK-specific text bindings here, the others are handled in
2695 wxControlAction action
;
2696 int keycode
= event
.GetKeyCode();
2697 if ( event
.ControlDown() )
2702 action
= wxACTION_TEXT_HOME
;
2706 action
= wxACTION_TEXT_LEFT
;
2710 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_RIGHT
;
2714 action
= wxACTION_TEXT_END
;
2718 action
= wxACTION_TEXT_RIGHT
;
2722 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_LEFT
;
2726 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_END
;
2730 action
= wxACTION_TEXT_DOWN
;
2734 action
= wxACTION_TEXT_UP
;
2738 //delete the entire line
2739 control
->PerformAction(wxACTION_TEXT_HOME
);
2740 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_END
;
2744 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_WORD_LEFT
;
2748 else if ( event
.AltDown() )
2753 action
= wxACTION_TEXT_WORD_LEFT
;
2757 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_WORD_RIGHT
;
2761 action
= wxACTION_TEXT_WORD_RIGHT
;
2766 if ( action
!= wxACTION_NONE
)
2768 control
->PerformAction(action
);
2774 return wxStdInputHandler::HandleKey(control
, event
, pressed
);
2777 #endif // wxUSE_TEXTCTRL
2779 #endif // wxUSE_THEME_GTK