]> git.saurik.com Git - wxWidgets.git/blob - src/qt/filedlg.cpp
Fixed Dialog Editor compilation and window sizing bug. Various warning-related
[wxWidgets.git] / src / qt / filedlg.cpp
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"
20
21 #if !USE_SHARED_LIBRARY
22 IMPLEMENT_CLASS(wxFileDialog, wxDialog)
23 #endif
24
25 char *wxFileSelector(const char *title,
26 const char *defaultDir, const char *defaultFileName,
27 const char *defaultExtension, const char *filter, int flags,
28 wxWindow *parent, int x, int y)
29 {
30 // If there's a default extension specified but no filter, we create a suitable
31 // filter.
32
33 wxString filter2("");
34 if ( defaultExtension && !filter )
35 filter2 = wxString("*.") + wxString(defaultExtension) ;
36 else if ( filter )
37 filter2 = filter;
38
39 wxString defaultDirString;
40 if (defaultDir)
41 defaultDirString = defaultDir;
42 else
43 defaultDirString = "";
44
45 wxString defaultFilenameString;
46 if (defaultFileName)
47 defaultFilenameString = defaultFileName;
48 else
49 defaultFilenameString = "";
50
51 wxFileDialog fileDialog(parent, title, defaultDirString, defaultFilenameString, filter2, flags, wxPoint(x, y));
52
53 if ( fileDialog.ShowModal() == wxID_OK )
54 {
55 strcpy(wxBuffer, (const char *)fileDialog.GetPath());
56 return wxBuffer;
57 }
58 else
59 return NULL;
60 }
61
62 char *wxFileSelectorEx(const char *title,
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();
79 strcpy(wxBuffer, (const char *)fileDialog.GetPath());
80 return wxBuffer;
81 }
82 else
83 return NULL;
84 }
85
86 wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
87 const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard,
88 long style, const wxPoint& pos)
89 {
90 m_message = message;
91 m_dialogStyle = style;
92 m_parent = parent;
93 m_path = "";
94 m_fileName = defaultFileName;
95 m_dir = defaultDir;
96 m_wildCard = wildCard;
97 m_filterIndex = 1;
98 }
99
100 int wxFileDialog::ShowModal()
101 {
102 // TODO
103 wxID_CANCEL;
104 }
105
106 // Generic file load/save dialog
107 static char *
108 wxDefaultFileSelector(bool load, const char *what, const char *extension, const char *default_name, wxWindow *parent)
109 {
110 char *ext = (char *)extension;
111
112 char prompt[50];
113 wxString str;
114 if (load)
115 str = "Load %s file";
116 else
117 str = "Save %s file";
118 sprintf(prompt, wxGetTranslation(str), what);
119
120 if (*ext == '.') ext++;
121 char wild[60];
122 sprintf(wild, "*.%s", ext);
123
124 return wxFileSelector (prompt, NULL, default_name, ext, wild, 0, parent);
125 }
126
127 // Generic file load dialog
128 char *
129 wxLoadFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent)
130 {
131 return wxDefaultFileSelector(TRUE, what, extension, default_name, parent);
132 }
133
134
135 // Generic file save dialog
136 char *
137 wxSaveFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent)
138 {
139 return wxDefaultFileSelector(FALSE, what, extension, default_name, parent);
140 }
141
142