]> git.saurik.com Git - wxWidgets.git/blame - src/msw/wince/filedlgwce.cpp
Fix duplicate wxContextMenuEvent generation in wxMSW.
[wxWidgets.git] / src / msw / wince / filedlgwce.cpp
CommitLineData
449110cd
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/msw/wince/filedlgwce.cpp
8300f815 3// Purpose: wxFileDialog implementation for smart phones driven by WinCE
449110cd
JS
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
449110cd
JS
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
8300f815 30#if wxUSE_FILEDLG && defined(__SMARTPHONE__) && defined(__WXWINCE__)
449110cd 31
949c9f74
WS
32#include "wx/filedlg.h"
33
449110cd
JS
34#ifndef WX_PRECOMP
35 #include "wx/utils.h"
36 #include "wx/msgdlg.h"
37 #include "wx/dialog.h"
449110cd
JS
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"
643e9cf9 50#include "wx/testing.h"
449110cd
JS
51
52// ============================================================================
53// implementation
54// ============================================================================
55
56// ----------------------------------------------------------------------------
57// wxWin macros
58// ----------------------------------------------------------------------------
59
60IMPLEMENT_CLASS(wxFileDialog, wxDialog)
61
62// ----------------------------------------------------------------------------
63// wxFileDialog
64// ----------------------------------------------------------------------------
65
66wxFileDialog::wxFileDialog(wxWindow *parent,
67 const wxString& message,
68 const wxString& defaultDir,
69 const wxString& defaultFileName,
70 const wxString& wildCard,
71 long style,
4c9a69c1
WS
72 const wxPoint& WXUNUSED(pos),
73 const wxSize& WXUNUSED(sz),
74 const wxString& WXUNUSED(name))
449110cd
JS
75{
76 m_message = message;
ff3e84ff 77 m_windowStyle = style;
e031f1df
WS
78 if ( ( m_windowStyle & wxFD_MULTIPLE ) && ( m_windowStyle & wxFD_SAVE ) )
79 m_windowStyle &= ~wxFD_MULTIPLE;
449110cd
JS
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
88void wxFileDialog::GetPaths(wxArrayString& paths) const
89{
90 paths.Empty();
91
92 wxString dir(m_dir);
9a83f860
VZ
93 if ( m_dir.Last() != wxT('\\') )
94 dir += wxT('\\');
449110cd
JS
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
106void wxFileDialog::SetPath(const wxString& path)
107{
108 wxString ext;
bd365871 109 wxFileName::SplitPath(path, &m_dir, &m_fileName, &ext);
449110cd 110 if ( !ext.empty() )
9a83f860 111 m_fileName << wxT('.') << ext;
449110cd
JS
112}
113
114int wxFileDialog::ShowModal()
115{
643e9cf9
VS
116 WX_TESTING_SHOW_MODAL_HOOK();
117
449110cd
JS
118 wxWindow* parentWindow = GetParent();
119 if (!parentWindow)
120 parentWindow = wxTheApp->GetTopWindow();
39fc096d 121
449110cd 122 wxString str = wxGetTextFromUser(m_message, _("File"), m_fileName, parentWindow);
caae22fb 123 if (str.empty())
449110cd 124 return wxID_CANCEL;
caae22fb
WS
125
126 m_fileName = str;
127 m_fileNames.Add(str);
128 return wxID_OK;
449110cd
JS
129}
130
7933c2d4
VS
131void wxFileDialog::GetFilenames(wxArrayString& files) const
132{
133 files = m_fileNames;
134}
135
8300f815 136#endif // wxUSE_FILEDLG && __SMARTPHONE__ && __WXWINCE__