summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/TipperYM/src/bitmap_func.cpp35
-rw-r--r--plugins/TipperYM/src/bitmap_func.h5
-rw-r--r--plugins/TipperYM/src/mir_smileys.cpp159
-rw-r--r--plugins/TipperYM/src/popwin.cpp132
-rw-r--r--plugins/TipperYM/src/version.h2
5 files changed, 140 insertions, 193 deletions
diff --git a/plugins/TipperYM/src/bitmap_func.cpp b/plugins/TipperYM/src/bitmap_func.cpp
index e1d20ed86e..d664f7420a 100644
--- a/plugins/TipperYM/src/bitmap_func.cpp
+++ b/plugins/TipperYM/src/bitmap_func.cpp
@@ -399,12 +399,8 @@ void DestroySkinBitmap()
skin.bCached = false;
}
-void SaveAlpha(LPRECT lpRect)
+COLOR32* SaveAlpha(LPRECT lpRect)
{
- if (skin.colSavedBits) {
- mir_free(skin.colSavedBits);
- skin.colSavedBits = 0;
- }
GdiFlush();
if (lpRect->left < 0) lpRect->left = 0;
@@ -417,8 +413,8 @@ void SaveAlpha(LPRECT lpRect)
int w = lpRect->right - lpRect->left;
int h = lpRect->bottom - lpRect->top;
- skin.colSavedBits = (COLOR32 *)mir_alloc(sizeof(COLOR32) * w * h);
- COLOR32 *p1 = skin.colSavedBits;
+ COLOR32 *res = (COLOR32 *)mir_alloc(sizeof(COLOR32) * w * h);
+ COLOR32 *p1 = res;
for (int i = 0; i < h; i++) {
if (i+y < 0) continue;
@@ -430,13 +426,11 @@ void SaveAlpha(LPRECT lpRect)
*p1++ = *p2++;
}
}
+ return res;
}
-void RestoreAlpha(LPRECT lpRect, BYTE alpha)
+void RestoreAlpha(LPRECT lpRect, COLOR32 *pBits, BYTE alpha)
{
- if (!skin.colSavedBits)
- return;
-
GdiFlush();
if (lpRect->left < 0) lpRect->left = 0;
@@ -449,7 +443,7 @@ void RestoreAlpha(LPRECT lpRect, BYTE alpha)
int w = lpRect->right - lpRect->left;
int h = lpRect->bottom - lpRect->top;
- COLOR32 *p1 = skin.colSavedBits;
+ COLOR32 *p1 = pBits;
for (int i = 0; i < h; i++) {
if (i+y < 0) continue;
@@ -467,9 +461,6 @@ void RestoreAlpha(LPRECT lpRect, BYTE alpha)
++p1; ++p2;
}
}
-
- mir_free(skin.colSavedBits);
- skin.colSavedBits = 0;
}
BOOL IsAlphaTransparent(HBITMAP hBitmap)
@@ -504,7 +495,7 @@ BOOL IsAlphaTransparent(HBITMAP hBitmap)
void DrawIconExAlpha(HDC hdc, int xLeft, int yTop, HICON hIcon, int cxWidth, int cyWidth, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags, bool bIsSmiley)
{
- bool restore = false;
+ mir_ptr<COLOR32> pBits;
if (skin.bNeedLayerUpdate && !bIsSmiley) {
ICONINFO icon;
@@ -512,8 +503,7 @@ void DrawIconExAlpha(HDC hdc, int xLeft, int yTop, HICON hIcon, int cxWidth, int
if ( !IsAlphaTransparent(icon.hbmColor)) {
RECT rc;
SetRect(&rc, xLeft, yTop, xLeft + cxWidth, yTop + cyWidth);
- SaveAlpha(&rc);
- restore = true;
+ pBits = SaveAlpha(&rc);
}
DeleteObject(icon.hbmColor);
@@ -523,10 +513,10 @@ void DrawIconExAlpha(HDC hdc, int xLeft, int yTop, HICON hIcon, int cxWidth, int
DrawIconEx(hdc, xLeft, yTop, hIcon, cxWidth, cyWidth, istepIfAniCur, hbrFlickerFreeDraw, diFlags);
- if (skin.bNeedLayerUpdate && restore) {
+ if (skin.bNeedLayerUpdate && pBits != NULL) {
RECT rc;
SetRect(&rc, xLeft, yTop, xLeft + cxWidth, yTop + cyWidth);
- RestoreAlpha(&rc);
+ RestoreAlpha(&rc, pBits);
}
}
@@ -535,9 +525,10 @@ int DrawTextAlpha(HDC hdc, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFo
RECT rc;
SetRect(&rc, lpRect->left - 1, lpRect->top - 1, lpRect->right + 1, lpRect->bottom + 1);
- if (skin.bNeedLayerUpdate) SaveAlpha(&rc);
+ mir_ptr<COLOR32> pBits;
+ if (skin.bNeedLayerUpdate) pBits = SaveAlpha(&rc);
int result = DrawText(hdc, lpString, nCount, lpRect, uFormat);
- if (skin.bNeedLayerUpdate) RestoreAlpha(&rc);
+ if (skin.bNeedLayerUpdate) RestoreAlpha(&rc, pBits);
return result;
}
diff --git a/plugins/TipperYM/src/bitmap_func.h b/plugins/TipperYM/src/bitmap_func.h
index ea4c11bd52..ec79f1d8fe 100644
--- a/plugins/TipperYM/src/bitmap_func.h
+++ b/plugins/TipperYM/src/bitmap_func.h
@@ -51,7 +51,6 @@ typedef struct {
HBITMAP hbmpSkinParts[SKIN_ITEMS_COUNT][SKIN_PARTS_COUNT];
FIBITMAP *fib[SKIN_ITEMS_COUNT];
COLOR32 *colBits;
- COLOR32 *colSavedBits;
int iWidth;
int iHeight;
bool bNeedLayerUpdate;
@@ -62,8 +61,8 @@ void CreateSkinBitmap(int iWidth, int iHeight, bool bServiceTip);
void DestroySkinBitmap();
int DrawTextAlpha(HDC hdc, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat);
void DrawIconExAlpha(HDC hdc, int xLeft, int yTop, HICON hIcon, int cxWidth, int cyWidth, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags, bool bIsSmiley);
-void SaveAlpha(LPRECT lpRect);
-void RestoreAlpha(LPRECT lpRect, BYTE alpha = 0xff);
+COLOR32* SaveAlpha(LPRECT lpRect);
+void RestoreAlpha(LPRECT lpRect, COLOR32 *pBits, BYTE alpha = 0xff);
void PremultipleChannels();
void ColorizeBitmap();
HRGN CreateOpaqueRgn(BYTE level, bool bOpaque);
diff --git a/plugins/TipperYM/src/mir_smileys.cpp b/plugins/TipperYM/src/mir_smileys.cpp
index ca94e5310c..53cc09fe46 100644
--- a/plugins/TipperYM/src/mir_smileys.cpp
+++ b/plugins/TipperYM/src/mir_smileys.cpp
@@ -23,8 +23,7 @@ Boston, MA 02111-1307, USA.
int InitTipperSmileys()
{
// Register smiley category
- if (ServiceExists(MS_SMILEYADD_REGISTERCATEGORY))
- {
+ if (ServiceExists(MS_SMILEYADD_REGISTERCATEGORY)) {
SMADD_REGCAT rc;
rc.cbSize = sizeof(rc);
rc.name = "tipper";
@@ -43,11 +42,10 @@ SMILEYPARSEINFO Smileys_PreParse(LPCTSTR lpString, int nCount, const char *proto
if (nCount == -1)
nCount = (int)mir_tstrlen(lpString);
- SMILEYPARSEINFO info = (SMILEYPARSEINFO) mir_calloc(sizeof(tagSMILEYPARSEINFO));
+ SMILEYPARSEINFO info = (SMILEYPARSEINFO)mir_calloc(sizeof(tagSMILEYPARSEINFO));
info->pieces = ReplaceSmileys(lpString, nCount, protocol, &info->max_height);
- if (!info->pieces)
- {
+ if (!info->pieces) {
mir_free(info);
return NULL;
}
@@ -57,8 +55,7 @@ SMILEYPARSEINFO Smileys_PreParse(LPCTSTR lpString, int nCount, const char *proto
void Smileys_FreeParse(SMILEYPARSEINFO parseInfo)
{
- if (parseInfo != NULL)
- {
+ if (parseInfo != NULL) {
if (parseInfo->pieces != NULL)
DestroySmileyList(parseInfo->pieces);
@@ -109,72 +106,62 @@ int Smileys_DrawText(HDC hDC, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT
SIZE GetTextSize(HDC hdcMem, const TCHAR *szText, SMILEYPARSEINFO info, UINT uTextFormat, int max_smiley_height, int max_width)
{
- SIZE text_size = {0};
+ SIZE text_size = { 0 };
int text_height;
int row_count = 0, pos_x = 0;
- if (szText == NULL || _tcsclen(szText) == 0)
- {
+ if (szText == NULL || _tcsclen(szText) == 0) {
text_size.cy = 0;
text_size.cx = 0;
}
- else
- {
- RECT text_rc = {0, 0, 2048, 2048};
+ else {
+ RECT text_rc = { 0, 0, 2048, 2048 };
- if (info->pieces == NULL)
- {
+ if (info->pieces == NULL) {
DrawText(hdcMem, szText, -1, &text_rc, DT_CALCRECT | uTextFormat);
text_size.cx = text_rc.right - text_rc.left;
text_size.cy = text_rc.bottom - text_rc.top;
}
- else
- {
+ else {
// Get real height of the line
text_height = DrawText(hdcMem, _T("A"), 1, &text_rc, DT_CALCRECT | uTextFormat);
// See each item of list
int i;
- for (i = 0; i < info->pieces->realCount; i++)
- {
- TEXTPIECE *piece = (TEXTPIECE *) info->pieces->items[i];
+ for (i = 0; i < info->pieces->realCount; i++) {
+ TEXTPIECE *piece = (TEXTPIECE *)info->pieces->items[i];
info->row_height[row_count] = max(info->row_height[row_count], text_height);
- if (piece->type == TEXT_PIECE_TYPE_TEXT)
- {
- RECT text_rc = {0, 0, 2048, 2048};
+ if (piece->type == TEXT_PIECE_TYPE_TEXT) {
+ RECT text_rc = { 0, 0, 2048, 2048 };
DrawText(hdcMem, szText + piece->start_pos, piece->len, &text_rc, DT_CALCRECT | uTextFormat);
pos_x += (text_rc.right - text_rc.left);
- if (pos_x > max_width)
- {
+ if (pos_x > max_width) {
text_size.cx = max(text_size.cx, pos_x - (text_rc.right - text_rc.left));
pos_x = text_rc.right - text_rc.left;
info->row_height[++row_count] = text_height;
}
- if (szText[piece->start_pos + piece->len - 1] == '\n')
- {
+ if (szText[piece->start_pos + piece->len - 1] == '\n') {
text_size.cx = max(text_size.cx, pos_x);
pos_x = 0;
info->row_height[++row_count] = 0;
}
}
- else
- {
+ else {
double factor;
if (uTextFormat & DT_RESIZE_SMILEYS && piece->smiley_height > text_height)
- factor = text_height / (double) piece->smiley_height;
+ factor = text_height / (double)piece->smiley_height;
else
factor = 1;
info->row_height[row_count] = max(info->row_height[row_count], piece->smiley_height * factor);
pos_x += piece->smiley_width * factor;
- if (pos_x > max_width)
- {
+ if (pos_x > max_width) {
text_size.cx = max(text_size.cx, pos_x - (piece->smiley_width * factor));
pos_x = piece->smiley_width * factor;
info->row_height[++row_count] = piece->smiley_height * factor;
@@ -212,36 +199,30 @@ void DrawTextSmiley(HDC hdcMem, RECT free_rc, const TCHAR *szText, int len, SMIL
// Get real height of the line
text_height = DrawText(hdcMem, _T("A"), 1, &tmp_rc, DT_CALCRECT | uTextFormat);
- SaveAlpha(&free_rc);
+ mir_ptr<COLOR32> pBits(SaveAlpha(&free_rc));
// Just draw ellipsis
if (free_rc.right <= free_rc.left)
- {
DrawText(hdcMem, _T("..."), 3, &free_rc, uTextFormat & ~DT_END_ELLIPSIS);
- }
- else
- {
+ else {
// Draw text and smileys
RECT text_rc = free_rc;
- for (; i < info->pieces->realCount && i >= 0 && len > 0; i += (uTextFormat & DT_RTLREADING ? -1 : 1))
- {
- TEXTPIECE *piece = (TEXTPIECE *) info->pieces->items[i];
+ for (; i < info->pieces->realCount && i >= 0 && len > 0; i += (uTextFormat & DT_RTLREADING ? -1 : 1)) {
+ TEXTPIECE *piece = (TEXTPIECE *)info->pieces->items[i];
if (uTextFormat & DT_RTLREADING)
text_rc.right = free_rc.right - pos_x;
else
text_rc.left = free_rc.left + pos_x;
- if (piece->type == TEXT_PIECE_TYPE_TEXT)
- {
+ if (piece->type == TEXT_PIECE_TYPE_TEXT) {
tmp_rc = text_rc;
tmp_rc.right = 2048;
DrawText(hdcMem, szText + piece->start_pos, min(len, piece->len), &tmp_rc, DT_CALCRECT | (uTextFormat & ~DT_END_ELLIPSIS));
pos_x += (tmp_rc.right - tmp_rc.left);
- if (pos_x > (free_rc.right - free_rc.left))
- {
+ if (pos_x > (free_rc.right - free_rc.left)) {
pos_x = tmp_rc.right - tmp_rc.left;
text_rc.left = free_rc.left;
text_rc.right = free_rc.right;
@@ -259,8 +240,7 @@ void DrawTextSmiley(HDC hdcMem, RECT free_rc, const TCHAR *szText, int len, SMIL
len -= piece->len;
text_rc.top -= shift;
- if (szText[piece->start_pos + piece->len - 1] == '\n')
- {
+ if (szText[piece->start_pos + piece->len - 1] == '\n') {
text_rc.left = free_rc.left;
text_rc.right = free_rc.right;
text_rc.top += info->row_height[row_count];
@@ -268,20 +248,17 @@ void DrawTextSmiley(HDC hdcMem, RECT free_rc, const TCHAR *szText, int len, SMIL
row_count++;
}
}
- else
- {
+ else {
double factor;
- if (len < piece->len)
- {
+ if (len < piece->len) {
len = 0;
}
- else
- {
+ else {
len -= piece->len;
if (uTextFormat & DT_RESIZE_SMILEYS && piece->smiley_height > text_height)
- factor = text_height / (double) piece->smiley_height;
+ factor = text_height / (double)piece->smiley_height;
else
factor = 1;
@@ -289,8 +266,7 @@ void DrawTextSmiley(HDC hdcMem, RECT free_rc, const TCHAR *szText, int len, SMIL
text_rc.left = max(text_rc.right - (int)(piece->smiley_width * factor), text_rc.left);
pos_x += piece->smiley_width * factor;
- if (pos_x > (free_rc.right - free_rc.left))
- {
+ if (pos_x > (free_rc.right - free_rc.left)) {
pos_x = piece->smiley_width * factor;
text_rc.left = free_rc.left;
text_rc.right = free_rc.right;
@@ -305,7 +281,7 @@ void DrawTextSmiley(HDC hdcMem, RECT free_rc, const TCHAR *szText, int len, SMIL
}
}
- RestoreAlpha(&free_rc);
+ RestoreAlpha(&free_rc, pBits);
}
void DestroySmileyList(SortedList* p_list)
@@ -313,14 +289,10 @@ void DestroySmileyList(SortedList* p_list)
if (p_list == NULL)
return;
- if (p_list->items != NULL)
- {
- int i;
- for (i = 0 ; i < p_list->realCount ; i++)
- {
+ if (p_list->items != NULL) {
+ for (int i = 0; i < p_list->realCount; i++) {
TEXTPIECE *piece = (TEXTPIECE *)p_list->items[i];
- if (piece != NULL)
- {
+ if (piece != NULL) {
if (piece->type == TEXT_PIECE_TYPE_SMILEY)
DestroyIcon(piece->smiley);
@@ -332,7 +304,7 @@ void DestroySmileyList(SortedList* p_list)
mir_free(p_list); //this free the p_list itself (alloc by List_Create)
}
-// Generete the list of smileys / text to be drawn
+// Generate the list of smileys / text to be drawn
SortedList *ReplaceSmileys(const TCHAR *text, int text_size, const char *protocol, int *max_smiley_height)
{
*max_smiley_height = 0;
@@ -349,7 +321,7 @@ SortedList *ReplaceSmileys(const TCHAR *text, int text_size, const char *protoco
strncpy(smileyProto, protocol, sizeof(smileyProto) - 1);
// Parse it!
- SMADD_BATCHPARSE2 sp = {0};
+ SMADD_BATCHPARSE2 sp = { 0 };
sp.cbSize = sizeof(sp);
sp.str = (TCHAR *)text;
sp.flag = SAFL_TCHAR;
@@ -368,24 +340,21 @@ SortedList *ReplaceSmileys(const TCHAR *text, int text_size, const char *protoco
word_start = word_end = (TCHAR *)text;
- for (unsigned i = 0; i < sp.numSmileys; i++)
- {
+ for (unsigned i = 0; i < sp.numSmileys; i++) {
// Get smile position
smiley_start = _tcsninc(text, spres[i].startChar);
smiley_end = _tcsninc(smiley_start, spres[i].size);
if (spres[i].hIcon) // For deffective smileypacks
{
- if (opt.iSmileyAddFlags & SMILEYADD_ONLYISOLATED)
- {
+ if (opt.iSmileyAddFlags & SMILEYADD_ONLYISOLATED) {
if ((smiley_start > text && *(smiley_start - 1) != ' ' && *(smiley_start - 1) != '\n' && *smiley_end != '\r') ||
(*smiley_end != '\0' && *smiley_end != ' ' && *smiley_end != '\n' && *smiley_end != '\r'))
continue;
}
// Add text
- while (word_end != smiley_start)
- {
+ while (word_end != smiley_start) {
while (word_end[0] != ' ' && word_end[0] != '\n')
word_end++;
@@ -394,8 +363,7 @@ SortedList *ReplaceSmileys(const TCHAR *text, int text_size, const char *protoco
else
word_end++;
- if (word_end > word_start)
- {
+ if (word_end > word_start) {
TEXTPIECE *piece = (TEXTPIECE *)mir_calloc(sizeof(TEXTPIECE));
piece->type = TEXT_PIECE_TYPE_TEXT;
piece->start_pos = word_start - text;
@@ -406,48 +374,41 @@ SortedList *ReplaceSmileys(const TCHAR *text, int text_size, const char *protoco
}
// Add smiley
- {
+ TEXTPIECE *piece = (TEXTPIECE *)mir_calloc(sizeof(TEXTPIECE));
+ piece->type = TEXT_PIECE_TYPE_SMILEY;
+ piece->len = spres[i].size;
+ piece->smiley = spres[i].hIcon;
+ piece->smiley_width = 16;
+ piece->smiley_height = 16;
+
+ ICONINFO icon;
+ if (GetIconInfo(piece->smiley, &icon)) {
BITMAP bm;
- ICONINFO icon;
- TEXTPIECE *piece = (TEXTPIECE *) mir_calloc(sizeof(TEXTPIECE));
-
- piece->type = TEXT_PIECE_TYPE_SMILEY;
- piece->len = spres[i].size;
- piece->smiley = spres[i].hIcon;
-
- piece->smiley_width = 16;
- piece->smiley_height = 16;
- if (GetIconInfo(piece->smiley, &icon))
- {
- if (GetObject(icon.hbmColor, sizeof(BITMAP), &bm))
- {
- piece->smiley_width = bm.bmWidth;
- piece->smiley_height = bm.bmHeight;
- }
-
- DeleteObject(icon.hbmMask);
- DeleteObject(icon.hbmColor);
+ if (GetObject(icon.hbmColor, sizeof(BITMAP), &bm)) {
+ piece->smiley_width = bm.bmWidth;
+ piece->smiley_height = bm.bmHeight;
}
- *max_smiley_height = max(piece->smiley_height, *max_smiley_height);
- List_Insert(plText, piece, plText->realCount);
+ DeleteObject(icon.hbmMask);
+ DeleteObject(icon.hbmColor);
}
+ *max_smiley_height = max(piece->smiley_height, *max_smiley_height);
+ List_Insert(plText, piece, plText->realCount);
+
word_start = word_end = smiley_end;
}
}
// Add rest of the text
- while (word_end != last_text_pos)
- {
+ while (word_end != last_text_pos) {
while (word_end[0] && word_end[0] != ' ' && word_end[0] != '\n')
word_end++;
if (word_end[0])
word_end++;
- if (word_end > word_start)
- {
+ if (word_end > word_start) {
TEXTPIECE *piece = (TEXTPIECE *)mir_calloc(sizeof(TEXTPIECE));
piece->type = TEXT_PIECE_TYPE_TEXT;
piece->start_pos = word_start - text;
diff --git a/plugins/TipperYM/src/popwin.cpp b/plugins/TipperYM/src/popwin.cpp
index 18be576c2e..1a6e9d0518 100644
--- a/plugins/TipperYM/src/popwin.cpp
+++ b/plugins/TipperYM/src/popwin.cpp
@@ -37,14 +37,14 @@ __inline void AddRow(PopupWindowData *pwd, TCHAR *swzLabel, TCHAR *swzValue, cha
LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
+ RECT rc;
PopupWindowData *pwd = (PopupWindowData *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
switch(uMsg) {
case WM_CREATE:
{
CREATESTRUCT *cs = (CREATESTRUCT *)lParam;
- pwd = (PopupWindowData *)mir_alloc(sizeof(PopupWindowData));
- memset(pwd, 0, sizeof(PopupWindowData));
+ pwd = (PopupWindowData *)mir_calloc(sizeof(PopupWindowData));
pwd->clcit = *(CLCINFOTIPEX *)cs->lpCreateParams;
pwd->iIconIndex = -1;
pwd->hpenBorder = CreatePen(PS_SOLID, 1, opt.bBorder ? opt.colBorder : opt.colBg);
@@ -61,7 +61,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
GetCursorPos(&pwd->ptCursorStartPos);
SetTimer(hwnd, ID_TIMER_CHECKMOUSE, CHECKMOUSE_ELAPSE, 0);
- //Register copy menu hotkey (CTRL+C)
+ // register copy menu hotkey (CTRL+C)
pwd->iHotkeyId = GlobalAddAtom(_T("Tipper"));
RegisterHotKey(hwnd, pwd->iHotkeyId, MOD_CONTROL, 0x43);
@@ -205,7 +205,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
pwd->iIndent = 0;
pwd->iSidebarWidth = 0;
- RECT rc = pwd->clcit.rcItem;
+ rc = pwd->clcit.rcItem;
bool mirandaTrayTip = ((rc.right - rc.left) == 20) && ((rc.bottom - rc.top) == 20) ? true : false;
if (mirandaTrayTip && !opt.bTraytip) {
@@ -427,13 +427,12 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
// since tipper win is topmost, this should put it at top of topmost windows
SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
- }
+ }
return 0;
case WM_ERASEBKGND:
if (!skin.bNeedLayerUpdate) {
HDC hdc = (HDC)wParam;
- RECT rc;
GetClientRect(hwnd, &rc);
BitBlt(hdc, 0, 0, skin.iWidth, skin.iHeight, skin.hdc, 0, 0, SRCCOPY);
@@ -461,15 +460,15 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
return TRUE;
case WM_PAINT:
+ PAINTSTRUCT ps;
{
RECT r, r2;
- PAINTSTRUCT ps;
BeginPaint(hwnd, &ps);
HDC hdc = skin.bNeedLayerUpdate ? skin.hdc : ps.hdc;
GetClientRect(hwnd, &r);
r2 = r;
- HFONT hOldFont = (HFONT)GetCurrentObject(hdc,OBJ_FONT);
+ HFONT hOldFont = (HFONT)GetCurrentObject(hdc, OBJ_FONT);
// text background
SetBkMode(hdc, TRANSPARENT);
@@ -530,7 +529,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
blend.SourceConstantAlpha = 255;
if (opt.bAvatarBorder) {
- SaveAlpha(&rcAvatar);
+ mir_ptr<COLOR32> pBits(SaveAlpha(&rcAvatar));
HBRUSH hbrBorder = CreateSolidBrush(opt.colAvatarBorder);
if (opt.bAvatarRound)
FrameRgn(hdc, hrgnAvatar, hbrBorder, 1, 1);
@@ -538,7 +537,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
FrameRect(hdc, &rcAvatar, hbrBorder);
DeleteObject(hbrBorder);
- RestoreAlpha(&rcAvatar, (BYTE)(opt.iAvatarOpacity / 100.0 * 255));
+ RestoreAlpha(&rcAvatar, pBits, (BYTE)(opt.iAvatarOpacity / 100.0 * 255));
}
if (hrgnAvatar) {
@@ -604,9 +603,9 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
tr.top += opt.iTextPadding;
RECT rec;
SetRect(&rec, r.left + opt.iPadding + pwd->iIndent, tr.top, r.right - opt.iPadding, tr.top + 1);
- SaveAlpha(&rec);
+ mir_ptr<COLOR32> pBits(SaveAlpha(&rec));
Rectangle(hdc, rec.left, rec.top, rec.right, rec.bottom);
- RestoreAlpha(&rec);
+ RestoreAlpha(&rec, pBits);
SelectObject(hdc, hOldPen);
}
@@ -622,9 +621,9 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
tr.top += opt.iTextPadding;
RECT rec;
SetRect(&rec, r2.left + opt.iPadding + pwd->iIndent, tr.top, r2.right - opt.iPadding, tr.top + 1);
- SaveAlpha(&rec);
+ mir_ptr<COLOR32> pBits(SaveAlpha(&rec));
Rectangle(hdc, rec.left, rec.top, rec.right, rec.bottom);
- RestoreAlpha(&rec);
+ RestoreAlpha(&rec, pBits);
SelectObject(hdc, hOldPen);
}
@@ -724,7 +723,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
SelectObject(hdc, hOldFont);
EndPaint(hwnd, &ps);
pwd->bIsPainted = true;
- }
+ }
return 0;
case WM_HOTKEY:
@@ -898,15 +897,13 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
}
break;
- case WM_DESTROY:
- ShowWindow(hwnd, SW_HIDE);
+ case WM_DESTROY:
+ ShowWindow(hwnd, SW_HIDE);
- mir_free(skin.colSavedBits);
if (skin.hBitmap)
DeleteObject(skin.hBitmap);
if (skin.hdc)
DeleteDC(skin.hdc);
- skin.colSavedBits = NULL;
skin.hBitmap = NULL;
skin.hdc = NULL;
@@ -942,7 +939,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
}
mir_free(pwd->clcit.swzText);
- mir_free(pwd);
+ mir_free(pwd);
pwd = NULL;
SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
@@ -951,23 +948,23 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
case WM_TIMER:
switch (wParam) {
case ID_TIMER_ANIMATE:
- pwd->iAnimStep ++;
+ pwd->iAnimStep++;
if (pwd->iAnimStep == ANIM_STEPS)
KillTimer(hwnd, ID_TIMER_ANIMATE);
SendMessage(hwnd, PUM_UPDATERGN, 1, 0);
break;
case ID_TIMER_CHECKMOUSE:
- {
- // workaround for tips that just won't go away
- POINT pt;
+ {
+ // workaround for tips that just won't go away
+ POINT pt;
- GetCursorPos(&pt);
- // mouse has moved beyond tollerance
- if (abs(pt.x - pwd->ptCursorStartPos.x) > opt.iMouseTollerance || abs(pt.y - pwd->ptCursorStartPos.y) > opt.iMouseTollerance)
- PostMPMessage(MUM_DELETEPOPUP, 0, 0);
- }
- break;
+ GetCursorPos(&pt);
+ // mouse has moved beyond tollerance
+ if (abs(pt.x - pwd->ptCursorStartPos.x) > opt.iMouseTollerance || abs(pt.y - pwd->ptCursorStartPos.y) > opt.iMouseTollerance)
+ PostMPMessage(MUM_DELETEPOPUP, 0, 0);
+ }
+ break;
case ID_TIMER_TRAYTIP:
KillTimer(hwnd, ID_TIMER_TRAYTIP);
SendMessage(hwnd, PUM_EXPANDTRAYTIP, 0, 0);
@@ -1008,8 +1005,8 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
pwd->bIsPainted = false;
if (skin.bNeedLayerUpdate) {
RECT r = pwd->rcWindow;
- POINT ptSrc = {0, 0};
- SIZE sz = {r.right - r.left, r.bottom - r.top};
+ POINT ptSrc = { 0, 0 };
+ SIZE sz = { r.right - r.left, r.bottom - r.top };
BLENDFUNCTION blend;
blend.BlendOp = AC_SRC_OVER;
@@ -1018,8 +1015,8 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
blend.AlphaFormat = AC_SRC_ALPHA;
UpdateLayeredWindow(hwnd, NULL, NULL, &sz, skin.hdc, &ptSrc, 0xffffffff, &blend, LWA_ALPHA);
- }
- else SetLayeredWindowAttributes(hwnd, RGB(0,0,0), 0, LWA_ALPHA);
+ }
+ else SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), 0, LWA_ALPHA);
SendMessage(hwnd, PUM_REFRESHTRAYTIP, 1, 0);
SendMessage(hwnd, PUM_GETHEIGHT, 0, 0);
@@ -1052,10 +1049,10 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
if (node->di.bIsVisible && CheckContactType(pwd->hContact, node->di)) {
if (GetLabelText(pwd->hContact, node->di, buff_label, LABEL_LEN) && GetValueText(pwd->hContact, node->di, buff, VALUE_LEN)) {
if (node->di.bLineAbove // we have a line above
- && pwd->iRowCount > 0 // and we're not the first row
- && pwd->rows[pwd->iRowCount - 1].bLineAbove // and above us there's a line above
- && pwd->rows[pwd->iRowCount - 1].swzLabel[0] == 0 // with no label
- && pwd->rows[pwd->iRowCount - 1].swzValue[0] == 0) // and no value
+ && pwd->iRowCount > 0 // and we're not the first row
+ && pwd->rows[pwd->iRowCount - 1].bLineAbove // and above us there's a line above
+ && pwd->rows[pwd->iRowCount - 1].swzLabel[0] == 0 // with no label
+ && pwd->rows[pwd->iRowCount - 1].swzValue[0] == 0) // and no value
{
// overwrite item above
pwd->iRowCount--;
@@ -1080,9 +1077,9 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
// if the last item is just a divider, remove it
if (pwd->iRowCount > 0
- && pwd->rows[pwd->iRowCount - 1].bLineAbove // and above us there's a line above
- && pwd->rows[pwd->iRowCount - 1].swzLabel[0] == 0 // with no label
- && pwd->rows[pwd->iRowCount - 1].swzValue[0] == 0) // and no value
+ && pwd->rows[pwd->iRowCount - 1].bLineAbove // and above us there's a line above
+ && pwd->rows[pwd->iRowCount - 1].swzLabel[0] == 0 // with no label
+ && pwd->rows[pwd->iRowCount - 1].swzValue[0] == 0) // and no value
{
pwd->iRowCount--;
mir_free(pwd->rows[pwd->iRowCount].swzLabel);
@@ -1103,17 +1100,17 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
return TRUE;
case PUM_GETHEIGHT:
+ RECT smr;
{
int *pHeight = (int *)wParam;
HDC hdc = GetDC(hwnd);
SIZE sz;
- RECT rc, smr;
rc.top = rc.left = 0;
rc.right = opt.iWinWidth;
int iWidth = opt.iPadding;
int iWinAvatarHeight = 0;
bool bStatusMsg = false;
- HFONT hOldFont = (HFONT)GetCurrentObject(hdc,OBJ_FONT);
+ HFONT hOldFont = (HFONT)GetCurrentObject(hdc, OBJ_FONT);
// avatar height
pwd->iAvatarHeight = 0;
@@ -1122,11 +1119,11 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
if (pwd->hContact) ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)pwd->hContact, 0);
else ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETMYAVATAR, 0, (LPARAM)pwd->clcit.szProto);
- if (ace && (ace->dwFlags & AVS_BITMAP_VALID) && !(ace->dwFlags & AVS_HIDEONCLIST)) {
+ if (ace && (ace->dwFlags & AVS_BITMAP_VALID) && !(ace->dwFlags & AVS_HIDEONCLIST)) {
if (opt.bOriginalAvatarSize && max(ace->bmWidth, ace->bmHeight) <= opt.iAvatarSize) {
pwd->iRealAvatarHeight = ace->bmHeight;
pwd->iRealAvatarWidth = ace->bmWidth;
- }
+ }
else if (ace->bmHeight >= ace->bmWidth) {
pwd->iRealAvatarHeight = opt.iAvatarSize;
pwd->iRealAvatarWidth = (int)(opt.iAvatarSize * (ace->bmWidth / (double)ace->bmHeight));
@@ -1136,8 +1133,8 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
pwd->iRealAvatarWidth = opt.iAvatarSize;
}
- pwd->iAvatarHeight = opt.iOuterAvatarPadding + opt.iInnerAvatarPadding + pwd->iRealAvatarHeight;
- iWinAvatarHeight = 2 * opt.iOuterAvatarPadding + pwd->iRealAvatarHeight;
+ pwd->iAvatarHeight = opt.iOuterAvatarPadding + opt.iInnerAvatarPadding + pwd->iRealAvatarHeight;
+ iWinAvatarHeight = 2 * opt.iOuterAvatarPadding + pwd->iRealAvatarHeight;
iWidth += pwd->iRealAvatarWidth + (opt.iOuterAvatarPadding + opt.iInnerAvatarPadding - opt.iPadding);
}
}
@@ -1158,17 +1155,17 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
iWidth += opt.iPadding + opt.iTitleIndent + smr.right;
pwd->iTitleHeight = opt.iPadding + smr.bottom;
- }
+ }
else pwd->iTitleHeight = opt.iPadding;
// icon height
int i, iCount = 0;
if (pwd->hContact || pwd->clcit.szProto) {
- for(i = 0; i < EXICONS_COUNT; i++) {
+ for (i = 0; i < EXICONS_COUNT; i++) {
if ((INT_PTR)pwd->extraIcons[i].hIcon == CALLSERVICE_NOTFOUND)
pwd->extraIcons[i].hIcon = 0;
- if (pwd->extraIcons[i].hIcon)
+ if (pwd->extraIcons[i].hIcon)
iCount++;
}
}
@@ -1180,10 +1177,10 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
for (i = 0; i < pwd->iRowCount; i++) {
if (pwd->rows[i].swzLabel && !pwd->rows[i].bValueNewline) {
if (pwd->bIsTrayTip && pwd->rows[i].bIsTitle) {
- if (hFontTrayTitle)
+ if (hFontTrayTitle)
SelectObject(hdc, (HGDIOBJ)hFontTrayTitle);
- }
- else if (hFontLabels)
+ }
+ else if (hFontLabels)
SelectObject(hdc, (HGDIOBJ)hFontLabels);
GetTextExtentPoint32(hdc, pwd->rows[i].swzLabel, (int)_tcslen(pwd->rows[i].swzLabel), &sz);
@@ -1194,10 +1191,10 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
for (i = 0; i < pwd->iRowCount; i++) {
if (pwd->bIsTrayTip && pwd->rows[i].bIsTitle) {
- if (hFontTrayTitle)
+ if (hFontTrayTitle)
SelectObject(hdc, (HGDIOBJ)hFontTrayTitle);
- }
- else if (hFontLabels)
+ }
+ else if (hFontLabels)
SelectObject(hdc, (HGDIOBJ)hFontLabels);
if (pwd->rows[i].swzLabel && pwd->rows[i].swzLabel[0])
@@ -1217,7 +1214,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
else
smr.right -= opt.iPadding;
- if (!pwd->rows[i].bValueNewline)
+ if (!pwd->rows[i].bValueNewline)
smr.right -= pwd->iLabelWidth + opt.iValueIndent;
if (pwd->rows[i].swzValue && pwd->rows[i].swzValue[0]) {
@@ -1227,7 +1224,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
}
DrawTextExt(hdc, pwd->rows[i].swzValue, -1, &smr, DT_CALCRECT | DT_LEFT | DT_WORDBREAK | DT_END_ELLIPSIS | DT_NOPREFIX, NULL, pwd->rows[i].spi);
- }
+ }
else smr.left = smr.right = 0;
// save so we don't have to recalculate
@@ -1237,7 +1234,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
if (pwd->rows[i].bValueNewline) {
if (sz.cy) pwd->rows[i].iTotalHeight += sz.cy + opt.iTextPadding;
if (smr.bottom) pwd->rows[i].iTotalHeight += smr.bottom + opt.iTextPadding;
- }
+ }
else {
int maxheight = max(sz.cy, smr.bottom);
if (maxheight) pwd->rows[i].iTotalHeight += maxheight + opt.iTextPadding;
@@ -1269,30 +1266,28 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
if (!pwd->bIsTextTip && iWidth < opt.iMinWidth) iWidth = opt.iMinWidth;
// ignore maxheight for tray tip
- if (!pwd->bIsTrayTip && iHeight > opt.iWinMaxHeight) iHeight = opt.iWinMaxHeight;
+ if (!pwd->bIsTrayTip && iHeight > opt.iWinMaxHeight) iHeight = opt.iWinMaxHeight;
if (iWidth > opt.iWinWidth) iWidth = opt.iWinWidth;
CreateSkinBitmap(iWidth, iHeight, pwd->bIsTextTip && !pwd->bIsTrayTip);
GetWindowRect(hwnd, &rc);
- if (rc.right - rc.left != iWidth || rc.bottom - rc.top != iHeight)
- {
+ if (rc.right - rc.left != iWidth || rc.bottom - rc.top != iHeight) {
SetWindowPos(hwnd, 0, 0, 0, iWidth, iHeight, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
GetWindowRect(hwnd, &pwd->rcWindow);
SendMessage(hwnd, PUM_UPDATERGN, 0, 0);
InvalidateRect(hwnd, 0, TRUE);
}
- if (pHeight)
+ if (pHeight)
*pHeight = iHeight;
- }
+ }
return TRUE;
case PUM_UPDATERGN:
+ HRGN hRgn;
{
- HRGN hRgn;
RECT r = pwd->rcWindow;
- int v, h;
int w = 11;
r.right -= r.left;
@@ -1361,6 +1356,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
if (!skin.bNeedLayerUpdate) {
// round corners
+ int v, h;
if (opt.bRound) {
h = (r.right - r.left) > (w * 2) ? w : (r.right - r.left);
v = (r.bottom - r.top) > (w * 2) ? w : (r.bottom - r.top);
@@ -1397,10 +1393,10 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
return TRUE;
case PUM_CALCPOS:
+ RECT rcWork;
{
- RECT rcWork, rc;
SystemParametersInfo(SPI_GETWORKAREA, 0, &rcWork, FALSE);
-
+
HMONITOR hMon = MonitorFromPoint(pwd->clcit.ptCursor, MONITOR_DEFAULTTONEAREST);
MONITORINFO mi;
mi.cbSize = sizeof(mi);
diff --git a/plugins/TipperYM/src/version.h b/plugins/TipperYM/src/version.h
index f8accebbd3..43f3d17d54 100644
--- a/plugins/TipperYM/src/version.h
+++ b/plugins/TipperYM/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 2
#define __MINOR_VERSION 1
#define __RELEASE_NUM 0
-#define __BUILD_NUM 6
+#define __BUILD_NUM 7
#include <stdver.h>