#include "wx/filedlg.h"
#include "wx/intl.h"
#include "wx/app.h"
+#include "wx/settings.h"
#include <Xm/Xm.h>
#include <Xm/MwmUtil.h>
#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)
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,
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 = "";
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();
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);
if (entirePath != "")
{
- Widget selectionWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_TEXT);
XmTextSetString(selectionWidget, (char*) (const char*) entirePath);
}
else
filter = m_wildCard;
- Widget filterWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_FILTER_TEXT);
XmTextSetString(filterWidget, (char*) (const char*) filter);
XmFileSelectionDoSearch(fileSel, NULL);
}
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;
}
// 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;
}
// 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);
}