1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/ribbon/bar.h
3 // Purpose: Top-level component of the ribbon-bar-style interface
4 // Author: Peter Cawley
8 // Copyright: (C) Peter Cawley
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_RIBBON_BAR_H_
13 #define _WX_RIBBON_BAR_H_
19 #include "wx/ribbon/control.h"
20 #include "wx/ribbon/page.h"
22 enum wxRibbonBarOption
24 wxRIBBON_BAR_SHOW_PAGE_LABELS
= 1 << 0,
25 wxRIBBON_BAR_SHOW_PAGE_ICONS
= 1 << 1,
26 wxRIBBON_BAR_FLOW_HORIZONTAL
= 0,
27 wxRIBBON_BAR_FLOW_VERTICAL
= 1 << 2,
28 wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS
= 1 << 3,
29 wxRIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONS
= 1 << 4,
30 wxRIBBON_BAR_ALWAYS_SHOW_TABS
= 1 << 5,
31 wxRIBBON_BAR_SHOW_TOGGLE_BUTTON
= 1 << 6,
32 wxRIBBON_BAR_SHOW_HELP_BUTTON
= 1 << 7,
34 wxRIBBON_BAR_DEFAULT_STYLE
= wxRIBBON_BAR_FLOW_HORIZONTAL
35 | wxRIBBON_BAR_SHOW_PAGE_LABELS
36 | wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS
37 | wxRIBBON_BAR_SHOW_TOGGLE_BUTTON
38 | wxRIBBON_BAR_SHOW_HELP_BUTTON
,
40 wxRIBBON_BAR_FOLDBAR_STYLE
= wxRIBBON_BAR_FLOW_VERTICAL
41 | wxRIBBON_BAR_SHOW_PAGE_ICONS
42 | wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS
43 | wxRIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONS
46 enum wxRibbonDisplayMode
49 wxRIBBON_BAR_MINIMIZED
,
53 class WXDLLIMPEXP_RIBBON wxRibbonBarEvent
: public wxNotifyEvent
56 wxRibbonBarEvent(wxEventType command_type
= wxEVT_NULL
,
58 wxRibbonPage
* page
= NULL
)
59 : wxNotifyEvent(command_type
, win_id
)
64 wxRibbonBarEvent(const wxRibbonBarEvent
& c
) : wxNotifyEvent(c
)
69 wxEvent
*Clone() const { return new wxRibbonBarEvent(*this); }
71 wxRibbonPage
* GetPage() {return m_page
;}
72 void SetPage(wxRibbonPage
* page
) {m_page
= page
;}
79 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonBarEvent
)
83 class WXDLLIMPEXP_RIBBON wxRibbonPageTabInfo
89 int small_begin_need_separator_width
;
90 int small_must_have_separator_width
;
99 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxRibbonPageTabInfo
, wxRibbonPageTabInfoArray
, WXDLLIMPEXP_RIBBON
);
102 class WXDLLIMPEXP_RIBBON wxRibbonBar
: public wxRibbonControl
107 wxRibbonBar(wxWindow
* parent
,
108 wxWindowID id
= wxID_ANY
,
109 const wxPoint
& pos
= wxDefaultPosition
,
110 const wxSize
& size
= wxDefaultSize
,
111 long style
= wxRIBBON_BAR_DEFAULT_STYLE
);
113 virtual ~wxRibbonBar();
115 bool Create(wxWindow
* parent
,
116 wxWindowID id
= wxID_ANY
,
117 const wxPoint
& pos
= wxDefaultPosition
,
118 const wxSize
& size
= wxDefaultSize
,
119 long style
= wxRIBBON_BAR_DEFAULT_STYLE
);
121 void SetTabCtrlMargins(int left
, int right
);
123 void SetArtProvider(wxRibbonArtProvider
* art
);
125 bool SetActivePage(size_t page
);
126 bool SetActivePage(wxRibbonPage
* page
);
127 int GetActivePage() const;
128 wxRibbonPage
* GetPage(int n
);
129 size_t GetPageCount() const;
130 bool DismissExpandedPanel();
131 int GetPageNumber(wxRibbonPage
* page
) const;
133 void DeletePage(size_t n
);
136 bool IsPageShown(size_t page
) const;
137 void ShowPage(size_t page
, bool show
= true);
138 void HidePage(size_t page
) { ShowPage(page
, false); }
140 bool IsPageHighlighted(size_t page
) const;
141 void AddPageHighlight(size_t page
, bool highlight
= true);
142 void RemovePageHighlight(size_t page
) { AddPageHighlight(page
, false); }
144 void ShowPanels(bool show
= true);
145 void HidePanels() { ShowPanels(false); }
146 bool ArePanelsShown() const { return m_arePanelsShown
; }
148 virtual bool HasMultiplePages() const { return true; }
150 void SetWindowStyleFlag(long style
);
151 long GetWindowStyleFlag() const;
152 virtual bool Realize();
154 // Implementation only.
155 bool IsToggleButtonHovered() const { return m_toggle_button_hovered
; }
156 bool IsHelpButtonHovered() const { return m_help_button_hovered
; }
158 void HideIfExpanded();
161 friend class wxRibbonPage
;
163 virtual wxSize
DoGetBestSize() const;
164 wxBorder
GetDefaultBorder() const { return wxBORDER_NONE
; }
165 wxRibbonPageTabInfo
* HitTestTabs(wxPoint position
, int* index
= NULL
);
166 void HitTestRibbonButton(const wxRect
& rect
, const wxPoint
& position
, bool &hover_flag
);
168 void CommonInit(long style
);
169 void AddPage(wxRibbonPage
*page
);
170 void RecalculateTabSizes();
171 void RecalculateMinSize();
172 void ScrollTabBar(int npixels
);
173 void RefreshTabBar();
174 void RepositionPage(wxRibbonPage
*page
);
176 void OnPaint(wxPaintEvent
& evt
);
177 void OnEraseBackground(wxEraseEvent
& evt
);
178 void DoEraseBackground(wxDC
& dc
);
179 void OnSize(wxSizeEvent
& evt
);
180 void OnMouseLeftDown(wxMouseEvent
& evt
);
181 void OnMouseLeftUp(wxMouseEvent
& evt
);
182 void OnMouseMiddleDown(wxMouseEvent
& evt
);
183 void OnMouseMiddleUp(wxMouseEvent
& evt
);
184 void OnMouseRightDown(wxMouseEvent
& evt
);
185 void OnMouseRightUp(wxMouseEvent
& evt
);
186 void OnMouseMove(wxMouseEvent
& evt
);
187 void OnMouseLeave(wxMouseEvent
& evt
);
188 void OnMouseDoubleClick(wxMouseEvent
& evt
);
189 void DoMouseButtonCommon(wxMouseEvent
& evt
, wxEventType tab_event_type
);
190 void OnKillFocus(wxFocusEvent
& evt
);
192 wxRibbonPageTabInfoArray m_pages
;
193 wxRect m_tab_scroll_left_button_rect
;
194 wxRect m_tab_scroll_right_button_rect
;
195 wxRect m_toggle_button_rect
;
196 wxRect m_help_button_rect
;
198 int m_tabs_total_width_ideal
;
199 int m_tabs_total_width_minimum
;
200 int m_tab_margin_left
;
201 int m_tab_margin_right
;
203 int m_tab_scroll_amount
;
205 int m_current_hovered_page
;
206 int m_tab_scroll_left_button_state
;
207 int m_tab_scroll_right_button_state
;
208 bool m_tab_scroll_buttons_shown
;
209 bool m_arePanelsShown
;
211 bool m_toggle_button_hovered
;
212 bool m_help_button_hovered
;
214 wxRibbonDisplayMode m_ribbon_state
;
217 DECLARE_CLASS(wxRibbonBar
)
218 DECLARE_EVENT_TABLE()
224 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED
, wxRibbonBarEvent
);
225 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING
, wxRibbonBarEvent
);
226 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN
, wxRibbonBarEvent
);
227 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP
, wxRibbonBarEvent
);
228 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN
, wxRibbonBarEvent
);
229 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP
, wxRibbonBarEvent
);
230 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK
, wxRibbonBarEvent
);
231 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONBAR_TOGGLED
, wxRibbonBarEvent
);
232 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONBAR_HELP_CLICKED
, wxRibbonBarEvent
);
234 typedef void (wxEvtHandler::*wxRibbonBarEventFunction
)(wxRibbonBarEvent
&);
236 #define wxRibbonBarEventHandler(func) \
237 wxEVENT_HANDLER_CAST(wxRibbonBarEventFunction, func)
239 #define EVT_RIBBONBAR_PAGE_CHANGED(winid, fn) \
240 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED, winid, wxRibbonBarEventHandler(fn))
241 #define EVT_RIBBONBAR_PAGE_CHANGING(winid, fn) \
242 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING, winid, wxRibbonBarEventHandler(fn))
243 #define EVT_RIBBONBAR_TAB_MIDDLE_DOWN(winid, fn) \
244 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN, winid, wxRibbonBarEventHandler(fn))
245 #define EVT_RIBBONBAR_TAB_MIDDLE_UP(winid, fn) \
246 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP, winid, wxRibbonBarEventHandler(fn))
247 #define EVT_RIBBONBAR_TAB_RIGHT_DOWN(winid, fn) \
248 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN, winid, wxRibbonBarEventHandler(fn))
249 #define EVT_RIBBONBAR_TAB_RIGHT_UP(winid, fn) \
250 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP, winid, wxRibbonBarEventHandler(fn))
251 #define EVT_RIBBONBAR_TAB_LEFT_DCLICK(winid, fn) \
252 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK, winid, wxRibbonBarEventHandler(fn))
253 #define EVT_RIBBONBAR_TOGGLED(winid, fn) \
254 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TOGGLED, winid, wxRibbonBarEventHandler(fn))
255 #define EVT_RIBBONBAR_HELP_CLICK(winid, fn) \
256 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_HELP_CLICKED, winid, wxRibbonBarEventHandler(fn))
259 // wxpython/swig event work
260 %constant wxEventType wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED
;
261 %constant wxEventType wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING
;
262 %constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN
;
263 %constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP
;
264 %constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN
;
265 %constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP
;
266 %constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK
;
267 %constant wxEventType wxEVT_COMMAND_RIBBONBAR_TOGGLED
;
268 %constant wxEventType wxEVT_COMMAND_RIBBONBAR_HELP_CLICKED
;
271 EVT_RIBBONBAR_PAGE_CHANGED
= wx
.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED
, 1 )
272 EVT_RIBBONBAR_PAGE_CHANGING
= wx
.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING
, 1 )
273 EVT_RIBBONBAR_TAB_MIDDLE_DOWN
= wx
.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN
, 1 )
274 EVT_RIBBONBAR_TAB_MIDDLE_UP
= wx
.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP
, 1 )
275 EVT_RIBBONBAR_TAB_RIGHT_DOWN
= wx
.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN
, 1 )
276 EVT_RIBBONBAR_TAB_RIGHT_UP
= wx
.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP
, 1 )
277 EVT_RIBBONBAR_TAB_LEFT_DCLICK
= wx
.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK
, 1 )
278 EVT_RIBBONBAR_TOGGLED
= wx
.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TOGGLED
, 1 )
279 EVT_RIBBONBAR_HELP_CLICK
= wx
.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_HELP_CLICKED
, 1 )
283 #endif // wxUSE_RIBBON
285 #endif // _WX_RIBBON_BAR_H_