]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/renderer.cpp
define wxUTF8Buf as the type returned by wxString::utf8_str()
[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 {
0100b858 381 int h = win->GetClientSize().GetHeight();
e1befae3 382
d16cf3cd 383 rect.x = position;
0100b858 384 rect.y = 0;
38418827 385 rect.width = full_size;
0100b858 386 rect.height = h;
d16cf3cd
VZ
387 }
388 else // horz
389 {
0100b858 390 int w = win->GetClientSize().GetWidth();
e1befae3 391
0100b858 392 rect.x = 0;
d16cf3cd 393 rect.y = position;
38418827 394 rect.height = full_size;
0100b858 395 rect.width = w;
d16cf3cd 396 }
f4322df6 397
847dfdb4
RR
398 int x_diff = 0;
399 if (win->GetLayoutDirection() == wxLayout_RightToLeft)
400 x_diff = rect.width;
35468934 401
af99040c
VZ
402 gtk_paint_handle
403 (
404 win->m_wxwindow->style,
2e992e06 405 gdk_window,
af99040c
VZ
406 flags & wxCONTROL_CURRENT ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL,
407 GTK_SHADOW_NONE,
408 NULL /* no clipping */,
409 win->m_wxwindow,
410 "paned",
847dfdb4
RR
411 dc.LogicalToDeviceX(rect.x) - x_diff,
412 dc.LogicalToDeviceY(rect.y),
af99040c
VZ
413 rect.width,
414 rect.height,
38418827 415 isVert ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL
af99040c 416 );
95155e75
VZ
417}
418
4c85ab75 419void
2e992e06 420wxRendererGTK::DrawDropArrow(wxWindow *WXUNUSED(win),
4c85ab75
VZ
421 wxDC& dc,
422 const wxRect& rect,
423 int flags)
38511687 424{
bc13e772 425 GtkWidget *button = GetButtonWidget();
38511687 426
4c85ab75
VZ
427 // If we give GTK_PIZZA(win->m_wxwindow)->bin_window as
428 // a window for gtk_paint_xxx function, then it won't
429 // work for wxMemoryDC. So that is why we assume wxDC
430 // is wxWindowDC (wxClientDC, wxMemoryDC and wxPaintDC
431 // are derived from it) and use its m_window.
ab171e95
RR
432 GdkWindow* gdk_window = NULL;
433#if wxUSE_NEW_DC
434 wxImplDC *impl = dc.GetImpl();
435 wxGTKImplDC *gtk_impl = wxDynamicCast( impl, wxGTKImplDC );
436 if (gtk_impl)
437 gdk_window = gtk_impl->GetGDKWindow();
438#else
439 gdk_window = dc.GetGDKWindow();
440#endif
2e992e06
VZ
441 wxASSERT_MSG( gdk_window,
442 wxT("cannot use wxRendererNative on wxDC of this type") );
a4622f29 443
4c85ab75
VZ
444 // draw arrow so that there is even space horizontally
445 // on both sides
446 int arrowX = rect.width/4 + 1;
447 int arrowWidth = rect.width - (arrowX*2);
448
449 // scale arrow's height accoording to the width
450 int arrowHeight = rect.width/3;
451 int arrowY = (rect.height-arrowHeight)/2 +
452 ((rect.height-arrowHeight) & 1);
453
e1befae3 454 GtkStateType state;
a4622f29 455
3203621a
JS
456 if ( flags & wxCONTROL_PRESSED )
457 state = GTK_STATE_ACTIVE;
a4622f29
VZ
458 else if ( flags & wxCONTROL_DISABLED )
459 state = GTK_STATE_INSENSITIVE;
3203621a
JS
460 else if ( flags & wxCONTROL_CURRENT )
461 state = GTK_STATE_PRELIGHT;
e1befae3
VZ
462 else
463 state = GTK_STATE_NORMAL;
a4622f29 464
a4622f29 465 // draw arrow on button
a4622f29
VZ
466 gtk_paint_arrow
467 (
bc13e772 468 button->style,
2e992e06 469 gdk_window,
a4622f29 470 state,
e1befae3 471 flags & wxCONTROL_PRESSED ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
a4622f29 472 NULL,
bc13e772 473 button,
a4622f29
VZ
474 "arrow",
475 GTK_ARROW_DOWN,
a8ac548e 476 FALSE,
4c85ab75
VZ
477 rect.x + arrowX,
478 rect.y + arrowY,
479 arrowWidth,
480 arrowHeight
a4622f29 481 );
38511687
VZ
482}
483
4c85ab75
VZ
484void
485wxRendererGTK::DrawComboBoxDropButton(wxWindow *win,
486 wxDC& dc,
487 const wxRect& rect,
488 int flags)
489{
2209baae
RR
490 DrawPushButton(win,dc,rect,flags);
491 DrawDropArrow(win,dc,rect);
492}
493
cdccdfab 494void
2e992e06 495wxRendererGTK::DrawCheckBox(wxWindow *WXUNUSED(win),
90b903c2
WS
496 wxDC& dc,
497 const wxRect& rect,
498 int flags )
2209baae
RR
499{
500 GtkWidget *button = GetCheckButtonWidget();
ab171e95
RR
501
502 GdkWindow* gdk_window = NULL;
503#if wxUSE_NEW_DC
504 wxImplDC *impl = dc.GetImpl();
505 wxGTKImplDC *gtk_impl = wxDynamicCast( impl, wxGTKImplDC );
506 if (gtk_impl)
507 gdk_window = gtk_impl->GetGDKWindow();
508#else
509 gdk_window = dc.GetGDKWindow();
510#endif
2e992e06
VZ
511 wxASSERT_MSG( gdk_window,
512 wxT("cannot use wxRendererNative on wxDC of this type") );
90b903c2 513
4c85ab75
VZ
514 GtkStateType state;
515
3203621a
JS
516 if ( flags & wxCONTROL_PRESSED )
517 state = GTK_STATE_ACTIVE;
4c85ab75
VZ
518 else if ( flags & wxCONTROL_DISABLED )
519 state = GTK_STATE_INSENSITIVE;
3203621a
JS
520 else if ( flags & wxCONTROL_CURRENT )
521 state = GTK_STATE_PRELIGHT;
4c85ab75
VZ
522 else
523 state = GTK_STATE_NORMAL;
90b903c2 524
2209baae 525 gtk_paint_check
4c85ab75
VZ
526 (
527 button->style,
2e992e06 528 gdk_window,
4c85ab75 529 state,
2209baae 530 flags & wxCONTROL_CHECKED ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
4c85ab75
VZ
531 NULL,
532 button,
2209baae 533 "cellcheck",
cdccdfab
WS
534 dc.LogicalToDeviceX(rect.x)+2,
535 dc.LogicalToDeviceY(rect.y)+3,
506d54a3 536 13, 13
4c85ab75 537 );
4c85ab75
VZ
538}
539
2209baae 540void
2e992e06 541wxRendererGTK::DrawPushButton(wxWindow *WXUNUSED(win),
2209baae
RR
542 wxDC& dc,
543 const wxRect& rect,
544 int flags)
862d8041 545{
2209baae 546 GtkWidget *button = GetButtonWidget();
862d8041 547
ab171e95
RR
548 GdkWindow* gdk_window = NULL;
549#if wxUSE_NEW_DC
550 wxImplDC *impl = dc.GetImpl();
551 wxGTKImplDC *gtk_impl = wxDynamicCast( impl, wxGTKImplDC );
552 if (gtk_impl)
553 gdk_window = gtk_impl->GetGDKWindow();
554#else
555 gdk_window = dc.GetGDKWindow();
556#endif
2e992e06
VZ
557 wxASSERT_MSG( gdk_window,
558 wxT("cannot use wxRendererNative on wxDC of this type") );
2209baae
RR
559
560 // draw button
862d8041
RR
561 GtkStateType state;
562
563 if ( flags & wxCONTROL_PRESSED )
564 state = GTK_STATE_ACTIVE;
565 else if ( flags & wxCONTROL_DISABLED )
566 state = GTK_STATE_INSENSITIVE;
567 else if ( flags & wxCONTROL_CURRENT )
568 state = GTK_STATE_PRELIGHT;
569 else
570 state = GTK_STATE_NORMAL;
2209baae
RR
571
572 gtk_paint_box
862d8041
RR
573 (
574 button->style,
2e992e06 575 gdk_window,
862d8041 576 state,
2209baae 577 flags & wxCONTROL_PRESSED ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
862d8041
RR
578 NULL,
579 button,
2209baae
RR
580 "button",
581 rect.x, rect.y, rect.width, rect.height
862d8041
RR
582 );
583}
daebb44c 584
cdccdfab 585void
daebb44c 586wxRendererGTK::DrawItemSelectionRect(wxWindow *win,
cdccdfab
WS
587 wxDC& dc,
588 const wxRect& rect,
589 int flags )
daebb44c 590{
ab171e95
RR
591 GdkWindow* gdk_window = NULL;
592#if wxUSE_NEW_DC
593 wxImplDC *impl = dc.GetImpl();
594 wxGTKImplDC *gtk_impl = wxDynamicCast( impl, wxGTKImplDC );
595 if (gtk_impl)
596 gdk_window = gtk_impl->GetGDKWindow();
597#else
598 gdk_window = dc.GetGDKWindow();
599#endif
2e992e06
VZ
600 wxASSERT_MSG( gdk_window,
601 wxT("cannot use wxRendererNative on wxDC of this type") );
602
08f57d21
RR
603 int x_diff = 0;
604 if (win->GetLayoutDirection() == wxLayout_RightToLeft)
605 x_diff = rect.width;
606
daebb44c 607 GtkStateType state;
90b903c2 608 if (flags & wxCONTROL_SELECTED)
daebb44c 609 {
05d97538
RR
610 // the wxCONTROL_FOCUSED state is deduced
611 // directly from the m_wxwindow by GTK+
612 state = GTK_STATE_SELECTED;
daebb44c 613
05d97538 614 gtk_paint_flat_box( win->m_widget->style,
2e992e06 615 gdk_window,
daebb44c
RR
616 state,
617 GTK_SHADOW_NONE,
cdccdfab 618 NULL,
daebb44c 619 win->m_wxwindow,
05d97538 620 "cell_even",
08f57d21 621 dc.LogicalToDeviceX(rect.x) - x_diff,
daebb44c
RR
622 dc.LogicalToDeviceY(rect.y),
623 rect.width,
624 rect.height );
625 }
72be9a3a
VZ
626 else // !wxCONTROL_SELECTED
627 {
628 state = GTK_STATE_NORMAL;
629 }
90b903c2 630
ce0cf2b8 631 if ((flags & wxCONTROL_CURRENT) && (flags & wxCONTROL_FOCUSED))
daebb44c 632 {
f4322df6 633 gtk_paint_focus( win->m_widget->style,
05d97538 634 gdk_window,
72be9a3a 635 state,
05d97538
RR
636 NULL,
637 win->m_wxwindow,
638 "treeview",
639 dc.LogicalToDeviceX(rect.x),
640 dc.LogicalToDeviceY(rect.y),
641 rect.width,
642 rect.height );
daebb44c
RR
643 }
644}
6d789987
JS
645
646void wxRendererGTK::DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, int flags)
647{
ab171e95
RR
648 GdkWindow* gdk_window = NULL;
649#if wxUSE_NEW_DC
650 wxImplDC *impl = dc.GetImpl();
651 wxGTKImplDC *gtk_impl = wxDynamicCast( impl, wxGTKImplDC );
652 if (gtk_impl)
653 gdk_window = gtk_impl->GetGDKWindow();
654#else
655 gdk_window = dc.GetGDKWindow();
656#endif
6d789987
JS
657 wxASSERT_MSG( gdk_window,
658 wxT("cannot use wxRendererNative on wxDC of this type") );
659
660 GtkStateType state;
661 if (flags & wxCONTROL_SELECTED)
662 state = GTK_STATE_SELECTED;
663 else
664 state = GTK_STATE_NORMAL;
665
666 gtk_paint_focus( win->m_widget->style,
667 gdk_window,
668 state,
669 NULL,
670 win->m_wxwindow,
671 NULL,
672 dc.LogicalToDeviceX(rect.x),
673 dc.LogicalToDeviceY(rect.y),
674 rect.width,
675 rect.height );
676}