]> git.saurik.com Git - wxWidgets.git/blame - src/msw/wince/filedlgwce.cpp
Minor source cleaning.
[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
JS
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,
4c9a69c1
WS
70 const wxPoint& WXUNUSED(pos),
71 const wxSize& WXUNUSED(sz),
72 const wxString& WXUNUSED(name))
449110cd
JS
73{
74 m_message = message;
ff3e84ff 75 m_windowStyle = style;
e031f1df
WS
76 if ( ( m_windowStyle & wxFD_MULTIPLE ) && ( m_windowStyle & wxFD_SAVE ) )
77 m_windowStyle &= ~wxFD_MULTIPLE;
449110cd
JS
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
86void 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
104void 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
112int wxFileDialog::ShowModal()
113{
114 wxWindow* parentWindow = GetParent();
115 if (!parentWindow)
116 parentWindow = wxTheApp->GetTopWindow();
39fc096d 117
449110cd 118 wxString str = wxGetTextFromUser(m_message, _("File"), m_fileName, parentWindow);
caae22fb 119 if (str.empty())
449110cd 120 return wxID_CANCEL;
caae22fb
WS
121
122 m_fileName = str;
123 m_fileNames.Add(str);
124 return wxID_OK;
449110cd
JS
125}
126
7933c2d4
VS
127void wxFileDialog::GetFilenames(wxArrayString& files) const
128{
129 files = m_fileNames;
130}
131
8300f815 132#endif // wxUSE_FILEDLG && __SMARTPHONE__ && __WXWINCE__