]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/config.cpp
Added wxRadioButton (not tested)
[wxWidgets.git] / src / common / config.cpp
index 4447719209077a0cbde7c56621054434159bafe8..b7c4a11854e14cb6d1c52de4422b6869f7f91a9f 100644 (file)
@@ -39,7 +39,7 @@
 #include  <wx/config.h>
 
 // we must include (one of) these files for wxConfigBase::Create
-#if defined(__MSWIN__) && defined(wxCONFIG_WIN32_NATIVE)
+#if defined(__WXMSW__) && defined(wxCONFIG_WIN32_NATIVE)
   #ifdef __WIN32__
     #include  <wx/msw/regconf.h>
   #else  //WIN16
@@ -56,7 +56,8 @@
 // global and class static variables
 // ----------------------------------------------------------------------------
 
-wxConfigBase *wxConfigBase::ms_pConfig = NULL;
+wxConfigBase *wxConfigBase::ms_pConfig     = NULL;
+bool          wxConfigBase::ms_bAutoCreate = TRUE;
 
 // ============================================================================
 // implementation
@@ -75,17 +76,21 @@ wxConfigBase *wxConfigBase::Set(wxConfigBase *pConfig)
 
 wxConfigBase *wxConfigBase::Create()
 {
-  return ms_pConfig =
-  #if defined(__MSWIN__) && defined(wxCONFIG_WIN32_NATIVE)
-    #ifdef __WIN32__
-      new wxRegConfig(wxTheApp->GetAppName(), wxTheApp->GetVendorName());
-    #else  //WIN16
-      #error "Sorry, no wxIniConfig yet..."
-      //new wxIniConfig(wxTheApp->GetAppName(), wxTheApp->GetVendorName());
+  if ( ms_bAutoCreate && ms_pConfig == NULL ) {
+    ms_pConfig =
+    #if defined(__WXMSW__) && defined(wxCONFIG_WIN32_NATIVE)
+      #ifdef __WIN32__
+        new wxRegConfig(wxTheApp->GetVendorName() + '\\' 
+                        + wxTheApp->GetAppName());
+      #else  //WIN16
+        new wxIniConfig(wxTheApp->GetAppName(), wxTheApp->GetVendorName());
+      #endif
+    #else // either we're under Unix or wish to use files even under Windows
+      new wxFileConfig(wxTheApp->GetAppName());
     #endif
-  #else // either we're under Unix or wish to use files even under Windows
-    new wxFileConfig(wxTheApp->GetAppName());
-  #endif
+  }
+
+  return ms_pConfig;
 }
 
 const char *wxConfigBase::Read(const char *szKey, const char *szDefault) const
@@ -217,11 +222,12 @@ wxString wxExpandEnvVars(const wxString& str)
           // check the closing bracket
           if ( bracket != Bracket_None ) {
             if ( m == str.Len() || str[m] != (char)bracket ) {
-              wxLogWarning(_("missing '%c' at position %d in '%s'."),
+              wxLogWarning(_("Environment variables expansion failed: "
+                             "missing '%c' at position %d in '%s'."),
                            (char)bracket, m + 1, str.c_str());
             }
             else {
-              // skip closing bracket
+              // skip closing bracket unless the variables wasn't expanded
               if ( pszValue == NULL )
                 strResult << (char)bracket;
               m++;
@@ -232,6 +238,15 @@ wxString wxExpandEnvVars(const wxString& str)
         }
         break;
 
+      case '\\':
+        // backslash can be used to suppress special meaning of % and $
+        if ( n != str.Len() && (str[n + 1] == '%' || str[n + 1] == '$') ) {
+          strResult += str[++n];
+
+          break;
+        }
+        //else: fall through
+
       default:
         strResult += str[n];
     }