1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: ribbondemo.cpp
3 // Purpose: wxRibbon: Ribbon user interface - sample/test program
4 // Author: Peter Cawley
7 // Copyright: (C) Copyright 2009, Peter Cawley
8 // Licence: wxWindows Library Licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #include "wx/wxprec.h"
19 #include "wx/textctrl.h"
20 #include "wx/ribbon/bar.h"
21 #include "wx/ribbon/buttonbar.h"
22 #include "wx/ribbon/gallery.h"
23 #include "wx/ribbon/toolbar.h"
26 #include "wx/msgdlg.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"
36 class MyApp
: public wxApp
47 class MyFrame
: public wxFrame
55 ID_CIRCLE
= wxID_HIGHEST
+ 1,
60 ID_SELECTION_EXPAND_H
,
61 ID_SELECTION_EXPAND_V
,
62 ID_SELECTION_CONTRACT
,
70 ID_POSITION_TOP_ICONS
,
73 ID_POSITION_LEFT_LABELS
,
74 ID_POSITION_LEFT_BOTH
,
84 ID_UI_CHANGE_TEXT_UPDATED
,
90 void OnEnableUpdateUI(wxUpdateUIEvent
& evt
);
91 void OnCheckUpdateUI(wxUpdateUIEvent
& evt
);
92 void OnChangeTextUpdateUI(wxUpdateUIEvent
& evt
);
93 void OnCheck(wxRibbonButtonBarEvent
& evt
);
94 void OnEnable(wxRibbonButtonBarEvent
& evt
);
95 void OnDisable(wxRibbonButtonBarEvent
& evt
);
96 void OnDisabled(wxRibbonButtonBarEvent
& evt
);
97 void OnEnableUpdated(wxRibbonButtonBarEvent
& evt
);
98 void OnChangeText1(wxRibbonButtonBarEvent
& evt
);
99 void OnChangeText2(wxRibbonButtonBarEvent
& evt
);
100 void OnCircleButton(wxRibbonButtonBarEvent
& evt
);
101 void OnCrossButton(wxRibbonButtonBarEvent
& evt
);
102 void OnTriangleButton(wxRibbonButtonBarEvent
& evt
);
103 void OnTriangleDropdown(wxRibbonButtonBarEvent
& evt
);
104 void OnSquareButton(wxRibbonButtonBarEvent
& evt
);
105 void OnPolygonDropdown(wxRibbonButtonBarEvent
& evt
);
106 void OnSelectionExpandVButton(wxRibbonButtonBarEvent
& evt
);
107 void OnSelectionExpandHButton(wxRibbonButtonBarEvent
& evt
);
108 void OnSelectionContractButton(wxRibbonButtonBarEvent
& evt
);
109 void OnHoveredColourChange(wxRibbonGalleryEvent
& evt
);
110 void OnPrimaryColourSelect(wxRibbonGalleryEvent
& evt
);
111 void OnSecondaryColourSelect(wxRibbonGalleryEvent
& evt
);
112 void OnColourGalleryButton(wxCommandEvent
& evt
);
113 void OnDefaultProvider(wxRibbonButtonBarEvent
& evt
);
114 void OnAUIProvider(wxRibbonButtonBarEvent
& evt
);
115 void OnMSWProvider(wxRibbonButtonBarEvent
& evt
);
116 void OnJustify(wxRibbonToolBarEvent
& evt
);
117 void OnJustifyUpdateUI(wxUpdateUIEvent
& evt
);
118 void OnNew(wxRibbonToolBarEvent
& evt
);
119 void OnNewDropdown(wxRibbonToolBarEvent
& evt
);
120 void OnPrint(wxRibbonToolBarEvent
& evt
);
121 void OnPrintDropdown(wxRibbonToolBarEvent
& evt
);
122 void OnRedoDropdown(wxRibbonToolBarEvent
& evt
);
123 void OnUndoDropdown(wxRibbonToolBarEvent
& evt
);
124 void OnPositionTop(wxRibbonToolBarEvent
& evt
);
125 void OnPositionTopLabels(wxCommandEvent
& evt
);
126 void OnPositionTopIcons(wxCommandEvent
& evt
);
127 void OnPositionTopBoth(wxCommandEvent
& evt
);
128 void OnPositionTopDropdown(wxRibbonToolBarEvent
& evt
);
129 void OnPositionLeft(wxRibbonToolBarEvent
& evt
);
130 void OnPositionLeftLabels(wxCommandEvent
& evt
);
131 void OnPositionLeftIcons(wxCommandEvent
& evt
);
132 void OnPositionLeftBoth(wxCommandEvent
& evt
);
133 void OnPositionLeftDropdown(wxRibbonToolBarEvent
& evt
);
134 void OnRemovePage(wxRibbonButtonBarEvent
& evt
);
135 void OnHidePages(wxRibbonButtonBarEvent
& evt
);
136 void OnShowPages(wxRibbonButtonBarEvent
& evt
);
137 void OnTogglePanels(wxCommandEvent
& evt
);
138 void OnRibbonBarToggled(wxRibbonBarEvent
& evt
);
139 void OnRibbonBarHelpClicked(wxRibbonBarEvent
& evt
);
141 void OnSizeEvent(wxSizeEvent
& evt
);
143 void OnExtButton(wxRibbonPanelEvent
& evt
);
146 wxRibbonGallery
* PopulateColoursPanel(wxWindow
* panel
, wxColour def
,
148 void AddText(wxString msg
);
149 wxRibbonGalleryItem
* AddColourToGallery(wxRibbonGallery
*gallery
,
150 wxString name
, wxMemoryDC
& dc
, wxColour
* value
= NULL
);
151 wxColour
GetGalleryColour(wxRibbonGallery
*gallery
,
152 wxRibbonGalleryItem
* item
, wxString
* name
);
153 void ResetGalleryArtProviders();
154 void SetArtProvider(wxRibbonArtProvider
* prov
);
155 void SetBarStyle(long style
);
157 wxRibbonBar
* m_ribbon
;
158 wxRibbonGallery
* m_primary_gallery
;
159 wxRibbonGallery
* m_secondary_gallery
;
160 wxTextCtrl
* m_logwindow
;
161 wxToggleButton
* m_togglePanels
;
163 wxColourData m_colour_data
;
164 wxColour m_default_primary
;
165 wxColour m_default_secondary
;
166 wxColour m_default_tertiary
;
167 wxMemoryDC m_bitmap_creation_dc
;
172 DECLARE_EVENT_TABLE()
175 // -- implementations --
182 wxFrame
* frame
= new MyFrame
;
188 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
189 EVT_RIBBONBUTTONBAR_CLICKED(ID_ENABLE
, MyFrame::OnEnable
)
190 EVT_RIBBONBUTTONBAR_CLICKED(ID_DISABLE
, MyFrame::OnDisable
)
191 EVT_RIBBONBUTTONBAR_CLICKED(ID_DISABLED
, MyFrame::OnDisabled
)
192 EVT_RIBBONBUTTONBAR_CLICKED(ID_UI_ENABLE_UPDATED
, MyFrame::OnEnableUpdated
)
193 EVT_UPDATE_UI(ID_UI_ENABLE_UPDATED
, MyFrame::OnEnableUpdateUI
)
194 EVT_RIBBONBUTTONBAR_CLICKED(ID_CHECK
, MyFrame::OnCheck
)
195 EVT_UPDATE_UI(ID_UI_CHECK_UPDATED
, MyFrame::OnCheckUpdateUI
)
196 EVT_RIBBONBUTTONBAR_CLICKED(ID_CHANGE_TEXT1
, MyFrame::OnChangeText1
)
197 EVT_RIBBONBUTTONBAR_CLICKED(ID_CHANGE_TEXT2
, MyFrame::OnChangeText2
)
198 EVT_UPDATE_UI(ID_UI_CHANGE_TEXT_UPDATED
, MyFrame::OnChangeTextUpdateUI
)
199 EVT_RIBBONBUTTONBAR_CLICKED(ID_DEFAULT_PROVIDER
, MyFrame::OnDefaultProvider
)
200 EVT_RIBBONBUTTONBAR_CLICKED(ID_AUI_PROVIDER
, MyFrame::OnAUIProvider
)
201 EVT_RIBBONBUTTONBAR_CLICKED(ID_MSW_PROVIDER
, MyFrame::OnMSWProvider
)
202 EVT_RIBBONBUTTONBAR_CLICKED(ID_SELECTION_EXPAND_H
, MyFrame::OnSelectionExpandHButton
)
203 EVT_RIBBONBUTTONBAR_CLICKED(ID_SELECTION_EXPAND_V
, MyFrame::OnSelectionExpandVButton
)
204 EVT_RIBBONBUTTONBAR_CLICKED(ID_SELECTION_CONTRACT
, MyFrame::OnSelectionContractButton
)
205 EVT_RIBBONBUTTONBAR_CLICKED(ID_CIRCLE
, MyFrame::OnCircleButton
)
206 EVT_RIBBONBUTTONBAR_CLICKED(ID_CROSS
, MyFrame::OnCrossButton
)
207 EVT_RIBBONBUTTONBAR_CLICKED(ID_TRIANGLE
, MyFrame::OnTriangleButton
)
208 EVT_RIBBONBUTTONBAR_CLICKED(ID_SQUARE
, MyFrame::OnSquareButton
)
209 EVT_RIBBONBUTTONBAR_DROPDOWN_CLICKED(ID_TRIANGLE
, MyFrame::OnTriangleDropdown
)
210 EVT_RIBBONBUTTONBAR_DROPDOWN_CLICKED(ID_POLYGON
, MyFrame::OnPolygonDropdown
)
211 EVT_RIBBONGALLERY_HOVER_CHANGED(ID_PRIMARY_COLOUR
, MyFrame::OnHoveredColourChange
)
212 EVT_RIBBONGALLERY_HOVER_CHANGED(ID_SECONDARY_COLOUR
, MyFrame::OnHoveredColourChange
)
213 EVT_RIBBONGALLERY_SELECTED(ID_PRIMARY_COLOUR
, MyFrame::OnPrimaryColourSelect
)
214 EVT_RIBBONGALLERY_SELECTED(ID_SECONDARY_COLOUR
, MyFrame::OnSecondaryColourSelect
)
215 EVT_RIBBONTOOLBAR_CLICKED(wxID_JUSTIFY_LEFT
, MyFrame::OnJustify
)
216 EVT_RIBBONTOOLBAR_CLICKED(wxID_JUSTIFY_CENTER
, MyFrame::OnJustify
)
217 EVT_RIBBONTOOLBAR_CLICKED(wxID_JUSTIFY_RIGHT
, MyFrame::OnJustify
)
218 EVT_UPDATE_UI(wxID_JUSTIFY_LEFT
, MyFrame::OnJustifyUpdateUI
)
219 EVT_UPDATE_UI(wxID_JUSTIFY_CENTER
, MyFrame::OnJustifyUpdateUI
)
220 EVT_UPDATE_UI(wxID_JUSTIFY_RIGHT
, MyFrame::OnJustifyUpdateUI
)
221 EVT_RIBBONTOOLBAR_CLICKED(wxID_NEW
, MyFrame::OnNew
)
222 EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(wxID_NEW
, MyFrame::OnNewDropdown
)
223 EVT_RIBBONTOOLBAR_CLICKED(wxID_PRINT
, MyFrame::OnPrint
)
224 EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(wxID_PRINT
, MyFrame::OnPrintDropdown
)
225 EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(wxID_REDO
, MyFrame::OnRedoDropdown
)
226 EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(wxID_UNDO
, MyFrame::OnUndoDropdown
)
227 EVT_RIBBONTOOLBAR_CLICKED(ID_POSITION_LEFT
, MyFrame::OnPositionLeft
)
228 EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(ID_POSITION_LEFT
, MyFrame::OnPositionLeftDropdown
)
229 EVT_RIBBONTOOLBAR_CLICKED(ID_POSITION_TOP
, MyFrame::OnPositionTop
)
230 EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(ID_POSITION_TOP
, MyFrame::OnPositionTopDropdown
)
231 EVT_BUTTON(ID_PRIMARY_COLOUR
, MyFrame::OnColourGalleryButton
)
232 EVT_BUTTON(ID_SECONDARY_COLOUR
, MyFrame::OnColourGalleryButton
)
233 EVT_MENU(ID_POSITION_LEFT
, MyFrame::OnPositionLeftIcons
)
234 EVT_MENU(ID_POSITION_LEFT_LABELS
, MyFrame::OnPositionLeftLabels
)
235 EVT_MENU(ID_POSITION_LEFT_BOTH
, MyFrame::OnPositionLeftBoth
)
236 EVT_MENU(ID_POSITION_TOP
, MyFrame::OnPositionTopLabels
)
237 EVT_MENU(ID_POSITION_TOP_ICONS
, MyFrame::OnPositionTopIcons
)
238 EVT_MENU(ID_POSITION_TOP_BOTH
, MyFrame::OnPositionTopBoth
)
239 EVT_TOGGLEBUTTON(ID_TOGGLE_PANELS
, MyFrame::OnTogglePanels
)
240 EVT_RIBBONPANEL_EXTBUTTON_ACTIVATED(wxID_ANY
, MyFrame::OnExtButton
)
241 EVT_RIBBONBUTTONBAR_CLICKED(ID_REMOVE_PAGE
, MyFrame::OnRemovePage
)
242 EVT_RIBBONBUTTONBAR_CLICKED(ID_HIDE_PAGES
, MyFrame::OnHidePages
)
243 EVT_RIBBONBUTTONBAR_CLICKED(ID_SHOW_PAGES
, MyFrame::OnShowPages
)
244 EVT_RIBBONBAR_TOGGLED(wxID_ANY
, MyFrame::OnRibbonBarToggled
)
245 EVT_RIBBONBAR_HELP_CLICK(wxID_ANY
, MyFrame::OnRibbonBarHelpClicked
)
246 EVT_SIZE(MyFrame::OnSizeEvent
)
249 #include "align_center.xpm"
250 #include "align_left.xpm"
251 #include "align_right.xpm"
252 #include "aui_style.xpm"
253 #include "auto_crop_selection.xpm"
254 #include "auto_crop_selection_small.xpm"
255 #include "circle.xpm"
256 #include "circle_small.xpm"
257 #include "colours.xpm"
260 #include "expand_selection_v.xpm"
261 #include "expand_selection_h.xpm"
263 #include "hexagon.xpm"
264 #include "msw_style.xpm"
265 #include "position_left_small.xpm"
266 #include "position_top_small.xpm"
267 #include "ribbon.xpm"
268 #include "selection_panel.xpm"
269 #include "square.xpm"
270 #include "triangle.xpm"
273 : wxFrame(NULL
, wxID_ANY
, wxT("wxRibbon Sample Application"), wxDefaultPosition
, wxSize(800, 600), wxDEFAULT_FRAME_STYLE
)
275 m_ribbon
= new wxRibbonBar(this,-1,wxDefaultPosition
, wxDefaultSize
, wxRIBBON_BAR_FLOW_HORIZONTAL
276 | wxRIBBON_BAR_SHOW_PAGE_LABELS
277 | wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS
278 | wxRIBBON_BAR_SHOW_TOGGLE_BUTTON
279 | wxRIBBON_BAR_SHOW_HELP_BUTTON
283 wxRibbonPage
* home
= new wxRibbonPage(m_ribbon
, wxID_ANY
, wxT("Examples"), ribbon_xpm
);
284 wxRibbonPanel
*toolbar_panel
= new wxRibbonPanel(home
, wxID_ANY
, wxT("Toolbar"),
285 wxNullBitmap
, wxDefaultPosition
, wxDefaultSize
,
286 wxRIBBON_PANEL_NO_AUTO_MINIMISE
|
287 wxRIBBON_PANEL_EXT_BUTTON
);
288 wxRibbonToolBar
*toolbar
= new wxRibbonToolBar(toolbar_panel
, ID_MAIN_TOOLBAR
);
289 toolbar
->AddToggleTool(wxID_JUSTIFY_LEFT
, align_left_xpm
);
290 toolbar
->AddToggleTool(wxID_JUSTIFY_CENTER
, align_center_xpm
);
291 toolbar
->AddToggleTool(wxID_JUSTIFY_RIGHT
, align_right_xpm
);
292 toolbar
->AddSeparator();
293 toolbar
->AddHybridTool(wxID_NEW
, wxArtProvider::GetBitmap(wxART_NEW
, wxART_OTHER
, wxSize(16, 15)));
294 toolbar
->AddTool(wxID_OPEN
, wxArtProvider::GetBitmap(wxART_FILE_OPEN
, wxART_OTHER
, wxSize(16, 15)), "Open something");
295 toolbar
->AddTool(wxID_SAVE
, wxArtProvider::GetBitmap(wxART_FILE_SAVE
, wxART_OTHER
, wxSize(16, 15)), "Save something");
296 toolbar
->AddTool(wxID_SAVEAS
, wxArtProvider::GetBitmap(wxART_FILE_SAVE_AS
, wxART_OTHER
, wxSize(16, 15)), "Save something as ...");
297 toolbar
->EnableTool(wxID_OPEN
, false);
298 toolbar
->EnableTool(wxID_SAVE
, false);
299 toolbar
->EnableTool(wxID_SAVEAS
, false);
300 toolbar
->AddSeparator();
301 toolbar
->AddDropdownTool(wxID_UNDO
, wxArtProvider::GetBitmap(wxART_UNDO
, wxART_OTHER
, wxSize(16, 15)));
302 toolbar
->AddDropdownTool(wxID_REDO
, wxArtProvider::GetBitmap(wxART_REDO
, wxART_OTHER
, wxSize(16, 15)));
303 toolbar
->AddSeparator();
304 toolbar
->AddTool(wxID_ANY
, wxArtProvider::GetBitmap(wxART_REPORT_VIEW
, wxART_OTHER
, wxSize(16, 15)));
305 toolbar
->AddTool(wxID_ANY
, wxArtProvider::GetBitmap(wxART_LIST_VIEW
, wxART_OTHER
, wxSize(16, 15)));
306 toolbar
->AddSeparator();
307 toolbar
->AddHybridTool(ID_POSITION_LEFT
, position_left_xpm
,
308 "Align ribbonbar vertically\non the left\nfor demonstration purposes");
309 toolbar
->AddHybridTool(ID_POSITION_TOP
, position_top_xpm
,
310 "Align the ribbonbar horizontally\nat the top\nfor demonstration purposes");
311 toolbar
->AddSeparator();
312 toolbar
->AddHybridTool(wxID_PRINT
, wxArtProvider::GetBitmap(wxART_PRINT
, wxART_OTHER
, wxSize(16, 15)),
313 "This is the Print button tooltip\ndemonstrating a tooltip");
314 toolbar
->SetRows(2, 3);
316 wxRibbonPanel
*selection_panel
= new wxRibbonPanel(home
, wxID_ANY
, wxT("Selection"), wxBitmap(selection_panel_xpm
));
317 wxRibbonButtonBar
*selection
= new wxRibbonButtonBar(selection_panel
);
318 selection
->AddButton(ID_SELECTION_EXPAND_V
, wxT("Expand Vertically"), wxBitmap(expand_selection_v_xpm
),
319 "This is a tooltip for Expand Vertically\ndemonstrating a tooltip");
320 selection
->AddButton(ID_SELECTION_EXPAND_H
, wxT("Expand Horizontally"), wxBitmap(expand_selection_h_xpm
), wxEmptyString
);
321 selection
->AddButton(ID_SELECTION_CONTRACT
, wxT("Contract"), wxBitmap(auto_crop_selection_xpm
), wxBitmap(auto_crop_selection_small_xpm
));
323 wxRibbonPanel
*shapes_panel
= new wxRibbonPanel(home
, wxID_ANY
, wxT("Shapes"), wxBitmap(circle_small_xpm
));
324 wxRibbonButtonBar
*shapes
= new wxRibbonButtonBar(shapes_panel
);
325 shapes
->AddButton(ID_CIRCLE
, wxT("Circle"), wxBitmap(circle_xpm
), wxBitmap(circle_small_xpm
),
326 wxNullBitmap
, wxNullBitmap
, wxRIBBON_BUTTON_NORMAL
,
327 "This is a tooltip for the circle button\ndemonstrating another tooltip");
328 shapes
->AddButton(ID_CROSS
, wxT("Cross"), wxBitmap(cross_xpm
), wxEmptyString
);
329 shapes
->AddHybridButton(ID_TRIANGLE
, wxT("Triangle"), wxBitmap(triangle_xpm
));
330 shapes
->AddButton(ID_SQUARE
, wxT("Square"), wxBitmap(square_xpm
), wxEmptyString
);
331 shapes
->AddDropdownButton(ID_POLYGON
, wxT("Other Polygon"), wxBitmap(hexagon_xpm
), wxEmptyString
);
333 wxRibbonPanel
*sizer_panel
= new wxRibbonPanel(home
, wxID_ANY
, wxT("Panel with Sizer"),
334 wxNullBitmap
, wxDefaultPosition
, wxDefaultSize
,
335 wxRIBBON_PANEL_DEFAULT_STYLE
);
338 as
.Add("Item 1 using a box sizer now");
339 as
.Add("Item 2 using a box sizer now");
340 wxComboBox
* sizer_panelcombo
= new wxComboBox(sizer_panel
, wxID_ANY
,
342 wxDefaultPosition
, wxDefaultSize
,
345 wxComboBox
* sizer_panelcombo2
= new wxComboBox(sizer_panel
, wxID_ANY
,
347 wxDefaultPosition
, wxDefaultSize
,
350 sizer_panelcombo
->Select(0);
351 sizer_panelcombo2
->Select(1);
352 sizer_panelcombo
->SetMinSize(wxSize(150, -1));
353 sizer_panelcombo2
->SetMinSize(wxSize(150, -1));
355 //not using wxWrapSizer(wxHORIZONTAL) as it reports an incorrect min height
356 wxSizer
* sizer_panelsizer
= new wxBoxSizer(wxVERTICAL
);
357 sizer_panelsizer
->AddStretchSpacer(1);
358 sizer_panelsizer
->Add(sizer_panelcombo
, 0, wxALL
|wxEXPAND
, 2);
359 sizer_panelsizer
->Add(sizer_panelcombo2
, 0, wxALL
|wxEXPAND
, 2);
360 sizer_panelsizer
->AddStretchSpacer(1);
361 sizer_panel
->SetSizer(sizer_panelsizer
);
363 wxFont
label_font(8, wxFONTFAMILY_DEFAULT
, wxFONTSTYLE_NORMAL
, wxFONTWEIGHT_LIGHT
);
364 m_bitmap_creation_dc
.SetFont(label_font
);
366 wxRibbonPage
* scheme
= new wxRibbonPage(m_ribbon
, wxID_ANY
, wxT("Appearance"), eye_xpm
);
367 m_ribbon
->GetArtProvider()->GetColourScheme(&m_default_primary
,
368 &m_default_secondary
, &m_default_tertiary
);
369 wxRibbonPanel
*provider_panel
= new wxRibbonPanel(scheme
, wxID_ANY
,
370 wxT("Art"), wxNullBitmap
, wxDefaultPosition
, wxDefaultSize
, wxRIBBON_PANEL_NO_AUTO_MINIMISE
);
371 wxRibbonButtonBar
*provider_bar
= new wxRibbonButtonBar(provider_panel
, wxID_ANY
);
372 provider_bar
->AddButton(ID_DEFAULT_PROVIDER
, wxT("Default Provider"),
373 wxArtProvider::GetBitmap(wxART_QUESTION
, wxART_OTHER
, wxSize(32, 32)));
374 provider_bar
->AddButton(ID_AUI_PROVIDER
, wxT("AUI Provider"), aui_style_xpm
);
375 provider_bar
->AddButton(ID_MSW_PROVIDER
, wxT("MSW Provider"), msw_style_xpm
);
376 wxRibbonPanel
*primary_panel
= new wxRibbonPanel(scheme
, wxID_ANY
,
377 wxT("Primary Colour"), colours_xpm
);
378 m_primary_gallery
= PopulateColoursPanel(primary_panel
,
379 m_default_primary
, ID_PRIMARY_COLOUR
);
380 wxRibbonPanel
*secondary_panel
= new wxRibbonPanel(scheme
, wxID_ANY
,
381 wxT("Secondary Colour"), colours_xpm
);
382 m_secondary_gallery
= PopulateColoursPanel(secondary_panel
,
383 m_default_secondary
, ID_SECONDARY_COLOUR
);
386 wxRibbonPage
* page
= new wxRibbonPage(m_ribbon
, wxID_ANY
, wxT("UI Updated"), ribbon_xpm
);
387 wxRibbonPanel
*panel
= new wxRibbonPanel(page
, wxID_ANY
, wxT("Enable/Disable"), ribbon_xpm
);
388 wxRibbonButtonBar
*bar
= new wxRibbonButtonBar(panel
, wxID_ANY
);
389 bar
->AddButton(ID_DISABLED
, wxT("Disabled"), ribbon_xpm
);
390 bar
->AddButton(ID_ENABLE
, wxT("Enable"), ribbon_xpm
);
391 bar
->AddButton(ID_DISABLE
, wxT("Disable"), ribbon_xpm
);
392 bar
->AddButton(ID_UI_ENABLE_UPDATED
, wxT("Enable UI updated"), ribbon_xpm
);
393 bar
->EnableButton(ID_DISABLED
, false);
396 panel
= new wxRibbonPanel(page
, wxID_ANY
, wxT("Toggle"), ribbon_xpm
);
397 bar
= new wxRibbonButtonBar(panel
, wxID_ANY
);
398 bar
->AddButton(ID_CHECK
, wxT("Toggle"), ribbon_xpm
);
399 bar
->AddToggleButton(ID_UI_CHECK_UPDATED
, wxT("Toggled UI updated"), ribbon_xpm
);
402 panel
= new wxRibbonPanel(page
, wxID_ANY
, wxT("Change text"), ribbon_xpm
);
403 bar
= new wxRibbonButtonBar(panel
, wxID_ANY
);
404 bar
->AddButton(ID_CHANGE_TEXT1
, wxT("One"), ribbon_xpm
);
405 bar
->AddButton(ID_CHANGE_TEXT2
, wxT("Two"), ribbon_xpm
);
406 bar
->AddButton(ID_UI_CHANGE_TEXT_UPDATED
, wxT("Zero"), ribbon_xpm
);
408 //Also set the general disabled text colour:
409 wxRibbonArtProvider
* artProvider
= m_ribbon
->GetArtProvider();
410 wxColour tColour
= artProvider
->GetColor(wxRIBBON_ART_BUTTON_BAR_LABEL_COLOUR
);
411 artProvider
->SetColor(wxRIBBON_ART_BUTTON_BAR_LABEL_DISABLED_COLOUR
, tColour
.MakeDisabled());
413 new wxRibbonPage(m_ribbon
, wxID_ANY
, wxT("Empty Page"), empty_xpm
);
415 wxRibbonPage
* page
= new wxRibbonPage(m_ribbon
, wxID_ANY
, wxT("Another Page"), empty_xpm
);
416 wxRibbonPanel
*panel
= new wxRibbonPanel(page
, wxID_ANY
, wxT("Page manipulation"), ribbon_xpm
);
417 wxRibbonButtonBar
*bar
= new wxRibbonButtonBar(panel
, wxID_ANY
);
418 bar
->AddButton(ID_REMOVE_PAGE
, wxT("Remove"), wxArtProvider::GetBitmap(wxART_DELETE
, wxART_OTHER
, wxSize(24, 24)));
419 bar
->AddButton(ID_HIDE_PAGES
, wxT("Hide Pages"), ribbon_xpm
);
420 bar
->AddButton(ID_SHOW_PAGES
, wxT("Show Pages"), ribbon_xpm
);
422 new wxRibbonPage(m_ribbon
, wxID_ANY
, wxT("Highlight Page"), empty_xpm
);
423 m_ribbon
->AddPageHighlight(m_ribbon
->GetPageCount()-1);
427 m_logwindow
= new wxTextCtrl(this, wxID_ANY
, wxEmptyString
,
428 wxDefaultPosition
, wxDefaultSize
, wxTE_MULTILINE
| wxTE_READONLY
|
429 wxTE_LEFT
| wxTE_BESTWRAP
| wxBORDER_NONE
);
431 m_togglePanels
= new wxToggleButton(this, ID_TOGGLE_PANELS
, "&Toggle panels");
432 m_togglePanels
->SetValue(true);
434 wxSizer
*s
= new wxBoxSizer(wxVERTICAL
);
436 s
->Add(m_ribbon
, 0, wxEXPAND
);
437 s
->Add(m_logwindow
, 1, wxEXPAND
);
438 s
->Add(m_togglePanels
, wxSizerFlags().Border());
443 void MyFrame::SetBarStyle(long style
)
446 m_ribbon
->SetWindowStyleFlag(style
);
447 wxBoxSizer
*pTopSize
= reinterpret_cast<wxBoxSizer
*>(GetSizer());
448 wxRibbonToolBar
*pToolbar
= wxDynamicCast(FindWindow(ID_MAIN_TOOLBAR
), wxRibbonToolBar
);
449 if(style
& wxRIBBON_BAR_FLOW_VERTICAL
)
451 m_ribbon
->SetTabCtrlMargins(10, 10);
452 pTopSize
->SetOrientation(wxHORIZONTAL
);
454 pToolbar
->SetRows(3, 5);
458 m_ribbon
->SetTabCtrlMargins(50, 20);
459 pTopSize
->SetOrientation(wxVERTICAL
);
461 pToolbar
->SetRows(2, 3);
472 class ColourClientData
: public wxClientData
475 ColourClientData(const wxString
& name
, const wxColour
& colour
)
476 : m_name(name
), m_colour(colour
) {}
478 const wxString
& GetName() const {return m_name
;}
479 const wxColour
& GetColour() const {return m_colour
;}
486 wxRibbonGallery
* MyFrame::PopulateColoursPanel(wxWindow
* panel
,
487 wxColour def
, int gallery_id
)
489 wxRibbonGallery
*gallery
= wxDynamicCast(panel
->FindWindow(gallery_id
), wxRibbonGallery
);
493 gallery
= new wxRibbonGallery(panel
, gallery_id
);
494 wxMemoryDC
& dc
= m_bitmap_creation_dc
;
495 wxRibbonGalleryItem
*def_item
=
496 AddColourToGallery(gallery
, wxT("Default"), dc
, &def
);
497 gallery
->SetSelection(def_item
);
498 AddColourToGallery(gallery
, wxT("BLUE"), dc
);
499 AddColourToGallery(gallery
, wxT("BLUE VIOLET"), dc
);
500 AddColourToGallery(gallery
, wxT("BROWN"), dc
);
501 AddColourToGallery(gallery
, wxT("CADET BLUE"), dc
);
502 AddColourToGallery(gallery
, wxT("CORAL"), dc
);
503 AddColourToGallery(gallery
, wxT("CYAN"), dc
);
504 AddColourToGallery(gallery
, wxT("DARK GREEN"), dc
);
505 AddColourToGallery(gallery
, wxT("DARK ORCHID"), dc
);
506 AddColourToGallery(gallery
, wxT("FIREBRICK"), dc
);
507 AddColourToGallery(gallery
, wxT("GOLD"), dc
);
508 AddColourToGallery(gallery
, wxT("GOLDENROD"), dc
);
509 AddColourToGallery(gallery
, wxT("GREEN"), dc
);
510 AddColourToGallery(gallery
, wxT("INDIAN RED"), dc
);
511 AddColourToGallery(gallery
, wxT("KHAKI"), dc
);
512 AddColourToGallery(gallery
, wxT("LIGHT BLUE"), dc
);
513 AddColourToGallery(gallery
, wxT("LIME GREEN"), dc
);
514 AddColourToGallery(gallery
, wxT("MAGENTA"), dc
);
515 AddColourToGallery(gallery
, wxT("MAROON"), dc
);
516 AddColourToGallery(gallery
, wxT("NAVY"), dc
);
517 AddColourToGallery(gallery
, wxT("ORANGE"), dc
);
518 AddColourToGallery(gallery
, wxT("ORCHID"), dc
);
519 AddColourToGallery(gallery
, wxT("PINK"), dc
);
520 AddColourToGallery(gallery
, wxT("PLUM"), dc
);
521 AddColourToGallery(gallery
, wxT("PURPLE"), dc
);
522 AddColourToGallery(gallery
, wxT("RED"), dc
);
523 AddColourToGallery(gallery
, wxT("SALMON"), dc
);
524 AddColourToGallery(gallery
, wxT("SEA GREEN"), dc
);
525 AddColourToGallery(gallery
, wxT("SIENNA"), dc
);
526 AddColourToGallery(gallery
, wxT("SKY BLUE"), dc
);
527 AddColourToGallery(gallery
, wxT("TAN"), dc
);
528 AddColourToGallery(gallery
, wxT("THISTLE"), dc
);
529 AddColourToGallery(gallery
, wxT("TURQUOISE"), dc
);
530 AddColourToGallery(gallery
, wxT("VIOLET"), dc
);
531 AddColourToGallery(gallery
, wxT("VIOLET RED"), dc
);
532 AddColourToGallery(gallery
, wxT("WHEAT"), dc
);
533 AddColourToGallery(gallery
, wxT("WHITE"), dc
);
534 AddColourToGallery(gallery
, wxT("YELLOW"), dc
);
539 wxColour
MyFrame::GetGalleryColour(wxRibbonGallery
*gallery
,
540 wxRibbonGalleryItem
* item
, wxString
* name
)
542 ColourClientData
*data
= (ColourClientData
*)gallery
->GetItemClientObject(item
);
544 *name
= data
->GetName();
545 return data
->GetColour();
548 void MyFrame::OnHoveredColourChange(wxRibbonGalleryEvent
& evt
)
550 // Set the background of the gallery to the hovered colour, or back to the
551 // default if there is no longer a hovered item.
553 wxRibbonGallery
*gallery
= evt
.GetGallery();
554 wxRibbonArtProvider
*provider
= gallery
->GetArtProvider();
556 if(evt
.GetGalleryItem() != NULL
)
558 if(provider
== m_ribbon
->GetArtProvider())
560 provider
= provider
->Clone();
561 gallery
->SetArtProvider(provider
);
563 provider
->SetColour(wxRIBBON_ART_GALLERY_HOVER_BACKGROUND_COLOUR
,
564 GetGalleryColour(evt
.GetGallery(), evt
.GetGalleryItem(), NULL
));
568 if(provider
!= m_ribbon
->GetArtProvider())
570 gallery
->SetArtProvider(m_ribbon
->GetArtProvider());
576 void MyFrame::OnPrimaryColourSelect(wxRibbonGalleryEvent
& evt
)
579 wxColour colour
= GetGalleryColour(evt
.GetGallery(), evt
.GetGalleryItem(), &name
);
580 AddText(wxT("Colour \"") + name
+ wxT("\" selected as primary."));
581 wxColour secondary
, tertiary
;
582 m_ribbon
->GetArtProvider()->GetColourScheme(NULL
, &secondary
, &tertiary
);
583 m_ribbon
->GetArtProvider()->SetColourScheme(colour
, secondary
, tertiary
);
584 ResetGalleryArtProviders();
588 void MyFrame::OnSecondaryColourSelect(wxRibbonGalleryEvent
& evt
)
591 wxColour colour
= GetGalleryColour(evt
.GetGallery(), evt
.GetGalleryItem(), &name
);
592 AddText(wxT("Colour \"") + name
+ wxT("\" selected as secondary."));
593 wxColour primary
, tertiary
;
594 m_ribbon
->GetArtProvider()->GetColourScheme(&primary
, NULL
, &tertiary
);
595 m_ribbon
->GetArtProvider()->SetColourScheme(primary
, colour
, tertiary
);
596 ResetGalleryArtProviders();
600 void MyFrame::ResetGalleryArtProviders()
602 if(m_primary_gallery
->GetArtProvider() != m_ribbon
->GetArtProvider())
604 delete m_primary_gallery
->GetArtProvider();
605 m_primary_gallery
->SetArtProvider(m_ribbon
->GetArtProvider());
607 if(m_secondary_gallery
->GetArtProvider() != m_ribbon
->GetArtProvider())
609 delete m_secondary_gallery
->GetArtProvider();
610 m_secondary_gallery
->SetArtProvider(m_ribbon
->GetArtProvider());
614 void MyFrame::OnChangeText1(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
616 m_new_text
= wxT("One");
619 void MyFrame::OnChangeText2(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
621 m_new_text
= wxT("Two");
624 void MyFrame::OnEnable(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
629 void MyFrame::OnDisable(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
634 void MyFrame::OnDisabled(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
636 AddText("ERROR: Disabled button activated (not supposed to happen)");
639 void MyFrame::OnEnableUpdated(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
641 AddText("Button activated");
644 void MyFrame::OnCheck(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
646 m_bChecked
= !m_bChecked
;
649 void MyFrame::OnEnableUpdateUI(wxUpdateUIEvent
& evt
)
651 evt
.Enable(m_bEnabled
);
654 void MyFrame::OnCheckUpdateUI(wxUpdateUIEvent
& evt
)
656 evt
.Check(m_bChecked
);
659 void MyFrame::OnChangeTextUpdateUI(wxUpdateUIEvent
& evt
)
661 if ( !m_new_text
.IsEmpty() )
663 evt
.SetText(m_new_text
);
664 m_new_text
= wxT("");
668 void MyFrame::OnSelectionExpandHButton(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
670 AddText(wxT("Expand selection horizontally button clicked."));
673 void MyFrame::OnSelectionExpandVButton(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
675 AddText(wxT("Expand selection vertically button clicked."));
678 void MyFrame::OnSelectionContractButton(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
680 AddText(wxT("Contract selection button clicked."));
683 void MyFrame::OnCircleButton(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
685 AddText(wxT("Circle button clicked."));
688 void MyFrame::OnCrossButton(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
690 AddText(wxT("Cross button clicked."));
693 void MyFrame::OnTriangleButton(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
695 AddText(wxT("Triangle button clicked."));
698 void MyFrame::OnTriangleDropdown(wxRibbonButtonBarEvent
& evt
)
701 menu
.Append(wxID_ANY
, wxT("Equilateral"));
702 menu
.Append(wxID_ANY
, wxT("Isosceles"));
703 menu
.Append(wxID_ANY
, wxT("Scalene"));
705 evt
.PopupMenu(&menu
);
708 void MyFrame::OnSquareButton(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
710 AddText(wxT("Square button clicked."));
713 void MyFrame::OnPolygonDropdown(wxRibbonButtonBarEvent
& evt
)
716 menu
.Append(wxID_ANY
, wxT("Pentagon (5 sided)"));
717 menu
.Append(wxID_ANY
, wxT("Hexagon (6 sided)"));
718 menu
.Append(wxID_ANY
, wxT("Heptagon (7 sided)"));
719 menu
.Append(wxID_ANY
, wxT("Octogon (8 sided)"));
720 menu
.Append(wxID_ANY
, wxT("Nonagon (9 sided)"));
721 menu
.Append(wxID_ANY
, wxT("Decagon (10 sided)"));
723 evt
.PopupMenu(&menu
);
726 void MyFrame::OnJustify(wxRibbonToolBarEvent
& evt
)
728 long style
= m_logwindow
->GetWindowStyle() &
729 ~(wxTE_LEFT
| wxTE_CENTER
| wxTE_RIGHT
);
732 case wxID_JUSTIFY_LEFT
:
733 m_logwindow
->SetWindowStyle(style
| wxTE_LEFT
);
735 case wxID_JUSTIFY_CENTER
:
736 m_logwindow
->SetWindowStyle(style
| wxTE_CENTER
);
738 case wxID_JUSTIFY_RIGHT
:
739 m_logwindow
->SetWindowStyle(style
| wxTE_RIGHT
);
744 void MyFrame::OnJustifyUpdateUI(wxUpdateUIEvent
& evt
)
748 case wxID_JUSTIFY_LEFT
:
749 evt
.Check(!m_logwindow
->HasFlag(wxTE_CENTER
| wxTE_RIGHT
));
751 case wxID_JUSTIFY_CENTER
:
752 evt
.Check(m_logwindow
->HasFlag(wxTE_CENTER
));
754 case wxID_JUSTIFY_RIGHT
:
755 evt
.Check(m_logwindow
->HasFlag(wxTE_RIGHT
));
760 void MyFrame::OnNew(wxRibbonToolBarEvent
& WXUNUSED(evt
))
762 AddText(wxT("New button clicked."));
765 void MyFrame::OnNewDropdown(wxRibbonToolBarEvent
& evt
)
768 menu
.Append(wxID_ANY
, wxT("New Document"));
769 menu
.Append(wxID_ANY
, wxT("New Template"));
770 menu
.Append(wxID_ANY
, wxT("New Mail"));
772 evt
.PopupMenu(&menu
);
775 void MyFrame::OnPrint(wxRibbonToolBarEvent
& WXUNUSED(evt
))
777 AddText(wxT("Print button clicked."));
780 void MyFrame::OnPrintDropdown(wxRibbonToolBarEvent
& evt
)
783 menu
.Append(wxID_ANY
, wxT("Print"));
784 menu
.Append(wxID_ANY
, wxT("Preview"));
785 menu
.Append(wxID_ANY
, wxT("Options"));
787 evt
.PopupMenu(&menu
);
790 void MyFrame::OnRedoDropdown(wxRibbonToolBarEvent
& evt
)
793 menu
.Append(wxID_ANY
, wxT("Redo E"));
794 menu
.Append(wxID_ANY
, wxT("Redo F"));
795 menu
.Append(wxID_ANY
, wxT("Redo G"));
797 evt
.PopupMenu(&menu
);
800 void MyFrame::OnUndoDropdown(wxRibbonToolBarEvent
& evt
)
803 menu
.Append(wxID_ANY
, wxT("Undo C"));
804 menu
.Append(wxID_ANY
, wxT("Undo B"));
805 menu
.Append(wxID_ANY
, wxT("Undo A"));
807 evt
.PopupMenu(&menu
);
810 void MyFrame::OnPositionTopLabels(wxCommandEvent
& WXUNUSED(evt
))
812 SetBarStyle(wxRIBBON_BAR_DEFAULT_STYLE
);
815 void MyFrame::OnPositionTopIcons(wxCommandEvent
& WXUNUSED(evt
))
817 SetBarStyle((wxRIBBON_BAR_DEFAULT_STYLE
&~wxRIBBON_BAR_SHOW_PAGE_LABELS
)
818 | wxRIBBON_BAR_SHOW_PAGE_ICONS
);
821 void MyFrame::OnPositionTopBoth(wxCommandEvent
& WXUNUSED(evt
))
823 SetBarStyle(wxRIBBON_BAR_DEFAULT_STYLE
| wxRIBBON_BAR_SHOW_PAGE_ICONS
);
826 void MyFrame::OnPositionLeftLabels(wxCommandEvent
& WXUNUSED(evt
))
828 SetBarStyle(wxRIBBON_BAR_DEFAULT_STYLE
| wxRIBBON_BAR_FLOW_VERTICAL
);
831 void MyFrame::OnPositionLeftIcons(wxCommandEvent
& WXUNUSED(evt
))
833 SetBarStyle((wxRIBBON_BAR_DEFAULT_STYLE
&~wxRIBBON_BAR_SHOW_PAGE_LABELS
) |
834 wxRIBBON_BAR_SHOW_PAGE_ICONS
| wxRIBBON_BAR_FLOW_VERTICAL
);
837 void MyFrame::OnPositionLeftBoth(wxCommandEvent
& WXUNUSED(evt
))
839 SetBarStyle(wxRIBBON_BAR_DEFAULT_STYLE
| wxRIBBON_BAR_SHOW_PAGE_ICONS
|
840 wxRIBBON_BAR_FLOW_VERTICAL
);
843 void MyFrame::OnPositionTop(wxRibbonToolBarEvent
& evt
)
845 OnPositionTopLabels(evt
);
848 void MyFrame::OnPositionTopDropdown(wxRibbonToolBarEvent
& evt
)
851 menu
.Append(ID_POSITION_TOP
, wxT("Top with Labels"));
852 menu
.Append(ID_POSITION_TOP_ICONS
, wxT("Top with Icons"));
853 menu
.Append(ID_POSITION_TOP_BOTH
, wxT("Top with Both"));
854 evt
.PopupMenu(&menu
);
857 void MyFrame::OnPositionLeft(wxRibbonToolBarEvent
& evt
)
859 OnPositionLeftIcons(evt
);
862 void MyFrame::OnPositionLeftDropdown(wxRibbonToolBarEvent
& evt
)
865 menu
.Append(ID_POSITION_LEFT
, wxT("Left with Icons"));
866 menu
.Append(ID_POSITION_LEFT_LABELS
, wxT("Left with Labels"));
867 menu
.Append(ID_POSITION_LEFT_BOTH
, wxT("Left with Both"));
868 evt
.PopupMenu(&menu
);
871 void MyFrame::OnTogglePanels(wxCommandEvent
& WXUNUSED(evt
))
873 m_ribbon
->ShowPanels(m_togglePanels
->GetValue());
876 void MyFrame::OnExtButton(wxRibbonPanelEvent
& WXUNUSED(evt
))
878 wxMessageBox("Extension button clicked");
881 void MyFrame::AddText(wxString msg
)
883 m_logwindow
->AppendText(msg
);
884 m_logwindow
->AppendText(wxT("\n"));
885 m_ribbon
->DismissExpandedPanel();
888 wxRibbonGalleryItem
* MyFrame::AddColourToGallery(wxRibbonGallery
*gallery
,
889 wxString colour
, wxMemoryDC
& dc
,
892 wxRibbonGalleryItem
* item
= NULL
;
894 if (colour
!= wxT("Default"))
895 c
= wxColour(colour
);
900 const int iWidth
= 64;
901 const int iHeight
= 40;
903 wxBitmap
bitmap(iWidth
, iHeight
);
904 dc
.SelectObject(bitmap
);
906 dc
.SetPen(*wxBLACK_PEN
);
908 dc
.DrawRectangle(0, 0, iWidth
, iHeight
);
910 colour
= colour
.Mid(0, 1) + colour
.Mid(1).Lower();
911 wxSize size
= dc
.GetTextExtent(colour
);
912 wxColour foreground
= wxColour(~c
.Red(), ~c
.Green(), ~c
.Blue());
913 if(abs(foreground
.Red() - c
.Red()) + abs(foreground
.Blue() - c
.Blue())
914 + abs(foreground
.Green() - c
.Green()) < 64)
916 // Foreground too similar to background - use a different
917 // strategy to find a contrasting colour
918 foreground
= wxColour((c
.Red() + 64) % 256, 255 - c
.Green(),
919 (c
.Blue() + 192) % 256);
921 dc
.SetTextForeground(foreground
);
922 dc
.DrawText(colour
, (iWidth
- size
.GetWidth() + 1) / 2,
923 (iHeight
- size
.GetHeight()) / 2);
924 dc
.SelectObjectAsSource(wxNullBitmap
);
926 item
= gallery
->Append(bitmap
, wxID_ANY
);
927 gallery
->SetItemClientObject(item
, new ColourClientData(colour
, c
));
932 void MyFrame::OnColourGalleryButton(wxCommandEvent
& evt
)
934 wxRibbonGallery
*gallery
= wxDynamicCast(evt
.GetEventObject(), wxRibbonGallery
);
938 m_ribbon
->DismissExpandedPanel();
939 if(gallery
->GetSelection())
940 m_colour_data
.SetColour(GetGalleryColour(gallery
, gallery
->GetSelection(), NULL
));
941 wxColourDialog
dlg(this, &m_colour_data
);
942 if(dlg
.ShowModal() == wxID_OK
)
944 m_colour_data
= dlg
.GetColourData();
945 wxColour clr
= m_colour_data
.GetColour();
947 // Try to find colour in gallery
948 wxRibbonGalleryItem
*item
= NULL
;
949 for(unsigned int i
= 0; i
< gallery
->GetCount(); ++i
)
951 item
= gallery
->GetItem(i
);
952 if(GetGalleryColour(gallery
, item
, NULL
) == clr
)
958 // Colour not in gallery - add it
961 item
= AddColourToGallery(gallery
,
962 clr
.GetAsString(wxC2S_HTML_SYNTAX
), m_bitmap_creation_dc
,
968 gallery
->EnsureVisible(item
);
969 gallery
->SetSelection(item
);
971 // Send an event to respond to the selection change
972 wxRibbonGalleryEvent
dummy(wxEVT_RIBBONGALLERY_SELECTED
, gallery
->GetId());
973 dummy
.SetEventObject(gallery
);
974 dummy
.SetGallery(gallery
);
975 dummy
.SetGalleryItem(item
);
976 ProcessWindowEvent(dummy
);
980 void MyFrame::OnDefaultProvider(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
982 m_ribbon
->DismissExpandedPanel();
983 SetArtProvider(new wxRibbonDefaultArtProvider
);
986 void MyFrame::OnAUIProvider(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
988 m_ribbon
->DismissExpandedPanel();
989 SetArtProvider(new wxRibbonAUIArtProvider
);
992 void MyFrame::OnMSWProvider(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
994 m_ribbon
->DismissExpandedPanel();
995 SetArtProvider(new wxRibbonMSWArtProvider
);
998 void MyFrame::SetArtProvider(wxRibbonArtProvider
*prov
)
1001 m_ribbon
->SetArtProvider(prov
);
1003 prov
->GetColourScheme(&m_default_primary
, &m_default_secondary
,
1004 &m_default_tertiary
);
1005 PopulateColoursPanel(m_primary_gallery
->GetParent(), m_default_primary
,
1007 PopulateColoursPanel(m_secondary_gallery
->GetParent(), m_default_secondary
,
1008 ID_SECONDARY_COLOUR
);
1010 m_ribbon
->Realize();
1012 GetSizer()->Layout();
1015 void MyFrame::OnRemovePage(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
1017 size_t n
= m_ribbon
->GetPageCount();
1020 m_ribbon
->DeletePage(n
-1);
1021 m_ribbon
->Realize();
1025 void MyFrame::OnHidePages(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
1027 m_ribbon
->HidePage(1);
1028 m_ribbon
->HidePage(2);
1029 m_ribbon
->HidePage(3);
1030 m_ribbon
->Realize();
1033 void MyFrame::OnShowPages(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
1035 m_ribbon
->ShowPage(1);
1036 m_ribbon
->ShowPage(2);
1037 m_ribbon
->ShowPage(3);
1038 m_ribbon
->Realize();
1041 void MyFrame::OnRibbonBarToggled(wxRibbonBarEvent
& WXUNUSED(evt
))
1043 AddText(wxString::Format("Ribbon bar %s.",
1044 m_ribbon
->ArePanelsShown()
1049 void MyFrame::OnRibbonBarHelpClicked(wxRibbonBarEvent
& WXUNUSED(evt
))
1051 AddText("Ribbon bar help clicked");
1054 // This shows how to hide ribbon dynamically if there is not enough space.
1055 void MyFrame::OnSizeEvent(wxSizeEvent
& evt
)
1057 if ( evt
.GetSize().GetWidth() < 200 )