minor code cleanup for future refactoring

This commit is contained in:
Damien GERARD 2015-08-06 11:03:57 +02:00
parent ba5d36e2bf
commit 366a393f13
19 changed files with 2251 additions and 2152 deletions

View File

@ -29,6 +29,7 @@
#include <string>
#include <windows.h>
#include <iso646.h>
#include <cstdint>
const bool dirUp = true;

View File

@ -362,7 +362,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
bool isVertical = (nppGUI._splitterPos == POS_VERTICAL);
_subSplitter.init(_pPublicInterface->getHinst(), hwnd);
_subSplitter.create(&_mainDocTab, &_subDocTab, 8, DYNAMIC, 50, isVertical);
_subSplitter.create(&_mainDocTab, &_subDocTab, 8, SplitterMode::DYNAMIC, 50, isVertical);
//--Status Bar Section--//
bool willBeShown = nppGUI._statusBarShow;
@ -3240,7 +3240,7 @@ void Notepad_plus::dockUserDlg()
else
pWindow = _pDocTab;
_pMainSplitter->create(pWindow, ScintillaEditView::getUserDefineDlg(), 8, RIGHT_FIX, 45);
_pMainSplitter->create(pWindow, ScintillaEditView::getUserDefineDlg(), 8, SplitterMode::RIGHT_FIX, 45);
}
if (bothActive())

View File

