1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/univ/toolbar.cpp
3 // Purpose: implementation of wxToolBar for wxUniversal
4 // Author: Robert Roebling, Vadim Zeitlin (universalization)
8 // Copyright: (c) 2001 Robert Roebling,
9 // (c) 2002 SciTech Software, Inc. (www.scitechsoft.com)
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
13 // ============================================================================
15 // ============================================================================
17 // ----------------------------------------------------------------------------
19 // ----------------------------------------------------------------------------
21 // For compilers that support precompilation, includes "wx.h".
22 #include "wx/wxprec.h"
30 #include "wx/toolbar.h"
41 #include "wx/univ/renderer.h"
43 // ----------------------------------------------------------------------------
44 // wxStdToolbarInputHandler: translates SPACE and ENTER keys and the left mouse
45 // click into button press/release actions
46 // ----------------------------------------------------------------------------
48 class WXDLLEXPORT wxStdToolbarInputHandler
: public wxStdInputHandler
51 wxStdToolbarInputHandler(wxInputHandler
*inphand
);
53 virtual bool HandleKey(wxInputConsumer
*consumer
,
54 const wxKeyEvent
& event
,
56 virtual bool HandleMouse(wxInputConsumer
*consumer
,
57 const wxMouseEvent
& event
);
58 virtual bool HandleMouseMove(wxInputConsumer
*consumer
, const wxMouseEvent
& event
);
59 virtual bool HandleFocus(wxInputConsumer
*consumer
, const wxFocusEvent
& event
);
60 virtual bool HandleActivation(wxInputConsumer
*consumer
, bool activated
);
63 wxWindow
*m_winCapture
;
64 wxToolBarToolBase
*m_toolCapture
;
65 wxToolBarToolBase
*m_toolLast
;
68 // ----------------------------------------------------------------------------
70 // ----------------------------------------------------------------------------
72 // value meaning that m_widthSeparator is not initialized
73 static const wxCoord INVALID_WIDTH
= wxDefaultCoord
;
75 // ----------------------------------------------------------------------------
76 // wxToolBarTool: our implementation of wxToolBarToolBase
77 // ----------------------------------------------------------------------------
79 class WXDLLEXPORT wxToolBarTool
: public wxToolBarToolBase
82 wxToolBarTool(wxToolBar
*tbar
,
84 const wxString
& label
,
85 const wxBitmap
& bmpNormal
,
86 const wxBitmap
& bmpDisabled
,
89 const wxString
& shortHelp
,
90 const wxString
& longHelp
)
91 : wxToolBarToolBase(tbar
, id
, label
, bmpNormal
, bmpDisabled
, kind
,
92 clientData
, shortHelp
, longHelp
)
101 m_isInverted
= false;
103 // mouse not here yet
104 m_underMouse
= false;
107 wxToolBarTool(wxToolBar
*tbar
, wxControl
*control
)
108 : wxToolBarToolBase(tbar
, control
)
112 m_y
= wxDefaultCoord
;
117 m_isInverted
= false;
119 // mouse not here yet
120 m_underMouse
= false;
123 // is this tool pressed, even temporarily? (this is different from being
124 // permanently toggled which is what IsToggled() returns)
125 bool IsPressed() const
126 { return CanBeToggled() ? IsToggled() != m_isInverted
: m_isInverted
; }
128 // are we temporarily pressed/unpressed?
129 bool IsInverted() const { return m_isInverted
; }
131 // press the tool temporarily by inverting its toggle state
132 void Invert() { m_isInverted
= !m_isInverted
; }
135 void SetUnderMouse( bool under
= true ) { m_underMouse
= under
; }
136 bool IsUnderMouse() { return m_underMouse
; }
139 // the tool position (for controls)
146 // true if the tool is pressed
149 // true if the tool is under the mouse
153 // ============================================================================
154 // wxToolBar implementation
155 // ============================================================================
157 IMPLEMENT_DYNAMIC_CLASS(wxToolBar
, wxControl
)
159 // ----------------------------------------------------------------------------
160 // wxToolBar creation
161 // ----------------------------------------------------------------------------
163 void wxToolBar::Init()
166 m_needsLayout
= false;
168 // unknown widths for the tools and separators
169 m_widthSeparator
= INVALID_WIDTH
;
174 wxRenderer
*renderer
= GetRenderer();
176 SetToolBitmapSize(renderer
->GetToolBarButtonSize(&m_widthSeparator
));
177 SetMargins(renderer
->GetToolBarMargin());
180 bool wxToolBar::Create(wxWindow
*parent
,
185 const wxString
& name
)
187 if ( !wxToolBarBase::Create(parent
, id
, pos
, size
, style
,
188 wxDefaultValidator
, name
) )
193 CreateInputHandler(wxINP_HANDLER_TOOLBAR
);
200 wxToolBar::~wxToolBar()
202 // Make sure the toolbar is removed from the parent.
206 void wxToolBar::SetMargins(int x
, int y
)
208 // This required for similar visual effects under
209 // native platforms and wxUniv.
210 wxToolBarBase::SetMargins( x
+ 3, y
+ 3 );
213 // ----------------------------------------------------------------------------
214 // wxToolBar tool-related methods
215 // ----------------------------------------------------------------------------
217 wxToolBarToolBase
*wxToolBar::FindToolForPosition(wxCoord x
, wxCoord y
) const
219 // check the "other" direction first: it must be inside the toolbar or we
220 // don't risk finding anything
223 if ( x
< 0 || x
> m_maxWidth
)
226 // we always use x, even for a vertical toolbar, this makes the code
232 if ( y
< 0 || y
> m_maxHeight
)
236 for ( wxToolBarToolsList::compatibility_iterator node
= m_tools
.GetFirst();
238 node
= node
->GetNext() )
240 wxToolBarToolBase
*tool
= node
->GetData();
241 wxRect rectTool
= GetToolRect(tool
);
243 wxCoord startTool
, endTool
;
244 GetRectLimits(rectTool
, &startTool
, &endTool
);
246 if ( x
>= startTool
&& x
<= endTool
)
248 // don't return the separators from here, they don't accept any
250 return tool
->IsSeparator() ? NULL
: tool
;
257 void wxToolBar::SetToolShortHelp(int id
, const wxString
& help
)
259 wxToolBarToolBase
*tool
= FindById(id
);
261 wxCHECK_RET( tool
, _T("SetToolShortHelp: no such tool") );
263 tool
->SetShortHelp(help
);
266 bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos
),
267 wxToolBarToolBase
* WXUNUSED(tool
))
269 // recalculate the toolbar geometry before redrawing it the next time
270 m_needsLayout
= true;
272 // and ensure that we indeed are going to redraw
278 bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos
),
279 wxToolBarToolBase
* WXUNUSED(tool
))
282 m_needsLayout
= true;
289 void wxToolBar::DoEnableTool(wxToolBarToolBase
*tool
, bool enable
)
291 // created disabled-state bitmap on demand
292 if ( !enable
&& !tool
->GetDisabledBitmap().Ok() )
294 wxImage
image( tool
->GetNormalBitmap().ConvertToImage() );
296 // TODO: don't hardcode 180
297 unsigned char bg_red
= 180;
298 unsigned char bg_green
= 180;
299 unsigned char bg_blue
= 180;
301 unsigned char mask_red
= image
.GetMaskRed();
302 unsigned char mask_green
= image
.GetMaskGreen();
303 unsigned char mask_blue
= image
.GetMaskBlue();
305 bool has_mask
= image
.HasMask();
308 for (y
= 0; y
< image
.GetHeight(); y
++)
310 for (x
= 0; x
< image
.GetWidth(); x
++)
312 unsigned char red
= image
.GetRed(x
,y
);
313 unsigned char green
= image
.GetGreen(x
,y
);
314 unsigned char blue
= image
.GetBlue(x
,y
);
315 if (!has_mask
|| red
!= mask_red
|| green
!= mask_green
|| blue
!= mask_blue
)
317 red
= (unsigned char)((((wxInt32
) red
- bg_red
) >> 1) + bg_red
);
318 green
= (unsigned char)((((wxInt32
) green
- bg_green
) >> 1) + bg_green
);
319 blue
= (unsigned char)((((wxInt32
) blue
- bg_blue
) >> 1) + bg_blue
);
320 image
.SetRGB( x
, y
, red
, green
, blue
);
325 for (y
= 0; y
< image
.GetHeight(); y
++)
327 for (x
= y
% 2; x
< image
.GetWidth(); x
+= 2)
329 unsigned char red
= image
.GetRed(x
,y
);
330 unsigned char green
= image
.GetGreen(x
,y
);
331 unsigned char blue
= image
.GetBlue(x
,y
);
332 if (!has_mask
|| red
!= mask_red
|| green
!= mask_green
|| blue
!= mask_blue
)
334 red
= (unsigned char)((((wxInt32
) red
- bg_red
) >> 1) + bg_red
);
335 green
= (unsigned char)((((wxInt32
) green
- bg_green
) >> 1) + bg_green
);
336 blue
= (unsigned char)((((wxInt32
) blue
- bg_blue
) >> 1) + bg_blue
);
337 image
.SetRGB( x
, y
, red
, green
, blue
);
342 tool
->SetDisabledBitmap(image
);
348 void wxToolBar::DoToggleTool(wxToolBarToolBase
*tool
, bool WXUNUSED(toggle
))
350 // note that if we're called the tool did change state (the base class
351 // checks for it), so it's not necessary to check for this again here
355 void wxToolBar::DoSetToggle(wxToolBarToolBase
*tool
, bool WXUNUSED(toggle
))
360 wxToolBarToolBase
*wxToolBar::CreateTool(int id
,
361 const wxString
& label
,
362 const wxBitmap
& bmpNormal
,
363 const wxBitmap
& bmpDisabled
,
365 wxObject
*clientData
,
366 const wxString
& shortHelp
,
367 const wxString
& longHelp
)
369 return new wxToolBarTool(this, id
, label
, bmpNormal
, bmpDisabled
, kind
,
370 clientData
, shortHelp
, longHelp
);
373 wxToolBarToolBase
*wxToolBar::CreateTool(wxControl
*control
)
375 return new wxToolBarTool(this, control
);
378 // ----------------------------------------------------------------------------
379 // wxToolBar geometry
380 // ----------------------------------------------------------------------------
382 wxRect
wxToolBar::GetToolRect(wxToolBarToolBase
*toolBase
) const
384 const wxToolBarTool
*tool
= (wxToolBarTool
*)toolBase
;
388 wxCHECK_MSG( tool
, rect
, _T("GetToolRect: NULL tool") );
390 // ensure that we always have the valid tool position
393 wxConstCast(this, wxToolBar
)->DoLayout();
396 rect
.x
= tool
->m_x
- m_xMargin
;
397 rect
.y
= tool
->m_y
- m_yMargin
;
401 if (tool
->IsButton())
403 if(!HasFlag(wxTB_TEXT
))
405 rect
.width
= m_defaultWidth
;
406 rect
.height
= m_defaultHeight
;
410 rect
.width
= m_defaultWidth
+
411 GetFont().GetPointSize() * tool
->GetLabel().length();
412 rect
.height
= m_defaultHeight
;
415 else if (tool
->IsSeparator())
417 rect
.width
= m_defaultWidth
;
418 rect
.height
= m_widthSeparator
;
422 rect
.width
= tool
->m_width
;
423 rect
.height
= tool
->m_height
;
428 if (tool
->IsButton())
430 if(!HasFlag(wxTB_TEXT
))
432 rect
.width
= m_defaultWidth
;
433 rect
.height
= m_defaultHeight
;
437 rect
.width
= m_defaultWidth
+
438 GetFont().GetPointSize() * tool
->GetLabel().length();
439 rect
.height
= m_defaultHeight
;
442 else if (tool
->IsSeparator())
444 rect
.width
= m_widthSeparator
;
445 rect
.height
= m_defaultHeight
;
449 rect
.width
= tool
->m_width
;
450 rect
.height
= tool
->m_height
;
454 rect
.width
+= 2*m_xMargin
;
455 rect
.height
+= 2*m_yMargin
;
460 bool wxToolBar::Realize()
462 if ( !wxToolBarBase::Realize() )
465 m_needsLayout
= true;
468 SetBestSize(wxDefaultSize
);
473 void wxToolBar::SetWindowStyleFlag( long style
)
475 wxToolBarBase::SetWindowStyleFlag(style
);
477 m_needsLayout
= true;
482 void wxToolBar::DoLayout()
484 wxASSERT_MSG( m_needsLayout
, _T("why are we called?") );
486 m_needsLayout
= false;
488 wxCoord x
= m_xMargin
,
491 wxCoord widthTool
= 0, maxWidthTool
= 0;
492 wxCoord heightTool
= 0, maxHeightTool
= 0;
493 wxCoord margin
= IsVertical() ? m_xMargin
: m_yMargin
;
494 wxCoord
*pCur
= IsVertical() ? &y
: &x
;
496 // calculate the positions of all elements
497 for ( wxToolBarToolsList::compatibility_iterator node
= m_tools
.GetFirst();
499 node
= node
->GetNext() )
501 wxToolBarTool
*tool
= (wxToolBarTool
*) node
->GetData();
506 // TODO ugly number fiddling
507 if (tool
->IsButton())
511 widthTool
= m_defaultHeight
;
512 heightTool
= m_defaultWidth
;
513 if(HasFlag(wxTB_TEXT
))
514 heightTool
+= GetFont().GetPointSize() * tool
->GetLabel().length();
518 widthTool
= m_defaultWidth
;
519 if(HasFlag(wxTB_TEXT
))
520 widthTool
+= GetFont().GetPointSize() * tool
->GetLabel().length();
522 heightTool
= m_defaultHeight
;
525 if(widthTool
> maxWidthTool
) // Record max width of tool
527 maxWidthTool
= widthTool
;
530 if(heightTool
> maxHeightTool
) // Record max width of tool
532 maxHeightTool
= heightTool
;
537 else if (tool
->IsSeparator())
539 *pCur
+= m_widthSeparator
;
541 else if (!IsVertical()) // horizontal control
543 wxControl
*control
= tool
->GetControl();
544 wxSize size
= control
->GetSize();
545 tool
->m_y
+= (m_defaultHeight
- size
.y
)/2;
546 tool
->m_width
= size
.x
;
547 tool
->m_height
= size
.y
;
549 *pCur
+= tool
->m_width
;
554 // calculate the total toolbar size
557 if(!HasFlag(wxTB_TEXT
))
559 xMin
= m_defaultWidth
+ 2*m_xMargin
;
560 yMin
= m_defaultHeight
+ 2*m_yMargin
;
566 xMin
= heightTool
+ 2*m_xMargin
;
567 yMin
= widthTool
+ 2*m_xMargin
;
571 xMin
= maxWidthTool
+ 2*m_xMargin
;
572 yMin
= heightTool
+ 2*m_xMargin
;
576 m_maxWidth
= x
< xMin
? xMin
: x
;
577 m_maxHeight
= y
< yMin
? yMin
: y
;
580 wxSize
wxToolBar::DoGetBestClientSize() const
582 return wxSize(m_maxWidth
, m_maxHeight
);
585 void wxToolBar::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
587 int old_width
, old_height
;
588 GetSize(&old_width
, &old_height
);
590 wxToolBarBase::DoSetSize(x
, y
, width
, height
, sizeFlags
);
592 // Correct width and height if needed.
593 if ( width
== wxDefaultCoord
|| height
== wxDefaultCoord
)
595 int tmp_width
, tmp_height
;
596 GetSize(&tmp_width
, &tmp_height
);
598 if ( width
== wxDefaultCoord
)
600 if ( height
== wxDefaultCoord
)
604 // We must refresh the frame size when the toolbar changes size
605 // otherwise the toolbar can be shown incorrectly
606 if ( old_width
!= width
|| old_height
!= height
)
608 // But before we send the size event check it
609 // we have a frame that is not being deleted.
610 wxFrame
*frame
= wxDynamicCast(GetParent(), wxFrame
);
611 if ( frame
&& !frame
->IsBeingDeleted() )
613 frame
->SendSizeEvent();
618 // ----------------------------------------------------------------------------
620 // ----------------------------------------------------------------------------
622 void wxToolBar::RefreshTool(wxToolBarToolBase
*tool
)
624 RefreshRect(GetToolRect(tool
));
627 void wxToolBar::GetRectLimits(const wxRect
& rect
,
631 wxCHECK_RET( start
&& end
, _T("NULL pointer in GetRectLimits") );
635 *start
= rect
.GetTop();
636 *end
= rect
.GetBottom();
640 *start
= rect
.GetLeft();
641 *end
= rect
.GetRight();
645 void wxToolBar::DoDraw(wxControlRenderer
*renderer
)
647 // prepare the variables used below
648 wxDC
& dc
= renderer
->GetDC();
649 wxRenderer
*rend
= renderer
->GetRenderer();
650 dc
.SetFont(GetFont());
652 // draw the border separating us from the menubar (if there is no menubar
653 // we probably shouldn't draw it?)
656 rend
->DrawHorizontalLine(dc
, 0, 0, GetClientSize().x
);
659 // get the update rect and its limits depending on the orientation
660 wxRect rectUpdate
= GetUpdateClientRect();
662 GetRectLimits(rectUpdate
, &start
, &end
);
664 // and redraw all the tools intersecting it
665 for ( wxToolBarToolsList::compatibility_iterator node
= m_tools
.GetFirst();
667 node
= node
->GetNext() )
669 wxToolBarTool
*tool
= (wxToolBarTool
*) node
->GetData();
670 wxRect rectTool
= GetToolRect(tool
);
671 wxCoord startTool
, endTool
;
672 GetRectLimits(rectTool
, &startTool
, &endTool
);
674 if ( endTool
< start
)
676 // we're still to the left of the area to redraw
680 if ( startTool
> end
)
682 // we're beyond the area to redraw, nothing left to do
686 if (tool
->IsSeparator() && !HasFlag(wxTB_FLAT
))
688 // Draw separators only in flat mode
692 // deal with the flags
695 if ( tool
->IsEnabled() )
697 // The toolbars without wxTB_FLAT don't react to the mouse hovering
698 if ( !HasFlag(wxTB_FLAT
) || tool
->IsUnderMouse() )
699 flags
|= wxCONTROL_CURRENT
;
701 else // disabled tool
703 flags
|= wxCONTROL_DISABLED
;
706 //if ( tool == m_toolCaptured )
707 // flags |= wxCONTROL_FOCUSED;
709 if ( tool
->IsPressed() )
710 flags
= wxCONTROL_PRESSED
;
714 if ( !tool
->IsSeparator() )
716 label
= tool
->GetLabel();
717 bitmap
= tool
->GetBitmap();
719 //else: leave both the label and the bitmap invalid to draw a separator
721 if ( !tool
->IsControl() )
724 if(HasFlag(wxTB_TEXT
))
726 tbStyle
|= wxTB_TEXT
;
729 if(HasFlag(wxTB_VERTICAL
))
731 tbStyle
|= wxTB_VERTICAL
;
735 tbStyle
|= wxTB_HORIZONTAL
;
737 rend
->DrawToolBarButton(dc
, label
, bitmap
, rectTool
, flags
, tool
->GetStyle(), tbStyle
);
741 wxControl
*control
= tool
->GetControl();
742 control
->Move(tool
->m_x
, tool
->m_y
);
747 // ----------------------------------------------------------------------------
749 // ----------------------------------------------------------------------------
751 bool wxToolBar::PerformAction(const wxControlAction
& action
,
753 const wxString
& strArg
)
755 wxToolBarTool
*tool
= (wxToolBarTool
*) FindById(numArg
);
759 if ( action
== wxACTION_TOOLBAR_TOGGLE
)
761 PerformAction( wxACTION_BUTTON_RELEASE
, numArg
);
763 PerformAction( wxACTION_BUTTON_CLICK
, numArg
);
765 // Write by Danny Raynor to change state again.
766 // Check button still pressed or not
767 if ( tool
->CanBeToggled() && tool
->IsToggled() )
772 if( tool
->IsInverted() )
774 PerformAction( wxACTION_TOOLBAR_RELEASE
, numArg
);
777 // Set mouse leave toolbar button range (If still in the range,
778 // toolbar button would get focus again
779 PerformAction( wxACTION_TOOLBAR_LEAVE
, numArg
);
781 else if ( action
== wxACTION_TOOLBAR_PRESS
)
783 wxLogTrace(_T("toolbar"), _T("Button '%s' pressed."), tool
->GetShortHelp().c_str());
789 else if ( action
== wxACTION_TOOLBAR_RELEASE
)
791 wxLogTrace(_T("toolbar"), _T("Button '%s' released."), tool
->GetShortHelp().c_str());
793 wxASSERT_MSG( tool
->IsInverted(), _T("release unpressed button?") );
799 else if ( action
== wxACTION_TOOLBAR_CLICK
)
802 if ( tool
->CanBeToggled() )
808 isToggled
= tool
->IsToggled();
810 else // simple non-checkable tool
814 OnLeftClick( tool
->GetId(), isToggled
);
816 else if ( action
== wxACTION_TOOLBAR_ENTER
)
818 wxCHECK_MSG( tool
, false, _T("no tool to enter?") );
820 if ( HasFlag(wxTB_FLAT
) && tool
->IsEnabled() )
822 tool
->SetUnderMouse( true );
824 if ( !tool
->IsToggled() )
828 else if ( action
== wxACTION_TOOLBAR_LEAVE
)
830 wxCHECK_MSG( tool
, false, _T("no tool to leave?") );
832 if ( HasFlag(wxTB_FLAT
) && tool
->IsEnabled() )
834 tool
->SetUnderMouse( false );
836 if ( !tool
->IsToggled() )
841 return wxControl::PerformAction(action
, numArg
, strArg
);
847 wxInputHandler
*wxToolBar::GetStdInputHandler(wxInputHandler
*handlerDef
)
849 static wxStdToolbarInputHandler
s_handler(handlerDef
);
854 // ============================================================================
855 // wxStdToolbarInputHandler implementation
856 // ============================================================================
858 wxStdToolbarInputHandler::wxStdToolbarInputHandler(wxInputHandler
*handler
)
859 : wxStdInputHandler(handler
)
862 m_toolCapture
= NULL
;
866 bool wxStdToolbarInputHandler::HandleKey(wxInputConsumer
*consumer
,
867 const wxKeyEvent
& event
,
870 // TODO: when we have a current button we should allow the arrow
872 return wxStdInputHandler::HandleKey(consumer
, event
, pressed
);
875 bool wxStdToolbarInputHandler::HandleMouse(wxInputConsumer
*consumer
,
876 const wxMouseEvent
& event
)
878 wxToolBar
*tbar
= wxStaticCast(consumer
->GetInputWindow(), wxToolBar
);
879 wxToolBarToolBase
*tool
= tbar
->FindToolForPosition(event
.GetX(), event
.GetY());
881 if ( event
.Button(1) )
884 if ( event
.LeftDown() || event
.LeftDClick() )
886 if ( !tool
|| !tool
->IsEnabled() )
890 m_winCapture
->CaptureMouse();
892 m_toolCapture
= tool
;
894 consumer
->PerformAction( wxACTION_BUTTON_PRESS
, tool
->GetId() );
898 else if ( event
.LeftUp() )
902 m_winCapture
->ReleaseMouse();
908 if ( tool
== m_toolCapture
)
909 consumer
->PerformAction( wxACTION_BUTTON_TOGGLE
, m_toolCapture
->GetId() );
911 consumer
->PerformAction( wxACTION_TOOLBAR_LEAVE
, m_toolCapture
->GetId() );
914 m_toolCapture
= NULL
;
918 //else: don't do anything special about the double click
921 return wxStdInputHandler::HandleMouse(consumer
, event
);
924 bool wxStdToolbarInputHandler::HandleMouseMove(wxInputConsumer
*consumer
,
925 const wxMouseEvent
& event
)
927 if ( !wxStdInputHandler::HandleMouseMove(consumer
, event
) )
929 wxToolBar
*tbar
= wxStaticCast(consumer
->GetInputWindow(), wxToolBar
);
932 if ( event
.Leaving() )
934 // We cannot possibly be over a tool when
935 // leaving the toolbar
940 tool
= (wxToolBarTool
*) tbar
->FindToolForPosition( event
.GetX(), event
.GetY() );
945 // During capture we only care of the captured tool
946 if (tool
&& (tool
!= m_toolCapture
))
949 if (tool
== m_toolLast
)
953 consumer
->PerformAction( wxACTION_BUTTON_PRESS
, m_toolCapture
->GetId() );
955 consumer
->PerformAction( wxACTION_BUTTON_RELEASE
, m_toolCapture
->GetId() );
961 if (tool
== m_toolLast
)
966 // Leave old tool if any
967 consumer
->PerformAction( wxACTION_TOOLBAR_LEAVE
, m_toolLast
->GetId() );
972 // Enter new tool if any
973 consumer
->PerformAction( wxACTION_TOOLBAR_ENTER
, tool
->GetId() );
985 bool wxStdToolbarInputHandler::HandleFocus(wxInputConsumer
*consumer
,
986 const wxFocusEvent
& WXUNUSED(event
))
990 // We shouldn't be left with a highlighted button
991 consumer
->PerformAction( wxACTION_TOOLBAR_LEAVE
, m_toolCapture
->GetId() );
997 bool wxStdToolbarInputHandler::HandleActivation(wxInputConsumer
*consumer
,
1000 if (m_toolCapture
&& !activated
)
1002 // We shouldn't be left with a highlighted button
1003 consumer
->PerformAction( wxACTION_TOOLBAR_LEAVE
, m_toolCapture
->GetId() );
1009 #endif // wxUSE_TOOLBAR