]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/renderer.cpp
fix a few hundreds of harmless unused parameters warnings and a couple of real bugs...
[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>
65571936 9// License: 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"
cdccdfab
WS
33#endif
34
9c7f49f5
VZ
35#include <gtk/gtk.h>
36#include "wx/gtk/win_gtk.h"
37
9c7f49f5 38// ----------------------------------------------------------------------------
38c4cb6a 39// wxRendererGTK: our wxRendererNative implementation
9c7f49f5
VZ
40// ----------------------------------------------------------------------------
41
38c4cb6a 42class WXDLLEXPORT wxRendererGTK : public wxDelegateRendererNative
9c7f49f5
VZ
43{
44public:
45 // draw the header control button (used by wxListCtrl)
c97c9952 46 virtual int DrawHeaderButton(wxWindow *win,
9c7f49f5
VZ
47 wxDC& dc,
48 const wxRect& rect,
4b94ddc4 49 int flags = 0,
80752b57 50 wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
4b94ddc4 51 wxHeaderButtonParams* params = NULL);
9c7f49f5 52
9c7f49f5
VZ
53 // draw the expanded/collapsed icon for a tree control item
54 virtual void DrawTreeItemButton(wxWindow *win,
55 wxDC& dc,
56 const wxRect& rect,
57 int flags = 0);
9c7f49f5 58
d16cf3cd
VZ
59 virtual void DrawSplitterBorder(wxWindow *win,
60 wxDC& dc,
af99040c
VZ
61 const wxRect& rect,
62 int flags = 0);
95155e75
VZ
63 virtual void DrawSplitterSash(wxWindow *win,
64 wxDC& dc,
65 const wxSize& size,
d16cf3cd 66 wxCoord position,
af99040c
VZ
67 wxOrientation orient,
68 int flags = 0);
d16cf3cd 69
38511687
VZ
70 virtual void DrawComboBoxDropButton(wxWindow *win,
71 wxDC& dc,
72 const wxRect& rect,
73 int flags = 0);
74
4c85ab75
VZ
75 virtual void DrawDropArrow(wxWindow *win,
76 wxDC& dc,
77 const wxRect& rect,
78 int flags = 0);
79
90b903c2
WS
80 virtual void DrawCheckBox(wxWindow *win,
81 wxDC& dc,
82 const wxRect& rect,
83 int flags = 0);
2209baae
RR
84
85 virtual void DrawPushButton(wxWindow *win,
86 wxDC& dc,
87 const wxRect& rect,
88 int flags = 0);
89
daebb44c
RR
90 virtual void DrawItemSelectionRect(wxWindow *win,
91 wxDC& dc,
92 const wxRect& rect,
93 int flags = 0);
90b903c2 94
6d789987
JS
95 virtual void DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, int flags = 0);
96
af99040c 97 virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win);
e1befae3
VZ
98
99private:
bc13e772
VZ
100 // FIXME: shouldn't we destroy these windows somewhere?
101
621ed8af 102 // used by DrawPushButton and DrawDropArrow
bc13e772
VZ
103 static GtkWidget *GetButtonWidget();
104
bc13e772
VZ
105 // used by DrawTreeItemButton()
106 static GtkWidget *GetTreeWidget();
90b903c2
WS
107
108 // used by DrawCheckBox()
862d8041 109 static GtkWidget *GetCheckButtonWidget();
621ed8af
RD
110
111 // Used by DrawHeaderButton
112 static GtkWidget *GetHeaderButtonWidget();
9c7f49f5
VZ
113};
114
115// ============================================================================
116// implementation
117// ============================================================================
118
119/* static */
f0244295 120wxRendererNative& wxRendererNative::GetDefault()
9c7f49f5
VZ
121{
122 static wxRendererGTK s_rendererGTK;
123
124 return s_rendererGTK;
125}
126
a4622f29 127// ----------------------------------------------------------------------------
bc13e772 128// helper functions
a4622f29
VZ
129// ----------------------------------------------------------------------------
130
bc13e772
VZ
131GtkWidget *
132wxRendererGTK::GetButtonWidget()
133{
134 static GtkWidget *s_button = NULL;
135 static GtkWidget *s_window = NULL;
a4622f29 136
bc13e772
VZ
137 if ( !s_button )
138 {
139 s_window = gtk_window_new( GTK_WINDOW_POPUP );
140 gtk_widget_realize( s_window );
141 s_button = gtk_button_new();
142 gtk_container_add( GTK_CONTAINER(s_window), s_button );
143 gtk_widget_realize( s_button );
144 }
145
146 return s_button;
147}
148
862d8041
RR
149GtkWidget *
150wxRendererGTK::GetCheckButtonWidget()
151{
152 static GtkWidget *s_button = NULL;
153 static GtkWidget *s_window = NULL;
154
155 if ( !s_button )
156 {
157 s_window = gtk_window_new( GTK_WINDOW_POPUP );
158 gtk_widget_realize( s_window );
159 s_button = gtk_check_button_new();
160 gtk_container_add( GTK_CONTAINER(s_window), s_button );
161 gtk_widget_realize( s_button );
162 }
163
164 return s_button;
165}
166
bc13e772
VZ
167GtkWidget *
168wxRendererGTK::GetTreeWidget()
a4622f29 169{
bc13e772
VZ
170 static GtkWidget *s_tree = NULL;
171 static GtkWidget *s_window = NULL;
172
173 if ( !s_tree )
174 {
175 s_tree = gtk_tree_view_new();
176 s_window = gtk_window_new( GTK_WINDOW_POPUP );
177 gtk_widget_realize( s_window );
178 gtk_container_add( GTK_CONTAINER(s_window), s_tree );
179 gtk_widget_realize( s_tree );
180 }
181
182 return s_tree;
a4622f29
VZ
183}
184
621ed8af 185
c7a757aa
RD
186// This one just gets the button used by the column header. Although it's
187// still a gtk_button the themes will typically differentiate and draw them
188// differently if the button is in a treeview.
621ed8af
RD
189GtkWidget *
190wxRendererGTK::GetHeaderButtonWidget()
191{
192 static GtkWidget *s_button = NULL;
6d789987 193
621ed8af
RD
194 if ( !s_button )
195 {
c7a757aa
RD
196 // Get the dummy tree widget, give it a column, and then use the
197 // widget in the column header for the rendering code.
621ed8af 198 GtkWidget* treewidget = GetTreeWidget();
c7a757aa
RD
199 GtkTreeViewColumn* column = gtk_tree_view_column_new();
200 gtk_tree_view_append_column(GTK_TREE_VIEW(treewidget), column);
201 s_button = column->button;
621ed8af
RD
202 }
203
204 return s_button;
205}
206
d16cf3cd
VZ
207// ----------------------------------------------------------------------------
208// list/tree controls drawing
209// ----------------------------------------------------------------------------
210
c97c9952 211int
9c7f49f5
VZ
212wxRendererGTK::DrawHeaderButton(wxWindow *win,
213 wxDC& dc,
214 const wxRect& rect,
4b94ddc4 215 int flags,
80752b57 216 wxHeaderSortIconType sortArrow,
4b94ddc4 217 wxHeaderButtonParams* params)
9c7f49f5 218{
9b311923 219
621ed8af 220 GtkWidget *button = GetHeaderButtonWidget();
ab171e95
RR
221
222 GdkWindow* gdk_window = NULL;
223#if wxUSE_NEW_DC
224 wxImplDC *impl = dc.GetImpl();
225 wxGTKImplDC *gtk_impl = wxDynamicCast( impl, wxGTKImplDC );
226 if (gtk_impl)
227 gdk_window = gtk_impl->GetGDKWindow();
228#else
229 gdk_window = dc.GetGDKWindow();
230#endif
2e992e06
VZ
231 wxASSERT_MSG( gdk_window,
232 wxT("cannot use wxRendererNative on wxDC of this type") );
233
5eefe029
RR
234 int x_diff = 0;
235 if (win->GetLayoutDirection() == wxLayout_RightToLeft)
236 x_diff = rect.width;
f4322df6 237
1cfc4971
RR
238 GtkStateType state = GTK_STATE_NORMAL;
239 if (flags & wxCONTROL_DISABLED)
240 state = GTK_STATE_INSENSITIVE;
241 else
242 {
243 if (flags & wxCONTROL_CURRENT)
244 state = GTK_STATE_PRELIGHT;
245 }
246
9c7f49f5
VZ
247 gtk_paint_box
248 (
bc13e772 249 button->style,
2e992e06 250 gdk_window,
1cfc4971 251 state,
9c7f49f5 252 GTK_SHADOW_OUT,
38511687 253 NULL,
bc13e772 254 button,
9b311923 255 "button",
5eefe029 256 dc.LogicalToDeviceX(rect.x) - x_diff, rect.y, rect.width, rect.height
9c7f49f5 257 );
4b94ddc4 258
c97c9952 259 return DrawHeaderButtonContents(win, dc, rect, flags, sortArrow, params);
9c7f49f5
VZ
260}
261
9c7f49f5 262// draw a ">" or "v" button
9c7f49f5 263void
f8b043e7 264wxRendererGTK::DrawTreeItemButton(wxWindow* win,
9a0b7e33 265 wxDC& dc, const wxRect& rect, int flags)
9c7f49f5 266{
bc13e772 267 GtkWidget *tree = GetTreeWidget();
f8b043e7 268
ab171e95
RR
269 GdkWindow* gdk_window = NULL;
270#if wxUSE_NEW_DC
271 wxImplDC *impl = dc.GetImpl();
272 wxGTKImplDC *gtk_impl = wxDynamicCast( impl, wxGTKImplDC );
273 if (gtk_impl)
274 gdk_window = gtk_impl->GetGDKWindow();
275#else
276 gdk_window = dc.GetGDKWindow();
277#endif
2e992e06
VZ
278 wxASSERT_MSG( gdk_window,
279 wxT("cannot use wxRendererNative on wxDC of this type") );
280
885dd597
RR
281 GtkStateType state;
282 if ( flags & wxCONTROL_CURRENT )
283 state = GTK_STATE_PRELIGHT;
284 else
285 state = GTK_STATE_NORMAL;
91af0895 286
428f4657
RR
287 int x_diff = 0;
288 if (win->GetLayoutDirection() == wxLayout_RightToLeft)
289 x_diff = rect.width;
2e992e06 290
bc13e772
VZ
291 // VZ: I don't know how to get the size of the expander so as to centre it
292 // in the given rectangle, +2/3 below is just what looks good here...
293 gtk_paint_expander
294 (
295 tree->style,
2e992e06 296 gdk_window,
885dd597 297 state,
bc13e772
VZ
298 NULL,
299 tree,
300 "treeview",
11012f47 301 dc.LogicalToDeviceX(rect.x) + 6 - x_diff,
bc13e772
VZ
302 dc.LogicalToDeviceY(rect.y) + 3,
303 flags & wxCONTROL_EXPANDED ? GTK_EXPANDER_EXPANDED
304 : GTK_EXPANDER_COLLAPSED
305 );
9c7f49f5
VZ
306}
307
9c7f49f5 308
d16cf3cd
VZ
309// ----------------------------------------------------------------------------
310// splitter sash drawing
311// ----------------------------------------------------------------------------
312
38418827
RR
313static int GetGtkSplitterFullSize()
314{
38418827
RR
315 static GtkWidget *s_paned = NULL;
316 if (s_paned == NULL)
317 s_paned = gtk_vpaned_new();
318
319 gint handle_size;
320 gtk_widget_style_get (s_paned, "handle_size", &handle_size, NULL);
91af0895 321
38418827 322 return handle_size;
38418827
RR
323}
324
af99040c 325wxSplitterRenderParams
38418827 326wxRendererGTK::GetSplitterParams(const wxWindow *WXUNUSED(win))
d16cf3cd 327{
af99040c
VZ
328 // we don't draw any border, hence 0 for the second field
329 return wxSplitterRenderParams
330 (
38418827 331 GetGtkSplitterFullSize(),
af99040c 332 0,
af99040c 333 true // hot sensitive
af99040c 334 );
d16cf3cd
VZ
335}
336
337void
338wxRendererGTK::DrawSplitterBorder(wxWindow * WXUNUSED(win),
339 wxDC& WXUNUSED(dc),
af99040c
VZ
340 const wxRect& WXUNUSED(rect),
341 int WXUNUSED(flags))
d16cf3cd
VZ
342{
343 // nothing to do
344}
95155e75 345
95155e75
VZ
346void
347wxRendererGTK::DrawSplitterSash(wxWindow *win,
348 wxDC& dc,
349 const wxSize& size,
d16cf3cd 350 wxCoord position,
af99040c 351 wxOrientation orient,
68567a96 352 int flags)
95155e75
VZ
353{
354 if ( !win->m_wxwindow->window )
355 {
0100b858 356 // window not realized yet
95155e75
VZ
357 return;
358 }
91af0895 359
ab171e95
RR
360 GdkWindow* gdk_window = NULL;
361#if wxUSE_NEW_DC
362 wxImplDC *impl = dc.GetImpl();
363 wxGTKImplDC *gtk_impl = wxDynamicCast( impl, wxGTKImplDC );
364 if (gtk_impl)
365 gdk_window = gtk_impl->GetGDKWindow();
366#else
367 gdk_window = dc.GetGDKWindow();
368#endif
2e992e06
VZ
369 wxASSERT_MSG( gdk_window,
370 wxT("cannot use wxRendererNative on wxDC of this type") );
371
38418827 372 wxCoord full_size = GetGtkSplitterFullSize();
95155e75 373
d16cf3cd
VZ
374 // are we drawing vertical or horizontal splitter?
375 const bool isVert = orient == wxVERTICAL;
376
d16cf3cd 377 GdkRectangle rect;
91af0895 378
d16cf3cd
VZ
379 if ( isVert )
380 {
381 rect.x = position;
0100b858 382 rect.y = 0;
38418827 383 rect.width = full_size;
e4161a2a 384 rect.height = size.y;
d16cf3cd
VZ
385 }
386 else // horz
387 {
0100b858 388 rect.x = 0;
d16cf3cd 389 rect.y = position;
38418827 390 rect.height = full_size;
e4161a2a 391 rect.width = size.x;
d16cf3cd 392 }
f4322df6 393
847dfdb4
RR
394 int x_diff = 0;
395 if (win->GetLayoutDirection() == wxLayout_RightToLeft)
396 x_diff = rect.width;
35468934 397
af99040c
VZ
398 gtk_paint_handle
399 (
400 win->m_wxwindow->style,
2e992e06 401 gdk_window,
af99040c
VZ
402 flags & wxCONTROL_CURRENT ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL,
403 GTK_SHADOW_NONE,
404 NULL /* no clipping */,
405 win->m_wxwindow,
406 "paned",
847dfdb4
RR
407 dc.LogicalToDeviceX(rect.x) - x_diff,
408 dc.LogicalToDeviceY(rect.y),
af99040c
VZ
409 rect.width,
410 rect.height,
38418827 411 isVert ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL
af99040c 412 );
95155e75
VZ
413}
414
4c85ab75 415void
2e992e06 416wxRendererGTK::DrawDropArrow(wxWindow *WXUNUSED(win),
4c85ab75
VZ
417 wxDC& dc,
418 const wxRect& rect,
419 int flags)
38511687 420{
bc13e772 421 GtkWidget *button = GetButtonWidget();
38511687 422
4c85ab75
VZ
423 // If we give GTK_PIZZA(win->m_wxwindow)->bin_window as
424 // a window for gtk_paint_xxx function, then it won't
425 // work for wxMemoryDC. So that is why we assume wxDC
426 // is wxWindowDC (wxClientDC, wxMemoryDC and wxPaintDC
427 // are derived from it) and use its m_window.
ab171e95
RR
428 GdkWindow* gdk_window = NULL;
429#if wxUSE_NEW_DC
430 wxImplDC *impl = dc.GetImpl();
431 wxGTKImplDC *gtk_impl = wxDynamicCast( impl, wxGTKImplDC );
432 if (gtk_impl)
433 gdk_window = gtk_impl->GetGDKWindow();
434#else
435 gdk_window = dc.GetGDKWindow();
436#endif
2e992e06
VZ
437 wxASSERT_MSG( gdk_window,
438 wxT("cannot use wxRendererNative on wxDC of this type") );
a4622f29 439
4c85ab75
VZ
440 // draw arrow so that there is even space horizontally
441 // on both sides
442 int arrowX = rect.width/4 + 1;
443 int arrowWidth = rect.width - (arrowX*2);
444
445 // scale arrow's height accoording to the width
446 int arrowHeight = rect.width/3;
447 int arrowY = (rect.height-arrowHeight)/2 +
448 ((rect.height-arrowHeight) & 1);
449
e1befae3 450 GtkStateType state;
a4622f29 451
3203621a
JS
452 if ( flags & wxCONTROL_PRESSED )
453 state = GTK_STATE_ACTIVE;
a4622f29
VZ
454 else if ( flags & wxCONTROL_DISABLED )
455 state = GTK_STATE_INSENSITIVE;
3203621a
JS
456 else if ( flags & wxCONTROL_CURRENT )
457 state = GTK_STATE_PRELIGHT;
e1befae3
VZ
458 else
459 state = GTK_STATE_NORMAL;
a4622f29 460
a4622f29 461 // draw arrow on button
a4622f29
VZ
462 gtk_paint_arrow
463 (
bc13e772 464 button->style,
2e992e06 465 gdk_window,
a4622f29 466 state,
e1befae3 467 flags & wxCONTROL_PRESSED ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
a4622f29 468 NULL,
bc13e772 469 button,
a4622f29
VZ
470 "arrow",
471 GTK_ARROW_DOWN,
a8ac548e 472 FALSE,
4c85ab75
VZ
473 rect.x + arrowX,
474 rect.y + arrowY,
475 arrowWidth,
476 arrowHeight
a4622f29 477 );
38511687
VZ
478}
479
4c85ab75
VZ
480void
481wxRendererGTK::DrawComboBoxDropButton(wxWindow *win,
482 wxDC& dc,
483 const wxRect& rect,
484 int flags)
485{
2209baae
RR
486 DrawPushButton(win,dc,rect,flags);
487 DrawDropArrow(win,dc,rect);
488}
489
cdccdfab 490void
2e992e06 491wxRendererGTK::DrawCheckBox(wxWindow *WXUNUSED(win),
90b903c2
WS
492 wxDC& dc,
493 const wxRect& rect,
494 int flags )
2209baae
RR
495{
496 GtkWidget *button = GetCheckButtonWidget();
ab171e95
RR
497
498 GdkWindow* gdk_window = NULL;
499#if wxUSE_NEW_DC
500 wxImplDC *impl = dc.GetImpl();
501 wxGTKImplDC *gtk_impl = wxDynamicCast( impl, wxGTKImplDC );
502 if (gtk_impl)
503 gdk_window = gtk_impl->GetGDKWindow();
504#else
505 gdk_window = dc.GetGDKWindow();
506#endif
2e992e06
VZ
507 wxASSERT_MSG( gdk_window,
508 wxT("cannot use wxRendererNative on wxDC of this type") );
90b903c2 509
4c85ab75
VZ
510 GtkStateType state;
511
3203621a
JS
512 if ( flags & wxCONTROL_PRESSED )
513 state = GTK_STATE_ACTIVE;
4c85ab75
VZ
514 else if ( flags & wxCONTROL_DISABLED )
515 state = GTK_STATE_INSENSITIVE;
3203621a
JS
516 else if ( flags & wxCONTROL_CURRENT )
517 state = GTK_STATE_PRELIGHT;
4c85ab75
VZ
518 else
519 state = GTK_STATE_NORMAL;
90b903c2 520
2209baae 521 gtk_paint_check
4c85ab75
VZ
522 (
523 button->style,
2e992e06 524 gdk_window,
4c85ab75 525 state,
2209baae 526 flags & wxCONTROL_CHECKED ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
4c85ab75
VZ
527 NULL,
528 button,
2209baae 529 "cellcheck",
cdccdfab
WS
530 dc.LogicalToDeviceX(rect.x)+2,
531 dc.LogicalToDeviceY(rect.y)+3,
506d54a3 532 13, 13
4c85ab75 533 );
4c85ab75
VZ
534}
535
2209baae 536void
2e992e06 537wxRendererGTK::DrawPushButton(wxWindow *WXUNUSED(win),
2209baae
RR
538 wxDC& dc,
539 const wxRect& rect,
540 int flags)
862d8041 541{
2209baae 542 GtkWidget *button = GetButtonWidget();
862d8041 543
ab171e95
RR
544 GdkWindow* gdk_window = NULL;
545#if wxUSE_NEW_DC
546 wxImplDC *impl = dc.GetImpl();
547 wxGTKImplDC *gtk_impl = wxDynamicCast( impl, wxGTKImplDC );
548 if (gtk_impl)
549 gdk_window = gtk_impl->GetGDKWindow();
550#else
551 gdk_window = dc.GetGDKWindow();
552#endif
2e992e06
VZ
553 wxASSERT_MSG( gdk_window,
554 wxT("cannot use wxRendererNative on wxDC of this type") );
2209baae
RR
555
556 // draw button
862d8041
RR
557 GtkStateType state;
558
559 if ( flags & wxCONTROL_PRESSED )
560 state = GTK_STATE_ACTIVE;
561 else if ( flags & wxCONTROL_DISABLED )
562 state = GTK_STATE_INSENSITIVE;
563 else if ( flags & wxCONTROL_CURRENT )
564 state = GTK_STATE_PRELIGHT;
565 else
566 state = GTK_STATE_NORMAL;
2209baae
RR
567
568 gtk_paint_box
862d8041
RR
569 (
570 button->style,
2e992e06 571 gdk_window,
862d8041 572 state,
2209baae 573 flags & wxCONTROL_PRESSED ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
862d8041
RR
574 NULL,
575 button,
2209baae
RR
576 "button",
577 rect.x, rect.y, rect.width, rect.height
862d8041
RR
578 );
579}
daebb44c 580
cdccdfab 581void
daebb44c 582wxRendererGTK::DrawItemSelectionRect(wxWindow *win,
cdccdfab
WS
583 wxDC& dc,
584 const wxRect& rect,
585 int flags )
daebb44c 586{
ab171e95
RR
587 GdkWindow* gdk_window = NULL;
588#if wxUSE_NEW_DC
589 wxImplDC *impl = dc.GetImpl();
590 wxGTKImplDC *gtk_impl = wxDynamicCast( impl, wxGTKImplDC );
591 if (gtk_impl)
592 gdk_window = gtk_impl->GetGDKWindow();
593#else
594 gdk_window = dc.GetGDKWindow();
595#endif
2e992e06
VZ
596 wxASSERT_MSG( gdk_window,
597 wxT("cannot use wxRendererNative on wxDC of this type") );
598
08f57d21
RR
599 int x_diff = 0;
600 if (win->GetLayoutDirection() == wxLayout_RightToLeft)
601 x_diff = rect.width;
602
daebb44c 603 GtkStateType state;
90b903c2 604 if (flags & wxCONTROL_SELECTED)
daebb44c 605 {
05d97538
RR
606 // the wxCONTROL_FOCUSED state is deduced
607 // directly from the m_wxwindow by GTK+
608 state = GTK_STATE_SELECTED;
daebb44c 609
05d97538 610 gtk_paint_flat_box( win->m_widget->style,
2e992e06 611 gdk_window,
daebb44c
RR
612 state,
613 GTK_SHADOW_NONE,
cdccdfab 614 NULL,
daebb44c 615 win->m_wxwindow,
05d97538 616 "cell_even",
08f57d21 617 dc.LogicalToDeviceX(rect.x) - x_diff,
daebb44c
RR
618 dc.LogicalToDeviceY(rect.y),
619 rect.width,
620 rect.height );
621 }
72be9a3a
VZ
622 else // !wxCONTROL_SELECTED
623 {
624 state = GTK_STATE_NORMAL;
625 }
90b903c2 626
ce0cf2b8 627 if ((flags & wxCONTROL_CURRENT) && (flags & wxCONTROL_FOCUSED))
daebb44c 628 {
f4322df6 629 gtk_paint_focus( win->m_widget->style,
05d97538 630 gdk_window,
72be9a3a 631 state,
05d97538
RR
632 NULL,
633 win->m_wxwindow,
634 "treeview",
635 dc.LogicalToDeviceX(rect.x),
636 dc.LogicalToDeviceY(rect.y),
637 rect.width,
638 rect.height );
daebb44c
RR
639 }
640}
6d789987
JS
641
642void wxRendererGTK::DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, int flags)
643{
ab171e95
RR
644 GdkWindow* gdk_window = NULL;
645#if wxUSE_NEW_DC
646 wxImplDC *impl = dc.GetImpl();
647 wxGTKImplDC *gtk_impl = wxDynamicCast( impl, wxGTKImplDC );
648 if (gtk_impl)
649 gdk_window = gtk_impl->GetGDKWindow();
650#else
651 gdk_window = dc.GetGDKWindow();
652#endif
6d789987
JS
653 wxASSERT_MSG( gdk_window,
654 wxT("cannot use wxRendererNative on wxDC of this type") );
655
656 GtkStateType state;
657 if (flags & wxCONTROL_SELECTED)
658 state = GTK_STATE_SELECTED;
659 else
660 state = GTK_STATE_NORMAL;
661
662 gtk_paint_focus( win->m_widget->style,
663 gdk_window,
664 state,
665 NULL,
666 win->m_wxwindow,
667 NULL,
668 dc.LogicalToDeviceX(rect.x),
669 dc.LogicalToDeviceY(rect.y),
670 rect.width,
671 rect.height );
672}