1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/ribbon/toolbar.h
3 // Purpose: Ribbon-style tool bar
4 // Author: Peter Cawley
8 // Copyright: (C) Peter Cawley
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_RIBBON_TOOLBAR_H_
12 #define _WX_RIBBON_TOOLBAR_H_
18 #include "wx/ribbon/control.h"
19 #include "wx/ribbon/art.h"
21 class wxRibbonToolBarToolBase
;
22 class wxRibbonToolBarToolGroup
;
23 WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxRibbonToolBarToolGroup
*, wxArrayRibbonToolBarToolGroup
, class WXDLLIMPEXP_RIBBON
);
25 enum wxRibbonToolBarToolState
27 wxRIBBON_TOOLBAR_TOOL_FIRST
= 1 << 0,
28 wxRIBBON_TOOLBAR_TOOL_LAST
= 1 << 1,
29 wxRIBBON_TOOLBAR_TOOL_POSITION_MASK
= wxRIBBON_TOOLBAR_TOOL_FIRST
| wxRIBBON_TOOLBAR_TOOL_LAST
,
31 wxRIBBON_TOOLBAR_TOOL_NORMAL_HOVERED
= 1 << 3,
32 wxRIBBON_TOOLBAR_TOOL_DROPDOWN_HOVERED
= 1 << 4,
33 wxRIBBON_TOOLBAR_TOOL_HOVER_MASK
= wxRIBBON_TOOLBAR_TOOL_NORMAL_HOVERED
| wxRIBBON_TOOLBAR_TOOL_DROPDOWN_HOVERED
,
34 wxRIBBON_TOOLBAR_TOOL_NORMAL_ACTIVE
= 1 << 5,
35 wxRIBBON_TOOLBAR_TOOL_DROPDOWN_ACTIVE
= 1 << 6,
36 wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK
= wxRIBBON_TOOLBAR_TOOL_NORMAL_ACTIVE
| wxRIBBON_TOOLBAR_TOOL_DROPDOWN_ACTIVE
,
37 wxRIBBON_TOOLBAR_TOOL_DISABLED
= 1 << 7,
38 wxRIBBON_TOOLBAR_TOOL_STATE_MASK
= 0xF8
42 class WXDLLIMPEXP_RIBBON wxRibbonToolBar
: public wxRibbonControl
47 wxRibbonToolBar(wxWindow
* parent
,
48 wxWindowID id
= wxID_ANY
,
49 const wxPoint
& pos
= wxDefaultPosition
,
50 const wxSize
& size
= wxDefaultSize
,
53 virtual ~wxRibbonToolBar();
55 bool Create(wxWindow
* parent
,
56 wxWindowID id
= wxID_ANY
,
57 const wxPoint
& pos
= wxDefaultPosition
,
58 const wxSize
& size
= wxDefaultSize
,
61 virtual wxRibbonToolBarToolBase
* AddTool(
63 const wxBitmap
& bitmap
,
64 const wxString
& help_string
,
65 wxRibbonButtonKind kind
= wxRIBBON_BUTTON_NORMAL
);
67 virtual wxRibbonToolBarToolBase
* AddDropdownTool(
69 const wxBitmap
& bitmap
,
70 const wxString
& help_string
= wxEmptyString
);
72 virtual wxRibbonToolBarToolBase
* AddHybridTool(
74 const wxBitmap
& bitmap
,
75 const wxString
& help_string
= wxEmptyString
);
77 virtual wxRibbonToolBarToolBase
* AddTool(
79 const wxBitmap
& bitmap
,
80 const wxBitmap
& bitmap_disabled
= wxNullBitmap
,
81 const wxString
& help_string
= wxEmptyString
,
82 wxRibbonButtonKind kind
= wxRIBBON_BUTTON_NORMAL
,
83 wxObject
* client_data
= NULL
);
85 virtual wxRibbonToolBarToolBase
* AddSeparator();
87 virtual bool Realize();
88 virtual void SetRows(int nMin
, int nMax
= -1);
90 virtual bool IsSizingContinuous() const;
93 friend class wxRibbonToolBarEvent
;
94 virtual wxSize
DoGetBestSize() const;
95 wxBorder
GetDefaultBorder() const { return wxBORDER_NONE
; }
97 void OnEraseBackground(wxEraseEvent
& evt
);
98 void OnMouseDown(wxMouseEvent
& evt
);
99 void OnMouseEnter(wxMouseEvent
& evt
);
100 void OnMouseLeave(wxMouseEvent
& evt
);
101 void OnMouseMove(wxMouseEvent
& evt
);
102 void OnMouseUp(wxMouseEvent
& evt
);
103 void OnPaint(wxPaintEvent
& evt
);
104 void OnSize(wxSizeEvent
& evt
);
106 virtual wxSize
DoGetNextSmallerSize(wxOrientation direction
,
107 wxSize relative_to
) const;
108 virtual wxSize
DoGetNextLargerSize(wxOrientation direction
,
109 wxSize relative_to
) const;
111 void CommonInit(long style
);
114 static wxBitmap
MakeDisabledBitmap(const wxBitmap
& original
);
116 wxArrayRibbonToolBarToolGroup m_groups
;
117 wxRibbonToolBarToolBase
* m_hover_tool
;
118 wxRibbonToolBarToolBase
* m_active_tool
;
124 DECLARE_CLASS(wxRibbonToolBar
)
125 DECLARE_EVENT_TABLE()
130 class WXDLLIMPEXP_RIBBON wxRibbonToolBarEvent
: public wxCommandEvent
133 wxRibbonToolBarEvent(wxEventType command_type
= wxEVT_NULL
,
135 wxRibbonToolBar
* bar
= NULL
)
136 : wxCommandEvent(command_type
, win_id
)
141 wxRibbonToolBarEvent(const wxRibbonToolBarEvent
& e
) : wxCommandEvent(e
)
146 wxEvent
*Clone() const { return new wxRibbonToolBarEvent(*this); }
148 wxRibbonToolBar
* GetBar() {return m_bar
;}
149 void SetBar(wxRibbonToolBar
* bar
) {m_bar
= bar
;}
150 bool PopupMenu(wxMenu
* menu
);
153 wxRibbonToolBar
* m_bar
;
157 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonToolBarEvent
)
163 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONTOOL_CLICKED
, wxRibbonToolBarEvent
);
164 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONTOOL_DROPDOWN_CLICKED
, wxRibbonToolBarEvent
);
166 typedef void (wxEvtHandler::*wxRibbonToolBarEventFunction
)(wxRibbonToolBarEvent
&);
168 #define wxRibbonToolBarEventHandler(func) \
169 wxEVENT_HANDLER_CAST(wxRibbonToolBarEventFunction, func)
171 #define EVT_RIBBONTOOLBAR_CLICKED(winid, fn) \
172 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONTOOL_CLICKED, winid, wxRibbonToolBarEventHandler(fn))
173 #define EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(winid, fn) \
174 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONTOOL_DROPDOWN_CLICKED, winid, wxRibbonToolBarEventHandler(fn))
177 // wxpython/swig event work
178 %constant wxEventType wxEVT_COMMAND_RIBBONTOOL_CLICKED
;
179 %constant wxEventType wxEVT_COMMAND_RIBBONTOOL_DROPDOWN_CLICKED
;
182 EVT_RIBBONTOOLBAR_CLICKED
= wx
.PyEventBinder( wxEVT_COMMAND_RIBBONTOOL_CLICKED
, 1 )
183 EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED
= wx
.PyEventBinder( wxEVT_COMMAND_RIBBONTOOL_DROPDOWN_CLICKED
, 1 )
187 #endif // wxUSE_RIBBON
189 #endif // _WX_RIBBON_TOOLBAR_H_