diff options
Diffstat (limited to 'src/modules/utils')
-rw-r--r-- | src/modules/utils/colourpicker.cpp | 65 | ||||
-rw-r--r-- | src/modules/utils/imgconv.cpp | 155 | ||||
-rw-r--r-- | src/modules/utils/openurl.cpp | 9 | ||||
-rw-r--r-- | src/modules/utils/timezones.cpp | 10 |
4 files changed, 113 insertions, 126 deletions
diff --git a/src/modules/utils/colourpicker.cpp b/src/modules/utils/colourpicker.cpp index badfcb712e..fccd240660 100644 --- a/src/modules/utils/colourpicker.cpp +++ b/src/modules/utils/colourpicker.cpp @@ -25,45 +25,46 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static LRESULT CALLBACK ColourPickerWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message) {
- case WM_CREATE:
- SetWindowLongPtr(hwnd, 0, 0);
- SetWindowLongPtr(hwnd, sizeof(COLORREF), 0);
- break;
- case CPM_SETDEFAULTCOLOUR:
- SetWindowLongPtr(hwnd, sizeof(COLORREF), lParam);
- break;
- case CPM_GETDEFAULTCOLOUR:
- return GetWindowLongPtr(hwnd, sizeof(COLORREF));
- case CPM_SETCOLOUR:
- SetWindowLongPtr(hwnd, 0, lParam);
- InvalidateRect(hwnd, NULL, FALSE);
- break;
- case CPM_GETCOLOUR:
- return GetWindowLongPtr(hwnd, 0);
- case WM_LBUTTONUP:
+ case WM_CREATE:
+ SetWindowLongPtr(hwnd, 0, 0);
+ SetWindowLongPtr(hwnd, sizeof(COLORREF), 0);
+ break;
+ case CPM_SETDEFAULTCOLOUR:
+ SetWindowLongPtr(hwnd, sizeof(COLORREF), lParam);
+ break;
+ case CPM_GETDEFAULTCOLOUR:
+ return GetWindowLongPtr(hwnd, sizeof(COLORREF));
+ case CPM_SETCOLOUR:
+ SetWindowLongPtr(hwnd, 0, lParam);
+ InvalidateRect(hwnd, NULL, FALSE);
+ break;
+ case CPM_GETCOLOUR:
+ return GetWindowLongPtr(hwnd, 0);
+ case WM_LBUTTONUP:
{
- CHOOSECOLOR cc = {0};
- COLORREF custColours[16] = {0};
+ CHOOSECOLOR cc = {0};
+ COLORREF custColours[16] = {0};
custColours[0] = GetWindowLongPtr(hwnd, sizeof(COLORREF));
- cc.lStructSize = sizeof(CHOOSECOLOR);
- cc.hwndOwner = hwnd;
- cc.hInstance = (HWND)hInst;
- cc.rgbResult = GetWindowLongPtr(hwnd, 0);
- cc.lpCustColors = custColours;
- cc.Flags = CC_ANYCOLOR|CC_FULLOPEN|CC_RGBINIT;
- if (ChooseColor(&cc)) {
+ cc.lStructSize = sizeof(CHOOSECOLOR);
+ cc.hwndOwner = hwnd;
+ cc.hInstance = (HWND)hInst;
+ cc.rgbResult = GetWindowLongPtr(hwnd, 0);
+ cc.lpCustColors = custColours;
+ cc.Flags = CC_ANYCOLOR|CC_FULLOPEN|CC_RGBINIT;
+ if (ChooseColor(&cc)) {
SetWindowLongPtr(hwnd, 0, cc.rgbResult);
SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hwnd), CPN_COLOURCHANGED), (LPARAM)hwnd);
InvalidateRect(hwnd, NULL, FALSE);
}
break;
}
- case WM_ENABLE:
- InvalidateRect(hwnd, NULL, FALSE);
- break;
- case WM_NCPAINT:
- case WM_PAINT:
- { PAINTSTRUCT ps;
+ case WM_ENABLE:
+ InvalidateRect(hwnd, NULL, FALSE);
+ break;
+ case WM_NCPAINT:
+ case WM_PAINT:
+ {
+ PAINTSTRUCT ps;
HDC hdc1;
RECT rc;
HBRUSH hBrush;
@@ -82,8 +83,6 @@ static LRESULT CALLBACK ColourPickerWndProc(HWND hwnd, UINT message, WPARAM wPar EndPaint(hwnd, &ps);
break;
}
- case WM_DESTROY:
- break;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
diff --git a/src/modules/utils/imgconv.cpp b/src/modules/utils/imgconv.cpp index 216167316b..03c39eef1d 100644 --- a/src/modules/utils/imgconv.cpp +++ b/src/modules/utils/imgconv.cpp @@ -26,13 +26,13 @@ typedef DWORD ARGB; void InitBitmapInfo(BITMAPINFO &bmi, const SIZE &size)
{
ZeroMemory(&bmi, sizeof(BITMAPINFO));
- bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biCompression = BI_RGB;
- bmi.bmiHeader.biBitCount = 32;
+ bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ bmi.bmiHeader.biPlanes = 1;
+ bmi.bmiHeader.biCompression = BI_RGB;
+ bmi.bmiHeader.biBitCount = 32;
- bmi.bmiHeader.biWidth = size.cx;
- bmi.bmiHeader.biHeight = size.cy;
+ bmi.bmiHeader.biWidth = size.cx;
+ bmi.bmiHeader.biHeight = size.cy;
}
void ConvertToPARGB32(HDC hdc, ARGB *pargb, HBITMAP hbmp, SIZE& sizImage, int cxRow)
@@ -41,77 +41,67 @@ void ConvertToPARGB32(HDC hdc, ARGB *pargb, HBITMAP hbmp, SIZE& sizImage, int cx InitBitmapInfo(bmi, sizImage);
void *pvBits = malloc(sizImage.cx * 4 * sizImage.cy);
- if (GetDIBits(hdc, hbmp, 0, bmi.bmiHeader.biHeight, pvBits, &bmi, DIB_RGB_COLORS) == bmi.bmiHeader.biHeight)
- {
- ULONG cxDelta = cxRow - bmi.bmiHeader.biWidth;
- ARGB *pargbMask = (ARGB *)pvBits;
-
- for (ULONG y = bmi.bmiHeader.biHeight + 1; --y;)
- {
- for (ULONG x = bmi.bmiHeader.biWidth + 1; --x;)
- {
- if (*pargbMask++)
- {
- // transparent pixel
- *pargb++=0;
- }
- else
- {
- // opaque pixel
- *pargb++ |= 0xFF000000;
- }
- }
-
- pargb += cxDelta;
- }
- }
- free(pvBits);
+ if (GetDIBits(hdc, hbmp, 0, bmi.bmiHeader.biHeight, pvBits, &bmi, DIB_RGB_COLORS) == bmi.bmiHeader.biHeight) {
+ ULONG cxDelta = cxRow - bmi.bmiHeader.biWidth;
+ ARGB *pargbMask = (ARGB *)pvBits;
+
+ for (ULONG y = bmi.bmiHeader.biHeight + 1; --y;) {
+ for (ULONG x = bmi.bmiHeader.biWidth + 1; --x;) {
+ if (*pargbMask++) {
+ // transparent pixel
+ *pargb++=0;
+ }
+ else {
+ // opaque pixel
+ *pargb++ |= 0xFF000000;
+ }
+ }
+
+ pargb += cxDelta;
+ }
+ }
+ free(pvBits);
}
bool HasAlpha(ARGB *pargb, SIZE& sizImage, int cxRow)
{
- ULONG cxDelta = cxRow - sizImage.cx;
- for (ULONG y = sizImage.cy; y--;)
- {
- for (ULONG x = sizImage.cx; x--;)
- {
- if (*pargb++ & 0xFF000000)
- return true;
- }
- pargb += cxDelta;
- }
-
- return false;
+ ULONG cxDelta = cxRow - sizImage.cx;
+ for (ULONG y = sizImage.cy; y--;) {
+ for (ULONG x = sizImage.cx; x--;) {
+ if (*pargb++ & 0xFF000000)
+ return true;
+ }
+ pargb += cxDelta;
+ }
+
+ return false;
}
void ConvertBufferToPARGB32(HANDLE hPaintBuffer, HDC hdc, HICON hIcon, SIZE& sizIcon)
{
- RGBQUAD *prgbQuad;
- int cxRow;
- HRESULT hr = getBufferedPaintBits(hPaintBuffer, &prgbQuad, &cxRow);
- if (SUCCEEDED(hr))
- {
- ARGB *pargb = (ARGB *)prgbQuad;
- if ( !HasAlpha(pargb, sizIcon, cxRow))
- {
- ICONINFO info;
- if (GetIconInfo(hIcon, &info))
- {
- if (info.hbmMask)
- ConvertToPARGB32(hdc, pargb, info.hbmMask, sizIcon, cxRow);
-
- DeleteObject(info.hbmColor);
- DeleteObject(info.hbmMask);
- }
- }
- }
+ RGBQUAD *prgbQuad;
+ int cxRow;
+ HRESULT hr = getBufferedPaintBits(hPaintBuffer, &prgbQuad, &cxRow);
+ if (SUCCEEDED(hr)) {
+ ARGB *pargb = (ARGB *)prgbQuad;
+ if ( !HasAlpha(pargb, sizIcon, cxRow)) {
+ ICONINFO info;
+ if (GetIconInfo(hIcon, &info)) {
+ if (info.hbmMask)
+ ConvertToPARGB32(hdc, pargb, info.hbmMask, sizIcon, cxRow);
+
+ DeleteObject(info.hbmColor);
+ DeleteObject(info.hbmMask);
+ }
+ }
+ }
}
HBITMAP ConvertIconToBitmap(HICON hicon, HIMAGELIST hIml, int iconId)
{
- SIZE sizIcon;
- sizIcon.cx = GetSystemMetrics(SM_CXSMICON);
- sizIcon.cy = GetSystemMetrics(SM_CYSMICON);
+ SIZE sizIcon;
+ sizIcon.cx = GetSystemMetrics(SM_CXSMICON);
+ sizIcon.cy = GetSystemMetrics(SM_CYSMICON);
RECT rcIcon = { 0, 0, sizIcon.cx, sizIcon.cy };
@@ -121,32 +111,31 @@ HBITMAP ConvertIconToBitmap(HICON hicon, HIMAGELIST hIml, int iconId) InitBitmapInfo(bmi, sizIcon);
HBITMAP hbmp = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, NULL, NULL, 0);
- HBITMAP hbmpOld = (HBITMAP)SelectObject(hdc, hbmp);
+ HBITMAP hbmpOld = (HBITMAP)SelectObject(hdc, hbmp);
BLENDFUNCTION bfAlpha = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
- BP_PAINTPARAMS paintParams = {0};
- paintParams.cbSize = sizeof(paintParams);
- paintParams.dwFlags = BPPF_ERASE;
- paintParams.pBlendFunction = &bfAlpha;
-
- HDC hdcBuffer;
- HANDLE hPaintBuffer = beginBufferedPaint(hdc, &rcIcon, BPBF_DIB, &paintParams, &hdcBuffer);
- if (hPaintBuffer)
- {
+ BP_PAINTPARAMS paintParams = {0};
+ paintParams.cbSize = sizeof(paintParams);
+ paintParams.dwFlags = BPPF_ERASE;
+ paintParams.pBlendFunction = &bfAlpha;
+
+ HDC hdcBuffer;
+ HANDLE hPaintBuffer = beginBufferedPaint(hdc, &rcIcon, BPBF_DIB, &paintParams, &hdcBuffer);
+ if (hPaintBuffer) {
if (hIml)
ImageList_Draw(hIml, iconId, hdc, 0, 0, ILD_TRANSPARENT);
else
DrawIconEx(hdcBuffer, 0, 0, hicon, sizIcon.cx, sizIcon.cy, 0, NULL, DI_NORMAL);
-
+
// If icon did not have an alpha channel we need to convert buffer to PARGB
- ConvertBufferToPARGB32(hPaintBuffer, hdc, hicon, sizIcon);
+ ConvertBufferToPARGB32(hPaintBuffer, hdc, hicon, sizIcon);
- // This will write the buffer contents to the destination bitmap
- endBufferedPaint(hPaintBuffer, TRUE);
- }
+ // This will write the buffer contents to the destination bitmap
+ endBufferedPaint(hPaintBuffer, TRUE);
+ }
- SelectObject(hdc, hbmpOld);
- DeleteDC(hdc);
+ SelectObject(hdc, hbmpOld);
+ DeleteDC(hdc);
- return hbmp;
+ return hbmp;
}
diff --git a/src/modules/utils/openurl.cpp b/src/modules/utils/openurl.cpp index 4caa9fb022..a50ee22e7e 100644 --- a/src/modules/utils/openurl.cpp +++ b/src/modules/utils/openurl.cpp @@ -31,8 +31,8 @@ typedef struct { static void OpenURLThread(void *arg)
{
- TOpenUrlInfo *hUrlInfo = (TOpenUrlInfo*)arg;
- if ( !hUrlInfo->szUrl)
+ TOpenUrlInfo *hUrlInfo = (TOpenUrlInfo*)arg;
+ if ( !hUrlInfo->szUrl)
return;
//wack a protocol on it
@@ -52,15 +52,14 @@ static void OpenURLThread(void *arg) wsprintf(szResult, _T("http://%s"), hUrlInfo->szUrl);
}
}
-
+
// check user defined browser for opening urls
DBVARIANT dbv;
if (!DBGetContactSettingTString(NULL, "Miranda", "OpenUrlBrowser", &dbv)) {
ShellExecute(NULL, _T("open"), dbv.ptszVal, szResult, NULL, (hUrlInfo->newWindow) ? SW_NORMAL : SW_SHOWDEFAULT);
DBFreeVariant(&dbv);
- } else {
- ShellExecute(NULL, _T("open"), szResult, NULL, NULL, (hUrlInfo->newWindow) ? SW_NORMAL : SW_SHOWDEFAULT);
}
+ else ShellExecute(NULL, _T("open"), szResult, NULL, NULL, (hUrlInfo->newWindow) ? SW_NORMAL : SW_SHOWDEFAULT);
mir_free(szResult);
mir_free(hUrlInfo->szUrl);
diff --git a/src/modules/utils/timezones.cpp b/src/modules/utils/timezones.cpp index 96935bb8af..5342b82d5c 100644 --- a/src/modules/utils/timezones.cpp +++ b/src/modules/utils/timezones.cpp @@ -58,11 +58,11 @@ static pfnSendMessageW_t pfnSendMessageW; typedef struct _REG_TZI_FORMAT
{
- LONG Bias;
- LONG StandardBias;
- LONG DaylightBias;
- SYSTEMTIME StandardDate;
- SYSTEMTIME DaylightDate;
+ LONG Bias;
+ LONG StandardBias;
+ LONG DaylightBias;
+ SYSTEMTIME StandardDate;
+ SYSTEMTIME DaylightDate;
} REG_TZI_FORMAT;
#define MIM_TZ_DISPLAYLEN 128
|