1 ///////////////////////////////////////////////////////////////////////////////
3 // Name: src/aui/dockart.cpp
4 // Purpose: wxaui: wx advanced user interface - docking window manager
5 // Author: Benjamin I. Williams
9 // Copyright: (C) Copyright 2005-2006, Kirix Corporation, All Rights Reserved
10 // Licence: wxWindows Library Licence, Version 3.1
11 ///////////////////////////////////////////////////////////////////////////////
13 // ============================================================================
15 // ============================================================================
17 // ----------------------------------------------------------------------------
19 // ----------------------------------------------------------------------------
21 #include "wx/wxprec.h"
29 #include "wx/statline.h"
30 #include "wx/dcbuffer.h"
33 #include "wx/settings.h"
36 #include "wx/aui/auibar.h"
37 #include "wx/aui/framemanager.h"
40 #include "wx/osx/private.h"
41 // for themeing support
42 #include <Carbon/Carbon.h>
45 #include "wx/arrimpl.cpp"
46 WX_DEFINE_OBJARRAY(wxAuiToolBarItemArray
)
49 wxDEFINE_EVENT( wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN
, wxAuiToolBarEvent
);
50 wxDEFINE_EVENT( wxEVT_COMMAND_AUITOOLBAR_OVERFLOW_CLICK
, wxAuiToolBarEvent
);
51 wxDEFINE_EVENT( wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK
, wxAuiToolBarEvent
);
52 wxDEFINE_EVENT( wxEVT_COMMAND_AUITOOLBAR_MIDDLE_CLICK
, wxAuiToolBarEvent
);
53 wxDEFINE_EVENT( wxEVT_COMMAND_AUITOOLBAR_BEGIN_DRAG
, wxAuiToolBarEvent
);
56 IMPLEMENT_CLASS(wxAuiToolBar
, wxControl
)
57 IMPLEMENT_DYNAMIC_CLASS(wxAuiToolBarEvent
, wxEvent
)
60 // missing wxITEM_* items
63 wxITEM_CONTROL
= wxITEM_MAX
,
68 const int BUTTON_DROPDOWN_WIDTH
= 10;
71 wxBitmap
wxAuiBitmapFromBits(const unsigned char bits
[], int w
, int h
,
72 const wxColour
& color
);
74 unsigned char wxAuiBlendColour(unsigned char fg
, unsigned char bg
, double alpha
);
75 wxColor
wxAuiStepColour(const wxColor
& c
, int percent
);
77 static wxBitmap
MakeDisabledBitmap(wxBitmap
& bmp
)
79 wxImage image
= bmp
.ConvertToImage();
82 mr
= image
.GetMaskRed();
83 mg
= image
.GetMaskGreen();
84 mb
= image
.GetMaskBlue();
86 unsigned char* data
= image
.GetData();
87 int width
= image
.GetWidth();
88 int height
= image
.GetHeight();
89 bool has_mask
= image
.HasMask();
91 for (int y
= height
-1; y
>= 0; --y
)
93 for (int x
= width
-1; x
>= 0; --x
)
95 data
= image
.GetData() + (y
*(width
*3))+(x
*3);
96 unsigned char* r
= data
;
97 unsigned char* g
= data
+1;
98 unsigned char* b
= data
+2;
100 if (has_mask
&& *r
== mr
&& *g
== mg
&& *b
== mb
)
103 *r
= wxAuiBlendColour(*r
, 255, 0.4);
104 *g
= wxAuiBlendColour(*g
, 255, 0.4);
105 *b
= wxAuiBlendColour(*b
, 255, 0.4);
109 return wxBitmap(image
);
112 static wxColor
GetBaseColor()
115 #if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON
116 wxColor base_colour
= wxColour( wxMacCreateCGColorFromHITheme(kThemeBrushToolbarBackground
));
118 wxColor base_colour
= wxSystemSettings
::GetColour(wxSYS_COLOUR_3DFACE
);
121 // the base_colour is too pale to use as our base colour,
122 // so darken it a bit --
123 if ((255-base_colour
.Red()) +
124 (255-base_colour
.Green()) +
125 (255-base_colour
.Blue()) < 60)
127 base_colour
= wxAuiStepColour(base_colour
, 92);
135 class ToolbarCommandCapture
: public wxEvtHandler
139 ToolbarCommandCapture() { m_last_id
= 0; }
140 int GetCommandId() const { return m_last_id
; }
142 bool ProcessEvent(wxEvent
& evt
)
144 if (evt
.GetEventType() == wxEVT_COMMAND_MENU_SELECTED
)
146 m_last_id
= evt
.GetId();
150 if (GetNextHandler())
151 return GetNextHandler()->ProcessEvent(evt
);
162 static const unsigned char
163 DISABLED_TEXT_GREY_HUE
= wxAuiBlendColour(0, 255, 0.4);
164 const wxColour
DISABLED_TEXT_COLOR(DISABLED_TEXT_GREY_HUE
,
165 DISABLED_TEXT_GREY_HUE
,
166 DISABLED_TEXT_GREY_HUE
);
168 wxAuiDefaultToolBarArt
::wxAuiDefaultToolBarArt()
170 m_base_colour
= GetBaseColor();
173 m_text_orientation
= wxAUI_TBTOOL_TEXT_BOTTOM
;
174 m_highlight_colour
= wxSystemSettings
::GetColour(wxSYS_COLOUR_HIGHLIGHT
);
176 m_separator_size
= 7;
178 m_overflow_size
= 16;
180 wxColor darker1_colour
= wxAuiStepColour(m_base_colour
, 85);
181 wxColor darker2_colour
= wxAuiStepColour(m_base_colour
, 75);
182 wxColor darker3_colour
= wxAuiStepColour(m_base_colour
, 60);
183 wxColor darker4_colour
= wxAuiStepColour(m_base_colour
, 50);
184 wxColor darker5_colour
= wxAuiStepColour(m_base_colour
, 40);
186 m_gripper_pen1
= wxPen(darker5_colour
);
187 m_gripper_pen2
= wxPen(darker3_colour
);
188 m_gripper_pen3
= *wxWHITE_PEN
;
190 static unsigned char button_dropdown_bits
[] = { 0xe0, 0xf1, 0xfb };
191 static unsigned char overflow_bits
[] = { 0x80, 0xff, 0x80, 0xc1, 0xe3, 0xf7 };
193 m_button_dropdown_bmp
= wxAuiBitmapFromBits(button_dropdown_bits
, 5, 3,
195 m_disabled_button_dropdown_bmp
= wxAuiBitmapFromBits(
196 button_dropdown_bits
, 5, 3,
197 wxColor(128,128,128));
198 m_overflow_bmp
= wxAuiBitmapFromBits(overflow_bits
, 7, 6, *wxBLACK
);
199 m_disabled_overflow_bmp
= wxAuiBitmapFromBits(overflow_bits
, 7, 6, wxColor(128,128,128));
201 m_font
= *wxNORMAL_FONT
;
204 wxAuiDefaultToolBarArt
::~wxAuiDefaultToolBarArt()
206 m_font
= *wxNORMAL_FONT
;
210 wxAuiToolBarArt
* wxAuiDefaultToolBarArt
::Clone()
212 return static_cast<wxAuiToolBarArt
*>(new wxAuiDefaultToolBarArt
);
215 void wxAuiDefaultToolBarArt
::SetFlags(unsigned int flags
)
220 void wxAuiDefaultToolBarArt
::SetFont(const wxFont
& font
)
225 void wxAuiDefaultToolBarArt
::SetTextOrientation(int orientation
)
227 m_text_orientation
= orientation
;
230 void wxAuiDefaultToolBarArt
::DrawBackground(
232 wxWindow
* WXUNUSED(wnd
),
237 wxColour start_colour
= wxAuiStepColour(m_base_colour
, 150);
238 wxColour end_colour
= wxAuiStepColour(m_base_colour
, 90);
239 dc
.GradientFillLinear(rect
, start_colour
, end_colour
, wxSOUTH
);
242 void wxAuiDefaultToolBarArt
::DrawLabel(
244 wxWindow
* WXUNUSED(wnd
),
245 const wxAuiToolBarItem
& item
,
249 dc
.SetTextForeground(*wxBLACK
);
251 // we only care about the text height here since the text
252 // will get cropped based on the width of the item
253 int text_width
= 0, text_height
= 0;
254 dc
.GetTextExtent(wxT("ABCDHgj"), &text_width
, &text_height
);
256 // set the clipping region
257 wxRect clip_rect
= rect
;
258 clip_rect
.width
-= 1;
259 dc
.SetClippingRegion(clip_rect
);
263 text_y
= rect
.y
+ (rect
.height
-text_height
)/2;
264 dc
.DrawText(item
.GetLabel(), text_x
, text_y
);
265 dc
.DestroyClippingRegion();
269 void wxAuiDefaultToolBarArt
::DrawButton(
271 wxWindow
* WXUNUSED(wnd
),
272 const wxAuiToolBarItem
& item
,
275 int text_width
= 0, text_height
= 0;
277 if (m_flags
& wxAUI_TB_TEXT
)
283 dc
.GetTextExtent(wxT("ABCDHgj"), &tx
, &text_height
);
285 dc
.GetTextExtent(item
.GetLabel(), &text_width
, &ty
);
288 int bmp_x
= 0, bmp_y
= 0;
289 int text_x
= 0, text_y
= 0;
291 if (m_text_orientation
== wxAUI_TBTOOL_TEXT_BOTTOM
)
295 (item
.GetBitmap().GetWidth()/2);
298 ((rect
.height
-text_height
)/2) -
299 (item
.GetBitmap().GetHeight()/2);
301 text_x
= rect
.x
+ (rect
.width
/2) - (text_width
/2) + 1;
302 text_y
= rect
.y
+ rect
.height
- text_height
- 1;
304 else if (m_text_orientation
== wxAUI_TBTOOL_TEXT_RIGHT
)
310 (item
.GetBitmap().GetHeight()/2);
312 text_x
= bmp_x
+ 3 + item
.GetBitmap().GetWidth();
319 if (!(item
.GetState() & wxAUI_BUTTON_STATE_DISABLED
))
321 if (item
.GetState() & wxAUI_BUTTON_STATE_PRESSED
)
323 dc
.SetPen(wxPen(m_highlight_colour
));
324 dc
.SetBrush(wxBrush(wxAuiStepColour(m_highlight_colour
, 150)));
325 dc
.DrawRectangle(rect
);
327 else if ((item
.GetState() & wxAUI_BUTTON_STATE_HOVER
) || item
.IsSticky())
329 dc
.SetPen(wxPen(m_highlight_colour
));
330 dc
.SetBrush(wxBrush(wxAuiStepColour(m_highlight_colour
, 170)));
332 // draw an even lighter background for checked item hovers (since
333 // the hover background is the same color as the check background)
334 if (item
.GetState() & wxAUI_BUTTON_STATE_CHECKED
)
335 dc
.SetBrush(wxBrush(wxAuiStepColour(m_highlight_colour
, 180)));
337 dc
.DrawRectangle(rect
);
339 else if (item
.GetState() & wxAUI_BUTTON_STATE_CHECKED
)
341 // it's important to put this code in an else statment after the
342 // hover, otherwise hovers won't draw properly for checked items
343 dc
.SetPen(wxPen(m_highlight_colour
));
344 dc
.SetBrush(wxBrush(wxAuiStepColour(m_highlight_colour
, 170)));
345 dc
.DrawRectangle(rect
);
350 if (item
.GetState() & wxAUI_BUTTON_STATE_DISABLED
)
351 bmp
= item
.GetDisabledBitmap();
353 bmp
= item
.GetBitmap();
358 dc
.DrawBitmap(bmp
, bmp_x
, bmp_y
, true);
360 // set the item's text color based on if it is disabled
361 dc
.SetTextForeground(*wxBLACK
);
362 if (item
.GetState() & wxAUI_BUTTON_STATE_DISABLED
)
363 dc
.SetTextForeground(DISABLED_TEXT_COLOR
);
365 if ( (m_flags
& wxAUI_TB_TEXT
) && !item
.GetLabel().empty() )
367 dc
.DrawText(item
.GetLabel(), text_x
, text_y
);
372 void wxAuiDefaultToolBarArt
::DrawDropDownButton(
374 wxWindow
* WXUNUSED(wnd
),
375 const wxAuiToolBarItem
& item
,
378 int text_width
= 0, text_height
= 0, text_x
= 0, text_y
= 0;
379 int bmp_x
= 0, bmp_y
= 0, dropbmp_x
= 0, dropbmp_y
= 0;
381 wxRect button_rect
= wxRect(rect
.x
,
383 rect
.width
-BUTTON_DROPDOWN_WIDTH
,
385 wxRect dropdown_rect
= wxRect(rect
.x
+rect
.width
-BUTTON_DROPDOWN_WIDTH
-1,
387 BUTTON_DROPDOWN_WIDTH
+1,
390 if (m_flags
& wxAUI_TB_TEXT
)
395 if (m_flags
& wxAUI_TB_TEXT
)
397 dc
.GetTextExtent(wxT("ABCDHgj"), &tx
, &text_height
);
401 dc
.GetTextExtent(item
.GetLabel(), &text_width
, &ty
);
406 dropbmp_x
= dropdown_rect
.x
+
407 (dropdown_rect
.width
/2) -
408 (m_button_dropdown_bmp
.GetWidth()/2);
409 dropbmp_y
= dropdown_rect
.y
+
410 (dropdown_rect
.height
/2) -
411 (m_button_dropdown_bmp
.GetHeight()/2);
414 if (m_text_orientation
== wxAUI_TBTOOL_TEXT_BOTTOM
)
416 bmp_x
= button_rect
.x
+
417 (button_rect
.width
/2) -
418 (item
.GetBitmap().GetWidth()/2);
419 bmp_y
= button_rect
.y
+
420 ((button_rect
.height
-text_height
)/2) -
421 (item
.GetBitmap().GetHeight()/2);
423 text_x
= rect
.x
+ (rect
.width
/2) - (text_width
/2) + 1;
424 text_y
= rect
.y
+ rect
.height
- text_height
- 1;
426 else if (m_text_orientation
== wxAUI_TBTOOL_TEXT_RIGHT
)
432 (item
.GetBitmap().GetHeight()/2);
434 text_x
= bmp_x
+ 3 + item
.GetBitmap().GetWidth();
441 if (item
.GetState() & wxAUI_BUTTON_STATE_PRESSED
)
443 dc
.SetPen(wxPen(m_highlight_colour
));
444 dc
.SetBrush(wxBrush(wxAuiStepColour(m_highlight_colour
, 140)));
445 dc
.DrawRectangle(button_rect
);
446 dc
.DrawRectangle(dropdown_rect
);
448 else if (item
.GetState() & wxAUI_BUTTON_STATE_HOVER
||
451 dc
.SetPen(wxPen(m_highlight_colour
));
452 dc
.SetBrush(wxBrush(wxAuiStepColour(m_highlight_colour
, 170)));
453 dc
.DrawRectangle(button_rect
);
454 dc
.DrawRectangle(dropdown_rect
);
459 if (item
.GetState() & wxAUI_BUTTON_STATE_DISABLED
)
461 bmp
= item
.GetDisabledBitmap();
462 dropbmp
= m_disabled_button_dropdown_bmp
;
466 bmp
= item
.GetBitmap();
467 dropbmp
= m_button_dropdown_bmp
;
473 dc
.DrawBitmap(bmp
, bmp_x
, bmp_y
, true);
474 dc
.DrawBitmap(dropbmp
, dropbmp_x
, dropbmp_y
, true);
476 // set the item's text color based on if it is disabled
477 dc
.SetTextForeground(*wxBLACK
);
478 if (item
.GetState() & wxAUI_BUTTON_STATE_DISABLED
)
479 dc
.SetTextForeground(DISABLED_TEXT_COLOR
);
481 if ( (m_flags
& wxAUI_TB_TEXT
) && !item
.GetLabel().empty() )
483 dc
.DrawText(item
.GetLabel(), text_x
, text_y
);
487 void wxAuiDefaultToolBarArt
::DrawControlLabel(
489 wxWindow
* WXUNUSED(wnd
),
490 const wxAuiToolBarItem
& item
,
493 if (!(m_flags
& wxAUI_TB_TEXT
))
496 if (m_text_orientation
!= wxAUI_TBTOOL_TEXT_BOTTOM
)
499 int text_x
= 0, text_y
= 0;
500 int text_width
= 0, text_height
= 0;
505 if (m_flags
& wxAUI_TB_TEXT
)
507 dc
.GetTextExtent(wxT("ABCDHgj"), &tx
, &text_height
);
511 dc
.GetTextExtent(item
.GetLabel(), &text_width
, &ty
);
513 // don't draw the label if it is wider than the item width
514 if (text_width
> rect
.width
)
517 // set the label's text color
518 dc
.SetTextForeground(*wxBLACK
);
520 text_x
= rect
.x
+ (rect
.width
/2) - (text_width
/2) + 1;
521 text_y
= rect
.y
+ rect
.height
- text_height
- 1;
523 if ( (m_flags
& wxAUI_TB_TEXT
) && !item
.GetLabel().empty() )
525 dc
.DrawText(item
.GetLabel(), text_x
, text_y
);
529 wxSize wxAuiDefaultToolBarArt
::GetLabelSize(
531 wxWindow
* WXUNUSED(wnd
),
532 const wxAuiToolBarItem
& item
)
536 // get label's height
537 int width
= 0, height
= 0;
538 dc
.GetTextExtent(wxT("ABCDHgj"), &width
, &height
);
541 width
= item
.GetMinSize().GetWidth();
543 return wxSize(width
, height
);
546 wxSize wxAuiDefaultToolBarArt
::GetToolSize(
548 wxWindow
* WXUNUSED(wnd
),
549 const wxAuiToolBarItem
& item
)
551 if (!item
.GetBitmap().IsOk() && !(m_flags
& wxAUI_TB_TEXT
))
552 return wxSize(16,16);
554 int width
= item
.GetBitmap().GetWidth();
555 int height
= item
.GetBitmap().GetHeight();
557 if (m_flags
& wxAUI_TB_TEXT
)
562 if (m_text_orientation
== wxAUI_TBTOOL_TEXT_BOTTOM
)
564 dc
.GetTextExtent(wxT("ABCDHgj"), &tx
, &ty
);
567 if ( !item
.GetLabel().empty() )
569 dc
.GetTextExtent(item
.GetLabel(), &tx
, &ty
);
570 width
= wxMax(width
, tx
+6);
573 else if ( m_text_orientation
== wxAUI_TBTOOL_TEXT_RIGHT
&&
574 !item
.GetLabel().empty() )
576 width
+= 3; // space between left border and bitmap
577 width
+= 3; // space between bitmap and text
579 if ( !item
.GetLabel().empty() )
581 dc
.GetTextExtent(item
.GetLabel(), &tx
, &ty
);
583 height
= wxMax(height
, ty
);
588 // if the tool has a dropdown button, add it to the width
589 if (item
.HasDropDown())
590 width
+= (BUTTON_DROPDOWN_WIDTH
+4);
592 return wxSize(width
, height
);
595 void wxAuiDefaultToolBarArt
::DrawSeparator(
597 wxWindow
* WXUNUSED(wnd
),
600 bool horizontal
= true;
601 if (m_flags
& wxAUI_TB_VERTICAL
)
608 rect
.x
+= (rect
.width
/2);
610 int new_height
= (rect
.height
*3)/4;
611 rect
.y
+= (rect
.height
/2) - (new_height
/2);
612 rect
.height
= new_height
;
616 rect
.y
+= (rect
.height
/2);
618 int new_width
= (rect
.width
*3)/4;
619 rect
.x
+= (rect
.width
/2) - (new_width
/2);
620 rect
.width
= new_width
;
623 wxColour start_colour
= wxAuiStepColour(m_base_colour
, 80);
624 wxColour end_colour
= wxAuiStepColour(m_base_colour
, 80);
625 dc
.GradientFillLinear(rect
, start_colour
, end_colour
, horizontal ? wxSOUTH
: wxEAST
);
628 void wxAuiDefaultToolBarArt
::DrawGripper(wxDC
& dc
,
629 wxWindow
* WXUNUSED(wnd
),
637 if (m_flags
& wxAUI_TB_VERTICAL
)
639 x
= rect
.x
+ (i
*4) + 5;
641 if (x
> rect
.GetWidth()-5)
647 y
= rect
.y
+ (i
*4) + 5;
648 if (y
> rect
.GetHeight()-5)
652 dc
.SetPen(m_gripper_pen1
);
654 dc
.SetPen(m_gripper_pen2
);
655 dc
.DrawPoint(x
, y
+1);
656 dc
.DrawPoint(x
+1, y
);
657 dc
.SetPen(m_gripper_pen3
);
658 dc
.DrawPoint(x
+2, y
+1);
659 dc
.DrawPoint(x
+2, y
+2);
660 dc
.DrawPoint(x
+1, y
+2);
667 void wxAuiDefaultToolBarArt
::DrawOverflowButton(wxDC
& dc
,
672 if (state
& wxAUI_BUTTON_STATE_HOVER
||
673 state
& wxAUI_BUTTON_STATE_PRESSED
)
675 wxRect cli_rect
= wnd
->GetClientRect();
676 wxColor light_gray_bg
= wxAuiStepColour(m_highlight_colour
, 170);
678 if (m_flags
& wxAUI_TB_VERTICAL
)
680 dc
.SetPen(wxPen(m_highlight_colour
));
681 dc
.DrawLine(rect
.x
, rect
.y
, rect
.x
+rect
.width
, rect
.y
);
682 dc
.SetPen(wxPen(light_gray_bg
));
683 dc
.SetBrush(wxBrush(light_gray_bg
));
684 dc
.DrawRectangle(rect
.x
, rect
.y
+1, rect
.width
, rect
.height
);
688 dc
.SetPen(wxPen(m_highlight_colour
));
689 dc
.DrawLine(rect
.x
, rect
.y
, rect
.x
, rect
.y
+rect
.height
);
690 dc
.SetPen(wxPen(light_gray_bg
));
691 dc
.SetBrush(wxBrush(light_gray_bg
));
692 dc
.DrawRectangle(rect
.x
+1, rect
.y
, rect
.width
, rect
.height
);
696 int x
= rect
.x
+1+(rect
.width
-m_overflow_bmp
.GetWidth())/2;
697 int y
= rect
.y
+1+(rect
.height
-m_overflow_bmp
.GetHeight())/2;
698 dc
.DrawBitmap(m_overflow_bmp
, x
, y
, true);
701 int wxAuiDefaultToolBarArt
::GetElementSize(int element_id
)
705 case wxAUI_TBART_SEPARATOR_SIZE
: return m_separator_size
;
706 case wxAUI_TBART_GRIPPER_SIZE
: return m_gripper_size
;
707 case wxAUI_TBART_OVERFLOW_SIZE
: return m_overflow_size
;
712 void wxAuiDefaultToolBarArt
::SetElementSize(int element_id
, int size
)
716 case wxAUI_TBART_SEPARATOR_SIZE
: m_separator_size
= size
;
717 case wxAUI_TBART_GRIPPER_SIZE
: m_gripper_size
= size
;
718 case wxAUI_TBART_OVERFLOW_SIZE
: m_overflow_size
= size
;
722 int wxAuiDefaultToolBarArt
::ShowDropDown(wxWindow
* wnd
,
723 const wxAuiToolBarItemArray
& items
)
727 size_t items_added
= 0;
729 size_t i
, count
= items
.GetCount();
730 for (i
= 0; i
< count
; ++i
)
732 wxAuiToolBarItem
& item
= items
.Item(i
);
734 if (item
.GetKind() == wxITEM_NORMAL
)
736 wxString text
= item
.GetShortHelp();
738 text
= item
.GetLabel();
743 wxMenuItem
* m
= new wxMenuItem(&menuPopup
, item
.GetId(), text
, item
.GetShortHelp());
745 m
->SetBitmap(item
.GetBitmap());
749 else if (item
.GetKind() == wxITEM_SEPARATOR
)
752 menuPopup
.AppendSeparator();
756 // find out where to put the popup menu of window items
757 wxPoint pt
= ::wxGetMousePosition();
758 pt
= wnd
->ScreenToClient(pt
);
760 // find out the screen coordinate at the bottom of the tab ctrl
761 wxRect cli_rect
= wnd
->GetClientRect();
762 pt
.y
= cli_rect
.y
+ cli_rect
.height
;
764 ToolbarCommandCapture
* cc
= new ToolbarCommandCapture
;
765 wnd
->PushEventHandler(cc
);
766 wnd
->PopupMenu(&menuPopup
, pt
);
767 int command
= cc
->GetCommandId();
768 wnd
->PopEventHandler(true);
776 BEGIN_EVENT_TABLE(wxAuiToolBar
, wxControl
)
777 EVT_SIZE(wxAuiToolBar
::OnSize
)
778 EVT_IDLE(wxAuiToolBar
::OnIdle
)
779 EVT_ERASE_BACKGROUND(wxAuiToolBar
::OnEraseBackground
)
780 EVT_PAINT(wxAuiToolBar
::OnPaint
)
781 EVT_LEFT_DOWN(wxAuiToolBar
::OnLeftDown
)
782 EVT_LEFT_DCLICK(wxAuiToolBar
::OnLeftDown
)
783 EVT_LEFT_UP(wxAuiToolBar
::OnLeftUp
)
784 EVT_RIGHT_DOWN(wxAuiToolBar
::OnRightDown
)
785 EVT_RIGHT_DCLICK(wxAuiToolBar
::OnRightDown
)
786 EVT_RIGHT_UP(wxAuiToolBar
::OnRightUp
)
787 EVT_MIDDLE_DOWN(wxAuiToolBar
::OnMiddleDown
)
788 EVT_MIDDLE_DCLICK(wxAuiToolBar
::OnMiddleDown
)
789 EVT_MIDDLE_UP(wxAuiToolBar
::OnMiddleUp
)
790 EVT_MOTION(wxAuiToolBar
::OnMotion
)
791 EVT_LEAVE_WINDOW(wxAuiToolBar
::OnLeaveWindow
)
792 EVT_SET_CURSOR(wxAuiToolBar
::OnSetCursor
)
796 wxAuiToolBar
::wxAuiToolBar(wxWindow
* parent
,
798 const wxPoint
& position
,
805 style
| wxBORDER_NONE
)
807 m_sizer
= new wxBoxSizer(wxHORIZONTAL
);
809 m_button_height
= -1;
810 m_sizer_element_count
= 0;
811 m_action_pos
= wxPoint(-1,-1);
812 m_action_item
= NULL
;
814 m_art
= new wxAuiDefaultToolBarArt
;
816 m_tool_border_padding
= 3;
817 m_tool_text_orientation
= wxAUI_TBTOOL_TEXT_BOTTOM
;
818 m_gripper_sizer_item
= NULL
;
819 m_overflow_sizer_item
= NULL
;
822 m_gripper_visible
= (m_style
& wxAUI_TB_GRIPPER
) ?
true : false;
823 m_overflow_visible
= (m_style
& wxAUI_TB_OVERFLOW
) ?
true : false;
824 m_overflow_state
= 0;
825 SetMargins(5, 5, 2, 2);
826 SetFont(*wxNORMAL_FONT
);
827 m_art
->SetFlags((unsigned int)m_style
);
828 SetExtraStyle(wxWS_EX_PROCESS_IDLE
);
829 if (style
& wxAUI_TB_HORZ_LAYOUT
)
830 SetToolTextOrientation(wxAUI_TBTOOL_TEXT_RIGHT
);
834 wxAuiToolBar
::~wxAuiToolBar()
840 void wxAuiToolBar
::SetWindowStyleFlag(long style
)
842 wxControl
::SetWindowStyleFlag(style
);
848 m_art
->SetFlags((unsigned int)m_style
);
851 if (m_style
& wxAUI_TB_GRIPPER
)
852 m_gripper_visible
= true;
854 m_gripper_visible
= false;
857 if (m_style
& wxAUI_TB_OVERFLOW
)
858 m_overflow_visible
= true;
860 m_overflow_visible
= false;
862 if (style
& wxAUI_TB_HORZ_LAYOUT
)
863 SetToolTextOrientation(wxAUI_TBTOOL_TEXT_RIGHT
);
865 SetToolTextOrientation(wxAUI_TBTOOL_TEXT_BOTTOM
);
868 long wxAuiToolBar
::GetWindowStyleFlag() const
873 void wxAuiToolBar
::SetArtProvider(wxAuiToolBarArt
* art
)
881 m_art
->SetFlags((unsigned int)m_style
);
882 m_art
->SetTextOrientation(m_tool_text_orientation
);
886 wxAuiToolBarArt
* wxAuiToolBar
::GetArtProvider() const
894 wxAuiToolBarItem
* wxAuiToolBar
::AddTool(int tool_id
,
895 const wxString
& label
,
896 const wxBitmap
& bitmap
,
897 const wxString
& short_help_string
,
900 return AddTool(tool_id
,
911 wxAuiToolBarItem
* wxAuiToolBar
::AddTool(int tool_id
,
912 const wxString
& label
,
913 const wxBitmap
& bitmap
,
914 const wxBitmap
& disabled_bitmap
,
916 const wxString
& short_help_string
,
917 const wxString
& long_help_string
,
918 wxObject
* WXUNUSED(client_data
))
920 wxAuiToolBarItem item
;
923 item
.bitmap
= bitmap
;
924 item
.disabled_bitmap
= disabled_bitmap
;
925 item
.short_help
= short_help_string
;
926 item
.long_help
= long_help_string
;
928 item
.dropdown
= false;
929 item
.spacer_pixels
= 0;
934 item
.sizer_item
= NULL
;
935 item
.min_size
= wxDefaultSize
;
939 if (item
.id
== wxID_ANY
)
942 if (!item
.disabled_bitmap
.IsOk())
944 // no disabled bitmap specified, we need to make one
945 if (item
.bitmap
.IsOk())
947 //wxImage img = item.bitmap.ConvertToImage();
948 //wxImage grey_version = img.ConvertToGreyscale();
949 //item.disabled_bitmap = wxBitmap(grey_version);
950 item
.disabled_bitmap
= MakeDisabledBitmap(item
.bitmap
);
954 return &m_items
.Last();
957 wxAuiToolBarItem
* wxAuiToolBar
::AddControl(wxControl
* control
,
958 const wxString
& label
)
960 wxAuiToolBarItem item
;
961 item
.window
= (wxWindow
*)control
;
963 item
.bitmap
= wxNullBitmap
;
964 item
.disabled_bitmap
= wxNullBitmap
;
966 item
.dropdown
= false;
967 item
.spacer_pixels
= 0;
968 item
.id
= control
->GetId();
971 item
.kind
= wxITEM_CONTROL
;
972 item
.sizer_item
= NULL
;
973 item
.min_size
= control
->GetEffectiveMinSize();
978 return &m_items
.Last();
981 wxAuiToolBarItem
* wxAuiToolBar
::AddLabel(int tool_id
,
982 const wxString
& label
,
985 wxSize min_size
= wxDefaultSize
;
989 wxAuiToolBarItem item
;
992 item
.bitmap
= wxNullBitmap
;
993 item
.disabled_bitmap
= wxNullBitmap
;
995 item
.dropdown
= false;
996 item
.spacer_pixels
= 0;
1000 item
.kind
= wxITEM_LABEL
;
1001 item
.sizer_item
= NULL
;
1002 item
.min_size
= min_size
;
1004 item
.sticky
= false;
1006 if (item
.id
== wxID_ANY
)
1007 item
.id
= wxNewId();
1010 return &m_items
.Last();
1013 wxAuiToolBarItem
* wxAuiToolBar
::AddSeparator()
1015 wxAuiToolBarItem item
;
1017 item
.label
= wxEmptyString
;
1018 item
.bitmap
= wxNullBitmap
;
1019 item
.disabled_bitmap
= wxNullBitmap
;
1021 item
.dropdown
= false;
1024 item
.proportion
= 0;
1025 item
.kind
= wxITEM_SEPARATOR
;
1026 item
.sizer_item
= NULL
;
1027 item
.min_size
= wxDefaultSize
;
1029 item
.sticky
= false;
1032 return &m_items
.Last();
1035 wxAuiToolBarItem
* wxAuiToolBar
::AddSpacer(int pixels
)
1037 wxAuiToolBarItem item
;
1039 item
.label
= wxEmptyString
;
1040 item
.bitmap
= wxNullBitmap
;
1041 item
.disabled_bitmap
= wxNullBitmap
;
1043 item
.dropdown
= false;
1044 item
.spacer_pixels
= pixels
;
1047 item
.proportion
= 0;
1048 item
.kind
= wxITEM_SPACER
;
1049 item
.sizer_item
= NULL
;
1050 item
.min_size
= wxDefaultSize
;
1052 item
.sticky
= false;
1055 return &m_items
.Last();
1058 wxAuiToolBarItem
* wxAuiToolBar
::AddStretchSpacer(int proportion
)
1060 wxAuiToolBarItem item
;
1062 item
.label
= wxEmptyString
;
1063 item
.bitmap
= wxNullBitmap
;
1064 item
.disabled_bitmap
= wxNullBitmap
;
1066 item
.dropdown
= false;
1067 item
.spacer_pixels
= 0;
1070 item
.proportion
= proportion
;
1071 item
.kind
= wxITEM_SPACER
;
1072 item
.sizer_item
= NULL
;
1073 item
.min_size
= wxDefaultSize
;
1075 item
.sticky
= false;
1078 return &m_items
.Last();
1081 void wxAuiToolBar
::Clear()
1084 m_sizer_element_count
= 0;
1087 bool wxAuiToolBar
::DeleteTool(int tool_id
)
1089 int idx
= GetToolIndex(tool_id
);
1090 if (idx
>= 0 && idx
< (int)m_items
.GetCount())
1092 m_items
.RemoveAt(idx
);
1100 bool wxAuiToolBar
::DeleteByIndex(int idx
)
1102 if (idx
>= 0 && idx
< (int)m_items
.GetCount())
1104 m_items
.RemoveAt(idx
);
1113 wxControl
* wxAuiToolBar
::FindControl(int id
)
1115 wxWindow
* wnd
= FindWindow(id
);
1116 return (wxControl
*)wnd
;
1119 wxAuiToolBarItem
* wxAuiToolBar
::FindTool(int tool_id
) const
1122 for (i
= 0, count
= m_items
.GetCount(); i
< count
; ++i
)
1124 wxAuiToolBarItem
& item
= m_items
.Item(i
);
1125 if (item
.id
== tool_id
)
1132 wxAuiToolBarItem
* wxAuiToolBar
::FindToolByPosition(wxCoord x
, wxCoord y
) const
1135 for (i
= 0, count
= m_items
.GetCount(); i
< count
; ++i
)
1137 wxAuiToolBarItem
& item
= m_items
.Item(i
);
1139 if (!item
.sizer_item
)
1142 wxRect rect
= item
.sizer_item
->GetRect();
1143 if (rect
.Contains(x
,y
))
1145 // if the item doesn't fit on the toolbar, return NULL
1146 if (!GetToolFitsByIndex(i
))
1156 wxAuiToolBarItem
* wxAuiToolBar
::FindToolByPositionWithPacking(wxCoord x
, wxCoord y
) const
1159 for (i
= 0, count
= m_items
.GetCount(); i
< count
; ++i
)
1161 wxAuiToolBarItem
& item
= m_items
.Item(i
);
1163 if (!item
.sizer_item
)
1166 wxRect rect
= item
.sizer_item
->GetRect();
1168 // apply tool packing
1170 rect
.width
+= m_tool_packing
;
1172 if (rect
.Contains(x
,y
))
1174 // if the item doesn't fit on the toolbar, return NULL
1175 if (!GetToolFitsByIndex(i
))
1185 wxAuiToolBarItem
* wxAuiToolBar
::FindToolByIndex(int idx
) const
1190 if (idx
>= (int)m_items
.size())
1193 return &(m_items
[idx
]);
1196 void wxAuiToolBar
::SetToolBitmapSize(const wxSize
& WXUNUSED(size
))
1198 // TODO: wxToolBar compatibility
1201 wxSize wxAuiToolBar
::GetToolBitmapSize() const
1203 // TODO: wxToolBar compatibility
1204 return wxSize(16,15);
1207 void wxAuiToolBar
::SetToolProportion(int tool_id
, int proportion
)
1209 wxAuiToolBarItem
* item
= FindTool(tool_id
);
1213 item
->proportion
= proportion
;
1216 int wxAuiToolBar
::GetToolProportion(int tool_id
) const
1218 wxAuiToolBarItem
* item
= FindTool(tool_id
);
1222 return item
->proportion
;
1225 void wxAuiToolBar
::SetToolSeparation(int separation
)
1228 m_art
->SetElementSize(wxAUI_TBART_SEPARATOR_SIZE
, separation
);
1231 int wxAuiToolBar
::GetToolSeparation() const
1234 return m_art
->GetElementSize(wxAUI_TBART_SEPARATOR_SIZE
);
1240 void wxAuiToolBar
::SetToolDropDown(int tool_id
, bool dropdown
)
1242 wxAuiToolBarItem
* item
= FindTool(tool_id
);
1246 item
->dropdown
= dropdown
;
1249 bool wxAuiToolBar
::GetToolDropDown(int tool_id
) const
1251 wxAuiToolBarItem
* item
= FindTool(tool_id
);
1255 return item
->dropdown
;
1258 void wxAuiToolBar
::SetToolSticky(int tool_id
, bool sticky
)
1260 // ignore separators
1264 wxAuiToolBarItem
* item
= FindTool(tool_id
);
1268 if (item
->sticky
== sticky
)
1271 item
->sticky
= sticky
;
1277 bool wxAuiToolBar
::GetToolSticky(int tool_id
) const
1279 wxAuiToolBarItem
* item
= FindTool(tool_id
);
1283 return item
->sticky
;
1289 void wxAuiToolBar
::SetToolBorderPadding(int padding
)
1291 m_tool_border_padding
= padding
;
1294 int wxAuiToolBar
::GetToolBorderPadding() const
1296 return m_tool_border_padding
;
1299 void wxAuiToolBar
::SetToolTextOrientation(int orientation
)
1301 m_tool_text_orientation
= orientation
;
1305 m_art
->SetTextOrientation(orientation
);
1309 int wxAuiToolBar
::GetToolTextOrientation() const
1311 return m_tool_text_orientation
;
1314 void wxAuiToolBar
::SetToolPacking(int packing
)
1316 m_tool_packing
= packing
;
1319 int wxAuiToolBar
::GetToolPacking() const
1321 return m_tool_packing
;
1325 void wxAuiToolBar
::SetOrientation(int WXUNUSED(orientation
))
1329 void wxAuiToolBar
::SetMargins(int left
, int right
, int top
, int bottom
)
1332 m_left_padding
= left
;
1334 m_right_padding
= right
;
1336 m_top_padding
= top
;
1338 m_bottom_padding
= bottom
;
1341 bool wxAuiToolBar
::GetGripperVisible() const
1343 return m_gripper_visible
;
1346 void wxAuiToolBar
::SetGripperVisible(bool visible
)
1348 m_gripper_visible
= visible
;
1350 m_style
|= wxAUI_TB_GRIPPER
;
1352 m_style
&= ~wxAUI_TB_GRIPPER
;
1358 bool wxAuiToolBar
::GetOverflowVisible() const
1360 return m_overflow_visible
;
1363 void wxAuiToolBar
::SetOverflowVisible(bool visible
)
1365 m_overflow_visible
= visible
;
1367 m_style
|= wxAUI_TB_OVERFLOW
;
1369 m_style
&= ~wxAUI_TB_OVERFLOW
;
1373 bool wxAuiToolBar
::SetFont(const wxFont
& font
)
1375 bool res
= wxWindow
::SetFont(font
);
1379 m_art
->SetFont(font
);
1386 void wxAuiToolBar
::SetHoverItem(wxAuiToolBarItem
* pitem
)
1388 wxAuiToolBarItem
* former_hover
= NULL
;
1391 for (i
= 0, count
= m_items
.GetCount(); i
< count
; ++i
)
1393 wxAuiToolBarItem
& item
= m_items
.Item(i
);
1394 if (item
.state
& wxAUI_BUTTON_STATE_HOVER
)
1395 former_hover
= &item
;
1396 item
.state
&= ~wxAUI_BUTTON_STATE_HOVER
;
1401 pitem
->state
|= wxAUI_BUTTON_STATE_HOVER
;
1404 if (former_hover
!= pitem
)
1411 void wxAuiToolBar
::SetPressedItem(wxAuiToolBarItem
* pitem
)
1413 wxAuiToolBarItem
* former_item
= NULL
;
1416 for (i
= 0, count
= m_items
.GetCount(); i
< count
; ++i
)
1418 wxAuiToolBarItem
& item
= m_items
.Item(i
);
1419 if (item
.state
& wxAUI_BUTTON_STATE_PRESSED
)
1420 former_item
= &item
;
1421 item
.state
&= ~wxAUI_BUTTON_STATE_PRESSED
;
1426 pitem
->state
&= ~wxAUI_BUTTON_STATE_HOVER
;
1427 pitem
->state
|= wxAUI_BUTTON_STATE_PRESSED
;
1430 if (former_item
!= pitem
)
1437 void wxAuiToolBar
::RefreshOverflowState()
1439 if (!m_overflow_sizer_item
)
1441 m_overflow_state
= 0;
1445 int overflow_state
= 0;
1447 wxRect overflow_rect
= GetOverflowRect();
1450 // find out the mouse's current position
1451 wxPoint pt
= ::wxGetMousePosition();
1452 pt
= this->ScreenToClient(pt
);
1454 // find out if the mouse cursor is inside the dropdown rectangle
1455 if (overflow_rect
.Contains(pt
.x
, pt
.y
))
1457 if (::wxGetMouseState().LeftDown())
1458 overflow_state
= wxAUI_BUTTON_STATE_PRESSED
;
1460 overflow_state
= wxAUI_BUTTON_STATE_HOVER
;
1463 if (overflow_state
!= m_overflow_state
)
1465 m_overflow_state
= overflow_state
;
1470 m_overflow_state
= overflow_state
;
1473 void wxAuiToolBar
::ToggleTool(int tool_id
, bool state
)
1475 wxAuiToolBarItem
* tool
= FindTool(tool_id
);
1477 if (tool
&& (tool
->kind
== wxITEM_CHECK
|| tool
->kind
== wxITEM_RADIO
))
1479 if (tool
->kind
== wxITEM_RADIO
)
1482 idx
= GetToolIndex(tool_id
);
1483 count
= (int)m_items
.GetCount();
1485 if (idx
>= 0 && idx
< count
)
1487 for (i
= idx
; i
< count
; ++i
)
1489 if (m_items
[i
].kind
!= wxITEM_RADIO
)
1491 m_items
[i
].state
&= ~wxAUI_BUTTON_STATE_CHECKED
;
1493 for (i
= idx
; i
> 0; i
--)
1495 if (m_items
[i
].kind
!= wxITEM_RADIO
)
1497 m_items
[i
].state
&= ~wxAUI_BUTTON_STATE_CHECKED
;
1501 tool
->state
|= wxAUI_BUTTON_STATE_CHECKED
;
1503 else if (tool
->kind
== wxITEM_CHECK
)
1506 tool
->state
|= wxAUI_BUTTON_STATE_CHECKED
;
1508 tool
->state
&= ~wxAUI_BUTTON_STATE_CHECKED
;
1513 bool wxAuiToolBar
::GetToolToggled(int tool_id
) const
1515 wxAuiToolBarItem
* tool
= FindTool(tool_id
);
1519 if ( (tool
->kind
!= wxITEM_CHECK
) && (tool
->kind
!= wxITEM_RADIO
) )
1522 return (tool
->state
& wxAUI_BUTTON_STATE_CHECKED
) ?
true : false;
1528 void wxAuiToolBar
::EnableTool(int tool_id
, bool state
)
1530 wxAuiToolBarItem
* tool
= FindTool(tool_id
);
1535 tool
->state
&= ~wxAUI_BUTTON_STATE_DISABLED
;
1537 tool
->state
|= wxAUI_BUTTON_STATE_DISABLED
;
1541 bool wxAuiToolBar
::GetToolEnabled(int tool_id
) const
1543 wxAuiToolBarItem
* tool
= FindTool(tool_id
);
1546 return (tool
->state
& wxAUI_BUTTON_STATE_DISABLED
) ?
false : true;
1551 wxString wxAuiToolBar
::GetToolLabel(int tool_id
) const
1553 wxAuiToolBarItem
* tool
= FindTool(tool_id
);
1554 wxASSERT_MSG(tool
, wxT("can't find tool in toolbar item array"));
1556 return wxEmptyString
;
1561 void wxAuiToolBar
::SetToolLabel(int tool_id
, const wxString
& label
)
1563 wxAuiToolBarItem
* tool
= FindTool(tool_id
);
1566 tool
->label
= label
;
1570 wxBitmap wxAuiToolBar
::GetToolBitmap(int tool_id
) const
1572 wxAuiToolBarItem
* tool
= FindTool(tool_id
);
1573 wxASSERT_MSG(tool
, wxT("can't find tool in toolbar item array"));
1575 return wxNullBitmap
;
1577 return tool
->bitmap
;
1580 void wxAuiToolBar
::SetToolBitmap(int tool_id
, const wxBitmap
& bitmap
)
1582 wxAuiToolBarItem
* tool
= FindTool(tool_id
);
1585 tool
->bitmap
= bitmap
;
1589 wxString wxAuiToolBar
::GetToolShortHelp(int tool_id
) const
1591 wxAuiToolBarItem
* tool
= FindTool(tool_id
);
1592 wxASSERT_MSG(tool
, wxT("can't find tool in toolbar item array"));
1594 return wxEmptyString
;
1596 return tool
->short_help
;
1599 void wxAuiToolBar
::SetToolShortHelp(int tool_id
, const wxString
& help_string
)
1601 wxAuiToolBarItem
* tool
= FindTool(tool_id
);
1604 tool
->short_help
= help_string
;
1608 wxString wxAuiToolBar
::GetToolLongHelp(int tool_id
) const
1610 wxAuiToolBarItem
* tool
= FindTool(tool_id
);
1611 wxASSERT_MSG(tool
, wxT("can't find tool in toolbar item array"));
1613 return wxEmptyString
;
1615 return tool
->long_help
;
1618 void wxAuiToolBar
::SetToolLongHelp(int tool_id
, const wxString
& help_string
)
1620 wxAuiToolBarItem
* tool
= FindTool(tool_id
);
1623 tool
->long_help
= help_string
;
1627 void wxAuiToolBar
::SetCustomOverflowItems(const wxAuiToolBarItemArray
& prepend
,
1628 const wxAuiToolBarItemArray
& append
)
1630 m_custom_overflow_prepend
= prepend
;
1631 m_custom_overflow_append
= append
;
1635 size_t wxAuiToolBar
::GetToolCount() const
1637 return m_items
.size();
1640 int wxAuiToolBar
::GetToolIndex(int tool_id
) const
1642 // this will prevent us from returning the index of the
1643 // first separator in the toolbar since its id is equal to -1
1647 size_t i
, count
= m_items
.GetCount();
1648 for (i
= 0; i
< count
; ++i
)
1650 wxAuiToolBarItem
& item
= m_items
.Item(i
);
1651 if (item
.id
== tool_id
)
1658 bool wxAuiToolBar
::GetToolFitsByIndex(int tool_idx
) const
1660 if (tool_idx
< 0 || tool_idx
>= (int)m_items
.GetCount())
1663 if (!m_items
[tool_idx
].sizer_item
)
1667 GetClientSize(&cli_w
, &cli_h
);
1669 wxRect rect
= m_items
[tool_idx
].sizer_item
->GetRect();
1671 if (m_style
& wxAUI_TB_VERTICAL
)
1673 // take the dropdown size into account
1674 if (m_overflow_visible
)
1675 cli_h
-= m_overflow_sizer_item
->GetSize().y
;
1677 if (rect
.y
+rect
.height
< cli_h
)
1682 // take the dropdown size into account
1683 if (m_overflow_visible
)
1684 cli_w
-= m_overflow_sizer_item
->GetSize().x
;
1686 if (rect
.x
+rect
.width
< cli_w
)
1694 bool wxAuiToolBar
::GetToolFits(int tool_id
) const
1696 return GetToolFitsByIndex(GetToolIndex(tool_id
));
1699 wxRect wxAuiToolBar
::GetToolRect(int tool_id
) const
1701 wxAuiToolBarItem
* tool
= FindTool(tool_id
);
1702 if (tool
&& tool
->sizer_item
)
1704 return tool
->sizer_item
->GetRect();
1710 bool wxAuiToolBar
::GetToolBarFits() const
1712 if (m_items
.GetCount() == 0)
1714 // empty toolbar always 'fits'
1718 // entire toolbar content fits if the last tool fits
1719 return GetToolFitsByIndex(m_items
.GetCount() - 1);
1722 bool wxAuiToolBar
::Realize()
1724 wxClientDC
dc(this);
1728 bool horizontal
= true;
1729 if (m_style
& wxAUI_TB_VERTICAL
)
1733 // create the new sizer to add toolbar elements to
1734 wxBoxSizer
* sizer
= new wxBoxSizer(horizontal ? wxHORIZONTAL
: wxVERTICAL
);
1737 int separator_size
= m_art
->GetElementSize(wxAUI_TBART_SEPARATOR_SIZE
);
1738 int gripper_size
= m_art
->GetElementSize(wxAUI_TBART_GRIPPER_SIZE
);
1739 if (gripper_size
> 0 && m_gripper_visible
)
1742 m_gripper_sizer_item
= sizer
->Add(gripper_size
, 1, 0, wxEXPAND
);
1744 m_gripper_sizer_item
= sizer
->Add(1, gripper_size
, 0, wxEXPAND
);
1748 m_gripper_sizer_item
= NULL
;
1751 // add "left" padding
1752 if (m_left_padding
> 0)
1755 sizer
->Add(m_left_padding
, 1);
1757 sizer
->Add(1, m_left_padding
);
1761 for (i
= 0, count
= m_items
.GetCount(); i
< count
; ++i
)
1763 wxAuiToolBarItem
& item
= m_items
.Item(i
);
1764 wxSizerItem
* sizer_item
= NULL
;
1770 wxSize size
= m_art
->GetLabelSize(dc
, this, item
);
1771 sizer_item
= sizer
->Add(size
.x
+ (m_tool_border_padding
*2),
1772 size
.y
+ (m_tool_border_padding
*2),
1777 sizer
->AddSpacer(m_tool_packing
);
1787 wxSize size
= m_art
->GetToolSize(dc
, this, item
);
1788 sizer_item
= sizer
->Add(size
.x
+ (m_tool_border_padding
*2),
1789 size
.y
+ (m_tool_border_padding
*2),
1795 sizer
->AddSpacer(m_tool_packing
);
1801 case wxITEM_SEPARATOR
:
1804 sizer_item
= sizer
->Add(separator_size
, 1, 0, wxEXPAND
);
1806 sizer_item
= sizer
->Add(1, separator_size
, 0, wxEXPAND
);
1811 sizer
->AddSpacer(m_tool_packing
);
1818 if (item
.proportion
> 0)
1819 sizer_item
= sizer
->AddStretchSpacer(item
.proportion
);
1821 sizer_item
= sizer
->Add(item
.spacer_pixels
, 1);
1824 case wxITEM_CONTROL
:
1826 //sizer_item = sizer->Add(item.window, item.proportion, wxEXPAND);
1827 wxSizerItem
* ctrl_sizer_item
;
1829 wxBoxSizer
* vert_sizer
= new wxBoxSizer(wxVERTICAL
);
1830 vert_sizer
->AddStretchSpacer(1);
1831 ctrl_sizer_item
= vert_sizer
->Add(item
.window
, 0, wxEXPAND
);
1832 vert_sizer
->AddStretchSpacer(1);
1833 if ( (m_style
& wxAUI_TB_TEXT
) &&
1834 m_tool_text_orientation
== wxAUI_TBTOOL_TEXT_BOTTOM
&&
1835 !item
.GetLabel().empty() )
1837 wxSize s
= GetLabelSize(item
.GetLabel());
1838 vert_sizer
->Add(1, s
.y
);
1842 sizer_item
= sizer
->Add(vert_sizer
, item
.proportion
, wxEXPAND
);
1844 wxSize min_size
= item
.min_size
;
1847 // proportional items will disappear from the toolbar if
1848 // their min width is not set to something really small
1849 if (item
.proportion
!= 0)
1854 if (min_size
.IsFullySpecified())
1856 sizer_item
->SetMinSize(min_size
);
1857 ctrl_sizer_item
->SetMinSize(min_size
);
1863 sizer
->AddSpacer(m_tool_packing
);
1868 item
.sizer_item
= sizer_item
;
1871 // add "right" padding
1872 if (m_right_padding
> 0)
1875 sizer
->Add(m_right_padding
, 1);
1877 sizer
->Add(1, m_right_padding
);
1880 // add drop down area
1881 m_overflow_sizer_item
= NULL
;
1883 if (m_style
& wxAUI_TB_OVERFLOW
)
1885 int overflow_size
= m_art
->GetElementSize(wxAUI_TBART_OVERFLOW_SIZE
);
1886 if (overflow_size
> 0 && m_overflow_visible
)
1889 m_overflow_sizer_item
= sizer
->Add(overflow_size
, 1, 0, wxEXPAND
);
1891 m_overflow_sizer_item
= sizer
->Add(1, overflow_size
, 0, wxEXPAND
);
1895 m_overflow_sizer_item
= NULL
;
1900 // the outside sizer helps us apply the "top" and "bottom" padding
1901 wxBoxSizer
* outside_sizer
= new wxBoxSizer(horizontal ? wxVERTICAL
: wxHORIZONTAL
);
1903 // add "top" padding
1904 if (m_top_padding
> 0)
1907 outside_sizer
->Add(1, m_top_padding
);
1909 outside_sizer
->Add(m_top_padding
, 1);
1912 // add the sizer that contains all of the toolbar elements
1913 outside_sizer
->Add(sizer
, 1, wxEXPAND
);
1915 // add "bottom" padding
1916 if (m_bottom_padding
> 0)
1919 outside_sizer
->Add(1, m_bottom_padding
);
1921 outside_sizer
->Add(m_bottom_padding
, 1);
1924 delete m_sizer
; // remove old sizer
1925 m_sizer
= outside_sizer
;
1927 // calculate the rock-bottom minimum size
1928 for (i
= 0, count
= m_items
.GetCount(); i
< count
; ++i
)
1930 wxAuiToolBarItem
& item
= m_items
.Item(i
);
1931 if (item
.sizer_item
&& item
.proportion
> 0 && item
.min_size
.IsFullySpecified())
1932 item
.sizer_item
->SetMinSize(0,0);
1935 m_absolute_min_size
= m_sizer
->GetMinSize();
1937 // reset the min sizes to what they were
1938 for (i
= 0, count
= m_items
.GetCount(); i
< count
; ++i
)
1940 wxAuiToolBarItem
& item
= m_items
.Item(i
);
1941 if (item
.sizer_item
&& item
.proportion
> 0 && item
.min_size
.IsFullySpecified())
1942 item
.sizer_item
->SetMinSize(item
.min_size
);
1946 wxSize size
= m_sizer
->GetMinSize();
1947 m_minWidth
= size
.x
;
1948 m_minHeight
= size
.y
;
1950 if ((m_style
& wxAUI_TB_NO_AUTORESIZE
) == 0)
1952 wxSize cur_size
= GetClientSize();
1953 wxSize new_size
= GetMinSize();
1954 if (new_size
!= cur_size
)
1956 SetClientSize(new_size
);
1960 m_sizer
->SetDimension(0, 0, cur_size
.x
, cur_size
.y
);
1965 wxSize cur_size
= GetClientSize();
1966 m_sizer
->SetDimension(0, 0, cur_size
.x
, cur_size
.y
);
1973 int wxAuiToolBar
::GetOverflowState() const
1975 return m_overflow_state
;
1978 wxRect wxAuiToolBar
::GetOverflowRect() const
1980 wxRect
cli_rect(wxPoint(0,0), GetClientSize());
1981 wxRect overflow_rect
= m_overflow_sizer_item
->GetRect();
1982 int overflow_size
= m_art
->GetElementSize(wxAUI_TBART_OVERFLOW_SIZE
);
1984 if (m_style
& wxAUI_TB_VERTICAL
)
1986 overflow_rect
.y
= cli_rect
.height
- overflow_size
;
1987 overflow_rect
.x
= 0;
1988 overflow_rect
.width
= cli_rect
.width
;
1989 overflow_rect
.height
= overflow_size
;
1993 overflow_rect
.x
= cli_rect
.width
- overflow_size
;
1994 overflow_rect
.y
= 0;
1995 overflow_rect
.width
= overflow_size
;
1996 overflow_rect
.height
= cli_rect
.height
;
1999 return overflow_rect
;
2002 wxSize wxAuiToolBar
::GetLabelSize(const wxString
& label
)
2004 wxClientDC
dc(this);
2007 int text_width
= 0, text_height
= 0;
2011 // get the text height
2012 dc
.GetTextExtent(wxT("ABCDHgj"), &tx
, &text_height
);
2014 // get the text width
2015 dc
.GetTextExtent(label
, &text_width
, &ty
);
2017 return wxSize(text_width
, text_height
);
2021 void wxAuiToolBar
::DoIdleUpdate()
2023 wxEvtHandler
* handler
= GetEventHandler();
2025 bool need_refresh
= false;
2028 for (i
= 0, count
= m_items
.GetCount(); i
< count
; ++i
)
2030 wxAuiToolBarItem
& item
= m_items
.Item(i
);
2035 wxUpdateUIEvent
evt(item
.id
);
2036 evt
.SetEventObject(this);
2038 if (handler
->ProcessEvent(evt
))
2040 if (evt
.GetSetEnabled())
2044 is_enabled
= item
.window
->IsEnabled();
2046 is_enabled
= (item
.state
& wxAUI_BUTTON_STATE_DISABLED
) ?
false : true;
2048 bool new_enabled
= evt
.GetEnabled();
2049 if (new_enabled
!= is_enabled
)
2053 item
.window
->Enable(new_enabled
);
2058 item
.state
&= ~wxAUI_BUTTON_STATE_DISABLED
;
2060 item
.state
|= wxAUI_BUTTON_STATE_DISABLED
;
2062 need_refresh
= true;
2066 if (evt
.GetSetChecked())
2068 // make sure we aren't checking an item that can't be
2069 if (item
.kind
!= wxITEM_CHECK
&& item
.kind
!= wxITEM_RADIO
)
2072 bool is_checked
= (item
.state
& wxAUI_BUTTON_STATE_CHECKED
) ?
true : false;
2073 bool new_checked
= evt
.GetChecked();
2075 if (new_checked
!= is_checked
)
2078 item
.state
|= wxAUI_BUTTON_STATE_CHECKED
;
2080 item
.state
&= ~wxAUI_BUTTON_STATE_CHECKED
;
2082 need_refresh
= true;
2097 void wxAuiToolBar
::OnSize(wxSizeEvent
& WXUNUSED(evt
))
2100 GetClientSize(&x
, &y
);
2103 SetOrientation(wxHORIZONTAL
);
2105 SetOrientation(wxVERTICAL
);
2107 if (((x
>= y
) && m_absolute_min_size
.x
> x
) ||
2108 ((y
> x
) && m_absolute_min_size
.y
> y
))
2110 // hide all flexible items
2112 for (i
= 0, count
= m_items
.GetCount(); i
< count
; ++i
)
2114 wxAuiToolBarItem
& item
= m_items
.Item(i
);
2115 if (item
.sizer_item
&& item
.proportion
> 0 && item
.sizer_item
->IsShown())
2117 item
.sizer_item
->Show(false);
2118 item
.sizer_item
->SetProportion(0);
2124 // show all flexible items
2126 for (i
= 0, count
= m_items
.GetCount(); i
< count
; ++i
)
2128 wxAuiToolBarItem
& item
= m_items
.Item(i
);
2129 if (item
.sizer_item
&& item
.proportion
> 0 && !item
.sizer_item
->IsShown())
2131 item
.sizer_item
->Show(true);
2132 item
.sizer_item
->SetProportion(item
.proportion
);
2137 m_sizer
->SetDimension(0, 0, x
, y
);
2145 void wxAuiToolBar
::DoSetSize(int x
,
2151 wxSize parent_size
= GetParent()->GetClientSize();
2152 if (x
+ width
> parent_size
.x
)
2153 width
= wxMax(0, parent_size
.x
- x
);
2154 if (y
+ height
> parent_size
.y
)
2155 height
= wxMax(0, parent_size
.y
- y
);
2157 wxWindow
::DoSetSize(x
, y
, width
, height
, sizeFlags
);
2161 void wxAuiToolBar
::OnIdle(wxIdleEvent
& evt
)
2167 void wxAuiToolBar
::OnPaint(wxPaintEvent
& WXUNUSED(evt
))
2169 wxBufferedPaintDC
dc(this);
2170 wxRect
cli_rect(wxPoint(0,0), GetClientSize());
2173 bool horizontal
= true;
2174 if (m_style
& wxAUI_TB_VERTICAL
)
2178 m_art
->DrawBackground(dc
, this, cli_rect
);
2180 int gripper_size
= m_art
->GetElementSize(wxAUI_TBART_GRIPPER_SIZE
);
2181 int dropdown_size
= m_art
->GetElementSize(wxAUI_TBART_OVERFLOW_SIZE
);
2183 // paint the gripper
2184 if (gripper_size
> 0 && m_gripper_sizer_item
)
2186 wxRect gripper_rect
= m_gripper_sizer_item
->GetRect();
2188 gripper_rect
.width
= gripper_size
;
2190 gripper_rect
.height
= gripper_size
;
2191 m_art
->DrawGripper(dc
, this, gripper_rect
);
2194 // calculated how far we can draw items
2197 last_extent
= cli_rect
.width
;
2199 last_extent
= cli_rect
.height
;
2200 if (m_overflow_visible
)
2201 last_extent
-= dropdown_size
;
2203 // paint each individual tool
2204 size_t i
, count
= m_items
.GetCount();
2205 for (i
= 0; i
< count
; ++i
)
2207 wxAuiToolBarItem
& item
= m_items
.Item(i
);
2209 if (!item
.sizer_item
)
2212 wxRect item_rect
= item
.sizer_item
->GetRect();
2215 if ((horizontal
&& item_rect
.x
+ item_rect
.width
>= last_extent
) ||
2216 (!horizontal
&& item_rect
.y
+ item_rect
.height
>= last_extent
))
2221 if (item
.kind
== wxITEM_SEPARATOR
)
2224 m_art
->DrawSeparator(dc
, this, item_rect
);
2226 else if (item
.kind
== wxITEM_LABEL
)
2228 // draw a text label only
2229 m_art
->DrawLabel(dc
, this, item
, item_rect
);
2231 else if (item
.kind
== wxITEM_NORMAL
)
2233 // draw a regular button or dropdown button
2235 m_art
->DrawButton(dc
, this, item
, item_rect
);
2237 m_art
->DrawDropDownButton(dc
, this, item
, item_rect
);
2239 else if (item
.kind
== wxITEM_CHECK
)
2241 // draw a toggle button
2242 m_art
->DrawButton(dc
, this, item
, item_rect
);
2244 else if (item
.kind
== wxITEM_RADIO
)
2246 // draw a toggle button
2247 m_art
->DrawButton(dc
, this, item
, item_rect
);
2249 else if (item
.kind
== wxITEM_CONTROL
)
2251 // draw the control's label
2252 m_art
->DrawControlLabel(dc
, this, item
, item_rect
);
2255 // fire a signal to see if the item wants to be custom-rendered
2256 OnCustomRender(dc
, item
, item_rect
);
2259 // paint the overflow button
2260 if (dropdown_size
> 0 && m_overflow_sizer_item
)
2262 wxRect dropdown_rect
= GetOverflowRect();
2263 m_art
->DrawOverflowButton(dc
, this, dropdown_rect
, m_overflow_state
);
2267 void wxAuiToolBar
::OnEraseBackground(wxEraseEvent
& WXUNUSED(evt
))
2272 void wxAuiToolBar
::OnLeftDown(wxMouseEvent
& evt
)
2274 wxRect
cli_rect(wxPoint(0,0), GetClientSize());
2276 if (m_gripper_sizer_item
)
2278 wxRect gripper_rect
= m_gripper_sizer_item
->GetRect();
2279 if (gripper_rect
.Contains(evt
.GetX(), evt
.GetY()))
2282 wxAuiManager
* manager
= wxAuiManager
::GetManager(this);
2286 int x_drag_offset
= evt
.GetX() - gripper_rect
.GetX();
2287 int y_drag_offset
= evt
.GetY() - gripper_rect
.GetY();
2289 // gripper was clicked
2290 manager
->StartPaneDrag(this, wxPoint(x_drag_offset
, y_drag_offset
));
2295 if (m_overflow_sizer_item
)
2297 wxRect overflow_rect
= GetOverflowRect();
2300 m_overflow_visible
&&
2301 overflow_rect
.Contains(evt
.m_x
, evt
.m_y
))
2303 wxAuiToolBarEvent
e(wxEVT_COMMAND_AUITOOLBAR_OVERFLOW_CLICK
, -1);
2304 e
.SetEventObject(this);
2306 e
.SetClickPoint(wxPoint(evt
.GetX(), evt
.GetY()));
2307 bool processed
= GetEventHandler()->ProcessEvent(e
);
2316 wxAuiToolBarItemArray overflow_items
;
2319 // add custom overflow prepend items, if any
2320 count
= m_custom_overflow_prepend
.GetCount();
2321 for (i
= 0; i
< count
; ++i
)
2322 overflow_items
.Add(m_custom_overflow_prepend
[i
]);
2324 // only show items that don't fit in the dropdown
2325 count
= m_items
.GetCount();
2326 for (i
= 0; i
< count
; ++i
)
2328 if (!GetToolFitsByIndex(i
))
2329 overflow_items
.Add(m_items
[i
]);
2332 // add custom overflow append items, if any
2333 count
= m_custom_overflow_append
.GetCount();
2334 for (i
= 0; i
< count
; ++i
)
2335 overflow_items
.Add(m_custom_overflow_append
[i
]);
2337 int res
= m_art
->ShowDropDown(this, overflow_items
);
2338 m_overflow_state
= 0;
2342 wxCommandEvent
e(wxEVT_COMMAND_MENU_SELECTED
, res
);
2343 e
.SetEventObject(this);
2344 GetParent()->GetEventHandler()->ProcessEvent(e
);
2353 m_action_pos
= wxPoint(evt
.GetX(), evt
.GetY());
2354 m_action_item
= FindToolByPosition(evt
.GetX(), evt
.GetY());
2358 if (m_action_item
->state
& wxAUI_BUTTON_STATE_DISABLED
)
2360 m_action_pos
= wxPoint(-1,-1);
2361 m_action_item
= NULL
;
2365 SetPressedItem(m_action_item
);
2367 // fire the tool dropdown event
2368 wxAuiToolBarEvent
e(wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN
, m_action_item
->id
);
2369 e
.SetEventObject(this);
2370 e
.SetToolId(m_action_item
->id
);
2371 e
.SetDropDownClicked(false);
2373 int mouse_x
= evt
.GetX();
2374 wxRect rect
= m_action_item
->sizer_item
->GetRect();
2376 if (m_action_item
->dropdown
&&
2377 mouse_x
>= (rect
.x
+rect
.width
-BUTTON_DROPDOWN_WIDTH
-1) &&
2378 mouse_x
< (rect
.x
+rect
.width
))
2380 e
.SetDropDownClicked(true);
2383 e
.SetClickPoint(evt
.GetPosition());
2384 e
.SetItemRect(rect
);
2385 GetEventHandler()->ProcessEvent(e
);
2390 void wxAuiToolBar
::OnLeftUp(wxMouseEvent
& evt
)
2392 SetPressedItem(NULL
);
2394 wxAuiToolBarItem
* hit_item
= FindToolByPosition(evt
.GetX(), evt
.GetY());
2395 if (hit_item
&& !(hit_item
->state
& wxAUI_BUTTON_STATE_DISABLED
))
2397 SetHoverItem(hit_item
);
2403 // reset drag and drop member variables
2405 m_action_pos
= wxPoint(-1,-1);
2406 m_action_item
= NULL
;
2411 wxAuiToolBarItem
* hit_item
;
2412 hit_item
= FindToolByPosition(evt
.GetX(), evt
.GetY());
2414 if (m_action_item
&& hit_item
== m_action_item
)
2418 if (hit_item
->kind
== wxITEM_CHECK
|| hit_item
->kind
== wxITEM_RADIO
)
2420 bool toggle
= false;
2422 if (m_action_item
->state
& wxAUI_BUTTON_STATE_CHECKED
)
2427 ToggleTool(m_action_item
->id
, toggle
);
2429 // repaint immediately
2433 wxCommandEvent
e(wxEVT_COMMAND_MENU_SELECTED
, m_action_item
->id
);
2434 e
.SetEventObject(this);
2435 GetEventHandler()->ProcessEvent(e
);
2440 wxCommandEvent
e(wxEVT_COMMAND_MENU_SELECTED
, m_action_item
->id
);
2441 e
.SetEventObject(this);
2442 GetEventHandler()->ProcessEvent(e
);
2448 // reset drag and drop member variables
2450 m_action_pos
= wxPoint(-1,-1);
2451 m_action_item
= NULL
;
2454 void wxAuiToolBar
::OnRightDown(wxMouseEvent
& evt
)
2456 wxRect
cli_rect(wxPoint(0,0), GetClientSize());
2458 if (m_gripper_sizer_item
)
2460 wxRect gripper_rect
= m_gripper_sizer_item
->GetRect();
2461 if (gripper_rect
.Contains(evt
.GetX(), evt
.GetY()))
2465 if (m_overflow_sizer_item
)
2467 int dropdown_size
= m_art
->GetElementSize(wxAUI_TBART_OVERFLOW_SIZE
);
2468 if (dropdown_size
> 0 &&
2469 evt
.m_x
> cli_rect
.width
- dropdown_size
&&
2471 evt
.m_y
< cli_rect
.height
&&
2478 m_action_pos
= wxPoint(evt
.GetX(), evt
.GetY());
2479 m_action_item
= FindToolByPosition(evt
.GetX(), evt
.GetY());
2483 if (m_action_item
->state
& wxAUI_BUTTON_STATE_DISABLED
)
2485 m_action_pos
= wxPoint(-1,-1);
2486 m_action_item
= NULL
;
2492 void wxAuiToolBar
::OnRightUp(wxMouseEvent
& evt
)
2494 wxAuiToolBarItem
* hit_item
;
2495 hit_item
= FindToolByPosition(evt
.GetX(), evt
.GetY());
2497 if (m_action_item
&& hit_item
== m_action_item
)
2499 if (hit_item
->kind
== wxITEM_NORMAL
)
2501 wxAuiToolBarEvent
e(wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK
, m_action_item
->id
);
2502 e
.SetEventObject(this);
2503 e
.SetToolId(m_action_item
->id
);
2504 e
.SetClickPoint(m_action_pos
);
2505 GetEventHandler()->ProcessEvent(e
);
2511 // right-clicked on the invalid area of the toolbar
2512 wxAuiToolBarEvent
e(wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK
, -1);
2513 e
.SetEventObject(this);
2515 e
.SetClickPoint(m_action_pos
);
2516 GetEventHandler()->ProcessEvent(e
);
2520 // reset member variables
2521 m_action_pos
= wxPoint(-1,-1);
2522 m_action_item
= NULL
;
2525 void wxAuiToolBar
::OnMiddleDown(wxMouseEvent
& evt
)
2527 wxRect
cli_rect(wxPoint(0,0), GetClientSize());
2529 if (m_gripper_sizer_item
)
2531 wxRect gripper_rect
= m_gripper_sizer_item
->GetRect();
2532 if (gripper_rect
.Contains(evt
.GetX(), evt
.GetY()))
2536 if (m_overflow_sizer_item
)
2538 int dropdown_size
= m_art
->GetElementSize(wxAUI_TBART_OVERFLOW_SIZE
);
2539 if (dropdown_size
> 0 &&
2540 evt
.m_x
> cli_rect
.width
- dropdown_size
&&
2542 evt
.m_y
< cli_rect
.height
&&
2549 m_action_pos
= wxPoint(evt
.GetX(), evt
.GetY());
2550 m_action_item
= FindToolByPosition(evt
.GetX(), evt
.GetY());
2554 if (m_action_item
->state
& wxAUI_BUTTON_STATE_DISABLED
)
2556 m_action_pos
= wxPoint(-1,-1);
2557 m_action_item
= NULL
;
2563 void wxAuiToolBar
::OnMiddleUp(wxMouseEvent
& evt
)
2565 wxAuiToolBarItem
* hit_item
;
2566 hit_item
= FindToolByPosition(evt
.GetX(), evt
.GetY());
2568 if (m_action_item
&& hit_item
== m_action_item
)
2570 if (hit_item
->kind
== wxITEM_NORMAL
)
2572 wxAuiToolBarEvent
e(wxEVT_COMMAND_AUITOOLBAR_MIDDLE_CLICK
, m_action_item
->id
);
2573 e
.SetEventObject(this);
2574 e
.SetToolId(m_action_item
->id
);
2575 e
.SetClickPoint(m_action_pos
);
2576 GetEventHandler()->ProcessEvent(e
);
2581 // reset member variables
2582 m_action_pos
= wxPoint(-1,-1);
2583 m_action_item
= NULL
;
2586 void wxAuiToolBar
::OnMotion(wxMouseEvent
& evt
)
2588 // start a drag event
2590 m_action_item
!= NULL
&&
2591 m_action_pos
!= wxPoint(-1,-1) &&
2592 abs(evt
.m_x
- m_action_pos
.x
) + abs(evt
.m_y
- m_action_pos
.y
) > 5)
2598 wxAuiToolBarEvent
e(wxEVT_COMMAND_AUITOOLBAR_BEGIN_DRAG
, GetId());
2599 e
.SetEventObject(this);
2600 e
.SetToolId(m_action_item
->id
);
2601 GetEventHandler()->ProcessEvent(e
);
2606 wxAuiToolBarItem
* hit_item
= FindToolByPosition(evt
.GetX(), evt
.GetY());
2609 if (!(hit_item
->state
& wxAUI_BUTTON_STATE_DISABLED
))
2610 SetHoverItem(hit_item
);
2616 // no hit item, remove any hit item
2617 SetHoverItem(hit_item
);
2620 // figure out tooltips
2621 wxAuiToolBarItem
* packing_hit_item
;
2622 packing_hit_item
= FindToolByPositionWithPacking(evt
.GetX(), evt
.GetY());
2623 if (packing_hit_item
)
2625 if (packing_hit_item
!= m_tip_item
)
2627 m_tip_item
= packing_hit_item
;
2629 if ( !packing_hit_item
->short_help
.empty() )
2630 SetToolTip(packing_hit_item
->short_help
);
2641 // if we've pressed down an item and we're hovering
2642 // over it, make sure it's state is set to pressed
2645 if (m_action_item
== hit_item
)
2646 SetPressedItem(m_action_item
);
2648 SetPressedItem(NULL
);
2651 // figure out the dropdown button state (are we hovering or pressing it?)
2652 RefreshOverflowState();
2655 void wxAuiToolBar
::OnLeaveWindow(wxMouseEvent
& WXUNUSED(evt
))
2657 RefreshOverflowState();
2659 SetPressedItem(NULL
);
2665 void wxAuiToolBar
::OnSetCursor(wxSetCursorEvent
& evt
)
2667 wxCursor cursor
= wxNullCursor
;
2669 if (m_gripper_sizer_item
)
2671 wxRect gripper_rect
= m_gripper_sizer_item
->GetRect();
2672 if (gripper_rect
.Contains(evt
.GetX(), evt
.GetY()))
2674 cursor
= wxCursor(wxCURSOR_SIZING
);
2678 evt
.SetCursor(cursor
);