]> git.saurik.com Git - wxWidgets.git/blame - src/stubs/filedlg.cpp
Fixed remaining int vs. long warnings.
[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 21
93cf77c0 22IMPLEMENT_CLASS(wxFileDialog, wxDialog)
93cf77c0 23
7482b220 24wxString wxFileSelector(const char *title,
93cf77c0
JS
25 const char *defaultDir, const char *defaultFileName,
26 const char *defaultExtension, const char *filter, int flags,
27 wxWindow *parent, int x, int y)
28{
29 // If there's a default extension specified but no filter, we create a suitable
30 // filter.
31
32 wxString filter2("");
33 if ( defaultExtension && !filter )
34 filter2 = wxString("*.") + wxString(defaultExtension) ;
35 else if ( filter )
36 filter2 = filter;
37
38 wxString defaultDirString;
39 if (defaultDir)
40 defaultDirString = defaultDir;
41 else
42 defaultDirString = "";
43
44 wxString defaultFilenameString;
45 if (defaultFileName)
46 defaultFilenameString = defaultFileName;
47 else
48 defaultFilenameString = "";
49
50 wxFileDialog fileDialog(parent, title, defaultDirString, defaultFilenameString, filter2, flags, wxPoint(x, y));
51
52 if ( fileDialog.ShowModal() == wxID_OK )
53 {
7482b220 54 return fileDialog.GetPath();
93cf77c0
JS
55 }
56 else
7482b220 57 return wxEmptyString;
93cf77c0
JS
58}
59
ad813b00 60wxString wxFileSelectorEx(const char *title,
93cf77c0
JS
61 const char *defaultDir,
62 const char *defaultFileName,
63 int* defaultFilterIndex,
64 const char *filter,
65 int flags,
66 wxWindow* parent,
67 int x,
68 int y)
69
70{
71 wxFileDialog fileDialog(parent, title ? title : "", defaultDir ? defaultDir : "",
72 defaultFileName ? defaultFileName : "", filter ? filter : "", flags, wxPoint(x, y));
73
74 if ( fileDialog.ShowModal() == wxID_OK )
75 {
76 *defaultFilterIndex = fileDialog.GetFilterIndex();
7482b220 77 return fileDialog.GetPath();
93cf77c0
JS
78 }
79 else
7482b220 80 return wxEmptyString;
93cf77c0
JS
81}
82
83wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
84 const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard,
85 long style, const wxPoint& pos)
86{
87 m_message = message;
88 m_dialogStyle = style;
89 m_parent = parent;
90 m_path = "";
91 m_fileName = defaultFileName;
92 m_dir = defaultDir;
93 m_wildCard = wildCard;
94 m_filterIndex = 1;
95}
96
97int wxFileDialog::ShowModal()
98{
99 // TODO
34138703 100 return wxID_CANCEL;
93cf77c0
JS
101}
102
103// Generic file load/save dialog
7482b220 104static wxString wxDefaultFileSelector(bool load, const char *what, const char *extension, const char *default_name, wxWindow *parent)
93cf77c0
JS
105{
106 char *ext = (char *)extension;
107
108 char prompt[50];
109 wxString str;
110 if (load)
111 str = "Load %s file";
112 else
113 str = "Save %s file";
114 sprintf(prompt, wxGetTranslation(str), what);
115
116 if (*ext == '.') ext++;
117 char wild[60];
118 sprintf(wild, "*.%s", ext);
119
120 return wxFileSelector (prompt, NULL, default_name, ext, wild, 0, parent);
121}
122
123// Generic file load dialog
7482b220 124wxString wxLoadFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent)
93cf77c0
JS
125{
126 return wxDefaultFileSelector(TRUE, what, extension, default_name, parent);
127}
128
129
130// Generic file save dialog
7482b220 131wxString wxSaveFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent)
93cf77c0
JS
132{
133 return wxDefaultFileSelector(FALSE, what, extension, default_name, parent);
134}
135
136