From f82addcc0fb5ebc1051123336ec090946011b95d Mon Sep 17 00:00:00 2001 From: slotwin Date: Tue, 17 Jun 2014 01:08:41 +0000 Subject: TopToolBar: expand list of internal buttons use default Miranda icons where possible fix crash on IcoLib icon change git-svn-id: http://svn.miranda-ng.org/main/trunk@9524 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TopToolBar/src/InternalButtons.cpp | 91 +++++++++++++++++++++--------- 1 file changed, 65 insertions(+), 26 deletions(-) (limited to 'plugins/TopToolBar/src/InternalButtons.cpp') diff --git a/plugins/TopToolBar/src/InternalButtons.cpp b/plugins/TopToolBar/src/InternalButtons.cpp index fa28ad79e0..0869b5b7a8 100644 --- a/plugins/TopToolBar/src/InternalButtons.cpp +++ b/plugins/TopToolBar/src/InternalButtons.cpp @@ -4,6 +4,12 @@ #define TTBI_GROUPSHOWHIDE "TTBInternal/GroupShowHide" #define TTBI_SOUNDSONOFF "TTBInternal/SoundsOnOFF" #define TTBI_MAINMENUBUTT "TTBInternal/MainMenuBUTT" +#define TTBI_STATUSMENUBUTT "TTBInternal/StatusMenuButt" + +#define INDEX_OFFLINE 5 +#define INDEX_META 6 +#define INDEX_GROUPS 7 +#define INDEX_SOUNDS 8 static HWND hwndContactTree; @@ -11,17 +17,21 @@ struct { char *name, *pszService; int iconidUp, iconidDn; char *tooltipUp, *tooltipDn; + bool bCustomIcon, bDefVisible; HANDLE hButton; } static stdButtons[] = { - { LPGEN("Show only online users"), MS_CLIST_SETHIDEOFFLINE, IDI_SHOWONLINEUP, IDI_SHOWONLINEDN, LPGEN("Hide offline users"), LPGEN("Show all users") }, - { LPGEN("Groups on/off"), TTBI_GROUPSHOWHIDE, IDI_GROUPSUP, IDI_GROUPSDN, LPGEN("Hide groups"), LPGEN("Show groups") }, - { LPGEN("Sounds enable/disable"), TTBI_SOUNDSONOFF, IDI_SOUNDUP, IDI_SOUNDDN, LPGEN("Disable sounds"), LPGEN("Enable sounds") }, - - { LPGEN("Show options page"), "Options/OptionsCommand", IDI_OPTIONSUP, 0, LPGEN("Show options") }, - { LPGEN("Minimize button"), MS_CLIST_SHOWHIDE, IDI_MINIMIZEUP, 0, NULL }, - { LPGEN("Find/Add contacts"), MS_FINDADD_FINDADD, IDI_FINDADDUP, 0, NULL }, - { LPGEN("Show main menu"), TTBI_MAINMENUBUTT, IDI_MIRANDAUP, 0, LPGEN("Show main menu") } + { LPGEN("Show main menu"), TTBI_MAINMENUBUTT, SKINICON_OTHER_MAINMENU, 0, LPGEN("Show main menu"), NULL, 0, 1 }, + { LPGEN("Show options page"), "Options/OptionsCommand", SKINICON_OTHER_OPTIONS, 0, LPGEN("Show options page"), NULL, 0, 1 }, + { LPGEN("Show accounts manager"), "Protos/ShowAccountManager", SKINICON_OTHER_ACCMGR, 0, LPGEN("Show accounts manager"), NULL, 0, 0 }, + { LPGEN("Find/add contacts"), MS_FINDADD_FINDADD, SKINICON_OTHER_FINDUSER, 0, LPGEN("Find/add contacts"), NULL, 0, 1 }, + { LPGEN("Show status menu"), TTBI_STATUSMENUBUTT, SKINICON_OTHER_STATUS, 0, LPGEN("Show status menu"), NULL, 0, 0 }, + { LPGEN("Show/hide offline contacts"), MS_CLIST_SETHIDEOFFLINE, IDI_HIDEOFFLINE, IDI_SHOWOFFLINE, LPGEN("Hide offline contacts"), LPGEN("Show offline contacts"), 1, 1 }, + { LPGEN("Enable/disable MetaContacts"), "MetaContacts/OnOff", IDI_METAOFF, IDI_METAON, LPGEN("Disable MetaContacts"), LPGEN("Enable MetaContacts"), 1, 1 }, + { LPGEN("Enable/disable groups"), TTBI_GROUPSHOWHIDE, IDI_GROUPSOFF, IDI_GROUPSON, LPGEN("Enable groups"), LPGEN("Disable groups"), 1, 1 }, + { LPGEN("Enable/disable sounds"), TTBI_SOUNDSONOFF, IDI_SOUNDSOFF, IDI_SOUNDSON, LPGEN("Disable sounds"), LPGEN("Enable sounds"), 1, 1 }, + { LPGEN("Minimize contact list"), MS_CLIST_SHOWHIDE, SKINICON_OTHER_SHOWHIDE, 0, LPGEN("Minimize contact list"), NULL, 0, 1 }, + { LPGEN("Exit"), "CloseAction", SKINICON_OTHER_EXIT, 0, LPGEN("Exit"), NULL, 0, 0 } }; /////////////////////////////////////////////////////////////////////////////// @@ -34,15 +44,17 @@ int OnSettingChanging(WPARAM hContact, LPARAM lParam) if (!strcmp(dbcws->szModule, "CList")) { if (!strcmp(dbcws->szSetting, "HideOffline")) - CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[0].hButton, (dbcws->value.bVal) ? TTBST_PUSHED : TTBST_RELEASED); - + CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[INDEX_OFFLINE].hButton, dbcws->value.bVal ? TTBST_RELEASED : TTBST_PUSHED); else if (!strcmp(dbcws->szSetting, "UseGroups")) - CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[1].hButton, (dbcws->value.bVal) ? TTBST_PUSHED : TTBST_RELEASED); + CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[INDEX_GROUPS].hButton, dbcws->value.bVal ? TTBST_PUSHED : TTBST_RELEASED); } - else if (!strcmp(dbcws->szModule, "Skin")) { if (!strcmp(dbcws->szSetting, "UseSound")) - CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[2].hButton, (dbcws->value.bVal) ? TTBST_RELEASED : TTBST_PUSHED); + CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[INDEX_SOUNDS].hButton, dbcws->value.bVal ? TTBST_PUSHED : TTBST_RELEASED); + } + else if (!strcmp(dbcws->szModule, "MetaContacts")) { + if (!strcmp(dbcws->szSetting, "Enabled")) + CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[INDEX_META].hButton, dbcws->value.bVal ? TTBST_PUSHED : TTBST_RELEASED); } return 0; @@ -58,6 +70,16 @@ INT_PTR TTBInternalMainMenuButt(WPARAM wParam, LPARAM lParam) return 0; } +INT_PTR TTBInternalStatusMenuButt(WPARAM wParam, LPARAM lParam) +{ + HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUGETSTATUS, 0, 0); + + POINT pt; + GetCursorPos(&pt); + TrackPopupMenu(hMenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, (HWND)CallService(MS_CLUI_GETHWND, 0, 0), NULL); + return 0; +} + INT_PTR TTBInternalGroupShowHide(WPARAM wParam, LPARAM lParam) { int newVal = !(GetWindowLongPtr(hwndContactTree, GWL_STYLE) & CLS_USEGROUPS); @@ -82,23 +104,37 @@ void InitInternalButtons() CreateServiceFunction(TTBI_GROUPSHOWHIDE, TTBInternalGroupShowHide); CreateServiceFunction(TTBI_SOUNDSONOFF, TTBInternalSoundsOnOff); CreateServiceFunction(TTBI_MAINMENUBUTT, TTBInternalMainMenuButt); + CreateServiceFunction(TTBI_STATUSMENUBUTT, TTBInternalStatusMenuButt); for (int i = 0; i < SIZEOF(stdButtons); i++) { - TTBButton ttb = { 0 }; + TTBButton ttb = {0}; ttb.cbSize = sizeof(ttb); ttb.name = stdButtons[i].name; ttb.pszService = stdButtons[i].pszService; - ttb.dwFlags = TTBBF_VISIBLE | TTBBF_INTERNAL; + ttb.dwFlags = TTBBF_INTERNAL; + if (stdButtons[i].bDefVisible == TRUE) + ttb.dwFlags |= TTBBF_VISIBLE; if ((ttb.pszTooltipDn = stdButtons[i].tooltipDn) != NULL) ttb.dwFlags |= TTBBF_SHOWTOOLTIP; ttb.pszTooltipUp = stdButtons[i].tooltipUp; - ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(stdButtons[i].iconidUp), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); - if (stdButtons[i].iconidDn) { - ttb.dwFlags |= TTBBF_ASPUSHBUTTON; - ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(stdButtons[i].iconidDn), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); + if (stdButtons[i].bCustomIcon) { + ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(stdButtons[i].iconidUp), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); + if (stdButtons[i].iconidDn) { + ttb.dwFlags |= TTBBF_ASPUSHBUTTON; + ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(stdButtons[i].iconidDn), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); + } + else + ttb.hIconDn = NULL; + } + else { + ttb.hIconHandleUp = LoadSkinnedIconHandle(stdButtons[i].iconidUp); + if (stdButtons[i].iconidDn) { + ttb.dwFlags |= TTBBF_ASPUSHBUTTON; + ttb.hIconHandleDn = LoadSkinnedIconHandle(stdButtons[i].iconidDn); + } + else + ttb.hIconHandleDn = ttb.hIconDn = NULL; } - else - ttb.hIconDn = NULL; if (i == 0) ttb.wParamUp = 1; @@ -106,14 +142,17 @@ void InitInternalButtons() stdButtons[i].hButton = (HANDLE)TTBAddButton((WPARAM)&ttb, 0); } - CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[0].hButton, - db_get_b(NULL, "CList", "HideOffline", 0) ? TTBST_PUSHED : TTBST_RELEASED); + CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[INDEX_OFFLINE].hButton, + db_get_b(NULL, "CList", "HideOffline", 0) ? TTBST_RELEASED : TTBST_PUSHED); - CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[1].hButton, + CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[INDEX_GROUPS].hButton, db_get_b(NULL, "CList", "UseGroups", 1) ? TTBST_PUSHED : TTBST_RELEASED); - CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[2].hButton, - db_get_b(NULL, "Skin", "UseSound", 1) ? TTBST_RELEASED : TTBST_PUSHED); + CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[INDEX_SOUNDS].hButton, + db_get_b(NULL, "Skin", "UseSound", 1) ? TTBST_PUSHED : TTBST_RELEASED); + + CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[INDEX_META].hButton, + db_get_b(NULL, "MetaContacts", "Enabled", 1) ? TTBST_PUSHED : TTBST_RELEASED); HookEvent(ME_DB_CONTACT_SETTINGCHANGED, OnSettingChanging); } -- cgit v1.2.3