[NEW_FEATURE] Add Project manager (in progress).
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@800 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
e252f39deb
commit
52a17f8056
@ -33,6 +33,7 @@
|
||||
#include "ansiCharPanel.h"
|
||||
#include "clipboardHistoryPanel.h"
|
||||
#include "VerticalFileSwitcher.h"
|
||||
#include "ProjectPanel.h"
|
||||
|
||||
enum tb_stat {tb_saved, tb_unsaved, tb_ro};
|
||||
#define DIR_LEFT true
|
||||
@ -107,7 +108,7 @@ ToolBarButtonUnit toolBarIcons[] = {
|
||||
|
||||
Notepad_plus::Notepad_plus(): _mainWindowStatus(0), _pDocTab(NULL), _pEditView(NULL),
|
||||
_pMainSplitter(NULL),
|
||||
_recordingMacro(false), _pTrayIco(NULL), _isUDDocked(false), _pFileSwitcherPanel(NULL),
|
||||
_recordingMacro(false), _pTrayIco(NULL), _isUDDocked(false), _pFileSwitcherPanel(NULL), _pProjectPanel(NULL),
|
||||
_linkTriggered(true), _isDocModifing(false), _isHotspotDblClicked(false), _sysMenuEntering(false),
|
||||
_autoCompleteMain(&_mainEditView), _autoCompleteSub(&_subEditView), _smartHighlighter(&_findReplaceDlg),
|
||||
_isFileOpening(false), _rememberThisSession(true), _pAnsiCharPanel(NULL), _pClipboardHistoryPanel(NULL)
|
||||
@ -156,6 +157,9 @@ Notepad_plus::~Notepad_plus()
|
||||
|
||||
if (_pFileSwitcherPanel)
|
||||
delete _pFileSwitcherPanel;
|
||||
|
||||
if (_pProjectPanel)
|
||||
delete _pProjectPanel;
|
||||
}
|
||||
|
||||
|
||||
@ -4655,3 +4659,28 @@ void Notepad_plus::launchAnsiCharPanel()
|
||||
}
|
||||
_pAnsiCharPanel->display();
|
||||
}
|
||||
|
||||
void Notepad_plus::launchProjectPanel()
|
||||
{
|
||||
if (!_pProjectPanel)
|
||||
{
|
||||
_pProjectPanel = new ProjectPanel;
|
||||
_pProjectPanel->init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf());
|
||||
|
||||
tTbData data = {0};
|
||||
_pProjectPanel->create(&data);
|
||||
|
||||
::SendMessage(_pPublicInterface->getHSelf(), NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, (WPARAM)_pProjectPanel->getHSelf());
|
||||
// define the default docking behaviour
|
||||
data.uMask = DWS_DF_CONT_LEFT | DWS_ICONTAB;
|
||||
//data.hIconTab = (HICON)::LoadImage(_pPublicInterface->getHinst(), MAKEINTRESOURCE(IDI_FIND_RESULT_ICON), IMAGE_ICON, 0, 0, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT);
|
||||
data.pszModuleName = NPP_INTERNAL_FUCTION_STR;
|
||||
|
||||
// the dlgDlg should be the index of funcItem where the current function pointer is
|
||||
// in this case is DOCKABLE_DEMO_INDEX
|
||||
// In the case of Notepad++ internal function, it'll be the command ID which triggers this dialog
|
||||
data.dlgID = IDM_VIEW_PROJECT_PANEL;
|
||||
::SendMessage(_pPublicInterface->getHSelf(), NPPM_DMMREGASDCKDLG, 0, (LPARAM)&data);
|
||||
}
|
||||
_pProjectPanel->display();
|
||||
}
|
@ -173,6 +173,7 @@ class Notepad_plus_Window;
|
||||
class AnsiCharPanel;
|
||||
class ClipboardHistoryPanel;
|
||||
class VerticalFileSwitcher;
|
||||
class ProjectPanel;
|
||||
|
||||
class Notepad_plus {
|
||||
|
||||
@ -399,6 +400,7 @@ private:
|
||||
AnsiCharPanel *_pAnsiCharPanel;
|
||||
ClipboardHistoryPanel *_pClipboardHistoryPanel;
|
||||
VerticalFileSwitcher *_pFileSwitcherPanel;
|
||||
ProjectPanel *_pProjectPanel;
|
||||
|
||||
BOOL notify(SCNotification *notification);
|
||||
void specialCmd(int id);
|
||||
@ -585,6 +587,7 @@ private:
|
||||
void launchAnsiCharPanel();
|
||||
void launchClipboardHistoryPanel();
|
||||
void launchFileSwitcherPanel();
|
||||
void launchProjectPanel();
|
||||
};
|
||||
|
||||
|
||||
|
@ -44,7 +44,8 @@ void Notepad_plus::command(int id)
|
||||
{
|
||||
case IDM_FILE_NEW:
|
||||
{
|
||||
fileNew();
|
||||
//fileNew();
|
||||
launchProjectPanel();
|
||||
}
|
||||
break;
|
||||
|
||||
@ -297,6 +298,12 @@ void Notepad_plus::command(int id)
|
||||
}
|
||||
break;
|
||||
|
||||
case IDM_VIEW_PROJECT_PANEL:
|
||||
{
|
||||
launchProjectPanel();
|
||||
}
|
||||
break;
|
||||
|
||||
case IDM_EDIT_DELETE:
|
||||
_pEditView->execute(WM_CLEAR);
|
||||
break;
|
||||
|
225
PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp
Normal file
225
PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp
Normal file
@ -0,0 +1,225 @@
|
||||
/*
|
||||
this file is part of notepad++
|
||||
Copyright (C)2011 Don HO <donho@altern.org>
|
||||
|
||||
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; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "precompiledHeaders.h"
|
||||
#include "ProjectPanel.h"
|
||||
#include "resource.h"
|
||||
#include "tinyxml.h"
|
||||
|
||||
BOOL CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG :
|
||||
{
|
||||
_treeView.init(_hInst, _hSelf, ID_PROJECTTREEVIEW);
|
||||
std::vector<Heading> headings;
|
||||
/*
|
||||
headings.push_back(Heading(TEXT("1-a"), 1));
|
||||
headings.push_back(Heading(TEXT("1-b"), 1));
|
||||
headings.push_back(Heading(TEXT("2-a"), 2));
|
||||
headings.push_back(Heading(TEXT("2-a"), 3));
|
||||
headings.push_back(Heading(TEXT("2-a"), 4));
|
||||
headings.push_back(Heading(TEXT("2-a"), 5));
|
||||
headings.push_back(Heading(TEXT("1-c"), 1));
|
||||
headings.push_back(Heading(TEXT("2-a"), 2));
|
||||
headings.push_back(Heading(TEXT("2-b"), 2));
|
||||
*/
|
||||
_treeView.initTreeViewItems(headings, IDR_ZOOMIN, IDR_ZOOMOUT, IDR_FIND);
|
||||
_treeView.display();
|
||||
openProject(TEXT("C:\\sources\\Notepad++\\trunk\\PowerEditor\\src\\WinControls\\ProjectPanel\\demo.xml"));
|
||||
return TRUE;
|
||||
}
|
||||
/*
|
||||
case WM_NOTIFY:
|
||||
{
|
||||
switch (((LPNMHDR)lParam)->code)
|
||||
{
|
||||
case NM_DBLCLK:
|
||||
{
|
||||
LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam;
|
||||
int i = lpnmitem->iItem;
|
||||
|
||||
if (i == -1)
|
||||
{
|
||||
//::MessageBoxA(NULL, "oh yeh","",MB_OK);
|
||||
::SendMessage(_hParent, WM_COMMAND, IDM_FILE_NEW, 0);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case NM_CLICK:
|
||||
{
|
||||
LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam;
|
||||
int i = lpnmitem->iItem;
|
||||
|
||||
if (i == -1)
|
||||
return TRUE;
|
||||
|
||||
LVITEM item;
|
||||
item.mask = LVIF_PARAM;
|
||||
item.iItem = i;
|
||||
ListView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item);
|
||||
TaskLstFnStatus *tlfs = (TaskLstFnStatus *)item.lParam;
|
||||
|
||||
activateDoc(tlfs);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case NM_RCLICK :
|
||||
{
|
||||
// Switch to the right document
|
||||
LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam;
|
||||
int i = lpnmitem->iItem;
|
||||
if (i == -1)
|
||||
return TRUE;
|
||||
|
||||
LVITEM item;
|
||||
item.mask = LVIF_PARAM;
|
||||
item.iItem = i;
|
||||
ListView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item);
|
||||
TaskLstFnStatus *tlfs = (TaskLstFnStatus *)item.lParam;
|
||||
|
||||
activateDoc(tlfs);
|
||||
|
||||
// Redirect NM_RCLICK message to Notepad_plus handle
|
||||
NMHDR nmhdr;
|
||||
nmhdr.code = NM_RCLICK;
|
||||
nmhdr.hwndFrom = _hSelf;
|
||||
nmhdr.idFrom = ::GetDlgCtrlID(nmhdr.hwndFrom);
|
||||
::SendMessage(_hParent, WM_NOTIFY, nmhdr.idFrom, (LPARAM)&nmhdr);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case LVN_GETINFOTIP:
|
||||
{
|
||||
LPNMLVGETINFOTIP pGetInfoTip = (LPNMLVGETINFOTIP)lParam;
|
||||
int i = pGetInfoTip->iItem;
|
||||
if (i == -1)
|
||||
return TRUE;
|
||||
generic_string fn = getFullFilePath((size_t)i);
|
||||
lstrcpyn(pGetInfoTip->pszText, fn.c_str(), pGetInfoTip->cchTextMax);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case LVN_COLUMNCLICK:
|
||||
{
|
||||
LPNMLISTVIEW pnmLV = (LPNMLISTVIEW)lParam;
|
||||
setHeaderOrder(pnmLV);
|
||||
ListView_SortItemsEx(pnmLV->hdr.hwndFrom, ListViewCompareProc,(LPARAM)pnmLV);
|
||||
return TRUE;
|
||||
}
|
||||
case LVN_KEYDOWN:
|
||||
{
|
||||
switch (((LPNMLVKEYDOWN)lParam)->wVKey)
|
||||
{
|
||||
case VK_RETURN:
|
||||
{
|
||||
int i = ListView_GetSelectionMark(_fileListView.getHSelf());
|
||||
|
||||
if (i == -1)
|
||||
return TRUE;
|
||||
|
||||
LVITEM item;
|
||||
item.mask = LVIF_PARAM;
|
||||
item.iItem = i;
|
||||
ListView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item);
|
||||
TaskLstFnStatus *tlfs = (TaskLstFnStatus *)item.lParam;
|
||||
activateDoc(tlfs);
|
||||
return TRUE;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
*/
|
||||
case WM_SIZE:
|
||||
{/*
|
||||
int width = LOWORD(lParam);
|
||||
int height = HIWORD(lParam);
|
||||
::MoveWindow(_fileListView.getHSelf(), 0, 0, width, height, TRUE);
|
||||
*/break;
|
||||
}
|
||||
|
||||
case WM_DESTROY:
|
||||
{
|
||||
//_fileListView.destroy();
|
||||
break;
|
||||
}
|
||||
|
||||
default :
|
||||
return DockingDlgInterface::run_dlgProc(message, wParam, lParam);
|
||||
}
|
||||
return DockingDlgInterface::run_dlgProc(message, wParam, lParam);
|
||||
}
|
||||
|
||||
bool ProjectPanel::openProject(TCHAR *projectFileName)
|
||||
{
|
||||
TiXmlDocument *pXmlDocProject = new TiXmlDocument(projectFileName);
|
||||
bool loadOkay = pXmlDocProject->LoadFile();
|
||||
if (!loadOkay)
|
||||
return false;
|
||||
|
||||
TiXmlNode *root = pXmlDocProject->FirstChild(TEXT("NotepadPlus"));
|
||||
if (!root)
|
||||
return false;
|
||||
|
||||
root = root->FirstChild(TEXT("Project"));
|
||||
if (!root)
|
||||
return false;
|
||||
|
||||
loadOkay = buildTreeFrom(root, TVI_ROOT);
|
||||
delete pXmlDocProject;
|
||||
|
||||
return loadOkay;
|
||||
}
|
||||
|
||||
bool ProjectPanel::buildTreeFrom(TiXmlNode *projectRoot, HTREEITEM hParentItem)
|
||||
{
|
||||
for (TiXmlNode *childNode = projectRoot->FirstChildElement();
|
||||
childNode ;
|
||||
childNode = childNode->NextSibling())
|
||||
{
|
||||
const TCHAR *v = childNode->Value();
|
||||
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);
|
||||
if (!childNode->NoChildren())
|
||||
{
|
||||
bool isOK = buildTreeFrom(childNode, addedItem);
|
||||
if (!isOK)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (lstrcmp(TEXT("File"), v) == 0)
|
||||
{
|
||||
_treeView.addItem((childNode->ToElement())->Attribute(TEXT("name")), hParentItem);
|
||||
//::MessageBox(NULL, (childNode->ToElement())->Attribute(TEXT("name")), TEXT("File"), MB_OK);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
57
PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.h
Normal file
57
PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.h
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
this file is part of notepad++
|
||||
Copyright (C)2011 Don HO <donho@altern.org>
|
||||
|
||||
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; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef PROJECTPANEL_H
|
||||
#define PROJECTPANEL_H
|
||||
|
||||
//#include <windows.h>
|
||||
#ifndef DOCKINGDLGINTERFACE_H
|
||||
#include "DockingDlgInterface.h"
|
||||
#endif //DOCKINGDLGINTERFACE_H
|
||||
|
||||
#include "TreeView.h"
|
||||
#include "ProjectPanel_rc.h"
|
||||
|
||||
class TiXmlNode;
|
||||
|
||||
class ProjectPanel : public DockingDlgInterface {
|
||||
public:
|
||||
ProjectPanel(): DockingDlgInterface(IDD_PROJECTPANEL) {};
|
||||
|
||||
void init(HINSTANCE hInst, HWND hPere) {
|
||||
DockingDlgInterface::init(hInst, hPere);
|
||||
};
|
||||
|
||||
virtual void display(bool toShow = true) const {
|
||||
DockingDlgInterface::display(toShow);
|
||||
};
|
||||
|
||||
void setParent(HWND parent2set){
|
||||
_hParent = parent2set;
|
||||
};
|
||||
|
||||
bool openProject(TCHAR *projectFileName);
|
||||
|
||||
protected:
|
||||
TreeView _treeView;
|
||||
virtual BOOL CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||
bool buildTreeFrom(TiXmlNode *projectRoot, HTREEITEM hParentItem);
|
||||
|
||||
};
|
||||
#endif // PROJECTPANEL_H
|
30
PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.rc
Normal file
30
PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.rc
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
this file is part of notepad++
|
||||
Copyright (C)2011 Don HO <donho@altern.org>
|
||||
|
||||
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; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include "ProjectPanel_rc.h"
|
||||
|
||||
IDD_PROJECTPANEL DIALOGEX 26, 41, 142, 324
|
||||
STYLE DS_SETFONT | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
EXSTYLE WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE
|
||||
CAPTION "Project"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x0
|
||||
BEGIN
|
||||
CONTROL "",ID_PROJECTTREEVIEW,"SysTreeView32", TVS_HASBUTTONS | TVS_HASLINES | WS_BORDER | WS_HSCROLL | WS_TABSTOP,7,7,172,93
|
||||
END
|
25
PowerEditor/src/WinControls/ProjectPanel/ProjectPanel_rc.h
Normal file
25
PowerEditor/src/WinControls/ProjectPanel/ProjectPanel_rc.h
Normal file
@ -0,0 +1,25 @@
|
||||
//this file is part of notepad++
|
||||
//Copyright (C)2011 Don HO <donho@altern.org>
|
||||
//
|
||||
//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; either
|
||||
//version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
//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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
#ifndef PROJECTPANEL_RC_H
|
||||
#define PROJECTPANEL_RC_H
|
||||
|
||||
#define IDD_PROJECTPANEL 3100
|
||||
#define ID_PROJECTTREEVIEW (IDD_PROJECTPANEL + 1)
|
||||
|
||||
#endif // PROJECTPANEL_RC_H
|
||||
|
189
PowerEditor/src/WinControls/ProjectPanel/TreeView.cpp
Normal file
189
PowerEditor/src/WinControls/ProjectPanel/TreeView.cpp
Normal file
@ -0,0 +1,189 @@
|
||||
//this file is part of notepad++
|
||||
//Copyright (C)2011 Don HO <donho@altern.org>
|
||||
//
|
||||
//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; either
|
||||
//version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
//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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
#include "precompiledHeaders.h"
|
||||
#include "TreeView.h"
|
||||
|
||||
|
||||
#define CX_BITMAP 14
|
||||
#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)
|
||||
{
|
||||
Window::init(hInst, parent);
|
||||
_hSelf = ::GetDlgItem(parent, treeViewID);
|
||||
}
|
||||
|
||||
BOOL TreeView::initImageList(int open_node_id, int closed_node_id, int leaf_id)
|
||||
{
|
||||
int i;
|
||||
HBITMAP hbmp;
|
||||
|
||||
// Creation of image list
|
||||
if ((_hImaLst = ImageList_Create(CX_BITMAP, CY_BITMAP, ILC_COLOR32 | ILC_MASK, NUM_BITMAPS, 0)) == NULL)
|
||||
return FALSE;
|
||||
|
||||
// Add the bmp in the list
|
||||
hbmp = LoadBitmap(_hInst, MAKEINTRESOURCE(open_node_id));
|
||||
if(hbmp == NULL)
|
||||
return FALSE;
|
||||
i =ImageList_Add(_hImaLst, hbmp, (HBITMAP)NULL);
|
||||
DeleteObject(hbmp);
|
||||
|
||||
hbmp = LoadBitmap(_hInst, MAKEINTRESOURCE(closed_node_id));
|
||||
if(hbmp == NULL)
|
||||
return FALSE;
|
||||
i =ImageList_Add(_hImaLst, hbmp, (HBITMAP)NULL);
|
||||
DeleteObject(hbmp);
|
||||
|
||||
hbmp = LoadBitmap(_hInst, MAKEINTRESOURCE(leaf_id));
|
||||
if(hbmp == NULL)
|
||||
return FALSE;
|
||||
i =ImageList_Add(_hImaLst, hbmp, (HBITMAP)NULL);
|
||||
DeleteObject(hbmp);
|
||||
|
||||
if (ImageList_GetImageCount(_hImaLst) < 3)
|
||||
return FALSE;
|
||||
|
||||
// Set image list to the tree view
|
||||
TreeView_SetImageList(_hSelf, _hImaLst, TVSIL_NORMAL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL TreeView::initTreeViewItems(std::vector<Heading> & headings, int idOpen, int idClosed, int idDocument)
|
||||
{
|
||||
HTREEITEM hti;
|
||||
|
||||
initImageList(idOpen,idClosed,idDocument);
|
||||
|
||||
for (size_t i = 0; i < headings.size(); i++)
|
||||
{
|
||||
// Add the item to the tree-view control.
|
||||
hti = addItem(headings[i]._name, headings[i]._level);
|
||||
if (hti == NULL)
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void TreeView::destroy()
|
||||
{
|
||||
::DestroyWindow(_hSelf);
|
||||
_hSelf = NULL;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
TVITEM tvi;
|
||||
tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
|
||||
|
||||
// Set the text of the item.
|
||||
tvi.pszText = (LPTSTR)itemName;
|
||||
tvi.cchTextMax = sizeof(tvi.pszText)/sizeof(tvi.pszText[0]);
|
||||
|
||||
// Assume the item is not a parent item, so give it a
|
||||
// document image.
|
||||
tvi.iImage = INDEX_LEAF;
|
||||
tvi.iSelectedImage = INDEX_LEAF;
|
||||
|
||||
// Save the heading level in the item's application-defined
|
||||
// data area.
|
||||
tvi.lParam = (LPARAM)0;//nLevel;
|
||||
|
||||
TVINSERTSTRUCT tvInsertStruct;
|
||||
tvInsertStruct.item = tvi;
|
||||
tvInsertStruct.hInsertAfter = (HTREEITEM)TVI_LAST;
|
||||
tvInsertStruct.hParent = hParentItem;
|
||||
|
||||
return (HTREEITEM)::SendMessage(_hSelf, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT)&tvInsertStruct);
|
||||
}
|
||||
|
||||
HTREEITEM TreeView::addItem(const TCHAR *itemName, int nLevel)
|
||||
{
|
||||
TVITEM tvi;
|
||||
TVINSERTSTRUCT tv_insert_struct;
|
||||
static HTREEITEM hPrev = (HTREEITEM)TVI_FIRST;
|
||||
static HTREEITEM hPrevRootItem = NULL;
|
||||
static HTREEITEM hPrevLev2Item = NULL;
|
||||
HTREEITEM hti;
|
||||
|
||||
tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
|
||||
|
||||
// Set the text of the item.
|
||||
tvi.pszText = (LPTSTR) itemName;
|
||||
tvi.cchTextMax = sizeof(tvi.pszText)/sizeof(tvi.pszText[0]);
|
||||
|
||||
// Assume the item is not a parent item, so give it a
|
||||
// document image.
|
||||
|
||||
tvi.iImage = INDEX_LEAF;
|
||||
tvi.iSelectedImage = INDEX_LEAF;
|
||||
|
||||
// Save the heading level in the item's application-defined
|
||||
// data area.
|
||||
tvi.lParam = (LPARAM)nLevel;
|
||||
tv_insert_struct.item = tvi;
|
||||
tv_insert_struct.hInsertAfter = hPrev;
|
||||
|
||||
// Set the parent item based on the specified level.
|
||||
if (nLevel == 1)
|
||||
tv_insert_struct.hParent = TVI_ROOT;
|
||||
else if (nLevel == 2)
|
||||
tv_insert_struct.hParent = hPrevRootItem;
|
||||
else
|
||||
tv_insert_struct.hParent = hPrevLev2Item;
|
||||
|
||||
// Add the item to the tree-view control.
|
||||
hPrev = (HTREEITEM)SendMessage(_hSelf, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT)&tv_insert_struct);
|
||||
|
||||
if (hPrev == NULL)
|
||||
return NULL;
|
||||
|
||||
// Save the handle to the item.
|
||||
if (nLevel == 1)
|
||||
hPrevRootItem = hPrev;
|
||||
else if (nLevel == 2)
|
||||
hPrevLev2Item = hPrev;
|
||||
|
||||
// The new item is a child item. Give the parent item a
|
||||
// closed folder bitmap to indicate it now has child items.
|
||||
if (nLevel > 1)
|
||||
{
|
||||
hti = TreeView_GetParent(_hSelf, hPrev);
|
||||
tvi.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE;
|
||||
tvi.hItem = hti;
|
||||
tvi.iImage = INDEX_CLOSED_NODE;
|
||||
tvi.iSelectedImage = INDEX_CLOSED_NODE;
|
||||
TreeView_SetItem(_hSelf, &tvi);
|
||||
}
|
||||
return hPrev;
|
||||
}
|
||||
|
||||
|
56
PowerEditor/src/WinControls/ProjectPanel/TreeView.h
Normal file
56
PowerEditor/src/WinControls/ProjectPanel/TreeView.h
Normal file
@ -0,0 +1,56 @@
|
||||
//this file is part of notepad++
|
||||
//Copyright (C)2011 Don HO <donho@altern.org>
|
||||
//
|
||||
//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; either
|
||||
//version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
//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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
#ifndef TREE_VIEW_H
|
||||
#define TREE_VIEW_H
|
||||
|
||||
#include "window.h"
|
||||
|
||||
struct Heading {
|
||||
TCHAR _name[64];
|
||||
int _level;
|
||||
Heading(TCHAR *name, int level): _level(level){
|
||||
lstrcpy(_name, name);
|
||||
};
|
||||
};
|
||||
|
||||
class TreeView : public Window
|
||||
{
|
||||
public:
|
||||
TreeView() : Window() {};
|
||||
|
||||
virtual ~TreeView() {};
|
||||
virtual void init(HINSTANCE hInst, HWND parent, int treeViewID);
|
||||
virtual void destroy();
|
||||
HTREEITEM addItem(const TCHAR *itemName, int nLevel);
|
||||
HTREEITEM addItem(const TCHAR *itemName, HTREEITEM hParentItem);
|
||||
BOOL initTreeViewItems(std::vector<Heading> & headings, int idOpen, int idClosed, int idDocument);
|
||||
|
||||
protected:
|
||||
HIMAGELIST _hImaLst;
|
||||
WNDPROC _defaultProc;
|
||||
LRESULT runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
static LRESULT CALLBACK staticProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
|
||||
return (((TreeView *)(::GetWindowLongPtr(hwnd, GWL_USERDATA)))->runProc(hwnd, Message, wParam, lParam));
|
||||
};
|
||||
BOOL initImageList(int open_node_id, int closed_node_id, int leaf_id);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // TREE_VIEW_H
|
12
PowerEditor/src/WinControls/ProjectPanel/demo.xml
Normal file
12
PowerEditor/src/WinControls/ProjectPanel/demo.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<NotepadPlus>
|
||||
<Project name="Notepad++">
|
||||
<Folder name="Power Editor">
|
||||
<Folder name="src">
|
||||
<File name="C:\toto.txt"/>
|
||||
</Folder>
|
||||
<File name="C:\sources\Notepad++\trunk\PowerEditor\license.txt"/>
|
||||
</Folder>
|
||||
<Folder name="Scintilla">
|
||||
</Folder>
|
||||
</Project>
|
||||
</NotepadPlus>
|
@ -243,6 +243,7 @@
|
||||
#define IDM_VIEW_UNFOLD_8 (IDM_VIEW_UNFOLD + 8)
|
||||
|
||||
#define IDM_VIEW_FILESWITCHER_PANEL (IDM_VIEW + 70)
|
||||
#define IDM_VIEW_PROJECT_PANEL (IDM_VIEW + 80)
|
||||
|
||||
#define IDM_VIEW_GOTO_ANOTHER_VIEW 10001
|
||||
#define IDM_VIEW_CLONE_TO_ANOTHER_VIEW 10002
|
||||
|
@ -299,7 +299,10 @@
|
||||
//#define IDD_FINDCHARACTERS 2900
|
||||
|
||||
//See VerticalFileSwitcher_rc.h
|
||||
//#define IDC_LIST_FILESWITCHER 3000
|
||||
//#define IDD_FILESWITCHER_PANEL 3000
|
||||
|
||||
//See ProjectPanel_rc.h
|
||||
//#define IDD_PROJECTPANEL 3100
|
||||
|
||||
// See regExtDlg.h
|
||||
//#define IDD_REGEXT 4000
|
||||
|
@ -133,7 +133,7 @@
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
FavorSizeOrSpeed="0"
|
||||
AdditionalIncludeDirectories="..\src\WinControls\AboutDlg;..\..\scintilla\include;..\include;..\src\WinControls;..\src\WinControls\ImageListSet;..\src\WinControls\OpenSaveFileDialog;..\src\WinControls\SplitterContainer;..\src\WinControls\StaticDialog;..\src\WinControls\TabBar;..\src\WinControls\ToolBar;..\src\MISC\Process;..\src\ScitillaComponent;..\src\MISC;..\src\MISC\SysMsg;..\src\WinControls\StatusBar;..\src;..\src\WinControls\StaticDialog\RunDlg;..\src\tinyxml;..\src\WinControls\ColourPicker;..\src\Win32Explr;..\src\MISC\RegExt;..\src\WinControls\TrayIcon;..\src\WinControls\shortcut;..\src\WinControls\Grid;..\src\WinControls\ContextMenu;..\src\MISC\PluginsManager;..\src\WinControls\Preference;..\src\WinControls\WindowsDlg;..\src\WinControls\TaskList;..\src\WinControls\DockingWnd;..\src\WinControls\ToolTip;..\src\MISC\Exception;..\src\MISC\Common;..\src\tinyxml\tinyXmlA;..\src\WinControls\AnsiCharPanel;..\src\WinControls\ClipboardHistory;..\src\WinControls\FindCharsInRange;..\src\WinControls\VerticalFileSwitcher"
|
||||
AdditionalIncludeDirectories="..\src\WinControls\AboutDlg;..\..\scintilla\include;..\include;..\src\WinControls;..\src\WinControls\ImageListSet;..\src\WinControls\OpenSaveFileDialog;..\src\WinControls\SplitterContainer;..\src\WinControls\StaticDialog;..\src\WinControls\TabBar;..\src\WinControls\ToolBar;..\src\MISC\Process;..\src\ScitillaComponent;..\src\MISC;..\src\MISC\SysMsg;..\src\WinControls\StatusBar;..\src;..\src\WinControls\StaticDialog\RunDlg;..\src\tinyxml;..\src\WinControls\ColourPicker;..\src\Win32Explr;..\src\MISC\RegExt;..\src\WinControls\TrayIcon;..\src\WinControls\shortcut;..\src\WinControls\Grid;..\src\WinControls\ContextMenu;..\src\MISC\PluginsManager;..\src\WinControls\Preference;..\src\WinControls\WindowsDlg;..\src\WinControls\TaskList;..\src\WinControls\DockingWnd;..\src\WinControls\ToolTip;..\src\MISC\Exception;..\src\MISC\Common;..\src\tinyxml\tinyXmlA;..\src\WinControls\AnsiCharPanel;..\src\WinControls\ClipboardHistory;..\src\WinControls\FindCharsInRange;..\src\WinControls\VerticalFileSwitcher;..\src\WinControls\ProjectPanel"
|
||||
PreprocessorDefinitions="WIN32;_WINDOWS;_USE_64BIT_TIME_T;TIXML_USE_STL;TIXMLA_USE_STL;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NON_CONFORMING_SWPRINTFS=1"
|
||||
MinimalRebuild="true"
|
||||
ExceptionHandling="2"
|
||||
@ -228,7 +228,7 @@
|
||||
FavorSizeOrSpeed="1"
|
||||
OmitFramePointers="false"
|
||||
WholeProgramOptimization="false"
|
||||
AdditionalIncludeDirectories="..\src\WinControls\AboutDlg;..\..\scintilla\include;..\include;..\src\WinControls;..\src\WinControls\ImageListSet;..\src\WinControls\OpenSaveFileDialog;..\src\WinControls\SplitterContainer;..\src\WinControls\StaticDialog;..\src\WinControls\TabBar;..\src\WinControls\ToolBar;..\src\MISC\Process;..\src\ScitillaComponent;..\src\MISC;..\src\MISC\SysMsg;..\src\WinControls\StatusBar;..\src;..\src\WinControls\StaticDialog\RunDlg;..\src\tinyxml;..\src\WinControls\ColourPicker;..\src\Win32Explr;..\src\MISC\RegExt;..\src\WinControls\TrayIcon;..\src\WinControls\shortcut;..\src\WinControls\Grid;..\src\WinControls\ContextMenu;..\src\MISC\PluginsManager;..\src\WinControls\Preference;..\src\WinControls\WindowsDlg;..\src\WinControls\TaskList;..\src\WinControls\DockingWnd;..\src\WinControls\ToolTip;..\src\MISC\Exception;..\src\MISC\Common;..\src\tinyxml\tinyXmlA;..\src\WinControls\AnsiCharPanel;..\src\WinControls\ClipboardHistory;..\src\WinControls\FindCharsInRange;..\src\WinControls\VerticalFileSwitcher"
|
||||
AdditionalIncludeDirectories="..\src\WinControls\AboutDlg;..\..\scintilla\include;..\include;..\src\WinControls;..\src\WinControls\ImageListSet;..\src\WinControls\OpenSaveFileDialog;..\src\WinControls\SplitterContainer;..\src\WinControls\StaticDialog;..\src\WinControls\TabBar;..\src\WinControls\ToolBar;..\src\MISC\Process;..\src\ScitillaComponent;..\src\MISC;..\src\MISC\SysMsg;..\src\WinControls\StatusBar;..\src;..\src\WinControls\StaticDialog\RunDlg;..\src\tinyxml;..\src\WinControls\ColourPicker;..\src\Win32Explr;..\src\MISC\RegExt;..\src\WinControls\TrayIcon;..\src\WinControls\shortcut;..\src\WinControls\Grid;..\src\WinControls\ContextMenu;..\src\MISC\PluginsManager;..\src\WinControls\Preference;..\src\WinControls\WindowsDlg;..\src\WinControls\TaskList;..\src\WinControls\DockingWnd;..\src\WinControls\ToolTip;..\src\MISC\Exception;..\src\MISC\Common;..\src\tinyxml\tinyXmlA;..\src\WinControls\AnsiCharPanel;..\src\WinControls\ClipboardHistory;..\src\WinControls\FindCharsInRange;..\src\WinControls\VerticalFileSwitcher;..\src\WinControls\ProjectPanel"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USE_64BIT_TIME_T;TIXML_USE_STL;TIXMLA_USE_STL;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NON_CONFORMING_SWPRINTFS=1"
|
||||
GeneratePreprocessedFile="0"
|
||||
StringPooling="true"
|
||||
@ -325,7 +325,7 @@
|
||||
FavorSizeOrSpeed="1"
|
||||
OmitFramePointers="false"
|
||||
WholeProgramOptimization="false"
|
||||
AdditionalIncludeDirectories="..\src\WinControls\AboutDlg;..\..\scintilla\include;..\include;..\src\WinControls;..\src\WinControls\ImageListSet;..\src\WinControls\OpenSaveFileDialog;..\src\WinControls\SplitterContainer;..\src\WinControls\StaticDialog;..\src\WinControls\TabBar;..\src\WinControls\ToolBar;..\src\MISC\Process;..\src\ScitillaComponent;..\src\MISC;..\src\MISC\SysMsg;..\src\WinControls\StatusBar;..\src;..\src\WinControls\StaticDialog\RunDlg;..\src\tinyxml;..\src\WinControls\ColourPicker;..\src\Win32Explr;..\src\MISC\RegExt;..\src\WinControls\TrayIcon;..\src\WinControls\shortcut;..\src\WinControls\Grid;..\src\WinControls\ContextMenu;..\src\MISC\PluginsManager;..\src\WinControls\Preference;..\src\WinControls\WindowsDlg;..\src\WinControls\TaskList;..\src\WinControls\DockingWnd;..\src\WinControls\ToolTip;..\src\MISC\Exception;..\src\MISC\Common;..\src\tinyxml\tinyXmlA;..\src\WinControls\AnsiCharPanel;..\src\WinControls\FindCharsInRange;..\src\WinControls\ClipboardHistory;..\src\WinControls\VerticalFileSwitcher"
|
||||
AdditionalIncludeDirectories="..\src\WinControls\AboutDlg;..\..\scintilla\include;..\include;..\src\WinControls;..\src\WinControls\ImageListSet;..\src\WinControls\OpenSaveFileDialog;..\src\WinControls\SplitterContainer;..\src\WinControls\StaticDialog;..\src\WinControls\TabBar;..\src\WinControls\ToolBar;..\src\MISC\Process;..\src\ScitillaComponent;..\src\MISC;..\src\MISC\SysMsg;..\src\WinControls\StatusBar;..\src;..\src\WinControls\StaticDialog\RunDlg;..\src\tinyxml;..\src\WinControls\ColourPicker;..\src\Win32Explr;..\src\MISC\RegExt;..\src\WinControls\TrayIcon;..\src\WinControls\shortcut;..\src\WinControls\Grid;..\src\WinControls\ContextMenu;..\src\MISC\PluginsManager;..\src\WinControls\Preference;..\src\WinControls\WindowsDlg;..\src\WinControls\TaskList;..\src\WinControls\DockingWnd;..\src\WinControls\ToolTip;..\src\MISC\Exception;..\src\MISC\Common;..\src\tinyxml\tinyXmlA;..\src\WinControls\AnsiCharPanel;..\src\WinControls\FindCharsInRange;..\src\WinControls\ClipboardHistory;..\src\WinControls\VerticalFileSwitcher;..\src\WinControls\ProjectPanel"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USE_64BIT_TIME_T;TIXML_USE_STL;TIXMLA_USE_STL;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NON_CONFORMING_SWPRINTFS=1"
|
||||
StringPooling="true"
|
||||
ExceptionHandling="2"
|
||||
@ -667,6 +667,10 @@
|
||||
RelativePath="..\src\MISC\Process\Process.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\WinControls\ProjectPanel\ProjectPanel.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\MISC\RegExt\regExtDlg.cpp"
|
||||
>
|
||||
@ -775,6 +779,10 @@
|
||||
RelativePath="..\src\WinControls\TrayIcon\trayIconControler.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\WinControls\ProjectPanel\TreeView.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\UniConversion.cpp"
|
||||
>
|
||||
@ -1113,6 +1121,10 @@
|
||||
RelativePath="..\src\icons\print.bmp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\WinControls\ProjectPanel\ProjectPanel.rc"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\icons\readonly.ico"
|
||||
>
|
||||
@ -1582,6 +1594,14 @@
|
||||
RelativePath="..\src\MISC\Process\Process.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\WinControls\ProjectPanel\ProjectPanel.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\WinControls\ProjectPanel\ProjectPanel_rc.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\MISC\RegExt\regExtDlg.h"
|
||||
>
|
||||
@ -1591,11 +1611,11 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\resource.h"
|
||||
RelativePath="..\src\WinControls\Preference\resource.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\WinControls\Preference\resource.h"
|
||||
RelativePath="..\src\resource.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
@ -1698,6 +1718,10 @@
|
||||
RelativePath="..\src\WinControls\TrayIcon\trayIconControler.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\WinControls\ProjectPanel\TreeView.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\UniConversion.h"
|
||||
>
|
||||
|
Loading…
Reference in New Issue
Block a user