]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/regconf.cpp
fixed client area origin handling in wxGTK
[wxWidgets.git] / src / msw / regconf.cpp
index 34a60f02bd5c9c18bf9c81f30a5723a676ab5c8b..07fcf8201b4224871c55944a7404c7880c487d19 100644 (file)
@@ -22,6 +22,7 @@
 
 #ifndef WX_PRECOMP
   #include  "wx/string.h"
 
 #ifndef WX_PRECOMP
   #include  "wx/string.h"
+  #include  "wx/intl.h"
 #endif //WX_PRECOMP
 
 #include "wx/event.h"
 #endif //WX_PRECOMP
 
 #include "wx/event.h"
@@ -220,7 +221,11 @@ void wxRegConfig::SetPath(const wxString& strPath)
         {
             strFullPath.reserve(2*m_strPath.length());
 
         {
             strFullPath.reserve(2*m_strPath.length());
 
-            strFullPath << m_strPath << wxCONFIG_PATH_SEPARATOR << strPath;
+            strFullPath << m_strPath;
+            if ( strFullPath.Len() == 0 || 
+                 strFullPath.Last() != wxCONFIG_PATH_SEPARATOR )
+                strFullPath << wxCONFIG_PATH_SEPARATOR; 
+            strFullPath << strPath;
         }
 
         // simplify it: we need to handle ".." here
         }
 
         // simplify it: we need to handle ".." here
@@ -269,6 +274,7 @@ void wxRegConfig::SetPath(const wxString& strPath)
                             // check the boundary condition below
 
                             // this is more efficient than strrchr()
                             // check the boundary condition below
 
                             // this is more efficient than strrchr()
+                            dst--;
                             while ( *dst != wxCONFIG_PATH_SEPARATOR )
                             {
                                 dst--;
                             while ( *dst != wxCONFIG_PATH_SEPARATOR )
                             {
                                 dst--;
@@ -283,10 +289,13 @@ void wxRegConfig::SetPath(const wxString& strPath)
                             posLastSlash = -1;
                         }
 
                             posLastSlash = -1;
                         }
 
-                        // this shouldn't happen
+                        // we must have found a slash one way or another!
                         wxASSERT_MSG( *dst == wxCONFIG_PATH_SEPARATOR,
                                       _T("error in wxRegConfig::SetPath") );
 
                         wxASSERT_MSG( *dst == wxCONFIG_PATH_SEPARATOR,
                                       _T("error in wxRegConfig::SetPath") );
 
+                        // stay at the same position
+                        dst--;
+
                         // we killed one
                         totalSlashes--;
                     }
                         // we killed one
                         totalSlashes--;
                     }
@@ -304,8 +313,12 @@ void wxRegConfig::SetPath(const wxString& strPath)
 
                         totalSlashes++;
                     }
 
                         totalSlashes++;
                     }
-                    //else: nothing to do, we squeeze several subseuquent
-                    //      slashes into one
+                    else // previous char was a slash too
+                    {
+                        // squeeze several subsequent slashes into one: i.e.
+                        // just ignore this one
+                        dst--;
+                    }
                 }
             }
             else // normal character
                 }
             }
             else // normal character
@@ -463,7 +476,7 @@ bool wxRegConfig::GetNextEntry(wxString& str, long& lIndex) const
   return bOk;
 }
 
   return bOk;
 }
 
-size_t wxRegConfig::GetNumberOfEntries(bool bRecursive) const
+size_t wxRegConfig::GetNumberOfEntries(bool WXUNUSED(bRecursive)) const
 {
   size_t nEntries = 0;
 
 {
   size_t nEntries = 0;
 
@@ -480,7 +493,7 @@ size_t wxRegConfig::GetNumberOfEntries(bool bRecursive) const
   return nEntries;
 }
 
   return nEntries;
 }
 
-size_t wxRegConfig::GetNumberOfGroups(bool bRecursive) const
+size_t wxRegConfig::GetNumberOfGroups(bool WXUNUSED(bRecursive)) const
 {
   size_t nGroups = 0;
 
 {
   size_t nGroups = 0;
 
@@ -690,34 +703,7 @@ bool wxRegConfig::RenameEntry(const wxString& oldName, const wxString& newName)
     if ( HasEntry(newName) )
         return FALSE;
 
     if ( HasEntry(newName) )
         return FALSE;
 
-    // delete the old entry and create the new one - but do in the reverse
-    // order to not lose the data if Create() fails
-
-    bool ok;
-    if ( m_keyLocal.IsNumericValue(oldName) )
-    {
-        long val;
-        ok = m_keyLocal.QueryValue(oldName, &val) &&
-             m_keyLocal.SetValue(newName, val);
-    }
-    else
-    {
-        wxString val;
-        ok = m_keyLocal.QueryValue(oldName, val) &&
-             m_keyLocal.SetValue(newName, val);
-    }
-
-    if ( !ok )
-        return FALSE;
-
-    if ( !m_keyLocal.DeleteValue(oldName) )
-    {
-        m_keyLocal.DeleteValue(newName);
-
-        return FALSE;
-    }
-
-    return TRUE;
+    return m_keyLocal.RenameValue(oldName, newName);
 }
 
 bool wxRegConfig::RenameGroup(const wxString& oldName, const wxString& newName)
 }
 
 bool wxRegConfig::RenameGroup(const wxString& oldName, const wxString& newName)
@@ -730,17 +716,13 @@ bool wxRegConfig::RenameGroup(const wxString& oldName, const wxString& newName)
     if ( HasGroup(newName) )
         return FALSE;
 
     if ( HasGroup(newName) )
         return FALSE;
 
-    // TODO there is no way to rename a registry key - we must do a deep copy
-    //      ourselves
-    wxFAIL_MSG(wxT("Registry key renaming not implemented"));
-
-    return FALSE;
+    return wxRegKey(m_keyLocal, oldName).Rename(newName);
 }
 
 // ----------------------------------------------------------------------------
 // deleting
 // ----------------------------------------------------------------------------
 }
 
 // ----------------------------------------------------------------------------
 // deleting
 // ----------------------------------------------------------------------------
-bool wxRegConfig::DeleteEntry(const wxString& value, bool bGroupIfEmptyAlso)
+bool wxRegConfig::DeleteEntry(const wxString& value, bool WXUNUSED(bGroupIfEmptyAlso))
 {
   wxConfigPathChanger path(this, value);
 
 {
   wxConfigPathChanger path(this, value);