]>
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, |
3c3ead1d PC |
32 | |
33 | wxRIBBON_BAR_DEFAULT_STYLE = wxRIBBON_BAR_FLOW_HORIZONTAL | |
34 | | wxRIBBON_BAR_SHOW_PAGE_LABELS | |
7c70331e VZ |
35 | | wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS |
36 | | wxRIBBON_BAR_SHOW_TOGGLE_BUTTON, | |
3c3ead1d PC |
37 | |
38 | wxRIBBON_BAR_FOLDBAR_STYLE = wxRIBBON_BAR_FLOW_VERTICAL | |
39 | | wxRIBBON_BAR_SHOW_PAGE_ICONS | |
40 | | wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS | |
2f6b64a9 | 41 | | wxRIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONS |
3c3ead1d PC |
42 | }; |
43 | ||
44 | class WXDLLIMPEXP_RIBBON wxRibbonBarEvent : public wxNotifyEvent | |
45 | { | |
46 | public: | |
47 | wxRibbonBarEvent(wxEventType command_type = wxEVT_NULL, | |
48 | int win_id = 0, | |
49 | wxRibbonPage* page = NULL) | |
50 | : wxNotifyEvent(command_type, win_id) | |
51 | , m_page(page) | |
52 | { | |
53 | } | |
54 | #ifndef SWIG | |
55 | wxRibbonBarEvent(const wxRibbonBarEvent& c) : wxNotifyEvent(c) | |
56 | { | |
57 | m_page = c.m_page; | |
58 | } | |
59 | #endif | |
60 | wxEvent *Clone() const { return new wxRibbonBarEvent(*this); } | |
61 | ||
62 | wxRibbonPage* GetPage() {return m_page;} | |
63 | void SetPage(wxRibbonPage* page) {m_page = page;} | |
64 | ||
65 | protected: | |
66 | wxRibbonPage* m_page; | |
67 | ||
68 | #ifndef SWIG | |
69 | private: | |
70 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonBarEvent) | |
71 | #endif | |
72 | }; | |
73 | ||
74 | class WXDLLIMPEXP_RIBBON wxRibbonPageTabInfo | |
75 | { | |
76 | public: | |
77 | wxRect rect; | |
78 | wxRibbonPage *page; | |
79 | int ideal_width; | |
80 | int small_begin_need_separator_width; | |
81 | int small_must_have_separator_width; | |
82 | int minimum_width; | |
83 | bool active; | |
84 | bool hovered; | |
70f86ded | 85 | bool highlight; |
5c14ec26 | 86 | bool shown; |
3c3ead1d PC |
87 | }; |
88 | ||
89 | #ifndef SWIG | |
90 | WX_DECLARE_USER_EXPORTED_OBJARRAY(wxRibbonPageTabInfo, wxRibbonPageTabInfoArray, WXDLLIMPEXP_RIBBON); | |
91 | #endif | |
92 | ||
93 | class WXDLLIMPEXP_RIBBON wxRibbonBar : public wxRibbonControl | |
94 | { | |
95 | public: | |
96 | wxRibbonBar(); | |
97 | ||
98 | wxRibbonBar(wxWindow* parent, | |
99 | wxWindowID id = wxID_ANY, | |
100 | const wxPoint& pos = wxDefaultPosition, | |
101 | const wxSize& size = wxDefaultSize, | |
102 | long style = wxRIBBON_BAR_DEFAULT_STYLE); | |
103 | ||
104 | virtual ~wxRibbonBar(); | |
105 | ||
106 | bool Create(wxWindow* parent, | |
107 | wxWindowID id = wxID_ANY, | |
108 | const wxPoint& pos = wxDefaultPosition, | |
109 | const wxSize& size = wxDefaultSize, | |
110 | long style = wxRIBBON_BAR_DEFAULT_STYLE); | |
111 | ||
112 | void SetTabCtrlMargins(int left, int right); | |
113 | ||
114 | void SetArtProvider(wxRibbonArtProvider* art); | |
115 | ||
116 | bool SetActivePage(size_t page); | |
117 | bool SetActivePage(wxRibbonPage* page); | |
118 | int GetActivePage() const; | |
119 | wxRibbonPage* GetPage(int n); | |
c21b99e0 | 120 | size_t GetPageCount() const; |
3c3ead1d | 121 | bool DismissExpandedPanel(); |
5c14ec26 | 122 | int GetPageNumber(wxRibbonPage* page) const; |
3c3ead1d | 123 | |
c21b99e0 VZ |
124 | void DeletePage(size_t n); |
125 | void ClearPages(); | |
126 | ||
5c14ec26 VZ |
127 | bool IsPageShown(size_t page) const; |
128 | void ShowPage(size_t page, bool show = true); | |
129 | void HidePage(size_t page) { ShowPage(page, false); } | |
130 | ||
70f86ded VZ |
131 | bool IsPageHighlighted(size_t page) const; |
132 | void AddPageHighlight(size_t page, bool highlight = true); | |
133 | void RemovePageHighlight(size_t page) { AddPageHighlight(page, false); } | |
134 | ||
3603e565 VZ |
135 | void ShowPanels(bool show = true); |
136 | void HidePanels() { ShowPanels(false); } | |
137 | bool ArePanelsShown() const { return m_arePanelsShown; } | |
138 | ||
3c3ead1d PC |
139 | virtual bool HasMultiplePages() const { return true; } |
140 | ||
141 | void SetWindowStyleFlag(long style); | |
142 | long GetWindowStyleFlag() const; | |
143 | virtual bool Realize(); | |
144 | ||
7c70331e VZ |
145 | // Implementation only. |
146 | bool IsToggleButtonHovered() const { return m_toggle_button_hovered; } | |
147 | ||
3c3ead1d PC |
148 | protected: |
149 | friend class wxRibbonPage; | |
150 | ||
cff9681b | 151 | virtual wxSize DoGetBestSize() const; |
3c3ead1d PC |
152 | wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } |
153 | wxRibbonPageTabInfo* HitTestTabs(wxPoint position, int* index = NULL); | |
7c70331e | 154 | void HitTestToggleButton(wxPoint position); |
3c3ead1d PC |
155 | |
156 | void CommonInit(long style); | |
157 | void AddPage(wxRibbonPage *page); | |
158 | void RecalculateTabSizes(); | |
159 | void RecalculateMinSize(); | |
160 | void ScrollTabBar(int npixels); | |
161 | void RefreshTabBar(); | |
162 | void RepositionPage(wxRibbonPage *page); | |
163 | ||
164 | void OnPaint(wxPaintEvent& evt); | |
165 | void OnEraseBackground(wxEraseEvent& evt); | |
166 | void DoEraseBackground(wxDC& dc); | |
167 | void OnSize(wxSizeEvent& evt); | |
168 | void OnMouseLeftDown(wxMouseEvent& evt); | |
169 | void OnMouseLeftUp(wxMouseEvent& evt); | |
170 | void OnMouseMiddleDown(wxMouseEvent& evt); | |
171 | void OnMouseMiddleUp(wxMouseEvent& evt); | |
172 | void OnMouseRightDown(wxMouseEvent& evt); | |
173 | void OnMouseRightUp(wxMouseEvent& evt); | |
174 | void OnMouseMove(wxMouseEvent& evt); | |
175 | void OnMouseLeave(wxMouseEvent& evt); | |
a65b84f4 | 176 | void OnMouseDoubleClick(wxMouseEvent& evt); |
3c3ead1d PC |
177 | void DoMouseButtonCommon(wxMouseEvent& evt, wxEventType tab_event_type); |
178 | ||
179 | wxRibbonPageTabInfoArray m_pages; | |
180 | wxRect m_tab_scroll_left_button_rect; | |
181 | wxRect m_tab_scroll_right_button_rect; | |
7c70331e | 182 | wxRect m_toggle_button_rect; |
3c3ead1d PC |
183 | long m_flags; |
184 | int m_tabs_total_width_ideal; | |
185 | int m_tabs_total_width_minimum; | |
186 | int m_tab_margin_left; | |
187 | int m_tab_margin_right; | |
188 | int m_tab_height; | |
189 | int m_tab_scroll_amount; | |
190 | int m_current_page; | |
191 | int m_current_hovered_page; | |
192 | int m_tab_scroll_left_button_state; | |
193 | int m_tab_scroll_right_button_state; | |
194 | bool m_tab_scroll_buttons_shown; | |
3603e565 | 195 | bool m_arePanelsShown; |
7c70331e VZ |
196 | bool m_bar_hovered; |
197 | bool m_toggle_button_hovered; | |
3c3ead1d PC |
198 | |
199 | #ifndef SWIG | |
200 | DECLARE_CLASS(wxRibbonBar) | |
201 | DECLARE_EVENT_TABLE() | |
202 | #endif | |
203 | }; | |
204 | ||
205 | #ifndef SWIG | |
206 | ||
207 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED, wxRibbonBarEvent); | |
208 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING, wxRibbonBarEvent); | |
209 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN, wxRibbonBarEvent); | |
210 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP, wxRibbonBarEvent); | |
211 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN, wxRibbonBarEvent); | |
212 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP, wxRibbonBarEvent); | |
a65b84f4 | 213 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK, wxRibbonBarEvent); |
7c70331e | 214 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_TOGGLED, wxRibbonBarEvent); |
3c3ead1d PC |
215 | |
216 | typedef void (wxEvtHandler::*wxRibbonBarEventFunction)(wxRibbonBarEvent&); | |
217 | ||
218 | #define wxRibbonBarEventHandler(func) \ | |
219 | wxEVENT_HANDLER_CAST(wxRibbonBarEventFunction, func) | |
220 | ||
221 | #define EVT_RIBBONBAR_PAGE_CHANGED(winid, fn) \ | |
222 | wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED, winid, wxRibbonBarEventHandler(fn)) | |
223 | #define EVT_RIBBONBAR_PAGE_CHANGING(winid, fn) \ | |
224 | wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING, winid, wxRibbonBarEventHandler(fn)) | |
225 | #define EVT_RIBBONBAR_TAB_MIDDLE_DOWN(winid, fn) \ | |
226 | wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN, winid, wxRibbonBarEventHandler(fn)) | |
227 | #define EVT_RIBBONBAR_TAB_MIDDLE_UP(winid, fn) \ | |
228 | wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP, winid, wxRibbonBarEventHandler(fn)) | |
229 | #define EVT_RIBBONBAR_TAB_RIGHT_DOWN(winid, fn) \ | |
230 | wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN, winid, wxRibbonBarEventHandler(fn)) | |
231 | #define EVT_RIBBONBAR_TAB_RIGHT_UP(winid, fn) \ | |
232 | wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP, winid, wxRibbonBarEventHandler(fn)) | |
a65b84f4 VZ |
233 | #define EVT_RIBBONBAR_TAB_LEFT_DCLICK(winid, fn) \ |
234 | wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK, winid, wxRibbonBarEventHandler(fn)) | |
7c70331e VZ |
235 | #define EVT_RIBBONBAR_TOGGLED(winid, fn) \ |
236 | wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TOGGLED, winid, wxRibbonBarEventHandler(fn)) | |
3c3ead1d PC |
237 | #else |
238 | ||
239 | // wxpython/swig event work | |
240 | %constant wxEventType wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED; | |
241 | %constant wxEventType wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING; | |
242 | %constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN; | |
243 | %constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP; | |
244 | %constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN; | |
245 | %constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP; | |
a65b84f4 | 246 | %constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK; |
7c70331e | 247 | %constant wxEventType wxEVT_COMMAND_RIBBONBAR_TOGGLED; |
3c3ead1d PC |
248 | |
249 | %pythoncode { | |
250 | EVT_RIBBONBAR_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED, 1 ) | |
251 | EVT_RIBBONBAR_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING, 1 ) | |
252 | EVT_RIBBONBAR_TAB_MIDDLE_DOWN = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN, 1 ) | |
253 | EVT_RIBBONBAR_TAB_MIDDLE_UP = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP, 1 ) | |
254 | EVT_RIBBONBAR_TAB_RIGHT_DOWN = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN, 1 ) | |
255 | EVT_RIBBONBAR_TAB_RIGHT_UP = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP, 1 ) | |
a65b84f4 | 256 | EVT_RIBBONBAR_TAB_LEFT_DCLICK = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK, 1 ) |
7c70331e | 257 | EVT_RIBBONBAR_TOGGLED = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TOGGLED, 1 ) |
3c3ead1d PC |
258 | } |
259 | #endif | |
260 | ||
261 | #endif // wxUSE_RIBBON | |
262 | ||
263 | #endif // _WX_RIBBON_BAR_H_ | |
264 |