diff options
author | Tobias Weimer <wishmaster51@googlemail.com> | 2015-03-06 23:20:16 +0000 |
---|---|---|
committer | Tobias Weimer <wishmaster51@googlemail.com> | 2015-03-06 23:20:16 +0000 |
commit | 052236c2ce0e28176d18cfdf08ac258cbf7600a1 (patch) | |
tree | b780a7ddc14490d62b5d4fb214149f8d565e595d /plugins/Clist_modern/src/modern_skinengine.cpp | |
parent | de82d806160c060dcca20968a0c788695d4459ab (diff) |
Clist_modern:
- Minor cleanup
git-svn-id: http://svn.miranda-ng.org/main/trunk@12363 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Clist_modern/src/modern_skinengine.cpp')
-rw-r--r-- | plugins/Clist_modern/src/modern_skinengine.cpp | 110 |
1 files changed, 41 insertions, 69 deletions
diff --git a/plugins/Clist_modern/src/modern_skinengine.cpp b/plugins/Clist_modern/src/modern_skinengine.cpp index 9eab051c74..da509b61a1 100644 --- a/plugins/Clist_modern/src/modern_skinengine.cpp +++ b/plugins/Clist_modern/src/modern_skinengine.cpp @@ -190,10 +190,9 @@ int IniParser::GetSkinFolder(IN const TCHAR * szFileName, OUT TCHAR * pszFolderN *pszPos = _T('\0'); _tcscpy(pszFolderName, szBuff); - TCHAR custom_folder[MAX_PATH]; - TCHAR cus[MAX_PATH]; + TCHAR custom_folder[MAX_PATH], cus[MAX_PATH]; TCHAR *b3; - _tcscpy(custom_folder, pszFolderName); + _tcsncpy(custom_folder, pszFolderName, MAX_PATH -1); b3 = custom_folder + _tcslen(custom_folder); while (b3 > custom_folder && *b3 != _T('\\')) { b3--; } *b3 = _T('\0'); @@ -533,15 +532,12 @@ int ske_ReleaseBufferDC(HDC hDC, int keepTime) BOOL ske_SetRgnOpaque(HDC memdc, HRGN hrgn, BOOL force) { - RGNDATA * rdata; - DWORD rgnsz; DWORD d; - RECT *rect; if (g_CluiData.fDisableSkinEngine && !force) return TRUE; - rgnsz = GetRegionData(hrgn, 0, NULL); - rdata = (RGNDATA *)mir_alloc(rgnsz); + DWORD rgnsz = GetRegionData(hrgn, 0, NULL); + RGNDATA *rdata = (RGNDATA *)mir_alloc(rgnsz); GetRegionData(hrgn, rgnsz, rdata); - rect = (RECT *)rdata->Buffer; + RECT *rect = (RECT *)rdata->Buffer; for (d = 0; d < rdata->rdh.nCount; d++) { ske_SetRectOpaque(memdc, &rect[d], force); } @@ -555,12 +551,11 @@ BOOL ske_SetRectOpaque(HDC memdc, RECT *fr, BOOL force) int f = 0; BYTE * bits; BITMAP bmp; - HBITMAP hbmp; if (g_CluiData.fDisableSkinEngine && !force) return TRUE; - hbmp = (HBITMAP)GetCurrentObject(memdc, OBJ_BITMAP); + HBITMAP hbmp = (HBITMAP)GetCurrentObject(memdc, OBJ_BITMAP); GetObject(hbmp, sizeof(bmp), &bmp); if (bmp.bmPlanes != 1) @@ -642,15 +637,13 @@ static BOOL ske_SkinFillRectByGlyph(HDC hDest, HDC hSource, RECT *rFill, RECT *r return 1; } else if (mode == FM_TILE_VERT && (rGlyph->bottom - rGlyph->top > 0) && (rGlyph->right - rGlyph->left > 0)) { - HDC mem2dc; - HBITMAP mem2bmp, oldbmp; RECT wr; IntersectRect(&wr, rClip, rFill); if ((wr.bottom - wr.top)*(wr.right - wr.left) == 0) return 0; - mem2dc = CreateCompatibleDC(hDest); + HDC mem2dc = CreateCompatibleDC(hDest); //SetStretchBltMode(mem2dc, HALFTONE); - mem2bmp = ske_CreateDIB32(wr.right - wr.left, rGlyph->bottom - rGlyph->top); - oldbmp = (HBITMAP)SelectObject(mem2dc, mem2bmp); + HBITMAP mem2bmp = ske_CreateDIB32(wr.right - wr.left, rGlyph->bottom - rGlyph->top); + HBITMAP oldbmp = (HBITMAP)SelectObject(mem2dc, mem2bmp); if (!oldbmp) return 0; @@ -730,18 +723,16 @@ static BOOL ske_SkinFillRectByGlyph(HDC hDest, HDC hSource, RECT *rFill, RECT *r DeleteDC(mem2dc); } else if (mode == FM_TILE_HORZ && (rGlyph->right - rGlyph->left > 0) && (rGlyph->bottom - rGlyph->top > 0) && (rFill->bottom - rFill->top) > 0 && (rFill->right - rFill->left) > 0) { - HDC mem2dc; RECT wr; - HBITMAP mem2bmp, oldbmp; int w = rGlyph->right - rGlyph->left; int h = rFill->bottom - rFill->top; IntersectRect(&wr, rClip, rFill); if ((wr.bottom - wr.top)*(wr.right - wr.left) == 0) return 0; h = wr.bottom - wr.top; - mem2dc = CreateCompatibleDC(hDest); + HDC mem2dc = CreateCompatibleDC(hDest); - mem2bmp = ske_CreateDIB32(w, h); - oldbmp = (HBITMAP)SelectObject(mem2dc, mem2bmp); + HBITMAP mem2bmp = ske_CreateDIB32(w, h); + HBITMAP oldbmp = (HBITMAP)SelectObject(mem2dc, mem2bmp); if (!oldbmp) return 0; @@ -757,8 +748,7 @@ static BOOL ske_SkinFillRectByGlyph(HDC hDest, HDC hSource, RECT *rFill, RECT *r if (drawMode == 0 || drawMode == 2) { if (drawMode == 0) { - int dx; - dx = (wr.left - rFill->left) % w; + int dx = (wr.left - rFill->left) % w; if (dx >= 0) { int wt; x = wr.left; @@ -774,8 +764,7 @@ static BOOL ske_SkinFillRectByGlyph(HDC hDest, HDC hSource, RECT *rFill, RECT *r BitBlt(hDest, x, wr.top, wr.right - x, h, mem2dc, 0, 0, SRCCOPY); } else { - int dx; - dx = (wr.left - rFill->left) % w; + int dx = (wr.left - rFill->left) % w; x = wr.left - dx; while (x < wr.right - w) { ske_AlphaBlend(hDest, x, wr.top, w, h, mem2dc, 0, 0, w, h, bf); @@ -788,8 +777,7 @@ static BOOL ske_SkinFillRectByGlyph(HDC hDest, HDC hSource, RECT *rFill, RECT *r } else { BLENDFUNCTION bf = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA }; - int dx; - dx = (wr.left - rFill->left) % w; + int dx = (wr.left - rFill->left) % w; if (dx >= 0) { int wt; x = wr.left; @@ -812,18 +800,16 @@ static BOOL ske_SkinFillRectByGlyph(HDC hDest, HDC hSource, RECT *rFill, RECT *r DeleteDC(mem2dc); } else if (mode == FM_TILE_BOTH && (rGlyph->right - rGlyph->left > 0) && (rGlyph->bottom - rGlyph->top > 0)) { - HDC mem2dc; int w = rGlyph->right - rGlyph->left; - int x = 0; + int x = 0; int h = rFill->bottom - rFill->top; - HBITMAP mem2bmp, oldbmp; RECT wr; IntersectRect(&wr, rClip, rFill); if ((wr.bottom - wr.top)*(wr.right - wr.left) == 0) return 0; - mem2dc = CreateCompatibleDC(hDest); - mem2bmp = ske_CreateDIB32(w, wr.bottom - wr.top); + HDC mem2dc = CreateCompatibleDC(hDest); + HBITMAP mem2bmp = ske_CreateDIB32(w, wr.bottom - wr.top); h = wr.bottom - wr.top; - oldbmp = (HBITMAP)SelectObject(mem2dc, mem2bmp); + HBITMAP oldbmp = (HBITMAP)SelectObject(mem2dc, mem2bmp); #ifdef _DEBUG if (!oldbmp) (NULL, "Tile bitmap not selected", "ERROR", MB_OK); @@ -833,10 +819,8 @@ static BOOL ske_SkinFillRectByGlyph(HDC hDest, HDC hSource, RECT *rFill, RECT *r //fill temp bitmap { - int y; - int dy; - dy = (wr.top - rFill->top) % (rGlyph->bottom - rGlyph->top); - y = -dy; + int dy = (wr.top - rFill->top) % (rGlyph->bottom - rGlyph->top); + int y = -dy; while (y < wr.bottom - wr.top) { ske_AlphaBlend(mem2dc, 0, y, w, rGlyph->bottom - rGlyph->top, hSource, rGlyph->left, rGlyph->top, w, rGlyph->bottom - rGlyph->top, bf); @@ -847,9 +831,7 @@ static BOOL ske_SkinFillRectByGlyph(HDC hDest, HDC hSource, RECT *rFill, RECT *r //end temp bitmap if (drawMode == 0 || drawMode == 2) { if (drawMode == 0) { - - int dx; - dx = (wr.left - rFill->left) % w; + int dx = (wr.left - rFill->left) % w; if (dx >= 0) { int wt; x = wr.left; @@ -865,8 +847,7 @@ static BOOL ske_SkinFillRectByGlyph(HDC hDest, HDC hSource, RECT *rFill, RECT *r BitBlt(hDest, x, wr.top, wr.right - x, h, mem2dc, 0, 0, SRCCOPY); } else { - int dx; - dx = (wr.left - rFill->left) % w; + int dx = (wr.left - rFill->left) % w; x = wr.left - dx; while (x < wr.right - w) { ske_AlphaBlend(hDest, x, wr.top, w, h, mem2dc, 0, 0, w, h, bf); @@ -880,8 +861,7 @@ static BOOL ske_SkinFillRectByGlyph(HDC hDest, HDC hSource, RECT *rFill, RECT *r else { BLENDFUNCTION bf = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA }; - int dx; - dx = (wr.left - rFill->left) % w; + int dx = (wr.left - rFill->left) % w; if (dx >= 0) { int wt; x = wr.left; @@ -913,7 +893,7 @@ HBITMAP ske_CreateDIB32(int cx, int cy) return ske_CreateDIB32Point(cx, cy, NULL); } -HBITMAP ske_CreateDIB32Point(int cx, int cy, void ** bits) +HBITMAP ske_CreateDIB32Point(int cx, int cy, void **bits) { if (cx < 0 || cy < 0) return NULL; @@ -928,7 +908,7 @@ HBITMAP ske_CreateDIB32Point(int cx, int cy, void ** bits) UINT *ptPixels; HBITMAP DirectBitmap = CreateDIBSection(NULL, - (BITMAPINFO *)&RGB32BitsBITMAPINFO, + &RGB32BitsBITMAPINFO, DIB_RGB_COLORS, (void **)&ptPixels, NULL, 0); @@ -1348,7 +1328,6 @@ int ske_AddDescriptorToSkinObjectList(LPSKINOBJECTDESCRIPTOR lpDescr, SKINOBJECT { SKINOBJECTSLIST *sk; if (Skin) sk = Skin; else sk = &g_SkinObjectList; - if (!sk) return 0; if (mir_bool_strcmpi(lpDescr->szObjectID, "_HEADER_")) return 0; {//check if new object allready presents. DWORD i = 0; @@ -1751,13 +1730,11 @@ static HBITMAP ske_LoadGlyphImageByDecoders(const TCHAR *tszFileName) if (bmpInfo.bmBitsPixel == 32) ske_PreMultiplyChanells(hBitmap, f); else { - HDC dc24, dc32; - HBITMAP hBitmap32, obmp24, obmp32; - dc32 = CreateCompatibleDC(NULL); - dc24 = CreateCompatibleDC(NULL); - hBitmap32 = ske_CreateDIB32(bmpInfo.bmWidth, bmpInfo.bmHeight); - obmp24 = (HBITMAP)SelectObject(dc24, hBitmap); - obmp32 = (HBITMAP)SelectObject(dc32, hBitmap32); + HDC dc32 = CreateCompatibleDC(NULL); + HDC dc24 = CreateCompatibleDC(NULL); + HBITMAP hBitmap32 = ske_CreateDIB32(bmpInfo.bmWidth, bmpInfo.bmHeight); + HBITMAP obmp24 = (HBITMAP)SelectObject(dc24, hBitmap); + HBITMAP obmp32 = (HBITMAP)SelectObject(dc32, hBitmap32); BitBlt(dc32, 0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, dc24, 0, 0, SRCCOPY); SelectObject(dc24, obmp24); SelectObject(dc32, obmp32); @@ -1787,15 +1764,15 @@ HBITMAP ske_LoadGlyphImage(const TCHAR *tszFileName) mir_cslock lck(cs_SkinChanging); - if (pLoadedImages) { - for (DWORD i = 0; i < dwLoadedImagesCount; i++) { - if (mir_bool_tstrcmpi(pLoadedImages[i].szFileName, szFile)) { - pLoadedImages[i].dwLoadedTimes++; - return pLoadedImages[i].hGlyph; - } + if (!pLoadedImages) + return NULL; + + for (DWORD i = 0; i < dwLoadedImagesCount; i++) { + if (mir_bool_tstrcmpi(pLoadedImages[i].szFileName, szFile)) { + pLoadedImages[i].dwLoadedTimes++; + return pLoadedImages[i].hGlyph; } } - // load new image HBITMAP hbmp = ske_skinLoadGlyphImage(szFile); if (hbmp == NULL) @@ -1965,11 +1942,9 @@ static void ske_LinkSkinObjects(SKINOBJECTSLIST * pObjectList) int i; // LINK Text with objects for (i = 0; i < pObjectList->pTextList->realCount; i++) { - GLYPHTEXT * glText; GLYPHOBJECT *globj = NULL; - SKINOBJECTDESCRIPTOR * lpobj; - glText = (GLYPHTEXT *)pObjectList->pTextList->items[i]; - lpobj = ske_FindObjectByName(glText->szObjectName, OT_GLYPHOBJECT, pObjectList); + GLYPHTEXT *glText = (GLYPHTEXT *)pObjectList->pTextList->items[i]; + SKINOBJECTDESCRIPTOR *lpobj = ske_FindObjectByName(glText->szObjectName, OT_GLYPHOBJECT, pObjectList); mir_free_and_nil(glText->szObjectName); if (lpobj) globj = (GLYPHOBJECT*)lpobj->Data; @@ -3017,10 +2992,7 @@ static int ske_ValidateSingleFrameImage(FRAMEWND * Frame, BOOL SkipBkgBlitting) } // copy image at hdc - if (SkipBkgBlitting) //image already at foreground - BitBlt(hdc, x1, y1, w1, h1, g_pCachedWindow->hImageDC, x + x1, y + y1, SRCCOPY); - else - BitBlt(hdc, x1, y1, w1, h1, g_pCachedWindow->hBackDC, x + x1, y + y1, SRCCOPY); + BitBlt(hdc, x1, y1, w1, h1, g_pCachedWindow->hBackDC, x + x1, y + y1, SRCCOPY); Frame->PaintCallbackProc(Frame->hWnd, hdc, &ru, Frame->UpdateRgn, Frame->dwFlags, Frame->PaintData); } |