[NEW_FEATURE] enhance Project manager (in progress).

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@802 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2011-09-01 20:59:36 +00:00
parent 463e198409
commit 4a2f689453
3 changed files with 22 additions and 14 deletions

View File

@ -30,7 +30,7 @@ BOOL CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPar
{ {
_treeView.init(_hInst, _hSelf, ID_PROJECTTREEVIEW); _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(); _treeView.display();
openProject(TEXT("C:\\sources\\Notepad++\\trunk\\PowerEditor\\src\\WinControls\\ProjectPanel\\demo.xml")); openProject(TEXT("C:\\sources\\Notepad++\\trunk\\PowerEditor\\src\\WinControls\\ProjectPanel\\demo.xml"));
return TRUE; return TRUE;
@ -182,7 +182,7 @@ bool ProjectPanel::openProject(TCHAR *projectFileName)
if (!root) if (!root)
return false; 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); buildTreeFrom(root, rootItem);
delete pXmlDocProject; delete pXmlDocProject;
@ -199,7 +199,7 @@ bool ProjectPanel::buildTreeFrom(TiXmlNode *projectRoot, HTREEITEM hParentItem)
if (lstrcmp(TEXT("Folder"), v) == 0) if (lstrcmp(TEXT("Folder"), v) == 0)
{ {
//::MessageBox(NULL, (childNode->ToElement())->Attribute(TEXT("name")), TEXT("Folder"), MB_OK); //::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()) if (!childNode->NoChildren())
{ {
bool isOK = buildTreeFrom(childNode, addedItem); bool isOK = buildTreeFrom(childNode, addedItem);
@ -209,7 +209,7 @@ bool ProjectPanel::buildTreeFrom(TiXmlNode *projectRoot, HTREEITEM hParentItem)
} }
else if (lstrcmp(TEXT("File"), v) == 0) 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); //::MessageBox(NULL, (childNode->ToElement())->Attribute(TEXT("name")), TEXT("File"), MB_OK);
} }
} }

View File

@ -23,9 +23,6 @@
#define CY_BITMAP 14 #define CY_BITMAP 14
#define NUM_BITMAPS 3 #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) 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); _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; int i;
HBITMAP hbmp; HBITMAP hbmp;
@ -43,6 +40,12 @@ BOOL TreeView::initImageList(int open_node_id, int closed_node_id, int leaf_id)
return FALSE; return FALSE;
// Add the bmp in the list // 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)); hbmp = LoadBitmap(_hInst, MAKEINTRESOURCE(open_node_id));
if(hbmp == NULL) if(hbmp == NULL)
return FALSE; 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); i =ImageList_Add(_hImaLst, hbmp, (HBITMAP)NULL);
DeleteObject(hbmp); DeleteObject(hbmp);
if (ImageList_GetImageCount(_hImaLst) < 3) if (ImageList_GetImageCount(_hImaLst) < 4)
return FALSE; return FALSE;
// Set image list to the tree view // 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); 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; TVITEM tvi;
tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; 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 // Assume the item is not a parent item, so give it a
// document image. // document image.
tvi.iImage = isNode?INDEX_CLOSED_NODE:INDEX_LEAF; tvi.iImage = iImage;//isNode?INDEX_CLOSED_NODE:INDEX_LEAF;
tvi.iSelectedImage = isNode?INDEX_OPEN_NODE:INDEX_LEAF; tvi.iSelectedImage = iImage;//isNode?INDEX_OPEN_NODE:INDEX_LEAF;
// Save the heading level in the item's application-defined // Save the heading level in the item's application-defined
// data area. // data area.

View File

@ -18,6 +18,11 @@
#ifndef TREE_VIEW_H #ifndef TREE_VIEW_H
#define 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" #include "window.h"
class TreeView : public Window class TreeView : public Window
@ -28,8 +33,8 @@ public:
virtual ~TreeView() {}; virtual ~TreeView() {};
virtual void init(HINSTANCE hInst, HWND parent, int treeViewID); virtual void init(HINSTANCE hInst, HWND parent, int treeViewID);
virtual void destroy(); virtual void destroy();
HTREEITEM addItem(const TCHAR *itemName, HTREEITEM hParentItem, bool isNode); HTREEITEM addItem(const TCHAR *itemName, HTREEITEM hParentItem, int iImage);
BOOL initImageList(int open_node_id, int closed_node_id, int leaf_id); BOOL initImageList(int project_root_id, int open_node_id, int closed_node_id, int leaf_id);
protected: protected:
HIMAGELIST _hImaLst; HIMAGELIST _hImaLst;