summaryrefslogtreecommitdiff
path: root/plugins/Clist_modern
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-07 17:47:17 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-07 17:47:17 +0000
commitc1852dd801390e08fc6372501556270a20c8439e (patch)
tree833f3486a3755adf8892b511322e152714127d2d /plugins/Clist_modern
parent26aed6878b3c891b618eb83469de75a623e80361 (diff)
- clist modern toolbar removed
git-svn-id: http://svn.miranda-ng.org/main/trunk@817 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Clist_modern')
-rw-r--r--plugins/Clist_modern/hdr/modern_commonheaders.h2
-rw-r--r--plugins/Clist_modern/hdr/modern_commonprototypes.h9
-rw-r--r--plugins/Clist_modern/hdr/modern_global_structure.h1
-rw-r--r--plugins/Clist_modern/init.cpp1
-rw-r--r--plugins/Clist_modern/modern_clc.cpp279
-rw-r--r--plugins/Clist_modern/modern_clistmod.cpp3
-rw-r--r--plugins/Clist_modern/modern_clui.cpp43
-rw-r--r--plugins/Clist_modern/modern_tbbutton.cpp953
-rw-r--r--plugins/Clist_modern/modern_toolbar.cpp1292
-rw-r--r--plugins/Clist_modern/resource.rc32
10 files changed, 556 insertions, 2059 deletions
diff --git a/plugins/Clist_modern/hdr/modern_commonheaders.h b/plugins/Clist_modern/hdr/modern_commonheaders.h
index 6b32f8e74b..efb7b572a9 100644
--- a/plugins/Clist_modern/hdr/modern_commonheaders.h
+++ b/plugins/Clist_modern/hdr/modern_commonheaders.h
@@ -131,8 +131,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "m_smileyadd.h"
#include "../m_api/m_xpTheme.h"
-#include "m_toolbar.h"
-
#include "../resource.h"
#include "modern_layered_window_engine.h"
diff --git a/plugins/Clist_modern/hdr/modern_commonprototypes.h b/plugins/Clist_modern/hdr/modern_commonprototypes.h
index 58cd28c7a9..2d0c7b5eb3 100644
--- a/plugins/Clist_modern/hdr/modern_commonprototypes.h
+++ b/plugins/Clist_modern/hdr/modern_commonprototypes.h
@@ -271,15 +271,16 @@ void gtaRenewText(HANDLE hContact);
int ExtraImage_ExtraIDToColumnNum(int extra);
int ExtraImage_ColumnNumToExtraID(int column);
-int LoadSkinButtonModule();
-void UninitSkinHotKeys();
-void GetDefaultFontSetting(int i,LOGFONTA *lf,COLORREF *colour);
-int CLUI_OnSkinLoad(WPARAM wParam, LPARAM lParam);
+int LoadSkinButtonModule();
+void UninitSkinHotKeys();
+void GetDefaultFontSetting(int i,LOGFONTA *lf,COLORREF *colour);
+int CLUI_OnSkinLoad(WPARAM wParam, LPARAM lParam);
HRESULT CluiLoadModule();
HRESULT PreLoadContactListModule();
HRESULT ClcLoadModule();
HRESULT ToolbarLoadModule();
HRESULT ToolbarButtonLoadModule();
+void CustomizeButton(HWND);
// INTERFACES
diff --git a/plugins/Clist_modern/hdr/modern_global_structure.h b/plugins/Clist_modern/hdr/modern_global_structure.h
index 3ee93c7385..09036459ec 100644
--- a/plugins/Clist_modern/hdr/modern_global_structure.h
+++ b/plugins/Clist_modern/hdr/modern_global_structure.h
@@ -82,7 +82,6 @@ typedef struct tagCLUIDATA
HANDLE hEventPreBuildSubGroupMenu;
HANDLE hEventStatusBarShowToolTip;
HANDLE hEventStatusBarHideToolTip;
- HANDLE hEventToolBarModuleLoaded;
HANDLE hEventSkinServicesCreated;
int nGapBetweenTitlebar;
diff --git a/plugins/Clist_modern/init.cpp b/plugins/Clist_modern/init.cpp
index 50674dffa4..c1a55fc300 100644
--- a/plugins/Clist_modern/init.cpp
+++ b/plugins/Clist_modern/init.cpp
@@ -240,7 +240,6 @@ static HRESULT CreateHookableEvents()
g_CluiData.hEventPreBuildSubGroupMenu = CreateHookableEvent(ME_CLIST_PREBUILDSUBGROUPMENU);
g_CluiData.hEventStatusBarShowToolTip = CreateHookableEvent(ME_CLIST_FRAMES_SB_SHOW_TOOLTIP);
g_CluiData.hEventStatusBarHideToolTip = CreateHookableEvent(ME_CLIST_FRAMES_SB_HIDE_TOOLTIP);
- g_CluiData.hEventToolBarModuleLoaded = CreateHookableEvent(ME_TB_MODULELOADED);
g_CluiData.hEventSkinServicesCreated = CreateHookableEvent(ME_SKIN_SERVICESCREATED);
return S_OK;
}
diff --git a/plugins/Clist_modern/modern_clc.cpp b/plugins/Clist_modern/modern_clc.cpp
index 0fde86687d..3967d9e465 100644
--- a/plugins/Clist_modern/modern_clc.cpp
+++ b/plugins/Clist_modern/modern_clc.cpp
@@ -134,7 +134,6 @@ static int clcHookModulesLoaded(WPARAM wParam,LPARAM lParam)
CallService(MS_BACKGROUNDCONFIG_REGISTER,(WPARAM)"StatusBar Background/StatusBar",0);
CallService(MS_BACKGROUNDCONFIG_REGISTER,(WPARAM)"Frames TitleBar BackGround/FrameTitleBar",0);
-
HookEvent(ME_BACKGROUNDCONFIG_CHANGED,clcHookBkgndConfigChanged);
HookEvent(ME_BACKGROUNDCONFIG_CHANGED,BgStatusBarChange);
HookEvent(ME_BACKGROUNDCONFIG_CHANGED,OnFrameTitleBarBackgroundChange);
@@ -299,7 +298,6 @@ static int clcExitDragToScroll()
return 1;
}
-
static int clcProceedDragToScroll(HWND hwnd, int Y)
{
int pos,dy;
@@ -803,15 +801,13 @@ void clcSetDelayTimer( UINT_PTR uIDEvent, HWND hwnd, int nDelay)
static LRESULT clcOnTimer(struct ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(wParam)
- {
+ switch(wParam) {
case TIMERID_INVALIDATE_FULL:
- {
- KillTimer(hwnd,TIMERID_INVALIDATE_FULL);
- pcli->pfnRecalcScrollBar(hwnd,dat);
- pcli->pfnInvalidateRect(hwnd,NULL,0);
- return corecli.pfnContactListControlWndProc(hwnd, msg, wParam, lParam);
- }
+ KillTimer(hwnd,TIMERID_INVALIDATE_FULL);
+ pcli->pfnRecalcScrollBar(hwnd,dat);
+ pcli->pfnInvalidateRect(hwnd,NULL,0);
+ return corecli.pfnContactListControlWndProc(hwnd, msg, wParam, lParam);
+
case TIMERID_INVALIDATE:
{
time_t cur_time = (time(NULL)/60);
@@ -837,8 +833,7 @@ static LRESULT clcOnTimer(struct ClcData *dat, HWND hwnd, UINT msg, WPARAM wPara
dat->NeedResort = 1;
pcli->pfnSortCLC(hwnd,dat,1);
cliRecalcScrollBar(hwnd,dat);
- if (ht)
- {
+ if (ht) {
int i=0;
struct ClcContact *contact;
struct ClcGroup *group;
@@ -852,19 +847,17 @@ static LRESULT clcOnTimer(struct ClcData *dat, HWND hwnd, UINT msg, WPARAM wPara
return corecli.pfnContactListControlWndProc(hwnd, msg, wParam, lParam);
}
case TIMERID_DELAYEDRESORTCLC:
- {
- TRACE("Do sort on Timer\n");
- KillTimer(hwnd,TIMERID_DELAYEDRESORTCLC);
- pcli->pfnSortCLC(hwnd,dat,1);
- pcli->pfnInvalidateRect(hwnd,NULL,FALSE);
- return 0;
- }
+ TRACE("Do sort on Timer\n");
+ KillTimer(hwnd,TIMERID_DELAYEDRESORTCLC);
+ pcli->pfnSortCLC(hwnd,dat,1);
+ pcli->pfnInvalidateRect(hwnd,NULL,FALSE);
+ return 0;
+
case TIMERID_RECALCSCROLLBAR:
- {
- KillTimer(hwnd,TIMERID_RECALCSCROLLBAR);
- pcli->pfnRecalcScrollBar(hwnd,dat);
- return 0;
- }
+ KillTimer(hwnd,TIMERID_RECALCSCROLLBAR);
+ pcli->pfnRecalcScrollBar(hwnd,dat);
+ return 0;
+
default:
return corecli.pfnContactListControlWndProc(hwnd, msg, wParam, lParam);
}
@@ -1107,23 +1100,18 @@ static LRESULT clcOnMouseMove(struct ClcData *dat, HWND hwnd, UINT msg, WPARAM w
if (window != hwnd) isOutside = TRUE;
}
- if (hitcontact != NULL)
- {
- int x,y,xm,ym;
- x = (short)LOWORD(lParam);
- y = (short)HIWORD(lParam);
- xm = GetSystemMetrics(SM_CXDOUBLECLK);
- ym = GetSystemMetrics(SM_CYDOUBLECLK);
- if (abs(HitPoint.x-x)>xm || abs(HitPoint.y-y)>ym)
- {
- if (fMouseUpped)
- {
+ if (hitcontact != NULL) {
+ int x = (short)LOWORD(lParam);
+ int y = (short)HIWORD(lParam);
+ int xm = GetSystemMetrics(SM_CXDOUBLECLK);
+ int ym = GetSystemMetrics(SM_CYDOUBLECLK);
+ if ( abs(HitPoint.x-x) > xm || abs(HitPoint.y-y) > ym) {
+ if (fMouseUpped) {
KillTimer(hwnd,TIMERID_SUBEXPAND);
CLUI_SafeSetTimer(hwnd,TIMERID_SUBEXPAND,0,NULL);
fMouseUpped = FALSE;
}
- else
- {
+ else {
KillTimer(hwnd,TIMERID_SUBEXPAND);
hitcontact = NULL;
fMouseUpped = FALSE;
@@ -1131,9 +1119,7 @@ static LRESULT clcOnMouseMove(struct ClcData *dat, HWND hwnd, UINT msg, WPARAM w
}
}
-
- if (dat->iDragItem == -1)
- {
+ if (dat->iDragItem == -1) {
DWORD flag = 0;
int iOldHotTrack = dat->iHotTrack;
@@ -1145,8 +1131,7 @@ static LRESULT clcOnMouseMove(struct ClcData *dat, HWND hwnd, UINT msg, WPARAM w
if (flag&CLCHT_NOWHERE)
dat->iHotTrack = -1;
- if (iOldHotTrack != dat->iHotTrack || isOutside)
- {
+ if (iOldHotTrack != dat->iHotTrack || isOutside) {
if (iOldHotTrack == -1 && !isOutside)
SetCapture(hwnd);
@@ -1172,28 +1157,23 @@ static LRESULT clcOnMouseMove(struct ClcData *dat, HWND hwnd, UINT msg, WPARAM w
}
return 0;
}
- if ((dat->dragStage&DRAGSTAGEM_STAGE) == DRAGSTAGE_NOTMOVED && !(dat->exStyle&CLS_EX_DISABLEDRAGDROP))
- {
+
+ if ((dat->dragStage&DRAGSTAGEM_STAGE) == DRAGSTAGE_NOTMOVED && !(dat->exStyle&CLS_EX_DISABLEDRAGDROP))
if (abs((short)LOWORD(lParam)-dat->ptDragStart.x) >= GetSystemMetrics(SM_CXDRAG) || abs((short)HIWORD(lParam)-dat->ptDragStart.y) >= GetSystemMetrics(SM_CYDRAG))
dat->dragStage = (dat->dragStage&~DRAGSTAGEM_STAGE)|DRAGSTAGE_ACTIVE;
- }
- if ((dat->dragStage&DRAGSTAGEM_STAGE) == DRAGSTAGE_ACTIVE)
- {
- HCURSOR hNewCursor;
+ if ((dat->dragStage&DRAGSTAGEM_STAGE) == DRAGSTAGE_ACTIVE) {
RECT clRect;
- POINT pt;
- int target;
-
GetClientRect(hwnd,&clRect);
+
+ POINT pt;
pt.x = (short)LOWORD(lParam); pt.y = (short)HIWORD(lParam);
- hNewCursor = LoadCursor(NULL, IDC_NO);
+ HCURSOR hNewCursor = LoadCursor(NULL, IDC_NO);
CLUI__cliInvalidateRect(hwnd,NULL,FALSE);
if (dat->dragAutoScrolling)
{KillTimer(hwnd,TIMERID_DRAGAUTOSCROLL); dat->dragAutoScrolling = 0;}
- target = GetDropTargetInformation(hwnd,dat,pt);
- if (dat->dragStage&DRAGSTAGEF_OUTSIDE && target != DROPTARGET_OUTSIDE)
- {
+ int target = GetDropTargetInformation(hwnd,dat,pt);
+ if (dat->dragStage&DRAGSTAGEF_OUTSIDE && target != DROPTARGET_OUTSIDE) {
NMCLISTCONTROL nm;
struct ClcContact *contact;
cliGetRowByIndex(dat,dat->iDragItem,&contact,NULL);
@@ -1205,118 +1185,119 @@ static LRESULT clcOnMouseMove(struct ClcData *dat, HWND hwnd, UINT msg, WPARAM w
SendMessage(GetParent(hwnd),WM_NOTIFY,0,(LPARAM)&nm);
dat->dragStage &= ~DRAGSTAGEF_OUTSIDE;
}
- switch(target)
- {
- case DROPTARGET_ONSELF:
- break;
+
+ switch(target) {
+ case DROPTARGET_ONSELF:
+ break;
- case DROPTARGET_ONCONTACT:
- if (ServiceExists(MS_MC_ADDTOMETA))
+ case DROPTARGET_ONCONTACT:
+ if (ServiceExists(MS_MC_ADDTOMETA))
+ {
+ struct ClcContact *contSour;
+ cliGetRowByIndex(dat,dat->iDragItem,&contSour,NULL);
+ if (contSour->type == CLCIT_CONTACT && g_szMetaModuleName && mir_strcmp(contSour->proto,g_szMetaModuleName))
{
- struct ClcContact *contSour;
- cliGetRowByIndex(dat,dat->iDragItem,&contSour,NULL);
- if (contSour->type == CLCIT_CONTACT && g_szMetaModuleName && mir_strcmp(contSour->proto,g_szMetaModuleName))
- {
- if ( !contSour->isSubcontact)
- hNewCursor = LoadCursor(GetModuleHandle(NULL), MAKEINTRESOURCE(IDC_DROPUSER)); /// Add to meta
- else
- hNewCursor = LoadCursor(g_hInst, MAKEINTRESOURCE(IDC_DROPMETA));
- }
-
+ if ( !contSour->isSubcontact)
+ hNewCursor = LoadCursor(GetModuleHandle(NULL), MAKEINTRESOURCE(IDC_DROPUSER)); /// Add to meta
+ else
+ hNewCursor = LoadCursor(g_hInst, MAKEINTRESOURCE(IDC_DROPMETA));
}
- break;
+
+ }
+ break;
- case DROPTARGET_ONMETACONTACT:
- if (ServiceExists(MS_MC_ADDTOMETA))
+ case DROPTARGET_ONMETACONTACT:
+ if (ServiceExists(MS_MC_ADDTOMETA))
+ {
+ struct ClcContact *contSour,*contDest;
+ cliGetRowByIndex(dat,dat->selection,&contDest,NULL);
+ cliGetRowByIndex(dat,dat->iDragItem,&contSour,NULL);
+ if (contSour->type == CLCIT_CONTACT && g_szMetaModuleName && mir_strcmp(contSour->proto,g_szMetaModuleName))
{
- struct ClcContact *contSour,*contDest;
- cliGetRowByIndex(dat,dat->selection,&contDest,NULL);
- cliGetRowByIndex(dat,dat->iDragItem,&contSour,NULL);
- if (contSour->type == CLCIT_CONTACT && g_szMetaModuleName && mir_strcmp(contSour->proto,g_szMetaModuleName))
- {
- if ( !contSour->isSubcontact)
- hNewCursor = LoadCursor(GetModuleHandle(NULL), MAKEINTRESOURCE(IDC_DROPUSER)); /// Add to meta
- else
- if (contSour->subcontacts == contDest)
- hNewCursor = LoadCursor(g_hInst, MAKEINTRESOURCE(IDC_DEFAULTSUB)); ///MakeDefault
- else
- hNewCursor = LoadCursor(g_hInst, MAKEINTRESOURCE(IDC_REGROUP));
- }
+ if ( !contSour->isSubcontact)
+ hNewCursor = LoadCursor(GetModuleHandle(NULL), MAKEINTRESOURCE(IDC_DROPUSER)); /// Add to meta
+ else
+ if (contSour->subcontacts == contDest)
+ hNewCursor = LoadCursor(g_hInst, MAKEINTRESOURCE(IDC_DEFAULTSUB)); ///MakeDefault
+ else
+ hNewCursor = LoadCursor(g_hInst, MAKEINTRESOURCE(IDC_REGROUP));
}
- break;
- case DROPTARGET_ONSUBCONTACT:
- if (ServiceExists(MS_MC_ADDTOMETA))
+ }
+ break;
+ case DROPTARGET_ONSUBCONTACT:
+ if (ServiceExists(MS_MC_ADDTOMETA))
+ {
+ struct ClcContact *contSour,*contDest;
+ cliGetRowByIndex(dat,dat->selection,&contDest,NULL);
+ cliGetRowByIndex(dat,dat->iDragItem,&contSour,NULL);
+ if (contSour->type == CLCIT_CONTACT && g_szMetaModuleName && mir_strcmp(contSour->proto,g_szMetaModuleName))
{
- struct ClcContact *contSour,*contDest;
- cliGetRowByIndex(dat,dat->selection,&contDest,NULL);
- cliGetRowByIndex(dat,dat->iDragItem,&contSour,NULL);
- if (contSour->type == CLCIT_CONTACT && g_szMetaModuleName && mir_strcmp(contSour->proto,g_szMetaModuleName))
- {
- if ( !contSour->isSubcontact)
- hNewCursor = LoadCursor(GetModuleHandle(NULL), MAKEINTRESOURCE(IDC_DROPUSER)); /// Add to meta
- else
- if (contDest->subcontacts == contSour->subcontacts)
- break;
- else
- hNewCursor = LoadCursor(g_hInst, MAKEINTRESOURCE(IDC_REGROUP));
- }
+ if ( !contSour->isSubcontact)
+ hNewCursor = LoadCursor(GetModuleHandle(NULL), MAKEINTRESOURCE(IDC_DROPUSER)); /// Add to meta
+ else
+ if (contDest->subcontacts == contSour->subcontacts)
+ break;
+ else
+ hNewCursor = LoadCursor(g_hInst, MAKEINTRESOURCE(IDC_REGROUP));
}
- break;
+ }
+ break;
- case DROPTARGET_ONGROUP:
- hNewCursor = LoadCursor(GetModuleHandle(NULL), MAKEINTRESOURCE(IDC_DROPUSER));
- break;
+ case DROPTARGET_ONGROUP:
+ hNewCursor = LoadCursor(GetModuleHandle(NULL), MAKEINTRESOURCE(IDC_DROPUSER));
+ break;
- case DROPTARGET_INSERTION:
- hNewCursor = LoadCursor(GetModuleHandle(NULL), MAKEINTRESOURCE(IDC_DROP));
- break;
+ case DROPTARGET_INSERTION:
+ hNewCursor = LoadCursor(GetModuleHandle(NULL), MAKEINTRESOURCE(IDC_DROP));
+ break;
- case DROPTARGET_OUTSIDE:
- {
- NMCLISTCONTROL nm;
- struct ClcContact *contact;
+ case DROPTARGET_OUTSIDE:
+ {
+ NMCLISTCONTROL nm;
+ struct ClcContact *contact;
- if (pt.x >= 0 && pt.x < clRect.right && ((pt.y < 0 && pt.y>-dat->dragAutoScrollHeight) || (pt.y >= clRect.bottom && pt.y < clRect.bottom+dat->dragAutoScrollHeight)))
+ if (pt.x >= 0 && pt.x < clRect.right && ((pt.y < 0 && pt.y>-dat->dragAutoScrollHeight) || (pt.y >= clRect.bottom && pt.y < clRect.bottom+dat->dragAutoScrollHeight)))
+ {
+ if ( !dat->dragAutoScrolling)
{
- if ( !dat->dragAutoScrolling)
- {
- if (pt.y < 0) dat->dragAutoScrolling = -1;
- else dat->dragAutoScrolling = 1;
- CLUI_SafeSetTimer(hwnd,TIMERID_DRAGAUTOSCROLL,dat->scrollTime,NULL);
- }
- SendMessage(hwnd,WM_TIMER,TIMERID_DRAGAUTOSCROLL,0);
+ if (pt.y < 0) dat->dragAutoScrolling = -1;
+ else dat->dragAutoScrolling = 1;
+ CLUI_SafeSetTimer(hwnd,TIMERID_DRAGAUTOSCROLL,dat->scrollTime,NULL);
}
-
- dat->dragStage |= DRAGSTAGEF_OUTSIDE;
- cliGetRowByIndex(dat,dat->iDragItem,&contact,NULL);
- nm.hdr.code = CLN_DRAGGING;
- nm.hdr.hwndFrom = hwnd;
- nm.hdr.idFrom = GetDlgCtrlID(hwnd);
- nm.flags = 0;
- nm.hItem = ContactToItemHandle(contact,&nm.flags);
- nm.pt = pt;
- if (SendMessage(GetParent(hwnd),WM_NOTIFY,0,(LPARAM)&nm))
- return 0;
- break;
+ SendMessage(hwnd,WM_TIMER,TIMERID_DRAGAUTOSCROLL,0);
}
- default:
- {
- struct ClcGroup *group = NULL;
- cliGetRowByIndex(dat,dat->iDragItem,NULL,&group);
- if (group && group->parent)
- {
- struct ClcContact *contSour;
- cliGetRowByIndex(dat,dat->iDragItem,&contSour,NULL);
- if ( !contSour->isSubcontact)
- hNewCursor = LoadCursor(GetModuleHandle(NULL), MAKEINTRESOURCE(IDC_DROPUSER));
- }
- break;
+
+ dat->dragStage |= DRAGSTAGEF_OUTSIDE;
+ cliGetRowByIndex(dat,dat->iDragItem,&contact,NULL);
+ nm.hdr.code = CLN_DRAGGING;
+ nm.hdr.hwndFrom = hwnd;
+ nm.hdr.idFrom = GetDlgCtrlID(hwnd);
+ nm.flags = 0;
+ nm.hItem = ContactToItemHandle(contact,&nm.flags);
+ nm.pt = pt;
+ if (SendMessage(GetParent(hwnd),WM_NOTIFY,0,(LPARAM)&nm))
+ return 0;
+ break;
+ }
+ default:
+ {
+ struct ClcGroup *group = NULL;
+ cliGetRowByIndex(dat,dat->iDragItem,NULL,&group);
+ if (group && group->parent)
+ {
+ struct ClcContact *contSour;
+ cliGetRowByIndex(dat,dat->iDragItem,&contSour,NULL);
+ if ( !contSour->isSubcontact)
+ hNewCursor = LoadCursor(GetModuleHandle(NULL), MAKEINTRESOURCE(IDC_DROPUSER));
}
+ break;
+ }
}
SetCursor(hNewCursor);
}
return 0;
}
+
static LRESULT clcOnLButtonUp(struct ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (clcExitDragToScroll())
@@ -1324,8 +1305,7 @@ static LRESULT clcOnLButtonUp(struct ClcData *dat, HWND hwnd, UINT msg, WPARAM w
fMouseUpped = TRUE;
- if (hitcontact != NULL && dat->expandMeta)
- {
+ if (hitcontact != NULL && dat->expandMeta) {
BYTE doubleClickExpand = db_get_b(NULL,"CLC","MetaDoubleClick",SETTING_METAAVOIDDBLCLICK_DEFAULT);
CLUI_SafeSetTimer(hwnd,TIMERID_SUBEXPAND,GetDoubleClickTime()*doubleClickExpand,NULL);
}
@@ -1333,7 +1313,7 @@ static LRESULT clcOnLButtonUp(struct ClcData *dat, HWND hwnd, UINT msg, WPARAM w
ReleaseCapture();
if (dat->iDragItem == -1) return 0;
SetCursor((HCURSOR)GetClassLongPtr(hwnd,GCLP_HCURSOR));
- if (dat->exStyle&CLS_EX_TRACKSELECT)
+ if (dat->exStyle & CLS_EX_TRACKSELECT)
{
DWORD flags;
dat->iHotTrack = cliHitTest(hwnd,dat,(short)LOWORD(lParam),(short)HIWORD(lParam),NULL,NULL,&flags);
@@ -1644,6 +1624,7 @@ static LRESULT clcOnIntmGroupChanged(struct ClcData *dat, HWND hwnd, UINT msg, W
SetTimer(hwnd,TIMERID_REBUILDAFTER,1,NULL);
return 0;
}
+
static LRESULT clcOnIntmIconChanged(struct ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
struct ClcContact *contact = NULL;
diff --git a/plugins/Clist_modern/modern_clistmod.cpp b/plugins/Clist_modern/modern_clistmod.cpp
index f46253f386..ffbddbb93c 100644
--- a/plugins/Clist_modern/modern_clistmod.cpp
+++ b/plugins/Clist_modern/modern_clistmod.cpp
@@ -45,7 +45,6 @@ void GroupMenus_Init(void);
int AddMainMenuItem(WPARAM wParam,LPARAM lParam);
int AddContactMenuItem(WPARAM wParam,LPARAM lParam);
void UninitCListEvents(void);
-int ContactSettingChanged(WPARAM wParam,LPARAM lParam);
int ContactAdded(WPARAM wParam,LPARAM lParam);
int GetContactDisplayName(WPARAM wParam,LPARAM lParam);
int CListOptInit(WPARAM wParam,LPARAM lParam);
@@ -257,9 +256,7 @@ HRESULT PreLoadContactListModule()
//initialize firstly hooks
//clist interface is empty yet so handles should check
- HookEvent(ME_DB_CONTACT_SETTINGCHANGED, ContactSettingChanged);
CreateServiceFunction(MS_CLIST_GETCONTACTICON, GetContactIcon);
-
return S_OK;
}
diff --git a/plugins/Clist_modern/modern_clui.cpp b/plugins/Clist_modern/modern_clui.cpp
index 4aeaa2f3af..4bc4bb922c 100644
--- a/plugins/Clist_modern/modern_clui.cpp
+++ b/plugins/Clist_modern/modern_clui.cpp
@@ -37,7 +37,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "hdr/modern_clcpaint.h"
#include "hdr/modern_sync.h"
-
+int ContactSettingChanged(WPARAM, LPARAM);
HRESULT (WINAPI *g_proc_DWMEnableBlurBehindWindow)(HWND hWnd, DWM_BLURBEHIND *pBlurBehind);
BOOL CALLBACK ProcessCLUIFrameInternalMsg(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, LRESULT& result );
@@ -349,6 +349,7 @@ HRESULT CLUI::RegisterAvatarMenu()
return S_OK;
}
+
HRESULT CLUI::CreateCLCWindow(const HWND hwndClui)
{
ClcWnd() = CreateWindow(CLISTCONTROL_CLASS,_T(""),
@@ -416,7 +417,6 @@ HRESULT CLUI::FillAlphaChannel( HDC hDC, RECT * prcParent, BYTE bAlpha)
HRESULT CLUI::CreateCLC()
{
-
INIT < CLISTFrame> Frame;
Frame.hWnd = ClcWnd();
@@ -447,6 +447,7 @@ HRESULT CLUI::CreateCLC()
nLastRequiredHeight = 0;
mutex_bDisableAutoUpdate = 0;
+ HookEvent(ME_DB_CONTACT_SETTINGCHANGED, ContactSettingChanged);
HookEvent(ME_DB_CONTACT_SETTINGCHANGED,CLUI::OnEvent_DBSettingChanging);
return S_OK;
@@ -2030,6 +2031,7 @@ LRESULT CLUI::OnSizingMoving( UINT msg, WPARAM wParam, LPARAM lParam )
case WM_SIZING:
return DefWindowProc(m_hWnd, msg, wParam, lParam);;
+
case WM_MOVE:
{
RECT rc;
@@ -2123,8 +2125,7 @@ LRESULT CLUI::OnSizingMoving( UINT msg, WPARAM wParam, LPARAM lParam )
}
case WM_WINDOWPOSCHANGING:
{
- WINDOWPOS * wp;
- wp = (WINDOWPOS *)lParam;
+ WINDOWPOS *wp = (WINDOWPOS *)lParam;
if (wp->flags&SWP_HIDEWINDOW && mutex_bAnimationInProgress)
return 0;
if (g_CluiData.fOnDesktop)
@@ -2155,23 +2156,25 @@ LRESULT CLUI::OnSyncCall( UINT /*msg*/, WPARAM wParam, LPARAM /*lParam*/ )
LRESULT CLUI::OnUpdate( UINT /*msg*/, WPARAM /*wParam*/, LPARAM /*lParam*/ )
{
- if ( g_flag_bPostWasCanceled ) return FALSE;
+ if ( g_flag_bPostWasCanceled )
+ return FALSE;
return ske_ValidateFrameImageProc( NULL );
}
+
LRESULT CLUI::OnInitMenu( UINT /*msg*/, WPARAM /*wParam*/, LPARAM /*lParam*/ )
{
- if ( !CLUI::IsMainMenuInited())
- {
- if ( ServiceExists( MS_CLIST_MENUBUILDMAIN )) CallService( MS_CLIST_MENUBUILDMAIN, 0, 0 );
+ if ( !CLUI::IsMainMenuInited()) {
+ if ( ServiceExists( MS_CLIST_MENUBUILDMAIN ))
+ CallService( MS_CLIST_MENUBUILDMAIN, 0, 0 );
CLUI::m_fMainMenuInited = TRUE;
}
return FALSE;
}
+
LRESULT CLUI::OnNcPaint( UINT msg, WPARAM wParam, LPARAM lParam )
{
int lRes = DefWindowProc( m_hWnd, msg, wParam, lParam );
- if ( !g_CluiData.fLayered && db_get_b( NULL,"CLUI","ShowMainMenu",SETTING_SHOWMAINMENU_DEFAULT ))
- {
+ if ( !g_CluiData.fLayered && db_get_b( NULL,"CLUI","ShowMainMenu",SETTING_SHOWMAINMENU_DEFAULT )) {
HDC hdc = NULL;
if ( msg == WM_PRINT ) hdc = (HDC)wParam;
if ( !hdc ) hdc = GetWindowDC( m_hWnd );
@@ -2180,10 +2183,12 @@ LRESULT CLUI::OnNcPaint( UINT msg, WPARAM wParam, LPARAM lParam )
}
return lRes;
}
+
LRESULT CLUI::OnEraseBkgnd( UINT /*msg*/, WPARAM /*wParam*/, LPARAM /*lParam*/ )
{
return TRUE;
}
+
LRESULT CLUI::OnNcCreate( UINT msg, WPARAM wParam, LPARAM lParam )
{
( (LPCREATESTRUCT)lParam )->style &= ~(CS_HREDRAW | CS_VREDRAW);
@@ -2192,8 +2197,7 @@ LRESULT CLUI::OnNcCreate( UINT msg, WPARAM wParam, LPARAM lParam )
LRESULT CLUI::OnPaint( UINT msg, WPARAM wParam, LPARAM lParam )
{
- if ( !g_CluiData.fLayered && IsWindowVisible(m_hWnd))
- {
+ if ( !g_CluiData.fLayered && IsWindowVisible(m_hWnd)) {
RECT w = {0};
RECT w2 = {0};
PAINTSTRUCT ps = {0};
@@ -2218,8 +2222,7 @@ LRESULT CLUI::OnPaint( UINT msg, WPARAM wParam, LPARAM lParam )
mod_DeleteDC(hdc);
ReleaseDC(m_hWnd,paintDC);
}
- else
- {
+ else {
HDC hdc = BeginPaint(m_hWnd,&ps);
ske_BltBackImage(m_hWnd,hdc,&ps.rcPaint);
ps.fErase = FALSE;
@@ -2227,15 +2230,14 @@ LRESULT CLUI::OnPaint( UINT msg, WPARAM wParam, LPARAM lParam )
}
ValidateRect(m_hWnd,NULL);
-
}
+
if (0 && (db_get_dw(NULL,"CLUIFrames","GapBetweenFrames",SETTING_GAPFRAMES_DEFAULT) || db_get_dw(NULL,"CLUIFrames","GapBetweenTitleBar",SETTING_GAPTITLEBAR_DEFAULT)))
{
- if (IsWindowVisible(m_hWnd))
+ if (IsWindowVisible(m_hWnd)) {
if (g_CluiData.fLayered)
SkinInvalidateFrame(m_hWnd,NULL);
- else
- {
+ else {
RECT w = {0};
RECT w2 = {0};
PAINTSTRUCT ps = {0};
@@ -2250,6 +2252,7 @@ LRESULT CLUI::OnPaint( UINT msg, WPARAM wParam, LPARAM lParam )
ps.fErase = FALSE;
EndPaint(m_hWnd,&ps);
}
+ }
}
return DefWindowProc(m_hWnd, msg, wParam, lParam);
}
@@ -2285,19 +2288,21 @@ LRESULT CLUI::OnCreate( UINT msg, WPARAM wParam, LPARAM lParam )
bTransparentFocus = 1;
return FALSE;
}
+
LRESULT CLUI::OnSetAllExtraIcons( UINT /*msg*/, WPARAM /*wParam*/, LPARAM /*lParam*/ )
{
return FALSE;
}
+
LRESULT CLUI::OnCreateClc( UINT /*msg*/, WPARAM /*wParam*/, LPARAM /*lParam*/ )
{
CreateCLC();
if ( db_get_b( NULL, "CList", "ShowOnStart", SETTING_SHOWONSTART_DEFAULT ))
cliShowHide( (WPARAM) m_hWnd, (LPARAM)TRUE );
PostMessage( pcli->hwndContactTree, CLM_AUTOREBUILD, 0, 0 );
-
return FALSE;
}
+
LRESULT CLUI::OnLButtonDown( UINT msg, WPARAM wParam, LPARAM lParam )
{
POINT pt;
diff --git a/plugins/Clist_modern/modern_tbbutton.cpp b/plugins/Clist_modern/modern_tbbutton.cpp
index 1358cc179d..2f38cc25e3 100644
--- a/plugins/Clist_modern/modern_tbbutton.cpp
+++ b/plugins/Clist_modern/modern_tbbutton.cpp
@@ -2,6 +2,9 @@
#include "hdr/modern_commonprototypes.h"
#include "m_api/m_skinbutton.h"
#include "hdr/modern_clcpaint.h"
+
+#include <m_button_int.h>
+
#ifdef __MINGW32__
#include <ctype.h>
#endif
@@ -10,44 +13,30 @@
#define BUTTON_POLLDELAY 50
#define b2str(a) ((a) ? "True" : "False")
-struct tagTBBUTTONDATA
+struct TBBUTTONDATA : public MButtonCtrl
{
- HWND hWnd; // handle of safe window
- char szButtonID[64]; // Unique stringID of button in form Module.Name
- int nStateId; // state of button
- BOOL fFocused; // button is focused flag
- BOOL fSendOnDown; // send event on button pushed
- BOOL fHotMark; // button is hot marked (e.g. current state)
- BOOL defbutton;
- int nFontID; // internal font ID
- HFONT hFont; // font
- HICON hIconPrivate; // icon need to be destroyed
- HICON hIcon; // icon not need to be destroyed
- char cHot; // button hot key
- TCHAR szText[128]; // text on the button
- RECT rcMargins; // margins of inner content
- BOOL pushBtn; // is it push button
- int pbState; // state of push button
-
- HANDLE hIcolibHandle; // handle of icon in iconlib
+ 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
+
+ HANDLE hIcolibHandle; // handle of icon in iconlib
XPTHANDLE hThemeButton;
XPTHANDLE hThemeToolbar;
- BOOL bThemed;
};
-typedef struct tagTBBUTTONDATA TBBUTTONDATA;
-
static CRITICAL_SECTION csTips;
static HWND hwndToolTips = NULL;
-static LRESULT CALLBACK TollbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-static void PaintWorker(TBBUTTONDATA *lpSBData, HDC hdcPaint , POINT * pOffset);
static BOOL bThemed = FALSE;
static HANDLE hButtonWindowList = NULL;
static HANDLE hBkgChangedHook = NULL;
-
static int OnIconLibIconChanged(WPARAM wParam, LPARAM lParam)
{
WindowList_BroadcastAsync(hButtonWindowList, MBM_REFRESHICOLIBICON,0,0);
@@ -57,256 +46,269 @@ static int OnIconLibIconChanged(WPARAM wParam, LPARAM lParam)
static void InvalidateParentRect(HWND hwndChild, RECT * lpRect, BOOL fErase)
{
LONG lExStyle = GetWindowLongPtr(hwndChild,GWL_EXSTYLE);
- if (lExStyle&WS_EX_TRANSPARENT)
- {
+ if (lExStyle & WS_EX_TRANSPARENT) {
NMHDR hdr;
hdr.hwndFrom = hwndChild;
hdr.idFrom = 0;
hdr.code = BUTTONNEEDREDRAW;
SendMessage(GetParent(hwndChild),WM_NOTIFY,(WPARAM)hwndChild,(LPARAM)&hdr);
}
- else
- {
- InvalidateRect(hwndChild,lpRect,fErase);
+ else InvalidateRect(hwndChild,lpRect,fErase);
+}
+
+static int TBStateConvert2Flat(int state)
+{
+ switch (state) {
+ case PBS_NORMAL:
+ return TS_NORMAL;
+ case PBS_HOT:
+ return TS_HOT;
+ case PBS_PRESSED:
+ return TS_PRESSED;
+ case PBS_DISABLED:
+ return TS_DISABLED;
+ case PBS_DEFAULTED:
+ return TS_NORMAL;
}
+ return TS_NORMAL;
}
-static LRESULT CALLBACK TollbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+
+static void PaintWorker(TBBUTTONDATA *lpSBData, HDC hdcPaint , POINT * pOffset)
{
- TBBUTTONDATA *lpSBData = (TBBUTTONDATA *) GetWindowLongPtr(hwndDlg, 0);
- switch (msg)
+ 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 ( !hdcPaint) return; //early exit
+
+ GetClientRect(lpSBData->hwnd, &rcClient);
+ width = rcClient.right - rcClient.left;
+ height = rcClient.bottom - rcClient.top;
+
+ hdcMem = pOffset?hdcPaint:CreateCompatibleDC(hdcPaint);
+ hOldFont = (HFONT)SelectObject(hdcMem, lpSBData->hFont);
+ if ( !pOffset) {
+ hbmMem = ske_CreateDIB32(width, height);
+ hbmOld = (HBITMAP)SelectObject(hdcMem, hbmMem);
+ }
+ else OffsetRect(&rcClient,offset.x,offset.y);
+
+ if ( !g_CluiData.fDisableSkinEngine) {
+ char szRequest[128];
+ /* painting */
+ 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
+ b2str(lpSBData->fFocused)); // Focused
+
+ SkinDrawGlyph(hdcMem,&rcClient,&rcClient,szRequest);
+ }
+ else
{
- case WM_NCCREATE:
+ if (xpt_IsThemed(lpSBData->hThemeToolbar))
{
- SetWindowLongPtr(hwndDlg, GWL_STYLE, GetWindowLongPtr(hwndDlg, GWL_STYLE) | BS_OWNERDRAW);
- lpSBData = (TBBUTTONDATA *)malloc(sizeof(TBBUTTONDATA));
- if (lpSBData == NULL)
- return FALSE;
- memset(lpSBData,0,sizeof(TBBUTTONDATA)); //I prefer memset to guarantee zeros
- lpSBData->hWnd = hwndDlg;
- lpSBData->nStateId = PBS_NORMAL;
- lpSBData->fFocused = FALSE;
- lpSBData->hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
- lpSBData->hIconPrivate = NULL;
- lpSBData->cHot = '\0';
- lpSBData->szText[0] = '\0';
- lpSBData->szButtonID[0] = '?';
- lpSBData->szButtonID[1] = '\0';
- lpSBData->pushBtn = FALSE;
- lpSBData->pbState = 0;
- lpSBData->fSendOnDown = FALSE;
- lpSBData->fHotMark = FALSE;
- lpSBData->nFontID = -1;
- SetWindowLongPtr(hwndDlg, 0, (LONG_PTR) lpSBData);
- if (((CREATESTRUCTA *) lParam)->lpszName)
- SetWindowText(hwndDlg, ((CREATESTRUCT *) lParam)->lpszName);
- lpSBData->hThemeButton = xpt_AddThemeHandle(lpSBData->hWnd, L"BUTTON");
- lpSBData->hThemeToolbar = xpt_AddThemeHandle(lpSBData->hWnd, L"TOOLBAR");
- WindowList_Add(hButtonWindowList, hwndDlg, NULL);
- return TRUE;
+ RECT *rc = &rcClient;
+ int state = IsWindowEnabled(lpSBData->hwnd) ? /*(lpSBData->stateId == PBS_PRESSED || lpSBData->bIsPushed == TRUE) ? PBS_PRESSED :*/ (lpSBData->stateId == PBS_NORMAL && lpSBData->bIsDefault ? PBS_DEFAULTED : lpSBData->stateId) : PBS_DISABLED;
+ xpt_DrawTheme(lpSBData->hThemeToolbar,lpSBData->hwnd,hdcMem,TP_BUTTON, TBStateConvert2Flat(state), rc, rc);
}
- case WM_DESTROY:
+ else
{
- /* #ifdef _DEBUG
- if (GetWindowLongPtr(hwndButton, GWL_USERDATA))
- DebugBreak();
- #endif */
-
- xpt_FreeThemeForWindow(hwndDlg);
- WindowList_Remove(hButtonWindowList, hwndDlg);
- if (lpSBData)
- {
- if (hwndToolTips)
+ HBRUSH hbr = NULL;
+
+ if (lpSBData->stateId == PBS_PRESSED || lpSBData->stateId == PBS_HOT)
+ hbr = GetSysColorBrush(COLOR_3DLIGHT);
+ else {
+ RECT btnRect;
+ POINT pt = {0};
+ int ret;
+ HWND hwndParent = GetParent(lpSBData->hwnd);
+ HDC dc = CreateCompatibleDC(NULL);
+ HBITMAP memBM, oldBM;
+ GetWindowRect(hwndParent,&btnRect);
+ memBM = ske_CreateDIB32( btnRect.right-btnRect.left, btnRect.bottom-btnRect.top );
+ oldBM = (HBITMAP)SelectObject ( dc, memBM );
+ ret = SendMessage(hwndParent,WM_ERASEBKGND,(WPARAM)dc,0);
+ GetWindowRect(lpSBData->hwnd,&btnRect);
+ ClientToScreen(hwndParent,&pt);
+ OffsetRect(&btnRect,-pt.x,-pt.y);
+ if (ret)
+ BitBlt(hdcMem,0,0,btnRect.right-btnRect.left,btnRect.bottom-btnRect.top,dc,btnRect.left,btnRect.top,SRCCOPY);
+ oldBM = (HBITMAP)SelectObject ( dc, oldBM );
+ DeleteObject(memBM);
+ DeleteDC(dc);
+ if ( !ret) //WM_ERASEBKG return false need to paint
{
- TOOLINFO ti;
-
- ZeroMemory(&ti, sizeof(ti));
- ti.cbSize = sizeof(ti);
- ti.uFlags = TTF_IDISHWND;
- ti.hwnd = lpSBData->hWnd;
- ti.uId = (UINT_PTR) lpSBData->hWnd;
- if (SendMessage(hwndToolTips, TTM_GETTOOLINFO, 0, (LPARAM) &ti))
- {
- SendMessage(hwndToolTips, TTM_DELTOOL, 0, (LPARAM) &ti);
- }
- if (SendMessage(hwndToolTips, TTM_GETTOOLCOUNT, 0, (LPARAM) &ti) == 0)
- {
- DestroyWindow(hwndToolTips);
- hwndToolTips = NULL;
- }
+ HDC pdc = GetDC(hwndParent);
+ HBRUSH oldBrush = (HBRUSH)GetCurrentObject( pdc, OBJ_BRUSH );
+ hbr = (HBRUSH)SendMessage(hwndParent, WM_CTLCOLORDLG, (WPARAM)pdc, (LPARAM)hwndParent);
+ SelectObject(pdc,oldBrush);
+ ReleaseDC(hwndParent,pdc);
}
- if (lpSBData->hIconPrivate)
- DestroyIcon(lpSBData->hIconPrivate);
- free(lpSBData); // lpSBData was malloced by native malloc
+
}
- SetWindowLongPtr(hwndDlg, 0, (LONG) NULL);
- break; // DONT! fall thru
- }
- case WM_SETTEXT:
- {
- lpSBData->cHot = 0;
- if ((TCHAR*) lParam)
- {
- TCHAR *tmp = (TCHAR *) lParam;
- while (*tmp)
- {
- if (*tmp == '&' && *(tmp + 1))
- {
- lpSBData->cHot = (char)tolower(*(tmp + 1));
- break;
- }
- tmp++;
- }
- InvalidateParentRect(lpSBData->hWnd, NULL, TRUE);
- lstrcpyn(lpSBData->szText, (TCHAR *)lParam, SIZEOF(lpSBData->szText)-1);
- lpSBData->szText[SIZEOF(lpSBData->szText)-1] = '\0';
+ if (hbr) {
+ FillRect(hdcMem, &rcClient, hbr);
+ DeleteObject(hbr);
}
- break;
- }
- case WM_SYSKEYUP:
- if (lpSBData->nStateId != PBS_DISABLED && lpSBData->cHot && lpSBData->cHot == tolower((int) wParam))
- {
- if (lpSBData->pushBtn)
- {
- if (lpSBData->pbState)
- lpSBData->pbState = 0;
- else
- lpSBData->pbState = 1;
- InvalidateParentRect(lpSBData->hWnd, NULL, TRUE);
+ if (lpSBData->stateId == PBS_HOT || lpSBData->fFocused) {
+ if (lpSBData->bIsPushed)
+ DrawEdge(hdcMem,&rcClient, EDGE_ETCHED,BF_RECT|BF_SOFT);
+ else DrawEdge(hdcMem,&rcClient, BDR_RAISEDOUTER,BF_RECT|BF_SOFT|BF_FLAT);
}
- if ( !lpSBData->fSendOnDown)
- SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM) hwndDlg);
- return 0;
+ else if (lpSBData->stateId == PBS_PRESSED)
+ DrawEdge(hdcMem, &rcClient, BDR_SUNKENOUTER,BF_RECT|BF_SOFT);
+ }
+ }
+
+ 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;
+ BOOL fHasText = (lpSBData->szText[0] != '\0');
+
+ /* formatter */
+ RECT rcIcon;
+ RECT rcText;
+
+ if ( !g_CluiData.fDisableSkinEngine) {
+ /* correct rect according to rcMargins */
+
+ rcTemp.left += lpSBData->rcMargins.left;
+ rcTemp.top += lpSBData->rcMargins.top;
+ rcTemp.bottom -= lpSBData->rcMargins.bottom;
+ rcTemp.right -= lpSBData->rcMargins.right;
+ }
+
+ rcIcon = rcTemp;
+ rcText = rcTemp;
+
+ /* reposition button items */
+ if (hHasIcon && fHasText ) {
+ rcIcon.right = rcIcon.left+16; /* CXSM_ICON */
+ rcText.left = rcIcon.right+2;
+ }
+ else if (hHasIcon) {
+ rcIcon.left += (rcIcon.right-rcIcon.left)/2-8;
+ rcIcon.right = rcIcon.left+16;
+ }
+
+ /* Check sizes*/
+ if (hHasIcon && (rcIcon.right>rcTemp.right || rcIcon.bottom>rcTemp.bottom || rcIcon.left < rcTemp.left || rcIcon.top < rcTemp.top))
+ hHasIcon = NULL;
+
+ if (fHasText && (rcText.right>rcTemp.right || rcText.bottom>rcTemp.bottom || rcText.left < rcTemp.left || rcText.top < rcTemp.top))
+ fHasText = FALSE;
+
+ if (hHasIcon) {
+ /* center icon vertically */
+ rcIcon.top += (rcClient.bottom-rcClient.top)/2 - 8; /* CYSM_ICON/2 */
+ rcIcon.bottom = rcIcon.top + 16; /* CYSM_ICON */
+ /* draw it */
+ ske_DrawIconEx(hdcMem, rcIcon.left+bPressed, rcIcon.top+bPressed, hHasIcon,
+ 16, 16, 0, NULL, DI_NORMAL);
+ }
+
+ if (fHasText) {
+ BOOL bCentered = TRUE;
+ SetBkMode(hdcMem,TRANSPARENT);
+ if (lpSBData->nFontID >= 0)
+ g_clcPainter.ChangeToFont(hdcMem,NULL,lpSBData->nFontID,NULL);
+
+ RECT TextRequiredRect = rcText;
+ ske_DrawText(hdcMem, lpSBData->szText, -1, &TextRequiredRect, DT_CENTER | DT_VCENTER | DT_CALCRECT | DT_SINGLELINE);
+ if (TextRequiredRect.right-TextRequiredRect.left>rcText.right-rcText.left)
+ bCentered = FALSE;
+
+ ske_DrawText(hdcMem, lpSBData->szText, -1, &rcText, (bCentered ? DT_CENTER: 0) | DT_VCENTER | DT_SINGLELINE);
+ ske_ResetTextEffect(hdcMem);
+ }
+ if ( !pOffset)
+ BitBlt(hdcPaint,0,0,width,height,hdcMem,0,0,SRCCOPY);
+
+ // better to use try/finally but looks like last one is Microsoft specific
+ SelectObject(hdcMem,hOldFont);
+ if ( !pOffset) {
+ SelectObject(hdcMem,hbmOld);
+ DeleteObject(hbmMem);
+ DeleteDC(hdcMem);
+ }
+}
+
+static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ TBBUTTONDATA *lpSBData = (TBBUTTONDATA *) GetWindowLongPtr(hwndDlg, 0);
+ switch (msg) {
+ case WM_DESTROY:
+ xpt_FreeThemeForWindow(hwndDlg);
+ WindowList_Remove(hButtonWindowList, hwndDlg);
+ if (lpSBData) {
+ if (lpSBData->hIconPrivate)
+ DestroyIcon(lpSBData->hIconPrivate);
+ free(lpSBData); // lpSBData was malloced by native malloc
}
+ break; // DONT! fall thru
+
+ case WM_SETTEXT:
+ lstrcpyn(lpSBData->szText, (TCHAR *)lParam, SIZEOF(lpSBData->szText)-1);
+ lpSBData->szText[SIZEOF(lpSBData->szText)-1] = '\0';
break;
case WM_SETFONT:
- {
- // remember the font so we can use it later
- lpSBData->hFont = (HFONT) wParam; // maybe we should redraw?
- lpSBData->nFontID = (int) lParam - 1;
- break;
- }
+ // remember the font so we can use it later
+ lpSBData->hFont = (HFONT) wParam; // maybe we should redraw?
+ lpSBData->nFontID = (int) lParam - 1;
+ break;
+
case BUTTONSETSENDONDOWN:
- {
- lpSBData->fSendOnDown = (BOOL) lParam;
- break;
- }
+ lpSBData->fSendOnDown = (BOOL) lParam;
+ break;
+
case BUTTONSETMARGINS:
- {
- if (lParam) lpSBData->rcMargins = *(RECT*)lParam;
- else
- {
- RECT nillRect = {0};
- lpSBData->rcMargins = nillRect;
- }
- return 0;
+ if (lParam) lpSBData->rcMargins = *(RECT*)lParam;
+ else {
+ RECT nillRect = {0};
+ lpSBData->rcMargins = nillRect;
}
+ return 0;
+
case BUTTONSETID:
- {
- lstrcpynA(lpSBData->szButtonID, (char *)lParam, SIZEOF(lpSBData->szButtonID)-1);
- lpSBData->szButtonID[SIZEOF(lpSBData->szButtonID)-1] = '\0';
- return 0;
- }
+ lstrcpynA(lpSBData->szButtonID, (char *)lParam, SIZEOF(lpSBData->szButtonID)-1);
+ lpSBData->szButtonID[SIZEOF(lpSBData->szButtonID)-1] = '\0';
+ return 0;
+
case BUTTONDRAWINPARENT:
- {
- if (IsWindowVisible(hwndDlg))
- PaintWorker(lpSBData, (HDC) wParam, (POINT*) lParam);
- return 0;
- }
+ if (IsWindowVisible(hwndDlg))
+ PaintWorker(lpSBData, (HDC) wParam, (POINT*) lParam);
+ return 0;
+
case WM_NCPAINT:
case WM_PAINT:
- {
-
+ if (g_CluiData.fDisableSkinEngine) {
PAINTSTRUCT ps;
- HDC hdcPaint;
- if (g_CluiData.fDisableSkinEngine)
- {
- hdcPaint = BeginPaint(hwndDlg, &ps);
- if (hdcPaint)
- {
- PaintWorker(lpSBData, hdcPaint, NULL);
- EndPaint(hwndDlg, &ps);
- }
+ HDC hdcPaint = BeginPaint(hwndDlg, &ps);
+ if (hdcPaint) {
+ PaintWorker(lpSBData, hdcPaint, NULL);
+ EndPaint(hwndDlg, &ps);
}
- ValidateRect(hwndDlg,NULL);
- return 0;
}
- case BUTTONADDTOOLTIP:
- {
- TOOLINFO ti;
+ ValidateRect(hwndDlg,NULL);
+ return 1;
- if ( !(char*) wParam)
- break;
- if ( !hwndToolTips)
- {
- hwndToolTips = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, _T(""), WS_POPUP, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(NULL), NULL);
- SetWindowPos(hwndToolTips, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
- }
- ZeroMemory(&ti, sizeof(ti));
- ti.cbSize = sizeof(ti);
- ti.uFlags = TTF_IDISHWND;
- ti.hwnd = lpSBData->hWnd;
- ti.uId = (UINT_PTR) lpSBData->hWnd;
- if (SendMessage(hwndToolTips, TTM_GETTOOLINFO, 0, (LPARAM) &ti)) {
- SendMessage(hwndToolTips, TTM_DELTOOL, 0, (LPARAM) &ti);
- }
- ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
- ti.uId = (UINT_PTR) lpSBData->hWnd;
- ti.lpszText = (TCHAR *) wParam;
- SendMessage(hwndToolTips, TTM_ADDTOOL, 0, (LPARAM) &ti);
- break;
+ case WM_CAPTURECHANGED:
+ if ( (HWND)lParam != lpSBData->hwnd && lpSBData->stateId != PBS_DISABLED) {
+ // don't change states if disabled
+ lpSBData->stateId = PBS_NORMAL;
+ InvalidateParentRect(lpSBData->hwnd, NULL, TRUE);
}
-
- case BUTTONSETASPUSHBTN:
- lpSBData->pushBtn = (wParam != 0);
- lpSBData->pbState = (lParam & 2) != 0;
- return 0;
-
- case WM_SETFOCUS:
- // set keyboard focus and redraw
- lpSBData->fFocused = TRUE;
- InvalidateParentRect(lpSBData->hWnd, NULL, TRUE);
break;
- case WM_KILLFOCUS:
- // kill focus and redraw
- lpSBData->fFocused = FALSE;
- InvalidateParentRect(lpSBData->hWnd, NULL, TRUE);
- break;
-
- case WM_WINDOWPOSCHANGED:
- InvalidateParentRect(lpSBData->hWnd, NULL, TRUE);
- break;
-
- case WM_ENABLE:
- // windows tells us to enable/disable
- {
- lpSBData->nStateId = wParam ? PBS_NORMAL : PBS_DISABLED;
- InvalidateParentRect(lpSBData->hWnd, NULL, TRUE);
- break;
- }
- /*case WM_MOUSELEAVE:
- {
- // faked by the WM_TIMER
- if (lpSBData->nStateId != PBS_DISABLED)
- {
- // don't change states if disabled
- lpSBData->nStateId = PBS_NORMAL;
- InvalidateParentRect(lpSBData->hWnd, NULL, TRUE);
- }
- break;
- }
- */
- case WM_CAPTURECHANGED:
- {
- if ( (HWND)lParam != lpSBData->hWnd && lpSBData->nStateId != PBS_DISABLED)
- {
- // don't change states if disabled
- lpSBData->nStateId = PBS_NORMAL;
- InvalidateParentRect(lpSBData->hWnd, NULL, TRUE);
- }
- break;
- }
case WM_LBUTTONDOWN:
{
int xPos = ( ( int )( short ) LOWORD( lParam ));
@@ -314,7 +316,7 @@ static LRESULT CALLBACK TollbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam
POINT ptMouse = { xPos, yPos };
RECT rcClient;
- GetClientRect( lpSBData->hWnd, &rcClient );
+ GetClientRect( lpSBData->hwnd, &rcClient );
if ( !PtInRect( &rcClient, ptMouse ))
{
@@ -323,55 +325,52 @@ static LRESULT CALLBACK TollbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam
break;
}
- if (lpSBData->nStateId != PBS_DISABLED && lpSBData->nStateId != PBS_PRESSED)
+ if (lpSBData->stateId != PBS_DISABLED && lpSBData->stateId != PBS_PRESSED)
{
- lpSBData->nStateId = PBS_PRESSED;
+ lpSBData->stateId = PBS_PRESSED;
lpSBData->fHotMark = TRUE;
- InvalidateParentRect(lpSBData->hWnd, NULL, TRUE);
+ InvalidateParentRect(lpSBData->hwnd, NULL, TRUE);
if (lpSBData->fSendOnDown)
{
SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM) hwndDlg);
- lpSBData->nStateId = PBS_NORMAL;
- InvalidateParentRect(lpSBData->hWnd, NULL, TRUE);
+ lpSBData->stateId = PBS_NORMAL;
+ InvalidateParentRect(lpSBData->hwnd, NULL, TRUE);
}
}
- SetCapture( lpSBData->hWnd );
+ SetCapture( lpSBData->hwnd );
break;
}
- case WM_LBUTTONUP:
- if ( GetCapture() == lpSBData->hWnd )
- {
+ case WM_LBUTTONUP:
+ if ( GetCapture() == lpSBData->hwnd ) {
int xPos = ( ( int )( short ) LOWORD( lParam ));
int yPos = ( ( int )( short ) HIWORD( lParam ));
POINT ptMouse = { xPos, yPos };
RECT rcClient;
- GetClientRect( lpSBData->hWnd, &rcClient );
+ GetClientRect( lpSBData->hwnd, &rcClient );
- if ( !PtInRect( &rcClient, ptMouse ))
- {
+ if ( !PtInRect( &rcClient, ptMouse )) {
lpSBData->fHotMark = FALSE;
ReleaseCapture();
break;
}
- if (lpSBData->pushBtn)
- {
- if (lpSBData->pbState)
- lpSBData->pbState = FALSE;
+ if (lpSBData->bIsPushBtn) {
+ if (lpSBData->bIsPushed)
+ lpSBData->bIsPushed = FALSE;
else
- lpSBData->pbState = TRUE;
+ lpSBData->bIsPushed = TRUE;
}
- if (lpSBData->nStateId != PBS_DISABLED)
+ if (lpSBData->stateId != PBS_DISABLED)
{
// don't change states if disabled
if (msg == WM_LBUTTONUP)
- lpSBData->nStateId = PBS_HOT;
+ lpSBData->stateId = PBS_HOT;
else
- lpSBData->nStateId = PBS_NORMAL;
- InvalidateParentRect(lpSBData->hWnd, NULL, TRUE);
+ lpSBData->stateId = PBS_NORMAL;
+ InvalidateParentRect(lpSBData->hwnd, NULL, TRUE);
}
if ( !lpSBData->fSendOnDown && lpSBData->fHotMark)
SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM) hwndDlg);
@@ -390,25 +389,25 @@ static LRESULT CALLBACK TollbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam
BOOL inClient = PtInRect(&rc, pt);
if ( inClient )
{
- SetCapture( lpSBData->hWnd );
- if ( lpSBData->nStateId == PBS_NORMAL )
+ SetCapture( lpSBData->hwnd );
+ if ( lpSBData->stateId == PBS_NORMAL )
{
- lpSBData->nStateId = PBS_HOT;
- InvalidateParentRect(lpSBData->hWnd, NULL, TRUE);
+ lpSBData->stateId = PBS_HOT;
+ InvalidateParentRect(lpSBData->hwnd, NULL, TRUE);
}
}
- if ( !inClient && lpSBData->nStateId == PBS_PRESSED )
+ if ( !inClient && lpSBData->stateId == PBS_PRESSED )
{
- lpSBData->nStateId = PBS_HOT;
- InvalidateParentRect(lpSBData->hWnd, NULL, TRUE);
+ lpSBData->stateId = PBS_HOT;
+ InvalidateParentRect(lpSBData->hwnd, NULL, TRUE);
}
- else if ( inClient && lpSBData->nStateId == PBS_HOT && bPressed )
+ else if ( inClient && lpSBData->stateId == PBS_HOT && bPressed )
{
if ( lpSBData->fHotMark )
{
- lpSBData->nStateId = PBS_PRESSED;
- InvalidateParentRect(lpSBData->hWnd, NULL, TRUE);
+ lpSBData->stateId = PBS_PRESSED;
+ InvalidateParentRect(lpSBData->hwnd, NULL, TRUE);
}
}
else if ( !inClient && !bPressed)
@@ -417,14 +416,6 @@ static LRESULT CALLBACK TollbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam
ReleaseCapture();
}
}
- // else
- {
- //KillTimer(hwndDlg, BUTTON_POLLID);
- //CLUI_SafeSetTimer(hwndDlg, BUTTON_POLLID, BUTTON_POLLDELAY, NULL);
- }
- // Call timer, used to start cheesy TrackMouseEvent faker
-
-
break;
case WM_NCHITTEST:
@@ -433,67 +424,35 @@ static LRESULT CALLBACK TollbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam
if (lr == HTLEFT || lr == HTRIGHT || lr == HTBOTTOM || lr == HTTOP || lr == HTTOPLEFT || lr == HTTOPRIGHT
|| lr == HTBOTTOMLEFT || lr == HTBOTTOMRIGHT)
return HTTRANSPARENT;
- break;
}
- /*case WM_TIMER: // use a timer to check if they have did a mouse out
- {
- if (wParam == BUTTON_POLLID)
- {
- HWND hwnd = GetCapture();
- if ( hwnd == lpSBData->hWnd )
- {
- //KillTimer(hwndDlg, BUTTON_POLLID);
- break;
- }
- RECT rc;
- POINT pt;
- GetWindowRect(hwndDlg, &rc);
- GetCursorPos(&pt);
- BOOL bInside = ( PtInRect( &rc, pt ) && ( WindowFromPoint( pt ) == lpSBData->hWnd));
- if ( !bInside )
- {
- // mouse must be gone, trigger mouse leave
- PostMessage(hwndDlg, WM_MOUSELEAVE, 0, 0L);
- KillTimer(hwndDlg, BUTTON_POLLID);
- }
- }
- break;
- }
- */
- case WM_ERASEBKGND:
- {
- return 1;
- }
- case MBM_SETICOLIBHANDLE:
- {
- if (lpSBData->hIconPrivate)
- {
- DestroyIcon(lpSBData->hIconPrivate);
- lpSBData->hIconPrivate = 0;
- }
+ break;
- lpSBData->hIcolibHandle = (HANDLE)lParam;
- if (lpSBData->hIcolibHandle)
- lpSBData->hIcon = (HICON)CallService(MS_SKIN2_GETICONBYHANDLE, 0 , (LPARAM) lpSBData->hIcolibHandle);
- else
- lpSBData->hIcon = NULL;
- 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);
+ else
+ lpSBData->hIcon = NULL;
+ 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
- lpSBData->hIcon = NULL;
- InvalidateRect(hwndDlg,NULL,TRUE);
- pcli->pfnInvalidateRect(GetParent(GetParent(hwndDlg)),NULL,TRUE);
- return 1;
- }
+ if (lpSBData->hIconPrivate) {
+ DestroyIcon(lpSBData->hIconPrivate);
+ lpSBData->hIconPrivate = 0;
+ }
+ if (lpSBData->hIcolibHandle)
+ lpSBData->hIcon = (HICON)CallService(MS_SKIN2_GETICONBYHANDLE, 0 , (LPARAM) lpSBData->hIcolibHandle);
+ else
+ lpSBData->hIcon = NULL;
+ InvalidateRect(hwndDlg,NULL,TRUE);
+ pcli->pfnInvalidateRect(GetParent(GetParent(hwndDlg)),NULL,TRUE);
+ return 1;
+
case MBM_UPDATETRANSPARENTFLAG:
{
LONG flag = GetWindowLongPtr(hwndDlg,GWL_EXSTYLE);
@@ -502,282 +461,81 @@ static LRESULT CALLBACK TollbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam
lParam = (g_CluiData.fDisableSkinEngine)?0:1;
flag &= ~WS_EX_TRANSPARENT;
if (lParam) flag |= WS_EX_TRANSPARENT;
- if (flag != oldFlag)
- {
+ if (flag != oldFlag) {
SetWindowLongPtr(hwndDlg,GWL_EXSTYLE,flag);
RedrawWindow(hwndDlg,NULL,NULL,RDW_INVALIDATE|RDW_UPDATENOW);
}
- return 0;
}
- case BM_GETIMAGE:
- {
- if (wParam == IMAGE_ICON)
- return (LRESULT)(lpSBData->hIconPrivate ? lpSBData->hIconPrivate : lpSBData->hIcon);
- 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;
- }
+ return 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;
- }
+ case BM_GETIMAGE:
+ if (wParam == IMAGE_ICON)
+ return (LRESULT)(lpSBData->hIconPrivate ? lpSBData->hIconPrivate : lpSBData->hIcon);
+ break;
- DeleteObject(ii.hbmMask);
- DeleteObject(ii.hbmColor);
- InvalidateParentRect(lpSBData->hWnd, NULL, TRUE);
- }
- else if (wParam == IMAGE_BITMAP)
- {
- if (lpSBData->hIconPrivate)
- DestroyIcon(lpSBData->hIconPrivate);
- lpSBData->hIcon = lpSBData->hIconPrivate = NULL;
- InvalidateParentRect(lpSBData->hWnd, NULL, TRUE);
- return 0; // not supported
- }
+ case BM_SETIMAGE:
+ if ( !lParam)
break;
- }
- }
- return DefWindowProc(hwndDlg, msg, wParam, lParam);
-}
-static int TBStateConvert2Flat(int state)
-{
- switch (state) {
-case PBS_NORMAL:
- return TS_NORMAL;
-case PBS_HOT:
- return TS_HOT;
-case PBS_PRESSED:
- return TS_PRESSED;
-case PBS_DISABLED:
- return TS_DISABLED;
-case PBS_DEFAULTED:
- return TS_NORMAL;
- }
- return TS_NORMAL;
-}
+ if (wParam == IMAGE_ICON) {
+ ICONINFO ii = {0};
+ BITMAP bm = {0};
-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 ( !hdcPaint) return; //early exit
-
- GetClientRect(lpSBData->hWnd, &rcClient);
- width = rcClient.right - rcClient.left;
- height = rcClient.bottom - rcClient.top;
-
- hdcMem = pOffset?hdcPaint:CreateCompatibleDC(hdcPaint);
- hOldFont = (HFONT)SelectObject(hdcMem, lpSBData->hFont);
- if ( !pOffset)
- {
- hbmMem = ske_CreateDIB32(width, height);
- hbmOld = (HBITMAP)SelectObject(hdcMem, hbmMem);
- }
- else
- {
- OffsetRect(&rcClient,offset.x,offset.y);
- }
- {
- if ( !g_CluiData.fDisableSkinEngine)
- {
- char szRequest[128];
- /* painting */
- mir_snprintf(szRequest,SIZEOF(szRequest),"Button,ID = %s,Hovered = %s,Pressed = %s,Focused = %s",
- lpSBData->szButtonID, // ID
- b2str(lpSBData->nStateId == PBS_HOT), // Hovered
- b2str(lpSBData->nStateId == PBS_PRESSED || lpSBData->pbState == TRUE), // Pressed
- b2str(lpSBData->fFocused)); // Focused
-
- SkinDrawGlyph(hdcMem,&rcClient,&rcClient,szRequest);
- }
- else
- {
- if (xpt_IsThemed(lpSBData->hThemeToolbar))
- {
- RECT *rc = &rcClient;
- int state = IsWindowEnabled(lpSBData->hWnd) ? /*(lpSBData->nStateId == PBS_PRESSED || lpSBData->pbState == TRUE) ? PBS_PRESSED :*/ (lpSBData->nStateId == PBS_NORMAL && lpSBData->defbutton ? PBS_DEFAULTED : lpSBData->nStateId) : PBS_DISABLED;
- xpt_DrawTheme(lpSBData->hThemeToolbar,lpSBData->hWnd,hdcMem,TP_BUTTON, TBStateConvert2Flat(state), rc, rc);
+ if (lpSBData->hIconPrivate) {
+ DestroyIcon(lpSBData->hIconPrivate);
+ lpSBData->hIconPrivate = 0;
}
- else
- {
- HBRUSH hbr = NULL;
-
- if (lpSBData->nStateId == PBS_PRESSED || lpSBData->nStateId == PBS_HOT)
- hbr = GetSysColorBrush(COLOR_3DLIGHT);
- else {
- RECT btnRect;
- POINT pt = {0};
- int ret;
- HWND hwndParent = GetParent(lpSBData->hWnd);
- HDC dc = CreateCompatibleDC(NULL);
- HBITMAP memBM, oldBM;
- GetWindowRect(hwndParent,&btnRect);
- memBM = ske_CreateDIB32( btnRect.right-btnRect.left, btnRect.bottom-btnRect.top );
- oldBM = (HBITMAP)SelectObject ( dc, memBM );
- ret = SendMessage(hwndParent,WM_ERASEBKGND,(WPARAM)dc,0);
- GetWindowRect(lpSBData->hWnd,&btnRect);
- ClientToScreen(hwndParent,&pt);
- OffsetRect(&btnRect,-pt.x,-pt.y);
- if (ret)
- BitBlt(hdcMem,0,0,btnRect.right-btnRect.left,btnRect.bottom-btnRect.top,dc,btnRect.left,btnRect.top,SRCCOPY);
- oldBM = (HBITMAP)SelectObject ( dc, oldBM );
- DeleteObject(memBM);
- DeleteDC(dc);
- if ( !ret) //WM_ERASEBKG return false need to paint
- {
- HDC pdc = GetDC(hwndParent);
- HBRUSH oldBrush = (HBRUSH)GetCurrentObject( pdc, OBJ_BRUSH );
- hbr = (HBRUSH)SendMessage(hwndParent, WM_CTLCOLORDLG, (WPARAM)pdc, (LPARAM)hwndParent);
- SelectObject(pdc,oldBrush);
- ReleaseDC(hwndParent,pdc);
- }
- }
- if (hbr) {
- FillRect(hdcMem, &rcClient, hbr);
- DeleteObject(hbr);
- }
- if (lpSBData->nStateId == PBS_HOT || lpSBData->fFocused) {
- if (lpSBData->pbState)
- DrawEdge(hdcMem,&rcClient, EDGE_ETCHED,BF_RECT|BF_SOFT);
- else DrawEdge(hdcMem,&rcClient, BDR_RAISEDOUTER,BF_RECT|BF_SOFT|BF_FLAT);
- }
- else if (lpSBData->nStateId == PBS_PRESSED)
- DrawEdge(hdcMem, &rcClient, BDR_SUNKENOUTER,BF_RECT|BF_SOFT);
+ 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;
}
- }
-
- }
- {
-
- RECT rcTemp = rcClient; //content rect
- BYTE bPressed = (lpSBData->nStateId == PBS_PRESSED || lpSBData->pbState == TRUE)?1:0;
- HICON hHasIcon = lpSBData->hIcon?lpSBData->hIcon:lpSBData->hIconPrivate?lpSBData->hIconPrivate:NULL;
- BOOL fHasText = (lpSBData->szText[0] != '\0');
-
- /* formatter */
- RECT rcIcon;
- RECT rcText;
-
-
- if ( !g_CluiData.fDisableSkinEngine)
- {
- /* correct rect according to rcMargins */
-
- rcTemp.left += lpSBData->rcMargins.left;
- rcTemp.top += lpSBData->rcMargins.top;
- rcTemp.bottom -= lpSBData->rcMargins.bottom;
- rcTemp.right -= lpSBData->rcMargins.right;
- }
-
- rcIcon = rcTemp;
- rcText = rcTemp;
-
-
- /* reposition button items */
- if (hHasIcon && fHasText )
- {
- rcIcon.right = rcIcon.left+16; /* CXSM_ICON */
- rcText.left = rcIcon.right+2;
- }
- else if (hHasIcon)
- {
- rcIcon.left += (rcIcon.right-rcIcon.left)/2-8;
- rcIcon.right = rcIcon.left+16;
- }
-
- {
- /* Check sizes*/
- if (hHasIcon &&
- (rcIcon.right>rcTemp.right ||
- rcIcon.bottom>rcTemp.bottom ||
- rcIcon.left < rcTemp.left ||
- rcIcon.top < rcTemp.top)) hHasIcon = NULL;
-
- if (fHasText &&
- (rcText.right>rcTemp.right ||
- rcText.bottom>rcTemp.bottom ||
- rcText.left < rcTemp.left ||
- rcText.top < rcTemp.top)) fHasText = FALSE;
- }
- if (hHasIcon)
- {
- /* center icon vertically */
- rcIcon.top += (rcClient.bottom-rcClient.top)/2 - 8; /* CYSM_ICON/2 */
- rcIcon.bottom = rcIcon.top + 16; /* CYSM_ICON */
- /* draw it */
- ske_DrawIconEx(hdcMem, rcIcon.left+bPressed, rcIcon.top+bPressed, hHasIcon,
- 16, 16, 0, NULL, DI_NORMAL);
+ DeleteObject(ii.hbmMask);
+ DeleteObject(ii.hbmColor);
+ InvalidateParentRect(lpSBData->hwnd, NULL, TRUE);
}
- if (fHasText)
+ else if (wParam == IMAGE_BITMAP)
{
- BOOL bCentered = TRUE;
- SetBkMode(hdcMem,TRANSPARENT);
- if (lpSBData->nFontID >= 0)
- g_clcPainter.ChangeToFont(hdcMem,NULL,lpSBData->nFontID,NULL);
- {
- RECT TextRequiredRect = rcText;
- ske_DrawText(hdcMem, lpSBData->szText, -1, &TextRequiredRect, DT_CENTER | DT_VCENTER | DT_CALCRECT | DT_SINGLELINE);
- if (TextRequiredRect.right-TextRequiredRect.left>rcText.right-rcText.left)
- bCentered = FALSE;
-
- }
- ske_DrawText(hdcMem, lpSBData->szText, -1, &rcText, (bCentered ? DT_CENTER: 0) | DT_VCENTER | DT_SINGLELINE);
- ske_ResetTextEffect(hdcMem);
+ if (lpSBData->hIconPrivate)
+ DestroyIcon(lpSBData->hIconPrivate);
+ lpSBData->hIcon = lpSBData->hIconPrivate = NULL;
+ InvalidateParentRect(lpSBData->hwnd, NULL, TRUE);
+ return 0; // not supported
}
- if ( !pOffset)
- BitBlt(hdcPaint,0,0,width,height,hdcMem,0,0,SRCCOPY);
+ break;
}
+ return 0;
+}
- // better to use try/finally but looks like last one is Microsoft specific
-
- SelectObject(hdcMem,hOldFont);
- if ( !pOffset)
- {
- SelectObject(hdcMem,hbmOld);
- DeleteObject(hbmMem);
- DeleteDC(hdcMem);
- }
- return;
+void CustomizeButton(HWND hwnd)
+{
+ MButtonCustomize Custom;
+ Custom.cbLen = sizeof(TBBUTTONDATA);
+ Custom.fnPainter = (pfnPainterFunc)PaintWorker;
+ Custom.fnWindowProc = ToolbarButtonProc;
+ SendMessage(hwnd, BUTTONSETCUSTOM, 0, (LPARAM)&Custom);
+
+ TBBUTTONDATA* p = (TBBUTTONDATA*)GetWindowLongPtr(hwnd, 0);
+ p->nFontID = -1;
+ p->hThemeButton = xpt_AddThemeHandle(p->hwnd, L"BUTTON");
+ p->hThemeToolbar = xpt_AddThemeHandle(p->hwnd, L"TOOLBAR");
+ WindowList_Add(hButtonWindowList, hwnd, NULL);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
int Buttons_OnSkinModeSettingsChanged(WPARAM wParam, LPARAM lParam)
{
WindowList_BroadcastAsync(hButtonWindowList, MBM_UPDATETRANSPARENTFLAG,0,2);
@@ -786,19 +544,8 @@ int Buttons_OnSkinModeSettingsChanged(WPARAM wParam, LPARAM lParam)
HRESULT ToolbarButtonLoadModule()
{
- WNDCLASSEX wc;
- ZeroMemory(&wc, sizeof(wc));
- wc.cbSize = sizeof(wc);
- wc.lpszClassName = SKINBUTTONCLASS;
- wc.lpfnWndProc = TollbarButtonProc;
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.cbWndExtra = sizeof(TBBUTTONDATA *);
- wc.hbrBackground = 0;
- wc.style = CS_GLOBALCLASS;
- RegisterClassEx(&wc);
hButtonWindowList = (HANDLE) CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
hIconChangedHook = HookEvent(ME_SKIN2_ICONSCHANGED,OnIconLibIconChanged);
hBkgChangedHook = HookEvent(ME_BACKGROUNDCONFIG_CHANGED,Buttons_OnSkinModeSettingsChanged);
-
return S_OK;
}
diff --git a/plugins/Clist_modern/modern_toolbar.cpp b/plugins/Clist_modern/modern_toolbar.cpp
index 914c084d36..05ddd64100 100644
--- a/plugins/Clist_modern/modern_toolbar.cpp
+++ b/plugins/Clist_modern/modern_toolbar.cpp
@@ -26,684 +26,65 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "hdr/modern_commonheaders.h"
#include "hdr/modern_commonprototypes.h"
#include "./m_api/m_skinbutton.h"
-#include "m_toolbar.h"
+#include <m_toptoolbar.h>
#include "hdr/modern_sync.h"
-//external definition
-COLORREF sttGetColor(char * module, char * color, COLORREF defColor);
+#define TTB_OPTDIR "TopToolBar"
-#define MS_CLUI_SHOWMAINMENU "CList/ShowMainMenu"
-#define MS_CLUI_SHOWSTATUSMENU "CList/ShowStatusMenu"
-#define MS_TTB_TOGGLEHIDEOFFLINE "CList/ToggleHideOffline"
+#if defined(WIN64)
+ static char szUrl[] = "http://nightly.miranda.im/x64/toptoolbar.zip";
+#else
+ static char szUrl[] = "http://nightly.miranda.im/x32/toptoolbar.zip";
+#endif
-#define MIRANDATOOLBARCLASSNAME "MirandaToolBar"
+static TCHAR szWarning[] = LPGENT("To view a toolbar in Clist Modern you need the TopToolBar plugin. Click Yes to download it or Cancel to continue");
-#define tbcheck if ( !g_CluiData.hEventToolBarModuleLoaded) return
-#define tblock EnterCriticalSection(&tbdat.cs)
-#define tbunlock LeaveCriticalSection(&tbdat.cs)
-
-enum {
- MTBM_FIRST = WM_USER,
- MTBM_ADDBUTTON, // will be broad casted thought bars to add button
- MTBM_REPOSBUTTONS,
- MTBM_LAYEREDPAINT,
- MTBM_SETBUTTONSTATE,
- MTBM_SETBUTTONSTATEBYID,
- MTBM_GETBUTTONSTATE,
- MTBM_GETBUTTONSTATEBYID,
- MTBM_REMOVE_ALL_BUTTONS,
- MTBM_UPDATEFRAMEVISIBILITY,
- MTBM_REMOVEBUTTON,
- MTBM_LAST
-};
-
-enum {
- SEPARATOR_NOT = 0,
- SEPARATOR_FIXED,
- SEPARATOR_FLEX
-};
-
-typedef struct _tag_MTB_BUTTONINFO
-{
- HWND hWindow;
- HWND hwndToolBar;
- char * szButtonID; //
- char * szButtonName; // The name of button (untranslated)
- char * szService; // Service to be executed
- TCHAR * szTooltip;
- TCHAR * szTooltipPressed;
- int nOrderValue; // Order of button
- BYTE position;
- BOOL bPushButton; // 2 icon state button.
- BYTE bSeparator; //0 - No, 2- flex, 1 -fixed
- HANDLE hPrimaryIconHandle;
- HANDLE hSecondaryIconHandle;
- BOOL bVisible;
- BYTE bPanelID;
- LPARAM lParam;
- void (*ParamDestructor)(void *); //will be called on parameters deletion
-}MTB_BUTTONINFO;
-
-typedef struct _tagMTBInfo
-{
- int cbSize;
- HANDLE hFrame;
- HWND hWnd;
- SortedList * pButtonList;
- int nButtonWidth;
- int nButtonHeight;
- int nButtonSpace;
- BOOL bFlatButtons;
- XPTHANDLE mtbXPTheme;
- BOOL fAutoSize;
- int nLineCount;
- WORD wLastHeight;
- BOOL fSingleLine;
-}MTBINFO;
-
-typedef struct _tag_MTB_GLOBALDAT
-{
- HANDLE hToolBarWindowList;
-
- //hooks and services handles
- HANDLE hehModulesLoaded;
- HANDLE hehSystemShutdown;
- HANDLE hehSettingsChanged;
- HANDLE hehOptInit;
- HANDLE hsvcToolBarAddButton;
- HANDLE hsvcToolBarRemoveButton;
- HANDLE hsvcToolBarGetButtonState;
- HANDLE hsvcToolBarSetButtonState;
-
- HBITMAP mtb_hBmpBackground;
- COLORREF mtb_bkColour;
- WORD mtb_backgroundBmpUse;
- BOOL mtb_useWinColors;
- HANDLE hHideOfflineButton;
-
- SortedList * listOfButtons;
- CRITICAL_SECTION cs;
-} MTB_GLOBALDAT;
-
-
-static INT_PTR svcToolBarAddButton(WPARAM wParam, LPARAM lParam);
-static INT_PTR svcToolBarRemoveButton(WPARAM wParam, LPARAM lParam);
-static INT_PTR svcToolBarGetButtonState(WPARAM wParam, LPARAM lParam);
-static INT_PTR svcToolBarGetButtonStateById(WPARAM wParam, LPARAM lParam);
-static INT_PTR svcToolBarSetButtonState(WPARAM wParam, LPARAM lParam);
-static INT_PTR svcToolBarSetButtonStateById(WPARAM wParam, LPARAM lParam);
-
-static int ehhToolbarModulesLoaded(WPARAM wParam, LPARAM lParam);
-static int ehhToolBarSystemShutdown(WPARAM wParam, LPARAM lParam);
-static int ehhToolBarSettingsChanged( WPARAM wParam, LPARAM lParam );
-static int ehhToolBarBackgroundSettingsChanged(WPARAM wParam, LPARAM lParam);
-static int ehhToolbarOptInit(WPARAM wParam, LPARAM lParam);
-
-static MTB_BUTTONINFO * ToolBar_AddButtonToBars(MTB_BUTTONINFO * mtbi);
-static LRESULT CALLBACK ToolBar_WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
-static LRESULT CALLBACK ToolBar_OptDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam);
-static int ToolBar_LayeredPaintProc(HWND hWnd, HDC hDC, RECT * rcPaint, HRGN rgn, DWORD dFlags, void * CallBackData);
-static void ToolBar_DefaultButtonRegistration();
-
-
-static void sttSetButtonPressed( char * szButton, BOOL bPressed );
-static HWND sttCreateToolBarFrame( HWND hwndParent, char * szCaption, int nHeight );
-static void sttGetButtonSettings(char * ID, BYTE * pbVisible, DWORD * pdwOrder, BYTE * pbPanelID);
-static void sttReloadButtons();
-static void sttTBButton2MTBBUTTONINFO(TBButton * bi, MTB_BUTTONINFO * mtbi);
-static int sttSortButtons(const void * vmtbi1, const void * vmtbi2);
-
-
-static MTB_GLOBALDAT tbdat = {0};
-
-//destructor for MTB_BUTTONINFO
-static void delete_MTB_BUTTONINFO(void * input)
-{
- MTB_BUTTONINFO * mtbi = (MTB_BUTTONINFO *)input;
- if (mtbi->hWindow && IsWindow(mtbi->hWindow)) DestroyWindow(mtbi->hWindow);
- mir_safe_free(mtbi->szButtonID);
- mir_safe_free(mtbi->szButtonName);
- mir_safe_free(mtbi->szService);
- mir_safe_free(mtbi->szTooltip);
- mir_safe_free(mtbi->szTooltipPressed);
- mir_safe_free(mtbi);
-}
-
-HRESULT ToolbarLoadModule()
-{
-
- tbdat.hehModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ehhToolbarModulesLoaded);
- tbdat.hehSystemShutdown = HookEvent(ME_SYSTEM_SHUTDOWN, ehhToolBarSystemShutdown);
-
- { //create window class
- WNDCLASS wndclass = {0};
- if (GetClassInfo(g_hInst,_T(MIRANDATOOLBARCLASSNAME),&wndclass) == 0)
- {
- wndclass.style = 0;
- wndclass.lpfnWndProc = ToolBar_WndProc;
- wndclass.cbClsExtra = 0;
- wndclass.cbWndExtra = 0;
- wndclass.hInstance = g_hInst;
- wndclass.hIcon = NULL;
- wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
- wndclass.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
- wndclass.lpszMenuName = NULL;
- wndclass.lpszClassName = _T(MIRANDATOOLBARCLASSNAME);
- RegisterClass(&wndclass);
- }
- }
- tbdat.listOfButtons = List_Create(0,1);
- InitializeCriticalSection(&tbdat.cs);
- return S_OK;
-}
-
-static int ehhToolbarModulesLoaded(WPARAM wParam, LPARAM lParam)
-{
- CallService(MS_BACKGROUNDCONFIG_REGISTER,(WPARAM)"ToolBar Background/ToolBar",0);
- HookEvent(ME_BACKGROUNDCONFIG_CHANGED,ehhToolBarBackgroundSettingsChanged);
- tbdat.hehOptInit = HookEvent(ME_OPT_INITIALISE,ehhToolbarOptInit);
- ehhToolBarBackgroundSettingsChanged(0,0);
- tbdat.hehSettingsChanged = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, ehhToolBarSettingsChanged );
-
- tbdat.hToolBarWindowList = (HANDLE) CallService(MS_UTILS_ALLOCWINDOWLIST,0,0);
-
- CreateServiceFunction(MS_TB_ADDBUTTON,svcToolBarAddButton);
- CreateServiceFunction(MS_TB_REMOVEBUTTON, svcToolBarRemoveButton);
-
- CreateServiceFunction(MS_TB_SETBUTTONSTATE, svcToolBarSetButtonState);
- CreateServiceFunction(MS_TB_SETBUTTONSTATEBYID, svcToolBarSetButtonStateById);
-
- CreateServiceFunction(MS_TB_GETBUTTONSTATE, svcToolBarGetButtonState);
- CreateServiceFunction(MS_TB_GETBUTTONSTATEBYID, svcToolBarGetButtonStateById);
-
- HWND hwndClist = (HWND) CallService(MS_CLUI_GETHWND,0,0);
- sttCreateToolBarFrame( hwndClist, ("ToolBar"), 24);
-
- NotifyEventHooks(g_CluiData.hEventToolBarModuleLoaded, 0, 0);
-
- return 0;
-}
-
-static int ehhToolBarSystemShutdown(WPARAM wParam, LPARAM lParam)
-{
- //Remove services;
- EnterCriticalSection(&tbdat.cs);
- g_CluiData.hEventToolBarModuleLoaded = NULL;
-
- li_ListDestruct(tbdat.listOfButtons,delete_MTB_BUTTONINFO);
-
- LeaveCriticalSection(&tbdat.cs);
- DeleteCriticalSection(&tbdat.cs);
-
- return 0;
-}
-
-static int ehhToolBarSettingsChanged( WPARAM wParam, LPARAM lParam )
-{
- DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam;
- if ((HANDLE)wParam != NULL) return 0;
- if ( !mir_strcmp(cws->szModule,"CList"))
- {
- if ( !mir_strcmp(cws->szSetting,"HideOffline"))
- sttSetButtonPressed("ShowHideOffline", (BOOL) db_get_b(NULL, "CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT));
- else if ( !mir_strcmp(cws->szSetting,"UseGroups"))
- sttSetButtonPressed( "UseGroups", (BOOL) db_get_b(NULL, "CList", "UseGroups", SETTING_USEGROUPS_DEFAULT));
- }
- else if ( !mir_strcmp(cws->szModule,"Skin"))
- {
- if ( !mir_strcmp(cws->szSetting,"UseSound"))
- sttSetButtonPressed( "EnableSounds", (BOOL) db_get_b(NULL, "Skin", "UseSound", SETTING_ENABLESOUNDS_DEFAULT ));
- }
-
- return 0;
-}
-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 ( !DBGetContactSettingString(NULL,"ToolBar","BkBitmap",&dbv)) {
- tbdat.mtb_hBmpBackground = (HBITMAP)CallService(MS_UTILS_LOADBITMAP,0,(LPARAM)dbv.pszVal);
- db_free(&dbv);
- }
- }
- tbdat.mtb_useWinColors = db_get_b(NULL, "ToolBar", "UseWinColours", CLCDEFAULT_USEWINDOWSCOLOURS);
- tbdat.mtb_backgroundBmpUse = db_get_w(NULL, "ToolBar", "BkBmpUse", CLCDEFAULT_BKBMPUSE);
- }
- PostMessage(pcli->hwndContactList,WM_SIZE,0,0);
- return 0;
-}
-
-static int ehhToolbarOptInit(WPARAM wParam, LPARAM lParam)
-{
- OPTIONSDIALOGPAGE odp = { 0 };
- odp.cbSize = sizeof(odp);
- odp.position = 0;
- odp.hInstance = g_hInst;
- odp.pszGroup = LPGEN("Contact List");
- odp.pszTitle = LPGEN("ToolBar");
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_TOOLBAR);
- odp.pfnDlgProc = (DLGPROC)ToolBar_OptDlgProc;
- odp.flags = ODPF_BOLDGROUPS;
- Options_AddPage(wParam, &odp);
- return 0;
-}
-static INT_PTR svcToolBarAddButton(WPARAM wParam, LPARAM lParam)
-{
- INT_PTR result = 0;
- BYTE bVisible;
- BYTE bPanel;
- DWORD dwOrder;
- TBButton * bi = (TBButton *)lParam;
- bVisible = (bi->tbbFlags&TBBF_VISIBLE ? TRUE : FALSE);
- if ( !ServiceExists(bi->pszServiceName))
- return 0;
- tbcheck 0;
- tblock;
- {
-
- MTB_BUTTONINFO * mtbi = (MTB_BUTTONINFO *)mir_calloc(sizeof(MTB_BUTTONINFO));
- sttTBButton2MTBBUTTONINFO(bi,mtbi);
-
- sttGetButtonSettings(mtbi->szButtonID, &bVisible, &dwOrder, &bPanel);
- mtbi->nOrderValue = dwOrder ? dwOrder : bi->defPos;
- mtbi->bVisible = bVisible;
- mtbi->bPanelID = bPanel;
-
- List_InsertPtr(tbdat.listOfButtons,mtbi);
-
- if (mtbi->bVisible)
- result = (INT_PTR)ToolBar_AddButtonToBars(mtbi);
- }
- tbunlock;
- return result;
-}
-static INT_PTR svcToolBarRemoveButton(WPARAM wParam, LPARAM lParam)
-{
- HANDLE hButton = (HANDLE)wParam;
- tbcheck 0;
- tblock;
- WindowList_Broadcast(tbdat.hToolBarWindowList, MTBM_REMOVEBUTTON, wParam, lParam);
- tbunlock;
- return 0;
-}
-static INT_PTR svcToolBarGetButtonState(WPARAM wParam, LPARAM lParam)
-{
- int res = -1;
- WindowList_Broadcast(tbdat.hToolBarWindowList, MTBM_GETBUTTONSTATE, wParam, (LPARAM) &res);
- return res;
-}
-static INT_PTR svcToolBarGetButtonStateById(WPARAM wParam, LPARAM lParam)
-{
- int res = -1;
- WindowList_Broadcast(tbdat.hToolBarWindowList, MTBM_GETBUTTONSTATEBYID, wParam, (LPARAM) &res);
- return res;
-}
-static INT_PTR svcToolBarSetButtonState(WPARAM wParam, LPARAM lParam)
-{
- WindowList_Broadcast(tbdat.hToolBarWindowList, MTBM_SETBUTTONSTATE, wParam, lParam);
- return 0;
-}
-
-static INT_PTR svcToolBarSetButtonStateById(WPARAM wParam, LPARAM lParam)
-{
- WindowList_Broadcast(tbdat.hToolBarWindowList, MTBM_SETBUTTONSTATEBYID, wParam, lParam);
- return 0;
-}
-
-static void sttTBButton2MTBBUTTONINFO(TBButton * bi, MTB_BUTTONINFO * mtbi)
-{
- // Convert TBButton struct to MTB_BUTTONINFO
- if ( !bi || !mtbi) return;
- if ( !(bi->tbbFlags&TBBF_ISSEPARATOR))
- {
- mtbi->szButtonName = mir_strdup(bi->pszButtonName);
- mtbi->szService = mir_strdup(bi->pszServiceName);
- mtbi->szButtonID = mir_strdup(bi->pszButtonID);
- mtbi->bPushButton = (bi->tbbFlags&TBBF_PUSHED)?TRUE:FALSE;
- mtbi->szTooltip = mir_a2t(Translate(bi->pszTooltipUp));
- mtbi->szTooltipPressed = mir_a2t(Translate(bi->pszTooltipDn));
- mtbi->bSeparator = SEPARATOR_NOT;
- mtbi->hPrimaryIconHandle = bi->hPrimaryIconHandle;
- mtbi->hSecondaryIconHandle = bi->hSecondaryIconHandle;
- mtbi->lParam = bi->lParam;
- }
- else
- {
- mtbi->nOrderValue = bi->defPos;
- mtbi->bSeparator = (((bi->tbbFlags & TBBF_FLEXSIZESEPARATOR) == TBBF_FLEXSIZESEPARATOR)? SEPARATOR_FLEX :
- ((bi->tbbFlags & TBBF_ISSEPARATOR) == TBBF_ISSEPARATOR)? SEPARATOR_FIXED : SEPARATOR_NOT);
- }
- mtbi->bVisible = ((bi->tbbFlags&TBBF_VISIBLE) != 0);
-}
-static void sttUpdateButtonState(MTB_BUTTONINFO * mtbi)
-{
- HANDLE ilIcon;
- ilIcon = (mtbi->bPushButton)?mtbi->hSecondaryIconHandle:mtbi->hPrimaryIconHandle;
- SendMessage(mtbi->hWindow, MBM_SETICOLIBHANDLE, 0, (LPARAM) ilIcon );
- SendMessage(mtbi->hWindow, BUTTONADDTOOLTIP, (WPARAM)((mtbi->bPushButton) ? mtbi->szTooltipPressed : mtbi->szTooltip), 0);
-
-}
-static int sttSortButtons(const void * vmtbi1, const void * vmtbi2)
-{
- MTB_BUTTONINFO * mtbi1 = (MTB_BUTTONINFO *)*((MTB_BUTTONINFO ** )vmtbi1);
- MTB_BUTTONINFO * mtbi2 = (MTB_BUTTONINFO *)*((MTB_BUTTONINFO ** )vmtbi2);
- if (mtbi1 == NULL || mtbi2 == NULL) return (mtbi1-mtbi2);
- return mtbi1->nOrderValue-mtbi2->nOrderValue;
-}
-
-static int sttReposButtons(MTBINFO * mti)
-{
- RECT rcClient;
- HDWP hdwp;
- int nBarSize;
- int nFlexSeparatorsCount = 0;
- int nUsedWidth = 0;
- int i=0;
- int nextX = 0;
- int nFreeSpace;
- BOOL bWasButttonBefore = FALSE;
- int iFirstButtonId = 0;
- int iLastButtonId = 0;
- int y = 0;
-// firstly let sort it by order
- qsort(mti->pButtonList->items,mti->pButtonList->realCount,sizeof(MTB_BUTTONINFO *),sttSortButtons);
-
- GetClientRect(mti->hWnd, &rcClient);
- nBarSize = rcClient.right-rcClient.left;
- if (nBarSize == 0) return 0;
- mti->nLineCount = 0;
- hdwp = BeginDeferWindowPos( mti->pButtonList->realCount );
- do
- {
- ++mti->nLineCount;
- bWasButttonBefore = FALSE;
- nUsedWidth = 0;
- //calculating count of visible buttons and separators in line
- for (i = iFirstButtonId; i < mti->pButtonList->realCount; i++)
- {
-
- MTB_BUTTONINFO * mtbi = (MTB_BUTTONINFO *)mti->pButtonList->items[i];
- if ( mtbi->bSeparator == 2 )
- nFlexSeparatorsCount++;
- else
- {
- int width = (mtbi->bSeparator == 1)? 4 : mti->nButtonWidth+(bWasButttonBefore ? mti->nButtonSpace : 0);
- if (nUsedWidth+width>nBarSize) break;
- nUsedWidth += width;
- }
- iLastButtonId = i+1;
- bWasButttonBefore = (mtbi->bSeparator == 0) ? TRUE : FALSE;
- }
-
- nFreeSpace = nBarSize-nUsedWidth;
-
- for (i = iFirstButtonId; i < iLastButtonId; i++)
- {
- MTB_BUTTONINFO * mtbi = (MTB_BUTTONINFO *)mti->pButtonList->items[i];
- if (mtbi->hWindow)
- {
- if (hdwp)
- {
- //if (nextX+mti->nButtonWidth +mti->nButtonSpace <= nBarSize)
- hdwp = DeferWindowPos(hdwp, mtbi->hWindow, NULL, nextX, y, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_SHOWWINDOW/*|SWP_NOREDRAW*/);
- //else break;
-// hdwp = DeferWindowPos(hdwp, mtbi->hWindow, NULL, nextX, y, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_HIDEWINDOW|SWP_NOREDRAW);
- }
- nextX += mti->nButtonWidth+mti->nButtonSpace;
- }
- else if ( mtbi->bSeparator == 1 )
- {
- nextX += 4;
- }
- else if (nFlexSeparatorsCount>0)
- {
- nextX += nFreeSpace/nFlexSeparatorsCount;
- nFreeSpace -= nFreeSpace/nFlexSeparatorsCount;
- nFlexSeparatorsCount--;
- }
- }
- if ( iFirstButtonId == iLastButtonId )
- break;
- iFirstButtonId = iLastButtonId;
-
- y += mti->nButtonHeight+mti->nButtonSpace;
- nextX = 0;
- if (mti->fSingleLine) break;
- } while (iFirstButtonId < mti->pButtonList->realCount && y >= 0 && (mti->fAutoSize || (y+mti->nButtonHeight <= rcClient.bottom-rcClient.top)));
- for (i = iFirstButtonId; i < mti->pButtonList->realCount; i++)
- {
- MTB_BUTTONINFO * mtbi = (MTB_BUTTONINFO *)mti->pButtonList->items[i];
- if (mtbi->hWindow && hdwp)
- {
- hdwp = DeferWindowPos(hdwp, mtbi->hWindow, NULL, nextX, y, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_HIDEWINDOW/*|SWP_NOREDRAW*/);
- }
- }
- if (hdwp) EndDeferWindowPos(hdwp);
- return (mti->nButtonHeight+mti->nButtonSpace)*mti->nLineCount-mti->nButtonSpace;
-}
-
-
-static HWND sttCreateToolBarFrame( HWND hwndParent, char * szCaption, int nHeight )
-{
- return CreateWindow( _T(MIRANDATOOLBARCLASSNAME), TranslateTS( _A2T(szCaption)), WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN,0,0,0,nHeight,hwndParent,NULL,g_hInst, (void*) szCaption);
-}
-
-static int sttButtonPressed(MTBINFO * pMTBInfo, HWND hwndbutton)
+static void CopySettings(const char* to, const char* from)
{
- MTB_BUTTONINFO * mtbi = (MTB_BUTTONINFO *)GetWindowLongPtr(hwndbutton, GWLP_USERDATA);
- if (mtbi && mtbi->hWindow == hwndbutton && mtbi->hwndToolBar == pMTBInfo->hWnd)
- {
- if (mtbi->szService && ServiceExists(mtbi->szService))
- return CallService(mtbi->szService, 0, mtbi->lParam);
- }
- return 0;
+ db_set_b(NULL, TTB_OPTDIR, to, db_get_b(NULL,"ModernToolBar",from, 0));
}
-static BOOL sttDrawToolBarBackground(HWND hwnd, HDC hdc, RECT * rect, MTBINFO * pMTBInfo)
+static void sttRegisterToolBarButton(char * pszButtonID, char * pszButtonName, char * pszServiceName,
+ char * pszTooltipUp, char * pszTooltipDn, int icoDefIdx, int defResource, int defResource2, BOOL bVisByDefault)
{
- 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 sttRegisterToolBarButton(char * pszButtonID, char * pszButtonName, char * pszServiceName,
- char * pszTooltipUp, char * pszTooltipDn, int icoDefIdx, int defResource, int defResource2, BOOL bVisByDefault)
-{
- TBButton tbb;
+ TTBButton tbb = { 0 };
static int defPos = 0;
defPos += 100;
- memset(&tbb,0, sizeof(TBButton));
- tbb.cbSize = sizeof(TBButton);
- if (pszButtonID)
- {
- tbb.defPos = defPos;
- tbb.pszButtonID = pszButtonID;
- tbb.pszButtonName = pszButtonName;
- tbb.pszServiceName = pszServiceName;
- tbb.pszTooltipUp = pszTooltipUp;
- tbb.pszTooltipDn = pszTooltipDn;
- {
- char buf[255];
- mir_snprintf(buf,SIZEOF(buf),"%s%s%s",TOOLBARBUTTON_ICONIDPREFIX, pszButtonID, TOOLBARBUTTON_ICONIDPRIMARYSUFFIX);
- tbb.hPrimaryIconHandle = RegisterIcolibIconHandle( buf, "ToolBar", pszButtonName , _T("icons\\toolbar_icons.dll"),-icoDefIdx, g_hInst, defResource );
- }
- if (pszTooltipDn)
- {
- char buf[255];
- mir_snprintf(buf,SIZEOF(buf),"%s%s%s",TOOLBARBUTTON_ICONIDPREFIX, pszButtonID, TOOLBARBUTTON_ICONIDSECONDARYSUFFIX);
- tbb.hSecondaryIconHandle = RegisterIcolibIconHandle( buf, "ToolBar", pszTooltipDn , _T("icons\\toolbar_icons.dll"),-(icoDefIdx+1), g_hInst, defResource2 );
- }
- }
- else
- {
- if ( pszButtonName[0] == 'D' ) tbb.tbbFlags = TBBF_FLEXSIZESEPARATOR;
- else tbb.tbbFlags = TBBF_ISSEPARATOR;
- }
- tbb.tbbFlags |= (bVisByDefault ? TBBF_VISIBLE :0 );
- CallService(MS_TB_ADDBUTTON,0, (LPARAM)&tbb);
-}
-
-static void sttSetButtonPressed( char * hButton, BOOL bPressed )
-{
- CallService(MS_TB_SETBUTTONSTATEBYID, (WPARAM) hButton, (LPARAM) (bPressed ? TBST_PUSHED : TBST_RELEASED));
-}
-static void sttAddStaticSeparator( BOOL bVisibleByDefault )
-{
- sttRegisterToolBarButton( NULL, "Separator", NULL, NULL, NULL, 0, 0, 0, bVisibleByDefault );
-}
-static void sttAddDynamicSeparator( BOOL bVisibleByDefault )
-{
- sttRegisterToolBarButton( NULL, "Dynamic separator", NULL, NULL, NULL, 0, 0, 0, bVisibleByDefault );
-}
-static void sttGetButtonSettings(char * ID, BYTE * pbVisible, DWORD * pdwOrder, BYTE * pbPanelID)
-{
- char key[255] = {0};
- BYTE vis = 1;
-
- DWORD ord;
- BYTE panel;
-
- if (pbVisible) vis = *pbVisible;
- mir_snprintf(key, SIZEOF(key), "visible_%s", ID);
- vis = db_get_b(NULL,"ModernToolBar", key, vis);
+ tbb.cbSize = sizeof(tbb);
+ tbb.dwFlags = TTBBF_ICONBYHANDLE;
+ if (pszButtonID) {
+ tbb.name = pszButtonID;
+ tbb.pszService = pszServiceName;
- mir_snprintf(key, SIZEOF(key), "order_%s", ID);
- ord = db_get_dw(NULL,"ModernToolBar", key, 0);
+ char buf[255];
+ mir_snprintf(buf,SIZEOF(buf),"%s%s%s", "TTB_", pszButtonID, "_dn");
+ tbb.hIconHandleUp = RegisterIcolibIconHandle( buf, "ToolBar", pszButtonName , _T("icons\\toolbar_icons.dll"),-icoDefIdx, g_hInst, defResource );
- mir_snprintf(key, SIZEOF(key), "panel_%s", ID);
- panel = db_get_b(NULL,"ModernToolBar", key, 0);
-
- if (pbVisible) *pbVisible = vis;
- if (pdwOrder) *pdwOrder = ord;
- if (pbPanelID) *pbPanelID = panel;
-}
-static void sttReloadButtons()
-{
- int i=0;
- tbcheck ;
- tblock;
- {
- int vis = db_get_b(NULL,"CLUI","ShowButtonBar",SETTINGS_SHOWBUTTONBAR_DEFAULT);
- WindowList_Broadcast(tbdat.hToolBarWindowList,MTBM_UPDATEFRAMEVISIBILITY,(WPARAM)db_get_b(NULL,"CLUI","ShowButtonBar",SETTINGS_SHOWBUTTONBAR_DEFAULT),0);
- }
-
- WindowList_Broadcast(tbdat.hToolBarWindowList, MTBM_REMOVE_ALL_BUTTONS, 0,0);
- for (i=0; i < tbdat.listOfButtons->realCount; i++)
- {
- BYTE bVisible;
- BYTE bPanel;
- DWORD dwOrder;
-
- MTB_BUTTONINFO * mtbi = (MTB_BUTTONINFO *)tbdat.listOfButtons->items[i];
-
- bVisible = mtbi->bVisible;
- sttGetButtonSettings(mtbi->szButtonID, &bVisible, &dwOrder, &bPanel);
-
- mtbi->nOrderValue = dwOrder ? dwOrder : mtbi->nOrderValue;
- mtbi->bVisible = bVisible;
- mtbi->bPanelID = bPanel;
-
- if (mtbi->bVisible)
- ToolBar_AddButtonToBars(mtbi);
+ if (pszTooltipDn) {
+ mir_snprintf(buf,SIZEOF(buf),"%s%s%s", "TTB_", pszButtonID, "_up");
+ tbb.hIconHandleUp = RegisterIcolibIconHandle( buf, "ToolBar", pszTooltipDn , _T("icons\\toolbar_icons.dll"),-(icoDefIdx+1), g_hInst, defResource2 );
+ }
}
- tbunlock;
- sttSetButtonPressed( "ShowHideOffline", (BOOL) db_get_b(NULL, "CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT));
- sttSetButtonPressed( "UseGroups", (BOOL) db_get_b(NULL, "CList", "UseGroups", SETTING_USEGROUPS_DEFAULT));
- sttSetButtonPressed( "EnableSounds", (BOOL) db_get_b(NULL, "Skin", "UseSound", SETTING_ENABLESOUNDS_DEFAULT ));
-
-}
-static int sttDBEnumProc (const char *szSetting,LPARAM lParam)
-{
-
- if (szSetting == NULL) return 0;
- if ( !strncmp(szSetting,"order_",6))
- db_unset(NULL, "ModernToolBar", szSetting);
- return 0;
-};
-static void sttDeleteOrderSettings()
-{
- DBCONTACTENUMSETTINGS dbces;
- dbces.pfnEnumProc = sttDBEnumProc;
- dbces.szModule = "ToolBar";
- dbces.ofsSettings = 0;
- CallService(MS_DB_CONTACT_ENUMSETTINGS,0,(LPARAM)&dbces);
-}
-static MTB_BUTTONINFO * ToolBar_AddButtonToBars(MTB_BUTTONINFO * mtbi)
-{
- int result = 0;
- if ( !mtbi->bVisible) return 0;
- WindowList_Broadcast(tbdat.hToolBarWindowList, MTBM_ADDBUTTON, (WPARAM)mtbi, 0);
- if (mtbi->hWindow)
- sttUpdateButtonState( mtbi );
- if (mtbi->hwndToolBar)
- SendMessage( mtbi->hwndToolBar, MTBM_REPOSBUTTONS, 0, 0);
- return mtbi;
-}
+ else tbb.dwFlags |= TTBBF_ISSEPARATOR;
-static int ToolBar_LayeredPaintProc(HWND hWnd, HDC hDC, RECT * rcPaint, HRGN rgn, DWORD dFlags, void * CallBackData)
-{
- return SendMessage(hWnd, MTBM_LAYEREDPAINT,(WPARAM)hDC,0);
+ tbb.dwFlags |= (bVisByDefault ? TTBBF_VISIBLE :0 );
+ CallService(MS_TTB_ADDBUTTON,0, (LPARAM)&tbb);
}
-
-
static void ToolBar_DefaultButtonRegistration()
{
-
- sttRegisterToolBarButton( "MainMenu", "Main Menu", MS_CLUI_SHOWMAINMENU,
+ sttRegisterToolBarButton( "MainMenu", "Main Menu", "CList/ShowMainMenu",
"Main menu", NULL, 100 , IDI_RESETVIEW, IDI_RESETVIEW, TRUE );
-
- sttRegisterToolBarButton( "StatusMenu", "Status Menu", MS_CLUI_SHOWSTATUSMENU,
+ sttRegisterToolBarButton( "StatusMenu", "Status Menu", "CList/ShowStatusMenu",
"Status menu", NULL, 105 , IDI_RESETVIEW, IDI_RESETVIEW, TRUE );
sttRegisterToolBarButton( "AccoMgr", "Accounts", MS_PROTO_SHOWACCMGR,
"Accounts...", NULL, 282 , IDI_ACCMGR, IDI_ACCMGR, TRUE );
sttRegisterToolBarButton( "ShowHideOffline","Show/Hide offline contacts", MS_CLIST_TOGGLEHIDEOFFLINE,
- "Hide offline contacts", "Show offline contacts", 110 /*and 111 */ , IDI_RESETVIEW, IDI_RESETVIEW, TRUE );
+ "Hide offline contacts", "Show offline contacts", 110, IDI_RESETVIEW, IDI_RESETVIEW, TRUE );
- sttSetButtonPressed( "ShowHideOffline", (BOOL) db_get_b(NULL, "CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT));
-
sttRegisterToolBarButton( "DatabaseEditor","DBEditor++", "DBEditorpp/MenuCommand",
"Database Editor", NULL, 130 , IDI_RESETVIEW, IDI_RESETVIEW, TRUE );
@@ -714,611 +95,32 @@ static void ToolBar_DefaultButtonRegistration()
"Options", NULL, 150 , IDI_RESETVIEW, IDI_RESETVIEW, TRUE );
sttRegisterToolBarButton( "UseGroups","Use/Disable groups", MS_CLIST_TOGGLEGROUPS,
- "Use groups", "Disable Groups", 160 /*and 161 */ , IDI_RESETVIEW, IDI_RESETVIEW, FALSE );
-
- sttSetButtonPressed( "UseGroups", (BOOL) db_get_b(NULL, "CList", "UseGroups", SETTING_USEGROUPS_DEFAULT));
+ "Use groups", "Disable Groups", 160, IDI_RESETVIEW, IDI_RESETVIEW, FALSE );
sttRegisterToolBarButton( "EnableSounds","Enable/Disable sounds", MS_CLIST_TOGGLESOUNDS,
- "Enable sounds", "Disable Sounds", 170 /*and 171 */ , IDI_RESETVIEW, IDI_RESETVIEW, FALSE );
+ "Enable sounds", "Disable Sounds", 170, IDI_RESETVIEW, IDI_RESETVIEW, FALSE );
- sttSetButtonPressed( "EnableSounds", (BOOL) db_get_b(NULL, "Skin", "UseSound", SETTING_ENABLESOUNDS_DEFAULT ));
-
- sttAddDynamicSeparator(FALSE);
-
sttRegisterToolBarButton( "Minimize","Minimize", "CList/ShowHide",
"Minimize", NULL, 180 , IDI_RESETVIEW, IDI_RESETVIEW, FALSE );
-
- sttReloadButtons();
}
-static void sttDrawNonLayeredSkinedBar(HWND hwnd, HDC hdc)
-{
- HDC hdc2;
- HBITMAP hbmp,hbmpo;
- RECT rc = {0};
- GetClientRect(hwnd,&rc);
- rc.right++;
- rc.bottom++;
- hdc2 = CreateCompatibleDC(hdc);
- hbmp = ske_CreateDIB32(rc.right,rc.bottom);
- 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 ToolBar_WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
-{
- static BOOL supressRepos = FALSE;
- MTBINFO * pMTBInfo = (MTBINFO *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- switch (msg)
- {
- case WM_CREATE:
- {
- HANDLE hFrame = NULL;
- CLISTFrame Frame = {0};
- CREATESTRUCT * lpcs = (CREATESTRUCT *) lParam;
- //create internal info
- MTBINFO * pMTBInfo = (MTBINFO *) mir_calloc( sizeof(MTBINFO));
- pMTBInfo->cbSize = sizeof(MTBINFO);
- SetWindowLongPtr( hwnd, GWLP_USERDATA, (LONG_PTR) pMTBInfo );
-
- pMTBInfo->nButtonWidth = db_get_b(NULL, "ModernToolBar", "option_Bar0_BtnWidth", SETTINGS_BARBTNWIDTH_DEFAULT);
- pMTBInfo->nButtonHeight = db_get_b(NULL, "ModernToolBar", "option_Bar0_BtnHeight", SETTINGS_BARBTNHEIGHT_DEFAULT);
- pMTBInfo->nButtonSpace = db_get_b(NULL, "ModernToolBar", "option_Bar0_BtnSpace", SETTINGS_BARBTNSPACE_DEFAULT);
- pMTBInfo->fAutoSize = db_get_b(NULL, "ModernToolBar", "option_Bar0_Autosize", SETTINGS_BARAUTOSIZE_DEFAULT);
- pMTBInfo->fSingleLine = db_get_b(NULL, "ModernToolBar", "option_Bar0_Multiline", SETTINGS_BARMULTILINE_DEFAULT) == 0;
- //register self frame
- Frame.cbSize = sizeof(CLISTFrame);
- Frame.hWnd = hwnd;
- Frame.align = alTop;
- Frame.hIcon = LoadSkinnedIcon (SKINICON_OTHER_MIRANDA);
- Frame.Flags = (db_get_b(NULL,"CLUI","ShowButtonBar",SETTINGS_SHOWBUTTONBAR_DEFAULT)?F_VISIBLE:0)|F_LOCKED|F_NOBORDER|F_NO_SUBCONTAINER;
-
- Frame.height = db_get_dw(NULL, "ModernToolBar", "option_Bar0_OldHeight", pMTBInfo->nButtonHeight);
- pMTBInfo->wLastHeight = Frame.height;
-
- pMTBInfo->nLineCount = 1;
- pMTBInfo->pButtonList = List_Create(0,1);
-
- Frame.name = (char*) lpcs->lpCreateParams;
- hFrame = (HANDLE)CallService(MS_CLIST_FRAMES_ADDFRAME,(WPARAM)&Frame,(LPARAM)0);
- CallService(MS_SKINENG_REGISTERPAINTSUB,(WPARAM)Frame.hWnd,(LPARAM)ToolBar_LayeredPaintProc); //$$$$$ register sub for frame
- pMTBInfo->hFrame = hFrame;
- pMTBInfo->hWnd = hwnd;
-
-
-
- //add self to window list
- WindowList_Add(tbdat.hToolBarWindowList, hwnd, NULL);
- pMTBInfo->mtbXPTheme = xpt_AddThemeHandle(hwnd,L"TOOLBAR");
- ToolBar_DefaultButtonRegistration();
- //SetTimer(hwnd,123,1000,NULL);
- return 0;
- }
- case WM_TIMER:
- {
-
- //KillTimer(hwnd,123);
- //ToolBar_DefaultButtonRegistration();
- return 0;
- }
- case WM_SHOWWINDOW:
- {
- {
- int res;
- int ID;
- ID = Sync( FindFrameID, hwnd );
- if (ID)
- {
- res = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS,ID),0);
- if (res >= 0) db_set_b(0,"CLUI","ShowButtonBar",(BYTE)(wParam/*(res&F_VISIBLE)*/?1:0));
- if (wParam) SendMessage(hwnd, MTBM_REPOSBUTTONS, 0, 0);
- }
- }
- break;
- }
- case MTBM_UPDATEFRAMEVISIBILITY:
- {
- BOOL vis = (BOOL)wParam;
- INT_PTR frameopt;
- BOOL curvis = IsWindowVisible(hwnd);
- BOOL bResize = FALSE;
- int frameID = Sync( FindFrameID, hwnd );
- int Height;
-
- pMTBInfo->nButtonWidth = db_get_b(NULL, "ModernToolBar", "option_Bar0_BtnWidth", SETTINGS_BARBTNWIDTH_DEFAULT);
- pMTBInfo->nButtonHeight = db_get_b(NULL, "ModernToolBar", "option_Bar0_BtnHeight", SETTINGS_BARBTNHEIGHT_DEFAULT);
- pMTBInfo->nButtonSpace = db_get_b(NULL, "ModernToolBar", "option_Bar0_BtnSpace", SETTINGS_BARBTNSPACE_DEFAULT);
- pMTBInfo->fAutoSize = db_get_b(NULL, "ModernToolBar", "option_Bar0_Autosize", SETTINGS_BARAUTOSIZE_DEFAULT);
- pMTBInfo->fSingleLine = db_get_b(NULL, "ModernToolBar", "option_Bar0_Multiline", SETTINGS_BARMULTILINE_DEFAULT) == 0;
-
- Height = sttReposButtons( pMTBInfo );
-
- if (pMTBInfo->fAutoSize)
- {
- frameopt = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT,frameID),0);
- if (Height != frameopt)
- {
- frameopt = Height;
- CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_HEIGHT,frameID),frameopt);
- bResize = TRUE;
- }
- }
-
- if ((curvis != vis || bResize) && vis != -1)
- {
- frameopt = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS,frameID),0);
- frameopt &= ~F_VISIBLE;
- frameopt |= vis ? F_VISIBLE : 0;
- CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_FLAGS,frameID),frameopt);
- }
- break;
- }
- case WM_DESTROY:
- {
- xpt_FreeThemeForWindow(hwnd);
- WindowList_Remove( tbdat.hToolBarWindowList, hwnd );
- SendMessage(hwnd, MTBM_REMOVE_ALL_BUTTONS, 0, 0 );
- List_Destroy( pMTBInfo->pButtonList );
- mir_free( pMTBInfo->pButtonList );
- SetWindowLongPtr( hwnd, GWLP_USERDATA, 0 );
- mir_free( pMTBInfo );
- return 0;
- }
- case WM_COMMAND:
- {
- if (HIWORD(wParam) == BN_CLICKED && lParam != 0 )
- sttButtonPressed(pMTBInfo, (HWND) lParam );
- return TRUE;
- }
- case MTBM_ADDBUTTON:
- {
- //Adding button
- MTB_BUTTONINFO * mtbi = (MTB_BUTTONINFO * )wParam;
- HWND hwndButton = NULL;
- if ( !(mtbi->bSeparator))
- hwndButton = CreateWindow(SKINBUTTONCLASS /*MIRANDABUTTONCLASS*/, _T(""), BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | WS_TABSTOP , 0, 0, pMTBInfo->nButtonWidth, pMTBInfo->nButtonHeight,
- hwnd, (HMENU) NULL, g_hInst, NULL);
- mtbi->hWindow = hwndButton;
- mtbi->hwndToolBar = hwnd;
-
- List_Insert(pMTBInfo->pButtonList, mtbi, pMTBInfo->pButtonList->realCount); //just insert pointer. such object are managed in global tbbutton list
- if (hwndButton)
- {
- char * buttonId = (char *)_alloca(sizeof("ToolBar.")+strlen(mtbi->szButtonID)+2);
- strcpy(buttonId,"ToolBar.");
- strcat(buttonId,mtbi->szButtonID);
- SendMessage(hwndButton, BUTTONSETID, 0 ,(LPARAM) buttonId );
- if (pMTBInfo->bFlatButtons)
- SendMessage(hwndButton, BUTTONSETASFLATBTN, TRUE, 0 );
- SetWindowLongPtr(hwndButton,GWLP_USERDATA,(LONG_PTR)mtbi);
- SendMessage(hwndButton, MBM_UPDATETRANSPARENTFLAG, 0, 2);
- }
- return (LRESULT)hwndButton;
- }
-
- case MTBM_REMOVE_ALL_BUTTONS:
- {
- int i;
- for (i=0; i < pMTBInfo->pButtonList->realCount; i++ )
- {
- MTB_BUTTONINFO * mtbi = (MTB_BUTTONINFO *)pMTBInfo->pButtonList->items[i];
- if (mtbi->hWindow && mtbi->hwndToolBar == hwnd)
- {
- DestroyWindow(mtbi->hWindow);
- mtbi->hWindow = NULL;
- mtbi->hwndToolBar = NULL;
- }
- }
- List_Destroy( pMTBInfo->pButtonList );
- mir_free( pMTBInfo->pButtonList );
- pMTBInfo->pButtonList = List_Create(0,1);
- break;
- }
- case WM_SIZE:
- if (pMTBInfo->wLastHeight != HIWORD(lParam))
- {
- db_set_dw(NULL, "ModernToolBar", "option_Bar0_OldHeight", HIWORD(lParam));
- pMTBInfo->wLastHeight = HIWORD(lParam);
- }
- if (supressRepos)
- {
- supressRepos = FALSE;
- break;
- }
- //fall through
- case MTBM_REPOSBUTTONS:
- {
- if (pMTBInfo && pMTBInfo->hWnd == hwnd)
- {
- int Height = sttReposButtons(pMTBInfo);
- if ( pMTBInfo->fAutoSize)
- {
- RECT rcClient;
- GetClientRect(pMTBInfo->hWnd, &rcClient);
- if (rcClient.bottom-rcClient.top != Height && Height)
- {
- supressRepos = TRUE;
- PostMessage(pMTBInfo->hWnd,MTBM_UPDATEFRAMEVISIBILITY, -1, 0);
- }
- }
-
- return 0;
- }
- break;
- }
- case WM_ERASEBKGND:
- if (g_CluiData.fDisableSkinEngine)
- return sttDrawToolBarBackground(hwnd, (HDC)wParam, NULL, pMTBInfo);
- else
- return 0;
-
- case WM_NCPAINT:
- case WM_PAINT:
- {
- BOOL ret = FALSE;
- 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
- ret = sttDrawToolBarBackground(hwnd, ps.hdc, &ps.rcPaint, pMTBInfo);
- EndPaint(hwnd,&ps);
- }
-
- return DefWindowProc(hwnd, msg, wParam, lParam);
- }
- case WM_NOTIFY:
- {
- if (((LPNMHDR) lParam)->code == BUTTONNEEDREDRAW)
- pcli->pfnInvalidateRect(hwnd, NULL, FALSE);
- return 0;
- }
- 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;
- MTB_BUTTONINFO * mtbi = (MTB_BUTTONINFO *)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 0;
- }
- case MTBM_SETBUTTONSTATEBYID:
- case MTBM_SETBUTTONSTATE:
- {
- char * hButtonId = (msg == MTBM_SETBUTTONSTATEBYID) ? (char *) wParam : NULL;
- void * hButton = (msg == MTBM_SETBUTTONSTATE) ? (void *)wParam : NULL;
- MTB_BUTTONINFO *mtbi = NULL;
- int i;
- for (i=0; i < pMTBInfo->pButtonList->realCount; i++)
- {
- mtbi = (MTB_BUTTONINFO*)pMTBInfo->pButtonList->items[i];
- if ((hButtonId && !strcmp(mtbi->szButtonID, hButtonId)) || (hButton == mtbi))
- {
- mtbi->bPushButton = (BOOL)lParam;
- sttUpdateButtonState(mtbi);
- pcli->pfnInvalidateRect(hwnd, NULL, FALSE);
- break;
- }
- }
- break;
- }
- case MTBM_GETBUTTONSTATEBYID:
- case MTBM_GETBUTTONSTATE:
- {
- int * res = (int*)lParam;
- if (res == NULL) break;
- char * hButtonId = (msg == MTBM_GETBUTTONSTATEBYID) ? (char *) wParam : NULL;
- void * hButton = (msg == MTBM_GETBUTTONSTATE) ? (void *)wParam : NULL;
- MTB_BUTTONINFO *mtbi = NULL;
- int i;
- for (i=0; i < pMTBInfo->pButtonList->realCount; i++)
- {
- mtbi = (MTB_BUTTONINFO*)pMTBInfo->pButtonList->items[i];
- if ((hButtonId && !strcmp(mtbi->szButtonID, hButtonId)) || (hButton == mtbi))
- {
- *res = 0;
- *res |= mtbi->bPushButton ? TBST_PUSHED : TBST_RELEASED;
- break;
- }
- }
- break;
- }
-
- case MTBM_REMOVEBUTTON:
- {
- MTB_BUTTONINFO *mtbi = NULL;
- for (int i=0; i < pMTBInfo->pButtonList->realCount; i++)
- {
- mtbi = (MTB_BUTTONINFO*)pMTBInfo->pButtonList->items[i];
- if (mtbi == (MTB_BUTTONINFO*)wParam)
- {
- List_Remove(pMTBInfo->pButtonList,i);
- for (int j = 0; j < tbdat.listOfButtons->realCount; j++)
- if (mtbi == (MTB_BUTTONINFO*)tbdat.listOfButtons->items[j])
- {
- List_Remove(tbdat.listOfButtons,j);
- break;
- }
- List_RemovePtr(tbdat.listOfButtons,mtbi);
- delete_MTB_BUTTONINFO((void*)mtbi);
- mtbi = NULL;
- pcli->pfnInvalidateRect(hwnd, NULL, FALSE);
- break;
- }
- }
- break;
- }
- default :
- return DefWindowProc(hwnd, msg, wParam, lParam);
- }
- return TRUE;
-}
-static int ControlIDS[] = {IDC_TEXT_W, IDC_SPIN_W, IDC_STATIC_W, IDC_TEXT_H,
- IDC_SPIN_H, IDC_STATIC_H,IDC_TEXT_S, IDC_SPIN_S,
- IDC_STATIC_S, IDC_BTNORDER, IDC_CHECK_MULTILINE, IDC_CHECK_AUTOSIZE };
-
-static LRESULT CALLBACK ToolBar_OptDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
+HRESULT ToolbarLoadModule()
{
- static HIMAGELIST himlButtonIcons = NULL;
- static BOOL dragging = FALSE;
- static HANDLE hDragItem = NULL;
- switch (msg)
- {
- case WM_DESTROY:
- ImageList_Destroy(himlButtonIcons);
- break;
- case WM_INITDIALOG:
- {
- HWND hTree = GetDlgItem(hwndDlg,IDC_BTNORDER);
- TranslateDialogDefault(hwndDlg);
- SetWindowLongPtr(hTree,GWL_STYLE,GetWindowLongPtr(hTree,GWL_STYLE)|TVS_NOHSCROLL);
- {
- himlButtonIcons = ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),ILC_COLOR32|ILC_MASK,2,2);
- TreeView_SetImageList(hTree,himlButtonIcons,TVSIL_NORMAL);
- }
- TreeView_DeleteAllItems(hTree);
- tblock;
-
- qsort(tbdat.listOfButtons->items,tbdat.listOfButtons->realCount,sizeof(MTB_BUTTONINFO *),sttSortButtons);
- {
- int i=0;
- for (i=0; i < tbdat.listOfButtons->realCount; i++)
- {
- TVINSERTSTRUCT tvis = {0};
- HTREEITEM hti;
- MTB_BUTTONINFO * mtbi = (MTB_BUTTONINFO*) tbdat.listOfButtons->items[i];
- TCHAR * szTempName = mir_a2t(mtbi->szButtonName);
- HICON hIcon = (HICON)CallService(MS_SKIN2_GETICONBYHANDLE, 0, (LPARAM)mtbi->hPrimaryIconHandle);
- int index = ImageList_AddIcon(himlButtonIcons, hIcon);
- CallService(MS_SKIN2_RELEASEICON, (WPARAM)hIcon, 0);
- tvis.hParent = NULL;
- tvis.hInsertAfter = TVI_LAST;
- tvis.item.mask = TVIF_PARAM|TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_STATE;
- tvis.item.lParam = (LPARAM)(mtbi);
- tvis.item.pszText = TranslateTS(szTempName);
- tvis.item.iImage = tvis.item.iSelectedImage = index;
- hti = TreeView_InsertItem(hTree,&tvis);
- TreeView_SetCheckState(hTree, hti, mtbi->bVisible );
- mir_free(szTempName);
- }
- }
- tbunlock;
-
- SendDlgItemMessage(hwndDlg,IDC_SPIN_W,UDM_SETRANGE,0,MAKELONG(50,10));
- SendDlgItemMessage(hwndDlg,IDC_SPIN_W,UDM_SETPOS,0,MAKELONG(db_get_b(NULL, "ModernToolBar", "option_Bar0_BtnWidth", SETTINGS_BARBTNWIDTH_DEFAULT),0));
-
- SendDlgItemMessage(hwndDlg,IDC_SPIN_H,UDM_SETRANGE,0,MAKELONG(50,10));
- SendDlgItemMessage(hwndDlg,IDC_SPIN_H,UDM_SETPOS,0,MAKELONG(db_get_b(NULL, "ModernToolBar", "option_Bar0_BtnHeight", SETTINGS_BARBTNHEIGHT_DEFAULT),0));
-
- SendDlgItemMessage(hwndDlg,IDC_SPIN_S,UDM_SETRANGE,0,MAKELONG(20,0));
- SendDlgItemMessage(hwndDlg,IDC_SPIN_S,UDM_SETPOS,0,MAKELONG(db_get_b(NULL, "ModernToolBar", "option_Bar0_BtnSpace", SETTINGS_BARBTNSPACE_DEFAULT),0));
+ if ( db_get_b(NULL, "CLUI", "ShowButtonBar", -1) != -1) {
+ CopySettings("BUTTWIDTH", "option_Bar0_BtnWidth");
+ CopySettings("BUTTHEIGHT", "option_Bar0_BtnHeight");
+ CopySettings("BUTTGAP", "option_Bar0_BtnSpace");
+ CopySettings("BUTTAUTOSIZE", "option_Bar0_Autosize");
+ CopySettings("BUTTMULTI", "option_Bar0_Multiline");
- CheckDlgButton(hwndDlg, IDC_CHECK_AUTOSIZE, db_get_b(NULL, "ModernToolBar", "option_Bar0_Autosize", SETTINGS_BARAUTOSIZE_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHECK_MULTILINE, db_get_b(NULL,"ModernToolBar", "option_Bar0_Multiline", SETTINGS_BARMULTILINE_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
+ db_unset(NULL, "CLUI", "ShowButtonBar");
- CheckDlgButton(hwndDlg, IDC_TBSHOW, db_get_b(NULL,"CLUI","ShowButtonBar",SETTINGS_SHOWBUTTONBAR_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
- {
- int i;
- BOOL en = IsDlgButtonChecked(hwndDlg,IDC_TBSHOW);
- for (i=0; i < SIZEOF(ControlIDS); i++)
- EnableWindow(GetDlgItem(hwndDlg,ControlIDS[i]), en);
- }
- return TRUE;
- }
+ CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)"ModernToolBar");
- case WM_NOTIFY:
- {
- switch(((LPNMHDR)lParam)->idFrom)
- {
- case 0:
- {
- switch (((LPNMHDR)lParam)->code)
- {
- case PSN_APPLY:
- {
- int order = 100;
- HWND hTree = GetDlgItem(hwndDlg,IDC_BTNORDER);
- int count = TreeView_GetCount(hTree);
- HTREEITEM hItem;
- sttDeleteOrderSettings();
- hItem = TreeView_GetRoot(hTree);
- do
- {
- TVITEM tvi = {0};
- MTB_BUTTONINFO *mtbi;
- tvi.mask = TBIF_LPARAM|TVIF_HANDLE;
- tvi.hItem = hItem;
- TreeView_GetItem(hTree, &tvi);
- mtbi = (MTB_BUTTONINFO *)tvi.lParam;
- if (mtbi)
- {
- char szTempSetting[200];
- mir_snprintf(szTempSetting, SIZEOF(szTempSetting), "order_%s", mtbi->szButtonID);
- db_set_dw(NULL, "ModernToolBar", szTempSetting, order);
- order += 10;
- mir_snprintf(szTempSetting, SIZEOF(szTempSetting), "visible_%s", mtbi->szButtonID);
- db_set_b(NULL, "ModernToolBar", szTempSetting, TreeView_GetCheckState(hTree,hItem));
- }
- hItem = TreeView_GetNextSibling(hTree,hItem);
- } while (hItem != NULL);
- db_set_b(NULL,"CLUI","ShowButtonBar",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_TBSHOW));
- db_set_b(NULL,"ModernToolBar","option_Bar0_BtnWidth", (BYTE)SendDlgItemMessage(hwndDlg,IDC_SPIN_W,UDM_GETPOS,0,0));
- db_set_b(NULL,"ModernToolBar","option_Bar0_BtnHeight",(BYTE)SendDlgItemMessage(hwndDlg,IDC_SPIN_H,UDM_GETPOS,0,0));
- db_set_b(NULL,"ModernToolBar","option_Bar0_BtnSpace", (BYTE)SendDlgItemMessage(hwndDlg,IDC_SPIN_S,UDM_GETPOS,0,0));
- db_set_b(NULL, "ModernToolBar", "option_Bar0_Autosize", (BYTE)IsDlgButtonChecked(hwndDlg,IDC_CHECK_AUTOSIZE));
- db_set_b(NULL,"ModernToolBar", "option_Bar0_Multiline", (BYTE)IsDlgButtonChecked(hwndDlg,IDC_CHECK_MULTILINE));
-
- sttReloadButtons();
- return TRUE;
- }
- }
- break;
- }
- case IDC_BTNORDER:
- {
- switch (((LPNMHDR)lParam)->code)
- {
- case TVN_BEGINDRAGA:
- case TVN_BEGINDRAGW:
- SetCapture(hwndDlg);
- dragging = TRUE;
- hDragItem = ((LPNMTREEVIEWA)lParam)->itemNew.hItem;
- TreeView_SelectItem(GetDlgItem(hwndDlg,IDC_BTNORDER),hDragItem);
- break;
- case NM_CLICK:
- {
- TVHITTESTINFO hti;
- hti.pt.x = (short)LOWORD(GetMessagePos());
- hti.pt.y = (short)HIWORD(GetMessagePos());
- ScreenToClient(((LPNMHDR)lParam)->hwndFrom,&hti.pt);
- if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom,&hti))
- if (hti.flags&TVHT_ONITEMSTATEICON)
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
- };
- }
- break;
- }
- }
- break;
- }
- case WM_MOUSEMOVE:
- {
- if ( !dragging) break;
- {
- TVHITTESTINFO hti;
- hti.pt.x = (short)LOWORD(lParam);
- hti.pt.y = (short)HIWORD(lParam);
- ClientToScreen(hwndDlg,&hti.pt);
- ScreenToClient(GetDlgItem(hwndDlg,IDC_BTNORDER),&hti.pt);
- TreeView_HitTest(GetDlgItem(hwndDlg,IDC_BTNORDER),&hti);
- if (hti.flags&(TVHT_ONITEM|TVHT_ONITEMRIGHT))
- {
- HTREEITEM it = hti.hItem;
- hti.pt.y -= TreeView_GetItemHeight(GetDlgItem(hwndDlg,IDC_BTNORDER))/2;
- TreeView_HitTest(GetDlgItem(hwndDlg,IDC_BTNORDER),&hti);
- if ( !(hti.flags&TVHT_ABOVE))
- TreeView_SetInsertMark(GetDlgItem(hwndDlg,IDC_BTNORDER),hti.hItem,1);
- else
- TreeView_SetInsertMark(GetDlgItem(hwndDlg,IDC_BTNORDER),it,0);
- }
- else
- {
- if (hti.flags&TVHT_ABOVE) SendDlgItemMessage(hwndDlg,IDC_BTNORDER,WM_VSCROLL,MAKEWPARAM(SB_LINEUP,0),0);
- if (hti.flags&TVHT_BELOW) SendDlgItemMessage(hwndDlg,IDC_BTNORDER,WM_VSCROLL,MAKEWPARAM(SB_LINEDOWN,0),0);
- TreeView_SetInsertMark(GetDlgItem(hwndDlg,IDC_BTNORDER),NULL,0);
- }
- }
- }
- break;
- case WM_LBUTTONUP:
- {
- if ( !dragging) break;
- TreeView_SetInsertMark(GetDlgItem(hwndDlg,IDC_BTNORDER),NULL,0);
- dragging = 0;
- ReleaseCapture();
- {
- TVHITTESTINFO hti;
- TVITEM tvi;
- hti.pt.x = (short)LOWORD(lParam);
- hti.pt.y = (short)HIWORD(lParam);
- ClientToScreen(hwndDlg,&hti.pt);
- ScreenToClient(GetDlgItem(hwndDlg,IDC_BTNORDER),&hti.pt);
- hti.pt.y -= TreeView_GetItemHeight(GetDlgItem(hwndDlg,IDC_BTNORDER))/2;
- TreeView_HitTest(GetDlgItem(hwndDlg,IDC_BTNORDER),&hti);
- if (hDragItem == hti.hItem) break;
- if (hti.flags&TVHT_ABOVE) hti.hItem = TVI_FIRST;
- tvi.mask = TVIF_HANDLE|TVIF_PARAM;
- tvi.hItem = (HTREEITEM)hDragItem;
- TreeView_GetItem(GetDlgItem(hwndDlg,IDC_BTNORDER),&tvi);
- if (hti.flags&(TVHT_ONITEM|TVHT_ONITEMRIGHT) || (hti.hItem == TVI_FIRST))
- {
- TVINSERTSTRUCT tvis;
- TCHAR name[128];
- tvis.item.mask = TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_STATE;
- tvis.item.stateMask = 0xFFFFFFFF;
- tvis.item.pszText = name;
- tvis.item.cchTextMax = sizeof(name);
- tvis.item.hItem = (HTREEITEM)hDragItem;
- //tvis.item.iImage = tvis.item.iSelectedImage = ((MTB_BUTTONINFO *)tvi.lParam)->bVisible;
- TreeView_GetItem(GetDlgItem(hwndDlg,IDC_BTNORDER),&tvis.item);
- TreeView_DeleteItem(GetDlgItem(hwndDlg,IDC_BTNORDER),hDragItem);
- tvis.hParent = NULL;
- tvis.hInsertAfter = hti.hItem;
- TreeView_SelectItem(GetDlgItem(hwndDlg,IDC_BTNORDER),TreeView_InsertItem(GetDlgItem(hwndDlg,IDC_BTNORDER),&tvis));
- SendMessage((GetParent(hwndDlg)), PSM_CHANGED, (WPARAM)hwndDlg, 0);
- }
- }
- }
- break;
- case WM_COMMAND:
- if (LOWORD(wParam) == IDC_TBSHOW) {
- {
- int i;
- BOOL en = IsDlgButtonChecked(hwndDlg,IDC_TBSHOW);
- for (i=0; i < SIZEOF(ControlIDS); i++)
- EnableWindow(GetDlgItem(hwndDlg,ControlIDS[i]), en);
- }
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
- } else if ( (LOWORD(wParam) == IDC_TEXT_W ||
- LOWORD(wParam) == IDC_TEXT_H ||
- LOWORD(wParam) == IDC_TEXT_S )
- && HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) return 0; // dont make apply enabled during buddy set crap
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
- break;
+ if (IDYES == MessageBox(NULL, TranslateTS(szWarning), TranslateT("Toolbar upgrade"), MB_ICONQUESTION | MB_YESNO))
+ CallService(MS_UTILS_OPENURL, 0, (LPARAM)szUrl);
}
- return FALSE;
+
+ ToolBar_DefaultButtonRegistration();
+ return S_OK;
}
diff --git a/plugins/Clist_modern/resource.rc b/plugins/Clist_modern/resource.rc
index aeb4af99c3..6a678a138f 100644
--- a/plugins/Clist_modern/resource.rc
+++ b/plugins/Clist_modern/resource.rc
@@ -355,28 +355,6 @@ BEGIN
CONTROL "",IDC_EXTRAORDER,"SysTreeView32",TVS_NOTOOLTIPS | WS_BORDER | WS_TABSTOP,18,36,182,107
END
-IDD_OPT_TOOLBAR DIALOGEX 0, 0, 307, 216
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-EXSTYLE WS_EX_CONTROLPARENT
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- GROUPBOX "Toolbar settings",IDC_STATIC,7,5,290,204
- CONTROL "",IDC_BTNORDER,"SysTreeView32",TVS_NOTOOLTIPS | TVS_CHECKBOXES | WS_BORDER | WS_TABSTOP,29,39,120,123
- LTEXT "Hints:\n* Use Drag&&Drop feature to change buttons order.\n* You can change button icons at Customize->Icons Toolbar section",IDC_STATIC,18,174,278,29
- CONTROL "Show Toolbar with next buttons:",IDC_TBSHOW,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,20,268,10
- EDITTEXT IDC_TEXT_W,240,118,35,12,ES_NUMBER
- CONTROL "",IDC_SPIN_W,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,276,118,11,12
- RTEXT "Button width",IDC_STATIC_W,154,120,80,10
- EDITTEXT IDC_TEXT_S,240,148,35,12,ES_NUMBER
- CONTROL "",IDC_SPIN_S,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,276,148,11,12
- RTEXT "Space between",IDC_STATIC_S,154,151,80,10
- EDITTEXT IDC_TEXT_H,240,133,35,12,ES_NUMBER
- CONTROL "",IDC_SPIN_H,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,276,133,11,12
- RTEXT "Height",IDC_STATIC_H,154,136,80,10
- CONTROL "Multiline toolbar",IDC_CHECK_MULTILINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,157,86,139,10
- CONTROL "Autosize toolbar",IDC_CHECK_AUTOSIZE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,157,100,139,10
-END
-
IDD_DELETECONTACT DIALOGEX 0, 0, 284, 90
STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_CONTROLPARENT
@@ -919,16 +897,6 @@ BEGIN
BOTTOMMARGIN, 155
END
- IDD_OPT_TOOLBAR, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 297
- VERTGUIDE, 18
- VERTGUIDE, 296
- TOPMARGIN, 5
- BOTTOMMARGIN, 209
- END
-
IDD_DELETECONTACT, DIALOG
BEGIN
LEFTMARGIN, 7