diff options
Diffstat (limited to 'plugins/MenuItemEx/src')
-rw-r--r-- | plugins/MenuItemEx/src/images.cpp | 26 | ||||
-rw-r--r-- | plugins/MenuItemEx/src/images.h | 3 | ||||
-rw-r--r-- | plugins/MenuItemEx/src/main.cpp | 107 | ||||
-rw-r--r-- | plugins/MenuItemEx/src/resource.h | 24 |
4 files changed, 75 insertions, 85 deletions
diff --git a/plugins/MenuItemEx/src/images.cpp b/plugins/MenuItemEx/src/images.cpp index f59b4c2c4e..4d2189a8d9 100644 --- a/plugins/MenuItemEx/src/images.cpp +++ b/plugins/MenuItemEx/src/images.cpp @@ -304,33 +304,30 @@ HICON MakeHalfAlphaIcon(HICON SourceIcon) //}
-HICON BindOverlayIcon(HICON SourceIcon, LPCSTR OverlayIconName)
+HICON BindOverlayIcon(HICON SourceIcon, int iIcon)
{
+ HICON TempIcon = CopyIcon(SourceIcon);
ICONINFO OverlayIconInfo, TargetIconInfo;
- BITMAP OverlayBitmapInfo, TargetBitmapInfo;
- HBITMAP OldOverlayBitmap, OldTargetBitmap;
- HICON OverlayIcon, TargetIcon, TempIcon;
- HDC OverlayDC, TargetDC;
- BLENDFUNCTION bf = { 0, 0, 255, 1 };
-
- TempIcon = CopyIcon(SourceIcon);
if (!GetIconInfo(TempIcon, &TargetIconInfo))
return nullptr;
MakeBitmap32(&TargetIconInfo.hbmColor);
CorrectBitmap32Alpha(TargetIconInfo.hbmColor, FALSE);
+
+ BITMAP OverlayBitmapInfo, TargetBitmapInfo;
GetObject(TargetIconInfo.hbmColor, sizeof(BITMAP), &TargetBitmapInfo);
- OverlayIcon = IcoLib_GetIcon(OverlayIconName);
+ HICON OverlayIcon = g_plugin.getIcon(iIcon);
if (!GetIconInfo(OverlayIcon, &OverlayIconInfo) || !GetObject(OverlayIconInfo.hbmColor, sizeof(BITMAP), &OverlayBitmapInfo))
return nullptr;
- TargetDC = CreateCompatibleDC(nullptr);
- OldTargetBitmap = (HBITMAP)SelectObject(TargetDC, TargetIconInfo.hbmColor);
+ HDC TargetDC = CreateCompatibleDC(nullptr);
+ HBITMAP OldTargetBitmap = (HBITMAP)SelectObject(TargetDC, TargetIconInfo.hbmColor);
- OverlayDC = CreateCompatibleDC(nullptr);
- OldOverlayBitmap = (HBITMAP)SelectObject(OverlayDC, OverlayIconInfo.hbmColor);
+ HDC OverlayDC = CreateCompatibleDC(nullptr);
+ HBITMAP OldOverlayBitmap = (HBITMAP)SelectObject(OverlayDC, OverlayIconInfo.hbmColor);
+ BLENDFUNCTION bf = { 0, 0, 255, 1 };
AlphaBlend(TargetDC, 0, 0, TargetBitmapInfo.bmWidth, TargetBitmapInfo.bmHeight,
OverlayDC, 0, 0, OverlayBitmapInfo.bmWidth, OverlayBitmapInfo.bmHeight, bf);
@@ -340,9 +337,8 @@ HICON BindOverlayIcon(HICON SourceIcon, LPCSTR OverlayIconName) BitBlt(TargetDC, 0, 0, TargetBitmapInfo.bmWidth, TargetBitmapInfo.bmHeight,
OverlayDC, 0, 0, SRCCOPY);
- TargetIcon = CreateIconIndirect(&TargetIconInfo);
+ HICON TargetIcon = CreateIconIndirect(&TargetIconInfo);
DestroyIcon(TempIcon);
- //DestroyIcon(OverlayIcon);
SelectObject(TargetDC, OldTargetBitmap);
DeleteObject(TargetIconInfo.hbmColor);
diff --git a/plugins/MenuItemEx/src/images.h b/plugins/MenuItemEx/src/images.h index c935ec8659..5c4cf01060 100644 --- a/plugins/MenuItemEx/src/images.h +++ b/plugins/MenuItemEx/src/images.h @@ -1,8 +1,7 @@ #ifndef __IMAGE_UTILS_H__
#define __IMAGE_UTILS_H__
-HICON BindOverlayIcon(HICON, LPCSTR);
-//HICON MakeGrayscaleIcon(HICON);
+HICON BindOverlayIcon(HICON, int iIcon);
HICON MakeHalfAlphaIcon(HICON);
#endif // __IMAGE_UTILS_H__
diff --git a/plugins/MenuItemEx/src/main.cpp b/plugins/MenuItemEx/src/main.cpp index 48d89f3b61..5a1c87ab99 100644 --- a/plugins/MenuItemEx/src/main.cpp +++ b/plugins/MenuItemEx/src/main.cpp @@ -22,13 +22,31 @@ PROTOACCOUNT **accs; int protoCount;
CMPlugin g_plugin;
-struct {
+static IconItem iconList[] =
+{
+ { LPGEN("Hide from list"), "hidefl", IDI_HIDE },
+ { LPGEN("Always visible"), "vis", IDI_VISIBLE },
+ { LPGEN("Never visible"), "invis", IDI_INVISIBLE },
+ { LPGEN("Copy ID"), "copyid", IDI_COPYID },
+ { LPGEN("Copy to Account"), "protocol", IDI_PROTOCOL },
+ { LPGEN("Ignore"), "ignore", IDI_IGNORE },
+ { LPGEN("Show in list"), "showil", IDI_SHOWINLIST },
+ { LPGEN("Copy Status Message"), "copysm1", IDI_COPYSTATUS },
+ { LPGEN("Copy xStatus Message"), "copysm2", IDI_COPYXSTATUS },
+ { LPGEN("Copy IP"), "copyip", IDI_COPYIP },
+ { LPGEN("Browse Received Files"), "recfiles", IDI_BROWSE },
+ { LPGEN("Copy MirVer"), "copymver", IDI_MIRVER },
+};
+
+struct
+{
char *module;
char *name;
wchar_t *fullName;
char flag;
}
-static const statusMsg[] = {
+static const statusMsg[] =
+{
{ "CList", "StatusMsg", LPGENW("Status message"), 1 },
{ nullptr, "XStatusName", LPGENW("xStatus title"), 4 },
{ nullptr, "XStatusMsg", LPGENW("xStatus message"), 2 },
@@ -37,25 +55,8 @@ static const statusMsg[] = { { "AdvStatus", "activity/text", LPGENW("Activity text"), 8 }
};
-static IconItem iconList[] = {
- { LPGEN("Hide from list"), "miex_hidefl", IDI_ICON0 },
- { LPGEN("Show in list"), "miex_showil", IDI_ICON8 },
- { LPGEN("Always visible"), "miex_vis", IDI_ICON1 },
- { LPGEN("Never visible"), "miex_invis", IDI_ICON2 },
- { LPGEN("Copy to Account"), "miex_protocol", IDI_ICON6 },
- { LPGEN("Ignore"), "miex_ignore", IDI_ICON7 },
- { LPGEN("Browse Received Files"), "miex_recfiles", IDI_ICON12 },
- { LPGEN("Copy MirVer"), "miex_copymver", IDI_ICON13 }
-};
-
-static IconItem overlayIconList[] = {
- { LPGEN("Copy ID"), "miex_copyid", IDI_ICON3 },
- { LPGEN("Copy Status Message"), "miex_copysm1", IDI_ICON9 },
- { LPGEN("Copy xStatus Message"), "miex_copysm2", IDI_ICON10 },
- { LPGEN("Copy IP"), "miex_copyip", IDI_ICON11 }
-};
-
-struct {
+struct
+{
wchar_t* name;
int type;
int icon;
@@ -86,16 +87,19 @@ PLUGININFOEX pluginInfoEx = { CMPlugin::CMPlugin() :
PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
-{}
+{
+}
/////////////////////////////////////////////////////////////////////////////////////////
-struct ModSetLinkLinkItem { // code from dbe++ plugin by Bio
+struct ModSetLinkLinkItem
+{ // code from dbe++ plugin by Bio
char *name;
BYTE *next; //struct ModSetLinkLinkItem
};
-struct ModuleSettingLL {
+struct ModuleSettingLL
+{
struct ModSetLinkLinkItem *first;
struct ModSetLinkLinkItem *last;
};
@@ -108,16 +112,14 @@ static int GetSetting(MCONTACT hContact, const char *szModule, const char *szSet static int enumModulesSettingsProc(const char *szName, void *lParam)
{
ModuleSettingLL *msll = (ModuleSettingLL *)lParam;
- if (!msll->first)
- {
+ if (!msll->first) {
msll->first = (struct ModSetLinkLinkItem *)malloc(sizeof(struct ModSetLinkLinkItem));
if (!msll->first) return 1;
msll->first->name = _strdup(szName);
msll->first->next = nullptr;
msll->last = msll->first;
}
- else
- {
+ else {
struct ModSetLinkLinkItem *item = (struct ModSetLinkLinkItem *)malloc(sizeof(struct ModSetLinkLinkItem));
if (!item) return 1;
msll->last->next = (BYTE*)item;
@@ -130,22 +132,18 @@ static int enumModulesSettingsProc(const char *szName, void *lParam) static void FreeModuleSettingLL(ModuleSettingLL* msll)
{
- if (msll)
- {
+ if (msll) {
struct ModSetLinkLinkItem *item = msll->first;
struct ModSetLinkLinkItem *temp;
- while (item)
- {
- if (item->name)
- {
+ while (item) {
+ if (item->name) {
free(item->name);
item->name = nullptr;
}
temp = item;
item = (struct ModSetLinkLinkItem *)item->next;
- if (temp)
- {
+ if (temp) {
free(temp);
temp = nullptr;
}
@@ -410,7 +408,7 @@ static void ModifyCopyID(MCONTACT hContact, BOOL bShowID, BOOL bTrimID) HICON hIconCID = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0);
{
- HICON hIcon = BindOverlayIcon(hIconCID, "miex_copyid");
+ HICON hIcon = BindOverlayIcon(hIconCID, IDI_COPYID);
DestroyIcon(hIconCID);
hIconCID = hIcon;
}
@@ -444,7 +442,7 @@ static void ModifyStatusMsg(MCONTACT hContact) HICON hIconSMsg = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0);
{
- HICON hIcon = BindOverlayIcon(hIconSMsg, (StatusMsgExists(hContact) & 2) ? "miex_copysm2" : "miex_copysm1");
+ HICON hIcon = BindOverlayIcon(hIconSMsg, (StatusMsgExists(hContact) & 2) ? IDI_COPYXSTATUS : IDI_COPYSTATUS);
DestroyIcon(hIconSMsg);
hIconSMsg = hIcon;
}
@@ -463,7 +461,7 @@ static void ModifyCopyIP(MCONTACT hContact) HICON hIconCIP = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0);
{
- HICON hIcon = BindOverlayIcon(hIconCIP, "miex_copyip");
+ HICON hIcon = BindOverlayIcon(hIconCIP, IDI_COPYIP);
DestroyIcon(hIconCIP);
hIconCIP = hIcon;
}
@@ -778,10 +776,8 @@ static int EnumProtoSubmenu(WPARAM, LPARAM) int pos = 1000;
if (protoCount) // remove old items
{
- for (int i = 0; i < protoCount; i++)
- {
- if (hProtoItem[i])
- {
+ for (int i = 0; i < protoCount; i++) {
+ if (hProtoItem[i]) {
Menu_RemoveItem(hProtoItem[i]);
hProtoItem[i] = nullptr;
}
@@ -790,8 +786,7 @@ static int EnumProtoSubmenu(WPARAM, LPARAM) Proto_EnumAccounts(&protoCount, &accs);
if (protoCount > MAX_PROTOS)
protoCount = MAX_PROTOS;
- for (int i = 0; i < protoCount; i++)
- {
+ for (int i = 0; i < protoCount; i++) {
hProtoItem[i] = AddSubmenuItem(hmenuProto, accs[i]->tszAccountName,
Skin_LoadProtoIcon(accs[i]->szModuleName, ID_STATUS_ONLINE), CMIF_SYSTEM | CMIF_KEEPUNTRANSLATED,
MS_PROTO, pos++, (INT_PTR)accs[i]->szModuleName);
@@ -824,8 +819,7 @@ static int TabsrmmButtonsInit(WPARAM, LPARAM) static void TabsrmmButtonsModify(MCONTACT hContact)
{
- if (!DirectoryExists(hContact))
- {
+ if (!DirectoryExists(hContact)) {
BBButton bbd = {};
bbd.pszModuleName = MODULENAME;
bbd.bbbFlags = BBSF_DISABLED | BBSF_HIDDEN;
@@ -873,7 +867,7 @@ static int PluginInit(WPARAM, LPARAM) mi.position++;
mi.name.w = LPGENW("Ignore");
mi.pszService = nullptr;
- mi.hIcolibItem = IcoLib_GetIcon("miex_ignore");
+ mi.hIcolibItem = g_plugin.getIconHandle(IDI_IGNORE);
hmenuIgnore = Menu_AddContactMenuItem(&mi);
hIgnoreItem[0] = AddSubmenuItem(hmenuIgnore, ii[0].name, Skin_LoadIcon(ii[0].icon), 0, MS_IGNORE, pos, ii[0].type);
@@ -881,7 +875,7 @@ static int PluginInit(WPARAM, LPARAM) for (int i = 1; i < _countof(ii); i++)
hIgnoreItem[i] = AddSubmenuItem(hmenuIgnore, ii[i].name, Skin_LoadIcon(ii[i].icon), 0, MS_IGNORE, pos++, ii[i].type);
- AddSubmenuItem(hmenuIgnore, LPGENW("Open ignore settings"), IcoLib_GetIcon("miex_ignore"), 0, MS_OPENIGNORE, pos, 0);
+ AddSubmenuItem(hmenuIgnore, LPGENW("Open ignore settings"), g_plugin.getIcon(IDI_IGNORE), 0, MS_OPENIGNORE, pos, 0);
pos += 100000; // insert separator
@@ -889,7 +883,7 @@ static int PluginInit(WPARAM, LPARAM) mi.position++;
mi.name.w = LPGENW("Copy to Account");
mi.pszService = MS_PROTO;
- mi.hIcolibItem = IcoLib_GetIcon("miex_protocol");
+ mi.hIcolibItem = g_plugin.getIconHandle(IDI_PROTOCOL);
hmenuProto = Menu_AddContactMenuItem(&mi);
EnumProtoSubmenu(0, 0);
@@ -906,7 +900,7 @@ static int PluginInit(WPARAM, LPARAM) mi.position++;
mi.name.w = LPGENW("Browse Received Files");
mi.pszService = MS_RECVFILES;
- mi.hIcolibItem = IcoLib_GetIcon("miex_recfiles");
+ mi.hIcolibItem = g_plugin.getIconHandle(IDI_BROWSE);
hmenuRecvFiles = Menu_AddContactMenuItem(&mi);
SET_UID(mi, 0xf750f36b, 0x284f, 0x4841, 0x83, 0x18, 0xc7, 0x10, 0x4, 0x73, 0xea, 0x22);
@@ -928,9 +922,9 @@ static int PluginInit(WPARAM, LPARAM) mi.pszService = MS_COPYMIRVER;
hmenuCopyMirVer = Menu_AddContactMenuItem(&mi);
- hIcons[0] = IcoLib_GetIcon("miex_copymver");
- hIcons[1] = IcoLib_GetIcon("miex_vis");
- hIcons[2] = IcoLib_GetIcon("miex_invis");
+ hIcons[0] = g_plugin.getIcon(IDI_MIRVER);
+ hIcons[1] = g_plugin.getIcon(IDI_VISIBLE);
+ hIcons[2] = g_plugin.getIcon(IDI_INVISIBLE);
hIcons[3] = MakeHalfAlphaIcon(hIcons[1]);
hIcons[4] = MakeHalfAlphaIcon(hIcons[2]);
@@ -940,10 +934,11 @@ static int PluginInit(WPARAM, LPARAM) return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
int CMPlugin::Load()
{
- g_plugin.registerIcon(LPGEN("MenuItemEx"), iconList);
- g_plugin.registerIcon(LPGEN("MenuItemEx"), overlayIconList);
+ g_plugin.registerIcon(LPGEN("MenuItemEx"), iconList, "miex");
CreateServiceFunction(MS_SETINVIS, onSetInvis);
CreateServiceFunction(MS_SETVIS, onSetVis);
diff --git a/plugins/MenuItemEx/src/resource.h b/plugins/MenuItemEx/src/resource.h index 1b51b15fe4..2cc96bb73b 100644 --- a/plugins/MenuItemEx/src/resource.h +++ b/plugins/MenuItemEx/src/resource.h @@ -4,18 +4,18 @@ //
#define IDD_OPTIONS 101
#define IDD_AUTHREQ 103
-#define IDI_ICON0 110
-#define IDI_ICON1 111
-#define IDI_ICON2 112
-#define IDI_ICON3 113
-#define IDI_ICON6 116
-#define IDI_ICON7 117
-#define IDI_ICON8 118
-#define IDI_ICON9 119
-#define IDI_ICON10 120
-#define IDI_ICON11 121
-#define IDI_ICON12 122
-#define IDI_ICON13 123
+#define IDI_HIDE 110
+#define IDI_VISIBLE 111
+#define IDI_INVISIBLE 112
+#define IDI_COPYID 113
+#define IDI_PROTOCOL 116
+#define IDI_IGNORE 117
+#define IDI_SHOWINLIST 118
+#define IDI_COPYSTATUS 119
+#define IDI_COPYXSTATUS 120
+#define IDI_COPYIP 121
+#define IDI_BROWSE 122
+#define IDI_MIRVER 123
#define IDC_VIS 1000
#define IDC_REASON 1001
#define IDC_HIDE 1002
|