#pragma implementation "dirdlgg.h"
#endif
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
#include "wx/defs.h"
#include "wx/utils.h"
#include "wx/dialog.h"
#include "wx/generic/dirdlgg.h"
+// If compiled under Windows, this macro can cause problems
+#ifdef GetFirstChild
+#undef GetFirstChild
+#endif
+
/* XPM */
static char * icon1_xpm[] = {
/* width height ncolors chars_per_pixel */
" ",
" "};
+/* XPM */
+static char * icon2_xpm[] = {
+/* width height ncolors chars_per_pixel */
+"16 16 6 1",
+/* colors */
+" s None c None",
+". c #000000",
+"+ c #c0c0c0",
+"@ c #808080",
+"# c #ffff00",
+"$ c #ffffff",
+/* pixels */
+" ",
+" @@@@@ ",
+" @$$$$$@ ",
+" @$#+#+#$@@@@@@ ",
+" @$+#+#+$$$$$$@.",
+" @$#+#+#+#+#+#@.",
+"@@@@@@@@@@@@@#@.",
+"@$$$$$$$$$$@@+@.",
+"@$#+#+#+#+##.@@.",
+" @$#+#+#+#+#+.@.",
+" @$+#+#+#+#+#.@.",
+" @$+#+#+#+##@..",
+" @@@@@@@@@@@@@.",
+" .............",
+" ",
+" "};
static const int ID_DIRCTRL = 1000;
static const int ID_TEXTCTRL = 1001;
// wxDirItemData
//-----------------------------------------------------------------------------
+class wxDirItemData : public wxTreeItemData
+{
+public:
+ wxDirItemData(wxString& path, wxString& name);
+ ~wxDirItemData();
+ bool HasSubDirs();
+ wxString *m_path, *m_name;
+ bool m_isHidden;
+ bool m_hasSubDirs;
+};
+
+//-----------------------------------------------------------------------------
+// wxDirCtrl
+//-----------------------------------------------------------------------------
+
+class wxDirCtrl: public wxTreeCtrl
+{
+ DECLARE_DYNAMIC_CLASS(wxDirCtrl)
+
+ public:
+ bool m_showHidden;
+ wxTreeItemId m_rootId;
+
+ wxDirCtrl(void);
+ wxDirCtrl(wxWindow *parent, const wxWindowID id = -1,
+ const wxString &dir = "/",
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ const long style = wxTR_HAS_BUTTONS,
+ const wxString& name = "wxTreeCtrl" );
+ void OnExpandItem(wxTreeEvent &event );
+ void OnCollapseItem(wxTreeEvent &event );
+ void ShowHidden( const bool yesno );
+ DECLARE_EVENT_TABLE()
+ protected:
+ void CreateItems(const wxTreeItemId &parent);
+ void SetupSections(void);
+ wxArrayString m_paths, m_names;
+};
+
+//-----------------------------------------------------------------------------
+// wxDirItemData
+//-----------------------------------------------------------------------------
+
wxDirItemData::wxDirItemData(wxString& path, wxString& name)
{
m_path = new wxString(path);
{
m_imageListNormal = new wxImageList(16, 16, TRUE);
m_imageListNormal->Add(wxICON(icon1));
+ m_imageListNormal->Add(wxICON(icon2));
SetImageList(m_imageListNormal);
m_showHidden = FALSE;
for (unsigned int i=0; i<m_paths.Count(); i++)
{
dir_item = new wxDirItemData(m_paths[i],m_names[i]);
- id = AppendItem( parent, m_names[i], 0, -1, dir_item);
+ id = AppendItem( parent, m_names[i], 0, 1, dir_item);
if (dir_item->m_hasSubDirs) SetItemHasChildren(id);
}
}
-void wxDirCtrl::OnExpandItem( const wxTreeEvent &event )
+void wxDirCtrl::OnExpandItem(wxTreeEvent &event )
{
if (event.GetItem() == m_rootId)
{
}
CreateItems(event.GetItem());
wxEndBusyCursor();
+
+ SortChildren( event.GetItem() );
};
-void wxDirCtrl::OnCollapseItem( const wxTreeEvent &event )
+void wxDirCtrl::OnCollapseItem(wxTreeEvent &event )
{
wxTreeItemId child, parent = event.GetItem();
long cookie;
m_input->SetValue( *(data->m_path) );
};
-void wxDirDialog::OnTreeKeyDown( wxKeyEvent &WXUNUSED(event) )
+void wxDirDialog::OnTreeKeyDown( wxTreeEvent &WXUNUSED(event) )
{
wxDirItemData *data =
(wxDirItemData*)m_dir->GetItemData(m_dir->GetSelection());