Skip to content

Commit

Permalink
[NEW_FEATURE] Add Project manager (in progress).
Browse files Browse the repository at this point in the history
- Notepad-plus svn trunk @ 800
  • Loading branch information
donho committed Aug 29, 2011
1 parent 9f5a1ef commit 96d754c
Show file tree
Hide file tree
Showing 13 changed files with 669 additions and 8 deletions.
31 changes: 30 additions & 1 deletion PowerEditor/src/Notepad_plus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -156,6 +157,9 @@ Notepad_plus::~Notepad_plus()

if (_pFileSwitcherPanel)
delete _pFileSwitcherPanel;

if (_pProjectPanel)
delete _pProjectPanel;
}


Expand Down Expand Up @@ -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();
}
3 changes: 3 additions & 0 deletions PowerEditor/src/Notepad_plus.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ class Notepad_plus_Window;
class AnsiCharPanel;
class ClipboardHistoryPanel;
class VerticalFileSwitcher;
class ProjectPanel;

class Notepad_plus {

Expand Down Expand Up @@ -399,6 +400,7 @@ friend class Notepad_plus_Window;
AnsiCharPanel *_pAnsiCharPanel;
ClipboardHistoryPanel *_pClipboardHistoryPanel;
VerticalFileSwitcher *_pFileSwitcherPanel;
ProjectPanel *_pProjectPanel;

BOOL notify(SCNotification *notification);
void specialCmd(int id);
Expand Down Expand Up @@ -585,6 +587,7 @@ friend class Notepad_plus_Window;
void launchAnsiCharPanel();
void launchClipboardHistoryPanel();
void launchFileSwitcherPanel();
void launchProjectPanel();
};


Expand Down
9 changes: 8 additions & 1 deletion PowerEditor/src/NppCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ void Notepad_plus::command(int id)
{
case IDM_FILE_NEW:
{
fileNew();
//fileNew();
launchProjectPanel();
}
break;

Expand Down Expand Up @@ -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;
Expand Down
225 changes: 225 additions & 0 deletions PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp
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;
}
57 changes: 57 additions & 0 deletions PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.h
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

0 comments on commit 96d754c

Please sign in to comment.