Applied patch [ 651640 ] Toolbar sizing fix
[wxWidgets.git] / src / univ / toolbar.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/univ/toolbar.cpp
3 // Purpose: implementation of wxToolBar for wxUniversal
4 // Author: Robert Roebling, Vadim Zeitlin (universalization)
5 // Modified by:
6 // Created: 20.02.02
7 // Id: $Id$
8 // Copyright: (c) 2001 Robert Roebling,
9 // (c) 2002 SciTech Software, Inc. (www.scitechsoft.com)
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
12
13 // ============================================================================
14 // declarations
15 // ============================================================================
16
17 // ----------------------------------------------------------------------------
18 // headers
19 // ----------------------------------------------------------------------------
20
21 #ifdef __GNUG__
22 #pragma implementation "univtoolbar.h"
23 #endif
24
25 // For compilers that support precompilation, includes "wx.h".
26 #include "wx/wxprec.h"
27
28 #ifdef __BORLANDC__
29 #pragma hdrstop
30 #endif
31
32 #if wxUSE_TOOLBAR
33
34 #ifndef WX_PRECOMP
35 #include "wx/utils.h"
36 #include "wx/app.h"
37 #endif
38
39 #include "wx/univ/renderer.h"
40
41 #include "wx/toolbar.h"
42 #include "wx/image.h"
43 #include "wx/log.h"
44
45 // ----------------------------------------------------------------------------
46 // constants
47 // ----------------------------------------------------------------------------
48
49 // value meaning that m_widthSeparator is not initialized
50 static const wxCoord INVALID_WIDTH = -1;
51
52 // ----------------------------------------------------------------------------
53 // wxToolBarTool: our implementation of wxToolBarToolBase
54 // ----------------------------------------------------------------------------
55
56 class WXDLLEXPORT wxToolBarTool : public wxToolBarToolBase
57 {
58 public:
59 wxToolBarTool(wxToolBar *tbar,
60 int id,
61 const wxString& label,
62 const wxBitmap& bmpNormal,
63 const wxBitmap& bmpDisabled,
64 wxItemKind kind,
65 wxObject *clientData,
66 const wxString& shortHelp,
67 const wxString& longHelp)
68 : wxToolBarToolBase(tbar, id, label, bmpNormal, bmpDisabled, kind,
69 clientData, shortHelp, longHelp)
70 {
71 // no position yet
72 m_x =
73 m_y = -1;
74
75 // not pressed yet
76 m_isInverted = FALSE;
77
78 // mouse not here yet
79 m_underMouse = FALSE;
80 }
81
82 // is this tool pressed, even temporarily? (this is different from being
83 // permanently toggled which is what IsToggled() returns)
84 bool IsPressed() const
85 { return CanBeToggled() ? IsToggled() != m_isInverted : m_isInverted; }
86
87 // are we temporarily pressed/unpressed?
88 bool IsInverted() const { return m_isInverted; }
89
90 // press the tool temporarily by inverting its toggle state
91 void Invert() { m_isInverted = !m_isInverted; }
92
93 // Set underMouse
94 void SetUnderMouse( bool under = TRUE ) { m_underMouse = under; }
95 bool IsUnderMouse() { return m_underMouse; }
96
97 public:
98 // the tool position (the size is known by the toolbar itself)
99 int m_x,
100 m_y;
101
102 private:
103 // TRUE if the tool is pressed
104 bool m_isInverted;
105
106 // TRUE if the tool is under the mouse
107 bool m_underMouse;
108 };
109
110 // ============================================================================
111 // wxToolBar implementation
112 // ============================================================================
113
114 IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxControl);
115
116 // ----------------------------------------------------------------------------
117 // wxToolBar creation
118 // ----------------------------------------------------------------------------
119
120 void wxToolBar::Init()
121 {
122 // no tools yet
123 m_needsLayout = FALSE;
124
125 // unknown widths for the tools and separators
126 m_widthSeparator = INVALID_WIDTH;
127
128 m_maxWidth =
129 m_maxHeight = 0;
130
131 wxRenderer *renderer = GetRenderer();
132
133 SetToolBitmapSize(renderer->GetToolBarButtonSize(&m_widthSeparator));
134 SetMargins(renderer->GetToolBarMargin());
135 }
136
137 bool wxToolBar::Create(wxWindow *parent,
138 wxWindowID id,
139 const wxPoint& pos,
140 const wxSize& size,
141 long style,
142 const wxString& name)
143 {
144 if ( !wxToolBarBase::Create(parent, id, pos, size, style,
145 wxDefaultValidator, name) )
146 {
147 return FALSE;
148 }
149
150 CreateInputHandler(wxINP_HANDLER_TOOLBAR);
151
152 SetBestSize(size);
153
154 return TRUE;
155 }
156
157 wxToolBar::~wxToolBar()
158 {
159 // Make sure the toolbar is removed from the parent.
160 SetSize(0,0);
161 }
162
163 void wxToolBar::SetMargins(int x, int y)
164 {
165 // This required for similar visual effects under
166 // native platforms and wxUniv.
167 wxToolBarBase::SetMargins( x + 3, y + 3 );
168 }
169
170 // ----------------------------------------------------------------------------
171 // wxToolBar tool-related methods
172 // ----------------------------------------------------------------------------
173
174 wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord x, wxCoord y) const
175 {
176 // check the "other" direction first: it must be inside the toolbar or we
177 // don't risk finding anything
178 if ( IsVertical() )
179 {
180 if ( x < 0 || x > m_maxWidth )
181 return NULL;
182
183 // we always use x, even for a vertical toolbar, this makes the code
184 // below simpler
185 x = y;
186 }
187 else // horizontal
188 {
189 if ( y < 0 || y > m_maxHeight )
190 return NULL;
191 }
192
193 for ( wxToolBarToolsList::Node *node = m_tools.GetFirst();
194 node;
195 node = node->GetNext() )
196 {
197 wxToolBarToolBase *tool = node->GetData();
198 wxRect rectTool = GetToolRect(tool);
199
200 wxCoord startTool, endTool;
201 GetRectLimits(rectTool, &startTool, &endTool);
202
203 if ( x >= startTool && x <= endTool )
204 {
205 // don't return the separators from here, they don't accept any
206 // input anyhow
207 return tool->IsSeparator() ? NULL : tool;
208 }
209 }
210
211 return NULL;
212 }
213
214 void wxToolBar::SetToolShortHelp(int id, const wxString& help)
215 {
216 wxToolBarToolBase *tool = FindById(id);
217
218 wxCHECK_RET( tool, _T("SetToolShortHelp: no such tool") );
219
220 tool->SetShortHelp(help);
221 }
222
223 bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos),
224 wxToolBarToolBase * WXUNUSED(tool))
225 {
226 // recalculate the toolbar geometry before redrawing it the next time
227 m_needsLayout = TRUE;
228
229 // and ensure that we indeed are going to redraw
230 Refresh();
231
232 return TRUE;
233 }
234
235 bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos),
236 wxToolBarToolBase * WXUNUSED(tool))
237 {
238 // as above
239 m_needsLayout = TRUE;
240
241 Refresh();
242
243 return TRUE;
244 }
245
246 void wxToolBar::DoEnableTool(wxToolBarToolBase *tool, bool enable)
247 {
248 // created disabled-state bitmap on demand
249 if ( !enable && !tool->GetDisabledBitmap().Ok() )
250 {
251 wxImage image( tool->GetNormalBitmap().ConvertToImage() );
252
253 // TODO: don't hardcode 180
254 unsigned char bg_red = 180;
255 unsigned char bg_green = 180;
256 unsigned char bg_blue = 180;
257
258 unsigned char mask_red = image.GetMaskRed();
259 unsigned char mask_green = image.GetMaskGreen();
260 unsigned char mask_blue = image.GetMaskBlue();
261
262 bool has_mask = image.HasMask();
263
264 int x,y;
265 for (y = 0; y < image.GetHeight(); y++)
266 {
267 for (x = 0; x < image.GetWidth(); x++)
268 {
269 unsigned char red = image.GetRed(x,y);
270 unsigned char green = image.GetGreen(x,y);
271 unsigned char blue = image.GetBlue(x,y);
272 if (!has_mask || red != mask_red || green != mask_green || blue != mask_blue)
273 {
274 red = (((wxInt32) red - bg_red) >> 1) + bg_red;
275 green = (((wxInt32) green - bg_green) >> 1) + bg_green;
276 blue = (((wxInt32) blue - bg_blue) >> 1) + bg_blue;
277 image.SetRGB( x, y, red, green, blue );
278 }
279 }
280 }
281
282 for (y = 0; y < image.GetHeight(); y++)
283 {
284 for (x = y % 2; x < image.GetWidth(); x += 2)
285 {
286 unsigned char red = image.GetRed(x,y);
287 unsigned char green = image.GetGreen(x,y);
288 unsigned char blue = image.GetBlue(x,y);
289 if (!has_mask || red != mask_red || green != mask_green || blue != mask_blue)
290 {
291 red = (((wxInt32) red - bg_red) >> 1) + bg_red;
292 green = (((wxInt32) green - bg_green) >> 1) + bg_green;
293 blue = (((wxInt32) blue - bg_blue) >> 1) + bg_blue;
294 image.SetRGB( x, y, red, green, blue );
295 }
296 }
297 }
298
299 tool->SetDisabledBitmap(image);
300 }
301
302 RefreshTool(tool);
303 }
304
305 void wxToolBar::DoToggleTool(wxToolBarToolBase *tool, bool WXUNUSED(toggle))
306 {
307 // note that if we're called the tool did change state (the base class
308 // checks for it), so it's not necessary to check for this again here
309 RefreshTool(tool);
310 }
311
312 void wxToolBar::DoSetToggle(wxToolBarToolBase *tool, bool WXUNUSED(toggle))
313 {
314 RefreshTool(tool);
315 }
316
317 wxToolBarToolBase *wxToolBar::CreateTool(int id,
318 const wxString& label,
319 const wxBitmap& bmpNormal,
320 const wxBitmap& bmpDisabled,
321 wxItemKind kind,
322 wxObject *clientData,
323 const wxString& shortHelp,
324 const wxString& longHelp)
325 {
326 return new wxToolBarTool(this, id, label, bmpNormal, bmpDisabled, kind,
327 clientData, shortHelp, longHelp);
328 }
329
330 wxToolBarToolBase *wxToolBar::CreateTool(wxControl *control)
331 {
332 wxFAIL_MSG( wxT("Toolbar doesn't support controls yet (TODO)") );
333
334 return NULL;
335 }
336
337 // ----------------------------------------------------------------------------
338 // wxToolBar geometry
339 // ----------------------------------------------------------------------------
340
341 wxRect wxToolBar::GetToolRect(wxToolBarToolBase *toolBase) const
342 {
343 const wxToolBarTool *tool = (wxToolBarTool *)toolBase;
344
345 wxRect rect;
346
347 wxCHECK_MSG( tool, rect, _T("GetToolRect: NULL tool") );
348
349 // ensure that we always have the valid tool position
350 if ( m_needsLayout )
351 {
352 wxConstCast(this, wxToolBar)->DoLayout();
353 }
354
355 rect.x = tool->m_x - m_xMargin;
356 rect.y = tool->m_y - m_yMargin;
357
358 if ( IsVertical() )
359 {
360 rect.width = m_defaultWidth;
361 rect.height = tool->IsSeparator() ? m_widthSeparator : m_defaultHeight;
362 }
363 else // horizontal
364 {
365 rect.width = tool->IsSeparator() ? m_widthSeparator : m_defaultWidth;
366 rect.height = m_defaultHeight;
367 }
368
369 rect.width += 2*m_xMargin;
370 rect.height += 2*m_yMargin;
371
372 return rect;
373 }
374
375 bool wxToolBar::Realize()
376 {
377 if ( !wxToolBarBase::Realize() )
378 return FALSE;
379
380 m_needsLayout = TRUE;
381 DoLayout();
382
383 SetBestSize(wxDefaultSize);
384
385 return TRUE;
386 }
387
388 void wxToolBar::DoLayout()
389 {
390 wxASSERT_MSG( m_needsLayout, _T("why are we called?") );
391
392 m_needsLayout = FALSE;
393
394 wxCoord x = m_xMargin,
395 y = m_yMargin;
396
397 const wxCoord widthTool = IsVertical() ? m_defaultHeight : m_defaultWidth;
398 wxCoord margin = IsVertical() ? m_xMargin : m_yMargin,
399 *pCur = IsVertical() ? &y : &x;
400
401 // calculate the positions of all elements
402 for ( wxToolBarToolsList::Node *node = m_tools.GetFirst();
403 node;
404 node = node->GetNext() )
405 {
406 wxToolBarTool *tool = (wxToolBarTool *) node->GetData();
407
408 tool->m_x = x;
409 tool->m_y = y;
410
411 // TODO ugly number fiddling
412 *pCur += ( tool->IsSeparator() ? m_widthSeparator : (widthTool+2) ) + margin;
413 }
414
415 // calculate the total toolbar size
416 wxCoord xMin = m_defaultWidth + 2*m_xMargin,
417 yMin = m_defaultHeight + 2*m_yMargin;
418
419 m_maxWidth = x < xMin ? xMin : x;
420 m_maxHeight = y < yMin ? yMin : y;
421 }
422
423 wxSize wxToolBar::DoGetBestClientSize() const
424 {
425 return wxSize(m_maxWidth, m_maxHeight);
426 }
427
428 void wxToolBar::DoSetSize(int x, int y, int width, int height, int sizeFlags)
429 {
430 int old_width, old_height;
431 GetSize(&old_width, &old_height);
432
433 wxToolBarBase::DoSetSize(x, y, width, height, sizeFlags);
434
435 // Correct width and height if needed.
436 if ( width == -1 || height == -1 )
437 {
438 int tmp_width, tmp_height;
439 GetSize(&tmp_width, &tmp_height);
440
441 if ( width == -1 )
442 width = tmp_width;
443 if ( height == -1 )
444 height = tmp_height;
445 }
446
447 // We must refresh the frame size when the toolbar changes size
448 // otherwise the toolbar can be shown incorrectly
449 if ( old_width != width || old_height != height )
450 {
451 // But before we send the size event check it
452 // we have a frame that is not being deleted.
453 wxFrame *frame = wxDynamicCast(GetParent(), wxFrame);
454 if ( frame && !frame->IsBeingDeleted() )
455 {
456 frame->SendSizeEvent();
457 }
458 }
459 }
460
461 // ----------------------------------------------------------------------------
462 // wxToolBar drawing
463 // ----------------------------------------------------------------------------
464
465 void wxToolBar::RefreshTool(wxToolBarToolBase *tool)
466 {
467 RefreshRect(GetToolRect(tool));
468 }
469
470 void wxToolBar::GetRectLimits(const wxRect& rect,
471 wxCoord *start,
472 wxCoord *end) const
473 {
474 wxCHECK_RET( start && end, _T("NULL pointer in GetRectLimits") );
475
476 if ( IsVertical() )
477 {
478 *start = rect.GetTop();
479 *end = rect.GetBottom();
480 }
481 else // horizontal
482 {
483 *start = rect.GetLeft();
484 *end = rect.GetRight();
485 }
486 }
487
488 void wxToolBar::DoDraw(wxControlRenderer *renderer)
489 {
490 // prepare the variables used below
491 wxDC& dc = renderer->GetDC();
492 wxRenderer *rend = renderer->GetRenderer();
493 // dc.SetFont(GetFont()); -- uncomment when we support labels
494
495 // draw the border separating us from the menubar (if there is no menubar
496 // we probably shouldn't draw it?)
497 if ( !IsVertical() )
498 {
499 rend->DrawHorizontalLine(dc, 0, 0, GetClientSize().x);
500 }
501
502 // get the update rect and its limits depending on the orientation
503 wxRect rectUpdate = GetUpdateClientRect();
504 wxCoord start, end;
505 GetRectLimits(rectUpdate, &start, &end);
506
507 // and redraw all the tools intersecting it
508 for ( wxToolBarToolsList::Node *node = m_tools.GetFirst();
509 node;
510 node = node->GetNext() )
511 {
512 wxToolBarTool *tool = (wxToolBarTool*) node->GetData();
513 wxRect rectTool = GetToolRect(tool);
514 wxCoord startTool, endTool;
515 GetRectLimits(rectTool, &startTool, &endTool);
516
517 if ( endTool < start )
518 {
519 // we're still to the left of the area to redraw
520 continue;
521 }
522
523 if ( startTool > end )
524 {
525 // we're beyond the area to redraw, nothing left to do
526 break;
527 }
528
529 if (tool->IsSeparator() && !HasFlag(wxTB_FLAT))
530 {
531 // Draw seperators only in flat mode
532 continue;
533 }
534
535 // deal with the flags
536 int flags = 0;
537
538 if ( tool->IsEnabled() )
539 {
540 // The toolbars without wxTB_FLAT don't react to the mouse hovering
541 if ( !HasFlag(wxTB_FLAT) || tool->IsUnderMouse() )
542 flags |= wxCONTROL_CURRENT;
543 }
544 else // disabled tool
545 {
546 flags |= wxCONTROL_DISABLED;
547 }
548
549 //if ( tool == m_toolCaptured )
550 // flags |= wxCONTROL_FOCUSED;
551
552 if ( tool->IsPressed() )
553 flags = wxCONTROL_PRESSED;
554
555 wxString label;
556 wxBitmap bitmap;
557 if ( !tool->IsSeparator() )
558 {
559 // label = tool->GetLabel();
560 bitmap = tool->GetBitmap();
561 }
562 //else: leave both the label and the bitmap invalid to draw a separator
563
564 rend->DrawToolBarButton(dc, label, bitmap, rectTool, flags);
565 }
566 }
567
568 // ----------------------------------------------------------------------------
569 // wxToolBar actions
570 // ----------------------------------------------------------------------------
571
572 bool wxToolBar::PerformAction(const wxControlAction& action,
573 long numArg,
574 const wxString& strArg)
575 {
576 wxToolBarTool *tool = (wxToolBarTool*) FindById(numArg);
577
578 if ( action == wxACTION_TOOLBAR_TOGGLE )
579 {
580 PerformAction( wxACTION_BUTTON_RELEASE, numArg );
581
582 PerformAction( wxACTION_BUTTON_CLICK, numArg );
583 }
584 else if ( action == wxACTION_TOOLBAR_PRESS )
585 {
586 wxLogTrace(_T("toolbar"), _T("Button '%s' pressed."), tool->GetShortHelp().c_str());
587
588 tool->Invert();
589
590 RefreshTool( tool );
591 }
592 else if ( action == wxACTION_TOOLBAR_RELEASE )
593 {
594 wxLogTrace(_T("toolbar"), _T("Button '%s' released."), tool->GetShortHelp().c_str());
595
596 wxASSERT_MSG( tool->IsInverted(), _T("release unpressed button?") );
597
598 tool->Invert();
599
600 RefreshTool( tool );
601 }
602 else if ( action == wxACTION_TOOLBAR_CLICK )
603 {
604 bool isToggled;
605 if ( tool->CanBeToggled() )
606 {
607 tool->Toggle();
608
609 RefreshTool( tool );
610
611 isToggled = tool->IsToggled();
612 }
613 else // simple non-checkable tool
614 {
615 isToggled = FALSE;
616 }
617 OnLeftClick( tool->GetId(), isToggled );
618 }
619 else if ( action == wxACTION_TOOLBAR_ENTER )
620 {
621 wxCHECK_MSG( tool, FALSE, _T("no tool to enter?") );
622
623 if ( HasFlag(wxTB_FLAT) && tool->IsEnabled() )
624 {
625 tool->SetUnderMouse( TRUE );
626
627 if ( !tool->IsToggled() )
628 RefreshTool( tool );
629 }
630 }
631 else if ( action == wxACTION_TOOLBAR_LEAVE )
632 {
633 wxCHECK_MSG( tool, FALSE, _T("no tool to leave?") );
634
635 if ( HasFlag(wxTB_FLAT) && tool->IsEnabled() )
636 {
637 tool->SetUnderMouse( FALSE );
638
639 if ( !tool->IsToggled() )
640 RefreshTool( tool );
641 }
642 }
643 else
644 return wxControl::PerformAction(action, numArg, strArg);
645
646 return TRUE;
647 }
648
649 // ============================================================================
650 // wxStdToolbarInputHandler implementation
651 // ============================================================================
652
653 wxStdToolbarInputHandler::wxStdToolbarInputHandler(wxInputHandler *handler)
654 : wxStdInputHandler(handler)
655 {
656 m_winCapture = NULL;
657 m_toolCapture = NULL;
658 m_toolLast = NULL;
659 }
660
661 bool wxStdToolbarInputHandler::HandleKey(wxInputConsumer *consumer,
662 const wxKeyEvent& event,
663 bool pressed)
664 {
665 // TODO: when we have a current button we should allow the arrow
666 // keys to move it
667 return wxStdInputHandler::HandleKey(consumer, event, pressed);
668 }
669
670 bool wxStdToolbarInputHandler::HandleMouse(wxInputConsumer *consumer,
671 const wxMouseEvent& event)
672 {
673 wxToolBar *tbar = wxStaticCast(consumer->GetInputWindow(), wxToolBar);
674 wxToolBarToolBase *tool = tbar->FindToolForPosition(event.GetX(), event.GetY());
675
676 if ( event.Button(1) )
677 {
678
679 if ( event.LeftDown() || event.LeftDClick() )
680 {
681 if ( !tool || !tool->IsEnabled() )
682 return TRUE;
683
684 m_winCapture = tbar;
685 m_winCapture->CaptureMouse();
686
687 m_toolCapture = tool;
688
689 consumer->PerformAction( wxACTION_BUTTON_PRESS, tool->GetId() );
690
691 return TRUE;
692 }
693 else if ( event.LeftUp() )
694 {
695 if ( m_winCapture )
696 {
697 m_winCapture->ReleaseMouse();
698 m_winCapture = NULL;
699 }
700
701 if (m_toolCapture)
702 {
703 if ( tool == m_toolCapture )
704 consumer->PerformAction( wxACTION_BUTTON_TOGGLE, m_toolCapture->GetId() );
705 else
706 consumer->PerformAction( wxACTION_TOOLBAR_LEAVE, m_toolCapture->GetId() );
707 }
708
709 m_toolCapture = NULL;
710
711 return TRUE;
712 }
713 //else: don't do anything special about the double click
714 }
715
716 return wxStdInputHandler::HandleMouse(consumer, event);
717 }
718
719 bool wxStdToolbarInputHandler::HandleMouseMove(wxInputConsumer *consumer,
720 const wxMouseEvent& event)
721 {
722 if ( !wxStdInputHandler::HandleMouseMove(consumer, event) )
723 {
724 wxToolBar *tbar = wxStaticCast(consumer->GetInputWindow(), wxToolBar);
725
726 wxToolBarTool *tool;
727 if ( event.Leaving() )
728 {
729 // We cannot possibly be over a tool when
730 // leaving the toolbar
731 tool = NULL;
732 }
733 else
734 {
735 tool = (wxToolBarTool*) tbar->FindToolForPosition( event.GetX(), event.GetY() );
736 }
737
738 if (m_toolCapture)
739 {
740 // During capture we only care of the captured tool
741 if (tool && (tool != m_toolCapture))
742 tool = NULL;
743
744 if (tool == m_toolLast)
745 return TRUE;
746
747 if (tool)
748 consumer->PerformAction( wxACTION_BUTTON_PRESS, m_toolCapture->GetId() );
749 else
750 consumer->PerformAction( wxACTION_BUTTON_RELEASE, m_toolCapture->GetId() );
751
752 m_toolLast = tool;
753 }
754 else
755 {
756 if (tool == m_toolLast)
757 return TRUE;
758
759 if (m_toolLast)
760 {
761 // Leave old tool if any
762 consumer->PerformAction( wxACTION_TOOLBAR_LEAVE, m_toolLast->GetId() );
763 }
764
765 if (tool)
766 {
767 // Enter new tool if any
768 consumer->PerformAction( wxACTION_TOOLBAR_ENTER, tool->GetId() );
769 }
770
771 m_toolLast = tool;
772 }
773
774 return TRUE;
775 }
776
777 return FALSE;
778 }
779
780 bool wxStdToolbarInputHandler::HandleFocus(wxInputConsumer *consumer,
781 const wxFocusEvent& event)
782 {
783 if (m_toolCapture)
784 {
785 // We shouldn't be left with a highlighted button
786 consumer->PerformAction( wxACTION_TOOLBAR_LEAVE, m_toolCapture->GetId() );
787 }
788
789 return TRUE;
790 }
791
792 bool wxStdToolbarInputHandler::HandleActivation(wxInputConsumer *consumer,
793 bool activated)
794 {
795 if (m_toolCapture && !activated)
796 {
797 // We shouldn't be left with a highlighted button
798 consumer->PerformAction( wxACTION_TOOLBAR_LEAVE, m_toolCapture->GetId() );
799 }
800
801 return TRUE;
802 }
803
804 #endif // wxUSE_TOOLBAR
805