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