summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tipper/popwin.cpp87
-rw-r--r--tipper/tipper.cpp4
-rw-r--r--tipper/tipper.mdsp8
-rw-r--r--tipper/tipper.rc2
-rw-r--r--tipper/version.h2
5 files changed, 75 insertions, 28 deletions
diff --git a/tipper/popwin.cpp b/tipper/popwin.cpp
index d217883..4912c96 100644
--- a/tipper/popwin.cpp
+++ b/tipper/popwin.cpp
@@ -37,6 +37,7 @@ struct PopupWindowData {
bool text_tip;
int indent, sb_width;
POINT start_cursor_pos; // work around bugs with hiding tips (timer check mouse position)
+ HBITMAP hBm;
};
LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
@@ -256,6 +257,16 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
else _tcscpy(pwd->swzTitle, TranslateT("(Unknown)"));
}
+ //get avatar if possible
+ char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)pwd->hContact, 0);
+ if(proto) {
+ char svc[256];
+ mir_snprintf(svc, 256, "%s%s", proto, PS_GETAVATARINFO);
+ PROTO_AVATAR_INFORMATION AI = {0};
+ AI.cbSize = sizeof(AI);
+ AI.hContact = pwd->hContact;
+ CallService(svc, (WPARAM)GAIF_FORCE, (LPARAM)&AI);
+ }
SendMessage(hwnd, PUM_REFRESH_VALUES, 0, 0);
}
}
@@ -374,7 +385,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
SetBkMode(hdc, TRANSPARENT);
// avatar
- if(!pwd->text_tip && options.av_layout != PAV_NONE && pwd->av_height) {
+ if(!pwd->text_tip && options.av_layout != PAV_NONE && pwd->av_height && pwd->hBm) {
RECT avr;
avr.top = options.av_padding;
@@ -390,19 +401,47 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
avr.bottom = avr.top + pwd->real_av_height;
- AVATARDRAWREQUEST adr = {0};
- adr.cbSize = sizeof(adr);
- adr.hContact = pwd->hContact;
- adr.hTargetDC = ps.hdc;
- adr.rcDraw = avr;
- adr.dwFlags = (options.av_round ? AVDRQ_ROUNDEDCORNER : 0);
- if(!pwd->hContact) { // status bar tip?
- adr.dwFlags |= AVDRQ_OWNPIC;
- adr.szProto = pwd->clcit.proto;
- }
- adr.radius = (options.av_round ? 5 : 0);
-
- CallService(MS_AV_DRAWAVATAR, 0, (LPARAM)&adr);
+ HDC hdcMem = CreateCompatibleDC(hdc);
+ HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem, pwd->hBm);
+ BITMAP bm;
+
+ GetObject(pwd->hBm, sizeof(bm), &bm);
+ HRGN rgn = 0;
+ if(options.av_round) {
+ rgn = CreateRoundRectRgn(avr.left, avr.top, avr.right + 1, avr.bottom + 1, 10, 10);
+ SelectClipRgn(hdc, rgn);
+ }
+
+ if(options.no_resize_av) {
+ BitBlt(hdc, avr.left, avr.top, avr.right - avr.left, avr.bottom - avr.top, hdcMem, 0, 0, SRCCOPY);
+ } else {
+ SetStretchBltMode(hdc, HALFTONE);
+ StretchBlt(hdc, avr.left, avr.top, avr.right - avr.left, avr.bottom - avr.top, hdcMem, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
+ }
+
+ if(rgn) {
+ SelectClipRgn(hdc, 0);
+ DeleteObject(rgn);
+ }
+
+ SelectObject(hdcMem, hbmOld);
+ DeleteDC(hdcMem);
+
+ /*
+ AVATARDRAWREQUEST adr = {0};
+ adr.cbSize = sizeof(adr);
+ adr.hContact = pwd->hContact;
+ adr.hTargetDC = ps.hdc;
+ adr.rcDraw = avr;
+ adr.dwFlags = (options.av_round ? AVDRQ_ROUNDEDCORNER : 0);// | (options.no_resize_av ? AVDRQ_DONTRESIZEIFSMALLER : 0);
+ if(!pwd->hContact) { // status bar tip?
+ adr.dwFlags |= AVDRQ_OWNPIC;
+ adr.szProto = pwd->clcit.proto;
+ }
+ adr.radius = (options.av_round ? 5 : 0);
+
+ CallService(MS_AV_DRAWAVATAR, 0, (LPARAM)&adr);
+ */
}
RECT tr;
@@ -538,6 +577,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
}
free(pwd->rows);
+ if(pwd->hBm) DeleteObject(pwd->hBm);
free(pwd); pwd = 0;
SetWindowLong(hwnd, GWL_USERDATA, 0);
}
@@ -688,16 +728,21 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
AVATARCACHEENTRY *ace = 0;
if(pwd->hContact) ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)pwd->hContact, 0);
else ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETMYAVATAR, 0, (LPARAM)pwd->clcit.proto);
+
if(ace && (ace->dwFlags & AVS_BITMAP_VALID) && !(ace->dwFlags & AVS_HIDEONCLIST)) {
- if(options.no_resize_av) {
- pwd->real_av_width = ace->bmWidth;
- pwd->real_av_height = ace->bmHeight;
+ if(pwd->hBm) DeleteObject(pwd->hBm);
+ pwd->hBm = (HBITMAP)CallService(MS_UTILS_LOADBITMAP,0,(LPARAM)ace->szFilename);
+ BITMAP bm;
+ GetObject(pwd->hBm, sizeof(bm), &bm);
+ if(options.no_resize_av || (bm.bmHeight <= options.av_size && bm.bmWidth <= options.av_size)) {
+ pwd->real_av_width = bm.bmWidth;
+ pwd->real_av_height = bm.bmHeight;
} else {
- if(ace->bmHeight >= ace->bmWidth) {
+ if(bm.bmHeight >= bm.bmWidth) {
pwd->real_av_height = options.av_size;
- pwd->real_av_width = (int)(options.av_size * (ace->bmWidth / (double)ace->bmHeight));
+ pwd->real_av_width = (int)(options.av_size * (bm.bmWidth / (double)bm.bmHeight));
} else {
- pwd->real_av_height = (int)(options.av_size * (ace->bmHeight / (double)ace->bmWidth));
+ pwd->real_av_height = (int)(options.av_size * (bm.bmHeight / (double)bm.bmWidth));
pwd->real_av_width = options.av_size;
}
}
@@ -759,7 +804,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
if(width < options.win_width) {
int wid = options.padding + pwd->indent + (pwd->rows[i].value_newline ? max(size.cx, smr.right - smr.left) : pwd->label_width + options.padding + (smr.right - smr.left));
if(pwd->tb_height + pwd->text_height + options.text_padding < pwd->av_height)
- width = max(width, wid + options.av_size + 2 * options.av_padding);
+ width = max(width, wid + pwd->real_av_width + 2 * options.av_padding);
else
width = max(width, wid + options.padding);
}
diff --git a/tipper/tipper.cpp b/tipper/tipper.cpp
index 953e8e9..ca6690f 100644
--- a/tipper/tipper.cpp
+++ b/tipper/tipper.cpp
@@ -22,7 +22,7 @@ ColourIDW colour_id_bgw = {0}, colour_id_borderw = {0}, colour_id_dividerw = {0}
HFONT hFontTitle = 0, hFontLabels = 0, hFontValues = 0;
// hooked here so it's in the main thread
-HANDLE hAvChangeEvent = 0, hShowTipEvent = 0, hHideTipEvent = 0, hAckEvent = 0, hFramesSBShow = 0, hFramesSBHide = 0, hSettingChangedEvent = 0;
+HANDLE hAvChangeEvent = 0, hAvContactChangeEvent = 0, hShowTipEvent = 0, hHideTipEvent = 0, hAckEvent = 0, hFramesSBShow = 0, hFramesSBHide = 0, hSettingChangedEvent = 0;
HANDLE hShowTipService = 0, hShowTipWService = 0, hHideTipService = 0;
@@ -358,6 +358,7 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) {
}
hAvChangeEvent = HookEvent(ME_AV_AVATARCHANGED, AvatarChanged);
+ hAvContactChangeEvent = HookEvent(ME_AV_CONTACTAVATARCHANGED, AvatarChanged);
hShowTipEvent = HookEvent(ME_CLC_SHOWINFOTIP, ShowTip);
hHideTipEvent = HookEvent(ME_CLC_HIDEINFOTIP, HideTip);
hAckEvent = HookEvent(ME_PROTO_ACK, ProtoAck);
@@ -377,6 +378,7 @@ int Shutdown(WPARAM wParam, LPARAM lParam) {
if(hFramesSBShow) UnhookEvent(hFramesSBShow);
if(hFramesSBHide) UnhookEvent(hFramesSBHide);
if(hAvChangeEvent) UnhookEvent(hAvChangeEvent);
+ if(hAvContactChangeEvent) UnhookEvent(hAvContactChangeEvent);
if(hShowTipEvent) UnhookEvent(hShowTipEvent);
if(hHideTipEvent) UnhookEvent(hHideTipEvent);
if(hAckEvent) UnhookEvent(hAckEvent);
diff --git a/tipper/tipper.mdsp b/tipper/tipper.mdsp
index 9ea4ca4..66a1325 100644
--- a/tipper/tipper.mdsp
+++ b/tipper/tipper.mdsp
@@ -108,11 +108,11 @@ extraResourceOptions=
options.cpp,637
version.h,519
m_tipper.h,760
-popwin.cpp,4146
-tipper.cpp,1265
+popwin.cpp,4094
+tipper.cpp,1262
message_pump.cpp,0
..\..\include\m_imgsrvc.h,1413
-common.h,1379
+common.h,1362
..\..\..\..\..\..\..\msys\include\windows.h,0
..\..\..\..\..\..\..\msys\include\wingdi.h,0
-..\..\plugins\freeimage\Miranda\include\m_freeimage.h,4153
+..\..\plugins\freeimage\Miranda\include\m_freeimage.h,4431
diff --git a/tipper/tipper.rc b/tipper/tipper.rc
index 4d0eed9..dd4330a 100644
--- a/tipper/tipper.rc
+++ b/tipper/tipper.rc
@@ -95,7 +95,7 @@ BEGIN
RTEXT "Avatar padding:",IDC_STATIC,143,53,59,8
EDITTEXT IDC_ED_AVSIZE,209,96,35,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT
CONTROL "",IDC_SPIN_AVSIZE,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,242,96,11,12
- RTEXT "Avatar size:",IDC_STATIC,145,98,60,8,0,WS_EX_RIGHT
+ RTEXT "Max avatar size:",IDC_STATIC,145,98,60,8,0,WS_EX_RIGHT
CONTROL "Keep original avatar size",IDC_CHK_NORESIZEAV,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,147,84,103,11
RTEXT "Background image:",IDC_STATIC,8,127,89,8
EDITTEXT IDC_ED_BGFN,100,125,96,12,ES_AUTOHSCROLL
diff --git a/tipper/version.h b/tipper/version.h
index 0077605..03c5b27 100644
--- a/tipper/version.h
+++ b/tipper/version.h
@@ -4,7 +4,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 4
#define __RELEASE_NUM 1
-#define __BUILD_NUM 0
+#define __BUILD_NUM 2
#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
#define __FILEVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM