[BUG_FIXED] Fix crash bug while a "New 2" is in session.xml.
Clean up the toolbar code. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@155 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
92c229a57a
commit
3701d40a8f
|
@ -542,10 +542,10 @@ bool Notepad_plus::loadSession(Session & session)
|
||||||
allSessionFilesLoaded = false;
|
allSessionFilesLoaded = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (session._activeMainIndex < session.nbMainFiles())
|
if (session._activeMainIndex < _mainDocTab.nbItem())//session.nbMainFiles())
|
||||||
_mainDocTab.activate(session._activeMainIndex);
|
_mainDocTab.activate(session._activeMainIndex);
|
||||||
|
|
||||||
if (session._activeSubIndex < session.nbSubFiles())
|
if (session._activeSubIndex < _subDocTab.nbItem())//session.nbSubFiles())
|
||||||
_subDocTab.activate(session._activeSubIndex);
|
_subDocTab.activate(session._activeSubIndex);
|
||||||
|
|
||||||
if ((session.nbSubFiles() > 0) && (session._activeView == MAIN_VIEW || session._activeView == SUB_VIEW))
|
if ((session.nbSubFiles() > 0) && (session._activeView == MAIN_VIEW || session._activeView == SUB_VIEW))
|
||||||
|
@ -6010,83 +6010,67 @@ bool Notepad_plus::switchToFile(const char *fileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolBarButtonUnit toolBarIcons[] = {
|
ToolBarButtonUnit toolBarIcons[] = {
|
||||||
//{IDM_FILE_NEW, IDI_NEW_OFF_ICON, IDI_NEW_ON_ICON, IDI_NEW_OFF_ICON, STD_FILENEW},
|
{IDM_FILE_NEW, IDI_NEW_OFF_ICON, IDI_NEW_ON_ICON, IDI_NEW_OFF_ICON, IDR_FILENEW},
|
||||||
{IDM_FILE_NEW, IDI_NEW_OFF_ICON, IDI_NEW_ON_ICON, IDI_NEW_OFF_ICON, -1},
|
{IDM_FILE_OPEN, IDI_OPEN_OFF_ICON, IDI_OPEN_ON_ICON, IDI_NEW_OFF_ICON, IDR_FILEOPEN},
|
||||||
//{IDM_FILE_OPEN, IDI_OPEN_OFF_ICON, IDI_OPEN_ON_ICON, IDI_NEW_OFF_ICON, STD_FILEOPEN},
|
{IDM_FILE_SAVE, IDI_SAVE_OFF_ICON, IDI_SAVE_ON_ICON, IDI_SAVE_DISABLE_ICON, IDR_FILESAVE},
|
||||||
{IDM_FILE_OPEN, IDI_OPEN_OFF_ICON, IDI_OPEN_ON_ICON, IDI_NEW_OFF_ICON, -1},
|
{IDM_FILE_SAVEALL, IDI_SAVEALL_OFF_ICON, IDI_SAVEALL_ON_ICON, IDI_SAVEALL_DISABLE_ICON, IDR_SAVEALL},
|
||||||
//{IDM_FILE_SAVE, IDI_SAVE_OFF_ICON, IDI_SAVE_ON_ICON, IDI_SAVE_DISABLE_ICON, STD_FILESAVE},
|
{IDM_FILE_CLOSE, IDI_CLOSE_OFF_ICON, IDI_CLOSE_ON_ICON, IDI_CLOSE_OFF_ICON, IDR_CLOSEFILE},
|
||||||
{IDM_FILE_SAVE, IDI_SAVE_OFF_ICON, IDI_SAVE_ON_ICON, IDI_SAVE_DISABLE_ICON, -1},
|
{IDM_FILE_CLOSEALL, IDI_CLOSEALL_OFF_ICON, IDI_CLOSEALL_ON_ICON, IDI_CLOSEALL_OFF_ICON, IDR_CLOSEALL},
|
||||||
{IDM_FILE_SAVEALL, IDI_SAVEALL_OFF_ICON, IDI_SAVEALL_ON_ICON, IDI_SAVEALL_DISABLE_ICON, -1},
|
{IDM_FILE_PRINTNOW, IDI_PRINT_OFF_ICON, IDI_PRINT_ON_ICON, IDI_PRINT_OFF_ICON, IDR_PRINT},
|
||||||
{IDM_FILE_CLOSE, IDI_CLOSE_OFF_ICON, IDI_CLOSE_ON_ICON, IDI_CLOSE_OFF_ICON, -1},
|
|
||||||
{IDM_FILE_CLOSEALL, IDI_CLOSEALL_OFF_ICON, IDI_CLOSEALL_ON_ICON, IDI_CLOSEALL_OFF_ICON, -1},
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------------------//
|
||||||
{0, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON},
|
{0, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON},
|
||||||
//-------------------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
//{IDM_EDIT_CUT, IDI_CUT_OFF_ICON, IDI_CUT_ON_ICON, IDI_CUT_DISABLE_ICON, STD_CUT},
|
{IDM_EDIT_CUT, IDI_CUT_OFF_ICON, IDI_CUT_ON_ICON, IDI_CUT_DISABLE_ICON, IDR_CUT},
|
||||||
//{IDM_EDIT_COPY, IDI_COPY_OFF_ICON, IDI_COPY_ON_ICON, IDI_COPY_DISABLE_ICON, STD_COPY},
|
{IDM_EDIT_COPY, IDI_COPY_OFF_ICON, IDI_COPY_ON_ICON, IDI_COPY_DISABLE_ICON, IDR_COPY},
|
||||||
//{IDM_EDIT_PASTE, IDI_PASTE_OFF_ICON, IDI_PASTE_ON_ICON, IDI_PASTE_DISABLE_ICON, STD_PASTE},
|
{IDM_EDIT_PASTE, IDI_PASTE_OFF_ICON, IDI_PASTE_ON_ICON, IDI_PASTE_DISABLE_ICON, IDR_PASTE},
|
||||||
{IDM_EDIT_CUT, IDI_CUT_OFF_ICON, IDI_CUT_ON_ICON, IDI_CUT_DISABLE_ICON, -1},
|
|
||||||
{IDM_EDIT_COPY, IDI_COPY_OFF_ICON, IDI_COPY_ON_ICON, IDI_COPY_DISABLE_ICON, -1},
|
|
||||||
{IDM_EDIT_PASTE, IDI_PASTE_OFF_ICON, IDI_PASTE_ON_ICON, IDI_PASTE_DISABLE_ICON, -1},
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------------------//
|
||||||
{0, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON},
|
{0, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON},
|
||||||
//-------------------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
//{IDM_EDIT_UNDO, IDI_UNDO_OFF_ICON, IDI_UNDO_ON_ICON, IDI_UNDO_DISABLE_ICON, STD_UNDO},
|
{IDM_EDIT_UNDO, IDI_UNDO_OFF_ICON, IDI_UNDO_ON_ICON, IDI_UNDO_DISABLE_ICON, IDR_UNDO},
|
||||||
//{IDM_EDIT_REDO, IDI_REDO_OFF_ICON, IDI_REDO_ON_ICON, IDI_REDO_DISABLE_ICON, STD_REDOW},
|
{IDM_EDIT_REDO, IDI_REDO_OFF_ICON, IDI_REDO_ON_ICON, IDI_REDO_DISABLE_ICON, IDR_REDO},
|
||||||
{IDM_EDIT_UNDO, IDI_UNDO_OFF_ICON, IDI_UNDO_ON_ICON, IDI_UNDO_DISABLE_ICON, -1},
|
|
||||||
{IDM_EDIT_REDO, IDI_REDO_OFF_ICON, IDI_REDO_ON_ICON, IDI_REDO_DISABLE_ICON, -1},
|
|
||||||
//-------------------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------------------//
|
||||||
{0, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON},
|
{0, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON},
|
||||||
//-------------------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
{IDM_SEARCH_FIND, IDI_FIND_OFF_ICON, IDI_FIND_ON_ICON, IDI_FIND_OFF_ICON, -1},
|
{IDM_SEARCH_FIND, IDI_FIND_OFF_ICON, IDI_FIND_ON_ICON, IDI_FIND_OFF_ICON, IDR_FIND},
|
||||||
{IDM_SEARCH_REPLACE, IDI_REPLACE_OFF_ICON, IDI_REPLACE_ON_ICON, IDI_REPLACE_OFF_ICON, -1},
|
{IDM_SEARCH_REPLACE, IDI_REPLACE_OFF_ICON, IDI_REPLACE_ON_ICON, IDI_REPLACE_OFF_ICON, IDR_REPLACE},
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------------------//
|
||||||
{0, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON},
|
{0, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON},
|
||||||
//-------------------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------------------//
|
||||||
{IDM_VIEW_ZOOMIN, IDI_ZOOMIN_OFF_ICON, IDI_ZOOMIN_ON_ICON, IDI_ZOOMIN_OFF_ICON, -1},
|
{IDM_VIEW_ZOOMIN, IDI_ZOOMIN_OFF_ICON, IDI_ZOOMIN_ON_ICON, IDI_ZOOMIN_OFF_ICON, IDR_ZOOMIN},
|
||||||
{IDM_VIEW_ZOOMOUT, IDI_ZOOMOUT_OFF_ICON, IDI_ZOOMOUT_ON_ICON, IDI_ZOOMOUT_OFF_ICON, -1},
|
{IDM_VIEW_ZOOMOUT, IDI_ZOOMOUT_OFF_ICON, IDI_ZOOMOUT_ON_ICON, IDI_ZOOMOUT_OFF_ICON, IDR_ZOOMOUT},
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------------------//
|
||||||
{0, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON},
|
{0, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON},
|
||||||
//-------------------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------------------//
|
||||||
{IDM_VIEW_SYNSCROLLV, IDI_SYNCV_OFF_ICON, IDI_SYNCV_ON_ICON, IDI_SYNCV_DISABLE_ICON, -1},
|
{IDM_VIEW_SYNSCROLLV, IDI_SYNCV_OFF_ICON, IDI_SYNCV_ON_ICON, IDI_SYNCV_DISABLE_ICON, IDR_SYNCV},
|
||||||
{IDM_VIEW_SYNSCROLLH, IDI_SYNCH_OFF_ICON, IDI_SYNCH_ON_ICON, IDI_SYNCH_DISABLE_ICON, -1},
|
{IDM_VIEW_SYNSCROLLH, IDI_SYNCH_OFF_ICON, IDI_SYNCH_ON_ICON, IDI_SYNCH_DISABLE_ICON, IDR_SYNCH},
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------------------//
|
||||||
{0, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON},
|
{0, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON},
|
||||||
//-------------------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------------------//
|
||||||
{IDM_VIEW_WRAP, IDI_VIEW_WRAP_OFF_ICON, IDI_VIEW_WRAP_ON_ICON, IDI_VIEW_WRAP_OFF_ICON, -1},
|
{IDM_VIEW_WRAP, IDI_VIEW_WRAP_OFF_ICON, IDI_VIEW_WRAP_ON_ICON, IDI_VIEW_WRAP_OFF_ICON, IDR_WRAP},
|
||||||
{IDM_VIEW_ALL_CHARACTERS, IDI_VIEW_ALL_CHAR_OFF_ICON, IDI_VIEW_ALL_CHAR_ON_ICON, IDI_VIEW_ALL_CHAR_OFF_ICON, -1},
|
{IDM_VIEW_ALL_CHARACTERS, IDI_VIEW_ALL_CHAR_OFF_ICON, IDI_VIEW_ALL_CHAR_ON_ICON, IDI_VIEW_ALL_CHAR_OFF_ICON, IDR_INVISIBLECHAR},
|
||||||
{IDM_VIEW_INDENT_GUIDE, IDI_VIEW_INDENT_OFF_ICON, IDI_VIEW_INDENT_ON_ICON, IDI_VIEW_INDENT_OFF_ICON, -1},
|
{IDM_VIEW_INDENT_GUIDE, IDI_VIEW_INDENT_OFF_ICON, IDI_VIEW_INDENT_ON_ICON, IDI_VIEW_INDENT_OFF_ICON, IDR_INDENTGUIDE},
|
||||||
{IDM_VIEW_USER_DLG, IDI_VIEW_UD_DLG_OFF_ICON, IDI_VIEW_UD_DLG_ON_ICON, IDI_VIEW_UD_DLG_OFF_ICON, -1},
|
{IDM_VIEW_USER_DLG, IDI_VIEW_UD_DLG_OFF_ICON, IDI_VIEW_UD_DLG_ON_ICON, IDI_VIEW_UD_DLG_OFF_ICON, IDR_SHOWPANNEL},
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------------------//
|
||||||
{0, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON},
|
{0, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON},
|
||||||
//-------------------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
{IDM_MACRO_STARTRECORDINGMACRO, IDI_STARTRECORD_OFF_ICON, IDI_STARTRECORD_ON_ICON, IDI_STARTRECORD_DISABLE_ICON, -1},
|
{IDM_MACRO_STARTRECORDINGMACRO, IDI_STARTRECORD_OFF_ICON, IDI_STARTRECORD_ON_ICON, IDI_STARTRECORD_DISABLE_ICON, IDR_STARTRECORD},
|
||||||
{IDM_MACRO_STOPRECORDINGMACRO, IDI_STOPRECORD_OFF_ICON, IDI_STOPRECORD_ON_ICON, IDI_STOPRECORD_DISABLE_ICON, -1},
|
{IDM_MACRO_STOPRECORDINGMACRO, IDI_STOPRECORD_OFF_ICON, IDI_STOPRECORD_ON_ICON, IDI_STOPRECORD_DISABLE_ICON, IDR_STOPRECORD},
|
||||||
{IDM_MACRO_PLAYBACKRECORDEDMACRO, IDI_PLAYRECORD_OFF_ICON, IDI_PLAYRECORD_ON_ICON, IDI_PLAYRECORD_DISABLE_ICON, -1},
|
{IDM_MACRO_PLAYBACKRECORDEDMACRO, IDI_PLAYRECORD_OFF_ICON, IDI_PLAYRECORD_ON_ICON, IDI_PLAYRECORD_DISABLE_ICON, IDR_PLAYRECORD},
|
||||||
{IDM_MACRO_RUNMULTIMACRODLG, IDI_MMPLAY_OFF_ICON, IDI_MMPLAY_ON_ICON, IDI_MMPLAY_DIS_ICON, -1},
|
{IDM_MACRO_RUNMULTIMACRODLG, IDI_MMPLAY_OFF_ICON, IDI_MMPLAY_ON_ICON, IDI_MMPLAY_DIS_ICON, IDR_M_PLAYRECORD},
|
||||||
{IDM_MACRO_SAVECURRENTMACRO, IDI_SAVERECORD_OFF_ICON, IDI_SAVERECORD_ON_ICON, IDI_SAVERECORD_DISABLE_ICON, -1},
|
{IDM_MACRO_SAVECURRENTMACRO, IDI_SAVERECORD_OFF_ICON, IDI_SAVERECORD_ON_ICON, IDI_SAVERECORD_DISABLE_ICON, IDR_SAVERECORD}
|
||||||
//-------------------------------------------------------------------------------------//
|
|
||||||
{0, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON, IDI_SEPARATOR_ICON},
|
|
||||||
//-------------------------------------------------------------------------------------//
|
|
||||||
|
|
||||||
//{IDM_FILE_PRINTNOW, IDI_PRINT_OFF_ICON, IDI_PRINT_ON_ICON, IDI_PRINT_OFF_ICON, STD_PRINT}
|
|
||||||
{IDM_FILE_PRINTNOW, IDI_PRINT_OFF_ICON, IDI_PRINT_ON_ICON, IDI_PRINT_OFF_ICON, -1}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int stdIcons[] = {IDR_FILENEW, IDR_FILEOPEN, IDR_FILESAVE, IDR_SAVEALL, IDR_CLOSEFILE, IDR_CLOSEALL, IDR_CUT, IDR_COPY, IDR_PASTE,\
|
|
||||||
IDR_UNDO, IDR_REDO, IDR_FIND, IDR_REPLACE, IDR_ZOOMIN, IDR_ZOOMOUT, IDR_SYNCV, IDR_SYNCH,\
|
|
||||||
IDR_WRAP, IDR_INVISIBLECHAR, IDR_INDENTGUIDE, IDR_SHOWPANNEL, IDR_STARTRECORD, IDR_STOPRECORD, IDR_PLAYRECORD, IDR_M_PLAYRECORD, IDR_SAVERECORD, IDR_PRINT};
|
|
||||||
|
|
||||||
void Notepad_plus::getTaskListInfo(TaskListInfo *tli)
|
void Notepad_plus::getTaskListInfo(TaskListInfo *tli)
|
||||||
{
|
{
|
||||||
int iView = getCurrentView();
|
int iView = getCurrentView();
|
||||||
|
@ -6587,13 +6571,14 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
||||||
menuID = IDM_VIEW_TOOLBAR_STANDARD;
|
menuID = IDM_VIEW_TOOLBAR_STANDARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
_toolBar.init(_hInst, hwnd, iconSize, toolBarIcons, sizeof(toolBarIcons)/sizeof(ToolBarButtonUnit), (tbStatus == TB_STANDARD), stdIcons, sizeof(stdIcons)/sizeof(int));
|
|
||||||
|
_toolBar.init(_hInst, hwnd, tbStatus, toolBarIcons, sizeof(toolBarIcons)/sizeof(ToolBarButtonUnit));
|
||||||
_toolBar.display(willBeShown);
|
_toolBar.display(willBeShown);
|
||||||
checkToolBarMenu(menuID);
|
checkToolBarMenu(menuID);
|
||||||
changeToolBarIcons();
|
changeToolBarIcons();
|
||||||
|
|
||||||
_rebar.init(_hInst, hwnd, &_toolBar);
|
_rebar.init(_hInst, hwnd, &_toolBar);
|
||||||
_rebar.display(tbStatus != TB_HIDE);
|
//_rebar.display(tbStatus != TB_HIDE);
|
||||||
|
|
||||||
//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;
|
||||||
|
@ -6805,10 +6790,11 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
{
|
{
|
||||||
RECT rc;
|
RECT rc;
|
||||||
getToolBarClientRect(rc);
|
//getToolBarClientRect(rc);
|
||||||
_toolBar.reSizeTo(rc);
|
//_toolBar.reSizeTo(rc);
|
||||||
|
|
||||||
::SetWindowPos(_rebar.getHSelf(), NULL, 0, 0, LOWORD(lParam), rc.bottom - rc.top, SWP_NOZORDER);
|
::MoveWindow(_toolBar.getHSelf(), 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
|
||||||
|
::MoveWindow(_rebar.getHSelf(), 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
|
||||||
|
|
||||||
getStatusBarClientRect(rc);
|
getStatusBarClientRect(rc);
|
||||||
_statusBar.reSizeTo(rc);
|
_statusBar.reSizeTo(rc);
|
||||||
|
@ -8450,3 +8436,4 @@ winVer getWindowsVersion()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ void ToolBarIcons::init(ToolBarButtonUnit *buttonUnitArray, int arraySize)
|
||||||
{
|
{
|
||||||
for (int i = 0 ; i < arraySize ; i++)
|
for (int i = 0 ; i < arraySize ; i++)
|
||||||
_tbiis.push_back(buttonUnitArray[i]);
|
_tbiis.push_back(buttonUnitArray[i]);
|
||||||
|
_nbCmd = arraySize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolBarIcons::create(HINSTANCE hInst, int iconSize)
|
void ToolBarIcons::create(HINSTANCE hInst, int iconSize)
|
||||||
|
@ -36,17 +37,7 @@ void ToolBarIcons::create(HINSTANCE hInst, int iconSize)
|
||||||
_iconListVector[HLIST_DISABLE].create(hInst, iconSize);
|
_iconListVector[HLIST_DISABLE].create(hInst, iconSize);
|
||||||
//_iconListVector[HLIST_UGLY].create(hInst, 16);
|
//_iconListVector[HLIST_UGLY].create(hInst, 16);
|
||||||
|
|
||||||
for (size_t i = 0 ; i < _tbiis.size() ; i++)
|
reInit(iconSize);
|
||||||
{
|
|
||||||
_cmdArray[_nbCmd++] = _tbiis[i]._cmdID;
|
|
||||||
if (_tbiis[i]._defaultIcon != IDI_SEPARATOR_ICON)
|
|
||||||
{
|
|
||||||
_iconListVector[HLIST_DEFAULT].addIcon(_tbiis[i]._defaultIcon);
|
|
||||||
_iconListVector[HLIST_HOT].addIcon(_tbiis[i]._hotIcon);
|
|
||||||
_iconListVector[HLIST_DISABLE].addIcon(_tbiis[i]._grayIcon);
|
|
||||||
//_iconListVector[HLIST_UGLY].addImage(_tbiis[i]._uglyIcon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolBarIcons::destroy()
|
void ToolBarIcons::destroy()
|
||||||
|
@ -68,3 +59,4 @@ bool IconList::changeIcon(int index, const char *iconLocation) const
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,10 @@ class IconList
|
||||||
public :
|
public :
|
||||||
IconList() : _hImglst(NULL) {};
|
IconList() : _hImglst(NULL) {};
|
||||||
|
|
||||||
void create(HINSTANCE hInst, int iconSize) {_iconSize = iconSize;
|
void create(HINSTANCE hInst, int iconSize) {
|
||||||
|
InitCommonControls();
|
||||||
_hInst = hInst;
|
_hInst = hInst;
|
||||||
InitCommonControls();
|
_iconSize = iconSize;
|
||||||
_hImglst = ImageList_Create(iconSize, iconSize, ILC_COLOR32 | ILC_MASK, 0, nbMax);
|
_hImglst = ImageList_Create(iconSize, iconSize, ILC_COLOR32 | ILC_MASK, 0, nbMax);
|
||||||
if (!_hImglst)
|
if (!_hImglst)
|
||||||
throw int(25);
|
throw int(25);
|
||||||
|
@ -59,7 +60,7 @@ public :
|
||||||
if (!hIcon)
|
if (!hIcon)
|
||||||
throw int(26);
|
throw int(26);
|
||||||
ImageList_AddIcon(_hImglst, hIcon);
|
ImageList_AddIcon(_hImglst, hIcon);
|
||||||
//ImageList_AddMasked(_hImglst, (HBITMAP)hBmp, RGB(0, 0, 0));
|
//ImageList_AddMasked(_hImglst, hBmp, RGB(0, 0, 0));
|
||||||
::DeleteObject(hIcon);
|
::DeleteObject(hIcon);
|
||||||
//::DeleteObject(hBmp);
|
//::DeleteObject(hBmp);
|
||||||
};
|
};
|
||||||
|
@ -112,7 +113,7 @@ typedef struct
|
||||||
int _hotIcon;
|
int _hotIcon;
|
||||||
int _grayIcon;
|
int _grayIcon;
|
||||||
|
|
||||||
int _uglyIcon;
|
int _stdIcon;
|
||||||
}ToolBarButtonUnit;
|
}ToolBarButtonUnit;
|
||||||
|
|
||||||
typedef std::vector<ToolBarButtonUnit> ToolBarIconIDs;
|
typedef std::vector<ToolBarButtonUnit> ToolBarIconIDs;
|
||||||
|
@ -183,8 +184,8 @@ public :
|
||||||
return int(_tbiis.size());
|
return int(_tbiis.size());
|
||||||
};
|
};
|
||||||
|
|
||||||
int getUglyIconAt(int i) const {
|
int getStdIconAt(int i) const {
|
||||||
return _tbiis[i]._uglyIcon;
|
return _tbiis[i]._stdIcon;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool replaceIcon(int witchList, int iconIndex, const char *iconLocation) const {
|
bool replaceIcon(int witchList, int iconIndex, const char *iconLocation) const {
|
||||||
|
|
|
@ -19,18 +19,18 @@
|
||||||
#include "ToolBar.h"
|
#include "ToolBar.h"
|
||||||
#include "SysMsg.h"
|
#include "SysMsg.h"
|
||||||
|
|
||||||
const bool ToolBar::REDUCED = true;
|
const int WS_TOOLBARSTYLE = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | TBSTYLE_TOOLTIPS |TBSTYLE_FLAT | CCS_TOP | BTNS_AUTOSIZE | CCS_NOPARENTALIGN | CCS_NORESIZE;
|
||||||
const bool ToolBar::ENLARGED = false;
|
|
||||||
const int WS_TOOLBARSTYLE = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | TBSTYLE_TOOLTIPS |TBSTYLE_FLAT | CCS_TOP | BTNS_AUTOSIZE;
|
|
||||||
|
|
||||||
bool ToolBar::init(HINSTANCE hInst, HWND hPere, int iconSize,
|
bool ToolBar::init( HINSTANCE hInst, HWND hPere, toolBarStatusType type,
|
||||||
ToolBarButtonUnit *buttonUnitArray, int arraySize,
|
ToolBarButtonUnit *buttonUnitArray, int arraySize)
|
||||||
bool doUglyStandardIcon, int *bmpArray, int bmpArraySize)
|
|
||||||
{
|
{
|
||||||
Window::init(hInst, hPere);
|
Window::init(hInst, hPere);
|
||||||
_state = doUglyStandardIcon?TB_STANDARD:(iconSize >= 32?TB_LARGE:TB_SMALL);
|
if (type == TB_HIDE) {
|
||||||
_bmpArray = bmpArray;
|
setState(TB_STANDARD); //assume standard
|
||||||
_bmpArraySize = bmpArraySize;
|
_visible = false; //but set visibility to false
|
||||||
|
}
|
||||||
|
_state = type;
|
||||||
|
int iconSize = (_state == TB_LARGE?32:16);
|
||||||
|
|
||||||
_toolBarIcons.init(buttonUnitArray, arraySize);
|
_toolBarIcons.init(buttonUnitArray, arraySize);
|
||||||
_toolBarIcons.create(_hInst, iconSize);
|
_toolBarIcons.create(_hInst, iconSize);
|
||||||
|
@ -40,17 +40,106 @@ bool ToolBar::init(HINSTANCE hInst, HWND hPere, int iconSize,
|
||||||
icex.dwICC = ICC_WIN95_CLASSES|ICC_COOL_CLASSES|ICC_BAR_CLASSES|ICC_USEREX_CLASSES;
|
icex.dwICC = ICC_WIN95_CLASSES|ICC_COOL_CLASSES|ICC_BAR_CLASSES|ICC_USEREX_CLASSES;
|
||||||
InitCommonControlsEx(&icex);
|
InitCommonControlsEx(&icex);
|
||||||
|
|
||||||
_hSelf = ::CreateWindowEx(
|
//Create the list of buttons
|
||||||
WS_EX_PALETTEWINDOW ,
|
_nrButtons = arraySize;
|
||||||
TOOLBARCLASSNAME,
|
_nrDynButtons = _vDynBtnReg.size();
|
||||||
"",
|
_nrTotalButtons = _nrButtons + (_nrDynButtons ? _nrDynButtons + 1 : 0);
|
||||||
WS_TOOLBARSTYLE,
|
_pTBB = new TBBUTTON[_nrTotalButtons]; //add one for the extra separator
|
||||||
0, 0,
|
|
||||||
0, 0,
|
int cmd = 0;
|
||||||
_hParent,
|
int bmpIndex = -1, style;
|
||||||
NULL,
|
size_t i = 0;
|
||||||
_hInst,
|
for (; i < _nrButtons ; i++)
|
||||||
0);
|
{
|
||||||
|
cmd = buttonUnitArray[i]._cmdID;
|
||||||
|
if (cmd != 0)
|
||||||
|
{
|
||||||
|
bmpIndex++;
|
||||||
|
style = BTNS_BUTTON;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
style = BTNS_SEP;
|
||||||
|
}
|
||||||
|
|
||||||
|
_pTBB[i].iBitmap = (cmd != 0?bmpIndex:0);
|
||||||
|
_pTBB[i].idCommand = cmd;
|
||||||
|
_pTBB[i].fsState = TBSTATE_ENABLED;
|
||||||
|
_pTBB[i].fsStyle = style;
|
||||||
|
_pTBB[i].dwData = 0;
|
||||||
|
_pTBB[i].iString = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_nrDynButtons > 0) {
|
||||||
|
//add separator
|
||||||
|
_pTBB[i].iBitmap = 0;
|
||||||
|
_pTBB[i].idCommand = 0;
|
||||||
|
_pTBB[i].fsState = TBSTATE_ENABLED;
|
||||||
|
_pTBB[i].fsStyle = BTNS_SEP;
|
||||||
|
_pTBB[i].dwData = 0;
|
||||||
|
_pTBB[i].iString = 0;
|
||||||
|
i++;
|
||||||
|
//add plugin buttons
|
||||||
|
for (size_t j = 0; j < _nrDynButtons ; j++, i++)
|
||||||
|
{
|
||||||
|
cmd = _vDynBtnReg[j].message;
|
||||||
|
bmpIndex++;
|
||||||
|
|
||||||
|
_pTBB[i].iBitmap = bmpIndex;
|
||||||
|
_pTBB[i].idCommand = cmd;
|
||||||
|
_pTBB[i].fsState = TBSTATE_ENABLED;
|
||||||
|
_pTBB[i].fsStyle = BTNS_BUTTON;
|
||||||
|
_pTBB[i].dwData = 0;
|
||||||
|
_pTBB[i].iString = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
reset(true); //load icons etc
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ToolBar::getWidth() const {
|
||||||
|
RECT btnRect;
|
||||||
|
int totalWidth = 0;
|
||||||
|
for(size_t i = 0; i < _nrCurrentButtons; i++) {
|
||||||
|
::SendMessage(_hSelf, TB_GETITEMRECT, i, (LPARAM)&btnRect);
|
||||||
|
totalWidth += btnRect.right - btnRect.left;
|
||||||
|
}
|
||||||
|
return totalWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolBar::reset(bool create)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(create && _hSelf) {
|
||||||
|
//Store current button state information
|
||||||
|
TBBUTTON tempBtn;
|
||||||
|
for(size_t i = 0; i < _nrCurrentButtons; i++) {
|
||||||
|
::SendMessage(_hSelf, TB_GETBUTTON, (WPARAM)i, (LPARAM)&tempBtn);
|
||||||
|
_pTBB[i].fsState = tempBtn.fsState;
|
||||||
|
}
|
||||||
|
::DestroyWindow(_hSelf);
|
||||||
|
_hSelf = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!_hSelf) {
|
||||||
|
_hSelf = ::CreateWindowEx(
|
||||||
|
WS_EX_PALETTEWINDOW,
|
||||||
|
TOOLBARCLASSNAME,
|
||||||
|
"",
|
||||||
|
WS_TOOLBARSTYLE,
|
||||||
|
0, 0,
|
||||||
|
0, 0,
|
||||||
|
_hParent,
|
||||||
|
NULL,
|
||||||
|
_hInst,
|
||||||
|
0);
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
|
||||||
if (!_hSelf)
|
if (!_hSelf)
|
||||||
{
|
{
|
||||||
|
@ -58,266 +147,42 @@ bool ToolBar::init(HINSTANCE hInst, HWND hPere, int iconSize,
|
||||||
throw int(9);
|
throw int(9);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the TB_BUTTONSTRUCTSIZE message, which is required for
|
if (_state != TB_STANDARD)
|
||||||
// backward compatibility.
|
|
||||||
::SendMessage(_hSelf, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
|
|
||||||
|
|
||||||
if (!doUglyStandardIcon)
|
|
||||||
{
|
{
|
||||||
|
//If non standard icons, use custom imagelists
|
||||||
setDefaultImageList();
|
setDefaultImageList();
|
||||||
setHotImageList();
|
setHotImageList();
|
||||||
setDisableImageList();
|
setDisableImageList();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
::SendMessage(_hSelf, TB_LOADIMAGES, IDB_STD_SMALL_COLOR, reinterpret_cast<LPARAM>(HINST_COMMCTRL));
|
//Else set the internal imagelist with standard bitmaps
|
||||||
|
|
||||||
if (bmpArray)
|
|
||||||
{
|
|
||||||
TBADDBITMAP addbmp = {_hInst, 0};
|
|
||||||
for (int i = 0 ; i < _bmpArraySize ; i++)
|
|
||||||
{
|
|
||||||
if ((i == _bmpArraySize - 1) && (_vDynBtnReg.size() != 0))
|
|
||||||
{
|
|
||||||
TBADDBITMAP addbmpdyn = {0, 0};
|
|
||||||
for (size_t j = 0; j < _vDynBtnReg.size(); j++)
|
|
||||||
{
|
|
||||||
addbmpdyn.nID = (INT_PTR)_vDynBtnReg[j].hBmp;
|
|
||||||
::SendMessage(_hSelf, TB_ADDBITMAP, 1, (LPARAM)&addbmpdyn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
addbmp.nID = _bmpArray[i];
|
|
||||||
::SendMessage(_hSelf, TB_ADDBITMAP, 1, (LPARAM)&addbmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
_pTBB = new TBBUTTON[_toolBarIcons.getNbCommand() + (_vDynBtnReg.size() ? _vDynBtnReg.size() + 1 : 0)];
|
|
||||||
unsigned int nbElement = _toolBarIcons.getNbCommand();
|
|
||||||
unsigned int nbDynIncPos = nbElement;
|
|
||||||
|
|
||||||
if (doUglyStandardIcon)
|
|
||||||
{
|
|
||||||
nbDynIncPos -= 2;
|
|
||||||
nbElement += (_vDynBtnReg.size() ? _vDynBtnReg.size() + 1 : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int inc = 1;
|
|
||||||
|
|
||||||
for (size_t i = 0, j = 0, k = 0; i < nbElement; i++)
|
|
||||||
{
|
|
||||||
int cmd = 0;
|
|
||||||
int bmpIndex, style;
|
|
||||||
|
|
||||||
if ((i > nbDynIncPos) && (_vDynBtnReg.size() != 0) && (j <= _vDynBtnReg.size()))
|
|
||||||
{
|
|
||||||
if (j < _vDynBtnReg.size())
|
|
||||||
{
|
|
||||||
cmd = _vDynBtnReg[j].message;
|
|
||||||
bmpIndex = (STD_PRINT + (inc++));
|
|
||||||
style = BTNS_BUTTON;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bmpIndex = 0;
|
|
||||||
style = BTNS_SEP;
|
|
||||||
}
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ((cmd = _toolBarIcons.getCommandAt(i - j)) != 0)
|
|
||||||
{
|
|
||||||
if (doUglyStandardIcon)
|
|
||||||
{
|
|
||||||
int ibmp = _toolBarIcons.getUglyIconAt(i - j);
|
|
||||||
bmpIndex = (ibmp == -1)?(STD_PRINT + (inc++)):ibmp;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
bmpIndex = k++;
|
|
||||||
|
|
||||||
style = BTNS_BUTTON;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bmpIndex = 0;
|
|
||||||
style = BTNS_SEP;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_pTBB[i].iBitmap = bmpIndex;
|
|
||||||
_pTBB[i].idCommand = cmd;
|
|
||||||
_pTBB[i].fsState = TBSTATE_ENABLED;
|
|
||||||
_pTBB[i].fsStyle = style;
|
|
||||||
_pTBB[i].dwData = 0;
|
|
||||||
_pTBB[i].iString = 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
setButtonSize(iconSize, iconSize);
|
|
||||||
|
|
||||||
::SendMessage(_hSelf, TB_ADDBUTTONS, (WPARAM)nbElement, (LPARAM)_pTBB);
|
|
||||||
::SendMessage(_hSelf, TB_AUTOSIZE, 0, 0);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ToolBar::reset()
|
|
||||||
{
|
|
||||||
setDefaultImageList();
|
|
||||||
setHotImageList();
|
|
||||||
setDisableImageList();
|
|
||||||
|
|
||||||
if (_state == TB_STANDARD)
|
|
||||||
{
|
|
||||||
int cmdElement = _toolBarIcons.getNbCommand();
|
|
||||||
int nbElement = cmdElement + (_vDynBtnReg.size() ? _vDynBtnReg.size() + 1 : 0);
|
|
||||||
|
|
||||||
for (int i = 0, j = 0, k = nbElement-1 ; i < nbElement ; i++, k--)
|
|
||||||
{
|
|
||||||
int cmd = 0;
|
|
||||||
int bmpIndex, style;
|
|
||||||
|
|
||||||
::SendMessage(_hSelf, TB_DELETEBUTTON, k, 0);
|
|
||||||
|
|
||||||
if (i >= cmdElement)
|
|
||||||
{
|
|
||||||
bmpIndex = -1;
|
|
||||||
cmd = 0;
|
|
||||||
style = 0;
|
|
||||||
}
|
|
||||||
else if ((cmd = _toolBarIcons.getCommandAt(i)) != 0)
|
|
||||||
{
|
|
||||||
bmpIndex = j++;
|
|
||||||
style = BTNS_BUTTON;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bmpIndex = 0;
|
|
||||||
style = BTNS_SEP;
|
|
||||||
}
|
|
||||||
_pTBB[i].iBitmap = bmpIndex;
|
|
||||||
_pTBB[i].idCommand = cmd;
|
|
||||||
_pTBB[i].fsState = TBSTATE_ENABLED;
|
|
||||||
_pTBB[i].fsStyle = style;
|
|
||||||
_pTBB[i].dwData = 0;
|
|
||||||
_pTBB[i].iString = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
::SendMessage(_hSelf, TB_ADDBUTTONS, (WPARAM)nbElement, (LPARAM)_pTBB);
|
|
||||||
}
|
|
||||||
|
|
||||||
::SendMessage(_hSelf, TB_AUTOSIZE, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ToolBar::setToUglyIcons()
|
|
||||||
{
|
|
||||||
if (_state == TB_STANDARD)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Due to the drawback of toolbar control (in-coexistence of Imagelist - custom icons and Bitmap - Std icons),
|
|
||||||
// We have to destroy the control then re-initialize it
|
|
||||||
::DestroyWindow(_hSelf);
|
|
||||||
|
|
||||||
//_state = REDUCED;
|
|
||||||
|
|
||||||
_hSelf = ::CreateWindowEx(
|
|
||||||
WS_EX_PALETTEWINDOW ,
|
|
||||||
TOOLBARCLASSNAME,
|
|
||||||
"",
|
|
||||||
WS_TOOLBARSTYLE,
|
|
||||||
0, 0,
|
|
||||||
0, 0,
|
|
||||||
_hParent,
|
|
||||||
NULL,
|
|
||||||
_hInst,
|
|
||||||
0);
|
|
||||||
|
|
||||||
if (!_hSelf)
|
|
||||||
{
|
|
||||||
systemMessage("System Err");
|
|
||||||
throw int(9);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send the TB_BUTTONSTRUCTSIZE message, which is required for
|
|
||||||
// backward compatibility.
|
|
||||||
::SendMessage(_hSelf, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
|
|
||||||
|
|
||||||
::SendMessage(_hSelf, TB_LOADIMAGES, IDB_STD_SMALL_COLOR, reinterpret_cast<LPARAM>(HINST_COMMCTRL));
|
|
||||||
|
|
||||||
if (_bmpArray)
|
|
||||||
{
|
|
||||||
TBADDBITMAP addbmp = {_hInst, 0};
|
TBADDBITMAP addbmp = {_hInst, 0};
|
||||||
for (int i = 0 ; i < _bmpArraySize ; i++)
|
TBADDBITMAP addbmpdyn = {0, 0};
|
||||||
|
for (size_t i = 0 ; i < _nrButtons ; i++)
|
||||||
{
|
{
|
||||||
if ((i == _bmpArraySize - 1) && (_vDynBtnReg.size() != 0))
|
addbmp.nID = _toolBarIcons.getStdIconAt(i);
|
||||||
{
|
|
||||||
TBADDBITMAP addbmpdyn = {0, 0};
|
|
||||||
for (size_t j = 0; j < _vDynBtnReg.size(); j++)
|
|
||||||
{
|
|
||||||
addbmpdyn.nID = (INT_PTR)_vDynBtnReg[j].hBmp;
|
|
||||||
::SendMessage(_hSelf, TB_ADDBITMAP, 1, (LPARAM)&addbmpdyn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
addbmp.nID = _bmpArray[i];
|
|
||||||
::SendMessage(_hSelf, TB_ADDBITMAP, 1, (LPARAM)&addbmp);
|
::SendMessage(_hSelf, TB_ADDBITMAP, 1, (LPARAM)&addbmp);
|
||||||
}
|
}
|
||||||
}
|
if (_nrDynButtons > 0) {
|
||||||
|
for (size_t j = 0; j < _nrDynButtons; j++)
|
||||||
unsigned int nbElement = _toolBarIcons.getNbCommand() + (_vDynBtnReg.size() ? _vDynBtnReg.size() + 1 : 0);
|
|
||||||
unsigned int nbDynIncPos = _toolBarIcons.getNbCommand() - 2;
|
|
||||||
int inc = 1;
|
|
||||||
|
|
||||||
for (size_t i = 0, j = 0 ; i < nbElement ; i++)
|
|
||||||
{
|
|
||||||
int cmd = 0;
|
|
||||||
int bmpIndex, style;
|
|
||||||
|
|
||||||
if ((i > nbDynIncPos) && (_vDynBtnReg.size() != 0) && (j <= _vDynBtnReg.size()))
|
|
||||||
{
|
|
||||||
if (j < _vDynBtnReg.size())
|
|
||||||
{
|
{
|
||||||
cmd = _vDynBtnReg[j].message;
|
addbmpdyn.nID = (UINT_PTR)_vDynBtnReg.at(j).hBmp;
|
||||||
bmpIndex = (STD_PRINT + (inc++));
|
::SendMessage(_hSelf, TB_ADDBITMAP, 1, (LPARAM)&addbmpdyn);
|
||||||
style = BTNS_BUTTON;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bmpIndex = 0;
|
|
||||||
style = BTNS_SEP;
|
|
||||||
}
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ((cmd = _toolBarIcons.getCommandAt(i - j)) != 0)
|
|
||||||
{
|
|
||||||
int ibmp = _toolBarIcons.getUglyIconAt(i - j);
|
|
||||||
bmpIndex = (ibmp == -1)?(STD_PRINT + (inc++)):ibmp;
|
|
||||||
style = BTNS_BUTTON;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bmpIndex = 0;
|
|
||||||
style = BTNS_SEP;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_pTBB[i].iBitmap = bmpIndex;
|
|
||||||
_pTBB[i].idCommand = cmd;
|
|
||||||
_pTBB[i].fsState = TBSTATE_ENABLED;
|
|
||||||
_pTBB[i].fsStyle = style;
|
|
||||||
_pTBB[i].dwData = 0;
|
|
||||||
_pTBB[i].iString = 0;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setButtonSize(16, 16);
|
if (create) { //if the toolbar has been recreated, readd the buttons
|
||||||
|
size_t nrBtnToAdd = (_state == TB_STANDARD?_nrTotalButtons:_nrButtons);
|
||||||
::SendMessage(_hSelf, TB_ADDBUTTONS, (WPARAM)nbElement, (LPARAM)_pTBB);
|
_nrCurrentButtons = nrBtnToAdd;
|
||||||
|
WORD btnSize = (_state == TB_LARGE?32:16);
|
||||||
|
::SendMessage(_hSelf, TB_SETBUTTONSIZE , (WPARAM)0, (LPARAM)MAKELONG (btnSize, btnSize));
|
||||||
|
::SendMessage(_hSelf, TB_ADDBUTTONS, (WPARAM)nrBtnToAdd, (LPARAM)_pTBB);
|
||||||
|
if (_visible)
|
||||||
|
Window::display(true);
|
||||||
|
}
|
||||||
::SendMessage(_hSelf, TB_AUTOSIZE, 0, 0);
|
::SendMessage(_hSelf, TB_AUTOSIZE, 0, 0);
|
||||||
_state = TB_STANDARD;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolBar::registerDynBtn(UINT messageID, toolbarIcons* tIcon)
|
void ToolBar::registerDynBtn(UINT messageID, toolbarIcons* tIcon)
|
||||||
|
@ -337,25 +202,47 @@ void ReBar::init(HINSTANCE hInst, HWND hPere, ToolBar *pToolBar)
|
||||||
{
|
{
|
||||||
Window::init(hInst, hPere);
|
Window::init(hInst, hPere);
|
||||||
_pToolBar = pToolBar;
|
_pToolBar = pToolBar;
|
||||||
|
|
||||||
_hSelf = CreateWindowEx(WS_EX_TOOLWINDOW,
|
_hSelf = CreateWindowEx(WS_EX_TOOLWINDOW,
|
||||||
REBARCLASSNAME,
|
REBARCLASSNAME,
|
||||||
NULL,
|
NULL,
|
||||||
WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|
|
WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|RBS_VARHEIGHT|
|
||||||
WS_CLIPCHILDREN|RBS_VARHEIGHT|
|
RBS_BANDBORDERS | CCS_NODIVIDER | CCS_NOPARENTALIGN,
|
||||||
CCS_NODIVIDER,
|
|
||||||
0,0,0,0, _hParent, NULL, _hInst, NULL);
|
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);
|
::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;
|
||||||
|
_rbBand.fStyle = 0;//RBBS_USECHEVRON;
|
||||||
|
|
||||||
_rbBand.hwndChild = _pToolBar->getHSelf();
|
_rbBand.hwndChild = _pToolBar->getHSelf();
|
||||||
|
_rbBand.cxMinChild = 0;
|
||||||
int dwBtnSize = SendMessage(_pToolBar->getHSelf(), TB_GETBUTTONSIZE, 0,0);
|
_rbBand.cyMinChild = HIWORD(size) + HIWORD(padding);
|
||||||
|
_rbBand.cyMaxChild = HIWORD(size) + HIWORD(padding);
|
||||||
_rbBand.cxMinChild = 34;//nbElement;
|
_rbBand.cyIntegral = 1;
|
||||||
_rbBand.cyMinChild = HIWORD(dwBtnSize);
|
_rbBand.cxIdeal = _rbBand.cx = _pToolBar->getWidth();
|
||||||
_rbBand.cx = 250;
|
|
||||||
::SendMessage(_hSelf, RB_INSERTBAND, (WPARAM)0, (LPARAM)&_rbBand);
|
::SendMessage(_hSelf, RB_INSERTBAND, (WPARAM)0, (LPARAM)&_rbBand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ReBar::reNew() {
|
||||||
|
int dwBtnSize = SendMessage(_pToolBar->getHSelf(), TB_GETBUTTONSIZE, 0,0);
|
||||||
|
|
||||||
|
_rbBand.hwndChild = _pToolBar->getHSelf();
|
||||||
|
_rbBand.cyMinChild = HIWORD(dwBtnSize);
|
||||||
|
_rbBand.cyMaxChild = HIWORD(dwBtnSize);
|
||||||
|
_rbBand.cxIdeal = _pToolBar->getWidth();
|
||||||
|
::SendMessage(_hSelf, RB_SETBANDINFO, (WPARAM)0, (LPARAM)&_rbBand);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -60,14 +60,11 @@ typedef struct {
|
||||||
class ToolBar : public Window
|
class ToolBar : public Window
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
const static bool REDUCED;
|
ToolBar():Window(), _pTBB(NULL), _nrButtons(0), _nrDynButtons(0), _nrTotalButtons(0), _nrCurrentButtons(0), _visible(true) {};
|
||||||
const static bool ENLARGED;
|
|
||||||
ToolBar():Window(), _pTBB(NULL){};
|
|
||||||
virtual ~ToolBar(){};
|
virtual ~ToolBar(){};
|
||||||
|
|
||||||
virtual bool init(HINSTANCE hInst, HWND hPere, int iconSize,
|
virtual bool init(HINSTANCE hInst, HWND hPere, toolBarStatusType type,
|
||||||
ToolBarButtonUnit *buttonUnitArray, int arraySize,
|
ToolBarButtonUnit *buttonUnitArray, int arraySize);
|
||||||
bool doUglyStandardIcon = false, int *bmpArray = NULL, int bmpArraySize = 0);
|
|
||||||
|
|
||||||
virtual void destroy() {
|
virtual void destroy() {
|
||||||
delete [] _pTBB;
|
delete [] _pTBB;
|
||||||
|
@ -85,33 +82,45 @@ public :
|
||||||
return Window::getHeight();
|
return Window::getHeight();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int getWidth() const;
|
||||||
|
|
||||||
void reduce() {
|
void reduce() {
|
||||||
if (_state == TB_SMALL)
|
if (_state == TB_SMALL)
|
||||||
return;
|
return;
|
||||||
// I really don't know why we have to enlarge then reduce
|
|
||||||
// to take the effect.
|
|
||||||
if (_state == TB_STANDARD)
|
|
||||||
_toolBarIcons.resizeIcon(32);
|
|
||||||
|
|
||||||
_toolBarIcons.resizeIcon(16);
|
_toolBarIcons.resizeIcon(16);
|
||||||
reset();
|
bool recreate = (_state == TB_STANDARD);
|
||||||
|
setState(TB_SMALL);
|
||||||
|
reset(recreate); //recreate toolbar if std icons were used
|
||||||
Window::redraw();
|
Window::redraw();
|
||||||
_state = TB_SMALL;
|
|
||||||
};
|
};
|
||||||
void enlarge() {
|
void enlarge() {
|
||||||
if (_state == TB_LARGE)
|
if (_state == TB_LARGE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_toolBarIcons.resizeIcon(32);
|
_toolBarIcons.resizeIcon(32);
|
||||||
reset();
|
bool recreate = (_state == TB_STANDARD);
|
||||||
|
setState(TB_LARGE);
|
||||||
|
reset(recreate); //recreate toolbar if std icons were used
|
||||||
Window::redraw();
|
Window::redraw();
|
||||||
_state = TB_LARGE;
|
|
||||||
};
|
};
|
||||||
|
void setToUglyIcons() {
|
||||||
|
if (_state == TB_STANDARD)
|
||||||
|
return;
|
||||||
|
bool recreate = true;
|
||||||
|
setState(TB_STANDARD);
|
||||||
|
reset(recreate); //must recreate toolbar if setting to internal bitmaps
|
||||||
|
Window::redraw();
|
||||||
|
}
|
||||||
|
void hide() {
|
||||||
|
if (getState() == TB_HIDE)
|
||||||
|
return;
|
||||||
|
display(false);
|
||||||
|
}
|
||||||
|
|
||||||
void display(bool toShow = true) {
|
void display(bool toShow = true) {
|
||||||
Window::display(toShow);
|
Window::display(toShow);
|
||||||
if (!toShow)
|
_visible = toShow;
|
||||||
_state = TB_HIDE;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool getCheckState(int ID2Check) const {
|
bool getCheckState(int ID2Check) const {
|
||||||
|
@ -122,9 +131,10 @@ public :
|
||||||
::SendMessage(_hSelf, TB_CHECKBUTTON, (WPARAM)ID2Check, (LPARAM)MAKELONG(willBeChecked, 0));
|
::SendMessage(_hSelf, TB_CHECKBUTTON, (WPARAM)ID2Check, (LPARAM)MAKELONG(willBeChecked, 0));
|
||||||
};
|
};
|
||||||
|
|
||||||
toolBarStatusType getState() const {return _state;};
|
toolBarStatusType getState() const {
|
||||||
|
bool test = _visible;
|
||||||
void setToUglyIcons();
|
return _visible?_state:TB_HIDE;
|
||||||
|
};
|
||||||
|
|
||||||
bool changeIcons(int whichLst, int iconIndex, const char *iconLocation){
|
bool changeIcons(int whichLst, int iconIndex, const char *iconLocation){
|
||||||
return _toolBarIcons.replaceIcon(whichLst, iconIndex, iconLocation);
|
return _toolBarIcons.replaceIcon(whichLst, iconIndex, iconLocation);
|
||||||
|
@ -136,9 +146,12 @@ private :
|
||||||
TBBUTTON *_pTBB;
|
TBBUTTON *_pTBB;
|
||||||
ToolBarIcons _toolBarIcons;
|
ToolBarIcons _toolBarIcons;
|
||||||
toolBarStatusType _state;
|
toolBarStatusType _state;
|
||||||
int *_bmpArray;
|
bool _visible;
|
||||||
int _bmpArraySize;
|
vector<tDynamicList> _vDynBtnReg;
|
||||||
vector<tDynamicList> _vDynBtnReg;
|
size_t _nrButtons;
|
||||||
|
size_t _nrDynButtons;
|
||||||
|
size_t _nrTotalButtons;
|
||||||
|
size_t _nrCurrentButtons;
|
||||||
|
|
||||||
|
|
||||||
void setDefaultImageList() {
|
void setDefaultImageList() {
|
||||||
|
@ -151,33 +164,22 @@ private :
|
||||||
::SendMessage(_hSelf, TB_SETDISABLEDIMAGELIST, (WPARAM)0, (LPARAM)_toolBarIcons.getDisableLst());
|
::SendMessage(_hSelf, TB_SETDISABLEDIMAGELIST, (WPARAM)0, (LPARAM)_toolBarIcons.getDisableLst());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void reset(bool create = false);
|
||||||
|
void setState(toolBarStatusType state) {
|
||||||
void setButtonSize(int w, int h) {
|
if(state == TB_HIDE) { //do not set the state to something else
|
||||||
::SendMessage(_hSelf, TB_SETBUTTONSIZE , (WPARAM)0, (LPARAM)MAKELONG (w, h));
|
_visible = false;
|
||||||
};
|
} else {
|
||||||
|
_visible = true;
|
||||||
void reset();
|
_state = state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ReBar : public Window
|
class ReBar : public Window
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
ReBar():Window(), _pToolBar(NULL) {
|
ReBar():Window(), _pToolBar(NULL) {};
|
||||||
_rbi.cbSize = sizeof(REBARINFO);
|
|
||||||
_rbi.fMask = 0;
|
|
||||||
_rbi.himl = (HIMAGELIST)NULL;
|
|
||||||
|
|
||||||
_rbBand.cbSize = sizeof(REBARBANDINFO);
|
|
||||||
_rbBand.fMask = /*RBBIM_COLORS | RBBIM_TEXT | RBBIM_BACKGROUND | \*/
|
|
||||||
RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE | \
|
|
||||||
RBBIM_SIZE;
|
|
||||||
|
|
||||||
_rbBand.fStyle = RBBS_FIXEDSIZE | RBBS_CHILDEDGE;
|
|
||||||
_rbBand.hbmBack = NULL;
|
|
||||||
_rbBand.lpText = "Toolbar";
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual void destroy() {
|
virtual void destroy() {
|
||||||
::DestroyWindow(_hSelf);
|
::DestroyWindow(_hSelf);
|
||||||
|
@ -185,12 +187,7 @@ public :
|
||||||
};
|
};
|
||||||
|
|
||||||
void init(HINSTANCE hInst, HWND hPere, ToolBar *pToolBar);
|
void init(HINSTANCE hInst, HWND hPere, ToolBar *pToolBar);
|
||||||
void reNew() {
|
void reNew();
|
||||||
_rbBand.hwndChild = _pToolBar->getHSelf();
|
|
||||||
int dwBtnSize = SendMessage(_pToolBar->getHSelf(), TB_GETBUTTONSIZE, 0,0);
|
|
||||||
_rbBand.cyMinChild = HIWORD(dwBtnSize);
|
|
||||||
::SendMessage(_hSelf, RB_SETBANDINFO, (WPARAM)0, (LPARAM)&_rbBand);
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
REBARINFO _rbi;
|
REBARINFO _rbi;
|
||||||
|
|
Loading…
Reference in New Issue