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 //Also set the general disabled text colour:
410 wxRibbonArtProvider
* artProvider
= m_ribbon
->GetArtProvider();
411 wxColour tColour
= artProvider
->GetColor(wxRIBBON_ART_BUTTON_BAR_LABEL_COLOUR
);
412 artProvider
->SetColor(wxRIBBON_ART_BUTTON_BAR_LABEL_DISABLED_COLOUR
, tColour
.MakeDisabled());
414 new wxRibbonPage(m_ribbon
, wxID_ANY
, wxT("Empty Page"), empty_xpm
);
416 wxRibbonPage
* page
= new wxRibbonPage(m_ribbon
, wxID_ANY
, wxT("Another Page"), empty_xpm
);
417 wxRibbonPanel
*panel
= new wxRibbonPanel(page
, wxID_ANY
, wxT("Page manipulation"), ribbon_xpm
);
418 wxRibbonButtonBar
*bar
= new wxRibbonButtonBar(panel
, wxID_ANY
);
419 bar
->AddButton(ID_REMOVE_PAGE
, wxT("Remove"), wxArtProvider::GetBitmap(wxART_DELETE
, wxART_OTHER
, wxSize(24, 24)));
420 bar
->AddButton(ID_HIDE_PAGES
, wxT("Hide Pages"), ribbon_xpm
);
421 bar
->AddButton(ID_SHOW_PAGES
, wxT("Show Pages"), ribbon_xpm
);
423 new wxRibbonPage(m_ribbon
, wxID_ANY
, wxT("Highlight Page"), empty_xpm
);
424 m_ribbon
->AddPageHighlight(m_ribbon
->GetPageCount()-1);
428 m_logwindow
= new wxTextCtrl(this, wxID_ANY
, wxEmptyString
,
429 wxDefaultPosition
, wxDefaultSize
, wxTE_MULTILINE
| wxTE_READONLY
|
430 wxTE_LEFT
| wxTE_BESTWRAP
| wxBORDER_NONE
);
432 m_togglePanels
= new wxToggleButton(this, ID_TOGGLE_PANELS
, "&Toggle panels");
433 m_togglePanels
->SetValue(true);
435 wxSizer
*s
= new wxBoxSizer(wxVERTICAL
);
437 s
->Add(m_ribbon
, 0, wxEXPAND
);
438 s
->Add(m_logwindow
, 1, wxEXPAND
);
439 s
->Add(m_togglePanels
, wxSizerFlags().Border());
444 void MyFrame::SetBarStyle(long style
)
447 m_ribbon
->SetWindowStyleFlag(style
);
448 wxBoxSizer
*pTopSize
= reinterpret_cast<wxBoxSizer
*>(GetSizer());
449 wxRibbonToolBar
*pToolbar
= wxDynamicCast(FindWindow(ID_MAIN_TOOLBAR
), wxRibbonToolBar
);
450 if(style
& wxRIBBON_BAR_FLOW_VERTICAL
)
452 m_ribbon
->SetTabCtrlMargins(10, 10);
453 pTopSize
->SetOrientation(wxHORIZONTAL
);
455 pToolbar
->SetRows(3, 5);
459 m_ribbon
->SetTabCtrlMargins(50, 20);
460 pTopSize
->SetOrientation(wxVERTICAL
);
462 pToolbar
->SetRows(2, 3);
473 class ColourClientData
: public wxClientData
476 ColourClientData(const wxString
& name
, const wxColour
& colour
)
477 : m_name(name
), m_colour(colour
) {}
479 const wxString
& GetName() const {return m_name
;}
480 const wxColour
& GetColour() const {return m_colour
;}
487 wxRibbonGallery
* MyFrame::PopulateColoursPanel(wxWindow
* panel
,
488 wxColour def
, int gallery_id
)
490 wxRibbonGallery
*gallery
= wxDynamicCast(panel
->FindWindow(gallery_id
), wxRibbonGallery
);
494 gallery
= new wxRibbonGallery(panel
, gallery_id
);
495 wxMemoryDC
& dc
= m_bitmap_creation_dc
;
496 wxRibbonGalleryItem
*def_item
=
497 AddColourToGallery(gallery
, wxT("Default"), dc
, &def
);
498 gallery
->SetSelection(def_item
);
499 AddColourToGallery(gallery
, wxT("BLUE"), dc
);
500 AddColourToGallery(gallery
, wxT("BLUE VIOLET"), dc
);
501 AddColourToGallery(gallery
, wxT("BROWN"), dc
);
502 AddColourToGallery(gallery
, wxT("CADET BLUE"), dc
);
503 AddColourToGallery(gallery
, wxT("CORAL"), dc
);
504 AddColourToGallery(gallery
, wxT("CYAN"), dc
);
505 AddColourToGallery(gallery
, wxT("DARK GREEN"), dc
);
506 AddColourToGallery(gallery
, wxT("DARK ORCHID"), dc
);
507 AddColourToGallery(gallery
, wxT("FIREBRICK"), dc
);
508 AddColourToGallery(gallery
, wxT("GOLD"), dc
);
509 AddColourToGallery(gallery
, wxT("GOLDENROD"), dc
);
510 AddColourToGallery(gallery
, wxT("GREEN"), dc
);
511 AddColourToGallery(gallery
, wxT("INDIAN RED"), dc
);
512 AddColourToGallery(gallery
, wxT("KHAKI"), dc
);
513 AddColourToGallery(gallery
, wxT("LIGHT BLUE"), dc
);
514 AddColourToGallery(gallery
, wxT("LIME GREEN"), dc
);
515 AddColourToGallery(gallery
, wxT("MAGENTA"), dc
);
516 AddColourToGallery(gallery
, wxT("MAROON"), dc
);
517 AddColourToGallery(gallery
, wxT("NAVY"), dc
);
518 AddColourToGallery(gallery
, wxT("ORANGE"), dc
);
519 AddColourToGallery(gallery
, wxT("ORCHID"), dc
);
520 AddColourToGallery(gallery
, wxT("PINK"), dc
);
521 AddColourToGallery(gallery
, wxT("PLUM"), dc
);
522 AddColourToGallery(gallery
, wxT("PURPLE"), dc
);
523 AddColourToGallery(gallery
, wxT("RED"), dc
);
524 AddColourToGallery(gallery
, wxT("SALMON"), dc
);
525 AddColourToGallery(gallery
, wxT("SEA GREEN"), dc
);
526 AddColourToGallery(gallery
, wxT("SIENNA"), dc
);
527 AddColourToGallery(gallery
, wxT("SKY BLUE"), dc
);
528 AddColourToGallery(gallery
, wxT("TAN"), dc
);
529 AddColourToGallery(gallery
, wxT("THISTLE"), dc
);
530 AddColourToGallery(gallery
, wxT("TURQUOISE"), dc
);
531 AddColourToGallery(gallery
, wxT("VIOLET"), dc
);
532 AddColourToGallery(gallery
, wxT("VIOLET RED"), dc
);
533 AddColourToGallery(gallery
, wxT("WHEAT"), dc
);
534 AddColourToGallery(gallery
, wxT("WHITE"), dc
);
535 AddColourToGallery(gallery
, wxT("YELLOW"), dc
);
540 wxColour
MyFrame::GetGalleryColour(wxRibbonGallery
*gallery
,
541 wxRibbonGalleryItem
* item
, wxString
* name
)
543 ColourClientData
*data
= (ColourClientData
*)gallery
->GetItemClientObject(item
);
545 *name
= data
->GetName();
546 return data
->GetColour();
549 void MyFrame::OnHoveredColourChange(wxRibbonGalleryEvent
& evt
)
551 // Set the background of the gallery to the hovered colour, or back to the
552 // default if there is no longer a hovered item.
554 wxRibbonGallery
*gallery
= evt
.GetGallery();
555 wxRibbonArtProvider
*provider
= gallery
->GetArtProvider();
557 if(evt
.GetGalleryItem() != NULL
)
559 if(provider
== m_ribbon
->GetArtProvider())
561 provider
= provider
->Clone();
562 gallery
->SetArtProvider(provider
);
564 provider
->SetColour(wxRIBBON_ART_GALLERY_HOVER_BACKGROUND_COLOUR
,
565 GetGalleryColour(evt
.GetGallery(), evt
.GetGalleryItem(), NULL
));
569 if(provider
!= m_ribbon
->GetArtProvider())
571 gallery
->SetArtProvider(m_ribbon
->GetArtProvider());
577 void MyFrame::OnPrimaryColourSelect(wxRibbonGalleryEvent
& evt
)
580 wxColour colour
= GetGalleryColour(evt
.GetGallery(), evt
.GetGalleryItem(), &name
);
581 AddText(wxT("Colour \"") + name
+ wxT("\" selected as primary."));
582 wxColour secondary
, tertiary
;
583 m_ribbon
->GetArtProvider()->GetColourScheme(NULL
, &secondary
, &tertiary
);
584 m_ribbon
->GetArtProvider()->SetColourScheme(colour
, secondary
, tertiary
);
585 ResetGalleryArtProviders();
589 void MyFrame::OnSecondaryColourSelect(wxRibbonGalleryEvent
& evt
)
592 wxColour colour
= GetGalleryColour(evt
.GetGallery(), evt
.GetGalleryItem(), &name
);
593 AddText(wxT("Colour \"") + name
+ wxT("\" selected as secondary."));
594 wxColour primary
, tertiary
;
595 m_ribbon
->GetArtProvider()->GetColourScheme(&primary
, NULL
, &tertiary
);
596 m_ribbon
->GetArtProvider()->SetColourScheme(primary
, colour
, tertiary
);
597 ResetGalleryArtProviders();
601 void MyFrame::ResetGalleryArtProviders()
603 if(m_primary_gallery
->GetArtProvider() != m_ribbon
->GetArtProvider())
605 delete m_primary_gallery
->GetArtProvider();
606 m_primary_gallery
->SetArtProvider(m_ribbon
->GetArtProvider());
608 if(m_secondary_gallery
->GetArtProvider() != m_ribbon
->GetArtProvider())
610 delete m_secondary_gallery
->GetArtProvider();
611 m_secondary_gallery
->SetArtProvider(m_ribbon
->GetArtProvider());
615 void MyFrame::OnChangeText1(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
617 m_new_text
= wxT("One");
620 void MyFrame::OnChangeText2(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
622 m_new_text
= wxT("Two");
625 void MyFrame::OnEnable(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
630 void MyFrame::OnDisable(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
635 void MyFrame::OnDisabled(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
637 AddText("ERROR: Disabled button activated (not supposed to happen)");
640 void MyFrame::OnEnableUpdated(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
642 AddText("Button activated");
645 void MyFrame::OnCheck(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
647 m_bChecked
= !m_bChecked
;
650 void MyFrame::OnEnableUpdateUI(wxUpdateUIEvent
& evt
)
652 evt
.Enable(m_bEnabled
);
655 void MyFrame::OnCheckUpdateUI(wxUpdateUIEvent
& evt
)
657 evt
.Check(m_bChecked
);
660 void MyFrame::OnChangeTextUpdateUI(wxUpdateUIEvent
& evt
)
662 if ( !m_new_text
.IsEmpty() )
664 evt
.SetText(m_new_text
);
665 m_new_text
= wxT("");
669 void MyFrame::OnSelectionExpandHButton(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
671 AddText(wxT("Expand selection horizontally button clicked."));
674 void MyFrame::OnSelectionExpandVButton(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
676 AddText(wxT("Expand selection vertically button clicked."));
679 void MyFrame::OnSelectionContractButton(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
681 AddText(wxT("Contract selection button clicked."));
684 void MyFrame::OnCircleButton(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
686 AddText(wxT("Circle button clicked."));
689 void MyFrame::OnCrossButton(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
691 AddText(wxT("Cross button clicked."));
694 void MyFrame::OnTriangleButton(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
696 AddText(wxT("Triangle button clicked."));
699 void MyFrame::OnTriangleDropdown(wxRibbonButtonBarEvent
& evt
)
702 menu
.Append(wxID_ANY
, wxT("Equilateral"));
703 menu
.Append(wxID_ANY
, wxT("Isosceles"));
704 menu
.Append(wxID_ANY
, wxT("Scalene"));
706 evt
.PopupMenu(&menu
);
709 void MyFrame::OnSquareButton(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
711 AddText(wxT("Square button clicked."));
714 void MyFrame::OnPolygonDropdown(wxRibbonButtonBarEvent
& evt
)
717 menu
.Append(wxID_ANY
, wxT("Pentagon (5 sided)"));
718 menu
.Append(wxID_ANY
, wxT("Hexagon (6 sided)"));
719 menu
.Append(wxID_ANY
, wxT("Heptagon (7 sided)"));
720 menu
.Append(wxID_ANY
, wxT("Octogon (8 sided)"));
721 menu
.Append(wxID_ANY
, wxT("Nonagon (9 sided)"));
722 menu
.Append(wxID_ANY
, wxT("Decagon (10 sided)"));
724 evt
.PopupMenu(&menu
);
727 void MyFrame::OnJustify(wxRibbonToolBarEvent
& evt
)
729 long style
= m_logwindow
->GetWindowStyle() &
730 ~(wxTE_LEFT
| wxTE_CENTER
| wxTE_RIGHT
);
733 case wxID_JUSTIFY_LEFT
:
734 m_logwindow
->SetWindowStyle(style
| wxTE_LEFT
);
736 case wxID_JUSTIFY_CENTER
:
737 m_logwindow
->SetWindowStyle(style
| wxTE_CENTER
);
739 case wxID_JUSTIFY_RIGHT
:
740 m_logwindow
->SetWindowStyle(style
| wxTE_RIGHT
);
745 void MyFrame::OnJustifyUpdateUI(wxUpdateUIEvent
& evt
)
749 case wxID_JUSTIFY_LEFT
:
750 evt
.Check(!m_logwindow
->HasFlag(wxTE_CENTER
| wxTE_RIGHT
));
752 case wxID_JUSTIFY_CENTER
:
753 evt
.Check(m_logwindow
->HasFlag(wxTE_CENTER
));
755 case wxID_JUSTIFY_RIGHT
:
756 evt
.Check(m_logwindow
->HasFlag(wxTE_RIGHT
));
761 void MyFrame::OnNew(wxRibbonToolBarEvent
& WXUNUSED(evt
))
763 AddText(wxT("New button clicked."));
766 void MyFrame::OnNewDropdown(wxRibbonToolBarEvent
& evt
)
769 menu
.Append(wxID_ANY
, wxT("New Document"));
770 menu
.Append(wxID_ANY
, wxT("New Template"));
771 menu
.Append(wxID_ANY
, wxT("New Mail"));
773 evt
.PopupMenu(&menu
);
776 void MyFrame::OnPrint(wxRibbonToolBarEvent
& WXUNUSED(evt
))
778 AddText(wxT("Print button clicked."));
781 void MyFrame::OnPrintDropdown(wxRibbonToolBarEvent
& evt
)
784 menu
.Append(wxID_ANY
, wxT("Print"));
785 menu
.Append(wxID_ANY
, wxT("Preview"));
786 menu
.Append(wxID_ANY
, wxT("Options"));
788 evt
.PopupMenu(&menu
);
791 void MyFrame::OnRedoDropdown(wxRibbonToolBarEvent
& evt
)
794 menu
.Append(wxID_ANY
, wxT("Redo E"));
795 menu
.Append(wxID_ANY
, wxT("Redo F"));
796 menu
.Append(wxID_ANY
, wxT("Redo G"));
798 evt
.PopupMenu(&menu
);
801 void MyFrame::OnUndoDropdown(wxRibbonToolBarEvent
& evt
)
804 menu
.Append(wxID_ANY
, wxT("Undo C"));
805 menu
.Append(wxID_ANY
, wxT("Undo B"));
806 menu
.Append(wxID_ANY
, wxT("Undo A"));
808 evt
.PopupMenu(&menu
);
811 void MyFrame::OnPositionTopLabels(wxCommandEvent
& WXUNUSED(evt
))
813 SetBarStyle(wxRIBBON_BAR_DEFAULT_STYLE
);
816 void MyFrame::OnPositionTopIcons(wxCommandEvent
& WXUNUSED(evt
))
818 SetBarStyle((wxRIBBON_BAR_DEFAULT_STYLE
&~wxRIBBON_BAR_SHOW_PAGE_LABELS
)
819 | wxRIBBON_BAR_SHOW_PAGE_ICONS
);
822 void MyFrame::OnPositionTopBoth(wxCommandEvent
& WXUNUSED(evt
))
824 SetBarStyle(wxRIBBON_BAR_DEFAULT_STYLE
| wxRIBBON_BAR_SHOW_PAGE_ICONS
);
827 void MyFrame::OnPositionLeftLabels(wxCommandEvent
& WXUNUSED(evt
))
829 SetBarStyle(wxRIBBON_BAR_DEFAULT_STYLE
| wxRIBBON_BAR_FLOW_VERTICAL
);
832 void MyFrame::OnPositionLeftIcons(wxCommandEvent
& WXUNUSED(evt
))
834 SetBarStyle((wxRIBBON_BAR_DEFAULT_STYLE
&~wxRIBBON_BAR_SHOW_PAGE_LABELS
) |
835 wxRIBBON_BAR_SHOW_PAGE_ICONS
| wxRIBBON_BAR_FLOW_VERTICAL
);
838 void MyFrame::OnPositionLeftBoth(wxCommandEvent
& WXUNUSED(evt
))
840 SetBarStyle(wxRIBBON_BAR_DEFAULT_STYLE
| wxRIBBON_BAR_SHOW_PAGE_ICONS
|
841 wxRIBBON_BAR_FLOW_VERTICAL
);
844 void MyFrame::OnPositionTop(wxRibbonToolBarEvent
& evt
)
846 OnPositionTopLabels(evt
);
849 void MyFrame::OnPositionTopDropdown(wxRibbonToolBarEvent
& evt
)
852 menu
.Append(ID_POSITION_TOP
, wxT("Top with Labels"));
853 menu
.Append(ID_POSITION_TOP_ICONS
, wxT("Top with Icons"));
854 menu
.Append(ID_POSITION_TOP_BOTH
, wxT("Top with Both"));
855 evt
.PopupMenu(&menu
);
858 void MyFrame::OnPositionLeft(wxRibbonToolBarEvent
& evt
)
860 OnPositionLeftIcons(evt
);
863 void MyFrame::OnPositionLeftDropdown(wxRibbonToolBarEvent
& evt
)
866 menu
.Append(ID_POSITION_LEFT
, wxT("Left with Icons"));
867 menu
.Append(ID_POSITION_LEFT_LABELS
, wxT("Left with Labels"));
868 menu
.Append(ID_POSITION_LEFT_BOTH
, wxT("Left with Both"));
869 evt
.PopupMenu(&menu
);
872 void MyFrame::OnTogglePanels(wxCommandEvent
& WXUNUSED(evt
))
874 m_ribbon
->ShowPanels(m_togglePanels
->GetValue());
877 void MyFrame::OnExtButton(wxRibbonPanelEvent
& WXUNUSED(evt
))
879 wxMessageBox("Extension button clicked");
882 void MyFrame::AddText(wxString msg
)
884 m_logwindow
->AppendText(msg
);
885 m_logwindow
->AppendText(wxT("\n"));
886 m_ribbon
->DismissExpandedPanel();
889 wxRibbonGalleryItem
* MyFrame::AddColourToGallery(wxRibbonGallery
*gallery
,
890 wxString colour
, wxMemoryDC
& dc
,
893 wxRibbonGalleryItem
* item
= NULL
;
895 if (colour
!= wxT("Default"))
896 c
= wxColour(colour
);
901 const int iWidth
= 64;
902 const int iHeight
= 40;
904 wxBitmap
bitmap(iWidth
, iHeight
);
905 dc
.SelectObject(bitmap
);
907 dc
.SetPen(*wxBLACK_PEN
);
909 dc
.DrawRectangle(0, 0, iWidth
, iHeight
);
911 colour
= colour
.Mid(0, 1) + colour
.Mid(1).Lower();
912 wxSize size
= dc
.GetTextExtent(colour
);
913 wxColour foreground
= wxColour(~c
.Red(), ~c
.Green(), ~c
.Blue());
914 if(abs(foreground
.Red() - c
.Red()) + abs(foreground
.Blue() - c
.Blue())
915 + abs(foreground
.Green() - c
.Green()) < 64)
917 // Foreground too similar to background - use a different
918 // strategy to find a contrasting colour
919 foreground
= wxColour((c
.Red() + 64) % 256, 255 - c
.Green(),
920 (c
.Blue() + 192) % 256);
922 dc
.SetTextForeground(foreground
);
923 dc
.DrawText(colour
, (iWidth
- size
.GetWidth() + 1) / 2,
924 (iHeight
- size
.GetHeight()) / 2);
925 dc
.SelectObjectAsSource(wxNullBitmap
);
927 item
= gallery
->Append(bitmap
, wxID_ANY
);
928 gallery
->SetItemClientObject(item
, new ColourClientData(colour
, c
));
933 void MyFrame::OnColourGalleryButton(wxCommandEvent
& evt
)
935 wxRibbonGallery
*gallery
= wxDynamicCast(evt
.GetEventObject(), wxRibbonGallery
);
939 m_ribbon
->DismissExpandedPanel();
940 if(gallery
->GetSelection())
941 m_colour_data
.SetColour(GetGalleryColour(gallery
, gallery
->GetSelection(), NULL
));
942 wxColourDialog
dlg(this, &m_colour_data
);
943 if(dlg
.ShowModal() == wxID_OK
)
945 m_colour_data
= dlg
.GetColourData();
946 wxColour clr
= m_colour_data
.GetColour();
948 // Try to find colour in gallery
949 wxRibbonGalleryItem
*item
= NULL
;
950 for(unsigned int i
= 0; i
< gallery
->GetCount(); ++i
)
952 item
= gallery
->GetItem(i
);
953 if(GetGalleryColour(gallery
, item
, NULL
) == clr
)
959 // Colour not in gallery - add it
962 item
= AddColourToGallery(gallery
,
963 clr
.GetAsString(wxC2S_HTML_SYNTAX
), m_bitmap_creation_dc
,
969 gallery
->EnsureVisible(item
);
970 gallery
->SetSelection(item
);
972 // Send an event to respond to the selection change
973 wxRibbonGalleryEvent
dummy(wxEVT_COMMAND_RIBBONGALLERY_SELECTED
, gallery
->GetId());
974 dummy
.SetEventObject(gallery
);
975 dummy
.SetGallery(gallery
);
976 dummy
.SetGalleryItem(item
);
977 ProcessWindowEvent(dummy
);
981 void MyFrame::OnDefaultProvider(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
983 m_ribbon
->DismissExpandedPanel();
984 SetArtProvider(new wxRibbonDefaultArtProvider
);
987 void MyFrame::OnAUIProvider(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
989 m_ribbon
->DismissExpandedPanel();
990 SetArtProvider(new wxRibbonAUIArtProvider
);
993 void MyFrame::OnMSWProvider(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
995 m_ribbon
->DismissExpandedPanel();
996 SetArtProvider(new wxRibbonMSWArtProvider
);
999 void MyFrame::SetArtProvider(wxRibbonArtProvider
*prov
)
1002 m_ribbon
->SetArtProvider(prov
);
1004 prov
->GetColourScheme(&m_default_primary
, &m_default_secondary
,
1005 &m_default_tertiary
);
1006 PopulateColoursPanel(m_primary_gallery
->GetParent(), m_default_primary
,
1008 PopulateColoursPanel(m_secondary_gallery
->GetParent(), m_default_secondary
,
1009 ID_SECONDARY_COLOUR
);
1011 m_ribbon
->Realize();
1013 GetSizer()->Layout();
1016 void MyFrame::OnRemovePage(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
1018 size_t n
= m_ribbon
->GetPageCount();
1021 m_ribbon
->DeletePage(n
-1);
1022 m_ribbon
->Realize();
1026 void MyFrame::OnHidePages(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
1028 m_ribbon
->HidePage(1);
1029 m_ribbon
->HidePage(2);
1030 m_ribbon
->HidePage(3);
1031 m_ribbon
->Realize();
1034 void MyFrame::OnShowPages(wxRibbonButtonBarEvent
& WXUNUSED(evt
))
1036 m_ribbon
->ShowPage(1);
1037 m_ribbon
->ShowPage(2);
1038 m_ribbon
->ShowPage(3);
1039 m_ribbon
->Realize();
1042 void MyFrame::OnRibbonBarToggled(wxRibbonBarEvent
& WXUNUSED(evt
))
1044 AddText(wxString::Format("Ribbon bar %s.",
1045 m_ribbon
->ArePanelsShown()
1050 void MyFrame::OnRibbonBarHelpClicked(wxRibbonBarEvent
& WXUNUSED(evt
))
1052 AddText("Ribbon bar help clicked");
1055 // This shows how to hide ribbon dynamically if there is not enough space.
1056 void MyFrame::OnSizeEvent(wxSizeEvent
& evt
)
1058 if ( evt
.GetSize().GetWidth() < 200 )