1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: ribbondemo.cpp
3 // Purpose: wxRibbon: Ribbon user interface - sample/test program
4 // Author: Peter Cawley
8 // Copyright: (C) Copyright 2009, Peter Cawley
9 // Licence: wxWindows Library Licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
20 #include "wx/textctrl.h"
21 #include "wx/ribbon/bar.h"
22 #include "wx/ribbon/buttonbar.h"
23 #include "wx/ribbon/gallery.h"
24 #include "wx/ribbon/toolbar.h"
27 #include "wx/msgdlg.h"
28 #include "wx/dcbuffer.h"
29 #include "wx/colordlg.h"
30 #include "wx/artprov.h"
31 #include "wx/combobox.h"
32 #include "wx/tglbtn.h"
33 #include "wx/wrapsizer.h"
37 class MyApp
: public wxApp
48 class MyFrame
: public wxFrame
56 ID_CIRCLE
= wxID_HIGHEST
+ 1,
61 ID_SELECTION_EXPAND_H
,
62 ID_SELECTION_EXPAND_V
,
63 ID_SELECTION_CONTRACT
,
71 ID_POSITION_TOP_ICONS
,
74 ID_POSITION_LEFT_LABELS
,
75 ID_POSITION_LEFT_BOTH
,
85 ID_UI_CHANGE_TEXT_UPDATED
,
91 void OnEnableUpdateUI(wxUpdateUIEvent
& evt
);
92 void OnCheckUpdateUI(wxUpdateUIEvent
& evt
);
93 void OnChangeTextUpdateUI(wxUpdateUIEvent
& evt
);
94 void OnCheck(wxRibbonButtonBarEvent
& evt
);
95 void OnEnable(wxRibbonButtonBarEvent
& evt
);
96 void OnDisable(wxRibbonButtonBarEvent
& evt
);
97 void OnDisabled(wxRibbonButtonBarEvent
& evt
);
98 void OnEnableUpdated(wxRibbonButtonBarEvent
& evt
);
99 void OnChangeText1(wxRibbonButtonBarEvent
& evt
);
100 void OnChangeText2(wxRibbonButtonBarEvent
& evt
);
101 void OnCircleButton(wxRibbonButtonBarEvent
& evt
);
102 void OnCrossButton(wxRibbonButtonBarEvent
& evt
);
103 void OnTriangleButton(wxRibbonButtonBarEvent
& evt
);
104 void OnTriangleDropdown(wxRibbonButtonBarEvent
& evt
);
105 void OnSquareButton(wxRibbonButtonBarEvent
& evt
);
106 void OnPolygonDropdown(wxRibbonButtonBarEvent
& evt
);
107 void OnSelectionExpandVButton(wxRibbonButtonBarEvent
& evt
);
108 void OnSelectionExpandHButton(wxRibbonButtonBarEvent
& evt
);
109 void OnSelectionContractButton(wxRibbonButtonBarEvent
& evt
);
110 void OnHoveredColourChange(wxRibbonGalleryEvent
& evt
);
111 void OnPrimaryColourSelect(wxRibbonGalleryEvent
& evt
);
112 void OnSecondaryColourSelect(wxRibbonGalleryEvent
& evt
);
113 void OnColourGalleryButton(wxCommandEvent
& evt
);
114 void OnDefaultProvider(wxRibbonButtonBarEvent
& evt
);
115 void OnAUIProvider(wxRibbonButtonBarEvent
& evt
);
116 void OnMSWProvider(wxRibbonButtonBarEvent
& evt
);
117 void OnJustify(wxRibbonToolBarEvent
& evt
);
118 void OnJustifyUpdateUI(wxUpdateUIEvent
& evt
);
119 void OnNew(wxRibbonToolBarEvent
& evt
);
120 void OnNewDropdown(wxRibbonToolBarEvent
& evt
);
121 void OnPrint(wxRibbonToolBarEvent
& evt
);
122 void OnPrintDropdown(wxRibbonToolBarEvent
& evt
);
123 void OnRedoDropdown(wxRibbonToolBarEvent
& evt
);
124 void OnUndoDropdown(wxRibbonToolBarEvent
& evt
);
125 void OnPositionTop(wxRibbonToolBarEvent
& evt
);
126 void OnPositionTopLabels(wxCommandEvent
& evt
);
127 void OnPositionTopIcons(wxCommandEvent
& evt
);
128 void OnPositionTopBoth(wxCommandEvent
& evt
);
129 void OnPositionTopDropdown(wxRibbonToolBarEvent
& evt
);
130 void OnPositionLeft(wxRibbonToolBarEvent
& evt
);
131 void OnPositionLeftLabels(wxCommandEvent
& evt
);
132 void OnPositionLeftIcons(wxCommandEvent
& evt
);
133 void OnPositionLeftBoth(wxCommandEvent
& evt
);
134 void OnPositionLeftDropdown(wxRibbonToolBarEvent
& evt
);
135 void OnRemovePage(wxRibbonButtonBarEvent
& evt
);
136 void OnHidePages(wxRibbonButtonBarEvent
& evt
);
137 void OnShowPages(wxRibbonButtonBarEvent
& evt
);
138 void OnTogglePanels(wxCommandEvent
& evt
);
139 void OnRibbonBarToggled(wxRibbonBarEvent
& evt
);
140 void OnRibbonBarHelpClicked(wxRibbonBarEvent
& evt
);
142 void OnSizeEvent(wxSizeEvent
& evt
);
144 void OnExtButton(wxRibbonPanelEvent
& evt
);
147 wxRibbonGallery
* PopulateColoursPanel(wxWindow
* panel
, wxColour def
,
149 void AddText(wxString msg
);
150 wxRibbonGalleryItem
* AddColourToGallery(wxRibbonGallery
*gallery
,
151 wxString name
, wxMemoryDC
& dc
, wxColour
* value
= NULL
);
152 wxColour
GetGalleryColour(wxRibbonGallery
*gallery
,
153 wxRibbonGalleryItem
* item
, wxString
* name
);
154 void ResetGalleryArtProviders();
155 void SetArtProvider(wxRibbonArtProvider
* prov
);
156 void SetBarStyle(long style
);
158 wxRibbonBar
* m_ribbon
;
159 wxRibbonGallery
* m_primary_gallery
;
160 wxRibbonGallery
* m_secondary_gallery
;
161 wxTextCtrl
* m_logwindow
;
162 wxToggleButton
* m_togglePanels
;
164 wxColourData m_colour_data
;
165 wxColour m_default_primary
;
166 wxColour m_default_secondary
;
167 wxColour m_default_tertiary
;
168 wxMemoryDC m_bitmap_creation_dc
;
173 DECLARE_EVENT_TABLE()
176 // -- implementations --
183 wxFrame
* frame
= new MyFrame
;
189 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
190 EVT_RIBBONBUTTONBAR_CLICKED(ID_ENABLE
, MyFrame::OnEnable
)
191 EVT_RIBBONBUTTONBAR_CLICKED(ID_DISABLE
, MyFrame::OnDisable
)
192 EVT_RIBBONBUTTONBAR_CLICKED(ID_DISABLED
, MyFrame::OnDisabled
)
193 EVT_RIBBONBUTTONBAR_CLICKED(ID_UI_ENABLE_UPDATED
, MyFrame::OnEnableUpdated
)
194 EVT_UPDATE_UI(ID_UI_ENABLE_UPDATED
, MyFrame::OnEnableUpdateUI
)
195 EVT_RIBBONBUTTONBAR_CLICKED(ID_CHECK
, MyFrame::OnCheck
)
196 EVT_UPDATE_UI(ID_UI_CHECK_UPDATED
, MyFrame::OnCheckUpdateUI
)
197 EVT_RIBBONBUTTONBAR_CLICKED(ID_CHANGE_TEXT1
, MyFrame::OnChangeText1
)
198 EVT_RIBBONBUTTONBAR_CLICKED(ID_CHANGE_TEXT2
, MyFrame::OnChangeText2
)
199 EVT_UPDATE_UI(ID_UI_CHANGE_TEXT_UPDATED
, MyFrame::OnChangeTextUpdateUI
)
200 EVT_RIBBONBUTTONBAR_CLICKED(ID_DEFAULT_PROVIDER
, MyFrame::OnDefaultProvider
)
201 EVT_RIBBONBUTTONBAR_CLICKED(ID_AUI_PROVIDER
, MyFrame::OnAUIProvider
)
202 EVT_RIBBONBUTTONBAR_CLICKED(ID_MSW_PROVIDER
, MyFrame::OnMSWProvider
)
203 EVT_RIBBONBUTTONBAR_CLICKED(ID_SELECTION_EXPAND_H
, MyFrame::OnSelectionExpandHButton
)
204 EVT_RIBBONBUTTONBAR_CLICKED(ID_SELECTION_EXPAND_V
, MyFrame::OnSelectionExpandVButton
)
205 EVT_RIBBONBUTTONBAR_CLICKED(ID_SELECTION_CONTRACT
, MyFrame::OnSelectionContractButton
)
206 EVT_RIBBONBUTTONBAR_CLICKED(ID_CIRCLE
, MyFrame::OnCircleButton
)
207 EVT_RIBBONBUTTONBAR_CLICKED(ID_CROSS
, MyFrame::OnCrossButton
)
208 EVT_RIBBONBUTTONBAR_CLICKED(ID_TRIANGLE
, MyFrame::OnTriangleButton
)
209 EVT_RIBBONBUTTONBAR_CLICKED(ID_SQUARE
, MyFrame::OnSquareButton
)
210 EVT_RIBBONBUTTONBAR_DROPDOWN_CLICKED(ID_TRIANGLE
, MyFrame::OnTriangleDropdown
)
211 EVT_RIBBONBUTTONBAR_DROPDOWN_CLICKED(ID_POLYGON
, MyFrame::OnPolygonDropdown
)
212 EVT_RIBBONGALLERY_HOVER_CHANGED(ID_PRIMARY_COLOUR
, MyFrame::OnHoveredColourChange
)
213 EVT_RIBBONGALLERY_HOVER_CHANGED(ID_SECONDARY_COLOUR
, MyFrame::OnHoveredColourChange
)
214 EVT_RIBBONGALLERY_SELECTED(ID_PRIMARY_COLOUR
, MyFrame::OnPrimaryColourSelect
)
215 EVT_RIBBONGALLERY_SELECTED(ID_SECONDARY_COLOUR
, MyFrame::OnSecondaryColourSelect
)
216 EVT_RIBBONTOOLBAR_CLICKED(wxID_JUSTIFY_LEFT
, MyFrame::OnJustify
)
217 EVT_RIBBONTOOLBAR_CLICKED(wxID_JUSTIFY_CENTER
, MyFrame::OnJustify
)
218 EVT_RIBBONTOOLBAR_CLICKED(wxID_JUSTIFY_RIGHT
, MyFrame::OnJustify
)
219 EVT_UPDATE_UI(wxID_JUSTIFY_LEFT
, MyFrame::OnJustifyUpdateUI
)
220 EVT_UPDATE_UI(wxID_JUSTIFY_CENTER
, MyFrame::OnJustifyUpdateUI
)
221 EVT_UPDATE_UI(wxID_JUSTIFY_RIGHT
, MyFrame::OnJustifyUpdateUI
)
222 EVT_RIBBONTOOLBAR_CLICKED(wxID_NEW
, MyFrame::OnNew
)
223 EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(wxID_NEW
, MyFrame::OnNewDropdown
)
224 EVT_RIBBONTOOLBAR_CLICKED(wxID_PRINT
, MyFrame::OnPrint
)
225 EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(wxID_PRINT
, MyFrame::OnPrintDropdown
)
226 EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(wxID_REDO
, MyFrame::OnRedoDropdown
)
227 EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(wxID_UNDO
, MyFrame::OnUndoDropdown
)
228 EVT_RIBBONTOOLBAR_CLICKED(ID_POSITION_LEFT
, MyFrame::OnPositionLeft
)
229 EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(ID_POSITION_LEFT
, MyFrame::OnPositionLeftDropdown
)
230 EVT_RIBBONTOOLBAR_CLICKED(ID_POSITION_TOP
, MyFrame::OnPositionTop
)
231 EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(ID_POSITION_TOP
, MyFrame::OnPositionTopDropdown
)
232 EVT_BUTTON(ID_PRIMARY_COLOUR
, MyFrame::OnColourGalleryButton
)
233 EVT_BUTTON(ID_SECONDARY_COLOUR
, MyFrame::OnColourGalleryButton
)
234 EVT_MENU(ID_POSITION_LEFT
, MyFrame::OnPositionLeftIcons
)
235 EVT_MENU(ID_POSITION_LEFT_LABELS
, MyFrame::OnPositionLeftLabels
)
236 EVT_MENU(ID_POSITION_LEFT_BOTH
, MyFrame::OnPositionLeftBoth
)
237 EVT_MENU(ID_POSITION_TOP
, MyFrame::OnPositionTopLabels
)
238 EVT_MENU(ID_POSITION_TOP_ICONS
, MyFrame::OnPositionTopIcons
)
239 EVT_MENU(ID_POSITION_TOP_BOTH
, MyFrame::OnPositionTopBoth
)
240 EVT_TOGGLEBUTTON(ID_TOGGLE_PANELS
, MyFrame::OnTogglePanels
)
241 EVT_RIBBONPANEL_EXTBUTTON_ACTIVATED(wxID_ANY
, MyFrame::OnExtButton
)
242 EVT_RIBBONBUTTONBAR_CLICKED(ID_REMOVE_PAGE
, MyFrame::OnRemovePage
)
243 EVT_RIBBONBUTTONBAR_CLICKED(ID_HIDE_PAGES
, MyFrame::OnHidePages
)
244 EVT_RIBBONBUTTONBAR_CLICKED(ID_SHOW_PAGES
, MyFrame::OnShowPages
)
245 EVT_RIBBONBAR_TOGGLED(wxID_ANY
, MyFrame::OnRibbonBarToggled
)
246 EVT_RIBBONBAR_HELP_CLICK(wxID_ANY
, MyFrame::OnRibbonBarHelpClicked
)
247 EVT_SIZE(MyFrame::OnSizeEvent
)
250 #include "align_center.xpm"
251 #include "align_left.xpm"
252 #include "align_right.xpm"
253 #include "aui_style.xpm"
254 #include "auto_crop_selection.xpm"
255 #include "auto_crop_selection_small.xpm"
256 #include "circle.xpm"
257 #include "circle_small.xpm"
258 #include "colours.xpm"
261 #include "expand_selection_v.xpm"
262 #include "expand_selection_h.xpm"
264 #include "hexagon.xpm"
265 #include "msw_style.xpm"
266 #include "position_left_small.xpm"
267 #include "position_top_small.xpm"
268 #include "ribbon.xpm"
269 #include "selection_panel.xpm"
270 #include "square.xpm"
271 #include "triangle.xpm"
274 : wxFrame(NULL
, wxID_ANY
, wxT("wxRibbon Sample Application"), wxDefaultPosition
, wxSize(800, 600), wxDEFAULT_FRAME_STYLE
)
276 m_ribbon
= new wxRibbonBar(this,-1,wxDefaultPosition
, wxDefaultSize
, wxRIBBON_BAR_FLOW_HORIZONTAL
277 | wxRIBBON_BAR_SHOW_PAGE_LABELS
278 | wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS
279 | wxRIBBON_BAR_SHOW_TOGGLE_BUTTON
280 | wxRIBBON_BAR_SHOW_HELP_BUTTON
284 wxRibbonPage
* home
= new wxRibbonPage(m_ribbon
, wxID_ANY
, wxT("Examples"), ribbon_xpm
);
285 wxRibbonPanel
*toolbar_panel
= new wxRibbonPanel(home
, wxID_ANY
, wxT("Toolbar"),
286 wxNullBitmap
, wxDefaultPosition
, wxDefaultSize
,
287 wxRIBBON_PANEL_NO_AUTO_MINIMISE
|
288 wxRIBBON_PANEL_EXT_BUTTON
);
289 wxRibbonToolBar
*toolbar
= new wxRibbonToolBar(toolbar_panel
, ID_MAIN_TOOLBAR
);
290 toolbar
->AddToggleTool(wxID_JUSTIFY_LEFT
, align_left_xpm
);
291 toolbar
->AddToggleTool(wxID_JUSTIFY_CENTER
, align_center_xpm
);
292 toolbar
->AddToggleTool(wxID_JUSTIFY_RIGHT
, align_right_xpm
);
293 toolbar
->AddSeparator();
294 toolbar
->AddHybridTool(wxID_NEW
, wxArtProvider::GetBitmap(wxART_NEW
, wxART_OTHER
, wxSize(16, 15)));
295 toolbar
->AddTool(wxID_OPEN
, wxArtProvider::GetBitmap(wxART_FILE_OPEN
, wxART_OTHER
, wxSize(16, 15)), "Open something");
296 toolbar
->AddTool(wxID_SAVE
, wxArtProvider::GetBitmap(wxART_FILE_SAVE
, wxART_OTHER
, wxSize(16, 15)), "Save something");
297 toolbar
->AddTool(wxID_SAVEAS
, wxArtProvider::GetBitmap(wxART_FILE_SAVE_AS
, wxART_OTHER
, wxSize(16, 15)), "Save something as ...");
298 toolbar
->EnableTool(wxID_OPEN
, false);
299 toolbar
->EnableTool(wxID_SAVE
, false);
300 toolbar
->EnableTool(wxID_SAVEAS
, false);
301 toolbar
->AddSeparator();
302 toolbar
->AddDropdownTool(wxID_UNDO
, wxArtProvider::GetBitmap(wxART_UNDO
, wxART_OTHER
, wxSize(16, 15)));
303 toolbar
->AddDropdownTool(wxID_REDO
, wxArtProvider::GetBitmap(wxART_REDO
, wxART_OTHER
, wxSize(16, 15)));
304 toolbar
->AddSeparator();
305 toolbar
->AddTool(wxID_ANY
, wxArtProvider::GetBitmap(wxART_REPORT_VIEW
, wxART_OTHER
, wxSize(16, 15)));
306 toolbar
->AddTool(wxID_ANY
, wxArtProvider::GetBitmap(wxART_LIST_VIEW
, wxART_OTHER
, wxSize(16, 15)));
307 toolbar
->AddSeparator();
308 toolbar
->AddHybridTool(ID_POSITION_LEFT
, position_left_xpm
,
309 "Align ribbonbar vertically\non the left\nfor demonstration purposes");
310 toolbar
->AddHybridTool(ID_POSITION_TOP
, position_top_xpm
,
311 "Align the ribbonbar horizontally\nat the top\nfor demonstration purposes");
312 toolbar
->AddSeparator();
313 toolbar
->AddHybridTool(wxID_PRINT
, wxArtProvider::GetBitmap(wxART_PRINT
, wxART_OTHER
, wxSize(16, 15)),
314 "This is the Print button tooltip\ndemonstrating a tooltip");
315 toolbar
->SetRows(2, 3);
317 wxRibbonPanel
*selection_panel
= new wxRibbonPanel(home
, wxID_ANY
, wxT("Selection"), wxBitmap(selection_panel_xpm
));
318 wxRibbonButtonBar
*selection
= new wxRibbonButtonBar(selection_panel
);
319 selection
->AddButton(ID_SELECTION_EXPAND_V
, wxT("Expand Vertically"), wxBitmap(expand_selection_v_xpm
),
320 "This is a tooltip for Expand Vertically\ndemonstrating a tooltip");
321 selection
->AddButton(ID_SELECTION_EXPAND_H
, wxT("Expand Horizontally"), wxBitmap(expand_selection_h_xpm
), wxEmptyString
);
322 selection
->AddButton(ID_SELECTION_CONTRACT
, wxT("Contract"), wxBitmap(auto_crop_selection_xpm
), wxBitmap(auto_crop_selection_small_xpm
));
324 wxRibbonPanel
*shapes_panel
= new wxRibbonPanel(home
, wxID_ANY
, wxT("Shapes"), wxBitmap(circle_small_xpm
));
325 wxRibbonButtonBar
*shapes
= new wxRibbonButtonBar(shapes_panel
);
326 shapes
->AddButton(ID_CIRCLE
, wxT("Circle"), wxBitmap(circle_xpm
), wxBitmap(circle_small_xpm
),
327 wxNullBitmap
, wxNullBitmap
, wxRIBBON_BUTTON_NORMAL
,
328 "This is a tooltip for the circle button\ndemonstrating another tooltip");
329 shapes
->AddButton(ID_CROSS
, wxT("Cross"), wxBitmap(cross_xpm
), wxEmptyString
);
330 shapes
->AddHybridButton(ID_TRIANGLE
, wxT("Triangle"), wxBitmap(triangle_xpm
));
331 shapes
->AddButton(ID_SQUARE
, wxT("Square"), wxBitmap(square_xpm
), wxEmptyString
);
332 shapes
->AddDropdownButton(ID_POLYGON
, wxT("Other Polygon"), wxBitmap(hexagon_xpm
), wxEmptyString
);
334 wxRibbonPanel
*sizer_panel
= new wxRibbonPanel(home
, wxID_ANY
, wxT("Panel with Sizer"),
335 wxNullBitmap
, wxDefaultPosition
, wxDefaultSize
,
336 wxRIBBON_PANEL_DEFAULT_STYLE
);
339 as
.Add("Item 1 using a box sizer now");
340 as
.Add("Item 2 using a box sizer now");
341 wxComboBox
* sizer_panelcombo
= new wxComboBox(sizer_panel
, wxID_ANY
,
343 wxDefaultPosition
, wxDefaultSize
,
346 wxComboBox
* sizer_panelcombo2
= new wxComboBox(sizer_panel
, wxID_ANY
,
348 wxDefaultPosition
, wxDefaultSize
,
351 sizer_panelcombo
->Select(0);
352 sizer_panelcombo2
->Select(1);
353 sizer_panelcombo
->SetMinSize(wxSize(150, -1));
354 sizer_panelcombo2
->SetMinSize(wxSize(150, -1));
356 //not using wxWrapSizer(wxHORIZONTAL) as it reports an incorrect min height
357 wxSizer
* sizer_panelsizer
= new wxBoxSizer(wxVERTICAL
);
358 sizer_panelsizer
->AddStretchSpacer(1);
359 sizer_panelsizer
->Add(sizer_panelcombo
, 0, wxALL
|wxEXPAND
, 2);
360 sizer_panelsizer
->Add(sizer_panelcombo2
, 0, wxALL
|wxEXPAND
, 2);
361 sizer_panelsizer
->AddStretchSpacer(1);
362 sizer_panel
->SetSizer(sizer_panelsizer
);
364 wxFont
label_font(8, wxFONTFAMILY_DEFAULT
, wxFONTSTYLE_NORMAL
, wxFONTWEIGHT_LIGHT
);
365 m_bitmap_creation_dc
.SetFont(label_font
);
367 wxRibbonPage
* scheme
= new wxRibbonPage(m_ribbon
, wxID_ANY
, wxT("Appearance"), eye_xpm
);
368 m_ribbon
->GetArtProvider()->GetColourScheme(&m_default_primary
,
369 &m_default_secondary
, &m_default_tertiary
);
370 wxRibbonPanel
*provider_panel
= new wxRibbonPanel(scheme
, wxID_ANY
,
371 wxT("Art"), wxNullBitmap
, wxDefaultPosition
, wxDefaultSize
, wxRIBBON_PANEL_NO_AUTO_MINIMISE
);
372 wxRibbonButtonBar
*provider_bar
= new wxRibbonButtonBar(provider_panel
, wxID_ANY
);
373 provider_bar
->AddButton(ID_DEFAULT_PROVIDER
, wxT("Default Provider"),
374 wxArtProvider::GetBitmap(wxART_QUESTION
, wxART_OTHER
, wxSize(32, 32)));
375 provider_bar
->AddButton(ID_AUI_PROVIDER
, wxT("AUI Provider"), aui_style_xpm
);
376 provider_bar
->AddButton(ID_MSW_PROVIDER
, wxT("MSW Provider"), msw_style_xpm
);
377 wxRibbonPanel
*primary_panel
= new wxRibbonPanel(scheme
, wxID_ANY
,
378 wxT("Primary Colour"), colours_xpm
);
379 m_primary_gallery
= PopulateColoursPanel(primary_panel
,
380 m_default_primary
, ID_PRIMARY_COLOUR
);
381 wxRibbonPanel
*secondary_panel
= new wxRibbonPanel(scheme
, wxID_ANY
,
382 wxT("Secondary Colour"), colours_xpm
);
383 m_secondary_gallery
= PopulateColoursPanel(secondary_panel
,
384 m_default_secondary
, ID_SECONDARY_COLOUR
);
387 wxRibbonPage
* page
= new wxRibbonPage(m_ribbon
, wxID_ANY
, wxT("UI Updated"), ribbon_xpm
);
388 wxRibbonPanel
*panel
= new wxRibbonPanel(page
, wxID_ANY
, wxT("Enable/Disable"), ribbon_xpm
);
389 wxRibbonButtonBar
*bar
= new wxRibbonButtonBar(panel
, wxID_ANY
);
390 bar
->AddButton(ID_DISABLED
, wxT("Disabled"), ribbon_xpm
);
391 bar
->AddButton(ID_ENABLE
, wxT("Enable"), ribbon_xpm
);
392 bar
->AddButton(ID_DISABLE
, wxT("Disable"), ribbon_xpm
);
393 bar
->AddButton(ID_UI_ENABLE_UPDATED
, wxT("Enable UI updated"), ribbon_xpm
);
394 bar
->EnableButton(ID_DISABLED
, false);
397 panel
= new wxRibbonPanel(page
, wxID_ANY
, wxT("Toggle"), ribbon_xpm
);
398 bar
= new wxRibbonButtonBar(panel
, wxID_ANY
);
399 bar
->AddButton(ID_CHECK
, wxT("Toggle"), ribbon_xpm
);
400 bar
->AddToggleButton(ID_UI_CHECK_UPDATED
, wxT("Toggled UI updated"), ribbon_xpm
);
403 panel
= new wxRibbonPanel(page
, wxID_ANY
, wxT("Change text"), ribbon_xpm
);
404 bar
= new wxRibbonButtonBar(panel
, wxID_ANY
);
405 bar
->AddButton(ID_CHANGE_TEXT1
, wxT("One"), ribbon_xpm
);
406 bar
->AddButton(ID_CHANGE_TEXT2
, wxT("Two"), ribbon_xpm
);
407 bar
->AddButton(ID_UI_CHANGE_TEXT_UPDATED
, wxT("Zero"), ribbon_xpm
);
409 new wxRibbonPage(m_ribbon
, wxID_ANY
, wxT("Empty Page"), empty_xpm
);
411 wxRibbonPage
* page
= new wxRibbonPage(m_ribbon
, wxID_ANY
, wxT("Another Page"), empty_xpm
);
412 wxRibbonPanel
*panel
= new wxRibbonPanel(page
, wxID_ANY
, wxT("Page manipulation"), ribbon_xpm
);
413 wxRibbonButtonBar
*bar
= new wxRibbonButtonBar(panel
, wxID_ANY
);
414 bar
->AddButton(ID_REMOVE_PAGE
, wxT("Remove"), wxArtProvider::GetBitmap(wxART_DELETE
, wxART_OTHER
, wxSize(24, 24)));
415 bar
->AddButton(ID_HIDE_PAGES
, wxT("Hide Pages"), ribbon_xpm
);
416 bar
->AddButton(ID_SHOW_PAGES
, wxT("Show Pages"), ribbon_xpm
);
418 new wxRibbonPage(m_ribbon
, wxID_ANY
, wxT("Highlight Page"), empty_xpm
);
419 m_ribbon
->AddPageHighlight(m_ribbon
->GetPageCount()-1);
423 m_logwindow
= new wxTextCtrl(this, wxID_ANY
, wxEmptyString
,
424 wxDefaultPosition
, wxDefaultSize
, wxTE_MULTILINE
| wxTE_READONLY
|
425 wxTE_LEFT
| wxTE_BESTWRAP
| wxBORDER_NONE
);
427 m_togglePanels
= new wxToggleButton(this, ID_TOGGLE_PANELS
, "&Toggle panels");
428 m_togglePanels
->SetValue(true);
430 wxSizer
*s
= new wxBoxSizer(wxVERTICAL
);
432 s
->Add(m_ribbon
, 0, wxEXPAND
);
433 s
->Add(m_logwindow
, 1, wxEXPAND
);
434 s
->Add(m_togglePanels
, wxSizerFlags().Border());
439 void MyFrame::SetBarStyle(long style
)
442 m_ribbon
->SetWindowStyleFlag(style
);
443 wxBoxSizer
*pTopSize
= reinterpret_cast<wxBoxSizer
*>(GetSizer());
444 wxRibbonToolBar
*pToolbar
= wxDynamicCast(FindWindow(ID_MAIN_TOOLBAR
), wxRibbonToolBar
);
445 if(style
& wxRIBBON_BAR_FLOW_VERTICAL
)
447 m_ribbon
->SetTabCtrlMargins(10, 10);
448 pTopSize
->SetOrientation(wxHORIZONTAL
);
450 pToolbar
->SetRows(3, 5);
454 m_ribbon
->SetTabCtrlMargins(50, 20);
455 pTopSize
->SetOrientation(wxVERTICAL
);
457 pToolbar
->SetRows(2, 3);
468 class ColourClientData
: public wxClientData
471 ColourClientData(const wxString
& name
, const wxColour
& colour
)
472 : m_name(name
), m_colour(colour
) {}
474 const wxString
& GetName() const {return m_name
;}
475 const wxColour
& GetColour() const {return m_colour
;}
482 wxRibbonGallery
* MyFrame::PopulateColoursPanel(wxWindow
* panel
,
483 wxColour def
, int gallery_id
)
485 wxRibbonGallery
*gallery
= wxDynamicCast(panel
->FindWindow(gallery_id
), wxRibbonGallery
);
489 gallery
= new wxRibbonGallery(panel
, gallery_id
);
490 wxMemoryDC
& dc
= m_bitmap_creation_dc
;
491 wxRibbonGalleryItem
*def_item
=
492 AddColourToGallery(gallery
, wxT("Default"), dc
, &def
);
493 gallery
->SetSelection(def_item
);
494 AddColourToGallery(gallery
, wxT("BLUE"), dc
);
495 AddColourToGallery(gallery
, wxT("BLUE VIOLET"), dc
);
496 AddColourToGallery(gallery
, wxT("BROWN"), dc
);
497 AddColourToGallery(gallery
, wxT("CADET BLUE"), dc
);
498 AddColourToGallery(gallery
, wxT("CORAL"), dc
);
499 AddColourToGallery(gallery
, wxT("CYAN"), dc
);
500 AddColourToGallery(gallery
, wxT("DARK GREEN"), dc
);
501 AddColourToGallery(gallery
, wxT("DARK ORCHID"), dc
);
502 AddColourToGallery(gallery
, wxT("FIREBRICK"), dc
);
503 AddColourToGallery(gallery
, wxT("GOLD"), dc
);
504 AddColourToGallery(gallery
, wxT("GOLDENROD"), dc
);
505 AddColourToGallery(gallery
, wxT("GREEN"), dc
);
506 AddColourToGallery(gallery
, wxT("INDIAN RED"), dc
);
507 AddColourToGallery(gallery
, wxT("KHAKI"), dc
);
508 AddColourToGallery(gallery
, wxT("LIGHT BLUE"), dc
);
509 AddColourToGallery(gallery
, wxT("LIME GREEN"), dc
);
510 AddColourToGallery(gallery
, wxT("MAGENTA"), dc
);
511 AddColourToGallery(gallery
, wxT("MAROON"), dc
);
512 AddColourToGallery(gallery
, wxT("NAVY"), dc
);
513 AddColourToGallery(gallery
, wxT("ORANGE"), dc
);
514 AddColourToGallery(gallery
, wxT("ORCHID"), dc
);
515 AddColourToGallery(gallery
, wxT("PINK"), dc
);
516 AddColourToGallery(gallery
, wxT("PLUM"), dc
);
517 AddColourToGallery(gallery
, wxT("PURPLE"), dc
);
518 AddColourToGallery(gallery
, wxT("RED"), dc
);
519 AddColourToGallery(gallery
, wxT("SALMON"), dc
);
520 AddColourToGallery(gallery
, wxT("SEA GREEN"), dc
);
521 AddColourToGallery(gallery
, wxT("SIENNA"), dc
);
522 AddColourToGallery(gallery
, wxT("SKY BLUE"), dc
);
523 AddColourToGallery(gallery
, wxT("TAN"), dc
);
524 AddColourToGallery(gallery
, wxT("THISTLE"), dc
);
525 AddColourToGallery(gallery
, wxT("TURQUOISE"), dc
);
526 AddColourToGallery(gallery
, wxT("VIOLET"), dc
);
527 AddColourToGallery(gallery
, wxT("VIOLET RED"), dc
);
528 AddColourToGallery(gallery
, wxT("WHEAT"), dc
);
529 AddColourToGallery(gallery
, wxT("WHITE"), dc
);
530 AddColourToGallery(gallery
, wxT("YELLOW"), dc
);
535 wxColour
MyFrame::GetGalleryColour(wxRibbonGallery
*gallery
,
536 wxRibbonGalleryItem
* item
, wxString
* name
)
538 ColourClientData
*data
= (ColourClientData
*)gallery
->GetItemClientObject(item
);
540 *name
= data
->GetName();
541 return data
->GetColour();
544 void MyFrame::OnHoveredColourChange(wxRibbonGalleryEvent
& evt
)
546 // Set the background of the gallery to the hovered colour, or back to the
547 // default if there is no longer a hovered item.
549 wxRibbonGallery
*gallery
= evt
.GetGallery();
550 wxRibbonArtProvider
*provider
= gallery
->GetArtProvider();
552 if(evt
.GetGalleryItem() != NULL
)
554 if(provider
== m_ribbon
->GetArtProvider())
556 provider
= provider
->Clone();
557 gallery
->SetArtProvider(provider
);
559 provider
->SetColour(wxRIBBON_ART_GALLERY_HOVER_BACKGROUND_COLOUR
,
560 GetGalleryColour(evt
.GetGallery(), evt
.GetGalleryItem(), NULL
));
564 if(provider
!= m_ribbon
->GetArtProvider())
566 gallery
->SetArtProvider(m_ribbon
->GetArtProvider());
572 void MyFrame::OnPrimaryColourSelect(wxRibbonGalleryEvent
& evt
)
575 wxColour colour
= GetGalleryColour(evt
.GetGallery(), evt
.GetGalleryItem(), &name
);
576 AddText(wxT("Colour \"") + name
+ wxT("\" selected as primary."));
577 wxColour secondary
, tertiary
;
578 m_ribbon
->GetArtProvider()->GetColourScheme(NULL
, &secondary
, &tertiary
);
579 m_ribbon
->GetArtProvider()->SetColourScheme(colour
, secondary
, tertiary
);
580 ResetGalleryArtProviders();
584 void MyFrame::OnSecondaryColourSelect(wxRibbonGalleryEvent
& evt
)
587 wxColour colour
= GetGalleryColour(evt
.GetGallery(), evt
.GetGalleryItem(), &name
);
588 AddText(wxT("Colour \"") + name
+ wxT("\" selected as secondary."));
589 wxColour primary
, tertiary
;
590 m_ribbon
->GetArtProvider()->GetColourScheme(&primary
, NULL
, &tertiary
);
591 m_ribbon
->GetArtProvider()->SetColourScheme(primary
, colour
, tertiary
);
592 ResetGalleryArtProviders();
596 void MyFrame::ResetGalleryArtProviders()
598 if(m_primary_gallery
->GetArtProvider() != m_ribbon
->GetArtProvider())
600 delete m_primary_gallery
->GetArtProvider();
601 m_primary_gallery
->SetArtProvider(m_ribbon
->GetArtProvider());
603 if(m_secondary_gallery
->GetArtProvider() != m_ribbon
->GetArtProvider())
605 delete m_secondary_gallery
->GetArtProvider();
606 m_secondary_gallery
->SetArtProvider(m_ribbon
->GetArtProvider());
610 void MyFrame::OnChangeText1(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
612 m_new_text
= wxT("One");
615 void MyFrame::OnChangeText2(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
617 m_new_text
= wxT("Two");
620 void MyFrame::OnEnable(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
625 void MyFrame::OnDisable(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
630 void MyFrame::OnDisabled(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
632 AddText("ERROR: Disabled button activated (not supposed to happen)");
635 void MyFrame::OnEnableUpdated(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
637 AddText("Button activated");
640 void MyFrame::OnCheck(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
642 m_bChecked
= !m_bChecked
;
645 void MyFrame::OnEnableUpdateUI(wxUpdateUIEvent
& evt
)
647 evt
.Enable(m_bEnabled
);
650 void MyFrame::OnCheckUpdateUI(wxUpdateUIEvent
& evt
)
652 evt
.Check(m_bChecked
);
655 void MyFrame::OnChangeTextUpdateUI(wxUpdateUIEvent
& evt
)
657 if ( !m_new_text
.IsEmpty() )
659 evt
.SetText(m_new_text
);
660 m_new_text
= wxT("");
664 void MyFrame::OnSelectionExpandHButton(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
666 AddText(wxT("Expand selection horizontally button clicked."));
669 void MyFrame::OnSelectionExpandVButton(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
671 AddText(wxT("Expand selection vertically button clicked."));
674 void MyFrame::OnSelectionContractButton(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
676 AddText(wxT("Contract selection button clicked."));
679 void MyFrame::OnCircleButton(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
681 AddText(wxT("Circle button clicked."));
684 void MyFrame::OnCrossButton(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
686 AddText(wxT("Cross button clicked."));
689 void MyFrame::OnTriangleButton(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
691 AddText(wxT("Triangle button clicked."));
694 void MyFrame::OnTriangleDropdown(wxRibbonButtonBarEvent
& evt
)
697 menu
.Append(wxID_ANY
, wxT("Equilateral"));
698 menu
.Append(wxID_ANY
, wxT("Isosceles"));
699 menu
.Append(wxID_ANY
, wxT("Scalene"));
701 evt
.PopupMenu(&menu
);
704 void MyFrame::OnSquareButton(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
706 AddText(wxT("Square button clicked."));
709 void MyFrame::OnPolygonDropdown(wxRibbonButtonBarEvent
& evt
)
712 menu
.Append(wxID_ANY
, wxT("Pentagon (5 sided)"));
713 menu
.Append(wxID_ANY
, wxT("Hexagon (6 sided)"));
714 menu
.Append(wxID_ANY
, wxT("Heptagon (7 sided)"));
715 menu
.Append(wxID_ANY
, wxT("Octogon (8 sided)"));
716 menu
.Append(wxID_ANY
, wxT("Nonagon (9 sided)"));
717 menu
.Append(wxID_ANY
, wxT("Decagon (10 sided)"));
719 evt
.PopupMenu(&menu
);
722 void MyFrame::OnJustify(wxRibbonToolBarEvent
& evt
)
724 long style
= m_logwindow
->GetWindowStyle() &
725 ~(wxTE_LEFT
| wxTE_CENTER
| wxTE_RIGHT
);
728 case wxID_JUSTIFY_LEFT
:
729 m_logwindow
->SetWindowStyle(style
| wxTE_LEFT
);
731 case wxID_JUSTIFY_CENTER
:
732 m_logwindow
->SetWindowStyle(style
| wxTE_CENTER
);
734 case wxID_JUSTIFY_RIGHT
:
735 m_logwindow
->SetWindowStyle(style
| wxTE_RIGHT
);
740 void MyFrame::OnJustifyUpdateUI(wxUpdateUIEvent
& evt
)
744 case wxID_JUSTIFY_LEFT
:
745 evt
.Check(!m_logwindow
->HasFlag(wxTE_CENTER
| wxTE_RIGHT
));
747 case wxID_JUSTIFY_CENTER
:
748 evt
.Check(m_logwindow
->HasFlag(wxTE_CENTER
));
750 case wxID_JUSTIFY_RIGHT
:
751 evt
.Check(m_logwindow
->HasFlag(wxTE_RIGHT
));
756 void MyFrame::OnNew(wxRibbonToolBarEvent
& WXUNUSED(evt
))
758 AddText(wxT("New button clicked."));
761 void MyFrame::OnNewDropdown(wxRibbonToolBarEvent
& evt
)
764 menu
.Append(wxID_ANY
, wxT("New Document"));
765 menu
.Append(wxID_ANY
, wxT("New Template"));
766 menu
.Append(wxID_ANY
, wxT("New Mail"));
768 evt
.PopupMenu(&menu
);
771 void MyFrame::OnPrint(wxRibbonToolBarEvent
& WXUNUSED(evt
))
773 AddText(wxT("Print button clicked."));
776 void MyFrame::OnPrintDropdown(wxRibbonToolBarEvent
& evt
)
779 menu
.Append(wxID_ANY
, wxT("Print"));
780 menu
.Append(wxID_ANY
, wxT("Preview"));
781 menu
.Append(wxID_ANY
, wxT("Options"));
783 evt
.PopupMenu(&menu
);
786 void MyFrame::OnRedoDropdown(wxRibbonToolBarEvent
& evt
)
789 menu
.Append(wxID_ANY
, wxT("Redo E"));
790 menu
.Append(wxID_ANY
, wxT("Redo F"));
791 menu
.Append(wxID_ANY
, wxT("Redo G"));
793 evt
.PopupMenu(&menu
);
796 void MyFrame::OnUndoDropdown(wxRibbonToolBarEvent
& evt
)
799 menu
.Append(wxID_ANY
, wxT("Undo C"));
800 menu
.Append(wxID_ANY
, wxT("Undo B"));
801 menu
.Append(wxID_ANY
, wxT("Undo A"));
803 evt
.PopupMenu(&menu
);
806 void MyFrame::OnPositionTopLabels(wxCommandEvent
& WXUNUSED(evt
))
808 SetBarStyle(wxRIBBON_BAR_DEFAULT_STYLE
);
811 void MyFrame::OnPositionTopIcons(wxCommandEvent
& WXUNUSED(evt
))
813 SetBarStyle((wxRIBBON_BAR_DEFAULT_STYLE
&~wxRIBBON_BAR_SHOW_PAGE_LABELS
)
814 | wxRIBBON_BAR_SHOW_PAGE_ICONS
);
817 void MyFrame::OnPositionTopBoth(wxCommandEvent
& WXUNUSED(evt
))
819 SetBarStyle(wxRIBBON_BAR_DEFAULT_STYLE
| wxRIBBON_BAR_SHOW_PAGE_ICONS
);
822 void MyFrame::OnPositionLeftLabels(wxCommandEvent
& WXUNUSED(evt
))
824 SetBarStyle(wxRIBBON_BAR_DEFAULT_STYLE
| wxRIBBON_BAR_FLOW_VERTICAL
);
827 void MyFrame::OnPositionLeftIcons(wxCommandEvent
& WXUNUSED(evt
))
829 SetBarStyle((wxRIBBON_BAR_DEFAULT_STYLE
&~wxRIBBON_BAR_SHOW_PAGE_LABELS
) |
830 wxRIBBON_BAR_SHOW_PAGE_ICONS
| wxRIBBON_BAR_FLOW_VERTICAL
);
833 void MyFrame::OnPositionLeftBoth(wxCommandEvent
& WXUNUSED(evt
))
835 SetBarStyle(wxRIBBON_BAR_DEFAULT_STYLE
| wxRIBBON_BAR_SHOW_PAGE_ICONS
|
836 wxRIBBON_BAR_FLOW_VERTICAL
);
839 void MyFrame::OnPositionTop(wxRibbonToolBarEvent
& evt
)
841 OnPositionTopLabels(evt
);
844 void MyFrame::OnPositionTopDropdown(wxRibbonToolBarEvent
& evt
)
847 menu
.Append(ID_POSITION_TOP
, wxT("Top with Labels"));
848 menu
.Append(ID_POSITION_TOP_ICONS
, wxT("Top with Icons"));
849 menu
.Append(ID_POSITION_TOP_BOTH
, wxT("Top with Both"));
850 evt
.PopupMenu(&menu
);
853 void MyFrame::OnPositionLeft(wxRibbonToolBarEvent
& evt
)
855 OnPositionLeftIcons(evt
);
858 void MyFrame::OnPositionLeftDropdown(wxRibbonToolBarEvent
& evt
)
861 menu
.Append(ID_POSITION_LEFT
, wxT("Left with Icons"));
862 menu
.Append(ID_POSITION_LEFT_LABELS
, wxT("Left with Labels"));
863 menu
.Append(ID_POSITION_LEFT_BOTH
, wxT("Left with Both"));
864 evt
.PopupMenu(&menu
);
867 void MyFrame::OnTogglePanels(wxCommandEvent
& WXUNUSED(evt
))
869 m_ribbon
->ShowPanels(m_togglePanels
->GetValue());
872 void MyFrame::OnExtButton(wxRibbonPanelEvent
& WXUNUSED(evt
))
874 wxMessageBox("Extension button clicked");
877 void MyFrame::AddText(wxString msg
)
879 m_logwindow
->AppendText(msg
);
880 m_logwindow
->AppendText(wxT("\n"));
881 m_ribbon
->DismissExpandedPanel();
884 wxRibbonGalleryItem
* MyFrame::AddColourToGallery(wxRibbonGallery
*gallery
,
885 wxString colour
, wxMemoryDC
& dc
,
888 wxRibbonGalleryItem
* item
= NULL
;
890 if (colour
!= wxT("Default"))
891 c
= wxColour(colour
);
896 const int iWidth
= 64;
897 const int iHeight
= 40;
899 wxBitmap
bitmap(iWidth
, iHeight
);
900 dc
.SelectObject(bitmap
);
902 dc
.SetPen(*wxBLACK_PEN
);
904 dc
.DrawRectangle(0, 0, iWidth
, iHeight
);
906 colour
= colour
.Mid(0, 1) + colour
.Mid(1).Lower();
907 wxSize size
= dc
.GetTextExtent(colour
);
908 wxColour foreground
= wxColour(~c
.Red(), ~c
.Green(), ~c
.Blue());
909 if(abs(foreground
.Red() - c
.Red()) + abs(foreground
.Blue() - c
.Blue())
910 + abs(foreground
.Green() - c
.Green()) < 64)
912 // Foreground too similar to background - use a different
913 // strategy to find a contrasting colour
914 foreground
= wxColour((c
.Red() + 64) % 256, 255 - c
.Green(),
915 (c
.Blue() + 192) % 256);
917 dc
.SetTextForeground(foreground
);
918 dc
.DrawText(colour
, (iWidth
- size
.GetWidth() + 1) / 2,
919 (iHeight
- size
.GetHeight()) / 2);
920 dc
.SelectObjectAsSource(wxNullBitmap
);
922 item
= gallery
->Append(bitmap
, wxID_ANY
);
923 gallery
->SetItemClientObject(item
, new ColourClientData(colour
, c
));
928 void MyFrame::OnColourGalleryButton(wxCommandEvent
& evt
)
930 wxRibbonGallery
*gallery
= wxDynamicCast(evt
.GetEventObject(), wxRibbonGallery
);
934 m_ribbon
->DismissExpandedPanel();
935 if(gallery
->GetSelection())
936 m_colour_data
.SetColour(GetGalleryColour(gallery
, gallery
->GetSelection(), NULL
));
937 wxColourDialog
dlg(this, &m_colour_data
);
938 if(dlg
.ShowModal() == wxID_OK
)
940 m_colour_data
= dlg
.GetColourData();
941 wxColour clr
= m_colour_data
.GetColour();
943 // Try to find colour in gallery
944 wxRibbonGalleryItem
*item
= NULL
;
945 for(unsigned int i
= 0; i
< gallery
->GetCount(); ++i
)
947 item
= gallery
->GetItem(i
);
948 if(GetGalleryColour(gallery
, item
, NULL
) == clr
)
954 // Colour not in gallery - add it
957 item
= AddColourToGallery(gallery
,
958 clr
.GetAsString(wxC2S_HTML_SYNTAX
), m_bitmap_creation_dc
,
964 gallery
->EnsureVisible(item
);
965 gallery
->SetSelection(item
);
967 // Send an event to respond to the selection change
968 wxRibbonGalleryEvent
dummy(wxEVT_COMMAND_RIBBONGALLERY_SELECTED
, gallery
->GetId());
969 dummy
.SetEventObject(gallery
);
970 dummy
.SetGallery(gallery
);
971 dummy
.SetGalleryItem(item
);
972 ProcessWindowEvent(dummy
);
976 void MyFrame::OnDefaultProvider(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
978 m_ribbon
->DismissExpandedPanel();
979 SetArtProvider(new wxRibbonDefaultArtProvider
);
982 void MyFrame::OnAUIProvider(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
984 m_ribbon
->DismissExpandedPanel();
985 SetArtProvider(new wxRibbonAUIArtProvider
);
988 void MyFrame::OnMSWProvider(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
990 m_ribbon
->DismissExpandedPanel();
991 SetArtProvider(new wxRibbonMSWArtProvider
);
994 void MyFrame::SetArtProvider(wxRibbonArtProvider
*prov
)
997 m_ribbon
->SetArtProvider(prov
);
999 prov
->GetColourScheme(&m_default_primary
, &m_default_secondary
,
1000 &m_default_tertiary
);
1001 PopulateColoursPanel(m_primary_gallery
->GetParent(), m_default_primary
,
1003 PopulateColoursPanel(m_secondary_gallery
->GetParent(), m_default_secondary
,
1004 ID_SECONDARY_COLOUR
);
1006 m_ribbon
->Realize();
1008 GetSizer()->Layout();
1011 void MyFrame::OnRemovePage(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
1013 size_t n
= m_ribbon
->GetPageCount();
1016 m_ribbon
->DeletePage(n
-1);
1017 m_ribbon
->Realize();
1021 void MyFrame::OnHidePages(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
1023 m_ribbon
->HidePage(1);
1024 m_ribbon
->HidePage(2);
1025 m_ribbon
->HidePage(3);
1026 m_ribbon
->Realize();
1029 void MyFrame::OnShowPages(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
1031 m_ribbon
->ShowPage(1);
1032 m_ribbon
->ShowPage(2);
1033 m_ribbon
->ShowPage(3);
1034 m_ribbon
->Realize();
1037 void MyFrame::OnRibbonBarToggled(wxRibbonBarEvent
& WXUNUSED(evt
))
1039 AddText(wxString::Format("Ribbon bar %s.",
1040 m_ribbon
->ArePanelsShown()
1045 void MyFrame::OnRibbonBarHelpClicked(wxRibbonBarEvent
& WXUNUSED(evt
))
1047 AddText("Ribbon bar help clicked");
1050 // This shows how to hide ribbon dynamically if there is not enough space.
1051 void MyFrame::OnSizeEvent(wxSizeEvent
& evt
)
1053 if ( evt
.GetSize().GetWidth() < 200 )