]> git.saurik.com Git - wxWidgets.git/blame - src/qt/filedlg.cpp
stray #include "wincmn.cpp" removed
[wxWidgets.git] / src / qt / filedlg.cpp
CommitLineData
7c78e7c7
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: filedlg.cpp
3// Purpose:
4// Author: Robert Roebling
5// Created: 01/02/97
6// Id:
7// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11#ifdef __GNUG__
12#pragma implementation "filedlg.h"
13#endif
14
15#include "wx/filedlg.h"
16#include "wx/utils.h"
17#include "wx/intl.h"
18#include "wx/generic/msgdlgg.h"
19
20//-----------------------------------------------------------------------------
21// wxFileDialog
22//-----------------------------------------------------------------------------
23
24IMPLEMENT_DYNAMIC_CLASS(wxFileDialog,wxDialog)
25
26wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
27 const wxString& defaultDir, const wxString& defaultFileName,
28 const wxString& wildCard,
29 long style, const wxPoint& pos )
30{
31 m_message = message;
32 m_path = "";
33 m_fileName = defaultFileName;
34 m_dir = defaultDir;
35 m_wildCard = wildCard;
36 m_dialogStyle = style;
37 m_filterIndex = 1;
38
39 m_path.Append(m_dir);
40 if(! m_path.IsEmpty() && m_path.Last()!='/') m_path.Append('/');
41 m_path.Append(m_fileName);
42
43};
44
45int wxFileDialog::ShowModal(void)
46{
47 int ret = wxDialog::ShowModal();
48
49 if (ret == wxID_OK)
50 {
51 };
52 return ret;
53};
54
55
56char *wxFileSelector(const char *title,
57 const char *defaultDir, const char *defaultFileName,
58 const char *defaultExtension, const char *filter, int flags,
59 wxWindow *parent, int x, int y)
60{
61 wxString filter2("");
62 if ( defaultExtension && !filter )
63 filter2 = wxString("*.") + wxString(defaultExtension) ;
64 else if ( filter )
65 filter2 = filter;
66
67 wxString defaultDirString;
68 if (defaultDir)
69 defaultDirString = defaultDir;
70 else
71 defaultDirString = "";
72
73 wxString defaultFilenameString;
74 if (defaultFileName)
75 defaultFilenameString = defaultFileName;
76 else
77 defaultFilenameString = "";
78
79 wxFileDialog fileDialog(parent, title, defaultDirString, defaultFilenameString,
80 filter2, flags, wxPoint(x, y));
81
82 if ( fileDialog.ShowModal() == wxID_OK )
83 {
84 strcpy(wxBuffer, (const char *)fileDialog.GetPath());
85 return wxBuffer;
86 }
87 else
88 return NULL;
89};
90
91char* wxLoadFileSelector(const char *what, const char *extension, const char *default_name,
92 wxWindow *parent )
93{
94 char *ext = (char *)extension;
95
96 char prompt[50];
97 wxString str = _("Load %s file");
98 sprintf(prompt, str, what);
99
100 if (*ext == '.') ext++;
101 char wild[60];
102 sprintf(wild, "*.%s", ext);
103
104 return wxFileSelector (prompt, NULL, default_name, ext, wild, 0, parent);
105};
106
107char* wxSaveFileSelector(const char *what, const char *extension, const char *default_name,
108 wxWindow *parent )
109{
110 char *ext = (char *)extension;
111
112 char prompt[50];
113 wxString str = _("Save %s file");
114 sprintf(prompt, 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
124
125