summaryrefslogtreecommitdiff
path: root/plugins/Clist_modern
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-09 09:02:16 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-09 09:02:16 +0000
commit6d10b27399e46e952ded3d5a8bc4645ccffb2c34 (patch)
treefc245f64fc5b4da747fa85d588cc10ce525504c2 /plugins/Clist_modern
parent4ce494e510feaaabc64ac4630645874ddd95203d (diff)
- customizeable TopToolbar
- restored Clist Modern toolbar painter git-svn-id: http://svn.miranda-ng.org/main/trunk@876 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Clist_modern')
-rw-r--r--plugins/Clist_modern/modern_cluiframes.cpp2
-rw-r--r--plugins/Clist_modern/modern_tbbutton.cpp44
-rw-r--r--plugins/Clist_modern/modern_toolbar.cpp183
3 files changed, 200 insertions, 29 deletions
diff --git a/plugins/Clist_modern/modern_cluiframes.cpp b/plugins/Clist_modern/modern_cluiframes.cpp
index 2df4d35889..5af86e7bde 100644
--- a/plugins/Clist_modern/modern_cluiframes.cpp
+++ b/plugins/Clist_modern/modern_cluiframes.cpp
@@ -2675,8 +2675,6 @@ int CLUIFramesOnClistResize(WPARAM wParam,LPARAM lParam)
}
GetWindowRect(pcli->hwndContactList,&mainRect);
mainHeight = mainRect.bottom-mainRect.top;
- //if (mainHeight < minHeight)
- // DebugBreak();
}
GetClientRect(pcli->hwndContactList,&nRect);
//$$$ Fixed borders
diff --git a/plugins/Clist_modern/modern_tbbutton.cpp b/plugins/Clist_modern/modern_tbbutton.cpp
index fc17b0921f..dadf53637a 100644
--- a/plugins/Clist_modern/modern_tbbutton.cpp
+++ b/plugins/Clist_modern/modern_tbbutton.cpp
@@ -15,7 +15,6 @@
#define b2str(a) ((a) ? "True" : "False")
void CustomizeToolbar(HWND);
-int Modern_InitButtons(WPARAM, LPARAM);
struct TBBUTTONDATA : public MButtonCtrl
{
@@ -77,27 +76,24 @@ static int TBStateConvert2Flat(int state)
return TS_NORMAL;
}
-static void PaintWorker(TBBUTTONDATA *lpSBData, HDC hdcPaint , POINT * pOffset)
+static void PaintWorker(TBBUTTONDATA *lpSBData, HDC hdcPaint , POINT *pOffset)
{
- HDC hdcMem;
- HBITMAP hbmMem;
- RECT rcClient;
- int width;
- int height;
- HBITMAP hbmOld = NULL;
- HFONT hOldFont = NULL;
- BLENDFUNCTION bf = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
POINT offset = {0};
- if (pOffset) offset = *pOffset;
+ if (pOffset)
+ offset = *pOffset;
- if ( !hdcPaint) return; //early exit
+ if ( !hdcPaint)
+ return; //early exit
+ RECT rcClient;
GetClientRect(lpSBData->hwnd, &rcClient);
- width = rcClient.right - rcClient.left;
- height = rcClient.bottom - rcClient.top;
+ int width = rcClient.right - rcClient.left;
+ int height = rcClient.bottom - rcClient.top;
- hdcMem = pOffset?hdcPaint:CreateCompatibleDC(hdcPaint);
- hOldFont = (HFONT)SelectObject(hdcMem, lpSBData->hFont);
+ HBITMAP hbmMem;
+ HBITMAP hbmOld = NULL;
+ HDC hdcMem = pOffset ? hdcPaint : CreateCompatibleDC(hdcPaint);
+ HFONT hOldFont = (HFONT)SelectObject(hdcMem, lpSBData->hFont);
if ( !pOffset) {
hbmMem = ske_CreateDIB32(width, height);
hbmOld = (HBITMAP)SelectObject(hdcMem, hbmMem);
@@ -107,7 +103,7 @@ static void PaintWorker(TBBUTTONDATA *lpSBData, HDC hdcPaint , POINT * pOffset)
if ( !g_CluiData.fDisableSkinEngine) {
char szRequest[128];
/* painting */
- mir_snprintf(szRequest,SIZEOF(szRequest),"Button,ID = %s,Hovered = %s,Pressed = %s,Focused = %s",
+ mir_snprintf(szRequest,SIZEOF(szRequest),"Button,ID=%s,Hovered=%s,Pressed=%s,Focused=%s",
lpSBData->szButtonID, // ID
b2str(lpSBData->stateId == PBS_HOT), // Hovered
b2str(lpSBData->stateId == PBS_PRESSED || lpSBData->bIsPushed == TRUE), // Pressed
@@ -312,21 +308,17 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam
RECT rcClient;
GetClientRect( lpSBData->hwnd, &rcClient );
-
- if ( !PtInRect( &rcClient, ptMouse ))
- {
+ if ( !PtInRect( &rcClient, ptMouse )) {
lpSBData->fHotMark = FALSE;
ReleaseCapture();
break;
}
- if (lpSBData->stateId != PBS_DISABLED && lpSBData->stateId != PBS_PRESSED)
- {
+ if (lpSBData->stateId != PBS_DISABLED && lpSBData->stateId != PBS_PRESSED) {
lpSBData->stateId = PBS_PRESSED;
lpSBData->fHotMark = TRUE;
InvalidateParentRect(lpSBData->hwnd, NULL, TRUE);
- if (lpSBData->fSendOnDown)
- {
+ if (lpSBData->fSendOnDown) {
SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM) hwndDlg);
lpSBData->stateId = PBS_NORMAL;
InvalidateParentRect(lpSBData->hwnd, NULL, TRUE);
@@ -510,7 +502,7 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam
static void CustomizeButton(HANDLE ttbid, HWND hWnd, LPARAM lParam)
{
if (ttbid == (HANDLE)-1) {
- //CustomizeToolbar(hWnd);
+ CustomizeToolbar(hWnd);
return;
}
@@ -521,6 +513,7 @@ static void CustomizeButton(HANDLE ttbid, HWND hWnd, LPARAM lParam)
SendMessage(hWnd, BUTTONSETCUSTOM, 0, (LPARAM)&Custom);
TBBUTTONDATA* p = (TBBUTTONDATA*)GetWindowLongPtr(hWnd, 0);
+ sprintf(p->szButtonID, "Toolbar.%p", p->hwnd);
p->nFontID = -1;
p->hThemeButton = xpt_AddThemeHandle(p->hwnd, L"BUTTON");
p->hThemeToolbar = xpt_AddThemeHandle(p->hwnd, L"TOOLBAR");
@@ -531,7 +524,6 @@ static void CustomizeButton(HANDLE ttbid, HWND hWnd, LPARAM lParam)
int Buttons_ModuleLoaded(WPARAM wParam, LPARAM lParam)
{
- HookEvent(ME_TTB_INITBUTTONS, Modern_InitButtons);
TopToolbar_SetCustomProc(CustomizeButton, 0);
return 0;
}
diff --git a/plugins/Clist_modern/modern_toolbar.cpp b/plugins/Clist_modern/modern_toolbar.cpp
index 59f30db249..606dc1122a 100644
--- a/plugins/Clist_modern/modern_toolbar.cpp
+++ b/plugins/Clist_modern/modern_toolbar.cpp
@@ -49,7 +49,7 @@ static BTNS[] =
{ "Minimize","Minimize", "CList/ShowHide", "Minimize", NULL, 180 , IDI_RESETVIEW, IDI_RESETVIEW, FALSE }
};
-int Modern_InitButtons(WPARAM, LPARAM)
+static int Modern_InitButtons(WPARAM, LPARAM)
{
TTBButton tbb = { 0 };
tbb.cbSize = sizeof(tbb);
@@ -81,6 +81,186 @@ int Modern_InitButtons(WPARAM, LPARAM)
///////////////////////////////////////////////////////////////////////////////
+#define MTBM_LAYEREDPAINT (WM_USER+20)
+
+struct ModernToolbarCtrl : public TTBCtrl
+{
+ XPTHANDLE mtbXPTheme;
+ BOOL fAutoSize;
+ int nLineCount;
+ WORD wLastHeight;
+ BOOL fSingleLine;
+};
+
+struct MTB_BUTTONINFO
+{
+ HWND hWindow;
+};
+
+struct
+{
+ HBITMAP mtb_hBmpBackground;
+ COLORREF mtb_bkColour;
+ WORD mtb_backgroundBmpUse;
+ BOOL mtb_useWinColors;
+}
+static tbdat = { 0 };
+
+COLORREF sttGetColor(char * module, char * color, COLORREF defColor);
+
+static int ehhToolBarBackgroundSettingsChanged(WPARAM wParam, LPARAM lParam)
+{
+ if ( tbdat.mtb_hBmpBackground) {
+ DeleteObject(tbdat.mtb_hBmpBackground);
+ tbdat.mtb_hBmpBackground = NULL;
+ }
+ if (g_CluiData.fDisableSkinEngine) {
+ DBVARIANT dbv;
+ tbdat.mtb_bkColour = sttGetColor("ToolBar","BkColour",CLCDEFAULT_BKCOLOUR);
+ if ( db_get_b(NULL,"ToolBar","UseBitmap",CLCDEFAULT_USEBITMAP)) {
+ if ( !db_get_s(NULL, "ToolBar", "BkBitmap", &dbv, DBVT_TCHAR)) {
+ tbdat.mtb_hBmpBackground = (HBITMAP)CallService(MS_UTILS_LOADBITMAP,0,(LPARAM)dbv.ptszVal);
+ db_free(&dbv);
+ }
+ }
+ tbdat.mtb_useWinColors = db_get_b(NULL, "ToolBar", "UseWinColours", CLCDEFAULT_USEWINDOWSCOLOURS);
+ tbdat.mtb_backgroundBmpUse = db_get_b(NULL, "ToolBar", "BkBmpUse", CLCDEFAULT_BKBMPUSE);
+ }
+ PostMessage(pcli->hwndContactList,WM_SIZE,0,0);
+ return 0;
+}
+
+static BOOL sttDrawToolBarBackground(HWND hwnd, HDC hdc, RECT * rect, ModernToolbarCtrl* pMTBInfo)
+{
+ BOOL bFloat = (GetParent(hwnd)!=pcli->hwndContactList);
+ if (g_CluiData.fDisableSkinEngine || !g_CluiData.fLayered || bFloat)
+ {
+ RECT rc;
+ HBRUSH hbr;
+
+ if (rect)
+ rc=*rect;
+ else
+ GetClientRect(hwnd,&rc);
+
+ if ( !(tbdat.mtb_backgroundBmpUse && tbdat.mtb_hBmpBackground) && tbdat.mtb_useWinColors)
+ {
+ if (xpt_IsThemed(pMTBInfo->mtbXPTheme))
+ xpt_DrawTheme(pMTBInfo->mtbXPTheme,pMTBInfo->hWnd, hdc, 0, 0, &rc, &rc);
+ else {
+ hbr = GetSysColorBrush(COLOR_3DFACE);
+ FillRect(hdc, &rc, hbr);
+ }
+ }
+ else if (!tbdat.mtb_hBmpBackground && !tbdat.mtb_useWinColors)
+ {
+ hbr = CreateSolidBrush(tbdat.mtb_bkColour);
+ FillRect(hdc, &rc, hbr);
+ DeleteObject(hbr);
+ }
+ else DrawBackGround(hwnd, hdc, tbdat.mtb_hBmpBackground, tbdat.mtb_bkColour, tbdat.mtb_backgroundBmpUse);
+ }
+ return TRUE;
+}
+
+static void sttDrawNonLayeredSkinedBar(HWND hwnd, HDC hdc)
+{
+ RECT rc = {0};
+ GetClientRect(hwnd, &rc);
+ rc.right++;
+ rc.bottom++;
+ HDC hdc2 = CreateCompatibleDC(hdc);
+ HBITMAP hbmp = ske_CreateDIB32(rc.right, rc.bottom);
+ HBITMAP hbmpo = (HBITMAP)SelectObject(hdc2, hbmp);
+ if (GetParent(hwnd) != pcli->hwndContactList) {
+ HBRUSH br = GetSysColorBrush(COLOR_3DFACE);
+ FillRect(hdc2, &rc, br);
+ }
+ else ske_BltBackImage(hwnd, hdc2, &rc);
+
+ SendMessage(hwnd, MTBM_LAYEREDPAINT, (WPARAM)hdc2, 0);
+ BitBlt(hdc, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, hdc2, rc.left, rc.top, SRCCOPY);
+ SelectObject(hdc2, hbmpo);
+ DeleteObject(hbmp);
+ mod_DeleteDC(hdc2);
+
+ SelectObject(hdc, (HFONT)GetStockObject(DEFAULT_GUI_FONT));
+ ValidateRect(hwnd, NULL);
+}
+
+static LRESULT CALLBACK toolbarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ ModernToolbarCtrl* pMTBInfo = (ModernToolbarCtrl*)GetWindowLongPtr(hwnd, 0);
+
+ switch( msg ) {
+ case WM_ERASEBKGND:
+ pMTBInfo->lResult = (g_CluiData.fDisableSkinEngine) ? sttDrawToolBarBackground(hwnd, (HDC)wParam, NULL, pMTBInfo) : 0;
+ return 1;
+
+ case WM_NCPAINT:
+ case WM_PAINT:
+ {
+ PAINTSTRUCT ps;
+ BOOL bFloat = (GetParent(hwnd) != pcli->hwndContactList);
+ if (g_CluiData.fDisableSkinEngine|| !g_CluiData.fLayered || bFloat ) {
+ BeginPaint(hwnd,&ps);
+ if ((!g_CluiData.fLayered || bFloat) && !g_CluiData.fDisableSkinEngine)
+ sttDrawNonLayeredSkinedBar(hwnd, ps.hdc);
+ else
+ sttDrawToolBarBackground(hwnd, ps.hdc, &ps.rcPaint, pMTBInfo);
+ EndPaint(hwnd,&ps);
+ }
+ }
+ pMTBInfo->lResult = DefWindowProc(hwnd, msg, wParam, lParam);
+ return 1;
+
+ case MTBM_LAYEREDPAINT:
+ {
+ int i;
+ RECT MyRect={0};
+ HDC hDC=(HDC)wParam;
+ GetWindowRect(hwnd,&MyRect);
+
+ RECT rcClient;
+ GetClientRect(hwnd, &rcClient);
+ SkinDrawGlyph(hDC, &rcClient, &rcClient, "Bar,ID=ToolBar,Part=Background");
+
+ for (i=0; i < pMTBInfo->pButtonList->realCount; i++) {
+ RECT childRect;
+ POINT Offset;
+ TTBCtrlButton* mtbi = (TTBCtrlButton*)pMTBInfo->pButtonList->items[i];
+ GetWindowRect(mtbi->hWindow, &childRect);
+ Offset.x = childRect.left - MyRect.left;;
+ Offset.y = childRect.top - MyRect.top;
+ SendMessage(mtbi->hWindow, BUTTONDRAWINPARENT, (WPARAM)hDC, (LPARAM)&Offset);
+ }
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+void CustomizeToolbar(HWND hwnd)
+{
+ TTBCtrlCustomize custData = { sizeof(ModernToolbarCtrl), toolbarWndProc, NULL };
+ SendMessage(hwnd, TTB_SETCUSTOM, 0, (LPARAM)&custData);
+
+ ModernToolbarCtrl* pMTBInfo = (ModernToolbarCtrl*)GetWindowLongPtr(hwnd, 0);
+ pMTBInfo->nLineCount = 1;
+ pMTBInfo->mtbXPTheme = xpt_AddThemeHandle(hwnd, L"TOOLBAR");
+}
+
+static int Toolbar_ModulesLoaded(WPARAM, LPARAM)
+{
+ CallService(MS_BACKGROUNDCONFIG_REGISTER, (WPARAM)"ToolBar Background/ToolBar",0);
+ HookEvent(ME_BACKGROUNDCONFIG_CHANGED, ehhToolBarBackgroundSettingsChanged);
+ HookEvent(ME_TTB_INITBUTTONS, Modern_InitButtons);
+ return 0;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
#define TTB_OPTDIR "TopToolBar"
#if defined(WIN64)
@@ -113,5 +293,6 @@ HRESULT ToolbarLoadModule()
CallService(MS_UTILS_OPENURL, 0, (LPARAM)szUrl);
}
+ HookEvent(ME_SYSTEM_MODULESLOADED, Toolbar_ModulesLoaded);
return S_OK;
}