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
,
118 virtual void DrawScrollCorner(wxDC
& dc
,
120 virtual void DrawCheckItem(wxDC
& dc
,
121 const wxString
& label
,
122 const wxBitmap
& bitmap
,
127 virtual void DrawToolBarButton(wxDC
& dc
,
128 const wxString
& label
,
129 const wxBitmap
& bitmap
,
134 #endif // wxUSE_TOOLBAR
137 virtual void DrawLineWrapMark(wxDC
& dc
, const wxRect
& rect
);
138 #endif // wxUSE_TEXTCTRL
141 virtual void DrawTab(wxDC
& dc
,
144 const wxString
& label
,
145 const wxBitmap
& bitmap
= wxNullBitmap
,
147 int indexAccel
= -1);
148 #endif // wxUSE_NOTEBOOK
151 virtual void DrawSliderShaft(wxDC
& dc
,
154 wxOrientation orient
,
157 wxRect
*rectShaft
= NULL
);
158 virtual void DrawSliderThumb(wxDC
& dc
,
160 wxOrientation orient
,
163 virtual void DrawSliderTicks(wxDC
& WXUNUSED(dc
),
164 const wxRect
& WXUNUSED(rect
),
165 int WXUNUSED(lenThumb
),
166 wxOrientation
WXUNUSED(orient
),
169 int WXUNUSED(step
) = 1,
170 int WXUNUSED(flags
) = 0,
171 long WXUNUSED(style
) = 0)
173 // we don't have the ticks in GTK version
175 #endif // wxUSE_SLIDER
178 virtual void DrawMenuBarItem(wxDC
& dc
,
180 const wxString
& label
,
182 int indexAccel
= -1);
183 virtual void DrawMenuItem(wxDC
& dc
,
185 const wxMenuGeometryInfo
& geometryInfo
,
186 const wxString
& label
,
187 const wxString
& accel
,
188 const wxBitmap
& bitmap
= wxNullBitmap
,
190 int indexAccel
= -1);
191 virtual void DrawMenuSeparator(wxDC
& dc
,
193 const wxMenuGeometryInfo
& geomInfo
);
194 #endif // wxUSE_MENUS
197 virtual void DrawStatusField(wxDC
& dc
,
199 const wxString
& label
,
200 int flags
= 0, int style
= 0);
201 #endif // wxUSE_STATUSBAR
203 virtual void DrawFrameTitleBar(wxDC
& dc
,
205 const wxString
& title
,
208 int specialButton
= 0,
209 int specialButtonFlag
= 0);
210 virtual void DrawFrameBorder(wxDC
& dc
,
213 virtual void DrawFrameBackground(wxDC
& dc
,
216 virtual void DrawFrameTitle(wxDC
& dc
,
218 const wxString
& title
,
220 virtual void DrawFrameIcon(wxDC
& dc
,
224 virtual void DrawFrameButton(wxDC
& dc
,
225 wxCoord x
, wxCoord y
,
230 virtual wxRect
GetFrameClientArea(const wxRect
& rect
, int flags
) const;
231 virtual wxSize
GetFrameTotalSize(const wxSize
& clientSize
, int flags
) const;
232 virtual wxSize
GetFrameMinSize(int flags
) const;
233 virtual wxSize
GetFrameIconSize() const;
234 virtual int HitTestFrame(const wxRect
& rect
, const wxPoint
& pt
, int flags
) const;
236 virtual void GetComboBitmaps(wxBitmap
*bmpNormal
,
238 wxBitmap
*bmpPressed
,
239 wxBitmap
*bmpDisabled
);
241 virtual void AdjustSize(wxSize
*size
, const wxWindow
*window
);
243 // geometry and hit testing
244 virtual wxSize
GetScrollbarArrowSize() const
245 { return m_sizeScrollbarArrow
; }
247 virtual wxRect
GetScrollbarRect(const wxScrollBar
*scrollbar
,
248 wxScrollBar::Element elem
,
249 int thumbPos
= -1) const;
250 #endif // wxUSE_SCROLLBAR
252 virtual wxCoord
GetListboxItemHeight(wxCoord fontHeight
)
253 { return fontHeight
+ 2; }
254 virtual wxSize
GetCheckBitmapSize() const
255 { return wxSize(10, 10); }
256 virtual wxSize
GetRadioBitmapSize() const
257 { return wxSize(11, 11); }
258 virtual wxCoord
GetCheckItemMargin() const
261 virtual wxSize
GetToolBarButtonSize(wxCoord
*separator
) const
262 { if ( separator
) *separator
= 5; return wxSize(16, 15); }
263 virtual wxSize
GetToolBarMargin() const
264 { return wxSize(6, 6); }
267 virtual wxRect
GetTextTotalArea(const wxTextCtrl
*text
,
268 const wxRect
& rect
) const;
269 virtual wxRect
GetTextClientArea(const wxTextCtrl
*text
,
271 wxCoord
*extraSpaceBeyond
) const;
272 #endif // wxUSE_TEXTCTRL
275 virtual wxSize
GetTabIndent() const { return wxSize(2, 2); }
276 virtual wxSize
GetTabPadding() const { return wxSize(6, 6); }
277 #endif // wxUSE_NOTEBOOK
280 virtual wxCoord
GetSliderDim() const { return 15; }
281 virtual wxCoord
GetSliderTickLen() const { return 0; }
282 virtual wxRect
GetSliderShaftRect(const wxRect
& rect
,
284 wxOrientation orient
,
285 long style
= 0) const;
286 virtual wxSize
GetSliderThumbSize(const wxRect
& rect
,
288 wxOrientation orient
) const;
289 #endif // wxUSE_SLIDER
291 virtual wxSize
GetProgressBarStep() const { return wxSize(16, 32); }
294 virtual wxSize
GetMenuBarItemSize(const wxSize
& sizeText
) const;
295 virtual wxMenuGeometryInfo
*GetMenuGeometry(wxWindow
*win
,
296 const wxMenu
& menu
) const;
297 #endif // wxUSE_MENUS
300 virtual wxSize
GetStatusBarBorders(wxCoord
*borderBetweenFields
) const;
301 #endif // wxUSE_STATUSBAR
303 // helpers for "wxBitmap wxColourScheme::Get()"
304 void DrawCheckBitmap(wxDC
& dc
, const wxRect
& rect
);
305 void DrawUncheckBitmap(wxDC
& dc
, const wxRect
& rect
, bool isPressed
);
306 void DrawUndeterminedBitmap(wxDC
& dc
, const wxRect
& rect
, bool isPressed
);
309 virtual void DrawSunkenBorder(wxDC
& dc
, wxRect
*rect
);
311 virtual void DrawFrameWithLabel(wxDC
& dc
,
312 const wxString
& label
,
313 const wxRect
& rectFrame
,
314 const wxRect
& rectText
,
319 // get the colour to use for background
320 wxColour
GetBackgroundColour(int flags
) const
322 if ( flags
& wxCONTROL_PRESSED
)
323 return wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
);
324 else if ( flags
& wxCONTROL_CURRENT
)
325 return wxSCHEME_COLOUR(m_scheme
, CONTROL_CURRENT
);
327 return wxSCHEME_COLOUR(m_scheme
, CONTROL
);
330 // as DrawShadedRect() but the pixels in the bottom left and upper right
331 // border are drawn with the pen1, not pen2
332 void DrawAntiShadedRect(wxDC
& dc
, wxRect
*rect
,
333 const wxPen
& pen1
, const wxPen
& pen2
);
335 // used for drawing opened rectangles - draws only one side of it at once
336 // (and doesn't adjust the rect)
337 void DrawAntiShadedRectSide(wxDC
& dc
,
343 // draw an opened rect for the arrow in given direction
344 void DrawArrowBorder(wxDC
& dc
,
348 // draw two sides of the rectangle
349 void DrawThumbBorder(wxDC
& dc
,
351 wxOrientation orient
);
353 // just as DrawRaisedBorder() except that the bottom left and up right
354 // pixels of the interior rect are drawn in another colour (i.e. the inner
355 // rect is drawn with DrawAntiShadedRect() and not DrawShadedRect())
356 void DrawAntiRaisedBorder(wxDC
& dc
, wxRect
*rect
);
358 // draw inner GTK shadow
359 void DrawInnerShadedRect(wxDC
& dc
, wxRect
*rect
);
362 // returns the size of the arrow for the scrollbar (depends on
364 wxSize
GetScrollbarArrowSize(const wxScrollBar
*scrollbar
) const
367 if ( scrollbar
->IsVertical() )
369 size
= m_sizeScrollbarArrow
;
373 size
.x
= m_sizeScrollbarArrow
.y
;
374 size
.y
= m_sizeScrollbarArrow
.x
;
379 #endif // wxUSE_SCROLLBAR
381 // get the line wrap indicator bitmap
382 wxBitmap
GetLineWrapBitmap() const;
384 virtual wxBitmap
GetCheckBitmap(int flags
);
385 virtual wxBitmap
GetRadioBitmap(int flags
);
387 // draw a /\ or \/ line from (x1, y1) to (x2, y1) passing by the point
389 void DrawUpZag(wxDC
& dc
,
390 wxCoord x1
, wxCoord x2
,
391 wxCoord y1
, wxCoord y2
);
392 void DrawDownZag(wxDC
& dc
,
393 wxCoord x1
, wxCoord x2
,
394 wxCoord y1
, wxCoord y2
);
396 // draw the radio button bitmap for the given state
397 void DrawRadioBitmap(wxDC
& dc
, const wxRect
& rect
, int flags
);
399 // draw check/radio - the bitmap must be a valid one by now
400 void DoDrawCheckOrRadioBitmap(wxDC
& dc
,
401 const wxString
& label
,
402 const wxBitmap
& bitmap
,
403 const wxRect
& rectTotal
,
408 // common part of DrawMenuItem() and DrawMenuBarItem()
409 void DoDrawMenuItem(wxDC
& dc
,
411 const wxString
& label
,
414 const wxString
& accel
= wxEmptyString
,
415 const wxBitmap
& bitmap
= wxNullBitmap
,
416 const wxGTKMenuGeometryInfo
*geometryInfo
= NULL
);
418 // initialize the combo bitmaps
419 void InitComboBitmaps();
422 const wxColourScheme
*m_scheme
;
425 wxSize m_sizeScrollbarArrow
;
430 // the checkbox and radio button bitmaps: first row is for the normal,
431 // second for the pressed state and the columns are for checked, unchecked
432 // and undeterminated respectively
433 wxBitmap m_bitmapsCheckbox
[IndicatorState_MaxCtrl
][IndicatorStatus_Max
],
434 m_bitmapsRadiobtn
[IndicatorState_MaxCtrl
][IndicatorStatus_Max
];
436 // the line wrap bitmap (drawn at the end of wrapped lines)
437 wxBitmap m_bmpLineWrap
;
439 // the combobox bitmaps
449 wxBitmap m_bitmapsCombo
[ComboState_Max
];
452 // ----------------------------------------------------------------------------
453 // wxGTKInputHandler and derived classes: process the keyboard and mouse
454 // messages according to GTK standards
455 // ----------------------------------------------------------------------------
457 class wxGTKInputHandler
: public wxInputHandler
460 wxGTKInputHandler() { }
462 virtual bool HandleKey(wxInputConsumer
*control
,
463 const wxKeyEvent
& event
,
465 virtual bool HandleMouse(wxInputConsumer
*control
,
466 const wxMouseEvent
& event
);
467 virtual bool HandleMouseMove(wxInputConsumer
*control
,
468 const wxMouseEvent
& event
);
473 class wxGTKScrollBarInputHandler
: public wxStdScrollBarInputHandler
476 wxGTKScrollBarInputHandler(wxRenderer
*renderer
, wxInputHandler
*handler
)
477 : wxStdScrollBarInputHandler(renderer
, handler
) { }
480 virtual void Highlight(wxScrollBar
*scrollbar
, bool doIt
)
482 // only arrows and the thumb can be highlighted
483 if ( !IsArrow() && m_htLast
!= wxHT_SCROLLBAR_THUMB
)
486 wxStdScrollBarInputHandler::Highlight(scrollbar
, doIt
);
489 virtual void Press(wxScrollBar
*scrollbar
, bool doIt
)
491 // only arrows can be pressed
495 wxStdScrollBarInputHandler::Press(scrollbar
, doIt
);
498 // any button can be used to drag the scrollbar under GTK+
499 virtual bool IsAllowedButton(int WXUNUSED(button
)) const { return true; }
503 return m_htLast
== wxHT_SCROLLBAR_ARROW_LINE_1
||
504 m_htLast
== wxHT_SCROLLBAR_ARROW_LINE_2
;
508 #endif // wxUSE_SCROLLBAR
512 class wxGTKCheckboxInputHandler
: public wxStdInputHandler
515 wxGTKCheckboxInputHandler(wxInputHandler
*handler
)
516 : wxStdInputHandler(handler
) { }
518 virtual bool HandleKey(wxInputConsumer
*control
,
519 const wxKeyEvent
& event
,
523 #endif // wxUSE_CHECKBOX
527 class wxGTKTextCtrlInputHandler
: public wxStdInputHandler
530 wxGTKTextCtrlInputHandler(wxInputHandler
*handler
)
531 : wxStdInputHandler(handler
) { }
533 virtual bool HandleKey(wxInputConsumer
*control
,
534 const wxKeyEvent
& event
,
538 #endif // wxUSE_TEXTCTRL
540 // ----------------------------------------------------------------------------
541 // wxGTKColourScheme: uses the standard GTK colours
542 // ----------------------------------------------------------------------------
544 class wxGTKColourScheme
: public wxColourScheme
547 virtual wxColour
Get(StdColour col
) const;
548 virtual wxColour
GetBackground(wxWindow
*win
) const;
551 // ----------------------------------------------------------------------------
553 // ----------------------------------------------------------------------------
555 class wxGTKArtProvider
: public wxArtProvider
558 virtual wxBitmap
CreateBitmap(const wxArtID
& id
,
559 const wxArtClient
& client
,
563 // ----------------------------------------------------------------------------
565 // ----------------------------------------------------------------------------
567 WX_DEFINE_ARRAY_PTR(wxInputHandler
*, wxArrayHandlers
);
569 class wxGTKTheme
: public wxTheme
573 virtual ~wxGTKTheme();
575 virtual wxRenderer
*GetRenderer();
576 virtual wxArtProvider
*GetArtProvider();
577 virtual wxInputHandler
*GetInputHandler(const wxString
& control
,
578 wxInputConsumer
*consumer
);
579 virtual wxColourScheme
*GetColourScheme();
582 wxGTKRenderer
*m_renderer
;
584 wxGTKArtProvider
*m_artProvider
;
586 // the names of the already created handlers and the handlers themselves
587 // (these arrays are synchronized)
588 wxSortedArrayString m_handlerNames
;
589 wxArrayHandlers m_handlers
;
591 wxGTKColourScheme
*m_scheme
;
593 WX_DECLARE_THEME(gtk
)
596 // ============================================================================
598 // ============================================================================
600 WX_IMPLEMENT_THEME(wxGTKTheme
, gtk
, wxTRANSLATE("GTK+ theme"));
602 // ----------------------------------------------------------------------------
604 // ----------------------------------------------------------------------------
606 wxGTKTheme::wxGTKTheme()
610 m_artProvider
= NULL
;
613 wxGTKTheme::~wxGTKTheme()
617 wxArtProvider::RemoveProvider(m_artProvider
);
620 wxRenderer
*wxGTKTheme::GetRenderer()
624 m_renderer
= new wxGTKRenderer(GetColourScheme());
630 wxArtProvider
*wxGTKTheme::GetArtProvider()
632 if ( !m_artProvider
)
634 m_artProvider
= new wxGTKArtProvider
;
637 return m_artProvider
;
640 wxColourScheme
*wxGTKTheme::GetColourScheme()
644 m_scheme
= new wxGTKColourScheme
;
649 wxInputHandler
*wxGTKTheme::GetInputHandler(const wxString
& control
,
650 wxInputConsumer
*consumer
)
652 wxInputHandler
*handler
= NULL
;
653 int n
= m_handlerNames
.Index(control
);
654 if ( n
== wxNOT_FOUND
)
656 static wxGTKInputHandler s_handlerDef
;
658 wxInputHandler
* const
659 handlerStd
= consumer
->DoGetStdInputHandler(&s_handlerDef
);
661 // create a new handler
663 if ( control
== wxINP_HANDLER_CHECKBOX
)
665 static wxGTKCheckboxInputHandler
s_handler(handlerStd
);
667 handler
= &s_handler
;
670 #endif // wxUSE_CHECKBOX
672 if ( control
== wxINP_HANDLER_SCROLLBAR
)
674 static wxGTKScrollBarInputHandler
s_handler(m_renderer
, handlerStd
);
676 handler
= &s_handler
;
679 #endif // wxUSE_SCROLLBAR
681 if ( control
== wxINP_HANDLER_TEXTCTRL
)
683 static wxGTKTextCtrlInputHandler
s_handler(handlerStd
);
685 handler
= &s_handler
;
688 #endif // wxUSE_TEXTCTRL
690 // no special handler for this control
691 handler
= handlerStd
;
694 n
= m_handlerNames
.Add(control
);
695 m_handlers
.Insert(handler
, n
);
697 else // we already have it
699 handler
= m_handlers
[n
];
705 // ============================================================================
707 // ============================================================================
709 wxColour
wxGTKColourScheme::GetBackground(wxWindow
*win
) const
712 if ( win
->UseBgCol() )
714 // use the user specified colour
715 col
= win
->GetBackgroundColour();
718 if ( !win
->ShouldInheritColours() )
720 // doesn't depend on the state
728 int flags
= win
->GetStateFlags();
730 // the colour set by the user should be used for the normal state
731 // and for the states for which we don't have any specific colours
732 if ( !col
.Ok() || (flags
!= 0) )
735 if ( wxDynamicCast(win
, wxScrollBar
) )
736 col
= Get(SCROLLBAR
);
738 #endif //wxUSE_SCROLLBAR
739 if ( (flags
& wxCONTROL_CURRENT
) && win
->CanBeHighlighted() )
740 col
= Get(CONTROL_CURRENT
);
741 else if ( flags
& wxCONTROL_PRESSED
)
742 col
= Get(CONTROL_PRESSED
);
751 wxColour
wxGTKColourScheme::Get(wxGTKColourScheme::StdColour col
) const
755 case WINDOW
: return *wxWHITE
;
757 case SHADOW_DARK
: return *wxBLACK
;
758 case SHADOW_HIGHLIGHT
: return *wxWHITE
;
759 case SHADOW_IN
: return wxColour(0xd6d6d6);
760 case SHADOW_OUT
: return wxColour(0x969696);
762 case CONTROL
: return wxColour(0xd6d6d6);
763 case CONTROL_PRESSED
: return wxColour(0xc3c3c3);
764 case CONTROL_CURRENT
: return wxColour(0xeaeaea);
766 case CONTROL_TEXT
: return *wxBLACK
;
767 case CONTROL_TEXT_DISABLED
:
768 return wxColour(0x757575);
769 case CONTROL_TEXT_DISABLED_SHADOW
:
773 case SCROLLBAR_PRESSED
: return wxColour(0xc3c3c3);
775 case HIGHLIGHT
: return wxColour(0x9c0000);
776 case HIGHLIGHT_TEXT
: return wxColour(0xffffff);
778 case GAUGE
: return Get(CONTROL_CURRENT
);
780 case TITLEBAR
: return wxColour(0xaeaaae);
781 case TITLEBAR_ACTIVE
: return wxColour(0x820300);
782 case TITLEBAR_TEXT
: return wxColour(0xc0c0c0);
783 case TITLEBAR_ACTIVE_TEXT
:
786 case DESKTOP
: return *wxBLACK
;
790 wxFAIL_MSG(_T("invalid standard colour"));
795 // ============================================================================
797 // ============================================================================
799 // ----------------------------------------------------------------------------
801 // ----------------------------------------------------------------------------
803 wxGTKRenderer::wxGTKRenderer(const wxColourScheme
*scheme
)
804 : wxStdRenderer(scheme
)
806 m_sizeScrollbarArrow
= wxSize(15, 14);
808 m_penGrey
= wxPen(wxSCHEME_COLOUR(scheme
, SCROLLBAR
));
811 // ----------------------------------------------------------------------------
813 // ----------------------------------------------------------------------------
815 void wxGTKRenderer::DrawAntiShadedRectSide(wxDC
& dc
,
821 dc
.SetPen(dir
== wxLEFT
|| dir
== wxUP
? pen1
: pen2
);
826 dc
.DrawLine(rect
.GetLeft(), rect
.GetTop(),
827 rect
.GetLeft(), rect
.GetBottom() + 1);
831 dc
.DrawLine(rect
.GetLeft(), rect
.GetTop(),
832 rect
.GetRight() + 1, rect
.GetTop());
836 dc
.DrawLine(rect
.GetRight(), rect
.GetTop(),
837 rect
.GetRight(), rect
.GetBottom() + 1);
841 dc
.DrawLine(rect
.GetLeft(), rect
.GetBottom(),
842 rect
.GetRight() + 1, rect
.GetBottom());
846 wxFAIL_MSG(_T("unknown rectangle side"));
850 void wxGTKRenderer::DrawAntiShadedRect(wxDC
& dc
, wxRect
*rect
,
851 const wxPen
& pen1
, const wxPen
& pen2
)
853 // draw the rectangle
855 dc
.DrawLine(rect
->GetLeft(), rect
->GetTop(),
856 rect
->GetLeft(), rect
->GetBottom() + 1);
857 dc
.DrawLine(rect
->GetLeft() + 1, rect
->GetTop(),
858 rect
->GetRight() + 1, rect
->GetTop());
860 dc
.DrawLine(rect
->GetRight(), rect
->GetTop() + 1,
861 rect
->GetRight(), rect
->GetBottom());
862 dc
.DrawLine(rect
->GetLeft() + 1, rect
->GetBottom(),
863 rect
->GetRight() + 1, rect
->GetBottom());
869 void wxGTKRenderer::DrawInnerShadedRect(wxDC
& dc
, wxRect
*rect
)
871 DrawAntiShadedRect(dc
, rect
, m_penDarkGrey
, m_penHighlight
);
872 DrawAntiShadedRect(dc
, rect
, m_penBlack
, m_penHighlight
);
875 void wxGTKRenderer::DrawAntiRaisedBorder(wxDC
& dc
, wxRect
*rect
)
877 DrawShadedRect(dc
, rect
, m_penHighlight
, m_penBlack
);
878 DrawAntiShadedRect(dc
, rect
, m_penLightGrey
, m_penDarkGrey
);
881 void wxGTKRenderer::DrawSunkenBorder(wxDC
& dc
, wxRect
*rect
)
883 DrawAntiShadedRect(dc
, rect
, m_penDarkGrey
, m_penHighlight
);
884 DrawShadedRect(dc
, rect
, m_penBlack
, m_penLightGrey
);
887 void wxGTKRenderer::DrawFocusRect(wxDC
& dc
, const wxRect
& rect
)
889 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
890 wxRect rectFocus
= rect
;
891 DrawRect(dc
, &rectFocus
, m_penBlack
);
894 void wxGTKRenderer::DrawTextBorder(wxDC
& dc
,
896 const wxRect
& rectOrig
,
900 wxRect rect
= rectOrig
;
902 if ( border
!= wxBORDER_NONE
)
904 if ( flags
& wxCONTROL_FOCUSED
)
906 DrawRect(dc
, &rect
, m_penBlack
);
907 DrawAntiShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
911 DrawInnerShadedRect(dc
, &rect
);
919 void wxGTKRenderer::DrawButtonLabel(wxDC
& dc
,
920 const wxString
& label
,
921 const wxBitmap
& image
,
928 // no focus rect around buttons label in GTK+
929 wxStdRenderer::DrawButtonLabel(dc
, label
, image
, rect
, flags
,
930 alignment
, indexAccel
, rectBounds
);
933 void wxGTKRenderer::DrawButtonBorder(wxDC
& dc
,
934 const wxRect
& rectTotal
,
938 wxRect rect
= rectTotal
;
940 if ( flags
& wxCONTROL_PRESSED
)
942 // button pressed: draw a black border around it and an inward shade
943 DrawRect(dc
, &rect
, m_penBlack
);
945 DrawInnerShadedRect(dc
, &rect
);
947 else // button not pressed
949 if ( flags
& wxCONTROL_ISDEFAULT
)
954 if ( flags
& wxCONTROL_FOCUSED
)
956 // button is currently default: add an extra border around it
957 DrawRect(dc
, &rect
, m_penBlack
);
960 // now draw a normal button
961 DrawShadedRect(dc
, &rect
, m_penHighlight
, m_penBlack
);
962 DrawAntiShadedRect(dc
, &rect
, GetBackgroundColour(flags
), m_penDarkGrey
);
969 // ----------------------------------------------------------------------------
971 // ----------------------------------------------------------------------------
973 void wxGTKRenderer::DrawFrameWithLabel(wxDC
& dc
,
974 const wxString
& label
,
975 const wxRect
& rectFrame
,
976 const wxRect
& rectTextOrig
,
981 wxRect
rectText(rectTextOrig
);
982 rectText
.Inflate(1, 0);
985 DrawLabel(dc
, label
, rectText
, flags
, alignment
, indexAccel
, &rectLabel
);
987 rectLabel
.width
+= 2;
989 DrawFrameWithoutLabel(dc
, rectFrame
, rectLabel
);
991 // GTK+ does it like this
992 dc
.SetPen(m_penHighlight
);
993 dc
.DrawPoint(rectText
.x
, rectFrame
.y
);
994 dc
.DrawPoint(rectText
.x
+ rectLabel
.width
- 3, rectFrame
.y
);
997 // ----------------------------------------------------------------------------
999 // ----------------------------------------------------------------------------
1001 void wxGTKRenderer::DrawCheckItem(wxDC
& dc
,
1002 const wxString
& label
,
1003 const wxBitmap
& bitmap
,
1007 wxRect rectBitmap
= rect
;
1009 rectBitmap
.width
= GetCheckBitmapSize().x
;
1011 // never draw the focus rect around the check indicators here
1012 DrawCheckButton(dc
, wxEmptyString
, bitmap
, rectBitmap
, flags
& ~wxCONTROL_FOCUSED
);
1014 wxRect rectLabel
= rect
;
1015 wxCoord shift
= rectBitmap
.width
+ 2*GetCheckItemMargin();
1016 rectLabel
.x
+= shift
;
1017 rectLabel
.width
-= shift
;
1018 DrawItem(dc
, label
, rectLabel
, flags
);
1021 // ----------------------------------------------------------------------------
1022 // check/radion buttons
1023 // ----------------------------------------------------------------------------
1025 void wxGTKRenderer::DrawUndeterminedBitmap(wxDC
& dc
,
1026 const wxRect
& rectTotal
,
1029 // FIXME: For sure it is not GTK look but it is better than nothing.
1030 // Show me correct look and I will immediatelly make it better (ABX)
1031 wxRect rect
= rectTotal
;
1033 wxColour col1
, col2
;
1037 col1
= wxSCHEME_COLOUR(m_scheme
, SHADOW_DARK
);
1038 col2
= wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
);
1042 col1
= wxSCHEME_COLOUR(m_scheme
, SHADOW_DARK
);
1043 col2
= wxSCHEME_COLOUR(m_scheme
, SHADOW_IN
);
1046 dc
.SetPen(*wxTRANSPARENT_PEN
);
1048 dc
.DrawRectangle(rect
);
1051 dc
.DrawRectangle(rect
);
1054 void wxGTKRenderer::DrawUncheckBitmap(wxDC
& dc
,
1055 const wxRect
& rectTotal
,
1058 wxRect rect
= rectTotal
;
1059 DrawAntiRaisedBorder(dc
, &rect
);
1061 wxColour col
= wxSCHEME_COLOUR(m_scheme
, SHADOW_IN
);
1062 dc
.SetPen(wxPen(col
));
1063 dc
.DrawPoint(rect
.GetRight() - 1, rect
.GetBottom() - 1);
1066 col
= wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
);
1067 //else: it is SHADOW_IN, leave as is
1069 dc
.SetPen(*wxTRANSPARENT_PEN
);
1071 dc
.DrawRectangle(rect
);
1074 void wxGTKRenderer::DrawCheckBitmap(wxDC
& dc
, const wxRect
& rectTotal
)
1076 wxRect rect
= rectTotal
;
1077 DrawAntiShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
1078 DrawShadedRect(dc
, &rect
, m_penBlack
, m_penLightGrey
);
1080 dc
.SetPen(*wxTRANSPARENT_PEN
);
1081 dc
.SetBrush(wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
));
1082 dc
.DrawRectangle(rect
);
1085 void wxGTKRenderer::DrawRadioBitmap(wxDC
& dc
,
1091 xRight
= rect
.GetRight(),
1092 yBottom
= rect
.GetBottom();
1094 wxCoord yMid
= (y
+ yBottom
) / 2;
1096 // then draw the upper half
1097 dc
.SetPen(flags
& wxCONTROL_CHECKED
? m_penDarkGrey
: m_penHighlight
);
1098 DrawUpZag(dc
, x
, xRight
, yMid
, y
);
1099 DrawUpZag(dc
, x
+ 1, xRight
- 1, yMid
, y
+ 1);
1102 if ( flags
& wxCONTROL_CHECKED
)
1103 dc
.SetPen(m_penBlack
);
1104 else if ( flags
& wxCONTROL_PRESSED
)
1105 dc
.SetPen(wxPen(wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
)));
1106 else // unchecked and unpressed
1110 DrawUpZag(dc
, x
+ 2, xRight
- 2, yMid
, y
+ 2);
1112 // and then the lower one
1113 dc
.SetPen(flags
& wxCONTROL_CHECKED
? m_penHighlight
: m_penBlack
);
1114 DrawDownZag(dc
, x
, xRight
, yMid
, yBottom
);
1115 if ( !(flags
& wxCONTROL_CHECKED
) )
1116 dc
.SetPen(m_penDarkGrey
);
1117 DrawDownZag(dc
, x
+ 1, xRight
- 1, yMid
, yBottom
- 1);
1119 if ( !(flags
& wxCONTROL_CHECKED
) )
1120 drawIt
= true; // with the same pen
1121 else if ( flags
& wxCONTROL_PRESSED
)
1123 dc
.SetPen(wxPen(wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
)));
1126 else // checked and unpressed
1130 DrawDownZag(dc
, x
+ 2, xRight
- 2, yMid
, yBottom
- 2);
1133 void wxGTKRenderer::DrawUpZag(wxDC
& dc
,
1139 wxCoord xMid
= (x1
+ x2
) / 2;
1140 dc
.DrawLine(x1
, y1
, xMid
, y2
);
1141 dc
.DrawLine(xMid
, y2
, x2
+ 1, y1
+ 1);
1144 void wxGTKRenderer::DrawDownZag(wxDC
& dc
,
1150 wxCoord xMid
= (x1
+ x2
) / 2;
1151 dc
.DrawLine(x1
+ 1, y1
+ 1, xMid
, y2
);
1152 dc
.DrawLine(xMid
, y2
, x2
, y1
);
1155 wxBitmap
wxGTKRenderer::GetCheckBitmap(int flags
)
1157 if ( !m_bitmapsCheckbox
[0][0].Ok() )
1159 // init the bitmaps once only
1161 wxSize size
= GetCheckBitmapSize();
1162 rect
.width
= size
.x
;
1163 rect
.height
= size
.y
;
1164 for ( int i
= 0; i
< 2; i
++ )
1166 for ( int j
= 0; j
< 3; j
++ )
1167 m_bitmapsCheckbox
[i
][j
].Create(rect
.width
, rect
.height
);
1173 dc
.SelectObject(m_bitmapsCheckbox
[0][0]);
1174 DrawCheckBitmap(dc
, rect
);
1177 dc
.SelectObject(m_bitmapsCheckbox
[0][1]);
1178 DrawUncheckBitmap(dc
, rect
, false);
1180 // normal undeterminated
1181 dc
.SelectObject(m_bitmapsCheckbox
[0][2]);
1182 DrawUndeterminedBitmap(dc
, rect
, false);
1185 m_bitmapsCheckbox
[1][0] = m_bitmapsCheckbox
[0][0];
1187 // pressed unchecked
1188 dc
.SelectObject(m_bitmapsCheckbox
[1][1]);
1189 DrawUncheckBitmap(dc
, rect
, true);
1191 // pressed undeterminated
1192 dc
.SelectObject(m_bitmapsCheckbox
[1][2]);
1193 DrawUndeterminedBitmap(dc
, rect
, true);
1196 IndicatorState state
;
1197 IndicatorStatus status
;
1198 GetIndicatorsFromFlags(flags
, state
, status
);
1200 // disabled looks the same as normal
1201 if ( state
== IndicatorState_Disabled
)
1202 state
= IndicatorState_Normal
;
1204 return m_bitmapsCheckbox
[state
][status
];
1207 wxBitmap
wxGTKRenderer::GetRadioBitmap(int flags
)
1209 IndicatorState state
;
1210 IndicatorStatus status
;
1211 GetIndicatorsFromFlags(flags
, state
, status
);
1213 wxBitmap
& bmp
= m_bitmapsRadiobtn
[state
][status
];
1216 const wxSize size
= GetRadioBitmapSize();
1219 bmp
.Create(size
.x
, size
.y
);
1220 dc
.SelectObject(bmp
);
1222 DrawRadioBitmap(dc
, size
, flags
);
1228 wxBitmap
wxGTKRenderer::GetLineWrapBitmap() const
1230 if ( !m_bmpLineWrap
.Ok() )
1232 // the line wrap bitmap as used by GTK+
1233 #define line_wrap_width 6
1234 #define line_wrap_height 9
1235 static const char line_wrap_bits
[] =
1237 0x1e, 0x3e, 0x30, 0x30, 0x39, 0x1f, 0x0f, 0x0f, 0x1f,
1240 wxBitmap
bmpLineWrap(line_wrap_bits
, line_wrap_width
, line_wrap_height
);
1241 if ( !bmpLineWrap
.Ok() )
1243 wxFAIL_MSG( _T("Failed to create line wrap XBM") );
1247 wxConstCast(this, wxGTKRenderer
)->m_bmpLineWrap
= bmpLineWrap
;
1251 return m_bmpLineWrap
;
1255 void wxGTKRenderer::DrawToolBarButton(wxDC
& dc
,
1256 const wxString
& label
,
1257 const wxBitmap
& bitmap
,
1258 const wxRect
& rectOrig
,
1260 long WXUNUSED(style
),
1263 // we don't draw the separators at all
1264 if ( !label
.empty() || bitmap
.Ok() )
1266 wxRect rect
= rectOrig
;
1267 rect
.Deflate(BORDER_THICKNESS
);
1269 if ( flags
& wxCONTROL_PRESSED
)
1271 DrawBorder(dc
, wxBORDER_SUNKEN
, rect
, flags
, &rect
);
1273 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
), rect
);
1275 else if ( flags
& wxCONTROL_CURRENT
)
1277 DrawBorder(dc
, wxBORDER_RAISED
, rect
, flags
, &rect
);
1279 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL_CURRENT
), rect
);
1282 if(tbarStyle
& wxTB_TEXT
)
1284 if(tbarStyle
& wxTB_HORIZONTAL
)
1286 dc
.DrawLabel(label
, bitmap
, rect
, wxALIGN_CENTRE
);
1290 dc
.DrawLabel(label
, bitmap
, rect
, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
);
1295 int xpoint
= (rect
.GetLeft() + rect
.GetRight() + 1 - bitmap
.GetWidth()) / 2;
1296 int ypoint
= (rect
.GetTop() + rect
.GetBottom() + 1 - bitmap
.GetHeight()) / 2;
1297 dc
.DrawBitmap(bitmap
, xpoint
, ypoint
);
1301 #endif // wxUSE_TOOLBAR
1303 // ----------------------------------------------------------------------------
1305 // ----------------------------------------------------------------------------
1309 wxRect
wxGTKRenderer::GetTextTotalArea(const wxTextCtrl
* WXUNUSED(text
),
1310 const wxRect
& rect
) const
1312 wxRect rectTotal
= rect
;
1313 rectTotal
.Inflate(2*BORDER_THICKNESS
);
1317 wxRect
wxGTKRenderer::GetTextClientArea(const wxTextCtrl
*text
,
1319 wxCoord
*extraSpaceBeyond
) const
1321 wxRect rectText
= rect
;
1322 rectText
.Deflate(2*BORDER_THICKNESS
);
1324 if ( text
->WrapLines() )
1326 // leave enough for the line wrap bitmap indicator
1327 wxCoord widthMark
= GetLineWrapBitmap().GetWidth() + 2;
1329 rectText
.width
-= widthMark
;
1331 if ( extraSpaceBeyond
)
1332 *extraSpaceBeyond
= widthMark
;
1338 #endif // wxUSE_TEXTCTRL
1340 void wxGTKRenderer::DrawLineWrapMark(wxDC
& dc
, const wxRect
& rect
)
1342 wxBitmap bmpLineWrap
= GetLineWrapBitmap();
1344 // for a mono bitmap he colours it appears in depends on the current text
1345 // colours, so set them correctly
1347 if ( bmpLineWrap
.GetDepth() == 1 )
1349 colFgOld
= dc
.GetTextForeground();
1351 // FIXME: I wonder what should we do if the background is black too?
1352 dc
.SetTextForeground(*wxBLACK
);
1355 dc
.DrawBitmap(bmpLineWrap
,
1356 rect
.x
, rect
.y
+ (rect
.height
- bmpLineWrap
.GetHeight())/2);
1358 if ( colFgOld
.Ok() )
1360 // restore old colour
1361 dc
.SetTextForeground(colFgOld
);
1365 // ----------------------------------------------------------------------------
1367 // ----------------------------------------------------------------------------
1371 void wxGTKRenderer::DrawTab(wxDC
& dc
,
1372 const wxRect
& rectOrig
,
1374 const wxString
& label
,
1375 const wxBitmap
& bitmap
,
1379 #define SELECT_FOR_VERTICAL(X,Y) ( isVertical ? Y : X )
1380 #define REVERSE_FOR_VERTICAL(X,Y) \
1381 SELECT_FOR_VERTICAL(X,Y) \
1383 SELECT_FOR_VERTICAL(Y,X)
1385 wxRect rect
= rectOrig
;
1387 bool isVertical
= ( dir
== wxLEFT
) || ( dir
== wxRIGHT
);
1389 // the current tab is drawn indented (to the top for default case) and
1390 // bigger than the other ones
1391 const wxSize indent
= GetTabIndent();
1392 if ( flags
& wxCONTROL_SELECTED
)
1394 rect
.Inflate( SELECT_FOR_VERTICAL( indent
.x
, 0),
1395 SELECT_FOR_VERTICAL( 0, indent
.y
));
1399 wxFAIL_MSG(_T("invaild notebook tab orientation"));
1406 rect
.height
+= indent
.y
;
1413 rect
.width
+= indent
.x
;
1418 // selected tab has different colour
1419 wxColour col
= flags
& wxCONTROL_SELECTED
1420 ? wxSCHEME_COLOUR(m_scheme
, SHADOW_IN
)
1421 : wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
);
1422 DrawSolidRect(dc
, col
, rect
);
1424 if ( flags
& wxCONTROL_FOCUSED
)
1426 // draw the focus rect
1427 wxRect rectBorder
= rect
;
1428 rectBorder
.Deflate(4, 3);
1429 if ( dir
== wxBOTTOM
)
1430 rectBorder
.Offset(0, -1);
1431 if ( dir
== wxRIGHT
)
1432 rectBorder
.Offset(-1, 0);
1434 DrawRect(dc
, &rectBorder
, m_penBlack
);
1437 // draw the text, image and the focus around them (if necessary)
1438 wxRect
rectLabel( REVERSE_FOR_VERTICAL(rect
.x
,rect
.y
),
1439 REVERSE_FOR_VERTICAL(rect
.width
,rect
.height
)
1441 rectLabel
.Deflate(1, 1);
1444 // draw it horizontally into memory and rotate for screen
1446 wxBitmap bitmapRotated
,
1447 bitmapMem( rectLabel
.x
+ rectLabel
.width
,
1448 rectLabel
.y
+ rectLabel
.height
);
1449 dcMem
.SelectObject(bitmapMem
);
1450 dcMem
.SetBackground(dc
.GetBackground());
1451 dcMem
.SetFont(dc
.GetFont());
1452 dcMem
.SetTextForeground(dc
.GetTextForeground());
1456 wxBitmap( wxImage( bitmap
.ConvertToImage() ).Rotate90(dir
==wxLEFT
) )
1459 #endif // wxUSE_IMAGE
1461 dcMem
.DrawLabel(label
, bitmapRotated
, rectLabel
, wxALIGN_CENTRE
, indexAccel
);
1462 dcMem
.SelectObject(wxNullBitmap
);
1463 bitmapMem
= bitmapMem
.GetSubBitmap(rectLabel
);
1465 bitmapMem
= wxBitmap(wxImage(bitmapMem
.ConvertToImage()).Rotate90(dir
==wxRIGHT
))
1469 dc
.DrawBitmap(bitmapMem
, rectLabel
.y
, rectLabel
.x
, false);
1473 dc
.DrawLabel(label
, bitmap
, rectLabel
, wxALIGN_CENTRE
, indexAccel
);
1476 // now draw the tab itself
1477 wxCoord x
= SELECT_FOR_VERTICAL(rect
.x
,rect
.y
),
1478 y
= SELECT_FOR_VERTICAL(rect
.y
,rect
.x
),
1479 x2
= SELECT_FOR_VERTICAL(rect
.GetRight(),rect
.GetBottom()),
1480 y2
= SELECT_FOR_VERTICAL(rect
.GetBottom(),rect
.GetRight());
1486 // left orientation looks like top but IsVertical makes x and y reversed
1488 // top is not vertical so use coordinates in written order
1489 dc
.SetPen(m_penHighlight
);
1490 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y2
),
1491 REVERSE_FOR_VERTICAL(x
, y
));
1492 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
),
1493 REVERSE_FOR_VERTICAL(x2
, y
));
1495 dc
.SetPen(m_penBlack
);
1496 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y2
),
1497 REVERSE_FOR_VERTICAL(x2
, y
));
1499 dc
.SetPen(m_penDarkGrey
);
1500 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
- 1, y2
),
1501 REVERSE_FOR_VERTICAL(x2
- 1, y
+ 1));
1503 if ( flags
& wxCONTROL_SELECTED
)
1505 dc
.SetPen(m_penLightGrey
);
1507 // overwrite the part of the border below this tab
1508 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
+ 1),
1509 REVERSE_FOR_VERTICAL(x2
- 1, y2
+ 1));
1511 // and the shadow of the tab to the left of us
1512 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
+ 2),
1513 REVERSE_FOR_VERTICAL(x
+ 1, y2
+ 1));
1518 // right orientation looks like bottom but IsVertical makes x and y reversed
1520 // bottom is not vertical so use coordinates in written order
1521 dc
.SetPen(m_penHighlight
);
1523 // we need to continue one pixel further to overwrite the corner of
1524 // the border for the selected tab
1525 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y
- (flags
& wxCONTROL_SELECTED
? 1 : 0)),
1526 REVERSE_FOR_VERTICAL(x
, y2
));
1528 // it doesn't work like this (TODO: implement it properly)
1530 // erase the corner of the tab to the right
1531 dc
.SetPen(m_penLightGrey
);
1532 dc
.DrawPoint(REVERSE_FOR_VERTICAL(x2
- 1, y
- 2));
1533 dc
.DrawPoint(REVERSE_FOR_VERTICAL(x2
- 2, y
- 2));
1534 dc
.DrawPoint(REVERSE_FOR_VERTICAL(x2
- 2, y
- 1));
1537 dc
.SetPen(m_penBlack
);
1538 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
),
1539 REVERSE_FOR_VERTICAL(x2
, y2
));
1540 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y
),
1541 REVERSE_FOR_VERTICAL(x2
, y2
));
1543 dc
.SetPen(m_penDarkGrey
);
1544 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 2, y2
- 1),
1545 REVERSE_FOR_VERTICAL(x2
- 1, y2
- 1));
1546 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
- 1, y
),
1547 REVERSE_FOR_VERTICAL(x2
- 1, y2
));
1549 if ( flags
& wxCONTROL_SELECTED
)
1551 dc
.SetPen(m_penLightGrey
);
1553 // overwrite the part of the (double!) border above this tab
1554 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
- 1),
1555 REVERSE_FOR_VERTICAL(x2
- 1, y
- 1));
1556 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
- 2),
1557 REVERSE_FOR_VERTICAL(x2
- 1, y
- 2));
1559 // and the shadow of the tab to the left of us
1560 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
- 1),
1561 REVERSE_FOR_VERTICAL(x
+ 1, y
- 1));
1567 #endif // wxUSE_NOTEBOOK
1569 // ----------------------------------------------------------------------------
1571 // ----------------------------------------------------------------------------
1575 wxSize
wxGTKRenderer::GetSliderThumbSize(const wxRect
& rect
,
1577 wxOrientation orient
) const
1579 static const wxCoord SLIDER_THUMB_LENGTH
= 30;
1583 wxRect rectShaft
= GetSliderShaftRect(rect
, lenThumb
, orient
);
1584 if ( orient
== wxHORIZONTAL
)
1586 size
.x
= wxMin(SLIDER_THUMB_LENGTH
, rectShaft
.width
);
1587 size
.y
= rectShaft
.height
;
1591 size
.y
= wxMin(SLIDER_THUMB_LENGTH
, rectShaft
.height
);
1592 size
.x
= rectShaft
.width
;
1598 wxRect
wxGTKRenderer::GetSliderShaftRect(const wxRect
& rect
,
1599 int WXUNUSED(lenThumb
),
1600 wxOrientation
WXUNUSED(orient
),
1601 long WXUNUSED(style
)) const
1603 return rect
.Deflate(2*BORDER_THICKNESS
, 2*BORDER_THICKNESS
);
1606 void wxGTKRenderer::DrawSliderShaft(wxDC
& dc
,
1607 const wxRect
& rectOrig
,
1608 int WXUNUSED(lenThumb
),
1609 wxOrientation
WXUNUSED(orient
),
1611 long WXUNUSED(style
),
1614 wxRect rect
= rectOrig
;
1616 // draw the border first
1617 if ( flags
& wxCONTROL_FOCUSED
)
1619 DrawRect(dc
, &rect
, m_penBlack
);
1621 else // not focused, normal
1623 DrawAntiShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
1626 DrawAntiShadedRect(dc
, &rect
, m_penBlack
, m_penLightGrey
);
1628 // and the background
1629 DrawSolidRect(dc
, wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
), rect
);
1635 void wxGTKRenderer::DrawSliderThumb(wxDC
& dc
,
1636 const wxRect
& rectOrig
,
1637 wxOrientation orient
,
1638 int WXUNUSED(flags
),
1639 long WXUNUSED(style
))
1641 // draw the thumb border
1642 wxRect rect
= rectOrig
;
1643 DrawAntiRaisedBorder(dc
, &rect
);
1645 // draw the handle in the middle
1646 if ( orient
== wxVERTICAL
)
1648 rect
.height
= 2*BORDER_THICKNESS
;
1649 rect
.y
= rectOrig
.y
+ (rectOrig
.height
- rect
.height
) / 2;
1653 rect
.width
= 2*BORDER_THICKNESS
;
1654 rect
.x
= rectOrig
.x
+ (rectOrig
.width
- rect
.width
) / 2;
1657 DrawShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
1660 #endif // wxUSE_SLIDER
1664 // ----------------------------------------------------------------------------
1666 // ----------------------------------------------------------------------------
1668 // wxGTKMenuGeometryInfo: the wxMenuGeometryInfo used by wxGTKRenderer
1669 class WXDLLEXPORT wxGTKMenuGeometryInfo
: public wxMenuGeometryInfo
1672 virtual wxSize
GetSize() const { return m_size
; }
1674 wxCoord
GetLabelOffset() const { return m_ofsLabel
; }
1675 wxCoord
GetAccelOffset() const { return m_ofsAccel
; }
1677 wxCoord
GetItemHeight() const { return m_heightItem
; }
1680 // the total size of the menu
1683 // the offset of the start of the menu item label
1686 // the offset of the start of the accel label
1689 // the height of a normal (not separator) item
1690 wxCoord m_heightItem
;
1692 friend wxMenuGeometryInfo
*
1693 wxGTKRenderer::GetMenuGeometry(wxWindow
*, const wxMenu
&) const;
1696 // FIXME: all constants are hardcoded but shouldn't be
1697 static const wxCoord MENU_LEFT_MARGIN
= 9;
1698 static const wxCoord MENU_RIGHT_MARGIN
= 6;
1700 static const wxCoord MENU_HORZ_MARGIN
= 6;
1701 static const wxCoord MENU_VERT_MARGIN
= 3;
1703 // the margin around bitmap/check marks (on each side)
1704 static const wxCoord MENU_BMP_MARGIN
= 2;
1706 // the margin between the labels and accel strings
1707 static const wxCoord MENU_ACCEL_MARGIN
= 8;
1709 // the separator height in pixels: in fact, strangely enough, the real height
1710 // is 2 but Windows adds one extra pixel in the bottom margin, so take it into
1712 static const wxCoord MENU_SEPARATOR_HEIGHT
= 3;
1714 // the size of the standard checkmark bitmap
1715 static const wxCoord MENU_CHECK_SIZE
= 9;
1717 void wxGTKRenderer::DrawMenuBarItem(wxDC
& dc
,
1719 const wxString
& label
,
1723 DoDrawMenuItem(dc
, rect
, label
, flags
, indexAccel
);
1726 void wxGTKRenderer::DrawMenuItem(wxDC
& dc
,
1728 const wxMenuGeometryInfo
& gi
,
1729 const wxString
& label
,
1730 const wxString
& accel
,
1731 const wxBitmap
& bitmap
,
1735 const wxGTKMenuGeometryInfo
& geomInfo
= (const wxGTKMenuGeometryInfo
&)gi
;
1740 rect
.width
= geomInfo
.GetSize().x
;
1741 rect
.height
= geomInfo
.GetItemHeight();
1743 DoDrawMenuItem(dc
, rect
, label
, flags
, indexAccel
, accel
, bitmap
, &geomInfo
);
1746 void wxGTKRenderer::DoDrawMenuItem(wxDC
& dc
,
1747 const wxRect
& rectOrig
,
1748 const wxString
& label
,
1751 const wxString
& accel
,
1752 const wxBitmap
& bitmap
,
1753 const wxGTKMenuGeometryInfo
*geometryInfo
)
1755 wxRect rect
= rectOrig
;
1757 // draw the selected item specially
1758 if ( flags
& wxCONTROL_SELECTED
)
1761 DrawBorder(dc
, wxBORDER_RAISED
, rect
, flags
, &rectIn
);
1763 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL_CURRENT
), rectIn
);
1766 rect
.Deflate(MENU_HORZ_MARGIN
, MENU_VERT_MARGIN
);
1768 // draw the bitmap: use the bitmap provided or the standard checkmark for
1769 // the checkable items
1772 wxBitmap bmp
= bitmap
;
1773 if ( !bmp
.Ok() && (flags
& wxCONTROL_CHECKABLE
) )
1775 bmp
= GetCheckBitmap(flags
);
1780 rect
.SetRight(geometryInfo
->GetLabelOffset());
1781 wxControlRenderer::DrawBitmap(dc
, bmp
, rect
);
1784 //else: menubar items don't have bitmaps
1789 rect
.x
= geometryInfo
->GetLabelOffset();
1790 rect
.SetRight(geometryInfo
->GetAccelOffset());
1793 DrawLabel(dc
, label
, rect
, flags
, wxALIGN_CENTRE_VERTICAL
, indexAccel
);
1795 // draw the accel string
1796 if ( !accel
.empty() )
1798 // menubar items shouldn't have them
1799 wxCHECK_RET( geometryInfo
, _T("accel strings only valid for menus") );
1801 rect
.x
= geometryInfo
->GetAccelOffset();
1802 rect
.SetRight(geometryInfo
->GetSize().x
);
1804 // NB: no accel index here
1805 DrawLabel(dc
, accel
, rect
, flags
, wxALIGN_CENTRE_VERTICAL
);
1808 // draw the submenu indicator
1809 if ( flags
& wxCONTROL_ISSUBMENU
)
1811 wxCHECK_RET( geometryInfo
, _T("wxCONTROL_ISSUBMENU only valid for menus") );
1813 rect
.x
= geometryInfo
->GetSize().x
- MENU_RIGHT_MARGIN
;
1814 rect
.width
= MENU_RIGHT_MARGIN
;
1816 DrawArrow(dc
, wxRIGHT
, rect
, flags
);
1820 void wxGTKRenderer::DrawMenuSeparator(wxDC
& dc
,
1822 const wxMenuGeometryInfo
& geomInfo
)
1824 DrawHorizontalLine(dc
, y
+ MENU_VERT_MARGIN
, 0, geomInfo
.GetSize().x
);
1827 wxSize
wxGTKRenderer::GetMenuBarItemSize(const wxSize
& sizeText
) const
1829 wxSize size
= sizeText
;
1831 // TODO: make this configurable
1832 size
.x
+= 2*MENU_HORZ_MARGIN
;
1833 size
.y
+= 2*MENU_VERT_MARGIN
;
1838 wxMenuGeometryInfo
*wxGTKRenderer::GetMenuGeometry(wxWindow
*win
,
1839 const wxMenu
& menu
) const
1841 // prepare the dc: for now we draw all the items with the system font
1843 dc
.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
1845 // the height of a normal item
1846 wxCoord heightText
= dc
.GetCharHeight();
1851 // the max length of label and accel strings: the menu width is the sum of
1852 // them, even if they're for different items (as the accels should be
1855 // the max length of the bitmap is never 0 as Windows always leaves enough
1856 // space for a check mark indicator
1857 wxCoord widthLabelMax
= 0,
1859 widthBmpMax
= MENU_LEFT_MARGIN
;
1861 for ( wxMenuItemList::compatibility_iterator node
= menu
.GetMenuItems().GetFirst();
1863 node
= node
->GetNext() )
1865 // height of this item
1868 wxMenuItem
*item
= node
->GetData();
1869 if ( item
->IsSeparator() )
1871 h
= MENU_SEPARATOR_HEIGHT
;
1873 else // not separator
1878 dc
.GetTextExtent(item
->GetLabel(), &widthLabel
, NULL
);
1879 if ( widthLabel
> widthLabelMax
)
1881 widthLabelMax
= widthLabel
;
1885 dc
.GetTextExtent(item
->GetAccelString(), &widthAccel
, NULL
);
1886 if ( widthAccel
> widthAccelMax
)
1888 widthAccelMax
= widthAccel
;
1891 const wxBitmap
& bmp
= item
->GetBitmap();
1894 wxCoord widthBmp
= bmp
.GetWidth();
1895 if ( widthBmp
> widthBmpMax
)
1896 widthBmpMax
= widthBmp
;
1898 //else if ( item->IsCheckable() ): no need to check for this as
1899 // MENU_LEFT_MARGIN is big enough to show the check mark
1902 h
+= 2*MENU_VERT_MARGIN
;
1904 // remember the item position and height
1905 item
->SetGeometry(height
, h
);
1910 // bundle the metrics into a struct and return it
1911 wxGTKMenuGeometryInfo
*gi
= new wxGTKMenuGeometryInfo
;
1913 gi
->m_ofsLabel
= widthBmpMax
+ 2*MENU_BMP_MARGIN
;
1914 gi
->m_ofsAccel
= gi
->m_ofsLabel
+ widthLabelMax
;
1915 if ( widthAccelMax
> 0 )
1917 // if we actually have any accesl, add a margin
1918 gi
->m_ofsAccel
+= MENU_ACCEL_MARGIN
;
1921 gi
->m_heightItem
= heightText
+ 2*MENU_VERT_MARGIN
;
1923 gi
->m_size
.x
= gi
->m_ofsAccel
+ widthAccelMax
+ MENU_RIGHT_MARGIN
;
1924 gi
->m_size
.y
= height
;
1929 #endif // wxUSE_MENUS
1933 // ----------------------------------------------------------------------------
1935 // ----------------------------------------------------------------------------
1938 wxGTKRenderer::GetStatusBarBorders(wxCoord
* WXUNUSED(borderBetweenFields
)) const
1943 void wxGTKRenderer::DrawStatusField(wxDC
& WXUNUSED(dc
),
1944 const wxRect
& WXUNUSED(rect
),
1945 const wxString
& WXUNUSED(label
),
1946 int WXUNUSED(flags
), int WXUNUSED(style
))
1950 #endif // wxUSE_STATUSBAR
1952 // ----------------------------------------------------------------------------
1954 // ----------------------------------------------------------------------------
1956 void wxGTKRenderer::InitComboBitmaps()
1958 wxSize sizeArrow
= m_sizeScrollbarArrow
;
1964 for ( n
= ComboState_Normal
; n
< ComboState_Max
; n
++ )
1966 m_bitmapsCombo
[n
].Create(sizeArrow
.x
, sizeArrow
.y
);
1969 static const int comboButtonFlags
[ComboState_Max
] =
1977 wxRect
rect(sizeArrow
);
1980 for ( n
= ComboState_Normal
; n
< ComboState_Max
; n
++ )
1982 int flags
= comboButtonFlags
[n
];
1984 dc
.SelectObject(m_bitmapsCombo
[n
]);
1985 DrawSolidRect(dc
, GetBackgroundColour(flags
), rect
);
1986 DrawArrow(dc
, wxDOWN
, rect
, flags
);
1990 void wxGTKRenderer::GetComboBitmaps(wxBitmap
*bmpNormal
,
1992 wxBitmap
*bmpPressed
,
1993 wxBitmap
*bmpDisabled
)
1995 if ( !m_bitmapsCombo
[ComboState_Normal
].Ok() )
2001 *bmpNormal
= m_bitmapsCombo
[ComboState_Normal
];
2003 *bmpFocus
= m_bitmapsCombo
[ComboState_Focus
];
2005 *bmpPressed
= m_bitmapsCombo
[ComboState_Pressed
];
2007 *bmpDisabled
= m_bitmapsCombo
[ComboState_Disabled
];
2010 // ----------------------------------------------------------------------------
2012 // ----------------------------------------------------------------------------
2014 void wxGTKRenderer::DrawArrowBorder(wxDC
& dc
,
2018 static const wxDirection sides
[] =
2020 wxUP
, wxLEFT
, wxRIGHT
, wxDOWN
2023 wxRect rect1
, rect2
, rectInner
;
2029 rectInner
.Inflate(-2);
2031 DrawSolidRect(dc
, wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
), *rect
);
2033 // find the side not to draw and also adjust the rectangles to compensate
2035 wxDirection sideToOmit
;
2039 sideToOmit
= wxDOWN
;
2041 rectInner
.height
+= 1;
2049 rectInner
.height
+= 1;
2053 sideToOmit
= wxRIGHT
;
2055 rectInner
.width
+= 1;
2059 sideToOmit
= wxLEFT
;
2063 rectInner
.width
+= 1;
2067 wxFAIL_MSG(_T("unknown arrow direction"));
2071 // the outer rect first
2073 for ( n
= 0; n
< WXSIZEOF(sides
); n
++ )
2075 wxDirection side
= sides
[n
];
2076 if ( side
== sideToOmit
)
2079 DrawAntiShadedRectSide(dc
, rect1
, m_penDarkGrey
, m_penHighlight
, side
);
2082 // and then the inner one
2083 for ( n
= 0; n
< WXSIZEOF(sides
); n
++ )
2085 wxDirection side
= sides
[n
];
2086 if ( side
== sideToOmit
)
2089 DrawAntiShadedRectSide(dc
, rect2
, m_penBlack
, m_penGrey
, side
);
2095 void wxGTKRenderer::DrawScrollbarArrow(wxDC
& dc
,
2097 const wxRect
& rectArrow
,
2100 // first of all, draw the border around it - but we don't want the border
2101 // on the side opposite to the arrow point
2102 wxRect rect
= rectArrow
;
2103 DrawArrowBorder(dc
, &rect
, dir
);
2105 // then the arrow itself
2106 DrawArrow(dc
, dir
, rect
, flags
);
2109 // gtk_default_draw_arrow() takes ~350 lines and we can't do much better here
2110 // these people are just crazy :-(
2111 void wxGTKRenderer::DrawArrow(wxDC
& dc
,
2124 wxPoint ptArrow
[Point_Max
];
2126 wxColour colInside
= GetBackgroundColour(flags
);
2128 if ( flags
& wxCONTROL_DISABLED
)
2130 penShadow
[0] = m_penDarkGrey
;
2131 penShadow
[1] = m_penDarkGrey
;
2132 penShadow
[2] = wxNullPen
;
2133 penShadow
[3] = wxNullPen
;
2135 else if ( flags
& wxCONTROL_PRESSED
)
2137 penShadow
[0] = m_penDarkGrey
;
2138 penShadow
[1] = m_penHighlight
;
2139 penShadow
[2] = wxNullPen
;
2140 penShadow
[3] = m_penBlack
;
2142 else // normal arrow
2144 penShadow
[0] = m_penHighlight
;
2145 penShadow
[1] = m_penBlack
;
2146 penShadow
[2] = m_penDarkGrey
;
2147 penShadow
[3] = wxNullPen
;
2151 if ( dir
== wxUP
|| dir
== wxDOWN
)
2154 middle
= (rect
.GetRight() + rect
.GetLeft() + 1) / 2;
2158 middle
= (rect
.GetTop() + rect
.GetBottom() + 1) / 2;
2161 // draw the arrow interior
2162 dc
.SetPen(*wxTRANSPARENT_PEN
);
2163 dc
.SetBrush(colInside
);
2168 ptArrow
[Point_First
].x
= rect
.GetLeft();
2169 ptArrow
[Point_First
].y
= rect
.GetBottom();
2170 ptArrow
[Point_Second
].x
= middle
;
2171 ptArrow
[Point_Second
].y
= rect
.GetTop();
2172 ptArrow
[Point_Third
].x
= rect
.GetRight();
2173 ptArrow
[Point_Third
].y
= rect
.GetBottom();
2177 ptArrow
[Point_First
] = rect
.GetPosition();
2178 ptArrow
[Point_Second
].x
= middle
;
2179 ptArrow
[Point_Second
].y
= rect
.GetBottom();
2180 ptArrow
[Point_Third
].x
= rect
.GetRight();
2181 ptArrow
[Point_Third
].y
= rect
.GetTop();
2185 ptArrow
[Point_First
].x
= rect
.GetRight();
2186 ptArrow
[Point_First
].y
= rect
.GetTop();
2187 ptArrow
[Point_Second
].x
= rect
.GetLeft();
2188 ptArrow
[Point_Second
].y
= middle
;
2189 ptArrow
[Point_Third
].x
= rect
.GetRight();
2190 ptArrow
[Point_Third
].y
= rect
.GetBottom();
2194 ptArrow
[Point_First
] = rect
.GetPosition();
2195 ptArrow
[Point_Second
].x
= rect
.GetRight();
2196 ptArrow
[Point_Second
].y
= middle
;
2197 ptArrow
[Point_Third
].x
= rect
.GetLeft();
2198 ptArrow
[Point_Third
].y
= rect
.GetBottom();
2202 wxFAIL_MSG(_T("unknown arrow direction"));
2205 dc
.DrawPolygon(WXSIZEOF(ptArrow
), ptArrow
);
2207 // draw the arrow border
2208 dc
.SetPen(penShadow
[0]);
2212 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_First
]);
2213 dc
.DrawPoint(ptArrow
[Point_First
]);
2214 if ( penShadow
[3].Ok() )
2216 dc
.SetPen(penShadow
[3]);
2217 dc
.DrawLine(ptArrow
[Point_First
].x
+ 1, ptArrow
[Point_First
].y
,
2218 ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
);
2220 dc
.SetPen(penShadow
[1]);
2221 dc
.DrawLine(ptArrow
[Point_Second
].x
+ 1, ptArrow
[Point_Second
].y
+ 1,
2222 ptArrow
[Point_Third
].x
, ptArrow
[Point_Third
].y
);
2223 dc
.DrawPoint(ptArrow
[Point_Third
]);
2224 dc
.DrawLine(ptArrow
[Point_Third
].x
- 2, ptArrow
[Point_Third
].y
,
2225 ptArrow
[Point_First
].x
+ 1, ptArrow
[Point_First
].y
);
2226 if ( penShadow
[2].Ok() )
2228 dc
.SetPen(penShadow
[2]);
2229 dc
.DrawLine(ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
,
2230 ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
+ 1);
2231 dc
.DrawLine(ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
- 1,
2232 ptArrow
[Point_First
].x
+ 2, ptArrow
[Point_First
].y
- 1);
2237 dc
.DrawLine(ptArrow
[Point_First
], ptArrow
[Point_Second
]);
2238 dc
.DrawLine(ptArrow
[Point_First
].x
+ 2, ptArrow
[Point_First
].y
,
2239 ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
);
2240 if ( penShadow
[2].Ok() )
2242 dc
.SetPen(penShadow
[2]);
2243 dc
.DrawLine(ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
- 1,
2244 ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
- 1);
2246 dc
.SetPen(penShadow
[1]);
2247 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_Third
]);
2248 dc
.DrawPoint(ptArrow
[Point_Third
]);
2252 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_First
]);
2253 dc
.DrawPoint(ptArrow
[Point_First
]);
2254 if ( penShadow
[2].Ok() )
2256 dc
.SetPen(penShadow
[2]);
2257 dc
.DrawLine(ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
,
2258 ptArrow
[Point_First
].x
- 1, ptArrow
[Point_First
].y
+ 2);
2259 dc
.DrawLine(ptArrow
[Point_Third
].x
, ptArrow
[Point_Third
].y
,
2260 ptArrow
[Point_Second
].x
+ 2, ptArrow
[Point_Second
].y
+ 1);
2262 dc
.SetPen(penShadow
[1]);
2263 dc
.DrawLine(ptArrow
[Point_Third
].x
, ptArrow
[Point_Third
].y
,
2264 ptArrow
[Point_First
].x
, ptArrow
[Point_First
].y
+ 1);
2265 dc
.DrawLine(ptArrow
[Point_Second
].x
+ 1, ptArrow
[Point_Second
].y
+ 1,
2266 ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
);
2270 dc
.DrawLine(ptArrow
[Point_First
], ptArrow
[Point_Third
]);
2271 dc
.DrawLine(ptArrow
[Point_First
].x
+ 2, ptArrow
[Point_First
].y
+ 1,
2272 ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
);
2273 dc
.SetPen(penShadow
[1]);
2274 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_Third
]);
2275 dc
.DrawPoint(ptArrow
[Point_Third
]);
2279 wxFAIL_MSG(_T("unknown arrow direction"));
2284 void wxGTKRenderer::DrawThumbBorder(wxDC
& dc
,
2286 wxOrientation orient
)
2288 if ( orient
== wxVERTICAL
)
2290 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2292 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2294 rect
->Inflate(-1, 0);
2296 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2298 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2300 rect
->Inflate(-1, 0);
2304 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2306 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2308 rect
->Inflate(0, -1);
2310 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2312 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2314 rect
->Inflate(0, -1);
2318 void wxGTKRenderer::DrawScrollbarThumb(wxDC
& dc
,
2319 wxOrientation orient
,
2323 // the thumb is never pressed never has focus border under GTK and the
2324 // scrollbar background never changes at all
2325 int flagsThumb
= flags
& ~(wxCONTROL_PRESSED
| wxCONTROL_FOCUSED
);
2327 // we don't want the border in the direction of the scrollbar movement
2328 wxRect rectThumb
= rect
;
2329 DrawThumbBorder(dc
, &rectThumb
, orient
);
2331 DrawButtonBorder(dc
, rectThumb
, flagsThumb
, &rectThumb
);
2332 DrawBackground(dc
, wxNullColour
, rectThumb
, flagsThumb
);
2335 void wxGTKRenderer::DrawScrollbarShaft(wxDC
& dc
,
2336 wxOrientation orient
,
2338 int WXUNUSED(flags
))
2340 wxRect rectBar
= rect
;
2341 DrawThumbBorder(dc
, &rectBar
, orient
);
2342 DrawSolidRect(dc
, wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
), rectBar
);
2345 void wxGTKRenderer::DrawScrollCorner(wxDC
& dc
, const wxRect
& rect
)
2347 DrawSolidRect(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL
), rect
);
2351 wxRect
wxGTKRenderer::GetScrollbarRect(const wxScrollBar
*scrollbar
,
2352 wxScrollBar::Element elem
,
2355 // as GTK scrollbars can't be disabled, it makes no sense to remove the
2356 // thumb for a scrollbar with range 0 - instead, make it fill the entire
2358 if ( (elem
== wxScrollBar::Element_Thumb
) && !scrollbar
->GetRange() )
2360 elem
= wxScrollBar::Element_Bar_2
;
2363 return wxStdRenderer::GetScrollbarRect(scrollbar
, elem
, thumbPos
);
2366 #endif // wxUSE_SCROLLBAR
2368 // ----------------------------------------------------------------------------
2370 // ----------------------------------------------------------------------------
2372 void wxGTKRenderer::AdjustSize(wxSize
*size
, const wxWindow
*window
)
2375 if ( wxDynamicCast(window
, wxBitmapButton
) )
2380 #endif // wxUSE_BMPBUTTON
2381 #if wxUSE_BUTTON || wxUSE_TOGGLEBTN
2384 || wxDynamicCast(window
, wxButton
)
2385 # endif // wxUSE_BUTTON
2386 # if wxUSE_TOGGLEBTN
2387 || wxDynamicCast(window
, wxToggleButton
)
2388 # endif // wxUSE_TOGGLEBTN
2391 if ( !(window
->GetWindowStyle() & wxBU_EXACTFIT
) )
2393 // TODO: this is ad hoc...
2394 size
->x
+= 3*window
->GetCharWidth();
2395 wxCoord minBtnHeight
= 18;
2396 if ( size
->y
< minBtnHeight
)
2397 size
->y
= minBtnHeight
;
2399 // button border width
2403 #endif // wxUSE_BUTTON || wxUSE_TOGGLEBTN
2405 if ( wxDynamicCast(window
, wxScrollBar
) )
2407 // we only set the width of vert scrollbars and height of the
2409 if ( window
->GetWindowStyle() & wxSB_HORIZONTAL
)
2410 size
->y
= m_sizeScrollbarArrow
.x
;
2412 size
->x
= m_sizeScrollbarArrow
.x
;
2415 #endif // wxUSE_SCROLLBAR
2417 // take into account the border width
2418 wxRect rectBorder
= GetBorderDimensions(window
->GetBorder());
2419 size
->x
+= rectBorder
.x
+ rectBorder
.width
;
2420 size
->y
+= rectBorder
.y
+ rectBorder
.height
;
2424 // ----------------------------------------------------------------------------
2425 // top level windows
2426 // ----------------------------------------------------------------------------
2428 void wxGTKRenderer::DrawFrameTitleBar(wxDC
& WXUNUSED(dc
),
2429 const wxRect
& WXUNUSED(rect
),
2430 const wxString
& WXUNUSED(title
),
2431 const wxIcon
& WXUNUSED(icon
),
2432 int WXUNUSED(flags
),
2433 int WXUNUSED(specialButton
),
2434 int WXUNUSED(specialButtonFlag
))
2438 void wxGTKRenderer::DrawFrameBorder(wxDC
& WXUNUSED(dc
),
2439 const wxRect
& WXUNUSED(rect
),
2440 int WXUNUSED(flags
))
2444 void wxGTKRenderer::DrawFrameBackground(wxDC
& WXUNUSED(dc
),
2445 const wxRect
& WXUNUSED(rect
),
2446 int WXUNUSED(flags
))
2450 void wxGTKRenderer::DrawFrameTitle(wxDC
& WXUNUSED(dc
),
2451 const wxRect
& WXUNUSED(rect
),
2452 const wxString
& WXUNUSED(title
),
2453 int WXUNUSED(flags
))
2457 void wxGTKRenderer::DrawFrameIcon(wxDC
& WXUNUSED(dc
),
2458 const wxRect
& WXUNUSED(rect
),
2459 const wxIcon
& WXUNUSED(icon
),
2460 int WXUNUSED(flags
))
2464 void wxGTKRenderer::DrawFrameButton(wxDC
& WXUNUSED(dc
),
2465 wxCoord
WXUNUSED(x
),
2466 wxCoord
WXUNUSED(y
),
2467 int WXUNUSED(button
),
2468 int WXUNUSED(flags
))
2473 wxGTKRenderer::GetFrameClientArea(const wxRect
& rect
,
2474 int WXUNUSED(flags
)) const
2480 wxGTKRenderer::GetFrameTotalSize(const wxSize
& clientSize
,
2481 int WXUNUSED(flags
)) const
2486 wxSize
wxGTKRenderer::GetFrameMinSize(int WXUNUSED(flags
)) const
2491 wxSize
wxGTKRenderer::GetFrameIconSize() const
2493 return wxSize(wxDefaultCoord
, wxDefaultCoord
);
2497 wxGTKRenderer::HitTestFrame(const wxRect
& WXUNUSED(rect
),
2498 const wxPoint
& WXUNUSED(pt
),
2499 int WXUNUSED(flags
)) const
2501 return wxHT_TOPLEVEL_CLIENT_AREA
;
2505 // ----------------------------------------------------------------------------
2507 // ----------------------------------------------------------------------------
2509 /* Copyright (c) Julian Smart */
2510 static const char *error_xpm
[] = {
2511 /* columns rows colors chars-per-pixel */
2525 " ................. ",
2526 " ................... ",
2527 " ....................... ",
2528 " ......................... ",
2529 " ........................... ",
2530 " ...........................X ",
2531 " .............................X ",
2532 " ............................... ",
2533 " ...............................X ",
2534 " .................................X ",
2535 " .................................X ",
2536 " .................................XX ",
2537 " ...ooooooooooooooooooooooooooo...XX ",
2538 " ....ooooooooooooooooooooooooooo....X ",
2539 " ....ooooooooooooooooooooooooooo....X ",
2540 " ....ooooooooooooooooooooooooooo....XX ",
2541 " ....ooooooooooooooooooooooooooo....XX ",
2542 " ....ooooooooooooooooooooooooooo....XX ",
2543 " ...ooooooooooooooooooooooooooo...XXX ",
2544 " ...ooooooooooooooooooooooooooo...XXX ",
2545 " .................................XX ",
2546 " .................................XX ",
2547 " ...............................XXX ",
2548 " ...............................XXX ",
2549 " .............................XXX ",
2550 " ...........................XXXX ",
2551 " ...........................XXX ",
2552 " .........................XXX ",
2553 " .......................XXXX ",
2554 " X...................XXXXX ",
2555 " X.................XXXXX ",
2556 " X.............XXXXX ",
2557 " XXXX.....XXXXXXXX ",
2568 /* Copyright (c) Julian Smart */
2569 static const char *info_xpm
[] = {
2570 /* columns rows colors chars-per-pixel */
2594 " .XXXOXXXXXXXoo. ",
2595 " .XOOXXX+XXXXXo. ",
2596 " .XOOOXX+++XXXXoo. ",
2597 " .XOOXXX+++XXXXXo. ",
2598 " .XOOOXXX+++XXXXXXo. ",
2599 " .XOOXXXX+++XXXXXXo. ",
2600 " .XXXXXXX+++XXXXXXX. ",
2601 " .XXXXXXX+++XXXXXXo. ",
2602 " .XXXXXXX+++XXXXXoo. ",
2603 " .XXXXXX+++XXXXXo. ",
2604 " .XXXXXXX+XXXXXXo. ",
2605 " .XXXXXXXXXXXXo. ",
2606 " .XXXXX+++XXXoo. ",
2632 /* Copyright (c) Julian Smart */
2633 static const char *warning_xpm
[] = {
2634 /* columns rows colors chars-per-pixel */
2664 " ..XXXXO@#XXX... ",
2665 " ...XXXXO@#XXXX.. ",
2666 " ..XXXXXO@#XXXX... ",
2667 " ...XXXXXo@OXXXXX.. ",
2668 " ...XXXXXXo@OXXXXXX.. ",
2669 " ..XXXXXXX$@OXXXXXX... ",
2670 " ...XXXXXXXX@XXXXXXXX.. ",
2671 " ...XXXXXXXXXXXXXXXXXX... ",
2672 " ..XXXXXXXXXXOXXXXXXXXX.. ",
2673 " ...XXXXXXXXXO@#XXXXXXXXX.. ",
2674 " ..XXXXXXXXXXX#XXXXXXXXXX... ",
2675 " ...XXXXXXXXXXXXXXXXXXXXXXX.. ",
2676 " ...XXXXXXXXXXXXXXXXXXXXXXXX... ",
2677 " .............................. ",
2678 " .............................. ",
2696 /* Copyright (c) Julian Smart */
2697 static const char *question_xpm
[] = {
2698 /* columns rows colors chars-per-pixel */
2728 " ..XXXXoooooXXXO+ ",
2729 " ..XXooooooooooooX@.. ",
2730 " ..XoooooooooooooooXX#. ",
2731 " $%XoooooooooooooooooXX#. ",
2732 " &.XoooooooXXXXXXooooooXX.. ",
2733 " .XooooooXX.$...$XXoooooX*. ",
2734 " $.XoooooX%.$ .*oooooo=.. ",
2735 " .XooooooX.. -.XoooooX.. ",
2736 " .XoooooX..+ .XoooooX;. ",
2737 " ...XXXX..: .XoooooX;. ",
2738 " ........ >.XoooooX;. ",
2772 wxBitmap
wxGTKArtProvider::CreateBitmap(const wxArtID
& id
,
2773 const wxArtClient
& WXUNUSED(client
),
2774 const wxSize
& WXUNUSED(size
))
2776 if ( id
== wxART_INFORMATION
)
2777 return wxBitmap(info_xpm
);
2778 if ( id
== wxART_ERROR
)
2779 return wxBitmap(error_xpm
);
2780 if ( id
== wxART_WARNING
)
2781 return wxBitmap(warning_xpm
);
2782 if ( id
== wxART_QUESTION
)
2783 return wxBitmap(question_xpm
);
2784 return wxNullBitmap
;
2788 // ============================================================================
2790 // ============================================================================
2792 // ----------------------------------------------------------------------------
2793 // wxGTKInputHandler
2794 // ----------------------------------------------------------------------------
2796 bool wxGTKInputHandler::HandleKey(wxInputConsumer
* WXUNUSED(control
),
2797 const wxKeyEvent
& WXUNUSED(event
),
2798 bool WXUNUSED(pressed
))
2803 bool wxGTKInputHandler::HandleMouse(wxInputConsumer
*control
,
2804 const wxMouseEvent
& event
)
2806 // clicking on the control gives it focus
2807 if ( event
.ButtonDown() && wxWindow::FindFocus() != control
->GetInputWindow() )
2809 control
->GetInputWindow()->SetFocus();
2817 bool wxGTKInputHandler::HandleMouseMove(wxInputConsumer
*control
,
2818 const wxMouseEvent
& event
)
2820 if ( event
.Entering() )
2822 control
->GetInputWindow()->SetCurrent(true);
2824 else if ( event
.Leaving() )
2826 control
->GetInputWindow()->SetCurrent(false);
2838 // ----------------------------------------------------------------------------
2839 // wxGTKCheckboxInputHandler
2840 // ----------------------------------------------------------------------------
2842 bool wxGTKCheckboxInputHandler::HandleKey(wxInputConsumer
*control
,
2843 const wxKeyEvent
& event
,
2848 int keycode
= event
.GetKeyCode();
2849 if ( keycode
== WXK_SPACE
|| keycode
== WXK_RETURN
)
2851 control
->PerformAction(wxACTION_CHECKBOX_TOGGLE
);
2860 #endif // wxUSE_CHECKBOX
2864 // ----------------------------------------------------------------------------
2865 // wxGTKTextCtrlInputHandler
2866 // ----------------------------------------------------------------------------
2868 bool wxGTKTextCtrlInputHandler::HandleKey(wxInputConsumer
*control
,
2869 const wxKeyEvent
& event
,
2872 // handle only GTK-specific text bindings here, the others are handled in
2876 wxControlAction action
;
2877 int keycode
= event
.GetKeyCode();
2878 if ( event
.ControlDown() )
2883 action
= wxACTION_TEXT_HOME
;
2887 action
= wxACTION_TEXT_LEFT
;
2891 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_RIGHT
;
2895 action
= wxACTION_TEXT_END
;
2899 action
= wxACTION_TEXT_RIGHT
;
2903 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_LEFT
;
2907 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_END
;
2911 action
= wxACTION_TEXT_DOWN
;
2915 action
= wxACTION_TEXT_UP
;
2919 //delete the entire line
2920 control
->PerformAction(wxACTION_TEXT_HOME
);
2921 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_END
;
2925 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_WORD_LEFT
;
2929 else if ( event
.AltDown() )
2934 action
= wxACTION_TEXT_WORD_LEFT
;
2938 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_WORD_RIGHT
;
2942 action
= wxACTION_TEXT_WORD_RIGHT
;
2947 if ( action
!= wxACTION_NONE
)
2949 control
->PerformAction(action
);
2955 return wxStdInputHandler::HandleKey(control
, event
, pressed
);
2958 #endif // wxUSE_TEXTCTRL