]> git.saurik.com Git - wxWidgets.git/blame - include/wx/ribbon/bar.h
Don't define __STRICT_ANSI__, we should build both with and without it.
[wxWidgets.git] / include / wx / ribbon / bar.h
CommitLineData
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
3c3ead1d
PC
7// Copyright: (C) Peter Cawley
8// Licence: wxWindows licence
9///////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_RIBBON_BAR_H_
12#define _WX_RIBBON_BAR_H_
13
14#include "wx/defs.h"
15
16#if wxUSE_RIBBON
17
18#include "wx/ribbon/control.h"
19#include "wx/ribbon/page.h"
20
21enum wxRibbonBarOption
22{
23 wxRIBBON_BAR_SHOW_PAGE_LABELS = 1 << 0,
24 wxRIBBON_BAR_SHOW_PAGE_ICONS = 1 << 1,
25 wxRIBBON_BAR_FLOW_HORIZONTAL = 0,
26 wxRIBBON_BAR_FLOW_VERTICAL = 1 << 2,
27 wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS = 1 << 3,
28 wxRIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONS = 1 << 4,
29 wxRIBBON_BAR_ALWAYS_SHOW_TABS = 1 << 5,
7c70331e 30 wxRIBBON_BAR_SHOW_TOGGLE_BUTTON = 1 << 6,
42d73941 31 wxRIBBON_BAR_SHOW_HELP_BUTTON = 1 << 7,
3c3ead1d
PC
32
33 wxRIBBON_BAR_DEFAULT_STYLE = wxRIBBON_BAR_FLOW_HORIZONTAL
34 | wxRIBBON_BAR_SHOW_PAGE_LABELS
7c70331e 35 | wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS
42d73941
VZ
36 | wxRIBBON_BAR_SHOW_TOGGLE_BUTTON
37 | wxRIBBON_BAR_SHOW_HELP_BUTTON,
3c3ead1d
PC
38
39 wxRIBBON_BAR_FOLDBAR_STYLE = wxRIBBON_BAR_FLOW_VERTICAL
40 | wxRIBBON_BAR_SHOW_PAGE_ICONS
41 | wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS
2f6b64a9 42 | wxRIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONS
3c3ead1d
PC
43};
44
42d73941
VZ
45enum wxRibbonDisplayMode
46{
47 wxRIBBON_BAR_PINNED,
48 wxRIBBON_BAR_MINIMIZED,
49 wxRIBBON_BAR_EXPANDED
50};
51
3c3ead1d
PC
52class WXDLLIMPEXP_RIBBON wxRibbonBarEvent : public wxNotifyEvent
53{
54public:
55 wxRibbonBarEvent(wxEventType command_type = wxEVT_NULL,
56 int win_id = 0,
57 wxRibbonPage* page = NULL)
58 : wxNotifyEvent(command_type, win_id)
59 , m_page(page)
60 {
61 }
62#ifndef SWIG
63 wxRibbonBarEvent(const wxRibbonBarEvent& c) : wxNotifyEvent(c)
64 {
65 m_page = c.m_page;
66 }
67#endif
68 wxEvent *Clone() const { return new wxRibbonBarEvent(*this); }
69
70 wxRibbonPage* GetPage() {return m_page;}
71 void SetPage(wxRibbonPage* page) {m_page = page;}
72
73protected:
74 wxRibbonPage* m_page;
75
76#ifndef SWIG
77private:
78 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonBarEvent)
79#endif
80};
81
82class WXDLLIMPEXP_RIBBON wxRibbonPageTabInfo
83{
84public:
85 wxRect rect;
86 wxRibbonPage *page;
87 int ideal_width;
88 int small_begin_need_separator_width;
89 int small_must_have_separator_width;
90 int minimum_width;
91 bool active;
92 bool hovered;
70f86ded 93 bool highlight;
5c14ec26 94 bool shown;
3c3ead1d
PC
95};
96
97#ifndef SWIG
98WX_DECLARE_USER_EXPORTED_OBJARRAY(wxRibbonPageTabInfo, wxRibbonPageTabInfoArray, WXDLLIMPEXP_RIBBON);
99#endif
100
101class WXDLLIMPEXP_RIBBON wxRibbonBar : public wxRibbonControl
102{
103public:
104 wxRibbonBar();
105
106 wxRibbonBar(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 virtual ~wxRibbonBar();
113
114 bool Create(wxWindow* parent,
115 wxWindowID id = wxID_ANY,
116 const wxPoint& pos = wxDefaultPosition,
117 const wxSize& size = wxDefaultSize,
118 long style = wxRIBBON_BAR_DEFAULT_STYLE);
119
120 void SetTabCtrlMargins(int left, int right);
121
122 void SetArtProvider(wxRibbonArtProvider* art);
123
124 bool SetActivePage(size_t page);
125 bool SetActivePage(wxRibbonPage* page);
126 int GetActivePage() const;
127 wxRibbonPage* GetPage(int n);
c21b99e0 128 size_t GetPageCount() const;
3c3ead1d 129 bool DismissExpandedPanel();
5c14ec26 130 int GetPageNumber(wxRibbonPage* page) const;
3c3ead1d 131
c21b99e0
VZ
132 void DeletePage(size_t n);
133 void ClearPages();
134
5c14ec26
VZ
135 bool IsPageShown(size_t page) const;
136 void ShowPage(size_t page, bool show = true);
137 void HidePage(size_t page) { ShowPage(page, false); }
138
70f86ded
VZ
139 bool IsPageHighlighted(size_t page) const;
140 void AddPageHighlight(size_t page, bool highlight = true);
141 void RemovePageHighlight(size_t page) { AddPageHighlight(page, false); }
142
3603e565
VZ
143 void ShowPanels(bool show = true);
144 void HidePanels() { ShowPanels(false); }
145 bool ArePanelsShown() const { return m_arePanelsShown; }
146
3c3ead1d
PC
147 virtual bool HasMultiplePages() const { return true; }
148
149 void SetWindowStyleFlag(long style);
150 long GetWindowStyleFlag() const;
151 virtual bool Realize();
152
7c70331e
VZ
153 // Implementation only.
154 bool IsToggleButtonHovered() const { return m_toggle_button_hovered; }
42d73941
VZ
155 bool IsHelpButtonHovered() const { return m_help_button_hovered; }
156
157 void HideIfExpanded();
7c70331e 158
3c3ead1d
PC
159protected:
160 friend class wxRibbonPage;
161
cff9681b 162 virtual wxSize DoGetBestSize() const;
3c3ead1d
PC
163 wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
164 wxRibbonPageTabInfo* HitTestTabs(wxPoint position, int* index = NULL);
42d73941 165 void HitTestRibbonButton(const wxRect& rect, const wxPoint& position, bool &hover_flag);
3c3ead1d
PC
166
167 void CommonInit(long style);
168 void AddPage(wxRibbonPage *page);
169 void RecalculateTabSizes();
170 void RecalculateMinSize();
171 void ScrollTabBar(int npixels);
172 void RefreshTabBar();
173 void RepositionPage(wxRibbonPage *page);
174
175 void OnPaint(wxPaintEvent& evt);
176 void OnEraseBackground(wxEraseEvent& evt);
177 void DoEraseBackground(wxDC& dc);
178 void OnSize(wxSizeEvent& evt);
179 void OnMouseLeftDown(wxMouseEvent& evt);
180 void OnMouseLeftUp(wxMouseEvent& evt);
181 void OnMouseMiddleDown(wxMouseEvent& evt);
182 void OnMouseMiddleUp(wxMouseEvent& evt);
183 void OnMouseRightDown(wxMouseEvent& evt);
184 void OnMouseRightUp(wxMouseEvent& evt);
185 void OnMouseMove(wxMouseEvent& evt);
186 void OnMouseLeave(wxMouseEvent& evt);
a65b84f4 187 void OnMouseDoubleClick(wxMouseEvent& evt);
3c3ead1d 188 void DoMouseButtonCommon(wxMouseEvent& evt, wxEventType tab_event_type);
42d73941 189 void OnKillFocus(wxFocusEvent& evt);
3c3ead1d
PC
190
191 wxRibbonPageTabInfoArray m_pages;
192 wxRect m_tab_scroll_left_button_rect;
193 wxRect m_tab_scroll_right_button_rect;
7c70331e 194 wxRect m_toggle_button_rect;
42d73941 195 wxRect m_help_button_rect;
3c3ead1d
PC
196 long m_flags;
197 int m_tabs_total_width_ideal;
198 int m_tabs_total_width_minimum;
199 int m_tab_margin_left;
200 int m_tab_margin_right;
201 int m_tab_height;
202 int m_tab_scroll_amount;
203 int m_current_page;
204 int m_current_hovered_page;
205 int m_tab_scroll_left_button_state;
206 int m_tab_scroll_right_button_state;
207 bool m_tab_scroll_buttons_shown;
3603e565 208 bool m_arePanelsShown;
7c70331e
VZ
209 bool m_bar_hovered;
210 bool m_toggle_button_hovered;
42d73941
VZ
211 bool m_help_button_hovered;
212
213 wxRibbonDisplayMode m_ribbon_state;
3c3ead1d
PC
214
215#ifndef SWIG
216 DECLARE_CLASS(wxRibbonBar)
217 DECLARE_EVENT_TABLE()
218#endif
219};
220
221#ifndef SWIG
222
ce7fe42e
VZ
223wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBAR_PAGE_CHANGED, wxRibbonBarEvent);
224wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBAR_PAGE_CHANGING, wxRibbonBarEvent);
225wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBAR_TAB_MIDDLE_DOWN, wxRibbonBarEvent);
226wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBAR_TAB_MIDDLE_UP, wxRibbonBarEvent);
227wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBAR_TAB_RIGHT_DOWN, wxRibbonBarEvent);
228wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBAR_TAB_RIGHT_UP, wxRibbonBarEvent);
229wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBAR_TAB_LEFT_DCLICK, wxRibbonBarEvent);
230wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBAR_TOGGLED, wxRibbonBarEvent);
231wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBAR_HELP_CLICK, wxRibbonBarEvent);
3c3ead1d
PC
232
233typedef void (wxEvtHandler::*wxRibbonBarEventFunction)(wxRibbonBarEvent&);
234
235#define wxRibbonBarEventHandler(func) \
236 wxEVENT_HANDLER_CAST(wxRibbonBarEventFunction, func)
237
238#define EVT_RIBBONBAR_PAGE_CHANGED(winid, fn) \
ce7fe42e 239 wx__DECLARE_EVT1(wxEVT_RIBBONBAR_PAGE_CHANGED, winid, wxRibbonBarEventHandler(fn))
3c3ead1d 240#define EVT_RIBBONBAR_PAGE_CHANGING(winid, fn) \
ce7fe42e 241 wx__DECLARE_EVT1(wxEVT_RIBBONBAR_PAGE_CHANGING, winid, wxRibbonBarEventHandler(fn))
3c3ead1d 242#define EVT_RIBBONBAR_TAB_MIDDLE_DOWN(winid, fn) \
ce7fe42e 243 wx__DECLARE_EVT1(wxEVT_RIBBONBAR_TAB_MIDDLE_DOWN, winid, wxRibbonBarEventHandler(fn))
3c3ead1d 244#define EVT_RIBBONBAR_TAB_MIDDLE_UP(winid, fn) \
ce7fe42e 245 wx__DECLARE_EVT1(wxEVT_RIBBONBAR_TAB_MIDDLE_UP, winid, wxRibbonBarEventHandler(fn))
3c3ead1d 246#define EVT_RIBBONBAR_TAB_RIGHT_DOWN(winid, fn) \
ce7fe42e 247 wx__DECLARE_EVT1(wxEVT_RIBBONBAR_TAB_RIGHT_DOWN, winid, wxRibbonBarEventHandler(fn))
3c3ead1d 248#define EVT_RIBBONBAR_TAB_RIGHT_UP(winid, fn) \
ce7fe42e 249 wx__DECLARE_EVT1(wxEVT_RIBBONBAR_TAB_RIGHT_UP, winid, wxRibbonBarEventHandler(fn))
a65b84f4 250#define EVT_RIBBONBAR_TAB_LEFT_DCLICK(winid, fn) \
ce7fe42e 251 wx__DECLARE_EVT1(wxEVT_RIBBONBAR_TAB_LEFT_DCLICK, winid, wxRibbonBarEventHandler(fn))
7c70331e 252#define EVT_RIBBONBAR_TOGGLED(winid, fn) \
ce7fe42e 253 wx__DECLARE_EVT1(wxEVT_RIBBONBAR_TOGGLED, winid, wxRibbonBarEventHandler(fn))
42d73941 254#define EVT_RIBBONBAR_HELP_CLICK(winid, fn) \
ce7fe42e 255 wx__DECLARE_EVT1(wxEVT_RIBBONBAR_HELP_CLICK, winid, wxRibbonBarEventHandler(fn))
3c3ead1d
PC
256#else
257
258// wxpython/swig event work
ce7fe42e
VZ
259%constant wxEventType wxEVT_RIBBONBAR_PAGE_CHANGED;
260%constant wxEventType wxEVT_RIBBONBAR_PAGE_CHANGING;
261%constant wxEventType wxEVT_RIBBONBAR_TAB_MIDDLE_DOWN;
262%constant wxEventType wxEVT_RIBBONBAR_TAB_MIDDLE_UP;
263%constant wxEventType wxEVT_RIBBONBAR_TAB_RIGHT_DOWN;
264%constant wxEventType wxEVT_RIBBONBAR_TAB_RIGHT_UP;
265%constant wxEventType wxEVT_RIBBONBAR_TAB_LEFT_DCLICK;
266%constant wxEventType wxEVT_RIBBONBAR_TOGGLED;
267%constant wxEventType wxEVT_RIBBONBAR_HELP_CLICK;
3c3ead1d
PC
268
269%pythoncode {
ce7fe42e
VZ
270 EVT_RIBBONBAR_PAGE_CHANGED = wx.PyEventBinder( wxEVT_RIBBONBAR_PAGE_CHANGED, 1 )
271 EVT_RIBBONBAR_PAGE_CHANGING = wx.PyEventBinder( wxEVT_RIBBONBAR_PAGE_CHANGING, 1 )
272 EVT_RIBBONBAR_TAB_MIDDLE_DOWN = wx.PyEventBinder( wxEVT_RIBBONBAR_TAB_MIDDLE_DOWN, 1 )
273 EVT_RIBBONBAR_TAB_MIDDLE_UP = wx.PyEventBinder( wxEVT_RIBBONBAR_TAB_MIDDLE_UP, 1 )
274 EVT_RIBBONBAR_TAB_RIGHT_DOWN = wx.PyEventBinder( wxEVT_RIBBONBAR_TAB_RIGHT_DOWN, 1 )
275 EVT_RIBBONBAR_TAB_RIGHT_UP = wx.PyEventBinder( wxEVT_RIBBONBAR_TAB_RIGHT_UP, 1 )
276 EVT_RIBBONBAR_TAB_LEFT_DCLICK = wx.PyEventBinder( wxEVT_RIBBONBAR_TAB_LEFT_DCLICK, 1 )
277 EVT_RIBBONBAR_TOGGLED = wx.PyEventBinder( wxEVT_RIBBONBAR_TOGGLED, 1 )
278 EVT_RIBBONBAR_HELP_CLICK = wx.PyEventBinder( wxEVT_RIBBONBAR_HELP_CLICK, 1 )
3c3ead1d
PC
279}
280#endif
281
ce7fe42e
VZ
282// old wxEVT_COMMAND_* constants
283#define wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED wxEVT_RIBBONBAR_PAGE_CHANGED
284#define wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING wxEVT_RIBBONBAR_PAGE_CHANGING
285#define wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN wxEVT_RIBBONBAR_TAB_MIDDLE_DOWN
286#define wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP wxEVT_RIBBONBAR_TAB_MIDDLE_UP
287#define wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN wxEVT_RIBBONBAR_TAB_RIGHT_DOWN
288#define wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP wxEVT_RIBBONBAR_TAB_RIGHT_UP
289#define wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK wxEVT_RIBBONBAR_TAB_LEFT_DCLICK
290#define wxEVT_COMMAND_RIBBONBAR_TOGGLED wxEVT_RIBBONBAR_TOGGLED
291#define wxEVT_COMMAND_RIBBONBAR_HELP_CLICKED wxEVT_RIBBONBAR_HELP_CLICK
292
3c3ead1d
PC
293#endif // wxUSE_RIBBON
294
295#endif // _WX_RIBBON_BAR_H_
296