[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:
parent
463e198409
commit
4a2f689453
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user