@ -24,13 +24,11 @@
// 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 NOTEPAD_PLUS_WINDOW_H
#define NOTEPAD_PLUS_WINDOW_H
#pragma once
#include "Notepad_plus.h"
const TCHAR COMMAND_ARG_HELP[] = TEXT("Usage :\r\
\r\
notepad++ [--help] [-multiInst] [-noPlugin] [-lLanguage] [-LlangCode] [-nLineNumber] [-cColumnNumber] [-xLeftPos] [-yTopPos] [-nosession] [-notabbar] [-ro] [-systemtray] [-loadingTime] [-alwaysOnTop] [-openSession] [-r] [-qnEsterEggName | -qtText | -qfCntentFileName] [filePath]\r\
@ -59,47 +57,57 @@ notepad++ [--help] [-multiInst] [-noPlugin] [-lLanguage] [-LlangCode] [-nLineNum
filePath : file or folder name to open (absolute or relative path name)\r\
");
class Notepad_plus_Window : public Window {
class Notepad_plus_Window : public Window
{
public:
Notepad_plus_Window() : _isPrelaunch(false), _disablePluginsManager(false) {};
void init(HINSTANCE, HWND, const TCHAR *cmdLine, CmdLineParams *cmdLineParams);
bool isDlgsMsg(MSG *msg) const;
HACCEL getAccTable() const {
HACCEL getAccTable() const
{
return _notepad_plus_plus_core.getAccTable();
};
}
bool emergency(generic_string emergencySavedDir) {
bool emergency(generic_string emergencySavedDir)
{
return _notepad_plus_plus_core.emergency(emergencySavedDir);
};
}
bool isPrelaunch() const {
bool isPrelaunch() const
{
return _isPrelaunch;
};
}
void setIsPrelaunch(bool val) {
void setIsPrelaunch(bool val)
{
_isPrelaunch = val;
};
}
virtual void destroy(){
virtual void destroy()
{
::DestroyWindow(_hSelf);
};
}
static const TCHAR * getClassName() {
static const TCHAR * getClassName()
{
return _className;
};
}
static HWND gNppHWND; //static handle to Notepad++ window, NULL if non-existant
private:
Notepad_plus _notepad_plus_plus_core;
static LRESULT CALLBACK Notepad_plus_Proc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
LRESULT runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
static const TCHAR _className[32];
bool _isPrelaunch;
bool _disablePluginsManager;
bool _isPrelaunch = false;
bool _disablePluginsManager = false;
std::string _userQuote; // keep the availability of this string for thread using
};
#endif //NOTEPAD_PLUS_WINDOW_H

View File

@ -43,7 +43,10 @@ using namespace std;
#define WM_DPICHANGED 0x02E0
struct SortTaskListPred
struct SortTaskListPred final
{
DocTabView *_views[2];
@ -70,13 +73,13 @@ LRESULT CALLBACK Notepad_plus_Window::Notepad_plus_Proc(HWND hwnd, UINT Message,
switch(Message)
{
case WM_NCCREATE : // First message we get the ptr of instantiated object
// then stock it into GWLP_USERDATA index in order to retrieve afterward
case WM_NCCREATE:
{
// First message we get the ptr of instantiated object
// then stock it into GWLP_USERDATA index in order to retrieve afterward
Notepad_plus_Window *pM30ide = (Notepad_plus_Window *)(((LPCREATESTRUCT)lParam)->lpCreateParams);
pM30ide->_hSelf = hwnd;
::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pM30ide);
return TRUE;
}
@ -87,27 +90,32 @@ LRESULT CALLBACK Notepad_plus_Window::Notepad_plus_Proc(HWND hwnd, UINT Message,
}
}
LRESULT Notepad_plus_Window::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
LRESULT result = FALSE;
switch (Message)
{
case WM_CREATE:
{
try{
try
{
_notepad_plus_plus_core._pPublicInterface = this;
result = _notepad_plus_plus_core.init(hwnd);
} catch (std::exception ex) {
return _notepad_plus_plus_core.init(hwnd);
}
catch (std::exception ex)
{
::MessageBoxA(_notepad_plus_plus_core._pPublicInterface->getHSelf(), ex.what(), "Exception On WM_CREATE", MB_OK);
exit(-1);
}
}
break;
}
default:
{
if (this)
return _notepad_plus_plus_core.process(hwnd, Message, wParam, lParam);
}
return result;
}
return FALSE;
}
@ -129,9 +137,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
{
DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)lParam;
if (dis->CtlType == ODT_TAB)
{
return ::SendMessage(dis->hwndItem, WM_DRAWITEM, wParam, lParam);
}
break;
}
case WM_DOCK_USERDEFINE_DLG:
@ -151,13 +158,13 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
TCHAR *userLangName = (TCHAR *)lParam;
if (!userLangName || !userLangName[0])
return FALSE;
generic_string name(userLangName);
generic_string name{userLangName};
//loop through buffers and reset the language (L_USER, TEXT("")) if (L_USER, name)
Buffer * buf;
for (int i = 0; i < MainFileManager->getNrBuffers(); ++i)
{
buf = MainFileManager->getBufferByIndex(i);
Buffer* buf = MainFileManager->getBufferByIndex(i);
if (buf->getLangType() == L_USER && name == buf->getUserDefineLangName())
buf->setLangType(L_USER, TEXT(""));
}
@ -169,14 +176,13 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
if (!lParam || !(((TCHAR *)lParam)[0]) || !wParam || !(((TCHAR *)wParam)[0]))
return FALSE;
generic_string oldName((TCHAR *)lParam);
generic_string newName((TCHAR *)wParam);
generic_string oldName{(TCHAR *)lParam};
generic_string newName{(TCHAR *)wParam};
//loop through buffers and reset the language (L_USER, newName) if (L_USER, oldName)
Buffer * buf;
for (int i = 0; i < MainFileManager->getNrBuffers(); ++i)
{
buf = MainFileManager->getBufferByIndex(i);
Buffer* buf = MainFileManager->getBufferByIndex(i);
if (buf->getLangType() == L_USER && oldName == buf->getUserDefineLangName())
buf->setLangType(L_USER, newName.c_str());
}
@ -218,13 +224,14 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
replaceInFiles();
return TRUE;
}
case NPPM_LAUNCHFINDINFILESDLG:
{
// Find in files function code should be here due to the number of parameters (2) cannot be passed via WM_COMMAND
const int strSize = FINDREPLACE_MAXLENGTH;
TCHAR str[strSize];
bool isFirstTime = !_findReplaceDlg.isCreated();
bool isFirstTime = not _findReplaceDlg.isCreated();
_findReplaceDlg.doDialog(FIND_DLG, _nativeLangSpeaker.isRTL());
_pEditView->getGenericSelectedText(str, strSize);
@ -233,6 +240,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
_nativeLangSpeaker.changeDlgLang(_findReplaceDlg.getHSelf(), "Find");
_findReplaceDlg.launchFindInFilesDlg();
setFindReplaceFolderFilter((const TCHAR*) wParam, (const TCHAR*) lParam);
return TRUE;
}
@ -241,11 +249,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
{
BufferID id = doOpen((const TCHAR *)lParam);
if (id != BUFFER_INVALID)
{
return switchToFile(id);
}
}
break;
}
case NPPM_INTERNAL_SETFILENAME:
{
@ -259,7 +265,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
}
return FALSE;
}
break;
case NPPM_GETBUFFERLANGTYPE:
{
@ -269,7 +274,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
Buffer * b = MainFileManager->getBufferByID(id);
return b->getLangType();
}
break;
case NPPM_SETBUFFERLANGTYPE:
{
@ -283,7 +287,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
b->setLangType((LangType)lParam);
return TRUE;
}
break;
case NPPM_GETBUFFERENCODING:
{
@ -293,7 +296,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
Buffer * b = MainFileManager->getBufferByID(id);
return b->getUnicodeMode();
}
break;
case NPPM_SETBUFFERENCODING:
{
@ -309,7 +311,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
b->setUnicodeMode((UniMode)lParam);
return TRUE;
}
break;
case NPPM_GETBUFFERFORMAT:
{
@ -319,7 +320,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
Buffer * b = MainFileManager->getBufferByID(id);
return b->getFormat();
}
break;
case NPPM_SETBUFFERFORMAT:
{
@ -333,30 +333,27 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
b->setFormat((formatType)lParam);
return TRUE;
}
break;
case NPPM_GETBUFFERIDFROMPOS:
{
DocTabView * pView = NULL;
if (lParam == MAIN_VIEW) {
DocTabView* pView = nullptr;
if (lParam == MAIN_VIEW)
pView = &_mainDocTab;
} else if (lParam == SUB_VIEW) {
else if (lParam == SUB_VIEW)
pView = &_subDocTab;
} else {
else
return (LRESULT)BUFFER_INVALID;
}
if ((int)wParam < pView->nbItem()) {
if ((int)wParam < pView->nbItem())
return (LRESULT)(pView->getBufferByIndex((int)wParam));
}
return (LRESULT)BUFFER_INVALID;
}
break;
case NPPM_GETCURRENTBUFFERID:
{
return (LRESULT)(_pEditView->getCurrentBufferID());
}
break;
case NPPM_RELOADBUFFERID:
{
@ -364,15 +361,14 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
return FALSE;
return doReload((BufferID)wParam, lParam != 0);
}
break;
case NPPM_RELOADFILE:
{
BufferID id = MainFileManager->getBufferFromName((const TCHAR *)lParam);
if (id != BUFFER_INVALID)
doReload(id, wParam != 0);
}
break;
}
case NPPM_SWITCHTOFILE :
{
@ -386,7 +382,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
{
return fileSave();
}
break;
case NPPM_SAVECURRENTFILEAS:
{
@ -396,19 +391,16 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
if (!filename) return FALSE;
return doSave(currentBufferID, filename, asCopy);
}
break;
case NPPM_SAVEALLFILES:
{
return fileSaveAll();
}
break;
case NPPM_GETCURRENTNATIVELANGENCODING:
{
return _nativeLangSpeaker.getLangEncoding();
}
break;
case NPPM_INTERNAL_DOCORDERCHANGED :
{
@ -422,15 +414,13 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
_pluginsManager.notify(&scnN);
return TRUE;
}
break;
case WM_SIZE:
{
RECT rc;
_pPublicInterface->getClientRect(rc);
if (lParam == 0) {
if (lParam == 0)
lParam = MAKELPARAM(rc.right - rc.left, rc.bottom - rc.top);
}
::MoveWindow(_rebarTop.getHSelf(), 0, 0, rc.right, _rebarTop.getHeight(), TRUE);
_statusBar.adjustParts(rc.right);
@ -450,14 +440,14 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
}
result = TRUE;
}
break;
}
case WM_MOVE:
{
result = TRUE;
}
break;
}
case WM_MOVING:
{
@ -466,14 +456,14 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
_pDocMap->doMove();
}
result = FALSE;
}
break;
}
case WM_SIZING:
{
result = FALSE;
}
break;
}
case WM_COPYDATA:
{
@ -531,8 +521,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
{
command(LOWORD(wParam));
}
}
return TRUE;
}
case NPPM_INTERNAL_SAVECURRENTSESSION:
{
@ -545,20 +535,20 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
getCurrentOpenedFiles(currentSession, true);
nppParam->writeSession(currentSession);
}
}
return TRUE;
}
case NPPM_INTERNAL_RELOADNATIVELANG:
{
reloadLang();
}
return TRUE;
}
case NPPM_INTERNAL_RELOADSTYLERS:
{
loadStyles();
}
return TRUE;
}
case NPPM_INTERNAL_PLUGINSHORTCUTMOTIFIED:
{
@ -567,8 +557,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
scnN.nmhdr.hwndFrom = (void *)lParam; // ShortcutKey structure
scnN.nmhdr.idFrom = (uptr_t)wParam; // cmdID
_pluginsManager.notify(&scnN);
}
return TRUE;
}
case NPPM_GETSHORTCUTBYCMDID:
{
@ -579,8 +569,10 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
}
case NPPM_MENUCOMMAND:
{
command(lParam);
return TRUE;
}
case NPPM_GETFULLCURRENTPATH:
case NPPM_GETCURRENTDIRECTORY:
@ -717,13 +709,15 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_GETOPENFILENAMESSECOND:
case NPPM_GETOPENFILENAMES:
{
if (!wParam) return 0;
if (!wParam)
return 0;
TCHAR** fileNames = (TCHAR**) wParam;
int nbFileNames = lParam;
int j = 0;
if (Message != NPPM_GETOPENFILENAMESSECOND) {
if (Message != NPPM_GETOPENFILENAMESSECOND)
{
for (int i = 0 ; i < _mainDocTab.nbItem() && j < nbFileNames ; ++i)
{
BufferID id = _mainDocTab.getBufferByIndex(i);
@ -731,7 +725,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
lstrcpy(fileNames[j++], buf->getFullPathName());
}
}
if (Message != NPPM_GETOPENFILENAMESPRIMARY) {
if (Message != NPPM_GETOPENFILENAMESPRIMARY)
{
for (int i = 0 ; i < _subDocTab.nbItem() && j < nbFileNames ; ++i)
{
BufferID id = _subDocTab.getBufferByIndex(i);
@ -744,7 +740,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case WM_GETTASKLISTINFO:
{
if (!wParam) return 0;
if (!wParam)
return 0;
TaskListInfo * tli = (TaskListInfo *)wParam;
getTaskListInfo(tli);
@ -761,6 +759,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
}
return TRUE;
}
if (NppParameters::getInstance()->getNppGUI()._styleMRU)
{
tli->_currentIndex = 0;
@ -783,7 +782,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case WM_MOUSEWHEEL:
{
if (LOWORD(wParam) & MK_RBUTTON)
if (0 != (LOWORD(wParam) & MK_RBUTTON))
{
// redirect to the IDC_PREV_DOC or IDC_NEXT_DOC so that we have the unified process
@ -800,11 +799,14 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
{
case APPCOMMAND_BROWSER_BACKWARD:
case APPCOMMAND_BROWSER_FORWARD:
{
int nbDoc = viewVisible(MAIN_VIEW)?_mainDocTab.nbItem():0;
nbDoc += viewVisible(SUB_VIEW)?_subDocTab.nbItem():0;
if (nbDoc > 1)
activateNextDoc((GET_APPCOMMAND_LPARAM(lParam) == APPCOMMAND_BROWSER_FORWARD)?dirDown:dirUp);
_linkTriggered = true;
break;
}
}
return ::DefWindowProc(hwnd, Message, wParam, lParam);
}
@ -812,12 +814,11 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_GETNBSESSIONFILES:
{
const TCHAR *sessionFileName = (const TCHAR *)lParam;
if ((!sessionFileName) || (sessionFileName[0] == '\0')) return 0;
if ((!sessionFileName) || (sessionFileName[0] == '\0'))
return 0;
Session session2Load;
if (pNppParam->loadSession(session2Load, sessionFileName))
{
return session2Load.nbMainFiles() + session2Load.nbSubFiles();
}
return 0;
}
@ -826,7 +827,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
const TCHAR *sessionFileName = (const TCHAR *)lParam;
TCHAR **sessionFileArray = (TCHAR **)wParam;
if ((!sessionFileName) || (sessionFileName[0] == '\0')) return FALSE;
if ((!sessionFileName) || (sessionFileName[0] == '\0'))
return FALSE;
Session session2Load;
if (pNppParam->loadSession(session2Load, sessionFileName))
@ -851,11 +853,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_DECODESCI:
{
// convert to ASCII
Utf8_16_Write UnicodeConvertor;
UINT length = 0;
char* buffer = NULL;
ScintillaEditView *pSci;
if (wParam == MAIN_VIEW)
pSci = &_mainEditView;
else if (wParam == SUB_VIEW)
@ -863,14 +861,14 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
else
return -1;
// get text of current scintilla
length = pSci->execute(SCI_GETTEXTLENGTH, 0, 0) + 1;
buffer = new char[length];
UINT length = pSci->execute(SCI_GETTEXTLENGTH, 0, 0) + 1;
char* buffer = new char[length];
pSci->execute(SCI_GETTEXT, length, (LPARAM)buffer);
// convert here
UniMode unicodeMode = pSci->getCurrentBuffer()->getUnicodeMode();
Utf8_16_Write UnicodeConvertor;
UnicodeConvertor.setEncoding(unicodeMode);
length = UnicodeConvertor.convert(buffer, length-1);
@ -893,11 +891,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_ENCODESCI:
{
// convert
Utf8_16_Read UnicodeConvertor;
UINT length = 0;
char* buffer = NULL;
ScintillaEditView *pSci;
if (wParam == MAIN_VIEW)
pSci = &_mainEditView;
else if (wParam == SUB_VIEW)
@ -906,18 +900,17 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
return -1;
// get text of current scintilla
length = pSci->execute(SCI_GETTEXTLENGTH, 0, 0) + 1;
buffer = new char[length];
UINT length = pSci->execute(SCI_GETTEXTLENGTH, 0, 0) + 1;
char* buffer = new char[length];
pSci->execute(SCI_GETTEXT, length, (LPARAM)buffer);
Utf8_16_Read UnicodeConvertor;
length = UnicodeConvertor.convert(buffer, length-1);
// set text in target
pSci->execute(SCI_CLEARALL);
pSci->addText(length, UnicodeConvertor.getNewBuf());
pSci->execute(SCI_EMPTYUNDOBUFFER);
// set cursor position
@ -968,7 +961,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
for (int i = 0 ; verStr[i] ; ++i)
{
if (verStr[i] == '.')
{
isDot = true;
}
else
{
if (!isDot)
@ -977,6 +972,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
auxVerStr[k++] = verStr[i];
}
}
mainVerStr[j] = '\0';
auxVerStr[k] = '\0';
@ -991,16 +987,23 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
}
case WM_GETCURRENTMACROSTATUS:
if (_recordingMacro) return MACRO_RECORDING_IN_PROGRESS;
{
if (_recordingMacro)
return MACRO_RECORDING_IN_PROGRESS;
return (_macro.empty())?0:MACRO_RECORDING_HAS_STOPPED;
}
case WM_FRSAVE_INT:
{
_macro.push_back(recordedMacroStep(wParam, 0, lParam, NULL, recordedMacroStep::mtSavedSnR));
break;
}
case WM_FRSAVE_STR:
{
_macro.push_back(recordedMacroStep(wParam, 0, 0, (const TCHAR *)lParam, recordedMacroStep::mtSavedSnR));
break;
}
case WM_MACRODLGRUNMACRO:
{
@ -1008,17 +1011,11 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
{
int times = 1;
if (_runMacroDlg.getMode() == RM_RUN_MULTI)
{
times = _runMacroDlg.getTimes();
}
else if (_runMacroDlg.getMode() == RM_RUN_EOF)
{
times = -1;
}
else
{
break;
}
int counter = 0;
int lastLine = int(_pEditView->execute(SCI_GETLINECOUNT)) - 1;
@ -1042,7 +1039,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
++counter;
if ( times >= 0 )
{
if ( counter >= times ) break;
if ( counter >= times )
break;
}
else // run until eof
{
@ -1065,13 +1063,15 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
// eof?
if ((currLine >= lastLine) || (currLine < 0)
|| ((deltaCurrLine == 0) && (currLine == 0) && ((deltaLastLine >= 0) || cursorMovedUp)))
{
break;
}
}
}
_pEditView->execute(SCI_ENDUNDOACTION);
}
}
break;
}
case NPPM_CREATESCINTILLAHANDLE:
{
@ -1089,7 +1089,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
return TRUE;
}
case NPPM_DESTROYSCINTILLAHANDLE:
{
return _scintillaCtrls4Plugins.destroyScintilla((HWND)lParam);
@ -1176,9 +1175,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
{
_mainEditView.execute(SCI_ASSIGNCMDKEY, wParam, lParam);
_subEditView.execute(SCI_ASSIGNCMDKEY, wParam, lParam);
return TRUE;
}
case NPPM_INTERNAL_CMDLIST_MODIFIED:
{
//changeMenuShortcut(lParam, (const TCHAR *)wParam);
@ -1253,22 +1252,30 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
if (wParam == MODELESSDIALOGADD)
{
for (size_t i = 0, len = _hModelessDlgs.size() ; i < len ; ++i)
{
if (_hModelessDlgs[i] == (HWND)lParam)
return NULL;
}
_hModelessDlgs.push_back((HWND)lParam);
return lParam;
}
else if (wParam == MODELESSDIALOGREMOVE)
else
{
if (wParam == MODELESSDIALOGREMOVE)
{
for (size_t i = 0, len = _hModelessDlgs.size(); i < len ; ++i)
{
if (_hModelessDlgs[i] == (HWND)lParam)
{
vector<HWND>::iterator hDlg = _hModelessDlgs.begin() + i;
_hModelessDlgs.erase(hDlg);
return NULL;
}
}
return lParam;
}
}
return TRUE;
}
@ -1282,15 +1289,15 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
{
if ((HWND(wParam) == _mainEditView.getHSelf()) || (HWND(wParam) == _subEditView.getHSelf()))
{
if ((HWND(wParam) == _mainEditView.getHSelf())) {
if ((HWND(wParam) == _mainEditView.getHSelf()))
switchEditViewTo(MAIN_VIEW);
} else {
else
switchEditViewTo(SUB_VIEW);
}
POINT p;
::GetCursorPos(&p);
ContextMenu scintillaContextmenu;
vector<MenuItemUnit> & tmp = pNppParam->getContextMenuItems();
std::vector<MenuItemUnit>& tmp = pNppParam->getContextMenuItems();
scintillaContextmenu.create(_pPublicInterface->getHSelf(), tmp, _mainMenuHandle);
scintillaContextmenu.display(p);
return TRUE;
@ -1405,8 +1412,10 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
}
case WM_ACTIVATE:
{
_pEditView->getFocus();
return TRUE;
}
case WM_DROPFILES:
{
@ -1465,20 +1474,21 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
_pProjectPanel_1->setBackgroundColor(style._bgColor);
_pProjectPanel_1->setForegroundColor(style._fgColor);
}
if (_pProjectPanel_2)
{
_pProjectPanel_2->setBackgroundColor(style._bgColor);
_pProjectPanel_2->setForegroundColor(style._fgColor);
}
if (_pProjectPanel_3)
{
_pProjectPanel_3->setBackgroundColor(style._bgColor);
_pProjectPanel_3->setForegroundColor(style._fgColor);
}
if (_pDocMap)
{
_pDocMap->setSyntaxHiliting();
}
// Notify plugins of update to styles xml
SCNotification scnN;
@ -1512,10 +1522,10 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
bool isSnapshotMode = nppgui.isSnapshotMode();
if (isSnapshotMode)
{
::LockWindowUpdate(_pPublicInterface->getHSelf());
if (isSnapshotMode)
MainFileManager->backupCurrentBuffer();
}
Session currentSession;
if (nppgui._rememberLastSession)
@ -1528,16 +1538,13 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
bool allClosed = fileCloseAll(false, isSnapshotMode); //try closing files before doing anything else
if (nppgui._rememberLastSession)
{
_lastRecentFileList.setLock(false); //only lock when the session is remembered
}
if (!allClosed)
{
//User cancelled the shutdown
scnN.nmhdr.code = NPPN_CANCELSHUTDOWN;
_pluginsManager.notify(&scnN);
return FALSE;
}
@ -1600,6 +1607,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
if (Message == WM_CLOSE)
::DestroyWindow(hwnd);
if (not isSnapshotMode)
::LockWindowUpdate(NULL);
}
return TRUE;
@ -1625,7 +1633,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
NppGUI & nppgui = (NppGUI &)(pNppParam->getNppGUI());
if ((nppgui._isMinimizedToTray || _pPublicInterface->isPrelaunch()) && (wParam == SC_MINIMIZE))
{
if (!_pTrayIco)
if (nullptr == _pTrayIco)
_pTrayIco = new trayIconControler(_pPublicInterface->getHSelf(), IDI_M30ICON, IDC_MINIMIZED_TRAY, ::LoadIcon(_pPublicInterface->getHinst(), MAKEINTRESOURCE(IDI_M30ICON)), TEXT(""));
_pTrayIco->doTrayIcon(ADD);
@ -1657,16 +1665,20 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
{
//case WM_LBUTTONDBLCLK:
case WM_LBUTTONUP :
{
_pEditView->getFocus();
::ShowWindow(_pPublicInterface->getHSelf(), SW_SHOW);
if (!_pPublicInterface->isPrelaunch())
_pTrayIco->doTrayIcon(REMOVE);
::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
return TRUE;
}
case WM_MBUTTONUP:
{
command(IDM_SYSTRAYPOPUP_NEW_AND_PASTE);
return TRUE;
}
case WM_RBUTTONUP:
{
@ -1683,7 +1695,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
DestroyMenu(hmenu);
return TRUE;
}
}
return TRUE;
}
@ -1726,21 +1737,24 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_DMMGETPLUGINHWNDBYNAME : //(const TCHAR *windowName, const TCHAR *moduleName)
{
if (!lParam) return NULL;
if (!lParam)
return NULL;
TCHAR *moduleName = (TCHAR *)lParam;
TCHAR *windowName = (TCHAR *)wParam;
vector<DockingCont *> dockContainer = _dockingManager.getContainerInfo();
std::vector<DockingCont *> dockContainer = _dockingManager.getContainerInfo();
for (size_t i = 0, len = dockContainer.size(); i < len ; ++i)
{
vector<tTbData *> tbData = dockContainer[i]->getDataOfAllTb();
std::vector<tTbData *> tbData = dockContainer[i]->getDataOfAllTb();
for (size_t j = 0, len2 = tbData.size() ; j < len2 ; ++j)
{
if (generic_stricmp(moduleName, tbData[j]->pszModuleName) == 0)
{
if (!windowName)
return (LRESULT)tbData[j]->hClient;
else if (generic_stricmp(windowName, tbData[j]->pszName) == 0)
if (generic_stricmp(windowName, tbData[j]->pszName) == 0)
return (LRESULT)tbData[j]->hClient;
}
}
@ -1806,13 +1820,19 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
}
case NPPM_ALLOCATESUPPORTED:
{
return TRUE;
}
case NPPM_ALLOCATECMDID:
{
return _pluginsManager.allocateCmdID(wParam, reinterpret_cast<int *>(lParam));
}
case NPPM_ALLOCATEMARKER:
{
return _pluginsManager.allocateMarker(wParam, reinterpret_cast<int *>(lParam));
}
case NPPM_HIDETABBAR:
{
@ -1831,12 +1851,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
return oldVal;
}
case NPPM_ISTABBARHIDDEN:
{
return _mainDocTab.getHideTabBarStatus();
}
case NPPM_HIDETOOLBAR:
{
bool show = (lParam != TRUE);
@ -1845,6 +1865,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
_rebarTop.setIDVisible(REBAR_BAR_TOOLBAR, show);
return currentStatus;
}
case NPPM_ISTOOLBARHIDDEN :
{
return !_rebarTop.getIDVisible(REBAR_BAR_TOOLBAR);
@ -1866,6 +1887,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
return isHidden;
}
case NPPM_ISMENUHIDDEN:
{
return (::GetMenu(_pPublicInterface->getHSelf()) == NULL);
@ -1877,9 +1899,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI();
bool oldVal = nppGUI._statusBarShow;
if (show == oldVal)
{
return oldVal;
}
RECT rc;
_pPublicInterface->getClientRect(rc);
@ -1899,31 +1920,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
{
return _activeView;
}
/*
case NPPM_ADDREBAR :
{
if (!lParam)
return FALSE;
_rebarTop.addBand((REBARBANDINFO*)lParam, false);
return TRUE;
}
case NPPM_UPDATEREBAR :
{
if (!lParam || wParam < REBAR_BAR_EXTERNAL)
return FALSE;
_rebarTop.reNew((int)wParam, (REBARBANDINFO*)lParam);
return TRUE;
}
case NPPM_REMOVEREBAR :
{
if (wParam < REBAR_BAR_EXTERNAL)
return FALSE;
_rebarTop.removeBand((int)wParam);
return TRUE;
}
*/
case NPPM_INTERNAL_ISFOCUSEDTAB:
{
HWND hTabToTest = (currentView() == MAIN_VIEW)?_mainDocTab.getHSelf():_subDocTab.getHSelf();
@ -1940,12 +1937,14 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
_pEditView->clearIndicator(SCE_UNIVERSAL_FOUND_STYLE_SMART);
return TRUE;
}
case NPPM_INTERNAL_CLEARINDICATORTAGMATCH:
{
_pEditView->clearIndicator(SCE_UNIVERSAL_TAGMATCH);
_pEditView->clearIndicator(SCE_UNIVERSAL_TAGATTR);
return TRUE;
}
case NPPM_INTERNAL_CLEARINDICATORTAGATTR:
{
_pEditView->clearIndicator(SCE_UNIVERSAL_TAGATTR);
@ -2013,13 +2012,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR:
case NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR:
{
return (Message == NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR?(NppParameters::getInstance())->getCurrentDefaultFgColor():(NppParameters::getInstance())->getCurrentDefaultBgColor());
/*
StyleArray & globalStyles = (NppParameters::getInstance())->getGlobalStylers();
int i = globalStyles.getStylerIndexByID(STYLE_DEFAULT);
Style & style = globalStyles.getStyler(i);
return (Message == NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR?style._fgColor:style._bgColor);
*/
return (Message == NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR
?(NppParameters::getInstance())->getCurrentDefaultFgColor()
:(NppParameters::getInstance())->getCurrentDefaultBgColor());
}
case NPPM_SHOWDOCSWITCHER:
@ -2122,8 +2117,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case WM_DPICHANGED:
{
//printInt(LOWORD(wParam));
//printInt(HIWORD(wParam));
return TRUE;
}
@ -2135,9 +2128,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
switch (nmdlg->type)
{
case WDT_ACTIVATE:
{
activateDoc(nmdlg->curSel);
nmdlg->processed = TRUE;
break;
}
case WDT_SAVE:
{
//loop through nmdlg->nItems, get index and save it
@ -2146,16 +2142,15 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
fileSave(_pDocTab->getBufferByIndex(i));
}
nmdlg->processed = TRUE;
}
break;
}
case WDT_CLOSE:
{
bool closed;
//loop through nmdlg->nItems, get index and close it
for (int i = 0; i < (int)nmdlg->nItems; ++i)
{
closed = fileClose(_pDocTab->getBufferByIndex(nmdlg->Items[i]), currentView());
bool closed = fileClose(_pDocTab->getBufferByIndex(nmdlg->Items[i]), currentView());
UINT pos = nmdlg->Items[i];
// The window list only needs to be rearranged when the file was actually closed
if (closed)
@ -2166,18 +2161,19 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
for (int j = i + 1; j < (int)nmdlg->nItems; ++j)
{
if (nmdlg->Items[j] > pos)
{
nmdlg->Items[j]--;
}
}
}
}
nmdlg->processed = TRUE;
}
break;
}
case WDT_SORT:
{
if (nmdlg->nItems != (unsigned int)_pDocTab->nbItem()) //sanity check, if mismatch just abort
break;
//Collect all buffers
std::vector<BufferID> tempBufs;
for (int i = 0; i < (int)nmdlg->nItems; ++i)
@ -2192,6 +2188,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
activateBuffer(_pDocTab->getBufferByIndex(_pDocTab->getCurrentTabIndex()), currentView());
break;
}
}
return TRUE;
}

View File

@ -1051,7 +1051,7 @@ void Notepad_plus::command(int id)
else
pWindow = _pDocTab;
_pMainSplitter->create(pWindow, ScintillaEditView::getUserDefineDlg(), 8, RIGHT_FIX, 45);
_pMainSplitter->create(pWindow, ScintillaEditView::getUserDefineDlg(), 8, SplitterMode::RIGHT_FIX, 45);
}
_pMainWindow = _pMainSplitter;

View File

@ -36,6 +36,10 @@
using namespace std;
BOOL Notepad_plus::notify(SCNotification *notification)
{
//Important, keep track of which element generated the message
@ -76,9 +80,8 @@ BOOL Notepad_plus::notify(SCNotification *notification)
prevWasEdit = false;
}
}
break;
}
case SCN_SAVEPOINTREACHED:
case SCN_SAVEPOINTLEFT:
@ -105,19 +108,16 @@ BOOL Notepad_plus::notify(SCNotification *notification)
id = MainFileManager->getBufferFromDocument(_fileEditView.execute(SCI_GETDOCPOINTER));
}
else
{
break; //wrong scintilla
}
if (id != BUFFER_INVALID)
{
buf = MainFileManager->getBufferByID(id);
}
else
{
break;
}
}
bool isDirty = notification->nmhdr.code == SCN_SAVEPOINTLEFT;
bool isSnapshotMode = NppParameters::getInstance()->getNppGUI().isSnapshotMode();
if (isSnapshotMode && !isDirty)
@ -131,11 +131,15 @@ BOOL Notepad_plus::notify(SCNotification *notification)
}
case SCN_MODIFYATTEMPTRO:
// on fout rien
{
// nothing to do
break;
}
case SCN_KEY:
{
break;
}
case TCN_TABDROPPEDOUTSIDE:
case TCN_TABDROPPED:
@ -254,9 +258,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
iView = SUB_VIEW;
}
else
{
break;
}
switchEditViewTo(iView);
BufferID bufid = _pDocTab->getBufferByIndex(_pDocTab->getCurrentTabIndex());
@ -407,7 +409,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
if (!_tabPopupMenu.isCreated())
{
vector<MenuItemUnit> itemUnitArray;
std::vector<MenuItemUnit> itemUnitArray;
itemUnitArray.push_back(MenuItemUnit(IDM_FILE_CLOSE, TEXT("Close")));
itemUnitArray.push_back(MenuItemUnit(IDM_FILE_CLOSEALL_BUT_CURRENT, TEXT("Close All BUT This")));
itemUnitArray.push_back(MenuItemUnit(IDM_FILE_CLOSEALL_TOLEFT, TEXT("Close All to the Left")));
@ -488,8 +490,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
case SCN_FOLDINGSTATECHANGED :
{
if ((notification->nmhdr.hwndFrom == _mainEditView.getHSelf())
|| (notification->nmhdr.hwndFrom == _subEditView.getHSelf()))
if ((notification->nmhdr.hwndFrom == _mainEditView.getHSelf()) || (notification->nmhdr.hwndFrom == _subEditView.getHSelf()))
{
int lineClicked = notification->line;
@ -676,8 +677,9 @@ BOOL Notepad_plus::notify(SCNotification *notification)
notifyView->execute(SCI_SETANCHOR, pos);
_isHotspotDblClicked = false;
}
}
break;
}
case SCN_UPDATEUI:
{
@ -725,7 +727,8 @@ BOOL Notepad_plus::notify(SCNotification *notification)
case TTN_GETDISPINFO:
{
try {
try
{
LPTOOLTIPTEXT lpttt = (LPTOOLTIPTEXT)notification;
//Joce's fix
@ -776,22 +779,26 @@ BOOL Notepad_plus::notify(SCNotification *notification)
return TRUE;
}
else
{
return FALSE;
}
} catch (...) {
catch (...)
{
//printStr(TEXT("ToolTip crash is caught!"));
}
}
break;
}
case SCN_ZOOM:
{
break;
}
case SCN_MACRORECORD:
{
_macro.push_back(recordedMacroStep(notification->message, notification->wParam, notification->lParam, _pEditView->execute(SCI_GETCODEPAGE)));
break;
}
case SCN_PAINTED:
{
@ -876,10 +883,9 @@ BOOL Notepad_plus::notify(SCNotification *notification)
int end = notifyView->execute(SCI_LINEFROMPOSITION, notification->position + notification->length);
int firstLine = begin < end ? begin : end;
int lastLine = begin > end ? begin : end;
for (int line = firstLine; line <= lastLine; ++line)
{
notifyView->execute(SCI_ENSUREVISIBLE, line, 0);
}
break;
}
@ -895,12 +901,14 @@ BOOL Notepad_plus::notify(SCNotification *notification)
SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
break;
}
case RBN_CHEVRONPUSHED:
{
NMREBARCHEVRON * lpnm = (NMREBARCHEVRON*) notification;
ReBar * notifRebar = &_rebarTop;
if (_rebarBottom.getHSelf() == lpnm->hdr.hwndFrom)
notifRebar = &_rebarBottom;
//If N++ ID, use proper object
if (lpnm->wID == REBAR_BAR_TOOLBAR)
{
@ -911,6 +919,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
_toolBar.doPopop(pt);
return TRUE;
}
//Else forward notification to window of rebarband
REBARBANDINFO rbBand;
ZeroMemory(&rbBand, REBARBAND_SIZE);

View File

@ -24,12 +24,13 @@
// 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 <iostream>
#include "ColourPicker.h"
#include "ColourPopup.h"
void ColourPicker::init(HINSTANCE hInst, HWND parent)
{
Window::init(hInst, parent);
@ -40,31 +41,24 @@ void ColourPicker::init(HINSTANCE hInst, HWND parent)
TEXT("F"),
WS_CHILD | WS_VISIBLE,
0, 0, 25, 25,
_hParent,
NULL,
_hInst,
(LPVOID)0);
if (!_hSelf)
{
throw std::runtime_error("ColourPicker::init : CreateWindowEx() function return null");
}
_hParent, NULL, _hInst, (LPVOID)0);
if (!_hSelf)
throw std::runtime_error("ColourPicker::init : CreateWindowEx() function return null");
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR)this);
_buttonDefaultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, (LONG_PTR)staticWinProc));
}
void ColourPicker::destroy()
{
if (_pColourPopup)
{
delete _pColourPopup;
_pColourPopup = NULL;
}
::DestroyWindow(_hSelf);
}
void ColourPicker::drawBackground(HDC hDC)
{
RECT rc;
@ -82,6 +76,7 @@ void ColourPicker::drawBackground(HDC hDC)
::DeleteObject(hbrush);
}
void ColourPicker::drawForeground(HDC hDC)
{
RECT rc;
@ -107,6 +102,7 @@ void ColourPicker::drawForeground(HDC hDC)
::SetBkMode(hDC, oldMode);
}
LRESULT ColourPicker::runProc(UINT Message, WPARAM wParam, LPARAM lParam)
{
switch (Message)
@ -136,6 +132,7 @@ LRESULT ColourPicker::runProc(UINT Message, WPARAM wParam, LPARAM lParam)
}
return TRUE;
}
case WM_RBUTTONDOWN:
{
_isEnabled = !_isEnabled;
@ -182,11 +179,14 @@ LRESULT ColourPicker::runProc(UINT Message, WPARAM wParam, LPARAM lParam)
}
case WM_PICKUP_CANCEL:
{
_pColourPopup->display(false);
return TRUE;
}
default:
return ::CallWindowProc(_buttonDefaultProc, _hSelf, Message, wParam, lParam);
}
return FALSE;
}

