|
From: Emilien K. <cur...@us...> - 2005-08-13 16:27:43
|
Update of /cvsroot/wxdevcenter/wxDevCenter/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4954/src Modified Files: FileSystemCtrl.cpp Added Files: FileSystemListCtrl.cpp FileSystemTreeCtrl.cpp Log Message: Separate FileSystemListCtrl and FileSystemTreeCtrl in two distinct files. --- NEW FILE: FileSystemTreeCtrl.cpp --- /** * @file FileSystemTreeCtrl.cpp * @author Cursor */ // // wxDevCenter // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; only version 2 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. #include <wxDevCenter.h> #include <wxDevCenter/FileSystemTreeCtrl.h> #include <wxDevCenter/FileSystem.h> using namespace wxDevCenter; ////////////////////////////////////////////////////////////////////// // // FileSystemTreeItemData // ////////////////////////////////////////////////////////////////////// FileSystemTreeItemData::FileSystemTreeItemData(wxString &Path, int iType, int iState): wxTreeItemData(), m_strPath(Path), m_iType(iType), m_iState(iState) { } wxString FileSystemTreeItemData::GetPath()const { return m_strPath; } int FileSystemTreeItemData::GetType()const { return m_iType; } int FileSystemTreeItemData::GetState()const { return m_iState; } ////////////////////////////////////////////////////////////////////// // // FileSystemTreeCtrl // ////////////////////////////////////////////////////////////////////// BEGIN_EVENT_TABLE(FileSystemTreeCtrl, wxTreeCtrl) EVT_TREE_ITEM_EXPANDING(wxID_ANY, FileSystemTreeCtrl::OnTreeItemExpanding) EVT_TREE_ITEM_GETTOOLTIP(wxID_ANY, FileSystemTreeCtrl::OnGetTooltip) END_EVENT_TABLE() FileSystemTreeCtrl::FileSystemTreeCtrl(wxWindow* parent, wxWindowID id, wxDevCenter::FileSystem *pFileSystem, const wxPoint& pos, const wxSize& size, long style): wxTreeCtrl(parent, id, pos, size, style), m_pFileSystem(pFileSystem), m_nMode(WXDC_FSTC_MODE_NORMAL), m_strRootPath() { if((m_pFileSystem!=NULL)&&(style&WXDC_FSTC_PROCESS_EVENT)!=0) PushEventHandler(m_pFileSystem); SetImageList(m_pFileSystem->GetImageList(WXDC_SETUP_TREE_ICON_SIZE)); } FileSystemTreeCtrl::~FileSystemTreeCtrl() { } // Fixe un nouveau système de fichier. void FileSystemTreeCtrl::SetFileSystem(wxDevCenter::FileSystem *pFileSystem) { DeleteAllItems(); // Retire l'ancien passage des évènements au système de fichier. if((GetWindowStyle()&WXDC_FSTC_PROCESS_EVENT)!=0 && m_pFileSystem!=NULL) PopEventHandler(false); m_pFileSystem = pFileSystem; // Ajoute le nouveau passage des évènements au système de fichier. if((GetWindowStyle()&WXDC_FSTC_PROCESS_EVENT)!=0) PushEventHandler(m_pFileSystem); SetImageList(m_pFileSystem->GetImageList(WXDC_SETUP_TREE_ICON_SIZE)); } void FileSystemTreeCtrl::Open(FilePath strRootPath, unsigned int nMode) { wxTreeItemId Id; wxString str; if(m_pFileSystem->IsDirectory(strRootPath)) { DeleteAllItems(); Id = AddRoot(strRootPath.GetFileName()); m_strRootPath = strRootPath; m_nMode = nMode; SetItemData(Id, new FileSystemTreeItemData( m_strRootPath , CalcItemType(m_strRootPath))); AppendItem(Id, "..."); Expand(GetRootItem()); SelectItem(GetRootItem()); } else OpenRoot(nMode); } void FileSystemTreeCtrl::OpenRoot(unsigned int nMode) { wxTreeItemId Id; m_nMode = nMode; DeleteAllItems(); m_strRootPath = m_pFileSystem->GetRootPath(); FileSystemTreeItemData *pItemData = new FileSystemTreeItemData(m_strRootPath, CalcItemType(FilePath(m_strRootPath))); Id = AddRoot(m_pFileSystem->GetRoot(), pItemData->GetType(), -1, pItemData); AppendItem(Id, "..."); Expand(GetRootItem()); SelectItem(GetRootItem()); } // Etend l'arbre pour afficher le fichier/répertoire demandé. wxTreeItemId FileSystemTreeCtrl::ExpandTo(FilePath strPath) { wxTreeItemId idParent, idChild; wxTreeItemIdValue cookie; FilePath strParentPath = strPath; strParentPath.RemoveFilename(); if(strPath == strParentPath) // Répertoire racine { idChild = GetRootItem(); SelectItem(idChild); } else { idParent = ExpandTo(strParentPath); if(idParent.IsOk()) { idChild = GetFirstChild(idParent, cookie); while(idChild.IsOk()) { FilePath strChildPath = ((FileSystemTreeItemData*) GetItemData(idChild))->GetPath(); if(strPath.StartsWith(strChildPath)) { RefreshContent(idChild); SelectItem(idChild); break; } idChild = GetNextChild(idParent, cookie); } } } return idChild; } void FileSystemTreeCtrl::OnTreeItemExpanding(wxTreeEvent &event) { RefreshContent(event.GetItem()); event.Skip(); } // Retourne le type associé au chemin spécifié. // Le type retourné est le type étendu (cad type de répertoire pris en compte) long FileSystemTreeCtrl::CalcItemType(FilePath path) { return m_pFileSystem->GetFileType(path); } // Recherche un fils direct d'un noeud. wxTreeItemId FileSystemTreeCtrl::FindChild(wxTreeItemId idParent, wxString strFileName) { bool bIsExpand = IsExpanded(idParent); if(!bIsExpand) Expand(idParent); wxTreeItemIdValue cookie; wxTreeItemId idChild; idChild = GetFirstChild(idParent, cookie); while(idChild.IsOk()) { if(GetItemText(idChild)==strFileName) break; idChild = GetNextChild(idParent, cookie); } if(!bIsExpand) Collapse(idParent); return idChild; } // Interception de l'évènement de demande de tooltip. void FileSystemTreeCtrl::OnGetTooltip(wxTreeEvent& event) { event.SetToolTip( ((FileSystemTreeItemData*)GetItemData(event.GetItem()))->GetPath() ); } // Rafraichi le contenu d'un répertoire. void FileSystemTreeCtrl::RefreshContent(wxTreeItemId idItem) { FileSystemTreeItemData *pItemData; wxTreeItemId NewId; wxString FP; wxString str; DeleteChildren(idItem); // Insertion des répertoires if(m_nMode&WXDC_FSTC_MODE_DIR) { str = ((FileSystemTreeItemData*)GetItemData(idItem))->GetPath(); FP = m_pFileSystem->FindFirst( str, wxDIR_DIRS); while(FP!="") { str = m_pFileSystem->GetCurrentFilePath(); pItemData = new FileSystemTreeItemData(str, CalcItemType(str)); NewId = AppendItem(idItem, FP, pItemData->GetType(), -1, pItemData); AppendItem(NewId, "..."); FP = m_pFileSystem->FindNext(); } } // Insertion des fichiers if(m_nMode&WXDC_FSTC_MODE_FILE) { str = ((FileSystemTreeItemData*)GetItemData(idItem))->GetPath(); FP = m_pFileSystem->FindFirst( str, wxDIR_FILES); while(FP!="") { str = m_pFileSystem->GetCurrentFilePath(); pItemData = new FileSystemTreeItemData(str, CalcItemType(str)); NewId = AppendItem(idItem, FP, pItemData->GetType(), -1, pItemData); FP = m_pFileSystem->FindNext(); } } } --- NEW FILE: FileSystemListCtrl.cpp --- /** * @file FileSystemListCtrl.cpp * @author Cursor */ // // wxDevCenter // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; only version 2 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. #include <wxDevCenter.h> #include <wxDevCenter/FileSystemListCtrl.h> #include <wxDevCenter/FileSystem.h> using namespace wxDevCenter; ////////////////////////////////////////////////////////////////////// // // FileSystemListCtrl // ////////////////////////////////////////////////////////////////////// BEGIN_EVENT_TABLE(FileSystemListCtrl, wxListCtrl) EVT_LIST_ITEM_ACTIVATED(wxID_ANY, FileSystemListCtrl::OnItemActived) END_EVENT_TABLE() // Constructeur. FileSystemListCtrl::FileSystemListCtrl(wxWindow* parent, wxWindowID id, FileSystem *pFileSystem, const wxPoint& pos, const wxSize& size, long style): wxListCtrl(parent, id, pos, size, style), m_pFileSystem(pFileSystem), m_nMode(WXDC_FSLC_MODE_NORMAL), m_strPath(), m_strWild("*.*") { SetImageList(m_pFileSystem->GetImageList(WXDC_SETUP_LIST_BIG_ICON_SIZE), wxIMAGE_LIST_NORMAL); SetImageList(m_pFileSystem->GetImageList(WXDC_SETUP_LIST_LITTLE_ICON_SIZE), wxIMAGE_LIST_SMALL); OpenRoot(); } // Destructeur. FileSystemListCtrl::~FileSystemListCtrl() { } // Fixe un nouveau système de fichier. void FileSystemListCtrl::SetFileSystem(FileSystem *pFileSystem) { DeleteAllItems(); m_pFileSystem = pFileSystem; SetImageList(m_pFileSystem->GetImageList(WXDC_SETUP_LIST_BIG_ICON_SIZE), wxIMAGE_LIST_NORMAL); SetImageList(m_pFileSystem->GetImageList(WXDC_SETUP_LIST_LITTLE_ICON_SIZE), wxIMAGE_LIST_SMALL); } // Supprime tous les éléments de la liste. bool FileSystemListCtrl::DeleteAllItems() { long item =-1; for(;;) { item = GetNextItem(item); if(item==-1) break; delete (wxString*) GetItemData(item); } return wxListCtrl::DeleteAllItems(); } // Met à jour la liste. void FileSystemListCtrl::UpdateList() { DeleteAllItems(); wxString str = m_pFileSystem->FindFirst(m_strPath, m_nMode&0x0003); long item = 0; while(!str.IsEmpty()) { FilePath strFilePath = m_pFileSystem->GetCurrentFilePath(); if(!m_pFileSystem->IsDirectory(strFilePath)) if(!FileSystem::TestWildcard(strFilePath, m_strWild)) { str = m_pFileSystem->FindNext(); continue; } item = InsertItem(item+1, str, CalcItemType(strFilePath)); SetItemData(item, (long)(void*)new wxString(strFilePath)); //SetItem(item, 1, strFilePath); str = m_pFileSystem->FindNext(); } } // Ouvre la liste dans un répertoire spécifique. void FileSystemListCtrl::Open(FilePath strPath, wxString strWild, unsigned int nMode) { wxString str; FilePath strFilePath; m_strWild = strWild; if(m_pFileSystem->IsDirectory(strPath)) { m_strPath = strPath; m_nMode = nMode; UpdateList(); } else OpenRoot(strWild, nMode); } // Ouvre la liste dans le répertoire racine. void FileSystemListCtrl::OpenRoot(wxString strWild, unsigned int nMode) { Open(m_pFileSystem->GetRootPath(), strWild, nMode); } // Fixe la chaine de filtrage de listage des fichier. void FileSystemListCtrl::SetWildcard(wxString strWild) { Open(m_strPath, strWild, m_nMode); } // Calcule le type d'un élément de l'arborescence. long FileSystemListCtrl::CalcItemType(FilePath path) { return m_pFileSystem->GetFileType(path); } // Intercepte les évènements de double-clic et d'entrée. void FileSystemListCtrl::OnItemActived(wxListEvent& event) { if(m_nMode&WXDC_FSLC_MODE_PROCESSCHANGE) { long lItem = event.GetIndex(); FilePath str = *((wxString*) GetItemData(lItem)); if(m_pFileSystem->IsDirectory(str)) ReOpen(str); } event.Skip(); } // Demande le ou les fichiers sélectionnées. void FileSystemListCtrl::GetSelectedFilesList(wxArrayString& files) { long item = -1; for(;;) { item = GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); if (item==-1) break; FilePath path = wxString(*((wxString*)GetItemData(item))); if(!m_pFileSystem->IsDirectory(path)) { files.Add(path); } } } // Demande le ou les fichiers sélectionnées. wxString FileSystemListCtrl::GetSelectedFiles() { FilePath file; wxArrayString files; wxString strList; GetSelectedFilesList(files); if(files.GetCount()>0) { file = files[0]; strList = file.GetFileName(); for(unsigned int n=1; n<files.GetCount(); n++) { file = files[n]; strList += ";" + file.GetFileName(); } } return strList; } Index: FileSystemCtrl.cpp =================================================================== RCS file: /cvsroot/wxdevcenter/wxDevCenter/src/FileSystemCtrl.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** FileSystemCtrl.cpp 13 Aug 2005 14:07:37 -0000 1.9 --- FileSystemCtrl.cpp 13 Aug 2005 16:27:34 -0000 1.10 *************** *** 35,442 **** using namespace wxDevCenter; - ////////////////////////////////////////////////////////////////////// - // - // FileSystemTreeItemData - // - ////////////////////////////////////////////////////////////////////// - FileSystemTreeItemData::FileSystemTreeItemData(wxString &Path, int iType, int iState): - wxTreeItemData(), - m_strPath(Path), - m_iType(iType), - m_iState(iState) - { - } - - wxString FileSystemTreeItemData::GetPath()const - { - return m_strPath; - } - - int FileSystemTreeItemData::GetType()const - { - return m_iType; - } - - int FileSystemTreeItemData::GetState()const - { - return m_iState; - } - - - - - ////////////////////////////////////////////////////////////////////// - // - // FileSystemTreeCtrl - // - ////////////////////////////////////////////////////////////////////// - - BEGIN_EVENT_TABLE(FileSystemTreeCtrl, wxTreeCtrl) - EVT_TREE_ITEM_EXPANDING(wxID_ANY, FileSystemTreeCtrl::OnTreeItemExpanding) - EVT_TREE_ITEM_GETTOOLTIP(wxID_ANY, FileSystemTreeCtrl::OnGetTooltip) - END_EVENT_TABLE() - - - - FileSystemTreeCtrl::FileSystemTreeCtrl(wxWindow* parent, wxWindowID id, - wxDevCenter::FileSystem *pFileSystem, - const wxPoint& pos, const wxSize& size, long style): - wxTreeCtrl(parent, id, pos, size, style), - m_pFileSystem(pFileSystem), - m_nMode(WXDC_FSTC_MODE_NORMAL), - m_strRootPath() - { - if((m_pFileSystem!=NULL)&&(style&WXDC_FSTC_PROCESS_EVENT)!=0) - PushEventHandler(m_pFileSystem); - SetImageList(m_pFileSystem->GetImageList(WXDC_SETUP_TREE_ICON_SIZE)); - } - - - FileSystemTreeCtrl::~FileSystemTreeCtrl() - { - - } - - // Fixe un nouveau système de fichier. - void FileSystemTreeCtrl::SetFileSystem(wxDevCenter::FileSystem *pFileSystem) - { - DeleteAllItems(); - // Retire l'ancien passage des évènements au système de fichier. - if((GetWindowStyle()&WXDC_FSTC_PROCESS_EVENT)!=0 && m_pFileSystem!=NULL) - PopEventHandler(false); - m_pFileSystem = pFileSystem; - // Ajoute le nouveau passage des évènements au système de fichier. - if((GetWindowStyle()&WXDC_FSTC_PROCESS_EVENT)!=0) - PushEventHandler(m_pFileSystem); - SetImageList(m_pFileSystem->GetImageList(WXDC_SETUP_TREE_ICON_SIZE)); - } - - - void FileSystemTreeCtrl::Open(FilePath strRootPath, unsigned int nMode) - { - wxTreeItemId Id; - wxString str; - - if(m_pFileSystem->IsDirectory(strRootPath)) - { - DeleteAllItems(); - Id = AddRoot(strRootPath.GetFileName()); - m_strRootPath = strRootPath; - m_nMode = nMode; - SetItemData(Id, new FileSystemTreeItemData( m_strRootPath , CalcItemType(m_strRootPath))); - AppendItem(Id, "..."); - - Expand(GetRootItem()); - SelectItem(GetRootItem()); - } - else - OpenRoot(nMode); - } - - - void FileSystemTreeCtrl::OpenRoot(unsigned int nMode) - { - wxTreeItemId Id; - m_nMode = nMode; - DeleteAllItems(); - - m_strRootPath = m_pFileSystem->GetRootPath(); - FileSystemTreeItemData *pItemData = new FileSystemTreeItemData(m_strRootPath, CalcItemType(FilePath(m_strRootPath))); - Id = AddRoot(m_pFileSystem->GetRoot(), pItemData->GetType(), -1, pItemData); - AppendItem(Id, "..."); - - Expand(GetRootItem()); - SelectItem(GetRootItem()); - } - - - // Etend l'arbre pour afficher le fichier/répertoire demandé. - wxTreeItemId FileSystemTreeCtrl::ExpandTo(FilePath strPath) - { - wxTreeItemId idParent, idChild; - wxTreeItemIdValue cookie; - - FilePath strParentPath = strPath; - strParentPath.RemoveFilename(); - - if(strPath == strParentPath) // Répertoire racine - { - idChild = GetRootItem(); - SelectItem(idChild); - } - else - { - idParent = ExpandTo(strParentPath); - if(idParent.IsOk()) - { - idChild = GetFirstChild(idParent, cookie); - while(idChild.IsOk()) - { - FilePath strChildPath = ((FileSystemTreeItemData*) GetItemData(idChild))->GetPath(); - if(strPath.StartsWith(strChildPath)) - { - RefreshContent(idChild); - SelectItem(idChild); - break; - } - idChild = GetNextChild(idParent, cookie); - } - } - } - return idChild; - } - - void FileSystemTreeCtrl::OnTreeItemExpanding(wxTreeEvent &event) - { - RefreshContent(event.GetItem()); - event.Skip(); - } - - // Retourne le type associé au chemin spécifié. - // Le type retourné est le type étendu (cad type de répertoire pris en compte) - long FileSystemTreeCtrl::CalcItemType(FilePath path) - { - return m_pFileSystem->GetFileType(path); - } - - // Recherche un fils direct d'un noeud. - wxTreeItemId FileSystemTreeCtrl::FindChild(wxTreeItemId idParent, wxString strFileName) - { - bool bIsExpand = IsExpanded(idParent); - if(!bIsExpand) - Expand(idParent); - - wxTreeItemIdValue cookie; - wxTreeItemId idChild; - idChild = GetFirstChild(idParent, cookie); - - while(idChild.IsOk()) - { - if(GetItemText(idChild)==strFileName) - break; - idChild = GetNextChild(idParent, cookie); - } - - if(!bIsExpand) - Collapse(idParent); - - return idChild; - } - - // Interception de l'évènement de demande de tooltip. - void FileSystemTreeCtrl::OnGetTooltip(wxTreeEvent& event) - { - event.SetToolTip( ((FileSystemTreeItemData*)GetItemData(event.GetItem()))->GetPath() ); - } - - - // Rafraichi le contenu d'un répertoire. - void FileSystemTreeCtrl::RefreshContent(wxTreeItemId idItem) - { - FileSystemTreeItemData *pItemData; - wxTreeItemId NewId; - wxString FP; - wxString str; - - DeleteChildren(idItem); - - // Insertion des répertoires - if(m_nMode&WXDC_FSTC_MODE_DIR) - { - str = ((FileSystemTreeItemData*)GetItemData(idItem))->GetPath(); - FP = m_pFileSystem->FindFirst( str, wxDIR_DIRS); - while(FP!="") - { - str = m_pFileSystem->GetCurrentFilePath(); - pItemData = new FileSystemTreeItemData(str, CalcItemType(str)); - NewId = AppendItem(idItem, FP, pItemData->GetType(), -1, pItemData); - AppendItem(NewId, "..."); - FP = m_pFileSystem->FindNext(); - } - } - - // Insertion des fichiers - if(m_nMode&WXDC_FSTC_MODE_FILE) - { - str = ((FileSystemTreeItemData*)GetItemData(idItem))->GetPath(); - FP = m_pFileSystem->FindFirst( str, wxDIR_FILES); - while(FP!="") - { - str = m_pFileSystem->GetCurrentFilePath(); - pItemData = new FileSystemTreeItemData(str, CalcItemType(str)); - NewId = AppendItem(idItem, FP, pItemData->GetType(), -1, pItemData); - FP = m_pFileSystem->FindNext(); - } - } - } - - - ////////////////////////////////////////////////////////////////////// - // - // FileSystemListCtrl - // - ////////////////////////////////////////////////////////////////////// - - BEGIN_EVENT_TABLE(FileSystemListCtrl, wxListCtrl) - EVT_LIST_ITEM_ACTIVATED(wxID_ANY, FileSystemListCtrl::OnItemActived) - END_EVENT_TABLE() - - // Constructeur. - FileSystemListCtrl::FileSystemListCtrl(wxWindow* parent, wxWindowID id, FileSystem *pFileSystem, const wxPoint& pos, const wxSize& size, long style): - wxListCtrl(parent, id, pos, size, style), - m_pFileSystem(pFileSystem), - m_nMode(WXDC_FSTC_MODE_NORMAL), - m_strPath(), - m_strWild("*.*") - { - SetImageList(m_pFileSystem->GetImageList(WXDC_SETUP_LIST_BIG_ICON_SIZE), wxIMAGE_LIST_NORMAL); - SetImageList(m_pFileSystem->GetImageList(WXDC_SETUP_LIST_LITTLE_ICON_SIZE), wxIMAGE_LIST_SMALL); - OpenRoot(); - } - - // Destructeur. - FileSystemListCtrl::~FileSystemListCtrl() - { - } - - // Fixe un nouveau système de fichier. - void FileSystemListCtrl::SetFileSystem(FileSystem *pFileSystem) - { - DeleteAllItems(); - m_pFileSystem = pFileSystem; - SetImageList(m_pFileSystem->GetImageList(WXDC_SETUP_LIST_BIG_ICON_SIZE), wxIMAGE_LIST_NORMAL); - SetImageList(m_pFileSystem->GetImageList(WXDC_SETUP_LIST_LITTLE_ICON_SIZE), wxIMAGE_LIST_SMALL); - } - - // Supprime tous les éléments de la liste. - bool FileSystemListCtrl::DeleteAllItems() - { - long item =-1; - for(;;) - { - item = GetNextItem(item); - if(item==-1) - break; - delete (wxString*) GetItemData(item); - } - return wxListCtrl::DeleteAllItems(); - } - - // Met à jour la liste. - void FileSystemListCtrl::UpdateList() - { - DeleteAllItems(); - - wxString str = m_pFileSystem->FindFirst(m_strPath, m_nMode&0x0003); - long item = 0; - while(!str.IsEmpty()) - { - FilePath strFilePath = m_pFileSystem->GetCurrentFilePath(); - - if(!m_pFileSystem->IsDirectory(strFilePath)) - if(!FileSystem::TestWildcard(strFilePath, m_strWild)) - { - str = m_pFileSystem->FindNext(); - continue; - } - - item = InsertItem(item+1, str, CalcItemType(strFilePath)); - SetItemData(item, (long)(void*)new wxString(strFilePath)); - - SetItem(item, 2, strFilePath); - str = m_pFileSystem->FindNext(); - } - } - - - // Ouvre la liste dans un répertoire spécifique. - void FileSystemListCtrl::Open(FilePath strPath, wxString strWild, unsigned int nMode) - { - wxString str; - FilePath strFilePath; - - m_strWild = strWild; - - if(m_pFileSystem->IsDirectory(strPath)) - { - m_strPath = strPath; - m_nMode = nMode; - UpdateList(); - } - else - OpenRoot(strWild, nMode); - } - - // Ouvre la liste dans le répertoire racine. - void FileSystemListCtrl::OpenRoot(wxString strWild, unsigned int nMode) - { - Open(m_pFileSystem->GetRootPath(), strWild, nMode); - } - - // Fixe la chaine de filtrage de listage des fichier. - void FileSystemListCtrl::SetWildcard(wxString strWild) - { - Open(m_strPath, strWild, m_nMode); - } - - - // Calcule le type d'un élément de l'arborescence. - long FileSystemListCtrl::CalcItemType(FilePath path) - { - return m_pFileSystem->GetFileType(path); - } - - // Intercepte les évènements de double-clic et d'entrée. - void FileSystemListCtrl::OnItemActived(wxListEvent& event) - { - if(m_nMode&WXDC_FSLC_MODE_PROCESSCHANGE) - { - long lItem = event.GetIndex(); - FilePath str = *((wxString*) GetItemData(lItem)); - if(m_pFileSystem->IsDirectory(str)) - ReOpen(str); - } - event.Skip(); - } - - // Demande le ou les fichiers sélectionnées. - void FileSystemListCtrl::GetSelectedFilesList(wxArrayString& files) - { - long item = -1; - for(;;) - { - item = GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); - if (item==-1) - break; - FilePath path = wxString(*((wxString*)GetItemData(item))); - if(!m_pFileSystem->IsDirectory(path)) - { - files.Add(path); - } - } - } - - - // Demande le ou les fichiers sélectionnées. - wxString FileSystemListCtrl::GetSelectedFiles() - { - FilePath file; - wxArrayString files; - wxString strList; - GetSelectedFilesList(files); - - if(files.GetCount()>0) - { - file = files[0]; - strList = file.GetFileName(); - for(unsigned int n=1; n<files.GetCount(); n++) - { - file = files[n]; - strList += ";" + file.GetFileName(); - } - } - return strList; - } --- 35,39 ---- |