]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/renderer.cpp
Merge wxBitmapButton and wxButton panels in the xrc sample.
[wxWidgets.git] / src / gtk / renderer.cpp
CommitLineData
9c7f49f5 1///////////////////////////////////////////////////////////////////////////////
90b903c2 2// Name: src/gtk/renderer.cpp
38c4cb6a 3// Purpose: implementation of wxRendererNative for wxGTK
9c7f49f5
VZ
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 20.07.2003
7// RCS-ID: $Id$
8// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
526954c5 9// Licence: wxWindows licence
9c7f49f5
VZ
10///////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
20// for compilers that support precompilation, includes "wx.h".
21#include "wx/wxprec.h"
22
23#ifdef __BORLANDC__
24 #pragma hdrstop
25#endif
26
e1bf3ad3 27#include "wx/renderer.h"
cdccdfab
WS
28
29#ifndef WX_PRECOMP
30 #include "wx/window.h"
ed4b0fdc 31 #include "wx/dcclient.h"
9eddec69 32 #include "wx/settings.h"
f1c09bed 33 #include "wx/module.h"
cdccdfab
WS
34#endif
35
02f07b19 36#include "wx/dcgraph.h"
888dde65 37#include "wx/gtk/dc.h"
e8759560 38#include "wx/gtk/private.h"
888dde65 39
9c7f49f5 40#include <gtk/gtk.h>
9c7f49f5 41
9c7f49f5 42// ----------------------------------------------------------------------------
38c4cb6a 43// wxRendererGTK: our wxRendererNative implementation
9c7f49f5
VZ
44// ----------------------------------------------------------------------------
45
38c4cb6a 46class WXDLLEXPORT wxRendererGTK : public wxDelegateRendererNative
9c7f49f5
VZ
47{
48public:
49 // draw the header control button (used by wxListCtrl)
c97c9952 50 virtual int DrawHeaderButton(wxWindow *win,
9c7f49f5
VZ
51 wxDC& dc,
52 const wxRect& rect,
4b94ddc4 53 int flags = 0,
80752b57 54 wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
4b94ddc4 55 wxHeaderButtonParams* params = NULL);
9c7f49f5 56
6f91f3a3
RR
57 virtual int GetHeaderButtonHeight(wxWindow *win);
58
59
9c7f49f5
VZ
60 // draw the expanded/collapsed icon for a tree control item
61 virtual void DrawTreeItemButton(wxWindow *win,
62 wxDC& dc,
63 const wxRect& rect,
64 int flags = 0);
9c7f49f5 65
d16cf3cd
VZ
66 virtual void DrawSplitterBorder(wxWindow *win,
67 wxDC& dc,
af99040c
VZ
68 const wxRect& rect,
69 int flags = 0);
95155e75
VZ
70 virtual void DrawSplitterSash(wxWindow *win,
71 wxDC& dc,
72 const wxSize& size,
d16cf3cd 73 wxCoord position,
af99040c
VZ
74 wxOrientation orient,
75 int flags = 0);
d16cf3cd 76
38511687
VZ
77 virtual void DrawComboBoxDropButton(wxWindow *win,
78 wxDC& dc,
79 const wxRect& rect,
80 int flags = 0);
81
4c85ab75
VZ
82 virtual void DrawDropArrow(wxWindow *win,
83 wxDC& dc,
84 const wxRect& rect,
85 int flags = 0);
86
90b903c2
WS
87 virtual void DrawCheckBox(wxWindow *win,
88 wxDC& dc,
89 const wxRect& rect,
90 int flags = 0);
2209baae
RR
91
92 virtual void DrawPushButton(wxWindow *win,
93 wxDC& dc,
94 const wxRect& rect,
95 int flags = 0);
96
daebb44c
RR
97 virtual void DrawItemSelectionRect(wxWindow *win,
98 wxDC& dc,
99 const wxRect& rect,
100 int flags = 0);
90b903c2 101
99c4be68
VZ
102 virtual void DrawChoice(wxWindow* win,
103 wxDC& dc,
104 const wxRect& rect,
e4131985
KO
105 int flags=0);
106
99c4be68
VZ
107 virtual void DrawComboBox(wxWindow* win,
108 wxDC& dc,
109 const wxRect& rect,
e4131985
KO
110 int flags=0);
111
99c4be68
VZ
112 virtual void DrawTextCtrl(wxWindow* win,
113 wxDC& dc,
114 const wxRect& rect,
e4131985
KO
115 int flags=0);
116
6e6b532c 117 virtual void DrawRadioBitmap(wxWindow* win,
99c4be68
VZ
118 wxDC& dc,
119 const wxRect& rect,
e4131985
KO
120 int flags=0);
121
6d789987
JS
122 virtual void DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, int flags = 0);
123
191e43fd 124 virtual wxSize GetCheckBoxSize(wxWindow *win);
f1c09bed 125
e8759560 126 virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win);
9c7f49f5
VZ
127};
128
129// ============================================================================
130// implementation
131// ============================================================================
132
133/* static */
f0244295 134wxRendererNative& wxRendererNative::GetDefault()
9c7f49f5
VZ
135{
136 static wxRendererGTK s_rendererGTK;
137
138 return s_rendererGTK;
139}
140
02f07b19 141static GdkWindow* wxGetGdkWindowForDC(wxWindow* win, wxDC& dc)
e4131985
KO
142{
143 GdkWindow* gdk_window = NULL;
99c4be68 144
02f07b19
KO
145#if wxUSE_GRAPHICS_CONTEXT
146 if ( dc.IsKindOf( CLASSINFO(wxGCDC) ) )
d81b2f54 147 gdk_window = win->GTKGetDrawingWindow();
02f07b19
KO
148 else
149#endif
150 {
e4131985 151#if wxUSE_NEW_DC
02f07b19
KO
152 wxDCImpl *impl = dc.GetImpl();
153 wxGTKDCImpl *gtk_impl = wxDynamicCast( impl, wxGTKDCImpl );
154 if (gtk_impl)
155 gdk_window = gtk_impl->GetGDKWindow();
e4131985 156#else
02f07b19 157 gdk_window = dc.GetGDKWindow();
e4131985 158#endif
02f07b19 159 }
b162ccca
FM
160
161#if !wxUSE_GRAPHICS_CONTEXT
162 wxUnusedVar(win);
163#endif
164
e4131985
KO
165 return gdk_window;
166}
167
d16cf3cd
VZ
168// ----------------------------------------------------------------------------
169// list/tree controls drawing
170// ----------------------------------------------------------------------------
171
c97c9952 172int
9c7f49f5
VZ
173wxRendererGTK::DrawHeaderButton(wxWindow *win,
174 wxDC& dc,
175 const wxRect& rect,
4b94ddc4 176 int flags,
80752b57 177 wxHeaderSortIconType sortArrow,
4b94ddc4 178 wxHeaderButtonParams* params)
9c7f49f5 179{
9b311923 180
e8759560 181 GtkWidget *button = wxGTKPrivate::GetHeaderButtonWidget();
09e72468
RR
182 if (flags & wxCONTROL_SPECIAL)
183 button = wxGTKPrivate::GetHeaderButtonWidgetFirst();
6f91f3a3 184 if (flags & wxCONTROL_DIRTY)
b047e876 185 button = wxGTKPrivate::GetHeaderButtonWidgetLast();
f1c09bed 186
02f07b19 187 GdkWindow* gdk_window = wxGetGdkWindowForDC(win, dc);
2e992e06
VZ
188 wxASSERT_MSG( gdk_window,
189 wxT("cannot use wxRendererNative on wxDC of this type") );
190
5eefe029
RR
191 int x_diff = 0;
192 if (win->GetLayoutDirection() == wxLayout_RightToLeft)
193 x_diff = rect.width;
f4322df6 194
1cfc4971
RR
195 GtkStateType state = GTK_STATE_NORMAL;
196 if (flags & wxCONTROL_DISABLED)
197 state = GTK_STATE_INSENSITIVE;
198 else
199 {
200 if (flags & wxCONTROL_CURRENT)
201 state = GTK_STATE_PRELIGHT;
202 }
203
9c7f49f5
VZ
204 gtk_paint_box
205 (
bc13e772 206 button->style,
2e992e06 207 gdk_window,
1cfc4971 208 state,
9c7f49f5 209 GTK_SHADOW_OUT,
38511687 210 NULL,
bc13e772 211 button,
9b311923 212 "button",
5eefe029 213 dc.LogicalToDeviceX(rect.x) - x_diff, rect.y, rect.width, rect.height
9c7f49f5 214 );
99c4be68 215
c97c9952 216 return DrawHeaderButtonContents(win, dc, rect, flags, sortArrow, params);
9c7f49f5
VZ
217}
218
6f91f3a3
RR
219int wxRendererGTK::GetHeaderButtonHeight(wxWindow *WXUNUSED(win))
220{
221 GtkWidget *button = wxGTKPrivate::GetHeaderButtonWidget();
99c4be68 222
6f91f3a3
RR
223 GtkRequisition req;
224 GTK_WIDGET_GET_CLASS(button)->size_request(button, &req);
99c4be68 225
6f91f3a3
RR
226 return req.height;
227}
228
229
9c7f49f5 230// draw a ">" or "v" button
9c7f49f5 231void
f8b043e7 232wxRendererGTK::DrawTreeItemButton(wxWindow* win,
9a0b7e33 233 wxDC& dc, const wxRect& rect, int flags)
9c7f49f5 234{
e8759560 235 GtkWidget *tree = wxGTKPrivate::GetTreeWidget();
f8b043e7 236
02f07b19 237 GdkWindow* gdk_window = wxGetGdkWindowForDC(win, dc);
2e992e06
VZ
238 wxASSERT_MSG( gdk_window,
239 wxT("cannot use wxRendererNative on wxDC of this type") );
240
885dd597
RR
241 GtkStateType state;
242 if ( flags & wxCONTROL_CURRENT )
243 state = GTK_STATE_PRELIGHT;
244 else
245 state = GTK_STATE_NORMAL;
91af0895 246
428f4657
RR
247 int x_diff = 0;
248 if (win->GetLayoutDirection() == wxLayout_RightToLeft)
249 x_diff = rect.width;
2e992e06 250
bc13e772
VZ
251 // VZ: I don't know how to get the size of the expander so as to centre it
252 // in the given rectangle, +2/3 below is just what looks good here...
253 gtk_paint_expander
254 (
255 tree->style,
2e992e06 256 gdk_window,
885dd597 257 state,
bc13e772
VZ
258 NULL,
259 tree,
260 "treeview",
11012f47 261 dc.LogicalToDeviceX(rect.x) + 6 - x_diff,
bc13e772
VZ
262 dc.LogicalToDeviceY(rect.y) + 3,
263 flags & wxCONTROL_EXPANDED ? GTK_EXPANDER_EXPANDED
264 : GTK_EXPANDER_COLLAPSED
265 );
9c7f49f5
VZ
266}
267
9c7f49f5 268
d16cf3cd
VZ
269// ----------------------------------------------------------------------------
270// splitter sash drawing
271// ----------------------------------------------------------------------------
272
f1c09bed 273static int GetGtkSplitterFullSize(GtkWidget* widget)
38418827 274{
38418827 275 gint handle_size;
f1c09bed 276 gtk_widget_style_get(widget, "handle_size", &handle_size, NULL);
91af0895 277
38418827 278 return handle_size;
38418827
RR
279}
280
af99040c 281wxSplitterRenderParams
38418827 282wxRendererGTK::GetSplitterParams(const wxWindow *WXUNUSED(win))
d16cf3cd 283{
af99040c
VZ
284 // we don't draw any border, hence 0 for the second field
285 return wxSplitterRenderParams
286 (
e8759560 287 GetGtkSplitterFullSize(wxGTKPrivate::GetSplitterWidget()),
af99040c 288 0,
af99040c 289 true // hot sensitive
af99040c 290 );
d16cf3cd
VZ
291}
292
293void
294wxRendererGTK::DrawSplitterBorder(wxWindow * WXUNUSED(win),
295 wxDC& WXUNUSED(dc),
af99040c
VZ
296 const wxRect& WXUNUSED(rect),
297 int WXUNUSED(flags))
d16cf3cd
VZ
298{
299 // nothing to do
300}
95155e75 301
95155e75 302void
02f07b19 303wxRendererGTK::DrawSplitterSash(wxWindow* win,
95155e75
VZ
304 wxDC& dc,
305 const wxSize& size,
d16cf3cd 306 wxCoord position,
af99040c 307 wxOrientation orient,
68567a96 308 int flags)
95155e75
VZ
309{
310 if ( !win->m_wxwindow->window )
311 {
0100b858 312 // window not realized yet
95155e75
VZ
313 return;
314 }
91af0895 315
02f07b19 316 GdkWindow* gdk_window = wxGetGdkWindowForDC(win, dc);
2e992e06
VZ
317 wxASSERT_MSG( gdk_window,
318 wxT("cannot use wxRendererNative on wxDC of this type") );
319
e8759560 320 wxCoord full_size = GetGtkSplitterFullSize(wxGTKPrivate::GetSplitterWidget());
95155e75 321
d16cf3cd
VZ
322 // are we drawing vertical or horizontal splitter?
323 const bool isVert = orient == wxVERTICAL;
324
d16cf3cd 325 GdkRectangle rect;
91af0895 326
d16cf3cd
VZ
327 if ( isVert )
328 {
329 rect.x = position;
0100b858 330 rect.y = 0;
38418827 331 rect.width = full_size;
e4161a2a 332 rect.height = size.y;
d16cf3cd
VZ
333 }
334 else // horz
335 {
0100b858 336 rect.x = 0;
d16cf3cd 337 rect.y = position;
38418827 338 rect.height = full_size;
e4161a2a 339 rect.width = size.x;
d16cf3cd 340 }
f4322df6 341
847dfdb4
RR
342 int x_diff = 0;
343 if (win->GetLayoutDirection() == wxLayout_RightToLeft)
344 x_diff = rect.width;
35468934 345
af99040c
VZ
346 gtk_paint_handle
347 (
348 win->m_wxwindow->style,
2e992e06 349 gdk_window,
af99040c
VZ
350 flags & wxCONTROL_CURRENT ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL,
351 GTK_SHADOW_NONE,
352 NULL /* no clipping */,
353 win->m_wxwindow,
354 "paned",
847dfdb4
RR
355 dc.LogicalToDeviceX(rect.x) - x_diff,
356 dc.LogicalToDeviceY(rect.y),
af99040c
VZ
357 rect.width,
358 rect.height,
38418827 359 isVert ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL
af99040c 360 );
95155e75
VZ
361}
362
4c85ab75 363void
02f07b19 364wxRendererGTK::DrawDropArrow(wxWindow* win,
4c85ab75
VZ
365 wxDC& dc,
366 const wxRect& rect,
367 int flags)
38511687 368{
e8759560 369 GtkWidget *button = wxGTKPrivate::GetButtonWidget();
38511687 370
02f07b19 371 // If we give WX_PIZZA(win->m_wxwindow)->bin_window as
4c85ab75
VZ
372 // a window for gtk_paint_xxx function, then it won't
373 // work for wxMemoryDC. So that is why we assume wxDC
374 // is wxWindowDC (wxClientDC, wxMemoryDC and wxPaintDC
375 // are derived from it) and use its m_window.
02f07b19 376 GdkWindow* gdk_window = wxGetGdkWindowForDC(win, dc);
2e992e06
VZ
377 wxASSERT_MSG( gdk_window,
378 wxT("cannot use wxRendererNative on wxDC of this type") );
a4622f29 379
4c85ab75
VZ
380 // draw arrow so that there is even space horizontally
381 // on both sides
382 int arrowX = rect.width/4 + 1;
383 int arrowWidth = rect.width - (arrowX*2);
384
385 // scale arrow's height accoording to the width
386 int arrowHeight = rect.width/3;
387 int arrowY = (rect.height-arrowHeight)/2 +
388 ((rect.height-arrowHeight) & 1);
389
e1befae3 390 GtkStateType state;
a4622f29 391
3203621a
JS
392 if ( flags & wxCONTROL_PRESSED )
393 state = GTK_STATE_ACTIVE;
a4622f29
VZ
394 else if ( flags & wxCONTROL_DISABLED )
395 state = GTK_STATE_INSENSITIVE;
3203621a
JS
396 else if ( flags & wxCONTROL_CURRENT )
397 state = GTK_STATE_PRELIGHT;
e1befae3
VZ
398 else
399 state = GTK_STATE_NORMAL;
a4622f29 400
a4622f29 401 // draw arrow on button
a4622f29
VZ
402 gtk_paint_arrow
403 (
bc13e772 404 button->style,
2e992e06 405 gdk_window,
a4622f29 406 state,
e1befae3 407 flags & wxCONTROL_PRESSED ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
a4622f29 408 NULL,
bc13e772 409 button,
a4622f29
VZ
410 "arrow",
411 GTK_ARROW_DOWN,
a8ac548e 412 FALSE,
4c85ab75
VZ
413 rect.x + arrowX,
414 rect.y + arrowY,
415 arrowWidth,
416 arrowHeight
a4622f29 417 );
38511687
VZ
418}
419
4c85ab75
VZ
420void
421wxRendererGTK::DrawComboBoxDropButton(wxWindow *win,
422 wxDC& dc,
423 const wxRect& rect,
424 int flags)
425{
2209baae
RR
426 DrawPushButton(win,dc,rect,flags);
427 DrawDropArrow(win,dc,rect);
428}
429
e8759560 430wxSize
191e43fd 431wxRendererGTK::GetCheckBoxSize(wxWindow *WXUNUSED(win))
e8759560
VZ
432{
433 gint indicator_size, indicator_spacing;
434 gtk_widget_style_get(wxGTKPrivate::GetCheckButtonWidget(),
435 "indicator_size", &indicator_size,
436 "indicator_spacing", &indicator_spacing,
437 NULL);
438
439 int size = indicator_size + indicator_spacing * 2;
440 return wxSize(size, size);
441}
442
cdccdfab 443void
02f07b19 444wxRendererGTK::DrawCheckBox(wxWindow* win,
90b903c2
WS
445 wxDC& dc,
446 const wxRect& rect,
447 int flags )
2209baae 448{
e8759560 449 GtkWidget *button = wxGTKPrivate::GetCheckButtonWidget();
f1c09bed 450
02f07b19 451 GdkWindow* gdk_window = wxGetGdkWindowForDC(win, dc);
2e992e06
VZ
452 wxASSERT_MSG( gdk_window,
453 wxT("cannot use wxRendererNative on wxDC of this type") );
90b903c2 454
e8759560
VZ
455 gint indicator_size, indicator_spacing;
456 gtk_widget_style_get(button,
457 "indicator_size", &indicator_size,
458 "indicator_spacing", &indicator_spacing,
459 NULL);
460
4c85ab75
VZ
461 GtkStateType state;
462
3203621a
JS
463 if ( flags & wxCONTROL_PRESSED )
464 state = GTK_STATE_ACTIVE;
4c85ab75
VZ
465 else if ( flags & wxCONTROL_DISABLED )
466 state = GTK_STATE_INSENSITIVE;
3203621a
JS
467 else if ( flags & wxCONTROL_CURRENT )
468 state = GTK_STATE_PRELIGHT;
4c85ab75
VZ
469 else
470 state = GTK_STATE_NORMAL;
90b903c2 471
e78778c8
RR
472 GtkShadowType shadow_type;
473
474 if ( flags & wxCONTROL_UNDETERMINED )
475 shadow_type = GTK_SHADOW_ETCHED_IN;
476 else if ( flags & wxCONTROL_CHECKED )
477 shadow_type = GTK_SHADOW_IN;
478 else
479 shadow_type = GTK_SHADOW_OUT;
480
2209baae 481 gtk_paint_check
4c85ab75
VZ
482 (
483 button->style,
2e992e06 484 gdk_window,
4c85ab75 485 state,
e78778c8 486 shadow_type,
4c85ab75
VZ
487 NULL,
488 button,
2209baae 489 "cellcheck",
e8759560
VZ
490 dc.LogicalToDeviceX(rect.x) + indicator_spacing,
491 dc.LogicalToDeviceY(rect.y) + indicator_spacing,
492 indicator_size, indicator_size
4c85ab75 493 );
4c85ab75
VZ
494}
495
2209baae 496void
02f07b19 497wxRendererGTK::DrawPushButton(wxWindow* win,
2209baae
RR
498 wxDC& dc,
499 const wxRect& rect,
500 int flags)
862d8041 501{
e8759560 502 GtkWidget *button = wxGTKPrivate::GetButtonWidget();
862d8041 503
02f07b19 504 GdkWindow* gdk_window = wxGetGdkWindowForDC(win, dc);
2e992e06
VZ
505 wxASSERT_MSG( gdk_window,
506 wxT("cannot use wxRendererNative on wxDC of this type") );
2209baae
RR
507
508 // draw button
862d8041
RR
509 GtkStateType state;
510
511 if ( flags & wxCONTROL_PRESSED )
512 state = GTK_STATE_ACTIVE;
513 else if ( flags & wxCONTROL_DISABLED )
514 state = GTK_STATE_INSENSITIVE;
515 else if ( flags & wxCONTROL_CURRENT )
516 state = GTK_STATE_PRELIGHT;
517 else
518 state = GTK_STATE_NORMAL;
2209baae
RR
519
520 gtk_paint_box
862d8041
RR
521 (
522 button->style,
2e992e06 523 gdk_window,
862d8041 524 state,
2209baae 525 flags & wxCONTROL_PRESSED ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
862d8041
RR
526 NULL,
527 button,
2209baae 528 "button",
99c4be68
VZ
529 dc.LogicalToDeviceX(rect.x),
530 dc.LogicalToDeviceY(rect.y),
531 rect.width,
e4131985 532 rect.height
862d8041
RR
533 );
534}
daebb44c 535
cdccdfab 536void
02f07b19 537wxRendererGTK::DrawItemSelectionRect(wxWindow* win,
cdccdfab
WS
538 wxDC& dc,
539 const wxRect& rect,
540 int flags )
daebb44c 541{
02f07b19 542 GdkWindow* gdk_window = wxGetGdkWindowForDC(win, dc);
2e992e06
VZ
543 wxASSERT_MSG( gdk_window,
544 wxT("cannot use wxRendererNative on wxDC of this type") );
545
90b903c2 546 if (flags & wxCONTROL_SELECTED)
daebb44c 547 {
c70ad287
VZ
548 int x_diff = 0;
549 if (win->GetLayoutDirection() == wxLayout_RightToLeft)
550 x_diff = rect.width;
551
05d97538
RR
552 // the wxCONTROL_FOCUSED state is deduced
553 // directly from the m_wxwindow by GTK+
c70ad287 554 gtk_paint_flat_box(wxGTKPrivate::GetTreeWidget()->style,
2e992e06 555 gdk_window,
c70ad287 556 GTK_STATE_SELECTED,
daebb44c 557 GTK_SHADOW_NONE,
cdccdfab 558 NULL,
daebb44c 559 win->m_wxwindow,
05d97538 560 "cell_even",
08f57d21 561 dc.LogicalToDeviceX(rect.x) - x_diff,
daebb44c
RR
562 dc.LogicalToDeviceY(rect.y),
563 rect.width,
564 rect.height );
565 }
90b903c2 566
ce0cf2b8 567 if ((flags & wxCONTROL_CURRENT) && (flags & wxCONTROL_FOCUSED))
c70ad287 568 DrawFocusRect(win, dc, rect, flags);
daebb44c 569}
6d789987
JS
570
571void wxRendererGTK::DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, int flags)
572{
02f07b19 573 GdkWindow* gdk_window = wxGetGdkWindowForDC(win, dc);
6d789987
JS
574 wxASSERT_MSG( gdk_window,
575 wxT("cannot use wxRendererNative on wxDC of this type") );
576
577 GtkStateType state;
578 if (flags & wxCONTROL_SELECTED)
579 state = GTK_STATE_SELECTED;
580 else
581 state = GTK_STATE_NORMAL;
582
583 gtk_paint_focus( win->m_widget->style,
584 gdk_window,
585 state,
586 NULL,
587 win->m_wxwindow,
588 NULL,
589 dc.LogicalToDeviceX(rect.x),
590 dc.LogicalToDeviceY(rect.y),
591 rect.width,
592 rect.height );
593}
e4131985
KO
594
595// Uses the theme to draw the border and fill for something like a wxTextCtrl
02f07b19 596void wxRendererGTK::DrawTextCtrl(wxWindow* win, wxDC& dc, const wxRect& rect, int flags)
e4131985
KO
597{
598 GtkWidget *entry = wxGTKPrivate::GetTextEntryWidget();
599
02f07b19 600 GdkWindow* gdk_window = wxGetGdkWindowForDC(win, dc);
e4131985
KO
601
602 GtkStateType state = GTK_STATE_NORMAL;
603 if ( flags & wxCONTROL_DISABLED )
604 state = GTK_STATE_INSENSITIVE;
99c4be68 605
e4131985
KO
606 if (flags & wxCONTROL_CURRENT )
607 GTK_WIDGET_SET_FLAGS( entry, GTK_HAS_FOCUS );
608 else
609 GTK_WIDGET_UNSET_FLAGS( entry, GTK_HAS_FOCUS );
610
611 gtk_paint_shadow
612 (
99c4be68 613 entry->style,
e4131985
KO
614 gdk_window,
615 state,
616 GTK_SHADOW_OUT,
617 NULL,
618 entry,
619 "entry",
620 dc.LogicalToDeviceX(rect.x),
621 dc.LogicalToDeviceY(rect.y),
622 rect.width,
99c4be68 623 rect.height
e4131985
KO
624 );
625}
626
627// Draw the equivallent of a wxComboBox
02f07b19 628void wxRendererGTK::DrawComboBox(wxWindow* win, wxDC& dc, const wxRect& rect, int flags)
e4131985
KO
629{
630 GtkWidget *combo = wxGTKPrivate::GetComboBoxWidget();
631
02f07b19 632 GdkWindow* gdk_window = wxGetGdkWindowForDC(win, dc);
e4131985
KO
633
634 GtkStateType state = GTK_STATE_NORMAL;
635 if ( flags & wxCONTROL_DISABLED )
636 state = GTK_STATE_INSENSITIVE;
99c4be68 637
e4131985
KO
638 if (flags & wxCONTROL_CURRENT )
639 GTK_WIDGET_SET_FLAGS( combo, GTK_HAS_FOCUS );
640 else
641 GTK_WIDGET_UNSET_FLAGS( combo, GTK_HAS_FOCUS );
642
643 gtk_paint_shadow
644 (
99c4be68 645 combo->style,
e4131985
KO
646 gdk_window,
647 state,
648 GTK_SHADOW_OUT,
649 NULL,
650 combo,
651 "combobox",
652 dc.LogicalToDeviceX(rect.x),
653 dc.LogicalToDeviceY(rect.y),
654 rect.width,
99c4be68 655 rect.height
e4131985
KO
656 );
657
658 wxRect r = rect;
659 int extent = rect.height / 2;
660 r.x += rect.width - extent - extent/2;
661 r.y += extent/2;
662 r.width = extent;
663 r.height = extent;
664
665 gtk_paint_arrow
666 (
99c4be68 667 combo->style,
e4131985
KO
668 gdk_window,
669 state,
670 GTK_SHADOW_OUT,
671 NULL,
672 combo,
673 "arrow",
674 GTK_ARROW_DOWN,
675 TRUE,
676 dc.LogicalToDeviceX(r.x),
677 dc.LogicalToDeviceY(r.y),
678 r.width,
679 r.height
680 );
681
682 r = rect;
683 r.x += rect.width - 2*extent;
684 r.width = 2;
685
686 gtk_paint_box
687 (
99c4be68 688 combo->style,
e4131985
KO
689 gdk_window,
690 state,
691 GTK_SHADOW_ETCHED_OUT,
692 NULL,
693 combo,
694 "vseparator",
695 dc.LogicalToDeviceX(r.x),
696 dc.LogicalToDeviceY(r.y+1),
697 r.width,
698 r.height-2
699 );
700}
701
702
703void wxRendererGTK::DrawChoice(wxWindow* win, wxDC& dc,
704 const wxRect& rect, int flags)
705{
706 DrawComboBox( win, dc, rect, flags );
707}
708
99c4be68 709
e4131985 710// Draw a themed radio button
6e6b532c 711void wxRendererGTK::DrawRadioBitmap(wxWindow* win, wxDC& dc, const wxRect& rect, int flags)
e4131985
KO
712{
713 GtkWidget *button = wxGTKPrivate::GetRadioButtonWidget();
714
02f07b19 715 GdkWindow* gdk_window = wxGetGdkWindowForDC(win, dc);
99c4be68 716
e4131985
KO
717 GtkShadowType shadow_type = GTK_SHADOW_OUT;
718 if ( flags & wxCONTROL_CHECKED )
719 shadow_type = GTK_SHADOW_IN;
720 else if ( flags & wxCONTROL_UNDETERMINED )
721 shadow_type = GTK_SHADOW_ETCHED_IN;
99c4be68 722
e4131985
KO
723 GtkStateType state = GTK_STATE_NORMAL;
724 if ( flags & wxCONTROL_DISABLED )
7e717730 725 state = GTK_STATE_INSENSITIVE;
e4131985 726 if ( flags & wxCONTROL_PRESSED )
7e717730 727 state = GTK_STATE_ACTIVE;
e4131985
KO
728/*
729 Don't know when to set this
730 state_type = GTK_STATE_PRELIGHT;
731*/
732
733 gtk_paint_option
734 (
735 button->style,
736 gdk_window,
737 state,
738 shadow_type,
739 NULL,
740 button,
741 "radiobutton",
99c4be68
VZ
742 dc.LogicalToDeviceX(rect.x),
743 dc.LogicalToDeviceY(rect.y),
e4131985
KO
744 rect.width, rect.height
745 );
746}