]> git.saurik.com Git - wxWidgets.git/blob - samples/ribbon/ribbondemo.cpp
Add wxRibbonControl::GetAncestorRibbonBar() helper.
[wxWidgets.git] / samples / ribbon / ribbondemo.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: ribbondemo.cpp
3 // Purpose: wxRibbon: Ribbon user interface - sample/test program
4 // Author: Peter Cawley
5 // Modified by:
6 // Created: 2009-05-25
7 // RCS-ID: $Id$
8 // Copyright: (C) Copyright 2009, Peter Cawley
9 // Licence: wxWindows Library Licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #ifdef __BORLANDC__
15 #pragma hdrstop
16 #endif
17
18 #include "wx/app.h"
19 #include "wx/frame.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"
25 #include "wx/sizer.h"
26 #include "wx/menu.h"
27 #include "wx/dcbuffer.h"
28 #include "wx/colordlg.h"
29 #include "wx/artprov.h"
30 #include "wx/combobox.h"
31 #include "wx/tglbtn.h"
32 #include "wx/wrapsizer.h"
33
34 // -- application --
35
36 class MyApp : public wxApp
37 {
38 public:
39 bool OnInit();
40 };
41
42 DECLARE_APP(MyApp)
43 IMPLEMENT_APP(MyApp)
44
45 // -- frame --
46
47 class MyFrame : public wxFrame
48 {
49 public:
50 MyFrame();
51 ~MyFrame();
52
53 enum
54 {
55 ID_CIRCLE = wxID_HIGHEST + 1,
56 ID_CROSS,
57 ID_TRIANGLE,
58 ID_SQUARE,
59 ID_POLYGON,
60 ID_SELECTION_EXPAND_H,
61 ID_SELECTION_EXPAND_V,
62 ID_SELECTION_CONTRACT,
63 ID_PRIMARY_COLOUR,
64 ID_SECONDARY_COLOUR,
65 ID_DEFAULT_PROVIDER,
66 ID_AUI_PROVIDER,
67 ID_MSW_PROVIDER,
68 ID_MAIN_TOOLBAR,
69 ID_POSITION_TOP,
70 ID_POSITION_TOP_ICONS,
71 ID_POSITION_TOP_BOTH,
72 ID_POSITION_LEFT,
73 ID_POSITION_LEFT_LABELS,
74 ID_POSITION_LEFT_BOTH,
75 ID_TOGGLE_PANELS,
76 ID_ENABLE,
77 ID_DISABLE,
78 ID_DISABLED,
79 ID_UI_ENABLE_UPDATED,
80 ID_CHECK,
81 ID_UI_CHECK_UPDATED,
82 ID_CHANGE_TEXT1,
83 ID_CHANGE_TEXT2,
84 ID_UI_CHANGE_TEXT_UPDATED
85 };
86
87 void OnEnableUpdateUI(wxUpdateUIEvent& evt);
88 void OnCheckUpdateUI(wxUpdateUIEvent& evt);
89 void OnChangeTextUpdateUI(wxUpdateUIEvent& evt);
90 void OnCheck(wxRibbonButtonBarEvent& evt);
91 void OnEnable(wxRibbonButtonBarEvent& evt);
92 void OnDisable(wxRibbonButtonBarEvent& evt);
93 void OnChangeText1(wxRibbonButtonBarEvent& evt);
94 void OnChangeText2(wxRibbonButtonBarEvent& evt);
95 void OnCircleButton(wxRibbonButtonBarEvent& evt);
96 void OnCrossButton(wxRibbonButtonBarEvent& evt);
97 void OnTriangleButton(wxRibbonButtonBarEvent& evt);
98 void OnTriangleDropdown(wxRibbonButtonBarEvent& evt);
99 void OnSquareButton(wxRibbonButtonBarEvent& evt);
100 void OnPolygonDropdown(wxRibbonButtonBarEvent& evt);
101 void OnSelectionExpandVButton(wxRibbonButtonBarEvent& evt);
102 void OnSelectionExpandHButton(wxRibbonButtonBarEvent& evt);
103 void OnSelectionContractButton(wxRibbonButtonBarEvent& evt);
104 void OnHoveredColourChange(wxRibbonGalleryEvent& evt);
105 void OnPrimaryColourSelect(wxRibbonGalleryEvent& evt);
106 void OnSecondaryColourSelect(wxRibbonGalleryEvent& evt);
107 void OnColourGalleryButton(wxCommandEvent& evt);
108 void OnDefaultProvider(wxRibbonButtonBarEvent& evt);
109 void OnAUIProvider(wxRibbonButtonBarEvent& evt);
110 void OnMSWProvider(wxRibbonButtonBarEvent& evt);
111 void OnJustify(wxRibbonToolBarEvent& evt);
112 void OnJustifyUpdateUI(wxUpdateUIEvent& evt);
113 void OnNew(wxRibbonToolBarEvent& evt);
114 void OnNewDropdown(wxRibbonToolBarEvent& evt);
115 void OnPrint(wxRibbonToolBarEvent& evt);
116 void OnPrintDropdown(wxRibbonToolBarEvent& evt);
117 void OnRedoDropdown(wxRibbonToolBarEvent& evt);
118 void OnUndoDropdown(wxRibbonToolBarEvent& evt);
119 void OnPositionTop(wxRibbonToolBarEvent& evt);
120 void OnPositionTopLabels(wxCommandEvent& evt);
121 void OnPositionTopIcons(wxCommandEvent& evt);
122 void OnPositionTopBoth(wxCommandEvent& evt);
123 void OnPositionTopDropdown(wxRibbonToolBarEvent& evt);
124 void OnPositionLeft(wxRibbonToolBarEvent& evt);
125 void OnPositionLeftLabels(wxCommandEvent& evt);
126 void OnPositionLeftIcons(wxCommandEvent& evt);
127 void OnPositionLeftBoth(wxCommandEvent& evt);
128 void OnPositionLeftDropdown(wxRibbonToolBarEvent& evt);
129
130 void OnTogglePanels(wxCommandEvent& evt);
131
132 protected:
133 wxRibbonGallery* PopulateColoursPanel(wxWindow* panel, wxColour def,
134 int gallery_id);
135 void AddText(wxString msg);
136 wxRibbonGalleryItem* AddColourToGallery(wxRibbonGallery *gallery,
137 wxString name, wxMemoryDC& dc, wxColour* value = NULL);
138 wxColour GetGalleryColour(wxRibbonGallery *gallery,
139 wxRibbonGalleryItem* item, wxString* name);
140 void ResetGalleryArtProviders();
141 void SetArtProvider(wxRibbonArtProvider* prov);
142 void SetBarStyle(long style);
143
144 wxRibbonBar* m_ribbon;
145 wxRibbonGallery* m_primary_gallery;
146 wxRibbonGallery* m_secondary_gallery;
147 wxTextCtrl* m_logwindow;
148 wxToggleButton* m_togglePanels;
149
150 wxColourData m_colour_data;
151 wxColour m_default_primary;
152 wxColour m_default_secondary;
153 wxColour m_default_tertiary;
154 wxMemoryDC m_bitmap_creation_dc;
155 bool m_bEnabled;
156 bool m_bChecked;
157 wxString m_new_text;
158
159 DECLARE_EVENT_TABLE()
160 };
161
162 // -- implementations --
163
164 bool MyApp::OnInit()
165 {
166 if(!wxApp::OnInit())
167 return false;
168
169 wxFrame* frame = new MyFrame;
170 frame->Show();
171
172 return true;
173 }
174
175 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
176 EVT_RIBBONBUTTONBAR_CLICKED(ID_ENABLE, MyFrame::OnEnable)
177 EVT_RIBBONBUTTONBAR_CLICKED(ID_DISABLE, MyFrame::OnDisable)
178 EVT_UPDATE_UI(ID_UI_ENABLE_UPDATED, MyFrame::OnEnableUpdateUI)
179 EVT_RIBBONBUTTONBAR_CLICKED(ID_CHECK, MyFrame::OnCheck)
180 EVT_UPDATE_UI(ID_UI_CHECK_UPDATED, MyFrame::OnCheckUpdateUI)
181 EVT_RIBBONBUTTONBAR_CLICKED(ID_CHANGE_TEXT1, MyFrame::OnChangeText1)
182 EVT_RIBBONBUTTONBAR_CLICKED(ID_CHANGE_TEXT2, MyFrame::OnChangeText2)
183 EVT_UPDATE_UI(ID_UI_CHANGE_TEXT_UPDATED, MyFrame::OnChangeTextUpdateUI)
184 EVT_RIBBONBUTTONBAR_CLICKED(ID_DEFAULT_PROVIDER, MyFrame::OnDefaultProvider)
185 EVT_RIBBONBUTTONBAR_CLICKED(ID_AUI_PROVIDER, MyFrame::OnAUIProvider)
186 EVT_RIBBONBUTTONBAR_CLICKED(ID_MSW_PROVIDER, MyFrame::OnMSWProvider)
187 EVT_RIBBONBUTTONBAR_CLICKED(ID_SELECTION_EXPAND_H, MyFrame::OnSelectionExpandHButton)
188 EVT_RIBBONBUTTONBAR_CLICKED(ID_SELECTION_EXPAND_V, MyFrame::OnSelectionExpandVButton)
189 EVT_RIBBONBUTTONBAR_CLICKED(ID_SELECTION_CONTRACT, MyFrame::OnSelectionContractButton)
190 EVT_RIBBONBUTTONBAR_CLICKED(ID_CIRCLE, MyFrame::OnCircleButton)
191 EVT_RIBBONBUTTONBAR_CLICKED(ID_CROSS, MyFrame::OnCrossButton)
192 EVT_RIBBONBUTTONBAR_CLICKED(ID_TRIANGLE, MyFrame::OnTriangleButton)
193 EVT_RIBBONBUTTONBAR_CLICKED(ID_SQUARE, MyFrame::OnSquareButton)
194 EVT_RIBBONBUTTONBAR_DROPDOWN_CLICKED(ID_TRIANGLE, MyFrame::OnTriangleDropdown)
195 EVT_RIBBONBUTTONBAR_DROPDOWN_CLICKED(ID_POLYGON, MyFrame::OnPolygonDropdown)
196 EVT_RIBBONGALLERY_HOVER_CHANGED(ID_PRIMARY_COLOUR, MyFrame::OnHoveredColourChange)
197 EVT_RIBBONGALLERY_HOVER_CHANGED(ID_SECONDARY_COLOUR, MyFrame::OnHoveredColourChange)
198 EVT_RIBBONGALLERY_SELECTED(ID_PRIMARY_COLOUR, MyFrame::OnPrimaryColourSelect)
199 EVT_RIBBONGALLERY_SELECTED(ID_SECONDARY_COLOUR, MyFrame::OnSecondaryColourSelect)
200 EVT_RIBBONTOOLBAR_CLICKED(wxID_JUSTIFY_LEFT, MyFrame::OnJustify)
201 EVT_RIBBONTOOLBAR_CLICKED(wxID_JUSTIFY_CENTER, MyFrame::OnJustify)
202 EVT_RIBBONTOOLBAR_CLICKED(wxID_JUSTIFY_RIGHT, MyFrame::OnJustify)
203 EVT_UPDATE_UI(wxID_JUSTIFY_LEFT, MyFrame::OnJustifyUpdateUI)
204 EVT_UPDATE_UI(wxID_JUSTIFY_CENTER, MyFrame::OnJustifyUpdateUI)
205 EVT_UPDATE_UI(wxID_JUSTIFY_RIGHT, MyFrame::OnJustifyUpdateUI)
206 EVT_RIBBONTOOLBAR_CLICKED(wxID_NEW, MyFrame::OnNew)
207 EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(wxID_NEW, MyFrame::OnNewDropdown)
208 EVT_RIBBONTOOLBAR_CLICKED(wxID_PRINT, MyFrame::OnPrint)
209 EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(wxID_PRINT, MyFrame::OnPrintDropdown)
210 EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(wxID_REDO, MyFrame::OnRedoDropdown)
211 EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(wxID_UNDO, MyFrame::OnUndoDropdown)
212 EVT_RIBBONTOOLBAR_CLICKED(ID_POSITION_LEFT, MyFrame::OnPositionLeft)
213 EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(ID_POSITION_LEFT, MyFrame::OnPositionLeftDropdown)
214 EVT_RIBBONTOOLBAR_CLICKED(ID_POSITION_TOP, MyFrame::OnPositionTop)
215 EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(ID_POSITION_TOP, MyFrame::OnPositionTopDropdown)
216 EVT_BUTTON(ID_PRIMARY_COLOUR, MyFrame::OnColourGalleryButton)
217 EVT_BUTTON(ID_SECONDARY_COLOUR, MyFrame::OnColourGalleryButton)
218 EVT_MENU(ID_POSITION_LEFT, MyFrame::OnPositionLeftIcons)
219 EVT_MENU(ID_POSITION_LEFT_LABELS, MyFrame::OnPositionLeftLabels)
220 EVT_MENU(ID_POSITION_LEFT_BOTH, MyFrame::OnPositionLeftBoth)
221 EVT_MENU(ID_POSITION_TOP, MyFrame::OnPositionTopLabels)
222 EVT_MENU(ID_POSITION_TOP_ICONS, MyFrame::OnPositionTopIcons)
223 EVT_MENU(ID_POSITION_TOP_BOTH, MyFrame::OnPositionTopBoth)
224 EVT_TOGGLEBUTTON(ID_TOGGLE_PANELS, MyFrame::OnTogglePanels)
225 END_EVENT_TABLE()
226
227 #include "align_center.xpm"
228 #include "align_left.xpm"
229 #include "align_right.xpm"
230 #include "aui_style.xpm"
231 #include "auto_crop_selection.xpm"
232 #include "auto_crop_selection_small.xpm"
233 #include "circle.xpm"
234 #include "circle_small.xpm"
235 #include "colours.xpm"
236 #include "cross.xpm"
237 #include "empty.xpm"
238 #include "expand_selection_v.xpm"
239 #include "expand_selection_h.xpm"
240 #include "eye.xpm"
241 #include "hexagon.xpm"
242 #include "msw_style.xpm"
243 #include "position_left_small.xpm"
244 #include "position_top_small.xpm"
245 #include "ribbon.xpm"
246 #include "selection_panel.xpm"
247 #include "square.xpm"
248 #include "triangle.xpm"
249
250 MyFrame::MyFrame()
251 : wxFrame(NULL, wxID_ANY, wxT("wxRibbon Sample Application"), wxDefaultPosition, wxSize(800, 600), wxDEFAULT_FRAME_STYLE)
252 {
253 m_ribbon = new wxRibbonBar(this, wxID_ANY);
254
255 {
256 wxRibbonPage* home = new wxRibbonPage(m_ribbon, wxID_ANY, wxT("Examples"), ribbon_xpm);
257 wxRibbonPanel *toolbar_panel = new wxRibbonPanel(home, wxID_ANY, wxT("Toolbar"),
258 wxNullBitmap, wxDefaultPosition, wxDefaultSize,
259 wxRIBBON_PANEL_NO_AUTO_MINIMISE);
260 wxRibbonToolBar *toolbar = new wxRibbonToolBar(toolbar_panel, ID_MAIN_TOOLBAR);
261 toolbar->AddToggleTool(wxID_JUSTIFY_LEFT, align_left_xpm);
262 toolbar->AddToggleTool(wxID_JUSTIFY_CENTER , align_center_xpm);
263 toolbar->AddToggleTool(wxID_JUSTIFY_RIGHT, align_right_xpm);
264 toolbar->AddSeparator();
265 toolbar->AddHybridTool(wxID_NEW, wxArtProvider::GetBitmap(wxART_NEW, wxART_OTHER, wxSize(16, 15)));
266 toolbar->AddTool(wxID_OPEN, wxArtProvider::GetBitmap(wxART_FILE_OPEN, wxART_OTHER, wxSize(16, 15)), "Open something");
267 toolbar->AddTool(wxID_SAVE, wxArtProvider::GetBitmap(wxART_FILE_SAVE, wxART_OTHER, wxSize(16, 15)), "Save something");
268 toolbar->AddTool(wxID_SAVEAS, wxArtProvider::GetBitmap(wxART_FILE_SAVE_AS, wxART_OTHER, wxSize(16, 15)), "Save something as ...");
269 toolbar->EnableTool(wxID_OPEN, false);
270 toolbar->EnableTool(wxID_SAVE, false);
271 toolbar->EnableTool(wxID_SAVEAS, false);
272 toolbar->AddSeparator();
273 toolbar->AddDropdownTool(wxID_UNDO, wxArtProvider::GetBitmap(wxART_UNDO, wxART_OTHER, wxSize(16, 15)));
274 toolbar->AddDropdownTool(wxID_REDO, wxArtProvider::GetBitmap(wxART_REDO, wxART_OTHER, wxSize(16, 15)));
275 toolbar->AddSeparator();
276 toolbar->AddTool(wxID_ANY, wxArtProvider::GetBitmap(wxART_REPORT_VIEW, wxART_OTHER, wxSize(16, 15)));
277 toolbar->AddTool(wxID_ANY, wxArtProvider::GetBitmap(wxART_LIST_VIEW, wxART_OTHER, wxSize(16, 15)));
278 toolbar->AddSeparator();
279 toolbar->AddHybridTool(ID_POSITION_LEFT, position_left_xpm,
280 "Align ribbonbar vertically\non the left\nfor demonstration purposes");
281 toolbar->AddHybridTool(ID_POSITION_TOP, position_top_xpm,
282 "Align the ribbonbar horizontally\nat the top\nfor demonstration purposes");
283 toolbar->AddSeparator();
284 toolbar->AddHybridTool(wxID_PRINT, wxArtProvider::GetBitmap(wxART_PRINT, wxART_OTHER, wxSize(16, 15)),
285 "This is the Print button tooltip\ndemonstrating a tooltip");
286 toolbar->SetRows(2, 3);
287
288 wxRibbonPanel *selection_panel = new wxRibbonPanel(home, wxID_ANY, wxT("Selection"), wxBitmap(selection_panel_xpm));
289 wxRibbonButtonBar *selection = new wxRibbonButtonBar(selection_panel);
290 selection->AddButton(ID_SELECTION_EXPAND_V, wxT("Expand Vertically"), wxBitmap(expand_selection_v_xpm),
291 "This is a tooltip for Expand Vertically\ndemonstrating a tooltip");
292 selection->AddButton(ID_SELECTION_EXPAND_H, wxT("Expand Horizontally"), wxBitmap(expand_selection_h_xpm), wxEmptyString);
293 selection->AddButton(ID_SELECTION_CONTRACT, wxT("Contract"), wxBitmap(auto_crop_selection_xpm), wxBitmap(auto_crop_selection_small_xpm));
294
295 wxRibbonPanel *shapes_panel = new wxRibbonPanel(home, wxID_ANY, wxT("Shapes"), wxBitmap(circle_small_xpm));
296 wxRibbonButtonBar *shapes = new wxRibbonButtonBar(shapes_panel);
297 shapes->AddButton(ID_CIRCLE, wxT("Circle"), wxBitmap(circle_xpm), wxBitmap(circle_small_xpm),
298 wxNullBitmap, wxNullBitmap, wxRIBBON_BUTTON_NORMAL,
299 "This is a tooltip for the circle button\ndemonstrating another tooltip");
300 shapes->AddButton(ID_CROSS, wxT("Cross"), wxBitmap(cross_xpm), wxEmptyString);
301 shapes->AddHybridButton(ID_TRIANGLE, wxT("Triangle"), wxBitmap(triangle_xpm));
302 shapes->AddButton(ID_SQUARE, wxT("Square"), wxBitmap(square_xpm), wxEmptyString);
303 shapes->AddDropdownButton(ID_POLYGON, wxT("Other Polygon"), wxBitmap(hexagon_xpm), wxEmptyString);
304
305 wxRibbonPanel *sizer_panel = new wxRibbonPanel(home, wxID_ANY, wxT("Panel with Sizer"),
306 wxNullBitmap, wxDefaultPosition, wxDefaultSize,
307 wxRIBBON_PANEL_DEFAULT_STYLE);
308
309 wxArrayString as;
310 as.Add("Item 1 using a box sizer now");
311 as.Add("Item 2 using a box sizer now");
312 wxComboBox* sizer_panelcombo = new wxComboBox(sizer_panel, wxID_ANY,
313 wxEmptyString,
314 wxDefaultPosition, wxDefaultSize,
315 as, wxCB_READONLY);
316
317 wxComboBox* sizer_panelcombo2 = new wxComboBox(sizer_panel, wxID_ANY,
318 wxEmptyString,
319 wxDefaultPosition, wxDefaultSize,
320 as, wxCB_READONLY);
321
322 sizer_panelcombo->Select(0);
323 sizer_panelcombo2->Select(1);
324 sizer_panelcombo->SetMinSize(wxSize(150, -1));
325 sizer_panelcombo2->SetMinSize(wxSize(150, -1));
326
327 //not using wxWrapSizer(wxHORIZONTAL) as it reports an incorrect min height
328 wxSizer* sizer_panelsizer = new wxBoxSizer(wxVERTICAL);
329 sizer_panelsizer->AddStretchSpacer(1);
330 sizer_panelsizer->Add(sizer_panelcombo, 0, wxALL|wxEXPAND, 2);
331 sizer_panelsizer->Add(sizer_panelcombo2, 0, wxALL|wxEXPAND, 2);
332 sizer_panelsizer->AddStretchSpacer(1);
333 sizer_panel->SetSizer(sizer_panelsizer);
334
335 wxFont label_font(8, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_LIGHT);
336 m_bitmap_creation_dc.SetFont(label_font);
337
338 wxRibbonPage* scheme = new wxRibbonPage(m_ribbon, wxID_ANY, wxT("Appearance"), eye_xpm);
339 m_ribbon->GetArtProvider()->GetColourScheme(&m_default_primary,
340 &m_default_secondary, &m_default_tertiary);
341 wxRibbonPanel *provider_panel = new wxRibbonPanel(scheme, wxID_ANY,
342 wxT("Art"), wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxRIBBON_PANEL_NO_AUTO_MINIMISE);
343 wxRibbonButtonBar *provider_bar = new wxRibbonButtonBar(provider_panel, wxID_ANY);
344 provider_bar->AddButton(ID_DEFAULT_PROVIDER, wxT("Default Provider"),
345 wxArtProvider::GetBitmap(wxART_QUESTION, wxART_OTHER, wxSize(32, 32)));
346 provider_bar->AddButton(ID_AUI_PROVIDER, wxT("AUI Provider"), aui_style_xpm);
347 provider_bar->AddButton(ID_MSW_PROVIDER, wxT("MSW Provider"), msw_style_xpm);
348 wxRibbonPanel *primary_panel = new wxRibbonPanel(scheme, wxID_ANY,
349 wxT("Primary Colour"), colours_xpm);
350 m_primary_gallery = PopulateColoursPanel(primary_panel,
351 m_default_primary, ID_PRIMARY_COLOUR);
352 wxRibbonPanel *secondary_panel = new wxRibbonPanel(scheme, wxID_ANY,
353 wxT("Secondary Colour"), colours_xpm);
354 m_secondary_gallery = PopulateColoursPanel(secondary_panel,
355 m_default_secondary, ID_SECONDARY_COLOUR);
356 }
357 {
358 wxRibbonPage* page = new wxRibbonPage(m_ribbon, wxID_ANY, wxT("UI Updated"), ribbon_xpm);
359 wxRibbonPanel *panel = new wxRibbonPanel(page, wxID_ANY, wxT("Enable/Disable"), ribbon_xpm);
360 wxRibbonButtonBar *bar = new wxRibbonButtonBar(panel, wxID_ANY);
361 bar->AddButton(ID_DISABLED, wxT("Disabled"), ribbon_xpm);
362 bar->AddButton(ID_ENABLE, wxT("Enable"), ribbon_xpm);
363 bar->AddButton(ID_DISABLE, wxT("Disable"), ribbon_xpm);
364 bar->AddButton(ID_UI_ENABLE_UPDATED, wxT("Enable UI updated"), ribbon_xpm);
365 bar->EnableButton(ID_DISABLED, false);
366 m_bEnabled = true;
367
368 panel = new wxRibbonPanel(page, wxID_ANY, wxT("Toggle"), ribbon_xpm);
369 bar = new wxRibbonButtonBar(panel, wxID_ANY);
370 bar->AddButton(ID_CHECK, wxT("Toggle"), ribbon_xpm);
371 bar->AddToggleButton(ID_UI_CHECK_UPDATED, wxT("Toggled UI updated"), ribbon_xpm);
372 m_bChecked = true;
373
374 panel = new wxRibbonPanel(page, wxID_ANY, wxT("Change text"), ribbon_xpm);
375 bar = new wxRibbonButtonBar(panel, wxID_ANY);
376 bar->AddButton(ID_CHANGE_TEXT1, wxT("One"), ribbon_xpm);
377 bar->AddButton(ID_CHANGE_TEXT2, wxT("Two"), ribbon_xpm);
378 bar->AddButton(ID_UI_CHANGE_TEXT_UPDATED, wxT("Zero"), ribbon_xpm);
379 }
380 new wxRibbonPage(m_ribbon, wxID_ANY, wxT("Empty Page"), empty_xpm);
381 new wxRibbonPage(m_ribbon, wxID_ANY, wxT("Another Page"), empty_xpm);
382
383 m_ribbon->Realize();
384
385 m_logwindow = new wxTextCtrl(this, wxID_ANY, wxEmptyString,
386 wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY |
387 wxTE_LEFT | wxTE_BESTWRAP | wxBORDER_NONE);
388
389 m_togglePanels = new wxToggleButton(this, ID_TOGGLE_PANELS, "&Toggle panels");
390 m_togglePanels->SetValue(true);
391
392 wxSizer *s = new wxBoxSizer(wxVERTICAL);
393
394 s->Add(m_ribbon, 0, wxEXPAND);
395 s->Add(m_logwindow, 1, wxEXPAND);
396 s->Add(m_togglePanels, wxSizerFlags().Border());
397
398 SetSizer(s);
399 }
400
401 void MyFrame::SetBarStyle(long style)
402 {
403 m_ribbon->Freeze();
404 m_ribbon->SetWindowStyleFlag(style);
405 wxBoxSizer *pTopSize = reinterpret_cast<wxBoxSizer*>(GetSizer());
406 wxRibbonToolBar *pToolbar = wxDynamicCast(FindWindow(ID_MAIN_TOOLBAR), wxRibbonToolBar);
407 if(style & wxRIBBON_BAR_FLOW_VERTICAL)
408 {
409 m_ribbon->SetTabCtrlMargins(10, 10);
410 pTopSize->SetOrientation(wxHORIZONTAL);
411 if(pToolbar)
412 pToolbar->SetRows(3, 5);
413 }
414 else
415 {
416 m_ribbon->SetTabCtrlMargins(50, 20);
417 pTopSize->SetOrientation(wxVERTICAL);
418 if(pToolbar)
419 pToolbar->SetRows(2, 3);
420 }
421 m_ribbon->Realise();
422 Layout();
423 m_ribbon->Thaw();
424 }
425
426 MyFrame::~MyFrame()
427 {
428 }
429
430 class ColourClientData : public wxClientData
431 {
432 public:
433 ColourClientData(const wxString& name, const wxColour& colour)
434 : m_name(name), m_colour(colour) {}
435
436 const wxString& GetName() const {return m_name;}
437 const wxColour& GetColour() const {return m_colour;}
438
439 private:
440 wxString m_name;
441 wxColour m_colour;
442 };
443
444 wxRibbonGallery* MyFrame::PopulateColoursPanel(wxWindow* panel,
445 wxColour def, int gallery_id)
446 {
447 wxRibbonGallery *gallery = wxDynamicCast(panel->FindWindow(gallery_id), wxRibbonGallery);
448 if(gallery)
449 gallery->Clear();
450 else
451 gallery = new wxRibbonGallery(panel, gallery_id);
452 wxMemoryDC& dc = m_bitmap_creation_dc;
453 wxRibbonGalleryItem *def_item =
454 AddColourToGallery(gallery, wxT("Default"), dc, &def);
455 gallery->SetSelection(def_item);
456 AddColourToGallery(gallery, wxT("BLUE"), dc);
457 AddColourToGallery(gallery, wxT("BLUE VIOLET"), dc);
458 AddColourToGallery(gallery, wxT("BROWN"), dc);
459 AddColourToGallery(gallery, wxT("CADET BLUE"), dc);
460 AddColourToGallery(gallery, wxT("CORAL"), dc);
461 AddColourToGallery(gallery, wxT("CYAN"), dc);
462 AddColourToGallery(gallery, wxT("DARK GREEN"), dc);
463 AddColourToGallery(gallery, wxT("DARK ORCHID"), dc);
464 AddColourToGallery(gallery, wxT("FIREBRICK"), dc);
465 AddColourToGallery(gallery, wxT("GOLD"), dc);
466 AddColourToGallery(gallery, wxT("GOLDENROD"), dc);
467 AddColourToGallery(gallery, wxT("GREEN"), dc);
468 AddColourToGallery(gallery, wxT("INDIAN RED"), dc);
469 AddColourToGallery(gallery, wxT("KHAKI"), dc);
470 AddColourToGallery(gallery, wxT("LIGHT BLUE"), dc);
471 AddColourToGallery(gallery, wxT("LIME GREEN"), dc);
472 AddColourToGallery(gallery, wxT("MAGENTA"), dc);
473 AddColourToGallery(gallery, wxT("MAROON"), dc);
474 AddColourToGallery(gallery, wxT("NAVY"), dc);
475 AddColourToGallery(gallery, wxT("ORANGE"), dc);
476 AddColourToGallery(gallery, wxT("ORCHID"), dc);
477 AddColourToGallery(gallery, wxT("PINK"), dc);
478 AddColourToGallery(gallery, wxT("PLUM"), dc);
479 AddColourToGallery(gallery, wxT("PURPLE"), dc);
480 AddColourToGallery(gallery, wxT("RED"), dc);
481 AddColourToGallery(gallery, wxT("SALMON"), dc);
482 AddColourToGallery(gallery, wxT("SEA GREEN"), dc);
483 AddColourToGallery(gallery, wxT("SIENNA"), dc);
484 AddColourToGallery(gallery, wxT("SKY BLUE"), dc);
485 AddColourToGallery(gallery, wxT("TAN"), dc);
486 AddColourToGallery(gallery, wxT("THISTLE"), dc);
487 AddColourToGallery(gallery, wxT("TURQUOISE"), dc);
488 AddColourToGallery(gallery, wxT("VIOLET"), dc);
489 AddColourToGallery(gallery, wxT("VIOLET RED"), dc);
490 AddColourToGallery(gallery, wxT("WHEAT"), dc);
491 AddColourToGallery(gallery, wxT("WHITE"), dc);
492 AddColourToGallery(gallery, wxT("YELLOW"), dc);
493
494 return gallery;
495 }
496
497 wxColour MyFrame::GetGalleryColour(wxRibbonGallery *gallery,
498 wxRibbonGalleryItem* item, wxString* name)
499 {
500 ColourClientData *data = (ColourClientData*)gallery->GetItemClientObject(item);
501 if(name != NULL)
502 *name = data->GetName();
503 return data->GetColour();
504 }
505
506 void MyFrame::OnHoveredColourChange(wxRibbonGalleryEvent& evt)
507 {
508 // Set the background of the gallery to the hovered colour, or back to the
509 // default if there is no longer a hovered item.
510
511 wxRibbonGallery *gallery = evt.GetGallery();
512 wxRibbonArtProvider *provider = gallery->GetArtProvider();
513
514 if(evt.GetGalleryItem() != NULL)
515 {
516 if(provider == m_ribbon->GetArtProvider())
517 {
518 provider = provider->Clone();
519 gallery->SetArtProvider(provider);
520 }
521 provider->SetColour(wxRIBBON_ART_GALLERY_HOVER_BACKGROUND_COLOUR,
522 GetGalleryColour(evt.GetGallery(), evt.GetGalleryItem(), NULL));
523 }
524 else
525 {
526 if(provider != m_ribbon->GetArtProvider())
527 {
528 gallery->SetArtProvider(m_ribbon->GetArtProvider());
529 delete provider;
530 }
531 }
532 }
533
534 void MyFrame::OnPrimaryColourSelect(wxRibbonGalleryEvent& evt)
535 {
536 wxString name;
537 wxColour colour = GetGalleryColour(evt.GetGallery(), evt.GetGalleryItem(), &name);
538 AddText(wxT("Colour \"") + name + wxT("\" selected as primary."));
539 wxColour secondary, tertiary;
540 m_ribbon->GetArtProvider()->GetColourScheme(NULL, &secondary, &tertiary);
541 m_ribbon->GetArtProvider()->SetColourScheme(colour, secondary, tertiary);
542 ResetGalleryArtProviders();
543 m_ribbon->Refresh();
544 }
545
546 void MyFrame::OnSecondaryColourSelect(wxRibbonGalleryEvent& evt)
547 {
548 wxString name;
549 wxColour colour = GetGalleryColour(evt.GetGallery(), evt.GetGalleryItem(), &name);
550 AddText(wxT("Colour \"") + name + wxT("\" selected as secondary."));
551 wxColour primary, tertiary;
552 m_ribbon->GetArtProvider()->GetColourScheme(&primary, NULL, &tertiary);
553 m_ribbon->GetArtProvider()->SetColourScheme(primary, colour, tertiary);
554 ResetGalleryArtProviders();
555 m_ribbon->Refresh();
556 }
557
558 void MyFrame::ResetGalleryArtProviders()
559 {
560 if(m_primary_gallery->GetArtProvider() != m_ribbon->GetArtProvider())
561 {
562 delete m_primary_gallery->GetArtProvider();
563 m_primary_gallery->SetArtProvider(m_ribbon->GetArtProvider());
564 }
565 if(m_secondary_gallery->GetArtProvider() != m_ribbon->GetArtProvider())
566 {
567 delete m_secondary_gallery->GetArtProvider();
568 m_secondary_gallery->SetArtProvider(m_ribbon->GetArtProvider());
569 }
570 }
571
572 void MyFrame::OnChangeText1(wxRibbonButtonBarEvent& WXUNUSED(evt))
573 {
574 m_new_text = wxT("One");
575 }
576
577 void MyFrame::OnChangeText2(wxRibbonButtonBarEvent& WXUNUSED(evt))
578 {
579 m_new_text = wxT("Two");
580 }
581
582 void MyFrame::OnEnable(wxRibbonButtonBarEvent& WXUNUSED(evt))
583 {
584 m_bEnabled = true;
585 }
586
587 void MyFrame::OnDisable(wxRibbonButtonBarEvent& WXUNUSED(evt))
588 {
589 m_bEnabled = false;
590 }
591
592 void MyFrame::OnCheck(wxRibbonButtonBarEvent& WXUNUSED(evt))
593 {
594 m_bChecked = !m_bChecked;
595 }
596
597 void MyFrame::OnEnableUpdateUI(wxUpdateUIEvent& evt)
598 {
599 evt.Enable(m_bEnabled);
600 }
601
602 void MyFrame::OnCheckUpdateUI(wxUpdateUIEvent& evt)
603 {
604 evt.Check(m_bChecked);
605 }
606
607 void MyFrame::OnChangeTextUpdateUI(wxUpdateUIEvent& evt)
608 {
609 if ( !m_new_text.IsEmpty() )
610 {
611 evt.SetText(m_new_text);
612 m_new_text = wxT("");
613 }
614 }
615
616 void MyFrame::OnSelectionExpandHButton(wxRibbonButtonBarEvent& WXUNUSED(evt))
617 {
618 AddText(wxT("Expand selection horizontally button clicked."));
619 }
620
621 void MyFrame::OnSelectionExpandVButton(wxRibbonButtonBarEvent& WXUNUSED(evt))
622 {
623 AddText(wxT("Expand selection vertically button clicked."));
624 }
625
626 void MyFrame::OnSelectionContractButton(wxRibbonButtonBarEvent& WXUNUSED(evt))
627 {
628 AddText(wxT("Contract selection button clicked."));
629 }
630
631 void MyFrame::OnCircleButton(wxRibbonButtonBarEvent& WXUNUSED(evt))
632 {
633 AddText(wxT("Circle button clicked."));
634 }
635
636 void MyFrame::OnCrossButton(wxRibbonButtonBarEvent& WXUNUSED(evt))
637 {
638 AddText(wxT("Cross button clicked."));
639 }
640
641 void MyFrame::OnTriangleButton(wxRibbonButtonBarEvent& WXUNUSED(evt))
642 {
643 AddText(wxT("Triangle button clicked."));
644 }
645
646 void MyFrame::OnTriangleDropdown(wxRibbonButtonBarEvent& evt)
647 {
648 wxMenu menu;
649 menu.Append(wxID_ANY, wxT("Equilateral"));
650 menu.Append(wxID_ANY, wxT("Isosceles"));
651 menu.Append(wxID_ANY, wxT("Scalene"));
652
653 evt.PopupMenu(&menu);
654 }
655
656 void MyFrame::OnSquareButton(wxRibbonButtonBarEvent& WXUNUSED(evt))
657 {
658 AddText(wxT("Square button clicked."));
659 }
660
661 void MyFrame::OnPolygonDropdown(wxRibbonButtonBarEvent& evt)
662 {
663 wxMenu menu;
664 menu.Append(wxID_ANY, wxT("Pentagon (5 sided)"));
665 menu.Append(wxID_ANY, wxT("Hexagon (6 sided)"));
666 menu.Append(wxID_ANY, wxT("Heptagon (7 sided)"));
667 menu.Append(wxID_ANY, wxT("Octogon (8 sided)"));
668 menu.Append(wxID_ANY, wxT("Nonagon (9 sided)"));
669 menu.Append(wxID_ANY, wxT("Decagon (10 sided)"));
670
671 evt.PopupMenu(&menu);
672 }
673
674 void MyFrame::OnJustify(wxRibbonToolBarEvent& evt)
675 {
676 long style = m_logwindow->GetWindowStyle() &
677 ~(wxTE_LEFT | wxTE_CENTER | wxTE_RIGHT);
678 switch(evt.GetId())
679 {
680 case wxID_JUSTIFY_LEFT:
681 m_logwindow->SetWindowStyle(style | wxTE_LEFT);
682 break;
683 case wxID_JUSTIFY_CENTER:
684 m_logwindow->SetWindowStyle(style | wxTE_CENTER);
685 break;
686 case wxID_JUSTIFY_RIGHT:
687 m_logwindow->SetWindowStyle(style | wxTE_RIGHT);
688 break;
689 }
690 }
691
692 void MyFrame::OnJustifyUpdateUI(wxUpdateUIEvent& evt)
693 {
694 switch(evt.GetId())
695 {
696 case wxID_JUSTIFY_LEFT:
697 evt.Check(!m_logwindow->HasFlag(wxTE_CENTER | wxTE_RIGHT));
698 break;
699 case wxID_JUSTIFY_CENTER:
700 evt.Check(m_logwindow->HasFlag(wxTE_CENTER));
701 break;
702 case wxID_JUSTIFY_RIGHT:
703 evt.Check(m_logwindow->HasFlag(wxTE_RIGHT));
704 break;
705 }
706 }
707
708 void MyFrame::OnNew(wxRibbonToolBarEvent& WXUNUSED(evt))
709 {
710 AddText(wxT("New button clicked."));
711 }
712
713 void MyFrame::OnNewDropdown(wxRibbonToolBarEvent& evt)
714 {
715 wxMenu menu;
716 menu.Append(wxID_ANY, wxT("New Document"));
717 menu.Append(wxID_ANY, wxT("New Template"));
718 menu.Append(wxID_ANY, wxT("New Mail"));
719
720 evt.PopupMenu(&menu);
721 }
722
723 void MyFrame::OnPrint(wxRibbonToolBarEvent& WXUNUSED(evt))
724 {
725 AddText(wxT("Print button clicked."));
726 }
727
728 void MyFrame::OnPrintDropdown(wxRibbonToolBarEvent& evt)
729 {
730 wxMenu menu;
731 menu.Append(wxID_ANY, wxT("Print"));
732 menu.Append(wxID_ANY, wxT("Preview"));
733 menu.Append(wxID_ANY, wxT("Options"));
734
735 evt.PopupMenu(&menu);
736 }
737
738 void MyFrame::OnRedoDropdown(wxRibbonToolBarEvent& evt)
739 {
740 wxMenu menu;
741 menu.Append(wxID_ANY, wxT("Redo E"));
742 menu.Append(wxID_ANY, wxT("Redo F"));
743 menu.Append(wxID_ANY, wxT("Redo G"));
744
745 evt.PopupMenu(&menu);
746 }
747
748 void MyFrame::OnUndoDropdown(wxRibbonToolBarEvent& evt)
749 {
750 wxMenu menu;
751 menu.Append(wxID_ANY, wxT("Undo C"));
752 menu.Append(wxID_ANY, wxT("Undo B"));
753 menu.Append(wxID_ANY, wxT("Undo A"));
754
755 evt.PopupMenu(&menu);
756 }
757
758 void MyFrame::OnPositionTopLabels(wxCommandEvent& WXUNUSED(evt))
759 {
760 SetBarStyle(wxRIBBON_BAR_DEFAULT_STYLE);
761 }
762
763 void MyFrame::OnPositionTopIcons(wxCommandEvent& WXUNUSED(evt))
764 {
765 SetBarStyle((wxRIBBON_BAR_DEFAULT_STYLE &~wxRIBBON_BAR_SHOW_PAGE_LABELS)
766 | wxRIBBON_BAR_SHOW_PAGE_ICONS);
767 }
768
769 void MyFrame::OnPositionTopBoth(wxCommandEvent& WXUNUSED(evt))
770 {
771 SetBarStyle(wxRIBBON_BAR_DEFAULT_STYLE | wxRIBBON_BAR_SHOW_PAGE_ICONS);
772 }
773
774 void MyFrame::OnPositionLeftLabels(wxCommandEvent& WXUNUSED(evt))
775 {
776 SetBarStyle(wxRIBBON_BAR_DEFAULT_STYLE | wxRIBBON_BAR_FLOW_VERTICAL);
777 }
778
779 void MyFrame::OnPositionLeftIcons(wxCommandEvent& WXUNUSED(evt))
780 {
781 SetBarStyle((wxRIBBON_BAR_DEFAULT_STYLE &~wxRIBBON_BAR_SHOW_PAGE_LABELS) |
782 wxRIBBON_BAR_SHOW_PAGE_ICONS | wxRIBBON_BAR_FLOW_VERTICAL);
783 }
784
785 void MyFrame::OnPositionLeftBoth(wxCommandEvent& WXUNUSED(evt))
786 {
787 SetBarStyle(wxRIBBON_BAR_DEFAULT_STYLE | wxRIBBON_BAR_SHOW_PAGE_ICONS |
788 wxRIBBON_BAR_FLOW_VERTICAL);
789 }
790
791 void MyFrame::OnPositionTop(wxRibbonToolBarEvent& evt)
792 {
793 OnPositionTopLabels(evt);
794 }
795
796 void MyFrame::OnPositionTopDropdown(wxRibbonToolBarEvent& evt)
797 {
798 wxMenu menu;
799 menu.Append(ID_POSITION_TOP, wxT("Top with Labels"));
800 menu.Append(ID_POSITION_TOP_ICONS, wxT("Top with Icons"));
801 menu.Append(ID_POSITION_TOP_BOTH, wxT("Top with Both"));
802 evt.PopupMenu(&menu);
803 }
804
805 void MyFrame::OnPositionLeft(wxRibbonToolBarEvent& evt)
806 {
807 OnPositionLeftIcons(evt);
808 }
809
810 void MyFrame::OnPositionLeftDropdown(wxRibbonToolBarEvent& evt)
811 {
812 wxMenu menu;
813 menu.Append(ID_POSITION_LEFT, wxT("Left with Icons"));
814 menu.Append(ID_POSITION_LEFT_LABELS, wxT("Left with Labels"));
815 menu.Append(ID_POSITION_LEFT_BOTH, wxT("Left with Both"));
816 evt.PopupMenu(&menu);
817 }
818
819 void MyFrame::OnTogglePanels(wxCommandEvent& WXUNUSED(evt))
820 {
821 m_ribbon->ShowPanels(m_togglePanels->GetValue());
822 }
823
824 void MyFrame::AddText(wxString msg)
825 {
826 m_logwindow->AppendText(msg);
827 m_logwindow->AppendText(wxT("\n"));
828 m_ribbon->DismissExpandedPanel();
829 }
830
831 wxRibbonGalleryItem* MyFrame::AddColourToGallery(wxRibbonGallery *gallery,
832 wxString colour, wxMemoryDC& dc,
833 wxColour* value)
834 {
835 wxRibbonGalleryItem* item = NULL;
836 wxColour c;
837 if (colour != wxT("Default"))
838 c = wxColour(colour);
839 if (!c.IsOk())
840 c = *value;
841 if(c.IsOk())
842 {
843 const int iWidth = 64;
844 const int iHeight = 40;
845
846 wxBitmap bitmap(iWidth, iHeight);
847 dc.SelectObject(bitmap);
848 wxBrush b(c);
849 dc.SetPen(*wxBLACK_PEN);
850 dc.SetBrush(b);
851 dc.DrawRectangle(0, 0, iWidth, iHeight);
852
853 colour = colour.Mid(0, 1) + colour.Mid(1).Lower();
854 wxSize size = dc.GetTextExtent(colour);
855 wxColour foreground = wxColour(~c.Red(), ~c.Green(), ~c.Blue());
856 if(abs(foreground.Red() - c.Red()) + abs(foreground.Blue() - c.Blue())
857 + abs(foreground.Green() - c.Green()) < 64)
858 {
859 // Foreground too similar to background - use a different
860 // strategy to find a contrasting colour
861 foreground = wxColour((c.Red() + 64) % 256, 255 - c.Green(),
862 (c.Blue() + 192) % 256);
863 }
864 dc.SetTextForeground(foreground);
865 dc.DrawText(colour, (iWidth - size.GetWidth() + 1) / 2,
866 (iHeight - size.GetHeight()) / 2);
867 dc.SelectObjectAsSource(wxNullBitmap);
868
869 item = gallery->Append(bitmap, wxID_ANY);
870 gallery->SetItemClientObject(item, new ColourClientData(colour, c));
871 }
872 return item;
873 }
874
875 void MyFrame::OnColourGalleryButton(wxCommandEvent& evt)
876 {
877 wxRibbonGallery *gallery = wxDynamicCast(evt.GetEventObject(), wxRibbonGallery);
878 if(gallery == NULL)
879 return;
880
881 m_ribbon->DismissExpandedPanel();
882 if(gallery->GetSelection())
883 m_colour_data.SetColour(GetGalleryColour(gallery, gallery->GetSelection(), NULL));
884 wxColourDialog dlg(this, &m_colour_data);
885 if(dlg.ShowModal() == wxID_OK)
886 {
887 m_colour_data = dlg.GetColourData();
888 wxColour clr = m_colour_data.GetColour();
889
890 // Try to find colour in gallery
891 wxRibbonGalleryItem *item = NULL;
892 for(unsigned int i = 0; i < gallery->GetCount(); ++i)
893 {
894 item = gallery->GetItem(i);
895 if(GetGalleryColour(gallery, item, NULL) == clr)
896 break;
897 else
898 item = NULL;
899 }
900
901 // Colour not in gallery - add it
902 if(item == NULL)
903 {
904 item = AddColourToGallery(gallery,
905 clr.GetAsString(wxC2S_HTML_SYNTAX), m_bitmap_creation_dc,
906 &clr);
907 gallery->Realise();
908 }
909
910 // Set selection
911 gallery->EnsureVisible(item);
912 gallery->SetSelection(item);
913
914 // Send an event to respond to the selection change
915 wxRibbonGalleryEvent dummy(wxEVT_COMMAND_RIBBONGALLERY_SELECTED, gallery->GetId());
916 dummy.SetEventObject(gallery);
917 dummy.SetGallery(gallery);
918 dummy.SetGalleryItem(item);
919 ProcessWindowEvent(dummy);
920 }
921 }
922
923 void MyFrame::OnDefaultProvider(wxRibbonButtonBarEvent& WXUNUSED(evt))
924 {
925 m_ribbon->DismissExpandedPanel();
926 SetArtProvider(new wxRibbonDefaultArtProvider);
927 }
928
929 void MyFrame::OnAUIProvider(wxRibbonButtonBarEvent& WXUNUSED(evt))
930 {
931 m_ribbon->DismissExpandedPanel();
932 SetArtProvider(new wxRibbonAUIArtProvider);
933 }
934
935 void MyFrame::OnMSWProvider(wxRibbonButtonBarEvent& WXUNUSED(evt))
936 {
937 m_ribbon->DismissExpandedPanel();
938 SetArtProvider(new wxRibbonMSWArtProvider);
939 }
940
941 void MyFrame::SetArtProvider(wxRibbonArtProvider *prov)
942 {
943 m_ribbon->Freeze();
944 m_ribbon->SetArtProvider(prov);
945
946 prov->GetColourScheme(&m_default_primary, &m_default_secondary,
947 &m_default_tertiary);
948 PopulateColoursPanel(m_primary_gallery->GetParent(), m_default_primary,
949 ID_PRIMARY_COLOUR);
950 PopulateColoursPanel(m_secondary_gallery->GetParent(), m_default_secondary,
951 ID_SECONDARY_COLOUR);
952
953 m_ribbon->Realize();
954 m_ribbon->Thaw();
955 GetSizer()->Layout();
956 }