Incremental search integrated into ReBar,
Fix Find dialogs buffer overflow, Added chevron into rebar to show hidden icons, Added plugin message to add rebarbands (experimental), simplify sizing logic a little, Remove nonexistant file from vc2003 project file. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@171 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
12a2f16042
commit
9e26b31e3a
|
@ -201,6 +201,17 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
|
|||
#define CHECKDOCOPT_UPDATESILENTLY 1
|
||||
#define CHECKDOCOPT_UPDATEGO2END 2
|
||||
|
||||
#define NPPM_ADDREBAR (NPPMSG + 55)
|
||||
// BOOL NPPM_ADDREBAR(0, REBARBANDINFO *)
|
||||
// Returns assigned ID in wID value of struct pointer
|
||||
#define NPPM_UPDATEREBAR (NPPMSG + 56)
|
||||
// BOOL NPPM_ADDREBAR(INT ID, REBARBANDINFO *)
|
||||
//Use ID assigned with NPPM_ADDREBAR
|
||||
#define NPPM_REMOVEREBAR (NPPMSG + 57)
|
||||
// BOOL NPPM_ADDREBAR(INT ID, 0)
|
||||
//Use ID assigned with NPPM_ADDREBAR
|
||||
|
||||
|
||||
#define RUNCOMMAND_USER (WM_USER + 3000)
|
||||
#define NPPM_GETFULLCURRENTPATH (RUNCOMMAND_USER + FULL_CURRENT_PATH)
|
||||
#define NPPM_GETCURRENTDIRECTORY (RUNCOMMAND_USER + CURRENT_DIRECTORY)
|
||||
|
|
|
@ -63,6 +63,8 @@ Notepad_plus::Notepad_plus(): Window(), _mainWindowStatus(0), _pDocTab(NULL), _p
|
|||
_recordingMacro(false), _pTrayIco(NULL), _isUDDocked(false), _isRTL(false),
|
||||
_linkTriggered(true), _isDocModifing(false), _isHotspotDblClicked(false), _isSaving(false), _hideMenu(true), _sysMenuEntering(false)
|
||||
{
|
||||
ZeroMemory(&_prevSelectedRange, sizeof(_prevSelectedRange));
|
||||
|
||||
_winVersion = getWindowsVersion();
|
||||
|
||||
TiXmlDocument *nativeLangDocRoot = (NppParameters::getInstance())->getNativeLang();
|
||||
|
@ -311,7 +313,8 @@ void Notepad_plus::init(HINSTANCE hInst, HWND parent, const char *cmdLine, CmdLi
|
|||
void Notepad_plus::killAllChildren()
|
||||
{
|
||||
_toolBar.destroy();
|
||||
_rebar.destroy();
|
||||
_rebarTop.destroy();
|
||||
_rebarBottom.destroy();
|
||||
|
||||
if (_pMainSplitter)
|
||||
{
|
||||
|
@ -343,7 +346,7 @@ bool Notepad_plus::saveGUIParams()
|
|||
{
|
||||
NppGUI & nppGUI = (NppGUI &)(NppParameters::getInstance())->getNppGUI();
|
||||
nppGUI._statusBarShow = _statusBar.isVisible();
|
||||
nppGUI._toolbarShow = _rebar.getIDVisible(REBAR_BAR_TOOLBAR);
|
||||
nppGUI._toolbarShow = _rebarTop.getIDVisible(REBAR_BAR_TOOLBAR);
|
||||
nppGUI._toolBarStatus = _toolBar.getState();
|
||||
|
||||
nppGUI._tabStatus = (TabBarPlus::doDragNDropOrNot()?TAB_DRAWTOPBAR:0) | \
|
||||
|
@ -2263,6 +2266,31 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
|||
SendMessage(_hSelf, 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
|
||||
switch(lpnm->wID) {
|
||||
case REBAR_BAR_TOOLBAR: {
|
||||
POINT pt;
|
||||
pt.x = lpnm->rc.left;
|
||||
pt.y = lpnm->rc.bottom;
|
||||
ClientToScreen(notifRebar->getHSelf(), &pt);
|
||||
_toolBar.doPopop(pt);
|
||||
return TRUE;
|
||||
break; }
|
||||
}
|
||||
//Else forward notification to window of rebarband
|
||||
REBARBANDINFO rbBand;
|
||||
rbBand.cbSize = sizeof(rbBand);
|
||||
rbBand.fMask = RBBIM_CHILD;
|
||||
::SendMessage(notifRebar->getHSelf(), RB_GETBANDINFO, lpnm->uBand, (LPARAM)&rbBand);
|
||||
::SendMessage(rbBand.hwndChild, WM_NOTIFY, 0, (LPARAM)lpnm);
|
||||
break;
|
||||
}
|
||||
|
||||
default :
|
||||
break;
|
||||
|
@ -2783,9 +2811,6 @@ void Notepad_plus::command(int id)
|
|||
char str[strSize];
|
||||
|
||||
bool isFirstTime = !_findReplaceDlg.isCreated();
|
||||
CharacterRange range = _pEditView->getSelection();
|
||||
if (range.cpMin == range.cpMax)
|
||||
_pEditView->expandWordSelection();
|
||||
|
||||
if (_nativeLang)
|
||||
{
|
||||
|
@ -2809,8 +2834,8 @@ void Notepad_plus::command(int id)
|
|||
}
|
||||
_findReplaceDlg.doDialog((id == IDM_SEARCH_FIND)?FIND_DLG:REPLACE_DLG, _isRTL);
|
||||
|
||||
if (_pEditView->getSelectedText(str, strSize, true))
|
||||
_findReplaceDlg.setSearchText(str, _pEditView->getCurrentBuffer()._unicodeMode != uni8Bit);
|
||||
_pEditView->getSelectedText(str, strSize);
|
||||
_findReplaceDlg.setSearchText(str, _pEditView->getCurrentBuffer()._unicodeMode != uni8Bit);
|
||||
|
||||
if (isFirstTime)
|
||||
changeDlgLang(_findReplaceDlg.getHSelf(), "Find");
|
||||
|
@ -2827,13 +2852,8 @@ void Notepad_plus::command(int id)
|
|||
const int strSize = 64;
|
||||
char str[strSize];
|
||||
|
||||
_incrementFindDlg.doDialog(_isRTL);
|
||||
|
||||
CharacterRange range = _pEditView->getSelection();
|
||||
if (range.cpMin == range.cpMax)
|
||||
{
|
||||
_pEditView->expandWordSelection();
|
||||
}
|
||||
_incrementFindDlg.display();
|
||||
|
||||
_pEditView->getSelectedText(str, strSize);
|
||||
_incrementFindDlg.setSearchText(str, _pEditView->getCurrentBuffer()._unicodeMode != uni8Bit);
|
||||
}
|
||||
|
@ -2856,31 +2876,19 @@ void Notepad_plus::command(int id)
|
|||
case IDM_SEARCH_VOLATILE_FINDNEXT :
|
||||
case IDM_SEARCH_VOLATILE_FINDPREV :
|
||||
{
|
||||
CharacterRange range = _pEditView->getSelection();
|
||||
if (range.cpMin == range.cpMax)
|
||||
{
|
||||
_pEditView->expandWordSelection();
|
||||
}
|
||||
else
|
||||
{
|
||||
char text2Find[MAX_PATH];
|
||||
_pEditView->getSelectedText(text2Find, sizeof(text2Find));
|
||||
char text2Find[MAX_PATH];
|
||||
_pEditView->getSelectedText(text2Find, sizeof(text2Find));
|
||||
|
||||
FindOption op;
|
||||
op._isWholeWord = false;
|
||||
op._whichDirection = (id == IDM_SEARCH_VOLATILE_FINDNEXT?DIR_DOWN:DIR_UP);
|
||||
_findReplaceDlg.processFindNext(text2Find, &op);
|
||||
}
|
||||
FindOption op;
|
||||
op._isWholeWord = false;
|
||||
op._whichDirection = (id == IDM_SEARCH_VOLATILE_FINDNEXT?DIR_DOWN:DIR_UP);
|
||||
_findReplaceDlg.processFindNext(text2Find, &op);
|
||||
break;
|
||||
}
|
||||
case IDM_SEARCH_MARKALL :
|
||||
{
|
||||
CharacterRange range = _pEditView->getSelection();
|
||||
if (range.cpMin == range.cpMax)
|
||||
{
|
||||
_pEditView->expandWordSelection();
|
||||
}
|
||||
char text2Find[MAX_PATH];
|
||||
const int strSize = 64;
|
||||
char text2Find[strSize];
|
||||
_pEditView->getSelectedText(text2Find, sizeof(text2Find));
|
||||
|
||||
FindOption op;
|
||||
|
@ -2974,9 +2982,7 @@ void Notepad_plus::command(int id)
|
|||
else
|
||||
_pMainWindow = _pDocTab;
|
||||
|
||||
RECT rc;
|
||||
getMainClientRect(rc);
|
||||
_dockingManager.reSizeTo(rc);
|
||||
::SendMessage(_hSelf, WM_SIZE, 0, 0);
|
||||
|
||||
udd->display(false);
|
||||
_mainWindowStatus &= ~DOCK_MASK;
|
||||
|
@ -3001,9 +3007,7 @@ void Notepad_plus::command(int id)
|
|||
|
||||
_pMainSplitter->setWin0((_mainWindowStatus & TWO_VIEWS_MASK)?(Window *)&_subSplitter:(Window *)_pDocTab);
|
||||
|
||||
RECT rc;
|
||||
getMainClientRect(rc);
|
||||
_dockingManager.reSizeTo(rc);
|
||||
::SendMessage(_hSelf, WM_SIZE, 0, 0);
|
||||
_pMainWindow->display();
|
||||
|
||||
_mainWindowStatus |= DOCK_MASK;
|
||||
|
@ -3157,8 +3161,8 @@ void Notepad_plus::command(int id)
|
|||
|
||||
case IDM_VIEW_TOOLBAR_HIDE:
|
||||
{
|
||||
bool toSet = !_rebar.getIDVisible(REBAR_BAR_TOOLBAR);
|
||||
_rebar.setIDVisible(REBAR_BAR_TOOLBAR, toSet);
|
||||
bool toSet = !_rebarTop.getIDVisible(REBAR_BAR_TOOLBAR);
|
||||
_rebarTop.setIDVisible(REBAR_BAR_TOOLBAR, toSet);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -3169,7 +3173,6 @@ void Notepad_plus::command(int id)
|
|||
if (state != TB_SMALL)
|
||||
{
|
||||
_toolBar.reduce();
|
||||
_rebar.reNew();
|
||||
changeToolBarIcons();
|
||||
}
|
||||
}
|
||||
|
@ -3182,7 +3185,6 @@ void Notepad_plus::command(int id)
|
|||
if (state != TB_LARGE)
|
||||
{
|
||||
_toolBar.enlarge();
|
||||
_rebar.reNew();
|
||||
changeToolBarIcons();
|
||||
}
|
||||
}
|
||||
|
@ -3195,7 +3197,6 @@ void Notepad_plus::command(int id)
|
|||
if (state != TB_STANDARD)
|
||||
{
|
||||
_toolBar.setToUglyIcons();
|
||||
_rebar.reNew();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -3222,19 +3223,14 @@ void Notepad_plus::command(int id)
|
|||
::SendMessage(_mainDocTab.getHSelf(), WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE, 0));
|
||||
::SendMessage(_subDocTab.getHSelf(), WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE, 0));
|
||||
}
|
||||
RECT rc;
|
||||
|
||||
getMainClientRect(rc);
|
||||
_dockingManager.reSizeTo(rc);
|
||||
|
||||
::SendMessage(_hSelf, WM_SIZE, 0, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
case IDM_VIEW_REFRESHTABAR :
|
||||
{
|
||||
RECT rc;
|
||||
getMainClientRect(rc);
|
||||
_dockingManager.reSizeTo(rc);
|
||||
::SendMessage(_hSelf, WM_SIZE, 0, 0);
|
||||
break;
|
||||
}
|
||||
case IDM_VIEW_LOCKTABBAR:
|
||||
|
@ -3268,9 +3264,7 @@ void Notepad_plus::command(int id)
|
|||
TabCtrl_SetItemSize(_mainDocTab.getHSelf(), 45, tabHeight);
|
||||
TabCtrl_SetItemSize(_subDocTab.getHSelf(), 45, tabHeight);
|
||||
}
|
||||
RECT rc;
|
||||
getMainClientRect(rc);
|
||||
_dockingManager.reSizeTo(rc);
|
||||
::SendMessage(_hSelf, WM_SIZE, 0, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3283,21 +3277,14 @@ void Notepad_plus::command(int id)
|
|||
case IDM_VIEW_DRAWTABBAR_VERTICAL :
|
||||
{
|
||||
TabBarPlus::setVertical(!TabBarPlus::isVertical());
|
||||
|
||||
RECT rc;
|
||||
getMainClientRect(rc);
|
||||
|
||||
_dockingManager.reSizeTo(rc);
|
||||
|
||||
::SendMessage(_hSelf, WM_SIZE, 0, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
case IDM_VIEW_DRAWTABBAR_MULTILINE :
|
||||
{
|
||||
TabBarPlus::setMultiLine(!TabBarPlus::isMultiLine());
|
||||
RECT rc;
|
||||
getMainClientRect(rc);
|
||||
_dockingManager.reSizeTo(rc);
|
||||
::SendMessage(_hSelf, WM_SIZE, 0, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -4533,9 +4520,7 @@ void Notepad_plus::hideCurrentView()
|
|||
_pDocTab->display(false);
|
||||
|
||||
// resize the main window
|
||||
RECT rc;
|
||||
getMainClientRect(rc);
|
||||
_dockingManager.reSizeTo(rc);
|
||||
::SendMessage(_hSelf, WM_SIZE, 0, 0);
|
||||
|
||||
switchEditViewTo((getCurrentView() == MAIN_VIEW)?SUB_VIEW:MAIN_VIEW);
|
||||
|
||||
|
@ -4705,25 +4690,9 @@ void Notepad_plus::reload(const char *fileName)
|
|||
|
||||
void Notepad_plus::getMainClientRect(RECT &rc) const
|
||||
{
|
||||
Window::getClientRect(rc);
|
||||
rc.top += _rebar.getHeight();
|
||||
rc.bottom -= _rebar.getHeight() +_statusBar.getHeight();
|
||||
}
|
||||
|
||||
void Notepad_plus::getToolBarClientRect(RECT &rc) const
|
||||
{
|
||||
Window::getClientRect(rc);
|
||||
rc.bottom = _rebar.getHeight();//_toolBar.getHeight();
|
||||
}
|
||||
|
||||
void Notepad_plus::getStatusBarClientRect(RECT & rc) const
|
||||
{
|
||||
RECT rectMain;
|
||||
|
||||
getMainClientRect(rectMain);
|
||||
getClientRect(rc);
|
||||
rc.top = rectMain.top + rectMain.bottom;
|
||||
rc.bottom = rc.bottom - rc.top;
|
||||
rc.top += _rebarTop.getHeight();
|
||||
rc.bottom -= rc.top + _rebarBottom.getHeight() + _statusBar.getHeight();
|
||||
}
|
||||
|
||||
void Notepad_plus::dockUserDlg()
|
||||
|
@ -4752,9 +4721,7 @@ void Notepad_plus::dockUserDlg()
|
|||
_mainWindowStatus |= DOCK_MASK;
|
||||
_pMainWindow = _pMainSplitter;
|
||||
|
||||
RECT rc;
|
||||
getMainClientRect(rc);
|
||||
_dockingManager.reSizeTo(rc);
|
||||
::SendMessage(_hSelf, WM_SIZE, 0, 0);
|
||||
}
|
||||
|
||||
void Notepad_plus::undockUserDlg()
|
||||
|
@ -4767,9 +4734,7 @@ void Notepad_plus::undockUserDlg()
|
|||
else
|
||||
_pMainWindow = _pDocTab;
|
||||
|
||||
RECT rc;
|
||||
getMainClientRect(rc);
|
||||
_dockingManager.reSizeTo(rc);
|
||||
::SendMessage(_hSelf, WM_SIZE, 0, 0);
|
||||
|
||||
_mainWindowStatus &= ~DOCK_MASK;
|
||||
(ScintillaEditView::getUserDefineDlg())->display();
|
||||
|
@ -4791,9 +4756,7 @@ void Notepad_plus::docGotoAnotherEditView(bool mode)
|
|||
_pMainWindow = &_subSplitter;
|
||||
|
||||
// resize the main window
|
||||
RECT rc;
|
||||
getMainClientRect(rc);
|
||||
_dockingManager.reSizeTo(rc);
|
||||
::SendMessage(_hSelf, WM_SIZE, 0, 0);
|
||||
|
||||
getNonCurrentEditView()->display();
|
||||
getNonCurrentDocTab()->display();
|
||||
|
@ -6223,50 +6186,10 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
|||
_statusBar.setPartWidth(STATUSBAR_UNICODE_TYPE, 100);
|
||||
_statusBar.setPartWidth(STATUSBAR_TYPING_MODE, 30);
|
||||
_statusBar.display(willBeShown);
|
||||
|
||||
_findReplaceDlg.init(_hInst, hwnd, &_pEditView);
|
||||
_incrementFindDlg.init(_hInst, hwnd, &_findReplaceDlg);
|
||||
_goToLineDlg.init(_hInst, hwnd, &_pEditView);
|
||||
_colEditorDlg.init(_hInst, hwnd, &_pEditView);
|
||||
_aboutDlg.init(_hInst, hwnd);
|
||||
_runDlg.init(_hInst, hwnd);
|
||||
_runMacroDlg.init(_hInst, hwnd);
|
||||
|
||||
_pMainWindow = &_mainDocTab;
|
||||
|
||||
_dockingManager.init(_hInst, hwnd, &_pMainWindow);
|
||||
|
||||
|
||||
|
||||
//--User Define Dialog Section--//
|
||||
int uddStatus = nppGUI._userDefineDlgStatus;
|
||||
UserDefineDialog *udd = _pEditView->getUserDefineDlg();
|
||||
|
||||
bool uddShow = false;
|
||||
switch (uddStatus)
|
||||
{
|
||||
case UDD_SHOW : // show & undocked
|
||||
udd->doDialog(true, _isRTL);
|
||||
changeUserDefineLang();
|
||||
uddShow = true;
|
||||
break;
|
||||
case UDD_DOCKED : { // hide & docked
|
||||
_isUDDocked = true;
|
||||
break;}
|
||||
case (UDD_SHOW | UDD_DOCKED) : // show & docked
|
||||
udd->doDialog(true, _isRTL);
|
||||
changeUserDefineLang();
|
||||
::SendMessage(udd->getHSelf(), WM_COMMAND, IDC_DOCK_BUTTON, 0);
|
||||
uddShow = true;
|
||||
break;
|
||||
|
||||
default : // hide & undocked
|
||||
break;
|
||||
}
|
||||
// UserDefine Dialog
|
||||
|
||||
checkMenuItem(IDM_VIEW_USER_DLG, uddShow);
|
||||
_toolBar.setCheck(IDM_VIEW_USER_DLG, uddShow);
|
||||
|
||||
//dynamicCheckMenuAndTB();
|
||||
_mainEditView.defineDocType(L_TXT);
|
||||
|
@ -6488,8 +6411,50 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
|||
|
||||
changeToolBarIcons();
|
||||
|
||||
_rebar.init(_hInst, hwnd, &_toolBar);
|
||||
_rebar.setIDVisible(REBAR_BAR_TOOLBAR, willBeShown);
|
||||
_rebarTop.init(_hInst, hwnd);
|
||||
_rebarBottom.init(_hInst, hwnd);
|
||||
_toolBar.addToRebar(&_rebarTop);
|
||||
_rebarTop.setIDVisible(REBAR_BAR_TOOLBAR, willBeShown);
|
||||
|
||||
//--Init dialogs--//
|
||||
_findReplaceDlg.init(_hInst, hwnd, &_pEditView);
|
||||
_incrementFindDlg.init(_hInst, hwnd, &_findReplaceDlg, _isRTL);
|
||||
_incrementFindDlg.addToRebar(&_rebarBottom);
|
||||
_goToLineDlg.init(_hInst, hwnd, &_pEditView);
|
||||
_colEditorDlg.init(_hInst, hwnd, &_pEditView);
|
||||
_aboutDlg.init(_hInst, hwnd);
|
||||
_runDlg.init(_hInst, hwnd);
|
||||
_runMacroDlg.init(_hInst, hwnd);
|
||||
|
||||
//--User Define Dialog Section--//
|
||||
int uddStatus = nppGUI._userDefineDlgStatus;
|
||||
UserDefineDialog *udd = _pEditView->getUserDefineDlg();
|
||||
|
||||
bool uddShow = false;
|
||||
switch (uddStatus)
|
||||
{
|
||||
case UDD_SHOW : // show & undocked
|
||||
udd->doDialog(true, _isRTL);
|
||||
changeUserDefineLang();
|
||||
uddShow = true;
|
||||
break;
|
||||
case UDD_DOCKED : { // hide & docked
|
||||
_isUDDocked = true;
|
||||
break;}
|
||||
case (UDD_SHOW | UDD_DOCKED) : // show & docked
|
||||
udd->doDialog(true, _isRTL);
|
||||
changeUserDefineLang();
|
||||
::SendMessage(udd->getHSelf(), WM_COMMAND, IDC_DOCK_BUTTON, 0);
|
||||
uddShow = true;
|
||||
break;
|
||||
|
||||
default : // hide & undocked
|
||||
break;
|
||||
}
|
||||
// UserDefine Dialog
|
||||
|
||||
checkMenuItem(IDM_VIEW_USER_DLG, uddShow);
|
||||
_toolBar.setCheck(IDM_VIEW_USER_DLG, uddShow);
|
||||
|
||||
//launch the plugin dlg memorized at the last session
|
||||
DockingManagerData &dmd = nppGUI._dockingData;
|
||||
|
@ -6592,10 +6557,6 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
|||
|
||||
bool isFirstTime = !_findReplaceDlg.isCreated();
|
||||
_findReplaceDlg.doDialog(FIND_DLG, _isRTL);
|
||||
//if ()
|
||||
CharacterRange range = _pEditView->getSelection();
|
||||
if (range.cpMin == range.cpMax)
|
||||
_pEditView->expandWordSelection();
|
||||
|
||||
_pEditView->getSelectedText(str, strSize);
|
||||
_findReplaceDlg.setSearchText(str);
|
||||
|
@ -6674,29 +6635,33 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
|||
|
||||
case WM_SIZE:
|
||||
{
|
||||
if (lParam == 0) {
|
||||
RECT winRect;
|
||||
getClientRect(winRect);
|
||||
lParam = MAKELPARAM(winRect.right - winRect.left, winRect.bottom - winRect.top);
|
||||
}
|
||||
RECT rc;
|
||||
::MoveWindow(_rebar.getHSelf(), 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
|
||||
getClientRect(rc);
|
||||
if (lParam == 0) {
|
||||
lParam = MAKELPARAM(rc.right - rc.left, rc.bottom - rc.top);
|
||||
}
|
||||
|
||||
getStatusBarClientRect(rc);
|
||||
_statusBar.reSizeTo(rc);
|
||||
::MoveWindow(_rebarTop.getHSelf(), 0, 0, rc.right, _rebarTop.getHeight(), TRUE);
|
||||
_statusBar.adjustParts(rc.right);
|
||||
::SendMessage(_statusBar.getHSelf(), WM_SIZE, wParam, lParam);
|
||||
|
||||
int rebarBottomHeight = _rebarBottom.getHeight();
|
||||
int statusBarHeight = _statusBar.getHeight();
|
||||
::MoveWindow(_rebarBottom.getHSelf(), 0, rc.bottom - rebarBottomHeight - statusBarHeight, rc.right, rebarBottomHeight, TRUE);
|
||||
|
||||
getMainClientRect(rc);
|
||||
_dockingManager.reSizeTo(rc);
|
||||
//_pMainWindow->reSizeTo(rc);
|
||||
|
||||
mkPosIncFindDlg();
|
||||
//mkPosIncFindDlg();
|
||||
result = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_MOVE:
|
||||
{
|
||||
redraw();
|
||||
mkPosIncFindDlg();
|
||||
//redraw();
|
||||
//mkPosIncFindDlg();
|
||||
result = TRUE;
|
||||
}
|
||||
break;
|
||||
|
@ -6824,21 +6789,21 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
|||
const int strSize = MAX_PATH;
|
||||
char str[strSize];
|
||||
|
||||
CharacterRange range = _pEditView->getSelection();
|
||||
if (range.cpMin == range.cpMax)
|
||||
_pEditView->expandWordSelection();
|
||||
|
||||
_pEditView->getSelectedText(str, strSize, true);
|
||||
|
||||
_pEditView->getSelectedText((char *)str, strSize);
|
||||
// For the compability reason, if wParam is 0, then we assume the size of string buffer (lParam) is large enough.
|
||||
// otherwise we check if the string buffer size is enough for the string to copy.
|
||||
if (wParam != 0)
|
||||
{
|
||||
if (strlen(str) >= wParam)
|
||||
if (strlen(str) >= wParam) //buffer too small
|
||||
{
|
||||
::MessageBox(_hSelf, "Allocated buffer size is not enough to copy the string.", "NPPM_GETCURRENTWORD error", MB_OK);
|
||||
return FALSE;
|
||||
}
|
||||
else //buffer large enough, perform safe copy
|
||||
{
|
||||
lstrcpyn((char *)lParam, str, wParam);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
strcpy((char *)lParam, str);
|
||||
|
@ -7773,7 +7738,31 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
|||
{
|
||||
return _mainDocTab.getHideTabBarStatus();
|
||||
}
|
||||
|
||||
|
||||
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 :
|
||||
{
|
||||
ScintillaEditView *cv = getCurrentEditView();
|
||||
|
@ -7926,7 +7915,8 @@ void Notepad_plus::fullScreenToggle()
|
|||
::ShowWindow(_hSelf, SW_HIDE);
|
||||
|
||||
//Hide rebar
|
||||
_rebar.display(false);
|
||||
_rebarTop.display(false);
|
||||
_rebarBottom.display(false);
|
||||
|
||||
//Set popup style for fullscreen window and store the old style
|
||||
_prevStyles = ::SetWindowLongPtr( _hSelf, GWL_STYLE, WS_POPUP );
|
||||
|
@ -7948,7 +7938,8 @@ void Notepad_plus::fullScreenToggle()
|
|||
::SetWindowPos(_hSelf, HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOREDRAW|SWP_NOZORDER);
|
||||
|
||||
//Show rebar
|
||||
_rebar.display(true);
|
||||
_rebarTop.display(true);
|
||||
_rebarBottom.display(true);
|
||||
|
||||
if (_winPlace.length)
|
||||
{
|
||||
|
@ -8244,20 +8235,29 @@ bool Notepad_plus::str2Cliboard(const char *str2cpy)
|
|||
|
||||
void Notepad_plus::markSelectedText()
|
||||
{
|
||||
//Get selection
|
||||
CharacterRange range = _pEditView->getSelection();
|
||||
//Dont mark if the selection has not changed.
|
||||
if (range.cpMin == _prevSelectedRange.cpMin && range.cpMax == _prevSelectedRange.cpMax)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_prevSelectedRange = range;
|
||||
|
||||
//Clear marks
|
||||
LangType lt = _pEditView->getCurrentDocType();
|
||||
if (lt == L_TXT)
|
||||
_pEditView->defineDocType(L_CPP);
|
||||
_pEditView->defineDocType(lt);
|
||||
|
||||
// Mark all if there is selection.
|
||||
CharacterRange range = _pEditView->getSelection();
|
||||
//If nothing selected, dont mark anything
|
||||
if (range.cpMin == range.cpMax)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
char text2Find[MAX_PATH];
|
||||
_pEditView->getSelectedText(text2Find, sizeof(text2Find));
|
||||
_pEditView->getSelectedText(text2Find, sizeof(text2Find), false); //do not expand selection (false)
|
||||
|
||||
FindOption op;
|
||||
op._isWholeWord = false;
|
||||
|
|
|
@ -198,7 +198,8 @@ private:
|
|||
|
||||
StatusBar _statusBar;
|
||||
bool _toReduceTabBar;
|
||||
ReBar _rebar;
|
||||
ReBar _rebarTop;
|
||||
ReBar _rebarBottom;
|
||||
|
||||
// Dialog
|
||||
FindReplaceDlg _findReplaceDlg;
|
||||
|
@ -241,6 +242,9 @@ private:
|
|||
bool _isHotspotDblClicked;
|
||||
bool _isSaving;
|
||||
|
||||
//For Dynamic selection highlight
|
||||
CharacterRange _prevSelectedRange;
|
||||
|
||||
struct ActivateAppInfo {
|
||||
bool _isActivated;
|
||||
int _x;
|
||||
|
@ -364,9 +368,7 @@ private:
|
|||
void dockUserDlg();
|
||||
void undockUserDlg();
|
||||
|
||||
void getToolBarClientRect(RECT &rc) const;
|
||||
void getMainClientRect(RECT & rc) const;
|
||||
void getStatusBarClientRect(RECT & rc) const;
|
||||
|
||||
int switchEditViewTo(int gid);
|
||||
|
||||
|
@ -621,13 +623,6 @@ private:
|
|||
::SetCurrentDirectory(dir);
|
||||
}
|
||||
bool str2Cliboard(const char *str2cpy);
|
||||
void mkPosIncFindDlg() {
|
||||
if (!_incrementFindDlg.isCreated())
|
||||
return;
|
||||
if (!_incrementFindDlg.isVisible())
|
||||
return;
|
||||
_incrementFindDlg.goToLowerLeft();
|
||||
};
|
||||
|
||||
bool getIntegralDockingData(tTbData & dockData, int & iCont, bool & isVisible);
|
||||
|
||||
|
|
|
@ -1331,6 +1331,25 @@ BOOL CALLBACK Finder::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
|
||||
|
||||
|
||||
void FindIncrementDlg::destroy() {
|
||||
if (_pRebar) {
|
||||
_pRebar->removeBand(_rbBand.wID);
|
||||
_pRebar = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void FindIncrementDlg::display(bool toShow) const {
|
||||
if (!_pRebar) {
|
||||
Window::display(toShow);
|
||||
return;
|
||||
}
|
||||
if (toShow)
|
||||
::SetFocus(::GetDlgItem(_hSelf, IDC_INCFINDTEXT));
|
||||
_pRebar->setIDVisible(_rbBand.wID, toShow);
|
||||
}
|
||||
HWND hRebar= 0;
|
||||
WNDPROC staticProcOrig = 0;
|
||||
LRESULT StaticProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
BOOL CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
|
@ -1341,6 +1360,7 @@ BOOL CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDCANCEL :
|
||||
::SetFocus((*(_pFRDlg->_ppEditView))->getHSelf());
|
||||
display(false);
|
||||
return TRUE;
|
||||
|
||||
|
@ -1359,7 +1379,7 @@ BOOL CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||
return TRUE;
|
||||
|
||||
case IDC_INCFINDTEXT :
|
||||
if ((wParam >> 16) == 0x0300)
|
||||
if (HIWORD(wParam) == EN_CHANGE)
|
||||
{
|
||||
if (_doSearchFromBegin)
|
||||
{
|
||||
|
@ -1378,23 +1398,52 @@ BOOL CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||
|
||||
}
|
||||
}
|
||||
case WM_ERASEBKGND:
|
||||
{
|
||||
HWND hParent = ::GetParent(_hSelf);
|
||||
HDC winDC = (HDC)wParam;
|
||||
//RTL handling
|
||||
POINT pt = {0, 0}, ptOrig = {0, 0};
|
||||
::MapWindowPoints(_hSelf, hParent, &pt, 1);
|
||||
::OffsetWindowOrgEx((HDC)wParam, pt.x, pt.y, &ptOrig);
|
||||
LRESULT lResult = SendMessage(hParent, WM_ERASEBKGND,(WPARAM)winDC, 0);
|
||||
::SetWindowOrgEx(winDC, ptOrig.x, ptOrig.y, NULL);
|
||||
return (BOOL)lResult;
|
||||
break; }
|
||||
case WM_SIZE:
|
||||
{
|
||||
//Handle sizing (resize editbox?)
|
||||
}
|
||||
case WM_MOVE:
|
||||
{
|
||||
::InvalidateRect(_hSelf, NULL, TRUE); //when moving, force background redraw
|
||||
return FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void FindIncrementDlg::goToLowerLeft()
|
||||
{
|
||||
RECT rc;
|
||||
::GetClientRect(_hParent, &rc);
|
||||
//RECT rcSelf;
|
||||
//::GetClientRect(_hSelf, &rcSelf);
|
||||
int selfHeight = _rc.bottom - _rc.top;
|
||||
int selfWidth = _rc.right - _rc.left;
|
||||
void FindIncrementDlg::addToRebar(ReBar * rebar) {
|
||||
if(_pRebar)
|
||||
return;
|
||||
hRebar = rebar->getHSelf();
|
||||
_pRebar = rebar;
|
||||
RECT client;
|
||||
getClientRect(client);
|
||||
|
||||
POINT llpoint;
|
||||
llpoint.x = rc.left;
|
||||
llpoint.y = rc.bottom - selfHeight;
|
||||
::ClientToScreen(_hParent, &llpoint);
|
||||
|
||||
::SetWindowPos(_hSelf, HWND_TOP, llpoint.x, llpoint.y, selfWidth, selfHeight, SWP_SHOWWINDOW);
|
||||
ZeroMemory(&_rbBand, sizeof(REBARBANDINFO));
|
||||
_rbBand.cbSize = sizeof(REBARBANDINFO);
|
||||
_rbBand.fMask = RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE |
|
||||
RBBIM_SIZE | RBBIM_ID;
|
||||
|
||||
_rbBand.fStyle = RBBS_HIDDEN;
|
||||
_rbBand.hwndChild = getHSelf();
|
||||
_rbBand.wID = REBAR_BAR_SEARCH; //ID REBAR_BAR_SEARCH for search dialog
|
||||
_rbBand.cxMinChild = 0;
|
||||
_rbBand.cyIntegral = 1;
|
||||
_rbBand.cyMinChild = _rbBand.cyMaxChild = client.bottom-client.top;
|
||||
_rbBand.cxIdeal = _rbBand.cx = client.right-client.left;
|
||||
|
||||
_pRebar->addBand(&_rbBand, true);
|
||||
}
|
||||
|
|
|
@ -372,27 +372,18 @@ private :
|
|||
class FindIncrementDlg : public StaticDialog
|
||||
{
|
||||
public :
|
||||
//FindIncrementDlg() : _doSearchFromBegin()
|
||||
void init(HINSTANCE hInst, HWND hPere, FindReplaceDlg *pFRDlg) {
|
||||
FindIncrementDlg() : _pFRDlg(NULL), _pRebar(NULL) {};
|
||||
void init(HINSTANCE hInst, HWND hPere, FindReplaceDlg *pFRDlg, bool isRTL = false) {
|
||||
Window::init(hInst, hPere);
|
||||
if (!pFRDlg)
|
||||
throw int(9910);
|
||||
_pFRDlg = pFRDlg;
|
||||
create(IDD_INCREMENT_FIND, isRTL);
|
||||
_isRTL = isRTL;
|
||||
};
|
||||
virtual void destroy();
|
||||
virtual void display(bool toShow = true) const;
|
||||
|
||||
void doDialog(bool isRTL = false) {
|
||||
if (!isCreated())
|
||||
{
|
||||
create(IDD_INCREMENT_FIND, isRTL);
|
||||
_isRTL = isRTL;
|
||||
}
|
||||
|
||||
goToLowerLeft();
|
||||
::SetFocus(::GetDlgItem(_hSelf, IDC_INCFINDTEXT));
|
||||
display();
|
||||
_doSearchFromBegin = true;
|
||||
};
|
||||
void goToLowerLeft();
|
||||
void setSearchText(const char * txt2find, bool isUTF8 = false) {
|
||||
_doSearchFromBegin = false;
|
||||
if (!isUTF8)
|
||||
|
@ -405,9 +396,16 @@ public :
|
|||
::SendDlgItemMessageW(_hSelf, IDC_INCFINDTEXT, WM_SETTEXT, 0, (LPARAM)wchars);
|
||||
}
|
||||
|
||||
void addToRebar(ReBar * rebar);
|
||||
private :
|
||||
bool _isRTL;
|
||||
FindReplaceDlg *_pFRDlg;
|
||||
|
||||
ReBar * _pRebar;
|
||||
REBARBANDINFO _rbBand;
|
||||
|
||||
HWND _hEditBox, _hSearchPrev, _hSearchNext, _hCheckCase;
|
||||
|
||||
bool _doSearchFromBegin;
|
||||
virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||
};
|
||||
|
|
|
@ -78,16 +78,17 @@ BEGIN
|
|||
CONTROL "",IDC_PERCENTAGE_SLIDER,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | NOT WS_VISIBLE | WS_TABSTOP,240,161,53,10
|
||||
END
|
||||
|
||||
IDD_INCREMENT_FIND DIALOGEX 0, 0, 330, 14
|
||||
STYLE DS_SYSMODAL | DS_MODALFRAME | DS_CONTROL | DS_3DLOOK | DS_FIXEDSYS | WS_POPUP
|
||||
IDD_INCREMENT_FIND DIALOGEX 0, 0, 330, 20
|
||||
STYLE DS_SYSMODAL | DS_CONTROL | DS_FIXEDSYS | WS_CHILD | WS_CLIPCHILDREN
|
||||
//EXSTYLE WS_EX_TRANSPARENT
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "X",IDCANCEL,2,1,12,12
|
||||
LTEXT "Find :",IDC_INCSTATIC,20,2,40,8
|
||||
EDITTEXT IDC_INCFINDTEXT,45,1,175,12,ES_AUTOHSCROLL | ES_WANTRETURN | NOT WS_BORDER,WS_EX_STATICEDGE
|
||||
DEFPUSHBUTTON "<",IDC_INCFINDPREVOK,223,0,16,14
|
||||
DEFPUSHBUTTON ">",IDC_INCFINDNXTOK,243,0,16,14
|
||||
CONTROL "Match case", IDC_INCFINDMATCHCASE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,270,2,60,12
|
||||
PUSHBUTTON "X",IDCANCEL,2,3,16,14
|
||||
LTEXT "Find :",IDC_INCSTATIC,20,5,25,12
|
||||
EDITTEXT IDC_INCFINDTEXT,45,4,175,12,ES_AUTOHSCROLL | ES_WANTRETURN | NOT WS_BORDER,WS_EX_STATICEDGE
|
||||
PUSHBUTTON "<",IDC_INCFINDPREVOK,223,3,16,14
|
||||
DEFPUSHBUTTON ">",IDC_INCFINDNXTOK,243,3,16,14
|
||||
CONTROL "Match case", IDC_INCFINDMATCHCASE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,270,5,60,12
|
||||
END
|
||||
|
||||
IDD_FINDRESULT DIALOGEX 26, 41, 223, 67
|
||||
|
|
|
@ -399,16 +399,18 @@ public:
|
|||
return (range.cpMax - range.cpMin);
|
||||
};
|
||||
|
||||
char * getSelectedText(char * txt, int size, bool expand=false) {
|
||||
CharacterRange range = getSelection();
|
||||
if (size <= (range.cpMax - range.cpMin))
|
||||
char * getSelectedText(char * txt, int size, bool expand = true) {
|
||||
if (!size)
|
||||
return NULL;
|
||||
if (expand && range.cpMax == range.cpMin)
|
||||
CharacterRange range = getSelection();
|
||||
if (range.cpMax == range.cpMin && expand)
|
||||
{
|
||||
expandWordSelection();
|
||||
range = getSelection();
|
||||
if (size <= (range.cpMax - range.cpMin))
|
||||
return NULL;
|
||||
}
|
||||
if (!(size > (range.cpMax - range.cpMin))) //there must be atleast 1 byte left for zero terminator
|
||||
{
|
||||
range.cpMax = range.cpMin+size-1; //keep room for zero terminator
|
||||
}
|
||||
getText(txt, range.cpMin, range.cpMax);
|
||||
return txt;
|
||||
|
|
|
@ -57,14 +57,14 @@ void StatusBar::init(HINSTANCE hInst, HWND hPere, int nbParts)
|
|||
|
||||
RECT rc;
|
||||
::GetClientRect(_hParent, &rc);
|
||||
adjustParts(rc);
|
||||
adjustParts(rc.right);
|
||||
}
|
||||
|
||||
void StatusBar::adjustParts(RECT & myRc)
|
||||
void StatusBar::adjustParts(int clientWidth)
|
||||
{
|
||||
// Calculate the right edge coordinate for each part, and
|
||||
// copy the coordinates to the array.
|
||||
int nWidth = myRc.right - 20;
|
||||
int nWidth = clientWidth - 20;
|
||||
for (int i = _nbParts - 1 ; i >= 0 ; i--)
|
||||
{
|
||||
_lpParts[i] = nWidth;
|
||||
|
|
|
@ -55,7 +55,7 @@ public :
|
|||
|
||||
virtual void reSizeTo(RECT & rc) {
|
||||
::MoveWindow(_hSelf, rc.left, rc.top, rc.right, rc.bottom, TRUE);
|
||||
adjustParts(rc);
|
||||
adjustParts(rc.right);
|
||||
redraw();
|
||||
};
|
||||
|
||||
|
@ -72,14 +72,14 @@ public :
|
|||
return (::SendMessage(_hSelf, SB_SETTEXT, whichPart, (LPARAM)str) == TRUE);
|
||||
};
|
||||
|
||||
void adjustParts(int clientWidth);
|
||||
|
||||
private :
|
||||
int _nbParts;
|
||||
int *_partWidthArray;
|
||||
|
||||
HLOCAL _hloc;
|
||||
LPINT _lpParts;
|
||||
|
||||
void adjustParts(RECT & myRc);
|
||||
LPINT _lpParts;
|
||||
};
|
||||
|
||||
#endif // STATUS_BAR_H
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
//#include "..\..\resource.h"
|
||||
#include "ToolBar.h"
|
||||
#include "SysMsg.h"
|
||||
#include "Shortcut.h"
|
||||
|
||||
const int WS_TOOLBARSTYLE = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | TBSTYLE_TOOLTIPS |TBSTYLE_FLAT | CCS_TOP | BTNS_AUTOSIZE | CCS_NOPARENTALIGN | CCS_NORESIZE | CCS_NODIVIDER;
|
||||
|
||||
|
@ -95,6 +96,17 @@ bool ToolBar::init( HINSTANCE hInst, HWND hPere, toolBarStatusType type,
|
|||
return true;
|
||||
}
|
||||
|
||||
void ToolBar::destroy() {
|
||||
if (_pRebar) {
|
||||
_pRebar->removeBand(_rbBand.wID);
|
||||
_pRebar = NULL;
|
||||
}
|
||||
delete [] _pTBB;
|
||||
::DestroyWindow(_hSelf);
|
||||
_hSelf = NULL;
|
||||
_toolBarIcons.destroy();
|
||||
};
|
||||
|
||||
int ToolBar::getWidth() const {
|
||||
RECT btnRect;
|
||||
int totalWidth = 0;
|
||||
|
@ -105,6 +117,14 @@ int ToolBar::getWidth() const {
|
|||
return totalWidth;
|
||||
}
|
||||
|
||||
int ToolBar::getHeight() const {
|
||||
DWORD size = (DWORD)SendMessage(_hSelf, TB_GETBUTTONSIZE, 0, 0);
|
||||
DWORD padding = (DWORD)SendMessage(_hSelf, TB_GETPADDING, 0,0);
|
||||
int totalHeight = HIWORD(size) + HIWORD(padding);
|
||||
|
||||
return totalHeight;
|
||||
}
|
||||
|
||||
void ToolBar::reset(bool create)
|
||||
{
|
||||
|
||||
|
@ -134,7 +154,7 @@ void ToolBar::reset(bool create)
|
|||
// Send the TB_BUTTONSTRUCTSIZE message, which is required for
|
||||
// backward compatibility.
|
||||
::SendMessage(_hSelf, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
|
||||
//::SendMessage(_hSelf, TB_SETEXTENDEDSTYLE, 0, (LPARAM)TBSTYLE_EX_HIDECLIPPEDBUTTONS);
|
||||
::SendMessage(_hSelf, TB_SETEXTENDEDSTYLE, 0, (LPARAM)TBSTYLE_EX_HIDECLIPPEDBUTTONS);
|
||||
}
|
||||
|
||||
if (!_hSelf)
|
||||
|
@ -177,6 +197,16 @@ void ToolBar::reset(bool create)
|
|||
::SendMessage(_hSelf, TB_ADDBUTTONS, (WPARAM)nrBtnToAdd, (LPARAM)_pTBB);
|
||||
}
|
||||
::SendMessage(_hSelf, TB_AUTOSIZE, 0, 0);
|
||||
|
||||
if (_pRebar) {
|
||||
_rbBand.hwndChild = getHSelf();
|
||||
_rbBand.cxMinChild = 0;
|
||||
_rbBand.cyIntegral = 1;
|
||||
_rbBand.cyMinChild = _rbBand.cyMaxChild = getHeight();
|
||||
_rbBand.cxIdeal = getWidth();
|
||||
|
||||
_pRebar->reNew(REBAR_BAR_TOOLBAR, &_rbBand);
|
||||
}
|
||||
}
|
||||
|
||||
void ToolBar::registerDynBtn(UINT messageID, toolbarIcons* tIcon)
|
||||
|
@ -192,10 +222,65 @@ void ToolBar::registerDynBtn(UINT messageID, toolbarIcons* tIcon)
|
|||
}
|
||||
}
|
||||
|
||||
void ReBar::init(HINSTANCE hInst, HWND hPere, ToolBar *pToolBar)
|
||||
void ToolBar::doPopop(POINT chevPoint) {
|
||||
//first find hidden buttons
|
||||
int width = Window::getWidth();
|
||||
|
||||
size_t start = 0;
|
||||
RECT btnRect = {0,0,0,0};
|
||||
while(start < _nrCurrentButtons) {
|
||||
::SendMessage(_hSelf, TB_GETITEMRECT, start, (LPARAM)&btnRect);
|
||||
if(btnRect.right > width)
|
||||
break;
|
||||
start++;
|
||||
}
|
||||
|
||||
if (start < _nrCurrentButtons) { //some buttons are hidden
|
||||
HMENU menu = ::CreatePopupMenu();
|
||||
int cmd;
|
||||
string text;
|
||||
while (start < _nrCurrentButtons) {
|
||||
cmd = _pTBB[start].idCommand;
|
||||
getNameStrFromCmd(cmd, text);
|
||||
if (_pTBB[start].idCommand != 0) {
|
||||
if (::SendMessage(_hSelf, TB_ISBUTTONENABLED, cmd, 0) != 0)
|
||||
AppendMenu(menu, MF_ENABLED, cmd, text.c_str());
|
||||
else
|
||||
AppendMenu(menu, MF_DISABLED|MF_GRAYED, cmd, text.c_str());
|
||||
} else
|
||||
AppendMenu(menu, MF_SEPARATOR, 0, "");
|
||||
start++;
|
||||
}
|
||||
TrackPopupMenu(menu, 0, chevPoint.x, chevPoint.y, 0, _hSelf, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void ToolBar::addToRebar(ReBar * rebar) {
|
||||
if (_pRebar)
|
||||
return;
|
||||
_pRebar = rebar;
|
||||
|
||||
ZeroMemory(&_rbBand, sizeof(REBARBANDINFO));
|
||||
_rbBand.cbSize = sizeof(REBARBANDINFO);
|
||||
_rbBand.fMask = RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE |
|
||||
RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_ID;
|
||||
|
||||
_rbBand.fStyle = RBBS_VARIABLEHEIGHT | RBBS_USECHEVRON;
|
||||
_rbBand.hwndChild = getHSelf();
|
||||
_rbBand.wID = REBAR_BAR_TOOLBAR; //ID REBAR_BAR_TOOLBAR for toolbar
|
||||
_rbBand.cxMinChild = 0;
|
||||
_rbBand.cyIntegral = 1;
|
||||
_rbBand.cyMinChild = _rbBand.cyMaxChild = getHeight();
|
||||
_rbBand.cxIdeal = _rbBand.cx = getWidth();
|
||||
|
||||
_pRebar->addBand(&_rbBand, true);
|
||||
|
||||
_rbBand.fMask = RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_IDEALSIZE | RBBIM_SIZE;
|
||||
}
|
||||
|
||||
void ReBar::init(HINSTANCE hInst, HWND hPere)
|
||||
{
|
||||
Window::init(hInst, hPere);
|
||||
_pToolBar = pToolBar;
|
||||
|
||||
_hSelf = CreateWindowEx(WS_EX_TOOLWINDOW,
|
||||
REBARCLASSNAME,
|
||||
|
@ -204,46 +289,43 @@ void ReBar::init(HINSTANCE hInst, HWND hPere, ToolBar *pToolBar)
|
|||
RBS_BANDBORDERS | CCS_NODIVIDER | CCS_NOPARENTALIGN,
|
||||
0,0,0,0, _hParent, NULL, _hInst, NULL);
|
||||
|
||||
ZeroMemory(&_rbi, sizeof(REBARINFO));
|
||||
_rbi.cbSize = sizeof(REBARINFO);
|
||||
_rbi.fMask = 0;
|
||||
_rbi.himl = (HIMAGELIST)NULL;
|
||||
::SendMessage(_hSelf, RB_SETBARINFO, 0, (LPARAM)&_rbi);
|
||||
|
||||
DWORD size = (DWORD)SendMessage(_pToolBar->getHSelf(), TB_GETBUTTONSIZE, 0, 0);
|
||||
DWORD padding = (DWORD)SendMessage(_pToolBar->getHSelf(), TB_GETPADDING, 0,0);
|
||||
|
||||
ZeroMemory(&_rbBand, sizeof(REBARBANDINFO));
|
||||
_rbBand.cbSize = sizeof(REBARBANDINFO);
|
||||
_rbBand.fMask = RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE |
|
||||
RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_ID;
|
||||
|
||||
_rbBand.fStyle = RBBS_VARIABLEHEIGHT;// | RBBS_USECHEVRON;
|
||||
_rbBand.hwndChild = _pToolBar->getHSelf();
|
||||
_rbBand.wID = REBAR_BAR_TOOLBAR; //ID REBAR_BAR_TOOLBAR for toolbar
|
||||
_rbBand.cxMinChild = 0;
|
||||
_rbBand.cyMinChild = HIWORD(size) + HIWORD(padding);
|
||||
_rbBand.cyMaxChild = HIWORD(size) + HIWORD(padding);
|
||||
_rbBand.cyIntegral = 1;
|
||||
_rbBand.cxIdeal = _rbBand.cx = _pToolBar->getWidth();
|
||||
|
||||
::SendMessage(_hSelf, RB_INSERTBAND, (WPARAM)0, (LPARAM)&_rbBand);
|
||||
REBARINFO rbi;
|
||||
ZeroMemory(&rbi, sizeof(REBARINFO));
|
||||
rbi.cbSize = sizeof(REBARINFO);
|
||||
rbi.fMask = 0;
|
||||
rbi.himl = (HIMAGELIST)NULL;
|
||||
::SendMessage(_hSelf, RB_SETBARINFO, 0, (LPARAM)&rbi);
|
||||
}
|
||||
|
||||
void ReBar::reNew() { //reNew is for toolbar only
|
||||
int index = (int)SendMessage(_hSelf, RB_IDTOINDEX, (WPARAM)REBAR_BAR_TOOLBAR, 0);
|
||||
DWORD size = (DWORD)SendMessage(_pToolBar->getHSelf(), TB_GETBUTTONSIZE, 0, 0);
|
||||
DWORD padding = (DWORD)SendMessage(_pToolBar->getHSelf(), TB_GETPADDING, 0,0);
|
||||
bool ReBar::addBand(REBARBANDINFO * rBand, bool useID) {
|
||||
if (rBand->fMask & RBBIM_STYLE)
|
||||
rBand->fStyle |= RBBS_GRIPPERALWAYS;
|
||||
else
|
||||
rBand->fStyle = RBBS_GRIPPERALWAYS;
|
||||
rBand->fMask |= RBBIM_ID | RBBIM_STYLE;
|
||||
if (useID) {
|
||||
if (isIDTaken(rBand->wID))
|
||||
return false;
|
||||
|
||||
_rbBand.fMask = RBBIM_CHILD | RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_IDEALSIZE;
|
||||
_rbBand.hwndChild = _pToolBar->getHSelf();
|
||||
_rbBand.cyMinChild = HIWORD(size) + HIWORD(padding);
|
||||
_rbBand.cyMaxChild = HIWORD(size) + HIWORD(padding);
|
||||
_rbBand.cxIdeal = _rbBand.cx = _pToolBar->getWidth();
|
||||
} else {
|
||||
rBand->wID = getNewID();
|
||||
}
|
||||
::SendMessage(_hSelf, RB_INSERTBAND, (WPARAM)-1, (LPARAM)rBand); //add to end of list
|
||||
return true;
|
||||
}
|
||||
|
||||
::SendMessage(_hSelf, RB_SETBANDINFO, (WPARAM)index, (LPARAM)&_rbBand);
|
||||
void ReBar::reNew(int id, REBARBANDINFO * rBand) {
|
||||
int index = (int)SendMessage(_hSelf, RB_IDTOINDEX, (WPARAM)id, 0);
|
||||
::SendMessage(_hSelf, RB_SETBANDINFO, (WPARAM)index, (LPARAM)rBand);
|
||||
};
|
||||
|
||||
void ReBar::removeBand(int id) {
|
||||
int index = (int)SendMessage(_hSelf, RB_IDTOINDEX, (WPARAM)id, 0);
|
||||
if (id >= REBAR_BAR_EXTERNAL)
|
||||
releaseID(id);
|
||||
::SendMessage(_hSelf, RB_DELETEBAND, (WPARAM)index, (LPARAM)0);
|
||||
}
|
||||
|
||||
void ReBar::setIDVisible(int id, bool show) {
|
||||
int index = (int)SendMessage(_hSelf, RB_IDTOINDEX, (WPARAM)id, 0);
|
||||
if (index == -1 )
|
||||
|
@ -270,4 +352,42 @@ bool ReBar::getIDVisible(int id) {
|
|||
return ((rbBand.fStyle & RBBS_HIDDEN) == 0);
|
||||
}
|
||||
|
||||
int ReBar::getNewID() {
|
||||
int idToUse = REBAR_BAR_EXTERNAL;
|
||||
int curVal = 0;
|
||||
size_t size = usedIDs.size();
|
||||
for(size_t i = 0; i < size; i++) {
|
||||
curVal = usedIDs.at(i);
|
||||
if (curVal < idToUse) {
|
||||
continue;
|
||||
} else if (curVal == idToUse) {
|
||||
idToUse++;
|
||||
} else {
|
||||
break; //found gap
|
||||
}
|
||||
}
|
||||
|
||||
usedIDs.push_back(idToUse);
|
||||
return idToUse;
|
||||
}
|
||||
|
||||
void ReBar::releaseID(int id) {
|
||||
size_t size = usedIDs.size();
|
||||
for(size_t i = 0; i < size; i++) {
|
||||
if (usedIDs.at(i) == id) {
|
||||
usedIDs.erase(usedIDs.begin()+i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ReBar::isIDTaken(int id) {
|
||||
size_t size = usedIDs.size();
|
||||
for(size_t i = 0; i < size; i++) {
|
||||
if (usedIDs.at(i) == id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
#define TOOL_BAR_H
|
||||
|
||||
#include "Window.h"
|
||||
#include "resource.h"
|
||||
#include "Notepad_plus_msgs.h"
|
||||
|
||||
#define REBAR_BAR_TOOLBAR 0
|
||||
//#define REBAR_BAR_SEARCH 1
|
||||
#define REBAR_BAR_SEARCH 1
|
||||
|
||||
#define REBAR_BAR_EXTERNAL 10
|
||||
#ifndef _WIN32_IE
|
||||
#define _WIN32_IE 0x0600
|
||||
#endif //_WIN32_IE
|
||||
|
@ -44,27 +44,24 @@ typedef struct {
|
|||
HICON hIcon; // icon for toolbar
|
||||
} tDynamicList;
|
||||
|
||||
class ReBar;
|
||||
|
||||
class ToolBar : public Window
|
||||
{
|
||||
public :
|
||||
ToolBar():Window(), _pTBB(NULL), _nrButtons(0), _nrDynButtons(0), _nrTotalButtons(0), _nrCurrentButtons(0) {};
|
||||
ToolBar():Window(), _pTBB(NULL), _nrButtons(0), _nrDynButtons(0), _nrTotalButtons(0), _nrCurrentButtons(0), _pRebar(NULL) {};
|
||||
virtual ~ToolBar(){};
|
||||
|
||||
virtual bool init(HINSTANCE hInst, HWND hPere, toolBarStatusType type,
|
||||
ToolBarButtonUnit *buttonUnitArray, int arraySize);
|
||||
|
||||
virtual void destroy() {
|
||||
delete [] _pTBB;
|
||||
::DestroyWindow(_hSelf);
|
||||
_hSelf = NULL;
|
||||
_toolBarIcons.destroy();
|
||||
};
|
||||
virtual void destroy();
|
||||
void enable(int cmdID, bool doEnable) const {
|
||||
::SendMessage(_hSelf, TB_ENABLEBUTTON, cmdID, (LPARAM)doEnable);
|
||||
};
|
||||
|
||||
int getWidth() const;
|
||||
int getHeight() const;
|
||||
|
||||
void reduce() {
|
||||
if (_state == TB_SMALL)
|
||||
|
@ -113,6 +110,10 @@ public :
|
|||
|
||||
void registerDynBtn(UINT message, toolbarIcons* hBmp);
|
||||
|
||||
void doPopop(POINT chevPoint); //show the popup if buttons are hidden
|
||||
|
||||
void addToRebar(ReBar * rebar);
|
||||
|
||||
private :
|
||||
TBBUTTON *_pTBB;
|
||||
ToolBarIcons _toolBarIcons;
|
||||
|
@ -122,6 +123,8 @@ private :
|
|||
size_t _nrDynButtons;
|
||||
size_t _nrTotalButtons;
|
||||
size_t _nrCurrentButtons;
|
||||
ReBar * _pRebar;
|
||||
REBARBANDINFO _rbBand;
|
||||
|
||||
|
||||
void setDefaultImageList() {
|
||||
|
@ -144,29 +147,28 @@ private :
|
|||
class ReBar : public Window
|
||||
{
|
||||
public :
|
||||
ReBar():Window(), _pToolBar(NULL) {};
|
||||
ReBar():Window() { usedIDs.clear(); };
|
||||
|
||||
virtual void destroy() {
|
||||
::DestroyWindow(_hSelf);
|
||||
_hSelf = NULL;
|
||||
usedIDs.clear();
|
||||
};
|
||||
|
||||
void init(HINSTANCE hInst, HWND hPere, ToolBar *pToolBar);
|
||||
void reNew();
|
||||
|
||||
int getHeight() const {
|
||||
if (::IsWindowVisible(_hSelf))
|
||||
return (int)(UINT)SendMessage(_hSelf, RB_GETBARHEIGHT, 0, 0);
|
||||
return 0;
|
||||
};
|
||||
void init(HINSTANCE hInst, HWND hPere);
|
||||
bool addBand(REBARBANDINFO * rBand, bool useID); //useID true if ID from info should be used (false for plugins). wID in bandinfo will be set to used ID
|
||||
void reNew(int id, REBARBANDINFO * rBand); //wID from bandinfo is used for update
|
||||
void removeBand(int id);
|
||||
|
||||
void setIDVisible(int id, bool show);
|
||||
bool getIDVisible(int id);
|
||||
|
||||
private:
|
||||
REBARINFO _rbi;
|
||||
REBARBANDINFO _rbBand;
|
||||
ToolBar *_pToolBar;
|
||||
vector<int> usedIDs;
|
||||
|
||||
int getNewID();
|
||||
void releaseID(int id);
|
||||
bool isIDTaken(int id);
|
||||
};
|
||||
|
||||
#endif // TOOL_BAR_H
|
||||
|
|
|
@ -361,9 +361,6 @@ IF NOT EXIST ..\bin\userDefineLang.xml COPY ..\src\userDefineLang.xml ..\bin\use
|
|||
<File
|
||||
RelativePath="..\src\Parameters.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\WinControls\Grid\resource.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\resource.h">
|
||||
</File>
|
||||
|
|
Loading…
Reference in New Issue