]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/tbargtk.cpp
A bit more or multi-format clipboard.
[wxWidgets.git] / src / gtk1 / tbargtk.cpp
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: tbargtk.cpp
3// Purpose: GTK toolbar
4// Author: Robert Roebling
32e9da8b 5// RCS-ID: $Id$
c801d85f 6// Copyright: (c) Robert Roebling
a3622daa 7// Licence: wxWindows licence
c801d85f
KB
8/////////////////////////////////////////////////////////////////////////////
9
10#ifdef __GNUG__
11#pragma implementation "tbargtk.h"
12#endif
13
14#include "wx/toolbar.h"
dcf924a3
RR
15
16#if wxUSE_TOOLBAR
17
e702ff0f 18#include "wx/frame.h"
c801d85f 19
83624f79
RR
20#include "glib.h"
21#include "gdk/gdk.h"
22#include "gtk/gtk.h"
23
acfd422a
RR
24//-----------------------------------------------------------------------------
25// idle system
26//-----------------------------------------------------------------------------
27
28extern void wxapp_install_idle_handler();
29extern bool g_isIdle;
30
314055fa
RR
31//-----------------------------------------------------------------------------
32// data
33//-----------------------------------------------------------------------------
34
9b7e522a
RR
35extern bool g_blockEventsOnDrag;
36extern wxCursor g_globalCursor;
314055fa 37
c801d85f 38//-----------------------------------------------------------------------------
2f2aa628 39// "clicked" (internal from gtk_toolbar)
c801d85f
KB
40//-----------------------------------------------------------------------------
41
42static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget), wxToolBarTool *tool )
43{
acfd422a
RR
44 if (g_isIdle) wxapp_install_idle_handler();
45
1144d24d
RR
46 if (g_blockEventsOnDrag) return;
47 if (!tool->m_enabled) return;
a3622daa 48
85eb36c2
RR
49 if (tool->m_isToggle)
50 {
51 tool->m_toggleState = !tool->m_toggleState;
52
53 if (tool->m_bitmap2.Ok())
54 {
55 wxBitmap bitmap = tool->m_bitmap1;
56 if (tool->m_toggleState) bitmap = tool->m_bitmap2;
57
58 GtkPixmap *pixmap = GTK_PIXMAP( tool->m_pixmap );
59
60 GdkBitmap *mask = (GdkBitmap *) NULL;
61 if (bitmap.GetMask()) mask = bitmap.GetMask()->GetBitmap();
62
63 gtk_pixmap_set( pixmap, bitmap.GetPixmap(), mask );
64 }
65 }
a3622daa 66
1144d24d 67 tool->m_owner->OnLeftClick( tool->m_index, tool->m_toggleState );
fc008f25 68}
c801d85f 69
2f2aa628
RR
70//-----------------------------------------------------------------------------
71// "enter_notify_event"
72//-----------------------------------------------------------------------------
73
314055fa
RR
74static gint gtk_toolbar_enter_callback( GtkWidget *WXUNUSED(widget),
75 GdkEventCrossing *WXUNUSED(gdk_event), wxToolBarTool *tool )
76{
acfd422a
RR
77 if (g_isIdle) wxapp_install_idle_handler();
78
1144d24d 79 if (g_blockEventsOnDrag) return TRUE;
b98d804b 80
b98d804b
RR
81
82 wxToolBar *tb = tool->m_owner;
83
c693edf3
RR
84#if (GTK_MINOR_VERSION == 0)
85 /* we grey-out the tip text of disabled tool in GTK 1.0 */
b98d804b
RR
86 if (tool->m_enabled)
87 {
88 if (tb->m_fg->red != 0)
f03fc89f 89 {
b98d804b
RR
90 tb->m_fg->red = 0;
91 tb->m_fg->green = 0;
92 tb->m_fg->blue = 0;
93 gdk_color_alloc( gtk_widget_get_colormap( GTK_WIDGET(tb->m_toolbar) ), tb->m_fg );
f03fc89f 94
b98d804b 95 gtk_tooltips_set_colors( GTK_TOOLBAR(tb->m_toolbar)->tooltips, tb->m_bg, tb->m_fg );
f03fc89f 96 }
b98d804b
RR
97 }
98 else
99 {
100 if (tb->m_fg->red == 0)
f03fc89f 101 {
b98d804b
RR
102 tb->m_fg->red = 33000;
103 tb->m_fg->green = 33000;
104 tb->m_fg->blue = 33000;
105 gdk_color_alloc( gtk_widget_get_colormap( GTK_WIDGET(tb->m_toolbar) ), tb->m_fg );
106 gtk_tooltips_set_colors( GTK_TOOLBAR(tb->m_toolbar)->tooltips, tb->m_bg, tb->m_fg );
f03fc89f 107 }
b98d804b 108 }
f7ac40d1 109#endif
b98d804b
RR
110
111 /* emit the event */
314055fa 112
b98d804b 113 tb->OnMouseEnter( tool->m_index );
314055fa 114
1144d24d 115 return FALSE;
314055fa
RR
116}
117
2f2aa628
RR
118//-----------------------------------------------------------------------------
119// wxToolBar
c801d85f
KB
120//-----------------------------------------------------------------------------
121
716b7364 122IMPLEMENT_DYNAMIC_CLASS(wxToolBar,wxControl)
c801d85f 123
b1da76e1
RR
124BEGIN_EVENT_TABLE(wxToolBar, wxControl)
125 EVT_IDLE(wxToolBar::OnIdle)
126END_EVENT_TABLE()
127
a3622daa 128wxToolBar::wxToolBar()
c801d85f 129{
fc008f25 130}
c801d85f 131
a3622daa 132wxToolBar::wxToolBar( wxWindow *parent, wxWindowID id,
c801d85f 133 const wxPoint& pos, const wxSize& size,
debe6624 134 long style, const wxString& name )
c801d85f 135{
1144d24d 136 Create( parent, id, pos, size, style, name );
fc008f25 137}
c801d85f 138
a3622daa 139wxToolBar::~wxToolBar()
c801d85f 140{
83624f79
RR
141 delete m_fg;
142 delete m_bg;
fc008f25 143}
c801d85f 144
a3622daa 145bool wxToolBar::Create( wxWindow *parent, wxWindowID id,
c801d85f 146 const wxPoint& pos, const wxSize& size,
debe6624 147 long style, const wxString& name )
c801d85f 148{
1144d24d 149 m_needParent = TRUE;
a3622daa 150
4dcaf11a
RR
151 if (!PreCreation( parent, pos, size ) ||
152 !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
153 {
223d09f6 154 wxFAIL_MSG( wxT("wxToolBar creation failed") );
4dcaf11a
RR
155 return FALSE;
156 }
c801d85f 157
1144d24d 158 m_tools.DeleteContents( TRUE );
a3622daa 159
1144d24d
RR
160 m_toolbar = GTK_TOOLBAR( gtk_toolbar_new( GTK_ORIENTATION_HORIZONTAL,
161 GTK_TOOLBAR_ICONS ) );
a3622daa 162
1144d24d
RR
163 m_separation = 5;
164 gtk_toolbar_set_space_size( m_toolbar, m_separation );
165 m_hasToolAlready = FALSE;
3502e687
RR
166
167 if (style & wxTB_DOCKABLE)
168 {
169 m_widget = gtk_handle_box_new();
f03fc89f
VZ
170 gtk_container_add( GTK_CONTAINER(m_widget), GTK_WIDGET(m_toolbar) );
171 gtk_widget_show( GTK_WIDGET(m_toolbar) );
172
b0795d45 173#if (GTK_MINOR_VERSION > 0)
f03fc89f 174 if (style & wxTB_FLAT)
858b5bdd 175 gtk_handle_box_set_shadow_type( GTK_HANDLE_BOX(m_widget), GTK_SHADOW_NONE );
b0795d45 176#endif
3502e687
RR
177 }
178 else
179 {
180 m_widget = GTK_WIDGET(m_toolbar);
181 }
f03fc89f 182
1144d24d 183 gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE );
858b5bdd
RR
184
185#if (GTK_MINOR_VERSION > 0)
186 if (style & wxTB_FLAT)
187 gtk_toolbar_set_button_relief( GTK_TOOLBAR(m_toolbar), GTK_RELIEF_NONE );
188#endif
83624f79
RR
189
190 m_fg = new GdkColor;
191 m_fg->red = 0;
192 m_fg->green = 0;
193 m_fg->blue = 0;
194 gdk_color_alloc( gtk_widget_get_colormap( GTK_WIDGET(m_toolbar) ), m_fg );
b46e8696 195
83624f79
RR
196 m_bg = new GdkColor;
197 m_bg->red = 65535;
198 m_bg->green = 65535;
199 m_bg->blue = 50000;
200 gdk_color_alloc( gtk_widget_get_colormap( GTK_WIDGET(m_toolbar) ), m_bg );
b46e8696 201
fac4253c
RR
202#if (GTK_MINOR_VERSION > 0)
203 gtk_tooltips_force_window( GTK_TOOLBAR(m_toolbar)->tooltips );
204
205 GtkStyle *g_style =
206 gtk_style_copy(
207 gtk_widget_get_style(
208 GTK_TOOLBAR(m_toolbar)->tooltips->tip_window ) );
f03fc89f 209
fac4253c
RR
210 g_style->bg[GTK_STATE_NORMAL] = *m_bg;
211 gtk_widget_set_style( GTK_TOOLBAR(m_toolbar)->tooltips->tip_window, g_style );
212#else
83624f79 213 gtk_tooltips_set_colors( GTK_TOOLBAR(m_toolbar)->tooltips, m_bg, m_fg );
fac4253c 214#endif
a3622daa 215
1144d24d
RR
216 m_xMargin = 0;
217 m_yMargin = 0;
218
f03fc89f 219 m_parent->DoAddChild( this );
6ca41e57 220
1144d24d 221 PostCreation();
a3622daa 222
1144d24d 223 Show( TRUE );
a3622daa 224
1144d24d 225 return TRUE;
fc008f25 226}
c801d85f 227
716b7364 228bool wxToolBar::OnLeftClick( int toolIndex, bool toggleDown )
c801d85f 229{
1144d24d
RR
230 wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, toolIndex );
231 event.SetEventObject(this);
232 event.SetInt( toolIndex );
233 event.SetExtraLong((long) toggleDown);
c801d85f 234
1144d24d 235 GetEventHandler()->ProcessEvent(event);
c801d85f 236
1144d24d 237 return TRUE;
fc008f25 238}
c801d85f 239
716b7364 240void wxToolBar::OnRightClick( int toolIndex, float WXUNUSED(x), float WXUNUSED(y) )
c801d85f 241{
1144d24d
RR
242 wxCommandEvent event( wxEVT_COMMAND_TOOL_RCLICKED, toolIndex );
243 event.SetEventObject( this );
244 event.SetInt( toolIndex );
c801d85f 245
1144d24d 246 GetEventHandler()->ProcessEvent(event);
fc008f25 247}
c801d85f 248
716b7364 249void wxToolBar::OnMouseEnter( int toolIndex )
c801d85f 250{
1144d24d
RR
251 wxCommandEvent event( wxEVT_COMMAND_TOOL_ENTER, GetId() );
252 event.SetEventObject(this);
253 event.SetInt( toolIndex );
314055fa 254
1144d24d 255 GetEventHandler()->ProcessEvent(event);
fc008f25 256}
c801d85f 257
a3622daa 258wxToolBarTool *wxToolBar::AddTool( int toolIndex, const wxBitmap& bitmap,
debe6624
JS
259 const wxBitmap& pushedBitmap, bool toggle,
260 float WXUNUSED(xPos), float WXUNUSED(yPos), wxObject *clientData,
c801d85f
KB
261 const wxString& helpString1, const wxString& helpString2 )
262{
1144d24d
RR
263 m_hasToolAlready = TRUE;
264
265 wxCHECK_MSG( bitmap.Ok(), (wxToolBarTool *)NULL,
223d09f6 266 wxT("invalid bitmap for wxToolBar icon") );
a3622daa 267
1144d24d 268 wxCHECK_MSG( bitmap.GetBitmap() == NULL, (wxToolBarTool *)NULL,
223d09f6 269 wxT("wxToolBar doesn't support GdkBitmap") );
03f38c58 270
1144d24d 271 wxCHECK_MSG( bitmap.GetPixmap() != NULL, (wxToolBarTool *)NULL,
223d09f6 272 wxT("wxToolBar::Add needs a wxBitmap") );
903f689b 273
1144d24d 274 GtkWidget *tool_pixmap = (GtkWidget *)NULL;
903f689b 275
903f689b 276 GdkPixmap *pixmap = bitmap.GetPixmap();
a3622daa 277
68dda785
VZ
278 GdkBitmap *mask = (GdkBitmap *)NULL;
279 if ( bitmap.GetMask() )
280 mask = bitmap.GetMask()->GetBitmap();
903f689b
RR
281
282 tool_pixmap = gtk_pixmap_new( pixmap, mask );
c693edf3 283#if (GTK_MINOR_VERSION > 0)
f7ac40d1 284 gtk_pixmap_set_build_insensitive( GTK_PIXMAP(tool_pixmap), TRUE );
c693edf3 285#endif
f7ac40d1 286
1144d24d 287 gtk_misc_set_alignment( GTK_MISC(tool_pixmap), 0.5, 0.5 );
a3622daa 288
2b1c162e
RR
289 wxToolBarTool *tool = new wxToolBarTool( this, toolIndex, bitmap, pushedBitmap,
290 toggle, clientData,
291 helpString1, helpString2,
f03fc89f 292 tool_pixmap );
2b1c162e 293
1144d24d
RR
294 GtkToolbarChildType ctype = toggle ? GTK_TOOLBAR_CHILD_TOGGLEBUTTON
295 : GTK_TOOLBAR_CHILD_BUTTON;
03f38c58 296
1144d24d 297 GtkWidget *item = gtk_toolbar_append_element
68dda785
VZ
298 (
299 GTK_TOOLBAR(m_toolbar),
300 ctype,
301 (GtkWidget *)NULL,
302 (const char *)NULL,
05939a81 303 helpString1.mbc_str(),
68dda785
VZ
304 "",
305 tool_pixmap,
306 (GtkSignalFunc)gtk_toolbar_callback,
307 (gpointer)tool
308 );
309
1144d24d 310 tool->m_item = item;
03f38c58 311
3017f78d
RR
312 GtkRequisition req;
313 (* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget)->klass )->size_request ) (m_widget, &req );
314 m_width = req.width;
315 m_height = req.height;
316
1144d24d
RR
317 gtk_signal_connect( GTK_OBJECT(tool->m_item),
318 "enter_notify_event",
319 GTK_SIGNAL_FUNC(gtk_toolbar_enter_callback),
320 (gpointer)tool );
314055fa 321
1144d24d 322 m_tools.Append( tool );
a3622daa 323
1144d24d 324 return tool;
fc008f25 325}
c801d85f 326
03f38c58 327void wxToolBar::AddSeparator()
c801d85f 328{
1144d24d 329 gtk_toolbar_append_space( m_toolbar );
fc008f25 330}
c801d85f 331
03f38c58 332void wxToolBar::ClearTools()
c801d85f 333{
223d09f6 334 wxFAIL_MSG( wxT("wxToolBar::ClearTools not implemented") );
fc008f25 335}
c801d85f 336
1144d24d 337bool wxToolBar::Realize()
46dc76ba 338{
1144d24d
RR
339 m_x = 0;
340 m_y = 0;
341 m_width = 100;
342 m_height = 0;
46dc76ba 343
1144d24d
RR
344 wxNode *node = m_tools.First();
345 while (node)
46dc76ba 346 {
1144d24d
RR
347 wxToolBarTool *tool = (wxToolBarTool*)node->Data();
348 if (tool->m_bitmap1.Ok())
349 {
350 int tool_height = tool->m_bitmap1.GetHeight();
351 if (tool_height > m_height) m_height = tool_height;
352 }
46dc76ba 353
1144d24d
RR
354 node = node->Next();
355 }
46dc76ba 356
1144d24d
RR
357 m_height += 5 + 2*m_yMargin;
358
359 return TRUE;
fc008f25 360}
46dc76ba 361
716b7364 362void wxToolBar::EnableTool(int toolIndex, bool enable)
c801d85f 363{
1144d24d
RR
364 wxNode *node = m_tools.First();
365 while (node)
366 {
367 wxToolBarTool *tool = (wxToolBarTool*)node->Data();
368 if (tool->m_index == toolIndex)
2b1c162e 369 {
1144d24d 370 tool->m_enabled = enable;
f03fc89f 371
c693edf3
RR
372#if (GTK_MINOR_VERSION > 0)
373 /* we don't disable the tools for GTK 1.0 as the bitmaps don't get
374 greyed anyway and this also disables tooltips */
f03fc89f
VZ
375 if (tool->m_item)
376 gtk_widget_set_sensitive( tool->m_item, enable );
c693edf3 377#endif
f03fc89f 378
1144d24d
RR
379 return;
380 }
381 node = node->Next();
cf4219e7 382 }
fc008f25 383
223d09f6 384 wxFAIL_MSG( wxT("wrong toolbar index") );
fc008f25 385}
c801d85f 386
fc008f25 387void wxToolBar::ToggleTool( int toolIndex, bool toggle )
c801d85f 388{
1144d24d
RR
389 wxNode *node = m_tools.First();
390 while (node)
391 {
392 wxToolBarTool *tool = (wxToolBarTool*)node->Data();
393 if (tool->m_index == toolIndex)
394 {
1144d24d 395 if ((tool->m_item) && (GTK_IS_TOGGLE_BUTTON(tool->m_item)))
e179bd65
RR
396 {
397 tool->m_toggleState = toggle;
398
399 if (tool->m_bitmap2.Ok())
400 {
401 wxBitmap bitmap = tool->m_bitmap1;
402 if (tool->m_toggleState) bitmap = tool->m_bitmap2;
403
404 GtkPixmap *pixmap = GTK_PIXMAP( tool->m_pixmap );
405
406 GdkBitmap *mask = (GdkBitmap *) NULL;
407 if (bitmap.GetMask()) mask = bitmap.GetMask()->GetBitmap();
408
409 gtk_pixmap_set( pixmap, bitmap.GetPixmap(), mask );
410 }
411
412 gtk_signal_disconnect_by_func( GTK_OBJECT(tool->m_item),
413 GTK_SIGNAL_FUNC(gtk_toolbar_callback), (gpointer*)tool );
414
1144d24d 415 gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(tool->m_item), toggle );
e179bd65
RR
416
417 gtk_signal_connect( GTK_OBJECT(tool->m_item), "clicked",
418 GTK_SIGNAL_FUNC(gtk_toolbar_callback), (gpointer*)tool );
419 }
420
1144d24d
RR
421 return;
422 }
423 node = node->Next();
fc008f25 424 }
fc008f25 425
223d09f6 426 wxFAIL_MSG( wxT("wrong toolbar index") );
fc008f25 427}
c801d85f 428
fc008f25 429wxObject *wxToolBar::GetToolClientData( int index ) const
c801d85f 430{
1144d24d
RR
431 wxNode *node = m_tools.First();
432 while (node)
433 {
434 wxToolBarTool *tool = (wxToolBarTool*)node->Data();
435 if (tool->m_index == index) return tool->m_clientData;;
436 node = node->Next();
437 }
fc008f25 438
223d09f6 439 wxFAIL_MSG( wxT("wrong toolbar index") );
fc008f25 440
1144d24d 441 return (wxObject*)NULL;
fc008f25 442}
c801d85f 443
716b7364 444bool wxToolBar::GetToolState(int toolIndex) const
c801d85f 445{
1144d24d
RR
446 wxNode *node = m_tools.First();
447 while (node)
448 {
449 wxToolBarTool *tool = (wxToolBarTool*)node->Data();
450 if (tool->m_index == toolIndex) return tool->m_toggleState;
451 node = node->Next();
452 }
fc008f25 453
223d09f6 454 wxFAIL_MSG( wxT("wrong toolbar index") );
fc008f25 455
1144d24d 456 return FALSE;
fc008f25 457}
c801d85f 458
716b7364 459bool wxToolBar::GetToolEnabled(int toolIndex) const
c801d85f 460{
1144d24d
RR
461 wxNode *node = m_tools.First();
462 while (node)
463 {
464 wxToolBarTool *tool = (wxToolBarTool*)node->Data();
465 if (tool->m_index == toolIndex) return tool->m_enabled;
466 node = node->Next();
467 }
fc008f25 468
223d09f6 469 wxFAIL_MSG( wxT("wrong toolbar index") );
fc008f25 470
1144d24d 471 return FALSE;
fc008f25 472}
c801d85f 473
1144d24d 474void wxToolBar::SetMargins( int x, int y )
c801d85f 475{
223d09f6 476 wxCHECK_RET( !m_hasToolAlready, wxT("wxToolBar::SetMargins must be called before adding tool.") );
1144d24d
RR
477
478 if (x > 2) gtk_toolbar_append_space( m_toolbar ); // oh well
479
480 m_xMargin = x;
481 m_yMargin = y;
fc008f25 482}
c801d85f 483
cf4219e7 484void wxToolBar::SetToolPacking( int WXUNUSED(packing) )
c801d85f 485{
223d09f6 486 wxFAIL_MSG( wxT("wxToolBar::SetToolPacking not implemented") );
fc008f25 487}
c801d85f 488
cf4219e7 489void wxToolBar::SetToolSeparation( int separation )
c801d85f 490{
1144d24d
RR
491 gtk_toolbar_set_space_size( m_toolbar, separation );
492 m_separation = separation;
493}
494
495int wxToolBar::GetToolPacking()
496{
497 return 0;
498}
499
500int wxToolBar::GetToolSeparation()
501{
502 return m_separation;
503}
504
505wxString wxToolBar::GetToolLongHelp(int toolIndex)
506{
507 wxNode *node = m_tools.First();
508 while (node)
509 {
510 wxToolBarTool *tool = (wxToolBarTool*)node->Data();
511 if (tool->m_index == toolIndex)
512 {
513 return tool->m_longHelpString;
514 }
515 node = node->Next();
516 }
517
223d09f6 518 wxFAIL_MSG( wxT("wrong toolbar index") );
1144d24d 519
223d09f6 520 return wxT("");
1144d24d
RR
521}
522
523wxString wxToolBar::GetToolShortHelp(int toolIndex)
524{
525 wxNode *node = m_tools.First();
526 while (node)
527 {
528 wxToolBarTool *tool = (wxToolBarTool*)node->Data();
529 if (tool->m_index == toolIndex)
530 {
531 return tool->m_shortHelpString;
532 }
533 node = node->Next();
534 }
535
223d09f6 536 wxFAIL_MSG( wxT("wrong toolbar index") );
1144d24d 537
223d09f6 538 return wxT("");
fc008f25 539}
c801d85f 540
1144d24d
RR
541void wxToolBar::SetToolLongHelp(int toolIndex, const wxString& helpString)
542{
543 wxNode *node = m_tools.First();
544 while (node)
545 {
546 wxToolBarTool *tool = (wxToolBarTool*)node->Data();
547 if (tool->m_index == toolIndex)
548 {
549 tool->m_longHelpString = helpString;
f03fc89f 550 return;
1144d24d
RR
551 }
552 node = node->Next();
553 }
554
223d09f6 555 wxFAIL_MSG( wxT("wrong toolbar index") );
1144d24d
RR
556
557 return;
558}
559
560void wxToolBar::SetToolShortHelp(int toolIndex, const wxString& helpString)
561{
562 wxNode *node = m_tools.First();
563 while (node)
564 {
565 wxToolBarTool *tool = (wxToolBarTool*)node->Data();
566 if (tool->m_index == toolIndex)
567 {
568 tool->m_shortHelpString = helpString;
f03fc89f 569 return;
1144d24d
RR
570 }
571 node = node->Next();
572 }
573
223d09f6 574 wxFAIL_MSG( wxT("wrong toolbar index") );
1144d24d
RR
575
576 return;
577}
578
b1da76e1
RR
579void wxToolBar::OnIdle( wxIdleEvent &WXUNUSED(ievent) )
580{
581 wxEvtHandler* evtHandler = GetEventHandler();
582
583 wxNode* node = m_tools.First();
584 while (node)
585 {
586 wxToolBarTool* tool = (wxToolBarTool*) node->Data();
587
588 wxUpdateUIEvent event( tool->m_index );
589 event.SetEventObject(this);
590
591 if (evtHandler->ProcessEvent( event ))
592 {
593 if (event.GetSetEnabled())
594 EnableTool(tool->m_index, event.GetEnabled());
595 if (event.GetSetChecked())
596 ToggleTool(tool->m_index, event.GetChecked());
597/*
598 if (event.GetSetText())
599 // Set tooltip?
600*/
601 }
602
603 node = node->Next();
604 }
605}
1144d24d 606
9b7e522a
RR
607void wxToolBar::OnInternalIdle()
608{
609 wxCursor cursor = m_cursor;
610 if (g_globalCursor.Ok()) cursor = g_globalCursor;
611
f7a11f8c 612 if (cursor.Ok())
9b7e522a 613 {
f7a11f8c
RR
614 /* I now set the cursor the anew in every OnInternalIdle call
615 as setting the cursor in a parent window also effects the
616 windows above so that checking for the current cursor is
617 not possible. */
618
619 if (HasFlag(wxTB_DOCKABLE))
620 {
621 /* if the toolbar is dockable, then m_widget stands for the
622 GtkHandleBox widget, which uses its own window so that we
623 can set the cursor for it. if the toolbar is not dockable,
624 m_widget comes from m_toolbar which uses its parent's
625 window ("windowless windows") and thus we cannot set the
626 cursor. */
627 gdk_window_set_cursor( m_widget->window, cursor.GetCursor() );
628 }
9b7e522a
RR
629
630 wxNode *node = m_tools.First();
631 while (node)
632 {
633 wxToolBarTool *tool = (wxToolBarTool*)node->Data();
634 if (!tool->m_item->window)
9b7e522a 635 break;
9b7e522a 636 else
f7a11f8c
RR
637 gdk_window_set_cursor( tool->m_item->window, cursor.GetCursor() );
638
9b7e522a
RR
639 node = node->Next();
640 }
641 }
642
643 UpdateWindowUI();
644}
645
dcf924a3 646#endif