Add possibility to hide panels in wxRibbon.
[wxWidgets.git] / interface / wx / ribbon / bar.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: ribbon/bar.h
3 // Purpose: interface of wxRibbonBar
4 // Author: Peter Cawley
5 // RCS-ID: $Id$
6 // Licence: wxWindows licence
7 ///////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxRibbonBarEvent
11
12 Event used to indicate various actions relating to a wxRibbonBar.
13
14 See wxRibbonBar for available event types.
15
16 @library{wxribbon}
17 @category{events,ribbon}
18
19 @see wxRibbonBar
20 */
21 class wxRibbonBarEvent : public wxNotifyEvent
22 {
23 public:
24 /**
25 Constructor.
26 */
27 wxRibbonBarEvent(wxEventType command_type = wxEVT_NULL,
28 int win_id = 0,
29 wxRibbonPage* page = NULL);
30
31 /**
32 Returns the page being changed to, or being clicked on.
33 */
34 wxRibbonPage* GetPage();
35
36 /**
37 Sets the page relating to this event.
38 */
39 void SetPage(wxRibbonPage* page);
40 };
41
42 /**
43 @class wxRibbonBar
44
45 Top-level control in a ribbon user interface. Serves as a tabbed container
46 for wxRibbonPage - a ribbon user interface typically has a ribbon bar,
47 which contains one or more wxRibbonPages, which in turn each contain one
48 or more wxRibbonPanels, which in turn contain controls.
49
50 While a wxRibbonBar has tabs similar to a wxNotebook, it does not follow
51 the same API for adding pages. Containers like wxNotebook can contain any
52 type of window as a page, hence the normal procedure is to create the
53 sub-window and then call wxBookCtrlBase::AddPage(). As wxRibbonBar can only
54 have wxRibbonPage as children (and a wxRibbonPage can only have a
55 wxRibbonBar as parent), when a page is created, it is automatically added
56 to the bar - there is no AddPage equivalent to call.
57
58 After all pages have been created, and all controls and panels placed on
59 those pages, Realize() must be called.
60
61 @sa wxRibbonPage
62 @sa wxRibbonPanel
63
64 @beginStyleTable
65 @style{wxRIBBON_BAR_DEFAULT_STYLE}
66 Defined as wxRIBBON_BAR_FLOW_HORIZONTAL |
67 wxRIBBON_BAR_SHOW_PAGE_LABELS | wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS
68 @style{wxRIBBON_BAR_FOLDBAR_STYLE}
69 Defined as wxRIBBON_BAR_FLOW_VERTICAL | wxRIBBON_BAR_SHOW_PAGE_ICONS
70 | wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS |
71 wxRIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONS
72 @style{wxRIBBON_BAR_SHOW_PAGE_LABELS}
73 Causes labels to be shown on the tabs in the ribbon bar.
74 @style{wxRIBBON_BAR_SHOW_PAGE_ICONS}
75 Causes icons to be shown on the tabs in the ribbon bar.
76 @style{wxRIBBON_BAR_FLOW_HORIZONTAL}
77 Causes panels within pages to stack horizontally.
78 @style{wxRIBBON_BAR_FLOW_VERTICAL}
79 Causes panels within pages to stack vertically.
80 @style{wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS}
81 Causes extension buttons to be shown on panels (where the panel has
82 such a button).
83 @style{wxRIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONS}
84 Causes minimise buttons to be shown on panels (where the panel has
85 such a button).
86 @endStyleTable
87
88
89 @beginEventEmissionTable{wxRibbonBarEvent}
90 @event{EVT_RIBBONBAR_PAGE_CHANGED(id, func)}
91 Triggered after the transition from one page being active to a different
92 page being active.
93 @event{EVT_RIBBONBAR_PAGE_CHANGING(id, func)}
94 Triggered prior to the transition from one page being active to a
95 different page being active, and can veto the change.
96 @event{EVT_RIBBONBAR_TAB_MIDDLE_DOWN(id, func)}
97 Triggered when the middle mouse button is pressed on a tab.
98 @event{EVT_RIBBONBAR_TAB_MIDDLE_UP(id, func)}
99 Triggered when the middle mouse button is released on a tab.
100 @event{EVT_RIBBONBAR_TAB_RIGHT_DOWN(id, func)}
101 Triggered when the right mouse button is pressed on a tab.
102 @event{EVT_RIBBONBAR_TAB_RIGHT_UP(id, func)}
103 Triggered when the right mouse button is released on a tab.
104 @event{EVT_RIBBONBAR_TAB_LEFT_DCLICK(id, func)}
105 Triggered when the left mouse button is double clicked on a tab.
106 @endEventTable
107
108 @library{wxribbon}
109 @category{ribbon}
110 */
111 class wxRibbonBar : public wxRibbonControl
112 {
113 public:
114 /**
115 Default constructor.
116 With this constructor, Create() should be called in order to create
117 the ribbon bar.
118 */
119 wxRibbonBar();
120
121 /**
122 Construct a ribbon bar with the given parameters.
123 */
124 wxRibbonBar(wxWindow* parent,
125 wxWindowID id = wxID_ANY,
126 const wxPoint& pos = wxDefaultPosition,
127 const wxSize& size = wxDefaultSize,
128 long style = wxRIBBON_BAR_DEFAULT_STYLE);
129
130 /**
131 Create a ribbon bar in two-step ribbon bar construction.
132 Should only be called when the default constructor is used, and
133 arguments have the same meaning as in the full constructor.
134 */
135 bool Create(wxWindow* parent,
136 wxWindowID id = wxID_ANY,
137 const wxPoint& pos = wxDefaultPosition,
138 const wxSize& size = wxDefaultSize,
139 long style = wxRIBBON_BAR_DEFAULT_STYLE);
140
141 /**
142 Destructor.
143 */
144 virtual ~wxRibbonBar();
145
146 /**
147 Set the margin widths (in pixels) on the left and right sides of the
148 tab bar region of the ribbon bar. These margins will be painted with
149 the tab background, but tabs and scroll buttons will never be painted
150 in the margins.
151
152 The left margin could be used for rendering something equivalent to the
153 "Office Button", though this is not currently implemented. The right
154 margin could be used for rendering a help button, and/or MDI buttons,
155 but again, this is not currently implemented.
156 */
157 void SetTabCtrlMargins(int left, int right);
158
159 /**
160 Set the art provider to be used be the ribbon bar. Also sets the art
161 provider on all current wxRibbonPage children, and any wxRibbonPage
162 children added in the future.
163
164 Note that unlike most other ribbon controls, the ribbon bar creates a
165 default art provider when initialised, so an explicit call to
166 SetArtProvider() is not required if the default art provider is
167 sufficient. Alos unlike other ribbon controls, the ribbon bar takes
168 ownership of the given pointer, and will delete it when the art
169 provider is changed or the bar is destroyed. If this behaviour is not
170 desired, then clone the art provider before setting it.
171 */
172 void SetArtProvider(wxRibbonArtProvider* art);
173
174 /**
175 Set the active page by index, without triggering any events.
176
177 @param page
178 The zero-based index of the page to activate.
179 @return @true if the specified page is now active, @false if it could
180 not be activated (for example because the page index is invalid).
181 */
182 bool SetActivePage(size_t page);
183
184 /**
185 Set the active page, without triggering any events.
186
187 @param page
188 The page to activate.
189 @return @true if the specified page is now active, @false if it could
190 not be activated (for example because the given page is not a child
191 of the ribbon bar).
192 */
193 bool SetActivePage(wxRibbonPage* page);
194
195 /**
196 Get the index of the active page.
197
198 In the rare case of no page being active, -1 is returned.
199 */
200 int GetActivePage() const;
201
202 /**
203 Get a page by index.
204
205 NULL will be returned if the given index is out of range.
206 */
207 wxRibbonPage* GetPage(int n);
208
209 /**
210 Dismiss the expanded panel of the currently active page.
211
212 Calls and returns the value fromwxRibbonPage::DismissExpandedPanel()
213 for the currently active page, or @false if there is no active page.
214 */
215 bool DismissExpandedPanel();
216
217 /**
218 Shows or hides the panel area of the ribbon bar.
219
220 If the panel area is hidden, then only the tab of the ribbon bar will
221 be shown. This is useful for giving the user more screen space to work
222 with when he/she doesn't need to see the ribbon's options.
223
224 @since 2.9.2
225 */
226 void ShowPanels(bool show = true);
227
228 /**
229 Hides the panel area of the ribbon bar.
230
231 This method simply calls ShowPanels() with @false argument.
232
233 @since 2.9.2
234 */
235 void HidePanels();
236
237 /**
238 Indicates whether the panel area of the ribbon bar is shown.
239
240 @see ShowPanels()
241
242 @since 2.9.2
243 */
244 bool ArePanelsShown() const;
245
246 /**
247 Perform initial layout and size calculations of the bar and its
248 children. This must be called after all of the bar's children have been
249 created (and their children created, etc.) - if it is not, then windows
250 may not be laid out or sized correctly.
251
252 Also calls wxRibbonPage::Realize() on each child page.
253 */
254 virtual bool Realize();
255 };