]>
Commit | Line | Data |
---|---|---|
449110cd JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: src/msw/wince/filedlgwce.cpp | |
3 | // Purpose: wxFileDialog for WinCE (SmartPhone) | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
65571936 | 9 | // Licence: wxWindows licence |
449110cd JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
14f355c2 | 20 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
449110cd JS |
21 | #pragma implementation "filedlg.h" |
22 | #endif | |
23 | ||
24 | // For compilers that support precompilation, includes "wx.h". | |
25 | #include "wx/wxprec.h" | |
26 | ||
27 | #ifdef __BORLANDC__ | |
28 | #pragma hdrstop | |
29 | #endif | |
30 | ||
31 | // Only use this for MS SmartPhone. Use standard file dialog | |
32 | // for Pocket PC. | |
33 | ||
d7da7f13 | 34 | #if wxUSE_FILEDLG && defined(__SMARTPHONE__) |
449110cd JS |
35 | |
36 | #ifndef WX_PRECOMP | |
37 | #include "wx/utils.h" | |
38 | #include "wx/msgdlg.h" | |
39 | #include "wx/dialog.h" | |
40 | #include "wx/filedlg.h" | |
41 | #include "wx/filefn.h" | |
42 | #include "wx/intl.h" | |
43 | #include "wx/log.h" | |
44 | #include "wx/app.h" | |
45 | #endif | |
46 | ||
47 | #include "wx/msw/private.h" | |
48 | ||
49 | #include <stdlib.h> | |
50 | #include <string.h> | |
51 | ||
52 | #include "wx/filename.h" | |
53 | ||
54 | // ============================================================================ | |
55 | // implementation | |
56 | // ============================================================================ | |
57 | ||
58 | // ---------------------------------------------------------------------------- | |
59 | // wxWin macros | |
60 | // ---------------------------------------------------------------------------- | |
61 | ||
62 | IMPLEMENT_CLASS(wxFileDialog, wxDialog) | |
63 | ||
64 | // ---------------------------------------------------------------------------- | |
65 | // wxFileDialog | |
66 | // ---------------------------------------------------------------------------- | |
67 | ||
68 | wxFileDialog::wxFileDialog(wxWindow *parent, | |
69 | const wxString& message, | |
70 | const wxString& defaultDir, | |
71 | const wxString& defaultFileName, | |
72 | const wxString& wildCard, | |
73 | long style, | |
74 | const wxPoint& WXUNUSED(pos)) | |
75 | { | |
76 | m_message = message; | |
77 | m_dialogStyle = style; | |
78 | if ( ( m_dialogStyle & wxMULTIPLE ) && ( m_dialogStyle & wxSAVE ) ) | |
79 | m_dialogStyle &= ~wxMULTIPLE; | |
80 | m_parent = parent; | |
81 | m_path = wxEmptyString; | |
82 | m_fileName = defaultFileName; | |
83 | m_dir = defaultDir; | |
84 | m_wildCard = wildCard; | |
85 | m_filterIndex = 0; | |
86 | } | |
87 | ||
88 | void wxFileDialog::GetPaths(wxArrayString& paths) const | |
89 | { | |
90 | paths.Empty(); | |
91 | ||
92 | wxString dir(m_dir); | |
93 | if ( m_dir.Last() != _T('\\') ) | |
94 | dir += _T('\\'); | |
95 | ||
96 | size_t count = m_fileNames.GetCount(); | |
97 | for ( size_t n = 0; n < count; n++ ) | |
98 | { | |
99 | if (wxFileName(m_fileNames[n]).IsAbsolute()) | |
100 | paths.Add(m_fileNames[n]); | |
101 | else | |
102 | paths.Add(dir + m_fileNames[n]); | |
103 | } | |
104 | } | |
105 | ||
106 | void wxFileDialog::SetPath(const wxString& path) | |
107 | { | |
108 | wxString ext; | |
109 | wxSplitPath(path, &m_dir, &m_fileName, &ext); | |
110 | if ( !ext.empty() ) | |
111 | m_fileName << _T('.') << ext; | |
112 | } | |
113 | ||
114 | int wxFileDialog::ShowModal() | |
115 | { | |
116 | wxWindow* parentWindow = GetParent(); | |
117 | if (!parentWindow) | |
118 | parentWindow = wxTheApp->GetTopWindow(); | |
39fc096d | 119 | |
449110cd JS |
120 | wxString str = wxGetTextFromUser(m_message, _("File"), m_fileName, parentWindow); |
121 | if (str) | |
122 | { | |
123 | m_fileName = str; | |
124 | m_fileNames.Add(str); | |
125 | return wxID_OK; | |
126 | } | |
127 | else | |
128 | { | |
129 | return wxID_CANCEL; | |
130 | } | |
131 | } | |
132 | ||
7933c2d4 VS |
133 | void wxFileDialog::GetFilenames(wxArrayString& files) const |
134 | { | |
135 | files = m_fileNames; | |
136 | } | |
137 | ||
449110cd JS |
138 | #endif // wxUSE_FILEDLG |
139 |