summaryrefslogtreecommitdiff
path: root/plugins/TopToolBar
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2017-09-17 16:25:09 +0300
committerKirill Volinsky <mataes2007@gmail.com>2017-09-17 16:25:09 +0300
commit4b42369bedd87f02c959303a817e7974bfd580c6 (patch)
tree6ab28fb01d5dca0a76094dea38fc8f2ed932d679 /plugins/TopToolBar
parent11627574479496d731b5c8954e13c459d6bba8ba (diff)
TopToolBar: all icons added to icolib (fixes #303)
Diffstat (limited to 'plugins/TopToolBar')
-rw-r--r--plugins/TopToolBar/res/main.rc8
-rw-r--r--plugins/TopToolBar/res/sep.bmpbin1194 -> 0 bytes
-rw-r--r--plugins/TopToolBar/res/separator.icobin0 -> 1150 bytes
-rw-r--r--plugins/TopToolBar/src/InternalButtons.cpp169
-rw-r--r--plugins/TopToolBar/src/main.cpp16
-rw-r--r--plugins/TopToolBar/src/resource.h2
-rw-r--r--plugins/TopToolBar/src/stdafx.h3
-rw-r--r--plugins/TopToolBar/src/toolbar.cpp4
-rw-r--r--plugins/TopToolBar/src/toolbarwnd.cpp2
-rw-r--r--plugins/TopToolBar/src/topbutton.cpp5
10 files changed, 123 insertions, 86 deletions
diff --git a/plugins/TopToolBar/res/main.rc b/plugins/TopToolBar/res/main.rc
index 1344c89e5c..1f4f2da3b5 100644
--- a/plugins/TopToolBar/res/main.rc
+++ b/plugins/TopToolBar/res/main.rc
@@ -81,13 +81,6 @@ END
#endif // APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Bitmap
-//
-
-IDB_SEP BITMAP "sep.bmp"
-
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
@@ -130,6 +123,7 @@ IDI_SOUNDSOFF ICON "Sounds Enable_Disable_DN.ico"
IDI_SOUNDSON ICON "Sounds Enable_Disable_UP.ico"
IDI_METAON ICON "..\\..\\..\\src\\mir_app\\res\\meta_menu.ico"
IDI_METAOFF ICON "..\\..\\..\\src\\mir_app\\res\\meta_menuof.ico"
+IDI_SEPARATOR ICON "separator.ico"
#endif // Neutral resources
/////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/TopToolBar/res/sep.bmp b/plugins/TopToolBar/res/sep.bmp
deleted file mode 100644
index 1665285275..0000000000
--- a/plugins/TopToolBar/res/sep.bmp
+++ /dev/null
Binary files differ
diff --git a/plugins/TopToolBar/res/separator.ico b/plugins/TopToolBar/res/separator.ico
new file mode 100644
index 0000000000..b0ece1fb25
--- /dev/null
+++ b/plugins/TopToolBar/res/separator.ico
Binary files differ
diff --git a/plugins/TopToolBar/src/InternalButtons.cpp b/plugins/TopToolBar/src/InternalButtons.cpp
index 26e06d42b3..5855153e75 100644
--- a/plugins/TopToolBar/src/InternalButtons.cpp
+++ b/plugins/TopToolBar/src/InternalButtons.cpp
@@ -5,33 +5,8 @@
#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;
-
-struct {
- char *name, *pszService;
- int iconidUp, iconidDn;
- char *tooltipUp, *tooltipDn;
- bool bCustomIcon, bDefVisible;
- HANDLE hButton;
-}
-static stdButtons[] = {
- { 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_TOGGLEHIDEOFFLINE, 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"), MS_CLIST_TOGGLEGROUPS, 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"), "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 }
-};
+HANDLE hMainMenu, hOptions, hAccManager, hFindAdd, hStatusMenu, hShowHideOffline, hMetaContacts, hGroups, hSounds, hMinimize, hExit;
///////////////////////////////////////////////////////////////////////////////
@@ -43,17 +18,17 @@ int OnSettingChanging(WPARAM hContact, LPARAM lParam)
if (!strcmp(dbcws->szModule, "CList")) {
if (!strcmp(dbcws->szSetting, "HideOffline"))
- CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[INDEX_OFFLINE].hButton, dbcws->value.bVal ? 0 : TTBST_PUSHED);
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hShowHideOffline, dbcws->value.bVal ? 0 : TTBST_PUSHED);
else if (!strcmp(dbcws->szSetting, "UseGroups"))
- CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[INDEX_GROUPS].hButton, dbcws->value.bVal ? TTBST_PUSHED : 0);
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hGroups, dbcws->value.bVal ? TTBST_PUSHED : 0);
}
else if (!strcmp(dbcws->szModule, "Skin")) {
if (!strcmp(dbcws->szSetting, "UseSound"))
- CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[INDEX_SOUNDS].hButton, dbcws->value.bVal ? TTBST_PUSHED : 0);
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hSounds, dbcws->value.bVal ? TTBST_PUSHED : 0);
}
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 : 0);
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hMetaContacts, dbcws->value.bVal ? TTBST_PUSHED : 0);
}
return 0;
@@ -92,51 +67,107 @@ void InitInternalButtons()
CreateServiceFunction(TTBI_MAINMENUBUTT, TTBInternalMainMenuButt);
CreateServiceFunction(TTBI_STATUSMENUBUTT, TTBInternalStatusMenuButt);
- for (int i = 0; i < _countof(stdButtons); i++) {
- TTBButton ttb = { 0 };
- ttb.name = stdButtons[i].name;
- ttb.pszService = stdButtons[i].pszService;
- 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;
- 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 = Skin_GetIconHandle(stdButtons[i].iconidUp);
- if (stdButtons[i].iconidDn) {
- ttb.dwFlags |= TTBBF_ASPUSHBUTTON;
- ttb.hIconHandleDn = Skin_GetIconHandle(stdButtons[i].iconidDn);
- }
- else
- ttb.hIconHandleDn = ttb.hIconDn = NULL;
- }
-
- if (i == 0)
- ttb.wParamUp = 1;
-
- stdButtons[i].hButton = (HANDLE)TTBAddButton((WPARAM)&ttb, 0);
- }
-
- CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[INDEX_OFFLINE].hButton,
+ TTBButton ttb = { 0 };
+ ttb.name = LPGEN("Show main menu");
+ ttb.pszService = TTBI_MAINMENUBUTT;
+ ttb.dwFlags = TTBBF_INTERNAL | TTBBF_VISIBLE;
+ ttb.pszTooltipUp = LPGEN("Show main menu");
+ ttb.hIconHandleUp = Skin_GetIconHandle(SKINICON_OTHER_MAINMENU);
+ ttb.wParamUp = 1;
+ hMainMenu = TopToolbar_AddButton(&ttb);
+
+ ttb.name = LPGEN("Show options page");
+ ttb.pszService = "Options/OptionsCommand";
+ ttb.dwFlags = TTBBF_INTERNAL | TTBBF_VISIBLE;
+ ttb.pszTooltipUp = LPGEN("Show options page");
+ ttb.hIconHandleUp = Skin_GetIconHandle(SKINICON_OTHER_OPTIONS);
+ ttb.wParamUp = 0;
+ hOptions = TopToolbar_AddButton(&ttb);
+
+ ttb.name = LPGEN("Show accounts manager");
+ ttb.pszService = "Protos/ShowAccountManager";
+ ttb.dwFlags = TTBBF_INTERNAL;
+ ttb.pszTooltipUp = LPGEN("Show accounts manager");
+ ttb.hIconHandleUp = Skin_GetIconHandle(SKINICON_OTHER_ACCMGR);
+ hAccManager = TopToolbar_AddButton(&ttb);
+
+ ttb.name = LPGEN("Find/add contacts");
+ ttb.pszService = MS_FINDADD_FINDADD;
+ ttb.dwFlags = TTBBF_INTERNAL | TTBBF_VISIBLE;
+ ttb.pszTooltipUp = LPGEN("Find/add contacts");
+ ttb.hIconHandleUp = Skin_GetIconHandle(SKINICON_OTHER_FINDUSER);
+ hFindAdd = TopToolbar_AddButton(&ttb);
+
+ ttb.name = LPGEN("Show status menu");
+ ttb.pszService = TTBI_STATUSMENUBUTT;
+ ttb.dwFlags = TTBBF_INTERNAL;
+ ttb.pszTooltipUp = LPGEN("Show status menu");
+ ttb.hIconHandleUp = Skin_GetIconHandle(SKINICON_OTHER_STATUS);
+ hStatusMenu = TopToolbar_AddButton(&ttb);
+
+ ttb.name = LPGEN("Show/hide offline contacts");
+ ttb.pszService = MS_CLIST_TOGGLEHIDEOFFLINE;
+ ttb.dwFlags = TTBBF_INTERNAL | TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP | TTBBF_ASPUSHBUTTON;
+ ttb.pszTooltipDn = LPGEN("Show offline contacts");
+ ttb.pszTooltipUp = LPGEN("Hide offline contacts");
+ ttb.hIconHandleDn = ttb.hIconHandleUp = NULL;
+ ttb.hIconUp = IcoLib_GetIconByHandle(iconList[1].hIcolib);
+ ttb.hIconDn = IcoLib_GetIconByHandle(iconList[2].hIcolib);
+ hShowHideOffline = TopToolbar_AddButton(&ttb);
+
+ ttb.name = LPGEN("Enable/disable metacontacts");
+ ttb.pszService = "MetaContacts/OnOff";
+ ttb.dwFlags = TTBBF_INTERNAL | TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP | TTBBF_ASPUSHBUTTON;
+ ttb.pszTooltipDn = LPGEN("Enable metacontacts");
+ ttb.pszTooltipUp = LPGEN("Disable metacontacts");
+ ttb.hIconUp = IcoLib_GetIconByHandle(iconList[7].hIcolib);
+ ttb.hIconDn = IcoLib_GetIconByHandle(iconList[8].hIcolib);
+ hMetaContacts = TopToolbar_AddButton(&ttb);
+
+ ttb.name = LPGEN("Enable/disable groups");
+ ttb.pszService = MS_CLIST_TOGGLEGROUPS;
+ ttb.dwFlags = TTBBF_INTERNAL | TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP | TTBBF_ASPUSHBUTTON;
+ ttb.pszTooltipDn = LPGEN("Disable groups");
+ ttb.pszTooltipUp = LPGEN("Enable groups");
+ ttb.hIconUp = IcoLib_GetIconByHandle(iconList[3].hIcolib);
+ ttb.hIconDn = IcoLib_GetIconByHandle(iconList[4].hIcolib);
+ hGroups = TopToolbar_AddButton(&ttb);
+
+ ttb.name = LPGEN("Enable/disable sounds");
+ ttb.pszService = TTBI_SOUNDSONOFF;
+ ttb.dwFlags = TTBBF_INTERNAL | TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP | TTBBF_ASPUSHBUTTON;
+ ttb.pszTooltipDn = LPGEN("Enable sounds");
+ ttb.pszTooltipUp = LPGEN("Disable sounds");
+ ttb.hIconUp = IcoLib_GetIconByHandle(iconList[5].hIcolib);
+ ttb.hIconDn = IcoLib_GetIconByHandle(iconList[6].hIcolib);
+ hSounds = TopToolbar_AddButton(&ttb);
+
+ ttb.name = LPGEN("Minimize contact list");
+ ttb.pszService = "Clist/ShowHide";
+ ttb.dwFlags = TTBBF_INTERNAL | TTBBF_VISIBLE;
+ ttb.pszTooltipUp = LPGEN("Minimize contact list");
+ ttb.hIconHandleUp = Skin_GetIconHandle(SKINICON_OTHER_SHOWHIDE);
+ ttb.pszTooltipDn = NULL;
+ ttb.hIconUp = ttb.hIconDn = NULL;
+ hMinimize = TopToolbar_AddButton(&ttb);
+
+ ttb.name = LPGEN("Exit");
+ ttb.pszService = "CloseAction";
+ ttb.dwFlags = TTBBF_INTERNAL;
+ ttb.pszTooltipUp = LPGEN("Exit");
+ ttb.hIconHandleUp = Skin_GetIconHandle(SKINICON_OTHER_EXIT);
+ hExit = TopToolbar_AddButton(&ttb);
+
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hShowHideOffline,
db_get_b(NULL, "CList", "HideOffline", 0) ? 0 : TTBST_PUSHED);
- CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[INDEX_GROUPS].hButton,
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hGroups,
db_get_b(NULL, "CList", "UseGroups", 1) ? TTBST_PUSHED : 0);
- CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[INDEX_SOUNDS].hButton,
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hSounds,
db_get_b(NULL, "Skin", "UseSound", 1) ? TTBST_PUSHED : 0);
- CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[INDEX_META].hButton,
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hMetaContacts,
db_get_b(NULL, "MetaContacts", "Enabled", 1) ? TTBST_PUSHED : 0);
HookEvent(ME_DB_CONTACT_SETTINGCHANGED, OnSettingChanging);
diff --git a/plugins/TopToolBar/src/main.cpp b/plugins/TopToolBar/src/main.cpp
index 24e6fbe66d..17c3ad9b97 100644
--- a/plugins/TopToolBar/src/main.cpp
+++ b/plugins/TopToolBar/src/main.cpp
@@ -25,6 +25,20 @@ extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD)
return &pluginInfo;
}
+IconItem iconList[] =
+{
+ { LPGEN("Execute"), "run", IDI_RUN },
+ { LPGEN("Hide offline contacts"), "hide_offline", IDI_HIDEOFFLINE },
+ { LPGEN("Show offline contacts"), "show_offline", IDI_SHOWOFFLINE },
+ { LPGEN("Disable groups"), "groups_off", IDI_GROUPSOFF },
+ { LPGEN("Enable groups"), "groups_on", IDI_GROUPSON },
+ { LPGEN("Disable sounds"), "sounds_off", IDI_SOUNDSOFF },
+ { LPGEN("Enable sounds"), "sounds_on", IDI_SOUNDSON },
+ { LPGEN("Disable metacontacts"), "meta_off", IDI_METAON },
+ { LPGEN("Enable metacontacts"), "meta_on", IDI_METAOFF },
+ { LPGEN("Separator"), "separator", IDI_SEPARATOR }
+};
+
/////////////////////////////////////////////////////////////////////////////////////////
extern "C" int __declspec(dllexport) Load(void)
@@ -32,6 +46,8 @@ extern "C" int __declspec(dllexport) Load(void)
mir_getLP(&pluginInfo);
pcli = Clist_GetInterface();
+ Icon_Register(hInst, TTB_OPTDIR, iconList, _countof(iconList), TTB_OPTDIR);
+
LoadToolbarModule();
return 0;
}
diff --git a/plugins/TopToolBar/src/resource.h b/plugins/TopToolBar/src/resource.h
index 6f260726f3..af79a74fc0 100644
--- a/plugins/TopToolBar/src/resource.h
+++ b/plugins/TopToolBar/src/resource.h
@@ -2,13 +2,13 @@
// Microsoft Visual C++ generated include file.
// Used by ..\res\main.rc
//
-#define IDB_SEP 118
#define IDI_SHOWOFFLINE 125
#define IDI_HIDEOFFLINE 126
#define IDI_GROUPSOFF 127
#define IDI_GROUPSON 128
#define IDI_SOUNDSOFF 129
#define IDI_SOUNDSON 130
+#define IDI_SEPARATOR 131
#define IDI_METAON 139
#define IDI_RUN 140
#define IDI_METAOFF 141
diff --git a/plugins/TopToolBar/src/stdafx.h b/plugins/TopToolBar/src/stdafx.h
index 57e4e39329..bc9169318e 100644
--- a/plugins/TopToolBar/src/stdafx.h
+++ b/plugins/TopToolBar/src/stdafx.h
@@ -103,11 +103,12 @@ extern TTBCtrl* g_ctrl;
extern LIST<TopButtonInt> Buttons;
extern HINSTANCE hInst;
-extern HBITMAP hBmpBackground, hBmpSeparator;
+extern HBITMAP hBmpBackground;
extern mir_cs csButtonsHook;
extern pfnCustomProc g_CustomProc;
extern LPARAM g_CustomProcParam;
extern HANDLE hTTBModuleLoaded;
+extern IconItem iconList[];
void AddToOptions(TopButtonInt* b);
void RemoveFromOptions(int id);
diff --git a/plugins/TopToolBar/src/toolbar.cpp b/plugins/TopToolBar/src/toolbar.cpp
index 7c1adde848..392cbe1fbe 100644
--- a/plugins/TopToolBar/src/toolbar.cpp
+++ b/plugins/TopToolBar/src/toolbar.cpp
@@ -637,8 +637,6 @@ int LoadToolbarModule()
db_unset(NULL, TTB_OPTDIR, "WarningDone");
- hBmpSeparator = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_SEP));
-
HookEvent(ME_SYSTEM_MODULELOAD, OnPluginLoad);
HookEvent(ME_SYSTEM_MODULEUNLOAD, OnPluginUnload);
HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoad);
@@ -680,8 +678,6 @@ int UnloadToolbarModule()
{
DestroyHookableEvent(hTTBModuleLoaded);
- DeleteObject(hBmpSeparator);
-
for (int i = 0; i < Buttons.getCount(); i++)
delete Buttons[i];
diff --git a/plugins/TopToolBar/src/toolbarwnd.cpp b/plugins/TopToolBar/src/toolbarwnd.cpp
index 3c22a12202..2a73eb86ad 100644
--- a/plugins/TopToolBar/src/toolbarwnd.cpp
+++ b/plugins/TopToolBar/src/toolbarwnd.cpp
@@ -2,7 +2,7 @@
#include "stdafx.h"
COLORREF bkColour;
-HBITMAP hBmpBackground, hBmpSeparator;
+HBITMAP hBmpBackground;
int backgroundBmpUse;
static wchar_t pluginname[] = L"TopToolBar";
diff --git a/plugins/TopToolBar/src/topbutton.cpp b/plugins/TopToolBar/src/topbutton.cpp
index 75a39c03a4..4faef0753d 100644
--- a/plugins/TopToolBar/src/topbutton.cpp
+++ b/plugins/TopToolBar/src/topbutton.cpp
@@ -151,9 +151,8 @@ void TopButtonInt::SetBitmap()
curstyle &= (~SS_ICON);
if (dwFlags & TTBBF_ISSEPARATOR) {
- SetWindowLongPtr(hwnd, GWL_STYLE, curstyle | SS_BITMAP);
- SendMessage(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBmpSeparator);
- SendMessage(hwnd, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBmpSeparator);
+ SetWindowLongPtr(hwnd, GWL_STYLE, curstyle | SS_ICON);
+ SendMessage(hwnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIconByHandle(iconList[9].hIcolib));
}
else {
if (GetWindowLongPtr(hwnd, GWL_STYLE) & SS_ICON)