]> git.saurik.com Git - wxWidgets.git/blame - src/generic/filedlgg.cpp
don't strip &s from tooltips (patch 1488318)
[wxWidgets.git] / src / generic / filedlgg.cpp
CommitLineData
81169710 1//////////////////////////////////////////////////////////////////////////////
812a5849 2// Name: src/generic/filedlgg.cpp
23254b13 3// Purpose: wxGenericFileDialog
8b17ba72
RR
4// Author: Robert Roebling
5// Modified by:
6// Created: 12/12/98
7// RCS-ID: $Id$
8// Copyright: (c) Robert Roebling
65571936 9// Licence: wxWindows licence
8b17ba72
RR
10/////////////////////////////////////////////////////////////////////////////
11
8b17ba72
RR
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
15#ifdef __BORLANDC__
246c5004 16 #pragma hdrstop
8b17ba72
RR
17#endif
18
4e1901b7 19#if wxUSE_FILEDLG
1e6feb95 20
06cc1fb9 21// NOTE : it probably also supports MAC, untested
144cf6da 22#if !defined(__UNIX__) && !defined(__DOS__) && !defined(__WIN32__) && !defined(__OS2__)
23254b13 23#error wxGenericFileDialog currently only supports Unix, win32 and DOS
8b17ba72
RR
24#endif
25
88a7a4e1
WS
26#ifndef WX_PRECOMP
27 #include "wx/hash.h"
28 #include "wx/intl.h"
9eddec69 29 #include "wx/settings.h"
e7c80f9e 30 #include "wx/log.h"
246c5004 31 #include "wx/msgdlg.h"
910b0053 32 #include "wx/bmpbuttn.h"
88a7a4e1
WS
33#endif
34
04dbb646
VZ
35#include "wx/checkbox.h"
36#include "wx/textctrl.h"
37#include "wx/choice.h"
38#include "wx/checkbox.h"
39#include "wx/stattext.h"
ec524671 40#include "wx/longlong.h"
8b17ba72 41#include "wx/sizer.h"
cae5359f 42#include "wx/tokenzr.h"
eaf40b23 43#include "wx/config.h"
48fe8374 44#include "wx/imaglist.h"
5e673a6a 45#include "wx/dir.h"
60d2cc25 46#include "wx/artprov.h"
619111b9 47#include "wx/filefn.h"
1265e13d 48#include "wx/file.h" // for wxS_IXXX constants only
23254b13 49#include "wx/filedlg.h" // wxOPEN, wxSAVE...
94c47543 50#include "wx/generic/filedlgg.h"
06cc1fb9 51#include "wx/generic/dirctrlg.h" // for wxFileIconsTable
8b17ba72 52
e6daf794
RR
53#if wxUSE_TOOLTIPS
54 #include "wx/tooltip.h"
55#endif
56
619111b9 57#ifndef __WXWINCE__
e7c80f9e
WS
58 #include <sys/types.h>
59 #include <sys/stat.h>
619111b9 60#endif
4894ae18
VS
61
62#ifdef __UNIX__
63 #include <dirent.h>
64 #include <pwd.h>
65 #ifndef __VMS
66 # include <grp.h>
67 #endif
68#endif
69
6a8c7c70
VS
70#ifdef __WINDOWS__
71 #include "wx/msw/wrapwin.h"
72 #include "wx/msw/mslu.h"
73#endif
74
4894ae18
VS
75#ifdef __WATCOMC__
76 #include <direct.h>
27df579a 77#endif
4894ae18 78
619111b9 79#ifndef __WXWINCE__
7a82dabc 80#include <time.h>
619111b9
JS
81#endif
82
099d4217 83#if defined(__UNIX__) || defined(__DOS__)
ac2def68 84#include <unistd.h>
099d4217 85#endif
8b17ba72 86
655cf310 87// ----------------------------------------------------------------------------
06cc1fb9 88// private functions
655cf310
VS
89// ----------------------------------------------------------------------------
90
06cc1fb9 91static
ec524671 92int wxCALLBACK wxFileDataNameCompare( long data1, long data2, long sortOrder)
655cf310 93{
ec524671
VZ
94 wxFileData *fd1 = (wxFileData *)wxUIntToPtr(data1);
95 wxFileData *fd2 = (wxFileData *)wxUIntToPtr(data2);
96
97 if (fd1->GetFileName() == wxT(".."))
98 return -sortOrder;
99 if (fd2->GetFileName() == wxT(".."))
100 return sortOrder;
101 if (fd1->IsDir() && !fd2->IsDir())
102 return -sortOrder;
103 if (fd2->IsDir() && !fd1->IsDir())
104 return sortOrder;
105
106 return sortOrder*wxStrcmp( fd1->GetFileName(), fd2->GetFileName() );
655cf310
VS
107}
108
c8c0e54c 109static
ec524671 110int wxCALLBACK wxFileDataSizeCompare(long data1, long data2, long sortOrder)
23254b13 111{
ec524671
VZ
112 wxFileData *fd1 = (wxFileData *)wxUIntToPtr(data1);
113 wxFileData *fd2 = (wxFileData *)wxUIntToPtr(data2);
114
115 if (fd1->GetFileName() == wxT(".."))
116 return -sortOrder;
117 if (fd2->GetFileName() == wxT(".."))
118 return sortOrder;
119 if (fd1->IsDir() && !fd2->IsDir())
120 return -sortOrder;
121 if (fd2->IsDir() && !fd1->IsDir())
122 return sortOrder;
123 if (fd1->IsLink() && !fd2->IsLink())
124 return -sortOrder;
125 if (fd2->IsLink() && !fd1->IsLink())
126 return sortOrder;
127
128 return fd1->GetSize() > fd2->GetSize() ? sortOrder : -sortOrder;
23254b13
JS
129}
130
131static
ec524671 132int wxCALLBACK wxFileDataTypeCompare(long data1, long data2, long sortOrder)
23254b13 133{
ec524671
VZ
134 wxFileData *fd1 = (wxFileData *)wxUIntToPtr(data1);
135 wxFileData *fd2 = (wxFileData *)wxUIntToPtr(data2);
136
137 if (fd1->GetFileName() == wxT(".."))
138 return -sortOrder;
139 if (fd2->GetFileName() == wxT(".."))
140 return sortOrder;
141 if (fd1->IsDir() && !fd2->IsDir())
142 return -sortOrder;
143 if (fd2->IsDir() && !fd1->IsDir())
144 return sortOrder;
145 if (fd1->IsLink() && !fd2->IsLink())
146 return -sortOrder;
147 if (fd2->IsLink() && !fd1->IsLink())
148 return sortOrder;
149
150 return sortOrder*wxStrcmp( fd1->GetFileType(), fd2->GetFileType() );
23254b13
JS
151}
152
153static
ec524671 154int wxCALLBACK wxFileDataTimeCompare(long data1, long data2, long sortOrder)
23254b13 155{
ec524671
VZ
156 wxFileData *fd1 = (wxFileData *)wxUIntToPtr(data1);
157 wxFileData *fd2 = (wxFileData *)wxUIntToPtr(data2);
158
159 if (fd1->GetFileName() == wxT(".."))
160 return -sortOrder;
161 if (fd2->GetFileName() == wxT(".."))
162 return sortOrder;
163 if (fd1->IsDir() && !fd2->IsDir())
164 return -sortOrder;
165 if (fd2->IsDir() && !fd1->IsDir())
166 return sortOrder;
23254b13 167
ec524671 168 return fd1->GetDateTime().IsLaterThan(fd2->GetDateTime()) ? sortOrder : -sortOrder;
c8c0e54c
VZ
169}
170
619111b9
JS
171#if defined(__WXWINCE__)
172#define IsTopMostDir(dir) (dir == wxT("\\") || dir == wxT("/"))
173#elif (defined(__DOS__) || defined(__WINDOWS__) || defined (__OS2__))
abc2a4cc 174#define IsTopMostDir(dir) (dir.empty())
70a7eb07
MW
175#else
176#define IsTopMostDir(dir) (dir == wxT("/"))
5e673a6a
VS
177#endif
178
06cc1fb9
JS
179// defined in src/generic/dirctrlg.cpp
180extern size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayInt &icon_ids);
181
8b17ba72
RR
182//-----------------------------------------------------------------------------
183// wxFileData
184//-----------------------------------------------------------------------------
185
06cc1fb9 186wxFileData::wxFileData( const wxString &filePath, const wxString &fileName, fileType type, int image_id )
8b17ba72 187{
ca9fb418 188 Init();
06cc1fb9
JS
189 m_fileName = fileName;
190 m_filePath = filePath;
23254b13 191 m_type = type;
06cc1fb9 192 m_image = image_id;
7a82dabc 193
b600ed13
VZ
194 ReadData();
195}
196
ca9fb418
VZ
197void wxFileData::Init()
198{
199 m_size = 0;
200 m_type = wxFileData::is_file;
201 m_image = wxFileIconsTable::file;
202}
203
81169710
VZ
204void wxFileData::Copy( const wxFileData& fileData )
205{
206 m_fileName = fileData.GetFileName();
207 m_filePath = fileData.GetFilePath();
208 m_size = fileData.GetSize();
209 m_dateTime = fileData.GetDateTime();
210 m_permissions = fileData.GetPermissions();
211 m_type = fileData.GetType();
ca9fb418 212 m_image = fileData.GetImageId();
81169710
VZ
213}
214
b600ed13
VZ
215void wxFileData::ReadData()
216{
06cc1fb9 217 if (IsDrive())
37fd1c97 218 {
23254b13
JS
219 m_size = 0;
220 return;
221 }
222
619111b9 223#if defined(__DOS__) || (defined(__WINDOWS__) && !defined(__WXWINCE__)) || defined(__OS2__)
06cc1fb9 224 // c:\.. is a drive don't stat it
567be187 225 if ((m_fileName == wxT("..")) && (m_filePath.length() <= 5))
23254b13
JS
226 {
227 m_type = is_drive;
37fd1c97
VS
228 m_size = 0;
229 return;
230 }
7f04165e 231#endif // __DOS__ || __WINDOWS__
c8c0e54c 232
619111b9
JS
233#ifdef __WXWINCE__
234
235 // WinCE
236
237 DWORD fileAttribs = GetFileAttributes(m_filePath.fn_str());
238 m_type |= (fileAttribs & FILE_ATTRIBUTE_DIRECTORY) != 0 ? is_dir : 0;
239
240 wxString p, f, ext;
241 wxSplitPath(m_filePath, & p, & f, & ext);
242 if (wxStricmp(ext, wxT("exe")) == 0)
243 m_type |= is_exe;
244
245 // Find out size
246 m_size = 0;
247 HANDLE fileHandle = CreateFile(m_filePath.fn_str(),
248 GENERIC_READ,
249 FILE_SHARE_READ,
250 NULL,
251 OPEN_EXISTING,
252 FILE_ATTRIBUTE_NORMAL,
253 NULL);
254
255 if (fileHandle != INVALID_HANDLE_VALUE)
c81c9392 256 {
619111b9
JS
257 m_size = GetFileSize(fileHandle, 0);
258 CloseHandle(fileHandle);
259 }
260
261 m_dateTime = wxFileModificationTime(m_filePath);
262
263#else
264
265 // OTHER PLATFORMS
266
8115f9e7 267 wxStructStat buff;
479cd5de 268
144cf6da 269#if defined(__UNIX__) && (!defined( __OS2__ ) && !defined(__VMS))
06cc1fb9 270 lstat( m_filePath.fn_str(), &buff );
23254b13 271 m_type |= S_ISLNK( buff.st_mode ) != 0 ? is_link : 0;
7f04165e 272#else // no lstat()
f3660dcb
SC
273 // only translate to file charset if we don't go by our
274 // wxStat implementation
275#ifndef wxNEED_WX_UNISTD_H
276 wxStat( m_filePath.fn_str() , &buff );
277#else
06cc1fb9 278 wxStat( m_filePath, &buff );
f3660dcb 279#endif
9f2d09aa
RR
280#endif
281
23254b13
JS
282 m_type |= (buff.st_mode & S_IFDIR) != 0 ? is_dir : 0;
283 m_type |= (buff.st_mode & wxS_IXUSR) != 0 ? is_exe : 0;
8b17ba72 284
ec524671 285 m_size = buff.st_size;
8b17ba72 286
06cc1fb9 287 m_dateTime = buff.st_mtime;
619111b9
JS
288#endif
289 // __WXWINCE__
c81c9392 290
06cc1fb9
JS
291#if defined(__UNIX__)
292 m_permissions.Printf(_T("%c%c%c%c%c%c%c%c%c"),
7f04165e
VZ
293 buff.st_mode & wxS_IRUSR ? _T('r') : _T('-'),
294 buff.st_mode & wxS_IWUSR ? _T('w') : _T('-'),
06cc1fb9
JS
295 buff.st_mode & wxS_IXUSR ? _T('x') : _T('-'),
296 buff.st_mode & wxS_IRGRP ? _T('r') : _T('-'),
297 buff.st_mode & wxS_IWGRP ? _T('w') : _T('-'),
298 buff.st_mode & wxS_IXGRP ? _T('x') : _T('-'),
299 buff.st_mode & wxS_IROTH ? _T('r') : _T('-'),
300 buff.st_mode & wxS_IWOTH ? _T('w') : _T('-'),
301 buff.st_mode & wxS_IXOTH ? _T('x') : _T('-'));
302#elif defined(__WIN32__)
0e4e783c 303 DWORD attribs = ::GetFileAttributes(m_filePath.c_str());
06cc1fb9
JS
304 if (attribs != (DWORD)-1)
305 {
306 m_permissions.Printf(_T("%c%c%c%c"),
307 attribs & FILE_ATTRIBUTE_ARCHIVE ? _T('A') : _T(' '),
308 attribs & FILE_ATTRIBUTE_READONLY ? _T('R') : _T(' '),
309 attribs & FILE_ATTRIBUTE_HIDDEN ? _T('H') : _T(' '),
310 attribs & FILE_ATTRIBUTE_SYSTEM ? _T('S') : _T(' '));
311 }
312#endif
619111b9
JS
313
314 // try to get a better icon
315 if (m_image == wxFileIconsTable::file)
316 {
317 if (m_fileName.Find(wxT('.'), true) != wxNOT_FOUND)
318 {
319 m_image = wxTheFileIconsTable->GetIconID( m_fileName.AfterLast(wxT('.')));
320 } else if (IsExe())
321 {
322 m_image = wxFileIconsTable::executable;
323 }
324 }
8b17ba72
RR
325}
326
b600ed13 327wxString wxFileData::GetFileType() const
8b17ba72 328{
06cc1fb9
JS
329 if (IsDir())
330 return _("<DIR>");
331 else if (IsLink())
332 return _("<LINK>");
333 else if (IsDrive())
334 return _("<DRIVE>");
7448de8d 335 else if (m_fileName.Find(wxT('.'), true) != wxNOT_FOUND)
06cc1fb9 336 return m_fileName.AfterLast(wxT('.'));
8b17ba72 337
06cc1fb9 338 return wxEmptyString;
8b17ba72
RR
339}
340
06cc1fb9 341wxString wxFileData::GetModificationTime() const
23254b13 342{
06cc1fb9
JS
343 // want time as 01:02 so they line up nicely, no %r in WIN32
344 return m_dateTime.FormatDate() + wxT(" ") + m_dateTime.Format(wxT("%I:%M:%S %p"));
23254b13
JS
345}
346
8b17ba72
RR
347wxString wxFileData::GetHint() const
348{
06cc1fb9 349 wxString s = m_filePath;
2b5f62a0 350 s += wxT(" ");
b8985048 351
23254b13 352 if (IsDir())
b8985048 353 s += _("<DIR>");
23254b13 354 else if (IsLink())
b8985048 355 s += _("<LINK>");
23254b13 356 else if (IsDrive())
b8985048
VZ
357 s += _("<DRIVE>");
358 else // plain file
ec524671
VZ
359 s += wxString::Format(_("%ld bytes"),
360 wxLongLong(m_size).ToString().c_str());
b8985048
VZ
361
362 s += wxT(' ');
363
364 if ( !IsDrive() )
23254b13 365 {
b8985048
VZ
366 s << GetModificationTime()
367 << wxT(" ")
368 << m_permissions;
8b17ba72 369 }
23254b13 370
8b17ba72 371 return s;
17a1ebd1 372}
8b17ba72 373
23254b13 374wxString wxFileData::GetEntry( fileListFieldType num ) const
8b17ba72
RR
375{
376 wxString s;
9cedab37 377 switch ( num )
8b17ba72 378 {
9cedab37 379 case FileList_Name:
06cc1fb9 380 s = m_fileName;
8b17ba72 381 break;
9cedab37 382
06cc1fb9
JS
383 case FileList_Size:
384 if (!IsDir() && !IsLink() && !IsDrive())
ec524671 385 s = wxLongLong(m_size).ToString();
8b17ba72 386 break;
9cedab37 387
06cc1fb9 388 case FileList_Type:
b600ed13 389 s = GetFileType();
8b17ba72 390 break;
8b17ba72 391
9cedab37 392 case FileList_Time:
7448de8d 393 if (!IsDrive())
06cc1fb9 394 s = GetModificationTime();
9cedab37 395 break;
8b17ba72 396
06cc1fb9 397#if defined(__UNIX__) || defined(__WIN32__)
9cedab37
VZ
398 case FileList_Perm:
399 s = m_permissions;
400 break;
06cc1fb9 401#endif // defined(__UNIX__) || defined(__WIN32__)
8b17ba72 402
9cedab37
VZ
403 default:
404 wxFAIL_MSG( _T("unexpected field in wxFileData::GetEntry()") );
405 }
8b17ba72 406
9cedab37 407 return s;
8b17ba72
RR
408}
409
06cc1fb9 410void wxFileData::SetNewName( const wxString &filePath, const wxString &fileName )
8b17ba72 411{
06cc1fb9
JS
412 m_fileName = fileName;
413 m_filePath = filePath;
8b17ba72
RR
414}
415
416void wxFileData::MakeItem( wxListItem &item )
417{
06cc1fb9 418 item.m_text = m_fileName;
9b00bb16 419 item.ClearAttributes();
9cedab37
VZ
420 if (IsExe())
421 item.SetTextColour(*wxRED);
422 if (IsDir())
423 item.SetTextColour(*wxBLUE);
48fe8374 424
06cc1fb9 425 item.m_image = m_image;
655cf310 426
8b17ba72
RR
427 if (IsLink())
428 {
564a150b
VZ
429 wxColour dg = wxTheColourDatabase->Find( _T("MEDIUM GREY") );
430 if ( dg.Ok() )
431 item.SetTextColour(dg);
8b17ba72 432 }
9f542367 433 item.m_data = wxPtrToUInt(this);
8b17ba72 434}
c8c0e54c 435
8b17ba72
RR
436//-----------------------------------------------------------------------------
437// wxFileCtrl
438//-----------------------------------------------------------------------------
439
619111b9
JS
440static bool ignoreChanges = false;
441
d84afea9 442IMPLEMENT_DYNAMIC_CLASS(wxFileCtrl,wxListCtrl)
8b17ba72
RR
443
444BEGIN_EVENT_TABLE(wxFileCtrl,wxListCtrl)
ca65c044
WS
445 EVT_LIST_DELETE_ITEM(wxID_ANY, wxFileCtrl::OnListDeleteItem)
446 EVT_LIST_DELETE_ALL_ITEMS(wxID_ANY, wxFileCtrl::OnListDeleteAllItems)
447 EVT_LIST_END_LABEL_EDIT(wxID_ANY, wxFileCtrl::OnListEndLabelEdit)
448 EVT_LIST_COL_CLICK(wxID_ANY, wxFileCtrl::OnListColClick)
8b17ba72
RR
449END_EVENT_TABLE()
450
655cf310 451
8b17ba72
RR
452wxFileCtrl::wxFileCtrl()
453{
ca65c044 454 m_showHidden = false;
23254b13
JS
455 m_sort_foward = 1;
456 m_sort_field = wxFileData::FileList_Name;
8b17ba72
RR
457}
458
9cedab37
VZ
459wxFileCtrl::wxFileCtrl(wxWindow *win,
460 wxWindowID id,
461 const wxString& wild,
462 bool showHidden,
463 const wxPoint& pos,
464 const wxSize& size,
465 long style,
466 const wxValidator &validator,
5e673a6a 467 const wxString &name)
9cedab37
VZ
468 : wxListCtrl(win, id, pos, size, style, validator, name),
469 m_wild(wild)
8b17ba72 470{
06cc1fb9 471 wxImageList *imageList = wxTheFileIconsTable->GetSmallImageList();
655cf310 472
0b855868 473 SetImageList( imageList, wxIMAGE_LIST_SMALL );
c8c0e54c 474
9cedab37 475 m_showHidden = showHidden;
23254b13
JS
476
477 m_sort_foward = 1;
478 m_sort_field = wxFileData::FileList_Name;
479
480 m_dirName = wxT("*");
481
482 if (style & wxLC_REPORT)
483 ChangeToReportMode();
8b17ba72
RR
484}
485
486void wxFileCtrl::ChangeToListMode()
487{
23254b13 488 ClearAll();
8b17ba72 489 SetSingleStyle( wxLC_LIST );
8f4fcc4e 490 UpdateFiles();
8b17ba72
RR
491}
492
493void wxFileCtrl::ChangeToReportMode()
494{
23254b13 495 ClearAll();
8b17ba72 496 SetSingleStyle( wxLC_REPORT );
23254b13 497
06cc1fb9
JS
498 // do this since WIN32 does mm/dd/yy UNIX does mm/dd/yyyy
499 // don't hardcode since mm/dd is dd/mm elsewhere
23254b13 500 int w, h;
06cc1fb9
JS
501 wxDateTime dt(22, wxDateTime::Dec, 2002, 22, 22, 22);
502 wxString txt = dt.FormatDate() + wxT("22") + dt.Format(wxT("%I:%M:%S %p"));
503 GetTextExtent(txt, &w, &h);
504
505 InsertColumn( 0, _("Name"), wxLIST_FORMAT_LEFT, w );
506 InsertColumn( 1, _("Size"), wxLIST_FORMAT_LEFT, w/2 );
507 InsertColumn( 2, _("Type"), wxLIST_FORMAT_LEFT, w/2 );
508 InsertColumn( 3, _("Modified"), wxLIST_FORMAT_LEFT, w );
509#if defined(__UNIX__)
510 GetTextExtent(wxT("Permissions 2"), &w, &h);
511 InsertColumn( 4, _("Permissions"), wxLIST_FORMAT_LEFT, w );
512#elif defined(__WIN32__)
513 GetTextExtent(wxT("Attributes 2"), &w, &h);
514 InsertColumn( 4, _("Attributes"), wxLIST_FORMAT_LEFT, w );
23254b13
JS
515#endif
516
8f4fcc4e 517 UpdateFiles();
8b17ba72
RR
518}
519
06cc1fb9 520void wxFileCtrl::ChangeToSmallIconMode()
8b17ba72 521{
23254b13 522 ClearAll();
06cc1fb9 523 SetSingleStyle( wxLC_SMALL_ICON );
8f4fcc4e 524 UpdateFiles();
8b17ba72
RR
525}
526
527void wxFileCtrl::ShowHidden( bool show )
528{
529 m_showHidden = show;
8f4fcc4e 530 UpdateFiles();
8b17ba72
RR
531}
532
0b855868
RR
533long wxFileCtrl::Add( wxFileData *fd, wxListItem &item )
534{
535 long ret = -1;
536 item.m_mask = wxLIST_MASK_TEXT + wxLIST_MASK_DATA + wxLIST_MASK_IMAGE;
537 fd->MakeItem( item );
538 long my_style = GetWindowStyleFlag();
539 if (my_style & wxLC_REPORT)
540 {
541 ret = InsertItem( item );
23254b13
JS
542 for (int i = 1; i < wxFileData::FileList_Max; i++)
543 SetItem( item.m_itemId, i, fd->GetEntry((wxFileData::fileListFieldType)i) );
0b855868 544 }
06cc1fb9 545 else if ((my_style & wxLC_LIST) || (my_style & wxLC_SMALL_ICON))
0b855868
RR
546 {
547 ret = InsertItem( item );
c8c0e54c 548 }
0b855868
RR
549 return ret;
550}
551
b600ed13
VZ
552void wxFileCtrl::UpdateItem(const wxListItem &item)
553{
554 wxFileData *fd = (wxFileData*)GetItemData(item);
555 wxCHECK_RET(fd, wxT("invalid filedata"));
556
557 fd->ReadData();
558
559 SetItemText(item, fd->GetFileName());
c3627a00 560 SetItemImage(item, fd->GetImageId());
b600ed13
VZ
561
562 if (GetWindowStyleFlag() & wxLC_REPORT)
563 {
564 for (int i = 1; i < wxFileData::FileList_Max; i++)
565 SetItem( item.m_itemId, i, fd->GetEntry((wxFileData::fileListFieldType)i) );
566 }
567}
568
8f4fcc4e 569void wxFileCtrl::UpdateFiles()
c8c0e54c 570{
2b5f62a0 571 // don't do anything before ShowModal() call which sets m_dirName
23254b13 572 if ( m_dirName == wxT("*") )
2b5f62a0
VZ
573 return;
574
37fd1c97 575 wxBusyCursor bcur; // this may take a while...
7a82dabc 576
23254b13 577 DeleteAllItems();
7a82dabc 578
8b17ba72 579 wxListItem item;
8b17ba72
RR
580 item.m_itemId = 0;
581 item.m_col = 0;
0b855868 582
619111b9 583#if (defined(__WINDOWS__) || defined(__DOS__) || defined(__WXMAC__) || defined(__OS2__)) && !defined(__WXWINCE__)
37fd1c97 584 if ( IsTopMostDir(m_dirName) )
abc2a4cc 585 {
06cc1fb9
JS
586 wxArrayString names, paths;
587 wxArrayInt icons;
588 size_t n, count = wxGetAvailableDrives(paths, names, icons);
589
590 for (n=0; n<count; n++)
abc2a4cc 591 {
999836aa 592 wxFileData *fd = new wxFileData(paths[n], names[n], wxFileData::is_drive, icons[n]);
81169710 593 if (Add(fd, item) != -1)
37fd1c97 594 item.m_itemId++;
81169710
VZ
595 else
596 delete fd;
37fd1c97 597 }
abc2a4cc 598 }
5e673a6a 599 else
06cc1fb9 600#endif // defined(__DOS__) || defined(__WINDOWS__)
8b17ba72 601 {
5e673a6a 602 // Real directory...
619111b9 603 if ( !IsTopMostDir(m_dirName) && !m_dirName.empty() )
8b17ba72 604 {
5e673a6a 605 wxString p(wxPathOnly(m_dirName));
619111b9 606#if (defined(__UNIX__) || defined(__WXWINCE__)) && !defined(__OS2__)
abc2a4cc 607 if (p.empty()) p = wxT("/");
06cc1fb9 608#endif // __UNIX__
999836aa 609 wxFileData *fd = new wxFileData(p, wxT(".."), wxFileData::is_dir, wxFileIconsTable::folder);
81169710 610 if (Add(fd, item) != -1)
7448de8d 611 item.m_itemId++;
81169710
VZ
612 else
613 delete fd;
8b17ba72 614 }
c8c0e54c 615
5e673a6a 616 wxString dirname(m_dirName);
144cf6da 617#if defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__)
5e673a6a
VS
618 if (dirname.length() == 2 && dirname[1u] == wxT(':'))
619 dirname << wxT('\\');
144cf6da 620#endif // defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__)
619111b9
JS
621
622 if (dirname.empty())
623 dirname = wxFILE_SEP_PATH;
624
625 wxLogNull logNull;
5e673a6a
VS
626 wxDir dir(dirname);
627
628 if ( dir.IsOpened() )
cae5359f 629 {
23254b13
JS
630 wxString dirPrefix(dirname);
631 if (dirPrefix.Last() != wxFILE_SEP_PATH)
632 dirPrefix += wxFILE_SEP_PATH;
633
5e673a6a 634 int hiddenFlag = m_showHidden ? wxDIR_HIDDEN : 0;
7a82dabc 635
5e673a6a
VS
636 bool cont;
637 wxString f;
638
639 // Get the directories first (not matched against wildcards):
640 cont = dir.GetFirst(&f, wxEmptyString, wxDIR_DIRS | hiddenFlag);
641 while (cont)
551adc4b 642 {
999836aa 643 wxFileData *fd = new wxFileData(dirPrefix + f, f, wxFileData::is_dir, wxFileIconsTable::folder);
81169710 644 if (Add(fd, item) != -1)
7448de8d 645 item.m_itemId++;
81169710
VZ
646 else
647 delete fd;
648
5e673a6a
VS
649 cont = dir.GetNext(&f);
650 }
651
7a82dabc 652 // Tokenize the wildcard string, so we can handle more than 1
5e673a6a
VS
653 // search pattern in a wildcard.
654 wxStringTokenizer tokenWild(m_wild, wxT(";"));
655 while ( tokenWild.HasMoreTokens() )
656 {
7a82dabc 657 cont = dir.GetFirst(&f, tokenWild.GetNextToken(),
5e673a6a
VS
658 wxDIR_FILES | hiddenFlag);
659 while (cont)
660 {
999836aa 661 wxFileData *fd = new wxFileData(dirPrefix + f, f, wxFileData::is_file, wxFileIconsTable::file);
81169710 662 if (Add(fd, item) != -1)
7448de8d 663 item.m_itemId++;
81169710
VZ
664 else
665 delete fd;
666
5e673a6a
VS
667 cont = dir.GetNext(&f);
668 }
551adc4b 669 }
cae5359f 670 }
cae5359f 671 }
c8c0e54c 672
06cc1fb9 673 SortItems(m_sort_field, m_sort_foward);
8b17ba72
RR
674}
675
0b855868 676void wxFileCtrl::SetWild( const wxString &wild )
8b17ba72 677{
06cc1fb9
JS
678 if (wild.Find(wxT('|')) != wxNOT_FOUND)
679 return;
680
0b855868 681 m_wild = wild;
8f4fcc4e 682 UpdateFiles();
0b855868
RR
683}
684
685void wxFileCtrl::MakeDir()
686{
5e673a6a 687 wxString new_name( _("NewName") );
0b855868 688 wxString path( m_dirName );
75ec8bd4 689 path += wxFILE_SEP_PATH;
0b855868
RR
690 path += new_name;
691 if (wxFileExists(path))
8b17ba72 692 {
0b855868
RR
693 // try NewName0, NewName1 etc.
694 int i = 0;
c8c0e54c 695 do {
0b855868 696 new_name = _("NewName");
c8c0e54c 697 wxString num;
223d09f6 698 num.Printf( wxT("%d"), i );
c8c0e54c
VZ
699 new_name += num;
700
0b855868 701 path = m_dirName;
75ec8bd4 702 path += wxFILE_SEP_PATH;
0b855868 703 path += new_name;
c8c0e54c
VZ
704 i++;
705 } while (wxFileExists(path));
8b17ba72 706 }
c8c0e54c 707
0b855868 708 wxLogNull log;
c8c0e54c 709 if (!wxMkdir(path))
8b17ba72 710 {
0b855868 711 wxMessageDialog dialog(this, _("Operation not permitted."), _("Error"), wxOK | wxICON_ERROR );
c8c0e54c 712 dialog.ShowModal();
0b855868 713 return;
8b17ba72 714 }
8b17ba72 715
06cc1fb9 716 wxFileData *fd = new wxFileData( path, new_name, wxFileData::is_dir, wxFileIconsTable::folder );
0b855868
RR
717 wxListItem item;
718 item.m_itemId = 0;
719 item.m_col = 0;
13111b2a 720 long id = Add( fd, item );
c8c0e54c 721
0b855868
RR
722 if (id != -1)
723 {
06cc1fb9 724 SortItems(m_sort_field, m_sort_foward);
9f542367 725 id = FindItem( 0, wxPtrToUInt(fd) );
0b855868
RR
726 EnsureVisible( id );
727 EditLabel( id );
728 }
81169710
VZ
729 else
730 delete fd;
8b17ba72
RR
731}
732
733void wxFileCtrl::GoToParentDir()
734{
5e673a6a 735 if (!IsTopMostDir(m_dirName))
8b17ba72 736 {
353f41cb 737 size_t len = m_dirName.Len();
083f7497 738 if (wxEndsWithPathSeparator(m_dirName))
353f41cb 739 m_dirName.Remove( len-1, 1 );
c8c0e54c 740 wxString fname( wxFileNameFromPath(m_dirName) );
0b855868 741 m_dirName = wxPathOnly( m_dirName );
144cf6da 742#if defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__)
abc2a4cc 743 if (!m_dirName.empty())
23254b13
JS
744 {
745 if (m_dirName.Last() == wxT('.'))
ca65c044 746 m_dirName = wxEmptyString;
23254b13
JS
747 }
748#elif defined(__UNIX__)
abc2a4cc 749 if (m_dirName.empty())
5e673a6a
VS
750 m_dirName = wxT("/");
751#endif
8f4fcc4e 752 UpdateFiles();
13111b2a 753 long id = FindItem( 0, fname );
abc2a4cc 754 if (id != wxNOT_FOUND)
c8c0e54c 755 {
619111b9 756 ignoreChanges = true;
c8c0e54c
VZ
757 SetItemState( id, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
758 EnsureVisible( id );
619111b9 759 ignoreChanges = false;
c8c0e54c 760 }
8b17ba72
RR
761 }
762}
763
764void wxFileCtrl::GoToHomeDir()
765{
766 wxString s = wxGetUserHome( wxString() );
5e673a6a 767 GoToDir(s);
8b17ba72
RR
768}
769
770void wxFileCtrl::GoToDir( const wxString &dir )
771{
da865fdd 772 if (!wxDirExists(dir)) return;
06cc1fb9 773
8b17ba72 774 m_dirName = dir;
8f4fcc4e 775 UpdateFiles();
619111b9
JS
776
777 ignoreChanges = true;
e6daf794 778 SetItemState( 0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
619111b9
JS
779 ignoreChanges = false;
780
e6daf794 781 EnsureVisible( 0 );
8b17ba72
RR
782}
783
81169710 784void wxFileCtrl::FreeItemData(wxListItem& item)
8b17ba72 785{
81169710
VZ
786 if ( item.m_data )
787 {
788 wxFileData *fd = (wxFileData*)item.m_data;
789 delete fd;
790
791 item.m_data = 0;
792 }
8b17ba72
RR
793}
794
7a82dabc
VZ
795void wxFileCtrl::OnListDeleteItem( wxListEvent &event )
796{
797 FreeItemData(event.m_item);
798}
799
a3a363f6 800void wxFileCtrl::OnListDeleteAllItems( wxListEvent & WXUNUSED(event) )
81169710
VZ
801{
802 FreeAllItemsData();
803}
804
7a82dabc 805void wxFileCtrl::FreeAllItemsData()
12c1b46a
RR
806{
807 wxListItem item;
808 item.m_mask = wxLIST_MASK_DATA;
809
810 item.m_itemId = GetNextItem( -1, wxLIST_NEXT_ALL );
92da8bde 811 while ( item.m_itemId != -1 )
12c1b46a
RR
812 {
813 GetItem( item );
7a82dabc 814 FreeItemData(item);
12c1b46a
RR
815 item.m_itemId = GetNextItem( item.m_itemId, wxLIST_NEXT_ALL );
816 }
817}
818
0b855868 819void wxFileCtrl::OnListEndLabelEdit( wxListEvent &event )
8b17ba72
RR
820{
821 wxFileData *fd = (wxFileData*)event.m_item.m_data;
0b855868 822 wxASSERT( fd );
c8c0e54c 823
abc2a4cc 824 if ((event.GetLabel().empty()) ||
0b855868
RR
825 (event.GetLabel() == _(".")) ||
826 (event.GetLabel() == _("..")) ||
75ec8bd4 827 (event.GetLabel().First( wxFILE_SEP_PATH ) != wxNOT_FOUND))
8b17ba72 828 {
0b855868 829 wxMessageDialog dialog(this, _("Illegal directory name."), _("Error"), wxOK | wxICON_ERROR );
c8c0e54c 830 dialog.ShowModal();
0b855868 831 event.Veto();
c8c0e54c 832 return;
8b17ba72 833 }
c8c0e54c 834
06cc1fb9 835 wxString new_name( wxPathOnly( fd->GetFilePath() ) );
75ec8bd4 836 new_name += wxFILE_SEP_PATH;
0b855868 837 new_name += event.GetLabel();
c8c0e54c 838
0b855868 839 wxLogNull log;
c8c0e54c 840
0b855868 841 if (wxFileExists(new_name))
8b17ba72 842 {
0b855868 843 wxMessageDialog dialog(this, _("File name exists already."), _("Error"), wxOK | wxICON_ERROR );
c8c0e54c 844 dialog.ShowModal();
0b855868 845 event.Veto();
8b17ba72 846 }
c8c0e54c 847
06cc1fb9 848 if (wxRenameFile(fd->GetFilePath(),new_name))
8b17ba72 849 {
0b855868 850 fd->SetNewName( new_name, event.GetLabel() );
619111b9
JS
851
852 ignoreChanges = true;
c8c0e54c 853 SetItemState( event.GetItem(), wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
619111b9
JS
854 ignoreChanges = false;
855
b600ed13 856 UpdateItem( event.GetItem() );
0b855868 857 EnsureVisible( event.GetItem() );
8b17ba72
RR
858 }
859 else
860 {
0b855868 861 wxMessageDialog dialog(this, _("Operation not permitted."), _("Error"), wxOK | wxICON_ERROR );
c8c0e54c 862 dialog.ShowModal();
0b855868 863 event.Veto();
8b17ba72 864 }
8b17ba72
RR
865}
866
23254b13
JS
867void wxFileCtrl::OnListColClick( wxListEvent &event )
868{
869 int col = event.GetColumn();
870
871 switch (col)
872 {
873 case wxFileData::FileList_Name :
06cc1fb9 874 case wxFileData::FileList_Size :
23254b13 875 case wxFileData::FileList_Type :
23254b13
JS
876 case wxFileData::FileList_Time : break;
877 default : return;
878 }
879
880 if ((wxFileData::fileListFieldType)col == m_sort_field)
06cc1fb9 881 m_sort_foward = !m_sort_foward;
23254b13
JS
882 else
883 m_sort_field = (wxFileData::fileListFieldType)col;
884
06cc1fb9 885 SortItems(m_sort_field, m_sort_foward);
23254b13
JS
886}
887
ec524671 888void wxFileCtrl::SortItems(wxFileData::fileListFieldType field, bool forward)
23254b13
JS
889{
890 m_sort_field = field;
ec524671
VZ
891 m_sort_foward = forward;
892 const long sort_dir = forward ? 1 : -1;
23254b13
JS
893
894 switch (m_sort_field)
895 {
06cc1fb9 896 case wxFileData::FileList_Size :
ec524671 897 wxListCtrl::SortItems(wxFileDataSizeCompare, sort_dir);
23254b13 898 break;
ec524671 899
23254b13 900 case wxFileData::FileList_Type :
ec524671
VZ
901 wxListCtrl::SortItems(wxFileDataTypeCompare, sort_dir);
902 break;
903
23254b13 904 case wxFileData::FileList_Time :
ec524671
VZ
905 wxListCtrl::SortItems(wxFileDataTimeCompare, sort_dir);
906 break;
812a5849
WS
907
908 case wxFileData::FileList_Name :
909 default :
910 wxListCtrl::SortItems(wxFileDataNameCompare, sort_dir);
911 break;
23254b13
JS
912 }
913}
914
7a82dabc
VZ
915wxFileCtrl::~wxFileCtrl()
916{
118322a3
WS
917 // Normally the data are freed via an EVT_LIST_DELETE_ALL_ITEMS event and
918 // wxFileCtrl::OnListDeleteAllItems. But if the event is generated after
919 // the destruction of the wxFileCtrl we need to free any data here:
920 FreeAllItemsData();
7a82dabc
VZ
921}
922
8b17ba72 923//-----------------------------------------------------------------------------
23254b13 924// wxGenericFileDialog
8b17ba72
RR
925//-----------------------------------------------------------------------------
926
5e673a6a
VS
927#define ID_LIST_MODE (wxID_FILEDLGG )
928#define ID_REPORT_MODE (wxID_FILEDLGG + 1)
929#define ID_UP_DIR (wxID_FILEDLGG + 5)
930#define ID_PARENT_DIR (wxID_FILEDLGG + 6)
931#define ID_NEW_DIR (wxID_FILEDLGG + 7)
932#define ID_CHOICE (wxID_FILEDLGG + 8)
933#define ID_TEXT (wxID_FILEDLGG + 9)
934#define ID_LIST_CTRL (wxID_FILEDLGG + 10)
5e673a6a 935#define ID_CHECK (wxID_FILEDLGG + 12)
8b17ba72 936
f74172ab 937IMPLEMENT_DYNAMIC_CLASS(wxGenericFileDialog, wxFileDialogBase)
23254b13
JS
938
939BEGIN_EVENT_TABLE(wxGenericFileDialog,wxDialog)
940 EVT_BUTTON(ID_LIST_MODE, wxGenericFileDialog::OnList)
941 EVT_BUTTON(ID_REPORT_MODE, wxGenericFileDialog::OnReport)
942 EVT_BUTTON(ID_UP_DIR, wxGenericFileDialog::OnUp)
943 EVT_BUTTON(ID_PARENT_DIR, wxGenericFileDialog::OnHome)
944 EVT_BUTTON(ID_NEW_DIR, wxGenericFileDialog::OnNew)
945 EVT_BUTTON(wxID_OK, wxGenericFileDialog::OnListOk)
946 EVT_LIST_ITEM_SELECTED(ID_LIST_CTRL, wxGenericFileDialog::OnSelected)
947 EVT_LIST_ITEM_ACTIVATED(ID_LIST_CTRL, wxGenericFileDialog::OnActivated)
948 EVT_CHOICE(ID_CHOICE,wxGenericFileDialog::OnChoiceFilter)
949 EVT_TEXT_ENTER(ID_TEXT,wxGenericFileDialog::OnTextEnter)
950 EVT_TEXT(ID_TEXT,wxGenericFileDialog::OnTextChange)
951 EVT_CHECKBOX(ID_CHECK,wxGenericFileDialog::OnCheck)
8b17ba72
RR
952END_EVENT_TABLE()
953
23254b13 954long wxGenericFileDialog::ms_lastViewStyle = wxLC_LIST;
ca65c044 955bool wxGenericFileDialog::ms_lastShowHidden = false;
655cf310 956
fe6cf128
VZ
957void wxGenericFileDialog::Init()
958{
959 m_bypassGenericImpl = false;
960
961 m_choice = NULL;
962 m_text = NULL;
963 m_list = NULL;
964 m_check = NULL;
965 m_static = NULL;
966 m_upDirButton = NULL;
967 m_newDirButton = NULL;
968}
969
23254b13 970wxGenericFileDialog::wxGenericFileDialog(wxWindow *parent,
9cedab37
VZ
971 const wxString& message,
972 const wxString& defaultDir,
973 const wxString& defaultFile,
974 const wxString& wildCard,
fe6cf128 975 long style,
4e1901b7 976 const wxPoint& pos,
fe6cf128 977 bool bypassGenericImpl ) : wxFileDialogBase()
8b17ba72 978{
fe6cf128
VZ
979 Init();
980 Create( parent, message, defaultDir, defaultFile, wildCard, style, pos, bypassGenericImpl );
4e1901b7
RR
981}
982
983bool wxGenericFileDialog::Create( wxWindow *parent,
abc2a4cc 984 const wxString& message,
fe6cf128 985 const wxString& defaultDir,
abc2a4cc
WS
986 const wxString& defaultFile,
987 const wxString& wildCard,
fe6cf128
VZ
988 long style,
989 const wxPoint& pos,
990 bool bypassGenericImpl )
4e1901b7 991{
fe6cf128
VZ
992 m_bypassGenericImpl = bypassGenericImpl;
993
7e4fb3b8 994 if (!wxFileDialogBase::Create(parent, message, defaultDir, defaultFile,
fe6cf128
VZ
995 wildCard, style, pos))
996 {
997 return false;
998 }
999
1000 if (m_bypassGenericImpl)
1001 return true;
1002
4e1901b7 1003 if (!wxDialog::Create( parent, wxID_ANY, message, pos, wxDefaultSize,
f43255e8 1004 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER
c81c9392 1005 ))
4e1901b7
RR
1006 {
1007 return false;
1008 }
f74172ab 1009
619111b9
JS
1010 ignoreChanges = true;
1011
ca65c044 1012 if (wxConfig::Get(false))
eaf40b23 1013 {
e7d9c398 1014 wxConfig::Get()->Read(wxT("/wxWindows/wxFileDialog/ViewStyle"),
9cedab37 1015 &ms_lastViewStyle);
e7d9c398 1016 wxConfig::Get()->Read(wxT("/wxWindows/wxFileDialog/ShowHidden"),
9cedab37 1017 &ms_lastShowHidden);
eaf40b23
VS
1018 }
1019
9cedab37
VZ
1020 if (m_dialogStyle == 0)
1021 m_dialogStyle = wxOPEN;
7941ba11 1022 if ((m_dialogStyle & wxMULTIPLE ) && !(m_dialogStyle & wxOPEN))
9b00bb16 1023 m_dialogStyle |= wxOPEN;
479cd5de 1024
353f41cb 1025 if ((m_dir.empty()) || (m_dir == wxT(".")))
ac2def68 1026 {
75ec8bd4 1027 m_dir = wxGetCwd();
619111b9
JS
1028 if (m_dir.empty())
1029 m_dir = wxFILE_SEP_PATH;
ac2def68 1030 }
7a82dabc 1031
353f41cb 1032 size_t len = m_dir.Len();
083f7497 1033 if ((len > 1) && (wxEndsWithPathSeparator(m_dir)))
353f41cb
RR
1034 m_dir.Remove( len-1, 1 );
1035
1036 m_path = m_dir;
75ec8bd4 1037 m_path += wxFILE_SEP_PATH;
8b17ba72 1038 m_path += defaultFile;
655cf310 1039 m_filterExtension = wxEmptyString;
c8c0e54c 1040
cae5359f 1041 // layout
4f5c180e 1042
2b5f62a0 1043 bool is_pda = (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA);
c8c0e54c 1044
8b17ba72 1045 wxBoxSizer *mainsizer = new wxBoxSizer( wxVERTICAL );
c8c0e54c 1046
8b17ba72 1047 wxBoxSizer *buttonsizer = new wxBoxSizer( wxHORIZONTAL );
c8c0e54c 1048
e6daf794 1049 wxBitmapButton *but;
c8c0e54c 1050
7a82dabc 1051 but = new wxBitmapButton(this, ID_LIST_MODE,
36668b35 1052 wxArtProvider::GetBitmap(wxART_LIST_VIEW, wxART_BUTTON));
e6daf794
RR
1053#if wxUSE_TOOLTIPS
1054 but->SetToolTip( _("View files as a list view") );
1055#endif
1056 buttonsizer->Add( but, 0, wxALL, 5 );
c8c0e54c 1057
60d2cc25 1058 but = new wxBitmapButton(this, ID_REPORT_MODE,
36668b35 1059 wxArtProvider::GetBitmap(wxART_REPORT_VIEW, wxART_BUTTON));
e6daf794
RR
1060#if wxUSE_TOOLTIPS
1061 but->SetToolTip( _("View files as a detailed view") );
1062#endif
1063 buttonsizer->Add( but, 0, wxALL, 5 );
c8c0e54c 1064
0b855868 1065 buttonsizer->Add( 30, 5, 1 );
e6daf794 1066
06cc1fb9 1067 m_upDirButton = new wxBitmapButton(this, ID_UP_DIR,
36668b35 1068 wxArtProvider::GetBitmap(wxART_GO_DIR_UP, wxART_BUTTON));
e6daf794 1069#if wxUSE_TOOLTIPS
06cc1fb9 1070 m_upDirButton->SetToolTip( _("Go to parent directory") );
e6daf794 1071#endif
06cc1fb9 1072 buttonsizer->Add( m_upDirButton, 0, wxALL, 5 );
c8c0e54c 1073
37fd1c97 1074#ifndef __DOS__ // VS: Home directory is meaningless in MS-DOS...
60d2cc25 1075 but = new wxBitmapButton(this, ID_PARENT_DIR,
36668b35 1076 wxArtProvider::GetBitmap(wxART_GO_HOME, wxART_BUTTON));
e6daf794
RR
1077#if wxUSE_TOOLTIPS
1078 but->SetToolTip( _("Go to home directory") );
1079#endif
1080 buttonsizer->Add( but, 0, wxALL, 5);
c8c0e54c 1081
e6daf794 1082 buttonsizer->Add( 20, 20 );
75ec8bd4 1083#endif //!__DOS__
c8c0e54c 1084
06cc1fb9 1085 m_newDirButton = new wxBitmapButton(this, ID_NEW_DIR,
36668b35 1086 wxArtProvider::GetBitmap(wxART_NEW_DIR, wxART_BUTTON));
e6daf794 1087#if wxUSE_TOOLTIPS
06cc1fb9 1088 m_newDirButton->SetToolTip( _("Create new directory") );
e6daf794 1089#endif
06cc1fb9 1090 buttonsizer->Add( m_newDirButton, 0, wxALL, 5 );
c8c0e54c 1091
2b5f62a0 1092 if (is_pda)
c15521c6
RR
1093 mainsizer->Add( buttonsizer, 0, wxALL | wxEXPAND, 0 );
1094 else
1095 mainsizer->Add( buttonsizer, 0, wxALL | wxEXPAND, 5 );
c8c0e54c 1096
9c884972 1097 wxBoxSizer *staticsizer = new wxBoxSizer( wxHORIZONTAL );
2b5f62a0 1098 if (is_pda)
ca65c044
WS
1099 staticsizer->Add( new wxStaticText( this, wxID_ANY, _("Current directory:") ), 0, wxRIGHT, 10 );
1100 m_static = new wxStaticText( this, wxID_ANY, m_dir );
9c884972
RR
1101 staticsizer->Add( m_static, 1 );
1102 mainsizer->Add( staticsizer, 0, wxEXPAND | wxLEFT|wxRIGHT|wxBOTTOM, 10 );
1103
619111b9 1104 long style2 = ms_lastViewStyle;
9cedab37 1105 if ( !(m_dialogStyle & wxMULTIPLE) )
cd6b752b 1106 style2 |= wxLC_SINGLE_SEL;
9cedab37 1107
619111b9
JS
1108#ifdef __WXWINCE__
1109 style2 |= wxSIMPLE_BORDER;
1110#else
1111 style2 |= wxSUNKEN_BORDER;
1112#endif
1113
23254b13 1114 m_list = new wxFileCtrl( this, ID_LIST_CTRL,
9548f380 1115 wxEmptyString, ms_lastShowHidden,
9cedab37 1116 wxDefaultPosition, wxSize(540,200),
cd6b752b 1117 style2);
9cedab37 1118
2b5f62a0 1119 if (is_pda)
c15521c6 1120 {
41fecb44
VS
1121 // PDAs have a different screen layout
1122 mainsizer->Add( m_list, 1, wxEXPAND | wxLEFT|wxRIGHT, 5 );
1123
41fecb44 1124 wxBoxSizer *textsizer = new wxBoxSizer( wxHORIZONTAL );
8e13c1ec 1125 m_text = new wxTextCtrl( this, ID_TEXT, m_fileName, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
41fecb44
VS
1126 textsizer->Add( m_text, 1, wxCENTER | wxALL, 5 );
1127 mainsizer->Add( textsizer, 0, wxEXPAND );
1128
ca06ee0d
RR
1129 m_check = NULL;
1130 m_choice = new wxChoice( this, ID_CHOICE );
1131 textsizer->Add( m_choice, 1, wxCENTER|wxALL, 5 );
41fecb44 1132
c81c9392
WS
1133 wxSizer *bsizer = CreateButtonSizer( wxOK|wxCANCEL , false, 5 );
1134 if(bsizer->GetChildren().GetCount() > 0 )
1135 {
1136 mainsizer->Add( bsizer, 0, wxEXPAND | wxALL, 5 );
1137 }
1138 else
1139 {
1140 delete bsizer;
1141 }
c15521c6
RR
1142 }
1143 else
1144 {
41fecb44
VS
1145 mainsizer->Add( m_list, 1, wxEXPAND | wxLEFT|wxRIGHT, 10 );
1146
1147 wxBoxSizer *textsizer = new wxBoxSizer( wxHORIZONTAL );
8e13c1ec 1148 m_text = new wxTextCtrl( this, ID_TEXT, m_fileName, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
41fecb44 1149 textsizer->Add( m_text, 1, wxCENTER | wxLEFT|wxRIGHT|wxTOP, 10 );
5f7bcb48 1150 textsizer->Add( new wxButton( this, wxID_OK ), 0, wxCENTER | wxLEFT|wxRIGHT|wxTOP, 10 );
41fecb44
VS
1151 mainsizer->Add( textsizer, 0, wxEXPAND );
1152
1153 wxBoxSizer *choicesizer = new wxBoxSizer( wxHORIZONTAL );
1154 m_choice = new wxChoice( this, ID_CHOICE );
1155 choicesizer->Add( m_choice, 1, wxCENTER|wxALL, 10 );
1156 m_check = new wxCheckBox( this, ID_CHECK, _("Show hidden files") );
9cedab37 1157 m_check->SetValue( ms_lastShowHidden );
41fecb44 1158 choicesizer->Add( m_check, 0, wxCENTER|wxALL, 10 );
5f7bcb48 1159 choicesizer->Add( new wxButton( this, wxID_CANCEL ), 0, wxCENTER | wxALL, 10 );
41fecb44 1160 mainsizer->Add( choicesizer, 0, wxEXPAND );
c15521c6 1161 }
24f932d2 1162
b4cfe261 1163 SetWildcard(wildCard);
8b17ba72 1164
ca65c044 1165 SetAutoLayout( true );
8b17ba72 1166 SetSizer( mainsizer );
c8c0e54c 1167
619111b9
JS
1168 if (!is_pda)
1169 {
1170 mainsizer->Fit( this );
1171 mainsizer->SetSizeHints( this );
ed58dbea 1172
619111b9
JS
1173 Centre( wxBOTH );
1174 }
c81c9392 1175
9cedab37 1176 m_text->SetFocus();
c81c9392 1177
619111b9 1178 ignoreChanges = false;
abc2a4cc 1179
4e1901b7 1180 return true;
8b17ba72
RR
1181}
1182
23254b13 1183wxGenericFileDialog::~wxGenericFileDialog()
cae5359f 1184{
619111b9
JS
1185 ignoreChanges = true;
1186
4e1901b7 1187 if (!m_bypassGenericImpl)
eaf40b23 1188 {
4e1901b7
RR
1189 if (wxConfig::Get(false))
1190 {
1191 wxConfig::Get()->Write(wxT("/wxWindows/wxFileDialog/ViewStyle"),
1192 ms_lastViewStyle);
1193 wxConfig::Get()->Write(wxT("/wxWindows/wxFileDialog/ShowHidden"),
1194 ms_lastShowHidden);
1195 }
c5ef41d3 1196
4e1901b7
RR
1197 const int count = m_choice->GetCount();
1198 for ( int i = 0; i < count; i++ )
1199 {
1200 delete (wxString *)m_choice->GetClientData(i);
1201 }
c5ef41d3 1202 }
cae5359f
RR
1203}
1204
23254b13 1205int wxGenericFileDialog::ShowModal()
9cedab37 1206{
619111b9
JS
1207 ignoreChanges = true;
1208
9cedab37 1209 m_list->GoToDir(m_dir);
06cc1fb9 1210 UpdateControls();
2b5f62a0 1211 m_text->SetValue(m_fileName);
9cedab37 1212
619111b9
JS
1213 ignoreChanges = false;
1214
9cedab37
VZ
1215 return wxDialog::ShowModal();
1216}
1217
16dce3b3
RR
1218bool wxGenericFileDialog::Show( bool show )
1219{
619111b9
JS
1220 // Called by ShowModal, so don't repeate the update
1221#ifndef __WIN32__
16dce3b3
RR
1222 if (show)
1223 {
1224 m_list->GoToDir(m_dir);
1225 UpdateControls();
1226 m_text->SetValue(m_fileName);
1227 }
619111b9 1228#endif
16dce3b3
RR
1229
1230 return wxDialog::Show( show );
1231}
1232
23254b13 1233void wxGenericFileDialog::DoSetFilterIndex(int filterindex)
2b5f62a0
VZ
1234{
1235 wxString *str = (wxString*) m_choice->GetClientData( filterindex );
1236 m_list->SetWild( *str );
1237 m_filterIndex = filterindex;
1238 if ( str->Left(2) == wxT("*.") )
1239 {
787d22ec
JS
1240 m_filterExtension = str->Mid(1);
1241 if (m_filterExtension == _T(".*"))
2b5f62a0
VZ
1242 m_filterExtension.clear();
1243 }
1244 else
1245 {
1246 m_filterExtension.clear();
1247 }
1248}
1249
b4cfe261
VZ
1250void wxGenericFileDialog::SetWildcard(const wxString& wildCard)
1251{
1252 wxFileDialogBase::SetWildcard(wildCard);
1253
1254 wxArrayString wildDescriptions, wildFilters;
1255 const size_t count = wxParseCommonDialogsFilter(m_wildCard,
1256 wildDescriptions,
1257 wildFilters);
1258 wxCHECK_RET( count, wxT("wxFileDialog: bad wildcard string") );
1259
7e4fb3b8
VZ
1260 const size_t countOld = m_choice->GetCount();
1261 size_t n;
1262 for ( n = 0; n < countOld; n++ )
fe6cf128
VZ
1263 {
1264 delete (wxString *)m_choice->GetClientData(n);
1265 }
7e4fb3b8 1266
fe6cf128 1267 for ( n = 0; n < count; n++ )
b4cfe261
VZ
1268 {
1269 m_choice->Append( wildDescriptions[n], new wxString( wildFilters[n] ) );
1270 }
1271
1272 SetFilterIndex( 0 );
1273}
1274
23254b13 1275void wxGenericFileDialog::SetFilterIndex( int filterindex )
04ea7f93
RR
1276{
1277 m_choice->SetSelection( filterindex );
2b5f62a0
VZ
1278
1279 DoSetFilterIndex(filterindex);
04ea7f93
RR
1280}
1281
23254b13 1282void wxGenericFileDialog::OnChoiceFilter( wxCommandEvent &event )
cae5359f 1283{
2b5f62a0 1284 DoSetFilterIndex((int)event.GetInt());
cae5359f
RR
1285}
1286
23254b13 1287void wxGenericFileDialog::OnCheck( wxCommandEvent &event )
bf9e3e73 1288{
9cedab37 1289 m_list->ShowHidden( (ms_lastShowHidden = event.GetInt() != 0) );
bf9e3e73
RR
1290}
1291
23254b13 1292void wxGenericFileDialog::OnActivated( wxListEvent &event )
8b17ba72 1293{
e1811a01 1294 HandleAction( event.m_item.m_text );
8b17ba72
RR
1295}
1296
23254b13 1297void wxGenericFileDialog::OnTextEnter( wxCommandEvent &WXUNUSED(event) )
cae5359f 1298{
b28a6678 1299 HandleAction( m_text->GetValue() );
cae5359f
RR
1300}
1301
23254b13 1302void wxGenericFileDialog::OnTextChange( wxCommandEvent &WXUNUSED(event) )
df413171
JS
1303{
1304 if (!ignoreChanges)
1305 {
1306 // Clear selections. Otherwise when the user types in a value they may
1307 // not get the file whose name they typed.
1308 if (m_list->GetSelectedItemCount() > 0)
1309 {
7f04165e 1310 long item = m_list->GetNextItem(-1, wxLIST_NEXT_ALL,
df413171
JS
1311 wxLIST_STATE_SELECTED);
1312 while ( item != -1 )
7f04165e 1313 {
df413171
JS
1314 m_list->SetItemState(item,0, wxLIST_STATE_SELECTED);
1315 item = m_list->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
7f04165e 1316 }
df413171
JS
1317 }
1318 }
1319}
1320
23254b13 1321void wxGenericFileDialog::OnSelected( wxListEvent &event )
8b17ba72 1322{
619111b9
JS
1323 static bool inSelected = false;
1324
1325 if (inSelected)
1326 return;
1327
1328 inSelected = true;
e1811a01 1329 wxString filename( event.m_item.m_text );
619111b9
JS
1330
1331#ifdef __WXWINCE__
1332 // No double-click on most WinCE devices, so do action immediately.
1333 HandleAction( filename );
1334#else
957eca2f
JS
1335 if (filename == wxT(".."))
1336 {
1337 inSelected = false;
1338 return;
1339 }
479cd5de 1340
06cc1fb9 1341 wxString dir = m_list->GetDir();
5e673a6a
VS
1342 if (!IsTopMostDir(dir))
1343 dir += wxFILE_SEP_PATH;
e1811a01 1344 dir += filename;
957eca2f
JS
1345 if (wxDirExists(dir))
1346 {
1347 inSelected = false;
1348 return;
1349 }
479cd5de 1350
ca65c044 1351 ignoreChanges = true;
e1811a01 1352 m_text->SetValue( filename );
ca65c044 1353 ignoreChanges = false;
619111b9
JS
1354#endif
1355 inSelected = false;
8b17ba72
RR
1356}
1357
23254b13 1358void wxGenericFileDialog::HandleAction( const wxString &fn )
8b17ba72 1359{
619111b9
JS
1360 if (ignoreChanges)
1361 return;
1362
e1811a01 1363 wxString filename( fn );
c81c9392
WS
1364 if (filename.empty())
1365 {
1366#ifdef __WXWINCE__
b28a6678 1367 EndModal(wxID_CANCEL);
c81c9392
WS
1368#endif
1369 return;
1370 }
223d09f6 1371 if (filename == wxT(".")) return;
c8c0e54c 1372
c81c9392
WS
1373 wxString dir = m_list->GetDir();
1374
b600ed13
VZ
1375 // "some/place/" means they want to chdir not try to load "place"
1376 bool want_dir = filename.Last() == wxFILE_SEP_PATH;
1377 if (want_dir)
1378 filename = filename.RemoveLast();
1379
223d09f6 1380 if (filename == wxT(".."))
0b855868 1381 {
619111b9 1382 ignoreChanges = true;
0b855868
RR
1383 m_list->GoToParentDir();
1384 m_list->SetFocus();
06cc1fb9 1385 UpdateControls();
619111b9 1386 ignoreChanges = false;
c8c0e54c 1387 return;
0b855868
RR
1388 }
1389
75ec8bd4 1390#ifdef __UNIX__
223d09f6 1391 if (filename == wxT("~"))
ed58dbea 1392 {
619111b9 1393 ignoreChanges = true;
ed58dbea
RR
1394 m_list->GoToHomeDir();
1395 m_list->SetFocus();
06cc1fb9 1396 UpdateControls();
619111b9 1397 ignoreChanges = false;
c8c0e54c 1398 return;
ed58dbea 1399 }
c8c0e54c 1400
b600ed13 1401 if (filename.BeforeFirst(wxT('/')) == wxT("~"))
ed58dbea 1402 {
71f2fb52 1403 filename = wxString(wxGetUserHome()) + filename.Remove(0, 1);
ed58dbea 1404 }
75ec8bd4 1405#endif // __UNIX__
ed58dbea 1406
854aa1e1 1407 if (!(m_dialogStyle & wxSAVE))
cae5359f 1408 {
854aa1e1
RR
1409 if ((filename.Find(wxT('*')) != wxNOT_FOUND) ||
1410 (filename.Find(wxT('?')) != wxNOT_FOUND))
c8c0e54c 1411 {
854aa1e1
RR
1412 if (filename.Find(wxFILE_SEP_PATH) != wxNOT_FOUND)
1413 {
1414 wxMessageBox(_("Illegal file specification."), _("Error"), wxOK | wxICON_ERROR );
1415 return;
1416 }
1417 m_list->SetWild( filename );
c8c0e54c
VZ
1418 return;
1419 }
cae5359f
RR
1420 }
1421
5e673a6a
VS
1422 if (!IsTopMostDir(dir))
1423 dir += wxFILE_SEP_PATH;
1424 if (!wxIsAbsolutePath(filename))
ed58dbea
RR
1425 {
1426 dir += filename;
1427 filename = dir;
1428 }
c8c0e54c 1429
da865fdd 1430 if (wxDirExists(filename))
8b17ba72 1431 {
619111b9 1432 ignoreChanges = true;
8b17ba72 1433 m_list->GoToDir( filename );
06cc1fb9 1434 UpdateControls();
619111b9 1435 ignoreChanges = false;
c8c0e54c 1436 return;
8b17ba72 1437 }
c8c0e54c 1438
b600ed13
VZ
1439 // they really wanted a dir, but it doesn't exist
1440 if (want_dir)
1441 {
1442 wxMessageBox(_("Directory doesn't exist."), _("Error"),
1443 wxOK | wxICON_ERROR );
1444 return;
1445 }
1446
2b5f62a0
VZ
1447 // append the default extension to the filename if it doesn't have any
1448 //
1449 // VZ: the logic of testing for !wxFileExists() only for the open file
1450 // dialog is not entirely clear to me, why don't we allow saving to a
1451 // file without extension as well?
1452 if ( !(m_dialogStyle & wxOPEN) || !wxFileExists(filename) )
8b17ba72 1453 {
f74172ab 1454 filename = AppendExtension(filename, m_filterExtension);
8b17ba72 1455 }
2b5f62a0
VZ
1456
1457 // check that the file [doesn't] exist if necessary
1458 if ( (m_dialogStyle & wxSAVE) &&
1459 (m_dialogStyle & wxOVERWRITE_PROMPT) &&
1460 wxFileExists( filename ) )
8b17ba72 1461 {
2b5f62a0 1462 wxString msg;
88d6c988 1463 msg.Printf( _("File '%s' already exists, do you really want to overwrite it?"), filename.c_str() );
655cf310 1464
2b5f62a0
VZ
1465 if (wxMessageBox(msg, _("Confirm"), wxYES_NO) != wxYES)
1466 return;
1467 }
1468 else if ( (m_dialogStyle & wxOPEN) &&
1469 (m_dialogStyle & wxFILE_MUST_EXIST) &&
1470 !wxFileExists(filename) )
1471 {
1472 wxMessageBox(_("Please choose an existing file."), _("Error"),
1473 wxOK | wxICON_ERROR );
8b17ba72
RR
1474 }
1475
1476 SetPath( filename );
479cd5de 1477
3f6638b8 1478 // change to the directory where the user went if asked
fda09b3f 1479 if ( m_dialogStyle & wxCHANGE_DIR )
3f6638b8
VZ
1480 {
1481 wxString cwd;
1482 wxSplitPath(filename, &cwd, NULL, NULL);
1483
0b98a252 1484 if ( cwd != wxGetCwd() )
3f6638b8
VZ
1485 {
1486 wxSetWorkingDirectory(cwd);
1487 }
1488 }
1489
b28a6678 1490 EndModal(wxID_OK);
e1811a01
RR
1491}
1492
23254b13 1493void wxGenericFileDialog::OnListOk( wxCommandEvent &WXUNUSED(event) )
e1811a01
RR
1494{
1495 HandleAction( m_text->GetValue() );
8b17ba72
RR
1496}
1497
23254b13 1498void wxGenericFileDialog::OnList( wxCommandEvent &WXUNUSED(event) )
8b17ba72 1499{
619111b9 1500 ignoreChanges = true;
8b17ba72 1501 m_list->ChangeToListMode();
9cedab37 1502 ms_lastViewStyle = wxLC_LIST;
0b855868 1503 m_list->SetFocus();
619111b9 1504 ignoreChanges = false;
8b17ba72
RR
1505}
1506
23254b13 1507void wxGenericFileDialog::OnReport( wxCommandEvent &WXUNUSED(event) )
8b17ba72 1508{
619111b9 1509 ignoreChanges = true;
8b17ba72 1510 m_list->ChangeToReportMode();
9cedab37 1511 ms_lastViewStyle = wxLC_REPORT;
0b855868 1512 m_list->SetFocus();
619111b9 1513 ignoreChanges = false;
8b17ba72
RR
1514}
1515
23254b13 1516void wxGenericFileDialog::OnUp( wxCommandEvent &WXUNUSED(event) )
8b17ba72 1517{
619111b9 1518 ignoreChanges = true;
8b17ba72 1519 m_list->GoToParentDir();
0b855868 1520 m_list->SetFocus();
06cc1fb9 1521 UpdateControls();
619111b9 1522 ignoreChanges = false;
8b17ba72
RR
1523}
1524
23254b13 1525void wxGenericFileDialog::OnHome( wxCommandEvent &WXUNUSED(event) )
8b17ba72 1526{
619111b9 1527 ignoreChanges = true;
8b17ba72 1528 m_list->GoToHomeDir();
0b855868 1529 m_list->SetFocus();
06cc1fb9 1530 UpdateControls();
619111b9 1531 ignoreChanges = false;
0b855868
RR
1532}
1533
23254b13 1534void wxGenericFileDialog::OnNew( wxCommandEvent &WXUNUSED(event) )
0b855868 1535{
619111b9
JS
1536 ignoreChanges = true;
1537
0b855868 1538 m_list->MakeDir();
619111b9
JS
1539
1540 ignoreChanges = false;
8b17ba72
RR
1541}
1542
23254b13 1543void wxGenericFileDialog::SetPath( const wxString& path )
8b17ba72
RR
1544{
1545 // not only set the full path but also update filename and dir
1546 m_path = path;
619111b9
JS
1547
1548#ifdef __WXWINCE__
1549 if (m_path.empty())
1550 m_path = wxFILE_SEP_PATH;
1551#endif
1552
9cedab37 1553 if ( !path.empty() )
8b17ba72
RR
1554 {
1555 wxString ext;
1556 wxSplitPath(path, &m_dir, &m_fileName, &ext);
9cedab37 1557 if (!ext.empty())
c8c0e54c 1558 {
223d09f6 1559 m_fileName += wxT(".");
8b17ba72 1560 m_fileName += ext;
c8c0e54c 1561 }
8b17ba72
RR
1562 }
1563}
c8c0e54c 1564
23254b13 1565void wxGenericFileDialog::GetPaths( wxArrayString& paths ) const
7941ba11
RR
1566{
1567 paths.Empty();
28c9c76e
RR
1568 if (m_list->GetSelectedItemCount() == 0)
1569 {
1570 paths.Add( GetPath() );
1571 return;
1572 }
479cd5de 1573
7941ba11
RR
1574 paths.Alloc( m_list->GetSelectedItemCount() );
1575
06cc1fb9 1576 wxString dir = m_list->GetDir();
5e673a6a 1577#ifdef __UNIX__
7a82dabc 1578 if (dir != wxT("/"))
619111b9
JS
1579#endif
1580#ifdef __WXWINCE__
1581 if (dir != wxT("/") && dir != wxT("\\"))
5e673a6a
VS
1582#endif
1583 dir += wxFILE_SEP_PATH;
7941ba11
RR
1584
1585 wxListItem item;
1586 item.m_mask = wxLIST_MASK_TEXT;
1587
1588 item.m_itemId = m_list->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
92da8bde 1589 while ( item.m_itemId != -1 )
68df5777 1590 {
7941ba11
RR
1591 m_list->GetItem( item );
1592 paths.Add( dir + item.m_text );
68df5777 1593 item.m_itemId = m_list->GetNextItem( item.m_itemId,
7941ba11
RR
1594 wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
1595 }
1596}
1597
23254b13 1598void wxGenericFileDialog::GetFilenames(wxArrayString& files) const
7941ba11
RR
1599{
1600 files.Empty();
28c9c76e
RR
1601 if (m_list->GetSelectedItemCount() == 0)
1602 {
1603 files.Add( GetFilename() );
1604 return;
1605 }
7941ba11
RR
1606 files.Alloc( m_list->GetSelectedItemCount() );
1607
1608 wxListItem item;
1609 item.m_mask = wxLIST_MASK_TEXT;
1610
1611 item.m_itemId = m_list->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
92da8bde 1612 while ( item.m_itemId != -1 )
68df5777 1613 {
7941ba11
RR
1614 m_list->GetItem( item );
1615 files.Add( item.m_text );
68df5777 1616 item.m_itemId = m_list->GetNextItem( item.m_itemId,
7941ba11
RR
1617 wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
1618 }
1619}
1620
06cc1fb9
JS
1621void wxGenericFileDialog::UpdateControls()
1622{
1623 wxString dir = m_list->GetDir();
1624 m_static->SetLabel(dir);
1625
1626 bool enable = !IsTopMostDir(dir);
1627 m_upDirButton->Enable(enable);
1628
144cf6da 1629#if defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__)
06cc1fb9 1630 m_newDirButton->Enable(enable);
144cf6da 1631#endif // defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__)
06cc1fb9
JS
1632}
1633
23254b13 1634#ifdef USE_GENERIC_FILEDIALOG
655cf310 1635
412e0d47 1636IMPLEMENT_DYNAMIC_CLASS(wxFileDialog, wxGenericFileDialog)
655cf310 1637
23254b13
JS
1638#endif // USE_GENERIC_FILEDIALOG
1639
4e1901b7 1640#endif // wxUSE_FILEDLG