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