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