From ab53b72bf7067feb9dede0fd76b5a3cbc13863b9 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 2 Jun 2015 15:55:48 +0000 Subject: - old PNG conversion code (png2dib, dib2png) removed; - m_png.h also removed; - all calls of LoadImage replaced with CallService(MS_IMG_LOAD); - four invalid CloseHandle() calls removed; - massive code cleaning for Popup, HistoryStats & SplashScreen plugins git-svn-id: http://svn.miranda-ng.org/main/trunk@13974 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Popup/src/actions.cpp | 7 +- plugins/Popup/src/avatars.cpp | 16 +- plugins/Popup/src/avatars_gif.cpp | 16 +- plugins/Popup/src/avatars_simple.cpp | 30 ++- plugins/Popup/src/bitmap_funcs.cpp | 106 ++--------- plugins/Popup/src/bitmap_funcs.h | 6 +- plugins/Popup/src/config.cpp | 5 +- plugins/Popup/src/effects.cpp | 16 +- plugins/Popup/src/font.cpp | 3 +- plugins/Popup/src/formula.cpp | 182 +++++++----------- plugins/Popup/src/headers.h | 2 +- plugins/Popup/src/history.cpp | 239 +++++++++++------------ plugins/Popup/src/icons.cpp | 7 +- plugins/Popup/src/notifications.cpp | 26 +-- plugins/Popup/src/opt_skins.cpp | 357 +++++++++++++++++------------------ plugins/Popup/src/popup_gdiplus.cpp | 17 +- plugins/Popup/src/popup_thread.cpp | 15 +- plugins/Popup/src/popup_wnd2.cpp | 198 +++++++++---------- plugins/Popup/src/services.cpp | 79 ++++---- plugins/Popup/src/skin.cpp | 166 ++++++++-------- 20 files changed, 661 insertions(+), 832 deletions(-) (limited to 'plugins/Popup/src') diff --git a/plugins/Popup/src/actions.cpp b/plugins/Popup/src/actions.cpp index d731bd9e80..291d2f10f8 100644 --- a/plugins/Popup/src/actions.cpp +++ b/plugins/Popup/src/actions.cpp @@ -143,7 +143,8 @@ DWORD MouseOverride(HWND hCombo, int number) // options -void LoadOption_Actions() { +void LoadOption_Actions() +{ PopupOptions.actions = db_get_dw(NULL, MODULNAME, "Actions", ACT_ENABLE | ACT_RIGHTICONS | ACT_DEF_KEEPWND | ACT_DEF_IMONLY | ACT_DEF_NOGLOBAL | ACT_DEF_MESSAGE | ACT_DEF_DETAILS | ACT_DEF_MENU | @@ -238,9 +239,7 @@ INT_PTR CALLBACK DlgProcPopupActions(HWND hwnd, UINT msg, WPARAM wParam, LPARAM mir_strncpy(szGroup, gActions[i]->lpzTitle, szName - gActions[i]->lpzTitle); int grpId = 0; - - if ((grpId = groups.getIndex(szGroup)) < 0) - { + if ((grpId = groups.getIndex(szGroup)) < 0) { LVGROUP group = { 0 }; group.cbSize = sizeof(group); group.mask = LVGF_HEADER | LVGF_GROUPID; diff --git a/plugins/Popup/src/avatars.cpp b/plugins/Popup/src/avatars.cpp index aa5529c5ee..89dee0724c 100644 --- a/plugins/Popup/src/avatars.cpp +++ b/plugins/Popup/src/avatars.cpp @@ -25,25 +25,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. PopupAvatar *PopupAvatar::create(MCONTACT hContact) { - if (hContact) - { - if (ServiceExists(MS_AV_GETAVATARBITMAP)) - { + if (hContact) { + if (ServiceExists(MS_AV_GETAVATARBITMAP)) { avatarCacheEntry *av = (avatarCacheEntry *)CallService(MS_AV_GETAVATARBITMAP, hContact, 0); - // MessageBox(NULL, _T("00"), _T(MODULNAME_LONG), MB_OK); if (av && (mir_tstrlen(av->szFilename) > 4)) - { - // MessageBox(NULL, _T("01"), _T(MODULNAME_LONG), MB_OK); if (!mir_tstrcmpi(av->szFilename + mir_tstrlen(av->szFilename) - 4, _T(".gif"))) - { - // MessageBox(NULL, _T("02"), _T(MODULNAME_LONG), MB_OK); if (db_get_b(NULL, MODULNAME, "EnableGifAnimation", 1) && GDIPlus_IsAnimatedGIF(av->szFilename)) - { - // MessageBox(NULL, _T("03"), _T(MODULNAME_LONG), MB_OK); return new GifAvatar(hContact); - } - } - } } } diff --git a/plugins/Popup/src/avatars_gif.cpp b/plugins/Popup/src/avatars_gif.cpp index cc935feccb..33ea2b02f4 100644 --- a/plugins/Popup/src/avatars_gif.cpp +++ b/plugins/Popup/src/avatars_gif.cpp @@ -60,8 +60,7 @@ void GifAvatar::draw(MyBitmap *bmp, int x, int y, int w, int h, POPUPOPTIONS *op { if (!av || (w <= 0) || (h <= 0)) return; - if (!frameCount || !frameDelays || !hBitmap || (cachedWidth != w) || (cachedHeight != h)) - { + if (!frameCount || !frameDelays || !hBitmap || (cachedWidth != w) || (cachedHeight != h)) { cachedWidth = w; cachedHeight = h; if (frameDelays) { @@ -75,13 +74,11 @@ void GifAvatar::draw(MyBitmap *bmp, int x, int y, int w, int h, POPUPOPTIONS *op if (!frameCount) return; HRGN rgn; - if (options->avatarRadius) - { + if (options->avatarRadius) { rgn = CreateRoundRectRgn(x, y, x + w, y + h, 2 * options->avatarRadius, 2 * options->avatarRadius); SelectClipRgn(bmp->getDC(), rgn); } - else - { + else { rgn = CreateRectRgn(x, y, x + w, y + h); } @@ -89,9 +86,7 @@ void GifAvatar::draw(MyBitmap *bmp, int x, int y, int w, int h, POPUPOPTIONS *op SelectObject(hdcTmp, hBitmap); SetStretchBltMode(bmp->getDC(), HALFTONE); - - if (av->dwFlags & AVS_PREMULTIPLIED) - { + if (av->dwFlags & AVS_PREMULTIPLIED) { BLENDFUNCTION bf; bf.BlendOp = AC_SRC_OVER; bf.BlendFlags = 0; @@ -99,8 +94,7 @@ void GifAvatar::draw(MyBitmap *bmp, int x, int y, int w, int h, POPUPOPTIONS *op bf.AlphaFormat = AC_SRC_ALPHA; AlphaBlend(bmp->getDC(), x, y, w, h, hdcTmp, frameSize.cx*activeFrame, 0, frameSize.cx, frameSize.cy, bf); - if (options->avatarBorders && options->avatarPNGBorders) - { + if (options->avatarBorders && options->avatarPNGBorders) { HBRUSH hbr = CreateSolidBrush(fonts.clAvatarBorder); bmp->saveAlpha(x, y, w, h); FrameRgn(bmp->getDC(), rgn, hbr, 1, 1); diff --git a/plugins/Popup/src/avatars_simple.cpp b/plugins/Popup/src/avatars_simple.cpp index ab5edadbf6..22e603db3d 100644 --- a/plugins/Popup/src/avatars_simple.cpp +++ b/plugins/Popup/src/avatars_simple.cpp @@ -23,14 +23,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "headers.h" -SimpleAvatar::SimpleAvatar(HANDLE h, bool bUseBitmap) : -PopupAvatar() +SimpleAvatar::SimpleAvatar(HANDLE h, bool bUseBitmap) + : PopupAvatar() { bIsAnimated = false; bIsValid = true; - if (bUseBitmap) - { + if (bUseBitmap) { BITMAP bmp; GetObject((HBITMAP)h, sizeof(bmp), &bmp); width = abs(bmp.bmWidth); @@ -45,14 +44,11 @@ PopupAvatar() return; } - if (h && ServiceExists(MS_AV_GETAVATARBITMAP)) - { + if (h && ServiceExists(MS_AV_GETAVATARBITMAP)) { avNeedFree = false; av = (avatarCacheEntry *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)h, 0); - if (av) - { - if (av->hbmPic && (av->dwFlags&AVS_BITMAP_VALID) && !(av->dwFlags&AVS_HIDEONCLIST) && !(av->dwFlags&AVS_NOTREADY)) - { + if (av) { + if (av->hbmPic && (av->dwFlags&AVS_BITMAP_VALID) && !(av->dwFlags&AVS_HIDEONCLIST) && !(av->dwFlags&AVS_NOTREADY)) { width = av->bmWidth; height = av->bmHeight; return; @@ -83,13 +79,11 @@ void SimpleAvatar::draw(MyBitmap *bmp, int x, int y, int w, int h, POPUPOPTIONS if (!av) return; HRGN rgn; - if (options->avatarRadius) - { + if (options->avatarRadius) { rgn = CreateRoundRectRgn(x, y, x + w, y + h, 2 * options->avatarRadius, 2 * options->avatarRadius); SelectClipRgn(bmp->getDC(), rgn); } - else - { + else { rgn = CreateRectRgn(x, y, x + w, y + h); } @@ -98,8 +92,7 @@ void SimpleAvatar::draw(MyBitmap *bmp, int x, int y, int w, int h, POPUPOPTIONS SetStretchBltMode(bmp->getDC(), HALFTONE); - if (av->dwFlags & AVS_HASTRANSPARENCY) - { + if (av->dwFlags & AVS_HASTRANSPARENCY) { BLENDFUNCTION bf; bf.BlendOp = AC_SRC_OVER; bf.BlendFlags = 0; @@ -107,8 +100,7 @@ void SimpleAvatar::draw(MyBitmap *bmp, int x, int y, int w, int h, POPUPOPTIONS bf.AlphaFormat = AC_SRC_ALPHA; AlphaBlend(bmp->getDC(), x, y, w, h, hdcTmp, 0, 0, av->bmWidth, av->bmHeight, bf); - if (options->avatarBorders && options->avatarPNGBorders) - { + if (options->avatarBorders && options->avatarPNGBorders) { HBRUSH hbr = CreateSolidBrush(fonts.clAvatarBorder); bmp->saveAlpha(x, y, w, h); FrameRgn(bmp->getDC(), rgn, hbr, 1, 1); @@ -119,7 +111,7 @@ void SimpleAvatar::draw(MyBitmap *bmp, int x, int y, int w, int h, POPUPOPTIONS else { bmp->saveAlpha(x, y, w, h); StretchBlt(bmp->getDC(), x, y, w, h, hdcTmp, 0, 0, av->bmWidth, av->bmHeight, SRCCOPY); - if (options->avatarBorders){ + if (options->avatarBorders) { HBRUSH hbr = CreateSolidBrush(fonts.clAvatarBorder); FrameRgn(bmp->getDC(), rgn, hbr, 1, 1); DeleteObject(hbr); diff --git a/plugins/Popup/src/bitmap_funcs.cpp b/plugins/Popup/src/bitmap_funcs.cpp index 52e341dff5..15b51a5998 100644 --- a/plugins/Popup/src/bitmap_funcs.cpp +++ b/plugins/Popup/src/bitmap_funcs.cpp @@ -55,14 +55,14 @@ MyBitmap::MyBitmap(int w, int h) allocate(w, h); } -MyBitmap::MyBitmap(const TCHAR *fn, const TCHAR *fnAlpha) +MyBitmap::MyBitmap(const TCHAR *fn) { dcBmp = 0; hBmp = 0; bits = 0; width = height = 0; bitsSave = 0; - loadFromFile(fn, fnAlpha); + loadFromFile(fn); } MyBitmap::~MyBitmap() @@ -720,78 +720,18 @@ bool MyBitmap::loadFromFile_gradient(const TCHAR *fn) return true; } -bool MyBitmap::loadFromFile_png(const TCHAR *fn) +bool MyBitmap::loadFromFile(const TCHAR *fn) { - if (!ServiceExists(MS_PNG2DIB)) - return false; - - HANDLE hFile, hMap = 0; - BYTE *ppMap = 0; - long cbFileSize = 0; - BITMAPINFOHEADER *pDib = 0; - BYTE *pDibBits = 0; - if ((hFile = CreateFile(fn, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL)) != INVALID_HANDLE_VALUE) - if ((hMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != NULL) - if ((ppMap = (BYTE*)MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) != NULL) - cbFileSize = GetFileSize(hFile, NULL); - if (cbFileSize) { - PNG2DIB param; - param.pSource = ppMap; - param.cbSourceSize = cbFileSize; - param.pResult = &pDib; - if (CallService(MS_PNG2DIB, 0, (LPARAM)¶m)) - pDibBits = (BYTE*)(pDib + 1); - else - cbFileSize = 0; - } - - if (ppMap) UnmapViewOfFile(ppMap); - if (hMap) CloseHandle(hMap); - if (hFile) CloseHandle(hFile); - - if (!cbFileSize) return false; - - BITMAPINFO *bi = (BITMAPINFO*)pDib; - BYTE *pt = (BYTE*)bi; - pt += bi->bmiHeader.biSize; - - if (bi->bmiHeader.biBitCount != 32) { - allocate(abs(bi->bmiHeader.biWidth), abs(bi->bmiHeader.biHeight)); - HDC hdcTmp = CreateCompatibleDC(getDC()); - HBITMAP hBitmap = CreateDIBitmap(getDC(), pDib, CBM_INIT, pDibBits, bi, DIB_PAL_COLORS); - HBITMAP hOldBmp = (HBITMAP)SelectObject(hdcTmp, hBitmap); - BitBlt(this->getDC(), 0, 0, abs(bi->bmiHeader.biWidth), abs(bi->bmiHeader.biHeight), hdcTmp, 0, 0, SRCCOPY); - this->makeOpaque(); - SelectObject(hdcTmp, hOldBmp); - DeleteDC(hdcTmp); - DeleteObject(hBitmap); - } - else { - allocate(abs(bi->bmiHeader.biWidth), abs(bi->bmiHeader.biHeight)); - BYTE *p2 = (BYTE *)pt; - for (int y = 0; y < bi->bmiHeader.biHeight; ++y) { - BYTE *p1 = (BYTE *)bits + (bi->bmiHeader.biHeight - y - 1)*bi->bmiHeader.biWidth * 4; - for (int x = 0; x < bi->bmiHeader.biWidth; ++x) { - p1[0] = p2[0]; - p1[1] = p2[1]; - p1[2] = p2[2]; - p1[3] = p2[3]; - p1 += 4; - p2 += 4; - } - } + if (bits) freemem(); - premultipleChannels(); - } + if (!_tcsncmp(fn, _T("pixel:"), mir_tstrlen(_T("pixel:")))) + return loadFromFile_pixel(fn); - GlobalFree(pDib); - return true; -} + if (!_tcsncmp(fn, _T("gradient:"), mir_tstrlen(_T("gradient:")))) + return loadFromFile_gradient(fn); -bool MyBitmap::loadFromFile_default(const TCHAR *fn, const TCHAR *fnAlpha) -{ SIZE sz; - HBITMAP hBmpLoaded = (HBITMAP)LoadImage(NULL, fn, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); + HBITMAP hBmpLoaded = (HBITMAP)CallService(MS_IMG_LOAD, (WPARAM)fn, IMGL_TCHAR); if (!hBmpLoaded) return false; @@ -809,36 +749,14 @@ bool MyBitmap::loadFromFile_default(const TCHAR *fn, const TCHAR *fnAlpha) DeleteDC(dcTmp); MyBitmap alpha; - if (fnAlpha && alpha.loadFromFile(fnAlpha) && - (alpha.getWidth() == width) && - (alpha.getHeight() == height)) { - for (int i = 0; i < width*height; i++) - bits[i] = (bits[i] & 0x00ffffff) | ((alpha.bits[i] & 0x000000ff) << 24); + if (bm.bmBitsPixel == 32) premultipleChannels(); - } - else makeOpaque(); + else + makeOpaque(); return true; } -bool MyBitmap::loadFromFile(const TCHAR *fn, const TCHAR *fnAlpha) -{ - if (bits) freemem(); - - if (!_tcsncmp(fn, _T("pixel:"), mir_tstrlen(_T("pixel:")))) - return loadFromFile_pixel(fn); - - if (!_tcsncmp(fn, _T("gradient:"), mir_tstrlen(_T("gradient:")))) - return loadFromFile_gradient(fn); - - TCHAR ext[5]; - mir_tstrncpy(ext, fn + (mir_tstrlen(fn) - 4), SIZEOF(ext)); - if (!mir_tstrcmpi(ext, _T(".png"))) - return loadFromFile_png(fn); - - return loadFromFile_default(fn, fnAlpha); -} - void MyBitmap::allocate(int w, int h) { width = w; diff --git a/plugins/Popup/src/bitmap_funcs.h b/plugins/Popup/src/bitmap_funcs.h index 6840e8f89e..64150200ee 100644 --- a/plugins/Popup/src/bitmap_funcs.h +++ b/plugins/Popup/src/bitmap_funcs.h @@ -45,18 +45,16 @@ private: bool loadFromFile_pixel(const TCHAR *fn); bool loadFromFile_gradient(const TCHAR *fn); - bool loadFromFile_png(const TCHAR *fn); - bool loadFromFile_default(const TCHAR *fn, const TCHAR *fnAlpha = 0); void premultipleChannels(); public: MyBitmap(); MyBitmap(int w, int h); - MyBitmap(const TCHAR *fn, const TCHAR *fnAlpha = 0); + MyBitmap(const TCHAR *fn); ~MyBitmap(); void allocate(int w, int h); - bool loadFromFile(const TCHAR *fn, const TCHAR *fnAlpha = 0); + bool loadFromFile(const TCHAR *fn); int getWidth() { return width; } int getHeight() { return height; } diff --git a/plugins/Popup/src/config.cpp b/plugins/Popup/src/config.cpp index b0f7004aec..0139fcbbdd 100644 --- a/plugins/Popup/src/config.cpp +++ b/plugins/Popup/src/config.cpp @@ -68,14 +68,15 @@ HRESULT(WINAPI *MyDwmEnableBlurBehindWindow)(HWND hWnd, DWM_BLURBEHIND *pBlurBeh // ====== Common Vars ======================== // common funcs -void LoadOptions() { +void LoadOptions() +{ memset(&PopupOptions, 0, sizeof(PopupOptions)); #if defined(_DEBUG) PopupOptions.debug = db_get_b(NULL, MODULNAME, "debug", FALSE); #endif // Load Popup Options - if (!OptionLoaded){ + if (!OptionLoaded) { LoadOption_General(); LoadOption_Skins(); LoadOption_Actions(); diff --git a/plugins/Popup/src/effects.cpp b/plugins/Popup/src/effects.cpp index 88b680a009..c0c6763ab3 100644 --- a/plugins/Popup/src/effects.cpp +++ b/plugins/Popup/src/effects.cpp @@ -50,24 +50,20 @@ public: this->frame = frame; stage = (frame * 2 > frameCount) ? 1 : 0; if (stage == 0) - { alpha = alpha0 + (alpha1 - alpha0) * frame * 2 / frameCount; - } else - { alpha = alpha0 + (alpha1 - alpha0) * (frame * 2 - frameCount) / frameCount; - } } virtual int getPixelAlpha(int x, int y) { - if (stage == 0) - { - if ((x / 16 + y / 16) % 2) return alpha0; + if (stage == 0) { + if ((x / 16 + y / 16) % 2) + return alpha0; return alpha; } - else - { - if ((x / 16 + y / 16) % 2) return alpha; + else { + if ((x / 16 + y / 16) % 2) + return alpha; return alpha1; } } diff --git a/plugins/Popup/src/font.cpp b/plugins/Popup/src/font.cpp index 5af5172e00..1b3ff5583f 100644 --- a/plugins/Popup/src/font.cpp +++ b/plugins/Popup/src/font.cpp @@ -25,7 +25,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. PopupFonts fonts = { 0 }; -void InitFonts() { +void InitFonts() +{ // Fonts FontIDT fid = { 0 }; fid.cbSize = sizeof(FontIDT); diff --git a/plugins/Popup/src/formula.cpp b/plugins/Popup/src/formula.cpp index cbd59163fd..2448fbb1fd 100644 --- a/plugins/Popup/src/formula.cpp +++ b/plugins/Popup/src/formula.cpp @@ -31,30 +31,21 @@ static inline bool myisspace(char ch) int Formula::eval_neq(TCHAR *&s, Args *args, bool *vars) const { int left = eval_sum(s, args, vars); - while (*s) - { - if (myisspace(*s)) - { + while (*s) { + if (myisspace(*s)) { ++s; } - else - if (*s == '<') - { - // this is needed due to side effects caused by min() macro... - int tmp = eval_sum(++s, args, vars); - left = min(left, tmp); - } - else - if (*s == '>') - { - // this is needed due to side effects caused by max() macro... - int tmp = eval_sum(++s, args, vars); - left = max(left, tmp); - } - else - { - break; - } + else if (*s == '<') { + // this is needed due to side effects caused by min() macro... + int tmp = eval_sum(++s, args, vars); + left = min(left, tmp); + } + else if (*s == '>') { + // this is needed due to side effects caused by max() macro... + int tmp = eval_sum(++s, args, vars); + left = max(left, tmp); + } + else break; } return left; } @@ -62,26 +53,17 @@ int Formula::eval_neq(TCHAR *&s, Args *args, bool *vars) const int Formula::eval_sum(TCHAR *&s, Args *args, bool *vars) const { int left = eval_mul(s, args, vars); - while (*s) - { - if (myisspace(*s)) - { + while (*s) { + if (myisspace(*s)) { ++s; } - else - if (*s == '+') - { - left += eval_mul(++s, args, vars); - } - else - if (*s == '-') - { - left -= eval_mul(++s, args, vars); - } - else - { - break; - } + else if (*s == '+') { + left += eval_mul(++s, args, vars); + } + else if (*s == '-') { + left -= eval_mul(++s, args, vars); + } + else break; } return left; } @@ -89,87 +71,65 @@ int Formula::eval_sum(TCHAR *&s, Args *args, bool *vars) const int Formula::eval_mul(TCHAR *&s, Args *args, bool *vars) const { int left = eval_atom(s, args, vars); - while (*s) - { - if (myisspace(*s)) - { + while (*s) { + if (myisspace(*s)) { ++s; } - else - if (*s == '*') - { - left *= eval_atom(++s, args, vars); - } - else - if (*s == '/') - { - if (int right = eval_atom(++s, args, vars)) - left /= right; - } - else - if (*s == '%') - { - if (int right = eval_atom(++s, args, vars)) - left %= right; - } - else - { - break; - } + else if (*s == '*') { + left *= eval_atom(++s, args, vars); + } + else if (*s == '/') { + if (int right = eval_atom(++s, args, vars)) + left /= right; + } + else if (*s == '%') { + if (int right = eval_atom(++s, args, vars)) + left %= right; + } + else break; } return left; } int Formula::eval_atom(TCHAR *&s, Args *args, bool *vars) const { - while (*s) - { - if (myisspace(*s)) - { + while (*s) { + if (myisspace(*s)) { ++s; } - else - if (*s == '(') - { - int res = eval_neq(++s, args, vars); - if (*s == ')') - ++s; - return res; - } - else - if ((*s == '+') || (*s == '-')) - { - int sign = 1; - if (*s == '-') - sign = -1; - return sign * eval_neq(++s, args, vars); - } - else - if (*s == '!') - { - return !eval_neq(++s, args, vars); - } - else - if ((*s >= '0') && (*s <= '9')) - { - int res = 0; - while ((*s >= '0') && (*s <= '9')) - res = res * 10 + *s++ - '0'; - return res; - } - else - { - if (!args) - return 0; - char buf[1024]; - char *bufptr = buf; - while (((*s >= '0') && (*s <= '9')) || ((*s >= 'a') && (*s <= 'z')) || ((*s >= 'A') && (*s <= 'A')) || (*s == '_') || (*s == '.')) - *bufptr++ = *s++; - *bufptr = 0; - int res = args->get(buf); - if (vars) *vars = true; - return res; - } + else if (*s == '(') { + int res = eval_neq(++s, args, vars); + if (*s == ')') + ++s; + return res; + } + else if ((*s == '+') || (*s == '-')) { + int sign = 1; + if (*s == '-') + sign = -1; + return sign * eval_neq(++s, args, vars); + } + else if (*s == '!') { + return !eval_neq(++s, args, vars); + } + else if ((*s >= '0') && (*s <= '9')) { + int res = 0; + while ((*s >= '0') && (*s <= '9')) + res = res * 10 + *s++ - '0'; + return res; + } + else { + if (!args) + return 0; + char buf[1024]; + char *bufptr = buf; + while (((*s >= '0') && (*s <= '9')) || ((*s >= 'a') && (*s <= 'z')) || ((*s >= 'A') && (*s <= 'A')) || (*s == '_') || (*s == '.')) + *bufptr++ = *s++; + *bufptr = 0; + int res = args->get(buf); + if (vars) *vars = true; + return res; + } } return 0; } diff --git a/plugins/Popup/src/headers.h b/plugins/Popup/src/headers.h index 91935af8c6..ce6142318a 100644 --- a/plugins/Popup/src/headers.h +++ b/plugins/Popup/src/headers.h @@ -74,7 +74,6 @@ http://miranda-ng.org/distr/ #include #include #include -#include #include #include #include @@ -83,6 +82,7 @@ http://miranda-ng.org/distr/ #include #include #include +#include #include #include diff --git a/plugins/Popup/src/history.cpp b/plugins/Popup/src/history.cpp index 4bdb947fb8..b2c2d0473b 100644 --- a/plugins/Popup/src/history.cpp +++ b/plugins/Popup/src/history.cpp @@ -124,100 +124,100 @@ static INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM, LPARAM lPara switch (msg) { case WM_INITDIALOG: - { - oldWidth = 0; - HWND hwndList = GetDlgItem(hwnd, IDC_POPUP_LIST); - for (int i = 0; i < arPopupHistory.getCount(); ++i) - ListBox_SetItemData(hwndList, ListBox_AddString(hwndList, _T("")), 0); - SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIcon(ICO_HISTORY, 0)); - SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)IcoLib_GetIcon(ICO_HISTORY, 1)); - - if (gbHppInstalled && PopupOptions.UseHppHistoryLog) { - logType = LOG_HPP; - ShowWindow(GetDlgItem(hwnd, IDC_POPUP_LIST), SW_HIDE); - - IEVIEWWINDOW ieWindow; - ieWindow.cbSize = sizeof(IEVIEWWINDOW); - ieWindow.iType = IEW_CREATE; - ieWindow.dwFlags = 0; - ieWindow.dwMode = IEWM_MUCC; - ieWindow.parent = hwnd; - ieWindow.x = 0; - ieWindow.y = 0; - ieWindow.cx = 100; - ieWindow.cy = 100; - CallService(MS_HPP_EG_WINDOW, 0, (LPARAM)&ieWindow); - hwndLog = ieWindow.hwnd; - ShowWindow(hwndLog, SW_SHOW); - - RECT rcLst; GetWindowRect(hwndList, &rcLst); - POINT pt; - pt.x = rcLst.left; - pt.y = rcLst.top; - ScreenToClient(hwnd, &pt); - - ieWindow.cbSize = sizeof(IEVIEWWINDOW); - ieWindow.iType = IEW_SETPOS; - ieWindow.parent = hwnd; - ieWindow.hwnd = hwndLog; - ieWindow.x = pt.x; - ieWindow.y = pt.y; - ieWindow.cx = rcLst.right - rcLst.left; - ieWindow.cy = rcLst.bottom - rcLst.top; - CallService(MS_HPP_EG_WINDOW, 0, (LPARAM)&ieWindow); - - IEVIEWEVENTDATA ieData; - - IEVIEWEVENT ieEvent; - ieEvent.cbSize = sizeof(ieEvent); - ieEvent.iType = IEE_LOG_MEM_EVENTS; - ieEvent.dwFlags = 0; - ieEvent.hwnd = hwndLog; - ieEvent.eventData = &ieData; - ieEvent.count = 1; - ieEvent.codepage = 0; - ieEvent.pszProto = NULL; - - for (int i = 0; i < arPopupHistory.getCount(); ++i) { - POPUPDATA2* ppd = arPopupHistory[i]; - ieData.cbSize = sizeof(ieData); - ieData.iType = IEED_EVENT_SYSTEM; - ieData.dwFlags = 0; - ieData.color = ppd->colorText; - if (ppd->flags & PU2_UNICODE) { - ieData.dwFlags |= IEEDF_UNICODE_TEXT | IEEDF_UNICODE_NICK; - ieData.pszNickW = ppd->lptzTitle; - ieData.pszTextW = ppd->lptzText; - ieData.pszText2W = NULL; - } - else { - ieData.dwFlags |= 0; - ieData.pszNick = ppd->lpzTitle; - ieData.pszText = ppd->lpzText; - ieData.pszText2 = NULL; + { + oldWidth = 0; + HWND hwndList = GetDlgItem(hwnd, IDC_POPUP_LIST); + for (int i = 0; i < arPopupHistory.getCount(); ++i) + ListBox_SetItemData(hwndList, ListBox_AddString(hwndList, _T("")), 0); + SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIcon(ICO_HISTORY, 0)); + SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)IcoLib_GetIcon(ICO_HISTORY, 1)); + + if (gbHppInstalled && PopupOptions.UseHppHistoryLog) { + logType = LOG_HPP; + ShowWindow(GetDlgItem(hwnd, IDC_POPUP_LIST), SW_HIDE); + + IEVIEWWINDOW ieWindow; + ieWindow.cbSize = sizeof(IEVIEWWINDOW); + ieWindow.iType = IEW_CREATE; + ieWindow.dwFlags = 0; + ieWindow.dwMode = IEWM_MUCC; + ieWindow.parent = hwnd; + ieWindow.x = 0; + ieWindow.y = 0; + ieWindow.cx = 100; + ieWindow.cy = 100; + CallService(MS_HPP_EG_WINDOW, 0, (LPARAM)&ieWindow); + hwndLog = ieWindow.hwnd; + ShowWindow(hwndLog, SW_SHOW); + + RECT rcLst; GetWindowRect(hwndList, &rcLst); + POINT pt; + pt.x = rcLst.left; + pt.y = rcLst.top; + ScreenToClient(hwnd, &pt); + + ieWindow.cbSize = sizeof(IEVIEWWINDOW); + ieWindow.iType = IEW_SETPOS; + ieWindow.parent = hwnd; + ieWindow.hwnd = hwndLog; + ieWindow.x = pt.x; + ieWindow.y = pt.y; + ieWindow.cx = rcLst.right - rcLst.left; + ieWindow.cy = rcLst.bottom - rcLst.top; + CallService(MS_HPP_EG_WINDOW, 0, (LPARAM)&ieWindow); + + IEVIEWEVENTDATA ieData; + + IEVIEWEVENT ieEvent; + ieEvent.cbSize = sizeof(ieEvent); + ieEvent.iType = IEE_LOG_MEM_EVENTS; + ieEvent.dwFlags = 0; + ieEvent.hwnd = hwndLog; + ieEvent.eventData = &ieData; + ieEvent.count = 1; + ieEvent.codepage = 0; + ieEvent.pszProto = NULL; + + for (int i = 0; i < arPopupHistory.getCount(); ++i) { + POPUPDATA2* ppd = arPopupHistory[i]; + ieData.cbSize = sizeof(ieData); + ieData.iType = IEED_EVENT_SYSTEM; + ieData.dwFlags = 0; + ieData.color = ppd->colorText; + if (ppd->flags & PU2_UNICODE) { + ieData.dwFlags |= IEEDF_UNICODE_TEXT | IEEDF_UNICODE_NICK; + ieData.pszNickW = ppd->lptzTitle; + ieData.pszTextW = ppd->lptzText; + ieData.pszText2W = NULL; + } + else { + ieData.dwFlags |= 0; + ieData.pszNick = ppd->lpzTitle; + ieData.pszText = ppd->lpzText; + ieData.pszText2 = NULL; + } + ieData.bIsMe = FALSE; + ieData.time = ppd->dwTimestamp; + ieData.dwData = 0; + ieData.next = NULL; + CallService(MS_HPP_EG_EVENT, 0, (WPARAM)&ieEvent); } - ieData.bIsMe = FALSE; - ieData.time = ppd->dwTimestamp; - ieData.dwData = 0; - ieData.next = NULL; - CallService(MS_HPP_EG_EVENT, 0, (WPARAM)&ieEvent); } - } - else { - logType = LOG_DEFAULT; - hwndLog = hwndList; + else { + logType = LOG_DEFAULT; + hwndLog = hwndList; - ShowWindow(hwndLog, SW_SHOW); - } + ShowWindow(hwndLog, SW_SHOW); + } - Utils_RestoreWindowPosition(hwnd, NULL, MODULNAME, "popupHistory_"); + Utils_RestoreWindowPosition(hwnd, NULL, MODULNAME, "popupHistory_"); - if (logType == LOG_DEFAULT) { - SendMessage(hwnd, UM_RESIZELIST, 0, 0); - ListBox_SetTopIndex(hwndLog, arPopupHistory.getCount() - 1); + if (logType == LOG_DEFAULT) { + SendMessage(hwnd, UM_RESIZELIST, 0, 0); + ListBox_SetTopIndex(hwndLog, arPopupHistory.getCount() - 1); + } } - } - return TRUE; + return TRUE; case WM_MEASUREITEM: if (logType == LOG_DEFAULT) { @@ -293,39 +293,40 @@ static INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM, LPARAM lPara return TRUE; case WM_SIZE: - { - RECT rcLst; GetClientRect(hwnd, &rcLst); - rcLst.left += 10; - rcLst.top += 10; - rcLst.right -= 10; - rcLst.bottom -= 10; - if (logType == LOG_HPP) { - SetWindowPos(hwndLog, NULL, - rcLst.left, rcLst.top, rcLst.right - rcLst.left, rcLst.bottom - rcLst.top, - SWP_NOZORDER | SWP_DEFERERASE | SWP_SHOWWINDOW); - - IEVIEWWINDOW ieWindow; - ieWindow.cbSize = sizeof(IEVIEWWINDOW); - ieWindow.iType = IEW_SETPOS; - ieWindow.parent = hwnd; - ieWindow.hwnd = hwndLog; - ieWindow.x = rcLst.left; - ieWindow.y = rcLst.top; - ieWindow.cx = rcLst.right - rcLst.left; - ieWindow.cy = rcLst.bottom - rcLst.top; - CallService(MS_HPP_EG_WINDOW, 0, (LPARAM)&ieWindow); - } - else if (logType == LOG_DEFAULT) { - SetWindowPos(hwndLog, NULL, - rcLst.left, rcLst.top, rcLst.right - rcLst.left, rcLst.bottom - rcLst.top, - SWP_NOZORDER | SWP_DEFERERASE | SWP_SHOWWINDOW); - if (rcLst.right - rcLst.left != oldWidth) { - oldWidth = rcLst.right - rcLst.left; - PostMessage(hwnd, UM_RESIZELIST, 0, 0); + { + RECT rcLst; + GetClientRect(hwnd, &rcLst); + rcLst.left += 10; + rcLst.top += 10; + rcLst.right -= 10; + rcLst.bottom -= 10; + if (logType == LOG_HPP) { + SetWindowPos(hwndLog, NULL, + rcLst.left, rcLst.top, rcLst.right - rcLst.left, rcLst.bottom - rcLst.top, + SWP_NOZORDER | SWP_DEFERERASE | SWP_SHOWWINDOW); + + IEVIEWWINDOW ieWindow; + ieWindow.cbSize = sizeof(IEVIEWWINDOW); + ieWindow.iType = IEW_SETPOS; + ieWindow.parent = hwnd; + ieWindow.hwnd = hwndLog; + ieWindow.x = rcLst.left; + ieWindow.y = rcLst.top; + ieWindow.cx = rcLst.right - rcLst.left; + ieWindow.cy = rcLst.bottom - rcLst.top; + CallService(MS_HPP_EG_WINDOW, 0, (LPARAM)&ieWindow); + } + else if (logType == LOG_DEFAULT) { + SetWindowPos(hwndLog, NULL, + rcLst.left, rcLst.top, rcLst.right - rcLst.left, rcLst.bottom - rcLst.top, + SWP_NOZORDER | SWP_DEFERERASE | SWP_SHOWWINDOW); + if (rcLst.right - rcLst.left != oldWidth) { + oldWidth = rcLst.right - rcLst.left; + PostMessage(hwnd, UM_RESIZELIST, 0, 0); + } } } - } - return TRUE; + return TRUE; case UM_RESIZELIST: if (logType == LOG_DEFAULT) { diff --git a/plugins/Popup/src/icons.cpp b/plugins/Popup/src/icons.cpp index 6775f971d6..321e62d569 100644 --- a/plugins/Popup/src/icons.cpp +++ b/plugins/Popup/src/icons.cpp @@ -29,14 +29,14 @@ static IconItem iconList[] = { LPGEN("Popups are enabled"), ICO_TB_POPUP_ON, IDI_POPUP }, { LPGEN("Popups are disabled"), ICO_TB_POPUP_OFF, IDI_NOPOPUP }, - // common popup + // common popup { LPGEN("Popups are enabled"), ICO_POPUP_ON, IDI_POPUP }, { LPGEN("Popups are disabled"), ICO_POPUP_OFF, IDI_NOPOPUP }, { LPGEN("With \"favorite\" overlay"), ICO_FAV, IDI_PU_FAVOURITE }, { LPGEN("With \"fullscreen\" overlay"), ICO_FULLSCREEN, IDI_PU_FULLSCREEN }, { LPGEN("Popup History"), ICO_HISTORY, IDI_HISTORY }, - // option + // option { LPGEN("Refresh skin list"), ICO_OPT_RELOAD, IDI_RELOAD }, { LPGEN("Popup placement"), ICO_OPT_RESIZE, IDI_RESIZE }, { LPGEN("OK"), ICO_OPT_OK, IDI_ACT_OK }, @@ -47,7 +47,7 @@ static IconItem iconList[] = { LPGEN("Show in fullscreen"), ICO_OPT_FULLSCREEN, IDI_OPT_FULLSCREEN }, { LPGEN("Blocked contact"), ICO_OPT_BLOCK, IDI_OPT_BLOCK }, - // action + // action { LPGEN("Quick reply"), ICO_ACT_REPLY, IDI_ACT_REPLY }, { LPGEN("Pin popup"), ICO_ACT_PIN, IDI_ACT_PIN }, { LPGEN("Pinned popup"), ICO_ACT_PINNED, IDI_ACT_PINNED }, @@ -57,7 +57,6 @@ static IconItem iconList[] = { LPGEN("Add contact permanently"), ICO_ACT_ADD, IDI_ACT_ADD }, { LPGEN("Dismiss popup"), ICO_ACT_CLOSE, IDI_ACT_CLOSE }, { LPGEN("Copy to clipboard"), ICO_ACT_COPY, IDI_ACT_COPY } - }; /** diff --git a/plugins/Popup/src/notifications.cpp b/plugins/Popup/src/notifications.cpp index 58d0461124..b5a9740f46 100644 --- a/plugins/Popup/src/notifications.cpp +++ b/plugins/Popup/src/notifications.cpp @@ -27,13 +27,11 @@ HANDLE g_hntfError, g_hntfWarning, g_hntfNotification; #define PopupNotificationData_SIGNATURE 0x11BEDA1A - int TreeDataSortFunc(const POPUPTREEDATA *p1, const POPUPTREEDATA *p2) { if (int cmp = mir_tstrcmp(p1->pszTreeRoot, p2->pszTreeRoot)) return cmp; return mir_tstrcmp(p1->pszDescription, p2->pszDescription); - } LIST gTreeData(20, TreeDataSortFunc); @@ -229,12 +227,8 @@ HANDLE FindTreeData(LPTSTR group, LPTSTR name, BYTE typ) { for (int i = 0; i < gTreeData.getCount(); i++) { POPUPTREEDATA *p = gTreeData[i]; - if (p->typ == typ && - (!group || (mir_tstrcmp(p->pszTreeRoot, group) == 0)) && - (!name || (mir_tstrcmp(p->pszDescription, name) == 0))) - { + if (p->typ == typ && (!group || (mir_tstrcmp(p->pszTreeRoot, group) == 0)) && (!name || (mir_tstrcmp(p->pszDescription, name) == 0))) return p; - } } return NULL; } @@ -251,14 +245,14 @@ void FillNotificationData(POPUPDATA2 *ppd, DWORD *disableWhen) ppd->iSeconds = ptd->timeoutValue; *disableWhen = ptd->enabled ? ptd->disableWhen : 0xFFFFFFFF; - LOGFONTA lf; // dummy to make FS happy (use LOGFONTA coz we use MS_FONT_GET) - FontID fontid = { 0 }; // use ansi version of fontID coz POPUPNOTIFICATION use char + LOGFONTA lf; // dummy to make FS happy (use LOGFONTA coz we use MS_FONT_GET) + FontID fontid = { 0 }; // use ansi version of fontID coz POPUPNOTIFICATION use char fontid.cbSize = sizeof(fontid); mir_snprintf(fontid.group, SIZEOF(fontid.group), PU_FNT_AND_COLOR"/%s", ptd->notification.lpzGroup); mir_snprintf(fontid.name, SIZEOF(fontid.name), "%s (colors only)", ptd->notification.lpzName); ppd->colorText = (COLORREF)CallService(MS_FONT_GET, (WPARAM)&fontid, (LPARAM)&lf); - ColourID colourid = { 0 }; // use ansi version of ColourID coz POPUPNOTIFICATION use char + ColourID colourid = { 0 }; // use ansi version of ColourID coz POPUPNOTIFICATION use char colourid.cbSize = sizeof(colourid); mir_snprintf(colourid.group, SIZEOF(colourid.group), PU_FNT_AND_COLOR"/%s", ptd->notification.lpzGroup); mir_snprintf(colourid.name, SIZEOF(colourid.name), "%s (colors only)", ptd->notification.lpzName); @@ -274,8 +268,7 @@ bool IsValidNotification(HANDLE hNotification) if (!hNotification) return false; bool res = false; - __try - { + __try { if (((POPUPTREEDATA *)hNotification)->signature == PopupNotificationData_SIGNATURE) res = true; } @@ -293,8 +286,7 @@ bool PerformAction(HANDLE hNotification, HWND hwnd, UINT message, WPARAM wparam, POPUPTREEDATA *ptd = (POPUPTREEDATA *)hNotification; char *lpzAction = NULL; - switch (message) - { + switch (message) { case WM_LBUTTONUP: case WM_COMMAND: lpzAction = ptd->leftAction; @@ -312,14 +304,12 @@ bool PerformAction(HANDLE hNotification, HWND hwnd, UINT message, WPARAM wparam, if (!mir_strcmp(lpzAction, POPUP_ACTION_NOTHING)) return true; - if (!mir_strcmp(lpzAction, POPUP_ACTION_DISMISS)) - { + if (!mir_strcmp(lpzAction, POPUP_ACTION_DISMISS)) { PUDeletePopup(hwnd); return true; } - for (int i = 0; i < ptd->notification.actionCount; ++i) - { + for (int i = 0; i < ptd->notification.actionCount; ++i) { if (!(ptd->notification.lpActions[i].dwFlags&PNAF_CALLBACK)) continue; if (mir_strcmp(ptd->notification.lpActions[i].lpzTitle, lpzAction)) diff --git a/plugins/Popup/src/opt_skins.cpp b/plugins/Popup/src/opt_skins.cpp index c4bfb60fba..52ac9b6ddc 100644 --- a/plugins/Popup/src/opt_skins.cpp +++ b/plugins/Popup/src/opt_skins.cpp @@ -349,127 +349,121 @@ INT_PTR CALLBACK DlgProcPopSkinsOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR switch (msg) { case WM_INITDIALOG: - { - HWND hCtrl = NULL; - DWORD dwIndex = 0; - - // Skin List - hCtrl = GetDlgItem(hwndDlg, IDC_SKINLIST); - ListBox_ResetContent(hCtrl); - for (const Skins::SKINLIST *sl = skins.getSkinList(); sl; sl = sl->next) { - dwIndex = ListBox_AddString(hCtrl, sl->name); - ListBox_SetItemData(hCtrl, dwIndex, sl->name); - } - ListBox_SetCurSel(hCtrl, ListBox_FindString(hCtrl, 0, PopupOptions.SkinPack)); + // Skin List + HWND hCtrl = GetDlgItem(hwndDlg, IDC_SKINLIST); + ListBox_ResetContent(hCtrl); + for (const Skins::SKINLIST *sl = skins.getSkinList(); sl; sl = sl->next) { + DWORD dwIndex = ListBox_AddString(hCtrl, sl->name); + ListBox_SetItemData(hCtrl, dwIndex, sl->name); + } + ListBox_SetCurSel(hCtrl, ListBox_FindString(hCtrl, 0, PopupOptions.SkinPack)); - // Skin List reload button - SendDlgItemMessage(hwndDlg, IDC_BTN_RELOAD, BUTTONSETASFLATBTN, TRUE, 0); - SendDlgItemMessage(hwndDlg, IDC_BTN_RELOAD, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon(ICO_OPT_RELOAD, 0)); - SendDlgItemMessage(hwndDlg, IDC_BTN_RELOAD, BUTTONADDTOOLTIP, (WPARAM)Translate("Refresh List"), 0); + // Skin List reload button + SendDlgItemMessage(hwndDlg, IDC_BTN_RELOAD, BUTTONSETASFLATBTN, TRUE, 0); + SendDlgItemMessage(hwndDlg, IDC_BTN_RELOAD, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon(ICO_OPT_RELOAD, 0)); + SendDlgItemMessage(hwndDlg, IDC_BTN_RELOAD, BUTTONADDTOOLTIP, (WPARAM)Translate("Refresh List"), 0); - // Skin Option List - SkinOptionList_Update(skinOptions, &skinOptionsCount, hwndDlg); + // Skin Option List + SkinOptionList_Update(skinOptions, &skinOptionsCount, hwndDlg); - // PreviewBox - mir_subclassWindow(GetDlgItem(hwndDlg, IDC_PREVIEWBOX), WndProcPreviewBox); - updatePreviewImage(GetDlgItem(hwndDlg, IDC_PREVIEWBOX)); + // PreviewBox + mir_subclassWindow(GetDlgItem(hwndDlg, IDC_PREVIEWBOX), WndProcPreviewBox); + updatePreviewImage(GetDlgItem(hwndDlg, IDC_PREVIEWBOX)); - // hooks - hhkFontsReload = HookEventMessage(ME_FONT_RELOAD, hwndDlg, WM_USER); + // hooks + hhkFontsReload = HookEventMessage(ME_FONT_RELOAD, hwndDlg, WM_USER); - TranslateDialogDefault(hwndDlg); - bDlgInit = true; - } - return TRUE; + TranslateDialogDefault(hwndDlg); + bDlgInit = true; + } + return TRUE; case WM_USER: updatePreviewImage(GetDlgItem(hwndDlg, IDC_PREVIEWBOX)); return TRUE; case WM_COMMAND: - { - HWND hCtrl = NULL; - UINT idCtrl = LOWORD(wParam); - switch (HIWORD(wParam)) { - case BN_KILLFOCUS: // Button controls - case BN_SETFOCUS: // Button controls - return TRUE; - break; - case BN_CLICKED: // Button controls - switch (idCtrl) { - case IDC_PREVIEW: - PopupPreview(); - break; - - case IDC_BTN_RELOAD: - { - DWORD dwIndex = 0; - TCHAR szNewSkin[128]; - LPTSTR pszOldSkin = mir_tstrdup(PopupOptions.SkinPack); - skins.load(); - hCtrl = GetDlgItem(hwndDlg, IDC_SKINLIST); - ListBox_ResetContent(hCtrl); - for (const Skins::SKINLIST *sl = skins.getSkinList(); sl; sl = sl->next) - { - dwIndex = ListBox_AddString(hCtrl, sl->name); - ListBox_SetItemData(hCtrl, dwIndex, sl->name); - } - ListBox_SetCurSel(hCtrl, ListBox_FindString(hCtrl, 0, PopupOptions.SkinPack)); - // make shure we have select skin (ListBox_SetCurSel may be fail) - ListBox_GetText(hCtrl, ListBox_GetCurSel(hCtrl), &szNewSkin); - if (mir_tstrcmp(pszOldSkin, szNewSkin) != 0) { - mir_free(PopupOptions.SkinPack); - PopupOptions.SkinPack = mir_tstrdup(szNewSkin); - } - mir_free(pszOldSkin); + { + HWND hCtrl = NULL; + UINT idCtrl = LOWORD(wParam); + switch (HIWORD(wParam)) { + case BN_KILLFOCUS: // Button controls + case BN_SETFOCUS: // Button controls + return TRUE; - const PopupSkin *skin = 0; - if (skin = skins.getSkin(PopupOptions.SkinPack)) { - // update Skin Option List from reload SkinPack - bDlgInit = false; - bDlgInit = SkinOptionList_Update(skinOptions, &skinOptionsCount, hwndDlg); - } + case BN_CLICKED: // Button controls + switch (idCtrl) { + case IDC_PREVIEW: + PopupPreview(); + break; - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - }// end IDC_BTN_RELOAD: - break; - case IDC_GETSKINS: - CallService(MS_UTILS_OPENURL, 0, (LPARAM)"http://miranda-ng.org/addons/category/13"); - break; - }// end switch(idCtrl) - updatePreviewImage(GetDlgItem(hwndDlg, IDC_PREVIEWBOX)); - break; - case CBN_SELCHANGE: // combo box controls - switch (idCtrl) { - case IDC_SKINLIST: - { - // Skin list change - mir_free(PopupOptions.SkinPack); - PopupOptions.SkinPack = mir_tstrdup((TCHAR *)SendDlgItemMessage( - hwndDlg, - IDC_SKINLIST, - LB_GETITEMDATA, - (WPARAM)SendDlgItemMessage(hwndDlg, IDC_SKINLIST, LB_GETCURSEL, 0, 0), - 0)); - const PopupSkin *skin = 0; - if (skin = skins.getSkin(PopupOptions.SkinPack)) { - mir_free(PopupOptions.SkinPack); - PopupOptions.SkinPack = mir_tstrdup(skin->getName()); + case IDC_GETSKINS: + CallService(MS_UTILS_OPENURL, 0, (LPARAM)"http://miranda-ng.org/addons/category/13"); + break; - // update Skin Option List - bDlgInit = false; - bDlgInit = SkinOptionList_Update(skinOptions, &skinOptionsCount, hwndDlg); + case IDC_BTN_RELOAD: + LPTSTR pszOldSkin = NEWTSTR_ALLOCA(PopupOptions.SkinPack); + skins.load(); + hCtrl = GetDlgItem(hwndDlg, IDC_SKINLIST); + ListBox_ResetContent(hCtrl); + for (const Skins::SKINLIST *sl = skins.getSkinList(); sl; sl = sl->next) { + DWORD dwIndex = ListBox_AddString(hCtrl, sl->name); + ListBox_SetItemData(hCtrl, dwIndex, sl->name); + } + ListBox_SetCurSel(hCtrl, ListBox_FindString(hCtrl, 0, PopupOptions.SkinPack)); + + // make shure we have select skin (ListBox_SetCurSel may be fail) + TCHAR szNewSkin[128]; + ListBox_GetText(hCtrl, ListBox_GetCurSel(hCtrl), &szNewSkin); + if (mir_tstrcmp(pszOldSkin, szNewSkin) != 0) { + mir_free(PopupOptions.SkinPack); + PopupOptions.SkinPack = mir_tstrdup(szNewSkin); + } + + const PopupSkin *skin = 0; + if (skin = skins.getSkin(PopupOptions.SkinPack)) { + // update Skin Option List from reload SkinPack + bDlgInit = false; + bDlgInit = SkinOptionList_Update(skinOptions, &skinOptionsCount, hwndDlg); + } + + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; } updatePreviewImage(GetDlgItem(hwndDlg, IDC_PREVIEWBOX)); - } - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - }// end switch(idCtrl) + break; + + case CBN_SELCHANGE: // combo box controls + switch (idCtrl) { + case IDC_SKINLIST: + { + // Skin list change + mir_free(PopupOptions.SkinPack); + PopupOptions.SkinPack = mir_tstrdup((TCHAR *)SendDlgItemMessage( + hwndDlg, + IDC_SKINLIST, + LB_GETITEMDATA, + (WPARAM)SendDlgItemMessage(hwndDlg, IDC_SKINLIST, LB_GETCURSEL, 0, 0), + 0)); + const PopupSkin *skin = 0; + if (skin = skins.getSkin(PopupOptions.SkinPack)) { + mir_free(PopupOptions.SkinPack); + PopupOptions.SkinPack = mir_tstrdup(skin->getName()); + + // update Skin Option List + bDlgInit = false; + bDlgInit = SkinOptionList_Update(skinOptions, &skinOptionsCount, hwndDlg); + } + updatePreviewImage(GetDlgItem(hwndDlg, IDC_PREVIEWBOX)); + } + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + }// end switch(idCtrl) + break; + }// end switch (HIWORD(wParam)) break; - }// end switch (HIWORD(wParam)) - break; - }// end WM_COMMAND + }// end WM_COMMAND case WM_NOTIFY: if (!bDlgInit) return FALSE; @@ -481,22 +475,22 @@ INT_PTR CALLBACK DlgProcPopSkinsOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR return TRUE; case PSN_APPLY: - { - // skin pack - db_set_ts(NULL, MODULNAME, "SkinPack", PopupOptions.SkinPack); - // skin options - const PopupSkin *skin = 0; - if (skin = skins.getSkin(PopupOptions.SkinPack)) - skin->saveOpts(); - skins.freeAllButActive(); - // more Skin options - db_set_b(NULL, MODULNAME, "DisplayTime", PopupOptions.DisplayTime); - db_set_b(NULL, MODULNAME, "DropShadow", PopupOptions.DropShadow); - db_set_b(NULL, MODULNAME, "EnableShadowRegion", PopupOptions.EnableFreeformShadows); - db_set_b(NULL, MODULNAME, "EnableAeroGlass", PopupOptions.EnableAeroGlass); - db_set_b(NULL, MODULNAME, "UseMText", PopupOptions.UseMText); - }// end PSN_APPLY: - return TRUE; + { + // skin pack + db_set_ts(NULL, MODULNAME, "SkinPack", PopupOptions.SkinPack); + // skin options + const PopupSkin *skin = 0; + if (skin = skins.getSkin(PopupOptions.SkinPack)) + skin->saveOpts(); + skins.freeAllButActive(); + // more Skin options + db_set_b(NULL, MODULNAME, "DisplayTime", PopupOptions.DisplayTime); + db_set_b(NULL, MODULNAME, "DropShadow", PopupOptions.DropShadow); + db_set_b(NULL, MODULNAME, "EnableShadowRegion", PopupOptions.EnableFreeformShadows); + db_set_b(NULL, MODULNAME, "EnableAeroGlass", PopupOptions.EnableAeroGlass); + db_set_b(NULL, MODULNAME, "UseMText", PopupOptions.UseMText); + }// end PSN_APPLY: + return TRUE; }// switch (((LPNMHDR)lParam)->code) break; }// end switch (((LPNMHDR)lParam)->idFrom) @@ -529,72 +523,73 @@ static void BoxPreview_OnPaint(HWND hwnd, HDC mydc, int mode) switch (mode) { case 0: - { // Avatar - HDC hdcAvatar = CreateCompatibleDC(mydc); - HBITMAP hbmSave = (HBITMAP)SelectObject(hdcAvatar, hbmNoAvatar); - GetClientRect(hwnd, &rc); - BITMAP bmp; - GetObject(hbmNoAvatar, sizeof(bmp), &bmp); - StretchBlt(mydc, 0, 0, rc.right, rc.bottom, hdcAvatar, 0, 0, abs(bmp.bmWidth), abs(bmp.bmHeight), SRCCOPY); - SelectObject(hdcAvatar, hbmSave); - DeleteDC(hdcAvatar); - HRGN rgn = CreateRoundRectRgn(0, 0, rc.right, rc.bottom, 2 * PopupOptions.avatarRadius, 2 * PopupOptions.avatarRadius); - FrameRgn(mydc, rgn, (HBRUSH)GetStockObject(BLACK_BRUSH), 1, 1); - DeleteObject(rgn); + { // Avatar + HDC hdcAvatar = CreateCompatibleDC(mydc); + HBITMAP hbmSave = (HBITMAP)SelectObject(hdcAvatar, hbmNoAvatar); + GetClientRect(hwnd, &rc); + BITMAP bmp; + GetObject(hbmNoAvatar, sizeof(bmp), &bmp); + StretchBlt(mydc, 0, 0, rc.right, rc.bottom, hdcAvatar, 0, 0, abs(bmp.bmWidth), abs(bmp.bmHeight), SRCCOPY); + SelectObject(hdcAvatar, hbmSave); + DeleteDC(hdcAvatar); + HRGN rgn = CreateRoundRectRgn(0, 0, rc.right, rc.bottom, 2 * PopupOptions.avatarRadius, 2 * PopupOptions.avatarRadius); + FrameRgn(mydc, rgn, (HBRUSH)GetStockObject(BLACK_BRUSH), 1, 1); + DeleteObject(rgn); + } break; - } + case 1: - { // Opacity - HBRUSH hbr = CreateSolidBrush(fonts.clBack); - HFONT hfnt = (HFONT)SelectObject(mydc, fonts.title); - GetClientRect(hwnd, &rc); - FillRect(mydc, &rc, hbr); - DrawIconEx(mydc, 10, (rc.bottom - rc.top - 16) / 2, IcoLib_GetIcon(ICO_POPUP_ON, 0), 16, 16, 0, hbr, DI_NORMAL); - SetBkMode(mydc, TRANSPARENT); - GetClientRect(hwnd, &rc); - rc.left += 30; // 10+16+4 -- icon - rc.right -= (rc.right - rc.left) / 3; - rc.bottom -= (rc.bottom - rc.top) / 3; - DrawText(mydc, _T(MODULNAME_LONG), -1, &rc, DT_CENTER | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER); - GetClientRect(hwnd, &rc); - rc.left += 30; // 10+16+4 -- icon - rc.left += (rc.right - rc.left) / 3; - rc.top += (rc.bottom - rc.top) / 3; - DrawText(mydc, _T(MODULNAME_LONG), -1, &rc, DT_CENTER | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER); - GetClientRect(hwnd, &rc); - FrameRect(mydc, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH)); - SelectObject(mydc, hfnt); - DeleteObject(hbr); - } - break; + { // Opacity + HBRUSH hbr = CreateSolidBrush(fonts.clBack); + HFONT hfnt = (HFONT)SelectObject(mydc, fonts.title); + GetClientRect(hwnd, &rc); + FillRect(mydc, &rc, hbr); + DrawIconEx(mydc, 10, (rc.bottom - rc.top - 16) / 2, IcoLib_GetIcon(ICO_POPUP_ON, 0), 16, 16, 0, hbr, DI_NORMAL); + SetBkMode(mydc, TRANSPARENT); + GetClientRect(hwnd, &rc); + rc.left += 30; // 10+16+4 -- icon + rc.right -= (rc.right - rc.left) / 3; + rc.bottom -= (rc.bottom - rc.top) / 3; + DrawText(mydc, _T(MODULNAME_LONG), -1, &rc, DT_CENTER | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER); + GetClientRect(hwnd, &rc); + rc.left += 30; // 10+16+4 -- icon + rc.left += (rc.right - rc.left) / 3; + rc.top += (rc.bottom - rc.top) / 3; + DrawText(mydc, _T(MODULNAME_LONG), -1, &rc, DT_CENTER | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER); + GetClientRect(hwnd, &rc); + FrameRect(mydc, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH)); + SelectObject(mydc, hfnt); + DeleteObject(hbr); + } + break; case 2: - { // Position - HBRUSH hbr = CreateSolidBrush(GetSysColor(COLOR_WINDOW)); - GetClientRect(hwnd, &rc); - FillRect(mydc, &rc, hbr); - DeleteObject(hbr); - - hbr = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT)); - GetClientRect(hwnd, &rc); - rc.right -= 100; - rc.top += 100; - FillRect(mydc, &rc, hbr); - DeleteObject(hbr); - - HPEN hpen = (HPEN)SelectObject(mydc, CreatePen(PS_DOT, 1, RGB(0, 0, 0))); - MoveToEx(mydc, 0, 100, NULL); - LineTo(mydc, 201, 100); - MoveToEx(mydc, 100, 0, NULL); - LineTo(mydc, 100, 201); - DeleteObject(SelectObject(mydc, hpen)); - - HRGN hrgn = CreateRectRgn(0, 0, 0, 0); - GetWindowRgn(hwnd, hrgn); - FrameRgn(mydc, hrgn, (HBRUSH)GetStockObject(BLACK_BRUSH), 1, 1); - DeleteObject(hrgn); - } - break; + { // Position + HBRUSH hbr = CreateSolidBrush(GetSysColor(COLOR_WINDOW)); + GetClientRect(hwnd, &rc); + FillRect(mydc, &rc, hbr); + DeleteObject(hbr); + + hbr = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT)); + GetClientRect(hwnd, &rc); + rc.right -= 100; + rc.top += 100; + FillRect(mydc, &rc, hbr); + DeleteObject(hbr); + + HPEN hpen = (HPEN)SelectObject(mydc, CreatePen(PS_DOT, 1, RGB(0, 0, 0))); + MoveToEx(mydc, 0, 100, NULL); + LineTo(mydc, 201, 100); + MoveToEx(mydc, 100, 0, NULL); + LineTo(mydc, 100, 201); + DeleteObject(SelectObject(mydc, hpen)); + + HRGN hrgn = CreateRectRgn(0, 0, 0, 0); + GetWindowRgn(hwnd, hrgn); + FrameRgn(mydc, hrgn, (HBRUSH)GetStockObject(BLACK_BRUSH), 1, 1); + DeleteObject(hrgn); + } + break; } } diff --git a/plugins/Popup/src/popup_gdiplus.cpp b/plugins/Popup/src/popup_gdiplus.cpp index aeee9ecb03..d323654740 100644 --- a/plugins/Popup/src/popup_gdiplus.cpp +++ b/plugins/Popup/src/popup_gdiplus.cpp @@ -43,7 +43,8 @@ void LoadGDIPlus() if (g_gdiplusToken == 0) Gdiplus::GdiplusStartup(&g_gdiplusToken, &gdiplusStartupInput, NULL); } - __except (EXCEPTION_EXECUTE_HANDLER) { + __except (EXCEPTION_EXECUTE_HANDLER) + { gbGdiPlusLoaded = false; } } @@ -55,7 +56,8 @@ void UnloadGDIPlus() if (g_gdiplusToken && gbGdiPlusLoaded) Gdiplus::GdiplusShutdown(g_gdiplusToken); } - __except (EXCEPTION_EXECUTE_HANDLER) { + __except (EXCEPTION_EXECUTE_HANDLER) + { // do nothing } gbGdiPlusLoaded = true; @@ -87,12 +89,10 @@ HBITMAP SkinEngine_CreateDIB32(int cx, int cy) UINT *ptPixels; HBITMAP DirectBitmap = CreateDIBSection(NULL, &RGB32BitsBITMAPINFO, DIB_RGB_COLORS, (void **)&ptPixels, NULL, 0); - if ((DirectBitmap == NULL || ptPixels == NULL) && cx != 0 && cy != 0) - { + if ((DirectBitmap == NULL || ptPixels == NULL) && cx != 0 && cy != 0) { ; } - else - { + else { memset(ptPixels, 0, cx*cy * 4); } return DirectBitmap; @@ -172,9 +172,8 @@ void GDIPlus_ExtractAnimatedGIF(TCHAR *szName, int width, int height, HBITMAP &p int * delays = (int*)mir_alloc(nFrameCount*sizeof(int)); memset(delays, 0, nFrameCount*sizeof(int)); - for (int i = 1; i < nFrameCount + 1; i++) - { - GUID pageGuid = FrameDimensionTime; + for (int i = 1; i < nFrameCount + 1; i++) { + GUID pageGuid = FrameDimensionTime; RectF rect((float)(i - 1)*clipWidth, (float)0, (float)clipWidth, (float)clipHeight); graphics.DrawImage(&image, rect, (float)0, (float)0, (float)imWidth, (float)imHeight, UnitPixel, &attr, NULL, NULL); image.SelectActiveFrame(&pageGuid, i); diff --git a/plugins/Popup/src/popup_thread.cpp b/plugins/Popup/src/popup_thread.cpp index 29f45dc3d7..a8f269635f 100644 --- a/plugins/Popup/src/popup_thread.cpp +++ b/plugins/Popup/src/popup_thread.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "headers.h" #include -// globals +// globals static int gIdleRequests = 0; static bool gTerminating = false; static HWND gHwndManager = 0; @@ -34,7 +34,7 @@ static HANDLE hThread = 0; static LIST popupList(3); -// forwards +// forwards enum { // message id's @@ -178,15 +178,14 @@ static LRESULT CALLBACK PopupThreadManagerWndProc(HWND hwnd, UINT message, WPARA break; case UTM_REMOVE_WINDOW: - { for (int i = popupList.getCount() - 1; i >= 0; i--) if (popupList[i] == wnd) popupList.remove(i); - } - RepositionPopups(); - --nPopups; - delete wnd; - break; + + RepositionPopups(); + --nPopups; + delete wnd; + break; case UTM_LOCK_QUEUE: ++gLockCount; diff --git a/plugins/Popup/src/popup_wnd2.cpp b/plugins/Popup/src/popup_wnd2.cpp index aad7891cbb..1dd02de909 100644 --- a/plugins/Popup/src/popup_wnd2.cpp +++ b/plugins/Popup/src/popup_wnd2.cpp @@ -968,16 +968,16 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara break; case ACT_DEF_ADD: - { - ADDCONTACTSTRUCT acs = { 0 }; - acs.hContact = m_hContact; - acs.handleType = HANDLE_CONTACT; - acs.szProto = 0; - CallServiceSync(MS_ADDCONTACT_SHOW, NULL, (LPARAM)&acs); - if (!(PopupOptions.actions&ACT_DEF_KEEPWND)) - PUDeletePopup(m_hwnd); - } - break; + { + ADDCONTACTSTRUCT acs = { 0 }; + acs.hContact = m_hContact; + acs.handleType = HANDLE_CONTACT; + acs.szProto = 0; + CallServiceSync(MS_ADDCONTACT_SHOW, NULL, (LPARAM)&acs); + if (!(PopupOptions.actions&ACT_DEF_KEEPWND)) + PUDeletePopup(m_hwnd); + } + break; case ACT_DEF_PIN: if (m_bIsPinned) @@ -1018,57 +1018,57 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara break; case UM_POPUPMODIFYACTIONICON: - { - LPPOPUPACTIONID actionId = (LPPOPUPACTIONID)wParam; - for (int i = 0; i < m_actionCount; ++i) - if ((m_actions[i].actionA.wParam == actionId->wParam) && - (m_actions[i].actionA.lParam == actionId->lParam)) { - m_actions[i].actionA.lchIcon = (HICON)lParam; - animate(); - break; - } - } - break; + { + LPPOPUPACTIONID actionId = (LPPOPUPACTIONID)wParam; + for (int i = 0; i < m_actionCount; ++i) + if ((m_actions[i].actionA.wParam == actionId->wParam) && + (m_actions[i].actionA.lParam == actionId->lParam)) { + m_actions[i].actionA.lchIcon = (HICON)lParam; + animate(); + break; + } + } + break; case UM_MENUDONE: - { - unlock(); - if (!(PopupOptions.actions&ACT_DEF_KEEPWND)) - PUDeletePopup(m_hwnd); - break; - } + { + unlock(); + if (!(PopupOptions.actions&ACT_DEF_KEEPWND)) + PUDeletePopup(m_hwnd); + break; + } case WM_LBUTTONUP: - { - int i; - for (i = 0; i < m_actionCount; ++i) - if (m_actions[i].hover) { - SendMessage(m_hwnd, UM_POPUPACTION, m_actions[i].actionA.wParam, m_actions[i].actionA.lParam); - break; - } + { + int i; + for (i = 0; i < m_actionCount; ++i) + if (m_actions[i].hover) { + SendMessage(m_hwnd, UM_POPUPACTION, m_actions[i].actionA.wParam, m_actions[i].actionA.lParam); + break; + } - if (i == m_actionCount) { - if (PopupOptions.overrideLeft != false && (m_hContact != NULL || PopupOptions.overrideLeft == 5 || PopupOptions.overrideLeft == 6)) { - switch (PopupOptions.overrideLeft) { - default: - case 1:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_MESSAGE); break; - case 2:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_REPLY); break; - case 3:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_DETAILS); break; - case 4:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_MENU); break; - case 5:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_DISMISS); break; - case 6:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_PIN); break; - case 7:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_COPY); break; + if (i == m_actionCount) { + if (PopupOptions.overrideLeft != false && (m_hContact != NULL || PopupOptions.overrideLeft == 5 || PopupOptions.overrideLeft == 6)) { + switch (PopupOptions.overrideLeft) { + default: + case 1:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_MESSAGE); break; + case 2:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_REPLY); break; + case 3:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_DETAILS); break; + case 4:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_MENU); break; + case 5:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_DISMISS); break; + case 6:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_PIN); break; + case 7:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_COPY); break; + } + } + else { + lock(); + if (!PerformAction(m_hNotification, m_hwnd, message, wParam, lParam)) + SendMessage(m_hwnd, WM_COMMAND, 0, 0); + unlock(); } } - else { - lock(); - if (!PerformAction(m_hNotification, m_hwnd, message, wParam, lParam)) - SendMessage(m_hwnd, WM_COMMAND, 0, 0); - unlock(); - } + break; } - break; - } case WM_MBUTTONUP: if (PopupOptions.overrideMiddle != false && (m_hContact != NULL || PopupOptions.overrideMiddle == 5 || PopupOptions.overrideMiddle == 6)) { @@ -1123,16 +1123,16 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara break; case AVATAR_TIMER: - { - int newDelay = m_avatar->activeFrameDelay(); - animate(); - if ((newDelay <= 0) || (newDelay != m_avatarFrameDelay)) KillTimer(m_hwnd, AVATAR_TIMER); - if (newDelay > 0) { - SetTimer(m_hwnd, AVATAR_TIMER, newDelay, 0); - m_avatarFrameDelay = newDelay; + { + int newDelay = m_avatar->activeFrameDelay(); + animate(); + if ((newDelay <= 0) || (newDelay != m_avatarFrameDelay)) KillTimer(m_hwnd, AVATAR_TIMER); + if (newDelay > 0) { + SetTimer(m_hwnd, AVATAR_TIMER, newDelay, 0); + m_avatarFrameDelay = newDelay; + } } - } - break; + break; case CURSOR_TIMER: POINT pt; GetCursorPos(&pt); @@ -1161,12 +1161,12 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara break; case UM_CALLMETHOD: - { - MethodPtr *method_copy = (MethodPtr *)wParam; - (this->*(*method_copy))(lParam); - delete method_copy; - } - break; + { + MethodPtr *method_copy = (MethodPtr *)wParam; + (this->*(*method_copy))(lParam); + delete method_copy; + } + break; case WM_PAINT: if (GetUpdateRect(m_hwnd, 0, FALSE)) { @@ -1184,44 +1184,44 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara break; case WM_MOUSEMOVE: - { - const PopupSkin *skin = skins.getSkin(m_lpzSkin ? m_lpzSkin : m_options->SkinPack); - if (skin) - if (skin->onMouseMove(this, LOWORD(lParam), HIWORD(lParam))) - animate(); - - if (m_bIsHovered) break; - TRACKMOUSEEVENT tme; - tme.cbSize = sizeof(tme); - tme.dwFlags = TME_LEAVE; - tme.dwHoverTime = HOVER_DEFAULT; - tme.hwndTrack = m_hwnd; - _TrackMouseEvent(&tme); - if (!m_customPopup) PopupThreadLock(); + { + const PopupSkin *skin = skins.getSkin(m_lpzSkin ? m_lpzSkin : m_options->SkinPack); + if (skin) + if (skin->onMouseMove(this, LOWORD(lParam), HIWORD(lParam))) + animate(); + + if (m_bIsHovered) break; + TRACKMOUSEEVENT tme; + tme.cbSize = sizeof(tme); + tme.dwFlags = TME_LEAVE; + tme.dwHoverTime = HOVER_DEFAULT; + tme.hwndTrack = m_hwnd; + _TrackMouseEvent(&tme); + if (!m_customPopup) PopupThreadLock(); - if (m_options->OpaqueOnHover) - updateLayered(255); + if (m_options->OpaqueOnHover) + updateLayered(255); - m_bIsHovered = true; - } - break; + m_bIsHovered = true; + } + break; case WM_MOUSELEAVE: - { - const PopupSkin *skin = skins.getSkin(m_lpzSkin ? m_lpzSkin : m_options->SkinPack); - if (skin) - if (skin->onMouseMove(this, LOWORD(lParam), HIWORD(lParam))) - animate(); + { + const PopupSkin *skin = skins.getSkin(m_lpzSkin ? m_lpzSkin : m_options->SkinPack); + if (skin) + if (skin->onMouseMove(this, LOWORD(lParam), HIWORD(lParam))) + animate(); - if (!m_bIsHovered) break; + if (!m_bIsHovered) break; - if (m_options->OpaqueOnHover) - updateLayered(m_options->UseTransparency ? m_options->Alpha : 255); + if (m_options->OpaqueOnHover) + updateLayered(m_options->UseTransparency ? m_options->Alpha : 255); - if (!m_customPopup) PopupThreadUnlock(); - m_bIsHovered = false; - } - break; + if (!m_customPopup) PopupThreadUnlock(); + m_bIsHovered = false; + } + break; case WM_CLOSE: hide(); diff --git a/plugins/Popup/src/services.cpp b/plugins/Popup/src/services.cpp index 1d54e21027..69b06749d8 100644 --- a/plugins/Popup/src/services.cpp +++ b/plugins/Popup/src/services.cpp @@ -284,28 +284,29 @@ INT_PTR Popup_Query(WPARAM wParam, LPARAM) return 0; switch (wParam) { - case PUQS_ENABLEPOPUPS: { - if (PopupOptions.ModuleIsEnabled) return 1; // They're already ON!!! - else { // Module was disabled. - svcEnableDisableMenuCommand(0, 0); - return 0; - } - } - case PUQS_DISABLEPOPUPS: { - if (!(PopupOptions.ModuleIsEnabled)) return 1; // They're already OFF!!! - else { - svcEnableDisableMenuCommand(0, 0); - return 0; - } - } + case PUQS_ENABLEPOPUPS: + if (PopupOptions.ModuleIsEnabled) + return 1; // They're already ON!!! + + // Module was disabled. + svcEnableDisableMenuCommand(0, 0); + return 0; + + case PUQS_DISABLEPOPUPS: + if (!(PopupOptions.ModuleIsEnabled)) + return 1; // They're already OFF!!! + + svcEnableDisableMenuCommand(0, 0); + return 0; + case PUQS_GETSTATUS: return (PopupOptions.ModuleIsEnabled); + default: return -1; } } - //===== Popup/RegisterActions INT_PTR Popup_RegisterActions(WPARAM wParam, LPARAM lParam) { @@ -427,9 +428,11 @@ INT_PTR Popup_UnregisterPopupClass(WPARAM, LPARAM lParam) } //===== Popup/AddPopupClass (for core class api support) -INT_PTR Popup_CreateClassPopup(WPARAM wParam, LPARAM lParam) { +INT_PTR Popup_CreateClassPopup(WPARAM wParam, LPARAM lParam) +{ POPUPDATACLASS *pdc = (POPUPDATACLASS *)lParam; - if (!pdc || (pdc->cbSize != sizeof(POPUPDATACLASS))) return 1; + if (!pdc || (pdc->cbSize != sizeof(POPUPDATACLASS))) + return 1; POPUPCLASS *pc; if (wParam) @@ -443,27 +446,27 @@ INT_PTR Popup_CreateClassPopup(WPARAM wParam, LPARAM lParam) { pc = NULL; mir_free(group); } - if (pc) { - POPUPDATA2 ppd2 = { sizeof(ppd2) }; - ppd2.colorBack = pc->colorBack; - ppd2.colorText = pc->colorText; - ppd2.lchIcon = pc->hIcon; - ppd2.iSeconds = pc->iSeconds; - ppd2.PluginWindowProc = pc->PluginWindowProc; - if (pc->flags & PCF_UNICODE) { - ppd2.flags = PU2_UNICODE; - ppd2.lptzTitle = (TCHAR*)pdc->ptszTitle; - ppd2.lptzText = (TCHAR*)pdc->ptszText; - } - else { - ppd2.flags = PU2_ANSI; - ppd2.lpzTitle = (char *)pdc->pszTitle; - ppd2.lpzText = (char *)pdc->pszText; - } - ppd2.lchContact = pdc->hContact; - ppd2.PluginData = pdc->PluginData; + if (pc == NULL) + return 1; - return Popup_AddPopup2((WPARAM)&ppd2, pc->lParam); + POPUPDATA2 ppd2 = { sizeof(ppd2) }; + ppd2.colorBack = pc->colorBack; + ppd2.colorText = pc->colorText; + ppd2.lchIcon = pc->hIcon; + ppd2.iSeconds = pc->iSeconds; + ppd2.PluginWindowProc = pc->PluginWindowProc; + if (pc->flags & PCF_UNICODE) { + ppd2.flags = PU2_UNICODE; + ppd2.lptzTitle = (TCHAR*)pdc->ptszTitle; + ppd2.lptzText = (TCHAR*)pdc->ptszText; } - return 1; + else { + ppd2.flags = PU2_ANSI; + ppd2.lpzTitle = (char *)pdc->pszTitle; + ppd2.lpzText = (char *)pdc->pszText; + } + ppd2.lchContact = pdc->hContact; + ppd2.PluginData = pdc->PluginData; + + return Popup_AddPopup2((WPARAM)&ppd2, pc->lParam); } diff --git a/plugins/Popup/src/skin.cpp b/plugins/Popup/src/skin.cpp index 751370ef54..c83a430b6b 100644 --- a/plugins/Popup/src/skin.cpp +++ b/plugins/Popup/src/skin.cpp @@ -226,81 +226,81 @@ void PopupSkin::measure(HDC hdc, PopupWnd2 *wnd, int maxw, POPUPOPTIONS *options SIZE szNew = { 0, 0 }; switch (head->type & ST_TYPEMASK) { case ST_TEXT: - { - int tmp = head->fw.eval(wnd->getArgs()); - // this is used to measure and layout text - wnd->getRenderInfo()->textw = tmp ? tmp : (maxw - head->fx.eval(wnd->getArgs())); - szNew.cx = wnd->getRenderInfo()->textw; - if (wnd->isTextEmpty()) - szNew.cx = szNew.cy = 0; - else { - HFONT hFntSave = (HFONT)SelectObject(hdc, fonts.text); - switch (wnd->getTextType()) { - case PopupWnd2::TT_UNICODE: - { - RECT rc; SetRect(&rc, 0, 0, szNew.cx, 0); - DrawTextEx(hdc, wnd->getText(), (int)mir_tstrlen(wnd->getText()), &rc, - DT_CALCRECT | DT_EXPANDTABS | DT_LEFT | DT_NOPREFIX | DT_TOP | DT_WORDBREAK/*|DT_RTLREADING*/, NULL); - szNew.cx = rc.right; - szNew.cy = rc.bottom; - } - break; - case PopupWnd2::TT_MTEXT: - MText.Measure(hdc, &szNew, wnd->getTextM()); - break; + { + int tmp = head->fw.eval(wnd->getArgs()); + // this is used to measure and layout text + wnd->getRenderInfo()->textw = tmp ? tmp : (maxw - head->fx.eval(wnd->getArgs())); + szNew.cx = wnd->getRenderInfo()->textw; + if (wnd->isTextEmpty()) + szNew.cx = szNew.cy = 0; + else { + HFONT hFntSave = (HFONT)SelectObject(hdc, fonts.text); + switch (wnd->getTextType()) { + case PopupWnd2::TT_UNICODE: + { + RECT rc; SetRect(&rc, 0, 0, szNew.cx, 0); + DrawTextEx(hdc, wnd->getText(), (int)mir_tstrlen(wnd->getText()), &rc, + DT_CALCRECT | DT_EXPANDTABS | DT_LEFT | DT_NOPREFIX | DT_TOP | DT_WORDBREAK/*|DT_RTLREADING*/, NULL); + szNew.cx = rc.right; + szNew.cy = rc.bottom; + } + break; + case PopupWnd2::TT_MTEXT: + MText.Measure(hdc, &szNew, wnd->getTextM()); + break; + } + SelectObject(hdc, hFntSave); } - SelectObject(hdc, hFntSave); - } - wnd->getRenderInfo()->texth = szNew.cy; + wnd->getRenderInfo()->texth = szNew.cy; - SIZE szActions = measureActionBar(hdc, wnd); - wnd->getRenderInfo()->actw = szActions.cx; - if (szActions.cy) { - szNew.cx = max(szNew.cx, szActions.cx); - szNew.cy += szActions.cy; - szNew.cy += 3; - } + SIZE szActions = measureActionBar(hdc, wnd); + wnd->getRenderInfo()->actw = szActions.cx; + if (szActions.cy) { + szNew.cx = max(szNew.cx, szActions.cx); + szNew.cy += szActions.cy; + szNew.cy += 3; + } - wnd->getRenderInfo()->realtextw = szNew.cx; + wnd->getRenderInfo()->realtextw = szNew.cx; - if (szNew.cx > maxw - head->fx.eval(wnd->getArgs())) - szNew.cx = maxw - head->fx.eval(wnd->getArgs()); - wnd->getArgs()->add("text.width", szNew.cx); - wnd->getArgs()->add("text.height", szNew.cy); - } - break; + if (szNew.cx > maxw - head->fx.eval(wnd->getArgs())) + szNew.cx = maxw - head->fx.eval(wnd->getArgs()); + wnd->getArgs()->add("text.width", szNew.cx); + wnd->getArgs()->add("text.height", szNew.cy); + } + break; case ST_TITLE: - { - int tmp = head->fw.eval(wnd->getArgs()); - // this is used to measure and layout text - wnd->getRenderInfo()->titlew = tmp ? tmp : (maxw - head->fx.eval(wnd->getArgs()) - STYLE_SZ_CLOCK); - szNew.cx = wnd->getRenderInfo()->titlew; - HFONT hFntSave = (HFONT)SelectObject(hdc, fonts.title); - switch (wnd->getTextType()) { - case PopupWnd2::TT_UNICODE: { - RECT rc; SetRect(&rc, 0, 0, szNew.cx, 0); - DrawTextEx(hdc, wnd->getTitle(), (int)mir_tstrlen(wnd->getTitle()), &rc, - DT_CALCRECT | DT_EXPANDTABS | DT_LEFT | DT_NOPREFIX | DT_TOP | DT_WORDBREAK/*|DT_RTLREADING*/, NULL); - szNew.cx = rc.right; - szNew.cy = rc.bottom; + int tmp = head->fw.eval(wnd->getArgs()); + // this is used to measure and layout text + wnd->getRenderInfo()->titlew = tmp ? tmp : (maxw - head->fx.eval(wnd->getArgs()) - STYLE_SZ_CLOCK); + szNew.cx = wnd->getRenderInfo()->titlew; + HFONT hFntSave = (HFONT)SelectObject(hdc, fonts.title); + switch (wnd->getTextType()) { + case PopupWnd2::TT_UNICODE: + { + RECT rc; SetRect(&rc, 0, 0, szNew.cx, 0); + DrawTextEx(hdc, wnd->getTitle(), (int)mir_tstrlen(wnd->getTitle()), &rc, + DT_CALCRECT | DT_EXPANDTABS | DT_LEFT | DT_NOPREFIX | DT_TOP | DT_WORDBREAK/*|DT_RTLREADING*/, NULL); + szNew.cx = rc.right; + szNew.cy = rc.bottom; + } + break; + case PopupWnd2::TT_MTEXT: + MText.Measure(hdc, &szNew, wnd->getTitleM()); + break; + } + + SelectObject(hdc, hFntSave); + if (szNew.cx > maxw - head->fx.eval(wnd->getArgs()) - STYLE_SZ_CLOCK) + szNew.cx = maxw - head->fx.eval(wnd->getArgs()) - STYLE_SZ_CLOCK; + szNew.cx += STYLE_SZ_CLOCK; + wnd->getArgs()->add("title.width", szNew.cx); + wnd->getArgs()->add("title.height", szNew.cy); } break; - case PopupWnd2::TT_MTEXT: - MText.Measure(hdc, &szNew, wnd->getTitleM()); - break; - } - - SelectObject(hdc, hFntSave); - if (szNew.cx > maxw - head->fx.eval(wnd->getArgs()) - STYLE_SZ_CLOCK) - szNew.cx = maxw - head->fx.eval(wnd->getArgs()) - STYLE_SZ_CLOCK; - szNew.cx += STYLE_SZ_CLOCK; - wnd->getArgs()->add("title.width", szNew.cx); - wnd->getArgs()->add("title.height", szNew.cy); - } - break; case ST_ICON: szNew.cx = szNew.cy = 16; @@ -499,12 +499,12 @@ void PopupSkin::display(MyBitmap *bmp, PopupWnd2 *wnd, POPUPOPTIONS *options, DW bmp->saveAlpha(); switch (wnd->getTextType()) { case PopupWnd2::TT_UNICODE: - { - RECT rc; SetRect(&rc, pos.x, pos.y, pos.x + sz.cx, pos.y + sz.cy); - DrawTextEx(hdc, wnd->getText(), (int)mir_tstrlen(wnd->getText()), &rc, - DT_EXPANDTABS | DT_LEFT | DT_NOPREFIX | DT_TOP | DT_WORDBREAK/*|DT_RTLREADING*/, NULL); - } - break; + { + RECT rc; SetRect(&rc, pos.x, pos.y, pos.x + sz.cx, pos.y + sz.cy); + DrawTextEx(hdc, wnd->getText(), (int)mir_tstrlen(wnd->getText()), &rc, + DT_EXPANDTABS | DT_LEFT | DT_NOPREFIX | DT_TOP | DT_WORDBREAK/*|DT_RTLREADING*/, NULL); + } + break; case PopupWnd2::TT_MTEXT: MText.Display(hdc, pos, sz, wnd->getTextM()); break; @@ -547,14 +547,14 @@ void PopupSkin::display(MyBitmap *bmp, PopupWnd2 *wnd, POPUPOPTIONS *options, DW switch (wnd->getTextType()) { case PopupWnd2::TT_UNICODE: - { - HFONT hFntSave = (HFONT)SelectObject(hdc, fonts.title); - RECT rc; SetRect(&rc, pos.x, pos.y, pos.x + sz.cx, pos.y + sz.cy); - DrawTextEx(hdc, wnd->getTitle(), (int)mir_tstrlen(wnd->getTitle()), &rc, - DT_EXPANDTABS | DT_LEFT | DT_NOPREFIX | DT_TOP | DT_WORDBREAK/*|DT_RTLREADING*/, NULL); - SelectObject(hdc, hFntSave); - } - break; + { + HFONT hFntSave = (HFONT)SelectObject(hdc, fonts.title); + RECT rc; SetRect(&rc, pos.x, pos.y, pos.x + sz.cx, pos.y + sz.cy); + DrawTextEx(hdc, wnd->getTitle(), (int)mir_tstrlen(wnd->getTitle()), &rc, + DT_EXPANDTABS | DT_LEFT | DT_NOPREFIX | DT_TOP | DT_WORDBREAK/*|DT_RTLREADING*/, NULL); + SelectObject(hdc, hFntSave); + } + break; case PopupWnd2::TT_MTEXT: HFONT hFntSave = (HFONT)SelectObject(hdc, fonts.title); MText.Display(hdc, pos, sz, wnd->getTitleM()); @@ -956,12 +956,8 @@ PopupSkin::SKINELEMENT *PopupSkin::loadObject(std::wistream &f) } else if (!mir_tstrcmp(buf, _T("source"))) { f >> buf; - if (((element->type & ST_TYPEMASK) == ST_MYBITMAP) || ((element->type & ST_TYPEMASK) == ST_CLOCK)) { - TCHAR *alpha = mir_tstrdup(buf); - alpha[mir_tstrlen(alpha) - 1] = 'a'; - element->myBmp = new MyBitmap(buf, alpha); - mir_free(alpha); - } + if (((element->type & ST_TYPEMASK) == ST_MYBITMAP) || ((element->type & ST_TYPEMASK) == ST_CLOCK)) + element->myBmp = new MyBitmap(buf); } else if (!mir_tstrcmp(buf, _T("mono"))) { element->type |= ST_MONO; -- cgit v1.2.3