summaryrefslogtreecommitdiff
path: root/plugins/Clist_modern
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-11 08:59:52 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-11 08:59:52 +0000
commitdb3992b55d0616896da4f616dfd09fac6642b292 (patch)
tree8a6624e32dfa68b67e168e333c4f7df4701929ec /plugins/Clist_modern
parent48e3bbf926d0a676d0c5e338c31144ee4209e113 (diff)
- modern toolbar bug emulation
- useless field privateIcon removed; - another useless code removed git-svn-id: http://svn.miranda-ng.org/main/trunk@897 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Clist_modern')
-rw-r--r--plugins/Clist_modern/hdr/modern_defsettings.h1
-rw-r--r--plugins/Clist_modern/m_api/m_skinbutton.h8
-rw-r--r--plugins/Clist_modern/modern_tbbutton.cpp111
-rw-r--r--plugins/Clist_modern/modern_toolbar.cpp23
4 files changed, 38 insertions, 105 deletions
diff --git a/plugins/Clist_modern/hdr/modern_defsettings.h b/plugins/Clist_modern/hdr/modern_defsettings.h
index 7298a8b4e8..c84d99840c 100644
--- a/plugins/Clist_modern/hdr/modern_defsettings.h
+++ b/plugins/Clist_modern/hdr/modern_defsettings.h
@@ -159,7 +159,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define SETTING_TRAYOPTION_DEFAULT 15 //show combined icon
#define SETTING_FADEIN_DEFAULT 0 //"CLUI","FadeInOut"
-#define SETTINGS_SHOWBUTTONBAR_DEFAULT 1 //"CLUI","ShowButtonBar"
//////////////////////////////////////////////////////////////////////////
// ROW SETTINGS
#define SETTING_ROWBORDER_DEFAULT 1 //"CList","RowBorder"
diff --git a/plugins/Clist_modern/m_api/m_skinbutton.h b/plugins/Clist_modern/m_api/m_skinbutton.h
index 86634cb566..943a0d20b6 100644
--- a/plugins/Clist_modern/m_api/m_skinbutton.h
+++ b/plugins/Clist_modern/m_api/m_skinbutton.h
@@ -1,13 +1,15 @@
#include "m_button.h"
+#define MBM_UPDATETRANSPARENTFLAG WM_USER+52
+#define MBM_SETICOLIBHANDLE WM_USER+53
+#define MBM_REFRESHICOLIBICON WM_USER+54
+#define MBM_SETBUTTONSTATE WM_USER+59
+
#define BUTTONSETID WM_USER+55
#define BUTTONDRAWINPARENT WM_USER+56
#define BUTTONSETMARGINS WM_USER+57
#define BUTTONSETSENDONDOWN WM_USER+58
-#define MBM_UPDATETRANSPARENTFLAG WM_USER+52
-#define MBM_SETICOLIBHANDLE WM_USER+53
-#define MBM_REFRESHICOLIBICON WM_USER+54
#define SBF_ALIGN_TL_RIGHT 1
#define SBF_ALIGN_TL_HCENTER 2
diff --git a/plugins/Clist_modern/modern_tbbutton.cpp b/plugins/Clist_modern/modern_tbbutton.cpp
index bb3169294f..6bad5fe972 100644
--- a/plugins/Clist_modern/modern_tbbutton.cpp
+++ b/plugins/Clist_modern/modern_tbbutton.cpp
@@ -18,14 +18,14 @@ void CustomizeToolbar(HWND);
struct TBBUTTONDATA : public MButtonCtrl
{
- char szButtonID[64]; // Unique stringID of button in form Module.Name
- BOOL fSendOnDown; // send event on button pushed
- BOOL fHotMark; // button is hot marked (e.g. current state)
- BOOL fFocused;
- int nFontID; // internal font ID
- HICON hIconPrivate; // icon need to be destroyed
- TCHAR szText[128]; // text on the button
- RECT rcMargins; // margins of inner content
+ char szButtonID[64]; // Unique stringID of button in form Module.Name
+ BOOL fSendOnDown; // send event on button pushed
+ BOOL fHotMark; // button is hot marked (e.g. current state)
+ BOOL fFocused;
+ 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
@@ -164,7 +164,7 @@ static void PaintWorker(TBBUTTONDATA *lpSBData, HDC hdcPaint , POINT *pOffset)
RECT rcTemp = rcClient; //content rect
BYTE bPressed = (lpSBData->stateId == PBS_PRESSED || lpSBData->bIsPushed == TRUE)?1:0;
- HICON hHasIcon = lpSBData->hIcon?lpSBData->hIcon:lpSBData->hIconPrivate?lpSBData->hIconPrivate:NULL;
+ HICON hHasIcon = lpSBData->hIcon ? lpSBData->hIcon : NULL;
BOOL fHasText = (lpSBData->szText[0] != '\0');
/* formatter */
@@ -242,8 +242,6 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam
case WM_DESTROY:
xpt_FreeThemeForWindow(hwndDlg);
WindowList_Remove(hButtonWindowList, hwndDlg);
- if (lpSBData->hIconPrivate)
- DestroyIcon(lpSBData->hIconPrivate);
break; // DONT! fall thru
case WM_SETTEXT:
@@ -257,6 +255,13 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam
lpSBData->nFontID = (int) lParam - 1;
break;
+ case MBM_SETBUTTONSTATE:
+ if (lpSBData->ttbID == (HANDLE)wParam) {
+ lpSBData->bIsPushed = lParam;
+ InvalidateParentRect(lpSBData->hwnd, NULL, TRUE);
+ }
+ break;
+
case BUTTONSETSENDONDOWN:
lpSBData->fSendOnDown = (BOOL) lParam;
break;
@@ -348,10 +353,7 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam
if (lpSBData->stateId != PBS_DISABLED) {
// don't change states if disabled
- if (msg == WM_LBUTTONUP)
- lpSBData->stateId = PBS_HOT;
- else
- lpSBData->stateId = PBS_NORMAL;
+ lpSBData->stateId = PBS_HOT;
InvalidateParentRect(lpSBData->hwnd, NULL, TRUE);
}
if ( !lpSBData->fSendOnDown)
@@ -413,11 +415,6 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam
return 1;
case MBM_SETICOLIBHANDLE:
- if (lpSBData->hIconPrivate) {
- DestroyIcon(lpSBData->hIconPrivate);
- lpSBData->hIconPrivate = 0;
- }
-
lpSBData->hIcolibHandle = (HANDLE)lParam;
if (lpSBData->hIcolibHandle)
lpSBData->hIcon = (HICON)CallService(MS_SKIN2_GETICONBYHANDLE, 0 , (LPARAM) lpSBData->hIcolibHandle);
@@ -426,10 +423,6 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam
return 1;
case MBM_REFRESHICOLIBICON:
- if (lpSBData->hIconPrivate) {
- DestroyIcon(lpSBData->hIconPrivate);
- lpSBData->hIconPrivate = 0;
- }
if (lpSBData->hIcolibHandle)
lpSBData->hIcon = (HICON)CallService(MS_SKIN2_GETICONBYHANDLE, 0 , (LPARAM) lpSBData->hIcolibHandle);
else
@@ -452,78 +445,13 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam
}
}
return 1;
-
- case BM_GETIMAGE:
- if (wParam == IMAGE_ICON) {
- lpSBData->lResult = (LRESULT)(lpSBData->hIconPrivate ? lpSBData->hIconPrivate : lpSBData->hIcon);
- return 1;
- }
- break;
-
- case BM_SETIMAGE:
- if ( !lParam)
- break;
-
- if (wParam == IMAGE_ICON) {
- ICONINFO ii = {0};
- BITMAP bm = {0};
-
- if (lpSBData->hIconPrivate) {
- DestroyIcon(lpSBData->hIconPrivate);
- lpSBData->hIconPrivate = 0;
- }
-
- GetIconInfo((HICON) lParam, &ii);
- GetObject(ii.hbmColor, sizeof(bm), &bm);
- if (bm.bmWidth > 16 || bm.bmHeight > 16) {
- HIMAGELIST hImageList;
- hImageList = ImageList_Create(16, 16, IsWinVerXPPlus() ? ILC_COLOR32 | ILC_MASK : ILC_COLOR16 | ILC_MASK, 1, 0);
- ImageList_AddIcon(hImageList, (HICON) lParam);
- lpSBData->hIconPrivate = ImageList_GetIcon(hImageList, 0, ILD_NORMAL);
- ImageList_RemoveAll(hImageList);
- ImageList_Destroy(hImageList);
- lpSBData->hIcon = 0;
- }
- else {
- lpSBData->hIcon = (HICON) lParam;
- lpSBData->hIconPrivate = NULL;
- }
-
- DeleteObject(ii.hbmMask);
- DeleteObject(ii.hbmColor);
- InvalidateParentRect(lpSBData->hwnd, NULL, TRUE);
- lpSBData->lResult = 0;
- return 1;
- }
- if (wParam == IMAGE_BITMAP)
- {
- if (lpSBData->hIconPrivate)
- DestroyIcon(lpSBData->hIconPrivate);
- lpSBData->hIcon = lpSBData->hIconPrivate = NULL;
- InvalidateParentRect(lpSBData->hwnd, NULL, TRUE);
- }
- break;
}
return 0;
}
-static BOOL CALLBACK BroadcastEnumChildProc(HWND hwndChild, LPARAM lParam)
-{
- MSG * pMsg=(MSG*)lParam;
- SendNotifyMessage( hwndChild, pMsg->message, pMsg->wParam, pMsg->lParam );
- EnumChildWindows( hwndChild, BroadcastEnumChildProc, lParam );
- return TRUE;
-}
-
-static LRESULT BroadCastMessageToChild(HWND hwnd, int message, WPARAM wParam, LPARAM lParam )
+void SetButtonPressed(HANDLE hButton, int state)
{
- MSG msg={0};
- msg.hwnd=hwnd;
- msg.lParam=lParam;
- msg.wParam=wParam;
- msg.message=message;
- EnumChildWindows(hwnd, BroadcastEnumChildProc, (LPARAM) &msg);
- return 1;
+ WindowList_BroadcastAsync(hButtonWindowList, MBM_SETBUTTONSTATE, (WPARAM)hButton, state);
}
void MakeButtonSkinned(HWND hWnd)
@@ -552,6 +480,7 @@ static void CustomizeButton(HANDLE ttbid, HWND hWnd, LPARAM lParam)
TBBUTTONDATA* p = (TBBUTTONDATA*)GetWindowLongPtr(hWnd, 0);
sprintf(p->szButtonID, "Toolbar.%p", p->hwnd);
+ p->ttbID = ttbid;
SendMessage(hWnd, MBM_UPDATETRANSPARENTFLAG, 0, 2);
}
diff --git a/plugins/Clist_modern/modern_toolbar.cpp b/plugins/Clist_modern/modern_toolbar.cpp
index 079946d9bf..10a1bda377 100644
--- a/plugins/Clist_modern/modern_toolbar.cpp
+++ b/plugins/Clist_modern/modern_toolbar.cpp
@@ -50,6 +50,8 @@ static BTNS[] =
{ "Minimize","Minimize", "CList/ShowHide", "Minimize", NULL, 180 , IDI_RESETVIEW, IDI_RESETVIEW, FALSE }
};
+void SetButtonPressed(HANDLE hButton, int state);
+
static int Modern_InitButtons(WPARAM, LPARAM)
{
TTBButton tbb = { 0 };
@@ -81,10 +83,9 @@ static int Modern_InitButtons(WPARAM, LPARAM)
BTNS[i].hButton = TopToolbar_AddButton(&tbb);
}
- CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)BTNS[3].hButton, db_get_b(NULL, "CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT) ? TTBST_PUSHED : TTBST_RELEASED);
- CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)BTNS[6].hButton, db_get_b(NULL, "CList", "UseGroups", SETTING_USEGROUPS_DEFAULT) ? TTBST_PUSHED : TTBST_RELEASED);
- CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)BTNS[7].hButton, db_get_b(NULL, "Skin", "UseSound", SETTING_ENABLESOUNDS_DEFAULT) ? TTBST_PUSHED : TTBST_RELEASED);
-
+ SetButtonPressed(BTNS[3].hButton, db_get_b(NULL, "CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT));
+ SetButtonPressed(BTNS[6].hButton, db_get_b(NULL, "CList", "UseGroups", SETTING_USEGROUPS_DEFAULT));
+ SetButtonPressed(BTNS[7].hButton, db_get_b(NULL, "Skin", "UseSound", SETTING_ENABLESOUNDS_DEFAULT));
return 1;
}
@@ -125,13 +126,13 @@ static int ehhToolBarSettingsChanged(WPARAM wParam, LPARAM lParam)
if (!mir_strcmp(cws->szModule,"CList")) {
if (!mir_strcmp(cws->szSetting,"HideOffline"))
- CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)BTNS[3].hButton, cws->value.bVal ? TTBST_PUSHED : TTBST_RELEASED);
+ SetButtonPressed(BTNS[3].hButton, cws->value.bVal);
else if (!mir_strcmp(cws->szSetting,"UseGroups"))
- CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)BTNS[6].hButton, cws->value.bVal ? TTBST_PUSHED : TTBST_RELEASED);
+ SetButtonPressed(BTNS[6].hButton, cws->value.bVal);
}
else if (!mir_strcmp(cws->szModule,"Skin")) {
if (!mir_strcmp(cws->szSetting,"UseSound"))
- CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)BTNS[7].hButton, cws->value.bVal ? TTBST_PUSHED : TTBST_RELEASED);
+ SetButtonPressed(BTNS[7].hButton, cws->value.bVal);
}
return 0;
@@ -336,7 +337,8 @@ static void CopySettings(const char* to, const char* from)
HRESULT ToolbarLoadModule()
{
- if ( db_get_b(NULL, "CLUI", "ShowButtonBar", -1) != -1) {
+ BYTE bOldSetting = db_get_b(NULL, "CLUI", "ShowButtonBar", 255);
+ if (bOldSetting != 255) {
CopySettings("BUTTWIDTH", "option_Bar0_BtnWidth");
CopySettings("BUTTHEIGHT", "option_Bar0_BtnHeight");
CopySettings("BUTTGAP", "option_Bar0_BtnSpace");
@@ -347,8 +349,9 @@ HRESULT ToolbarLoadModule()
CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)"ModernToolBar");
- if (IDYES == MessageBox(NULL, TranslateTS(szWarning), TranslateT("Toolbar upgrade"), MB_ICONQUESTION | MB_YESNO))
- CallService(MS_UTILS_OPENURL, 0, (LPARAM)szUrl);
+ if (bOldSetting == 1)
+ if (IDYES == MessageBox(NULL, TranslateTS(szWarning), TranslateT("Toolbar upgrade"), MB_ICONQUESTION | MB_YESNO))
+ CallService(MS_UTILS_OPENURL, 0, (LPARAM)szUrl);
}
ehhToolBarBackgroundSettingsChanged(0,0);