mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-27 07:44:24 +02:00
Add the ability to hide selected toolbar buttons via a XML conf file
Usage: Move & rename toolbarButtonsConf_example.xml to %APPDATA%\Notepad++\toolbarButtonsConf.xml, modify the XML file content & save it in your favorite editor (Notepad++, whatelse? ;) ), then relaunch Notepad++. This PR simplies largely the logic of PR #15999 to make the code maintainable. Fix #15106, fix #15440, fix #16000, close #16216
This commit is contained in:
parent
83755ca155
commit
3d4a53adb4
@ -26,7 +26,7 @@ BIN_DIRECTORY := ../bin
|
|||||||
INSTALLER_DIRECTORY := ../installer
|
INSTALLER_DIRECTORY := ../installer
|
||||||
|
|
||||||
TARGET_BINARY := notepad++.exe
|
TARGET_BINARY := notepad++.exe
|
||||||
SRC_DATA := contextMenu.xml langs.model.xml shortcuts.xml stylers.model.xml tabContextMenu_example.xml toolbarIcons.xml
|
SRC_DATA := contextMenu.xml langs.model.xml shortcuts.xml stylers.model.xml tabContextMenu_example.xml toolbarButtonsConf_example.xml toolbarIcons.xml
|
||||||
BIN_DATA := change.log doLocalConf.xml nppLogNulContentCorruptionIssue.xml readme.txt userDefineLangs/
|
BIN_DATA := change.log doLocalConf.xml nppLogNulContentCorruptionIssue.xml readme.txt userDefineLangs/
|
||||||
INSTALLER_DATA := autoCompletion/ functionList/ localization/ themes/
|
INSTALLER_DATA := autoCompletion/ functionList/ localization/ themes/
|
||||||
|
|
||||||
|
@ -75,6 +75,7 @@ Function copyCommonFiles
|
|||||||
SetOutPath "$UPDATE_PATH\"
|
SetOutPath "$UPDATE_PATH\"
|
||||||
File "..\bin\contextMenu.xml"
|
File "..\bin\contextMenu.xml"
|
||||||
File "..\src\tabContextMenu_example.xml"
|
File "..\src\tabContextMenu_example.xml"
|
||||||
|
File "..\src\toolbarButtonsConf_example.xml"
|
||||||
File "..\src\toolbarIcons.xml"
|
File "..\src\toolbarIcons.xml"
|
||||||
|
|
||||||
SetOverwrite on
|
SetOverwrite on
|
||||||
|
@ -243,6 +243,7 @@ Section Uninstall
|
|||||||
Delete "$INSTDIR\langs.model.xml"
|
Delete "$INSTDIR\langs.model.xml"
|
||||||
Delete "$INSTDIR\stylers.model.xml"
|
Delete "$INSTDIR\stylers.model.xml"
|
||||||
Delete "$INSTDIR\tabContextMenu_example.xml"
|
Delete "$INSTDIR\tabContextMenu_example.xml"
|
||||||
|
Delete "$INSTDIR\toolbarButtonsConf_example.xml"
|
||||||
Delete "$INSTDIR\stylers_remove.xml"
|
Delete "$INSTDIR\stylers_remove.xml"
|
||||||
Delete "$INSTDIR\localization\english.xml"
|
Delete "$INSTDIR\localization\english.xml"
|
||||||
Delete "$INSTDIR\LINEDRAW.TTF"
|
Delete "$INSTDIR\LINEDRAW.TTF"
|
||||||
@ -277,6 +278,7 @@ Section Uninstall
|
|||||||
Delete "$APPDATA\${APPNAME}\insertExt.ini"
|
Delete "$APPDATA\${APPNAME}\insertExt.ini"
|
||||||
Delete "$APPDATA\${APPNAME}\nppLogNulContentCorruptionIssue.log"
|
Delete "$APPDATA\${APPNAME}\nppLogNulContentCorruptionIssue.log"
|
||||||
Delete "$APPDATA\${APPNAME}\tabContextMenu_example.xml"
|
Delete "$APPDATA\${APPNAME}\tabContextMenu_example.xml"
|
||||||
|
Delete "$APPDATA\${APPNAME}\toolbarButtonsConf_example.xml"
|
||||||
Delete "$APPDATA\${APPNAME}\toolbarIcons.xml"
|
Delete "$APPDATA\${APPNAME}\toolbarIcons.xml"
|
||||||
Delete "$APPDATA\${APPNAME}\userDefineLangs\userDefinedLang-markdown.default.modern.xml"
|
Delete "$APPDATA\${APPNAME}\userDefineLangs\userDefinedLang-markdown.default.modern.xml"
|
||||||
Delete "$APPDATA\${APPNAME}\userDefineLangs\markdown._preinstalled.udl.xml"
|
Delete "$APPDATA\${APPNAME}\userDefineLangs\markdown._preinstalled.udl.xml"
|
||||||
|
@ -111,6 +111,8 @@ copy /Y ..\src\contextMenu.xml .\minimalist\
|
|||||||
If ErrorLevel 1 goto End
|
If ErrorLevel 1 goto End
|
||||||
copy /Y ..\src\tabContextMenu_example.xml .\minimalist\
|
copy /Y ..\src\tabContextMenu_example.xml .\minimalist\
|
||||||
If ErrorLevel 1 goto End
|
If ErrorLevel 1 goto End
|
||||||
|
copy /Y ..\src\toolbarButtonsConf_example.xml .\minimalist\
|
||||||
|
If ErrorLevel 1 goto End
|
||||||
copy /Y ..\src\shortcuts.xml .\minimalist\
|
copy /Y ..\src\shortcuts.xml .\minimalist\
|
||||||
If ErrorLevel 1 goto End
|
If ErrorLevel 1 goto End
|
||||||
copy /Y ..\bin\doLocalConf.xml .\minimalist\
|
copy /Y ..\bin\doLocalConf.xml .\minimalist\
|
||||||
@ -146,6 +148,8 @@ copy /Y ..\src\contextMenu.xml .\minimalist64\
|
|||||||
If ErrorLevel 1 goto End
|
If ErrorLevel 1 goto End
|
||||||
copy /Y ..\src\tabContextMenu_example.xml .\minimalist64\
|
copy /Y ..\src\tabContextMenu_example.xml .\minimalist64\
|
||||||
If ErrorLevel 1 goto End
|
If ErrorLevel 1 goto End
|
||||||
|
copy /Y ..\src\toolbarButtonsConf_example.xml .\minimalist64\
|
||||||
|
If ErrorLevel 1 goto End
|
||||||
copy /Y ..\src\shortcuts.xml .\minimalist64\
|
copy /Y ..\src\shortcuts.xml .\minimalist64\
|
||||||
If ErrorLevel 1 goto End
|
If ErrorLevel 1 goto End
|
||||||
copy /Y ..\bin\doLocalConf.xml .\minimalist64\
|
copy /Y ..\bin\doLocalConf.xml .\minimalist64\
|
||||||
@ -181,6 +185,8 @@ copy /Y ..\src\contextMenu.xml .\minimalistArm64\
|
|||||||
If ErrorLevel 1 goto End
|
If ErrorLevel 1 goto End
|
||||||
copy /Y ..\src\tabContextMenu_example.xml .\minimalistArm64\
|
copy /Y ..\src\tabContextMenu_example.xml .\minimalistArm64\
|
||||||
If ErrorLevel 1 goto End
|
If ErrorLevel 1 goto End
|
||||||
|
copy /Y ..\src\toolbarButtonsConf_example.xml .\minimalistArm64\
|
||||||
|
If ErrorLevel 1 goto End
|
||||||
copy /Y ..\src\shortcuts.xml .\minimalistArm64\
|
copy /Y ..\src\shortcuts.xml .\minimalistArm64\
|
||||||
If ErrorLevel 1 goto End
|
If ErrorLevel 1 goto End
|
||||||
copy /Y ..\bin\doLocalConf.xml .\minimalistArm64\
|
copy /Y ..\bin\doLocalConf.xml .\minimalistArm64\
|
||||||
@ -267,6 +273,8 @@ copy /Y ..\src\contextMenu.xml .\zipped.package.release\
|
|||||||
If ErrorLevel 1 goto End
|
If ErrorLevel 1 goto End
|
||||||
copy /Y ..\src\tabContextMenu_example.xml .\zipped.package.release\
|
copy /Y ..\src\tabContextMenu_example.xml .\zipped.package.release\
|
||||||
If ErrorLevel 1 goto End
|
If ErrorLevel 1 goto End
|
||||||
|
copy /Y ..\src\toolbarButtonsConf_example.xml .\zipped.package.release\
|
||||||
|
If ErrorLevel 1 goto End
|
||||||
copy /Y ..\src\shortcuts.xml .\zipped.package.release\
|
copy /Y ..\src\shortcuts.xml .\zipped.package.release\
|
||||||
If ErrorLevel 1 goto End
|
If ErrorLevel 1 goto End
|
||||||
copy /Y ..\bin\doLocalConf.xml .\zipped.package.release\
|
copy /Y ..\bin\doLocalConf.xml .\zipped.package.release\
|
||||||
@ -295,6 +303,8 @@ copy /Y ..\src\contextMenu.xml .\zipped.package.release64\
|
|||||||
If ErrorLevel 1 goto End
|
If ErrorLevel 1 goto End
|
||||||
copy /Y ..\src\tabContextMenu_example.xml .\zipped.package.release64\
|
copy /Y ..\src\tabContextMenu_example.xml .\zipped.package.release64\
|
||||||
If ErrorLevel 1 goto End
|
If ErrorLevel 1 goto End
|
||||||
|
copy /Y ..\src\toolbarButtonsConf_example.xml .\zipped.package.release64\
|
||||||
|
If ErrorLevel 1 goto End
|
||||||
copy /Y ..\src\shortcuts.xml .\zipped.package.release64\
|
copy /Y ..\src\shortcuts.xml .\zipped.package.release64\
|
||||||
If ErrorLevel 1 goto End
|
If ErrorLevel 1 goto End
|
||||||
copy /Y ..\bin\doLocalConf.xml .\zipped.package.release64\
|
copy /Y ..\bin\doLocalConf.xml .\zipped.package.release64\
|
||||||
@ -322,6 +332,8 @@ copy /Y ..\src\contextMenu.xml .\zipped.package.releaseArm64\
|
|||||||
If ErrorLevel 1 goto End
|
If ErrorLevel 1 goto End
|
||||||
copy /Y ..\src\tabContextMenu_example.xml .\zipped.package.releaseArm64\
|
copy /Y ..\src\tabContextMenu_example.xml .\zipped.package.releaseArm64\
|
||||||
If ErrorLevel 1 goto End
|
If ErrorLevel 1 goto End
|
||||||
|
copy /Y ..\src\toolbarButtonsConf_example.xml .\zipped.package.releaseArm64\
|
||||||
|
If ErrorLevel 1 goto End
|
||||||
copy /Y ..\src\shortcuts.xml .\zipped.package.releaseArm64\
|
copy /Y ..\src\shortcuts.xml .\zipped.package.releaseArm64\
|
||||||
If ErrorLevel 1 goto End
|
If ErrorLevel 1 goto End
|
||||||
copy /Y ..\bin\doLocalConf.xml .\zipped.package.releaseArm64\
|
copy /Y ..\bin\doLocalConf.xml .\zipped.package.releaseArm64\
|
||||||
|
@ -150,11 +150,17 @@ Notepad_plus::Notepad_plus()
|
|||||||
nppParam.setNativeLangSpeaker(&_nativeLangSpeaker);
|
nppParam.setNativeLangSpeaker(&_nativeLangSpeaker);
|
||||||
|
|
||||||
TiXmlDocument *toolIconsDocRoot = nppParam.getCustomizedToolIcons();
|
TiXmlDocument *toolIconsDocRoot = nppParam.getCustomizedToolIcons();
|
||||||
|
TiXmlDocument *toolButtonsDocRoot = nppParam.getCustomizedToolButtons();
|
||||||
|
|
||||||
if (toolIconsDocRoot)
|
if (toolIconsDocRoot)
|
||||||
{
|
{
|
||||||
_toolBar.initTheme(toolIconsDocRoot);
|
_toolBar.initTheme(toolIconsDocRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (toolButtonsDocRoot)
|
||||||
|
{
|
||||||
|
_toolBar.initHideButtonsConf(toolButtonsDocRoot, toolBarIcons, sizeof(toolBarIcons) / sizeof(ToolBarButtonUnit));
|
||||||
|
}
|
||||||
|
|
||||||
// Determine if user is administrator.
|
// Determine if user is administrator.
|
||||||
BOOL is_admin;
|
BOOL is_admin;
|
||||||
|
@ -1498,6 +1498,21 @@ bool NppParameters::load()
|
|||||||
isAllLoaded = false;
|
isAllLoaded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------//
|
||||||
|
// toolbarButtonsConf.xml : for per user //
|
||||||
|
//---------------------------------------//
|
||||||
|
std::wstring toolbarButtonsConfXmlPath(_userPath);
|
||||||
|
pathAppend(toolbarButtonsConfXmlPath, L"toolbarButtonsConf.xml");
|
||||||
|
|
||||||
|
_pXmlToolButtonsConfDoc = new TiXmlDocument(toolbarButtonsConfXmlPath);
|
||||||
|
loadOkay = _pXmlToolButtonsConfDoc->LoadFile();
|
||||||
|
if (!loadOkay)
|
||||||
|
{
|
||||||
|
delete _pXmlToolButtonsConfDoc;
|
||||||
|
_pXmlToolButtonsConfDoc = nullptr;
|
||||||
|
isAllLoaded = false;
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------------//
|
//------------------------------//
|
||||||
// shortcuts.xml : for per user //
|
// shortcuts.xml : for per user //
|
||||||
//------------------------------//
|
//------------------------------//
|
||||||
@ -1724,6 +1739,7 @@ void NppParameters::destroyInstance()
|
|||||||
|
|
||||||
delete _pXmlNativeLangDocA;
|
delete _pXmlNativeLangDocA;
|
||||||
delete _pXmlToolIconsDoc;
|
delete _pXmlToolIconsDoc;
|
||||||
|
delete _pXmlToolButtonsConfDoc;
|
||||||
delete _pXmlShortcutDocA;
|
delete _pXmlShortcutDocA;
|
||||||
delete _pXmlContextMenuDocA;
|
delete _pXmlContextMenuDocA;
|
||||||
delete _pXmlTabContextMenuDocA;
|
delete _pXmlTabContextMenuDocA;
|
||||||
|
@ -1630,7 +1630,8 @@ public:
|
|||||||
|
|
||||||
TiXmlDocumentA * getNativeLangA() const {return _pXmlNativeLangDocA;};
|
TiXmlDocumentA * getNativeLangA() const {return _pXmlNativeLangDocA;};
|
||||||
|
|
||||||
TiXmlDocument * getCustomizedToolIcons() const {return _pXmlToolIconsDoc;};
|
TiXmlDocument* getCustomizedToolIcons() const {return _pXmlToolIconsDoc;};
|
||||||
|
TiXmlDocument* getCustomizedToolButtons() const {return _pXmlToolButtonsConfDoc;};
|
||||||
|
|
||||||
bool isTransparentAvailable() const {
|
bool isTransparentAvailable() const {
|
||||||
return (_winVersion >= WV_VISTA);
|
return (_winVersion >= WV_VISTA);
|
||||||
@ -1875,6 +1876,7 @@ private:
|
|||||||
TiXmlDocument *_pXmlUserLangDoc = nullptr; // userDefineLang.xml
|
TiXmlDocument *_pXmlUserLangDoc = nullptr; // userDefineLang.xml
|
||||||
std::vector<UdlXmlFileState> _pXmlUserLangsDoc; // userDefineLang customized XMLs
|
std::vector<UdlXmlFileState> _pXmlUserLangsDoc; // userDefineLang customized XMLs
|
||||||
TiXmlDocument *_pXmlToolIconsDoc = nullptr; // toolbarIcons.xml
|
TiXmlDocument *_pXmlToolIconsDoc = nullptr; // toolbarIcons.xml
|
||||||
|
TiXmlDocument * _pXmlToolButtonsConfDoc = nullptr; // toolbarButtonsConf.xml
|
||||||
|
|
||||||
TiXmlDocumentA *_pXmlShortcutDocA = nullptr; // shortcuts.xml
|
TiXmlDocumentA *_pXmlShortcutDocA = nullptr; // shortcuts.xml
|
||||||
|
|
||||||
|
@ -67,6 +67,81 @@ ToolbarIconIdUnit toolbarIconIDs[] = {
|
|||||||
{ L"save-macro", true }
|
{ L"save-macro", true }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void ToolBar::initHideButtonsConf(TiXmlDocument* toolButtonsDocRoot, ToolBarButtonUnit* buttonUnitArray, int arraySize)
|
||||||
|
{
|
||||||
|
TiXmlNode* toolButtons = toolButtonsDocRoot->FirstChild(L"NotepadPlus");
|
||||||
|
if (toolButtons)
|
||||||
|
{
|
||||||
|
toolButtons = toolButtons->FirstChild(L"ToolbarButtons");
|
||||||
|
if (toolButtons)
|
||||||
|
{
|
||||||
|
// Standard toolbar button
|
||||||
|
TiXmlNode* standardToolButtons = toolButtons->FirstChild(L"Standard");
|
||||||
|
if (standardToolButtons)
|
||||||
|
{
|
||||||
|
_toolbarStdButtonsConfArray = new bool[arraySize];
|
||||||
|
|
||||||
|
TiXmlElement* stdBtnElement = standardToolButtons->ToElement();
|
||||||
|
const wchar_t* isHideAll = stdBtnElement->Attribute(L"hideAll");
|
||||||
|
if (isHideAll && (lstrcmp(isHideAll, L"yes") == 0))
|
||||||
|
{
|
||||||
|
for (int i = 0; i < arraySize; ++i)
|
||||||
|
_toolbarStdButtonsConfArray[i] = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < arraySize; ++i)
|
||||||
|
_toolbarStdButtonsConfArray[i] = true;
|
||||||
|
|
||||||
|
for (TiXmlNode* childNode = standardToolButtons->FirstChildElement(L"Button");
|
||||||
|
childNode;
|
||||||
|
childNode = childNode->NextSibling(L"Button"))
|
||||||
|
{
|
||||||
|
TiXmlElement* element = childNode->ToElement();
|
||||||
|
int cmdID =0;
|
||||||
|
const wchar_t* cmdIDStr = element->Attribute(L"id", &cmdID);
|
||||||
|
|
||||||
|
int index = 0;
|
||||||
|
const wchar_t* orderStr = element->Attribute(L"index", &index);
|
||||||
|
|
||||||
|
const wchar_t* isHide = element->Attribute(L"hide");
|
||||||
|
|
||||||
|
if (cmdIDStr && orderStr && isHide && (lstrcmp(isHide, L"yes") == 0))
|
||||||
|
{
|
||||||
|
if (index < arraySize && buttonUnitArray[index]._cmdID == cmdID)
|
||||||
|
_toolbarStdButtonsConfArray[index] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Plugin toolbar button
|
||||||
|
TiXmlNode* pluginToolButtons = toolButtons->FirstChild(L"Plugin");
|
||||||
|
if (pluginToolButtons)
|
||||||
|
{
|
||||||
|
TiXmlElement* pluginBtnElement = pluginToolButtons->ToElement();
|
||||||
|
const wchar_t* isHideAll = pluginBtnElement->Attribute(L"hideAll");
|
||||||
|
if (isHideAll && (lstrcmp(isHideAll, L"yes") == 0))
|
||||||
|
{
|
||||||
|
_toolbarPluginButtonsConf._isHideAll = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (TiXmlNode* childNode = pluginToolButtons->FirstChildElement(L"Button");
|
||||||
|
childNode;
|
||||||
|
childNode = childNode->NextSibling(L"Button"))
|
||||||
|
{
|
||||||
|
bool doShow = true;
|
||||||
|
TiXmlElement* element = childNode->ToElement();
|
||||||
|
const wchar_t* isHide = element->Attribute(L"hide");
|
||||||
|
|
||||||
|
doShow = !(isHide && (lstrcmp(isHide, L"yes") == 0));
|
||||||
|
_toolbarPluginButtonsConf._showPluginButtonsArray.push_back(doShow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ToolBar::initTheme(TiXmlDocument *toolIconsDocRoot)
|
void ToolBar::initTheme(TiXmlDocument *toolIconsDocRoot)
|
||||||
{
|
{
|
||||||
_toolIcons = toolIconsDocRoot->FirstChild(L"NotepadPlus");
|
_toolIcons = toolIconsDocRoot->FirstChild(L"NotepadPlus");
|
||||||
@ -122,7 +197,7 @@ void ToolBar::initTheme(TiXmlDocument *toolIconsDocRoot)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ToolBar::init( HINSTANCE hInst, HWND hPere, toolBarStatusType type, ToolBarButtonUnit *buttonUnitArray, int arraySize)
|
bool ToolBar::init( HINSTANCE hInst, HWND hPere, toolBarStatusType type, ToolBarButtonUnit* buttonUnitArray, int arraySize)
|
||||||
{
|
{
|
||||||
Window::init(hInst, hPere);
|
Window::init(hInst, hPere);
|
||||||
|
|
||||||
@ -141,7 +216,7 @@ bool ToolBar::init( HINSTANCE hInst, HWND hPere, toolBarStatusType type, ToolBar
|
|||||||
InitCommonControlsEx(&icex);
|
InitCommonControlsEx(&icex);
|
||||||
|
|
||||||
//Create the list of buttons
|
//Create the list of buttons
|
||||||
_nbButtons = arraySize;
|
_nbButtons = arraySize;
|
||||||
_nbDynButtons = _vDynBtnReg.size();
|
_nbDynButtons = _vDynBtnReg.size();
|
||||||
_nbTotalButtons = _nbButtons + (_nbDynButtons ? _nbDynButtons + 1 : 0);
|
_nbTotalButtons = _nbButtons + (_nbDynButtons ? _nbDynButtons + 1 : 0);
|
||||||
_pTBB = new TBBUTTON[_nbTotalButtons]; //add one for the extra separator
|
_pTBB = new TBBUTTON[_nbTotalButtons]; //add one for the extra separator
|
||||||
@ -150,6 +225,7 @@ bool ToolBar::init( HINSTANCE hInst, HWND hPere, toolBarStatusType type, ToolBar
|
|||||||
int bmpIndex = -1;
|
int bmpIndex = -1;
|
||||||
BYTE style = 0;
|
BYTE style = 0;
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
|
|
||||||
for (; i < _nbButtons && i < _nbTotalButtons; ++i)
|
for (; i < _nbButtons && i < _nbTotalButtons; ++i)
|
||||||
{
|
{
|
||||||
cmd = buttonUnitArray[i]._cmdID;
|
cmd = buttonUnitArray[i]._cmdID;
|
||||||
@ -158,38 +234,42 @@ bool ToolBar::init( HINSTANCE hInst, HWND hPere, toolBarStatusType type, ToolBar
|
|||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
style = BTNS_SEP;
|
style = BTNS_SEP;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case IDM_VIEW_ALL_CHARACTERS:
|
case IDM_VIEW_ALL_CHARACTERS:
|
||||||
{
|
{
|
||||||
++bmpIndex;
|
++bmpIndex;
|
||||||
style = BTNS_DROPDOWN;
|
style = BTNS_DROPDOWN;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
++bmpIndex;
|
++bmpIndex;
|
||||||
style = BTNS_BUTTON;
|
style = BTNS_BUTTON;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_pTBB[i].iBitmap = (cmd != 0 ? bmpIndex : 0);
|
_pTBB[i].iBitmap = (cmd != 0 ? bmpIndex : 0);
|
||||||
_pTBB[i].idCommand = cmd;
|
_pTBB[i].idCommand = cmd;
|
||||||
_pTBB[i].fsState = TBSTATE_ENABLED;
|
_pTBB[i].fsState = TBSTATE_ENABLED | (_toolbarStdButtonsConfArray ? (_toolbarStdButtonsConfArray[i] ? 0 : TBSTATE_HIDDEN) : 0);
|
||||||
_pTBB[i].fsStyle = style;
|
_pTBB[i].fsStyle = style;
|
||||||
_pTBB[i].dwData = 0;
|
_pTBB[i].dwData = 0;
|
||||||
_pTBB[i].iString = 0;
|
_pTBB[i].iString = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool doHideAllPluginButtons = _toolbarPluginButtonsConf._isHideAll;
|
||||||
|
size_t nbPluginButtonsConf = _toolbarPluginButtonsConf._showPluginButtonsArray.size();
|
||||||
|
|
||||||
if (_nbDynButtons > 0 && i < _nbTotalButtons)
|
if (_nbDynButtons > 0 && i < _nbTotalButtons)
|
||||||
{
|
{
|
||||||
|
unsigned char addedStateFlag = doHideAllPluginButtons ? TBSTATE_HIDDEN : (nbPluginButtonsConf > 0 ? (_toolbarPluginButtonsConf._showPluginButtonsArray[0] ? 0 : TBSTATE_HIDDEN) : 0);
|
||||||
|
|
||||||
//add separator
|
//add separator
|
||||||
_pTBB[i].iBitmap = 0;
|
_pTBB[i].iBitmap = 0;
|
||||||
_pTBB[i].idCommand = 0;
|
_pTBB[i].idCommand = 0;
|
||||||
_pTBB[i].fsState = TBSTATE_ENABLED;
|
_pTBB[i].fsState = TBSTATE_ENABLED | addedStateFlag;
|
||||||
_pTBB[i].fsStyle = BTNS_SEP;
|
_pTBB[i].fsStyle = BTNS_SEP;
|
||||||
_pTBB[i].dwData = 0;
|
_pTBB[i].dwData = 0;
|
||||||
_pTBB[i].iString = 0;
|
_pTBB[i].iString = 0;
|
||||||
@ -201,9 +281,11 @@ bool ToolBar::init( HINSTANCE hInst, HWND hPere, toolBarStatusType type, ToolBar
|
|||||||
cmd = _vDynBtnReg[j]._message;
|
cmd = _vDynBtnReg[j]._message;
|
||||||
++bmpIndex;
|
++bmpIndex;
|
||||||
|
|
||||||
|
addedStateFlag = doHideAllPluginButtons ? TBSTATE_HIDDEN : (nbPluginButtonsConf > j + 1 ? (_toolbarPluginButtonsConf._showPluginButtonsArray[j + 1] ? 0 : TBSTATE_HIDDEN) : 0);
|
||||||
|
|
||||||
_pTBB[i].iBitmap = bmpIndex;
|
_pTBB[i].iBitmap = bmpIndex;
|
||||||
_pTBB[i].idCommand = cmd;
|
_pTBB[i].idCommand = cmd;
|
||||||
_pTBB[i].fsState = TBSTATE_ENABLED;
|
_pTBB[i].fsState = TBSTATE_ENABLED | addedStateFlag;
|
||||||
_pTBB[i].fsStyle = BTNS_BUTTON;
|
_pTBB[i].fsStyle = BTNS_BUTTON;
|
||||||
_pTBB[i].dwData = 0;
|
_pTBB[i].dwData = 0;
|
||||||
_pTBB[i].iString = 0;
|
_pTBB[i].iString = 0;
|
||||||
|
@ -43,6 +43,12 @@ struct iconLocator {
|
|||||||
: _listIndex(iList), _iconIndex(iIcon), _iconLocation(iconLoc){};
|
: _listIndex(iList), _iconIndex(iIcon), _iconLocation(iconLoc){};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ToolbarPluginButtonsConf
|
||||||
|
{
|
||||||
|
bool _isHideAll = false;
|
||||||
|
std::vector<bool> _showPluginButtonsArray;
|
||||||
|
};
|
||||||
|
|
||||||
class ReBar;
|
class ReBar;
|
||||||
class TiXmlDocument;
|
class TiXmlDocument;
|
||||||
class TiXmlNode;
|
class TiXmlNode;
|
||||||
@ -53,9 +59,10 @@ public :
|
|||||||
ToolBar() = default;
|
ToolBar() = default;
|
||||||
~ToolBar() = default;
|
~ToolBar() = default;
|
||||||
|
|
||||||
void initTheme(TiXmlDocument *toolIconsDocRoot);
|
void initTheme(TiXmlDocument* toolIconsDocRoot);
|
||||||
virtual bool init(HINSTANCE hInst, HWND hPere, toolBarStatusType type,
|
void initHideButtonsConf(TiXmlDocument* toolButtonsDocRoot, ToolBarButtonUnit* buttonUnitArray, int arraySize);
|
||||||
ToolBarButtonUnit *buttonUnitArray, int arraySize);
|
|
||||||
|
virtual bool init(HINSTANCE hInst, HWND hPere, toolBarStatusType type, ToolBarButtonUnit* buttonUnitArray, int arraySize);
|
||||||
|
|
||||||
virtual void destroy();
|
virtual void destroy();
|
||||||
void enable(int cmdID, bool doEnable) const {
|
void enable(int cmdID, bool doEnable) const {
|
||||||
@ -116,8 +123,10 @@ private :
|
|||||||
ReBar * _pRebar = nullptr;
|
ReBar * _pRebar = nullptr;
|
||||||
REBARBANDINFO _rbBand = {};
|
REBARBANDINFO _rbBand = {};
|
||||||
std::vector<iconLocator> _customIconVect;
|
std::vector<iconLocator> _customIconVect;
|
||||||
|
bool* _toolbarStdButtonsConfArray = nullptr;
|
||||||
|
ToolbarPluginButtonsConf _toolbarPluginButtonsConf;
|
||||||
|
|
||||||
TiXmlNode *_toolIcons = nullptr;
|
TiXmlNode* _toolIcons = nullptr;
|
||||||
|
|
||||||
DPIManagerV2 _dpiManager;
|
DPIManagerV2 _dpiManager;
|
||||||
|
|
||||||
|
76
PowerEditor/src/toolbarButtonsConf_example.xml
Normal file
76
PowerEditor/src/toolbarButtonsConf_example.xml
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<NotepadPlus>
|
||||||
|
<ToolbarButtons>
|
||||||
|
<!--
|
||||||
|
This file makes your toolbar buttons hideable.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
Move and rename the "toolbarButtonsConf_example.xml" to "%APPDATA%\Notepad++\toolbarButtonsConf.xml"
|
||||||
|
(or beside "notepad++.exe" if you're using the portable package).
|
||||||
|
Modify the attributes "hideAll" or "hide" of the items with "yes" or "no" values.
|
||||||
|
Save the file and relaunch Notepad++ to hide/show the buttons you selected.
|
||||||
|
|
||||||
|
Notice:
|
||||||
|
1. The values of the attributes "index" and "id" shouldn't be modified because they are used for synchronizing with internal data to maintain the coherence of this file.
|
||||||
|
2. The attribute "name" is informative only, so the values of "name" can be modified for the user's convenience.
|
||||||
|
3. The "yes" value of the "hideAll" attribute will override all values of the "hide" attribute.
|
||||||
|
-->
|
||||||
|
<Standard hideAll="no">
|
||||||
|
<Button hide="no" index="0" id="41001" name="New" />
|
||||||
|
<Button hide="no" index="1" id="41002" name="Open..." />
|
||||||
|
<Button hide="no" index="2" id="41006" name="Save" />
|
||||||
|
<Button hide="no" index="3" id="41007" name="Save All" />
|
||||||
|
<Button hide="no" index="4" id="41003" name="Close" />
|
||||||
|
<Button hide="no" index="5" id="41004" name="Close All" />
|
||||||
|
<Button hide="no" index="6" id="41010" name="Print..." />
|
||||||
|
<Button hide="no" index="7" id="0" name="SEPARATOR" />
|
||||||
|
<Button hide="no" index="8" id="42001" name="Cut" />
|
||||||
|
<Button hide="no" index="9" id="42002" name="Copy" />
|
||||||
|
<Button hide="no" index="10" id="42005" name="Paste" />
|
||||||
|
<Button hide="no" index="11" id="0" name="SEPARATOR" />
|
||||||
|
<Button hide="no" index="12" id="42003" name="Undo" />
|
||||||
|
<Button hide="no" index="13" id="42004" name="Redo" />
|
||||||
|
<Button hide="no" index="14" id="0" name="SEPARATOR" />
|
||||||
|
<Button hide="no" index="15" id="43001" name="Find..." />
|
||||||
|
<Button hide="no" index="16" id="43003" name="Replace..." />
|
||||||
|
<Button hide="no" index="17" id="0" name="SEPARATOR" />
|
||||||
|
<Button hide="no" index="18" id="44023" name="Zoom In (Ctrl+Mouse Wheel Up)" />
|
||||||
|
<Button hide="no" index="19" id="44024" name="Zoom Out (Ctrl+Mouse Wheel Down)" />
|
||||||
|
<Button hide="no" index="20" id="0" name="SEPARATOR" />
|
||||||
|
<Button hide="no" index="21" id="44035" name="Synchronize Vertical Scrolling" />
|
||||||
|
<Button hide="no" index="22" id="44036" name="Synchronize Horizontal Scrolling" />
|
||||||
|
<Button hide="no" index="23" id="0" name="SEPARATOR" />
|
||||||
|
<Button hide="no" index="24" id="44022" name="Word wrap" />
|
||||||
|
<Button hide="no" index="25" id="44019" name="Show All Characters" />
|
||||||
|
<Button hide="no" index="26" id="44020" name="Show Indent Guide" />
|
||||||
|
<Button hide="no" index="27" id="0" name="SEPARATOR" />
|
||||||
|
<Button hide="no" index="28" id="46250" name="Define your language..." />
|
||||||
|
<Button hide="no" index="29" id="44080" name="Document Map" />
|
||||||
|
<Button hide="no" index="30" id="44070" name="Document List" />
|
||||||
|
<Button hide="no" index="31" id="44084" name="Function List" />
|
||||||
|
<Button hide="no" index="32" id="44085" name="Folder as Workspace" />
|
||||||
|
<Button hide="no" index="33" id="0" name="SEPARATOR" />
|
||||||
|
<Button hide="no" index="34" id="44097" name="Monitoring (tail -f)" />
|
||||||
|
<Button hide="no" index="35" id="0" name="SEPARATOR" />
|
||||||
|
<Button hide="no" index="36" id="42018" name="Start Recording" />
|
||||||
|
<Button hide="no" index="37" id="42019" name="Stop Recording" />
|
||||||
|
<Button hide="no" index="38" id="42021" name="Playback" />
|
||||||
|
<Button hide="no" index="39" id="42032" name="Run a Macro Multiple Times..." />
|
||||||
|
<Button hide="no" index="40" id="42025" name="Save Current Recorded Macro..." />
|
||||||
|
</Standard>
|
||||||
|
<!--
|
||||||
|
In this section we can hide toolbar buttons for installed plugins based on their order in the toolbar (including separators).
|
||||||
|
"Name" attribute has no effect, use it as a reminder.
|
||||||
|
When installing / uninstalling plugins, add/remove button entries as necessary so your button settings correspond to the changed toolbar button order.
|
||||||
|
-->
|
||||||
|
<Plugin hideAll="no">
|
||||||
|
<Button hide="no" name="SEPARATOR" /> <!-- The 1st button -->
|
||||||
|
<Button hide="no" name="Plugin button 1" /> <!-- The 2nd button -->
|
||||||
|
<Button hide="no" name="Plugin button 2" /> <!-- The 3rd button -->
|
||||||
|
<Button hide="no" name="Plugin button 3" /> <!-- The 4th button -->
|
||||||
|
<!--Button hide="no" name="Plugin button 4" /--> <!-- uncomment "Button" tags if need -->
|
||||||
|
<!--Button hide="no" name="Plugin button 5" /--> <!-- uncomment "Button" tags if need -->
|
||||||
|
<!-- Add more "Button" tags here... -->
|
||||||
|
</Plugin>
|
||||||
|
</ToolbarButtons>
|
||||||
|
</NotepadPlus>
|
Loading…
x
Reference in New Issue
Block a user