]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/ribbon/ribbondemo.cpp
Support using GetTextExtent() with empty string to get descent in wxOSX.
[wxWidgets.git] / samples / ribbon / ribbondemo.cpp
index c29360c3dc8aedd04f447681ef08a3de9c4ff33b..7a326c8598e6814ebbf32d6c33805d70ae305710 100644 (file)
@@ -94,6 +94,8 @@ public:
     void OnCheck(wxRibbonButtonBarEvent& evt);
     void OnEnable(wxRibbonButtonBarEvent& evt);
     void OnDisable(wxRibbonButtonBarEvent& evt);
+    void OnDisabled(wxRibbonButtonBarEvent& evt);
+    void OnEnableUpdated(wxRibbonButtonBarEvent& evt);
     void OnChangeText1(wxRibbonButtonBarEvent& evt);
     void OnChangeText2(wxRibbonButtonBarEvent& evt);
     void OnCircleButton(wxRibbonButtonBarEvent& evt);
@@ -187,6 +189,8 @@ bool MyApp::OnInit()
 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
 EVT_RIBBONBUTTONBAR_CLICKED(ID_ENABLE, MyFrame::OnEnable)
 EVT_RIBBONBUTTONBAR_CLICKED(ID_DISABLE, MyFrame::OnDisable)
+EVT_RIBBONBUTTONBAR_CLICKED(ID_DISABLED, MyFrame::OnDisabled)
+EVT_RIBBONBUTTONBAR_CLICKED(ID_UI_ENABLE_UPDATED, MyFrame::OnEnableUpdated)
 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)
@@ -401,6 +405,11 @@ MyFrame::MyFrame()
         bar->AddButton(ID_CHANGE_TEXT1, wxT("One"), ribbon_xpm);
         bar->AddButton(ID_CHANGE_TEXT2, wxT("Two"), ribbon_xpm);
         bar->AddButton(ID_UI_CHANGE_TEXT_UPDATED, wxT("Zero"), ribbon_xpm);
+
+        //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());
     }
     new wxRibbonPage(m_ribbon, wxID_ANY, wxT("Empty Page"), empty_xpm);
     {
@@ -623,6 +632,16 @@ void MyFrame::OnDisable(wxRibbonButtonBarEvent& WXUNUSED(evt))
     m_bEnabled = false;
 }
 
+void MyFrame::OnDisabled(wxRibbonButtonBarEvent& WXUNUSED(evt))
+{
+    AddText("ERROR: Disabled button activated (not supposed to happen)");
+}
+
+void MyFrame::OnEnableUpdated(wxRibbonButtonBarEvent& WXUNUSED(evt))
+{
+    AddText("Button activated");
+}
+
 void MyFrame::OnCheck(wxRibbonButtonBarEvent& WXUNUSED(evt))
 {
     m_bChecked = !m_bChecked;
@@ -951,7 +970,7 @@ void MyFrame::OnColourGalleryButton(wxCommandEvent& evt)
         gallery->SetSelection(item);
 
         // Send an event to respond to the selection change
-        wxRibbonGalleryEvent dummy(wxEVT_COMMAND_RIBBONGALLERY_SELECTED, gallery->GetId());
+        wxRibbonGalleryEvent dummy(wxEVT_RIBBONGALLERY_SELECTED, gallery->GetId());
         dummy.SetEventObject(gallery);
         dummy.SetGallery(gallery);
         dummy.SetGalleryItem(item);
@@ -1042,4 +1061,4 @@ void MyFrame::OnSizeEvent(wxSizeEvent& evt)
         m_ribbon->Show();
 
     evt.Skip();
-}
\ No newline at end of file
+}