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/dcclient.h"
36 #include "wx/window.h"
40 #include "wx/bmpbuttn.h"
41 #include "wx/button.h"
42 #include "wx/checkbox.h"
43 #include "wx/listbox.h"
44 #include "wx/checklst.h"
45 #include "wx/combobox.h"
46 #include "wx/scrolbar.h"
47 #include "wx/slider.h"
48 #include "wx/textctrl.h"
49 #include "wx/toolbar.h"
50 #include "wx/statusbr.h"
52 #include "wx/settings.h"
53 #include "wx/toplevel.h"
57 #include "wx/notebook.h"
58 #include "wx/spinbutt.h"
59 #include "wx/artprov.h"
60 #include "wx/tglbtn.h"
62 #include "wx/univ/stdrend.h"
63 #include "wx/univ/inpcons.h"
64 #include "wx/univ/inphand.h"
65 #include "wx/univ/colschem.h"
67 class wxGTKMenuGeometryInfo
;
69 // ----------------------------------------------------------------------------
71 // ----------------------------------------------------------------------------
73 // standard border size
74 static const int BORDER_THICKNESS
= 2;
76 // ----------------------------------------------------------------------------
77 // wxGTKRenderer: draw the GUI elements in GTK style
78 // ----------------------------------------------------------------------------
80 class wxGTKRenderer
: public wxStdRenderer
83 wxGTKRenderer(const wxColourScheme
*scheme
);
86 virtual void DrawFocusRect(wxWindow
* win
, wxDC
& dc
, const wxRect
& rect
, int flags
= 0);
87 virtual void DrawTextBorder(wxDC
& dc
,
91 wxRect
*rectIn
= NULL
);
92 virtual void DrawButtonLabel(wxDC
& dc
,
93 const wxString
& label
,
94 const wxBitmap
& image
,
100 virtual void DrawButtonBorder(wxDC
& dc
,
103 wxRect
*rectIn
= NULL
);
104 virtual void DrawArrow(wxDC
& dc
,
108 virtual void DrawScrollbarArrow(wxDC
& dc
,
112 virtual void DrawScrollbarThumb(wxDC
& dc
,
113 wxOrientation orient
,
116 virtual void DrawScrollbarShaft(wxDC
& dc
,
117 wxOrientation orient
,
122 virtual void DrawToolBarButton(wxDC
& dc
,
123 const wxString
& label
,
124 const wxBitmap
& bitmap
,
129 #endif // wxUSE_TOOLBAR
132 virtual void DrawLineWrapMark(wxDC
& dc
, const wxRect
& rect
);
133 #endif // wxUSE_TEXTCTRL
136 virtual void DrawTab(wxDC
& dc
,
139 const wxString
& label
,
140 const wxBitmap
& bitmap
= wxNullBitmap
,
142 int indexAccel
= -1);
143 #endif // wxUSE_NOTEBOOK
146 virtual void DrawSliderShaft(wxDC
& dc
,
149 wxOrientation orient
,
152 wxRect
*rectShaft
= NULL
);
153 virtual void DrawSliderThumb(wxDC
& dc
,
155 wxOrientation orient
,
158 virtual void DrawSliderTicks(wxDC
& WXUNUSED(dc
),
159 const wxRect
& WXUNUSED(rect
),
160 int WXUNUSED(lenThumb
),
161 wxOrientation
WXUNUSED(orient
),
164 int WXUNUSED(step
) = 1,
165 int WXUNUSED(flags
) = 0,
166 long WXUNUSED(style
) = 0)
168 // we don't have the ticks in GTK version
170 #endif // wxUSE_SLIDER
173 virtual void DrawMenuBarItem(wxDC
& dc
,
175 const wxString
& label
,
177 int indexAccel
= -1);
178 virtual void DrawMenuItem(wxDC
& dc
,
180 const wxMenuGeometryInfo
& geometryInfo
,
181 const wxString
& label
,
182 const wxString
& accel
,
183 const wxBitmap
& bitmap
= wxNullBitmap
,
185 int indexAccel
= -1);
186 virtual void DrawMenuSeparator(wxDC
& dc
,
188 const wxMenuGeometryInfo
& geomInfo
);
189 #endif // wxUSE_MENUS
191 virtual void GetComboBitmaps(wxBitmap
*bmpNormal
,
193 wxBitmap
*bmpPressed
,
194 wxBitmap
*bmpDisabled
);
196 virtual void AdjustSize(wxSize
*size
, const wxWindow
*window
);
198 // geometry and hit testing
200 virtual wxSize
GetScrollbarArrowSize() const
201 { return m_sizeScrollbarArrow
; }
202 #endif // wxUSE_SCROLLBAR
204 virtual wxSize
GetCheckBitmapSize() const
205 { return wxSize(10, 10); }
206 virtual wxSize
GetRadioBitmapSize() const
207 { return wxSize(11, 11); }
208 virtual wxCoord
GetCheckItemMargin() const
212 virtual wxSize
GetToolBarButtonSize(wxCoord
*separator
) const
213 { if ( separator
) *separator
= 5; return wxSize(16, 15); }
214 virtual wxSize
GetToolBarMargin() const
215 { return wxSize(6, 6); }
216 #endif // wxUSE_TOOLBAR
219 virtual wxRect
GetTextClientArea(const wxTextCtrl
*text
,
221 wxCoord
*extraSpaceBeyond
) const;
222 #endif // wxUSE_TEXTCTRL
225 virtual wxSize
GetTabIndent() const { return wxSize(2, 2); }
226 virtual wxSize
GetTabPadding() const { return wxSize(6, 6); }
227 #endif // wxUSE_NOTEBOOK
230 virtual wxCoord
GetSliderDim() const { return 15; }
231 virtual wxCoord
GetSliderTickLen() const { return 0; }
232 virtual wxRect
GetSliderShaftRect(const wxRect
& rect
,
234 wxOrientation orient
,
235 long style
= 0) const;
236 virtual wxSize
GetSliderThumbSize(const wxRect
& rect
,
238 wxOrientation orient
) const;
239 #endif // wxUSE_SLIDER
241 virtual wxSize
GetProgressBarStep() const { return wxSize(16, 32); }
244 virtual wxSize
GetMenuBarItemSize(const wxSize
& sizeText
) const;
245 virtual wxMenuGeometryInfo
*GetMenuGeometry(wxWindow
*win
,
246 const wxMenu
& menu
) const;
247 #endif // wxUSE_MENUS
249 // helpers for "wxBitmap wxColourScheme::Get()"
250 void DrawCheckBitmap(wxDC
& dc
, const wxRect
& rect
);
251 void DrawUncheckBitmap(wxDC
& dc
, const wxRect
& rect
, bool isPressed
);
252 void DrawUndeterminedBitmap(wxDC
& dc
, const wxRect
& rect
, bool isPressed
);
255 // overridden wxStdRenderer methods
256 virtual void DrawSunkenBorder(wxDC
& dc
, wxRect
*rect
);
258 virtual void DrawFrameWithLabel(wxDC
& dc
,
259 const wxString
& label
,
260 const wxRect
& rectFrame
,
261 const wxRect
& rectText
,
266 virtual void DrawCheckItemBitmap(wxDC
& dc
,
267 const wxBitmap
& bitmap
,
271 // get the colour to use for background
272 wxColour
GetBackgroundColour(int flags
) const
274 if ( flags
& wxCONTROL_PRESSED
)
275 return wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
);
276 else if ( flags
& wxCONTROL_CURRENT
)
277 return wxSCHEME_COLOUR(m_scheme
, CONTROL_CURRENT
);
279 return wxSCHEME_COLOUR(m_scheme
, CONTROL
);
282 // as DrawShadedRect() but the pixels in the bottom left and upper right
283 // border are drawn with the pen1, not pen2
284 void DrawAntiShadedRect(wxDC
& dc
, wxRect
*rect
,
285 const wxPen
& pen1
, const wxPen
& pen2
);
287 // used for drawing opened rectangles - draws only one side of it at once
288 // (and doesn't adjust the rect)
289 void DrawAntiShadedRectSide(wxDC
& dc
,
295 // draw an opened rect for the arrow in given direction
296 void DrawArrowBorder(wxDC
& dc
,
300 // draw two sides of the rectangle
301 void DrawThumbBorder(wxDC
& dc
,
303 wxOrientation orient
);
305 // just as DrawRaisedBorder() except that the bottom left and up right
306 // pixels of the interior rect are drawn in another colour (i.e. the inner
307 // rect is drawn with DrawAntiShadedRect() and not DrawShadedRect())
308 void DrawAntiRaisedBorder(wxDC
& dc
, wxRect
*rect
);
310 // draw inner GTK shadow
311 void DrawInnerShadedRect(wxDC
& dc
, wxRect
*rect
);
313 // get the line wrap indicator bitmap
314 wxBitmap
GetLineWrapBitmap() const;
316 virtual wxBitmap
GetCheckBitmap(int flags
);
317 virtual wxBitmap
GetRadioBitmap(int flags
);
319 // draw a /\ or \/ line from (x1, y1) to (x2, y1) passing by the point
321 void DrawUpZag(wxDC
& dc
,
322 wxCoord x1
, wxCoord x2
,
323 wxCoord y1
, wxCoord y2
);
324 void DrawDownZag(wxDC
& dc
,
325 wxCoord x1
, wxCoord x2
,
326 wxCoord y1
, wxCoord y2
);
328 // draw the radio button bitmap for the given state
329 void DrawRadioButtonBitmap(wxDC
& dc
, const wxRect
& rect
, int flags
);
331 // common part of DrawMenuItem() and DrawMenuBarItem()
332 void DoDrawMenuItem(wxDC
& dc
,
334 const wxString
& label
,
337 const wxString
& accel
= wxEmptyString
,
338 const wxBitmap
& bitmap
= wxNullBitmap
,
339 const wxGTKMenuGeometryInfo
*geometryInfo
= NULL
);
341 // initialize the combo bitmaps
342 void InitComboBitmaps();
344 virtual wxBitmap
GetFrameButtonBitmap(FrameButtonType
WXUNUSED(type
))
351 wxSize m_sizeScrollbarArrow
;
356 // the checkbox and radio button bitmaps: first row is for the normal,
357 // second for the pressed state and the columns are for checked, unchecked
358 // and undeterminated respectively
359 wxBitmap m_bitmapsCheckbox
[IndicatorState_MaxCtrl
][IndicatorStatus_Max
],
360 m_bitmapsRadiobtn
[IndicatorState_MaxCtrl
][IndicatorStatus_Max
];
362 // the line wrap bitmap (drawn at the end of wrapped lines)
363 wxBitmap m_bmpLineWrap
;
365 // the combobox bitmaps
375 wxBitmap m_bitmapsCombo
[ComboState_Max
];
378 // ----------------------------------------------------------------------------
379 // wxGTKInputHandler and derived classes: process the keyboard and mouse
380 // messages according to GTK standards
381 // ----------------------------------------------------------------------------
383 class wxGTKInputHandler
: public wxInputHandler
386 wxGTKInputHandler() { }
388 virtual bool HandleKey(wxInputConsumer
*control
,
389 const wxKeyEvent
& event
,
391 virtual bool HandleMouse(wxInputConsumer
*control
,
392 const wxMouseEvent
& event
);
393 virtual bool HandleMouseMove(wxInputConsumer
*control
,
394 const wxMouseEvent
& event
);
399 class wxGTKScrollBarInputHandler
: public wxStdScrollBarInputHandler
402 wxGTKScrollBarInputHandler(wxRenderer
*renderer
, wxInputHandler
*handler
)
403 : wxStdScrollBarInputHandler(renderer
, handler
) { }
406 virtual void Highlight(wxScrollBar
*scrollbar
, bool doIt
)
408 // only arrows and the thumb can be highlighted
409 if ( !IsArrow() && m_htLast
!= wxHT_SCROLLBAR_THUMB
)
412 wxStdScrollBarInputHandler::Highlight(scrollbar
, doIt
);
415 virtual void Press(wxScrollBar
*scrollbar
, bool doIt
)
417 // only arrows can be pressed
421 wxStdScrollBarInputHandler::Press(scrollbar
, doIt
);
424 // any button can be used to drag the scrollbar under GTK+
425 virtual bool IsAllowedButton(int WXUNUSED(button
)) const { return true; }
429 return m_htLast
== wxHT_SCROLLBAR_ARROW_LINE_1
||
430 m_htLast
== wxHT_SCROLLBAR_ARROW_LINE_2
;
434 #endif // wxUSE_SCROLLBAR
438 class wxGTKCheckboxInputHandler
: public wxStdInputHandler
441 wxGTKCheckboxInputHandler(wxInputHandler
*handler
)
442 : wxStdInputHandler(handler
) { }
444 virtual bool HandleKey(wxInputConsumer
*control
,
445 const wxKeyEvent
& event
,
449 #endif // wxUSE_CHECKBOX
453 class wxGTKTextCtrlInputHandler
: public wxStdInputHandler
456 wxGTKTextCtrlInputHandler(wxInputHandler
*handler
)
457 : wxStdInputHandler(handler
) { }
459 virtual bool HandleKey(wxInputConsumer
*control
,
460 const wxKeyEvent
& event
,
464 #endif // wxUSE_TEXTCTRL
466 // ----------------------------------------------------------------------------
467 // wxGTKColourScheme: uses the standard GTK colours
468 // ----------------------------------------------------------------------------
470 class wxGTKColourScheme
: public wxColourScheme
473 virtual wxColour
Get(StdColour col
) const;
474 virtual wxColour
GetBackground(wxWindow
*win
) const;
477 // ----------------------------------------------------------------------------
479 // ----------------------------------------------------------------------------
481 class wxGTKArtProvider
: public wxArtProvider
484 virtual wxBitmap
CreateBitmap(const wxArtID
& id
,
485 const wxArtClient
& client
,
489 // ----------------------------------------------------------------------------
491 // ----------------------------------------------------------------------------
493 WX_DEFINE_ARRAY_PTR(wxInputHandler
*, wxArrayHandlers
);
495 class wxGTKTheme
: public wxTheme
499 virtual ~wxGTKTheme();
501 virtual wxRenderer
*GetRenderer();
502 virtual wxArtProvider
*GetArtProvider();
503 virtual wxInputHandler
*GetInputHandler(const wxString
& control
,
504 wxInputConsumer
*consumer
);
505 virtual wxColourScheme
*GetColourScheme();
508 wxGTKRenderer
*m_renderer
;
510 wxGTKArtProvider
*m_artProvider
;
512 // the names of the already created handlers and the handlers themselves
513 // (these arrays are synchronized)
514 wxSortedArrayString m_handlerNames
;
515 wxArrayHandlers m_handlers
;
517 wxGTKColourScheme
*m_scheme
;
519 WX_DECLARE_THEME(gtk
)
522 // ============================================================================
524 // ============================================================================
526 WX_IMPLEMENT_THEME(wxGTKTheme
, gtk
, wxTRANSLATE("GTK+ theme"));
528 // ----------------------------------------------------------------------------
530 // ----------------------------------------------------------------------------
532 wxGTKTheme::wxGTKTheme()
536 m_artProvider
= NULL
;
539 wxGTKTheme::~wxGTKTheme()
543 delete m_artProvider
;
546 wxRenderer
*wxGTKTheme::GetRenderer()
550 m_renderer
= new wxGTKRenderer(GetColourScheme());
556 wxArtProvider
*wxGTKTheme::GetArtProvider()
558 if ( !m_artProvider
)
560 m_artProvider
= new wxGTKArtProvider
;
563 return m_artProvider
;
566 wxColourScheme
*wxGTKTheme::GetColourScheme()
570 m_scheme
= new wxGTKColourScheme
;
575 wxInputHandler
*wxGTKTheme::GetInputHandler(const wxString
& control
,
576 wxInputConsumer
*consumer
)
578 wxInputHandler
*handler
= NULL
;
579 int n
= m_handlerNames
.Index(control
);
580 if ( n
== wxNOT_FOUND
)
582 static wxGTKInputHandler s_handlerDef
;
584 wxInputHandler
* const
585 handlerStd
= consumer
->DoGetStdInputHandler(&s_handlerDef
);
587 // create a new handler
589 if ( control
== wxINP_HANDLER_CHECKBOX
)
591 static wxGTKCheckboxInputHandler
s_handler(handlerStd
);
593 handler
= &s_handler
;
596 #endif // wxUSE_CHECKBOX
598 if ( control
== wxINP_HANDLER_SCROLLBAR
)
600 static wxGTKScrollBarInputHandler
s_handler(m_renderer
, handlerStd
);
602 handler
= &s_handler
;
605 #endif // wxUSE_SCROLLBAR
607 if ( control
== wxINP_HANDLER_TEXTCTRL
)
609 static wxGTKTextCtrlInputHandler
s_handler(handlerStd
);
611 handler
= &s_handler
;
614 #endif // wxUSE_TEXTCTRL
616 // no special handler for this control
617 handler
= handlerStd
;
620 n
= m_handlerNames
.Add(control
);
621 m_handlers
.Insert(handler
, n
);
623 else // we already have it
625 handler
= m_handlers
[n
];
631 // ============================================================================
633 // ============================================================================
635 wxColour
wxGTKColourScheme::GetBackground(wxWindow
*win
) const
638 if ( win
->UseBgCol() )
640 // use the user specified colour
641 col
= win
->GetBackgroundColour();
644 if ( !win
->ShouldInheritColours() )
646 // doesn't depend on the state
654 int flags
= win
->GetStateFlags();
656 // the colour set by the user should be used for the normal state
657 // and for the states for which we don't have any specific colours
658 if ( !col
.IsOk() || (flags
!= 0) )
661 if ( wxDynamicCast(win
, wxScrollBar
) )
662 col
= Get(SCROLLBAR
);
664 #endif //wxUSE_SCROLLBAR
665 if ( (flags
& wxCONTROL_CURRENT
) && win
->CanBeHighlighted() )
666 col
= Get(CONTROL_CURRENT
);
667 else if ( flags
& wxCONTROL_PRESSED
)
668 col
= Get(CONTROL_PRESSED
);
677 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(wxT("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(wxT("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(wxWindow
* WXUNUSED(win
), 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/radio 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::DrawRadioButtonBitmap(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].IsOk() )
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 DrawRadioButtonBitmap(dc
, size
, flags
);
1141 wxBitmap
wxGTKRenderer::GetLineWrapBitmap() const
1143 if ( !m_bmpLineWrap
.IsOk() )
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
.IsOk() )
1156 wxFAIL_MSG( wxT("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
.IsOk() )
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
.IsOk() )
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(wxT("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 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
.IsOk() && (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
, wxT("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
, wxT("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
->GetItemLabelText(), &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
].IsOk() )
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(wxT("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(wxT("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].IsOk() )
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].IsOk() )
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].IsOk() )
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].IsOk() )
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(wxT("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
) )
2269 Don't adjust the size for a scrollbar as its DoGetBestClientSize
2270 already has the correct size set. Any size changes here would get
2271 added to the best size, making the scrollbar larger.
2272 Also skip border width adjustments, they don't make sense for us.
2277 #endif // wxUSE_SCROLLBAR
2279 // take into account the border width
2280 wxStdRenderer::AdjustSize(size
, window
);
2284 // ----------------------------------------------------------------------------
2286 // ----------------------------------------------------------------------------
2288 /* Copyright (c) Julian Smart */
2289 static const char *error_xpm
[] = {
2290 /* columns rows colors chars-per-pixel */
2304 " ................. ",
2305 " ................... ",
2306 " ....................... ",
2307 " ......................... ",
2308 " ........................... ",
2309 " ...........................X ",
2310 " .............................X ",
2311 " ............................... ",
2312 " ...............................X ",
2313 " .................................X ",
2314 " .................................X ",
2315 " .................................XX ",
2316 " ...ooooooooooooooooooooooooooo...XX ",
2317 " ....ooooooooooooooooooooooooooo....X ",
2318 " ....ooooooooooooooooooooooooooo....X ",
2319 " ....ooooooooooooooooooooooooooo....XX ",
2320 " ....ooooooooooooooooooooooooooo....XX ",
2321 " ....ooooooooooooooooooooooooooo....XX ",
2322 " ...ooooooooooooooooooooooooooo...XXX ",
2323 " ...ooooooooooooooooooooooooooo...XXX ",
2324 " .................................XX ",
2325 " .................................XX ",
2326 " ...............................XXX ",
2327 " ...............................XXX ",
2328 " .............................XXX ",
2329 " ...........................XXXX ",
2330 " ...........................XXX ",
2331 " .........................XXX ",
2332 " .......................XXXX ",
2333 " X...................XXXXX ",
2334 " X.................XXXXX ",
2335 " X.............XXXXX ",
2336 " XXXX.....XXXXXXXX ",
2347 /* Copyright (c) Julian Smart */
2348 static const char *info_xpm
[] = {
2349 /* columns rows colors chars-per-pixel */
2373 " .XXXOXXXXXXXoo. ",
2374 " .XOOXXX+XXXXXo. ",
2375 " .XOOOXX+++XXXXoo. ",
2376 " .XOOXXX+++XXXXXo. ",
2377 " .XOOOXXX+++XXXXXXo. ",
2378 " .XOOXXXX+++XXXXXXo. ",
2379 " .XXXXXXX+++XXXXXXX. ",
2380 " .XXXXXXX+++XXXXXXo. ",
2381 " .XXXXXXX+++XXXXXoo. ",
2382 " .XXXXXX+++XXXXXo. ",
2383 " .XXXXXXX+XXXXXXo. ",
2384 " .XXXXXXXXXXXXo. ",
2385 " .XXXXX+++XXXoo. ",
2411 /* Copyright (c) Julian Smart */
2412 static const char *warning_xpm
[] = {
2413 /* columns rows colors chars-per-pixel */
2443 " ..XXXXO@#XXX... ",
2444 " ...XXXXO@#XXXX.. ",
2445 " ..XXXXXO@#XXXX... ",
2446 " ...XXXXXo@OXXXXX.. ",
2447 " ...XXXXXXo@OXXXXXX.. ",
2448 " ..XXXXXXX$@OXXXXXX... ",
2449 " ...XXXXXXXX@XXXXXXXX.. ",
2450 " ...XXXXXXXXXXXXXXXXXX... ",
2451 " ..XXXXXXXXXXOXXXXXXXXX.. ",
2452 " ...XXXXXXXXXO@#XXXXXXXXX.. ",
2453 " ..XXXXXXXXXXX#XXXXXXXXXX... ",
2454 " ...XXXXXXXXXXXXXXXXXXXXXXX.. ",
2455 " ...XXXXXXXXXXXXXXXXXXXXXXXX... ",
2456 " .............................. ",
2457 " .............................. ",
2475 /* Copyright (c) Julian Smart */
2476 static const char *question_xpm
[] = {
2477 /* columns rows colors chars-per-pixel */
2507 " ..XXXXoooooXXXO+ ",
2508 " ..XXooooooooooooX@.. ",
2509 " ..XoooooooooooooooXX#. ",
2510 " $%XoooooooooooooooooXX#. ",
2511 " &.XoooooooXXXXXXooooooXX.. ",
2512 " .XooooooXX.$...$XXoooooX*. ",
2513 " $.XoooooX%.$ .*oooooo=.. ",
2514 " .XooooooX.. -.XoooooX.. ",
2515 " .XoooooX..+ .XoooooX;. ",
2516 " ...XXXX..: .XoooooX;. ",
2517 " ........ >.XoooooX;. ",
2551 wxBitmap
wxGTKArtProvider::CreateBitmap(const wxArtID
& id
,
2552 const wxArtClient
& WXUNUSED(client
),
2553 const wxSize
& WXUNUSED(size
))
2555 if ( id
== wxART_INFORMATION
)
2556 return wxBitmap(info_xpm
);
2557 if ( id
== wxART_ERROR
)
2558 return wxBitmap(error_xpm
);
2559 if ( id
== wxART_WARNING
)
2560 return wxBitmap(warning_xpm
);
2561 if ( id
== wxART_QUESTION
)
2562 return wxBitmap(question_xpm
);
2563 return wxNullBitmap
;
2567 // ============================================================================
2569 // ============================================================================
2571 // ----------------------------------------------------------------------------
2572 // wxGTKInputHandler
2573 // ----------------------------------------------------------------------------
2575 bool wxGTKInputHandler::HandleKey(wxInputConsumer
* WXUNUSED(control
),
2576 const wxKeyEvent
& WXUNUSED(event
),
2577 bool WXUNUSED(pressed
))
2582 bool wxGTKInputHandler::HandleMouse(wxInputConsumer
*control
,
2583 const wxMouseEvent
& event
)
2585 // clicking on the control gives it focus
2586 if ( event
.ButtonDown() && wxWindow::FindFocus() != control
->GetInputWindow() )
2588 control
->GetInputWindow()->SetFocus();
2596 bool wxGTKInputHandler::HandleMouseMove(wxInputConsumer
*control
,
2597 const wxMouseEvent
& event
)
2599 if ( event
.Entering() )
2601 control
->GetInputWindow()->SetCurrent(true);
2603 else if ( event
.Leaving() )
2605 control
->GetInputWindow()->SetCurrent(false);
2617 // ----------------------------------------------------------------------------
2618 // wxGTKCheckboxInputHandler
2619 // ----------------------------------------------------------------------------
2621 bool wxGTKCheckboxInputHandler::HandleKey(wxInputConsumer
*control
,
2622 const wxKeyEvent
& event
,
2627 int keycode
= event
.GetKeyCode();
2628 if ( keycode
== WXK_SPACE
|| keycode
== WXK_RETURN
)
2630 control
->PerformAction(wxACTION_CHECKBOX_TOGGLE
);
2639 #endif // wxUSE_CHECKBOX
2643 // ----------------------------------------------------------------------------
2644 // wxGTKTextCtrlInputHandler
2645 // ----------------------------------------------------------------------------
2647 bool wxGTKTextCtrlInputHandler::HandleKey(wxInputConsumer
*control
,
2648 const wxKeyEvent
& event
,
2651 // handle only GTK-specific text bindings here, the others are handled in
2655 wxControlAction action
;
2656 int keycode
= event
.GetKeyCode();
2657 if ( event
.ControlDown() )
2662 action
= wxACTION_TEXT_HOME
;
2666 action
= wxACTION_TEXT_LEFT
;
2670 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_RIGHT
;
2674 action
= wxACTION_TEXT_END
;
2678 action
= wxACTION_TEXT_RIGHT
;
2682 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_LEFT
;
2686 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_END
;
2690 action
= wxACTION_TEXT_DOWN
;
2694 action
= wxACTION_TEXT_UP
;
2698 //delete the entire line
2699 control
->PerformAction(wxACTION_TEXT_HOME
);
2700 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_END
;
2704 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_WORD_LEFT
;
2708 else if ( event
.AltDown() )
2713 action
= wxACTION_TEXT_WORD_LEFT
;
2717 action
<< wxACTION_TEXT_PREFIX_DEL
<< wxACTION_TEXT_WORD_RIGHT
;
2721 action
= wxACTION_TEXT_WORD_RIGHT
;
2726 if ( action
!= wxACTION_NONE
)
2728 control
->PerformAction(action
);
2734 return wxStdInputHandler::HandleKey(control
, event
, pressed
);
2737 #endif // wxUSE_TEXTCTRL
2739 #endif // wxUSE_THEME_GTK