]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/config/conftest.cpp
Added context help stuff to wxPython
[wxWidgets.git] / samples / config / conftest.cpp
index 4626dd0122c8f607c78409a836d73a5a4bc5d9f3..16ced7f3fe9791ad6f282b715434a31a6640b11b 100644 (file)
@@ -28,6 +28,7 @@
 // ----------------------------------------------------------------------------
 // classes
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // classes
 // ----------------------------------------------------------------------------
+
 class MyApp: public wxApp
 {
 public:
 class MyApp: public wxApp
 {
 public:
@@ -46,7 +47,6 @@ public:
   void OnQuit(wxCommandEvent& event);
   void OnAbout(wxCommandEvent& event);
   void OnDelete(wxCommandEvent& event);
   void OnQuit(wxCommandEvent& event);
   void OnAbout(wxCommandEvent& event);
   void OnDelete(wxCommandEvent& event);
-  bool OnClose() { return TRUE; }
 
 private:
   wxTextCtrl *m_text;
 
 private:
   wxTextCtrl *m_text;
@@ -57,18 +57,19 @@ private:
 
 enum
 {
 
 enum
 {
-  Minimal_Quit,
-  Minimal_About,
-  Minimal_Delete
+  ConfTest_Quit,
+  ConfTest_About,
+  ConfTest_Delete
 };
 
 // ----------------------------------------------------------------------------
 // event tables
 // ----------------------------------------------------------------------------
 };
 
 // ----------------------------------------------------------------------------
 // event tables
 // ----------------------------------------------------------------------------
+
 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
-  EVT_MENU(Minimal_Quit, MyFrame::OnQuit)
-  EVT_MENU(Minimal_About, MyFrame::OnAbout)
-  EVT_MENU(Minimal_Delete, MyFrame::OnDelete)
+  EVT_MENU(ConfTest_Quit, MyFrame::OnQuit)
+  EVT_MENU(ConfTest_About, MyFrame::OnAbout)
+  EVT_MENU(ConfTest_Delete, MyFrame::OnDelete)
 END_EVENT_TABLE()
 
 // ============================================================================
 END_EVENT_TABLE()
 
 // ============================================================================
@@ -78,6 +79,7 @@ END_EVENT_TABLE()
 // ----------------------------------------------------------------------------
 // application
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // application
 // ----------------------------------------------------------------------------
+
 IMPLEMENT_APP(MyApp)
 
 // `Main program' equivalent, creating windows and returning main app frame
 IMPLEMENT_APP(MyApp)
 
 // `Main program' equivalent, creating windows and returning main app frame
@@ -143,11 +145,11 @@ MyFrame::MyFrame()
   // menu
   wxMenu *file_menu = new wxMenu;
 
   // 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->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->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);
   wxMenuBar *menu_bar = new wxMenuBar;
   menu_bar->Append(file_menu, "&File");
   SetMenuBar(menu_bar);
@@ -187,6 +189,17 @@ MyFrame::MyFrame()
       h = pConfig->Read("h", 200);
   Move(x, y);
   SetClientSize(w, h);
       h = pConfig->Read("h", 200);
   Move(x, y);
   SetClientSize(w, h);
+
+  pConfig->SetPath("/");
+  wxString s;
+  if ( pConfig->Read("TestValue", &s) )
+  {
+      wxLogStatus(this, "TestValue from config is '%s'", s.c_str());
+  }
+  else
+  {
+      wxLogStatus(this, "TestValue not found in the config");
+  }
 }
 
 void MyFrame::OnQuit(wxCommandEvent&)
 }
 
 void MyFrame::OnQuit(wxCommandEvent&)
@@ -196,24 +209,23 @@ void MyFrame::OnQuit(wxCommandEvent&)
 
 void MyFrame::OnAbout(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&)
 {
                wxICON_INFORMATION | wxOK);
 }
 
 void MyFrame::OnDelete(wxCommandEvent&)
 {
-  // VZ: it seems that DeleteAll() wreaks havoc on NT. Disabled until I
-  // investigate it further, do _not_ compile this code in meanwhile!
-#if 0
-  if ( wxConfigBase::Get()->DeleteAll() ) {
-    wxLogMessage("Config file/registry key successfully deleted.");
-
-    delete wxConfigBase::Set((wxConfigBase *) NULL);
-    wxConfigBase::DontCreateOnDemand();
-  }
-  else
-#endif // 0
-    wxLogError("Deleting config file/registry key failed.");
+    if ( wxConfigBase::Get()->DeleteAll() ) 
+    {
+        wxLogMessage(_T("Config file/registry key successfully deleted."));
+
+        delete wxConfigBase::Set((wxConfigBase *) NULL);
+        wxConfigBase::DontCreateOnDemand();
+    }
+    else
+    {
+        wxLogError(_T("Deleting config file/registry key failed."));
+    }
 }
 
 MyFrame::~MyFrame()
 }
 
 MyFrame::~MyFrame()
@@ -233,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("/MainFrame/y", (long) y);
   pConfig->Write("/MainFrame/w", (long) w);
   pConfig->Write("/MainFrame/h", (long) h);
+
+  pConfig->Write("/TestValue", "");
 }
 }