2009-09-16 08:06:02 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: ribbondemo.cpp
|
|
|
|
// Purpose: wxRibbon: Ribbon user interface - sample/test program
|
|
|
|
// Author: Peter Cawley
|
|
|
|
// Modified by:
|
|
|
|
// Created: 2009-05-25
|
|
|
|
// Copyright: (C) Copyright 2009, Peter Cawley
|
|
|
|
// Licence: wxWindows Library Licence
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/app.h"
|
|
|
|
#include "wx/frame.h"
|
|
|
|
#include "wx/textctrl.h"
|
|
|
|
#include "wx/ribbon/bar.h"
|
|
|
|
#include "wx/ribbon/buttonbar.h"
|
|
|
|
#include "wx/ribbon/gallery.h"
|
|
|
|
#include "wx/ribbon/toolbar.h"
|
|
|
|
#include "wx/sizer.h"
|
|
|
|
#include "wx/menu.h"
|
2012-06-05 08:12:43 -04:00
|
|
|
#include "wx/msgdlg.h"
|
2009-09-16 08:06:02 -04:00
|
|
|
#include "wx/dcbuffer.h"
|
|
|
|
#include "wx/colordlg.h"
|
|
|
|
#include "wx/artprov.h"
|
2010-08-29 05:42:55 -04:00
|
|
|
#include "wx/combobox.h"
|
2011-01-06 17:02:07 -05:00
|
|
|
#include "wx/tglbtn.h"
|
2010-08-29 05:42:55 -04:00
|
|
|
#include "wx/wrapsizer.h"
|
2009-09-16 08:06:02 -04:00
|
|
|
|
|
|
|
// -- application --
|
|
|
|
|
|
|
|
class MyApp : public wxApp
|
|
|
|
{
|
|
|
|
public:
|
2014-03-29 20:02:23 -04:00
|
|
|
bool OnInit() wxOVERRIDE;
|
2009-09-16 08:06:02 -04:00
|
|
|
};
|
|
|
|
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_APP(MyApp);
|
|
|
|
wxIMPLEMENT_APP(MyApp);
|
2009-09-16 08:06:02 -04:00
|
|
|
|
|
|
|
// -- frame --
|
|
|
|
|
|
|
|
class MyFrame : public wxFrame
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MyFrame();
|
|
|
|
~MyFrame();
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
ID_CIRCLE = wxID_HIGHEST + 1,
|
|
|
|
ID_CROSS,
|
|
|
|
ID_TRIANGLE,
|
|
|
|
ID_SQUARE,
|
|
|
|
ID_POLYGON,
|
|
|
|
ID_SELECTION_EXPAND_H,
|
|
|
|
ID_SELECTION_EXPAND_V,
|
|
|
|
ID_SELECTION_CONTRACT,
|
2018-03-15 11:34:50 -04:00
|
|
|
ID_BUTTON_XX,
|
|
|
|
ID_BUTTON_XY,
|
2009-09-16 08:06:02 -04:00
|
|
|
ID_PRIMARY_COLOUR,
|
|
|
|
ID_SECONDARY_COLOUR,
|
|
|
|
ID_DEFAULT_PROVIDER,
|
|
|
|
ID_AUI_PROVIDER,
|
|
|
|
ID_MSW_PROVIDER,
|
|
|
|
ID_MAIN_TOOLBAR,
|
|
|
|
ID_POSITION_TOP,
|
|
|
|
ID_POSITION_TOP_ICONS,
|
|
|
|
ID_POSITION_TOP_BOTH,
|
|
|
|
ID_POSITION_LEFT,
|
|
|
|
ID_POSITION_LEFT_LABELS,
|
|
|
|
ID_POSITION_LEFT_BOTH,
|
2011-12-29 17:05:34 -05:00
|
|
|
ID_TOGGLE_PANELS,
|
|
|
|
ID_ENABLE,
|
|
|
|
ID_DISABLE,
|
|
|
|
ID_DISABLED,
|
|
|
|
ID_UI_ENABLE_UPDATED,
|
|
|
|
ID_CHECK,
|
|
|
|
ID_UI_CHECK_UPDATED,
|
|
|
|
ID_CHANGE_TEXT1,
|
|
|
|
ID_CHANGE_TEXT2,
|
2012-06-30 12:33:18 -04:00
|
|
|
ID_UI_CHANGE_TEXT_UPDATED,
|
2012-07-13 07:46:43 -04:00
|
|
|
ID_REMOVE_PAGE,
|
|
|
|
ID_HIDE_PAGES,
|
2018-03-15 11:34:50 -04:00
|
|
|
ID_SHOW_PAGES,
|
|
|
|
ID_PLUS_MINUS,
|
|
|
|
ID_CHANGE_LABEL,
|
|
|
|
ID_SMALL_BUTTON_1,
|
|
|
|
ID_SMALL_BUTTON_2,
|
|
|
|
ID_SMALL_BUTTON_3,
|
|
|
|
ID_SMALL_BUTTON_4,
|
|
|
|
ID_SMALL_BUTTON_5,
|
|
|
|
ID_SMALL_BUTTON_6
|
2009-09-16 08:06:02 -04:00
|
|
|
};
|
|
|
|
|
2011-12-29 17:05:34 -05:00
|
|
|
void OnEnableUpdateUI(wxUpdateUIEvent& evt);
|
|
|
|
void OnCheckUpdateUI(wxUpdateUIEvent& evt);
|
|
|
|
void OnChangeTextUpdateUI(wxUpdateUIEvent& evt);
|
|
|
|
void OnCheck(wxRibbonButtonBarEvent& evt);
|
|
|
|
void OnEnable(wxRibbonButtonBarEvent& evt);
|
|
|
|
void OnDisable(wxRibbonButtonBarEvent& evt);
|
2012-09-28 19:49:20 -04:00
|
|
|
void OnDisabled(wxRibbonButtonBarEvent& evt);
|
|
|
|
void OnEnableUpdated(wxRibbonButtonBarEvent& evt);
|
2011-12-29 17:05:34 -05:00
|
|
|
void OnChangeText1(wxRibbonButtonBarEvent& evt);
|
|
|
|
void OnChangeText2(wxRibbonButtonBarEvent& evt);
|
2009-09-16 08:06:02 -04:00
|
|
|
void OnCircleButton(wxRibbonButtonBarEvent& evt);
|
|
|
|
void OnCrossButton(wxRibbonButtonBarEvent& evt);
|
|
|
|
void OnTriangleButton(wxRibbonButtonBarEvent& evt);
|
|
|
|
void OnTriangleDropdown(wxRibbonButtonBarEvent& evt);
|
|
|
|
void OnSquareButton(wxRibbonButtonBarEvent& evt);
|
|
|
|
void OnPolygonDropdown(wxRibbonButtonBarEvent& evt);
|
|
|
|
void OnSelectionExpandVButton(wxRibbonButtonBarEvent& evt);
|
|
|
|
void OnSelectionExpandHButton(wxRibbonButtonBarEvent& evt);
|
|
|
|
void OnSelectionContractButton(wxRibbonButtonBarEvent& evt);
|
|
|
|
void OnHoveredColourChange(wxRibbonGalleryEvent& evt);
|
|
|
|
void OnPrimaryColourSelect(wxRibbonGalleryEvent& evt);
|
|
|
|
void OnSecondaryColourSelect(wxRibbonGalleryEvent& evt);
|
|
|
|
void OnColourGalleryButton(wxCommandEvent& evt);
|
|
|
|
void OnDefaultProvider(wxRibbonButtonBarEvent& evt);
|
|
|
|
void OnAUIProvider(wxRibbonButtonBarEvent& evt);
|
|
|
|
void OnMSWProvider(wxRibbonButtonBarEvent& evt);
|
2012-01-08 09:52:56 -05:00
|
|
|
void OnJustify(wxRibbonToolBarEvent& evt);
|
|
|
|
void OnJustifyUpdateUI(wxUpdateUIEvent& evt);
|
2009-09-16 08:06:02 -04:00
|
|
|
void OnNew(wxRibbonToolBarEvent& evt);
|
|
|
|
void OnNewDropdown(wxRibbonToolBarEvent& evt);
|
|
|
|
void OnPrint(wxRibbonToolBarEvent& evt);
|
|
|
|
void OnPrintDropdown(wxRibbonToolBarEvent& evt);
|
|
|
|
void OnRedoDropdown(wxRibbonToolBarEvent& evt);
|
|
|
|
void OnUndoDropdown(wxRibbonToolBarEvent& evt);
|
|
|
|
void OnPositionTop(wxRibbonToolBarEvent& evt);
|
|
|
|
void OnPositionTopLabels(wxCommandEvent& evt);
|
|
|
|
void OnPositionTopIcons(wxCommandEvent& evt);
|
|
|
|
void OnPositionTopBoth(wxCommandEvent& evt);
|
|
|
|
void OnPositionTopDropdown(wxRibbonToolBarEvent& evt);
|
|
|
|
void OnPositionLeft(wxRibbonToolBarEvent& evt);
|
|
|
|
void OnPositionLeftLabels(wxCommandEvent& evt);
|
|
|
|
void OnPositionLeftIcons(wxCommandEvent& evt);
|
|
|
|
void OnPositionLeftBoth(wxCommandEvent& evt);
|
|
|
|
void OnPositionLeftDropdown(wxRibbonToolBarEvent& evt);
|
2012-06-30 12:33:18 -04:00
|
|
|
void OnRemovePage(wxRibbonButtonBarEvent& evt);
|
2012-07-13 07:46:43 -04:00
|
|
|
void OnHidePages(wxRibbonButtonBarEvent& evt);
|
|
|
|
void OnShowPages(wxRibbonButtonBarEvent& evt);
|
2018-03-15 11:34:50 -04:00
|
|
|
void OnPlusMinus(wxRibbonButtonBarEvent& evt);
|
|
|
|
void OnChangeLabel(wxRibbonButtonBarEvent& evt);
|
2011-01-06 17:02:07 -05:00
|
|
|
void OnTogglePanels(wxCommandEvent& evt);
|
2012-07-30 13:53:36 -04:00
|
|
|
void OnRibbonBarToggled(wxRibbonBarEvent& evt);
|
2012-09-15 19:19:59 -04:00
|
|
|
void OnRibbonBarHelpClicked(wxRibbonBarEvent& evt);
|
|
|
|
|
|
|
|
void OnSizeEvent(wxSizeEvent& evt);
|
2011-01-06 17:02:07 -05:00
|
|
|
|
2012-06-03 15:17:09 -04:00
|
|
|
void OnExtButton(wxRibbonPanelEvent& evt);
|
|
|
|
|
2009-09-16 08:06:02 -04:00
|
|
|
protected:
|
|
|
|
wxRibbonGallery* PopulateColoursPanel(wxWindow* panel, wxColour def,
|
|
|
|
int gallery_id);
|
|
|
|
void AddText(wxString msg);
|
|
|
|
wxRibbonGalleryItem* AddColourToGallery(wxRibbonGallery *gallery,
|
|
|
|
wxString name, wxMemoryDC& dc, wxColour* value = NULL);
|
|
|
|
wxColour GetGalleryColour(wxRibbonGallery *gallery,
|
|
|
|
wxRibbonGalleryItem* item, wxString* name);
|
|
|
|
void ResetGalleryArtProviders();
|
|
|
|
void SetArtProvider(wxRibbonArtProvider* prov);
|
|
|
|
void SetBarStyle(long style);
|
|
|
|
|
|
|
|
wxRibbonBar* m_ribbon;
|
|
|
|
wxRibbonGallery* m_primary_gallery;
|
|
|
|
wxRibbonGallery* m_secondary_gallery;
|
|
|
|
wxTextCtrl* m_logwindow;
|
2011-01-06 17:02:07 -05:00
|
|
|
wxToggleButton* m_togglePanels;
|
|
|
|
|
2009-09-16 08:06:02 -04:00
|
|
|
wxColourData m_colour_data;
|
|
|
|
wxColour m_default_primary;
|
|
|
|
wxColour m_default_secondary;
|
|
|
|
wxColour m_default_tertiary;
|
|
|
|
wxMemoryDC m_bitmap_creation_dc;
|
2011-12-29 17:05:34 -05:00
|
|
|
bool m_bEnabled;
|
|
|
|
bool m_bChecked;
|
|
|
|
wxString m_new_text;
|
2009-09-16 08:06:02 -04:00
|
|
|
|
2018-03-15 11:34:50 -04:00
|
|
|
wxRibbonButtonBar* m_mutable_button_bar;
|
|
|
|
bool m_plus_minus_state;
|
|
|
|
bool m_change_label_state;
|
|
|
|
|
2014-03-30 03:07:55 -04:00
|
|
|
wxDECLARE_EVENT_TABLE();
|
2009-09-16 08:06:02 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// -- implementations --
|
|
|
|
|
|
|
|
bool MyApp::OnInit()
|
|
|
|
{
|
|
|
|
if(!wxApp::OnInit())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
wxFrame* frame = new MyFrame;
|
|
|
|
frame->Show();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-03-30 03:07:55 -04:00
|
|
|
wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
2011-12-29 17:05:34 -05:00
|
|
|
EVT_RIBBONBUTTONBAR_CLICKED(ID_ENABLE, MyFrame::OnEnable)
|
|
|
|
EVT_RIBBONBUTTONBAR_CLICKED(ID_DISABLE, MyFrame::OnDisable)
|
2012-09-28 19:49:20 -04:00
|
|
|
EVT_RIBBONBUTTONBAR_CLICKED(ID_DISABLED, MyFrame::OnDisabled)
|
|
|
|
EVT_RIBBONBUTTONBAR_CLICKED(ID_UI_ENABLE_UPDATED, MyFrame::OnEnableUpdated)
|
2011-12-29 17:05:34 -05:00
|
|
|
EVT_UPDATE_UI(ID_UI_ENABLE_UPDATED, MyFrame::OnEnableUpdateUI)
|
|
|
|
EVT_RIBBONBUTTONBAR_CLICKED(ID_CHECK, MyFrame::OnCheck)
|
|
|
|
EVT_UPDATE_UI(ID_UI_CHECK_UPDATED, MyFrame::OnCheckUpdateUI)
|
|
|
|
EVT_RIBBONBUTTONBAR_CLICKED(ID_CHANGE_TEXT1, MyFrame::OnChangeText1)
|
|
|
|
EVT_RIBBONBUTTONBAR_CLICKED(ID_CHANGE_TEXT2, MyFrame::OnChangeText2)
|
|
|
|
EVT_UPDATE_UI(ID_UI_CHANGE_TEXT_UPDATED, MyFrame::OnChangeTextUpdateUI)
|
2009-09-16 08:06:02 -04:00
|
|
|
EVT_RIBBONBUTTONBAR_CLICKED(ID_DEFAULT_PROVIDER, MyFrame::OnDefaultProvider)
|
|
|
|
EVT_RIBBONBUTTONBAR_CLICKED(ID_AUI_PROVIDER, MyFrame::OnAUIProvider)
|
|
|
|
EVT_RIBBONBUTTONBAR_CLICKED(ID_MSW_PROVIDER, MyFrame::OnMSWProvider)
|
|
|
|
EVT_RIBBONBUTTONBAR_CLICKED(ID_SELECTION_EXPAND_H, MyFrame::OnSelectionExpandHButton)
|
|
|
|
EVT_RIBBONBUTTONBAR_CLICKED(ID_SELECTION_EXPAND_V, MyFrame::OnSelectionExpandVButton)
|
|
|
|
EVT_RIBBONBUTTONBAR_CLICKED(ID_SELECTION_CONTRACT, MyFrame::OnSelectionContractButton)
|
|
|
|
EVT_RIBBONBUTTONBAR_CLICKED(ID_CIRCLE, MyFrame::OnCircleButton)
|
|
|
|
EVT_RIBBONBUTTONBAR_CLICKED(ID_CROSS, MyFrame::OnCrossButton)
|
|
|
|
EVT_RIBBONBUTTONBAR_CLICKED(ID_TRIANGLE, MyFrame::OnTriangleButton)
|
|
|
|
EVT_RIBBONBUTTONBAR_CLICKED(ID_SQUARE, MyFrame::OnSquareButton)
|
|
|
|
EVT_RIBBONBUTTONBAR_DROPDOWN_CLICKED(ID_TRIANGLE, MyFrame::OnTriangleDropdown)
|
|
|
|
EVT_RIBBONBUTTONBAR_DROPDOWN_CLICKED(ID_POLYGON, MyFrame::OnPolygonDropdown)
|
|
|
|
EVT_RIBBONGALLERY_HOVER_CHANGED(ID_PRIMARY_COLOUR, MyFrame::OnHoveredColourChange)
|
|
|
|
EVT_RIBBONGALLERY_HOVER_CHANGED(ID_SECONDARY_COLOUR, MyFrame::OnHoveredColourChange)
|
|
|
|
EVT_RIBBONGALLERY_SELECTED(ID_PRIMARY_COLOUR, MyFrame::OnPrimaryColourSelect)
|
|
|
|
EVT_RIBBONGALLERY_SELECTED(ID_SECONDARY_COLOUR, MyFrame::OnSecondaryColourSelect)
|
2012-01-08 09:52:56 -05:00
|
|
|
EVT_RIBBONTOOLBAR_CLICKED(wxID_JUSTIFY_LEFT, MyFrame::OnJustify)
|
|
|
|
EVT_RIBBONTOOLBAR_CLICKED(wxID_JUSTIFY_CENTER, MyFrame::OnJustify)
|
|
|
|
EVT_RIBBONTOOLBAR_CLICKED(wxID_JUSTIFY_RIGHT, MyFrame::OnJustify)
|
|
|
|
EVT_UPDATE_UI(wxID_JUSTIFY_LEFT, MyFrame::OnJustifyUpdateUI)
|
|
|
|
EVT_UPDATE_UI(wxID_JUSTIFY_CENTER, MyFrame::OnJustifyUpdateUI)
|
|
|
|
EVT_UPDATE_UI(wxID_JUSTIFY_RIGHT, MyFrame::OnJustifyUpdateUI)
|
2009-09-16 08:06:02 -04:00
|
|
|
EVT_RIBBONTOOLBAR_CLICKED(wxID_NEW, MyFrame::OnNew)
|
|
|
|
EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(wxID_NEW, MyFrame::OnNewDropdown)
|
|
|
|
EVT_RIBBONTOOLBAR_CLICKED(wxID_PRINT, MyFrame::OnPrint)
|
|
|
|
EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(wxID_PRINT, MyFrame::OnPrintDropdown)
|
|
|
|
EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(wxID_REDO, MyFrame::OnRedoDropdown)
|
|
|
|
EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(wxID_UNDO, MyFrame::OnUndoDropdown)
|
|
|
|
EVT_RIBBONTOOLBAR_CLICKED(ID_POSITION_LEFT, MyFrame::OnPositionLeft)
|
|
|
|
EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(ID_POSITION_LEFT, MyFrame::OnPositionLeftDropdown)
|
|
|
|
EVT_RIBBONTOOLBAR_CLICKED(ID_POSITION_TOP, MyFrame::OnPositionTop)
|
|
|
|
EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(ID_POSITION_TOP, MyFrame::OnPositionTopDropdown)
|
|
|
|
EVT_BUTTON(ID_PRIMARY_COLOUR, MyFrame::OnColourGalleryButton)
|
|
|
|
EVT_BUTTON(ID_SECONDARY_COLOUR, MyFrame::OnColourGalleryButton)
|
|
|
|
EVT_MENU(ID_POSITION_LEFT, MyFrame::OnPositionLeftIcons)
|
|
|
|
EVT_MENU(ID_POSITION_LEFT_LABELS, MyFrame::OnPositionLeftLabels)
|
|
|
|
EVT_MENU(ID_POSITION_LEFT_BOTH, MyFrame::OnPositionLeftBoth)
|
|
|
|
EVT_MENU(ID_POSITION_TOP, MyFrame::OnPositionTopLabels)
|
|
|
|
EVT_MENU(ID_POSITION_TOP_ICONS, MyFrame::OnPositionTopIcons)
|
|
|
|
EVT_MENU(ID_POSITION_TOP_BOTH, MyFrame::OnPositionTopBoth)
|
2011-01-06 17:02:07 -05:00
|
|
|
EVT_TOGGLEBUTTON(ID_TOGGLE_PANELS, MyFrame::OnTogglePanels)
|
2012-06-03 15:17:09 -04:00
|
|
|
EVT_RIBBONPANEL_EXTBUTTON_ACTIVATED(wxID_ANY, MyFrame::OnExtButton)
|
2012-06-30 12:33:18 -04:00
|
|
|
EVT_RIBBONBUTTONBAR_CLICKED(ID_REMOVE_PAGE, MyFrame::OnRemovePage)
|
2012-07-13 07:46:43 -04:00
|
|
|
EVT_RIBBONBUTTONBAR_CLICKED(ID_HIDE_PAGES, MyFrame::OnHidePages)
|
|
|
|
EVT_RIBBONBUTTONBAR_CLICKED(ID_SHOW_PAGES, MyFrame::OnShowPages)
|
2018-03-15 11:34:50 -04:00
|
|
|
EVT_RIBBONBUTTONBAR_CLICKED(ID_PLUS_MINUS, MyFrame::OnPlusMinus)
|
|
|
|
EVT_RIBBONBUTTONBAR_CLICKED(ID_CHANGE_LABEL, MyFrame::OnChangeLabel)
|
2012-07-30 13:53:36 -04:00
|
|
|
EVT_RIBBONBAR_TOGGLED(wxID_ANY, MyFrame::OnRibbonBarToggled)
|
2012-09-15 19:19:59 -04:00
|
|
|
EVT_RIBBONBAR_HELP_CLICK(wxID_ANY, MyFrame::OnRibbonBarHelpClicked)
|
|
|
|
EVT_SIZE(MyFrame::OnSizeEvent)
|
2014-03-30 03:07:55 -04:00
|
|
|
wxEND_EVENT_TABLE()
|
2009-09-16 08:06:02 -04:00
|
|
|
|
|
|
|
#include "align_center.xpm"
|
|
|
|
#include "align_left.xpm"
|
|
|
|
#include "align_right.xpm"
|
|
|
|
#include "aui_style.xpm"
|
|
|
|
#include "auto_crop_selection.xpm"
|
|
|
|
#include "auto_crop_selection_small.xpm"
|
|
|
|
#include "circle.xpm"
|
|
|
|
#include "circle_small.xpm"
|
|
|
|
#include "colours.xpm"
|
|
|
|
#include "cross.xpm"
|
|
|
|
#include "empty.xpm"
|
|
|
|
#include "expand_selection_v.xpm"
|
|
|
|
#include "expand_selection_h.xpm"
|
|
|
|
#include "eye.xpm"
|
|
|
|
#include "hexagon.xpm"
|
|
|
|
#include "msw_style.xpm"
|
|
|
|
#include "position_left_small.xpm"
|
|
|
|
#include "position_top_small.xpm"
|
|
|
|
#include "ribbon.xpm"
|
|
|
|
#include "selection_panel.xpm"
|
|
|
|
#include "square.xpm"
|
|
|
|
#include "triangle.xpm"
|
|
|
|
|
|
|
|
MyFrame::MyFrame()
|
2018-09-22 19:15:08 -04:00
|
|
|
: wxFrame(NULL, wxID_ANY, "wxRibbon Sample Application", wxDefaultPosition, wxSize(800, 600), wxDEFAULT_FRAME_STYLE)
|
2009-09-16 08:06:02 -04:00
|
|
|
{
|
2012-09-15 19:19:59 -04:00
|
|
|
m_ribbon = new wxRibbonBar(this,-1,wxDefaultPosition, wxDefaultSize, wxRIBBON_BAR_FLOW_HORIZONTAL
|
|
|
|
| wxRIBBON_BAR_SHOW_PAGE_LABELS
|
|
|
|
| wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS
|
|
|
|
| wxRIBBON_BAR_SHOW_TOGGLE_BUTTON
|
|
|
|
| wxRIBBON_BAR_SHOW_HELP_BUTTON
|
|
|
|
);
|
2009-09-16 08:06:02 -04:00
|
|
|
|
|
|
|
{
|
2018-09-22 19:15:08 -04:00
|
|
|
wxRibbonPage* home = new wxRibbonPage(m_ribbon, wxID_ANY, "Examples", ribbon_xpm);
|
2019-01-30 11:28:08 -05:00
|
|
|
wxRibbonPanel *toolbar_panel = new wxRibbonPanel(home, wxID_ANY, "Toolbar",
|
|
|
|
wxNullBitmap, wxDefaultPosition, wxDefaultSize,
|
2012-06-03 15:17:09 -04:00
|
|
|
wxRIBBON_PANEL_NO_AUTO_MINIMISE |
|
|
|
|
wxRIBBON_PANEL_EXT_BUTTON);
|
2009-09-16 08:06:02 -04:00
|
|
|
wxRibbonToolBar *toolbar = new wxRibbonToolBar(toolbar_panel, ID_MAIN_TOOLBAR);
|
2012-01-08 09:52:56 -05:00
|
|
|
toolbar->AddToggleTool(wxID_JUSTIFY_LEFT, align_left_xpm);
|
|
|
|
toolbar->AddToggleTool(wxID_JUSTIFY_CENTER , align_center_xpm);
|
|
|
|
toolbar->AddToggleTool(wxID_JUSTIFY_RIGHT, align_right_xpm);
|
2009-09-16 08:06:02 -04:00
|
|
|
toolbar->AddSeparator();
|
|
|
|
toolbar->AddHybridTool(wxID_NEW, wxArtProvider::GetBitmap(wxART_NEW, wxART_OTHER, wxSize(16, 15)));
|
2012-01-08 09:52:56 -05:00
|
|
|
toolbar->AddTool(wxID_OPEN, wxArtProvider::GetBitmap(wxART_FILE_OPEN, wxART_OTHER, wxSize(16, 15)), "Open something");
|
|
|
|
toolbar->AddTool(wxID_SAVE, wxArtProvider::GetBitmap(wxART_FILE_SAVE, wxART_OTHER, wxSize(16, 15)), "Save something");
|
|
|
|
toolbar->AddTool(wxID_SAVEAS, wxArtProvider::GetBitmap(wxART_FILE_SAVE_AS, wxART_OTHER, wxSize(16, 15)), "Save something as ...");
|
|
|
|
toolbar->EnableTool(wxID_OPEN, false);
|
|
|
|
toolbar->EnableTool(wxID_SAVE, false);
|
|
|
|
toolbar->EnableTool(wxID_SAVEAS, false);
|
2009-09-16 08:06:02 -04:00
|
|
|
toolbar->AddSeparator();
|
|
|
|
toolbar->AddDropdownTool(wxID_UNDO, wxArtProvider::GetBitmap(wxART_UNDO, wxART_OTHER, wxSize(16, 15)));
|
|
|
|
toolbar->AddDropdownTool(wxID_REDO, wxArtProvider::GetBitmap(wxART_REDO, wxART_OTHER, wxSize(16, 15)));
|
|
|
|
toolbar->AddSeparator();
|
|
|
|
toolbar->AddTool(wxID_ANY, wxArtProvider::GetBitmap(wxART_REPORT_VIEW, wxART_OTHER, wxSize(16, 15)));
|
|
|
|
toolbar->AddTool(wxID_ANY, wxArtProvider::GetBitmap(wxART_LIST_VIEW, wxART_OTHER, wxSize(16, 15)));
|
|
|
|
toolbar->AddSeparator();
|
2019-01-30 11:28:08 -05:00
|
|
|
toolbar->AddHybridTool(ID_POSITION_LEFT, position_left_xpm,
|
2010-10-20 13:49:42 -04:00
|
|
|
"Align ribbonbar vertically\non the left\nfor demonstration purposes");
|
2019-01-30 11:28:08 -05:00
|
|
|
toolbar->AddHybridTool(ID_POSITION_TOP, position_top_xpm,
|
2010-10-20 13:49:42 -04:00
|
|
|
"Align the ribbonbar horizontally\nat the top\nfor demonstration purposes");
|
2009-09-16 08:06:02 -04:00
|
|
|
toolbar->AddSeparator();
|
2010-10-20 13:49:42 -04:00
|
|
|
toolbar->AddHybridTool(wxID_PRINT, wxArtProvider::GetBitmap(wxART_PRINT, wxART_OTHER, wxSize(16, 15)),
|
|
|
|
"This is the Print button tooltip\ndemonstrating a tooltip");
|
2009-09-16 08:06:02 -04:00
|
|
|
toolbar->SetRows(2, 3);
|
|
|
|
|
2018-09-22 19:15:08 -04:00
|
|
|
wxRibbonPanel *selection_panel = new wxRibbonPanel(home, wxID_ANY, "Selection", wxBitmap(selection_panel_xpm));
|
2009-09-16 08:06:02 -04:00
|
|
|
wxRibbonButtonBar *selection = new wxRibbonButtonBar(selection_panel);
|
2018-09-22 19:15:08 -04:00
|
|
|
selection->AddButton(ID_SELECTION_EXPAND_V, "Expand Vertically", wxBitmap(expand_selection_v_xpm),
|
2010-10-20 13:49:42 -04:00
|
|
|
"This is a tooltip for Expand Vertically\ndemonstrating a tooltip");
|
2018-09-22 19:15:08 -04:00
|
|
|
selection->AddButton(ID_SELECTION_EXPAND_H, "Expand Horizontally", wxBitmap(expand_selection_h_xpm), wxEmptyString);
|
|
|
|
selection->AddButton(ID_SELECTION_CONTRACT, "Contract", wxBitmap(auto_crop_selection_xpm), wxBitmap(auto_crop_selection_small_xpm));
|
2009-09-16 08:06:02 -04:00
|
|
|
|
2018-09-22 19:15:08 -04:00
|
|
|
wxRibbonPanel *shapes_panel = new wxRibbonPanel(home, wxID_ANY, "Shapes", wxBitmap(circle_small_xpm));
|
2009-09-16 08:06:02 -04:00
|
|
|
wxRibbonButtonBar *shapes = new wxRibbonButtonBar(shapes_panel);
|
2019-01-30 11:28:08 -05:00
|
|
|
shapes->AddButton(ID_CIRCLE, "Circle", wxBitmap(circle_xpm), wxBitmap(circle_small_xpm),
|
2010-10-20 13:49:42 -04:00
|
|
|
wxNullBitmap, wxNullBitmap, wxRIBBON_BUTTON_NORMAL,
|
|
|
|
"This is a tooltip for the circle button\ndemonstrating another tooltip");
|
2018-09-22 19:15:08 -04:00
|
|
|
shapes->AddButton(ID_CROSS, "Cross", wxBitmap(cross_xpm), wxEmptyString);
|
|
|
|
shapes->AddHybridButton(ID_TRIANGLE, "Triangle", wxBitmap(triangle_xpm));
|
|
|
|
shapes->AddButton(ID_SQUARE, "Square", wxBitmap(square_xpm), wxEmptyString);
|
|
|
|
shapes->AddDropdownButton(ID_POLYGON, "Other Polygon", wxBitmap(hexagon_xpm), wxEmptyString);
|
2009-09-16 08:06:02 -04:00
|
|
|
|
2019-01-30 11:28:08 -05:00
|
|
|
wxRibbonPanel *sizer_panel = new wxRibbonPanel(home, wxID_ANY, "Panel with Sizer",
|
|
|
|
wxNullBitmap, wxDefaultPosition, wxDefaultSize,
|
2010-10-20 13:49:42 -04:00
|
|
|
wxRIBBON_PANEL_DEFAULT_STYLE);
|
2010-08-29 05:42:55 -04:00
|
|
|
|
|
|
|
wxArrayString as;
|
2010-10-20 13:49:42 -04:00
|
|
|
as.Add("Item 1 using a box sizer now");
|
|
|
|
as.Add("Item 2 using a box sizer now");
|
2019-01-30 11:28:08 -05:00
|
|
|
wxComboBox* sizer_panelcombo = new wxComboBox(sizer_panel, wxID_ANY,
|
|
|
|
wxEmptyString,
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
2010-10-20 13:49:42 -04:00
|
|
|
as, wxCB_READONLY);
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2019-01-30 11:28:08 -05:00
|
|
|
wxComboBox* sizer_panelcombo2 = new wxComboBox(sizer_panel, wxID_ANY,
|
|
|
|
wxEmptyString,
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
2010-10-20 13:49:42 -04:00
|
|
|
as, wxCB_READONLY);
|
|
|
|
|
|
|
|
sizer_panelcombo->Select(0);
|
|
|
|
sizer_panelcombo2->Select(1);
|
2010-08-29 05:42:55 -04:00
|
|
|
sizer_panelcombo->SetMinSize(wxSize(150, -1));
|
|
|
|
sizer_panelcombo2->SetMinSize(wxSize(150, -1));
|
|
|
|
|
2018-03-15 11:34:50 -04:00
|
|
|
wxRibbonButtonBar* bar = new wxRibbonButtonBar(sizer_panel, wxID_ANY);
|
2018-09-22 19:15:08 -04:00
|
|
|
bar->AddButton(ID_BUTTON_XX, "xx", ribbon_xpm);
|
|
|
|
bar->AddButton(ID_BUTTON_XY, "xy", ribbon_xpm);
|
2018-03-15 11:34:50 -04:00
|
|
|
// This prevents ribbon buttons in panels with sizer from collapsing.
|
|
|
|
bar->SetButtonMinSizeClass(ID_BUTTON_XX, wxRIBBON_BUTTONBAR_BUTTON_LARGE);
|
|
|
|
bar->SetButtonMinSizeClass(ID_BUTTON_XY, wxRIBBON_BUTTONBAR_BUTTON_LARGE);
|
|
|
|
|
|
|
|
wxSizer* sizer_panelsizer_h = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
wxSizer* sizer_panelsizer_v = new wxBoxSizer(wxVERTICAL);
|
|
|
|
sizer_panelsizer_v->AddStretchSpacer(1);
|
|
|
|
sizer_panelsizer_v->Add(sizer_panelcombo, 0, wxALL|wxEXPAND, 2);
|
|
|
|
sizer_panelsizer_v->Add(sizer_panelcombo2, 0, wxALL|wxEXPAND, 2);
|
|
|
|
sizer_panelsizer_v->AddStretchSpacer(1);
|
|
|
|
sizer_panelsizer_h->Add(bar, 0, wxEXPAND);
|
|
|
|
sizer_panelsizer_h->Add(sizer_panelsizer_v, 0);
|
|
|
|
sizer_panel->SetSizer(sizer_panelsizer_h);
|
2010-08-29 05:42:55 -04:00
|
|
|
|
2018-09-17 09:29:42 -04:00
|
|
|
wxFont label_font(wxFontInfo(8).Light());
|
2009-09-16 08:06:02 -04:00
|
|
|
m_bitmap_creation_dc.SetFont(label_font);
|
|
|
|
|
2018-09-22 19:15:08 -04:00
|
|
|
wxRibbonPage* scheme = new wxRibbonPage(m_ribbon, wxID_ANY, "Appearance", eye_xpm);
|
2009-09-16 08:06:02 -04:00
|
|
|
m_ribbon->GetArtProvider()->GetColourScheme(&m_default_primary,
|
|
|
|
&m_default_secondary, &m_default_tertiary);
|
|
|
|
wxRibbonPanel *provider_panel = new wxRibbonPanel(scheme, wxID_ANY,
|
2018-09-22 19:15:08 -04:00
|
|
|
"Art", wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxRIBBON_PANEL_NO_AUTO_MINIMISE);
|
2009-09-16 08:06:02 -04:00
|
|
|
wxRibbonButtonBar *provider_bar = new wxRibbonButtonBar(provider_panel, wxID_ANY);
|
2018-09-22 19:15:08 -04:00
|
|
|
provider_bar->AddButton(ID_DEFAULT_PROVIDER, "Default Provider",
|
2009-09-16 08:06:02 -04:00
|
|
|
wxArtProvider::GetBitmap(wxART_QUESTION, wxART_OTHER, wxSize(32, 32)));
|
2018-09-22 19:15:08 -04:00
|
|
|
provider_bar->AddButton(ID_AUI_PROVIDER, "AUI Provider", aui_style_xpm);
|
|
|
|
provider_bar->AddButton(ID_MSW_PROVIDER, "MSW Provider", msw_style_xpm);
|
2009-09-16 08:06:02 -04:00
|
|
|
wxRibbonPanel *primary_panel = new wxRibbonPanel(scheme, wxID_ANY,
|
2018-09-22 19:15:08 -04:00
|
|
|
"Primary Colour", colours_xpm);
|
2009-09-16 08:06:02 -04:00
|
|
|
m_primary_gallery = PopulateColoursPanel(primary_panel,
|
|
|
|
m_default_primary, ID_PRIMARY_COLOUR);
|
|
|
|
wxRibbonPanel *secondary_panel = new wxRibbonPanel(scheme, wxID_ANY,
|
2018-09-22 19:15:08 -04:00
|
|
|
"Secondary Colour", colours_xpm);
|
2009-09-16 08:06:02 -04:00
|
|
|
m_secondary_gallery = PopulateColoursPanel(secondary_panel,
|
|
|
|
m_default_secondary, ID_SECONDARY_COLOUR);
|
|
|
|
}
|
2011-12-29 17:05:34 -05:00
|
|
|
{
|
2018-09-22 19:15:08 -04:00
|
|
|
wxRibbonPage* page = new wxRibbonPage(m_ribbon, wxID_ANY, "UI Updated", ribbon_xpm);
|
|
|
|
wxRibbonPanel *panel = new wxRibbonPanel(page, wxID_ANY, "Enable/Disable", ribbon_xpm);
|
2011-12-29 17:05:34 -05:00
|
|
|
wxRibbonButtonBar *bar = new wxRibbonButtonBar(panel, wxID_ANY);
|
2018-09-22 19:15:08 -04:00
|
|
|
bar->AddButton(ID_DISABLED, "Disabled", ribbon_xpm);
|
|
|
|
bar->AddButton(ID_ENABLE, "Enable", ribbon_xpm);
|
|
|
|
bar->AddButton(ID_DISABLE, "Disable", ribbon_xpm);
|
|
|
|
bar->AddButton(ID_UI_ENABLE_UPDATED, "Enable UI updated", ribbon_xpm);
|
2011-12-29 17:05:34 -05:00
|
|
|
bar->EnableButton(ID_DISABLED, false);
|
|
|
|
m_bEnabled = true;
|
|
|
|
|
2018-09-22 19:15:08 -04:00
|
|
|
panel = new wxRibbonPanel(page, wxID_ANY, "Toggle", ribbon_xpm);
|
2011-12-29 17:05:34 -05:00
|
|
|
bar = new wxRibbonButtonBar(panel, wxID_ANY);
|
2018-09-22 19:15:08 -04:00
|
|
|
bar->AddButton(ID_CHECK, "Toggle", ribbon_xpm);
|
|
|
|
bar->AddToggleButton(ID_UI_CHECK_UPDATED, "Toggled UI updated", ribbon_xpm);
|
2011-12-29 17:05:34 -05:00
|
|
|
m_bChecked = true;
|
|
|
|
|
2018-09-22 19:15:08 -04:00
|
|
|
panel = new wxRibbonPanel(page, wxID_ANY, "Change text", ribbon_xpm);
|
2011-12-29 17:05:34 -05:00
|
|
|
bar = new wxRibbonButtonBar(panel, wxID_ANY);
|
2018-09-22 19:15:08 -04:00
|
|
|
bar->AddButton(ID_CHANGE_TEXT1, "One", ribbon_xpm);
|
|
|
|
bar->AddButton(ID_CHANGE_TEXT2, "Two", ribbon_xpm);
|
|
|
|
bar->AddButton(ID_UI_CHANGE_TEXT_UPDATED, "Zero", ribbon_xpm);
|
2012-10-04 19:23:41 -04:00
|
|
|
|
|
|
|
//Also set the general disabled text colour:
|
|
|
|
wxRibbonArtProvider* artProvider = m_ribbon->GetArtProvider();
|
|
|
|
wxColour tColour = artProvider->GetColor(wxRIBBON_ART_BUTTON_BAR_LABEL_COLOUR);
|
|
|
|
artProvider->SetColor(wxRIBBON_ART_BUTTON_BAR_LABEL_DISABLED_COLOUR, tColour.MakeDisabled());
|
2011-12-29 17:05:34 -05:00
|
|
|
}
|
2018-09-22 19:15:08 -04:00
|
|
|
new wxRibbonPage(m_ribbon, wxID_ANY, "Empty Page", empty_xpm);
|
2012-06-30 12:33:18 -04:00
|
|
|
{
|
2018-09-22 19:15:08 -04:00
|
|
|
wxRibbonPage* page = new wxRibbonPage(m_ribbon, wxID_ANY, "Another Page", empty_xpm);
|
|
|
|
wxRibbonPanel *panel = new wxRibbonPanel(page, wxID_ANY, "Page manipulation", ribbon_xpm);
|
2012-06-30 12:33:18 -04:00
|
|
|
wxRibbonButtonBar *bar = new wxRibbonButtonBar(panel, wxID_ANY);
|
2018-09-22 19:15:08 -04:00
|
|
|
bar->AddButton(ID_REMOVE_PAGE, "Remove", wxArtProvider::GetBitmap(wxART_DELETE, wxART_OTHER, wxSize(24, 24)));
|
|
|
|
bar->AddButton(ID_HIDE_PAGES, "Hide Pages", ribbon_xpm);
|
|
|
|
bar->AddButton(ID_SHOW_PAGES, "Show Pages", ribbon_xpm);
|
2018-03-15 11:34:50 -04:00
|
|
|
|
2018-09-22 19:15:08 -04:00
|
|
|
panel = new wxRibbonPanel(page, wxID_ANY, "Button bar manipulation", ribbon_xpm);
|
2018-03-15 11:34:50 -04:00
|
|
|
m_mutable_button_bar = new wxRibbonButtonBar(panel, wxID_ANY);
|
2018-09-22 19:15:08 -04:00
|
|
|
m_mutable_button_bar->AddButton(ID_PLUS_MINUS, "+/-",
|
2018-03-15 11:34:50 -04:00
|
|
|
wxArtProvider::GetBitmap(wxART_PLUS, wxART_OTHER, wxSize(24, 24)));
|
|
|
|
m_plus_minus_state = false;
|
2018-09-22 19:15:08 -04:00
|
|
|
m_mutable_button_bar->AddButton(ID_CHANGE_LABEL, "short", ribbon_xpm);
|
|
|
|
m_mutable_button_bar->SetButtonTextMinWidth(ID_CHANGE_LABEL, "some long text");
|
2018-03-15 11:34:50 -04:00
|
|
|
m_change_label_state = false;
|
|
|
|
|
2018-09-22 19:15:08 -04:00
|
|
|
panel = new wxRibbonPanel(page, wxID_ANY, "Always medium buttons", ribbon_xpm);
|
2018-03-15 11:34:50 -04:00
|
|
|
bar = new wxRibbonButtonBar(panel, wxID_ANY);
|
2018-09-22 19:15:08 -04:00
|
|
|
bar->AddButton(ID_SMALL_BUTTON_1, "Button 1", ribbon_xpm);
|
2018-03-15 11:34:50 -04:00
|
|
|
bar->SetButtonMaxSizeClass(ID_SMALL_BUTTON_1, wxRIBBON_BUTTONBAR_BUTTON_MEDIUM);
|
2018-09-22 19:15:08 -04:00
|
|
|
bar->AddButton(ID_SMALL_BUTTON_2, "Button 2", ribbon_xpm);
|
2018-03-15 11:34:50 -04:00
|
|
|
bar->SetButtonMaxSizeClass(ID_SMALL_BUTTON_2, wxRIBBON_BUTTONBAR_BUTTON_MEDIUM);
|
2018-09-22 19:15:08 -04:00
|
|
|
bar->AddButton(ID_SMALL_BUTTON_3, "Button 3", ribbon_xpm);
|
|
|
|
bar->AddButton(ID_SMALL_BUTTON_4, "Button 4", ribbon_xpm);
|
|
|
|
bar->AddButton(ID_SMALL_BUTTON_5, "Button 5", ribbon_xpm);
|
2018-03-15 11:34:50 -04:00
|
|
|
bar->SetButtonMaxSizeClass(ID_SMALL_BUTTON_5, wxRIBBON_BUTTONBAR_BUTTON_MEDIUM);
|
2018-09-22 19:15:08 -04:00
|
|
|
bar->AddButton(ID_SMALL_BUTTON_6, "Button 6", ribbon_xpm);
|
2018-03-15 11:34:50 -04:00
|
|
|
bar->SetButtonMaxSizeClass(ID_SMALL_BUTTON_6, wxRIBBON_BUTTONBAR_BUTTON_MEDIUM);
|
2012-06-30 12:33:18 -04:00
|
|
|
}
|
2018-09-22 19:15:08 -04:00
|
|
|
new wxRibbonPage(m_ribbon, wxID_ANY, "Highlight Page", empty_xpm);
|
2012-08-15 19:34:36 -04:00
|
|
|
m_ribbon->AddPageHighlight(m_ribbon->GetPageCount()-1);
|
2009-09-16 08:06:02 -04:00
|
|
|
|
2018-03-15 11:34:50 -04:00
|
|
|
{
|
2018-09-22 19:15:08 -04:00
|
|
|
wxRibbonPage* page = new wxRibbonPage(m_ribbon, wxID_ANY, "Advanced", empty_xpm);
|
|
|
|
wxRibbonPanel* panel = new wxRibbonPanel(page, wxID_ANY, "Button bar manipulation", ribbon_xpm);
|
2018-03-15 11:34:50 -04:00
|
|
|
m_mutable_button_bar = new wxRibbonButtonBar(panel, wxID_ANY);
|
2018-09-22 19:15:08 -04:00
|
|
|
m_mutable_button_bar->AddButton(ID_PLUS_MINUS, "+/-",
|
2018-03-15 11:34:50 -04:00
|
|
|
wxArtProvider::GetBitmap(wxART_PLUS, wxART_OTHER, wxSize(24, 24)));
|
|
|
|
m_plus_minus_state = false;
|
2018-09-22 19:15:08 -04:00
|
|
|
m_mutable_button_bar->AddButton(ID_CHANGE_LABEL, "short", ribbon_xpm);
|
|
|
|
m_mutable_button_bar->SetButtonTextMinWidth(ID_CHANGE_LABEL, "some long text");
|
2018-03-15 11:34:50 -04:00
|
|
|
m_change_label_state = false;
|
|
|
|
|
2018-09-22 19:15:08 -04:00
|
|
|
panel = new wxRibbonPanel(page, wxID_ANY, "Always medium buttons", ribbon_xpm);
|
2018-03-15 11:34:50 -04:00
|
|
|
wxRibbonButtonBar* bar = new wxRibbonButtonBar(panel, wxID_ANY);
|
2018-09-22 19:15:08 -04:00
|
|
|
bar->AddButton(ID_SMALL_BUTTON_1, "Button 1", ribbon_xpm);
|
2018-03-15 11:34:50 -04:00
|
|
|
bar->SetButtonMaxSizeClass(ID_SMALL_BUTTON_1, wxRIBBON_BUTTONBAR_BUTTON_MEDIUM);
|
2018-09-22 19:15:08 -04:00
|
|
|
bar->AddButton(ID_SMALL_BUTTON_2, "Button 2", ribbon_xpm);
|
2018-03-15 11:34:50 -04:00
|
|
|
bar->SetButtonMaxSizeClass(ID_SMALL_BUTTON_2, wxRIBBON_BUTTONBAR_BUTTON_MEDIUM);
|
2018-09-22 19:15:08 -04:00
|
|
|
bar->AddButton(ID_SMALL_BUTTON_3, "Button 3", ribbon_xpm);
|
|
|
|
bar->AddButton(ID_SMALL_BUTTON_4, "Button 4", ribbon_xpm);
|
|
|
|
bar->AddButton(ID_SMALL_BUTTON_5, "Button 5", ribbon_xpm);
|
2018-03-15 11:34:50 -04:00
|
|
|
bar->SetButtonMaxSizeClass(ID_SMALL_BUTTON_5, wxRIBBON_BUTTONBAR_BUTTON_MEDIUM);
|
2018-09-22 19:15:08 -04:00
|
|
|
bar->AddButton(ID_SMALL_BUTTON_6, "Button 6", ribbon_xpm);
|
2018-03-15 11:34:50 -04:00
|
|
|
bar->SetButtonMaxSizeClass(ID_SMALL_BUTTON_6, wxRIBBON_BUTTONBAR_BUTTON_MEDIUM);
|
|
|
|
}
|
|
|
|
|
2009-09-16 08:06:02 -04:00
|
|
|
m_ribbon->Realize();
|
|
|
|
|
|
|
|
m_logwindow = new wxTextCtrl(this, wxID_ANY, wxEmptyString,
|
|
|
|
wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY |
|
|
|
|
wxTE_LEFT | wxTE_BESTWRAP | wxBORDER_NONE);
|
|
|
|
|
2011-01-06 17:02:07 -05:00
|
|
|
m_togglePanels = new wxToggleButton(this, ID_TOGGLE_PANELS, "&Toggle panels");
|
|
|
|
m_togglePanels->SetValue(true);
|
|
|
|
|
2009-09-16 08:06:02 -04:00
|
|
|
wxSizer *s = new wxBoxSizer(wxVERTICAL);
|
|
|
|
|
|
|
|
s->Add(m_ribbon, 0, wxEXPAND);
|
|
|
|
s->Add(m_logwindow, 1, wxEXPAND);
|
2011-01-06 17:02:07 -05:00
|
|
|
s->Add(m_togglePanels, wxSizerFlags().Border());
|
2009-09-16 08:06:02 -04:00
|
|
|
|
|
|
|
SetSizer(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::SetBarStyle(long style)
|
|
|
|
{
|
|
|
|
m_ribbon->Freeze();
|
|
|
|
m_ribbon->SetWindowStyleFlag(style);
|
|
|
|
wxBoxSizer *pTopSize = reinterpret_cast<wxBoxSizer*>(GetSizer());
|
|
|
|
wxRibbonToolBar *pToolbar = wxDynamicCast(FindWindow(ID_MAIN_TOOLBAR), wxRibbonToolBar);
|
|
|
|
if(style & wxRIBBON_BAR_FLOW_VERTICAL)
|
|
|
|
{
|
|
|
|
m_ribbon->SetTabCtrlMargins(10, 10);
|
|
|
|
pTopSize->SetOrientation(wxHORIZONTAL);
|
|
|
|
if(pToolbar)
|
|
|
|
pToolbar->SetRows(3, 5);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_ribbon->SetTabCtrlMargins(50, 20);
|
|
|
|
pTopSize->SetOrientation(wxVERTICAL);
|
|
|
|
if(pToolbar)
|
|
|
|
pToolbar->SetRows(2, 3);
|
|
|
|
}
|
|
|
|
m_ribbon->Realise();
|
|
|
|
Layout();
|
|
|
|
m_ribbon->Thaw();
|
|
|
|
}
|
|
|
|
|
|
|
|
MyFrame::~MyFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
class ColourClientData : public wxClientData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ColourClientData(const wxString& name, const wxColour& colour)
|
|
|
|
: m_name(name), m_colour(colour) {}
|
|
|
|
|
|
|
|
const wxString& GetName() const {return m_name;}
|
|
|
|
const wxColour& GetColour() const {return m_colour;}
|
|
|
|
|
|
|
|
private:
|
|
|
|
wxString m_name;
|
|
|
|
wxColour m_colour;
|
|
|
|
};
|
|
|
|
|
|
|
|
wxRibbonGallery* MyFrame::PopulateColoursPanel(wxWindow* panel,
|
|
|
|
wxColour def, int gallery_id)
|
|
|
|
{
|
|
|
|
wxRibbonGallery *gallery = wxDynamicCast(panel->FindWindow(gallery_id), wxRibbonGallery);
|
|
|
|
if(gallery)
|
|
|
|
gallery->Clear();
|
|
|
|
else
|
|
|
|
gallery = new wxRibbonGallery(panel, gallery_id);
|
|
|
|
wxMemoryDC& dc = m_bitmap_creation_dc;
|
2010-09-30 07:44:45 -04:00
|
|
|
wxRibbonGalleryItem *def_item =
|
2018-09-22 19:15:08 -04:00
|
|
|
AddColourToGallery(gallery, "Default", dc, &def);
|
2009-09-16 08:06:02 -04:00
|
|
|
gallery->SetSelection(def_item);
|
2018-09-22 19:15:08 -04:00
|
|
|
AddColourToGallery(gallery, "BLUE", dc);
|
|
|
|
AddColourToGallery(gallery, "BLUE VIOLET", dc);
|
|
|
|
AddColourToGallery(gallery, "BROWN", dc);
|
|
|
|
AddColourToGallery(gallery, "CADET BLUE", dc);
|
|
|
|
AddColourToGallery(gallery, "CORAL", dc);
|
|
|
|
AddColourToGallery(gallery, "CYAN", dc);
|
|
|
|
AddColourToGallery(gallery, "DARK GREEN", dc);
|
|
|
|
AddColourToGallery(gallery, "DARK ORCHID", dc);
|
|
|
|
AddColourToGallery(gallery, "FIREBRICK", dc);
|
|
|
|
AddColourToGallery(gallery, "GOLD", dc);
|
|
|
|
AddColourToGallery(gallery, "GOLDENROD", dc);
|
|
|
|
AddColourToGallery(gallery, "GREEN", dc);
|
|
|
|
AddColourToGallery(gallery, "INDIAN RED", dc);
|
|
|
|
AddColourToGallery(gallery, "KHAKI", dc);
|
|
|
|
AddColourToGallery(gallery, "LIGHT BLUE", dc);
|
|
|
|
AddColourToGallery(gallery, "LIME GREEN", dc);
|
|
|
|
AddColourToGallery(gallery, "MAGENTA", dc);
|
|
|
|
AddColourToGallery(gallery, "MAROON", dc);
|
|
|
|
AddColourToGallery(gallery, "NAVY", dc);
|
|
|
|
AddColourToGallery(gallery, "ORANGE", dc);
|
|
|
|
AddColourToGallery(gallery, "ORCHID", dc);
|
|
|
|
AddColourToGallery(gallery, "PINK", dc);
|
|
|
|
AddColourToGallery(gallery, "PLUM", dc);
|
|
|
|
AddColourToGallery(gallery, "PURPLE", dc);
|
|
|
|
AddColourToGallery(gallery, "RED", dc);
|
|
|
|
AddColourToGallery(gallery, "SALMON", dc);
|
|
|
|
AddColourToGallery(gallery, "SEA GREEN", dc);
|
|
|
|
AddColourToGallery(gallery, "SIENNA", dc);
|
|
|
|
AddColourToGallery(gallery, "SKY BLUE", dc);
|
|
|
|
AddColourToGallery(gallery, "TAN", dc);
|
|
|
|
AddColourToGallery(gallery, "THISTLE", dc);
|
|
|
|
AddColourToGallery(gallery, "TURQUOISE", dc);
|
|
|
|
AddColourToGallery(gallery, "VIOLET", dc);
|
|
|
|
AddColourToGallery(gallery, "VIOLET RED", dc);
|
|
|
|
AddColourToGallery(gallery, "WHEAT", dc);
|
|
|
|
AddColourToGallery(gallery, "WHITE", dc);
|
|
|
|
AddColourToGallery(gallery, "YELLOW", dc);
|
2009-09-16 08:06:02 -04:00
|
|
|
|
|
|
|
return gallery;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxColour MyFrame::GetGalleryColour(wxRibbonGallery *gallery,
|
|
|
|
wxRibbonGalleryItem* item, wxString* name)
|
|
|
|
{
|
|
|
|
ColourClientData *data = (ColourClientData*)gallery->GetItemClientObject(item);
|
|
|
|
if(name != NULL)
|
|
|
|
*name = data->GetName();
|
|
|
|
return data->GetColour();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnHoveredColourChange(wxRibbonGalleryEvent& evt)
|
|
|
|
{
|
|
|
|
// Set the background of the gallery to the hovered colour, or back to the
|
|
|
|
// default if there is no longer a hovered item.
|
|
|
|
|
|
|
|
wxRibbonGallery *gallery = evt.GetGallery();
|
|
|
|
wxRibbonArtProvider *provider = gallery->GetArtProvider();
|
|
|
|
|
|
|
|
if(evt.GetGalleryItem() != NULL)
|
|
|
|
{
|
|
|
|
if(provider == m_ribbon->GetArtProvider())
|
|
|
|
{
|
|
|
|
provider = provider->Clone();
|
|
|
|
gallery->SetArtProvider(provider);
|
|
|
|
}
|
|
|
|
provider->SetColour(wxRIBBON_ART_GALLERY_HOVER_BACKGROUND_COLOUR,
|
|
|
|
GetGalleryColour(evt.GetGallery(), evt.GetGalleryItem(), NULL));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(provider != m_ribbon->GetArtProvider())
|
|
|
|
{
|
|
|
|
gallery->SetArtProvider(m_ribbon->GetArtProvider());
|
|
|
|
delete provider;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnPrimaryColourSelect(wxRibbonGalleryEvent& evt)
|
|
|
|
{
|
|
|
|
wxString name;
|
|
|
|
wxColour colour = GetGalleryColour(evt.GetGallery(), evt.GetGalleryItem(), &name);
|
2018-09-28 21:45:15 -04:00
|
|
|
AddText("Colour \"" + name + "\" selected as primary.");
|
2009-09-16 08:06:02 -04:00
|
|
|
wxColour secondary, tertiary;
|
|
|
|
m_ribbon->GetArtProvider()->GetColourScheme(NULL, &secondary, &tertiary);
|
|
|
|
m_ribbon->GetArtProvider()->SetColourScheme(colour, secondary, tertiary);
|
|
|
|
ResetGalleryArtProviders();
|
|
|
|
m_ribbon->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnSecondaryColourSelect(wxRibbonGalleryEvent& evt)
|
|
|
|
{
|
|
|
|
wxString name;
|
|
|
|
wxColour colour = GetGalleryColour(evt.GetGallery(), evt.GetGalleryItem(), &name);
|
2018-09-28 21:45:15 -04:00
|
|
|
AddText("Colour \"" + name + "\" selected as secondary.");
|
2009-09-16 08:06:02 -04:00
|
|
|
wxColour primary, tertiary;
|
|
|
|
m_ribbon->GetArtProvider()->GetColourScheme(&primary, NULL, &tertiary);
|
|
|
|
m_ribbon->GetArtProvider()->SetColourScheme(primary, colour, tertiary);
|
|
|
|
ResetGalleryArtProviders();
|
|
|
|
m_ribbon->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::ResetGalleryArtProviders()
|
|
|
|
{
|
|
|
|
if(m_primary_gallery->GetArtProvider() != m_ribbon->GetArtProvider())
|
|
|
|
{
|
|
|
|
delete m_primary_gallery->GetArtProvider();
|
|
|
|
m_primary_gallery->SetArtProvider(m_ribbon->GetArtProvider());
|
|
|
|
}
|
|
|
|
if(m_secondary_gallery->GetArtProvider() != m_ribbon->GetArtProvider())
|
|
|
|
{
|
|
|
|
delete m_secondary_gallery->GetArtProvider();
|
|
|
|
m_secondary_gallery->SetArtProvider(m_ribbon->GetArtProvider());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-29 17:05:34 -05:00
|
|
|
void MyFrame::OnChangeText1(wxRibbonButtonBarEvent& WXUNUSED(evt))
|
|
|
|
{
|
2018-09-22 19:15:08 -04:00
|
|
|
m_new_text = "One";
|
2011-12-29 17:05:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnChangeText2(wxRibbonButtonBarEvent& WXUNUSED(evt))
|
|
|
|
{
|
2018-09-22 19:15:08 -04:00
|
|
|
m_new_text = "Two";
|
2011-12-29 17:05:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnEnable(wxRibbonButtonBarEvent& WXUNUSED(evt))
|
|
|
|
{
|
|
|
|
m_bEnabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnDisable(wxRibbonButtonBarEvent& WXUNUSED(evt))
|
|
|
|
{
|
|
|
|
m_bEnabled = false;
|
|
|
|
}
|
|
|
|
|
2012-09-28 19:49:20 -04:00
|
|
|
void MyFrame::OnDisabled(wxRibbonButtonBarEvent& WXUNUSED(evt))
|
|
|
|
{
|
|
|
|
AddText("ERROR: Disabled button activated (not supposed to happen)");
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnEnableUpdated(wxRibbonButtonBarEvent& WXUNUSED(evt))
|
|
|
|
{
|
|
|
|
AddText("Button activated");
|
|
|
|
}
|
|
|
|
|
2011-12-29 17:05:34 -05:00
|
|
|
void MyFrame::OnCheck(wxRibbonButtonBarEvent& WXUNUSED(evt))
|
|
|
|
{
|
|
|
|
m_bChecked = !m_bChecked;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnEnableUpdateUI(wxUpdateUIEvent& evt)
|
|
|
|
{
|
|
|
|
evt.Enable(m_bEnabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnCheckUpdateUI(wxUpdateUIEvent& evt)
|
|
|
|
{
|
|
|
|
evt.Check(m_bChecked);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnChangeTextUpdateUI(wxUpdateUIEvent& evt)
|
|
|
|
{
|
|
|
|
if ( !m_new_text.IsEmpty() )
|
|
|
|
{
|
|
|
|
evt.SetText(m_new_text);
|
2018-09-22 19:15:08 -04:00
|
|
|
m_new_text = "";
|
2011-12-29 17:05:34 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-16 08:06:02 -04:00
|
|
|
void MyFrame::OnSelectionExpandHButton(wxRibbonButtonBarEvent& WXUNUSED(evt))
|
|
|
|
{
|
2018-09-22 19:15:08 -04:00
|
|
|
AddText("Expand selection horizontally button clicked.");
|
2009-09-16 08:06:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnSelectionExpandVButton(wxRibbonButtonBarEvent& WXUNUSED(evt))
|
|
|
|
{
|
2018-09-22 19:15:08 -04:00
|
|
|
AddText("Expand selection vertically button clicked.");
|
2009-09-16 08:06:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnSelectionContractButton(wxRibbonButtonBarEvent& WXUNUSED(evt))
|
|
|
|
{
|
2018-09-22 19:15:08 -04:00
|
|
|
AddText("Contract selection button clicked.");
|
2009-09-16 08:06:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnCircleButton(wxRibbonButtonBarEvent& WXUNUSED(evt))
|
|
|
|
{
|
2018-09-22 19:15:08 -04:00
|
|
|
AddText("Circle button clicked.");
|
2009-09-16 08:06:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnCrossButton(wxRibbonButtonBarEvent& WXUNUSED(evt))
|
|
|
|
{
|
2018-09-22 19:15:08 -04:00
|
|
|
AddText("Cross button clicked.");
|
2009-09-16 08:06:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnTriangleButton(wxRibbonButtonBarEvent& WXUNUSED(evt))
|
|
|
|
{
|
2018-09-22 19:15:08 -04:00
|
|
|
AddText("Triangle button clicked.");
|
2009-09-16 08:06:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnTriangleDropdown(wxRibbonButtonBarEvent& evt)
|
|
|
|
{
|
|
|
|
wxMenu menu;
|
2018-09-22 19:15:08 -04:00
|
|
|
menu.Append(wxID_ANY, "Equilateral");
|
|
|
|
menu.Append(wxID_ANY, "Isosceles");
|
|
|
|
menu.Append(wxID_ANY, "Scalene");
|
2009-09-16 08:06:02 -04:00
|
|
|
|
|
|
|
evt.PopupMenu(&menu);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnSquareButton(wxRibbonButtonBarEvent& WXUNUSED(evt))
|
|
|
|
{
|
2018-09-22 19:15:08 -04:00
|
|
|
AddText("Square button clicked.");
|
2009-09-16 08:06:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnPolygonDropdown(wxRibbonButtonBarEvent& evt)
|
|
|
|
{
|
|
|
|
wxMenu menu;
|
2018-09-22 19:15:08 -04:00
|
|
|
menu.Append(wxID_ANY, "Pentagon (5 sided)");
|
|
|
|
menu.Append(wxID_ANY, "Hexagon (6 sided)");
|
|
|
|
menu.Append(wxID_ANY, "Heptagon (7 sided)");
|
|
|
|
menu.Append(wxID_ANY, "Octogon (8 sided)");
|
|
|
|
menu.Append(wxID_ANY, "Nonagon (9 sided)");
|
|
|
|
menu.Append(wxID_ANY, "Decagon (10 sided)");
|
2009-09-16 08:06:02 -04:00
|
|
|
|
|
|
|
evt.PopupMenu(&menu);
|
|
|
|
}
|
|
|
|
|
2012-01-08 09:52:56 -05:00
|
|
|
void MyFrame::OnJustify(wxRibbonToolBarEvent& evt)
|
|
|
|
{
|
|
|
|
long style = m_logwindow->GetWindowStyle() &
|
|
|
|
~(wxTE_LEFT | wxTE_CENTER | wxTE_RIGHT);
|
|
|
|
switch(evt.GetId())
|
|
|
|
{
|
|
|
|
case wxID_JUSTIFY_LEFT:
|
|
|
|
m_logwindow->SetWindowStyle(style | wxTE_LEFT);
|
|
|
|
break;
|
|
|
|
case wxID_JUSTIFY_CENTER:
|
|
|
|
m_logwindow->SetWindowStyle(style | wxTE_CENTER);
|
|
|
|
break;
|
|
|
|
case wxID_JUSTIFY_RIGHT:
|
|
|
|
m_logwindow->SetWindowStyle(style | wxTE_RIGHT);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnJustifyUpdateUI(wxUpdateUIEvent& evt)
|
|
|
|
{
|
|
|
|
switch(evt.GetId())
|
|
|
|
{
|
|
|
|
case wxID_JUSTIFY_LEFT:
|
|
|
|
evt.Check(!m_logwindow->HasFlag(wxTE_CENTER | wxTE_RIGHT));
|
|
|
|
break;
|
|
|
|
case wxID_JUSTIFY_CENTER:
|
|
|
|
evt.Check(m_logwindow->HasFlag(wxTE_CENTER));
|
|
|
|
break;
|
|
|
|
case wxID_JUSTIFY_RIGHT:
|
|
|
|
evt.Check(m_logwindow->HasFlag(wxTE_RIGHT));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-16 08:06:02 -04:00
|
|
|
void MyFrame::OnNew(wxRibbonToolBarEvent& WXUNUSED(evt))
|
|
|
|
{
|
2018-09-22 19:15:08 -04:00
|
|
|
AddText("New button clicked.");
|
2009-09-16 08:06:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnNewDropdown(wxRibbonToolBarEvent& evt)
|
|
|
|
{
|
|
|
|
wxMenu menu;
|
2018-09-22 19:15:08 -04:00
|
|
|
menu.Append(wxID_ANY, "New Document");
|
|
|
|
menu.Append(wxID_ANY, "New Template");
|
|
|
|
menu.Append(wxID_ANY, "New Mail");
|
2009-09-16 08:06:02 -04:00
|
|
|
|
|
|
|
evt.PopupMenu(&menu);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnPrint(wxRibbonToolBarEvent& WXUNUSED(evt))
|
|
|
|
{
|
2018-09-22 19:15:08 -04:00
|
|
|
AddText("Print button clicked.");
|
2009-09-16 08:06:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnPrintDropdown(wxRibbonToolBarEvent& evt)
|
|
|
|
{
|
|
|
|
wxMenu menu;
|
2018-09-22 19:15:08 -04:00
|
|
|
menu.Append(wxID_ANY, "Print");
|
|
|
|
menu.Append(wxID_ANY, "Preview");
|
|
|
|
menu.Append(wxID_ANY, "Options");
|
2009-09-16 08:06:02 -04:00
|
|
|
|
|
|
|
evt.PopupMenu(&menu);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnRedoDropdown(wxRibbonToolBarEvent& evt)
|
|
|
|
{
|
|
|
|
wxMenu menu;
|
2018-09-22 19:15:08 -04:00
|
|
|
menu.Append(wxID_ANY, "Redo E");
|
|
|
|
menu.Append(wxID_ANY, "Redo F");
|
|
|
|
menu.Append(wxID_ANY, "Redo G");
|
2009-09-16 08:06:02 -04:00
|
|
|
|
|
|
|
evt.PopupMenu(&menu);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnUndoDropdown(wxRibbonToolBarEvent& evt)
|
|
|
|
{
|
|
|
|
wxMenu menu;
|
2018-09-22 19:15:08 -04:00
|
|
|
menu.Append(wxID_ANY, "Undo C");
|
|
|
|
menu.Append(wxID_ANY, "Undo B");
|
|
|
|
menu.Append(wxID_ANY, "Undo A");
|
2009-09-16 08:06:02 -04:00
|
|
|
|
|
|
|
evt.PopupMenu(&menu);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnPositionTopLabels(wxCommandEvent& WXUNUSED(evt))
|
|
|
|
{
|
|
|
|
SetBarStyle(wxRIBBON_BAR_DEFAULT_STYLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnPositionTopIcons(wxCommandEvent& WXUNUSED(evt))
|
|
|
|
{
|
|
|
|
SetBarStyle((wxRIBBON_BAR_DEFAULT_STYLE &~wxRIBBON_BAR_SHOW_PAGE_LABELS)
|
|
|
|
| wxRIBBON_BAR_SHOW_PAGE_ICONS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnPositionTopBoth(wxCommandEvent& WXUNUSED(evt))
|
|
|
|
{
|
|
|
|
SetBarStyle(wxRIBBON_BAR_DEFAULT_STYLE | wxRIBBON_BAR_SHOW_PAGE_ICONS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnPositionLeftLabels(wxCommandEvent& WXUNUSED(evt))
|
|
|
|
{
|
|
|
|
SetBarStyle(wxRIBBON_BAR_DEFAULT_STYLE | wxRIBBON_BAR_FLOW_VERTICAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnPositionLeftIcons(wxCommandEvent& WXUNUSED(evt))
|
|
|
|
{
|
|
|
|
SetBarStyle((wxRIBBON_BAR_DEFAULT_STYLE &~wxRIBBON_BAR_SHOW_PAGE_LABELS) |
|
|
|
|
wxRIBBON_BAR_SHOW_PAGE_ICONS | wxRIBBON_BAR_FLOW_VERTICAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnPositionLeftBoth(wxCommandEvent& WXUNUSED(evt))
|
|
|
|
{
|
|
|
|
SetBarStyle(wxRIBBON_BAR_DEFAULT_STYLE | wxRIBBON_BAR_SHOW_PAGE_ICONS |
|
|
|
|
wxRIBBON_BAR_FLOW_VERTICAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnPositionTop(wxRibbonToolBarEvent& evt)
|
|
|
|
{
|
|
|
|
OnPositionTopLabels(evt);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnPositionTopDropdown(wxRibbonToolBarEvent& evt)
|
|
|
|
{
|
|
|
|
wxMenu menu;
|
2018-09-22 19:15:08 -04:00
|
|
|
menu.Append(ID_POSITION_TOP, "Top with Labels");
|
|
|
|
menu.Append(ID_POSITION_TOP_ICONS, "Top with Icons");
|
|
|
|
menu.Append(ID_POSITION_TOP_BOTH, "Top with Both");
|
2009-09-16 08:06:02 -04:00
|
|
|
evt.PopupMenu(&menu);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnPositionLeft(wxRibbonToolBarEvent& evt)
|
|
|
|
{
|
|
|
|
OnPositionLeftIcons(evt);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnPositionLeftDropdown(wxRibbonToolBarEvent& evt)
|
|
|
|
{
|
|
|
|
wxMenu menu;
|
2018-09-22 19:15:08 -04:00
|
|
|
menu.Append(ID_POSITION_LEFT, "Left with Icons");
|
|
|
|
menu.Append(ID_POSITION_LEFT_LABELS, "Left with Labels");
|
|
|
|
menu.Append(ID_POSITION_LEFT_BOTH, "Left with Both");
|
2009-09-16 08:06:02 -04:00
|
|
|
evt.PopupMenu(&menu);
|
|
|
|
}
|
|
|
|
|
2011-01-06 17:02:07 -05:00
|
|
|
void MyFrame::OnTogglePanels(wxCommandEvent& WXUNUSED(evt))
|
|
|
|
{
|
|
|
|
m_ribbon->ShowPanels(m_togglePanels->GetValue());
|
|
|
|
}
|
|
|
|
|
2012-06-03 15:17:09 -04:00
|
|
|
void MyFrame::OnExtButton(wxRibbonPanelEvent& WXUNUSED(evt))
|
|
|
|
{
|
|
|
|
wxMessageBox("Extension button clicked");
|
|
|
|
}
|
|
|
|
|
2009-09-16 08:06:02 -04:00
|
|
|
void MyFrame::AddText(wxString msg)
|
|
|
|
{
|
|
|
|
m_logwindow->AppendText(msg);
|
2018-09-22 19:15:08 -04:00
|
|
|
m_logwindow->AppendText("\n");
|
2009-09-16 08:06:02 -04:00
|
|
|
m_ribbon->DismissExpandedPanel();
|
|
|
|
}
|
|
|
|
|
|
|
|
wxRibbonGalleryItem* MyFrame::AddColourToGallery(wxRibbonGallery *gallery,
|
|
|
|
wxString colour, wxMemoryDC& dc,
|
|
|
|
wxColour* value)
|
|
|
|
{
|
|
|
|
wxRibbonGalleryItem* item = NULL;
|
2010-04-01 12:59:34 -04:00
|
|
|
wxColour c;
|
2018-09-22 19:15:08 -04:00
|
|
|
if (colour != "Default")
|
2010-04-01 12:59:34 -04:00
|
|
|
c = wxColour(colour);
|
|
|
|
if (!c.IsOk())
|
2009-09-16 08:06:02 -04:00
|
|
|
c = *value;
|
|
|
|
if(c.IsOk())
|
|
|
|
{
|
|
|
|
const int iWidth = 64;
|
|
|
|
const int iHeight = 40;
|
|
|
|
|
|
|
|
wxBitmap bitmap(iWidth, iHeight);
|
|
|
|
dc.SelectObject(bitmap);
|
|
|
|
wxBrush b(c);
|
|
|
|
dc.SetPen(*wxBLACK_PEN);
|
|
|
|
dc.SetBrush(b);
|
|
|
|
dc.DrawRectangle(0, 0, iWidth, iHeight);
|
|
|
|
|
|
|
|
colour = colour.Mid(0, 1) + colour.Mid(1).Lower();
|
|
|
|
wxSize size = dc.GetTextExtent(colour);
|
|
|
|
wxColour foreground = wxColour(~c.Red(), ~c.Green(), ~c.Blue());
|
|
|
|
if(abs(foreground.Red() - c.Red()) + abs(foreground.Blue() - c.Blue())
|
|
|
|
+ abs(foreground.Green() - c.Green()) < 64)
|
|
|
|
{
|
|
|
|
// Foreground too similar to background - use a different
|
|
|
|
// strategy to find a contrasting colour
|
|
|
|
foreground = wxColour((c.Red() + 64) % 256, 255 - c.Green(),
|
|
|
|
(c.Blue() + 192) % 256);
|
|
|
|
}
|
|
|
|
dc.SetTextForeground(foreground);
|
|
|
|
dc.DrawText(colour, (iWidth - size.GetWidth() + 1) / 2,
|
|
|
|
(iHeight - size.GetHeight()) / 2);
|
|
|
|
dc.SelectObjectAsSource(wxNullBitmap);
|
|
|
|
|
|
|
|
item = gallery->Append(bitmap, wxID_ANY);
|
|
|
|
gallery->SetItemClientObject(item, new ColourClientData(colour, c));
|
|
|
|
}
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnColourGalleryButton(wxCommandEvent& evt)
|
|
|
|
{
|
|
|
|
wxRibbonGallery *gallery = wxDynamicCast(evt.GetEventObject(), wxRibbonGallery);
|
|
|
|
if(gallery == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_ribbon->DismissExpandedPanel();
|
|
|
|
if(gallery->GetSelection())
|
|
|
|
m_colour_data.SetColour(GetGalleryColour(gallery, gallery->GetSelection(), NULL));
|
|
|
|
wxColourDialog dlg(this, &m_colour_data);
|
|
|
|
if(dlg.ShowModal() == wxID_OK)
|
|
|
|
{
|
|
|
|
m_colour_data = dlg.GetColourData();
|
|
|
|
wxColour clr = m_colour_data.GetColour();
|
|
|
|
|
|
|
|
// Try to find colour in gallery
|
|
|
|
wxRibbonGalleryItem *item = NULL;
|
|
|
|
for(unsigned int i = 0; i < gallery->GetCount(); ++i)
|
|
|
|
{
|
|
|
|
item = gallery->GetItem(i);
|
|
|
|
if(GetGalleryColour(gallery, item, NULL) == clr)
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
item = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Colour not in gallery - add it
|
|
|
|
if(item == NULL)
|
|
|
|
{
|
|
|
|
item = AddColourToGallery(gallery,
|
|
|
|
clr.GetAsString(wxC2S_HTML_SYNTAX), m_bitmap_creation_dc,
|
|
|
|
&clr);
|
|
|
|
gallery->Realise();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set selection
|
|
|
|
gallery->EnsureVisible(item);
|
|
|
|
gallery->SetSelection(item);
|
|
|
|
|
|
|
|
// Send an event to respond to the selection change
|
2013-04-25 06:11:03 -04:00
|
|
|
wxRibbonGalleryEvent dummy(wxEVT_RIBBONGALLERY_SELECTED, gallery->GetId());
|
2009-09-16 08:06:02 -04:00
|
|
|
dummy.SetEventObject(gallery);
|
|
|
|
dummy.SetGallery(gallery);
|
|
|
|
dummy.SetGalleryItem(item);
|
|
|
|
ProcessWindowEvent(dummy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnDefaultProvider(wxRibbonButtonBarEvent& WXUNUSED(evt))
|
|
|
|
{
|
|
|
|
m_ribbon->DismissExpandedPanel();
|
|
|
|
SetArtProvider(new wxRibbonDefaultArtProvider);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnAUIProvider(wxRibbonButtonBarEvent& WXUNUSED(evt))
|
|
|
|
{
|
|
|
|
m_ribbon->DismissExpandedPanel();
|
|
|
|
SetArtProvider(new wxRibbonAUIArtProvider);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnMSWProvider(wxRibbonButtonBarEvent& WXUNUSED(evt))
|
|
|
|
{
|
|
|
|
m_ribbon->DismissExpandedPanel();
|
|
|
|
SetArtProvider(new wxRibbonMSWArtProvider);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::SetArtProvider(wxRibbonArtProvider *prov)
|
|
|
|
{
|
|
|
|
m_ribbon->Freeze();
|
|
|
|
m_ribbon->SetArtProvider(prov);
|
|
|
|
|
|
|
|
prov->GetColourScheme(&m_default_primary, &m_default_secondary,
|
|
|
|
&m_default_tertiary);
|
|
|
|
PopulateColoursPanel(m_primary_gallery->GetParent(), m_default_primary,
|
|
|
|
ID_PRIMARY_COLOUR);
|
|
|
|
PopulateColoursPanel(m_secondary_gallery->GetParent(), m_default_secondary,
|
|
|
|
ID_SECONDARY_COLOUR);
|
|
|
|
|
|
|
|
m_ribbon->Realize();
|
|
|
|
m_ribbon->Thaw();
|
|
|
|
GetSizer()->Layout();
|
|
|
|
}
|
2012-06-30 12:33:18 -04:00
|
|
|
|
|
|
|
void MyFrame::OnRemovePage(wxRibbonButtonBarEvent& WXUNUSED(evt))
|
|
|
|
{
|
|
|
|
size_t n = m_ribbon->GetPageCount();
|
|
|
|
if(n > 0)
|
|
|
|
{
|
|
|
|
m_ribbon->DeletePage(n-1);
|
|
|
|
m_ribbon->Realize();
|
|
|
|
}
|
|
|
|
}
|
2012-07-13 07:46:43 -04:00
|
|
|
|
|
|
|
void MyFrame::OnHidePages(wxRibbonButtonBarEvent& WXUNUSED(evt))
|
|
|
|
{
|
|
|
|
m_ribbon->HidePage(1);
|
|
|
|
m_ribbon->HidePage(2);
|
|
|
|
m_ribbon->HidePage(3);
|
|
|
|
m_ribbon->Realize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnShowPages(wxRibbonButtonBarEvent& WXUNUSED(evt))
|
|
|
|
{
|
|
|
|
m_ribbon->ShowPage(1);
|
|
|
|
m_ribbon->ShowPage(2);
|
|
|
|
m_ribbon->ShowPage(3);
|
|
|
|
m_ribbon->Realize();
|
|
|
|
}
|
2012-07-30 13:53:36 -04:00
|
|
|
|
2018-03-15 11:34:50 -04:00
|
|
|
void MyFrame::OnPlusMinus(wxRibbonButtonBarEvent& WXUNUSED(evt))
|
|
|
|
{
|
|
|
|
if(m_plus_minus_state)
|
|
|
|
{
|
|
|
|
m_mutable_button_bar->SetButtonIcon(ID_PLUS_MINUS,
|
|
|
|
wxArtProvider::GetBitmap(wxART_PLUS, wxART_OTHER, wxSize(24, 24)));
|
|
|
|
m_plus_minus_state = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_mutable_button_bar->SetButtonIcon(ID_PLUS_MINUS,
|
|
|
|
wxArtProvider::GetBitmap(wxART_MINUS, wxART_OTHER, wxSize(24, 24)));
|
|
|
|
m_plus_minus_state = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnChangeLabel(wxRibbonButtonBarEvent& WXUNUSED(evt))
|
|
|
|
{
|
|
|
|
if(m_change_label_state)
|
|
|
|
{
|
2018-09-22 19:15:08 -04:00
|
|
|
m_mutable_button_bar->SetButtonText(ID_CHANGE_LABEL, "short");
|
2018-03-15 11:34:50 -04:00
|
|
|
m_change_label_state = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-09-22 19:15:08 -04:00
|
|
|
m_mutable_button_bar->SetButtonText(ID_CHANGE_LABEL, "some long text");
|
2018-03-15 11:34:50 -04:00
|
|
|
m_change_label_state = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-30 13:53:36 -04:00
|
|
|
void MyFrame::OnRibbonBarToggled(wxRibbonBarEvent& WXUNUSED(evt))
|
|
|
|
{
|
|
|
|
AddText(wxString::Format("Ribbon bar %s.",
|
|
|
|
m_ribbon->ArePanelsShown()
|
|
|
|
? "expanded"
|
|
|
|
: "collapsed"));
|
|
|
|
}
|
2012-09-15 19:19:59 -04:00
|
|
|
|
|
|
|
void MyFrame::OnRibbonBarHelpClicked(wxRibbonBarEvent& WXUNUSED(evt))
|
|
|
|
{
|
|
|
|
AddText("Ribbon bar help clicked");
|
|
|
|
}
|
|
|
|
|
|
|
|
// This shows how to hide ribbon dynamically if there is not enough space.
|
|
|
|
void MyFrame::OnSizeEvent(wxSizeEvent& evt)
|
|
|
|
{
|
|
|
|
if ( evt.GetSize().GetWidth() < 200 )
|
|
|
|
m_ribbon->Hide();
|
|
|
|
else
|
|
|
|
m_ribbon->Show();
|
|
|
|
|
|
|
|
evt.Skip();
|
2012-09-28 19:49:20 -04:00
|
|
|
}
|