1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/generic/dirctrlg.cpp
3 // Purpose: wxGenericDirCtrl
4 // Author: Harm van der Heijden, Robert Roebling, Julian Smart
8 // Copyright: (c) Harm van der Heijden, Robert Roebling and Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
19 #if wxUSE_DIRDLG || wxUSE_FILEDLG
21 #include "wx/generic/dirctrlg.h"
28 #include "wx/button.h"
30 #include "wx/settings.h"
31 #include "wx/msgdlg.h"
32 #include "wx/choice.h"
33 #include "wx/textctrl.h"
34 #include "wx/layout.h"
36 #include "wx/textdlg.h"
37 #include "wx/gdicmn.h"
39 #include "wx/module.h"
42 #include "wx/filename.h"
43 #include "wx/filefn.h"
44 #include "wx/imaglist.h"
45 #include "wx/tokenzr.h"
47 #include "wx/artprov.h"
48 #include "wx/mimetype.h"
51 #include "wx/statline.h"
54 #if defined(__WXMAC__)
55 #include "wx/osx/private.h" // includes mac headers
60 #include "wx/msw/winundef.h"
61 #include "wx/volume.h"
63 // FIXME - Mingw32 1.0 has both _getdrive() and _chdrive(). For now, let's assume
64 // older releases don't, but it should be verified and the checks modified
66 #if !defined(__GNUWIN32__) || (defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 1)
67 #if !defined(__WXWINCE__)
76 #if defined(__OS2__) || defined(__DOS__)
88 #if defined(__WXMAC__)
89 // #include "MoreFilesX.h"
96 extern WXDLLEXPORT_DATA(const char) wxFileSelectorDefaultWildcardStr
[];
98 // If compiled under Windows, this macro can cause problems
103 bool wxIsDriveAvailable(const wxString
& dirName
);
105 // ----------------------------------------------------------------------------
107 // ----------------------------------------------------------------------------
109 wxDEFINE_EVENT( wxEVT_DIRCTRL_SELECTIONCHANGED
, wxTreeEvent
);
110 wxDEFINE_EVENT( wxEVT_DIRCTRL_FILEACTIVATED
, wxTreeEvent
);
112 // ----------------------------------------------------------------------------
113 // wxGetAvailableDrives, for WINDOWS, DOS, OS2, MAC, UNIX (returns "/")
114 // ----------------------------------------------------------------------------
116 size_t wxGetAvailableDrives(wxArrayString
&paths
, wxArrayString
&names
, wxArrayInt
&icon_ids
)
118 #ifdef wxHAS_FILESYSTEM_VOLUMES
121 // No logical drives; return "\"
122 paths
.Add(wxT("\\"));
123 names
.Add(wxT("\\"));
124 icon_ids
.Add(wxFileIconsTable::computer
);
125 #elif defined(__WIN32__) && wxUSE_FSVOLUME
126 // TODO: this code (using wxFSVolumeBase) should be used for all platforms
127 // but unfortunately wxFSVolumeBase is not implemented everywhere
128 const wxArrayString as
= wxFSVolumeBase::GetVolumes();
130 for (size_t i
= 0; i
< as
.GetCount(); i
++)
132 wxString path
= as
[i
];
133 wxFSVolume
vol(path
);
135 switch (vol
.GetKind())
137 case wxFS_VOL_FLOPPY
:
138 if ( (path
== wxT("a:\\")) || (path
== wxT("b:\\")) )
139 imageId
= wxFileIconsTable::floppy
;
141 imageId
= wxFileIconsTable::removeable
;
143 case wxFS_VOL_DVDROM
:
145 imageId
= wxFileIconsTable::cdrom
;
147 case wxFS_VOL_NETWORK
:
148 if (path
[0] == wxT('\\'))
149 continue; // skip "\\computer\folder"
150 imageId
= wxFileIconsTable::drive
;
155 imageId
= wxFileIconsTable::drive
;
159 names
.Add(vol
.GetDisplayName());
160 icon_ids
.Add(imageId
);
162 #elif defined(__OS2__)
164 ULONG ulDriveNum
= 0;
165 ULONG ulDriveMap
= 0;
166 rc
= ::DosQueryCurrentDisk(&ulDriveNum
, &ulDriveMap
);
172 if (ulDriveMap
& ( 1 << i
))
174 const wxString path
= wxFileName::GetVolumeString(
175 'A' + i
, wxPATH_GET_SEPARATOR
);
176 const wxString name
= wxFileName::GetVolumeString(
177 'A' + i
, wxPATH_NO_SEPARATOR
);
179 // Note: If _filesys is unsupported by some compilers,
180 // we can always replace it by DosQueryFSAttach
181 char filesysname
[20];
183 ULONG cbBuffer
= sizeof(filesysname
);
184 PFSQBUFFER2 pfsqBuffer
= (PFSQBUFFER2
)filesysname
;
185 APIRET rc
= ::DosQueryFSAttach(name
.fn_str(),0,FSAIL_QUERYNAME
,pfsqBuffer
,&cbBuffer
);
188 filesysname
[0] = '\0';
191 _filesys(name
.fn_str(), filesysname
, sizeof(filesysname
));
193 /* FAT, LAN, HPFS, CDFS, NFS */
195 if (path
== wxT("A:\\") || path
== wxT("B:\\"))
196 imageId
= wxFileIconsTable::floppy
;
197 else if (!strcmp(filesysname
, "CDFS"))
198 imageId
= wxFileIconsTable::cdrom
;
199 else if (!strcmp(filesysname
, "LAN") ||
200 !strcmp(filesysname
, "NFS"))
201 imageId
= wxFileIconsTable::drive
;
203 imageId
= wxFileIconsTable::drive
;
206 icon_ids
.Add(imageId
);
211 #else // !__WIN32__, !__OS2__
212 /* If we can switch to the drive, it exists. */
213 for ( char drive
= 'A'; drive
<= 'Z'; drive
++ )
216 path
= wxFileName::GetVolumeString(drive
, wxPATH_GET_SEPARATOR
);
218 if (wxIsDriveAvailable(path
))
221 names
.Add(wxFileName::GetVolumeString(drive
, wxPATH_NO_SEPARATOR
));
222 icon_ids
.Add(drive
<= 2 ? wxFileIconsTable::floppy
223 : wxFileIconsTable::drive
);
226 #endif // __WIN32__/!__WIN32__
228 #elif defined(__WXMAC__) && wxOSX_USE_COCOA_OR_CARBON
230 ItemCount volumeIndex
= 1;
233 while( noErr
== err
)
235 HFSUniStr255 volumeName
;
237 FSVolumeInfo volumeInfo
;
238 err
= FSGetVolumeInfo(0, volumeIndex
, NULL
, kFSVolInfoFlags
, &volumeInfo
, &volumeName
, &fsRef
);
241 wxString path
= wxMacFSRefToPath( &fsRef
) ;
242 wxString name
= wxMacHFSUniStrToString( &volumeName
) ;
244 if ( (volumeInfo
.flags
& kFSVolFlagSoftwareLockedMask
) || (volumeInfo
.flags
& kFSVolFlagHardwareLockedMask
) )
246 icon_ids
.Add(wxFileIconsTable::cdrom
);
250 icon_ids
.Add(wxFileIconsTable::drive
);
252 // todo other removable
260 #elif defined(__UNIX__)
263 icon_ids
.Add(wxFileIconsTable::computer
);
265 #error "Unsupported platform in wxGenericDirCtrl!"
267 wxASSERT_MSG( (paths
.GetCount() == names
.GetCount()), wxT("The number of paths and their human readable names should be equal in number."));
268 wxASSERT_MSG( (paths
.GetCount() == icon_ids
.GetCount()), wxT("Wrong number of icons for available drives."));
269 return paths
.GetCount();
272 // ----------------------------------------------------------------------------
273 // wxIsDriveAvailable
274 // ----------------------------------------------------------------------------
278 bool wxIsDriveAvailable(const wxString
& dirName
)
280 // FIXME: this method leads to hang up under Watcom for some reason
282 wxUnusedVar(dirName
);
284 if ( dirName
.length() == 3 && dirName
[1u] == wxT(':') )
286 wxString
dirNameLower(dirName
.Lower());
287 // VS: always return true for removable media, since Win95 doesn't
288 // like it when MS-DOS app accesses empty floppy drive
289 return (dirNameLower
[0u] == wxT('a') ||
290 dirNameLower
[0u] == wxT('b') ||
291 wxDirExists(dirNameLower
));
298 #elif defined(__WINDOWS__) || defined(__OS2__)
300 int setdrive(int WXUNUSED_IN_WINCE(drive
))
304 #elif defined(__GNUWIN32__) && \
305 (defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 1)
306 return _chdrive(drive
);
310 if (drive
< 1 || drive
> 31)
312 newdrive
[0] = (wxChar
)(wxT('A') + drive
- 1);
313 newdrive
[1] = wxT(':');
315 newdrive
[2] = wxT('\\');
316 newdrive
[3] = wxT('\0');
318 newdrive
[2] = wxT('\0');
320 #if defined(__WINDOWS__)
321 if (::SetCurrentDirectory(newdrive
))
323 // VA doesn't know what LPSTR is and has its own set
324 if (!DosSetCurrentDir((PSZ
)newdrive
))
332 bool wxIsDriveAvailable(const wxString
& WXUNUSED_IN_WINCE(dirName
))
338 UINT errorMode
= SetErrorMode(SEM_FAILCRITICALERRORS
| SEM_NOOPENFILEERRORBOX
);
342 // Check if this is a root directory and if so,
343 // whether the drive is available.
344 if (dirName
.length() == 3 && dirName
[(size_t)1] == wxT(':'))
346 wxString
dirNameLower(dirName
.Lower());
347 #if defined(__GNUWIN32__) && !(defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 1)
348 success
= wxDirExists(dirNameLower
);
351 // Avoid changing to drive since no media may be inserted.
352 if (dirNameLower
[(size_t)0] == 'a' || dirNameLower
[(size_t)0] == 'b')
355 int currentDrive
= _getdrive();
356 int thisDrive
= (int) (dirNameLower
[(size_t)0] - 'a' + 1) ;
357 int err
= setdrive( thisDrive
) ;
358 setdrive( currentDrive
);
367 (void) SetErrorMode(errorMode
);
373 #endif // __WINDOWS__ || __OS2__
375 #endif // wxUSE_DIRDLG || wxUSE_FILEDLG
381 // Function which is called by quick sort. We want to override the default wxArrayString behaviour,
382 // and sort regardless of case.
383 static int wxCMPFUNC_CONV
wxDirCtrlStringCompareFunction(const wxString
& strFirst
, const wxString
& strSecond
)
385 return strFirst
.CmpNoCase(strSecond
);
388 //-----------------------------------------------------------------------------
390 //-----------------------------------------------------------------------------
392 wxDirItemData::wxDirItemData(const wxString
& path
, const wxString
& name
,
397 /* Insert logic to detect hidden files here
398 * In UnixLand we just check whether the first char is a dot
399 * For FileNameFromPath read LastDirNameInThisPath ;-) */
400 // m_isHidden = (bool)(wxFileNameFromPath(*m_path)[0] == '.');
402 m_isExpanded
= false;
406 void wxDirItemData::SetNewDirName(const wxString
& path
)
409 m_name
= wxFileNameFromPath(path
);
412 bool wxDirItemData::HasSubDirs() const
420 if ( !dir
.Open(m_path
) )
424 return dir
.HasSubDirs();
427 bool wxDirItemData::HasFiles(const wxString
& WXUNUSED(spec
)) const
435 if ( !dir
.Open(m_path
) )
439 return dir
.HasFiles();
442 //-----------------------------------------------------------------------------
444 //-----------------------------------------------------------------------------
446 BEGIN_EVENT_TABLE(wxGenericDirCtrl
, wxControl
)
447 EVT_TREE_ITEM_EXPANDING (wxID_TREECTRL
, wxGenericDirCtrl::OnExpandItem
)
448 EVT_TREE_ITEM_COLLAPSED (wxID_TREECTRL
, wxGenericDirCtrl::OnCollapseItem
)
449 EVT_TREE_BEGIN_LABEL_EDIT (wxID_TREECTRL
, wxGenericDirCtrl::OnBeginEditItem
)
450 EVT_TREE_END_LABEL_EDIT (wxID_TREECTRL
, wxGenericDirCtrl::OnEndEditItem
)
451 EVT_TREE_SEL_CHANGED (wxID_TREECTRL
, wxGenericDirCtrl::OnTreeSelChange
)
452 EVT_TREE_ITEM_ACTIVATED (wxID_TREECTRL
, wxGenericDirCtrl::OnItemActivated
)
453 EVT_SIZE (wxGenericDirCtrl::OnSize
)
456 wxGenericDirCtrl::wxGenericDirCtrl(void)
461 void wxGenericDirCtrl::ExpandRoot()
463 ExpandDir(m_rootId
); // automatically expand first level
465 // Expand and select the default path
466 if (!m_defaultPath
.empty())
468 ExpandPath(m_defaultPath
);
473 // On Unix, there's only one node under the (hidden) root node. It
474 // represents the / path, so the user would always have to expand it;
475 // let's do it ourselves
476 ExpandPath( wxT("/") );
481 bool wxGenericDirCtrl::Create(wxWindow
*parent
,
482 const wxWindowID treeid
,
487 const wxString
& filter
,
489 const wxString
& name
)
491 if (!wxControl::Create(parent
, treeid
, pos
, size
, style
, wxDefaultValidator
, name
))
494 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
));
495 SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
));
499 long treeStyle
= wxTR_HAS_BUTTONS
;
501 // On Windows CE, if you hide the root, you get a crash when
502 // attempting to access data for children of the root item.
504 treeStyle
|= wxTR_HIDE_ROOT
;
508 treeStyle
|= wxTR_NO_LINES
;
511 if (style
& wxDIRCTRL_EDIT_LABELS
)
512 treeStyle
|= wxTR_EDIT_LABELS
;
514 if (style
& wxDIRCTRL_MULTIPLE
)
515 treeStyle
|= wxTR_MULTIPLE
;
517 if ((style
& wxDIRCTRL_3D_INTERNAL
) == 0)
518 treeStyle
|= wxNO_BORDER
;
520 m_treeCtrl
= CreateTreeCtrl(this, wxID_TREECTRL
,
521 wxPoint(0,0), GetClientSize(), treeStyle
);
523 if (!filter
.empty() && (style
& wxDIRCTRL_SHOW_FILTERS
))
524 m_filterListCtrl
= new wxDirFilterListCtrl(this, wxID_FILTERLISTCTRL
);
529 if (m_filter
.empty())
530 m_filter
= wxFileSelectorDefaultWildcardStr
;
532 SetFilterIndex(defaultFilter
);
534 if (m_filterListCtrl
)
535 m_filterListCtrl
->FillFilterList(filter
, defaultFilter
);
537 m_treeCtrl
->SetImageList(wxTheFileIconsTable
->GetSmallImageList());
539 m_showHidden
= false;
540 wxDirItemData
* rootData
= new wxDirItemData(wxEmptyString
, wxEmptyString
, true);
544 #if defined(__WINDOWS__) || defined(__OS2__) || defined(__DOS__)
545 rootName
= _("Computer");
547 rootName
= _("Sections");
550 m_rootId
= m_treeCtrl
->AddRoot( rootName
, 3, -1, rootData
);
551 m_treeCtrl
->SetItemHasChildren(m_rootId
);
555 SetInitialSize(size
);
561 wxGenericDirCtrl::~wxGenericDirCtrl()
565 void wxGenericDirCtrl::Init()
567 m_showHidden
= false;
569 m_currentFilterStr
= wxEmptyString
; // Default: any file
571 m_filterListCtrl
= NULL
;
574 wxTreeCtrl
* wxGenericDirCtrl::CreateTreeCtrl(wxWindow
*parent
, wxWindowID treeid
, const wxPoint
& pos
, const wxSize
& size
, long treeStyle
)
576 return new wxTreeCtrl(parent
, treeid
, pos
, size
, treeStyle
);
579 void wxGenericDirCtrl::ShowHidden( bool show
)
581 if ( m_showHidden
== show
)
586 if ( HasFlag(wxDIRCTRL_MULTIPLE
) )
591 for ( unsigned n
= 0; n
< paths
.size(); n
++ )
593 ExpandPath(paths
[n
]);
598 wxString path
= GetPath();
605 wxGenericDirCtrl::AddSection(const wxString
& path
, const wxString
& name
, int imageId
)
607 wxDirItemData
*dir_item
= new wxDirItemData(path
,name
,true);
609 wxTreeItemId treeid
= AppendItem( m_rootId
, name
, imageId
, -1, dir_item
);
611 m_treeCtrl
->SetItemHasChildren(treeid
);
616 void wxGenericDirCtrl::SetupSections()
618 wxArrayString paths
, names
;
621 size_t n
, count
= wxGetAvailableDrives(paths
, names
, icons
);
624 wxString home
= wxGetHomeDir();
625 AddSection( home
, _("Home directory"), 1);
626 home
+= wxT("/Desktop");
627 AddSection( home
, _("Desktop"), 1);
630 for (n
= 0; n
< count
; n
++)
631 AddSection(paths
[n
], names
[n
], icons
[n
]);
634 void wxGenericDirCtrl::SetFocus()
636 // we don't need focus ourselves, give it to the tree so that the user
639 m_treeCtrl
->SetFocus();
642 void wxGenericDirCtrl::OnBeginEditItem(wxTreeEvent
&event
)
644 // don't rename the main entry "Sections"
645 if (event
.GetItem() == m_rootId
)
651 // don't rename the individual sections
652 if (m_treeCtrl
->GetItemParent( event
.GetItem() ) == m_rootId
)
659 void wxGenericDirCtrl::OnEndEditItem(wxTreeEvent
&event
)
661 if (event
.IsEditCancelled())
664 if ((event
.GetLabel().empty()) ||
665 (event
.GetLabel() == wxT(".")) ||
666 (event
.GetLabel() == wxT("..")) ||
667 (event
.GetLabel().Find(wxT('/')) != wxNOT_FOUND
) ||
668 (event
.GetLabel().Find(wxT('\\')) != wxNOT_FOUND
) ||
669 (event
.GetLabel().Find(wxT('|')) != wxNOT_FOUND
))
671 wxMessageDialog
dialog(this, _("Illegal directory name."), _("Error"), wxOK
| wxICON_ERROR
);
677 wxTreeItemId treeid
= event
.GetItem();
678 wxDirItemData
*data
= GetItemData( treeid
);
681 wxString
new_name( wxPathOnly( data
->m_path
) );
682 new_name
+= wxString(wxFILE_SEP_PATH
);
683 new_name
+= event
.GetLabel();
687 if (wxFileExists(new_name
))
689 wxMessageDialog
dialog(this, _("File name exists already."), _("Error"), wxOK
| wxICON_ERROR
);
694 if (wxRenameFile(data
->m_path
,new_name
))
696 data
->SetNewDirName( new_name
);
700 wxMessageDialog
dialog(this, _("Operation not permitted."), _("Error"), wxOK
| wxICON_ERROR
);
706 void wxGenericDirCtrl::OnTreeSelChange(wxTreeEvent
&event
)
708 wxTreeEvent
changedEvent(wxEVT_DIRCTRL_SELECTIONCHANGED
, GetId());
710 changedEvent
.SetEventObject(this);
711 changedEvent
.SetItem(event
.GetItem());
712 changedEvent
.SetClientObject(m_treeCtrl
->GetItemData(event
.GetItem()));
714 if (GetEventHandler()->SafelyProcessEvent(changedEvent
) && !changedEvent
.IsAllowed())
720 void wxGenericDirCtrl::OnItemActivated(wxTreeEvent
&event
)
722 wxTreeItemId treeid
= event
.GetItem();
723 const wxDirItemData
*data
= GetItemData(treeid
);
733 wxTreeEvent
changedEvent(wxEVT_DIRCTRL_FILEACTIVATED
, GetId());
735 changedEvent
.SetEventObject(this);
736 changedEvent
.SetItem(treeid
);
737 changedEvent
.SetClientObject(m_treeCtrl
->GetItemData(treeid
));
739 if (GetEventHandler()->SafelyProcessEvent(changedEvent
) && !changedEvent
.IsAllowed())
746 void wxGenericDirCtrl::OnExpandItem(wxTreeEvent
&event
)
748 wxTreeItemId parentId
= event
.GetItem();
750 // VS: this is needed because the event handler is called from wxTreeCtrl
751 // ctor when wxTR_HIDE_ROOT was specified
753 if (!m_rootId
.IsOk())
754 m_rootId
= m_treeCtrl
->GetRootItem();
759 void wxGenericDirCtrl::OnCollapseItem(wxTreeEvent
&event
)
761 CollapseDir(event
.GetItem());
764 void wxGenericDirCtrl::CollapseDir(wxTreeItemId parentId
)
768 wxDirItemData
*data
= GetItemData(parentId
);
769 if (!data
->m_isExpanded
)
772 data
->m_isExpanded
= false;
774 m_treeCtrl
->Freeze();
775 if (parentId
!= m_treeCtrl
->GetRootItem())
776 m_treeCtrl
->CollapseAndReset(parentId
);
777 m_treeCtrl
->DeleteChildren(parentId
);
781 void wxGenericDirCtrl::PopulateNode(wxTreeItemId parentId
)
783 wxDirItemData
*data
= GetItemData(parentId
);
785 if (data
->m_isExpanded
)
788 data
->m_isExpanded
= true;
790 if (parentId
== m_treeCtrl
->GetRootItem())
798 wxString search
,path
,filename
;
800 wxString
dirName(data
->m_path
);
802 #if (defined(__WINDOWS__) && !defined(__WXWINCE__)) || defined(__DOS__) || defined(__OS2__)
803 // Check if this is a root directory and if so,
804 // whether the drive is avaiable.
805 if (!wxIsDriveAvailable(dirName
))
807 data
->m_isExpanded
= false;
808 //wxMessageBox(wxT("Sorry, this drive is not available."));
813 // This may take a longish time. Go to busy cursor
816 #if defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__)
817 if (dirName
.Last() == ':')
818 dirName
+= wxString(wxFILE_SEP_PATH
);
822 wxArrayString filenames
;
825 wxString eachFilename
;
832 int style
= wxDIR_DIRS
;
833 if (m_showHidden
) style
|= wxDIR_HIDDEN
;
834 if (d
.GetFirst(& eachFilename
, wxEmptyString
, style
))
838 if ((eachFilename
!= wxT(".")) && (eachFilename
!= wxT("..")))
840 dirs
.Add(eachFilename
);
843 while (d
.GetNext(&eachFilename
));
846 dirs
.Sort(wxDirCtrlStringCompareFunction
);
848 // Now do the filenames -- but only if we're allowed to
849 if (!HasFlag(wxDIRCTRL_DIR_ONLY
))
855 int style
= wxDIR_FILES
;
856 if (m_showHidden
) style
|= wxDIR_HIDDEN
;
857 // Process each filter (ex: "JPEG Files (*.jpg;*.jpeg)|*.jpg;*.jpeg")
858 wxStringTokenizer strTok
;
860 strTok
.SetString(m_currentFilterStr
,wxT(";"));
861 while(strTok
.HasMoreTokens())
863 curFilter
= strTok
.GetNextToken();
864 if (d
.GetFirst(& eachFilename
, curFilter
, style
))
868 if ((eachFilename
!= wxT(".")) && (eachFilename
!= wxT("..")))
870 filenames
.Add(eachFilename
);
873 while (d
.GetNext(& eachFilename
));
877 filenames
.Sort(wxDirCtrlStringCompareFunction
);
880 // Now we really know whether we have any children so tell the tree control
882 m_treeCtrl
->SetItemHasChildren(parentId
, !dirs
.empty() || !filenames
.empty());
884 // Add the sorted dirs
886 for (i
= 0; i
< dirs
.GetCount(); i
++)
888 eachFilename
= dirs
[i
];
890 if (!wxEndsWithPathSeparator(path
))
891 path
+= wxString(wxFILE_SEP_PATH
);
892 path
+= eachFilename
;
894 wxDirItemData
*dir_item
= new wxDirItemData(path
,eachFilename
,true);
895 wxTreeItemId treeid
= AppendItem( parentId
, eachFilename
,
896 wxFileIconsTable::folder
, -1, dir_item
);
897 m_treeCtrl
->SetItemImage( treeid
, wxFileIconsTable::folder_open
,
898 wxTreeItemIcon_Expanded
);
900 // assume that it does have children by default as it can take a long
901 // time to really check for this (think remote drives...)
903 // and if we're wrong, we'll correct the icon later if
904 // the user really tries to open this item
905 m_treeCtrl
->SetItemHasChildren(treeid
);
908 // Add the sorted filenames
909 if (!HasFlag(wxDIRCTRL_DIR_ONLY
))
911 for (i
= 0; i
< filenames
.GetCount(); i
++)
913 eachFilename
= filenames
[i
];
915 if (!wxEndsWithPathSeparator(path
))
916 path
+= wxString(wxFILE_SEP_PATH
);
917 path
+= eachFilename
;
918 //path = dirName + wxString(wxT("/")) + eachFilename;
919 wxDirItemData
*dir_item
= new wxDirItemData(path
,eachFilename
,false);
920 int image_id
= wxFileIconsTable::file
;
921 if (eachFilename
.Find(wxT('.')) != wxNOT_FOUND
)
922 image_id
= wxTheFileIconsTable
->GetIconID(eachFilename
.AfterLast(wxT('.')));
923 (void) AppendItem( parentId
, eachFilename
, image_id
, -1, dir_item
);
928 void wxGenericDirCtrl::ExpandDir(wxTreeItemId parentId
)
930 // ExpandDir() will not actually expand the tree node, just populate it
931 PopulateNode(parentId
);
934 void wxGenericDirCtrl::ReCreateTree()
936 CollapseDir(m_treeCtrl
->GetRootItem());
940 void wxGenericDirCtrl::CollapseTree()
942 wxTreeItemIdValue cookie
;
943 wxTreeItemId child
= m_treeCtrl
->GetFirstChild(m_rootId
, cookie
);
947 child
= m_treeCtrl
->GetNextChild(m_rootId
, cookie
);
951 // Find the child that matches the first part of 'path'.
952 // E.g. if a child path is "/usr" and 'path' is "/usr/include"
953 // then the child for /usr is returned.
954 wxTreeItemId
wxGenericDirCtrl::FindChild(wxTreeItemId parentId
, const wxString
& path
, bool& done
)
956 wxString
path2(path
);
958 // Make sure all separators are as per the current platform
959 path2
.Replace(wxT("\\"), wxString(wxFILE_SEP_PATH
));
960 path2
.Replace(wxT("/"), wxString(wxFILE_SEP_PATH
));
962 // Append a separator to foil bogus substring matching
963 path2
+= wxString(wxFILE_SEP_PATH
);
965 // In MSW or PM, case is not significant
966 #if defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__)
970 wxTreeItemIdValue cookie
;
971 wxTreeItemId childId
= m_treeCtrl
->GetFirstChild(parentId
, cookie
);
972 while (childId
.IsOk())
974 wxDirItemData
* data
= GetItemData(childId
);
976 if (data
&& !data
->m_path
.empty())
978 wxString
childPath(data
->m_path
);
979 if (!wxEndsWithPathSeparator(childPath
))
980 childPath
+= wxString(wxFILE_SEP_PATH
);
982 // In MSW and PM, case is not significant
983 #if defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__)
984 childPath
.MakeLower();
987 if (childPath
.length() <= path2
.length())
989 wxString path3
= path2
.Mid(0, childPath
.length());
990 if (childPath
== path3
)
992 if (path3
.length() == path2
.length())
1001 childId
= m_treeCtrl
->GetNextChild(parentId
, cookie
);
1003 wxTreeItemId invalid
;
1007 // Try to expand as much of the given path as possible,
1008 // and select the given tree item.
1009 bool wxGenericDirCtrl::ExpandPath(const wxString
& path
)
1012 wxTreeItemId treeid
= FindChild(m_rootId
, path
, done
);
1013 wxTreeItemId lastId
= treeid
; // The last non-zero treeid
1014 while (treeid
.IsOk() && !done
)
1018 treeid
= FindChild(treeid
, path
, done
);
1025 wxDirItemData
*data
= GetItemData(lastId
);
1028 m_treeCtrl
->Expand(lastId
);
1030 if (HasFlag(wxDIRCTRL_SELECT_FIRST
) && data
->m_isDir
)
1032 // Find the first file in this directory
1033 wxTreeItemIdValue cookie
;
1034 wxTreeItemId childId
= m_treeCtrl
->GetFirstChild(lastId
, cookie
);
1035 bool selectedChild
= false;
1036 while (childId
.IsOk())
1038 data
= GetItemData(childId
);
1040 if (data
&& data
->m_path
!= wxEmptyString
&& !data
->m_isDir
)
1042 m_treeCtrl
->SelectItem(childId
);
1043 m_treeCtrl
->EnsureVisible(childId
);
1044 selectedChild
= true;
1047 childId
= m_treeCtrl
->GetNextChild(lastId
, cookie
);
1051 m_treeCtrl
->SelectItem(lastId
);
1052 m_treeCtrl
->EnsureVisible(lastId
);
1057 m_treeCtrl
->SelectItem(lastId
);
1058 m_treeCtrl
->EnsureVisible(lastId
);
1065 bool wxGenericDirCtrl::CollapsePath(const wxString
& path
)
1068 wxTreeItemId treeid
= FindChild(m_rootId
, path
, done
);
1069 wxTreeItemId lastId
= treeid
; // The last non-zero treeid
1071 while ( treeid
.IsOk() && !done
)
1073 CollapseDir(treeid
);
1075 treeid
= FindChild(treeid
, path
, done
);
1077 if ( treeid
.IsOk() )
1081 if ( !lastId
.IsOk() )
1084 m_treeCtrl
->SelectItem(lastId
);
1085 m_treeCtrl
->EnsureVisible(lastId
);
1090 wxDirItemData
* wxGenericDirCtrl::GetItemData(wxTreeItemId itemId
)
1092 return static_cast<wxDirItemData
*>(m_treeCtrl
->GetItemData(itemId
));
1095 wxString
wxGenericDirCtrl::GetPath(wxTreeItemId itemId
) const
1097 const wxDirItemData
*
1098 data
= static_cast<wxDirItemData
*>(m_treeCtrl
->GetItemData(itemId
));
1100 return data
->m_path
;
1103 wxString
wxGenericDirCtrl::GetPath() const
1105 // Allow calling GetPath() in multiple selection from OnSelFilter
1106 if (m_treeCtrl
->HasFlag(wxTR_MULTIPLE
))
1108 wxArrayTreeItemIds items
;
1109 m_treeCtrl
->GetSelections(items
);
1110 if (items
.size() > 0)
1112 // return first string only
1113 wxTreeItemId treeid
= items
[0];
1114 return GetPath(treeid
);
1117 return wxEmptyString
;
1120 wxTreeItemId treeid
= m_treeCtrl
->GetSelection();
1123 return GetPath(treeid
);
1126 return wxEmptyString
;
1129 void wxGenericDirCtrl::GetPaths(wxArrayString
& paths
) const
1133 wxArrayTreeItemIds items
;
1134 m_treeCtrl
->GetSelections(items
);
1135 for ( unsigned n
= 0; n
< items
.size(); n
++ )
1137 wxTreeItemId treeid
= items
[n
];
1138 paths
.push_back(GetPath(treeid
));
1142 wxString
wxGenericDirCtrl::GetFilePath() const
1144 wxTreeItemId treeid
= m_treeCtrl
->GetSelection();
1147 wxDirItemData
* data
= (wxDirItemData
*) m_treeCtrl
->GetItemData(treeid
);
1149 return wxEmptyString
;
1151 return data
->m_path
;
1154 return wxEmptyString
;
1157 void wxGenericDirCtrl::GetFilePaths(wxArrayString
& paths
) const
1161 wxArrayTreeItemIds items
;
1162 m_treeCtrl
->GetSelections(items
);
1163 for ( unsigned n
= 0; n
< items
.size(); n
++ )
1165 wxTreeItemId treeid
= items
[n
];
1166 wxDirItemData
* data
= (wxDirItemData
*) m_treeCtrl
->GetItemData(treeid
);
1167 if ( !data
->m_isDir
)
1168 paths
.Add(data
->m_path
);
1172 void wxGenericDirCtrl::SetPath(const wxString
& path
)
1174 m_defaultPath
= path
;
1179 void wxGenericDirCtrl::SelectPath(const wxString
& path
, bool select
)
1182 wxTreeItemId treeid
= FindChild(m_rootId
, path
, done
);
1183 wxTreeItemId lastId
= treeid
; // The last non-zero treeid
1184 while ( treeid
.IsOk() && !done
)
1186 treeid
= FindChild(treeid
, path
, done
);
1187 if ( treeid
.IsOk() )
1190 if ( !lastId
.IsOk() )
1195 m_treeCtrl
->SelectItem(treeid
, select
);
1199 void wxGenericDirCtrl::SelectPaths(const wxArrayString
& paths
)
1201 if ( HasFlag(wxDIRCTRL_MULTIPLE
) )
1204 for ( unsigned n
= 0; n
< paths
.size(); n
++ )
1206 SelectPath(paths
[n
]);
1211 void wxGenericDirCtrl::UnselectAll()
1213 m_treeCtrl
->UnselectAll();
1218 void wxGenericDirCtrl::FindChildFiles(wxTreeItemId treeid
, int dirFlags
, wxArrayString
& filenames
)
1220 wxDirItemData
*data
= (wxDirItemData
*) m_treeCtrl
->GetItemData(treeid
);
1222 // This may take a longish time. Go to busy cursor
1227 wxString search
,path
,filename
;
1229 wxString
dirName(data
->m_path
);
1231 #if defined(__WINDOWS__) || defined(__OS2__)
1232 if (dirName
.Last() == ':')
1233 dirName
+= wxString(wxFILE_SEP_PATH
);
1237 wxString eachFilename
;
1244 if (d
.GetFirst(& eachFilename
, m_currentFilterStr
, dirFlags
))
1248 if ((eachFilename
!= wxT(".")) && (eachFilename
!= wxT("..")))
1250 filenames
.Add(eachFilename
);
1253 while (d
.GetNext(& eachFilename
)) ;
1259 void wxGenericDirCtrl::SetFilterIndex(int n
)
1261 m_currentFilter
= n
;
1264 if (ExtractWildcard(m_filter
, n
, f
, d
))
1265 m_currentFilterStr
= f
;
1268 m_currentFilterStr
= wxT("*");
1270 m_currentFilterStr
= wxT("*.*");
1274 void wxGenericDirCtrl::SetFilter(const wxString
& filter
)
1278 if (!filter
.empty() && !m_filterListCtrl
&& HasFlag(wxDIRCTRL_SHOW_FILTERS
))
1279 m_filterListCtrl
= new wxDirFilterListCtrl(this, wxID_FILTERLISTCTRL
);
1280 else if (filter
.empty() && m_filterListCtrl
)
1282 m_filterListCtrl
->Destroy();
1283 m_filterListCtrl
= NULL
;
1287 if (ExtractWildcard(m_filter
, m_currentFilter
, f
, d
))
1288 m_currentFilterStr
= f
;
1291 m_currentFilterStr
= wxT("*");
1293 m_currentFilterStr
= wxT("*.*");
1295 // current filter index is meaningless after filter change, set it to zero
1297 if (m_filterListCtrl
)
1298 m_filterListCtrl
->FillFilterList(m_filter
, 0);
1301 // Extract description and actual filter from overall filter string
1302 bool wxGenericDirCtrl::ExtractWildcard(const wxString
& filterStr
, int n
, wxString
& filter
, wxString
& description
)
1304 wxArrayString filters
, descriptions
;
1305 int count
= wxParseCommonDialogsFilter(filterStr
, descriptions
, filters
);
1306 if (count
> 0 && n
< count
)
1308 filter
= filters
[n
];
1309 description
= descriptions
[n
];
1317 void wxGenericDirCtrl::DoResize()
1319 wxSize sz
= GetClientSize();
1320 int verticalSpacing
= 3;
1324 if (m_filterListCtrl
)
1326 filterSz
= m_filterListCtrl
->GetSize();
1327 sz
.y
-= (filterSz
.y
+ verticalSpacing
);
1329 m_treeCtrl
->SetSize(0, 0, sz
.x
, sz
.y
);
1330 if (m_filterListCtrl
)
1332 m_filterListCtrl
->SetSize(0, sz
.y
+ verticalSpacing
, sz
.x
, filterSz
.y
);
1333 // Don't know why, but this needs refreshing after a resize (wxMSW)
1334 m_filterListCtrl
->Refresh();
1340 void wxGenericDirCtrl::OnSize(wxSizeEvent
& WXUNUSED(event
))
1345 wxTreeItemId
wxGenericDirCtrl::AppendItem (const wxTreeItemId
& parent
,
1346 const wxString
& text
,
1347 int image
, int selectedImage
,
1348 wxTreeItemData
* data
)
1350 wxTreeCtrl
*treeCtrl
= GetTreeCtrl ();
1352 wxASSERT (treeCtrl
);
1356 return treeCtrl
->AppendItem (parent
, text
, image
, selectedImage
, data
);
1360 return wxTreeItemId();
1365 //-----------------------------------------------------------------------------
1366 // wxDirFilterListCtrl
1367 //-----------------------------------------------------------------------------
1369 IMPLEMENT_CLASS(wxDirFilterListCtrl
, wxChoice
)
1371 BEGIN_EVENT_TABLE(wxDirFilterListCtrl
, wxChoice
)
1372 EVT_CHOICE(wxID_ANY
, wxDirFilterListCtrl::OnSelFilter
)
1375 bool wxDirFilterListCtrl::Create(wxGenericDirCtrl
* parent
,
1376 const wxWindowID treeid
,
1383 // by default our border style is determined by the style of our parent
1384 if ( !(style
& wxBORDER_MASK
) )
1386 style
|= parent
->HasFlag(wxDIRCTRL_3D_INTERNAL
) ? wxBORDER_SUNKEN
1390 return wxChoice::Create(parent
, treeid
, pos
, size
, 0, NULL
, style
);
1393 void wxDirFilterListCtrl::Init()
1398 void wxDirFilterListCtrl::OnSelFilter(wxCommandEvent
& WXUNUSED(event
))
1400 int sel
= GetSelection();
1402 if (m_dirCtrl
->HasFlag(wxDIRCTRL_MULTIPLE
))
1404 wxArrayString paths
;
1405 m_dirCtrl
->GetPaths(paths
);
1407 m_dirCtrl
->SetFilterIndex(sel
);
1409 // If the filter has changed, the view is out of date, so
1410 // collapse the tree.
1411 m_dirCtrl
->ReCreateTree();
1413 // Expand and select the previously selected paths
1414 for (unsigned int i
= 0; i
< paths
.GetCount(); i
++)
1416 m_dirCtrl
->ExpandPath(paths
.Item(i
));
1421 wxString currentPath
= m_dirCtrl
->GetPath();
1423 m_dirCtrl
->SetFilterIndex(sel
);
1424 m_dirCtrl
->ReCreateTree();
1426 // Try to restore the selection, or at least the directory
1427 m_dirCtrl
->ExpandPath(currentPath
);
1431 void wxDirFilterListCtrl::FillFilterList(const wxString
& filter
, int defaultFilter
)
1434 wxArrayString descriptions
, filters
;
1435 size_t n
= (size_t) wxParseCommonDialogsFilter(filter
, descriptions
, filters
);
1437 if (n
> 0 && defaultFilter
< (int) n
)
1439 for (size_t i
= 0; i
< n
; i
++)
1440 Append(descriptions
[i
]);
1441 SetSelection(defaultFilter
);
1444 #endif // wxUSE_DIRDLG
1446 #if wxUSE_DIRDLG || wxUSE_FILEDLG
1448 // ----------------------------------------------------------------------------
1449 // wxFileIconsTable icons
1450 // ----------------------------------------------------------------------------
1453 /* Computer (c) Julian Smart */
1454 static const char* const file_icons_tbl_computer_xpm
[] = {
1455 /* columns rows colors chars-per-pixel */
1519 // ----------------------------------------------------------------------------
1520 // wxFileIconsTable & friends
1521 // ----------------------------------------------------------------------------
1523 // global instance of a wxFileIconsTable
1524 wxFileIconsTable
* wxTheFileIconsTable
= NULL
;
1526 // A module to allow icons table cleanup
1528 class wxFileIconsTableModule
: public wxModule
1530 DECLARE_DYNAMIC_CLASS(wxFileIconsTableModule
)
1532 wxFileIconsTableModule() {}
1533 bool OnInit() { wxTheFileIconsTable
= new wxFileIconsTable
; return true; }
1536 wxDELETE(wxTheFileIconsTable
);
1540 IMPLEMENT_DYNAMIC_CLASS(wxFileIconsTableModule
, wxModule
)
1542 class wxFileIconEntry
: public wxObject
1545 wxFileIconEntry(int i
) { iconid
= i
; }
1550 wxFileIconsTable::wxFileIconsTable()
1553 m_smallImageList
= NULL
;
1556 wxFileIconsTable::~wxFileIconsTable()
1560 WX_CLEAR_HASH_TABLE(*m_HashTable
);
1563 if (m_smallImageList
) delete m_smallImageList
;
1566 // delayed initialization - wait until first use (wxArtProv not created yet)
1567 void wxFileIconsTable::Create()
1569 wxCHECK_RET(!m_smallImageList
&& !m_HashTable
, wxT("creating icons twice"));
1570 m_HashTable
= new wxHashTable(wxKEY_STRING
);
1571 m_smallImageList
= new wxImageList(16, 16);
1574 m_smallImageList
->Add(wxArtProvider::GetBitmap(wxART_FOLDER
,
1578 m_smallImageList
->Add(wxArtProvider::GetBitmap(wxART_FOLDER_OPEN
,
1583 // GTK24 uses this icon in the file open dialog
1584 m_smallImageList
->Add(wxArtProvider::GetBitmap(wxART_HARDDISK
,
1588 m_smallImageList
->Add(wxIcon(file_icons_tbl_computer_xpm
));
1591 m_smallImageList
->Add(wxArtProvider::GetBitmap(wxART_HARDDISK
,
1595 m_smallImageList
->Add(wxArtProvider::GetBitmap(wxART_CDROM
,
1599 m_smallImageList
->Add(wxArtProvider::GetBitmap(wxART_FLOPPY
,
1603 m_smallImageList
->Add(wxArtProvider::GetBitmap(wxART_REMOVABLE
,
1607 m_smallImageList
->Add(wxArtProvider::GetBitmap(wxART_NORMAL_FILE
,
1611 if (GetIconID(wxEmptyString
, wxT("application/x-executable")) == file
)
1613 m_smallImageList
->Add(wxArtProvider::GetBitmap(wxART_EXECUTABLE_FILE
,
1616 delete m_HashTable
->Get(wxT("exe"));
1617 m_HashTable
->Delete(wxT("exe"));
1618 m_HashTable
->Put(wxT("exe"), new wxFileIconEntry(executable
));
1620 /* else put into list by GetIconID
1621 (KDE defines application/x-executable for *.exe and has nice icon)
1625 wxImageList
*wxFileIconsTable::GetSmallImageList()
1627 if (!m_smallImageList
)
1630 return m_smallImageList
;
1633 #if wxUSE_MIMETYPE && wxUSE_IMAGE && (!defined(__WINDOWS__) || wxUSE_WXDIB)
1634 // VS: we don't need this function w/o wxMimeTypesManager because we'll only have
1635 // one icon and we won't resize it
1637 static wxBitmap
CreateAntialiasedBitmap(const wxImage
& img
)
1639 const unsigned int size
= 16;
1641 wxImage
smallimg (size
, size
);
1642 unsigned char *p1
, *p2
, *ps
;
1643 unsigned char mr
= img
.GetMaskRed(),
1644 mg
= img
.GetMaskGreen(),
1645 mb
= img
.GetMaskBlue();
1648 unsigned sr
, sg
, sb
, smask
;
1650 p1
= img
.GetData(), p2
= img
.GetData() + 3 * size
*2, ps
= smallimg
.GetData();
1651 smallimg
.SetMaskColour(mr
, mr
, mr
);
1653 for (y
= 0; y
< size
; y
++)
1655 for (x
= 0; x
< size
; x
++)
1657 sr
= sg
= sb
= smask
= 0;
1658 if (p1
[0] != mr
|| p1
[1] != mg
|| p1
[2] != mb
)
1659 sr
+= p1
[0], sg
+= p1
[1], sb
+= p1
[2];
1662 if (p1
[0] != mr
|| p1
[1] != mg
|| p1
[2] != mb
)
1663 sr
+= p1
[0], sg
+= p1
[1], sb
+= p1
[2];
1666 if (p2
[0] != mr
|| p2
[1] != mg
|| p2
[2] != mb
)
1667 sr
+= p2
[0], sg
+= p2
[1], sb
+= p2
[2];
1670 if (p2
[0] != mr
|| p2
[1] != mg
|| p2
[2] != mb
)
1671 sr
+= p2
[0], sg
+= p2
[1], sb
+= p2
[2];
1676 ps
[0] = ps
[1] = ps
[2] = mr
;
1679 ps
[0] = (unsigned char)(sr
>> 2);
1680 ps
[1] = (unsigned char)(sg
>> 2);
1681 ps
[2] = (unsigned char)(sb
>> 2);
1685 p1
+= size
*2 * 3, p2
+= size
*2 * 3;
1688 return wxBitmap(smallimg
);
1691 // This function is currently not unused anymore
1693 // finds empty borders and return non-empty area of image:
1694 static wxImage
CutEmptyBorders(const wxImage
& img
)
1696 unsigned char mr
= img
.GetMaskRed(),
1697 mg
= img
.GetMaskGreen(),
1698 mb
= img
.GetMaskBlue();
1699 unsigned char *dt
= img
.GetData(), *dttmp
;
1700 unsigned w
= img
.GetWidth(), h
= img
.GetHeight();
1702 unsigned top
, bottom
, left
, right
, i
;
1705 #define MK_DTTMP(x,y) dttmp = dt + ((x + y * w) * 3)
1706 #define NOEMPTY_PIX(empt) if (dttmp[0] != mr || dttmp[1] != mg || dttmp[2] != mb) {empt = false; break;}
1708 for (empt
= true, top
= 0; empt
&& top
< h
; top
++)
1711 for (i
= 0; i
< w
; i
++, dttmp
+=3)
1714 for (empt
= true, bottom
= h
-1; empt
&& bottom
> top
; bottom
--)
1716 MK_DTTMP(0, bottom
);
1717 for (i
= 0; i
< w
; i
++, dttmp
+=3)
1720 for (empt
= true, left
= 0; empt
&& left
< w
; left
++)
1723 for (i
= 0; i
< h
; i
++, dttmp
+=3*w
)
1726 for (empt
= true, right
= w
-1; empt
&& right
> left
; right
--)
1729 for (i
= 0; i
< h
; i
++, dttmp
+=3*w
)
1732 top
--, left
--, bottom
++, right
++;
1734 return img
.GetSubImage(wxRect(left
, top
, right
- left
+ 1, bottom
- top
+ 1));
1738 #endif // wxUSE_MIMETYPE
1740 int wxFileIconsTable::GetIconID(const wxString
& extension
, const wxString
& mime
)
1742 if (!m_smallImageList
)
1746 if (!extension
.empty())
1748 wxFileIconEntry
*entry
= (wxFileIconEntry
*) m_HashTable
->Get(extension
);
1749 if (entry
) return (entry
-> iconid
);
1752 wxFileType
*ft
= (mime
.empty()) ?
1753 wxTheMimeTypesManager
-> GetFileTypeFromExtension(extension
) :
1754 wxTheMimeTypesManager
-> GetFileTypeFromMimeType(mime
);
1756 wxIconLocation iconLoc
;
1761 if ( ft
&& ft
->GetIcon(&iconLoc
) )
1763 ic
= wxIcon( iconLoc
);
1772 m_HashTable
->Put(extension
, new wxFileIconEntry(newid
));
1777 bmp
.CopyFromIcon(ic
);
1782 m_HashTable
->Put(extension
, new wxFileIconEntry(newid
));
1786 const unsigned int size
= 16;
1788 int treeid
= m_smallImageList
->GetImageCount();
1789 if ((bmp
.GetWidth() == (int) size
) && (bmp
.GetHeight() == (int) size
))
1791 m_smallImageList
->Add(bmp
);
1793 #if wxUSE_IMAGE && (!defined(__WINDOWS__) || wxUSE_WXDIB)
1796 wxImage img
= bmp
.ConvertToImage();
1798 if ((img
.GetWidth() != size
*2) || (img
.GetHeight() != size
*2))
1799 // m_smallImageList->Add(CreateAntialiasedBitmap(CutEmptyBorders(img).Rescale(size*2, size*2)));
1800 m_smallImageList
->Add(CreateAntialiasedBitmap(img
.Rescale(size
*2, size
*2)));
1802 m_smallImageList
->Add(CreateAntialiasedBitmap(img
));
1804 #endif // wxUSE_IMAGE
1806 m_HashTable
->Put(extension
, new wxFileIconEntry(treeid
));
1809 #else // !wxUSE_MIMETYPE
1812 if (extension
== wxT("exe"))
1816 #endif // wxUSE_MIMETYPE/!wxUSE_MIMETYPE
1819 #endif // wxUSE_DIRDLG || wxUSE_FILEDLG