+// Convert a colour to a 6-digit hex string
+wxString wxColourToHexString(const wxColour& col)
+{
+ wxString hex;
+
+ hex += wxDecToHex(col.Red());
+ hex += wxDecToHex(col.Green());
+ hex += wxDecToHex(col.Blue());
+
+ return hex;
+}
+
+// Convert 6-digit hex string to a colour
+wxColour wxHexStringToColour(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));
+
+ return wxColour(r, g, b);
+}
+
+// Find the absolute path where this application has been run from.
+// argv0 is wxTheApp->argv[0]
+// cwd is the current working directory (at startup)
+// appVariableName is the name of a variable containing the directory for this app, e.g.
+// MYAPPDIR. This is checked first.
+
+wxString wxFindAppPath(const wxString& argv0, const wxString& cwd, const wxString& appVariableName)
+{
+ wxString str;
+
+ // Try appVariableName
+ if (!appVariableName.IsEmpty())
+ {
+ str = wxGetenv(appVariableName);
+ if (!str.IsEmpty())
+ return str;
+ }
+
+ if (wxIsAbsolutePath(argv0))
+ return wxPathOnly(argv0);
+ else
+ {
+ // Is it a relative path?
+ wxString currentDir(cwd);
+ if (currentDir.Last() != wxFILE_SEP_PATH)
+ currentDir += wxFILE_SEP_PATH;
+
+ str = currentDir + argv0;
+ if (wxFileExists(str))
+ return wxPathOnly(str);
+ }
+
+ // OK, it's neither an absolute path nor a relative path.
+ // Search PATH.
+
+ wxPathList pathList;
+ pathList.AddEnvList(wxT("PATH"));
+ str = pathList.FindAbsoluteValidPath(argv0);
+ if (!str.IsEmpty())
+ return wxPathOnly(str);
+
+ // Failed
+ return wxEmptyString;
+}