]> git.saurik.com Git - wxWidgets.git/blame - src/stubs/filedlg.cpp
1. sorted wxListBox and wxComboBox seem to work under wxGTK
[wxWidgets.git] / src / stubs / filedlg.cpp
CommitLineData
93cf77c0
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: filedlg.cpp
3// Purpose: wxFileDialog
4// Author: AUTHOR
5// Modified by:
6// Created: ??/??/98
7// RCS-ID: $Id$
8// Copyright: (c) AUTHOR
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "filedlg.h"
14#endif
15
16#include "wx/defs.h"
17#include "wx/utils.h"
18#include "wx/dialog.h"
19#include "wx/filedlg.h"
34138703 20#include "wx/intl.h"
93cf77c0
JS
21
22#if !USE_SHARED_LIBRARY
23IMPLEMENT_CLASS(wxFileDialog, wxDialog)
24#endif
25
7482b220 26wxString wxFileSelector(const char *title,
93cf77c0
JS
27 const char *defaultDir, const char *defaultFileName,
28 const char *defaultExtension, const char *filter, int flags,
29 wxWindow *parent, int x, int y)
30{
31 // If there's a default extension specified but no filter, we create a suitable
32 // filter.
33
34 wxString filter2("");
35 if ( defaultExtension && !filter )
36 filter2 = wxString("*.") + wxString(defaultExtension) ;
37 else if ( filter )
38 filter2 = filter;
39
40 wxString defaultDirString;
41 if (defaultDir)
42 defaultDirString = defaultDir;
43 else
44 defaultDirString = "";
45
46 wxString defaultFilenameString;
47 if (defaultFileName)
48 defaultFilenameString = defaultFileName;
49 else
50 defaultFilenameString = "";
51
52 wxFileDialog fileDialog(parent, title, defaultDirString, defaultFilenameString, filter2, flags, wxPoint(x, y));
53
54 if ( fileDialog.ShowModal() == wxID_OK )
55 {
7482b220 56 return fileDialog.GetPath();
93cf77c0
JS
57 }
58 else
7482b220 59 return wxEmptyString;
93cf77c0
JS
60}
61
ad813b00 62wxString wxFileSelectorEx(const char *title,
93cf77c0
JS
63 const char *defaultDir,
64 const char *defaultFileName,
65 int* defaultFilterIndex,
66 const char *filter,
67 int flags,
68 wxWindow* parent,
69 int x,
70 int y)
71
72{
73 wxFileDialog fileDialog(parent, title ? title : "", defaultDir ? defaultDir : "",
74 defaultFileName ? defaultFileName : "", filter ? filter : "", flags, wxPoint(x, y));
75
76 if ( fileDialog.ShowModal() == wxID_OK )
77 {
78 *defaultFilterIndex = fileDialog.GetFilterIndex();
7482b220 79 return fileDialog.GetPath();
93cf77c0
JS
80 }
81 else
7482b220 82 return wxEmptyString;
93cf77c0
JS
83}
84
85wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
86 const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard,
87 long style, const wxPoint& pos)
88{
89 m_message = message;
90 m_dialogStyle = style;
91 m_parent = parent;
92 m_path = "";
93 m_fileName = defaultFileName;
94 m_dir = defaultDir;
95 m_wildCard = wildCard;
96 m_filterIndex = 1;
97}
98
99int wxFileDialog::ShowModal()
100{
101 // TODO
34138703 102 return wxID_CANCEL;
93cf77c0
JS
103}
104
105// Generic file load/save dialog
7482b220 106static wxString wxDefaultFileSelector(bool load, const char *what, const char *extension, const char *default_name, wxWindow *parent)
93cf77c0
JS
107{
108 char *ext = (char *)extension;
109
110 char prompt[50];
111 wxString str;
112 if (load)
113 str = "Load %s file";
114 else
115 str = "Save %s file";
116 sprintf(prompt, wxGetTranslation(str), what);
117
118 if (*ext == '.') ext++;
119 char wild[60];
120 sprintf(wild, "*.%s", ext);
121
122 return wxFileSelector (prompt, NULL, default_name, ext, wild, 0, parent);
123}
124
125// Generic file load dialog
7482b220 126wxString wxLoadFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent)
93cf77c0
JS
127{
128 return wxDefaultFileSelector(TRUE, what, extension, default_name, parent);
129}
130
131
132// Generic file save dialog
7482b220 133wxString wxSaveFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent)
93cf77c0
JS
134{
135 return wxDefaultFileSelector(FALSE, what, extension, default_name, parent);
136}
137
138