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
212 virtual wxSize
GetToolBarButtonSize(wxCoord
*separator
) const
213 { if ( separator
) *separator
= 5; return wxSize(16, 15); }
214 virtual wxSize
GetToolBarMargin() const
215 { return wxSize(6, 6); }
218 virtual wxRect
GetTextClientArea(const wxTextCtrl
*text
,
220 wxCoord
*extraSpaceBeyond
) const;
221 #endif // wxUSE_TEXTCTRL
224 virtual wxSize
GetTabIndent() const { return wxSize(2, 2); }
225 virtual wxSize
GetTabPadding() const { return wxSize(6, 6); }
226 #endif // wxUSE_NOTEBOOK
229 virtual wxCoord
GetSliderDim() const { return 15; }
230 virtual wxCoord
GetSliderTickLen() const { return 0; }
231 virtual wxRect
GetSliderShaftRect(const wxRect
& rect
,
233 wxOrientation orient
,
234 long style
= 0) const;
235 virtual wxSize
GetSliderThumbSize(const wxRect
& rect
,
237 wxOrientation orient
) const;
238 #endif // wxUSE_SLIDER
240 virtual wxSize
GetProgressBarStep() const { return wxSize(16, 32); }
243 virtual wxSize
GetMenuBarItemSize(const wxSize
& sizeText
) const;
244 virtual wxMenuGeometryInfo
*GetMenuGeometry(wxWindow
*win
,
245 const wxMenu
& menu
) const;
246 #endif // wxUSE_MENUS
248 // helpers for "wxBitmap wxColourScheme::Get()"
249 void DrawCheckBitmap(wxDC
& dc
, const wxRect
& rect
);
250 void DrawUncheckBitmap(wxDC
& dc
, const wxRect
& rect
, bool isPressed
);
251 void DrawUndeterminedBitmap(wxDC
& dc
, const wxRect
& rect
, bool isPressed
);
254 // overridden wxStdRenderer methods
255 virtual void DrawSunkenBorder(wxDC
& dc
, wxRect
*rect
);
257 virtual void DrawFrameWithLabel(wxDC
& dc
,
258 const wxString
& label
,
259 const wxRect
& rectFrame
,
260 const wxRect
& rectText
,
265 virtual void DrawCheckItemBitmap(wxDC
& dc
,
266 const wxBitmap
& bitmap
,
270 // get the colour to use for background
271 wxColour
GetBackgroundColour(int flags
) const
273 if ( flags
& wxCONTROL_PRESSED
)
274 return wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
);
275 else if ( flags
& wxCONTROL_CURRENT
)
276 return wxSCHEME_COLOUR(m_scheme
, CONTROL_CURRENT
);
278 return wxSCHEME_COLOUR(m_scheme
, CONTROL
);
281 // as DrawShadedRect() but the pixels in the bottom left and upper right
282 // border are drawn with the pen1, not pen2
283 void DrawAntiShadedRect(wxDC
& dc
, wxRect
*rect
,
284 const wxPen
& pen1
, const wxPen
& pen2
);
286 // used for drawing opened rectangles - draws only one side of it at once
287 // (and doesn't adjust the rect)
288 void DrawAntiShadedRectSide(wxDC
& dc
,
294 // draw an opened rect for the arrow in given direction
295 void DrawArrowBorder(wxDC
& dc
,
299 // draw two sides of the rectangle
300 void DrawThumbBorder(wxDC
& dc
,
302 wxOrientation orient
);
304 // just as DrawRaisedBorder() except that the bottom left and up right
305 // pixels of the interior rect are drawn in another colour (i.e. the inner
306 // rect is drawn with DrawAntiShadedRect() and not DrawShadedRect())
307 void DrawAntiRaisedBorder(wxDC
& dc
, wxRect
*rect
);
309 // draw inner GTK shadow
310 void DrawInnerShadedRect(wxDC
& dc
, wxRect
*rect
);
313 // returns the size of the arrow for the scrollbar (depends on
315 wxSize
GetScrollbarArrowSize(const wxScrollBar
*scrollbar
) const
318 if ( scrollbar
->IsVertical() )
320 size
= m_sizeScrollbarArrow
;
324 size
.x
= m_sizeScrollbarArrow
.y
;
325 size
.y
= m_sizeScrollbarArrow
.x
;
330 #endif // wxUSE_SCROLLBAR
332 // get the line wrap indicator bitmap
333 wxBitmap
GetLineWrapBitmap() const;
335 virtual wxBitmap
GetCheckBitmap(int flags
);
336 virtual wxBitmap
GetRadioBitmap(int flags
);
338 // draw a /\ or \/ line from (x1, y1) to (x2, y1) passing by the point
340 void DrawUpZag(wxDC
& dc
,
341 wxCoord x1
, wxCoord x2
,
342 wxCoord y1
, wxCoord y2
);
343 void DrawDownZag(wxDC
& dc
,
344 wxCoord x1
, wxCoord x2
,
345 wxCoord y1
, wxCoord y2
);
347 // draw the radio button bitmap for the given state
348 void DrawRadioBitmap(wxDC
& dc
, const wxRect
& rect
, int flags
);
350 // common part of DrawMenuItem() and DrawMenuBarItem()
351 void DoDrawMenuItem(wxDC
& dc
,
353 const wxString
& label
,
356 const wxString
& accel
= wxEmptyString
,
357 const wxBitmap
& bitmap
= wxNullBitmap
,
358 const wxGTKMenuGeometryInfo
*geometryInfo
= NULL
);
360 // initialize the combo bitmaps
361 void InitComboBitmaps();
363 virtual wxBitmap
GetFrameButtonBitmap(FrameButtonType
WXUNUSED(type
))
369 const wxColourScheme
*m_scheme
;
372 wxSize m_sizeScrollbarArrow
;
377 // the checkbox and radio button bitmaps: first row is for the normal,
378 // second for the pressed state and the columns are for checked, unchecked
379 // and undeterminated respectively
380 wxBitmap m_bitmapsCheckbox
[IndicatorState_MaxCtrl
][IndicatorStatus_Max
],
381 m_bitmapsRadiobtn
[IndicatorState_MaxCtrl
][IndicatorStatus_Max
];
383 // the line wrap bitmap (drawn at the end of wrapped lines)
384 wxBitmap m_bmpLineWrap
;
386 // the combobox bitmaps
396 wxBitmap m_bitmapsCombo
[ComboState_Max
];
399 // ----------------------------------------------------------------------------
400 // wxGTKInputHandler and derived classes: process the keyboard and mouse
401 // messages according to GTK standards
402 // ----------------------------------------------------------------------------
404 class wxGTKInputHandler
: public wxInputHandler
407 wxGTKInputHandler() { }
409 virtual bool HandleKey(wxInputConsumer
*control
,
410 const wxKeyEvent
& event
,
412 virtual bool HandleMouse(wxInputConsumer
*control
,
413 const wxMouseEvent
& event
);
414 virtual bool HandleMouseMove(wxInputConsumer
*control
,
415 const wxMouseEvent
& event
);
420 class wxGTKScrollBarInputHandler
: public wxStdScrollBarInputHandler
423 wxGTKScrollBarInputHandler(wxRenderer
*renderer
, wxInputHandler
*handler
)
424 : wxStdScrollBarInputHandler(renderer
, handler
) { }
427 virtual void Highlight(wxScrollBar
*scrollbar
, bool doIt
)
429 // only arrows and the thumb can be highlighted
430 if ( !IsArrow() && m_htLast
!= wxHT_SCROLLBAR_THUMB
)
433 wxStdScrollBarInputHandler::Highlight(scrollbar
, doIt
);
436 virtual void Press(wxScrollBar
*scrollbar
, bool doIt
)
438 // only arrows can be pressed
442 wxStdScrollBarInputHandler::Press(scrollbar
, doIt
);
445 // any button can be used to drag the scrollbar under GTK+
446 virtual bool IsAllowedButton(int WXUNUSED(button
)) const { return true; }
450 return m_htLast
== wxHT_SCROLLBAR_ARROW_LINE_1
||
451 m_htLast
== wxHT_SCROLLBAR_ARROW_LINE_2
;
455 #endif // wxUSE_SCROLLBAR
459 class wxGTKCheckboxInputHandler
: public wxStdInputHandler
462 wxGTKCheckboxInputHandler(wxInputHandler
*handler
)
463 : wxStdInputHandler(handler
) { }
465 virtual bool HandleKey(wxInputConsumer
*control
,
466 const wxKeyEvent
& event
,
470 #endif // wxUSE_CHECKBOX
474 class wxGTKTextCtrlInputHandler
: public wxStdInputHandler
477 wxGTKTextCtrlInputHandler(wxInputHandler
*handler
)
478 : wxStdInputHandler(handler
) { }
480 virtual bool HandleKey(wxInputConsumer
*control
,
481 const wxKeyEvent
& event
,
485 #endif // wxUSE_TEXTCTRL
487 // ----------------------------------------------------------------------------
488 // wxGTKColourScheme: uses the standard GTK colours
489 // ----------------------------------------------------------------------------
491 class wxGTKColourScheme
: public wxColourScheme
494 virtual wxColour
Get(StdColour col
) const;
495 virtual wxColour
GetBackground(wxWindow
*win
) const;
498 // ----------------------------------------------------------------------------
500 // ----------------------------------------------------------------------------
502 class wxGTKArtProvider
: public wxArtProvider
505 virtual wxBitmap
CreateBitmap(const wxArtID
& id
,
506 const wxArtClient
& client
,
510 // ----------------------------------------------------------------------------
512 // ----------------------------------------------------------------------------
514 WX_DEFINE_ARRAY_PTR(wxInputHandler
*, wxArrayHandlers
);
516 class wxGTKTheme
: public wxTheme
520 virtual ~wxGTKTheme();
522 virtual wxRenderer
*GetRenderer();
523 virtual wxArtProvider
*GetArtProvider();
524 virtual wxInputHandler
*GetInputHandler(const wxString
& control
,
525 wxInputConsumer
*consumer
);
526 virtual wxColourScheme
*GetColourScheme();
529 wxGTKRenderer
*m_renderer
;
531 wxGTKArtProvider
*m_artProvider
;
533 // the names of the already created handlers and the handlers themselves
534 // (these arrays are synchronized)
535 wxSortedArrayString m_handlerNames
;
536 wxArrayHandlers m_handlers
;
538 wxGTKColourScheme
*m_scheme
;
540 WX_DECLARE_THEME(gtk
)
543 // ============================================================================
545 // ============================================================================
547 WX_IMPLEMENT_THEME(wxGTKTheme
, gtk
, wxTRANSLATE("GTK+ theme"));
549 // ----------------------------------------------------------------------------
551 // ----------------------------------------------------------------------------
553 wxGTKTheme::wxGTKTheme()
557 m_artProvider
= NULL
;
560 wxGTKTheme::~wxGTKTheme()
564 wxArtProvider::RemoveProvider(m_artProvider
);
567 wxRenderer
*wxGTKTheme::GetRenderer()
571 m_renderer
= new wxGTKRenderer(GetColourScheme());
577 wxArtProvider
*wxGTKTheme::GetArtProvider()
579 if ( !m_artProvider
)
581 m_artProvider
= new wxGTKArtProvider
;
584 return m_artProvider
;
587 wxColourScheme
*wxGTKTheme::GetColourScheme()
591 m_scheme
= new wxGTKColourScheme
;
596 wxInputHandler
*wxGTKTheme::GetInputHandler(const wxString
& control
,
597 wxInputConsumer
*consumer
)
599 wxInputHandler
*handler
= NULL
;
600 int n
= m_handlerNames
.Index(control
);
601 if ( n
== wxNOT_FOUND
)
603 static wxGTKInputHandler s_handlerDef
;
605 wxInputHandler
* const
606 handlerStd
= consumer
->DoGetStdInputHandler(&s_handlerDef
);
608 // create a new handler
610 if ( control
== wxINP_HANDLER_CHECKBOX
)
612 static wxGTKCheckboxInputHandler
s_handler(handlerStd
);
614 handler
= &s_handler
;
617 #endif // wxUSE_CHECKBOX
619 if ( control
== wxINP_HANDLER_SCROLLBAR
)
621 static wxGTKScrollBarInputHandler
s_handler(m_renderer
, handlerStd
);
623 handler
= &s_handler
;
626 #endif // wxUSE_SCROLLBAR
628 if ( control
== wxINP_HANDLER_TEXTCTRL
)
630 static wxGTKTextCtrlInputHandler
s_handler(handlerStd
);
632 handler
= &s_handler
;
635 #endif // wxUSE_TEXTCTRL
637 // no special handler for this control
638 handler
= handlerStd
;
641 n
= m_handlerNames
.Add(control
);
642 m_handlers
.Insert(handler
, n
);
644 else // we already have it
646 handler
= m_handlers
[n
];
652 // ============================================================================
654 // ============================================================================
656 wxColour
wxGTKColourScheme::GetBackground(wxWindow
*win
) const
659 if ( win
->UseBgCol() )
661 // use the user specified colour
662 col
= win
->GetBackgroundColour();
665 if ( !win
->ShouldInheritColours() )
667 // doesn't depend on the state
675 int flags
= win
->GetStateFlags();
677 // the colour set by the user should be used for the normal state
678 // and for the states for which we don't have any specific colours
679 if ( !col
.Ok() || (flags
!= 0) )
682 if ( wxDynamicCast(win
, wxScrollBar
) )
683 col
= Get(SCROLLBAR
);
685 #endif //wxUSE_SCROLLBAR
686 if ( (flags
& wxCONTROL_CURRENT
) && win
->CanBeHighlighted() )
687 col
= Get(CONTROL_CURRENT
);
688 else if ( flags
& wxCONTROL_PRESSED
)
689 col
= Get(CONTROL_PRESSED
);
698 wxColour
wxGTKColourScheme::Get(wxGTKColourScheme::StdColour col
) const
702 case WINDOW
: return *wxWHITE
;
704 case SHADOW_DARK
: return *wxBLACK
;
705 case SHADOW_HIGHLIGHT
: return *wxWHITE
;
706 case SHADOW_IN
: return wxColour(0xd6d6d6);
707 case SHADOW_OUT
: return wxColour(0x969696);
709 case CONTROL
: return wxColour(0xd6d6d6);
710 case CONTROL_PRESSED
: return wxColour(0xc3c3c3);
711 case CONTROL_CURRENT
: return wxColour(0xeaeaea);
713 case CONTROL_TEXT
: return *wxBLACK
;
714 case CONTROL_TEXT_DISABLED
:
715 return wxColour(0x757575);
716 case CONTROL_TEXT_DISABLED_SHADOW
:
720 case SCROLLBAR_PRESSED
: return wxColour(0xc3c3c3);
722 case HIGHLIGHT
: return wxColour(0x9c0000);
723 case HIGHLIGHT_TEXT
: return wxColour(0xffffff);
725 case GAUGE
: return Get(CONTROL_CURRENT
);
727 case TITLEBAR
: return wxColour(0xaeaaae);
728 case TITLEBAR_ACTIVE
: return wxColour(0x820300);
729 case TITLEBAR_TEXT
: return wxColour(0xc0c0c0);
730 case TITLEBAR_ACTIVE_TEXT
:
733 case DESKTOP
: return *wxBLACK
;
737 wxFAIL_MSG(_T("invalid standard colour"));
742 // ============================================================================
744 // ============================================================================
746 // ----------------------------------------------------------------------------
748 // ----------------------------------------------------------------------------
750 wxGTKRenderer::wxGTKRenderer(const wxColourScheme
*scheme
)
751 : wxStdRenderer(scheme
)
753 m_sizeScrollbarArrow
= wxSize(15, 14);
755 m_penGrey
= wxPen(wxSCHEME_COLOUR(scheme
, SCROLLBAR
));
758 // ----------------------------------------------------------------------------
760 // ----------------------------------------------------------------------------
762 void wxGTKRenderer::DrawAntiShadedRectSide(wxDC
& dc
,
768 dc
.SetPen(dir
== wxLEFT
|| dir
== wxUP
? pen1
: pen2
);
773 dc
.DrawLine(rect
.GetLeft(), rect
.GetTop(),
774 rect
.GetLeft(), rect
.GetBottom() + 1);
778 dc
.DrawLine(rect
.GetLeft(), rect
.GetTop(),
779 rect
.GetRight() + 1, rect
.GetTop());
783 dc
.DrawLine(rect
.GetRight(), rect
.GetTop(),
784 rect
.GetRight(), rect
.GetBottom() + 1);
788 dc
.DrawLine(rect
.GetLeft(), rect
.GetBottom(),
789 rect
.GetRight() + 1, rect
.GetBottom());
793 wxFAIL_MSG(_T("unknown rectangle side"));
797 void wxGTKRenderer::DrawAntiShadedRect(wxDC
& dc
, wxRect
*rect
,
798 const wxPen
& pen1
, const wxPen
& pen2
)
800 // draw the rectangle
802 dc
.DrawLine(rect
->GetLeft(), rect
->GetTop(),
803 rect
->GetLeft(), rect
->GetBottom() + 1);
804 dc
.DrawLine(rect
->GetLeft() + 1, rect
->GetTop(),
805 rect
->GetRight() + 1, rect
->GetTop());
807 dc
.DrawLine(rect
->GetRight(), rect
->GetTop() + 1,
808 rect
->GetRight(), rect
->GetBottom());
809 dc
.DrawLine(rect
->GetLeft() + 1, rect
->GetBottom(),
810 rect
->GetRight() + 1, rect
->GetBottom());
816 void wxGTKRenderer::DrawInnerShadedRect(wxDC
& dc
, wxRect
*rect
)
818 DrawAntiShadedRect(dc
, rect
, m_penDarkGrey
, m_penHighlight
);
819 DrawAntiShadedRect(dc
, rect
, m_penBlack
, m_penHighlight
);
822 void wxGTKRenderer::DrawAntiRaisedBorder(wxDC
& dc
, wxRect
*rect
)
824 DrawShadedRect(dc
, rect
, m_penHighlight
, m_penBlack
);
825 DrawAntiShadedRect(dc
, rect
, m_penLightGrey
, m_penDarkGrey
);
828 void wxGTKRenderer::DrawSunkenBorder(wxDC
& dc
, wxRect
*rect
)
830 DrawAntiShadedRect(dc
, rect
, m_penDarkGrey
, m_penHighlight
);
831 DrawShadedRect(dc
, rect
, m_penBlack
, m_penLightGrey
);
834 void wxGTKRenderer::DrawFocusRect(wxDC
& dc
, const wxRect
& rect
)
836 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
837 wxRect rectFocus
= rect
;
838 DrawRect(dc
, &rectFocus
, m_penBlack
);
841 void wxGTKRenderer::DrawTextBorder(wxDC
& dc
,
843 const wxRect
& rectOrig
,
847 wxRect rect
= rectOrig
;
849 if ( border
!= wxBORDER_NONE
)
851 if ( flags
& wxCONTROL_FOCUSED
)
853 DrawRect(dc
, &rect
, m_penBlack
);
854 DrawAntiShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
858 DrawInnerShadedRect(dc
, &rect
);
866 void wxGTKRenderer::DrawButtonLabel(wxDC
& dc
,
867 const wxString
& label
,
868 const wxBitmap
& image
,
875 // no focus rect around buttons label in GTK+
876 wxStdRenderer::DrawButtonLabel(dc
, label
, image
, rect
, flags
,
877 alignment
, indexAccel
, rectBounds
);
880 void wxGTKRenderer::DrawButtonBorder(wxDC
& dc
,
881 const wxRect
& rectTotal
,
885 wxRect rect
= rectTotal
;
887 if ( flags
& wxCONTROL_PRESSED
)
889 // button pressed: draw a black border around it and an inward shade
890 DrawRect(dc
, &rect
, m_penBlack
);
892 DrawInnerShadedRect(dc
, &rect
);
894 else // button not pressed
896 if ( flags
& wxCONTROL_ISDEFAULT
)
901 if ( flags
& wxCONTROL_FOCUSED
)
903 // button is currently default: add an extra border around it
904 DrawRect(dc
, &rect
, m_penBlack
);
907 // now draw a normal button
908 DrawShadedRect(dc
, &rect
, m_penHighlight
, m_penBlack
);
909 DrawAntiShadedRect(dc
, &rect
, GetBackgroundColour(flags
), m_penDarkGrey
);
916 // ----------------------------------------------------------------------------
918 // ----------------------------------------------------------------------------
920 void wxGTKRenderer::DrawFrameWithLabel(wxDC
& dc
,
921 const wxString
& label
,
922 const wxRect
& rectFrame
,
923 const wxRect
& rectTextOrig
,
928 wxRect
rectText(rectTextOrig
);
929 rectText
.Inflate(1, 0);
932 DrawLabel(dc
, label
, rectText
, flags
, alignment
, indexAccel
, &rectLabel
);
934 rectLabel
.width
+= 2;
936 DrawFrameWithoutLabel(dc
, rectFrame
, rectLabel
);
938 // GTK+ does it like this
939 dc
.SetPen(m_penHighlight
);
940 dc
.DrawPoint(rectText
.x
, rectFrame
.y
);
941 dc
.DrawPoint(rectText
.x
+ rectLabel
.width
- 3, rectFrame
.y
);
944 // ----------------------------------------------------------------------------
945 // check/radion buttons
946 // ----------------------------------------------------------------------------
948 void wxGTKRenderer::DrawCheckItemBitmap(wxDC
& dc
,
949 const wxBitmap
& bitmap
,
953 // never draw the focus rect around the check indicators here
954 DrawCheckButton(dc
, wxEmptyString
, bitmap
, rect
, flags
& ~wxCONTROL_FOCUSED
);
957 void wxGTKRenderer::DrawUndeterminedBitmap(wxDC
& dc
,
958 const wxRect
& rectTotal
,
961 // FIXME: For sure it is not GTK look but it is better than nothing.
962 // Show me correct look and I will immediatelly make it better (ABX)
963 wxRect rect
= rectTotal
;
969 col1
= wxSCHEME_COLOUR(m_scheme
, SHADOW_DARK
);
970 col2
= wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
);
974 col1
= wxSCHEME_COLOUR(m_scheme
, SHADOW_DARK
);
975 col2
= wxSCHEME_COLOUR(m_scheme
, SHADOW_IN
);
978 dc
.SetPen(*wxTRANSPARENT_PEN
);
980 dc
.DrawRectangle(rect
);
983 dc
.DrawRectangle(rect
);
986 void wxGTKRenderer::DrawUncheckBitmap(wxDC
& dc
,
987 const wxRect
& rectTotal
,
990 wxRect rect
= rectTotal
;
991 DrawAntiRaisedBorder(dc
, &rect
);
993 wxColour col
= wxSCHEME_COLOUR(m_scheme
, SHADOW_IN
);
994 dc
.SetPen(wxPen(col
));
995 dc
.DrawPoint(rect
.GetRight() - 1, rect
.GetBottom() - 1);
998 col
= wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
);
999 //else: it is SHADOW_IN, leave as is
1001 dc
.SetPen(*wxTRANSPARENT_PEN
);
1003 dc
.DrawRectangle(rect
);
1006 void wxGTKRenderer::DrawCheckBitmap(wxDC
& dc
, const wxRect
& rectTotal
)
1008 wxRect rect
= rectTotal
;
1009 DrawAntiShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
1010 DrawShadedRect(dc
, &rect
, m_penBlack
, m_penLightGrey
);
1012 dc
.SetPen(*wxTRANSPARENT_PEN
);
1013 dc
.SetBrush(wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
));
1014 dc
.DrawRectangle(rect
);
1017 void wxGTKRenderer::DrawRadioBitmap(wxDC
& dc
,
1023 xRight
= rect
.GetRight(),
1024 yBottom
= rect
.GetBottom();
1026 wxCoord yMid
= (y
+ yBottom
) / 2;
1028 // then draw the upper half
1029 dc
.SetPen(flags
& wxCONTROL_CHECKED
? m_penDarkGrey
: m_penHighlight
);
1030 DrawUpZag(dc
, x
, xRight
, yMid
, y
);
1031 DrawUpZag(dc
, x
+ 1, xRight
- 1, yMid
, y
+ 1);
1034 if ( flags
& wxCONTROL_CHECKED
)
1035 dc
.SetPen(m_penBlack
);
1036 else if ( flags
& wxCONTROL_PRESSED
)
1037 dc
.SetPen(wxPen(wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
)));
1038 else // unchecked and unpressed
1042 DrawUpZag(dc
, x
+ 2, xRight
- 2, yMid
, y
+ 2);
1044 // and then the lower one
1045 dc
.SetPen(flags
& wxCONTROL_CHECKED
? m_penHighlight
: m_penBlack
);
1046 DrawDownZag(dc
, x
, xRight
, yMid
, yBottom
);
1047 if ( !(flags
& wxCONTROL_CHECKED
) )
1048 dc
.SetPen(m_penDarkGrey
);
1049 DrawDownZag(dc
, x
+ 1, xRight
- 1, yMid
, yBottom
- 1);
1051 if ( !(flags
& wxCONTROL_CHECKED
) )
1052 drawIt
= true; // with the same pen
1053 else if ( flags
& wxCONTROL_PRESSED
)
1055 dc
.SetPen(wxPen(wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
)));
1058 else // checked and unpressed
1062 DrawDownZag(dc
, x
+ 2, xRight
- 2, yMid
, yBottom
- 2);
1065 void wxGTKRenderer::DrawUpZag(wxDC
& dc
,
1071 wxCoord xMid
= (x1
+ x2
) / 2;
1072 dc
.DrawLine(x1
, y1
, xMid
, y2
);
1073 dc
.DrawLine(xMid
, y2
, x2
+ 1, y1
+ 1);
1076 void wxGTKRenderer::DrawDownZag(wxDC
& dc
,
1082 wxCoord xMid
= (x1
+ x2
) / 2;
1083 dc
.DrawLine(x1
+ 1, y1
+ 1, xMid
, y2
);
1084 dc
.DrawLine(xMid
, y2
, x2
, y1
);
1087 wxBitmap
wxGTKRenderer::GetCheckBitmap(int flags
)
1089 if ( !m_bitmapsCheckbox
[0][0].Ok() )
1091 // init the bitmaps once only
1093 wxSize size
= GetCheckBitmapSize();
1094 rect
.width
= size
.x
;
1095 rect
.height
= size
.y
;
1096 for ( int i
= 0; i
< 2; i
++ )
1098 for ( int j
= 0; j
< 3; j
++ )
1099 m_bitmapsCheckbox
[i
][j
].Create(rect
.width
, rect
.height
);
1105 dc
.SelectObject(m_bitmapsCheckbox
[0][0]);
1106 DrawCheckBitmap(dc
, rect
);
1109 dc
.SelectObject(m_bitmapsCheckbox
[0][1]);
1110 DrawUncheckBitmap(dc
, rect
, false);
1112 // normal undeterminated
1113 dc
.SelectObject(m_bitmapsCheckbox
[0][2]);
1114 DrawUndeterminedBitmap(dc
, rect
, false);
1117 m_bitmapsCheckbox
[1][0] = m_bitmapsCheckbox
[0][0];
1119 // pressed unchecked
1120 dc
.SelectObject(m_bitmapsCheckbox
[1][1]);
1121 DrawUncheckBitmap(dc
, rect
, true);
1123 // pressed undeterminated
1124 dc
.SelectObject(m_bitmapsCheckbox
[1][2]);
1125 DrawUndeterminedBitmap(dc
, rect
, true);
1128 IndicatorState state
;
1129 IndicatorStatus status
;
1130 GetIndicatorsFromFlags(flags
, state
, status
);
1132 // disabled looks the same as normal
1133 if ( state
== IndicatorState_Disabled
)
1134 state
= IndicatorState_Normal
;
1136 return m_bitmapsCheckbox
[state
][status
];
1139 wxBitmap
wxGTKRenderer::GetRadioBitmap(int flags
)
1141 IndicatorState state
;
1142 IndicatorStatus status
;
1143 GetIndicatorsFromFlags(flags
, state
, status
);
1145 wxBitmap
& bmp
= m_bitmapsRadiobtn
[state
][status
];
1148 const wxSize size
= GetRadioBitmapSize();
1151 bmp
.Create(size
.x
, size
.y
);
1152 dc
.SelectObject(bmp
);
1154 DrawRadioBitmap(dc
, size
, flags
);
1160 wxBitmap
wxGTKRenderer::GetLineWrapBitmap() const
1162 if ( !m_bmpLineWrap
.Ok() )
1164 // the line wrap bitmap as used by GTK+
1165 #define line_wrap_width 6
1166 #define line_wrap_height 9
1167 static const char line_wrap_bits
[] =
1169 0x1e, 0x3e, 0x30, 0x30, 0x39, 0x1f, 0x0f, 0x0f, 0x1f,
1172 wxBitmap
bmpLineWrap(line_wrap_bits
, line_wrap_width
, line_wrap_height
);
1173 if ( !bmpLineWrap
.Ok() )
1175 wxFAIL_MSG( _T("Failed to create line wrap XBM") );
1179 wxConstCast(this, wxGTKRenderer
)->m_bmpLineWrap
= bmpLineWrap
;
1183 return m_bmpLineWrap
;
1187 void wxGTKRenderer::DrawToolBarButton(wxDC
& dc
,
1188 const wxString
& label
,
1189 const wxBitmap
& bitmap
,
1190 const wxRect
& rectOrig
,
1192 long WXUNUSED(style
),
1195 // we don't draw the separators at all
1196 if ( !label
.empty() || bitmap
.Ok() )
1198 wxRect rect
= rectOrig
;
1199 rect
.Deflate(BORDER_THICKNESS
);
1201 if ( flags
& wxCONTROL_PRESSED
)
1203 DrawBorder(dc
, wxBORDER_SUNKEN
, rect
, flags
, &rect
);
1205 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
), rect
);
1207 else if ( flags
& wxCONTROL_CURRENT
)
1209 DrawBorder(dc
, wxBORDER_RAISED
, rect
, flags
, &rect
);
1211 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL_CURRENT
), rect
);
1214 if(tbarStyle
& wxTB_TEXT
)
1216 if(tbarStyle
& wxTB_HORIZONTAL
)
1218 dc
.DrawLabel(label
, bitmap
, rect
, wxALIGN_CENTRE
);
1222 dc
.DrawLabel(label
, bitmap
, rect
, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
);
1227 int xpoint
= (rect
.GetLeft() + rect
.GetRight() + 1 - bitmap
.GetWidth()) / 2;
1228 int ypoint
= (rect
.GetTop() + rect
.GetBottom() + 1 - bitmap
.GetHeight()) / 2;
1229 dc
.DrawBitmap(bitmap
, xpoint
, ypoint
);
1233 #endif // wxUSE_TOOLBAR
1235 // ----------------------------------------------------------------------------
1237 // ----------------------------------------------------------------------------
1241 wxRect
wxGTKRenderer::GetTextClientArea(const wxTextCtrl
*text
,
1243 wxCoord
*extraSpaceBeyond
) const
1246 rectText
= wxStdRenderer::GetTextClientArea(text
, rect
, extraSpaceBeyond
);
1248 if ( text
->WrapLines() )
1250 // leave enough for the line wrap bitmap indicator
1251 wxCoord widthMark
= GetLineWrapBitmap().GetWidth() + 2;
1253 rectText
.width
-= widthMark
;
1255 if ( extraSpaceBeyond
)
1256 *extraSpaceBeyond
= widthMark
;
1262 void wxGTKRenderer::DrawLineWrapMark(wxDC
& dc
, const wxRect
& rect
)
1264 wxBitmap bmpLineWrap
= GetLineWrapBitmap();
1266 // for a mono bitmap he colours it appears in depends on the current text
1267 // colours, so set them correctly
1269 if ( bmpLineWrap
.GetDepth() == 1 )
1271 colFgOld
= dc
.GetTextForeground();
1273 // FIXME: I wonder what should we do if the background is black too?
1274 dc
.SetTextForeground(*wxBLACK
);
1277 dc
.DrawBitmap(bmpLineWrap
,
1278 rect
.x
, rect
.y
+ (rect
.height
- bmpLineWrap
.GetHeight())/2);
1280 if ( colFgOld
.Ok() )
1282 // restore old colour
1283 dc
.SetTextForeground(colFgOld
);
1287 #endif // wxUSE_TEXTCTRL
1289 // ----------------------------------------------------------------------------
1291 // ----------------------------------------------------------------------------
1295 void wxGTKRenderer::DrawTab(wxDC
& dc
,
1296 const wxRect
& rectOrig
,
1298 const wxString
& label
,
1299 const wxBitmap
& bitmap
,
1303 #define SELECT_FOR_VERTICAL(X,Y) ( isVertical ? Y : X )
1304 #define REVERSE_FOR_VERTICAL(X,Y) \
1305 SELECT_FOR_VERTICAL(X,Y) \
1307 SELECT_FOR_VERTICAL(Y,X)
1309 wxRect rect
= rectOrig
;
1311 bool isVertical
= ( dir
== wxLEFT
) || ( dir
== wxRIGHT
);
1313 // the current tab is drawn indented (to the top for default case) and
1314 // bigger than the other ones
1315 const wxSize indent
= GetTabIndent();
1316 if ( flags
& wxCONTROL_SELECTED
)
1318 rect
.Inflate( SELECT_FOR_VERTICAL( indent
.x
, 0),
1319 SELECT_FOR_VERTICAL( 0, indent
.y
));
1323 wxFAIL_MSG(_T("invaild notebook tab orientation"));
1330 rect
.height
+= indent
.y
;
1337 rect
.width
+= indent
.x
;
1342 // selected tab has different colour
1343 wxColour col
= flags
& wxCONTROL_SELECTED
1344 ? wxSCHEME_COLOUR(m_scheme
, SHADOW_IN
)
1345 : wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
);
1346 DrawSolidRect(dc
, col
, rect
);
1348 if ( flags
& wxCONTROL_FOCUSED
)
1350 // draw the focus rect
1351 wxRect rectBorder
= rect
;
1352 rectBorder
.Deflate(4, 3);
1353 if ( dir
== wxBOTTOM
)
1354 rectBorder
.Offset(0, -1);
1355 if ( dir
== wxRIGHT
)
1356 rectBorder
.Offset(-1, 0);
1358 DrawRect(dc
, &rectBorder
, m_penBlack
);
1361 // draw the text, image and the focus around them (if necessary)
1362 wxRect
rectLabel( REVERSE_FOR_VERTICAL(rect
.x
,rect
.y
),
1363 REVERSE_FOR_VERTICAL(rect
.width
,rect
.height
)
1365 rectLabel
.Deflate(1, 1);
1368 // draw it horizontally into memory and rotate for screen
1370 wxBitmap bitmapRotated
,
1371 bitmapMem( rectLabel
.x
+ rectLabel
.width
,
1372 rectLabel
.y
+ rectLabel
.height
);
1373 dcMem
.SelectObject(bitmapMem
);
1374 dcMem
.SetBackground(dc
.GetBackground());
1375 dcMem
.SetFont(dc
.GetFont());
1376 dcMem
.SetTextForeground(dc
.GetTextForeground());
1380 wxBitmap( wxImage( bitmap
.ConvertToImage() ).Rotate90(dir
==wxLEFT
) )
1383 #endif // wxUSE_IMAGE
1385 dcMem
.DrawLabel(label
, bitmapRotated
, rectLabel
, wxALIGN_CENTRE
, indexAccel
);
1386 dcMem
.SelectObject(wxNullBitmap
);
1387 bitmapMem
= bitmapMem
.GetSubBitmap(rectLabel
);
1389 bitmapMem
= wxBitmap(wxImage(bitmapMem
.ConvertToImage()).Rotate90(dir
==wxRIGHT
))
1393 dc
.DrawBitmap(bitmapMem
, rectLabel
.y
, rectLabel
.x
, false);
1397 dc
.DrawLabel(label
, bitmap
, rectLabel
, wxALIGN_CENTRE
, indexAccel
);
1400 // now draw the tab itself
1401 wxCoord x
= SELECT_FOR_VERTICAL(rect
.x
,rect
.y
),
1402 y
= SELECT_FOR_VERTICAL(rect
.y
,rect
.x
),
1403 x2
= SELECT_FOR_VERTICAL(rect
.GetRight(),rect
.GetBottom()),
1404 y2
= SELECT_FOR_VERTICAL(rect
.GetBottom(),rect
.GetRight());
1410 // left orientation looks like top but IsVertical makes x and y reversed
1412 // top is not vertical so use coordinates in written order
1413 dc
.SetPen(m_penHighlight
);
1414 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y2
),
1415 REVERSE_FOR_VERTICAL(x
, y
));
1416 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
),
1417 REVERSE_FOR_VERTICAL(x2
, y
));
1419 dc
.SetPen(m_penBlack
);
1420 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y2
),
1421 REVERSE_FOR_VERTICAL(x2
, y
));
1423 dc
.SetPen(m_penDarkGrey
);
1424 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
- 1, y2
),
1425 REVERSE_FOR_VERTICAL(x2
- 1, y
+ 1));
1427 if ( flags
& wxCONTROL_SELECTED
)
1429 dc
.SetPen(m_penLightGrey
);
1431 // overwrite the part of the border below this tab
1432 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
+ 1),
1433 REVERSE_FOR_VERTICAL(x2
- 1, y2
+ 1));
1435 // and the shadow of the tab to the left of us
1436 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
+ 2),
1437 REVERSE_FOR_VERTICAL(x
+ 1, y2
+ 1));
1442 // right orientation looks like bottom but IsVertical makes x and y reversed
1444 // bottom is not vertical so use coordinates in written order
1445 dc
.SetPen(m_penHighlight
);
1447 // we need to continue one pixel further to overwrite the corner of
1448 // the border for the selected tab
1449 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y
- (flags
& wxCONTROL_SELECTED
? 1 : 0)),
1450 REVERSE_FOR_VERTICAL(x
, y2
));
1452 // it doesn't work like this (TODO: implement it properly)
1454 // erase the corner of the tab to the right
1455 dc
.SetPen(m_penLightGrey
);
1456 dc
.DrawPoint(REVERSE_FOR_VERTICAL(x2
- 1, y
- 2));
1457 dc
.DrawPoint(REVERSE_FOR_VERTICAL(x2
- 2, y
- 2));
1458 dc
.DrawPoint(REVERSE_FOR_VERTICAL(x2
- 2, y
- 1));
1461 dc
.SetPen(m_penBlack
);
1462 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
),
1463 REVERSE_FOR_VERTICAL(x2
, y2
));
1464 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y
),
1465 REVERSE_FOR_VERTICAL(x2
, y2
));
1467 dc
.SetPen(m_penDarkGrey
);
1468 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 2, y2
- 1),
1469 REVERSE_FOR_VERTICAL(x2
- 1, y2
- 1));
1470 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
- 1, y
),
1471 REVERSE_FOR_VERTICAL(x2
- 1, y2
));
1473 if ( flags
& wxCONTROL_SELECTED
)
1475 dc
.SetPen(m_penLightGrey
);
1477 // overwrite the part of the (double!) border above this tab
1478 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
- 1),
1479 REVERSE_FOR_VERTICAL(x2
- 1, y
- 1));
1480 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
- 2),
1481 REVERSE_FOR_VERTICAL(x2
- 1, y
- 2));
1483 // and the shadow of the tab to the left of us
1484 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
- 1),
1485 REVERSE_FOR_VERTICAL(x
+ 1, y
- 1));
1491 #endif // wxUSE_NOTEBOOK
1493 // ----------------------------------------------------------------------------
1495 // ----------------------------------------------------------------------------
1499 wxSize
wxGTKRenderer::GetSliderThumbSize(const wxRect
& rect
,
1501 wxOrientation orient
) const
1503 static const wxCoord SLIDER_THUMB_LENGTH
= 30;
1507 wxRect rectShaft
= GetSliderShaftRect(rect
, lenThumb
, orient
);
1508 if ( orient
== wxHORIZONTAL
)
1510 size
.x
= wxMin(SLIDER_THUMB_LENGTH
, rectShaft
.width
);
1511 size
.y
= rectShaft
.height
;
1515 size
.y
= wxMin(SLIDER_THUMB_LENGTH
, rectShaft
.height
);
1516 size
.x
= rectShaft
.width
;
1522 wxRect
wxGTKRenderer::GetSliderShaftRect(const wxRect
& rect
,
1523 int WXUNUSED(lenThumb
),
1524 wxOrientation
WXUNUSED(orient
),
1525 long WXUNUSED(style
)) const
1527 return rect
.Deflate(2*BORDER_THICKNESS
, 2*BORDER_THICKNESS
);
1530 void wxGTKRenderer::DrawSliderShaft(wxDC
& dc
,
1531 const wxRect
& rectOrig
,
1532 int WXUNUSED(lenThumb
),
1533 wxOrientation
WXUNUSED(orient
),
1535 long WXUNUSED(style
),
1538 wxRect rect
= rectOrig
;
1540 // draw the border first
1541 if ( flags
& wxCONTROL_FOCUSED
)
1543 DrawRect(dc
, &rect
, m_penBlack
);
1545 else // not focused, normal
1547 DrawAntiShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
1550 DrawAntiShadedRect(dc
, &rect
, m_penBlack
, m_penLightGrey
);
1552 // and the background
1553 DrawSolidRect(dc
, wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
), rect
);
1559 void wxGTKRenderer::DrawSliderThumb(wxDC
& dc
,
1560 const wxRect
& rectOrig
,
1561 wxOrientation orient
,
1562 int WXUNUSED(flags
),
1563 long WXUNUSED(style
))
1565 // draw the thumb border
1566 wxRect rect
= rectOrig
;
1567 DrawAntiRaisedBorder(dc
, &rect
);
1569 // draw the handle in the middle
1570 if ( orient
== wxVERTICAL
)
1572 rect
.height
= 2*BORDER_THICKNESS
;
1573 rect
.y
= rectOrig
.y
+ (rectOrig
.height
- rect
.height
) / 2;
1577 rect
.width
= 2*BORDER_THICKNESS
;
1578 rect
.x
= rectOrig
.x
+ (rectOrig
.width
- rect
.width
) / 2;
1581 DrawShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
1584 #endif // wxUSE_SLIDER
1588 // ----------------------------------------------------------------------------
1590 // ----------------------------------------------------------------------------
1592 // wxGTKMenuGeometryInfo: the wxMenuGeometryInfo used by wxGTKRenderer
1593 class WXDLLEXPORT wxGTKMenuGeometryInfo
: public wxMenuGeometryInfo
1596 virtual wxSize
GetSize() const { return m_size
; }
1598 wxCoord
GetLabelOffset() const { return m_ofsLabel
; }
1599 wxCoord
GetAccelOffset() const { return m_ofsAccel
; }
1601 wxCoord
GetItemHeight() const { return m_heightItem
; }
1604 // the total size of the menu
1607 // the offset of the start of the menu item label
1610 // the offset of the start of the accel label
1613 // the height of a normal (not separator) item
1614 wxCoord m_heightItem
;
1616 friend wxMenuGeometryInfo
*
1617 wxGTKRenderer::GetMenuGeometry(wxWindow
*, const wxMenu
&) const;
1620 // FIXME: all constants are hardcoded but shouldn't be
1621 static const wxCoord MENU_LEFT_MARGIN
= 9;
1622 static const wxCoord MENU_RIGHT_MARGIN
= 6;
1624 static const wxCoord MENU_HORZ_MARGIN
= 6;
1625 static const wxCoord MENU_VERT_MARGIN
= 3;
1627 // the margin around bitmap/check marks (on each side)
1628 static const wxCoord MENU_BMP_MARGIN
= 2;
1630 // the margin between the labels and accel strings
1631 static const wxCoord MENU_ACCEL_MARGIN
= 8;
1633 // the separator height in pixels: in fact, strangely enough, the real height
1634 // is 2 but Windows adds one extra pixel in the bottom margin, so take it into
1636 static const wxCoord MENU_SEPARATOR_HEIGHT
= 3;
1638 // the size of the standard checkmark bitmap
1639 static const wxCoord MENU_CHECK_SIZE
= 9;
1641 void wxGTKRenderer::DrawMenuBarItem(wxDC
& dc
,
1643 const wxString
& label
,
1647 DoDrawMenuItem(dc
, rect
, label
, flags
, indexAccel
);
1650 void wxGTKRenderer::DrawMenuItem(wxDC
& dc
,
1652 const wxMenuGeometryInfo
& gi
,
1653 const wxString
& label
,
1654 const wxString
& accel
,
1655 const wxBitmap
& bitmap
,
1659 const wxGTKMenuGeometryInfo
& geomInfo
= (const wxGTKMenuGeometryInfo
&)gi
;
1664 rect
.width
= geomInfo
.GetSize().x
;
1665 rect
.height
= geomInfo
.GetItemHeight();
1667 DoDrawMenuItem(dc
, rect
, label
, flags
, indexAccel
, accel
, bitmap
, &geomInfo
);
1670 void wxGTKRenderer::DoDrawMenuItem(wxDC
& dc
,
1671 const wxRect
& rectOrig
,
1672 const wxString
& label
,
1675 const wxString
& accel
,
1676 const wxBitmap
& bitmap
,
1677 const wxGTKMenuGeometryInfo
*geometryInfo
)
1679 wxRect rect
= rectOrig
;
1681 // draw the selected item specially
1682 if ( flags
& wxCONTROL_SELECTED
)
1685 DrawBorder(dc
, wxBORDER_RAISED
, rect
, flags
, &rectIn
);
1687 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL_CURRENT
), rectIn
);
1690 rect
.Deflate(MENU_HORZ_MARGIN
, MENU_VERT_MARGIN
);
1692 // draw the bitmap: use the bitmap provided or the standard checkmark for
1693 // the checkable items
1696 wxBitmap bmp
= bitmap
;
1697 if ( !bmp
.Ok() && (flags
& wxCONTROL_CHECKABLE
) )
1699 bmp
= GetCheckBitmap(flags
);
1704 rect
.SetRight(geometryInfo
->GetLabelOffset());
1705 wxControlRenderer::DrawBitmap(dc
, bmp
, rect
);
1708 //else: menubar items don't have bitmaps
1713 rect
.x
= geometryInfo
->GetLabelOffset();
1714 rect
.SetRight(geometryInfo
->GetAccelOffset());
1717 DrawLabel(dc
, label
, rect
, flags
, wxALIGN_CENTRE_VERTICAL
, indexAccel
);
1719 // draw the accel string
1720 if ( !accel
.empty() )
1722 // menubar items shouldn't have them
1723 wxCHECK_RET( geometryInfo
, _T("accel strings only valid for menus") );
1725 rect
.x
= geometryInfo
->GetAccelOffset();
1726 rect
.SetRight(geometryInfo
->GetSize().x
);
1728 // NB: no accel index here
1729 DrawLabel(dc
, accel
, rect
, flags
, wxALIGN_CENTRE_VERTICAL
);
1732 // draw the submenu indicator
1733 if ( flags
& wxCONTROL_ISSUBMENU
)
1735 wxCHECK_RET( geometryInfo
, _T("wxCONTROL_ISSUBMENU only valid for menus") );
1737 rect
.x
= geometryInfo
->GetSize().x
- MENU_RIGHT_MARGIN
;
1738 rect
.width
= MENU_RIGHT_MARGIN
;
1740 DrawArrow(dc
, wxRIGHT
, rect
, flags
);
1744 void wxGTKRenderer::DrawMenuSeparator(wxDC
& dc
,
1746 const wxMenuGeometryInfo
& geomInfo
)
1748 DrawHorizontalLine(dc
, y
+ MENU_VERT_MARGIN
, 0, geomInfo
.GetSize().x
);
1751 wxSize
wxGTKRenderer::GetMenuBarItemSize(const wxSize
& sizeText
) const
1753 wxSize size
= sizeText
;
1755 // TODO: make this configurable
1756 size
.x
+= 2*MENU_HORZ_MARGIN
;
1757 size
.y
+= 2*MENU_VERT_MARGIN
;
1762 wxMenuGeometryInfo
*wxGTKRenderer::GetMenuGeometry(wxWindow
*win
,
1763 const wxMenu
& menu
) const
1765 // prepare the dc: for now we draw all the items with the system font
1767 dc
.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
1769 // the height of a normal item
1770 wxCoord heightText
= dc
.GetCharHeight();
1775 // the max length of label and accel strings: the menu width is the sum of
1776 // them, even if they're for different items (as the accels should be
1779 // the max length of the bitmap is never 0 as Windows always leaves enough
1780 // space for a check mark indicator
1781 wxCoord widthLabelMax
= 0,
1783 widthBmpMax
= MENU_LEFT_MARGIN
;
1785 for ( wxMenuItemList::compatibility_iterator node
= menu
.GetMenuItems().GetFirst();
1787 node
= node
->GetNext() )
1789 // height of this item
1792 wxMenuItem
*item
= node
->GetData();
1793 if ( item
->IsSeparator() )
1795 h
= MENU_SEPARATOR_HEIGHT
;
1797 else // not separator
1802 dc
.GetTextExtent(item
->GetLabel(), &widthLabel
, NULL
);
1803 if ( widthLabel
> widthLabelMax
)
1805 widthLabelMax
= widthLabel
;
1809 dc
.GetTextExtent(item
->GetAccelString(), &widthAccel
, NULL
);
1810 if ( widthAccel
> widthAccelMax
)
1812 widthAccelMax
= widthAccel
;
1815 const wxBitmap
& bmp
= item
->GetBitmap();
1818 wxCoord widthBmp
= bmp
.GetWidth();
1819 if ( widthBmp
> widthBmpMax
)
1820 widthBmpMax
= widthBmp
;
1822 //else if ( item->IsCheckable() ): no need to check for this as
1823 // MENU_LEFT_MARGIN is big enough to show the check mark
1826 h
+= 2*MENU_VERT_MARGIN
;
1828 // remember the item position and height
1829 item
->SetGeometry(height
, h
);
1834 // bundle the metrics into a struct and return it
1835 wxGTKMenuGeometryInfo
*gi
= new wxGTKMenuGeometryInfo
;
1837 gi
->m_ofsLabel
= widthBmpMax
+ 2*MENU_BMP_MARGIN
;
1838 gi
->m_ofsAccel
= gi
->m_ofsLabel
+ widthLabelMax
;
1839 if ( widthAccelMax
> 0 )
1841 // if we actually have any accesl, add a margin
1842 gi
->m_ofsAccel
+= MENU_ACCEL_MARGIN
;
1845 gi
->m_heightItem
= heightText
+ 2*MENU_VERT_MARGIN
;
1847 gi
->m_size
.x
= gi
->m_ofsAccel
+ widthAccelMax
+ MENU_RIGHT_MARGIN
;
1848 gi
->m_size
.y
= height
;
1853 #endif // wxUSE_MENUS
1855 // ----------------------------------------------------------------------------
1857 // ----------------------------------------------------------------------------
1859 void wxGTKRenderer::InitComboBitmaps()
1861 wxSize sizeArrow
= m_sizeScrollbarArrow
;
1867 for ( n
= ComboState_Normal
; n
< ComboState_Max
; n
++ )
1869 m_bitmapsCombo
[n
].Create(sizeArrow
.x
, sizeArrow
.y
);
1872 static const int comboButtonFlags
[ComboState_Max
] =
1880 wxRect
rect(sizeArrow
);
1883 for ( n
= ComboState_Normal
; n
< ComboState_Max
; n
++ )
1885 int flags
= comboButtonFlags
[n
];
1887 dc
.SelectObject(m_bitmapsCombo
[n
]);
1888 DrawSolidRect(dc
, GetBackgroundColour(flags
), rect
);
1889 DrawArrow(dc
, wxDOWN
, rect
, flags
);
1893 void wxGTKRenderer::GetComboBitmaps(wxBitmap
*bmpNormal
,
1895 wxBitmap
*bmpPressed
,
1896 wxBitmap
*bmpDisabled
)
1898 if ( !m_bitmapsCombo
[ComboState_Normal
].Ok() )
1904 *bmpNormal
= m_bitmapsCombo
[ComboState_Normal
];
1906 *bmpFocus
= m_bitmapsCombo
[ComboState_Focus
];
1908 *bmpPressed
= m_bitmapsCombo
[ComboState_Pressed
];
1910 *bmpDisabled
= m_bitmapsCombo
[ComboState_Disabled
];
1913 // ----------------------------------------------------------------------------
1915 // ----------------------------------------------------------------------------
1917 void wxGTKRenderer::DrawArrowBorder(wxDC
& dc
,
1921 static const wxDirection sides
[] =
1923 wxUP
, wxLEFT
, wxRIGHT
, wxDOWN
1926 wxRect rect1
, rect2
, rectInner
;
1932 rectInner
.Inflate(-2);
1934 DrawSolidRect(dc
, wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
), *rect
);
1936 // find the side not to draw and also adjust the rectangles to compensate
1938 wxDirection sideToOmit
;
1942 sideToOmit
= wxDOWN
;
1944 rectInner
.height
+= 1;
1952 rectInner
.height
+= 1;
1956 sideToOmit
= wxRIGHT
;
1958 rectInner
.width
+= 1;
1962 sideToOmit
= wxLEFT
;
1966 rectInner
.width
+= 1;
1970 wxFAIL_MSG(_T("unknown arrow direction"));
1974 // the outer rect first
1976 for ( n
= 0; n
< WXSIZEOF(sides
); n
++ )
1978 wxDirection side
= sides
[n
];
1979 if ( side
== sideToOmit
)
1982 DrawAntiShadedRectSide(dc
, rect1
, m_penDarkGrey
, m_penHighlight
, side
);
1985 // and then the inner one
1986 for ( n
= 0; n
< WXSIZEOF(sides
); n
++ )
1988 wxDirection side
= sides
[n
];
1989 if ( side
== sideToOmit
)
1992 DrawAntiShadedRectSide(dc
, rect2
, m_penBlack
, m_penGrey
, side
);
1998 void wxGTKRenderer::DrawScrollbarArrow(wxDC
& dc
,
2000 const wxRect
& rectArrow
,
2003 // first of all, draw the border around it - but we don't want the border
2004 // on the side opposite to the arrow point
2005 wxRect rect
= rectArrow
;
2006 DrawArrowBorder(dc
, &rect
, dir
);
2008 // then the arrow itself
2009 DrawArrow(dc
, dir
, rect
, flags
);
2012 // gtk_default_draw_arrow() takes ~350 lines and we can't do much better here
2013 // these people are just crazy :-(
2014 void wxGTKRenderer::DrawArrow(wxDC
& dc
,
2027 wxPoint ptArrow
[Point_Max
];
2029 wxColour colInside
= GetBackgroundColour(flags
);
2031 if ( flags
& wxCONTROL_DISABLED
)
2033 penShadow
[0] = m_penDarkGrey
;
2034 penShadow
[1] = m_penDarkGrey
;
2035 penShadow
[2] = wxNullPen
;
2036 penShadow
[3] = wxNullPen
;
2038 else if ( flags
& wxCONTROL_PRESSED
)
2040 penShadow
[0] = m_penDarkGrey
;
2041 penShadow
[1] = m_penHighlight
;
2042 penShadow
[2] = wxNullPen
;
2043 penShadow
[3] = m_penBlack
;
2045 else // normal arrow
2047 penShadow
[0] = m_penHighlight
;
2048 penShadow
[1] = m_penBlack
;
2049 penShadow
[2] = m_penDarkGrey
;
2050 penShadow
[3] = wxNullPen
;
2054 if ( dir
== wxUP
|| dir
== wxDOWN
)
2057 middle
= (rect
.GetRight() + rect
.GetLeft() + 1) / 2;
2061 middle
= (rect
.GetTop() + rect
.GetBottom() + 1) / 2;
2064 // draw the arrow interior
2065 dc
.SetPen(*wxTRANSPARENT_PEN
);
2066 dc
.SetBrush(colInside
);
2071 ptArrow
[Point_First
].x
= rect
.GetLeft();
2072 ptArrow
[Point_First
].y
= rect
.GetBottom();
2073 ptArrow
[Point_Second
].x
= middle
;
2074 ptArrow
[Point_Second
].y
= rect
.GetTop();
2075 ptArrow
[Point_Third
].x
= rect
.GetRight();
2076 ptArrow
[Point_Third
].y
= rect
.GetBottom();
2080 ptArrow
[Point_First
] = rect
.GetPosition();
2081 ptArrow
[Point_Second
].x
= middle
;
2082 ptArrow
[Point_Second
].y
= rect
.GetBottom();
2083 ptArrow
[Point_Third
].x
= rect
.GetRight();
2084 ptArrow
[Point_Third
].y
= rect
.GetTop();
2088 ptArrow
[Point_First
].x
= rect
.GetRight();
2089 ptArrow
[Point_First
].y
= rect
.GetTop();
2090 ptArrow
[Point_Second
].x
= rect
.GetLeft();
2091 ptArrow
[Point_Second
].y
= middle
;
2092 ptArrow
[Point_Third
].x
= rect
.GetRight();
2093 ptArrow
[Point_Third
].y
= rect
.GetBottom();
2097 ptArrow
[Point_First
] = rect
.GetPosition();
2098 ptArrow
[Point_Second
].x
= rect
.GetRight();
2099 ptArrow
[Point_Second
].y
= middle
;
2100 ptArrow
[Point_Third
].x
= rect
.GetLeft();
2101 ptArrow
[Point_Third
].y
= rect
.GetBottom();
2105 wxFAIL_MSG(_T("unknown arrow direction"));
2108 dc
.DrawPolygon(WXSIZEOF(ptArrow
), ptArrow
);
2110 // draw the arrow border
2111 dc
.SetPen(penShadow
[0]);
2115 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_First
]);
2116 dc
.DrawPoint(ptArrow
[Point_First
]);
2117 if ( penShadow
[3].Ok() )
2119 dc
.SetPen(penShadow
[3]);
2120 dc
.DrawLine(ptArrow
[Point_First
].x
+ 1, ptArrow
[Point_First
].y
,
2121 ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
);
2123 dc
.SetPen(penShadow
[1]);
2124 dc
.DrawLine(ptArrow
[Point_Second
].x
+ 1, ptArrow
[Point_Second
].y
+ 1,
2125 ptArrow
[Point_Third
].x
, ptArrow
[Point_Third
].y
);
2126 dc
.DrawPoint(ptArrow
[Point_Third
]);
2127 dc
.DrawLine(ptArrow
[Point_Third
].x
- 2, ptArrow
[Point_Third
].y
,
2128 ptArrow
[Point_First
].x
+ 1, ptArrow
[Point_First
].y
);
2129 if ( penShadow
[2].Ok() )
2131 dc
.SetPen(penShadow
[2]);
2132 dc
.DrawLine(ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
,
2133 ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
+ 1);
2134 dc
.DrawLine(ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
- 1,
2135 ptArrow
[Point_First
].x
+ 2, ptArrow
[Point_First
].y
- 1);
2140 dc
.DrawLine(ptArrow
[Point_First
], ptArrow
[Point_Second
]);
2141 dc
.DrawLine(ptArrow
[Point_First
].x
+ 2, ptArrow
[Point_First
].y
,
2142 ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
);
2143 if ( penShadow
[2].Ok() )
2145 dc
.SetPen(penShadow
[2]);
2146 dc
.DrawLine(ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
- 1,
2147 ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
- 1);
2149 dc
.SetPen(penShadow
[1]);
2150 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_Third
]);
2151 dc
.DrawPoint(ptArrow
[Point_Third
]);
2155 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_First
]);
2156 dc
.DrawPoint(ptArrow
[Point_First
]);
2157 if ( penShadow
[2].Ok() )
2159 dc
.SetPen(penShadow
[2]);
2160 dc
.DrawLine(ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
,
2161 ptArrow
[Point_First
].x
- 1, ptArrow
[Point_First
].y
+ 2);
2162 dc
.DrawLine(ptArrow
[Point_Third
].x
, ptArrow
[Point_Third
].y
,
2163 ptArrow
[Point_Second
].x
+ 2, ptArrow
[Point_Second
].y
+ 1);
2165 dc
.SetPen(penShadow
[1]);
2166 dc
.DrawLine(ptArrow
[Point_Third
].x
, ptArrow
[Point_Third
].y
,
2167 ptArrow
[Point_First
].x
, ptArrow
[Point_First
].y
+ 1);
2168 dc
.DrawLine(ptArrow
[Point_Second
].x
+ 1, ptArrow
[Point_Second
].y
+ 1,
2169 ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
);
2173 dc
.DrawLine(ptArrow
[Point_First
], ptArrow
[Point_Third
]);
2174 dc
.DrawLine(ptArrow
[Point_First
].x
+ 2, ptArrow
[Point_First
].y
+ 1,
2175 ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
);
2176 dc
.SetPen(penShadow
[1]);
2177 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_Third
]);
2178 dc
.DrawPoint(ptArrow
[Point_Third
]);
2182 wxFAIL_MSG(_T("unknown arrow direction"));
2187 void wxGTKRenderer::DrawThumbBorder(wxDC
& dc
,
2189 wxOrientation orient
)
2191 if ( orient
== wxVERTICAL
)
2193 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2195 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2197 rect
->Inflate(-1, 0);
2199 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2201 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2203 rect
->Inflate(-1, 0);
2207 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2209 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2211 rect
->Inflate(0, -1);
2213 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2215 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2217 rect
->Inflate(0, -1);
2221 void wxGTKRenderer::DrawScrollbarThumb(wxDC
& dc
,
2222 wxOrientation orient
,
2226 // the thumb is never pressed never has focus border under GTK and the
2227 // scrollbar background never changes at all
2228 int flagsThumb
= flags
& ~(wxCONTROL_PRESSED
| wxCONTROL_FOCUSED
);
2230 // we don't want the border in the direction of the scrollbar movement
2231 wxRect rectThumb
= rect
;
2232 DrawThumbBorder(dc
, &rectThumb
, orient
);
2234 DrawButtonBorder(dc
, rectThumb
, flagsThumb
, &rectThumb
);
2235 DrawBackground(dc
, wxNullColour
, rectThumb
, flagsThumb
);
2238 void wxGTKRenderer::DrawScrollbarShaft(wxDC
& dc
,
2239 wxOrientation orient
,
2241 int WXUNUSED(flags
))
2243 wxRect rectBar
= rect
;
2244 DrawThumbBorder(dc
, &rectBar
, orient
);
2245 DrawSolidRect(dc
, wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
), rectBar
);
2249 wxRect
wxGTKRenderer::GetScrollbarRect(const wxScrollBar
*scrollbar
,
2250 wxScrollBar::Element elem
,
2253 // as GTK scrollbars can't be disabled, it makes no sense to remove the
2254 // thumb for a scrollbar with range 0 - instead, make it fill the entire
2256 if ( (elem
== wxScrollBar::Element_Thumb
) && !scrollbar
->GetRange() )
2258 elem
= wxScrollBar::Element_Bar_2
;
2261 return wxStdRenderer::GetScrollbarRect(scrollbar
, elem
, thumbPos
);
2264 #endif // wxUSE_SCROLLBAR
2266 // ----------------------------------------------------------------------------
2268 // ----------------------------------------------------------------------------
2270 void wxGTKRenderer::AdjustSize(wxSize
*size
, const wxWindow
*window
)
2273 if ( wxDynamicCast(window
, wxBitmapButton
) )
2278 #endif // wxUSE_BMPBUTTON
2279 #if wxUSE_BUTTON || wxUSE_TOGGLEBTN
2282 || wxDynamicCast(window
, wxButton
)
2283 # endif // wxUSE_BUTTON
2284 # if wxUSE_TOGGLEBTN
2285 || wxDynamicCast(window
, wxToggleButton
)
2286 # endif // wxUSE_TOGGLEBTN
2289 if ( !(window
->GetWindowStyle() & wxBU_EXACTFIT
) )
2291 // TODO: this is ad hoc...
2292 size
->x
+= 3*window
->GetCharWidth();
2293 wxCoord minBtnHeight
= 18;
2294 if ( size
->y
< minBtnHeight
)
2295 size
->y
= minBtnHeight
;
2297 // button border width
2301 #endif // wxUSE_BUTTON || wxUSE_TOGGLEBTN
2303 if ( wxDynamicCast(window
, wxScrollBar
) )
2305 // we only set the width of vert scrollbars and height of the
2307 if ( window
->GetWindowStyle() & wxSB_HORIZONTAL
)
2308 size
->y
= m_sizeScrollbarArrow
.x
;
2310 size
->x
= m_sizeScrollbarArrow
.x
;
2313 #endif // wxUSE_SCROLLBAR
2315 // take into account the border width
2316 wxStdRenderer::AdjustSize(size
, window
);
2320 // ----------------------------------------------------------------------------
2322 // ----------------------------------------------------------------------------
2324 /* Copyright (c) Julian Smart */
2325 static const char *error_xpm
[] = {
2326 /* columns rows colors chars-per-pixel */
2340 " ................. ",
2341 " ................... ",
2342 " ....................... ",
2343 " ......................... ",
2344 " ........................... ",
2345 " ...........................X ",
2346 " .............................X ",
2347 " ............................... ",
2348 " ...............................X ",
2349 " .................................X ",
2350 " .................................X ",
2351 " .................................XX ",
2352 " ...ooooooooooooooooooooooooooo...XX ",
2353 " ....ooooooooooooooooooooooooooo....X ",
2354 " ....ooooooooooooooooooooooooooo....X ",
2355 " ....ooooooooooooooooooooooooooo....XX ",
2356 " ....ooooooooooooooooooooooooooo....XX ",
2357 " ....ooooooooooooooooooooooooooo....XX ",
2358 " ...ooooooooooooooooooooooooooo...XXX ",
2359 " ...ooooooooooooooooooooooooooo...XXX ",
2360 " .................................XX ",
2361 " .................................XX ",
2362 " ...............................XXX ",
2363 " ...............................XXX ",
2364 " .............................XXX ",
2365 " ...........................XXXX ",
2366 " ...........................XXX ",
2367 " .........................XXX ",
2368 " .......................XXXX ",
2369 " X...................XXXXX ",
2370 " X.................XXXXX ",
2371 " X.............XXXXX ",
2372 " XXXX.....XXXXXXXX ",
2383 /* Copyright (c) Julian Smart */
2384 static const char *info_xpm
[] = {
2385 /* columns rows colors chars-per-pixel */
2409 " .XXXOXXXXXXXoo. ",
2410 " .XOOXXX+XXXXXo. ",
2411 " .XOOOXX+++XXXXoo. ",
2412 " .XOOXXX+++XXXXXo. ",
2413 " .XOOOXXX+++XXXXXXo. ",
2414 " .XOOXXXX+++XXXXXXo. ",
2415 " .XXXXXXX+++XXXXXXX. ",
2416 " .XXXXXXX+++XXXXXXo. ",
2417 " .XXXXXXX+++XXXXXoo. ",
2418 " .XXXXXX+++XXXXXo. ",
2419 " .XXXXXXX+XXXXXXo. ",
2420 " .XXXXXXXXXXXXo. ",
2421 " .XXXXX+++XXXoo. ",
2447 /* Copyright (c) Julian Smart */
2448 static const char *warning_xpm
[] = {
2449 /* columns rows colors chars-per-pixel */
2479 " ..XXXXO@#XXX... ",
2480 " ...XXXXO@#XXXX.. ",
2481 " ..XXXXXO@#XXXX... ",
2482 " ...XXXXXo@OXXXXX.. ",
2483 " ...XXXXXXo@OXXXXXX.. ",
2484 " ..XXXXXXX$@OXXXXXX... ",
2485 " ...XXXXXXXX@XXXXXXXX.. ",
2486 " ...XXXXXXXXXXXXXXXXXX... ",
2487 " ..XXXXXXXXXXOXXXXXXXXX.. ",
2488 " ...XXXXXXXXXO@#XXXXXXXXX.. ",
2489 " ..XXXXXXXXXXX#XXXXXXXXXX... ",
2490 " ...XXXXXXXXXXXXXXXXXXXXXXX.. ",
2491 " ...XXXXXXXXXXXXXXXXXXXXXXXX... ",
2492 " .............................. ",
2493 " .............................. ",
2511 /* Copyright (c) Julian Smart */
2512 static const char *question_xpm
[] = {
2513 /* columns rows colors chars-per-pixel */
2543 " ..XXXXoooooXXXO+ ",
2544 " ..XXooooooooooooX@.. ",
2545 " ..XoooooooooooooooXX#. ",
2546 " $%XoooooooooooooooooXX#. ",
2547 " &.XoooooooXXXXXXooooooXX.. ",
2548 " .XooooooXX.$...$XXoooooX*. ",
2549 " $.XoooooX%.$ .*oooooo=.. ",
2550 " .XooooooX.. -.XoooooX.. ",
2551 " .XoooooX..+ .XoooooX;. ",
2552 " ...XXXX..: .XoooooX;. ",
2553 " ........ >.XoooooX;. ",
2587 wxBitmap
wxGTKArtProvider::CreateBitmap(const wxArtID
& id
,
2588 const wxArtClient
& WXUNUSED(client
),
2589 const wxSize
& WXUNUSED(size
))
2591 if ( id
== wxART_INFORMATION
)
2592 return wxBitmap(info_xpm
);
2593 if ( id
== wxART_ERROR
)
2594 return wxBitmap(error_xpm
);
2595 if ( id
== wxART_WARNING
)
2596 return wxBitmap(warning_xpm
);
2597 if ( id
== wxART_QUESTION
)
2598 return wxBitmap(question_xpm
);
2599 return wxNullBitmap
;
2603 // ============================================================================
2605 // ============================================================================
2607 // ----------------------------------------------------------------------------
2608 // wxGTKInputHandler
2609 // ----------------------------------------------------------------------------
2611 bool wxGTKInputHandler::HandleKey(wxInputConsumer
* WXUNUSED(control
),
2612 const wxKeyEvent
& WXUNUSED(event
),
2613 bool WXUNUSED(pressed
))
2618 bool wxGTKInputHandler::HandleMouse(wxInputConsumer
*control
,
2619 const wxMouseEvent
& event
)
2621 // clicking on the control gives it focus
2622 if ( event
.ButtonDown() && wxWindow::FindFocus() != control
->GetInputWindow() )
2624 control
->GetInputWindow()->SetFocus();
2632 bool wxGTKInputHandler::HandleMouseMove(wxInputConsumer
*control
,
2633 const wxMouseEvent
& event
)
2635 if ( event
.Entering() )
2637 control
->GetInputWindow()->SetCurrent(true);
2639 else if ( event
.Leaving() )
2641 control
->GetInputWindow()->SetCurrent(false);
2653 // ----------------------------------------------------------------------------
2654 // wxGTKCheckboxInputHandler
2655 // ----------------------------------------------------------------------------
2657 bool wxGTKCheckboxInputHandler::HandleKey(wxInputConsumer
*control
,
2658 const wxKeyEvent
& event
,
2663 int keycode
= event
.GetKeyCode();
2664 if ( keycode
== WXK_SPACE
|| keycode
== WXK_RETURN
)
2666 control
->PerformAction(wxACTION_CHECKBOX_TOGGLE
);
2675 #endif // wxUSE_CHECKBOX
2679 // ----------------------------------------------------------------------------
2680 // wxGTKTextCtrlInputHandler
2681 // ----------------------------------------------------------------------------
2683 bool wxGTKTextCtrlInputHandler::HandleKey(wxInputConsumer
*control
,
2684 const wxKeyEvent
& event
,
2687 // handle only GTK-specific text bindings here, the others are handled in
2691 wxControlAction action
;
2692 int keycode
= event
.GetKeyCode();
2693 if ( event
.ControlDown() )
2698 action
= wxACTION_TEXT_HOME
;
2702 action
= wxACTION_TEXT_LEFT
;
2706 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_RIGHT
;
2710 action
= wxACTION_TEXT_END
;
2714 action
= wxACTION_TEXT_RIGHT
;
2718 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_LEFT
;
2722 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_END
;
2726 action
= wxACTION_TEXT_DOWN
;
2730 action
= wxACTION_TEXT_UP
;
2734 //delete the entire line
2735 control
->PerformAction(wxACTION_TEXT_HOME
);
2736 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_END
;
2740 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_WORD_LEFT
;
2744 else if ( event
.AltDown() )
2749 action
= wxACTION_TEXT_WORD_LEFT
;
2753 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_WORD_RIGHT
;
2757 action
= wxACTION_TEXT_WORD_RIGHT
;
2762 if ( action
!= wxACTION_NONE
)
2764 control
->PerformAction(action
);
2770 return wxStdInputHandler::HandleKey(control
, event
, pressed
);
2773 #endif // wxUSE_TEXTCTRL