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