]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/uiaction/uiaction.cpp
Don't call wxTextMeasure::BeginMeasuring() when using non-native wxDC.
[wxWidgets.git] / samples / uiaction / uiaction.cpp
index 3b6d0785872a498c4a98d0ddd49820dbea8e0368..6fd518e2999ff2506145b1fe00122327d166d8df 100644 (file)
@@ -40,7 +40,7 @@
 
 // the application icon (under Windows and OS/2 it is in resources and even
 // though we could still include the XPM here it would be unused)
-#if !defined(__WXMSW__) && !defined(__WXPM__)
+#ifndef wxHAS_IMAGES_IN_RESOURCES
     #include "../sample.xpm"
 #endif
 
@@ -52,7 +52,8 @@
 enum
 {
     // menu items
-    RunSimulation = 1
+    RunSimulation = 1,
+    SimulateText
 };
 
 // ----------------------------------------------------------------------------
@@ -77,6 +78,7 @@ public:
 
     void OnButtonPressed(wxCommandEvent& event);
     void OnRunSimulation(wxCommandEvent& event);
+    void OnSimulateText(wxCommandEvent& event);
     void OnExit(wxCommandEvent& WXUNUSED(event)) { Close(); }
 
 private:
@@ -89,6 +91,7 @@ private:
 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
     EVT_BUTTON(wxID_ANY, MyFrame::OnButtonPressed)
     EVT_MENU(RunSimulation, MyFrame::OnRunSimulation)
+    EVT_MENU(SimulateText, MyFrame::OnSimulateText)
     EVT_MENU(wxID_EXIT, MyFrame::OnExit)
 END_EVENT_TABLE()
 
@@ -137,7 +140,11 @@ MyFrame::MyFrame(const wxString& title)
     wxMenu *fileMenu = new wxMenu;
 
     fileMenu->Append(wxID_NEW, "&New File...", "Open a new file");
-    fileMenu->Append(RunSimulation, "&Run Simulation...", "Run the UI action simulation");
+    fileMenu->Append(RunSimulation, "&Run Simulation",
+                     "Run predefined UI action simulation");
+    fileMenu->Append(SimulateText, "Simulate &text input...",
+                     "Enter text to simulate");
+    fileMenu->AppendSeparator();
 
     fileMenu->Append(wxID_EXIT, "E&xit\tAlt-X", "Quit this program");
 
@@ -184,6 +191,29 @@ void MyFrame::OnRunSimulation(wxCommandEvent& WXUNUSED(event))
     sim.Char(WXK_RETURN);
     sim.Text("aAbBcC");
     sim.Char(WXK_RETURN);
+    sim.Text("1 234.57e-8");
+    sim.Char(WXK_RETURN);
+
+}
+
+void MyFrame::OnSimulateText(wxCommandEvent& WXUNUSED(event))
+{
+    static wxString s_text;
+    const wxString text = wxGetTextFromUser
+                          (
+                            "Enter text to simulate: ",
+                            "wxUIActionSimulator wxWidgets Sample",
+                            s_text,
+                            this
+                          );
+    if ( text.empty() )
+        return;
+
+    s_text = text;
+
+    wxUIActionSimulator sim;
+    m_text->SetFocus();
+    sim.Text(s_text.c_str());
 }
 
 void MyFrame::OnButtonPressed(wxCommandEvent& WXUNUSED(event))