]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/config/conftest.cpp
Make it possible to use svn-find-native-eols script without svn checkout.
[wxWidgets.git] / samples / config / conftest.cpp
index c829260882376fe00c6f64073813de8e169a4f99..dd903e237854066b97bad0b9b6eeda8f5619c5c4 100644 (file)
@@ -6,7 +6,7 @@
 // Created:     03.08.98
 // RCS-ID:      $Id$
 // Copyright:   (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
-// Licence:     wxWindows license
+// Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
 
 // ============================================================================
@@ -29,7 +29,7 @@
 #include "wx/log.h"
 #include "wx/config.h"
 
-#ifndef __WXMSW__
+#ifndef wxHAS_IMAGES_IN_RESOURCES
     #include "../sample.xpm"
 #endif
 
@@ -63,21 +63,14 @@ private:
     DECLARE_EVENT_TABLE()
 };
 
-enum
-{
-  ConfTest_Quit,
-  ConfTest_About,
-  ConfTest_Delete
-};
-
 // ----------------------------------------------------------------------------
 // event tables
 // ----------------------------------------------------------------------------
 
 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
-  EVT_MENU(ConfTest_Quit, MyFrame::OnQuit)
-  EVT_MENU(ConfTest_About, MyFrame::OnAbout)
-  EVT_MENU(ConfTest_Delete, MyFrame::OnDelete)
+  EVT_MENU(wxID_EXIT, MyFrame::OnQuit)
+  EVT_MENU(wxID_ABOUT, MyFrame::OnAbout)
+  EVT_MENU(wxID_DELETE, MyFrame::OnDelete)
 END_EVENT_TABLE()
 
 // ============================================================================
@@ -106,8 +99,8 @@ bool MyApp::OnInit()
     // of the config file/registry key and must be set before the first call
     // to Get() if you want to override the default values (the application
     // name is the name of the executable and the vendor name is the same)
-    SetVendorName(_T("wxWidgets"));
-    SetAppName(_T("conftest")); // not needed, it's the default value
+    SetVendorName(wxT("wxWidgets"));
+    SetAppName(wxT("conftest")); // not needed, it's the default value
 
     wxConfigBase *pConfig = wxConfigBase::Get();
 
@@ -126,14 +119,13 @@ bool MyApp::OnInit()
     // create the main program window
     MyFrame *frame = new MyFrame;
     frame->Show(true);
-    SetTopWindow(frame);
 
     // use our config object...
