From dde622d64e2c3ef843c70971b4f108189f19195f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 22 Jan 2014 15:59:28 +0000 Subject: clist_nicer: option to display xStatus icon instead of a usual one doesn't work git-svn-id: http://svn.miranda-ng.org/main/trunk@7827 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Clist_nicer/src/clistmod.cpp | 167 ++++++++++++++++------------------- 1 file changed, 78 insertions(+), 89 deletions(-) (limited to 'plugins/Clist_nicer/src/clistmod.cpp') diff --git a/plugins/Clist_nicer/src/clistmod.cpp b/plugins/Clist_nicer/src/clistmod.cpp index d8e97bcd7f..8b23d00f02 100644 --- a/plugins/Clist_nicer/src/clistmod.cpp +++ b/plugins/Clist_nicer/src/clistmod.cpp @@ -55,9 +55,10 @@ int IconFromStatusMode(const char *szProto, int status, HANDLE hContact, HICON * int finalStatus; if (szProto != NULL && !strcmp(szProto, cfg::dat.szMetaName) && cfg::dat.bMetaAvail && hContact != 0 && !(cfg::dat.dwFlags & CLUI_USEMETAICONS)) { - HANDLE hSubContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM) hContact, 0); + HANDLE hSubContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0); szFinalProto = GetContactProto(hSubContact); finalStatus = (status == 0) ? (WORD) cfg::getWord(hSubContact, szFinalProto, "Status", ID_STATUS_OFFLINE) : status; + hContact = hSubContact; } else { szFinalProto = (char*) szProto; @@ -71,6 +72,7 @@ int IconFromStatusMode(const char *szProto, int status, HANDLE hContact, HICON * *phIcon = Skin_GetIcon(szBuf); } } + return saveIconFromStatusMode(szFinalProto, finalStatus, hContact); } @@ -124,8 +126,8 @@ Begin of Hrk's code for bug int GetWindowVisibleState(HWND hWnd, int iStepX, int iStepY) { - RECT rc = {0}, rcUpdate = {0}; - POINT pt = {0}; + RECT rc = { 0 }, rcUpdate = { 0 }; + POINT pt = { 0 }; register int i = 0, j = 0, width = 0, height = 0, iCountedDots = 0, iNotCoveredDots = 0; BOOL bPartiallyCovered = FALSE; HWND hAux = 0; @@ -138,79 +140,67 @@ int GetWindowVisibleState(HWND hWnd, int iStepX, int iStepY) if (IsIconic(hWnd) || !IsWindowVisible(hWnd)) return GWVS_HIDDEN; - else { - HRGN rgn = 0; - POINT ptOrig; - RECT rcClient; - int clip = (int)cfg::dat.bClipBorder; - - GetClientRect(hWnd, &rcClient); - ptOrig.x = ptOrig.y = 0; - ClientToScreen(hWnd, &ptOrig); - rc.left = ptOrig.x; - rc.top = ptOrig.y; - rc.right = rc.left + rcClient.right; - rc.bottom = rc.top + rcClient.bottom; - - //GetWindowRect(hWnd, &rc); - width = rc.right - rc.left; - height = rc.bottom - rc.top; - - if (iStepX <= 0) - iStepX = 4; - if (iStepY <= 0) - iStepY = 16; - - /* - * use a rounded clip region to determine which pixels are covered - * this will avoid problems with certain XP themes which are using transparency for rounded - * window frames (reluna being one popular example). - - * the radius of 8 should be sufficient for most themes as they usually don't use bigger - * radii. - * also, clip at least 2 pixels from the border (same reason) - */ - - if (g_CLUIImageItem) - clip = 5; - else - clip = 0; - //clip = max(clip, db_get_b(NULL, "CLUI", "ignoreframepixels", 2)); - //rgn = CreateRoundRectRgn(rc.left + clip, rc.top + clip, rc.right - clip, rc.bottom - clip, 10 + clip, 10 + clip); - //rgn = CreateRectRgn(rc.left, rc.top, rc.right, rc.bottom); - //for (i = rc.top + 3 + clip; i < rc.bottom - 3 - clip; i += (height / iStepY)) { - for (i = rc.top + clip; i < rc.bottom; i += (height / iStepY)) { - pt.y = i; - //for (j = rc.left + 3 + clip; j < rc.right - 3 - clip; j += (width / iStepX)) { - for (j = rc.left + clip; j < rc.right; j += (width / iStepX)) { - /*if (rgn) { - ptTest.x = j; - ptTest.y = i; - if ( !PtInRegion(rgn, ptTest.x, ptTest.y)) { - continue; - } - }*/ - pt.x = j; - hAux = WindowFromPoint(pt); - while (GetParent(hAux) != NULL) - hAux = GetParent(hAux); - if (hAux != hWnd && hAux) //There's another window! - bPartiallyCovered = TRUE; - else - iNotCoveredDots++; //Let's count the not covered dots. - iCountedDots++; //Let's keep track of how many dots we checked. - } + + HRGN rgn = 0; + POINT ptOrig; + RECT rcClient; + int clip = (int)cfg::dat.bClipBorder; + + GetClientRect(hWnd, &rcClient); + ptOrig.x = ptOrig.y = 0; + ClientToScreen(hWnd, &ptOrig); + rc.left = ptOrig.x; + rc.top = ptOrig.y; + rc.right = rc.left + rcClient.right; + rc.bottom = rc.top + rcClient.bottom; + + //GetWindowRect(hWnd, &rc); + width = rc.right - rc.left; + height = rc.bottom - rc.top; + + if (iStepX <= 0) + iStepX = 4; + if (iStepY <= 0) + iStepY = 16; + + /* + * use a rounded clip region to determine which pixels are covered + * this will avoid problems with certain XP themes which are using transparency for rounded + * window frames (reluna being one popular example). + + * the radius of 8 should be sufficient for most themes as they usually don't use bigger + * radii. + * also, clip at least 2 pixels from the border (same reason) + */ + + if (g_CLUIImageItem) + clip = 5; + else + clip = 0; + + for (i = rc.top + clip; i < rc.bottom; i += (height / iStepY)) { + pt.y = i; + for (j = rc.left + clip; j < rc.right; j += (width / iStepX)) { + pt.x = j; + hAux = WindowFromPoint(pt); + while (GetParent(hAux) != NULL) + hAux = GetParent(hAux); + if (hAux != hWnd && hAux) //There's another window! + bPartiallyCovered = TRUE; + else + iNotCoveredDots++; //Let's count the not covered dots. + iCountedDots++; //Let's keep track of how many dots we checked. } - if (rgn) - DeleteObject(rgn); - - if (iNotCoveredDots == iCountedDots) //Every dot was not covered: the window is visible. - return GWVS_VISIBLE; - else if (iNotCoveredDots == 0) //They're all covered! - return GWVS_COVERED; - else //There are dots which are visible, but they are not as many as the ones we counted: it's partially covered. - return GWVS_PARTIALLY_COVERED; } + if (rgn) + DeleteObject(rgn); + + if (iNotCoveredDots == iCountedDots) //Every dot was not covered: the window is visible. + return GWVS_VISIBLE; + if (iNotCoveredDots == 0) //They're all covered! + return GWVS_COVERED; + //There are dots which are visible, but they are not as many as the ones we counted: it's partially covered. + return GWVS_PARTIALLY_COVERED; } int ShowHide(WPARAM wParam, LPARAM lParam) @@ -225,19 +215,19 @@ int ShowHide(WPARAM wParam, LPARAM lParam) } else { switch (iVisibleState) { - case GWVS_PARTIALLY_COVERED: - //If we don't want to bring it to top, we can use a simple break. This goes against readability ;-) but the comment explains it. - if ( !cfg::getByte("CList", "BringToFront", SETTING_BRINGTOFRONT_DEFAULT)) - break; - case GWVS_COVERED: //Fall through (and we're already falling) - case GWVS_HIDDEN: - bShow = TRUE; - break; - case GWVS_VISIBLE: //This is not needed, but goes for readability. - bShow = FALSE; + case GWVS_PARTIALLY_COVERED: + //If we don't want to bring it to top, we can use a simple break. This goes against readability ;-) but the comment explains it. + if (!cfg::getByte("CList", "BringToFront", SETTING_BRINGTOFRONT_DEFAULT)) break; - case -1: //We can't get here, both cli.hwndContactList and iStepX and iStepY are right. - return 0; + case GWVS_COVERED: //Fall through (and we're already falling) + case GWVS_HIDDEN: + bShow = TRUE; + break; + case GWVS_VISIBLE: //This is not needed, but goes for readability. + bShow = FALSE; + break; + case -1: //We can't get here, both cli.hwndContactList and iStepX and iStepY are right. + return 0; } } @@ -245,7 +235,7 @@ int ShowHide(WPARAM wParam, LPARAM lParam) RECT rcWindow; SetWindowPos(pcli->hwndContactList, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOREDRAW | SWP_NOSENDCHANGING | SWP_NOCOPYBITS); - if ( !cfg::getByte("CList", "OnTop", SETTING_ONTOP_DEFAULT)) + if (!cfg::getByte("CList", "OnTop", SETTING_ONTOP_DEFAULT)) SetWindowPos(pcli->hwndContactList, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOREDRAW | SWP_NOSENDCHANGING | SWP_NOCOPYBITS); SetForegroundWindow(pcli->hwndContactList); //SetActiveWindow(pcli->hwndContactList); @@ -253,8 +243,7 @@ int ShowHide(WPARAM wParam, LPARAM lParam) cfg::writeByte("CList", "State", SETTING_STATE_NORMAL); GetWindowRect(pcli->hwndContactList, &rcWindow); - if (Utils_AssertInsideScreen(&rcWindow) == 1) - { + if (Utils_AssertInsideScreen(&rcWindow) == 1) { MoveWindow(pcli->hwndContactList, rcWindow.left, rcWindow.top, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top, TRUE); } -- cgit v1.2.3