]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/msw/wince/filedlgwce.cpp
Include wx/string.h according to precompiled headers of wx/wx.h (with other minor...
[wxWidgets.git] / src / msw / wince / filedlgwce.cpp
... / ...
CommitLineData
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
58IMPLEMENT_CLASS(wxFileDialog, wxDialog)
59
60// ----------------------------------------------------------------------------
61// wxFileDialog
62// ----------------------------------------------------------------------------
63
64wxFileDialog::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{
72 m_message = message;
73 m_dialogStyle = style;
74 if ( ( m_dialogStyle & wxMULTIPLE ) && ( m_dialogStyle & wxSAVE ) )
75 m_dialogStyle &= ~wxMULTIPLE;
76 m_parent = parent;
77 m_path = wxEmptyString;
78 m_fileName = defaultFileName;
79 m_dir = defaultDir;
80 m_wildCard = wildCard;
81 m_filterIndex = 0;
82}
83
84void wxFileDialog::GetPaths(wxArrayString& paths) const
85{
86 paths.Empty();
87
88 wxString dir(m_dir);
89 if ( m_dir.Last() != _T('\\') )
90 dir += _T('\\');
91
92 size_t count = m_fileNames.GetCount();
93 for ( size_t n = 0; n < count; n++ )
94 {
95 if (wxFileName(m_fileNames[n]).IsAbsolute())
96 paths.Add(m_fileNames[n]);
97 else
98 paths.Add(dir + m_fileNames[n]);
99 }
100}
101
102void wxFileDialog::SetPath(const wxString& path)
103{
104 wxString ext;
105 wxSplitPath(path, &m_dir, &m_fileName, &ext);
106 if ( !ext.empty() )
107 m_fileName << _T('.') << ext;
108}
109
110int wxFileDialog::ShowModal()
111{
112 wxWindow* parentWindow = GetParent();
113 if (!parentWindow)
114 parentWindow = wxTheApp->GetTopWindow();
115
116 wxString str = wxGetTextFromUser(m_message, _("File"), m_fileName, parentWindow);
117 if (str.empty())
118 return wxID_CANCEL;
119
120 m_fileName = str;
121 m_fileNames.Add(str);
122 return wxID_OK;
123}
124
125void wxFileDialog::GetFilenames(wxArrayString& files) const
126{
127 files = m_fileNames;
128}
129
130#endif // wxUSE_FILEDLG && __SMARTPHONE__ && __WXWINCE__