]>
Commit | Line | Data |
---|---|---|
3c3ead1d PC |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/ribbon/bar.h | |
3 | // Purpose: Top-level component of the ribbon-bar-style interface | |
4 | // Author: Peter Cawley | |
5 | // Modified by: | |
6 | // Created: 2009-05-23 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (C) Peter Cawley | |
9 | // Licence: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_RIBBON_BAR_H_ | |
13 | #define _WX_RIBBON_BAR_H_ | |
14 | ||
15 | #include "wx/defs.h" | |
16 | ||
17 | #if wxUSE_RIBBON | |
18 | ||
19 | #include "wx/ribbon/control.h" | |
20 | #include "wx/ribbon/page.h" | |
21 | ||
22 | enum wxRibbonBarOption | |
23 | { | |
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, | |
7c70331e | 31 | wxRIBBON_BAR_SHOW_TOGGLE_BUTTON = 1 << 6, |
42d73941 | 32 | wxRIBBON_BAR_SHOW_HELP_BUTTON = 1 << 7, |
3c3ead1d PC |
33 | |
34 | wxRIBBON_BAR_DEFAULT_STYLE = wxRIBBON_BAR_FLOW_HORIZONTAL | |
35 | | wxRIBBON_BAR_SHOW_PAGE_LABELS | |
7c70331e | 36 | | wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS |
42d73941 VZ |
37 | | wxRIBBON_BAR_SHOW_TOGGLE_BUTTON |
38 | | wxRIBBON_BAR_SHOW_HELP_BUTTON, | |
3c3ead1d PC |
39 | |
40 | wxRIBBON_BAR_FOLDBAR_STYLE = wxRIBBON_BAR_FLOW_VERTICAL | |
41 | | wxRIBBON_BAR_SHOW_PAGE_ICONS | |
42 | | wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS | |
2f6b64a9 | 43 | | wxRIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONS |
3c3ead1d PC |
44 | }; |
45 | ||
42d73941 VZ |
46 | enum wxRibbonDisplayMode |
47 | { | |
48 | wxRIBBON_BAR_PINNED, | |
49 | wxRIBBON_BAR_MINIMIZED, | |
50 | wxRIBBON_BAR_EXPANDED | |
51 | }; | |
52 | ||
3c3ead1d PC |
53 | class WXDLLIMPEXP_RIBBON wxRibbonBarEvent : public wxNotifyEvent |
54 | { | |
55 | public: | |
56 | wxRibbonBarEvent(wxEventType command_type = wxEVT_NULL, | |
57 | int win_id = 0, | |
58 | wxRibbonPage* page = NULL) | |
59 | : wxNotifyEvent(command_type, win_id) | |
60 | , m_page(page) | |
61 | { | |
62 | } | |
63 | #ifndef SWIG | |
64 | wxRibbonBarEvent(const wxRibbonBarEvent& c) : wxNotifyEvent(c) | |
65 | { | |
66 | m_page = c.m_page; | |
67 | } | |
68 | #endif | |
69 | wxEvent *Clone() const { return new wxRibbonBarEvent(*this); } | |
70 | ||
71 | wxRibbonPage* GetPage() {return m_page;} | |
72 | void SetPage(wxRibbonPage* page) {m_page = page;} | |
73 | ||
74 | protected: | |
75 | wxRibbonPage* m_page; | |
76 | ||
77 | #ifndef SWIG | |
78 | private: | |
79 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonBarEvent) | |
80 | #endif | |
81 | }; | |
82 | ||
83 | class WXDLLIMPEXP_RIBBON wxRibbonPageTabInfo | |
84 | { | |
85 | public: | |
86 | wxRect rect; | |
87 | wxRibbonPage *page; | |
88 | int ideal_width; | |
89 | int small_begin_need_separator_width; | |
90 | int small_must_have_separator_width; | |
91 | int minimum_width; | |
92 | bool active; | |
93 | bool hovered; | |
70f86ded | 94 | bool highlight; |
5c14ec26 | 95 | bool shown; |
3c3ead1d PC |
96 | }; |
97 | ||
98 | #ifndef SWIG | |
99 | WX_DECLARE_USER_EXPORTED_OBJARRAY(wxRibbonPageTabInfo, wxRibbonPageTabInfoArray, WXDLLIMPEXP_RIBBON); | |
100 | #endif | |
101 | ||
102 | class WXDLLIMPEXP_RIBBON wxRibbonBar : public wxRibbonControl | |
103 | { | |
104 | public: | |
105 | wxRibbonBar(); | |
106 | ||
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); | |
112 | ||
113 | virtual ~wxRibbonBar(); | |
114 | ||
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); | |
120 | ||
121 | void SetTabCtrlMargins(int left, int right); | |
122 | ||
123 | void SetArtProvider(wxRibbonArtProvider* art); | |
124 | ||
125 | bool SetActivePage(size_t page); | |
126 | bool SetActivePage(wxRibbonPage* page); | |
127 | int GetActivePage() const; | |
128 | wxRibbonPage* GetPage(int n); | |
c21b99e0 | 129 | size_t GetPageCount() const; |
3c3ead1d | 130 | bool DismissExpandedPanel(); |
5c14ec26 | 131 | int GetPageNumber(wxRibbonPage* page) const; |
3c3ead1d | 132 | |
c21b99e0 VZ |
133 | void DeletePage(size_t n); |
134 | void ClearPages(); | |
135 | ||
5c14ec26 VZ |
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); } | |
139 | ||
70f86ded VZ |
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); } | |
143 | ||
3603e565 VZ |
144 | void ShowPanels(bool show = true); |
145 | void HidePanels() { ShowPanels(false); } | |
146 | bool ArePanelsShown() const { return m_arePanelsShown; } | |
147 | ||
3c3ead1d PC |
148 | virtual bool HasMultiplePages() const { return true; } |
149 | ||
150 | void SetWindowStyleFlag(long style); | |
151 | long GetWindowStyleFlag() const; | |
152 | virtual bool Realize(); | |
153 | ||
7c70331e VZ |
154 | // Implementation only. |
155 | bool IsToggleButtonHovered() const { return m_toggle_button_hovered; } | |
42d73941 VZ |
156 | bool IsHelpButtonHovered() const { return m_help_button_hovered; } |
157 | ||
158 | void HideIfExpanded(); | |
7c70331e | 159 | |
3c3ead1d PC |
160 | protected: |
161 | friend class wxRibbonPage; | |
162 | ||
cff9681b | 163 | virtual wxSize DoGetBestSize() const; |
3c3ead1d PC |
164 | wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } |
165 | wxRibbonPageTabInfo* HitTestTabs(wxPoint position, int* index = NULL); | |
42d73941 | 166 | void HitTestRibbonButton(const wxRect& rect, const wxPoint& position, bool &hover_flag); |
3c3ead1d PC |
167 | |
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); | |
175 | ||
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); | |
a65b84f4 | 188 | void OnMouseDoubleClick(wxMouseEvent& evt); |
3c3ead1d | 189 | void DoMouseButtonCommon(wxMouseEvent& evt, wxEventType tab_event_type); |
42d73941 | 190 | void OnKillFocus(wxFocusEvent& evt); |
3c3ead1d PC |
191 | |
192 | wxRibbonPageTabInfoArray m_pages; | |
193 | wxRect m_tab_scroll_left_button_rect; | |
194 | wxRect m_tab_scroll_right_button_rect; | |
7c70331e | 195 | wxRect m_toggle_button_rect; |
42d73941 | 196 | wxRect m_help_button_rect; |
3c3ead1d PC |
197 | long m_flags; |
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; | |
202 | int m_tab_height; | |
203 | int m_tab_scroll_amount; | |
204 | int m_current_page; | |
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; | |
3603e565 | 209 | bool m_arePanelsShown; |
7c70331e VZ |
210 | bool m_bar_hovered; |
211 | bool m_toggle_button_hovered; | |
42d73941 VZ |
212 | bool m_help_button_hovered; |
213 | ||
214 | wxRibbonDisplayMode m_ribbon_state; | |
3c3ead1d PC |
215 | |
216 | #ifndef SWIG | |
217 | DECLARE_CLASS(wxRibbonBar) | |
218 | DECLARE_EVENT_TABLE() | |
219 | #endif | |
220 | }; | |
221 | ||
222 | #ifndef SWIG | |
223 | ||
ce7fe42e VZ |
224 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBAR_PAGE_CHANGED, wxRibbonBarEvent); |
225 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBAR_PAGE_CHANGING, wxRibbonBarEvent); | |
226 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBAR_TAB_MIDDLE_DOWN, wxRibbonBarEvent); | |
227 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBAR_TAB_MIDDLE_UP, wxRibbonBarEvent); | |
228 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBAR_TAB_RIGHT_DOWN, wxRibbonBarEvent); | |
229 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBAR_TAB_RIGHT_UP, wxRibbonBarEvent); | |
230 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBAR_TAB_LEFT_DCLICK, wxRibbonBarEvent); | |
231 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBAR_TOGGLED, wxRibbonBarEvent); | |
232 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBAR_HELP_CLICK, wxRibbonBarEvent); | |
3c3ead1d PC |
233 | |
234 | typedef void (wxEvtHandler::*wxRibbonBarEventFunction)(wxRibbonBarEvent&); | |
235 | ||
236 | #define wxRibbonBarEventHandler(func) \ | |
237 | wxEVENT_HANDLER_CAST(wxRibbonBarEventFunction, func) | |
238 | ||
239 | #define EVT_RIBBONBAR_PAGE_CHANGED(winid, fn) \ | |
ce7fe42e | 240 | wx__DECLARE_EVT1(wxEVT_RIBBONBAR_PAGE_CHANGED, winid, wxRibbonBarEventHandler(fn)) |
3c3ead1d | 241 | #define EVT_RIBBONBAR_PAGE_CHANGING(winid, fn) \ |
ce7fe42e | 242 | wx__DECLARE_EVT1(wxEVT_RIBBONBAR_PAGE_CHANGING, winid, wxRibbonBarEventHandler(fn)) |
3c3ead1d | 243 | #define EVT_RIBBONBAR_TAB_MIDDLE_DOWN(winid, fn) \ |
ce7fe42e | 244 | wx__DECLARE_EVT1(wxEVT_RIBBONBAR_TAB_MIDDLE_DOWN, winid, wxRibbonBarEventHandler(fn)) |
3c3ead1d | 245 | #define EVT_RIBBONBAR_TAB_MIDDLE_UP(winid, fn) \ |
ce7fe42e | 246 | wx__DECLARE_EVT1(wxEVT_RIBBONBAR_TAB_MIDDLE_UP, winid, wxRibbonBarEventHandler(fn)) |
3c3ead1d | 247 | #define EVT_RIBBONBAR_TAB_RIGHT_DOWN(winid, fn) \ |
ce7fe42e | 248 | wx__DECLARE_EVT1(wxEVT_RIBBONBAR_TAB_RIGHT_DOWN, winid, wxRibbonBarEventHandler(fn)) |
3c3ead1d | 249 | #define EVT_RIBBONBAR_TAB_RIGHT_UP(winid, fn) \ |
ce7fe42e | 250 | wx__DECLARE_EVT1(wxEVT_RIBBONBAR_TAB_RIGHT_UP, winid, wxRibbonBarEventHandler(fn)) |
a65b84f4 | 251 | #define EVT_RIBBONBAR_TAB_LEFT_DCLICK(winid, fn) \ |
ce7fe42e | 252 | wx__DECLARE_EVT1(wxEVT_RIBBONBAR_TAB_LEFT_DCLICK, winid, wxRibbonBarEventHandler(fn)) |
7c70331e | 253 | #define EVT_RIBBONBAR_TOGGLED(winid, fn) \ |
ce7fe42e | 254 | wx__DECLARE_EVT1(wxEVT_RIBBONBAR_TOGGLED, winid, wxRibbonBarEventHandler(fn)) |
42d73941 | 255 | #define EVT_RIBBONBAR_HELP_CLICK(winid, fn) \ |
ce7fe42e | 256 | wx__DECLARE_EVT1(wxEVT_RIBBONBAR_HELP_CLICK, winid, wxRibbonBarEventHandler(fn)) |
3c3ead1d PC |
257 | #else |
258 | ||
259 | // wxpython/swig event work | |
ce7fe42e VZ |
260 | %constant wxEventType wxEVT_RIBBONBAR_PAGE_CHANGED; |
261 | %constant wxEventType wxEVT_RIBBONBAR_PAGE_CHANGING; | |
262 | %constant wxEventType wxEVT_RIBBONBAR_TAB_MIDDLE_DOWN; | |
263 | %constant wxEventType wxEVT_RIBBONBAR_TAB_MIDDLE_UP; | |
264 | %constant wxEventType wxEVT_RIBBONBAR_TAB_RIGHT_DOWN; | |
265 | %constant wxEventType wxEVT_RIBBONBAR_TAB_RIGHT_UP; | |
266 | %constant wxEventType wxEVT_RIBBONBAR_TAB_LEFT_DCLICK; | |
267 | %constant wxEventType wxEVT_RIBBONBAR_TOGGLED; | |
268 | %constant wxEventType wxEVT_RIBBONBAR_HELP_CLICK; | |
3c3ead1d PC |
269 | |
270 | %pythoncode { | |
ce7fe42e VZ |
271 | EVT_RIBBONBAR_PAGE_CHANGED = wx.PyEventBinder( wxEVT_RIBBONBAR_PAGE_CHANGED, 1 ) |
272 | EVT_RIBBONBAR_PAGE_CHANGING = wx.PyEventBinder( wxEVT_RIBBONBAR_PAGE_CHANGING, 1 ) | |
273 | EVT_RIBBONBAR_TAB_MIDDLE_DOWN = wx.PyEventBinder( wxEVT_RIBBONBAR_TAB_MIDDLE_DOWN, 1 ) | |
274 | EVT_RIBBONBAR_TAB_MIDDLE_UP = wx.PyEventBinder( wxEVT_RIBBONBAR_TAB_MIDDLE_UP, 1 ) | |
275 | EVT_RIBBONBAR_TAB_RIGHT_DOWN = wx.PyEventBinder( wxEVT_RIBBONBAR_TAB_RIGHT_DOWN, 1 ) | |
276 | EVT_RIBBONBAR_TAB_RIGHT_UP = wx.PyEventBinder( wxEVT_RIBBONBAR_TAB_RIGHT_UP, 1 ) | |
277 | EVT_RIBBONBAR_TAB_LEFT_DCLICK = wx.PyEventBinder( wxEVT_RIBBONBAR_TAB_LEFT_DCLICK, 1 ) | |
278 | EVT_RIBBONBAR_TOGGLED = wx.PyEventBinder( wxEVT_RIBBONBAR_TOGGLED, 1 ) | |
279 | EVT_RIBBONBAR_HELP_CLICK = wx.PyEventBinder( wxEVT_RIBBONBAR_HELP_CLICK, 1 ) | |
3c3ead1d PC |
280 | } |
281 | #endif | |
282 | ||
ce7fe42e VZ |
283 | // old wxEVT_COMMAND_* constants |
284 | #define wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED wxEVT_RIBBONBAR_PAGE_CHANGED | |
285 | #define wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING wxEVT_RIBBONBAR_PAGE_CHANGING | |
286 | #define wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN wxEVT_RIBBONBAR_TAB_MIDDLE_DOWN | |
287 | #define wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP wxEVT_RIBBONBAR_TAB_MIDDLE_UP | |
288 | #define wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN wxEVT_RIBBONBAR_TAB_RIGHT_DOWN | |
289 | #define wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP wxEVT_RIBBONBAR_TAB_RIGHT_UP | |
290 | #define wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK wxEVT_RIBBONBAR_TAB_LEFT_DCLICK | |
291 | #define wxEVT_COMMAND_RIBBONBAR_TOGGLED wxEVT_RIBBONBAR_TOGGLED | |
292 | #define wxEVT_COMMAND_RIBBONBAR_HELP_CLICKED wxEVT_RIBBONBAR_HELP_CLICK | |
293 | ||
3c3ead1d PC |
294 | #endif // wxUSE_RIBBON |
295 | ||
296 | #endif // _WX_RIBBON_BAR_H_ | |
297 |