-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NEW_FEATURE] Add Project manager (in progress).
- Notepad-plus svn trunk @ 800
- Loading branch information
Showing
13 changed files
with
669 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
225 changes: 225 additions & 0 deletions
225
PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.