diff options
author | George Hazan <george.hazan@gmail.com> | 2014-04-08 14:45:54 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-04-08 14:45:54 +0000 |
commit | afa73da4259ee9a00e60570031f94338542636d8 (patch) | |
tree | cacf0a9d83484c8a3143e3b6aa0c8af42ed022a4 /plugins/Clist_nicer/src/CLCButton.cpp | |
parent | 0a41e7f5bd2d3cd705e5806b3190ff7afadde131 (diff) |
- fixes #596 (Clist nicer skin doesn't show buttons)
- code formatting fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@8891 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Clist_nicer/src/CLCButton.cpp')
-rw-r--r-- | plugins/Clist_nicer/src/CLCButton.cpp | 261 |
1 files changed, 185 insertions, 76 deletions
diff --git a/plugins/Clist_nicer/src/CLCButton.cpp b/plugins/Clist_nicer/src/CLCButton.cpp index a0db5e52e6..ef0d9ae385 100644 --- a/plugins/Clist_nicer/src/CLCButton.cpp +++ b/plugins/Clist_nicer/src/CLCButton.cpp @@ -21,29 +21,24 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_button_int.h>
#include <m_toptoolbar.h>
-struct
-{
- int ctrlid;
- char *pszButtonID, *pszButtonDn, *pszButtonName;
- int isPush, isVis, isAction;
- HANDLE hButton;
- HWND hwndButton;
-}
-static BTNS[] =
+HWND g_hwndToolbarFrame;
+HANDLE hToolbarFrame = (HANDLE)-1;
+
+struct CluiTopButton BTNS[] =
{
- { IDC_TBTOPMENU, "CLN_topmenu", NULL, LPGEN("Show menu"), 1, 1, 1 },
- { IDC_TBHIDEOFFLINE, "CLN_online", NULL, LPGEN("Show / hide offline contacts"), 0, 1, 0 },
- { IDC_TBHIDEGROUPS, "CLN_groups", NULL, LPGEN("Toggle group mode"), 0, 1, 0 },
- { IDC_TBFINDANDADD, "CLN_findadd", NULL, LPGEN("Find and add contacts"), 1, 1, 0 },
- { IDC_TBACCOUNTS, "CLN_accounts", NULL, LPGEN("Accounts"), 1, 1, 0 },
- { IDC_TBOPTIONS, "CLN_options", NULL, LPGEN("Open preferences"), 1, 1, 0 },
- { IDC_TBSOUND, "CLN_sound", "CLN_soundsoff", LPGEN("Toggle sounds"), 0, 1, 0 },
- { IDC_TBMINIMIZE, "CLN_minimize", NULL, LPGEN("Minimize contact list"), 1, 0, 0 },
- { IDC_TBTOPSTATUS, "CLN_topstatus", NULL, LPGEN("Status menu"), 1, 0, 1 },
-
- { IDC_TBSELECTVIEWMODE, "CLN_CLVM_select", NULL, LPGEN("Select view mode"), 1, 0, 1 },
- { IDC_TBCONFIGUREVIEWMODE,"CLN_CLVM_options", NULL, LPGEN("Setup view modes"), 1, 0, 0 },
- { IDC_TBCLEARVIEWMODE, "CLN_CLVM_reset", NULL, LPGEN("Clear view mode"), 1, 0, 0 }
+ { IDC_TBTOPMENU, "CLN_topmenu", NULL, LPGEN("Show menu"), 1, 1, 1 },
+ { IDC_TBHIDEOFFLINE, "CLN_online", NULL, LPGEN("Hide offline contacts"), 0, 1, 0 },
+ { IDC_TBHIDEGROUPS, "CLN_groups", NULL, LPGEN("Enable group mode"), 0, 1, 0 },
+ { IDC_TBFINDANDADD, "CLN_findadd", NULL, LPGEN("Find and add contacts"), 1, 1, 0 },
+ { IDC_TBACCOUNTS, "CLN_accounts", NULL, LPGEN("Accounts"), 1, 1, 0 },
+ { IDC_TBOPTIONS, "CLN_options", NULL, LPGEN("Open preferences"), 1, 1, 0 },
+ { IDC_TBSOUND, "CLN_sound", "CLN_soundsoff", LPGEN("Disable sounds"), 0, 1, 0 },
+ { IDC_TBMINIMIZE, "CLN_minimize", NULL, LPGEN("Minimize contact list"), 1, 0, 0 },
+ { IDC_TBTOPSTATUS, "CLN_topstatus", NULL, LPGEN("Status menu"), 1, 0, 1 },
+
+ { IDC_TBSELECTVIEWMODE, "CLN_CLVM_select", NULL, LPGEN("Select view mode"), 1, 0, 1 },
+ { IDC_TBCONFIGUREVIEWMODE, "CLN_CLVM_options", NULL, LPGEN("Setup view modes"), 1, 0, 0 },
+ { IDC_TBCLEARVIEWMODE, "CLN_CLVM_reset", NULL, LPGEN("Clear view mode"), 1, 0, 0 }
};
static int g_index = -1;
@@ -55,21 +50,30 @@ static int getButtonIndex(HANDLE hButton) if (g_index != -1)
return g_index;
- for (int i=0; i < SIZEOF(BTNS); i++)
+ for (int i = 0; i < SIZEOF(BTNS); i++)
if (BTNS[i].hButton == hButton)
return i;
return -1;
}
+static int getLastIndex()
+{
+ for (int i = 0; ; i++)
+ if (BTNS[i].pszButtonID == NULL)
+ return i;
+
+ return -1;
+}
+
static void InitDefaultButtons()
{
- for (int i=0; i < SIZEOF(BTNS); i++ ) {
+ for (int i = 0; i < SIZEOF(BTNS); i++ ) {
TTBButton tbb = { sizeof(tbb) };
g_index = i;
if (BTNS[i].pszButtonID) {
- if ( !BTNS[i].isPush)
+ if (!BTNS[i].isPush)
tbb.dwFlags |= TTBBF_ASPUSHBUTTON;
tbb.pszTooltipUp = tbb.name = LPGEN(BTNS[i].pszButtonName);
@@ -79,19 +83,19 @@ static void InitDefaultButtons() }
else tbb.dwFlags |= TTBBF_ISSEPARATOR;
- tbb.dwFlags |= (BTNS[i].isVis ? TTBBF_VISIBLE : 0 );
+ tbb.dwFlags |= (BTNS[i].isVis ? TTBBF_VISIBLE : 0);
BTNS[i].hButton = TopToolbar_AddButton(&tbb);
}
g_index = -1;
ClcSetButtonState(IDC_TBHIDEOFFLINE, db_get_b(NULL, "CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT));
ClcSetButtonState(IDC_TBHIDEGROUPS, db_get_b(NULL, "CList", "UseGroups", SETTING_USEGROUPS_DEFAULT));
- ClcSetButtonState(IDC_TBSOUND, db_get_b(NULL, "Skin", "UseSound", 1));
+ ClcSetButtonState(IDC_TBSOUND, db_get_b(NULL, "Skin", "UseSound", 1) ? BST_UNCHECKED : BST_CHECKED);
}
void ClcSetButtonState(int ctrlid, int status)
{
- for (int i=0; i < SIZEOF(BTNS); i++)
+ for (int i = 0; i < SIZEOF(BTNS); i++)
if (BTNS[i].ctrlid == ctrlid) {
CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)BTNS[i].hButton, status ? TTBST_PUSHED : TTBST_RELEASED);
break;
@@ -100,7 +104,7 @@ void ClcSetButtonState(int ctrlid, int status) HWND ClcGetButtonWindow(int ctrlid)
{
- for (int i=0; i < SIZEOF(BTNS); i++)
+ for (int i = 0; i < SIZEOF(BTNS); i++)
if (BTNS[i].ctrlid == ctrlid)
return BTNS[i].hwndButton;
@@ -109,7 +113,7 @@ HWND ClcGetButtonWindow(int ctrlid) int ClcGetButtonId(HWND hwnd)
{
- for (int i=0; i < SIZEOF(BTNS); i++)
+ for (int i = 0; i < SIZEOF(BTNS); i++)
if (BTNS[i].hwndButton == hwnd)
return BTNS[i].ctrlid;
@@ -127,11 +131,12 @@ struct MButtonExtension : public MButtonCtrl int iIcon;
ButtonItem *buttonItem;
LONG lastGlyphMetrics[4];
+ bool bIsTTButton;
};
// Used for our own cheap TrackMouseEvent
-#define BUTTON_POLLID 100
-#define BUTTON_POLLDELAY 50
+#define BUTTON_POLLID 100
+#define BUTTON_POLLDELAY 50
static int TBStateConvert2Flat(int state)
{
@@ -180,7 +185,8 @@ static void PaintWorker(MButtonExtension *ctl, HDC hdcPaint) DrawThemeParentBackground(ctl->hwnd, hdcMem, &rc);
}
DrawThemeBackground(ctl->hThemeToolbar, hdcMem, TP_BUTTON, TBStateConvert2Flat(state), &rc, &rc);
- } else {
+ }
+ else {
HBRUSH hbr;
RECT rc = rcClient;
@@ -207,7 +213,7 @@ static void PaintWorker(MButtonExtension *ctl, HDC hdcPaint) glyphMetrics[3], g_glyphItem->bf);
}
}
- else if (ctl->bIsSkinned) { // skinned
+ else if (ctl->bIsSkinned) { // skinned
RECT rcParent;
POINT pt;
HWND hwndParent = pcli->hwndContactList;
@@ -220,24 +226,28 @@ static void PaintWorker(MButtonExtension *ctl, HDC hdcPaint) ScreenToClient(pcli->hwndContactList, &pt);
- if (HIWORD(ctl->bIsSkinned))
+ if (ctl->bIsTTButton)
item_id = ctl->stateId == PBS_HOT ? ID_EXTBKTBBUTTONMOUSEOVER : (ctl->stateId == PBS_PRESSED ? ID_EXTBKTBBUTTONSPRESSED : ID_EXTBKTBBUTTONSNPRESSED);
else
item_id = ctl->stateId == PBS_HOT ? ID_EXTBKBUTTONSMOUSEOVER : (ctl->stateId == PBS_PRESSED ? ID_EXTBKBUTTONSPRESSED : ID_EXTBKBUTTONSNPRESSED);
item = arStatusItems[item_id - ID_STATUS_OFFLINE];
- SetTextColor(hdcMem, item->TEXTCOLOR);
- if (item->IGNORED) {
- if (pt.y < 10 || cfg::dat.bWallpaperMode)
- BitBlt(hdcMem, 0, 0, rc.right, rc.bottom, cfg::dat.hdcBg, pt.x, pt.y, SRCCOPY);
- else
- FillRect(hdcMem, &rc, GetSysColorBrush(COLOR_3DFACE));
+ if (pt.y < 10 || cfg::dat.bWallpaperMode)
+ BitBlt(hdcMem, 0, 0, rc.right, rc.bottom, cfg::dat.hdcBg, pt.x, pt.y, SRCCOPY);
+ else
+ FillRect(hdcMem, &rc, GetSysColorBrush(COLOR_3DFACE));
+
+ if (ctl->bIsTTButton) {
+ GetWindowRect(ctl->hwnd, &rcParent);
+ pt.x = rcParent.left;
+ pt.y = rcParent.top;
+
+ ScreenToClient(g_hwndToolbarFrame, &pt);
+ BitBlt(hdcMem, 0, 0, rc.right, rc.bottom, cfg::dat.hdcToolbar, pt.x, pt.y, SRCCOPY);
}
- else {
- if (pt.y < 10 || cfg::dat.bWallpaperMode)
- BitBlt(hdcMem, 0, 0, rc.right, rc.bottom, cfg::dat.hdcBg, pt.x, pt.y, SRCCOPY);
- else
- FillRect(hdcMem, &rc, GetSysColorBrush(COLOR_3DFACE));
+
+ SetTextColor(hdcMem, item->TEXTCOLOR);
+ if (!item->IGNORED) {
rc.top += item->MARGIN_TOP; rc.bottom -= item->MARGIN_BOTTOM;
rc.left += item->MARGIN_LEFT; rc.right -= item->MARGIN_RIGHT;
DrawAlpha(hdcMem, &rc, item->COLOR, item->ALPHA, item->COLOR2, item->COLOR2_TRANSPARENT, item->GRADIENT,
@@ -253,7 +263,7 @@ static void PaintWorker(MButtonExtension *ctl, HDC hdcPaint) hwndParent = GetParent(ctl->hwnd);
dc = GetDC(hwndParent);
- hbr = (HBRUSH) SendMessage(hwndParent, WM_CTLCOLORDLG, (WPARAM) dc, (LPARAM) hwndParent);
+ hbr = (HBRUSH)SendMessage(hwndParent, WM_CTLCOLORDLG, (WPARAM)dc, (LPARAM)hwndParent);
ReleaseDC(hwndParent, dc);
}
if (hbr) {
@@ -261,22 +271,24 @@ static void PaintWorker(MButtonExtension *ctl, HDC hdcPaint) DeleteObject(hbr);
}
}
- if ( !ctl->bIsSkinned && ctl->buttonItem == 0) {
+ if (!ctl->bIsSkinned && ctl->buttonItem == 0) {
if (ctl->stateId == PBS_HOT || ctl->focus) {
if (ctl->bIsPushed)
DrawEdge(hdcMem, &rc, EDGE_ETCHED, BF_RECT | BF_SOFT);
else
DrawEdge(hdcMem, &rc, BDR_RAISEDOUTER, BF_RECT | BF_SOFT);
- } else if (ctl->stateId == PBS_PRESSED)
+ }
+ else if (ctl->stateId == PBS_PRESSED)
DrawEdge(hdcMem, &rc, BDR_SUNKENOUTER, BF_RECT | BF_SOFT);
}
}
- } else {
+ }
+ else {
// Draw background/border
if (ctl->hThemeButton && ctl->bIsThemed) {
int state = IsWindowEnabled(ctl->hwnd) ? (ctl->stateId == PBS_NORMAL && ctl->bIsDefault ? PBS_DEFAULTED : ctl->stateId) : PBS_DISABLED;
POINT pt;
- RECT rcParent;
+ RECT rcParent, rc = rcClient;
GetWindowRect(ctl->hwnd, &rcParent);
pt.x = rcParent.left;
@@ -284,11 +296,21 @@ static void PaintWorker(MButtonExtension *ctl, HDC hdcPaint) ScreenToClient(pcli->hwndContactList, &pt);
BitBlt(hdcMem, 0, 0, rcClient.right, rcClient.bottom, cfg::dat.hdcBg, pt.x, pt.y, SRCCOPY);
+ if (ctl->bIsTTButton) {
+ GetWindowRect(ctl->hwnd, &rcParent);
+ pt.x = rcParent.left;
+ pt.y = rcParent.top;
+
+ ScreenToClient(g_hwndToolbarFrame, &pt);
+ BitBlt(hdcMem, 0, 0, rc.right, rc.bottom, cfg::dat.hdcToolbar, pt.x, pt.y, SRCCOPY);
+ }
+
if (IsThemeBackgroundPartiallyTransparent(ctl->hThemeButton, BP_PUSHBUTTON, state)) {
DrawThemeParentBackground(ctl->hwnd, hdcMem, &rcClient);
}
DrawThemeBackground(ctl->hThemeButton, hdcMem, BP_PUSHBUTTON, state, &rcClient, &rcClient);
- } else {
+ }
+ else {
UINT uState = DFCS_BUTTONPUSH | ((ctl->stateId == PBS_HOT) ? DFCS_HOT : 0) | ((ctl->stateId == PBS_PRESSED) ? DFCS_PUSHED : 0);
if (ctl->bIsDefault && ctl->stateId == PBS_NORMAL)
uState |= DLGC_DEFPUSHBUTTON;
@@ -312,9 +334,10 @@ static void PaintWorker(MButtonExtension *ctl, HDC hdcPaint) if (ctl->iIcon)
ImageList_DrawEx(ctl->hIml, ctl->iIcon, hdcMem, ix, iy, g_cxsmIcon, g_cysmIcon, CLR_NONE, CLR_NONE, ILD_NORMAL);
else
- DrawState(hdcMem, NULL, NULL, (LPARAM) hIconNew, 0, ix, iy, g_cxsmIcon, g_cysmIcon, IsWindowEnabled(ctl->hwnd) ? DST_ICON | DSS_NORMAL : DST_ICON | DSS_DISABLED);
+ DrawState(hdcMem, NULL, NULL, (LPARAM)hIconNew, 0, ix, iy, g_cxsmIcon, g_cysmIcon, IsWindowEnabled(ctl->hwnd) ? DST_ICON | DSS_NORMAL : DST_ICON | DSS_DISABLED);
ctl->sLabel.cx = ctl->sLabel.cy = 0;
- } else {
+ }
+ else {
GetTextExtentPoint32(hdcMem, ctl->szText, lstrlen(ctl->szText), &ctl->sLabel);
if (g_cxsmIcon + ctl->sLabel.cx + 8 > rcClient.right - rcClient.left)
@@ -326,10 +349,11 @@ static void PaintWorker(MButtonExtension *ctl, HDC hdcPaint) if (ctl->iIcon)
ImageList_DrawEx(ctl->hIml, ctl->iIcon, hdcMem, ix, iy, g_cxsmIcon, g_cysmIcon, CLR_NONE, CLR_NONE, ILD_NORMAL);
else
- DrawState(hdcMem, NULL, NULL, (LPARAM) hIconNew, 0, ix, iy, g_cxsmIcon, g_cysmIcon, IsWindowEnabled(ctl->hwnd) ? DST_ICON | DSS_NORMAL : DST_ICON | DSS_DISABLED);
+ DrawState(hdcMem, NULL, NULL, (LPARAM)hIconNew, 0, ix, iy, g_cxsmIcon, g_cysmIcon, IsWindowEnabled(ctl->hwnd) ? DST_ICON | DSS_NORMAL : DST_ICON | DSS_DISABLED);
xOffset = ix + g_cxsmIcon + 4;
}
- } else if (ctl->hBitmap) {
+ }
+ else if (ctl->hBitmap) {
BITMAP bminfo;
int ix, iy;
@@ -349,11 +373,11 @@ static void PaintWorker(MButtonExtension *ctl, HDC hdcPaint) CopyRect(&rcText, &rcClient);
SetBkMode(hdcMem, TRANSPARENT);
// XP w/themes doesn't used the glossy disabled text. Is it always using COLOR_GRAYTEXT? Seems so.
- if ( !ctl->bIsSkinned)
+ if (!ctl->bIsSkinned)
SetTextColor(hdcMem, IsWindowEnabled(ctl->hwnd) || !ctl->hThemeButton ? GetSysColor(COLOR_BTNTEXT) : GetSysColor(COLOR_GRAYTEXT));
if (ctl->arrow)
- DrawState(hdcMem, NULL, NULL, (LPARAM) ctl->arrow, 0, rcClient.right - rcClient.left - 5 - g_cxsmIcon + (!ctl->hThemeButton && ctl->stateId == PBS_PRESSED ? 1 : 0), (rcClient.bottom - rcClient.top) / 2 - g_cysmIcon / 2 + (!ctl->hThemeButton && ctl->stateId == PBS_PRESSED ? 1 : 0), g_cxsmIcon, g_cysmIcon, IsWindowEnabled(ctl->hwnd) ? DST_ICON : DST_ICON | DSS_DISABLED);
- DrawState(hdcMem, NULL, NULL, (LPARAM) ctl->szText, 0, xOffset + (!ctl->hThemeButton && ctl->stateId == PBS_PRESSED ? 1 : 0), ctl->hThemeButton ? (rcText.bottom - rcText.top - ctl->sLabel.cy) / 2 + 1 : (rcText.bottom - rcText.top - ctl->sLabel.cy) / 2 + (ctl->stateId == PBS_PRESSED ? 1 : 0), ctl->sLabel.cx, ctl->sLabel.cy, IsWindowEnabled(ctl->hwnd) || ctl->hThemeButton ? DST_PREFIXTEXT | DSS_NORMAL : DST_PREFIXTEXT | DSS_DISABLED);
+ DrawState(hdcMem, NULL, NULL, (LPARAM)ctl->arrow, 0, rcClient.right - rcClient.left - 5 - g_cxsmIcon + (!ctl->hThemeButton && ctl->stateId == PBS_PRESSED ? 1 : 0), (rcClient.bottom - rcClient.top) / 2 - g_cysmIcon / 2 + (!ctl->hThemeButton && ctl->stateId == PBS_PRESSED ? 1 : 0), g_cxsmIcon, g_cysmIcon, IsWindowEnabled(ctl->hwnd) ? DST_ICON : DST_ICON | DSS_DISABLED);
+ DrawState(hdcMem, NULL, NULL, (LPARAM)ctl->szText, 0, xOffset + (!ctl->hThemeButton && ctl->stateId == PBS_PRESSED ? 1 : 0), ctl->hThemeButton ? (rcText.bottom - rcText.top - ctl->sLabel.cy) / 2 + 1 : (rcText.bottom - rcText.top - ctl->sLabel.cy) / 2 + (ctl->stateId == PBS_PRESSED ? 1 : 0), ctl->sLabel.cx, ctl->sLabel.cy, IsWindowEnabled(ctl->hwnd) || ctl->hThemeButton ? DST_PREFIXTEXT | DSS_NORMAL : DST_PREFIXTEXT | DSS_DISABLED);
}
if (hOldFont)
SelectObject(hdcMem, hOldFont);
@@ -385,7 +409,7 @@ static LRESULT CALLBACK TSButtonWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR break;
case BM_SETIMAGE:
- if ( !lParam)
+ if (!lParam)
break;
bct->hIml = 0;
@@ -432,14 +456,14 @@ static LRESULT CALLBACK TSButtonWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR case BUTTONSETIMLICON:
if (bct->hIconPrivate)
DestroyIcon(bct->hIconPrivate);
- bct->hIml = (HIMAGELIST) wParam;
- bct->iIcon = (int) lParam;
+ bct->hIml = (HIMAGELIST)wParam;
+ bct->iIcon = (int)lParam;
bct->hIcon = bct->hIconPrivate = 0;
InvalidateRect(bct->hwnd, NULL, TRUE);
break;
case BUTTONSETSKINNED:
- bct->bIsSkinned = lParam != 0;
+ bct->bIsSkinned = wParam != 0;
bct->bIsThemed = bct->bIsSkinned ? FALSE : bct->bIsThemed;
InvalidateRect(bct->hwnd, NULL, TRUE);
break;
@@ -448,10 +472,21 @@ static LRESULT CALLBACK TSButtonWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR bct->buttonItem = (ButtonItem *)lParam;
break;
+ case BUTTONSETTTBUTTON:
+ bct->bIsTTButton = wParam != 0;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+
case WM_NCHITTEST:
- switch( SendMessage(pcli->hwndContactList, WM_NCHITTEST, wParam, lParam)) {
- case HTLEFT: case HTRIGHT: case HTBOTTOM: case HTTOP:
- case HTTOPLEFT: case HTTOPRIGHT: case HTBOTTOMLEFT: case HTBOTTOMRIGHT:
+ switch (SendMessage(pcli->hwndContactList, WM_NCHITTEST, wParam, lParam)) {
+ case HTLEFT:
+ case HTRIGHT:
+ case HTBOTTOM:
+ case HTTOP:
+ case HTTOPLEFT:
+ case HTTOPRIGHT:
+ case HTBOTTOMLEFT:
+ case HTBOTTOMRIGHT:
return HTTRANSPARENT;
}
}
@@ -460,11 +495,72 @@ static LRESULT CALLBACK TSButtonWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR static LRESULT CALLBACK ToolbarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- // standard buttons are processed in the main window
- if (msg == WM_COMMAND && HIWORD(wParam) == BN_CLICKED) {
- int iCtrlId = ClcGetButtonId((HWND)lParam);
- if (iCtrlId)
- SendMessage(pcli->hwndContactList, msg, MAKELONG(iCtrlId, BN_CLICKED), lParam);
+ switch (msg) {
+ case WM_ERASEBKGND:
+ return TRUE;
+
+ case WM_NCPAINT:
+ case WM_PAINT:
+ {
+ PAINTSTRUCT ps;
+ HDC hdc = BeginPaint(hwnd, &ps);
+
+ RECT rc, rcClient;
+ GetClientRect(hwnd, &rc);
+ rcClient = rc;
+
+ if (cfg::dat.hdcToolbar) {
+ SelectObject(cfg::dat.hdcToolbar, cfg::dat.hbmToolbarOld);
+ DeleteObject(cfg::dat.hbmToolbar);
+ DeleteDC(cfg::dat.hdcToolbar);
+ cfg::dat.hdcToolbar = NULL;
+ }
+ cfg::dat.hdcToolbar = CreateCompatibleDC(hdc);
+ cfg::dat.hbmToolbar = CreateCompatibleBitmap(hdc, rcClient.right, rcClient.bottom);
+ cfg::dat.hbmToolbarOld = reinterpret_cast<HBITMAP>(SelectObject(cfg::dat.hdcToolbar, cfg::dat.hbmToolbar));
+ HDC hdcMem = cfg::dat.hdcToolbar;
+ SetBkMode(hdcMem, TRANSPARENT);
+
+ if (cfg::dat.bWallpaperMode)
+ SkinDrawBg(hwnd, hdcMem);
+
+ StatusItems_t *item = arStatusItems[ID_EXTBKBUTTONBAR - ID_STATUS_OFFLINE];
+ if (item->IGNORED)
+ FillRect(hdcMem, &rc, GetSysColorBrush(COLOR_3DFACE));
+ else {
+ rc.top += item->MARGIN_TOP;
+ rc.bottom -= item->MARGIN_BOTTOM;
+ rc.left += item->MARGIN_LEFT;
+ rc.right -= item->MARGIN_RIGHT;
+
+ DrawAlpha(hdcMem, &rc, item->COLOR, item->ALPHA, item->COLOR2, item->COLOR2_TRANSPARENT,
+ item->GRADIENT, item->CORNER, item->BORDERSTYLE, item->imageItem);
+ }
+
+ BitBlt(hdc, 0, 0, rcClient.right, rcClient.bottom, hdcMem, 0, 0, SRCCOPY);
+ ps.fErase = FALSE;
+ EndPaint(hwnd, &ps);
+ return 0;
+ }
+
+ case WM_COMMAND:
+ if (HIWORD(wParam) == BN_CLICKED) {
+ int iCtrlId = ClcGetButtonId((HWND)lParam);
+ // standard buttons are processed in the main window
+ if (iCtrlId) {
+ SendMessage(pcli->hwndContactList, msg, MAKELONG(iCtrlId, BN_CLICKED), lParam);
+ return 0;
+ }
+ }
+
+ case WM_DESTROY:
+ if (cfg::dat.hdcToolbar && lParam == NULL) { // lParam is NULL when toolbar frame is being deleted
+ SelectObject(cfg::dat.hdcToolbar, cfg::dat.hbmToolbarOld);
+ DeleteObject(cfg::dat.hbmToolbar);
+ DeleteDC(cfg::dat.hdcToolbar);
+ cfg::dat.hdcToolbar = NULL;
+ }
+ break;
}
return mir_callNextSubclass(hwnd, ToolbarWndProc, msg, wParam, lParam);
@@ -472,28 +568,40 @@ static LRESULT CALLBACK ToolbarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA static void CustomizeToolbar(HANDLE hButton, HWND hWnd, LPARAM)
{
- // we don't customize the toolbar window, only buttons
if (hButton == TTB_WINDOW_HANDLE) {
mir_subclassWindow(hWnd, ToolbarWndProc);
+
+ g_hwndToolbarFrame = hWnd;
+ TTBCtrl* pTBInfo = (TTBCtrl*)GetWindowLongPtr(hWnd, 0);
+ pTBInfo->bHardUpdate = FALSE;
+
InitDefaultButtons();
+ SetButtonToSkinned();
return;
}
SendMessage(hWnd, BUTTONSETCUSTOMPAINT, sizeof(MButtonExtension), (LPARAM)PaintWorker);
mir_subclassWindow(hWnd, TSButtonWndProc);
- MButtonExtension *bct = (MButtonExtension*) GetWindowLongPtr(hWnd, 0);
+ MButtonExtension *bct = (MButtonExtension*)GetWindowLongPtr(hWnd, 0);
int idx = getButtonIndex(hButton);
if (idx != -1) { // adding built-in button
BTNS[idx].hwndButton = hWnd;
if (BTNS[idx].isAction)
bct->bSendOnDown = true;
- if ( !BTNS[idx].isPush)
+ if (!BTNS[idx].isPush)
bct->bIsPushBtn = true;
}
+ else {
+ idx = getLastIndex();
+ BTNS[idx].hwndButton = hWnd;
+ BTNS[idx].pszButtonID = "plugin";
+ bool bSkinned = cfg::dat.bSkinnedButtonMode != 0;
+ CustomizeButton(hWnd, bSkinned, !bSkinned, bSkinned, true);
+ }
}
-void CustomizeButton(HWND hWnd, bool bIsSkinned, bool bIsThemed, bool bIsFlat)
+void CustomizeButton(HWND hWnd, bool bIsSkinned, bool bIsThemed, bool bIsFlat, bool bIsTTButton)
{
SendMessage(hWnd, BUTTONSETCUSTOMPAINT, sizeof(MButtonExtension), (LPARAM)PaintWorker);
mir_subclassWindow(hWnd, TSButtonWndProc);
@@ -501,6 +609,7 @@ void CustomizeButton(HWND hWnd, bool bIsSkinned, bool bIsThemed, bool bIsFlat) SendMessage(hWnd, BUTTONSETSKINNED, bIsSkinned, 0);
SendMessage(hWnd, BUTTONSETASTHEMEDBTN, bIsThemed, 0);
SendMessage(hWnd, BUTTONSETASFLATBTN, bIsFlat, 0);
+ SendMessage(hWnd, BUTTONSETTTBUTTON, bIsTTButton, 0);
}
static int Nicer_CustomizeToolbar(WPARAM, LPARAM)
@@ -512,7 +621,7 @@ static int Nicer_CustomizeToolbar(WPARAM, LPARAM) static int Nicer_ReloadToolbar(WPARAM wParam, LPARAM)
{
PLUGININFOEX *pInfo = (PLUGININFOEX*)wParam;
- if ( !_stricmp(pInfo->shortName, "TopToolBar"))
+ if (!_stricmp(pInfo->shortName, "TopToolBar"))
TopToolbar_SetCustomProc(CustomizeToolbar, 0);
return 0;
}
|