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