]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/utilscmn.cpp
Stupid bug: using LastError() instead of Error()
[wxWidgets.git] / src / common / utilscmn.cpp
index 6a6371248134e8fdc57e817463617d7c768fdcd0..5a685ccc754f50eb7f42318c072f493ea31c96ed 100644 (file)
     #endif
 #endif
 
+#if wxUSE_GUI
+    #include "wx/colordlg.h"
+#endif // wxUSE_GUI
+
 #include <time.h>
 
 #ifndef __MWERKS__
@@ -865,19 +869,14 @@ int wxMessageBox(const wxString& message, const wxString& caption, long style,
     {
         case wxID_OK:
             return wxOK;
-            break;
         case wxID_YES:
             return wxYES;
-            break;
         case wxID_NO:
             return wxNO;
-            break;
         default:
         case wxID_CANCEL:
             return wxCANCEL;
-            break;
     }
-    return ans;
 }
 
 #if wxUSE_TEXTDLG
@@ -885,14 +884,58 @@ wxString wxGetTextFromUser(const wxString& message, const wxString& caption,
                         const wxString& defaultValue, wxWindow *parent,
                         int x, int y, bool WXUNUSED(centre) )
 {
+    wxString str;
     wxTextEntryDialog dialog(parent, message, caption, defaultValue, wxOK|wxCANCEL, wxPoint(x, y));
     if (dialog.ShowModal() == wxID_OK)
-        return dialog.GetValue();
-    else
-        return wxString("");
+    {
+        str = dialog.GetValue();
+    }
+
+    return str;
+}
+
+wxString wxGetPasswordFromUser(const wxString& message,
+                               const wxString& caption,
+                               const wxString& defaultValue,
+                               wxWindow *parent)
+{
+    wxString str;
+    wxTextEntryDialog dialog(parent, message, caption, defaultValue,
+                             wxOK | wxCANCEL | wxTE_PASSWORD);
+    if ( dialog.ShowModal() == wxID_OK )
+    {
+        str = dialog.GetValue();
+    }
+
+    return str;
 }
+
 #endif // wxUSE_TEXTDLG
 
+wxColour wxGetColourFromUser(wxWindow *parent, const wxColour& colInit)
+{
+      wxColourData data;
+      data.SetChooseFull(TRUE);
+      if ( colInit.Ok() )
+      {
+          data.SetColour((wxColour &)colInit); // const_cast
+      }
+
+      wxColour colRet;
+      wxColourDialog dialog(parent, &data);
+      if ( dialog.ShowModal() == wxID_OK )
+      {
+          colRet = dialog.GetColourData().GetColour();
+      }
+      //else: leave it invalid
+
+      return colRet;
+}
+
+// ----------------------------------------------------------------------------
+// missing C RTL functions (FIXME shouldn't be here at all)
+// ----------------------------------------------------------------------------
+
 #ifdef __MWERKS__
 char *strdup(const char *s)
 {
@@ -1040,3 +1083,37 @@ wxString wxGetHomeDir()
 
     return home;
 }
+
+#if 0
+
+wxString wxGetCurrentDir()
+{
+    wxString dir;
+    size_t len = 1024;
+    bool ok;
+    do
+    {
+        ok = getcwd(dir.GetWriteBuf(len + 1), len) != NULL;
+        dir.UngetWriteBuf();
+
+        if ( !ok )
+        {
+            if ( errno != ERANGE )
+            {
+                wxLogSysError(_T("Failed to get current directory"));
+
+                return wxEmptyString;
+            }
+            else
+            {
+                // buffer was too small, retry with a larger one
+                len *= 2;
+            }
+        }
+        //else: ok
+    } while ( !ok );
+
+    return dir;
+}
+
+#endif // 0