From eb8ccdb0ad9e2c508f425b2b25a6eb1e25644461 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 19 Jun 2012 18:21:17 +0000 Subject: clist nicer+ button sync git-svn-id: http://svn.miranda-ng.org/main/trunk@485 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- include/m_button.h | 7 ++++ plugins/Clist_nicer/SRC/clcopts.cpp | 46 ++++++++++---------- plugins/Clist_nicer/SRC/clistmenus.cpp | 8 ++-- plugins/Clist_nicer/SRC/extBackg.cpp | 20 ++++----- plugins/Clist_nicer/SRC/viewmodes.cpp | 8 ++-- src/modules/button/button.cpp | 76 +++++++++++++++++++--------------- 6 files changed, 91 insertions(+), 74 deletions(-) diff --git a/include/m_button.h b/include/m_button.h index d5742ce4b0..2e8f9e4cf9 100644 --- a/include/m_button.h +++ b/include/m_button.h @@ -56,6 +56,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Only works on MButtonClass buttons #define BUTTONSETASFLATBTN (WM_USER+4) +// Sets the button type as a flat button without borders v0.3.3+ +// wParam = TRUE/FALSE default on/off +// lParam = not used +// Usage: SendMessage(hwndbutton, BUTTONSETASFLATBTN, 1, 0); +// Only works on MButtonClass buttons +#define BUTTONSETASTHEMEDBTN (WM_USER+5) + // Sets a tooltip for the button v0.3.3+ // wParam = (WPARAM)(char *)szTip // lParam = not used diff --git a/plugins/Clist_nicer/SRC/clcopts.cpp b/plugins/Clist_nicer/SRC/clcopts.cpp index 110ca15111..d32068818e 100644 --- a/plugins/Clist_nicer/SRC/clcopts.cpp +++ b/plugins/Clist_nicer/SRC/clcopts.cpp @@ -1055,29 +1055,29 @@ static INT_PTR CALLBACK DlgProcDspProfiles(HWND hwnd, UINT msg, WPARAM wParam, L { hwndList = GetDlgItem(hwnd, IDC_PROFILELIST); - HWND hwndAdd = GetDlgItem(hwnd, IDC_DSP_ADD); - SendMessage(hwndAdd, BUTTONSETASFLATBTN, TRUE, 1); - SendMessage(hwndAdd, BUTTONSETASFLATBTN + 10, 0, 1); - SendMessage(hwndAdd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ADDCONTACT), IMAGE_ICON, 16, 16, LR_SHARED)); - SetWindowText(hwndAdd, TranslateT("Add New...")); - - hwndAdd = GetDlgItem(hwnd, IDC_DSP_DELETE); - SendMessage(hwndAdd, BUTTONSETASFLATBTN, TRUE, 1); - SendMessage(hwndAdd, BUTTONSETASFLATBTN + 10, 0, 1); - SendMessage(hwndAdd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_DELETE), IMAGE_ICON, 16, 16, LR_SHARED)); - SetWindowText(hwndAdd, TranslateT("Delete")); - - hwndAdd = GetDlgItem(hwnd, IDC_DSP_RENAME); - SendMessage(hwndAdd, BUTTONSETASFLATBTN, TRUE, 1); - SendMessage(hwndAdd, BUTTONSETASFLATBTN + 10, 0, 1); - SendMessage(hwndAdd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_RENAME), IMAGE_ICON, 16, 16, LR_SHARED)); - SetWindowText(hwndAdd, TranslateT("Rename...")); - - hwndAdd = GetDlgItem(hwnd, IDC_DSP_APPLY); - SendMessage(hwndAdd, BUTTONSETASFLATBTN, TRUE, 1); - SendMessage(hwndAdd, BUTTONSETASFLATBTN + 10, 0, 1); - SendMessage(hwndAdd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_OPTIONS), IMAGE_ICON, 16, 16, LR_SHARED)); - SetWindowText(hwndAdd, TranslateT("Apply this profile")); + HWND hwndBtn = GetDlgItem(hwnd, IDC_DSP_ADD); + SendMessage(hwndBtn, BUTTONSETASFLATBTN, FALSE, 0); + SendMessage(hwndBtn, BUTTONSETASTHEMEDBTN, TRUE, 0); + SendMessage(hwndBtn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ADDCONTACT), IMAGE_ICON, 16, 16, LR_SHARED)); + SetWindowText(hwndBtn, TranslateT("Add New...")); + + hwndBtn = GetDlgItem(hwnd, IDC_DSP_DELETE); + SendMessage(hwndBtn, BUTTONSETASFLATBTN, FALSE, 0); + SendMessage(hwndBtn, BUTTONSETASTHEMEDBTN, TRUE, 0); + SendMessage(hwndBtn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_DELETE), IMAGE_ICON, 16, 16, LR_SHARED)); + SetWindowText(hwndBtn, TranslateT("Delete")); + + hwndBtn = GetDlgItem(hwnd, IDC_DSP_RENAME); + SendMessage(hwndBtn, BUTTONSETASFLATBTN, FALSE, 0); + SendMessage(hwndBtn, BUTTONSETASTHEMEDBTN, TRUE, 0); + SendMessage(hwndBtn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_RENAME), IMAGE_ICON, 16, 16, LR_SHARED)); + SetWindowText(hwndBtn, TranslateT("Rename...")); + + hwndBtn = GetDlgItem(hwnd, IDC_DSP_APPLY); + SendMessage(hwndBtn, BUTTONSETASFLATBTN, FALSE, 0); + SendMessage(hwndBtn, BUTTONSETASTHEMEDBTN, TRUE, 0); + SendMessage(hwndBtn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_OPTIONS), IMAGE_ICON, 16, 16, LR_SHARED)); + SetWindowText(hwndBtn, TranslateT("Apply this profile")); RECT rcClient; GetClientRect(hwnd, &rcClient); diff --git a/plugins/Clist_nicer/SRC/clistmenus.cpp b/plugins/Clist_nicer/SRC/clistmenus.cpp index 58f6a0fcc8..082a655b5b 100644 --- a/plugins/Clist_nicer/SRC/clistmenus.cpp +++ b/plugins/Clist_nicer/SRC/clistmenus.cpp @@ -113,16 +113,16 @@ static INT_PTR CALLBACK IgnoreDialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPA SendMessage(hWnd, WM_USER + 120, 0, 0); TranslateDialogDefault(hWnd); hwndAdd = GetDlgItem(hWnd, IDC_IGN_ADDPERMANENTLY); // CreateWindowEx(0, _T("CLCButtonClass"), _T("FOO"), WS_VISIBLE | BS_PUSHBUTTON | WS_CHILD | WS_TABSTOP, 200, 276, 106, 24, hWnd, (HMENU)IDC_IGN_ADDPERMANENTLY, g_hInst, NULL); - SendMessage(hwndAdd, BUTTONSETASFLATBTN, TRUE, 1); - SendMessage(hwndAdd, BUTTONSETASFLATBTN + 10, 0, 1); + SendMessage(hwndAdd, BUTTONSETASFLATBTN, FALSE, 0); + SendMessage(hwndAdd, BUTTONSETASTHEMEDBTN, TRUE, 0); SendMessage(hwndAdd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(210), IMAGE_ICON, 16, 16, LR_SHARED)); SetWindowText(hwndAdd, TranslateT("Add permanently")); EnableWindow(hwndAdd, cfg::getByte(hContact, "CList", "NotOnList", 0)); hwndAdd = GetDlgItem(hWnd, IDC_DSP_LOADDEFAULT); // CreateWindowEx(0, _T("CLCButtonClass"), _T("FOO"), WS_VISIBLE | BS_PUSHBUTTON | WS_CHILD | WS_TABSTOP, 200, 276, 106, 24, hWnd, (HMENU)IDC_IGN_ADDPERMANENTLY, g_hInst, NULL); - SendMessage(hwndAdd, BUTTONSETASFLATBTN, TRUE, 1); - SendMessage(hwndAdd, BUTTONSETASFLATBTN + 10, 0, 1); + SendMessage(hwndAdd, BUTTONSETASFLATBTN, FALSE, 0); + SendMessage(hwndAdd, BUTTONSETASTHEMEDBTN, TRUE, 0); SendMessage(hwndAdd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_DELETE), IMAGE_ICON, 16, 16, LR_SHARED)); SetWindowText(hwndAdd, TranslateT("Revert to default")); diff --git a/plugins/Clist_nicer/SRC/extBackg.cpp b/plugins/Clist_nicer/SRC/extBackg.cpp index 4e2f0a852e..5fe9cfb9c8 100644 --- a/plugins/Clist_nicer/SRC/extBackg.cpp +++ b/plugins/Clist_nicer/SRC/extBackg.cpp @@ -419,16 +419,16 @@ void SetButtonToSkinned() SendDlgItemMessage(pcli->hwndContactList, IDC_TBMENU, BM_SETSKINNED, 0, bSkinned); SendDlgItemMessage(pcli->hwndContactList, IDC_TBGLOBALSTATUS, BM_SETSKINNED, 0, bSkinned); if(bSkinned) { - SendDlgItemMessage(pcli->hwndContactList, IDC_TBMENU, BUTTONSETASFLATBTN, TRUE, 0); - SendDlgItemMessage(pcli->hwndContactList, IDC_TBGLOBALSTATUS, BUTTONSETASFLATBTN, TRUE, 0); - SendDlgItemMessage(pcli->hwndContactList, IDC_TBGLOBALSTATUS, BUTTONSETASFLATBTN + 10, 0, 0); - SendDlgItemMessage(pcli->hwndContactList, IDC_TBMENU, BUTTONSETASFLATBTN + 10, 0, 0); + SendDlgItemMessage(pcli->hwndContactList, IDC_TBMENU, BUTTONSETASFLATBTN, FALSE, 0); + SendDlgItemMessage(pcli->hwndContactList, IDC_TBGLOBALSTATUS, BUTTONSETASFLATBTN, FALSE, 0); + SendDlgItemMessage(pcli->hwndContactList, IDC_TBGLOBALSTATUS, BUTTONSETASTHEMEDBTN, 0, 0); + SendDlgItemMessage(pcli->hwndContactList, IDC_TBMENU, BUTTONSETASTHEMEDBTN, 0, 0); } else { - SendDlgItemMessage(pcli->hwndContactList, IDC_TBMENU, BUTTONSETASFLATBTN, TRUE, 1); - SendDlgItemMessage(pcli->hwndContactList, IDC_TBGLOBALSTATUS, BUTTONSETASFLATBTN, TRUE, 1); - SendDlgItemMessage(pcli->hwndContactList, IDC_TBGLOBALSTATUS, BUTTONSETASFLATBTN + 10, 0, 1); - SendDlgItemMessage(pcli->hwndContactList, IDC_TBMENU, BUTTONSETASFLATBTN + 10, 0, 1); + SendDlgItemMessage(pcli->hwndContactList, IDC_TBMENU, BUTTONSETASFLATBTN, FALSE, 0); + SendDlgItemMessage(pcli->hwndContactList, IDC_TBGLOBALSTATUS, BUTTONSETASFLATBTN, FALSE, 0); + SendDlgItemMessage(pcli->hwndContactList, IDC_TBGLOBALSTATUS, BUTTONSETASTHEMEDBTN, TRUE, 0); + SendDlgItemMessage(pcli->hwndContactList, IDC_TBMENU, BUTTONSETASTHEMEDBTN, TRUE, 0); } SendMessage(g_hwndViewModeFrame, WM_USER + 100, 0, 0); } @@ -1235,8 +1235,8 @@ static void BTN_ReadItem(char *itemName, char *file) } newItem->hWnd = CreateWindowEx(0, MIRANDABUTTONCLASS, _T(""), BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | WS_TABSTOP, 0, 0, 5, 5, pcli->hwndContactList, (HMENU)newItem->uId, g_hInst, NULL); SendMessage(newItem->hWnd, BM_SETBTNITEM, 0, (LPARAM)newItem); - SendMessage(newItem->hWnd, BUTTONSETASFLATBTN, TRUE, 0); - SendMessage(newItem->hWnd, BUTTONSETASFLATBTN + 10, 0, 0); + SendMessage(newItem->hWnd, BUTTONSETASFLATBTN, FALSE, 0); + SendMessage(newItem->hWnd, BUTTONSETASTHEMEDBTN, 0, 0); if(newItem->dwFlags & BUTTON_ISTOGGLE) SendMessage(newItem->hWnd, BUTTONSETASPUSHBTN, TRUE, 0); diff --git a/plugins/Clist_nicer/SRC/viewmodes.cpp b/plugins/Clist_nicer/SRC/viewmodes.cpp index aecf8029e6..19297307c9 100644 --- a/plugins/Clist_nicer/SRC/viewmodes.cpp +++ b/plugins/Clist_nicer/SRC/viewmodes.cpp @@ -949,12 +949,12 @@ LRESULT CALLBACK ViewModeFrameWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM while(_buttons[i] != 0) { SendMessage(GetDlgItem(hwnd, _buttons[i]), BM_SETSKINNED, 0, bSkinned); if(bSkinned) { - SendDlgItemMessage(hwnd, _buttons[i], BUTTONSETASFLATBTN, TRUE, 0); - SendDlgItemMessage(hwnd, _buttons[i], BUTTONSETASFLATBTN + 10, 0, 0); + SendDlgItemMessage(hwnd, _buttons[i], BUTTONSETASFLATBTN, FALSE, 0); + SendDlgItemMessage(hwnd, _buttons[i], BUTTONSETASTHEMEDBTN, 0, 0); } else { - SendDlgItemMessage(hwnd, _buttons[i], BUTTONSETASFLATBTN, TRUE, 1); - SendDlgItemMessage(hwnd, _buttons[i], BUTTONSETASFLATBTN + 10, 0, 1); + SendDlgItemMessage(hwnd, _buttons[i], BUTTONSETASFLATBTN, FALSE, 0); + SendDlgItemMessage(hwnd, _buttons[i], BUTTONSETASTHEMEDBTN, TRUE, 0); } i++; } diff --git a/src/modules/button/button.cpp b/src/modules/button/button.cpp index 32ade1cd7a..752e4da1bb 100644 --- a/src/modules/button/button.cpp +++ b/src/modules/button/button.cpp @@ -31,17 +31,20 @@ struct MButtonCtrl int focus; // has focus (1 or 0) HFONT hFont; // font HICON arrow; // uses down arrow - int defbutton; // default button HICON hIcon; HBITMAP hBitmap; - int pushBtn; - int pbState; HTHEME hThemeButton; HTHEME hThemeToolbar; TCHAR cHot; - int flatBtn; HWND hwndToolTips; IAccPropServices* pAccPropServices; + + bool bIsPushBtn, // button has two states + bIsPushed, // is button pushed or not + bIsDefault, // default button + bIsFlat, // flat button + bIsThemed, // themed button + bIsSkinned; // skinned button }; struct TTooltips @@ -125,15 +128,14 @@ static void PaintWorker(MButtonCtrl *ctl, HDC hdcPaint) hOld = (HDC)SelectObject(hdcMem, hbmMem); // If its a push button, check to see if it should stay pressed - if (ctl->pushBtn && ctl->pbState) ctl->stateId = PBS_PRESSED; + if (ctl->bIsPushBtn && ctl->bIsPushed) ctl->stateId = PBS_PRESSED; // Draw the flat button - if (ctl->flatBtn) { + if (ctl->bIsFlat) { if (ctl->hThemeToolbar) { - int state = IsWindowEnabled(ctl->hwnd)?(ctl->stateId == PBS_NORMAL&&ctl->defbutton?PBS_DEFAULTED:ctl->stateId):PBS_DISABLED; - if (isThemeBackgroundPartiallyTransparent(ctl->hThemeToolbar, TP_BUTTON, TBStateConvert2Flat(state))) { + int state = IsWindowEnabled(ctl->hwnd)?(ctl->stateId == PBS_NORMAL && ctl->bIsDefault ? PBS_DEFAULTED : ctl->stateId):PBS_DISABLED; + if (isThemeBackgroundPartiallyTransparent(ctl->hThemeToolbar, TP_BUTTON, TBStateConvert2Flat(state))) drawThemeParentBackground(ctl->hwnd, hdcMem, &rcClient); - } drawThemeBackground(ctl->hThemeToolbar, hdcMem, TP_BUTTON, TBStateConvert2Flat(state), &rcClient, &rcClient); } else { @@ -154,7 +156,7 @@ static void PaintWorker(MButtonCtrl *ctl, HDC hdcPaint) DeleteObject(hbr); } if (ctl->stateId == PBS_HOT || ctl->focus) { - if (ctl->pbState) + if (ctl->bIsPushed) DrawEdge(hdcMem, &rcClient, EDGE_ETCHED, BF_RECT|BF_SOFT); else DrawEdge(hdcMem, &rcClient, BDR_RAISEDOUTER, BF_RECT|BF_SOFT|BF_FLAT); } @@ -165,15 +167,16 @@ static void PaintWorker(MButtonCtrl *ctl, HDC hdcPaint) else { // Draw background/border if (ctl->hThemeButton) { - int state = IsWindowEnabled(ctl->hwnd)?(ctl->stateId == PBS_NORMAL&&ctl->defbutton?PBS_DEFAULTED:ctl->stateId):PBS_DISABLED; + int state = IsWindowEnabled(ctl->hwnd)?(ctl->stateId == PBS_NORMAL && ctl->bIsDefault ? PBS_DEFAULTED : ctl->stateId) : PBS_DISABLED; if (isThemeBackgroundPartiallyTransparent(ctl->hThemeButton, BP_PUSHBUTTON, state)) { drawThemeParentBackground(ctl->hwnd, hdcMem, &rcClient); } drawThemeBackground(ctl->hThemeButton, hdcMem, BP_PUSHBUTTON, state, &rcClient, &rcClient); } else { - UINT uState = DFCS_BUTTONPUSH|((ctl->stateId == PBS_HOT)?DFCS_HOT:0)|((ctl->stateId == PBS_PRESSED)?DFCS_PUSHED:0); - if (ctl->defbutton&&ctl->stateId == PBS_NORMAL) uState |= DLGC_DEFPUSHBUTTON; + 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; DrawFrameControl(hdcMem, &rcClient, DFC_BUTTON, uState); } @@ -334,13 +337,13 @@ static LRESULT CALLBACK MButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, L case WM_KEYUP: if (bct->stateId != PBS_DISABLED && wParam == VK_SPACE) { - if (bct->pushBtn) { - if (bct->pbState) { - bct->pbState = 0; + if (bct->bIsPushBtn) { + if (bct->bIsPushed) { + bct->bIsPushed = 0; bct->stateId = PBS_NORMAL; } else { - bct->pbState = 1; + bct->bIsPushed = 1; bct->stateId = PBS_PRESSED; } InvalidateRect(bct->hwnd, NULL, TRUE); @@ -352,13 +355,13 @@ static LRESULT CALLBACK MButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, L case WM_SYSKEYUP: if (bct->stateId != PBS_DISABLED && bct->cHot && bct->cHot == tolower((int)wParam)) { - if (bct->pushBtn) { - if (bct->pbState) { - bct->pbState = 0; + if (bct->bIsPushBtn) { + if (bct->bIsPushed) { + bct->bIsPushed = 0; bct->stateId = PBS_NORMAL; } else { - bct->pbState = 1; + bct->bIsPushed = 1; bct->stateId = PBS_PRESSED; } InvalidateRect(bct->hwnd, NULL, TRUE); @@ -413,22 +416,23 @@ static LRESULT CALLBACK MButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, L else return 0; case BM_SETCHECK: - if ( !bct->pushBtn) break; + if ( !bct->bIsPushBtn) break; if (wParam == BST_CHECKED) { - bct->pbState = 1; + bct->bIsPushed = 1; bct->stateId = PBS_PRESSED; } else if (wParam == BST_UNCHECKED) { - bct->pbState = 0; + bct->bIsPushed = 0; bct->stateId = PBS_NORMAL; } InvalidateRect(bct->hwnd, NULL, TRUE); break; + case BM_GETCHECK: - if (bct->pushBtn) { - return bct->pbState?BST_CHECKED:BST_UNCHECKED; - } + if (bct->bIsPushBtn) + return bct->bIsPushed ? BST_CHECKED : BST_UNCHECKED; return 0; + case BUTTONSETARROW: // turn arrow on/off if (wParam) { if ( !bct->arrow) { @@ -447,17 +451,23 @@ static LRESULT CALLBACK MButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, L break; case BUTTONSETDEFAULT: - bct->defbutton = (wParam != 0); + bct->bIsDefault = (wParam != 0); InvalidateRect(bct->hwnd, NULL, TRUE); break; case BUTTONSETASPUSHBTN: - bct->pushBtn = (wParam != 0); + bct->bIsPushBtn = (wParam != 0); InvalidateRect(bct->hwnd, NULL, TRUE); break; case BUTTONSETASFLATBTN: - bct->flatBtn = (wParam != 0); + bct->bIsFlat = (wParam != 0); + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + + case BUTTONSETASTHEMEDBTN: + if ((bct->bIsThemed = (wParam != 0)) != 0) + bct->bIsSkinned = false; InvalidateRect(bct->hwnd, NULL, TRUE); break; @@ -539,9 +549,9 @@ static LRESULT CALLBACK MButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, L case WM_LBUTTONUP: { int showClick = 0; - if (bct->pushBtn) { - if (bct->pbState) bct->pbState = 0; - else bct->pbState = 1; + if (bct->bIsPushBtn) { + if (bct->bIsPushed) bct->bIsPushed = 0; + else bct->bIsPushed = 1; } if (bct->stateId != PBS_DISABLED) { // don't change states if disabled if (bct->stateId == PBS_PRESSED) -- cgit v1.2.3