View File

@ -24,62 +24,54 @@
// 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 COLOUR_POPUP_H
#define COLOUR_POPUP_H
#ifndef COLOUR_POPUP_RESOURCE_H
#pragma once
#include "ColourPopupResource.h"
#endif //COLOUR_POPUP_RESOURCE_H
#ifndef RESOURCE_H
#include "resource.h"
#endif //RESOURCE_H
#include "Window.h"
#define WM_PICKUP_COLOR (COLOURPOPUP_USER + 1)
#define WM_PICKUP_CANCEL (COLOURPOPUP_USER + 2)
class ColourPopup : public Window
{
public :
ColourPopup() : Window()/*, isColourChooserLaunched(false)*/ {};
ColourPopup(COLORREF defaultColor) : Window(), /* isColourChooserLaunched(false), */ _colour(defaultColor) {};
~ColourPopup(){};
ColourPopup() = default;
explicit ColourPopup(COLORREF defaultColor) : _colour(defaultColor) {}
virtual ~ColourPopup() {}
bool isCreated() const {
bool isCreated() const
{
return (_hSelf != NULL);
};
}
void create(int dialogID);
void doDialog(POINT p) {
void doDialog(POINT p)
{
if (!isCreated())
create(IDD_COLOUR_POPUP);
::SetWindowPos(_hSelf, HWND_TOP, p.x, p.y, _rc.right - _rc.left, _rc.bottom - _rc.top, SWP_SHOWWINDOW);
};
}
virtual void destroy() {
virtual void destroy()
{
::DestroyWindow(_hSelf);
};
}
void setColour(COLORREF c) {
void setColour(COLORREF c)
{
_colour = c;
};
}
COLORREF getSelColour(){return _colour;};
private :
RECT _rc;
COLORREF _colour;
//bool isColourChooserLaunched;
//bool isColourChooserLaunched = false;
static INT_PTR CALLBACK dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
};
#endif //COLOUR_POPUP_H

