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"
30 #include "wx/dcmemory.h"
31 #include "wx/window.h"
35 #include "wx/bmpbuttn.h"
36 #include "wx/button.h"
37 #include "wx/checkbox.h"
38 #include "wx/listbox.h"
39 #include "wx/checklst.h"
40 #include "wx/combobox.h"
41 #include "wx/scrolbar.h"
42 #include "wx/slider.h"
43 #include "wx/textctrl.h"
44 #include "wx/toolbar.h"
45 #include "wx/statusbr.h"
47 #include "wx/settings.h"
48 #include "wx/toplevel.h"
52 #include "wx/notebook.h"
53 #include "wx/spinbutt.h"
54 #include "wx/artprov.h"
55 #ifdef wxUSE_TOGGLEBTN
56 #include "wx/tglbtn.h"
57 #endif // wxUSE_TOGGLEBTN
59 #include "wx/univ/stdrend.h"
60 #include "wx/univ/inpcons.h"
61 #include "wx/univ/inphand.h"
62 #include "wx/univ/colschem.h"
63 #include "wx/univ/theme.h"
65 class WXDLLEXPORT wxGTKMenuGeometryInfo
;
67 // ----------------------------------------------------------------------------
69 // ----------------------------------------------------------------------------
71 // standard border size
72 static const int BORDER_THICKNESS
= 2;
74 // ----------------------------------------------------------------------------
75 // wxGTKRenderer: draw the GUI elements in GTK style
76 // ----------------------------------------------------------------------------
78 class wxGTKRenderer
: public wxStdRenderer
81 wxGTKRenderer(const wxColourScheme
*scheme
);
84 virtual void DrawFocusRect(wxDC
& dc
, const wxRect
& rect
);
85 virtual void DrawTextBorder(wxDC
& dc
,
89 wxRect
*rectIn
= NULL
);
90 virtual void DrawButtonLabel(wxDC
& dc
,
91 const wxString
& label
,
92 const wxBitmap
& image
,
98 virtual void DrawButtonBorder(wxDC
& dc
,
101 wxRect
*rectIn
= NULL
);
102 virtual void DrawArrow(wxDC
& dc
,
106 virtual void DrawScrollbarArrow(wxDC
& dc
,
110 virtual void DrawScrollbarThumb(wxDC
& dc
,
111 wxOrientation orient
,
114 virtual void DrawScrollbarShaft(wxDC
& dc
,
115 wxOrientation orient
,
120 virtual void DrawToolBarButton(wxDC
& dc
,
121 const wxString
& label
,
122 const wxBitmap
& bitmap
,
127 #endif // wxUSE_TOOLBAR
130 virtual void DrawLineWrapMark(wxDC
& dc
, const wxRect
& rect
);
131 #endif // wxUSE_TEXTCTRL
134 virtual void DrawTab(wxDC
& dc
,
137 const wxString
& label
,
138 const wxBitmap
& bitmap
= wxNullBitmap
,
140 int indexAccel
= -1);
141 #endif // wxUSE_NOTEBOOK
144 virtual void DrawSliderShaft(wxDC
& dc
,
147 wxOrientation orient
,
150 wxRect
*rectShaft
= NULL
);
151 virtual void DrawSliderThumb(wxDC
& dc
,
153 wxOrientation orient
,
156 virtual void DrawSliderTicks(wxDC
& WXUNUSED(dc
),
157 const wxRect
& WXUNUSED(rect
),
158 int WXUNUSED(lenThumb
),
159 wxOrientation
WXUNUSED(orient
),
162 int WXUNUSED(step
) = 1,
163 int WXUNUSED(flags
) = 0,
164 long WXUNUSED(style
) = 0)
166 // we don't have the ticks in GTK version
168 #endif // wxUSE_SLIDER
171 virtual void DrawMenuBarItem(wxDC
& dc
,
173 const wxString
& label
,
175 int indexAccel
= -1);
176 virtual void DrawMenuItem(wxDC
& dc
,
178 const wxMenuGeometryInfo
& geometryInfo
,
179 const wxString
& label
,
180 const wxString
& accel
,
181 const wxBitmap
& bitmap
= wxNullBitmap
,
183 int indexAccel
= -1);
184 virtual void DrawMenuSeparator(wxDC
& dc
,
186 const wxMenuGeometryInfo
& geomInfo
);
187 #endif // wxUSE_MENUS
189 virtual void GetComboBitmaps(wxBitmap
*bmpNormal
,
191 wxBitmap
*bmpPressed
,
192 wxBitmap
*bmpDisabled
);
194 virtual void AdjustSize(wxSize
*size
, const wxWindow
*window
);
196 // geometry and hit testing
197 virtual wxSize
GetScrollbarArrowSize() const
198 { return m_sizeScrollbarArrow
; }
200 virtual wxRect
GetScrollbarRect(const wxScrollBar
*scrollbar
,
201 wxScrollBar::Element elem
,
202 int thumbPos
= -1) const;
203 #endif // wxUSE_SCROLLBAR
205 virtual wxSize
GetCheckBitmapSize() const
206 { return wxSize(10, 10); }
207 virtual wxSize
GetRadioBitmapSize() const
208 { return wxSize(11, 11); }
209 virtual wxCoord
GetCheckItemMargin() const
213 virtual wxSize
GetToolBarButtonSize(wxCoord
*separator
) const
214 { if ( separator
) *separator
= 5; return wxSize(16, 15); }
215 virtual wxSize
GetToolBarMargin() const
216 { return wxSize(6, 6); }
217 #endif // wxUSE_TOOLBAR
220 virtual wxRect
GetTextClientArea(const wxTextCtrl
*text
,
222 wxCoord
*extraSpaceBeyond
) const;
223 #endif // wxUSE_TEXTCTRL
226 virtual wxSize
GetTabIndent() const { return wxSize(2, 2); }
227 virtual wxSize
GetTabPadding() const { return wxSize(6, 6); }
228 #endif // wxUSE_NOTEBOOK
231 virtual wxCoord
GetSliderDim() const { return 15; }
232 virtual wxCoord
GetSliderTickLen() const { return 0; }
233 virtual wxRect
GetSliderShaftRect(const wxRect
& rect
,
235 wxOrientation orient
,
236 long style
= 0) const;
237 virtual wxSize
GetSliderThumbSize(const wxRect
& rect
,
239 wxOrientation orient
) const;
240 #endif // wxUSE_SLIDER
242 virtual wxSize
GetProgressBarStep() const { return wxSize(16, 32); }
245 virtual wxSize
GetMenuBarItemSize(const wxSize
& sizeText
) const;
246 virtual wxMenuGeometryInfo
*GetMenuGeometry(wxWindow
*win
,
247 const wxMenu
& menu
) const;
248 #endif // wxUSE_MENUS
250 // helpers for "wxBitmap wxColourScheme::Get()"
251 void DrawCheckBitmap(wxDC
& dc
, const wxRect
& rect
);
252 void DrawUncheckBitmap(wxDC
& dc
, const wxRect
& rect
, bool isPressed
);
253 void DrawUndeterminedBitmap(wxDC
& dc
, const wxRect
& rect
, bool isPressed
);
256 // overridden wxStdRenderer methods
257 virtual void DrawSunkenBorder(wxDC
& dc
, wxRect
*rect
);
259 virtual void DrawFrameWithLabel(wxDC
& dc
,
260 const wxString
& label
,
261 const wxRect
& rectFrame
,
262 const wxRect
& rectText
,
267 virtual void DrawCheckItemBitmap(wxDC
& dc
,
268 const wxBitmap
& bitmap
,
272 // get the colour to use for background
273 wxColour
GetBackgroundColour(int flags
) const
275 if ( flags
& wxCONTROL_PRESSED
)
276 return wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
);
277 else if ( flags
& wxCONTROL_CURRENT
)
278 return wxSCHEME_COLOUR(m_scheme
, CONTROL_CURRENT
);
280 return wxSCHEME_COLOUR(m_scheme
, CONTROL
);
283 // as DrawShadedRect() but the pixels in the bottom left and upper right
284 // border are drawn with the pen1, not pen2
285 void DrawAntiShadedRect(wxDC
& dc
, wxRect
*rect
,
286 const wxPen
& pen1
, const wxPen
& pen2
);
288 // used for drawing opened rectangles - draws only one side of it at once
289 // (and doesn't adjust the rect)
290 void DrawAntiShadedRectSide(wxDC
& dc
,
296 // draw an opened rect for the arrow in given direction
297 void DrawArrowBorder(wxDC
& dc
,
301 // draw two sides of the rectangle
302 void DrawThumbBorder(wxDC
& dc
,
304 wxOrientation orient
);
306 // just as DrawRaisedBorder() except that the bottom left and up right
307 // pixels of the interior rect are drawn in another colour (i.e. the inner
308 // rect is drawn with DrawAntiShadedRect() and not DrawShadedRect())
309 void DrawAntiRaisedBorder(wxDC
& dc
, wxRect
*rect
);
311 // draw inner GTK shadow
312 void DrawInnerShadedRect(wxDC
& dc
, wxRect
*rect
);
315 // returns the size of the arrow for the scrollbar (depends on
317 wxSize
GetScrollbarArrowSize(const wxScrollBar
*scrollbar
) const
320 if ( scrollbar
->IsVertical() )
322 size
= m_sizeScrollbarArrow
;
326 size
.x
= m_sizeScrollbarArrow
.y
;
327 size
.y
= m_sizeScrollbarArrow
.x
;
332 #endif // wxUSE_SCROLLBAR
334 // get the line wrap indicator bitmap
335 wxBitmap
GetLineWrapBitmap() const;
337 virtual wxBitmap
GetCheckBitmap(int flags
);
338 virtual wxBitmap
GetRadioBitmap(int flags
);
340 // draw a /\ or \/ line from (x1, y1) to (x2, y1) passing by the point
342 void DrawUpZag(wxDC
& dc
,
343 wxCoord x1
, wxCoord x2
,
344 wxCoord y1
, wxCoord y2
);
345 void DrawDownZag(wxDC
& dc
,
346 wxCoord x1
, wxCoord x2
,
347 wxCoord y1
, wxCoord y2
);
349 // draw the radio button bitmap for the given state
350 void DrawRadioBitmap(wxDC
& dc
, const wxRect
& rect
, int flags
);
352 // common part of DrawMenuItem() and DrawMenuBarItem()
353 void DoDrawMenuItem(wxDC
& dc
,
355 const wxString
& label
,
358 const wxString
& accel
= wxEmptyString
,
359 const wxBitmap
& bitmap
= wxNullBitmap
,
360 const wxGTKMenuGeometryInfo
*geometryInfo
= NULL
);
362 // initialize the combo bitmaps
363 void InitComboBitmaps();
365 virtual wxBitmap
GetFrameButtonBitmap(FrameButtonType
WXUNUSED(type
))
371 const wxColourScheme
*m_scheme
;
374 wxSize m_sizeScrollbarArrow
;
379 // the checkbox and radio button bitmaps: first row is for the normal,
380 // second for the pressed state and the columns are for checked, unchecked
381 // and undeterminated respectively
382 wxBitmap m_bitmapsCheckbox
[IndicatorState_MaxCtrl
][IndicatorStatus_Max
],
383 m_bitmapsRadiobtn
[IndicatorState_MaxCtrl
][IndicatorStatus_Max
];
385 // the line wrap bitmap (drawn at the end of wrapped lines)
386 wxBitmap m_bmpLineWrap
;
388 // the combobox bitmaps
398 wxBitmap m_bitmapsCombo
[ComboState_Max
];
401 // ----------------------------------------------------------------------------
402 // wxGTKInputHandler and derived classes: process the keyboard and mouse
403 // messages according to GTK standards
404 // ----------------------------------------------------------------------------
406 class wxGTKInputHandler
: public wxInputHandler
409 wxGTKInputHandler() { }
411 virtual bool HandleKey(wxInputConsumer
*control
,
412 const wxKeyEvent
& event
,
414 virtual bool HandleMouse(wxInputConsumer
*control
,
415 const wxMouseEvent
& event
);
416 virtual bool HandleMouseMove(wxInputConsumer
*control
,
417 const wxMouseEvent
& event
);
422 class wxGTKScrollBarInputHandler
: public wxStdScrollBarInputHandler
425 wxGTKScrollBarInputHandler(wxRenderer
*renderer
, wxInputHandler
*handler
)
426 : wxStdScrollBarInputHandler(renderer
, handler
) { }
429 virtual void Highlight(wxScrollBar
*scrollbar
, bool doIt
)
431 // only arrows and the thumb can be highlighted
432 if ( !IsArrow() && m_htLast
!= wxHT_SCROLLBAR_THUMB
)
435 wxStdScrollBarInputHandler::Highlight(scrollbar
, doIt
);
438 virtual void Press(wxScrollBar
*scrollbar
, bool doIt
)
440 // only arrows can be pressed
444 wxStdScrollBarInputHandler::Press(scrollbar
, doIt
);
447 // any button can be used to drag the scrollbar under GTK+
448 virtual bool IsAllowedButton(int WXUNUSED(button
)) const { return true; }
452 return m_htLast
== wxHT_SCROLLBAR_ARROW_LINE_1
||
453 m_htLast
== wxHT_SCROLLBAR_ARROW_LINE_2
;
457 #endif // wxUSE_SCROLLBAR
461 class wxGTKCheckboxInputHandler
: public wxStdInputHandler
464 wxGTKCheckboxInputHandler(wxInputHandler
*handler
)
465 : wxStdInputHandler(handler
) { }
467 virtual bool HandleKey(wxInputConsumer
*control
,
468 const wxKeyEvent
& event
,
472 #endif // wxUSE_CHECKBOX
476 class wxGTKTextCtrlInputHandler
: public wxStdInputHandler
479 wxGTKTextCtrlInputHandler(wxInputHandler
*handler
)
480 : wxStdInputHandler(handler
) { }
482 virtual bool HandleKey(wxInputConsumer
*control
,
483 const wxKeyEvent
& event
,
487 #endif // wxUSE_TEXTCTRL
489 // ----------------------------------------------------------------------------
490 // wxGTKColourScheme: uses the standard GTK colours
491 // ----------------------------------------------------------------------------
493 class wxGTKColourScheme
: public wxColourScheme
496 virtual wxColour
Get(StdColour col
) const;
497 virtual wxColour
GetBackground(wxWindow
*win
) const;
500 // ----------------------------------------------------------------------------
502 // ----------------------------------------------------------------------------
504 class wxGTKArtProvider
: public wxArtProvider
507 virtual wxBitmap
CreateBitmap(const wxArtID
& id
,
508 const wxArtClient
& client
,
512 // ----------------------------------------------------------------------------
514 // ----------------------------------------------------------------------------
516 WX_DEFINE_ARRAY_PTR(wxInputHandler
*, wxArrayHandlers
);
518 class wxGTKTheme
: public wxTheme
522 virtual ~wxGTKTheme();
524 virtual wxRenderer
*GetRenderer();
525 virtual wxArtProvider
*GetArtProvider();
526 virtual wxInputHandler
*GetInputHandler(const wxString
& control
,
527 wxInputConsumer
*consumer
);
528 virtual wxColourScheme
*GetColourScheme();
531 wxGTKRenderer
*m_renderer
;
533 wxGTKArtProvider
*m_artProvider
;
535 // the names of the already created handlers and the handlers themselves
536 // (these arrays are synchronized)
537 wxSortedArrayString m_handlerNames
;
538 wxArrayHandlers m_handlers
;
540 wxGTKColourScheme
*m_scheme
;
542 WX_DECLARE_THEME(gtk
)
545 // ============================================================================
547 // ============================================================================
549 WX_IMPLEMENT_THEME(wxGTKTheme
, gtk
, wxTRANSLATE("GTK+ theme"));
551 // ----------------------------------------------------------------------------
553 // ----------------------------------------------------------------------------
555 wxGTKTheme::wxGTKTheme()
559 m_artProvider
= NULL
;
562 wxGTKTheme::~wxGTKTheme()
566 delete m_artProvider
;
569 wxRenderer
*wxGTKTheme::GetRenderer()
573 m_renderer
= new wxGTKRenderer(GetColourScheme());
579 wxArtProvider
*wxGTKTheme::GetArtProvider()
581 if ( !m_artProvider
)
583 m_artProvider
= new wxGTKArtProvider
;
586 return m_artProvider
;
589 wxColourScheme
*wxGTKTheme::GetColourScheme()
593 m_scheme
= new wxGTKColourScheme
;
598 wxInputHandler
*wxGTKTheme::GetInputHandler(const wxString
& control
,
599 wxInputConsumer
*consumer
)
601 wxInputHandler
*handler
= NULL
;
602 int n
= m_handlerNames
.Index(control
);
603 if ( n
== wxNOT_FOUND
)
605 static wxGTKInputHandler s_handlerDef
;
607 wxInputHandler
* const
608 handlerStd
= consumer
->DoGetStdInputHandler(&s_handlerDef
);
610 // create a new handler
612 if ( control
== wxINP_HANDLER_CHECKBOX
)
614 static wxGTKCheckboxInputHandler
s_handler(handlerStd
);
616 handler
= &s_handler
;
619 #endif // wxUSE_CHECKBOX
621 if ( control
== wxINP_HANDLER_SCROLLBAR
)
623 static wxGTKScrollBarInputHandler
s_handler(m_renderer
, handlerStd
);
625 handler
= &s_handler
;
628 #endif // wxUSE_SCROLLBAR
630 if ( control
== wxINP_HANDLER_TEXTCTRL
)
632 static wxGTKTextCtrlInputHandler
s_handler(handlerStd
);
634 handler
= &s_handler
;
637 #endif // wxUSE_TEXTCTRL
639 // no special handler for this control
640 handler
= handlerStd
;
643 n
= m_handlerNames
.Add(control
);
644 m_handlers
.Insert(handler
, n
);
646 else // we already have it
648 handler
= m_handlers
[n
];
654 // ============================================================================
656 // ============================================================================
658 wxColour
wxGTKColourScheme::GetBackground(wxWindow
*win
) const
661 if ( win
->UseBgCol() )
663 // use the user specified colour
664 col
= win
->GetBackgroundColour();
667 if ( !win
->ShouldInheritColours() )
669 // doesn't depend on the state
677 int flags
= win
->GetStateFlags();
679 // the colour set by the user should be used for the normal state
680 // and for the states for which we don't have any specific colours
681 if ( !col
.Ok() || (flags
!= 0) )
684 if ( wxDynamicCast(win
, wxScrollBar
) )
685 col
= Get(SCROLLBAR
);
687 #endif //wxUSE_SCROLLBAR
688 if ( (flags
& wxCONTROL_CURRENT
) && win
->CanBeHighlighted() )
689 col
= Get(CONTROL_CURRENT
);
690 else if ( flags
& wxCONTROL_PRESSED
)
691 col
= Get(CONTROL_PRESSED
);
700 wxColour
wxGTKColourScheme::Get(wxGTKColourScheme::StdColour col
) const
704 case WINDOW
: return *wxWHITE
;
706 case SHADOW_DARK
: return *wxBLACK
;
707 case SHADOW_HIGHLIGHT
: return *wxWHITE
;
708 case SHADOW_IN
: return wxColour(0xd6d6d6);
709 case SHADOW_OUT
: return wxColour(0x969696);
711 case CONTROL
: return wxColour(0xd6d6d6);
712 case CONTROL_PRESSED
: return wxColour(0xc3c3c3);
713 case CONTROL_CURRENT
: return wxColour(0xeaeaea);
715 case CONTROL_TEXT
: return *wxBLACK
;
716 case CONTROL_TEXT_DISABLED
:
717 return wxColour(0x757575);
718 case CONTROL_TEXT_DISABLED_SHADOW
:
722 case SCROLLBAR_PRESSED
: return wxColour(0xc3c3c3);
724 case HIGHLIGHT
: return wxColour(0x9c0000);
725 case HIGHLIGHT_TEXT
: return wxColour(0xffffff);
727 case GAUGE
: return Get(CONTROL_CURRENT
);
729 case TITLEBAR
: return wxColour(0xaeaaae);
730 case TITLEBAR_ACTIVE
: return wxColour(0x820300);
731 case TITLEBAR_TEXT
: return wxColour(0xc0c0c0);
732 case TITLEBAR_ACTIVE_TEXT
:
735 case DESKTOP
: return *wxBLACK
;
739 wxFAIL_MSG(_T("invalid standard colour"));
744 // ============================================================================
746 // ============================================================================
748 // ----------------------------------------------------------------------------
750 // ----------------------------------------------------------------------------
752 wxGTKRenderer::wxGTKRenderer(const wxColourScheme
*scheme
)
753 : wxStdRenderer(scheme
)
755 m_sizeScrollbarArrow
= wxSize(15, 14);
757 m_penGrey
= wxPen(wxSCHEME_COLOUR(scheme
, SCROLLBAR
));
760 // ----------------------------------------------------------------------------
762 // ----------------------------------------------------------------------------
764 void wxGTKRenderer::DrawAntiShadedRectSide(wxDC
& dc
,
770 dc
.SetPen(dir
== wxLEFT
|| dir
== wxUP
? pen1
: pen2
);
775 dc
.DrawLine(rect
.GetLeft(), rect
.GetTop(),
776 rect
.GetLeft(), rect
.GetBottom() + 1);
780 dc
.DrawLine(rect
.GetLeft(), rect
.GetTop(),
781 rect
.GetRight() + 1, rect
.GetTop());
785 dc
.DrawLine(rect
.GetRight(), rect
.GetTop(),
786 rect
.GetRight(), rect
.GetBottom() + 1);
790 dc
.DrawLine(rect
.GetLeft(), rect
.GetBottom(),
791 rect
.GetRight() + 1, rect
.GetBottom());
795 wxFAIL_MSG(_T("unknown rectangle side"));
799 void wxGTKRenderer::DrawAntiShadedRect(wxDC
& dc
, wxRect
*rect
,
800 const wxPen
& pen1
, const wxPen
& pen2
)
802 // draw the rectangle
804 dc
.DrawLine(rect
->GetLeft(), rect
->GetTop(),
805 rect
->GetLeft(), rect
->GetBottom() + 1);
806 dc
.DrawLine(rect
->GetLeft() + 1, rect
->GetTop(),
807 rect
->GetRight() + 1, rect
->GetTop());
809 dc
.DrawLine(rect
->GetRight(), rect
->GetTop() + 1,
810 rect
->GetRight(), rect
->GetBottom());
811 dc
.DrawLine(rect
->GetLeft() + 1, rect
->GetBottom(),
812 rect
->GetRight() + 1, rect
->GetBottom());
818 void wxGTKRenderer::DrawInnerShadedRect(wxDC
& dc
, wxRect
*rect
)
820 DrawAntiShadedRect(dc
, rect
, m_penDarkGrey
, m_penHighlight
);
821 DrawAntiShadedRect(dc
, rect
, m_penBlack
, m_penHighlight
);
824 void wxGTKRenderer::DrawAntiRaisedBorder(wxDC
& dc
, wxRect
*rect
)
826 DrawShadedRect(dc
, rect
, m_penHighlight
, m_penBlack
);
827 DrawAntiShadedRect(dc
, rect
, m_penLightGrey
, m_penDarkGrey
);
830 void wxGTKRenderer::DrawSunkenBorder(wxDC
& dc
, wxRect
*rect
)
832 DrawAntiShadedRect(dc
, rect
, m_penDarkGrey
, m_penHighlight
);
833 DrawShadedRect(dc
, rect
, m_penBlack
, m_penLightGrey
);
836 void wxGTKRenderer::DrawFocusRect(wxDC
& dc
, const wxRect
& rect
)
838 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
839 wxRect rectFocus
= rect
;
840 DrawRect(dc
, &rectFocus
, m_penBlack
);
843 void wxGTKRenderer::DrawTextBorder(wxDC
& dc
,
845 const wxRect
& rectOrig
,
849 wxRect rect
= rectOrig
;
851 if ( border
!= wxBORDER_NONE
)
853 if ( flags
& wxCONTROL_FOCUSED
)
855 DrawRect(dc
, &rect
, m_penBlack
);
856 DrawAntiShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
860 DrawInnerShadedRect(dc
, &rect
);
868 void wxGTKRenderer::DrawButtonLabel(wxDC
& dc
,
869 const wxString
& label
,
870 const wxBitmap
& image
,
877 // no focus rect around buttons label in GTK+
878 wxStdRenderer::DrawButtonLabel(dc
, label
, image
, rect
, flags
,
879 alignment
, indexAccel
, rectBounds
);
882 void wxGTKRenderer::DrawButtonBorder(wxDC
& dc
,
883 const wxRect
& rectTotal
,
887 wxRect rect
= rectTotal
;
889 if ( flags
& wxCONTROL_PRESSED
)
891 // button pressed: draw a black border around it and an inward shade
892 DrawRect(dc
, &rect
, m_penBlack
);
894 DrawInnerShadedRect(dc
, &rect
);
896 else // button not pressed
898 if ( flags
& wxCONTROL_ISDEFAULT
)
903 if ( flags
& wxCONTROL_FOCUSED
)
905 // button is currently default: add an extra border around it
906 DrawRect(dc
, &rect
, m_penBlack
);
909 // now draw a normal button
910 DrawShadedRect(dc
, &rect
, m_penHighlight
, m_penBlack
);
911 DrawAntiShadedRect(dc
, &rect
, GetBackgroundColour(flags
), m_penDarkGrey
);
918 // ----------------------------------------------------------------------------
920 // ----------------------------------------------------------------------------
922 void wxGTKRenderer::DrawFrameWithLabel(wxDC
& dc
,
923 const wxString
& label
,
924 const wxRect
& rectFrame
,
925 const wxRect
& rectTextOrig
,
930 wxRect
rectText(rectTextOrig
);
931 rectText
.Inflate(1, 0);
934 DrawLabel(dc
, label
, rectText
, flags
, alignment
, indexAccel
, &rectLabel
);
936 rectLabel
.width
+= 2;
938 DrawFrameWithoutLabel(dc
, rectFrame
, rectLabel
);
940 // GTK+ does it like this
941 dc
.SetPen(m_penHighlight
);
942 dc
.DrawPoint(rectText
.x
, rectFrame
.y
);
943 dc
.DrawPoint(rectText
.x
+ rectLabel
.width
- 3, rectFrame
.y
);
946 // ----------------------------------------------------------------------------
947 // check/radion buttons
948 // ----------------------------------------------------------------------------
950 void wxGTKRenderer::DrawCheckItemBitmap(wxDC
& dc
,
951 const wxBitmap
& bitmap
,
955 // never draw the focus rect around the check indicators here
956 DrawCheckButton(dc
, wxEmptyString
, bitmap
, rect
, flags
& ~wxCONTROL_FOCUSED
);
959 void wxGTKRenderer::DrawUndeterminedBitmap(wxDC
& dc
,
960 const wxRect
& rectTotal
,
963 // FIXME: For sure it is not GTK look but it is better than nothing.
964 // Show me correct look and I will immediatelly make it better (ABX)
965 wxRect rect
= rectTotal
;
971 col1
= wxSCHEME_COLOUR(m_scheme
, SHADOW_DARK
);
972 col2
= wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
);
976 col1
= wxSCHEME_COLOUR(m_scheme
, SHADOW_DARK
);
977 col2
= wxSCHEME_COLOUR(m_scheme
, SHADOW_IN
);
980 dc
.SetPen(*wxTRANSPARENT_PEN
);
982 dc
.DrawRectangle(rect
);
985 dc
.DrawRectangle(rect
);
988 void wxGTKRenderer::DrawUncheckBitmap(wxDC
& dc
,
989 const wxRect
& rectTotal
,
992 wxRect rect
= rectTotal
;
993 DrawAntiRaisedBorder(dc
, &rect
);
995 wxColour col
= wxSCHEME_COLOUR(m_scheme
, SHADOW_IN
);
996 dc
.SetPen(wxPen(col
));
997 dc
.DrawPoint(rect
.GetRight() - 1, rect
.GetBottom() - 1);
1000 col
= wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
);
1001 //else: it is SHADOW_IN, leave as is
1003 dc
.SetPen(*wxTRANSPARENT_PEN
);
1005 dc
.DrawRectangle(rect
);
1008 void wxGTKRenderer::DrawCheckBitmap(wxDC
& dc
, const wxRect
& rectTotal
)
1010 wxRect rect
= rectTotal
;
1011 DrawAntiShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
1012 DrawShadedRect(dc
, &rect
, m_penBlack
, m_penLightGrey
);
1014 dc
.SetPen(*wxTRANSPARENT_PEN
);
1015 dc
.SetBrush(wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
));
1016 dc
.DrawRectangle(rect
);
1019 void wxGTKRenderer::DrawRadioBitmap(wxDC
& dc
,
1025 xRight
= rect
.GetRight(),
1026 yBottom
= rect
.GetBottom();
1028 wxCoord yMid
= (y
+ yBottom
) / 2;
1030 // then draw the upper half
1031 dc
.SetPen(flags
& wxCONTROL_CHECKED
? m_penDarkGrey
: m_penHighlight
);
1032 DrawUpZag(dc
, x
, xRight
, yMid
, y
);
1033 DrawUpZag(dc
, x
+ 1, xRight
- 1, yMid
, y
+ 1);
1036 if ( flags
& wxCONTROL_CHECKED
)
1037 dc
.SetPen(m_penBlack
);
1038 else if ( flags
& wxCONTROL_PRESSED
)
1039 dc
.SetPen(wxPen(wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
)));
1040 else // unchecked and unpressed
1044 DrawUpZag(dc
, x
+ 2, xRight
- 2, yMid
, y
+ 2);
1046 // and then the lower one
1047 dc
.SetPen(flags
& wxCONTROL_CHECKED
? m_penHighlight
: m_penBlack
);
1048 DrawDownZag(dc
, x
, xRight
, yMid
, yBottom
);
1049 if ( !(flags
& wxCONTROL_CHECKED
) )
1050 dc
.SetPen(m_penDarkGrey
);
1051 DrawDownZag(dc
, x
+ 1, xRight
- 1, yMid
, yBottom
- 1);
1053 if ( !(flags
& wxCONTROL_CHECKED
) )
1054 drawIt
= true; // with the same pen
1055 else if ( flags
& wxCONTROL_PRESSED
)
1057 dc
.SetPen(wxPen(wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
)));
1060 else // checked and unpressed
1064 DrawDownZag(dc
, x
+ 2, xRight
- 2, yMid
, yBottom
- 2);
1067 void wxGTKRenderer::DrawUpZag(wxDC
& dc
,
1073 wxCoord xMid
= (x1
+ x2
) / 2;
1074 dc
.DrawLine(x1
, y1
, xMid
, y2
);
1075 dc
.DrawLine(xMid
, y2
, x2
+ 1, y1
+ 1);
1078 void wxGTKRenderer::DrawDownZag(wxDC
& dc
,
1084 wxCoord xMid
= (x1
+ x2
) / 2;
1085 dc
.DrawLine(x1
+ 1, y1
+ 1, xMid
, y2
);
1086 dc
.DrawLine(xMid
, y2
, x2
, y1
);
1089 wxBitmap
wxGTKRenderer::GetCheckBitmap(int flags
)
1091 if ( !m_bitmapsCheckbox
[0][0].Ok() )
1093 // init the bitmaps once only
1095 wxSize size
= GetCheckBitmapSize();
1096 rect
.width
= size
.x
;
1097 rect
.height
= size
.y
;
1098 for ( int i
= 0; i
< 2; i
++ )
1100 for ( int j
= 0; j
< 3; j
++ )
1101 m_bitmapsCheckbox
[i
][j
].Create(rect
.width
, rect
.height
);
1107 dc
.SelectObject(m_bitmapsCheckbox
[0][0]);
1108 DrawCheckBitmap(dc
, rect
);
1111 dc
.SelectObject(m_bitmapsCheckbox
[0][1]);
1112 DrawUncheckBitmap(dc
, rect
, false);
1114 // normal undeterminated
1115 dc
.SelectObject(m_bitmapsCheckbox
[0][2]);
1116 DrawUndeterminedBitmap(dc
, rect
, false);
1119 m_bitmapsCheckbox
[1][0] = m_bitmapsCheckbox
[0][0];
1121 // pressed unchecked
1122 dc
.SelectObject(m_bitmapsCheckbox
[1][1]);
1123 DrawUncheckBitmap(dc
, rect
, true);
1125 // pressed undeterminated
1126 dc
.SelectObject(m_bitmapsCheckbox
[1][2]);
1127 DrawUndeterminedBitmap(dc
, rect
, true);
1130 IndicatorState state
;
1131 IndicatorStatus status
;
1132 GetIndicatorsFromFlags(flags
, state
, status
);
1134 // disabled looks the same as normal
1135 if ( state
== IndicatorState_Disabled
)
1136 state
= IndicatorState_Normal
;
1138 return m_bitmapsCheckbox
[state
][status
];
1141 wxBitmap
wxGTKRenderer::GetRadioBitmap(int flags
)
1143 IndicatorState state
;
1144 IndicatorStatus status
;
1145 GetIndicatorsFromFlags(flags
, state
, status
);
1147 wxBitmap
& bmp
= m_bitmapsRadiobtn
[state
][status
];
1150 const wxSize size
= GetRadioBitmapSize();
1153 bmp
.Create(size
.x
, size
.y
);
1154 dc
.SelectObject(bmp
);
1156 DrawRadioBitmap(dc
, size
, flags
);
1162 wxBitmap
wxGTKRenderer::GetLineWrapBitmap() const
1164 if ( !m_bmpLineWrap
.Ok() )
1166 // the line wrap bitmap as used by GTK+
1167 #define line_wrap_width 6
1168 #define line_wrap_height 9
1169 static const char line_wrap_bits
[] =
1171 0x1e, 0x3e, 0x30, 0x30, 0x39, 0x1f, 0x0f, 0x0f, 0x1f,
1174 wxBitmap
bmpLineWrap(line_wrap_bits
, line_wrap_width
, line_wrap_height
);
1175 if ( !bmpLineWrap
.Ok() )
1177 wxFAIL_MSG( _T("Failed to create line wrap XBM") );
1181 wxConstCast(this, wxGTKRenderer
)->m_bmpLineWrap
= bmpLineWrap
;
1185 return m_bmpLineWrap
;
1189 void wxGTKRenderer::DrawToolBarButton(wxDC
& dc
,
1190 const wxString
& label
,
1191 const wxBitmap
& bitmap
,
1192 const wxRect
& rectOrig
,
1194 long WXUNUSED(style
),
1197 // we don't draw the separators at all
1198 if ( !label
.empty() || bitmap
.Ok() )
1200 wxRect rect
= rectOrig
;
1201 rect
.Deflate(BORDER_THICKNESS
);
1203 if ( flags
& wxCONTROL_PRESSED
)
1205 DrawBorder(dc
, wxBORDER_SUNKEN
, rect
, flags
, &rect
);
1207 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
), rect
);
1209 else if ( flags
& wxCONTROL_CURRENT
)
1211 DrawBorder(dc
, wxBORDER_RAISED
, rect
, flags
, &rect
);
1213 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL_CURRENT
), rect
);
1216 if(tbarStyle
& wxTB_TEXT
)
1218 if(tbarStyle
& wxTB_HORIZONTAL
)
1220 dc
.DrawLabel(label
, bitmap
, rect
, wxALIGN_CENTRE
);
1224 dc
.DrawLabel(label
, bitmap
, rect
, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
);
1229 int xpoint
= (rect
.GetLeft() + rect
.GetRight() + 1 - bitmap
.GetWidth()) / 2;
1230 int ypoint
= (rect
.GetTop() + rect
.GetBottom() + 1 - bitmap
.GetHeight()) / 2;
1231 dc
.DrawBitmap(bitmap
, xpoint
, ypoint
);
1235 #endif // wxUSE_TOOLBAR
1237 // ----------------------------------------------------------------------------
1239 // ----------------------------------------------------------------------------
1243 wxRect
wxGTKRenderer::GetTextClientArea(const wxTextCtrl
*text
,
1245 wxCoord
*extraSpaceBeyond
) const
1248 rectText
= wxStdRenderer::GetTextClientArea(text
, rect
, extraSpaceBeyond
);
1250 if ( text
->WrapLines() )
1252 // leave enough for the line wrap bitmap indicator
1253 wxCoord widthMark
= GetLineWrapBitmap().GetWidth() + 2;
1255 rectText
.width
-= widthMark
;
1257 if ( extraSpaceBeyond
)
1258 *extraSpaceBeyond
= widthMark
;
1264 void wxGTKRenderer::DrawLineWrapMark(wxDC
& dc
, const wxRect
& rect
)
1266 wxBitmap bmpLineWrap
= GetLineWrapBitmap();
1268 // for a mono bitmap he colours it appears in depends on the current text
1269 // colours, so set them correctly
1271 if ( bmpLineWrap
.GetDepth() == 1 )
1273 colFgOld
= dc
.GetTextForeground();
1275 // FIXME: I wonder what should we do if the background is black too?
1276 dc
.SetTextForeground(*wxBLACK
);
1279 dc
.DrawBitmap(bmpLineWrap
,
1280 rect
.x
, rect
.y
+ (rect
.height
- bmpLineWrap
.GetHeight())/2);
1282 if ( colFgOld
.Ok() )
1284 // restore old colour
1285 dc
.SetTextForeground(colFgOld
);
1289 #endif // wxUSE_TEXTCTRL
1291 // ----------------------------------------------------------------------------
1293 // ----------------------------------------------------------------------------
1297 void wxGTKRenderer::DrawTab(wxDC
& dc
,
1298 const wxRect
& rectOrig
,
1300 const wxString
& label
,
1301 const wxBitmap
& bitmap
,
1305 #define SELECT_FOR_VERTICAL(X,Y) ( isVertical ? Y : X )
1306 #define REVERSE_FOR_VERTICAL(X,Y) \
1307 SELECT_FOR_VERTICAL(X,Y) \
1309 SELECT_FOR_VERTICAL(Y,X)
1311 wxRect rect
= rectOrig
;
1313 bool isVertical
= ( dir
== wxLEFT
) || ( dir
== wxRIGHT
);
1315 // the current tab is drawn indented (to the top for default case) and
1316 // bigger than the other ones
1317 const wxSize indent
= GetTabIndent();
1318 if ( flags
& wxCONTROL_SELECTED
)
1320 rect
.Inflate( SELECT_FOR_VERTICAL( indent
.x
, 0),
1321 SELECT_FOR_VERTICAL( 0, indent
.y
));
1325 wxFAIL_MSG(_T("invaild notebook tab orientation"));
1332 rect
.height
+= indent
.y
;
1339 rect
.width
+= indent
.x
;
1344 // selected tab has different colour
1345 wxColour col
= flags
& wxCONTROL_SELECTED
1346 ? wxSCHEME_COLOUR(m_scheme
, SHADOW_IN
)
1347 : wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
);
1348 DrawSolidRect(dc
, col
, rect
);
1350 if ( flags
& wxCONTROL_FOCUSED
)
1352 // draw the focus rect
1353 wxRect rectBorder
= rect
;
1354 rectBorder
.Deflate(4, 3);
1355 if ( dir
== wxBOTTOM
)
1356 rectBorder
.Offset(0, -1);
1357 if ( dir
== wxRIGHT
)
1358 rectBorder
.Offset(-1, 0);
1360 DrawRect(dc
, &rectBorder
, m_penBlack
);
1363 // draw the text, image and the focus around them (if necessary)
1364 wxRect
rectLabel( REVERSE_FOR_VERTICAL(rect
.x
,rect
.y
),
1365 REVERSE_FOR_VERTICAL(rect
.width
,rect
.height
)
1367 rectLabel
.Deflate(1, 1);
1370 // draw it horizontally into memory and rotate for screen
1372 wxBitmap bitmapRotated
,
1373 bitmapMem( rectLabel
.x
+ rectLabel
.width
,
1374 rectLabel
.y
+ rectLabel
.height
);
1375 dcMem
.SelectObject(bitmapMem
);
1376 dcMem
.SetBackground(dc
.GetBackground());
1377 dcMem
.SetFont(dc
.GetFont());
1378 dcMem
.SetTextForeground(dc
.GetTextForeground());
1382 wxBitmap( wxImage( bitmap
.ConvertToImage() ).Rotate90(dir
==wxLEFT
) )
1385 #endif // wxUSE_IMAGE
1387 dcMem
.DrawLabel(label
, bitmapRotated
, rectLabel
, wxALIGN_CENTRE
, indexAccel
);
1388 dcMem
.SelectObject(wxNullBitmap
);
1389 bitmapMem
= bitmapMem
.GetSubBitmap(rectLabel
);
1391 bitmapMem
= wxBitmap(wxImage(bitmapMem
.ConvertToImage()).Rotate90(dir
==wxRIGHT
))
1395 dc
.DrawBitmap(bitmapMem
, rectLabel
.y
, rectLabel
.x
, false);
1399 dc
.DrawLabel(label
, bitmap
, rectLabel
, wxALIGN_CENTRE
, indexAccel
);
1402 // now draw the tab itself
1403 wxCoord x
= SELECT_FOR_VERTICAL(rect
.x
,rect
.y
),
1404 y
= SELECT_FOR_VERTICAL(rect
.y
,rect
.x
),
1405 x2
= SELECT_FOR_VERTICAL(rect
.GetRight(),rect
.GetBottom()),
1406 y2
= SELECT_FOR_VERTICAL(rect
.GetBottom(),rect
.GetRight());
1412 // left orientation looks like top but IsVertical makes x and y reversed
1414 // top is not vertical so use coordinates in written order
1415 dc
.SetPen(m_penHighlight
);
1416 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y2
),
1417 REVERSE_FOR_VERTICAL(x
, y
));
1418 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
),
1419 REVERSE_FOR_VERTICAL(x2
, y
));
1421 dc
.SetPen(m_penBlack
);
1422 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y2
),
1423 REVERSE_FOR_VERTICAL(x2
, y
));
1425 dc
.SetPen(m_penDarkGrey
);
1426 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
- 1, y2
),
1427 REVERSE_FOR_VERTICAL(x2
- 1, y
+ 1));
1429 if ( flags
& wxCONTROL_SELECTED
)
1431 dc
.SetPen(m_penLightGrey
);
1433 // overwrite the part of the border below this tab
1434 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
+ 1),
1435 REVERSE_FOR_VERTICAL(x2
- 1, y2
+ 1));
1437 // and the shadow of the tab to the left of us
1438 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
+ 2),
1439 REVERSE_FOR_VERTICAL(x
+ 1, y2
+ 1));
1444 // right orientation looks like bottom but IsVertical makes x and y reversed
1446 // bottom is not vertical so use coordinates in written order
1447 dc
.SetPen(m_penHighlight
);
1449 // we need to continue one pixel further to overwrite the corner of
1450 // the border for the selected tab
1451 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y
- (flags
& wxCONTROL_SELECTED
? 1 : 0)),
1452 REVERSE_FOR_VERTICAL(x
, y2
));
1454 // it doesn't work like this (TODO: implement it properly)
1456 // erase the corner of the tab to the right
1457 dc
.SetPen(m_penLightGrey
);
1458 dc
.DrawPoint(REVERSE_FOR_VERTICAL(x2
- 1, y
- 2));
1459 dc
.DrawPoint(REVERSE_FOR_VERTICAL(x2
- 2, y
- 2));
1460 dc
.DrawPoint(REVERSE_FOR_VERTICAL(x2
- 2, y
- 1));
1463 dc
.SetPen(m_penBlack
);
1464 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
),
1465 REVERSE_FOR_VERTICAL(x2
, y2
));
1466 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y
),
1467 REVERSE_FOR_VERTICAL(x2
, y2
));
1469 dc
.SetPen(m_penDarkGrey
);
1470 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 2, y2
- 1),
1471 REVERSE_FOR_VERTICAL(x2
- 1, y2
- 1));
1472 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
- 1, y
),
1473 REVERSE_FOR_VERTICAL(x2
- 1, y2
));
1475 if ( flags
& wxCONTROL_SELECTED
)
1477 dc
.SetPen(m_penLightGrey
);
1479 // overwrite the part of the (double!) border above this tab
1480 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
- 1),
1481 REVERSE_FOR_VERTICAL(x2
- 1, y
- 1));
1482 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
- 2),
1483 REVERSE_FOR_VERTICAL(x2
- 1, y
- 2));
1485 // and the shadow of the tab to the left of us
1486 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
- 1),
1487 REVERSE_FOR_VERTICAL(x
+ 1, y
- 1));
1493 #endif // wxUSE_NOTEBOOK
1495 // ----------------------------------------------------------------------------
1497 // ----------------------------------------------------------------------------
1501 wxSize
wxGTKRenderer::GetSliderThumbSize(const wxRect
& rect
,
1503 wxOrientation orient
) const
1505 static const wxCoord SLIDER_THUMB_LENGTH
= 30;
1509 wxRect rectShaft
= GetSliderShaftRect(rect
, lenThumb
, orient
);
1510 if ( orient
== wxHORIZONTAL
)
1512 size
.x
= wxMin(SLIDER_THUMB_LENGTH
, rectShaft
.width
);
1513 size
.y
= rectShaft
.height
;
1517 size
.y
= wxMin(SLIDER_THUMB_LENGTH
, rectShaft
.height
);
1518 size
.x
= rectShaft
.width
;
1524 wxRect
wxGTKRenderer::GetSliderShaftRect(const wxRect
& rect
,
1525 int WXUNUSED(lenThumb
),
1526 wxOrientation
WXUNUSED(orient
),
1527 long WXUNUSED(style
)) const
1529 return rect
.Deflate(2*BORDER_THICKNESS
, 2*BORDER_THICKNESS
);
1532 void wxGTKRenderer::DrawSliderShaft(wxDC
& dc
,
1533 const wxRect
& rectOrig
,
1534 int WXUNUSED(lenThumb
),
1535 wxOrientation
WXUNUSED(orient
),
1537 long WXUNUSED(style
),
1540 wxRect rect
= rectOrig
;
1542 // draw the border first
1543 if ( flags
& wxCONTROL_FOCUSED
)
1545 DrawRect(dc
, &rect
, m_penBlack
);
1547 else // not focused, normal
1549 DrawAntiShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
1552 DrawAntiShadedRect(dc
, &rect
, m_penBlack
, m_penLightGrey
);
1554 // and the background
1555 DrawSolidRect(dc
, wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
), rect
);
1561 void wxGTKRenderer::DrawSliderThumb(wxDC
& dc
,
1562 const wxRect
& rectOrig
,
1563 wxOrientation orient
,
1564 int WXUNUSED(flags
),
1565 long WXUNUSED(style
))
1567 // draw the thumb border
1568 wxRect rect
= rectOrig
;
1569 DrawAntiRaisedBorder(dc
, &rect
);
1571 // draw the handle in the middle
1572 if ( orient
== wxVERTICAL
)
1574 rect
.height
= 2*BORDER_THICKNESS
;
1575 rect
.y
= rectOrig
.y
+ (rectOrig
.height
- rect
.height
) / 2;
1579 rect
.width
= 2*BORDER_THICKNESS
;
1580 rect
.x
= rectOrig
.x
+ (rectOrig
.width
- rect
.width
) / 2;
1583 DrawShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
1586 #endif // wxUSE_SLIDER
1590 // ----------------------------------------------------------------------------
1592 // ----------------------------------------------------------------------------
1594 // wxGTKMenuGeometryInfo: the wxMenuGeometryInfo used by wxGTKRenderer
1595 class WXDLLEXPORT wxGTKMenuGeometryInfo
: public wxMenuGeometryInfo
1598 virtual wxSize
GetSize() const { return m_size
; }
1600 wxCoord
GetLabelOffset() const { return m_ofsLabel
; }
1601 wxCoord
GetAccelOffset() const { return m_ofsAccel
; }
1603 wxCoord
GetItemHeight() const { return m_heightItem
; }
1606 // the total size of the menu
1609 // the offset of the start of the menu item label
1612 // the offset of the start of the accel label
1615 // the height of a normal (not separator) item
1616 wxCoord m_heightItem
;
1618 friend wxMenuGeometryInfo
*
1619 wxGTKRenderer::GetMenuGeometry(wxWindow
*, const wxMenu
&) const;
1622 // FIXME: all constants are hardcoded but shouldn't be
1623 static const wxCoord MENU_LEFT_MARGIN
= 9;
1624 static const wxCoord MENU_RIGHT_MARGIN
= 6;
1626 static const wxCoord MENU_HORZ_MARGIN
= 6;
1627 static const wxCoord MENU_VERT_MARGIN
= 3;
1629 // the margin around bitmap/check marks (on each side)
1630 static const wxCoord MENU_BMP_MARGIN
= 2;
1632 // the margin between the labels and accel strings
1633 static const wxCoord MENU_ACCEL_MARGIN
= 8;
1635 // the separator height in pixels: in fact, strangely enough, the real height
1636 // is 2 but Windows adds one extra pixel in the bottom margin, so take it into
1638 static const wxCoord MENU_SEPARATOR_HEIGHT
= 3;
1640 // the size of the standard checkmark bitmap
1641 static const wxCoord MENU_CHECK_SIZE
= 9;
1643 void wxGTKRenderer::DrawMenuBarItem(wxDC
& dc
,
1645 const wxString
& label
,
1649 DoDrawMenuItem(dc
, rect
, label
, flags
, indexAccel
);
1652 void wxGTKRenderer::DrawMenuItem(wxDC
& dc
,
1654 const wxMenuGeometryInfo
& gi
,
1655 const wxString
& label
,
1656 const wxString
& accel
,
1657 const wxBitmap
& bitmap
,
1661 const wxGTKMenuGeometryInfo
& geomInfo
= (const wxGTKMenuGeometryInfo
&)gi
;
1666 rect
.width
= geomInfo
.GetSize().x
;
1667 rect
.height
= geomInfo
.GetItemHeight();
1669 DoDrawMenuItem(dc
, rect
, label
, flags
, indexAccel
, accel
, bitmap
, &geomInfo
);
1672 void wxGTKRenderer::DoDrawMenuItem(wxDC
& dc
,
1673 const wxRect
& rectOrig
,
1674 const wxString
& label
,
1677 const wxString
& accel
,
1678 const wxBitmap
& bitmap
,
1679 const wxGTKMenuGeometryInfo
*geometryInfo
)
1681 wxRect rect
= rectOrig
;
1683 // draw the selected item specially
1684 if ( flags
& wxCONTROL_SELECTED
)
1687 DrawBorder(dc
, wxBORDER_RAISED
, rect
, flags
, &rectIn
);
1689 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL_CURRENT
), rectIn
);
1692 rect
.Deflate(MENU_HORZ_MARGIN
, MENU_VERT_MARGIN
);
1694 // draw the bitmap: use the bitmap provided or the standard checkmark for
1695 // the checkable items
1698 wxBitmap bmp
= bitmap
;
1699 if ( !bmp
.Ok() && (flags
& wxCONTROL_CHECKABLE
) )
1701 bmp
= GetCheckBitmap(flags
);
1706 rect
.SetRight(geometryInfo
->GetLabelOffset());
1707 wxControlRenderer::DrawBitmap(dc
, bmp
, rect
);
1710 //else: menubar items don't have bitmaps
1715 rect
.x
= geometryInfo
->GetLabelOffset();
1716 rect
.SetRight(geometryInfo
->GetAccelOffset());
1719 DrawLabel(dc
, label
, rect
, flags
, wxALIGN_CENTRE_VERTICAL
, indexAccel
);
1721 // draw the accel string
1722 if ( !accel
.empty() )
1724 // menubar items shouldn't have them
1725 wxCHECK_RET( geometryInfo
, _T("accel strings only valid for menus") );
1727 rect
.x
= geometryInfo
->GetAccelOffset();
1728 rect
.SetRight(geometryInfo
->GetSize().x
);
1730 // NB: no accel index here
1731 DrawLabel(dc
, accel
, rect
, flags
, wxALIGN_CENTRE_VERTICAL
);
1734 // draw the submenu indicator
1735 if ( flags
& wxCONTROL_ISSUBMENU
)
1737 wxCHECK_RET( geometryInfo
, _T("wxCONTROL_ISSUBMENU only valid for menus") );
1739 rect
.x
= geometryInfo
->GetSize().x
- MENU_RIGHT_MARGIN
;
1740 rect
.width
= MENU_RIGHT_MARGIN
;
1742 DrawArrow(dc
, wxRIGHT
, rect
, flags
);
1746 void wxGTKRenderer::DrawMenuSeparator(wxDC
& dc
,
1748 const wxMenuGeometryInfo
& geomInfo
)
1750 DrawHorizontalLine(dc
, y
+ MENU_VERT_MARGIN
, 0, geomInfo
.GetSize().x
);
1753 wxSize
wxGTKRenderer::GetMenuBarItemSize(const wxSize
& sizeText
) const
1755 wxSize size
= sizeText
;
1757 // TODO: make this configurable
1758 size
.x
+= 2*MENU_HORZ_MARGIN
;
1759 size
.y
+= 2*MENU_VERT_MARGIN
;
1764 wxMenuGeometryInfo
*wxGTKRenderer::GetMenuGeometry(wxWindow
*win
,
1765 const wxMenu
& menu
) const
1767 // prepare the dc: for now we draw all the items with the system font
1769 dc
.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
1771 // the height of a normal item
1772 wxCoord heightText
= dc
.GetCharHeight();
1777 // the max length of label and accel strings: the menu width is the sum of
1778 // them, even if they're for different items (as the accels should be
1781 // the max length of the bitmap is never 0 as Windows always leaves enough
1782 // space for a check mark indicator
1783 wxCoord widthLabelMax
= 0,
1785 widthBmpMax
= MENU_LEFT_MARGIN
;
1787 for ( wxMenuItemList::compatibility_iterator node
= menu
.GetMenuItems().GetFirst();
1789 node
= node
->GetNext() )
1791 // height of this item
1794 wxMenuItem
*item
= node
->GetData();
1795 if ( item
->IsSeparator() )
1797 h
= MENU_SEPARATOR_HEIGHT
;
1799 else // not separator
1804 dc
.GetTextExtent(item
->GetLabel(), &widthLabel
, NULL
);
1805 if ( widthLabel
> widthLabelMax
)
1807 widthLabelMax
= widthLabel
;
1811 dc
.GetTextExtent(item
->GetAccelString(), &widthAccel
, NULL
);
1812 if ( widthAccel
> widthAccelMax
)
1814 widthAccelMax
= widthAccel
;
1817 const wxBitmap
& bmp
= item
->GetBitmap();
1820 wxCoord widthBmp
= bmp
.GetWidth();
1821 if ( widthBmp
> widthBmpMax
)
1822 widthBmpMax
= widthBmp
;
1824 //else if ( item->IsCheckable() ): no need to check for this as
1825 // MENU_LEFT_MARGIN is big enough to show the check mark
1828 h
+= 2*MENU_VERT_MARGIN
;
1830 // remember the item position and height
1831 item
->SetGeometry(height
, h
);
1836 // bundle the metrics into a struct and return it
1837 wxGTKMenuGeometryInfo
*gi
= new wxGTKMenuGeometryInfo
;
1839 gi
->m_ofsLabel
= widthBmpMax
+ 2*MENU_BMP_MARGIN
;
1840 gi
->m_ofsAccel
= gi
->m_ofsLabel
+ widthLabelMax
;
1841 if ( widthAccelMax
> 0 )
1843 // if we actually have any accesl, add a margin
1844 gi
->m_ofsAccel
+= MENU_ACCEL_MARGIN
;
1847 gi
->m_heightItem
= heightText
+ 2*MENU_VERT_MARGIN
;
1849 gi
->m_size
.x
= gi
->m_ofsAccel
+ widthAccelMax
+ MENU_RIGHT_MARGIN
;
1850 gi
->m_size
.y
= height
;
1855 #endif // wxUSE_MENUS
1857 // ----------------------------------------------------------------------------
1859 // ----------------------------------------------------------------------------
1861 void wxGTKRenderer::InitComboBitmaps()
1863 wxSize sizeArrow
= m_sizeScrollbarArrow
;
1869 for ( n
= ComboState_Normal
; n
< ComboState_Max
; n
++ )
1871 m_bitmapsCombo
[n
].Create(sizeArrow
.x
, sizeArrow
.y
);
1874 static const int comboButtonFlags
[ComboState_Max
] =
1882 wxRect
rect(sizeArrow
);
1885 for ( n
= ComboState_Normal
; n
< ComboState_Max
; n
++ )
1887 int flags
= comboButtonFlags
[n
];
1889 dc
.SelectObject(m_bitmapsCombo
[n
]);
1890 DrawSolidRect(dc
, GetBackgroundColour(flags
), rect
);
1891 DrawArrow(dc
, wxDOWN
, rect
, flags
);
1895 void wxGTKRenderer::GetComboBitmaps(wxBitmap
*bmpNormal
,
1897 wxBitmap
*bmpPressed
,
1898 wxBitmap
*bmpDisabled
)
1900 if ( !m_bitmapsCombo
[ComboState_Normal
].Ok() )
1906 *bmpNormal
= m_bitmapsCombo
[ComboState_Normal
];
1908 *bmpFocus
= m_bitmapsCombo
[ComboState_Focus
];
1910 *bmpPressed
= m_bitmapsCombo
[ComboState_Pressed
];
1912 *bmpDisabled
= m_bitmapsCombo
[ComboState_Disabled
];
1915 // ----------------------------------------------------------------------------
1917 // ----------------------------------------------------------------------------
1919 void wxGTKRenderer::DrawArrowBorder(wxDC
& dc
,
1923 static const wxDirection sides
[] =
1925 wxUP
, wxLEFT
, wxRIGHT
, wxDOWN
1928 wxRect rect1
, rect2
, rectInner
;
1934 rectInner
.Inflate(-2);
1936 DrawSolidRect(dc
, wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
), *rect
);
1938 // find the side not to draw and also adjust the rectangles to compensate
1940 wxDirection sideToOmit
;
1944 sideToOmit
= wxDOWN
;
1946 rectInner
.height
+= 1;
1954 rectInner
.height
+= 1;
1958 sideToOmit
= wxRIGHT
;
1960 rectInner
.width
+= 1;
1964 sideToOmit
= wxLEFT
;
1968 rectInner
.width
+= 1;
1972 wxFAIL_MSG(_T("unknown arrow direction"));
1976 // the outer rect first
1978 for ( n
= 0; n
< WXSIZEOF(sides
); n
++ )
1980 wxDirection side
= sides
[n
];
1981 if ( side
== sideToOmit
)
1984 DrawAntiShadedRectSide(dc
, rect1
, m_penDarkGrey
, m_penHighlight
, side
);
1987 // and then the inner one
1988 for ( n
= 0; n
< WXSIZEOF(sides
); n
++ )
1990 wxDirection side
= sides
[n
];
1991 if ( side
== sideToOmit
)
1994 DrawAntiShadedRectSide(dc
, rect2
, m_penBlack
, m_penGrey
, side
);
2000 void wxGTKRenderer::DrawScrollbarArrow(wxDC
& dc
,
2002 const wxRect
& rectArrow
,
2005 // first of all, draw the border around it - but we don't want the border
2006 // on the side opposite to the arrow point
2007 wxRect rect
= rectArrow
;
2008 DrawArrowBorder(dc
, &rect
, dir
);
2010 // then the arrow itself
2011 DrawArrow(dc
, dir
, rect
, flags
);
2014 // gtk_default_draw_arrow() takes ~350 lines and we can't do much better here
2015 // these people are just crazy :-(
2016 void wxGTKRenderer::DrawArrow(wxDC
& dc
,
2029 wxPoint ptArrow
[Point_Max
];
2031 wxColour colInside
= GetBackgroundColour(flags
);
2033 if ( flags
& wxCONTROL_DISABLED
)
2035 penShadow
[0] = m_penDarkGrey
;
2036 penShadow
[1] = m_penDarkGrey
;
2037 penShadow
[2] = wxNullPen
;
2038 penShadow
[3] = wxNullPen
;
2040 else if ( flags
& wxCONTROL_PRESSED
)
2042 penShadow
[0] = m_penDarkGrey
;
2043 penShadow
[1] = m_penHighlight
;
2044 penShadow
[2] = wxNullPen
;
2045 penShadow
[3] = m_penBlack
;
2047 else // normal arrow
2049 penShadow
[0] = m_penHighlight
;
2050 penShadow
[1] = m_penBlack
;
2051 penShadow
[2] = m_penDarkGrey
;
2052 penShadow
[3] = wxNullPen
;
2056 if ( dir
== wxUP
|| dir
== wxDOWN
)
2059 middle
= (rect
.GetRight() + rect
.GetLeft() + 1) / 2;
2063 middle
= (rect
.GetTop() + rect
.GetBottom() + 1) / 2;
2066 // draw the arrow interior
2067 dc
.SetPen(*wxTRANSPARENT_PEN
);
2068 dc
.SetBrush(colInside
);
2073 ptArrow
[Point_First
].x
= rect
.GetLeft();
2074 ptArrow
[Point_First
].y
= rect
.GetBottom();
2075 ptArrow
[Point_Second
].x
= middle
;
2076 ptArrow
[Point_Second
].y
= rect
.GetTop();
2077 ptArrow
[Point_Third
].x
= rect
.GetRight();
2078 ptArrow
[Point_Third
].y
= rect
.GetBottom();
2082 ptArrow
[Point_First
] = rect
.GetPosition();
2083 ptArrow
[Point_Second
].x
= middle
;
2084 ptArrow
[Point_Second
].y
= rect
.GetBottom();
2085 ptArrow
[Point_Third
].x
= rect
.GetRight();
2086 ptArrow
[Point_Third
].y
= rect
.GetTop();
2090 ptArrow
[Point_First
].x
= rect
.GetRight();
2091 ptArrow
[Point_First
].y
= rect
.GetTop();
2092 ptArrow
[Point_Second
].x
= rect
.GetLeft();
2093 ptArrow
[Point_Second
].y
= middle
;
2094 ptArrow
[Point_Third
].x
= rect
.GetRight();
2095 ptArrow
[Point_Third
].y
= rect
.GetBottom();
2099 ptArrow
[Point_First
] = rect
.GetPosition();
2100 ptArrow
[Point_Second
].x
= rect
.GetRight();
2101 ptArrow
[Point_Second
].y
= middle
;
2102 ptArrow
[Point_Third
].x
= rect
.GetLeft();
2103 ptArrow
[Point_Third
].y
= rect
.GetBottom();
2107 wxFAIL_MSG(_T("unknown arrow direction"));
2110 dc
.DrawPolygon(WXSIZEOF(ptArrow
), ptArrow
);
2112 // draw the arrow border
2113 dc
.SetPen(penShadow
[0]);
2117 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_First
]);
2118 dc
.DrawPoint(ptArrow
[Point_First
]);
2119 if ( penShadow
[3].Ok() )
2121 dc
.SetPen(penShadow
[3]);
2122 dc
.DrawLine(ptArrow
[Point_First
].x
+ 1, ptArrow
[Point_First
].y
,
2123 ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
);
2125 dc
.SetPen(penShadow
[1]);
2126 dc
.DrawLine(ptArrow
[Point_Second
].x
+ 1, ptArrow
[Point_Second
].y
+ 1,
2127 ptArrow
[Point_Third
].x
, ptArrow
[Point_Third
].y
);
2128 dc
.DrawPoint(ptArrow
[Point_Third
]);
2129 dc
.DrawLine(ptArrow
[Point_Third
].x
- 2, ptArrow
[Point_Third
].y
,
2130 ptArrow
[Point_First
].x
+ 1, ptArrow
[Point_First
].y
);
2131 if ( penShadow
[2].Ok() )
2133 dc
.SetPen(penShadow
[2]);
2134 dc
.DrawLine(ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
,
2135 ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
+ 1);
2136 dc
.DrawLine(ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
- 1,
2137 ptArrow
[Point_First
].x
+ 2, ptArrow
[Point_First
].y
- 1);
2142 dc
.DrawLine(ptArrow
[Point_First
], ptArrow
[Point_Second
]);
2143 dc
.DrawLine(ptArrow
[Point_First
].x
+ 2, ptArrow
[Point_First
].y
,
2144 ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
);
2145 if ( penShadow
[2].Ok() )
2147 dc
.SetPen(penShadow
[2]);
2148 dc
.DrawLine(ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
- 1,
2149 ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
- 1);
2151 dc
.SetPen(penShadow
[1]);
2152 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_Third
]);
2153 dc
.DrawPoint(ptArrow
[Point_Third
]);
2157 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_First
]);
2158 dc
.DrawPoint(ptArrow
[Point_First
]);
2159 if ( penShadow
[2].Ok() )
2161 dc
.SetPen(penShadow
[2]);
2162 dc
.DrawLine(ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
,
2163 ptArrow
[Point_First
].x
- 1, ptArrow
[Point_First
].y
+ 2);
2164 dc
.DrawLine(ptArrow
[Point_Third
].x
, ptArrow
[Point_Third
].y
,
2165 ptArrow
[Point_Second
].x
+ 2, ptArrow
[Point_Second
].y
+ 1);
2167 dc
.SetPen(penShadow
[1]);
2168 dc
.DrawLine(ptArrow
[Point_Third
].x
, ptArrow
[Point_Third
].y
,
2169 ptArrow
[Point_First
].x
, ptArrow
[Point_First
].y
+ 1);
2170 dc
.DrawLine(ptArrow
[Point_Second
].x
+ 1, ptArrow
[Point_Second
].y
+ 1,
2171 ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
);
2175 dc
.DrawLine(ptArrow
[Point_First
], ptArrow
[Point_Third
]);
2176 dc
.DrawLine(ptArrow
[Point_First
].x
+ 2, ptArrow
[Point_First
].y
+ 1,
2177 ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
);
2178 dc
.SetPen(penShadow
[1]);
2179 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_Third
]);
2180 dc
.DrawPoint(ptArrow
[Point_Third
]);
2184 wxFAIL_MSG(_T("unknown arrow direction"));
2189 void wxGTKRenderer::DrawThumbBorder(wxDC
& dc
,
2191 wxOrientation orient
)
2193 if ( orient
== wxVERTICAL
)
2195 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2197 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2199 rect
->Inflate(-1, 0);
2201 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2203 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2205 rect
->Inflate(-1, 0);
2209 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2211 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2213 rect
->Inflate(0, -1);
2215 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2217 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2219 rect
->Inflate(0, -1);
2223 void wxGTKRenderer::DrawScrollbarThumb(wxDC
& dc
,
2224 wxOrientation orient
,
2228 // the thumb is never pressed never has focus border under GTK and the
2229 // scrollbar background never changes at all
2230 int flagsThumb
= flags
& ~(wxCONTROL_PRESSED
| wxCONTROL_FOCUSED
);
2232 // we don't want the border in the direction of the scrollbar movement
2233 wxRect rectThumb
= rect
;
2234 DrawThumbBorder(dc
, &rectThumb
, orient
);
2236 DrawButtonBorder(dc
, rectThumb
, flagsThumb
, &rectThumb
);
2237 DrawBackground(dc
, wxNullColour
, rectThumb
, flagsThumb
);
2240 void wxGTKRenderer::DrawScrollbarShaft(wxDC
& dc
,
2241 wxOrientation orient
,
2243 int WXUNUSED(flags
))
2245 wxRect rectBar
= rect
;
2246 DrawThumbBorder(dc
, &rectBar
, orient
);
2247 DrawSolidRect(dc
, wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
), rectBar
);
2251 wxRect
wxGTKRenderer::GetScrollbarRect(const wxScrollBar
*scrollbar
,
2252 wxScrollBar::Element elem
,
2255 // as GTK scrollbars can't be disabled, it makes no sense to remove the
2256 // thumb for a scrollbar with range 0 - instead, make it fill the entire
2258 if ( (elem
== wxScrollBar::Element_Thumb
) && !scrollbar
->GetRange() )
2260 elem
= wxScrollBar::Element_Bar_2
;
2263 return wxStdRenderer::GetScrollbarRect(scrollbar
, elem
, thumbPos
);
2266 #endif // wxUSE_SCROLLBAR
2268 // ----------------------------------------------------------------------------
2270 // ----------------------------------------------------------------------------
2272 void wxGTKRenderer::AdjustSize(wxSize
*size
, const wxWindow
*window
)
2275 if ( wxDynamicCast(window
, wxBitmapButton
) )
2280 #endif // wxUSE_BMPBUTTON
2281 #if wxUSE_BUTTON || wxUSE_TOGGLEBTN
2284 || wxDynamicCast(window
, wxButton
)
2285 # endif // wxUSE_BUTTON
2286 # if wxUSE_TOGGLEBTN
2287 || wxDynamicCast(window
, wxToggleButton
)
2288 # endif // wxUSE_TOGGLEBTN
2291 if ( !(window
->GetWindowStyle() & wxBU_EXACTFIT
) )
2293 // TODO: this is ad hoc...
2294 size
->x
+= 3*window
->GetCharWidth();
2295 wxCoord minBtnHeight
= 18;
2296 if ( size
->y
< minBtnHeight
)
2297 size
->y
= minBtnHeight
;
2299 // button border width
2303 #endif // wxUSE_BUTTON || wxUSE_TOGGLEBTN
2305 if ( wxDynamicCast(window
, wxScrollBar
) )
2307 // we only set the width of vert scrollbars and height of the
2309 if ( window
->GetWindowStyle() & wxSB_HORIZONTAL
)
2310 size
->y
= m_sizeScrollbarArrow
.x
;
2312 size
->x
= m_sizeScrollbarArrow
.x
;
2315 #endif // wxUSE_SCROLLBAR
2317 // take into account the border width
2318 wxStdRenderer::AdjustSize(size
, window
);
2322 // ----------------------------------------------------------------------------
2324 // ----------------------------------------------------------------------------
2326 /* Copyright (c) Julian Smart */
2327 static const char *error_xpm
[] = {
2328 /* columns rows colors chars-per-pixel */
2342 " ................. ",
2343 " ................... ",
2344 " ....................... ",
2345 " ......................... ",
2346 " ........................... ",
2347 " ...........................X ",
2348 " .............................X ",
2349 " ............................... ",
2350 " ...............................X ",
2351 " .................................X ",
2352 " .................................X ",
2353 " .................................XX ",
2354 " ...ooooooooooooooooooooooooooo...XX ",
2355 " ....ooooooooooooooooooooooooooo....X ",
2356 " ....ooooooooooooooooooooooooooo....X ",
2357 " ....ooooooooooooooooooooooooooo....XX ",
2358 " ....ooooooooooooooooooooooooooo....XX ",
2359 " ....ooooooooooooooooooooooooooo....XX ",
2360 " ...ooooooooooooooooooooooooooo...XXX ",
2361 " ...ooooooooooooooooooooooooooo...XXX ",
2362 " .................................XX ",
2363 " .................................XX ",
2364 " ...............................XXX ",
2365 " ...............................XXX ",
2366 " .............................XXX ",
2367 " ...........................XXXX ",
2368 " ...........................XXX ",
2369 " .........................XXX ",
2370 " .......................XXXX ",
2371 " X...................XXXXX ",
2372 " X.................XXXXX ",
2373 " X.............XXXXX ",
2374 " XXXX.....XXXXXXXX ",
2385 /* Copyright (c) Julian Smart */
2386 static const char *info_xpm
[] = {
2387 /* columns rows colors chars-per-pixel */
2411 " .XXXOXXXXXXXoo. ",
2412 " .XOOXXX+XXXXXo. ",
2413 " .XOOOXX+++XXXXoo. ",
2414 " .XOOXXX+++XXXXXo. ",
2415 " .XOOOXXX+++XXXXXXo. ",
2416 " .XOOXXXX+++XXXXXXo. ",
2417 " .XXXXXXX+++XXXXXXX. ",
2418 " .XXXXXXX+++XXXXXXo. ",
2419 " .XXXXXXX+++XXXXXoo. ",
2420 " .XXXXXX+++XXXXXo. ",
2421 " .XXXXXXX+XXXXXXo. ",
2422 " .XXXXXXXXXXXXo. ",
2423 " .XXXXX+++XXXoo. ",
2449 /* Copyright (c) Julian Smart */
2450 static const char *warning_xpm
[] = {
2451 /* columns rows colors chars-per-pixel */
2481 " ..XXXXO@#XXX... ",
2482 " ...XXXXO@#XXXX.. ",
2483 " ..XXXXXO@#XXXX... ",
2484 " ...XXXXXo@OXXXXX.. ",
2485 " ...XXXXXXo@OXXXXXX.. ",
2486 " ..XXXXXXX$@OXXXXXX... ",
2487 " ...XXXXXXXX@XXXXXXXX.. ",
2488 " ...XXXXXXXXXXXXXXXXXX... ",
2489 " ..XXXXXXXXXXOXXXXXXXXX.. ",
2490 " ...XXXXXXXXXO@#XXXXXXXXX.. ",
2491 " ..XXXXXXXXXXX#XXXXXXXXXX... ",
2492 " ...XXXXXXXXXXXXXXXXXXXXXXX.. ",
2493 " ...XXXXXXXXXXXXXXXXXXXXXXXX... ",
2494 " .............................. ",
2495 " .............................. ",
2513 /* Copyright (c) Julian Smart */
2514 static const char *question_xpm
[] = {
2515 /* columns rows colors chars-per-pixel */
2545 " ..XXXXoooooXXXO+ ",
2546 " ..XXooooooooooooX@.. ",
2547 " ..XoooooooooooooooXX#. ",
2548 " $%XoooooooooooooooooXX#. ",
2549 " &.XoooooooXXXXXXooooooXX.. ",
2550 " .XooooooXX.$...$XXoooooX*. ",
2551 " $.XoooooX%.$ .*oooooo=.. ",
2552 " .XooooooX.. -.XoooooX.. ",
2553 " .XoooooX..+ .XoooooX;. ",
2554 " ...XXXX..: .XoooooX;. ",
2555 " ........ >.XoooooX;. ",
2589 wxBitmap
wxGTKArtProvider::CreateBitmap(const wxArtID
& id
,
2590 const wxArtClient
& WXUNUSED(client
),
2591 const wxSize
& WXUNUSED(size
))
2593 if ( id
== wxART_INFORMATION
)
2594 return wxBitmap(info_xpm
);
2595 if ( id
== wxART_ERROR
)
2596 return wxBitmap(error_xpm
);
2597 if ( id
== wxART_WARNING
)
2598 return wxBitmap(warning_xpm
);
2599 if ( id
== wxART_QUESTION
)
2600 return wxBitmap(question_xpm
);
2601 return wxNullBitmap
;
2605 // ============================================================================
2607 // ============================================================================
2609 // ----------------------------------------------------------------------------
2610 // wxGTKInputHandler
2611 // ----------------------------------------------------------------------------
2613 bool wxGTKInputHandler::HandleKey(wxInputConsumer
* WXUNUSED(control
),
2614 const wxKeyEvent
& WXUNUSED(event
),
2615 bool WXUNUSED(pressed
))
2620 bool wxGTKInputHandler::HandleMouse(wxInputConsumer
*control
,
2621 const wxMouseEvent
& event
)
2623 // clicking on the control gives it focus
2624 if ( event
.ButtonDown() && wxWindow::FindFocus() != control
->GetInputWindow() )
2626 control
->GetInputWindow()->SetFocus();
2634 bool wxGTKInputHandler::HandleMouseMove(wxInputConsumer
*control
,
2635 const wxMouseEvent
& event
)
2637 if ( event
.Entering() )
2639 control
->GetInputWindow()->SetCurrent(true);
2641 else if ( event
.Leaving() )
2643 control
->GetInputWindow()->SetCurrent(false);
2655 // ----------------------------------------------------------------------------
2656 // wxGTKCheckboxInputHandler
2657 // ----------------------------------------------------------------------------
2659 bool wxGTKCheckboxInputHandler::HandleKey(wxInputConsumer
*control
,
2660 const wxKeyEvent
& event
,
2665 int keycode
= event
.GetKeyCode();
2666 if ( keycode
== WXK_SPACE
|| keycode
== WXK_RETURN
)
2668 control
->PerformAction(wxACTION_CHECKBOX_TOGGLE
);
2677 #endif // wxUSE_CHECKBOX
2681 // ----------------------------------------------------------------------------
2682 // wxGTKTextCtrlInputHandler
2683 // ----------------------------------------------------------------------------
2685 bool wxGTKTextCtrlInputHandler::HandleKey(wxInputConsumer
*control
,
2686 const wxKeyEvent
& event
,
2689 // handle only GTK-specific text bindings here, the others are handled in
2693 wxControlAction action
;
2694 int keycode
= event
.GetKeyCode();
2695 if ( event
.ControlDown() )
2700 action
= wxACTION_TEXT_HOME
;
2704 action
= wxACTION_TEXT_LEFT
;
2708 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_RIGHT
;
2712 action
= wxACTION_TEXT_END
;
2716 action
= wxACTION_TEXT_RIGHT
;
2720 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_LEFT
;
2724 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_END
;
2728 action
= wxACTION_TEXT_DOWN
;
2732 action
= wxACTION_TEXT_UP
;
2736 //delete the entire line
2737 control
->PerformAction(wxACTION_TEXT_HOME
);
2738 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_END
;
2742 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_WORD_LEFT
;
2746 else if ( event
.AltDown() )
2751 action
= wxACTION_TEXT_WORD_LEFT
;
2755 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_WORD_RIGHT
;
2759 action
= wxACTION_TEXT_WORD_RIGHT
;
2764 if ( action
!= wxACTION_NONE
)
2766 control
->PerformAction(action
);
2772 return wxStdInputHandler::HandleKey(control
, event
, pressed
);
2775 #endif // wxUSE_TEXTCTRL