1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/univ/themes/gtk.cpp
3 // Purpose: wxUniversal theme implementing GTK-like LNF
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ===========================================================================
14 // ===========================================================================
16 // ---------------------------------------------------------------------------
18 // ---------------------------------------------------------------------------
20 // for compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
27 #include "wx/univ/theme.h"
34 #include "wx/dcmemory.h"
35 #include "wx/window.h"
39 #include "wx/bmpbuttn.h"
40 #include "wx/button.h"
41 #include "wx/checkbox.h"
42 #include "wx/listbox.h"
43 #include "wx/checklst.h"
44 #include "wx/combobox.h"
45 #include "wx/scrolbar.h"
46 #include "wx/slider.h"
47 #include "wx/textctrl.h"
48 #include "wx/toolbar.h"
49 #include "wx/statusbr.h"
51 #include "wx/settings.h"
52 #include "wx/toplevel.h"
56 #include "wx/notebook.h"
57 #include "wx/spinbutt.h"
58 #include "wx/artprov.h"
59 #ifdef wxUSE_TOGGLEBTN
60 #include "wx/tglbtn.h"
61 #endif // wxUSE_TOGGLEBTN
63 #include "wx/univ/stdrend.h"
64 #include "wx/univ/inpcons.h"
65 #include "wx/univ/inphand.h"
66 #include "wx/univ/colschem.h"
68 class WXDLLEXPORT wxGTKMenuGeometryInfo
;
70 // ----------------------------------------------------------------------------
72 // ----------------------------------------------------------------------------
74 // standard border size
75 static const int BORDER_THICKNESS
= 2;
77 // ----------------------------------------------------------------------------
78 // wxGTKRenderer: draw the GUI elements in GTK style
79 // ----------------------------------------------------------------------------
81 class wxGTKRenderer
: public wxStdRenderer
84 wxGTKRenderer(const wxColourScheme
*scheme
);
87 virtual void DrawFocusRect(wxDC
& dc
, const wxRect
& rect
, int flags
= 0);
88 virtual void DrawTextBorder(wxDC
& dc
,
92 wxRect
*rectIn
= NULL
);
93 virtual void DrawButtonLabel(wxDC
& dc
,
94 const wxString
& label
,
95 const wxBitmap
& image
,
101 virtual void DrawButtonBorder(wxDC
& dc
,
104 wxRect
*rectIn
= NULL
);
105 virtual void DrawArrow(wxDC
& dc
,
109 virtual void DrawScrollbarArrow(wxDC
& dc
,
113 virtual void DrawScrollbarThumb(wxDC
& dc
,
114 wxOrientation orient
,
117 virtual void DrawScrollbarShaft(wxDC
& dc
,
118 wxOrientation orient
,
123 virtual void DrawToolBarButton(wxDC
& dc
,
124 const wxString
& label
,
125 const wxBitmap
& bitmap
,
130 #endif // wxUSE_TOOLBAR
133 virtual void DrawLineWrapMark(wxDC
& dc
, const wxRect
& rect
);
134 #endif // wxUSE_TEXTCTRL
137 virtual void DrawTab(wxDC
& dc
,
140 const wxString
& label
,
141 const wxBitmap
& bitmap
= wxNullBitmap
,
143 int indexAccel
= -1);
144 #endif // wxUSE_NOTEBOOK
147 virtual void DrawSliderShaft(wxDC
& dc
,
150 wxOrientation orient
,
153 wxRect
*rectShaft
= NULL
);
154 virtual void DrawSliderThumb(wxDC
& dc
,
156 wxOrientation orient
,
159 virtual void DrawSliderTicks(wxDC
& WXUNUSED(dc
),
160 const wxRect
& WXUNUSED(rect
),
161 int WXUNUSED(lenThumb
),
162 wxOrientation
WXUNUSED(orient
),
165 int WXUNUSED(step
) = 1,
166 int WXUNUSED(flags
) = 0,
167 long WXUNUSED(style
) = 0)
169 // we don't have the ticks in GTK version
171 #endif // wxUSE_SLIDER
174 virtual void DrawMenuBarItem(wxDC
& dc
,
176 const wxString
& label
,
178 int indexAccel
= -1);
179 virtual void DrawMenuItem(wxDC
& dc
,
181 const wxMenuGeometryInfo
& geometryInfo
,
182 const wxString
& label
,
183 const wxString
& accel
,
184 const wxBitmap
& bitmap
= wxNullBitmap
,
186 int indexAccel
= -1);
187 virtual void DrawMenuSeparator(wxDC
& dc
,
189 const wxMenuGeometryInfo
& geomInfo
);
190 #endif // wxUSE_MENUS
192 virtual void GetComboBitmaps(wxBitmap
*bmpNormal
,
194 wxBitmap
*bmpPressed
,
195 wxBitmap
*bmpDisabled
);
197 virtual void AdjustSize(wxSize
*size
, const wxWindow
*window
);
199 // geometry and hit testing
201 virtual wxSize
GetScrollbarArrowSize() const
202 { return m_sizeScrollbarArrow
; }
203 #endif // wxUSE_SCROLLBAR
205 virtual wxSize
GetCheckBitmapSize() const
206 { return wxSize(10, 10); }
207 virtual wxSize
GetRadioBitmapSize() const
208 { return wxSize(11, 11); }
209 virtual wxCoord
GetCheckItemMargin() const
213 virtual wxSize
GetToolBarButtonSize(wxCoord
*separator
) const
214 { if ( separator
) *separator
= 5; return wxSize(16, 15); }
215 virtual wxSize
GetToolBarMargin() const
216 { return wxSize(6, 6); }
217 #endif // wxUSE_TOOLBAR
220 virtual wxRect
GetTextClientArea(const wxTextCtrl
*text
,
222 wxCoord
*extraSpaceBeyond
) const;
223 #endif // wxUSE_TEXTCTRL
226 virtual wxSize
GetTabIndent() const { return wxSize(2, 2); }
227 virtual wxSize
GetTabPadding() const { return wxSize(6, 6); }
228 #endif // wxUSE_NOTEBOOK
231 virtual wxCoord
GetSliderDim() const { return 15; }
232 virtual wxCoord
GetSliderTickLen() const { return 0; }
233 virtual wxRect
GetSliderShaftRect(const wxRect
& rect
,
235 wxOrientation orient
,
236 long style
= 0) const;
237 virtual wxSize
GetSliderThumbSize(const wxRect
& rect
,
239 wxOrientation orient
) const;
240 #endif // wxUSE_SLIDER
242 virtual wxSize
GetProgressBarStep() const { return wxSize(16, 32); }
245 virtual wxSize
GetMenuBarItemSize(const wxSize
& sizeText
) const;
246 virtual wxMenuGeometryInfo
*GetMenuGeometry(wxWindow
*win
,
247 const wxMenu
& menu
) const;
248 #endif // wxUSE_MENUS
250 // helpers for "wxBitmap wxColourScheme::Get()"
251 void DrawCheckBitmap(wxDC
& dc
, const wxRect
& rect
);
252 void DrawUncheckBitmap(wxDC
& dc
, const wxRect
& rect
, bool isPressed
);
253 void DrawUndeterminedBitmap(wxDC
& dc
, const wxRect
& rect
, bool isPressed
);
256 // overridden wxStdRenderer methods
257 virtual void DrawSunkenBorder(wxDC
& dc
, wxRect
*rect
);
259 virtual void DrawFrameWithLabel(wxDC
& dc
,
260 const wxString
& label
,
261 const wxRect
& rectFrame
,
262 const wxRect
& rectText
,
267 virtual void DrawCheckItemBitmap(wxDC
& dc
,
268 const wxBitmap
& bitmap
,
272 // get the colour to use for background
273 wxColour
GetBackgroundColour(int flags
) const
275 if ( flags
& wxCONTROL_PRESSED
)
276 return wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
);
277 else if ( flags
& wxCONTROL_CURRENT
)
278 return wxSCHEME_COLOUR(m_scheme
, CONTROL_CURRENT
);
280 return wxSCHEME_COLOUR(m_scheme
, CONTROL
);
283 // as DrawShadedRect() but the pixels in the bottom left and upper right
284 // border are drawn with the pen1, not pen2
285 void DrawAntiShadedRect(wxDC
& dc
, wxRect
*rect
,
286 const wxPen
& pen1
, const wxPen
& pen2
);
288 // used for drawing opened rectangles - draws only one side of it at once
289 // (and doesn't adjust the rect)
290 void DrawAntiShadedRectSide(wxDC
& dc
,
296 // draw an opened rect for the arrow in given direction
297 void DrawArrowBorder(wxDC
& dc
,
301 // draw two sides of the rectangle
302 void DrawThumbBorder(wxDC
& dc
,
304 wxOrientation orient
);
306 // just as DrawRaisedBorder() except that the bottom left and up right
307 // pixels of the interior rect are drawn in another colour (i.e. the inner
308 // rect is drawn with DrawAntiShadedRect() and not DrawShadedRect())
309 void DrawAntiRaisedBorder(wxDC
& dc
, wxRect
*rect
);
311 // draw inner GTK shadow
312 void DrawInnerShadedRect(wxDC
& dc
, wxRect
*rect
);
314 // get the line wrap indicator bitmap
315 wxBitmap
GetLineWrapBitmap() const;
317 virtual wxBitmap
GetCheckBitmap(int flags
);
318 virtual wxBitmap
GetRadioBitmap(int flags
);
320 // draw a /\ or \/ line from (x1, y1) to (x2, y1) passing by the point
322 void DrawUpZag(wxDC
& dc
,
323 wxCoord x1
, wxCoord x2
,
324 wxCoord y1
, wxCoord y2
);
325 void DrawDownZag(wxDC
& dc
,
326 wxCoord x1
, wxCoord x2
,
327 wxCoord y1
, wxCoord y2
);
329 // draw the radio button bitmap for the given state
330 void DrawRadioBitmap(wxDC
& dc
, const wxRect
& rect
, int flags
);
332 // common part of DrawMenuItem() and DrawMenuBarItem()
333 void DoDrawMenuItem(wxDC
& dc
,
335 const wxString
& label
,
338 const wxString
& accel
= wxEmptyString
,
339 const wxBitmap
& bitmap
= wxNullBitmap
,
340 const wxGTKMenuGeometryInfo
*geometryInfo
= NULL
);
342 // initialize the combo bitmaps
343 void InitComboBitmaps();
345 virtual wxBitmap
GetFrameButtonBitmap(FrameButtonType
WXUNUSED(type
))
352 wxSize m_sizeScrollbarArrow
;
357 // the checkbox and radio button bitmaps: first row is for the normal,
358 // second for the pressed state and the columns are for checked, unchecked
359 // and undeterminated respectively
360 wxBitmap m_bitmapsCheckbox
[IndicatorState_MaxCtrl
][IndicatorStatus_Max
],
361 m_bitmapsRadiobtn
[IndicatorState_MaxCtrl
][IndicatorStatus_Max
];
363 // the line wrap bitmap (drawn at the end of wrapped lines)
364 wxBitmap m_bmpLineWrap
;
366 // the combobox bitmaps
376 wxBitmap m_bitmapsCombo
[ComboState_Max
];
379 // ----------------------------------------------------------------------------
380 // wxGTKInputHandler and derived classes: process the keyboard and mouse
381 // messages according to GTK standards
382 // ----------------------------------------------------------------------------
384 class wxGTKInputHandler
: public wxInputHandler
387 wxGTKInputHandler() { }
389 virtual bool HandleKey(wxInputConsumer
*control
,
390 const wxKeyEvent
& event
,
392 virtual bool HandleMouse(wxInputConsumer
*control
,
393 const wxMouseEvent
& event
);
394 virtual bool HandleMouseMove(wxInputConsumer
*control
,
395 const wxMouseEvent
& event
);
400 class wxGTKScrollBarInputHandler
: public wxStdScrollBarInputHandler
403 wxGTKScrollBarInputHandler(wxRenderer
*renderer
, wxInputHandler
*handler
)
404 : wxStdScrollBarInputHandler(renderer
, handler
) { }
407 virtual void Highlight(wxScrollBar
*scrollbar
, bool doIt
)
409 // only arrows and the thumb can be highlighted
410 if ( !IsArrow() && m_htLast
!= wxHT_SCROLLBAR_THUMB
)
413 wxStdScrollBarInputHandler::Highlight(scrollbar
, doIt
);
416 virtual void Press(wxScrollBar
*scrollbar
, bool doIt
)
418 // only arrows can be pressed
422 wxStdScrollBarInputHandler::Press(scrollbar
, doIt
);
425 // any button can be used to drag the scrollbar under GTK+
426 virtual bool IsAllowedButton(int WXUNUSED(button
)) const { return true; }
430 return m_htLast
== wxHT_SCROLLBAR_ARROW_LINE_1
||
431 m_htLast
== wxHT_SCROLLBAR_ARROW_LINE_2
;
435 #endif // wxUSE_SCROLLBAR
439 class wxGTKCheckboxInputHandler
: public wxStdInputHandler
442 wxGTKCheckboxInputHandler(wxInputHandler
*handler
)
443 : wxStdInputHandler(handler
) { }
445 virtual bool HandleKey(wxInputConsumer
*control
,
446 const wxKeyEvent
& event
,
450 #endif // wxUSE_CHECKBOX
454 class wxGTKTextCtrlInputHandler
: public wxStdInputHandler
457 wxGTKTextCtrlInputHandler(wxInputHandler
*handler
)
458 : wxStdInputHandler(handler
) { }
460 virtual bool HandleKey(wxInputConsumer
*control
,
461 const wxKeyEvent
& event
,
465 #endif // wxUSE_TEXTCTRL
467 // ----------------------------------------------------------------------------
468 // wxGTKColourScheme: uses the standard GTK colours
469 // ----------------------------------------------------------------------------
471 class wxGTKColourScheme
: public wxColourScheme
474 virtual wxColour
Get(StdColour col
) const;
475 virtual wxColour
GetBackground(wxWindow
*win
) const;
478 // ----------------------------------------------------------------------------
480 // ----------------------------------------------------------------------------
482 class wxGTKArtProvider
: public wxArtProvider
485 virtual wxBitmap
CreateBitmap(const wxArtID
& id
,
486 const wxArtClient
& client
,
490 // ----------------------------------------------------------------------------
492 // ----------------------------------------------------------------------------
494 WX_DEFINE_ARRAY_PTR(wxInputHandler
*, wxArrayHandlers
);
496 class wxGTKTheme
: public wxTheme
500 virtual ~wxGTKTheme();
502 virtual wxRenderer
*GetRenderer();
503 virtual wxArtProvider
*GetArtProvider();
504 virtual wxInputHandler
*GetInputHandler(const wxString
& control
,
505 wxInputConsumer
*consumer
);
506 virtual wxColourScheme
*GetColourScheme();
509 wxGTKRenderer
*m_renderer
;
511 wxGTKArtProvider
*m_artProvider
;
513 // the names of the already created handlers and the handlers themselves
514 // (these arrays are synchronized)
515 wxSortedArrayString m_handlerNames
;
516 wxArrayHandlers m_handlers
;
518 wxGTKColourScheme
*m_scheme
;
520 WX_DECLARE_THEME(gtk
)
523 // ============================================================================
525 // ============================================================================
527 WX_IMPLEMENT_THEME(wxGTKTheme
, gtk
, wxTRANSLATE("GTK+ theme"));
529 // ----------------------------------------------------------------------------
531 // ----------------------------------------------------------------------------
533 wxGTKTheme::wxGTKTheme()
537 m_artProvider
= NULL
;
540 wxGTKTheme::~wxGTKTheme()
544 delete m_artProvider
;
547 wxRenderer
*wxGTKTheme::GetRenderer()
551 m_renderer
= new wxGTKRenderer(GetColourScheme());
557 wxArtProvider
*wxGTKTheme::GetArtProvider()
559 if ( !m_artProvider
)
561 m_artProvider
= new wxGTKArtProvider
;
564 return m_artProvider
;
567 wxColourScheme
*wxGTKTheme::GetColourScheme()
571 m_scheme
= new wxGTKColourScheme
;
576 wxInputHandler
*wxGTKTheme::GetInputHandler(const wxString
& control
,
577 wxInputConsumer
*consumer
)
579 wxInputHandler
*handler
= NULL
;
580 int n
= m_handlerNames
.Index(control
);
581 if ( n
== wxNOT_FOUND
)
583 static wxGTKInputHandler s_handlerDef
;
585 wxInputHandler
* const
586 handlerStd
= consumer
->DoGetStdInputHandler(&s_handlerDef
);
588 // create a new handler
590 if ( control
== wxINP_HANDLER_CHECKBOX
)
592 static wxGTKCheckboxInputHandler
s_handler(handlerStd
);
594 handler
= &s_handler
;
597 #endif // wxUSE_CHECKBOX
599 if ( control
== wxINP_HANDLER_SCROLLBAR
)
601 static wxGTKScrollBarInputHandler
s_handler(m_renderer
, handlerStd
);
603 handler
= &s_handler
;
606 #endif // wxUSE_SCROLLBAR
608 if ( control
== wxINP_HANDLER_TEXTCTRL
)
610 static wxGTKTextCtrlInputHandler
s_handler(handlerStd
);
612 handler
= &s_handler
;
615 #endif // wxUSE_TEXTCTRL
617 // no special handler for this control
618 handler
= handlerStd
;
621 n
= m_handlerNames
.Add(control
);
622 m_handlers
.Insert(handler
, n
);
624 else // we already have it
626 handler
= m_handlers
[n
];
632 // ============================================================================
634 // ============================================================================
636 wxColour
wxGTKColourScheme::GetBackground(wxWindow
*win
) const
639 if ( win
->UseBgCol() )
641 // use the user specified colour
642 col
= win
->GetBackgroundColour();
645 if ( !win
->ShouldInheritColours() )
647 // doesn't depend on the state
655 int flags
= win
->GetStateFlags();
657 // the colour set by the user should be used for the normal state
658 // and for the states for which we don't have any specific colours
659 if ( !col
.Ok() || (flags
!= 0) )
662 if ( wxDynamicCast(win
, wxScrollBar
) )
663 col
= Get(SCROLLBAR
);
665 #endif //wxUSE_SCROLLBAR
666 if ( (flags
& wxCONTROL_CURRENT
) && win
->CanBeHighlighted() )
667 col
= Get(CONTROL_CURRENT
);
668 else if ( flags
& wxCONTROL_PRESSED
)
669 col
= Get(CONTROL_PRESSED
);
678 wxColour
wxGTKColourScheme::Get(wxGTKColourScheme::StdColour col
) const
682 case WINDOW
: return *wxWHITE
;
684 case SHADOW_DARK
: return *wxBLACK
;
685 case SHADOW_HIGHLIGHT
: return *wxWHITE
;
686 case SHADOW_IN
: return wxColour(0xd6d6d6);
687 case SHADOW_OUT
: return wxColour(0x969696);
689 case CONTROL
: return wxColour(0xd6d6d6);
690 case CONTROL_PRESSED
: return wxColour(0xc3c3c3);
691 case CONTROL_CURRENT
: return wxColour(0xeaeaea);
693 case CONTROL_TEXT
: return *wxBLACK
;
694 case CONTROL_TEXT_DISABLED
:
695 return wxColour(0x757575);
696 case CONTROL_TEXT_DISABLED_SHADOW
:
700 case SCROLLBAR_PRESSED
: return wxColour(0xc3c3c3);
702 case HIGHLIGHT
: return wxColour(0x9c0000);
703 case HIGHLIGHT_TEXT
: return wxColour(0xffffff);
705 case GAUGE
: return Get(CONTROL_CURRENT
);
707 case TITLEBAR
: return wxColour(0xaeaaae);
708 case TITLEBAR_ACTIVE
: return wxColour(0x820300);
709 case TITLEBAR_TEXT
: return wxColour(0xc0c0c0);
710 case TITLEBAR_ACTIVE_TEXT
:
713 case DESKTOP
: return *wxBLACK
;
717 wxFAIL_MSG(_T("invalid standard colour"));
722 // ============================================================================
724 // ============================================================================
726 // ----------------------------------------------------------------------------
728 // ----------------------------------------------------------------------------
730 wxGTKRenderer::wxGTKRenderer(const wxColourScheme
*scheme
)
731 : wxStdRenderer(scheme
)
733 m_sizeScrollbarArrow
= wxSize(15, 14);
735 m_penGrey
= wxPen(wxSCHEME_COLOUR(scheme
, SCROLLBAR
));
738 // ----------------------------------------------------------------------------
740 // ----------------------------------------------------------------------------
742 void wxGTKRenderer::DrawAntiShadedRectSide(wxDC
& dc
,
748 dc
.SetPen(dir
== wxLEFT
|| dir
== wxUP
? pen1
: pen2
);
753 dc
.DrawLine(rect
.GetLeft(), rect
.GetTop(),
754 rect
.GetLeft(), rect
.GetBottom() + 1);
758 dc
.DrawLine(rect
.GetLeft(), rect
.GetTop(),
759 rect
.GetRight() + 1, rect
.GetTop());
763 dc
.DrawLine(rect
.GetRight(), rect
.GetTop(),
764 rect
.GetRight(), rect
.GetBottom() + 1);
768 dc
.DrawLine(rect
.GetLeft(), rect
.GetBottom(),
769 rect
.GetRight() + 1, rect
.GetBottom());
773 wxFAIL_MSG(_T("unknown rectangle side"));
777 void wxGTKRenderer::DrawAntiShadedRect(wxDC
& dc
, wxRect
*rect
,
778 const wxPen
& pen1
, const wxPen
& pen2
)
780 // draw the rectangle
782 dc
.DrawLine(rect
->GetLeft(), rect
->GetTop(),
783 rect
->GetLeft(), rect
->GetBottom() + 1);
784 dc
.DrawLine(rect
->GetLeft() + 1, rect
->GetTop(),
785 rect
->GetRight() + 1, rect
->GetTop());
787 dc
.DrawLine(rect
->GetRight(), rect
->GetTop() + 1,
788 rect
->GetRight(), rect
->GetBottom());
789 dc
.DrawLine(rect
->GetLeft() + 1, rect
->GetBottom(),
790 rect
->GetRight() + 1, rect
->GetBottom());
796 void wxGTKRenderer::DrawInnerShadedRect(wxDC
& dc
, wxRect
*rect
)
798 DrawAntiShadedRect(dc
, rect
, m_penDarkGrey
, m_penHighlight
);
799 DrawAntiShadedRect(dc
, rect
, m_penBlack
, m_penHighlight
);
802 void wxGTKRenderer::DrawAntiRaisedBorder(wxDC
& dc
, wxRect
*rect
)
804 DrawShadedRect(dc
, rect
, m_penHighlight
, m_penBlack
);
805 DrawAntiShadedRect(dc
, rect
, m_penLightGrey
, m_penDarkGrey
);
808 void wxGTKRenderer::DrawSunkenBorder(wxDC
& dc
, wxRect
*rect
)
810 DrawAntiShadedRect(dc
, rect
, m_penDarkGrey
, m_penHighlight
);
811 DrawShadedRect(dc
, rect
, m_penBlack
, m_penLightGrey
);
815 wxGTKRenderer::DrawFocusRect(wxDC
& dc
, const wxRect
& rect
, int WXUNUSED(flags
))
817 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
818 wxRect rectFocus
= rect
;
819 DrawRect(dc
, &rectFocus
, m_penBlack
);
822 void wxGTKRenderer::DrawTextBorder(wxDC
& dc
,
824 const wxRect
& rectOrig
,
828 wxRect rect
= rectOrig
;
830 if ( border
!= wxBORDER_NONE
)
832 if ( flags
& wxCONTROL_FOCUSED
)
834 DrawRect(dc
, &rect
, m_penBlack
);
835 DrawAntiShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
839 DrawInnerShadedRect(dc
, &rect
);
847 void wxGTKRenderer::DrawButtonLabel(wxDC
& dc
,
848 const wxString
& label
,
849 const wxBitmap
& image
,
856 // no focus rect around buttons label in GTK+
857 wxStdRenderer::DrawButtonLabel(dc
, label
, image
, rect
, flags
,
858 alignment
, indexAccel
, rectBounds
);
861 void wxGTKRenderer::DrawButtonBorder(wxDC
& dc
,
862 const wxRect
& rectTotal
,
866 wxRect rect
= rectTotal
;
868 if ( flags
& wxCONTROL_PRESSED
)
870 // button pressed: draw a black border around it and an inward shade
871 DrawRect(dc
, &rect
, m_penBlack
);
873 DrawInnerShadedRect(dc
, &rect
);
875 else // button not pressed
877 if ( flags
& wxCONTROL_ISDEFAULT
)
882 if ( flags
& wxCONTROL_FOCUSED
)
884 // button is currently default: add an extra border around it
885 DrawRect(dc
, &rect
, m_penBlack
);
888 // now draw a normal button
889 DrawShadedRect(dc
, &rect
, m_penHighlight
, m_penBlack
);
890 DrawAntiShadedRect(dc
, &rect
, GetBackgroundColour(flags
), m_penDarkGrey
);
897 // ----------------------------------------------------------------------------
899 // ----------------------------------------------------------------------------
901 void wxGTKRenderer::DrawFrameWithLabel(wxDC
& dc
,
902 const wxString
& label
,
903 const wxRect
& rectFrame
,
904 const wxRect
& rectTextOrig
,
909 wxRect
rectText(rectTextOrig
);
910 rectText
.Inflate(1, 0);
913 DrawLabel(dc
, label
, rectText
, flags
, alignment
, indexAccel
, &rectLabel
);
915 rectLabel
.width
+= 2;
917 DrawFrameWithoutLabel(dc
, rectFrame
, rectLabel
);
919 // GTK+ does it like this
920 dc
.SetPen(m_penHighlight
);
921 dc
.DrawPoint(rectText
.x
, rectFrame
.y
);
922 dc
.DrawPoint(rectText
.x
+ rectLabel
.width
- 3, rectFrame
.y
);
925 // ----------------------------------------------------------------------------
926 // check/radion buttons
927 // ----------------------------------------------------------------------------
929 void wxGTKRenderer::DrawCheckItemBitmap(wxDC
& dc
,
930 const wxBitmap
& bitmap
,
934 // never draw the focus rect around the check indicators here
935 DrawCheckButton(dc
, wxEmptyString
, bitmap
, rect
, flags
& ~wxCONTROL_FOCUSED
);
938 void wxGTKRenderer::DrawUndeterminedBitmap(wxDC
& dc
,
939 const wxRect
& rectTotal
,
942 // FIXME: For sure it is not GTK look but it is better than nothing.
943 // Show me correct look and I will immediatelly make it better (ABX)
944 wxRect rect
= rectTotal
;
950 col1
= wxSCHEME_COLOUR(m_scheme
, SHADOW_DARK
);
951 col2
= wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
);
955 col1
= wxSCHEME_COLOUR(m_scheme
, SHADOW_DARK
);
956 col2
= wxSCHEME_COLOUR(m_scheme
, SHADOW_IN
);
959 dc
.SetPen(*wxTRANSPARENT_PEN
);
961 dc
.DrawRectangle(rect
);
964 dc
.DrawRectangle(rect
);
967 void wxGTKRenderer::DrawUncheckBitmap(wxDC
& dc
,
968 const wxRect
& rectTotal
,
971 wxRect rect
= rectTotal
;
972 DrawAntiRaisedBorder(dc
, &rect
);
974 wxColour col
= wxSCHEME_COLOUR(m_scheme
, SHADOW_IN
);
975 dc
.SetPen(wxPen(col
));
976 dc
.DrawPoint(rect
.GetRight() - 1, rect
.GetBottom() - 1);
979 col
= wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
);
980 //else: it is SHADOW_IN, leave as is
982 dc
.SetPen(*wxTRANSPARENT_PEN
);
984 dc
.DrawRectangle(rect
);
987 void wxGTKRenderer::DrawCheckBitmap(wxDC
& dc
, const wxRect
& rectTotal
)
989 wxRect rect
= rectTotal
;
990 DrawAntiShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
991 DrawShadedRect(dc
, &rect
, m_penBlack
, m_penLightGrey
);
993 dc
.SetPen(*wxTRANSPARENT_PEN
);
994 dc
.SetBrush(wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
));
995 dc
.DrawRectangle(rect
);
998 void wxGTKRenderer::DrawRadioBitmap(wxDC
& dc
,
1004 xRight
= rect
.GetRight(),
1005 yBottom
= rect
.GetBottom();
1007 wxCoord yMid
= (y
+ yBottom
) / 2;
1009 // then draw the upper half
1010 dc
.SetPen(flags
& wxCONTROL_CHECKED
? m_penDarkGrey
: m_penHighlight
);
1011 DrawUpZag(dc
, x
, xRight
, yMid
, y
);
1012 DrawUpZag(dc
, x
+ 1, xRight
- 1, yMid
, y
+ 1);
1015 if ( flags
& wxCONTROL_CHECKED
)
1016 dc
.SetPen(m_penBlack
);
1017 else if ( flags
& wxCONTROL_PRESSED
)
1018 dc
.SetPen(wxPen(wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
)));
1019 else // unchecked and unpressed
1023 DrawUpZag(dc
, x
+ 2, xRight
- 2, yMid
, y
+ 2);
1025 // and then the lower one
1026 dc
.SetPen(flags
& wxCONTROL_CHECKED
? m_penHighlight
: m_penBlack
);
1027 DrawDownZag(dc
, x
, xRight
, yMid
, yBottom
);
1028 if ( !(flags
& wxCONTROL_CHECKED
) )
1029 dc
.SetPen(m_penDarkGrey
);
1030 DrawDownZag(dc
, x
+ 1, xRight
- 1, yMid
, yBottom
- 1);
1032 if ( !(flags
& wxCONTROL_CHECKED
) )
1033 drawIt
= true; // with the same pen
1034 else if ( flags
& wxCONTROL_PRESSED
)
1036 dc
.SetPen(wxPen(wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
)));
1039 else // checked and unpressed
1043 DrawDownZag(dc
, x
+ 2, xRight
- 2, yMid
, yBottom
- 2);
1046 void wxGTKRenderer::DrawUpZag(wxDC
& dc
,
1052 wxCoord xMid
= (x1
+ x2
) / 2;
1053 dc
.DrawLine(x1
, y1
, xMid
, y2
);
1054 dc
.DrawLine(xMid
, y2
, x2
+ 1, y1
+ 1);
1057 void wxGTKRenderer::DrawDownZag(wxDC
& dc
,
1063 wxCoord xMid
= (x1
+ x2
) / 2;
1064 dc
.DrawLine(x1
+ 1, y1
+ 1, xMid
, y2
);
1065 dc
.DrawLine(xMid
, y2
, x2
, y1
);
1068 wxBitmap
wxGTKRenderer::GetCheckBitmap(int flags
)
1070 if ( !m_bitmapsCheckbox
[0][0].Ok() )
1072 // init the bitmaps once only
1074 wxSize size
= GetCheckBitmapSize();
1075 rect
.width
= size
.x
;
1076 rect
.height
= size
.y
;
1077 for ( int i
= 0; i
< 2; i
++ )
1079 for ( int j
= 0; j
< 3; j
++ )
1080 m_bitmapsCheckbox
[i
][j
].Create(rect
.width
, rect
.height
);
1086 dc
.SelectObject(m_bitmapsCheckbox
[0][0]);
1087 DrawCheckBitmap(dc
, rect
);
1090 dc
.SelectObject(m_bitmapsCheckbox
[0][1]);
1091 DrawUncheckBitmap(dc
, rect
, false);
1093 // normal undeterminated
1094 dc
.SelectObject(m_bitmapsCheckbox
[0][2]);
1095 DrawUndeterminedBitmap(dc
, rect
, false);
1098 m_bitmapsCheckbox
[1][0] = m_bitmapsCheckbox
[0][0];
1100 // pressed unchecked
1101 dc
.SelectObject(m_bitmapsCheckbox
[1][1]);
1102 DrawUncheckBitmap(dc
, rect
, true);
1104 // pressed undeterminated
1105 dc
.SelectObject(m_bitmapsCheckbox
[1][2]);
1106 DrawUndeterminedBitmap(dc
, rect
, true);
1109 IndicatorState state
;
1110 IndicatorStatus status
;
1111 GetIndicatorsFromFlags(flags
, state
, status
);
1113 // disabled looks the same as normal
1114 if ( state
== IndicatorState_Disabled
)
1115 state
= IndicatorState_Normal
;
1117 return m_bitmapsCheckbox
[state
][status
];
1120 wxBitmap
wxGTKRenderer::GetRadioBitmap(int flags
)
1122 IndicatorState state
;
1123 IndicatorStatus status
;
1124 GetIndicatorsFromFlags(flags
, state
, status
);
1126 wxBitmap
& bmp
= m_bitmapsRadiobtn
[state
][status
];
1129 const wxSize size
= GetRadioBitmapSize();
1132 bmp
.Create(size
.x
, size
.y
);
1133 dc
.SelectObject(bmp
);
1135 DrawRadioBitmap(dc
, size
, flags
);
1141 wxBitmap
wxGTKRenderer::GetLineWrapBitmap() const
1143 if ( !m_bmpLineWrap
.Ok() )
1145 // the line wrap bitmap as used by GTK+
1146 #define line_wrap_width 6
1147 #define line_wrap_height 9
1148 static const char line_wrap_bits
[] =
1150 0x1e, 0x3e, 0x30, 0x30, 0x39, 0x1f, 0x0f, 0x0f, 0x1f,
1153 wxBitmap
bmpLineWrap(line_wrap_bits
, line_wrap_width
, line_wrap_height
);
1154 if ( !bmpLineWrap
.Ok() )
1156 wxFAIL_MSG( _T("Failed to create line wrap XBM") );
1160 wxConstCast(this, wxGTKRenderer
)->m_bmpLineWrap
= bmpLineWrap
;
1164 return m_bmpLineWrap
;
1168 void wxGTKRenderer::DrawToolBarButton(wxDC
& dc
,
1169 const wxString
& label
,
1170 const wxBitmap
& bitmap
,
1171 const wxRect
& rectOrig
,
1173 long WXUNUSED(style
),
1176 // we don't draw the separators at all
1177 if ( !label
.empty() || bitmap
.Ok() )
1179 wxRect rect
= rectOrig
;
1180 rect
.Deflate(BORDER_THICKNESS
);
1182 if ( flags
& wxCONTROL_PRESSED
)
1184 DrawBorder(dc
, wxBORDER_SUNKEN
, rect
, flags
, &rect
);
1186 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
), rect
);
1188 else if ( flags
& wxCONTROL_CURRENT
)
1190 DrawBorder(dc
, wxBORDER_RAISED
, rect
, flags
, &rect
);
1192 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL_CURRENT
), rect
);
1195 if(tbarStyle
& wxTB_TEXT
)
1197 if(tbarStyle
& wxTB_HORIZONTAL
)
1199 dc
.DrawLabel(label
, bitmap
, rect
, wxALIGN_CENTRE
);
1203 dc
.DrawLabel(label
, bitmap
, rect
, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
);
1208 int xpoint
= (rect
.GetLeft() + rect
.GetRight() + 1 - bitmap
.GetWidth()) / 2;
1209 int ypoint
= (rect
.GetTop() + rect
.GetBottom() + 1 - bitmap
.GetHeight()) / 2;
1210 dc
.DrawBitmap(bitmap
, xpoint
, ypoint
);
1214 #endif // wxUSE_TOOLBAR
1216 // ----------------------------------------------------------------------------
1218 // ----------------------------------------------------------------------------
1222 wxRect
wxGTKRenderer::GetTextClientArea(const wxTextCtrl
*text
,
1224 wxCoord
*extraSpaceBeyond
) const
1227 rectText
= wxStdRenderer::GetTextClientArea(text
, rect
, extraSpaceBeyond
);
1229 if ( text
->WrapLines() )
1231 // leave enough for the line wrap bitmap indicator
1232 wxCoord widthMark
= GetLineWrapBitmap().GetWidth() + 2;
1234 rectText
.width
-= widthMark
;
1236 if ( extraSpaceBeyond
)
1237 *extraSpaceBeyond
= widthMark
;
1243 void wxGTKRenderer::DrawLineWrapMark(wxDC
& dc
, const wxRect
& rect
)
1245 wxBitmap bmpLineWrap
= GetLineWrapBitmap();
1247 // for a mono bitmap he colours it appears in depends on the current text
1248 // colours, so set them correctly
1250 if ( bmpLineWrap
.GetDepth() == 1 )
1252 colFgOld
= dc
.GetTextForeground();
1254 // FIXME: I wonder what should we do if the background is black too?
1255 dc
.SetTextForeground(*wxBLACK
);
1258 dc
.DrawBitmap(bmpLineWrap
,
1259 rect
.x
, rect
.y
+ (rect
.height
- bmpLineWrap
.GetHeight())/2);
1261 if ( colFgOld
.Ok() )
1263 // restore old colour
1264 dc
.SetTextForeground(colFgOld
);
1268 #endif // wxUSE_TEXTCTRL
1270 // ----------------------------------------------------------------------------
1272 // ----------------------------------------------------------------------------
1276 void wxGTKRenderer::DrawTab(wxDC
& dc
,
1277 const wxRect
& rectOrig
,
1279 const wxString
& label
,
1280 const wxBitmap
& bitmap
,
1284 #define SELECT_FOR_VERTICAL(X,Y) ( isVertical ? Y : X )
1285 #define REVERSE_FOR_VERTICAL(X,Y) \
1286 SELECT_FOR_VERTICAL(X,Y) \
1288 SELECT_FOR_VERTICAL(Y,X)
1290 wxRect rect
= rectOrig
;
1292 bool isVertical
= ( dir
== wxLEFT
) || ( dir
== wxRIGHT
);
1294 // the current tab is drawn indented (to the top for default case) and
1295 // bigger than the other ones
1296 const wxSize indent
= GetTabIndent();
1297 if ( flags
& wxCONTROL_SELECTED
)
1299 rect
.Inflate( SELECT_FOR_VERTICAL( indent
.x
, 0),
1300 SELECT_FOR_VERTICAL( 0, indent
.y
));
1304 wxFAIL_MSG(_T("invaild notebook tab orientation"));
1311 rect
.height
+= indent
.y
;
1318 rect
.width
+= indent
.x
;
1323 // selected tab has different colour
1324 wxColour col
= flags
& wxCONTROL_SELECTED
1325 ? wxSCHEME_COLOUR(m_scheme
, SHADOW_IN
)
1326 : wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
);
1327 DrawSolidRect(dc
, col
, rect
);
1329 if ( flags
& wxCONTROL_FOCUSED
)
1331 // draw the focus rect
1332 wxRect rectBorder
= rect
;
1333 rectBorder
.Deflate(4, 3);
1334 if ( dir
== wxBOTTOM
)
1335 rectBorder
.Offset(0, -1);
1336 if ( dir
== wxRIGHT
)
1337 rectBorder
.Offset(-1, 0);
1339 DrawRect(dc
, &rectBorder
, m_penBlack
);
1342 // draw the text, image and the focus around them (if necessary)
1343 wxRect
rectLabel( REVERSE_FOR_VERTICAL(rect
.x
,rect
.y
),
1344 REVERSE_FOR_VERTICAL(rect
.width
,rect
.height
)
1346 rectLabel
.Deflate(1, 1);
1349 // draw it horizontally into memory and rotate for screen
1351 wxBitmap bitmapRotated
,
1352 bitmapMem( rectLabel
.x
+ rectLabel
.width
,
1353 rectLabel
.y
+ rectLabel
.height
);
1354 dcMem
.SelectObject(bitmapMem
);
1355 dcMem
.SetBackground(dc
.GetBackground());
1356 dcMem
.SetFont(dc
.GetFont());
1357 dcMem
.SetTextForeground(dc
.GetTextForeground());
1361 wxBitmap( wxImage( bitmap
.ConvertToImage() ).Rotate90(dir
==wxLEFT
) )
1364 #endif // wxUSE_IMAGE
1366 dcMem
.DrawLabel(label
, bitmapRotated
, rectLabel
, wxALIGN_CENTRE
, indexAccel
);
1367 dcMem
.SelectObject(wxNullBitmap
);
1368 bitmapMem
= bitmapMem
.GetSubBitmap(rectLabel
);
1370 bitmapMem
= wxBitmap(wxImage(bitmapMem
.ConvertToImage()).Rotate90(dir
==wxRIGHT
))
1374 dc
.DrawBitmap(bitmapMem
, rectLabel
.y
, rectLabel
.x
, false);
1378 dc
.DrawLabel(label
, bitmap
, rectLabel
, wxALIGN_CENTRE
, indexAccel
);
1381 // now draw the tab itself
1382 wxCoord x
= SELECT_FOR_VERTICAL(rect
.x
,rect
.y
),
1383 y
= SELECT_FOR_VERTICAL(rect
.y
,rect
.x
),
1384 x2
= SELECT_FOR_VERTICAL(rect
.GetRight(),rect
.GetBottom()),
1385 y2
= SELECT_FOR_VERTICAL(rect
.GetBottom(),rect
.GetRight());
1391 // left orientation looks like top but IsVertical makes x and y reversed
1393 // top is not vertical so use coordinates in written order
1394 dc
.SetPen(m_penHighlight
);
1395 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y2
),
1396 REVERSE_FOR_VERTICAL(x
, y
));
1397 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
),
1398 REVERSE_FOR_VERTICAL(x2
, y
));
1400 dc
.SetPen(m_penBlack
);
1401 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y2
),
1402 REVERSE_FOR_VERTICAL(x2
, y
));
1404 dc
.SetPen(m_penDarkGrey
);
1405 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
- 1, y2
),
1406 REVERSE_FOR_VERTICAL(x2
- 1, y
+ 1));
1408 if ( flags
& wxCONTROL_SELECTED
)
1410 dc
.SetPen(m_penLightGrey
);
1412 // overwrite the part of the border below this tab
1413 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
+ 1),
1414 REVERSE_FOR_VERTICAL(x2
- 1, y2
+ 1));
1416 // and the shadow of the tab to the left of us
1417 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
+ 2),
1418 REVERSE_FOR_VERTICAL(x
+ 1, y2
+ 1));
1423 // right orientation looks like bottom but IsVertical makes x and y reversed
1425 // bottom is not vertical so use coordinates in written order
1426 dc
.SetPen(m_penHighlight
);
1428 // we need to continue one pixel further to overwrite the corner of
1429 // the border for the selected tab
1430 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y
- (flags
& wxCONTROL_SELECTED
? 1 : 0)),
1431 REVERSE_FOR_VERTICAL(x
, y2
));
1433 // it doesn't work like this (TODO: implement it properly)
1435 // erase the corner of the tab to the right
1436 dc
.SetPen(m_penLightGrey
);
1437 dc
.DrawPoint(REVERSE_FOR_VERTICAL(x2
- 1, y
- 2));
1438 dc
.DrawPoint(REVERSE_FOR_VERTICAL(x2
- 2, y
- 2));
1439 dc
.DrawPoint(REVERSE_FOR_VERTICAL(x2
- 2, y
- 1));
1442 dc
.SetPen(m_penBlack
);
1443 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
),
1444 REVERSE_FOR_VERTICAL(x2
, y2
));
1445 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y
),
1446 REVERSE_FOR_VERTICAL(x2
, y2
));
1448 dc
.SetPen(m_penDarkGrey
);
1449 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 2, y2
- 1),
1450 REVERSE_FOR_VERTICAL(x2
- 1, y2
- 1));
1451 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
- 1, y
),
1452 REVERSE_FOR_VERTICAL(x2
- 1, y2
));
1454 if ( flags
& wxCONTROL_SELECTED
)
1456 dc
.SetPen(m_penLightGrey
);
1458 // overwrite the part of the (double!) border above this tab
1459 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
- 1),
1460 REVERSE_FOR_VERTICAL(x2
- 1, y
- 1));
1461 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
- 2),
1462 REVERSE_FOR_VERTICAL(x2
- 1, y
- 2));
1464 // and the shadow of the tab to the left of us
1465 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
- 1),
1466 REVERSE_FOR_VERTICAL(x
+ 1, y
- 1));
1472 #endif // wxUSE_NOTEBOOK
1474 // ----------------------------------------------------------------------------
1476 // ----------------------------------------------------------------------------
1480 wxSize
wxGTKRenderer::GetSliderThumbSize(const wxRect
& rect
,
1482 wxOrientation orient
) const
1484 static const wxCoord SLIDER_THUMB_LENGTH
= 30;
1488 wxRect rectShaft
= GetSliderShaftRect(rect
, lenThumb
, orient
);
1489 if ( orient
== wxHORIZONTAL
)
1491 size
.x
= wxMin(SLIDER_THUMB_LENGTH
, rectShaft
.width
);
1492 size
.y
= rectShaft
.height
;
1496 size
.y
= wxMin(SLIDER_THUMB_LENGTH
, rectShaft
.height
);
1497 size
.x
= rectShaft
.width
;
1503 wxRect
wxGTKRenderer::GetSliderShaftRect(const wxRect
& rect
,
1504 int WXUNUSED(lenThumb
),
1505 wxOrientation
WXUNUSED(orient
),
1506 long WXUNUSED(style
)) const
1508 return rect
.Deflate(2*BORDER_THICKNESS
, 2*BORDER_THICKNESS
);
1511 void wxGTKRenderer::DrawSliderShaft(wxDC
& dc
,
1512 const wxRect
& rectOrig
,
1513 int WXUNUSED(lenThumb
),
1514 wxOrientation
WXUNUSED(orient
),
1516 long WXUNUSED(style
),
1519 wxRect rect
= rectOrig
;
1521 // draw the border first
1522 if ( flags
& wxCONTROL_FOCUSED
)
1524 DrawRect(dc
, &rect
, m_penBlack
);
1526 else // not focused, normal
1528 DrawAntiShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
1531 DrawAntiShadedRect(dc
, &rect
, m_penBlack
, m_penLightGrey
);
1533 // and the background
1534 DrawSolidRect(dc
, wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
), rect
);
1540 void wxGTKRenderer::DrawSliderThumb(wxDC
& dc
,
1541 const wxRect
& rectOrig
,
1542 wxOrientation orient
,
1543 int WXUNUSED(flags
),
1544 long WXUNUSED(style
))
1546 // draw the thumb border
1547 wxRect rect
= rectOrig
;
1548 DrawAntiRaisedBorder(dc
, &rect
);
1550 // draw the handle in the middle
1551 if ( orient
== wxVERTICAL
)
1553 rect
.height
= 2*BORDER_THICKNESS
;
1554 rect
.y
= rectOrig
.y
+ (rectOrig
.height
- rect
.height
) / 2;
1558 rect
.width
= 2*BORDER_THICKNESS
;
1559 rect
.x
= rectOrig
.x
+ (rectOrig
.width
- rect
.width
) / 2;
1562 DrawShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
1565 #endif // wxUSE_SLIDER
1569 // ----------------------------------------------------------------------------
1571 // ----------------------------------------------------------------------------
1573 // wxGTKMenuGeometryInfo: the wxMenuGeometryInfo used by wxGTKRenderer
1574 class WXDLLEXPORT wxGTKMenuGeometryInfo
: public wxMenuGeometryInfo
1577 virtual wxSize
GetSize() const { return m_size
; }
1579 wxCoord
GetLabelOffset() const { return m_ofsLabel
; }
1580 wxCoord
GetAccelOffset() const { return m_ofsAccel
; }
1582 wxCoord
GetItemHeight() const { return m_heightItem
; }
1585 // the total size of the menu
1588 // the offset of the start of the menu item label
1591 // the offset of the start of the accel label
1594 // the height of a normal (not separator) item
1595 wxCoord m_heightItem
;
1597 friend wxMenuGeometryInfo
*
1598 wxGTKRenderer::GetMenuGeometry(wxWindow
*, const wxMenu
&) const;
1601 // FIXME: all constants are hardcoded but shouldn't be
1602 static const wxCoord MENU_LEFT_MARGIN
= 9;
1603 static const wxCoord MENU_RIGHT_MARGIN
= 6;
1605 static const wxCoord MENU_HORZ_MARGIN
= 6;
1606 static const wxCoord MENU_VERT_MARGIN
= 3;
1608 // the margin around bitmap/check marks (on each side)
1609 static const wxCoord MENU_BMP_MARGIN
= 2;
1611 // the margin between the labels and accel strings
1612 static const wxCoord MENU_ACCEL_MARGIN
= 8;
1614 // the separator height in pixels: in fact, strangely enough, the real height
1615 // is 2 but Windows adds one extra pixel in the bottom margin, so take it into
1617 static const wxCoord MENU_SEPARATOR_HEIGHT
= 3;
1619 // the size of the standard checkmark bitmap
1620 static const wxCoord MENU_CHECK_SIZE
= 9;
1622 void wxGTKRenderer::DrawMenuBarItem(wxDC
& dc
,
1624 const wxString
& label
,
1628 DoDrawMenuItem(dc
, rect
, label
, flags
, indexAccel
);
1631 void wxGTKRenderer::DrawMenuItem(wxDC
& dc
,
1633 const wxMenuGeometryInfo
& gi
,
1634 const wxString
& label
,
1635 const wxString
& accel
,
1636 const wxBitmap
& bitmap
,
1640 const wxGTKMenuGeometryInfo
& geomInfo
= (const wxGTKMenuGeometryInfo
&)gi
;
1645 rect
.width
= geomInfo
.GetSize().x
;
1646 rect
.height
= geomInfo
.GetItemHeight();
1648 DoDrawMenuItem(dc
, rect
, label
, flags
, indexAccel
, accel
, bitmap
, &geomInfo
);
1651 void wxGTKRenderer::DoDrawMenuItem(wxDC
& dc
,
1652 const wxRect
& rectOrig
,
1653 const wxString
& label
,
1656 const wxString
& accel
,
1657 const wxBitmap
& bitmap
,
1658 const wxGTKMenuGeometryInfo
*geometryInfo
)
1660 wxRect rect
= rectOrig
;
1662 // draw the selected item specially
1663 if ( flags
& wxCONTROL_SELECTED
)
1666 DrawBorder(dc
, wxBORDER_RAISED
, rect
, flags
, &rectIn
);
1668 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL_CURRENT
), rectIn
);
1671 rect
.Deflate(MENU_HORZ_MARGIN
, MENU_VERT_MARGIN
);
1673 // draw the bitmap: use the bitmap provided or the standard checkmark for
1674 // the checkable items
1677 wxBitmap bmp
= bitmap
;
1678 if ( !bmp
.Ok() && (flags
& wxCONTROL_CHECKABLE
) )
1680 bmp
= GetCheckBitmap(flags
);
1685 rect
.SetRight(geometryInfo
->GetLabelOffset());
1686 wxControlRenderer::DrawBitmap(dc
, bmp
, rect
);
1689 //else: menubar items don't have bitmaps
1694 rect
.x
= geometryInfo
->GetLabelOffset();
1695 rect
.SetRight(geometryInfo
->GetAccelOffset());
1698 DrawLabel(dc
, label
, rect
, flags
, wxALIGN_CENTRE_VERTICAL
, indexAccel
);
1700 // draw the accel string
1701 if ( !accel
.empty() )
1703 // menubar items shouldn't have them
1704 wxCHECK_RET( geometryInfo
, _T("accel strings only valid for menus") );
1706 rect
.x
= geometryInfo
->GetAccelOffset();
1707 rect
.SetRight(geometryInfo
->GetSize().x
);
1709 // NB: no accel index here
1710 DrawLabel(dc
, accel
, rect
, flags
, wxALIGN_CENTRE_VERTICAL
);
1713 // draw the submenu indicator
1714 if ( flags
& wxCONTROL_ISSUBMENU
)
1716 wxCHECK_RET( geometryInfo
, _T("wxCONTROL_ISSUBMENU only valid for menus") );
1718 rect
.x
= geometryInfo
->GetSize().x
- MENU_RIGHT_MARGIN
;
1719 rect
.width
= MENU_RIGHT_MARGIN
;
1721 DrawArrow(dc
, wxRIGHT
, rect
, flags
);
1725 void wxGTKRenderer::DrawMenuSeparator(wxDC
& dc
,
1727 const wxMenuGeometryInfo
& geomInfo
)
1729 DrawHorizontalLine(dc
, y
+ MENU_VERT_MARGIN
, 0, geomInfo
.GetSize().x
);
1732 wxSize
wxGTKRenderer::GetMenuBarItemSize(const wxSize
& sizeText
) const
1734 wxSize size
= sizeText
;
1736 // TODO: make this configurable
1737 size
.x
+= 2*MENU_HORZ_MARGIN
;
1738 size
.y
+= 2*MENU_VERT_MARGIN
;
1743 wxMenuGeometryInfo
*wxGTKRenderer::GetMenuGeometry(wxWindow
*win
,
1744 const wxMenu
& menu
) const
1746 // prepare the dc: for now we draw all the items with the system font
1748 dc
.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
1750 // the height of a normal item
1751 wxCoord heightText
= dc
.GetCharHeight();
1756 // the max length of label and accel strings: the menu width is the sum of
1757 // them, even if they're for different items (as the accels should be
1760 // the max length of the bitmap is never 0 as Windows always leaves enough
1761 // space for a check mark indicator
1762 wxCoord widthLabelMax
= 0,
1764 widthBmpMax
= MENU_LEFT_MARGIN
;
1766 for ( wxMenuItemList::compatibility_iterator node
= menu
.GetMenuItems().GetFirst();
1768 node
= node
->GetNext() )
1770 // height of this item
1773 wxMenuItem
*item
= node
->GetData();
1774 if ( item
->IsSeparator() )
1776 h
= MENU_SEPARATOR_HEIGHT
;
1778 else // not separator
1783 dc
.GetTextExtent(item
->GetLabel(), &widthLabel
, NULL
);
1784 if ( widthLabel
> widthLabelMax
)
1786 widthLabelMax
= widthLabel
;
1790 dc
.GetTextExtent(item
->GetAccelString(), &widthAccel
, NULL
);
1791 if ( widthAccel
> widthAccelMax
)
1793 widthAccelMax
= widthAccel
;
1796 const wxBitmap
& bmp
= item
->GetBitmap();
1799 wxCoord widthBmp
= bmp
.GetWidth();
1800 if ( widthBmp
> widthBmpMax
)
1801 widthBmpMax
= widthBmp
;
1803 //else if ( item->IsCheckable() ): no need to check for this as
1804 // MENU_LEFT_MARGIN is big enough to show the check mark
1807 h
+= 2*MENU_VERT_MARGIN
;
1809 // remember the item position and height
1810 item
->SetGeometry(height
, h
);
1815 // bundle the metrics into a struct and return it
1816 wxGTKMenuGeometryInfo
*gi
= new wxGTKMenuGeometryInfo
;
1818 gi
->m_ofsLabel
= widthBmpMax
+ 2*MENU_BMP_MARGIN
;
1819 gi
->m_ofsAccel
= gi
->m_ofsLabel
+ widthLabelMax
;
1820 if ( widthAccelMax
> 0 )
1822 // if we actually have any accesl, add a margin
1823 gi
->m_ofsAccel
+= MENU_ACCEL_MARGIN
;
1826 gi
->m_heightItem
= heightText
+ 2*MENU_VERT_MARGIN
;
1828 gi
->m_size
.x
= gi
->m_ofsAccel
+ widthAccelMax
+ MENU_RIGHT_MARGIN
;
1829 gi
->m_size
.y
= height
;
1834 #endif // wxUSE_MENUS
1836 // ----------------------------------------------------------------------------
1838 // ----------------------------------------------------------------------------
1840 void wxGTKRenderer::InitComboBitmaps()
1842 wxSize sizeArrow
= m_sizeScrollbarArrow
;
1848 for ( n
= ComboState_Normal
; n
< ComboState_Max
; n
++ )
1850 m_bitmapsCombo
[n
].Create(sizeArrow
.x
, sizeArrow
.y
);
1853 static const int comboButtonFlags
[ComboState_Max
] =
1861 wxRect
rect(sizeArrow
);
1864 for ( n
= ComboState_Normal
; n
< ComboState_Max
; n
++ )
1866 int flags
= comboButtonFlags
[n
];
1868 dc
.SelectObject(m_bitmapsCombo
[n
]);
1869 DrawSolidRect(dc
, GetBackgroundColour(flags
), rect
);
1870 DrawArrow(dc
, wxDOWN
, rect
, flags
);
1874 void wxGTKRenderer::GetComboBitmaps(wxBitmap
*bmpNormal
,
1876 wxBitmap
*bmpPressed
,
1877 wxBitmap
*bmpDisabled
)
1879 if ( !m_bitmapsCombo
[ComboState_Normal
].Ok() )
1885 *bmpNormal
= m_bitmapsCombo
[ComboState_Normal
];
1887 *bmpFocus
= m_bitmapsCombo
[ComboState_Focus
];
1889 *bmpPressed
= m_bitmapsCombo
[ComboState_Pressed
];
1891 *bmpDisabled
= m_bitmapsCombo
[ComboState_Disabled
];
1894 // ----------------------------------------------------------------------------
1896 // ----------------------------------------------------------------------------
1898 void wxGTKRenderer::DrawArrowBorder(wxDC
& dc
,
1902 static const wxDirection sides
[] =
1904 wxUP
, wxLEFT
, wxRIGHT
, wxDOWN
1907 wxRect rect1
, rect2
, rectInner
;
1913 rectInner
.Inflate(-2);
1915 DrawSolidRect(dc
, wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
), *rect
);
1917 // find the side not to draw and also adjust the rectangles to compensate
1919 wxDirection sideToOmit
;
1923 sideToOmit
= wxDOWN
;
1925 rectInner
.height
+= 1;
1933 rectInner
.height
+= 1;
1937 sideToOmit
= wxRIGHT
;
1939 rectInner
.width
+= 1;
1943 sideToOmit
= wxLEFT
;
1947 rectInner
.width
+= 1;
1951 wxFAIL_MSG(_T("unknown arrow direction"));
1955 // the outer rect first
1957 for ( n
= 0; n
< WXSIZEOF(sides
); n
++ )
1959 wxDirection side
= sides
[n
];
1960 if ( side
== sideToOmit
)
1963 DrawAntiShadedRectSide(dc
, rect1
, m_penDarkGrey
, m_penHighlight
, side
);
1966 // and then the inner one
1967 for ( n
= 0; n
< WXSIZEOF(sides
); n
++ )
1969 wxDirection side
= sides
[n
];
1970 if ( side
== sideToOmit
)
1973 DrawAntiShadedRectSide(dc
, rect2
, m_penBlack
, m_penGrey
, side
);
1979 void wxGTKRenderer::DrawScrollbarArrow(wxDC
& dc
,
1981 const wxRect
& rectArrow
,
1984 // first of all, draw the border around it - but we don't want the border
1985 // on the side opposite to the arrow point
1986 wxRect rect
= rectArrow
;
1987 DrawArrowBorder(dc
, &rect
, dir
);
1989 // then the arrow itself
1990 DrawArrow(dc
, dir
, rect
, flags
);
1993 // gtk_default_draw_arrow() takes ~350 lines and we can't do much better here
1994 // these people are just crazy :-(
1995 void wxGTKRenderer::DrawArrow(wxDC
& dc
,
2008 wxPoint ptArrow
[Point_Max
];
2010 wxColour colInside
= GetBackgroundColour(flags
);
2012 if ( flags
& wxCONTROL_DISABLED
)
2014 penShadow
[0] = m_penDarkGrey
;
2015 penShadow
[1] = m_penDarkGrey
;
2016 penShadow
[2] = wxNullPen
;
2017 penShadow
[3] = wxNullPen
;
2019 else if ( flags
& wxCONTROL_PRESSED
)
2021 penShadow
[0] = m_penDarkGrey
;
2022 penShadow
[1] = m_penHighlight
;
2023 penShadow
[2] = wxNullPen
;
2024 penShadow
[3] = m_penBlack
;
2026 else // normal arrow
2028 penShadow
[0] = m_penHighlight
;
2029 penShadow
[1] = m_penBlack
;
2030 penShadow
[2] = m_penDarkGrey
;
2031 penShadow
[3] = wxNullPen
;
2035 if ( dir
== wxUP
|| dir
== wxDOWN
)
2038 middle
= (rect
.GetRight() + rect
.GetLeft() + 1) / 2;
2042 middle
= (rect
.GetTop() + rect
.GetBottom() + 1) / 2;
2045 // draw the arrow interior
2046 dc
.SetPen(*wxTRANSPARENT_PEN
);
2047 dc
.SetBrush(colInside
);
2052 ptArrow
[Point_First
].x
= rect
.GetLeft();
2053 ptArrow
[Point_First
].y
= rect
.GetBottom();
2054 ptArrow
[Point_Second
].x
= middle
;
2055 ptArrow
[Point_Second
].y
= rect
.GetTop();
2056 ptArrow
[Point_Third
].x
= rect
.GetRight();
2057 ptArrow
[Point_Third
].y
= rect
.GetBottom();
2061 ptArrow
[Point_First
] = rect
.GetPosition();
2062 ptArrow
[Point_Second
].x
= middle
;
2063 ptArrow
[Point_Second
].y
= rect
.GetBottom();
2064 ptArrow
[Point_Third
].x
= rect
.GetRight();
2065 ptArrow
[Point_Third
].y
= rect
.GetTop();
2069 ptArrow
[Point_First
].x
= rect
.GetRight();
2070 ptArrow
[Point_First
].y
= rect
.GetTop();
2071 ptArrow
[Point_Second
].x
= rect
.GetLeft();
2072 ptArrow
[Point_Second
].y
= middle
;
2073 ptArrow
[Point_Third
].x
= rect
.GetRight();
2074 ptArrow
[Point_Third
].y
= rect
.GetBottom();
2078 ptArrow
[Point_First
] = rect
.GetPosition();
2079 ptArrow
[Point_Second
].x
= rect
.GetRight();
2080 ptArrow
[Point_Second
].y
= middle
;
2081 ptArrow
[Point_Third
].x
= rect
.GetLeft();
2082 ptArrow
[Point_Third
].y
= rect
.GetBottom();
2086 wxFAIL_MSG(_T("unknown arrow direction"));
2089 dc
.DrawPolygon(WXSIZEOF(ptArrow
), ptArrow
);
2091 // draw the arrow border
2092 dc
.SetPen(penShadow
[0]);
2096 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_First
]);
2097 dc
.DrawPoint(ptArrow
[Point_First
]);
2098 if ( penShadow
[3].Ok() )
2100 dc
.SetPen(penShadow
[3]);
2101 dc
.DrawLine(ptArrow
[Point_First
].x
+ 1, ptArrow
[Point_First
].y
,
2102 ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
);
2104 dc
.SetPen(penShadow
[1]);
2105 dc
.DrawLine(ptArrow
[Point_Second
].x
+ 1, ptArrow
[Point_Second
].y
+ 1,
2106 ptArrow
[Point_Third
].x
, ptArrow
[Point_Third
].y
);
2107 dc
.DrawPoint(ptArrow
[Point_Third
]);
2108 dc
.DrawLine(ptArrow
[Point_Third
].x
- 2, ptArrow
[Point_Third
].y
,
2109 ptArrow
[Point_First
].x
+ 1, ptArrow
[Point_First
].y
);
2110 if ( penShadow
[2].Ok() )
2112 dc
.SetPen(penShadow
[2]);
2113 dc
.DrawLine(ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
,
2114 ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
+ 1);
2115 dc
.DrawLine(ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
- 1,
2116 ptArrow
[Point_First
].x
+ 2, ptArrow
[Point_First
].y
- 1);
2121 dc
.DrawLine(ptArrow
[Point_First
], ptArrow
[Point_Second
]);
2122 dc
.DrawLine(ptArrow
[Point_First
].x
+ 2, ptArrow
[Point_First
].y
,
2123 ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
);
2124 if ( penShadow
[2].Ok() )
2126 dc
.SetPen(penShadow
[2]);
2127 dc
.DrawLine(ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
- 1,
2128 ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
- 1);
2130 dc
.SetPen(penShadow
[1]);
2131 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_Third
]);
2132 dc
.DrawPoint(ptArrow
[Point_Third
]);
2136 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_First
]);
2137 dc
.DrawPoint(ptArrow
[Point_First
]);
2138 if ( penShadow
[2].Ok() )
2140 dc
.SetPen(penShadow
[2]);
2141 dc
.DrawLine(ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
,
2142 ptArrow
[Point_First
].x
- 1, ptArrow
[Point_First
].y
+ 2);
2143 dc
.DrawLine(ptArrow
[Point_Third
].x
, ptArrow
[Point_Third
].y
,
2144 ptArrow
[Point_Second
].x
+ 2, ptArrow
[Point_Second
].y
+ 1);
2146 dc
.SetPen(penShadow
[1]);
2147 dc
.DrawLine(ptArrow
[Point_Third
].x
, ptArrow
[Point_Third
].y
,
2148 ptArrow
[Point_First
].x
, ptArrow
[Point_First
].y
+ 1);
2149 dc
.DrawLine(ptArrow
[Point_Second
].x
+ 1, ptArrow
[Point_Second
].y
+ 1,
2150 ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
);
2154 dc
.DrawLine(ptArrow
[Point_First
], ptArrow
[Point_Third
]);
2155 dc
.DrawLine(ptArrow
[Point_First
].x
+ 2, ptArrow
[Point_First
].y
+ 1,
2156 ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
);
2157 dc
.SetPen(penShadow
[1]);
2158 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_Third
]);
2159 dc
.DrawPoint(ptArrow
[Point_Third
]);
2163 wxFAIL_MSG(_T("unknown arrow direction"));
2168 void wxGTKRenderer::DrawThumbBorder(wxDC
& dc
,
2170 wxOrientation orient
)
2172 if ( orient
== wxVERTICAL
)
2174 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2176 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2178 rect
->Inflate(-1, 0);
2180 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2182 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2184 rect
->Inflate(-1, 0);
2188 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2190 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2192 rect
->Inflate(0, -1);
2194 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2196 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2198 rect
->Inflate(0, -1);
2202 void wxGTKRenderer::DrawScrollbarThumb(wxDC
& dc
,
2203 wxOrientation orient
,
2207 // the thumb is never pressed never has focus border under GTK and the
2208 // scrollbar background never changes at all
2209 int flagsThumb
= flags
& ~(wxCONTROL_PRESSED
| wxCONTROL_FOCUSED
);
2211 // we don't want the border in the direction of the scrollbar movement
2212 wxRect rectThumb
= rect
;
2213 DrawThumbBorder(dc
, &rectThumb
, orient
);
2215 DrawButtonBorder(dc
, rectThumb
, flagsThumb
, &rectThumb
);
2216 DrawBackground(dc
, wxNullColour
, rectThumb
, flagsThumb
);
2219 void wxGTKRenderer::DrawScrollbarShaft(wxDC
& dc
,
2220 wxOrientation orient
,
2222 int WXUNUSED(flags
))
2224 wxRect rectBar
= rect
;
2225 DrawThumbBorder(dc
, &rectBar
, orient
);
2226 DrawSolidRect(dc
, wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
), rectBar
);
2229 // ----------------------------------------------------------------------------
2231 // ----------------------------------------------------------------------------
2233 void wxGTKRenderer::AdjustSize(wxSize
*size
, const wxWindow
*window
)
2236 if ( wxDynamicCast(window
, wxBitmapButton
) )
2241 #endif // wxUSE_BMPBUTTON
2242 #if wxUSE_BUTTON || wxUSE_TOGGLEBTN
2245 || wxDynamicCast(window
, wxButton
)
2246 # endif // wxUSE_BUTTON
2247 # if wxUSE_TOGGLEBTN
2248 || wxDynamicCast(window
, wxToggleButton
)
2249 # endif // wxUSE_TOGGLEBTN
2252 if ( !(window
->GetWindowStyle() & wxBU_EXACTFIT
) )
2254 // TODO: this is ad hoc...
2255 size
->x
+= 3*window
->GetCharWidth();
2256 wxCoord minBtnHeight
= 18;
2257 if ( size
->y
< minBtnHeight
)
2258 size
->y
= minBtnHeight
;
2260 // button border width
2264 #endif // wxUSE_BUTTON || wxUSE_TOGGLEBTN
2266 if ( wxDynamicCast(window
, wxScrollBar
) )
2268 // we only set the width of vert scrollbars and height of the
2270 if ( window
->GetWindowStyle() & wxSB_HORIZONTAL
)
2271 size
->y
= m_sizeScrollbarArrow
.x
;
2273 size
->x
= m_sizeScrollbarArrow
.x
;
2276 #endif // wxUSE_SCROLLBAR
2278 // take into account the border width
2279 wxStdRenderer::AdjustSize(size
, window
);
2283 // ----------------------------------------------------------------------------
2285 // ----------------------------------------------------------------------------
2287 /* Copyright (c) Julian Smart */
2288 static const char *error_xpm
[] = {
2289 /* columns rows colors chars-per-pixel */
2303 " ................. ",
2304 " ................... ",
2305 " ....................... ",
2306 " ......................... ",
2307 " ........................... ",
2308 " ...........................X ",
2309 " .............................X ",
2310 " ............................... ",
2311 " ...............................X ",
2312 " .................................X ",
2313 " .................................X ",
2314 " .................................XX ",
2315 " ...ooooooooooooooooooooooooooo...XX ",
2316 " ....ooooooooooooooooooooooooooo....X ",
2317 " ....ooooooooooooooooooooooooooo....X ",
2318 " ....ooooooooooooooooooooooooooo....XX ",
2319 " ....ooooooooooooooooooooooooooo....XX ",
2320 " ....ooooooooooooooooooooooooooo....XX ",
2321 " ...ooooooooooooooooooooooooooo...XXX ",
2322 " ...ooooooooooooooooooooooooooo...XXX ",
2323 " .................................XX ",
2324 " .................................XX ",
2325 " ...............................XXX ",
2326 " ...............................XXX ",
2327 " .............................XXX ",
2328 " ...........................XXXX ",
2329 " ...........................XXX ",
2330 " .........................XXX ",
2331 " .......................XXXX ",
2332 " X...................XXXXX ",
2333 " X.................XXXXX ",
2334 " X.............XXXXX ",
2335 " XXXX.....XXXXXXXX ",
2346 /* Copyright (c) Julian Smart */
2347 static const char *info_xpm
[] = {
2348 /* columns rows colors chars-per-pixel */
2372 " .XXXOXXXXXXXoo. ",
2373 " .XOOXXX+XXXXXo. ",
2374 " .XOOOXX+++XXXXoo. ",
2375 " .XOOXXX+++XXXXXo. ",
2376 " .XOOOXXX+++XXXXXXo. ",
2377 " .XOOXXXX+++XXXXXXo. ",
2378 " .XXXXXXX+++XXXXXXX. ",
2379 " .XXXXXXX+++XXXXXXo. ",
2380 " .XXXXXXX+++XXXXXoo. ",
2381 " .XXXXXX+++XXXXXo. ",
2382 " .XXXXXXX+XXXXXXo. ",
2383 " .XXXXXXXXXXXXo. ",
2384 " .XXXXX+++XXXoo. ",
2410 /* Copyright (c) Julian Smart */
2411 static const char *warning_xpm
[] = {
2412 /* columns rows colors chars-per-pixel */
2442 " ..XXXXO@#XXX... ",
2443 " ...XXXXO@#XXXX.. ",
2444 " ..XXXXXO@#XXXX... ",
2445 " ...XXXXXo@OXXXXX.. ",
2446 " ...XXXXXXo@OXXXXXX.. ",
2447 " ..XXXXXXX$@OXXXXXX... ",
2448 " ...XXXXXXXX@XXXXXXXX.. ",
2449 " ...XXXXXXXXXXXXXXXXXX... ",
2450 " ..XXXXXXXXXXOXXXXXXXXX.. ",
2451 " ...XXXXXXXXXO@#XXXXXXXXX.. ",
2452 " ..XXXXXXXXXXX#XXXXXXXXXX... ",
2453 " ...XXXXXXXXXXXXXXXXXXXXXXX.. ",
2454 " ...XXXXXXXXXXXXXXXXXXXXXXXX... ",
2455 " .............................. ",
2456 " .............................. ",
2474 /* Copyright (c) Julian Smart */
2475 static const char *question_xpm
[] = {
2476 /* columns rows colors chars-per-pixel */
2506 " ..XXXXoooooXXXO+ ",
2507 " ..XXooooooooooooX@.. ",
2508 " ..XoooooooooooooooXX#. ",
2509 " $%XoooooooooooooooooXX#. ",
2510 " &.XoooooooXXXXXXooooooXX.. ",
2511 " .XooooooXX.$...$XXoooooX*. ",
2512 " $.XoooooX%.$ .*oooooo=.. ",
2513 " .XooooooX.. -.XoooooX.. ",
2514 " .XoooooX..+ .XoooooX;. ",
2515 " ...XXXX..: .XoooooX;. ",
2516 " ........ >.XoooooX;. ",
2550 wxBitmap
wxGTKArtProvider::CreateBitmap(const wxArtID
& id
,
2551 const wxArtClient
& WXUNUSED(client
),
2552 const wxSize
& WXUNUSED(size
))
2554 if ( id
== wxART_INFORMATION
)
2555 return wxBitmap(info_xpm
);
2556 if ( id
== wxART_ERROR
)
2557 return wxBitmap(error_xpm
);
2558 if ( id
== wxART_WARNING
)
2559 return wxBitmap(warning_xpm
);
2560 if ( id
== wxART_QUESTION
)
2561 return wxBitmap(question_xpm
);
2562 return wxNullBitmap
;
2566 // ============================================================================
2568 // ============================================================================
2570 // ----------------------------------------------------------------------------
2571 // wxGTKInputHandler
2572 // ----------------------------------------------------------------------------
2574 bool wxGTKInputHandler::HandleKey(wxInputConsumer
* WXUNUSED(control
),
2575 const wxKeyEvent
& WXUNUSED(event
),
2576 bool WXUNUSED(pressed
))
2581 bool wxGTKInputHandler::HandleMouse(wxInputConsumer
*control
,
2582 const wxMouseEvent
& event
)
2584 // clicking on the control gives it focus
2585 if ( event
.ButtonDown() && wxWindow::FindFocus() != control
->GetInputWindow() )
2587 control
->GetInputWindow()->SetFocus();
2595 bool wxGTKInputHandler::HandleMouseMove(wxInputConsumer
*control
,
2596 const wxMouseEvent
& event
)
2598 if ( event
.Entering() )
2600 control
->GetInputWindow()->SetCurrent(true);
2602 else if ( event
.Leaving() )
2604 control
->GetInputWindow()->SetCurrent(false);
2616 // ----------------------------------------------------------------------------
2617 // wxGTKCheckboxInputHandler
2618 // ----------------------------------------------------------------------------
2620 bool wxGTKCheckboxInputHandler::HandleKey(wxInputConsumer
*control
,
2621 const wxKeyEvent
& event
,
2626 int keycode
= event
.GetKeyCode();
2627 if ( keycode
== WXK_SPACE
|| keycode
== WXK_RETURN
)
2629 control
->PerformAction(wxACTION_CHECKBOX_TOGGLE
);
2638 #endif // wxUSE_CHECKBOX
2642 // ----------------------------------------------------------------------------
2643 // wxGTKTextCtrlInputHandler
2644 // ----------------------------------------------------------------------------
2646 bool wxGTKTextCtrlInputHandler::HandleKey(wxInputConsumer
*control
,
2647 const wxKeyEvent
& event
,
2650 // handle only GTK-specific text bindings here, the others are handled in
2654 wxControlAction action
;
2655 int keycode
= event
.GetKeyCode();
2656 if ( event
.ControlDown() )
2661 action
= wxACTION_TEXT_HOME
;
2665 action
= wxACTION_TEXT_LEFT
;
2669 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_RIGHT
;
2673 action
= wxACTION_TEXT_END
;
2677 action
= wxACTION_TEXT_RIGHT
;
2681 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_LEFT
;
2685 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_END
;
2689 action
= wxACTION_TEXT_DOWN
;
2693 action
= wxACTION_TEXT_UP
;
2697 //delete the entire line
2698 control
->PerformAction(wxACTION_TEXT_HOME
);
2699 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_END
;
2703 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_WORD_LEFT
;
2707 else if ( event
.AltDown() )
2712 action
= wxACTION_TEXT_WORD_LEFT
;
2716 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_WORD_RIGHT
;
2720 action
= wxACTION_TEXT_WORD_RIGHT
;
2725 if ( action
!= wxACTION_NONE
)
2727 control
->PerformAction(action
);
2733 return wxStdInputHandler::HandleKey(control
, event
, pressed
);
2736 #endif // wxUSE_TEXTCTRL
2738 #endif // wxUSE_THEME_GTK