]> git.saurik.com Git - wxWidgets.git/blobdiff - src/motif/filedlg.cpp
wxSplitPath() bugs corrected and it's documented
[wxWidgets.git] / src / motif / filedlg.cpp
index a17964d2b87b4d7a09e58973ff288dc0bce68fd5..ed6a27f8754dd6c51e713af953935ccc60ef2480 100644 (file)
@@ -19,6 +19,7 @@
 #include "wx/filedlg.h"
 #include "wx/intl.h"
 #include "wx/app.h"
+#include "wx/settings.h"
 
 #include <Xm/Xm.h>
 #include <Xm/MwmUtil.h>
@@ -43,7 +44,7 @@ IMPLEMENT_CLASS(wxFileDialog, wxDialog)
 #define wxFSB_HEIGHT               500
 
 
-char *wxFileSelector(const char *title,
+wxString wxFileSelector(const char *title,
                      const char *defaultDir, const char *defaultFileName,
                      const char *defaultExtension, const char *filter, int flags,
                      wxWindow *parent, int x, int y)
@@ -73,14 +74,13 @@ char *wxFileSelector(const char *title,
     
     if ( fileDialog.ShowModal() == wxID_OK )
     {
-        strcpy(wxBuffer, (const char *)fileDialog.GetPath());
-        return wxBuffer;
+        return fileDialog.GetPath();
     }
     else
-        return NULL;
+        return wxEmptyString;
 }
 
-char *wxFileSelectorEx(const char *title,
+wxString wxFileSelectorEx(const char *title,
                        const char *defaultDir,
                        const char *defaultFileName,
                        int* defaultFilterIndex,
@@ -97,11 +97,10 @@ char *wxFileSelectorEx(const char *title,
     if ( fileDialog.ShowModal() == wxID_OK )
     {
         *defaultFilterIndex = fileDialog.GetFilterIndex();
-        strcpy(wxBuffer, (const char *)fileDialog.GetPath());
-        return wxBuffer;
+        return fileDialog.GetPath();
     }
     else
-        return NULL;
+        return wxEmptyString;
 }
 
 wxString wxFileDialog::m_fileSelectorAnswer = "";
@@ -144,6 +143,38 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
     m_pos = pos;
 }
 
+static void wxChangeListBoxColours(wxWindow* win, Widget widget)
+{
+    win->DoChangeBackgroundColour((WXWidget) widget, *wxWHITE);
+
+    // Change colour of the scrolled areas of the listboxes
+    Widget listParent = XtParent (widget);
+    win->DoChangeBackgroundColour((WXWidget) listParent, *wxWHITE, TRUE);
+
+    Widget hsb = (Widget) 0;
+    Widget vsb = (Widget) 0;
+    XtVaGetValues (listParent,
+        XmNhorizontalScrollBar, &hsb,
+        XmNverticalScrollBar, &vsb,
+        NULL);
+    
+   /* TODO: should scrollbars be affected? Should probably have separate
+    * function to change them (by default, taken from wxSystemSettings)
+    */
+    wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
+    win->DoChangeBackgroundColour((WXWidget) hsb, backgroundColour, TRUE);
+    win->DoChangeBackgroundColour((WXWidget) vsb, backgroundColour, TRUE);
+
+    if (hsb)
+      XtVaSetValues (hsb,
+        XmNtroughColor, backgroundColour.AllocColour(XtDisplay(hsb)),
+        NULL);
+    if (vsb)
+      XtVaSetValues (vsb,
+        XmNtroughColor, backgroundColour.AllocColour(XtDisplay(vsb)),
+        NULL);
+}
+
 int wxFileDialog::ShowModal()
 {
     wxBeginBusyCursor();
@@ -159,6 +190,15 @@ int wxFileDialog::ShowModal()
     
     Widget fileSel = XmCreateFileSelectionDialog(parentWidget, "file_selector", NULL, 0);
     XtUnmanageChild(XmFileSelectionBoxGetChild(fileSel, XmDIALOG_HELP_BUTTON));
+
+    Widget filterWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_FILTER_TEXT);
+    Widget selectionWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_TEXT);
+    Widget dirListWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_DIR_LIST);
+    Widget fileListWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_LIST);
+    Widget okWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_OK_BUTTON);
+    Widget applyWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_APPLY_BUTTON);
+    Widget cancelWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_CANCEL_BUTTON);
+
     
     Widget shell = XtParent(fileSel);
     
@@ -182,7 +222,6 @@ int wxFileDialog::ShowModal()
     
     if (entirePath != "")
     {
-        Widget selectionWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_TEXT);
         XmTextSetString(selectionWidget, (char*) (const char*) entirePath);
     }
     
@@ -194,7 +233,6 @@ int wxFileDialog::ShowModal()
         else
             filter = m_wildCard;
         
-        Widget filterWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_FILTER_TEXT);
         XmTextSetString(filterWidget, (char*) (const char*) filter);
         XmFileSelectionDoSearch(fileSel, NULL);
     }
@@ -231,9 +269,21 @@ int wxFileDialog::ShowModal()
         XmNresizePolicy, XmRESIZE_NONE,
         NULL);
 #endif
+    DoChangeBackgroundColour((WXWidget) fileSel, m_backgroundColour);
+    DoChangeBackgroundColour((WXWidget) filterWidget, *wxWHITE);
+    DoChangeBackgroundColour((WXWidget) selectionWidget, *wxWHITE);
+
+    /* For some reason this crashes
+    DoChangeBackgroundColour((WXWidget) okWidget, m_backgroundColour, TRUE);
+    DoChangeBackgroundColour((WXWidget) cancelWidget, m_backgroundColour, TRUE);
+    DoChangeBackgroundColour((WXWidget) applyWidget, m_backgroundColour, TRUE);
+    */
+
+    wxChangeListBoxColours(this, dirListWidget);
+    wxChangeListBoxColours(this, fileListWidget);
     
     XtManageChild(fileSel);
-    
+
     m_fileSelectorAnswer = "";
     m_fileSelectorReturned = FALSE;
     
@@ -274,7 +324,7 @@ int wxFileDialog::ShowModal()
 }
 
 // Generic file load/save dialog
-static char *
+static wxString
 wxDefaultFileSelector(bool load, const char *what, const char *extension, const char *default_name, wxWindow *parent)
 {
     char *ext = (char *)extension;
@@ -295,16 +345,14 @@ wxDefaultFileSelector(bool load, const char *what, const char *extension, const
 }
 
 // Generic file load dialog
-char *
-wxLoadFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent)
+wxString wxLoadFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent)
 {
     return wxDefaultFileSelector(TRUE, what, extension, default_name, parent);
 }
 
 
 // Generic file save dialog
-char *
-wxSaveFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent)
+wxString wxSaveFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent)
 {
     return wxDefaultFileSelector(FALSE, what, extension, default_name, parent);
 }