]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/tbargtk.cpp
The usual RTL fix for GTK+'s theme drawing function.
[wxWidgets.git] / src / gtk / tbargtk.cpp
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
76b49cf4 2// Name: src/gtk/tbargtk.cpp
c801d85f
KB
3// Purpose: GTK toolbar
4// Author: Robert Roebling
8a0681f9 5// Modified: 13.12.99 by VZ to derive from wxToolBarBase
32e9da8b 6// RCS-ID: $Id$
c801d85f 7// Copyright: (c) Robert Roebling
65571936 8// Licence: wxWindows licence
c801d85f
KB
9/////////////////////////////////////////////////////////////////////////////
10
8a0681f9
VZ
11// ============================================================================
12// declarations
13// ============================================================================
14
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
14f355c2
VS
19// For compilers that support precompilation, includes "wx.h".
20#include "wx/wxprec.h"
21
8a0681f9 22#if wxUSE_TOOLBAR_NATIVE
dcf924a3 23
4e3e485b
WS
24#include "wx/toolbar.h"
25
76b49cf4
WS
26#ifndef WX_PRECOMP
27 #include "wx/frame.h"
28#endif
c801d85f 29
1efb5db8
MR
30// FIXME: Use GtkImage instead of GtkPixmap. Use the new toolbar API for when gtk runtime is new enough?
31// Beware that the new and old toolbar API may not be mixed in usage.
32#include <gtk/gtkversion.h>
33#ifdef GTK_DISABLE_DEPRECATED
34#undef GTK_DISABLE_DEPRECATED
35#endif
36
9e691f46 37#include "wx/gtk/private.h"
83624f79 38
8a0681f9
VZ
39// ----------------------------------------------------------------------------
40// globals
41// ----------------------------------------------------------------------------
acfd422a 42
314055fa 43// data
9b7e522a
RR
44extern bool g_blockEventsOnDrag;
45extern wxCursor g_globalCursor;
314055fa 46
e76c0b5f
VZ
47// ----------------------------------------------------------------------------
48// private functions
49// ----------------------------------------------------------------------------
50
77ffb593 51// translate wxWidgets toolbar style flags to GTK orientation and style
e76c0b5f
VZ
52static void GetGtkStyle(long style,
53 GtkOrientation *orient, GtkToolbarStyle *gtkStyle)
54{
7a976304 55 *orient = ( style & wxTB_LEFT || style & wxTB_RIGHT ) ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL;
e76c0b5f
VZ
56
57
58 if ( style & wxTB_TEXT )
59 {
99e8cb50
VZ
60 *gtkStyle = style & wxTB_NOICONS
61 ? GTK_TOOLBAR_TEXT
62 : (
99e8cb50 63 style & wxTB_HORZ_LAYOUT ? GTK_TOOLBAR_BOTH_HORIZ :
99e8cb50 64 GTK_TOOLBAR_BOTH);
e76c0b5f
VZ
65 }
66 else // no text, hence we must have the icons or what would we show?
67 {
68 *gtkStyle = GTK_TOOLBAR_ICONS;
69 }
70}
71
8a0681f9
VZ
72// ----------------------------------------------------------------------------
73// wxToolBarTool
74// ----------------------------------------------------------------------------
75
76class wxToolBarTool : public wxToolBarToolBase
77{
78public:
79 wxToolBarTool(wxToolBar *tbar,
80 int id,
e76c0b5f 81 const wxString& label,
8a0681f9
VZ
82 const wxBitmap& bitmap1,
83 const wxBitmap& bitmap2,
e76c0b5f 84 wxItemKind kind,
8a0681f9
VZ
85 wxObject *clientData,
86 const wxString& shortHelpString,
87 const wxString& longHelpString)
e76c0b5f 88 : wxToolBarToolBase(tbar, id, label, bitmap1, bitmap2, kind,
8a0681f9
VZ
89 clientData, shortHelpString, longHelpString)
90 {
91 Init();
92 }
93
94 wxToolBarTool(wxToolBar *tbar, wxControl *control)
95 : wxToolBarToolBase(tbar, control)
96 {
97 Init();
98 }
99
38762f09
VZ
100 // is this a radio button?
101 //
102 // unlike GetKind(), can be called for any kind of tools, not just buttons
103 bool IsRadio() const { return IsButton() && GetKind() == wxITEM_RADIO; }
104
e76c0b5f
VZ
105 // this is only called for the normal buttons, i.e. not separators nor
106 // controls
107 GtkToolbarChildType GetGtkChildType() const
108 {
109 switch ( GetKind() )
110 {
111 case wxITEM_CHECK:
112 return GTK_TOOLBAR_CHILD_TOGGLEBUTTON;
113
114 case wxITEM_RADIO:
115 return GTK_TOOLBAR_CHILD_RADIOBUTTON;
116
117 default:
118 wxFAIL_MSG( _T("unknown toolbar child type") );
119 // fall through
120
121 case wxITEM_NORMAL:
122 return GTK_TOOLBAR_CHILD_BUTTON;
123 }
124 }
125
eba91e51 126 void SetImage(const wxBitmap& bitmap)
ab86c659
VS
127 {
128 if (bitmap.Ok())
129 {
eba91e51
PC
130 // setting from pixmap doesn't seem to work right, but pixbuf works well
131 gtk_image_set_from_pixbuf((GtkImage*)m_image, bitmap.GetPixbuf());
ab86c659
VS
132 }
133 }
134
8a0681f9 135 GtkWidget *m_item;
eba91e51 136 GtkWidget *m_image;
8a0681f9
VZ
137
138protected:
139 void Init();
140};
141
142// ----------------------------------------------------------------------------
143// wxWin macros
144// ----------------------------------------------------------------------------
145
2eb10e2a 146IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxControl)
8a0681f9
VZ
147
148// ============================================================================
149// implementation
150// ============================================================================
151
c801d85f 152//-----------------------------------------------------------------------------
2f2aa628 153// "clicked" (internal from gtk_toolbar)
c801d85f
KB
154//-----------------------------------------------------------------------------
155
865bb325 156extern "C" {
8a0681f9
VZ
157static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget),
158 wxToolBarTool *tool )
c801d85f 159{
248bcf0a 160 if (g_isIdle)
59fe1666
RR
161 wxapp_install_idle_handler();
162
8a0681f9 163 wxToolBar *tbar = (wxToolBar *)tool->GetToolBar();
248bcf0a 164
9864c56d 165 if (tbar->m_blockEvent) return;
acfd422a 166
1144d24d 167 if (g_blockEventsOnDrag) return;
8a0681f9 168 if (!tool->IsEnabled()) return;
a3622daa 169
8a0681f9 170 if (tool->CanBeToggled())
248bcf0a 171 {
8a0681f9
VZ
172 tool->Toggle();
173
eba91e51 174 tool->SetImage(tool->GetBitmap());
38762f09
VZ
175
176 if ( tool->IsRadio() && !tool->IsToggled() )
177 {
178 // radio button went up, don't report this as a wxWin event
179 return;
180 }
85eb36c2 181 }
a3622daa 182
6bb7cee4
VZ
183 if( !tbar->OnLeftClick( tool->GetId(), tool->IsToggled() ) && tool->CanBeToggled() )
184 {
185 // revert back
186 tool->Toggle();
187
eba91e51 188 tool->SetImage(tool->GetBitmap());
6bb7cee4 189 }
fc008f25 190}
865bb325 191}
c801d85f 192
2f2aa628 193//-----------------------------------------------------------------------------
a8945eef 194// "enter_notify_event" / "leave_notify_event"
2f2aa628
RR
195//-----------------------------------------------------------------------------
196
865bb325 197extern "C" {
248bcf0a 198static gint gtk_toolbar_tool_callback( GtkWidget *WXUNUSED(widget),
a8945eef
MB
199 GdkEventCrossing *gdk_event,
200 wxToolBarTool *tool )
314055fa 201{
14819684 202 // don't need to install idle handler, its done from "event" signal
acfd422a 203
1144d24d 204 if (g_blockEventsOnDrag) return TRUE;
248bcf0a 205
8a0681f9 206 wxToolBar *tb = (wxToolBar *)tool->GetToolBar();
248bcf0a 207
47c93b63 208 // emit the event
a8945eef
MB
209 if( gdk_event->type == GDK_ENTER_NOTIFY )
210 tb->OnMouseEnter( tool->GetId() );
211 else
212 tb->OnMouseEnter( -1 );
248bcf0a 213
1144d24d 214 return FALSE;
314055fa 215}
865bb325 216}
314055fa 217
bf9e3e73
RR
218//-----------------------------------------------------------------------------
219// InsertChild callback for wxToolBar
220//-----------------------------------------------------------------------------
221
8a0681f9
VZ
222static void wxInsertChildInToolBar( wxToolBar* WXUNUSED(parent),
223 wxWindow* WXUNUSED(child) )
bf9e3e73 224{
47c93b63 225 // we don't do anything here
bf9e3e73
RR
226}
227
8a0681f9
VZ
228// ----------------------------------------------------------------------------
229// wxToolBarTool
230// ----------------------------------------------------------------------------
c801d85f 231
8a0681f9
VZ
232void wxToolBarTool::Init()
233{
234 m_item =
eba91e51 235 m_image = NULL;
8a0681f9 236}
c801d85f 237
8a0681f9 238wxToolBarToolBase *wxToolBar::CreateTool(int id,
e76c0b5f 239 const wxString& text,
8a0681f9
VZ
240 const wxBitmap& bitmap1,
241 const wxBitmap& bitmap2,
e76c0b5f 242 wxItemKind kind,
8a0681f9
VZ
243 wxObject *clientData,
244 const wxString& shortHelpString,
245 const wxString& longHelpString)
246{
e76c0b5f 247 return new wxToolBarTool(this, id, text, bitmap1, bitmap2, kind,
8a0681f9
VZ
248 clientData, shortHelpString, longHelpString);
249}
b1da76e1 250
8a0681f9 251wxToolBarToolBase *wxToolBar::CreateTool(wxControl *control)
c801d85f 252{
8a0681f9 253 return new wxToolBarTool(this, control);
fc008f25 254}
c801d85f 255
8a0681f9
VZ
256//-----------------------------------------------------------------------------
257// wxToolBar construction
258//-----------------------------------------------------------------------------
259
260void wxToolBar::Init()
c801d85f 261{
8a0681f9 262 m_toolbar = (GtkToolbar *)NULL;
91af0895 263 m_blockEvent = false;
d2c0a964
RD
264 m_defaultWidth = 32;
265 m_defaultHeight = 32;
fc008f25 266}
c801d85f 267
a3622daa 268wxToolBar::~wxToolBar()
c801d85f 269{
fc008f25 270}
c801d85f 271
8a0681f9
VZ
272bool wxToolBar::Create( wxWindow *parent,
273 wxWindowID id,
274 const wxPoint& pos,
275 const wxSize& size,
276 long style,
277 const wxString& name )
c801d85f 278{
91af0895 279 m_needParent = true;
bf9e3e73 280 m_insertCallback = (wxInsertChildFunction)wxInsertChildInToolBar;
a3622daa 281
8a0681f9
VZ
282 if ( !PreCreation( parent, pos, size ) ||
283 !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
4dcaf11a 284 {
223d09f6 285 wxFAIL_MSG( wxT("wxToolBar creation failed") );
c801d85f 286
91af0895 287 return false;
8a0681f9 288 }
a3622daa 289
d408730c
VZ
290 FixupStyle();
291
9e691f46 292 m_toolbar = GTK_TOOLBAR( gtk_toolbar_new() );
e76c0b5f 293 GtkSetStyle();
99e8cb50 294
2b5f62a0
VZ
295 // Doesn't work this way.
296 // GtkToolbarSpaceStyle space_style = GTK_TOOLBAR_SPACE_EMPTY;
297 // gtk_widget_style_set (GTK_WIDGET (m_toolbar), "space_style", &space_style, NULL);
a3622daa 298
8a0681f9 299 SetToolSeparation(7);
3502e687
RR
300
301 if (style & wxTB_DOCKABLE)
302 {
303 m_widget = gtk_handle_box_new();
f03fc89f
VZ
304 gtk_container_add( GTK_CONTAINER(m_widget), GTK_WIDGET(m_toolbar) );
305 gtk_widget_show( GTK_WIDGET(m_toolbar) );
8a0681f9 306
f03fc89f 307 if (style & wxTB_FLAT)
858b5bdd 308 gtk_handle_box_set_shadow_type( GTK_HANDLE_BOX(m_widget), GTK_SHADOW_NONE );
3502e687
RR
309 }
310 else
248bcf0a
RD
311 {
312 m_widget = gtk_event_box_new();
313 gtk_container_add( GTK_CONTAINER(m_widget), GTK_WIDGET(m_toolbar) );
314 ConnectWidget( m_widget );
315 gtk_widget_show(GTK_WIDGET(m_toolbar));
3502e687 316 }
8a0681f9 317
9e691f46 318 // FIXME: there is no such function for toolbars in 2.0
68567a96 319#if 0
858b5bdd
RR
320 if (style & wxTB_FLAT)
321 gtk_toolbar_set_button_relief( GTK_TOOLBAR(m_toolbar), GTK_RELIEF_NONE );
9e691f46 322#endif
be25e480 323
f03fc89f 324 m_parent->DoAddChild( this );
8a0681f9 325
abdeb9e7 326 PostCreation(size);
a3622daa 327
91af0895 328 return true;
fc008f25 329}
c801d85f 330
48468900
RR
331GdkWindow *wxToolBar::GTKGetWindow(wxArrayGdkWindows& windows) const
332{
333 return GTK_WIDGET(m_toolbar)->window;
334}
335
e76c0b5f
VZ
336void wxToolBar::GtkSetStyle()
337{
338 GtkOrientation orient;
339 GtkToolbarStyle style;
340 GetGtkStyle(GetWindowStyle(), &orient, &style);
341
342 gtk_toolbar_set_orientation(m_toolbar, orient);
343 gtk_toolbar_set_style(m_toolbar, style);
8c4e2405 344 gtk_toolbar_set_tooltips(m_toolbar, !(style & wxTB_NO_TOOLTIPS));
e76c0b5f
VZ
345}
346
347void wxToolBar::SetWindowStyleFlag( long style )
348{
349 wxToolBarBase::SetWindowStyleFlag(style);
8ad31f9d 350
e76c0b5f
VZ
351 if ( m_toolbar )
352 GtkSetStyle();
353}
354
8a0681f9 355bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
c801d85f 356{
8c4e2405 357 wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, toolBase);
248bcf0a 358
8a0681f9
VZ
359 if ( tool->IsButton() )
360 {
2b5f62a0
VZ
361 if ( !HasFlag(wxTB_NOICONS) )
362 {
363 wxBitmap bitmap = tool->GetNormalBitmap();
c801d85f 364
91af0895 365 wxCHECK_MSG( bitmap.Ok(), false,
2b5f62a0 366 wxT("invalid bitmap for wxToolBar icon") );
a3622daa 367
eba91e51
PC
368 tool->m_image = gtk_image_new();
369 tool->SetImage(bitmap);
248bcf0a 370
eba91e51 371 gtk_misc_set_alignment((GtkMisc*)tool->m_image, 0.5, 0.5);
2b5f62a0 372 }
8a0681f9 373 }
c801d85f 374
8c4e2405
PC
375 const int posGtk = int(pos);
376
8a0681f9
VZ
377 switch ( tool->GetStyle() )
378 {
379 case wxTOOL_STYLE_BUTTON:
38762f09
VZ
380 // for a radio button we need the widget which starts the radio
381 // group it belongs to, i.e. the first radio button immediately
382 // preceding this one
8a0681f9 383 {
38762f09
VZ
384 GtkWidget *widget = NULL;
385
386 if ( tool->IsRadio() )
387 {
98fc1d65
MB
388 wxToolBarToolsList::compatibility_iterator node
389 = wxToolBarToolsList::compatibility_iterator();
17a1ebd1
VZ
390 if ( pos )
391 node = m_tools.Item(pos - 1);
222ed1d6 392
38762f09
VZ
393 while ( node )
394 {
17a1ebd1
VZ
395 wxToolBarTool *toolNext = (wxToolBarTool *)node->GetData();
396 if ( !toolNext->IsRadio() )
38762f09
VZ
397 break;
398
17a1ebd1 399 widget = toolNext->m_item;
38762f09
VZ
400
401 node = node->GetPrevious();
402 }
403
404 if ( !widget )
405 {
406 // this is the first button in the radio button group,
407 // it will be toggled automatically by GTK so bring the
408 // internal flag in sync
91af0895 409 tool->Toggle(true);
38762f09
VZ
410 }
411 }
412
413 tool->m_item = gtk_toolbar_insert_element
414 (
415 m_toolbar,
416 tool->GetGtkChildType(),
417 widget,
418 tool->GetLabel().empty()
419 ? NULL
fab591c5 420 : (const char*) wxGTK_CONV( tool->GetLabel() ),
38762f09
VZ
421 tool->GetShortHelp().empty()
422 ? NULL
fab591c5 423 : (const char*) wxGTK_CONV( tool->GetShortHelp() ),
38762f09 424 "", // tooltip_private_text (?)
eba91e51 425 tool->m_image,
38762f09
VZ
426 (GtkSignalFunc)gtk_toolbar_callback,
427 (gpointer)tool,
6a1359c0 428 posGtk
38762f09
VZ
429 );
430
eba91e51 431 wxCHECK_MSG(tool->m_item != NULL, false, _T("gtk_toolbar_insert_element() failed"));
99e8cb50 432
9fa72bd2
MR
433 g_signal_connect (tool->m_item, "enter_notify_event",
434 G_CALLBACK (gtk_toolbar_tool_callback),
435 tool);
436 g_signal_connect (tool->m_item, "leave_notify_event",
437 G_CALLBACK (gtk_toolbar_tool_callback),
438 tool);
8a0681f9 439 }
8a0681f9
VZ
440 break;
441
442 case wxTOOL_STYLE_SEPARATOR:
6a1359c0 443 gtk_toolbar_insert_space( m_toolbar, posGtk );
8a0681f9
VZ
444
445 // skip the rest
91af0895 446 return true;
bf9e3e73 447
8a0681f9
VZ
448 case wxTOOL_STYLE_CONTROL:
449 gtk_toolbar_insert_widget(
450 m_toolbar,
451 tool->GetControl()->m_widget,
452 (const char *) NULL,
453 (const char *) NULL,
6a1359c0 454 posGtk
8a0681f9
VZ
455 );
456 break;
457 }
bf9e3e73 458
bf9e3e73 459 GtkRequisition req;
2afa14f2
OK
460 (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget) )->size_request )
461 (m_widget, &req );
00655497 462 m_width = req.width + m_xMargin;
6f67eafe 463 m_height = req.height + 2*m_yMargin;
9f884528 464 InvalidateBestSize();
bf9e3e73 465
91af0895 466 return true;
bf9e3e73
RR
467}
468
4a64a89c 469bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *toolBase)
c801d85f 470{
8c4e2405 471 wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, toolBase);
c801d85f 472
8a0681f9 473 switch ( tool->GetStyle() )
97d7bfb8 474 {
8a0681f9
VZ
475 case wxTOOL_STYLE_CONTROL:
476 tool->GetControl()->Destroy();
477 break;
97d7bfb8 478
8a0681f9
VZ
479 case wxTOOL_STYLE_BUTTON:
480 gtk_widget_destroy( tool->m_item );
481 break;
97d7bfb8 482
4a64a89c
RD
483 case wxTOOL_STYLE_SEPARATOR:
484 gtk_toolbar_remove_space( m_toolbar, pos );
485 break;
8a0681f9 486 }
c801d85f 487
9f884528 488 InvalidateBestSize();
91af0895 489 return true;
fc008f25 490}
46dc76ba 491
8a0681f9
VZ
492// ----------------------------------------------------------------------------
493// wxToolBar tools state
494// ----------------------------------------------------------------------------
495
496void wxToolBar::DoEnableTool(wxToolBarToolBase *toolBase, bool enable)
c801d85f 497{
8c4e2405 498 wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, toolBase);
8a0681f9 499
8a0681f9 500 if (tool->m_item)
fab591c5 501 {
8a0681f9 502 gtk_widget_set_sensitive( tool->m_item, enable );
fab591c5 503 }
fc008f25 504}
c801d85f 505
248bcf0a 506void wxToolBar::DoToggleTool( wxToolBarToolBase *toolBase, bool toggle )
c801d85f 507{
8c4e2405 508 wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, toolBase);
8a0681f9
VZ
509
510 GtkWidget *item = tool->m_item;
511 if ( item && GTK_IS_TOGGLE_BUTTON(item) )
1144d24d 512 {
eba91e51 513 tool->SetImage(tool->GetBitmap());
c801d85f 514
91af0895 515 m_blockEvent = true;
8a0681f9 516
e343da37 517 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(item), toggle );
248bcf0a 518
91af0895 519 m_blockEvent = false;
1144d24d 520 }
fc008f25 521}
c801d85f 522
8a0681f9
VZ
523void wxToolBar::DoSetToggle(wxToolBarToolBase * WXUNUSED(tool),
524 bool WXUNUSED(toggle))
c801d85f 525{
8a0681f9
VZ
526 // VZ: absolutely no idea about how to do it
527 wxFAIL_MSG( _T("not implemented") );
fc008f25 528}
c801d85f 529
8a0681f9
VZ
530// ----------------------------------------------------------------------------
531// wxToolBar geometry
532// ----------------------------------------------------------------------------
533
534wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord WXUNUSED(x),
535 wxCoord WXUNUSED(y)) const
c801d85f 536{
8a0681f9
VZ
537 // VZ: GTK+ doesn't seem to have such thing
538 wxFAIL_MSG( _T("wxToolBar::FindToolForPosition() not implemented") );
539
540 return (wxToolBarToolBase *)NULL;
fc008f25 541}
c801d85f 542
1144d24d 543void wxToolBar::SetMargins( int x, int y )
c801d85f 544{
8a0681f9
VZ
545 wxCHECK_RET( GetToolsCount() == 0,
546 wxT("wxToolBar::SetMargins must be called before adding tools.") );
248bcf0a 547
1144d24d
RR
548 m_xMargin = x;
549 m_yMargin = y;
fc008f25 550}
c801d85f 551
cf4219e7 552void wxToolBar::SetToolSeparation( int separation )
c801d85f 553{
9e691f46 554 // FIXME: this function disappeared
68567a96 555#if 0
1144d24d 556 gtk_toolbar_set_space_size( m_toolbar, separation );
9e691f46
VZ
557#endif
558
8a0681f9 559 m_toolSeparation = separation;
1144d24d
RR
560}
561
a1f79c1e
VZ
562void wxToolBar::SetToolShortHelp( int id, const wxString& helpString )
563{
8c4e2405 564 wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, FindById(id));
a1f79c1e
VZ
565
566 if ( tool )
567 {
568 (void)tool->SetShortHelp(helpString);
569 gtk_tooltips_set_tip(m_toolbar->tooltips, tool->m_item,
fab591c5 570 wxGTK_CONV( helpString ), "");
a1f79c1e
VZ
571 }
572}
573
8a0681f9
VZ
574// ----------------------------------------------------------------------------
575// wxToolBar idle handling
576// ----------------------------------------------------------------------------
1144d24d 577
9b7e522a
RR
578void wxToolBar::OnInternalIdle()
579{
1417c811
RR
580 // Check if we have to show window now
581 if (GtkShowFromOnIdle()) return;
582
9b7e522a
RR
583 wxCursor cursor = m_cursor;
584 if (g_globalCursor.Ok()) cursor = g_globalCursor;
585
f7a11f8c 586 if (cursor.Ok())
9b7e522a 587 {
f7a11f8c 588 /* I now set the cursor the anew in every OnInternalIdle call
8a0681f9
VZ
589 as setting the cursor in a parent window also effects the
590 windows above so that checking for the current cursor is
591 not possible. */
85ec2f26
RR
592
593 if (HasFlag(wxTB_DOCKABLE) && (m_widget->window))
9b7e522a 594 {
8a0681f9
VZ
595 /* if the toolbar is dockable, then m_widget stands for the
596 GtkHandleBox widget, which uses its own window so that we
597 can set the cursor for it. if the toolbar is not dockable,
598 m_widget comes from m_toolbar which uses its parent's
599 window ("windowless windows") and thus we cannot set the
600 cursor. */
601 gdk_window_set_cursor( m_widget->window, cursor.GetCursor() );
602 }
603
222ed1d6 604 wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst();
8a0681f9
VZ
605 while ( node )
606 {
607 wxToolBarTool *tool = (wxToolBarTool *)node->GetData();
608 node = node->GetNext();
609
610 GtkWidget *item = tool->m_item;
611 if ( item )
612 {
613 GdkWindow *window = item->window;
614
615 if ( window )
616 {
617 gdk_window_set_cursor( window, cursor.GetCursor() );
618 }
619 }
9b7e522a
RR
620 }
621 }
622
e39af974
JS
623 if (wxUpdateUIEvent::CanUpdate(this))
624 UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
9b7e522a
RR
625}
626
9d522606
RD
627
628// ----------------------------------------------------------------------------
629
630// static
631wxVisualAttributes
632wxToolBar::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
633{
9d522606 634 return GetDefaultAttributesFromGTKWidget(gtk_toolbar_new);
9d522606
RD
635}
636
a1f79c1e 637#endif // wxUSE_TOOLBAR_NATIVE