]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/config/conftest.cpp
Define SF_UNICODE if undefined
[wxWidgets.git] / samples / config / conftest.cpp
index fe26c3b968a200a14721c7c9ec8538d4a393d9e1..19b06638e35faad5e71969e6767e5351c94a787a 100644 (file)
@@ -28,6 +28,7 @@
 // ----------------------------------------------------------------------------
 // classes
 // ----------------------------------------------------------------------------
+
 class MyApp: public wxApp
 {
 public:
@@ -46,7 +47,6 @@ public:
   void OnQuit(wxCommandEvent& event);
   void OnAbout(wxCommandEvent& event);
   void OnDelete(wxCommandEvent& event);
-  void OnCloseWindow(wxCloseEvent& event);
 
 private:
   wxTextCtrl *m_text;
@@ -57,19 +57,19 @@ private:
 
 enum
 {
-  Minimal_Quit,
-  Minimal_About,
-  Minimal_Delete
+  ConfTest_Quit,
+  ConfTest_About,
+  ConfTest_Delete
 };
 
 // ----------------------------------------------------------------------------
 // event tables
 // ----------------------------------------------------------------------------
+
 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
-  EVT_MENU(Minimal_Quit, MyFrame::OnQuit)
-  EVT_MENU(Minimal_About, MyFrame::OnAbout)
-  EVT_MENU(Minimal_Delete, MyFrame::OnDelete)
-  EVT_CLOSE(MyFrame::OnCloseWindow)
+  EVT_MENU(ConfTest_Quit, MyFrame::OnQuit)
+  EVT_MENU(ConfTest_About, MyFrame::OnAbout)
+  EVT_MENU(ConfTest_Delete, MyFrame::OnDelete)
 END_EVENT_TABLE()
 
 // ============================================================================
@@ -79,6 +79,7 @@ END_EVENT_TABLE()
 // ----------------------------------------------------------------------------
 // application
 // ----------------------------------------------------------------------------
+
 IMPLEMENT_APP(MyApp)
 
 // `Main program' equivalent, creating windows and returning main app frame
@@ -141,20 +142,14 @@ int MyApp::OnExit()
 MyFrame::MyFrame()
        : wxFrame((wxFrame *) NULL, -1, "wxConfig Demo")
 {
-  // submenu
-  wxMenu *sub_menu = new wxMenu( wxMENU_TEAROFF );
-  sub_menu->Append(Minimal_About, "&About", "About this sample");
-  sub_menu->Append(Minimal_About, "&About", "About this sample");
-  sub_menu->Append(Minimal_About, "&About", "About this sample");
-
   // menu
   wxMenu *file_menu = new wxMenu;
 
-  file_menu->Append(Minimal_Delete, "&Delete", "Delete config file");
+  file_menu->Append(ConfTest_Delete, "&Delete", "Delete config file");
   file_menu->AppendSeparator();
-  file_menu->Append(Minimal_About, "&About", "About this sample");
+  file_menu->Append(ConfTest_About, "&About\tF1", "About this sample");
   file_menu->AppendSeparator();
-  file_menu->Append(Minimal_Quit, "E&xit", "Exit the program");
+  file_menu->Append(ConfTest_Quit, "E&xit\tAlt-X", "Exit the program");
   wxMenuBar *menu_bar = new wxMenuBar;
   menu_bar->Append(file_menu, "&File");
   SetMenuBar(menu_bar);
@@ -194,11 +189,17 @@ MyFrame::MyFrame()
       h = pConfig->Read("h", 200);
   Move(x, y);
   SetClientSize(w, h);
-}
 
-void MyFrame::OnCloseWindow(wxCloseEvent& event)
-{
-    this->Destroy();
+  pConfig->SetPath("/");
+  wxString s;
+  if ( pConfig->Read("TestValue", &s) )
+  {
+      wxLogStatus(this, wxT("TestValue from config is '%s'"), s.c_str());
+  }
+  else
+  {
+      wxLogStatus(this, wxT("TestValue not found in the config"));
+  }
 }
 
 void MyFrame::OnQuit(wxCommandEvent&)
@@ -208,21 +209,22 @@ void MyFrame::OnQuit(wxCommandEvent&)
 
 void MyFrame::OnAbout(wxCommandEvent&)
 {
-  wxMessageBox("wxConfig demo\n© Vadim Zeitlin 1998", "About",
+  wxMessageBox(_T("wxConfig demo\n© Vadim Zeitlin 1998"), _T("About"),
                wxICON_INFORMATION | wxOK);
 }
 
 void MyFrame::OnDelete(wxCommandEvent&)
 {
-    if ( wxConfigBase::Get()->DeleteAll() ) {
-        wxLogMessage("Config file/registry key successfully deleted.");
+    if ( wxConfigBase::Get()->DeleteAll() ) 
+    {
+        wxLogMessage(_T("Config file/registry key successfully deleted."));
 
         delete wxConfigBase::Set((wxConfigBase *) NULL);
         wxConfigBase::DontCreateOnDemand();
     }
     else
     {
-        wxLogError("Deleting config file/registry key failed.");
+        wxLogError(_T("Deleting config file/registry key failed."));
     }
 }
 
@@ -243,4 +245,6 @@ MyFrame::~MyFrame()
   pConfig->Write("/MainFrame/y", (long) y);
   pConfig->Write("/MainFrame/w", (long) w);
   pConfig->Write("/MainFrame/h", (long) h);
+
+  pConfig->Write("/TestValue", "");
 }