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
);
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
);
837 void wxGTKRenderer::DrawFocusRect(wxDC
& dc
, const wxRect
& rect
)
839 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
840 wxRect rectFocus
= rect
;
841 DrawRect(dc
, &rectFocus
, m_penBlack
);
844 void wxGTKRenderer::DrawTextBorder(wxDC
& dc
,
846 const wxRect
& rectOrig
,
850 wxRect rect
= rectOrig
;
852 if ( border
!= wxBORDER_NONE
)
854 if ( flags
& wxCONTROL_FOCUSED
)
856 DrawRect(dc
, &rect
, m_penBlack
);
857 DrawAntiShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
861 DrawInnerShadedRect(dc
, &rect
);
869 void wxGTKRenderer::DrawButtonLabel(wxDC
& dc
,
870 const wxString
& label
,
871 const wxBitmap
& image
,
878 // no focus rect around buttons label in GTK+
879 wxStdRenderer::DrawButtonLabel(dc
, label
, image
, rect
, flags
,
880 alignment
, indexAccel
, rectBounds
);
883 void wxGTKRenderer::DrawButtonBorder(wxDC
& dc
,
884 const wxRect
& rectTotal
,
888 wxRect rect
= rectTotal
;
890 if ( flags
& wxCONTROL_PRESSED
)
892 // button pressed: draw a black border around it and an inward shade
893 DrawRect(dc
, &rect
, m_penBlack
);
895 DrawInnerShadedRect(dc
, &rect
);
897 else // button not pressed
899 if ( flags
& wxCONTROL_ISDEFAULT
)
904 if ( flags
& wxCONTROL_FOCUSED
)
906 // button is currently default: add an extra border around it
907 DrawRect(dc
, &rect
, m_penBlack
);
910 // now draw a normal button
911 DrawShadedRect(dc
, &rect
, m_penHighlight
, m_penBlack
);
912 DrawAntiShadedRect(dc
, &rect
, GetBackgroundColour(flags
), m_penDarkGrey
);
919 // ----------------------------------------------------------------------------
921 // ----------------------------------------------------------------------------
923 void wxGTKRenderer::DrawFrameWithLabel(wxDC
& dc
,
924 const wxString
& label
,
925 const wxRect
& rectFrame
,
926 const wxRect
& rectTextOrig
,
931 wxRect
rectText(rectTextOrig
);
932 rectText
.Inflate(1, 0);
935 DrawLabel(dc
, label
, rectText
, flags
, alignment
, indexAccel
, &rectLabel
);
937 rectLabel
.width
+= 2;
939 DrawFrameWithoutLabel(dc
, rectFrame
, rectLabel
);
941 // GTK+ does it like this
942 dc
.SetPen(m_penHighlight
);
943 dc
.DrawPoint(rectText
.x
, rectFrame
.y
);
944 dc
.DrawPoint(rectText
.x
+ rectLabel
.width
- 3, rectFrame
.y
);
947 // ----------------------------------------------------------------------------
948 // check/radion buttons
949 // ----------------------------------------------------------------------------
951 void wxGTKRenderer::DrawCheckItemBitmap(wxDC
& dc
,
952 const wxBitmap
& bitmap
,
956 // never draw the focus rect around the check indicators here
957 DrawCheckButton(dc
, wxEmptyString
, bitmap
, rect
, flags
& ~wxCONTROL_FOCUSED
);
960 void wxGTKRenderer::DrawUndeterminedBitmap(wxDC
& dc
,
961 const wxRect
& rectTotal
,
964 // FIXME: For sure it is not GTK look but it is better than nothing.
965 // Show me correct look and I will immediatelly make it better (ABX)
966 wxRect rect
= rectTotal
;
972 col1
= wxSCHEME_COLOUR(m_scheme
, SHADOW_DARK
);
973 col2
= wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
);
977 col1
= wxSCHEME_COLOUR(m_scheme
, SHADOW_DARK
);
978 col2
= wxSCHEME_COLOUR(m_scheme
, SHADOW_IN
);
981 dc
.SetPen(*wxTRANSPARENT_PEN
);
983 dc
.DrawRectangle(rect
);
986 dc
.DrawRectangle(rect
);
989 void wxGTKRenderer::DrawUncheckBitmap(wxDC
& dc
,
990 const wxRect
& rectTotal
,
993 wxRect rect
= rectTotal
;
994 DrawAntiRaisedBorder(dc
, &rect
);
996 wxColour col
= wxSCHEME_COLOUR(m_scheme
, SHADOW_IN
);
997 dc
.SetPen(wxPen(col
));
998 dc
.DrawPoint(rect
.GetRight() - 1, rect
.GetBottom() - 1);
1001 col
= wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
);
1002 //else: it is SHADOW_IN, leave as is
1004 dc
.SetPen(*wxTRANSPARENT_PEN
);
1006 dc
.DrawRectangle(rect
);
1009 void wxGTKRenderer::DrawCheckBitmap(wxDC
& dc
, const wxRect
& rectTotal
)
1011 wxRect rect
= rectTotal
;
1012 DrawAntiShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
1013 DrawShadedRect(dc
, &rect
, m_penBlack
, m_penLightGrey
);
1015 dc
.SetPen(*wxTRANSPARENT_PEN
);
1016 dc
.SetBrush(wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
));
1017 dc
.DrawRectangle(rect
);
1020 void wxGTKRenderer::DrawRadioBitmap(wxDC
& dc
,
1026 xRight
= rect
.GetRight(),
1027 yBottom
= rect
.GetBottom();
1029 wxCoord yMid
= (y
+ yBottom
) / 2;
1031 // then draw the upper half
1032 dc
.SetPen(flags
& wxCONTROL_CHECKED
? m_penDarkGrey
: m_penHighlight
);
1033 DrawUpZag(dc
, x
, xRight
, yMid
, y
);
1034 DrawUpZag(dc
, x
+ 1, xRight
- 1, yMid
, y
+ 1);
1037 if ( flags
& wxCONTROL_CHECKED
)
1038 dc
.SetPen(m_penBlack
);
1039 else if ( flags
& wxCONTROL_PRESSED
)
1040 dc
.SetPen(wxPen(wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
)));
1041 else // unchecked and unpressed
1045 DrawUpZag(dc
, x
+ 2, xRight
- 2, yMid
, y
+ 2);
1047 // and then the lower one
1048 dc
.SetPen(flags
& wxCONTROL_CHECKED
? m_penHighlight
: m_penBlack
);
1049 DrawDownZag(dc
, x
, xRight
, yMid
, yBottom
);
1050 if ( !(flags
& wxCONTROL_CHECKED
) )
1051 dc
.SetPen(m_penDarkGrey
);
1052 DrawDownZag(dc
, x
+ 1, xRight
- 1, yMid
, yBottom
- 1);
1054 if ( !(flags
& wxCONTROL_CHECKED
) )
1055 drawIt
= true; // with the same pen
1056 else if ( flags
& wxCONTROL_PRESSED
)
1058 dc
.SetPen(wxPen(wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
)));
1061 else // checked and unpressed
1065 DrawDownZag(dc
, x
+ 2, xRight
- 2, yMid
, yBottom
- 2);
1068 void wxGTKRenderer::DrawUpZag(wxDC
& dc
,
1074 wxCoord xMid
= (x1
+ x2
) / 2;
1075 dc
.DrawLine(x1
, y1
, xMid
, y2
);
1076 dc
.DrawLine(xMid
, y2
, x2
+ 1, y1
+ 1);
1079 void wxGTKRenderer::DrawDownZag(wxDC
& dc
,
1085 wxCoord xMid
= (x1
+ x2
) / 2;
1086 dc
.DrawLine(x1
+ 1, y1
+ 1, xMid
, y2
);
1087 dc
.DrawLine(xMid
, y2
, x2
, y1
);
1090 wxBitmap
wxGTKRenderer::GetCheckBitmap(int flags
)
1092 if ( !m_bitmapsCheckbox
[0][0].Ok() )
1094 // init the bitmaps once only
1096 wxSize size
= GetCheckBitmapSize();
1097 rect
.width
= size
.x
;
1098 rect
.height
= size
.y
;
1099 for ( int i
= 0; i
< 2; i
++ )
1101 for ( int j
= 0; j
< 3; j
++ )
1102 m_bitmapsCheckbox
[i
][j
].Create(rect
.width
, rect
.height
);
1108 dc
.SelectObject(m_bitmapsCheckbox
[0][0]);
1109 DrawCheckBitmap(dc
, rect
);
1112 dc
.SelectObject(m_bitmapsCheckbox
[0][1]);
1113 DrawUncheckBitmap(dc
, rect
, false);
1115 // normal undeterminated
1116 dc
.SelectObject(m_bitmapsCheckbox
[0][2]);
1117 DrawUndeterminedBitmap(dc
, rect
, false);
1120 m_bitmapsCheckbox
[1][0] = m_bitmapsCheckbox
[0][0];
1122 // pressed unchecked
1123 dc
.SelectObject(m_bitmapsCheckbox
[1][1]);
1124 DrawUncheckBitmap(dc
, rect
, true);
1126 // pressed undeterminated
1127 dc
.SelectObject(m_bitmapsCheckbox
[1][2]);
1128 DrawUndeterminedBitmap(dc
, rect
, true);
1131 IndicatorState state
;
1132 IndicatorStatus status
;
1133 GetIndicatorsFromFlags(flags
, state
, status
);
1135 // disabled looks the same as normal
1136 if ( state
== IndicatorState_Disabled
)
1137 state
= IndicatorState_Normal
;
1139 return m_bitmapsCheckbox
[state
][status
];
1142 wxBitmap
wxGTKRenderer::GetRadioBitmap(int flags
)
1144 IndicatorState state
;
1145 IndicatorStatus status
;
1146 GetIndicatorsFromFlags(flags
, state
, status
);
1148 wxBitmap
& bmp
= m_bitmapsRadiobtn
[state
][status
];
1151 const wxSize size
= GetRadioBitmapSize();
1154 bmp
.Create(size
.x
, size
.y
);
1155 dc
.SelectObject(bmp
);
1157 DrawRadioBitmap(dc
, size
, flags
);
1163 wxBitmap
wxGTKRenderer::GetLineWrapBitmap() const
1165 if ( !m_bmpLineWrap
.Ok() )
1167 // the line wrap bitmap as used by GTK+
1168 #define line_wrap_width 6
1169 #define line_wrap_height 9
1170 static const char line_wrap_bits
[] =
1172 0x1e, 0x3e, 0x30, 0x30, 0x39, 0x1f, 0x0f, 0x0f, 0x1f,
1175 wxBitmap
bmpLineWrap(line_wrap_bits
, line_wrap_width
, line_wrap_height
);
1176 if ( !bmpLineWrap
.Ok() )
1178 wxFAIL_MSG( _T("Failed to create line wrap XBM") );
1182 wxConstCast(this, wxGTKRenderer
)->m_bmpLineWrap
= bmpLineWrap
;
1186 return m_bmpLineWrap
;
1190 void wxGTKRenderer::DrawToolBarButton(wxDC
& dc
,
1191 const wxString
& label
,
1192 const wxBitmap
& bitmap
,
1193 const wxRect
& rectOrig
,
1195 long WXUNUSED(style
),
1198 // we don't draw the separators at all
1199 if ( !label
.empty() || bitmap
.Ok() )
1201 wxRect rect
= rectOrig
;
1202 rect
.Deflate(BORDER_THICKNESS
);
1204 if ( flags
& wxCONTROL_PRESSED
)
1206 DrawBorder(dc
, wxBORDER_SUNKEN
, rect
, flags
, &rect
);
1208 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
), rect
);
1210 else if ( flags
& wxCONTROL_CURRENT
)
1212 DrawBorder(dc
, wxBORDER_RAISED
, rect
, flags
, &rect
);
1214 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL_CURRENT
), rect
);
1217 if(tbarStyle
& wxTB_TEXT
)
1219 if(tbarStyle
& wxTB_HORIZONTAL
)
1221 dc
.DrawLabel(label
, bitmap
, rect
, wxALIGN_CENTRE
);
1225 dc
.DrawLabel(label
, bitmap
, rect
, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
);
1230 int xpoint
= (rect
.GetLeft() + rect
.GetRight() + 1 - bitmap
.GetWidth()) / 2;
1231 int ypoint
= (rect
.GetTop() + rect
.GetBottom() + 1 - bitmap
.GetHeight()) / 2;
1232 dc
.DrawBitmap(bitmap
, xpoint
, ypoint
);
1236 #endif // wxUSE_TOOLBAR
1238 // ----------------------------------------------------------------------------
1240 // ----------------------------------------------------------------------------
1244 wxRect
wxGTKRenderer::GetTextClientArea(const wxTextCtrl
*text
,
1246 wxCoord
*extraSpaceBeyond
) const
1249 rectText
= wxStdRenderer::GetTextClientArea(text
, rect
, extraSpaceBeyond
);
1251 if ( text
->WrapLines() )
1253 // leave enough for the line wrap bitmap indicator
1254 wxCoord widthMark
= GetLineWrapBitmap().GetWidth() + 2;
1256 rectText
.width
-= widthMark
;
1258 if ( extraSpaceBeyond
)
1259 *extraSpaceBeyond
= widthMark
;
1265 void wxGTKRenderer::DrawLineWrapMark(wxDC
& dc
, const wxRect
& rect
)
1267 wxBitmap bmpLineWrap
= GetLineWrapBitmap();
1269 // for a mono bitmap he colours it appears in depends on the current text
1270 // colours, so set them correctly
1272 if ( bmpLineWrap
.GetDepth() == 1 )
1274 colFgOld
= dc
.GetTextForeground();
1276 // FIXME: I wonder what should we do if the background is black too?
1277 dc
.SetTextForeground(*wxBLACK
);
1280 dc
.DrawBitmap(bmpLineWrap
,
1281 rect
.x
, rect
.y
+ (rect
.height
- bmpLineWrap
.GetHeight())/2);
1283 if ( colFgOld
.Ok() )
1285 // restore old colour
1286 dc
.SetTextForeground(colFgOld
);
1290 #endif // wxUSE_TEXTCTRL
1292 // ----------------------------------------------------------------------------
1294 // ----------------------------------------------------------------------------
1298 void wxGTKRenderer::DrawTab(wxDC
& dc
,
1299 const wxRect
& rectOrig
,
1301 const wxString
& label
,
1302 const wxBitmap
& bitmap
,
1306 #define SELECT_FOR_VERTICAL(X,Y) ( isVertical ? Y : X )
1307 #define REVERSE_FOR_VERTICAL(X,Y) \
1308 SELECT_FOR_VERTICAL(X,Y) \
1310 SELECT_FOR_VERTICAL(Y,X)
1312 wxRect rect
= rectOrig
;
1314 bool isVertical
= ( dir
== wxLEFT
) || ( dir
== wxRIGHT
);
1316 // the current tab is drawn indented (to the top for default case) and
1317 // bigger than the other ones
1318 const wxSize indent
= GetTabIndent();
1319 if ( flags
& wxCONTROL_SELECTED
)
1321 rect
.Inflate( SELECT_FOR_VERTICAL( indent
.x
, 0),
1322 SELECT_FOR_VERTICAL( 0, indent
.y
));
1326 wxFAIL_MSG(_T("invaild notebook tab orientation"));
1333 rect
.height
+= indent
.y
;
1340 rect
.width
+= indent
.x
;
1345 // selected tab has different colour
1346 wxColour col
= flags
& wxCONTROL_SELECTED
1347 ? wxSCHEME_COLOUR(m_scheme
, SHADOW_IN
)
1348 : wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
);
1349 DrawSolidRect(dc
, col
, rect
);
1351 if ( flags
& wxCONTROL_FOCUSED
)
1353 // draw the focus rect
1354 wxRect rectBorder
= rect
;
1355 rectBorder
.Deflate(4, 3);
1356 if ( dir
== wxBOTTOM
)
1357 rectBorder
.Offset(0, -1);
1358 if ( dir
== wxRIGHT
)
1359 rectBorder
.Offset(-1, 0);
1361 DrawRect(dc
, &rectBorder
, m_penBlack
);
1364 // draw the text, image and the focus around them (if necessary)
1365 wxRect
rectLabel( REVERSE_FOR_VERTICAL(rect
.x
,rect
.y
),
1366 REVERSE_FOR_VERTICAL(rect
.width
,rect
.height
)
1368 rectLabel
.Deflate(1, 1);
1371 // draw it horizontally into memory and rotate for screen
1373 wxBitmap bitmapRotated
,
1374 bitmapMem( rectLabel
.x
+ rectLabel
.width
,
1375 rectLabel
.y
+ rectLabel
.height
);
1376 dcMem
.SelectObject(bitmapMem
);
1377 dcMem
.SetBackground(dc
.GetBackground());
1378 dcMem
.SetFont(dc
.GetFont());
1379 dcMem
.SetTextForeground(dc
.GetTextForeground());
1383 wxBitmap( wxImage( bitmap
.ConvertToImage() ).Rotate90(dir
==wxLEFT
) )
1386 #endif // wxUSE_IMAGE
1388 dcMem
.DrawLabel(label
, bitmapRotated
, rectLabel
, wxALIGN_CENTRE
, indexAccel
);
1389 dcMem
.SelectObject(wxNullBitmap
);
1390 bitmapMem
= bitmapMem
.GetSubBitmap(rectLabel
);
1392 bitmapMem
= wxBitmap(wxImage(bitmapMem
.ConvertToImage()).Rotate90(dir
==wxRIGHT
))
1396 dc
.DrawBitmap(bitmapMem
, rectLabel
.y
, rectLabel
.x
, false);
1400 dc
.DrawLabel(label
, bitmap
, rectLabel
, wxALIGN_CENTRE
, indexAccel
);
1403 // now draw the tab itself
1404 wxCoord x
= SELECT_FOR_VERTICAL(rect
.x
,rect
.y
),
1405 y
= SELECT_FOR_VERTICAL(rect
.y
,rect
.x
),
1406 x2
= SELECT_FOR_VERTICAL(rect
.GetRight(),rect
.GetBottom()),
1407 y2
= SELECT_FOR_VERTICAL(rect
.GetBottom(),rect
.GetRight());
1413 // left orientation looks like top but IsVertical makes x and y reversed
1415 // top is not vertical so use coordinates in written order
1416 dc
.SetPen(m_penHighlight
);
1417 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y2
),
1418 REVERSE_FOR_VERTICAL(x
, y
));
1419 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
),
1420 REVERSE_FOR_VERTICAL(x2
, y
));
1422 dc
.SetPen(m_penBlack
);
1423 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y2
),
1424 REVERSE_FOR_VERTICAL(x2
, y
));
1426 dc
.SetPen(m_penDarkGrey
);
1427 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
- 1, y2
),
1428 REVERSE_FOR_VERTICAL(x2
- 1, y
+ 1));
1430 if ( flags
& wxCONTROL_SELECTED
)
1432 dc
.SetPen(m_penLightGrey
);
1434 // overwrite the part of the border below this tab
1435 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
+ 1),
1436 REVERSE_FOR_VERTICAL(x2
- 1, y2
+ 1));
1438 // and the shadow of the tab to the left of us
1439 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
+ 2),
1440 REVERSE_FOR_VERTICAL(x
+ 1, y2
+ 1));
1445 // right orientation looks like bottom but IsVertical makes x and y reversed
1447 // bottom is not vertical so use coordinates in written order
1448 dc
.SetPen(m_penHighlight
);
1450 // we need to continue one pixel further to overwrite the corner of
1451 // the border for the selected tab
1452 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y
- (flags
& wxCONTROL_SELECTED
? 1 : 0)),
1453 REVERSE_FOR_VERTICAL(x
, y2
));
1455 // it doesn't work like this (TODO: implement it properly)
1457 // erase the corner of the tab to the right
1458 dc
.SetPen(m_penLightGrey
);
1459 dc
.DrawPoint(REVERSE_FOR_VERTICAL(x2
- 1, y
- 2));
1460 dc
.DrawPoint(REVERSE_FOR_VERTICAL(x2
- 2, y
- 2));
1461 dc
.DrawPoint(REVERSE_FOR_VERTICAL(x2
- 2, y
- 1));
1464 dc
.SetPen(m_penBlack
);
1465 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
),
1466 REVERSE_FOR_VERTICAL(x2
, y2
));
1467 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y
),
1468 REVERSE_FOR_VERTICAL(x2
, y2
));
1470 dc
.SetPen(m_penDarkGrey
);
1471 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 2, y2
- 1),
1472 REVERSE_FOR_VERTICAL(x2
- 1, y2
- 1));
1473 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
- 1, y
),
1474 REVERSE_FOR_VERTICAL(x2
- 1, y2
));
1476 if ( flags
& wxCONTROL_SELECTED
)
1478 dc
.SetPen(m_penLightGrey
);
1480 // overwrite the part of the (double!) border above this tab
1481 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
- 1),
1482 REVERSE_FOR_VERTICAL(x2
- 1, y
- 1));
1483 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
- 2),
1484 REVERSE_FOR_VERTICAL(x2
- 1, y
- 2));
1486 // and the shadow of the tab to the left of us
1487 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
- 1),
1488 REVERSE_FOR_VERTICAL(x
+ 1, y
- 1));
1494 #endif // wxUSE_NOTEBOOK
1496 // ----------------------------------------------------------------------------
1498 // ----------------------------------------------------------------------------
1502 wxSize
wxGTKRenderer::GetSliderThumbSize(const wxRect
& rect
,
1504 wxOrientation orient
) const
1506 static const wxCoord SLIDER_THUMB_LENGTH
= 30;
1510 wxRect rectShaft
= GetSliderShaftRect(rect
, lenThumb
, orient
);
1511 if ( orient
== wxHORIZONTAL
)
1513 size
.x
= wxMin(SLIDER_THUMB_LENGTH
, rectShaft
.width
);
1514 size
.y
= rectShaft
.height
;
1518 size
.y
= wxMin(SLIDER_THUMB_LENGTH
, rectShaft
.height
);
1519 size
.x
= rectShaft
.width
;
1525 wxRect
wxGTKRenderer::GetSliderShaftRect(const wxRect
& rect
,
1526 int WXUNUSED(lenThumb
),
1527 wxOrientation
WXUNUSED(orient
),
1528 long WXUNUSED(style
)) const
1530 return rect
.Deflate(2*BORDER_THICKNESS
, 2*BORDER_THICKNESS
);
1533 void wxGTKRenderer::DrawSliderShaft(wxDC
& dc
,
1534 const wxRect
& rectOrig
,
1535 int WXUNUSED(lenThumb
),
1536 wxOrientation
WXUNUSED(orient
),
1538 long WXUNUSED(style
),
1541 wxRect rect
= rectOrig
;
1543 // draw the border first
1544 if ( flags
& wxCONTROL_FOCUSED
)
1546 DrawRect(dc
, &rect
, m_penBlack
);
1548 else // not focused, normal
1550 DrawAntiShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
1553 DrawAntiShadedRect(dc
, &rect
, m_penBlack
, m_penLightGrey
);
1555 // and the background
1556 DrawSolidRect(dc
, wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
), rect
);
1562 void wxGTKRenderer::DrawSliderThumb(wxDC
& dc
,
1563 const wxRect
& rectOrig
,
1564 wxOrientation orient
,
1565 int WXUNUSED(flags
),
1566 long WXUNUSED(style
))
1568 // draw the thumb border
1569 wxRect rect
= rectOrig
;
1570 DrawAntiRaisedBorder(dc
, &rect
);
1572 // draw the handle in the middle
1573 if ( orient
== wxVERTICAL
)
1575 rect
.height
= 2*BORDER_THICKNESS
;
1576 rect
.y
= rectOrig
.y
+ (rectOrig
.height
- rect
.height
) / 2;
1580 rect
.width
= 2*BORDER_THICKNESS
;
1581 rect
.x
= rectOrig
.x
+ (rectOrig
.width
- rect
.width
) / 2;
1584 DrawShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
1587 #endif // wxUSE_SLIDER
1591 // ----------------------------------------------------------------------------
1593 // ----------------------------------------------------------------------------
1595 // wxGTKMenuGeometryInfo: the wxMenuGeometryInfo used by wxGTKRenderer
1596 class WXDLLEXPORT wxGTKMenuGeometryInfo
: public wxMenuGeometryInfo
1599 virtual wxSize
GetSize() const { return m_size
; }
1601 wxCoord
GetLabelOffset() const { return m_ofsLabel
; }
1602 wxCoord
GetAccelOffset() const { return m_ofsAccel
; }
1604 wxCoord
GetItemHeight() const { return m_heightItem
; }
1607 // the total size of the menu
1610 // the offset of the start of the menu item label
1613 // the offset of the start of the accel label
1616 // the height of a normal (not separator) item
1617 wxCoord m_heightItem
;
1619 friend wxMenuGeometryInfo
*
1620 wxGTKRenderer::GetMenuGeometry(wxWindow
*, const wxMenu
&) const;
1623 // FIXME: all constants are hardcoded but shouldn't be
1624 static const wxCoord MENU_LEFT_MARGIN
= 9;
1625 static const wxCoord MENU_RIGHT_MARGIN
= 6;
1627 static const wxCoord MENU_HORZ_MARGIN
= 6;
1628 static const wxCoord MENU_VERT_MARGIN
= 3;
1630 // the margin around bitmap/check marks (on each side)
1631 static const wxCoord MENU_BMP_MARGIN
= 2;
1633 // the margin between the labels and accel strings
1634 static const wxCoord MENU_ACCEL_MARGIN
= 8;
1636 // the separator height in pixels: in fact, strangely enough, the real height
1637 // is 2 but Windows adds one extra pixel in the bottom margin, so take it into
1639 static const wxCoord MENU_SEPARATOR_HEIGHT
= 3;
1641 // the size of the standard checkmark bitmap
1642 static const wxCoord MENU_CHECK_SIZE
= 9;
1644 void wxGTKRenderer::DrawMenuBarItem(wxDC
& dc
,
1646 const wxString
& label
,
1650 DoDrawMenuItem(dc
, rect
, label
, flags
, indexAccel
);
1653 void wxGTKRenderer::DrawMenuItem(wxDC
& dc
,
1655 const wxMenuGeometryInfo
& gi
,
1656 const wxString
& label
,
1657 const wxString
& accel
,
1658 const wxBitmap
& bitmap
,
1662 const wxGTKMenuGeometryInfo
& geomInfo
= (const wxGTKMenuGeometryInfo
&)gi
;
1667 rect
.width
= geomInfo
.GetSize().x
;
1668 rect
.height
= geomInfo
.GetItemHeight();
1670 DoDrawMenuItem(dc
, rect
, label
, flags
, indexAccel
, accel
, bitmap
, &geomInfo
);
1673 void wxGTKRenderer::DoDrawMenuItem(wxDC
& dc
,
1674 const wxRect
& rectOrig
,
1675 const wxString
& label
,
1678 const wxString
& accel
,
1679 const wxBitmap
& bitmap
,
1680 const wxGTKMenuGeometryInfo
*geometryInfo
)
1682 wxRect rect
= rectOrig
;
1684 // draw the selected item specially
1685 if ( flags
& wxCONTROL_SELECTED
)
1688 DrawBorder(dc
, wxBORDER_RAISED
, rect
, flags
, &rectIn
);
1690 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL_CURRENT
), rectIn
);
1693 rect
.Deflate(MENU_HORZ_MARGIN
, MENU_VERT_MARGIN
);
1695 // draw the bitmap: use the bitmap provided or the standard checkmark for
1696 // the checkable items
1699 wxBitmap bmp
= bitmap
;
1700 if ( !bmp
.Ok() && (flags
& wxCONTROL_CHECKABLE
) )
1702 bmp
= GetCheckBitmap(flags
);
1707 rect
.SetRight(geometryInfo
->GetLabelOffset());
1708 wxControlRenderer::DrawBitmap(dc
, bmp
, rect
);
1711 //else: menubar items don't have bitmaps
1716 rect
.x
= geometryInfo
->GetLabelOffset();
1717 rect
.SetRight(geometryInfo
->GetAccelOffset());
1720 DrawLabel(dc
, label
, rect
, flags
, wxALIGN_CENTRE_VERTICAL
, indexAccel
);
1722 // draw the accel string
1723 if ( !accel
.empty() )
1725 // menubar items shouldn't have them
1726 wxCHECK_RET( geometryInfo
, _T("accel strings only valid for menus") );
1728 rect
.x
= geometryInfo
->GetAccelOffset();
1729 rect
.SetRight(geometryInfo
->GetSize().x
);
1731 // NB: no accel index here
1732 DrawLabel(dc
, accel
, rect
, flags
, wxALIGN_CENTRE_VERTICAL
);
1735 // draw the submenu indicator
1736 if ( flags
& wxCONTROL_ISSUBMENU
)
1738 wxCHECK_RET( geometryInfo
, _T("wxCONTROL_ISSUBMENU only valid for menus") );
1740 rect
.x
= geometryInfo
->GetSize().x
- MENU_RIGHT_MARGIN
;
1741 rect
.width
= MENU_RIGHT_MARGIN
;
1743 DrawArrow(dc
, wxRIGHT
, rect
, flags
);
1747 void wxGTKRenderer::DrawMenuSeparator(wxDC
& dc
,
1749 const wxMenuGeometryInfo
& geomInfo
)
1751 DrawHorizontalLine(dc
, y
+ MENU_VERT_MARGIN
, 0, geomInfo
.GetSize().x
);
1754 wxSize
wxGTKRenderer::GetMenuBarItemSize(const wxSize
& sizeText
) const
1756 wxSize size
= sizeText
;
1758 // TODO: make this configurable
1759 size
.x
+= 2*MENU_HORZ_MARGIN
;
1760 size
.y
+= 2*MENU_VERT_MARGIN
;
1765 wxMenuGeometryInfo
*wxGTKRenderer::GetMenuGeometry(wxWindow
*win
,
1766 const wxMenu
& menu
) const
1768 // prepare the dc: for now we draw all the items with the system font
1770 dc
.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
1772 // the height of a normal item
1773 wxCoord heightText
= dc
.GetCharHeight();
1778 // the max length of label and accel strings: the menu width is the sum of
1779 // them, even if they're for different items (as the accels should be
1782 // the max length of the bitmap is never 0 as Windows always leaves enough
1783 // space for a check mark indicator
1784 wxCoord widthLabelMax
= 0,
1786 widthBmpMax
= MENU_LEFT_MARGIN
;
1788 for ( wxMenuItemList::compatibility_iterator node
= menu
.GetMenuItems().GetFirst();
1790 node
= node
->GetNext() )
1792 // height of this item
1795 wxMenuItem
*item
= node
->GetData();
1796 if ( item
->IsSeparator() )
1798 h
= MENU_SEPARATOR_HEIGHT
;
1800 else // not separator
1805 dc
.GetTextExtent(item
->GetLabel(), &widthLabel
, NULL
);
1806 if ( widthLabel
> widthLabelMax
)
1808 widthLabelMax
= widthLabel
;
1812 dc
.GetTextExtent(item
->GetAccelString(), &widthAccel
, NULL
);
1813 if ( widthAccel
> widthAccelMax
)
1815 widthAccelMax
= widthAccel
;
1818 const wxBitmap
& bmp
= item
->GetBitmap();
1821 wxCoord widthBmp
= bmp
.GetWidth();
1822 if ( widthBmp
> widthBmpMax
)
1823 widthBmpMax
= widthBmp
;
1825 //else if ( item->IsCheckable() ): no need to check for this as
1826 // MENU_LEFT_MARGIN is big enough to show the check mark
1829 h
+= 2*MENU_VERT_MARGIN
;
1831 // remember the item position and height
1832 item
->SetGeometry(height
, h
);
1837 // bundle the metrics into a struct and return it
1838 wxGTKMenuGeometryInfo
*gi
= new wxGTKMenuGeometryInfo
;
1840 gi
->m_ofsLabel
= widthBmpMax
+ 2*MENU_BMP_MARGIN
;
1841 gi
->m_ofsAccel
= gi
->m_ofsLabel
+ widthLabelMax
;
1842 if ( widthAccelMax
> 0 )
1844 // if we actually have any accesl, add a margin
1845 gi
->m_ofsAccel
+= MENU_ACCEL_MARGIN
;
1848 gi
->m_heightItem
= heightText
+ 2*MENU_VERT_MARGIN
;
1850 gi
->m_size
.x
= gi
->m_ofsAccel
+ widthAccelMax
+ MENU_RIGHT_MARGIN
;
1851 gi
->m_size
.y
= height
;
1856 #endif // wxUSE_MENUS
1858 // ----------------------------------------------------------------------------
1860 // ----------------------------------------------------------------------------
1862 void wxGTKRenderer::InitComboBitmaps()
1864 wxSize sizeArrow
= m_sizeScrollbarArrow
;
1870 for ( n
= ComboState_Normal
; n
< ComboState_Max
; n
++ )
1872 m_bitmapsCombo
[n
].Create(sizeArrow
.x
, sizeArrow
.y
);
1875 static const int comboButtonFlags
[ComboState_Max
] =
1883 wxRect
rect(sizeArrow
);
1886 for ( n
= ComboState_Normal
; n
< ComboState_Max
; n
++ )
1888 int flags
= comboButtonFlags
[n
];
1890 dc
.SelectObject(m_bitmapsCombo
[n
]);
1891 DrawSolidRect(dc
, GetBackgroundColour(flags
), rect
);
1892 DrawArrow(dc
, wxDOWN
, rect
, flags
);
1896 void wxGTKRenderer::GetComboBitmaps(wxBitmap
*bmpNormal
,
1898 wxBitmap
*bmpPressed
,
1899 wxBitmap
*bmpDisabled
)
1901 if ( !m_bitmapsCombo
[ComboState_Normal
].Ok() )
1907 *bmpNormal
= m_bitmapsCombo
[ComboState_Normal
];
1909 *bmpFocus
= m_bitmapsCombo
[ComboState_Focus
];
1911 *bmpPressed
= m_bitmapsCombo
[ComboState_Pressed
];
1913 *bmpDisabled
= m_bitmapsCombo
[ComboState_Disabled
];
1916 // ----------------------------------------------------------------------------
1918 // ----------------------------------------------------------------------------
1920 void wxGTKRenderer::DrawArrowBorder(wxDC
& dc
,
1924 static const wxDirection sides
[] =
1926 wxUP
, wxLEFT
, wxRIGHT
, wxDOWN
1929 wxRect rect1
, rect2
, rectInner
;
1935 rectInner
.Inflate(-2);
1937 DrawSolidRect(dc
, wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
), *rect
);
1939 // find the side not to draw and also adjust the rectangles to compensate
1941 wxDirection sideToOmit
;
1945 sideToOmit
= wxDOWN
;
1947 rectInner
.height
+= 1;
1955 rectInner
.height
+= 1;
1959 sideToOmit
= wxRIGHT
;
1961 rectInner
.width
+= 1;
1965 sideToOmit
= wxLEFT
;
1969 rectInner
.width
+= 1;
1973 wxFAIL_MSG(_T("unknown arrow direction"));
1977 // the outer rect first
1979 for ( n
= 0; n
< WXSIZEOF(sides
); n
++ )
1981 wxDirection side
= sides
[n
];
1982 if ( side
== sideToOmit
)
1985 DrawAntiShadedRectSide(dc
, rect1
, m_penDarkGrey
, m_penHighlight
, side
);
1988 // and then the inner one
1989 for ( n
= 0; n
< WXSIZEOF(sides
); n
++ )
1991 wxDirection side
= sides
[n
];
1992 if ( side
== sideToOmit
)
1995 DrawAntiShadedRectSide(dc
, rect2
, m_penBlack
, m_penGrey
, side
);
2001 void wxGTKRenderer::DrawScrollbarArrow(wxDC
& dc
,
2003 const wxRect
& rectArrow
,
2006 // first of all, draw the border around it - but we don't want the border
2007 // on the side opposite to the arrow point
2008 wxRect rect
= rectArrow
;
2009 DrawArrowBorder(dc
, &rect
, dir
);
2011 // then the arrow itself
2012 DrawArrow(dc
, dir
, rect
, flags
);
2015 // gtk_default_draw_arrow() takes ~350 lines and we can't do much better here
2016 // these people are just crazy :-(
2017 void wxGTKRenderer::DrawArrow(wxDC
& dc
,
2030 wxPoint ptArrow
[Point_Max
];
2032 wxColour colInside
= GetBackgroundColour(flags
);
2034 if ( flags
& wxCONTROL_DISABLED
)
2036 penShadow
[0] = m_penDarkGrey
;
2037 penShadow
[1] = m_penDarkGrey
;
2038 penShadow
[2] = wxNullPen
;
2039 penShadow
[3] = wxNullPen
;
2041 else if ( flags
& wxCONTROL_PRESSED
)
2043 penShadow
[0] = m_penDarkGrey
;
2044 penShadow
[1] = m_penHighlight
;
2045 penShadow
[2] = wxNullPen
;
2046 penShadow
[3] = m_penBlack
;
2048 else // normal arrow
2050 penShadow
[0] = m_penHighlight
;
2051 penShadow
[1] = m_penBlack
;
2052 penShadow
[2] = m_penDarkGrey
;
2053 penShadow
[3] = wxNullPen
;
2057 if ( dir
== wxUP
|| dir
== wxDOWN
)
2060 middle
= (rect
.GetRight() + rect
.GetLeft() + 1) / 2;
2064 middle
= (rect
.GetTop() + rect
.GetBottom() + 1) / 2;
2067 // draw the arrow interior
2068 dc
.SetPen(*wxTRANSPARENT_PEN
);
2069 dc
.SetBrush(colInside
);
2074 ptArrow
[Point_First
].x
= rect
.GetLeft();
2075 ptArrow
[Point_First
].y
= rect
.GetBottom();
2076 ptArrow
[Point_Second
].x
= middle
;
2077 ptArrow
[Point_Second
].y
= rect
.GetTop();
2078 ptArrow
[Point_Third
].x
= rect
.GetRight();
2079 ptArrow
[Point_Third
].y
= rect
.GetBottom();
2083 ptArrow
[Point_First
] = rect
.GetPosition();
2084 ptArrow
[Point_Second
].x
= middle
;
2085 ptArrow
[Point_Second
].y
= rect
.GetBottom();
2086 ptArrow
[Point_Third
].x
= rect
.GetRight();
2087 ptArrow
[Point_Third
].y
= rect
.GetTop();
2091 ptArrow
[Point_First
].x
= rect
.GetRight();
2092 ptArrow
[Point_First
].y
= rect
.GetTop();
2093 ptArrow
[Point_Second
].x
= rect
.GetLeft();
2094 ptArrow
[Point_Second
].y
= middle
;
2095 ptArrow
[Point_Third
].x
= rect
.GetRight();
2096 ptArrow
[Point_Third
].y
= rect
.GetBottom();
2100 ptArrow
[Point_First
] = rect
.GetPosition();
2101 ptArrow
[Point_Second
].x
= rect
.GetRight();
2102 ptArrow
[Point_Second
].y
= middle
;
2103 ptArrow
[Point_Third
].x
= rect
.GetLeft();
2104 ptArrow
[Point_Third
].y
= rect
.GetBottom();
2108 wxFAIL_MSG(_T("unknown arrow direction"));
2111 dc
.DrawPolygon(WXSIZEOF(ptArrow
), ptArrow
);
2113 // draw the arrow border
2114 dc
.SetPen(penShadow
[0]);
2118 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_First
]);
2119 dc
.DrawPoint(ptArrow
[Point_First
]);
2120 if ( penShadow
[3].Ok() )
2122 dc
.SetPen(penShadow
[3]);
2123 dc
.DrawLine(ptArrow
[Point_First
].x
+ 1, ptArrow
[Point_First
].y
,
2124 ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
);
2126 dc
.SetPen(penShadow
[1]);
2127 dc
.DrawLine(ptArrow
[Point_Second
].x
+ 1, ptArrow
[Point_Second
].y
+ 1,
2128 ptArrow
[Point_Third
].x
, ptArrow
[Point_Third
].y
);
2129 dc
.DrawPoint(ptArrow
[Point_Third
]);
2130 dc
.DrawLine(ptArrow
[Point_Third
].x
- 2, ptArrow
[Point_Third
].y
,
2131 ptArrow
[Point_First
].x
+ 1, ptArrow
[Point_First
].y
);
2132 if ( penShadow
[2].Ok() )
2134 dc
.SetPen(penShadow
[2]);
2135 dc
.DrawLine(ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
,
2136 ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
+ 1);
2137 dc
.DrawLine(ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
- 1,
2138 ptArrow
[Point_First
].x
+ 2, ptArrow
[Point_First
].y
- 1);
2143 dc
.DrawLine(ptArrow
[Point_First
], ptArrow
[Point_Second
]);
2144 dc
.DrawLine(ptArrow
[Point_First
].x
+ 2, ptArrow
[Point_First
].y
,
2145 ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
);
2146 if ( penShadow
[2].Ok() )
2148 dc
.SetPen(penShadow
[2]);
2149 dc
.DrawLine(ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
- 1,
2150 ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
- 1);
2152 dc
.SetPen(penShadow
[1]);
2153 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_Third
]);
2154 dc
.DrawPoint(ptArrow
[Point_Third
]);
2158 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_First
]);
2159 dc
.DrawPoint(ptArrow
[Point_First
]);
2160 if ( penShadow
[2].Ok() )
2162 dc
.SetPen(penShadow
[2]);
2163 dc
.DrawLine(ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
,
2164 ptArrow
[Point_First
].x
- 1, ptArrow
[Point_First
].y
+ 2);
2165 dc
.DrawLine(ptArrow
[Point_Third
].x
, ptArrow
[Point_Third
].y
,
2166 ptArrow
[Point_Second
].x
+ 2, ptArrow
[Point_Second
].y
+ 1);
2168 dc
.SetPen(penShadow
[1]);
2169 dc
.DrawLine(ptArrow
[Point_Third
].x
, ptArrow
[Point_Third
].y
,
2170 ptArrow
[Point_First
].x
, ptArrow
[Point_First
].y
+ 1);
2171 dc
.DrawLine(ptArrow
[Point_Second
].x
+ 1, ptArrow
[Point_Second
].y
+ 1,
2172 ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
);
2176 dc
.DrawLine(ptArrow
[Point_First
], ptArrow
[Point_Third
]);
2177 dc
.DrawLine(ptArrow
[Point_First
].x
+ 2, ptArrow
[Point_First
].y
+ 1,
2178 ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
);
2179 dc
.SetPen(penShadow
[1]);
2180 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_Third
]);
2181 dc
.DrawPoint(ptArrow
[Point_Third
]);
2185 wxFAIL_MSG(_T("unknown arrow direction"));
2190 void wxGTKRenderer::DrawThumbBorder(wxDC
& dc
,
2192 wxOrientation orient
)
2194 if ( orient
== wxVERTICAL
)
2196 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2198 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2200 rect
->Inflate(-1, 0);
2202 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2204 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2206 rect
->Inflate(-1, 0);
2210 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2212 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2214 rect
->Inflate(0, -1);
2216 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2218 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2220 rect
->Inflate(0, -1);
2224 void wxGTKRenderer::DrawScrollbarThumb(wxDC
& dc
,
2225 wxOrientation orient
,
2229 // the thumb is never pressed never has focus border under GTK and the
2230 // scrollbar background never changes at all
2231 int flagsThumb
= flags
& ~(wxCONTROL_PRESSED
| wxCONTROL_FOCUSED
);
2233 // we don't want the border in the direction of the scrollbar movement
2234 wxRect rectThumb
= rect
;
2235 DrawThumbBorder(dc
, &rectThumb
, orient
);
2237 DrawButtonBorder(dc
, rectThumb
, flagsThumb
, &rectThumb
);
2238 DrawBackground(dc
, wxNullColour
, rectThumb
, flagsThumb
);
2241 void wxGTKRenderer::DrawScrollbarShaft(wxDC
& dc
,
2242 wxOrientation orient
,
2244 int WXUNUSED(flags
))
2246 wxRect rectBar
= rect
;
2247 DrawThumbBorder(dc
, &rectBar
, orient
);
2248 DrawSolidRect(dc
, wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
), rectBar
);
2252 wxRect
wxGTKRenderer::GetScrollbarRect(const wxScrollBar
*scrollbar
,
2253 wxScrollBar::Element elem
,
2256 // as GTK scrollbars can't be disabled, it makes no sense to remove the
2257 // thumb for a scrollbar with range 0 - instead, make it fill the entire
2259 if ( (elem
== wxScrollBar::Element_Thumb
) && !scrollbar
->GetRange() )
2261 elem
= wxScrollBar::Element_Bar_2
;
2264 return wxStdRenderer::GetScrollbarRect(scrollbar
, elem
, thumbPos
);
2267 #endif // wxUSE_SCROLLBAR
2269 // ----------------------------------------------------------------------------
2271 // ----------------------------------------------------------------------------
2273 void wxGTKRenderer::AdjustSize(wxSize
*size
, const wxWindow
*window
)
2276 if ( wxDynamicCast(window
, wxBitmapButton
) )
2281 #endif // wxUSE_BMPBUTTON
2282 #if wxUSE_BUTTON || wxUSE_TOGGLEBTN
2285 || wxDynamicCast(window
, wxButton
)
2286 # endif // wxUSE_BUTTON
2287 # if wxUSE_TOGGLEBTN
2288 || wxDynamicCast(window
, wxToggleButton
)
2289 # endif // wxUSE_TOGGLEBTN
2292 if ( !(window
->GetWindowStyle() & wxBU_EXACTFIT
) )
2294 // TODO: this is ad hoc...
2295 size
->x
+= 3*window
->GetCharWidth();
2296 wxCoord minBtnHeight
= 18;
2297 if ( size
->y
< minBtnHeight
)
2298 size
->y
= minBtnHeight
;
2300 // button border width
2304 #endif // wxUSE_BUTTON || wxUSE_TOGGLEBTN
2306 if ( wxDynamicCast(window
, wxScrollBar
) )
2308 // we only set the width of vert scrollbars and height of the
2310 if ( window
->GetWindowStyle() & wxSB_HORIZONTAL
)
2311 size
->y
= m_sizeScrollbarArrow
.x
;
2313 size
->x
= m_sizeScrollbarArrow
.x
;
2316 #endif // wxUSE_SCROLLBAR
2318 // take into account the border width
2319 wxStdRenderer::AdjustSize(size
, window
);
2323 // ----------------------------------------------------------------------------
2325 // ----------------------------------------------------------------------------
2327 /* Copyright (c) Julian Smart */
2328 static const char *error_xpm
[] = {
2329 /* columns rows colors chars-per-pixel */
2343 " ................. ",
2344 " ................... ",
2345 " ....................... ",
2346 " ......................... ",
2347 " ........................... ",
2348 " ...........................X ",
2349 " .............................X ",
2350 " ............................... ",
2351 " ...............................X ",
2352 " .................................X ",
2353 " .................................X ",
2354 " .................................XX ",
2355 " ...ooooooooooooooooooooooooooo...XX ",
2356 " ....ooooooooooooooooooooooooooo....X ",
2357 " ....ooooooooooooooooooooooooooo....X ",
2358 " ....ooooooooooooooooooooooooooo....XX ",
2359 " ....ooooooooooooooooooooooooooo....XX ",
2360 " ....ooooooooooooooooooooooooooo....XX ",
2361 " ...ooooooooooooooooooooooooooo...XXX ",
2362 " ...ooooooooooooooooooooooooooo...XXX ",
2363 " .................................XX ",
2364 " .................................XX ",
2365 " ...............................XXX ",
2366 " ...............................XXX ",
2367 " .............................XXX ",
2368 " ...........................XXXX ",
2369 " ...........................XXX ",
2370 " .........................XXX ",
2371 " .......................XXXX ",
2372 " X...................XXXXX ",
2373 " X.................XXXXX ",
2374 " X.............XXXXX ",
2375 " XXXX.....XXXXXXXX ",
2386 /* Copyright (c) Julian Smart */
2387 static const char *info_xpm
[] = {
2388 /* columns rows colors chars-per-pixel */
2412 " .XXXOXXXXXXXoo. ",
2413 " .XOOXXX+XXXXXo. ",
2414 " .XOOOXX+++XXXXoo. ",
2415 " .XOOXXX+++XXXXXo. ",
2416 " .XOOOXXX+++XXXXXXo. ",
2417 " .XOOXXXX+++XXXXXXo. ",
2418 " .XXXXXXX+++XXXXXXX. ",
2419 " .XXXXXXX+++XXXXXXo. ",
2420 " .XXXXXXX+++XXXXXoo. ",
2421 " .XXXXXX+++XXXXXo. ",
2422 " .XXXXXXX+XXXXXXo. ",
2423 " .XXXXXXXXXXXXo. ",
2424 " .XXXXX+++XXXoo. ",
2450 /* Copyright (c) Julian Smart */
2451 static const char *warning_xpm
[] = {
2452 /* columns rows colors chars-per-pixel */
2482 " ..XXXXO@#XXX... ",
2483 " ...XXXXO@#XXXX.. ",
2484 " ..XXXXXO@#XXXX... ",
2485 " ...XXXXXo@OXXXXX.. ",
2486 " ...XXXXXXo@OXXXXXX.. ",
2487 " ..XXXXXXX$@OXXXXXX... ",
2488 " ...XXXXXXXX@XXXXXXXX.. ",
2489 " ...XXXXXXXXXXXXXXXXXX... ",
2490 " ..XXXXXXXXXXOXXXXXXXXX.. ",
2491 " ...XXXXXXXXXO@#XXXXXXXXX.. ",
2492 " ..XXXXXXXXXXX#XXXXXXXXXX... ",
2493 " ...XXXXXXXXXXXXXXXXXXXXXXX.. ",
2494 " ...XXXXXXXXXXXXXXXXXXXXXXXX... ",
2495 " .............................. ",
2496 " .............................. ",
2514 /* Copyright (c) Julian Smart */
2515 static const char *question_xpm
[] = {
2516 /* columns rows colors chars-per-pixel */
2546 " ..XXXXoooooXXXO+ ",
2547 " ..XXooooooooooooX@.. ",
2548 " ..XoooooooooooooooXX#. ",
2549 " $%XoooooooooooooooooXX#. ",
2550 " &.XoooooooXXXXXXooooooXX.. ",
2551 " .XooooooXX.$...$XXoooooX*. ",
2552 " $.XoooooX%.$ .*oooooo=.. ",
2553 " .XooooooX.. -.XoooooX.. ",
2554 " .XoooooX..+ .XoooooX;. ",
2555 " ...XXXX..: .XoooooX;. ",
2556 " ........ >.XoooooX;. ",
2590 wxBitmap
wxGTKArtProvider::CreateBitmap(const wxArtID
& id
,
2591 const wxArtClient
& WXUNUSED(client
),
2592 const wxSize
& WXUNUSED(size
))
2594 if ( id
== wxART_INFORMATION
)
2595 return wxBitmap(info_xpm
);
2596 if ( id
== wxART_ERROR
)
2597 return wxBitmap(error_xpm
);
2598 if ( id
== wxART_WARNING
)
2599 return wxBitmap(warning_xpm
);
2600 if ( id
== wxART_QUESTION
)
2601 return wxBitmap(question_xpm
);
2602 return wxNullBitmap
;
2606 // ============================================================================
2608 // ============================================================================
2610 // ----------------------------------------------------------------------------
2611 // wxGTKInputHandler
2612 // ----------------------------------------------------------------------------
2614 bool wxGTKInputHandler::HandleKey(wxInputConsumer
* WXUNUSED(control
),
2615 const wxKeyEvent
& WXUNUSED(event
),
2616 bool WXUNUSED(pressed
))
2621 bool wxGTKInputHandler::HandleMouse(wxInputConsumer
*control
,
2622 const wxMouseEvent
& event
)
2624 // clicking on the control gives it focus
2625 if ( event
.ButtonDown() && wxWindow::FindFocus() != control
->GetInputWindow() )
2627 control
->GetInputWindow()->SetFocus();
2635 bool wxGTKInputHandler::HandleMouseMove(wxInputConsumer
*control
,
2636 const wxMouseEvent
& event
)
2638 if ( event
.Entering() )
2640 control
->GetInputWindow()->SetCurrent(true);
2642 else if ( event
.Leaving() )
2644 control
->GetInputWindow()->SetCurrent(false);
2656 // ----------------------------------------------------------------------------
2657 // wxGTKCheckboxInputHandler
2658 // ----------------------------------------------------------------------------
2660 bool wxGTKCheckboxInputHandler::HandleKey(wxInputConsumer
*control
,
2661 const wxKeyEvent
& event
,
2666 int keycode
= event
.GetKeyCode();
2667 if ( keycode
== WXK_SPACE
|| keycode
== WXK_RETURN
)
2669 control
->PerformAction(wxACTION_CHECKBOX_TOGGLE
);
2678 #endif // wxUSE_CHECKBOX
2682 // ----------------------------------------------------------------------------
2683 // wxGTKTextCtrlInputHandler
2684 // ----------------------------------------------------------------------------
2686 bool wxGTKTextCtrlInputHandler::HandleKey(wxInputConsumer
*control
,
2687 const wxKeyEvent
& event
,
2690 // handle only GTK-specific text bindings here, the others are handled in
2694 wxControlAction action
;
2695 int keycode
= event
.GetKeyCode();
2696 if ( event
.ControlDown() )
2701 action
= wxACTION_TEXT_HOME
;
2705 action
= wxACTION_TEXT_LEFT
;
2709 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_RIGHT
;
2713 action
= wxACTION_TEXT_END
;
2717 action
= wxACTION_TEXT_RIGHT
;
2721 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_LEFT
;
2725 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_END
;
2729 action
= wxACTION_TEXT_DOWN
;
2733 action
= wxACTION_TEXT_UP
;
2737 //delete the entire line
2738 control
->PerformAction(wxACTION_TEXT_HOME
);
2739 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_END
;
2743 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_WORD_LEFT
;
2747 else if ( event
.AltDown() )
2752 action
= wxACTION_TEXT_WORD_LEFT
;
2756 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_WORD_RIGHT
;
2760 action
= wxACTION_TEXT_WORD_RIGHT
;
2765 if ( action
!= wxACTION_NONE
)
2767 control
->PerformAction(action
);
2773 return wxStdInputHandler::HandleKey(control
, event
, pressed
);
2776 #endif // wxUSE_TEXTCTRL
2778 #endif // wxUSE_THEME_GTK