-    if ( pConfig->Read(_T("/Controls/Check"), 1l) != 0 ) {
-        wxMessageBox(_T("You can disable this message box by unchecking\n")
-                    _T("the checkbox in the main window (of course, a real\n")
-                    _T("program would have a checkbox right here but we\n")
-                    _T("keep it simple)"), _T("Welcome to wxConfig demo"),
+    if ( pConfig->Read(wxT("/Controls/Check"), 1l) != 0 ) {
+        wxMessageBox(wxT("You can disable this message box by unchecking\n")
+                    wxT("the checkbox in the main window (of course, a real\n")
+                    wxT("program would have a checkbox right here but we\n")
+                    wxT("keep it simple)"), wxT("Welcome to wxConfig demo"),
                     wxICON_INFORMATION | wxOK);
     }
 
@@ -156,20 +148,20 @@ int MyApp::OnExit()
 
 // main frame ctor
 MyFrame::MyFrame()
-       : wxFrame((wxFrame *) NULL, wxID_ANY, _T("wxConfig Demo"))
+       : wxFrame((wxFrame *) NULL, wxID_ANY, wxT("wxConfig Demo"))
 {
     SetIcon(wxICON(sample));
 
     // menu
     wxMenu *file_menu = new wxMenu;
 
-    file_menu->Append(ConfTest_Delete, _T("&Delete"), _T("Delete config file"));
+    file_menu->Append(wxID_DELETE, wxT("&Delete"), wxT("Delete config file"));
     file_menu->AppendSeparator();
-    file_menu->Append(ConfTest_About, _T("&About\tF1"), _T("About this sample"));
+    file_menu->Append(wxID_ABOUT, wxT("&About\tF1"), wxT("About this sample"));
     file_menu->AppendSeparator();
-    file_menu->Append(ConfTest_Quit, _T("E&xit\tAlt-X"), _T("Exit the program"));
+    file_menu->Append(wxID_EXIT, wxT("E&xit\tAlt-X"), wxT("Exit the program"));
     wxMenuBar *menu_bar = new wxMenuBar;
-    menu_bar->Append(file_menu, _T("&File"));
+    menu_bar->Append(file_menu, wxT("&File"));
     SetMenuBar(menu_bar);
 
 #if wxUSE_STATUSBAR
@@ -178,10 +170,10 @@ MyFrame::MyFrame()
 
     // child controls
     wxPanel *panel = new wxPanel(this);
-    (void)new wxStaticText(panel, wxID_ANY, _T("These controls remember their values!"),
+    (void)new wxStaticText(panel, wxID_ANY, wxT("These controls remember their values!"),
                             wxPoint(10, 10), wxSize(300, 20));
-    m_text = new wxTextCtrl(panel, wxID_ANY, _T(""), wxPoint(10, 40), wxSize(300, 20));
-    m_check = new wxCheckBox(panel, wxID_ANY, _T("show welcome message box at startup"),
+    m_text = new wxTextCtrl(panel, wxID_ANY, wxT(""), wxPoint(10, 40), wxSize(300, 20));
+    m_check = new wxCheckBox(panel, wxID_ANY, wxT("show welcome message box at startup"),
                             wxPoint(10, 70), wxSize(300, 20));
 
     // restore the control's values from the config
@@ -194,25 +186,25 @@ MyFrame::MyFrame()
     wxConfigBase *pConfig = wxConfigBase::Get();
 
     // we could write Read("/Controls/Text") as well, it's just to show SetPath()
-    pConfig->SetPath(_T("/Controls"));
+    pConfig->SetPath(wxT("/Controls"));
 
-    m_text->SetValue(pConfig->Read(_T("Text"), _T("")));
-    m_check->SetValue(pConfig->Read(_T("Check"), 1l) != 0);
+    m_text->SetValue(pConfig->Read(wxT("Text"), wxT("")));
+    m_check->SetValue(pConfig->Read(wxT("Check"), 1l) != 0);
 
     // SetPath() understands ".."
-    pConfig->SetPath(_T("../MainFrame"));
+    pConfig->SetPath(wxT("../MainFrame"));
 
     // restore frame position and size
-    int x = pConfig->Read(_T("x"), 50),
-        y = pConfig->Read(_T("y"), 50),
-        w = pConfig->Read(_T("w"), 350),
-        h = pConfig->Read(_T("h"), 200);
+    int x = pConfig->Read(wxT("x"), 50),
+        y = pConfig->Read(wxT("y"), 50),
+        w = pConfig->Read(wxT("w"), 350),
+        h = pConfig->Read(wxT("h"), 200);
     Move(x, y);
     SetClientSize(w, h);
 
-    pConfig->SetPath(_T("/"));
+    pConfig->SetPath(wxT("/"));
     wxString s;
-    if ( pConfig->Read(_T("TestValue"), &s) )
+    if ( pConfig->Read(wxT("TestValue"), &s) )
     {
         wxLogStatus(this, wxT("TestValue from config is '%s'"), s.c_str());
     }
@@ -229,7 +221,7 @@ void MyFrame::OnQuit(wxCommandEvent&)
 
 void MyFrame::OnAbout(wxCommandEvent&)
 {
-    wxMessageBox(_T("wxConfig demo\n(c) 1998-2001 Vadim Zeitlin"), _T("About"),
+    wxMessageBox(wxT("wxConfig demo\n(c) 1998-2001 Vadim Zeitlin"), wxT("About"),
                  wxICON_INFORMATION | wxOK);
 }
 
@@ -238,20 +230,20 @@ void MyFrame::OnDelete(wxCommandEvent&)
     wxConfigBase *pConfig = wxConfigBase::Get();
     if ( pConfig == NULL )
     {
-        wxLogError(_T("No config to delete!"));
+        wxLogError(wxT("No config to delete!"));
         return;
     }
 
     if ( pConfig->DeleteAll() )
     {
-        wxLogMessage(_T("Config file/registry key successfully deleted."));
+        wxLogMessage(wxT("Config file/registry key successfully deleted."));
 
         delete wxConfigBase::Set(NULL);
         wxConfigBase::DontCreateOnDemand();
     }
     else
     {
-        wxLogError(_T("Deleting config file/registry key failed."));
+        wxLogError(wxT("Deleting config file/registry key failed."));
     }
 }
 
@@ -262,18 +254,18 @@ MyFrame::~MyFrame()
         return;
 
     // save the control's values to the config
-    pConfig->Write(_T("/Controls/Text"), m_text->GetValue());
-    pConfig->Write(_T("/Controls/Check"), m_check->GetValue());
+    pConfig->Write(wxT("/Controls/Text"), m_text->GetValue());
+    pConfig->Write(wxT("/Controls/Check"), m_check->GetValue());
 
     // save the frame position
     int x, y, w, h;
     GetClientSize(&w, &h);
     GetPosition(&x, &y);
-    pConfig->Write(_T("/MainFrame/x"), (long) x);
-    pConfig->Write(_T("/MainFrame/y"), (long) y);
-    pConfig->Write(_T("/MainFrame/w"), (long) w);
-    pConfig->Write(_T("/MainFrame/h"), (long) h);
+    pConfig->Write(wxT("/MainFrame/x"), (long) x);
+    pConfig->Write(wxT("/MainFrame/y"), (long) y);
+    pConfig->Write(wxT("/MainFrame/w"), (long) w);
+    pConfig->Write(wxT("/MainFrame/h"), (long) h);
 
-    pConfig->Write(_T("/TestValue"), wxT("A test value"));
+    pConfig->Write(wxT("/TestValue"), wxT("A test value"));
 }