[UPDATE] refactoring (in progress).
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@624 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
bffdb9f4fe
commit
2e54127036
|
@ -62,76 +62,12 @@ Notepad_plus::Notepad_plus(): Window(), _mainWindowStatus(0), _pDocTab(NULL), _p
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TiXmlDocument *toolIconsDocRoot = (NppParameters::getInstance())->getToolIcons();
|
TiXmlDocument *toolIconsDocRoot = (NppParameters::getInstance())->getToolIcons();
|
||||||
|
|
||||||
|
|
||||||
if (toolIconsDocRoot)
|
if (toolIconsDocRoot)
|
||||||
{
|
{
|
||||||
_toolIcons = toolIconsDocRoot->FirstChild(TEXT("NotepadPlus"));
|
_toolBar.initTheme(toolIconsDocRoot);
|
||||||
if (_toolIcons)
|
}
|
||||||
{
|
|
||||||
_toolIcons = _toolIcons->FirstChild(TEXT("ToolBarIcons"));
|
|
||||||
if (_toolIcons)
|
|
||||||
{
|
|
||||||
_toolIcons = _toolIcons->FirstChild(TEXT("Theme"));
|
|
||||||
if (_toolIcons)
|
|
||||||
{
|
|
||||||
const TCHAR *themeDir = (_toolIcons->ToElement())->Attribute(TEXT("pathPrefix"));
|
|
||||||
|
|
||||||
for (TiXmlNode *childNode = _toolIcons->FirstChildElement(TEXT("Icon"));
|
|
||||||
childNode ;
|
|
||||||
childNode = childNode->NextSibling(TEXT("Icon")))
|
|
||||||
{
|
|
||||||
int iIcon;
|
|
||||||
const TCHAR *res = (childNode->ToElement())->Attribute(TEXT("id"), &iIcon);
|
|
||||||
if (res)
|
|
||||||
{
|
|
||||||
TiXmlNode *grandChildNode = childNode->FirstChildElement(TEXT("normal"));
|
|
||||||
if (grandChildNode)
|
|
||||||
{
|
|
||||||
TiXmlNode *valueNode = grandChildNode->FirstChild();
|
|
||||||
//putain, enfin!!!
|
|
||||||
if (valueNode)
|
|
||||||
{
|
|
||||||
generic_string locator = themeDir?themeDir:TEXT("");
|
|
||||||
|
|
||||||
locator += valueNode->Value();
|
|
||||||
_customIconVect.push_back(iconLocator(0, iIcon, locator));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
grandChildNode = childNode->FirstChildElement(TEXT("hover"));
|
|
||||||
if (grandChildNode)
|
|
||||||
{
|
|
||||||
TiXmlNode *valueNode = grandChildNode->FirstChild();
|
|
||||||
//putain, enfin!!!
|
|
||||||
if (valueNode)
|
|
||||||
{
|
|
||||||
generic_string locator = themeDir?themeDir:TEXT("");
|
|
||||||
|
|
||||||
locator += valueNode->Value();
|
|
||||||
_customIconVect.push_back(iconLocator(1, iIcon, locator));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
grandChildNode = childNode->FirstChildElement(TEXT("disabled"));
|
|
||||||
if (grandChildNode)
|
|
||||||
{
|
|
||||||
TiXmlNode *valueNode = grandChildNode->FirstChild();
|
|
||||||
//putain, enfin!!!
|
|
||||||
if (valueNode)
|
|
||||||
{
|
|
||||||
generic_string locator = themeDir?themeDir:TEXT("");
|
|
||||||
|
|
||||||
locator += valueNode->Value();
|
|
||||||
_customIconVect.push_back(iconLocator(2, iIcon, locator));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
_toolIcons = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ATTENTION : the order of the destruction is very important
|
// ATTENTION : the order of the destruction is very important
|
||||||
|
@ -2991,10 +2927,7 @@ bool Notepad_plus::addCurrentMacro()
|
||||||
|
|
||||||
void Notepad_plus::changeToolBarIcons()
|
void Notepad_plus::changeToolBarIcons()
|
||||||
{
|
{
|
||||||
if (!_toolIcons)
|
_toolBar.changeIcons();
|
||||||
return;
|
|
||||||
for (int i = 0 ; i < int(_customIconVect.size()) ; i++)
|
|
||||||
_toolBar.changeIcons(_customIconVect[i].listIndex, _customIconVect[i].iconIndex, (_customIconVect[i].iconLocation).c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Notepad_plus::switchToFile(BufferID id)
|
bool Notepad_plus::switchToFile(BufferID id)
|
||||||
|
|
|
@ -144,17 +144,8 @@ enum Views {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct TaskListInfo;
|
struct TaskListInfo;
|
||||||
|
|
||||||
struct iconLocator {
|
|
||||||
int listIndex;
|
|
||||||
int iconIndex;
|
|
||||||
generic_string iconLocation;
|
|
||||||
|
|
||||||
iconLocator(int iList, int iIcon, const generic_string iconLoc)
|
|
||||||
: listIndex(iList), iconIndex(iIcon), iconLocation(iconLoc){};
|
|
||||||
};
|
|
||||||
|
|
||||||
struct VisibleGUIConf {
|
struct VisibleGUIConf {
|
||||||
bool isPostIt;
|
bool isPostIt;
|
||||||
|
@ -301,7 +292,7 @@ private:
|
||||||
AutoCompletion _autoCompleteSub; //each Scintilla has its own autoComplete
|
AutoCompletion _autoCompleteSub; //each Scintilla has its own autoComplete
|
||||||
|
|
||||||
SmartHighlighter _smartHighlighter;
|
SmartHighlighter _smartHighlighter;
|
||||||
TiXmlNode *_toolIcons;
|
//TiXmlNode *_toolIcons;
|
||||||
NativeLangSpeaker _nativeLangSpeaker;
|
NativeLangSpeaker _nativeLangSpeaker;
|
||||||
DocTabView _mainDocTab;
|
DocTabView _mainDocTab;
|
||||||
DocTabView _subDocTab;
|
DocTabView _subDocTab;
|
||||||
|
@ -344,7 +335,7 @@ private:
|
||||||
|
|
||||||
LastRecentFileList _lastRecentFileList;
|
LastRecentFileList _lastRecentFileList;
|
||||||
|
|
||||||
vector<iconLocator> _customIconVect;
|
//vector<iconLocator> _customIconVect;
|
||||||
|
|
||||||
WindowsMenu _windowsMenu;
|
WindowsMenu _windowsMenu;
|
||||||
HMENU _mainMenuHandle;
|
HMENU _mainMenuHandle;
|
||||||
|
|
|
@ -22,6 +22,75 @@
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
void ToolBar::initTheme(TiXmlDocument *toolIconsDocRoot)
|
||||||
|
{
|
||||||
|
_toolIcons = toolIconsDocRoot->FirstChild(TEXT("NotepadPlus"));
|
||||||
|
if (_toolIcons)
|
||||||
|
{
|
||||||
|
_toolIcons = _toolIcons->FirstChild(TEXT("ToolBarIcons"));
|
||||||
|
if (_toolIcons)
|
||||||
|
{
|
||||||
|
_toolIcons = _toolIcons->FirstChild(TEXT("Theme"));
|
||||||
|
if (_toolIcons)
|
||||||
|
{
|
||||||
|
const TCHAR *themeDir = (_toolIcons->ToElement())->Attribute(TEXT("pathPrefix"));
|
||||||
|
|
||||||
|
for (TiXmlNode *childNode = _toolIcons->FirstChildElement(TEXT("Icon"));
|
||||||
|
childNode ;
|
||||||
|
childNode = childNode->NextSibling(TEXT("Icon")))
|
||||||
|
{
|
||||||
|
int iIcon;
|
||||||
|
const TCHAR *res = (childNode->ToElement())->Attribute(TEXT("id"), &iIcon);
|
||||||
|
if (res)
|
||||||
|
{
|
||||||
|
TiXmlNode *grandChildNode = childNode->FirstChildElement(TEXT("normal"));
|
||||||
|
if (grandChildNode)
|
||||||
|
{
|
||||||
|
TiXmlNode *valueNode = grandChildNode->FirstChild();
|
||||||
|
//putain, enfin!!!
|
||||||
|
if (valueNode)
|
||||||
|
{
|
||||||
|
generic_string locator = themeDir?themeDir:TEXT("");
|
||||||
|
|
||||||
|
locator += valueNode->Value();
|
||||||
|
_customIconVect.push_back(iconLocator(0, iIcon, locator));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
grandChildNode = childNode->FirstChildElement(TEXT("hover"));
|
||||||
|
if (grandChildNode)
|
||||||
|
{
|
||||||
|
TiXmlNode *valueNode = grandChildNode->FirstChild();
|
||||||
|
//putain, enfin!!!
|
||||||
|
if (valueNode)
|
||||||
|
{
|
||||||
|
generic_string locator = themeDir?themeDir:TEXT("");
|
||||||
|
|
||||||
|
locator += valueNode->Value();
|
||||||
|
_customIconVect.push_back(iconLocator(1, iIcon, locator));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
grandChildNode = childNode->FirstChildElement(TEXT("disabled"));
|
||||||
|
if (grandChildNode)
|
||||||
|
{
|
||||||
|
TiXmlNode *valueNode = grandChildNode->FirstChild();
|
||||||
|
//putain, enfin!!!
|
||||||
|
if (valueNode)
|
||||||
|
{
|
||||||
|
generic_string locator = themeDir?themeDir:TEXT("");
|
||||||
|
|
||||||
|
locator += valueNode->Value();
|
||||||
|
_customIconVect.push_back(iconLocator(2, iIcon, locator));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool ToolBar::init( HINSTANCE hInst, HWND hPere, toolBarStatusType type,
|
bool ToolBar::init( HINSTANCE hInst, HWND hPere, toolBarStatusType type,
|
||||||
ToolBarButtonUnit *buttonUnitArray, int arraySize)
|
ToolBarButtonUnit *buttonUnitArray, int arraySize)
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,7 +43,18 @@ typedef struct {
|
||||||
HICON hIcon; // icon for toolbar
|
HICON hIcon; // icon for toolbar
|
||||||
} tDynamicList;
|
} tDynamicList;
|
||||||
|
|
||||||
|
struct iconLocator {
|
||||||
|
int listIndex;
|
||||||
|
int iconIndex;
|
||||||
|
generic_string iconLocation;
|
||||||
|
|
||||||
|
iconLocator(int iList, int iIcon, const generic_string iconLoc)
|
||||||
|
: listIndex(iList), iconIndex(iIcon), iconLocation(iconLoc){};
|
||||||
|
};
|
||||||
|
|
||||||
class ReBar;
|
class ReBar;
|
||||||
|
class TiXmlDocument;
|
||||||
|
class TiXmlNode;
|
||||||
|
|
||||||
class ToolBar : public Window
|
class ToolBar : public Window
|
||||||
{
|
{
|
||||||
|
@ -51,6 +62,7 @@ public :
|
||||||
ToolBar():Window(), _pTBB(NULL), _nrButtons(0), _nrDynButtons(0), _nrTotalButtons(0), _nrCurrentButtons(0), _pRebar(NULL) {};
|
ToolBar():Window(), _pTBB(NULL), _nrButtons(0), _nrDynButtons(0), _nrTotalButtons(0), _nrCurrentButtons(0), _pRebar(NULL) {};
|
||||||
virtual ~ToolBar(){};
|
virtual ~ToolBar(){};
|
||||||
|
|
||||||
|
void initTheme(TiXmlDocument *toolIconsDocRoot);
|
||||||
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);
|
||||||
|
|
||||||
|
@ -103,6 +115,14 @@ public :
|
||||||
return _state;
|
return _state;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool changeIcons() {
|
||||||
|
if (!_toolIcons)
|
||||||
|
return false;
|
||||||
|
for (int i = 0 ; i < int(_customIconVect.size()) ; i++)
|
||||||
|
changeIcons(_customIconVect[i].listIndex, _customIconVect[i].iconIndex, (_customIconVect[i].iconLocation).c_str());
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
bool changeIcons(int whichLst, int iconIndex, const TCHAR *iconLocation){
|
bool changeIcons(int whichLst, int iconIndex, const TCHAR *iconLocation){
|
||||||
return _toolBarIcons.replaceIcon(whichLst, iconIndex, iconLocation);
|
return _toolBarIcons.replaceIcon(whichLst, iconIndex, iconLocation);
|
||||||
};
|
};
|
||||||
|
@ -124,6 +144,8 @@ private :
|
||||||
size_t _nrCurrentButtons;
|
size_t _nrCurrentButtons;
|
||||||
ReBar * _pRebar;
|
ReBar * _pRebar;
|
||||||
REBARBANDINFO _rbBand;
|
REBARBANDINFO _rbBand;
|
||||||
|
vector<iconLocator> _customIconVect;
|
||||||
|
TiXmlNode *_toolIcons;
|
||||||
|
|
||||||
|
|
||||||
void setDefaultImageList() {
|
void setDefaultImageList() {
|
||||||
|
|
Loading…
Reference in New Issue