]> git.saurik.com Git - wxWidgets.git/blame - src/qt/filedlg.cpp
Removed XPM lib references from makefile
[wxWidgets.git] / src / qt / filedlg.cpp
CommitLineData
7c78e7c7
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: filedlg.cpp
01b2eeec
KB
3// Purpose: wxFileDialog
4// Author: AUTHOR
5// Modified by:
6// Created: ??/??/98
7// RCS-ID: $Id$
8// Copyright: (c) AUTHOR
9// Licence: wxWindows licence
7c78e7c7
RR
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "filedlg.h"
14#endif
15
01b2eeec 16#include "wx/defs.h"
7c78e7c7 17#include "wx/utils.h"
01b2eeec
KB
18#include "wx/dialog.h"
19#include "wx/filedlg.h"
7c78e7c7 20
01b2eeec 21IMPLEMENT_CLASS(wxFileDialog, wxDialog)
7c78e7c7
RR
22
23char *wxFileSelector(const char *title,
24 const char *defaultDir, const char *defaultFileName,
25 const char *defaultExtension, const char *filter, int flags,
26 wxWindow *parent, int x, int y)
27{
01b2eeec
KB
28 // If there's a default extension specified but no filter, we create a suitable
29 // filter.
30
31 wxString filter2("");
32 if ( defaultExtension && !filter )
33 filter2 = wxString("*.") + wxString(defaultExtension) ;
34 else if ( filter )
35 filter2 = filter;
36
37 wxString defaultDirString;
38 if (defaultDir)
39 defaultDirString = defaultDir;
40 else
41 defaultDirString = "";
42
43 wxString defaultFilenameString;
44 if (defaultFileName)
45 defaultFilenameString = defaultFileName;
46 else
47 defaultFilenameString = "";
48
49 wxFileDialog fileDialog(parent, title, defaultDirString, defaultFilenameString, filter2, flags, wxPoint(x, y));
50
51 if ( fileDialog.ShowModal() == wxID_OK )
52 {
53 strcpy(wxBuffer, (const char *)fileDialog.GetPath());
54 return wxBuffer;
55 }
56 else
57 return NULL;
58}
59
60char *wxFileSelectorEx(const char *title,
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)
7c78e7c7 69
01b2eeec
KB
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();
77 strcpy(wxBuffer, (const char *)fileDialog.GetPath());
78 return wxBuffer;
79 }
80 else
81 return NULL;
82}
7c78e7c7 83
01b2eeec
KB
84wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
85 const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard,
86 long style, const wxPoint& pos)
87{
88 m_message = message;
89 m_dialogStyle = style;
90 m_parent = parent;
91 m_path = "";
92 m_fileName = defaultFileName;
93 m_dir = defaultDir;
94 m_wildCard = wildCard;
95 m_filterIndex = 1;
96}
97
98int wxFileDialog::ShowModal()
99{
100 // TODO
101 wxID_CANCEL;
102}
7c78e7c7 103
01b2eeec
KB
104// Generic file load/save dialog
105static char *
106wxDefaultFileSelector(bool load, const char *what, const char *extension, const char *default_name, wxWindow *parent)
7c78e7c7
RR
107{
108 char *ext = (char *)extension;
109
110 char prompt[50];
01b2eeec
KB
111 wxString str;
112 if (load)
113 str = "Load %s file";
114 else
115 str = "Save %s file";
116 sprintf(prompt, wxGetTranslation(str), what);
7c78e7c7
RR
117
118 if (*ext == '.') ext++;
119 char wild[60];
120 sprintf(wild, "*.%s", ext);
121
122 return wxFileSelector (prompt, NULL, default_name, ext, wild, 0, parent);
01b2eeec
KB
123}
124
125// Generic file load dialog
126char *
127wxLoadFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent)
128{
129 return wxDefaultFileSelector(TRUE, what, extension, default_name, parent);
130}
7c78e7c7
RR
131
132
01b2eeec
KB
133// Generic file save dialog
134char *
135wxSaveFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent)
136{
137 return wxDefaultFileSelector(FALSE, what, extension, default_name, parent);
138}
7c78e7c7
RR
139
140