]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/configtool/src/utils.cpp
Resize all top level windows when SIP changes visibility.
[wxWidgets.git] / utils / configtool / src / utils.cpp
index 78d6aca247ac19fd7ff9955c38d993f366c66005..0ec2e0bb0ec63cd2abc877cb1a4434c316c78b58 100644 (file)
@@ -9,10 +9,6 @@
 // Licence:
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
-// #pragma implementation
-#endif
-
 // For compilers that support precompilation, includes "wx/wx.h".
 #include "wx/wxprec.h"
 
 #include "wx/process.h"
 #include "wx/variant.h"
 #include "wx/cmdline.h"
+#include "wx/msgdlg.h"
+#include "wx/log.h"
+#include "wx/sizer.h"
+#include "wx/icon.h"
+#include "wx/intl.h"
 
 #endif
 
@@ -82,9 +83,9 @@ wxString apColourToHexString(const wxColour& col)
 // Convert 6-digit hex string to a colour
 wxColour apHexStringToColour(const wxString& hex)
 {
-    unsigned int r = wxHexToDec(hex.Mid(0, 2));
-    unsigned int g = wxHexToDec(hex.Mid(2, 2));
-    unsigned int b = wxHexToDec(hex.Mid(4, 2));
+    unsigned char r = (unsigned char)wxHexToDec(hex.Mid(0, 2));
+    unsigned char g = (unsigned char)wxHexToDec(hex.Mid(2, 2));
+    unsigned char b = (unsigned char)wxHexToDec(hex.Mid(4, 2));
 
     return wxColour(r, g, b);
 }
@@ -116,7 +117,7 @@ wxFont apStringToFont(const wxString& str)
     int style = wxNORMAL;
     int weight = wxNORMAL;
     int underlined = 0;
-    wxString facename(wxT(""));
+    wxString facename;
 
     wxStringTokenizer tkz(str, wxT(","));
     int i = 0;
@@ -132,7 +133,7 @@ wxFont apStringToFont(const wxString& str)
                 pointSize = 8;
             if (pointSize == 9)
                 pointSize = 10;
-#endif            
+#endif
         }
         else if (i == 1)
             family = StringToInt(token);
@@ -167,56 +168,6 @@ int apFindNotebookPage(wxNotebook* notebook, const wxString& name)
     return -1;
 }
 
-/*
- * View an HTML file
- */
-
-void apViewHTMLFile(const wxString& url)
-{
-#ifdef __WXMSW__
-    HKEY hKey;
-    TCHAR szCmdName[1024];
-    DWORD dwType, dw = sizeof(szCmdName);
-    LONG lRes;
-    lRes = RegOpenKey(HKEY_CLASSES_ROOT, _T("htmlfile\\shell\\open\\command"), &hKey);
-    if(lRes == ERROR_SUCCESS && RegQueryValueEx(hKey,(LPTSTR)NULL, NULL,
-        &dwType, (LPBYTE)szCmdName, &dw) == ERROR_SUCCESS)
-    {
-        wxStrcat(szCmdName, (const wxChar*) url);
-        PROCESS_INFORMATION  piProcInfo;
-        STARTUPINFO          siStartInfo;
-        memset(&siStartInfo, 0, sizeof(STARTUPINFO));
-        siStartInfo.cb = sizeof(STARTUPINFO);
-        CreateProcess(NULL, szCmdName, NULL, NULL, false, 0, NULL,
-            NULL, &siStartInfo, &piProcInfo );
-    }
-    if(lRes == ERROR_SUCCESS)
-        RegCloseKey(hKey);
-#else
-    wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension(wxT("html"));
-    if ( !ft )
-    {
-        wxLogError(_T("Impossible to determine the file type for extension html. Please edit your MIME types."));
-        return ;
-    }
-
-    wxString cmd;
-    bool ok = ft->GetOpenCommand(&cmd,
-                                 wxFileType::MessageParameters(url, _T("")));
-    delete ft;
-
-    if (!ok)
-    {
-        // TODO: some kind of configuration dialog here.
-        wxMessageBox(_("Could not determine the command for running the browser."),
-                     wxT("Browsing problem"), wxOK|wxICON_EXCLAMATION);
-        return ;
-    }
-
-    ok = (wxExecute(cmd, false) != 0);
-#endif
-}
-
 wxString wxGetTempDir()
 {
     wxString dir;
@@ -230,7 +181,7 @@ wxString wxGetTempDir()
         wxString envVar(wxGetenv(_T("TEMP")));
         dir = envVar;
     }
