From 8a4d920ac00055a4ae15bafcce0e696abea9d6b1 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 4 Aug 2014 20:19:21 +0000 Subject: - AvatarChanged finally destroyed; - info panel's size calculation moved to WM_SIZE handler; - many drawing glitches fixed git-svn-id: http://svn.miranda-ng.org/main/trunk@10056 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TabSRMM/src/chat/window.cpp | 3 +- plugins/TabSRMM/src/functions.h | 1 - plugins/TabSRMM/src/globals.cpp | 5 +- plugins/TabSRMM/src/infopanel.cpp | 7 +- plugins/TabSRMM/src/msgdialog.cpp | 115 ++++++++++++++++-------------- plugins/TabSRMM/src/msgdlgutils.cpp | 135 ++++++++++-------------------------- plugins/TabSRMM/src/msgs.cpp | 36 ---------- plugins/TabSRMM/src/msgs.h | 2 +- plugins/TabSRMM/src/userprefs.cpp | 1 - 9 files changed, 103 insertions(+), 202 deletions(-) diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index 33da2d71cf..cf12f38349 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -2463,14 +2463,13 @@ LABEL_SHOWWINDOW: GetClientRect(GetDlgItem(hwndDlg, IDC_CHAT_LOG), &rc); if ((pt.y + 2 >= MIN_PANELHEIGHT + 2) && (pt.y + 2 < 100) && (pt.y + 2 < rc.bottom - 30)) dat->Panel->setHeight(pt.y + 2); - dat->panelWidth = -1; RedrawWindow(hwndDlg, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); if (M.isAero()) InvalidateRect(GetParent(hwndDlg), NULL, FALSE); SendMessage(hwndDlg, WM_SIZE, DM_SPLITTERMOVED, 0); break; } - } + } break; case GC_FIREHOOK: diff --git a/plugins/TabSRMM/src/functions.h b/plugins/TabSRMM/src/functions.h index c494f33dc2..e9ea3c884a 100644 --- a/plugins/TabSRMM/src/functions.h +++ b/plugins/TabSRMM/src/functions.h @@ -33,7 +33,6 @@ #ifndef _TABSRMM_FUNCTIONS_H #define _TABSRMM_FUNCTIONS_H -int AvatarChanged(WPARAM wParam, LPARAM lParam); int MyAvatarChanged(WPARAM wParam, LPARAM lParam); int IconsChanged(WPARAM wParam, LPARAM lParam); int IcoLibIconsChanged(WPARAM wParam, LPARAM lParam); diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp index c909370dbb..61508ecf94 100644 --- a/plugins/TabSRMM/src/globals.cpp +++ b/plugins/TabSRMM/src/globals.cpp @@ -271,7 +271,6 @@ void CGlobals::hookSystemEvents() HookEvent(ME_SKIN2_ICONSCHANGED, ::IcoLibIconsChanged); HookEvent(ME_AV_MYAVATARCHANGED, ::MyAvatarChanged); - HookEvent(ME_AV_AVATARCHANGED, ::AvatarChanged); } int CGlobals::TopToolbarLoaded(WPARAM,LPARAM) @@ -517,10 +516,8 @@ int CGlobals::PreshutdownSendRecv(WPARAM wParam, LPARAM lParam) ::SI_DeinitStatusIcons(); ::CB_DeInitCustomButtons(); - /* - * the event API - */ + // the event API DestroyHookableEvent(PluginConfig.m_event_MsgWin); DestroyHookableEvent(PluginConfig.m_event_MsgPopup); DestroyHookableEvent(PluginConfig.m_event_WriteEvent); diff --git a/plugins/TabSRMM/src/infopanel.cpp b/plugins/TabSRMM/src/infopanel.cpp index 06878b606e..beb3ddfdd1 100644 --- a/plugins/TabSRMM/src/infopanel.cpp +++ b/plugins/TabSRMM/src/infopanel.cpp @@ -58,7 +58,7 @@ int CInfoPanel::setPanelHandler(TWindowData *dat, WPARAM wParam, LPARAM lParam) if (dat->pContainer->settings->fPrivate && srcDat->pContainer != dat->pContainer) return 0; - dat->panelWidth = -1; + dat->Panel->setHeight((LONG)lParam); } } @@ -1202,7 +1202,7 @@ INT_PTR CALLBACK CInfoPanel::ConfigDlgProc(HWND hwnd, UINT msg, WPARAM wParam, L db_unset(m_dat->hContact, SRMSGMOD_T, "hideavatar"); else db_set_b(m_dat->hContact, SRMSGMOD_T, "hideavatar", vNew); - m_dat->panelWidth = -1; + ::ShowPicture(m_dat, FALSE); ::SendMessage(m_dat->hwnd, WM_SIZE, 0, 0); ::DM_ScrollToBottom(m_dat, 0, 1); @@ -1256,7 +1256,6 @@ INT_PTR CALLBACK CInfoPanel::ConfigDlgProc(HWND hwnd, UINT msg, WPARAM wParam, L if (m_height != lOldHeight) { ::SendMessage(m_dat->hwnd, WM_SIZE, 0, 0); - m_dat->panelWidth = -1; ::SetAeroMargins(m_dat->pContainer); ::RedrawWindow(m_dat->hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW); ::RedrawWindow(GetParent(m_dat->hwnd), NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW); @@ -1294,7 +1293,7 @@ int CInfoPanel::invokeConfigDialog(const POINT& pt) RECT rc; ::GetWindowRect(m_dat->hwnd, &rc); rc.bottom = rc.top + m_height; - rc.right -= m_dat->panelWidth; + rc.right -= m_dat->iPanelAvatarX; POINT ptTest = pt; if (!::PtInRect(&rc, ptTest)) diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index 6499e89f8d..f3d22f183a 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -902,7 +902,6 @@ LRESULT CALLBACK SplitterSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM DM_ScrollToBottom(dat, 0, 1); if (dat && dat->bType == SESSIONTYPE_IM && hwnd == GetDlgItem(hwndParent, IDC_PANELSPLITTER)) { SendMessage(hwndParent, WM_SIZE, 0, 0); - dat->panelWidth = -1; RedrawWindow(hwndParent, NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW); } else if ((dat && dat->bType == SESSIONTYPE_IM && hwnd == GetDlgItem(hwndParent, IDC_SPLITTER)) || @@ -1299,7 +1298,6 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP dat->bIsAutosizingInput = IsAutoSplitEnabled(dat); dat->iInputAreaHeight = -1; SetMessageLog(dat); - dat->panelWidth = -1; if (dat->hContact) { dat->codePage = M.GetDword(dat->hContact, "ANSIcodepage", CP_ACP); dat->Panel->loadHeight(); @@ -1630,59 +1628,70 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP BB_SetButtonsPos(dat); // size info panel fields - LONG cx = rc.right; - LONG panelHeight = dat->Panel->getHeight(); - LONG panelWidth = (dat->panelWidth != -1 ? dat->panelWidth : 0); - - rc.top = 1; - rc.left = cx - (panelWidth > 0 ? panelWidth : panelHeight); - rc.bottom = rc.top + (panelHeight - 3); - rc.right = cx; - rc.bottom--; - - if (dat->bShowInfoAvatar) { - SetWindowPos(dat->hwndPanelPicParent, HWND_TOP, rc.left - 2, rc.top, rc.right - rc.left, (rc.bottom - rc.top) + 1, 0); - ShowWindow(dat->hwndPanelPicParent, (dat->panelWidth == -1) || !dat->Panel->isActive() ? SW_HIDE : SW_SHOW); - } - else ShowWindow(dat->hwndPanelPicParent, SW_HIDE); - - dat->rcPic = rc; - - rc.right = cx - panelWidth; - rc.left = cx - panelWidth - dat->panelStatusCX; - rc.bottom = panelHeight - 3; - rc.top = rc.bottom - dat->ipFieldHeight; - dat->rcStatus = rc; - - rc.left = CInfoPanel::LEFT_OFFSET_LOGO; - rc.right = cx - dat->panelWidth - (panelHeight < CInfoPanel::DEGRADE_THRESHOLD ? (dat->rcStatus.right - dat->rcStatus.left) + 3 : 0); - rc.bottom = panelHeight - (panelHeight >= CInfoPanel::DEGRADE_THRESHOLD ? dat->ipFieldHeight : 0) - 1; - rc.top = 1; - dat->rcNick = rc; - - rc.left = CInfoPanel::LEFT_OFFSET_LOGO; - rc.right = cx - (dat->panelWidth + 2) - dat->panelStatusCX; - rc.bottom = panelHeight - 3; - rc.top = rc.bottom - dat->ipFieldHeight; - dat->rcUIN = rc; - - if (GetDlgItem(hwndDlg, IDC_CLIST) != 0) { - RECT rc, rcClient, rcLog; - GetClientRect(hwndDlg, &rcClient); - GetClientRect(GetDlgItem(hwndDlg, IDC_LOG), &rcLog); - rc.top = 0; - rc.right = rcClient.right; - rc.left = rcClient.right - dat->multiSplitterX; - rc.bottom = rcLog.bottom; - if (dat->Panel->isActive()) - rc.top += (dat->Panel->getHeight() + 1); - MoveWindow(GetDlgItem(hwndDlg, IDC_CLIST), rc.left, rc.top, rc.right - rc.left, rcLog.bottom - rcLog.top, FALSE); - } + if (dat->Panel->isActive()) { + LONG cx = rc.right; + LONG panelHeight = dat->Panel->getHeight(); + + hbm = (m_pContainer->avatarMode == 3) ? dat->hOwnPic : (dat->ace ? dat->ace->hbmPic : PluginConfig.g_hbmUnknown); + double dHeight = 0, dWidth = 0; + Utils::scaleAvatarHeightLimited(hbm, dWidth, dHeight, panelHeight); + + LONG panelAvatarWidth = dat->iPanelAvatarX = (int)dWidth; + dat->iPanelAvatarY = (int)dHeight; + + rc.top = 1; + rc.left = cx - (panelAvatarWidth > 0 ? panelAvatarWidth : panelHeight); + rc.bottom = rc.top + (panelHeight - 3); + rc.right = cx; + rc.bottom--; + + if (dat->bShowInfoAvatar) { + SetWindowPos(dat->hwndPanelPicParent, HWND_TOP, rc.left - 2, rc.top, rc.right - rc.left, (rc.bottom - rc.top) + 1, 0); + ShowWindow(dat->hwndPanelPicParent, (dat->iPanelAvatarX == 0) || !dat->Panel->isActive() ? SW_HIDE : SW_SHOW); + } + else { + ShowWindow(dat->hwndPanelPicParent, SW_HIDE); + panelAvatarWidth = dat->iPanelAvatarX = dat->iPanelAvatarY = 0; + } + + dat->rcPic = rc; + + rc.right = cx - panelAvatarWidth; + rc.left = cx - panelAvatarWidth - dat->panelStatusCX; + rc.bottom = panelHeight - 3; + rc.top = rc.bottom - dat->ipFieldHeight; + dat->rcStatus = rc; + + rc.left = CInfoPanel::LEFT_OFFSET_LOGO; + rc.right = cx - dat->iPanelAvatarX - (panelHeight < CInfoPanel::DEGRADE_THRESHOLD ? (dat->rcStatus.right - dat->rcStatus.left) + 3 : 0); + rc.bottom = panelHeight - (panelHeight >= CInfoPanel::DEGRADE_THRESHOLD ? dat->ipFieldHeight : 0) - 1; + rc.top = 1; + dat->rcNick = rc; + + rc.left = CInfoPanel::LEFT_OFFSET_LOGO; + rc.right = cx - (dat->iPanelAvatarX + 2) - dat->panelStatusCX; + rc.bottom = panelHeight - 3; + rc.top = rc.bottom - dat->ipFieldHeight; + dat->rcUIN = rc; + + if (GetDlgItem(hwndDlg, IDC_CLIST) != 0) { + RECT rc, rcClient, rcLog; + GetClientRect(hwndDlg, &rcClient); + GetClientRect(GetDlgItem(hwndDlg, IDC_LOG), &rcLog); + rc.top = 0; + rc.right = rcClient.right; + rc.left = rcClient.right - dat->multiSplitterX; + rc.bottom = rcLog.bottom; + if (dat->Panel->isActive()) + rc.top += (dat->Panel->getHeight() + 1); + MoveWindow(GetDlgItem(hwndDlg, IDC_CLIST), rc.left, rc.top, rc.right - rc.left, rcLog.bottom - rcLog.top, FALSE); + } + dat->Panel->Invalidate(); + } if (dat->hwndIEView || dat->hwndHPP) ResizeIeView(dat, 0, 0, 0, 0); - dat->Panel->Invalidate(); DetermineMinHeight(dat); } break; @@ -2305,7 +2314,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP ScreenToClient(hwndDlg, &pt); if ((pt.y + 2 >= MIN_PANELHEIGHT + 2) && (pt.y + 2 < 100) && (pt.y + 2 < rc.bottom - 30)) dat->Panel->setHeight(pt.y + 2, true); - dat->panelWidth = -1; + RedrawWindow(hwndDlg, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); if (M.isAero()) InvalidateRect(GetParent(hwndDlg), NULL, FALSE); @@ -3081,7 +3090,7 @@ quote_from_last: case DM_PROTOAVATARCHANGED: dat->ace = Utils::loadAvatarFromAVS(dat->hContact); - dat->panelWidth = -1; // force new size calculations + ShowPicture(dat, TRUE); if (dat->Panel->isActive()) SendMessage(hwndDlg, WM_SIZE, 0, 0); diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp index b6faa067d4..c0f1bf62d6 100644 --- a/plugins/TabSRMM/src/msgdlgutils.cpp +++ b/plugins/TabSRMM/src/msgdlgutils.cpp @@ -217,24 +217,19 @@ void TSAPI FlashTab(TWindowData *dat, HWND hwndTab, int iTabindex, BOOL *bState, void TSAPI CalcDynamicAvatarSize(TWindowData *dat, BITMAP *bminfo) { + if (dat->dwFlags & MWF_WASBACKGROUNDCREATE || dat->pContainer->dwFlags & CNT_DEFERREDCONFIGURE || dat->pContainer->dwFlags & CNT_CREATE_MINIMIZED || IsIconic(dat->pContainer->hwnd)) + return; // at this stage, the layout is not yet ready... + RECT rc; - double aspect = 0, newWidth = 0, picAspect = 0; - double picProjectedWidth = 0; + GetClientRect(dat->hwnd, &rc); + BOOL bBottomToolBar = dat->pContainer->dwFlags & CNT_BOTTOMTOOLBAR; BOOL bToolBar = dat->pContainer->dwFlags & CNT_HIDETOOLBAR ? 0 : 1; bool bInfoPanel = dat->Panel->isActive(); int iSplitOffset = dat->bIsAutosizingInput ? 1 : 0; - GetClientRect(dat->hwnd, &rc); - - if (dat->dwFlags & MWF_WASBACKGROUNDCREATE || dat->pContainer->dwFlags & CNT_DEFERREDCONFIGURE || dat->pContainer->dwFlags & CNT_CREATE_MINIMIZED || IsIconic(dat->pContainer->hwnd)) - return; // at this stage, the layout is not yet ready... - - if (bminfo->bmWidth == 0 || bminfo->bmHeight == 0) - picAspect = 1.0; - else - picAspect = (double)(bminfo->bmWidth / (double)bminfo->bmHeight); - picProjectedWidth = (double)((dat->dynaSplitter - ((bBottomToolBar && bToolBar) ? DPISCALEX_S(24) : 0) + ((dat->showUIElements != 0) ? DPISCALEX_S(28) : DPISCALEX_S(2)))) * picAspect; + double picAspect = (bminfo->bmWidth == 0 || bminfo->bmHeight == 0) ? 1.0 : (double)(bminfo->bmWidth / (double)bminfo->bmHeight); + double picProjectedWidth = (double)((dat->dynaSplitter - ((bBottomToolBar && bToolBar) ? DPISCALEX_S(24) : 0) + ((dat->showUIElements != 0) ? DPISCALEX_S(28) : DPISCALEX_S(2)))) * picAspect; if ((rc.right - (int)picProjectedWidth) > (dat->iButtonBarReallyNeeds) && !PluginConfig.m_AlwaysFullToolbarWidth && bToolBar) dat->iRealAvatarHeight = dat->dynaSplitter + 3 + (dat->showUIElements ? DPISCALEY_S(28) : DPISCALEY_S(2)); @@ -249,12 +244,8 @@ void TSAPI CalcDynamicAvatarSize(TWindowData *dat, BITMAP *bminfo) if (M.GetByte(dat->hContact, "dontscaleavatars", M.GetByte("dontscaleavatars", 0))) dat->iRealAvatarHeight = min(bminfo->bmHeight, dat->iRealAvatarHeight); - if (bminfo->bmHeight != 0) - aspect = (double)dat->iRealAvatarHeight / (double)bminfo->bmHeight; - else - aspect = 1; - - newWidth = (double)bminfo->bmWidth * aspect; + double aspect = (bminfo->bmHeight != 0) ? (double)dat->iRealAvatarHeight / (double)bminfo->bmHeight : 1.0; + double newWidth = (double)bminfo->bmWidth * aspect; if (newWidth > (double)(rc.right) * 0.8) newWidth = (double)(rc.right) * 0.8; dat->pic.cy = dat->iRealAvatarHeight + 2; @@ -369,7 +360,7 @@ int TSAPI MsgWindowMenuHandler(TWindowData *dat, int selection, int menuId) avOverrideMode = 1; db_set_b(dat->hContact, SRMSGMOD_T, "hideavatar", avOverrideMode); } - dat->panelWidth = -1; + ShowPicture(dat, FALSE); SendMessage(hwndDlg, WM_SIZE, 0, 0); DM_ScrollToBottom(dat, 0, 1); @@ -594,7 +585,7 @@ bool TSAPI GetAvatarVisibility(HWND hwndDlg, TWindowData *dat) Utils::setAvatarContact(dat->hwndPanelPic, dat->hContact); } - SendMessage(dat->hwndContactPic, AVATAR_SETPROTOCOL, 0, (LPARAM)dat->szProto); + SendMessage(dat->hwndContactPic, AVATAR_SETPROTOCOL, 0, (LPARAM)dat->cache->getActiveProto()); } else { dat->bShowInfoAvatar = false; @@ -627,7 +618,7 @@ bool TSAPI GetAvatarVisibility(HWND hwndDlg, TWindowData *dat) return false; if (dat->hwndPanelPic) { // shows contact or user picture, depending on panel visibility - SendMessage(dat->hwndContactPic, AVATAR_SETPROTOCOL, 0, (LPARAM)dat->szProto); + SendMessage(dat->hwndContactPic, AVATAR_SETPROTOCOL, 0, (LPARAM)dat->cache->getActiveProto()); Utils::setAvatarContact(dat->hwndPanelPic, dat->hContact); } else Utils::setAvatarContact(dat->hwndContactPic, dat->hContact); @@ -749,7 +740,6 @@ void TSAPI ShowPicture(TWindowData *dat, BOOL showNewPic) if (showNewPic) { if (dat->Panel->isActive() && dat->pContainer->avatarMode != 3) { if (!dat->hwndPanelPic) { - dat->panelWidth = -1; InvalidateRect(dat->hwnd, NULL, TRUE); UpdateWindow(dat->hwnd); SendMessage(dat->hwnd, WM_SIZE, 0, 0); @@ -1525,29 +1515,19 @@ int TSAPI MsgWindowDrawHandler(WPARAM wParam, LPARAM lParam, TWindowData *dat) if (hbmAvatar == NULL) return TRUE; - BITMAP bminfo; - double dAspect = 0, dNewWidth = 0, dNewHeight = 0; - DWORD iMaxHeight = 0, top, cx, cy; - RECT rc, rcClient, rcFrame; + int iMaxHeight = 0, top, cx, cy; + RECT rcClient, rcFrame; bool bPanelPic = dis->hwndItem == hwndDlg; DWORD aceFlags = 0; - HRGN clipRgn = 0; - int iRad = PluginConfig.m_WinVerMajor >= 5 ? 4 : 6; bool bDrawOwnAvatar = dat->Panel->isActive() && dat->pContainer->avatarMode != 3; + BITMAP bminfo; if (bPanelPic) { - GetObject(hbmAvatar, sizeof(bminfo), &bminfo); - - if ((dat->ace && dat->bShowInfoAvatar && !(dat->ace->dwFlags & AVS_HIDEONCLIST)) || dat->bShowInfoAvatar) - aceFlags = dat->ace ? dat->ace->dwFlags : 0; - else { - if (dat->panelWidth) { - dat->panelWidth = -1; - if (!CSkin::m_skinEnabled) - SendMessage(hwndDlg, WM_SIZE, 0, 0); - } + if (!dat->bShowInfoAvatar) return TRUE; - } + + aceFlags = dat->ace ? dat->ace->dwFlags : 0; + GetObject(hbmAvatar, sizeof(bminfo), &bminfo); } else { if (!bDrawOwnAvatar) { @@ -1560,6 +1540,7 @@ int TSAPI MsgWindowDrawHandler(WPARAM wParam, LPARAM lParam, TWindowData *dat) GetObject(bDrawOwnAvatar ? dat->hOwnPic : hbmAvatar, sizeof(bminfo), &bminfo); } + RECT rc; GetClientRect(hwndDlg, &rc); if (bPanelPic) { rcClient = dis->rcItem; @@ -1575,45 +1556,13 @@ int TSAPI MsgWindowDrawHandler(WPARAM wParam, LPARAM lParam, TWindowData *dat) if (cx < 5 || cy < 5) return TRUE; - if (bPanelPic) { - if (bminfo.bmHeight > bminfo.bmWidth) { - if (bminfo.bmHeight > 0) - dAspect = (double)(cy /*- 2*/) / (double)bminfo.bmHeight; - else - dAspect = 1.0; - dNewWidth = (double)bminfo.bmWidth * dAspect; - dNewHeight = cy;// - 2; - } - else { - if (bminfo.bmWidth > 0) - dAspect = (double)(cy /*- 2*/) / (double)bminfo.bmWidth; - else - dAspect = 1.0; - dNewHeight = (double)bminfo.bmHeight * dAspect; - dNewWidth = cy;// - 2; - } - if (dat->panelWidth == -1) { - dat->panelWidth = (int)dNewWidth; - return 0; - } - } - else { - if (bminfo.bmHeight > 0) - dAspect = (double)dat->iRealAvatarHeight / (double)bminfo.bmHeight; - else - dAspect = 1.0; - dNewWidth = (double)bminfo.bmWidth * dAspect; - if (dNewWidth > (double)(rc.right) * 0.8) - dNewWidth = (double)(rc.right) * 0.8; - iMaxHeight = dat->iRealAvatarHeight; - } - HDC hdcDraw = CreateCompatibleDC(dis->hDC); HBITMAP hbmDraw = CreateCompatibleBitmap(dis->hDC, cx, cy); HBITMAP hbmOld = (HBITMAP)SelectObject(hdcDraw, hbmDraw); bool bAero = M.isAero(); + HRGN clipRgn = 0; HBRUSH hOldBrush = (HBRUSH)SelectObject(hdcDraw, bAero ? (HBRUSH)GetStockObject(HOLLOW_BRUSH) : GetSysColorBrush(COLOR_3DFACE)); rcFrame = rcClient; @@ -1645,6 +1594,7 @@ int TSAPI MsgWindowDrawHandler(WPARAM wParam, LPARAM lParam, TWindowData *dat) if (CSkin::m_bAvatarBorderType == 1) Rectangle(hdcDraw, rcEdge.left, rcEdge.top, rcEdge.right, rcEdge.bottom); else if (CSkin::m_bAvatarBorderType == 2) { + int iRad = PluginConfig.m_WinVerMajor >= 5 ? 4 : 6; clipRgn = CreateRoundRectRgn(rcEdge.left, rcEdge.top, rcEdge.right + 1, rcEdge.bottom + 1, iRad, iRad); SelectClipRgn(hdcDraw, clipRgn); } @@ -1654,46 +1604,31 @@ int TSAPI MsgWindowDrawHandler(WPARAM wParam, LPARAM lParam, TWindowData *dat) } if (((bDrawOwnAvatar ? dat->hOwnPic : hbmAvatar) && dat->bShowAvatar) || bPanelPic) { - HDC hdcMem = CreateCompatibleDC(dis->hDC); - HBITMAP hbmMem = 0; if (bPanelPic) { - bool bBorder = (CSkin::m_bAvatarBorderType ? true : false); - - LONG height_off = 0; - LONG border_off = bBorder ? 1 : 0; + bool bBorder = (CSkin::m_bAvatarBorderType ? true : false); - ResizeBitmap rb; - rb.size = sizeof(rb); - rb.fit = RESIZEBITMAP_STRETCH; - rb.max_height = (int)(dNewHeight - (bBorder ? 2 : 0)); - rb.max_width = (int)(dNewWidth - (bBorder ? 2 : 0)); - rb.hBmp = hbmAvatar; - - HBITMAP hbmNew = (HBITMAP)CallService(MS_IMG_RESIZE, (WPARAM)&rb, 0); - hbmMem = (HBITMAP)SelectObject(hdcMem, hbmNew); + int border_off = bBorder ? 1 : 0; + int iMaxHeight = dat->iPanelAvatarY - (bBorder ? 2 : 0); + int iMaxWidth = dat->iPanelAvatarX - (bBorder ? 2 : 0); rcFrame.left = rcFrame.top = 0; rcFrame.right = (rcClient.right - rcClient.left); rcFrame.bottom = (rcClient.bottom - rcClient.top); - rcFrame.left = rcFrame.right - (LONG)dNewWidth; - rcFrame.bottom = (LONG)dNewHeight; + rcFrame.left = rcFrame.right - (LONG)dat->iPanelAvatarX; + rcFrame.bottom = (LONG)dat->iPanelAvatarY; - height_off = ((cy)-(rb.max_height + (bBorder ? 2 : 0))) / 2; + int height_off = (cy - iMaxHeight - (bBorder ? 2 : 0)) / 2; rcFrame.top += height_off; rcFrame.bottom += height_off; SendMessage(dat->hwndPanelPic, AVATAR_SETAEROCOMPATDRAWING, 0, bAero ? TRUE : FALSE); SetWindowPos(dat->hwndPanelPic, HWND_TOP, rcFrame.left + border_off, rcFrame.top + border_off, - rb.max_width, rb.max_height, SWP_SHOWWINDOW | SWP_ASYNCWINDOWPOS | SWP_DEFERERASE | SWP_NOSENDCHANGING); - - SelectObject(hdcMem, hbmMem); - DeleteDC(hdcMem); - if (hbmNew != hbmAvatar) - DeleteObject(hbmNew); + iMaxWidth, iMaxHeight, SWP_SHOWWINDOW | SWP_ASYNCWINDOWPOS | SWP_DEFERERASE | SWP_NOSENDCHANGING); } else { - hbmMem = (HBITMAP)SelectObject(hdcMem, (bDrawOwnAvatar) ? dat->hOwnPic : hbmAvatar); + HDC hdcMem = CreateCompatibleDC(dis->hDC); + HBITMAP hbmMem = (HBITMAP)SelectObject(hdcMem, (bDrawOwnAvatar) ? dat->hOwnPic : hbmAvatar); LONG xy_off = 1; //CSkin::m_bAvatarBorderType ? 1 : 0; LONG width_off = 0; //= CSkin::m_bAvatarBorderType ? 0 : 2; @@ -1704,14 +1639,14 @@ int TSAPI MsgWindowDrawHandler(WPARAM wParam, LPARAM lParam, TWindowData *dat) HBITMAP hbmOld = (HBITMAP)SelectObject(hdcTemp, hbmTemp); SetStretchBltMode(hdcTemp, HALFTONE); - StretchBlt(hdcTemp, 0, 0, bminfo.bmWidth, bminfo.bmHeight, hdcDraw, xy_off, top + xy_off, (int)dNewWidth + width_off, iMaxHeight + width_off, SRCCOPY); + StretchBlt(hdcTemp, 0, 0, bminfo.bmWidth, bminfo.bmHeight, hdcDraw, xy_off, top + xy_off, (int)dat->iPanelAvatarX + width_off, iMaxHeight + width_off, SRCCOPY); GdiAlphaBlend(hdcTemp, 0, 0, bminfo.bmWidth, bminfo.bmHeight, hdcMem, 0, 0, bminfo.bmWidth, bminfo.bmHeight, CSkin::m_default_bf); - StretchBlt(hdcDraw, xy_off, top + xy_off, (int)dNewWidth + width_off, iMaxHeight + width_off, hdcTemp, 0, 0, bminfo.bmWidth, bminfo.bmHeight, SRCCOPY); + StretchBlt(hdcDraw, xy_off, top + xy_off, (int)dat->iPanelAvatarX + width_off, iMaxHeight + width_off, hdcTemp, 0, 0, bminfo.bmWidth, bminfo.bmHeight, SRCCOPY); SelectObject(hdcTemp, hbmOld); DeleteObject(hbmTemp); DeleteDC(hdcTemp); } - else StretchBlt(hdcDraw, xy_off, top + xy_off, (int)dNewWidth + width_off, iMaxHeight + width_off, hdcMem, 0, 0, bminfo.bmWidth, bminfo.bmHeight, SRCCOPY); + else StretchBlt(hdcDraw, xy_off, top + xy_off, (int)dat->iPanelAvatarX + width_off, iMaxHeight + width_off, hdcMem, 0, 0, bminfo.bmWidth, bminfo.bmHeight, SRCCOPY); SelectObject(hdcMem, hbmMem); DeleteObject(hbmMem); diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp index a53fb2baca..9225b1d489 100644 --- a/plugins/TabSRMM/src/msgs.cpp +++ b/plugins/TabSRMM/src/msgs.cpp @@ -370,42 +370,6 @@ int SplitmsgShutdown(void) return 0; } -int AvatarChanged(WPARAM wParam, LPARAM lParam) -{ - if (wParam == 0) { // protocol picture has changed... - M.BroadcastMessage(DM_PROTOAVATARCHANGED, wParam, lParam); - return 0; - } - - HWND hwnd = M.FindWindow(wParam); - if (hwnd == NULL) - return 0; - - TWindowData *dat = (TWindowData*)GetWindowLongPtr(hwnd, GWLP_USERDATA); - if (dat == NULL) - return 0; - - avatarCacheEntry *ace = (avatarCacheEntry *)lParam; - dat->ace = ace; - if (dat->hTaskbarIcon) - DestroyIcon(dat->hTaskbarIcon); - dat->hTaskbarIcon = 0; - DM_RecalcPictureSize(dat); - if (!dat->bShowAvatar || !dat->bShowInfoAvatar) - GetAvatarVisibility(hwnd, dat); - if (dat->hwndPanelPic) { - dat->panelWidth = -1; // force new size calculations (not for flash avatars) - SendMessage(dat->hwnd, WM_SIZE, 0, 1); - } - dat->panelWidth = -1; // force new size calculations (not for flash avatars) - RedrawWindow(dat->hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); - SendMessage(dat->hwnd, WM_SIZE, 0, 1); - ShowPicture(dat, TRUE); - dat->dwFlagsEx |= MWF_EX_AVATARCHANGED; - dat->pContainer->SideBar->updateSession(dat); - return 0; -} - int MyAvatarChanged(WPARAM wParam, LPARAM lParam) { if (wParam == 0 || IsBadReadPtr((void*)wParam, 4)) diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h index 3587f6c5e2..cba8d7e694 100644 --- a/plugins/TabSRMM/src/msgs.h +++ b/plugins/TabSRMM/src/msgs.h @@ -307,7 +307,7 @@ struct TWindowData int iEventQueueSize; LCID lcid; TCHAR lcID[10]; - int panelWidth; + int iPanelAvatarX, iPanelAvatarY; DWORD idle; HWND hwndTip; TOOLINFO ti; diff --git a/plugins/TabSRMM/src/userprefs.cpp b/plugins/TabSRMM/src/userprefs.cpp index 65b1a968af..5661e39239 100644 --- a/plugins/TabSRMM/src/userprefs.cpp +++ b/plugins/TabSRMM/src/userprefs.cpp @@ -284,7 +284,6 @@ static INT_PTR CALLBACK DlgProcUserPrefs(HWND hwndDlg, UINT msg, WPARAM wParam, } if (hWnd && dat) { SendMessage(hWnd, DM_CONFIGURETOOLBAR, 0, 1); - dat->panelWidth = -1; ShowPicture(dat, FALSE); SendMessage(hWnd, WM_SIZE, 0, 0); DM_ScrollToBottom(dat, 0, 1); -- cgit v1.2.3