minor code cleanup for future refactoring
This commit is contained in:
parent
ba5d36e2bf
commit
366a393f13
@ -29,6 +29,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <iso646.h>
|
#include <iso646.h>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
|
||||||
const bool dirUp = true;
|
const bool dirUp = true;
|
||||||
|
@ -362,7 +362,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
|
|||||||
bool isVertical = (nppGUI._splitterPos == POS_VERTICAL);
|
bool isVertical = (nppGUI._splitterPos == POS_VERTICAL);
|
||||||
|
|
||||||
_subSplitter.init(_pPublicInterface->getHinst(), hwnd);
|
_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--//
|
//--Status Bar Section--//
|
||||||
bool willBeShown = nppGUI._statusBarShow;
|
bool willBeShown = nppGUI._statusBarShow;
|
||||||
@ -3240,7 +3240,7 @@ void Notepad_plus::dockUserDlg()
|
|||||||
else
|
else
|
||||||
pWindow = _pDocTab;
|
pWindow = _pDocTab;
|
||||||
|
|
||||||
_pMainSplitter->create(pWindow, ScintillaEditView::getUserDefineDlg(), 8, RIGHT_FIX, 45);
|
_pMainSplitter->create(pWindow, ScintillaEditView::getUserDefineDlg(), 8, SplitterMode::RIGHT_FIX, 45);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bothActive())
|
if (bothActive())
|
||||||
|
@ -24,13 +24,11 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#ifndef NOTEPAD_PLUS_WINDOW_H
|
|
||||||
#define NOTEPAD_PLUS_WINDOW_H
|
|
||||||
|
|
||||||
#include "Notepad_plus.h"
|
#include "Notepad_plus.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const TCHAR COMMAND_ARG_HELP[] = TEXT("Usage :\r\
|
const TCHAR COMMAND_ARG_HELP[] = TEXT("Usage :\r\
|
||||||
\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\
|
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\
|
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:
|
public:
|
||||||
Notepad_plus_Window() : _isPrelaunch(false), _disablePluginsManager(false) {};
|
|
||||||
void init(HINSTANCE, HWND, const TCHAR *cmdLine, CmdLineParams *cmdLineParams);
|
void init(HINSTANCE, HWND, const TCHAR *cmdLine, CmdLineParams *cmdLineParams);
|
||||||
|
|
||||||
bool isDlgsMsg(MSG *msg) const;
|
bool isDlgsMsg(MSG *msg) const;
|
||||||
|
|
||||||
HACCEL getAccTable() const {
|
HACCEL getAccTable() const
|
||||||
|
{
|
||||||
return _notepad_plus_plus_core.getAccTable();
|
return _notepad_plus_plus_core.getAccTable();
|
||||||
};
|
}
|
||||||
|
|
||||||
bool emergency(generic_string emergencySavedDir) {
|
bool emergency(generic_string emergencySavedDir)
|
||||||
|
{
|
||||||
return _notepad_plus_plus_core.emergency(emergencySavedDir);
|
return _notepad_plus_plus_core.emergency(emergencySavedDir);
|
||||||
};
|
}
|
||||||
|
|
||||||
bool isPrelaunch() const {
|
bool isPrelaunch() const
|
||||||
|
{
|
||||||
return _isPrelaunch;
|
return _isPrelaunch;
|
||||||
};
|
}
|
||||||
|
|
||||||
void setIsPrelaunch(bool val) {
|
void setIsPrelaunch(bool val)
|
||||||
|
{
|
||||||
_isPrelaunch = val;
|
_isPrelaunch = val;
|
||||||
};
|
}
|
||||||
|
|
||||||
virtual void destroy(){
|
virtual void destroy()
|
||||||
|
{
|
||||||
::DestroyWindow(_hSelf);
|
::DestroyWindow(_hSelf);
|
||||||
};
|
}
|
||||||
|
|
||||||
static const TCHAR * getClassName() {
|
static const TCHAR * getClassName()
|
||||||
|
{
|
||||||
return _className;
|
return _className;
|
||||||
};
|
}
|
||||||
|
|
||||||
static HWND gNppHWND; //static handle to Notepad++ window, NULL if non-existant
|
static HWND gNppHWND; //static handle to Notepad++ window, NULL if non-existant
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Notepad_plus _notepad_plus_plus_core;
|
Notepad_plus _notepad_plus_plus_core;
|
||||||
static LRESULT CALLBACK Notepad_plus_Proc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
|
static LRESULT CALLBACK Notepad_plus_Proc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
|
||||||
LRESULT runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
|
LRESULT runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
static const TCHAR _className[32];
|
static const TCHAR _className[32];
|
||||||
bool _isPrelaunch;
|
bool _isPrelaunch = false;
|
||||||
bool _disablePluginsManager;
|
bool _disablePluginsManager = false;
|
||||||
std::string _userQuote; // keep the availability of this string for thread using
|
std::string _userQuote; // keep the availability of this string for thread using
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //NOTEPAD_PLUS_WINDOW_H
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1051,7 +1051,7 @@ void Notepad_plus::command(int id)
|
|||||||
else
|
else
|
||||||
pWindow = _pDocTab;
|
pWindow = _pDocTab;
|
||||||
|
|
||||||
_pMainSplitter->create(pWindow, ScintillaEditView::getUserDefineDlg(), 8, RIGHT_FIX, 45);
|
_pMainSplitter->create(pWindow, ScintillaEditView::getUserDefineDlg(), 8, SplitterMode::RIGHT_FIX, 45);
|
||||||
}
|
}
|
||||||
|
|
||||||
_pMainWindow = _pMainSplitter;
|
_pMainWindow = _pMainSplitter;
|
||||||
|
@ -36,6 +36,10 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BOOL Notepad_plus::notify(SCNotification *notification)
|
BOOL Notepad_plus::notify(SCNotification *notification)
|
||||||
{
|
{
|
||||||
//Important, keep track of which element generated the message
|
//Important, keep track of which element generated the message
|
||||||
@ -76,9 +80,8 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
|||||||
prevWasEdit = false;
|
prevWasEdit = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case SCN_SAVEPOINTREACHED:
|
case SCN_SAVEPOINTREACHED:
|
||||||
case SCN_SAVEPOINTLEFT:
|
case SCN_SAVEPOINTLEFT:
|
||||||
@ -105,19 +108,16 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
|||||||
id = MainFileManager->getBufferFromDocument(_fileEditView.execute(SCI_GETDOCPOINTER));
|
id = MainFileManager->getBufferFromDocument(_fileEditView.execute(SCI_GETDOCPOINTER));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
break; //wrong scintilla
|
break; //wrong scintilla
|
||||||
}
|
|
||||||
|
|
||||||
if (id != BUFFER_INVALID)
|
if (id != BUFFER_INVALID)
|
||||||
{
|
{
|
||||||
buf = MainFileManager->getBufferByID(id);
|
buf = MainFileManager->getBufferByID(id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
bool isDirty = notification->nmhdr.code == SCN_SAVEPOINTLEFT;
|
bool isDirty = notification->nmhdr.code == SCN_SAVEPOINTLEFT;
|
||||||
bool isSnapshotMode = NppParameters::getInstance()->getNppGUI().isSnapshotMode();
|
bool isSnapshotMode = NppParameters::getInstance()->getNppGUI().isSnapshotMode();
|
||||||
if (isSnapshotMode && !isDirty)
|
if (isSnapshotMode && !isDirty)
|
||||||
@ -130,12 +130,16 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SCN_MODIFYATTEMPTRO :
|
case SCN_MODIFYATTEMPTRO:
|
||||||
// on fout rien
|
{
|
||||||
|
// nothing to do
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case SCN_KEY:
|
case SCN_KEY:
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case TCN_TABDROPPEDOUTSIDE:
|
case TCN_TABDROPPEDOUTSIDE:
|
||||||
case TCN_TABDROPPED:
|
case TCN_TABDROPPED:
|
||||||
@ -254,9 +258,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
|||||||
iView = SUB_VIEW;
|
iView = SUB_VIEW;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
switchEditViewTo(iView);
|
switchEditViewTo(iView);
|
||||||
BufferID bufid = _pDocTab->getBufferByIndex(_pDocTab->getCurrentTabIndex());
|
BufferID bufid = _pDocTab->getBufferByIndex(_pDocTab->getCurrentTabIndex());
|
||||||
@ -407,7 +409,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
|||||||
|
|
||||||
if (!_tabPopupMenu.isCreated())
|
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_CLOSE, TEXT("Close")));
|
||||||
itemUnitArray.push_back(MenuItemUnit(IDM_FILE_CLOSEALL_BUT_CURRENT, TEXT("Close All BUT This")));
|
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")));
|
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 :
|
case SCN_FOLDINGSTATECHANGED :
|
||||||
{
|
{
|
||||||
if ((notification->nmhdr.hwndFrom == _mainEditView.getHSelf())
|
if ((notification->nmhdr.hwndFrom == _mainEditView.getHSelf()) || (notification->nmhdr.hwndFrom == _subEditView.getHSelf()))
|
||||||
|| (notification->nmhdr.hwndFrom == _subEditView.getHSelf()))
|
|
||||||
{
|
{
|
||||||
int lineClicked = notification->line;
|
int lineClicked = notification->line;
|
||||||
|
|
||||||
@ -522,7 +523,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SCN_DOUBLECLICK :
|
case SCN_DOUBLECLICK:
|
||||||
{
|
{
|
||||||
if (notification->modifiers == SCMOD_CTRL)
|
if (notification->modifiers == SCMOD_CTRL)
|
||||||
{
|
{
|
||||||
@ -676,8 +677,9 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
|||||||
notifyView->execute(SCI_SETANCHOR, pos);
|
notifyView->execute(SCI_SETANCHOR, pos);
|
||||||
_isHotspotDblClicked = false;
|
_isHotspotDblClicked = false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case SCN_UPDATEUI:
|
case SCN_UPDATEUI:
|
||||||
{
|
{
|
||||||
@ -725,7 +727,8 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
|||||||
|
|
||||||
case TTN_GETDISPINFO:
|
case TTN_GETDISPINFO:
|
||||||
{
|
{
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
LPTOOLTIPTEXT lpttt = (LPTOOLTIPTEXT)notification;
|
LPTOOLTIPTEXT lpttt = (LPTOOLTIPTEXT)notification;
|
||||||
|
|
||||||
//Joce's fix
|
//Joce's fix
|
||||||
@ -776,22 +779,26 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
} catch (...) {
|
catch (...)
|
||||||
|
{
|
||||||
//printStr(TEXT("ToolTip crash is caught!"));
|
//printStr(TEXT("ToolTip crash is caught!"));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
case SCN_ZOOM:
|
case SCN_ZOOM:
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case SCN_MACRORECORD:
|
case SCN_MACRORECORD:
|
||||||
|
{
|
||||||
_macro.push_back(recordedMacroStep(notification->message, notification->wParam, notification->lParam, _pEditView->execute(SCI_GETCODEPAGE)));
|
_macro.push_back(recordedMacroStep(notification->message, notification->wParam, notification->lParam, _pEditView->execute(SCI_GETCODEPAGE)));
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case SCN_PAINTED:
|
case SCN_PAINTED:
|
||||||
{
|
{
|
||||||
@ -830,7 +837,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SCN_HOTSPOTDOUBLECLICK :
|
case SCN_HOTSPOTDOUBLECLICK:
|
||||||
{
|
{
|
||||||
notifyView->execute(SCI_SETWORDCHARS, 0, (LPARAM)"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-+.,:?&@=/%#()");
|
notifyView->execute(SCI_SETWORDCHARS, 0, (LPARAM)"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-+.,:?&@=/%#()");
|
||||||
|
|
||||||
@ -870,16 +877,15 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SCN_NEEDSHOWN :
|
case SCN_NEEDSHOWN:
|
||||||
{
|
{
|
||||||
int begin = notifyView->execute(SCI_LINEFROMPOSITION, notification->position);
|
int begin = notifyView->execute(SCI_LINEFROMPOSITION, notification->position);
|
||||||
int end = notifyView->execute(SCI_LINEFROMPOSITION, notification->position + notification->length);
|
int end = notifyView->execute(SCI_LINEFROMPOSITION, notification->position + notification->length);
|
||||||
int firstLine = begin < end ? begin : end;
|
int firstLine = begin < end ? begin : end;
|
||||||
int lastLine = begin > end ? begin : end;
|
int lastLine = begin > end ? begin : end;
|
||||||
|
|
||||||
for (int line = firstLine; line <= lastLine; ++line)
|
for (int line = firstLine; line <= lastLine; ++line)
|
||||||
{
|
|
||||||
notifyView->execute(SCI_ENSUREVISIBLE, line, 0);
|
notifyView->execute(SCI_ENSUREVISIBLE, line, 0);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -895,12 +901,14 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
|||||||
SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
|
SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case RBN_CHEVRONPUSHED:
|
case RBN_CHEVRONPUSHED:
|
||||||
{
|
{
|
||||||
NMREBARCHEVRON * lpnm = (NMREBARCHEVRON*) notification;
|
NMREBARCHEVRON * lpnm = (NMREBARCHEVRON*) notification;
|
||||||
ReBar * notifRebar = &_rebarTop;
|
ReBar * notifRebar = &_rebarTop;
|
||||||
if (_rebarBottom.getHSelf() == lpnm->hdr.hwndFrom)
|
if (_rebarBottom.getHSelf() == lpnm->hdr.hwndFrom)
|
||||||
notifRebar = &_rebarBottom;
|
notifRebar = &_rebarBottom;
|
||||||
|
|
||||||
//If N++ ID, use proper object
|
//If N++ ID, use proper object
|
||||||
if (lpnm->wID == REBAR_BAR_TOOLBAR)
|
if (lpnm->wID == REBAR_BAR_TOOLBAR)
|
||||||
{
|
{
|
||||||
@ -911,6 +919,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
|||||||
_toolBar.doPopop(pt);
|
_toolBar.doPopop(pt);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Else forward notification to window of rebarband
|
//Else forward notification to window of rebarband
|
||||||
REBARBANDINFO rbBand;
|
REBARBANDINFO rbBand;
|
||||||
ZeroMemory(&rbBand, REBARBAND_SIZE);
|
ZeroMemory(&rbBand, REBARBAND_SIZE);
|
||||||
@ -922,7 +931,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default :
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,12 +24,13 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "ColourPicker.h"
|
#include "ColourPicker.h"
|
||||||
#include "ColourPopup.h"
|
#include "ColourPopup.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ColourPicker::init(HINSTANCE hInst, HWND parent)
|
void ColourPicker::init(HINSTANCE hInst, HWND parent)
|
||||||
{
|
{
|
||||||
Window::init(hInst, parent);
|
Window::init(hInst, parent);
|
||||||
@ -40,37 +41,30 @@ void ColourPicker::init(HINSTANCE hInst, HWND parent)
|
|||||||
TEXT("F"),
|
TEXT("F"),
|
||||||
WS_CHILD | WS_VISIBLE,
|
WS_CHILD | WS_VISIBLE,
|
||||||
0, 0, 25, 25,
|
0, 0, 25, 25,
|
||||||
_hParent,
|
_hParent, NULL, _hInst, (LPVOID)0);
|
||||||
NULL,
|
|
||||||
_hInst,
|
|
||||||
(LPVOID)0);
|
|
||||||
if (!_hSelf)
|
|
||||||
{
|
|
||||||
throw std::runtime_error("ColourPicker::init : CreateWindowEx() function return null");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!_hSelf)
|
||||||
|
throw std::runtime_error("ColourPicker::init : CreateWindowEx() function return null");
|
||||||
|
|
||||||
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR)this);
|
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR)this);
|
||||||
_buttonDefaultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, (LONG_PTR)staticWinProc));
|
_buttonDefaultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, (LONG_PTR)staticWinProc));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColourPicker::destroy()
|
void ColourPicker::destroy()
|
||||||
{
|
{
|
||||||
if (_pColourPopup)
|
|
||||||
{
|
|
||||||
delete _pColourPopup;
|
delete _pColourPopup;
|
||||||
_pColourPopup = NULL;
|
_pColourPopup = NULL;
|
||||||
}
|
|
||||||
::DestroyWindow(_hSelf);
|
::DestroyWindow(_hSelf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColourPicker::drawBackground(HDC hDC)
|
void ColourPicker::drawBackground(HDC hDC)
|
||||||
{
|
{
|
||||||
RECT rc;
|
RECT rc;
|
||||||
HBRUSH hbrush;
|
HBRUSH hbrush;
|
||||||
|
|
||||||
if(!hDC)
|
if (!hDC)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
getClientRect(rc);
|
getClientRect(rc);
|
||||||
@ -82,12 +76,13 @@ void ColourPicker::drawBackground(HDC hDC)
|
|||||||
::DeleteObject(hbrush);
|
::DeleteObject(hbrush);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColourPicker::drawForeground(HDC hDC)
|
void ColourPicker::drawForeground(HDC hDC)
|
||||||
{
|
{
|
||||||
RECT rc;
|
RECT rc;
|
||||||
HBRUSH hbrush = NULL;
|
HBRUSH hbrush = NULL;
|
||||||
|
|
||||||
if(!hDC || _isEnabled)
|
if (!hDC || _isEnabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int oldMode = ::SetBkMode(hDC, TRANSPARENT);
|
int oldMode = ::SetBkMode(hDC, TRANSPARENT);
|
||||||
@ -107,12 +102,13 @@ void ColourPicker::drawForeground(HDC hDC)
|
|||||||
::SetBkMode(hDC, oldMode);
|
::SetBkMode(hDC, oldMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LRESULT ColourPicker::runProc(UINT Message, WPARAM wParam, LPARAM lParam)
|
LRESULT ColourPicker::runProc(UINT Message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (Message)
|
switch (Message)
|
||||||
{
|
{
|
||||||
case WM_LBUTTONDBLCLK :
|
case WM_LBUTTONDBLCLK:
|
||||||
case WM_LBUTTONDOWN :
|
case WM_LBUTTONDOWN:
|
||||||
{
|
{
|
||||||
RECT rc;
|
RECT rc;
|
||||||
POINT p;
|
POINT p;
|
||||||
@ -136,6 +132,7 @@ LRESULT ColourPicker::runProc(UINT Message, WPARAM wParam, LPARAM lParam)
|
|||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_RBUTTONDOWN:
|
case WM_RBUTTONDOWN:
|
||||||
{
|
{
|
||||||
_isEnabled = !_isEnabled;
|
_isEnabled = !_isEnabled;
|
||||||
@ -152,7 +149,7 @@ LRESULT ColourPicker::runProc(UINT Message, WPARAM wParam, LPARAM lParam)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_PAINT :
|
case WM_PAINT:
|
||||||
{
|
{
|
||||||
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
||||||
HDC dc = ::BeginPaint(_hSelf, &ps);
|
HDC dc = ::BeginPaint(_hSelf, &ps);
|
||||||
@ -161,7 +158,7 @@ LRESULT ColourPicker::runProc(UINT Message, WPARAM wParam, LPARAM lParam)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_PICKUP_COLOR :
|
case WM_PICKUP_COLOR:
|
||||||
{
|
{
|
||||||
_currentColour = (COLORREF)wParam;
|
_currentColour = (COLORREF)wParam;
|
||||||
redraw();
|
redraw();
|
||||||
@ -171,7 +168,7 @@ LRESULT ColourPicker::runProc(UINT Message, WPARAM wParam, LPARAM lParam)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_ENABLE :
|
case WM_ENABLE:
|
||||||
{
|
{
|
||||||
if ((BOOL)wParam == FALSE)
|
if ((BOOL)wParam == FALSE)
|
||||||
{
|
{
|
||||||
@ -181,12 +178,15 @@ LRESULT ColourPicker::runProc(UINT Message, WPARAM wParam, LPARAM lParam)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_PICKUP_CANCEL :
|
case WM_PICKUP_CANCEL:
|
||||||
|
{
|
||||||
_pColourPopup->display(false);
|
_pColourPopup->display(false);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
default :
|
default:
|
||||||
return ::CallWindowProc(_buttonDefaultProc, _hSelf, Message, wParam, lParam);
|
return ::CallWindowProc(_buttonDefaultProc, _hSelf, Message, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -24,62 +24,54 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#ifndef COLOUR_POPUP_H
|
|
||||||
#define COLOUR_POPUP_H
|
|
||||||
|
|
||||||
#ifndef COLOUR_POPUP_RESOURCE_H
|
|
||||||
#include "ColourPopupResource.h"
|
#include "ColourPopupResource.h"
|
||||||
#endif //COLOUR_POPUP_RESOURCE_H
|
|
||||||
|
|
||||||
#ifndef RESOURCE_H
|
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#endif //RESOURCE_H
|
|
||||||
|
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
|
|
||||||
#define WM_PICKUP_COLOR (COLOURPOPUP_USER + 1)
|
#define WM_PICKUP_COLOR (COLOURPOPUP_USER + 1)
|
||||||
#define WM_PICKUP_CANCEL (COLOURPOPUP_USER + 2)
|
#define WM_PICKUP_CANCEL (COLOURPOPUP_USER + 2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ColourPopup : public Window
|
class ColourPopup : public Window
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
ColourPopup() : Window()/*, isColourChooserLaunched(false)*/ {};
|
ColourPopup() = default;
|
||||||
ColourPopup(COLORREF defaultColor) : Window(), /* isColourChooserLaunched(false), */ _colour(defaultColor) {};
|
explicit ColourPopup(COLORREF defaultColor) : _colour(defaultColor) {}
|
||||||
~ColourPopup(){};
|
virtual ~ColourPopup() {}
|
||||||
|
|
||||||
bool isCreated() const {
|
bool isCreated() const
|
||||||
|
{
|
||||||
return (_hSelf != NULL);
|
return (_hSelf != NULL);
|
||||||
};
|
}
|
||||||
|
|
||||||
void create(int dialogID);
|
void create(int dialogID);
|
||||||
|
|
||||||
void doDialog(POINT p) {
|
void doDialog(POINT p)
|
||||||
|
{
|
||||||
if (!isCreated())
|
if (!isCreated())
|
||||||
create(IDD_COLOUR_POPUP);
|
create(IDD_COLOUR_POPUP);
|
||||||
::SetWindowPos(_hSelf, HWND_TOP, p.x, p.y, _rc.right - _rc.left, _rc.bottom - _rc.top, SWP_SHOWWINDOW);
|
::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);
|
::DestroyWindow(_hSelf);
|
||||||
};
|
}
|
||||||
|
|
||||||
void setColour(COLORREF c) {
|
void setColour(COLORREF c)
|
||||||
|
{
|
||||||
_colour = c;
|
_colour = c;
|
||||||
};
|
}
|
||||||
|
|
||||||
COLORREF getSelColour(){return _colour;};
|
COLORREF getSelColour(){return _colour;};
|
||||||
|
|
||||||
private :
|
private :
|
||||||
RECT _rc;
|
RECT _rc;
|
||||||
COLORREF _colour;
|
COLORREF _colour;
|
||||||
//bool isColourChooserLaunched;
|
//bool isColourChooserLaunched = false;
|
||||||
|
|
||||||
static INT_PTR CALLBACK dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
static INT_PTR CALLBACK dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //COLOUR_POPUP_H
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,11 +24,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#ifndef COLOUR_POPUP_RESOURCE_H
|
|
||||||
|
|
||||||
#define IDD_COLOUR_POPUP 2100
|
#define IDD_COLOUR_POPUP 2100
|
||||||
#define IDC_COLOUR_LIST (IDD_COLOUR_POPUP + 1)
|
#define IDC_COLOUR_LIST (IDD_COLOUR_POPUP + 1)
|
||||||
|
|
||||||
#endif //COLOUR_POPUP_RESOURCE_H
|
|
||||||
|
@ -142,9 +142,8 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
|
|||||||
_pBgColour->init(_hInst, _hSelf);
|
_pBgColour->init(_hInst, _hSelf);
|
||||||
|
|
||||||
POINT p1, p2;
|
POINT p1, p2;
|
||||||
|
alignWith(_hFgColourStaticText, _pFgColour->getHSelf(), PosAlign::right, p1);
|
||||||
alignWith(_hFgColourStaticText, _pFgColour->getHSelf(), ALIGNPOS_RIGHT, p1);
|
alignWith(_hBgColourStaticText, _pBgColour->getHSelf(), PosAlign::right, p2);
|
||||||
alignWith(_hBgColourStaticText, _pBgColour->getHSelf(), ALIGNPOS_RIGHT, p2);
|
|
||||||
|
|
||||||
p1.x = p2.x = ((p1.x > p2.x)?p1.x:p2.x) + 10;
|
p1.x = p2.x = ((p1.x > p2.x)?p1.x:p2.x) + 10;
|
||||||
p1.y -= 4; p2.y -= 4;
|
p1.y -= 4; p2.y -= 4;
|
||||||
@ -170,7 +169,6 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
|
|||||||
goToCenter();
|
goToCenter();
|
||||||
|
|
||||||
loadLangListFromNppParam();
|
loadLangListFromNppParam();
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -827,6 +825,7 @@ void WordStyleDlg::setVisualFromStyleList()
|
|||||||
const TCHAR *ckwStr = (style._keywords)?style._keywords->c_str():TEXT("");
|
const TCHAR *ckwStr = (style._keywords)?style._keywords->c_str():TEXT("");
|
||||||
::SendDlgItemMessage(_hSelf, IDC_USER_KEYWORDS_EDIT, WM_SETTEXT, 0, (LPARAM)(ckwStr));
|
::SendDlgItemMessage(_hSelf, IDC_USER_KEYWORDS_EDIT, WM_SETTEXT, 0, (LPARAM)(ckwStr));
|
||||||
}
|
}
|
||||||
|
|
||||||
int showOption = shouldBeDisplayed?SW_SHOW:SW_HIDE;
|
int showOption = shouldBeDisplayed?SW_SHOW:SW_HIDE;
|
||||||
::ShowWindow(::GetDlgItem(_hSelf, IDC_DEF_KEYWORDS_EDIT), showOption);
|
::ShowWindow(::GetDlgItem(_hSelf, IDC_DEF_KEYWORDS_EDIT), showOption);
|
||||||
::ShowWindow(::GetDlgItem(_hSelf, IDC_USER_KEYWORDS_EDIT),showOption);
|
::ShowWindow(::GetDlgItem(_hSelf, IDC_USER_KEYWORDS_EDIT),showOption);
|
||||||
@ -837,6 +836,7 @@ void WordStyleDlg::setVisualFromStyleList()
|
|||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WordStyleDlg::create(int dialogID, bool isRTL)
|
void WordStyleDlg::create(int dialogID, bool isRTL)
|
||||||
{
|
{
|
||||||
StaticDialog::create(dialogID, isRTL);
|
StaticDialog::create(dialogID, isRTL);
|
||||||
@ -853,6 +853,7 @@ void WordStyleDlg::create(int dialogID, bool isRTL)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WordStyleDlg::apply()
|
void WordStyleDlg::apply()
|
||||||
{
|
{
|
||||||
LexerStylerArray & lsa = (NppParameters::getInstance())->getLStylerArray();
|
LexerStylerArray & lsa = (NppParameters::getInstance())->getLStylerArray();
|
||||||
|
@ -24,8 +24,6 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "Splitter.h"
|
#include "Splitter.h"
|
||||||
@ -38,28 +36,24 @@ bool Splitter::_isVerticalFixedRegistered = false;
|
|||||||
|
|
||||||
#define SPLITTER_SIZE 8
|
#define SPLITTER_SIZE 8
|
||||||
|
|
||||||
Splitter::Splitter() : Window()
|
|
||||||
|
|
||||||
|
Splitter::Splitter()
|
||||||
{
|
{
|
||||||
//hInstance = GetModuleHandle(NULL);
|
|
||||||
_rect.left = 0; // x axis
|
_rect.left = 0; // x axis
|
||||||
_rect.top = 0; // y axis
|
_rect.top = 0; // y axis
|
||||||
_rect.right = 0; // Width of the spliter.
|
_rect.right = 0; // Width of the spliter.
|
||||||
_rect.bottom = 0; // Height of the spliter
|
_rect.bottom = 0; // Height of the spliter
|
||||||
_isFixed = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Splitter::init( HINSTANCE hInst, HWND hPere, int splitterSize,
|
void Splitter::init( HINSTANCE hInst, HWND hPere, int splitterSize, double iSplitRatio, DWORD dwFlags)
|
||||||
double iSplitRatio, DWORD dwFlags)
|
|
||||||
{
|
{
|
||||||
if (hPere == NULL)
|
if (hPere == NULL)
|
||||||
{
|
|
||||||
throw std::runtime_error("Splitter::init : Parameter hPere is null");
|
throw std::runtime_error("Splitter::init : Parameter hPere is null");
|
||||||
}
|
|
||||||
if (iSplitRatio < 0)
|
if (iSplitRatio < 0)
|
||||||
{
|
|
||||||
throw std::runtime_error("Splitter::init : Parameter iSplitRatio shoulds be 0 < ratio < 100");
|
throw std::runtime_error("Splitter::init : Parameter iSplitRatio shoulds be 0 < ratio < 100");
|
||||||
}
|
|
||||||
|
|
||||||
Window::init(hInst, hPere);
|
Window::init(hInst, hPere);
|
||||||
_spiltterSize = splitterSize;
|
_spiltterSize = splitterSize;
|
||||||
@ -183,24 +177,14 @@ void Splitter::init( HINSTANCE hInst, HWND hPere, int splitterSize,
|
|||||||
_isVerticalFixedRegistered = true;
|
_isVerticalFixedRegistered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_hSelf = CreateWindowEx(
|
_hSelf = CreateWindowEx(dwExStyle, wcex.lpszClassName,
|
||||||
dwExStyle,
|
|
||||||
wcex.lpszClassName,
|
|
||||||
TEXT(""),
|
TEXT(""),
|
||||||
dwStyle,
|
dwStyle,
|
||||||
_rect.left,
|
_rect.left, _rect.top, _rect.right, _rect.bottom,
|
||||||
_rect.top,
|
_hParent, NULL, _hInst, this);
|
||||||
_rect.right,
|
|
||||||
_rect.bottom,
|
|
||||||
_hParent,
|
|
||||||
NULL,
|
|
||||||
_hInst,
|
|
||||||
(LPVOID)this);
|
|
||||||
|
|
||||||
if (!_hSelf)
|
if (!_hSelf)
|
||||||
{
|
|
||||||
throw std::runtime_error("Splitter::init : CreateWindowEx() function return null");
|
throw std::runtime_error("Splitter::init : CreateWindowEx() function return null");
|
||||||
}
|
|
||||||
|
|
||||||
RECT rc;
|
RECT rc;
|
||||||
getClientRect(rc);
|
getClientRect(rc);
|
||||||
@ -209,8 +193,8 @@ void Splitter::init( HINSTANCE hInst, HWND hPere, int splitterSize,
|
|||||||
_clickZone2TL.left = rc.left;
|
_clickZone2TL.left = rc.left;
|
||||||
_clickZone2TL.top = rc.top;
|
_clickZone2TL.top = rc.top;
|
||||||
|
|
||||||
int clickZoneWidth = getClickZone(WIDTH);
|
int clickZoneWidth = getClickZone(WH::width);
|
||||||
int clickZoneHeight = getClickZone(HEIGHT);
|
int clickZoneHeight = getClickZone(WH::height);
|
||||||
_clickZone2TL.right = clickZoneWidth;
|
_clickZone2TL.right = clickZoneWidth;
|
||||||
_clickZone2TL.bottom = clickZoneHeight;
|
_clickZone2TL.bottom = clickZoneHeight;
|
||||||
|
|
||||||
@ -221,23 +205,33 @@ void Splitter::init( HINSTANCE hInst, HWND hPere, int splitterSize,
|
|||||||
|
|
||||||
display();
|
display();
|
||||||
::SendMessage(_hParent, WM_RESIZE_CONTAINER, _rect.left, _rect.top);
|
::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)
|
int Splitter::getClickZone(WH which)
|
||||||
{
|
{
|
||||||
|
// determinated by (_dwFlags & SV_VERTICAL) && _splitterSize
|
||||||
if (_spiltterSize <= 8)
|
if (_spiltterSize <= 8)
|
||||||
{
|
{
|
||||||
return isVertical()?(which==WIDTH?_spiltterSize:HIEGHT_MINIMAL)
|
return isVertical()
|
||||||
:(which==WIDTH?HIEGHT_MINIMAL:_spiltterSize);
|
? (which == WH::width ? _spiltterSize : HIEGHT_MINIMAL)
|
||||||
|
: (which == WH::width ? HIEGHT_MINIMAL : _spiltterSize);
|
||||||
}
|
}
|
||||||
else // (_spiltterSize > 8)
|
else // (_spiltterSize > 8)
|
||||||
{
|
{
|
||||||
return isVertical()?(which==WIDTH? 8:15)
|
return isVertical()
|
||||||
:(which==WIDTH?15:8);
|
? ((which == WH::width) ? 8 : 15)
|
||||||
|
: ((which == WH::width) ? 15 : 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LRESULT CALLBACK Splitter::staticWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK Splitter::staticWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch(uMsg)
|
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)
|
LRESULT CALLBACK Splitter::spliterWndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (uMsg)
|
switch (uMsg)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
case WM_LBUTTONDBLCLK:
|
|
||||||
{
|
|
||||||
::MessageBox(NULL, TEXT(""), TEXT(""), MB_OK);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
case WM_RBUTTONDBLCLK:
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
*/
|
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
{
|
{
|
||||||
POINT p;
|
POINT p;
|
||||||
@ -300,12 +282,15 @@ LRESULT CALLBACK Splitter::spliterWndProc(UINT uMsg, WPARAM wParam, LPARAM lPara
|
|||||||
::SetCapture(_hSelf);
|
::SetCapture(_hSelf);
|
||||||
_isDraged = true;
|
_isDraged = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
case WM_RBUTTONDOWN :
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
case WM_RBUTTONDOWN:
|
||||||
|
{
|
||||||
::SendMessage(_hParent, WM_DOPOPUPMENU, wParam, lParam);
|
::SendMessage(_hParent, WM_DOPOPUPMENU, wParam, lParam);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
{
|
{
|
||||||
@ -386,6 +371,7 @@ LRESULT CALLBACK Splitter::spliterWndProc(UINT uMsg, WPARAM wParam, LPARAM lPara
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_CAPTURECHANGED:
|
case WM_CAPTURECHANGED:
|
||||||
{
|
{
|
||||||
if (_isDraged)
|
if (_isDraged)
|
||||||
@ -397,17 +383,23 @@ LRESULT CALLBACK Splitter::spliterWndProc(UINT uMsg, WPARAM wParam, LPARAM lPara
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_PAINT :
|
case WM_PAINT:
|
||||||
|
{
|
||||||
drawSplitter();
|
drawSplitter();
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
|
{
|
||||||
destroy();
|
destroy();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ::DefWindowProc(_hSelf, uMsg, wParam, lParam);
|
return ::DefWindowProc(_hSelf, uMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Splitter::resizeSpliter(RECT *pRect)
|
void Splitter::resizeSpliter(RECT *pRect)
|
||||||
{
|
{
|
||||||
RECT rect;
|
RECT rect;
|
||||||
@ -449,8 +441,8 @@ void Splitter::resizeSpliter(RECT *pRect)
|
|||||||
|
|
||||||
RECT rc;
|
RECT rc;
|
||||||
getClientRect(rc);
|
getClientRect(rc);
|
||||||
_clickZone2BR.right = getClickZone(WIDTH);
|
_clickZone2BR.right = getClickZone(WH::width);
|
||||||
_clickZone2BR.bottom = getClickZone(HEIGHT);
|
_clickZone2BR.bottom = getClickZone(WH::height);
|
||||||
_clickZone2BR.left = rc.right - _clickZone2BR.right;
|
_clickZone2BR.left = rc.right - _clickZone2BR.right;
|
||||||
_clickZone2BR.top = rc.bottom - _clickZone2BR.bottom;
|
_clickZone2BR.top = rc.bottom - _clickZone2BR.bottom;
|
||||||
|
|
||||||
@ -460,6 +452,7 @@ void Splitter::resizeSpliter(RECT *pRect)
|
|||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Splitter::gotoTopLeft()
|
void Splitter::gotoTopLeft()
|
||||||
{
|
{
|
||||||
if ((_dwFlags & SV_ENABLELDBLCLK) && (!_isFixed) && (_splitPercent > 1))
|
if ((_dwFlags & SV_ENABLELDBLCLK) && (!_isFixed) && (_splitPercent > 1))
|
||||||
@ -468,6 +461,7 @@ void Splitter::gotoTopLeft()
|
|||||||
_rect.top = 1;
|
_rect.top = 1;
|
||||||
else
|
else
|
||||||
_rect.left = 1;
|
_rect.left = 1;
|
||||||
|
|
||||||
_splitPercent = 1;
|
_splitPercent = 1;
|
||||||
|
|
||||||
::SendMessage(_hParent, WM_RESIZE_CONTAINER, _rect.left, _rect.top);
|
::SendMessage(_hParent, WM_RESIZE_CONTAINER, _rect.left, _rect.top);
|
||||||
@ -476,6 +470,7 @@ void Splitter::gotoTopLeft()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Splitter::gotoRightBouuom()
|
void Splitter::gotoRightBouuom()
|
||||||
{
|
{
|
||||||
if ((_dwFlags & SV_ENABLERDBLCLK) && (!_isFixed) && (_splitPercent < 99))
|
if ((_dwFlags & SV_ENABLERDBLCLK) && (!_isFixed) && (_splitPercent < 99))
|
||||||
@ -496,6 +491,7 @@ void Splitter::gotoRightBouuom()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Splitter::drawSplitter()
|
void Splitter::drawSplitter()
|
||||||
{
|
{
|
||||||
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
||||||
@ -506,14 +502,14 @@ void Splitter::drawSplitter()
|
|||||||
|
|
||||||
if ((_spiltterSize >= 4) && (_dwFlags & SV_RESIZEWTHPERCNT))
|
if ((_spiltterSize >= 4) && (_dwFlags & SV_RESIZEWTHPERCNT))
|
||||||
{
|
{
|
||||||
adjustZoneToDraw(TLrc, TOP_LEFT);
|
adjustZoneToDraw(TLrc, ZONE_TYPE::topLeft);
|
||||||
adjustZoneToDraw(BRrc, BOTTOM_RIGHT);
|
adjustZoneToDraw(BRrc, ZONE_TYPE::bottomRight);
|
||||||
paintArrow(hdc, TLrc, isVertical()?ARROW_LEFT:ARROW_UP);
|
paintArrow(hdc, TLrc, isVertical() ? Arrow::left : Arrow::up);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isVertical())
|
if (isVertical())
|
||||||
{
|
{
|
||||||
rcToDraw2.top = (_dwFlags & SV_RESIZEWTHPERCNT)?_clickZone2TL.bottom:0;
|
rcToDraw2.top = (_dwFlags & SV_RESIZEWTHPERCNT) ? _clickZone2TL.bottom : 0;
|
||||||
rcToDraw2.bottom = rcToDraw2.top + 2;
|
rcToDraw2.bottom = rcToDraw2.top + 2;
|
||||||
|
|
||||||
rcToDraw1.top = rcToDraw2.top + 1;
|
rcToDraw1.top = rcToDraw2.top + 1;
|
||||||
@ -563,6 +559,7 @@ void Splitter::drawSplitter()
|
|||||||
rcToDraw1.left += 4;
|
rcToDraw1.left += 4;
|
||||||
rcToDraw1.right += 4;
|
rcToDraw1.right += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
rcToDraw2.top += 4;
|
rcToDraw2.top += 4;
|
||||||
rcToDraw2.bottom += 4;
|
rcToDraw2.bottom += 4;
|
||||||
rcToDraw1.top += 4;
|
rcToDraw1.top += 4;
|
||||||
@ -570,16 +567,18 @@ void Splitter::drawSplitter()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((_spiltterSize >= 4) && (_dwFlags & SV_RESIZEWTHPERCNT))
|
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);
|
::EndPaint(_hSelf, &ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Splitter::rotate()
|
void Splitter::rotate()
|
||||||
{
|
{
|
||||||
if (!_isFixed)
|
if (!_isFixed)
|
||||||
{
|
{
|
||||||
destroy();
|
destroy();
|
||||||
|
|
||||||
if (_dwFlags & SV_HORIZONTAL)
|
if (_dwFlags & SV_HORIZONTAL)
|
||||||
{
|
{
|
||||||
_dwFlags ^= SV_HORIZONTAL;
|
_dwFlags ^= SV_HORIZONTAL;
|
||||||
@ -590,28 +589,35 @@ void Splitter::rotate()
|
|||||||
_dwFlags ^= SV_VERTICAL;
|
_dwFlags ^= SV_VERTICAL;
|
||||||
_dwFlags |= SV_HORIZONTAL;
|
_dwFlags |= SV_HORIZONTAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
init(_hInst, _hParent, _spiltterSize, _splitPercent, _dwFlags);
|
init(_hInst, _hParent, _spiltterSize, _splitPercent, _dwFlags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Splitter::paintArrow(HDC hdc, const RECT &rect, Arrow arrowDir)
|
void Splitter::paintArrow(HDC hdc, const RECT &rect, Arrow arrowDir)
|
||||||
{
|
{
|
||||||
RECT rc;
|
RECT rc;
|
||||||
rc.left = rect.left; rc.top = rect.top;
|
rc.left = rect.left; rc.top = rect.top;
|
||||||
rc.right = rect.right; rc.bottom = rect.bottom;
|
rc.right = rect.right; rc.bottom = rect.bottom;
|
||||||
if (arrowDir == ARROW_LEFT)
|
|
||||||
|
switch (arrowDir)
|
||||||
|
{
|
||||||
|
case Arrow::left:
|
||||||
{
|
{
|
||||||
int x = rc.right;
|
int x = rc.right;
|
||||||
int y = rc.top;
|
int y = rc.top;
|
||||||
|
|
||||||
//::MoveToEx(hdc, x, y, NULL);
|
//::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);
|
::MoveToEx(hdc, x, y++, NULL);
|
||||||
::LineTo(hdc, x, rc.bottom--);
|
::LineTo(hdc, x, rc.bottom--);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else if (arrowDir == ARROW_RIGHT)
|
|
||||||
|
case Arrow::right:
|
||||||
{
|
{
|
||||||
int x = rc.left;
|
int x = rc.left;
|
||||||
int y = rc.top;
|
int y = rc.top;
|
||||||
@ -622,20 +628,24 @@ void Splitter::paintArrow(HDC hdc, const RECT &rect, Arrow arrowDir)
|
|||||||
::MoveToEx(hdc, x, y++, NULL);
|
::MoveToEx(hdc, x, y++, NULL);
|
||||||
::LineTo(hdc, x, rc.bottom--);
|
::LineTo(hdc, x, rc.bottom--);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else if (arrowDir == ARROW_UP)
|
|
||||||
|
case Arrow::up:
|
||||||
{
|
{
|
||||||
int x = rc.left;
|
int x = rc.left;
|
||||||
int y = rc.bottom;
|
int y = rc.bottom;
|
||||||
|
|
||||||
//::MoveToEx(hdc, x, y, NULL);
|
//::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);
|
::MoveToEx(hdc, x++, y, NULL);
|
||||||
::LineTo(hdc, rc.right--, y);
|
::LineTo(hdc, rc.right--, y);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else if (arrowDir == ARROW_DOWN)
|
|
||||||
|
case Arrow::down:
|
||||||
{
|
{
|
||||||
int x = rc.left;
|
int x = rc.left;
|
||||||
int y = rc.top;
|
int y = rc.top;
|
||||||
@ -646,26 +656,34 @@ void Splitter::paintArrow(HDC hdc, const RECT &rect, Arrow arrowDir)
|
|||||||
::MoveToEx(hdc, x++, y, NULL);
|
::MoveToEx(hdc, x++, y, NULL);
|
||||||
::LineTo(hdc, rc.right--, y);
|
::LineTo(hdc, rc.right--, y);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Splitter::adjustZoneToDraw(RECT & rc2def, ZONE_TYPE whichZone)
|
|
||||||
|
|
||||||
|
void Splitter::adjustZoneToDraw(RECT& rc2def, ZONE_TYPE whichZone)
|
||||||
{
|
{
|
||||||
if (_spiltterSize < 4) return;
|
if (_spiltterSize < 4)
|
||||||
|
return;
|
||||||
|
|
||||||
int x0, y0, x1, y1, w, h;
|
int x0, y0, x1, y1, w, h;
|
||||||
|
|
||||||
if ((4 <= _spiltterSize) && (_spiltterSize <= 8))
|
if ((4 <= _spiltterSize) && (_spiltterSize <= 8))
|
||||||
{
|
{
|
||||||
w = (isVertical()?4:7);
|
w = (isVertical() ? 4 : 7);
|
||||||
h = (isVertical()?7:4);
|
h = (isVertical() ? 7 : 4);
|
||||||
}
|
}
|
||||||
else // (_spiltterSize > 8)
|
else // (_spiltterSize > 8)
|
||||||
{
|
{
|
||||||
w = (isVertical()?6:11);
|
w = (isVertical() ? 6 : 11);
|
||||||
h = (isVertical()?11:6);
|
h = (isVertical() ? 11 : 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isVertical())
|
if (isVertical())
|
||||||
{//w=4 h=7
|
{
|
||||||
if (whichZone == TOP_LEFT)
|
// w=4 h=7
|
||||||
|
if (whichZone == ZONE_TYPE::topLeft)
|
||||||
{
|
{
|
||||||
x0 = 0;
|
x0 = 0;
|
||||||
y0 = (_clickZone2TL.bottom - h) / 2;
|
y0 = (_clickZone2TL.bottom - h) / 2;
|
||||||
@ -675,12 +693,14 @@ void Splitter::adjustZoneToDraw(RECT & rc2def, ZONE_TYPE whichZone)
|
|||||||
x0 = _clickZone2BR.left + _clickZone2BR.right - w;
|
x0 = _clickZone2BR.left + _clickZone2BR.right - w;
|
||||||
y0 = (_clickZone2BR.bottom - h) / 2 + _clickZone2BR.top;
|
y0 = (_clickZone2BR.bottom - h) / 2 + _clickZone2BR.top;
|
||||||
}
|
}
|
||||||
|
|
||||||
x1 = x0 + w;
|
x1 = x0 + w;
|
||||||
y1 = y0 + h;
|
y1 = y0 + h;
|
||||||
}
|
}
|
||||||
else // Horizontal
|
else // Horizontal
|
||||||
{//w=7 h=4
|
{
|
||||||
if (whichZone == TOP_LEFT)
|
//w=7 h=4
|
||||||
|
if (whichZone == ZONE_TYPE::topLeft)
|
||||||
{
|
{
|
||||||
x0 = (_clickZone2TL.right - w) / 2;
|
x0 = (_clickZone2TL.right - w) / 2;
|
||||||
y0 = 0;
|
y0 = 0;
|
||||||
@ -690,11 +710,14 @@ void Splitter::adjustZoneToDraw(RECT & rc2def, ZONE_TYPE whichZone)
|
|||||||
x0 = ((_clickZone2BR.right - w) / 2) + _clickZone2BR.left;
|
x0 = ((_clickZone2BR.right - w) / 2) + _clickZone2BR.left;
|
||||||
y0 = _clickZone2BR.top + _clickZone2BR.bottom - h;
|
y0 = _clickZone2BR.top + _clickZone2BR.bottom - h;
|
||||||
}
|
}
|
||||||
|
|
||||||
x1 = x0 + w;
|
x1 = x0 + w;
|
||||||
y1 = y0 + h;
|
y1 = y0 + h;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc2def.left = x0;
|
rc2def.left = x0;
|
||||||
rc2def.top = y0;
|
rc2def.top = y0;
|
||||||
rc2def.right = x1;
|
rc2def.right = x1;
|
||||||
rc2def.bottom = y1;
|
rc2def.bottom = y1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,16 +24,11 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#ifndef SPLITTER_H
|
|
||||||
#define SPLITTER_H
|
|
||||||
|
|
||||||
#ifndef RESOURCE_H
|
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#endif //RESOURCE_H
|
|
||||||
|
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
|
#include "Common.h"
|
||||||
|
|
||||||
|
|
||||||
#define SV_HORIZONTAL 0x00000001
|
#define SV_HORIZONTAL 0x00000001
|
||||||
#define SV_VERTICAL 0x00000002
|
#define SV_VERTICAL 0x00000002
|
||||||
@ -50,43 +45,47 @@
|
|||||||
|
|
||||||
const int HIEGHT_MINIMAL = 15;
|
const int HIEGHT_MINIMAL = 15;
|
||||||
|
|
||||||
enum Arrow {ARROW_LEFT, ARROW_UP, ARROW_RIGHT, ARROW_DOWN};
|
|
||||||
|
|
||||||
typedef bool WH;
|
enum class Arrow { left, up, right, down };
|
||||||
const bool WIDTH = true;
|
|
||||||
const bool HEIGHT = false;
|
|
||||||
|
|
||||||
typedef bool ZONE_TYPE;
|
enum class WH { height, width };
|
||||||
const bool TOP_LEFT = true;
|
|
||||||
const bool BOTTOM_RIGHT = false;
|
|
||||||
|
|
||||||
enum SplitterMode {
|
enum class ZONE_TYPE { bottomRight, topLeft };
|
||||||
|
|
||||||
|
enum class SplitterMode: std::uint8_t
|
||||||
|
{
|
||||||
DYNAMIC, LEFT_FIX, RIGHT_FIX
|
DYNAMIC, LEFT_FIX, RIGHT_FIX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Splitter : public Window
|
class Splitter : public Window
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Splitter();
|
Splitter();
|
||||||
~Splitter(){};
|
virtual ~Splitter() = default;
|
||||||
void destroy() {
|
|
||||||
::DestroyWindow(_hSelf);
|
virtual void destroy() override;
|
||||||
};
|
|
||||||
void resizeSpliter(RECT *pRect = NULL);
|
void resizeSpliter(RECT *pRect = NULL);
|
||||||
void init(HINSTANCE hInst, HWND hPere, int splitterSize,
|
void init(HINSTANCE hInst, HWND hPere, int splitterSize, double iSplitRatio, DWORD dwFlags);
|
||||||
double iSplitRatio, DWORD dwFlags);
|
|
||||||
void rotate();
|
void rotate();
|
||||||
int getPhisicalSize() const {
|
|
||||||
|
int getPhisicalSize() const
|
||||||
|
{
|
||||||
return _spiltterSize;
|
return _spiltterSize;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RECT _rect;
|
RECT _rect;
|
||||||
double _splitPercent;
|
double _splitPercent = 0.;
|
||||||
int _spiltterSize;
|
int _spiltterSize = 0;
|
||||||
bool _isDraged;
|
bool _isDraged = false;
|
||||||
DWORD _dwFlags;
|
DWORD _dwFlags = 0;
|
||||||
bool _isFixed;
|
bool _isFixed = false;
|
||||||
static bool _isHorizontalRegistered;
|
static bool _isHorizontalRegistered;
|
||||||
static bool _isVerticalRegistered;
|
static bool _isVerticalRegistered;
|
||||||
static bool _isHorizontalFixedRegistered;
|
static bool _isHorizontalFixedRegistered;
|
||||||
@ -105,26 +104,31 @@ private:
|
|||||||
void gotoTopLeft();
|
void gotoTopLeft();
|
||||||
void gotoRightBouuom();
|
void gotoRightBouuom();
|
||||||
|
|
||||||
bool isInLeftTopZone(const POINT &p) const {
|
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));
|
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 {
|
bool isInRightBottomZone(const POINT& p) const
|
||||||
return (((p.x >= _clickZone2BR.left) &&
|
{
|
||||||
(p.x <= _clickZone2BR.left + _clickZone2BR.right)) &&
|
return ((p.x >= _clickZone2BR.left)
|
||||||
(p.y >= _clickZone2BR.top) &&
|
and (p.x <= _clickZone2BR.left + _clickZone2BR.right)
|
||||||
(p.y <= _clickZone2BR.top + _clickZone2BR.bottom));
|
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));
|
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));
|
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
|
|
||||||
|
@ -24,16 +24,18 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "SplitterContainer.h"
|
#include "SplitterContainer.h"
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool SplitterContainer::_isRegistered = false;
|
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);
|
//Window::init(hInst, parent);
|
||||||
_pWin0 = pWin0;
|
_pWin0 = pWin0;
|
||||||
@ -42,7 +44,8 @@ void SplitterContainer::create(Window *pWin0, Window *pWin1, int splitterSize,
|
|||||||
_splitterMode = mode;
|
_splitterMode = mode;
|
||||||
_ratio = ratio;
|
_ratio = ratio;
|
||||||
_dwSplitterStyle |= isVertical?SV_VERTICAL:SV_HORIZONTAL;
|
_dwSplitterStyle |= isVertical?SV_VERTICAL:SV_HORIZONTAL;
|
||||||
if (_splitterMode != DYNAMIC)
|
|
||||||
|
if (_splitterMode != SplitterMode::DYNAMIC)
|
||||||
{
|
{
|
||||||
_dwSplitterStyle |= SV_FIXED;
|
_dwSplitterStyle |= SV_FIXED;
|
||||||
_dwSplitterStyle &= ~SV_RESIZEWTHPERCNT;
|
_dwSplitterStyle &= ~SV_RESIZEWTHPERCNT;
|
||||||
@ -66,30 +69,63 @@ void SplitterContainer::create(Window *pWin0, Window *pWin1, int splitterSize,
|
|||||||
splitterContainerClass.lpszClassName = SPC_CLASS_NAME;
|
splitterContainerClass.lpszClassName = SPC_CLASS_NAME;
|
||||||
|
|
||||||
if (!::RegisterClass(&splitterContainerClass))
|
if (!::RegisterClass(&splitterContainerClass))
|
||||||
{
|
|
||||||
throw std::runtime_error(" SplitterContainer::create : RegisterClass() function failed");
|
throw std::runtime_error(" SplitterContainer::create : RegisterClass() function failed");
|
||||||
}
|
|
||||||
_isRegistered = true;
|
_isRegistered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_hSelf = ::CreateWindowEx(
|
_hSelf = ::CreateWindowEx(
|
||||||
0,
|
0, SPC_CLASS_NAME, TEXT("a koi sert?"),
|
||||||
SPC_CLASS_NAME,
|
|
||||||
TEXT("a koi sert?"),
|
|
||||||
WS_CHILD | WS_CLIPCHILDREN,
|
WS_CHILD | WS_CLIPCHILDREN,
|
||||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
_hParent, NULL, _hInst, this);
|
||||||
_hParent,
|
|
||||||
NULL,
|
|
||||||
_hInst,
|
|
||||||
(LPVOID)this);
|
|
||||||
|
|
||||||
if (!_hSelf)
|
if (!_hSelf)
|
||||||
{
|
|
||||||
throw std::runtime_error(" SplitterContainer::create : CreateWindowEx() function return null");
|
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)
|
void SplitterContainer::rotateTo(DIRECTION direction)
|
||||||
{
|
{
|
||||||
bool doSwitchWindow = false;
|
bool doSwitchWindow = false;
|
||||||
@ -97,13 +133,13 @@ void SplitterContainer::rotateTo(DIRECTION direction)
|
|||||||
{
|
{
|
||||||
_dwSplitterStyle ^= SV_VERTICAL;
|
_dwSplitterStyle ^= SV_VERTICAL;
|
||||||
_dwSplitterStyle |= SV_HORIZONTAL;
|
_dwSplitterStyle |= SV_HORIZONTAL;
|
||||||
doSwitchWindow = (direction == LEFT);
|
doSwitchWindow = (direction == DIRECTION::LEFT);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_dwSplitterStyle ^= SV_HORIZONTAL;
|
_dwSplitterStyle ^= SV_HORIZONTAL;
|
||||||
_dwSplitterStyle |= SV_VERTICAL;
|
_dwSplitterStyle |= SV_VERTICAL;
|
||||||
doSwitchWindow = (direction == RIGHT);
|
doSwitchWindow = (direction == DIRECTION::RIGHT);
|
||||||
}
|
}
|
||||||
if (doSwitchWindow)
|
if (doSwitchWindow)
|
||||||
{
|
{
|
||||||
@ -120,42 +156,54 @@ LRESULT CALLBACK SplitterContainer::staticWinProc(HWND hwnd, UINT message, WPARA
|
|||||||
SplitterContainer *pSplitterContainer = NULL;
|
SplitterContainer *pSplitterContainer = NULL;
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
case WM_NCCREATE :
|
case WM_NCCREATE:
|
||||||
|
{
|
||||||
pSplitterContainer = (SplitterContainer *)(((LPCREATESTRUCT)lParam)->lpCreateParams);
|
pSplitterContainer = (SplitterContainer *)(((LPCREATESTRUCT)lParam)->lpCreateParams);
|
||||||
pSplitterContainer->_hSelf = hwnd;
|
pSplitterContainer->_hSelf = hwnd;
|
||||||
::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pSplitterContainer);
|
::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pSplitterContainer);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
default :
|
default:
|
||||||
|
{
|
||||||
pSplitterContainer = (SplitterContainer *)::GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
pSplitterContainer = (SplitterContainer *)::GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||||
if (!pSplitterContainer)
|
if (!pSplitterContainer)
|
||||||
return ::DefWindowProc(hwnd, message, wParam, lParam);
|
return ::DefWindowProc(hwnd, message, wParam, lParam);
|
||||||
return pSplitterContainer->runProc(message, wParam, lParam);
|
return pSplitterContainer->runProc(message, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LRESULT SplitterContainer::runProc(UINT message, WPARAM wParam, LPARAM lParam)
|
LRESULT SplitterContainer::runProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
case WM_CREATE :
|
case WM_CREATE:
|
||||||
|
{
|
||||||
_splitter.init(_hInst, _hSelf, _splitterSize, _ratio, _dwSplitterStyle);
|
_splitter.init(_hInst, _hSelf, _splitterSize, _ratio, _dwSplitterStyle);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_COMMAND :
|
case WM_COMMAND:
|
||||||
{
|
{
|
||||||
switch (LOWORD(wParam))
|
switch (LOWORD(wParam))
|
||||||
{
|
{
|
||||||
case ROTATION_A_GAUCHE:
|
case ROTATION_A_GAUCHE:
|
||||||
rotateTo(LEFT);
|
{
|
||||||
return TRUE;
|
rotateTo(DIRECTION::LEFT);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case ROTATION_A_DROITE:
|
case ROTATION_A_DROITE:
|
||||||
rotateTo(RIGHT);
|
{
|
||||||
return TRUE;
|
rotateTo(DIRECTION::RIGHT);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
case WM_RESIZE_CONTAINER :
|
|
||||||
|
case WM_RESIZE_CONTAINER:
|
||||||
{
|
{
|
||||||
RECT rc0, rc1;
|
RECT rc0, rc1;
|
||||||
getClientRect(rc0);
|
getClientRect(rc0);
|
||||||
@ -192,9 +240,9 @@ LRESULT SplitterContainer::runProc(UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_DOPOPUPMENU :
|
case WM_DOPOPUPMENU:
|
||||||
{
|
{
|
||||||
if ((_splitterMode != LEFT_FIX) && (_splitterMode != RIGHT_FIX) )
|
if ((_splitterMode != SplitterMode::LEFT_FIX) && (_splitterMode != SplitterMode::RIGHT_FIX) )
|
||||||
{
|
{
|
||||||
POINT p;
|
POINT p;
|
||||||
::GetCursorPos(&p);
|
::GetCursorPos(&p);
|
||||||
@ -213,35 +261,47 @@ LRESULT SplitterContainer::runProc(UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_GETSPLITTER_X :
|
case WM_GETSPLITTER_X:
|
||||||
{
|
{
|
||||||
if (_splitterMode == LEFT_FIX)
|
switch (_splitterMode)
|
||||||
return MAKELONG(_pWin0->getWidth(), LEFT_FIX);
|
{
|
||||||
else if (_splitterMode == RIGHT_FIX)
|
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();
|
int x = getWidth()-_pWin1->getWidth();
|
||||||
if (x < 0)
|
if (x < 0)
|
||||||
x = 0;
|
x = 0;
|
||||||
return MAKELONG(x, RIGHT_FIX);
|
return MAKELONG(x, static_cast<std::uint8_t>(SplitterMode::RIGHT_FIX));
|
||||||
}
|
}
|
||||||
else
|
default:
|
||||||
return MAKELONG(0, DYNAMIC);
|
break;
|
||||||
|
}
|
||||||
|
return MAKELONG(0, static_cast<std::uint8_t>(SplitterMode::DYNAMIC));
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_GETSPLITTER_Y :
|
case WM_GETSPLITTER_Y:
|
||||||
{
|
{
|
||||||
if (_splitterMode == LEFT_FIX)
|
switch (_splitterMode)
|
||||||
return MAKELONG(_pWin0->getHeight(), LEFT_FIX);
|
{
|
||||||
else if (_splitterMode == RIGHT_FIX)
|
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();
|
int y = getHeight()-_pWin1->getHeight();
|
||||||
if (y < 0)
|
if (y < 0)
|
||||||
y = 0;
|
y = 0;
|
||||||
return MAKELONG(y, RIGHT_FIX);
|
return MAKELONG(y, static_cast<std::uint8_t>(SplitterMode::RIGHT_FIX));
|
||||||
}
|
}
|
||||||
else
|
default:
|
||||||
return MAKELONG(0, DYNAMIC);
|
break;
|
||||||
|
}
|
||||||
|
return MAKELONG(0, static_cast<std::uint8_t>(SplitterMode::DYNAMIC));
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_LBUTTONDBLCLK:
|
case WM_LBUTTONDBLCLK:
|
||||||
@ -250,21 +310,18 @@ LRESULT SplitterContainer::runProc(UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
::GetCursorPos(&pt);
|
::GetCursorPos(&pt);
|
||||||
::ScreenToClient(_splitter.getHSelf(), &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());
|
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, NPPM_INTERNAL_SWITCHVIEWFROMHWND, 0, (LPARAM)targetWindow->getHSelf());
|
||||||
::SendMessage(parent, WM_COMMAND, IDM_FILE_NEW, 0);
|
::SendMessage(parent, WM_COMMAND, IDM_FILE_NEW, 0);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
default :
|
default:
|
||||||
return ::DefWindowProc(_hSelf, message, wParam, lParam);
|
return ::DefWindowProc(_hSelf, message, wParam, lParam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,94 +24,74 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#ifndef SPLITTER_CONTAINER_H
|
|
||||||
#define SPLITTER_CONTAINER_H
|
|
||||||
|
|
||||||
#ifndef SPLITTER_H
|
|
||||||
#include "Splitter.h"
|
#include "Splitter.h"
|
||||||
#endif //SPLITTER_H
|
|
||||||
|
|
||||||
#ifndef MENUCMDID_H
|
|
||||||
#include "menuCmdID.h"
|
#include "menuCmdID.h"
|
||||||
#endif //MENUCMDID_H
|
|
||||||
|
|
||||||
#define SPC_CLASS_NAME TEXT("splitterContainer")
|
#define SPC_CLASS_NAME TEXT("splitterContainer")
|
||||||
|
|
||||||
#define ROTATION_A_GAUCHE 2000
|
#define ROTATION_A_GAUCHE 2000
|
||||||
#define ROTATION_A_DROITE 2001
|
#define ROTATION_A_DROITE 2001
|
||||||
|
|
||||||
typedef bool DIRECTION;
|
|
||||||
const bool LEFT = true;
|
enum class DIRECTION
|
||||||
const bool RIGHT = false;
|
{
|
||||||
|
RIGHT,
|
||||||
|
LEFT
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SplitterContainer : public Window
|
class SplitterContainer : public Window
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
SplitterContainer(): Window(), _x(0), _y(0), _hPopupMenu(NULL),
|
virtual ~SplitterContainer() = default;
|
||||||
_dwSplitterStyle(SV_ENABLERDBLCLK | SV_ENABLELDBLCLK | SV_RESIZEWTHPERCNT){
|
|
||||||
};
|
|
||||||
~SplitterContainer(){};
|
|
||||||
void create(Window *pWin0, Window *pWin1, int splitterSize = 4,
|
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() {
|
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);
|
|
||||||
|
|
||||||
_pWin0->display(toShow);
|
void reSizeTo(RECT & rc);
|
||||||
_pWin1->display(toShow);
|
|
||||||
_splitter.display(toShow);
|
|
||||||
};
|
|
||||||
virtual void redraw() const {
|
|
||||||
_pWin0->redraw(true);
|
|
||||||
_pWin1->redraw(true);
|
|
||||||
};
|
|
||||||
|
|
||||||
void setWin0(Window *pWin) {
|
virtual void display(bool toShow = true) const;
|
||||||
|
|
||||||
|
virtual void redraw() const;
|
||||||
|
|
||||||
|
void setWin0(Window* pWin)
|
||||||
|
{
|
||||||
_pWin0 = pWin;
|
_pWin0 = pWin;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
void setWin1(Window* pWin)
|
||||||
|
{
|
||||||
void setWin1(Window *pWin) {
|
|
||||||
_pWin1 = pWin;
|
_pWin1 = pWin;
|
||||||
};
|
}
|
||||||
|
|
||||||
bool isVertical() const {
|
bool isVertical() const
|
||||||
|
{
|
||||||
return ((_dwSplitterStyle & SV_VERTICAL) != 0);
|
return ((_dwSplitterStyle & SV_VERTICAL) != 0);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
private :
|
private :
|
||||||
Window *_pWin0; // left or top window
|
Window* _pWin0 = nullptr; // left or top window
|
||||||
Window *_pWin1; // right or bottom window
|
Window* _pWin1 = nullptr; // right or bottom window
|
||||||
|
|
||||||
Splitter _splitter;
|
Splitter _splitter;
|
||||||
int _splitterSize;
|
int _splitterSize = 0;
|
||||||
int _ratio;
|
int _ratio = 0;
|
||||||
int _x, _y;
|
int _x = 0;
|
||||||
HMENU _hPopupMenu;
|
int _y = 0;
|
||||||
DWORD _dwSplitterStyle;
|
HMENU _hPopupMenu = NULL;
|
||||||
|
DWORD _dwSplitterStyle = (SV_ENABLERDBLCLK | SV_ENABLELDBLCLK | SV_RESIZEWTHPERCNT);
|
||||||
|
|
||||||
SplitterMode _splitterMode;
|
SplitterMode _splitterMode = SplitterMode::DYNAMIC;
|
||||||
static bool _isRegistered;
|
static bool _isRegistered;
|
||||||
|
|
||||||
static LRESULT CALLBACK staticWinProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
|
static LRESULT CALLBACK staticWinProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
|
||||||
LRESULT runProc(UINT Message, WPARAM wParam, LPARAM lParam);
|
LRESULT runProc(UINT Message, WPARAM wParam, LPARAM lParam);
|
||||||
void rotateTo(DIRECTION direction);
|
void rotateTo(DIRECTION direction);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //SPLITTER_CONTAINER_H
|
|
||||||
|
@ -29,6 +29,43 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "StaticDialog.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()
|
void StaticDialog::goToCenter()
|
||||||
{
|
{
|
||||||
RECT rc;
|
RECT rc;
|
||||||
@ -47,7 +84,8 @@ void StaticDialog::goToCenter()
|
|||||||
|
|
||||||
void StaticDialog::display(bool toShow) const
|
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
|
// 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.
|
// displayed the dialog, then ensure that it's still visible on the single monitor.
|
||||||
RECT workAreaRect = {0};
|
RECT workAreaRect = {0};
|
||||||
@ -57,6 +95,7 @@ void StaticDialog::display(bool toShow) const
|
|||||||
int newLeft = rc.left;
|
int newLeft = rc.left;
|
||||||
int newTop = rc.top;
|
int newTop = rc.top;
|
||||||
int margin = ::GetSystemMetrics(SM_CYSMCAPTION);
|
int margin = ::GetSystemMetrics(SM_CYSMCAPTION);
|
||||||
|
|
||||||
if (newLeft > ::GetSystemMetrics(SM_CXVIRTUALSCREEN)-margin)
|
if (newLeft > ::GetSystemMetrics(SM_CXVIRTUALSCREEN)-margin)
|
||||||
newLeft -= rc.right - workAreaRect.right;
|
newLeft -= rc.right - workAreaRect.right;
|
||||||
if (newLeft + (rc.right - rc.left) < ::GetSystemMetrics(SM_XVIRTUALSCREEN)+margin)
|
if (newLeft + (rc.right - rc.left) < ::GetSystemMetrics(SM_XVIRTUALSCREEN)+margin)
|
||||||
@ -131,11 +170,12 @@ void StaticDialog::create(int dialogID, bool isRTL, bool msgDestParent)
|
|||||||
::SendMessage(msgDestParent?_hParent:(::GetParent(_hParent)), NPPM_MODELESSDIALOG, MODELESSDIALOGADD, (WPARAM)_hSelf);
|
::SendMessage(msgDestParent?_hParent:(::GetParent(_hParent)), NPPM_MODELESSDIALOG, MODELESSDIALOGADD, (WPARAM)_hSelf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
INT_PTR CALLBACK StaticDialog::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
INT_PTR CALLBACK StaticDialog::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
case WM_INITDIALOG :
|
case WM_INITDIALOG:
|
||||||
{
|
{
|
||||||
StaticDialog *pStaticDlg = (StaticDialog *)(lParam);
|
StaticDialog *pStaticDlg = (StaticDialog *)(lParam);
|
||||||
pStaticDlg->_hSelf = hwnd;
|
pStaticDlg->_hSelf = hwnd;
|
||||||
@ -146,7 +186,7 @@ INT_PTR CALLBACK StaticDialog::dlgProc(HWND hwnd, UINT message, WPARAM wParam, L
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
default :
|
default:
|
||||||
{
|
{
|
||||||
StaticDialog *pStaticDlg = reinterpret_cast<StaticDialog *>(::GetWindowLongPtr(hwnd, GWLP_USERDATA));
|
StaticDialog *pStaticDlg = reinterpret_cast<StaticDialog *>(::GetWindowLongPtr(hwnd, GWLP_USERDATA));
|
||||||
if (!pStaticDlg)
|
if (!pStaticDlg)
|
||||||
@ -166,26 +206,31 @@ void StaticDialog::alignWith(HWND handle, HWND handle2Align, PosAlign pos, POINT
|
|||||||
|
|
||||||
switch (pos)
|
switch (pos)
|
||||||
{
|
{
|
||||||
case ALIGNPOS_LEFT :
|
case PosAlign::left:
|
||||||
|
{
|
||||||
::GetWindowRect(handle2Align, &rc2);
|
::GetWindowRect(handle2Align, &rc2);
|
||||||
point.x -= rc2.right - rc2.left;
|
point.x -= rc2.right - rc2.left;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case ALIGNPOS_RIGHT :
|
case PosAlign::right:
|
||||||
|
{
|
||||||
::GetWindowRect(handle, &rc2);
|
::GetWindowRect(handle, &rc2);
|
||||||
point.x += rc2.right - rc2.left;
|
point.x += rc2.right - rc2.left;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case ALIGNPOS_TOP :
|
case PosAlign::top:
|
||||||
|
{
|
||||||
::GetWindowRect(handle2Align, &rc2);
|
::GetWindowRect(handle2Align, &rc2);
|
||||||
point.y -= rc2.bottom - rc2.top;
|
point.y -= rc2.bottom - rc2.top;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default : //ALIGNPOS_BOTTOM
|
case PosAlign::bottom:
|
||||||
|
{
|
||||||
::GetWindowRect(handle, &rc2);
|
::GetWindowRect(handle, &rc2);
|
||||||
point.y += rc2.bottom - rc2.top;
|
point.y += rc2.bottom - rc2.top;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
::ScreenToClient(_hSelf, &point);
|
::ScreenToClient(_hSelf, &point);
|
||||||
}
|
}
|
||||||
|
@ -24,19 +24,18 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#ifndef STATIC_DIALOG_H
|
|
||||||
#define STATIC_DIALOG_H
|
|
||||||
|
|
||||||
#include "Notepad_plus_msgs.h"
|
#include "Notepad_plus_msgs.h"
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
|
|
||||||
|
|
||||||
typedef HRESULT (WINAPI * ETDTProc) (HWND, DWORD);
|
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 dlgVer;
|
||||||
WORD signature;
|
WORD signature;
|
||||||
DWORD helpID;
|
DWORD helpID;
|
||||||
@ -48,51 +47,37 @@ struct DLGTEMPLATEEX {
|
|||||||
short cx;
|
short cx;
|
||||||
short cy;
|
short cy;
|
||||||
// The structure has more fields but are variable length
|
// The structure has more fields but are variable length
|
||||||
} ;
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class StaticDialog : public Window
|
class StaticDialog : public Window
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
StaticDialog() : Window() {};
|
virtual ~StaticDialog();
|
||||||
~StaticDialog(){
|
|
||||||
if (isCreated()) {
|
|
||||||
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR)NULL); //Prevent run_dlgProc from doing anything, since its virtual
|
|
||||||
destroy();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
virtual void create(int dialogID, bool isRTL = false, bool msgDestParent = true);
|
virtual void create(int dialogID, bool isRTL = false, bool msgDestParent = true);
|
||||||
|
|
||||||
virtual bool isCreated() const {
|
virtual bool isCreated() const
|
||||||
|
{
|
||||||
return (_hSelf != NULL);
|
return (_hSelf != NULL);
|
||||||
};
|
}
|
||||||
|
|
||||||
void goToCenter();
|
void goToCenter();
|
||||||
|
|
||||||
void display(bool toShow = true) const;
|
void display(bool toShow = true) const;
|
||||||
|
|
||||||
POINT getTopPoint(HWND hwnd, bool isLeft = 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;
|
|
||||||
};
|
|
||||||
|
|
||||||
bool isCheckedOrNot(int checkControlID) const {
|
bool isCheckedOrNot(int checkControlID) const
|
||||||
|
{
|
||||||
return (BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, checkControlID), BM_GETCHECK, 0, 0));
|
return (BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, checkControlID), BM_GETCHECK, 0, 0));
|
||||||
};
|
}
|
||||||
|
|
||||||
void destroy() {
|
virtual void destroy() override;
|
||||||
::SendMessage(_hParent, NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, (WPARAM)_hSelf);
|
|
||||||
::DestroyWindow(_hSelf);
|
|
||||||
};
|
|
||||||
|
|
||||||
protected :
|
|
||||||
|
protected:
|
||||||
RECT _rc;
|
RECT _rc;
|
||||||
static INT_PTR CALLBACK dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
static INT_PTR CALLBACK dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) = 0;
|
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) = 0;
|
||||||
@ -100,5 +85,3 @@ protected :
|
|||||||
void alignWith(HWND handle, HWND handle2Align, PosAlign pos, POINT & point);
|
void alignWith(HWND handle, HWND handle2Align, PosAlign pos, POINT & point);
|
||||||
HGLOBAL makeRTLResource(int dialogID, DLGTEMPLATE **ppMyDlgTemplate);
|
HGLOBAL makeRTLResource(int dialogID, DLGTEMPLATE **ppMyDlgTemplate);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //STATIC_DIALOG_H
|
|
||||||
|
@ -33,7 +33,13 @@
|
|||||||
class Window
|
class Window
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
//! \name Constructors & Destructor
|
||||||
|
//@{
|
||||||
|
Window() = default;
|
||||||
|
Window(const Window&) = delete;
|
||||||
virtual ~Window() = default;
|
virtual ~Window() = default;
|
||||||
|
//@}
|
||||||
|
|
||||||
|
|
||||||
virtual void init(HINSTANCE hInst, HWND parent)
|
virtual void init(HINSTANCE hInst, HWND parent)
|
||||||
{
|
{
|
||||||
@ -123,6 +129,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Window& operator = (const Window&) = delete;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HINSTANCE _hInst = NULL;
|
HINSTANCE _hInst = NULL;
|
||||||
HWND _hParent = NULL;
|
HWND _hParent = NULL;
|
||||||
|
@ -24,13 +24,11 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#ifndef RESOURCE_H
|
|
||||||
#define RESOURCE_H
|
|
||||||
|
|
||||||
#define NOTEPAD_PLUS_VERSION TEXT("Notepad++ v6.8.1")
|
#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
|
// 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")
|
// ex : #define VERSION_VALUE TEXT("5.63\0")
|
||||||
#define VERSION_VALUE TEXT("6.8.1\0")
|
#define VERSION_VALUE TEXT("6.8.1\0")
|
||||||
@ -456,7 +454,3 @@
|
|||||||
#define MENUINDEX_MACRO 7
|
#define MENUINDEX_MACRO 7
|
||||||
#define MENUINDEX_RUN 8
|
#define MENUINDEX_RUN 8
|
||||||
#define MENUINDEX_PLUGINS 9
|
#define MENUINDEX_PLUGINS 9
|
||||||
|
|
||||||
#endif // RESOURCE_H
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user