]> git.saurik.com Git - wxWidgets.git/blame - src/msw/wince/filedlgwce.cpp
wxWinCE power build fixes.
[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,
70 const wxPoint& WXUNUSED(pos))
71{
72 m_message = message;
ff3e84ff
VZ
73 m_windowStyle = style;
74 if ( ( m_windowStyle & wxMULTIPLE ) && ( m_windowStyle & wxSAVE ) )
75 m_windowStyle &= ~wxMULTIPLE;
449110cd
JS
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();
39fc096d 115
449110cd 116 wxString str = wxGetTextFromUser(m_message, _("File"), m_fileName, parentWindow);
caae22fb 117 if (str.empty())
449110cd 118 return wxID_CANCEL;
caae22fb
WS
119
120 m_fileName = str;
121 m_fileNames.Add(str);
122 return wxID_OK;
449110cd
JS
123}
124
7933c2d4
VS
125void wxFileDialog::GetFilenames(wxArrayString& files) const
126{
127 files = m_fileNames;
128}
129
8300f815 130#endif // wxUSE_FILEDLG && __SMARTPHONE__ && __WXWINCE__