]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/configtool/src/utils.cpp
documented return value of Find[Absolute]ValidPath() correctly
[wxWidgets.git] / utils / configtool / src / utils.cpp
index 389a8f26fbb4523970dfec3d7ce9066b379af79c..f4d192038936a96181fc87f101b0d8f76d12490a 100644 (file)
@@ -6,7 +6,7 @@
 // Created:     2002-09-04
 // RCS-ID:      $Id$
 // Copyright:   (c) Julian Smart
-// Licence:    
+// Licence:
 /////////////////////////////////////////////////////////////////////////////
 
 #ifdef __GNUG__
@@ -77,12 +77,9 @@ wxString apColourToHexString(const wxColour& col)
 // Convert 6-digit hex string to a colour
 wxColour apHexStringToColour(const wxString& hex)
 {
-    unsigned int r = 0;
-    unsigned int g = 0;
-    unsigned int b = 0;
-    r = wxHexToDec(hex.Mid(0, 2));
-    g = wxHexToDec(hex.Mid(2, 2));
-    b = wxHexToDec(hex.Mid(4, 2));
+    unsigned int r = wxHexToDec(hex.Mid(0, 2));
+    unsigned int g = wxHexToDec(hex.Mid(2, 2));
+    unsigned int b = wxHexToDec(hex.Mid(4, 2));
 
     return wxColour(r, g, b);
 }
@@ -185,7 +182,7 @@ void apViewHTMLFile(const wxString& url)
         STARTUPINFO          siStartInfo;
         memset(&siStartInfo, 0, sizeof(STARTUPINFO));
         siStartInfo.cb = sizeof(STARTUPINFO);
-        CreateProcess(NULL, szCmdName, NULL, NULL, FALSE, 0, NULL,
+        CreateProcess(NULL, szCmdName, NULL, NULL, false, 0, NULL,
             NULL, &siStartInfo, &piProcInfo );
     }
     if(lRes == ERROR_SUCCESS)
@@ -207,11 +204,11 @@ void apViewHTMLFile(const wxString& url)
     {
         // TODO: some kind of configuration dialog here.
         wxMessageBox(_("Could not determine the command for running the browser."),
-                  wxT("Browsing problem"), wxOK|wxICON_EXCLAMATION);
+                     wxT("Browsing problem"), wxOK|wxICON_EXCLAMATION);
         return ;
     }
 
-    ok = (wxExecute(cmd, FALSE) != 0);
+    ok = (wxExecute(cmd, false) != 0);
 #endif
 }
 
@@ -254,17 +251,14 @@ bool apInvokeAppForFile(const wxString& filename)
         msg.Printf(wxT("Sorry, could not determine what application to invoke for extension %s\nYou may need to edit your MIME types."),
             ext.c_str());
         wxMessageBox(msg, wxT("Application Invocation"), wxICON_EXCLAMATION|wxOK);
-        return FALSE;
+        return false;
     }
 
     wxString cmd;
-    bool ok = ft->GetOpenCommand(&cmd,
-                                 wxFileType::MessageParameters(filename, _T("")));
+    ft->GetOpenCommand(&cmd, wxFileType::MessageParameters(filename, _T("")));
     delete ft;
 
-    ok = (wxExecute(cmd, FALSE) != 0);
-
-    return ok;
+    return (wxExecute(cmd, false) != 0);
 }
 
 // Find the absolute path where this application has been run from.
@@ -343,7 +337,7 @@ void apAddContextHelpButton(wxWindow*
 #ifdef __WXMAC__
     wxSize buttonSize(20, 20);
 #else
-    wxSize buttonSize(-1, -1);
+    wxSize buttonSize = wxDefaultSize;
 #endif
     wxButton *contextButton = new wxContextHelpButton( parent, wxID_CONTEXT_HELP,
         wxDefaultPosition, buttonSize);
@@ -414,7 +408,7 @@ void wxIconInfo::SetIconId(int state, bool enabled, int iconId)
 wxIconTable::wxIconTable(wxImageList* imageList)
 {
     m_imageList = imageList;
-    DeleteContents(TRUE);
+    DeleteContents(true);
 }
 
 void wxIconTable::AppendInfo(wxIconInfo* info)
@@ -435,7 +429,7 @@ bool wxIconTable::AddInfo(const wxString& name, const wxIcon& icon, int state, b
         Append(info);
     }
     info->SetIconId(state, enabled, m_imageList->Add(icon));
-    return TRUE;
+    return true;
 }
 
 wxIconInfo* wxIconTable::FindInfo(const wxString& name) const
@@ -463,9 +457,9 @@ bool wxIconTable::SetIconId(const wxString& name, int state, bool enabled, int i
 {
     wxIconInfo* info = FindInfo(name);
     if (!info)
-        return FALSE;
+        return false;
     info->SetIconId(state, enabled, iconId);
-    return TRUE;
+    return true;
 }
 
 // Output stream operators
@@ -517,28 +511,27 @@ bool ctMatchString(const wxString& matchAgainst, const wxString& matchText, bool
 {
     // Fast operation if not matching against whole words only
     if (!wholeWordOnly)
-        return (matchAgainst.Find(matchText) != -1);
+        return (matchAgainst.Find(matchText) != wxNOT_FOUND);
 
     wxString left(matchAgainst);
-    bool success = FALSE;
-    int pos = 0;
+    bool success = false;
     int matchTextLen = (int) matchText.Length();
     while (!success && !matchAgainst.IsEmpty())
     {
-        pos = left.Find(matchText);
-        if (pos == -1)
-            return FALSE;
+        int pos = left.Find(matchText);
+        if (pos == wxNOT_FOUND)
+            return false;
 
-        bool firstCharOK = FALSE;
-        bool lastCharOK = FALSE;
+        bool firstCharOK = false;
+        bool lastCharOK = false;
         if (pos == 0 || !wxIsalnum(left[(size_t) (pos-1)]))
-            firstCharOK = TRUE;
+            firstCharOK = true;
 
         if (((pos + matchTextLen) == (int) left.Length()) || !wxIsalnum(left[(size_t) (pos + matchTextLen)]))
-            lastCharOK = TRUE;
+            lastCharOK = true;
 
         if (firstCharOK && lastCharOK)
-            success = TRUE;
+            success = true;
 
         left = left.Mid(pos+1);
     }