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