-    
+
     if ( dir.empty() )
     {
         // default
@@ -262,7 +213,7 @@ bool apInvokeAppForFile(const wxString& filename)
     }
 
     wxString cmd;
-    ft->GetOpenCommand(&cmd, wxFileType::MessageParameters(filename, _T("")));
+    ft->GetOpenCommand(&cmd, wxFileType::MessageParameters(filename, wxEmptyString));
     delete ft;
 
     return (wxExecute(cmd, false) != 0);
@@ -277,10 +228,10 @@ bool apInvokeAppForFile(const wxString& filename)
 wxString apFindAppPath(const wxString& argv0, const wxString& cwd, const wxString& appVariableName)
 {
     // Try appVariableName
-    if (!appVariableName.IsEmpty())
+    if (!appVariableName.empty())
     {
         wxString strVar(wxGetenv(appVariableName.c_str()));
-        if (!strVar.IsEmpty())
+        if (!strVar.empty())
             return strVar;
     }
 
@@ -304,7 +255,7 @@ wxString apFindAppPath(const wxString& argv0, const wxString& cwd, const wxStrin
     wxPathList pathList;
     pathList.AddEnvList(wxT("PATH"));
     wxString strPath = pathList.FindAbsoluteValidPath(argv0);
-    if (!strPath.IsEmpty())
+    if (!strPath.empty())
         return wxPathOnly(strPath);
 
     // Failed
@@ -312,25 +263,25 @@ wxString apFindAppPath(const wxString& argv0, const wxString& cwd, const wxStrin
 }
 
 // Adds a context-sensitive help button, for non-Windows platforms
-void apAddContextHelpButton(wxWindow* 
+void apAddContextHelpButton(wxWindow*
                                       #if defined(__WXGTK__) || defined(__WXMAC__)
                                       parent
                                       #else
                                       WXUNUSED(parent)
                                       #endif
-                                      , wxSizer* 
+                                      , wxSizer*
                                                  #if defined(__WXGTK__) || defined(__WXMAC__)
                                                  sizer
                                                  #else
                                                  WXUNUSED(sizer)
                                                  #endif
-                                                 , int 
+                                                 , int
                                                        #if defined(__WXGTK__) || defined(__WXMAC__)
                                                        sizerFlags
                                                        #else
                                                        WXUNUSED(sizerFlags)
                                                        #endif
-                                                       , int 
+                                                       , int
                                                              #if defined(__WXGTK__) || defined(__WXMAC__)
                                                              sizerBorder
                                                              #else
@@ -392,7 +343,7 @@ int wxIconInfo::GetIconId(int state, bool enabled) const
 {
     wxASSERT ( state < (wxMAX_ICON_STATES * 2) );
     wxASSERT ( state < m_maxStates );
-    
+
     return m_states[state * 2 + (enabled ? 0 : 1)];
 }
 
@@ -401,7 +352,7 @@ void wxIconInfo::SetIconId(int state, bool enabled, int iconId)
     wxASSERT ( state < (wxMAX_ICON_STATES * 2) );
     if (state+1 > m_maxStates)
         m_maxStates = state+1;
-    
+
     m_states[state * 2 + (enabled ? 0 : 1)] = iconId;
 }
 
@@ -426,7 +377,7 @@ void wxIconTable::AppendInfo(wxIconInfo* info)
 bool wxIconTable::AddInfo(const wxString& name, const wxIcon& icon, int state, bool enabled)
 {
     wxASSERT (m_imageList != NULL);
-    
+
     wxIconInfo* info = FindInfo(name);
     if (!info)
     {
@@ -521,7 +472,7 @@ bool ctMatchString(const wxString& matchAgainst, const wxString& matchText, bool
     wxString left(matchAgainst);
     bool success = false;
     int matchTextLen = (int) matchText.Length();
-    while (!success && !matchAgainst.IsEmpty())
+    while (!success && !matchAgainst.empty())
     {
         int pos = left.Find(matchText);
         if (pos == wxNOT_FOUND)