1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/univ/themes/gtk.cpp
3 // Purpose: wxUniversal theme implementing GTK-like LNF
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ===========================================================================
13 // ===========================================================================
15 // ---------------------------------------------------------------------------
17 // ---------------------------------------------------------------------------
19 // for compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
26 #include "wx/univ/theme.h"
33 #include "wx/dcmemory.h"
34 #include "wx/dcclient.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 #include "wx/tglbtn.h"
61 #include "wx/univ/stdrend.h"
62 #include "wx/univ/inpcons.h"
63 #include "wx/univ/inphand.h"
64 #include "wx/univ/colschem.h"
66 class wxGTKMenuGeometryInfo
;
68 // ----------------------------------------------------------------------------
70 // ----------------------------------------------------------------------------
72 // standard border size
73 static const int BORDER_THICKNESS
= 2;
75 // ----------------------------------------------------------------------------
76 // wxGTKRenderer: draw the GUI elements in GTK style
77 // ----------------------------------------------------------------------------
79 class wxGTKRenderer
: public wxStdRenderer
82 wxGTKRenderer(const wxColourScheme
*scheme
);
85 virtual void DrawFocusRect(wxWindow
* win
, wxDC
& dc
, const wxRect
& rect
, int flags
= 0);
86 virtual void DrawTextBorder(wxDC
& dc
,
90 wxRect
*rectIn
= NULL
);
91 virtual void DrawButtonLabel(wxDC
& dc
,
92 const wxString
& label
,
93 const wxBitmap
& image
,
99 virtual void DrawButtonBorder(wxDC
& dc
,
102 wxRect
*rectIn
= NULL
);
103 virtual void DrawArrow(wxDC
& dc
,
107 virtual void DrawScrollbarArrow(wxDC
& dc
,
111 virtual void DrawScrollbarThumb(wxDC
& dc
,
112 wxOrientation orient
,
115 virtual void DrawScrollbarShaft(wxDC
& dc
,
116 wxOrientation orient
,
121 virtual void DrawToolBarButton(wxDC
& dc
,
122 const wxString
& label
,
123 const wxBitmap
& bitmap
,
128 #endif // wxUSE_TOOLBAR
131 virtual void DrawLineWrapMark(wxDC
& dc
, const wxRect
& rect
);
132 #endif // wxUSE_TEXTCTRL
135 virtual void DrawTab(wxDC
& dc
,
138 const wxString
& label
,
139 const wxBitmap
& bitmap
= wxNullBitmap
,
141 int indexAccel
= -1);
142 #endif // wxUSE_NOTEBOOK
145 virtual void DrawSliderShaft(wxDC
& dc
,
148 wxOrientation orient
,
151 wxRect
*rectShaft
= NULL
);
152 virtual void DrawSliderThumb(wxDC
& dc
,
154 wxOrientation orient
,
157 virtual void DrawSliderTicks(wxDC
& WXUNUSED(dc
),
158 const wxRect
& WXUNUSED(rect
),
159 int WXUNUSED(lenThumb
),
160 wxOrientation
WXUNUSED(orient
),
163 int WXUNUSED(step
) = 1,
164 int WXUNUSED(flags
) = 0,
165 long WXUNUSED(style
) = 0)
167 // we don't have the ticks in GTK version
169 #endif // wxUSE_SLIDER
172 virtual void DrawMenuBarItem(wxDC
& dc
,
174 const wxString
& label
,
176 int indexAccel
= -1);
177 virtual void DrawMenuItem(wxDC
& dc
,
179 const wxMenuGeometryInfo
& geometryInfo
,
180 const wxString
& label
,
181 const wxString
& accel
,
182 const wxBitmap
& bitmap
= wxNullBitmap
,
184 int indexAccel
= -1);
185 virtual void DrawMenuSeparator(wxDC
& dc
,
187 const wxMenuGeometryInfo
& geomInfo
);
188 #endif // wxUSE_MENUS
190 virtual void GetComboBitmaps(wxBitmap
*bmpNormal
,
192 wxBitmap
*bmpPressed
,
193 wxBitmap
*bmpDisabled
);
195 virtual void AdjustSize(wxSize
*size
, const wxWindow
*window
);
197 // geometry and hit testing
199 virtual wxSize
GetScrollbarArrowSize() const
200 { return m_sizeScrollbarArrow
; }
201 #endif // wxUSE_SCROLLBAR
203 virtual wxSize
GetCheckBitmapSize() const
204 { return wxSize(10, 10); }
205 virtual wxSize
GetRadioBitmapSize() const
206 { return wxSize(11, 11); }
207 virtual wxCoord
GetCheckItemMargin() const
211 virtual wxSize
GetToolBarButtonSize(wxCoord
*separator
) const
212 { if ( separator
) *separator
= 5; return wxSize(16, 15); }
213 virtual wxSize
GetToolBarMargin() const
214 { return wxSize(6, 6); }
215 #endif // wxUSE_TOOLBAR
218 virtual wxRect
GetTextClientArea(const wxTextCtrl
*text
,
220 wxCoord
*extraSpaceBeyond
) const;
221 #endif // wxUSE_TEXTCTRL
224 virtual wxSize
GetTabIndent() const { return wxSize(2, 2); }
225 virtual wxSize
GetTabPadding() const { return wxSize(6, 6); }
226 #endif // wxUSE_NOTEBOOK
229 virtual wxCoord
GetSliderDim() const { return 15; }
230 virtual wxCoord
GetSliderTickLen() const { return 0; }
231 virtual wxRect
GetSliderShaftRect(const wxRect
& rect
,
233 wxOrientation orient
,
234 long style
= 0) const;
235 virtual wxSize
GetSliderThumbSize(const wxRect
& rect
,
237 wxOrientation orient
) const;
238 #endif // wxUSE_SLIDER
240 virtual wxSize
GetProgressBarStep() const { return wxSize(16, 32); }
243 virtual wxSize
GetMenuBarItemSize(const wxSize
& sizeText
) const;
244 virtual wxMenuGeometryInfo
*GetMenuGeometry(wxWindow
*win
,
245 const wxMenu
& menu
) const;
246 #endif // wxUSE_MENUS
248 // helpers for "wxBitmap wxColourScheme::Get()"
249 void DrawCheckBitmap(wxDC
& dc
, const wxRect
& rect
);
250 void DrawUncheckBitmap(wxDC
& dc
, const wxRect
& rect
, bool isPressed
);
251 void DrawUndeterminedBitmap(wxDC
& dc
, const wxRect
& rect
, bool isPressed
);
254 // overridden wxStdRenderer methods
255 virtual void DrawSunkenBorder(wxDC
& dc
, wxRect
*rect
);
257 virtual void DrawFrameWithLabel(wxDC
& dc
,
258 const wxString
& label
,
259 const wxRect
& rectFrame
,
260 const wxRect
& rectText
,
265 virtual void DrawCheckItemBitmap(wxDC
& dc
,
266 const wxBitmap
& bitmap
,
270 // get the colour to use for background
271 wxColour
GetBackgroundColour(int flags
) const
273 if ( flags
& wxCONTROL_PRESSED
)
274 return wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
);
275 else if ( flags
& wxCONTROL_CURRENT
)
276 return wxSCHEME_COLOUR(m_scheme
, CONTROL_CURRENT
);
278 return wxSCHEME_COLOUR(m_scheme
, CONTROL
);
281 // as DrawShadedRect() but the pixels in the bottom left and upper right
282 // border are drawn with the pen1, not pen2
283 void DrawAntiShadedRect(wxDC
& dc
, wxRect
*rect
,
284 const wxPen
& pen1
, const wxPen
& pen2
);
286 // used for drawing opened rectangles - draws only one side of it at once
287 // (and doesn't adjust the rect)
288 void DrawAntiShadedRectSide(wxDC
& dc
,
294 // draw an opened rect for the arrow in given direction
295 void DrawArrowBorder(wxDC
& dc
,
299 // draw two sides of the rectangle
300 void DrawThumbBorder(wxDC
& dc
,
302 wxOrientation orient
);
304 // just as DrawRaisedBorder() except that the bottom left and up right
305 // pixels of the interior rect are drawn in another colour (i.e. the inner
306 // rect is drawn with DrawAntiShadedRect() and not DrawShadedRect())
307 void DrawAntiRaisedBorder(wxDC
& dc
, wxRect
*rect
);
309 // draw inner GTK shadow
310 void DrawInnerShadedRect(wxDC
& dc
, wxRect
*rect
);
312 // get the line wrap indicator bitmap
313 wxBitmap
GetLineWrapBitmap() const;
315 virtual wxBitmap
GetCheckBitmap(int flags
);
316 virtual wxBitmap
GetRadioBitmap(int flags
);
318 // draw a /\ or \/ line from (x1, y1) to (x2, y1) passing by the point
320 void DrawUpZag(wxDC
& dc
,
321 wxCoord x1
, wxCoord x2
,
322 wxCoord y1
, wxCoord y2
);
323 void DrawDownZag(wxDC
& dc
,
324 wxCoord x1
, wxCoord x2
,
325 wxCoord y1
, wxCoord y2
);
327 // draw the radio button bitmap for the given state
328 void DrawRadioButtonBitmap(wxDC
& dc
, const wxRect
& rect
, int flags
);
330 // common part of DrawMenuItem() and DrawMenuBarItem()
331 void DoDrawMenuItem(wxDC
& dc
,
333 const wxString
& label
,
336 const wxString
& accel
= wxEmptyString
,
337 const wxBitmap
& bitmap
= wxNullBitmap
,
338 const wxGTKMenuGeometryInfo
*geometryInfo
= NULL
);
340 // initialize the combo bitmaps
341 void InitComboBitmaps();
343 virtual wxBitmap
GetFrameButtonBitmap(FrameButtonType
WXUNUSED(type
))
350 wxSize m_sizeScrollbarArrow
;
355 // the checkbox and radio button bitmaps: first row is for the normal,
356 // second for the pressed state and the columns are for checked, unchecked
357 // and undeterminated respectively
358 wxBitmap m_bitmapsCheckbox
[IndicatorState_MaxCtrl
][IndicatorStatus_Max
],
359 m_bitmapsRadiobtn
[IndicatorState_MaxCtrl
][IndicatorStatus_Max
];
361 // the line wrap bitmap (drawn at the end of wrapped lines)
362 wxBitmap m_bmpLineWrap
;
364 // the combobox bitmaps
374 wxBitmap m_bitmapsCombo
[ComboState_Max
];
377 // ----------------------------------------------------------------------------
378 // wxGTKInputHandler and derived classes: process the keyboard and mouse
379 // messages according to GTK standards
380 // ----------------------------------------------------------------------------
382 class wxGTKInputHandler
: public wxInputHandler
385 wxGTKInputHandler() { }
387 virtual bool HandleKey(wxInputConsumer
*control
,
388 const wxKeyEvent
& event
,
390 virtual bool HandleMouse(wxInputConsumer
*control
,
391 const wxMouseEvent
& event
);
392 virtual bool HandleMouseMove(wxInputConsumer
*control
,
393 const wxMouseEvent
& event
);
398 class wxGTKScrollBarInputHandler
: public wxStdScrollBarInputHandler
401 wxGTKScrollBarInputHandler(wxRenderer
*renderer
, wxInputHandler
*handler
)
402 : wxStdScrollBarInputHandler(renderer
, handler
) { }
405 virtual void Highlight(wxScrollBar
*scrollbar
, bool doIt
)
407 // only arrows and the thumb can be highlighted
408 if ( !IsArrow() && m_htLast
!= wxHT_SCROLLBAR_THUMB
)
411 wxStdScrollBarInputHandler::Highlight(scrollbar
, doIt
);
414 virtual void Press(wxScrollBar
*scrollbar
, bool doIt
)
416 // only arrows can be pressed
420 wxStdScrollBarInputHandler::Press(scrollbar
, doIt
);
423 // any button can be used to drag the scrollbar under GTK+
424 virtual bool IsAllowedButton(int WXUNUSED(button
)) const { return true; }
428 return m_htLast
== wxHT_SCROLLBAR_ARROW_LINE_1
||
429 m_htLast
== wxHT_SCROLLBAR_ARROW_LINE_2
;
433 #endif // wxUSE_SCROLLBAR
437 class wxGTKCheckboxInputHandler
: public wxStdInputHandler
440 wxGTKCheckboxInputHandler(wxInputHandler
*handler
)
441 : wxStdInputHandler(handler
) { }
443 virtual bool HandleKey(wxInputConsumer
*control
,
444 const wxKeyEvent
& event
,
448 #endif // wxUSE_CHECKBOX
452 class wxGTKTextCtrlInputHandler
: public wxStdInputHandler
455 wxGTKTextCtrlInputHandler(wxInputHandler
*handler
)
456 : wxStdInputHandler(handler
) { }
458 virtual bool HandleKey(wxInputConsumer
*control
,
459 const wxKeyEvent
& event
,
463 #endif // wxUSE_TEXTCTRL
465 // ----------------------------------------------------------------------------
466 // wxGTKColourScheme: uses the standard GTK colours
467 // ----------------------------------------------------------------------------
469 class wxGTKColourScheme
: public wxColourScheme
472 virtual wxColour
Get(StdColour col
) const;
473 virtual wxColour
GetBackground(wxWindow
*win
) const;
476 // ----------------------------------------------------------------------------
478 // ----------------------------------------------------------------------------
480 class wxGTKArtProvider
: public wxArtProvider
483 virtual wxBitmap
CreateBitmap(const wxArtID
& id
,
484 const wxArtClient
& client
,
488 // ----------------------------------------------------------------------------
490 // ----------------------------------------------------------------------------
492 WX_DEFINE_ARRAY_PTR(wxInputHandler
*, wxArrayHandlers
);
494 class wxGTKTheme
: public wxTheme
498 virtual ~wxGTKTheme();
500 virtual wxRenderer
*GetRenderer();
501 virtual wxArtProvider
*GetArtProvider();
502 virtual wxInputHandler
*GetInputHandler(const wxString
& control
,
503 wxInputConsumer
*consumer
);
504 virtual wxColourScheme
*GetColourScheme();
507 wxGTKRenderer
*m_renderer
;
509 wxGTKArtProvider
*m_artProvider
;
511 // the names of the already created handlers and the handlers themselves
512 // (these arrays are synchronized)
513 wxSortedArrayString m_handlerNames
;
514 wxArrayHandlers m_handlers
;
516 wxGTKColourScheme
*m_scheme
;
518 WX_DECLARE_THEME(gtk
)
521 // ============================================================================
523 // ============================================================================
525 WX_IMPLEMENT_THEME(wxGTKTheme
, gtk
, wxTRANSLATE("GTK+ theme"));
527 // ----------------------------------------------------------------------------
529 // ----------------------------------------------------------------------------
531 wxGTKTheme::wxGTKTheme()
535 m_artProvider
= NULL
;
538 wxGTKTheme::~wxGTKTheme()
542 delete m_artProvider
;
545 wxRenderer
*wxGTKTheme::GetRenderer()
549 m_renderer
= new wxGTKRenderer(GetColourScheme());
555 wxArtProvider
*wxGTKTheme::GetArtProvider()
557 if ( !m_artProvider
)
559 m_artProvider
= new wxGTKArtProvider
;
562 return m_artProvider
;
565 wxColourScheme
*wxGTKTheme::GetColourScheme()
569 m_scheme
= new wxGTKColourScheme
;
574 wxInputHandler
*wxGTKTheme::GetInputHandler(const wxString
& control
,
575 wxInputConsumer
*consumer
)
577 wxInputHandler
*handler
= NULL
;
578 int n
= m_handlerNames
.Index(control
);
579 if ( n
== wxNOT_FOUND
)
581 static wxGTKInputHandler s_handlerDef
;
583 wxInputHandler
* const
584 handlerStd
= consumer
->DoGetStdInputHandler(&s_handlerDef
);
586 // create a new handler
588 if ( control
== wxINP_HANDLER_CHECKBOX
)
590 static wxGTKCheckboxInputHandler
s_handler(handlerStd
);
592 handler
= &s_handler
;
595 #endif // wxUSE_CHECKBOX
597 if ( control
== wxINP_HANDLER_SCROLLBAR
)
599 static wxGTKScrollBarInputHandler
s_handler(m_renderer
, handlerStd
);
601 handler
= &s_handler
;
604 #endif // wxUSE_SCROLLBAR
606 if ( control
== wxINP_HANDLER_TEXTCTRL
)
608 static wxGTKTextCtrlInputHandler
s_handler(handlerStd
);
610 handler
= &s_handler
;
613 #endif // wxUSE_TEXTCTRL
615 // no special handler for this control
616 handler
= handlerStd
;
619 n
= m_handlerNames
.Add(control
);
620 m_handlers
.Insert(handler
, n
);
622 else // we already have it
624 handler
= m_handlers
[n
];
630 // ============================================================================
632 // ============================================================================
634 wxColour
wxGTKColourScheme::GetBackground(wxWindow
*win
) const
637 if ( win
->UseBgCol() )
639 // use the user specified colour
640 col
= win
->GetBackgroundColour();
643 if ( !win
->ShouldInheritColours() )
645 // doesn't depend on the state
653 int flags
= win
->GetStateFlags();
655 // the colour set by the user should be used for the normal state
656 // and for the states for which we don't have any specific colours
657 if ( !col
.IsOk() || (flags
!= 0) )
660 if ( wxDynamicCast(win
, wxScrollBar
) )
661 col
= Get(SCROLLBAR
);
663 #endif //wxUSE_SCROLLBAR
664 if ( (flags
& wxCONTROL_CURRENT
) && win
->CanBeHighlighted() )
665 col
= Get(CONTROL_CURRENT
);
666 else if ( flags
& wxCONTROL_PRESSED
)
667 col
= Get(CONTROL_PRESSED
);
676 wxColour
wxGTKColourScheme::Get(wxGTKColourScheme::StdColour col
) const
681 case WINDOW
: return *wxWHITE
;
683 case SHADOW_DARK
: return *wxBLACK
;
684 case SHADOW_HIGHLIGHT
: return *wxWHITE
;
685 case SHADOW_IN
: return wxColour(0xd6d6d6);
686 case SHADOW_OUT
: return wxColour(0x969696);
688 case CONTROL
: return wxColour(0xd6d6d6);
689 case CONTROL_PRESSED
: return wxColour(0xc3c3c3);
690 case CONTROL_CURRENT
: return wxColour(0xeaeaea);
692 case CONTROL_TEXT
: return *wxBLACK
;
693 case CONTROL_TEXT_DISABLED
:
694 return wxColour(0x757575);
695 case CONTROL_TEXT_DISABLED_SHADOW
:
699 case SCROLLBAR_PRESSED
: return wxColour(0xc3c3c3);
701 case HIGHLIGHT
: return wxColour(0x9c0000);
702 case HIGHLIGHT_TEXT
: return wxColour(0xffffff);
704 case GAUGE
: return Get(CONTROL_CURRENT
);
706 case TITLEBAR
: return wxColour(0xaeaaae);
707 case TITLEBAR_ACTIVE
: return wxColour(0x820300);
708 case TITLEBAR_TEXT
: return wxColour(0xc0c0c0);
709 case TITLEBAR_ACTIVE_TEXT
:
712 case DESKTOP
: return *wxBLACK
;
716 wxFAIL_MSG(wxT("invalid standard colour"));
721 // ============================================================================
723 // ============================================================================
725 // ----------------------------------------------------------------------------
727 // ----------------------------------------------------------------------------
729 wxGTKRenderer::wxGTKRenderer(const wxColourScheme
*scheme
)
730 : wxStdRenderer(scheme
)
732 m_sizeScrollbarArrow
= wxSize(15, 14);
734 m_penGrey
= wxPen(wxSCHEME_COLOUR(scheme
, SCROLLBAR
));
737 // ----------------------------------------------------------------------------
739 // ----------------------------------------------------------------------------
741 void wxGTKRenderer::DrawAntiShadedRectSide(wxDC
& dc
,
747 dc
.SetPen(dir
== wxLEFT
|| dir
== wxUP
? pen1
: pen2
);
752 dc
.DrawLine(rect
.GetLeft(), rect
.GetTop(),
753 rect
.GetLeft(), rect
.GetBottom() + 1);
757 dc
.DrawLine(rect
.GetLeft(), rect
.GetTop(),
758 rect
.GetRight() + 1, rect
.GetTop());
762 dc
.DrawLine(rect
.GetRight(), rect
.GetTop(),
763 rect
.GetRight(), rect
.GetBottom() + 1);
767 dc
.DrawLine(rect
.GetLeft(), rect
.GetBottom(),
768 rect
.GetRight() + 1, rect
.GetBottom());
772 wxFAIL_MSG(wxT("unknown rectangle side"));
776 void wxGTKRenderer::DrawAntiShadedRect(wxDC
& dc
, wxRect
*rect
,
777 const wxPen
& pen1
, const wxPen
& pen2
)
779 // draw the rectangle
781 dc
.DrawLine(rect
->GetLeft(), rect
->GetTop(),
782 rect
->GetLeft(), rect
->GetBottom() + 1);
783 dc
.DrawLine(rect
->GetLeft() + 1, rect
->GetTop(),
784 rect
->GetRight() + 1, rect
->GetTop());
786 dc
.DrawLine(rect
->GetRight(), rect
->GetTop() + 1,
787 rect
->GetRight(), rect
->GetBottom());
788 dc
.DrawLine(rect
->GetLeft() + 1, rect
->GetBottom(),
789 rect
->GetRight() + 1, rect
->GetBottom());
795 void wxGTKRenderer::DrawInnerShadedRect(wxDC
& dc
, wxRect
*rect
)
797 DrawAntiShadedRect(dc
, rect
, m_penDarkGrey
, m_penHighlight
);
798 DrawAntiShadedRect(dc
, rect
, m_penBlack
, m_penHighlight
);
801 void wxGTKRenderer::DrawAntiRaisedBorder(wxDC
& dc
, wxRect
*rect
)
803 DrawShadedRect(dc
, rect
, m_penHighlight
, m_penBlack
);
804 DrawAntiShadedRect(dc
, rect
, m_penLightGrey
, m_penDarkGrey
);
807 void wxGTKRenderer::DrawSunkenBorder(wxDC
& dc
, wxRect
*rect
)
809 DrawAntiShadedRect(dc
, rect
, m_penDarkGrey
, m_penHighlight
);
810 DrawShadedRect(dc
, rect
, m_penBlack
, m_penLightGrey
);
814 wxGTKRenderer::DrawFocusRect(wxWindow
* WXUNUSED(win
), wxDC
& dc
, const wxRect
& rect
, int WXUNUSED(flags
))
816 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
817 wxRect rectFocus
= rect
;
818 DrawRect(dc
, &rectFocus
, m_penBlack
);
821 void wxGTKRenderer::DrawTextBorder(wxDC
& dc
,
823 const wxRect
& rectOrig
,
827 wxRect rect
= rectOrig
;
829 if ( border
!= wxBORDER_NONE
)
831 if ( flags
& wxCONTROL_FOCUSED
)
833 DrawRect(dc
, &rect
, m_penBlack
);
834 DrawAntiShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
838 DrawInnerShadedRect(dc
, &rect
);
846 void wxGTKRenderer::DrawButtonLabel(wxDC
& dc
,
847 const wxString
& label
,
848 const wxBitmap
& image
,
855 // no focus rect around buttons label in GTK+
856 wxStdRenderer::DrawButtonLabel(dc
, label
, image
, rect
, flags
,
857 alignment
, indexAccel
, rectBounds
);
860 void wxGTKRenderer::DrawButtonBorder(wxDC
& dc
,
861 const wxRect
& rectTotal
,
865 wxRect rect
= rectTotal
;
867 if ( flags
& wxCONTROL_PRESSED
)
869 // button pressed: draw a black border around it and an inward shade
870 DrawRect(dc
, &rect
, m_penBlack
);
872 DrawInnerShadedRect(dc
, &rect
);
874 else // button not pressed
876 if ( flags
& wxCONTROL_ISDEFAULT
)
881 if ( flags
& wxCONTROL_FOCUSED
)
883 // button is currently default: add an extra border around it
884 DrawRect(dc
, &rect
, m_penBlack
);
887 // now draw a normal button
888 DrawShadedRect(dc
, &rect
, m_penHighlight
, m_penBlack
);
889 DrawAntiShadedRect(dc
, &rect
, GetBackgroundColour(flags
), m_penDarkGrey
);
896 // ----------------------------------------------------------------------------
898 // ----------------------------------------------------------------------------
900 void wxGTKRenderer::DrawFrameWithLabel(wxDC
& dc
,
901 const wxString
& label
,
902 const wxRect
& rectFrame
,
903 const wxRect
& rectTextOrig
,
908 wxRect
rectText(rectTextOrig
);
909 rectText
.Inflate(1, 0);
912 DrawLabel(dc
, label
, rectText
, flags
, alignment
, indexAccel
, &rectLabel
);
914 rectLabel
.width
+= 2;
916 DrawFrameWithoutLabel(dc
, rectFrame
, rectLabel
);
918 // GTK+ does it like this
919 dc
.SetPen(m_penHighlight
);
920 dc
.DrawPoint(rectText
.x
, rectFrame
.y
);
921 dc
.DrawPoint(rectText
.x
+ rectLabel
.width
- 3, rectFrame
.y
);
924 // ----------------------------------------------------------------------------
925 // check/radio buttons
926 // ----------------------------------------------------------------------------
928 void wxGTKRenderer::DrawCheckItemBitmap(wxDC
& dc
,
929 const wxBitmap
& bitmap
,
933 // never draw the focus rect around the check indicators here
934 DrawCheckButton(dc
, wxEmptyString
, bitmap
, rect
, flags
& ~wxCONTROL_FOCUSED
);
937 void wxGTKRenderer::DrawUndeterminedBitmap(wxDC
& dc
,
938 const wxRect
& rectTotal
,
941 // FIXME: For sure it is not GTK look but it is better than nothing.
942 // Show me correct look and I will immediatelly make it better (ABX)
943 wxRect rect
= rectTotal
;
949 col1
= wxSCHEME_COLOUR(m_scheme
, SHADOW_DARK
);
950 col2
= wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
);
954 col1
= wxSCHEME_COLOUR(m_scheme
, SHADOW_DARK
);
955 col2
= wxSCHEME_COLOUR(m_scheme
, SHADOW_IN
);
958 dc
.SetPen(*wxTRANSPARENT_PEN
);
960 dc
.DrawRectangle(rect
);
963 dc
.DrawRectangle(rect
);
966 void wxGTKRenderer::DrawUncheckBitmap(wxDC
& dc
,
967 const wxRect
& rectTotal
,
970 wxRect rect
= rectTotal
;
971 DrawAntiRaisedBorder(dc
, &rect
);
973 wxColour col
= wxSCHEME_COLOUR(m_scheme
, SHADOW_IN
);
974 dc
.SetPen(wxPen(col
));
975 dc
.DrawPoint(rect
.GetRight() - 1, rect
.GetBottom() - 1);
978 col
= wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
);
979 //else: it is SHADOW_IN, leave as is
981 dc
.SetPen(*wxTRANSPARENT_PEN
);
983 dc
.DrawRectangle(rect
);
986 void wxGTKRenderer::DrawCheckBitmap(wxDC
& dc
, const wxRect
& rectTotal
)
988 wxRect rect
= rectTotal
;
989 DrawAntiShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
990 DrawShadedRect(dc
, &rect
, m_penBlack
, m_penLightGrey
);
992 dc
.SetPen(*wxTRANSPARENT_PEN
);
993 dc
.SetBrush(wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
));
994 dc
.DrawRectangle(rect
);
997 void wxGTKRenderer::DrawRadioButtonBitmap(wxDC
& dc
,
1003 xRight
= rect
.GetRight(),
1004 yBottom
= rect
.GetBottom();
1006 wxCoord yMid
= (y
+ yBottom
) / 2;
1008 // then draw the upper half
1009 dc
.SetPen(flags
& wxCONTROL_CHECKED
? m_penDarkGrey
: m_penHighlight
);
1010 DrawUpZag(dc
, x
, xRight
, yMid
, y
);
1011 DrawUpZag(dc
, x
+ 1, xRight
- 1, yMid
, y
+ 1);
1014 if ( flags
& wxCONTROL_CHECKED
)
1015 dc
.SetPen(m_penBlack
);
1016 else if ( flags
& wxCONTROL_PRESSED
)
1017 dc
.SetPen(wxPen(wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
)));
1018 else // unchecked and unpressed
1022 DrawUpZag(dc
, x
+ 2, xRight
- 2, yMid
, y
+ 2);
1024 // and then the lower one
1025 dc
.SetPen(flags
& wxCONTROL_CHECKED
? m_penHighlight
: m_penBlack
);
1026 DrawDownZag(dc
, x
, xRight
, yMid
, yBottom
);
1027 if ( !(flags
& wxCONTROL_CHECKED
) )
1028 dc
.SetPen(m_penDarkGrey
);
1029 DrawDownZag(dc
, x
+ 1, xRight
- 1, yMid
, yBottom
- 1);
1031 if ( !(flags
& wxCONTROL_CHECKED
) )
1032 drawIt
= true; // with the same pen
1033 else if ( flags
& wxCONTROL_PRESSED
)
1035 dc
.SetPen(wxPen(wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
)));
1038 else // checked and unpressed
1042 DrawDownZag(dc
, x
+ 2, xRight
- 2, yMid
, yBottom
- 2);
1045 void wxGTKRenderer::DrawUpZag(wxDC
& dc
,
1051 wxCoord xMid
= (x1
+ x2
) / 2;
1052 dc
.DrawLine(x1
, y1
, xMid
, y2
);
1053 dc
.DrawLine(xMid
, y2
, x2
+ 1, y1
+ 1);
1056 void wxGTKRenderer::DrawDownZag(wxDC
& dc
,
1062 wxCoord xMid
= (x1
+ x2
) / 2;
1063 dc
.DrawLine(x1
+ 1, y1
+ 1, xMid
, y2
);
1064 dc
.DrawLine(xMid
, y2
, x2
, y1
);
1067 wxBitmap
wxGTKRenderer::GetCheckBitmap(int flags
)
1069 if ( !m_bitmapsCheckbox
[0][0].IsOk() )
1071 // init the bitmaps once only
1073 wxSize size
= GetCheckBitmapSize();
1074 rect
.width
= size
.x
;
1075 rect
.height
= size
.y
;
1076 for ( int i
= 0; i
< 2; i
++ )
1078 for ( int j
= 0; j
< 3; j
++ )
1079 m_bitmapsCheckbox
[i
][j
].Create(rect
.width
, rect
.height
);
1085 dc
.SelectObject(m_bitmapsCheckbox
[0][0]);
1086 DrawCheckBitmap(dc
, rect
);
1089 dc
.SelectObject(m_bitmapsCheckbox
[0][1]);
1090 DrawUncheckBitmap(dc
, rect
, false);
1092 // normal undeterminated
1093 dc
.SelectObject(m_bitmapsCheckbox
[0][2]);
1094 DrawUndeterminedBitmap(dc
, rect
, false);
1097 m_bitmapsCheckbox
[1][0] = m_bitmapsCheckbox
[0][0];
1099 // pressed unchecked
1100 dc
.SelectObject(m_bitmapsCheckbox
[1][1]);
1101 DrawUncheckBitmap(dc
, rect
, true);
1103 // pressed undeterminated
1104 dc
.SelectObject(m_bitmapsCheckbox
[1][2]);
1105 DrawUndeterminedBitmap(dc
, rect
, true);
1108 IndicatorState state
;
1109 IndicatorStatus status
;
1110 GetIndicatorsFromFlags(flags
, state
, status
);
1112 // disabled looks the same as normal
1113 if ( state
== IndicatorState_Disabled
)
1114 state
= IndicatorState_Normal
;
1116 return m_bitmapsCheckbox
[state
][status
];
1119 wxBitmap
wxGTKRenderer::GetRadioBitmap(int flags
)
1121 IndicatorState state
;
1122 IndicatorStatus status
;
1123 GetIndicatorsFromFlags(flags
, state
, status
);
1125 wxBitmap
& bmp
= m_bitmapsRadiobtn
[state
][status
];
1128 const wxSize size
= GetRadioBitmapSize();
1131 bmp
.Create(size
.x
, size
.y
);
1132 dc
.SelectObject(bmp
);
1134 DrawRadioButtonBitmap(dc
, size
, flags
);
1140 wxBitmap
wxGTKRenderer::GetLineWrapBitmap() const
1142 if ( !m_bmpLineWrap
.IsOk() )
1144 // the line wrap bitmap as used by GTK+
1145 #define line_wrap_width 6
1146 #define line_wrap_height 9
1147 static const char line_wrap_bits
[] =
1149 0x1e, 0x3e, 0x30, 0x30, 0x39, 0x1f, 0x0f, 0x0f, 0x1f,
1152 wxBitmap
bmpLineWrap(line_wrap_bits
, line_wrap_width
, line_wrap_height
);
1153 if ( !bmpLineWrap
.IsOk() )
1155 wxFAIL_MSG( wxT("Failed to create line wrap XBM") );
1159 wxConstCast(this, wxGTKRenderer
)->m_bmpLineWrap
= bmpLineWrap
;
1163 return m_bmpLineWrap
;
1167 void wxGTKRenderer::DrawToolBarButton(wxDC
& dc
,
1168 const wxString
& label
,
1169 const wxBitmap
& bitmap
,
1170 const wxRect
& rectOrig
,
1172 long WXUNUSED(style
),
1175 // we don't draw the separators at all
1176 if ( !label
.empty() || bitmap
.IsOk() )
1178 wxRect rect
= rectOrig
;
1179 rect
.Deflate(BORDER_THICKNESS
);
1181 if ( flags
& wxCONTROL_PRESSED
)
1183 DrawBorder(dc
, wxBORDER_SUNKEN
, rect
, flags
, &rect
);
1185 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL_PRESSED
), rect
);
1187 else if ( flags
& wxCONTROL_CURRENT
)
1189 DrawBorder(dc
, wxBORDER_RAISED
, rect
, flags
, &rect
);
1191 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL_CURRENT
), rect
);
1194 if(tbarStyle
& wxTB_TEXT
)
1196 if(tbarStyle
& wxTB_HORIZONTAL
)
1198 dc
.DrawLabel(label
, bitmap
, rect
, wxALIGN_CENTRE
);
1202 dc
.DrawLabel(label
, bitmap
, rect
, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
);
1207 int xpoint
= (rect
.GetLeft() + rect
.GetRight() + 1 - bitmap
.GetWidth()) / 2;
1208 int ypoint
= (rect
.GetTop() + rect
.GetBottom() + 1 - bitmap
.GetHeight()) / 2;
1209 dc
.DrawBitmap(bitmap
, xpoint
, ypoint
);
1213 #endif // wxUSE_TOOLBAR
1215 // ----------------------------------------------------------------------------
1217 // ----------------------------------------------------------------------------
1221 wxRect
wxGTKRenderer::GetTextClientArea(const wxTextCtrl
*text
,
1223 wxCoord
*extraSpaceBeyond
) const
1226 rectText
= wxStdRenderer::GetTextClientArea(text
, rect
, extraSpaceBeyond
);
1228 if ( text
->WrapLines() )
1230 // leave enough for the line wrap bitmap indicator
1231 wxCoord widthMark
= GetLineWrapBitmap().GetWidth() + 2;
1233 rectText
.width
-= widthMark
;
1235 if ( extraSpaceBeyond
)
1236 *extraSpaceBeyond
= widthMark
;
1242 void wxGTKRenderer::DrawLineWrapMark(wxDC
& dc
, const wxRect
& rect
)
1244 wxBitmap bmpLineWrap
= GetLineWrapBitmap();
1246 // for a mono bitmap he colours it appears in depends on the current text
1247 // colours, so set them correctly
1249 if ( bmpLineWrap
.GetDepth() == 1 )
1251 colFgOld
= dc
.GetTextForeground();
1253 // FIXME: I wonder what should we do if the background is black too?
1254 dc
.SetTextForeground(*wxBLACK
);
1257 dc
.DrawBitmap(bmpLineWrap
,
1258 rect
.x
, rect
.y
+ (rect
.height
- bmpLineWrap
.GetHeight())/2);
1260 if ( colFgOld
.IsOk() )
1262 // restore old colour
1263 dc
.SetTextForeground(colFgOld
);
1267 #endif // wxUSE_TEXTCTRL
1269 // ----------------------------------------------------------------------------
1271 // ----------------------------------------------------------------------------
1275 void wxGTKRenderer::DrawTab(wxDC
& dc
,
1276 const wxRect
& rectOrig
,
1278 const wxString
& label
,
1279 const wxBitmap
& bitmap
,
1283 #define SELECT_FOR_VERTICAL(X,Y) ( isVertical ? Y : X )
1284 #define REVERSE_FOR_VERTICAL(X,Y) \
1285 SELECT_FOR_VERTICAL(X,Y) \
1287 SELECT_FOR_VERTICAL(Y,X)
1289 wxRect rect
= rectOrig
;
1291 bool isVertical
= ( dir
== wxLEFT
) || ( dir
== wxRIGHT
);
1293 // the current tab is drawn indented (to the top for default case) and
1294 // bigger than the other ones
1295 const wxSize indent
= GetTabIndent();
1296 if ( flags
& wxCONTROL_SELECTED
)
1298 rect
.Inflate( SELECT_FOR_VERTICAL( indent
.x
, 0),
1299 SELECT_FOR_VERTICAL( 0, indent
.y
));
1303 wxFAIL_MSG(wxT("invaild notebook tab orientation"));
1310 rect
.height
+= indent
.y
;
1317 rect
.width
+= indent
.x
;
1322 // selected tab has different colour
1323 wxColour col
= flags
& wxCONTROL_SELECTED
1324 ? wxSCHEME_COLOUR(m_scheme
, SHADOW_IN
)
1325 : wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
);
1326 DrawSolidRect(dc
, col
, rect
);
1328 if ( flags
& wxCONTROL_FOCUSED
)
1330 // draw the focus rect
1331 wxRect rectBorder
= rect
;
1332 rectBorder
.Deflate(4, 3);
1333 if ( dir
== wxBOTTOM
)
1334 rectBorder
.Offset(0, -1);
1335 if ( dir
== wxRIGHT
)
1336 rectBorder
.Offset(-1, 0);
1338 DrawRect(dc
, &rectBorder
, m_penBlack
);
1341 // draw the text, image and the focus around them (if necessary)
1342 wxRect
rectLabel( REVERSE_FOR_VERTICAL(rect
.x
,rect
.y
),
1343 REVERSE_FOR_VERTICAL(rect
.width
,rect
.height
)
1345 rectLabel
.Deflate(1, 1);
1348 // draw it horizontally into memory and rotate for screen
1350 wxBitmap bitmapRotated
,
1351 bitmapMem( rectLabel
.x
+ rectLabel
.width
,
1352 rectLabel
.y
+ rectLabel
.height
);
1353 dcMem
.SelectObject(bitmapMem
);
1354 dcMem
.SetBackground(dc
.GetBackground());
1355 dcMem
.SetFont(dc
.GetFont());
1356 dcMem
.SetTextForeground(dc
.GetTextForeground());
1360 wxBitmap( wxImage( bitmap
.ConvertToImage() ).Rotate90(dir
==wxLEFT
) )
1363 #endif // wxUSE_IMAGE
1365 dcMem
.DrawLabel(label
, bitmapRotated
, rectLabel
, wxALIGN_CENTRE
, indexAccel
);
1366 dcMem
.SelectObject(wxNullBitmap
);
1367 bitmapMem
= bitmapMem
.GetSubBitmap(rectLabel
);
1369 bitmapMem
= wxBitmap(wxImage(bitmapMem
.ConvertToImage()).Rotate90(dir
==wxRIGHT
))
1373 dc
.DrawBitmap(bitmapMem
, rectLabel
.y
, rectLabel
.x
, false);
1377 dc
.DrawLabel(label
, bitmap
, rectLabel
, wxALIGN_CENTRE
, indexAccel
);
1380 // now draw the tab itself
1381 wxCoord x
= SELECT_FOR_VERTICAL(rect
.x
,rect
.y
),
1382 y
= SELECT_FOR_VERTICAL(rect
.y
,rect
.x
),
1383 x2
= SELECT_FOR_VERTICAL(rect
.GetRight(),rect
.GetBottom()),
1384 y2
= SELECT_FOR_VERTICAL(rect
.GetBottom(),rect
.GetRight());
1390 // left orientation looks like top but IsVertical makes x and y reversed
1392 // top is not vertical so use coordinates in written order
1393 dc
.SetPen(m_penHighlight
);
1394 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y2
),
1395 REVERSE_FOR_VERTICAL(x
, y
));
1396 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
),
1397 REVERSE_FOR_VERTICAL(x2
, y
));
1399 dc
.SetPen(m_penBlack
);
1400 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y2
),
1401 REVERSE_FOR_VERTICAL(x2
, y
));
1403 dc
.SetPen(m_penDarkGrey
);
1404 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
- 1, y2
),
1405 REVERSE_FOR_VERTICAL(x2
- 1, y
+ 1));
1407 if ( flags
& wxCONTROL_SELECTED
)
1409 dc
.SetPen(m_penLightGrey
);
1411 // overwrite the part of the border below this tab
1412 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
+ 1),
1413 REVERSE_FOR_VERTICAL(x2
- 1, y2
+ 1));
1415 // and the shadow of the tab to the left of us
1416 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
+ 2),
1417 REVERSE_FOR_VERTICAL(x
+ 1, y2
+ 1));
1422 // right orientation looks like bottom but IsVertical makes x and y reversed
1424 // bottom is not vertical so use coordinates in written order
1425 dc
.SetPen(m_penHighlight
);
1427 // we need to continue one pixel further to overwrite the corner of
1428 // the border for the selected tab
1429 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y
- (flags
& wxCONTROL_SELECTED
? 1 : 0)),
1430 REVERSE_FOR_VERTICAL(x
, y2
));
1432 // it doesn't work like this (TODO: implement it properly)
1434 // erase the corner of the tab to the right
1435 dc
.SetPen(m_penLightGrey
);
1436 dc
.DrawPoint(REVERSE_FOR_VERTICAL(x2
- 1, y
- 2));
1437 dc
.DrawPoint(REVERSE_FOR_VERTICAL(x2
- 2, y
- 2));
1438 dc
.DrawPoint(REVERSE_FOR_VERTICAL(x2
- 2, y
- 1));
1441 dc
.SetPen(m_penBlack
);
1442 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
),
1443 REVERSE_FOR_VERTICAL(x2
, y2
));
1444 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y
),
1445 REVERSE_FOR_VERTICAL(x2
, y2
));
1447 dc
.SetPen(m_penDarkGrey
);
1448 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 2, y2
- 1),
1449 REVERSE_FOR_VERTICAL(x2
- 1, y2
- 1));
1450 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
- 1, y
),
1451 REVERSE_FOR_VERTICAL(x2
- 1, y2
));
1453 if ( flags
& wxCONTROL_SELECTED
)
1455 dc
.SetPen(m_penLightGrey
);
1457 // overwrite the part of the (double!) border above this tab
1458 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
- 1),
1459 REVERSE_FOR_VERTICAL(x2
- 1, y
- 1));
1460 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
- 2),
1461 REVERSE_FOR_VERTICAL(x2
- 1, y
- 2));
1463 // and the shadow of the tab to the left of us
1464 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
- 1),
1465 REVERSE_FOR_VERTICAL(x
+ 1, y
- 1));
1471 #endif // wxUSE_NOTEBOOK
1473 // ----------------------------------------------------------------------------
1475 // ----------------------------------------------------------------------------
1479 wxSize
wxGTKRenderer::GetSliderThumbSize(const wxRect
& rect
,
1481 wxOrientation orient
) const
1483 static const wxCoord SLIDER_THUMB_LENGTH
= 30;
1487 wxRect rectShaft
= GetSliderShaftRect(rect
, lenThumb
, orient
);
1488 if ( orient
== wxHORIZONTAL
)
1490 size
.x
= wxMin(SLIDER_THUMB_LENGTH
, rectShaft
.width
);
1491 size
.y
= rectShaft
.height
;
1495 size
.y
= wxMin(SLIDER_THUMB_LENGTH
, rectShaft
.height
);
1496 size
.x
= rectShaft
.width
;
1502 wxRect
wxGTKRenderer::GetSliderShaftRect(const wxRect
& rect
,
1503 int WXUNUSED(lenThumb
),
1504 wxOrientation
WXUNUSED(orient
),
1505 long WXUNUSED(style
)) const
1507 return rect
.Deflate(2*BORDER_THICKNESS
, 2*BORDER_THICKNESS
);
1510 void wxGTKRenderer::DrawSliderShaft(wxDC
& dc
,
1511 const wxRect
& rectOrig
,
1512 int WXUNUSED(lenThumb
),
1513 wxOrientation
WXUNUSED(orient
),
1515 long WXUNUSED(style
),
1518 wxRect rect
= rectOrig
;
1520 // draw the border first
1521 if ( flags
& wxCONTROL_FOCUSED
)
1523 DrawRect(dc
, &rect
, m_penBlack
);
1525 else // not focused, normal
1527 DrawAntiShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
1530 DrawAntiShadedRect(dc
, &rect
, m_penBlack
, m_penLightGrey
);
1532 // and the background
1533 DrawSolidRect(dc
, wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
), rect
);
1539 void wxGTKRenderer::DrawSliderThumb(wxDC
& dc
,
1540 const wxRect
& rectOrig
,
1541 wxOrientation orient
,
1542 int WXUNUSED(flags
),
1543 long WXUNUSED(style
))
1545 // draw the thumb border
1546 wxRect rect
= rectOrig
;
1547 DrawAntiRaisedBorder(dc
, &rect
);
1549 // draw the handle in the middle
1550 if ( orient
== wxVERTICAL
)
1552 rect
.height
= 2*BORDER_THICKNESS
;
1553 rect
.y
= rectOrig
.y
+ (rectOrig
.height
- rect
.height
) / 2;
1557 rect
.width
= 2*BORDER_THICKNESS
;
1558 rect
.x
= rectOrig
.x
+ (rectOrig
.width
- rect
.width
) / 2;
1561 DrawShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
1564 #endif // wxUSE_SLIDER
1568 // ----------------------------------------------------------------------------
1570 // ----------------------------------------------------------------------------
1572 // wxGTKMenuGeometryInfo: the wxMenuGeometryInfo used by wxGTKRenderer
1573 class wxGTKMenuGeometryInfo
: public wxMenuGeometryInfo
1576 virtual wxSize
GetSize() const { return m_size
; }
1578 wxCoord
GetLabelOffset() const { return m_ofsLabel
; }
1579 wxCoord
GetAccelOffset() const { return m_ofsAccel
; }
1581 wxCoord
GetItemHeight() const { return m_heightItem
; }
1584 // the total size of the menu
1587 // the offset of the start of the menu item label
1590 // the offset of the start of the accel label
1593 // the height of a normal (not separator) item
1594 wxCoord m_heightItem
;
1596 friend wxMenuGeometryInfo
*
1597 wxGTKRenderer::GetMenuGeometry(wxWindow
*, const wxMenu
&) const;
1600 // FIXME: all constants are hardcoded but shouldn't be
1601 static const wxCoord MENU_LEFT_MARGIN
= 9;
1602 static const wxCoord MENU_RIGHT_MARGIN
= 6;
1604 static const wxCoord MENU_HORZ_MARGIN
= 6;
1605 static const wxCoord MENU_VERT_MARGIN
= 3;
1607 // the margin around bitmap/check marks (on each side)
1608 static const wxCoord MENU_BMP_MARGIN
= 2;
1610 // the margin between the labels and accel strings
1611 static const wxCoord MENU_ACCEL_MARGIN
= 8;
1613 // the separator height in pixels: in fact, strangely enough, the real height
1614 // is 2 but Windows adds one extra pixel in the bottom margin, so take it into
1616 static const wxCoord MENU_SEPARATOR_HEIGHT
= 3;
1618 // the size of the standard checkmark bitmap
1619 static const wxCoord MENU_CHECK_SIZE
= 9;
1621 void wxGTKRenderer::DrawMenuBarItem(wxDC
& dc
,
1623 const wxString
& label
,
1627 DoDrawMenuItem(dc
, rect
, label
, flags
, indexAccel
);
1630 void wxGTKRenderer::DrawMenuItem(wxDC
& dc
,
1632 const wxMenuGeometryInfo
& gi
,
1633 const wxString
& label
,
1634 const wxString
& accel
,
1635 const wxBitmap
& bitmap
,
1639 const wxGTKMenuGeometryInfo
& geomInfo
= (const wxGTKMenuGeometryInfo
&)gi
;
1644 rect
.width
= geomInfo
.GetSize().x
;
1645 rect
.height
= geomInfo
.GetItemHeight();
1647 DoDrawMenuItem(dc
, rect
, label
, flags
, indexAccel
, accel
, bitmap
, &geomInfo
);
1650 void wxGTKRenderer::DoDrawMenuItem(wxDC
& dc
,
1651 const wxRect
& rectOrig
,
1652 const wxString
& label
,
1655 const wxString
& accel
,
1656 const wxBitmap
& bitmap
,
1657 const wxGTKMenuGeometryInfo
*geometryInfo
)
1659 wxRect rect
= rectOrig
;
1661 // draw the selected item specially
1662 if ( flags
& wxCONTROL_SELECTED
)
1665 DrawBorder(dc
, wxBORDER_RAISED
, rect
, flags
, &rectIn
);
1667 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL_CURRENT
), rectIn
);
1670 rect
.Deflate(MENU_HORZ_MARGIN
, MENU_VERT_MARGIN
);
1672 // draw the bitmap: use the bitmap provided or the standard checkmark for
1673 // the checkable items
1676 wxBitmap bmp
= bitmap
;
1677 if ( !bmp
.IsOk() && (flags
& wxCONTROL_CHECKABLE
) )
1679 bmp
= GetCheckBitmap(flags
);
1684 rect
.SetRight(geometryInfo
->GetLabelOffset());
1685 wxControlRenderer::DrawBitmap(dc
, bmp
, rect
);
1688 //else: menubar items don't have bitmaps
1693 rect
.x
= geometryInfo
->GetLabelOffset();
1694 rect
.SetRight(geometryInfo
->GetAccelOffset());
1697 DrawLabel(dc
, label
, rect
, flags
, wxALIGN_CENTRE_VERTICAL
, indexAccel
);
1699 // draw the accel string
1700 if ( !accel
.empty() )
1702 // menubar items shouldn't have them
1703 wxCHECK_RET( geometryInfo
, wxT("accel strings only valid for menus") );
1705 rect
.x
= geometryInfo
->GetAccelOffset();
1706 rect
.SetRight(geometryInfo
->GetSize().x
);
1708 // NB: no accel index here
1709 DrawLabel(dc
, accel
, rect
, flags
, wxALIGN_CENTRE_VERTICAL
);
1712 // draw the submenu indicator
1713 if ( flags
& wxCONTROL_ISSUBMENU
)
1715 wxCHECK_RET( geometryInfo
, wxT("wxCONTROL_ISSUBMENU only valid for menus") );
1717 rect
.x
= geometryInfo
->GetSize().x
- MENU_RIGHT_MARGIN
;
1718 rect
.width
= MENU_RIGHT_MARGIN
;
1720 DrawArrow(dc
, wxRIGHT
, rect
, flags
);
1724 void wxGTKRenderer::DrawMenuSeparator(wxDC
& dc
,
1726 const wxMenuGeometryInfo
& geomInfo
)
1728 DrawHorizontalLine(dc
, y
+ MENU_VERT_MARGIN
, 0, geomInfo
.GetSize().x
);
1731 wxSize
wxGTKRenderer::GetMenuBarItemSize(const wxSize
& sizeText
) const
1733 wxSize size
= sizeText
;
1735 // TODO: make this configurable
1736 size
.x
+= 2*MENU_HORZ_MARGIN
;
1737 size
.y
+= 2*MENU_VERT_MARGIN
;
1742 wxMenuGeometryInfo
*wxGTKRenderer::GetMenuGeometry(wxWindow
*win
,
1743 const wxMenu
& menu
) const
1745 // prepare the dc: for now we draw all the items with the system font
1747 dc
.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
1749 // the height of a normal item
1750 wxCoord heightText
= dc
.GetCharHeight();
1755 // the max length of label and accel strings: the menu width is the sum of
1756 // them, even if they're for different items (as the accels should be
1759 // the max length of the bitmap is never 0 as Windows always leaves enough
1760 // space for a check mark indicator
1761 wxCoord widthLabelMax
= 0,
1763 widthBmpMax
= MENU_LEFT_MARGIN
;
1765 for ( wxMenuItemList::compatibility_iterator node
= menu
.GetMenuItems().GetFirst();
1767 node
= node
->GetNext() )
1769 // height of this item
1772 wxMenuItem
*item
= node
->GetData();
1773 if ( item
->IsSeparator() )
1775 h
= MENU_SEPARATOR_HEIGHT
;
1777 else // not separator
1782 dc
.GetTextExtent(item
->GetItemLabelText(), &widthLabel
, NULL
);
1783 if ( widthLabel
> widthLabelMax
)
1785 widthLabelMax
= widthLabel
;
1789 dc
.GetTextExtent(item
->GetAccelString(), &widthAccel
, NULL
);
1790 if ( widthAccel
> widthAccelMax
)
1792 widthAccelMax
= widthAccel
;
1795 const wxBitmap
& bmp
= item
->GetBitmap();
1798 wxCoord widthBmp
= bmp
.GetWidth();
1799 if ( widthBmp
> widthBmpMax
)
1800 widthBmpMax
= widthBmp
;
1802 //else if ( item->IsCheckable() ): no need to check for this as
1803 // MENU_LEFT_MARGIN is big enough to show the check mark
1806 h
+= 2*MENU_VERT_MARGIN
;
1808 // remember the item position and height
1809 item
->SetGeometry(height
, h
);
1814 // bundle the metrics into a struct and return it
1815 wxGTKMenuGeometryInfo
*gi
= new wxGTKMenuGeometryInfo
;
1817 gi
->m_ofsLabel
= widthBmpMax
+ 2*MENU_BMP_MARGIN
;
1818 gi
->m_ofsAccel
= gi
->m_ofsLabel
+ widthLabelMax
;
1819 if ( widthAccelMax
> 0 )
1821 // if we actually have any accesl, add a margin
1822 gi
->m_ofsAccel
+= MENU_ACCEL_MARGIN
;
1825 gi
->m_heightItem
= heightText
+ 2*MENU_VERT_MARGIN
;
1827 gi
->m_size
.x
= gi
->m_ofsAccel
+ widthAccelMax
+ MENU_RIGHT_MARGIN
;
1828 gi
->m_size
.y
= height
;
1833 #endif // wxUSE_MENUS
1835 // ----------------------------------------------------------------------------
1837 // ----------------------------------------------------------------------------
1839 void wxGTKRenderer::InitComboBitmaps()
1841 wxSize sizeArrow
= m_sizeScrollbarArrow
;
1847 for ( n
= ComboState_Normal
; n
< ComboState_Max
; n
++ )
1849 m_bitmapsCombo
[n
].Create(sizeArrow
.x
, sizeArrow
.y
);
1852 static const int comboButtonFlags
[ComboState_Max
] =
1860 wxRect
rect(sizeArrow
);
1863 for ( n
= ComboState_Normal
; n
< ComboState_Max
; n
++ )
1865 int flags
= comboButtonFlags
[n
];
1867 dc
.SelectObject(m_bitmapsCombo
[n
]);
1868 DrawSolidRect(dc
, GetBackgroundColour(flags
), rect
);
1869 DrawArrow(dc
, wxDOWN
, rect
, flags
);
1873 void wxGTKRenderer::GetComboBitmaps(wxBitmap
*bmpNormal
,
1875 wxBitmap
*bmpPressed
,
1876 wxBitmap
*bmpDisabled
)
1878 if ( !m_bitmapsCombo
[ComboState_Normal
].IsOk() )
1884 *bmpNormal
= m_bitmapsCombo
[ComboState_Normal
];
1886 *bmpFocus
= m_bitmapsCombo
[ComboState_Focus
];
1888 *bmpPressed
= m_bitmapsCombo
[ComboState_Pressed
];
1890 *bmpDisabled
= m_bitmapsCombo
[ComboState_Disabled
];
1893 // ----------------------------------------------------------------------------
1895 // ----------------------------------------------------------------------------
1897 void wxGTKRenderer::DrawArrowBorder(wxDC
& dc
,
1901 static const wxDirection sides
[] =
1903 wxUP
, wxLEFT
, wxRIGHT
, wxDOWN
1906 wxRect rect1
, rect2
, rectInner
;
1912 rectInner
.Inflate(-2);
1914 DrawSolidRect(dc
, wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
), *rect
);
1916 // find the side not to draw and also adjust the rectangles to compensate
1918 wxDirection sideToOmit
;
1922 sideToOmit
= wxDOWN
;
1924 rectInner
.height
+= 1;
1932 rectInner
.height
+= 1;
1936 sideToOmit
= wxRIGHT
;
1938 rectInner
.width
+= 1;
1942 sideToOmit
= wxLEFT
;
1946 rectInner
.width
+= 1;
1950 wxFAIL_MSG(wxT("unknown arrow direction"));
1954 // the outer rect first
1956 for ( n
= 0; n
< WXSIZEOF(sides
); n
++ )
1958 wxDirection side
= sides
[n
];
1959 if ( side
== sideToOmit
)
1962 DrawAntiShadedRectSide(dc
, rect1
, m_penDarkGrey
, m_penHighlight
, side
);
1965 // and then the inner one
1966 for ( n
= 0; n
< WXSIZEOF(sides
); n
++ )
1968 wxDirection side
= sides
[n
];
1969 if ( side
== sideToOmit
)
1972 DrawAntiShadedRectSide(dc
, rect2
, m_penBlack
, m_penGrey
, side
);
1978 void wxGTKRenderer::DrawScrollbarArrow(wxDC
& dc
,
1980 const wxRect
& rectArrow
,
1983 // first of all, draw the border around it - but we don't want the border
1984 // on the side opposite to the arrow point
1985 wxRect rect
= rectArrow
;
1986 DrawArrowBorder(dc
, &rect
, dir
);
1988 // then the arrow itself
1989 DrawArrow(dc
, dir
, rect
, flags
);
1992 // gtk_default_draw_arrow() takes ~350 lines and we can't do much better here
1993 // these people are just crazy :-(
1994 void wxGTKRenderer::DrawArrow(wxDC
& dc
,
2007 wxPoint ptArrow
[Point_Max
];
2009 wxColour colInside
= GetBackgroundColour(flags
);
2011 if ( flags
& wxCONTROL_DISABLED
)
2013 penShadow
[0] = m_penDarkGrey
;
2014 penShadow
[1] = m_penDarkGrey
;
2015 penShadow
[2] = wxNullPen
;
2016 penShadow
[3] = wxNullPen
;
2018 else if ( flags
& wxCONTROL_PRESSED
)
2020 penShadow
[0] = m_penDarkGrey
;
2021 penShadow
[1] = m_penHighlight
;
2022 penShadow
[2] = wxNullPen
;
2023 penShadow
[3] = m_penBlack
;
2025 else // normal arrow
2027 penShadow
[0] = m_penHighlight
;
2028 penShadow
[1] = m_penBlack
;
2029 penShadow
[2] = m_penDarkGrey
;
2030 penShadow
[3] = wxNullPen
;
2034 if ( dir
== wxUP
|| dir
== wxDOWN
)
2037 middle
= (rect
.GetRight() + rect
.GetLeft() + 1) / 2;
2041 middle
= (rect
.GetTop() + rect
.GetBottom() + 1) / 2;
2044 // draw the arrow interior
2045 dc
.SetPen(*wxTRANSPARENT_PEN
);
2046 dc
.SetBrush(colInside
);
2051 ptArrow
[Point_First
].x
= rect
.GetLeft();
2052 ptArrow
[Point_First
].y
= rect
.GetBottom();
2053 ptArrow
[Point_Second
].x
= middle
;
2054 ptArrow
[Point_Second
].y
= rect
.GetTop();
2055 ptArrow
[Point_Third
].x
= rect
.GetRight();
2056 ptArrow
[Point_Third
].y
= rect
.GetBottom();
2060 ptArrow
[Point_First
] = rect
.GetPosition();
2061 ptArrow
[Point_Second
].x
= middle
;
2062 ptArrow
[Point_Second
].y
= rect
.GetBottom();
2063 ptArrow
[Point_Third
].x
= rect
.GetRight();
2064 ptArrow
[Point_Third
].y
= rect
.GetTop();
2068 ptArrow
[Point_First
].x
= rect
.GetRight();
2069 ptArrow
[Point_First
].y
= rect
.GetTop();
2070 ptArrow
[Point_Second
].x
= rect
.GetLeft();
2071 ptArrow
[Point_Second
].y
= middle
;
2072 ptArrow
[Point_Third
].x
= rect
.GetRight();
2073 ptArrow
[Point_Third
].y
= rect
.GetBottom();
2077 ptArrow
[Point_First
] = rect
.GetPosition();
2078 ptArrow
[Point_Second
].x
= rect
.GetRight();
2079 ptArrow
[Point_Second
].y
= middle
;
2080 ptArrow
[Point_Third
].x
= rect
.GetLeft();
2081 ptArrow
[Point_Third
].y
= rect
.GetBottom();
2085 wxFAIL_MSG(wxT("unknown arrow direction"));
2088 dc
.DrawPolygon(WXSIZEOF(ptArrow
), ptArrow
);
2090 // draw the arrow border
2091 dc
.SetPen(penShadow
[0]);
2095 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_First
]);
2096 dc
.DrawPoint(ptArrow
[Point_First
]);
2097 if ( penShadow
[3].IsOk() )
2099 dc
.SetPen(penShadow
[3]);
2100 dc
.DrawLine(ptArrow
[Point_First
].x
+ 1, ptArrow
[Point_First
].y
,
2101 ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
);
2103 dc
.SetPen(penShadow
[1]);
2104 dc
.DrawLine(ptArrow
[Point_Second
].x
+ 1, ptArrow
[Point_Second
].y
+ 1,
2105 ptArrow
[Point_Third
].x
, ptArrow
[Point_Third
].y
);
2106 dc
.DrawPoint(ptArrow
[Point_Third
]);
2107 dc
.DrawLine(ptArrow
[Point_Third
].x
- 2, ptArrow
[Point_Third
].y
,
2108 ptArrow
[Point_First
].x
+ 1, ptArrow
[Point_First
].y
);
2109 if ( penShadow
[2].IsOk() )
2111 dc
.SetPen(penShadow
[2]);
2112 dc
.DrawLine(ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
,
2113 ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
+ 1);
2114 dc
.DrawLine(ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
- 1,
2115 ptArrow
[Point_First
].x
+ 2, ptArrow
[Point_First
].y
- 1);
2120 dc
.DrawLine(ptArrow
[Point_First
], ptArrow
[Point_Second
]);
2121 dc
.DrawLine(ptArrow
[Point_First
].x
+ 2, ptArrow
[Point_First
].y
,
2122 ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
);
2123 if ( penShadow
[2].IsOk() )
2125 dc
.SetPen(penShadow
[2]);
2126 dc
.DrawLine(ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
- 1,
2127 ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
- 1);
2129 dc
.SetPen(penShadow
[1]);
2130 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_Third
]);
2131 dc
.DrawPoint(ptArrow
[Point_Third
]);
2135 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_First
]);
2136 dc
.DrawPoint(ptArrow
[Point_First
]);
2137 if ( penShadow
[2].IsOk() )
2139 dc
.SetPen(penShadow
[2]);
2140 dc
.DrawLine(ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
,
2141 ptArrow
[Point_First
].x
- 1, ptArrow
[Point_First
].y
+ 2);
2142 dc
.DrawLine(ptArrow
[Point_Third
].x
, ptArrow
[Point_Third
].y
,
2143 ptArrow
[Point_Second
].x
+ 2, ptArrow
[Point_Second
].y
+ 1);
2145 dc
.SetPen(penShadow
[1]);
2146 dc
.DrawLine(ptArrow
[Point_Third
].x
, ptArrow
[Point_Third
].y
,
2147 ptArrow
[Point_First
].x
, ptArrow
[Point_First
].y
+ 1);
2148 dc
.DrawLine(ptArrow
[Point_Second
].x
+ 1, ptArrow
[Point_Second
].y
+ 1,
2149 ptArrow
[Point_Third
].x
- 1, ptArrow
[Point_Third
].y
);
2153 dc
.DrawLine(ptArrow
[Point_First
], ptArrow
[Point_Third
]);
2154 dc
.DrawLine(ptArrow
[Point_First
].x
+ 2, ptArrow
[Point_First
].y
+ 1,
2155 ptArrow
[Point_Second
].x
, ptArrow
[Point_Second
].y
);
2156 dc
.SetPen(penShadow
[1]);
2157 dc
.DrawLine(ptArrow
[Point_Second
], ptArrow
[Point_Third
]);
2158 dc
.DrawPoint(ptArrow
[Point_Third
]);
2162 wxFAIL_MSG(wxT("unknown arrow direction"));
2167 void wxGTKRenderer::DrawThumbBorder(wxDC
& dc
,
2169 wxOrientation orient
)
2171 if ( orient
== wxVERTICAL
)
2173 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2175 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2177 rect
->Inflate(-1, 0);
2179 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2181 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2183 rect
->Inflate(-1, 0);
2187 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2189 DrawAntiShadedRectSide(dc
, *rect
, m_penDarkGrey
, m_penHighlight
,
2191 rect
->Inflate(0, -1);
2193 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2195 DrawAntiShadedRectSide(dc
, *rect
, m_penBlack
, m_penGrey
,
2197 rect
->Inflate(0, -1);
2201 void wxGTKRenderer::DrawScrollbarThumb(wxDC
& dc
,
2202 wxOrientation orient
,
2206 // the thumb is never pressed never has focus border under GTK and the
2207 // scrollbar background never changes at all
2208 int flagsThumb
= flags
& ~(wxCONTROL_PRESSED
| wxCONTROL_FOCUSED
);
2210 // we don't want the border in the direction of the scrollbar movement
2211 wxRect rectThumb
= rect
;
2212 DrawThumbBorder(dc
, &rectThumb
, orient
);
2214 DrawButtonBorder(dc
, rectThumb
, flagsThumb
, &rectThumb
);
2215 DrawBackground(dc
, wxNullColour
, rectThumb
, flagsThumb
);
2218 void wxGTKRenderer::DrawScrollbarShaft(wxDC
& dc
,
2219 wxOrientation orient
,
2221 int WXUNUSED(flags
))
2223 wxRect rectBar
= rect
;
2224 DrawThumbBorder(dc
, &rectBar
, orient
);
2225 DrawSolidRect(dc
, wxSCHEME_COLOUR(m_scheme
, SCROLLBAR
), rectBar
);
2228 // ----------------------------------------------------------------------------
2230 // ----------------------------------------------------------------------------
2232 void wxGTKRenderer::AdjustSize(wxSize
*size
, const wxWindow
*window
)
2235 if ( wxDynamicCast(window
, wxBitmapButton
) )
2240 #endif // wxUSE_BMPBUTTON
2241 #if wxUSE_BUTTON || wxUSE_TOGGLEBTN
2244 || wxDynamicCast(window
, wxButton
)
2245 # endif // wxUSE_BUTTON
2246 # if wxUSE_TOGGLEBTN
2247 || wxDynamicCast(window
, wxToggleButton
)
2248 # endif // wxUSE_TOGGLEBTN
2251 if ( !(window
->GetWindowStyle() & wxBU_EXACTFIT
) )
2253 // TODO: this is ad hoc...
2254 size
->x
+= 3*window
->GetCharWidth();
2255 wxCoord minBtnHeight
= 18;
2256 if ( size
->y
< minBtnHeight
)
2257 size
->y
= minBtnHeight
;
2259 // button border width
2263 #endif // wxUSE_BUTTON || wxUSE_TOGGLEBTN
2265 if ( wxDynamicCast(window
, wxScrollBar
) )
2268 Don't adjust the size for a scrollbar as its DoGetBestClientSize
2269 already has the correct size set. Any size changes here would get
2270 added to the best size, making the scrollbar larger.
2271 Also skip border width adjustments, they don't make sense for us.
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