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