1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
/*
Scriver
Copyright (c) 2000-09 Miranda ICQ/IM project,
all portions of this codebase are copyrighted to the people
listed in contributors.txt.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "commonheaders.h"
HANDLE hHookIconPressedEvt;
void DrawStatusIcons(MCONTACT hContact, HDC hDC, const RECT &r, int gap)
{
int x = r.left;
int cx_icon = GetSystemMetrics(SM_CXSMICON);
int cy_icon = GetSystemMetrics(SM_CYSMICON);
int nIcon = 0;
while (StatusIconData *si = Srmm_GetNthIcon(hContact, nIcon++)) {
HICON hIcon = ((si->flags & MBF_DISABLED) && si->hIconDisabled) ? si->hIconDisabled : si->hIcon;
SetBkMode(hDC, TRANSPARENT);
DrawIconEx(hDC, x, (r.top + r.bottom - cy_icon) >> 1, hIcon, cx_icon, cy_icon, 0, NULL, DI_NORMAL);
x += cx_icon + gap;
}
}
void CheckStatusIconClick(MCONTACT hContact, HWND hwndFrom, POINT pt, const RECT &rc, int gap, int click_flags)
{
unsigned int iconNum = (pt.x - rc.left) / (GetSystemMetrics(SM_CXSMICON) + gap);
StatusIconData *si = Srmm_GetNthIcon(hContact, iconNum);
if (si == NULL)
return;
ClientToScreen(hwndFrom, &pt);
StatusIconClickData sicd = { sizeof(sicd) };
sicd.clickLocation = pt;
sicd.dwId = si->dwId;
sicd.szModule = si->szModule;
sicd.flags = click_flags;
NotifyEventHooks(hHookIconPressedEvt, hContact, (LPARAM)&sicd);
}
static int OnSrmmIconChanged(WPARAM hContact, LPARAM)
{
if (hContact == NULL)
WindowList_Broadcast(g_dat.hParentWindowList, DM_STATUSICONCHANGE, 0, 0);
else {
HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, hContact);
if (hwnd == NULL)
hwnd = SM_FindWindowByContact(hContact);
if (hwnd != NULL)
PostMessage(GetParent(hwnd), DM_STATUSICONCHANGE, 0, 0);
}
return 0;
}
int InitStatusIcons()
{
HookEvent(ME_MSG_ICONSCHANGED, OnSrmmIconChanged);
hHookIconPressedEvt = CreateHookableEvent(ME_MSG_ICONPRESSED);
return 0;
}
int DeinitStatusIcons()
{
DestroyHookableEvent(hHookIconPressedEvt);
return 0;
}
int GetStatusIconsCount(MCONTACT hContact)
{
int nIcon = 0;
while (Srmm_GetNthIcon(hContact, nIcon) != NULL)
nIcon++;
return nIcon;
}
|