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
140 virtual void DrawTab(wxDC
& dc
,
143 const wxString
& label
,
144 const wxBitmap
& bitmap
= wxNullBitmap
,
146 int indexAccel
= -1);
149 virtual void DrawSliderShaft(wxDC
& dc
,
152 wxOrientation orient
,
155 wxRect
*rectShaft
= NULL
);
156 virtual void DrawSliderThumb(wxDC
& dc
,
158 wxOrientation orient
,
161 virtual void DrawSliderTicks(wxDC
& WXUNUSED(dc
),
162 const wxRect
& WXUNUSED(rect
),
163 int WXUNUSED(lenThumb
),
164 wxOrientation
WXUNUSED(orient
),
167 int WXUNUSED(step
) = 1,
168 int WXUNUSED(flags
) = 0,
169 long WXUNUSED(style
) = 0)
171 // we don't have the ticks in GTK version
173 #endif // wxUSE_SLIDER
176 virtual void DrawMenuBarItem(wxDC
& dc
,
178 const wxString
& label
,
180 int indexAccel
= -1);
181 virtual void DrawMenuItem(wxDC
& dc
,
183 const wxMenuGeometryInfo
& geometryInfo
,
184 const wxString
& label
,
185 const wxString
& accel
,
186 const wxBitmap
& bitmap
= wxNullBitmap
,
188 int indexAccel
= -1);
189 virtual void DrawMenuSeparator(wxDC
& dc
,
191 const wxMenuGeometryInfo
& geomInfo
);
192 #endif // wxUSE_MENUS
195 virtual void DrawStatusField(wxDC
& dc
,
197 const wxString
& label
,
198 int flags
= 0, int style
= 0);
199 #endif // wxUSE_STATUSBAR
201 virtual void DrawFrameTitleBar(wxDC
& dc
,
203 const wxString
& title
,
206 int specialButton
= 0,
207 int specialButtonFlag
= 0);
208 virtual void DrawFrameBorder(wxDC
& dc
,
211 virtual void DrawFrameBackground(wxDC
& dc
,
214 virtual void DrawFrameTitle(wxDC
& dc
,
216 const wxString
& title
,
218 virtual void DrawFrameIcon(wxDC
& dc
,
222 virtual void DrawFrameButton(wxDC
& dc
,
223 wxCoord x
, wxCoord y
,
228 virtual wxRect
GetFrameClientArea(const wxRect
& rect
, int flags
) const;
229 virtual wxSize
GetFrameTotalSize(const wxSize
& clientSize
, int flags
) const;
230 virtual wxSize
GetFrameMinSize(int flags
) const;
231 virtual wxSize
GetFrameIconSize() const;
232 virtual int HitTestFrame(const wxRect
& rect
, const wxPoint
& pt
, int flags
) const;
234 virtual void GetComboBitmaps(wxBitmap
*bmpNormal
,
236 wxBitmap
*bmpPressed
,
237 wxBitmap
*bmpDisabled
);
239 virtual void AdjustSize(wxSize
*size
, const wxWindow
*window
);
241 // geometry and hit testing
242 virtual wxSize
GetScrollbarArrowSize() const
243 { return m_sizeScrollbarArrow
; }
245 virtual wxRect
GetScrollbarRect(const wxScrollBar
*scrollbar
,
246 wxScrollBar::Element elem
,
247 int thumbPos
= -1) const;
248 #endif // wxUSE_SCROLLBAR
250 virtual wxCoord
GetListboxItemHeight(wxCoord fontHeight
)
251 { return fontHeight
+ 2; }
252 virtual wxSize
GetCheckBitmapSize() const
253 { return wxSize(10, 10); }
254 virtual wxSize
GetRadioBitmapSize() const
255 { return wxSize(11, 11); }
256 virtual wxCoord
GetCheckItemMargin() const
259 virtual wxSize
GetToolBarButtonSize(wxCoord
*separator
) const
260 { if ( separator
) *separator
= 5; return wxSize(16, 15); }
261 virtual wxSize
GetToolBarMargin() const
262 { return wxSize(6, 6); }
265 virtual wxRect
GetTextTotalArea(const wxTextCtrl
*text
,
266 const wxRect
& rect
) const;
267 virtual wxRect
GetTextClientArea(const wxTextCtrl
*text
,
269 wxCoord
*extraSpaceBeyond
) const;
270 #endif // wxUSE_TEXTCTRL
272 virtual wxSize
GetTabIndent() const { return wxSize(2, 2); }
273 virtual wxSize
GetTabPadding() const { return wxSize(6, 6); }
276 virtual wxCoord
GetSliderDim() const { return 15; }
277 virtual wxCoord
GetSliderTickLen() const { return 0; }
278 virtual wxRect
GetSliderShaftRect(const wxRect
& rect
,
280 wxOrientation orient
,
281 long style
= 0) const;
282 virtual wxSize
GetSliderThumbSize(const wxRect
& rect
,
284 wxOrientation orient
) const;
285 #endif // wxUSE_SLIDER
287 virtual wxSize
GetProgressBarStep() const { return wxSize(16, 32); }
290 virtual wxSize
GetMenuBarItemSize(const wxSize
& sizeText
) const;
291 virtual wxMenuGeometryInfo
*GetMenuGeometry(wxWindow
*win
,
292 const wxMenu
& menu
) const;
293 #endif // wxUSE_MENUS
296 virtual wxSize
GetStatusBarBorders(wxCoord
*borderBetweenFields
) const;
297 #endif // wxUSE_STATUSBAR
299 // helpers for "wxBitmap wxColourScheme::Get()"
300 void DrawCheckBitmap(wxDC
& dc
, const wxRect
& rect
);
301 void DrawUncheckBitmap(wxDC
& dc
, const wxRect
& rect
, bool isPressed
);
302 void DrawUndeterminedBitmap(wxDC
& dc
, const wxRect
& rect
, bool isPressed
);
305 virtual void DrawSunkenBorder(wxDC
& dc
, wxRect
*rect
);
307 virtual void DrawFrameWithLabel(wxDC
& dc
,
308 const wxString
& label
,
309 const wxRect
& rectFrame
,
310 const wxRect
& rectText
,
315 // get the colour to use for background
316 wxColour
GetBackgroundColour(int flags
) const
318 if ( flags
& wxCONTROL_PRESSED
)
319 return wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
);
320 else if ( flags
& wxCONTROL_CURRENT
)
321 return wxSCHEME_COLOUR(m_scheme
, CONTROL_CURRENT
);
323 return wxSCHEME_COLOUR(m_scheme
, CONTROL
);
326 // as DrawShadedRect() but the pixels in the bottom left and upper right
327 // border are drawn with the pen1, not pen2
328 void DrawAntiShadedRect(wxDC
& dc
, wxRect
*rect
,
329 const wxPen
& pen1
, const wxPen
& pen2
);
331 // used for drawing opened rectangles - draws only one side of it at once
332 // (and doesn't adjust the rect)
333 void DrawAntiShadedRectSide(wxDC
& dc
,
339 // draw an opened rect for the arrow in given direction
340 void DrawArrowBorder(wxDC
& dc
,
344 // draw two sides of the rectangle
345 void DrawThumbBorder(wxDC
& dc
,
347 wxOrientation orient
);
349 // just as DrawRaisedBorder() except that the bottom left and up right
350 // pixels of the interior rect are drawn in another colour (i.e. the inner
351 // rect is drawn with DrawAntiShadedRect() and not DrawShadedRect())
352 void DrawAntiRaisedBorder(wxDC
& dc
, wxRect
*rect
);
354 // draw inner GTK shadow
355 void DrawInnerShadedRect(wxDC
& dc
, wxRect
*rect
);
358 // returns the size of the arrow for the scrollbar (depends on
360 wxSize
GetScrollbarArrowSize(const wxScrollBar
*scrollbar
) const
363 if ( scrollbar
->IsVertical() )
365 size
= m_sizeScrollbarArrow
;
369 size
.x
= m_sizeScrollbarArrow
.y
;
370 size
.y
= m_sizeScrollbarArrow
.x
;
375 #endif // wxUSE_SCROLLBAR
377 // get the line wrap indicator bitmap
378 wxBitmap
GetLineWrapBitmap() const;
380 virtual wxBitmap
GetCheckBitmap(int flags
);
381 virtual wxBitmap
GetRadioBitmap(int flags
);
383 // draw a /\ or \/ line from (x1, y1) to (x2, y1) passing by the point
385 void DrawUpZag(wxDC
& dc
,
386 wxCoord x1
, wxCoord x2
,
387 wxCoord y1
, wxCoord y2
);
388 void DrawDownZag(wxDC
& dc
,
389 wxCoord x1
, wxCoord x2
,
390 wxCoord y1
, wxCoord y2
);
392 // draw the radio button bitmap for the given state
393 void DrawRadioBitmap(wxDC
& dc
, const wxRect
& rect
, int flags
);
395 // draw check/radio - the bitmap must be a valid one by now
396 void DoDrawCheckOrRadioBitmap(wxDC
& dc
,
397 const wxString
& label
,
398 const wxBitmap
& bitmap
,
399 const wxRect
& rectTotal
,
404 // common part of DrawMenuItem() and DrawMenuBarItem()
405 void DoDrawMenuItem(wxDC
& dc
,
407 const wxString
& label
,
410 const wxString
& accel
= wxEmptyString
,
411 const wxBitmap
& bitmap
= wxNullBitmap
,
412 const wxGTKMenuGeometryInfo
*geometryInfo
= NULL
);
414 // initialize the combo bitmaps
415 void InitComboBitmaps();
418 const wxColourScheme
*m_scheme
;
421 wxSize m_sizeScrollbarArrow
;
426 // the checkbox and radio button bitmaps: first row is for the normal,
427 // second for the pressed state and the columns are for checked, unchecked
428 // and undeterminated respectively
429 wxBitmap m_bitmapsCheckbox
[IndicatorState_MaxCtrl
][IndicatorStatus_Max
],
430 m_bitmapsRadiobtn
[IndicatorState_MaxCtrl
][IndicatorStatus_Max
];
432 // the line wrap bitmap (drawn at the end of wrapped lines)
433 wxBitmap m_bmpLineWrap
;
435 // the combobox bitmaps
445 wxBitmap m_bitmapsCombo
[ComboState_Max
];
448 // ----------------------------------------------------------------------------
449 // wxGTKInputHandler and derived classes: process the keyboard and mouse
450 // messages according to GTK standards
451 // ----------------------------------------------------------------------------
453 class wxGTKInputHandler
: public wxInputHandler
456 wxGTKInputHandler() { }
458 virtual bool HandleKey(wxInputConsumer
*control
,
459 const wxKeyEvent
& event
,
461 virtual bool HandleMouse(wxInputConsumer
*control
,
462 const wxMouseEvent
& event
);
463 virtual bool HandleMouseMove(wxInputConsumer
*control
,
464 const wxMouseEvent
& event
);
469 class wxGTKScrollBarInputHandler
: public wxStdScrollBarInputHandler
472 wxGTKScrollBarInputHandler(wxRenderer
*renderer
, wxInputHandler
*handler
)
473 : wxStdScrollBarInputHandler(renderer
, handler
) { }
476 virtual void Highlight(wxScrollBar
*scrollbar
, bool doIt
)
478 // only arrows and the thumb can be highlighted
479 if ( !IsArrow() && m_htLast
!= wxHT_SCROLLBAR_THUMB
)
482 wxStdScrollBarInputHandler::Highlight(scrollbar
, doIt
);
485 virtual void Press(wxScrollBar
*scrollbar
, bool doIt
)
487 // only arrows can be pressed
491 wxStdScrollBarInputHandler::Press(scrollbar
, doIt
);
494 // any button can be used to drag the scrollbar under GTK+
495 virtual bool IsAllowedButton(int WXUNUSED(button
)) const { return true; }
499 return m_htLast
== wxHT_SCROLLBAR_ARROW_LINE_1
||
500 m_htLast
== wxHT_SCROLLBAR_ARROW_LINE_2
;
504 #endif // wxUSE_SCROLLBAR
508 class wxGTKCheckboxInputHandler
: public wxStdInputHandler
511 wxGTKCheckboxInputHandler(wxInputHandler
*handler
)
512 : wxStdInputHandler(handler
) { }
514 virtual bool HandleKey(wxInputConsumer
*control
,
515 const wxKeyEvent
& event
,
519 #endif // wxUSE_CHECKBOX
523 class wxGTKTextCtrlInputHandler
: public wxStdInputHandler
526 wxGTKTextCtrlInputHandler(wxInputHandler
*handler
)
527 : wxStdInputHandler(handler
) { }
529 virtual bool HandleKey(wxInputConsumer
*control
,
530 const wxKeyEvent
& event
,
534 #endif // wxUSE_TEXTCTRL
536 // ----------------------------------------------------------------------------
537 // wxGTKColourScheme: uses the standard GTK colours
538 // ----------------------------------------------------------------------------
540 class wxGTKColourScheme
: public wxColourScheme
543 virtual wxColour
Get(StdColour col
) const;
544 virtual wxColour
GetBackground(wxWindow
*win
) const;
547 // ----------------------------------------------------------------------------
549 // ----------------------------------------------------------------------------
551 class wxGTKArtProvider
: public wxArtProvider
554 virtual wxBitmap
CreateBitmap(const wxArtID
& id
,
555 const wxArtClient
& client
,
559 // ----------------------------------------------------------------------------
561 // ----------------------------------------------------------------------------
563 WX_DEFINE_ARRAY_PTR(wxInputHandler
*, wxArrayHandlers
);
565 class wxGTKTheme
: public wxTheme
569 virtual ~wxGTKTheme();
571 virtual wxRenderer
*GetRenderer();
572 virtual wxArtProvider
*GetArtProvider();
573 virtual wxInputHandler
*GetInputHandler(const wxString
& control
,
574 wxInputConsumer
*consumer
);
575 virtual wxColourScheme
*GetColourScheme();
578 wxGTKRenderer
*m_renderer
;
580 wxGTKArtProvider
*m_artProvider
;
582 // the names of the already created handlers and the handlers themselves
583 // (these arrays are synchronized)
584 wxSortedArrayString m_handlerNames
;
585 wxArrayHandlers m_handlers
;
587 wxGTKInputHandler
*m_handlerDefault
;
589 wxGTKColourScheme
*m_scheme
;
591 WX_DECLARE_THEME(gtk
)
594 // ============================================================================
596 // ============================================================================
598 WX_IMPLEMENT_THEME(wxGTKTheme
, gtk
, wxTRANSLATE("GTK+ theme"));
600 // ----------------------------------------------------------------------------
602 // ----------------------------------------------------------------------------
604 wxGTKTheme::wxGTKTheme()
608 m_handlerDefault
= NULL
;
609 m_artProvider
= NULL
;
612 wxGTKTheme::~wxGTKTheme()
614 size_t count
= m_handlers
.GetCount();
615 for ( size_t n
= 0; n
< count
; n
++ )
617 if ( m_handlers
[n
] != m_handlerDefault
)
618 delete m_handlers
[n
];
621 delete m_handlerDefault
;
624 wxArtProvider::RemoveProvider(m_artProvider
);
627 wxRenderer
*wxGTKTheme::GetRenderer()
631 m_renderer
= new wxGTKRenderer(GetColourScheme());
637 wxArtProvider
*wxGTKTheme::GetArtProvider()
639 if ( !m_artProvider
)
641 m_artProvider
= new wxGTKArtProvider
;
644 return m_artProvider
;
647 wxColourScheme
*wxGTKTheme::GetColourScheme()
651 m_scheme
= new wxGTKColourScheme
;
656 wxInputHandler
*wxGTKTheme::GetInputHandler(const wxString
& control
,
657 wxInputConsumer
*consumer
)
659 wxInputHandler
*handler
= NULL
;
660 int n
= m_handlerNames
.Index(control
);
661 if ( n
== wxNOT_FOUND
)
663 static wxGTKInputHandler s_handlerDef
;
665 wxInputHandler
* const
666 handlerStd
= consumer
->DoGetStdInputHandler(&s_handlerDef
);
668 // create a new handler
670 if ( control
== wxINP_HANDLER_CHECKBOX
)
672 static wxGTKCheckboxInputHandler
s_handler(handlerStd
);
674 handler
= &s_handler
;
677 #endif // wxUSE_CHECKBOX
679 if ( control
== wxINP_HANDLER_SCROLLBAR
)
681 static wxGTKScrollBarInputHandler
s_handler(m_renderer
, handlerStd
);
683 handler
= &s_handler
;
686 #endif // wxUSE_SCROLLBAR
688 if ( control
== wxINP_HANDLER_TEXTCTRL
)
690 static wxGTKTextCtrlInputHandler
s_handler(handlerStd
);
692 handler
= &s_handler
;
695 #endif // wxUSE_TEXTCTRL
697 // no special handler for this control
698 handler
= handlerStd
;
701 n
= m_handlerNames
.Add(control
);
702 m_handlers
.Insert(handler
, n
);
704 else // we already have it
706 handler
= m_handlers
[n
];
712 // ============================================================================
714 // ============================================================================
716 wxColour
wxGTKColourScheme::GetBackground(wxWindow
*win
) const
719 if ( win
->UseBgCol() )
721 // use the user specified colour
722 col
= win
->GetBackgroundColour();
725 if ( !win
->ShouldInheritColours() )
727 // doesn't depend on the state
735 int flags
= win
->GetStateFlags();
737 // the colour set by the user should be used for the normal state
738 // and for the states for which we don't have any specific colours
739 if ( !col
.Ok() || (flags
!= 0) )
742 if ( wxDynamicCast(win
, wxScrollBar
) )
743 col
= Get(SCROLLBAR
);
745 #endif //wxUSE_SCROLLBAR
746 if ( (flags
& wxCONTROL_CURRENT
) && win
->CanBeHighlighted() )
747 col
= Get(CONTROL_CURRENT
);
748 else if ( flags
& wxCONTROL_PRESSED
)
749 col
= Get(CONTROL_PRESSED
);
758 wxColour
wxGTKColourScheme::Get(wxGTKColourScheme::StdColour col
) const
762 case WINDOW
: return *wxWHITE
;
764 case SHADOW_DARK
: return *wxBLACK
;
765 case SHADOW_HIGHLIGHT
: return *wxWHITE
;
766 case SHADOW_IN
: return wxColour(0xd6d6d6);
767 case SHADOW_OUT
: return wxColour(0x969696);
769 case CONTROL
: return wxColour(0xd6d6d6);
770 case CONTROL_PRESSED
: return wxColour(0xc3c3c3);
771 case CONTROL_CURRENT
: return wxColour(0xeaeaea);
773 case CONTROL_TEXT
: return *wxBLACK
;
774 case CONTROL_TEXT_DISABLED
:
775 return wxColour(0x757575);
776 case CONTROL_TEXT_DISABLED_SHADOW
:
780 case SCROLLBAR_PRESSED
: return wxColour(0xc3c3c3);
782 case HIGHLIGHT
: return wxColour(0x9c0000);
783 case HIGHLIGHT_TEXT
: return wxColour(0xffffff);
785 case GAUGE
: return Get(CONTROL_CURRENT
);
787 case TITLEBAR
: return wxColour(0xaeaaae);
788 case TITLEBAR_ACTIVE
: return wxColour(0x820300);
789 case TITLEBAR_TEXT
: return wxColour(0xc0c0c0);
790 case TITLEBAR_ACTIVE_TEXT
:
793 case DESKTOP
: return *wxBLACK
;
797 wxFAIL_MSG(_T("invalid standard colour"));
802 // ============================================================================
804 // ============================================================================
806 // ----------------------------------------------------------------------------
808 // ----------------------------------------------------------------------------
810 wxGTKRenderer::wxGTKRenderer(const wxColourScheme
*scheme
)
811 : wxStdRenderer(scheme
)
813 m_sizeScrollbarArrow
= wxSize(15, 14);
815 m_penGrey
= wxPen(wxSCHEME_COLOUR(scheme
, SCROLLBAR
));
818 // ----------------------------------------------------------------------------
820 // ----------------------------------------------------------------------------
822 void wxGTKRenderer::DrawAntiShadedRectSide(wxDC
& dc
,
828 dc
.SetPen(dir
== wxLEFT
|| dir
== wxUP
? pen1
: pen2
);
833 dc
.DrawLine(rect
.GetLeft(), rect
.GetTop(),
834 rect
.GetLeft(), rect
.GetBottom() + 1);
838 dc
.DrawLine(rect
.GetLeft(), rect
.GetTop(),
839 rect
.GetRight() + 1, rect
.GetTop());
843 dc
.DrawLine(rect
.GetRight(), rect
.GetTop(),
844 rect
.GetRight(), rect
.GetBottom() + 1);
848 dc
.DrawLine(rect
.GetLeft(), rect
.GetBottom(),
849 rect
.GetRight() + 1, rect
.GetBottom());
853 wxFAIL_MSG(_T("unknown rectangle side"));
857 void wxGTKRenderer::DrawAntiShadedRect(wxDC
& dc
, wxRect
*rect
,
858 const wxPen
& pen1
, const wxPen
& pen2
)
860 // draw the rectangle
862 dc
.DrawLine(rect
->GetLeft(), rect
->GetTop(),
863 rect
->GetLeft(), rect
->GetBottom() + 1);
864 dc
.DrawLine(rect
->GetLeft() + 1, rect
->GetTop(),
865 rect
->GetRight() + 1, rect
->GetTop());
867 dc
.DrawLine(rect
->GetRight(), rect
->GetTop() + 1,
868 rect
->GetRight(), rect
->GetBottom());
869 dc
.DrawLine(rect
->GetLeft() + 1, rect
->GetBottom(),
870 rect
->GetRight() + 1, rect
->GetBottom());
876 void wxGTKRenderer::DrawInnerShadedRect(wxDC
& dc
, wxRect
*rect
)
878 DrawAntiShadedRect(dc
, rect
, m_penDarkGrey
, m_penHighlight
);
879 DrawAntiShadedRect(dc
, rect
, m_penBlack
, m_penHighlight
);
882 void wxGTKRenderer::DrawAntiRaisedBorder(wxDC
& dc
, wxRect
*rect
)
884 DrawShadedRect(dc
, rect
, m_penHighlight
, m_penBlack
);
885 DrawAntiShadedRect(dc
, rect
, m_penLightGrey
, m_penDarkGrey
);
888 void wxGTKRenderer::DrawSunkenBorder(wxDC
& dc
, wxRect
*rect
)
890 DrawAntiShadedRect(dc
, rect
, m_penDarkGrey
, m_penHighlight
);
891 DrawShadedRect(dc
, rect
, m_penBlack
, m_penLightGrey
);
894 void wxGTKRenderer::DrawFocusRect(wxDC
& dc
, const wxRect
& rect
)
896 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
897 wxRect rectFocus
= rect
;
898 DrawRect(dc
, &rectFocus
, m_penBlack
);
901 void wxGTKRenderer::DrawTextBorder(wxDC
& dc
,
903 const wxRect
& rectOrig
,
907 wxRect rect
= rectOrig
;
909 if ( border
!= wxBORDER_NONE
)
911 if ( flags
& wxCONTROL_FOCUSED
)
913 DrawRect(dc
, &rect
, m_penBlack
);
914 DrawAntiShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
918 DrawInnerShadedRect(dc
, &rect
);
926 void wxGTKRenderer::DrawButtonLabel(wxDC
& dc
,
927 const wxString
& label
,
928 const wxBitmap
& image
,
935 // no focus rect around buttons label in GTK+
936 wxStdRenderer::DrawButtonLabel(dc
, label
, image
, rect
, flags
,
937 alignment
, indexAccel
, rectBounds
);
940 void wxGTKRenderer::DrawButtonBorder(wxDC
& dc
,
941 const wxRect
& rectTotal
,
945 wxRect rect
= rectTotal
;
947 if ( flags
& wxCONTROL_PRESSED
)
949 // button pressed: draw a black border around it and an inward shade
950 DrawRect(dc
, &rect
, m_penBlack
);
952 DrawInnerShadedRect(dc
, &rect
);
954 else // button not pressed
956 if ( flags
& wxCONTROL_ISDEFAULT
)
961 if ( flags
& wxCONTROL_FOCUSED
)
963 // button is currently default: add an extra border around it
964 DrawRect(dc
, &rect
, m_penBlack
);
967 // now draw a normal button
968 DrawShadedRect(dc
, &rect
, m_penHighlight
, m_penBlack
);
969 DrawAntiShadedRect(dc
, &rect
, GetBackgroundColour(flags
), m_penDarkGrey
);
976 // ----------------------------------------------------------------------------
978 // ----------------------------------------------------------------------------
980 void wxGTKRenderer::DrawFrameWithLabel(wxDC
& dc
,
981 const wxString
& label
,
982 const wxRect
& rectFrame
,
983 const wxRect
& rectTextOrig
,
988 wxRect
rectText(rectTextOrig
);
989 rectText
.Inflate(1, 0);
992 DrawLabel(dc
, label
, rectText
, flags
, alignment
, indexAccel
, &rectLabel
);
994 rectLabel
.width
+= 2;
996 DrawFrameWithoutLabel(dc
, rectFrame
, rectLabel
);
998 // GTK+ does it like this
999 dc
.SetPen(m_penHighlight
);
1000 dc
.DrawPoint(rectText
.x
, rectFrame
.y
);
1001 dc
.DrawPoint(rectText
.x
+ rectLabel
.width
- 3, rectFrame
.y
);
1004 // ----------------------------------------------------------------------------
1006 // ----------------------------------------------------------------------------
1008 void wxGTKRenderer::DrawCheckItem(wxDC
& dc
,
1009 const wxString
& label
,
1010 const wxBitmap
& bitmap
,
1014 wxRect rectBitmap
= rect
;
1016 rectBitmap
.width
= GetCheckBitmapSize().x
;
1018 // never draw the focus rect around the check indicators here
1019 DrawCheckButton(dc
, wxEmptyString
, bitmap
, rectBitmap
, flags
& ~wxCONTROL_FOCUSED
);
1021 wxRect rectLabel
= rect
;
1022 wxCoord shift
= rectBitmap
.width
+ 2*GetCheckItemMargin();
1023 rectLabel
.x
+= shift
;
1024 rectLabel
.width
-= shift
;
1025 DrawItem(dc
, label
, rectLabel
, flags
);
1028 // ----------------------------------------------------------------------------
1029 // check/radion buttons
1030 // ----------------------------------------------------------------------------
1032 void wxGTKRenderer::DrawUndeterminedBitmap(wxDC
& dc
,
1033 const wxRect
& rectTotal
,
1036 // FIXME: For sure it is not GTK look but it is better than nothing.
1037 // Show me correct look and I will immediatelly make it better (ABX)
1038 wxRect rect
= rectTotal
;
1040 wxColour col1
, col2
;
1044 col1
= wxSCHEME_COLOUR(m_scheme
, SHADOW_DARK
);
1045 col2
= wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
);
1049 col1
= wxSCHEME_COLOUR(m_scheme
, SHADOW_DARK
);
1050 col2
= wxSCHEME_COLOUR(m_scheme
, SHADOW_IN
);
1053 dc
.SetPen(*wxTRANSPARENT_PEN
);
1055 dc
.DrawRectangle(rect
);
1058 dc
.DrawRectangle(rect
);
1061 void wxGTKRenderer::DrawUncheckBitmap(wxDC
& dc
,
1062 const wxRect
& rectTotal
,
1065 wxRect rect
= rectTotal
;
1066 DrawAntiRaisedBorder(dc
, &rect
);
1068 wxColour col
= wxSCHEME_COLOUR(m_scheme
, SHADOW_IN
);
1069 dc
.SetPen(wxPen(col
));
1070 dc
.DrawPoint(rect
.GetRight() - 1, rect
.GetBottom() - 1);
1073 col
= wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
);
1074 //else: it is SHADOW_IN, leave as is
1076 dc
.SetPen(*wxTRANSPARENT_PEN
);
1078 dc
.DrawRectangle(rect
);
1081 void wxGTKRenderer::DrawCheckBitmap(wxDC
& dc
, const wxRect
& rectTotal
)
1083 wxRect rect
= rectTotal
;
1084 DrawAntiShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
1085 DrawShadedRect(dc
, &rect
, m_penBlack
, m_penLightGrey
);
1087 dc
.SetPen(*wxTRANSPARENT_PEN
);
1088 dc
.SetBrush(wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
));
1089 dc
.DrawRectangle(rect
);
1092 void wxGTKRenderer::DrawRadioBitmap(wxDC
& dc
,
1098 xRight
= rect
.GetRight(),
1099 yBottom
= rect
.GetBottom();
1101 wxCoord yMid
= (y
+ yBottom
) / 2;
1103 // then draw the upper half
1104 dc
.SetPen(flags
& wxCONTROL_CHECKED
? m_penDarkGrey
: m_penHighlight
);
1105 DrawUpZag(dc
, x
, xRight
, yMid
, y
);
1106 DrawUpZag(dc
, x
+ 1, xRight
- 1, yMid
, y
+ 1);
1109 if ( flags
& wxCONTROL_CHECKED
)
1110 dc
.SetPen(m_penBlack
);
1111 else if ( flags
& wxCONTROL_PRESSED
)
1112 dc
.SetPen(wxPen(wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
)));
1113 else // unchecked and unpressed
1117 DrawUpZag(dc
, x
+ 2, xRight
- 2, yMid
, y
+ 2);
1119 // and then the lower one
1120 dc
.SetPen(flags
& wxCONTROL_CHECKED
? m_penHighlight
: m_penBlack
);
1121 DrawDownZag(dc
, x
, xRight
, yMid
, yBottom
);
1122 if ( !(flags
& wxCONTROL_CHECKED
) )
1123 dc
.SetPen(m_penDarkGrey
);
1124 DrawDownZag(dc
, x
+ 1, xRight
- 1, yMid
, yBottom
- 1);
1126 if ( !(flags
& wxCONTROL_CHECKED
) )
1127 drawIt
= true; // with the same pen
1128 else if ( flags
& wxCONTROL_PRESSED
)
1130 dc
.SetPen(wxPen(wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
)));
1133 else // checked and unpressed
1137 DrawDownZag(dc
, x
+ 2, xRight
- 2, yMid
, yBottom
- 2);
1140 void wxGTKRenderer::DrawUpZag(wxDC
& dc
,
1146 wxCoord xMid
= (x1
+ x2
) / 2;
1147 dc
.DrawLine(x1
, y1
, xMid
, y2
);
1148 dc
.DrawLine(xMid
, y2
, x2
+ 1, y1
+ 1);
1151 void wxGTKRenderer::DrawDownZag(wxDC
& dc
,
1157 wxCoord xMid
= (x1
+ x2
) / 2;
1158 dc
.DrawLine(x1
+ 1, y1
+ 1, xMid
, y2
);
1159 dc
.DrawLine(xMid
, y2
, x2
, y1
);
1162 wxBitmap
wxGTKRenderer::GetCheckBitmap(int flags
)
1164 if ( !m_bitmapsCheckbox
[0][0].Ok() )
1166 // init the bitmaps once only
1168 wxSize size
= GetCheckBitmapSize();
1169 rect
.width
= size
.x
;
1170 rect
.height
= size
.y
;
1171 for ( int i
= 0; i
< 2; i
++ )
1173 for ( int j
= 0; j
< 3; j
++ )
1174 m_bitmapsCheckbox
[i
][j
].Create(rect
.width
, rect
.height
);
1180 dc
.SelectObject(m_bitmapsCheckbox
[0][0]);
1181 DrawCheckBitmap(dc
, rect
);
1184 dc
.SelectObject(m_bitmapsCheckbox
[0][1]);
1185 DrawUncheckBitmap(dc
, rect
, false);
1187 // normal undeterminated
1188 dc
.SelectObject(m_bitmapsCheckbox
[0][2]);
1189 DrawUndeterminedBitmap(dc
, rect
, false);
1192 m_bitmapsCheckbox
[1][0] = m_bitmapsCheckbox
[0][0];
1194 // pressed unchecked
1195 dc
.SelectObject(m_bitmapsCheckbox
[1][1]);
1196 DrawUncheckBitmap(dc
, rect
, true);
1198 // pressed undeterminated
1199 dc
.SelectObject(m_bitmapsCheckbox
[1][2]);
1200 DrawUndeterminedBitmap(dc
, rect
, true);
1203 IndicatorState state
;
1204 IndicatorStatus status
;
1205 GetIndicatorsFromFlags(flags
, state
, status
);
1207 // disabled looks the same as normal
1208 if ( state
== IndicatorState_Disabled
)
1209 state
= IndicatorState_Normal
;
1211 return m_bitmapsCheckbox
[state
][status
];
1214 wxBitmap
wxGTKRenderer::GetRadioBitmap(int flags
)
1216 IndicatorState state
;
1217 IndicatorStatus status
;
1218 GetIndicatorsFromFlags(flags
, state
, status
);
1220 wxBitmap
& bmp
= m_bitmapsRadiobtn
[state
][status
];
1223 const wxSize size
= GetRadioBitmapSize();
1226 bmp
.Create(size
.x
, size
.y
);
1227 dc
.SelectObject(bmp
);
1229 DrawRadioBitmap(dc
, size
, flags
);
1235 wxBitmap
wxGTKRenderer::GetLineWrapBitmap() const
1237 if ( !m_bmpLineWrap
.Ok() )
1239 // the line wrap bitmap as used by GTK+
1240 #define line_wrap_width 6
1241 #define line_wrap_height 9
1242 static const char line_wrap_bits
[] =
1244 0x1e, 0x3e, 0x30, 0x30, 0x39, 0x1f, 0x0f, 0x0f, 0x1f,
1247 wxBitmap
bmpLineWrap(line_wrap_bits
, line_wrap_width
, line_wrap_height
);
1248 if ( !bmpLineWrap
.Ok() )
1250 wxFAIL_MSG( _T("Failed to create line wrap XBM") );
1254 wxConstCast(this, wxGTKRenderer
)->m_bmpLineWrap
= bmpLineWrap
;
1258 return m_bmpLineWrap
;
1262 void wxGTKRenderer::DrawToolBarButton(wxDC
& dc
,
1263 const wxString
& label
,
1264 const wxBitmap
& bitmap
,
1265 const wxRect
& rectOrig
,
1267 long WXUNUSED(style
),
1270 // we don't draw the separators at all
1271 if ( !label
.empty() || bitmap
.Ok() )
1273 wxRect rect
= rectOrig
;
1274 rect
.Deflate(BORDER_THICKNESS
);
1276 if ( flags
& wxCONTROL_PRESSED
)
1278 DrawBorder(dc
, wxBORDER_SUNKEN
, rect
, flags
, &rect
);
1280 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
), rect
);
1282 else if ( flags
& wxCONTROL_CURRENT
)
1284 DrawBorder(dc
, wxBORDER_RAISED
, rect
, flags
, &rect
);
1286 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL_CURRENT
), rect
);
1289 if(tbarStyle
& wxTB_TEXT
)
1291 if(tbarStyle
& wxTB_HORIZONTAL
)
1293 dc
.DrawLabel(label
, bitmap
, rect
, wxALIGN_CENTRE
);
1297 dc
.DrawLabel(label
, bitmap
, rect
, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
);
1302 int xpoint
= (rect
.GetLeft() + rect
.GetRight() + 1 - bitmap
.GetWidth()) / 2;
1303 int ypoint
= (rect
.GetTop() + rect
.GetBottom() + 1 - bitmap
.GetHeight()) / 2;
1304 dc
.DrawBitmap(bitmap
, xpoint
, ypoint
);
1308 #endif // wxUSE_TOOLBAR
1310 // ----------------------------------------------------------------------------
1312 // ----------------------------------------------------------------------------
1316 wxRect
wxGTKRenderer::GetTextTotalArea(const wxTextCtrl
* WXUNUSED(text
),
1317 const wxRect
& rect
) const
1319 wxRect rectTotal
= rect
;
1320 rectTotal
.Inflate(2*BORDER_THICKNESS
);
1324 wxRect
wxGTKRenderer::GetTextClientArea(const wxTextCtrl
*text
,
1326 wxCoord
*extraSpaceBeyond
) const
1328 wxRect rectText
= rect
;
1329 rectText
.Deflate(2*BORDER_THICKNESS
);
1331 if ( text
->WrapLines() )
1333 // leave enough for the line wrap bitmap indicator
1334 wxCoord widthMark
= GetLineWrapBitmap().GetWidth() + 2;
1336 rectText
.width
-= widthMark
;
1338 if ( extraSpaceBeyond
)
1339 *extraSpaceBeyond
= widthMark
;
1345 #endif // wxUSE_TEXTCTRL
1347 void wxGTKRenderer::DrawLineWrapMark(wxDC
& dc
, const wxRect
& rect
)
1349 wxBitmap bmpLineWrap
= GetLineWrapBitmap();
1351 // for a mono bitmap he colours it appears in depends on the current text
1352 // colours, so set them correctly
1354 if ( bmpLineWrap
.GetDepth() == 1 )
1356 colFgOld
= dc
.GetTextForeground();
1358 // FIXME: I wonder what should we do if the background is black too?
1359 dc
.SetTextForeground(*wxBLACK
);
1362 dc
.DrawBitmap(bmpLineWrap
,
1363 rect
.x
, rect
.y
+ (rect
.height
- bmpLineWrap
.GetHeight())/2);
1365 if ( colFgOld
.Ok() )
1367 // restore old colour
1368 dc
.SetTextForeground(colFgOld
);
1372 // ----------------------------------------------------------------------------
1374 // ----------------------------------------------------------------------------
1376 void wxGTKRenderer::DrawTab(wxDC
& dc
,
1377 const wxRect
& rectOrig
,
1379 const wxString
& label
,
1380 const wxBitmap
& bitmap
,
1384 #define SELECT_FOR_VERTICAL(X,Y) ( isVertical ? Y : X )
1385 #define REVERSE_FOR_VERTICAL(X,Y) \
1386 SELECT_FOR_VERTICAL(X,Y) \
1388 SELECT_FOR_VERTICAL(Y,X)
1390 wxRect rect
= rectOrig
;
1392 bool isVertical
= ( dir
== wxLEFT
) || ( dir
== wxRIGHT
);
1394 // the current tab is drawn indented (to the top for default case) and
1395 // bigger than the other ones
1396 const wxSize indent
= GetTabIndent();
1397 if ( flags
& wxCONTROL_SELECTED
)
1399 rect
.Inflate( SELECT_FOR_VERTICAL( indent
.x
, 0),
1400 SELECT_FOR_VERTICAL( 0, indent
.y
));
1404 wxFAIL_MSG(_T("invaild notebook tab orientation"));
1411 rect
.height
+= indent
.y
;
1418 rect
.width
+= indent
.x
;
1423 // selected tab has different colour
1424 wxColour col
= flags
& wxCONTROL_SELECTED
1425 ? wxSCHEME_COLOUR(m_scheme
, SHADOW_IN
)
1426 : wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
);
1427 DrawSolidRect(dc
, col
, rect
);
1429 if ( flags
& wxCONTROL_FOCUSED
)
1431 // draw the focus rect
1432 wxRect rectBorder
= rect
;
1433 rectBorder
.Deflate(4, 3);
1434 if ( dir
== wxBOTTOM
)
1435 rectBorder
.Offset(0, -1);
1436 if ( dir
== wxRIGHT
)
1437 rectBorder
.Offset(-1, 0);
1439 DrawRect(dc
, &rectBorder
, m_penBlack
);
1442 // draw the text, image and the focus around them (if necessary)
1443 wxRect
rectLabel( REVERSE_FOR_VERTICAL(rect
.x
,rect
.y
),
1444 REVERSE_FOR_VERTICAL(rect
.width
,rect
.height
)
1446 rectLabel
.Deflate(1, 1);
1449 // draw it horizontally into memory and rotate for screen
1451 wxBitmap bitmapRotated
,
1452 bitmapMem( rectLabel
.x
+ rectLabel
.width
,
1453 rectLabel
.y
+ rectLabel
.height
);
1454 dcMem
.SelectObject(bitmapMem
);
1455 dcMem
.SetBackground(dc
.GetBackground());
1456 dcMem
.SetFont(dc
.GetFont());
1457 dcMem
.SetTextForeground(dc
.GetTextForeground());
1461 wxBitmap( wxImage( bitmap
.ConvertToImage() ).Rotate90(dir
==wxLEFT
) )
1464 #endif // wxUSE_IMAGE
1466 dcMem
.DrawLabel(label
, bitmapRotated
, rectLabel
, wxALIGN_CENTRE
, indexAccel
);
1467 dcMem
.SelectObject(wxNullBitmap
);
1468 bitmapMem
= bitmapMem
.GetSubBitmap(rectLabel
);
1470 bitmapMem
= wxBitmap(wxImage(bitmapMem
.ConvertToImage()).Rotate90(dir
==wxRIGHT
))
1474 dc
.DrawBitmap(bitmapMem
, rectLabel
.y
, rectLabel
.x
, false);
1478 dc
.DrawLabel(label
, bitmap
, rectLabel
, wxALIGN_CENTRE
, indexAccel
);
1481 // now draw the tab itself
1482 wxCoord x
= SELECT_FOR_VERTICAL(rect
.x
,rect
.y
),
1483 y
= SELECT_FOR_VERTICAL(rect
.y
,rect
.x
),
1484 x2
= SELECT_FOR_VERTICAL(rect
.GetRight(),rect
.GetBottom()),
1485 y2
= SELECT_FOR_VERTICAL(rect
.GetBottom(),rect
.GetRight());
1491 // left orientation looks like top but IsVertical makes x and y reversed
1493 // top is not vertical so use coordinates in written order
1494 dc
.SetPen(m_penHighlight
);
1495 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y2
),
1496 REVERSE_FOR_VERTICAL(x
, y
));
1497 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
),
1498 REVERSE_FOR_VERTICAL(x2
, y
));
1500 dc
.SetPen(m_penBlack
);
1501 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y2
),
1502 REVERSE_FOR_VERTICAL(x2
, y
));
1504 dc
.SetPen(m_penDarkGrey
);
1505 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
- 1, y2
),
1506 REVERSE_FOR_VERTICAL(x2
- 1, y
+ 1));
1508 if ( flags
& wxCONTROL_SELECTED
)
1510 dc
.SetPen(m_penLightGrey
);
1512 // overwrite the part of the border below this tab
1513 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
+ 1),
1514 REVERSE_FOR_VERTICAL(x2
- 1, y2
+ 1));
1516 // and the shadow of the tab to the left of us
1517 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
+ 2),
1518 REVERSE_FOR_VERTICAL(x
+ 1, y2
+ 1));
1523 // right orientation looks like bottom but IsVertical makes x and y reversed
1525 // bottom is not vertical so use coordinates in written order
1526 dc
.SetPen(m_penHighlight
);
1528 // we need to continue one pixel further to overwrite the corner of
1529 // the border for the selected tab
1530 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y
- (flags
& wxCONTROL_SELECTED
? 1 : 0)),
1531 REVERSE_FOR_VERTICAL(x
, y2
));
1533 // it doesn't work like this (TODO: implement it properly)
1535 // erase the corner of the tab to the right
1536 dc
.SetPen(m_penLightGrey
);
1537 dc
.DrawPoint(REVERSE_FOR_VERTICAL(x2
- 1, y
- 2));
1538 dc
.DrawPoint(REVERSE_FOR_VERTICAL(x2
- 2, y
- 2));
1539 dc
.DrawPoint(REVERSE_FOR_VERTICAL(x2
- 2, y
- 1));
1542 dc
.SetPen(m_penBlack
);
1543 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
),
1544 REVERSE_FOR_VERTICAL(x2
, y2
));
1545 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y
),
1546 REVERSE_FOR_VERTICAL(x2
, y2
));
1548 dc
.SetPen(m_penDarkGrey
);
1549 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 2, y2
- 1),
1550 REVERSE_FOR_VERTICAL(x2
- 1, y2
- 1));
1551 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
- 1, y
),
1552 REVERSE_FOR_VERTICAL(x2
- 1, y2
));
1554 if ( flags
& wxCONTROL_SELECTED
)
1556 dc
.SetPen(m_penLightGrey
);
1558 // overwrite the part of the (double!) border above this tab
1559 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
- 1),
1560 REVERSE_FOR_VERTICAL(x2
- 1, y
- 1));
1561 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
- 2),
1562 REVERSE_FOR_VERTICAL(x2
- 1, y
- 2));
1564 // and the shadow of the tab to the left of us
1565 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
- 1),
1566 REVERSE_FOR_VERTICAL(x
+ 1, y
- 1));
1574 // ----------------------------------------------------------------------------
1576 // ----------------------------------------------------------------------------
1578 wxSize
wxGTKRenderer::GetSliderThumbSize(const wxRect
& rect
,
1580 wxOrientation orient
) const
1582 static const wxCoord SLIDER_THUMB_LENGTH
= 30;
1586 wxRect rectShaft
= GetSliderShaftRect(rect
, lenThumb
, orient
);
1587 if ( orient
== wxHORIZONTAL
)
1589 size
.x
= wxMin(SLIDER_THUMB_LENGTH
, rectShaft
.width
);
1590 size
.y
= rectShaft
.height
;
1594 size
.y
= wxMin(SLIDER_THUMB_LENGTH
, rectShaft
.height
);
1595 size
.x
= rectShaft
.width
;
1601 wxRect
wxGTKRenderer::GetSliderShaftRect(const wxRect
& rect
,
1602 int WXUNUSED(lenThumb
),
1603 wxOrientation
WXUNUSED(orient
),
1604 long WXUNUSED(style
)) const
1606 return rect
.Deflate(2*BORDER_THICKNESS
, 2*BORDER_THICKNESS
);
1609 void wxGTKRenderer::DrawSliderShaft(wxDC
& dc
,
1610 const wxRect
& rectOrig
,
1611 int WXUNUSED(lenThumb
),
1612 wxOrientation
WXUNUSED(orient
),
1614 long WXUNUSED(style
),
1617 wxRect rect
= rectOrig
;
1619 // draw the border first
1620 if ( flags
& wxCONTROL_FOCUSED
)
1622 DrawRect(dc
, &rect
, m_penBlack
);
1624 else // not focused, normal
1626 DrawAntiShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
1629 DrawAntiShadedRect(dc
, &rect
, m_penBlack
, m_penLightGrey
);
1631 // and the background
1632 DrawSolidRect(dc
, wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
), rect
);
1638 void wxGTKRenderer::DrawSliderThumb(wxDC
& dc
,
1639 const wxRect
& rectOrig
,
1640 wxOrientation orient
,
1641 int WXUNUSED(flags
),
1642 long WXUNUSED(style
))
1644 // draw the thumb border
1645 wxRect rect
= rectOrig
;
1646 DrawAntiRaisedBorder(dc
, &rect
);
1648 // draw the handle in the middle
1649 if ( orient
== wxVERTICAL
)
1651 rect
.height
= 2*BORDER_THICKNESS
;
1652 rect
.y
= rectOrig
.y
+ (rectOrig
.height
- rect
.height
) / 2;
1656 rect
.width
= 2*BORDER_THICKNESS
;
1657 rect
.x
= rectOrig
.x
+ (rectOrig
.width
- rect
.width
) / 2;
1660 DrawShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
1663 #endif // wxUSE_SLIDER
1667 // ----------------------------------------------------------------------------
1669 // ----------------------------------------------------------------------------
1671 // wxGTKMenuGeometryInfo: the wxMenuGeometryInfo used by wxGTKRenderer
1672 class WXDLLEXPORT wxGTKMenuGeometryInfo
: public wxMenuGeometryInfo
1675 virtual wxSize
GetSize() const { return m_size
; }
1677 wxCoord
GetLabelOffset() const { return m_ofsLabel
; }
1678 wxCoord
GetAccelOffset() const { return m_ofsAccel
; }
1680 wxCoord
GetItemHeight() const { return m_heightItem
; }
1683 // the total size of the menu
1686 // the offset of the start of the menu item label
1689 // the offset of the start of the accel label
1692 // the height of a normal (not separator) item
1693 wxCoord m_heightItem
;
1695 friend wxMenuGeometryInfo
*
1696 wxGTKRenderer::GetMenuGeometry(wxWindow
*, const wxMenu
&) const;
1699 // FIXME: all constants are hardcoded but shouldn't be
1700 static const wxCoord MENU_LEFT_MARGIN
= 9;
1701 static const wxCoord MENU_RIGHT_MARGIN
= 6;
1703 static const wxCoord MENU_HORZ_MARGIN
= 6;
1704 static const wxCoord MENU_VERT_MARGIN
= 3;
1706 // the margin around bitmap/check marks (on each side)
1707 static const wxCoord MENU_BMP_MARGIN
= 2;
1709 // the margin between the labels and accel strings
1710 static const wxCoord MENU_ACCEL_MARGIN
= 8;
1712 // the separator height in pixels: in fact, strangely enough, the real height
1713 // is 2 but Windows adds one extra pixel in the bottom margin, so take it into
1715 static const wxCoord MENU_SEPARATOR_HEIGHT
= 3;
1717 // the size of the standard checkmark bitmap
1718 static const wxCoord MENU_CHECK_SIZE
= 9;
1720 void wxGTKRenderer::DrawMenuBarItem(wxDC
& dc
,
1722 const wxString
& label
,
1726 DoDrawMenuItem(dc
, rect
, label
, flags
, indexAccel
);
1729 void wxGTKRenderer::DrawMenuItem(wxDC
& dc
,
1731 const wxMenuGeometryInfo
& gi
,
1732 const wxString
& label
,
1733 const wxString
& accel
,
1734 const wxBitmap
& bitmap
,
1738 const wxGTKMenuGeometryInfo
& geomInfo
= (const wxGTKMenuGeometryInfo
&)gi
;
1743 rect
.width
= geomInfo
.GetSize().x
;
1744 rect
.height
= geomInfo
.GetItemHeight();
1746 DoDrawMenuItem(dc
, rect
, label
, flags
, indexAccel
, accel
, bitmap
, &geomInfo
);
1749 void wxGTKRenderer::DoDrawMenuItem(wxDC
& dc
,
1750 const wxRect
& rectOrig
,
1751 const wxString
& label
,
1754 const wxString
& accel
,
1755 const wxBitmap
& bitmap
,
1756 const wxGTKMenuGeometryInfo
*geometryInfo
)
1758 wxRect rect
= rectOrig
;
1760 // draw the selected item specially
1761 if ( flags
& wxCONTROL_SELECTED
)
1764 DrawBorder(dc
, wxBORDER_RAISED
, rect
, flags
, &rectIn
);
1766 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL_CURRENT
), rectIn
);
1769 rect
.Deflate(MENU_HORZ_MARGIN
, MENU_VERT_MARGIN
);
1771 // draw the bitmap: use the bitmap provided or the standard checkmark for
1772 // the checkable items
1775 wxBitmap bmp
= bitmap
;
1776 if ( !bmp
.Ok() && (flags
& wxCONTROL_CHECKABLE
) )
1778 bmp
= GetCheckBitmap(flags
);
1783 rect
.SetRight(geometryInfo
->GetLabelOffset());
1784 wxControlRenderer::DrawBitmap(dc
, bmp
, rect
);
1787 //else: menubar items don't have bitmaps
1792 rect
.x
= geometryInfo
->GetLabelOffset();
1793 rect
.SetRight(geometryInfo
->GetAccelOffset());
1796 DrawLabel(dc
, label
, rect
, flags
, wxALIGN_CENTRE_VERTICAL
, indexAccel
);
1798 // draw the accel string
1799 if ( !accel
.empty() )
1801 // menubar items shouldn't have them
1802 wxCHECK_RET( geometryInfo
, _T("accel strings only valid for menus") );
1804 rect
.x
= geometryInfo
->GetAccelOffset();
1805 rect
.SetRight(geometryInfo
->GetSize().x
);
1807 // NB: no accel index here
1808 DrawLabel(dc
, accel
, rect
, flags
, wxALIGN_CENTRE_VERTICAL
);
1811 // draw the submenu indicator
1812 if ( flags
& wxCONTROL_ISSUBMENU
)
1814 wxCHECK_RET( geometryInfo
, _T("wxCONTROL_ISSUBMENU only valid for menus") );
1816 rect
.x
= geometryInfo
->GetSize().x
- MENU_RIGHT_MARGIN
;
1817 rect
.width
= MENU_RIGHT_MARGIN
;
1819 DrawArrow(dc
, wxRIGHT
, rect
, flags
);
1823 void wxGTKRenderer::DrawMenuSeparator(wxDC
& dc
,
1825 const wxMenuGeometryInfo
& geomInfo
)
1827 DrawHorizontalLine(dc
, y
+ MENU_VERT_MARGIN
, 0, geomInfo
.GetSize().x
);
1830 wxSize
wxGTKRenderer::GetMenuBarItemSize(const wxSize
& sizeText
) const
1832 wxSize size
= sizeText
;
1834 // TODO: make this configurable
1835 size
.x
+= 2*MENU_HORZ_MARGIN
;
1836 size
.y
+= 2*MENU_VERT_MARGIN
;
1841 wxMenuGeometryInfo
*wxGTKRenderer::GetMenuGeometry(wxWindow
*win
,
1842 const wxMenu
& menu
) const
1844 // prepare the dc: for now we draw all the items with the system font
1846 dc
.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
1848 // the height of a normal item
1849 wxCoord heightText
= dc
.GetCharHeight();
1854 // the max length of label and accel strings: the menu width is the sum of
1855 // them, even if they're for different items (as the accels should be
1858 // the max length of the bitmap is never 0 as Windows always leaves enough
1859 // space for a check mark indicator
1860 wxCoord widthLabelMax
= 0,
1862 widthBmpMax
= MENU_LEFT_MARGIN
;
1864 for ( wxMenuItemList::compatibility_iterator node
= menu
.GetMenuItems().GetFirst();
1866 node
= node
->GetNext() )
1868 // height of this item
1871 wxMenuItem
*item
= node
->GetData();
1872 if ( item
->IsSeparator() )
1874 h
= MENU_SEPARATOR_HEIGHT
;
1876 else // not separator
1881 dc
.GetTextExtent(item
->GetLabel(), &widthLabel
, NULL
);
1882 if ( widthLabel
> widthLabelMax
)
1884 widthLabelMax
= widthLabel
;
1888 dc
.GetTextExtent(item
->GetAccelString(), &widthAccel
, NULL
);
1889 if ( widthAccel
> widthAccelMax
)
1891 widthAccelMax
= widthAccel
;
1894 const wxBitmap
& bmp
= item
->GetBitmap();
1897 wxCoord widthBmp
= bmp
.GetWidth();
1898 if ( widthBmp
> widthBmpMax
)
1899 widthBmpMax
= widthBmp
;
1901 //else if ( item->IsCheckable() ): no need to check for this as
1902 // MENU_LEFT_MARGIN is big enough to show the check mark
1905 h
+= 2*MENU_VERT_MARGIN
;
1907 // remember the item position and height
1908 item
->SetGeometry(height
, h
);
1913 // bundle the metrics into a struct and return it
1914 wxGTKMenuGeometryInfo
*gi
= new wxGTKMenuGeometryInfo
;
1916 gi
->m_ofsLabel
= widthBmpMax
+ 2*MENU_BMP_MARGIN
;
1917 gi
->m_ofsAccel
= gi
->m_ofsLabel
+ widthLabelMax
;
1918 if ( widthAccelMax
> 0 )
1920 // if we actually have any accesl, add a margin
1921 gi
->m_ofsAccel
+= MENU_ACCEL_MARGIN
;
1924 gi
->m_heightItem
= heightText
+ 2*MENU_VERT_MARGIN
;
1926 gi
->m_size
.x
= gi
->m_ofsAccel
+ widthAccelMax
+ MENU_RIGHT_MARGIN
;
1927 gi
->m_size
.y
= height
;
1932 #endif // wxUSE_MENUS
1936 // ----------------------------------------------------------------------------
1938 // ----------------------------------------------------------------------------
1941 wxGTKRenderer::GetStatusBarBorders(wxCoord
* WXUNUSED(borderBetweenFields
)) const
1946 void wxGTKRenderer::DrawStatusField(wxDC
& WXUNUSED(dc
),
1947 const wxRect
& WXUNUSED(rect
),
1948 const wxString
& WXUNUSED(label
),
1949 int WXUNUSED(flags
), int WXUNUSED(style
))
1953 #endif // wxUSE_STATUSBAR
1955 // ----------------------------------------------------------------------------
1957 // ----------------------------------------------------------------------------
1959 void wxGTKRenderer::InitComboBitmaps()
1961 wxSize sizeArrow
= m_sizeScrollbarArrow
;
1967 for ( n
= ComboState_Normal
; n
< ComboState_Max
; n
++ )
1969 m_bitmapsCombo
[n
].Create(sizeArrow
.x
, sizeArrow
.y
);
1972 static const int comboButtonFlags
[ComboState_Max
] =
1980 wxRect
rect(sizeArrow
);
1983 for ( n
= ComboState_Normal
; n
< ComboState_Max
; n
++ )
1985 int flags
= comboButtonFlags
[n
];
1987 dc
.SelectObject(m_bitmapsCombo
[n
]);
1988 DrawSolidRect(dc
, GetBackgroundColour(flags
), rect
);
1989 DrawArrow(dc
, wxDOWN
, rect
, flags
);
1993 void wxGTKRenderer::GetComboBitmaps(wxBitmap
*bmpNormal
,
1995 wxBitmap
*bmpPressed
,
1996 wxBitmap
*bmpDisabled
)
1998 if ( !m_bitmapsCombo
[ComboState_Normal
].Ok() )
2004 *bmpNormal
= m_bitmapsCombo
[ComboState_Normal
];
2006 *bmpFocus
= m_bitmapsCombo
[ComboState_Focus
];
2008 *bmpPressed
= m_bitmapsCombo
[ComboState_Pressed
];
2010 *bmpDisabled
= m_bitmapsCombo
[ComboState_Disabled
];
2013 // ----------------------------------------------------------------------------
2015 // ----------------------------------------------------------------------------
2017 void wxGTKRenderer::DrawArrowBorder(wxDC
& dc
,
2021 static const wxDirection sides
[] =
2023 wxUP
, wxLEFT
, wxRIGHT
, wxDOWN
2026 wxRect rect1
, rect2
, rectInner
;
2032 rectInner
.Inflate(-2);
2034 DrawSolidRect(dc
, wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
), *rect
);
2036 // find the side not to draw and also adjust the rectangles to compensate
2038 wxDirection sideToOmit
;
2042 sideToOmit
= wxDOWN
;
2044 rectInner
.height
+= 1;
2052 rectInner
.height
+= 1;
2056 sideToOmit
= wxRIGHT
;
2058 rectInner
.width
+= 1;
2062 sideToOmit
= wxLEFT
;
2066 rectInner
.width
+= 1;
2070 wxFAIL_MSG(_T("unknown arrow direction"));
2074 // the outer rect first
2076 for ( n
= 0; n
< WXSIZEOF(sides
); n
++ )
2078 wxDirection side
= sides
[n
];
2079 if ( side
== sideToOmit
)
2082 DrawAntiShadedRectSide(dc
, rect1
, m_penDarkGrey
, m_penHighlight
, side
);
2085 // and then the inner one
2086 for ( n
= 0; n
< WXSIZEOF(sides
); n
++ )
2088 wxDirection side
= sides
[n
];
2089 if ( side
== sideToOmit
)
2092 DrawAntiShadedRectSide(dc
, rect2
, m_penBlack
, m_penGrey
, side
);
2098 void wxGTKRenderer::DrawScrollbarArrow(wxDC
& dc
,
2100 const wxRect
& rectArrow
,
2103 // first of all, draw the border around it - but we don't want the border
2104 // on the side opposite to the arrow point
2105 wxRect rect
= rectArrow
;
2106 DrawArrowBorder(dc
, &rect
, dir
);
2108 // then the arrow itself
2109 DrawArrow(dc
, dir
, rect
, flags
);
2112 // gtk_default_draw_arrow() takes ~350 lines and we can't do much better here
2113 // these people are just crazy :-(
2114 void wxGTKRenderer::DrawArrow(wxDC
& dc
,
2127 wxPoint ptArrow
[Point_Max
];
2129 wxColour colInside
= GetBackgroundColour(flags
);
2131 if ( flags
& wxCONTROL_DISABLED
)
2133 penShadow
[0] = m_penDarkGrey
;
2134 penShadow
[1] = m_penDarkGrey
;
2135 penShadow
[2] = wxNullPen
;
2136 penShadow
[3] = wxNullPen
;
2138 else if ( flags
& wxCONTROL_PRESSED
)
2140 penShadow
[0] = m_penDarkGrey
;
2141 penShadow
[1] = m_penHighlight
;
2142 penShadow
[2] = wxNullPen
;
2143 penShadow
[3] = m_penBlack
;
2145 else // normal arrow
2147 penShadow
[0] = m_penHighlight
;
2148 penShadow
[1] = m_penBlack
;
2149 penShadow
[2] = m_penDarkGrey
;
2150 penShadow
[3] = wxNullPen
;
2154 if ( dir
== wxUP
|| dir
== wxDOWN
)
2157 middle
= (rect
.GetRight() + rect
.GetLeft() + 1) / 2;
2161 middle
= (rect
.GetTop() + rect
.GetBottom() + 1) / 2;
2164 // draw the arrow interior
2165 dc
.SetPen(*wxTRANSPARENT_PEN
);
2166 dc
.SetBrush(colInside
);
2171 ptArrow
[Point_First
].x
= rect
.GetLeft();
2172 ptArrow
[Point_First
].y
= rect
.GetBottom();
2173 ptArrow
[Point_Second
].x
= middle
;
2174 ptArrow
[Point_Second
].y
= rect
.GetTop();
2175 ptArrow
[Point_Third
].x
= rect
.GetRight();
2176 ptArrow
[Point_Third
].y
= rect
.GetBottom();
2180 ptArrow
[Point_First
] = rect
.GetPosition();
2181 ptArrow
[Point_Second
].x
= middle
;
2182 ptArrow
[Point_Second
].y
= rect
.GetBottom();
2183 ptArrow
[Point_Third
].x
= rect
.GetRight();
2184 ptArrow
[Point_Third
].y
= rect
.GetTop();
2188 ptArrow
[Point_First
].x
= rect
.GetRight();
2189 ptArrow
[Point_First
].y
= rect
.GetTop();
2190 ptArrow
[Point_Second
].x
= rect
.GetLeft();
2191 ptArrow
[Point_Second
].y
= middle
;
2192 ptArrow
[Point_Third
].x
= rect
.GetRight();
2193 ptArrow
[Point_Third
].y
= rect
.GetBottom();
2197 ptArrow
[Point_First
] = rect
.GetPosition();
2198 ptArrow
[Point_Second
].x
= rect
.GetRight();
2199 ptArrow
[Point_Second
].y
= middle
;
2200 ptArrow
[Point_Third
].x
= rect
.GetLeft();
2201 ptArrow
[Point_Third
].y
= rect
.GetBottom();
2205 wxFAIL_MSG(_T("unknown arrow direction"));
2208 dc
.DrawPolygon(WXSIZEOF(ptArrow
), ptArrow
);
2210 // draw the arrow border
2211 dc
.SetPen(penShadow
[0]);
2215 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_First
]);
2216 dc
.DrawPoint(ptArrow
[Point_First
]);
2217 if ( penShadow
[3].Ok() )
2219 dc
.SetPen(penShadow
[3]);
2220 dc
.DrawLine(ptArrow
[Point_First
].x
+ 1, ptArrow
[Point_First
].y
,
2221 ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
);
2223 dc
.SetPen(penShadow
[1]);
2224 dc
.DrawLine(ptArrow
[Point_Second
].x
+ 1, ptArrow
[Point_Second
].y
+ 1,
2225 ptArrow
[Point_Third
].x
, ptArrow
[Point_Third
].y
);
2226 dc
.DrawPoint(ptArrow
[Point_Third
]);
2227 dc
.DrawLine(ptArrow
[Point_Third
].x
- 2, ptArrow
[Point_Third
].y
,
2228 ptArrow
[Point_First
].x
+ 1, ptArrow
[Point_First
].y
);
2229 if ( penShadow
[2].Ok() )
2231 dc
.SetPen(penShadow
[2]);
2232 dc
.DrawLine(ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
,
2233 ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
+ 1);
2234 dc
.DrawLine(ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
- 1,
2235 ptArrow
[Point_First
].x
+ 2, ptArrow
[Point_First
].y
- 1);
2240 dc
.DrawLine(ptArrow
[Point_First
], ptArrow
[Point_Second
]);
2241 dc
.DrawLine(ptArrow
[Point_First
].x
+ 2, ptArrow
[Point_First
].y
,
2242 ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
);
2243 if ( penShadow
[2].Ok() )
2245 dc
.SetPen(penShadow
[2]);
2246 dc
.DrawLine(ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
- 1,
2247 ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
- 1);
2249 dc
.SetPen(penShadow
[1]);
2250 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_Third
]);
2251 dc
.DrawPoint(ptArrow
[Point_Third
]);
2255 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_First
]);
2256 dc
.DrawPoint(ptArrow
[Point_First
]);
2257 if ( penShadow
[2].Ok() )
2259 dc
.SetPen(penShadow
[2]);
2260 dc
.DrawLine(ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
,
2261 ptArrow
[Point_First
].x
- 1, ptArrow
[Point_First
].y
+ 2);
2262 dc
.DrawLine(ptArrow
[Point_Third
].x
, ptArrow
[Point_Third
].y
,
2263 ptArrow
[Point_Second
].x
+ 2, ptArrow
[Point_Second
].y
+ 1);
2265 dc
.SetPen(penShadow
[1]);
2266 dc
.DrawLine(ptArrow
[Point_Third
].x
, ptArrow
[Point_Third
].y
,
2267 ptArrow
[Point_First
].x
, ptArrow
[Point_First
].y
+ 1);
2268 dc
.DrawLine(ptArrow
[Point_Second
].x
+ 1, ptArrow
[Point_Second
].y
+ 1,
2269 ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
);
2273 dc
.DrawLine(ptArrow
[Point_First
], ptArrow
[Point_Third
]);
2274 dc
.DrawLine(ptArrow
[Point_First
].x
+ 2, ptArrow
[Point_First
].y
+ 1,
2275 ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
);
2276 dc
.SetPen(penShadow
[1]);
2277 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_Third
]);
2278 dc
.DrawPoint(ptArrow
[Point_Third
]);
2282 wxFAIL_MSG(_T("unknown arrow direction"));
2287 void wxGTKRenderer::DrawThumbBorder(wxDC
& dc
,
2289 wxOrientation orient
)
2291 if ( orient
== wxVERTICAL
)
2293 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2295 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2297 rect
->Inflate(-1, 0);
2299 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2301 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2303 rect
->Inflate(-1, 0);
2307 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2309 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2311 rect
->Inflate(0, -1);
2313 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2315 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2317 rect
->Inflate(0, -1);
2321 void wxGTKRenderer::DrawScrollbarThumb(wxDC
& dc
,
2322 wxOrientation orient
,
2326 // the thumb is never pressed never has focus border under GTK and the
2327 // scrollbar background never changes at all
2328 int flagsThumb
= flags
& ~(wxCONTROL_PRESSED
| wxCONTROL_FOCUSED
);
2330 // we don't want the border in the direction of the scrollbar movement
2331 wxRect rectThumb
= rect
;
2332 DrawThumbBorder(dc
, &rectThumb
, orient
);
2334 DrawButtonBorder(dc
, rectThumb
, flagsThumb
, &rectThumb
);
2335 DrawBackground(dc
, wxNullColour
, rectThumb
, flagsThumb
);
2338 void wxGTKRenderer::DrawScrollbarShaft(wxDC
& dc
,
2339 wxOrientation orient
,
2341 int WXUNUSED(flags
))
2343 wxRect rectBar
= rect
;
2344 DrawThumbBorder(dc
, &rectBar
, orient
);
2345 DrawSolidRect(dc
, wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
), rectBar
);
2348 void wxGTKRenderer::DrawScrollCorner(wxDC
& dc
, const wxRect
& rect
)
2350 DrawSolidRect(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL
), rect
);
2354 wxRect
wxGTKRenderer::GetScrollbarRect(const wxScrollBar
*scrollbar
,
2355 wxScrollBar::Element elem
,
2358 // as GTK scrollbars can't be disabled, it makes no sense to remove the
2359 // thumb for a scrollbar with range 0 - instead, make it fill the entire
2361 if ( (elem
== wxScrollBar::Element_Thumb
) && !scrollbar
->GetRange() )
2363 elem
= wxScrollBar::Element_Bar_2
;
2366 return wxStdRenderer::GetScrollbarRect(scrollbar
, elem
, thumbPos
);
2369 #endif // wxUSE_SCROLLBAR
2371 // ----------------------------------------------------------------------------
2373 // ----------------------------------------------------------------------------
2375 void wxGTKRenderer::AdjustSize(wxSize
*size
, const wxWindow
*window
)
2378 if ( wxDynamicCast(window
, wxBitmapButton
) )
2383 #endif // wxUSE_BMPBUTTON
2384 #if wxUSE_BUTTON || wxUSE_TOGGLEBTN
2387 || wxDynamicCast(window
, wxButton
)
2388 # endif // wxUSE_BUTTON
2389 # if wxUSE_TOGGLEBTN
2390 || wxDynamicCast(window
, wxToggleButton
)
2391 # endif // wxUSE_TOGGLEBTN
2394 if ( !(window
->GetWindowStyle() & wxBU_EXACTFIT
) )
2396 // TODO: this is ad hoc...
2397 size
->x
+= 3*window
->GetCharWidth();
2398 wxCoord minBtnHeight
= 18;
2399 if ( size
->y
< minBtnHeight
)
2400 size
->y
= minBtnHeight
;
2402 // button border width
2406 #endif // wxUSE_BUTTON || wxUSE_TOGGLEBTN
2408 if ( wxDynamicCast(window
, wxScrollBar
) )
2410 // we only set the width of vert scrollbars and height of the
2412 if ( window
->GetWindowStyle() & wxSB_HORIZONTAL
)
2413 size
->y
= m_sizeScrollbarArrow
.x
;
2415 size
->x
= m_sizeScrollbarArrow
.x
;
2418 #endif // wxUSE_SCROLLBAR
2420 // take into account the border width
2421 wxRect rectBorder
= GetBorderDimensions(window
->GetBorder());
2422 size
->x
+= rectBorder
.x
+ rectBorder
.width
;
2423 size
->y
+= rectBorder
.y
+ rectBorder
.height
;
2427 // ----------------------------------------------------------------------------
2428 // top level windows
2429 // ----------------------------------------------------------------------------
2431 void wxGTKRenderer::DrawFrameTitleBar(wxDC
& WXUNUSED(dc
),
2432 const wxRect
& WXUNUSED(rect
),
2433 const wxString
& WXUNUSED(title
),
2434 const wxIcon
& WXUNUSED(icon
),
2435 int WXUNUSED(flags
),
2436 int WXUNUSED(specialButton
),
2437 int WXUNUSED(specialButtonFlag
))
2441 void wxGTKRenderer::DrawFrameBorder(wxDC
& WXUNUSED(dc
),
2442 const wxRect
& WXUNUSED(rect
),
2443 int WXUNUSED(flags
))
2447 void wxGTKRenderer::DrawFrameBackground(wxDC
& WXUNUSED(dc
),
2448 const wxRect
& WXUNUSED(rect
),
2449 int WXUNUSED(flags
))
2453 void wxGTKRenderer::DrawFrameTitle(wxDC
& WXUNUSED(dc
),
2454 const wxRect
& WXUNUSED(rect
),
2455 const wxString
& WXUNUSED(title
),
2456 int WXUNUSED(flags
))
2460 void wxGTKRenderer::DrawFrameIcon(wxDC
& WXUNUSED(dc
),
2461 const wxRect
& WXUNUSED(rect
),
2462 const wxIcon
& WXUNUSED(icon
),
2463 int WXUNUSED(flags
))
2467 void wxGTKRenderer::DrawFrameButton(wxDC
& WXUNUSED(dc
),
2468 wxCoord
WXUNUSED(x
),
2469 wxCoord
WXUNUSED(y
),
2470 int WXUNUSED(button
),
2471 int WXUNUSED(flags
))
2476 wxGTKRenderer::GetFrameClientArea(const wxRect
& rect
,
2477 int WXUNUSED(flags
)) const
2483 wxGTKRenderer::GetFrameTotalSize(const wxSize
& clientSize
,
2484 int WXUNUSED(flags
)) const
2489 wxSize
wxGTKRenderer::GetFrameMinSize(int WXUNUSED(flags
)) const
2494 wxSize
wxGTKRenderer::GetFrameIconSize() const
2496 return wxSize(wxDefaultCoord
, wxDefaultCoord
);
2500 wxGTKRenderer::HitTestFrame(const wxRect
& WXUNUSED(rect
),
2501 const wxPoint
& WXUNUSED(pt
),
2502 int WXUNUSED(flags
)) const
2504 return wxHT_TOPLEVEL_CLIENT_AREA
;
2508 // ----------------------------------------------------------------------------
2510 // ----------------------------------------------------------------------------
2512 /* Copyright (c) Julian Smart */
2513 static const char *error_xpm
[] = {
2514 /* columns rows colors chars-per-pixel */
2528 " ................. ",
2529 " ................... ",
2530 " ....................... ",
2531 " ......................... ",
2532 " ........................... ",
2533 " ...........................X ",
2534 " .............................X ",
2535 " ............................... ",
2536 " ...............................X ",
2537 " .................................X ",
2538 " .................................X ",
2539 " .................................XX ",
2540 " ...ooooooooooooooooooooooooooo...XX ",
2541 " ....ooooooooooooooooooooooooooo....X ",
2542 " ....ooooooooooooooooooooooooooo....X ",
2543 " ....ooooooooooooooooooooooooooo....XX ",
2544 " ....ooooooooooooooooooooooooooo....XX ",
2545 " ....ooooooooooooooooooooooooooo....XX ",
2546 " ...ooooooooooooooooooooooooooo...XXX ",
2547 " ...ooooooooooooooooooooooooooo...XXX ",
2548 " .................................XX ",
2549 " .................................XX ",
2550 " ...............................XXX ",
2551 " ...............................XXX ",
2552 " .............................XXX ",
2553 " ...........................XXXX ",
2554 " ...........................XXX ",
2555 " .........................XXX ",
2556 " .......................XXXX ",
2557 " X...................XXXXX ",
2558 " X.................XXXXX ",
2559 " X.............XXXXX ",
2560 " XXXX.....XXXXXXXX ",
2571 /* Copyright (c) Julian Smart */
2572 static const char *info_xpm
[] = {
2573 /* columns rows colors chars-per-pixel */
2597 " .XXXOXXXXXXXoo. ",
2598 " .XOOXXX+XXXXXo. ",
2599 " .XOOOXX+++XXXXoo. ",
2600 " .XOOXXX+++XXXXXo. ",
2601 " .XOOOXXX+++XXXXXXo. ",
2602 " .XOOXXXX+++XXXXXXo. ",
2603 " .XXXXXXX+++XXXXXXX. ",
2604 " .XXXXXXX+++XXXXXXo. ",
2605 " .XXXXXXX+++XXXXXoo. ",
2606 " .XXXXXX+++XXXXXo. ",
2607 " .XXXXXXX+XXXXXXo. ",
2608 " .XXXXXXXXXXXXo. ",
2609 " .XXXXX+++XXXoo. ",
2635 /* Copyright (c) Julian Smart */
2636 static const char *warning_xpm
[] = {
2637 /* columns rows colors chars-per-pixel */
2667 " ..XXXXO@#XXX... ",
2668 " ...XXXXO@#XXXX.. ",
2669 " ..XXXXXO@#XXXX... ",
2670 " ...XXXXXo@OXXXXX.. ",
2671 " ...XXXXXXo@OXXXXXX.. ",
2672 " ..XXXXXXX$@OXXXXXX... ",
2673 " ...XXXXXXXX@XXXXXXXX.. ",
2674 " ...XXXXXXXXXXXXXXXXXX... ",
2675 " ..XXXXXXXXXXOXXXXXXXXX.. ",
2676 " ...XXXXXXXXXO@#XXXXXXXXX.. ",
2677 " ..XXXXXXXXXXX#XXXXXXXXXX... ",
2678 " ...XXXXXXXXXXXXXXXXXXXXXXX.. ",
2679 " ...XXXXXXXXXXXXXXXXXXXXXXXX... ",
2680 " .............................. ",
2681 " .............................. ",
2699 /* Copyright (c) Julian Smart */
2700 static const char *question_xpm
[] = {
2701 /* columns rows colors chars-per-pixel */
2731 " ..XXXXoooooXXXO+ ",
2732 " ..XXooooooooooooX@.. ",
2733 " ..XoooooooooooooooXX#. ",
2734 " $%XoooooooooooooooooXX#. ",
2735 " &.XoooooooXXXXXXooooooXX.. ",
2736 " .XooooooXX.$...$XXoooooX*. ",
2737 " $.XoooooX%.$ .*oooooo=.. ",
2738 " .XooooooX.. -.XoooooX.. ",
2739 " .XoooooX..+ .XoooooX;. ",
2740 " ...XXXX..: .XoooooX;. ",
2741 " ........ >.XoooooX;. ",
2775 wxBitmap
wxGTKArtProvider::CreateBitmap(const wxArtID
& id
,
2776 const wxArtClient
& WXUNUSED(client
),
2777 const wxSize
& WXUNUSED(size
))
2779 if ( id
== wxART_INFORMATION
)
2780 return wxBitmap(info_xpm
);
2781 if ( id
== wxART_ERROR
)
2782 return wxBitmap(error_xpm
);
2783 if ( id
== wxART_WARNING
)
2784 return wxBitmap(warning_xpm
);
2785 if ( id
== wxART_QUESTION
)
2786 return wxBitmap(question_xpm
);
2787 return wxNullBitmap
;
2791 // ============================================================================
2793 // ============================================================================
2795 // ----------------------------------------------------------------------------
2796 // wxGTKInputHandler
2797 // ----------------------------------------------------------------------------
2799 bool wxGTKInputHandler::HandleKey(wxInputConsumer
* WXUNUSED(control
),
2800 const wxKeyEvent
& WXUNUSED(event
),
2801 bool WXUNUSED(pressed
))
2806 bool wxGTKInputHandler::HandleMouse(wxInputConsumer
*control
,
2807 const wxMouseEvent
& event
)
2809 // clicking on the control gives it focus
2810 if ( event
.ButtonDown() && wxWindow::FindFocus() != control
->GetInputWindow() )
2812 control
->GetInputWindow()->SetFocus();
2820 bool wxGTKInputHandler::HandleMouseMove(wxInputConsumer
*control
,
2821 const wxMouseEvent
& event
)
2823 if ( event
.Entering() )
2825 control
->GetInputWindow()->SetCurrent(true);
2827 else if ( event
.Leaving() )
2829 control
->GetInputWindow()->SetCurrent(false);
2841 // ----------------------------------------------------------------------------
2842 // wxGTKCheckboxInputHandler
2843 // ----------------------------------------------------------------------------
2845 bool wxGTKCheckboxInputHandler::HandleKey(wxInputConsumer
*control
,
2846 const wxKeyEvent
& event
,
2851 int keycode
= event
.GetKeyCode();
2852 if ( keycode
== WXK_SPACE
|| keycode
== WXK_RETURN
)
2854 control
->PerformAction(wxACTION_CHECKBOX_TOGGLE
);
2863 #endif // wxUSE_CHECKBOX
2867 // ----------------------------------------------------------------------------
2868 // wxGTKTextCtrlInputHandler
2869 // ----------------------------------------------------------------------------
2871 bool wxGTKTextCtrlInputHandler::HandleKey(wxInputConsumer
*control
,
2872 const wxKeyEvent
& event
,
2875 // handle only GTK-specific text bindings here, the others are handled in
2879 wxControlAction action
;
2880 int keycode
= event
.GetKeyCode();
2881 if ( event
.ControlDown() )
2886 action
= wxACTION_TEXT_HOME
;
2890 action
= wxACTION_TEXT_LEFT
;
2894 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_RIGHT
;
2898 action
= wxACTION_TEXT_END
;
2902 action
= wxACTION_TEXT_RIGHT
;
2906 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_LEFT
;
2910 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_END
;
2914 action
= wxACTION_TEXT_DOWN
;
2918 action
= wxACTION_TEXT_UP
;
2922 //delete the entire line
2923 control
->PerformAction(wxACTION_TEXT_HOME
);
2924 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_END
;
2928 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_WORD_LEFT
;
2932 else if ( event
.AltDown() )
2937 action
= wxACTION_TEXT_WORD_LEFT
;
2941 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_WORD_RIGHT
;
2945 action
= wxACTION_TEXT_WORD_RIGHT
;
2950 if ( action
!= wxACTION_NONE
)
2952 control
->PerformAction(action
);
2958 return wxStdInputHandler::HandleKey(control
, event
, pressed
);
2961 #endif // wxUSE_TEXTCTRL