X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7c78e7c70271608b076b1dbed201b1204e6898d4..f8c5636c42238296eb67bf73d1da3c5acb010fee:/src/qt/filedlg.cpp diff --git a/src/qt/filedlg.cpp b/src/qt/filedlg.cpp index c8b6e78720..57ff74897b 100644 --- a/src/qt/filedlg.cpp +++ b/src/qt/filedlg.cpp @@ -1,125 +1,140 @@ ///////////////////////////////////////////////////////////////////////////// // Name: filedlg.cpp -// Purpose: -// Author: Robert Roebling -// Created: 01/02/97 -// Id: -// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem -// Licence: wxWindows licence +// Purpose: wxFileDialog +// Author: AUTHOR +// Modified by: +// Created: ??/??/98 +// RCS-ID: $Id$ +// Copyright: (c) AUTHOR +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ #pragma implementation "filedlg.h" #endif -#include "wx/filedlg.h" +#include "wx/defs.h" #include "wx/utils.h" -#include "wx/intl.h" -#include "wx/generic/msgdlgg.h" - -//----------------------------------------------------------------------------- -// wxFileDialog -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxFileDialog,wxDialog) - -wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, - const wxString& defaultDir, const wxString& defaultFileName, - const wxString& wildCard, - long style, const wxPoint& pos ) -{ - m_message = message; - m_path = ""; - m_fileName = defaultFileName; - m_dir = defaultDir; - m_wildCard = wildCard; - m_dialogStyle = style; - m_filterIndex = 1; - - m_path.Append(m_dir); - if(! m_path.IsEmpty() && m_path.Last()!='/') m_path.Append('/'); - m_path.Append(m_fileName); - -}; - -int wxFileDialog::ShowModal(void) -{ - int ret = wxDialog::ShowModal(); +#include "wx/dialog.h" +#include "wx/filedlg.h" - if (ret == wxID_OK) - { - }; - return ret; -}; - +IMPLEMENT_CLASS(wxFileDialog, wxDialog) char *wxFileSelector(const char *title, const char *defaultDir, const char *defaultFileName, const char *defaultExtension, const char *filter, int flags, wxWindow *parent, int x, int y) { - wxString filter2(""); - if ( defaultExtension && !filter ) - filter2 = wxString("*.") + wxString(defaultExtension) ; - else if ( filter ) - filter2 = filter; - - wxString defaultDirString; - if (defaultDir) - defaultDirString = defaultDir; - else - defaultDirString = ""; - - wxString defaultFilenameString; - if (defaultFileName) - defaultFilenameString = defaultFileName; - else - defaultFilenameString = ""; - - wxFileDialog fileDialog(parent, title, defaultDirString, defaultFilenameString, - filter2, flags, wxPoint(x, y)); - - if ( fileDialog.ShowModal() == wxID_OK ) - { - strcpy(wxBuffer, (const char *)fileDialog.GetPath()); - return wxBuffer; - } - else - return NULL; -}; - -char* wxLoadFileSelector(const char *what, const char *extension, const char *default_name, - wxWindow *parent ) -{ - char *ext = (char *)extension; - - char prompt[50]; - wxString str = _("Load %s file"); - sprintf(prompt, str, what); + // If there's a default extension specified but no filter, we create a suitable + // filter. + + wxString filter2(""); + if ( defaultExtension && !filter ) + filter2 = wxString("*.") + wxString(defaultExtension) ; + else if ( filter ) + filter2 = filter; + + wxString defaultDirString; + if (defaultDir) + defaultDirString = defaultDir; + else + defaultDirString = ""; + + wxString defaultFilenameString; + if (defaultFileName) + defaultFilenameString = defaultFileName; + else + defaultFilenameString = ""; + + wxFileDialog fileDialog(parent, title, defaultDirString, defaultFilenameString, filter2, flags, wxPoint(x, y)); + + if ( fileDialog.ShowModal() == wxID_OK ) + { + strcpy(wxBuffer, (const char *)fileDialog.GetPath()); + return wxBuffer; + } + else + return NULL; +} + +char *wxFileSelectorEx(const char *title, + const char *defaultDir, + const char *defaultFileName, + int* defaultFilterIndex, + const char *filter, + int flags, + wxWindow* parent, + int x, + int y) - if (*ext == '.') ext++; - char wild[60]; - sprintf(wild, "*.%s", ext); +{ + wxFileDialog fileDialog(parent, title ? title : "", defaultDir ? defaultDir : "", + defaultFileName ? defaultFileName : "", filter ? filter : "", flags, wxPoint(x, y)); + + if ( fileDialog.ShowModal() == wxID_OK ) + { + *defaultFilterIndex = fileDialog.GetFilterIndex(); + strcpy(wxBuffer, (const char *)fileDialog.GetPath()); + return wxBuffer; + } + else + return NULL; +} - return wxFileSelector (prompt, NULL, default_name, ext, wild, 0, parent); -}; +wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, + const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard, + long style, const wxPoint& pos) +{ + m_message = message; + m_dialogStyle = style; + m_parent = parent; + m_path = ""; + m_fileName = defaultFileName; + m_dir = defaultDir; + m_wildCard = wildCard; + m_filterIndex = 1; +} + +int wxFileDialog::ShowModal() +{ + // TODO + wxID_CANCEL; +} -char* wxSaveFileSelector(const char *what, const char *extension, const char *default_name, - wxWindow *parent ) +// Generic file load/save dialog +static char * +wxDefaultFileSelector(bool load, const char *what, const char *extension, const char *default_name, wxWindow *parent) { char *ext = (char *)extension; char prompt[50]; - wxString str = _("Save %s file"); - sprintf(prompt, str, what); + wxString str; + if (load) + str = "Load %s file"; + else + str = "Save %s file"; + sprintf(prompt, wxGetTranslation(str), what); if (*ext == '.') ext++; char wild[60]; sprintf(wild, "*.%s", ext); return wxFileSelector (prompt, NULL, default_name, ext, wild, 0, parent); -}; +} + +// Generic file load dialog +char * +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) +{ + return wxDefaultFileSelector(FALSE, what, extension, default_name, parent); +}