]> git.saurik.com Git - wxWidgets.git/blob - src/os2/filedlg.cpp
using Theme layout for measuring as well
[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 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18
19 #ifndef WX_PRECOMP
20 #include <stdio.h>
21 #include "wx/defs.h"
22 #include "wx/utils.h"
23 #include "wx/msgdlg.h"
24 #include "wx/dialog.h"
25 #include "wx/filedlg.h"
26 #include "wx/intl.h"
27 #include "wx/log.h"
28 #endif
29
30 #define INCL_PM
31 #include <os2.h>
32
33 #include "wx/os2/private.h"
34
35 #include <math.h>
36 #include <stdlib.h>
37 #include <string.h>
38
39 IMPLEMENT_CLASS(wxFileDialog, wxDialog)
40
41 wxString wxFileSelector( const char* title
42 ,const char* defaultDir
43 ,const char* defaultFileName
44 ,const char* defaultExtension
45 ,const char* filter
46 ,int flags
47 ,wxWindow* parent
48 ,int x
49 ,int y
50 )
51 {
52 // If there's a default extension specified but no filter, we create a suitable
53 // filter.
54
55 wxString filter2("");
56 if ( defaultExtension && !filter )
57 filter2 = wxString("*.") + wxString(defaultExtension) ;
58 else if ( filter )
59 filter2 = filter;
60
61 wxString defaultDirString;
62 if (defaultDir)
63 defaultDirString = defaultDir;
64 else
65 defaultDirString = "";
66
67 wxString defaultFilenameString;
68 if (defaultFileName)
69 defaultFilenameString = defaultFileName;
70 else
71 defaultFilenameString = "";
72
73 wxFileDialog fileDialog(parent, title, defaultDirString, defaultFilenameString, filter2, flags, wxPoint(x, y));
74
75 if ( fileDialog.ShowModal() == wxID_OK )
76 {
77 return fileDialog.GetPath();
78 }
79 else
80 return wxEmptyString;
81 }
82
83 # ifndef MAXPATH
84 # define MAXPATH 400
85 # endif
86
87 # ifndef MAXDRIVE
88 # define MAXDRIVE 3
89 # endif
90
91 # ifndef MAXFILE
92 # define MAXFILE 9
93 # endif
94
95 # ifndef MAXEXT
96 # define MAXEXT 5
97 # endif
98
99 wxString wxFileSelectorEx( const char* title
100 ,const char* defaultDir
101 ,const char* defaultFileName
102 ,int* defaultFilterIndex
103 ,const char* filter
104 ,int flags
105 ,wxWindow* parent
106 ,int x
107 ,int y
108 )
109 {
110 wxFileDialog fileDialog(parent, title ? title : "", defaultDir ? defaultDir : "",
111 defaultFileName ? defaultFileName : "", filter ? filter : "", flags, wxPoint(x, y));
112
113 if ( fileDialog.ShowModal() == wxID_OK )
114 {
115 *defaultFilterIndex = fileDialog.GetFilterIndex();
116 return fileDialog.GetPath();
117 }
118 else
119 return wxEmptyString;
120 }
121
122 wxFileDialog::wxFileDialog( wxWindow* parent
123 ,const wxString& message
124 ,const wxString& defaultDir
125 ,const wxString& defaultFileName
126 ,const wxString& wildCard
127 ,long style
128 ,const wxPoint& pos
129 )
130 {
131 m_message = message;
132 m_dialogStyle = style;
133 m_parent = parent;
134 m_path = "";
135 m_fileName = defaultFileName;
136 m_dir = defaultDir;
137 m_wildCard = wildCard;
138 m_filterIndex = 1;
139 }
140
141 int wxFileDialog::ShowModal()
142 {
143 // TODO
144 return wxID_CANCEL;
145 }
146
147 // Generic file load/save dialog
148 static wxString wxDefaultFileSelector( bool load
149 ,const char* what
150 ,const char* extension
151 ,const char* default_name
152 ,wxWindow* parent
153 )
154 {
155 char *ext = (char *)extension;
156
157 char prompt[50];
158 wxString str;
159 if (load)
160 str = "Load %s file";
161 else
162 str = "Save %s file";
163 sprintf(prompt, wxGetTranslation(str), what);
164
165 if (*ext == '.') ext++;
166 char wild[60];
167 sprintf(wild, "*.%s", ext);
168
169 return wxFileSelector (prompt, NULL, default_name, ext, wild, 0, parent);
170 }
171
172 // Generic file load dialog
173 wxString wxLoadFileSelector( const char* what
174 ,const char* extension
175 ,const char* default_name
176 ,wxWindow* parent
177 )
178 {
179 return wxDefaultFileSelector(TRUE, what, extension, default_name, parent);
180 }
181
182
183 // Generic file save dialog
184 wxString wxSaveFileSelector( const char* what
185 ,const char* extension
186 ,const char* default_name
187 ,wxWindow* parent
188 )
189 {
190 return wxDefaultFileSelector(FALSE, what, extension, default_name, parent);
191 }
192
193