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
pull/343/head^2
harrybharry 2008-04-19 18:32:38 +00:00
parent 12a2f16042
commit 9e26b31e3a
12 changed files with 461 additions and 286 deletions

View File

@ -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_UPDATESILENTLY 1
#define CHECKDOCOPT_UPDATEGO2END 2 #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 RUNCOMMAND_USER (WM_USER + 3000)
#define NPPM_GETFULLCURRENTPATH (RUNCOMMAND_USER + FULL_CURRENT_PATH) #define NPPM_GETFULLCURRENTPATH (RUNCOMMAND_USER + FULL_CURRENT_PATH)
#define NPPM_GETCURRENTDIRECTORY (RUNCOMMAND_USER + CURRENT_DIRECTORY) #define NPPM_GETCURRENTDIRECTORY (RUNCOMMAND_USER + CURRENT_DIRECTORY)

View File

@ -63,6 +63,8 @@ Notepad_plus::Notepad_plus(): Window(), _mainWindowStatus(0), _pDocTab(NULL), _p
_recordingMacro(false), _pTrayIco(NULL), _isUDDocked(false), _isRTL(false), _recordingMacro(false), _pTrayIco(NULL), _isUDDocked(false), _isRTL(false),
_linkTriggered(true), _isDocModifing(false), _isHotspotDblClicked(false), _isSaving(false), _hideMenu(true), _sysMenuEntering(false) _linkTriggered(true), _isDocModifing(false), _isHotspotDblClicked(false), _isSaving(false), _hideMenu(true), _sysMenuEntering(false)
{ {
ZeroMemory(&_prevSelectedRange, sizeof(_prevSelectedRange));
_winVersion = getWindowsVersion(); _winVersion = getWindowsVersion();
TiXmlDocument *nativeLangDocRoot = (NppParameters::getInstance())->getNativeLang(); 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() void Notepad_plus::killAllChildren()
{ {
_toolBar.destroy(); _toolBar.destroy();
_rebar.destroy(); _rebarTop.destroy();
_rebarBottom.destroy();
if (_pMainSplitter) if (_pMainSplitter)
{ {
@ -343,7 +346,7 @@ bool Notepad_plus::saveGUIParams()
{ {
NppGUI & nppGUI = (NppGUI &)(NppParameters::getInstance())->getNppGUI(); NppGUI & nppGUI = (NppGUI &)(NppParameters::getInstance())->getNppGUI();
nppGUI._statusBarShow = _statusBar.isVisible(); nppGUI._statusBarShow = _statusBar.isVisible();
nppGUI._toolbarShow = _rebar.getIDVisible(REBAR_BAR_TOOLBAR); nppGUI._toolbarShow = _rebarTop.getIDVisible(REBAR_BAR_TOOLBAR);
nppGUI._toolBarStatus = _toolBar.getState(); nppGUI._toolBarStatus = _toolBar.getState();
nppGUI._tabStatus = (TabBarPlus::doDragNDropOrNot()?TAB_DRAWTOPBAR:0) | \ nppGUI._tabStatus = (TabBarPlus::doDragNDropOrNot()?TAB_DRAWTOPBAR:0) | \
@ -2263,6 +2266,31 @@ BOOL Notepad_plus::notify(SCNotification *notification)
SendMessage(_hSelf, WM_SIZE, 0, 0); SendMessage(_hSelf, WM_SIZE, 0, 0);
break; 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 : default :
break; break;
@ -2783,9 +2811,6 @@ void Notepad_plus::command(int id)
char str[strSize]; char str[strSize];
bool isFirstTime = !_findReplaceDlg.isCreated(); bool isFirstTime = !_findReplaceDlg.isCreated();
CharacterRange range = _pEditView->getSelection();
if (range.cpMin == range.cpMax)
_pEditView->expandWordSelection();
if (_nativeLang) if (_nativeLang)
{ {
@ -2809,8 +2834,8 @@ void Notepad_plus::command(int id)
} }
_findReplaceDlg.doDialog((id == IDM_SEARCH_FIND)?FIND_DLG:REPLACE_DLG, _isRTL); _findReplaceDlg.doDialog((id == IDM_SEARCH_FIND)?FIND_DLG:REPLACE_DLG, _isRTL);
if (_pEditView->getSelectedText(str, strSize, true)) _pEditView->getSelectedText(str, strSize);
_findReplaceDlg.setSearchText(str, _pEditView->getCurrentBuffer()._unicodeMode != uni8Bit); _findReplaceDlg.setSearchText(str, _pEditView->getCurrentBuffer()._unicodeMode != uni8Bit);
if (isFirstTime) if (isFirstTime)
changeDlgLang(_findReplaceDlg.getHSelf(), "Find"); changeDlgLang(_findReplaceDlg.getHSelf(), "Find");
@ -2827,13 +2852,8 @@ void Notepad_plus::command(int id)
const int strSize = 64; const int strSize = 64;
char str[strSize]; char str[strSize];
_incrementFindDlg.doDialog(_isRTL); _incrementFindDlg.display();
CharacterRange range = _pEditView->getSelection();
if (range.cpMin == range.cpMax)
{
_pEditView->expandWordSelection();
}
_pEditView->getSelectedText(str, strSize); _pEditView->getSelectedText(str, strSize);
_incrementFindDlg.setSearchText(str, _pEditView->getCurrentBuffer()._unicodeMode != uni8Bit); _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_FINDNEXT :
case IDM_SEARCH_VOLATILE_FINDPREV : case IDM_SEARCH_VOLATILE_FINDPREV :
{ {
CharacterRange range = _pEditView->getSelection(); char text2Find[MAX_PATH];
if (range.cpMin == range.cpMax) _pEditView->getSelectedText(text2Find, sizeof(text2Find));
{
_pEditView->expandWordSelection();
}
else
{
char text2Find[MAX_PATH];
_pEditView->getSelectedText(text2Find, sizeof(text2Find));
FindOption op; FindOption op;
op._isWholeWord = false; op._isWholeWord = false;
op._whichDirection = (id == IDM_SEARCH_VOLATILE_FINDNEXT?DIR_DOWN:DIR_UP); op._whichDirection = (id == IDM_SEARCH_VOLATILE_FINDNEXT?DIR_DOWN:DIR_UP);
_findReplaceDlg.processFindNext(text2Find, &op); _findReplaceDlg.processFindNext(text2Find, &op);
}
break; break;
} }
case IDM_SEARCH_MARKALL : case IDM_SEARCH_MARKALL :
{ {
CharacterRange range = _pEditView->getSelection(); const int strSize = 64;
if (range.cpMin == range.cpMax) char text2Find[strSize];
{
_pEditView->expandWordSelection();
}
char text2Find[MAX_PATH];
_pEditView->getSelectedText(text2Find, sizeof(text2Find)); _pEditView->getSelectedText(text2Find, sizeof(text2Find));
FindOption op; FindOption op;
@ -2974,9 +2982,7 @@ void Notepad_plus::command(int id)
else else
_pMainWindow = _pDocTab; _pMainWindow = _pDocTab;
RECT rc; ::SendMessage(_hSelf, WM_SIZE, 0, 0);
getMainClientRect(rc);
_dockingManager.reSizeTo(rc);
udd->display(false); udd->display(false);
_mainWindowStatus &= ~DOCK_MASK; _mainWindowStatus &= ~DOCK_MASK;
@ -3001,9 +3007,7 @@ void Notepad_plus::command(int id)
_pMainSplitter->setWin0((_mainWindowStatus & TWO_VIEWS_MASK)?(Window *)&_subSplitter:(Window *)_pDocTab); _pMainSplitter->setWin0((_mainWindowStatus & TWO_VIEWS_MASK)?(Window *)&_subSplitter:(Window *)_pDocTab);
RECT rc; ::SendMessage(_hSelf, WM_SIZE, 0, 0);
getMainClientRect(rc);
_dockingManager.reSizeTo(rc);
_pMainWindow->display(); _pMainWindow->display();
_mainWindowStatus |= DOCK_MASK; _mainWindowStatus |= DOCK_MASK;
@ -3157,8 +3161,8 @@ void Notepad_plus::command(int id)
case IDM_VIEW_TOOLBAR_HIDE: case IDM_VIEW_TOOLBAR_HIDE:
{ {
bool toSet = !_rebar.getIDVisible(REBAR_BAR_TOOLBAR); bool toSet = !_rebarTop.getIDVisible(REBAR_BAR_TOOLBAR);
_rebar.setIDVisible(REBAR_BAR_TOOLBAR, toSet); _rebarTop.setIDVisible(REBAR_BAR_TOOLBAR, toSet);
} }
break; break;
@ -3169,7 +3173,6 @@ void Notepad_plus::command(int id)
if (state != TB_SMALL) if (state != TB_SMALL)
{ {
_toolBar.reduce(); _toolBar.reduce();
_rebar.reNew();
changeToolBarIcons(); changeToolBarIcons();
} }
} }
@ -3182,7 +3185,6 @@ void Notepad_plus::command(int id)
if (state != TB_LARGE) if (state != TB_LARGE)
{ {
_toolBar.enlarge(); _toolBar.enlarge();
_rebar.reNew();
changeToolBarIcons(); changeToolBarIcons();
} }
} }
@ -3195,7 +3197,6 @@ void Notepad_plus::command(int id)
if (state != TB_STANDARD) if (state != TB_STANDARD)
{ {
_toolBar.setToUglyIcons(); _toolBar.setToUglyIcons();
_rebar.reNew();
} }
} }
break; break;
@ -3222,19 +3223,14 @@ void Notepad_plus::command(int id)
::SendMessage(_mainDocTab.getHSelf(), WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE, 0)); ::SendMessage(_mainDocTab.getHSelf(), WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE, 0));
::SendMessage(_subDocTab.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; break;
} }
case IDM_VIEW_REFRESHTABAR : case IDM_VIEW_REFRESHTABAR :
{ {
RECT rc; ::SendMessage(_hSelf, WM_SIZE, 0, 0);
getMainClientRect(rc);
_dockingManager.reSizeTo(rc);
break; break;
} }
case IDM_VIEW_LOCKTABBAR: case IDM_VIEW_LOCKTABBAR:
@ -3268,9 +3264,7 @@ void Notepad_plus::command(int id)
TabCtrl_SetItemSize(_mainDocTab.getHSelf(), 45, tabHeight); TabCtrl_SetItemSize(_mainDocTab.getHSelf(), 45, tabHeight);
TabCtrl_SetItemSize(_subDocTab.getHSelf(), 45, tabHeight); TabCtrl_SetItemSize(_subDocTab.getHSelf(), 45, tabHeight);
} }
RECT rc; ::SendMessage(_hSelf, WM_SIZE, 0, 0);
getMainClientRect(rc);
_dockingManager.reSizeTo(rc);
break; break;
} }
@ -3283,21 +3277,14 @@ void Notepad_plus::command(int id)
case IDM_VIEW_DRAWTABBAR_VERTICAL : case IDM_VIEW_DRAWTABBAR_VERTICAL :
{ {
TabBarPlus::setVertical(!TabBarPlus::isVertical()); TabBarPlus::setVertical(!TabBarPlus::isVertical());
::SendMessage(_hSelf, WM_SIZE, 0, 0);
RECT rc;
getMainClientRect(rc);
_dockingManager.reSizeTo(rc);
break; break;
} }
case IDM_VIEW_DRAWTABBAR_MULTILINE : case IDM_VIEW_DRAWTABBAR_MULTILINE :
{ {
TabBarPlus::setMultiLine(!TabBarPlus::isMultiLine()); TabBarPlus::setMultiLine(!TabBarPlus::isMultiLine());
RECT rc; ::SendMessage(_hSelf, WM_SIZE, 0, 0);
getMainClientRect(rc);
_dockingManager.reSizeTo(rc);
break; break;
} }
@ -4533,9 +4520,7 @@ void Notepad_plus::hideCurrentView()
_pDocTab->display(false); _pDocTab->display(false);
// resize the main window // resize the main window
RECT rc; ::SendMessage(_hSelf, WM_SIZE, 0, 0);
getMainClientRect(rc);
_dockingManager.reSizeTo(rc);
switchEditViewTo((getCurrentView() == MAIN_VIEW)?SUB_VIEW:MAIN_VIEW); 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 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); getClientRect(rc);
rc.top = rectMain.top + rectMain.bottom; rc.top += _rebarTop.getHeight();
rc.bottom = rc.bottom - rc.top; rc.bottom -= rc.top + _rebarBottom.getHeight() + _statusBar.getHeight();
} }
void Notepad_plus::dockUserDlg() void Notepad_plus::dockUserDlg()
@ -4752,9 +4721,7 @@ void Notepad_plus::dockUserDlg()
_mainWindowStatus |= DOCK_MASK; _mainWindowStatus |= DOCK_MASK;
_pMainWindow = _pMainSplitter; _pMainWindow = _pMainSplitter;
RECT rc; ::SendMessage(_hSelf, WM_SIZE, 0, 0);
getMainClientRect(rc);
_dockingManager.reSizeTo(rc);
} }
void Notepad_plus::undockUserDlg() void Notepad_plus::undockUserDlg()
@ -4767,9 +4734,7 @@ void Notepad_plus::undockUserDlg()
else else
_pMainWindow = _pDocTab; _pMainWindow = _pDocTab;
RECT rc; ::SendMessage(_hSelf, WM_SIZE, 0, 0);
getMainClientRect(rc);
_dockingManager.reSizeTo(rc);
_mainWindowStatus &= ~DOCK_MASK; _mainWindowStatus &= ~DOCK_MASK;
(ScintillaEditView::getUserDefineDlg())->display(); (ScintillaEditView::getUserDefineDlg())->display();
@ -4791,9 +4756,7 @@ void Notepad_plus::docGotoAnotherEditView(bool mode)
_pMainWindow = &_subSplitter; _pMainWindow = &_subSplitter;
// resize the main window // resize the main window
RECT rc; ::SendMessage(_hSelf, WM_SIZE, 0, 0);
getMainClientRect(rc);
_dockingManager.reSizeTo(rc);
getNonCurrentEditView()->display(); getNonCurrentEditView()->display();
getNonCurrentDocTab()->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_UNICODE_TYPE, 100);
_statusBar.setPartWidth(STATUSBAR_TYPING_MODE, 30); _statusBar.setPartWidth(STATUSBAR_TYPING_MODE, 30);
_statusBar.display(willBeShown); _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; _pMainWindow = &_mainDocTab;
_dockingManager.init(_hInst, hwnd, &_pMainWindow); _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(); //dynamicCheckMenuAndTB();
_mainEditView.defineDocType(L_TXT); _mainEditView.defineDocType(L_TXT);
@ -6488,8 +6411,50 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
changeToolBarIcons(); changeToolBarIcons();
_rebar.init(_hInst, hwnd, &_toolBar); _rebarTop.init(_hInst, hwnd);
_rebar.setIDVisible(REBAR_BAR_TOOLBAR, willBeShown); _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 //launch the plugin dlg memorized at the last session
DockingManagerData &dmd = nppGUI._dockingData; DockingManagerData &dmd = nppGUI._dockingData;
@ -6592,10 +6557,6 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
bool isFirstTime = !_findReplaceDlg.isCreated(); bool isFirstTime = !_findReplaceDlg.isCreated();
_findReplaceDlg.doDialog(FIND_DLG, _isRTL); _findReplaceDlg.doDialog(FIND_DLG, _isRTL);
//if ()
CharacterRange range = _pEditView->getSelection();
if (range.cpMin == range.cpMax)
_pEditView->expandWordSelection();
_pEditView->getSelectedText(str, strSize); _pEditView->getSelectedText(str, strSize);
_findReplaceDlg.setSearchText(str); _findReplaceDlg.setSearchText(str);
@ -6674,29 +6635,33 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case WM_SIZE: case WM_SIZE:
{ {
if (lParam == 0) {
RECT winRect;
getClientRect(winRect);
lParam = MAKELPARAM(winRect.right - winRect.left, winRect.bottom - winRect.top);
}
RECT rc; 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); ::MoveWindow(_rebarTop.getHSelf(), 0, 0, rc.right, _rebarTop.getHeight(), TRUE);
_statusBar.reSizeTo(rc); _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); getMainClientRect(rc);
_dockingManager.reSizeTo(rc); _dockingManager.reSizeTo(rc);
//_pMainWindow->reSizeTo(rc);
mkPosIncFindDlg(); //mkPosIncFindDlg();
result = TRUE; result = TRUE;
} }
break; break;
case WM_MOVE: case WM_MOVE:
{ {
redraw(); //redraw();
mkPosIncFindDlg(); //mkPosIncFindDlg();
result = TRUE; result = TRUE;
} }
break; break;
@ -6824,21 +6789,21 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
const int strSize = MAX_PATH; const int strSize = MAX_PATH;
char str[strSize]; char str[strSize];
CharacterRange range = _pEditView->getSelection(); _pEditView->getSelectedText((char *)str, strSize);
if (range.cpMin == range.cpMax)
_pEditView->expandWordSelection();
_pEditView->getSelectedText(str, strSize, true);
// For the compability reason, if wParam is 0, then we assume the size of string buffer (lParam) is large enough. // 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. // otherwise we check if the string buffer size is enough for the string to copy.
if (wParam != 0) 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); ::MessageBox(_hSelf, "Allocated buffer size is not enough to copy the string.", "NPPM_GETCURRENTWORD error", MB_OK);
return FALSE; return FALSE;
} }
else //buffer large enough, perform safe copy
{
lstrcpyn((char *)lParam, str, wParam);
return TRUE;
}
} }
strcpy((char *)lParam, str); strcpy((char *)lParam, str);
@ -7773,7 +7738,31 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
{ {
return _mainDocTab.getHideTabBarStatus(); 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 : case NPPM_INTERNAL_ISFOCUSEDTAB :
{ {
ScintillaEditView *cv = getCurrentEditView(); ScintillaEditView *cv = getCurrentEditView();
@ -7926,7 +7915,8 @@ void Notepad_plus::fullScreenToggle()
::ShowWindow(_hSelf, SW_HIDE); ::ShowWindow(_hSelf, SW_HIDE);
//Hide rebar //Hide rebar
_rebar.display(false); _rebarTop.display(false);
_rebarBottom.display(false);
//Set popup style for fullscreen window and store the old style //Set popup style for fullscreen window and store the old style
_prevStyles = ::SetWindowLongPtr( _hSelf, GWL_STYLE, WS_POPUP ); _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); ::SetWindowPos(_hSelf, HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOREDRAW|SWP_NOZORDER);
//Show rebar //Show rebar
_rebar.display(true); _rebarTop.display(true);
_rebarBottom.display(true);
if (_winPlace.length) if (_winPlace.length)
{ {
@ -8244,20 +8235,29 @@ bool Notepad_plus::str2Cliboard(const char *str2cpy)
void Notepad_plus::markSelectedText() 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(); LangType lt = _pEditView->getCurrentDocType();
if (lt == L_TXT) if (lt == L_TXT)
_pEditView->defineDocType(L_CPP); _pEditView->defineDocType(L_CPP);
_pEditView->defineDocType(lt); _pEditView->defineDocType(lt);
// Mark all if there is selection. //If nothing selected, dont mark anything
CharacterRange range = _pEditView->getSelection();
if (range.cpMin == range.cpMax) if (range.cpMin == range.cpMax)
{ {
return; return;
} }
char text2Find[MAX_PATH]; char text2Find[MAX_PATH];
_pEditView->getSelectedText(text2Find, sizeof(text2Find)); _pEditView->getSelectedText(text2Find, sizeof(text2Find), false); //do not expand selection (false)
FindOption op; FindOption op;
op._isWholeWord = false; op._isWholeWord = false;

View File

@ -198,7 +198,8 @@ private:
StatusBar _statusBar; StatusBar _statusBar;
bool _toReduceTabBar; bool _toReduceTabBar;
ReBar _rebar; ReBar _rebarTop;
ReBar _rebarBottom;
// Dialog // Dialog
FindReplaceDlg _findReplaceDlg; FindReplaceDlg _findReplaceDlg;
@ -241,6 +242,9 @@ private:
bool _isHotspotDblClicked; bool _isHotspotDblClicked;
bool _isSaving; bool _isSaving;
//For Dynamic selection highlight
CharacterRange _prevSelectedRange;
struct ActivateAppInfo { struct ActivateAppInfo {
bool _isActivated; bool _isActivated;
int _x; int _x;
@ -364,9 +368,7 @@ private:
void dockUserDlg(); void dockUserDlg();
void undockUserDlg(); void undockUserDlg();
void getToolBarClientRect(RECT &rc) const;
void getMainClientRect(RECT & rc) const; void getMainClientRect(RECT & rc) const;
void getStatusBarClientRect(RECT & rc) const;
int switchEditViewTo(int gid); int switchEditViewTo(int gid);
@ -621,13 +623,6 @@ private:
::SetCurrentDirectory(dir); ::SetCurrentDirectory(dir);
} }
bool str2Cliboard(const char *str2cpy); 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); bool getIntegralDockingData(tTbData & dockData, int & iCont, bool & isVisible);

View File

@ -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) BOOL CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{ {
switch (message) switch (message)
@ -1341,6 +1360,7 @@ BOOL CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
switch (LOWORD(wParam)) switch (LOWORD(wParam))
{ {
case IDCANCEL : case IDCANCEL :
::SetFocus((*(_pFRDlg->_ppEditView))->getHSelf());
display(false); display(false);
return TRUE; return TRUE;
@ -1359,7 +1379,7 @@ BOOL CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
return TRUE; return TRUE;
case IDC_INCFINDTEXT : case IDC_INCFINDTEXT :
if ((wParam >> 16) == 0x0300) if (HIWORD(wParam) == EN_CHANGE)
{ {
if (_doSearchFromBegin) 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; return FALSE;
} }
void FindIncrementDlg::goToLowerLeft() void FindIncrementDlg::addToRebar(ReBar * rebar) {
{ if(_pRebar)
RECT rc; return;
::GetClientRect(_hParent, &rc); hRebar = rebar->getHSelf();
//RECT rcSelf; _pRebar = rebar;
//::GetClientRect(_hSelf, &rcSelf); RECT client;
int selfHeight = _rc.bottom - _rc.top; getClientRect(client);
int selfWidth = _rc.right - _rc.left;
POINT llpoint; ZeroMemory(&_rbBand, sizeof(REBARBANDINFO));
llpoint.x = rc.left; _rbBand.cbSize = sizeof(REBARBANDINFO);
llpoint.y = rc.bottom - selfHeight; _rbBand.fMask = RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE |
::ClientToScreen(_hParent, &llpoint); RBBIM_SIZE | RBBIM_ID;
::SetWindowPos(_hSelf, HWND_TOP, llpoint.x, llpoint.y, selfWidth, selfHeight, SWP_SHOWWINDOW); _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);
} }

View File

@ -372,27 +372,18 @@ private :
class FindIncrementDlg : public StaticDialog class FindIncrementDlg : public StaticDialog
{ {
public : public :
//FindIncrementDlg() : _doSearchFromBegin() FindIncrementDlg() : _pFRDlg(NULL), _pRebar(NULL) {};
void init(HINSTANCE hInst, HWND hPere, FindReplaceDlg *pFRDlg) { void init(HINSTANCE hInst, HWND hPere, FindReplaceDlg *pFRDlg, bool isRTL = false) {
Window::init(hInst, hPere); Window::init(hInst, hPere);
if (!pFRDlg) if (!pFRDlg)
throw int(9910); throw int(9910);
_pFRDlg = pFRDlg; _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) { void setSearchText(const char * txt2find, bool isUTF8 = false) {
_doSearchFromBegin = false; _doSearchFromBegin = false;
if (!isUTF8) if (!isUTF8)
@ -405,9 +396,16 @@ public :
::SendDlgItemMessageW(_hSelf, IDC_INCFINDTEXT, WM_SETTEXT, 0, (LPARAM)wchars); ::SendDlgItemMessageW(_hSelf, IDC_INCFINDTEXT, WM_SETTEXT, 0, (LPARAM)wchars);
} }
void addToRebar(ReBar * rebar);
private : private :
bool _isRTL; bool _isRTL;
FindReplaceDlg *_pFRDlg; FindReplaceDlg *_pFRDlg;
ReBar * _pRebar;
REBARBANDINFO _rbBand;
HWND _hEditBox, _hSearchPrev, _hSearchNext, _hCheckCase;
bool _doSearchFromBegin; bool _doSearchFromBegin;
virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
}; };

View File

@ -78,16 +78,17 @@ BEGIN
CONTROL "",IDC_PERCENTAGE_SLIDER,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | NOT WS_VISIBLE | WS_TABSTOP,240,161,53,10 CONTROL "",IDC_PERCENTAGE_SLIDER,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | NOT WS_VISIBLE | WS_TABSTOP,240,161,53,10
END END
IDD_INCREMENT_FIND DIALOGEX 0, 0, 330, 14 IDD_INCREMENT_FIND DIALOGEX 0, 0, 330, 20
STYLE DS_SYSMODAL | DS_MODALFRAME | DS_CONTROL | DS_3DLOOK | DS_FIXEDSYS | WS_POPUP STYLE DS_SYSMODAL | DS_CONTROL | DS_FIXEDSYS | WS_CHILD | WS_CLIPCHILDREN
//EXSTYLE WS_EX_TRANSPARENT
FONT 8, "MS Shell Dlg" FONT 8, "MS Shell Dlg"
BEGIN BEGIN
DEFPUSHBUTTON "X",IDCANCEL,2,1,12,12 PUSHBUTTON "X",IDCANCEL,2,3,16,14
LTEXT "Find :",IDC_INCSTATIC,20,2,40,8 LTEXT "Find :",IDC_INCSTATIC,20,5,25,12
EDITTEXT IDC_INCFINDTEXT,45,1,175,12,ES_AUTOHSCROLL | ES_WANTRETURN | NOT WS_BORDER,WS_EX_STATICEDGE EDITTEXT IDC_INCFINDTEXT,45,4,175,12,ES_AUTOHSCROLL | ES_WANTRETURN | NOT WS_BORDER,WS_EX_STATICEDGE
DEFPUSHBUTTON "<",IDC_INCFINDPREVOK,223,0,16,14 PUSHBUTTON "<",IDC_INCFINDPREVOK,223,3,16,14
DEFPUSHBUTTON ">",IDC_INCFINDNXTOK,243,0,16,14 DEFPUSHBUTTON ">",IDC_INCFINDNXTOK,243,3,16,14
CONTROL "Match case", IDC_INCFINDMATCHCASE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,270,2,60,12 CONTROL "Match case", IDC_INCFINDMATCHCASE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,270,5,60,12
END END
IDD_FINDRESULT DIALOGEX 26, 41, 223, 67 IDD_FINDRESULT DIALOGEX 26, 41, 223, 67

View File

@ -399,16 +399,18 @@ public:
return (range.cpMax - range.cpMin); return (range.cpMax - range.cpMin);
}; };
char * getSelectedText(char * txt, int size, bool expand=false) { char * getSelectedText(char * txt, int size, bool expand = true) {
CharacterRange range = getSelection(); if (!size)
if (size <= (range.cpMax - range.cpMin))
return NULL; return NULL;
if (expand && range.cpMax == range.cpMin) CharacterRange range = getSelection();
if (range.cpMax == range.cpMin && expand)
{ {
expandWordSelection(); expandWordSelection();
range = getSelection(); 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); getText(txt, range.cpMin, range.cpMax);
return txt; return txt;

View File

@ -57,14 +57,14 @@ void StatusBar::init(HINSTANCE hInst, HWND hPere, int nbParts)
RECT rc; RECT rc;
::GetClientRect(_hParent, &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 // Calculate the right edge coordinate for each part, and
// copy the coordinates to the array. // copy the coordinates to the array.
int nWidth = myRc.right - 20; int nWidth = clientWidth - 20;
for (int i = _nbParts - 1 ; i >= 0 ; i--) for (int i = _nbParts - 1 ; i >= 0 ; i--)
{ {
_lpParts[i] = nWidth; _lpParts[i] = nWidth;

View File

@ -55,7 +55,7 @@ public :
virtual void reSizeTo(RECT & rc) { virtual void reSizeTo(RECT & rc) {
::MoveWindow(_hSelf, rc.left, rc.top, rc.right, rc.bottom, TRUE); ::MoveWindow(_hSelf, rc.left, rc.top, rc.right, rc.bottom, TRUE);
adjustParts(rc); adjustParts(rc.right);
redraw(); redraw();
}; };
@ -72,14 +72,14 @@ public :
return (::SendMessage(_hSelf, SB_SETTEXT, whichPart, (LPARAM)str) == TRUE); return (::SendMessage(_hSelf, SB_SETTEXT, whichPart, (LPARAM)str) == TRUE);
}; };
void adjustParts(int clientWidth);
private : private :
int _nbParts; int _nbParts;
int *_partWidthArray; int *_partWidthArray;
HLOCAL _hloc; HLOCAL _hloc;
LPINT _lpParts; LPINT _lpParts;
void adjustParts(RECT & myRc);
}; };
#endif // STATUS_BAR_H #endif // STATUS_BAR_H

View File

@ -18,6 +18,7 @@
//#include "..\..\resource.h" //#include "..\..\resource.h"
#include "ToolBar.h" #include "ToolBar.h"
#include "SysMsg.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; 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; 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 { int ToolBar::getWidth() const {
RECT btnRect; RECT btnRect;
int totalWidth = 0; int totalWidth = 0;
@ -105,6 +117,14 @@ int ToolBar::getWidth() const {
return totalWidth; 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) void ToolBar::reset(bool create)
{ {
@ -134,7 +154,7 @@ void ToolBar::reset(bool create)
// Send the TB_BUTTONSTRUCTSIZE message, which is required for // Send the TB_BUTTONSTRUCTSIZE message, which is required for
// backward compatibility. // backward compatibility.
::SendMessage(_hSelf, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0); ::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) if (!_hSelf)
@ -177,6 +197,16 @@ void ToolBar::reset(bool create)
::SendMessage(_hSelf, TB_ADDBUTTONS, (WPARAM)nrBtnToAdd, (LPARAM)_pTBB); ::SendMessage(_hSelf, TB_ADDBUTTONS, (WPARAM)nrBtnToAdd, (LPARAM)_pTBB);
} }
::SendMessage(_hSelf, TB_AUTOSIZE, 0, 0); ::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) 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); Window::init(hInst, hPere);
_pToolBar = pToolBar;
_hSelf = CreateWindowEx(WS_EX_TOOLWINDOW, _hSelf = CreateWindowEx(WS_EX_TOOLWINDOW,
REBARCLASSNAME, REBARCLASSNAME,
@ -204,46 +289,43 @@ void ReBar::init(HINSTANCE hInst, HWND hPere, ToolBar *pToolBar)
RBS_BANDBORDERS | CCS_NODIVIDER | CCS_NOPARENTALIGN, RBS_BANDBORDERS | CCS_NODIVIDER | CCS_NOPARENTALIGN,
0,0,0,0, _hParent, NULL, _hInst, NULL); 0,0,0,0, _hParent, NULL, _hInst, NULL);
ZeroMemory(&_rbi, sizeof(REBARINFO)); REBARINFO rbi;
_rbi.cbSize = sizeof(REBARINFO); ZeroMemory(&rbi, sizeof(REBARINFO));
_rbi.fMask = 0; rbi.cbSize = sizeof(REBARINFO);
_rbi.himl = (HIMAGELIST)NULL; rbi.fMask = 0;
::SendMessage(_hSelf, RB_SETBARINFO, 0, (LPARAM)&_rbi); 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);
} }
void ReBar::reNew() { //reNew is for toolbar only bool ReBar::addBand(REBARBANDINFO * rBand, bool useID) {
int index = (int)SendMessage(_hSelf, RB_IDTOINDEX, (WPARAM)REBAR_BAR_TOOLBAR, 0); if (rBand->fMask & RBBIM_STYLE)
DWORD size = (DWORD)SendMessage(_pToolBar->getHSelf(), TB_GETBUTTONSIZE, 0, 0); rBand->fStyle |= RBBS_GRIPPERALWAYS;
DWORD padding = (DWORD)SendMessage(_pToolBar->getHSelf(), TB_GETPADDING, 0,0); 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; } else {
_rbBand.hwndChild = _pToolBar->getHSelf(); rBand->wID = getNewID();
_rbBand.cyMinChild = HIWORD(size) + HIWORD(padding); }
_rbBand.cyMaxChild = HIWORD(size) + HIWORD(padding); ::SendMessage(_hSelf, RB_INSERTBAND, (WPARAM)-1, (LPARAM)rBand); //add to end of list
_rbBand.cxIdeal = _rbBand.cx = _pToolBar->getWidth(); 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) { void ReBar::setIDVisible(int id, bool show) {
int index = (int)SendMessage(_hSelf, RB_IDTOINDEX, (WPARAM)id, 0); int index = (int)SendMessage(_hSelf, RB_IDTOINDEX, (WPARAM)id, 0);
if (index == -1 ) if (index == -1 )
@ -270,4 +352,42 @@ bool ReBar::getIDVisible(int id) {
return ((rbBand.fStyle & RBBS_HIDDEN) == 0); 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;
}

View File

@ -19,12 +19,12 @@
#define TOOL_BAR_H #define TOOL_BAR_H
#include "Window.h" #include "Window.h"
#include "resource.h"
#include "Notepad_plus_msgs.h" #include "Notepad_plus_msgs.h"
#define REBAR_BAR_TOOLBAR 0 #define REBAR_BAR_TOOLBAR 0
//#define REBAR_BAR_SEARCH 1 #define REBAR_BAR_SEARCH 1
#define REBAR_BAR_EXTERNAL 10
#ifndef _WIN32_IE #ifndef _WIN32_IE
#define _WIN32_IE 0x0600 #define _WIN32_IE 0x0600
#endif //_WIN32_IE #endif //_WIN32_IE
@ -44,27 +44,24 @@ typedef struct {
HICON hIcon; // icon for toolbar HICON hIcon; // icon for toolbar
} tDynamicList; } tDynamicList;
class ReBar;
class ToolBar : public Window class ToolBar : public Window
{ {
public : 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 ~ToolBar(){};
virtual bool init(HINSTANCE hInst, HWND hPere, toolBarStatusType type, virtual bool init(HINSTANCE hInst, HWND hPere, toolBarStatusType type,
ToolBarButtonUnit *buttonUnitArray, int arraySize); ToolBarButtonUnit *buttonUnitArray, int arraySize);
virtual void destroy() { virtual void destroy();
delete [] _pTBB;
::DestroyWindow(_hSelf);
_hSelf = NULL;
_toolBarIcons.destroy();
};
void enable(int cmdID, bool doEnable) const { void enable(int cmdID, bool doEnable) const {
::SendMessage(_hSelf, TB_ENABLEBUTTON, cmdID, (LPARAM)doEnable); ::SendMessage(_hSelf, TB_ENABLEBUTTON, cmdID, (LPARAM)doEnable);
}; };
int getWidth() const; int getWidth() const;
int getHeight() const;
void reduce() { void reduce() {
if (_state == TB_SMALL) if (_state == TB_SMALL)
@ -113,6 +110,10 @@ public :
void registerDynBtn(UINT message, toolbarIcons* hBmp); void registerDynBtn(UINT message, toolbarIcons* hBmp);
void doPopop(POINT chevPoint); //show the popup if buttons are hidden
void addToRebar(ReBar * rebar);
private : private :
TBBUTTON *_pTBB; TBBUTTON *_pTBB;
ToolBarIcons _toolBarIcons; ToolBarIcons _toolBarIcons;
@ -122,6 +123,8 @@ private :
size_t _nrDynButtons; size_t _nrDynButtons;
size_t _nrTotalButtons; size_t _nrTotalButtons;
size_t _nrCurrentButtons; size_t _nrCurrentButtons;
ReBar * _pRebar;
REBARBANDINFO _rbBand;
void setDefaultImageList() { void setDefaultImageList() {
@ -144,29 +147,28 @@ private :
class ReBar : public Window class ReBar : public Window
{ {
public : public :
ReBar():Window(), _pToolBar(NULL) {}; ReBar():Window() { usedIDs.clear(); };
virtual void destroy() { virtual void destroy() {
::DestroyWindow(_hSelf); ::DestroyWindow(_hSelf);
_hSelf = NULL; _hSelf = NULL;
usedIDs.clear();
}; };
void init(HINSTANCE hInst, HWND hPere, ToolBar *pToolBar); void init(HINSTANCE hInst, HWND hPere);
void reNew(); 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
int getHeight() const { void removeBand(int id);
if (::IsWindowVisible(_hSelf))
return (int)(UINT)SendMessage(_hSelf, RB_GETBARHEIGHT, 0, 0);
return 0;
};
void setIDVisible(int id, bool show); void setIDVisible(int id, bool show);
bool getIDVisible(int id); bool getIDVisible(int id);
private: private:
REBARINFO _rbi; vector<int> usedIDs;
REBARBANDINFO _rbBand;
ToolBar *_pToolBar; int getNewID();
void releaseID(int id);
bool isIDTaken(int id);
}; };
#endif // TOOL_BAR_H #endif // TOOL_BAR_H

View File

@ -361,9 +361,6 @@ IF NOT EXIST ..\bin\userDefineLang.xml COPY ..\src\userDefineLang.xml ..\bin\use
<File <File
RelativePath="..\src\Parameters.h"> RelativePath="..\src\Parameters.h">
</File> </File>
<File
RelativePath="..\src\WinControls\Grid\resource.h">
</File>
<File <File
RelativePath="..\src\resource.h"> RelativePath="..\src\resource.h">
</File> </File>