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,
32 wxRIBBON_BAR_DEFAULT_STYLE
= wxRIBBON_BAR_FLOW_HORIZONTAL
33 | wxRIBBON_BAR_SHOW_PAGE_LABELS
34 | wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS
,
36 wxRIBBON_BAR_FOLDBAR_STYLE
= wxRIBBON_BAR_FLOW_VERTICAL
37 | wxRIBBON_BAR_SHOW_PAGE_ICONS
38 | wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS
39 | wxRIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONS
42 class WXDLLIMPEXP_RIBBON wxRibbonBarEvent
: public wxNotifyEvent
45 wxRibbonBarEvent(wxEventType command_type
= wxEVT_NULL
,
47 wxRibbonPage
* page
= NULL
)
48 : wxNotifyEvent(command_type
, win_id
)
53 wxRibbonBarEvent(const wxRibbonBarEvent
& c
) : wxNotifyEvent(c
)
58 wxEvent
*Clone() const { return new wxRibbonBarEvent(*this); }
60 wxRibbonPage
* GetPage() {return m_page
;}
61 void SetPage(wxRibbonPage
* page
) {m_page
= page
;}
68 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonBarEvent
)
72 class WXDLLIMPEXP_RIBBON wxRibbonPageTabInfo
78 int small_begin_need_separator_width
;
79 int small_must_have_separator_width
;
86 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxRibbonPageTabInfo
, wxRibbonPageTabInfoArray
, WXDLLIMPEXP_RIBBON
);
89 class WXDLLIMPEXP_RIBBON wxRibbonBar
: public wxRibbonControl
94 wxRibbonBar(wxWindow
* parent
,
95 wxWindowID id
= wxID_ANY
,
96 const wxPoint
& pos
= wxDefaultPosition
,
97 const wxSize
& size
= wxDefaultSize
,
98 long style
= wxRIBBON_BAR_DEFAULT_STYLE
);
100 virtual ~wxRibbonBar();
102 bool Create(wxWindow
* parent
,
103 wxWindowID id
= wxID_ANY
,
104 const wxPoint
& pos
= wxDefaultPosition
,
105 const wxSize
& size
= wxDefaultSize
,
106 long style
= wxRIBBON_BAR_DEFAULT_STYLE
);
108 void SetTabCtrlMargins(int left
, int right
);
110 void SetArtProvider(wxRibbonArtProvider
* art
);
112 bool SetActivePage(size_t page
);
113 bool SetActivePage(wxRibbonPage
* page
);
114 int GetActivePage() const;
115 wxRibbonPage
* GetPage(int n
);
116 bool DismissExpandedPanel();
118 void ShowPanels(bool show
= true);
119 void HidePanels() { ShowPanels(false); }
120 bool ArePanelsShown() const { return m_arePanelsShown
; }
122 virtual bool HasMultiplePages() const { return true; }
124 void SetWindowStyleFlag(long style
);
125 long GetWindowStyleFlag() const;
126 virtual bool Realize();
129 friend class wxRibbonPage
;
131 virtual wxSize
DoGetBestSize() const;
132 wxBorder
GetDefaultBorder() const { return wxBORDER_NONE
; }
133 wxRibbonPageTabInfo
* HitTestTabs(wxPoint position
, int* index
= NULL
);
135 void CommonInit(long style
);
136 void AddPage(wxRibbonPage
*page
);
137 void RecalculateTabSizes();
138 void RecalculateMinSize();
139 void ScrollTabBar(int npixels
);
140 void RefreshTabBar();
141 void RepositionPage(wxRibbonPage
*page
);
143 void OnPaint(wxPaintEvent
& evt
);
144 void OnEraseBackground(wxEraseEvent
& evt
);
145 void DoEraseBackground(wxDC
& dc
);
146 void OnSize(wxSizeEvent
& evt
);
147 void OnMouseLeftDown(wxMouseEvent
& evt
);
148 void OnMouseLeftUp(wxMouseEvent
& evt
);
149 void OnMouseMiddleDown(wxMouseEvent
& evt
);
150 void OnMouseMiddleUp(wxMouseEvent
& evt
);
151 void OnMouseRightDown(wxMouseEvent
& evt
);
152 void OnMouseRightUp(wxMouseEvent
& evt
);
153 void OnMouseMove(wxMouseEvent
& evt
);
154 void OnMouseLeave(wxMouseEvent
& evt
);
155 void OnMouseDoubleClick(wxMouseEvent
& evt
);
156 void DoMouseButtonCommon(wxMouseEvent
& evt
, wxEventType tab_event_type
);
158 wxRibbonPageTabInfoArray m_pages
;
159 wxRect m_tab_scroll_left_button_rect
;
160 wxRect m_tab_scroll_right_button_rect
;
162 int m_tabs_total_width_ideal
;
163 int m_tabs_total_width_minimum
;
164 int m_tab_margin_left
;
165 int m_tab_margin_right
;
167 int m_tab_scroll_amount
;
169 int m_current_hovered_page
;
170 int m_tab_scroll_left_button_state
;
171 int m_tab_scroll_right_button_state
;
172 bool m_tab_scroll_buttons_shown
;
173 bool m_arePanelsShown
;
176 DECLARE_CLASS(wxRibbonBar
)
177 DECLARE_EVENT_TABLE()
183 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED
, wxRibbonBarEvent
);
184 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING
, wxRibbonBarEvent
);
185 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN
, wxRibbonBarEvent
);
186 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP
, wxRibbonBarEvent
);
187 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN
, wxRibbonBarEvent
);
188 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP
, wxRibbonBarEvent
);
189 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK
, wxRibbonBarEvent
);
191 typedef void (wxEvtHandler::*wxRibbonBarEventFunction
)(wxRibbonBarEvent
&);
193 #define wxRibbonBarEventHandler(func) \
194 wxEVENT_HANDLER_CAST(wxRibbonBarEventFunction, func)
196 #define EVT_RIBBONBAR_PAGE_CHANGED(winid, fn) \
197 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED, winid, wxRibbonBarEventHandler(fn))
198 #define EVT_RIBBONBAR_PAGE_CHANGING(winid, fn) \
199 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING, winid, wxRibbonBarEventHandler(fn))
200 #define EVT_RIBBONBAR_TAB_MIDDLE_DOWN(winid, fn) \
201 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN, winid, wxRibbonBarEventHandler(fn))
202 #define EVT_RIBBONBAR_TAB_MIDDLE_UP(winid, fn) \
203 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP, winid, wxRibbonBarEventHandler(fn))
204 #define EVT_RIBBONBAR_TAB_RIGHT_DOWN(winid, fn) \
205 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN, winid, wxRibbonBarEventHandler(fn))
206 #define EVT_RIBBONBAR_TAB_RIGHT_UP(winid, fn) \
207 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP, winid, wxRibbonBarEventHandler(fn))
208 #define EVT_RIBBONBAR_TAB_LEFT_DCLICK(winid, fn) \
209 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK, winid, wxRibbonBarEventHandler(fn))
212 // wxpython/swig event work
213 %constant wxEventType wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED
;
214 %constant wxEventType wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING
;
215 %constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN
;
216 %constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP
;
217 %constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN
;
218 %constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP
;
219 %constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK
;
222 EVT_RIBBONBAR_PAGE_CHANGED
= wx
.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED
, 1 )
223 EVT_RIBBONBAR_PAGE_CHANGING
= wx
.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING
, 1 )
224 EVT_RIBBONBAR_TAB_MIDDLE_DOWN
= wx
.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN
, 1 )
225 EVT_RIBBONBAR_TAB_MIDDLE_UP
= wx
.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP
, 1 )
226 EVT_RIBBONBAR_TAB_RIGHT_DOWN
= wx
.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN
, 1 )
227 EVT_RIBBONBAR_TAB_RIGHT_UP
= wx
.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP
, 1 )
228 EVT_RIBBONBAR_TAB_LEFT_DCLICK
= wx
.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK
, 1 )
232 #endif // wxUSE_RIBBON
234 #endif // _WX_RIBBON_BAR_H_