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