View File

@ -24,11 +24,7 @@
// 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 COLOUR_POPUP_RESOURCE_H
#pragma once
#define IDD_COLOUR_POPUP 2100
#define IDC_COLOUR_LIST (IDD_COLOUR_POPUP + 1)
#endif //COLOUR_POPUP_RESOURCE_H

View File

@ -142,9 +142,8 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
_pBgColour->init(_hInst, _hSelf);
POINT p1, p2;
alignWith(_hFgColourStaticText, _pFgColour->getHSelf(), ALIGNPOS_RIGHT, p1);
alignWith(_hBgColourStaticText, _pBgColour->getHSelf(), ALIGNPOS_RIGHT, p2);
alignWith(_hFgColourStaticText, _pFgColour->getHSelf(), PosAlign::right, p1);
alignWith(_hBgColourStaticText, _pBgColour->getHSelf(), PosAlign::right, p2);
p1.x = p2.x = ((p1.x > p2.x)?p1.x:p2.x) + 10;
p1.y -= 4; p2.y -= 4;
@ -170,7 +169,6 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
goToCenter();
loadLangListFromNppParam();
return TRUE;
}
@ -827,6 +825,7 @@ void WordStyleDlg::setVisualFromStyleList()
const TCHAR *ckwStr = (style._keywords)?style._keywords->c_str():TEXT("");
::SendDlgItemMessage(_hSelf, IDC_USER_KEYWORDS_EDIT, WM_SETTEXT, 0, (LPARAM)(ckwStr));
}
int showOption = shouldBeDisplayed?SW_SHOW:SW_HIDE;
::ShowWindow(::GetDlgItem(_hSelf, IDC_DEF_KEYWORDS_EDIT), showOption);
::ShowWindow(::GetDlgItem(_hSelf, IDC_USER_KEYWORDS_EDIT),showOption);
@ -837,6 +836,7 @@ void WordStyleDlg::setVisualFromStyleList()
redraw();
}
void WordStyleDlg::create(int dialogID, bool isRTL)
{
StaticDialog::create(dialogID, isRTL);
@ -853,6 +853,7 @@ void WordStyleDlg::create(int dialogID, bool isRTL)
}
}
void WordStyleDlg::apply()
{
LexerStylerArray & lsa = (NppParameters::getInstance())->getLStylerArray();

View File

@ -24,8 +24,6 @@
// 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 <iostream>
#include <windows.h>
#include "Splitter.h"
@ -38,28 +36,24 @@ bool Splitter::_isVerticalFixedRegistered = false;
#define SPLITTER_SIZE 8
Splitter::Splitter() : Window()
Splitter::Splitter()
{
//hInstance = GetModuleHandle(NULL);
_rect.left = 0; // x axis
_rect.top = 0; // y axis
_rect.right = 0; // Width of the spliter.
_rect.bottom = 0; // Height of the spliter
_isFixed = false;
}
void Splitter::init( HINSTANCE hInst, HWND hPere, int splitterSize,
double iSplitRatio, DWORD dwFlags)
void Splitter::init( HINSTANCE hInst, HWND hPere, int splitterSize, double iSplitRatio, DWORD dwFlags)
{
if (hPere == NULL)
{
throw std::runtime_error("Splitter::init : Parameter hPere is null");
}
if (iSplitRatio < 0)
{
throw std::runtime_error("Splitter::init : Parameter iSplitRatio shoulds be 0 < ratio < 100");
}
Window::init(hInst, hPere);
_spiltterSize = splitterSize;
@ -183,24 +177,14 @@ void Splitter::init( HINSTANCE hInst, HWND hPere, int splitterSize,
_isVerticalFixedRegistered = true;
}
_hSelf = CreateWindowEx(
dwExStyle,
wcex.lpszClassName,
_hSelf = CreateWindowEx(dwExStyle, wcex.lpszClassName,
TEXT(""),
dwStyle,
_rect.left,
_rect.top,
_rect.right,
_rect.bottom,
_hParent,
NULL,
_hInst,
(LPVOID)this);
_rect.left, _rect.top, _rect.right, _rect.bottom,
_hParent, NULL, _hInst, this);
if (!_hSelf)
{
throw std::runtime_error("Splitter::init : CreateWindowEx() function return null");
}
RECT rc;
getClientRect(rc);
@ -209,8 +193,8 @@ void Splitter::init( HINSTANCE hInst, HWND hPere, int splitterSize,
_clickZone2TL.left = rc.left;
_clickZone2TL.top = rc.top;
int clickZoneWidth = getClickZone(WIDTH);
int clickZoneHeight = getClickZone(HEIGHT);
int clickZoneWidth = getClickZone(WH::width);
int clickZoneHeight = getClickZone(WH::height);
_clickZone2TL.right = clickZoneWidth;
_clickZone2TL.bottom = clickZoneHeight;
@ -221,23 +205,33 @@ void Splitter::init( HINSTANCE hInst, HWND hPere, int splitterSize,
display();
::SendMessage(_hParent, WM_RESIZE_CONTAINER, _rect.left, _rect.top);
}
// determinated by (_dwFlags & SV_VERTICAL) && _splitterSize
void Splitter::destroy()
{
::DestroyWindow(_hSelf);
}
int Splitter::getClickZone(WH which)
{
// determinated by (_dwFlags & SV_VERTICAL) && _splitterSize
if (_spiltterSize <= 8)
{
return isVertical()?(which==WIDTH?_spiltterSize:HIEGHT_MINIMAL)
:(which==WIDTH?HIEGHT_MINIMAL:_spiltterSize);
return isVertical()
? (which == WH::width ? _spiltterSize : HIEGHT_MINIMAL)
: (which == WH::width ? HIEGHT_MINIMAL : _spiltterSize);
}
else // (_spiltterSize > 8)
{
return isVertical()?(which==WIDTH? 8:15)
:(which==WIDTH?15:8);
return isVertical()
? ((which == WH::width) ? 8 : 15)
: ((which == WH::width) ? 15 : 8);
}
}
LRESULT CALLBACK Splitter::staticWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
@ -260,23 +254,11 @@ LRESULT CALLBACK Splitter::staticWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LP
}
}
LRESULT CALLBACK Splitter::spliterWndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
/*
case WM_LBUTTONDBLCLK:
{
::MessageBox(NULL, TEXT(""), TEXT(""), MB_OK);
}
return 0;
case WM_RBUTTONDBLCLK:
{
}
return 0;
*/
case WM_LBUTTONDOWN:
{
POINT p;
@ -300,12 +282,15 @@ LRESULT CALLBACK Splitter::spliterWndProc(UINT uMsg, WPARAM wParam, LPARAM lPara
::SetCapture(_hSelf);
_isDraged = true;
}
}
return 0;
}
case WM_RBUTTONDOWN:
{
::SendMessage(_hParent, WM_DOPOPUPMENU, wParam, lParam);
return TRUE;
}
case WM_MOUSEMOVE:
{
@ -386,6 +371,7 @@ LRESULT CALLBACK Splitter::spliterWndProc(UINT uMsg, WPARAM wParam, LPARAM lPara
}
return 0;
}
case WM_CAPTURECHANGED:
{
if (_isDraged)
@ -398,16 +384,22 @@ LRESULT CALLBACK Splitter::spliterWndProc(UINT uMsg, WPARAM wParam, LPARAM lPara
}
case WM_PAINT:
{
drawSplitter();
return 0;
}
case WM_CLOSE:
{
destroy();
return 0;
}
}
return ::DefWindowProc(_hSelf, uMsg, wParam, lParam);
}
void Splitter::resizeSpliter(RECT *pRect)
{
RECT rect;
@ -449,8 +441,8 @@ void Splitter::resizeSpliter(RECT *pRect)
RECT rc;
getClientRect(rc);
_clickZone2BR.right = getClickZone(WIDTH);
_clickZone2BR.bottom = getClickZone(HEIGHT);
_clickZone2BR.right = getClickZone(WH::width);
_clickZone2BR.bottom = getClickZone(WH::height);
_clickZone2BR.left = rc.right - _clickZone2BR.right;
_clickZone2BR.top = rc.bottom - _clickZone2BR.bottom;
@ -460,6 +452,7 @@ void Splitter::resizeSpliter(RECT *pRect)
redraw();
}
void Splitter::gotoTopLeft()
{
if ((_dwFlags & SV_ENABLELDBLCLK) && (!_isFixed) && (_splitPercent > 1))
@ -468,6 +461,7 @@ void Splitter::gotoTopLeft()
_rect.top = 1;
else
_rect.left = 1;
_splitPercent = 1;
::SendMessage(_hParent, WM_RESIZE_CONTAINER, _rect.left, _rect.top);
@ -476,6 +470,7 @@ void Splitter::gotoTopLeft()
}
}
void Splitter::gotoRightBouuom()
{
if ((_dwFlags & SV_ENABLERDBLCLK) && (!_isFixed) && (_splitPercent < 99))
@ -496,6 +491,7 @@ void Splitter::gotoRightBouuom()
}
}
void Splitter::drawSplitter()
{
PAINTSTRUCT ps;
@ -506,9 +502,9 @@ void Splitter::drawSplitter()
if ((_spiltterSize >= 4) && (_dwFlags & SV_RESIZEWTHPERCNT))
{
adjustZoneToDraw(TLrc, TOP_LEFT);
adjustZoneToDraw(BRrc, BOTTOM_RIGHT);
paintArrow(hdc, TLrc, isVertical()?ARROW_LEFT:ARROW_UP);
adjustZoneToDraw(TLrc, ZONE_TYPE::topLeft);
adjustZoneToDraw(BRrc, ZONE_TYPE::bottomRight);
paintArrow(hdc, TLrc, isVertical() ? Arrow::left : Arrow::up);
}
if (isVertical())
@ -563,6 +559,7 @@ void Splitter::drawSplitter()
rcToDraw1.left += 4;
rcToDraw1.right += 4;
}
rcToDraw2.top += 4;
rcToDraw2.bottom += 4;
rcToDraw1.top += 4;
@ -570,16 +567,18 @@ void Splitter::drawSplitter()
}
if ((_spiltterSize >= 4) && (_dwFlags & SV_RESIZEWTHPERCNT))
paintArrow(hdc, BRrc, isVertical()?ARROW_RIGHT:ARROW_DOWN);
paintArrow(hdc, BRrc, isVertical() ? Arrow::right : Arrow::down);
::EndPaint(_hSelf, &ps);
}
void Splitter::rotate()
{
if (!_isFixed)
{
destroy();
if (_dwFlags & SV_HORIZONTAL)
{
_dwFlags ^= SV_HORIZONTAL;
@ -590,28 +589,35 @@ void Splitter::rotate()
_dwFlags ^= SV_VERTICAL;
_dwFlags |= SV_HORIZONTAL;
}
init(_hInst, _hParent, _spiltterSize, _splitPercent, _dwFlags);
}
}
void Splitter::paintArrow(HDC hdc, const RECT &rect, Arrow arrowDir)
{
RECT rc;
rc.left = rect.left; rc.top = rect.top;
rc.right = rect.right; rc.bottom = rect.bottom;
if (arrowDir == ARROW_LEFT)
switch (arrowDir)
{
case Arrow::left:
{
int x = rc.right;
int y = rc.top;
//::MoveToEx(hdc, x, y, NULL);
for (; (x > rc.left) && (y != rc.bottom) ; x--)
for (; (x > rc.left) && (y != rc.bottom) ; --x)
{
::MoveToEx(hdc, x, y++, NULL);
::LineTo(hdc, x, rc.bottom--);
}
break;
}
else if (arrowDir == ARROW_RIGHT)
case Arrow::right:
{
int x = rc.left;
int y = rc.top;
@ -622,20 +628,24 @@ void Splitter::paintArrow(HDC hdc, const RECT &rect, Arrow arrowDir)
::MoveToEx(hdc, x, y++, NULL);
::LineTo(hdc, x, rc.bottom--);
}
break;
}
else if (arrowDir == ARROW_UP)
case Arrow::up:
{
int x = rc.left;
int y = rc.bottom;
//::MoveToEx(hdc, x, y, NULL);
for (; (y > rc.top) && (x != rc.right) ; y--)
for (; (y > rc.top) && (x != rc.right) ; --y)
{
::MoveToEx(hdc, x++, y, NULL);
::LineTo(hdc, rc.right--, y);
}
break;
}
else if (arrowDir == ARROW_DOWN)
case Arrow::down:
{
int x = rc.left;
int y = rc.top;
@ -646,12 +656,19 @@ void Splitter::paintArrow(HDC hdc, const RECT &rect, Arrow arrowDir)
::MoveToEx(hdc, x++, y, NULL);
::LineTo(hdc, rc.right--, y);
}
break;
}
}
}
void Splitter::adjustZoneToDraw(RECT& rc2def, ZONE_TYPE whichZone)
{
if (_spiltterSize < 4) return;
if (_spiltterSize < 4)
return;
int x0, y0, x1, y1, w, h;
if ((4 <= _spiltterSize) && (_spiltterSize <= 8))
{
w = (isVertical() ? 4 : 7);
@ -664,8 +681,9 @@ void Splitter::adjustZoneToDraw(RECT & rc2def, ZONE_TYPE whichZone)
}
if (isVertical())
{//w=4 h=7
if (whichZone == TOP_LEFT)
{
// w=4 h=7
if (whichZone == ZONE_TYPE::topLeft)
{
x0 = 0;
y0 = (_clickZone2TL.bottom - h) / 2;
@ -675,12 +693,14 @@ void Splitter::adjustZoneToDraw(RECT & rc2def, ZONE_TYPE whichZone)
x0 = _clickZone2BR.left + _clickZone2BR.right - w;
y0 = (_clickZone2BR.bottom - h) / 2 + _clickZone2BR.top;
}
x1 = x0 + w;
y1 = y0 + h;
}
else // Horizontal
{//w=7 h=4
if (whichZone == TOP_LEFT)
{
//w=7 h=4
if (whichZone == ZONE_TYPE::topLeft)
{
x0 = (_clickZone2TL.right - w) / 2;
y0 = 0;
@ -690,11 +710,14 @@ void Splitter::adjustZoneToDraw(RECT & rc2def, ZONE_TYPE whichZone)
x0 = ((_clickZone2BR.right - w) / 2) + _clickZone2BR.left;
y0 = _clickZone2BR.top + _clickZone2BR.bottom - h;
}
x1 = x0 + w;
y1 = y0 + h;
}
rc2def.left = x0;
rc2def.top = y0;
rc2def.right = x1;
rc2def.bottom = y1;
}

View File

@ -24,16 +24,11 @@
// 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 SPLITTER_H
#define SPLITTER_H
#ifndef RESOURCE_H
#pragma once
#include "resource.h"
#endif //RESOURCE_H
#include "Window.h"
#include "Common.h"
#define SV_HORIZONTAL 0x00000001
#define SV_VERTICAL 0x00000002
@ -50,43 +45,47 @@
const int HIEGHT_MINIMAL = 15;
enum Arrow {ARROW_LEFT, ARROW_UP, ARROW_RIGHT, ARROW_DOWN};
typedef bool WH;
const bool WIDTH = true;
const bool HEIGHT = false;
enum class Arrow { left, up, right, down };
typedef bool ZONE_TYPE;
const bool TOP_LEFT = true;
const bool BOTTOM_RIGHT = false;
enum class WH { height, width };
enum SplitterMode {
enum class ZONE_TYPE { bottomRight, topLeft };
enum class SplitterMode: std::uint8_t
{
DYNAMIC, LEFT_FIX, RIGHT_FIX
};
class Splitter : public Window
{
public:
Splitter();
~Splitter(){};
void destroy() {
::DestroyWindow(_hSelf);
};
virtual ~Splitter() = default;
virtual void destroy() override;
void resizeSpliter(RECT *pRect = NULL);
void init(HINSTANCE hInst, HWND hPere, int splitterSize,
double iSplitRatio, DWORD dwFlags);
void init(HINSTANCE hInst, HWND hPere, int splitterSize, double iSplitRatio, DWORD dwFlags);
void rotate();
int getPhisicalSize() const {
int getPhisicalSize() const
{
return _spiltterSize;
};
}
private:
RECT _rect;
double _splitPercent;
int _spiltterSize;
bool _isDraged;
DWORD _dwFlags;
bool _isFixed;
double _splitPercent = 0.;
int _spiltterSize = 0;
bool _isDraged = false;
DWORD _dwFlags = 0;
bool _isFixed = false;
static bool _isHorizontalRegistered;
static bool _isVerticalRegistered;
static bool _isHorizontalFixedRegistered;
@ -105,26 +104,31 @@ private:
void gotoTopLeft();
void gotoRightBouuom();
bool isInLeftTopZone(const POINT &p) const {
return (((p.x >= _clickZone2TL.left) && (p.x <= _clickZone2TL.left + _clickZone2TL.right)) &&
(p.y >= _clickZone2TL.top) && (p.y <= _clickZone2TL.top + _clickZone2TL.bottom));
};
bool isInLeftTopZone(const POINT& p) const
{
return ((p.x >= _clickZone2TL.left)
and (p.x <= _clickZone2TL.left + _clickZone2TL.right)
and (p.y >= _clickZone2TL.top)
and (p.y <= _clickZone2TL.top + _clickZone2TL.bottom));
}
bool isInRightBottomZone(const POINT &p) const {
return (((p.x >= _clickZone2BR.left) &&
(p.x <= _clickZone2BR.left + _clickZone2BR.right)) &&
(p.y >= _clickZone2BR.top) &&
(p.y <= _clickZone2BR.top + _clickZone2BR.bottom));
};
bool isInRightBottomZone(const POINT& p) const
{
return ((p.x >= _clickZone2BR.left)
and (p.x <= _clickZone2BR.left + _clickZone2BR.right)
and (p.y >= _clickZone2BR.top)
and (p.y <= _clickZone2BR.top + _clickZone2BR.bottom));
}
int getSplitterFixPosX() {
int getSplitterFixPosX() const
{
long result = long(::SendMessage(_hParent, WM_GETSPLITTER_X, 0, 0));
return (LOWORD(result) - ((HIWORD(result) == RIGHT_FIX) ? _spiltterSize : 0));
};
return (LOWORD(result) - ((HIWORD(result) == static_cast<std::uint8_t>(SplitterMode::RIGHT_FIX)) ? _spiltterSize : 0));
}
int getSplitterFixPosY() {
int getSplitterFixPosY() const
{
long result = long(::SendMessage(_hParent, WM_GETSPLITTER_Y, 0, 0));
return (LOWORD(result) - ((HIWORD(result) == RIGHT_FIX) ? _spiltterSize : 0));
return (LOWORD(result) - ((HIWORD(result) == static_cast<std::uint8_t>(SplitterMode::RIGHT_FIX)) ? _spiltterSize : 0));
}
};
};
#endif //SPLITTER_H

View File

@ -24,16 +24,18 @@
// 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 <iostream>
#include <windows.h>
#include "SplitterContainer.h"
#include <cassert>
bool SplitterContainer::_isRegistered = false;
void SplitterContainer::create(Window *pWin0, Window *pWin1, int splitterSize,
SplitterMode mode, int ratio, bool isVertical)
void SplitterContainer::create(Window *pWin0, Window *pWin1, int splitterSize, SplitterMode mode, int ratio, bool isVertical)
{
//Window::init(hInst, parent);
_pWin0 = pWin0;
@ -42,7 +44,8 @@ void SplitterContainer::create(Window *pWin0, Window *pWin1, int splitterSize,
_splitterMode = mode;
_ratio = ratio;
_dwSplitterStyle |= isVertical?SV_VERTICAL:SV_HORIZONTAL;
if (_splitterMode != DYNAMIC)
if (_splitterMode != SplitterMode::DYNAMIC)
{
_dwSplitterStyle |= SV_FIXED;
_dwSplitterStyle &= ~SV_RESIZEWTHPERCNT;
@ -66,30 +69,63 @@ void SplitterContainer::create(Window *pWin0, Window *pWin1, int splitterSize,
splitterContainerClass.lpszClassName = SPC_CLASS_NAME;
if (!::RegisterClass(&splitterContainerClass))
{
throw std::runtime_error(" SplitterContainer::create : RegisterClass() function failed");
}
_isRegistered = true;
}
_hSelf = ::CreateWindowEx(
0,
SPC_CLASS_NAME,
TEXT("a koi sert?"),
0, SPC_CLASS_NAME, TEXT("a koi sert?"),
WS_CHILD | WS_CLIPCHILDREN,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
_hParent,
NULL,
_hInst,
(LPVOID)this);
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
_hParent, NULL, _hInst, this);
if (!_hSelf)
{
throw std::runtime_error(" SplitterContainer::create : CreateWindowEx() function return null");
}
void SplitterContainer::destroy()
{
if (_hPopupMenu)
::DestroyMenu(_hPopupMenu);
_splitter.destroy();
::DestroyWindow(_hSelf);
}
void SplitterContainer::reSizeTo(RECT & rc)
{
_x = rc.left;
_y = rc.top;
::MoveWindow(_hSelf, _x, _y, rc.right, rc.bottom, FALSE);
_splitter.resizeSpliter();
}
void SplitterContainer::display(bool toShow) const
{
Window::display(toShow);
assert(_pWin0 != nullptr);
assert(_pWin1 != nullptr);
_pWin0->display(toShow);
_pWin1->display(toShow);
_splitter.display(toShow);
}
void SplitterContainer::redraw() const
{
assert(_pWin0 != nullptr);
assert(_pWin1 != nullptr);
_pWin0->redraw(true);
_pWin1->redraw(true);
}
void SplitterContainer::rotateTo(DIRECTION direction)
{
bool doSwitchWindow = false;
@ -97,13 +133,13 @@ void SplitterContainer::rotateTo(DIRECTION direction)
{
_dwSplitterStyle ^= SV_VERTICAL;
_dwSplitterStyle |= SV_HORIZONTAL;
doSwitchWindow = (direction == LEFT);
doSwitchWindow = (direction == DIRECTION::LEFT);
}
else
{
_dwSplitterStyle ^= SV_HORIZONTAL;
_dwSplitterStyle |= SV_VERTICAL;
doSwitchWindow = (direction == RIGHT);
doSwitchWindow = (direction == DIRECTION::RIGHT);
}
if (doSwitchWindow)
{
@ -121,40 +157,52 @@ LRESULT CALLBACK SplitterContainer::staticWinProc(HWND hwnd, UINT message, WPARA
switch (message)
{
case WM_NCCREATE:
{
pSplitterContainer = (SplitterContainer *)(((LPCREATESTRUCT)lParam)->lpCreateParams);
pSplitterContainer->_hSelf = hwnd;
::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pSplitterContainer);
return TRUE;
}
default:
{
pSplitterContainer = (SplitterContainer *)::GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (!pSplitterContainer)
return ::DefWindowProc(hwnd, message, wParam, lParam);
return pSplitterContainer->runProc(message, wParam, lParam);
}
}
}
LRESULT SplitterContainer::runProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_CREATE:
{
_splitter.init(_hInst, _hSelf, _splitterSize, _ratio, _dwSplitterStyle);
return TRUE;
}
case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case ROTATION_A_GAUCHE:
rotateTo(LEFT);
return TRUE;
{
rotateTo(DIRECTION::LEFT);
break;
}
case ROTATION_A_DROITE:
rotateTo(RIGHT);
return TRUE;
{
rotateTo(DIRECTION::RIGHT);
break;
}
}
return TRUE;
}
case WM_RESIZE_CONTAINER:
{
RECT rc0, rc1;
@ -194,7 +242,7 @@ LRESULT SplitterContainer::runProc(UINT message, WPARAM wParam, LPARAM lParam)
case WM_DOPOPUPMENU:
{
if ((_splitterMode != LEFT_FIX) && (_splitterMode != RIGHT_FIX) )
if ((_splitterMode != SplitterMode::LEFT_FIX) && (_splitterMode != SplitterMode::RIGHT_FIX) )
{
POINT p;
::GetCursorPos(&p);
@ -215,33 +263,45 @@ LRESULT SplitterContainer::runProc(UINT message, WPARAM wParam, LPARAM lParam)
case WM_GETSPLITTER_X:
{
if (_splitterMode == LEFT_FIX)
return MAKELONG(_pWin0->getWidth(), LEFT_FIX);
else if (_splitterMode == RIGHT_FIX)
switch (_splitterMode)
{
case SplitterMode::LEFT_FIX:
{
return MAKELONG(_pWin0->getWidth(), static_cast<std::uint8_t>(SplitterMode::LEFT_FIX));
}
case SplitterMode::RIGHT_FIX:
{
int x = getWidth()-_pWin1->getWidth();
if (x < 0)
x = 0;
return MAKELONG(x, RIGHT_FIX);
return MAKELONG(x, static_cast<std::uint8_t>(SplitterMode::RIGHT_FIX));
}
else
return MAKELONG(0, DYNAMIC);
default:
break;
}
return MAKELONG(0, static_cast<std::uint8_t>(SplitterMode::DYNAMIC));
}
case WM_GETSPLITTER_Y:
{
if (_splitterMode == LEFT_FIX)
return MAKELONG(_pWin0->getHeight(), LEFT_FIX);
else if (_splitterMode == RIGHT_FIX)
switch (_splitterMode)
{
case SplitterMode::LEFT_FIX:
{
return MAKELONG(_pWin0->getHeight(), static_cast<std::uint8_t>(SplitterMode::LEFT_FIX));
}
case SplitterMode::RIGHT_FIX:
{
int y = getHeight()-_pWin1->getHeight();
if (y < 0)
y = 0;
return MAKELONG(y, RIGHT_FIX);
return MAKELONG(y, static_cast<std::uint8_t>(SplitterMode::RIGHT_FIX));
}
else
return MAKELONG(0, DYNAMIC);
default:
break;
}
return MAKELONG(0, static_cast<std::uint8_t>(SplitterMode::DYNAMIC));
}
case WM_LBUTTONDBLCLK:
@ -250,15 +310,12 @@ LRESULT SplitterContainer::runProc(UINT message, WPARAM wParam, LPARAM lParam)
::GetCursorPos(&pt);
::ScreenToClient(_splitter.getHSelf(), &pt);
Window* targetWindow;
if(this->isVertical())
targetWindow = pt.x < 0?_pWin0:_pWin1;
else
targetWindow = pt.y < 0?_pWin0:_pWin1;
HWND parent = ::GetParent(getHSelf());
Window* targetWindow = (this->isVertical())
? (pt.x < 0 ? _pWin0 : _pWin1)
: (pt.y < 0 ? _pWin0 : _pWin1);
::SendMessage(parent, NPPM_INTERNAL_SWITCHVIEWFROMHWND, 0, (LPARAM)targetWindow->getHSelf());
::SendMessage(parent, WM_COMMAND, IDM_FILE_NEW, 0);
return TRUE;

View File

@ -24,94 +24,74 @@
// 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 SPLITTER_CONTAINER_H
#define SPLITTER_CONTAINER_H
#ifndef SPLITTER_H
#pragma once
#include "Splitter.h"
#endif //SPLITTER_H
#ifndef MENUCMDID_H
#include "menuCmdID.h"
#endif //MENUCMDID_H
#define SPC_CLASS_NAME TEXT("splitterContainer")
#define ROTATION_A_GAUCHE 2000
#define ROTATION_A_DROITE 2001
typedef bool DIRECTION;
const bool LEFT = true;
const bool RIGHT = false;
enum class DIRECTION
{
RIGHT,
LEFT
};
class SplitterContainer : public Window
{
public :
SplitterContainer(): Window(), _x(0), _y(0), _hPopupMenu(NULL),
_dwSplitterStyle(SV_ENABLERDBLCLK | SV_ENABLELDBLCLK | SV_RESIZEWTHPERCNT){
};
~SplitterContainer(){};
virtual ~SplitterContainer() = default;
void create(Window *pWin0, Window *pWin1, int splitterSize = 4,
SplitterMode mode = DYNAMIC, int ratio = 50, bool _isVertical = true);
SplitterMode mode = SplitterMode::DYNAMIC, int ratio = 50, bool _isVertical = true);
void destroy() {
if (_hPopupMenu)
::DestroyMenu(_hPopupMenu);
_splitter.destroy();
::DestroyWindow(_hSelf);
};
void reSizeTo(RECT & rc) {
_x = rc.left;
_y = rc.top;
::MoveWindow(_hSelf, _x, _y, rc.right, rc.bottom, FALSE);
_splitter.resizeSpliter();
};
virtual void display(bool toShow = true) const {
Window::display(toShow);
void destroy();
_pWin0->display(toShow);
_pWin1->display(toShow);
_splitter.display(toShow);
};
virtual void redraw() const {
_pWin0->redraw(true);
_pWin1->redraw(true);
};
void reSizeTo(RECT & rc);
void setWin0(Window *pWin) {
virtual void display(bool toShow = true) const;
virtual void redraw() const;
void setWin0(Window* pWin)
{
_pWin0 = pWin;
}
};
void setWin1(Window *pWin) {
void setWin1(Window* pWin)
{
_pWin1 = pWin;
};
}
bool isVertical() const {
bool isVertical() const
{
return ((_dwSplitterStyle & SV_VERTICAL) != 0);
};
}
private :
Window *_pWin0; // left or top window
Window *_pWin1; // right or bottom window
Window* _pWin0 = nullptr; // left or top window
Window* _pWin1 = nullptr; // right or bottom window
Splitter _splitter;
int _splitterSize;
int _ratio;
int _x, _y;
HMENU _hPopupMenu;
DWORD _dwSplitterStyle;
int _splitterSize = 0;
int _ratio = 0;
int _x = 0;
int _y = 0;
HMENU _hPopupMenu = NULL;
DWORD _dwSplitterStyle = (SV_ENABLERDBLCLK | SV_ENABLELDBLCLK | SV_RESIZEWTHPERCNT);
SplitterMode _splitterMode;
SplitterMode _splitterMode = SplitterMode::DYNAMIC;
static bool _isRegistered;
static LRESULT CALLBACK staticWinProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
LRESULT runProc(UINT Message, WPARAM wParam, LPARAM lParam);
void rotateTo(DIRECTION direction);
};
#endif //SPLITTER_CONTAINER_H

View File

@ -29,6 +29,43 @@
#include <windows.h>
#include "StaticDialog.h"
StaticDialog::~StaticDialog()
{
if (isCreated())
{
// Prevent run_dlgProc from doing anything, since its virtual
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR) NULL);
destroy();
}
}
void StaticDialog::destroy()
{
::SendMessage(_hParent, NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, (WPARAM)_hSelf);
::DestroyWindow(_hSelf);
}
POINT StaticDialog::getTopPoint(HWND hwnd, bool isLeft) const
{
RECT rc;
::GetWindowRect(hwnd, &rc);
POINT p;
if (isLeft)
p.x = rc.left;
else
p.x = rc.right;
p.y = rc.top;
::ScreenToClient(_hSelf, &p);
return p;
}
void StaticDialog::goToCenter()
{
RECT rc;
@ -47,7 +84,8 @@ void StaticDialog::goToCenter()
void StaticDialog::display(bool toShow) const
{
if (toShow) {
if (toShow)
{
// If the user has switched from a dual monitor to a single monitor since we last
// displayed the dialog, then ensure that it's still visible on the single monitor.
RECT workAreaRect = {0};
@ -57,6 +95,7 @@ void StaticDialog::display(bool toShow) const
int newLeft = rc.left;
int newTop = rc.top;
int margin = ::GetSystemMetrics(SM_CYSMCAPTION);
if (newLeft > ::GetSystemMetrics(SM_CXVIRTUALSCREEN)-margin)
newLeft -= rc.right - workAreaRect.right;
if (newLeft + (rc.right - rc.left) < ::GetSystemMetrics(SM_XVIRTUALSCREEN)+margin)
@ -131,6 +170,7 @@ void StaticDialog::create(int dialogID, bool isRTL, bool msgDestParent)
::SendMessage(msgDestParent?_hParent:(::GetParent(_hParent)), NPPM_MODELESSDIALOG, MODELESSDIALOGADD, (WPARAM)_hSelf);
}
INT_PTR CALLBACK StaticDialog::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
@ -166,26 +206,31 @@ void StaticDialog::alignWith(HWND handle, HWND handle2Align, PosAlign pos, POINT
switch (pos)
{
case ALIGNPOS_LEFT :
case PosAlign::left:
{
::GetWindowRect(handle2Align, &rc2);
point.x -= rc2.right - rc2.left;
break;
case ALIGNPOS_RIGHT :
}
case PosAlign::right:
{
::GetWindowRect(handle, &rc2);
point.x += rc2.right - rc2.left;
break;
case ALIGNPOS_TOP :
}
case PosAlign::top:
{
::GetWindowRect(handle2Align, &rc2);
point.y -= rc2.bottom - rc2.top;
break;
default : //ALIGNPOS_BOTTOM
}
case PosAlign::bottom:
{
::GetWindowRect(handle, &rc2);
point.y += rc2.bottom - rc2.top;
break;
}
}
::ScreenToClient(_hSelf, &point);
}

View File

@ -24,19 +24,18 @@
// 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 STATIC_DIALOG_H
#define STATIC_DIALOG_H
#pragma once
#include "Notepad_plus_msgs.h"
#include "Window.h"
typedef HRESULT (WINAPI * ETDTProc) (HWND, DWORD);
enum PosAlign{ALIGNPOS_LEFT, ALIGNPOS_RIGHT, ALIGNPOS_TOP, ALIGNPOS_BOTTOM};
enum class PosAlign { left, right, top, bottom };
struct DLGTEMPLATEEX {
struct DLGTEMPLATEEX
{
WORD dlgVer;
WORD signature;
DWORD helpID;
@ -50,47 +49,33 @@ struct DLGTEMPLATEEX {
// The structure has more fields but are variable length
};
class StaticDialog : public Window
{
public :
StaticDialog() : Window() {};
~StaticDialog(){
if (isCreated()) {
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR)NULL); //Prevent run_dlgProc from doing anything, since its virtual
destroy();
}
};
virtual ~StaticDialog();
virtual void create(int dialogID, bool isRTL = false, bool msgDestParent = true);
virtual bool isCreated() const {
virtual bool isCreated() const
{
return (_hSelf != NULL);
};
}
void goToCenter();
void display(bool toShow = true) const;
POINT getTopPoint(HWND hwnd, bool isLeft = true) const {
RECT rc;
::GetWindowRect(hwnd, &rc);
POINT p;
if (isLeft)
p.x = rc.left;
else
p.x = rc.right;
p.y = rc.top;
::ScreenToClient(_hSelf, &p);
return p;
};
POINT getTopPoint(HWND hwnd, bool isLeft = true) const;
bool isCheckedOrNot(int checkControlID) const {
bool isCheckedOrNot(int checkControlID) const
{
return (BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, checkControlID), BM_GETCHECK, 0, 0));
};
}
virtual void destroy() override;
void destroy() {
::SendMessage(_hParent, NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, (WPARAM)_hSelf);
::DestroyWindow(_hSelf);
};
protected:
RECT _rc;
@ -100,5 +85,3 @@ protected :
void alignWith(HWND handle, HWND handle2Align, PosAlign pos, POINT & point);
HGLOBAL makeRTLResource(int dialogID, DLGTEMPLATE **ppMyDlgTemplate);
};
#endif //STATIC_DIALOG_H

View File

@ -33,7 +33,13 @@
class Window
{
public:
//! \name Constructors & Destructor
//@{
Window() = default;
Window(const Window&) = delete;
virtual ~Window() = default;
//@}
virtual void init(HINSTANCE hInst, HWND parent)
{
@ -123,6 +129,9 @@ public:
}
Window& operator = (const Window&) = delete;
protected:
HINSTANCE _hInst = NULL;
HWND _hParent = NULL;

View File

@ -24,13 +24,11 @@
// 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 RESOURCE_H
#define RESOURCE_H
#pragma once
#define NOTEPAD_PLUS_VERSION TEXT("Notepad++ v6.8.1")
// should be X.Y : ie. if VERSION_DIGITALVALUE == 4, 7, 1, 0 , then X = 4, Y = 71
// ex : #define VERSION_VALUE TEXT("5.63\0")
#define VERSION_VALUE TEXT("6.8.1\0")
@ -456,7 +454,3 @@
#define MENUINDEX_MACRO 7
#define MENUINDEX_RUN 8
#define MENUINDEX_PLUGINS 9
#endif // RESOURCE_H