removed USE_SHARED_LIBRARY(IES)
[wxWidgets.git] / src / common / tbarbase.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: tbarbase.cpp
3 // Purpose: Toolbar base classes
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "tbarbase.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include "wx/wx.h"
25 #endif
26
27 #include "wx/frame.h"
28
29 // For ::UpdateWindow
30 #ifdef __WXMSW__
31 #include <windows.h>
32 #endif
33
34 #if wxUSE_TOOLBAR
35
36 #include "wx/tbarbase.h"
37
38 IMPLEMENT_ABSTRACT_CLASS(wxToolBarBase, wxControl)
39 IMPLEMENT_DYNAMIC_CLASS(wxToolBarTool, wxObject)
40
41 BEGIN_EVENT_TABLE(wxToolBarBase, wxControl)
42 EVT_SCROLL(wxToolBarBase::OnScroll)
43 EVT_SIZE(wxToolBarBase::OnSize)
44 EVT_IDLE(wxToolBarBase::OnIdle)
45 END_EVENT_TABLE()
46
47 // Keep a list of all toolbars created, so you can tell whether a toolbar
48 // is still valid: a tool may have quit the toolbar.
49 static wxList gs_ToolBars;
50
51 #ifdef __WXGTK__
52 wxToolBarTool::wxToolBarTool(wxToolBar *owner, int theIndex,
53 const wxBitmap& theBitmap1, const wxBitmap& theBitmap2,
54 bool toggle, wxObject *clientData,
55 const wxString& helpS1, const wxString& helpS2,
56 GtkWidget *pixmap )
57 #else
58 wxToolBarTool::wxToolBarTool(int theIndex,
59 const wxBitmap& theBitmap1, const wxBitmap& theBitmap2, bool toggle,
60 long xPos, long yPos, const wxString& helpS1, const wxString& helpS2)
61 #endif
62 {
63 m_toolStyle = wxTOOL_STYLE_BUTTON;
64 #ifdef __WXGTK__
65 m_owner = owner;
66 m_pixmap = pixmap;
67 m_item = (GtkWidget*) NULL;
68 m_clientData = clientData;
69 m_x = 0;
70 m_y = 0;
71 #else
72 m_clientData = NULL;
73 m_x = xPos;
74 m_y = yPos;
75 #endif
76 m_index = theIndex;
77 m_isToggle = toggle;
78 m_toggleState = FALSE;
79 m_enabled = TRUE;
80 m_bitmap1 = theBitmap1;
81 m_bitmap2 = theBitmap2;
82 m_width = m_height = 0;
83 m_deleteSecondBitmap = FALSE;
84 if (m_bitmap1.Ok())
85 {
86 m_width = m_bitmap1.GetWidth()+2;
87 m_height = m_bitmap1.GetHeight()+2;
88 }
89 m_shortHelpString = helpS1;
90 m_longHelpString = helpS2;
91 m_control = (wxControl*) NULL;
92 }
93
94 wxToolBarTool::wxToolBarTool(wxControl *control)
95 {
96 m_toolStyle = wxTOOL_STYLE_CONTROL;
97 m_control = control;
98 m_index = control->GetId();
99 }
100
101 wxToolBarTool::~wxToolBarTool()
102 {
103 /*
104 if (m_deleteSecondBitmap && m_bitmap2)
105 delete m_bitmap2;
106 */
107 }
108
109
110 // class wxToolBar
111
112 wxToolBarBase::wxToolBarBase(void) : m_tools(wxKEY_INTEGER)
113 {
114 gs_ToolBars.Append(this);
115
116 m_maxRows = 1;
117 m_maxCols = 32000;
118 m_maxWidth = 0;
119 m_maxHeight = 0;
120 m_defaultWidth = 16;
121 m_defaultHeight = 15;
122 m_xMargin = 0;
123 m_yMargin = 0;
124 m_toolPacking = 1;
125 m_toolSeparation = 5;
126 m_currentTool = -1;
127
128 m_xScrollPixelsPerLine = 0;
129 m_yScrollPixelsPerLine = 0;
130 m_xScrollingEnabled = TRUE;
131 m_yScrollingEnabled = TRUE;
132 m_xScrollPosition = 0;
133 m_yScrollPosition = 0;
134 m_calcScrolledOffset = TRUE;
135 m_xScrollLines = 0;
136 m_yScrollLines = 0;
137 m_xScrollLinesPerPage = 0;
138 m_yScrollLinesPerPage = 0;
139 }
140
141 wxToolBarBase::~wxToolBarBase ()
142 {
143 gs_ToolBars.DeleteObject(this);
144
145 for ( wxNode *node = m_tools.First(); node; node = node->Next() )
146 {
147 wxToolBarTool *tool = (wxToolBarTool *)node->Data();
148 delete tool;
149 }
150 }
151
152 // Only allow toggle if returns TRUE
153 bool wxToolBarBase::OnLeftClick(int toolIndex, bool toggleDown)
154 {
155 wxCommandEvent event(wxEVT_COMMAND_TOOL_CLICKED, toolIndex);
156 event.SetEventObject(this);
157 event.SetExtraLong((long) toggleDown);
158
159 // Send events to this toolbar instead (and thence up the window hierarchy)
160 GetEventHandler()->ProcessEvent(event);
161
162 return TRUE;
163 }
164
165 // Call when right button down.
166 void wxToolBarBase::OnRightClick(int toolIndex,
167 long WXUNUSED(x),
168 long WXUNUSED(y))
169 {
170 wxCommandEvent event(wxEVT_COMMAND_TOOL_RCLICKED, toolIndex);
171 event.SetEventObject(this);
172 event.SetInt(toolIndex);
173
174 GetEventHandler()->ProcessEvent(event);
175 }
176
177 // Called when the mouse cursor enters a tool bitmap (no button pressed).
178 // Argument is -1 if mouse is exiting the toolbar.
179 // Note that for this event, the id of the window is used,
180 // and the integer parameter of wxCommandEvent is used to retrieve
181 // the tool id.
182 void wxToolBarBase::OnMouseEnter ( int toolIndex )
183 {
184 wxCommandEvent event(wxEVT_COMMAND_TOOL_ENTER, GetId());
185 event.SetEventObject(this);
186 event.SetInt(toolIndex);
187
188 GetEventHandler()->ProcessEvent(event);
189 }
190
191 // If pushedBitmap is NULL, a reversed version of bitmap is
192 // created and used as the pushed/toggled image.
193 // If toggle is TRUE, the button toggles between the two states.
194 wxToolBarTool *wxToolBarBase::AddTool(int index, const wxBitmap& bitmap, const wxBitmap& pushedBitmap,
195 bool toggle, wxCoord xPos, wxCoord yPos, wxObject *clientData,
196 const wxString& helpString1, const wxString& helpString2)
197 {
198 #ifdef __WXGTK__
199 wxToolBarTool *tool = new wxToolBarTool( (wxToolBar*)this, index, bitmap, pushedBitmap, toggle,
200 (wxObject*) NULL, helpString1, helpString2);
201 #else
202 wxToolBarTool *tool = new wxToolBarTool(index, bitmap, pushedBitmap, toggle, xPos, yPos, helpString1, helpString2);
203 #endif
204 tool->m_clientData = clientData;
205
206 if (xPos > -1)
207 tool->m_x = xPos;
208 else
209 tool->m_x = m_xMargin;
210
211 if (yPos > -1)
212 tool->m_y = yPos;
213 else
214 tool->m_y = m_yMargin;
215
216 // Calculate reasonable max size in case Layout() not called
217 if ((tool->m_x + bitmap.GetWidth() + m_xMargin) > m_maxWidth)
218 m_maxWidth = (tool->m_x + bitmap.GetWidth() + m_xMargin);
219
220 if ((tool->m_y + bitmap.GetHeight() + m_yMargin) > m_maxHeight)
221 m_maxHeight = (tool->m_y + bitmap.GetHeight() + m_yMargin);
222
223 m_tools.Append((long)index, tool);
224 return tool;
225 }
226
227 void wxToolBarBase::AddSeparator ()
228 {
229 wxToolBarTool *tool = new wxToolBarTool;
230 tool->m_index = -1;
231 tool->m_toolStyle = wxTOOL_STYLE_SEPARATOR;
232 m_tools.Append(-1, tool);
233 }
234
235 void wxToolBarBase::ClearTools()
236 {
237 m_pressedTool = m_currentTool = -1;
238 wxNode *node = m_tools.First();
239 while (node)
240 {
241 wxToolBarTool *tool = (wxToolBarTool *)node->Data();
242 wxNode *nextNode = node->Next();
243 delete tool;
244 delete node;
245 node = nextNode;
246 }
247 }
248
249 void wxToolBarBase::EnableTool(int index, bool enable)
250 {
251 wxNode *node = m_tools.Find((long)index);
252 if (node)
253 {
254 wxToolBarTool *tool = (wxToolBarTool *)node->Data();
255 if (tool)
256 tool->m_enabled = enable;
257 }
258 }
259
260 void wxToolBarBase::ToggleTool(int WXUNUSED(index),
261 bool WXUNUSED(toggle))
262 {
263 }
264
265 void wxToolBarBase::SetToggle(int index, bool value)
266 {
267 wxNode *node=m_tools.Find((long)index);
268 if (node){
269 wxToolBarTool *tool = (wxToolBarTool *)node->Data();
270 tool->m_isToggle = value;
271 }
272 }
273
274 bool wxToolBarBase::GetToolState(int index) const
275 {
276 wxNode *node = m_tools.Find((long)index);
277 if (node)
278 {
279 wxToolBarTool *tool = (wxToolBarTool *)node->Data();
280 if (tool)
281 {
282 return tool->m_toggleState;
283 }
284 else return FALSE;
285 }
286 else return FALSE;
287 }
288
289 bool wxToolBarBase::GetToolEnabled(int index) const
290 {
291 wxNode *node = m_tools.Find((long)index);
292 if (node)
293 {
294 wxToolBarTool *tool = (wxToolBarTool *)node->Data();
295 if (tool)
296 {
297 return tool->m_enabled;
298 }
299 else return FALSE;
300 }
301 else return FALSE;
302 }
303
304 wxObject *wxToolBarBase::GetToolClientData(int index) const
305 {
306 wxNode *node = m_tools.Find((long)index);
307 if (node)
308 {
309 wxToolBarTool *tool = (wxToolBarTool *)node->Data();
310 if (tool)
311 {
312 return tool->m_clientData;
313 }
314 else return NULL;
315 }
316 else return NULL;
317 }
318
319 void wxToolBarBase::SetToolShortHelp(int index, const wxString& helpString)
320 {
321 wxNode *node=m_tools.Find((long)index);
322 if (node)
323 {
324 wxToolBarTool *tool = (wxToolBarTool *)node->Data();
325 tool->m_shortHelpString = helpString;
326 }
327 }
328
329 wxString wxToolBarBase::GetToolShortHelp(int index) const
330 {
331 wxNode *node=m_tools.Find((long)index);
332 if (node)
333 {
334 wxToolBarTool *tool = (wxToolBarTool *)node->Data();
335 return tool->m_shortHelpString;
336 }
337 else
338 return wxString("");
339 }
340
341 void wxToolBarBase::SetToolLongHelp(int index, const wxString& helpString)
342 {
343 wxNode *node=m_tools.Find((long)index);
344 if (node)
345 {
346 wxToolBarTool *tool = (wxToolBarTool *)node->Data();
347 tool->m_longHelpString = helpString;
348 }
349 }
350
351 wxString wxToolBarBase::GetToolLongHelp(int index) const
352 {
353 wxNode *node=m_tools.Find((long)index);
354 if (node)
355 {
356 wxToolBarTool *tool = (wxToolBarTool *)node->Data();
357 return tool->m_longHelpString;
358 }
359 else
360 return wxString("");
361 }
362
363 wxToolBarTool *wxToolBarBase::FindToolForPosition(long x, long y) const
364 {
365 wxNode *node = m_tools.First();
366 while (node)
367 {
368 wxToolBarTool *tool = (wxToolBarTool *)node->Data();
369 if ((x >= tool->m_x) && (y >= tool->m_y) &&
370 (x <= (tool->m_x + tool->GetWidth())) &&
371 (y <= (tool->m_y + tool->GetHeight())))
372 return tool;
373
374 node = node->Next();
375 }
376 return NULL;
377 }
378
379 wxSize wxToolBarBase::GetMaxSize ( void ) const
380 {
381 return wxSize(m_maxWidth, m_maxHeight);
382 }
383
384 // Okay, so we've left the tool we're in ... we must check if
385 // the tool we're leaving was a 'sprung push button' and if so,
386 // spring it back to the up state.
387 //
388 void wxToolBarBase::SetMargins(int x, int y)
389 {
390 m_xMargin = x;
391 m_yMargin = y;
392 }
393
394 void wxToolBarBase::SetToolPacking(int packing)
395 {
396 m_toolPacking = packing;
397 }
398
399 void wxToolBarBase::SetToolSeparation(int separation)
400 {
401 m_toolSeparation = separation;
402 }
403
404 void wxToolBarBase::Command(wxCommandEvent& WXUNUSED(event))
405 {
406 }
407
408 void wxToolBarBase::LayoutTools()
409 {
410 }
411
412
413 // SCROLLING IMPLEMENTATION
414
415 /*
416 * pixelsPerUnitX/pixelsPerUnitY: number of pixels per unit (e.g. pixels per text line)
417 * noUnitsX/noUnitsY: : no. units per scrollbar
418 */
419 void wxToolBarBase::SetScrollbars (int pixelsPerUnitX, int pixelsPerUnitY,
420 int noUnitsX, int noUnitsY,
421 int xPos, int yPos)
422 {
423 m_xScrollPixelsPerLine = pixelsPerUnitX;
424 m_yScrollPixelsPerLine = pixelsPerUnitY;
425 m_xScrollLines = noUnitsX;
426 m_yScrollLines = noUnitsY;
427
428 int w, h;
429 GetSize(&w, &h);
430
431 // Recalculate scroll bar range and position
432 if (m_xScrollLines > 0)
433 {
434 m_xScrollPosition = xPos;
435 SetScrollPos (wxHORIZONTAL, m_xScrollPosition, TRUE);
436 }
437 else
438 {
439 SetScrollbar(wxHORIZONTAL, 0, 0, 0, FALSE);
440 m_xScrollPosition = 0;
441 }
442
443 if (m_yScrollLines > 0)
444 {
445 m_yScrollPosition = yPos;
446 SetScrollPos (wxVERTICAL, m_yScrollPosition, TRUE);
447 }
448 else
449 {
450 SetScrollbar(wxVERTICAL, 0, 0, 0, FALSE);
451 m_yScrollPosition = 0;
452 }
453 AdjustScrollbars();
454 Refresh();
455 #ifdef __WXMSW__
456 ::UpdateWindow ((HWND) GetHWND());
457 #endif
458 }
459
460
461 void wxToolBarBase::OnScroll(wxScrollEvent& event)
462 {
463 int orient = event.GetOrientation();
464
465 int nScrollInc = CalcScrollInc(event);
466 if (nScrollInc == 0)
467 return;
468
469 if (orient == wxHORIZONTAL)
470 {
471 int newPos = m_xScrollPosition + nScrollInc;
472 SetScrollPos(wxHORIZONTAL, newPos, TRUE );
473 }
474 else
475 {
476 int newPos = m_yScrollPosition + nScrollInc;
477 SetScrollPos(wxVERTICAL, newPos, TRUE );
478 }
479
480 if (orient == wxHORIZONTAL)
481 {
482 if (m_xScrollingEnabled)
483 ScrollWindow(-m_xScrollPixelsPerLine * nScrollInc, 0, NULL);
484 else
485 Refresh();
486 }
487 else
488 {
489 if (m_yScrollingEnabled)
490 ScrollWindow(0, -m_yScrollPixelsPerLine * nScrollInc, NULL);
491 else
492 Refresh();
493 }
494
495 if (orient == wxHORIZONTAL)
496 {
497 m_xScrollPosition += nScrollInc;
498 }
499 else
500 {
501 m_yScrollPosition += nScrollInc;
502 }
503
504 }
505
506 int wxToolBarBase::CalcScrollInc(wxScrollEvent& event)
507 {
508 int pos = event.GetPosition();
509 int orient = event.GetOrientation();
510
511 int nScrollInc = 0;
512 switch (event.GetEventType())
513 {
514 case wxEVT_SCROLL_TOP:
515 {
516 if (orient == wxHORIZONTAL)
517 nScrollInc = - m_xScrollPosition;
518 else
519 nScrollInc = - m_yScrollPosition;
520 break;
521 }
522 case wxEVT_SCROLL_BOTTOM:
523 {
524 if (orient == wxHORIZONTAL)
525 nScrollInc = m_xScrollLines - m_xScrollPosition;
526 else
527 nScrollInc = m_yScrollLines - m_yScrollPosition;
528 break;
529 }
530 case wxEVT_SCROLL_LINEUP:
531 {
532 nScrollInc = -1;
533 break;
534 }
535 case wxEVT_SCROLL_LINEDOWN:
536 {
537 nScrollInc = 1;
538 break;
539 }
540 case wxEVT_SCROLL_PAGEUP:
541 {
542 if (orient == wxHORIZONTAL)
543 nScrollInc = -GetScrollPageSize(wxHORIZONTAL);
544 else
545 nScrollInc = -GetScrollPageSize(wxVERTICAL);
546 break;
547 }
548 case wxEVT_SCROLL_PAGEDOWN:
549 {
550 if (orient == wxHORIZONTAL)
551 nScrollInc = GetScrollPageSize(wxHORIZONTAL);
552 else
553 nScrollInc = GetScrollPageSize(wxVERTICAL);
554 break;
555 }
556 case wxEVT_SCROLL_THUMBTRACK:
557 {
558 if (orient == wxHORIZONTAL)
559 nScrollInc = pos - m_xScrollPosition;
560 else
561 nScrollInc = pos - m_yScrollPosition;
562 break;
563 }
564 default:
565 {
566 break;
567 }
568 }
569 if (orient == wxHORIZONTAL)
570 {
571 int w, h;
572 GetClientSize(&w, &h);
573
574 int nMaxWidth = m_xScrollLines*m_xScrollPixelsPerLine;
575 int noPositions = (int) ( ((nMaxWidth - w)/(float)m_xScrollPixelsPerLine) + 0.5 );
576 if (noPositions < 0)
577 noPositions = 0;
578
579 if ( (m_xScrollPosition + nScrollInc) < 0 )
580 nScrollInc = -m_xScrollPosition; // As -ve as we can go
581 else if ( (m_xScrollPosition + nScrollInc) > noPositions )
582 nScrollInc = noPositions - m_xScrollPosition; // As +ve as we can go
583
584 return nScrollInc;
585 }
586 else
587 {
588 int w, h;
589 GetClientSize(&w, &h);
590
591 int nMaxHeight = m_yScrollLines*m_yScrollPixelsPerLine;
592 int noPositions = (int) ( ((nMaxHeight - h)/(float)m_yScrollPixelsPerLine) + 0.5 );
593 if (noPositions < 0)
594 noPositions = 0;
595
596 if ( (m_yScrollPosition + nScrollInc) < 0 )
597 nScrollInc = -m_yScrollPosition; // As -ve as we can go
598 else if ( (m_yScrollPosition + nScrollInc) > noPositions )
599 nScrollInc = noPositions - m_yScrollPosition; // As +ve as we can go
600
601 return nScrollInc;
602 }
603 }
604
605 // Adjust the scrollbars - new version.
606 void wxToolBarBase::AdjustScrollbars()
607 {
608 int w, h;
609 GetClientSize(&w, &h);
610
611 // Recalculate scroll bar range and position
612 if (m_xScrollLines > 0)
613 {
614 int nMaxWidth = m_xScrollLines*m_xScrollPixelsPerLine;
615 int newRange = (int) ( ((nMaxWidth)/(float)m_xScrollPixelsPerLine) + 0.5 );
616 if (newRange < 0)
617 newRange = 0;
618
619 m_xScrollPosition = wxMin(newRange, m_xScrollPosition);
620
621 // Calculate page size i.e. number of scroll units you get on the
622 // current client window
623 int noPagePositions = (int) ( (w/(float)m_xScrollPixelsPerLine) + 0.5 );
624 if (noPagePositions < 1)
625 noPagePositions = 1;
626
627 SetScrollbar(wxHORIZONTAL, m_xScrollPosition, noPagePositions, newRange);
628 SetScrollPageSize(wxHORIZONTAL, noPagePositions);
629 }
630 if (m_yScrollLines > 0)
631 {
632 int nMaxHeight = m_yScrollLines*m_yScrollPixelsPerLine;
633 int newRange = (int) ( ((nMaxHeight)/(float)m_yScrollPixelsPerLine) + 0.5 );
634 if (newRange < 0)
635 newRange = 0;
636
637 m_yScrollPosition = wxMin(newRange, m_yScrollPosition);
638
639 // Calculate page size i.e. number of scroll units you get on the
640 // current client window
641 int noPagePositions = (int) ( (h/(float)m_yScrollPixelsPerLine) + 0.5 );
642 if (noPagePositions < 1)
643 noPagePositions = 1;
644
645 SetScrollbar(wxVERTICAL, m_yScrollPosition, noPagePositions, newRange);
646 SetScrollPageSize(wxVERTICAL, noPagePositions);
647 }
648 }
649
650 // Default OnSize resets scrollbars, if any
651 void wxToolBarBase::OnSize(wxSizeEvent& WXUNUSED(event))
652 {
653 #if wxUSE_CONSTRAINTS
654 if (GetAutoLayout())
655 Layout();
656 #endif
657
658 AdjustScrollbars();
659 }
660
661 // Prepare the DC by translating it according to the current scroll position
662 void wxToolBarBase::PrepareDC(wxDC& dc)
663 {
664 dc.SetDeviceOrigin(- m_xScrollPosition * m_xScrollPixelsPerLine, - m_yScrollPosition * m_yScrollPixelsPerLine);
665 }
666
667 void wxToolBarBase::GetScrollPixelsPerUnit (int *x_unit, int *y_unit) const
668 {
669 *x_unit = m_xScrollPixelsPerLine;
670 *y_unit = m_yScrollPixelsPerLine;
671 }
672
673 int wxToolBarBase::GetScrollPageSize(int orient) const
674 {
675 if ( orient == wxHORIZONTAL )
676 return m_xScrollLinesPerPage;
677 else
678 return m_yScrollLinesPerPage;
679 }
680
681 void wxToolBarBase::SetScrollPageSize(int orient, int pageSize)
682 {
683 if ( orient == wxHORIZONTAL )
684 m_xScrollLinesPerPage = pageSize;
685 else
686 m_yScrollLinesPerPage = pageSize;
687 }
688
689 /*
690 * Scroll to given position (scroll position, not pixel position)
691 */
692 void wxToolBarBase::Scroll (int x_pos, int y_pos)
693 {
694 int old_x, old_y;
695 ViewStart (&old_x, &old_y);
696 if (((x_pos == -1) || (x_pos == old_x)) && ((y_pos == -1) || (y_pos == old_y)))
697 return;
698
699 if (x_pos > -1)
700 {
701 m_xScrollPosition = x_pos;
702 SetScrollPos (wxHORIZONTAL, x_pos, TRUE);
703 }
704 if (y_pos > -1)
705 {
706 m_yScrollPosition = y_pos;
707 SetScrollPos (wxVERTICAL, y_pos, TRUE);
708 }
709 Refresh();
710 #ifdef __WXMSW__
711 UpdateWindow ((HWND) GetHWND());
712 #endif
713 }
714
715 void wxToolBarBase::EnableScrolling (bool x_scroll, bool y_scroll)
716 {
717 m_xScrollingEnabled = x_scroll;
718 m_yScrollingEnabled = y_scroll;
719 }
720
721 void wxToolBarBase::GetVirtualSize (int *x, int *y) const
722 {
723 *x = m_xScrollPixelsPerLine * m_xScrollLines;
724 *y = m_yScrollPixelsPerLine * m_yScrollLines;
725 }
726
727 // Where the current view starts from
728 void wxToolBarBase::ViewStart (int *x, int *y) const
729 {
730 *x = m_xScrollPosition;
731 *y = m_yScrollPosition;
732 }
733
734 void wxToolBarBase::OnIdle(wxIdleEvent&
735 #ifdef __WXGTK__
736 WXUNUSED(event)
737 #else
738 event
739 #endif
740 )
741 {
742 #ifndef __WXGTK__
743 wxWindow::OnIdle(event);
744 #endif
745
746 DoToolbarUpdates();
747 }
748
749 // Do the toolbar button updates (check for EVT_UPDATE_UI handlers)
750 void wxToolBarBase::DoToolbarUpdates()
751 {
752 wxEvtHandler* evtHandler = GetEventHandler() ;
753
754 wxNode* node = GetTools().First();
755 while (node)
756 {
757 wxToolBarTool* tool = (wxToolBarTool* ) node->Data();
758
759 wxUpdateUIEvent event(tool->m_index);
760 event.SetEventObject(this);
761
762 if (evtHandler->ProcessEvent(event))
763 {
764 if (event.GetSetEnabled())
765 EnableTool(tool->m_index, event.GetEnabled());
766 if (event.GetSetChecked())
767 ToggleTool(tool->m_index, event.GetChecked());
768 /*
769 if (event.GetSetText())
770 // Set tooltip?
771 */
772 }
773
774 node = node->Next();
775 }
776 }
777
778 #endif