]> git.saurik.com Git - wxWidgets.git/blob - src/msw/wince/filedlgwce.cpp
Allow setting LCID used by wxAutomationObject.
[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 #include "wx/filedlg.h"
33
34 #ifndef WX_PRECOMP
35 #include "wx/utils.h"
36 #include "wx/msgdlg.h"
37 #include "wx/dialog.h"
38 #include "wx/filefn.h"
39 #include "wx/intl.h"
40 #include "wx/log.h"
41 #include "wx/app.h"
42 #endif
43
44 #include "wx/msw/private.h"
45
46 #include <stdlib.h>
47 #include <string.h>
48
49 #include "wx/filename.h"
50
51 // ============================================================================
52 // implementation
53 // ============================================================================
54
55 // ----------------------------------------------------------------------------
56 // wxWin macros
57 // ----------------------------------------------------------------------------
58
59 IMPLEMENT_CLASS(wxFileDialog, wxDialog)
60
61 // ----------------------------------------------------------------------------
62 // wxFileDialog
63 // ----------------------------------------------------------------------------
64
65 wxFileDialog::wxFileDialog(wxWindow *parent,
66 const wxString& message,
67 const wxString& defaultDir,
68 const wxString& defaultFileName,
69 const wxString& wildCard,
70 long style,
71 const wxPoint& WXUNUSED(pos),
72 const wxSize& WXUNUSED(sz),
73 const wxString& WXUNUSED(name))
74 {
75 m_message = message;
76 m_windowStyle = style;
77 if ( ( m_windowStyle & wxFD_MULTIPLE ) && ( m_windowStyle & wxFD_SAVE ) )
78 m_windowStyle &= ~wxFD_MULTIPLE;
79 m_parent = parent;
80 m_path = wxEmptyString;
81 m_fileName = defaultFileName;
82 m_dir = defaultDir;
83 m_wildCard = wildCard;
84 m_filterIndex = 0;
85 }
86
87 void wxFileDialog::GetPaths(wxArrayString& paths) const
88 {
89 paths.Empty();
90
91 wxString dir(m_dir);
92 if ( m_dir.Last() != wxT('\\') )
93 dir += wxT('\\');
94
95 size_t count = m_fileNames.GetCount();
96 for ( size_t n = 0; n < count; n++ )
97 {
98 if (wxFileName(m_fileNames[n]).IsAbsolute())
99 paths.Add(m_fileNames[n]);
100 else
101 paths.Add(dir + m_fileNames[n]);
102 }
103 }
104
105 void wxFileDialog::SetPath(const wxString& path)
106 {
107 wxString ext;
108 wxFileName::SplitPath(path, &m_dir, &m_fileName, &ext);
109 if ( !ext.empty() )
110 m_fileName << wxT('.') << ext;
111 }
112
113 int wxFileDialog::ShowModal()
114 {
115 wxWindow* parentWindow = GetParent();
116 if (!parentWindow)
117 parentWindow = wxTheApp->GetTopWindow();
118
119 wxString str = wxGetTextFromUser(m_message, _("File"), m_fileName, parentWindow);
120 if (str.empty())
121 return wxID_CANCEL;
122
123 m_fileName = str;
124 m_fileNames.Add(str);
125 return wxID_OK;
126 }
127
128 void wxFileDialog::GetFilenames(wxArrayString& files) const
129 {
130 files = m_fileNames;
131 }
132
133 #endif // wxUSE_FILEDLG && __SMARTPHONE__ && __WXWINCE__