From 4a2f689453ab956ce45005363b78de2b0c2e1bef Mon Sep 17 00:00:00 2001 From: Don Ho Date: Thu, 1 Sep 2011 20:59:36 +0000 Subject: [PATCH] [NEW_FEATURE] enhance Project manager (in progress). git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@802 f5eea248-9336-0410-98b8-ebc06183d4e3 --- .../WinControls/ProjectPanel/ProjectPanel.cpp | 8 ++++---- .../src/WinControls/ProjectPanel/TreeView.cpp | 19 +++++++++++-------- .../src/WinControls/ProjectPanel/TreeView.h | 9 +++++++-- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp b/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp index 55e701f69..00f0cc0f5 100644 --- a/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp +++ b/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp @@ -30,7 +30,7 @@ BOOL CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPar { _treeView.init(_hInst, _hSelf, ID_PROJECTTREEVIEW); - _treeView.initImageList(IDR_ZOOMIN, IDR_ZOOMOUT, IDR_FIND); + _treeView.initImageList(IDR_WRAP, IDR_ZOOMIN, IDR_ZOOMOUT, IDR_FIND); _treeView.display(); openProject(TEXT("C:\\sources\\Notepad++\\trunk\\PowerEditor\\src\\WinControls\\ProjectPanel\\demo.xml")); return TRUE; @@ -182,7 +182,7 @@ bool ProjectPanel::openProject(TCHAR *projectFileName) if (!root) return false; - HTREEITEM rootItem = _treeView.addItem((root->ToElement())->Attribute(TEXT("name")), TVI_ROOT, true); + HTREEITEM rootItem = _treeView.addItem((root->ToElement())->Attribute(TEXT("name")), TVI_ROOT, INDEX_PROJECT_ROOT); buildTreeFrom(root, rootItem); delete pXmlDocProject; @@ -199,7 +199,7 @@ bool ProjectPanel::buildTreeFrom(TiXmlNode *projectRoot, HTREEITEM hParentItem) if (lstrcmp(TEXT("Folder"), v) == 0) { //::MessageBox(NULL, (childNode->ToElement())->Attribute(TEXT("name")), TEXT("Folder"), MB_OK); - HTREEITEM addedItem = _treeView.addItem((childNode->ToElement())->Attribute(TEXT("name")), hParentItem, true); + HTREEITEM addedItem = _treeView.addItem((childNode->ToElement())->Attribute(TEXT("name")), hParentItem, INDEX_CLOSED_NODE); if (!childNode->NoChildren()) { bool isOK = buildTreeFrom(childNode, addedItem); @@ -209,7 +209,7 @@ bool ProjectPanel::buildTreeFrom(TiXmlNode *projectRoot, HTREEITEM hParentItem) } else if (lstrcmp(TEXT("File"), v) == 0) { - _treeView.addItem((childNode->ToElement())->Attribute(TEXT("name")), hParentItem, false); + _treeView.addItem((childNode->ToElement())->Attribute(TEXT("name")), hParentItem, INDEX_LEAF); //::MessageBox(NULL, (childNode->ToElement())->Attribute(TEXT("name")), TEXT("File"), MB_OK); } } diff --git a/PowerEditor/src/WinControls/ProjectPanel/TreeView.cpp b/PowerEditor/src/WinControls/ProjectPanel/TreeView.cpp index 85555cde7..7f45e3588 100644 --- a/PowerEditor/src/WinControls/ProjectPanel/TreeView.cpp +++ b/PowerEditor/src/WinControls/ProjectPanel/TreeView.cpp @@ -23,9 +23,6 @@ #define CY_BITMAP 14 #define NUM_BITMAPS 3 -#define INDEX_OPEN_NODE 0 -#define INDEX_CLOSED_NODE 1 -#define INDEX_LEAF 2 void TreeView::init(HINSTANCE hInst, HWND parent, int treeViewID) { @@ -33,7 +30,7 @@ void TreeView::init(HINSTANCE hInst, HWND parent, int treeViewID) _hSelf = ::GetDlgItem(parent, treeViewID); } -BOOL TreeView::initImageList(int open_node_id, int closed_node_id, int leaf_id) +BOOL TreeView::initImageList(int project_root_id, int open_node_id, int closed_node_id, int leaf_id) { int i; HBITMAP hbmp; @@ -43,6 +40,12 @@ BOOL TreeView::initImageList(int open_node_id, int closed_node_id, int leaf_id) return FALSE; // Add the bmp in the list + hbmp = LoadBitmap(_hInst, MAKEINTRESOURCE(project_root_id)); + if(hbmp == NULL) + return FALSE; + i =ImageList_Add(_hImaLst, hbmp, (HBITMAP)NULL); + DeleteObject(hbmp); + hbmp = LoadBitmap(_hInst, MAKEINTRESOURCE(open_node_id)); if(hbmp == NULL) return FALSE; @@ -61,7 +64,7 @@ BOOL TreeView::initImageList(int open_node_id, int closed_node_id, int leaf_id) i =ImageList_Add(_hImaLst, hbmp, (HBITMAP)NULL); DeleteObject(hbmp); - if (ImageList_GetImageCount(_hImaLst) < 3) + if (ImageList_GetImageCount(_hImaLst) < 4) return FALSE; // Set image list to the tree view @@ -82,7 +85,7 @@ LRESULT TreeView::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) return ::CallWindowProc(_defaultProc, hwnd, Message, wParam, lParam); } -HTREEITEM TreeView::addItem(const TCHAR *itemName, HTREEITEM hParentItem, bool isNode) +HTREEITEM TreeView::addItem(const TCHAR *itemName, HTREEITEM hParentItem, int iImage) { TVITEM tvi; tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; @@ -93,8 +96,8 @@ HTREEITEM TreeView::addItem(const TCHAR *itemName, HTREEITEM hParentItem, bool i // Assume the item is not a parent item, so give it a // document image. - tvi.iImage = isNode?INDEX_CLOSED_NODE:INDEX_LEAF; - tvi.iSelectedImage = isNode?INDEX_OPEN_NODE:INDEX_LEAF; + tvi.iImage = iImage;//isNode?INDEX_CLOSED_NODE:INDEX_LEAF; + tvi.iSelectedImage = iImage;//isNode?INDEX_OPEN_NODE:INDEX_LEAF; // Save the heading level in the item's application-defined // data area. diff --git a/PowerEditor/src/WinControls/ProjectPanel/TreeView.h b/PowerEditor/src/WinControls/ProjectPanel/TreeView.h index 133f737eb..c56102cc8 100644 --- a/PowerEditor/src/WinControls/ProjectPanel/TreeView.h +++ b/PowerEditor/src/WinControls/ProjectPanel/TreeView.h @@ -18,6 +18,11 @@ #ifndef TREE_VIEW_H #define TREE_VIEW_H +#define INDEX_PROJECT_ROOT 0 +#define INDEX_OPEN_NODE 1 +#define INDEX_CLOSED_NODE 2 +#define INDEX_LEAF 3 + #include "window.h" class TreeView : public Window @@ -28,8 +33,8 @@ public: virtual ~TreeView() {}; virtual void init(HINSTANCE hInst, HWND parent, int treeViewID); virtual void destroy(); - HTREEITEM addItem(const TCHAR *itemName, HTREEITEM hParentItem, bool isNode); - BOOL initImageList(int open_node_id, int closed_node_id, int leaf_id); + HTREEITEM addItem(const TCHAR *itemName, HTREEITEM hParentItem, int iImage); + BOOL initImageList(int project_root_id, int open_node_id, int closed_node_id, int leaf_id); protected: HIMAGELIST _hImaLst;