From a971c497d5c86f11df8a048e3e9eb88691966169 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 21 Jul 2013 10:37:30 +0000 Subject: - BUTTONSETSENDONDOWN functionality moved to the core; - custom button click processing removed from clist_nicer; - control id assignment removed and replaced with the search by HWND git-svn-id: http://svn.miranda-ng.org/main/trunk@5440 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Clist_modern/src/m_api/m_skinbutton.h | 2 - plugins/Clist_modern/src/modern_tbbutton.cpp | 79 ++++++++++++++------------- 2 files changed, 41 insertions(+), 40 deletions(-) (limited to 'plugins/Clist_modern/src') diff --git a/plugins/Clist_modern/src/m_api/m_skinbutton.h b/plugins/Clist_modern/src/m_api/m_skinbutton.h index 43a3167ce3..1ca5c38e6d 100644 --- a/plugins/Clist_modern/src/m_api/m_skinbutton.h +++ b/plugins/Clist_modern/src/m_api/m_skinbutton.h @@ -7,8 +7,6 @@ #define BUTTONSETID WM_USER+55 #define BUTTONDRAWINPARENT WM_USER+56 #define BUTTONSETMARGINS WM_USER+57 -#define BUTTONSETSENDONDOWN WM_USER+58 - #define SBF_ALIGN_TL_RIGHT 1 #define SBF_ALIGN_TL_HCENTER 2 diff --git a/plugins/Clist_modern/src/modern_tbbutton.cpp b/plugins/Clist_modern/src/modern_tbbutton.cpp index a82696884e..9d55684139 100644 --- a/plugins/Clist_modern/src/modern_tbbutton.cpp +++ b/plugins/Clist_modern/src/modern_tbbutton.cpp @@ -19,18 +19,15 @@ void CustomizeToolbar(HWND); struct TBBUTTONDATA : public MButtonCtrl { char *szButtonID; // button id - BOOL fSendOnDown; // send event on button pushed - BOOL fHotMark; // button is hot marked (e.g. current state) - BOOL fFocused; + bool bHotMark; // button is hot marked (e.g. current state) + bool bFocused; int nFontID; // internal font ID - HANDLE ttbID; // control ID TCHAR szText[128]; // text on the button RECT rcMargins; // margins of inner content - HANDLE hIcolibHandle; // handle of icon in iconlib + HANDLE hIcolibHandle; // handle of icon in iconlib - XPTHANDLE hThemeButton; - XPTHANDLE hThemeToolbar; + XPTHANDLE hThemeButton, hThemeToolbar; }; static CRITICAL_SECTION csTips; @@ -109,7 +106,7 @@ static void PaintWorker(TBBUTTONDATA *bct, HDC hdcPaint , POINT *pOffset) bct->szButtonID, // ID b2str(bct->stateId == PBS_HOT), // Hovered b2str(bct->stateId == PBS_PRESSED || bct->bIsPushed == TRUE), // Pressed - b2str(bct->fFocused)); // Focused + b2str(bct->bFocused)); // Focused SkinDrawGlyph(hdcMem,&rcClient,&rcClient,szRequest); } @@ -154,7 +151,7 @@ static void PaintWorker(TBBUTTONDATA *bct, HDC hdcPaint , POINT *pOffset) FillRect(hdcMem, &rcClient, hbr); DeleteObject(hbr); } - if (bct->stateId == PBS_HOT || bct->fFocused) { + if (bct->stateId == PBS_HOT || bct->bFocused) { if (bct->bIsPushed) DrawEdge(hdcMem,&rcClient, EDGE_ETCHED,BF_RECT|BF_SOFT); else @@ -234,16 +231,16 @@ static void PaintWorker(TBBUTTONDATA *bct, HDC hdcPaint , POINT *pOffset) static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - TBBUTTONDATA *bct = (TBBUTTONDATA *) GetWindowLongPtr(hwndDlg, 0); + TBBUTTONDATA *bct = (TBBUTTONDATA*)GetWindowLongPtr(hwndDlg, 0); + switch (msg) { case WM_DESTROY: xpt_FreeThemeForWindow(hwndDlg); WindowList_Remove(hButtonWindowList, hwndDlg); - break; // DONT! fall thru + break; case WM_SETTEXT: - lstrcpyn(bct->szText, (TCHAR *)lParam, SIZEOF(bct->szText)-1); - bct->szText[SIZEOF(bct->szText)-1] = '\0'; + _tcsncpy_s(bct->szText, SIZEOF(bct->szText), (TCHAR*)lParam, _TRUNCATE); break; case WM_SETFONT: @@ -252,10 +249,6 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam bct->nFontID = (int)lParam - 1; break; - case BUTTONSETSENDONDOWN: - bct->fSendOnDown = (BOOL)lParam; - break; - case BUTTONSETMARGINS: if (lParam) bct->rcMargins = *(RECT*)lParam; else { @@ -270,7 +263,7 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam case BUTTONDRAWINPARENT: if (IsWindowVisible(hwndDlg)) - PaintWorker(bct, (HDC) wParam, (POINT*) lParam); + PaintWorker(bct, (HDC)wParam, (POINT*)lParam); break; case WM_NCPAINT: @@ -301,15 +294,15 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam RECT rcClient; GetClientRect(bct->hwnd, &rcClient); if ( !PtInRect(&rcClient, ptMouse)) { - bct->fHotMark = FALSE; + bct->bHotMark = false; ReleaseCapture(); } else { if (bct->stateId != PBS_DISABLED && bct->stateId != PBS_PRESSED) { bct->stateId = PBS_PRESSED; - bct->fHotMark = TRUE; + bct->bHotMark = true; InvalidateParentRect(bct->hwnd, NULL, TRUE); - if (bct->fSendOnDown) { + if (bct->bSendOnDown) { SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM) hwndDlg); bct->stateId = PBS_NORMAL; InvalidateParentRect(bct->hwnd, NULL, TRUE); @@ -321,14 +314,14 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam return 0; case WM_LBUTTONUP: - if ( GetCapture() == bct->hwnd ) { + if (GetCapture() == bct->hwnd) { POINT ptMouse = UNPACK_POINT(lParam); RECT rcClient; GetClientRect(bct->hwnd, &rcClient); if ( !PtInRect(&rcClient, ptMouse)) { - bct->fHotMark = FALSE; + bct->bHotMark = false; ReleaseCapture(); break; } @@ -341,44 +334,45 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam bct->stateId = PBS_HOT; InvalidateParentRect(bct->hwnd, NULL, TRUE); } - if ( !bct->fSendOnDown) { - bct->fHotMark = FALSE; + if ( !bct->bSendOnDown) { + bct->bHotMark = false; SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM)hwndDlg); } } - else bct->fHotMark = FALSE; + else bct->bHotMark = false; return 0; case WM_MOUSEMOVE: { - RECT rc; - POINT pt; BOOL bPressed = (wParam & MK_LBUTTON) != 0; - if ( bPressed && !bct->fHotMark ) + if (bPressed && !bct->bHotMark) break; + + RECT rc; + POINT pt; GetWindowRect(hwndDlg, &rc); GetCursorPos(&pt); BOOL inClient = PtInRect(&rc, pt); - if ( inClient ) { - SetCapture( bct->hwnd ); - if ( bct->stateId == PBS_NORMAL ) { + if (inClient) { + SetCapture(bct->hwnd); + if (bct->stateId == PBS_NORMAL) { bct->stateId = PBS_HOT; InvalidateParentRect(bct->hwnd, NULL, TRUE); } } - if ( !inClient && bct->stateId == PBS_PRESSED ) { + if (!inClient && bct->stateId == PBS_PRESSED) { bct->stateId = PBS_HOT; InvalidateParentRect(bct->hwnd, NULL, TRUE); } - else if ( inClient && bct->stateId == PBS_HOT && bPressed ) { - if ( bct->fHotMark ) { + else if (inClient && bct->stateId == PBS_HOT && bPressed) { + if (bct->bHotMark) { bct->stateId = PBS_PRESSED; InvalidateParentRect(bct->hwnd, NULL, TRUE); } } else if ( !inClient && !bPressed) { - bct->fHotMark = FALSE; + bct->bHotMark = false; ReleaseCapture(); } } @@ -401,6 +395,16 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam InvalidateRect(bct->hwnd, NULL, TRUE); return 0; + case WM_SETFOCUS: // set keyboard focus and redraw + bct->bFocused = true; + InvalidateParentRect(bct->hwnd, NULL, TRUE); + break; + + case WM_KILLFOCUS: // kill focus and redraw + bct->bFocused = false; + InvalidateParentRect(bct->hwnd, NULL, TRUE); + break; + case WM_ERASEBKGND: return 1; @@ -459,9 +463,8 @@ void CustomizeButton(HANDLE ttbid, HWND hWnd, LPARAM lParam) MakeButtonSkinned(hWnd); - TBBUTTONDATA* p = (TBBUTTONDATA*)GetWindowLongPtr(hWnd, 0); + TBBUTTONDATA *p = (TBBUTTONDATA*)GetWindowLongPtr(hWnd, 0); p->szButtonID = "Toolbar.MissingID"; - p->ttbID = ttbid; SendMessage(hWnd, MBM_UPDATETRANSPARENTFLAG, 0, 2); } -- cgit v1.2.3