]> git.saurik.com Git - wxWidgets.git/commitdiff
add round trip wxTextCtrl::Get/SetValue() test
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 22 Aug 2006 11:19:06 +0000 (11:19 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 22 Aug 2006 11:19:06 +0000 (11:19 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40742 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/font/font.cpp

index ca7ef1bc27436cc7c6b7ac613aff64dc341c5573..649a3d25a5819aadaa2be8cc603efa04eb0d29a3 100644 (file)
@@ -105,6 +105,7 @@ public:
 
     void OnwxPointerFont(wxCommandEvent& event);
 
+    void OnTestTextValue(wxCommandEvent& event);
     void OnViewMsg(wxCommandEvent& event);
     void OnSelectFont(wxCommandEvent& event);
     void OnEnumerateFamiliesForEncoding(wxCommandEvent& event);
@@ -153,6 +154,8 @@ enum
     Font_Quit = 1,
     Font_About,
     Font_ViewMsg,
+    Font_TestTextValue,
+
     Font_IncSize,
     Font_DecSize,
     Font_Bold,
@@ -185,6 +188,7 @@ enum
 // simple menu events like this the static method is much simpler.
 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
     EVT_MENU(Font_Quit,  MyFrame::OnQuit)
+    EVT_MENU(Font_TestTextValue, MyFrame::OnTestTextValue)
     EVT_MENU(Font_ViewMsg, MyFrame::OnViewMsg)
     EVT_MENU(Font_About, MyFrame::OnAbout)
 
@@ -259,6 +263,8 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
     // create a menu bar
     wxMenu *menuFile = new wxMenu;
 
+    menuFile->Append(Font_TestTextValue, wxT("&Test text value"),
+                     wxT("Verify that getting and setting text value doesn't change it"));
     menuFile->Append(Font_ViewMsg, wxT("&View...\tCtrl-V"),
                      wxT("View an email message file"));
     menuFile->AppendSeparator();
@@ -680,6 +686,16 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
     Close(true);
 }
 
+void MyFrame::OnTestTextValue(wxCommandEvent& WXUNUSED(event))
+{
+    wxString value = m_textctrl->GetValue();
+    m_textctrl->SetValue(value);
+    if ( m_textctrl->GetValue() != value )
+    {
+        wxLogError(wxT("Text value changed after getting and setting it"));
+    }
+}
+
 void MyFrame::OnViewMsg(wxCommandEvent& WXUNUSED(event))
 {
 #if wxUSE_FILEDLG
@@ -800,9 +816,9 @@ void MyFrame::OnViewMsg(wxCommandEvent& WXUNUSED(event))
 
 void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
 {
-    wxMessageBox(wxT("wxWidgets font demo\n")
-                 wxT("(c) 1999 Vadim Zeitlin"),
-                 wxT("About Font"),
+    wxMessageBox(wxT("wxWidgets font sample\n")
+                 wxT("(c) 1999-2006 Vadim Zeitlin"),
+                 wxString(wxT("About ")) + SAMPLE_TITLE,
                  wxOK | wxICON_INFORMATION, this);
 }