summaryrefslogtreecommitdiff
path: root/plugins/AVS/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/AVS/src')
-rw-r--r--plugins/AVS/src/acc.cpp230
1 files changed, 111 insertions, 119 deletions
diff --git a/plugins/AVS/src/acc.cpp b/plugins/AVS/src/acc.cpp
index df1efe844b..272f55cc96 100644
--- a/plugins/AVS/src/acc.cpp
+++ b/plugins/AVS/src/acc.cpp
@@ -374,18 +374,18 @@ static LRESULT CALLBACK ACCWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
{
ACCData *data = (ACCData*)GetWindowLongPtr(hwnd, 0);
char *szProto;
+ RECT rc;
switch (msg) {
case WM_NCCREATE:
SetWindowLongPtr(hwnd, GWL_STYLE, GetWindowLongPtr(hwnd, GWL_STYLE) | BS_OWNERDRAW);
SetWindowLongPtr(hwnd, GWL_EXSTYLE, GetWindowLongPtr(hwnd, GWL_EXSTYLE) | WS_EX_TRANSPARENT);
- data = (ACCData*)mir_alloc(sizeof(ACCData));
+ data = (ACCData*)mir_calloc(sizeof(ACCData));
if (data == NULL)
return FALSE;
+
SetWindowLongPtr(hwnd, 0, (LONG_PTR)data);
-
- memset(data, 0, sizeof(ACCData));
data->hHook = HookEventMessage(ME_AV_AVATARCHANGED, hwnd, DM_AVATARCHANGED);
data->hHookMy = HookEventMessage(ME_AV_MYAVATARCHANGED, hwnd, DM_MYAVATARCHANGED);
data->hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
@@ -493,47 +493,44 @@ static LRESULT CALLBACK ACCWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
return(TRUE);
case AVATAR_GETUSEDSPACE:
- {
- int *width = (int*)wParam;
- int *height = (int*)lParam;
-
- RECT rc;
GetClientRect(hwnd, &rc);
+ {
+ int *width = (int*)wParam;
+ int *height = (int*)lParam;
+
+ // Get avatar
+ avatarCacheEntry *ace;
+ if (data->hContact == NULL)
+ ace = (avatarCacheEntry *)CallService(MS_AV_GETMYAVATAR, 0, (LPARAM)data->proto);
+ else
+ ace = (avatarCacheEntry *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)data->hContact, 0);
- // Get avatar
- avatarCacheEntry *ace;
- if (data->hContact == NULL)
- ace = (avatarCacheEntry *)CallService(MS_AV_GETMYAVATAR, 0, (LPARAM)data->proto);
- else
- ace = (avatarCacheEntry *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)data->hContact, 0);
-
- if (ace == NULL || ace->bmHeight == 0 || ace->bmWidth == 0
- || (data->respectHidden && (ace->dwFlags & AVS_HIDEONCLIST))) {
- *width = 0;
- *height = 0;
- return TRUE;
- }
+ if (ace == NULL || ace->bmHeight == 0 || ace->bmWidth == 0 || (data->respectHidden && (ace->dwFlags & AVS_HIDEONCLIST))) {
+ *width = 0;
+ *height = 0;
+ return TRUE;
+ }
- // Get its size
- int targetWidth = rc.right - rc.left;
- int targetHeight = rc.bottom - rc.top;
+ // Get its size
+ int targetWidth = rc.right - rc.left;
+ int targetHeight = rc.bottom - rc.top;
- if (!data->resizeIfSmaller && ace->bmHeight <= targetHeight && ace->bmWidth <= targetWidth) {
- *height = ace->bmHeight;
- *width = ace->bmWidth;
- }
- else if (ace->bmHeight > ace->bmWidth) {
- float dScale = targetHeight / (float)ace->bmHeight;
- *height = targetHeight;
- *width = (int)(ace->bmWidth * dScale);
- }
- else {
- float dScale = targetWidth / (float)ace->bmWidth;
- *height = (int)(ace->bmHeight * dScale);
- *width = targetWidth;
+ if (!data->resizeIfSmaller && ace->bmHeight <= targetHeight && ace->bmWidth <= targetWidth) {
+ *height = ace->bmHeight;
+ *width = ace->bmWidth;
+ }
+ else if (ace->bmHeight > ace->bmWidth) {
+ float dScale = targetHeight / (float)ace->bmHeight;
+ *height = targetHeight;
+ *width = (int)(ace->bmWidth * dScale);
+ }
+ else {
+ float dScale = targetWidth / (float)ace->bmWidth;
+ *height = (int)(ace->bmHeight * dScale);
+ *width = targetWidth;
+ }
}
- }
- return TRUE;
+ return TRUE;
case DM_AVATARCHANGED:
if (data->hContact == wParam) {
@@ -555,101 +552,97 @@ static LRESULT CALLBACK ACCWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
}
break;
- case WM_NCPAINT:
case WM_PAINT:
- {
PAINTSTRUCT ps;
- HDC hdc = BeginPaint(hwnd, &ps);
- if (hdc == NULL)
- break;
+ {
+ HDC hdc = BeginPaint(hwnd, &ps);
+ if (hdc == NULL)
+ break;
- int oldBkMode = SetBkMode(hdc, TRANSPARENT);
- SetStretchBltMode(hdc, HALFTONE);
+ int oldBkMode = SetBkMode(hdc, TRANSPARENT);
+ SetStretchBltMode(hdc, HALFTONE);
- RECT rc;
- GetClientRect(hwnd, &rc);
+ GetClientRect(hwnd, &rc);
- // Draw background
- if (data->bkgColor != -1) {
- HBRUSH hbrush = CreateSolidBrush(data->bkgColor);
- FillRect(hdc, &rc, hbrush);
- DeleteObject(hbrush);
- }
+ // Draw background
+ if (data->bkgColor != -1) {
+ HBRUSH hbrush = CreateSolidBrush(data->bkgColor);
+ FillRect(hdc, &rc, hbrush);
+ DeleteObject(hbrush);
+ }
- if (data->hContact == NULL && data->proto[0] == 0 && db_get_b(NULL, AVS_MODULE, "GlobalUserAvatarNotConsistent", 1))
- DrawText(hdc, data->hFont, rc, TranslateT("Protocols have different avatars"));
-
- // Has an animated gif
- // Has a "normal" image
- else {
- // Draw avatar
- AVATARDRAWREQUEST avdrq = { 0 };
- avdrq.cbSize = sizeof(avdrq);
- avdrq.rcDraw = rc;
- avdrq.hContact = data->hContact;
- avdrq.szProto = data->proto;
- avdrq.hTargetDC = hdc;
- avdrq.dwFlags = AVDRQ_HIDEBORDERONTRANSPARENCY
- | (data->respectHidden ? AVDRQ_RESPECTHIDDEN : 0)
- | (data->hContact != NULL ? 0 : AVDRQ_OWNPIC)
- | (data->avatarBorderColor == -1 ? 0 : AVDRQ_DRAWBORDER)
- | (data->avatarRoundCornerRadius <= 0 ? 0 : AVDRQ_ROUNDEDCORNER)
- | (data->fAero ? AVDRQ_AERO : 0)
- | (data->resizeIfSmaller ? 0 : AVDRQ_DONTRESIZEIFSMALLER);
- avdrq.clrBorder = data->avatarBorderColor;
- avdrq.radius = data->avatarRoundCornerRadius;
-
- INT_PTR ret;
- if (data->showingAnimatedGif) {
- InternalDrawAvatar(&avdrq, data->ag.hbms[data->ag.frame.num], data->ag.logicalWidth, data->ag.logicalHeight, 0);
- ret = 1;
-
- if (!data->ag.started) {
- SetTimer(hwnd, 0, data->ag.times[data->ag.frame.num], NULL);
- data->ag.started = TRUE;
+ if (data->hContact == NULL && data->proto[0] == 0 && db_get_b(NULL, AVS_MODULE, "GlobalUserAvatarNotConsistent", 1))
+ DrawText(hdc, data->hFont, rc, TranslateT("Protocols have different avatars"));
+
+ // Has an animated gif
+ // Has a "normal" image
+ else {
+ // Draw avatar
+ AVATARDRAWREQUEST avdrq = { 0 };
+ avdrq.cbSize = sizeof(avdrq);
+ avdrq.rcDraw = rc;
+ avdrq.hContact = data->hContact;
+ avdrq.szProto = data->proto;
+ avdrq.hTargetDC = hdc;
+ avdrq.dwFlags = AVDRQ_HIDEBORDERONTRANSPARENCY
+ | (data->respectHidden ? AVDRQ_RESPECTHIDDEN : 0)
+ | (data->hContact != NULL ? 0 : AVDRQ_OWNPIC)
+ | (data->avatarBorderColor == -1 ? 0 : AVDRQ_DRAWBORDER)
+ | (data->avatarRoundCornerRadius <= 0 ? 0 : AVDRQ_ROUNDEDCORNER)
+ | (data->fAero ? AVDRQ_AERO : 0)
+ | (data->resizeIfSmaller ? 0 : AVDRQ_DONTRESIZEIFSMALLER);
+ avdrq.clrBorder = data->avatarBorderColor;
+ avdrq.radius = data->avatarRoundCornerRadius;
+
+ INT_PTR ret;
+ if (data->showingAnimatedGif) {
+ InternalDrawAvatar(&avdrq, data->ag.hbms[data->ag.frame.num], data->ag.logicalWidth, data->ag.logicalHeight, 0);
+ ret = 1;
+
+ if (!data->ag.started) {
+ SetTimer(hwnd, 0, data->ag.times[data->ag.frame.num], NULL);
+ data->ag.started = TRUE;
+ }
}
- }
- else
- ret = DrawAvatarPicture(0, (LPARAM)&avdrq);
+ else ret = DrawAvatarPicture(0, (LPARAM)&avdrq);
- if (ret == 0)
- DrawText(hdc, data->hFont, rc, data->noAvatarText);
- }
+ if (ret == 0)
+ DrawText(hdc, data->hFont, rc, data->noAvatarText);
+ }
- // Draw control border
- if (data->borderColor != -1) {
- HBRUSH hbrush = CreateSolidBrush(data->borderColor);
- FrameRect(hdc, &rc, hbrush);
- DeleteObject(hbrush);
- }
+ // Draw control border
+ if (data->borderColor != -1) {
+ HBRUSH hbrush = CreateSolidBrush(data->borderColor);
+ FrameRect(hdc, &rc, hbrush);
+ DeleteObject(hbrush);
+ }
- SetBkMode(hdc, oldBkMode);
+ SetBkMode(hdc, oldBkMode);
- EndPaint(hwnd, &ps);
- }
- return TRUE;
+ EndPaint(hwnd, &ps);
+ }
+ return TRUE;
case WM_ERASEBKGND:
- {
- HDC hdc = (HDC)wParam;
- RECT rc;
GetClientRect(hwnd, &rc);
+ {
+ HDC hdc = (HDC)wParam;
+
+ // Draw background
+ if (data->bkgColor != -1) {
+ HBRUSH hbrush = CreateSolidBrush(data->bkgColor);
+ FillRect(hdc, &rc, hbrush);
+ DeleteObject(hbrush);
+ }
- // Draw background
- if (data->bkgColor != -1) {
- HBRUSH hbrush = CreateSolidBrush(data->bkgColor);
- FillRect(hdc, &rc, hbrush);
- DeleteObject(hbrush);
- }
-
- // Draw control border
- if (data->borderColor != -1) {
- HBRUSH hbrush = CreateSolidBrush(data->borderColor);
- FrameRect(hdc, &rc, hbrush);
- DeleteObject(hbrush);
+ // Draw control border
+ if (data->borderColor != -1) {
+ HBRUSH hbrush = CreateSolidBrush(data->borderColor);
+ FrameRect(hdc, &rc, hbrush);
+ DeleteObject(hbrush);
+ }
}
- }
- return TRUE;
+ return TRUE;
case WM_SIZE:
InvalidateRect(hwnd, NULL, TRUE);
@@ -689,7 +682,6 @@ int LoadACC()
wc.lpfnWndProc = ACCWndProc;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.cbWndExtra = sizeof(ACCData*);
- wc.hbrBackground = 0;
wc.style = CS_GLOBALCLASS;
RegisterClassEx(&wc);
return 0;