[NEW_FEATURE] Add Document Map feature (in progress).
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@860 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
e100472728
commit
76c1a650c5
|
@ -34,6 +34,7 @@
|
|||
#include "clipboardHistoryPanel.h"
|
||||
#include "VerticalFileSwitcher.h"
|
||||
#include "ProjectPanel.h"
|
||||
#include "documentMap.h"
|
||||
|
||||
enum tb_stat {tb_saved, tb_unsaved, tb_ro};
|
||||
#define DIR_LEFT true
|
||||
|
@ -109,7 +110,7 @@ ToolBarButtonUnit toolBarIcons[] = {
|
|||
Notepad_plus::Notepad_plus(): _mainWindowStatus(0), _pDocTab(NULL), _pEditView(NULL),
|
||||
_pMainSplitter(NULL),
|
||||
_recordingMacro(false), _pTrayIco(NULL), _isUDDocked(false), _pFileSwitcherPanel(NULL),
|
||||
_pProjectPanel_1(NULL), _pProjectPanel_2(NULL), _pProjectPanel_3(NULL),
|
||||
_pProjectPanel_1(NULL), _pProjectPanel_2(NULL), _pProjectPanel_3(NULL), _pDocMap(NULL),
|
||||
_linkTriggered(true), _isDocModifing(false), _isHotspotDblClicked(false), _sysMenuEntering(false),
|
||||
_autoCompleteMain(&_mainEditView), _autoCompleteSub(&_subEditView), _smartHighlighter(&_findReplaceDlg),
|
||||
_isFileOpening(false), _rememberThisSession(true), _pAnsiCharPanel(NULL), _pClipboardHistoryPanel(NULL)
|
||||
|
@ -171,9 +172,15 @@ Notepad_plus::~Notepad_plus()
|
|||
{
|
||||
delete _pProjectPanel_3;
|
||||
}
|
||||
if (_pDocMap)
|
||||
{
|
||||
delete _pDocMap;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
LRESULT Notepad_plus::init(HWND hwnd)
|
||||
{
|
||||
NppParameters *pNppParam = NppParameters::getInstance();
|
||||
|
@ -4274,6 +4281,11 @@ void Notepad_plus::notifyBufferActivated(BufferID bufid, int view)
|
|||
_pFileSwitcherPanel->activateItem((int)bufid, currentView());
|
||||
}
|
||||
|
||||
if (_pDocMap)
|
||||
{
|
||||
_pDocMap->reloadMap();
|
||||
}
|
||||
|
||||
_linkTriggered = true;
|
||||
}
|
||||
|
||||
|
@ -4748,6 +4760,33 @@ void Notepad_plus::launchProjectPanel(int cmdID, ProjectPanel ** pProjPanel, int
|
|||
(*pProjPanel)->display();
|
||||
}
|
||||
|
||||
void Notepad_plus::launchDocMap()
|
||||
{
|
||||
if (!_pDocMap)
|
||||
{
|
||||
_pDocMap = new DocumentMap();
|
||||
|
||||
_pDocMap->init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), &_pEditView);
|
||||
|
||||
tTbData data = {0};
|
||||
_pDocMap->create(&data);
|
||||
|
||||
::SendMessage(_pPublicInterface->getHSelf(), NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, (WPARAM)_pDocMap->getHSelf());
|
||||
// define the default docking behaviour
|
||||
data.uMask = DWS_DF_CONT_RIGHT | 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_DOC_MAP;
|
||||
::SendMessage(_pPublicInterface->getHSelf(), NPPM_DMMREGASDCKDLG, 0, (LPARAM)&data);
|
||||
}
|
||||
_pDocMap->display();
|
||||
}
|
||||
|
||||
|
||||
struct TextPlayerParams {
|
||||
HWND _nppHandle;
|
||||
ScintillaEditView *_pCurrentView;
|
||||
|
@ -4768,7 +4807,7 @@ struct Quote{
|
|||
const char *_quote;
|
||||
};
|
||||
|
||||
const int nbQuote = 46;
|
||||
const int nbQuote = 47;
|
||||
Quote quotes[nbQuote] = {
|
||||
{"Notepad++", "Notepad++ is written in C++ and uses pure Win32 API and STL which ensures a higher execution speed and smaller program size.\nBy optimizing as many routines as possible without losing user friendliness, Notepad++ is trying to reduce the world carbon dioxide emissions. When using less CPU power, the PC can throttle down and reduce power consumption, resulting in a greener environment."},
|
||||
{"Martin Golding", "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."},
|
||||
|
@ -4816,7 +4855,7 @@ Quote quotes[nbQuote] = {
|
|||
{"Anonymous #19", "F_CK: All I need is U."},
|
||||
{"Anonymous #20", "Never make eye contact when eating a banana."},
|
||||
{"Anonymous #21", "I love my sixpack so much, I protect it with a layer of fat."},
|
||||
//{"Anonymous #22", ""},
|
||||
{"Anonymous #22", "\"It's impossible.\" said pride.\n\"It's risky.\" said experience.\n\"It's pointless.\" said reason.\n\"Give it a try.\" whispered the heart.\n...\n\"What the hell was that?!?!?!?!?!.\" shouted the anus two minutes later."}
|
||||
//{"", ""},
|
||||
//{"", ""},
|
||||
//{"", ""},
|
||||
|
|
|
@ -175,6 +175,7 @@ class AnsiCharPanel;
|
|||
class ClipboardHistoryPanel;
|
||||
class VerticalFileSwitcher;
|
||||
class ProjectPanel;
|
||||
class DocumentMap;
|
||||
|
||||
class Notepad_plus {
|
||||
|
||||
|
@ -406,6 +407,8 @@ private:
|
|||
ProjectPanel *_pProjectPanel_2;
|
||||
ProjectPanel *_pProjectPanel_3;
|
||||
|
||||
DocumentMap *_pDocMap;
|
||||
|
||||
BOOL notify(SCNotification *notification);
|
||||
void specialCmd(int id);
|
||||
void command(int id);
|
||||
|
@ -592,6 +595,7 @@ private:
|
|||
void launchClipboardHistoryPanel();
|
||||
void launchFileSwitcherPanel();
|
||||
void launchProjectPanel(int cmdID, ProjectPanel ** pProjPanel, int panelID);
|
||||
void launchDocMap();
|
||||
int getQuoteIndexFrom(const char *quoter) const;
|
||||
void showQuoteFromIndex(int index) const;
|
||||
void showAllQuotes() const;
|
||||
|
|
|
@ -435,6 +435,7 @@ BEGIN
|
|||
MENUITEM "Project Panel 2", IDM_VIEW_PROJECT_PANEL_2
|
||||
MENUITEM "Project Panel 3", IDM_VIEW_PROJECT_PANEL_3
|
||||
END
|
||||
MENUITEM "Document Map", IDM_VIEW_DOC_MAP
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Synchronize Vertical Scrolling", IDM_VIEW_SYNSCROLLV
|
||||
MENUITEM "Synchronize Horizontal Scrolling", IDM_VIEW_SYNSCROLLH
|
||||
|
|
|
@ -1032,7 +1032,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
|||
{
|
||||
return (LRESULT)_scintillaCtrls4Plugins.createSintilla((lParam == NULL?_pPublicInterface->getHSelf():(HWND)lParam));
|
||||
}
|
||||
|
||||
|
||||
case NPPM_INTERNAL_GETSCINTEDTVIEW:
|
||||
{
|
||||
return (LRESULT)_scintillaCtrls4Plugins.getScintillaEditViewFrom((HWND)lParam);
|
||||
}
|
||||
|
||||
case NPPM_DESTROYSCINTILLAHANDLE :
|
||||
{
|
||||
return _scintillaCtrls4Plugins.destroyScintilla((HWND)lParam);
|
||||
|
|
|
@ -313,6 +313,12 @@ void Notepad_plus::command(int id)
|
|||
}
|
||||
break;
|
||||
|
||||
case IDM_VIEW_DOC_MAP:
|
||||
{
|
||||
launchDocMap();
|
||||
}
|
||||
break;
|
||||
|
||||
case IDM_EDIT_DELETE:
|
||||
_pEditView->execute(WM_CLEAR);
|
||||
break;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "xmlMatchedTagsHighlighter.h"
|
||||
#include "VerticalFileSwitcher.h"
|
||||
#include "ProjectPanel.h"
|
||||
#include "documentMap.h"
|
||||
|
||||
BOOL Notepad_plus::notify(SCNotification *notification)
|
||||
{
|
||||
|
@ -425,6 +426,11 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
|||
updateStatusBar();
|
||||
AutoCompletion * autoC = isFromPrimary?&_autoCompleteMain:&_autoCompleteSub;
|
||||
autoC->update(0);
|
||||
|
||||
if (_pDocMap)
|
||||
{
|
||||
_pDocMap->scrollMap();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -1309,9 +1309,15 @@ public:
|
|||
return (_transparentFuncAddr != NULL);
|
||||
};
|
||||
|
||||
// 0 <= percent < 256
|
||||
// if (percent == 255) then opacq
|
||||
void SetTransparent(HWND hwnd, int percent) {
|
||||
if (!_transparentFuncAddr) return;
|
||||
::SetWindowLongPtr(hwnd, GWL_EXSTYLE, ::GetWindowLongPtrW(hwnd, GWL_EXSTYLE) | 0x00080000);
|
||||
if (percent > 255)
|
||||
percent = 255;
|
||||
if (percent < 0)
|
||||
percent = 0;
|
||||
_transparentFuncAddr(hwnd, 0, percent, 0x00000002);
|
||||
};
|
||||
|
||||
|
|
|
@ -28,21 +28,38 @@ HWND ScintillaCtrls::createSintilla(HWND hParent)
|
|||
return scint->getHSelf();
|
||||
}
|
||||
|
||||
bool ScintillaCtrls::destroyScintilla(HWND handle2Destroy)
|
||||
int ScintillaCtrls::getIndexFrom(HWND handle2Find)
|
||||
{
|
||||
for (size_t i = 0 ; i < _scintVector.size() ; i++)
|
||||
{
|
||||
if (_scintVector[i]->getHSelf() == handle2Destroy)
|
||||
if (_scintVector[i]->getHSelf() == handle2Find)
|
||||
{
|
||||
_scintVector[i]->destroy();
|
||||
delete _scintVector[i];
|
||||
|
||||
vector<ScintillaEditView *>::iterator it2delete = _scintVector.begin()+ i;
|
||||
_scintVector.erase(it2delete);
|
||||
return true;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ScintillaEditView * ScintillaCtrls::getScintillaEditViewFrom(HWND handle2Find)
|
||||
{
|
||||
int i = getIndexFrom(handle2Find);
|
||||
if (i == -1 || size_t(i) >= _scintVector.size())
|
||||
return NULL;
|
||||
return _scintVector[i];
|
||||
}
|
||||
|
||||
bool ScintillaCtrls::destroyScintilla(HWND handle2Destroy)
|
||||
{
|
||||
int i = getIndexFrom(handle2Destroy);
|
||||
if (i == -1)
|
||||
return false;
|
||||
|
||||
_scintVector[i]->destroy();
|
||||
delete _scintVector[i];
|
||||
|
||||
vector<ScintillaEditView *>::iterator it2delete = _scintVector.begin()+ i;
|
||||
_scintVector.erase(it2delete);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ScintillaCtrls::destroy()
|
||||
|
|
|
@ -28,6 +28,7 @@ public :
|
|||
};
|
||||
|
||||
HWND createSintilla(HWND hParent);
|
||||
ScintillaEditView * getScintillaEditViewFrom(HWND handle2Find);
|
||||
bool destroyScintilla(HWND handle2Destroy);
|
||||
void destroy();
|
||||
|
||||
|
@ -35,6 +36,7 @@ private:
|
|||
std::vector<ScintillaEditView *> _scintVector;
|
||||
HINSTANCE _hInst;
|
||||
HWND _hParent;
|
||||
int getIndexFrom(HWND handle2Find);
|
||||
};
|
||||
|
||||
#endif //SCINTILLACTRLS_H
|
||||
|
|
|
@ -250,7 +250,7 @@ void ScintillaEditView::init(HINSTANCE hInst, HWND hPere)
|
|||
_codepage = ::GetACP();
|
||||
|
||||
//Use either Unicode or ANSI setwindowlong, depending on environment
|
||||
if (::IsWindowUnicode(_hSelf))
|
||||
if (::IsWindowUnicode(_hSelf))
|
||||
{
|
||||
::SetWindowLongPtrW(_hSelf, GWL_USERDATA, reinterpret_cast<LONG>(this));
|
||||
_callWindowProc = CallWindowProcW;
|
||||
|
|
|
@ -584,6 +584,8 @@ public:
|
|||
return false;
|
||||
};
|
||||
void setHiLiteResultWords(const TCHAR *keywords);
|
||||
void defineDocType(LangType typeDoc); //setup stylers for active document
|
||||
|
||||
/*
|
||||
pair<size_t, bool> getLineUndoState(size_t currentLine) {
|
||||
Buffer * buf = getCurrentBuffer();
|
||||
|
@ -657,7 +659,6 @@ protected:
|
|||
BufferStyleMap _hotspotStyles;
|
||||
|
||||
//Lexers and Styling
|
||||
void defineDocType(LangType typeDoc); //setup stylers for active document
|
||||
void restyleBuffer();
|
||||
const char * getCompleteKeywordList(std::basic_string<char> & kwl, LangType langType, int keywordIndex);
|
||||
void setKeywords(LangType langType, const char *keywords, int index);
|
||||
|
|
|
@ -0,0 +1,420 @@
|
|||
/*
|
||||
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 "documentMap.h"
|
||||
#include "ScintillaEditView.h"
|
||||
|
||||
|
||||
void DocumentMap::reloadMap()
|
||||
{
|
||||
if (_pScintillaEditView && _ppEditView)
|
||||
{
|
||||
Document currentDoc = (*_ppEditView)->execute(SCI_GETDOCPOINTER);
|
||||
::SendMessage(_pScintillaEditView->getHSelf(), SCI_SETDOCPOINTER, 0, (LPARAM)currentDoc);
|
||||
scrollMap();
|
||||
}
|
||||
}
|
||||
|
||||
void DocumentMap::scrollMap()
|
||||
{
|
||||
if (_pScintillaEditView && _ppEditView)
|
||||
{
|
||||
// Visible line for the code view
|
||||
int firstVisibleLine = (*_ppEditView)->execute(SCI_GETFIRSTVISIBLELINE);
|
||||
int nbLine = (*_ppEditView)->execute(SCI_LINESONSCREEN, firstVisibleLine);
|
||||
//int nbTotalLine = (*_ppEditView)->getCurrentLineNumber();
|
||||
|
||||
int lastVisibleLine = firstVisibleLine + nbLine;
|
||||
|
||||
// Visible line for the map view
|
||||
int firstVisibleLineMap = _pScintillaEditView->execute(SCI_GETFIRSTVISIBLELINE);
|
||||
int nbLineMap = _pScintillaEditView->execute(SCI_LINESONSCREEN, firstVisibleLine);
|
||||
int lastVisibleLineMap = firstVisibleLineMap + nbLineMap;
|
||||
|
||||
if (lastVisibleLineMap < lastVisibleLine)
|
||||
_pScintillaEditView->execute(SCI_GOTOLINE, lastVisibleLine);
|
||||
else
|
||||
_pScintillaEditView->execute(SCI_GOTOLINE, firstVisibleLine);
|
||||
|
||||
int higherPos = _pScintillaEditView->execute(SCI_POSITIONFROMLINE, firstVisibleLine);
|
||||
int lowerPos = _pScintillaEditView->execute(SCI_POSITIONFROMLINE, lastVisibleLine);
|
||||
int higherY = _pScintillaEditView->execute(SCI_POINTYFROMPOSITION, 0, higherPos);
|
||||
int lowerY = _pScintillaEditView->execute(SCI_POINTYFROMPOSITION, 0, lowerPos);
|
||||
if (lowerY == 0)
|
||||
{
|
||||
int lineHeight = _pScintillaEditView->execute(SCI_TEXTHEIGHT, firstVisibleLine);
|
||||
lowerY = nbLine * lineHeight + firstVisibleLine;
|
||||
}
|
||||
_vzDlg.drawZone(higherY, lowerY);
|
||||
}
|
||||
}
|
||||
|
||||
void DocumentMap::scrollMap(bool direction, moveMode whichMode)
|
||||
{
|
||||
// Visible line for the code view
|
||||
int firstVisibleLine = (*_ppEditView)->execute(SCI_GETFIRSTVISIBLELINE);
|
||||
int nbLine = (*_ppEditView)->execute(SCI_LINESONSCREEN, firstVisibleLine);
|
||||
int lastVisibleLine = firstVisibleLine + nbLine;
|
||||
|
||||
int nbLine2go = (whichMode == perLine?1:nbLine);
|
||||
int line2go = 1;
|
||||
|
||||
if (direction == moveDown)
|
||||
{
|
||||
line2go = lastVisibleLine + nbLine2go;
|
||||
}
|
||||
else
|
||||
{
|
||||
line2go = firstVisibleLine - nbLine2go;
|
||||
}
|
||||
(*_ppEditView)->execute(SCI_GOTOLINE, line2go);
|
||||
|
||||
scrollMap();
|
||||
}
|
||||
|
||||
|
||||
BOOL CALLBACK DocumentMap::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG :
|
||||
{
|
||||
//_glassHandle = ::GetDlgItem(_hSelf, IDC_GLASS);
|
||||
HWND hwndScintilla = (HWND)::SendMessage(_hParent, NPPM_CREATESCINTILLAHANDLE, 0, (LPARAM)_hSelf);
|
||||
_pScintillaEditView = (ScintillaEditView *)::SendMessage(_hParent, NPPM_INTERNAL_GETSCINTEDTVIEW, 0, (LPARAM)hwndScintilla);
|
||||
::SendMessage(_pScintillaEditView->getHSelf(), SCI_SETZOOM, (WPARAM)-10, 0);
|
||||
::SendMessage(_pScintillaEditView->getHSelf(), SCI_SETVSCROLLBAR, FALSE, 0);
|
||||
::SendMessage(_pScintillaEditView->getHSelf(), SCI_SETHSCROLLBAR, FALSE, 0);
|
||||
reloadMap();
|
||||
|
||||
_pScintillaEditView->showIndentGuideLine(false);
|
||||
_pScintillaEditView->defineDocType((*_ppEditView)->getCurrentBuffer()->getLangType());
|
||||
|
||||
_pScintillaEditView->showMargin(0, false);
|
||||
_pScintillaEditView->showMargin(1, false);
|
||||
_pScintillaEditView->showMargin(2, false);
|
||||
_pScintillaEditView->showMargin(3, false);
|
||||
|
||||
_pScintillaEditView->display();
|
||||
/*
|
||||
_glassHandle = ::CreateWindowEx(0,//TEXT("Static"),
|
||||
TEXT("STATIC"), TEXT("STATIC"),
|
||||
WS_CHILD | WS_VISIBLE | SS_OWNERDRAW,
|
||||
0,
|
||||
0,
|
||||
100,
|
||||
100,
|
||||
_hSelf,
|
||||
(HMENU) NULL,
|
||||
::GetModuleHandle(NULL),
|
||||
NULL);
|
||||
::ShowWindow(_glassHandle, SW_SHOW);
|
||||
*/
|
||||
_vzDlg.init(::GetModuleHandle(NULL), _hSelf);
|
||||
_vzDlg.doDialog();
|
||||
(NppParameters::getInstance())->SetTransparent(_vzDlg.getHSelf(), 100); // 0 <= transparancy < 256
|
||||
return TRUE;
|
||||
}
|
||||
case WM_DESTROY:
|
||||
{
|
||||
//::SendMessage(_hParent, NPPM_DESTROYSCINTILLAHANDLE, 0, (LPARAM)_pScintillaEditView->getHSelf());
|
||||
//printStr(TEXT("fw"));
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
case WM_SIZE:
|
||||
{
|
||||
if (_pScintillaEditView)
|
||||
{
|
||||
int width = LOWORD(lParam);
|
||||
int height = HIWORD(lParam);
|
||||
::MoveWindow(_pScintillaEditView->getHSelf(), 0, 0, width , height, TRUE);
|
||||
|
||||
if (_vzDlg.isCreated())
|
||||
{
|
||||
POINT pt = {0,0};
|
||||
::ClientToScreen(_pScintillaEditView->getHSelf(), &pt);
|
||||
::MoveWindow(_vzDlg.getHSelf(), pt.x, pt.y, width-4, height-4, TRUE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_NOTIFY:
|
||||
{
|
||||
switch (((LPNMHDR)lParam)->code)
|
||||
{
|
||||
case NM_DBLCLK:
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
case DOCUMENTMAP_SCROLL:
|
||||
{
|
||||
bool dir = (wParam != 0);
|
||||
moveMode mode = (lParam == 0)?perLine:perPage;
|
||||
scrollMap(dir, mode);
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
case DOCUMENTMAP_MOUSECLICKED:
|
||||
{
|
||||
int newPosY = HIWORD(lParam);
|
||||
int currentCenterPosY = _vzDlg.getCurrentCenterPosY();
|
||||
//int currentHeight = _vzDlg.getViewerHeight();
|
||||
|
||||
bool dir = (newPosY < currentCenterPosY)?moveUp:moveDown;
|
||||
int pixelPerLine = _pScintillaEditView->execute(SCI_TEXTHEIGHT, 0);
|
||||
|
||||
int jumpDistance;
|
||||
if (dir == moveUp)
|
||||
{
|
||||
jumpDistance = currentCenterPosY - newPosY;
|
||||
int nbLine2jump = jumpDistance/pixelPerLine;
|
||||
int firstVisibleLine = (*_ppEditView)->execute(SCI_GETFIRSTVISIBLELINE);
|
||||
firstVisibleLine -= nbLine2jump;
|
||||
if (firstVisibleLine < 0)
|
||||
firstVisibleLine = 0;
|
||||
(*_ppEditView)->execute(SCI_GOTOLINE, firstVisibleLine);
|
||||
}
|
||||
else
|
||||
{
|
||||
jumpDistance = newPosY - currentCenterPosY;
|
||||
int nbLine2jump = jumpDistance/pixelPerLine;
|
||||
int firstVisibleLine = (*_ppEditView)->execute(SCI_GETFIRSTVISIBLELINE);
|
||||
int nbLine = (*_ppEditView)->execute(SCI_LINESONSCREEN, firstVisibleLine);
|
||||
int lastVisibleLine = firstVisibleLine + nbLine;
|
||||
|
||||
lastVisibleLine += nbLine2jump;
|
||||
(*_ppEditView)->execute(SCI_GOTOLINE, lastVisibleLine);
|
||||
}
|
||||
scrollMap();
|
||||
|
||||
/*
|
||||
int newHigher = newPosY - (currentHeight / 2);
|
||||
int newLower = newPosY + (currentHeight / 2);
|
||||
|
||||
if (newHigher < 0)
|
||||
{
|
||||
newHigher = 0;
|
||||
newLower = currentHeight;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
default :
|
||||
return DockingDlgInterface::run_dlgProc(message, wParam, lParam);
|
||||
}
|
||||
return DockingDlgInterface::run_dlgProc(message, wParam, lParam);
|
||||
}
|
||||
|
||||
void ViewZoneDlg::drawPreviewZone(DRAWITEMSTRUCT *pdis)
|
||||
{
|
||||
//switch (pdis->itemAction)
|
||||
{
|
||||
//case ODA_DRAWENTIRE:
|
||||
//switch (pdis->CtlID)
|
||||
{
|
||||
//case IDC_GLASS:
|
||||
{
|
||||
RECT rc = pdis->rcItem;
|
||||
|
||||
//const COLORREF red = RGB(0xFF, 0x00, 0x00);
|
||||
//const COLORREF yellow = RGB(0xFF, 0xFF, 0);
|
||||
//const COLORREF grey = RGB(128, 128, 128);
|
||||
const COLORREF orange = RGB(0xFF, 0x80, 0x00);
|
||||
//const COLORREF liteGrey = RGB(192, 192, 192);
|
||||
const COLORREF white = RGB(0xFF, 0xFF, 0xFF);
|
||||
HBRUSH hbrushFg = CreateSolidBrush(orange);
|
||||
HBRUSH hbrushBg = CreateSolidBrush(white);
|
||||
FillRect(pdis->hDC, &rc, hbrushBg);
|
||||
|
||||
rc.top = _higherY;
|
||||
rc.bottom = _lowerY;
|
||||
FillRect(pdis->hDC, &rc, hbrushFg);
|
||||
/*
|
||||
HPEN hpen = CreatePen(PS_SOLID, 1, RGB(0x00, 0x00, 0x00));
|
||||
HPEN holdPen = (HPEN)SelectObject(pdis->hDC, hpen);
|
||||
|
||||
::MoveToEx(pdis->hDC, 0 , _higherY , NULL);
|
||||
::LineTo(pdis->hDC, rc.left, _higherY);
|
||||
::MoveToEx(pdis->hDC, 0 , _lowerY , NULL);
|
||||
::LineTo(pdis->hDC, rc.left, _lowerY);
|
||||
|
||||
SelectObject(pdis->hDC, holdPen);
|
||||
DeleteObject(hpen);
|
||||
*/
|
||||
|
||||
|
||||
DeleteObject(hbrushFg);
|
||||
DeleteObject(hbrushBg);
|
||||
//FrameRect(pdis->hDC, &rc, (HBRUSH) GetStockObject(GRAY_BRUSH));
|
||||
//break;
|
||||
}
|
||||
}
|
||||
// *** FALL THROUGH ***
|
||||
/*
|
||||
case ODA_SELECT:
|
||||
break;
|
||||
case ODA_FOCUS:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
void ViewZoneDlg::doDialog()
|
||||
{
|
||||
if (!isCreated())
|
||||
create(IDD_VIEWZONE);
|
||||
display();
|
||||
};
|
||||
|
||||
BOOL CALLBACK ViewZoneDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG :
|
||||
{
|
||||
_viewZoneCanvas = ::GetDlgItem(_hSelf, IDC_VIEWZONECANVAS);
|
||||
::SetWindowLongPtrW(_viewZoneCanvas, GWL_USERDATA, reinterpret_cast<LONG>(this));
|
||||
_canvasDefaultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_viewZoneCanvas, GWL_WNDPROC, reinterpret_cast<LONG>(canvasStaticProc)));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_LBUTTONDOWN:
|
||||
{
|
||||
::SendMessage(_hParent, DOCUMENTMAP_MOUSECLICKED, wParam, lParam);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
{
|
||||
if (wParam & MK_LBUTTON)
|
||||
::SendMessage(_hParent, DOCUMENTMAP_MOUSECLICKED, wParam, lParam);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_DRAWITEM :
|
||||
{
|
||||
drawPreviewZone((DRAWITEMSTRUCT *)lParam);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_SIZE:
|
||||
{
|
||||
if (_viewZoneCanvas)
|
||||
{
|
||||
int width = LOWORD(lParam);
|
||||
int height = HIWORD(lParam);
|
||||
//::SetWindowPos(_pScintillaEditView->getHSelf(), _glassHandle, 0, 0, width, height, SWP_SHOWWINDOW);
|
||||
::MoveWindow(_viewZoneCanvas, 0, 0, width , height, TRUE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_COMMAND :
|
||||
{/*
|
||||
switch (wParam)
|
||||
{
|
||||
case IDCANCEL :
|
||||
case IDOK :
|
||||
display(false);
|
||||
return TRUE;
|
||||
|
||||
default :
|
||||
break;
|
||||
}
|
||||
*/
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_DESTROY :
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL CALLBACK ViewZoneDlg::canvasStaticProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
ViewZoneDlg *pViewZoneDlg = reinterpret_cast<ViewZoneDlg *>(::GetWindowLongPtr(hwnd, GWL_USERDATA));
|
||||
if (!pViewZoneDlg)
|
||||
return FALSE;
|
||||
return pViewZoneDlg->canvas_runProc(hwnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
BOOL CALLBACK ViewZoneDlg::canvas_runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_DESTROY:
|
||||
{
|
||||
::MessageBoxA(NULL,"Destroy","",MB_OK);
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
case WM_KEYDOWN:
|
||||
if (wParam == VK_UP)
|
||||
{
|
||||
::SendMessage(_hParent, DOCUMENTMAP_SCROLL, (WPARAM)moveUp, 0);
|
||||
}
|
||||
if (wParam == VK_DOWN)
|
||||
{
|
||||
::SendMessage(_hParent, DOCUMENTMAP_SCROLL, (WPARAM)moveDown, 0);
|
||||
}
|
||||
if (wParam == VK_PRIOR)
|
||||
{
|
||||
::SendMessage(_hParent, DOCUMENTMAP_SCROLL, (WPARAM)moveUp, 1);
|
||||
}
|
||||
if (wParam == VK_NEXT)
|
||||
{
|
||||
::SendMessage(_hParent, DOCUMENTMAP_SCROLL, (WPARAM)moveDown, 1);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_SIZE:
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_NOTIFY:
|
||||
{
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
default :
|
||||
return _canvasDefaultProc(hwnd, message, wParam, lParam);
|
||||
}
|
||||
return _canvasDefaultProc(hwnd, message, wParam, lParam);
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
this file is part of notepad++
|
||||
Copyright (C)2003 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 DOCUMENTMAP_H
|
||||
#define DOCUMENTMAP_H
|
||||
|
||||
#ifndef DOCKINGDLGINTERFACE_H
|
||||
#include "DockingDlgInterface.h"
|
||||
#endif //DOCKINGDLGINTERFACE_H
|
||||
|
||||
#include "documentMap_rc.h"
|
||||
|
||||
#define DOCUMENTMAP_SCROLL (WM_USER + 1)
|
||||
#define DOCUMENTMAP_MOUSECLICKED (WM_USER + 2)
|
||||
|
||||
class ScintillaEditView;
|
||||
const bool moveDown = true;
|
||||
const bool moveUp = false;
|
||||
|
||||
enum moveMode {
|
||||
perLine,
|
||||
perPage
|
||||
};
|
||||
|
||||
class ViewZoneDlg : public StaticDialog
|
||||
{
|
||||
public :
|
||||
ViewZoneDlg() : StaticDialog() {};
|
||||
|
||||
void doDialog();
|
||||
|
||||
virtual void destroy() {
|
||||
};
|
||||
|
||||
void drawZone(long hY, long lY) {
|
||||
_higherY = hY;
|
||||
_lowerY = lY;
|
||||
::InvalidateRect(_viewZoneCanvas, NULL, TRUE);
|
||||
};
|
||||
|
||||
int getViewerHeight() const {
|
||||
return (_lowerY - _higherY);
|
||||
};
|
||||
|
||||
int getCurrentCenterPosY() const {
|
||||
return (_lowerY - _higherY)/2 + _higherY;
|
||||
};
|
||||
|
||||
protected :
|
||||
virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
static BOOL CALLBACK canvasStaticProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
BOOL CALLBACK canvas_runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
void drawPreviewZone(DRAWITEMSTRUCT *pdis);
|
||||
|
||||
private :
|
||||
HWND _viewZoneCanvas;
|
||||
WNDPROC _canvasDefaultProc;
|
||||
|
||||
long _higherY;
|
||||
long _lowerY;
|
||||
};
|
||||
|
||||
|
||||
class DocumentMap : public DockingDlgInterface {
|
||||
public:
|
||||
DocumentMap(): DockingDlgInterface(IDD_DOCUMENTMAP), _ppEditView(NULL), _pScintillaEditView(NULL)
|
||||
{};
|
||||
|
||||
void init(HINSTANCE hInst, HWND hPere, ScintillaEditView **ppEditView) {
|
||||
DockingDlgInterface::init(hInst, hPere);
|
||||
_ppEditView = ppEditView;
|
||||
};
|
||||
|
||||
virtual void display(bool toShow = true) const {
|
||||
DockingDlgInterface::display(toShow);
|
||||
};
|
||||
|
||||
void setParent(HWND parent2set){
|
||||
_hParent = parent2set;
|
||||
};
|
||||
|
||||
void reloadMap();
|
||||
void scrollMap();
|
||||
void scrollMap(bool direction, moveMode whichMode);
|
||||
|
||||
protected:
|
||||
virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
private:
|
||||
ScintillaEditView **_ppEditView;
|
||||
ScintillaEditView *_pScintillaEditView;
|
||||
//HWND _glassHandle;
|
||||
ViewZoneDlg _vzDlg;
|
||||
};
|
||||
|
||||
|
||||
#endif // DOCUMENTMAP_H
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
this file is part of notepad++
|
||||
Copyright (C)2003 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 "documentMap_rc.h"
|
||||
|
||||
IDD_DOCUMENTMAP DIALOGEX 26, 41, 142, 324
|
||||
STYLE DS_SETFONT | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
EXSTYLE WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE
|
||||
CAPTION "Document Map"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x0
|
||||
BEGIN
|
||||
END
|
||||
|
||||
IDD_VIEWZONE DIALOGEX 26, 41, 200, 200
|
||||
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x0
|
||||
BEGIN
|
||||
CONTROL "",IDC_VIEWZONECANVAS,"Static",SS_OWNERDRAW,0,0,50,14
|
||||
END
|
|
@ -0,0 +1,26 @@
|
|||
//this file is part of notepad++
|
||||
//Copyright (C)2003 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 DOCUMENTMAP_RC_H
|
||||
#define DOCUMENTMAP_RC_H
|
||||
|
||||
#define IDD_DOCUMENTMAP 3300
|
||||
#define IDD_VIEWZONE 3320
|
||||
#define IDC_VIEWZONECANVAS (IDD_VIEWZONE + 1)
|
||||
|
||||
#endif // DOCUMENTMAP_RC_H
|
||||
|
|
@ -245,7 +245,8 @@
|
|||
#define IDM_VIEW_FILESWITCHER_PANEL (IDM_VIEW + 70)
|
||||
#define IDM_VIEW_SWITCHTO_OTHER_VIEW (IDM_VIEW + 72)
|
||||
|
||||
//#define IDM_VIEW_LAUNCH_PROJECT_PANEL (IDM_VIEW + 80)
|
||||
#define IDM_VIEW_DOC_MAP (IDM_VIEW + 80)
|
||||
|
||||
#define IDM_VIEW_PROJECT_PANEL_1 (IDM_VIEW + 81)
|
||||
#define IDM_VIEW_PROJECT_PANEL_2 (IDM_VIEW + 82)
|
||||
#define IDM_VIEW_PROJECT_PANEL_3 (IDM_VIEW + 83)
|
||||
|
|
|
@ -311,6 +311,11 @@
|
|||
|
||||
//See ProjectPanel_rc.h
|
||||
//#define IDD_PROJECTPANEL 3100
|
||||
//#define IDD_FILERELOCALIZER_DIALOG 3200
|
||||
|
||||
//See documentMap_rc.h
|
||||
//#define IDD_DOCUMENTMAP 3300
|
||||
|
||||
|
||||
// See regExtDlg.h
|
||||
//#define IDD_REGEXT 4000
|
||||
|
@ -358,6 +363,7 @@
|
|||
#define NPPM_INTERNAL_SCINTILLAFINFEROPENALL (NOTEPADPLUS_USER_INTERNAL + 34)
|
||||
#define NPPM_INTERNAL_RECENTFILELIST_UPDATE (NOTEPADPLUS_USER_INTERNAL + 35)
|
||||
#define NPPM_INTERNAL_RECENTFILELIST_SWITCH (NOTEPADPLUS_USER_INTERNAL + 36)
|
||||
#define NPPM_INTERNAL_GETSCINTEDTVIEW (NOTEPADPLUS_USER_INTERNAL + 37)
|
||||
|
||||
//wParam: 0
|
||||
//lParam: document new index
|
||||
|
|
|
@ -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;..\src\WinControls\ProjectPanel"
|
||||
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;..\src\WinControls\DocumentMap"
|
||||
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"
|
||||
|
@ -563,6 +563,10 @@
|
|||
RelativePath="..\src\ScitillaComponent\DocTabView.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\WinControls\DocumentMap\documentMap.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\EncodingMapper.cpp"
|
||||
>
|
||||
|
@ -929,6 +933,10 @@
|
|||
RelativePath="..\src\WinControls\DockingWnd\DockingGUIWidget.rc"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\WinControls\DocumentMap\documentMap.rc"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\cursors\drag.cur"
|
||||
>
|
||||
|
@ -1486,6 +1494,14 @@
|
|||
RelativePath="..\src\ScitillaComponent\DocTabView.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\WinControls\DocumentMap\documentMap.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\WinControls\DocumentMap\documentMapl_rc.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\EncodingMapper.h"
|
||||
>
|
||||
|
@ -1614,10 +1630,6 @@
|
|||
RelativePath="..\src\resource.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\WinControls\Preference\resource.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\WinControls\StaticDialog\RunDlg\RunDlg.h"
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue