1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/generic/dirctrlg.cpp
3 // Purpose: wxGenericDirCtrl
4 // Author: Harm van der Heijden, Robert Roebling, Julian Smart
7 // Copyright: (c) Harm van der Heijden, Robert Roebling and Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
18 #if wxUSE_DIRDLG || wxUSE_FILEDLG
20 #include "wx/generic/dirctrlg.h"
27 #include "wx/button.h"
29 #include "wx/settings.h"
30 #include "wx/msgdlg.h"
31 #include "wx/choice.h"
32 #include "wx/textctrl.h"
33 #include "wx/layout.h"
35 #include "wx/textdlg.h"
36 #include "wx/gdicmn.h"
38 #include "wx/module.h"
41 #include "wx/filename.h"
42 #include "wx/filefn.h"
43 #include "wx/imaglist.h"
44 #include "wx/tokenzr.h"
46 #include "wx/artprov.h"
47 #include "wx/mimetype.h"
50 #include "wx/statline.h"
53 #if defined(__WXMAC__)
54 #include "wx/osx/private.h" // includes mac headers
59 #include "wx/msw/winundef.h"
60 #include "wx/volume.h"
62 // FIXME - Mingw32 1.0 has both _getdrive() and _chdrive(). For now, let's assume
63 // older releases don't, but it should be verified and the checks modified
65 #if !defined(__GNUWIN32__) || (defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 1)
66 #if !defined(__WXWINCE__)
75 #if defined(__OS2__) || defined(__DOS__)
87 #if defined(__WXMAC__)
88 // #include "MoreFilesX.h"
95 extern WXDLLEXPORT_DATA(const char) wxFileSelectorDefaultWildcardStr
[];
97 // If compiled under Windows, this macro can cause problems
102 bool wxIsDriveAvailable(const wxString
& dirName
);
104 // ----------------------------------------------------------------------------
106 // ----------------------------------------------------------------------------
108 wxDEFINE_EVENT( wxEVT_DIRCTRL_SELECTIONCHANGED
, wxTreeEvent
);
109 wxDEFINE_EVENT( wxEVT_DIRCTRL_FILEACTIVATED
, wxTreeEvent
);
111 // ----------------------------------------------------------------------------
112 // wxGetAvailableDrives, for WINDOWS, DOS, OS2, MAC, UNIX (returns "/")
113 // ----------------------------------------------------------------------------
115 size_t wxGetAvailableDrives(wxArrayString
&paths
, wxArrayString
&names
, wxArrayInt
&icon_ids
)
117 #ifdef wxHAS_FILESYSTEM_VOLUMES
120 // No logical drives; return "\"
121 paths
.Add(wxT("\\"));
122 names
.Add(wxT("\\"));
123 icon_ids
.Add(wxFileIconsTable::computer
);
124 #elif defined(__WIN32__) && wxUSE_FSVOLUME
125 // TODO: this code (using wxFSVolumeBase) should be used for all platforms
126 // but unfortunately wxFSVolumeBase is not implemented everywhere
127 const wxArrayString as
= wxFSVolumeBase::GetVolumes();
129 for (size_t i
= 0; i
< as
.GetCount(); i
++)
131 wxString path
= as
[i
];
132 wxFSVolume
vol(path
);
134 switch (vol
.GetKind())
136 case wxFS_VOL_FLOPPY
:
137 if ( (path
== wxT("a:\\")) || (path
== wxT("b:\\")) )
138 imageId
= wxFileIconsTable::floppy
;
140 imageId
= wxFileIconsTable::removeable
;
142 case wxFS_VOL_DVDROM
:
144 imageId
= wxFileIconsTable::cdrom
;
146 case wxFS_VOL_NETWORK
:
147 if (path
[0] == wxT('\\'))
148 continue; // skip "\\computer\folder"
149 imageId
= wxFileIconsTable::drive
;
154 imageId
= wxFileIconsTable::drive
;
158 names
.Add(vol
.GetDisplayName());
159 icon_ids
.Add(imageId
);
161 #elif defined(__OS2__)
163 ULONG ulDriveNum
= 0;
164 ULONG ulDriveMap
= 0;
165 rc
= ::DosQueryCurrentDisk(&ulDriveNum
, &ulDriveMap
);
171 if (ulDriveMap
& ( 1 << i
))
173 const wxString path
= wxFileName::GetVolumeString(
174 'A' + i
, wxPATH_GET_SEPARATOR
);
175 const wxString name
= wxFileName::GetVolumeString(
176 'A' + i
, wxPATH_NO_SEPARATOR
);
178 // Note: If _filesys is unsupported by some compilers,
179 // we can always replace it by DosQueryFSAttach
180 char filesysname
[20];
182 ULONG cbBuffer
= sizeof(filesysname
);
183 PFSQBUFFER2 pfsqBuffer
= (PFSQBUFFER2
)filesysname
;
184 APIRET rc
= ::DosQueryFSAttach(name
.fn_str(),0,FSAIL_QUERYNAME
,pfsqBuffer
,&cbBuffer
);
187 filesysname
[0] = '\0';
190 _filesys(name
.fn_str(), filesysname
, sizeof(filesysname
));
192 /* FAT, LAN, HPFS, CDFS, NFS */
194 if (path
== wxT("A:\\") || path
== wxT("B:\\"))
195 imageId
= wxFileIconsTable::floppy
;
196 else if (!strcmp(filesysname
, "CDFS"))
197 imageId
= wxFileIconsTable::cdrom
;
198 else if (!strcmp(filesysname
, "LAN") ||
199 !strcmp(filesysname
, "NFS"))
200 imageId
= wxFileIconsTable::drive
;
202 imageId
= wxFileIconsTable::drive
;
205 icon_ids
.Add(imageId
);
210 #else // !__WIN32__, !__OS2__
211 /* If we can switch to the drive, it exists. */
212 for ( char drive
= 'A'; drive
<= 'Z'; drive
++ )
215 path
= wxFileName::GetVolumeString(drive
, wxPATH_GET_SEPARATOR
);
217 if (wxIsDriveAvailable(path
))
220 names
.Add(wxFileName::GetVolumeString(drive
, wxPATH_NO_SEPARATOR
));
221 icon_ids
.Add(drive
<= 2 ? wxFileIconsTable::floppy
222 : wxFileIconsTable::drive
);
225 #endif // __WIN32__/!__WIN32__
227 #elif defined(__WXMAC__) && wxOSX_USE_COCOA_OR_CARBON
229 ItemCount volumeIndex
= 1;
232 while( noErr
== err
)
234 HFSUniStr255 volumeName
;
236 FSVolumeInfo volumeInfo
;
237 err
= FSGetVolumeInfo(0, volumeIndex
, NULL
, kFSVolInfoFlags
, &volumeInfo
, &volumeName
, &fsRef
);
240 wxString path
= wxMacFSRefToPath( &fsRef
) ;
241 wxString name
= wxMacHFSUniStrToString( &volumeName
) ;
243 if ( (volumeInfo
.flags
& kFSVolFlagSoftwareLockedMask
) || (volumeInfo
.flags
& kFSVolFlagHardwareLockedMask
) )
245 icon_ids
.Add(wxFileIconsTable::cdrom
);
249 icon_ids
.Add(wxFileIconsTable::drive
);
251 // todo other removable
259 #elif defined(__UNIX__)
262 icon_ids
.Add(wxFileIconsTable::computer
);
264 #error "Unsupported platform in wxGenericDirCtrl!"
266 wxASSERT_MSG( (paths
.GetCount() == names
.GetCount()), wxT("The number of paths and their human readable names should be equal in number."));
267 wxASSERT_MSG( (paths
.GetCount() == icon_ids
.GetCount()), wxT("Wrong number of icons for available drives."));
268 return paths
.GetCount();
271 // ----------------------------------------------------------------------------
272 // wxIsDriveAvailable
273 // ----------------------------------------------------------------------------
277 bool wxIsDriveAvailable(const wxString
& dirName
)
279 // FIXME: this method leads to hang up under Watcom for some reason
281 wxUnusedVar(dirName
);
283 if ( dirName
.length() == 3 && dirName
[1u] == wxT(':') )
285 wxString
dirNameLower(dirName
.Lower());
286 // VS: always return true for removable media, since Win95 doesn't
287 // like it when MS-DOS app accesses empty floppy drive
288 return (dirNameLower
[0u] == wxT('a') ||
289 dirNameLower
[0u] == wxT('b') ||
290 wxDirExists(dirNameLower
));
297 #elif defined(__WINDOWS__) || defined(__OS2__)
299 int setdrive(int WXUNUSED_IN_WINCE(drive
))
303 #elif defined(__GNUWIN32__) && \
304 (defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 1)
305 return _chdrive(drive
);
309 if (drive
< 1 || drive
> 31)
311 newdrive
[0] = (wxChar
)(wxT('A') + drive
- 1);
312 newdrive
[1] = wxT(':');
314 newdrive
[2] = wxT('\\');
315 newdrive
[3] = wxT('\0');
317 newdrive
[2] = wxT('\0');
319 #if defined(__WINDOWS__)
320 if (::SetCurrentDirectory(newdrive
))
322 // VA doesn't know what LPSTR is and has its own set
323 if (!DosSetCurrentDir((PSZ
)newdrive
))
331 bool wxIsDriveAvailable(const wxString
& WXUNUSED_IN_WINCE(dirName
))
337 UINT errorMode
= SetErrorMode(SEM_FAILCRITICALERRORS
| SEM_NOOPENFILEERRORBOX
);
341 // Check if this is a root directory and if so,
342 // whether the drive is available.
343 if (dirName
.length() == 3 && dirName
[(size_t)1] == wxT(':'))
345 wxString
dirNameLower(dirName
.Lower());
346 #if defined(__GNUWIN32__) && !(defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 1)
347 success
= wxDirExists(dirNameLower
);
350 // Avoid changing to drive since no media may be inserted.
351 if (dirNameLower
[(size_t)0] == 'a' || dirNameLower
[(size_t)0] == 'b')
354 int currentDrive
= _getdrive();
355 int thisDrive
= (int) (dirNameLower
[(size_t)0] - 'a' + 1) ;
356 int err
= setdrive( thisDrive
) ;
357 setdrive( currentDrive
);
366 (void) SetErrorMode(errorMode
);
372 #endif // __WINDOWS__ || __OS2__
374 #endif // wxUSE_DIRDLG || wxUSE_FILEDLG
380 // Function which is called by quick sort. We want to override the default wxArrayString behaviour,
381 // and sort regardless of case.
382 static int wxCMPFUNC_CONV
wxDirCtrlStringCompareFunction(const wxString
& strFirst
, const wxString
& strSecond
)
384 return strFirst
.CmpNoCase(strSecond
);
387 //-----------------------------------------------------------------------------
389 //-----------------------------------------------------------------------------
391 wxDirItemData::wxDirItemData(const wxString
& path
, const wxString
& name
,
396 /* Insert logic to detect hidden files here
397 * In UnixLand we just check whether the first char is a dot
398 * For FileNameFromPath read LastDirNameInThisPath ;-) */
399 // m_isHidden = (bool)(wxFileNameFromPath(*m_path)[0] == '.');
401 m_isExpanded
= false;
405 void wxDirItemData::SetNewDirName(const wxString
& path
)
408 m_name
= wxFileNameFromPath(path
);
411 bool wxDirItemData::HasSubDirs() const
419 if ( !dir
.Open(m_path
) )
423 return dir
.HasSubDirs();
426 bool wxDirItemData::HasFiles(const wxString
& WXUNUSED(spec
)) const
434 if ( !dir
.Open(m_path
) )
438 return dir
.HasFiles();
441 //-----------------------------------------------------------------------------
443 //-----------------------------------------------------------------------------
445 BEGIN_EVENT_TABLE(wxGenericDirCtrl
, wxControl
)
446 EVT_TREE_ITEM_EXPANDING (wxID_TREECTRL
, wxGenericDirCtrl::OnExpandItem
)
447 EVT_TREE_ITEM_COLLAPSED (wxID_TREECTRL
, wxGenericDirCtrl::OnCollapseItem
)
448 EVT_TREE_BEGIN_LABEL_EDIT (wxID_TREECTRL
, wxGenericDirCtrl::OnBeginEditItem
)
449 EVT_TREE_END_LABEL_EDIT (wxID_TREECTRL
, wxGenericDirCtrl::OnEndEditItem
)
450 EVT_TREE_SEL_CHANGED (wxID_TREECTRL
, wxGenericDirCtrl::OnTreeSelChange
)
451 EVT_TREE_ITEM_ACTIVATED (wxID_TREECTRL
, wxGenericDirCtrl::OnItemActivated
)
452 EVT_SIZE (wxGenericDirCtrl::OnSize
)
455 wxGenericDirCtrl::wxGenericDirCtrl(void)
460 void wxGenericDirCtrl::ExpandRoot()
462 ExpandDir(m_rootId
); // automatically expand first level
464 // Expand and select the default path
465 if (!m_defaultPath
.empty())
467 ExpandPath(m_defaultPath
);
472 // On Unix, there's only one node under the (hidden) root node. It
473 // represents the / path, so the user would always have to expand it;
474 // let's do it ourselves
475 ExpandPath( wxT("/") );
480 bool wxGenericDirCtrl::Create(wxWindow
*parent
,
481 const wxWindowID treeid
,
486 const wxString
& filter
,
488 const wxString
& name
)
490 if (!wxControl::Create(parent
, treeid
, pos
, size
, style
, wxDefaultValidator
, name
))
493 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
));
494 SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
));
498 long treeStyle
= wxTR_HAS_BUTTONS
;
500 // On Windows CE, if you hide the root, you get a crash when
501 // attempting to access data for children of the root item.
503 treeStyle
|= wxTR_HIDE_ROOT
;
507 treeStyle
|= wxTR_NO_LINES
;
510 if (style
& wxDIRCTRL_EDIT_LABELS
)
511 treeStyle
|= wxTR_EDIT_LABELS
;
513 if (style
& wxDIRCTRL_MULTIPLE
)
514 treeStyle
|= wxTR_MULTIPLE
;
516 if ((style
& wxDIRCTRL_3D_INTERNAL
) == 0)
517 treeStyle
|= wxNO_BORDER
;
519 m_treeCtrl
= CreateTreeCtrl(this, wxID_TREECTRL
,
520 wxPoint(0,0), GetClientSize(), treeStyle
);
522 if (!filter
.empty() && (style
& wxDIRCTRL_SHOW_FILTERS
))
523 m_filterListCtrl
= new wxDirFilterListCtrl(this, wxID_FILTERLISTCTRL
);
528 if (m_filter
.empty())
529 m_filter
= wxFileSelectorDefaultWildcardStr
;
531 SetFilterIndex(defaultFilter
);
533 if (m_filterListCtrl
)
534 m_filterListCtrl
->FillFilterList(filter
, defaultFilter
);
536 m_treeCtrl
->SetImageList(wxTheFileIconsTable
->GetSmallImageList());
538 m_showHidden
= false;
539 wxDirItemData
* rootData
= new wxDirItemData(wxEmptyString
, wxEmptyString
, true);
543 #if defined(__WINDOWS__) || defined(__OS2__) || defined(__DOS__)
544 rootName
= _("Computer");
546 rootName
= _("Sections");
549 m_rootId
= m_treeCtrl
->AddRoot( rootName
, 3, -1, rootData
);
550 m_treeCtrl
->SetItemHasChildren(m_rootId
);
554 SetInitialSize(size
);
560 wxGenericDirCtrl::~wxGenericDirCtrl()
564 void wxGenericDirCtrl::Init()
566 m_showHidden
= false;
568 m_currentFilterStr
= wxEmptyString
; // Default: any file
570 m_filterListCtrl
= NULL
;
573 wxTreeCtrl
* wxGenericDirCtrl::CreateTreeCtrl(wxWindow
*parent
, wxWindowID treeid
, const wxPoint
& pos
, const wxSize
& size
, long treeStyle
)
575 return new wxTreeCtrl(parent
, treeid
, pos
, size
, treeStyle
);
578 void wxGenericDirCtrl::ShowHidden( bool show
)
580 if ( m_showHidden
== show
)
585 if ( HasFlag(wxDIRCTRL_MULTIPLE
) )
590 for ( unsigned n
= 0; n
< paths
.size(); n
++ )
592 ExpandPath(paths
[n
]);
597 wxString path
= GetPath();
604 wxGenericDirCtrl::AddSection(const wxString
& path
, const wxString
& name
, int imageId
)
606 wxDirItemData
*dir_item
= new wxDirItemData(path
,name
,true);
608 wxTreeItemId treeid
= AppendItem( m_rootId
, name
, imageId
, -1, dir_item
);
610 m_treeCtrl
->SetItemHasChildren(treeid
);
615 void wxGenericDirCtrl::SetupSections()
617 wxArrayString paths
, names
;
620 size_t n
, count
= wxGetAvailableDrives(paths
, names
, icons
);
623 wxString home
= wxGetHomeDir();
624 AddSection( home
, _("Home directory"), 1);
625 home
+= wxT("/Desktop");
626 AddSection( home
, _("Desktop"), 1);
629 for (n
= 0; n
< count
; n
++)
630 AddSection(paths
[n
], names
[n
], icons
[n
]);
633 void wxGenericDirCtrl::SetFocus()
635 // we don't need focus ourselves, give it to the tree so that the user
638 m_treeCtrl
->SetFocus();
641 void wxGenericDirCtrl::OnBeginEditItem(wxTreeEvent
&event
)
643 // don't rename the main entry "Sections"
644 if (event
.GetItem() == m_rootId
)
650 // don't rename the individual sections
651 if (m_treeCtrl
->GetItemParent( event
.GetItem() ) == m_rootId
)
658 void wxGenericDirCtrl::OnEndEditItem(wxTreeEvent
&event
)
660 if (event
.IsEditCancelled())
663 if ((event
.GetLabel().empty()) ||
664 (event
.GetLabel() == wxT(".")) ||
665 (event
.GetLabel() == wxT("..")) ||
666 (event
.GetLabel().Find(wxT('/')) != wxNOT_FOUND
) ||
667 (event
.GetLabel().Find(wxT('\\')) != wxNOT_FOUND
) ||
668 (event
.GetLabel().Find(wxT('|')) != wxNOT_FOUND
))
670 wxMessageDialog
dialog(this, _("Illegal directory name."), _("Error"), wxOK
| wxICON_ERROR
);
676 wxTreeItemId treeid
= event
.GetItem();
677 wxDirItemData
*data
= GetItemData( treeid
);
680 wxString
new_name( wxPathOnly( data
->m_path
) );
681 new_name
+= wxString(wxFILE_SEP_PATH
);
682 new_name
+= event
.GetLabel();
686 if (wxFileExists(new_name
))
688 wxMessageDialog
dialog(this, _("File name exists already."), _("Error"), wxOK
| wxICON_ERROR
);
693 if (wxRenameFile(data
->m_path
,new_name
))
695 data
->SetNewDirName( new_name
);
699 wxMessageDialog
dialog(this, _("Operation not permitted."), _("Error"), wxOK
| wxICON_ERROR
);
705 void wxGenericDirCtrl::OnTreeSelChange(wxTreeEvent
&event
)
707 wxTreeEvent
changedEvent(wxEVT_DIRCTRL_SELECTIONCHANGED
, GetId());
709 changedEvent
.SetEventObject(this);
710 changedEvent
.SetItem(event
.GetItem());
711 changedEvent
.SetClientObject(m_treeCtrl
->GetItemData(event
.GetItem()));
713 if (GetEventHandler()->SafelyProcessEvent(changedEvent
) && !changedEvent
.IsAllowed())
719 void wxGenericDirCtrl::OnItemActivated(wxTreeEvent
&event
)
721 wxTreeItemId treeid
= event
.GetItem();
722 const wxDirItemData
*data
= GetItemData(treeid
);
732 wxTreeEvent
changedEvent(wxEVT_DIRCTRL_FILEACTIVATED
, GetId());
734 changedEvent
.SetEventObject(this);
735 changedEvent
.SetItem(treeid
);
736 changedEvent
.SetClientObject(m_treeCtrl
->GetItemData(treeid
));
738 if (GetEventHandler()->SafelyProcessEvent(changedEvent
) && !changedEvent
.IsAllowed())
745 void wxGenericDirCtrl::OnExpandItem(wxTreeEvent
&event
)
747 wxTreeItemId parentId
= event
.GetItem();
749 // VS: this is needed because the event handler is called from wxTreeCtrl
750 // ctor when wxTR_HIDE_ROOT was specified
752 if (!m_rootId
.IsOk())
753 m_rootId
= m_treeCtrl
->GetRootItem();
758 void wxGenericDirCtrl::OnCollapseItem(wxTreeEvent
&event
)
760 CollapseDir(event
.GetItem());
763 void wxGenericDirCtrl::CollapseDir(wxTreeItemId parentId
)
767 wxDirItemData
*data
= GetItemData(parentId
);
768 if (!data
->m_isExpanded
)
771 data
->m_isExpanded
= false;
773 m_treeCtrl
->Freeze();
774 if (parentId
!= m_treeCtrl
->GetRootItem())
775 m_treeCtrl
->CollapseAndReset(parentId
);
776 m_treeCtrl
->DeleteChildren(parentId
);
780 void wxGenericDirCtrl::PopulateNode(wxTreeItemId parentId
)
782 wxDirItemData
*data
= GetItemData(parentId
);
784 if (data
->m_isExpanded
)
787 data
->m_isExpanded
= true;
789 if (parentId
== m_treeCtrl
->GetRootItem())
797 wxString search
,path
,filename
;
799 wxString
dirName(data
->m_path
);
801 #if (defined(__WINDOWS__) && !defined(__WXWINCE__)) || defined(__DOS__) || defined(__OS2__)
802 // Check if this is a root directory and if so,
803 // whether the drive is avaiable.
804 if (!wxIsDriveAvailable(dirName
))
806 data
->m_isExpanded
= false;
807 //wxMessageBox(wxT("Sorry, this drive is not available."));
812 // This may take a longish time. Go to busy cursor
815 #if defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__)
816 if (dirName
.Last() == ':')
817 dirName
+= wxString(wxFILE_SEP_PATH
);
821 wxArrayString filenames
;
824 wxString eachFilename
;
831 int style
= wxDIR_DIRS
;
832 if (m_showHidden
) style
|= wxDIR_HIDDEN
;
833 if (d
.GetFirst(& eachFilename
, wxEmptyString
, style
))
837 if ((eachFilename
!= wxT(".")) && (eachFilename
!= wxT("..")))
839 dirs
.Add(eachFilename
);
842 while (d
.GetNext(&eachFilename
));
845 dirs
.Sort(wxDirCtrlStringCompareFunction
);
847 // Now do the filenames -- but only if we're allowed to
848 if (!HasFlag(wxDIRCTRL_DIR_ONLY
))
854 int style
= wxDIR_FILES
;
855 if (m_showHidden
) style
|= wxDIR_HIDDEN
;
856 // Process each filter (ex: "JPEG Files (*.jpg;*.jpeg)|*.jpg;*.jpeg")
857 wxStringTokenizer strTok
;
859 strTok
.SetString(m_currentFilterStr
,wxT(";"));
860 while(strTok
.HasMoreTokens())
862 curFilter
= strTok
.GetNextToken();
863 if (d
.GetFirst(& eachFilename
, curFilter
, style
))
867 if ((eachFilename
!= wxT(".")) && (eachFilename
!= wxT("..")))
869 filenames
.Add(eachFilename
);
872 while (d
.GetNext(& eachFilename
));
876 filenames
.Sort(wxDirCtrlStringCompareFunction
);
879 // Now we really know whether we have any children so tell the tree control
881 m_treeCtrl
->SetItemHasChildren(parentId
, !dirs
.empty() || !filenames
.empty());
883 // Add the sorted dirs
885 for (i
= 0; i
< dirs
.GetCount(); i
++)
887 eachFilename
= dirs
[i
];
889 if (!wxEndsWithPathSeparator(path
))
890 path
+= wxString(wxFILE_SEP_PATH
);
891 path
+= eachFilename
;
893 wxDirItemData
*dir_item
= new wxDirItemData(path
,eachFilename
,true);
894 wxTreeItemId treeid
= AppendItem( parentId
, eachFilename
,
895 wxFileIconsTable::folder
, -1, dir_item
);
896 m_treeCtrl
->SetItemImage( treeid
, wxFileIconsTable::folder_open
,
897 wxTreeItemIcon_Expanded
);
899 // assume that it does have children by default as it can take a long
900 // time to really check for this (think remote drives...)
902 // and if we're wrong, we'll correct the icon later if
903 // the user really tries to open this item
904 m_treeCtrl
->SetItemHasChildren(treeid
);
907 // Add the sorted filenames
908 if (!HasFlag(wxDIRCTRL_DIR_ONLY
))
910 for (i
= 0; i
< filenames
.GetCount(); i
++)
912 eachFilename
= filenames
[i
];
914 if (!wxEndsWithPathSeparator(path
))
915 path
+= wxString(wxFILE_SEP_PATH
);
916 path
+= eachFilename
;
917 //path = dirName + wxString(wxT("/")) + eachFilename;
918 wxDirItemData
*dir_item
= new wxDirItemData(path
,eachFilename
,false);
919 int image_id
= wxFileIconsTable::file
;
920 if (eachFilename
.Find(wxT('.')) != wxNOT_FOUND
)
921 image_id
= wxTheFileIconsTable
->GetIconID(eachFilename
.AfterLast(wxT('.')));
922 (void) AppendItem( parentId
, eachFilename
, image_id
, -1, dir_item
);
927 void wxGenericDirCtrl::ExpandDir(wxTreeItemId parentId
)
929 // ExpandDir() will not actually expand the tree node, just populate it
930 PopulateNode(parentId
);
933 void wxGenericDirCtrl::ReCreateTree()
935 CollapseDir(m_treeCtrl
->GetRootItem());
939 void wxGenericDirCtrl::CollapseTree()
941 wxTreeItemIdValue cookie
;
942 wxTreeItemId child
= m_treeCtrl
->GetFirstChild(m_rootId
, cookie
);
946 child
= m_treeCtrl
->GetNextChild(m_rootId
, cookie
);
950 // Find the child that matches the first part of 'path'.
951 // E.g. if a child path is "/usr" and 'path' is "/usr/include"
952 // then the child for /usr is returned.
953 wxTreeItemId
wxGenericDirCtrl::FindChild(wxTreeItemId parentId
, const wxString
& path
, bool& done
)
955 wxString
path2(path
);
957 // Make sure all separators are as per the current platform
958 path2
.Replace(wxT("\\"), wxString(wxFILE_SEP_PATH
));
959 path2
.Replace(wxT("/"), wxString(wxFILE_SEP_PATH
));
961 // Append a separator to foil bogus substring matching
962 path2
+= wxString(wxFILE_SEP_PATH
);
964 // In MSW or PM, case is not significant
965 #if defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__)
969 wxTreeItemIdValue cookie
;
970 wxTreeItemId childId
= m_treeCtrl
->GetFirstChild(parentId
, cookie
);
971 while (childId
.IsOk())
973 wxDirItemData
* data
= GetItemData(childId
);
975 if (data
&& !data
->m_path
.empty())
977 wxString
childPath(data
->m_path
);
978 if (!wxEndsWithPathSeparator(childPath
))
979 childPath
+= wxString(wxFILE_SEP_PATH
);
981 // In MSW and PM, case is not significant
982 #if defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__)
983 childPath
.MakeLower();
986 if (childPath
.length() <= path2
.length())
988 wxString path3
= path2
.Mid(0, childPath
.length());
989 if (childPath
== path3
)
991 if (path3
.length() == path2
.length())
1000 childId
= m_treeCtrl
->GetNextChild(parentId
, cookie
);
1002 wxTreeItemId invalid
;
1006 // Try to expand as much of the given path as possible,
1007 // and select the given tree item.
1008 bool wxGenericDirCtrl::ExpandPath(const wxString
& path
)
1011 wxTreeItemId treeid
= FindChild(m_rootId
, path
, done
);
1012 wxTreeItemId lastId
= treeid
; // The last non-zero treeid
1013 while (treeid
.IsOk() && !done
)
1017 treeid
= FindChild(treeid
, path
, done
);
1024 wxDirItemData
*data
= GetItemData(lastId
);
1027 m_treeCtrl
->Expand(lastId
);
1029 if (HasFlag(wxDIRCTRL_SELECT_FIRST
) && data
->m_isDir
)
1031 // Find the first file in this directory
1032 wxTreeItemIdValue cookie
;
1033 wxTreeItemId childId
= m_treeCtrl
->GetFirstChild(lastId
, cookie
);
1034 bool selectedChild
= false;
1035 while (childId
.IsOk())
1037 data
= GetItemData(childId
);
1039 if (data
&& data
->m_path
!= wxEmptyString
&& !data
->m_isDir
)
1041 m_treeCtrl
->SelectItem(childId
);
1042 m_treeCtrl
->EnsureVisible(childId
);
1043 selectedChild
= true;
1046 childId
= m_treeCtrl
->GetNextChild(lastId
, cookie
);
1050 m_treeCtrl
->SelectItem(lastId
);
1051 m_treeCtrl
->EnsureVisible(lastId
);
1056 m_treeCtrl
->SelectItem(lastId
);
1057 m_treeCtrl
->EnsureVisible(lastId
);
1064 bool wxGenericDirCtrl::CollapsePath(const wxString
& path
)
1067 wxTreeItemId treeid
= FindChild(m_rootId
, path
, done
);
1068 wxTreeItemId lastId
= treeid
; // The last non-zero treeid
1070 while ( treeid
.IsOk() && !done
)
1072 CollapseDir(treeid
);
1074 treeid
= FindChild(treeid
, path
, done
);
1076 if ( treeid
.IsOk() )
1080 if ( !lastId
.IsOk() )
1083 m_treeCtrl
->SelectItem(lastId
);
1084 m_treeCtrl
->EnsureVisible(lastId
);
1089 wxDirItemData
* wxGenericDirCtrl::GetItemData(wxTreeItemId itemId
)
1091 return static_cast<wxDirItemData
*>(m_treeCtrl
->GetItemData(itemId
));
1094 wxString
wxGenericDirCtrl::GetPath(wxTreeItemId itemId
) const
1096 const wxDirItemData
*
1097 data
= static_cast<wxDirItemData
*>(m_treeCtrl
->GetItemData(itemId
));
1099 return data
->m_path
;
1102 wxString
wxGenericDirCtrl::GetPath() const
1104 // Allow calling GetPath() in multiple selection from OnSelFilter
1105 if (m_treeCtrl
->HasFlag(wxTR_MULTIPLE
))
1107 wxArrayTreeItemIds items
;
1108 m_treeCtrl
->GetSelections(items
);
1109 if (items
.size() > 0)
1111 // return first string only
1112 wxTreeItemId treeid
= items
[0];
1113 return GetPath(treeid
);
1116 return wxEmptyString
;
1119 wxTreeItemId treeid
= m_treeCtrl
->GetSelection();
1122 return GetPath(treeid
);
1125 return wxEmptyString
;
1128 void wxGenericDirCtrl::GetPaths(wxArrayString
& paths
) const
1132 wxArrayTreeItemIds items
;
1133 m_treeCtrl
->GetSelections(items
);
1134 for ( unsigned n
= 0; n
< items
.size(); n
++ )
1136 wxTreeItemId treeid
= items
[n
];
1137 paths
.push_back(GetPath(treeid
));
1141 wxString
wxGenericDirCtrl::GetFilePath() const
1143 wxTreeItemId treeid
= m_treeCtrl
->GetSelection();
1146 wxDirItemData
* data
= (wxDirItemData
*) m_treeCtrl
->GetItemData(treeid
);
1148 return wxEmptyString
;
1150 return data
->m_path
;
1153 return wxEmptyString
;
1156 void wxGenericDirCtrl::GetFilePaths(wxArrayString
& paths
) const
1160 wxArrayTreeItemIds items
;
1161 m_treeCtrl
->GetSelections(items
);
1162 for ( unsigned n
= 0; n
< items
.size(); n
++ )
1164 wxTreeItemId treeid
= items
[n
];
1165 wxDirItemData
* data
= (wxDirItemData
*) m_treeCtrl
->GetItemData(treeid
);
1166 if ( !data
->m_isDir
)
1167 paths
.Add(data
->m_path
);
1171 void wxGenericDirCtrl::SetPath(const wxString
& path
)
1173 m_defaultPath
= path
;
1178 void wxGenericDirCtrl::SelectPath(const wxString
& path
, bool select
)
1181 wxTreeItemId treeid
= FindChild(m_rootId
, path
, done
);
1182 wxTreeItemId lastId
= treeid
; // The last non-zero treeid
1183 while ( treeid
.IsOk() && !done
)
1185 treeid
= FindChild(treeid
, path
, done
);
1186 if ( treeid
.IsOk() )
1189 if ( !lastId
.IsOk() )
1194 m_treeCtrl
->SelectItem(treeid
, select
);
1198 void wxGenericDirCtrl::SelectPaths(const wxArrayString
& paths
)
1200 if ( HasFlag(wxDIRCTRL_MULTIPLE
) )
1203 for ( unsigned n
= 0; n
< paths
.size(); n
++ )
1205 SelectPath(paths
[n
]);
1210 void wxGenericDirCtrl::UnselectAll()
1212 m_treeCtrl
->UnselectAll();
1217 void wxGenericDirCtrl::FindChildFiles(wxTreeItemId treeid
, int dirFlags
, wxArrayString
& filenames
)
1219 wxDirItemData
*data
= (wxDirItemData
*) m_treeCtrl
->GetItemData(treeid
);
1221 // This may take a longish time. Go to busy cursor
1226 wxString search
,path
,filename
;
1228 wxString
dirName(data
->m_path
);
1230 #if defined(__WINDOWS__) || defined(__OS2__)
1231 if (dirName
.Last() == ':')
1232 dirName
+= wxString(wxFILE_SEP_PATH
);
1236 wxString eachFilename
;
1243 if (d
.GetFirst(& eachFilename
, m_currentFilterStr
, dirFlags
))
1247 if ((eachFilename
!= wxT(".")) && (eachFilename
!= wxT("..")))
1249 filenames
.Add(eachFilename
);
1252 while (d
.GetNext(& eachFilename
)) ;
1258 void wxGenericDirCtrl::SetFilterIndex(int n
)
1260 m_currentFilter
= n
;
1263 if (ExtractWildcard(m_filter
, n
, f
, d
))
1264 m_currentFilterStr
= f
;
1267 m_currentFilterStr
= wxT("*");
1269 m_currentFilterStr
= wxT("*.*");
1273 void wxGenericDirCtrl::SetFilter(const wxString
& filter
)
1277 if (!filter
.empty() && !m_filterListCtrl
&& HasFlag(wxDIRCTRL_SHOW_FILTERS
))
1278 m_filterListCtrl
= new wxDirFilterListCtrl(this, wxID_FILTERLISTCTRL
);
1279 else if (filter
.empty() && m_filterListCtrl
)
1281 m_filterListCtrl
->Destroy();
1282 m_filterListCtrl
= NULL
;
1286 if (ExtractWildcard(m_filter
, m_currentFilter
, f
, d
))
1287 m_currentFilterStr
= f
;
1290 m_currentFilterStr
= wxT("*");
1292 m_currentFilterStr
= wxT("*.*");
1294 // current filter index is meaningless after filter change, set it to zero
1296 if (m_filterListCtrl
)
1297 m_filterListCtrl
->FillFilterList(m_filter
, 0);
1300 // Extract description and actual filter from overall filter string
1301 bool wxGenericDirCtrl::ExtractWildcard(const wxString
& filterStr
, int n
, wxString
& filter
, wxString
& description
)
1303 wxArrayString filters
, descriptions
;
1304 int count
= wxParseCommonDialogsFilter(filterStr
, descriptions
, filters
);
1305 if (count
> 0 && n
< count
)
1307 filter
= filters
[n
];
1308 description
= descriptions
[n
];
1316 void wxGenericDirCtrl::DoResize()
1318 wxSize sz
= GetClientSize();
1319 int verticalSpacing
= 3;
1323 if (m_filterListCtrl
)
1325 filterSz
= m_filterListCtrl
->GetSize();
1326 sz
.y
-= (filterSz
.y
+ verticalSpacing
);
1328 m_treeCtrl
->SetSize(0, 0, sz
.x
, sz
.y
);
1329 if (m_filterListCtrl
)
1331 m_filterListCtrl
->SetSize(0, sz
.y
+ verticalSpacing
, sz
.x
, filterSz
.y
);
1332 // Don't know why, but this needs refreshing after a resize (wxMSW)
1333 m_filterListCtrl
->Refresh();
1339 void wxGenericDirCtrl::OnSize(wxSizeEvent
& WXUNUSED(event
))
1344 wxTreeItemId
wxGenericDirCtrl::AppendItem (const wxTreeItemId
& parent
,
1345 const wxString
& text
,
1346 int image
, int selectedImage
,
1347 wxTreeItemData
* data
)
1349 wxTreeCtrl
*treeCtrl
= GetTreeCtrl ();
1351 wxASSERT (treeCtrl
);
1355 return treeCtrl
->AppendItem (parent
, text
, image
, selectedImage
, data
);
1359 return wxTreeItemId();
1364 //-----------------------------------------------------------------------------
1365 // wxDirFilterListCtrl
1366 //-----------------------------------------------------------------------------
1368 IMPLEMENT_CLASS(wxDirFilterListCtrl
, wxChoice
)
1370 BEGIN_EVENT_TABLE(wxDirFilterListCtrl
, wxChoice
)
1371 EVT_CHOICE(wxID_ANY
, wxDirFilterListCtrl::OnSelFilter
)
1374 bool wxDirFilterListCtrl::Create(wxGenericDirCtrl
* parent
,
1375 const wxWindowID treeid
,
1382 // by default our border style is determined by the style of our parent
1383 if ( !(style
& wxBORDER_MASK
) )
1385 style
|= parent
->HasFlag(wxDIRCTRL_3D_INTERNAL
) ? wxBORDER_SUNKEN
1389 return wxChoice::Create(parent
, treeid
, pos
, size
, 0, NULL
, style
);
1392 void wxDirFilterListCtrl::Init()
1397 void wxDirFilterListCtrl::OnSelFilter(wxCommandEvent
& WXUNUSED(event
))
1399 int sel
= GetSelection();
1401 if (m_dirCtrl
->HasFlag(wxDIRCTRL_MULTIPLE
))
1403 wxArrayString paths
;
1404 m_dirCtrl
->GetPaths(paths
);
1406 m_dirCtrl
->SetFilterIndex(sel
);
1408 // If the filter has changed, the view is out of date, so
1409 // collapse the tree.
1410 m_dirCtrl
->ReCreateTree();
1412 // Expand and select the previously selected paths
1413 for (unsigned int i
= 0; i
< paths
.GetCount(); i
++)
1415 m_dirCtrl
->ExpandPath(paths
.Item(i
));
1420 wxString currentPath
= m_dirCtrl
->GetPath();
1422 m_dirCtrl
->SetFilterIndex(sel
);
1423 m_dirCtrl
->ReCreateTree();
1425 // Try to restore the selection, or at least the directory
1426 m_dirCtrl
->ExpandPath(currentPath
);
1430 void wxDirFilterListCtrl::FillFilterList(const wxString
& filter
, int defaultFilter
)
1433 wxArrayString descriptions
, filters
;
1434 size_t n
= (size_t) wxParseCommonDialogsFilter(filter
, descriptions
, filters
);
1436 if (n
> 0 && defaultFilter
< (int) n
)
1438 for (size_t i
= 0; i
< n
; i
++)
1439 Append(descriptions
[i
]);
1440 SetSelection(defaultFilter
);
1443 #endif // wxUSE_DIRDLG
1445 #if wxUSE_DIRDLG || wxUSE_FILEDLG
1447 // ----------------------------------------------------------------------------
1448 // wxFileIconsTable icons
1449 // ----------------------------------------------------------------------------
1452 /* Computer (c) Julian Smart */
1453 static const char* const file_icons_tbl_computer_xpm
[] = {
1454 /* columns rows colors chars-per-pixel */
1518 // ----------------------------------------------------------------------------
1519 // wxFileIconsTable & friends
1520 // ----------------------------------------------------------------------------
1522 // global instance of a wxFileIconsTable
1523 wxFileIconsTable
* wxTheFileIconsTable
= NULL
;
1525 // A module to allow icons table cleanup
1527 class wxFileIconsTableModule
: public wxModule
1529 DECLARE_DYNAMIC_CLASS(wxFileIconsTableModule
)
1531 wxFileIconsTableModule() {}
1532 bool OnInit() { wxTheFileIconsTable
= new wxFileIconsTable
; return true; }
1535 wxDELETE(wxTheFileIconsTable
);
1539 IMPLEMENT_DYNAMIC_CLASS(wxFileIconsTableModule
, wxModule
)
1541 class wxFileIconEntry
: public wxObject
1544 wxFileIconEntry(int i
) { iconid
= i
; }
1549 wxFileIconsTable::wxFileIconsTable()
1552 m_smallImageList
= NULL
;
1555 wxFileIconsTable::~wxFileIconsTable()
1559 WX_CLEAR_HASH_TABLE(*m_HashTable
);
1562 if (m_smallImageList
) delete m_smallImageList
;
1565 // delayed initialization - wait until first use (wxArtProv not created yet)
1566 void wxFileIconsTable::Create()
1568 wxCHECK_RET(!m_smallImageList
&& !m_HashTable
, wxT("creating icons twice"));
1569 m_HashTable
= new wxHashTable(wxKEY_STRING
);
1570 m_smallImageList
= new wxImageList(16, 16);
1573 m_smallImageList
->Add(wxArtProvider::GetBitmap(wxART_FOLDER
,
1577 m_smallImageList
->Add(wxArtProvider::GetBitmap(wxART_FOLDER_OPEN
,
1582 // GTK24 uses this icon in the file open dialog
1583 m_smallImageList
->Add(wxArtProvider::GetBitmap(wxART_HARDDISK
,
1587 m_smallImageList
->Add(wxIcon(file_icons_tbl_computer_xpm
));
1590 m_smallImageList
->Add(wxArtProvider::GetBitmap(wxART_HARDDISK
,
1594 m_smallImageList
->Add(wxArtProvider::GetBitmap(wxART_CDROM
,
1598 m_smallImageList
->Add(wxArtProvider::GetBitmap(wxART_FLOPPY
,
1602 m_smallImageList
->Add(wxArtProvider::GetBitmap(wxART_REMOVABLE
,
1606 m_smallImageList
->Add(wxArtProvider::GetBitmap(wxART_NORMAL_FILE
,
1610 if (GetIconID(wxEmptyString
, wxT("application/x-executable")) == file
)
1612 m_smallImageList
->Add(wxArtProvider::GetBitmap(wxART_EXECUTABLE_FILE
,
1615 delete m_HashTable
->Get(wxT("exe"));
1616 m_HashTable
->Delete(wxT("exe"));
1617 m_HashTable
->Put(wxT("exe"), new wxFileIconEntry(executable
));
1619 /* else put into list by GetIconID
1620 (KDE defines application/x-executable for *.exe and has nice icon)
1624 wxImageList
*wxFileIconsTable::GetSmallImageList()
1626 if (!m_smallImageList
)
1629 return m_smallImageList
;
1632 #if wxUSE_MIMETYPE && wxUSE_IMAGE && (!defined(__WINDOWS__) || wxUSE_WXDIB)
1633 // VS: we don't need this function w/o wxMimeTypesManager because we'll only have
1634 // one icon and we won't resize it
1636 static wxBitmap
CreateAntialiasedBitmap(const wxImage
& img
)
1638 const unsigned int size
= 16;
1640 wxImage
smallimg (size
, size
);
1641 unsigned char *p1
, *p2
, *ps
;
1642 unsigned char mr
= img
.GetMaskRed(),
1643 mg
= img
.GetMaskGreen(),
1644 mb
= img
.GetMaskBlue();
1647 unsigned sr
, sg
, sb
, smask
;
1649 p1
= img
.GetData(), p2
= img
.GetData() + 3 * size
*2, ps
= smallimg
.GetData();
1650 smallimg
.SetMaskColour(mr
, mr
, mr
);
1652 for (y
= 0; y
< size
; y
++)
1654 for (x
= 0; x
< size
; x
++)
1656 sr
= sg
= sb
= smask
= 0;
1657 if (p1
[0] != mr
|| p1
[1] != mg
|| p1
[2] != mb
)
1658 sr
+= p1
[0], sg
+= p1
[1], sb
+= p1
[2];
1661 if (p1
[0] != mr
|| p1
[1] != mg
|| p1
[2] != mb
)
1662 sr
+= p1
[0], sg
+= p1
[1], sb
+= p1
[2];
1665 if (p2
[0] != mr
|| p2
[1] != mg
|| p2
[2] != mb
)
1666 sr
+= p2
[0], sg
+= p2
[1], sb
+= p2
[2];
1669 if (p2
[0] != mr
|| p2
[1] != mg
|| p2
[2] != mb
)
1670 sr
+= p2
[0], sg
+= p2
[1], sb
+= p2
[2];
1675 ps
[0] = ps
[1] = ps
[2] = mr
;
1678 ps
[0] = (unsigned char)(sr
>> 2);
1679 ps
[1] = (unsigned char)(sg
>> 2);
1680 ps
[2] = (unsigned char)(sb
>> 2);
1684 p1
+= size
*2 * 3, p2
+= size
*2 * 3;
1687 return wxBitmap(smallimg
);
1690 // This function is currently not unused anymore
1692 // finds empty borders and return non-empty area of image:
1693 static wxImage
CutEmptyBorders(const wxImage
& img
)
1695 unsigned char mr
= img
.GetMaskRed(),
1696 mg
= img
.GetMaskGreen(),
1697 mb
= img
.GetMaskBlue();
1698 unsigned char *dt
= img
.GetData(), *dttmp
;
1699 unsigned w
= img
.GetWidth(), h
= img
.GetHeight();
1701 unsigned top
, bottom
, left
, right
, i
;
1704 #define MK_DTTMP(x,y) dttmp = dt + ((x + y * w) * 3)
1705 #define NOEMPTY_PIX(empt) if (dttmp[0] != mr || dttmp[1] != mg || dttmp[2] != mb) {empt = false; break;}
1707 for (empt
= true, top
= 0; empt
&& top
< h
; top
++)
1710 for (i
= 0; i
< w
; i
++, dttmp
+=3)
1713 for (empt
= true, bottom
= h
-1; empt
&& bottom
> top
; bottom
--)
1715 MK_DTTMP(0, bottom
);
1716 for (i
= 0; i
< w
; i
++, dttmp
+=3)
1719 for (empt
= true, left
= 0; empt
&& left
< w
; left
++)
1722 for (i
= 0; i
< h
; i
++, dttmp
+=3*w
)
1725 for (empt
= true, right
= w
-1; empt
&& right
> left
; right
--)
1728 for (i
= 0; i
< h
; i
++, dttmp
+=3*w
)
1731 top
--, left
--, bottom
++, right
++;
1733 return img
.GetSubImage(wxRect(left
, top
, right
- left
+ 1, bottom
- top
+ 1));
1737 #endif // wxUSE_MIMETYPE
1739 int wxFileIconsTable::GetIconID(const wxString
& extension
, const wxString
& mime
)
1741 if (!m_smallImageList
)
1745 if (!extension
.empty())
1747 wxFileIconEntry
*entry
= (wxFileIconEntry
*) m_HashTable
->Get(extension
);
1748 if (entry
) return (entry
-> iconid
);
1751 wxFileType
*ft
= (mime
.empty()) ?
1752 wxTheMimeTypesManager
-> GetFileTypeFromExtension(extension
) :
1753 wxTheMimeTypesManager
-> GetFileTypeFromMimeType(mime
);
1755 wxIconLocation iconLoc
;
1760 if ( ft
&& ft
->GetIcon(&iconLoc
) )
1762 ic
= wxIcon( iconLoc
);
1771 m_HashTable
->Put(extension
, new wxFileIconEntry(newid
));
1776 bmp
.CopyFromIcon(ic
);
1781 m_HashTable
->Put(extension
, new wxFileIconEntry(newid
));
1785 const unsigned int size
= 16;
1787 int treeid
= m_smallImageList
->GetImageCount();
1788 if ((bmp
.GetWidth() == (int) size
) && (bmp
.GetHeight() == (int) size
))
1790 m_smallImageList
->Add(bmp
);
1792 #if wxUSE_IMAGE && (!defined(__WINDOWS__) || wxUSE_WXDIB)
1795 wxImage img
= bmp
.ConvertToImage();
1797 if ((img
.GetWidth() != size
*2) || (img
.GetHeight() != size
*2))
1798 // m_smallImageList->Add(CreateAntialiasedBitmap(CutEmptyBorders(img).Rescale(size*2, size*2)));
1799 m_smallImageList
->Add(CreateAntialiasedBitmap(img
.Rescale(size
*2, size
*2)));
1801 m_smallImageList
->Add(CreateAntialiasedBitmap(img
));
1803 #endif // wxUSE_IMAGE
1805 m_HashTable
->Put(extension
, new wxFileIconEntry(treeid
));
1808 #else // !wxUSE_MIMETYPE
1811 if (extension
== wxT("exe"))
1815 #endif // wxUSE_MIMETYPE/!wxUSE_MIMETYPE
1818 #endif // wxUSE_DIRDLG || wxUSE_FILEDLG