]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/uiaction/uiaction.cpp
Fix handling of help buttons with non-empty label under OS X.
[wxWidgets.git] / samples / uiaction / uiaction.cpp
index a9eeb435191e663fd9f50f564edde471a6600f6b..63a5bb627103575244367c19dc7fb60942dbf4ac 100644 (file)
@@ -30,7 +30,9 @@
     #include "wx/wx.h"
 #endif
 
-#include "wx/uiaction.h"
+#if wxUSE_UIACTIONSIMULATOR
+    #include "wx/uiaction.h"
+#endif
 
 // ----------------------------------------------------------------------------
 // resources
     #include "../sample.xpm"
 #endif
 
+// ----------------------------------------------------------------------------
+// constants
+// ----------------------------------------------------------------------------
+
+// IDs for the controls and the menu commands
+enum
+{
+    // menu items
+    TheButton = 100,
+    RunSimulation
+};
+
 // ----------------------------------------------------------------------------
 // private classes
 // ----------------------------------------------------------------------------
@@ -53,6 +67,8 @@ public:
     virtual bool OnInit();
 };
 
+#if wxUSE_UIACTIONSIMULATOR
+
 // Define a new frame type: this is going to be our main frame
 class MyFrame : public wxFrame
 {
@@ -69,21 +85,16 @@ public:
 private:
     bool m_buttonPressed;
     bool m_menuSelected;
-};
 
-// ----------------------------------------------------------------------------
-// constants
-// ----------------------------------------------------------------------------
-
-// IDs for the controls and the menu commands
-enum
-{
-    // menu items
-    TheButton = wxID_ANY,
-    RunSimulation = wxID_ANY
+    DECLARE_EVENT_TABLE()
 };
 
-IMPLEMENT_APP(MyApp)
+BEGIN_EVENT_TABLE(MyFrame, wxFrame)
+    EVT_BUTTON(TheButton, MyFrame::OnButtonPressed)
+    EVT_MENU(RunSimulation, MyFrame::OnRunSimulation)
+END_EVENT_TABLE()
+
+#endif // wxUSE_UIACTIONSIMULATOR
 
 // ============================================================================
 // implementation
@@ -93,21 +104,30 @@ IMPLEMENT_APP(MyApp)
 // the application class
 // ----------------------------------------------------------------------------
 
+IMPLEMENT_APP(MyApp)
+
 bool MyApp::OnInit()
 {
     if ( !wxApp::OnInit() )
         return false;
 
+#if wxUSE_UIACTIONSIMULATOR
     MyFrame *frame = new MyFrame("wxUIActionSimulator sample application");
     frame->Show(true);
     
     return true;
+#else // !wxUSE_UIACTIONSIMULATOR
+    wxLogError("wxUSE_UIACTIONSIMULATOR must be 1 for this sample");
+    return false;
+#endif // wxUSE_UIACTIONSIMULATOR/!wxUSE_UIACTIONSIMULATOR
 }
 
 // ----------------------------------------------------------------------------
 // main frame
 // ----------------------------------------------------------------------------
 
+#if wxUSE_UIACTIONSIMULATOR
+
 // frame constructor
 MyFrame::MyFrame(const wxString& title)
        : wxFrame(NULL, wxID_ANY, title)
@@ -134,8 +154,6 @@ MyFrame::MyFrame(const wxString& title)
 
     wxButton* button = new wxButton(this, TheButton, "Button");
     button->SetName("TheButton");
-    Bind(wxEVT_COMMAND_BUTTON_CLICKED, &MyFrame::OnButtonPressed, this, button->GetId());
-    Bind(wxEVT_COMMAND_MENU_SELECTED, &MyFrame::OnRunSimulation, this, RunSimulation);
 }
 
 
@@ -159,3 +177,5 @@ void MyFrame::OnButtonPressed(wxCommandEvent&)
 {
     m_buttonPressed = true;
 }
+
+#endif // wxUSE_UIACTIONSIMULATOR