summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-06-10 18:14:24 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-06-10 18:14:24 +0000
commitc53f6c34134b6028777a07ee9df80a962d395b45 (patch)
tree5275b0ad94f0fa12c88a047cd18587272dd69c0b
parentb7e047f64d8b79e5b6cf9ea682a09d575821129c (diff)
mwclist plusified
git-svn-id: http://svn.miranda-ng.org/main/trunk@381 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/Mwclist/BkgrCfg.cpp (renamed from plugins/Mwclist/BkgrCfg.c)101
-rw-r--r--plugins/Mwclist/CLUIFrames/cluiframes.c3428
-rw-r--r--plugins/Mwclist/CLUIFrames/cluiframes.cpp3015
-rw-r--r--plugins/Mwclist/CLUIFrames/extraimage.cpp (renamed from plugins/Mwclist/CLUIFrames/extraimage.c)213
-rw-r--r--plugins/Mwclist/CLUIFrames/framesmenu.cpp (renamed from plugins/Mwclist/CLUIFrames/framesmenu.c)120
-rw-r--r--plugins/Mwclist/CLUIFrames/statusbar.c630
-rw-r--r--plugins/Mwclist/CLUIFrames/statusbar.cpp599
-rw-r--r--plugins/Mwclist/clc.cpp (renamed from plugins/Mwclist/clc.c)132
-rw-r--r--plugins/Mwclist/clc.h6
-rw-r--r--plugins/Mwclist/clcidents.c338
-rw-r--r--plugins/Mwclist/clcidents.cpp301
-rw-r--r--plugins/Mwclist/clcitems.c695
-rw-r--r--plugins/Mwclist/clcitems.cpp696
-rw-r--r--plugins/Mwclist/clcopts.c1109
-rw-r--r--plugins/Mwclist/clcopts.cpp576
-rw-r--r--plugins/Mwclist/clcpaint.c748
-rw-r--r--plugins/Mwclist/clcpaint.cpp686
-rw-r--r--plugins/Mwclist/clcutils.c296
-rw-r--r--plugins/Mwclist/clcutils.cpp289
-rw-r--r--plugins/Mwclist/clist_mw_10.vcxproj54
-rw-r--r--plugins/Mwclist/clist_mw_10.vcxproj.filters6
-rw-r--r--plugins/Mwclist/clistmenus.cpp (renamed from plugins/Mwclist/clistmenus.c)21
-rw-r--r--plugins/Mwclist/clistmod.cpp (renamed from plugins/Mwclist/clistmod.c)42
-rw-r--r--plugins/Mwclist/clistopts.cpp (renamed from plugins/Mwclist/clistopts.c)105
-rw-r--r--plugins/Mwclist/clistsettings.cpp (renamed from plugins/Mwclist/clistsettings.c)138
-rw-r--r--plugins/Mwclist/clisttray.cpp (renamed from plugins/Mwclist/clisttray.c)189
-rw-r--r--plugins/Mwclist/clui.cpp (renamed from plugins/Mwclist/clui.c)513
-rw-r--r--plugins/Mwclist/cluiopts.cpp (renamed from plugins/Mwclist/cluiopts.c)107
-rw-r--r--plugins/Mwclist/cluiservices.cpp (renamed from plugins/Mwclist/cluiservices.c)97
-rw-r--r--plugins/Mwclist/commonheaders.cpp (renamed from plugins/Mwclist/commonheaders.c)4
-rw-r--r--plugins/Mwclist/commonheaders.h8
-rw-r--r--plugins/Mwclist/contact.cpp (renamed from plugins/Mwclist/contact.c)76
-rw-r--r--plugins/Mwclist/groupmenu.c751
-rw-r--r--plugins/Mwclist/groupmenu.cpp685
-rw-r--r--plugins/Mwclist/init.cpp (renamed from plugins/Mwclist/init.c)30
-rw-r--r--plugins/Mwclist/keyboard.cpp (renamed from plugins/Mwclist/keyboard.c)26
-rw-r--r--plugins/Mwclist/resource.h6
-rw-r--r--plugins/Mwclist/resource.rc171
38 files changed, 7829 insertions, 9178 deletions
diff --git a/plugins/Mwclist/BkgrCfg.c b/plugins/Mwclist/BkgrCfg.cpp
index adc96b1970..c8c565bd0e 100644
--- a/plugins/Mwclist/BkgrCfg.c
+++ b/plugins/Mwclist/BkgrCfg.cpp
@@ -53,12 +53,12 @@ static INT_PTR CALLBACK DlgProcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
HWND hList = GetDlgItem(hwndDlg, IDC_BKGRLIST);
TranslateDialogDefault(hwndDlg);
- dat=(struct BkgrData*)mir_alloc(sizeof(struct BkgrData));
+ dat = (struct BkgrData*)mir_alloc(sizeof(struct BkgrData));
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
dat->count = bkgrCount;
dat->item = (struct BkgrItem*)mir_alloc(sizeof(struct BkgrItem)*dat->count);
dat->indx = CB_ERR;
- for(indx = 0; indx < dat->count; indx++)
+ for (indx = 0; indx < dat->count; indx++)
{
char *module = bkgrList[indx] + strlen(bkgrList[indx]) + 1;
int jndx;
@@ -87,15 +87,15 @@ static INT_PTR CALLBACK DlgProcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
PostMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_BKGRLIST, CBN_SELCHANGE), 0);
{
HRESULT (STDAPICALLTYPE *MySHAutoComplete)(HWND,DWORD);
- MySHAutoComplete=(HRESULT (STDAPICALLTYPE*)(HWND,DWORD))GetProcAddress(GetModuleHandleA("shlwapi"),"SHAutoComplete");
- if(MySHAutoComplete) MySHAutoComplete(GetDlgItem(hwndDlg,IDC_FILENAME),1);
+ MySHAutoComplete = (HRESULT (STDAPICALLTYPE*)(HWND,DWORD))GetProcAddress(GetModuleHandleA("shlwapi"),"SHAutoComplete");
+ if (MySHAutoComplete) MySHAutoComplete(GetDlgItem(hwndDlg,IDC_FILENAME),1);
}
return TRUE;
}
case WM_DESTROY:
- if(dat)
+ if (dat)
{
- if(dat->item) mir_free(dat->item);
+ if (dat->item) mir_free(dat->item);
mir_free(dat);
}
@@ -104,7 +104,7 @@ static INT_PTR CALLBACK DlgProcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
case M_BKGR_GETSTATE:
{
int indx = wParam;
- if(indx == CB_ERR || indx >= dat->count) break;
+ if (indx == CB_ERR || indx >= dat->count) break;
indx = SendDlgItemMessage(hwndDlg, IDC_BKGRLIST, CB_GETITEMDATA, indx, 0);
dat->item[indx].useBitmap = IsDlgButtonChecked(hwndDlg,IDC_BITMAP);
@@ -113,13 +113,13 @@ static INT_PTR CALLBACK DlgProcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
GetDlgItemTextA(hwndDlg, IDC_FILENAME, dat->item[indx].filename, sizeof(dat->item[indx].filename));
{
WORD flags = 0;
- if(IsDlgButtonChecked(hwndDlg,IDC_STRETCHH)) flags |= CLB_STRETCHH;
- if(IsDlgButtonChecked(hwndDlg,IDC_STRETCHV)) flags |= CLB_STRETCHV;
- if(IsDlgButtonChecked(hwndDlg,IDC_TILEH)) flags |= CLBF_TILEH;
- if(IsDlgButtonChecked(hwndDlg,IDC_TILEV)) flags |= CLBF_TILEV;
- if(IsDlgButtonChecked(hwndDlg,IDC_SCROLL)) flags |= CLBF_SCROLL;
- if(IsDlgButtonChecked(hwndDlg,IDC_PROPORTIONAL)) flags |= CLBF_PROPORTIONAL;
- if(IsDlgButtonChecked(hwndDlg,IDC_TILEVROWH)) flags |= CLBF_TILEVTOROWHEIGHT;
+ if (IsDlgButtonChecked(hwndDlg,IDC_STRETCHH)) flags |= CLB_STRETCHH;
+ if (IsDlgButtonChecked(hwndDlg,IDC_STRETCHV)) flags |= CLB_STRETCHV;
+ if (IsDlgButtonChecked(hwndDlg,IDC_TILEH)) flags |= CLBF_TILEH;
+ if (IsDlgButtonChecked(hwndDlg,IDC_TILEV)) flags |= CLBF_TILEV;
+ if (IsDlgButtonChecked(hwndDlg,IDC_SCROLL)) flags |= CLBF_SCROLL;
+ if (IsDlgButtonChecked(hwndDlg,IDC_PROPORTIONAL)) flags |= CLBF_PROPORTIONAL;
+ if (IsDlgButtonChecked(hwndDlg,IDC_TILEVROWH)) flags |= CLBF_TILEVTOROWHEIGHT;
dat->item[indx].flags = flags;
}
break;
@@ -128,7 +128,7 @@ static INT_PTR CALLBACK DlgProcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
{
int indx = wParam;
int flags = dat->item[indx].flags;
- if(indx == CB_ERR || indx >= dat->count) break;
+ if (indx == CB_ERR || indx >= dat->count) break;
indx = SendDlgItemMessage(hwndDlg, IDC_BKGRLIST, CB_GETITEMDATA, indx, 0);
CheckDlgButton(hwndDlg, IDC_BITMAP, dat->item[indx].useBitmap?BST_CHECKED:BST_UNCHECKED);
@@ -146,47 +146,6 @@ static INT_PTR CALLBACK DlgProcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
CheckDlgButton(hwndDlg,IDC_SCROLL,flags&CLBF_SCROLL?BST_CHECKED:BST_UNCHECKED);
CheckDlgButton(hwndDlg,IDC_PROPORTIONAL,flags&CLBF_PROPORTIONAL?BST_CHECKED:BST_UNCHECKED);
CheckDlgButton(hwndDlg,IDC_TILEVROWH,flags&CLBF_TILEVTOROWHEIGHT?BST_CHECKED:BST_UNCHECKED);
-/*
- {
- WORD visibility;
- int cy = 55;
- char *sz = bkgrList[indx] + strlen(bkgrList[indx]) + 1;
- sz += strlen(sz) + 1;
- visibility = (WORD)~(*(DWORD*)(sz));
-//M_BKGR_BACKCOLOR,M_BKGR_SELECTCOLOR,M_BKGR_ALLOWBITMAPS,M_BKGR_STRETCH,M_BKGR_TILE}
- if(visibility & M_BKGR_BACKCOLOR)
- {
- SetWindowPos(GetDlgItem(hwndDlg, IDC_BC_STATIC), 0,
- 20, cy,
- 0, 0,
- SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOSIZE);
- SetWindowPos(GetDlgItem(hwndDlg, IDC_BKGCOLOUR), 0,
- 130, cy,
- 0, 0,
- SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOSIZE);
- cy += 25;
- }
- if(visibility & M_BKGR_SELECTCOLOR)
- {
- SetWindowPos(GetDlgItem(hwndDlg, IDC_SC_STATIC), 0,
- 20, cy,
- 0, 0,
- SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOSIZE);
- SetWindowPos(GetDlgItem(hwndDlg, IDC_SELCOLOUR), 0,
- 130, cy,
- 0, 0,
- SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOSIZE);
- cy += 25;
- }
- ShowWindow(GetDlgItem(hwndDlg,IDC_STRETCHH), visibility&CLB_STRETCHH?SW_SHOW:SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg,IDC_STRETCHV), visibility&CLB_STRETCHV?SW_SHOW:SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg,IDC_TILEH), visibility&CLBF_TILEH?SW_SHOW:SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg,IDC_TILEV), visibility&CLBF_TILEV?SW_SHOW:SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg,IDC_SCROLL), visibility&CLBF_SCROLL?SW_SHOW:SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg,IDC_PROPORTIONAL), visibility&CLBF_PROPORTIONAL?SW_SHOW:SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg,IDC_TILEVROWH), visibility&CLBF_TILEVTOROWHEIGHT?SW_SHOW:SW_HIDE);
- }
-*/
SendMessage(hwndDlg, M_BKGR_UPDATE, 0,0);
break;
@@ -195,15 +154,15 @@ static INT_PTR CALLBACK DlgProcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
{
int isChecked = IsDlgButtonChecked(hwndDlg,IDC_BITMAP);
int indx;
- for(indx = 0; indx < ARRAY_SIZE(bitmapRelatedControls); indx++)
+ for (indx = 0; indx < ARRAY_SIZE(bitmapRelatedControls); indx++)
EnableWindow(GetDlgItem(hwndDlg, bitmapRelatedControls[indx]),isChecked);
break;
}
case WM_COMMAND:
- if(LOWORD(wParam) == IDC_BROWSE)
+ if (LOWORD(wParam) == IDC_BROWSE)
{
char str[MAX_PATH];
- OPENFILENAMEA ofn={0};
+ OPENFILENAMEA ofn = {0};
char filter[512];
GetDlgItemTextA(hwndDlg,IDC_FILENAME, str, sizeof(str));
@@ -221,14 +180,14 @@ static INT_PTR CALLBACK DlgProcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
SetDlgItemTextA(hwndDlg, IDC_FILENAME, str);
}
else
- if(LOWORD(wParam) == IDC_FILENAME && HIWORD(wParam) != EN_CHANGE) break;
- if(LOWORD(wParam) == IDC_BITMAP)
+ if (LOWORD(wParam) == IDC_FILENAME && HIWORD(wParam) != EN_CHANGE) break;
+ if (LOWORD(wParam) == IDC_BITMAP)
SendMessage(hwndDlg, M_BKGR_UPDATE, 0,0);
- if(LOWORD(wParam) == IDC_FILENAME && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()))
+ if (LOWORD(wParam) == IDC_FILENAME && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()))
return 0;
- if(LOWORD(wParam) == IDC_BKGRLIST)
+ if (LOWORD(wParam) == IDC_BKGRLIST)
{
- if(HIWORD(wParam) == CBN_SELCHANGE)
+ if (HIWORD(wParam) == CBN_SELCHANGE)
{
SendMessage(hwndDlg, M_BKGR_GETSTATE, dat->indx, 0);
SendMessage(hwndDlg, M_BKGR_SETSTATE, dat->indx = SendDlgItemMessage(hwndDlg, IDC_BKGRLIST, CB_GETCURSEL, 0,0), 0);
@@ -237,7 +196,7 @@ static INT_PTR CALLBACK DlgProcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
}
{
int indx = SendDlgItemMessage(hwndDlg, IDC_BKGRLIST, CB_GETCURSEL, 0,0);
- if(indx != CB_ERR && indx < dat->count)
+ if (indx != CB_ERR && indx < dat->count)
{
indx = SendDlgItemMessage(hwndDlg, IDC_BKGRLIST, CB_GETITEMDATA, indx, 0);
dat->item[indx].changed = TRUE;
@@ -256,8 +215,8 @@ static INT_PTR CALLBACK DlgProcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
{
int indx;
SendMessage(hwndDlg, M_BKGR_GETSTATE, SendDlgItemMessage(hwndDlg, IDC_BKGRLIST, CB_GETCURSEL, 0,0), 0);
- for(indx = 0; indx < dat->count; indx++)
- if(dat->item[indx].changed)
+ for (indx = 0; indx < dat->count; indx++)
+ if (dat->item[indx].changed)
{
char *module = bkgrList[indx] + strlen(bkgrList[indx]) + 1;
DBWriteContactSettingByte(NULL, module, "UseBitmap", (BYTE)dat->item[indx].useBitmap);
@@ -307,7 +266,7 @@ static INT_PTR BkgrCfg_Register(WPARAM wParam,LPARAM lParam)
value = (char *)mir_alloc(len + 4); // add room for flags (DWORD)
memcpy(value, szSetting, len);
tok = strchr(value, '/');
- if(tok == NULL)
+ if (tok == NULL)
{
mir_free(value);
return 1;
@@ -353,11 +312,11 @@ int BGModuleLoad()
int BGModuleUnload(void)
{
- if(bkgrList != NULL)
+ if (bkgrList != NULL)
{
int indx;
- for(indx = 0; indx < bkgrCount; indx++)
- if(bkgrList[indx] != NULL)
+ for (indx = 0; indx < bkgrCount; indx++)
+ if (bkgrList[indx] != NULL)
mir_free(bkgrList[indx]);
mir_free(bkgrList);
}
diff --git a/plugins/Mwclist/CLUIFrames/cluiframes.c b/plugins/Mwclist/CLUIFrames/cluiframes.c
deleted file mode 100644
index 53dda27d3e..0000000000
--- a/plugins/Mwclist/CLUIFrames/cluiframes.c
+++ /dev/null
@@ -1,3428 +0,0 @@
-/*
-Miranda IM: the free IM client for Microsoft* Windows*
-
-Copyright 2000-2003 Miranda ICQ/IM project,
-all portions of this codebase are copyrighted to the people
-listed in contributors.txt.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "../commonheaders.h"
-
-extern HINSTANCE g_hInst;
-
-//we use dynamic frame list,
-//but who wants so huge number of frames ??
-#define MAX_FRAMES 16
-
-#define UNCOLLAPSED_FRAME_SIZE 0
-#define DEFAULT_TITLEBAR_HEIGHT 20
-
-//legacy menu support
-#define frame_menu_lock 1
-#define frame_menu_visible 2
-#define frame_menu_showtitlebar 3
-#define frame_menu_floating 4
-extern int ModifyMenuItemProxy(WPARAM wParam,LPARAM lParam);
-static int UpdateTBToolTip(int framepos);
-INT_PTR CLUIFrameSetFloat(WPARAM wParam,LPARAM lParam);
-int CLUIFrameResizeFloatingFrame(int framepos);
-extern int ProcessCommandProxy(WPARAM wParam,LPARAM lParam);
-extern int InitFramesMenus(void);
-int GapBetweenTitlebar;
-
-LOGFONTA TitleBarLogFont={0};
-
-boolean FramesSysNotStarted=TRUE;
-
-HANDLE hService[20], hHook[4];
-
-typedef struct
-{
- int order;
- int realpos;
-}
- SortData;
-
-static int sortfunc(const void *a,const void *b)
-{
- SortData *sd1,*sd2;
- sd1=(SortData *)a;
- sd2=(SortData *)b;
- if (sd1->order > sd2->order){return(1);}
- if (sd1->order < sd2->order){return(-1);}
- //if (sd1->order = sd2->order){return(0);}
- return (0);
-}
-
-
-//============
-#define CLUIFRAMESSETALIGN "CLUIFramesSetAlign"
-
-#define CLUIFRAMESSETALIGNALTOP "CLUIFramesSetAlignalTop"
-#define CLUIFRAMESSETALIGNALCLIENT "CLUIFramesSetAlignalClient"
-#define CLUIFRAMESSETALIGNALBOTTOM "CLUIFramesSetAlignalBottom"
-
-#define CLUIFRAMESMOVEUPDOWN "CLUIFramesMoveUpDown"
-typedef struct tagMenuHandles
-{
- HANDLE MainMenuItem;
- HANDLE MIVisible,MITitle,MITBVisible,MILock,MIColl,MIFloating,MIAlignRoot;
- HANDLE MIAlignTop,MIAlignClient,MIAlignBottom;
- HANDLE MIBorder;
-} FrameMenuHandles;
-
-typedef struct tagFrameTitleBar{
- HWND hwnd;
- HWND TitleBarbutt;
- HWND hwndTip;
-
- LPTSTR tbname;
- LPTSTR tooltip;
- HMENU hmenu;
- HICON hicon;
-
- BOOLEAN ShowTitleBar;
- BOOLEAN ShowTitleBarTip;
- COLORREF BackColour;
- int oldstyles;
- POINT oldpos;
- RECT wndSize;
-} FrameTitleBar;
-
-typedef struct _DockOpt
-{
- HWND hwndLeft;
- HWND hwndRight;
-}
-DockOpt;
-
-typedef struct {
- int id;
- HWND hWnd ;
- RECT wndSize;
- LPTSTR name;
- int align;
- int height;
- int dwFlags;
- BOOLEAN Locked;
- BOOLEAN visible;
- BOOLEAN needhide;
- BOOLEAN collapsed;
- int prevvisframe;
- int HeightWhenCollapsed;
- FrameTitleBar TitleBar;
- FrameMenuHandles MenuHandles;
- int oldstyles;
- BOOLEAN floating;
- HWND ContainerWnd;
- POINT FloatingPos;
- POINT FloatingSize;
- BOOLEAN minmaxenabled;
- BOOLEAN UseBorder;
- int order;
- DockOpt dockOpt;
-} wndFrame;
-
-//static wndFrame Frames[MAX_FRAMES];
-static wndFrame *Frames=NULL;
-
-static int nFramescount=0;
-static int alclientFrame=-1;//for fast access to frame with alclient properties
-static int NextFrameId=100;
-
-HFONT TitleBarFont;
-static TitleBarH=DEFAULT_TITLEBAR_HEIGHT;
-static boolean resizing=FALSE;
-
-// menus
-static HANDLE contMIVisible,contMITitle,contMITBVisible,contMILock,contMIColl,contMIFloating;
-static HANDLE contMIAlignRoot;
-static HANDLE contMIAlignTop,contMIAlignClient,contMIAlignBottom;
-static HANDLE contMIBorder;
-static HANDLE MainMIRoot=(HANDLE)-1;
-
-// others
-static int ContactListHeight;
-static int LastStoreTick=0;
-
-static int lbypos=-1;
-static int oldframeheight=-1;
-static int curdragbar=-1;
-static CRITICAL_SECTION csFrameHook;
-
-static BOOLEAN CLUIFramesFitInSize(void);
-static int RemoveItemFromList(int pos,wndFrame **lpFrames,int *FrameItemCount);
-HWND hWndExplorerToolBar;
-static int GapBetweenFrames=1;
-
-static int RemoveItemFromList(int pos,wndFrame **lpFrames,int *FrameItemCount)
-{
- memcpy(&((*lpFrames)[pos]),&((*lpFrames)[pos+1]),sizeof(wndFrame)*(*FrameItemCount-pos-1));
- (*FrameItemCount)--;
- (*lpFrames)=(wndFrame*)realloc((*lpFrames),sizeof(wndFrame)*(*FrameItemCount));
- return 0;
-}
-
-static int id2pos(int id)
-{
- int i;
-
- if (FramesSysNotStarted) return -1;
-
- for (i=0;i<nFramescount;i++)
- {
- if (Frames[i].id==id) return(i);
- }
- return(-1);
-}
-
-static int btoint(BOOLEAN b)
-{
- if(b) return 1;
- return 0;
-}
-
-static void __inline lockfrm()
-{
- EnterCriticalSection(&csFrameHook);
-}
-
-static void __inline ulockfrm()
-{
- LeaveCriticalSection(&csFrameHook);
-}
-
-//////////screen docking,code from "floating contacts" plugin.
-
-static wndFrame* FindFrameByWnd( HWND hwnd )
-{
- BOOL bFound = FALSE;
- int i;
-
- if ( hwnd == NULL ) return( NULL );
-
- for(i=0;i<nFramescount;i++)
- {
- if ((Frames[i].floating)&&(Frames[i].ContainerWnd==hwnd) ){return(&Frames[i]);}
- }
-
- return( NULL);
-}
-
-
-static void DockThumbs( wndFrame *pThumbLeft, wndFrame *pThumbRight, BOOL bMoveLeft )
-{
- if ( ( pThumbRight->dockOpt.hwndLeft == NULL ) && ( pThumbLeft->dockOpt.hwndRight == NULL ) )
- {
- pThumbRight->dockOpt.hwndLeft = pThumbLeft->ContainerWnd;
- pThumbLeft->dockOpt.hwndRight = pThumbRight->ContainerWnd;
- }
-}
-
-
-static void UndockThumbs( wndFrame *pThumb1, wndFrame *pThumb2 )
-{
- if ( ( pThumb1 == NULL ) || ( pThumb2 == NULL ) )
- {
- return;
- }
-
- if ( pThumb1->dockOpt.hwndRight == pThumb2->ContainerWnd )
- {
- pThumb1->dockOpt.hwndRight = NULL;
- }
-
- if ( pThumb1->dockOpt.hwndLeft == pThumb2->ContainerWnd )
- {
- pThumb1->dockOpt.hwndLeft = NULL;
- }
-
- if ( pThumb2->dockOpt.hwndRight == pThumb1->ContainerWnd )
- {
- pThumb2->dockOpt.hwndRight = NULL;
- }
-
- if ( pThumb2->dockOpt.hwndLeft == pThumb1->ContainerWnd )
- {
- pThumb2->dockOpt.hwndLeft = NULL;
- }
-}
-
-BOOLEAN bMoveTogether;
-
-static void PositionThumb( wndFrame *pThumb, short nX, short nY )
-{
- wndFrame *pCurThumb = &Frames[0];
- wndFrame *pDockThumb = pThumb;
- wndFrame fakeMainWindow;
- wndFrame fakeTaskBarWindow;
- RECT rc;
- RECT rcThumb;
- RECT rcOld;
- SIZE sizeScreen;
- int nNewX;
- int nNewY;
- int nOffs = 10;
- int nWidth;
- int nHeight;
- POINT pt;
- RECT rcLeft;
- RECT rcTop;
- RECT rcRight;
- RECT rcBottom;
- BOOL bDocked;
- BOOL bDockedLeft;
- BOOL bDockedRight;
- BOOL bLeading;
- int frmidx=0;
-
- if ( pThumb == NULL ) return;
-
- sizeScreen.cx = GetSystemMetrics( SM_CXSCREEN );
- sizeScreen.cy = GetSystemMetrics( SM_CYSCREEN );
-
- // Get thumb dimnsions
- GetWindowRect( pThumb->ContainerWnd, &rcThumb );
- nWidth = rcThumb.right - rcThumb.left;
- nHeight = rcThumb.bottom - rcThumb.top;
-
- // Docking to the edges of the screen
- nNewX = nX < nOffs ? 0 : nX;
- nNewX = nNewX > ( sizeScreen.cx - nWidth - nOffs ) ? ( sizeScreen.cx - nWidth ) : nNewX;
- nNewY = nY < nOffs ? 0 : nY;
- nNewY = nNewY > ( sizeScreen.cy - nHeight - nOffs ) ? ( sizeScreen.cy - nHeight ) : nNewY;
-
- bLeading = pThumb->dockOpt.hwndRight != NULL;
-
- if ( bMoveTogether )
- {
- UndockThumbs( pThumb, FindFrameByWnd( pThumb->dockOpt.hwndLeft ) );
- GetWindowRect( pThumb->ContainerWnd, &rcOld );
- }
-
- memset(&fakeMainWindow,0,sizeof(fakeMainWindow));
- fakeMainWindow.ContainerWnd=pcli->hwndContactList;
- fakeMainWindow.floating=TRUE;
-
- memset(&fakeTaskBarWindow,0,sizeof(fakeTaskBarWindow));
- fakeTaskBarWindow.ContainerWnd=hWndExplorerToolBar;
- fakeTaskBarWindow.floating=TRUE;
-
-
- while( pCurThumb != NULL )
- {
- if (pCurThumb->floating) {
-
- if ( pCurThumb != pThumb )
- {
- GetWindowRect( pThumb->ContainerWnd, &rcThumb );
- OffsetRect( &rcThumb, nX - rcThumb.left, nY - rcThumb.top );
-
- GetWindowRect( pCurThumb->ContainerWnd, &rc );
-
- // These are rects we will dock into
-
- rcLeft.left = rc.left - nOffs;
- rcLeft.top = rc.top - nOffs;
- rcLeft.right = rc.left + nOffs;
- rcLeft.bottom = rc.bottom + nOffs;
-
- rcTop.left = rc.left - nOffs;
- rcTop.top = rc.top - nOffs;
- rcTop.right = rc.right + nOffs;
- rcTop.bottom = rc.top + nOffs;
-
- rcRight.left = rc.right - nOffs;
- rcRight.top = rc.top - nOffs;
- rcRight.right = rc.right + nOffs;
- rcRight.bottom = rc.bottom + nOffs;
-
- rcBottom.left = rc.left - nOffs;
- rcBottom.top = rc.bottom - nOffs;
- rcBottom.right = rc.right + nOffs;
- rcBottom.bottom = rc.bottom + nOffs;
-
-
- bDockedLeft = FALSE;
- bDockedRight = FALSE;
-
- // Upper-left
- pt.x = rcThumb.left;
- pt.y = rcThumb.top;
- bDocked = FALSE;
-
- if ( PtInRect( &rcRight, pt ) )
- {
- nNewX = rc.right;
- bDocked = TRUE;
- }
-
- if ( PtInRect( &rcBottom, pt ) )
- {
- nNewY = rc.bottom;
-
- if ( PtInRect( &rcLeft, pt ) )
- {
- nNewX = rc.left;
- }
- }
-
- if ( PtInRect( &rcTop, pt ) )
- {
- nNewY = rc.top;
- bDockedLeft = bDocked;
- }
-
- // Upper-right
- pt.x = rcThumb.right;
- pt.y = rcThumb.top;
- bDocked = FALSE;
-
- if ( !bLeading && PtInRect( &rcLeft, pt ) )
- {
- if ( !bDockedLeft )
- {
- nNewX = rc.left - nWidth;
- bDocked = TRUE;
- }
- else if ( rc.right == rcThumb.left )
- {
- bDocked = TRUE;
- }
- }
-
-
- if ( PtInRect( &rcBottom, pt ) )
- {
- nNewY = rc.bottom;
-
- if ( PtInRect( &rcRight, pt ) )
- {
- nNewX = rc.right - nWidth;
- }
- }
-
- if ( !bLeading && PtInRect( &rcTop, pt ) )
- {
- nNewY = rc.top;
- bDockedRight = bDocked;
- }
-
- if ( bMoveTogether )
- {
- if ( bDockedRight )
- {
- DockThumbs( pThumb, pCurThumb, TRUE );
- }
-
- if ( bDockedLeft )
- {
- DockThumbs( pCurThumb, pThumb, FALSE );
- }
- }
-
- // Lower-left
- pt.x = rcThumb.left;
- pt.y = rcThumb.bottom;
-
- if ( PtInRect( &rcRight, pt ) )
- {
- nNewX = rc.right;
- }
-
- if ( PtInRect( &rcTop, pt ) )
- {
- nNewY = rc.top - nHeight;
-
- if ( PtInRect( &rcLeft, pt ) )
- {
- nNewX = rc.left;
- }
- }
-
-
- // Lower-right
- pt.x = rcThumb.right;
- pt.y = rcThumb.bottom;
-
- if ( !bLeading && PtInRect( &rcLeft, pt ) )
- {
- nNewX = rc.left - nWidth;
- }
-
- if ( !bLeading && PtInRect( &rcTop, pt ) )
- {
- nNewY = rc.top - nHeight;
-
- if ( PtInRect( &rcRight, pt ) )
- {
- nNewX = rc.right - nWidth;
- }
- }
- }
-
- }
- frmidx++;
- if (pCurThumb->ContainerWnd==fakeTaskBarWindow.ContainerWnd){break;}
- if (pCurThumb->ContainerWnd==fakeMainWindow.ContainerWnd){
- pCurThumb=&fakeTaskBarWindow;continue;}
- if (frmidx==nFramescount){
- pCurThumb=&fakeMainWindow;continue;
- }
-
- pCurThumb = &Frames[frmidx];
-
-
-
- }
-
- // Adjust coords once again
- nNewX = nNewX < nOffs ? 0 : nNewX;
- nNewX = nNewX > ( sizeScreen.cx - nWidth - nOffs ) ? ( sizeScreen.cx - nWidth ) : nNewX;
- nNewY = nNewY < nOffs ? 0 : nNewY;
- nNewY = nNewY > ( sizeScreen.cy - nHeight - nOffs ) ? ( sizeScreen.cy - nHeight ) : nNewY;
-
-
- SetWindowPos( pThumb->ContainerWnd,
- HWND_TOPMOST,
- nNewX,
- nNewY,
- 0,
- 0,
- SWP_NOSIZE | SWP_NOZORDER );
-
-
- // OK, move all docked thumbs
- if ( bMoveTogether )
- {
- pDockThumb = FindFrameByWnd( pDockThumb->dockOpt.hwndRight );
-
- PositionThumb( pDockThumb, (short)( nNewX + nWidth ), (short)nNewY );
- }
-}
-
-
-//////////
-
-
-
-void GetBorderSize(HWND hwnd,RECT *rect)
-{
- RECT wr,cr;
- POINT pt1,pt2;
-
- GetWindowRect(hwnd,&wr);
- GetClientRect(hwnd,&cr);
- pt1.y=cr.top;pt1.x=cr.left;
- pt2.y=cr.bottom;pt2.x=cr.right;
-
- ClientToScreen(hwnd,&pt1);
- ClientToScreen(hwnd,&pt2);
-
- cr.top=pt1.y;cr.left=pt1.x;
- cr.bottom=pt2.y;cr.right=pt2.x;
-
- rect->top=cr.top-wr.top;
- rect->left=cr.left-wr.left;
- rect->right=wr.right-cr.right;
- rect->bottom=wr.bottom-cr.bottom;
- //if (rect->top+rect->bottom>10){rect->top=rect->bottom=2;}
- //if (rect->left+rect->right>10){rect->top=rect->bottom=2;}
-
-}
-
-//append string
-char __inline *AS(char *str,const char *setting,char *addstr)
-{
- if(str!=NULL) {
- strcpy(str,setting);
- strcat(str,addstr);
- }
- return str;
-}
-
-int DBLoadFrameSettingsAtPos(int pos,int Frameid)
-{
- char sadd[15];
- char buf[255];
-// char *oldtb;
-
- _itoa(pos,sadd,10);
-
- //DBWriteContactSettingTString(0,CLUIFrameModule,strcat("Name",sadd),Frames[Frameid].tname);
-
- //boolean
- Frames[Frameid].collapsed=DBGetContactSettingByte(0,CLUIFrameModule,AS(buf,"Collapse",sadd),Frames[Frameid].collapsed);
-
- Frames[Frameid].Locked =DBGetContactSettingByte(0,CLUIFrameModule,AS(buf,"Locked",sadd),Frames[Frameid].Locked);
- Frames[Frameid].visible =DBGetContactSettingByte(0,CLUIFrameModule,AS(buf,"Visible",sadd),Frames[Frameid].visible);
- Frames[Frameid].TitleBar.ShowTitleBar =DBGetContactSettingByte(0,CLUIFrameModule,AS(buf,"TBVisile",sadd),Frames[Frameid].TitleBar.ShowTitleBar);
-
- Frames[Frameid].height =DBGetContactSettingWord(0,CLUIFrameModule,AS(buf,"Height",sadd),Frames[Frameid].height);
- Frames[Frameid].HeightWhenCollapsed =DBGetContactSettingWord(0,CLUIFrameModule,AS(buf,"HeightCollapsed",sadd),0);
- Frames[Frameid].align =DBGetContactSettingWord(0,CLUIFrameModule,AS(buf,"Align",sadd),Frames[Frameid].align);
-
- Frames[Frameid].FloatingPos.x =DBGetContactSettingRangedWord(0,CLUIFrameModule,AS(buf,"FloatX",sadd),100,0,1024);
- Frames[Frameid].FloatingPos.y =DBGetContactSettingRangedWord(0,CLUIFrameModule,AS(buf,"FloatY",sadd),100,0,1024);
- Frames[Frameid].FloatingSize.x =DBGetContactSettingRangedWord(0,CLUIFrameModule,AS(buf,"FloatW",sadd),100,0,1024);
- Frames[Frameid].FloatingSize.y =DBGetContactSettingRangedWord(0,CLUIFrameModule,AS(buf,"FloatH",sadd),100,0,1024);
-
- Frames[Frameid].floating =DBGetContactSettingByte(0,CLUIFrameModule,AS(buf,"Floating",sadd),0);
- Frames[Frameid].order =DBGetContactSettingWord(0,CLUIFrameModule,AS(buf,"Order",sadd),0);
-
- Frames[Frameid].UseBorder =DBGetContactSettingByte(0,CLUIFrameModule,AS(buf,"UseBorder",sadd),Frames[Frameid].UseBorder);
-
- return 0;
-}
-
-int DBStoreFrameSettingsAtPos(int pos,int Frameid)
-{
- char sadd[16];
- char buf[255];
-
- _itoa(pos,sadd,10);
-
- DBWriteContactSettingTString(0,CLUIFrameModule,AS(buf,"Name",sadd),Frames[Frameid].name);
- //boolean
- DBWriteContactSettingByte(0,CLUIFrameModule,AS(buf,"Collapse",sadd),(BYTE)btoint(Frames[Frameid].collapsed));
- DBWriteContactSettingByte(0,CLUIFrameModule,AS(buf,"Locked",sadd),(BYTE)btoint(Frames[Frameid].Locked));
- DBWriteContactSettingByte(0,CLUIFrameModule,AS(buf,"Visible",sadd),(BYTE)btoint(Frames[Frameid].visible));
- DBWriteContactSettingByte(0,CLUIFrameModule,AS(buf,"TBVisile",sadd),(BYTE)btoint(Frames[Frameid].TitleBar.ShowTitleBar));
-
- DBWriteContactSettingWord(0,CLUIFrameModule,AS(buf,"Height",sadd),(WORD)Frames[Frameid].height);
- DBWriteContactSettingWord(0,CLUIFrameModule,AS(buf,"HeightCollapsed",sadd),(WORD)Frames[Frameid].HeightWhenCollapsed);
- DBWriteContactSettingWord(0,CLUIFrameModule,AS(buf,"Align",sadd),(WORD)Frames[Frameid].align);
- //FloatingPos
- DBWriteContactSettingWord(0,CLUIFrameModule,AS(buf,"FloatX",sadd),(WORD)Frames[Frameid].FloatingPos.x);
- DBWriteContactSettingWord(0,CLUIFrameModule,AS(buf,"FloatY",sadd),(WORD)Frames[Frameid].FloatingPos.y);
- DBWriteContactSettingWord(0,CLUIFrameModule,AS(buf,"FloatW",sadd),(WORD)Frames[Frameid].FloatingSize.x);
- DBWriteContactSettingWord(0,CLUIFrameModule,AS(buf,"FloatH",sadd),(WORD)Frames[Frameid].FloatingSize.y);
-
- DBWriteContactSettingByte(0,CLUIFrameModule,AS(buf,"Floating",sadd),(BYTE)btoint(Frames[Frameid].floating));
- DBWriteContactSettingByte(0,CLUIFrameModule,AS(buf,"UseBorder",sadd),(BYTE)btoint(Frames[Frameid].UseBorder));
- DBWriteContactSettingWord(0,CLUIFrameModule,AS(buf,"Order",sadd),(WORD)Frames[Frameid].order);
- //DBWriteContactSettingString(0,CLUIFrameModule,AS(buf,"TBName",sadd),Frames[Frameid].TitleBar.tbname);
- return 0;
-}
-
-int LocateStorePosition(int Frameid,int maxstored)
-{
- int i;
- LPTSTR frmname;
- char settingname[255];
- if(Frames[Frameid].name==NULL) return -1;
-
- for(i=0;i<maxstored;i++) {
- mir_snprintf(settingname,sizeof(settingname),"Name%d",i);
- frmname=DBGetStringT(0,CLUIFrameModule,settingname);
- if(frmname==NULL) continue;
- if(lstrcmpi(frmname,Frames[Frameid].name)==0) {
- mir_free(frmname);
- return i;
- }
- mir_free(frmname);
- }
- return -1;
-}
-
-int CLUIFramesLoadFrameSettings(int Frameid)
-{
- int storpos,maxstored;
-
- //lockfrm();must locked in caller
- if(Frameid<0||Frameid>=nFramescount) return -1;
-
- maxstored=DBGetContactSettingWord(0,CLUIFrameModule,"StoredFrames",-1);
- if(maxstored==-1) return 0;
-
- storpos=LocateStorePosition(Frameid,maxstored);
- if(storpos==-1) return 0;
-
- DBLoadFrameSettingsAtPos(storpos,Frameid);
- //ulockfrm();
- return 0;
-}
-
-int CLUIFramesStoreFrameSettings(int Frameid)
-{
- int maxstored,storpos;
-
- //lockfrm();
- if(Frameid<0||Frameid>=nFramescount) return -1;
-
- maxstored=DBGetContactSettingWord(0,CLUIFrameModule,"StoredFrames",-1);
- if(maxstored==-1) maxstored=0;
-
- storpos=LocateStorePosition(Frameid,maxstored);
- if(storpos==-1) {storpos=maxstored; maxstored++;}
-
- DBStoreFrameSettingsAtPos(storpos,Frameid);
- DBWriteContactSettingWord(0,CLUIFrameModule,"StoredFrames",(WORD)maxstored);
- //ulockfrm();
- return 0;
-}
-
-int CLUIFramesStoreAllFrames()
-{
- int i;
- lockfrm();
- for(i=0;i<nFramescount;i++)
- CLUIFramesStoreFrameSettings(i);
- ulockfrm();
- return 0;
-}
-
-// Get client frame
-int CLUIFramesGetalClientFrame(void)
-{
- int i;
- if(alclientFrame!=-1)
- return alclientFrame;
-
- if(alclientFrame!=-1) {
- /* this value could become invalid if RemoveItemFromList was called,
- * so we double-check */
- if (alclientFrame<nFramescount) {
- if(Frames[alclientFrame].align==alClient) {
- return alclientFrame;
- }
- }
-}
-
- for(i=0;i<nFramescount;i++)
- if(Frames[i].align==alClient) {
- alclientFrame=i;
- return i;
- }
- //pluginLink
- return -1;
-}
-
-HMENU CLUIFramesCreateMenuForFrame(int frameid,int root,int popuppos,char *addservice)
-{
- CLISTMENUITEM mi;
- //TMO_MenuItem tmi;
- HANDLE menuid;
- int framepos=id2pos(frameid);
-
- ZeroMemory(&mi,sizeof(mi));
-
- mi.cbSize=sizeof(mi);
- mi.hIcon=LoadIcon(g_hInst,MAKEINTRESOURCE(IDI_CLIENTMIRANDA));
- mi.pszPopupName=(char *)root;
- mi.popupPosition=frameid;
- mi.position=popuppos++;
- mi.pszName=LPGEN("&FrameTitle");
- mi.flags=CMIF_CHILDPOPUP|CMIF_GRAYED;
- mi.pszContactOwner=(char *)0;
- menuid=(HANDLE)CallService(addservice,0,(LPARAM)&mi);
- if(frameid==-1) contMITitle=menuid;
- else Frames[framepos].MenuHandles.MITitle=menuid;
-
- popuppos+=100000;
- mi.hIcon=NULL;
- mi.cbSize=sizeof(mi);
- mi.pszPopupName=(char *)root;
- mi.popupPosition=frameid;
- mi.position=popuppos++;
- mi.pszName=LPGEN("&Visible");
- mi.flags=CMIF_CHILDPOPUP|CMIF_CHECKED;
- mi.pszContactOwner=(char *)0;
- mi.pszService=MS_CLIST_FRAMES_SHFRAME;
- menuid=(HANDLE)CallService(addservice,0,(LPARAM)&mi);
- if(frameid==-1) contMIVisible=menuid;
- else Frames[framepos].MenuHandles.MIVisible=menuid;
-
- mi.pszPopupName=(char *)root;
- mi.popupPosition=frameid;
- mi.position=popuppos++;
- mi.pszName=LPGEN("&Show TitleBar");
- mi.flags=CMIF_CHILDPOPUP|CMIF_CHECKED;
- mi.pszService=MS_CLIST_FRAMES_SHFRAMETITLEBAR;
- mi.pszContactOwner=(char *)0;
- menuid=(HANDLE)CallService(addservice,0,(LPARAM)&mi);
- if(frameid==-1) contMITBVisible=menuid;
- else Frames[framepos].MenuHandles.MITBVisible=menuid;
-
-
- popuppos+=100000;
-
- mi.pszPopupName=(char *)root;
- mi.popupPosition=frameid;
- mi.position=popuppos++;
- mi.pszName=LPGEN("&Locked");
- mi.flags=CMIF_CHILDPOPUP|CMIF_CHECKED;
- mi.pszService=MS_CLIST_FRAMES_ULFRAME;
- mi.pszContactOwner=(char *)0;
- menuid=(HANDLE)CallService(addservice,0,(LPARAM)&mi);
- if(frameid==-1) contMILock=menuid;
- else Frames[framepos].MenuHandles.MILock=menuid;
-
- mi.pszPopupName=(char *)root;
- mi.popupPosition=frameid;
- mi.position=popuppos++;
- mi.pszName=LPGEN("&Collapsed");
- mi.flags=CMIF_CHILDPOPUP|CMIF_CHECKED;
- mi.pszService=MS_CLIST_FRAMES_UCOLLFRAME;
- mi.pszContactOwner=(char *)0;
- menuid=(HANDLE)CallService(addservice,0,(LPARAM)&mi);
- if(frameid==-1) contMIColl=menuid;
- else Frames[framepos].MenuHandles.MIColl=menuid;
-
- //floating
- mi.pszPopupName=(char *)root;
- mi.popupPosition=frameid;
- mi.position=popuppos++;
- mi.pszName=LPGEN("&Floating Mode");
- mi.flags=CMIF_CHILDPOPUP;
- mi.pszService="Set_Floating";
- mi.pszContactOwner=(char *)0;
- menuid=(HANDLE)CallService(addservice,0,(LPARAM)&mi);
- if(frameid==-1) contMIFloating=menuid;
- else Frames[framepos].MenuHandles.MIFloating=menuid;
-
-
- popuppos+=100000;
-
- mi.pszPopupName=(char *)root;
- mi.popupPosition=frameid;
- mi.position=popuppos++;
- mi.pszName=LPGEN("&Border");
- mi.flags=CMIF_CHILDPOPUP|CMIF_CHECKED;
- mi.pszService=MS_CLIST_FRAMES_SETUNBORDER;
- mi.pszContactOwner=(char *)0;
- menuid=(HANDLE)CallService(addservice,0,(LPARAM)&mi);
- if(frameid==-1) contMIBorder=menuid;
- else Frames[framepos].MenuHandles.MIBorder=menuid;
-
- popuppos+=100000;
-
- {
- //alignment root
- mi.pszPopupName=(char *)root;
- mi.popupPosition=frameid;
- mi.position=popuppos++;
- mi.pszName=LPGEN("&Align");
- mi.flags=CMIF_CHILDPOPUP|CMIF_ROOTPOPUP;
- mi.pszService="";
- mi.pszContactOwner=(char *)0;
- menuid=(HANDLE)CallService(addservice,0,(LPARAM)&mi);
- if(frameid==-1) contMIAlignRoot=menuid;
- else Frames[framepos].MenuHandles.MIAlignRoot=menuid;
-
- mi.flags=CMIF_CHILDPOPUP;
- //align top
- mi.pszPopupName=(char *)menuid;
- mi.popupPosition=frameid;
- mi.position=popuppos++;
- mi.pszName=LPGEN("&Top");
- mi.pszService=CLUIFRAMESSETALIGNALTOP;
- mi.pszContactOwner=(char *)alTop;
- menuid=(HANDLE)CallService(addservice,0,(LPARAM)&mi);
- if(frameid==-1) contMIAlignTop=menuid;
- else Frames[framepos].MenuHandles.MIAlignTop=menuid;
-
-
- //align client
- mi.position=popuppos++;
- mi.pszName=LPGEN("&Client");
- mi.pszService=CLUIFRAMESSETALIGNALCLIENT;
- mi.pszContactOwner=(char *)alClient;
- menuid=(HANDLE)CallService(addservice,0,(LPARAM)&mi);
- if(frameid==-1) contMIAlignClient=menuid;
- else Frames[framepos].MenuHandles.MIAlignClient=menuid;
-
- //align bottom
- mi.position=popuppos++;
- mi.pszName=LPGEN("&Bottom");
- mi.pszService=CLUIFRAMESSETALIGNALBOTTOM;
- mi.pszContactOwner=(char *)alBottom;
- menuid=(HANDLE)CallService(addservice,0,(LPARAM)&mi);
- if(frameid==-1) contMIAlignBottom=menuid;
- else Frames[framepos].MenuHandles.MIAlignBottom=menuid;
-
- }
-
- { //position
- //position root
- mi.pszPopupName=(char *)root;
- mi.popupPosition=frameid;
- mi.position=popuppos++;
- mi.pszName=LPGEN("&Position");
- mi.flags=CMIF_CHILDPOPUP|CMIF_ROOTPOPUP;
- mi.pszService="";
- mi.pszContactOwner=(char *)0;
- menuid=(HANDLE)CallService(addservice,0,(LPARAM)&mi);
-
- mi.pszPopupName=(char *)menuid;
- mi.popupPosition=frameid;
- mi.position=popuppos++;
- mi.pszName=LPGEN("&Up");
- mi.flags=CMIF_CHILDPOPUP;
- mi.pszService=CLUIFRAMESMOVEUPDOWN;
- mi.pszContactOwner=(char *)1;
- CallService(addservice,0,(LPARAM)&mi);
-
- mi.pszPopupName=(char *)menuid;
- mi.popupPosition=frameid;
- mi.position=popuppos++;
- mi.pszName=LPGEN("&Down");
- mi.flags=CMIF_CHILDPOPUP;
- mi.pszService=CLUIFRAMESMOVEUPDOWN;
- mi.pszContactOwner=(char *)-1;
- CallService(addservice,0,(LPARAM)&mi);
-
- }
-
- return 0;
-}
-
-INT_PTR ModifyMItem(WPARAM wParam,LPARAM lParam)
-{
-return ModifyMenuItemProxy(wParam,lParam);
-}
-
-
-static int CLUIFramesModifyContextMenuForFrame(WPARAM wParam,LPARAM lParam)
-{
- int pos;
- CLISTMENUITEM mi;
- //TMO_MenuItem tmi;
-
- lockfrm();
- pos=id2pos(wParam);
-
- if(pos>=0&&pos<nFramescount) {
- memset(&mi,0,sizeof(mi));
- mi.cbSize=sizeof(mi);
- mi.flags=CMIM_NAME|CMIF_CHILDPOPUP|CMIF_TCHAR;
- mi.ptszName=Frames[pos].TitleBar.tbname ? Frames[pos].TitleBar.tbname : Frames[pos].name;
- ModifyMItem((WPARAM)contMITitle,(LPARAM)&mi);
-
- mi.flags=CMIM_FLAGS|CMIF_CHILDPOPUP;
- if(Frames[pos].visible) mi.flags|=CMIF_CHECKED;
- ModifyMItem((WPARAM)contMIVisible,(LPARAM)&mi);
-
- mi.flags=CMIM_FLAGS|CMIF_CHILDPOPUP;
- if(Frames[pos].Locked) mi.flags|=CMIF_CHECKED;
- ModifyMItem((WPARAM)contMILock,(LPARAM)&mi);
-
- mi.flags=CMIM_FLAGS|CMIF_CHILDPOPUP;
- if(Frames[pos].TitleBar.ShowTitleBar) mi.flags|=CMIF_CHECKED;
- ModifyMItem((WPARAM)contMITBVisible,(LPARAM)&mi);
-
- mi.flags=CMIM_FLAGS|CMIF_CHILDPOPUP;
- if(Frames[pos].floating) mi.flags|=CMIF_CHECKED;
- ModifyMItem((WPARAM)contMIFloating,(LPARAM)&mi);
-
- mi.flags=CMIM_FLAGS|CMIF_CHILDPOPUP;
- if ((Frames[pos].UseBorder)) mi.flags|=CMIF_CHECKED;
- ModifyMItem((WPARAM)contMIBorder,(LPARAM)&mi);
-
-
-
- mi.flags=CMIM_FLAGS|CMIF_CHILDPOPUP;
- if(Frames[pos].align&alTop) mi.flags|=CMIF_CHECKED;
- ModifyMItem((WPARAM)contMIAlignTop,(LPARAM)&mi);
-
- mi.flags=CMIM_FLAGS|CMIF_CHILDPOPUP;
- if(Frames[pos].align&alClient) mi.flags|=CMIF_CHECKED;
- ModifyMItem((WPARAM)contMIAlignClient,(LPARAM)&mi);
-
- mi.flags=CMIM_FLAGS|CMIF_CHILDPOPUP;
- if(Frames[pos].align&alBottom) mi.flags|=CMIF_CHECKED;
- ModifyMItem((WPARAM)contMIAlignBottom,(LPARAM)&mi);
-
-
- mi.flags=CMIM_FLAGS|CMIF_CHILDPOPUP;
- if(Frames[pos].collapsed) mi.flags|=CMIF_CHECKED;
- if ((!Frames[pos].visible)||(Frames[pos].Locked)||(pos==CLUIFramesGetalClientFrame())) mi.flags|=CMIF_GRAYED;
- ModifyMItem((WPARAM)contMIColl,(LPARAM)&mi);
- }
- ulockfrm();
- return 0;
-}
-
-INT_PTR CLUIFramesModifyMainMenuItems(WPARAM wParam,LPARAM lParam)
-{
- int pos;
- CLISTMENUITEM mi;
- //TMO_MenuItem tmi;
-
- lockfrm();
- pos=id2pos(wParam);
-
- if (pos>=0&&pos<nFramescount) {
- memset(&mi,0,sizeof(mi));
- mi.cbSize=sizeof(mi);
- mi.flags=CMIM_NAME|CMIF_CHILDPOPUP|CMIF_TCHAR;
- mi.ptszName=Frames[pos].TitleBar.tbname ? Frames[pos].TitleBar.tbname : Frames[pos].name;
- CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)Frames[pos].MenuHandles.MITitle,(LPARAM)&mi);
-
- mi.flags=CMIM_FLAGS|CMIF_CHILDPOPUP;
- if(Frames[pos].visible) mi.flags|=CMIF_CHECKED;
- CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)Frames[pos].MenuHandles.MIVisible,(LPARAM)&mi);
-
- mi.flags=CMIM_FLAGS|CMIF_CHILDPOPUP;
- if(Frames[pos].Locked) mi.flags|=CMIF_CHECKED;
- CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)Frames[pos].MenuHandles.MILock,(LPARAM)&mi);
-
- mi.flags=CMIM_FLAGS|CMIF_CHILDPOPUP;
- if(Frames[pos].TitleBar.ShowTitleBar) mi.flags|=CMIF_CHECKED;
- CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)Frames[pos].MenuHandles.MITBVisible,(LPARAM)&mi);
-
- mi.flags=CMIM_FLAGS|CMIF_CHILDPOPUP;
- if(Frames[pos].floating) mi.flags|=CMIF_CHECKED;
- CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)Frames[pos].MenuHandles.MIFloating,(LPARAM)&mi);
-
- mi.flags=CMIM_FLAGS|CMIF_CHILDPOPUP;
- if ((Frames[pos].UseBorder)) mi.flags|=CMIF_CHECKED;
- CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)Frames[pos].MenuHandles.MIBorder,(LPARAM)&mi);
-
- mi.flags=CMIM_FLAGS|CMIF_CHILDPOPUP|((Frames[pos].align&alClient)?CMIF_GRAYED:0);
- if(Frames[pos].align&alTop) mi.flags|=CMIF_CHECKED;
- CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)Frames[pos].MenuHandles.MIAlignTop,(LPARAM)&mi);
-
- mi.flags=CMIM_FLAGS|CMIF_CHILDPOPUP;
- if(Frames[pos].align&alClient) mi.flags|=CMIF_CHECKED;
- CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)Frames[pos].MenuHandles.MIAlignClient,(LPARAM)&mi);
-
- mi.flags=CMIM_FLAGS|CMIF_CHILDPOPUP|((Frames[pos].align&alClient)?CMIF_GRAYED:0);
- if(Frames[pos].align&alBottom) mi.flags|=CMIF_CHECKED;
- CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)Frames[pos].MenuHandles.MIAlignBottom,(LPARAM)&mi);
-
-/*
- mi.flags=CMIM_FLAGS|CMIF_CHILDPOPUP|((Frames[pos].align&alClient)?CMIF_GRAYED:0);
- if(Frames[pos].align&alTop) mi.flags|=CMIF_CHECKED;
- ModifyMItem((WPARAM)contMIAlignTop,(LPARAM)&mi);
-
- mi.flags=CMIM_FLAGS|CMIF_CHILDPOPUP|CMIF_GRAYED;
- if(Frames[pos].align&alClient) mi.flags|=CMIF_CHECKED;
- ModifyMItem((WPARAM)contMIAlignClient,(LPARAM)&mi);
-
- mi.flags=CMIM_FLAGS|CMIF_CHILDPOPUP|((Frames[pos].align&alClient)?CMIF_GRAYED:0);
- if(Frames[pos].align&alBottom) mi.flags|=CMIF_CHECKED;
- ModifyMItem((WPARAM)contMIAlignBottom,(LPARAM)&mi);
-
-*/
-
-
-
- mi.flags=CMIM_FLAGS|CMIF_CHILDPOPUP;
- if(Frames[pos].collapsed) mi.flags|=CMIF_CHECKED;
- if ((!Frames[pos].visible)||Frames[pos].Locked||(pos==CLUIFramesGetalClientFrame())) mi.flags|=CMIF_GRAYED;
- CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)Frames[pos].MenuHandles.MIColl,(LPARAM)&mi);
- }
- ulockfrm();
- return 0;
-}
-
-//hiword(wParam)=frameid,loword(wParam)=flag
-INT_PTR CLUIFramesGetFrameOptions(WPARAM wParam,LPARAM lParam)
-{
- int pos;
- INT_PTR retval;
-
- if (FramesSysNotStarted) return 0;
-
- lockfrm();
- pos=id2pos(HIWORD(wParam));
- if(pos<0||pos>=nFramescount) {
- ulockfrm();
- return -1;
- }
-
- switch(LOWORD(wParam))
- {
- case FO_FLAGS:
- retval=0;
- if(Frames[pos].visible) retval|=F_VISIBLE;
- if (!Frames[pos].collapsed) retval|=F_UNCOLLAPSED;
- if(Frames[pos].Locked) retval|=F_LOCKED;
- if(Frames[pos].TitleBar.ShowTitleBar) retval|=F_SHOWTB;
- if(Frames[pos].TitleBar.ShowTitleBarTip) retval|=F_SHOWTBTIP;
- if (!(GetWindowLongPtr(Frames[pos].hWnd,GWL_STYLE)&WS_BORDER)) retval|=F_NOBORDER;
- break;
-
- case FO_NAME:
- retval=(INT_PTR)Frames[pos].name;
- break;
-
- case FO_TBNAME:
- retval=(INT_PTR)Frames[pos].TitleBar.tbname;
- break;
-
- case FO_TBTIPNAME:
- retval=(INT_PTR)Frames[pos].TitleBar.tooltip;
- break;
-
- case FO_TBSTYLE:
- retval=GetWindowLongPtr(Frames[pos].TitleBar.hwnd,GWL_STYLE);
- break;
-
- case FO_TBEXSTYLE:
- retval=GetWindowLongPtr(Frames[pos].TitleBar.hwnd,GWL_EXSTYLE);
- break;
-
- case FO_ICON:
- retval=(INT_PTR)Frames[pos].TitleBar.hicon;
- break;
-
- case FO_HEIGHT:
- retval=(INT_PTR)Frames[pos].height;
- break;
-
- case FO_ALIGN:
- retval=(INT_PTR)Frames[pos].align;
- break;
- case FO_FLOATING:
- retval=(INT_PTR)Frames[pos].floating;
- break;
- default:
- retval=-1;
- break;
- }
- ulockfrm();
- return retval;
-}
-
-//hiword(wParam)=frameid,loword(wParam)=flag
-INT_PTR CLUIFramesSetFrameOptions(WPARAM wParam,LPARAM lParam)
-{
- int pos;
- INT_PTR retval; // value to be returned
-
- lockfrm();
- pos=id2pos(HIWORD(wParam));
- if(pos<0||pos>=nFramescount) {
- ulockfrm();
- return -1;
- }
-
- switch(LOWORD(wParam) & ~FO_UNICODETEXT)
- {
- case FO_FLAGS:{
- int flag=lParam;
- int style;
-
- Frames[pos].dwFlags=flag;
- Frames[pos].visible=FALSE;
- if(flag&F_VISIBLE) Frames[pos].visible=TRUE;
-
- Frames[pos].collapsed=TRUE;
- if(flag&F_UNCOLLAPSED) Frames[pos].collapsed=FALSE;
-
- Frames[pos].Locked=FALSE;
- if(flag&F_LOCKED) Frames[pos].Locked=TRUE;
-
- Frames[pos].UseBorder=TRUE;
- if(flag&F_NOBORDER) Frames[pos].UseBorder=FALSE;
-
- Frames[pos].TitleBar.ShowTitleBar=FALSE;
- if(flag&F_SHOWTB) Frames[pos].TitleBar.ShowTitleBar=TRUE;
-
- Frames[pos].TitleBar.ShowTitleBarTip=FALSE;
- if(flag&F_SHOWTBTIP) Frames[pos].TitleBar.ShowTitleBarTip=TRUE;
-
- SendMessage(Frames[pos].TitleBar.hwndTip,TTM_ACTIVATE,(WPARAM)Frames[pos].TitleBar.ShowTitleBarTip,0);
-
- style=(int)GetWindowLongPtr(Frames[pos].hWnd,GWL_STYLE);
- style|=WS_BORDER;
- if(flag&F_NOBORDER) {style&=(~WS_BORDER);}
- SetWindowLongPtr(Frames[pos].hWnd,GWL_STYLE,(LONG)style);
- ulockfrm();
- CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,(LPARAM)0);
- return 0;
- }
-
- case FO_NAME:
- if(lParam==(LPARAM)NULL) {ulockfrm(); return -1;}
- mir_free(Frames[pos].name);
- Frames[pos].name=mir_tstrdup((LPTSTR)lParam);
- ulockfrm();
- return 0;
-
- case FO_TBNAME:
- if(lParam==(LPARAM)NULL) {ulockfrm(); return(-1);}
- mir_free(Frames[pos].TitleBar.tbname);
- Frames[pos].TitleBar.tbname=mir_tstrdup((LPTSTR)lParam);
- ulockfrm();
- if (Frames[pos].floating&&(Frames[pos].TitleBar.tbname!=NULL)){SetWindowText(Frames[pos].ContainerWnd,Frames[pos].TitleBar.tbname);}
- return 0;
-
- case FO_TBTIPNAME:
- if(lParam==(LPARAM)NULL) {ulockfrm(); return(-1);}
- mir_free(Frames[pos].TitleBar.tooltip);
- Frames[pos].TitleBar.tooltip=mir_tstrdup((LPTSTR)lParam);
- UpdateTBToolTip(pos);
- ulockfrm();
- return 0;
-
- case FO_TBSTYLE:
- SetWindowLongPtr(Frames[pos].TitleBar.hwnd,GWL_STYLE,lParam);
- ulockfrm();
- return 0;
-
- case FO_TBEXSTYLE:
- SetWindowLongPtr(Frames[pos].TitleBar.hwnd,GWL_EXSTYLE,lParam);
- ulockfrm();
- return 0;
-
- case FO_ICON:
- Frames[pos].TitleBar.hicon=(HICON)lParam;
- ulockfrm();
- return 0;
-
- case FO_HEIGHT:
- if(lParam<0) {ulockfrm(); return -1;}
- retval=Frames[pos].height;
- Frames[pos].height=lParam;
- if (!CLUIFramesFitInSize()) Frames[pos].height=retval;
- retval=Frames[pos].height;
- ulockfrm();
-
- return retval;
-
- case FO_FLOATING:
- if(lParam<0) {ulockfrm(); return -1;}
-
- {
- int id=Frames[pos].id;
- Frames[pos].floating=!(lParam);
- ulockfrm();
-
- CLUIFrameSetFloat(id,1);//lparam=1 use stored width and height
- return(wParam);
- }
-
- case FO_ALIGN:
- if (!(lParam&alTop||lParam&alBottom||lParam&alClient))
- {
- OutputDebugStringA("Wrong align option \r\n");
- return (-1);
- }
-
- if ((lParam&alClient)&&(CLUIFramesGetalClientFrame()>=0)) { //only one alClient frame possible
- alclientFrame=-1;//recalc it
- ulockfrm();
- return -1;
- }
- Frames[pos].align=lParam;
-
- ulockfrm();
- return(0);
- }
- ulockfrm();
- CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,(LPARAM)0);
- return -1;
-}
-
-//wparam=lparam=0
-static INT_PTR CLUIFramesShowAll(WPARAM wParam,LPARAM lParam)
-{
- int i;
- for(i=0;i<nFramescount;i++)
- Frames[i].visible=TRUE;
- CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,(LPARAM)0);
- return 0;
-}
-
-//wparam=lparam=0
-INT_PTR CLUIFramesShowAllTitleBars(WPARAM wParam,LPARAM lParam)
-{
- int i;
- for(i=0;i<nFramescount;i++)
- Frames[i].TitleBar.ShowTitleBar=TRUE;
- CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,(LPARAM)0);
- return 0;
-}
-
-//wparam=lparam=0
-INT_PTR CLUIFramesHideAllTitleBars(WPARAM wParam,LPARAM lParam)
-{
- int i;
- for(i=0;i<nFramescount;i++)
- Frames[i].TitleBar.ShowTitleBar=FALSE;
- CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,(LPARAM)0);
- return 0;
-}
-
-//wparam=frameid
-INT_PTR CLUIFramesShowHideFrame(WPARAM wParam,LPARAM lParam)
-{
- int pos;
-
- lockfrm();
- pos=id2pos(wParam);
- if(pos>=0&&(int)pos<nFramescount)
- Frames[pos].visible=!Frames[pos].visible;
- if (Frames[pos].floating){CLUIFrameResizeFloatingFrame(pos);}
- ulockfrm();
- if (!Frames[pos].floating) CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,(LPARAM)0);
- return 0;
-}
-
-//wparam=frameid
-INT_PTR CLUIFramesShowHideFrameTitleBar(WPARAM wParam,LPARAM lParam)
-{
- int pos;
-
- lockfrm();
- pos=id2pos(wParam);
- if(pos>=0&&(int)pos<nFramescount)
- Frames[pos].TitleBar.ShowTitleBar=!Frames[pos].TitleBar.ShowTitleBar;
- //if (Frames[pos].height>
-
- ulockfrm();
-
- CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,(LPARAM)0);
-
-
- return 0;
-}
-//wparam=frameid
-//lparam=-1 up ,1 down
-INT_PTR CLUIFramesMoveUpDown(WPARAM wParam,LPARAM lParam)
-{
- int pos,i,curpos,curalign,v,tmpval;
-
- lockfrm();
- pos=id2pos(wParam);
- if(pos>=0&&(int)pos<nFramescount) {
- SortData *sd;
- curpos=Frames[pos].order;
- curalign=Frames[pos].align;
- v=0;
- sd=(SortData*)malloc(sizeof(SortData)*nFramescount);
- memset(sd,0,sizeof(SortData)*nFramescount);
- for (i=0;i<nFramescount;i++)
- {
- if (Frames[i].floating||(!Frames[i].visible)||(Frames[i].align!=curalign)){continue;}
-
- sd[v].order=Frames[i].order;
- sd[v].realpos=i;
- v++;
- }
- if (v==0){ulockfrm();return(0);}
- qsort(sd,v,sizeof(SortData),sortfunc);
- for (i=0;i<v;i++)
- {
- if (sd[i].realpos==pos)
- {
- if (lParam==-1)
- {
- if (i>=v-1) break;
- tmpval=Frames[sd[i+1].realpos].order;
- Frames[sd[i+1].realpos].order=Frames[pos].order;
- Frames[pos].order=tmpval;
- break;
- }
- if (lParam==+1)
- {
- if (i<1) break;
- tmpval=Frames[sd[i-1].realpos].order;
- Frames[sd[i-1].realpos].order=Frames[pos].order;
- Frames[pos].order=tmpval;
- break;
- }
-
-
- }
- }
-
- if (sd!=NULL){free(sd);}
- CLUIFramesStoreFrameSettings(pos);
- CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,0);
-
- }
- ulockfrm();
- return(0);
-}
-
-
-
-//wparam=frameid
-//lparam=alignment
-INT_PTR CLUIFramesSetAlign(WPARAM wParam,LPARAM lParam)
-{
- CLUIFramesSetFrameOptions(MAKEWPARAM(FO_ALIGN,wParam),lParam);
- CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,0);
- return(0);
-}
-INT_PTR CLUIFramesSetAlignalTop(WPARAM wParam,LPARAM lParam)
-{
- return CLUIFramesSetAlign(wParam,alTop);
-}
-INT_PTR CLUIFramesSetAlignalBottom(WPARAM wParam,LPARAM lParam)
-{
- return CLUIFramesSetAlign(wParam,alBottom);
-}
-INT_PTR CLUIFramesSetAlignalClient(WPARAM wParam,LPARAM lParam)
-{
- return CLUIFramesSetAlign(wParam,alClient);
-}
-
-
-//wparam=frameid
-INT_PTR CLUIFramesLockUnlockFrame(WPARAM wParam,LPARAM lParam)
-{
- int pos;
-
- lockfrm();
- pos=id2pos(wParam);
- if(pos>=0&&(int)pos<nFramescount) {
- Frames[pos].Locked=!Frames[pos].Locked;
- CLUIFramesStoreFrameSettings(pos);
- }
- ulockfrm();
- return 0;
-}
-
-//wparam=frameid
-INT_PTR CLUIFramesSetUnSetBorder(WPARAM wParam,LPARAM lParam)
-{
- RECT rc;
- int FrameId,oldflags;
- HWND hw;
- boolean flt;
-
- lockfrm();
- FrameId=id2pos(wParam);
- if (FrameId==-1){ulockfrm();return(-1);}
- flt=
- oldflags=CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS,MAKEWPARAM(FO_FLAGS,wParam),0);
- if (oldflags&F_NOBORDER)
- {
- oldflags&=(~F_NOBORDER);
- }
- else
- {
- oldflags|=F_NOBORDER;
- }
- hw = Frames[FrameId].hWnd;
- GetWindowRect(hw,&rc);
-
- ulockfrm();
- CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_FLAGS,wParam),oldflags);
-// CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,(LPARAM)0);
- /*
- if (Frames[FrameId].floating){
- CLUIFrameResizeFloatingFrame(FrameId);
- }
- */
-
- {
- SetWindowPos(hw,0,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_DRAWFRAME);
- }
- return(0);
-}
-//wparam=frameid
-INT_PTR CLUIFramesCollapseUnCollapseFrame(WPARAM wParam,LPARAM lParam)
-{
- int FrameId;
-
- lockfrm();
- FrameId=id2pos(wParam);
- if(FrameId>=0&&FrameId<nFramescount)
- {
- int oldHeight;
-
- // do not collapse/uncollapse client/locked/invisible frames
- if(Frames[FrameId].align==alClient&&!(Frames[FrameId].Locked||(!Frames[FrameId].visible)||Frames[FrameId].floating))
- {
- RECT rc;
- if(CallService(MS_CLIST_DOCKINGISDOCKED,0,0)) {ulockfrm();return 0;}
- if(DBGetContactSettingByte(NULL,"CLUI","AutoSize",0)) {ulockfrm();return 0;}
- GetWindowRect(pcli->hwndContactList,&rc);
-
- if(Frames[FrameId].collapsed==TRUE) {
- rc.bottom-=rc.top;
- rc.bottom-=Frames[FrameId].height;
- Frames[FrameId].HeightWhenCollapsed=Frames[FrameId].height;
- Frames[FrameId].collapsed=FALSE;
- }
- else
- {
- rc.bottom-=rc.top;
- rc.bottom+=Frames[FrameId].HeightWhenCollapsed;
- Frames[FrameId].collapsed=TRUE;
- }
-
- SetWindowPos(pcli->hwndContactList,NULL,0,0,rc.right-rc.left,rc.bottom,SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE);
-
- CLUIFramesStoreAllFrames();
- ulockfrm();
- return 0;
-
- }
- if(Frames[FrameId].Locked||(!Frames[FrameId].visible)) return 0;
-
- oldHeight=Frames[FrameId].height;
-
- // if collapsed, uncollapse
- if(Frames[FrameId].collapsed==TRUE) {
- Frames[FrameId].HeightWhenCollapsed=Frames[FrameId].height;
- Frames[FrameId].height=UNCOLLAPSED_FRAME_SIZE;
- Frames[FrameId].collapsed=FALSE;
- }
- // if uncollapsed, collapse
- else {
- Frames[FrameId].height=Frames[FrameId].HeightWhenCollapsed;
- Frames[FrameId].collapsed=TRUE;
- }
-
- if (!Frames[FrameId].floating)
- {
-
- if (!CLUIFramesFitInSize()) {
- //cant collapse,we can resize only for height<alclient frame height
- int alfrm=CLUIFramesGetalClientFrame();
-
- if(alfrm!=-1) {
- Frames[FrameId].collapsed=FALSE;
- if(Frames[alfrm].height>2*UNCOLLAPSED_FRAME_SIZE) {
- oldHeight=Frames[alfrm].height-UNCOLLAPSED_FRAME_SIZE;
- Frames[FrameId].collapsed=TRUE;
- }
- }else
- {
- int i,sumheight=0;
- for(i=0;i<nFramescount;i++) {
- if ((Frames[i].align!=alClient)&&(!Frames[i].floating)&&(Frames[i].visible)&&(!Frames[i].needhide)) {
- sumheight+=(Frames[i].height)+(TitleBarH*btoint(Frames[i].TitleBar.ShowTitleBar))+2;
- return FALSE;
- }
- if(sumheight>ContactListHeight-0-2)
- {
- Frames[FrameId].height=(ContactListHeight-0-2)-sumheight;
- }
-
- }
- }
-
- Frames[FrameId].height=oldHeight;
-
- if(Frames[FrameId].collapsed==FALSE) {
-
- if (!Frames[FrameId].floating)
- {
- }
- else
- {
- //SetWindowPos(Frames[FrameId].hWnd,HWND_TOP,0,0,Frames[FrameId].wndSize.right-Frames[FrameId].wndSize.left,Frames[FrameId].height,SWP_SHOWWINDOW|SWP_NOMOVE);
- SetWindowPos(Frames[FrameId].ContainerWnd,HWND_TOP,0,0,Frames[FrameId].wndSize.right-Frames[FrameId].wndSize.left+6,Frames[FrameId].height+DEFAULT_TITLEBAR_HEIGHT+4,SWP_SHOWWINDOW|SWP_NOMOVE);
- }
-
-
- ulockfrm();return -1;}//redraw not needed
- }
- }//floating test
- ulockfrm();
- //CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,0);
- if (!Frames[FrameId].floating)
- {
- CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,0);
- }
- else
- {
- //SetWindowPos(Frames[FrameId].hWnd,HWND_TOP,0,0,Frames[FrameId].wndSize.right-Frames[FrameId].wndSize.left,Frames[FrameId].height,SWP_SHOWWINDOW|SWP_NOMOVE);
- RECT contwnd;
- GetWindowRect(Frames[FrameId].ContainerWnd,&contwnd);
- contwnd.top=contwnd.bottom-contwnd.top;//height
- contwnd.left=contwnd.right-contwnd.left;//width
-
- contwnd.top-=(oldHeight-Frames[FrameId].height);//newheight
- SetWindowPos(Frames[FrameId].ContainerWnd,HWND_TOP,0,0,contwnd.left,contwnd.top,SWP_SHOWWINDOW|SWP_NOMOVE);
- }
- CLUIFramesStoreAllFrames();
- return(0);
- }
- else
- return -1;
-
- ulockfrm();
-
- return 0;
-}
-
-static int CLUIFramesLoadMainMenu()
-{
- CLISTMENUITEM mi;
- //TMO_MenuItem tmi;
- int i,separator;
-
- if (!(ServiceExists(MS_CLIST_REMOVEMAINMENUITEM)))
- {
- //hmm new menu system not used..so display only two items and warning message
- ZeroMemory(&mi,sizeof(mi));
- mi.cbSize=sizeof(mi);
- // create "show all frames" menu
- mi.hIcon=NULL;//LoadIcon(g_hInst,MAKEINTRESOURCE(IDI_MIRANDA));
- mi.flags=CMIF_GRAYED;
- mi.position=10000000;
- mi.pszPopupName=LPGEN("Frames");
- mi.pszName=LPGEN("New Menu System not Found...");
- mi.pszService="";
- CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&mi);
-
- // create "show all frames" menu
- mi.hIcon=NULL;//LoadIcon(g_hInst,MAKEINTRESOURCE(IDI_MIRANDA));
- mi.flags=0;
- mi.position=10100000;
- mi.pszPopupName=LPGEN("Frames");
- mi.pszName=LPGEN("Show All Frames");
- mi.pszService=MS_CLIST_FRAMES_SHOWALLFRAMES;
- CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&mi);
-
- mi.hIcon=NULL;//LoadIcon(g_hInst,MAKEINTRESOURCE(IDI_HELP));
- mi.position=10100001;
- mi.pszPopupName=LPGEN("Frames");
- mi.flags=CMIF_CHILDPOPUP;
- mi.pszName=LPGEN("Show All Titlebars");
- mi.pszService=MS_CLIST_FRAMES_SHOWALLFRAMESTB;
- CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&mi);
-
- return(0);
- }
-
-
- if(MainMIRoot!=(HANDLE)-1) { CallService(MS_CLIST_REMOVEMAINMENUITEM,(WPARAM)MainMIRoot,0); MainMIRoot=(HANDLE)-1;}
-
- ZeroMemory(&mi,sizeof(mi));
- mi.cbSize=sizeof(mi);
-
- // create root menu
- mi.hIcon=LoadIcon(g_hInst,MAKEINTRESOURCE(IDI_CLIENTMIRANDA));
- mi.flags=CMIF_ROOTPOPUP;
- mi.position=3000090000;
- mi.pszPopupName=(char*)-1;
- mi.pszName=LPGEN("Frames");
- mi.pszService=0;
- MainMIRoot=(HANDLE)CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&mi);
-
- // create frames menu
- separator=3000200000;
- for (i=0;i<nFramescount;i++) {
- mi.hIcon=Frames[i].TitleBar.hicon;
- mi.flags=CMIF_CHILDPOPUP|CMIF_ROOTPOPUP|CMIF_TCHAR;
- mi.position=separator;
- mi.pszPopupName=(char*)MainMIRoot;
- mi.ptszName=Frames[i].TitleBar.tbname ? Frames[i].TitleBar.tbname : Frames[i].name;
- mi.pszService=0;
- Frames[i].MenuHandles.MainMenuItem=(HANDLE)CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&mi);
- CLUIFramesCreateMenuForFrame(Frames[i].id,(int)Frames[i].MenuHandles.MainMenuItem,separator,MS_CLIST_ADDMAINMENUITEM);
- CLUIFramesModifyMainMenuItems(Frames[i].id,0);
- //NotifyEventHooks(hPreBuildFrameMenuEvent,i,(LPARAM)Frames[i].MenuHandles.MainMenuItem);
- CallService(MS_CLIST_FRAMEMENUNOTIFY,(WPARAM)Frames[i].id,(LPARAM)Frames[i].MenuHandles.MainMenuItem);
- separator++;
- }
-
- separator+=100000;
-
- // create "show all frames" menu
- mi.hIcon=NULL;//LoadIcon(g_hInst,MAKEINTRESOURCE(IDI_MIRANDA));
- mi.flags=CMIF_CHILDPOPUP;
- mi.position=separator++;
- mi.pszPopupName=(char*)MainMIRoot;
- mi.pszName=LPGEN("Show All Frames");
- mi.pszService=MS_CLIST_FRAMES_SHOWALLFRAMES;
- CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&mi);
-
- // create "show all titlebars" menu
- mi.hIcon=NULL;//LoadIcon(g_hInst,MAKEINTRESOURCE(IDI_HELP));
- mi.position=separator++;
- mi.pszPopupName=(char*)MainMIRoot;
- mi.flags=CMIF_CHILDPOPUP;
- mi.pszName=LPGEN("Show All Titlebars");
- mi.pszService=MS_CLIST_FRAMES_SHOWALLFRAMESTB;
- CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&mi);
-
- // create "hide all titlebars" menu
- mi.hIcon=NULL;//LoadIcon(g_hInst,MAKEINTRESOURCE(IDI_HELP));
- mi.position=separator++;
- mi.pszPopupName=(char*)MainMIRoot;
- mi.flags=CMIF_CHILDPOPUP;
- mi.pszName=LPGEN("Hide All Titlebars");
- mi.pszService=MS_CLIST_FRAMES_HIDEALLFRAMESTB;
- CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&mi);
-
- return 0;
-}
-
-static HFONT CLUILoadTitleBarFont()
-{
- char facename[]="MS Shell Dlg";
- HFONT hfont;
- LOGFONT logfont;
- memset(&logfont,0,sizeof(logfont));
- memcpy(logfont.lfFaceName,facename,sizeof(facename));
- logfont.lfWeight=FW_NORMAL;
- logfont.lfHeight=-10;
- hfont=CreateFontIndirect(&logfont);
- return hfont;
-}
-
-static int UpdateTBToolTip(int framepos)
-{
- {
- TOOLINFO ti;
-
- ZeroMemory(&ti,sizeof(ti));
- ti.cbSize=sizeof(ti);
- ti.lpszText=Frames[framepos].TitleBar.tooltip;
- ti.hinst=g_hInst;
- ti.uFlags=TTF_IDISHWND|TTF_SUBCLASS ;
- ti.uId=(UINT_PTR)Frames[framepos].TitleBar.hwnd;
-
- return(SendMessage(Frames[framepos].TitleBar.hwndTip,TTM_UPDATETIPTEXT,(WPARAM)0,(LPARAM)&ti));
- }
-
-}
-
-//wparam=(CLISTFrame*)clfrm
-INT_PTR CLUIFramesAddFrame(WPARAM wParam,LPARAM lParam)
-{
- int style,retval;
- CLISTFrame *clfrm=(CLISTFrame *)wParam;
-
- if(pcli->hwndContactList==0) return -1;
- if (FramesSysNotStarted) return -1;
- if(clfrm->cbSize!=sizeof(CLISTFrame)) return -1;
- if (!(TitleBarFont)) TitleBarFont=CLUILoadTitleBarFont();
-
- lockfrm();
- if(nFramescount>=MAX_FRAMES) { ulockfrm(); return -1;}
- Frames=(wndFrame*)realloc(Frames,sizeof(wndFrame)*(nFramescount+1));
-
- memset(&Frames[nFramescount],0,sizeof(wndFrame));
- Frames[nFramescount].id=NextFrameId++;
- Frames[nFramescount].align=clfrm->align;
- Frames[nFramescount].hWnd=clfrm->hWnd;
- Frames[nFramescount].height=clfrm->height;
- Frames[nFramescount].TitleBar.hicon=clfrm->hIcon;
- Frames[nFramescount].TitleBar.BackColour;
- Frames[nFramescount].floating=FALSE;
-
-
- //override tbbtip
- //clfrm->Flags|=F_SHOWTBTIP;
- //
- if (DBGetContactSettingByte(0,CLUIFrameModule,"RemoveAllBorders",0)==1)
- {
- clfrm->Flags|=F_NOBORDER;
- }
- Frames[nFramescount].dwFlags=clfrm->Flags;
-
- if (clfrm->name==NULL||((clfrm->Flags&F_UNICODE) ? lstrlenW(clfrm->wname) : lstrlenA(clfrm->name))==0) {
- Frames[nFramescount].name=(LPTSTR)malloc(255 * sizeof(TCHAR));
- GetClassName(Frames[nFramescount].hWnd,Frames[nFramescount].name,255);
- }
- else
- Frames[nFramescount].name=(clfrm->Flags&F_UNICODE) ? mir_u2t(clfrm->wname) : mir_a2t(clfrm->name);
- if (IsBadCodePtr((FARPROC)clfrm->TBname) || clfrm->TBname==NULL
- || ((clfrm->Flags&F_UNICODE) ? lstrlenW(clfrm->TBwname) : lstrlenA(clfrm->TBname)) == 0)
- Frames[nFramescount].TitleBar.tbname=mir_tstrdup(Frames[nFramescount].name);
- else
- Frames[nFramescount].TitleBar.tbname=(clfrm->Flags&F_UNICODE) ? mir_u2t(clfrm->TBwname) : mir_a2t(clfrm->TBname);
- Frames[nFramescount].needhide=FALSE;
- Frames[nFramescount].TitleBar.ShowTitleBar=(clfrm->Flags&F_SHOWTB?TRUE:FALSE);
- Frames[nFramescount].TitleBar.ShowTitleBarTip=(clfrm->Flags&F_SHOWTBTIP?TRUE:FALSE);
-
- Frames[nFramescount].collapsed = clfrm->Flags&F_UNCOLLAPSED?FALSE:TRUE;
- Frames[nFramescount].Locked = clfrm->Flags&F_LOCKED?TRUE:FALSE;
- Frames[nFramescount].visible = clfrm->Flags&F_VISIBLE?TRUE:FALSE;
-
- Frames[nFramescount].UseBorder=(clfrm->Flags&F_NOBORDER)?FALSE:TRUE;
-
-
- // create frame
- Frames[nFramescount].TitleBar.hwnd
- =CreateWindow(CLUIFrameTitleBarClassName,Frames[nFramescount].name,
- (DBGetContactSettingByte(0,CLUIFrameModule,"RemoveAllTitleBarBorders",0)?0:WS_BORDER)
-
- |WS_CHILD|WS_CLIPCHILDREN|
- (Frames[nFramescount].TitleBar.ShowTitleBar?WS_VISIBLE:0)|
- WS_CLIPCHILDREN,
- 0,0,0,0,pcli->hwndContactList,NULL,g_hInst,NULL);
- SetWindowLongPtr(Frames[nFramescount].TitleBar.hwnd,GWLP_USERDATA,Frames[nFramescount].id);
-
- Frames[nFramescount].TitleBar.hwndTip
- =CreateWindowEx(0, TOOLTIPS_CLASS, NULL,
- WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
- CW_USEDEFAULT, CW_USEDEFAULT,
- CW_USEDEFAULT, CW_USEDEFAULT,
- pcli->hwndContactList, NULL, g_hInst,
- NULL);
-
-SetWindowPos(Frames[nFramescount].TitleBar.hwndTip, HWND_TOPMOST,0, 0, 0, 0,
- SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
- {
- TOOLINFOA ti;
- int res;
-
- ZeroMemory(&ti,sizeof(ti));
- ti.cbSize=sizeof(ti);
- ti.lpszText="";
- ti.hinst=g_hInst;
- ti.uFlags=TTF_IDISHWND|TTF_SUBCLASS ;
- ti.uId=(UINT_PTR)Frames[nFramescount].TitleBar.hwnd;
- res=SendMessage(Frames[nFramescount].TitleBar.hwndTip,TTM_ADDTOOL,(WPARAM)0,(LPARAM)&ti);
- }
-
-SendMessage(Frames[nFramescount].TitleBar.hwndTip,TTM_ACTIVATE,(WPARAM)Frames[nFramescount].TitleBar.ShowTitleBarTip,0);
-
- Frames[nFramescount].oldstyles=GetWindowLongPtr(Frames[nFramescount].hWnd,GWL_STYLE);
- Frames[nFramescount].TitleBar.oldstyles=GetWindowLongPtr(Frames[nFramescount].TitleBar.hwnd,GWL_STYLE);
- //Frames[nFramescount].FloatingPos.x=
-
- retval=Frames[nFramescount].id;
- Frames[nFramescount].order=nFramescount+1;
- nFramescount++;
-
- CLUIFramesLoadFrameSettings(id2pos(retval));
- style=GetWindowLongPtr(Frames[nFramescount-1].hWnd,GWL_STYLE);
- style&=(~WS_BORDER);
- style|=((Frames[nFramescount-1].UseBorder)?WS_BORDER:0);
- SetWindowLongPtr(Frames[nFramescount-1].hWnd,GWL_STYLE,style);
-
-
- if (Frames[nFramescount-1].order==0){Frames[nFramescount-1].order=nFramescount;}
- ulockfrm();
-
-
- alclientFrame=-1;//recalc it
- CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,0);
-
- if (Frames[nFramescount-1].floating)
- {
-
- Frames[nFramescount-1].floating=FALSE;
- //SetWindowPos(Frames[nFramescount-1].hw
- CLUIFrameSetFloat(retval,1);//lparam=1 use stored width and height
- }
-
- return retval;
-}
-
-static INT_PTR CLUIFramesRemoveFrame(WPARAM wParam,LPARAM lParam)
-{
- int pos;
- if (FramesSysNotStarted) return -1;
- lockfrm();
- pos=id2pos(wParam);
-
- if (pos<0||pos>nFramescount){ulockfrm();return(-1);}
-
- mir_free(Frames[pos].name);
- mir_free(Frames[pos].TitleBar.tbname);
- mir_free(Frames[pos].TitleBar.tooltip);
-
- DestroyWindow(Frames[pos].hWnd);
- Frames[pos].hWnd=(HWND)-1;
- DestroyWindow(Frames[pos].TitleBar.hwnd);
- Frames[pos].TitleBar.hwnd=(HWND)-1;
- DestroyWindow(Frames[pos].ContainerWnd);
- Frames[pos].ContainerWnd=(HWND)-1;
- DestroyMenu(Frames[pos].TitleBar.hmenu);
-
- RemoveItemFromList(pos,&Frames,&nFramescount);
-
- ulockfrm();
- InvalidateRect(pcli->hwndContactList,NULL,TRUE);
- CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,0);
- InvalidateRect(pcli->hwndContactList,NULL,TRUE);
-
- return(0);
-}
-
-
-int CLUIFramesForceUpdateTB(const wndFrame *Frame)
-{
- if (Frame->TitleBar.hwnd!=0) RedrawWindow(Frame->TitleBar.hwnd,NULL,NULL,RDW_ALLCHILDREN|RDW_UPDATENOW|RDW_ERASE|RDW_INVALIDATE|RDW_FRAME);
- //UpdateWindow(Frame->TitleBar.hwnd);
- return 0;
-}
-
-int CLUIFramesForceUpdateFrame(const wndFrame *Frame)
-{
-
- if (Frame->hWnd!=0)
- {
- RedrawWindow(Frame->hWnd,NULL,NULL,RDW_UPDATENOW|RDW_FRAME|RDW_ERASE|RDW_INVALIDATE);
- UpdateWindow(Frame->hWnd);
- }
- if(Frame->floating)
- {
- if (Frame->ContainerWnd!=0) RedrawWindow(Frame->ContainerWnd,NULL,NULL,RDW_UPDATENOW|RDW_ALLCHILDREN|RDW_ERASE|RDW_INVALIDATE|RDW_FRAME);
- //UpdateWindow(Frame->ContainerWnd);
- }
- return 0;
-}
-
-int CLUIFrameMoveResize(const wndFrame *Frame)
-{
- //int b;
- // we need to show or hide the frame?
- if(Frame->visible&&(!Frame->needhide)) {
- ShowWindow(Frame->hWnd,SW_SHOW);
- ShowWindow(Frame->TitleBar.hwnd,Frame->TitleBar.ShowTitleBar==TRUE?SW_SHOW:SW_HIDE);
- }
- else {
- ShowWindow(Frame->hWnd,SW_HIDE);
- ShowWindow(Frame->TitleBar.hwnd,SW_HIDE);
- return(0);
- }
-
- // set frame position
- SetWindowPos(Frame->hWnd,NULL,Frame->wndSize.left,Frame->wndSize.top,
- Frame->wndSize.right-Frame->wndSize.left,
- Frame->wndSize.bottom-Frame->wndSize.top,SWP_NOZORDER|SWP_NOREDRAW);
- // set titlebar position
- if(Frame->TitleBar.ShowTitleBar) {
- SetWindowPos(Frame->TitleBar.hwnd,NULL,Frame->wndSize.left,Frame->wndSize.top-TitleBarH-GapBetweenTitlebar,
- Frame->wndSize.right-Frame->wndSize.left,
- TitleBarH,SWP_NOZORDER|SWP_NOREDRAW );
- }
-// Sleep(0);
- return 0;
-}
-
-BOOLEAN CLUIFramesFitInSize(void)
-{
- int i;
- int sumheight=0;
- int tbh=0; // title bar height
- int clientfrm;
-
- clientfrm=CLUIFramesGetalClientFrame();
- if(clientfrm!=-1)
- tbh=TitleBarH*btoint(Frames[clientfrm].TitleBar.ShowTitleBar);
-
- for(i=0;i<nFramescount;i++) {
- if ((Frames[i].align!=alClient)&&(!Frames[i].floating)&&(Frames[i].visible)&&(!Frames[i].needhide)) {
- sumheight+=(Frames[i].height)+(TitleBarH*btoint(Frames[i].TitleBar.ShowTitleBar))+2;
- if(sumheight>ContactListHeight-tbh-2)
- return FALSE;
- }
- }
- return TRUE;
-}
-
-int CLUIFramesGetMinHeight()
-{
- int i,tbh,clientfrm,sumheight=0;
- RECT border;
- int allbord=0;
- if(pcli->hwndContactList==NULL) return 0;
- lockfrm();
-
- // search for alClient frame and get the titlebar's height
- tbh=0;
- clientfrm=CLUIFramesGetalClientFrame();
- if(clientfrm!=-1)
- tbh=TitleBarH*btoint(Frames[clientfrm].TitleBar.ShowTitleBar);
-
- for(i=0;i<nFramescount;i++)
- {
- if ((Frames[i].align!=alClient)&&(Frames[i].visible)&&(!Frames[i].needhide)&&(!Frames[i].floating))
- {
- RECT wsize;
-
- GetWindowRect(Frames[i].hWnd,&wsize);
- sumheight+=(wsize.bottom-wsize.top)+(TitleBarH*btoint(Frames[i].TitleBar.ShowTitleBar))+3;
- }
- }
- ulockfrm();
- GetBorderSize(pcli->hwndContactList,&border);
-
- //GetWindowRect(pcli->hwndContactList,&winrect);
- //GetClientRect(pcli->hwndContactList,&clirect);
-// clirect.bottom-=clirect.top;
-// clirect.bottom+=border.top+border.bottom;
- //allbord=(winrect.bottom-winrect.top)-(clirect.bottom-clirect.top);
- return (sumheight+border.top+border.bottom+allbord+tbh+3);
-}
-
-
-int CLUIFramesResize(const RECT newsize)
-{
- int sumheight=9999999,newheight;
- int prevframe,prevframebottomline;
- int tbh,curfrmtbh;
- int drawitems;
- int clientfrm;
- int i,j;
- int sepw=GapBetweenFrames;
- SortData *sdarray;
-
-
- GapBetweenTitlebar=(int)DBGetContactSettingDword(NULL,"CLUIFrames","GapBetweenTitleBar",1);
- GapBetweenFrames=DBGetContactSettingDword(NULL,"CLUIFrames","GapBetweenFrames",1);
- TitleBarH=DBGetContactSettingDword(NULL,"CLUIFrames","TitleBarH",DEFAULT_TITLEBAR_HEIGHT);
-
- sepw=GapBetweenFrames;
-
- if(nFramescount<1) return 0;
-
-
- newheight=newsize.bottom-newsize.top;
-
-
-
- // search for alClient frame and get the titlebar's height
- tbh=0;
- clientfrm=CLUIFramesGetalClientFrame();
- if(clientfrm!=-1)
- tbh=(TitleBarH+GapBetweenTitlebar)*btoint(Frames[clientfrm].TitleBar.ShowTitleBar);
-
- for(i=0;i<nFramescount;i++)
- {
- if (!Frames[i].floating)
- {
- Frames[i].needhide=FALSE;
- Frames[i].wndSize.left=0;
- Frames[i].wndSize.right=newsize.right-0;
- }
- }
- {
- //sorting stuff
- sdarray=(SortData*)malloc(sizeof(SortData)*nFramescount);
- if (sdarray==NULL){return(-1);}
- for(i=0;i<nFramescount;i++)
- { sdarray[i].order=Frames[i].order;
- sdarray[i].realpos=i;
- }
- qsort(sdarray,nFramescount,sizeof(SortData),sortfunc);
-
- }
-
- drawitems=nFramescount;
-
- while(sumheight>(newheight-tbh)&&drawitems>0) {
- sumheight=0;
- drawitems=0;
- for(i=0;i<nFramescount;i++) {
- if (((Frames[i].align!=alClient))&&(!Frames[i].floating)&&(Frames[i].visible)&&(!Frames[i].needhide)) {
- drawitems++;
- curfrmtbh=(TitleBarH+GapBetweenTitlebar)*btoint(Frames[i].TitleBar.ShowTitleBar);
- sumheight+=(Frames[i].height)+curfrmtbh+sepw+(Frames[i].UseBorder?2:0);
- if(sumheight>newheight-tbh) {
- sumheight-=(Frames[i].height)+curfrmtbh+sepw;
- Frames[i].needhide=TRUE;
- drawitems--;
- break;
- }
- }
- }
- }
-
- prevframe=-1;
- prevframebottomline=0;
- for(j=0;j<nFramescount;j++) {
- //move all alTop frames
- i=sdarray[j].realpos;
- if ((!Frames[i].needhide)&&(!Frames[i].floating)&&(Frames[i].visible)&&(Frames[i].align==alTop)) {
- curfrmtbh=(TitleBarH+GapBetweenTitlebar)*btoint(Frames[i].TitleBar.ShowTitleBar);
- Frames[i].wndSize.top=prevframebottomline+sepw+(curfrmtbh);
- Frames[i].wndSize.bottom=Frames[i].height+Frames[i].wndSize.top+(Frames[i].UseBorder?2:0);
- Frames[i].prevvisframe=prevframe;
- prevframe=i;
- prevframebottomline=Frames[i].wndSize.bottom;
- if(prevframebottomline>newheight){
- //prevframebottomline-=Frames[i].height+(curfrmtbh+1);
- //Frames[i].needhide=TRUE;
- }
- }
- }
-
- if(sumheight<newheight) {
- for(j=0;j<nFramescount;j++) {
- //move alClient frame
- i=sdarray[j].realpos;
- if ((!Frames[i].needhide)&&(!Frames[i].floating)&&(Frames[i].visible)&&(Frames[i].align==alClient)) {
- int oldh;
- Frames[i].wndSize.top=prevframebottomline+sepw+(tbh);
- Frames[i].wndSize.bottom=Frames[i].wndSize.top+newheight-sumheight-tbh-sepw;
-
- oldh=Frames[i].height;
- Frames[i].height=Frames[i].wndSize.bottom-Frames[i].wndSize.top;
- Frames[i].prevvisframe=prevframe;
- prevframe=i;
- prevframebottomline=Frames[i].wndSize.bottom;
- if(prevframebottomline>newheight) {
- //prevframebottomline-=Frames[i].height+(tbh+1);
- //Frames[i].needhide=TRUE;
- }
- break;
- }
- }
- }
-
- //newheight
- prevframebottomline=newheight+sepw;
- //prevframe=-1;
- for(j=nFramescount-1;j>=0;j--) {
- //move all alBottom frames
- i=sdarray[j].realpos;
- if ((Frames[i].visible)&&(!Frames[i].floating)&&(!Frames[i].needhide)&&(Frames[i].align==alBottom)) {
- curfrmtbh=(TitleBarH+GapBetweenTitlebar)*btoint(Frames[i].TitleBar.ShowTitleBar);
-
- Frames[i].wndSize.bottom=prevframebottomline-sepw;
- Frames[i].wndSize.top=Frames[i].wndSize.bottom-Frames[i].height-(Frames[i].UseBorder?2:0);
- Frames[i].prevvisframe=prevframe;
- prevframe=i;
- prevframebottomline=Frames[i].wndSize.top/*-1*/-curfrmtbh;
- if(prevframebottomline>newheight) {
-
- }
- }
- }
-
- if (sdarray!=NULL){free(sdarray);sdarray=NULL;}
-
- for(i=0;i<nFramescount;i++) {
-
- if (Frames[i].floating){
- CLUIFrameResizeFloatingFrame(i);
- }else
- {
- CLUIFrameMoveResize(&Frames[i]);
- }
-
- }
- return 0;
-}
-
-INT_PTR CLUIFramesUpdateFrame(WPARAM wParam,LPARAM lParam)
-{
- if (FramesSysNotStarted) return -1;
- if(wParam==-1) { CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,(LPARAM)0); return 0;}
- if(lParam&FU_FMPOS) CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,1);
- lockfrm();
- wParam=id2pos(wParam);
- if(wParam<0||(int)wParam>=nFramescount) { ulockfrm(); return -1;}
- if(lParam&FU_TBREDRAW) CLUIFramesForceUpdateTB(&Frames[wParam]);
- if(lParam&FU_FMREDRAW) CLUIFramesForceUpdateFrame(&Frames[wParam]);
- //if () {}
- ulockfrm();
-
- return 0;
-}
-
-int CLUIFramesOnClistResize(WPARAM wParam,LPARAM lParam)
-{
- RECT nRect,rcStatus;
- int tick,i;
-
- if (FramesSysNotStarted) return -1;
- lockfrm();
- //if (resizing){return(0);}
- //resizing=TRUE;
- GetClientRect(pcli->hwndContactList,&nRect);
-
- //if(DBGetContactSettingByte(NULL,"CLUI","ShowSBar",1)) GetWindowRect(pcli->hwndStatus,&rcStatus);
- //else rcStatus.top=rcStatus.bottom=0;
- rcStatus.top=rcStatus.bottom=0;
-
-
- nRect.bottom-=nRect.top;
- nRect.bottom-=(rcStatus.bottom-rcStatus.top);
- nRect.right-=nRect.left;
- nRect.left=0;
- nRect.top=0;
- ContactListHeight=nRect.bottom;
-
- tick=GetTickCount();
-
-
- CLUIFramesResize(nRect);
-
- for (i=0;i<nFramescount;i++)
- {
- CLUIFramesForceUpdateFrame(&Frames[i]);
- CLUIFramesForceUpdateTB(&Frames[i]);
-
- }
-
- //resizing=FALSE;
- ulockfrm();
- tick=GetTickCount()-tick;
-
- if (pcli->hwndContactList!=0) InvalidateRect(pcli->hwndContactList,NULL,TRUE);
- if (pcli->hwndContactList!=0) UpdateWindow(pcli->hwndContactList);
-
- //if(lParam==2) RedrawWindow(pcli->hwndContactList,NULL,NULL,RDW_UPDATENOW|RDW_ALLCHILDREN|RDW_ERASE|RDW_INVALIDATE);
-
-
- Sleep(0);
-
- //dont save to database too many times
- if(GetTickCount()-LastStoreTick>1000){ CLUIFramesStoreAllFrames();LastStoreTick=GetTickCount();}
-
- return 0;
-}
-
-static HBITMAP hBmpBackground;
-static int backgroundBmpUse;
-static COLORREF bkColour;
-static COLORREF SelBkColour;
-boolean AlignCOLLIconToLeft; //will hide frame icon
-
-int OnFrameTitleBarBackgroundChange()
-{
- DBVARIANT dbv;
-
- AlignCOLLIconToLeft=DBGetContactSettingByte(NULL,"FrameTitleBar","AlignCOLLIconToLeft",0);
-
- bkColour=DBGetContactSettingDword(NULL,"FrameTitleBar","BkColour",CLCDEFAULT_BKCOLOUR);
- //SelBkColour=DBGetContactSettingDword(NULL,"FrameTitleBar","SelBkColour",0);
-
- if(hBmpBackground) {DeleteObject(hBmpBackground); hBmpBackground=NULL;}
- if(DBGetContactSettingByte(NULL,"FrameTitleBar","UseBitmap",CLCDEFAULT_USEBITMAP)) {
- if (!DBGetContactSetting(NULL,"FrameTitleBar","BkBitmap",&dbv)) {
- hBmpBackground=(HBITMAP)CallService(MS_UTILS_LOADBITMAP,0,(LPARAM)dbv.pszVal);
- mir_free(dbv.pszVal);
- }
- }
- backgroundBmpUse=DBGetContactSettingWord(NULL,"FrameTitleBar","BkBmpUse",CLCDEFAULT_BKBMPUSE);
-
- CLUIFramesOnClistResize(0,0);
- return 0;
-}
-
-void DrawBackGroundTTB(HWND hwnd,HDC mhdc)
-{
- HDC hdcMem,hdc;
- RECT clRect,*rcPaint;
-
- int yScroll=0;
- int y;
- PAINTSTRUCT paintst={0};
- HBITMAP hBmpOsb,hOldBmp;
- DWORD style=GetWindowLongPtr(hwnd,GWL_STYLE);
- int grey=0;
- HFONT oFont;
- HBRUSH hBrushAlternateGrey=NULL;
-
- HFONT hFont;
-
- //InvalidateRect(hwnd,0,FALSE);
-
- hFont=(HFONT)SendMessage(hwnd,WM_GETFONT,0,0);
-
- if (mhdc)
- {
- hdc=mhdc;
- rcPaint=NULL;
- }else
- {
- hdc=BeginPaint(hwnd,&paintst);
- rcPaint=&(paintst.rcPaint);
- }
-
- GetClientRect(hwnd,&clRect);
- if(rcPaint==NULL) rcPaint=&clRect;
- if (rcPaint->right-rcPaint->left==0||rcPaint->top-rcPaint->bottom==0) rcPaint=&clRect;
- y=-yScroll;
- hdcMem=CreateCompatibleDC(hdc);
- hBmpOsb=CreateBitmap(clRect.right,clRect.bottom,1,GetDeviceCaps(hdc,BITSPIXEL),NULL);
- hOldBmp=SelectObject(hdcMem,hBmpOsb);
- oFont=SelectObject(hdcMem,hFont);
- SetBkMode(hdcMem,TRANSPARENT);
- { HBRUSH hBrush,hoBrush;
-
- hBrush=CreateSolidBrush(bkColour);
- hoBrush=(HBRUSH)SelectObject(hdcMem,hBrush);
- FillRect(hdcMem,rcPaint,hBrush);
- SelectObject(hdcMem,hoBrush);
- DeleteObject(hBrush);
- if(hBmpBackground) {
- BITMAP bmp;
- HDC hdcBmp;
- int x,y;
- int maxx,maxy;
- int destw,desth;
-
- GetObject(hBmpBackground,sizeof(bmp),&bmp);
- hdcBmp=CreateCompatibleDC(hdcMem);
- SelectObject(hdcBmp,hBmpBackground);
- y=backgroundBmpUse&CLBF_SCROLL?-yScroll:0;
- maxx=backgroundBmpUse&CLBF_TILEH?clRect.right:1;
- maxy=backgroundBmpUse&CLBF_TILEV?maxy=rcPaint->bottom:y+1;
- switch(backgroundBmpUse&CLBM_TYPE) {
- case CLB_STRETCH:
- if(backgroundBmpUse&CLBF_PROPORTIONAL) {
- if(clRect.right*bmp.bmHeight<clRect.bottom*bmp.bmWidth) {
- desth=clRect.bottom;
- destw=desth*bmp.bmWidth/bmp.bmHeight;
- }
- else {
- destw=clRect.right;
- desth=destw*bmp.bmHeight/bmp.bmWidth;
- }
- }
- else {
- destw=clRect.right;
- desth=clRect.bottom;
- }
- break;
- case CLB_STRETCHH:
- if(backgroundBmpUse&CLBF_PROPORTIONAL) {
- destw=clRect.right;
- desth=destw*bmp.bmHeight/bmp.bmWidth;
- }
- else {
- destw=clRect.right;
- desth=bmp.bmHeight;
- }
- break;
- case CLB_STRETCHV:
- if(backgroundBmpUse&CLBF_PROPORTIONAL) {
- desth=clRect.bottom;
- destw=desth*bmp.bmWidth/bmp.bmHeight;
- }
- else {
- destw=bmp.bmWidth;
- desth=clRect.bottom;
- }
- break;
- default: //clb_topleft
- destw=bmp.bmWidth;
- desth=bmp.bmHeight;
- break;
- }
- desth=clRect.bottom -clRect.top;
- for (;y<maxy;y+=desth) {
- if(y<rcPaint->top-desth) continue;
- for(x=0;x<maxx;x+=destw)
- StretchBlt(hdcMem,x,y,destw,desth,hdcBmp,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
- }
- DeleteDC(hdcBmp);
- }
- }
-
- {
-
- BitBlt(hdc,rcPaint->left,rcPaint->top,rcPaint->right-rcPaint->left,rcPaint->bottom-rcPaint->top,hdcMem,rcPaint->left,rcPaint->top,SRCCOPY);
-
- SelectObject(hdcMem,hOldBmp);
- SelectObject(hdcMem,oFont);
- DeleteObject(hBmpOsb);
- DeleteDC(hdcMem);
- paintst.fErase=FALSE;
- //DeleteObject(hFont);
- if (!mhdc)
- {
- EndPaint(hwnd,&paintst);
- }
- }
-}
-
-
-static int DrawTitleBar(HDC dc,RECT rect,int Frameid)
-{
- HDC hdcMem;
- HBITMAP hBmpOsb,hoBmp;
- HBRUSH hBack,hoBrush;
- HDC paintDC;
- int pos;
- HFONT hoTTBFont;
-
-
- //GetClientRect(hwnd,&rect);
- paintDC=dc;
-
-// paintDC = BeginPaint(hwnd, &paintStruct);
- //rect=paintStruct.rcPaint;
-
-
- hdcMem=CreateCompatibleDC(paintDC);
- hBmpOsb=CreateBitmap(rect.right,rect.bottom,1,GetDeviceCaps(paintDC,BITSPIXEL),NULL);
- hoBmp=SelectObject(hdcMem,hBmpOsb);
-
- hoTTBFont=SelectObject(hdcMem,TitleBarFont);
- SetBkMode(hdcMem,TRANSPARENT);
-
- hBack=GetSysColorBrush(COLOR_3DFACE);
- hoBrush=SelectObject(hdcMem,hBack);
-
- //FillRect(hdcMem,&rect,hBack);
-
-
- lockfrm();
- pos=id2pos(Frameid);
-
- if (pos>=0&&pos<nFramescount)
- {
-
- GetClientRect(Frames[pos].TitleBar.hwnd,&Frames[pos].TitleBar.wndSize);
- {
- //set font charset
- HFONT oFont;
- HFONT hf=GetStockObject(DEFAULT_GUI_FONT);
-
- if (TitleBarLogFont.lfHeight!=0)
- {
- hf=CreateFontIndirectA(&TitleBarLogFont);
- }
-
- oFont=SelectObject(hdcMem,hf);
-
- DrawBackGroundTTB(Frames[pos].TitleBar.hwnd,hdcMem);
- //hFront=CreateSolidPe (SelBkColour);
- //SelectObject(hdcMem,hFront);
- SelBkColour=DBGetContactSettingDword(NULL,"CLUIFrames","FramesTitleBarFontCol",0);
- if (SelBkColour) SetTextColor(hdcMem,SelBkColour);
-
-
- if (!AlignCOLLIconToLeft)
- {
-
- if(Frames[pos].TitleBar.hicon!=NULL) {
- //(TitleBarH>>1)-(GetSystemMetrics(SM_CXSMICON)>>1)
- DrawIconEx(hdcMem,2,((TitleBarH>>1)-(GetSystemMetrics(SM_CYSMICON)>>1)),Frames[pos].TitleBar.hicon,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),0,NULL,DI_NORMAL);
- TextOut(hdcMem,GetSystemMetrics(SM_CYSMICON)+4,0,Frames[pos].TitleBar.tbname,lstrlen(Frames[pos].TitleBar.tbname));
- }
- else
- TextOut(hdcMem,2,0,Frames[pos].TitleBar.tbname,lstrlen(Frames[pos].TitleBar.tbname));
-
- }else
- {
- TextOut(hdcMem,GetSystemMetrics(SM_CXSMICON)+2,0,Frames[pos].TitleBar.tbname,lstrlen(Frames[pos].TitleBar.tbname));
- }
-
-
- if (!AlignCOLLIconToLeft)
- {
- DrawIconEx(hdcMem,Frames[pos].TitleBar.wndSize.right-GetSystemMetrics(SM_CXSMICON)-2,((TitleBarH>>1)-(GetSystemMetrics(SM_CXSMICON)>>1)),Frames[pos].collapsed?LoadSkinnedIcon(SKINICON_OTHER_GROUPOPEN):LoadSkinnedIcon(SKINICON_OTHER_GROUPSHUT),GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),0,NULL,DI_NORMAL);
- }
- else
- {
- DrawIconEx(hdcMem,0,((TitleBarH>>1)-(GetSystemMetrics(SM_CXSMICON)>>1)),Frames[pos].collapsed?LoadSkinnedIcon(SKINICON_OTHER_GROUPOPEN):LoadSkinnedIcon(SKINICON_OTHER_GROUPSHUT),GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),0,NULL,DI_NORMAL);
- }
-
- DeleteObject(hf);
- SelectObject(hdcMem,oFont);
- //DeleteObject(hFront);
- }
- }
- ulockfrm();
-
- BitBlt(paintDC,rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,hdcMem,rect.left,rect.top,SRCCOPY);
-
- SelectObject(hdcMem,hoBmp);
- SelectObject(hdcMem,hoBrush);
- SelectObject(hdcMem,hoTTBFont);
- DeleteDC(hdcMem);
- DeleteObject(hBack);
- DeleteObject(hBmpOsb);
- //EndPaint(hwnd, &paintStruct);
- return 0;
-
-}
-
-//for old multiwindow
-#define MPCF_CONTEXTFRAMEMENU 3
-POINT ptOld;
-short nLeft = 0;
-short nTop = 0;
-
-LRESULT CALLBACK CLUIFrameTitleBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- RECT rect;
- int Frameid,Framemod,direction;
- int xpos,ypos;
-
- Frameid=(GetWindowLongPtr(hwnd,GWLP_USERDATA));
- memset(&rect,0,sizeof(rect));
-
-
- switch(msg)
- {
- case WM_CREATE:
- SendMessage(hwnd,WM_SETFONT,(WPARAM)TitleBarFont,0);
- return FALSE;
- case WM_MEASUREITEM:
- return CallService(MS_CLIST_MENUMEASUREITEM,wParam,lParam);
- case WM_DRAWITEM:
- return CallService(MS_CLIST_MENUDRAWITEM,wParam,lParam);
-
- case WM_ENABLE:
- if (hwnd!=0) InvalidateRect(hwnd,NULL,FALSE);
- return 0;
- /*
- case WM_PRINT:
- case WM_PRINTCLIENT:
- InvalidateRect(hwnd,NULL,FALSE);
- {
- RECT rect;
- HDC dc;
- GetClientRect(hwnd,&rect);
- //DrawTitleBar(wParam,rect,Frameid);
- SendMessage(hwnd,WM_PAINT,0,0);
- SendMessage(hwnd,WM_NCPAINT,1,0);
- dc=GetDC(hwnd);
- SendMessage(hwnd,WM_ERASEBKGND,dc,0);
- ReleaseDC(hwnd,dc);
- SendMessage(hwnd,WM_PAINT,0,0);
-// UpdateWindow(hwnd);
- return(0);
- }
- */
- /*
- case WM_NCPAINT:
- {
-
- // if(wParam==1) break;
- { POINT ptTopLeft={0,0}
- HRGN hClientRgn;
- ClientToScreen(hwnd,&ptTopLeft);
- hClientRgn=CreateRectRgn(0,0,1,1);
- CombineRgn(hClientRgn,(HRGN)wParam,NULL,RGN_COPY);
- OffsetRgn(hClientRgn,-ptTopLeft.x,-ptTopLeft.y);
- InvalidateRgn(hwnd,hClientRgn,FALSE);
- DeleteObject(hClientRgn);
- UpdateWindow(hwnd);
- }
- //return(0);
- }
- */
-
-
- case WM_COMMAND:
-
-
- if (ServiceExists(MO_CREATENEWMENUOBJECT))
- {
- //if ( CallService(MS_CLIST_MENUPROCESSCOMMAND,MAKEWPARAM(LOWORD(wParam),0),(LPARAM)Frameid) ){break;}
- if (ProcessCommandProxy(MAKEWPARAM(LOWORD(wParam),0),(LPARAM)Frameid) ) break;
- }else
- {
- if ( CallService(MS_CLIST_MENUPROCESSCOMMAND,MAKEWPARAM(LOWORD(wParam),MPCF_CONTEXTFRAMEMENU),(LPARAM)Frameid) ){break;}
-
- }
-
-
- if(HIWORD(wParam)==0) {//mouse events for self created menu
- int framepos=id2pos(Frameid);
- if (framepos==-1){break;}
-
- switch(LOWORD(wParam))
- {
- case frame_menu_lock:
- Frames[framepos].Locked=!Frames[framepos].Locked;
- break;
- case frame_menu_visible:
- Frames[framepos].visible=!Frames[framepos].visible;
- break;
- case frame_menu_showtitlebar:
- Frames[framepos].TitleBar.ShowTitleBar=!Frames[framepos].TitleBar.ShowTitleBar;
- break;
- case frame_menu_floating:
- CLUIFrameSetFloat(Frameid,0);
- break;
- }
- CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,(LPARAM)0);
- }
-
- break;
- case WM_RBUTTONDOWN:
- {
- HMENU hmenu;
- POINT pt;
- GetCursorPos(&pt);
-
- if (ServiceExists(MS_CLIST_MENUBUILDFRAMECONTEXT))
- {
- hmenu=(HMENU)CallService(MS_CLIST_MENUBUILDFRAMECONTEXT,Frameid,0);
- }
- else
- {//legacy menu support
- int framepos=id2pos(Frameid);
- lockfrm();
- if (framepos==-1){ulockfrm();break;}
- hmenu=CreatePopupMenu();
-// Frames[Frameid].TitleBar.hmenu=hmenu;
- AppendMenu(hmenu,MF_STRING|MF_DISABLED|MF_GRAYED,15,Frames[framepos].name);
- AppendMenu(hmenu,MF_SEPARATOR,16,_T(""));
-
- if (Frames[framepos].Locked)
- {AppendMenu(hmenu,MF_STRING|MF_CHECKED,frame_menu_lock,TranslateT("Lock Frame"));}
- else{AppendMenu(hmenu,MF_STRING,frame_menu_lock,TranslateT("Lock Frame"));}
-
- if (Frames[framepos].visible)
- {AppendMenu(hmenu,MF_STRING|MF_CHECKED,frame_menu_visible,TranslateT("Visible"));}
- else{AppendMenu(hmenu,MF_STRING,frame_menu_visible,TranslateT("Visible") );}
-
- if (Frames[framepos].TitleBar.ShowTitleBar)
- {AppendMenu(hmenu,MF_STRING|MF_CHECKED,frame_menu_showtitlebar,TranslateT("Show TitleBar") );}
- else{AppendMenu(hmenu,MF_STRING,frame_menu_showtitlebar,TranslateT("Show TitleBar") );}
-
- if (Frames[framepos].floating)
- {AppendMenu(hmenu,MF_STRING|MF_CHECKED,frame_menu_floating,TranslateT("Floating") );}
- else{AppendMenu(hmenu,MF_STRING,frame_menu_floating,TranslateT("Floating") );}
-
- //err=GetMenuItemCount(hmenu)
- ulockfrm();
- }
-
- TrackPopupMenu(hmenu,TPM_LEFTALIGN,pt.x,pt.y,0,hwnd,0);
- DestroyMenu(hmenu);
- }
- break;
- case WM_LBUTTONDBLCLK:
- {
- Framemod=-1;
- lbypos=-1;oldframeheight=-1;ReleaseCapture();
- CallService(MS_CLIST_FRAMES_UCOLLFRAME,Frameid,0);
- lbypos=-1;oldframeheight=-1;ReleaseCapture();
- }
- break;
-
- case WM_LBUTTONUP:
- {
- if(GetCapture()!=hwnd){break;}
- curdragbar=-1;lbypos=-1;oldframeheight=-1;ReleaseCapture();
- break;
- }
- case WM_LBUTTONDOWN:
- {
-
- int framepos=id2pos(Frameid);
- lockfrm();
- if (framepos==-1){ulockfrm();break;}
- {
- if (Frames[framepos].floating)
- {
-
- POINT pt;
- GetCursorPos(&pt);
- Frames[framepos].TitleBar.oldpos=pt;
- }
- }
-
- //ScreenToClient(Frames[framepos].ContainerWnd,&Frames[framepos].TitleBar.oldpos);
-
- if ((!(wParam&MK_CONTROL))&&Frames[framepos].Locked&&(!(Frames[framepos].floating)))
- {
- if (DBGetContactSettingByte(NULL,"CLUI","ClientAreaDrag",0)) {
- POINT pt;
- //pt=nm->pt;
- GetCursorPos(&pt);
- return SendMessage(GetParent(hwnd), WM_SYSCOMMAND, SC_MOVE|HTCAPTION,MAKELPARAM(pt.x,pt.y));
- }
- }
-
- if (Frames[framepos].floating)
- {
- RECT rc;
- GetCursorPos(&ptOld);
- //ClientToScreen(hwnd,&ptOld);
- GetWindowRect( hwnd, &rc );
-
- nLeft = (short)rc.left;
- nTop = (short)rc.top;
- }
- ulockfrm();
- SetCapture(hwnd);
-
-
- break;
- }
- case WM_MOUSEMOVE:
- {
- POINT pt,pt2;
- RECT wndr;
- int pos;
-//tbinfo
-{
- char TBcapt[255];
-
- lockfrm();
- pos=id2pos(Frameid);
-
- if (pos!=-1)
- {
- int oldflags;
- wsprintfA(TBcapt,"%s - h:%d, vis:%d, fl:%d, fl:(%d,%d,%d,%d),or: %d",
- Frames[pos].name,Frames[pos].height,Frames[pos].visible,Frames[pos].floating,
- Frames[pos].FloatingPos.x,Frames[pos].FloatingPos.y,
- Frames[pos].FloatingSize.x,Frames[pos].FloatingSize.y,
- Frames[pos].order
- );
-
- oldflags=CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS,MAKEWPARAM(FO_FLAGS,Frames[pos].id),(LPARAM)0);
- if (!(oldflags&F_SHOWTBTIP))
- {
- oldflags|=F_SHOWTBTIP;
- //CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_FLAGS,Frames[pos].id),(LPARAM)oldflags);
- }
- //CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_TBTIPNAME,Frames[pos].id),(LPARAM)TBcapt);
- }
-
- ulockfrm();
-
-}
-//
- if ((wParam&MK_LBUTTON)/*&&(wParam&MK_CONTROL)*/)
- {
- RECT rcMiranda;
- RECT rcwnd,rcOverlap;
- POINT newpt,ofspt,curpt,newpos;
- //if(GetCapture()!=hwnd){break;}
- //curdragbar=-1;lbypos=-1;oldframeheight=-1;ReleaseCapture();
- lockfrm();
- pos=id2pos(Frameid);
- if (Frames[pos].floating)
- {
-
- GetCursorPos(&curpt);
- rcwnd.bottom=curpt.y+5;
- rcwnd.top=curpt.y;
- rcwnd.left=curpt.x;
- rcwnd.right=curpt.x+5;
-
- GetWindowRect(pcli->hwndContactList, &rcMiranda );
- //GetWindowRect( Frames[pos].ContainerWnd, &rcwnd );
- //IntersectRect( &rcOverlap, &rcwnd, &rcMiranda )
- if (IsWindowVisible(pcli->hwndContactList) &&IntersectRect( &rcOverlap, &rcwnd, &rcMiranda ))
- {
- int id=Frames[pos].id;
-
-
- ulockfrm();
-
- ofspt.x=0;ofspt.y=0;
- ClientToScreen(Frames[pos].TitleBar.hwnd,&ofspt);
- ofspt.x=curpt.x-ofspt.x;ofspt.y=curpt.y-ofspt.y;
-
- CLUIFrameSetFloat(id,0);
- newpt.x=0;newpt.y=0;
- ClientToScreen(Frames[pos].TitleBar.hwnd,&newpt);
- SetCursorPos(newpt.x+ofspt.x,newpt.y+ofspt.y);
- GetCursorPos(&curpt);
- lockfrm();
- Frames[pos].TitleBar.oldpos=curpt;
- ulockfrm();
- return(0);
- }
-
- }
- else
- {
- int id=Frames[pos].id;
-
- GetCursorPos(&curpt);
- rcwnd.bottom=curpt.y+5;
- rcwnd.top=curpt.y;
- rcwnd.left=curpt.x;
- rcwnd.right=curpt.x+5;
-
- GetWindowRect(pcli->hwndContactList, &rcMiranda );
- //GetWindowRect( Frames[pos].ContainerWnd, &rcwnd );
- //IntersectRect( &rcOverlap, &rcwnd, &rcMiranda )
-
-
- if (!IntersectRect( &rcOverlap, &rcwnd, &rcMiranda ) )
- {
-
-
- ulockfrm();
- GetCursorPos(&curpt);
- GetWindowRect( Frames[pos].hWnd, &rcwnd );
- rcwnd.left=rcwnd.right-rcwnd.left;
- rcwnd.top=rcwnd.bottom-rcwnd.top;
- newpos.x=curpt.x;newpos.y=curpt.y;
- if (curpt.x>=(rcMiranda.right-1)){newpos.x=curpt.x+5;}
- if (curpt.x<=(rcMiranda.left+1)){newpos.x=curpt.x-(rcwnd.left)-5;}
-
- if (curpt.y>=(rcMiranda.bottom-1)){newpos.y=curpt.y+5;}
- if (curpt.y<=(rcMiranda.top+1)){newpos.y=curpt.y-(rcwnd.top)-5;}
-
-
- ofspt.x=0;ofspt.y=0;
- //ClientToScreen(Frames[pos].TitleBar.hwnd,&ofspt);
- GetWindowRect(Frames[pos].TitleBar.hwnd,&rcwnd);
- ofspt.x=curpt.x-ofspt.x;ofspt.y=curpt.y-ofspt.y;
-
- Frames[pos].FloatingPos.x=newpos.x;
- Frames[pos].FloatingPos.y=newpos.y;
- CLUIFrameSetFloat(id,0);
- //SetWindowPos(Frames[pos].ContainerWnd,0,newpos.x,newpos.y,0,0,SWP_NOSIZE);
-
- lockfrm();
- newpt.x=0;newpt.y=0;
- ClientToScreen(Frames[pos].TitleBar.hwnd,&newpt);
-
- GetWindowRect( Frames[pos].hWnd, &rcwnd );
- SetCursorPos(newpt.x+(rcwnd.right-rcwnd.left)/2,newpt.y+(rcwnd.bottom-rcwnd.top)/2);
- GetCursorPos(&curpt);
-
- Frames[pos].TitleBar.oldpos=curpt;
- ulockfrm();
-
- return(0);
- }
-
- }
- ulockfrm();
- //return(0);
- }
-
- if(wParam&MK_LBUTTON) {
- int newh=-1,prevold;
-
- if(GetCapture()!=hwnd){break;}
-
- lockfrm();
- pos=id2pos(Frameid);
-
- if (Frames[pos].floating)
- {
- GetCursorPos(&pt);
- if ((Frames[pos].TitleBar.oldpos.x!=pt.x)||(Frames[pos].TitleBar.oldpos.y!=pt.y))
- {
-
- pt2=pt;
- ScreenToClient(hwnd,&pt2);
- GetWindowRect(Frames[pos].ContainerWnd,&wndr);
- {
- int dX,dY;
- POINT ptNew;
-
- ptNew.x = pt.x;
- ptNew.y = pt.y;
- //ClientToScreen( hwnd, &ptNew );
-
- dX = ptNew.x - ptOld.x;
- dY = ptNew.y - ptOld.y;
-
- nLeft += (short)dX;
- nTop += (short)dY;
-
- if (!(wParam&MK_CONTROL))
- {
- PositionThumb( &Frames[pos], nLeft, nTop );
- }else
- {
-
- SetWindowPos( Frames[pos].ContainerWnd,
- HWND_TOPMOST,
- nLeft,
- nTop,
- 0,
- 0,
- SWP_NOSIZE | SWP_NOZORDER );
- }
-
- ptOld = ptNew;
-
-
-
- }
-
- pt.x=nLeft;
- pt.y=nTop;
- Frames[pos].TitleBar.oldpos=pt;
- }
- ulockfrm();
- //break;
- return(0);
- }
-
-
- if(Frames[pos].prevvisframe!=-1) {
- GetCursorPos(&pt);
-
- if ((Frames[pos].TitleBar.oldpos.x==pt.x)&&(Frames[pos].TitleBar.oldpos.y==pt.y))
- {ulockfrm();break;}
-
- ypos=rect.top+pt.y;xpos=rect.left+pt.x;
- Framemod=-1;
-
- if(Frames[pos].align==alBottom) {
- direction=-1;
- Framemod=pos;
- }
- else {
- direction=1;
- Framemod=Frames[pos].prevvisframe;
- }
- if(Frames[Framemod].Locked) {ulockfrm();break;}
- if(curdragbar!=-1&&curdragbar!=pos) {ulockfrm();break;}
-
- if(lbypos==-1) {
- curdragbar=pos;
- lbypos=ypos;
- oldframeheight=Frames[Framemod].height;
- SetCapture(hwnd);
- {ulockfrm();break;}
- }
- else
- {
- // if(GetCapture()!=hwnd){ulockfrm();break;}
- }
-
- newh=oldframeheight+direction*(ypos-lbypos);
- if(newh>0) {
- prevold=Frames[Framemod].height;
- Frames[Framemod].height=newh;
- if (!CLUIFramesFitInSize()) { Frames[Framemod].height=prevold; ulockfrm();return TRUE;}
- Frames[Framemod].height=newh;
- if(newh>3) Frames[Framemod].collapsed=TRUE;
-
- }
- Frames[pos].TitleBar.oldpos=pt;
- }
- ulockfrm();
- if (newh>0){CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,(LPARAM)0);}
- break;
- }
- curdragbar=-1;lbypos=-1;oldframeheight=-1;ReleaseCapture();
- }
- break;
- case WM_PRINTCLIENT:
- {
- if (lParam&PRF_CLIENT)
- {
- GetClientRect(hwnd,&rect);
- DrawTitleBar((HDC)wParam,rect,Frameid);
- }
- }
- case WM_PAINT:
- {
- HDC paintDC;
- PAINTSTRUCT paintStruct;
-
- //GetClientRect(hwnd,&rect);
- paintDC = BeginPaint(hwnd, &paintStruct);
- rect=paintStruct.rcPaint;
- DrawTitleBar(paintDC,rect,Frameid);
- EndPaint(hwnd, &paintStruct);
- return 0;
- }
- default:return DefWindowProc(hwnd, msg, wParam, lParam);
- }
- return TRUE;
-}
-int CLUIFrameResizeFloatingFrame(int framepos)
-{
-
- int width,height;
- RECT rect;
-
- if (!Frames[framepos].floating){return(0);}
- if (Frames[framepos].ContainerWnd==0){return(0);}
- GetClientRect(Frames[framepos].ContainerWnd,&rect);
-
- width=rect.right-rect.left;
- height=rect.bottom-rect.top;
-
- Frames[framepos].visible?ShowWindow(Frames[framepos].ContainerWnd,SW_SHOW):ShowWindow(Frames[framepos].ContainerWnd,SW_HIDE);
-
-
-
- if (Frames[framepos].TitleBar.ShowTitleBar)
- {
- ShowWindow(Frames[framepos].TitleBar.hwnd,SW_SHOW);
- //if (Frames[framepos].Locked){return(0);}
- Frames[framepos].height=height-DEFAULT_TITLEBAR_HEIGHT;
-
- SetWindowPos(Frames[framepos].TitleBar.hwnd,HWND_TOP,0,0,width,DEFAULT_TITLEBAR_HEIGHT,SWP_SHOWWINDOW|SWP_DRAWFRAME);
- SetWindowPos(Frames[framepos].hWnd,HWND_TOP,0,DEFAULT_TITLEBAR_HEIGHT,width,height-DEFAULT_TITLEBAR_HEIGHT,SWP_SHOWWINDOW);
-
- }
- else
- {
- //SetWindowPos(Frames[framepos].TitleBar.hwnd,HWND_TOP,0,0,width,DEFAULT_TITLEBAR_HEIGHT,SWP_SHOWWINDOW|SWP_NOMOVE);
- //if (Frames[framepos].Locked){return(0);}
- Frames[framepos].height=height;
- ShowWindow(Frames[framepos].TitleBar.hwnd,SW_HIDE);
- SetWindowPos(Frames[framepos].hWnd,HWND_TOP,0,0,width,height,SWP_SHOWWINDOW);
-
- }
-// CLUIFramesForceUpdateFrame(&Frames[framepos]);
- if (Frames[framepos].ContainerWnd!=0) UpdateWindow(Frames[framepos].ContainerWnd);
- //GetClientRect(Frames[framepos].TitleBar.hwnd,&Frames[framepos].TitleBar.wndSize);
- GetWindowRect(Frames[framepos].hWnd,&Frames[framepos].wndSize);
- //Frames[framepos].height=Frames[framepos].wndSize.bottom-Frames[framepos].wndSize.top;
- //GetClientRect(Frames[framepos].hWnd,&Frames[framepos].wndSize);
- //Frames[framepos].height=Frames[framepos].wndSize.bottom-Frames[framepos].wndSize.top;
- return(0);
-}
-
-static int CLUIFrameOnMainMenuBuild(WPARAM wParam,LPARAM lParam)
-{
- CLUIFramesLoadMainMenu();
- return 0;
-}
-//static int CLUIFrameContainerWndProc
-LRESULT CALLBACK CLUIFrameContainerWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
-
- RECT rect;
- int Frameid;
-
- Frameid=(GetWindowLongPtr(hwnd,GWLP_USERDATA));
- memset(&rect,0,sizeof(rect));
-/*
-if ((msg == WM_MOVE) || (msg == WM_MOVING) || (msg == WM_NCLBUTTONDOWN) || (msg == WM_SYSCOMMAND) )
-{
- if (ServiceExists("Utils/SnapWindowProc"))
- {
- SnapWindowProc_t SnapInfo;
- memset(&SnapInfo,0,sizeof(SnapInfo));
-
- SnapInfo.hWnd = hwnd;
- SnapInfo.wParam = wParam;
- SnapInfo.lParam = lParam;
- if (CallService("Utils/SnapWindowProc",(WPARAM)&SnapInfo,msg)!=0){return(TRUE);}
- }
-}
-*/
- switch(msg)
- {
- case WM_CREATE:
- {
- int framepos;
- lockfrm();
- framepos=id2pos(Frameid);
- //SetWindowPos(Frames[framepos].TitleBar.hwndTip, HWND_TOPMOST,0, 0, 0, 0,SWP_NOMOVE | SWP_NOSIZE );
- ulockfrm();
- return(0);
- }
- case WM_GETMINMAXINFO:
- //DefWindowProc(hwnd,msg,wParam,lParam);
- {
- int framepos;
- MINMAXINFO minmax;
-
- lockfrm();
- framepos=id2pos(Frameid);
- if(framepos<0||framepos>=nFramescount){ulockfrm();break;}
- if (!Frames[framepos].minmaxenabled){ulockfrm();break;}
- if (Frames[framepos].ContainerWnd==0){ulockfrm();break;}
-
- if (Frames[framepos].Locked)
- {
- RECT rct;
-
- GetWindowRect(hwnd,&rct);
- ((LPMINMAXINFO)lParam)->ptMinTrackSize.x=rct.right-rct.left;
- ((LPMINMAXINFO)lParam)->ptMinTrackSize.y=rct.bottom-rct.top;
- ((LPMINMAXINFO)lParam)->ptMaxTrackSize.x=rct.right-rct.left;
- ((LPMINMAXINFO)lParam)->ptMaxTrackSize.y=rct.bottom-rct.top;
- //ulockfrm();
- //return(0);
- }
-
-
- memset(&minmax,0,sizeof(minmax));
- if (SendMessage(Frames[framepos].hWnd,WM_GETMINMAXINFO,(WPARAM)0,(LPARAM)&minmax)==0)
- {
- RECT border;
- int tbh=TitleBarH*btoint(Frames[framepos].TitleBar.ShowTitleBar);
- GetBorderSize(hwnd,&border);
- if (minmax.ptMaxTrackSize.x!=0&&minmax.ptMaxTrackSize.y!=0){
-
- ((LPMINMAXINFO)lParam)->ptMinTrackSize.x=minmax.ptMinTrackSize.x;
- ((LPMINMAXINFO)lParam)->ptMinTrackSize.y=minmax.ptMinTrackSize.y;
- ((LPMINMAXINFO)lParam)->ptMaxTrackSize.x=minmax.ptMaxTrackSize.x+border.left+border.right;
- ((LPMINMAXINFO)lParam)->ptMaxTrackSize.y=minmax.ptMaxTrackSize.y+tbh+border.top+border.bottom;
- }
-
- }
- else
- {
-
- ulockfrm();
- return(DefWindowProc(hwnd, msg, wParam, lParam));
- }
- ulockfrm();
-
-
- }
- //return 0;
-
- case WM_MOVE:
- {
- int framepos;
- RECT rect;
-
-
- lockfrm();
- framepos=id2pos(Frameid);
-
- if(framepos<0||framepos>=nFramescount){ulockfrm();break;}
- if (Frames[framepos].ContainerWnd==0){ulockfrm();return(0);}
-
- GetWindowRect(Frames[framepos].ContainerWnd,&rect);
- Frames[framepos].FloatingPos.x=rect.left;
- Frames[framepos].FloatingPos.y=rect.top;
- Frames[framepos].FloatingSize.x=rect.right-rect.left;
- Frames[framepos].FloatingSize.y=rect.bottom-rect.top;
-
- CLUIFramesStoreFrameSettings(framepos);
- ulockfrm();
-
- return(0);
- }
- case WM_SIZE:
- {
- int framepos;
- RECT rect;
-
-
- lockfrm();
- framepos=id2pos(Frameid);
-
- if(framepos<0||framepos>=nFramescount){ulockfrm();break;}
- if (Frames[framepos].ContainerWnd==0){ulockfrm();return(0);}
- CLUIFrameResizeFloatingFrame(framepos);
-
- GetWindowRect(Frames[framepos].ContainerWnd,&rect);
- Frames[framepos].FloatingPos.x=rect.left;
- Frames[framepos].FloatingPos.y=rect.top;
- Frames[framepos].FloatingSize.x=rect.right-rect.left;
- Frames[framepos].FloatingSize.y=rect.bottom-rect.top;
-
- CLUIFramesStoreFrameSettings(framepos);
- ulockfrm();
-
- return(0);
- }
- case WM_CLOSE:
- {
- DestroyWindow(hwnd);
- break;
- }
- case WM_DESTROY:
- {
- //{ CLUIFramesStoreAllFrames();}
- return(0);
- }
- /*
- case WM_COMMAND:
- case WM_NOTIFY:
- return(SendMessage(pcli->hwndContactList,msg,wParam,lParam));
- */
-
-
- }
- return DefWindowProc(hwnd, msg, wParam, lParam);
-}
-
-static HWND CreateContainerWindow(HWND parent,int x,int y,int width,int height)
-{
- return(CreateWindowA("FramesContainer","aaaa",WS_POPUP|WS_THICKFRAME,x,y,width,height,parent,0,g_hInst,0));
-}
-
-INT_PTR CLUIFrameSetFloat(WPARAM wParam,LPARAM lParam)
-{
- HWND hwndtmp, hwndtooltiptmp;
- wndFrame *frame;
- int pos;
-
- lockfrm();
-
- pos = id2pos(wParam);
- if (pos < 0 || pos > nFramescount)
- {
- ulockfrm();
- return 0;
- }
-
- frame = &Frames[pos];
-
- //parent=GetParent(Frames[wParam].hWnd);
- if (frame->floating)
- {
- //SetWindowLongPtr(frame->hWnd,GWL_STYLE,Frames[wParam].oldstyles);
- //SetWindowLongPtr(frame->TitleBar.hwnd,GWL_STYLE,Frames[wParam].TitleBar.oldstyles);
- SetParent(frame->hWnd,pcli->hwndContactList);
- SetParent(frame->TitleBar.hwnd,pcli->hwndContactList);
- frame->floating=FALSE;
- DestroyWindow(frame->ContainerWnd);
- frame->ContainerWnd=NULL;
- }
- else
- {
- RECT recttb,rectw,border;
- int temp;
- int neww,newh;
- BOOLEAN locked;
-
- frame->oldstyles=GetWindowLongPtr(frame->hWnd,GWL_STYLE);
- frame->TitleBar.oldstyles=GetWindowLongPtr(frame->TitleBar.hwnd,GWL_STYLE);
- locked=frame->Locked;
- frame->Locked=FALSE;
- frame->minmaxenabled=FALSE;
-
- GetWindowRect(frame->hWnd,&rectw);
- GetWindowRect(frame->TitleBar.hwnd,&recttb);
- if (!frame->TitleBar.ShowTitleBar){
- recttb.top=recttb.bottom=recttb.left=recttb.right=0;
- }
-
- frame->ContainerWnd=CreateContainerWindow(pcli->hwndContactList,frame->FloatingPos.x,frame->FloatingPos.y,10,10);
-
-
-
-
- SetParent(frame->hWnd,frame->ContainerWnd);
- SetParent(frame->TitleBar.hwnd,frame->ContainerWnd);
-
- //SetWindowPos(frame->TitleBar.hwnd,HWND_TOP,0,0,0,0,SWP_NOSIZE);
- //SetWindowPos(frame->hWnd,HWND_TOP,0,recttb.bottom-recttb.top,0,0,SWP_NOSIZE);
- GetBorderSize(frame->ContainerWnd,&border);
-
-
- SetWindowLongPtr(frame->ContainerWnd, GWLP_USERDATA, frame->id);
- if ((lParam==1))
- {
- if ((frame->FloatingPos.x!=0)&&(frame->FloatingPos.y!=0))
- {
- if (frame->FloatingPos.x<20){frame->FloatingPos.x=40;}
- if (frame->FloatingPos.y<20){frame->FloatingPos.y=40;}
-
- SetWindowPos(frame->ContainerWnd,HWND_TOPMOST,frame->FloatingPos.x,frame->FloatingPos.y,frame->FloatingSize.x,frame->FloatingSize.y,SWP_HIDEWINDOW);
- }else
- {
- SetWindowPos(frame->ContainerWnd,HWND_TOPMOST,120,120,140,140,SWP_HIDEWINDOW);
- }
- }
- else
- {
- neww=rectw.right-rectw.left+border.left+border.right;
- newh=(rectw.bottom-rectw.top)+(recttb.bottom-recttb.top)+border.top+border.bottom;
- if (neww<20){neww=40;}
- if (newh<20){newh=40;}
- if (frame->FloatingPos.x<20){frame->FloatingPos.x=40;}
- if (frame->FloatingPos.y<20){frame->FloatingPos.y=40;}
-
- SetWindowPos(frame->ContainerWnd,HWND_TOPMOST,frame->FloatingPos.x,frame->FloatingPos.y,neww,newh,SWP_HIDEWINDOW);
- }
-
-
- SetWindowText(frame->ContainerWnd,frame->TitleBar.tbname);
-
- temp=GetWindowLongPtr(frame->ContainerWnd,GWL_EXSTYLE);
- temp|=WS_EX_TOOLWINDOW|WS_EX_TOPMOST ;
- SetWindowLongPtr(frame->ContainerWnd,GWL_EXSTYLE,temp);
-
- //SetWindowLongPtr(frame->hWnd,GWL_STYLE,WS_POPUP|(frame->oldstyles&(~WS_CHILD)));
- //SetWindowLongPtr(frame->TitleBar.hwnd,GWL_STYLE,WS_POPUP|(frame->TitleBar.oldstyles&(~WS_CHILD)));
-
- frame->floating=TRUE;
- frame->Locked=locked;
-
- }
- CLUIFramesStoreFrameSettings(pos);
- frame->minmaxenabled=TRUE;
- hwndtooltiptmp=frame->TitleBar.hwndTip;
-
- hwndtmp=frame->ContainerWnd;
- ulockfrm();
- CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0);
- SendMessage(hwndtmp,WM_SIZE,0,0);
-
- SetWindowPos(hwndtooltiptmp, HWND_TOPMOST,0, 0, 0, 0,SWP_NOMOVE | SWP_NOSIZE );
- return 0;
-}
-
-static int CLUIFrameOnFontChange(WPARAM wParam,LPARAM lParam)
-{
- FontID fid={0};
- fid.cbSize=sizeof(fid);
- memset(&TitleBarLogFont,0,sizeof(TitleBarLogFont));
-
- strcpy(fid.group,LPGEN("Frames"));
- strcpy(fid.name,LPGEN("TitleBarFont"));
- strcpy(fid.dbSettingsGroup,"CLUIFrames");
- strcpy(fid.prefix,"FramesTitleBarFont");
-
- CallService(MS_FONT_GET,(WPARAM)&fid,(LPARAM)&TitleBarLogFont);
- CLUIFramesOnClistResize(0,0);
-
-
- return 0;
-}
-
-static void CLUIRegisterFonts()
-{
- if (ServiceExists(MS_FONT_REGISTER))
- {
- FontID fid={0};
-
- fid.cbSize=sizeof(fid);
- strcpy(fid.group,LPGEN("Frames"));
- strcpy(fid.name,LPGEN("TitleBarFont"));
- strcpy(fid.dbSettingsGroup,"CLUIFrames");
- strcpy(fid.prefix,"FramesTitleBarFont");
-
- CallService(MS_FONT_REGISTER,(WPARAM)&fid,0);
- CLUIFrameOnFontChange(0,0);
- HookEvent(ME_FONT_RELOAD,CLUIFrameOnFontChange);
-} }
-
-static int CLUIFrameOnModulesLoad(WPARAM wParam,LPARAM lParam)
-{
- CLUIFramesLoadMainMenu(0,0);
- CLUIFramesCreateMenuForFrame(-1,-1,000010000,MS_CLIST_ADDCONTEXTFRAMEMENUITEM);
- CLUIRegisterFonts();
- return 0;
-}
-
-static int CLUIFrameOnModulesUnload(WPARAM wParam,LPARAM lParam)
-{
- CallService( MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, ( LPARAM )contMIVisible, 0 );
- CallService( MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, ( LPARAM )contMITitle, 0 );
- CallService( MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, ( LPARAM )contMITBVisible, 0 );
- CallService( MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, ( LPARAM )contMILock, 0 );
- CallService( MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, ( LPARAM )contMIColl, 0 );
- CallService( MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, ( LPARAM )contMIFloating, 0 );
- CallService( MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, ( LPARAM )contMIAlignRoot, 0 );
- CallService( MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, ( LPARAM )contMIAlignTop, 0 );
- CallService( MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, ( LPARAM )contMIAlignClient, 0 );
- CallService( MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, ( LPARAM )contMIAlignBottom, 0 );
- CallService( MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, ( LPARAM )contMIBorder, 0 );
- return 0;
-}
-
-static INT_PTR CLUIGetCapsService(WPARAM wParam,LPARAM lParam)
-{
- switch (wParam) {
- case CLUICAPS_FLAGS1:
- return CLUIF_HIDEEMPTYGROUPS | CLUIF_DISABLEGROUPS | CLUIF_HASONTOPOPTION | CLUIF_HASAUTOHIDEOPTION;
- case CLUICAPS_FLAGS2:
- return MAKELONG(EXTRACOLUMNCOUNT,1);
- }
- return 0;
-}
-
-int LoadCLUIFramesModule(void)
-{
- WNDCLASS wndclass;
- WNDCLASS cntclass;
-
- wndclass.style = CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW ;
- wndclass.lpfnWndProc = CLUIFrameTitleBarProc;
- wndclass.cbClsExtra = 0;
- wndclass.cbWndExtra = 0;
- wndclass.hInstance = g_hInst;
- wndclass.hIcon = NULL;
- wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
- wndclass.hbrBackground = NULL;
- wndclass.lpszMenuName = NULL;
- wndclass.lpszClassName = CLUIFrameTitleBarClassName;
- RegisterClass(&wndclass);
-
- //container helper
-
- cntclass.style = CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW|( IsWinVerXPPlus() ? CS_DROPSHADOW : 0);
- cntclass.lpfnWndProc = CLUIFrameContainerWndProc;
- cntclass.cbClsExtra = 0;
- cntclass.cbWndExtra = 0;
- cntclass.hInstance = g_hInst;
- cntclass.hIcon = NULL;
- cntclass.hCursor = LoadCursor(NULL, IDC_ARROW);
- cntclass.hbrBackground = NULL;
- cntclass.lpszMenuName = NULL;
- cntclass.lpszClassName = _T("FramesContainer");
- RegisterClass(&cntclass);
- //end container helper
-
- GapBetweenFrames=DBGetContactSettingDword(NULL,"CLUIFrames","GapBetweenFrames",1);
-
- nFramescount=0;
- InitializeCriticalSection(&csFrameHook);
- InitFramesMenus();
-
- hHook[0] = HookEvent(ME_SYSTEM_MODULESLOADED,CLUIFrameOnModulesLoad);
- hHook[1] = HookEvent(ME_CLIST_PREBUILDFRAMEMENU,CLUIFramesModifyContextMenuForFrame);
- hHook[2] = HookEvent(ME_CLIST_PREBUILDMAINMENU,CLUIFrameOnMainMenuBuild);
-
- hService[0] = CreateServiceFunction(MS_CLIST_FRAMES_ADDFRAME,CLUIFramesAddFrame);
- hService[1] = CreateServiceFunction(MS_CLIST_FRAMES_REMOVEFRAME,CLUIFramesRemoveFrame);
-
- hService[2] = CreateServiceFunction(MS_CLIST_FRAMES_SETFRAMEOPTIONS,CLUIFramesSetFrameOptions);
- hService[3] = CreateServiceFunction(MS_CLIST_FRAMES_GETFRAMEOPTIONS,CLUIFramesGetFrameOptions);
- hService[4] = CreateServiceFunction(MS_CLIST_FRAMES_UPDATEFRAME,CLUIFramesUpdateFrame);
-
- hService[5] = CreateServiceFunction(MS_CLIST_FRAMES_SHFRAMETITLEBAR,CLUIFramesShowHideFrameTitleBar);
- hService[6] = CreateServiceFunction(MS_CLIST_FRAMES_SHOWALLFRAMESTB,CLUIFramesShowAllTitleBars);
- hService[7] = CreateServiceFunction(MS_CLIST_FRAMES_HIDEALLFRAMESTB,CLUIFramesHideAllTitleBars);
- hService[8] = CreateServiceFunction(MS_CLIST_FRAMES_SHFRAME,CLUIFramesShowHideFrame);
- hService[9] = CreateServiceFunction(MS_CLIST_FRAMES_SHOWALLFRAMES,CLUIFramesShowAll);
-
- hService[10] = CreateServiceFunction(MS_CLIST_FRAMES_ULFRAME,CLUIFramesLockUnlockFrame);
- hService[11] = CreateServiceFunction(MS_CLIST_FRAMES_UCOLLFRAME,CLUIFramesCollapseUnCollapseFrame);
- hService[12] = CreateServiceFunction(MS_CLIST_FRAMES_SETUNBORDER,CLUIFramesSetUnSetBorder);
-
- hService[13] = CreateServiceFunction(MS_CLUI_GETCAPS,CLUIGetCapsService);
-
- hService[14] = CreateServiceFunction(CLUIFRAMESSETALIGN,CLUIFramesSetAlign);
- hService[15] = CreateServiceFunction(CLUIFRAMESMOVEUPDOWN,CLUIFramesMoveUpDown);
-
- hService[16] = CreateServiceFunction(CLUIFRAMESSETALIGNALTOP,CLUIFramesSetAlignalTop);
- hService[17] = CreateServiceFunction(CLUIFRAMESSETALIGNALCLIENT,CLUIFramesSetAlignalClient);
- hService[18] = CreateServiceFunction(CLUIFRAMESSETALIGNALBOTTOM,CLUIFramesSetAlignalBottom);
-
- hService[19] = CreateServiceFunction("Set_Floating",CLUIFrameSetFloat);
- hWndExplorerToolBar =FindWindowExA(0,0,"Shell_TrayWnd",NULL);
- OnFrameTitleBarBackgroundChange(0,0);
- FramesSysNotStarted=FALSE;
- hHook[3] = HookEvent(ME_SYSTEM_PRESHUTDOWN, CLUIFrameOnModulesUnload);
- return 0;
-}
-
-int UnLoadCLUIFramesModule(void)
-{
- int i;
- FramesSysNotStarted=TRUE;
-
- for (i=0; i<SIZEOF(hService); ++i)
- DestroyServiceFunction(hService[i]);
-
- for (i=0; i<SIZEOF(hHook); ++i)
- UnhookEvent(hHook[i]);
-
- CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,0);
- CLUIFramesStoreAllFrames();
- lockfrm();
- for (i=0;i<nFramescount;i++) {
- DestroyWindow(Frames[i].hWnd);
- Frames[i].hWnd=(HWND)-1;
- DestroyWindow(Frames[i].TitleBar.hwnd);
- Frames[i].TitleBar.hwnd=(HWND)-1;
- DestroyWindow(Frames[i].ContainerWnd);
- Frames[i].ContainerWnd=(HWND)-1;
- DestroyMenu(Frames[i].TitleBar.hmenu);
-
- mir_free(Frames[i].name);
- mir_free(Frames[i].TitleBar.tbname);
- mir_free(Frames[i].TitleBar.tooltip);
- }
- if(Frames) free(Frames);
- Frames=NULL;
- nFramescount=0;
- UnregisterClass(CLUIFrameTitleBarClassName,g_hInst);
- DeleteObject(TitleBarFont);
- ulockfrm();
- DeleteCriticalSection(&csFrameHook);
- return 0;
-}
diff --git a/plugins/Mwclist/CLUIFrames/cluiframes.cpp b/plugins/Mwclist/CLUIFrames/cluiframes.cpp
new file mode 100644
index 0000000000..a84992f80a
--- /dev/null
+++ b/plugins/Mwclist/CLUIFrames/cluiframes.cpp
@@ -0,0 +1,3015 @@
+/*
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2003 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "../commonheaders.h"
+
+extern HINSTANCE g_hInst;
+
+//we use dynamic frame list,
+//but who wants so huge number of frames ??
+#define MAX_FRAMES 16
+
+#define UNCOLLAPSED_FRAME_SIZE 0
+#define DEFAULT_TITLEBAR_HEIGHT 20
+
+//legacy menu support
+#define frame_menu_lock 1
+#define frame_menu_visible 2
+#define frame_menu_showtitlebar 3
+#define frame_menu_floating 4
+extern int ModifyMenuItemProxy(WPARAM wParam,LPARAM lParam);
+static int UpdateTBToolTip(int framepos);
+INT_PTR CLUIFrameSetFloat(WPARAM wParam,LPARAM lParam);
+int CLUIFrameResizeFloatingFrame(int framepos);
+extern int ProcessCommandProxy(WPARAM wParam,LPARAM lParam);
+extern int InitFramesMenus(void);
+int GapBetweenTitlebar;
+
+LOGFONTA TitleBarLogFont = {0};
+
+boolean FramesSysNotStarted = TRUE;
+
+HANDLE hService[20], hHook[4];
+
+typedef struct
+{
+ int order;
+ int realpos;
+}
+ SortData;
+
+static int sortfunc(const void *a,const void *b)
+{
+ SortData *sd1,*sd2;
+ sd1 = (SortData *)a;
+ sd2 = (SortData *)b;
+ if (sd1->order > sd2->order){return(1);}
+ if (sd1->order < sd2->order){return(-1);}
+ //if (sd1->order == sd2->order){return 0;}
+ return 0;
+}
+
+
+// == == == == == ==
+#define CLUIFRAMESSETALIGN "CLUIFramesSetAlign"
+
+#define CLUIFRAMESSETALIGNALTOP "CLUIFramesSetAlignalTop"
+#define CLUIFRAMESSETALIGNALCLIENT "CLUIFramesSetAlignalClient"
+#define CLUIFRAMESSETALIGNALBOTTOM "CLUIFramesSetAlignalBottom"
+
+#define CLUIFRAMESMOVEUPDOWN "CLUIFramesMoveUpDown"
+typedef struct tagMenuHandles
+{
+ HANDLE MainMenuItem;
+ HANDLE MIVisible,MITitle,MITBVisible,MILock,MIColl,MIFloating,MIAlignRoot;
+ HANDLE MIAlignTop,MIAlignClient,MIAlignBottom;
+ HANDLE MIBorder;
+} FrameMenuHandles;
+
+typedef struct tagFrameTitleBar{
+ HWND hwnd;
+ HWND TitleBarbutt;
+ HWND hwndTip;
+
+ LPTSTR tbname;
+ LPTSTR tooltip;
+ HMENU hmenu;
+ HICON hicon;
+
+ BOOLEAN ShowTitleBar;
+ BOOLEAN ShowTitleBarTip;
+ COLORREF BackColour;
+ int oldstyles;
+ POINT oldpos;
+ RECT wndSize;
+} FrameTitleBar;
+
+typedef struct _DockOpt
+{
+ HWND hwndLeft;
+ HWND hwndRight;
+}
+DockOpt;
+
+typedef struct {
+ int id;
+ HWND hWnd ;
+ RECT wndSize;
+ LPTSTR name;
+ int align;
+ int height;
+ int dwFlags;
+ BOOLEAN Locked;
+ BOOLEAN visible;
+ BOOLEAN needhide;
+ BOOLEAN collapsed;
+ int prevvisframe;
+ int HeightWhenCollapsed;
+ FrameTitleBar TitleBar;
+ FrameMenuHandles MenuHandles;
+ int oldstyles;
+ BOOLEAN floating;
+ HWND ContainerWnd;
+ POINT FloatingPos;
+ POINT FloatingSize;
+ BOOLEAN minmaxenabled;
+ BOOLEAN UseBorder;
+ int order;
+ DockOpt dockOpt;
+} wndFrame;
+
+//static wndFrame Frames[MAX_FRAMES];
+static wndFrame *Frames = NULL;
+
+static int nFramescount = 0;
+static int alclientFrame = -1;//for fast access to frame with alclient properties
+static int NextFrameId = 100;
+
+HFONT TitleBarFont;
+static int TitleBarH = DEFAULT_TITLEBAR_HEIGHT;
+static boolean resizing = FALSE;
+
+// menus
+static HANDLE contMIVisible,contMITitle,contMITBVisible,contMILock,contMIColl,contMIFloating;
+static HANDLE contMIAlignRoot;
+static HANDLE contMIAlignTop,contMIAlignClient,contMIAlignBottom;
+static HANDLE contMIBorder;
+static HGENMENU MainMIRoot = (HGENMENU)-1;
+
+// others
+static int ContactListHeight;
+static int LastStoreTick = 0;
+
+static int lbypos = -1;
+static int oldframeheight = -1;
+static int curdragbar = -1;
+static CRITICAL_SECTION csFrameHook;
+
+static BOOLEAN CLUIFramesFitInSize(void);
+static int RemoveItemFromList(int pos,wndFrame **lpFrames,int *FrameItemCount);
+HWND hWndExplorerToolBar;
+static int GapBetweenFrames = 1;
+
+static int RemoveItemFromList(int pos,wndFrame **lpFrames,int *FrameItemCount)
+{
+ memcpy(&((*lpFrames)[pos]),&((*lpFrames)[pos+1]),sizeof(wndFrame)*(*FrameItemCount-pos-1));
+ (*FrameItemCount)--;
+ (*lpFrames) = (wndFrame*)realloc((*lpFrames),sizeof(wndFrame)*(*FrameItemCount));
+ return 0;
+}
+
+static int id2pos(int id)
+{
+ if (FramesSysNotStarted)
+ return -1;
+
+ for (int i = 0;i<nFramescount;i++)
+ if (Frames[i].id == id)
+ return i;
+
+ return -1;
+}
+
+static int btoint(BOOLEAN b)
+{
+ if (b) return 1;
+ return 0;
+}
+
+static void __inline lockfrm()
+{
+ EnterCriticalSection(&csFrameHook);
+}
+
+static void __inline ulockfrm()
+{
+ LeaveCriticalSection(&csFrameHook);
+}
+
+//////////screen docking,code from "floating contacts" plugin.
+
+static wndFrame* FindFrameByWnd( HWND hwnd )
+{
+ if ( hwnd == NULL )
+ return NULL;
+
+ for (int i = 0; i < nFramescount; i++)
+ if ( Frames[i].floating && Frames[i].ContainerWnd == hwnd )
+ return &Frames[i];
+
+ return NULL;
+}
+
+static void DockThumbs( wndFrame *pThumbLeft, wndFrame *pThumbRight, BOOL bMoveLeft )
+{
+ if ( pThumbRight->dockOpt.hwndLeft == NULL && pThumbLeft->dockOpt.hwndRight == NULL ) {
+ pThumbRight->dockOpt.hwndLeft = pThumbLeft->ContainerWnd;
+ pThumbLeft->dockOpt.hwndRight = pThumbRight->ContainerWnd;
+ }
+}
+
+static void UndockThumbs( wndFrame *pThumb1, wndFrame *pThumb2 )
+{
+ if ( pThumb1 == NULL || pThumb2 == NULL )
+ return;
+
+ if ( pThumb1->dockOpt.hwndRight == pThumb2->ContainerWnd )
+ pThumb1->dockOpt.hwndRight = NULL;
+
+ if ( pThumb1->dockOpt.hwndLeft == pThumb2->ContainerWnd )
+ pThumb1->dockOpt.hwndLeft = NULL;
+
+ if ( pThumb2->dockOpt.hwndRight == pThumb1->ContainerWnd )
+ pThumb2->dockOpt.hwndRight = NULL;
+
+ if ( pThumb2->dockOpt.hwndLeft == pThumb1->ContainerWnd )
+ pThumb2->dockOpt.hwndLeft = NULL;
+}
+
+BOOLEAN bMoveTogether;
+
+static void PositionThumb( wndFrame *pThumb, short nX, short nY )
+{
+ wndFrame *pCurThumb = &Frames[0];
+ wndFrame *pDockThumb = pThumb;
+ wndFrame fakeMainWindow;
+ wndFrame fakeTaskBarWindow;
+ RECT rc;
+ RECT rcThumb;
+ RECT rcOld;
+ SIZE sizeScreen;
+ int nNewX;
+ int nNewY;
+ int nOffs = 10;
+ int nWidth;
+ int nHeight;
+ POINT pt;
+ RECT rcLeft;
+ RECT rcTop;
+ RECT rcRight;
+ RECT rcBottom;
+ BOOL bDocked;
+ BOOL bDockedLeft;
+ BOOL bDockedRight;
+ BOOL bLeading;
+ int frmidx = 0;
+
+ if ( pThumb == NULL )
+ return;
+
+ sizeScreen.cx = GetSystemMetrics( SM_CXSCREEN );
+ sizeScreen.cy = GetSystemMetrics( SM_CYSCREEN );
+
+ // Get thumb dimnsions
+ GetWindowRect( pThumb->ContainerWnd, &rcThumb );
+ nWidth = rcThumb.right - rcThumb.left;
+ nHeight = rcThumb.bottom - rcThumb.top;
+
+ // Docking to the edges of the screen
+ nNewX = nX < nOffs ? 0 : nX;
+ nNewX = nNewX > ( sizeScreen.cx - nWidth - nOffs ) ? ( sizeScreen.cx - nWidth ) : nNewX;
+ nNewY = nY < nOffs ? 0 : nY;
+ nNewY = nNewY > ( sizeScreen.cy - nHeight - nOffs ) ? ( sizeScreen.cy - nHeight ) : nNewY;
+
+ bLeading = pThumb->dockOpt.hwndRight != NULL;
+
+ if ( bMoveTogether ) {
+ UndockThumbs( pThumb, FindFrameByWnd( pThumb->dockOpt.hwndLeft ) );
+ GetWindowRect( pThumb->ContainerWnd, &rcOld );
+ }
+
+ memset(&fakeMainWindow,0,sizeof(fakeMainWindow));
+ fakeMainWindow.ContainerWnd = pcli->hwndContactList;
+ fakeMainWindow.floating = TRUE;
+
+ memset(&fakeTaskBarWindow,0,sizeof(fakeTaskBarWindow));
+ fakeTaskBarWindow.ContainerWnd = hWndExplorerToolBar;
+ fakeTaskBarWindow.floating = TRUE;
+
+ while( pCurThumb != NULL ) {
+ if (pCurThumb->floating) {
+ if ( pCurThumb != pThumb ) {
+ GetWindowRect( pThumb->ContainerWnd, &rcThumb );
+ OffsetRect( &rcThumb, nX - rcThumb.left, nY - rcThumb.top );
+
+ GetWindowRect( pCurThumb->ContainerWnd, &rc );
+
+ // These are rects we will dock into
+ rcLeft.left = rc.left - nOffs;
+ rcLeft.top = rc.top - nOffs;
+ rcLeft.right = rc.left + nOffs;
+ rcLeft.bottom = rc.bottom + nOffs;
+
+ rcTop.left = rc.left - nOffs;
+ rcTop.top = rc.top - nOffs;
+ rcTop.right = rc.right + nOffs;
+ rcTop.bottom = rc.top + nOffs;
+
+ rcRight.left = rc.right - nOffs;
+ rcRight.top = rc.top - nOffs;
+ rcRight.right = rc.right + nOffs;
+ rcRight.bottom = rc.bottom + nOffs;
+
+ rcBottom.left = rc.left - nOffs;
+ rcBottom.top = rc.bottom - nOffs;
+ rcBottom.right = rc.right + nOffs;
+ rcBottom.bottom = rc.bottom + nOffs;
+
+
+ bDockedLeft = FALSE;
+ bDockedRight = FALSE;
+
+ // Upper-left
+ pt.x = rcThumb.left;
+ pt.y = rcThumb.top;
+ bDocked = FALSE;
+
+ if ( PtInRect( &rcRight, pt )) {
+ nNewX = rc.right;
+ bDocked = TRUE;
+ }
+
+ if ( PtInRect( &rcBottom, pt )) {
+ nNewY = rc.bottom;
+ if ( PtInRect( &rcLeft, pt ) )
+ nNewX = rc.left;
+ }
+
+ if ( PtInRect( &rcTop, pt )) {
+ nNewY = rc.top;
+ bDockedLeft = bDocked;
+ }
+
+ // Upper-right
+ pt.x = rcThumb.right;
+ pt.y = rcThumb.top;
+ bDocked = FALSE;
+
+ if ( !bLeading && PtInRect( &rcLeft, pt )) {
+ if ( !bDockedLeft ) {
+ nNewX = rc.left - nWidth;
+ bDocked = TRUE;
+ }
+ else if ( rc.right == rcThumb.left )
+ bDocked = TRUE;
+ }
+
+ if ( PtInRect( &rcBottom, pt )) {
+ nNewY = rc.bottom;
+ if ( PtInRect( &rcRight, pt ))
+ nNewX = rc.right - nWidth;
+ }
+
+ if ( !bLeading && PtInRect( &rcTop, pt )) {
+ nNewY = rc.top;
+ bDockedRight = bDocked;
+ }
+
+ if ( bMoveTogether ) {
+ if ( bDockedRight )
+ DockThumbs( pThumb, pCurThumb, TRUE );
+
+ if ( bDockedLeft )
+ DockThumbs( pCurThumb, pThumb, FALSE );
+ }
+
+ // Lower-left
+ pt.x = rcThumb.left;
+ pt.y = rcThumb.bottom;
+
+ if ( PtInRect( &rcRight, pt ))
+ nNewX = rc.right;
+
+ if ( PtInRect( &rcTop, pt )) {
+ nNewY = rc.top - nHeight;
+ if ( PtInRect( &rcLeft, pt ) )
+ nNewX = rc.left;
+ }
+
+ // Lower-right
+ pt.x = rcThumb.right;
+ pt.y = rcThumb.bottom;
+
+ if ( !bLeading && PtInRect( &rcLeft, pt ))
+ nNewX = rc.left - nWidth;
+
+ if ( !bLeading && PtInRect( &rcTop, pt )) {
+ nNewY = rc.top - nHeight;
+ if ( PtInRect( &rcRight, pt ) )
+ nNewX = rc.right - nWidth;
+ }
+ }
+ }
+
+ frmidx++;
+ if (pCurThumb->ContainerWnd = fakeTaskBarWindow.ContainerWnd){break;}
+ if (pCurThumb->ContainerWnd = fakeMainWindow.ContainerWnd){
+ pCurThumb = &fakeTaskBarWindow;continue;}
+ if (frmidx = nFramescount){
+ pCurThumb = &fakeMainWindow;continue;
+ }
+
+ pCurThumb = &Frames[frmidx];
+ }
+
+ // Adjust coords once again
+ nNewX = nNewX < nOffs ? 0 : nNewX;
+ nNewX = nNewX > ( sizeScreen.cx - nWidth - nOffs ) ? ( sizeScreen.cx - nWidth ) : nNewX;
+ nNewY = nNewY < nOffs ? 0 : nNewY;
+ nNewY = nNewY > ( sizeScreen.cy - nHeight - nOffs ) ? ( sizeScreen.cy - nHeight ) : nNewY;
+
+ SetWindowPos( pThumb->ContainerWnd, HWND_TOPMOST, nNewX, nNewY, 0, 0, SWP_NOSIZE | SWP_NOZORDER );
+
+ // OK, move all docked thumbs
+ if ( bMoveTogether ) {
+ pDockThumb = FindFrameByWnd( pDockThumb->dockOpt.hwndRight );
+ PositionThumb( pDockThumb, (short)( nNewX + nWidth ), (short)nNewY );
+ }
+}
+
+//////////
+
+void GetBorderSize(HWND hwnd,RECT *rect)
+{
+ RECT wr,cr;
+ POINT pt1,pt2;
+
+ GetWindowRect(hwnd,&wr);
+ GetClientRect(hwnd,&cr);
+ pt1.y = cr.top;pt1.x = cr.left;
+ pt2.y = cr.bottom;pt2.x = cr.right;
+
+ ClientToScreen(hwnd,&pt1);
+ ClientToScreen(hwnd,&pt2);
+
+ cr.top = pt1.y;cr.left = pt1.x;
+ cr.bottom = pt2.y;cr.right = pt2.x;
+
+ rect->top = cr.top-wr.top;
+ rect->left = cr.left-wr.left;
+ rect->right = wr.right-cr.right;
+ rect->bottom = wr.bottom-cr.bottom;
+}
+
+//append string
+char __inline *AS(char *str,const char *setting,char *addstr)
+{
+ if (str != NULL) {
+ strcpy(str,setting);
+ strcat(str,addstr);
+ }
+ return str;
+}
+
+int DBLoadFrameSettingsAtPos(int pos,int Frameid)
+{
+ char sadd[15];
+ char buf[255];
+
+ _itoa(pos,sadd,10);
+
+ //boolean
+ Frames[Frameid].collapsed = DBGetContactSettingByte(0,CLUIFrameModule,AS(buf,"Collapse",sadd),Frames[Frameid].collapsed);
+
+ Frames[Frameid].Locked = DBGetContactSettingByte(0,CLUIFrameModule,AS(buf,"Locked",sadd),Frames[Frameid].Locked);
+ Frames[Frameid].visible = DBGetContactSettingByte(0,CLUIFrameModule,AS(buf,"Visible",sadd),Frames[Frameid].visible);
+ Frames[Frameid].TitleBar.ShowTitleBar = DBGetContactSettingByte(0,CLUIFrameModule,AS(buf,"TBVisile",sadd),Frames[Frameid].TitleBar.ShowTitleBar);
+
+ Frames[Frameid].height = DBGetContactSettingWord(0,CLUIFrameModule,AS(buf,"Height",sadd),Frames[Frameid].height);
+ Frames[Frameid].HeightWhenCollapsed = DBGetContactSettingWord(0,CLUIFrameModule,AS(buf,"HeightCollapsed",sadd),0);
+ Frames[Frameid].align = DBGetContactSettingWord(0,CLUIFrameModule,AS(buf,"Align",sadd),Frames[Frameid].align);
+
+ Frames[Frameid].FloatingPos.x = DBGetContactSettingRangedWord(0,CLUIFrameModule,AS(buf,"FloatX",sadd),100,0,1024);
+ Frames[Frameid].FloatingPos.y = DBGetContactSettingRangedWord(0,CLUIFrameModule,AS(buf,"FloatY",sadd),100,0,1024);
+ Frames[Frameid].FloatingSize.x = DBGetContactSettingRangedWord(0,CLUIFrameModule,AS(buf,"FloatW",sadd),100,0,1024);
+ Frames[Frameid].FloatingSize.y = DBGetContactSettingRangedWord(0,CLUIFrameModule,AS(buf,"FloatH",sadd),100,0,1024);
+
+ Frames[Frameid].floating = DBGetContactSettingByte(0,CLUIFrameModule,AS(buf,"Floating",sadd),0);
+ Frames[Frameid].order = DBGetContactSettingWord(0,CLUIFrameModule,AS(buf,"Order",sadd),0);
+
+ Frames[Frameid].UseBorder = DBGetContactSettingByte(0,CLUIFrameModule,AS(buf,"UseBorder",sadd),Frames[Frameid].UseBorder);
+
+ return 0;
+}
+
+int DBStoreFrameSettingsAtPos(int pos,int Frameid)
+{
+ char sadd[16];
+ char buf[255];
+
+ _itoa(pos,sadd,10);
+
+ DBWriteContactSettingTString(0,CLUIFrameModule,AS(buf,"Name",sadd),Frames[Frameid].name);
+ //boolean
+ DBWriteContactSettingByte(0,CLUIFrameModule,AS(buf,"Collapse",sadd),(BYTE)btoint(Frames[Frameid].collapsed));
+ DBWriteContactSettingByte(0,CLUIFrameModule,AS(buf,"Locked",sadd),(BYTE)btoint(Frames[Frameid].Locked));
+ DBWriteContactSettingByte(0,CLUIFrameModule,AS(buf,"Visible",sadd),(BYTE)btoint(Frames[Frameid].visible));
+ DBWriteContactSettingByte(0,CLUIFrameModule,AS(buf,"TBVisile",sadd),(BYTE)btoint(Frames[Frameid].TitleBar.ShowTitleBar));
+
+ DBWriteContactSettingWord(0,CLUIFrameModule,AS(buf,"Height",sadd),(WORD)Frames[Frameid].height);
+ DBWriteContactSettingWord(0,CLUIFrameModule,AS(buf,"HeightCollapsed",sadd),(WORD)Frames[Frameid].HeightWhenCollapsed);
+ DBWriteContactSettingWord(0,CLUIFrameModule,AS(buf,"Align",sadd),(WORD)Frames[Frameid].align);
+ //FloatingPos
+ DBWriteContactSettingWord(0,CLUIFrameModule,AS(buf,"FloatX",sadd),(WORD)Frames[Frameid].FloatingPos.x);
+ DBWriteContactSettingWord(0,CLUIFrameModule,AS(buf,"FloatY",sadd),(WORD)Frames[Frameid].FloatingPos.y);
+ DBWriteContactSettingWord(0,CLUIFrameModule,AS(buf,"FloatW",sadd),(WORD)Frames[Frameid].FloatingSize.x);
+ DBWriteContactSettingWord(0,CLUIFrameModule,AS(buf,"FloatH",sadd),(WORD)Frames[Frameid].FloatingSize.y);
+
+ DBWriteContactSettingByte(0,CLUIFrameModule,AS(buf,"Floating",sadd),(BYTE)btoint(Frames[Frameid].floating));
+ DBWriteContactSettingByte(0,CLUIFrameModule,AS(buf,"UseBorder",sadd),(BYTE)btoint(Frames[Frameid].UseBorder));
+ DBWriteContactSettingWord(0,CLUIFrameModule,AS(buf,"Order",sadd),(WORD)Frames[Frameid].order);
+ //DBWriteContactSettingString(0,CLUIFrameModule,AS(buf,"TBName",sadd),Frames[Frameid].TitleBar.tbname);
+ return 0;
+}
+
+int LocateStorePosition(int Frameid,int maxstored)
+{
+ int i;
+ LPTSTR frmname;
+ char settingname[255];
+ if (Frames[Frameid].name == NULL) return -1;
+
+ for (i = 0;i<maxstored;i++) {
+ mir_snprintf(settingname,sizeof(settingname),"Name%d",i);
+ frmname = DBGetStringT(0,CLUIFrameModule,settingname);
+ if (frmname == NULL) continue;
+ if (lstrcmpi(frmname,Frames[Frameid].name) == 0) {
+ mir_free(frmname);
+ return i;
+ }
+ mir_free(frmname);
+ }
+ return -1;
+}
+
+int CLUIFramesLoadFrameSettings(int Frameid)
+{
+ if (Frameid < 0 || Frameid >= nFramescount)
+ return -1;
+
+ int maxstored = DBGetContactSettingWord(0,CLUIFrameModule,"StoredFrames",-1);
+ if (maxstored == -1)
+ return 0;
+
+ int storpos = LocateStorePosition(Frameid,maxstored);
+ if (storpos == -1)
+ return 0;
+
+ DBLoadFrameSettingsAtPos(storpos,Frameid);
+ return 0;
+}
+
+int CLUIFramesStoreFrameSettings(int Frameid)
+{
+ if (Frameid < 0 || Frameid >= nFramescount)
+ return -1;
+
+ int maxstored = DBGetContactSettingWord(0,CLUIFrameModule,"StoredFrames",-1);
+ if (maxstored == -1) maxstored = 0;
+
+ int storpos = LocateStorePosition(Frameid,maxstored);
+ if (storpos == -1) {storpos = maxstored; maxstored++;}
+
+ DBStoreFrameSettingsAtPos(storpos,Frameid);
+ DBWriteContactSettingWord(0,CLUIFrameModule,"StoredFrames",(WORD)maxstored);
+ //ulockfrm();
+ return 0;
+}
+
+int CLUIFramesStoreAllFrames()
+{
+ lockfrm();
+ for (int i = 0;i<nFramescount;i++)
+ CLUIFramesStoreFrameSettings(i);
+ ulockfrm();
+ return 0;
+}
+
+// Get client frame
+int CLUIFramesGetalClientFrame(void)
+{
+ if (alclientFrame != -1)
+ return alclientFrame;
+
+ if (alclientFrame != -1) {
+ /* this value could become invalid if RemoveItemFromList was called,
+ * so we double-check */
+ if (alclientFrame<nFramescount) {
+ if (Frames[alclientFrame].align == alClient) {
+ return alclientFrame;
+ }
+ }
+ }
+
+ for (int i = 0;i<nFramescount;i++)
+ if (Frames[i].align == alClient) {
+ alclientFrame = i;
+ return i;
+ }
+
+ //pluginLink
+ return -1;
+}
+
+HMENU CLUIFramesCreateMenuForFrame(int frameid,int root,int popuppos,char *addservice)
+{
+ CLISTMENUITEM mi;
+ //TMO_MenuItem tmi;
+ HANDLE menuid;
+ int framepos = id2pos(frameid);
+
+ ZeroMemory(&mi,sizeof(mi));
+
+ mi.cbSize = sizeof(mi);
+ mi.hIcon = LoadIcon(g_hInst,MAKEINTRESOURCE(IDI_CLIENTMIRANDA));
+ mi.pszPopupName = (char *)root;
+ mi.popupPosition = frameid;
+ mi.position = popuppos++;
+ mi.pszName = LPGEN("&FrameTitle");
+ mi.flags = CMIF_CHILDPOPUP|CMIF_GRAYED;
+ mi.pszContactOwner = (char *)0;
+ menuid = (HANDLE)CallService(addservice,0,(LPARAM)&mi);
+ if (frameid == -1) contMITitle = menuid;
+ else Frames[framepos].MenuHandles.MITitle = menuid;
+
+ popuppos += 100000;
+ mi.hIcon = NULL;
+ mi.cbSize = sizeof(mi);
+ mi.pszPopupName = (char *)root;
+ mi.popupPosition = frameid;
+ mi.position = popuppos++;
+ mi.pszName = LPGEN("&Visible");
+ mi.flags = CMIF_CHILDPOPUP|CMIF_CHECKED;
+ mi.pszContactOwner = (char *)0;
+ mi.pszService = MS_CLIST_FRAMES_SHFRAME;
+ menuid = (HANDLE)CallService(addservice,0,(LPARAM)&mi);
+ if (frameid == -1) contMIVisible = menuid;
+ else Frames[framepos].MenuHandles.MIVisible = menuid;
+
+ mi.pszPopupName = (char *)root;
+ mi.popupPosition = frameid;
+ mi.position = popuppos++;
+ mi.pszName = LPGEN("&Show TitleBar");
+ mi.flags = CMIF_CHILDPOPUP|CMIF_CHECKED;
+ mi.pszService = MS_CLIST_FRAMES_SHFRAMETITLEBAR;
+ mi.pszContactOwner = (char *)0;
+ menuid = (HANDLE)CallService(addservice,0,(LPARAM)&mi);
+ if (frameid == -1) contMITBVisible = menuid;
+ else Frames[framepos].MenuHandles.MITBVisible = menuid;
+
+
+ popuppos += 100000;
+
+ mi.pszPopupName = (char *)root;
+ mi.popupPosition = frameid;
+ mi.position = popuppos++;
+ mi.pszName = LPGEN("&Locked");
+ mi.flags = CMIF_CHILDPOPUP|CMIF_CHECKED;
+ mi.pszService = MS_CLIST_FRAMES_ULFRAME;
+ mi.pszContactOwner = (char *)0;
+ menuid = (HANDLE)CallService(addservice,0,(LPARAM)&mi);
+ if (frameid == -1) contMILock = menuid;
+ else Frames[framepos].MenuHandles.MILock = menuid;
+
+ mi.pszPopupName = (char *)root;
+ mi.popupPosition = frameid;
+ mi.position = popuppos++;
+ mi.pszName = LPGEN("&Collapsed");
+ mi.flags = CMIF_CHILDPOPUP|CMIF_CHECKED;
+ mi.pszService = MS_CLIST_FRAMES_UCOLLFRAME;
+ mi.pszContactOwner = (char *)0;
+ menuid = (HANDLE)CallService(addservice,0,(LPARAM)&mi);
+ if (frameid == -1) contMIColl = menuid;
+ else Frames[framepos].MenuHandles.MIColl = menuid;
+
+ //floating
+ mi.pszPopupName = (char *)root;
+ mi.popupPosition = frameid;
+ mi.position = popuppos++;
+ mi.pszName = LPGEN("&Floating Mode");
+ mi.flags = CMIF_CHILDPOPUP;
+ mi.pszService = "Set_Floating";
+ mi.pszContactOwner = (char *)0;
+ menuid = (HANDLE)CallService(addservice,0,(LPARAM)&mi);
+ if (frameid == -1) contMIFloating = menuid;
+ else Frames[framepos].MenuHandles.MIFloating = menuid;
+
+
+ popuppos += 100000;
+
+ mi.pszPopupName = (char *)root;
+ mi.popupPosition = frameid;
+ mi.position = popuppos++;
+ mi.pszName = LPGEN("&Border");
+ mi.flags = CMIF_CHILDPOPUP|CMIF_CHECKED;
+ mi.pszService = MS_CLIST_FRAMES_SETUNBORDER;
+ mi.pszContactOwner = (char *)0;
+ menuid = (HANDLE)CallService(addservice,0,(LPARAM)&mi);
+ if (frameid == -1) contMIBorder = menuid;
+ else Frames[framepos].MenuHandles.MIBorder = menuid;
+
+ popuppos += 100000;
+
+ //alignment root
+ mi.pszPopupName = (char *)root;
+ mi.popupPosition = frameid;
+ mi.position = popuppos++;
+ mi.pszName = LPGEN("&Align");
+ mi.flags = CMIF_CHILDPOPUP|CMIF_ROOTPOPUP;
+ mi.pszService = "";
+ mi.pszContactOwner = (char *)0;
+ menuid = (HANDLE)CallService(addservice,0,(LPARAM)&mi);
+ if (frameid == -1) contMIAlignRoot = menuid;
+ else Frames[framepos].MenuHandles.MIAlignRoot = menuid;
+
+ mi.flags = CMIF_CHILDPOPUP;
+ //align top
+ mi.pszPopupName = (char *)menuid;
+ mi.popupPosition = frameid;
+ mi.position = popuppos++;
+ mi.pszName = LPGEN("&Top");
+ mi.pszService = CLUIFRAMESSETALIGNALTOP;
+ mi.pszContactOwner = (char *)alTop;
+ menuid = (HANDLE)CallService(addservice,0,(LPARAM)&mi);
+ if (frameid == -1) contMIAlignTop = menuid;
+ else Frames[framepos].MenuHandles.MIAlignTop = menuid;
+
+
+ //align client
+ mi.position = popuppos++;
+ mi.pszName = LPGEN("&Client");
+ mi.pszService = CLUIFRAMESSETALIGNALCLIENT;
+ mi.pszContactOwner = (char *)alClient;
+ menuid = (HANDLE)CallService(addservice,0,(LPARAM)&mi);
+ if (frameid == -1) contMIAlignClient = menuid;
+ else Frames[framepos].MenuHandles.MIAlignClient = menuid;
+
+ //align bottom
+ mi.position = popuppos++;
+ mi.pszName = LPGEN("&Bottom");
+ mi.pszService = CLUIFRAMESSETALIGNALBOTTOM;
+ mi.pszContactOwner = (char *)alBottom;
+ menuid = (HANDLE)CallService(addservice,0,(LPARAM)&mi);
+ if (frameid == -1) contMIAlignBottom = menuid;
+ else Frames[framepos].MenuHandles.MIAlignBottom = menuid;
+
+ //position
+ //position root
+ mi.pszPopupName = (char *)root;
+ mi.popupPosition = frameid;
+ mi.position = popuppos++;
+ mi.pszName = LPGEN("&Position");
+ mi.flags = CMIF_CHILDPOPUP|CMIF_ROOTPOPUP;
+ mi.pszService = "";
+ mi.pszContactOwner = (char *)0;
+ menuid = (HANDLE)CallService(addservice,0,(LPARAM)&mi);
+
+ mi.pszPopupName = (char *)menuid;
+ mi.popupPosition = frameid;
+ mi.position = popuppos++;
+ mi.pszName = LPGEN("&Up");
+ mi.flags = CMIF_CHILDPOPUP;
+ mi.pszService = CLUIFRAMESMOVEUPDOWN;
+ mi.pszContactOwner = (char *)1;
+ CallService(addservice,0,(LPARAM)&mi);
+
+ mi.pszPopupName = (char *)menuid;
+ mi.popupPosition = frameid;
+ mi.position = popuppos++;
+ mi.pszName = LPGEN("&Down");
+ mi.flags = CMIF_CHILDPOPUP;
+ mi.pszService = CLUIFRAMESMOVEUPDOWN;
+ mi.pszContactOwner = (char *)-1;
+ CallService(addservice,0,(LPARAM)&mi);
+
+ return 0;
+}
+
+INT_PTR ModifyMItem(WPARAM wParam,LPARAM lParam)
+{
+ return ModifyMenuItemProxy(wParam,lParam);
+}
+
+static int CLUIFramesModifyContextMenuForFrame(WPARAM wParam,LPARAM lParam)
+{
+ int pos;
+ CLISTMENUITEM mi;
+ //TMO_MenuItem tmi;
+
+ lockfrm();
+ pos = id2pos(wParam);
+
+ if (pos >= 0 && pos < nFramescount) {
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.flags = CMIM_NAME|CMIF_CHILDPOPUP|CMIF_TCHAR;
+ mi.ptszName = Frames[pos].TitleBar.tbname ? Frames[pos].TitleBar.tbname : Frames[pos].name;
+ ModifyMItem((WPARAM)contMITitle,(LPARAM)&mi);
+
+ mi.flags = CMIM_FLAGS|CMIF_CHILDPOPUP;
+ if (Frames[pos].visible) mi.flags|=CMIF_CHECKED;
+ ModifyMItem((WPARAM)contMIVisible,(LPARAM)&mi);
+
+ mi.flags = CMIM_FLAGS|CMIF_CHILDPOPUP;
+ if (Frames[pos].Locked) mi.flags|=CMIF_CHECKED;
+ ModifyMItem((WPARAM)contMILock,(LPARAM)&mi);
+
+ mi.flags = CMIM_FLAGS|CMIF_CHILDPOPUP;
+ if (Frames[pos].TitleBar.ShowTitleBar) mi.flags|=CMIF_CHECKED;
+ ModifyMItem((WPARAM)contMITBVisible,(LPARAM)&mi);
+
+ mi.flags = CMIM_FLAGS|CMIF_CHILDPOPUP;
+ if (Frames[pos].floating) mi.flags|=CMIF_CHECKED;
+ ModifyMItem((WPARAM)contMIFloating,(LPARAM)&mi);
+
+ mi.flags = CMIM_FLAGS|CMIF_CHILDPOPUP;
+ if ((Frames[pos].UseBorder)) mi.flags|=CMIF_CHECKED;
+ ModifyMItem((WPARAM)contMIBorder,(LPARAM)&mi);
+
+ mi.flags = CMIM_FLAGS|CMIF_CHILDPOPUP;
+ if (Frames[pos].align&alTop) mi.flags|=CMIF_CHECKED;
+ ModifyMItem((WPARAM)contMIAlignTop,(LPARAM)&mi);
+
+ mi.flags = CMIM_FLAGS|CMIF_CHILDPOPUP;
+ if (Frames[pos].align&alClient) mi.flags|=CMIF_CHECKED;
+ ModifyMItem((WPARAM)contMIAlignClient,(LPARAM)&mi);
+
+ mi.flags = CMIM_FLAGS|CMIF_CHILDPOPUP;
+ if (Frames[pos].align&alBottom) mi.flags|=CMIF_CHECKED;
+ ModifyMItem((WPARAM)contMIAlignBottom,(LPARAM)&mi);
+
+ mi.flags = CMIM_FLAGS|CMIF_CHILDPOPUP;
+ if (Frames[pos].collapsed) mi.flags|=CMIF_CHECKED;
+ if ((!Frames[pos].visible)||(Frames[pos].Locked)||(pos == CLUIFramesGetalClientFrame())) mi.flags|=CMIF_GRAYED;
+ ModifyMItem((WPARAM)contMIColl,(LPARAM)&mi);
+ }
+ ulockfrm();
+ return 0;
+}
+
+INT_PTR CLUIFramesModifyMainMenuItems(WPARAM wParam,LPARAM lParam)
+{
+ lockfrm();
+
+ int pos = id2pos(wParam);
+ if (pos >= 0 && pos < nFramescount) {
+ CLISTMENUITEM mi = { 0 };
+ mi.cbSize = sizeof(mi);
+ mi.flags = CMIM_NAME|CMIF_CHILDPOPUP|CMIF_TCHAR;
+ mi.ptszName = Frames[pos].TitleBar.tbname ? Frames[pos].TitleBar.tbname : Frames[pos].name;
+ CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)Frames[pos].MenuHandles.MITitle,(LPARAM)&mi);
+
+ mi.flags = CMIM_FLAGS|CMIF_CHILDPOPUP;
+ if (Frames[pos].visible) mi.flags|=CMIF_CHECKED;
+ CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)Frames[pos].MenuHandles.MIVisible,(LPARAM)&mi);
+
+ mi.flags = CMIM_FLAGS|CMIF_CHILDPOPUP;
+ if (Frames[pos].Locked) mi.flags|=CMIF_CHECKED;
+ CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)Frames[pos].MenuHandles.MILock,(LPARAM)&mi);
+
+ mi.flags = CMIM_FLAGS|CMIF_CHILDPOPUP;
+ if (Frames[pos].TitleBar.ShowTitleBar) mi.flags|=CMIF_CHECKED;
+ CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)Frames[pos].MenuHandles.MITBVisible,(LPARAM)&mi);
+
+ mi.flags = CMIM_FLAGS|CMIF_CHILDPOPUP;
+ if (Frames[pos].floating) mi.flags|=CMIF_CHECKED;
+ CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)Frames[pos].MenuHandles.MIFloating,(LPARAM)&mi);
+
+ mi.flags = CMIM_FLAGS|CMIF_CHILDPOPUP;
+ if ((Frames[pos].UseBorder)) mi.flags|=CMIF_CHECKED;
+ CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)Frames[pos].MenuHandles.MIBorder,(LPARAM)&mi);
+
+ mi.flags = CMIM_FLAGS|CMIF_CHILDPOPUP|((Frames[pos].align&alClient)?CMIF_GRAYED:0);
+ if (Frames[pos].align&alTop) mi.flags|=CMIF_CHECKED;
+ CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)Frames[pos].MenuHandles.MIAlignTop,(LPARAM)&mi);
+
+ mi.flags = CMIM_FLAGS|CMIF_CHILDPOPUP;
+ if (Frames[pos].align&alClient) mi.flags|=CMIF_CHECKED;
+ CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)Frames[pos].MenuHandles.MIAlignClient,(LPARAM)&mi);
+
+ mi.flags = CMIM_FLAGS|CMIF_CHILDPOPUP|((Frames[pos].align&alClient)?CMIF_GRAYED:0);
+ if (Frames[pos].align&alBottom) mi.flags|=CMIF_CHECKED;
+ CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)Frames[pos].MenuHandles.MIAlignBottom,(LPARAM)&mi);
+
+ mi.flags = CMIM_FLAGS|CMIF_CHILDPOPUP;
+ if (Frames[pos].collapsed) mi.flags|=CMIF_CHECKED;
+ if ((!Frames[pos].visible)||Frames[pos].Locked||(pos == CLUIFramesGetalClientFrame())) mi.flags|=CMIF_GRAYED;
+ CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)Frames[pos].MenuHandles.MIColl,(LPARAM)&mi);
+ }
+ ulockfrm();
+ return 0;
+}
+
+//hiword(wParam) = frameid,loword(wParam) = flag
+INT_PTR CLUIFramesGetFrameOptions(WPARAM wParam,LPARAM lParam)
+{
+ if (FramesSysNotStarted) return 0;
+
+ lockfrm();
+ int pos = id2pos(HIWORD(wParam));
+ if (pos < 0 || pos >= nFramescount) {
+ ulockfrm();
+ return -1;
+ }
+
+ INT_PTR retval;
+
+ switch(LOWORD(wParam)) {
+ case FO_FLAGS:
+ retval = 0;
+ if (Frames[pos].visible) retval|=F_VISIBLE;
+ if (!Frames[pos].collapsed) retval|=F_UNCOLLAPSED;
+ if (Frames[pos].Locked) retval|=F_LOCKED;
+ if (Frames[pos].TitleBar.ShowTitleBar) retval|=F_SHOWTB;
+ if (Frames[pos].TitleBar.ShowTitleBarTip) retval|=F_SHOWTBTIP;
+ if (!(GetWindowLongPtr(Frames[pos].hWnd,GWL_STYLE)&WS_BORDER)) retval|=F_NOBORDER;
+ break;
+
+ case FO_NAME:
+ retval = (INT_PTR)Frames[pos].name;
+ break;
+
+ case FO_TBNAME:
+ retval = (INT_PTR)Frames[pos].TitleBar.tbname;
+ break;
+
+ case FO_TBTIPNAME:
+ retval = (INT_PTR)Frames[pos].TitleBar.tooltip;
+ break;
+
+ case FO_TBSTYLE:
+ retval = GetWindowLongPtr(Frames[pos].TitleBar.hwnd,GWL_STYLE);
+ break;
+
+ case FO_TBEXSTYLE:
+ retval = GetWindowLongPtr(Frames[pos].TitleBar.hwnd,GWL_EXSTYLE);
+ break;
+
+ case FO_ICON:
+ retval = (INT_PTR)Frames[pos].TitleBar.hicon;
+ break;
+
+ case FO_HEIGHT:
+ retval = (INT_PTR)Frames[pos].height;
+ break;
+
+ case FO_ALIGN:
+ retval = (INT_PTR)Frames[pos].align;
+ break;
+ case FO_FLOATING:
+ retval = (INT_PTR)Frames[pos].floating;
+ break;
+ default:
+ retval = -1;
+ break;
+ }
+ ulockfrm();
+ return retval;
+}
+
+//hiword(wParam) = frameid,loword(wParam) = flag
+INT_PTR CLUIFramesSetFrameOptions(WPARAM wParam,LPARAM lParam)
+{
+ lockfrm();
+ int pos = id2pos(HIWORD(wParam));
+ if (pos<0||pos>=nFramescount) {
+ ulockfrm();
+ return -1;
+ }
+
+ INT_PTR retval; // value to be returned
+
+ switch(LOWORD(wParam) & ~FO_UNICODETEXT) {
+ case FO_FLAGS:{
+ int flag = lParam;
+ int style;
+
+ Frames[pos].dwFlags = flag;
+ Frames[pos].visible = FALSE;
+ if (flag&F_VISIBLE) Frames[pos].visible = TRUE;
+
+ Frames[pos].collapsed = TRUE;
+ if (flag&F_UNCOLLAPSED) Frames[pos].collapsed = FALSE;
+
+ Frames[pos].Locked = FALSE;
+ if (flag&F_LOCKED) Frames[pos].Locked = TRUE;
+
+ Frames[pos].UseBorder = TRUE;
+ if (flag&F_NOBORDER) Frames[pos].UseBorder = FALSE;
+
+ Frames[pos].TitleBar.ShowTitleBar = FALSE;
+ if (flag&F_SHOWTB) Frames[pos].TitleBar.ShowTitleBar = TRUE;
+
+ Frames[pos].TitleBar.ShowTitleBarTip = FALSE;
+ if (flag&F_SHOWTBTIP) Frames[pos].TitleBar.ShowTitleBarTip = TRUE;
+
+ SendMessage(Frames[pos].TitleBar.hwndTip,TTM_ACTIVATE,(WPARAM)Frames[pos].TitleBar.ShowTitleBarTip,0);
+
+ style = (int)GetWindowLongPtr(Frames[pos].hWnd,GWL_STYLE);
+ style|=WS_BORDER;
+ if (flag&F_NOBORDER) {style &= (~WS_BORDER);}
+ SetWindowLongPtr(Frames[pos].hWnd,GWL_STYLE,(LONG)style);
+ ulockfrm();
+ CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,(LPARAM)0);
+ return 0;
+ }
+
+ case FO_NAME:
+ if (lParam == (LPARAM)NULL) {ulockfrm(); return -1;}
+ mir_free(Frames[pos].name);
+ Frames[pos].name = mir_tstrdup((LPTSTR)lParam);
+ ulockfrm();
+ return 0;
+
+ case FO_TBNAME:
+ if (lParam == (LPARAM)NULL) {ulockfrm(); return(-1);}
+ mir_free(Frames[pos].TitleBar.tbname);
+ Frames[pos].TitleBar.tbname = mir_tstrdup((LPTSTR)lParam);
+ ulockfrm();
+ if (Frames[pos].floating&&(Frames[pos].TitleBar.tbname != NULL)){SetWindowText(Frames[pos].ContainerWnd,Frames[pos].TitleBar.tbname);}
+ return 0;
+
+ case FO_TBTIPNAME:
+ if (lParam == (LPARAM)NULL) {ulockfrm(); return(-1);}
+ mir_free(Frames[pos].TitleBar.tooltip);
+ Frames[pos].TitleBar.tooltip = mir_tstrdup((LPTSTR)lParam);
+ UpdateTBToolTip(pos);
+ ulockfrm();
+ return 0;
+
+ case FO_TBSTYLE:
+ SetWindowLongPtr(Frames[pos].TitleBar.hwnd,GWL_STYLE,lParam);
+ ulockfrm();
+ return 0;
+
+ case FO_TBEXSTYLE:
+ SetWindowLongPtr(Frames[pos].TitleBar.hwnd,GWL_EXSTYLE,lParam);
+ ulockfrm();
+ return 0;
+
+ case FO_ICON:
+ Frames[pos].TitleBar.hicon = (HICON)lParam;
+ ulockfrm();
+ return 0;
+
+ case FO_HEIGHT:
+ if (lParam<0) {ulockfrm(); return -1;}
+ retval = Frames[pos].height;
+ Frames[pos].height = lParam;
+ if (!CLUIFramesFitInSize()) Frames[pos].height = retval;
+ retval = Frames[pos].height;
+ ulockfrm();
+
+ return retval;
+
+ case FO_FLOATING:
+ if (lParam<0) {ulockfrm(); return -1;}
+
+ {
+ int id = Frames[pos].id;
+ Frames[pos].floating = !(lParam);
+ ulockfrm();
+
+ CLUIFrameSetFloat(id,1);//lparam = 1 use stored width and height
+ return wParam;
+ }
+
+ case FO_ALIGN:
+ if ( !(lParam&alTop || lParam&alBottom || lParam&alClient)) {
+ OutputDebugStringA("Wrong align option \r\n");
+ return (-1);
+ }
+
+ if ((lParam&alClient)&&(CLUIFramesGetalClientFrame()>=0)) { //only one alClient frame possible
+ alclientFrame = -1;//recalc it
+ ulockfrm();
+ return -1;
+ }
+ Frames[pos].align = lParam;
+
+ ulockfrm();
+ return 0;
+ }
+ ulockfrm();
+ CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,(LPARAM)0);
+ return -1;
+}
+
+//wparam = lparam = 0
+static INT_PTR CLUIFramesShowAll(WPARAM wParam,LPARAM lParam)
+{
+ for (int i = 0;i<nFramescount;i++)
+ Frames[i].visible = TRUE;
+ CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,(LPARAM)0);
+ return 0;
+}
+
+//wparam = lparam = 0
+INT_PTR CLUIFramesShowAllTitleBars(WPARAM wParam,LPARAM lParam)
+{
+ for (int i = 0;i<nFramescount;i++)
+ Frames[i].TitleBar.ShowTitleBar = TRUE;
+ CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,(LPARAM)0);
+ return 0;
+}
+
+//wparam = lparam = 0
+INT_PTR CLUIFramesHideAllTitleBars(WPARAM wParam,LPARAM lParam)
+{
+ for (int i = 0;i<nFramescount;i++)
+ Frames[i].TitleBar.ShowTitleBar = FALSE;
+ CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,(LPARAM)0);
+ return 0;
+}
+
+//wparam = frameid
+INT_PTR CLUIFramesShowHideFrame(WPARAM wParam,LPARAM lParam)
+{
+ lockfrm();
+ int pos = id2pos(wParam);
+ if ( pos >= 0 && (int)pos < nFramescount)
+ Frames[pos].visible = !Frames[pos].visible;
+ if (Frames[pos].floating)
+ CLUIFrameResizeFloatingFrame(pos);
+ ulockfrm();
+
+ if (!Frames[pos].floating)
+ CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,(LPARAM)0);
+ return 0;
+}
+
+//wparam = frameid
+INT_PTR CLUIFramesShowHideFrameTitleBar(WPARAM wParam,LPARAM lParam)
+{
+ lockfrm();
+ int pos = id2pos(wParam);
+ if ( pos >= 0 && (int)pos < nFramescount)
+ Frames[pos].TitleBar.ShowTitleBar = !Frames[pos].TitleBar.ShowTitleBar;
+
+ ulockfrm();
+
+ CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,(LPARAM)0);
+ return 0;
+}
+
+//wparam = frameid
+//lparam = -1 up ,1 down
+INT_PTR CLUIFramesMoveUpDown(WPARAM wParam,LPARAM lParam)
+{
+ int pos,i,curpos,curalign,v,tmpval;
+
+ lockfrm();
+ pos = id2pos(wParam);
+ if (pos>=0&&(int)pos<nFramescount) {
+ SortData *sd;
+ curpos = Frames[pos].order;
+ curalign = Frames[pos].align;
+ v = 0;
+ sd = (SortData*)malloc(sizeof(SortData)*nFramescount);
+ memset(sd,0,sizeof(SortData)*nFramescount);
+ for (i = 0;i<nFramescount;i++) {
+ if (Frames[i].floating||(!Frames[i].visible)||(Frames[i].align != curalign))
+ continue;
+
+ sd[v].order = Frames[i].order;
+ sd[v].realpos = i;
+ v++;
+ }
+ if (v == 0) {
+ ulockfrm();
+ return 0;
+ }
+ qsort(sd,v,sizeof(SortData),sortfunc);
+ for (i = 0;i<v;i++) {
+ if (sd[i].realpos == pos) {
+ if (lParam == -1) {
+ if (i >= v-1)
+ break;
+
+ tmpval = Frames[sd[i+1].realpos].order;
+ Frames[sd[i+1].realpos].order = Frames[pos].order;
+ Frames[pos].order = tmpval;
+ break;
+ }
+ if (lParam == +1) {
+ if (i < 1)
+ break;
+
+ tmpval = Frames[sd[i-1].realpos].order;
+ Frames[sd[i-1].realpos].order = Frames[pos].order;
+ Frames[pos].order = tmpval;
+ break;
+ }
+ }
+ }
+
+ if (sd != NULL)
+ free(sd);
+ CLUIFramesStoreFrameSettings(pos);
+ CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,0);
+ }
+ ulockfrm();
+ return 0;
+}
+
+//wparam = frameid
+//lparam = alignment
+INT_PTR CLUIFramesSetAlign(WPARAM wParam,LPARAM lParam)
+{
+ CLUIFramesSetFrameOptions(MAKEWPARAM(FO_ALIGN,wParam),lParam);
+ CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,0);
+ return 0;
+}
+
+INT_PTR CLUIFramesSetAlignalTop(WPARAM wParam,LPARAM lParam)
+{
+ return CLUIFramesSetAlign(wParam,alTop);
+}
+
+INT_PTR CLUIFramesSetAlignalBottom(WPARAM wParam,LPARAM lParam)
+{
+ return CLUIFramesSetAlign(wParam,alBottom);
+}
+
+INT_PTR CLUIFramesSetAlignalClient(WPARAM wParam,LPARAM lParam)
+{
+ return CLUIFramesSetAlign(wParam,alClient);
+}
+
+//wparam = frameid
+INT_PTR CLUIFramesLockUnlockFrame(WPARAM wParam,LPARAM lParam)
+{
+ lockfrm();
+ int pos = id2pos(wParam);
+ if (pos >= 0 && (int)pos < nFramescount) {
+ Frames[pos].Locked = !Frames[pos].Locked;
+ CLUIFramesStoreFrameSettings(pos);
+ }
+ ulockfrm();
+ return 0;
+}
+
+//wparam = frameid
+INT_PTR CLUIFramesSetUnSetBorder(WPARAM wParam,LPARAM lParam)
+{
+ int oldflags;
+
+ lockfrm();
+ int FrameId = id2pos(wParam);
+ if (FrameId == -1) {
+ ulockfrm();
+ return -1;
+ }
+
+ boolean flt = oldflags = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS,MAKEWPARAM(FO_FLAGS,wParam),0);
+ if (oldflags & F_NOBORDER)
+ oldflags &= (~F_NOBORDER);
+ else
+ oldflags |= F_NOBORDER;
+
+ HWND hw = Frames[FrameId].hWnd;
+ RECT rc;
+ GetWindowRect(hw, &rc);
+
+ ulockfrm();
+ CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_FLAGS,wParam),oldflags);
+
+ SetWindowPos(hw,0,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_DRAWFRAME);
+ return 0;
+}
+
+//wparam = frameid
+INT_PTR CLUIFramesCollapseUnCollapseFrame(WPARAM wParam,LPARAM lParam)
+{
+ int FrameId;
+
+ lockfrm();
+ FrameId = id2pos(wParam);
+ if (FrameId >= 0 && FrameId < nFramescount) {
+ int oldHeight;
+
+ // do not collapse/uncollapse client/locked/invisible frames
+ if (Frames[FrameId].align == alClient&&!(Frames[FrameId].Locked||(!Frames[FrameId].visible)||Frames[FrameId].floating)) {
+ RECT rc;
+ if (CallService(MS_CLIST_DOCKINGISDOCKED,0,0)) {
+ ulockfrm();
+ return 0;
+ }
+ if (DBGetContactSettingByte(NULL,"CLUI","AutoSize",0)) {
+ ulockfrm();
+ return 0;
+ }
+
+ GetWindowRect(pcli->hwndContactList, &rc);
+
+ if (Frames[FrameId].collapsed == TRUE) {
+ rc.bottom -= rc.top;
+ rc.bottom -= Frames[FrameId].height;
+ Frames[FrameId].HeightWhenCollapsed = Frames[FrameId].height;
+ Frames[FrameId].collapsed = FALSE;
+ }
+ else {
+ rc.bottom -= rc.top;
+ rc.bottom += Frames[FrameId].HeightWhenCollapsed;
+ Frames[FrameId].collapsed = TRUE;
+ }
+
+ SetWindowPos(pcli->hwndContactList,NULL,0,0,rc.right-rc.left,rc.bottom,SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE);
+
+ CLUIFramesStoreAllFrames();
+ ulockfrm();
+ return 0;
+ }
+
+ if (Frames[FrameId].Locked||(!Frames[FrameId].visible))
+ return 0;
+
+ oldHeight = Frames[FrameId].height;
+
+ // if collapsed, uncollapse
+ if (Frames[FrameId].collapsed == TRUE) {
+ Frames[FrameId].HeightWhenCollapsed = Frames[FrameId].height;
+ Frames[FrameId].height = UNCOLLAPSED_FRAME_SIZE;
+ Frames[FrameId].collapsed = FALSE;
+ }
+ // if uncollapsed, collapse
+ else {
+ Frames[FrameId].height = Frames[FrameId].HeightWhenCollapsed;
+ Frames[FrameId].collapsed = TRUE;
+ }
+
+ if (!Frames[FrameId].floating) {
+ if (!CLUIFramesFitInSize()) {
+ //cant collapse,we can resize only for height<alclient frame height
+ int alfrm = CLUIFramesGetalClientFrame();
+
+ if (alfrm != -1) {
+ Frames[FrameId].collapsed = FALSE;
+ if (Frames[alfrm].height>2*UNCOLLAPSED_FRAME_SIZE) {
+ oldHeight = Frames[alfrm].height-UNCOLLAPSED_FRAME_SIZE;
+ Frames[FrameId].collapsed = TRUE;
+ }
+ }
+ else {
+ int i,sumheight = 0;
+ for (i = 0; i < nFramescount; i++) {
+ if ((Frames[i].align != alClient)&&(!Frames[i].floating)&&(Frames[i].visible)&&(!Frames[i].needhide)) {
+ sumheight += (Frames[i].height)+(TitleBarH*btoint(Frames[i].TitleBar.ShowTitleBar))+2;
+ return FALSE;
+ }
+
+ if (sumheight>ContactListHeight-0-2)
+ Frames[FrameId].height = (ContactListHeight-0-2)-sumheight;
+ }
+ }
+
+ Frames[FrameId].height = oldHeight;
+
+ if (Frames[FrameId].collapsed == FALSE) {
+ if (Frames[FrameId].floating)
+ SetWindowPos(Frames[FrameId].ContainerWnd,HWND_TOP,0,0,Frames[FrameId].wndSize.right-Frames[FrameId].wndSize.left+6,Frames[FrameId].height+DEFAULT_TITLEBAR_HEIGHT+4,SWP_SHOWWINDOW|SWP_NOMOVE);
+
+ ulockfrm();
+ return -1;
+ }
+ }
+ }
+
+ ulockfrm();
+
+ if (!Frames[FrameId].floating)
+ CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,0);
+ else {
+ //SetWindowPos(Frames[FrameId].hWnd,HWND_TOP,0,0,Frames[FrameId].wndSize.right-Frames[FrameId].wndSize.left,Frames[FrameId].height,SWP_SHOWWINDOW|SWP_NOMOVE);
+ RECT contwnd;
+ GetWindowRect(Frames[FrameId].ContainerWnd,&contwnd);
+ contwnd.top = contwnd.bottom-contwnd.top;//height
+ contwnd.left = contwnd.right-contwnd.left;//width
+
+ contwnd.top -= (oldHeight-Frames[FrameId].height);//newheight
+ SetWindowPos(Frames[FrameId].ContainerWnd,HWND_TOP,0,0,contwnd.left,contwnd.top,SWP_SHOWWINDOW|SWP_NOMOVE);
+ }
+ CLUIFramesStoreAllFrames();
+ return 0;
+ }
+ else return -1;
+
+ ulockfrm();
+ return 0;
+}
+
+static int CLUIFramesLoadMainMenu()
+{
+ CLISTMENUITEM mi;
+ int i,separator;
+
+ if ( !(ServiceExists(MS_CLIST_REMOVEMAINMENUITEM))) {
+ //hmm new menu system not used..so display only two items and warning message
+ ZeroMemory(&mi,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ // create "show all frames" menu
+ mi.hIcon = NULL;//LoadIcon(g_hInst,MAKEINTRESOURCE(IDI_MIRANDA));
+ mi.flags = CMIF_GRAYED;
+ mi.position = 10000000;
+ mi.pszPopupName = LPGEN("Frames");
+ mi.pszName = LPGEN("New Menu System not Found...");
+ mi.pszService = "";
+ CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&mi);
+
+ // create "show all frames" menu
+ mi.hIcon = NULL;//LoadIcon(g_hInst,MAKEINTRESOURCE(IDI_MIRANDA));
+ mi.flags = 0;
+ mi.position = 10100000;
+ mi.pszPopupName = LPGEN("Frames");
+ mi.pszName = LPGEN("Show All Frames");
+ mi.pszService = MS_CLIST_FRAMES_SHOWALLFRAMES;
+ CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&mi);
+
+ mi.hIcon = NULL;//LoadIcon(g_hInst,MAKEINTRESOURCE(IDI_HELP));
+ mi.position = 10100001;
+ mi.pszPopupName = LPGEN("Frames");
+ mi.flags = CMIF_CHILDPOPUP;
+ mi.pszName = LPGEN("Show All Titlebars");
+ mi.pszService = MS_CLIST_FRAMES_SHOWALLFRAMESTB;
+ CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&mi);
+ return 0;
+ }
+
+ if (MainMIRoot != (HGENMENU)-1) {
+ CallService(MS_CLIST_REMOVEMAINMENUITEM,(WPARAM)MainMIRoot,0);
+ MainMIRoot = (HGENMENU)-1;
+ }
+
+ ZeroMemory(&mi,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+
+ // create root menu
+ mi.hIcon = LoadIcon(g_hInst,MAKEINTRESOURCE(IDI_CLIENTMIRANDA));
+ mi.flags = CMIF_ROOTPOPUP;
+ mi.position = 3000090000;
+ mi.pszPopupName = (char*)-1;
+ mi.pszName = LPGEN("Frames");
+ mi.pszService = 0;
+ MainMIRoot = (HGENMENU)CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&mi);
+
+ // create frames menu
+ separator = 3000200000;
+ for (i = 0;i<nFramescount;i++) {
+ mi.hIcon = Frames[i].TitleBar.hicon;
+ mi.flags = CMIF_CHILDPOPUP|CMIF_ROOTPOPUP|CMIF_TCHAR;
+ mi.position = separator;
+ mi.hParentMenu = MainMIRoot;
+ mi.ptszName = Frames[i].TitleBar.tbname ? Frames[i].TitleBar.tbname : Frames[i].name;
+ mi.pszService = 0;
+ Frames[i].MenuHandles.MainMenuItem = (HANDLE)CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&mi);
+ CLUIFramesCreateMenuForFrame(Frames[i].id,(int)Frames[i].MenuHandles.MainMenuItem,separator,MS_CLIST_ADDMAINMENUITEM);
+ CLUIFramesModifyMainMenuItems(Frames[i].id,0);
+ //NotifyEventHooks(hPreBuildFrameMenuEvent,i,(LPARAM)Frames[i].MenuHandles.MainMenuItem);
+ CallService(MS_CLIST_FRAMEMENUNOTIFY,(WPARAM)Frames[i].id,(LPARAM)Frames[i].MenuHandles.MainMenuItem);
+ separator++;
+ }
+
+ separator += 100000;
+
+ // create "show all frames" menu
+ mi.hIcon = NULL;
+ mi.flags = CMIF_CHILDPOPUP;
+ mi.position = separator++;
+ mi.hParentMenu = MainMIRoot;
+ mi.pszName = LPGEN("Show All Frames");
+ mi.pszService = MS_CLIST_FRAMES_SHOWALLFRAMES;
+ CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&mi);
+
+ // create "show all titlebars" menu
+ mi.hIcon = NULL;
+ mi.position = separator++;
+ mi.hParentMenu = MainMIRoot;
+ mi.flags = CMIF_CHILDPOPUP;
+ mi.pszName = LPGEN("Show All Titlebars");
+ mi.pszService = MS_CLIST_FRAMES_SHOWALLFRAMESTB;
+ CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&mi);
+
+ // create "hide all titlebars" menu
+ mi.hIcon = NULL;
+ mi.position = separator++;
+ mi.hParentMenu = MainMIRoot;
+ mi.flags = CMIF_CHILDPOPUP;
+ mi.pszName = LPGEN("Hide All Titlebars");
+ mi.pszService = MS_CLIST_FRAMES_HIDEALLFRAMESTB;
+ CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&mi);
+ return 0;
+}
+
+static HFONT CLUILoadTitleBarFont()
+{
+ char facename[] = "MS Shell Dlg";
+ HFONT hfont;
+ LOGFONT logfont;
+ memset(&logfont,0,sizeof(logfont));
+ memcpy(logfont.lfFaceName,facename,sizeof(facename));
+ logfont.lfWeight = FW_NORMAL;
+ logfont.lfHeight = -10;
+ hfont = CreateFontIndirect(&logfont);
+ return hfont;
+}
+
+static int UpdateTBToolTip(int framepos)
+{
+ TOOLINFO ti = { 0 };
+ ti.cbSize = sizeof(ti);
+ ti.lpszText = Frames[framepos].TitleBar.tooltip;
+ ti.hinst = g_hInst;
+ ti.uFlags = TTF_IDISHWND|TTF_SUBCLASS ;
+ ti.uId = (UINT_PTR)Frames[framepos].TitleBar.hwnd;
+
+ return SendMessage(Frames[framepos].TitleBar.hwndTip, TTM_UPDATETIPTEXT, 0, (LPARAM)&ti);
+}
+
+//wparam = (CLISTFrame*)clfrm
+INT_PTR CLUIFramesAddFrame(WPARAM wParam,LPARAM lParam)
+{
+ int style,retval;
+ CLISTFrame *clfrm = (CLISTFrame *)wParam;
+
+ if (pcli->hwndContactList == 0) return -1;
+ if (FramesSysNotStarted) return -1;
+ if (clfrm->cbSize != sizeof(CLISTFrame)) return -1;
+ if (!(TitleBarFont)) TitleBarFont = CLUILoadTitleBarFont();
+
+ lockfrm();
+ if (nFramescount>=MAX_FRAMES) { ulockfrm(); return -1;}
+ Frames = (wndFrame*)realloc(Frames,sizeof(wndFrame)*(nFramescount+1));
+
+ memset(&Frames[nFramescount],0,sizeof(wndFrame));
+ Frames[nFramescount].id = NextFrameId++;
+ Frames[nFramescount].align = clfrm->align;
+ Frames[nFramescount].hWnd = clfrm->hWnd;
+ Frames[nFramescount].height = clfrm->height;
+ Frames[nFramescount].TitleBar.hicon = clfrm->hIcon;
+ Frames[nFramescount].TitleBar.BackColour;
+ Frames[nFramescount].floating = FALSE;
+
+ //override tbbtip
+ //clfrm->Flags|=F_SHOWTBTIP;
+ //
+ if (DBGetContactSettingByte(0,CLUIFrameModule,"RemoveAllBorders",0) == 1)
+ clfrm->Flags|=F_NOBORDER;
+
+ Frames[nFramescount].dwFlags = clfrm->Flags;
+
+ if (clfrm->name == NULL||((clfrm->Flags&F_UNICODE) ? lstrlenW(clfrm->wname) : lstrlenA(clfrm->name)) == 0) {
+ Frames[nFramescount].name = (LPTSTR)malloc(255 * sizeof(TCHAR));
+ GetClassName(Frames[nFramescount].hWnd,Frames[nFramescount].name,255);
+ }
+ else Frames[nFramescount].name = (clfrm->Flags&F_UNICODE) ? mir_u2t(clfrm->wname) : mir_a2t(clfrm->name);
+
+ if (IsBadCodePtr((FARPROC)clfrm->TBname) || clfrm->TBname == NULL
+ || ((clfrm->Flags&F_UNICODE) ? lstrlenW(clfrm->TBwname) : lstrlenA(clfrm->TBname)) == 0)
+ Frames[nFramescount].TitleBar.tbname = mir_tstrdup(Frames[nFramescount].name);
+ else
+ Frames[nFramescount].TitleBar.tbname = (clfrm->Flags&F_UNICODE) ? mir_u2t(clfrm->TBwname) : mir_a2t(clfrm->TBname);
+ Frames[nFramescount].needhide = FALSE;
+ Frames[nFramescount].TitleBar.ShowTitleBar = (clfrm->Flags&F_SHOWTB?TRUE:FALSE);
+ Frames[nFramescount].TitleBar.ShowTitleBarTip = (clfrm->Flags&F_SHOWTBTIP?TRUE:FALSE);
+
+ Frames[nFramescount].collapsed = clfrm->Flags & F_UNCOLLAPSED ? FALSE:TRUE;
+ Frames[nFramescount].Locked = clfrm->Flags & F_LOCKED ? TRUE : FALSE;
+ Frames[nFramescount].visible = clfrm->Flags & F_VISIBLE ? TRUE : FALSE;
+
+ Frames[nFramescount].UseBorder = (clfrm->Flags&F_NOBORDER)?FALSE:TRUE;
+
+ // create frame
+ Frames[nFramescount].TitleBar.hwnd = CreateWindow(CLUIFrameTitleBarClassName,Frames[nFramescount].name,
+ (DBGetContactSettingByte(0,CLUIFrameModule,"RemoveAllTitleBarBorders",0)?0:WS_BORDER) |WS_CHILD|WS_CLIPCHILDREN|
+ (Frames[nFramescount].TitleBar.ShowTitleBar?WS_VISIBLE:0)| WS_CLIPCHILDREN,
+ 0,0,0,0,pcli->hwndContactList,NULL,g_hInst,NULL);
+ SetWindowLongPtr(Frames[nFramescount].TitleBar.hwnd,GWLP_USERDATA,Frames[nFramescount].id);
+
+ Frames[nFramescount].TitleBar.hwndTip = CreateWindowEx(0, TOOLTIPS_CLASS, NULL,
+ WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
+ CW_USEDEFAULT, CW_USEDEFAULT,
+ CW_USEDEFAULT, CW_USEDEFAULT,
+ pcli->hwndContactList, NULL, g_hInst, NULL);
+
+ SetWindowPos(Frames[nFramescount].TitleBar.hwndTip, HWND_TOPMOST,0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+
+ TOOLINFO ti = { 0 };
+ ti.cbSize = sizeof(ti);
+ ti.lpszText = _T("");
+ ti.hinst = g_hInst;
+ ti.uFlags = TTF_IDISHWND|TTF_SUBCLASS ;
+ ti.uId = (UINT_PTR)Frames[nFramescount].TitleBar.hwnd;
+ SendMessage(Frames[nFramescount].TitleBar.hwndTip,TTM_ADDTOOL,(WPARAM)0,(LPARAM)&ti);
+
+ SendMessage(Frames[nFramescount].TitleBar.hwndTip,TTM_ACTIVATE,(WPARAM)Frames[nFramescount].TitleBar.ShowTitleBarTip,0);
+
+ Frames[nFramescount].oldstyles = GetWindowLongPtr(Frames[nFramescount].hWnd,GWL_STYLE);
+ Frames[nFramescount].TitleBar.oldstyles = GetWindowLongPtr(Frames[nFramescount].TitleBar.hwnd,GWL_STYLE);
+ //Frames[nFramescount].FloatingPos.x =
+
+ retval = Frames[nFramescount].id;
+ Frames[nFramescount].order = nFramescount+1;
+ nFramescount++;
+
+ CLUIFramesLoadFrameSettings(id2pos(retval));
+ style = GetWindowLongPtr(Frames[nFramescount-1].hWnd,GWL_STYLE);
+ style &= (~WS_BORDER);
+ style|=((Frames[nFramescount-1].UseBorder)?WS_BORDER:0);
+ SetWindowLongPtr(Frames[nFramescount-1].hWnd,GWL_STYLE,style);
+
+ if (Frames[nFramescount-1].order == 0){Frames[nFramescount-1].order = nFramescount;}
+ ulockfrm();
+
+ alclientFrame = -1;//recalc it
+ CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,0);
+
+ if (Frames[nFramescount-1].floating) {
+ Frames[nFramescount-1].floating = FALSE;
+ CLUIFrameSetFloat(retval,1);//lparam = 1 use stored width and height
+ }
+
+ return retval;
+}
+
+static INT_PTR CLUIFramesRemoveFrame(WPARAM wParam,LPARAM lParam)
+{
+ if (FramesSysNotStarted)
+ return -1;
+
+ lockfrm();
+ int pos = id2pos(wParam);
+
+ if (pos<0||pos>nFramescount){ulockfrm();return(-1);}
+
+ mir_free(Frames[pos].name);
+ mir_free(Frames[pos].TitleBar.tbname);
+ mir_free(Frames[pos].TitleBar.tooltip);
+
+ DestroyWindow(Frames[pos].hWnd);
+ Frames[pos].hWnd = (HWND)-1;
+ DestroyWindow(Frames[pos].TitleBar.hwnd);
+ Frames[pos].TitleBar.hwnd = (HWND)-1;
+ DestroyWindow(Frames[pos].ContainerWnd);
+ Frames[pos].ContainerWnd = (HWND)-1;
+ DestroyMenu(Frames[pos].TitleBar.hmenu);
+
+ RemoveItemFromList(pos,&Frames,&nFramescount);
+
+ ulockfrm();
+ InvalidateRect(pcli->hwndContactList,NULL,TRUE);
+ CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,0);
+ InvalidateRect(pcli->hwndContactList,NULL,TRUE);
+
+ return 0;
+}
+
+
+int CLUIFramesForceUpdateTB(const wndFrame *Frame)
+{
+ if (Frame->TitleBar.hwnd != 0)
+ RedrawWindow(Frame->TitleBar.hwnd,NULL,NULL,RDW_ALLCHILDREN|RDW_UPDATENOW|RDW_ERASE|RDW_INVALIDATE|RDW_FRAME);
+ return 0;
+}
+
+int CLUIFramesForceUpdateFrame(const wndFrame *Frame)
+{
+ if (Frame->hWnd != 0) {
+ RedrawWindow(Frame->hWnd,NULL,NULL,RDW_UPDATENOW|RDW_FRAME|RDW_ERASE|RDW_INVALIDATE);
+ UpdateWindow(Frame->hWnd);
+ }
+ if (Frame->floating) {
+ if (Frame->ContainerWnd != 0)
+ RedrawWindow(Frame->ContainerWnd,NULL,NULL,RDW_UPDATENOW|RDW_ALLCHILDREN|RDW_ERASE|RDW_INVALIDATE|RDW_FRAME);
+ }
+ return 0;
+}
+
+int CLUIFrameMoveResize(const wndFrame *Frame)
+{
+ //int b;
+ // we need to show or hide the frame?
+ if (Frame->visible&&(!Frame->needhide)) {
+ ShowWindow(Frame->hWnd,SW_SHOW);
+ ShowWindow(Frame->TitleBar.hwnd,Frame->TitleBar.ShowTitleBar == TRUE?SW_SHOW:SW_HIDE);
+ }
+ else {
+ ShowWindow(Frame->hWnd,SW_HIDE);
+ ShowWindow(Frame->TitleBar.hwnd,SW_HIDE);
+ return 0;
+ }
+
+ // set frame position
+ SetWindowPos(Frame->hWnd,NULL,Frame->wndSize.left,Frame->wndSize.top,
+ Frame->wndSize.right-Frame->wndSize.left,
+ Frame->wndSize.bottom-Frame->wndSize.top,SWP_NOZORDER|SWP_NOREDRAW);
+
+ // set titlebar position
+ if (Frame->TitleBar.ShowTitleBar)
+ SetWindowPos(Frame->TitleBar.hwnd,NULL,Frame->wndSize.left,Frame->wndSize.top-TitleBarH-GapBetweenTitlebar,
+ Frame->wndSize.right-Frame->wndSize.left,
+ TitleBarH,SWP_NOZORDER|SWP_NOREDRAW );
+
+ return 0;
+}
+
+BOOLEAN CLUIFramesFitInSize(void)
+{
+ int sumheight = 0;
+ int tbh = 0; // title bar height
+
+ int clientfrm = CLUIFramesGetalClientFrame();
+ if (clientfrm != -1)
+ tbh = TitleBarH*btoint(Frames[clientfrm].TitleBar.ShowTitleBar);
+
+ for (int i = 0;i<nFramescount;i++) {
+ if ((Frames[i].align != alClient)&&(!Frames[i].floating)&&(Frames[i].visible)&&(!Frames[i].needhide)) {
+ sumheight += (Frames[i].height)+(TitleBarH*btoint(Frames[i].TitleBar.ShowTitleBar))+2;
+ if (sumheight>ContactListHeight-tbh-2)
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+int CLUIFramesGetMinHeight()
+{
+ int i,tbh,clientfrm,sumheight = 0;
+ RECT border;
+ int allbord = 0;
+ if (pcli->hwndContactList == NULL) return 0;
+ lockfrm();
+
+ // search for alClient frame and get the titlebar's height
+ tbh = 0;
+ clientfrm = CLUIFramesGetalClientFrame();
+ if (clientfrm != -1)
+ tbh = TitleBarH*btoint(Frames[clientfrm].TitleBar.ShowTitleBar);
+
+ for (i = 0; i < nFramescount; i++) {
+ if ((Frames[i].align != alClient)&&(Frames[i].visible)&&(!Frames[i].needhide)&&(!Frames[i].floating)) {
+ RECT wsize;
+
+ GetWindowRect(Frames[i].hWnd,&wsize);
+ sumheight += (wsize.bottom-wsize.top)+(TitleBarH*btoint(Frames[i].TitleBar.ShowTitleBar))+3;
+ }
+ }
+ ulockfrm();
+ GetBorderSize(pcli->hwndContactList,&border);
+ return (sumheight+border.top+border.bottom+allbord+tbh+3);
+}
+
+int CLUIFramesResize(const RECT newsize)
+{
+ int sumheight = 9999999,newheight;
+ int prevframe,prevframebottomline;
+ int tbh,curfrmtbh;
+ int drawitems;
+ int clientfrm;
+ int i,j;
+ int sepw = GapBetweenFrames;
+ SortData *sdarray;
+
+ GapBetweenTitlebar = (int)DBGetContactSettingDword(NULL,"CLUIFrames","GapBetweenTitleBar",1);
+ GapBetweenFrames = DBGetContactSettingDword(NULL,"CLUIFrames","GapBetweenFrames",1);
+ TitleBarH = DBGetContactSettingDword(NULL,"CLUIFrames","TitleBarH",DEFAULT_TITLEBAR_HEIGHT);
+
+ sepw = GapBetweenFrames;
+ if (nFramescount < 1)
+ return 0;
+
+ newheight = newsize.bottom-newsize.top;
+
+ // search for alClient frame and get the titlebar's height
+ tbh = 0;
+ clientfrm = CLUIFramesGetalClientFrame();
+ if (clientfrm != -1)
+ tbh = (TitleBarH+GapBetweenTitlebar)*btoint(Frames[clientfrm].TitleBar.ShowTitleBar);
+
+ for (i = 0; i < nFramescount; i++) {
+ if (!Frames[i].floating) {
+ Frames[i].needhide = FALSE;
+ Frames[i].wndSize.left = 0;
+ Frames[i].wndSize.right = newsize.right-0;
+ }
+ }
+
+ //sorting stuff
+ sdarray = (SortData*)malloc(sizeof(SortData)*nFramescount);
+ if (sdarray == NULL){return(-1);}
+ for (i = 0;i<nFramescount;i++) {
+ sdarray[i].order = Frames[i].order;
+ sdarray[i].realpos = i;
+ }
+ qsort(sdarray,nFramescount,sizeof(SortData),sortfunc);
+
+ drawitems = nFramescount;
+
+ while(sumheight>(newheight-tbh)&&drawitems>0) {
+ sumheight = 0;
+ drawitems = 0;
+ for (i = 0;i<nFramescount;i++) {
+ if (((Frames[i].align != alClient))&&(!Frames[i].floating)&&(Frames[i].visible)&&(!Frames[i].needhide)) {
+ drawitems++;
+ curfrmtbh = (TitleBarH+GapBetweenTitlebar)*btoint(Frames[i].TitleBar.ShowTitleBar);
+ sumheight += (Frames[i].height)+curfrmtbh+sepw+(Frames[i].UseBorder?2:0);
+ if (sumheight>newheight-tbh) {
+ sumheight -= (Frames[i].height)+curfrmtbh+sepw;
+ Frames[i].needhide = TRUE;
+ drawitems--;
+ break;
+ }
+ }
+ }
+ }
+
+ prevframe = -1;
+ prevframebottomline = 0;
+ for (j = 0;j<nFramescount;j++) {
+ //move all alTop frames
+ i = sdarray[j].realpos;
+ if ((!Frames[i].needhide)&&(!Frames[i].floating)&&(Frames[i].visible)&&(Frames[i].align == alTop)) {
+ curfrmtbh = (TitleBarH+GapBetweenTitlebar)*btoint(Frames[i].TitleBar.ShowTitleBar);
+ Frames[i].wndSize.top = prevframebottomline+sepw+(curfrmtbh);
+ Frames[i].wndSize.bottom = Frames[i].height+Frames[i].wndSize.top+(Frames[i].UseBorder?2:0);
+ Frames[i].prevvisframe = prevframe;
+ prevframe = i;
+ prevframebottomline = Frames[i].wndSize.bottom;
+ if (prevframebottomline>newheight){
+ //prevframebottomline -= Frames[i].height+(curfrmtbh+1);
+ //Frames[i].needhide = TRUE;
+ }
+ }
+ }
+
+ if (sumheight<newheight) {
+ for (j = 0;j<nFramescount;j++) {
+ //move alClient frame
+ i = sdarray[j].realpos;
+ if ((!Frames[i].needhide)&&(!Frames[i].floating)&&(Frames[i].visible)&&(Frames[i].align == alClient)) {
+ int oldh;
+ Frames[i].wndSize.top = prevframebottomline+sepw+(tbh);
+ Frames[i].wndSize.bottom = Frames[i].wndSize.top+newheight-sumheight-tbh-sepw;
+
+ oldh = Frames[i].height;
+ Frames[i].height = Frames[i].wndSize.bottom-Frames[i].wndSize.top;
+ Frames[i].prevvisframe = prevframe;
+ prevframe = i;
+ prevframebottomline = Frames[i].wndSize.bottom;
+ if (prevframebottomline>newheight) {
+ //prevframebottomline -= Frames[i].height+(tbh+1);
+ //Frames[i].needhide = TRUE;
+ }
+ break;
+ }
+ }
+ }
+
+ //newheight
+ prevframebottomline = newheight+sepw;
+ //prevframe = -1;
+ for (j = nFramescount-1;j>=0;j--) {
+ //move all alBottom frames
+ i = sdarray[j].realpos;
+ if ((Frames[i].visible)&&(!Frames[i].floating)&&(!Frames[i].needhide)&&(Frames[i].align == alBottom)) {
+ curfrmtbh = (TitleBarH+GapBetweenTitlebar)*btoint(Frames[i].TitleBar.ShowTitleBar);
+
+ Frames[i].wndSize.bottom = prevframebottomline-sepw;
+ Frames[i].wndSize.top = Frames[i].wndSize.bottom-Frames[i].height-(Frames[i].UseBorder?2:0);
+ Frames[i].prevvisframe = prevframe;
+ prevframe = i;
+ prevframebottomline = Frames[i].wndSize.top/*-1*/-curfrmtbh;
+ if (prevframebottomline>newheight) {
+
+ }
+ }
+ }
+
+ if (sdarray != NULL) {
+ free(sdarray);
+ sdarray = NULL;
+ }
+
+ for (i = 0;i<nFramescount;i++) {
+ if (Frames[i].floating)
+ CLUIFrameResizeFloatingFrame(i);
+ else
+ CLUIFrameMoveResize(&Frames[i]);
+ }
+ return 0;
+}
+
+INT_PTR CLUIFramesUpdateFrame(WPARAM wParam,LPARAM lParam)
+{
+ if (FramesSysNotStarted) return -1;
+ if (wParam == -1) { CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,(LPARAM)0); return 0;}
+ if (lParam&FU_FMPOS) CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,1);
+ lockfrm();
+ wParam = id2pos(wParam);
+ if (wParam<0||(int)wParam>=nFramescount) { ulockfrm(); return -1;}
+ if (lParam&FU_TBREDRAW) CLUIFramesForceUpdateTB(&Frames[wParam]);
+ if (lParam&FU_FMREDRAW) CLUIFramesForceUpdateFrame(&Frames[wParam]);
+ //if () {}
+ ulockfrm();
+
+ return 0;
+}
+
+int CLUIFramesOnClistResize(WPARAM wParam,LPARAM lParam)
+{
+ RECT nRect,rcStatus;
+ int tick,i;
+
+ if (FramesSysNotStarted) return -1;
+ lockfrm();
+
+ GetClientRect(pcli->hwndContactList,&nRect);
+
+ rcStatus.top = rcStatus.bottom = 0;
+
+ nRect.bottom -= nRect.top;
+ nRect.bottom -= (rcStatus.bottom-rcStatus.top);
+ nRect.right -= nRect.left;
+ nRect.left = 0;
+ nRect.top = 0;
+ ContactListHeight = nRect.bottom;
+
+ tick = GetTickCount();
+
+ CLUIFramesResize(nRect);
+
+ for (i = 0; i < nFramescount; i++) {
+ CLUIFramesForceUpdateFrame(&Frames[i]);
+ CLUIFramesForceUpdateTB(&Frames[i]);
+ }
+
+ //resizing = FALSE;
+ ulockfrm();
+ tick = GetTickCount()-tick;
+
+ if (pcli->hwndContactList != 0) InvalidateRect(pcli->hwndContactList,NULL,TRUE);
+ if (pcli->hwndContactList != 0) UpdateWindow(pcli->hwndContactList);
+
+ Sleep(0);
+
+ //dont save to database too many times
+ if (GetTickCount() - LastStoreTick > 1000) {
+ CLUIFramesStoreAllFrames();
+ LastStoreTick = GetTickCount();
+ }
+ return 0;
+}
+
+static HBITMAP hBmpBackground;
+static int backgroundBmpUse;
+static COLORREF bkColour;
+static COLORREF SelBkColour;
+boolean AlignCOLLIconToLeft; //will hide frame icon
+
+int OnFrameTitleBarBackgroundChange(WPARAM wParam,LPARAM lParam)
+{
+ DBVARIANT dbv;
+
+ AlignCOLLIconToLeft = DBGetContactSettingByte(NULL,"FrameTitleBar","AlignCOLLIconToLeft",0);
+
+ bkColour = DBGetContactSettingDword(NULL,"FrameTitleBar","BkColour",CLCDEFAULT_BKCOLOUR);
+ //SelBkColour = DBGetContactSettingDword(NULL,"FrameTitleBar","SelBkColour",0);
+
+ if (hBmpBackground) {DeleteObject(hBmpBackground); hBmpBackground = NULL;}
+ if (DBGetContactSettingByte(NULL,"FrameTitleBar","UseBitmap",CLCDEFAULT_USEBITMAP)) {
+ if (!DBGetContactSetting(NULL,"FrameTitleBar","BkBitmap",&dbv)) {
+ hBmpBackground = (HBITMAP)CallService(MS_UTILS_LOADBITMAP,0,(LPARAM)dbv.pszVal);
+ mir_free(dbv.pszVal);
+ }
+ }
+ backgroundBmpUse = DBGetContactSettingWord(NULL,"FrameTitleBar","BkBmpUse",CLCDEFAULT_BKBMPUSE);
+
+ CLUIFramesOnClistResize(0,0);
+ return 0;
+}
+
+void DrawBackGroundTTB(HWND hwnd,HDC mhdc)
+{
+ HDC hdcMem,hdc;
+ RECT clRect,*rcPaint;
+
+ int yScroll = 0;
+ int y;
+ PAINTSTRUCT paintst = {0};
+ HBITMAP hBmpOsb,hOldBmp;
+ DWORD style = GetWindowLongPtr(hwnd,GWL_STYLE);
+ int grey = 0;
+ HFONT oFont;
+ HBRUSH hBrushAlternateGrey = NULL;
+
+ HFONT hFont;
+
+ //InvalidateRect(hwnd,0,FALSE);
+
+ hFont = (HFONT)SendMessage(hwnd,WM_GETFONT,0,0);
+
+ if (mhdc) {
+ hdc = mhdc;
+ rcPaint = NULL;
+ }
+ else {
+ hdc = BeginPaint(hwnd,&paintst);
+ rcPaint = &(paintst.rcPaint);
+ }
+
+ GetClientRect(hwnd,&clRect);
+ if (rcPaint == NULL) rcPaint = &clRect;
+ if (rcPaint->right-rcPaint->left == 0||rcPaint->top-rcPaint->bottom == 0) rcPaint = &clRect;
+ y = -yScroll;
+ hdcMem = CreateCompatibleDC(hdc);
+ hBmpOsb = CreateBitmap(clRect.right,clRect.bottom,1,GetDeviceCaps(hdc,BITSPIXEL),NULL);
+ hOldBmp = (HBITMAP)SelectObject(hdcMem,hBmpOsb);
+ oFont = (HFONT)SelectObject(hdcMem,hFont);
+ SetBkMode(hdcMem,TRANSPARENT);
+ {
+ HBRUSH hBrush = CreateSolidBrush(bkColour);
+ HBRUSH hoBrush = (HBRUSH)SelectObject(hdcMem,hBrush);
+ FillRect(hdcMem,rcPaint,hBrush);
+ SelectObject(hdcMem,hoBrush);
+ DeleteObject(hBrush);
+ if (hBmpBackground) {
+ BITMAP bmp;
+ HDC hdcBmp;
+ int x,y;
+ int maxx,maxy;
+ int destw,desth;
+
+ GetObject(hBmpBackground,sizeof(bmp),&bmp);
+ hdcBmp = CreateCompatibleDC(hdcMem);
+ SelectObject(hdcBmp,hBmpBackground);
+ y = backgroundBmpUse&CLBF_SCROLL?-yScroll:0;
+ maxx = backgroundBmpUse&CLBF_TILEH?clRect.right:1;
+ maxy = backgroundBmpUse&CLBF_TILEV?maxy = rcPaint->bottom:y+1;
+ switch(backgroundBmpUse&CLBM_TYPE) {
+ case CLB_STRETCH:
+ if (backgroundBmpUse&CLBF_PROPORTIONAL) {
+ if (clRect.right*bmp.bmHeight<clRect.bottom*bmp.bmWidth) {
+ desth = clRect.bottom;
+ destw = desth*bmp.bmWidth/bmp.bmHeight;
+ }
+ else {
+ destw = clRect.right;
+ desth = destw*bmp.bmHeight/bmp.bmWidth;
+ }
+ }
+ else {
+ destw = clRect.right;
+ desth = clRect.bottom;
+ }
+ break;
+ case CLB_STRETCHH:
+ if (backgroundBmpUse&CLBF_PROPORTIONAL) {
+ destw = clRect.right;
+ desth = destw*bmp.bmHeight/bmp.bmWidth;
+ }
+ else {
+ destw = clRect.right;
+ desth = bmp.bmHeight;
+ }
+ break;
+ case CLB_STRETCHV:
+ if (backgroundBmpUse&CLBF_PROPORTIONAL) {
+ desth = clRect.bottom;
+ destw = desth*bmp.bmWidth/bmp.bmHeight;
+ }
+ else {
+ destw = bmp.bmWidth;
+ desth = clRect.bottom;
+ }
+ break;
+ default: //clb_topleft
+ destw = bmp.bmWidth;
+ desth = bmp.bmHeight;
+ break;
+ }
+ desth = clRect.bottom -clRect.top;
+ for (;y<maxy;y += desth) {
+ if (y<rcPaint->top-desth) continue;
+ for (x = 0;x<maxx;x += destw)
+ StretchBlt(hdcMem,x,y,destw,desth,hdcBmp,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
+ }
+ DeleteDC(hdcBmp);
+ }
+ }
+
+ BitBlt(hdc,rcPaint->left,rcPaint->top,rcPaint->right-rcPaint->left,rcPaint->bottom-rcPaint->top,hdcMem,rcPaint->left,rcPaint->top,SRCCOPY);
+
+ SelectObject(hdcMem,hOldBmp);
+ SelectObject(hdcMem,oFont);
+ DeleteObject(hBmpOsb);
+ DeleteDC(hdcMem);
+ paintst.fErase = FALSE;
+ //DeleteObject(hFont);
+ if (!mhdc)
+ EndPaint(hwnd,&paintst);
+}
+
+static int DrawTitleBar(HDC dc,RECT rect,int Frameid)
+{
+ HDC paintDC = dc;
+
+ HDC hdcMem = CreateCompatibleDC(paintDC);
+ HBITMAP hBmpOsb = CreateBitmap(rect.right,rect.bottom,1,GetDeviceCaps(paintDC,BITSPIXEL),NULL);
+ HBITMAP hoBmp = (HBITMAP)SelectObject(hdcMem,hBmpOsb);
+
+ HFONT hoTTBFont = (HFONT)SelectObject(hdcMem,TitleBarFont);
+ SetBkMode(hdcMem,TRANSPARENT);
+
+ HBRUSH hBack = GetSysColorBrush(COLOR_3DFACE);
+ HBRUSH hoBrush = (HBRUSH)SelectObject(hdcMem,hBack);
+
+ lockfrm();
+
+ int pos = id2pos(Frameid);
+ if (pos >= 0 && pos < nFramescount) {
+ GetClientRect(Frames[pos].TitleBar.hwnd,&Frames[pos].TitleBar.wndSize);
+
+ //set font charset
+ HFONT hf = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
+ if (TitleBarLogFont.lfHeight != 0)
+ hf = CreateFontIndirectA(&TitleBarLogFont);
+
+ HFONT oFont = (HFONT)SelectObject(hdcMem,hf);
+
+ DrawBackGroundTTB(Frames[pos].TitleBar.hwnd,hdcMem);
+ //hFront = CreateSolidPe (SelBkColour);
+ //SelectObject(hdcMem,hFront);
+ SelBkColour = DBGetContactSettingDword(NULL,"CLUIFrames","FramesTitleBarFontCol",0);
+ if (SelBkColour) SetTextColor(hdcMem,SelBkColour);
+
+ if (!AlignCOLLIconToLeft) {
+
+ if (Frames[pos].TitleBar.hicon != NULL) {
+ //(TitleBarH>>1)-(GetSystemMetrics(SM_CXSMICON)>>1)
+ DrawIconEx(hdcMem,2,((TitleBarH>>1)-(GetSystemMetrics(SM_CYSMICON)>>1)),Frames[pos].TitleBar.hicon,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),0,NULL,DI_NORMAL);
+ TextOut(hdcMem,GetSystemMetrics(SM_CYSMICON)+4,0,Frames[pos].TitleBar.tbname,lstrlen(Frames[pos].TitleBar.tbname));
+ }
+ else
+ TextOut(hdcMem,2,0,Frames[pos].TitleBar.tbname,lstrlen(Frames[pos].TitleBar.tbname));
+ }
+ else
+ TextOut(hdcMem,GetSystemMetrics(SM_CXSMICON)+2,0,Frames[pos].TitleBar.tbname,lstrlen(Frames[pos].TitleBar.tbname));
+
+ if (!AlignCOLLIconToLeft)
+ DrawIconEx(hdcMem,Frames[pos].TitleBar.wndSize.right-GetSystemMetrics(SM_CXSMICON)-2,((TitleBarH>>1)-(GetSystemMetrics(SM_CXSMICON)>>1)),Frames[pos].collapsed?LoadSkinnedIcon(SKINICON_OTHER_GROUPOPEN):LoadSkinnedIcon(SKINICON_OTHER_GROUPSHUT),GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),0,NULL,DI_NORMAL);
+ else
+ DrawIconEx(hdcMem,0,((TitleBarH>>1)-(GetSystemMetrics(SM_CXSMICON)>>1)),Frames[pos].collapsed?LoadSkinnedIcon(SKINICON_OTHER_GROUPOPEN):LoadSkinnedIcon(SKINICON_OTHER_GROUPSHUT),GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),0,NULL,DI_NORMAL);
+
+ DeleteObject(hf);
+ SelectObject(hdcMem,oFont);
+ }
+ ulockfrm();
+
+ BitBlt(paintDC,rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,hdcMem,rect.left,rect.top,SRCCOPY);
+
+ SelectObject(hdcMem,hoBmp);
+ SelectObject(hdcMem,hoBrush);
+ SelectObject(hdcMem,hoTTBFont);
+ DeleteDC(hdcMem);
+ DeleteObject(hBack);
+ DeleteObject(hBmpOsb);
+ return 0;
+}
+
+//for old multiwindow
+#define MPCF_CONTEXTFRAMEMENU 3
+POINT ptOld;
+short nLeft = 0;
+short nTop = 0;
+
+LRESULT CALLBACK CLUIFrameTitleBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ RECT rect;
+ int Frameid,Framemod,direction;
+ int xpos,ypos;
+
+ Frameid = (GetWindowLongPtr(hwnd,GWLP_USERDATA));
+ memset(&rect,0,sizeof(rect));
+
+ switch(msg) {
+ case WM_CREATE:
+ SendMessage(hwnd,WM_SETFONT,(WPARAM)TitleBarFont,0);
+ return FALSE;
+
+ case WM_MEASUREITEM:
+ return CallService(MS_CLIST_MENUMEASUREITEM,wParam,lParam);
+
+ case WM_DRAWITEM:
+ return CallService(MS_CLIST_MENUDRAWITEM,wParam,lParam);
+
+ case WM_ENABLE:
+ if (hwnd != 0) InvalidateRect(hwnd,NULL,FALSE);
+ return 0;
+
+ case WM_COMMAND:
+ if ( ServiceExists(MO_CREATENEWMENUOBJECT)) {
+ if (ProcessCommandProxy(MAKEWPARAM(LOWORD(wParam),0),(LPARAM)Frameid) ) break;
+ }
+ else if ( CallService(MS_CLIST_MENUPROCESSCOMMAND,MAKEWPARAM(LOWORD(wParam),MPCF_CONTEXTFRAMEMENU),(LPARAM)Frameid) )
+ break;
+
+ if (HIWORD(wParam) == 0) {//mouse events for self created menu
+ int framepos = id2pos(Frameid);
+ if (framepos == -1)
+ break;
+
+ switch(LOWORD(wParam)) {
+ case frame_menu_lock:
+ Frames[framepos].Locked = !Frames[framepos].Locked;
+ break;
+ case frame_menu_visible:
+ Frames[framepos].visible = !Frames[framepos].visible;
+ break;
+ case frame_menu_showtitlebar:
+ Frames[framepos].TitleBar.ShowTitleBar = !Frames[framepos].TitleBar.ShowTitleBar;
+ break;
+ case frame_menu_floating:
+ CLUIFrameSetFloat(Frameid,0);
+ break;
+ }
+ CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,(LPARAM)0);
+ }
+ break;
+
+ case WM_RBUTTONDOWN:
+ {
+ HMENU hmenu;
+ POINT pt;
+ GetCursorPos(&pt);
+
+ if (ServiceExists(MS_CLIST_MENUBUILDFRAMECONTEXT))
+ hmenu = (HMENU)CallService(MS_CLIST_MENUBUILDFRAMECONTEXT,Frameid,0);
+ else {
+ //legacy menu support
+ int framepos = id2pos(Frameid);
+ lockfrm();
+ if (framepos == -1){ulockfrm();break;}
+ hmenu = CreatePopupMenu();
+
+ AppendMenu(hmenu,MF_STRING|MF_DISABLED|MF_GRAYED,15,Frames[framepos].name);
+ AppendMenu(hmenu,MF_SEPARATOR,16,_T(""));
+
+ if (Frames[framepos].Locked)
+ {AppendMenu(hmenu,MF_STRING|MF_CHECKED,frame_menu_lock,TranslateT("Lock Frame"));}
+ else{AppendMenu(hmenu,MF_STRING,frame_menu_lock,TranslateT("Lock Frame"));}
+
+ if (Frames[framepos].visible)
+ {AppendMenu(hmenu,MF_STRING|MF_CHECKED,frame_menu_visible,TranslateT("Visible"));}
+ else{AppendMenu(hmenu,MF_STRING,frame_menu_visible,TranslateT("Visible") );}
+
+ if (Frames[framepos].TitleBar.ShowTitleBar)
+ {AppendMenu(hmenu,MF_STRING|MF_CHECKED,frame_menu_showtitlebar,TranslateT("Show TitleBar") );}
+ else{AppendMenu(hmenu,MF_STRING,frame_menu_showtitlebar,TranslateT("Show TitleBar") );}
+
+ if (Frames[framepos].floating)
+ {AppendMenu(hmenu,MF_STRING|MF_CHECKED,frame_menu_floating,TranslateT("Floating") );}
+ else{AppendMenu(hmenu,MF_STRING,frame_menu_floating,TranslateT("Floating") );}
+
+ ulockfrm();
+ }
+
+ TrackPopupMenu(hmenu,TPM_LEFTALIGN,pt.x,pt.y,0,hwnd,0);
+ DestroyMenu(hmenu);
+ }
+ break;
+
+ case WM_LBUTTONDBLCLK:
+ Framemod = -1;
+ lbypos = -1;oldframeheight = -1;ReleaseCapture();
+ CallService(MS_CLIST_FRAMES_UCOLLFRAME,Frameid,0);
+ lbypos = -1;oldframeheight = -1;ReleaseCapture();
+ break;
+
+ case WM_LBUTTONUP:
+ if (GetCapture() != hwnd)
+ break;
+ curdragbar = -1;lbypos = -1;oldframeheight = -1;ReleaseCapture();
+ break;
+
+ case WM_LBUTTONDOWN:
+ {
+ int framepos = id2pos(Frameid);
+ if (framepos == -1)
+ break;
+
+ lockfrm();
+ if (Frames[framepos].floating)
+ {
+ POINT pt;
+ GetCursorPos(&pt);
+ Frames[framepos].TitleBar.oldpos = pt;
+ }
+
+ if (( !(wParam & MK_CONTROL)) && Frames[framepos].Locked && (!(Frames[framepos].floating))) {
+ if (DBGetContactSettingByte(NULL,"CLUI","ClientAreaDrag",0)) {
+ POINT pt;
+ //pt = nm->pt;
+ GetCursorPos(&pt);
+ return SendMessage(GetParent(hwnd), WM_SYSCOMMAND, SC_MOVE|HTCAPTION,MAKELPARAM(pt.x,pt.y));
+ }
+ }
+
+ if (Frames[framepos].floating) {
+ RECT rc;
+ GetCursorPos(&ptOld);
+ //ClientToScreen(hwnd,&ptOld);
+ GetWindowRect( hwnd, &rc );
+
+ nLeft = (short)rc.left;
+ nTop = (short)rc.top;
+ }
+ ulockfrm();
+ SetCapture(hwnd);
+ }
+ break;
+
+ case WM_MOUSEMOVE:
+ {
+ POINT pt,pt2;
+ RECT wndr;
+ int pos;
+
+ char TBcapt[255];
+
+ lockfrm();
+ pos = id2pos(Frameid);
+
+ if (pos != -1) {
+ int oldflags;
+ wsprintfA(TBcapt,"%s - h:%d, vis:%d, fl:%d, fl:(%d,%d,%d,%d),or: %d",
+ Frames[pos].name,Frames[pos].height,Frames[pos].visible,Frames[pos].floating,
+ Frames[pos].FloatingPos.x,Frames[pos].FloatingPos.y,
+ Frames[pos].FloatingSize.x,Frames[pos].FloatingSize.y,
+ Frames[pos].order);
+
+ oldflags = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS,MAKEWPARAM(FO_FLAGS,Frames[pos].id),(LPARAM)0);
+ if ( !(oldflags & F_SHOWTBTIP))
+ oldflags |= F_SHOWTBTIP;
+ }
+
+ ulockfrm();
+
+ if (wParam & MK_LBUTTON) {
+ RECT rcMiranda;
+ RECT rcwnd,rcOverlap;
+ POINT newpt,ofspt,curpt,newpos;
+ //if (GetCapture() != hwnd){break;}
+ //curdragbar = -1;lbypos = -1;oldframeheight = -1;ReleaseCapture();
+ lockfrm();
+ pos = id2pos(Frameid);
+ if (Frames[pos].floating) {
+
+ GetCursorPos(&curpt);
+ rcwnd.bottom = curpt.y+5;
+ rcwnd.top = curpt.y;
+ rcwnd.left = curpt.x;
+ rcwnd.right = curpt.x+5;
+
+ GetWindowRect(pcli->hwndContactList, &rcMiranda );
+ //GetWindowRect( Frames[pos].ContainerWnd, &rcwnd );
+ //IntersectRect( &rcOverlap, &rcwnd, &rcMiranda )
+ if (IsWindowVisible(pcli->hwndContactList) &&IntersectRect( &rcOverlap, &rcwnd, &rcMiranda )) {
+ int id = Frames[pos].id;
+ ulockfrm();
+
+ ofspt.x = 0;ofspt.y = 0;
+ ClientToScreen(Frames[pos].TitleBar.hwnd,&ofspt);
+ ofspt.x = curpt.x-ofspt.x;ofspt.y = curpt.y-ofspt.y;
+
+ CLUIFrameSetFloat(id,0);
+ newpt.x = 0;newpt.y = 0;
+ ClientToScreen(Frames[pos].TitleBar.hwnd,&newpt);
+ SetCursorPos(newpt.x+ofspt.x,newpt.y+ofspt.y);
+ GetCursorPos(&curpt);
+ lockfrm();
+ Frames[pos].TitleBar.oldpos = curpt;
+ ulockfrm();
+ return 0;
+ }
+ }
+ else {
+ int id = Frames[pos].id;
+
+ GetCursorPos(&curpt);
+ rcwnd.bottom = curpt.y+5;
+ rcwnd.top = curpt.y;
+ rcwnd.left = curpt.x;
+ rcwnd.right = curpt.x+5;
+
+ GetWindowRect(pcli->hwndContactList, &rcMiranda );
+
+ if (!IntersectRect( &rcOverlap, &rcwnd, &rcMiranda )) {
+ ulockfrm();
+ GetCursorPos(&curpt);
+ GetWindowRect( Frames[pos].hWnd, &rcwnd );
+ rcwnd.left = rcwnd.right-rcwnd.left;
+ rcwnd.top = rcwnd.bottom-rcwnd.top;
+ newpos.x = curpt.x;newpos.y = curpt.y;
+ if (curpt.x>=(rcMiranda.right-1)){newpos.x = curpt.x+5;}
+ if (curpt.x<=(rcMiranda.left+1)){newpos.x = curpt.x-(rcwnd.left)-5;}
+
+ if (curpt.y>=(rcMiranda.bottom-1)){newpos.y = curpt.y+5;}
+ if (curpt.y<=(rcMiranda.top+1)){newpos.y = curpt.y-(rcwnd.top)-5;}
+
+
+ ofspt.x = 0;ofspt.y = 0;
+ //ClientToScreen(Frames[pos].TitleBar.hwnd,&ofspt);
+ GetWindowRect(Frames[pos].TitleBar.hwnd,&rcwnd);
+ ofspt.x = curpt.x-ofspt.x;ofspt.y = curpt.y-ofspt.y;
+
+ Frames[pos].FloatingPos.x = newpos.x;
+ Frames[pos].FloatingPos.y = newpos.y;
+ CLUIFrameSetFloat(id,0);
+ //SetWindowPos(Frames[pos].ContainerWnd,0,newpos.x,newpos.y,0,0,SWP_NOSIZE);
+
+ lockfrm();
+ newpt.x = 0;newpt.y = 0;
+ ClientToScreen(Frames[pos].TitleBar.hwnd,&newpt);
+
+ GetWindowRect( Frames[pos].hWnd, &rcwnd );
+ SetCursorPos(newpt.x+(rcwnd.right-rcwnd.left)/2,newpt.y+(rcwnd.bottom-rcwnd.top)/2);
+ GetCursorPos(&curpt);
+
+ Frames[pos].TitleBar.oldpos = curpt;
+ ulockfrm();
+
+ return 0;
+ }
+ }
+ ulockfrm();
+ }
+
+ if (wParam & MK_LBUTTON) {
+ int newh = -1,prevold;
+
+ if (GetCapture() != hwnd){break;}
+
+ lockfrm();
+ pos = id2pos(Frameid);
+
+ if (Frames[pos].floating) {
+ GetCursorPos(&pt);
+ if ((Frames[pos].TitleBar.oldpos.x != pt.x)||(Frames[pos].TitleBar.oldpos.y != pt.y)) {
+
+ pt2 = pt;
+ ScreenToClient(hwnd,&pt2);
+ GetWindowRect(Frames[pos].ContainerWnd,&wndr);
+
+ int dX,dY;
+ POINT ptNew;
+
+ ptNew.x = pt.x;
+ ptNew.y = pt.y;
+ //ClientToScreen( hwnd, &ptNew );
+
+ dX = ptNew.x - ptOld.x;
+ dY = ptNew.y - ptOld.y;
+
+ nLeft += (short)dX;
+ nTop += (short)dY;
+
+ if ( !(wParam & MK_CONTROL))
+ PositionThumb( &Frames[pos], nLeft, nTop );
+ else
+ SetWindowPos( Frames[pos].ContainerWnd,
+ HWND_TOPMOST,
+ nLeft,
+ nTop,
+ 0,
+ 0,
+ SWP_NOSIZE | SWP_NOZORDER );
+
+ ptOld = ptNew;
+
+ pt.x = nLeft;
+ pt.y = nTop;
+ Frames[pos].TitleBar.oldpos = pt;
+ }
+
+ ulockfrm();
+ return 0;
+ }
+
+ if (Frames[pos].prevvisframe != -1) {
+ GetCursorPos(&pt);
+
+ if ((Frames[pos].TitleBar.oldpos.x == pt.x)&&(Frames[pos].TitleBar.oldpos.y == pt.y)) {
+ ulockfrm();
+ break;
+ }
+
+ ypos = rect.top+pt.y;xpos = rect.left+pt.x;
+ Framemod = -1;
+
+ if (Frames[pos].align == alBottom) {
+ direction = -1;
+ Framemod = pos;
+ }
+ else {
+ direction = 1;
+ Framemod = Frames[pos].prevvisframe;
+ }
+ if (Frames[Framemod].Locked) {ulockfrm();break;}
+ if (curdragbar != -1&&curdragbar != pos) {ulockfrm();break;}
+
+ if (lbypos == -1) {
+ curdragbar = pos;
+ lbypos = ypos;
+ oldframeheight = Frames[Framemod].height;
+ SetCapture(hwnd);
+ {ulockfrm();break;}
+ }
+
+ newh = oldframeheight+direction*(ypos-lbypos);
+ if (newh > 0) {
+ prevold = Frames[Framemod].height;
+ Frames[Framemod].height = newh;
+ if (!CLUIFramesFitInSize()) {
+ Frames[Framemod].height = prevold;
+ ulockfrm();
+ return TRUE;
+ }
+ Frames[Framemod].height = newh;
+ if (newh > 3)
+ Frames[Framemod].collapsed = TRUE;
+ }
+ Frames[pos].TitleBar.oldpos = pt;
+ }
+ ulockfrm();
+ if (newh > 0)
+ CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0);
+ break;
+ }
+ curdragbar = -1;lbypos = -1;oldframeheight = -1;ReleaseCapture();
+ }
+ break;
+
+ case WM_PRINTCLIENT:
+ if (lParam & PRF_CLIENT) {
+ GetClientRect(hwnd,&rect);
+ DrawTitleBar((HDC)wParam,rect,Frameid);
+ }
+
+ case WM_PAINT:
+ {
+ HDC paintDC;
+ PAINTSTRUCT paintStruct;
+
+ //GetClientRect(hwnd,&rect);
+ paintDC = BeginPaint(hwnd, &paintStruct);
+ rect = paintStruct.rcPaint;
+ DrawTitleBar(paintDC,rect,Frameid);
+ EndPaint(hwnd, &paintStruct);
+ }
+ return 0;
+
+ default:
+ return DefWindowProc(hwnd, msg, wParam, lParam);
+ }
+ return TRUE;
+}
+
+int CLUIFrameResizeFloatingFrame(int framepos)
+{
+ int width,height;
+ RECT rect;
+
+ if (!Frames[framepos].floating){return 0;}
+ if (Frames[framepos].ContainerWnd == 0){return 0;}
+ GetClientRect(Frames[framepos].ContainerWnd,&rect);
+
+ width = rect.right-rect.left;
+ height = rect.bottom-rect.top;
+
+ Frames[framepos].visible?ShowWindow(Frames[framepos].ContainerWnd,SW_SHOW):ShowWindow(Frames[framepos].ContainerWnd,SW_HIDE);
+
+ if (Frames[framepos].TitleBar.ShowTitleBar) {
+ ShowWindow(Frames[framepos].TitleBar.hwnd,SW_SHOW);
+ Frames[framepos].height = height-DEFAULT_TITLEBAR_HEIGHT;
+
+ SetWindowPos(Frames[framepos].TitleBar.hwnd,HWND_TOP,0,0,width,DEFAULT_TITLEBAR_HEIGHT,SWP_SHOWWINDOW|SWP_DRAWFRAME);
+ SetWindowPos(Frames[framepos].hWnd,HWND_TOP,0,DEFAULT_TITLEBAR_HEIGHT,width,height-DEFAULT_TITLEBAR_HEIGHT,SWP_SHOWWINDOW);
+ }
+ else {
+ Frames[framepos].height = height;
+ ShowWindow(Frames[framepos].TitleBar.hwnd,SW_HIDE);
+ SetWindowPos(Frames[framepos].hWnd,HWND_TOP,0,0,width,height,SWP_SHOWWINDOW);
+ }
+
+ if (Frames[framepos].ContainerWnd != 0)
+ UpdateWindow(Frames[framepos].ContainerWnd);
+
+ GetWindowRect(Frames[framepos].hWnd,&Frames[framepos].wndSize);
+ return 0;
+}
+
+static int CLUIFrameOnMainMenuBuild(WPARAM wParam,LPARAM lParam)
+{
+ CLUIFramesLoadMainMenu();
+ return 0;
+}
+
+LRESULT CALLBACK CLUIFrameContainerWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ RECT rect = { 0 };
+ int Frameid = (GetWindowLongPtr(hwnd,GWLP_USERDATA));
+
+ switch(msg) {
+ case WM_CREATE:
+ {
+ lockfrm();
+ int framepos = id2pos(Frameid);
+ ulockfrm();
+ }
+ return 0;
+
+ case WM_GETMINMAXINFO:
+ {
+ int framepos;
+ MINMAXINFO minmax;
+
+ lockfrm();
+ framepos = id2pos(Frameid);
+ if (framepos<0||framepos>=nFramescount){ulockfrm();break;}
+ if (!Frames[framepos].minmaxenabled){ulockfrm();break;}
+ if (Frames[framepos].ContainerWnd == 0){ulockfrm();break;}
+
+ if (Frames[framepos].Locked) {
+ RECT rct;
+
+ GetWindowRect(hwnd,&rct);
+ ((LPMINMAXINFO)lParam)->ptMinTrackSize.x = rct.right-rct.left;
+ ((LPMINMAXINFO)lParam)->ptMinTrackSize.y = rct.bottom-rct.top;
+ ((LPMINMAXINFO)lParam)->ptMaxTrackSize.x = rct.right-rct.left;
+ ((LPMINMAXINFO)lParam)->ptMaxTrackSize.y = rct.bottom-rct.top;
+ }
+
+ memset(&minmax,0,sizeof(minmax));
+ if (SendMessage(Frames[framepos].hWnd,WM_GETMINMAXINFO,(WPARAM)0,(LPARAM)&minmax) == 0) {
+ RECT border;
+ int tbh = TitleBarH*btoint(Frames[framepos].TitleBar.ShowTitleBar);
+ GetBorderSize(hwnd,&border);
+ if (minmax.ptMaxTrackSize.x != 0&&minmax.ptMaxTrackSize.y != 0){
+ ((LPMINMAXINFO)lParam)->ptMinTrackSize.x = minmax.ptMinTrackSize.x;
+ ((LPMINMAXINFO)lParam)->ptMinTrackSize.y = minmax.ptMinTrackSize.y;
+ ((LPMINMAXINFO)lParam)->ptMaxTrackSize.x = minmax.ptMaxTrackSize.x+border.left+border.right;
+ ((LPMINMAXINFO)lParam)->ptMaxTrackSize.y = minmax.ptMaxTrackSize.y+tbh+border.top+border.bottom;
+ }
+ }
+ else {
+ ulockfrm();
+ return(DefWindowProc(hwnd, msg, wParam, lParam));
+ }
+
+ ulockfrm();
+ }
+
+ case WM_MOVE:
+ {
+ lockfrm();
+ int framepos = id2pos(Frameid);
+
+ if (framepos<0||framepos>=nFramescount){ulockfrm();break;}
+ if (Frames[framepos].ContainerWnd == 0){ulockfrm();return 0;}
+
+ RECT rect;
+ GetWindowRect(Frames[framepos].ContainerWnd,&rect);
+ Frames[framepos].FloatingPos.x = rect.left;
+ Frames[framepos].FloatingPos.y = rect.top;
+ Frames[framepos].FloatingSize.x = rect.right-rect.left;
+ Frames[framepos].FloatingSize.y = rect.bottom-rect.top;
+
+ CLUIFramesStoreFrameSettings(framepos);
+ ulockfrm();
+ }
+ return 0;
+
+ case WM_SIZE:
+ {
+ lockfrm();
+ int framepos = id2pos(Frameid);
+
+ if (framepos<0||framepos>=nFramescount){ulockfrm();break;}
+ if (Frames[framepos].ContainerWnd == 0){ulockfrm();return 0;}
+ CLUIFrameResizeFloatingFrame(framepos);
+
+ RECT rect;
+ GetWindowRect(Frames[framepos].ContainerWnd,&rect);
+ Frames[framepos].FloatingPos.x = rect.left;
+ Frames[framepos].FloatingPos.y = rect.top;
+ Frames[framepos].FloatingSize.x = rect.right-rect.left;
+ Frames[framepos].FloatingSize.y = rect.bottom-rect.top;
+
+ CLUIFramesStoreFrameSettings(framepos);
+ ulockfrm();
+ }
+ return 0;
+
+ case WM_CLOSE:
+ DestroyWindow(hwnd);
+ break;
+
+ case WM_DESTROY:
+ return 0;
+ }
+ return DefWindowProc(hwnd, msg, wParam, lParam);
+}
+
+static HWND CreateContainerWindow(HWND parent,int x,int y,int width,int height)
+{
+ return(CreateWindowA("FramesContainer","aaaa",WS_POPUP|WS_THICKFRAME,x,y,width,height,parent,0,g_hInst,0));
+}
+
+INT_PTR CLUIFrameSetFloat(WPARAM wParam,LPARAM lParam)
+{
+ HWND hwndtmp, hwndtooltiptmp;
+ wndFrame *frame;
+ int pos;
+
+ lockfrm();
+
+ pos = id2pos(wParam);
+ if (pos < 0 || pos > nFramescount) {
+ ulockfrm();
+ return 0;
+ }
+
+ frame = &Frames[pos];
+
+ //parent = GetParent(Frames[wParam].hWnd);
+ if (frame->floating) {
+ SetParent(frame->hWnd,pcli->hwndContactList);
+ SetParent(frame->TitleBar.hwnd,pcli->hwndContactList);
+ frame->floating = FALSE;
+ DestroyWindow(frame->ContainerWnd);
+ frame->ContainerWnd = NULL;
+ }
+ else {
+ RECT recttb,rectw,border;
+ int temp;
+ int neww,newh;
+ BOOLEAN locked;
+
+ frame->oldstyles = GetWindowLongPtr(frame->hWnd,GWL_STYLE);
+ frame->TitleBar.oldstyles = GetWindowLongPtr(frame->TitleBar.hwnd,GWL_STYLE);
+ locked = frame->Locked;
+ frame->Locked = FALSE;
+ frame->minmaxenabled = FALSE;
+
+ GetWindowRect(frame->hWnd,&rectw);
+ GetWindowRect(frame->TitleBar.hwnd,&recttb);
+ if (!frame->TitleBar.ShowTitleBar)
+ recttb.top = recttb.bottom = recttb.left = recttb.right = 0;
+
+ frame->ContainerWnd = CreateContainerWindow(pcli->hwndContactList,frame->FloatingPos.x,frame->FloatingPos.y,10,10);
+
+ SetParent(frame->hWnd,frame->ContainerWnd);
+ SetParent(frame->TitleBar.hwnd,frame->ContainerWnd);
+
+ GetBorderSize(frame->ContainerWnd,&border);
+
+ SetWindowLongPtr(frame->ContainerWnd, GWLP_USERDATA, frame->id);
+ if ((lParam == 1)) {
+ if ((frame->FloatingPos.x != 0)&&(frame->FloatingPos.y != 0)) {
+ if (frame->FloatingPos.x<20){frame->FloatingPos.x = 40;}
+ if (frame->FloatingPos.y<20){frame->FloatingPos.y = 40;}
+
+ SetWindowPos(frame->ContainerWnd,HWND_TOPMOST,frame->FloatingPos.x,frame->FloatingPos.y,frame->FloatingSize.x,frame->FloatingSize.y,SWP_HIDEWINDOW);
+ }
+ else SetWindowPos(frame->ContainerWnd,HWND_TOPMOST,120,120,140,140,SWP_HIDEWINDOW);
+ }
+ else {
+ neww = rectw.right-rectw.left+border.left+border.right;
+ newh = (rectw.bottom-rectw.top)+(recttb.bottom-recttb.top)+border.top+border.bottom;
+ if (neww<20){neww = 40;}
+ if (newh<20){newh = 40;}
+ if (frame->FloatingPos.x<20){frame->FloatingPos.x = 40;}
+ if (frame->FloatingPos.y<20){frame->FloatingPos.y = 40;}
+
+ SetWindowPos(frame->ContainerWnd,HWND_TOPMOST,frame->FloatingPos.x,frame->FloatingPos.y,neww,newh,SWP_HIDEWINDOW);
+ }
+
+ SetWindowText(frame->ContainerWnd,frame->TitleBar.tbname);
+
+ temp = GetWindowLongPtr(frame->ContainerWnd,GWL_EXSTYLE);
+ temp|=WS_EX_TOOLWINDOW|WS_EX_TOPMOST ;
+ SetWindowLongPtr(frame->ContainerWnd,GWL_EXSTYLE,temp);
+
+ frame->floating = TRUE;
+ frame->Locked = locked;
+ }
+
+ CLUIFramesStoreFrameSettings(pos);
+ frame->minmaxenabled = TRUE;
+ hwndtooltiptmp = frame->TitleBar.hwndTip;
+
+ hwndtmp = frame->ContainerWnd;
+ ulockfrm();
+ CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0);
+ SendMessage(hwndtmp,WM_SIZE,0,0);
+
+ SetWindowPos(hwndtooltiptmp, HWND_TOPMOST,0, 0, 0, 0,SWP_NOMOVE | SWP_NOSIZE );
+ return 0;
+}
+
+static int CLUIFrameOnFontChange(WPARAM wParam,LPARAM lParam)
+{
+ FontID fid = {0};
+ fid.cbSize = sizeof(fid);
+ memset(&TitleBarLogFont,0,sizeof(TitleBarLogFont));
+
+ strcpy(fid.group,LPGEN("Frames"));
+ strcpy(fid.name,LPGEN("TitleBarFont"));
+ strcpy(fid.dbSettingsGroup,"CLUIFrames");
+ strcpy(fid.prefix,"FramesTitleBarFont");
+
+ CallService(MS_FONT_GET,(WPARAM)&fid,(LPARAM)&TitleBarLogFont);
+ CLUIFramesOnClistResize(0,0);
+ return 0;
+}
+
+static void CLUIRegisterFonts()
+{
+ if (ServiceExists(MS_FONT_REGISTER)) {
+ FontID fid = {0};
+ fid.cbSize = sizeof(fid);
+ strcpy(fid.group,LPGEN("Frames"));
+ strcpy(fid.name,LPGEN("TitleBarFont"));
+ strcpy(fid.dbSettingsGroup,"CLUIFrames");
+ strcpy(fid.prefix,"FramesTitleBarFont");
+
+ CallService(MS_FONT_REGISTER,(WPARAM)&fid,0);
+ CLUIFrameOnFontChange(0,0);
+ HookEvent(ME_FONT_RELOAD,CLUIFrameOnFontChange);
+} }
+
+static int CLUIFrameOnModulesLoad(WPARAM wParam,LPARAM lParam)
+{
+ CLUIFramesLoadMainMenu();
+ CLUIFramesCreateMenuForFrame(-1,-1,000010000,MS_CLIST_ADDCONTEXTFRAMEMENUITEM);
+ CLUIRegisterFonts();
+ return 0;
+}
+
+static int CLUIFrameOnModulesUnload(WPARAM wParam,LPARAM lParam)
+{
+ CallService( MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, ( LPARAM )contMIVisible, 0 );
+ CallService( MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, ( LPARAM )contMITitle, 0 );
+ CallService( MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, ( LPARAM )contMITBVisible, 0 );
+ CallService( MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, ( LPARAM )contMILock, 0 );
+ CallService( MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, ( LPARAM )contMIColl, 0 );
+ CallService( MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, ( LPARAM )contMIFloating, 0 );
+ CallService( MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, ( LPARAM )contMIAlignRoot, 0 );
+ CallService( MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, ( LPARAM )contMIAlignTop, 0 );
+ CallService( MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, ( LPARAM )contMIAlignClient, 0 );
+ CallService( MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, ( LPARAM )contMIAlignBottom, 0 );
+ CallService( MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, ( LPARAM )contMIBorder, 0 );
+ return 0;
+}
+
+static INT_PTR CLUIGetCapsService(WPARAM wParam,LPARAM lParam)
+{
+ switch (wParam) {
+ case CLUICAPS_FLAGS1:
+ return CLUIF_HIDEEMPTYGROUPS | CLUIF_DISABLEGROUPS | CLUIF_HASONTOPOPTION | CLUIF_HASAUTOHIDEOPTION;
+ case CLUICAPS_FLAGS2:
+ return MAKELONG(EXTRACOLUMNCOUNT,1);
+ }
+ return 0;
+}
+
+int LoadCLUIFramesModule(void)
+{
+ WNDCLASS wndclass;
+ wndclass.style = CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW ;
+ wndclass.lpfnWndProc = CLUIFrameTitleBarProc;
+ wndclass.cbClsExtra = 0;
+ wndclass.cbWndExtra = 0;
+ wndclass.hInstance = g_hInst;
+ wndclass.hIcon = NULL;
+ wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wndclass.hbrBackground = NULL;
+ wndclass.lpszMenuName = NULL;
+ wndclass.lpszClassName = CLUIFrameTitleBarClassName;
+ RegisterClass(&wndclass);
+
+ //container helper
+ WNDCLASS cntclass;
+ cntclass.style = CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW|( IsWinVerXPPlus() ? CS_DROPSHADOW : 0);
+ cntclass.lpfnWndProc = CLUIFrameContainerWndProc;
+ cntclass.cbClsExtra = 0;
+ cntclass.cbWndExtra = 0;
+ cntclass.hInstance = g_hInst;
+ cntclass.hIcon = NULL;
+ cntclass.hCursor = LoadCursor(NULL, IDC_ARROW);
+ cntclass.hbrBackground = NULL;
+ cntclass.lpszMenuName = NULL;
+ cntclass.lpszClassName = _T("FramesContainer");
+ RegisterClass(&cntclass);
+ //end container helper
+
+ GapBetweenFrames = DBGetContactSettingDword(NULL,"CLUIFrames","GapBetweenFrames",1);
+
+ nFramescount = 0;
+ InitializeCriticalSection(&csFrameHook);
+ InitFramesMenus();
+
+ hHook[0] = HookEvent(ME_SYSTEM_MODULESLOADED,CLUIFrameOnModulesLoad);
+ hHook[1] = HookEvent(ME_CLIST_PREBUILDFRAMEMENU,CLUIFramesModifyContextMenuForFrame);
+ hHook[2] = HookEvent(ME_CLIST_PREBUILDMAINMENU,CLUIFrameOnMainMenuBuild);
+
+ hService[0] = CreateServiceFunction(MS_CLIST_FRAMES_ADDFRAME,CLUIFramesAddFrame);
+ hService[1] = CreateServiceFunction(MS_CLIST_FRAMES_REMOVEFRAME,CLUIFramesRemoveFrame);
+
+ hService[2] = CreateServiceFunction(MS_CLIST_FRAMES_SETFRAMEOPTIONS,CLUIFramesSetFrameOptions);
+ hService[3] = CreateServiceFunction(MS_CLIST_FRAMES_GETFRAMEOPTIONS,CLUIFramesGetFrameOptions);
+ hService[4] = CreateServiceFunction(MS_CLIST_FRAMES_UPDATEFRAME,CLUIFramesUpdateFrame);
+
+ hService[5] = CreateServiceFunction(MS_CLIST_FRAMES_SHFRAMETITLEBAR,CLUIFramesShowHideFrameTitleBar);
+ hService[6] = CreateServiceFunction(MS_CLIST_FRAMES_SHOWALLFRAMESTB,CLUIFramesShowAllTitleBars);
+ hService[7] = CreateServiceFunction(MS_CLIST_FRAMES_HIDEALLFRAMESTB,CLUIFramesHideAllTitleBars);
+ hService[8] = CreateServiceFunction(MS_CLIST_FRAMES_SHFRAME,CLUIFramesShowHideFrame);
+ hService[9] = CreateServiceFunction(MS_CLIST_FRAMES_SHOWALLFRAMES,CLUIFramesShowAll);
+
+ hService[10] = CreateServiceFunction(MS_CLIST_FRAMES_ULFRAME,CLUIFramesLockUnlockFrame);
+ hService[11] = CreateServiceFunction(MS_CLIST_FRAMES_UCOLLFRAME,CLUIFramesCollapseUnCollapseFrame);
+ hService[12] = CreateServiceFunction(MS_CLIST_FRAMES_SETUNBORDER,CLUIFramesSetUnSetBorder);
+
+ hService[13] = CreateServiceFunction(MS_CLUI_GETCAPS,CLUIGetCapsService);
+
+ hService[14] = CreateServiceFunction(CLUIFRAMESSETALIGN,CLUIFramesSetAlign);
+ hService[15] = CreateServiceFunction(CLUIFRAMESMOVEUPDOWN,CLUIFramesMoveUpDown);
+
+ hService[16] = CreateServiceFunction(CLUIFRAMESSETALIGNALTOP,CLUIFramesSetAlignalTop);
+ hService[17] = CreateServiceFunction(CLUIFRAMESSETALIGNALCLIENT,CLUIFramesSetAlignalClient);
+ hService[18] = CreateServiceFunction(CLUIFRAMESSETALIGNALBOTTOM,CLUIFramesSetAlignalBottom);
+
+ hService[19] = CreateServiceFunction("Set_Floating",CLUIFrameSetFloat);
+ hWndExplorerToolBar = FindWindowExA(0,0,"Shell_TrayWnd",NULL);
+ OnFrameTitleBarBackgroundChange(0,0);
+ FramesSysNotStarted = FALSE;
+ hHook[3] = HookEvent(ME_SYSTEM_PRESHUTDOWN, CLUIFrameOnModulesUnload);
+ return 0;
+}
+
+int UnLoadCLUIFramesModule(void)
+{
+ int i;
+ FramesSysNotStarted = TRUE;
+
+ for (i = 0; i<SIZEOF(hService); ++i)
+ DestroyServiceFunction(hService[i]);
+
+ for (i = 0; i<SIZEOF(hHook); ++i)
+ UnhookEvent(hHook[i]);
+
+ CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,0);
+ CLUIFramesStoreAllFrames();
+ lockfrm();
+ for (i = 0;i<nFramescount;i++) {
+ DestroyWindow(Frames[i].hWnd);
+ Frames[i].hWnd = (HWND)-1;
+ DestroyWindow(Frames[i].TitleBar.hwnd);
+ Frames[i].TitleBar.hwnd = (HWND)-1;
+ DestroyWindow(Frames[i].ContainerWnd);
+ Frames[i].ContainerWnd = (HWND)-1;
+ DestroyMenu(Frames[i].TitleBar.hmenu);
+
+ mir_free(Frames[i].name);
+ mir_free(Frames[i].TitleBar.tbname);
+ mir_free(Frames[i].TitleBar.tooltip);
+ }
+
+ if (Frames)
+ free(Frames);
+ Frames = NULL;
+ nFramescount = 0;
+ UnregisterClass(CLUIFrameTitleBarClassName,g_hInst);
+ DeleteObject(TitleBarFont);
+ ulockfrm();
+ DeleteCriticalSection(&csFrameHook);
+ return 0;
+}
diff --git a/plugins/Mwclist/CLUIFrames/extraimage.c b/plugins/Mwclist/CLUIFrames/extraimage.cpp
index 2124612a5d..04e086c167 100644
--- a/plugins/Mwclist/CLUIFrames/extraimage.c
+++ b/plugins/Mwclist/CLUIFrames/extraimage.cpp
@@ -2,7 +2,7 @@
extern int DefaultImageListColorDepth;
-int EnabledColumnCount=0;
+int EnabledColumnCount = 0;
boolean visar[EXTRACOLUMNCOUNT];
#define ExtraImageIconsIndexCount 3
int ExtraImageIconsIndex[ExtraImageIconsIndexCount];
@@ -18,10 +18,10 @@ extern int ClcIconsChanged(WPARAM,LPARAM);
void SetAllExtraIcons(HWND hwndList,HANDLE hContact);
void LoadExtraImageFunc();
-extern HICON LoadIconFromExternalFile (char *filename,int i,boolean UseLibrary,boolean registerit,char *IconName,char *SectName,char *Description,int internalidx);
-boolean ImageCreated=FALSE;
+HICON LoadIconFromExternalFile(char*, int, boolean, boolean, char*, char*, char*, int, HICON = NULL);
+boolean ImageCreated = FALSE;
void ReloadExtraIcons();
-BYTE ExtraOrder[]=
+BYTE ExtraOrder[] =
{
0, // EXTRA_ICON_EMAIL
1, // EXTRA_ICON_PROTO
@@ -41,13 +41,13 @@ BOOL HasExtraIconsService()
boolean isColumnVisible(int extra)
{
- int i=0;
+ int i = 0;
if (HasExtraIconsService())
return TRUE;
- for (i=0; i<sizeof(ExtraOrder)/sizeof(ExtraOrder[0]); i++)
- if (ExtraOrder[i]==extra)
+ for (i = 0; i<sizeof(ExtraOrder)/sizeof(ExtraOrder[0]); i++)
+ if (ExtraOrder[i] == extra)
{
switch(i+1)
{
@@ -68,15 +68,15 @@ boolean isColumnVisible(int extra)
void GetVisColumns()
{
- visar[0]=isColumnVisible(0);
- visar[1]=isColumnVisible(1);
- visar[2]=isColumnVisible(2);
- visar[3]=isColumnVisible(3);
- visar[4]=isColumnVisible(4);
- visar[5]=isColumnVisible(5);
- visar[6]=isColumnVisible(6);
- visar[7]=isColumnVisible(7);
- visar[8]=isColumnVisible(8);
+ visar[0] = isColumnVisible(0);
+ visar[1] = isColumnVisible(1);
+ visar[2] = isColumnVisible(2);
+ visar[3] = isColumnVisible(3);
+ visar[4] = isColumnVisible(4);
+ visar[5] = isColumnVisible(5);
+ visar[6] = isColumnVisible(6);
+ visar[7] = isColumnVisible(7);
+ visar[8] = isColumnVisible(8);
};
__inline int bti(boolean b)
@@ -90,10 +90,10 @@ int colsum(int from,int to)
if (to<0||to>=EXTRACOLUMNCOUNT){return(-1);};
if (to<from){return(-1);};
- sum=0;
- for (i=from;i<=to;i++)
+ sum = 0;
+ for (i = from;i<=to;i++)
{
- sum+=bti(visar[i]);
+ sum += bti(visar[i]);
};
return(sum);
};
@@ -109,9 +109,9 @@ int ExtraToColumnNum(int extra)
}
else
{
- int cnt=EnabledColumnCount;
- int extracnt=EXTRACOLUMNCOUNT-1;
- int ord=ExtraOrder[extra-1];
+ int cnt = EnabledColumnCount;
+ int extracnt = EXTRACOLUMNCOUNT-1;
+ int ord = ExtraOrder[extra-1];
if (!visar[ord]) return -1;
return (colsum(0,ord)-1);
}
@@ -124,8 +124,8 @@ int ColumnNumToExtra(int column)
if (HasExtraIconsService())
return column+1;
- for (i=0; i<sizeof(ExtraOrder)/sizeof(ExtraOrder[0]); i++)
- if (ExtraOrder[i]==column)
+ for (i = 0; i<sizeof(ExtraOrder)/sizeof(ExtraOrder[0]); i++)
+ if (ExtraOrder[i] == column)
return i+1;
return -1;
@@ -137,25 +137,25 @@ INT_PTR SetIconForExtraColumn(WPARAM wParam,LPARAM lParam)
int icol;
HANDLE hItem;
- if (pcli->hwndContactTree==0){return(-1);};
- if (wParam==0||lParam==0){return(-1);};
- piec=(pIconExtraColumn)lParam;
+ if (pcli->hwndContactTree == 0){return(-1);};
+ if (wParam == 0||lParam == 0){return(-1);};
+ piec = (pIconExtraColumn)lParam;
- if (piec->cbSize!=sizeof(IconExtraColumn)){return(-1);};
- icol=ExtraToColumnNum(piec->ColumnType);
- if (icol==-1){return(-1);};
- hItem=(HANDLE)SendMessage(pcli->hwndContactTree,CLM_FINDCONTACT,(WPARAM)wParam,0);
- if (hItem==0){return(-1);};
+ if (piec->cbSize != sizeof(IconExtraColumn)){return(-1);};
+ icol = ExtraToColumnNum(piec->ColumnType);
+ if (icol == -1){return(-1);};
+ hItem = (HANDLE)SendMessage(pcli->hwndContactTree,CLM_FINDCONTACT,(WPARAM)wParam,0);
+ if (hItem == 0){return(-1);};
SendMessage(pcli->hwndContactTree,CLM_SETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(icol,piec->hImage));
- return(0);
+ return 0;
};
-//wparam=hIcon
+//wparam = hIcon
//return hImage on success,-1 on failure
INT_PTR AddIconToExtraImageList(WPARAM wParam,LPARAM lParam)
{
- if (hExtraImageList==0||wParam==0){return(-1);};
+ if (hExtraImageList == 0||wParam == 0){return(-1);};
return((int)ImageList_AddIcon(hExtraImageList,(HICON)wParam));
}
@@ -164,23 +164,23 @@ void SetNewExtraColumnCount()
int newcount;
GetVisColumns();
- newcount=colsum(0,EXTRACOLUMNCOUNT-1);
+ newcount = colsum(0,EXTRACOLUMNCOUNT-1);
DBWriteContactSettingByte(NULL,CLUIFrameModule,"EnabledColumnCount",(BYTE)newcount);
- EnabledColumnCount=newcount;
+ EnabledColumnCount = newcount;
SendMessage(pcli->hwndContactTree,CLM_SETEXTRACOLUMNS,EnabledColumnCount,0);
}
int OnIconLibIconChanged(WPARAM wParam,LPARAM lParam)
{
HICON hicon;
- hicon=LoadIconFromExternalFile("clisticons.dll",0,TRUE,FALSE,"Email","Contact List","Email Icon",-IDI_EMAIL);
- ExtraImageIconsIndex[0]=ImageList_ReplaceIcon(hExtraImageList,ExtraImageIconsIndex[0],hicon );
+ hicon = LoadIconFromExternalFile("clisticons.dll",0,TRUE,FALSE,"Email","Contact List","Email Icon",-IDI_EMAIL);
+ ExtraImageIconsIndex[0] = ImageList_ReplaceIcon(hExtraImageList,ExtraImageIconsIndex[0],hicon );
- hicon=LoadIconFromExternalFile("clisticons.dll",1,TRUE,FALSE,"Sms","Contact List","Sms Icon",-IDI_SMS);
- ExtraImageIconsIndex[1]=ImageList_ReplaceIcon(hExtraImageList,ExtraImageIconsIndex[1],hicon );
+ hicon = LoadIconFromExternalFile("clisticons.dll",1,TRUE,FALSE,"Sms","Contact List","Sms Icon",-IDI_SMS);
+ ExtraImageIconsIndex[1] = ImageList_ReplaceIcon(hExtraImageList,ExtraImageIconsIndex[1],hicon );
- hicon=LoadIconFromExternalFile("clisticons.dll",4,TRUE,FALSE,"Web","Contact List","Web Icon",-IDI_GLOBUS);
- ExtraImageIconsIndex[2]=ImageList_ReplaceIcon(hExtraImageList,ExtraImageIconsIndex[2],hicon );
+ hicon = LoadIconFromExternalFile("clisticons.dll",4,TRUE,FALSE,"Web","Contact List","Web Icon",-IDI_GLOBUS);
+ ExtraImageIconsIndex[2] = ImageList_ReplaceIcon(hExtraImageList,ExtraImageIconsIndex[2],hicon );
NotifyEventHooks(ME_SKIN_ICONSCHANGED,0,0);
pcli->pfnClcBroadcast( INTM_INVALIDATE,0,0);
@@ -196,27 +196,27 @@ void ReloadExtraIcons()
SendMessage(pcli->hwndContactTree,CLM_SETEXTRACOLUMNSSPACE,DBGetContactSettingByte(NULL,"CLUI","ExtraColumnSpace",18),0);
SendMessage(pcli->hwndContactTree,CLM_SETEXTRAIMAGELIST,0,(LPARAM)NULL);
if (hExtraImageList){ImageList_Destroy(hExtraImageList);};
- hExtraImageList=ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),ILC_COLOR32|ILC_MASK,1,256);
+ hExtraImageList = ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),ILC_COLOR32|ILC_MASK,1,256);
if (!HasExtraIconsService())
{
//loading icons
- hicon=LoadIconFromExternalFile("clisticons.dll",0,TRUE,TRUE,"Email","Contact List","Email Icon",-IDI_EMAIL);
- if (!hicon) hicon=LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_EMAIL));
- ExtraImageIconsIndex[0]=ImageList_AddIcon(hExtraImageList,hicon );
+ hicon = LoadIconFromExternalFile("clisticons.dll",0,TRUE,TRUE,"Email","Contact List","Email Icon",-IDI_EMAIL);
+ if (!hicon) hicon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_EMAIL));
+ ExtraImageIconsIndex[0] = ImageList_AddIcon(hExtraImageList,hicon );
- hicon=LoadIconFromExternalFile("clisticons.dll",1,TRUE,TRUE,"Sms","Contact List","Sms Icon",-IDI_SMS);
- if (!hicon) hicon=LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_SMS));
- ExtraImageIconsIndex[1]=ImageList_AddIcon(hExtraImageList,hicon );
+ hicon = LoadIconFromExternalFile("clisticons.dll",1,TRUE,TRUE,"Sms","Contact List","Sms Icon",-IDI_SMS);
+ if (!hicon) hicon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_SMS));
+ ExtraImageIconsIndex[1] = ImageList_AddIcon(hExtraImageList,hicon );
- hicon=LoadIconFromExternalFile("clisticons.dll",4,TRUE,TRUE,"Web","Contact List","Web Icon",-IDI_GLOBUS);
- if (!hicon) hicon=LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_GLOBUS));
- ExtraImageIconsIndex[2]=ImageList_AddIcon(hExtraImageList,hicon );
+ hicon = LoadIconFromExternalFile("clisticons.dll",4,TRUE,TRUE,"Web","Contact List","Web Icon",-IDI_GLOBUS);
+ if (!hicon) hicon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_GLOBUS));
+ ExtraImageIconsIndex[2] = ImageList_AddIcon(hExtraImageList,hicon );
//calc only needed protocols
ProtoEnumAccounts( &count, &accs );
- for ( i=0; i < count; i++ )
+ for ( i = 0; i < count; i++ )
if ( IsAccountEnabled( accs[i] ) && CallProtoService( accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0 ))
ImageList_AddIcon( hExtraImageList, LoadSkinnedProtoIcon( accs[i]->szModuleName, ID_STATUS_ONLINE ));
}
@@ -226,7 +226,7 @@ void ReloadExtraIcons()
//SetAllExtraIcons(hImgList);
SetNewExtraColumnCount();
NotifyEventHooks(hExtraImageListRebuilding,0,0);
- ImageCreated=TRUE;
+ ImageCreated = TRUE;
}
void ClearExtraIcons();
@@ -244,60 +244,59 @@ void ClearExtraIcons()
int i;
HANDLE hContact,hItem;
- //EnabledColumnCount=DBGetContactSettingByte(NULL,CLUIFrameModule,"EnabledColumnCount",5);
+ //EnabledColumnCount = DBGetContactSettingByte(NULL,CLUIFrameModule,"EnabledColumnCount",5);
//SendMessage(pcli->hwndContactTree,CLM_SETEXTRACOLUMNS,EnabledColumnCount,0);
SetNewExtraColumnCount();
- hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0);
+ hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0);
do {
- hItem=(HANDLE)SendMessage(pcli->hwndContactTree,CLM_FINDCONTACT,(WPARAM)hContact,0);
- if (hItem==0){continue;};
- for (i=0;i<EnabledColumnCount;i++)
+ hItem = (HANDLE)SendMessage(pcli->hwndContactTree,CLM_FINDCONTACT,(WPARAM)hContact,0);
+ if (hItem == 0){continue;};
+ for (i = 0;i<EnabledColumnCount;i++)
{
SendMessage(pcli->hwndContactTree,CLM_SETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(i,0xFF));
};
- } while(hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0));
+ } while(hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0));
};
void SetAllExtraIcons(HWND hwndList,HANDLE hContact)
{
HANDLE hItem;
- boolean hcontgiven=FALSE;
+ boolean hcontgiven = FALSE;
char *szProto;
char *ImgIndex[64];
int maxpr,count,i;
PROTOACCOUNT **accs;
pdisplayNameCacheEntry pdnce;
int em,pr,sms,a1,a2,w1,c1;
- int tick=0;
+ int tick = 0;
BOOL hasExtraIconsService;
- hcontgiven=(hContact!=0);
+ hcontgiven = (hContact != 0);
- if (pcli->hwndContactTree==0){return;};
- tick=GetTickCount();
- if (ImageCreated==FALSE) ReloadExtraIcons();
+ if (pcli->hwndContactTree == 0){return;};
+ tick = GetTickCount();
+ if (ImageCreated == FALSE) ReloadExtraIcons();
SetNewExtraColumnCount();
hasExtraIconsService = HasExtraIconsService();
- if (!hasExtraIconsService)
- {
- em=ExtraToColumnNum(EXTRA_ICON_EMAIL);
- pr=ExtraToColumnNum(EXTRA_ICON_PROTO);
- sms=ExtraToColumnNum(EXTRA_ICON_SMS);
- a1=ExtraToColumnNum(EXTRA_ICON_ADV1);
- a2=ExtraToColumnNum(EXTRA_ICON_ADV2);
- w1=ExtraToColumnNum(EXTRA_ICON_WEB);
- c1=ExtraToColumnNum(EXTRA_ICON_CLIENT);
+ if (!hasExtraIconsService) {
+ em = ExtraToColumnNum(EXTRA_ICON_EMAIL);
+ pr = ExtraToColumnNum(EXTRA_ICON_PROTO);
+ sms = ExtraToColumnNum(EXTRA_ICON_SMS);
+ a1 = ExtraToColumnNum(EXTRA_ICON_ADV1);
+ a2 = ExtraToColumnNum(EXTRA_ICON_ADV2);
+ w1 = ExtraToColumnNum(EXTRA_ICON_WEB);
+ c1 = ExtraToColumnNum(EXTRA_ICON_CLIENT);
memset(ImgIndex,0,sizeof(ImgIndex));
ProtoEnumAccounts( &count, &accs );
- maxpr=0;
+ maxpr = 0;
//calc only needed protocols
- for ( i=0; i < count; i++ ) {
+ for ( i = 0; i < count; i++ ) {
if ( !IsAccountEnabled( accs[i] ) || CallProtoService( accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0 ) == 0 )
continue;
ImgIndex[maxpr] = accs[i]->szModuleName;
@@ -306,33 +305,33 @@ void SetAllExtraIcons(HWND hwndList,HANDLE hContact)
}
if ( hContact == NULL )
- hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0);
+ hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0);
do {
- szProto=NULL;
- hItem=hContact;
- if (hItem==0){continue;};
- pdnce=(pdisplayNameCacheEntry)pcli->pfnGetCacheEntry(hItem);
- if (pdnce==NULL) {continue;};
+ szProto = NULL;
+ hItem = hContact;
+ if (hItem == 0){continue;};
+ pdnce = (pdisplayNameCacheEntry)pcli->pfnGetCacheEntry(hItem);
+ if (pdnce == NULL) {continue;};
- // szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0);
- szProto=pdnce->szProto;
+ // szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0);
+ szProto = pdnce->szProto;
if (!hasExtraIconsService)
{
- if (ExtraToColumnNum(EXTRA_ICON_WEB)!=-1)
+ if (ExtraToColumnNum(EXTRA_ICON_WEB) != -1)
{
- boolean showweb=FALSE;
+ boolean showweb = FALSE;
if (szProto != NULL)
{
char *homepage;
- homepage=DBGetStringA(pdnce->hContact,"UserInfo", "Homepage");
+ homepage = DBGetStringA(pdnce->hContact,"UserInfo", "Homepage");
if (!homepage)
- homepage=DBGetStringA(pdnce->hContact,pdnce->szProto, "Homepage");
- if (homepage!=NULL)
+ homepage = DBGetStringA(pdnce->hContact,pdnce->szProto, "Homepage");
+ if (homepage != NULL)
{
- showweb=TRUE;
+ showweb = TRUE;
mir_free(homepage);
}
}
@@ -340,39 +339,39 @@ void SetAllExtraIcons(HWND hwndList,HANDLE hContact)
SendMessage(hwndList,CLM_SETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(ExtraToColumnNum(EXTRA_ICON_WEB),(showweb)?2:0xFF));
}
- if (ExtraToColumnNum(EXTRA_ICON_EMAIL)!=-1)
+ if (ExtraToColumnNum(EXTRA_ICON_EMAIL) != -1)
{
- DBVARIANT dbv={0};
- boolean showemail=TRUE;
+ DBVARIANT dbv = {0};
+ boolean showemail = TRUE;
if (szProto == NULL || DBGetContactSettingString(hContact, szProto, "e-mail",&dbv))
{
DBFreeVariant(&dbv);
if (DBGetContactSettingString(hContact, "UserInfo", "Mye-mail0", &dbv))
- showemail=FALSE;
+ showemail = FALSE;
}
DBFreeVariant(&dbv);
SendMessage(hwndList,CLM_SETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(ExtraToColumnNum(EXTRA_ICON_EMAIL),(showemail)?0:0xFF));
}
- if (ExtraToColumnNum(EXTRA_ICON_SMS)!=-1)
+ if (ExtraToColumnNum(EXTRA_ICON_SMS) != -1)
{
- DBVARIANT dbv={0};
- boolean showsms=TRUE;
+ DBVARIANT dbv = {0};
+ boolean showsms = TRUE;
if (szProto == NULL || DBGetContactSettingString(hContact, szProto, "Cellular",&dbv)) {
DBFreeVariant(&dbv);
if (DBGetContactSettingString(hContact, "UserInfo", "MyPhone0", &dbv))
- showsms=FALSE;
+ showsms = FALSE;
}
SendMessage(hwndList,CLM_SETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(ExtraToColumnNum(EXTRA_ICON_SMS),(showsms)?1:0xFF));
DBFreeVariant(&dbv);
}
- if(ExtraToColumnNum(EXTRA_ICON_PROTO)!=-1)
+ if (ExtraToColumnNum(EXTRA_ICON_PROTO) != -1)
{
- for (i=0;i<maxpr;i++)
+ for (i = 0;i<maxpr;i++)
{
if (!MyStrCmp(ImgIndex[i],szProto))
{
@@ -387,9 +386,9 @@ void SetAllExtraIcons(HWND hwndList,HANDLE hContact)
if (hcontgiven) break;
Sleep(0);
}
- while(hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0));
+ while(hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0));
- tick=GetTickCount()-tick;
+ tick = GetTickCount()-tick;
InvalidateRect(hwndList,NULL,FALSE);
Sleep(0);
}
@@ -399,8 +398,8 @@ void LoadExtraImageFunc()
CreateServiceFunction(MS_CLIST_EXTRA_SET_ICON,SetIconForExtraColumn);
CreateServiceFunction(MS_CLIST_EXTRA_ADD_ICON,AddIconToExtraImageList);
- hExtraImageListRebuilding=CreateHookableEvent(ME_CLIST_EXTRA_LIST_REBUILD);
- hExtraImageApplying=CreateHookableEvent(ME_CLIST_EXTRA_IMAGE_APPLY);
- hExtraImageClick=CreateHookableEvent(ME_CLIST_EXTRA_CLICK);
+ hExtraImageListRebuilding = CreateHookableEvent(ME_CLIST_EXTRA_LIST_REBUILD);
+ hExtraImageApplying = CreateHookableEvent(ME_CLIST_EXTRA_IMAGE_APPLY);
+ hExtraImageClick = CreateHookableEvent(ME_CLIST_EXTRA_CLICK);
HookEvent(ME_SKIN2_ICONSCHANGED,OnIconLibIconChanged);
}
diff --git a/plugins/Mwclist/CLUIFrames/framesmenu.c b/plugins/Mwclist/CLUIFrames/framesmenu.cpp
index efc8254995..fc47474b2a 100644
--- a/plugins/Mwclist/CLUIFrames/framesmenu.c
+++ b/plugins/Mwclist/CLUIFrames/framesmenu.cpp
@@ -1,6 +1,6 @@
#include "../commonheaders.h"
-//==========================Frames
+// == == == == == == == == == == == == == Frames
HANDLE hFrameMenuObject;
static HANDLE hPreBuildFrameMenuEvent;
extern int InitCustomMenus(void);
@@ -27,41 +27,41 @@ INT_PTR FreeOwnerDataFrameMenu (WPARAM wParam,LPARAM lParam)
{
lpFrameMenuExecParam cmep;
- cmep=(lpFrameMenuExecParam)lParam;
- if (cmep!=NULL){
- FreeAndNil(&cmep->szServiceName);
- FreeAndNil(&cmep);
+ cmep = (lpFrameMenuExecParam)lParam;
+ if (cmep != NULL){
+ FreeAndNil((void**)&cmep->szServiceName);
+ FreeAndNil((void**)&cmep);
}
- return(0);
+ return 0;
}
static INT_PTR AddContextFrameMenuItem(WPARAM wParam,LPARAM lParam)
{
- CLISTMENUITEM *mi=(CLISTMENUITEM*)lParam;
+ CLISTMENUITEM *mi = (CLISTMENUITEM*)lParam;
TMO_MenuItem tmi;
- if(mi->cbSize!=sizeof(CLISTMENUITEM)) return 0;
+ if (mi->cbSize != sizeof(CLISTMENUITEM)) return 0;
memset(&tmi,0,sizeof(tmi));
- tmi.cbSize=sizeof(tmi);
- tmi.flags=mi->flags;
- tmi.hIcon=mi->hIcon;
- tmi.hotKey=mi->hotKey;
- tmi.position=mi->position;
- tmi.pszName=mi->pszName;
+ tmi.cbSize = sizeof(tmi);
+ tmi.flags = mi->flags;
+ tmi.hIcon = mi->hIcon;
+ tmi.hotKey = mi->hotKey;
+ tmi.position = mi->position;
+ tmi.pszName = mi->pszName;
- if(mi->flags&CMIF_ROOTPOPUP||mi->flags&CMIF_CHILDPOPUP)
+ if (mi->flags&CMIF_ROOTPOPUP||mi->flags&CMIF_CHILDPOPUP)
tmi.root = mi->hParentMenu;
{
lpFrameMenuExecParam fmep;
- fmep=(lpFrameMenuExecParam)mir_alloc(sizeof(FrameMenuExecParam));
- if (fmep==NULL){return(0);}
- fmep->szServiceName=mir_strdup(mi->pszService);
- fmep->Frameid=mi->popupPosition;
- fmep->param1=(INT_PTR)mi->pszContactOwner;
+ fmep = (lpFrameMenuExecParam)mir_alloc(sizeof(FrameMenuExecParam));
+ if (fmep == NULL){return 0;}
+ fmep->szServiceName = mir_strdup(mi->pszService);
+ fmep->Frameid = mi->popupPosition;
+ fmep->param1 = (INT_PTR)mi->pszContactOwner;
- tmi.ownerdata=fmep;
+ tmi.ownerdata = fmep;
}
return(CallService(MO_ADDNEWMENUITEM,(WPARAM)hFrameMenuObject,(LPARAM)&tmi));
@@ -71,11 +71,11 @@ static INT_PTR RemoveContextFrameMenuItem(WPARAM wParam,LPARAM lParam)
{
/* this do by free service
lpFrameMenuExecParam fmep;
- fmep=(lpFrameMenuExecParam)CallService(MO_MENUITEMGETOWNERDATA,wParam,lParam);
- if (fmep!=NULL){
- if (fmep->szServiceName!=NULL){
+ fmep = (lpFrameMenuExecParam)CallService(MO_MENUITEMGETOWNERDATA,wParam,lParam);
+ if (fmep != NULL){
+ if (fmep->szServiceName != NULL){
mir_free(fmep->szServiceName);
- fmep->szServiceName=NULL;
+ fmep->szServiceName = NULL;
}
mir_free(fmep);
}
@@ -89,64 +89,62 @@ static INT_PTR RemoveContextFrameMenuItem(WPARAM wParam,LPARAM lParam)
//lparam - lparam from winproc
INT_PTR FrameMenuExecService(WPARAM wParam,LPARAM lParam)
{
- lpFrameMenuExecParam fmep=(lpFrameMenuExecParam)wParam;
- if (fmep==NULL){return(-1);}
+ lpFrameMenuExecParam fmep = (lpFrameMenuExecParam)wParam;
+ if (fmep == NULL){return(-1);}
CallService(fmep->szServiceName,lParam,fmep->param1);
- return(0);
+ return 0;
}
//true - ok,false ignore
INT_PTR FrameMenuCheckService(WPARAM wParam,LPARAM lParam)
{
- PCheckProcParam pcpp=(PCheckProcParam)wParam;
- lpFrameMenuExecParam fmep;
- TMO_MenuItem mi;
+ PCheckProcParam pcpp = (PCheckProcParam)wParam;
+ if (pcpp == NULL)
+ return FALSE;
- if (pcpp==NULL){return(FALSE);}
- if (CallService(MO_GETMENUITEM,(WPARAM)pcpp->MenuItemHandle,(LPARAM)&mi)==0)
- {
- fmep=mi.ownerdata;
- if (fmep!=NULL)
- {
+ TMO_MenuItem mi;
+ if (CallService(MO_GETMENUITEM,(WPARAM)pcpp->MenuItemHandle,(LPARAM)&mi) == 0) {
+ lpFrameMenuExecParam fmep = (lpFrameMenuExecParam)mi.ownerdata;
+ if (fmep != NULL) {
//pcpp->wParam - frameid
- if (((WPARAM)fmep->Frameid==pcpp->wParam)||fmep->Frameid==-1) return(TRUE);
+ if (((WPARAM)fmep->Frameid == pcpp->wParam)||fmep->Frameid == -1) return(TRUE);
}
}
- return(FALSE);
+ return FALSE;
}
static INT_PTR ContextFrameMenuNotify(WPARAM wParam,LPARAM lParam)
{
NotifyEventHooks(hPreBuildFrameMenuEvent,wParam,lParam);
- return(0);
+ return 0;
}
static INT_PTR BuildContextFrameMenu(WPARAM wParam,LPARAM lParam)
{
- CLISTMENUITEM *mi=(CLISTMENUITEM*)lParam;
+ CLISTMENUITEM *mi = (CLISTMENUITEM*)lParam;
HMENU hMenu;
ListParam param = { 0 };
- param.MenuObjectHandle=hFrameMenuObject;
- param.wParam=wParam;
- param.lParam=lParam;
+ param.MenuObjectHandle = hFrameMenuObject;
+ param.wParam = wParam;
+ param.lParam = lParam;
- hMenu=CreatePopupMenu();
+ hMenu = CreatePopupMenu();
//NotifyEventHooks(hPreBuildFrameMenuEvent,wParam,-1);
ContextFrameMenuNotify(wParam,-1);
CallService(MO_BUILDMENU,(WPARAM)hMenu,(LPARAM)&param);
return (INT_PTR)hMenu;
}
-//==========================Frames end
-boolean InternalGenMenuModule=FALSE;
+// == == == == == == == == == == == == == Frames end
+boolean InternalGenMenuModule = FALSE;
int MeasureItemProxy(WPARAM wParam,LPARAM lParam)
{
int val;
if (InternalGenMenuModule)
{
- val=CallService(MS_INT_MENUMEASUREITEM,wParam,lParam);
+ val = CallService(MS_INT_MENUMEASUREITEM,wParam,lParam);
if (val) return(val);
}
return CallService(MS_CLIST_MENUMEASUREITEM,wParam,lParam);
@@ -157,7 +155,7 @@ int DrawItemProxy(WPARAM wParam,LPARAM lParam)
if (InternalGenMenuModule)
{
int val;
- val=CallService(MS_INT_MENUDRAWITEM,wParam,lParam);
+ val = CallService(MS_INT_MENUDRAWITEM,wParam,lParam);
if (val) return(val);
}
return CallService(MS_CLIST_MENUDRAWITEM,wParam,lParam);
@@ -168,7 +166,7 @@ int ProcessCommandProxy(WPARAM wParam,LPARAM lParam)
if (InternalGenMenuModule)
{
int val;
- val=CallService(MS_INT_MENUPROCESSCOMMAND,wParam,lParam);
+ val = CallService(MS_INT_MENUPROCESSCOMMAND,wParam,lParam);
if (val) return(val);
}
@@ -181,7 +179,7 @@ int ModifyMenuItemProxy(WPARAM wParam,LPARAM lParam)
if (InternalGenMenuModule)
{
int val;
- val=CallService(MS_INT_MODIFYMENUITEM,wParam,lParam);
+ val = CallService(MS_INT_MODIFYMENUITEM,wParam,lParam);
if (val) return(val);
}
@@ -196,7 +194,7 @@ int InitFramesMenus(void)
{
InitCustomMenus();
- InternalGenMenuModule=TRUE;
+ InternalGenMenuModule = TRUE;
}
if (ServiceExists(MO_REMOVEMENUOBJECT))
@@ -210,20 +208,20 @@ int InitFramesMenus(void)
CreateServiceFunction(MS_CLIST_ADDCONTEXTFRAMEMENUITEM,AddContextFrameMenuItem);
CreateServiceFunction(MS_CLIST_MENUBUILDFRAMECONTEXT,BuildContextFrameMenu);
CreateServiceFunction(MS_CLIST_FRAMEMENUNOTIFY,ContextFrameMenuNotify);
- hPreBuildFrameMenuEvent=CreateHookableEvent(ME_CLIST_PREBUILDFRAMEMENU);
+ hPreBuildFrameMenuEvent = CreateHookableEvent(ME_CLIST_PREBUILDFRAMEMENU);
//frame menu object
memset(&tmp,0,sizeof(tmp));
- tmp.cbSize=sizeof(tmp);
- tmp.CheckService="FrameMenuCheckService";
- tmp.ExecService="FrameMenuExecService";
- tmp.name="FrameMenu";
- hFrameMenuObject=(HANDLE)CallService(MO_CREATENEWMENUOBJECT,0,(LPARAM)&tmp);
+ tmp.cbSize = sizeof(tmp);
+ tmp.CheckService = "FrameMenuCheckService";
+ tmp.ExecService = "FrameMenuExecService";
+ tmp.name = "FrameMenu";
+ hFrameMenuObject = (HANDLE)CallService(MO_CREATENEWMENUOBJECT,0,(LPARAM)&tmp);
{
OptParam op;
- op.Handle=hFrameMenuObject;
- op.Setting=OPT_MENUOBJECT_SET_FREE_SERVICE;
- op.Value=(INT_PTR)"FrameMenuFreeService";
+ op.Handle = hFrameMenuObject;
+ op.Setting = OPT_MENUOBJECT_SET_FREE_SERVICE;
+ op.Value = (INT_PTR)"FrameMenuFreeService";
CallService(MO_SETOPTIONSMENUOBJECT,(WPARAM)0,(LPARAM)&op);
}
}
diff --git a/plugins/Mwclist/CLUIFrames/statusbar.c b/plugins/Mwclist/CLUIFrames/statusbar.c
deleted file mode 100644
index a682c9a632..0000000000
--- a/plugins/Mwclist/CLUIFrames/statusbar.c
+++ /dev/null
@@ -1,630 +0,0 @@
-#include "../commonheaders.h"
-
-extern HINSTANCE g_hInst;
-HANDLE hStatusBarShowToolTipEvent,hStatusBarHideToolTipEvent;
-boolean canloadstatusbar=FALSE;
-HWND helperhwnd=0;
-HANDLE hFrameHelperStatusBar;
-extern int CluiProtocolStatusChanged(WPARAM wParam,LPARAM lParam);
-extern INT_PTR GetConnectingIconService (WPARAM wParam,LPARAM lParam);
-extern int CluiProtocolStatusChanged(WPARAM wParam,LPARAM lParam);
-int RecreateStatusBar();
-
-int UseOwnerDrawStatusBar;
-
-
-#define TM_STATUSBAR 23435234
-#define TM_STATUSBARHIDE 23435235
-boolean tooltipshoing;
-WNDPROC OldWindowProc=NULL;
-
-
-POINT lastpnt;
-RECT OldRc={0};
-static HBITMAP hBmpBackground;
-static int backgroundBmpUse;
-static COLORREF bkColour;
-extern BYTE showOpts;
-int extraspace;
-
-int OnStatusBarBackgroundChange()
-{
- {
- DBVARIANT dbv;
- showOpts=DBGetContactSettingByte(NULL,"CLUI","SBarShow",1);
- bkColour=DBGetContactSettingDword(NULL,"StatusBar","BkColour",CLCDEFAULT_BKCOLOUR);
- if(hBmpBackground) {DeleteObject(hBmpBackground); hBmpBackground=NULL;}
- if(DBGetContactSettingByte(NULL,"StatusBar","UseBitmap",CLCDEFAULT_USEBITMAP)) {
- if (!DBGetContactSettingString(NULL,"StatusBar","BkBitmap",&dbv)) {
- hBmpBackground=(HBITMAP)CallService(MS_UTILS_LOADBITMAP,0,(LPARAM)dbv.pszVal);
- mir_free(dbv.pszVal);
- }
- }
- backgroundBmpUse=DBGetContactSettingWord(NULL,"StatusBar","BkBmpUse",CLCDEFAULT_BKBMPUSE);
- extraspace=DBGetContactSettingDword(NULL,"StatusBar","BkExtraSpace",0);
- }
-
- RecreateStatusBar(pcli->hwndContactList);
- if (pcli->hwndStatus) InvalidateRect(pcli->hwndStatus,NULL,TRUE);
- return 0;
-}
-
-
-void DrawDataForStatusBar(LPDRAWITEMSTRUCT dis)
-{
- //LPDRAWITEMSTRUCT dis=(LPDRAWITEMSTRUCT)lParam;
- ProtocolData *PD=(ProtocolData *)dis->itemData;
- char *szProto=(char*)dis->itemData;
- int status,x;
- SIZE textSize;
- boolean NeedDestroy=FALSE;
- HICON hIcon;
- HRGN hrgn;
-
-
- if (PD==NULL){return;}
- if (dis->hDC==NULL) {return;}
-
- //clip it
-
- hrgn = CreateRectRgn(dis->rcItem.left, dis->rcItem.top,
- dis->rcItem.right, dis->rcItem.bottom);
-
- SelectClipRgn(dis->hDC, hrgn);
-
- szProto=PD->RealName;
-#ifdef _DEBUG
- {
- //char buf[512];
- //sprintf(buf,"proto: %s draw at pos: %d\r\n",szProto,dis->rcItem.left);
- //OutputDebugStringA(buf);
- }
-#endif
-
- status=CallProtoService(szProto,PS_GETSTATUS,0,0);
- SetBkMode(dis->hDC,TRANSPARENT);
- x=dis->rcItem.left+extraspace;
-
- if(showOpts&1)
- {
- if ((DBGetContactSettingByte(NULL,"CLUI","UseConnectingIcon",1)==1) && status < ID_STATUS_OFFLINE)
- {
- hIcon=(HICON)GetConnectingIconService((WPARAM)szProto,0);
-
- if (hIcon)
- {
- NeedDestroy=TRUE;
- }else
- {
- hIcon=LoadSkinnedProtoIcon(szProto,status);
- }
-
- }else
- {
- hIcon=LoadSkinnedProtoIcon(szProto,status);
- }
- DrawIconEx(dis->hDC,x,(dis->rcItem.top+dis->rcItem.bottom-GetSystemMetrics(SM_CYSMICON))>>1,hIcon,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),0,NULL,DI_NORMAL);
- if (NeedDestroy) DestroyIcon(hIcon);
- x+=GetSystemMetrics(SM_CXSMICON)+2;
- }
- else x+=2;
- if(showOpts&2) {
- TCHAR szName[64];
-
- PROTOACCOUNT* pa = ProtoGetAccount(szProto);
- mir_sntprintf(szName, SIZEOF(szName), _T("%s%s"), pa->tszAccountName, showOpts&4 ? _T(" ") : _T(""));
- GetTextExtentPoint32(dis->hDC, szName, (int)_tcslen(szName), &textSize);
-
- TextOut(dis->hDC,x,(dis->rcItem.top+dis->rcItem.bottom-textSize.cy)>>1,szName,lstrlen(szName));
- x+=textSize.cx;
- }
- if(showOpts&4) {
- TCHAR *szStatus = pcli->pfnGetStatusModeDescription(status, 0);
- if (!szStatus) szStatus = _T("");
- GetTextExtentPoint32(dis->hDC,szStatus,lstrlen(szStatus),&textSize);
- TextOut(dis->hDC,x,(dis->rcItem.top+dis->rcItem.bottom-textSize.cy)>>1,szStatus,lstrlen(szStatus));
- }
- SelectClipRgn(dis->hDC, NULL);
- DeleteObject(hrgn);
-}
-
-void DrawBackGround(HWND hwnd,HDC mhdc)
-{
- HDC hdcMem,hdc;
- RECT clRect,*rcPaint;
-
- int yScroll=0;
- int y;
- PAINTSTRUCT paintst={0};
- HBITMAP hBmpOsb,holdbmp;
- DWORD style=GetWindowLongPtr(hwnd,GWL_STYLE);
- int grey=0;
- HFONT oFont;
- HBRUSH hBrushAlternateGrey=NULL;
-
- HFONT hFont;
-
- //InvalidateRect(hwnd,0,FALSE);
-
- hFont=(HFONT)SendMessage(hwnd,WM_GETFONT,0,0);
-
- if (mhdc)
- {
- hdc=mhdc;
- rcPaint=NULL;
- }else
- {
- hdc=BeginPaint(hwnd,&paintst);
- rcPaint=&(paintst.rcPaint);
- }
-
- GetClientRect(hwnd,&clRect);
- if(rcPaint==NULL) rcPaint=&clRect;
- if (rcPaint->right-rcPaint->left==0||rcPaint->top-rcPaint->bottom==0) rcPaint=&clRect;
- y=-yScroll;
- hdcMem=CreateCompatibleDC(hdc);
- hBmpOsb=CreateBitmap(clRect.right,clRect.bottom,1,GetDeviceCaps(hdc,BITSPIXEL),NULL);
- holdbmp=SelectObject(hdcMem,hBmpOsb);
- oFont=SelectObject(hdcMem,hFont);
- SetBkMode(hdcMem,TRANSPARENT);
- { HBRUSH hBrush,hoBrush;
-
- hBrush=CreateSolidBrush(bkColour);
- hoBrush=(HBRUSH)SelectObject(hdcMem,hBrush);
- FillRect(hdcMem,rcPaint,hBrush);
- SelectObject(hdcMem,hoBrush);
- DeleteObject(hBrush);
- if(hBmpBackground) {
- BITMAP bmp;
- HDC hdcBmp,holdbackbmp;
- int x,y;
- int maxx,maxy;
- int destw,desth;
-
- GetObject(hBmpBackground,sizeof(bmp),&bmp);
- hdcBmp=CreateCompatibleDC(hdcMem);
- holdbackbmp=SelectObject(hdcBmp,hBmpBackground);
- y=backgroundBmpUse&CLBF_SCROLL?-yScroll:0;
- maxx=backgroundBmpUse&CLBF_TILEH?clRect.right:1;
- maxy=backgroundBmpUse&CLBF_TILEV?maxy=rcPaint->bottom:y+1;
- switch(backgroundBmpUse&CLBM_TYPE) {
- case CLB_STRETCH:
- if(backgroundBmpUse&CLBF_PROPORTIONAL) {
- if(clRect.right*bmp.bmHeight<clRect.bottom*bmp.bmWidth) {
- desth=clRect.bottom;
- destw=desth*bmp.bmWidth/bmp.bmHeight;
- }
- else {
- destw=clRect.right;
- desth=destw*bmp.bmHeight/bmp.bmWidth;
- }
- }
- else {
- destw=clRect.right;
- desth=clRect.bottom;
- }
- break;
- case CLB_STRETCHH:
- if(backgroundBmpUse&CLBF_PROPORTIONAL) {
- destw=clRect.right;
- desth=destw*bmp.bmHeight/bmp.bmWidth;
- }
- else {
- destw=clRect.right;
- desth=bmp.bmHeight;
- }
- break;
- case CLB_STRETCHV:
- if(backgroundBmpUse&CLBF_PROPORTIONAL) {
- desth=clRect.bottom;
- destw=desth*bmp.bmWidth/bmp.bmHeight;
- }
- else {
- destw=bmp.bmWidth;
- desth=clRect.bottom;
- }
- break;
- default: //clb_topleft
- destw=bmp.bmWidth;
- desth=bmp.bmHeight;
- break;
- }
- desth=clRect.bottom -clRect.top;
- for (;y<maxy;y+=desth) {
- if(y<rcPaint->top-desth) continue;
- for(x=0;x<maxx;x+=destw)
- StretchBlt(hdcMem,x,y,destw,desth,hdcBmp,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
- }
- SelectObject(hdcBmp,holdbackbmp);
- DeleteDC(hdcBmp);
- }
- }
-
- //call to draw icons
- {
- DRAWITEMSTRUCT ds;
- int nParts,nPanel;
- ProtocolData *PD;
- RECT rc,clrc;
- int startoffset,sectwidth;
-
- memset(&ds,0,sizeof(ds));
- ds.hwndItem=hwnd;
- ds.hDC=hdcMem;
-
-
- startoffset=DBGetContactSettingDword(NULL,"StatusBar","FirstIconOffset",0);
- extraspace=DBGetContactSettingDword(NULL,"StatusBar","BkExtraSpace",0);
-
- nParts=SendMessage(hwnd,SB_GETPARTS,0,0);
- memset(&rc,0,sizeof(RECT));
- GetClientRect(hwnd,&clrc);
- clrc.right-=clrc.left;
- clrc.right-=startoffset;
- sectwidth=clrc.right/nParts;
-
- for (nPanel=0;nPanel<nParts;nPanel++)
- {
- PD=(ProtocolData *)SendMessage(pcli->hwndStatus,SB_GETTEXT,(WPARAM)nPanel,(LPARAM)0);
- if(PD==NULL){
- continue;
- }
- SendMessage(hwnd,SB_GETRECT,(WPARAM)nPanel,(LPARAM)&rc);
- //rc.left+=startoffset;
- //if (rc.left>=rc.right) rc.left=rc.right-1;
- rc.top=0;
- rc.left=nPanel*sectwidth+startoffset;
- rc.right=rc.left+sectwidth-1;
- ds.rcItem=rc;
- ds.itemData=(ULONG_PTR)PD;
- ds.itemID=nPanel;
-
- DrawDataForStatusBar(&ds);
- } }
-
- BitBlt(hdc,rcPaint->left,rcPaint->top,rcPaint->right-rcPaint->left,rcPaint->bottom-rcPaint->top,hdcMem,rcPaint->left,rcPaint->top,SRCCOPY);
-
- SelectObject(hdcMem,holdbmp);
- SelectObject(hdcMem,oFont);
- DeleteObject(hBmpOsb);
- DeleteDC(hdcMem);
- paintst.fErase=FALSE;
- //DeleteObject(hFont);
- if (!mhdc)
- EndPaint(hwnd,&paintst);
-}
-
-LRESULT CALLBACK StatusBarOwnerDrawProc( HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam
-)
-{
-if (UseOwnerDrawStatusBar)
-{
- switch(uMsg)
- {
- case WM_ERASEBKGND:
- {
-
- //DrawBackGround(hwnd);
- return 0;
- }
- case WM_PRINT:
- {
- DrawBackGround(hwnd,(HDC)wParam);
- return 0;
- }
- case WM_PAINT:
- {
- DrawBackGround(hwnd,0);
- return 0;
- }
- }
-
-}
-return (CallWindowProc(OldWindowProc,hwnd,uMsg,wParam,lParam)
- );
-}
-
-LRESULT CALLBACK StatusHelperProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- switch(msg)
- {
- case WM_CREATE:
- {
- {
- tooltipshoing=FALSE;
- //HWND label;
- //label=CreateWindow("static","Top window",WS_VISIBLE|WS_CHILD ,2,2,120,60,hwnd,NULL,g_hInst,0);
- //SendMessage(label,WM_SETFONT,(WPARAM)TitleBarFont,0);
- }
- return(FALSE);
-
- }
- case WM_GETMINMAXINFO:{
- RECT rct;
- if (pcli->hwndStatus==0){break;}
- GetWindowRect(pcli->hwndStatus,&rct);
- memset((LPMINMAXINFO)lParam,0,sizeof(MINMAXINFO));
- ((LPMINMAXINFO)lParam)->ptMinTrackSize.x=5;
- ((LPMINMAXINFO)lParam)->ptMinTrackSize.y=rct.bottom-rct.top;
- ((LPMINMAXINFO)lParam)->ptMaxTrackSize.x=1600;
- ((LPMINMAXINFO)lParam)->ptMaxTrackSize.y=rct.bottom-rct.top;
- return(0);
- }
-
- case WM_NCHITTEST:
- {
-
- }
- case WM_SHOWWINDOW:
- {
- {
- int res;
- if (hFrameHelperStatusBar)
- {
- res=CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS,hFrameHelperStatusBar),0);
- DBWriteContactSettingByte(0,"CLUI","ShowSBar",(BYTE)((res&F_VISIBLE)?1:0));
- }
- }
-
-
- if (tooltipshoing){
- NotifyEventHooks(hStatusBarHideToolTipEvent,0,0);
- tooltipshoing=FALSE;
- }
- return(0);
- //
- }
- case WM_TIMER:
- {
- if (wParam==TM_STATUSBARHIDE)
- {
- KillTimer(hwnd,TM_STATUSBARHIDE);
-
- if (tooltipshoing){
- NotifyEventHooks(hStatusBarHideToolTipEvent,0,0);
- tooltipshoing=FALSE;
- }
-
-
- }
-
- if (wParam==TM_STATUSBAR)
- {
- POINT pt;
- KillTimer(hwnd,TM_STATUSBAR);
-
- GetCursorPos(&pt);
- if (pt.x==lastpnt.x&&pt.y==lastpnt.y)
- {
- {
- int i,nParts;
- ProtocolData *PD;
- RECT rc;
- ScreenToClient(pcli->hwndStatus,&pt);
- nParts=SendMessage(pcli->hwndStatus,SB_GETPARTS,0,0);
- for(i=0;i<nParts;i++) {
- SendMessage(pcli->hwndStatus,SB_GETRECT,i,(LPARAM)&rc);
- if(PtInRect(&rc,pt)) {
- PD=(ProtocolData *)SendMessage(pcli->hwndStatus,SB_GETTEXT,i,(LPARAM)0);
- if(PD==NULL){return(0);}
-
- NotifyEventHooks(hStatusBarShowToolTipEvent,(WPARAM)PD->RealName,0);
- SetTimer(hwnd,TM_STATUSBARHIDE,DBGetContactSettingWord(NULL,"CLUIFrames","HideToolTipTime",5000),0);
- tooltipshoing=TRUE;
-
- break;
- }
- }
-
-
-
- }
-
-
-
- }
-
- }
-
- return(0);
- }
-
- case WM_SETCURSOR:
- {
-
- {
- POINT pt;
- GetCursorPos(&pt);
- if (pt.x==lastpnt.x&&pt.y==lastpnt.y)
- {
- return(0);
- }
- lastpnt=pt;
- if (tooltipshoing){
- KillTimer(hwnd,TM_STATUSBARHIDE);
- NotifyEventHooks(hStatusBarHideToolTipEvent,0,0);
- tooltipshoing=FALSE;
- }
- KillTimer(hwnd,TM_STATUSBAR);
- SetTimer(hwnd,TM_STATUSBAR,DBGetContactSettingWord(NULL,"CLC","InfoTipHoverTime",750),0);
- return(0);
- }
-
- }
- case WM_NOTIFY:
- {
- if (lParam==0){return(0);}
- if (((LPNMHDR)lParam)->hwndFrom == pcli->hwndStatus)
- {
-
- if (((LPNMHDR)lParam)->code == WM_NCHITTEST)
- {
- LPNMMOUSE lpnmmouse = (LPNMMOUSE) lParam;
- /*
- {
- GetCursorPos(&lastpnt);
- if (tooltipshoing){
- KillTimer(hwnd,TM_STATUSBARHIDE);
- NotifyEventHooks(hStatusBarHideToolTipEvent,0,0);
- tooltipshoing=FALSE;
- }
- KillTimer(hwnd,TM_STATUSBAR);
- SetTimer(hwnd,TM_STATUSBAR,DBGetContactSettingWord(NULL,"CLC","InfoTipHoverTime",750),0);
- return(0);
- }
- */
- } ;
- }
- }
-
-
-
-
- case WM_CONTEXTMENU:
- KillTimer(hwnd,TM_STATUSBARHIDE);
-
- if (tooltipshoing){
- NotifyEventHooks(hStatusBarHideToolTipEvent,0,0);
- }
- tooltipshoing=FALSE;
-
-
- case WM_MEASUREITEM:
- case WM_DRAWITEM:
- {
- //parent do all work for us
- return(SendMessage(pcli->hwndContactList,msg,wParam,lParam));
- }
-/*
- case WM_PAINT:
- {
- return(0);
- }
-*/
- case WM_MOVE:
- PostMessage(pcli->hwndStatus,WM_MOVE,wParam,lParam);
- case WM_SIZE:
- {
- RECT rc;
- int b;
- if (pcli->hwndStatus!=0)
- {
-
-
-
- GetClientRect(hwnd,&rc);
-
- b=LOWORD(lParam);
- if (b!=0&&(rc.right-rc.left)!=(OldRc.right-OldRc.left))
- {
- OldRc=rc;
- if (canloadstatusbar)
- {
- if(DBGetContactSettingByte(NULL,"CLUI","UseOwnerDrawStatusBar",0)||DBGetContactSettingByte(NULL,"CLUI","EqualSections",1)) {
- CluiProtocolStatusChanged(0,0);
- }
- }
- }
- if(msg==WM_SIZE) PostMessage(pcli->hwndStatus,WM_SIZE,wParam,lParam);
- if (pcli->hwndStatus!=0) InvalidateRect(pcli->hwndStatus,NULL,TRUE);
- return(0);
- }
- }
-
- default:
- return DefWindowProc(hwnd, msg, wParam, lParam);
-
- }
- return DefWindowProc(hwnd, msg, wParam, lParam);
-}
-
-HWND CreateStatusHelper(HWND parent)
-{
- WNDCLASS wndclass={0};
- TCHAR pluginname[] = _T("Statushelper");
-
- if (GetClassInfo(g_hInst,pluginname,&wndclass) == 0 ) {
- wndclass.style = 0;
- wndclass.lpfnWndProc = StatusHelperProc;
- wndclass.cbClsExtra = 0;
- wndclass.cbWndExtra = 0;
- wndclass.hInstance = g_hInst;
- wndclass.hIcon = NULL;
- wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
- wndclass.hbrBackground = (HBRUSH)(COLOR_3DFACE+1);
- wndclass.lpszMenuName = NULL;
- wndclass.lpszClassName = pluginname;
- RegisterClass(&wndclass);
- }
-
- return(CreateWindow(pluginname,pluginname,
- /*WS_THICKFRAME|*/WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN,
- 0,0,0,0,parent,NULL,g_hInst,NULL));
-}
-
-HANDLE CreateStatusBarFrame()
-{
- CLISTFrame Frame;
- int h;
- RECT rc;
-
- memset(&Frame,0,sizeof(Frame));
- Frame.cbSize=sizeof(CLISTFrame);
- Frame.hWnd=helperhwnd;
- Frame.align=alBottom;
- Frame.hIcon=LoadSkinnedIcon (SKINICON_OTHER_MIRANDA);
- Frame.Flags=(DBGetContactSettingByte(NULL,"CLUI","ShowSBar",1)?F_VISIBLE:0)|F_LOCKED|F_NOBORDER|F_TCHAR;
- GetWindowRect(helperhwnd,&rc);
- h=rc.bottom-rc.top;
- Frame.height=(h==0)?20:h;
-
-
- Frame.tname=_T("Status");
- Frame.TBtname=TranslateT("Status Bar");
- hFrameHelperStatusBar=(HANDLE)CallService(MS_CLIST_FRAMES_ADDFRAME,(WPARAM)&Frame,(LPARAM)0);
-
-
- return hFrameHelperStatusBar;
-}
-
-int RecreateStatusBar(HWND parent)
-{
- if (pcli->hwndStatus) {
- FreeProtocolData();
- DestroyWindow(pcli->hwndStatus);
- }
- pcli->hwndStatus=0;
- if (hFrameHelperStatusBar) CallService(MS_CLIST_FRAMES_REMOVEFRAME,(WPARAM)hFrameHelperStatusBar,0);
-
- helperhwnd=CreateStatusHelper(parent);
- UseOwnerDrawStatusBar=DBGetContactSettingByte(NULL,"CLUI","UseOwnerDrawStatusBar",0);
-
- //create the status wnd
- pcli->hwndStatus = CreateStatusWindow(
- ( DBGetContactSettingByte(0,"CLUI","SBarUseSizeGrip",TRUE) && (!UseOwnerDrawStatusBar)?SBARS_SIZEGRIP:0)|
- WS_CHILD | (DBGetContactSettingByte(NULL,"CLUI","ShowSBar",1)?WS_VISIBLE:0), _T(""), helperhwnd, 0);
-
- OldWindowProc=(WNDPROC)GetWindowLongPtr(pcli->hwndStatus,GWLP_WNDPROC);
- SetWindowLongPtr(pcli->hwndStatus,GWLP_WNDPROC,(LONG_PTR)&StatusBarOwnerDrawProc);
- CreateStatusBarFrame();
- {
- SetWindowPos(helperhwnd,NULL,1,1,1,1,SWP_NOZORDER);
- CluiProtocolStatusChanged(0,0);
- CallService(MS_CLIST_FRAMES_UPDATEFRAME,-1,0);
- }
-
- return 0;
-}
-
-HWND CreateStatusBarhWnd(HWND parent)
-{
- RecreateStatusBar(parent);
- OnStatusBarBackgroundChange();
-
- hStatusBarShowToolTipEvent=CreateHookableEvent(ME_CLIST_FRAMES_SB_SHOW_TOOLTIP);
- hStatusBarHideToolTipEvent=CreateHookableEvent(ME_CLIST_FRAMES_SB_HIDE_TOOLTIP);
- return pcli->hwndStatus;
-}
diff --git a/plugins/Mwclist/CLUIFrames/statusbar.cpp b/plugins/Mwclist/CLUIFrames/statusbar.cpp
new file mode 100644
index 0000000000..319f4f8f63
--- /dev/null
+++ b/plugins/Mwclist/CLUIFrames/statusbar.cpp
@@ -0,0 +1,599 @@
+#include "../commonheaders.h"
+
+extern HINSTANCE g_hInst;
+HANDLE hStatusBarShowToolTipEvent,hStatusBarHideToolTipEvent;
+boolean canloadstatusbar = FALSE;
+HWND helperhwnd = 0;
+HANDLE hFrameHelperStatusBar;
+
+void CluiProtocolStatusChanged(int parStatus, const char* szProto);
+
+INT_PTR GetConnectingIconService (WPARAM wParam,LPARAM lParam);
+
+int RecreateStatusBar(HWND);
+int UseOwnerDrawStatusBar;
+
+#define TM_STATUSBAR 23435234
+#define TM_STATUSBARHIDE 23435235
+boolean tooltipshoing;
+WNDPROC OldWindowProc = NULL;
+
+
+POINT lastpnt;
+RECT OldRc = {0};
+static HBITMAP hBmpBackground;
+static int backgroundBmpUse;
+static COLORREF bkColour;
+extern BYTE showOpts;
+int extraspace;
+
+int OnStatusBarBackgroundChange()
+{
+ {
+ DBVARIANT dbv;
+ showOpts = DBGetContactSettingByte(NULL,"CLUI","SBarShow",1);
+ bkColour = DBGetContactSettingDword(NULL,"StatusBar","BkColour",CLCDEFAULT_BKCOLOUR);
+ if (hBmpBackground) {DeleteObject(hBmpBackground); hBmpBackground = NULL;}
+ if (DBGetContactSettingByte(NULL,"StatusBar","UseBitmap",CLCDEFAULT_USEBITMAP)) {
+ if (!DBGetContactSettingString(NULL,"StatusBar","BkBitmap",&dbv)) {
+ hBmpBackground = (HBITMAP)CallService(MS_UTILS_LOADBITMAP,0,(LPARAM)dbv.pszVal);
+ mir_free(dbv.pszVal);
+ }
+ }
+ backgroundBmpUse = DBGetContactSettingWord(NULL,"StatusBar","BkBmpUse",CLCDEFAULT_BKBMPUSE);
+ extraspace = DBGetContactSettingDword(NULL,"StatusBar","BkExtraSpace",0);
+ }
+
+ RecreateStatusBar(pcli->hwndContactList);
+ if (pcli->hwndStatus) InvalidateRect(pcli->hwndStatus,NULL,TRUE);
+ return 0;
+}
+
+
+void DrawDataForStatusBar(LPDRAWITEMSTRUCT dis)
+{
+ //LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam;
+ ProtocolData *PD = (ProtocolData *)dis->itemData;
+ char *szProto = (char*)dis->itemData;
+ int status,x;
+ SIZE textSize;
+ boolean NeedDestroy = FALSE;
+ HICON hIcon;
+ HRGN hrgn;
+
+
+ if (PD == NULL){return;}
+ if (dis->hDC == NULL) {return;}
+
+ //clip it
+
+ hrgn = CreateRectRgn(dis->rcItem.left, dis->rcItem.top,
+ dis->rcItem.right, dis->rcItem.bottom);
+
+ SelectClipRgn(dis->hDC, hrgn);
+
+ szProto = PD->RealName;
+#ifdef _DEBUG
+ {
+ //char buf[512];
+ //sprintf(buf,"proto: %s draw at pos: %d\r\n",szProto,dis->rcItem.left);
+ //OutputDebugStringA(buf);
+ }
+#endif
+
+ status = CallProtoService(szProto,PS_GETSTATUS,0,0);
+ SetBkMode(dis->hDC,TRANSPARENT);
+ x = dis->rcItem.left+extraspace;
+
+ if (showOpts&1)
+ {
+ if ((DBGetContactSettingByte(NULL,"CLUI","UseConnectingIcon",1) == 1) && status < ID_STATUS_OFFLINE)
+ {
+ hIcon = (HICON)GetConnectingIconService((WPARAM)szProto,0);
+
+ if (hIcon)
+ {
+ NeedDestroy = TRUE;
+ }else
+ {
+ hIcon = LoadSkinnedProtoIcon(szProto,status);
+ }
+
+ }else
+ {
+ hIcon = LoadSkinnedProtoIcon(szProto,status);
+ }
+ DrawIconEx(dis->hDC,x,(dis->rcItem.top+dis->rcItem.bottom-GetSystemMetrics(SM_CYSMICON))>>1,hIcon,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),0,NULL,DI_NORMAL);
+ if (NeedDestroy) DestroyIcon(hIcon);
+ x += GetSystemMetrics(SM_CXSMICON)+2;
+ }
+ else x += 2;
+ if (showOpts&2) {
+ TCHAR szName[64];
+
+ PROTOACCOUNT* pa = ProtoGetAccount(szProto);
+ mir_sntprintf(szName, SIZEOF(szName), _T("%s%s"), pa->tszAccountName, showOpts&4 ? _T(" ") : _T(""));
+ GetTextExtentPoint32(dis->hDC, szName, (int)_tcslen(szName), &textSize);
+
+ TextOut(dis->hDC,x,(dis->rcItem.top+dis->rcItem.bottom-textSize.cy)>>1,szName,lstrlen(szName));
+ x += textSize.cx;
+ }
+ if (showOpts&4) {
+ TCHAR *szStatus = pcli->pfnGetStatusModeDescription(status, 0);
+ if (!szStatus)
+ szStatus = _T("");
+ GetTextExtentPoint32(dis->hDC,szStatus,lstrlen(szStatus),&textSize);
+ TextOut(dis->hDC,x,(dis->rcItem.top+dis->rcItem.bottom-textSize.cy)>>1,szStatus,lstrlen(szStatus));
+ }
+ SelectClipRgn(dis->hDC, NULL);
+ DeleteObject(hrgn);
+}
+
+void DrawBackGround(HWND hwnd,HDC mhdc)
+{
+ HDC hdcMem,hdc;
+ RECT clRect,*rcPaint;
+
+ int yScroll = 0;
+ int y;
+ PAINTSTRUCT paintst = {0};
+ HBITMAP hBmpOsb,holdbmp;
+ DWORD style = GetWindowLongPtr(hwnd,GWL_STYLE);
+ int grey = 0;
+ HFONT oFont;
+ HBRUSH hBrushAlternateGrey = NULL;
+
+ HFONT hFont;
+
+ //InvalidateRect(hwnd,0,FALSE);
+
+ hFont = (HFONT)SendMessage(hwnd,WM_GETFONT,0,0);
+
+ if (mhdc)
+ {
+ hdc = mhdc;
+ rcPaint = NULL;
+ }else
+ {
+ hdc = BeginPaint(hwnd,&paintst);
+ rcPaint = &(paintst.rcPaint);
+ }
+
+ GetClientRect(hwnd,&clRect);
+ if (rcPaint == NULL) rcPaint = &clRect;
+ if (rcPaint->right-rcPaint->left == 0||rcPaint->top-rcPaint->bottom == 0) rcPaint = &clRect;
+ y = -yScroll;
+ hdcMem = CreateCompatibleDC(hdc);
+ hBmpOsb = CreateBitmap(clRect.right,clRect.bottom,1,GetDeviceCaps(hdc,BITSPIXEL),NULL);
+ holdbmp = (HBITMAP)SelectObject(hdcMem,hBmpOsb);
+ oFont = (HFONT)SelectObject(hdcMem,hFont);
+ SetBkMode(hdcMem,TRANSPARENT);
+ { HBRUSH hBrush,hoBrush;
+
+ hBrush = CreateSolidBrush(bkColour);
+ hoBrush = (HBRUSH)SelectObject(hdcMem,hBrush);
+ FillRect(hdcMem,rcPaint,hBrush);
+ SelectObject(hdcMem,hoBrush);
+ DeleteObject(hBrush);
+ if (hBmpBackground) {
+ BITMAP bmp;
+ int x,y;
+ int maxx,maxy;
+ int destw,desth;
+
+ GetObject(hBmpBackground,sizeof(bmp),&bmp);
+ HDC hdcBmp = CreateCompatibleDC(hdcMem);
+ HDC holdbackbmp = (HDC)SelectObject(hdcBmp,hBmpBackground);
+ y = backgroundBmpUse&CLBF_SCROLL?-yScroll:0;
+ maxx = backgroundBmpUse&CLBF_TILEH?clRect.right:1;
+ maxy = backgroundBmpUse&CLBF_TILEV?maxy = rcPaint->bottom:y+1;
+ switch(backgroundBmpUse&CLBM_TYPE) {
+ case CLB_STRETCH:
+ if (backgroundBmpUse&CLBF_PROPORTIONAL) {
+ if (clRect.right*bmp.bmHeight<clRect.bottom*bmp.bmWidth) {
+ desth = clRect.bottom;
+ destw = desth*bmp.bmWidth/bmp.bmHeight;
+ }
+ else {
+ destw = clRect.right;
+ desth = destw*bmp.bmHeight/bmp.bmWidth;
+ }
+ }
+ else {
+ destw = clRect.right;
+ desth = clRect.bottom;
+ }
+ break;
+ case CLB_STRETCHH:
+ if (backgroundBmpUse&CLBF_PROPORTIONAL) {
+ destw = clRect.right;
+ desth = destw*bmp.bmHeight/bmp.bmWidth;
+ }
+ else {
+ destw = clRect.right;
+ desth = bmp.bmHeight;
+ }
+ break;
+ case CLB_STRETCHV:
+ if (backgroundBmpUse&CLBF_PROPORTIONAL) {
+ desth = clRect.bottom;
+ destw = desth*bmp.bmWidth/bmp.bmHeight;
+ }
+ else {
+ destw = bmp.bmWidth;
+ desth = clRect.bottom;
+ }
+ break;
+ default: //clb_topleft
+ destw = bmp.bmWidth;
+ desth = bmp.bmHeight;
+ break;
+ }
+ desth = clRect.bottom -clRect.top;
+ for (;y<maxy;y += desth) {
+ if (y<rcPaint->top-desth) continue;
+ for (x = 0;x<maxx;x += destw)
+ StretchBlt(hdcMem,x,y,destw,desth,hdcBmp,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
+ }
+ SelectObject(hdcBmp,holdbackbmp);
+ DeleteDC(hdcBmp);
+ }
+ }
+
+ //call to draw icons
+ {
+ DRAWITEMSTRUCT ds;
+ int nParts,nPanel;
+ ProtocolData *PD;
+ RECT rc,clrc;
+ int startoffset,sectwidth;
+
+ memset(&ds,0,sizeof(ds));
+ ds.hwndItem = hwnd;
+ ds.hDC = hdcMem;
+
+
+ startoffset = DBGetContactSettingDword(NULL,"StatusBar","FirstIconOffset",0);
+ extraspace = DBGetContactSettingDword(NULL,"StatusBar","BkExtraSpace",0);
+
+ nParts = SendMessage(hwnd,SB_GETPARTS,0,0);
+ memset(&rc,0,sizeof(RECT));
+ GetClientRect(hwnd,&clrc);
+ clrc.right -= clrc.left;
+ clrc.right -= startoffset;
+ sectwidth = clrc.right/nParts;
+
+ for (nPanel = 0;nPanel<nParts;nPanel++)
+ {
+ PD = (ProtocolData *)SendMessage(pcli->hwndStatus,SB_GETTEXT,(WPARAM)nPanel,(LPARAM)0);
+ if (PD == NULL){
+ continue;
+ }
+ SendMessage(hwnd,SB_GETRECT,(WPARAM)nPanel,(LPARAM)&rc);
+ //rc.left += startoffset;
+ //if (rc.left>=rc.right) rc.left = rc.right-1;
+ rc.top = 0;
+ rc.left = nPanel*sectwidth+startoffset;
+ rc.right = rc.left+sectwidth-1;
+ ds.rcItem = rc;
+ ds.itemData = (ULONG_PTR)PD;
+ ds.itemID = nPanel;
+
+ DrawDataForStatusBar(&ds);
+ } }
+
+ BitBlt(hdc,rcPaint->left,rcPaint->top,rcPaint->right-rcPaint->left,rcPaint->bottom-rcPaint->top,hdcMem,rcPaint->left,rcPaint->top,SRCCOPY);
+
+ SelectObject(hdcMem,holdbmp);
+ SelectObject(hdcMem,oFont);
+ DeleteObject(hBmpOsb);
+ DeleteDC(hdcMem);
+ paintst.fErase = FALSE;
+ //DeleteObject(hFont);
+ if (!mhdc)
+ EndPaint(hwnd,&paintst);
+}
+
+LRESULT CALLBACK StatusBarOwnerDrawProc( HWND hwnd,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam
+)
+{
+if (UseOwnerDrawStatusBar)
+{
+ switch(uMsg)
+ {
+ case WM_ERASEBKGND:
+ {
+
+ //DrawBackGround(hwnd);
+ return 0;
+ }
+ case WM_PRINT:
+ {
+ DrawBackGround(hwnd,(HDC)wParam);
+ return 0;
+ }
+ case WM_PAINT:
+ {
+ DrawBackGround(hwnd,0);
+ return 0;
+ }
+ }
+
+}
+return (CallWindowProc(OldWindowProc,hwnd,uMsg,wParam,lParam)
+ );
+}
+
+LRESULT CALLBACK StatusHelperProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg)
+ {
+ case WM_CREATE:
+ {
+ {
+ tooltipshoing = FALSE;
+ //HWND label;
+ //label = CreateWindow("static","Top window",WS_VISIBLE|WS_CHILD ,2,2,120,60,hwnd,NULL,g_hInst,0);
+ //SendMessage(label,WM_SETFONT,(WPARAM)TitleBarFont,0);
+ }
+ return(FALSE);
+
+ }
+ case WM_GETMINMAXINFO:{
+ RECT rct;
+ if (pcli->hwndStatus == 0){break;}
+ GetWindowRect(pcli->hwndStatus,&rct);
+ memset((LPMINMAXINFO)lParam,0,sizeof(MINMAXINFO));
+ ((LPMINMAXINFO)lParam)->ptMinTrackSize.x = 5;
+ ((LPMINMAXINFO)lParam)->ptMinTrackSize.y = rct.bottom-rct.top;
+ ((LPMINMAXINFO)lParam)->ptMaxTrackSize.x = 1600;
+ ((LPMINMAXINFO)lParam)->ptMaxTrackSize.y = rct.bottom-rct.top;
+ return 0;
+ }
+
+ case WM_NCHITTEST:
+ {
+
+ }
+ case WM_SHOWWINDOW:
+ {
+ {
+ int res;
+ if (hFrameHelperStatusBar)
+ {
+ res = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS,hFrameHelperStatusBar),0);
+ DBWriteContactSettingByte(0,"CLUI","ShowSBar",(BYTE)((res&F_VISIBLE)?1:0));
+ }
+ }
+
+
+ if (tooltipshoing){
+ NotifyEventHooks(hStatusBarHideToolTipEvent,0,0);
+ tooltipshoing = FALSE;
+ }
+ return 0;
+ //
+ }
+ case WM_TIMER:
+ {
+ if (wParam == TM_STATUSBARHIDE)
+ {
+ KillTimer(hwnd,TM_STATUSBARHIDE);
+
+ if (tooltipshoing){
+ NotifyEventHooks(hStatusBarHideToolTipEvent,0,0);
+ tooltipshoing = FALSE;
+ }
+
+
+ }
+
+ if (wParam == TM_STATUSBAR)
+ {
+ POINT pt;
+ KillTimer(hwnd,TM_STATUSBAR);
+
+ GetCursorPos(&pt);
+ if (pt.x == lastpnt.x&&pt.y == lastpnt.y)
+ {
+ {
+ int i,nParts;
+ ProtocolData *PD;
+ RECT rc;
+ ScreenToClient(pcli->hwndStatus,&pt);
+ nParts = SendMessage(pcli->hwndStatus,SB_GETPARTS,0,0);
+ for (i = 0;i<nParts;i++) {
+ SendMessage(pcli->hwndStatus,SB_GETRECT,i,(LPARAM)&rc);
+ if (PtInRect(&rc,pt)) {
+ PD = (ProtocolData *)SendMessage(pcli->hwndStatus,SB_GETTEXT,i,(LPARAM)0);
+ if (PD == NULL){return 0;}
+
+ NotifyEventHooks(hStatusBarShowToolTipEvent,(WPARAM)PD->RealName,0);
+ SetTimer(hwnd,TM_STATUSBARHIDE,DBGetContactSettingWord(NULL,"CLUIFrames","HideToolTipTime",5000),0);
+ tooltipshoing = TRUE;
+
+ break;
+ }
+ }
+
+
+
+ }
+
+
+
+ }
+
+ }
+
+ return 0;
+ }
+
+ case WM_SETCURSOR:
+ {
+
+ {
+ POINT pt;
+ GetCursorPos(&pt);
+ if (pt.x == lastpnt.x&&pt.y == lastpnt.y)
+ {
+ return 0;
+ }
+ lastpnt = pt;
+ if (tooltipshoing){
+ KillTimer(hwnd,TM_STATUSBARHIDE);
+ NotifyEventHooks(hStatusBarHideToolTipEvent,0,0);
+ tooltipshoing = FALSE;
+ }
+ KillTimer(hwnd,TM_STATUSBAR);
+ SetTimer(hwnd,TM_STATUSBAR,DBGetContactSettingWord(NULL,"CLC","InfoTipHoverTime",750),0);
+ return 0;
+ }
+
+ }
+ case WM_NOTIFY:
+ {
+ if (lParam == 0){return 0;}
+ if (((LPNMHDR)lParam)->hwndFrom == pcli->hwndStatus)
+ {
+
+ if (((LPNMHDR)lParam)->code == WM_NCHITTEST)
+ {
+ LPNMMOUSE lpnmmouse = (LPNMMOUSE) lParam;
+ } ;
+ }
+ }
+
+ case WM_CONTEXTMENU:
+ KillTimer(hwnd,TM_STATUSBARHIDE);
+
+ if (tooltipshoing)
+ NotifyEventHooks(hStatusBarHideToolTipEvent,0,0);
+
+ tooltipshoing = FALSE;
+
+ case WM_MEASUREITEM:
+ case WM_DRAWITEM:
+ //parent do all work for us
+ return(SendMessage(pcli->hwndContactList,msg,wParam,lParam));
+
+ case WM_MOVE:
+ PostMessage(pcli->hwndStatus,WM_MOVE,wParam,lParam);
+
+ case WM_SIZE:
+ {
+ RECT rc;
+ int b;
+ if (pcli->hwndStatus != 0) {
+ GetClientRect(hwnd,&rc);
+
+ b = LOWORD(lParam);
+ if (b != 0&&(rc.right-rc.left) != (OldRc.right-OldRc.left)) {
+ OldRc = rc;
+ if (canloadstatusbar)
+ if (DBGetContactSettingByte(NULL,"CLUI","UseOwnerDrawStatusBar",0)||DBGetContactSettingByte(NULL,"CLUI","EqualSections",1))
+ CluiProtocolStatusChanged(0,0);
+ }
+ if (msg == WM_SIZE) PostMessage(pcli->hwndStatus,WM_SIZE,wParam,lParam);
+ if (pcli->hwndStatus != 0) InvalidateRect(pcli->hwndStatus,NULL,TRUE);
+ return 0;
+ }
+ }
+
+ default:
+ return DefWindowProc(hwnd, msg, wParam, lParam);
+
+ }
+ return DefWindowProc(hwnd, msg, wParam, lParam);
+}
+
+HWND CreateStatusHelper(HWND parent)
+{
+ WNDCLASS wndclass = {0};
+ TCHAR pluginname[] = _T("Statushelper");
+
+ if (GetClassInfo(g_hInst,pluginname,&wndclass) == 0 ) {
+ wndclass.style = 0;
+ wndclass.lpfnWndProc = StatusHelperProc;
+ wndclass.cbClsExtra = 0;
+ wndclass.cbWndExtra = 0;
+ wndclass.hInstance = g_hInst;
+ wndclass.hIcon = NULL;
+ wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
+ wndclass.hbrBackground = (HBRUSH)(COLOR_3DFACE+1);
+ wndclass.lpszMenuName = NULL;
+ wndclass.lpszClassName = pluginname;
+ RegisterClass(&wndclass);
+ }
+
+ return(CreateWindow(pluginname,pluginname,
+ /*WS_THICKFRAME|*/WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN,
+ 0,0,0,0,parent,NULL,g_hInst,NULL));
+}
+
+HANDLE CreateStatusBarFrame()
+{
+ CLISTFrame Frame;
+ int h;
+ RECT rc;
+
+ memset(&Frame,0,sizeof(Frame));
+ Frame.cbSize = sizeof(CLISTFrame);
+ Frame.hWnd = helperhwnd;
+ Frame.align = alBottom;
+ Frame.hIcon = LoadSkinnedIcon (SKINICON_OTHER_MIRANDA);
+ Frame.Flags = (DBGetContactSettingByte(NULL,"CLUI","ShowSBar",1)?F_VISIBLE:0)|F_LOCKED|F_NOBORDER|F_TCHAR;
+ GetWindowRect(helperhwnd,&rc);
+ h = rc.bottom-rc.top;
+ Frame.height = (h == 0)?20:h;
+
+
+ Frame.tname = _T("Status");
+ Frame.TBtname = TranslateT("Status Bar");
+ hFrameHelperStatusBar = (HANDLE)CallService(MS_CLIST_FRAMES_ADDFRAME,(WPARAM)&Frame,(LPARAM)0);
+
+
+ return hFrameHelperStatusBar;
+}
+
+int RecreateStatusBar(HWND parent)
+{
+ if (pcli->hwndStatus) {
+ FreeProtocolData();
+ DestroyWindow(pcli->hwndStatus);
+ }
+ pcli->hwndStatus = 0;
+ if (hFrameHelperStatusBar) CallService(MS_CLIST_FRAMES_REMOVEFRAME,(WPARAM)hFrameHelperStatusBar,0);
+
+ helperhwnd = CreateStatusHelper(parent);
+ UseOwnerDrawStatusBar = DBGetContactSettingByte(NULL,"CLUI","UseOwnerDrawStatusBar",0);
+
+ //create the status wnd
+ pcli->hwndStatus = CreateStatusWindow(
+ ( DBGetContactSettingByte(0,"CLUI","SBarUseSizeGrip",TRUE) && (!UseOwnerDrawStatusBar)?SBARS_SIZEGRIP:0)|
+ WS_CHILD | (DBGetContactSettingByte(NULL,"CLUI","ShowSBar",1)?WS_VISIBLE:0), _T(""), helperhwnd, 0);
+
+ OldWindowProc = (WNDPROC)GetWindowLongPtr(pcli->hwndStatus,GWLP_WNDPROC);
+ SetWindowLongPtr(pcli->hwndStatus,GWLP_WNDPROC,(LONG_PTR)&StatusBarOwnerDrawProc);
+ CreateStatusBarFrame();
+ {
+ SetWindowPos(helperhwnd,NULL,1,1,1,1,SWP_NOZORDER);
+ CluiProtocolStatusChanged(0,0);
+ CallService(MS_CLIST_FRAMES_UPDATEFRAME,-1,0);
+ }
+
+ return 0;
+}
+
+HWND CreateStatusBarhWnd(HWND parent)
+{
+ RecreateStatusBar(parent);
+ OnStatusBarBackgroundChange();
+
+ hStatusBarShowToolTipEvent = CreateHookableEvent(ME_CLIST_FRAMES_SB_SHOW_TOOLTIP);
+ hStatusBarHideToolTipEvent = CreateHookableEvent(ME_CLIST_FRAMES_SB_HIDE_TOOLTIP);
+ return pcli->hwndStatus;
+}
diff --git a/plugins/Mwclist/clc.c b/plugins/Mwclist/clc.cpp
index 6de26b6148..d43edd855d 100644
--- a/plugins/Mwclist/clc.c
+++ b/plugins/Mwclist/clc.cpp
@@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "commonheaders.h"
-int DefaultImageListColorDepth=ILC_COLOR32;
+int DefaultImageListColorDepth = ILC_COLOR32;
HIMAGELIST himlCListClc;
@@ -41,38 +41,38 @@ void LoadExtraImageFunc( void );
void UnloadCLUIModule( void );
extern int sortByStatus;
-struct ClcContact * hitcontact=NULL;
+struct ClcContact * hitcontact = NULL;
extern LRESULT ( CALLBACK *saveContactListControlWndProc )(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
static int stopStatusUpdater = 0;
-void StatusUpdaterThread(HWND hwndDlg)
+void StatusUpdaterThread(void*)
{
- int i,curdelay,lastcheck=0;
+ int i,curdelay,lastcheck = 0;
HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_LOWEST);
while (!stopStatusUpdater) {
- curdelay=DBGetContactSettingByte(hContact,"CList","StatusMsgAutoDelay",15000);
- if (curdelay<5000) curdelay=5000;
+ curdelay = DBGetContactSettingByte(hContact,"CList","StatusMsgAutoDelay",15000);
+ if (curdelay<5000) curdelay = 5000;
if ((int)(GetTickCount()-lastcheck)>curdelay)
{
- lastcheck=GetTickCount();
+ lastcheck = GetTickCount();
if (DBGetContactSettingByte(hContact,"CList","StatusMsgAuto",0)) {
- for (i=0; i<5; i++) {
- if (hContact!=NULL) {
- pdisplayNameCacheEntry pdnce =(pdisplayNameCacheEntry)pcli->pfnGetCacheEntry((HANDLE)hContact);
+ for (i = 0; i<5; i++) {
+ if (hContact != NULL) {
+ pdisplayNameCacheEntry pdnce = (pdisplayNameCacheEntry)pcli->pfnGetCacheEntry((HANDLE)hContact);
if (pdnce && !pdnce->protoNotExists && pdnce->szProto)
- {
CallContactService(hContact, PSS_GETAWAYMSG, 0, 0);
- }
+
hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
}
- if (hContact==NULL) {
+ if (hContact == NULL) {
hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
- if (hContact==NULL) break;
+ if (hContact == NULL)
+ break;
}
Sleep(500);
}
@@ -96,12 +96,12 @@ void SortClcByTimer (HWND hwnd)
static int ClcSettingChanged(WPARAM wParam, LPARAM lParam)
{
- DBCONTACTWRITESETTING *cws=(DBCONTACTWRITESETTING*)lParam;
+ DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam;
if ((HANDLE)wParam != NULL && !strcmp(cws->szModule,"MetaContacts") && !strcmp(cws->szSetting,"Handle"))
pcli->pfnClcBroadcast( INTM_NAMEORDERCHANGED, 0, 0 );
- if ((HANDLE)wParam!=NULL&&!strcmp(cws->szModule,"CList")) {
+ if ((HANDLE)wParam != NULL&&!strcmp(cws->szModule,"CList")) {
if ( !strcmp( cws->szSetting, "noOffline" ))
pcli->pfnClcBroadcast( INTM_NAMEORDERCHANGED, wParam, lParam );
else if (!strcmp(cws->szSetting,"StatusMsg"))
@@ -142,91 +142,93 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L
break;
case INTM_ICONCHANGED:
- { struct ClcContact *contact=NULL;
- struct ClcGroup *group=NULL;
- int recalcScrollBar=0,shouldShow;
- HANDLE hSelItem=NULL;
- struct ClcContact *selcontact=NULL;
+ { struct ClcContact *contact = NULL;
+ struct ClcGroup *group = NULL;
+ int recalcScrollBar = 0,shouldShow;
+ HANDLE hSelItem = NULL;
+ struct ClcContact *selcontact = NULL;
pdisplayNameCacheEntry cacheEntry = GetContactFullCacheEntry((HANDLE)wParam);
WORD status;
- int NeedResort=0;
+ int NeedResort = 0;
char *szProto = cacheEntry->szProto;
- if(szProto==NULL) status=ID_STATUS_OFFLINE;
- else status=cacheEntry->status;
+ if (szProto == NULL)
+ status = ID_STATUS_OFFLINE;
+ else
+ status = cacheEntry->status;
- shouldShow=(GetWindowLongPtr(hwnd,GWL_STYLE)&CLS_SHOWHIDDEN || !cacheEntry->Hidden) && (!pcli->pfnIsHiddenMode(dat,status)||cacheEntry->noHiddenOffline || CallService(MS_CLIST_GETCONTACTICON,wParam,0)!=LOWORD(lParam)); //this means an offline msg is flashing, so the contact should be shown
+ shouldShow = (GetWindowLongPtr(hwnd,GWL_STYLE)&CLS_SHOWHIDDEN || !cacheEntry->Hidden) && (!pcli->pfnIsHiddenMode(dat,status)||cacheEntry->noHiddenOffline || CallService(MS_CLIST_GETCONTACTICON,wParam,0) != LOWORD(lParam)); //this means an offline msg is flashing, so the contact should be shown
if (!FindItem(hwnd,dat,(HANDLE)wParam,&contact,&group,NULL)) {
- if(shouldShow && CallService(MS_DB_CONTACT_IS, wParam, 0)) {
- if(dat->selection>=0 && GetRowByIndex(dat,dat->selection,&selcontact,NULL)!=-1)
- hSelItem=pcli->pfnContactToHItem(selcontact);
+ if (shouldShow && CallService(MS_DB_CONTACT_IS, wParam, 0)) {
+ if (dat->selection>=0 && GetRowByIndex(dat,dat->selection,&selcontact,NULL) != -1)
+ hSelItem = pcli->pfnContactToHItem(selcontact);
AddContactToTree(hwnd,dat,(HANDLE)wParam,0,0);
- NeedResort=1;
- recalcScrollBar=1;
+ NeedResort = 1;
+ recalcScrollBar = 1;
FindItem(hwnd,dat,(HANDLE)wParam,&contact,NULL,NULL);
if (contact) {
- contact->iImage=(WORD)lParam;
+ contact->iImage = (WORD)lParam;
pcli->pfnNotifyNewContact(hwnd,(HANDLE)wParam);
- dat->NeedResort=1;
+ dat->NeedResort = 1;
}
}
}
else {
//item in list already
- DWORD style=GetWindowLongPtr(hwnd,GWL_STYLE);
- if(contact->iImage== (WORD)lParam) break;
- if (sortByStatus) dat->NeedResort=1;
+ DWORD style = GetWindowLongPtr(hwnd,GWL_STYLE);
+ if (contact->iImage == (WORD)lParam) break;
+ if (sortByStatus) dat->NeedResort = 1;
if (!shouldShow && !(style&CLS_NOHIDEOFFLINE) && (style&CLS_HIDEOFFLINE || group->hideOffline)) {
- if(dat->selection>=0 && GetRowByIndex(dat,dat->selection,&selcontact,NULL)!=-1)
- hSelItem=pcli->pfnContactToHItem(selcontact);
+ if (dat->selection>=0 && GetRowByIndex(dat,dat->selection,&selcontact,NULL) != -1)
+ hSelItem = pcli->pfnContactToHItem(selcontact);
RemoveItemFromGroup(hwnd,group,contact,0);
- recalcScrollBar=1;
- dat->NeedResort=1;
+ recalcScrollBar = 1;
+ dat->NeedResort = 1;
}
else {
int oldflags;
- contact->iImage=(WORD)lParam;
- oldflags=contact->flags;
+ contact->iImage = (WORD)lParam;
+ oldflags = contact->flags;
if (!pcli->pfnIsHiddenMode(dat,status)||cacheEntry->noHiddenOffline) contact->flags|=CONTACTF_ONLINE;
- else contact->flags&=~CONTACTF_ONLINE;
- if (oldflags!=contact->flags)
- dat->NeedResort=1;
+ else contact->flags &= ~CONTACTF_ONLINE;
+ if (oldflags != contact->flags)
+ dat->NeedResort = 1;
} }
- if(hSelItem) {
+ if (hSelItem) {
struct ClcGroup *selgroup;
- if(FindItem(hwnd,dat,hSelItem,&selcontact,&selgroup,NULL))
- dat->selection=GetRowsPriorTo(&dat->list,selgroup,li.List_IndexOf((SortedList*)&selgroup->cl, selcontact));
+ if (FindItem(hwnd,dat,hSelItem,&selcontact,&selgroup,NULL))
+ dat->selection = GetRowsPriorTo(&dat->list,selgroup,li.List_IndexOf((SortedList*)&selgroup->cl, selcontact));
else
- dat->selection=-1;
+ dat->selection = -1;
}
SortClcByTimer(hwnd);
- if(recalcScrollBar) RecalcScrollBar(hwnd,dat);
+ if (recalcScrollBar) RecalcScrollBar(hwnd,dat);
goto LBL_Exit;
}
case INTM_STATUSMSGCHANGED:
- { struct ClcContact *contact=NULL;
- struct ClcGroup *group=NULL;
+ { struct ClcContact *contact = NULL;
+ struct ClcGroup *group = NULL;
DBVARIANT dbv;
if (!(dat->style&CLS_SHOWSTATUSMESSAGES)) break;
- if(FindItem(hwnd,dat,(HANDLE)wParam,&contact,&group,NULL) && contact!=NULL) {
- contact->flags &= ~CONTACTF_STATUSMSG;
+ if (FindItem(hwnd,dat,(HANDLE)wParam,&contact,&group,NULL) && contact != NULL) {
+ contact->flags &= ~CONTACTF_STATUSMSG;
if (!DBGetContactSettingTString((HANDLE)wParam, "CList", "StatusMsg", &dbv)) {
int j;
- if (dbv.ptszVal==NULL||_tcslen(dbv.ptszVal)==0) break;
+ if (dbv.ptszVal == NULL||_tcslen(dbv.ptszVal) == 0) break;
lstrcpyn(contact->szStatusMsg, dbv.ptszVal, SIZEOF(contact->szStatusMsg));
- for (j=(int)_tcslen(contact->szStatusMsg)-1;j>=0;j--) {
- if (contact->szStatusMsg[j]=='\r' || contact->szStatusMsg[j]=='\n' || contact->szStatusMsg[j]=='\t') {
+ for (j = (int)_tcslen(contact->szStatusMsg)-1;j>=0;j--) {
+ if (contact->szStatusMsg[j] == '\r' || contact->szStatusMsg[j] == '\n' || contact->szStatusMsg[j] == '\t') {
contact->szStatusMsg[j] = ' ';
}
}
DBFreeVariant(&dbv);
if (_tcslen(contact->szStatusMsg)>0) {
contact->flags |= CONTACTF_STATUSMSG;
- dat->NeedResort=TRUE;
+ dat->NeedResort = TRUE;
}
}
}
@@ -238,7 +240,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L
goto LBL_Exit;
}
case WM_TIMER:
- if (wParam==TIMERID_DELAYEDREPAINT) {
+ if (wParam == TIMERID_DELAYEDREPAINT) {
KillTimer(hwnd,TIMERID_DELAYEDREPAINT);
InvalidateRect(hwnd,NULL,FALSE);
break;
@@ -247,11 +249,11 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L
if ( wParam == TIMERID_SUBEXPAND) {
KillTimer(hwnd,TIMERID_SUBEXPAND);
if (hitcontact) {
- if (hitcontact->SubExpanded) hitcontact->SubExpanded=0; else hitcontact->SubExpanded=1;
+ if (hitcontact->SubExpanded) hitcontact->SubExpanded = 0; else hitcontact->SubExpanded = 1;
DBWriteContactSettingByte(hitcontact->hContact,"CList","Expanded",hitcontact->SubExpanded);
}
- hitcontact=NULL;
- dat->NeedResort=1;
+ hitcontact = NULL;
+ dat->NeedResort = 1;
SortCLC(hwnd,dat,1);
RecalcScrollBar(hwnd,dat);
break;
@@ -263,8 +265,8 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L
stopStatusUpdater = 1;
break;
}
-
- { LRESULT res = saveContactListControlWndProc(hwnd, msg, wParam, lParam);
+ {
+ LRESULT res = saveContactListControlWndProc(hwnd, msg, wParam, lParam);
switch (msg) {
case WM_CREATE:
mir_forkthread(StatusUpdaterThread,0);
@@ -282,10 +284,10 @@ int LoadCLCModule(void)
LoadCLUIFramesModule();
LoadExtraImageFunc();
- himlCListClc=(HIMAGELIST)CallService(MS_CLIST_GETICONSIMAGELIST,0,0);
+ himlCListClc = (HIMAGELIST)CallService(MS_CLIST_GETICONSIMAGELIST,0,0);
HookEvent(ME_SYSTEM_MODULESLOADED,ClcModulesLoaded);
- hSettingChanged1=HookEvent(ME_DB_CONTACT_SETTINGCHANGED,ClcSettingChanged);
+ hSettingChanged1 = HookEvent(ME_DB_CONTACT_SETTINGCHANGED,ClcSettingChanged);
HookEvent(ME_OPT_INITIALISE,ClcOptInit);
HookEvent(ME_SYSTEM_SHUTDOWN,ClcShutdown);
return 0;
diff --git a/plugins/Mwclist/clc.h b/plugins/Mwclist/clc.h
index 8083b91dec..6bb37c2beb 100644
--- a/plugins/Mwclist/clc.h
+++ b/plugins/Mwclist/clc.h
@@ -127,7 +127,6 @@ struct ClcData {
DWORD style;
SortedList lCLCContactsCache;
- BYTE HiLightMode;
BYTE doubleClickExpand;
int MetaIgnoreEmptyExtra;
};
@@ -194,12 +193,11 @@ typedef struct {
typedef struct {
int cbSize;
void (*PaintClc)(HWND,struct ClcData *,HDC,RECT *,int ,ClcProtoStatus *,HIMAGELIST);
-
} ExternDrawer,*pExternDrawer ;
-ExternDrawer SED;
+extern ExternDrawer SED;
-#define CLM_SETEXTRACOLUMNSSPACE (CLM_FIRST+73) //wParam=extra space between icons
+#define CLM_SETEXTRACOLUMNSSPACE (CLM_FIRST+73) //wParam = extra space between icons
void FreeAndNil( void** p );
diff --git a/plugins/Mwclist/clcidents.c b/plugins/Mwclist/clcidents.c
deleted file mode 100644
index 09a68588bc..0000000000
--- a/plugins/Mwclist/clcidents.c
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
-
-Miranda IM: the free IM client for Microsoft* Windows*
-
-Copyright 2000-2003 Miranda ICQ/IM project,
-all portions of this codebase are copyrighted to the people
-listed in contributors.txt.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-#include "commonheaders.h"
-#include "m_clc.h"
-#include "clc.h"
-
-/* the CLC uses 3 different ways to identify elements in its list, this file
-contains routines to convert between them.
-
-1) struct ClcContact/struct ClcGroup pair. Only ever used within the duration
-of a single operation, but used at some point in nearly everything
-2) index integer. The 0-based number of the item from the top. Only visible
-items are counted (ie not closed groups). Used for saving selection and drag
-highlight
-3) hItem handle. Either the hContact or (hGroup|HCONTACT_ISGROUP). Used
-exclusively externally
-
-1->2: GetRowsPriorTo()
-1->3: ContactToHItem()
-3->1: FindItem()
-2->1: GetRowByIndex()
-*/
-
-int GetRowsPriorTo(struct ClcGroup *group,struct ClcGroup *subgroup,int contactIndex)
-{
- int count=0;
-
- group->scanIndex=0;
- for (;;) {
- if(group->scanIndex==group->cl.count) {
- group=group->parent;
- if(group==NULL) break;
- group->scanIndex++;
- continue;
- }
- if(group==subgroup && contactIndex==group->scanIndex) return count;
- count++;
- if ((group->cl.items[group->scanIndex]->type==CLCIT_CONTACT) && (group->cl.items[group->scanIndex]->flags & CONTACTF_STATUSMSG)) {
- count++;
- }
-
- if(group->cl.items[group->scanIndex]->type==CLCIT_GROUP) {
- if(group->cl.items[group->scanIndex]->group==subgroup && contactIndex==-1)
- return count-1;
- if(group->cl.items[group->scanIndex]->group->expanded) {
- group=group->cl.items[group->scanIndex]->group;
- group->scanIndex=0;
- continue;
- }
- }
- if(group->cl.items[group->scanIndex]->type==CLCIT_CONTACT)
- {
- count+=group->cl.items[group->scanIndex]->SubAllocated*group->cl.items[group->scanIndex]->SubExpanded;
- }
- group->scanIndex++;
- }
- return -1;
-}
-
-pdisplayNameCacheEntry GetCLCFullCacheEntry(struct ClcData *dat,HANDLE hContact)
-{
- int idx;
- displayNameCacheEntry dnce, *pdnce,*pdnce2;
-
- if (hContact==0) return NULL;
- dnce.hContact=hContact;
-
- pdnce=li.List_Find(&dat->lCLCContactsCache,&dnce);
-
- if (pdnce==NULL)
- {
- pdnce=mir_calloc(sizeof(displayNameCacheEntry));
- pdnce->hContact=hContact;
- li.List_GetIndex(&dat->lCLCContactsCache,pdnce,&idx);
- li.List_Insert(&dat->lCLCContactsCache,pdnce,idx);
-
- pdnce2=li.List_Find(&dat->lCLCContactsCache,&dnce);//for check
- if (pdnce2->hContact!=pdnce->hContact)
- {
- return (NULL);
- }
-
- if (pdnce2!=pdnce)
- {
- return (NULL);
- }
- }
-
- return (pdnce);
-}
-
-void ClearClcContactCache(struct ClcData *dat,HANDLE hContact)
-{
-
- pdisplayNameCacheEntry cacheEntry;
-
- if (hContact==INVALID_HANDLE_VALUE)
- {
- int i,tick;
- tick=GetTickCount();
-
- for(i=0;i<(dat->lCLCContactsCache.realCount);i++)
- {
- pdisplayNameCacheEntry pdnce = dat->lCLCContactsCache.items[i];
- pdnce->ClcContact = NULL;
- }
- tick=GetTickCount()-tick;
-
- { char buf[256];
- sprintf (buf,"Clear full cache %d ms\r\n",tick);
- OutputDebugStringA(buf);
- }
- }
- if (!IsHContactGroup(hContact)&&!IsHContactInfo(hContact))
- {
- cacheEntry=GetCLCFullCacheEntry(dat,hContact);
- if (cacheEntry!=NULL)
- cacheEntry->ClcContact=NULL;
- }
-}
-
-void SetClcContactCacheItem(struct ClcData *dat,HANDLE hContact,void *contact)
-{
- pdisplayNameCacheEntry cacheEntry;
- if (!IsHContactGroup(hContact)&&!IsHContactInfo(hContact))
- {
- cacheEntry=GetCLCFullCacheEntry(dat,hContact);
- if (cacheEntry!=NULL)
- {
- cacheEntry->ClcContact=contact;
- }
- }
-
-}
-
-
-
-int FindItem(HWND hwnd,struct ClcData *dat,HANDLE hItem,struct ClcContact **contact,struct ClcGroup **subgroup,int *isVisible)
-{
- int index=0, i;
- int nowVisible=1;
- struct ClcGroup *group=&dat->list;
-
- group->scanIndex=0;
-
- if (isVisible==NULL&&hItem!=NULL&&subgroup==NULL&&!IsHContactGroup(hItem)&&!IsHContactInfo(hItem))
- {
- //try use cache
- pdisplayNameCacheEntry cacheEntry;
- cacheEntry=GetCLCFullCacheEntry(dat,hItem);
- if (cacheEntry!=NULL)
- {
- if (cacheEntry->ClcContact==NULL)
- {
- int *isv={0};
- void *z={0};
- int ret;
- ret=FindItem(hwnd,dat,hItem,(struct ClcContact ** )&z,(struct ClcGroup** )&isv,NULL);
- if (ret=0) {return (0);}
- cacheEntry->ClcContact=(void *)z;
- }
- if (cacheEntry->ClcContact!=NULL)
- {
- if (contact!=NULL)
- *contact=(struct ClcContact *)cacheEntry->ClcContact;
-
- {
- /*
- void *p={0}
- int *isv={0}
- int ret;
- ret=FindItem(hwnd,dat,hItem,&p,&isv,NULL);
- if (ret=0) {return (0);}
- if (p!=cacheEntry->ClcContact)
- {
- MessageBox(0,"hITEM FAILEDDDDDDDD!!!!!","",0);
- //cacheEntry->ClcContact=p;
- }
- */
- }
- return 1;
- }
- }
- }
-
- group=&dat->list;
-
- for (;;) {
- if(group->scanIndex==group->cl.count) {
- struct ClcGroup *tgroup;
- group=group->parent;
- if(group==NULL) break;
- nowVisible=1;
- for(tgroup=group;tgroup;tgroup=tgroup->parent)
- if (!group->expanded) {nowVisible=0; break;}
- group->scanIndex++;
- continue;
- }
- if(nowVisible) index++;
- if ((IsHContactGroup(hItem) && group->cl.items[group->scanIndex]->type==CLCIT_GROUP && ((UINT_PTR)hItem&~HCONTACT_ISGROUP)==group->cl.items[group->scanIndex]->groupId) ||
- (IsHContactContact(hItem) && group->cl.items[group->scanIndex]->type==CLCIT_CONTACT && group->cl.items[group->scanIndex]->hContact==hItem) ||
- (IsHContactInfo(hItem) && group->cl.items[group->scanIndex]->type==CLCIT_INFO && group->cl.items[group->scanIndex]->hContact==(HANDLE)((UINT_PTR)hItem&~HCONTACT_ISINFO))) {
- if(isVisible) {
- if (!nowVisible) *isVisible=0;
- else {
- if ((index+1)*dat->rowHeight<dat->yScroll) *isVisible=0;
- else {
- RECT clRect;
- GetClientRect(hwnd,&clRect);
- if(index*dat->rowHeight>=dat->yScroll+clRect.bottom) *isVisible=0;
- else *isVisible=1;
- } } }
-
- if(contact) *contact=group->cl.items[group->scanIndex];
- if(subgroup) *subgroup=group;
- return 1;
- }
-
- if (group->cl.items[group->scanIndex]->type==CLCIT_CONTACT &&
- group->cl.items[group->scanIndex]->SubAllocated>0)
- for (i=1; i<=group->cl.items[group->scanIndex]->SubAllocated; i++)
- if (IsHContactContact(hItem) && group->cl.items[group->scanIndex]->subcontacts[i-1].hContact==hItem)
- {
- if(contact) *contact=&group->cl.items[group->scanIndex]->subcontacts[i-1];
- if(subgroup) *subgroup=group;
- return 1;
- }
-
- if(group->cl.items[group->scanIndex]->type==CLCIT_GROUP) {
- struct ClcGroup* save = group;
- group=group->cl.items[group->scanIndex]->group;
- group->scanIndex=0;
- nowVisible&=group->expanded;
- continue;
- }
- group->scanIndex++;
- }
- return 0;
-}
-#define CacheArrSize 255
-struct ClcGroup *CacheIndex[CacheArrSize]={NULL};
-boolean CacheIndexClear=TRUE;
-void ClearRowByIndexCache()
-{
- if (!CacheIndexClear)
- {
- memset(CacheIndex,0,sizeof(CacheIndex));
- CacheIndexClear=TRUE;
- }
-
-}
-int GetRowByIndex(struct ClcData *dat,int testindex,struct ClcContact **contact,struct ClcGroup **subgroup)
-{
- int index=0,i;
- struct ClcGroup *group=&dat->list;
-
- if (testindex<0) return (-1);
- // if (FALSE&&(testindex>0)&&testindex<CacheArrSize&&CacheIndex[testindex]!=NULL)
- // {
- // if(contact) *contact=&(CacheIndex[testindex])->cl.items[group->scanIndex];
- // if(subgroup) *subgroup=(CacheIndex[testindex]);
- // return (testindex);
- // }else
- {
- group->scanIndex=0;
- for (;;) {
- if(group->scanIndex==group->cl.count) {
- group=group->parent;
- if(group==NULL) break;
- group->scanIndex++;
- continue;
- }
- if ((index>0) && (index<CacheArrSize))
- {
- CacheIndex[index]=group;
- CacheIndexClear=FALSE;
- }
-
- if(testindex==index) {
- if(contact) *contact = group->cl.items[group->scanIndex];
- if(subgroup) *subgroup = group;
- return index;
- }
-
- if (group->cl.items[group->scanIndex]->type==CLCIT_CONTACT)
- if (group->cl.items[group->scanIndex]->SubAllocated)
- if (group->cl.items[group->scanIndex]->SubExpanded)
- {
- for (i=0;i<group->cl.items[group->scanIndex]->SubAllocated;i++)
- {
- if ((index>0) && (index<CacheArrSize))
- {
- CacheIndex[index]=group;
- CacheIndexClear=FALSE;
- }
- index++;
- if(testindex==index) {
- if(contact) *contact=&group->cl.items[group->scanIndex]->subcontacts[i];
- if(subgroup) *subgroup=group;
- return index;
- }
- }
- }
- index++;
- if ((group->cl.items[group->scanIndex]->type==CLCIT_CONTACT) && (group->cl.items[group->scanIndex]->flags & CONTACTF_STATUSMSG)) {
- index++;
- }
-
- if(group->cl.items[group->scanIndex]->type==CLCIT_GROUP && group->cl.items[group->scanIndex]->group->expanded) {
- group=group->cl.items[group->scanIndex]->group;
- group->scanIndex=0;
- continue;
- }
- group->scanIndex++;
- }
- }
- return -1;
-}
diff --git a/plugins/Mwclist/clcidents.cpp b/plugins/Mwclist/clcidents.cpp
new file mode 100644
index 0000000000..0f9d4692ac
--- /dev/null
+++ b/plugins/Mwclist/clcidents.cpp
@@ -0,0 +1,301 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2003 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+#include "commonheaders.h"
+#include "m_clc.h"
+#include "clc.h"
+
+/* the CLC uses 3 different ways to identify elements in its list, this file
+contains routines to convert between them.
+
+1) struct ClcContact/struct ClcGroup pair. Only ever used within the duration
+of a single operation, but used at some point in nearly everything
+2) index integer. The 0-based number of the item from the top. Only visible
+items are counted (ie not closed groups). Used for saving selection and drag
+highlight
+3) hItem handle. Either the hContact or (hGroup|HCONTACT_ISGROUP). Used
+exclusively externally
+
+1->2: GetRowsPriorTo()
+1->3: ContactToHItem()
+3->1: FindItem()
+2->1: GetRowByIndex()
+*/
+
+int GetRowsPriorTo(struct ClcGroup *group,struct ClcGroup *subgroup,int contactIndex)
+{
+ int count = 0;
+
+ group->scanIndex = 0;
+ for (;;) {
+ if (group->scanIndex == group->cl.count) {
+ group = group->parent;
+ if (group == NULL) break;
+ group->scanIndex++;
+ continue;
+ }
+ if (group == subgroup && contactIndex == group->scanIndex) return count;
+ count++;
+ if ((group->cl.items[group->scanIndex]->type == CLCIT_CONTACT) && (group->cl.items[group->scanIndex]->flags & CONTACTF_STATUSMSG)) {
+ count++;
+ }
+
+ if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) {
+ if (group->cl.items[group->scanIndex]->group == subgroup && contactIndex == -1)
+ return count-1;
+ if (group->cl.items[group->scanIndex]->group->expanded) {
+ group = group->cl.items[group->scanIndex]->group;
+ group->scanIndex = 0;
+ continue;
+ }
+ }
+
+ if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT)
+ count += group->cl.items[group->scanIndex]->SubAllocated*group->cl.items[group->scanIndex]->SubExpanded;
+
+ group->scanIndex++;
+ }
+ return -1;
+}
+
+pdisplayNameCacheEntry GetCLCFullCacheEntry(struct ClcData *dat,HANDLE hContact)
+{
+ int idx;
+ displayNameCacheEntry dnce, *pdnce,*pdnce2;
+
+ if (hContact == 0) return NULL;
+ dnce.hContact = hContact;
+
+ pdnce = (displayNameCacheEntry*)li.List_Find(&dat->lCLCContactsCache,&dnce);
+
+ if (pdnce == NULL)
+ {
+ pdnce = (displayNameCacheEntry*)mir_calloc(sizeof(displayNameCacheEntry));
+ pdnce->hContact = hContact;
+ li.List_GetIndex(&dat->lCLCContactsCache,pdnce,&idx);
+ li.List_Insert(&dat->lCLCContactsCache,pdnce,idx);
+
+ pdnce2 = (displayNameCacheEntry*)li.List_Find(&dat->lCLCContactsCache,&dnce);//for check
+ if (pdnce2->hContact != pdnce->hContact)
+ return NULL;
+
+ if (pdnce2 != pdnce)
+ return NULL;
+ }
+
+ return (pdnce);
+}
+
+void ClearClcContactCache(struct ClcData *dat,HANDLE hContact)
+{
+ pdisplayNameCacheEntry cacheEntry;
+
+ if (hContact == INVALID_HANDLE_VALUE) {
+ int i,tick;
+ tick = GetTickCount();
+
+ for (i = 0;i<(dat->lCLCContactsCache.realCount);i++) {
+ pdisplayNameCacheEntry pdnce = (pdisplayNameCacheEntry)dat->lCLCContactsCache.items[i];
+ pdnce->ClcContact = NULL;
+ }
+ tick = GetTickCount()-tick;
+ {
+ char buf[256];
+ sprintf (buf,"Clear full cache %d ms\r\n",tick);
+ OutputDebugStringA(buf);
+ }
+ }
+ if ( !IsHContactGroup(hContact) && !IsHContactInfo(hContact)) {
+ cacheEntry = GetCLCFullCacheEntry(dat,hContact);
+ if (cacheEntry != NULL)
+ cacheEntry->ClcContact = NULL;
+ }
+}
+
+void SetClcContactCacheItem(struct ClcData *dat,HANDLE hContact,void *contact)
+{
+ pdisplayNameCacheEntry cacheEntry;
+ if ( !IsHContactGroup(hContact) && !IsHContactInfo(hContact)) {
+ cacheEntry = GetCLCFullCacheEntry(dat,hContact);
+ if (cacheEntry != NULL)
+ cacheEntry->ClcContact = contact;
+ }
+}
+
+int FindItem(HWND hwnd,struct ClcData *dat,HANDLE hItem,struct ClcContact **contact,struct ClcGroup **subgroup,int *isVisible)
+{
+ int index = 0, i;
+ int nowVisible = 1;
+ struct ClcGroup *group = &dat->list;
+
+ group->scanIndex = 0;
+
+ if (isVisible == NULL && hItem != NULL && subgroup == NULL && !IsHContactGroup(hItem) && !IsHContactInfo(hItem)) {
+ //try use cache
+ pdisplayNameCacheEntry cacheEntry;
+ cacheEntry = GetCLCFullCacheEntry(dat,hItem);
+ if (cacheEntry != NULL) {
+ if (cacheEntry->ClcContact == NULL) {
+ int *isv = {0};
+ void *z = {0};
+ int ret;
+ ret = FindItem(hwnd,dat,hItem,(struct ClcContact ** )&z,(struct ClcGroup** )&isv,NULL);
+ if (ret = 0) {return 0;}
+ cacheEntry->ClcContact = (void *)z;
+ }
+
+ if (cacheEntry->ClcContact != NULL) {
+ if (contact != NULL)
+ *contact = (struct ClcContact *)cacheEntry->ClcContact;
+
+ return 1;
+ }
+ }
+ }
+
+ group = &dat->list;
+
+ for (;;) {
+ if (group->scanIndex == group->cl.count) {
+ struct ClcGroup *tgroup;
+ group = group->parent;
+ if (group == NULL)
+ break;
+
+ nowVisible = 1;
+ for (tgroup = group;tgroup;tgroup = tgroup->parent)
+ if (!group->expanded) {
+ nowVisible = 0;
+ break;
+ }
+
+ group->scanIndex++;
+ continue;
+ }
+ if (nowVisible) index++;
+ if ((IsHContactGroup(hItem) && group->cl.items[group->scanIndex]->type == CLCIT_GROUP && ((UINT_PTR)hItem&~HCONTACT_ISGROUP) == group->cl.items[group->scanIndex]->groupId) ||
+ (IsHContactContact(hItem) && group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && group->cl.items[group->scanIndex]->hContact == hItem) ||
+ (IsHContactInfo(hItem) && group->cl.items[group->scanIndex]->type == CLCIT_INFO && group->cl.items[group->scanIndex]->hContact == (HANDLE)((UINT_PTR)hItem&~HCONTACT_ISINFO))) {
+ if (isVisible) {
+ if (!nowVisible) *isVisible = 0;
+ else {
+ if ((index+1)*dat->rowHeight<dat->yScroll) *isVisible = 0;
+ else {
+ RECT clRect;
+ GetClientRect(hwnd,&clRect);
+ if (index*dat->rowHeight>=dat->yScroll+clRect.bottom) *isVisible = 0;
+ else *isVisible = 1;
+ } } }
+
+ if (contact) *contact = group->cl.items[group->scanIndex];
+ if (subgroup) *subgroup = group;
+ return 1;
+ }
+
+ if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT &&
+ group->cl.items[group->scanIndex]->SubAllocated>0)
+ for (i = 1; i<=group->cl.items[group->scanIndex]->SubAllocated; i++)
+ if (IsHContactContact(hItem) && group->cl.items[group->scanIndex]->subcontacts[i-1].hContact == hItem) {
+ if (contact) *contact = &group->cl.items[group->scanIndex]->subcontacts[i-1];
+ if (subgroup) *subgroup = group;
+ return 1;
+ }
+
+ if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) {
+ struct ClcGroup* save = group;
+ group = group->cl.items[group->scanIndex]->group;
+ group->scanIndex = 0;
+ nowVisible &= group->expanded;
+ continue;
+ }
+ group->scanIndex++;
+ }
+ return 0;
+}
+#define CacheArrSize 255
+struct ClcGroup *CacheIndex[CacheArrSize] = {NULL};
+boolean CacheIndexClear = TRUE;
+void ClearRowByIndexCache()
+{
+ if (!CacheIndexClear) {
+ memset(CacheIndex,0,sizeof(CacheIndex));
+ CacheIndexClear = TRUE;
+ }
+}
+
+int GetRowByIndex(struct ClcData *dat,int testindex,struct ClcContact **contact,struct ClcGroup **subgroup)
+{
+ int index = 0,i;
+ struct ClcGroup *group = &dat->list;
+
+ if (testindex < 0) return -1;
+
+ group->scanIndex = 0;
+ for (;;) {
+ if (group->scanIndex == group->cl.count) {
+ group = group->parent;
+ if (group == NULL) break;
+ group->scanIndex++;
+ continue;
+ }
+ if ((index>0) && (index<CacheArrSize))
+ {
+ CacheIndex[index] = group;
+ CacheIndexClear = FALSE;
+ }
+
+ if (testindex == index) {
+ if (contact) *contact = group->cl.items[group->scanIndex];
+ if (subgroup) *subgroup = group;
+ return index;
+ }
+
+ if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT)
+ if (group->cl.items[group->scanIndex]->SubAllocated)
+ if (group->cl.items[group->scanIndex]->SubExpanded) {
+ for (i = 0;i<group->cl.items[group->scanIndex]->SubAllocated;i++) {
+ if ((index>0) && (index<CacheArrSize)) {
+ CacheIndex[index] = group;
+ CacheIndexClear = FALSE;
+ }
+ index++;
+ if (testindex == index) {
+ if (contact) *contact = &group->cl.items[group->scanIndex]->subcontacts[i];
+ if (subgroup) *subgroup = group;
+ return index;
+ }
+ }
+ }
+
+ index++;
+ if ((group->cl.items[group->scanIndex]->type == CLCIT_CONTACT) && (group->cl.items[group->scanIndex]->flags & CONTACTF_STATUSMSG))
+ index++;
+
+ if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP && group->cl.items[group->scanIndex]->group->expanded) {
+ group = group->cl.items[group->scanIndex]->group;
+ group->scanIndex = 0;
+ continue;
+ }
+ group->scanIndex++;
+ }
+ return -1;
+}
diff --git a/plugins/Mwclist/clcitems.c b/plugins/Mwclist/clcitems.c
deleted file mode 100644
index 8c2e20efb3..0000000000
--- a/plugins/Mwclist/clcitems.c
+++ /dev/null
@@ -1,695 +0,0 @@
-/*
-
-Miranda IM: the free IM client for Microsoft* Windows*
-
-Copyright 2000-2003 Miranda ICQ/IM project,
-all portions of this codebase are copyrighted to the people
-listed in contributors.txt.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-#include "commonheaders.h"
-#include "m_clc.h"
-#include "clc.h"
-#include "clist.h"
-#include "m_metacontacts.h"
-
-
-extern int ( *saveAddItemToGroup )( struct ClcGroup *group, int iAboveItem );
-extern int ( *saveAddInfoItemToGroup )(struct ClcGroup *group,int flags,const TCHAR *pszText);
-extern struct ClcGroup* ( *saveAddGroup )(HWND hwnd,struct ClcData *dat,const TCHAR *szName,DWORD flags,int groupId,int calcTotalMembers);
-extern void (*saveFreeContact)(struct ClcContact *p);
-extern void (*saveFreeGroup)(struct ClcGroup *p);
-
-//routines for managing adding/removal of items in the list, including sorting
-
-extern void ClearClcContactCache(struct ClcData *dat,HANDLE hContact);
-
-void AddSubcontacts(struct ClcContact * cont)
-{
- int subcount,i,j;
- HANDLE hsub;
- pdisplayNameCacheEntry cacheEntry;
- cacheEntry=GetContactFullCacheEntry(cont->hContact);
- OutputDebugStringA("Proceed AddSubcontacts\r\n");
- subcount=(int)CallService(MS_MC_GETNUMCONTACTS,(WPARAM)cont->hContact,0);
- cont->SubExpanded=DBGetContactSettingByte(cont->hContact,"CList","Expanded",0);
- cont->isSubcontact=0;
- cont->subcontacts=(struct ClcContact *) mir_realloc(cont->subcontacts, sizeof(struct ClcContact)*subcount);
- cont->SubAllocated=subcount;
- i=0;
- for (j=0; j<subcount; j++)
- {
- hsub=(HANDLE)CallService(MS_MC_GETSUBCONTACT,(WPARAM)cont->hContact,j);
- cacheEntry=GetContactFullCacheEntry(hsub);
- if (!(DBGetContactSettingByte(NULL,"CLC","MetaHideOfflineSub",1) && DBGetContactSettingByte(NULL,"CList","HideOffline",SETTING_HIDEOFFLINE_DEFAULT) )||
- cacheEntry->status!=ID_STATUS_OFFLINE )
- {
- cont->subcontacts[i].hContact=cacheEntry->hContact;
- cont->subcontacts[i].iImage=CallService(MS_CLIST_GETCONTACTICON,(WPARAM)cacheEntry->hContact,0);
- memset(cont->subcontacts[i].iExtraImage,0xFF,SIZEOF(cont->subcontacts[i].iExtraImage));
- cont->subcontacts[i].proto=cacheEntry->szProto;
- lstrcpyn(cont->subcontacts[i].szText,cacheEntry->name,SIZEOF(cont->subcontacts[i].szText));
- cont->subcontacts[i].type=CLCIT_CONTACT;
- //cont->flags=0;//CONTACTF_ONLINE;
- cont->subcontacts[i].isSubcontact=1;
- i++;
- }
- }
- cont->SubAllocated=i;
- if (!i) mir_free(cont->subcontacts);
-}
-
-void FreeContact(struct ClcContact *p)
-{
- if ( p->SubAllocated && !p->isSubcontact)
- mir_free(p->subcontacts);
-
- saveFreeContact( p );
-}
-
-int AddItemToGroup(struct ClcGroup *group,int iAboveItem)
-{
- iAboveItem = saveAddItemToGroup( group, iAboveItem );
- ClearRowByIndexCache();
- return iAboveItem;
-}
-
-struct ClcGroup *AddGroup(HWND hwnd,struct ClcData *dat,const TCHAR *szName,DWORD flags,int groupId,int calcTotalMembers)
-{
- struct ClcGroup* result;
-
- ClearRowByIndexCache();
- dat->NeedResort=1;
- result = saveAddGroup( hwnd, dat, szName, flags, groupId, calcTotalMembers);
- ClearRowByIndexCache();
- return result;
-}
-
-void FreeGroup(struct ClcGroup *group)
-{
- saveFreeGroup( group );
- ClearRowByIndexCache();
-}
-
-int AddInfoItemToGroup(struct ClcGroup *group,int flags,const TCHAR *pszText)
-{
- int i = saveAddInfoItemToGroup( group, flags, pszText );
- ClearRowByIndexCache();
- return i;
-}
-
-static struct ClcContact * AddContactToGroup(struct ClcData *dat,struct ClcGroup *group,pdisplayNameCacheEntry cacheEntry)
-{
- char *szProto;
- WORD apparentMode;
- DWORD idleMode;
- HANDLE hContact;
- DBVARIANT dbv;
- int i;
- char AdvancedService[255]={0};
- int img =-1;
- int basicIcon = 0;
-
- if (cacheEntry==NULL) return NULL;
- if (group==NULL) return NULL;
- if (dat==NULL) return NULL;
-
- hContact=cacheEntry->hContact;
- //ClearClcContactCache(hContact);
-
- dat->NeedResort=1;
- for(i=group->cl.count-1;i>=0;i--)
- if(group->cl.items[i]->type!=CLCIT_INFO || !(group->cl.items[i]->flags&CLCIIF_BELOWCONTACTS)) break;
- i=AddItemToGroup(group,i+1);
- group->cl.items[i]->type = CLCIT_CONTACT;
- group->cl.items[i]->SubAllocated = 0;
- group->cl.items[i]->isSubcontact = 0;
- group->cl.items[i]->subcontacts = NULL;
-
- _snprintf(AdvancedService,sizeof(AdvancedService),"%s%s",cacheEntry->szProto,"/GetAdvancedStatusIcon");
-
- if (ServiceExists(AdvancedService))
- img = CallService(AdvancedService,(WPARAM)hContact, (LPARAM)0);
-
- if (img==-1 || !(LOWORD(img))) img = CallService(MS_CLIST_GETCONTACTICON,(WPARAM)hContact,0);
-
- group->cl.items[i]->iImage = img;
-
- cacheEntry=GetContactFullCacheEntry(hContact);
- group->cl.items[i]->hContact=hContact;
-
- //cacheEntry->ClcContact=&(group->cl.items[i]);
- //SetClcContactCacheItem(dat,hContact,&(group->cl.items[i]));
-
- szProto=cacheEntry->szProto;
- if(szProto!=NULL&&!pcli->pfnIsHiddenMode(dat,cacheEntry->status))
- group->cl.items[i]->flags|=CONTACTF_ONLINE;
- apparentMode=szProto!=NULL?cacheEntry->ApparentMode:0;
- if(apparentMode==ID_STATUS_OFFLINE) group->cl.items[i]->flags|=CONTACTF_INVISTO;
- else if(apparentMode==ID_STATUS_ONLINE) group->cl.items[i]->flags|=CONTACTF_VISTO;
- else if(apparentMode) group->cl.items[i]->flags|=CONTACTF_VISTO|CONTACTF_INVISTO;
- if(cacheEntry->NotOnList) group->cl.items[i]->flags|=CONTACTF_NOTONLIST;
- idleMode=szProto!=NULL?cacheEntry->IdleTS:0;
- if (idleMode) group->cl.items[i]->flags|=CONTACTF_IDLE;
-
- lstrcpyn(group->cl.items[i]->szText,cacheEntry->name, SIZEOF(group->cl.items[i]->szText));
- group->cl.items[i]->proto = szProto;
-
-
- if (dat->style&CLS_SHOWSTATUSMESSAGES)
- {
- if (!DBGetContactSettingTString(hContact, "CList", "StatusMsg", &dbv)) {
- int j;
- lstrcpyn(group->cl.items[i]->szStatusMsg, dbv.ptszVal, SIZEOF(group->cl.items[i]->szStatusMsg));
- for (j=(int)_tcslen(group->cl.items[i]->szStatusMsg)-1;j>=0;j--) {
- if (group->cl.items[i]->szStatusMsg[j]=='\r' || group->cl.items[i]->szStatusMsg[j]=='\n' || group->cl.items[i]->szStatusMsg[j]=='\t') {
- group->cl.items[i]->szStatusMsg[j] = ' ';
- }
- }
- DBFreeVariant(&dbv);
- if (_tcslen(group->cl.items[i]->szStatusMsg)>0) {
- group->cl.items[i]->flags |= CONTACTF_STATUSMSG;
- }
- }
- }
-
- ClearRowByIndexCache();
- return group->cl.items[i];
-}
-
-void AddContactToTree(HWND hwnd,struct ClcData *dat,HANDLE hContact,int updateTotalCount,int checkHideOffline)
-{
- struct ClcGroup *group;
- struct ClcContact * cont;
- pdisplayNameCacheEntry cacheEntry;
- DWORD style=GetWindowLongPtr(hwnd,GWL_STYLE);
- WORD status;
- char *szProto;
-
- if (FindItem(hwnd,dat,hContact,NULL,NULL,NULL)==1){return;}
- cacheEntry=GetContactFullCacheEntry(hContact);
- if (cacheEntry==NULL) return;
- szProto=cacheEntry->szProto;
-
-
- //char *szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0);
-
- dat->NeedResort=1;
- ClearRowByIndexCache();
- ClearClcContactCache(dat,hContact);
-
- if(style&CLS_NOHIDEOFFLINE) checkHideOffline=0;
- if(checkHideOffline) {
- if(szProto==NULL) status=ID_STATUS_OFFLINE;
- else status=cacheEntry->status;
- }
-
- if(lstrlen(cacheEntry->szGroup)==0)
- group=&dat->list;
- else {
- group=AddGroup(hwnd,dat,cacheEntry->szGroup,(DWORD)-1,0,0);
- if(group==NULL) {
- int i,len;
- DWORD groupFlags;
- TCHAR *szGroupName;
- if (!(style&CLS_HIDEEMPTYGROUPS)) {/*mir_free(dbv.pszVal);*/return;}
- if(checkHideOffline && pcli->pfnIsHiddenMode(dat,status)) {
- for(i=1;;i++) {
- szGroupName = pcli->pfnGetGroupName(i,&groupFlags);
- if(szGroupName==NULL) {/*mir_free(dbv.pszVal);*/ return;} //never happens
- if (!lstrcmp(szGroupName,cacheEntry->szGroup)) break;
- }
- if(groupFlags&GROUPF_HIDEOFFLINE) {/*mir_free(dbv.pszVal);*/ return;}
- }
- for(i=1;;i++) {
- szGroupName=pcli->pfnGetGroupName(i,&groupFlags);
- if(szGroupName==NULL) {/*mir_free(dbv.pszVal);*/ return;} //never happens
- if (!lstrcmp(szGroupName,cacheEntry->szGroup)) break;
- len=lstrlen(szGroupName);
- if (!_tcsncmp(szGroupName,cacheEntry->szGroup,len) && cacheEntry->szGroup[len]=='\\')
- AddGroup(hwnd,dat,szGroupName,groupFlags,i,1);
- }
- group=AddGroup(hwnd,dat,cacheEntry->szGroup,groupFlags,i,1);
- }
- // mir_free(dbv.pszVal);
- }
- if(checkHideOffline) {
- if(pcli->pfnIsHiddenMode(dat,status) && (style&CLS_HIDEOFFLINE || group->hideOffline)) {
- if(updateTotalCount) group->totalMembers++;
- return;
- }
- }
- cont=AddContactToGroup(dat,group,cacheEntry);
- if (cont)
- if (cont->proto)
- {
- cont->SubAllocated=0;
- if (strcmp(cont->proto,"MetaContacts")==0)
- AddSubcontacts(cont);
- }
- if(updateTotalCount) group->totalMembers++;
- ClearRowByIndexCache();
-}
-
-extern struct ClcGroup* ( *saveRemoveItemFromGroup )(HWND hwnd,struct ClcGroup *group,struct ClcContact *contact,int updateTotalCount);
-
-struct ClcGroup *RemoveItemFromGroup(HWND hwnd,struct ClcGroup *group,struct ClcContact *contact,int updateTotalCount)
-{
- ClearRowByIndexCache();
- if(contact->type==CLCIT_CONTACT) {
- struct ClcData* dat = (struct ClcData*)GetWindowLongPtr(hwnd,0);
- ClearClcContactCache(dat,contact->hContact);
- }
-
- group = saveRemoveItemFromGroup(hwnd, group, contact, updateTotalCount);
-
- ClearRowByIndexCache();
- return group;
-}
-
-void DeleteItemFromTree(HWND hwnd,HANDLE hItem)
-{
- struct ClcContact *contact;
- struct ClcGroup *group;
- struct ClcData *dat=(struct ClcData*)GetWindowLongPtr(hwnd,0);
-
- ClearRowByIndexCache();
- dat->NeedResort=1;
-
- if (!FindItem(hwnd,dat,hItem,&contact,&group,NULL)) {
- DBVARIANT dbv;
- int i,nameOffset;
- if (!IsHContactContact(hItem)) return;
- ClearClcContactCache(dat,hItem);
-
- if(DBGetContactSettingTString(hItem,"CList","Group",&dbv)) return;
-
- //decrease member counts of all parent groups too
- group=&dat->list;
- nameOffset=0;
- for(i=0;;i++) {
- if(group->scanIndex==group->cl.count) break;
- if(group->cl.items[i]->type==CLCIT_GROUP) {
- int len=lstrlen(group->cl.items[i]->szText);
- if (!_tcsncmp(group->cl.items[i]->szText,dbv.ptszVal+nameOffset,len) && (dbv.ptszVal[nameOffset+len]=='\\' || dbv.pszVal[nameOffset+len]=='\0')) {
- group->totalMembers--;
- if(dbv.pszVal[nameOffset+len]=='\0') break;
- }
- }
- }
- mir_free(dbv.pszVal);
- }
- else RemoveItemFromGroup(hwnd,group,contact,1);
-
- ClearRowByIndexCache();
-}
-
-
-
-void RebuildEntireList(HWND hwnd,struct ClcData *dat)
-{
-// char *szProto;
- DWORD style=GetWindowLongPtr(hwnd,GWL_STYLE);
- HANDLE hContact;
- struct ClcContact * cont;
- struct ClcGroup *group;
- //DBVARIANT dbv;
- int tick=GetTickCount();
-
- ClearRowByIndexCache();
- ClearClcContactCache(dat,INVALID_HANDLE_VALUE);
-
- dat->list.expanded=1;
- dat->list.hideOffline=DBGetContactSettingByte(NULL,"CLC","HideOfflineRoot",0);
- memset( &dat->list.cl, 0, sizeof( dat->list.cl ));
- dat->list.cl.increment = 30;
- dat->NeedResort=1;
- dat->selection=-1;
- dat->HiLightMode=DBGetContactSettingByte(NULL,"CLC","HiLightMode",0);
- {
- int i;
- TCHAR *szGroupName;
- DWORD groupFlags;
-
- for(i=1;;i++) {
- szGroupName=pcli->pfnGetGroupName(i,&groupFlags);
- if(szGroupName==NULL) break;
- AddGroup(hwnd,dat,szGroupName,groupFlags,i,0);
- }
- }
-
- hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0);
- while(hContact) {
-
- pdisplayNameCacheEntry cacheEntry;
- cont=NULL;
- cacheEntry=GetContactFullCacheEntry(hContact);
- //cacheEntry->ClcContact=NULL;
- ClearClcContactCache(dat,hContact);
- if (cacheEntry==NULL)
- {
- MessageBoxA(0,"Fail To Get CacheEntry for hContact","!!!!!!!!",0);
- }
-
-
- if(style&CLS_SHOWHIDDEN || !cacheEntry->Hidden) {
- if(lstrlen(cacheEntry->szGroup)==0)
- group=&dat->list;
- else {
- group=AddGroup(hwnd,dat,cacheEntry->szGroup,(DWORD)-1,0,0);
- //mir_free(dbv.pszVal);
- }
-
- if(group!=NULL) {
- group->totalMembers++;
- if (!(style&CLS_NOHIDEOFFLINE) && (style&CLS_HIDEOFFLINE || group->hideOffline)) {
- //szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0);
- if(cacheEntry->szProto==NULL) {
- if (!pcli->pfnIsHiddenMode(dat,ID_STATUS_OFFLINE)||cacheEntry->noHiddenOffline)
- cont=AddContactToGroup(dat,group,cacheEntry);
- }
- else
- if (!pcli->pfnIsHiddenMode(dat,cacheEntry->status)||cacheEntry->noHiddenOffline)
- cont=AddContactToGroup(dat,group,cacheEntry);
- }
- else cont=AddContactToGroup(dat,group,cacheEntry);
- }
- }
- if (cont)
- if (cont->proto)
- {
- cont->SubAllocated=0;
- if (strcmp(cont->proto,"MetaContacts")==0)
- AddSubcontacts(cont);
- }
- hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0);
- }
-
- if(style&CLS_HIDEEMPTYGROUPS) {
- group=&dat->list;
- group->scanIndex=0;
- for (;;) {
- if(group->scanIndex==group->cl.count) {
- group=group->parent;
- if(group==NULL) break;
- }
- else if(group->cl.items[group->scanIndex]->type==CLCIT_GROUP) {
- if(group->cl.items[group->scanIndex]->group->cl.count==0) {
- group=RemoveItemFromGroup(hwnd,group,group->cl.items[group->scanIndex],0);
- }
- else {
- group=group->cl.items[group->scanIndex]->group;
- group->scanIndex=0;
- }
- continue;
- }
- group->scanIndex++;
- }
- }
-
- SortCLC(hwnd,dat,0);
- tick=GetTickCount()-tick;
- {
- char buf[255];
- //sprintf(buf,"%s %s took %i ms",__FILE__,__LINE__,tick);
- sprintf(buf,"RebuildEntireList %d \r\n",tick);
-
- OutputDebugStringA(buf);
- DBWriteContactSettingDword((HANDLE)0,"CLUI","PF:Last RebuildEntireList Time:",tick);
- }
-}
-
-
-int GetNewSelection(struct ClcGroup *group, int selection, int direction)
-{
- int lastcount=0, count=0;//group->cl.count;
- struct ClcGroup *topgroup=group;
- if (selection<0) {
- return 0;
- }
- group->scanIndex=0;
- for (;;) {
- if(group->scanIndex==group->cl.count) {
- group=group->parent;
- if(group==NULL) break;
- group->scanIndex++;
- continue;
- }
- if (count>=selection) return count;
- lastcount = count;
- count++;
- if ((group->cl.items[group->scanIndex]->type==CLCIT_CONTACT) && (group->cl.items[group->scanIndex]->flags & CONTACTF_STATUSMSG)) {
- count++;
- }
- if (!direction) {
- if (count>selection) return lastcount;
- }
- if(group->cl.items[group->scanIndex]->type==CLCIT_GROUP && (group->cl.items[group->scanIndex]->group->expanded)) {
- group=group->cl.items[group->scanIndex]->group;
- group->scanIndex=0;
- // count+=group->cl.count;
- continue;
- }
- group->scanIndex++;
- }
- return lastcount;
- }
-
-int GetGroupContentsCount(struct ClcGroup *group,int visibleOnly)
-{
- int count=0;//group->cl.count;
- struct ClcGroup *topgroup=group;
-
- group->scanIndex=0;
- for (;;) {
- if(group->scanIndex==group->cl.count) {
- if(group==topgroup) break;
- group=group->parent;
- group->scanIndex++;
- continue;
-
- }
-// else if (group->cl.items[group->scanIndex]->type==CLCIT_CONTACT && (group->cl.items[group->scanIndex]->SubAllocated>0) && visibleOnly && group->cl.items[group->scanIndex]->SubExpanded)
-// {
-// count+=group->cl.items[group->scanIndex]->SubAllocated;
- count++;
- if ((group->cl.items[group->scanIndex]->type==CLCIT_CONTACT) && (group->cl.items[group->scanIndex]->flags & CONTACTF_STATUSMSG)) {
- count++;
-
- }
-// else if(group->cl.items[group->scanIndex]->type==CLCIT_GROUP && (!visibleOnly || group->cl.items[group->scanIndex]->group->expanded)) {
- if(group->cl.items[group->scanIndex]->type==CLCIT_GROUP && (!visibleOnly || group->cl.items[group->scanIndex]->group->expanded)) {
- group=group->cl.items[group->scanIndex]->group;
- group->scanIndex=0;
-// count+=group->cl.count;
- continue;
- }
- group->scanIndex++;
- }
- return count;
-}
-
-extern void ( *saveSortCLC )(HWND hwnd,struct ClcData *dat,int useInsertionSort);
-
-void SortCLC(HWND hwnd,struct ClcData *dat,int useInsertionSort)
-{
-#ifdef _DEBUG
- DWORD tick = GetTickCount();
-#endif
- int oldSort = dat->NeedResort;
- saveSortCLC(hwnd, dat, useInsertionSort);
- if ( oldSort )
- ClearRowByIndexCache();
-
-#ifdef _DEBUG
- {
- char buf[255];
- //sprintf(buf,"%s %s took %i ms",__FILE__,__LINE__,tick);
- tick = GetTickCount()-tick;
- if (tick>5)
- {
- sprintf(buf,"SortCLC %d \r\n",tick);
- OutputDebugStringA(buf);
- DBWriteContactSettingDword((HANDLE)0,"CLUI","PF:Last SortCLC Time:",tick);
- }
- }
-#endif
-}
-
-struct SavedContactState_t {
- HANDLE hContact;
- BYTE iExtraImage[MAXEXTRACOLUMNS];
- int checked;
-};
-
-struct SavedGroupState_t
-{
- int groupId, expanded;
-};
-
-struct SavedInfoState_t
-{
- int parentId;
- struct ClcContact contact;
-};
-
-void SaveStateAndRebuildList(HWND hwnd,struct ClcData *dat)
-{
- NMCLISTCONTROL nm;
- int i,j;
- struct SavedGroupState_t *savedGroup=NULL;
- int savedGroupCount=0,savedGroupAlloced=0;
- struct SavedContactState_t *savedContact=NULL;
- int savedContactCount=0,savedContactAlloced=0;
- struct SavedInfoState_t *savedInfo=NULL;
- int savedInfoCount=0,savedInfoAlloced=0;
- struct ClcGroup *group;
- struct ClcContact *contact;
-
- int tick=GetTickCount();
- int allocstep=1024;
- pcli->pfnHideInfoTip(hwnd,dat);
- KillTimer(hwnd,TIMERID_INFOTIP);
- KillTimer(hwnd,TIMERID_RENAME);
- pcli->pfnEndRename(hwnd,dat,1);
-
- group = &dat->list;
- group->scanIndex=0;
- for (;;) {
- if(group->scanIndex==group->cl.count) {
- group=group->parent;
- if(group==NULL) break;
- }
- else if(group->cl.items[group->scanIndex]->type==CLCIT_GROUP) {
- group=group->cl.items[group->scanIndex]->group;
- group->scanIndex=0;
- if (++savedGroupCount>savedGroupAlloced) {
- savedGroupAlloced+=allocstep;
- savedGroup=(struct SavedGroupState_t*)mir_realloc(savedGroup,sizeof(struct SavedGroupState_t)*savedGroupAlloced);
- }
- savedGroup[savedGroupCount-1].groupId=group->groupId;
- savedGroup[savedGroupCount-1].expanded=group->expanded;
- continue;
- }
- else if(group->cl.items[group->scanIndex]->type==CLCIT_CONTACT) {
- if (++savedContactCount>savedContactAlloced) {
- savedContactAlloced+=allocstep;
- savedContact=(struct SavedContactState_t*)mir_realloc(savedContact,sizeof(struct SavedContactState_t)*savedContactAlloced);
- }
- savedContact[savedContactCount-1].hContact = group->cl.items[group->scanIndex]->hContact;
- CopyMemory(savedContact[savedContactCount-1].iExtraImage, group->cl.items[group->scanIndex]->iExtraImage, MAXEXTRACOLUMNS);
- savedContact[savedContactCount-1].checked = group->cl.items[group->scanIndex]->flags&CONTACTF_CHECKED;
- if (group->cl.items[group->scanIndex]->SubAllocated>0)
- {
- int l;
- for (l=0; l<group->cl.items[group->scanIndex]->SubAllocated; l++)
- {
- if (++savedContactCount>savedContactAlloced) {
- savedContactAlloced+=allocstep;
- savedContact=(struct SavedContactState_t*)mir_realloc(savedContact,sizeof(struct SavedContactState_t)*savedContactAlloced);
- }
- savedContact[savedContactCount-1].hContact = group->cl.items[group->scanIndex]->subcontacts[l].hContact;
- CopyMemory(savedContact[savedContactCount-1].iExtraImage ,group->cl.items[group->scanIndex]->subcontacts[l].iExtraImage,MAXEXTRACOLUMNS);
- savedContact[savedContactCount-1].checked=group->cl.items[group->scanIndex]->subcontacts[l].flags&CONTACTF_CHECKED;
- }
- }
- }
- else if(group->cl.items[group->scanIndex]->type==CLCIT_INFO) {
- if (++savedInfoCount>savedInfoAlloced) {
- savedInfoAlloced+=allocstep;
- savedInfo=(struct SavedInfoState_t*)mir_realloc(savedInfo,sizeof(struct SavedInfoState_t)*savedInfoAlloced);
- }
- if(group->parent==NULL) savedInfo[savedInfoCount-1].parentId=-1;
- else savedInfo[savedInfoCount-1].parentId=group->groupId;
- savedInfo[savedInfoCount-1].contact = *group->cl.items[group->scanIndex];
- }
- group->scanIndex++;
- }
-
- pcli->pfnFreeGroup(&dat->list);
- RebuildEntireList(hwnd,dat);
-
- group=&dat->list;
- group->scanIndex=0;
- for (;;) {
- if(group->scanIndex==group->cl.count) {
- group=group->parent;
- if(group==NULL) break;
- }
- else if(group->cl.items[group->scanIndex]->type==CLCIT_GROUP) {
- group=group->cl.items[group->scanIndex]->group;
- group->scanIndex=0;
- for(i=0;i<savedGroupCount;i++)
- if(savedGroup[i].groupId==group->groupId) {
- group->expanded=savedGroup[i].expanded;
- break;
- }
- continue;
- }
- else if(group->cl.items[group->scanIndex]->type==CLCIT_CONTACT) {
- for(i=0;i<savedContactCount;i++)
- if(savedContact[i].hContact == group->cl.items[group->scanIndex]->hContact) {
- CopyMemory(group->cl.items[group->scanIndex]->iExtraImage,savedContact[i].iExtraImage,MAXEXTRACOLUMNS);
- if(savedContact[i].checked) group->cl.items[group->scanIndex]->flags|=CONTACTF_CHECKED;
- break;
- }
- if (group->cl.items[group->scanIndex]->SubAllocated>0)
- {
- int l;
- for (l=0; l<group->cl.items[group->scanIndex]->SubAllocated; l++)
- for(i=0;i<savedContactCount;i++)
- if(savedContact[i].hContact == group->cl.items[group->scanIndex]->subcontacts[l].hContact) {
- CopyMemory(group->cl.items[group->scanIndex]->subcontacts[l].iExtraImage,savedContact[i].iExtraImage,MAXEXTRACOLUMNS);
- if(savedContact[i].checked) group->cl.items[group->scanIndex]->subcontacts[l].flags|=CONTACTF_CHECKED;
- break;
- }
- }
- }
- group->scanIndex++;
- }
- if(savedGroup) mir_free(savedGroup);
- if(savedContact) mir_free(savedContact);
- for(i=0;i<savedInfoCount;i++) {
- if(savedInfo[i].parentId==-1) group=&dat->list;
- else {
- if (!FindItem(hwnd,dat,(HANDLE)(savedInfo[i].parentId|HCONTACT_ISGROUP),&contact,NULL,NULL)) continue;
- group=contact->group;
- }
- j=AddInfoItemToGroup(group,savedInfo[i].contact.flags,_T(""));
- *group->cl.items[j] = savedInfo[i].contact;
- }
- if(savedInfo) mir_free(savedInfo);
- pcli->pfnRecalculateGroupCheckboxes(hwnd,dat);
-
- RecalcScrollBar(hwnd,dat);
- nm.hdr.code=CLN_LISTREBUILT;
- nm.hdr.hwndFrom=hwnd;
- nm.hdr.idFrom=GetDlgCtrlID(hwnd);
-
-
- //srand(GetTickCount());
-
- tick=GetTickCount()-tick;
- {
- char buf[255];
- //sprintf(buf,"%s %s took %i ms",__FILE__,__LINE__,tick);
- sprintf(buf,"SaveStateAndRebuildList %d \r\n",tick);
-
- OutputDebugStringA(buf);
- }
- ClearRowByIndexCache();
- SendMessage(GetParent(hwnd),WM_NOTIFY,0,(LPARAM)&nm);
-}
diff --git a/plugins/Mwclist/clcitems.cpp b/plugins/Mwclist/clcitems.cpp
new file mode 100644
index 0000000000..3e504a2611
--- /dev/null
+++ b/plugins/Mwclist/clcitems.cpp
@@ -0,0 +1,696 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2003 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+#include "commonheaders.h"
+#include "m_clc.h"
+#include "clc.h"
+#include "clist.h"
+#include "m_metacontacts.h"
+
+
+extern int ( *saveAddItemToGroup )( struct ClcGroup *group, int iAboveItem );
+extern int ( *saveAddInfoItemToGroup )(struct ClcGroup *group,int flags,const TCHAR *pszText);
+extern struct ClcGroup* ( *saveAddGroup )(HWND hwnd,struct ClcData *dat,const TCHAR *szName,DWORD flags,int groupId,int calcTotalMembers);
+extern void (*saveFreeContact)(struct ClcContact *p);
+extern void (*saveFreeGroup)(struct ClcGroup *p);
+
+//routines for managing adding/removal of items in the list, including sorting
+
+extern void ClearClcContactCache(struct ClcData *dat,HANDLE hContact);
+
+void AddSubcontacts(struct ClcContact * cont)
+{
+ int subcount,i,j;
+ HANDLE hsub;
+ pdisplayNameCacheEntry cacheEntry;
+ cacheEntry = GetContactFullCacheEntry(cont->hContact);
+ OutputDebugStringA("Proceed AddSubcontacts\r\n");
+ subcount = (int)CallService(MS_MC_GETNUMCONTACTS,(WPARAM)cont->hContact,0);
+ cont->SubExpanded = DBGetContactSettingByte(cont->hContact,"CList","Expanded",0);
+ cont->isSubcontact = 0;
+ cont->subcontacts = (struct ClcContact *) mir_realloc(cont->subcontacts, sizeof(struct ClcContact)*subcount);
+ cont->SubAllocated = subcount;
+ i = 0;
+ for (j = 0; j<subcount; j++)
+ {
+ hsub = (HANDLE)CallService(MS_MC_GETSUBCONTACT,(WPARAM)cont->hContact,j);
+ cacheEntry = GetContactFullCacheEntry(hsub);
+ if (!(DBGetContactSettingByte(NULL,"CLC","MetaHideOfflineSub",1) && DBGetContactSettingByte(NULL,"CList","HideOffline",SETTING_HIDEOFFLINE_DEFAULT) )||
+ cacheEntry->status != ID_STATUS_OFFLINE )
+ {
+ cont->subcontacts[i].hContact = cacheEntry->hContact;
+ cont->subcontacts[i].iImage = CallService(MS_CLIST_GETCONTACTICON,(WPARAM)cacheEntry->hContact,0);
+ memset(cont->subcontacts[i].iExtraImage,0xFF,SIZEOF(cont->subcontacts[i].iExtraImage));
+ cont->subcontacts[i].proto = cacheEntry->szProto;
+ lstrcpyn(cont->subcontacts[i].szText,cacheEntry->name,SIZEOF(cont->subcontacts[i].szText));
+ cont->subcontacts[i].type = CLCIT_CONTACT;
+ //cont->flags = 0;//CONTACTF_ONLINE;
+ cont->subcontacts[i].isSubcontact = 1;
+ i++;
+ }
+ }
+ cont->SubAllocated = i;
+ if (!i) mir_free(cont->subcontacts);
+}
+
+void FreeContact(struct ClcContact *p)
+{
+ if ( p->SubAllocated && !p->isSubcontact)
+ mir_free(p->subcontacts);
+
+ saveFreeContact( p );
+}
+
+int AddItemToGroup(struct ClcGroup *group,int iAboveItem)
+{
+ iAboveItem = saveAddItemToGroup( group, iAboveItem );
+ ClearRowByIndexCache();
+ return iAboveItem;
+}
+
+struct ClcGroup *AddGroup(HWND hwnd,struct ClcData *dat,const TCHAR *szName,DWORD flags,int groupId,int calcTotalMembers)
+{
+ struct ClcGroup* result;
+
+ ClearRowByIndexCache();
+ dat->NeedResort = 1;
+ result = saveAddGroup( hwnd, dat, szName, flags, groupId, calcTotalMembers);
+ ClearRowByIndexCache();
+ return result;
+}
+
+void FreeGroup(struct ClcGroup *group)
+{
+ saveFreeGroup( group );
+ ClearRowByIndexCache();
+}
+
+int AddInfoItemToGroup(struct ClcGroup *group,int flags,const TCHAR *pszText)
+{
+ int i = saveAddInfoItemToGroup( group, flags, pszText );
+ ClearRowByIndexCache();
+ return i;
+}
+
+static struct ClcContact * AddContactToGroup(struct ClcData *dat,struct ClcGroup *group,pdisplayNameCacheEntry cacheEntry)
+{
+ char *szProto;
+ WORD apparentMode;
+ DWORD idleMode;
+ HANDLE hContact;
+ DBVARIANT dbv;
+ int i;
+ char AdvancedService[255] = {0};
+ int img = -1;
+ int basicIcon = 0;
+
+ if (cacheEntry == NULL || group == NULL || dat == NULL)
+ return NULL;
+
+ hContact = cacheEntry->hContact;
+
+ dat->NeedResort = 1;
+ for (i = group->cl.count-1;i>=0;i--)
+ if (group->cl.items[i]->type != CLCIT_INFO || !(group->cl.items[i]->flags&CLCIIF_BELOWCONTACTS)) break;
+ i = AddItemToGroup(group,i+1);
+ group->cl.items[i]->type = CLCIT_CONTACT;
+ group->cl.items[i]->SubAllocated = 0;
+ group->cl.items[i]->isSubcontact = 0;
+ group->cl.items[i]->subcontacts = NULL;
+
+ _snprintf(AdvancedService,sizeof(AdvancedService),"%s%s",cacheEntry->szProto,"/GetAdvancedStatusIcon");
+
+ if (ServiceExists(AdvancedService))
+ img = CallService(AdvancedService,(WPARAM)hContact, (LPARAM)0);
+
+ if (img == -1 || !(LOWORD(img)))
+ img = CallService(MS_CLIST_GETCONTACTICON,(WPARAM)hContact,0);
+
+ group->cl.items[i]->iImage = img;
+
+ cacheEntry = GetContactFullCacheEntry(hContact);
+ group->cl.items[i]->hContact = hContact;
+
+ //cacheEntry->ClcContact = &(group->cl.items[i]);
+ //SetClcContactCacheItem(dat,hContact,&(group->cl.items[i]));
+
+ szProto = cacheEntry->szProto;
+ if (szProto != NULL&&!pcli->pfnIsHiddenMode(dat,cacheEntry->status))
+ group->cl.items[i]->flags|=CONTACTF_ONLINE;
+ apparentMode = szProto != NULL?cacheEntry->ApparentMode:0;
+ if (apparentMode == ID_STATUS_OFFLINE) group->cl.items[i]->flags|=CONTACTF_INVISTO;
+ else if (apparentMode == ID_STATUS_ONLINE) group->cl.items[i]->flags|=CONTACTF_VISTO;
+ else if (apparentMode) group->cl.items[i]->flags|=CONTACTF_VISTO|CONTACTF_INVISTO;
+ if (cacheEntry->NotOnList) group->cl.items[i]->flags|=CONTACTF_NOTONLIST;
+ idleMode = szProto != NULL?cacheEntry->IdleTS:0;
+ if (idleMode) group->cl.items[i]->flags|=CONTACTF_IDLE;
+
+ lstrcpyn(group->cl.items[i]->szText,cacheEntry->name, SIZEOF(group->cl.items[i]->szText));
+ group->cl.items[i]->proto = szProto;
+
+ if (dat->style & CLS_SHOWSTATUSMESSAGES) {
+ if (!DBGetContactSettingTString(hContact, "CList", "StatusMsg", &dbv)) {
+ int j;
+ lstrcpyn(group->cl.items[i]->szStatusMsg, dbv.ptszVal, SIZEOF(group->cl.items[i]->szStatusMsg));
+ for (j = (int)_tcslen(group->cl.items[i]->szStatusMsg)-1;j>=0;j--) {
+ if (group->cl.items[i]->szStatusMsg[j] == '\r' || group->cl.items[i]->szStatusMsg[j] == '\n' || group->cl.items[i]->szStatusMsg[j] == '\t') {
+ group->cl.items[i]->szStatusMsg[j] = ' ';
+ }
+ }
+ DBFreeVariant(&dbv);
+ if (_tcslen(group->cl.items[i]->szStatusMsg)>0) {
+ group->cl.items[i]->flags |= CONTACTF_STATUSMSG;
+ }
+ }
+ }
+
+ ClearRowByIndexCache();
+ return group->cl.items[i];
+}
+
+void AddContactToTree(HWND hwnd,struct ClcData *dat,HANDLE hContact,int updateTotalCount,int checkHideOffline)
+{
+ struct ClcGroup *group;
+ struct ClcContact * cont;
+ pdisplayNameCacheEntry cacheEntry;
+ DWORD style = GetWindowLongPtr(hwnd,GWL_STYLE);
+ WORD status;
+ char *szProto;
+
+ if (FindItem(hwnd,dat,hContact,NULL,NULL,NULL) == 1){return;}
+ cacheEntry = GetContactFullCacheEntry(hContact);
+ if (cacheEntry == NULL) return;
+ szProto = cacheEntry->szProto;
+
+
+ //char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0);
+
+ dat->NeedResort = 1;
+ ClearRowByIndexCache();
+ ClearClcContactCache(dat,hContact);
+
+ if (style&CLS_NOHIDEOFFLINE) checkHideOffline = 0;
+ if (checkHideOffline) {
+ if (szProto == NULL) status = ID_STATUS_OFFLINE;
+ else status = cacheEntry->status;
+ }
+
+ if (lstrlen(cacheEntry->szGroup) == 0)
+ group = &dat->list;
+ else {
+ group = AddGroup(hwnd,dat,cacheEntry->szGroup,(DWORD)-1,0,0);
+ if (group == NULL) {
+ int i,len;
+ DWORD groupFlags;
+ TCHAR *szGroupName;
+ if ( !(style & CLS_HIDEEMPTYGROUPS))
+ return;
+
+ if (checkHideOffline && pcli->pfnIsHiddenMode(dat,status)) {
+ for (i = 1;;i++) {
+ szGroupName = pcli->pfnGetGroupName(i,&groupFlags);
+ if (szGroupName == NULL)
+ return; //never happens
+ if (!lstrcmp(szGroupName,cacheEntry->szGroup)) break;
+ }
+ if (groupFlags & GROUPF_HIDEOFFLINE)
+ return;
+ }
+ for (i = 1;; i++) {
+ szGroupName = pcli->pfnGetGroupName(i,&groupFlags);
+ if (szGroupName == NULL)
+ return; //never happens
+ if (!lstrcmp(szGroupName,cacheEntry->szGroup))
+ break;
+ len = lstrlen(szGroupName);
+ if (!_tcsncmp(szGroupName,cacheEntry->szGroup,len) && cacheEntry->szGroup[len] == '\\')
+ AddGroup(hwnd,dat,szGroupName,groupFlags,i,1);
+ }
+ group = AddGroup(hwnd,dat,cacheEntry->szGroup,groupFlags,i,1);
+ }
+ }
+
+ if (checkHideOffline) {
+ if (pcli->pfnIsHiddenMode(dat,status) && (style&CLS_HIDEOFFLINE || group->hideOffline)) {
+ if (updateTotalCount) group->totalMembers++;
+ return;
+ }
+ }
+ cont = AddContactToGroup(dat,group,cacheEntry);
+ if (cont && cont->proto) {
+ cont->SubAllocated = 0;
+ if (strcmp(cont->proto,"MetaContacts") == 0)
+ AddSubcontacts(cont);
+ }
+ if (updateTotalCount)
+ group->totalMembers++;
+ ClearRowByIndexCache();
+}
+
+extern struct ClcGroup* ( *saveRemoveItemFromGroup )(HWND hwnd,struct ClcGroup *group,struct ClcContact *contact,int updateTotalCount);
+
+struct ClcGroup *RemoveItemFromGroup(HWND hwnd,struct ClcGroup *group,struct ClcContact *contact,int updateTotalCount)
+{
+ ClearRowByIndexCache();
+ if (contact->type == CLCIT_CONTACT) {
+ struct ClcData* dat = (struct ClcData*)GetWindowLongPtr(hwnd,0);
+ ClearClcContactCache(dat,contact->hContact);
+ }
+
+ group = saveRemoveItemFromGroup(hwnd, group, contact, updateTotalCount);
+
+ ClearRowByIndexCache();
+ return group;
+}
+
+void DeleteItemFromTree(HWND hwnd,HANDLE hItem)
+{
+ struct ClcContact *contact;
+ struct ClcGroup *group;
+ struct ClcData *dat = (struct ClcData*)GetWindowLongPtr(hwnd,0);
+
+ ClearRowByIndexCache();
+ dat->NeedResort = 1;
+
+ if (!FindItem(hwnd,dat,hItem,&contact,&group,NULL)) {
+ DBVARIANT dbv;
+ int i,nameOffset;
+ if (!IsHContactContact(hItem)) return;
+ ClearClcContactCache(dat,hItem);
+
+ if (DBGetContactSettingTString(hItem,"CList","Group",&dbv)) return;
+
+ //decrease member counts of all parent groups too
+ group = &dat->list;
+ nameOffset = 0;
+ for (i = 0;;i++) {
+ if (group->scanIndex == group->cl.count) break;
+ if (group->cl.items[i]->type == CLCIT_GROUP) {
+ int len = lstrlen(group->cl.items[i]->szText);
+ if (!_tcsncmp(group->cl.items[i]->szText,dbv.ptszVal+nameOffset,len) && (dbv.ptszVal[nameOffset+len] == '\\' || dbv.pszVal[nameOffset+len] == '\0')) {
+ group->totalMembers--;
+ if (dbv.pszVal[nameOffset+len] == '\0') break;
+ }
+ }
+ }
+ mir_free(dbv.pszVal);
+ }
+ else RemoveItemFromGroup(hwnd,group,contact,1);
+
+ ClearRowByIndexCache();
+}
+
+
+
+void RebuildEntireList(HWND hwnd,struct ClcData *dat)
+{
+// char *szProto;
+ DWORD style = GetWindowLongPtr(hwnd,GWL_STYLE);
+ HANDLE hContact;
+ struct ClcContact * cont;
+ struct ClcGroup *group;
+ //DBVARIANT dbv;
+ int tick = GetTickCount();
+
+ ClearRowByIndexCache();
+ ClearClcContactCache(dat,INVALID_HANDLE_VALUE);
+
+ dat->list.expanded = 1;
+ dat->list.hideOffline = DBGetContactSettingByte(NULL,"CLC","HideOfflineRoot",0);
+ memset( &dat->list.cl, 0, sizeof( dat->list.cl ));
+ dat->list.cl.increment = 30;
+ dat->NeedResort = 1;
+ dat->selection = -1;
+ {
+ int i;
+ TCHAR *szGroupName;
+ DWORD groupFlags;
+
+ for (i = 1;;i++) {
+ szGroupName = pcli->pfnGetGroupName(i,&groupFlags);
+ if (szGroupName == NULL) break;
+ AddGroup(hwnd,dat,szGroupName,groupFlags,i,0);
+ }
+ }
+
+ hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0);
+ while(hContact) {
+
+ pdisplayNameCacheEntry cacheEntry;
+ cont = NULL;
+ cacheEntry = GetContactFullCacheEntry(hContact);
+ //cacheEntry->ClcContact = NULL;
+ ClearClcContactCache(dat,hContact);
+ if (cacheEntry == NULL)
+ {
+ MessageBoxA(0,"Fail To Get CacheEntry for hContact","!!!!!!!!",0);
+ }
+
+
+ if (style&CLS_SHOWHIDDEN || !cacheEntry->Hidden) {
+ if (lstrlen(cacheEntry->szGroup) == 0)
+ group = &dat->list;
+ else {
+ group = AddGroup(hwnd,dat,cacheEntry->szGroup,(DWORD)-1,0,0);
+ //mir_free(dbv.pszVal);
+ }
+
+ if (group != NULL) {
+ group->totalMembers++;
+ if (!(style&CLS_NOHIDEOFFLINE) && (style&CLS_HIDEOFFLINE || group->hideOffline)) {
+ //szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0);
+ if (cacheEntry->szProto == NULL) {
+ if (!pcli->pfnIsHiddenMode(dat,ID_STATUS_OFFLINE)||cacheEntry->noHiddenOffline)
+ cont = AddContactToGroup(dat,group,cacheEntry);
+ }
+ else
+ if (!pcli->pfnIsHiddenMode(dat,cacheEntry->status)||cacheEntry->noHiddenOffline)
+ cont = AddContactToGroup(dat,group,cacheEntry);
+ }
+ else cont = AddContactToGroup(dat,group,cacheEntry);
+ }
+ }
+ if (cont)
+ if (cont->proto)
+ {
+ cont->SubAllocated = 0;
+ if (strcmp(cont->proto,"MetaContacts") == 0)
+ AddSubcontacts(cont);
+ }
+ hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0);
+ }
+
+ if (style&CLS_HIDEEMPTYGROUPS) {
+ group = &dat->list;
+ group->scanIndex = 0;
+ for (;;) {
+ if (group->scanIndex == group->cl.count) {
+ group = group->parent;
+ if (group == NULL) break;
+ }
+ else if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) {
+ if (group->cl.items[group->scanIndex]->group->cl.count == 0) {
+ group = RemoveItemFromGroup(hwnd,group,group->cl.items[group->scanIndex],0);
+ }
+ else {
+ group = group->cl.items[group->scanIndex]->group;
+ group->scanIndex = 0;
+ }
+ continue;
+ }
+ group->scanIndex++;
+ }
+ }
+
+ SortCLC(hwnd,dat,0);
+ tick = GetTickCount()-tick;
+ {
+ char buf[255];
+ //sprintf(buf,"%s %s took %i ms",__FILE__,__LINE__,tick);
+ sprintf(buf,"RebuildEntireList %d \r\n",tick);
+
+ OutputDebugStringA(buf);
+ DBWriteContactSettingDword((HANDLE)0,"CLUI","PF:Last RebuildEntireList Time:",tick);
+ }
+}
+
+
+int GetNewSelection(struct ClcGroup *group, int selection, int direction)
+{
+ int lastcount = 0, count = 0;//group->cl.count;
+ struct ClcGroup *topgroup = group;
+ if (selection<0) {
+ return 0;
+ }
+ group->scanIndex = 0;
+ for (;;) {
+ if (group->scanIndex == group->cl.count) {
+ group = group->parent;
+ if (group == NULL) break;
+ group->scanIndex++;
+ continue;
+ }
+ if (count>=selection) return count;
+ lastcount = count;
+ count++;
+ if ((group->cl.items[group->scanIndex]->type == CLCIT_CONTACT) && (group->cl.items[group->scanIndex]->flags & CONTACTF_STATUSMSG)) {
+ count++;
+ }
+ if (!direction) {
+ if (count>selection) return lastcount;
+ }
+ if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP && (group->cl.items[group->scanIndex]->group->expanded)) {
+ group = group->cl.items[group->scanIndex]->group;
+ group->scanIndex = 0;
+ // count += group->cl.count;
+ continue;
+ }
+ group->scanIndex++;
+ }
+ return lastcount;
+ }
+
+int GetGroupContentsCount(struct ClcGroup *group,int visibleOnly)
+{
+ int count = 0;//group->cl.count;
+ struct ClcGroup *topgroup = group;
+
+ group->scanIndex = 0;
+ for (;;) {
+ if (group->scanIndex == group->cl.count) {
+ if (group == topgroup) break;
+ group = group->parent;
+ group->scanIndex++;
+ continue;
+
+ }
+// else if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && (group->cl.items[group->scanIndex]->SubAllocated>0) && visibleOnly && group->cl.items[group->scanIndex]->SubExpanded)
+// {
+// count += group->cl.items[group->scanIndex]->SubAllocated;
+ count++;
+ if ((group->cl.items[group->scanIndex]->type == CLCIT_CONTACT) && (group->cl.items[group->scanIndex]->flags & CONTACTF_STATUSMSG)) {
+ count++;
+
+ }
+// else if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP && (!visibleOnly || group->cl.items[group->scanIndex]->group->expanded)) {
+ if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP && (!visibleOnly || group->cl.items[group->scanIndex]->group->expanded)) {
+ group = group->cl.items[group->scanIndex]->group;
+ group->scanIndex = 0;
+// count += group->cl.count;
+ continue;
+ }
+ group->scanIndex++;
+ }
+ return count;
+}
+
+extern void ( *saveSortCLC )(HWND hwnd,struct ClcData *dat,int useInsertionSort);
+
+void SortCLC(HWND hwnd,struct ClcData *dat,int useInsertionSort)
+{
+#ifdef _DEBUG
+ DWORD tick = GetTickCount();
+#endif
+ int oldSort = dat->NeedResort;
+ saveSortCLC(hwnd, dat, useInsertionSort);
+ if ( oldSort )
+ ClearRowByIndexCache();
+
+#ifdef _DEBUG
+ {
+ char buf[255];
+ //sprintf(buf,"%s %s took %i ms",__FILE__,__LINE__,tick);
+ tick = GetTickCount()-tick;
+ if (tick > 5) {
+ sprintf(buf,"SortCLC %d \r\n",tick);
+ OutputDebugStringA(buf);
+ DBWriteContactSettingDword((HANDLE)0,"CLUI","PF:Last SortCLC Time:",tick);
+ }
+ }
+#endif
+}
+
+struct SavedContactState_t
+{
+ HANDLE hContact;
+ BYTE iExtraImage[MAXEXTRACOLUMNS];
+ int checked;
+};
+
+struct SavedGroupState_t
+{
+ int groupId, expanded;
+};
+
+struct SavedInfoState_t
+{
+ int parentId;
+ struct ClcContact contact;
+};
+
+void SaveStateAndRebuildList(HWND hwnd,struct ClcData *dat)
+{
+ NMCLISTCONTROL nm;
+ int i,j;
+ struct SavedGroupState_t *savedGroup = NULL;
+ int savedGroupCount = 0,savedGroupAlloced = 0;
+ struct SavedContactState_t *savedContact = NULL;
+ int savedContactCount = 0,savedContactAlloced = 0;
+ struct SavedInfoState_t *savedInfo = NULL;
+ int savedInfoCount = 0,savedInfoAlloced = 0;
+ struct ClcGroup *group;
+ struct ClcContact *contact;
+
+ int tick = GetTickCount();
+ int allocstep = 1024;
+ pcli->pfnHideInfoTip(hwnd,dat);
+ KillTimer(hwnd,TIMERID_INFOTIP);
+ KillTimer(hwnd,TIMERID_RENAME);
+ pcli->pfnEndRename(hwnd,dat,1);
+
+ group = &dat->list;
+ group->scanIndex = 0;
+ for (;;) {
+ if (group->scanIndex == group->cl.count) {
+ group = group->parent;
+ if (group == NULL) break;
+ }
+ else if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) {
+ group = group->cl.items[group->scanIndex]->group;
+ group->scanIndex = 0;
+ if (++savedGroupCount>savedGroupAlloced) {
+ savedGroupAlloced += allocstep;
+ savedGroup = (struct SavedGroupState_t*)mir_realloc(savedGroup,sizeof(struct SavedGroupState_t)*savedGroupAlloced);
+ }
+ savedGroup[savedGroupCount-1].groupId = group->groupId;
+ savedGroup[savedGroupCount-1].expanded = group->expanded;
+ continue;
+ }
+ else if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT) {
+ if (++savedContactCount>savedContactAlloced) {
+ savedContactAlloced += allocstep;
+ savedContact = (struct SavedContactState_t*)mir_realloc(savedContact,sizeof(struct SavedContactState_t)*savedContactAlloced);
+ }
+ savedContact[savedContactCount-1].hContact = group->cl.items[group->scanIndex]->hContact;
+ CopyMemory(savedContact[savedContactCount-1].iExtraImage, group->cl.items[group->scanIndex]->iExtraImage, MAXEXTRACOLUMNS);
+ savedContact[savedContactCount-1].checked = group->cl.items[group->scanIndex]->flags & CONTACTF_CHECKED;
+ if (group->cl.items[group->scanIndex]->SubAllocated>0)
+ {
+ int l;
+ for (l = 0; l<group->cl.items[group->scanIndex]->SubAllocated; l++)
+ {
+ if (++savedContactCount>savedContactAlloced) {
+ savedContactAlloced += allocstep;
+ savedContact = (struct SavedContactState_t*)mir_realloc(savedContact,sizeof(struct SavedContactState_t)*savedContactAlloced);
+ }
+ savedContact[savedContactCount-1].hContact = group->cl.items[group->scanIndex]->subcontacts[l].hContact;
+ CopyMemory(savedContact[savedContactCount-1].iExtraImage ,group->cl.items[group->scanIndex]->subcontacts[l].iExtraImage,MAXEXTRACOLUMNS);
+ savedContact[savedContactCount-1].checked = group->cl.items[group->scanIndex]->subcontacts[l].flags&CONTACTF_CHECKED;
+ }
+ }
+ }
+ else if (group->cl.items[group->scanIndex]->type == CLCIT_INFO) {
+ if (++savedInfoCount>savedInfoAlloced) {
+ savedInfoAlloced += allocstep;
+ savedInfo = (struct SavedInfoState_t*)mir_realloc(savedInfo,sizeof(struct SavedInfoState_t)*savedInfoAlloced);
+ }
+ if (group->parent == NULL) savedInfo[savedInfoCount-1].parentId = -1;
+ else savedInfo[savedInfoCount-1].parentId = group->groupId;
+ savedInfo[savedInfoCount-1].contact = *group->cl.items[group->scanIndex];
+ }
+ group->scanIndex++;
+ }
+
+ pcli->pfnFreeGroup(&dat->list);
+ RebuildEntireList(hwnd,dat);
+
+ group = &dat->list;
+ group->scanIndex = 0;
+ for (;;) {
+ if (group->scanIndex == group->cl.count) {
+ group = group->parent;
+ if (group == NULL) break;
+ }
+ else if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) {
+ group = group->cl.items[group->scanIndex]->group;
+ group->scanIndex = 0;
+ for (i = 0;i<savedGroupCount;i++)
+ if (savedGroup[i].groupId == group->groupId) {
+ group->expanded = savedGroup[i].expanded;
+ break;
+ }
+ continue;
+ }
+ else if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT) {
+ for (i = 0;i<savedContactCount;i++)
+ if (savedContact[i].hContact == group->cl.items[group->scanIndex]->hContact) {
+ CopyMemory(group->cl.items[group->scanIndex]->iExtraImage,savedContact[i].iExtraImage,MAXEXTRACOLUMNS);
+ if (savedContact[i].checked) group->cl.items[group->scanIndex]->flags|=CONTACTF_CHECKED;
+ break;
+ }
+ if (group->cl.items[group->scanIndex]->SubAllocated>0)
+ {
+ int l;
+ for (l = 0; l<group->cl.items[group->scanIndex]->SubAllocated; l++)
+ for (i = 0;i<savedContactCount;i++)
+ if (savedContact[i].hContact == group->cl.items[group->scanIndex]->subcontacts[l].hContact) {
+ CopyMemory(group->cl.items[group->scanIndex]->subcontacts[l].iExtraImage,savedContact[i].iExtraImage,MAXEXTRACOLUMNS);
+ if (savedContact[i].checked) group->cl.items[group->scanIndex]->subcontacts[l].flags|=CONTACTF_CHECKED;
+ break;
+ }
+ }
+ }
+ group->scanIndex++;
+ }
+ if (savedGroup) mir_free(savedGroup);
+ if (savedContact) mir_free(savedContact);
+ for (i = 0;i<savedInfoCount;i++) {
+ if (savedInfo[i].parentId == -1) group = &dat->list;
+ else {
+ if (!FindItem(hwnd,dat,(HANDLE)(savedInfo[i].parentId|HCONTACT_ISGROUP),&contact,NULL,NULL)) continue;
+ group = contact->group;
+ }
+ j = AddInfoItemToGroup(group,savedInfo[i].contact.flags,_T(""));
+ *group->cl.items[j] = savedInfo[i].contact;
+ }
+ if (savedInfo) mir_free(savedInfo);
+ pcli->pfnRecalculateGroupCheckboxes(hwnd,dat);
+
+ RecalcScrollBar(hwnd,dat);
+ nm.hdr.code = CLN_LISTREBUILT;
+ nm.hdr.hwndFrom = hwnd;
+ nm.hdr.idFrom = GetDlgCtrlID(hwnd);
+
+
+ //srand(GetTickCount());
+
+ tick = GetTickCount()-tick;
+ {
+ char buf[255];
+ //sprintf(buf,"%s %s took %i ms",__FILE__,__LINE__,tick);
+ sprintf(buf,"SaveStateAndRebuildList %d \r\n",tick);
+
+ OutputDebugStringA(buf);
+ }
+ ClearRowByIndexCache();
+ SendMessage(GetParent(hwnd),WM_NOTIFY,0,(LPARAM)&nm);
+}
diff --git a/plugins/Mwclist/clcopts.c b/plugins/Mwclist/clcopts.c
deleted file mode 100644
index ce349cac5e..0000000000
--- a/plugins/Mwclist/clcopts.c
+++ /dev/null
@@ -1,1109 +0,0 @@
-/*
-
-Miranda IM: the free IM client for Microsoft* Windows*
-
-Copyright 2000-2003 Miranda ICQ/IM project,
-all portions of this codebase are copyrighted to the people
-listed in contributors.txt.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-#include "commonheaders.h"
-#include "m_clc.h"
-#include "clc.h"
-
-#define DBFONTF_BOLD 1
-#define DBFONTF_ITALIC 2
-#define DBFONTF_UNDERLINE 4
-
-static INT_PTR CALLBACK DlgProcClcMainOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-static INT_PTR CALLBACK DlgProcClcMetaOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-static INT_PTR CALLBACK DlgProcClcTextOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-
-static INT_PTR CALLBACK DlgProcStatusBarBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-extern void OnStatusBarBackgroundChange();
-
-int BgClcChange(WPARAM wParam,LPARAM lParam)
-{
- pcli->pfnClcOptionsChanged();
- return 0;
-}
-
-int BgStatusBarChange(WPARAM wParam,LPARAM lParam)
-{
- pcli->pfnClcOptionsChanged();
- OnStatusBarBackgroundChange();
- return 0;
-}
-
-int ClcOptInit(WPARAM wParam,LPARAM lParam)
-{
- OPTIONSDIALOGPAGE odp;
-
- ZeroMemory(&odp,sizeof(odp));
- odp.cbSize=sizeof(odp);
- odp.position=0;
- odp.hInstance=g_hInst;
- odp.pszGroup=LPGEN("Contact List");
- odp.pszTemplate=MAKEINTRESOURCEA(IDD_OPT_CLC);
- odp.pszTitle=LPGEN("List");
- odp.pfnDlgProc=DlgProcClcMainOpts;
- odp.flags=ODPF_BOLDGROUPS|ODPF_EXPERTONLY;
- CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp);
-
- if (!ServiceExists(MS_BACKGROUNDCONFIG_REGISTER))
- {
- odp.pszTemplate=MAKEINTRESOURCEA(IDD_OPT_CLCBKG);
- odp.pszTitle=LPGEN("List Background");
- odp.pfnDlgProc=DlgProcClcBkgOpts;
- odp.flags=ODPF_BOLDGROUPS;
- CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp);
- }
-
- odp.pszTemplate=MAKEINTRESOURCEA(IDD_OPT_CLCTEXT);
- odp.pszTitle=LPGEN("List Text");
- odp.pfnDlgProc=DlgProcClcTextOpts;
- CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp);
-
- odp.pszTemplate=MAKEINTRESOURCEA(IDD_OPT_META_CLC);
- odp.pszTitle=LPGEN("List MetaContacts");
- odp.pfnDlgProc=DlgProcClcMetaOpts;
- CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp);
-
- if (!ServiceExists(MS_BACKGROUNDCONFIG_REGISTER))
- {
- odp.pszTemplate=MAKEINTRESOURCEA(IDD_OPT_CLCBKG);
- odp.pszTitle=LPGEN("StatusBar Background");
- odp.pfnDlgProc=DlgProcStatusBarBkgOpts;
- odp.flags=ODPF_BOLDGROUPS;
- CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp);
- }
-
- return 0;
-}
-
-struct CheckBoxToStyleEx_t {
- int id;
- DWORD flag;
- int not;
-} static const checkBoxToStyleEx[]={
- {IDC_DISABLEDRAGDROP,CLS_EX_DISABLEDRAGDROP,0},
- {IDC_NOTEDITLABELS,CLS_EX_EDITLABELS,1},
- {IDC_SHOWSELALWAYS,CLS_EX_SHOWSELALWAYS,0},
- {IDC_TRACKSELECT,CLS_EX_TRACKSELECT,0},
- {IDC_SHOWGROUPCOUNTS,CLS_EX_SHOWGROUPCOUNTS,0},
- {IDC_HIDECOUNTSWHENEMPTY,CLS_EX_HIDECOUNTSWHENEMPTY,0},
- {IDC_DIVIDERONOFF,CLS_EX_DIVIDERONOFF,0},
- {IDC_NOTNOTRANSLUCENTSEL,CLS_EX_NOTRANSLUCENTSEL,1},
- {IDC_LINEWITHGROUPS,CLS_EX_LINEWITHGROUPS,0},
- {IDC_QUICKSEARCHVISONLY,CLS_EX_QUICKSEARCHVISONLY,0},
- {IDC_SORTGROUPSALPHA,CLS_EX_SORTGROUPSALPHA,0},
- {IDC_NOTNOSMOOTHSCROLLING,CLS_EX_NOSMOOTHSCROLLING,1}};
-
-struct CheckBoxValues_t {
- DWORD style;
- TCHAR *szDescr;
-};
-static const struct CheckBoxValues_t greyoutValues[] =
-{
- {GREYF_UNFOCUS, _T("Not focused") },
- {MODEF_OFFLINE, _T("Offline") },
- {PF2_ONLINE, _T("Online") },
- {PF2_SHORTAWAY, _T("Away") },
- {PF2_LONGAWAY, _T("NA") },
- {PF2_LIGHTDND, _T("Occupied") },
- {PF2_HEAVYDND, _T("DND") },
- {PF2_FREECHAT, _T("Free for chat") },
- {PF2_INVISIBLE, _T("Invisible") },
- {PF2_OUTTOLUNCH, _T("Out to lunch") },
- {PF2_ONTHEPHONE, _T("On the phone") }
-};
-
-static const struct CheckBoxValues_t offlineValues[] =
-{
- {MODEF_OFFLINE, _T("Offline") },
- {PF2_ONLINE, _T("Online") },
- {PF2_SHORTAWAY, _T("Away") },
- {PF2_LONGAWAY, _T("NA") },
- {PF2_LIGHTDND, _T("Occupied") },
- {PF2_HEAVYDND, _T("DND") },
- {PF2_FREECHAT, _T("Free for chat") },
- {PF2_INVISIBLE, _T("Invisible") },
- {PF2_OUTTOLUNCH, _T("Out to lunch") },
- {PF2_ONTHEPHONE, _T("On the phone") }
-};
-
-static void FillCheckBoxTree(HWND hwndTree,const struct CheckBoxValues_t *values,int nValues,DWORD style)
-{
- TVINSERTSTRUCT tvis;
- int i;
-
- tvis.hParent=NULL;
- tvis.hInsertAfter=TVI_LAST;
- tvis.item.mask=TVIF_PARAM|TVIF_TEXT|TVIF_STATE;
- for(i=0;i<nValues;i++) {
- tvis.item.lParam = values[i].style;
- tvis.item.pszText = TranslateTS(values[i].szDescr);
- tvis.item.stateMask = TVIS_STATEIMAGEMASK;
- tvis.item.state = INDEXTOSTATEIMAGEMASK((style&tvis.item.lParam)!=0?2:1);
- TreeView_InsertItem(hwndTree,&tvis);
- }
-}
-
-static DWORD MakeCheckBoxTreeFlags(HWND hwndTree)
-{
- DWORD flags=0;
- TVITEM tvi;
-
- tvi.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_STATE;
- tvi.hItem=TreeView_GetRoot(hwndTree);
- while(tvi.hItem) {
- TreeView_GetItem(hwndTree,&tvi);
- if (((tvi.state&TVIS_STATEIMAGEMASK)>>12==2)) flags|=tvi.lParam;
- tvi.hItem=TreeView_GetNextSibling(hwndTree,tvi.hItem);
- }
- return flags;
-}
-
-static INT_PTR CALLBACK DlgProcClcMetaOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- LPNMHDR t;
- t=((LPNMHDR)lParam);
- switch (msg)
- {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
-
- CheckDlgButton(hwndDlg, IDC_META, DBGetContactSettingByte(NULL,"CLC","Meta",0) ? BST_CHECKED : BST_UNCHECKED); /// by FYR
- CheckDlgButton(hwndDlg, IDC_METADBLCLK, DBGetContactSettingByte(NULL,"CLC","MetaDoubleClick",0) ? BST_CHECKED : BST_UNCHECKED); /// by FYR
- CheckDlgButton(hwndDlg, IDC_METASUBEXTRA, DBGetContactSettingByte(NULL,"CLC","MetaHideExtra",0) ? BST_CHECKED : BST_UNCHECKED); /// by FYR
- CheckDlgButton(hwndDlg, IDC_METASUBEXTRA_IGN, DBGetContactSettingByte(NULL,"CLC","MetaIgnoreEmptyExtra",1) ? BST_CHECKED : BST_UNCHECKED); /// by FYR
- CheckDlgButton(hwndDlg, IDC_METASUB_HIDEOFFLINE, DBGetContactSettingByte(NULL,"CLC","MetaHideOfflineSub",1) ? BST_CHECKED : BST_UNCHECKED); /// by FYR
- return TRUE;
- case WM_COMMAND:
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- return TRUE;
- case WM_NOTIFY:
-
- switch(t->idFrom)
- {
- case 0:
- switch (t->code)
- {
- case PSN_APPLY:
- DBWriteContactSettingByte(NULL,"CLC","Meta",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_META)); // by FYR
- DBWriteContactSettingByte(NULL,"CLC","MetaDoubleClick",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_METADBLCLK)); // by FYR
- DBWriteContactSettingByte(NULL,"CLC","MetaHideExtra",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_METASUBEXTRA)); // by FYR
- DBWriteContactSettingByte(NULL,"CLC","MetaIgnoreEmptyExtra",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_METASUBEXTRA_IGN)); // by FYR
- DBWriteContactSettingByte(NULL,"CLC","MetaHideOfflineSub",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_METASUB_HIDEOFFLINE)); // by FYR
- pcli->pfnClcOptionsChanged();
- return TRUE;
- }
- break;
- }
- break;
- }
- return FALSE;
-
-
-
-
-}
-
-static INT_PTR CALLBACK DlgProcClcMainOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- switch (msg)
- {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_GREYOUTOPTS),GWL_STYLE,GetWindowLongPtr(GetDlgItem(hwndDlg,IDC_GREYOUTOPTS),GWL_STYLE)|TVS_NOHSCROLL|TVS_CHECKBOXES);
- SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_HIDEOFFLINEOPTS),GWL_STYLE,GetWindowLongPtr(GetDlgItem(hwndDlg,IDC_HIDEOFFLINEOPTS),GWL_STYLE)|TVS_NOHSCROLL|TVS_CHECKBOXES);
- { int i;
- DWORD exStyle=DBGetContactSettingDword(NULL,"CLC","ExStyle",pcli->pfnGetDefaultExStyle());
- for(i=0;i < SIZEOF(checkBoxToStyleEx); i++)
- CheckDlgButton(hwndDlg,checkBoxToStyleEx[i].id,(exStyle&checkBoxToStyleEx[i].flag)^(checkBoxToStyleEx[i].flag*checkBoxToStyleEx[i].not)?BST_CHECKED:BST_UNCHECKED);
- }
- { UDACCEL accel[2]={{0,10},{2,50}};
- SendDlgItemMessage(hwndDlg,IDC_SMOOTHTIMESPIN,UDM_SETRANGE,0,MAKELONG(999,0));
- SendDlgItemMessage(hwndDlg,IDC_SMOOTHTIMESPIN,UDM_SETACCEL,SIZEOF(accel), (LPARAM)&accel );
- SendDlgItemMessage(hwndDlg,IDC_SMOOTHTIMESPIN,UDM_SETPOS,0,MAKELONG(DBGetContactSettingWord(NULL,"CLC","ScrollTime",CLCDEFAULT_SCROLLTIME),0));
- }
- CheckDlgButton(hwndDlg,IDC_IDLE,DBGetContactSettingByte(NULL,"CLC","ShowIdle",CLCDEFAULT_SHOWIDLE)?BST_CHECKED:BST_UNCHECKED);
-
- /* CheckDlgButton(hwndDlg, IDC_META, DBGetContactSettingByte(NULL,"CLC","Meta",0) ? BST_CHECKED : BST_UNCHECKED); /// by FYR
- CheckDlgButton(hwndDlg, IDC_METADBLCLK, DBGetContactSettingByte(NULL,"CLC","MetaDoubleClick",0) ? BST_CHECKED : BST_UNCHECKED); /// by FYR
- CheckDlgButton(hwndDlg, IDC_METASUBEXTRA, DBGetContactSettingByte(NULL,"CLC","MetaHideExtra",1) ? BST_CHECKED : BST_UNCHECKED); /// by FYR
- */
- SendDlgItemMessage(hwndDlg,IDC_LEFTMARGINSPIN,UDM_SETRANGE,0,MAKELONG(64,0));
- SendDlgItemMessage(hwndDlg,IDC_LEFTMARGINSPIN,UDM_SETPOS,0,MAKELONG(DBGetContactSettingByte(NULL,"CLC","LeftMargin",CLCDEFAULT_LEFTMARGIN),0));
- SendDlgItemMessage(hwndDlg,IDC_GROUPINDENTSPIN,UDM_SETRANGE,0,MAKELONG(50,0));
- SendDlgItemMessage(hwndDlg,IDC_GROUPINDENTSPIN,UDM_SETPOS,0,MAKELONG(DBGetContactSettingByte(NULL,"CLC","GroupIndent",CLCDEFAULT_GROUPINDENT),0));
- CheckDlgButton(hwndDlg,IDC_GREYOUT,DBGetContactSettingDword(NULL,"CLC","GreyoutFlags",CLCDEFAULT_GREYOUTFLAGS)?BST_CHECKED:BST_UNCHECKED);
-
-
- EnableWindow(GetDlgItem(hwndDlg,IDC_SMOOTHTIME),IsDlgButtonChecked(hwndDlg,IDC_NOTNOSMOOTHSCROLLING));
- EnableWindow(GetDlgItem(hwndDlg,IDC_GREYOUTOPTS),IsDlgButtonChecked(hwndDlg,IDC_GREYOUT));
- FillCheckBoxTree(GetDlgItem(hwndDlg,IDC_GREYOUTOPTS),greyoutValues,SIZEOF(greyoutValues),DBGetContactSettingDword(NULL,"CLC","FullGreyoutFlags",CLCDEFAULT_FULLGREYOUTFLAGS));
- FillCheckBoxTree(GetDlgItem(hwndDlg,IDC_HIDEOFFLINEOPTS),offlineValues,SIZEOF(offlineValues),DBGetContactSettingDword(NULL,"CLC","OfflineModes",CLCDEFAULT_OFFLINEMODES));
- CheckDlgButton(hwndDlg,IDC_NOSCROLLBAR,DBGetContactSettingByte(NULL,"CLC","NoVScrollBar",0)?BST_CHECKED:BST_UNCHECKED);
- return TRUE;
- case WM_VSCROLL:
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case WM_COMMAND:
- if(LOWORD(wParam)==IDC_NOTNOSMOOTHSCROLLING)
- EnableWindow(GetDlgItem(hwndDlg,IDC_SMOOTHTIME),IsDlgButtonChecked(hwndDlg,IDC_NOTNOSMOOTHSCROLLING));
- if(LOWORD(wParam)==IDC_GREYOUT)
- EnableWindow(GetDlgItem(hwndDlg,IDC_GREYOUTOPTS),IsDlgButtonChecked(hwndDlg,IDC_GREYOUT));
- if ((LOWORD(wParam)==IDC_LEFTMARGIN || LOWORD(wParam)==IDC_SMOOTHTIME || LOWORD(wParam)==IDC_GROUPINDENT) && (HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus())) return 0;
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case WM_NOTIFY:
- switch(((LPNMHDR)lParam)->idFrom) {
- case IDC_GREYOUTOPTS:
- case IDC_HIDEOFFLINEOPTS:
- if (((LPNMHDR)lParam)->code==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) {
- TVITEM tvi;
- tvi.mask=TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
- tvi.hItem=hti.hItem;
- TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom,&tvi);
- tvi.iImage=tvi.iSelectedImage=tvi.iImage==1?2:1;
- TreeView_SetItem(((LPNMHDR)lParam)->hwndFrom,&tvi);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- }
- break;
- case 0:
- switch (((LPNMHDR)lParam)->code)
- {
- case PSN_APPLY:
- { int i;
- DWORD exStyle=0;
- for(i=0;i < SIZEOF(checkBoxToStyleEx);i++)
- if ((IsDlgButtonChecked(hwndDlg,checkBoxToStyleEx[i].id)==0)==checkBoxToStyleEx[i].not)
- exStyle|=checkBoxToStyleEx[i].flag;
- DBWriteContactSettingDword(NULL,"CLC","ExStyle",exStyle);
- }
- { DWORD fullGreyoutFlags=MakeCheckBoxTreeFlags(GetDlgItem(hwndDlg,IDC_GREYOUTOPTS));
- DBWriteContactSettingDword(NULL,"CLC","FullGreyoutFlags",fullGreyoutFlags);
- if(IsDlgButtonChecked(hwndDlg,IDC_GREYOUT))
- DBWriteContactSettingDword(NULL,"CLC","GreyoutFlags",fullGreyoutFlags);
- else
- DBWriteContactSettingDword(NULL,"CLC","GreyoutFlags",0);
- }
- /* DBWriteContactSettingByte(NULL,"CLC","Meta",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_META)); // by FYR
- DBWriteContactSettingByte(NULL,"CLC","MetaDoubleClick",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_METADBLCLK)); // by FYR
- DBWriteContactSettingByte(NULL,"CLC","MetaHideExtra",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_METASUBEXTRA)); // by FYR
-
- */
- DBWriteContactSettingByte(NULL,"CLC","ShowIdle",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_IDLE)?1:0));
- DBWriteContactSettingDword(NULL,"CLC","OfflineModes",MakeCheckBoxTreeFlags(GetDlgItem(hwndDlg,IDC_HIDEOFFLINEOPTS)));
- DBWriteContactSettingByte(NULL,"CLC","LeftMargin",(BYTE)SendDlgItemMessage(hwndDlg,IDC_LEFTMARGINSPIN,UDM_GETPOS,0,0));
- DBWriteContactSettingWord(NULL,"CLC","ScrollTime",(WORD)SendDlgItemMessage(hwndDlg,IDC_SMOOTHTIMESPIN,UDM_GETPOS,0,0));
- DBWriteContactSettingByte(NULL,"CLC","GroupIndent",(BYTE)SendDlgItemMessage(hwndDlg,IDC_GROUPINDENTSPIN,UDM_GETPOS,0,0));
- DBWriteContactSettingByte(NULL,"CLC","NoVScrollBar",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_NOSCROLLBAR)?1:0));
-
-
- pcli->pfnClcOptionsChanged();
- return TRUE;
- }
- break;
- }
- break;
- case WM_DESTROY:
- ImageList_Destroy(TreeView_GetImageList(GetDlgItem(hwndDlg,IDC_GREYOUTOPTS),TVSIL_NORMAL));
- break;
- }
- return FALSE;
-}
-
-static INT_PTR CALLBACK DlgProcStatusBarBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- CheckDlgButton(hwndDlg,IDC_BITMAP,DBGetContactSettingByte(NULL,"StatusBar","UseBitmap",CLCDEFAULT_USEBITMAP)?BST_CHECKED:BST_UNCHECKED);
- SendMessage(hwndDlg,WM_USER+10,0,0);
- SendDlgItemMessage(hwndDlg,IDC_BKGCOLOUR,CPM_SETDEFAULTCOLOUR,0,CLCDEFAULT_BKCOLOUR);
- SendDlgItemMessage(hwndDlg,IDC_BKGCOLOUR,CPM_SETCOLOUR,0,DBGetContactSettingDword(NULL,"StatusBar","BkColour",CLCDEFAULT_BKCOLOUR));
- SendDlgItemMessage(hwndDlg,IDC_SELCOLOUR,CPM_SETDEFAULTCOLOUR,0,CLCDEFAULT_SELBKCOLOUR);
- SendDlgItemMessage(hwndDlg,IDC_SELCOLOUR,CPM_SETCOLOUR,0,DBGetContactSettingDword(NULL,"StatusBar","SelBkColour",CLCDEFAULT_SELBKCOLOUR));
- { DBVARIANT dbv;
- if (!DBGetContactSettingString(NULL,"StatusBar","BkBitmap",&dbv)) {
- SetDlgItemTextA(hwndDlg,IDC_FILENAME,dbv.pszVal);
- if (ServiceExists(MS_UTILS_PATHTOABSOLUTE)) {
- char szPath[MAX_PATH];
-
- if (CallService(MS_UTILS_PATHTOABSOLUTE, (WPARAM)dbv.pszVal, (LPARAM)szPath))
- SetDlgItemTextA(hwndDlg,IDC_FILENAME,szPath);
- }
- else
- mir_free(dbv.pszVal);
- }
- }
-
- CheckDlgButton(hwndDlg,IDC_HILIGHTMODE,DBGetContactSettingByte(NULL,"StatusBar","HiLightMode",0)==0?BST_CHECKED:BST_UNCHECKED);
- CheckDlgButton(hwndDlg,IDC_HILIGHTMODE1,DBGetContactSettingByte(NULL,"StatusBar","HiLightMode",0)==1?BST_CHECKED:BST_UNCHECKED);
- CheckDlgButton(hwndDlg,IDC_HILIGHTMODE2,DBGetContactSettingByte(NULL,"StatusBar","HiLightMode",0)==2?BST_CHECKED:BST_UNCHECKED);
- CheckDlgButton(hwndDlg,IDC_HILIGHTMODE3,DBGetContactSettingByte(NULL,"StatusBar","HiLightMode",0)==3?BST_CHECKED:BST_UNCHECKED);
-
- { WORD bmpUse=DBGetContactSettingWord(NULL,"StatusBar","BkBmpUse",CLCDEFAULT_BKBMPUSE);
- CheckDlgButton(hwndDlg,IDC_STRETCHH,bmpUse&CLB_STRETCHH?BST_CHECKED:BST_UNCHECKED);
- CheckDlgButton(hwndDlg,IDC_STRETCHV,bmpUse&CLB_STRETCHV?BST_CHECKED:BST_UNCHECKED);
- CheckDlgButton(hwndDlg,IDC_TILEH,bmpUse&CLBF_TILEH?BST_CHECKED:BST_UNCHECKED);
- CheckDlgButton(hwndDlg,IDC_TILEV,bmpUse&CLBF_TILEV?BST_CHECKED:BST_UNCHECKED);
- CheckDlgButton(hwndDlg,IDC_SCROLL,bmpUse&CLBF_SCROLL?BST_CHECKED:BST_UNCHECKED);
- CheckDlgButton(hwndDlg,IDC_PROPORTIONAL,bmpUse&CLBF_PROPORTIONAL?BST_CHECKED:BST_UNCHECKED);
- CheckDlgButton(hwndDlg,IDC_TILEVROWH,bmpUse&CLBF_TILEVTOROWHEIGHT?BST_CHECKED:BST_UNCHECKED);
-
- }
- { HRESULT (STDAPICALLTYPE *MySHAutoComplete)(HWND,DWORD);
- MySHAutoComplete=(HRESULT (STDAPICALLTYPE*)(HWND,DWORD))GetProcAddress(GetModuleHandleA("shlwapi"),"SHAutoComplete");
- if(MySHAutoComplete) MySHAutoComplete(GetDlgItem(hwndDlg,IDC_FILENAME),1);
- }
- return TRUE;
-
- case WM_USER+10:
- EnableWindow(GetDlgItem(hwndDlg,IDC_FILENAME),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
- EnableWindow(GetDlgItem(hwndDlg,IDC_BROWSE),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
- EnableWindow(GetDlgItem(hwndDlg,IDC_STRETCHH),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
- EnableWindow(GetDlgItem(hwndDlg,IDC_STRETCHV),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
- EnableWindow(GetDlgItem(hwndDlg,IDC_TILEH),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
- EnableWindow(GetDlgItem(hwndDlg,IDC_TILEV),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
- EnableWindow(GetDlgItem(hwndDlg,IDC_SCROLL),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
- EnableWindow(GetDlgItem(hwndDlg,IDC_PROPORTIONAL),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
- EnableWindow(GetDlgItem(hwndDlg,IDC_TILEVROWH),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
- break;
-
- case WM_COMMAND:
- if(LOWORD(wParam)==IDC_BROWSE) {
- char str[MAX_PATH];
- OPENFILENAMEA ofn={0};
- char filter[512];
-
- GetDlgItemTextA(hwndDlg,IDC_FILENAME,str,SIZEOF(str));
- ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
- ofn.hwndOwner = hwndDlg;
- ofn.hInstance = NULL;
- CallService(MS_UTILS_GETBITMAPFILTERSTRINGS,SIZEOF(filter),(LPARAM)filter);
- ofn.lpstrFilter = filter;
- ofn.lpstrFile = str;
- ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
- ofn.nMaxFile = SIZEOF(str);
- ofn.nMaxFileTitle = MAX_PATH;
- ofn.lpstrDefExt = "bmp";
- if (!GetOpenFileNameA(&ofn)) break;
- SetDlgItemTextA(hwndDlg,IDC_FILENAME,str);
- }
- else if(LOWORD(wParam)==IDC_FILENAME && HIWORD(wParam)!=EN_CHANGE) break;
- if(LOWORD(wParam)==IDC_BITMAP) SendMessage(hwndDlg,WM_USER+10,0,0);
- if(LOWORD(wParam)==IDC_FILENAME && (HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus())) return 0;
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case WM_NOTIFY:
- switch(((LPNMHDR)lParam)->idFrom) {
- case 0:
- switch (((LPNMHDR)lParam)->code) {
- case PSN_APPLY:
- DBWriteContactSettingByte(NULL,"StatusBar","UseBitmap",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
- { COLORREF col;
- col=SendDlgItemMessage(hwndDlg,IDC_BKGCOLOUR,CPM_GETCOLOUR,0,0);
- if(col==CLCDEFAULT_BKCOLOUR) DBDeleteContactSetting(NULL,"StatusBar","BkColour");
- else DBWriteContactSettingDword(NULL,"StatusBar","BkColour",col);
- col=SendDlgItemMessage(hwndDlg,IDC_SELCOLOUR,CPM_GETCOLOUR,0,0);
- if(col==CLCDEFAULT_SELBKCOLOUR) DBDeleteContactSetting(NULL,"StatusBar","SelBkColour");
- else DBWriteContactSettingDword(NULL,"StatusBar","SelBkColour",col);
- }
- {
- char str[MAX_PATH],strrel[MAX_PATH];
- GetDlgItemTextA(hwndDlg,IDC_FILENAME,str,SIZEOF(str));
- if (ServiceExists(MS_UTILS_PATHTORELATIVE)) {
- if (CallService(MS_UTILS_PATHTORELATIVE, (WPARAM)str, (LPARAM)strrel))
- DBWriteContactSettingString(NULL,"StatusBar","BkBitmap",strrel);
- else DBWriteContactSettingString(NULL,"StatusBar","BkBitmap",str);
- }
- else DBWriteContactSettingString(NULL,"StatusBar","BkBitmap",str);
-
- }
- { WORD flags=0;
- if(IsDlgButtonChecked(hwndDlg,IDC_STRETCHH)) flags|=CLB_STRETCHH;
- if(IsDlgButtonChecked(hwndDlg,IDC_STRETCHV)) flags|=CLB_STRETCHV;
- if(IsDlgButtonChecked(hwndDlg,IDC_TILEH)) flags|=CLBF_TILEH;
- if(IsDlgButtonChecked(hwndDlg,IDC_TILEV)) flags|=CLBF_TILEV;
- if(IsDlgButtonChecked(hwndDlg,IDC_SCROLL)) flags|=CLBF_SCROLL;
- if(IsDlgButtonChecked(hwndDlg,IDC_PROPORTIONAL)) flags|=CLBF_PROPORTIONAL;
- if(IsDlgButtonChecked(hwndDlg,IDC_TILEVROWH)) flags|=CLBF_TILEVTOROWHEIGHT;
-
- DBWriteContactSettingWord(NULL,"StatusBar","BkBmpUse",flags);
- }
- {
- int hil=0;
- if (IsDlgButtonChecked(hwndDlg,IDC_HILIGHTMODE1)) hil=1;
- if (IsDlgButtonChecked(hwndDlg,IDC_HILIGHTMODE2)) hil=2;
- if (IsDlgButtonChecked(hwndDlg,IDC_HILIGHTMODE3)) hil=3;
-
- DBWriteContactSettingByte(NULL,"StatusBar","HiLightMode",(BYTE)hil);
- }
-
- pcli->pfnClcOptionsChanged();
- OnStatusBarBackgroundChange();
- return TRUE;
- }
- break;
- }
- break;
- }
- return FALSE;
-}
-
-static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- CheckDlgButton(hwndDlg,IDC_BITMAP,DBGetContactSettingByte(NULL,"CLC","UseBitmap",CLCDEFAULT_USEBITMAP)?BST_CHECKED:BST_UNCHECKED);
- SendMessage(hwndDlg,WM_USER+10,0,0);
- SendDlgItemMessage(hwndDlg,IDC_BKGCOLOUR,CPM_SETDEFAULTCOLOUR,0,CLCDEFAULT_BKCOLOUR);
- SendDlgItemMessage(hwndDlg,IDC_BKGCOLOUR,CPM_SETCOLOUR,0,DBGetContactSettingDword(NULL,"CLC","BkColour",CLCDEFAULT_BKCOLOUR));
- SendDlgItemMessage(hwndDlg,IDC_SELCOLOUR,CPM_SETDEFAULTCOLOUR,0,CLCDEFAULT_SELBKCOLOUR);
- SendDlgItemMessage(hwndDlg,IDC_SELCOLOUR,CPM_SETCOLOUR,0,DBGetContactSettingDword(NULL,"CLC","SelBkColour",CLCDEFAULT_SELBKCOLOUR));
- { DBVARIANT dbv;
- if (!DBGetContactSettingString(NULL,"CLC","BkBitmap",&dbv)) {
- SetDlgItemTextA(hwndDlg,IDC_FILENAME,dbv.pszVal);
- if (ServiceExists(MS_UTILS_PATHTOABSOLUTE)) {
- char szPath[MAX_PATH];
-
- if (CallService(MS_UTILS_PATHTOABSOLUTE, (WPARAM)dbv.pszVal, (LPARAM)szPath))
- SetDlgItemTextA(hwndDlg,IDC_FILENAME,szPath);
- }
- else mir_free(dbv.pszVal);
- }
- }
-
- { WORD bmpUse=DBGetContactSettingWord(NULL,"CLC","BkBmpUse",CLCDEFAULT_BKBMPUSE);
- CheckDlgButton(hwndDlg,IDC_STRETCHH,bmpUse&CLB_STRETCHH?BST_CHECKED:BST_UNCHECKED);
- CheckDlgButton(hwndDlg,IDC_STRETCHV,bmpUse&CLB_STRETCHV?BST_CHECKED:BST_UNCHECKED);
- CheckDlgButton(hwndDlg,IDC_TILEH,bmpUse&CLBF_TILEH?BST_CHECKED:BST_UNCHECKED);
- CheckDlgButton(hwndDlg,IDC_TILEV,bmpUse&CLBF_TILEV?BST_CHECKED:BST_UNCHECKED);
- CheckDlgButton(hwndDlg,IDC_SCROLL,bmpUse&CLBF_SCROLL?BST_CHECKED:BST_UNCHECKED);
- CheckDlgButton(hwndDlg,IDC_PROPORTIONAL,bmpUse&CLBF_PROPORTIONAL?BST_CHECKED:BST_UNCHECKED);
- CheckDlgButton(hwndDlg,IDC_TILEVROWH,bmpUse&CLBF_TILEVTOROWHEIGHT?BST_CHECKED:BST_UNCHECKED);
-
- }
- { HRESULT (STDAPICALLTYPE *MySHAutoComplete)(HWND,DWORD);
- MySHAutoComplete=(HRESULT (STDAPICALLTYPE*)(HWND,DWORD))GetProcAddress(GetModuleHandleA("shlwapi"),"SHAutoComplete");
- if(MySHAutoComplete) MySHAutoComplete(GetDlgItem(hwndDlg,IDC_FILENAME),1);
- }
- return TRUE;
- case WM_USER+10:
- EnableWindow(GetDlgItem(hwndDlg,IDC_FILENAME),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
- EnableWindow(GetDlgItem(hwndDlg,IDC_BROWSE),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
- EnableWindow(GetDlgItem(hwndDlg,IDC_STRETCHH),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
- EnableWindow(GetDlgItem(hwndDlg,IDC_STRETCHV),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
- EnableWindow(GetDlgItem(hwndDlg,IDC_TILEH),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
- EnableWindow(GetDlgItem(hwndDlg,IDC_TILEV),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
- EnableWindow(GetDlgItem(hwndDlg,IDC_SCROLL),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
- EnableWindow(GetDlgItem(hwndDlg,IDC_PROPORTIONAL),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
- EnableWindow(GetDlgItem(hwndDlg,IDC_TILEVROWH),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
- break;
- case WM_COMMAND:
- if(LOWORD(wParam)==IDC_BROWSE) {
- char str[MAX_PATH];
- OPENFILENAMEA ofn={0};
- char filter[512];
-
- GetDlgItemTextA(hwndDlg,IDC_FILENAME,str,SIZEOF(str));
- ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
- ofn.hwndOwner = hwndDlg;
- ofn.hInstance = NULL;
- CallService(MS_UTILS_GETBITMAPFILTERSTRINGS,SIZEOF(filter),(LPARAM)filter);
- ofn.lpstrFilter = filter;
- ofn.lpstrFile = str;
- ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
- ofn.nMaxFile = SIZEOF(str);
- ofn.nMaxFileTitle = MAX_PATH;
- ofn.lpstrDefExt = "bmp";
- if (!GetOpenFileNameA(&ofn)) break;
- SetDlgItemTextA(hwndDlg,IDC_FILENAME,str);
- }
- else if(LOWORD(wParam)==IDC_FILENAME && HIWORD(wParam)!=EN_CHANGE) break;
- if(LOWORD(wParam)==IDC_BITMAP) SendMessage(hwndDlg,WM_USER+10,0,0);
- if(LOWORD(wParam)==IDC_FILENAME && (HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus())) return 0;
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case WM_NOTIFY:
- switch(((LPNMHDR)lParam)->idFrom) {
- case 0:
- switch (((LPNMHDR)lParam)->code) {
- case PSN_APPLY:
- DBWriteContactSettingByte(NULL,"CLC","UseBitmap",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
- { COLORREF col;
- col=SendDlgItemMessage(hwndDlg,IDC_BKGCOLOUR,CPM_GETCOLOUR,0,0);
- if(col==CLCDEFAULT_BKCOLOUR) DBDeleteContactSetting(NULL,"CLC","BkColour");
- else DBWriteContactSettingDword(NULL,"CLC","BkColour",col);
- col=SendDlgItemMessage(hwndDlg,IDC_SELCOLOUR,CPM_GETCOLOUR,0,0);
- if(col==CLCDEFAULT_SELBKCOLOUR) DBDeleteContactSetting(NULL,"CLC","SelBkColour");
- else DBWriteContactSettingDword(NULL,"CLC","SelBkColour",col);
- }
- {
- char str[MAX_PATH],strrel[MAX_PATH];
- GetDlgItemTextA(hwndDlg,IDC_FILENAME,str,SIZEOF(str));
- if (ServiceExists(MS_UTILS_PATHTORELATIVE)) {
- if (CallService(MS_UTILS_PATHTORELATIVE, (WPARAM)str, (LPARAM)strrel))
- DBWriteContactSettingString(NULL,"CLC","BkBitmap",strrel);
- else DBWriteContactSettingString(NULL,"CLC","BkBitmap",str);
- }
- else DBWriteContactSettingString(NULL,"CLC","BkBitmap",str);
- }
- { WORD flags=0;
- if(IsDlgButtonChecked(hwndDlg,IDC_STRETCHH)) flags|=CLB_STRETCHH;
- if(IsDlgButtonChecked(hwndDlg,IDC_STRETCHV)) flags|=CLB_STRETCHV;
- if(IsDlgButtonChecked(hwndDlg,IDC_TILEH)) flags|=CLBF_TILEH;
- if(IsDlgButtonChecked(hwndDlg,IDC_TILEV)) flags|=CLBF_TILEV;
- if(IsDlgButtonChecked(hwndDlg,IDC_SCROLL)) flags|=CLBF_SCROLL;
- if(IsDlgButtonChecked(hwndDlg,IDC_PROPORTIONAL)) flags|=CLBF_PROPORTIONAL;
- if(IsDlgButtonChecked(hwndDlg,IDC_TILEVROWH)) flags|=CLBF_TILEVTOROWHEIGHT;
-
- DBWriteContactSettingWord(NULL,"CLC","BkBmpUse",flags);
- }
-
- pcli->pfnClcOptionsChanged();
- return TRUE;
- }
- break;
- }
- break;
- }
- return FALSE;
-}
-
-static const TCHAR *szFontIdDescr[FONTID_MAX+1]=
-{
- LPGENT("Standard contacts"),
- LPGENT("Online contacts to whom you have a different visibility"),
- LPGENT("Offline contacts"),
- LPGENT("Contacts which are 'not on list'"),
- LPGENT("Groups"),
- LPGENT("Group member counts"),
- LPGENT("Dividers"),
- LPGENT("Offline contacts to whom you have a different visibility"),
- LPGENT("Status messages"),
- LPGENT("Group Closed"),
- LPGENT("Hover Contacts")
-};
-
-#define SAMEASF_FACE 1
-#define SAMEASF_SIZE 2
-#define SAMEASF_STYLE 4
-#define SAMEASF_COLOUR 8
-#include <pshpack1.h>
-struct {
- BYTE sameAsFlags,sameAs;
- COLORREF colour;
- char size;
- BYTE style;
- BYTE charset;
- TCHAR szFace[LF_FACESIZE];
-} static fontSettings[FONTID_MAX+1];
-#include <poppack.h>
-static const WORD fontSameAsDefault[FONTID_MAX+1]={0x00FF,0x0B00,0x0F00,0x0700,0x0B00,0x0104,0x0D00,0x0B02,0x0B00,0x0700};
-static const char *fontSizes[]={"7","8","10","14","16","18","20","24","28","16","7"};
-static const int fontListOrder[FONTID_MAX+1]={FONTID_CONTACTS,FONTID_INVIS,FONTID_OFFLINE,FONTID_OFFINVIS,FONTID_NOTONLIST,FONTID_GROUPS,FONTID_GROUPCOUNTS,FONTID_DIVIDERS,FONTID_STATUSMSG,FONTID_GROUPSCLOSED,FONTID_CONTACTSHOVER};
-
-#define M_REBUILDFONTGROUP (WM_USER+10)
-#define M_REMAKESAMPLE (WM_USER+11)
-#define M_RECALCONEFONT (WM_USER+12)
-#define M_RECALCOTHERFONTS (WM_USER+13)
-#define M_SAVEFONT (WM_USER+14)
-#define M_REFRESHSAMEASBOXES (WM_USER+15)
-#define M_FILLSCRIPTCOMBO (WM_USER+16)
-#define M_REDOROWHEIGHT (WM_USER+17)
-#define M_LOADFONT (WM_USER+18)
-#define M_GUESSSAMEASBOXES (WM_USER+19)
-#define M_SETSAMEASBOXES (WM_USER+20)
-
-static int CALLBACK EnumFontsProc(ENUMLOGFONTEX *lpelfe,NEWTEXTMETRICEX *lpntme,int FontType,LPARAM lParam)
-{
- if (!IsWindow((HWND)lParam)) return FALSE;
- if(SendMessage((HWND)lParam,CB_FINDSTRINGEXACT,-1,(LPARAM)lpelfe->elfLogFont.lfFaceName)==CB_ERR)
- SendMessage((HWND)lParam,CB_ADDSTRING,0,(LPARAM)lpelfe->elfLogFont.lfFaceName);
- return TRUE;
-}
-
-void FillFontListThread(HWND hwndDlg)
-{
- LOGFONT lf={0};
- HDC hdc=GetDC(hwndDlg);
- lf.lfCharSet=DEFAULT_CHARSET;
- lf.lfFaceName[0]=0;
- lf.lfPitchAndFamily=0;
- EnumFontFamiliesEx(hdc,&lf,(FONTENUMPROC)EnumFontsProc,(LPARAM)GetDlgItem(hwndDlg,IDC_TYPEFACE),0);
- ReleaseDC(hwndDlg,hdc);
- return;
-}
-
-static int CALLBACK EnumFontScriptsProc(ENUMLOGFONTEX *lpelfe,NEWTEXTMETRICEX *lpntme,int FontType,LPARAM lParam)
-{
- if(SendMessage((HWND)lParam,CB_FINDSTRINGEXACT,-1,(LPARAM)lpelfe->elfScript)==CB_ERR) {
- int i=SendMessage((HWND)lParam,CB_ADDSTRING,0,(LPARAM)lpelfe->elfScript);
- SendMessage((HWND)lParam,CB_SETITEMDATA,i,lpelfe->elfLogFont.lfCharSet);
- }
- return TRUE;
-}
-
-static int TextOptsDlgResizer(HWND hwndDlg,LPARAM lParam,UTILRESIZECONTROL *urc)
-{
- return RD_ANCHORX_LEFT|RD_ANCHORY_TOP;
-}
-
-static void SwitchTextDlgToMode(HWND hwndDlg,int expert)
-{
- ShowWindow(GetDlgItem(hwndDlg,IDC_GAMMACORRECT),expert?SW_SHOW:SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg,IDC_STSAMETEXT),expert?SW_SHOW:SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg,IDC_SAMETYPE),expert?SW_SHOW:SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg,IDC_SAMESIZE),expert?SW_SHOW:SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg,IDC_SAMESTYLE),expert?SW_SHOW:SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg,IDC_SAMECOLOUR),expert?SW_SHOW:SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg,IDC_STSIZETEXT),expert?SW_HIDE:SW_SHOW);
- ShowWindow(GetDlgItem(hwndDlg,IDC_STCOLOURTEXT),expert?SW_HIDE:SW_SHOW);
- SetDlgItemText(hwndDlg,IDC_STASTEXT,TranslateTS( expert ? _T("as:") : _T("based on:" )));
- { UTILRESIZEDIALOG urd={0};
- urd.cbSize=sizeof(urd);
- urd.hwndDlg=hwndDlg;
- urd.hInstance=g_hInst;
- urd.lpTemplate=MAKEINTRESOURCEA(expert?IDD_OPT_CLCTEXT:IDD_OPT_CLCTEXTSIMPLE);
- urd.pfnResizer=TextOptsDlgResizer;
- CallService(MS_UTILS_RESIZEDIALOG,0,(LPARAM)&urd);
- }
- //resizer breaks the sizing of the edit box
- SendDlgItemMessage(hwndDlg,IDC_ROWHEIGHTSPIN,UDM_SETBUDDY,(WPARAM)GetDlgItem(hwndDlg,IDC_ROWHEIGHT),0);
- SendMessage(hwndDlg,M_REFRESHSAMEASBOXES,SendDlgItemMessage(hwndDlg,IDC_FONTID,CB_GETITEMDATA,SendDlgItemMessage(hwndDlg,IDC_FONTID,CB_GETCURSEL,0,0),0),0);
-}
-
-static INT_PTR CALLBACK DlgProcClcTextOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- static HFONT hFontSample;
-
- switch (msg) {
- case WM_INITDIALOG:
- hFontSample=NULL;
- SetDlgItemTextA(hwndDlg,IDC_SAMPLE,"Sample");
- TranslateDialogDefault(hwndDlg);
- if (!SendMessage(GetParent(hwndDlg),PSM_ISEXPERT,0,0))
- SwitchTextDlgToMode(hwndDlg,0);
- mir_forkthread(FillFontListThread,hwndDlg);
- {
- int i,itemId,fontId;
- LOGFONT lf;
- COLORREF colour;
- WORD sameAs;
- char str[32];
-
- for(i=0;i<=FONTID_MAX;i++) {
- fontId=fontListOrder[i];
- pcli->pfnGetFontSetting(fontId,&lf,&colour);
- wsprintfA(str,"Font%dAs",fontId);
- sameAs=DBGetContactSettingWord(NULL,"CLC",str,fontSameAsDefault[fontId]);
- fontSettings[fontId].sameAsFlags=HIBYTE(sameAs);
- fontSettings[fontId].sameAs=LOBYTE(sameAs);
- fontSettings[fontId].style=(lf.lfWeight==FW_NORMAL?0:DBFONTF_BOLD)|(lf.lfItalic?DBFONTF_ITALIC:0)|(lf.lfUnderline?DBFONTF_UNDERLINE:0);
- if(lf.lfHeight<0) {
- HDC hdc;
- SIZE size;
- HFONT hFont=CreateFontIndirect(&lf);
- hdc=GetDC(hwndDlg);
- SelectObject(hdc,hFont);
- GetTextExtentPoint32A(hdc,"_W",2,&size);
- ReleaseDC(hwndDlg,hdc);
- DeleteObject(hFont);
- fontSettings[fontId].size=(char)size.cy;
- }
- else fontSettings[fontId].size=(char)lf.lfHeight;
- fontSettings[fontId].charset=lf.lfCharSet;
- fontSettings[fontId].colour=colour;
- lstrcpy(fontSettings[fontId].szFace,lf.lfFaceName);
- itemId=SendDlgItemMessage(hwndDlg,IDC_FONTID,CB_ADDSTRING,0,(LPARAM)TranslateTS(szFontIdDescr[fontId]));
- SendDlgItemMessage(hwndDlg,IDC_FONTID,CB_SETITEMDATA,itemId,fontId);
- }
- SendDlgItemMessage(hwndDlg,IDC_FONTID,CB_SETCURSEL,0,0);
- for(i=0; i < SIZEOF(fontSizes);i++)
- SendDlgItemMessageA(hwndDlg,IDC_FONTSIZE,CB_ADDSTRING,0,(LPARAM)fontSizes[i]);
- }
- SendDlgItemMessage(hwndDlg,IDC_ROWHEIGHTSPIN,UDM_SETRANGE,0,MAKELONG(255,0));
- SendDlgItemMessage(hwndDlg,IDC_ROWHEIGHTSPIN,UDM_SETPOS,0,MAKELONG(DBGetContactSettingByte(NULL,"CLC","RowHeight",CLCDEFAULT_ROWHEIGHT),0));
- SendMessage(hwndDlg,M_REBUILDFONTGROUP,0,0);
- SendMessage(hwndDlg,M_SAVEFONT,0,0);
- SendDlgItemMessage(hwndDlg,IDC_HOTCOLOUR,CPM_SETDEFAULTCOLOUR,0,CLCDEFAULT_HOTTEXTCOLOUR);
- SendDlgItemMessage(hwndDlg,IDC_HOTCOLOUR,CPM_SETCOLOUR,0,DBGetContactSettingDword(NULL,"CLC","HotTextColour",CLCDEFAULT_HOTTEXTCOLOUR));
- CheckDlgButton(hwndDlg,IDC_GAMMACORRECT,DBGetContactSettingByte(NULL,"CLC","GammaCorrect",CLCDEFAULT_GAMMACORRECT)?BST_CHECKED:BST_UNCHECKED);
- SendDlgItemMessage(hwndDlg,IDC_SELCOLOUR,CPM_SETDEFAULTCOLOUR,0,CLCDEFAULT_SELTEXTCOLOUR);
- SendDlgItemMessage(hwndDlg,IDC_SELCOLOUR,CPM_SETCOLOUR,0,DBGetContactSettingDword(NULL,"CLC","SelTextColour",CLCDEFAULT_SELTEXTCOLOUR));
- SendDlgItemMessage(hwndDlg,IDC_QUICKCOLOUR,CPM_SETDEFAULTCOLOUR,0,CLCDEFAULT_QUICKSEARCHCOLOUR);
- SendDlgItemMessage(hwndDlg,IDC_QUICKCOLOUR,CPM_SETCOLOUR,0,DBGetContactSettingDword(NULL,"CLC","QuickSearchColour",CLCDEFAULT_QUICKSEARCHCOLOUR));
-
- CheckDlgButton(hwndDlg,IDC_HILIGHTMODE,DBGetContactSettingByte(NULL,"CLC","HiLightMode",0)==0?BST_CHECKED:BST_UNCHECKED);
- CheckDlgButton(hwndDlg,IDC_HILIGHTMODE1,DBGetContactSettingByte(NULL,"CLC","HiLightMode",0)==1?BST_CHECKED:BST_UNCHECKED);
- CheckDlgButton(hwndDlg,IDC_HILIGHTMODE2,DBGetContactSettingByte(NULL,"CLC","HiLightMode",0)==2?BST_CHECKED:BST_UNCHECKED);
- CheckDlgButton(hwndDlg,IDC_HILIGHTMODE3,DBGetContactSettingByte(NULL,"CLC","HiLightMode",0)==3?BST_CHECKED:BST_UNCHECKED);
- return TRUE;
-
- case M_REBUILDFONTGROUP: //remake all the needed controls when the user changes the font selector at the top
- { int i=SendDlgItemMessage(hwndDlg,IDC_FONTID,CB_GETITEMDATA,SendDlgItemMessage(hwndDlg,IDC_FONTID,CB_GETCURSEL,0,0),0);
- SendMessage(hwndDlg,M_SETSAMEASBOXES,i,0);
- { int j,id,itemId;
- TCHAR szText[256];
- SendDlgItemMessage(hwndDlg,IDC_SAMEAS,CB_RESETCONTENT,0,0);
- itemId=SendDlgItemMessage(hwndDlg,IDC_SAMEAS,CB_ADDSTRING,0,(LPARAM)TranslateT("<none>"));
- SendDlgItemMessage(hwndDlg,IDC_SAMEAS,CB_SETITEMDATA,itemId,0xFF);
- if(0xFF==fontSettings[i].sameAs)
- SendDlgItemMessage(hwndDlg,IDC_SAMEAS,CB_SETCURSEL,itemId,0);
- for(j=0;j<=FONTID_MAX;j++) {
- SendDlgItemMessage(hwndDlg,IDC_FONTID,CB_GETLBTEXT,j,(LPARAM)szText);
- id=SendDlgItemMessage(hwndDlg,IDC_FONTID,CB_GETITEMDATA,j,0);
- if(id==i) continue;
- itemId=SendDlgItemMessage(hwndDlg,IDC_SAMEAS,CB_ADDSTRING,0,(LPARAM)szText);
- SendDlgItemMessage(hwndDlg,IDC_SAMEAS,CB_SETITEMDATA,itemId,id);
- if(id==fontSettings[i].sameAs)
- SendDlgItemMessage(hwndDlg,IDC_SAMEAS,CB_SETCURSEL,itemId,0);
- }
- }
- SendMessage(hwndDlg,M_LOADFONT,i,0);
- SendMessage(hwndDlg,M_REFRESHSAMEASBOXES,i,0);
- SendMessage(hwndDlg,M_REMAKESAMPLE,0,0);
- break;
- }
- case M_SETSAMEASBOXES: //set the check mark in the 'same as' boxes to the right value for fontid wParam
- CheckDlgButton(hwndDlg,IDC_SAMETYPE,fontSettings[wParam].sameAsFlags&SAMEASF_FACE?BST_CHECKED:BST_UNCHECKED);
- CheckDlgButton(hwndDlg,IDC_SAMESIZE,fontSettings[wParam].sameAsFlags&SAMEASF_SIZE?BST_CHECKED:BST_UNCHECKED);
- CheckDlgButton(hwndDlg,IDC_SAMESTYLE,fontSettings[wParam].sameAsFlags&SAMEASF_STYLE?BST_CHECKED:BST_UNCHECKED);
- CheckDlgButton(hwndDlg,IDC_SAMECOLOUR,fontSettings[wParam].sameAsFlags&SAMEASF_COLOUR?BST_CHECKED:BST_UNCHECKED);
- break;
- case M_FILLSCRIPTCOMBO: //fill the script combo box and set the selection to the value for fontid wParam
- { LOGFONT lf={0};
- int i;
- HDC hdc=GetDC(hwndDlg);
- lf.lfCharSet=DEFAULT_CHARSET;
- GetDlgItemText(hwndDlg,IDC_TYPEFACE,lf.lfFaceName,SIZEOF(lf.lfFaceName));
- lf.lfPitchAndFamily=0;
- SendDlgItemMessage(hwndDlg,IDC_SCRIPT,CB_RESETCONTENT,0,0);
- EnumFontFamiliesEx(hdc,&lf,(FONTENUMPROC)EnumFontScriptsProc,(LPARAM)GetDlgItem(hwndDlg,IDC_SCRIPT),0);
- ReleaseDC(hwndDlg,hdc);
- for(i=SendDlgItemMessage(hwndDlg,IDC_SCRIPT,CB_GETCOUNT,0,0)-1;i>=0;i--) {
- if(SendDlgItemMessage(hwndDlg,IDC_SCRIPT,CB_GETITEMDATA,i,0)==fontSettings[wParam].charset) {
- SendDlgItemMessage(hwndDlg,IDC_SCRIPT,CB_SETCURSEL,i,0);
- break;
- }
- }
- if(i<0) SendDlgItemMessage(hwndDlg,IDC_SCRIPT,CB_SETCURSEL,0,0);
- break;
- }
- case WM_CTLCOLORSTATIC:
- if ((HWND)lParam==GetDlgItem(hwndDlg,IDC_SAMPLE)) {
- SetTextColor((HDC)wParam,SendDlgItemMessage(hwndDlg,IDC_COLOUR,CPM_GETCOLOUR,0,0));
- SetBkColor((HDC)wParam,GetSysColor(COLOR_3DFACE));
- return (INT_PTR)GetSysColorBrush(COLOR_3DFACE);
- }
- break;
- case M_REFRESHSAMEASBOXES: //set the disabled flag on the 'same as' checkboxes to the values for fontid wParam
- EnableWindow(GetDlgItem(hwndDlg,IDC_SAMETYPE),fontSettings[wParam].sameAs!=0xFF);
- EnableWindow(GetDlgItem(hwndDlg,IDC_SAMESIZE),fontSettings[wParam].sameAs!=0xFF);
- EnableWindow(GetDlgItem(hwndDlg,IDC_SAMESTYLE),fontSettings[wParam].sameAs!=0xFF);
- EnableWindow(GetDlgItem(hwndDlg,IDC_SAMECOLOUR),fontSettings[wParam].sameAs!=0xFF);
- if(SendMessage(GetParent(hwndDlg),PSM_ISEXPERT,0,0)) {
- EnableWindow(GetDlgItem(hwndDlg,IDC_TYPEFACE),fontSettings[wParam].sameAs==0xFF || !(fontSettings[wParam].sameAsFlags&SAMEASF_FACE));
- EnableWindow(GetDlgItem(hwndDlg,IDC_SCRIPT),fontSettings[wParam].sameAs==0xFF || !(fontSettings[wParam].sameAsFlags&SAMEASF_FACE));
- EnableWindow(GetDlgItem(hwndDlg,IDC_FONTSIZE),fontSettings[wParam].sameAs==0xFF || !(fontSettings[wParam].sameAsFlags&SAMEASF_SIZE));
- EnableWindow(GetDlgItem(hwndDlg,IDC_BOLD),fontSettings[wParam].sameAs==0xFF || !(fontSettings[wParam].sameAsFlags&SAMEASF_STYLE));
- EnableWindow(GetDlgItem(hwndDlg,IDC_ITALIC),fontSettings[wParam].sameAs==0xFF || !(fontSettings[wParam].sameAsFlags&SAMEASF_STYLE));
- EnableWindow(GetDlgItem(hwndDlg,IDC_UNDERLINE),fontSettings[wParam].sameAs==0xFF || !(fontSettings[wParam].sameAsFlags&SAMEASF_STYLE));
- EnableWindow(GetDlgItem(hwndDlg,IDC_COLOUR),fontSettings[wParam].sameAs==0xFF || !(fontSettings[wParam].sameAsFlags&SAMEASF_COLOUR));
- }
- else {
- EnableWindow(GetDlgItem(hwndDlg,IDC_TYPEFACE),TRUE);
- EnableWindow(GetDlgItem(hwndDlg,IDC_SCRIPT),TRUE);
- EnableWindow(GetDlgItem(hwndDlg,IDC_FONTSIZE),TRUE);
- EnableWindow(GetDlgItem(hwndDlg,IDC_BOLD),TRUE);
- EnableWindow(GetDlgItem(hwndDlg,IDC_ITALIC),TRUE);
- EnableWindow(GetDlgItem(hwndDlg,IDC_UNDERLINE),TRUE);
- EnableWindow(GetDlgItem(hwndDlg,IDC_COLOUR),TRUE);
- }
- break;
- case M_REMAKESAMPLE: //remake the sample edit box font based on the settings in the controls
- { LOGFONT lf;
- if(hFontSample) {
- SendDlgItemMessage(hwndDlg,IDC_SAMPLE,WM_SETFONT,SendDlgItemMessage(hwndDlg,IDC_FONTID,WM_GETFONT,0,0),0);
- DeleteObject(hFontSample);
- }
- lf.lfHeight=GetDlgItemInt(hwndDlg,IDC_FONTSIZE,NULL,FALSE);
- {
- HDC hdc=GetDC(NULL);
- lf.lfHeight=-MulDiv(lf.lfHeight, GetDeviceCaps(hdc, LOGPIXELSY), 72);
- ReleaseDC(NULL,hdc);
- }
- lf.lfWidth=lf.lfEscapement=lf.lfOrientation=0;
- lf.lfWeight=IsDlgButtonChecked(hwndDlg,IDC_BOLD)?FW_BOLD:FW_NORMAL;
- lf.lfItalic=IsDlgButtonChecked(hwndDlg,IDC_ITALIC);
- lf.lfUnderline=IsDlgButtonChecked(hwndDlg,IDC_UNDERLINE);
- lf.lfStrikeOut=0;
- lf.lfCharSet=(BYTE)SendDlgItemMessage(hwndDlg,IDC_SCRIPT,CB_GETITEMDATA,SendDlgItemMessage(hwndDlg,IDC_SCRIPT,CB_GETCURSEL,0,0),0);
- lf.lfOutPrecision=OUT_DEFAULT_PRECIS;
- lf.lfClipPrecision=CLIP_DEFAULT_PRECIS;
- lf.lfQuality=DEFAULT_QUALITY;
- lf.lfPitchAndFamily=DEFAULT_PITCH|FF_DONTCARE;
- GetDlgItemText(hwndDlg,IDC_TYPEFACE,lf.lfFaceName,SIZEOF(lf.lfFaceName));
- hFontSample=CreateFontIndirect(&lf);
- SendDlgItemMessage(hwndDlg,IDC_SAMPLE,WM_SETFONT,(WPARAM)hFontSample,TRUE);
- break;
- }
- case M_RECALCONEFONT: //copy the 'same as' settings for fontid wParam from their sources
- if(fontSettings[wParam].sameAs==0xFF) break;
- if(fontSettings[wParam].sameAsFlags&SAMEASF_FACE) {
- lstrcpy(fontSettings[wParam].szFace,fontSettings[fontSettings[wParam].sameAs].szFace);
- fontSettings[wParam].charset=fontSettings[fontSettings[wParam].sameAs].charset;
- }
- if(fontSettings[wParam].sameAsFlags&SAMEASF_SIZE)
- fontSettings[wParam].size=fontSettings[fontSettings[wParam].sameAs].size;
- if(fontSettings[wParam].sameAsFlags&SAMEASF_STYLE)
- fontSettings[wParam].style=fontSettings[fontSettings[wParam].sameAs].style;
- if(fontSettings[wParam].sameAsFlags&SAMEASF_COLOUR)
- fontSettings[wParam].colour=fontSettings[fontSettings[wParam].sameAs].colour;
- break;
- case M_RECALCOTHERFONTS: //recalculate the 'same as' settings for all fonts but wParam
- { int i;
- for(i=0;i<=FONTID_MAX;i++) {
- if(i==(int)wParam) continue;
- SendMessage(hwndDlg,M_RECALCONEFONT,i,0);
- }
- break;
- }
- case M_SAVEFONT: //save the font settings from the controls to font wParam
- fontSettings[wParam].sameAsFlags=(IsDlgButtonChecked(hwndDlg,IDC_SAMETYPE)?SAMEASF_FACE:0)|(IsDlgButtonChecked(hwndDlg,IDC_SAMESIZE)?SAMEASF_SIZE:0)|(IsDlgButtonChecked(hwndDlg,IDC_SAMESTYLE)?SAMEASF_STYLE:0)|(IsDlgButtonChecked(hwndDlg,IDC_SAMECOLOUR)?SAMEASF_COLOUR:0);
- fontSettings[wParam].sameAs=(BYTE)SendDlgItemMessage(hwndDlg,IDC_SAMEAS,CB_GETITEMDATA,SendDlgItemMessage(hwndDlg,IDC_SAMEAS,CB_GETCURSEL,0,0),0);
- GetDlgItemText(hwndDlg,IDC_TYPEFACE,fontSettings[wParam].szFace,SIZEOF(fontSettings[wParam].szFace));
- fontSettings[wParam].charset=(BYTE)SendDlgItemMessage(hwndDlg,IDC_SCRIPT,CB_GETITEMDATA,SendDlgItemMessage(hwndDlg,IDC_SCRIPT,CB_GETCURSEL,0,0),0);
- fontSettings[wParam].size=(char)GetDlgItemInt(hwndDlg,IDC_FONTSIZE,NULL,FALSE);
- fontSettings[wParam].style=(IsDlgButtonChecked(hwndDlg,IDC_BOLD)?DBFONTF_BOLD:0)|(IsDlgButtonChecked(hwndDlg,IDC_ITALIC)?DBFONTF_ITALIC:0)|(IsDlgButtonChecked(hwndDlg,IDC_UNDERLINE)?DBFONTF_UNDERLINE:0);
- fontSettings[wParam].colour=SendDlgItemMessage(hwndDlg,IDC_COLOUR,CPM_GETCOLOUR,0,0);
- SendMessage(hwndDlg,M_REDOROWHEIGHT,0,0);
- break;
- case M_REDOROWHEIGHT: //recalculate the minimum feasible row height
- { int i;
- int minHeight=1;//GetSystemMetrics(SM_CYSMICON) +1;
- for(i=0;i<=FONTID_MAX;i++)
- {
- SIZE fontSize;
- HFONT hFont, oldfnt;
- HDC hdc=GetDC(NULL);
- LOGFONT lf;
- lf.lfHeight=fontSettings[i].size;
- {
- HDC hdc=GetDC(NULL);
- lf.lfHeight=-MulDiv(lf.lfHeight, GetDeviceCaps(hdc, LOGPIXELSY), 72);
- ReleaseDC(NULL,hdc);
- }
- lf.lfWidth=lf.lfEscapement=lf.lfOrientation=0;
- lf.lfWeight=(fontSettings[i].style&DBFONTF_BOLD)?FW_BOLD:FW_NORMAL;
- lf.lfItalic=fontSettings[i].style&DBFONTF_ITALIC;
- lf.lfUnderline=fontSettings[i].style&DBFONTF_UNDERLINE;
- lf.lfStrikeOut=0;
- lf.lfCharSet=(BYTE)fontSettings[i].charset;
- lf.lfOutPrecision=OUT_DEFAULT_PRECIS;
- lf.lfClipPrecision=CLIP_DEFAULT_PRECIS;
- lf.lfQuality=DEFAULT_QUALITY;
- lf.lfPitchAndFamily=DEFAULT_PITCH|FF_DONTCARE;
- _tcscpy(lf.lfFaceName,fontSettings[i].szFace);
-
- hFont=CreateFontIndirect(&lf);
- oldfnt=(HFONT)SelectObject(hdc,(HFONT)hFont);
- GetTextExtentPoint32A(hdc,"x",1,&fontSize);
- if(fontSize.cy+2>minHeight) minHeight=fontSize.cy+2;
- SelectObject(hdc,oldfnt);
- DeleteObject(hFont);
- ReleaseDC(NULL,hdc);
-
-
- }
- //i=SendDlgItemMessage(hwndDlg,IDC_ROWHEIGHTSPIN,UDM_GETPOS,0,0);
- //if(i<minHeight) SendDlgItemMessage(hwndDlg,IDC_ROWHEIGHTSPIN,UDM_SETPOS,0,MAKELONG(minHeight,0));
- minHeight=1;
- SendDlgItemMessage(hwndDlg,IDC_ROWHEIGHTSPIN,UDM_SETRANGE,0,MAKELONG(255,minHeight));
- break;
- }
-
- case M_LOADFONT: //load font wParam into the controls
- SetDlgItemText(hwndDlg,IDC_TYPEFACE,fontSettings[wParam].szFace);
- SendMessage(hwndDlg,M_FILLSCRIPTCOMBO,wParam,0);
- SetDlgItemInt(hwndDlg,IDC_FONTSIZE,fontSettings[wParam].size,FALSE);
- CheckDlgButton(hwndDlg,IDC_BOLD,fontSettings[wParam].style&DBFONTF_BOLD?BST_CHECKED:BST_UNCHECKED);
- CheckDlgButton(hwndDlg,IDC_ITALIC,fontSettings[wParam].style&DBFONTF_ITALIC?BST_CHECKED:BST_UNCHECKED);
- CheckDlgButton(hwndDlg,IDC_UNDERLINE,fontSettings[wParam].style&DBFONTF_UNDERLINE?BST_CHECKED:BST_UNCHECKED);
- { LOGFONT lf;
- COLORREF colour;
- pcli->pfnGetDefaultFontSetting(wParam,&lf,&colour);
- SendDlgItemMessage(hwndDlg,IDC_COLOUR,CPM_SETDEFAULTCOLOUR,0,colour);
- }
- SendDlgItemMessage(hwndDlg,IDC_COLOUR,CPM_SETCOLOUR,0,fontSettings[wParam].colour);
- break;
- case M_GUESSSAMEASBOXES: //guess suitable values for the 'same as' checkboxes for fontId wParam
- fontSettings[wParam].sameAsFlags=0;
- if(fontSettings[wParam].sameAs==0xFF) break;
- if (!lstrcmp(fontSettings[wParam].szFace,fontSettings[fontSettings[wParam].sameAs].szFace) &&
- fontSettings[wParam].charset==fontSettings[fontSettings[wParam].sameAs].charset)
- fontSettings[wParam].sameAsFlags|=SAMEASF_FACE;
- if(fontSettings[wParam].size==fontSettings[fontSettings[wParam].sameAs].size)
- fontSettings[wParam].sameAsFlags|=SAMEASF_SIZE;
- if(fontSettings[wParam].style==fontSettings[fontSettings[wParam].sameAs].style)
- fontSettings[wParam].sameAsFlags|=SAMEASF_STYLE;
- if(fontSettings[wParam].colour==fontSettings[fontSettings[wParam].sameAs].colour)
- fontSettings[wParam].sameAsFlags|=SAMEASF_COLOUR;
- SendMessage(hwndDlg,M_SETSAMEASBOXES,wParam,0);
- break;
- case WM_VSCROLL:
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case WM_COMMAND:
- { int fontId=SendDlgItemMessage(hwndDlg,IDC_FONTID,CB_GETITEMDATA,SendDlgItemMessage(hwndDlg,IDC_FONTID,CB_GETCURSEL,0,0),0);
- switch(LOWORD(wParam)) {
- case IDC_FONTID:
- if(HIWORD(wParam)!=CBN_SELCHANGE) return FALSE;
- SendMessage(hwndDlg,M_REBUILDFONTGROUP,0,0);
- return 0;
- case IDC_SAMETYPE:
- case IDC_SAMESIZE:
- case IDC_SAMESTYLE:
- case IDC_SAMECOLOUR:
- SendMessage(hwndDlg,M_SAVEFONT,fontId,0);
- SendMessage(hwndDlg,M_RECALCONEFONT,fontId,0);
- SendMessage(hwndDlg,M_REMAKESAMPLE,0,0);
- SendMessage(hwndDlg,M_REFRESHSAMEASBOXES,fontId,0);
- break;
- case IDC_SAMEAS:
- if(HIWORD(wParam)!=CBN_SELCHANGE) return FALSE;
- if(SendDlgItemMessage(hwndDlg,IDC_SAMEAS,CB_GETITEMDATA,SendDlgItemMessage(hwndDlg,IDC_SAMEAS,CB_GETCURSEL,0,0),0)==fontId)
- SendDlgItemMessage(hwndDlg,IDC_SAMEAS,CB_SETCURSEL,0,0);
- if (!SendMessage(GetParent(hwndDlg),PSM_ISEXPERT,0,0)) {
- int sameAs=SendDlgItemMessage(hwndDlg,IDC_SAMEAS,CB_GETITEMDATA,SendDlgItemMessage(hwndDlg,IDC_SAMEAS,CB_GETCURSEL,0,0),0);
- if(sameAs!=0xFF) SendMessage(hwndDlg,M_LOADFONT,sameAs,0);
- SendMessage(hwndDlg,M_SAVEFONT,fontId,0);
- SendMessage(hwndDlg,M_GUESSSAMEASBOXES,fontId,0);
- }
- else SendMessage(hwndDlg,M_SAVEFONT,fontId,0);
- SendMessage(hwndDlg,M_RECALCONEFONT,fontId,0);
- SendMessage(hwndDlg,M_FILLSCRIPTCOMBO,fontId,0);
- SendMessage(hwndDlg,M_REMAKESAMPLE,0,0);
- SendMessage(hwndDlg,M_REFRESHSAMEASBOXES,fontId,0);
- break;
- case IDC_TYPEFACE:
- case IDC_SCRIPT:
- case IDC_FONTSIZE:
- if(HIWORD(wParam)!=CBN_EDITCHANGE && HIWORD(wParam)!=CBN_SELCHANGE) return FALSE;
- if(HIWORD(wParam)==CBN_SELCHANGE) {
- SendDlgItemMessage(hwndDlg,LOWORD(wParam),CB_SETCURSEL,SendDlgItemMessage(hwndDlg,LOWORD(wParam),CB_GETCURSEL,0,0),0);
- }
- if(LOWORD(wParam)==IDC_TYPEFACE)
- SendMessage(hwndDlg,M_FILLSCRIPTCOMBO,fontId,0);
- //fall through
- case IDC_BOLD:
- case IDC_ITALIC:
- case IDC_UNDERLINE:
- case IDC_COLOUR:
- SendMessage(hwndDlg,M_SAVEFONT,fontId,0);
- if (!SendMessage(GetParent(hwndDlg),PSM_ISEXPERT,0,0)) {
- SendMessage(hwndDlg,M_GUESSSAMEASBOXES,fontId,0);
- SendMessage(hwndDlg,M_REFRESHSAMEASBOXES,fontId,0);
- }
- SendMessage(hwndDlg,M_RECALCOTHERFONTS,fontId,0);
- SendMessage(hwndDlg,M_REMAKESAMPLE,0,0);
- SendMessage(hwndDlg,M_REDOROWHEIGHT,0,0);
- break;
- case IDC_SAMPLE:
- return 0;
- case IDC_ROWHEIGHT:
- if(HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus()) return 0;
- break;
- }
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- }
- case WM_NOTIFY:
- switch(((LPNMHDR)lParam)->idFrom) {
- case 0:
- switch (((LPNMHDR)lParam)->code) {
- case PSN_APPLY:
- { int i;
- char str[20];
-
- for(i=0;i<=FONTID_MAX;i++) {
- wsprintfA(str,"Font%dName",i);
- DBWriteContactSettingTString(NULL,"CLC",str,fontSettings[i].szFace);
- wsprintfA(str,"Font%dSet",i);
- DBWriteContactSettingByte(NULL,"CLC",str,fontSettings[i].charset);
- wsprintfA(str,"Font%dSize",i);
- DBWriteContactSettingByte(NULL,"CLC",str,fontSettings[i].size);
- wsprintfA(str,"Font%dSty",i);
- DBWriteContactSettingByte(NULL,"CLC",str,fontSettings[i].style);
- wsprintfA(str,"Font%dCol",i);
- DBWriteContactSettingDword(NULL,"CLC",str,fontSettings[i].colour);
- wsprintfA(str,"Font%dAs",i);
- DBWriteContactSettingWord(NULL,"CLC",str,(WORD)((fontSettings[i].sameAsFlags<<8)|fontSettings[i].sameAs));
- }
- }
- { COLORREF col;
- col=SendDlgItemMessage(hwndDlg,IDC_SELCOLOUR,CPM_GETCOLOUR,0,0);
- if(col==CLCDEFAULT_SELTEXTCOLOUR) DBDeleteContactSetting(NULL,"CLC","SelTextColour");
- else DBWriteContactSettingDword(NULL,"CLC","SelTextColour",col);
- col=SendDlgItemMessage(hwndDlg,IDC_HOTCOLOUR,CPM_GETCOLOUR,0,0);
- if(col==CLCDEFAULT_HOTTEXTCOLOUR) DBDeleteContactSetting(NULL,"CLC","HotTextColour");
- else DBWriteContactSettingDword(NULL,"CLC","HotTextColour",col);
- col=SendDlgItemMessage(hwndDlg,IDC_QUICKCOLOUR,CPM_GETCOLOUR,0,0);
- if(col==CLCDEFAULT_QUICKSEARCHCOLOUR) DBDeleteContactSetting(NULL,"CLC","QuickSearchColour");
- else DBWriteContactSettingDword(NULL,"CLC","QuickSearchColour",col);
- }
- DBWriteContactSettingByte(NULL,"CLC","RowHeight",(BYTE)SendDlgItemMessage(hwndDlg,IDC_ROWHEIGHTSPIN,UDM_GETPOS,0,0));
- DBWriteContactSettingByte(NULL,"CLC","GammaCorrect",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_GAMMACORRECT));
- {
- int hil=0;
- if (IsDlgButtonChecked(hwndDlg,IDC_HILIGHTMODE1)) hil=1;
- if (IsDlgButtonChecked(hwndDlg,IDC_HILIGHTMODE2)) hil=2;
- if (IsDlgButtonChecked(hwndDlg,IDC_HILIGHTMODE3)) hil=3;
-
- DBWriteContactSettingByte(NULL,"CLC","HiLightMode",(BYTE)hil);
- }
-
- pcli->pfnClcOptionsChanged();
- return TRUE;
- case PSN_EXPERTCHANGED:
- SwitchTextDlgToMode(hwndDlg,((PSHNOTIFY*)lParam)->lParam);
- break;
- }
- break;
- }
- break;
- case WM_DESTROY:
- if(hFontSample) {
- SendDlgItemMessage(hwndDlg,IDC_SAMPLE,WM_SETFONT,SendDlgItemMessage(hwndDlg,IDC_FONTID,WM_GETFONT,0,0),0);
- DeleteObject(hFontSample);
- }
- break;
- }
- return FALSE;
-}
diff --git a/plugins/Mwclist/clcopts.cpp b/plugins/Mwclist/clcopts.cpp
new file mode 100644
index 0000000000..201f2543f9
--- /dev/null
+++ b/plugins/Mwclist/clcopts.cpp
@@ -0,0 +1,576 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2003 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+#include "commonheaders.h"
+#include "m_clc.h"
+#include "clc.h"
+
+#define DBFONTF_BOLD 1
+#define DBFONTF_ITALIC 2
+#define DBFONTF_UNDERLINE 4
+
+static INT_PTR CALLBACK DlgProcClcMainOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+static INT_PTR CALLBACK DlgProcClcMetaOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+
+static INT_PTR CALLBACK DlgProcStatusBarBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+int OnStatusBarBackgroundChange();
+
+int BgClcChange(WPARAM wParam,LPARAM lParam)
+{
+ pcli->pfnClcOptionsChanged();
+ return 0;
+}
+
+int BgStatusBarChange(WPARAM wParam,LPARAM lParam)
+{
+ pcli->pfnClcOptionsChanged();
+ OnStatusBarBackgroundChange();
+ return 0;
+}
+
+int ClcOptInit(WPARAM wParam,LPARAM lParam)
+{
+ OPTIONSDIALOGPAGE odp = { 0 };
+ odp.cbSize = sizeof(odp);
+ odp.position = 0;
+ odp.hInstance = g_hInst;
+ odp.pszGroup = LPGEN("Contact List");
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_CLC);
+ odp.pszTitle = LPGEN("List");
+ odp.pfnDlgProc = DlgProcClcMainOpts;
+ odp.flags = ODPF_BOLDGROUPS|ODPF_EXPERTONLY;
+ CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp);
+
+ if (!ServiceExists(MS_BACKGROUNDCONFIG_REGISTER)) {
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_CLCBKG);
+ odp.pszTitle = LPGEN("List Background");
+ odp.pfnDlgProc = DlgProcClcBkgOpts;
+ odp.flags = ODPF_BOLDGROUPS;
+ CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp);
+ }
+
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_META_CLC);
+ odp.pszTitle = LPGEN("List MetaContacts");
+ odp.pfnDlgProc = DlgProcClcMetaOpts;
+ CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp);
+
+ if (!ServiceExists(MS_BACKGROUNDCONFIG_REGISTER))
+ {
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_CLCBKG);
+ odp.pszTitle = LPGEN("StatusBar Background");
+ odp.pfnDlgProc = DlgProcStatusBarBkgOpts;
+ odp.flags = ODPF_BOLDGROUPS;
+ CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp);
+ }
+
+ return 0;
+}
+
+struct CheckBoxToStyleEx_t {
+ int id;
+ DWORD flag;
+ int not;
+} static const checkBoxToStyleEx[] = {
+ {IDC_DISABLEDRAGDROP,CLS_EX_DISABLEDRAGDROP,0},
+ {IDC_NOTEDITLABELS,CLS_EX_EDITLABELS,1},
+ {IDC_SHOWSELALWAYS,CLS_EX_SHOWSELALWAYS,0},
+ {IDC_TRACKSELECT,CLS_EX_TRACKSELECT,0},
+ {IDC_SHOWGROUPCOUNTS,CLS_EX_SHOWGROUPCOUNTS,0},
+ {IDC_HIDECOUNTSWHENEMPTY,CLS_EX_HIDECOUNTSWHENEMPTY,0},
+ {IDC_DIVIDERONOFF,CLS_EX_DIVIDERONOFF,0},
+ {IDC_NOTNOTRANSLUCENTSEL,CLS_EX_NOTRANSLUCENTSEL,1},
+ {IDC_LINEWITHGROUPS,CLS_EX_LINEWITHGROUPS,0},
+ {IDC_QUICKSEARCHVISONLY,CLS_EX_QUICKSEARCHVISONLY,0},
+ {IDC_SORTGROUPSALPHA,CLS_EX_SORTGROUPSALPHA,0},
+ {IDC_NOTNOSMOOTHSCROLLING,CLS_EX_NOSMOOTHSCROLLING,1}};
+
+struct CheckBoxValues_t {
+ DWORD style;
+ TCHAR *szDescr;
+};
+static const struct CheckBoxValues_t greyoutValues[] =
+{
+ {GREYF_UNFOCUS, _T("Not focused") },
+ {MODEF_OFFLINE, _T("Offline") },
+ {PF2_ONLINE, _T("Online") },
+ {PF2_SHORTAWAY, _T("Away") },
+ {PF2_LONGAWAY, _T("NA") },
+ {PF2_LIGHTDND, _T("Occupied") },
+ {PF2_HEAVYDND, _T("DND") },
+ {PF2_FREECHAT, _T("Free for chat") },
+ {PF2_INVISIBLE, _T("Invisible") },
+ {PF2_OUTTOLUNCH, _T("Out to lunch") },
+ {PF2_ONTHEPHONE, _T("On the phone") }
+};
+
+static const struct CheckBoxValues_t offlineValues[] =
+{
+ {MODEF_OFFLINE, _T("Offline") },
+ {PF2_ONLINE, _T("Online") },
+ {PF2_SHORTAWAY, _T("Away") },
+ {PF2_LONGAWAY, _T("NA") },
+ {PF2_LIGHTDND, _T("Occupied") },
+ {PF2_HEAVYDND, _T("DND") },
+ {PF2_FREECHAT, _T("Free for chat") },
+ {PF2_INVISIBLE, _T("Invisible") },
+ {PF2_OUTTOLUNCH, _T("Out to lunch") },
+ {PF2_ONTHEPHONE, _T("On the phone") }
+};
+
+static void FillCheckBoxTree(HWND hwndTree,const struct CheckBoxValues_t *values,int nValues,DWORD style)
+{
+ TVINSERTSTRUCT tvis;
+ int i;
+
+ tvis.hParent = NULL;
+ tvis.hInsertAfter = TVI_LAST;
+ tvis.item.mask = TVIF_PARAM|TVIF_TEXT|TVIF_STATE;
+ for (i = 0;i<nValues;i++) {
+ tvis.item.lParam = values[i].style;
+ tvis.item.pszText = TranslateTS(values[i].szDescr);
+ tvis.item.stateMask = TVIS_STATEIMAGEMASK;
+ tvis.item.state = INDEXTOSTATEIMAGEMASK((style&tvis.item.lParam) != 0?2:1);
+ TreeView_InsertItem(hwndTree,&tvis);
+ }
+}
+
+static DWORD MakeCheckBoxTreeFlags(HWND hwndTree)
+{
+ DWORD flags = 0;
+ TVITEM tvi;
+
+ tvi.mask = TVIF_HANDLE|TVIF_PARAM|TVIF_STATE;
+ tvi.hItem = TreeView_GetRoot(hwndTree);
+ while(tvi.hItem) {
+ TreeView_GetItem(hwndTree,&tvi);
+ if (((tvi.state&TVIS_STATEIMAGEMASK)>>12 == 2)) flags|=tvi.lParam;
+ tvi.hItem = TreeView_GetNextSibling(hwndTree,tvi.hItem);
+ }
+ return flags;
+}
+
+static INT_PTR CALLBACK DlgProcClcMetaOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ LPNMHDR t;
+ t = ((LPNMHDR)lParam);
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+
+ CheckDlgButton(hwndDlg, IDC_META, DBGetContactSettingByte(NULL,"CLC","Meta",0) ? BST_CHECKED : BST_UNCHECKED); /// by FYR
+ CheckDlgButton(hwndDlg, IDC_METADBLCLK, DBGetContactSettingByte(NULL,"CLC","MetaDoubleClick",0) ? BST_CHECKED : BST_UNCHECKED); /// by FYR
+ CheckDlgButton(hwndDlg, IDC_METASUBEXTRA, DBGetContactSettingByte(NULL,"CLC","MetaHideExtra",0) ? BST_CHECKED : BST_UNCHECKED); /// by FYR
+ CheckDlgButton(hwndDlg, IDC_METASUBEXTRA_IGN, DBGetContactSettingByte(NULL,"CLC","MetaIgnoreEmptyExtra",1) ? BST_CHECKED : BST_UNCHECKED); /// by FYR
+ CheckDlgButton(hwndDlg, IDC_METASUB_HIDEOFFLINE, DBGetContactSettingByte(NULL,"CLC","MetaHideOfflineSub",1) ? BST_CHECKED : BST_UNCHECKED); /// by FYR
+ return TRUE;
+ case WM_COMMAND:
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ return TRUE;
+ case WM_NOTIFY:
+
+ switch(t->idFrom)
+ {
+ case 0:
+ switch (t->code)
+ {
+ case PSN_APPLY:
+ DBWriteContactSettingByte(NULL,"CLC","Meta",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_META)); // by FYR
+ DBWriteContactSettingByte(NULL,"CLC","MetaDoubleClick",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_METADBLCLK)); // by FYR
+ DBWriteContactSettingByte(NULL,"CLC","MetaHideExtra",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_METASUBEXTRA)); // by FYR
+ DBWriteContactSettingByte(NULL,"CLC","MetaIgnoreEmptyExtra",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_METASUBEXTRA_IGN)); // by FYR
+ DBWriteContactSettingByte(NULL,"CLC","MetaHideOfflineSub",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_METASUB_HIDEOFFLINE)); // by FYR
+ pcli->pfnClcOptionsChanged();
+ return TRUE;
+ }
+ break;
+ }
+ break;
+ }
+ return FALSE;
+
+
+
+
+}
+
+static INT_PTR CALLBACK DlgProcClcMainOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_GREYOUTOPTS),GWL_STYLE,GetWindowLongPtr(GetDlgItem(hwndDlg,IDC_GREYOUTOPTS),GWL_STYLE)|TVS_NOHSCROLL|TVS_CHECKBOXES);
+ SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_HIDEOFFLINEOPTS),GWL_STYLE,GetWindowLongPtr(GetDlgItem(hwndDlg,IDC_HIDEOFFLINEOPTS),GWL_STYLE)|TVS_NOHSCROLL|TVS_CHECKBOXES);
+ { int i;
+ DWORD exStyle = DBGetContactSettingDword(NULL,"CLC","ExStyle",pcli->pfnGetDefaultExStyle());
+ for (i = 0;i < SIZEOF(checkBoxToStyleEx); i++)
+ CheckDlgButton(hwndDlg,checkBoxToStyleEx[i].id,(exStyle&checkBoxToStyleEx[i].flag)^(checkBoxToStyleEx[i].flag*checkBoxToStyleEx[i].not)?BST_CHECKED:BST_UNCHECKED);
+ }
+ { UDACCEL accel[2] = {{0,10},{2,50}};
+ SendDlgItemMessage(hwndDlg,IDC_SMOOTHTIMESPIN,UDM_SETRANGE,0,MAKELONG(999,0));
+ SendDlgItemMessage(hwndDlg,IDC_SMOOTHTIMESPIN,UDM_SETACCEL,SIZEOF(accel), (LPARAM)&accel );
+ SendDlgItemMessage(hwndDlg,IDC_SMOOTHTIMESPIN,UDM_SETPOS,0,MAKELONG(DBGetContactSettingWord(NULL,"CLC","ScrollTime",CLCDEFAULT_SCROLLTIME),0));
+ }
+ CheckDlgButton(hwndDlg,IDC_IDLE,DBGetContactSettingByte(NULL,"CLC","ShowIdle",CLCDEFAULT_SHOWIDLE)?BST_CHECKED:BST_UNCHECKED);
+
+ /* CheckDlgButton(hwndDlg, IDC_META, DBGetContactSettingByte(NULL,"CLC","Meta",0) ? BST_CHECKED : BST_UNCHECKED); /// by FYR
+ CheckDlgButton(hwndDlg, IDC_METADBLCLK, DBGetContactSettingByte(NULL,"CLC","MetaDoubleClick",0) ? BST_CHECKED : BST_UNCHECKED); /// by FYR
+ CheckDlgButton(hwndDlg, IDC_METASUBEXTRA, DBGetContactSettingByte(NULL,"CLC","MetaHideExtra",1) ? BST_CHECKED : BST_UNCHECKED); /// by FYR
+ */
+ SendDlgItemMessage(hwndDlg,IDC_LEFTMARGINSPIN,UDM_SETRANGE,0,MAKELONG(64,0));
+ SendDlgItemMessage(hwndDlg,IDC_LEFTMARGINSPIN,UDM_SETPOS,0,MAKELONG(DBGetContactSettingByte(NULL,"CLC","LeftMargin",CLCDEFAULT_LEFTMARGIN),0));
+ SendDlgItemMessage(hwndDlg,IDC_GROUPINDENTSPIN,UDM_SETRANGE,0,MAKELONG(50,0));
+ SendDlgItemMessage(hwndDlg,IDC_GROUPINDENTSPIN,UDM_SETPOS,0,MAKELONG(DBGetContactSettingByte(NULL,"CLC","GroupIndent",CLCDEFAULT_GROUPINDENT),0));
+ CheckDlgButton(hwndDlg,IDC_GREYOUT,DBGetContactSettingDword(NULL,"CLC","GreyoutFlags",CLCDEFAULT_GREYOUTFLAGS)?BST_CHECKED:BST_UNCHECKED);
+
+
+ EnableWindow(GetDlgItem(hwndDlg,IDC_SMOOTHTIME),IsDlgButtonChecked(hwndDlg,IDC_NOTNOSMOOTHSCROLLING));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_GREYOUTOPTS),IsDlgButtonChecked(hwndDlg,IDC_GREYOUT));
+ FillCheckBoxTree(GetDlgItem(hwndDlg,IDC_GREYOUTOPTS),greyoutValues,SIZEOF(greyoutValues),DBGetContactSettingDword(NULL,"CLC","FullGreyoutFlags",CLCDEFAULT_FULLGREYOUTFLAGS));
+ FillCheckBoxTree(GetDlgItem(hwndDlg,IDC_HIDEOFFLINEOPTS),offlineValues,SIZEOF(offlineValues),DBGetContactSettingDword(NULL,"CLC","OfflineModes",CLCDEFAULT_OFFLINEMODES));
+ CheckDlgButton(hwndDlg,IDC_NOSCROLLBAR,DBGetContactSettingByte(NULL,"CLC","NoVScrollBar",0)?BST_CHECKED:BST_UNCHECKED);
+ return TRUE;
+ case WM_VSCROLL:
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ case WM_COMMAND:
+ if (LOWORD(wParam) == IDC_NOTNOSMOOTHSCROLLING)
+ EnableWindow(GetDlgItem(hwndDlg,IDC_SMOOTHTIME),IsDlgButtonChecked(hwndDlg,IDC_NOTNOSMOOTHSCROLLING));
+ if (LOWORD(wParam) == IDC_GREYOUT)
+ EnableWindow(GetDlgItem(hwndDlg,IDC_GREYOUTOPTS),IsDlgButtonChecked(hwndDlg,IDC_GREYOUT));
+ if ((LOWORD(wParam) == IDC_LEFTMARGIN || LOWORD(wParam) == IDC_SMOOTHTIME || LOWORD(wParam) == IDC_GROUPINDENT) && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return 0;
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->idFrom) {
+ case IDC_GREYOUTOPTS:
+ case IDC_HIDEOFFLINEOPTS:
+ if (((LPNMHDR)lParam)->code == 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) {
+ TVITEM tvi;
+ tvi.mask = TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
+ tvi.hItem = hti.hItem;
+ TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom,&tvi);
+ tvi.iImage = tvi.iSelectedImage = tvi.iImage == 1?2:1;
+ TreeView_SetItem(((LPNMHDR)lParam)->hwndFrom,&tvi);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ }
+ break;
+ case 0:
+ switch (((LPNMHDR)lParam)->code)
+ {
+ case PSN_APPLY:
+ { int i;
+ DWORD exStyle = 0;
+ for (i = 0;i < SIZEOF(checkBoxToStyleEx);i++)
+ if ((IsDlgButtonChecked(hwndDlg,checkBoxToStyleEx[i].id) == 0) == checkBoxToStyleEx[i].not)
+ exStyle|=checkBoxToStyleEx[i].flag;
+ DBWriteContactSettingDword(NULL,"CLC","ExStyle",exStyle);
+ }
+ { DWORD fullGreyoutFlags = MakeCheckBoxTreeFlags(GetDlgItem(hwndDlg,IDC_GREYOUTOPTS));
+ DBWriteContactSettingDword(NULL,"CLC","FullGreyoutFlags",fullGreyoutFlags);
+ if (IsDlgButtonChecked(hwndDlg,IDC_GREYOUT))
+ DBWriteContactSettingDword(NULL,"CLC","GreyoutFlags",fullGreyoutFlags);
+ else
+ DBWriteContactSettingDword(NULL,"CLC","GreyoutFlags",0);
+ }
+ /* DBWriteContactSettingByte(NULL,"CLC","Meta",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_META)); // by FYR
+ DBWriteContactSettingByte(NULL,"CLC","MetaDoubleClick",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_METADBLCLK)); // by FYR
+ DBWriteContactSettingByte(NULL,"CLC","MetaHideExtra",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_METASUBEXTRA)); // by FYR
+
+ */
+ DBWriteContactSettingByte(NULL,"CLC","ShowIdle",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_IDLE)?1:0));
+ DBWriteContactSettingDword(NULL,"CLC","OfflineModes",MakeCheckBoxTreeFlags(GetDlgItem(hwndDlg,IDC_HIDEOFFLINEOPTS)));
+ DBWriteContactSettingByte(NULL,"CLC","LeftMargin",(BYTE)SendDlgItemMessage(hwndDlg,IDC_LEFTMARGINSPIN,UDM_GETPOS,0,0));
+ DBWriteContactSettingWord(NULL,"CLC","ScrollTime",(WORD)SendDlgItemMessage(hwndDlg,IDC_SMOOTHTIMESPIN,UDM_GETPOS,0,0));
+ DBWriteContactSettingByte(NULL,"CLC","GroupIndent",(BYTE)SendDlgItemMessage(hwndDlg,IDC_GROUPINDENTSPIN,UDM_GETPOS,0,0));
+ DBWriteContactSettingByte(NULL,"CLC","NoVScrollBar",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_NOSCROLLBAR)?1:0));
+
+
+ pcli->pfnClcOptionsChanged();
+ return TRUE;
+ }
+ break;
+ }
+ break;
+ case WM_DESTROY:
+ ImageList_Destroy(TreeView_GetImageList(GetDlgItem(hwndDlg,IDC_GREYOUTOPTS),TVSIL_NORMAL));
+ break;
+ }
+ return FALSE;
+}
+
+static INT_PTR CALLBACK DlgProcStatusBarBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ CheckDlgButton(hwndDlg,IDC_BITMAP,DBGetContactSettingByte(NULL,"StatusBar","UseBitmap",CLCDEFAULT_USEBITMAP)?BST_CHECKED:BST_UNCHECKED);
+ SendMessage(hwndDlg,WM_USER+10,0,0);
+ SendDlgItemMessage(hwndDlg,IDC_BKGCOLOUR,CPM_SETDEFAULTCOLOUR,0,CLCDEFAULT_BKCOLOUR);
+ SendDlgItemMessage(hwndDlg,IDC_BKGCOLOUR,CPM_SETCOLOUR,0,DBGetContactSettingDword(NULL,"StatusBar","BkColour",CLCDEFAULT_BKCOLOUR));
+ SendDlgItemMessage(hwndDlg,IDC_SELCOLOUR,CPM_SETDEFAULTCOLOUR,0,CLCDEFAULT_SELBKCOLOUR);
+ SendDlgItemMessage(hwndDlg,IDC_SELCOLOUR,CPM_SETCOLOUR,0,DBGetContactSettingDword(NULL,"StatusBar","SelBkColour",CLCDEFAULT_SELBKCOLOUR));
+ { DBVARIANT dbv;
+ if (!DBGetContactSettingString(NULL,"StatusBar","BkBitmap",&dbv)) {
+ SetDlgItemTextA(hwndDlg,IDC_FILENAME,dbv.pszVal);
+ if (ServiceExists(MS_UTILS_PATHTOABSOLUTE)) {
+ char szPath[MAX_PATH];
+
+ if (CallService(MS_UTILS_PATHTOABSOLUTE, (WPARAM)dbv.pszVal, (LPARAM)szPath))
+ SetDlgItemTextA(hwndDlg,IDC_FILENAME,szPath);
+ }
+ else
+ mir_free(dbv.pszVal);
+ }
+ }
+
+ { WORD bmpUse = DBGetContactSettingWord(NULL,"StatusBar","BkBmpUse",CLCDEFAULT_BKBMPUSE);
+ CheckDlgButton(hwndDlg,IDC_STRETCHH,bmpUse&CLB_STRETCHH?BST_CHECKED:BST_UNCHECKED);
+ CheckDlgButton(hwndDlg,IDC_STRETCHV,bmpUse&CLB_STRETCHV?BST_CHECKED:BST_UNCHECKED);
+ CheckDlgButton(hwndDlg,IDC_TILEH,bmpUse&CLBF_TILEH?BST_CHECKED:BST_UNCHECKED);
+ CheckDlgButton(hwndDlg,IDC_TILEV,bmpUse&CLBF_TILEV?BST_CHECKED:BST_UNCHECKED);
+ CheckDlgButton(hwndDlg,IDC_SCROLL,bmpUse&CLBF_SCROLL?BST_CHECKED:BST_UNCHECKED);
+ CheckDlgButton(hwndDlg,IDC_PROPORTIONAL,bmpUse&CLBF_PROPORTIONAL?BST_CHECKED:BST_UNCHECKED);
+ CheckDlgButton(hwndDlg,IDC_TILEVROWH,bmpUse&CLBF_TILEVTOROWHEIGHT?BST_CHECKED:BST_UNCHECKED);
+
+ }
+ { HRESULT (STDAPICALLTYPE *MySHAutoComplete)(HWND,DWORD);
+ MySHAutoComplete = (HRESULT (STDAPICALLTYPE*)(HWND,DWORD))GetProcAddress(GetModuleHandleA("shlwapi"),"SHAutoComplete");
+ if (MySHAutoComplete) MySHAutoComplete(GetDlgItem(hwndDlg,IDC_FILENAME),1);
+ }
+ return TRUE;
+
+ case WM_USER+10:
+ EnableWindow(GetDlgItem(hwndDlg,IDC_FILENAME),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_BROWSE),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_STRETCHH),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_STRETCHV),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_TILEH),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_TILEV),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_SCROLL),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_PROPORTIONAL),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_TILEVROWH),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ break;
+
+ case WM_COMMAND:
+ if (LOWORD(wParam) == IDC_BROWSE) {
+ char str[MAX_PATH];
+ OPENFILENAMEA ofn = {0};
+ char filter[512];
+
+ GetDlgItemTextA(hwndDlg,IDC_FILENAME,str,SIZEOF(str));
+ ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
+ ofn.hwndOwner = hwndDlg;
+ ofn.hInstance = NULL;
+ CallService(MS_UTILS_GETBITMAPFILTERSTRINGS,SIZEOF(filter),(LPARAM)filter);
+ ofn.lpstrFilter = filter;
+ ofn.lpstrFile = str;
+ ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
+ ofn.nMaxFile = SIZEOF(str);
+ ofn.nMaxFileTitle = MAX_PATH;
+ ofn.lpstrDefExt = "bmp";
+ if (!GetOpenFileNameA(&ofn)) break;
+ SetDlgItemTextA(hwndDlg,IDC_FILENAME,str);
+ }
+ else if (LOWORD(wParam) == IDC_FILENAME && HIWORD(wParam) != EN_CHANGE) break;
+ if (LOWORD(wParam) == IDC_BITMAP) SendMessage(hwndDlg,WM_USER+10,0,0);
+ if (LOWORD(wParam) == IDC_FILENAME && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return 0;
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_APPLY:
+ DBWriteContactSettingByte(NULL,"StatusBar","UseBitmap",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ { COLORREF col;
+ col = SendDlgItemMessage(hwndDlg,IDC_BKGCOLOUR,CPM_GETCOLOUR,0,0);
+ if (col == CLCDEFAULT_BKCOLOUR) DBDeleteContactSetting(NULL,"StatusBar","BkColour");
+ else DBWriteContactSettingDword(NULL,"StatusBar","BkColour",col);
+ col = SendDlgItemMessage(hwndDlg,IDC_SELCOLOUR,CPM_GETCOLOUR,0,0);
+ if (col == CLCDEFAULT_SELBKCOLOUR) DBDeleteContactSetting(NULL,"StatusBar","SelBkColour");
+ else DBWriteContactSettingDword(NULL,"StatusBar","SelBkColour",col);
+ }
+ {
+ char str[MAX_PATH],strrel[MAX_PATH];
+ GetDlgItemTextA(hwndDlg,IDC_FILENAME,str,SIZEOF(str));
+ if (ServiceExists(MS_UTILS_PATHTORELATIVE)) {
+ if (CallService(MS_UTILS_PATHTORELATIVE, (WPARAM)str, (LPARAM)strrel))
+ DBWriteContactSettingString(NULL,"StatusBar","BkBitmap",strrel);
+ else DBWriteContactSettingString(NULL,"StatusBar","BkBitmap",str);
+ }
+ else DBWriteContactSettingString(NULL,"StatusBar","BkBitmap",str);
+
+ }
+ { WORD flags = 0;
+ if (IsDlgButtonChecked(hwndDlg,IDC_STRETCHH)) flags|=CLB_STRETCHH;
+ if (IsDlgButtonChecked(hwndDlg,IDC_STRETCHV)) flags|=CLB_STRETCHV;
+ if (IsDlgButtonChecked(hwndDlg,IDC_TILEH)) flags|=CLBF_TILEH;
+ if (IsDlgButtonChecked(hwndDlg,IDC_TILEV)) flags|=CLBF_TILEV;
+ if (IsDlgButtonChecked(hwndDlg,IDC_SCROLL)) flags|=CLBF_SCROLL;
+ if (IsDlgButtonChecked(hwndDlg,IDC_PROPORTIONAL)) flags|=CLBF_PROPORTIONAL;
+ if (IsDlgButtonChecked(hwndDlg,IDC_TILEVROWH)) flags|=CLBF_TILEVTOROWHEIGHT;
+
+ DBWriteContactSettingWord(NULL,"StatusBar","BkBmpUse",flags);
+ }
+
+ pcli->pfnClcOptionsChanged();
+ OnStatusBarBackgroundChange();
+ return TRUE;
+ }
+ break;
+ }
+ break;
+ }
+ return FALSE;
+}
+
+static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ CheckDlgButton(hwndDlg,IDC_BITMAP,DBGetContactSettingByte(NULL,"CLC","UseBitmap",CLCDEFAULT_USEBITMAP)?BST_CHECKED:BST_UNCHECKED);
+ SendMessage(hwndDlg,WM_USER+10,0,0);
+ SendDlgItemMessage(hwndDlg,IDC_BKGCOLOUR,CPM_SETDEFAULTCOLOUR,0,CLCDEFAULT_BKCOLOUR);
+ SendDlgItemMessage(hwndDlg,IDC_BKGCOLOUR,CPM_SETCOLOUR,0,DBGetContactSettingDword(NULL,"CLC","BkColour",CLCDEFAULT_BKCOLOUR));
+ SendDlgItemMessage(hwndDlg,IDC_SELCOLOUR,CPM_SETDEFAULTCOLOUR,0,CLCDEFAULT_SELBKCOLOUR);
+ SendDlgItemMessage(hwndDlg,IDC_SELCOLOUR,CPM_SETCOLOUR,0,DBGetContactSettingDword(NULL,"CLC","SelBkColour",CLCDEFAULT_SELBKCOLOUR));
+ { DBVARIANT dbv;
+ if (!DBGetContactSettingString(NULL,"CLC","BkBitmap",&dbv)) {
+ SetDlgItemTextA(hwndDlg,IDC_FILENAME,dbv.pszVal);
+ if (ServiceExists(MS_UTILS_PATHTOABSOLUTE)) {
+ char szPath[MAX_PATH];
+
+ if (CallService(MS_UTILS_PATHTOABSOLUTE, (WPARAM)dbv.pszVal, (LPARAM)szPath))
+ SetDlgItemTextA(hwndDlg,IDC_FILENAME,szPath);
+ }
+ else mir_free(dbv.pszVal);
+ }
+ }
+
+ { WORD bmpUse = DBGetContactSettingWord(NULL,"CLC","BkBmpUse",CLCDEFAULT_BKBMPUSE);
+ CheckDlgButton(hwndDlg,IDC_STRETCHH,bmpUse&CLB_STRETCHH?BST_CHECKED:BST_UNCHECKED);
+ CheckDlgButton(hwndDlg,IDC_STRETCHV,bmpUse&CLB_STRETCHV?BST_CHECKED:BST_UNCHECKED);
+ CheckDlgButton(hwndDlg,IDC_TILEH,bmpUse&CLBF_TILEH?BST_CHECKED:BST_UNCHECKED);
+ CheckDlgButton(hwndDlg,IDC_TILEV,bmpUse&CLBF_TILEV?BST_CHECKED:BST_UNCHECKED);
+ CheckDlgButton(hwndDlg,IDC_SCROLL,bmpUse&CLBF_SCROLL?BST_CHECKED:BST_UNCHECKED);
+ CheckDlgButton(hwndDlg,IDC_PROPORTIONAL,bmpUse&CLBF_PROPORTIONAL?BST_CHECKED:BST_UNCHECKED);
+ CheckDlgButton(hwndDlg,IDC_TILEVROWH,bmpUse&CLBF_TILEVTOROWHEIGHT?BST_CHECKED:BST_UNCHECKED);
+
+ }
+ { HRESULT (STDAPICALLTYPE *MySHAutoComplete)(HWND,DWORD);
+ MySHAutoComplete = (HRESULT (STDAPICALLTYPE*)(HWND,DWORD))GetProcAddress(GetModuleHandleA("shlwapi"),"SHAutoComplete");
+ if (MySHAutoComplete) MySHAutoComplete(GetDlgItem(hwndDlg,IDC_FILENAME),1);
+ }
+ return TRUE;
+ case WM_USER+10:
+ EnableWindow(GetDlgItem(hwndDlg,IDC_FILENAME),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_BROWSE),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_STRETCHH),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_STRETCHV),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_TILEH),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_TILEV),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_SCROLL),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_PROPORTIONAL),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_TILEVROWH),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ break;
+ case WM_COMMAND:
+ if (LOWORD(wParam) == IDC_BROWSE) {
+ char str[MAX_PATH];
+ OPENFILENAMEA ofn = {0};
+ char filter[512];
+
+ GetDlgItemTextA(hwndDlg,IDC_FILENAME,str,SIZEOF(str));
+ ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
+ ofn.hwndOwner = hwndDlg;
+ ofn.hInstance = NULL;
+ CallService(MS_UTILS_GETBITMAPFILTERSTRINGS,SIZEOF(filter),(LPARAM)filter);
+ ofn.lpstrFilter = filter;
+ ofn.lpstrFile = str;
+ ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
+ ofn.nMaxFile = SIZEOF(str);
+ ofn.nMaxFileTitle = MAX_PATH;
+ ofn.lpstrDefExt = "bmp";
+ if (!GetOpenFileNameA(&ofn)) break;
+ SetDlgItemTextA(hwndDlg,IDC_FILENAME,str);
+ }
+ else if (LOWORD(wParam) == IDC_FILENAME && HIWORD(wParam) != EN_CHANGE) break;
+ if (LOWORD(wParam) == IDC_BITMAP) SendMessage(hwndDlg,WM_USER+10,0,0);
+ if (LOWORD(wParam) == IDC_FILENAME && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return 0;
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_APPLY:
+ DBWriteContactSettingByte(NULL,"CLC","UseBitmap",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ { COLORREF col;
+ col = SendDlgItemMessage(hwndDlg,IDC_BKGCOLOUR,CPM_GETCOLOUR,0,0);
+ if (col == CLCDEFAULT_BKCOLOUR) DBDeleteContactSetting(NULL,"CLC","BkColour");
+ else DBWriteContactSettingDword(NULL,"CLC","BkColour",col);
+ col = SendDlgItemMessage(hwndDlg,IDC_SELCOLOUR,CPM_GETCOLOUR,0,0);
+ if (col == CLCDEFAULT_SELBKCOLOUR) DBDeleteContactSetting(NULL,"CLC","SelBkColour");
+ else DBWriteContactSettingDword(NULL,"CLC","SelBkColour",col);
+ }
+ {
+ char str[MAX_PATH],strrel[MAX_PATH];
+ GetDlgItemTextA(hwndDlg,IDC_FILENAME,str,SIZEOF(str));
+ if (ServiceExists(MS_UTILS_PATHTORELATIVE)) {
+ if (CallService(MS_UTILS_PATHTORELATIVE, (WPARAM)str, (LPARAM)strrel))
+ DBWriteContactSettingString(NULL,"CLC","BkBitmap",strrel);
+ else DBWriteContactSettingString(NULL,"CLC","BkBitmap",str);
+ }
+ else DBWriteContactSettingString(NULL,"CLC","BkBitmap",str);
+ }
+ { WORD flags = 0;
+ if (IsDlgButtonChecked(hwndDlg,IDC_STRETCHH)) flags|=CLB_STRETCHH;
+ if (IsDlgButtonChecked(hwndDlg,IDC_STRETCHV)) flags|=CLB_STRETCHV;
+ if (IsDlgButtonChecked(hwndDlg,IDC_TILEH)) flags|=CLBF_TILEH;
+ if (IsDlgButtonChecked(hwndDlg,IDC_TILEV)) flags|=CLBF_TILEV;
+ if (IsDlgButtonChecked(hwndDlg,IDC_SCROLL)) flags|=CLBF_SCROLL;
+ if (IsDlgButtonChecked(hwndDlg,IDC_PROPORTIONAL)) flags|=CLBF_PROPORTIONAL;
+ if (IsDlgButtonChecked(hwndDlg,IDC_TILEVROWH)) flags|=CLBF_TILEVTOROWHEIGHT;
+
+ DBWriteContactSettingWord(NULL,"CLC","BkBmpUse",flags);
+ }
+
+ pcli->pfnClcOptionsChanged();
+ return TRUE;
+ }
+ break;
+ }
+ break;
+ }
+ return FALSE;
+}
+
diff --git a/plugins/Mwclist/clcpaint.c b/plugins/Mwclist/clcpaint.c
deleted file mode 100644
index db10a510dd..0000000000
--- a/plugins/Mwclist/clcpaint.c
+++ /dev/null
@@ -1,748 +0,0 @@
-/*
-
-Miranda IM: the free IM client for Microsoft* Windows*
-
-Copyright 2000-2003 Miranda ICQ/IM project,
-all portions of this codebase are copyrighted to the people
-listed in contributors.txt.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-#include "commonheaders.h"
-#include "m_clc.h"
-#include "clc.h"
-//#include <gdiplus.h>
-
-extern HIMAGELIST himlCListClc;
-static BYTE divide3[765]={255};
-int MetaIgnoreEmptyExtra;
-
-static void ChangeToFont(HDC hdc,struct ClcData *dat,int id,int *fontHeight)
-{
- SelectObject(hdc,dat->fontInfo[id].hFont);
- SetTextColor(hdc,dat->fontInfo[id].colour);
- if(fontHeight) *fontHeight=dat->fontInfo[id].fontHeight;
-}
-
-static void __inline SetHotTrackColour(HDC hdc,struct ClcData *dat)
-{
- if(dat->gammaCorrection) {
- COLORREF oldCol,newCol;
- int oldLum,newLum;
-
- oldCol=GetTextColor(hdc);
- oldLum=(GetRValue(oldCol)*30+GetGValue(oldCol)*59+GetBValue(oldCol)*11)/100;
- newLum=(GetRValue(dat->hotTextColour)*30+GetGValue(dat->hotTextColour)*59+GetBValue(dat->hotTextColour)*11)/100;
- if(newLum==0) {
- SetTextColor(hdc,dat->hotTextColour);
- return;
- }
- if(newLum>=oldLum+20) {
- oldLum+=20;
- newCol=RGB(GetRValue(dat->hotTextColour)*oldLum/newLum,GetGValue(dat->hotTextColour)*oldLum/newLum,GetBValue(dat->hotTextColour)*oldLum/newLum);
- }
- else if(newLum<=oldLum) {
- int r,g,b;
- r=GetRValue(dat->hotTextColour)*oldLum/newLum;
- g=GetGValue(dat->hotTextColour)*oldLum/newLum;
- b=GetBValue(dat->hotTextColour)*oldLum/newLum;
- if(r>255) {
- g+=(r-255)*3/7;
- b+=(r-255)*3/7;
- r=255;
- }
- if(g>255) {
- r+=(g-255)*59/41;
- if(r>255) r=255;
- b+=(g-255)*59/41;
- g=255;
- }
- if(b>255) {
- r+=(b-255)*11/89;
- if(r>255) r=255;
- g+=(b-255)*11/89;
- if(g>255) g=255;
- b=255;
- }
- newCol=RGB(r,g,b);
- }
- else newCol=dat->hotTextColour;
- SetTextColor(hdc,newCol);
- }
- else
- SetTextColor(hdc,dat->hotTextColour);
-}
-
-static int GetStatusOnlineness(int status)
-{
- switch(status) {
- case ID_STATUS_FREECHAT: return 110;
- case ID_STATUS_ONLINE: return 100;
- case ID_STATUS_OCCUPIED: return 60;
- case ID_STATUS_ONTHEPHONE: return 50;
- case ID_STATUS_DND: return 40;
- case ID_STATUS_AWAY: return 30;
- case ID_STATUS_OUTTOLUNCH: return 20;
- case ID_STATUS_NA: return 10;
- case ID_STATUS_INVISIBLE: return 5;
- }
- return 0;
-}
-
-static int GetGeneralisedStatus(void)
-{
- int i,status,thisStatus,statusOnlineness,thisOnlineness;
-
- status=ID_STATUS_OFFLINE;
- statusOnlineness=0;
-
- for (i=0;i<pcli->hClcProtoCount;i++) {
- thisStatus = pcli->clcProto[i].dwStatus;
- if(thisStatus==ID_STATUS_INVISIBLE) return ID_STATUS_INVISIBLE;
- thisOnlineness=GetStatusOnlineness(thisStatus);
- if(thisOnlineness>statusOnlineness) {
- status=thisStatus;
- statusOnlineness=thisOnlineness;
- }
- }
- return status;
-}
-
-static int GetRealStatus(struct ClcContact * contact, int status)
-{
- int i;
- char *szProto=contact->proto;
- if (!szProto) return status;
- for (i=0;i<pcli->hClcProtoCount;i++) {
- if (!lstrcmpA(pcli->clcProto[i].szProto,szProto)) {
- return pcli->clcProto[i].dwStatus;
- }
- }
- return status;
-}
-
-static HMODULE themeAPIHandle = NULL; // handle to uxtheme.dll
-static HANDLE (WINAPI *MyOpenThemeData)(HWND,LPCWSTR);
-static HRESULT (WINAPI *MyCloseThemeData)(HANDLE);
-static HRESULT (WINAPI *MyDrawThemeBackground)(HANDLE,HDC,int,int,const RECT *,const RECT *);
-
-#define MGPROC(x) GetProcAddress(themeAPIHandle,x)
-void InternalPaintClc(HWND hwnd,struct ClcData *dat,HDC hdc,RECT *rcPaint)
-{
- HDC hdcMem;
- HBITMAP oldbmp;
- HBITMAP oldbm;
- HFONT oldfont;
- RECT clRect;
- int y,indent,index,fontHeight, subindex, subident;
- struct ClcContact *Drawing;
- struct ClcGroup *group;
- HBITMAP hBmpOsb;
- DWORD style=GetWindowLongPtr(hwnd,GWL_STYLE);
- int status=GetGeneralisedStatus();
- int grey=0,groupCountsFontTopShift;
- HBRUSH hBrushAlternateGrey=NULL;
- POINT pt;
- RECT testrc;
-
-
- // yes I know about GetSysColorBrush()
- COLORREF tmpbkcolour = style&CLS_CONTACTLIST ? ( /*dat->useWindowsColours ? GetSysColor(COLOR_3DFACE) :*/ dat->bkColour ) : dat->bkColour;
-//
-
-
- if(dat->greyoutFlags & pcli->pfnClcStatusToPf2(status) || style&WS_DISABLED) grey=1;
- else if(GetFocus()!=hwnd && dat->greyoutFlags&GREYF_UNFOCUS) grey=1;
- GetClientRect(hwnd,&clRect);
-
- if(rcPaint==NULL) rcPaint=&clRect;
- //rcPaint=&clRect;
-
- if(IsRectEmpty(rcPaint)) return;
- GetCursorPos(&pt);
- ScreenToClient(hwnd,&pt);
-
-
- y=-dat->yScroll;
- hdcMem=CreateCompatibleDC(hdc);
- hBmpOsb=CreateBitmap(clRect.right,clRect.bottom,1,GetDeviceCaps(hdc,BITSPIXEL),NULL);
- oldbmp=(HBITMAP)SelectObject(hdcMem,hBmpOsb);
- { TEXTMETRIC tm;
-
-
- oldfont=SelectObject(hdcMem,dat->fontInfo[FONTID_GROUPS].hFont);
-
- GetTextMetrics(hdcMem,&tm);
- groupCountsFontTopShift=tm.tmAscent;
- SelectObject(hdcMem,dat->fontInfo[FONTID_GROUPCOUNTS].hFont);
- GetTextMetrics(hdcMem,&tm);
- groupCountsFontTopShift-=tm.tmAscent;
- SelectObject(hdcMem,oldfont);
- }
- if(style&CLS_GREYALTERNATE)
- hBrushAlternateGrey=CreateSolidBrush(GetNearestColor(hdcMem,RGB(GetRValue(tmpbkcolour)-10,GetGValue(tmpbkcolour)-10,GetBValue(tmpbkcolour)-10)));
- ChangeToFont(hdcMem,dat,FONTID_CONTACTS,&fontHeight);
- SetBkMode(hdcMem,TRANSPARENT);
- { HBRUSH hBrush,hoBrush;
-
- hBrush=CreateSolidBrush(tmpbkcolour);
- hoBrush=(HBRUSH)SelectObject(hdcMem,hBrush);
- FillRect(hdcMem,rcPaint,hBrush);
- SelectObject(hdcMem,hoBrush);
- DeleteObject(hBrush);
- if(dat->hBmpBackground) {
- BITMAP bmp;
- HDC hdcBmp;
- int x,y;
- int maxx,maxy;
- int destw,desth;
-
- // XXX: Halftone isnt supported on 9x, however the scretch problems dont happen on 98.
- SetStretchBltMode(hdcMem, HALFTONE);
-
-
- GetObject(dat->hBmpBackground,sizeof(bmp),&bmp);
- hdcBmp=CreateCompatibleDC(hdcMem);
- oldbm=SelectObject(hdcBmp,dat->hBmpBackground);
- y=dat->backgroundBmpUse&CLBF_SCROLL?-dat->yScroll:0;
- maxx=dat->backgroundBmpUse&CLBF_TILEH?clRect.right:1;
- maxy=dat->backgroundBmpUse&CLBF_TILEV?maxy=rcPaint->bottom:y+1;
- switch(dat->backgroundBmpUse&CLBM_TYPE) {
- case CLB_STRETCH:
- if(dat->backgroundBmpUse&CLBF_PROPORTIONAL) {
- if(clRect.right*bmp.bmHeight<clRect.bottom*bmp.bmWidth) {
- desth=clRect.bottom;
- destw=desth*bmp.bmWidth/bmp.bmHeight;
- }
- else {
- destw=clRect.right;
- desth=destw*bmp.bmHeight/bmp.bmWidth;
- }
- }
- else {
- destw=clRect.right;
- desth=clRect.bottom;
- }
- break;
- case CLB_STRETCHH:
- if(dat->backgroundBmpUse&CLBF_PROPORTIONAL) {
- destw=clRect.right;
- desth=destw*bmp.bmHeight/bmp.bmWidth;
- }
- else {
- destw=clRect.right;
- desth=bmp.bmHeight;
- if (dat->backgroundBmpUse&CLBF_TILEVTOROWHEIGHT)
- {
- desth=dat->rowHeight;
- }
-
- }
- break;
- case CLB_STRETCHV:
- if(dat->backgroundBmpUse&CLBF_PROPORTIONAL) {
- desth=clRect.bottom;
- destw=desth*bmp.bmWidth/bmp.bmHeight;
- }
- else {
- destw=bmp.bmWidth;
- desth=clRect.bottom;
- }
- break;
- default: //clb_topleft
- destw=bmp.bmWidth;
- desth=bmp.bmHeight;
- if (dat->backgroundBmpUse&CLBF_TILEVTOROWHEIGHT)
- {
- desth=dat->rowHeight;
- }
- break;
- }
- for (;y<maxy;y+=desth) {
- if(y<rcPaint->top-desth) continue;
- for(x=0;x<maxx;x+=destw)
- StretchBlt(hdcMem,x,y,destw,desth,hdcBmp,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
- }
- SelectObject(hdcBmp,oldbm);
- DeleteDC(hdcBmp);
- }
- }
- group=&dat->list;
- group->scanIndex=0;
- indent=0;
- subindex=-1;
- for(index=0;y<rcPaint->bottom;)
- {
- if (subindex==-1)
- if (group->scanIndex==group->cl.count)
- {
- group=group->parent;
- indent--;
- if(group==NULL) break;
- group->scanIndex++;
- continue;
- }
- //if(group==NULL) break;
- if(y>rcPaint->top-dat->rowHeight )
- {
-
-
- int iImage=-1;
- int selected;
- int hottrack;
- SIZE textSize,countsSize,spaceSize;
- int width,checkboxWidth;
- char *szCounts;
-
- if (subindex==-1)
- {
- Drawing=group->cl.items[group->scanIndex];
- subident=0;
- }
- else
- {
- Drawing=&(group->cl.items[group->scanIndex]->subcontacts[subindex]);
- subident=dat->rowHeight/2;
- }
- //alternating grey
-
- selected=index==dat->selection && (dat->showSelAlways || dat->exStyle&CLS_EX_SHOWSELALWAYS || GetFocus()==hwnd) && Drawing->type!=CLCIT_DIVIDER;
- hottrack=dat->exStyle&CLS_EX_TRACKSELECT && Drawing->type!=CLCIT_DIVIDER && dat->iHotTrack==index;
-
- if(style&CLS_GREYALTERNATE && index&1) {
- RECT rc;
- rc.top=y; rc.bottom=rc.top+dat->rowHeight;
- rc.left=0; rc.right=clRect.right;
- FillRect(hdcMem,&rc,hBrushAlternateGrey);
- }
-
- //setup
- if(Drawing->type==CLCIT_GROUP)
- {
- if (Drawing->group->expanded)
- {
- ChangeToFont(hdcMem,dat,FONTID_GROUPS,&fontHeight);
- }
- else
- {
- ChangeToFont(hdcMem,dat,FONTID_GROUPSCLOSED,&fontHeight);
- }
- }
- else if(Drawing->type==CLCIT_INFO) {
- if(Drawing->flags&CLCIIF_GROUPFONT) ChangeToFont(hdcMem,dat,FONTID_GROUPS,&fontHeight);
- else ChangeToFont(hdcMem,dat,FONTID_CONTACTS,&fontHeight);
- }
- else if(Drawing->type==CLCIT_DIVIDER)
- ChangeToFont(hdcMem,dat,FONTID_DIVIDERS,&fontHeight);
- else if(Drawing->type==CLCIT_CONTACT && (Drawing->flags&CONTACTF_NOTONLIST) && (!Drawing->isSubcontact) )
- ChangeToFont(hdcMem,dat,FONTID_NOTONLIST,&fontHeight);
- else if ( Drawing->type==CLCIT_CONTACT &&
- (
- (Drawing->flags&CONTACTF_INVISTO && (!Drawing->isSubcontact) && GetRealStatus(group->cl.items[group->scanIndex], status) != ID_STATUS_INVISIBLE )
- ||
- (Drawing->flags&CONTACTF_VISTO && (!Drawing->isSubcontact) && GetRealStatus(group->cl.items[group->scanIndex], status)==ID_STATUS_INVISIBLE)
- )
- )
- {
- // the contact is in the always visible list and the proto is invisible
- // the contact is in the always invisible and the proto is in any other mode
- ChangeToFont(hdcMem,dat, Drawing->flags&CONTACTF_ONLINE ? FONTID_INVIS:FONTID_OFFINVIS ,&fontHeight);
- }
- else if(Drawing->type==CLCIT_CONTACT && (!(Drawing->flags&CONTACTF_ONLINE) && (!Drawing->isSubcontact)))
- ChangeToFont(hdcMem,dat,FONTID_OFFLINE,&fontHeight);
- else
- ChangeToFont(hdcMem,dat,FONTID_CONTACTS,&fontHeight);
- GetTextExtentPoint32(hdcMem,Drawing->szText,lstrlen(Drawing->szText),&textSize);
- width=textSize.cx;
- if(Drawing->type==CLCIT_GROUP) {
-
- szCounts = pcli->pfnGetGroupCountsText(dat,group->cl.items[group->scanIndex]);
- if(szCounts[0]) {
- GetTextExtentPoint32A(hdcMem," ",1,&spaceSize);
- ChangeToFont(hdcMem,dat,FONTID_GROUPCOUNTS,&fontHeight);
- GetTextExtentPoint32A(hdcMem,szCounts,lstrlenA(szCounts),&countsSize);
- width+=spaceSize.cx+countsSize.cx;
- }
- }
-
- if ((style&CLS_CHECKBOXES && Drawing->type==CLCIT_CONTACT) ||
- (style&CLS_GROUPCHECKBOXES && Drawing->type==CLCIT_GROUP) ||
- (Drawing->type==CLCIT_INFO && Drawing->flags&CLCIIF_CHECKBOX))
- checkboxWidth=dat->checkboxSize+2;
- else checkboxWidth=0;
-
- //background
- if(selected) {
- switch (dat->HiLightMode)
- {
- case 0:
- {
- int x=dat->leftMargin+indent*dat->groupIndent+checkboxWidth+dat->iconXSpace-2+subident;
- ImageList_DrawEx(dat->himlHighlight,0,hdcMem,x,y,min(width+5,clRect.right-x),dat->rowHeight,CLR_NONE,CLR_NONE,dat->exStyle&CLS_EX_NOTRANSLUCENTSEL?ILD_NORMAL:ILD_BLEND25);
- SetTextColor(hdcMem,dat->selTextColour);
- break;
- }
- case 1:
- {
- ImageList_DrawEx(dat->himlHighlight,0,hdcMem,0,y,clRect.right,
- dat->rowHeight,CLR_NONE,CLR_NONE,
- dat->exStyle&CLS_EX_NOTRANSLUCENTSEL?ILD_NORMAL:ILD_BLEND25);
- SetTextColor(hdcMem,dat->selTextColour);
- break;
- }
-
- case 2:
- {
- ImageList_DrawEx(dat->himlHighlight,0,hdcMem,1,y+1,clRect.right-2,
- dat->rowHeight-1,CLR_NONE,CLR_NONE,
- dat->exStyle&CLS_EX_NOTRANSLUCENTSEL?ILD_NORMAL:ILD_BLEND25);
- SetTextColor(hdcMem,dat->selTextColour);
- break;
- }
- case 3:
- {
- SetTextColor(hdcMem,dat->selTextColour);
- break;
- }
- }
- }
- else if(hottrack)
- SetHotTrackColour(hdcMem,dat);
-
- //checkboxes
- if(checkboxWidth && (subindex==-1 ||1)) {
- RECT rc;
- HANDLE hTheme = NULL;
-
- // THEME
- if (IsWinVerXPPlus()) {
- if (!themeAPIHandle) {
- themeAPIHandle = GetModuleHandleA("uxtheme");
- if (themeAPIHandle) {
- MyOpenThemeData = (HANDLE (WINAPI *)(HWND,LPCWSTR))MGPROC("OpenThemeData");
- MyCloseThemeData = (HRESULT (WINAPI *)(HANDLE))MGPROC("CloseThemeData");
- MyDrawThemeBackground = (HRESULT (WINAPI *)(HANDLE,HDC,int,int,const RECT *,const RECT *))MGPROC("DrawThemeBackground");
- }
- }
- // Make sure all of these methods are valid (i would hope either all or none work)
- if (MyOpenThemeData
- &&MyCloseThemeData
- &&MyDrawThemeBackground) {
- hTheme = MyOpenThemeData(hwnd,L"BUTTON");
- }
- }
- rc.left=dat->leftMargin+indent*dat->groupIndent+subident;
- rc.right=rc.left+dat->checkboxSize;
- rc.top=y+((dat->rowHeight-dat->checkboxSize)>>1);
- rc.bottom=rc.top+dat->checkboxSize;
- if (hTheme) {
- MyDrawThemeBackground(hTheme, hdcMem, BP_CHECKBOX, Drawing->flags&CONTACTF_CHECKED?(hottrack?CBS_CHECKEDHOT:CBS_CHECKEDNORMAL):(hottrack?CBS_UNCHECKEDHOT:CBS_UNCHECKEDNORMAL), &rc, &rc);
- }
- else DrawFrameControl(hdcMem,&rc,DFC_BUTTON,DFCS_BUTTONCHECK|DFCS_FLAT|(Drawing->flags&CONTACTF_CHECKED?DFCS_CHECKED:0)|(hottrack?DFCS_HOT:0));
- if (hTheme&&MyCloseThemeData) {
- MyCloseThemeData(hTheme);
- hTheme = NULL;
- }
- }
-
- //icon
- if(Drawing->type==CLCIT_GROUP)
- iImage=Drawing->group->expanded?IMAGE_GROUPOPEN:IMAGE_GROUPSHUT;
- else if(Drawing->type==CLCIT_CONTACT)
- iImage=Drawing->iImage;
- if(iImage!=-1) {
- /*COLORREF colourFg=dat->selBkColour;
- int mode=ILD_NORMAL;
- if(selected) mode=ILD_SELECTED;
- else if(hottrack) {mode=ILD_FOCUS; colourFg=dat->hotTextColour;}
- else if(Drawing->type==CLCIT_CONTACT && Drawing->flags&CONTACTF_NOTONLIST) {colourFg=dat->fontInfo[FONTID_NOTONLIST].colour; mode=ILD_BLEND50;}
- ImageList_DrawEx(himlCListClc,iImage,hdcMem,dat->leftMargin+indent*dat->groupIndent+checkboxWidth,y+((dat->rowHeight-16)>>1),0,0,CLR_NONE,colourFg,mode);
- */
- COLORREF colourFg=dat->selBkColour;
- int mode=ILD_NORMAL;
- if(hottrack) {colourFg=dat->hotTextColour;}
- else if(Drawing->type==CLCIT_CONTACT && Drawing->flags&CONTACTF_NOTONLIST && (!Drawing->isSubcontact)) {colourFg=dat->fontInfo[FONTID_NOTONLIST].colour; mode=ILD_BLEND50;}
- if (Drawing->type==CLCIT_CONTACT && dat->showIdle && (Drawing->flags&CONTACTF_IDLE)&& (!Drawing->isSubcontact) && GetRealStatus(group->cl.items[group->scanIndex],ID_STATUS_OFFLINE)!=ID_STATUS_OFFLINE)
- mode=ILD_SELECTED;
- ImageList_DrawEx(himlCListClc,iImage,hdcMem,dat->leftMargin+subident+indent*dat->groupIndent+checkboxWidth,y+((dat->rowHeight-16)>>1),0,0,CLR_NONE,colourFg,mode);
- }
-
- //text
- if(Drawing->type==CLCIT_DIVIDER) {
- RECT rc;
- rc.top=y+(dat->rowHeight>>1); rc.bottom=rc.top+2;
- rc.left=dat->leftMargin+indent*dat->groupIndent;
- rc.right=rc.left+((clRect.right-rc.left-textSize.cx)>>1)-3;
- DrawEdge(hdcMem,&rc,BDR_SUNKENOUTER,BF_RECT);
- TextOut(hdcMem,rc.right+3,y+((dat->rowHeight-fontHeight)>>1),Drawing->szText,lstrlen(Drawing->szText));
- rc.left=rc.right+6+textSize.cx;
- rc.right=clRect.right;
- DrawEdge(hdcMem,&rc,BDR_SUNKENOUTER,BF_RECT);
- }
- else if(Drawing->type==CLCIT_GROUP) {
- RECT rc;
- if(szCounts[0]) {
- struct ClcGroup *clcg;
-
- clcg=(struct ClcGroup *)Drawing;
-
- fontHeight=dat->fontInfo[FONTID_GROUPS].fontHeight;
-
- rc.left=dat->leftMargin+indent*dat->groupIndent+checkboxWidth+dat->iconXSpace;
- rc.right=min(clRect.right-countsSize.cx,rc.left+textSize.cx+spaceSize.cx);
- rc.top=y+((dat->rowHeight-fontHeight)>>1);
- rc.bottom=rc.top+textSize.cy;
- if(rc.right<rc.left+4) rc.right=clRect.right+1;
- else TextOutA(hdcMem,rc.right,rc.top+groupCountsFontTopShift,szCounts,lstrlenA(szCounts));
-
- //ChangeToFont(hdcMem,dat,FONTID_GROUPS,&fontHeight);
- if (Drawing->group->expanded)
- {
- ChangeToFont(hdcMem,dat,FONTID_GROUPS,&fontHeight);
- }
- else
- {
- ChangeToFont(hdcMem,dat,FONTID_GROUPSCLOSED,&fontHeight);
- }
-
- if(selected)
- SetTextColor(hdcMem,dat->selTextColour);
- else if(hottrack)
- SetHotTrackColour(hdcMem,dat);
- rc.right--;
- ExtTextOut(hdcMem,rc.left,rc.top,ETO_CLIPPED,&rc,Drawing->szText,lstrlen(Drawing->szText),NULL);
- }
- else TextOut(hdcMem,dat->leftMargin+indent*dat->groupIndent+checkboxWidth+dat->iconXSpace,y+((dat->rowHeight-fontHeight)>>1),Drawing->szText,lstrlen(Drawing->szText));
- if(dat->exStyle&CLS_EX_LINEWITHGROUPS) {
- //calc if extra icons present
- int enabledextraicons=0;
- for(iImage=0;iImage<dat->extraColumnsCount;iImage++) {
- if(Drawing->iExtraImage[iImage]==0xFF) continue;
- enabledextraicons++;
- }
- rc.top=y+(dat->rowHeight>>1); rc.bottom=rc.top+2;
- rc.left=dat->leftMargin+subident+indent*dat->groupIndent+checkboxWidth+dat->iconXSpace+width+3;
- rc.right=clRect.right-1-dat->extraColumnSpacing*enabledextraicons;
- if(rc.right-rc.left>1) DrawEdge(hdcMem,&rc,BDR_SUNKENOUTER,BF_RECT);
- }
- }
- else
- {
- RECT rc;
- rc.left=dat->leftMargin+subident+indent*dat->groupIndent+checkboxWidth+dat->iconXSpace;
- rc.top=y+((dat->rowHeight-fontHeight)>>1);
- rc.bottom=rc.top+dat->rowHeight;
- rc.right=clRect.right;
- if (Drawing->type=CLCIT_CONTACT)
- {
- if (hottrack/*PtInRect(&rc,pt)*/)
- {
- ChangeToFont(hdcMem,dat,FONTID_CONTACTSHOVER,&fontHeight);
- }
- }
-
- DrawText(hdcMem,Drawing->szText,lstrlen(Drawing->szText),&rc,DT_END_ELLIPSIS);
-
- }
- if(selected) {
- if(Drawing->type!=CLCIT_DIVIDER) {
- SetTextColor(hdcMem,dat->quickSearchColour);
- TextOut(hdcMem,dat->leftMargin+subident+indent*dat->groupIndent+checkboxWidth+dat->iconXSpace,y+((dat->rowHeight-fontHeight)>>1),Drawing->szText,lstrlen(dat->szQuickSearch));
- }
- }
-
- if (dat->style&CLS_SHOWSTATUSMESSAGES)
- {
- // status message
- if (group->cl.items[group->scanIndex]->type==CLCIT_CONTACT && group->cl.items[group->scanIndex]->flags & CONTACTF_STATUSMSG) {
- TCHAR * szText = group->cl.items[group->scanIndex]->szStatusMsg;
- RECT rc;
- rc.left=dat->leftMargin+indent*dat->groupIndent+checkboxWidth+dat->iconXSpace;
- rc.top=y+dat->rowHeight+((dat->rowHeight-fontHeight)>>1);
- rc.right=(clRect.right - clRect.left);
- rc.bottom=rc.top+dat->rowHeight;
- ChangeToFont(hdcMem,dat,FONTID_STATUSMSG,&fontHeight);
- //ExtTextOut(hdcMem,rc.left,rc.top,ETO_CLIPPED,&rc,szText,lstrlen(szText),NULL);
- DrawText(hdcMem, szText, lstrlen(szText), &rc, DT_SINGLELINE | DT_EDITCONTROL | DT_NOPREFIX | DT_NOCLIP | DT_WORD_ELLIPSIS);
- }
- }
-
- if (!Drawing->isSubcontact || (DBGetContactSettingByte(NULL,"CLC","MetaHideExtra",0)==0))
- {
-
- //extra icons
- if (!(style&CLS_EX_MULTICOLUMNALIGNLEFT))
- {
- int c=dat->extraColumnsCount;
- for(iImage=dat->extraColumnsCount-1;iImage>=0;iImage--) {
- COLORREF colourFg=dat->selBkColour;
- int mode=ILD_NORMAL;
-
- if(Drawing->iExtraImage[iImage]==0xFF) continue;
- if(selected) mode=ILD_SELECTED;
- else if(hottrack) {mode=ILD_FOCUS; colourFg=dat->hotTextColour;}
- else if(Drawing->type==CLCIT_CONTACT && Drawing->flags&CONTACTF_NOTONLIST) {colourFg=dat->fontInfo[FONTID_NOTONLIST].colour; mode=ILD_BLEND50;}
- {
-
- }
- if (dat->MetaIgnoreEmptyExtra) c--; else c=iImage;
-
- testrc.left=clRect.right-dat->extraColumnSpacing*(dat->extraColumnsCount-c);
- testrc.top=(y+((dat->rowHeight-16)>>1));
- testrc.right=testrc.left+16;
- testrc.bottom=testrc.top+16;
- if (!PtInRect(&testrc,pt))
- {
- mode=ILD_NORMAL;
- }
-
- ImageList_DrawEx(dat->himlExtraColumns,Drawing->iExtraImage[iImage],hdcMem,clRect.right-dat->extraColumnSpacing*(dat->extraColumnsCount-c),y+((dat->rowHeight-16)>>1),0,0,CLR_NONE,colourFg,mode);
- }
- }
- else
- {
- int ic=0;
- for(iImage=0;iImage<dat->extraColumnsCount;iImage++) {
- COLORREF colourFg=dat->selBkColour;
- int mode=ILD_NORMAL;
- int x;
-
- //if(group->cl.items[group->scanIndex].iExtraImage[iImage]==0xFF) continue;
- /*
- if(selected) mode=ILD_SELECTED;
- else if(hottrack) {mode=ILD_FOCUS; colourFg=dat->hotTextColour;}
- else if(group->cl.items[group->scanIndex]->type==CLCIT_CONTACT && group->cl.items[group->scanIndex]->flags&CONTACTF_NOTONLIST) {colourFg=dat->fontInfo[FONTID_NOTONLIST].colour; mode=ILD_BLEND50;}
-
- x=(dat->leftMargin+indent*dat->groupIndent+checkboxWidth+dat->iconXSpace-2+width);
- x+=16;
- x=x+dat->extraColumnSpacing*(ic);
- if (iImage==dat->extraColumnsCount-1) {x=clRect.right-18;}
- ImageList_DrawEx(dat->himlExtraColumns,group->cl.items[group->scanIndex].iExtraImage[iImage],hdcMem,
- x,
- y+((dat->rowHeight-16)>>1),0,0,CLR_NONE,colourFg,mode);
- */
- if(Drawing->iExtraImage[iImage]==0xFF) continue;
- //if(selected) mode=ILD_SELECTED;
- else if(hottrack) {mode=ILD_FOCUS; colourFg=dat->hotTextColour;}
- else if(Drawing->type==CLCIT_CONTACT && Drawing->flags&CONTACTF_NOTONLIST) {colourFg=dat->fontInfo[FONTID_NOTONLIST].colour; mode=ILD_BLEND50;}
-
- x=(dat->leftMargin+indent*dat->groupIndent+checkboxWidth+dat->iconXSpace-2+width);
- x+=16;
- x=x+dat->extraColumnSpacing*(ic);
- if (iImage==dat->extraColumnsCount-1) {x=clRect.right-18;}
- ImageList_DrawEx(dat->himlExtraColumns,Drawing->iExtraImage[iImage],hdcMem,
- x,
- y+((dat->rowHeight-16)>>1),0,0,CLR_NONE,colourFg,mode);
-
- ic++;
- }
- }
- }
- }
- index++;
- y+=dat->rowHeight;
-
- if (group->cl.items[group->scanIndex]->type==CLCIT_CONTACT && group->cl.items[group->scanIndex]->flags & CONTACTF_STATUSMSG) {
- y+=dat->rowHeight;
- index++;
- }
-
- //increment by subcontacts
- if (group->cl.items[group->scanIndex]->subcontacts!=NULL && group->cl.items[group->scanIndex]->type!=CLCIT_GROUP)
- if (group->cl.items[group->scanIndex]->SubExpanded)
- if (subindex<group->cl.items[group->scanIndex]->SubAllocated-1)
- subindex++;
- else subindex=-1;
-
- if(subindex==-1) {
- if(group->cl.items[group->scanIndex]->type==CLCIT_GROUP && group->cl.items[group->scanIndex]->group->expanded)
- {
- group=group->cl.items[group->scanIndex]->group;
- indent++;
- group->scanIndex=0;
- subindex=-1;
- continue;
- }
- group->scanIndex++;
- }
- }
- if(dat->iInsertionMark!=-1) { //insertion mark
- HBRUSH hBrush,hoBrush;
- POINT pts[8];
- HRGN hRgn;
-
- pts[0].x=dat->leftMargin; pts[0].y=dat->iInsertionMark*dat->rowHeight-dat->yScroll-4;
- pts[1].x=pts[0].x+2; pts[1].y=pts[0].y+3;
- pts[2].x=clRect.right-4; pts[2].y=pts[1].y;
- pts[3].x=clRect.right-1; pts[3].y=pts[0].y-1;
- pts[4].x=pts[3].x; pts[4].y=pts[0].y+7;
- pts[5].x=pts[2].x+1; pts[5].y=pts[1].y+2;
- pts[6].x=pts[1].x; pts[6].y=pts[5].y;
- pts[7].x=pts[0].x; pts[7].y=pts[4].y;
- hRgn=CreatePolygonRgn(pts,SIZEOF(pts),ALTERNATE);
- hBrush=CreateSolidBrush(dat->fontInfo[FONTID_CONTACTS].colour);
- hoBrush=(HBRUSH)SelectObject(hdcMem,hBrush);
- FillRgn(hdcMem,hRgn,hBrush);
- SelectObject(hdcMem,hoBrush);
- DeleteObject(hBrush);
- }
- if (!grey)
- BitBlt(hdc,rcPaint->left,rcPaint->top,rcPaint->right-rcPaint->left,rcPaint->bottom-rcPaint->top,hdcMem,rcPaint->left,rcPaint->top,SRCCOPY);
- //DeleteDC(hdcMem);
- if(hBrushAlternateGrey) DeleteObject(hBrushAlternateGrey);
- if(grey) {
- PBYTE bits;
- BITMAPINFOHEADER bmih={0};
- int i;
- int greyRed,greyGreen,greyBlue;
- COLORREF greyColour;
- bmih.biBitCount=32;
- bmih.biSize=sizeof(bmih);
- bmih.biCompression=BI_RGB;
- bmih.biHeight=-clRect.bottom;
- bmih.biPlanes=1;
- bmih.biWidth=clRect.right;
- bits=(PBYTE)mir_alloc(4*bmih.biWidth*-bmih.biHeight);
- GetDIBits(hdc,hBmpOsb,0,clRect.bottom,bits,(BITMAPINFO*)&bmih,DIB_RGB_COLORS);
- greyColour=GetSysColor(COLOR_3DFACE);
- greyRed=GetRValue(greyColour)*2;
- greyGreen=GetGValue(greyColour)*2;
- greyBlue=GetBValue(greyColour)*2;
- if(divide3[0]==255) {
- for(i=0; i < SIZEOF(divide3); i++) divide3[i]=(i+1)/3;
- }
- for(i=4*clRect.right*clRect.bottom-4;i>=0;i-=4) {
- bits[i]=divide3[bits[i]+greyBlue];
- bits[i+1]=divide3[bits[i+1]+greyGreen];
- bits[i+2]=divide3[bits[i+2]+greyRed];
- }
- SetDIBitsToDevice(hdc,0,0,clRect.right,clRect.bottom,0,0,0,clRect.bottom,bits,(BITMAPINFO*)&bmih,DIB_RGB_COLORS);
- mir_free(bits);
- }
- SelectObject(hdcMem,oldfont);
- SelectObject(hdcMem,oldbmp);
- DeleteObject(hBmpOsb);
- DeleteDC(hdcMem);
-}
-
-void PaintClc(HWND hwnd,struct ClcData *dat,HDC hdc,RECT *rcPaint)
-{
- if (SED.cbSize==sizeof(SED)&&SED.PaintClc!=NULL)
- {
- SED.PaintClc(hwnd,dat,hdc,rcPaint,pcli->hClcProtoCount,pcli->clcProto,himlCListClc);
- return;
- }
- InternalPaintClc(hwnd,dat,hdc,rcPaint);
-}
diff --git a/plugins/Mwclist/clcpaint.cpp b/plugins/Mwclist/clcpaint.cpp
new file mode 100644
index 0000000000..498e597d31
--- /dev/null
+++ b/plugins/Mwclist/clcpaint.cpp
@@ -0,0 +1,686 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2003 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "commonheaders.h"
+#include "m_clc.h"
+#include "clc.h"
+
+extern HIMAGELIST himlCListClc;
+static BYTE divide3[765] = {255};
+int MetaIgnoreEmptyExtra;
+ExternDrawer SED;
+
+static void ChangeToFont(HDC hdc,struct ClcData *dat,int id,int *fontHeight)
+{
+ SelectObject(hdc,dat->fontInfo[id].hFont);
+ SetTextColor(hdc,dat->fontInfo[id].colour);
+ if (fontHeight) *fontHeight = dat->fontInfo[id].fontHeight;
+}
+
+static void __inline SetHotTrackColour(HDC hdc,struct ClcData *dat)
+{
+ if (dat->gammaCorrection) {
+ COLORREF oldCol,newCol;
+ int oldLum,newLum;
+
+ oldCol = GetTextColor(hdc);
+ oldLum = (GetRValue(oldCol)*30+GetGValue(oldCol)*59+GetBValue(oldCol)*11)/100;
+ newLum = (GetRValue(dat->hotTextColour)*30+GetGValue(dat->hotTextColour)*59+GetBValue(dat->hotTextColour)*11)/100;
+ if (newLum == 0) {
+ SetTextColor(hdc,dat->hotTextColour);
+ return;
+ }
+ if (newLum>=oldLum+20) {
+ oldLum += 20;
+ newCol = RGB(GetRValue(dat->hotTextColour)*oldLum/newLum,GetGValue(dat->hotTextColour)*oldLum/newLum,GetBValue(dat->hotTextColour)*oldLum/newLum);
+ }
+ else if (newLum<=oldLum) {
+ int r,g,b;
+ r = GetRValue(dat->hotTextColour)*oldLum/newLum;
+ g = GetGValue(dat->hotTextColour)*oldLum/newLum;
+ b = GetBValue(dat->hotTextColour)*oldLum/newLum;
+ if (r>255) {
+ g += (r-255)*3/7;
+ b += (r-255)*3/7;
+ r = 255;
+ }
+ if (g>255) {
+ r += (g-255)*59/41;
+ if (r>255) r = 255;
+ b += (g-255)*59/41;
+ g = 255;
+ }
+ if (b>255) {
+ r += (b-255)*11/89;
+ if (r>255) r = 255;
+ g += (b-255)*11/89;
+ if (g>255) g = 255;
+ b = 255;
+ }
+ newCol = RGB(r,g,b);
+ }
+ else newCol = dat->hotTextColour;
+ SetTextColor(hdc,newCol);
+ }
+ else
+ SetTextColor(hdc,dat->hotTextColour);
+}
+
+static int GetStatusOnlineness(int status)
+{
+ switch(status) {
+ case ID_STATUS_FREECHAT: return 110;
+ case ID_STATUS_ONLINE: return 100;
+ case ID_STATUS_OCCUPIED: return 60;
+ case ID_STATUS_ONTHEPHONE: return 50;
+ case ID_STATUS_DND: return 40;
+ case ID_STATUS_AWAY: return 30;
+ case ID_STATUS_OUTTOLUNCH: return 20;
+ case ID_STATUS_NA: return 10;
+ case ID_STATUS_INVISIBLE: return 5;
+ }
+ return 0;
+}
+
+static int GetGeneralisedStatus(void)
+{
+ int i,status,thisStatus,statusOnlineness,thisOnlineness;
+
+ status = ID_STATUS_OFFLINE;
+ statusOnlineness = 0;
+
+ for (i = 0;i<pcli->hClcProtoCount;i++) {
+ thisStatus = pcli->clcProto[i].dwStatus;
+ if (thisStatus == ID_STATUS_INVISIBLE)
+ return ID_STATUS_INVISIBLE;
+
+ thisOnlineness = GetStatusOnlineness(thisStatus);
+ if (thisOnlineness > statusOnlineness) {
+ status = thisStatus;
+ statusOnlineness = thisOnlineness;
+ }
+ }
+ return status;
+}
+
+static int GetRealStatus(struct ClcContact * contact, int status)
+{
+ int i;
+ char *szProto = contact->proto;
+ if (!szProto) return status;
+ for (i = 0;i<pcli->hClcProtoCount;i++) {
+ if (!lstrcmpA(pcli->clcProto[i].szProto,szProto)) {
+ return pcli->clcProto[i].dwStatus;
+ }
+ }
+ return status;
+}
+
+static HMODULE themeAPIHandle = NULL; // handle to uxtheme.dll
+static HANDLE (WINAPI *MyOpenThemeData)(HWND,LPCWSTR);
+static HRESULT (WINAPI *MyCloseThemeData)(HANDLE);
+static HRESULT (WINAPI *MyDrawThemeBackground)(HANDLE,HDC,int,int,const RECT *,const RECT *);
+
+#define MGPROC(x) GetProcAddress(themeAPIHandle,x)
+void InternalPaintClc(HWND hwnd,struct ClcData *dat,HDC hdc,RECT *rcPaint)
+{
+ HDC hdcMem;
+ HBITMAP oldbmp;
+ HBITMAP oldbm;
+ HFONT oldfont;
+ RECT clRect;
+ int y,indent,index,fontHeight, subindex, subident;
+ struct ClcContact *Drawing;
+ struct ClcGroup *group;
+ HBITMAP hBmpOsb;
+ DWORD style = GetWindowLongPtr(hwnd,GWL_STYLE);
+ int status = GetGeneralisedStatus();
+ int grey = 0,groupCountsFontTopShift;
+ HBRUSH hBrushAlternateGrey = NULL;
+ POINT pt;
+ RECT testrc;
+
+ // yes I know about GetSysColorBrush()
+ COLORREF tmpbkcolour = style&CLS_CONTACTLIST ? ( /*dat->useWindowsColours ? GetSysColor(COLOR_3DFACE) :*/ dat->bkColour ) : dat->bkColour;
+
+ if (dat->greyoutFlags & pcli->pfnClcStatusToPf2(status) || style&WS_DISABLED) grey = 1;
+ else if (GetFocus() != hwnd && dat->greyoutFlags&GREYF_UNFOCUS) grey = 1;
+ GetClientRect(hwnd,&clRect);
+
+ if (rcPaint == NULL) rcPaint = &clRect;
+ //rcPaint = &clRect;
+
+ if (IsRectEmpty(rcPaint)) return;
+ GetCursorPos(&pt);
+ ScreenToClient(hwnd,&pt);
+
+
+ y = -dat->yScroll;
+ hdcMem = CreateCompatibleDC(hdc);
+ hBmpOsb = CreateBitmap(clRect.right,clRect.bottom,1,GetDeviceCaps(hdc,BITSPIXEL),NULL);
+ oldbmp = (HBITMAP)SelectObject(hdcMem,hBmpOsb);
+ {
+ oldfont = (HFONT)SelectObject(hdcMem,dat->fontInfo[FONTID_GROUPS].hFont);
+
+ TEXTMETRIC tm;
+ GetTextMetrics(hdcMem,&tm);
+ groupCountsFontTopShift = tm.tmAscent;
+ SelectObject(hdcMem,dat->fontInfo[FONTID_GROUPCOUNTS].hFont);
+ GetTextMetrics(hdcMem,&tm);
+ groupCountsFontTopShift -= tm.tmAscent;
+ SelectObject(hdcMem,oldfont);
+ }
+
+ if (style&CLS_GREYALTERNATE)
+ hBrushAlternateGrey = CreateSolidBrush(GetNearestColor(hdcMem,RGB(GetRValue(tmpbkcolour)-10,GetGValue(tmpbkcolour)-10,GetBValue(tmpbkcolour)-10)));
+
+ ChangeToFont(hdcMem,dat,FONTID_CONTACTS,&fontHeight);
+ SetBkMode(hdcMem,TRANSPARENT);
+
+ HBRUSH hBrush,hoBrush;
+
+ hBrush = CreateSolidBrush(tmpbkcolour);
+ hoBrush = (HBRUSH)SelectObject(hdcMem,hBrush);
+ FillRect(hdcMem,rcPaint,hBrush);
+ SelectObject(hdcMem,hoBrush);
+ DeleteObject(hBrush);
+ if (dat->hBmpBackground) {
+ BITMAP bmp;
+ HDC hdcBmp;
+ int x,y;
+ int maxx,maxy;
+ int destw,desth;
+
+ // XXX: Halftone isnt supported on 9x, however the scretch problems dont happen on 98.
+ SetStretchBltMode(hdcMem, HALFTONE);
+
+ GetObject(dat->hBmpBackground,sizeof(bmp),&bmp);
+ hdcBmp = CreateCompatibleDC(hdcMem);
+ oldbm = (HBITMAP)SelectObject(hdcBmp,dat->hBmpBackground);
+ y = dat->backgroundBmpUse&CLBF_SCROLL?-dat->yScroll:0;
+ maxx = dat->backgroundBmpUse&CLBF_TILEH?clRect.right:1;
+ maxy = dat->backgroundBmpUse&CLBF_TILEV?maxy = rcPaint->bottom:y+1;
+ switch(dat->backgroundBmpUse&CLBM_TYPE) {
+ case CLB_STRETCH:
+ if (dat->backgroundBmpUse&CLBF_PROPORTIONAL) {
+ if (clRect.right*bmp.bmHeight<clRect.bottom*bmp.bmWidth) {
+ desth = clRect.bottom;
+ destw = desth*bmp.bmWidth/bmp.bmHeight;
+ }
+ else {
+ destw = clRect.right;
+ desth = destw*bmp.bmHeight/bmp.bmWidth;
+ }
+ }
+ else {
+ destw = clRect.right;
+ desth = clRect.bottom;
+ }
+ break;
+
+ case CLB_STRETCHH:
+ if (dat->backgroundBmpUse&CLBF_PROPORTIONAL) {
+ destw = clRect.right;
+ desth = destw*bmp.bmHeight/bmp.bmWidth;
+ }
+ else {
+ destw = clRect.right;
+ desth = bmp.bmHeight;
+ if (dat->backgroundBmpUse&CLBF_TILEVTOROWHEIGHT)
+ desth = dat->rowHeight;
+ }
+ break;
+
+ case CLB_STRETCHV:
+ if (dat->backgroundBmpUse&CLBF_PROPORTIONAL) {
+ desth = clRect.bottom;
+ destw = desth*bmp.bmWidth/bmp.bmHeight;
+ }
+ else {
+ destw = bmp.bmWidth;
+ desth = clRect.bottom;
+ }
+ break;
+
+ default: //clb_topleft
+ destw = bmp.bmWidth;
+ desth = bmp.bmHeight;
+ if (dat->backgroundBmpUse&CLBF_TILEVTOROWHEIGHT)
+ desth = dat->rowHeight;
+ break;
+ }
+
+ for (;y<maxy;y += desth) {
+ if (y<rcPaint->top-desth) continue;
+ for (x = 0;x<maxx;x += destw)
+ StretchBlt(hdcMem,x,y,destw,desth,hdcBmp,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
+ }
+ SelectObject(hdcBmp,oldbm);
+ DeleteDC(hdcBmp);
+ }
+ group = &dat->list;
+ group->scanIndex = 0;
+ indent = 0;
+ subindex = -1;
+ for (index = 0;y<rcPaint->bottom;) {
+ if (subindex == -1)
+ if (group->scanIndex == group->cl.count) {
+ group = group->parent;
+ indent--;
+ if (group == NULL) break;
+ group->scanIndex++;
+ continue;
+ }
+
+ if (y>rcPaint->top-dat->rowHeight ) {
+ int iImage = -1;
+ int selected;
+ int hottrack;
+ SIZE textSize,countsSize,spaceSize;
+ int width,checkboxWidth;
+ char *szCounts;
+
+ if (subindex == -1) {
+ Drawing = group->cl.items[group->scanIndex];
+ subident = 0;
+ }
+ else {
+ Drawing = &(group->cl.items[group->scanIndex]->subcontacts[subindex]);
+ subident = dat->rowHeight/2;
+ }
+ //alternating grey
+
+ selected = index == dat->selection && (dat->showSelAlways || dat->exStyle&CLS_EX_SHOWSELALWAYS || GetFocus() == hwnd) && Drawing->type != CLCIT_DIVIDER;
+ hottrack = dat->exStyle&CLS_EX_TRACKSELECT && Drawing->type != CLCIT_DIVIDER && dat->iHotTrack == index;
+
+ if (style&CLS_GREYALTERNATE && index&1) {
+ RECT rc;
+ rc.top = y; rc.bottom = rc.top+dat->rowHeight;
+ rc.left = 0; rc.right = clRect.right;
+ FillRect(hdcMem,&rc,hBrushAlternateGrey);
+ }
+
+ //setup
+ if (Drawing->type == CLCIT_GROUP) {
+ if (Drawing->group->expanded)
+ ChangeToFont(hdcMem,dat,FONTID_GROUPS,&fontHeight);
+ else
+ ChangeToFont(hdcMem,dat,FONTID_GROUPSCLOSED,&fontHeight);
+ }
+ else if (Drawing->type == CLCIT_INFO) {
+ if (Drawing->flags&CLCIIF_GROUPFONT) ChangeToFont(hdcMem,dat,FONTID_GROUPS,&fontHeight);
+ else ChangeToFont(hdcMem,dat,FONTID_CONTACTS,&fontHeight);
+ }
+ else if (Drawing->type == CLCIT_DIVIDER)
+ ChangeToFont(hdcMem,dat,FONTID_DIVIDERS,&fontHeight);
+ else if (Drawing->type == CLCIT_CONTACT && (Drawing->flags&CONTACTF_NOTONLIST) && (!Drawing->isSubcontact) )
+ ChangeToFont(hdcMem,dat,FONTID_NOTONLIST,&fontHeight);
+ else if ( Drawing->type == CLCIT_CONTACT &&
+ (
+ (Drawing->flags&CONTACTF_INVISTO && (!Drawing->isSubcontact) && GetRealStatus(group->cl.items[group->scanIndex], status) != ID_STATUS_INVISIBLE )
+ ||
+ (Drawing->flags&CONTACTF_VISTO && (!Drawing->isSubcontact) && GetRealStatus(group->cl.items[group->scanIndex], status) == ID_STATUS_INVISIBLE)
+ )
+ )
+ {
+ // the contact is in the always visible list and the proto is invisible
+ // the contact is in the always invisible and the proto is in any other mode
+ ChangeToFont(hdcMem,dat, Drawing->flags&CONTACTF_ONLINE ? FONTID_INVIS:FONTID_OFFINVIS ,&fontHeight);
+ }
+ else if (Drawing->type == CLCIT_CONTACT && (!(Drawing->flags&CONTACTF_ONLINE) && (!Drawing->isSubcontact)))
+ ChangeToFont(hdcMem,dat,FONTID_OFFLINE,&fontHeight);
+ else
+ ChangeToFont(hdcMem,dat,FONTID_CONTACTS,&fontHeight);
+ GetTextExtentPoint32(hdcMem,Drawing->szText,lstrlen(Drawing->szText),&textSize);
+ width = textSize.cx;
+ if (Drawing->type == CLCIT_GROUP) {
+ szCounts = pcli->pfnGetGroupCountsText(dat,group->cl.items[group->scanIndex]);
+ if (szCounts[0]) {
+ GetTextExtentPoint32A(hdcMem," ",1,&spaceSize);
+ ChangeToFont(hdcMem,dat,FONTID_GROUPCOUNTS,&fontHeight);
+ GetTextExtentPoint32A(hdcMem,szCounts,lstrlenA(szCounts),&countsSize);
+ width += spaceSize.cx+countsSize.cx;
+ }
+ }
+
+ if ((style&CLS_CHECKBOXES && Drawing->type == CLCIT_CONTACT) ||
+ (style&CLS_GROUPCHECKBOXES && Drawing->type == CLCIT_GROUP) ||
+ (Drawing->type == CLCIT_INFO && Drawing->flags&CLCIIF_CHECKBOX))
+ checkboxWidth = dat->checkboxSize+2;
+ else checkboxWidth = 0;
+
+ //background
+ if (selected) {
+ SetTextColor(hdcMem,dat->selTextColour);
+ break;
+ }
+ else if (hottrack)
+ SetHotTrackColour(hdcMem,dat);
+
+ //checkboxes
+ if (checkboxWidth && (subindex == -1 ||1)) {
+ RECT rc;
+ HANDLE hTheme = NULL;
+
+ // THEME
+ if (IsWinVerXPPlus()) {
+ if (!themeAPIHandle) {
+ themeAPIHandle = GetModuleHandleA("uxtheme");
+ if (themeAPIHandle) {
+ MyOpenThemeData = (HANDLE (WINAPI *)(HWND,LPCWSTR))MGPROC("OpenThemeData");
+ MyCloseThemeData = (HRESULT (WINAPI *)(HANDLE))MGPROC("CloseThemeData");
+ MyDrawThemeBackground = (HRESULT (WINAPI *)(HANDLE,HDC,int,int,const RECT *,const RECT *))MGPROC("DrawThemeBackground");
+ }
+ }
+ // Make sure all of these methods are valid (i would hope either all or none work)
+ if (MyOpenThemeData
+ &&MyCloseThemeData
+ &&MyDrawThemeBackground) {
+ hTheme = MyOpenThemeData(hwnd,L"BUTTON");
+ }
+ }
+ rc.left = dat->leftMargin+indent*dat->groupIndent+subident;
+ rc.right = rc.left+dat->checkboxSize;
+ rc.top = y+((dat->rowHeight-dat->checkboxSize)>>1);
+ rc.bottom = rc.top+dat->checkboxSize;
+ if (hTheme) {
+ MyDrawThemeBackground(hTheme, hdcMem, BP_CHECKBOX, Drawing->flags&CONTACTF_CHECKED?(hottrack?CBS_CHECKEDHOT:CBS_CHECKEDNORMAL):(hottrack?CBS_UNCHECKEDHOT:CBS_UNCHECKEDNORMAL), &rc, &rc);
+ }
+ else DrawFrameControl(hdcMem,&rc,DFC_BUTTON,DFCS_BUTTONCHECK|DFCS_FLAT|(Drawing->flags&CONTACTF_CHECKED?DFCS_CHECKED:0)|(hottrack?DFCS_HOT:0));
+ if (hTheme&&MyCloseThemeData) {
+ MyCloseThemeData(hTheme);
+ hTheme = NULL;
+ }
+ }
+
+ //icon
+ if (Drawing->type == CLCIT_GROUP)
+ iImage = Drawing->group->expanded?IMAGE_GROUPOPEN:IMAGE_GROUPSHUT;
+ else if (Drawing->type == CLCIT_CONTACT)
+ iImage = Drawing->iImage;
+ if (iImage != -1) {
+ /*COLORREF colourFg = dat->selBkColour;
+ int mode = ILD_NORMAL;
+ if (selected) mode = ILD_SELECTED;
+ else if (hottrack) {mode = ILD_FOCUS; colourFg = dat->hotTextColour;}
+ else if (Drawing->type == CLCIT_CONTACT && Drawing->flags&CONTACTF_NOTONLIST) {colourFg = dat->fontInfo[FONTID_NOTONLIST].colour; mode = ILD_BLEND50;}
+ ImageList_DrawEx(himlCListClc,iImage,hdcMem,dat->leftMargin+indent*dat->groupIndent+checkboxWidth,y+((dat->rowHeight-16)>>1),0,0,CLR_NONE,colourFg,mode);
+ */
+ COLORREF colourFg = dat->selBkColour;
+ int mode = ILD_NORMAL;
+ if (hottrack) {colourFg = dat->hotTextColour;}
+ else if (Drawing->type == CLCIT_CONTACT && Drawing->flags&CONTACTF_NOTONLIST && (!Drawing->isSubcontact)) {colourFg = dat->fontInfo[FONTID_NOTONLIST].colour; mode = ILD_BLEND50;}
+ if (Drawing->type == CLCIT_CONTACT && dat->showIdle && (Drawing->flags&CONTACTF_IDLE)&& (!Drawing->isSubcontact) && GetRealStatus(group->cl.items[group->scanIndex],ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
+ mode = ILD_SELECTED;
+ ImageList_DrawEx(himlCListClc,iImage,hdcMem,dat->leftMargin+subident+indent*dat->groupIndent+checkboxWidth,y+((dat->rowHeight-16)>>1),0,0,CLR_NONE,colourFg,mode);
+ }
+
+ //text
+ if (Drawing->type == CLCIT_DIVIDER) {
+ RECT rc;
+ rc.top = y+(dat->rowHeight>>1); rc.bottom = rc.top+2;
+ rc.left = dat->leftMargin+indent*dat->groupIndent;
+ rc.right = rc.left+((clRect.right-rc.left-textSize.cx)>>1)-3;
+ DrawEdge(hdcMem,&rc,BDR_SUNKENOUTER,BF_RECT);
+ TextOut(hdcMem,rc.right+3,y+((dat->rowHeight-fontHeight)>>1),Drawing->szText,lstrlen(Drawing->szText));
+ rc.left = rc.right+6+textSize.cx;
+ rc.right = clRect.right;
+ DrawEdge(hdcMem,&rc,BDR_SUNKENOUTER,BF_RECT);
+ }
+ else if (Drawing->type == CLCIT_GROUP) {
+ RECT rc;
+ if (szCounts[0]) {
+ struct ClcGroup *clcg;
+
+ clcg = (struct ClcGroup *)Drawing;
+
+ fontHeight = dat->fontInfo[FONTID_GROUPS].fontHeight;
+
+ rc.left = dat->leftMargin+indent*dat->groupIndent+checkboxWidth+dat->iconXSpace;
+ rc.right = min(clRect.right-countsSize.cx,rc.left+textSize.cx+spaceSize.cx);
+ rc.top = y+((dat->rowHeight-fontHeight)>>1);
+ rc.bottom = rc.top+textSize.cy;
+ if (rc.right<rc.left+4) rc.right = clRect.right+1;
+ else TextOutA(hdcMem,rc.right,rc.top+groupCountsFontTopShift,szCounts,lstrlenA(szCounts));
+
+ //ChangeToFont(hdcMem,dat,FONTID_GROUPS,&fontHeight);
+ if (Drawing->group->expanded)
+ {
+ ChangeToFont(hdcMem,dat,FONTID_GROUPS,&fontHeight);
+ }
+ else
+ {
+ ChangeToFont(hdcMem,dat,FONTID_GROUPSCLOSED,&fontHeight);
+ }
+
+ if (selected)
+ SetTextColor(hdcMem,dat->selTextColour);
+ else if (hottrack)
+ SetHotTrackColour(hdcMem,dat);
+ rc.right--;
+ ExtTextOut(hdcMem,rc.left,rc.top,ETO_CLIPPED,&rc,Drawing->szText,lstrlen(Drawing->szText),NULL);
+ }
+ else TextOut(hdcMem,dat->leftMargin+indent*dat->groupIndent+checkboxWidth+dat->iconXSpace,y+((dat->rowHeight-fontHeight)>>1),Drawing->szText,lstrlen(Drawing->szText));
+ if (dat->exStyle&CLS_EX_LINEWITHGROUPS) {
+ //calc if extra icons present
+ int enabledextraicons = 0;
+ for (iImage = 0;iImage<dat->extraColumnsCount;iImage++) {
+ if (Drawing->iExtraImage[iImage] == 0xFF) continue;
+ enabledextraicons++;
+ }
+ rc.top = y+(dat->rowHeight>>1); rc.bottom = rc.top+2;
+ rc.left = dat->leftMargin+subident+indent*dat->groupIndent+checkboxWidth+dat->iconXSpace+width+3;
+ rc.right = clRect.right-1-dat->extraColumnSpacing*enabledextraicons;
+ if (rc.right-rc.left>1) DrawEdge(hdcMem,&rc,BDR_SUNKENOUTER,BF_RECT);
+ }
+ }
+ else {
+ RECT rc;
+ rc.left = dat->leftMargin+subident+indent*dat->groupIndent+checkboxWidth+dat->iconXSpace;
+ rc.top = y+((dat->rowHeight-fontHeight)>>1);
+ rc.bottom = rc.top+dat->rowHeight;
+ rc.right = clRect.right;
+ if (Drawing->type = CLCIT_CONTACT)
+ if (hottrack)
+ ChangeToFont(hdcMem,dat,FONTID_CONTACTSHOVER,&fontHeight);
+
+ DrawText(hdcMem,Drawing->szText,lstrlen(Drawing->szText),&rc,DT_END_ELLIPSIS);
+
+ }
+
+ if (selected) {
+ if (Drawing->type != CLCIT_DIVIDER) {
+ SetTextColor(hdcMem,dat->quickSearchColour);
+ TextOut(hdcMem,dat->leftMargin+subident+indent*dat->groupIndent+checkboxWidth+dat->iconXSpace,y+((dat->rowHeight-fontHeight)>>1),Drawing->szText,lstrlen(dat->szQuickSearch));
+ }
+ }
+
+ if (dat->style&CLS_SHOWSTATUSMESSAGES)
+ {
+ // status message
+ if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && group->cl.items[group->scanIndex]->flags & CONTACTF_STATUSMSG) {
+ TCHAR * szText = group->cl.items[group->scanIndex]->szStatusMsg;
+ RECT rc;
+ rc.left = dat->leftMargin + indent * dat->groupIndent + checkboxWidth + dat->iconXSpace;
+ rc.top = y+dat->rowHeight+((dat->rowHeight-fontHeight)>>1);
+ rc.right = (clRect.right - clRect.left);
+ rc.bottom = rc.top+dat->rowHeight;
+ ChangeToFont(hdcMem,dat,FONTID_STATUSMSG,&fontHeight);
+ //ExtTextOut(hdcMem,rc.left,rc.top,ETO_CLIPPED,&rc,szText,lstrlen(szText),NULL);
+ DrawText(hdcMem, szText, lstrlen(szText), &rc, DT_SINGLELINE | DT_EDITCONTROL | DT_NOPREFIX | DT_NOCLIP | DT_WORD_ELLIPSIS);
+ }
+ }
+
+ if (!Drawing->isSubcontact || (DBGetContactSettingByte(NULL,"CLC","MetaHideExtra",0) == 0)) {
+
+ //extra icons
+ if ( !(style & CLS_EX_MULTICOLUMNALIGNLEFT)) {
+ int c = dat->extraColumnsCount;
+ for (iImage = dat->extraColumnsCount-1;iImage>=0;iImage--) {
+ COLORREF colourFg = dat->selBkColour;
+ int mode = ILD_NORMAL;
+
+ if (Drawing->iExtraImage[iImage] == 0xFF) continue;
+ if (selected) mode = ILD_SELECTED;
+ else if (hottrack) {mode = ILD_FOCUS; colourFg = dat->hotTextColour;}
+ else if (Drawing->type == CLCIT_CONTACT && Drawing->flags&CONTACTF_NOTONLIST) {colourFg = dat->fontInfo[FONTID_NOTONLIST].colour; mode = ILD_BLEND50;}
+ {
+
+ }
+ if (dat->MetaIgnoreEmptyExtra) c--; else c = iImage;
+
+ testrc.left = clRect.right-dat->extraColumnSpacing*(dat->extraColumnsCount-c);
+ testrc.top = (y+((dat->rowHeight-16)>>1));
+ testrc.right = testrc.left+16;
+ testrc.bottom = testrc.top+16;
+ if (!PtInRect(&testrc,pt))
+ mode = ILD_NORMAL;
+
+ ImageList_DrawEx(dat->himlExtraColumns,Drawing->iExtraImage[iImage],hdcMem,clRect.right-dat->extraColumnSpacing*(dat->extraColumnsCount-c),y+((dat->rowHeight-16)>>1),0,0,CLR_NONE,colourFg,mode);
+ }
+ }
+ else {
+ int ic = 0;
+ for (iImage = 0;iImage<dat->extraColumnsCount;iImage++) {
+ COLORREF colourFg = dat->selBkColour;
+ int mode = ILD_NORMAL;
+ int x;
+
+ if (Drawing->iExtraImage[iImage] == 0xFF)
+ continue;
+
+ if (hottrack) {
+ mode = ILD_FOCUS;
+ colourFg = dat->hotTextColour;
+ }
+ else if (Drawing->type == CLCIT_CONTACT && (Drawing->flags & CONTACTF_NOTONLIST)) {
+ colourFg = dat->fontInfo[FONTID_NOTONLIST].colour;
+ mode = ILD_BLEND50;
+ }
+
+ x = (dat->leftMargin+indent*dat->groupIndent+checkboxWidth+dat->iconXSpace-2+width);
+ x += 16;
+ x = x+dat->extraColumnSpacing*(ic);
+ if (iImage == dat->extraColumnsCount-1) {x = clRect.right-18;}
+ ImageList_DrawEx(dat->himlExtraColumns,Drawing->iExtraImage[iImage],hdcMem,
+ x,
+ y+((dat->rowHeight-16)>>1),0,0,CLR_NONE,colourFg,mode);
+
+ ic++;
+ }
+ }
+ }
+ }
+ index++;
+ y += dat->rowHeight;
+
+ if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && group->cl.items[group->scanIndex]->flags & CONTACTF_STATUSMSG) {
+ y += dat->rowHeight;
+ index++;
+ }
+
+ //increment by subcontacts
+ if (group->cl.items[group->scanIndex]->subcontacts != NULL && group->cl.items[group->scanIndex]->type != CLCIT_GROUP)
+ if (group->cl.items[group->scanIndex]->SubExpanded)
+ if (subindex<group->cl.items[group->scanIndex]->SubAllocated-1)
+ subindex++;
+ else subindex = -1;
+
+ if (subindex == -1) {
+ if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP && group->cl.items[group->scanIndex]->group->expanded) {
+ group = group->cl.items[group->scanIndex]->group;
+ indent++;
+ group->scanIndex = 0;
+ subindex = -1;
+ continue;
+ }
+ group->scanIndex++;
+ }
+ }
+ if (dat->iInsertionMark != -1) { //insertion mark
+ HBRUSH hBrush,hoBrush;
+ POINT pts[8];
+ HRGN hRgn;
+
+ pts[0].x = dat->leftMargin; pts[0].y = dat->iInsertionMark*dat->rowHeight-dat->yScroll-4;
+ pts[1].x = pts[0].x+2; pts[1].y = pts[0].y+3;
+ pts[2].x = clRect.right-4; pts[2].y = pts[1].y;
+ pts[3].x = clRect.right-1; pts[3].y = pts[0].y-1;
+ pts[4].x = pts[3].x; pts[4].y = pts[0].y+7;
+ pts[5].x = pts[2].x+1; pts[5].y = pts[1].y+2;
+ pts[6].x = pts[1].x; pts[6].y = pts[5].y;
+ pts[7].x = pts[0].x; pts[7].y = pts[4].y;
+ hRgn = CreatePolygonRgn(pts,SIZEOF(pts),ALTERNATE);
+ hBrush = CreateSolidBrush(dat->fontInfo[FONTID_CONTACTS].colour);
+ hoBrush = (HBRUSH)SelectObject(hdcMem,hBrush);
+ FillRgn(hdcMem,hRgn,hBrush);
+ SelectObject(hdcMem,hoBrush);
+ DeleteObject(hBrush);
+ }
+ if (!grey)
+ BitBlt(hdc,rcPaint->left,rcPaint->top,rcPaint->right-rcPaint->left,rcPaint->bottom-rcPaint->top,hdcMem,rcPaint->left,rcPaint->top,SRCCOPY);
+ //DeleteDC(hdcMem);
+ if (hBrushAlternateGrey) DeleteObject(hBrushAlternateGrey);
+ if (grey) {
+ PBYTE bits;
+ BITMAPINFOHEADER bmih = {0};
+ int i;
+ int greyRed,greyGreen,greyBlue;
+ COLORREF greyColour;
+ bmih.biBitCount = 32;
+ bmih.biSize = sizeof(bmih);
+ bmih.biCompression = BI_RGB;
+ bmih.biHeight = -clRect.bottom;
+ bmih.biPlanes = 1;
+ bmih.biWidth = clRect.right;
+ bits = (PBYTE)mir_alloc(4*bmih.biWidth*-bmih.biHeight);
+ GetDIBits(hdc,hBmpOsb,0,clRect.bottom,bits,(BITMAPINFO*)&bmih,DIB_RGB_COLORS);
+ greyColour = GetSysColor(COLOR_3DFACE);
+ greyRed = GetRValue(greyColour)*2;
+ greyGreen = GetGValue(greyColour)*2;
+ greyBlue = GetBValue(greyColour)*2;
+ if (divide3[0] == 255) {
+ for (i = 0; i < SIZEOF(divide3); i++) divide3[i] = (i+1)/3;
+ }
+ for (i = 4*clRect.right*clRect.bottom-4;i>=0;i -= 4) {
+ bits[i] = divide3[bits[i]+greyBlue];
+ bits[i+1] = divide3[bits[i+1]+greyGreen];
+ bits[i+2] = divide3[bits[i+2]+greyRed];
+ }
+ SetDIBitsToDevice(hdc,0,0,clRect.right,clRect.bottom,0,0,0,clRect.bottom,bits,(BITMAPINFO*)&bmih,DIB_RGB_COLORS);
+ mir_free(bits);
+ }
+ SelectObject(hdcMem,oldfont);
+ SelectObject(hdcMem,oldbmp);
+ DeleteObject(hBmpOsb);
+ DeleteDC(hdcMem);
+}
+
+void PaintClc(HWND hwnd,struct ClcData *dat,HDC hdc,RECT *rcPaint)
+{
+ if (SED.cbSize == sizeof(SED)&&SED.PaintClc != NULL) {
+ SED.PaintClc(hwnd,dat,hdc,rcPaint,pcli->hClcProtoCount,pcli->clcProto,himlCListClc);
+ return;
+ }
+ InternalPaintClc(hwnd,dat,hdc,rcPaint);
+}
diff --git a/plugins/Mwclist/clcutils.c b/plugins/Mwclist/clcutils.c
deleted file mode 100644
index 151654ed3b..0000000000
--- a/plugins/Mwclist/clcutils.c
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
-
-Miranda IM: the free IM client for Microsoft* Windows*
-
-Copyright 2000-2003 Miranda ICQ/IM project,
-all portions of this codebase are copyrighted to the people
-listed in contributors.txt.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-#include "commonheaders.h"
-#include "m_clc.h"
-#include "clc.h"
-
-//loads of stuff that didn't really fit anywhere else
-
-int HitTest(HWND hwnd,struct ClcData *dat,int testx,int testy,struct ClcContact **contact,struct ClcGroup **group,DWORD *flags)
-{
- struct ClcContact *hitcontact;
- struct ClcGroup *hitgroup;
- int hit,indent,width,i,cxSmIcon;
- int checkboxWidth, subident,ic=0;
- SIZE textSize;
- HDC hdc;
- HFONT oldfont;
- RECT clRect;
- DWORD style=GetWindowLongPtr(hwnd,GWL_STYLE);
-
- if(flags) *flags=0;
- GetClientRect(hwnd,&clRect);
- if(testx<0 || testy<0 || testy>=clRect.bottom || testx>=clRect.right) {
- if(flags) {
- if(testx<0) *flags|=CLCHT_TOLEFT;
- else if(testx>=clRect.right) *flags|=CLCHT_TORIGHT;
- if(testy<0) *flags|=CLCHT_ABOVE;
- else if(testy>=clRect.bottom) *flags|=CLCHT_BELOW;
- }
- return -1;
- }
- if(testx<dat->leftMargin) {
- if(flags) *flags|=CLCHT_INLEFTMARGIN|CLCHT_NOWHERE;
- return -1;
- }
- hit=GetRowByIndex(dat ,(testy+dat->yScroll)/dat->rowHeight,&hitcontact,&hitgroup);
- if(hit==-1) {
- if(flags) *flags|=CLCHT_NOWHERE|CLCHT_BELOWITEMS;
- return -1;
- }
- if(contact) *contact=hitcontact;
- if(group) *group=hitgroup;
- /////////
- if (hitcontact->type==CLCIT_CONTACT && hitcontact->isSubcontact)
- subident=dat->rowHeight/2;
- else
- subident=0;
-
- for(indent=0;hitgroup->parent;indent++,hitgroup=hitgroup->parent);
- if(testx<dat->leftMargin+indent*dat->groupIndent+subident) {
- if(flags) *flags|=CLCHT_ONITEMINDENT;
- return hit;
- }
- checkboxWidth=0;
- if(style&CLS_CHECKBOXES && hitcontact->type==CLCIT_CONTACT) checkboxWidth=dat->checkboxSize+2;
- if(style&CLS_GROUPCHECKBOXES && hitcontact->type==CLCIT_GROUP) checkboxWidth=dat->checkboxSize+2;
- if(hitcontact->type==CLCIT_INFO && hitcontact->flags&CLCIIF_CHECKBOX) checkboxWidth=dat->checkboxSize+2;
- if(testx<dat->leftMargin+indent*dat->groupIndent+checkboxWidth+subident) {
- if(flags) *flags|=CLCHT_ONITEMCHECK;
- return hit;
- }
- if(testx<dat->leftMargin+indent*dat->groupIndent+checkboxWidth+dat->iconXSpace+subident) {
- if(flags) *flags|=CLCHT_ONITEMICON;
- return hit;
- }
-
- hdc=GetDC(hwnd);
- GetTextExtentPoint32(hdc,hitcontact->szText,lstrlen(hitcontact->szText),&textSize);
- width=textSize.cx;
-
- cxSmIcon=GetSystemMetrics(SM_CXSMICON);
-
- for(i=0;i<dat->extraColumnsCount;i++) {
- int x;
- if(hitcontact->iExtraImage[i]==0xFF) continue;
-
- if ((style&CLS_EX_MULTICOLUMNALIGNLEFT))
- {
- x=(dat->leftMargin+indent*dat->groupIndent+checkboxWidth+dat->iconXSpace-2+width);
- x+=16;
- x=x+dat->extraColumnSpacing*(ic);
- if (i==dat->extraColumnsCount-1) {x=clRect.right-18;}
- }else
- {
- int ir;
- if (dat->MetaIgnoreEmptyExtra)
- {
- int j;
- ir = 0;
- for(j=i;j<dat->extraColumnsCount;j++)
- if(hitcontact->iExtraImage[j]!=0xFF)
- ir++;
- }else
- ir = dat->extraColumnsCount-i;
-
- x=clRect.right-dat->extraColumnSpacing*ir;
- }
- ic++;
-
- if(testx>=x &&
- testx<x+cxSmIcon) {
- if(flags) *flags|=CLCHT_ONITEMEXTRA|(i<<24);
-
- ReleaseDC(hwnd,hdc);
- return hit;
- } }
-
- if(hitcontact->type==CLCIT_GROUP)
- oldfont=SelectObject(hdc,dat->fontInfo[FONTID_GROUPS].hFont);
- else oldfont=SelectObject(hdc,dat->fontInfo[FONTID_CONTACTS].hFont);
- if (DBGetContactSettingByte(NULL,"CLC","HiLightMode",0)==1)
- {
- if(flags) *flags|=CLCHT_ONITEMLABEL;
- SelectObject(hdc,oldfont);
- ReleaseDC(hwnd,hdc);
- return hit;
- }
-
- GetTextExtentPoint32(hdc,hitcontact->szText,lstrlen(hitcontact->szText),&textSize);
- width=textSize.cx;
- if(hitcontact->type==CLCIT_GROUP) {
- char *szCounts;
- szCounts = pcli->pfnGetGroupCountsText(dat,hitcontact);
- if(szCounts[0]) {
- GetTextExtentPoint32A(hdc," ",1,&textSize);
- width+=textSize.cx;
- SelectObject(hdc,dat->fontInfo[FONTID_GROUPCOUNTS].hFont);
- GetTextExtentPoint32A(hdc,szCounts,lstrlenA(szCounts),&textSize);
- width+=textSize.cx;
- }
- }
- SelectObject(hdc,oldfont);
- ReleaseDC(hwnd,hdc);
- if(testx<dat->leftMargin+indent*dat->groupIndent+checkboxWidth+dat->iconXSpace+width+4+subident) {
- if(flags) *flags|=CLCHT_ONITEMLABEL;
- return hit;
- }
- if(flags) *flags|=CLCHT_NOWHERE;
- return -1;
-}
-
-void ScrollTo(HWND hwnd,struct ClcData *dat,int desty,int noSmooth)
-{
- DWORD startTick,nowTick;
- int oldy=dat->yScroll;
- RECT clRect,rcInvalidate;
- int maxy,previousy;
-
- if(dat->iHotTrack!=-1 && dat->yScroll != desty) {
- pcli->pfnInvalidateItem(hwnd,dat,dat->iHotTrack);
- dat->iHotTrack=-1;
- ReleaseCapture();
- }
- GetClientRect(hwnd,&clRect);
- rcInvalidate=clRect;
- maxy=dat->rowHeight*GetGroupContentsCount(&dat->list,2)-clRect.bottom;
- if(desty>maxy) desty=maxy;
- if(desty<0) desty=0;
- if(abs(desty-dat->yScroll)<4) noSmooth=1;
- if (!noSmooth && dat->exStyle&CLS_EX_NOSMOOTHSCROLLING) noSmooth=1;
- previousy=dat->yScroll;
- if (!noSmooth) {
- startTick=GetTickCount();
- for (;;) {
- nowTick=GetTickCount();
- if(nowTick>=startTick+dat->scrollTime) break;
- dat->yScroll=oldy+(desty-oldy)*(int)(nowTick-startTick)/dat->scrollTime;
- if(dat->backgroundBmpUse&CLBF_SCROLL || dat->hBmpBackground==NULL)
- ScrollWindowEx(hwnd,0,previousy-dat->yScroll,NULL,NULL,NULL,NULL,SW_INVALIDATE);
- else
- InvalidateRect(hwnd,NULL,FALSE);
- previousy=dat->yScroll;
- SetScrollPos(hwnd,SB_VERT,dat->yScroll,TRUE);
- UpdateWindow(hwnd);
- }
- }
- dat->yScroll=desty;
- if(dat->backgroundBmpUse&CLBF_SCROLL || dat->hBmpBackground==NULL)
- ScrollWindowEx(hwnd,0,previousy-dat->yScroll,NULL,NULL,NULL,NULL,SW_INVALIDATE);
- else
- InvalidateRect(hwnd,NULL,FALSE);
- SetScrollPos(hwnd,SB_VERT,dat->yScroll,TRUE);
-}
-
-void RecalcScrollBar(HWND hwnd,struct ClcData *dat)
-{
- SCROLLINFO si={0};
- RECT clRect;
- NMCLISTCONTROL nm;
- boolean sbar=FALSE;
-
- GetClientRect(hwnd,&clRect);
-
- si.cbSize=sizeof(si);
- si.fMask=SIF_ALL;
- si.nMin=0;
- si.nMax=dat->rowHeight*GetGroupContentsCount(&dat->list,2)-1;
- si.nPage=clRect.bottom;
- si.nPos=dat->yScroll;
-
- nm.hdr.code=CLN_LISTSIZECHANGE;
- nm.hdr.hwndFrom=hwnd;
- nm.hdr.idFrom=GetDlgCtrlID(hwnd);
- nm.pt.y=si.nMax;
- SendMessage(GetParent(hwnd),WM_NOTIFY,0,(LPARAM)&nm);
-
- GetClientRect(hwnd,&clRect);
- si.cbSize=sizeof(si);
- si.fMask=SIF_ALL;
- si.nMin=0;
- si.nMax=dat->rowHeight*GetGroupContentsCount(&dat->list,2)-1;
- si.nPage=clRect.bottom;
- si.nPos=dat->yScroll;
-
- sbar=(dat->noVScrollbar==1||(int)si.nPage>si.nMax);
-
- ShowScrollBar(hwnd,SB_VERT,sbar? FALSE : TRUE);
- if (!sbar) {
- if ( GetWindowLongPtr(hwnd,GWL_STYLE)&CLS_CONTACTLIST ) {
- if ( dat->noVScrollbar==0 ) SetScrollInfo(hwnd,SB_VERT,&si,TRUE);
- else SetScrollInfo(hwnd,SB_VERT,&si,FALSE);
- }
- else SetScrollInfo(hwnd,SB_VERT,&si,TRUE);
- }
- ScrollTo(hwnd,dat,dat->yScroll,1);
-}
-
-void CalcEipPosition( struct ClcData *dat, struct ClcContact *contact, struct ClcGroup *group, POINT *result)
-{
- int indent;
- for (indent = 0; group->parent; indent++, group = group->parent);
- result->x = indent * dat->groupIndent + dat->iconXSpace - 2;
- result->y = dat->selection * dat->rowHeight - dat->yScroll;
-
- if (contact->type == CLCIT_CONTACT && contact->isSubcontact)
- result->x += dat->rowHeight/2;
-}
-
-void GetDefaultFontSetting(int i,LOGFONT *lf,COLORREF *colour)
-{
- SystemParametersInfo(SPI_GETICONTITLELOGFONT,sizeof(LOGFONT),lf,FALSE);
- *colour=GetSysColor(COLOR_WINDOWTEXT);
- switch(i) {
- case FONTID_GROUPS:
- lf->lfWeight=FW_BOLD;
- break;
- case FONTID_GROUPCOUNTS:
- lf->lfHeight=(int)(lf->lfHeight*.75);
- *colour=GetSysColor(COLOR_3DSHADOW);
- break;
- case FONTID_OFFINVIS:
- case FONTID_INVIS:
- lf->lfItalic=!lf->lfItalic;
- break;
- case FONTID_DIVIDERS:
- lf->lfHeight=(int)(lf->lfHeight*.75);
- break;
- case FONTID_NOTONLIST:
- *colour=GetSysColor(COLOR_3DSHADOW);
- break;
-} }
-
-extern void ( *saveLoadClcOptions )(HWND hwnd,struct ClcData *dat);
-
-void LoadClcOptions(HWND hwnd,struct ClcData *dat)
-{
- int i;
-
- dat->style=GetWindowLongPtr(hwnd,GWL_STYLE);
- dat->MetaIgnoreEmptyExtra=DBGetContactSettingByte(NULL,"CLC","MetaIgnoreEmptyExtra",1);
- saveLoadClcOptions( hwnd, dat );
-
- for (i = 0; i <= FONTID_MAX; i++)
- if (dat->fontInfo[i].fontHeight > dat->rowHeight)
- dat->rowHeight = dat->fontInfo[i].fontHeight;
-}
diff --git a/plugins/Mwclist/clcutils.cpp b/plugins/Mwclist/clcutils.cpp
new file mode 100644
index 0000000000..39ed63e403
--- /dev/null
+++ b/plugins/Mwclist/clcutils.cpp
@@ -0,0 +1,289 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2003 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+#include "commonheaders.h"
+#include "m_clc.h"
+#include "clc.h"
+
+//loads of stuff that didn't really fit anywhere else
+
+int HitTest(HWND hwnd,struct ClcData *dat,int testx,int testy,struct ClcContact **contact,struct ClcGroup **group,DWORD *flags)
+{
+ struct ClcContact *hitcontact;
+ struct ClcGroup *hitgroup;
+ int hit,indent,width,i,cxSmIcon;
+ int checkboxWidth, subident,ic = 0;
+ SIZE textSize;
+ HDC hdc;
+ HFONT oldfont;
+ RECT clRect;
+ DWORD style = GetWindowLongPtr(hwnd,GWL_STYLE);
+
+ if (flags) *flags = 0;
+ GetClientRect(hwnd,&clRect);
+ if (testx<0 || testy<0 || testy>=clRect.bottom || testx>=clRect.right) {
+ if (flags) {
+ if (testx<0) *flags|=CLCHT_TOLEFT;
+ else if (testx>=clRect.right) *flags|=CLCHT_TORIGHT;
+ if (testy<0) *flags|=CLCHT_ABOVE;
+ else if (testy>=clRect.bottom) *flags|=CLCHT_BELOW;
+ }
+ return -1;
+ }
+ if (testx<dat->leftMargin) {
+ if (flags) *flags|=CLCHT_INLEFTMARGIN|CLCHT_NOWHERE;
+ return -1;
+ }
+ hit = GetRowByIndex(dat ,(testy+dat->yScroll)/dat->rowHeight,&hitcontact,&hitgroup);
+ if (hit == -1) {
+ if (flags) *flags|=CLCHT_NOWHERE|CLCHT_BELOWITEMS;
+ return -1;
+ }
+ if (contact) *contact = hitcontact;
+ if (group) *group = hitgroup;
+ /////////
+ if (hitcontact->type == CLCIT_CONTACT && hitcontact->isSubcontact)
+ subident = dat->rowHeight/2;
+ else
+ subident = 0;
+
+ for (indent = 0;hitgroup->parent;indent++,hitgroup = hitgroup->parent);
+ if (testx<dat->leftMargin+indent*dat->groupIndent+subident) {
+ if (flags) *flags|=CLCHT_ONITEMINDENT;
+ return hit;
+ }
+ checkboxWidth = 0;
+ if (style&CLS_CHECKBOXES && hitcontact->type == CLCIT_CONTACT) checkboxWidth = dat->checkboxSize+2;
+ if (style&CLS_GROUPCHECKBOXES && hitcontact->type == CLCIT_GROUP) checkboxWidth = dat->checkboxSize+2;
+ if (hitcontact->type == CLCIT_INFO && hitcontact->flags&CLCIIF_CHECKBOX) checkboxWidth = dat->checkboxSize+2;
+ if (testx<dat->leftMargin+indent*dat->groupIndent+checkboxWidth+subident) {
+ if (flags) *flags|=CLCHT_ONITEMCHECK;
+ return hit;
+ }
+ if (testx<dat->leftMargin+indent*dat->groupIndent+checkboxWidth+dat->iconXSpace+subident) {
+ if (flags) *flags|=CLCHT_ONITEMICON;
+ return hit;
+ }
+
+ hdc = GetDC(hwnd);
+ GetTextExtentPoint32(hdc,hitcontact->szText,lstrlen(hitcontact->szText),&textSize);
+ width = textSize.cx;
+
+ cxSmIcon = GetSystemMetrics(SM_CXSMICON);
+
+ for (i = 0;i<dat->extraColumnsCount;i++) {
+ int x;
+ if (hitcontact->iExtraImage[i] == 0xFF) continue;
+
+ if ((style&CLS_EX_MULTICOLUMNALIGNLEFT))
+ {
+ x = (dat->leftMargin+indent*dat->groupIndent+checkboxWidth+dat->iconXSpace-2+width);
+ x += 16;
+ x = x+dat->extraColumnSpacing*(ic);
+ if (i == dat->extraColumnsCount-1) {x = clRect.right-18;}
+ }else
+ {
+ int ir;
+ if (dat->MetaIgnoreEmptyExtra)
+ {
+ int j;
+ ir = 0;
+ for (j = i;j<dat->extraColumnsCount;j++)
+ if (hitcontact->iExtraImage[j] != 0xFF)
+ ir++;
+ }else
+ ir = dat->extraColumnsCount-i;
+
+ x = clRect.right-dat->extraColumnSpacing*ir;
+ }
+ ic++;
+
+ if (testx>=x &&
+ testx<x+cxSmIcon) {
+ if (flags) *flags|=CLCHT_ONITEMEXTRA|(i<<24);
+
+ ReleaseDC(hwnd,hdc);
+ return hit;
+ } }
+
+ if (hitcontact->type == CLCIT_GROUP)
+ oldfont = (HFONT)SelectObject(hdc,dat->fontInfo[FONTID_GROUPS].hFont);
+ else
+ oldfont = (HFONT)SelectObject(hdc,dat->fontInfo[FONTID_CONTACTS].hFont);
+
+ GetTextExtentPoint32(hdc,hitcontact->szText,lstrlen(hitcontact->szText),&textSize);
+ width = textSize.cx;
+ if (hitcontact->type == CLCIT_GROUP) {
+ char *szCounts = pcli->pfnGetGroupCountsText(dat,hitcontact);
+ if (szCounts[0]) {
+ GetTextExtentPoint32A(hdc," ",1,&textSize);
+ width += textSize.cx;
+ SelectObject(hdc,dat->fontInfo[FONTID_GROUPCOUNTS].hFont);
+ GetTextExtentPoint32A(hdc,szCounts,lstrlenA(szCounts),&textSize);
+ width += textSize.cx;
+ }
+ }
+ SelectObject(hdc,oldfont);
+ ReleaseDC(hwnd,hdc);
+ if (testx<dat->leftMargin+indent*dat->groupIndent+checkboxWidth+dat->iconXSpace+width+4+subident) {
+ if (flags) *flags|=CLCHT_ONITEMLABEL;
+ return hit;
+ }
+ if (flags) *flags|=CLCHT_NOWHERE;
+ return -1;
+}
+
+void ScrollTo(HWND hwnd,struct ClcData *dat,int desty,int noSmooth)
+{
+ DWORD startTick,nowTick;
+ int oldy = dat->yScroll;
+ RECT clRect,rcInvalidate;
+ int maxy,previousy;
+
+ if (dat->iHotTrack != -1 && dat->yScroll != desty) {
+ pcli->pfnInvalidateItem(hwnd,dat,dat->iHotTrack);
+ dat->iHotTrack = -1;
+ ReleaseCapture();
+ }
+ GetClientRect(hwnd,&clRect);
+ rcInvalidate = clRect;
+ maxy = dat->rowHeight*GetGroupContentsCount(&dat->list,2)-clRect.bottom;
+ if (desty>maxy) desty = maxy;
+ if (desty<0) desty = 0;
+ if (abs(desty-dat->yScroll)<4) noSmooth = 1;
+ if (!noSmooth && dat->exStyle&CLS_EX_NOSMOOTHSCROLLING) noSmooth = 1;
+ previousy = dat->yScroll;
+ if (!noSmooth) {
+ startTick = GetTickCount();
+ for (;;) {
+ nowTick = GetTickCount();
+ if (nowTick>=startTick+dat->scrollTime) break;
+ dat->yScroll = oldy+(desty-oldy)*(int)(nowTick-startTick)/dat->scrollTime;
+ if (dat->backgroundBmpUse&CLBF_SCROLL || dat->hBmpBackground == NULL)
+ ScrollWindowEx(hwnd,0,previousy-dat->yScroll,NULL,NULL,NULL,NULL,SW_INVALIDATE);
+ else
+ InvalidateRect(hwnd,NULL,FALSE);
+ previousy = dat->yScroll;
+ SetScrollPos(hwnd,SB_VERT,dat->yScroll,TRUE);
+ UpdateWindow(hwnd);
+ }
+ }
+ dat->yScroll = desty;
+ if (dat->backgroundBmpUse&CLBF_SCROLL || dat->hBmpBackground == NULL)
+ ScrollWindowEx(hwnd,0,previousy-dat->yScroll,NULL,NULL,NULL,NULL,SW_INVALIDATE);
+ else
+ InvalidateRect(hwnd,NULL,FALSE);
+ SetScrollPos(hwnd,SB_VERT,dat->yScroll,TRUE);
+}
+
+void RecalcScrollBar(HWND hwnd,struct ClcData *dat)
+{
+ SCROLLINFO si = {0};
+ RECT clRect;
+ NMCLISTCONTROL nm;
+ boolean sbar = FALSE;
+
+ GetClientRect(hwnd,&clRect);
+
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_ALL;
+ si.nMin = 0;
+ si.nMax = dat->rowHeight*GetGroupContentsCount(&dat->list,2)-1;
+ si.nPage = clRect.bottom;
+ si.nPos = dat->yScroll;
+
+ nm.hdr.code = CLN_LISTSIZECHANGE;
+ nm.hdr.hwndFrom = hwnd;
+ nm.hdr.idFrom = GetDlgCtrlID(hwnd);
+ nm.pt.y = si.nMax;
+ SendMessage(GetParent(hwnd),WM_NOTIFY,0,(LPARAM)&nm);
+
+ GetClientRect(hwnd,&clRect);
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_ALL;
+ si.nMin = 0;
+ si.nMax = dat->rowHeight*GetGroupContentsCount(&dat->list,2)-1;
+ si.nPage = clRect.bottom;
+ si.nPos = dat->yScroll;
+
+ sbar = (dat->noVScrollbar == 1||(int)si.nPage>si.nMax);
+
+ ShowScrollBar(hwnd,SB_VERT,sbar? FALSE : TRUE);
+ if (!sbar) {
+ if ( GetWindowLongPtr(hwnd,GWL_STYLE)&CLS_CONTACTLIST ) {
+ if ( dat->noVScrollbar == 0 ) SetScrollInfo(hwnd,SB_VERT,&si,TRUE);
+ else SetScrollInfo(hwnd,SB_VERT,&si,FALSE);
+ }
+ else SetScrollInfo(hwnd,SB_VERT,&si,TRUE);
+ }
+ ScrollTo(hwnd,dat,dat->yScroll,1);
+}
+
+void CalcEipPosition( struct ClcData *dat, struct ClcContact *contact, struct ClcGroup *group, POINT *result)
+{
+ int indent;
+ for (indent = 0; group->parent; indent++, group == group->parent);
+ result->x = indent * dat->groupIndent + dat->iconXSpace - 2;
+ result->y = dat->selection * dat->rowHeight - dat->yScroll;
+
+ if (contact->type == CLCIT_CONTACT && contact->isSubcontact)
+ result->x += dat->rowHeight/2;
+}
+
+void GetDefaultFontSetting(int i,LOGFONT *lf,COLORREF *colour)
+{
+ SystemParametersInfo(SPI_GETICONTITLELOGFONT,sizeof(LOGFONT),lf,FALSE);
+ *colour = GetSysColor(COLOR_WINDOWTEXT);
+ switch(i) {
+ case FONTID_GROUPS:
+ lf->lfWeight = FW_BOLD;
+ break;
+ case FONTID_GROUPCOUNTS:
+ lf->lfHeight = (int)(lf->lfHeight*.75);
+ *colour = GetSysColor(COLOR_3DSHADOW);
+ break;
+ case FONTID_OFFINVIS:
+ case FONTID_INVIS:
+ lf->lfItalic = !lf->lfItalic;
+ break;
+ case FONTID_DIVIDERS:
+ lf->lfHeight = (int)(lf->lfHeight*.75);
+ break;
+ case FONTID_NOTONLIST:
+ *colour = GetSysColor(COLOR_3DSHADOW);
+ break;
+} }
+
+extern void ( *saveLoadClcOptions )(HWND hwnd,struct ClcData *dat);
+
+void LoadClcOptions(HWND hwnd,struct ClcData *dat)
+{
+ int i;
+
+ dat->style = GetWindowLongPtr(hwnd,GWL_STYLE);
+ dat->MetaIgnoreEmptyExtra = DBGetContactSettingByte(NULL,"CLC","MetaIgnoreEmptyExtra",1);
+ saveLoadClcOptions( hwnd, dat );
+
+ for (i = 0; i <= FONTID_MAX; i++)
+ if (dat->fontInfo[i].fontHeight > dat->rowHeight)
+ dat->rowHeight = dat->fontInfo[i].fontHeight;
+}
diff --git a/plugins/Mwclist/clist_mw_10.vcxproj b/plugins/Mwclist/clist_mw_10.vcxproj
index 56a0059000..c7baad178d 100644
--- a/plugins/Mwclist/clist_mw_10.vcxproj
+++ b/plugins/Mwclist/clist_mw_10.vcxproj
@@ -86,7 +86,7 @@
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include\msapi;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>..\..\include;..\..\include\msapi;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
<AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -146,7 +146,7 @@
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include\msapi;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>..\..\include;..\..\include\msapi;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
<AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -194,38 +194,39 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="BkgrCfg.c" />
- <ClCompile Include="clc.c" />
- <ClCompile Include="clcidents.c" />
- <ClCompile Include="clcitems.c" />
- <ClCompile Include="clcopts.c" />
- <ClCompile Include="clcpaint.c" />
- <ClCompile Include="clcutils.c" />
- <ClCompile Include="clistmenus.c" />
- <ClCompile Include="clistmod.c" />
- <ClCompile Include="clistopts.c" />
- <ClCompile Include="clistsettings.c" />
- <ClCompile Include="clisttray.c" />
- <ClCompile Include="clui.c" />
- <ClCompile Include="cluiopts.c" />
- <ClCompile Include="cluiservices.c" />
- <ClCompile Include="commonheaders.c">
+ <ClCompile Include="BkgrCfg.cpp" />
+ <ClCompile Include="clc.cpp" />
+ <ClCompile Include="clcfonts.cpp" />
+ <ClCompile Include="clcidents.cpp" />
+ <ClCompile Include="clcitems.cpp" />
+ <ClCompile Include="clcopts.cpp" />
+ <ClCompile Include="clcpaint.cpp" />
+ <ClCompile Include="clcutils.cpp" />
+ <ClCompile Include="clistmenus.cpp" />
+ <ClCompile Include="clistmod.cpp" />
+ <ClCompile Include="clistopts.cpp" />
+ <ClCompile Include="clistsettings.cpp" />
+ <ClCompile Include="clisttray.cpp" />
+ <ClCompile Include="clui.cpp" />
+ <ClCompile Include="cluiopts.cpp" />
+ <ClCompile Include="cluiservices.cpp" />
+ <ClCompile Include="commonheaders.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
- <ClCompile Include="contact.c" />
- <ClCompile Include="groupmenu.c" />
- <ClCompile Include="init.c" />
- <ClCompile Include="keyboard.c" />
- <ClCompile Include="CLUIFrames\cluiframes.c">
+ <ClCompile Include="contact.cpp" />
+ <ClCompile Include="groupmenu.cpp" />
+ <ClCompile Include="init.cpp" />
+ <ClCompile Include="keyboard.cpp" />
+ <ClCompile Include="CLUIFrames\cluiframes.cpp">
<PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
- <ClCompile Include="CLUIFrames\extraimage.c">
+ <ClCompile Include="CLUIFrames\extraimage.cpp">
<PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
- <ClCompile Include="CLUIFrames\framesmenu.c">
+ <ClCompile Include="CLUIFrames\framesmenu.cpp">
<PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
- <ClCompile Include="CLUIFrames\statusbar.c">
+ <ClCompile Include="CLUIFrames\statusbar.cpp">
<PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
</ItemGroup>
@@ -235,7 +236,6 @@
<ClInclude Include="clist.h" />
<ClInclude Include="commonheaders.h" />
<ClInclude Include="resource.h" />
- <ClInclude Include="statusmodes.h" />
</ItemGroup>
<ItemGroup>
<None Include="res\1.ico" />
diff --git a/plugins/Mwclist/clist_mw_10.vcxproj.filters b/plugins/Mwclist/clist_mw_10.vcxproj.filters
index 58749e1b76..bf1d996a90 100644
--- a/plugins/Mwclist/clist_mw_10.vcxproj.filters
+++ b/plugins/Mwclist/clist_mw_10.vcxproj.filters
@@ -27,6 +27,9 @@
<ClCompile Include="clcidents.c">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="clcfonts.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
<ClCompile Include="clcitems.c">
<Filter>Source Files</Filter>
</ClCompile>
@@ -107,9 +110,6 @@
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="statusmodes.h">
- <Filter>Header Files</Filter>
- </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="res\1.ico">
diff --git a/plugins/Mwclist/clistmenus.c b/plugins/Mwclist/clistmenus.cpp
index 3d03b81b90..db84dca927 100644
--- a/plugins/Mwclist/clistmenus.c
+++ b/plugins/Mwclist/clistmenus.cpp
@@ -30,28 +30,27 @@ void DestroyTrayMenu(HMENU hMenu)
int i, cnt;
cnt = GetMenuItemCount(hMenu);
- for (i=0; i<cnt; ++i)
- {
- HMENU hSubMenu = GetSubMenu(hMenu, i);
- if (hSubMenu == hMainStatusMenu || hSubMenu == hMainMenu)
- RemoveMenu(hMenu, i--, MF_BYPOSITION);
- }
- DestroyMenu(hMenu);
+ for (i = 0; i<cnt; ++i) {
+ HMENU hSubMenu = GetSubMenu(hMenu, i);
+ if (hSubMenu == hMainStatusMenu || hSubMenu == hMainMenu)
+ RemoveMenu(hMenu, i--, MF_BYPOSITION);
+ }
+ DestroyMenu(hMenu);
}
INT_PTR CloseAction(WPARAM wParam,LPARAM lParam)
{
- if (CallService(MS_SYSTEM_OKTOEXIT,(WPARAM)0,(LPARAM)0))
+ if ( CallService(MS_SYSTEM_OKTOEXIT,(WPARAM)0,(LPARAM)0))
DestroyWindow(pcli->hwndContactList);
- return(0);
+ return 0;
}
int InitCustomMenus(void)
{
CreateServiceFunction("CloseAction",CloseAction);
- hMainStatusMenu = (HMENU)CallService(MS_CLIST_MENUGETSTATUS,0,0);
- hMainMenu = (HMENU)CallService(MS_CLIST_MENUGETMAIN,0,0);
+ hMainStatusMenu = (HMENU)CallService(MS_CLIST_MENUGETSTATUS,0,0);
+ hMainMenu = (HMENU)CallService(MS_CLIST_MENUGETMAIN,0,0);
return 0;
}
diff --git a/plugins/Mwclist/clistmod.c b/plugins/Mwclist/clistmod.cpp
index 962925d9aa..6551c8d03e 100644
--- a/plugins/Mwclist/clistmod.c
+++ b/plugins/Mwclist/clistmod.cpp
@@ -42,22 +42,22 @@ static HANDLE hSettingChanged, hProtoAckHook;
/////////// End by FYR ////////
int cli_IconFromStatusMode(const char *szProto,int nStatus, HANDLE hContact)
{
- int result=-1;
+ int result = -1;
if (hContact && szProto) {
- char * szActProto=(char*)szProto;
- char AdvancedService[255]={0};
- int nActStatus=nStatus;
- HANDLE hActContact=hContact;
+ char * szActProto = (char*)szProto;
+ char AdvancedService[255] = {0};
+ int nActStatus = nStatus;
+ HANDLE hActContact = hContact;
if (!DBGetContactSettingByte(NULL,"CLC","Meta",0) && !strcmp(szActProto,"MetaContacts")) {
// substitute params by mostonline contact datas
- HANDLE hMostOnlineContact=(HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT,(WPARAM)hActContact,0);
+ HANDLE hMostOnlineContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT,(WPARAM)hActContact,0);
if (hMostOnlineContact && hMostOnlineContact != (HANDLE)CALLSERVICE_NOTFOUND) {
pdisplayNameCacheEntry cacheEntry;
- cacheEntry=(pdisplayNameCacheEntry)pcli->pfnGetCacheEntry(hMostOnlineContact);
+ cacheEntry = (pdisplayNameCacheEntry)pcli->pfnGetCacheEntry(hMostOnlineContact);
if (cacheEntry && cacheEntry->szProto) {
- szActProto=cacheEntry->szProto;
- nActStatus=cacheEntry->status;
- hActContact=hMostOnlineContact;
+ szActProto = cacheEntry->szProto;
+ nActStatus = cacheEntry->status;
+ hActContact = hMostOnlineContact;
}
}
}
@@ -66,11 +66,11 @@ int cli_IconFromStatusMode(const char *szProto,int nStatus, HANDLE hContact)
if (ServiceExists(AdvancedService))
result = CallService(AdvancedService,(WPARAM)hActContact, (LPARAM)0);
- if (result==-1 || !(LOWORD(result)))
+ if (result == -1 || !(LOWORD(result)))
// result == -1 means no Advanced icon. LOWORD(result) == 0 happens when Advanced icon returned by ICQ (i.e. no transpot)
result = saveIconFromStatusMode(szActProto,nActStatus,NULL);
}
- else result=saveIconFromStatusMode(szProto,nStatus,NULL);
+ else result = saveIconFromStatusMode(szProto,nStatus,NULL);
return result;
}
@@ -83,10 +83,10 @@ int ExtIconFromStatusMode(HANDLE hContact, const char *szProto,int status)
if ( szProto != NULL ) {
if (strcmp(szProto,"MetaContacts") == 0 ) {
- hContact=(HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT,(UINT)hContact,0);
+ hContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT,(UINT)hContact,0);
if ( hContact != 0 ) {
- szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(UINT)hContact,0);
- status=DBGetContactSettingWord(hContact,szProto,"Status",ID_STATUS_OFFLINE);
+ szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(UINT)hContact,0);
+ status = DBGetContactSettingWord(hContact,szProto,"Status",ID_STATUS_OFFLINE);
}
}
}*/
@@ -98,8 +98,8 @@ int ExtIconFromStatusMode(HANDLE hContact, const char *szProto,int status)
static int ProtocolAck(WPARAM wParam,LPARAM lParam)
{
- ACKDATA *ack=(ACKDATA*)lParam;
- if (ack->type==ACKTYPE_AWAYMSG && ack->lParam) {
+ ACKDATA *ack = (ACKDATA*)lParam;
+ if (ack->type == ACKTYPE_AWAYMSG && ack->lParam) {
DBVARIANT dbv;
if (!DBGetContactSettingString(ack->hContact, "CList", "StatusMsg", &dbv)) {
if (!strcmp(dbv.pszVal, (char *)ack->lParam)) {
@@ -130,19 +130,19 @@ static int ContactListShutdownProc(WPARAM wParam,LPARAM lParam)
int LoadContactListModule(void)
{
HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
- while (hContact!=NULL) {
+ while (hContact != NULL) {
DBWriteContactSettingString(hContact, "CList", "StatusMsg", "");
hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
}
hCListImages = (HIMAGELIST)CallService(MS_CLIST_GETICONSIMAGELIST, 0, 0);
- DefaultImageListColorDepth=DBGetContactSettingDword(NULL,"CList","DefaultImageListColorDepth",ILC_COLOR32);
+ DefaultImageListColorDepth = DBGetContactSettingDword(NULL,"CList","DefaultImageListColorDepth",ILC_COLOR32);
hProtoAckHook = (HANDLE) HookEvent(ME_PROTO_ACK, ProtocolAck);
HookEvent(ME_OPT_INITIALISE,CListOptInit);
HookEvent(ME_SYSTEM_SHUTDOWN,ContactListShutdownProc);
- hSettingChanged=HookEvent(ME_DB_CONTACT_SETTINGCHANGED,ContactSettingChanged);
- hContactIconChangedEvent=CreateHookableEvent(ME_CLIST_CONTACTICONCHANGED);
+ hSettingChanged = HookEvent(ME_DB_CONTACT_SETTINGCHANGED,ContactSettingChanged);
+ hContactIconChangedEvent = CreateHookableEvent(ME_CLIST_CONTACTICONCHANGED);
CreateServiceFunction(MS_CLIST_CONTACTCHANGEGROUP,ContactChangeGroup);
CreateServiceFunction(MS_CLIST_HOTKEYSPROCESSMESSAGE,HotkeysProcessMessage);
CreateServiceFunction(MS_CLIST_GETSTATUSMODE, GetStatusMode);
diff --git a/plugins/Mwclist/clistopts.c b/plugins/Mwclist/clistopts.cpp
index 4be31595a5..947d68da69 100644
--- a/plugins/Mwclist/clistopts.c
+++ b/plugins/Mwclist/clistopts.cpp
@@ -32,22 +32,22 @@ void SortContacts(void);
static INT_PTR CALLBACK DlgProcGenOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-static UINT expertOnlyControls[]={IDC_ALWAYSSTATUS};
+static UINT expertOnlyControls[] = {IDC_ALWAYSSTATUS};
int CListOptInit(WPARAM wParam,LPARAM lParam)
{
OPTIONSDIALOGPAGE odp;
ZeroMemory(&odp,sizeof(odp));
- odp.cbSize=sizeof(odp);
- odp.position=-1000000000;
- odp.hInstance=g_hInst;
- odp.pszTemplate=MAKEINTRESOURCEA(IDD_OPT_CLIST);
- odp.pszTitle=LPGEN("Contact List");
- odp.pfnDlgProc=DlgProcGenOpts;
- odp.flags=ODPF_BOLDGROUPS;
- odp.nIDBottomSimpleControl=IDC_STCLISTGROUP;
- odp.expertOnlyControls=expertOnlyControls;
- odp.nExpertOnlyControls=sizeof(expertOnlyControls)/sizeof(expertOnlyControls[0]);
+ odp.cbSize = sizeof(odp);
+ odp.position = -1000000000;
+ odp.hInstance = g_hInst;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_CLIST);
+ odp.pszTitle = LPGEN("Contact List");
+ odp.pfnDlgProc = DlgProcGenOpts;
+ odp.flags = ODPF_BOLDGROUPS;
+ odp.nIDBottomSimpleControl = IDC_STCLISTGROUP;
+ odp.expertOnlyControls = expertOnlyControls;
+ odp.nExpertOnlyControls = sizeof(expertOnlyControls)/sizeof(expertOnlyControls[0]);
CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp);
return 0;
}
@@ -58,10 +58,10 @@ static INT_PTR CALLBACK DlgProcGenOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
{
case WM_USER+1:
{
- HANDLE hContact=(HANDLE)wParam;
+ HANDLE hContact = (HANDLE)wParam;
DBCONTACTWRITESETTING * ws = (DBCONTACTWRITESETTING *)lParam;
if ( hContact == NULL && ws != NULL && ws->szModule != NULL && ws->szSetting != NULL
- && lstrcmpiA(ws->szModule,"CList")==0 && lstrcmpiA(ws->szSetting,"UseGroups")==0
+ && lstrcmpiA(ws->szModule,"CList") == 0 && lstrcmpiA(ws->szSetting,"UseGroups") == 0
&& IsWindowVisible(hwndDlg) ) {
CheckDlgButton(hwndDlg,IDC_DISABLEGROUPS,ws->value.bVal == 0);
}
@@ -77,6 +77,12 @@ static INT_PTR CALLBACK DlgProcGenOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
TranslateDialogDefault(hwndDlg);
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)HookEventMessage(ME_DB_CONTACT_SETTINGCHANGED,hwndDlg,WM_USER+1));
+ CheckDlgButton(hwndDlg,IDC_GAMMACORRECT,DBGetContactSettingByte(NULL,"CLC","GammaCorrect",CLCDEFAULT_GAMMACORRECT)?BST_CHECKED:BST_UNCHECKED);
+
+ SendDlgItemMessage(hwndDlg,IDC_ROWHEIGHTSPIN,UDM_SETBUDDY,(WPARAM)GetDlgItem(hwndDlg,IDC_ROWHEIGHT),0);
+ SendDlgItemMessage(hwndDlg,IDC_ROWHEIGHTSPIN,UDM_SETRANGE,0,MAKELONG(255,0));
+ SendDlgItemMessage(hwndDlg,IDC_ROWHEIGHTSPIN,UDM_SETPOS,0,MAKELONG(DBGetContactSettingByte(NULL,"CLC","RowHeight",CLCDEFAULT_ROWHEIGHT),0));
+
CheckDlgButton(hwndDlg, IDC_ONTOP, DBGetContactSettingByte(NULL,"CList","OnTop",SETTING_ONTOP_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_HIDEOFFLINE, DBGetContactSettingByte(NULL,"CList","HideOffline",SETTING_HIDEOFFLINE_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_HIDEEMPTYGROUPS, DBGetContactSettingByte(NULL,"CList","HideEmptyGroups",SETTING_HIDEEMPTYGROUPS_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
@@ -93,11 +99,11 @@ static INT_PTR CALLBACK DlgProcGenOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
CheckDlgButton(hwndDlg, IDC_AUTOHIDE, DBGetContactSettingByte(NULL,"CList","AutoHide",SETTING_AUTOHIDE_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
EnableWindow(GetDlgItem(hwndDlg,IDC_HIDETIME),IsDlgButtonChecked(hwndDlg,IDC_AUTOHIDE));
EnableWindow(GetDlgItem(hwndDlg,IDC_HIDETIMESPIN),IsDlgButtonChecked(hwndDlg,IDC_AUTOHIDE));
- { DWORD caps=CallService(MS_CLUI_GETCAPS,CLUICAPS_FLAGS1,0);
+ { DWORD caps = CallService(MS_CLUI_GETCAPS,CLUICAPS_FLAGS1,0);
if (!(caps&CLUIF_HIDEEMPTYGROUPS)) ShowWindow(GetDlgItem(hwndDlg,IDC_HIDEEMPTYGROUPS),SW_HIDE);
if (!(caps&CLUIF_DISABLEGROUPS)) ShowWindow(GetDlgItem(hwndDlg,IDC_DISABLEGROUPS),SW_HIDE);
- if(caps&CLUIF_HASONTOPOPTION) ShowWindow(GetDlgItem(hwndDlg,IDC_ONTOP),SW_HIDE);
- if(caps&CLUIF_HASAUTOHIDEOPTION) {
+ if (caps&CLUIF_HASONTOPOPTION) ShowWindow(GetDlgItem(hwndDlg,IDC_ONTOP),SW_HIDE);
+ if (caps&CLUIF_HASAUTOHIDEOPTION) {
ShowWindow(GetDlgItem(hwndDlg,IDC_AUTOHIDE),SW_HIDE);
ShowWindow(GetDlgItem(hwndDlg,IDC_HIDETIME),SW_HIDE);
ShowWindow(GetDlgItem(hwndDlg,IDC_HIDETIMESPIN),SW_HIDE);
@@ -109,22 +115,22 @@ static INT_PTR CALLBACK DlgProcGenOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
CheckDlgButton(hwndDlg, IDC_ONECLK, DBGetContactSettingByte(NULL,"CList","Tray1Click",SETTING_TRAY1CLICK_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_ALWAYSSTATUS, DBGetContactSettingByte(NULL,"CList","AlwaysStatus",SETTING_ALWAYSSTATUS_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_ALWAYSMULTI, !DBGetContactSettingByte(NULL,"CList","AlwaysMulti",SETTING_ALWAYSMULTI_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_DONTCYCLE, DBGetContactSettingByte(NULL,"CList","TrayIcon",SETTING_TRAYICON_DEFAULT)==SETTING_TRAYICON_SINGLE ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CYCLE, DBGetContactSettingByte(NULL,"CList","TrayIcon",SETTING_TRAYICON_DEFAULT)==SETTING_TRAYICON_CYCLE ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_MULTITRAY, DBGetContactSettingByte(NULL,"CList","TrayIcon",SETTING_TRAYICON_DEFAULT)==SETTING_TRAYICON_MULTI ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_DONTCYCLE, DBGetContactSettingByte(NULL,"CList","TrayIcon",SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_SINGLE ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CYCLE, DBGetContactSettingByte(NULL,"CList","TrayIcon",SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_CYCLE ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_MULTITRAY, DBGetContactSettingByte(NULL,"CList","TrayIcon",SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_MULTI ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_DISABLEBLINK, DBGetContactSettingByte(NULL,"CList","DisableTrayFlash",0) == 1 ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_ICONBLINK, DBGetContactSettingByte(NULL,"CList","NoIconBlink",0) == 1 ? BST_CHECKED : BST_UNCHECKED );
- if(IsDlgButtonChecked(hwndDlg,IDC_DONTCYCLE)) {
+ if (IsDlgButtonChecked(hwndDlg,IDC_DONTCYCLE)) {
EnableWindow(GetDlgItem(hwndDlg,IDC_CYCLETIMESPIN),FALSE);
EnableWindow(GetDlgItem(hwndDlg,IDC_CYCLETIME),FALSE);
EnableWindow(GetDlgItem(hwndDlg,IDC_ALWAYSMULTI),FALSE);
}
- if(IsDlgButtonChecked(hwndDlg,IDC_CYCLE)) {
+ if (IsDlgButtonChecked(hwndDlg,IDC_CYCLE)) {
EnableWindow(GetDlgItem(hwndDlg,IDC_PRIMARYSTATUS),FALSE);
EnableWindow(GetDlgItem(hwndDlg,IDC_ALWAYSMULTI),FALSE);
}
- if(IsDlgButtonChecked(hwndDlg,IDC_MULTITRAY)) {
+ if (IsDlgButtonChecked(hwndDlg,IDC_MULTITRAY)) {
EnableWindow(GetDlgItem(hwndDlg,IDC_CYCLETIMESPIN),FALSE);
EnableWindow(GetDlgItem(hwndDlg,IDC_CYCLETIME),FALSE);
EnableWindow(GetDlgItem(hwndDlg,IDC_PRIMARYSTATUS),FALSE);
@@ -133,42 +139,53 @@ static INT_PTR CALLBACK DlgProcGenOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
SendDlgItemMessage(hwndDlg,IDC_CYCLETIMESPIN,UDM_SETPOS,0,MAKELONG(DBGetContactSettingWord(NULL,"CList","CycleTime",SETTING_CYCLETIME_DEFAULT),0));
{ int i,count,item;
PROTOACCOUNT **accs;
- DBVARIANT dbv={DBVT_DELETED};
+ DBVARIANT dbv = {DBVT_DELETED};
DBGetContactSettingString(NULL,"CList","PrimaryStatus",&dbv);
ProtoEnumAccounts( &count, &accs );
- item=SendDlgItemMessage(hwndDlg,IDC_PRIMARYSTATUS,CB_ADDSTRING,0,(LPARAM)TranslateT("Global"));
+ item = SendDlgItemMessage(hwndDlg,IDC_PRIMARYSTATUS,CB_ADDSTRING,0,(LPARAM)TranslateT("Global"));
SendDlgItemMessage(hwndDlg,IDC_PRIMARYSTATUS,CB_SETITEMDATA,item,(LPARAM)0);
- for ( i=0; i < count; i++ ) {
+ for ( i = 0; i < count; i++ ) {
if ( !IsAccountEnabled( accs[i] ) || CallProtoService( accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0 ) == 0 )
continue;
- item=SendDlgItemMessage(hwndDlg,IDC_PRIMARYSTATUS,CB_ADDSTRING,0,(LPARAM)accs[i]->tszAccountName);
+ item = SendDlgItemMessage(hwndDlg,IDC_PRIMARYSTATUS,CB_ADDSTRING,0,(LPARAM)accs[i]->tszAccountName);
SendDlgItemMessage(hwndDlg,IDC_PRIMARYSTATUS,CB_SETITEMDATA,item,(LPARAM)accs[i] );
if ( dbv.type == DBVT_ASCIIZ && !lstrcmpA( dbv.pszVal, accs[i]->szModuleName ))
SendDlgItemMessage(hwndDlg,IDC_PRIMARYSTATUS,CB_SETCURSEL,item,0);
}
}
- if (-1==(int)SendDlgItemMessage(hwndDlg,IDC_PRIMARYSTATUS,CB_GETCURSEL,0,0))
+ if (-1 == (int)SendDlgItemMessage(hwndDlg,IDC_PRIMARYSTATUS,CB_GETCURSEL,0,0))
SendDlgItemMessage(hwndDlg,IDC_PRIMARYSTATUS,CB_SETCURSEL,0,0);
SendDlgItemMessage(hwndDlg,IDC_BLINKSPIN,UDM_SETBUDDY,(WPARAM)GetDlgItem(hwndDlg,IDC_BLINKTIME),0); // set buddy
SendDlgItemMessage(hwndDlg,IDC_BLINKSPIN,UDM_SETRANGE,0,MAKELONG(0x3FFF,250));
SendDlgItemMessage(hwndDlg,IDC_BLINKSPIN,UDM_SETPOS,0,MAKELONG(DBGetContactSettingWord(NULL,"CList","IconFlashTime",550),0));
return TRUE;
+ case WM_VSCROLL:
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
case WM_COMMAND:
- if(LOWORD(wParam)==IDC_AUTOHIDE) {
- EnableWindow(GetDlgItem(hwndDlg,IDC_HIDETIME),IsDlgButtonChecked(hwndDlg,IDC_AUTOHIDE));
- EnableWindow(GetDlgItem(hwndDlg,IDC_HIDETIMESPIN),IsDlgButtonChecked(hwndDlg,IDC_AUTOHIDE));
- }
- if(LOWORD(wParam)==IDC_DONTCYCLE || LOWORD(wParam)==IDC_CYCLE || LOWORD(wParam)==IDC_MULTITRAY) {
- EnableWindow(GetDlgItem(hwndDlg,IDC_PRIMARYSTATUS),IsDlgButtonChecked(hwndDlg,IDC_DONTCYCLE));
- EnableWindow(GetDlgItem(hwndDlg,IDC_CYCLETIME),IsDlgButtonChecked(hwndDlg,IDC_CYCLE));
- EnableWindow(GetDlgItem(hwndDlg,IDC_CYCLETIMESPIN),IsDlgButtonChecked(hwndDlg,IDC_CYCLE));
- EnableWindow(GetDlgItem(hwndDlg,IDC_ALWAYSMULTI),IsDlgButtonChecked(hwndDlg,IDC_MULTITRAY));
+ switch (LOWORD(wParam)) {
+ case IDC_AUTOHIDE:
+ EnableWindow(GetDlgItem(hwndDlg,IDC_HIDETIME),IsDlgButtonChecked(hwndDlg,IDC_AUTOHIDE));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_HIDETIMESPIN),IsDlgButtonChecked(hwndDlg,IDC_AUTOHIDE));
+ break;
+ case IDC_DONTCYCLE:
+ case IDC_CYCLE:
+ case IDC_MULTITRAY:
+ EnableWindow(GetDlgItem(hwndDlg,IDC_PRIMARYSTATUS),IsDlgButtonChecked(hwndDlg,IDC_DONTCYCLE));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_CYCLETIME),IsDlgButtonChecked(hwndDlg,IDC_CYCLE));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_CYCLETIMESPIN),IsDlgButtonChecked(hwndDlg,IDC_CYCLE));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_ALWAYSMULTI),IsDlgButtonChecked(hwndDlg,IDC_MULTITRAY));
+ break;
+ case IDC_ROWHEIGHT:
+ if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) return 0;
+ break;
}
- if ((LOWORD(wParam)==IDC_HIDETIME || LOWORD(wParam)==IDC_CYCLETIME) && HIWORD(wParam)!=EN_CHANGE) break;
- if(LOWORD(wParam)==IDC_PRIMARYSTATUS && HIWORD(wParam)!=CBN_SELCHANGE) break;
- if ((LOWORD(wParam)==IDC_HIDETIME || LOWORD(wParam)==IDC_CYCLETIME) && (HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus())) return 0;
- if (LOWORD(wParam)==IDC_BLINKTIME && HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) return 0; // dont make apply enabled during buddy set crap
+ if ((LOWORD(wParam) == IDC_HIDETIME || LOWORD(wParam) == IDC_CYCLETIME) && HIWORD(wParam) != EN_CHANGE) break;
+ if (LOWORD(wParam) == IDC_PRIMARYSTATUS && HIWORD(wParam) != CBN_SELCHANGE) break;
+ if ((LOWORD(wParam) == IDC_HIDETIME || LOWORD(wParam) == IDC_CYCLETIME) && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return 0;
+ if (LOWORD(wParam) == IDC_BLINKTIME && HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) return 0; // dont make apply enabled during buddy set crap
+
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case WM_NOTIFY:
@@ -178,9 +195,9 @@ static INT_PTR CALLBACK DlgProcGenOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
{
case PSN_APPLY:
DBWriteContactSettingByte(NULL,"CList","HideOffline",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_HIDEOFFLINE));
- { DWORD caps=CallService(MS_CLUI_GETCAPS,CLUICAPS_FLAGS1,0);
- if(caps&CLUIF_HIDEEMPTYGROUPS) DBWriteContactSettingByte(NULL,"CList","HideEmptyGroups",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_HIDEEMPTYGROUPS));
- if(caps&CLUIF_DISABLEGROUPS) DBWriteContactSettingByte(NULL,"CList","UseGroups",(BYTE)!IsDlgButtonChecked(hwndDlg,IDC_DISABLEGROUPS));
+ { DWORD caps = CallService(MS_CLUI_GETCAPS,CLUICAPS_FLAGS1,0);
+ if (caps&CLUIF_HIDEEMPTYGROUPS) DBWriteContactSettingByte(NULL,"CList","HideEmptyGroups",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_HIDEEMPTYGROUPS));
+ if (caps&CLUIF_DISABLEGROUPS) DBWriteContactSettingByte(NULL,"CList","UseGroups",(BYTE)!IsDlgButtonChecked(hwndDlg,IDC_DISABLEGROUPS));
if (!(caps&CLUIF_HASONTOPOPTION)) {
DBWriteContactSettingByte(NULL,"CList","OnTop",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_ONTOP));
SetWindowPos(pcli->hwndContactList,IsDlgButtonChecked(hwndDlg,IDC_ONTOP)?HWND_TOPMOST:HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
@@ -193,6 +210,8 @@ static INT_PTR CALLBACK DlgProcGenOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
DBWriteContactSettingByte(NULL,"CList","SortByStatus",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_SORTBYSTATUS));
DBWriteContactSettingByte(NULL,"CList","SortByProto",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_SORTBYPROTO));
DBWriteContactSettingByte(NULL,"CList","NoOfflineBottom",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_NOOFFLINEMOVE));
+ DBWriteContactSettingByte(NULL,"CLC","RowHeight",(BYTE)SendDlgItemMessage(hwndDlg,IDC_ROWHEIGHTSPIN,UDM_GETPOS,0,0));
+ DBWriteContactSettingByte(NULL,"CLC","GammaCorrect",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_GAMMACORRECT));
DBWriteContactSettingByte(NULL,"CList","ConfirmDelete",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_CONFIRMDELETE));
DBWriteContactSettingByte(NULL,"CList","Tray1Click",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_ONECLK));
diff --git a/plugins/Mwclist/clistsettings.c b/plugins/Mwclist/clistsettings.cpp
index ba3ef3befa..6f135387b7 100644
--- a/plugins/Mwclist/clistsettings.c
+++ b/plugins/Mwclist/clistsettings.cpp
@@ -43,19 +43,19 @@ void InitDisplayNameCache(SortedList *list)
HANDLE hContact;
memset(list,0,sizeof(SortedList));
- list->sortFunc=handleCompare;
- list->increment=CallService(MS_DB_CONTACT_GETCOUNT,0,0)+1;
+ list->sortFunc = (FSortFunc)handleCompare;
+ list->increment = CallService(MS_DB_CONTACT_GETCOUNT,0,0)+1;
- hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0);
- i=0;
- while (hContact!=0)
+ hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0);
+ i = 0;
+ while (hContact != 0)
{
- displayNameCacheEntry *pdnce = mir_calloc(sizeof(displayNameCacheEntry));
+ displayNameCacheEntry *pdnce = (pdisplayNameCacheEntry)mir_calloc(sizeof(displayNameCacheEntry));
pdnce->hContact = hContact;
InvalidateDisplayNameCacheEntryByPDNE(hContact,pdnce,0);
li.List_GetIndex(list,pdnce,&idx);
li.List_Insert(list,pdnce,idx);
- hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0);
+ hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0);
i++;
} }
@@ -74,8 +74,8 @@ void FreeDisplayNameCache(SortedList *list)
{
int i;
- for ( i=0; i < list->realCount; i++) {
- FreeDisplayNameCacheItem(list->items[i] );
+ for ( i = 0; i < list->realCount; i++) {
+ FreeDisplayNameCacheItem((ClcCacheEntryBase*)list->items[i] );
mir_free(list->items[i]);
}
@@ -89,16 +89,16 @@ void CheckPDNCE(ClcCacheEntryBase *_pdnce)
return;
if (pdnce->szProto == NULL && pdnce->protoNotExists == FALSE) {
- pdnce->szProto=GetProtoForContact(pdnce->hContact);
+ pdnce->szProto = GetProtoForContact(pdnce->hContact);
if (pdnce->szProto == NULL)
- pdnce->protoNotExists=FALSE;
+ pdnce->protoNotExists = FALSE;
else {
if (CallService(MS_PROTO_ISPROTOCOLLOADED,0,(LPARAM)pdnce->szProto) == 0)
- pdnce->protoNotExists=TRUE;
+ pdnce->protoNotExists = TRUE;
else {
if ( pdnce->szProto && pdnce->name ) {
mir_free(pdnce->name);
- pdnce->name=NULL;
+ pdnce->name = NULL;
} } } }
if (pdnce->name == NULL)
@@ -107,16 +107,16 @@ void CheckPDNCE(ClcCacheEntryBase *_pdnce)
pdnce->name = mir_tstrdup(TranslateT("_NoProtocol_"));
else {
if (OnModulesLoadedCalled)
- pdnce->name=GetNameForContact(pdnce->hContact,0,&pdnce->isUnknown);
+ pdnce->name = GetNameForContact(pdnce->hContact,0,&pdnce->isUnknown);
else
- pdnce->name=GetNameForContact(pdnce->hContact,0,NULL);
+ pdnce->name = GetNameForContact(pdnce->hContact,0,NULL);
}
}
else {
if (pdnce->isUnknown&&pdnce->szProto&&pdnce->protoNotExists == TRUE&&OnModulesLoadedCalled) {
- pdnce->protoNotExists=FALSE;
+ pdnce->protoNotExists = FALSE;
mir_free(pdnce->name);
- pdnce->name=GetNameForContact(pdnce->hContact,0,&pdnce->isUnknown);
+ pdnce->name = GetNameForContact(pdnce->hContact,0,&pdnce->isUnknown);
} }
if (pdnce->status == 0)
@@ -135,22 +135,22 @@ void CheckPDNCE(ClcCacheEntryBase *_pdnce)
}
if (pdnce->Hidden == -1)
- pdnce->Hidden=DBGetContactSettingByte(pdnce->hContact,"CList","Hidden",0);
+ pdnce->Hidden = DBGetContactSettingByte(pdnce->hContact,"CList","Hidden",0);
if (pdnce->noHiddenOffline == -1)
- pdnce->noHiddenOffline=DBGetContactSettingByte(pdnce->hContact,"CList","noOffline",0);
+ pdnce->noHiddenOffline = DBGetContactSettingByte(pdnce->hContact,"CList","noOffline",0);
if ( pdnce->IdleTS == -1 )
pdnce->IdleTS = DBGetContactSettingDword(pdnce->hContact,pdnce->szProto,"IdleTS",0);
if (pdnce->ApparentMode == -1)
- pdnce->ApparentMode=DBGetContactSettingWord(pdnce->hContact,pdnce->szProto,"ApparentMode",0);
+ pdnce->ApparentMode = DBGetContactSettingWord(pdnce->hContact,pdnce->szProto,"ApparentMode",0);
if (pdnce->NotOnList == -1)
- pdnce->NotOnList=DBGetContactSettingByte(pdnce->hContact,"CList","NotOnList",0);
+ pdnce->NotOnList = DBGetContactSettingByte(pdnce->hContact,"CList","NotOnList",0);
if (pdnce->IsExpanded == -1)
- pdnce->IsExpanded=DBGetContactSettingByte(pdnce->hContact,"CList","Expanded",0);
+ pdnce->IsExpanded = DBGetContactSettingByte(pdnce->hContact,"CList","Expanded",0);
}
void InvalidateDisplayNameCacheEntryByPDNE(HANDLE hContact,pdisplayNameCacheEntry pdnce,int SettingType)
@@ -161,45 +161,45 @@ void InvalidateDisplayNameCacheEntryByPDNE(HANDLE hContact,pdisplayNameCacheEntr
if ( SettingType == -1 || SettingType == DBVT_DELETED )
{
mir_free(pdnce->name);
- pdnce->name=NULL;
+ pdnce->name = NULL;
mir_free(pdnce->szGroup);
- pdnce->szGroup=NULL;
+ pdnce->szGroup = NULL;
- pdnce->Hidden=-1;
- pdnce->protoNotExists=FALSE;
+ pdnce->Hidden = -1;
+ pdnce->protoNotExists = FALSE;
mir_free(pdnce->szProto);
- pdnce->szProto=NULL;
- pdnce->status=0;
- pdnce->IdleTS=-1;
- pdnce->ApparentMode=-1;
- pdnce->NotOnList=-1;
- pdnce->isUnknown=FALSE;
- pdnce->noHiddenOffline=-1;
- pdnce->IsExpanded=-1;
+ pdnce->szProto = NULL;
+ pdnce->status = 0;
+ pdnce->IdleTS = -1;
+ pdnce->ApparentMode = -1;
+ pdnce->NotOnList = -1;
+ pdnce->isUnknown = FALSE;
+ pdnce->noHiddenOffline = -1;
+ pdnce->IsExpanded = -1;
return;
}
if (SettingType >= DBVT_WCHAR)
{
mir_free(pdnce->name);
- pdnce->name=NULL;
+ pdnce->name = NULL;
mir_free(pdnce->szGroup);
- pdnce->szGroup=NULL;
+ pdnce->szGroup = NULL;
mir_free(pdnce->szProto);
- pdnce->szProto=NULL;
+ pdnce->szProto = NULL;
return;
}
// in other cases clear all binary cache
- pdnce->Hidden=-1;
- pdnce->protoNotExists=FALSE;
- pdnce->status=0;
- pdnce->IdleTS=-1;
- pdnce->ApparentMode=-1;
- pdnce->NotOnList=-1;
- pdnce->isUnknown=FALSE;
- pdnce->noHiddenOffline=-1;
- pdnce->IsExpanded=-1;
+ pdnce->Hidden = -1;
+ pdnce->protoNotExists = FALSE;
+ pdnce->status = 0;
+ pdnce->IdleTS = -1;
+ pdnce->ApparentMode = -1;
+ pdnce->NotOnList = -1;
+ pdnce->isUnknown = FALSE;
+ pdnce->noHiddenOffline = -1;
+ pdnce->IsExpanded = -1;
}
char *GetContactCachedProtocol(HANDLE hContact)
@@ -217,13 +217,13 @@ char *GetProtoForContact(HANDLE hContact)
DBCONTACTGETSETTING dbcgs;
char name[32];
- dbv.type=DBVT_ASCIIZ;
- dbv.pszVal=name;
- dbv.cchVal=SIZEOF(name);
- dbcgs.pValue=&dbv;
- dbcgs.szModule="Protocol";
- dbcgs.szSetting="p";
- if(CallService(MS_DB_CONTACT_GETSETTINGSTATIC,(WPARAM)hContact,(LPARAM)&dbcgs)) return NULL;
+ dbv.type = DBVT_ASCIIZ;
+ dbv.pszVal = name;
+ dbv.cchVal = SIZEOF(name);
+ dbcgs.pValue = &dbv;
+ dbcgs.szModule = "Protocol";
+ dbcgs.szSetting = "p";
+ if (CallService(MS_DB_CONTACT_GETSETTINGSTATIC,(WPARAM)hContact,(LPARAM)&dbcgs)) return NULL;
return mir_strdup(dbcgs.pValue->pszVal);
}
@@ -253,29 +253,29 @@ TCHAR* GetNameForContact(HANDLE hContact,int flag,boolean *isUnknown)
pdisplayNameCacheEntry GetContactFullCacheEntry(HANDLE hContact)
{
pdisplayNameCacheEntry cacheEntry = (pdisplayNameCacheEntry)pcli->pfnGetCacheEntry(hContact);
- if (cacheEntry!=NULL)
+ if (cacheEntry != NULL)
return(cacheEntry);
- return (NULL);
+ return NULL;
}
int GetContactInfosForSort(HANDLE hContact,char **Proto,TCHAR **Name,int *Status)
{
pdisplayNameCacheEntry cacheEntry = (pdisplayNameCacheEntry)pcli->pfnGetCacheEntry(hContact);
- if (cacheEntry!=NULL)
+ if (cacheEntry != NULL)
{
- if (Proto!=NULL) *Proto = cacheEntry->szProto;
- if (Name!=NULL) *Name = cacheEntry->name;
- if (Status!=NULL) *Status = cacheEntry->status;
+ if (Proto != NULL) *Proto = cacheEntry->szProto;
+ if (Name != NULL) *Name = cacheEntry->name;
+ if (Status != NULL) *Status = cacheEntry->status;
}
- return (0);
+ return 0;
}
int GetContactCachedStatus(HANDLE hContact)
{
pdisplayNameCacheEntry cacheEntry = (pdisplayNameCacheEntry)pcli->pfnGetCacheEntry(hContact);
- if (cacheEntry&&cacheEntry->status!=0) return cacheEntry->status;
- return (0);
+ if (cacheEntry&&cacheEntry->status != 0) return cacheEntry->status;
+ return 0;
}
int ContactSettingChanged(WPARAM wParam,LPARAM lParam)
@@ -296,7 +296,7 @@ int ContactSettingChanged(WPARAM wParam,LPARAM lParam)
return 0;
}
- if (pdnce&&(pdnce->protoNotExists == FALSE)&&pdnce->szProto)
+ if (pdnce && pdnce->protoNotExists == FALSE && pdnce->szProto)
{
if (!strcmp(cws->szModule,pdnce->szProto))
{
@@ -305,7 +305,7 @@ int ContactSettingChanged(WPARAM wParam,LPARAM lParam)
if (cws->value.type == DBVT_WORD&&!strcmp(cws->szSetting, "Status")) {
if (!(pdnce->Hidden == 1)) {
- if(DBGetContactSettingByte((HANDLE)NULL,"CList","ShowStatusMsg",0)||DBGetContactSettingByte((HANDLE)wParam,"CList","StatusMsgAuto",0))
+ if (DBGetContactSettingByte((HANDLE)NULL,"CList","ShowStatusMsg",0)||DBGetContactSettingByte((HANDLE)wParam,"CList","StatusMsgAuto",0))
DBWriteContactSettingString((HANDLE)wParam, "CList", "StatusMsg", "");
if (DBGetContactSettingByte(NULL, "CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT)) {
@@ -340,7 +340,7 @@ int ContactSettingChanged(WPARAM wParam,LPARAM lParam)
*/
//name is null or (setting is myhandle)
- if(pdnce->name == NULL||(!strcmp(cws->szSetting,"MyHandle")) )
+ if (pdnce->name == NULL||(!strcmp(cws->szSetting,"MyHandle")) )
InvalidateDisplayNameCacheEntryByPDNE((HANDLE)wParam,pdnce,cws->value.type);
if ((!strcmp(cws->szSetting,"Group")) )
@@ -348,8 +348,8 @@ int ContactSettingChanged(WPARAM wParam,LPARAM lParam)
if (!strcmp(cws->szSetting,"Hidden")) {
InvalidateDisplayNameCacheEntryByPDNE((HANDLE)wParam,pdnce,cws->value.type);
- if(cws->value.type == DBVT_DELETED || cws->value.bVal == 0) {
- char *szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0);
+ if (cws->value.type == DBVT_DELETED || cws->value.bVal == 0) {
+ char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0);
ChangeContactIcon((HANDLE)wParam,ExtIconFromStatusMode((HANDLE)wParam,szProto,szProto == NULL?ID_STATUS_OFFLINE:DBGetContactSettingWord((HANDLE)wParam,szProto,"Status",ID_STATUS_OFFLINE)),1); //by FYR
} }
@@ -363,8 +363,8 @@ int ContactSettingChanged(WPARAM wParam,LPARAM lParam)
OutputDebugStringA("CHANGE: proto\r\n");
InvalidateDisplayNameCacheEntryByPDNE((HANDLE)wParam,pdnce,cws->value.type);
- if(cws->value.type == DBVT_DELETED) szProto=NULL;
- else szProto=cws->value.pszVal;
+ if (cws->value.type == DBVT_DELETED) szProto = NULL;
+ else szProto = cws->value.pszVal;
ChangeContactIcon((HANDLE)wParam,ExtIconFromStatusMode((HANDLE)wParam,szProto,szProto == NULL?ID_STATUS_OFFLINE:DBGetContactSettingWord((HANDLE)wParam,szProto,"Status",ID_STATUS_OFFLINE)),0); //by FYR
}
}
diff --git a/plugins/Mwclist/clisttray.c b/plugins/Mwclist/clisttray.cpp
index 0147aa4517..9112d74a1f 100644
--- a/plugins/Mwclist/clisttray.c
+++ b/plugins/Mwclist/clisttray.cpp
@@ -31,7 +31,7 @@ void DestroyTrayMenu(HMENU hMenu);
INT_PTR TrayIconProcessMessage(WPARAM wParam,LPARAM lParam)
{
- MSG *msg=(MSG*)wParam;
+ MSG *msg = (MSG*)wParam;
switch(msg->message) {
case WM_DRAWITEM:
return CallService(MS_CLIST_MENUDRAWITEM,msg->wParam,msg->lParam);
@@ -43,7 +43,7 @@ INT_PTR TrayIconProcessMessage(WPARAM wParam,LPARAM lParam)
if (msg->lParam == WM_RBUTTONUP)
{
POINT pt;
- HMENU hMenu=(HMENU)CallService(MS_CLIST_MENUBUILDTRAY,(WPARAM)0,(LPARAM)0);
+ HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDTRAY,(WPARAM)0,(LPARAM)0);
SetForegroundWindow(msg->hwnd);
SetFocus(msg->hwnd);
@@ -53,7 +53,7 @@ INT_PTR TrayIconProcessMessage(WPARAM wParam,LPARAM lParam)
}
else break;
- *((LRESULT*)lParam)=0;
+ *((LRESULT*)lParam) = 0;
return TRUE;
}
@@ -75,7 +75,7 @@ INT_PTR Param1;
}TrayMenuExecParam,*lpTrayMenuExecParam;
/*
-wparam=handle to the menu item returned by MS_CLIST_ADDCONTACTMENUITEM
+wparam = handle to the menu item returned by MS_CLIST_ADDCONTACTMENUITEM
return 0 on success.
*/
static INT_PTR RemoveTrayMenuItem(WPARAM wParam,LPARAM lParam)
@@ -89,89 +89,90 @@ static INT_PTR BuildTrayMenu(WPARAM wParam,LPARAM lParam)
int tick;
HMENU hMenu;
ListParam param = { 0 };
- param.MenuObjectHandle=hTrayMenuObject;
+ param.MenuObjectHandle = hTrayMenuObject;
- //hMenu=hMainMenu;
- hMenu=CreatePopupMenu();
- //hMenu=wParam;
- tick=GetTickCount();
+ //hMenu = hMainMenu;
+ hMenu = CreatePopupMenu();
+ //hMenu = wParam;
+ tick = GetTickCount();
NotifyEventHooks(hPreBuildTrayMenuEvent,0,0);
CallService(MO_BUILDMENU,(WPARAM)hMenu,(LPARAM)&param);
//DrawMenuBar((HWND)CallService("CLUI/GetHwnd",0,0));
- tick=GetTickCount()-tick;
+ tick = GetTickCount()-tick;
return (INT_PTR)hMenu;
}
static INT_PTR AddTrayMenuItem(WPARAM wParam,LPARAM lParam)
{
- CLISTMENUITEM *mi=(CLISTMENUITEM*)lParam;
+ CLISTMENUITEM *mi = (CLISTMENUITEM*)lParam;
TMO_MenuItem tmi;
OptParam op;
- if(mi->cbSize!=sizeof(CLISTMENUITEM)) return 0;
+ if (mi->cbSize != sizeof(CLISTMENUITEM)) return 0;
memset(&tmi,0,sizeof(tmi));
- tmi.cbSize=sizeof(tmi);
- tmi.flags=mi->flags;
- tmi.hIcon=mi->hIcon;
- tmi.hotKey=mi->hotKey;
- tmi.pszName=mi->pszName;
- tmi.position=mi->position;
+ tmi.cbSize = sizeof(tmi);
+ tmi.flags = mi->flags;
+ tmi.hIcon = mi->hIcon;
+ tmi.hotKey = mi->hotKey;
+ tmi.pszName = mi->pszName;
+ tmi.position = mi->position;
//pszPopupName for new system mean root level
//pszPopupName for old system mean that exists popup
- tmi.root=(HGENMENU)mi->pszPopupName;
+ tmi.root = (HGENMENU)mi->pszPopupName;
- tmi.ownerdata=NULL;
+ tmi.ownerdata = NULL;
{
lpTrayMenuExecParam mmep;
- mmep=(lpTrayMenuExecParam)mir_alloc(sizeof(TrayMenuExecParam));
- if(mmep==NULL){return(0);}
+ mmep = (lpTrayMenuExecParam)mir_alloc(sizeof(TrayMenuExecParam));
+ if (mmep == NULL)
+ return 0;
//we need just one parametr.
mmep->szServiceName = mir_strdup(mi->pszService);
mmep->Param1 = mi->popupPosition;
- tmi.ownerdata=mmep;
+ tmi.ownerdata = mmep;
}
- op.Handle=(HANDLE)CallService(MO_ADDNEWMENUITEM,(WPARAM)hTrayMenuObject,(LPARAM)&tmi);
- op.Setting=OPT_MENUITEMSETUNIQNAME;
- op.Value=(INT_PTR)mi->pszService;
+ op.Handle = (HANDLE)CallService(MO_ADDNEWMENUITEM,(WPARAM)hTrayMenuObject,(LPARAM)&tmi);
+ op.Setting = OPT_MENUITEMSETUNIQNAME;
+ op.Value = (INT_PTR)mi->pszService;
CallService(MO_SETOPTIONSMENUITEM,(WPARAM)0,(LPARAM)&op);
return (INT_PTR)op.Handle;
}
INT_PTR TrayMenuCheckService(WPARAM wParam,LPARAM lParam)
{
- return(0);
+ return 0;
}
INT_PTR TrayMenuonAddService(WPARAM wParam,LPARAM lParam)
{
- MENUITEMINFO *mii=(MENUITEMINFO* )wParam;
- if (mii==NULL) return 0;
+ MENUITEMINFO *mii = (MENUITEMINFO* )wParam;
+ if (mii == NULL) return 0;
- if (hHideShowMainMenuItem==(HANDLE)lParam)
+ if (hHideShowMainMenuItem == (HANDLE)lParam)
{
mii->fMask|=MIIM_STATE;
mii->fState|=MFS_DEFAULT;
}
- if (hTrayMainMenuItemProxy==(HANDLE)lParam)
+ if (hTrayMainMenuItemProxy == (HANDLE)lParam)
{
mii->fMask|=MIIM_SUBMENU;
- //mi.fType=MFT_STRING;
- mii->hSubMenu=(HMENU)CallService(MS_CLIST_MENUGETMAIN,0,0);
+ //mi.fType = MFT_STRING;
+ mii->hSubMenu = (HMENU)CallService(MS_CLIST_MENUGETMAIN,0,0);
}
- if (hTrayStatusMenuItemProxy==(HANDLE)lParam)
+ if (hTrayStatusMenuItemProxy == (HANDLE)lParam)
{
mii->fMask|=MIIM_SUBMENU;
- //mi.fType=MFT_STRING;
- mii->hSubMenu=(HMENU)CallService(MS_CLIST_MENUGETSTATUS,0,0);
+ //mi.fType = MFT_STRING;
+ mii->hSubMenu = (HMENU)CallService(MS_CLIST_MENUGETSTATUS,0,0);
}
return(TRUE);
@@ -182,13 +183,13 @@ INT_PTR TrayMenuonAddService(WPARAM wParam,LPARAM lParam)
//wparam - ownerdata
//lparam - lparam from winproc
INT_PTR TrayMenuExecService(WPARAM wParam,LPARAM lParam) {
- if (wParam!=0)
+ if (wParam != 0)
{
- lpTrayMenuExecParam mmep=(lpTrayMenuExecParam)wParam;
+ lpTrayMenuExecParam mmep = (lpTrayMenuExecParam)wParam;
if (!strcmp(mmep->szServiceName,"Help/AboutCommand"))
{
//bug in help.c,it used wparam as parent window handle without reason.
- mmep->Param1=0;
+ mmep->Param1 = 0;
}
CallService(mmep->szServiceName,mmep->Param1,lParam);
}
@@ -199,17 +200,15 @@ INT_PTR FreeOwnerDataTrayMenu (WPARAM wParam,LPARAM lParam)
{
lpTrayMenuExecParam mmep;
- mmep=(lpTrayMenuExecParam)lParam;
- if (mmep!=NULL){
- FreeAndNil(&mmep->szServiceName);
- FreeAndNil(&mmep);
+ mmep = (lpTrayMenuExecParam)lParam;
+ if (mmep != NULL){
+ FreeAndNil((void**)&mmep->szServiceName);
+ FreeAndNil((void**)&mmep);
}
- return(0);
+ return 0;
}
-HANDLE hPreBuildTrayMenuEvent;
-
void InitTrayMenus(void)
{
TMenuParam tmp;
@@ -217,11 +216,11 @@ void InitTrayMenus(void)
//Tray menu
memset(&tmp,0,sizeof(tmp));
- tmp.cbSize=sizeof(tmp);
- tmp.CheckService=NULL;
- tmp.ExecService="CLISTMENUSTRAY/ExecService";
- tmp.name="Tray Menu";
- hTrayMenuObject=(HANDLE)CallService(MO_CREATENEWMENUOBJECT,(WPARAM)0,(LPARAM)&tmp);
+ tmp.cbSize = sizeof(tmp);
+ tmp.CheckService = NULL;
+ tmp.ExecService = "CLISTMENUSTRAY/ExecService";
+ tmp.name = "TrayMenu";
+ hTrayMenuObject = (HANDLE)CallService(MO_CREATENEWMENUOBJECT,(WPARAM)0,(LPARAM)&tmp);
CreateServiceFunction("CLISTMENUSTRAY/ExecService",TrayMenuExecService);
CreateServiceFunction("CLISTMENUSTRAY/FreeOwnerDataTrayMenu",FreeOwnerDataTrayMenu);
@@ -230,21 +229,21 @@ void InitTrayMenus(void)
CreateServiceFunction(MS_CLIST_ADDTRAYMENUITEM,AddTrayMenuItem);
CreateServiceFunction(MS_CLIST_REMOVETRAYMENUITEM,RemoveTrayMenuItem);
CreateServiceFunction(MS_CLIST_MENUBUILDTRAY,BuildTrayMenu);
- hPreBuildTrayMenuEvent=CreateHookableEvent(ME_CLIST_PREBUILDTRAYMENU);
+ hPreBuildTrayMenuEvent = CreateHookableEvent(ME_CLIST_PREBUILDTRAYMENU);
- op.Handle=hTrayMenuObject;
- op.Setting=OPT_USERDEFINEDITEMS;
- op.Value=TRUE;
+ op.Handle = hTrayMenuObject;
+ op.Setting = OPT_USERDEFINEDITEMS;
+ op.Value = TRUE;
CallService(MO_SETOPTIONSMENUOBJECT,(WPARAM)0,(LPARAM)&op);
- op.Handle=hTrayMenuObject;
- op.Setting=OPT_MENUOBJECT_SET_FREE_SERVICE;
- op.Value=(INT_PTR)"CLISTMENUSTRAY/FreeOwnerDataTrayMenu";
+ op.Handle = hTrayMenuObject;
+ op.Setting = OPT_MENUOBJECT_SET_FREE_SERVICE;
+ op.Value = (INT_PTR)"CLISTMENUSTRAY/FreeOwnerDataTrayMenu";
CallService(MO_SETOPTIONSMENUOBJECT,(WPARAM)0,(LPARAM)&op);
- op.Handle=hTrayMenuObject;
- op.Setting=OPT_MENUOBJECT_SET_ONADD_SERVICE;
- op.Value=(INT_PTR)"CLISTMENUSTRAY/TrayMenuonAddService";
+ op.Handle = hTrayMenuObject;
+ op.Setting = OPT_MENUOBJECT_SET_ONADD_SERVICE;
+ op.Value = (INT_PTR)"CLISTMENUSTRAY/TrayMenuonAddService";
CallService(MO_SETOPTIONSMENUOBJECT,(WPARAM)0,(LPARAM)&op);
{
@@ -252,54 +251,54 @@ void InitTrayMenus(void)
CLISTMENUITEM mi;
memset(&mi,0,sizeof(mi));
- mi.cbSize=sizeof(mi);
- mi.position=900000;
- mi.pszService="CloseAction";
- mi.pszName=LPGEN("E&xit");
+ mi.cbSize = sizeof(mi);
+ mi.position = 900000;
+ mi.pszService = "CloseAction";
+ mi.pszName = LPGEN("E&xit");
AddTrayMenuItem((WPARAM)0,(LPARAM)&mi);
memset(&mi,0,sizeof(mi));
- mi.cbSize=sizeof(mi);
- mi.position=100000;
- mi.pszService=MS_CLIST_SHOWHIDE;
- mi.pszName=LPGEN("&Hide/Show");
- hHideShowMainMenuItem=(HANDLE)AddTrayMenuItem((WPARAM)0,(LPARAM)&mi);
+ mi.cbSize = sizeof(mi);
+ mi.position = 100000;
+ mi.pszService = MS_CLIST_SHOWHIDE;
+ mi.pszName = LPGEN("&Hide/Show");
+ hHideShowMainMenuItem = (HANDLE)AddTrayMenuItem((WPARAM)0,(LPARAM)&mi);
memset(&mi,0,sizeof(mi));
- mi.cbSize=sizeof(mi);
- mi.position=200000;
- mi.hIcon=LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_FINDUSER));
- mi.pszService="FindAdd/FindAddCommand";
- mi.pszName=LPGEN("&Find/Add Contacts...");
+ mi.cbSize = sizeof(mi);
+ mi.position = 200000;
+ mi.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_FINDUSER));
+ mi.pszService = "FindAdd/FindAddCommand";
+ mi.pszName = LPGEN("&Find/Add Contacts...");
AddTrayMenuItem((WPARAM)0,(LPARAM)&mi);
memset(&mi,0,sizeof(mi));
- mi.cbSize=sizeof(mi);
- mi.position=300000;
- mi.pszService="";
- mi.pszName=LPGEN("&Main Menu");
- hTrayMainMenuItemProxy=(HANDLE)AddTrayMenuItem((WPARAM)0,(LPARAM)&mi);
+ mi.cbSize = sizeof(mi);
+ mi.position = 300000;
+ mi.pszService = "";
+ mi.pszName = LPGEN("&Main Menu");
+ hTrayMainMenuItemProxy = (HANDLE)AddTrayMenuItem((WPARAM)0,(LPARAM)&mi);
memset(&mi,0,sizeof(mi));
- mi.cbSize=sizeof(mi);
- mi.position=300100;
- mi.pszService="";
- mi.pszName=LPGEN("&Status");
- hTrayStatusMenuItemProxy=(HANDLE)AddTrayMenuItem((WPARAM)0,(LPARAM)&mi);
+ mi.cbSize = sizeof(mi);
+ mi.position = 300100;
+ mi.pszService = "";
+ mi.pszName = LPGEN("&Status");
+ hTrayStatusMenuItemProxy = (HANDLE)AddTrayMenuItem((WPARAM)0,(LPARAM)&mi);
memset(&mi,0,sizeof(mi));
- mi.cbSize=sizeof(mi);
- mi.position=400000;
- mi.hIcon=LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_OPTIONS));
- mi.pszService="Options/OptionsCommand";
- mi.pszName=LPGEN("&Options...");
+ mi.cbSize = sizeof(mi);
+ mi.position = 400000;
+ mi.hIcon = LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_OPTIONS));
+ mi.pszService = "Options/OptionsCommand";
+ mi.pszName = LPGEN("&Options...");
AddTrayMenuItem((WPARAM)0,(LPARAM)&mi);
memset(&mi,0,sizeof(mi));
- mi.cbSize=sizeof(mi);
- mi.position=500000;
- mi.hIcon=LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_CLIENTMIRANDA));
- mi.pszService="Help/AboutCommand";
- mi.pszName=LPGEN("&About");
+ mi.cbSize = sizeof(mi);
+ mi.position = 500000;
+ mi.hIcon = LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_CLIENTMIRANDA));
+ mi.pszService = "Help/AboutCommand";
+ mi.pszName = LPGEN("&About");
AddTrayMenuItem((WPARAM)0,(LPARAM)&mi);
} }
diff --git a/plugins/Mwclist/clui.c b/plugins/Mwclist/clui.cpp
index d770e3547f..f8a820bca6 100644
--- a/plugins/Mwclist/clui.c
+++ b/plugins/Mwclist/clui.cpp
@@ -31,16 +31,16 @@ extern int DefaultImageListColorDepth;
static HMODULE hUserDll;
HMENU hMenuMain;
static HANDLE hContactDraggingEvent,hContactDroppedEvent,hContactDragStopEvent;
-UINT hMsgGetProfile=0;
+UINT hMsgGetProfile = 0;
extern boolean canloadstatusbar;
-boolean OnModulesLoadedCalled=FALSE;
+boolean OnModulesLoadedCalled = FALSE;
-HANDLE hSettingChangedHook=0;
+HANDLE hSettingChangedHook = 0;
-static int transparentFocus=1;
+static int transparentFocus = 1;
static byte oldhideoffline;
-static int lastreqh=0,requr=0,disableautoupd=1;
+static int lastreqh = 0,requr = 0,disableautoupd = 1;
HANDLE hFrameContactTree;
BYTE showOpts;//for statusbar
@@ -54,16 +54,17 @@ int TimerCreated;
ProtoTicks CycleStartTick[64];//max 64 protocols
-int CycleTimeInterval=2000;
-int CycleIconCount=8;
-int DefaultStep=100;
+int CycleTimeInterval = 2000;
+int CycleIconCount = 8;
+int DefaultStep = 100;
BOOL (WINAPI *MySetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD);
BOOL (WINAPI *MyAnimateWindow)(HWND hWnd,DWORD dwTime,DWORD dwFlags);
int CluiOptInit(WPARAM wParam,LPARAM lParam);
int SortList(WPARAM wParam,LPARAM lParam);
-int CluiProtocolStatusChanged(WPARAM wParam,LPARAM lParam);
+
+void CluiProtocolStatusChanged(int parStatus, const char* szProto);
extern void SetAllExtraIcons(HWND hwndList,HANDLE hContact);
extern void ReloadExtraIcons();
@@ -90,20 +91,20 @@ static int CluiModulesLoaded(WPARAM wParam,LPARAM lParam)
{
MENUITEMINFO mii;
ZeroMemory(&mii,sizeof(mii));
- mii.cbSize=MENUITEMINFO_V4_SIZE;
- mii.fMask=MIIM_SUBMENU;
- mii.hSubMenu=(HMENU)CallService(MS_CLIST_MENUGETMAIN,0,0);
+ mii.cbSize = MENUITEMINFO_V4_SIZE;
+ mii.fMask = MIIM_SUBMENU;
+ mii.hSubMenu = (HMENU)CallService(MS_CLIST_MENUGETMAIN,0,0);
SetMenuItemInfo(hMenuMain,0,TRUE,&mii);
- mii.hSubMenu=(HMENU)CallService(MS_CLIST_MENUGETSTATUS,0,0);
+ mii.hSubMenu = (HMENU)CallService(MS_CLIST_MENUGETSTATUS,0,0);
SetMenuItemInfo(hMenuMain,1,TRUE,&mii);
- canloadstatusbar=TRUE;
+ canloadstatusbar = TRUE;
SendMessage(pcli->hwndContactList,WM_SIZE,0,0);
CluiProtocolStatusChanged(0,0);
Sleep(0);
PostMessage(pcli->hwndContactList,M_CREATECLC,0,0);
- OnModulesLoadedCalled=TRUE;
+ OnModulesLoadedCalled = TRUE;
pcli->pfnInvalidateDisplayNameCacheEntry(INVALID_HANDLE_VALUE);
InitGroupMenus();
RegisterProtoIconsForAllProtoIconLib();
@@ -114,23 +115,23 @@ pProtoTicks GetProtoTicksByProto(char * szProto)
{
int i;
- for (i=0;i<64;i++)
+ for (i = 0;i<64;i++)
{
- if (CycleStartTick[i].szProto==NULL) break;
+ if (CycleStartTick[i].szProto == NULL) break;
if (strcmp(CycleStartTick[i].szProto,szProto)) continue;
return(&CycleStartTick[i]);
}
- for (i=0;i<64;i++)
+ for (i = 0;i<64;i++)
{
- if (CycleStartTick[i].szProto==NULL)
+ if (CycleStartTick[i].szProto == NULL)
{
- CycleStartTick[i].szProto=mir_strdup(szProto);
- CycleStartTick[i].CycleStartTick=0;
- CycleStartTick[i].n=i;
+ CycleStartTick[i].szProto = mir_strdup(szProto);
+ CycleStartTick[i].CycleStartTick = 0;
+ CycleStartTick[i].n = i;
return(&CycleStartTick[i]);
}
}
- return (NULL);
+ return NULL;
}
int GetConnectingIconForProtoCount(char *szProto)
@@ -141,14 +142,14 @@ int GetConnectingIconForProtoCount(char *szProto)
int ret;
GetModuleFileNameA(GetModuleHandle(NULL), szPath, MAX_PATH);
- str=strrchr(szPath,'\\');
- if(str!=NULL) *str=0;
+ str = strrchr(szPath,'\\');
+ if (str != NULL) *str = 0;
_snprintf(szFullPath, SIZEOF(szFullPath), "%s\\Icons\\proto_conn_%s.dll", szPath, szProto);
lstrcpynA(file,szFullPath,SIZEOF(file));
CallService(MS_UTILS_PATHTOABSOLUTE, (WPARAM)file, (LPARAM)fileFull);
- ret=ExtractIconExA(fileFull,-1,NULL,NULL,1);
- if (ret==0&&!strcmp(szProto,"ICQ")) ret=8;
+ ret = ExtractIconExA(fileFull,-1,NULL,NULL,1);
+ if (ret == 0&&!strcmp(szProto,"ICQ")) ret = 8;
return ret;
}
@@ -164,9 +165,9 @@ static HICON ExtractIconFromPath(const char *path)
// OutputDebugStringA(buf);
}
lstrcpynA(file,path,SIZEOF(file));
- comma=strrchr(file,',');
- if(comma==NULL) n=0;
- else {n=atoi(comma+1); *comma=0;}
+ comma = strrchr(file,',');
+ if (comma == NULL) n = 0;
+ else {n = atoi(comma+1); *comma = 0;}
CallService(MS_UTILS_PATHTOABSOLUTE, (WPARAM)file, (LPARAM)fileFull);
#ifdef _DEBUG
@@ -177,7 +178,7 @@ static HICON ExtractIconFromPath(const char *path)
}
#endif
- hIcon=NULL;
+ hIcon = NULL;
ExtractIconExA(fileFull,n,NULL,&hIcon,1);
return hIcon;
}
@@ -185,41 +186,41 @@ static HICON ExtractIconFromPath(const char *path)
HICON LoadIconFromExternalFile(char *filename,int i,boolean UseLibrary,boolean registerit,char *IconName,char *SectName,char *Description,int internalidx,HICON DefIcon)
{
char szPath[MAX_PATH],szMyPath[MAX_PATH], szFullPath[MAX_PATH],*str;
- HICON hIcon=NULL;
- SKINICONDESC sid={0};
+ HICON hIcon = NULL;
+ SKINICONDESC sid = {0};
memset(szMyPath,0,SIZEOF(szMyPath));
memset(szFullPath,0,SIZEOF(szFullPath));
- if (filename!=NULL)
+ if (filename != NULL)
{
GetModuleFileNameA(GetModuleHandle(NULL), szPath, MAX_PATH);
GetModuleFileNameA(g_hInst, szMyPath, MAX_PATH);
- str=strrchr(szPath,'\\');
- if(str!=NULL) *str=0;
+ str = strrchr(szPath,'\\');
+ if (str != NULL) *str = 0;
_snprintf(szFullPath, SIZEOF(szFullPath), "%s\\Icons\\%s,%d", szPath, filename, i);
}
if (!UseLibrary||!ServiceExists(MS_SKIN2_ADDICON))
{
- hIcon=ExtractIconFromPath(szFullPath);
+ hIcon = ExtractIconFromPath(szFullPath);
if (hIcon) return hIcon;
}
else
{
- if (registerit&&IconName!=NULL&&SectName!=NULL)
+ if (registerit&&IconName != NULL&&SectName != NULL)
{
sid.cbSize = sizeof(sid);
sid.pszSection = SectName;
- sid.pszName=IconName;
+ sid.pszName = IconName;
sid.pszDescription = Description;
- if (strlen(szMyPath)!=0)
+ if (strlen(szMyPath) != 0)
{
- sid.pszDefaultFile=szMyPath;
+ sid.pszDefaultFile = szMyPath;
}
- sid.iDefaultIndex=internalidx;
- sid.hDefaultIcon=DefIcon;
+ sid.iDefaultIndex = internalidx;
+ sid.hDefaultIcon = DefIcon;
CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
{
@@ -241,7 +242,7 @@ void RegisterProtoIcons (char *protoname)
int i;
char buf[256];
char buf2[256];
- for (i=0;i<8;i++)
+ for (i = 0;i<8;i++)
{
sprintf(buf,"%s #%d",protoname,i);
sprintf(buf2,"Contact List/Connection Icons %s",protoname);
@@ -257,7 +258,7 @@ void RegisterProtoIconsForAllProtoIconLib()
PROTOACCOUNT **accs;
ProtoEnumAccounts( &protoCount, &accs );
- for ( i=0; i < protoCount; i++ )
+ for ( i = 0; i < protoCount; i++ )
if ( IsAccountEnabled( accs[i] ) && CallProtoService( accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0 ))
RegisterProtoIcons( accs[i]->szModuleName );
}
@@ -265,14 +266,14 @@ void RegisterProtoIconsForAllProtoIconLib()
HICON GetConnectingIconForProto_DLL(char *szProto,int b)
{
char szFullPath[MAX_PATH];
- HICON hIcon=NULL;
+ HICON hIcon = NULL;
- b=b-1;
+ b = b-1;
_snprintf(szFullPath, SIZEOF(szFullPath), "proto_conn_%s.dll",szProto);
- // hIcon=ExtractIconFromPath(szFullPath);
+ // hIcon = ExtractIconFromPath(szFullPath);
// if (hIcon) return hIcon;
- hIcon=LoadIconFromExternalFile(szFullPath,b+1,FALSE,FALSE,NULL,NULL,NULL,0,0);
+ hIcon = LoadIconFromExternalFile(szFullPath,b+1,FALSE,FALSE,NULL,NULL,NULL,0,0);
if (hIcon) return hIcon;
#ifdef _DEBUG
@@ -299,42 +300,35 @@ HICON GetConnectingIconForProto_DLL(char *szProto,int b)
HICON GetConnectingIconForProto(char *szProto,int b)
{
- if (ServiceExists(MS_SKIN2_GETICON)&&DBGetContactSettingByte(NULL,"CList","UseProtoIconFromIcoLib",1))
- {
- HICON hIcon=0;
- char buf[256];
- sprintf(buf,"%s #%d",szProto,b);
-
- hIcon=LoadIconFromExternalFile(NULL,b,TRUE,FALSE,buf,"Contact List/Connection Icons",buf,0,NULL);
- if (hIcon==NULL) return (GetConnectingIconForProto_DLL(szProto,b));
- return (CopyIcon(hIcon));
-
- }else
- {
- return(GetConnectingIconForProto_DLL(szProto,b));
- }
- return (NULL);
-}
-
-
+ if (ServiceExists(MS_SKIN2_GETICON)&&DBGetContactSettingByte(NULL,"CList","UseProtoIconFromIcoLib",1)) {
+ HICON hIcon = 0;
+ char buf[256];
+ sprintf(buf,"%s #%d",szProto,b);
+ hIcon = LoadIconFromExternalFile(NULL,b,TRUE,FALSE,buf,"Contact List/Connection Icons",buf,0,NULL);
+ if (hIcon == NULL) return (GetConnectingIconForProto_DLL(szProto,b));
+ return (CopyIcon(hIcon));
+ }
+
+ return GetConnectingIconForProto_DLL(szProto, b);
+}
-//wParam = szProto
+//wParam == szProto
INT_PTR GetConnectingIconService(WPARAM wParam,LPARAM lParam)
{
int b;
- ProtoTicks *pt=NULL;
- HICON hIcon=NULL;
+ ProtoTicks *pt = NULL;
+ HICON hIcon = NULL;
- char *szProto=(char *)wParam;
+ char *szProto = (char *)wParam;
if (!szProto) return 0;
- pt=GetProtoTicksByProto(szProto);
+ pt = GetProtoTicksByProto(szProto);
- if (pt!=NULL) {
- if (pt->CycleStartTick!=0&&pt->IconsCount!=0) {
- b=((GetTickCount()-pt->CycleStartTick)/(DefaultStep))%pt->IconsCount;
- hIcon=GetConnectingIconForProto(szProto,b);
+ if (pt != NULL) {
+ if (pt->CycleStartTick != 0&&pt->IconsCount != 0) {
+ b = ((GetTickCount()-pt->CycleStartTick)/(DefaultStep))%pt->IconsCount;
+ hIcon = GetConnectingIconForProto(szProto,b);
}
}
@@ -343,104 +337,84 @@ INT_PTR GetConnectingIconService(WPARAM wParam,LPARAM lParam)
int CreateTimerForConnectingIcon(WPARAM wParam,LPARAM lParam)
{
- int status=(int)wParam;
- char *szProto=(char *)lParam;
- if (!szProto) return (0);
- if (!status) return (0);
+ int status = (int)wParam;
+ char *szProto = (char *)lParam;
+ if (!szProto) return 0;
+ if (!status) return 0;
- if ((DBGetContactSettingByte(NULL,"CLUI","UseConnectingIcon",1)==1)&&status>=ID_STATUS_CONNECTING&&status<=ID_STATUS_CONNECTING+MAX_CONNECT_RETRIES)
- {
- ProtoTicks *pt=NULL;
+ if (( DBGetContactSettingByte(NULL,"CLUI","UseConnectingIcon",1) == 1) && status >= ID_STATUS_CONNECTING && status <= ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES) {
+ ProtoTicks *pt = NULL;
int cnt;
- pt=GetProtoTicksByProto(szProto);
- if (pt!=NULL)
- {
- if (pt->CycleStartTick==0)
- {
- // sprintf(buf,"SetTimer %d\r\n",pt->n);
- // OutputDebugStringA(buf);
-
+ pt = GetProtoTicksByProto(szProto);
+ if (pt != NULL) {
+ if (pt->CycleStartTick == 0) {
KillTimer(pcli->hwndContactList,TM_STATUSBARUPDATE+pt->n);
- cnt=GetConnectingIconForProtoCount(szProto);
+ cnt = GetConnectingIconForProtoCount(szProto);
if (ServiceExists(MS_SKIN2_GETICON)&&DBGetContactSettingByte(NULL,"Clist","UseProtoIconFromIcoLib",1))
- {
- cnt=8;
- }
+ cnt = 8;
- if (cnt!=0)
- {
- DefaultStep=DBGetContactSettingWord(NULL,"CLUI","DefaultStepConnectingIcon",100);
- pt->IconsCount=cnt;
+ if (cnt != 0) {
+ DefaultStep = DBGetContactSettingWord(NULL,"CLUI","DefaultStepConnectingIcon",100);
+ pt->IconsCount = cnt;
SetTimer(pcli->hwndContactList,TM_STATUSBARUPDATE+pt->n,(int)(DefaultStep)/1,0);
- pt->TimerCreated=1;
- pt->CycleStartTick=GetTickCount();
+ pt->TimerCreated = 1;
+ pt->CycleStartTick = GetTickCount();
}
}
}
}
return 0;
}
+
// Restore protocols to the last global status.
// Used to reconnect on restore after standby.
int OnSettingChanging(WPARAM wParam,LPARAM lParam)
{
- DBCONTACTWRITESETTING *dbcws=(DBCONTACTWRITESETTING *)lParam;
- if (wParam==0)
- {
- if ((dbcws->value.type==DBVT_BYTE)&&!strcmp(dbcws->szModule,"CLUI"))
- {
- if (!strcmp(dbcws->szSetting,"SBarShow"))
- {
- showOpts=dbcws->value.bVal;
- return(0);
+ DBCONTACTWRITESETTING *dbcws = (DBCONTACTWRITESETTING *)lParam;
+ if (wParam == 0) {
+ if ((dbcws->value.type == DBVT_BYTE)&&!strcmp(dbcws->szModule,"CLUI")) {
+ if (!strcmp(dbcws->szSetting,"SBarShow")) {
+ showOpts = dbcws->value.bVal;
+ return 0;
}
}
}
- else
- {
- if (dbcws==NULL){return(0);}
+ else {
+ if (dbcws == NULL)
+ return 0;
- if (!ServiceExists("ExtraIcon/Register"))
- {
- if (dbcws->value.type==DBVT_ASCIIZ&&!strcmp(dbcws->szSetting,"e-mail"))
- {
+ if ( !ServiceExists("ExtraIcon/Register")) {
+ if (dbcws->value.type == DBVT_ASCIIZ&&!strcmp(dbcws->szSetting,"e-mail")) {
SetAllExtraIcons(pcli->hwndContactTree,(HANDLE)wParam);
- return(0);
+ return 0;
}
- if (dbcws->value.type==DBVT_ASCIIZ&&!strcmp(dbcws->szSetting,"Cellular"))
- {
+ if (dbcws->value.type == DBVT_ASCIIZ&&!strcmp(dbcws->szSetting,"Cellular")) {
SetAllExtraIcons(pcli->hwndContactTree,(HANDLE)wParam);
- return(0);
+ return 0;
}
- if (dbcws->value.type==DBVT_ASCIIZ&&strstr(dbcws->szModule,"ICQ"))
- {
- if (!strcmp(dbcws->szSetting,(HANDLE)"MirVer"))
- {
+ if (dbcws->value.type == DBVT_ASCIIZ&&strstr(dbcws->szModule,"ICQ")) {
+ if ( !strcmp(dbcws->szSetting, "MirVer")) {
SetAllExtraIcons(pcli->hwndContactTree,(HANDLE)wParam);
- return(0);
+ return 0;
}
-
}
- if (dbcws->value.type==DBVT_ASCIIZ&&!strcmp(dbcws->szModule,"UserInfo"))
- {
- if (!strcmp(dbcws->szSetting,(HANDLE)"MyPhone0"))
- {
+ if (dbcws->value.type == DBVT_ASCIIZ&&!strcmp(dbcws->szModule,"UserInfo")) {
+ if ( !strcmp(dbcws->szSetting, "MyPhone0")) {
SetAllExtraIcons(pcli->hwndContactTree,(HANDLE)wParam);
- return(0);
+ return 0;
}
- if (!strcmp(dbcws->szSetting,(HANDLE)"Mye-mail0"))
- {
+ if (!strcmp(dbcws->szSetting, "Mye-mail0")) {
SetAllExtraIcons(pcli->hwndContactTree,(HANDLE)wParam);
- return(0);
+ return 0;
}
}
}
}
- return(0);
+ return 0;
}
HWND PreCreateCLC(HWND parent)
@@ -466,65 +440,65 @@ int CreateCLC(HWND parent)
// create contact list frame
CLISTFrame Frame;
memset(&Frame,0,sizeof(Frame));
- Frame.cbSize=sizeof(CLISTFrame);
- Frame.hWnd=pcli->hwndContactTree;
- Frame.align=alClient;
- Frame.hIcon=LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
+ Frame.cbSize = sizeof(CLISTFrame);
+ Frame.hWnd = pcli->hwndContactTree;
+ Frame.align = alClient;
+ Frame.hIcon = LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
//LoadIcon(hInst,MAKEINTRESOURCE(IDI_MIRANDA));
- Frame.Flags=F_VISIBLE|F_SHOWTB|F_SHOWTBTIP|F_TCHAR;
- Frame.tname=_T("My Contacts");
- Frame.TBtname=TranslateT("My Contacts");
- hFrameContactTree=(HWND)CallService(MS_CLIST_FRAMES_ADDFRAME,(WPARAM)&Frame,(LPARAM)0);
+ Frame.Flags = F_VISIBLE|F_SHOWTB|F_SHOWTBTIP|F_TCHAR;
+ Frame.tname = _T("My Contacts");
+ Frame.TBtname = TranslateT("My Contacts");
+ hFrameContactTree = (HWND)CallService(MS_CLIST_FRAMES_ADDFRAME,(WPARAM)&Frame,(LPARAM)0);
//free(Frame.name);
CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_TBTIPNAME,hFrameContactTree),(LPARAM)TranslateT("My Contacts"));
}
ReloadExtraIcons();
{
- lastreqh=0;
+ lastreqh = 0;
{
CallService(MS_CLIST_SETHIDEOFFLINE,(WPARAM)oldhideoffline,0);
}
- { int state=DBGetContactSettingByte(NULL,"CList","State",SETTING_STATE_NORMAL);
- if(state==SETTING_STATE_NORMAL) ShowWindow(pcli->hwndContactList, SW_SHOW);
- else if(state==SETTING_STATE_MINIMIZED) ShowWindow(pcli->hwndContactList, SW_SHOWMINIMIZED);
+ { int state = DBGetContactSettingByte(NULL,"CList","State",SETTING_STATE_NORMAL);
+ if (state == SETTING_STATE_NORMAL) ShowWindow(pcli->hwndContactList, SW_SHOW);
+ else if (state == SETTING_STATE_MINIMIZED) ShowWindow(pcli->hwndContactList, SW_SHOWMINIMIZED);
}
- lastreqh=0;
- disableautoupd=0;
+ lastreqh = 0;
+ disableautoupd = 0;
}
- hSettingChangedHook=HookEvent(ME_DB_CONTACT_SETTINGCHANGED,OnSettingChanging);
- return(0);
+ hSettingChangedHook = HookEvent(ME_DB_CONTACT_SETTINGCHANGED,OnSettingChanging);
+ return 0;
}
int GetStatsuBarProtoRect(HWND hwnd,char *szProto,RECT *rc)
{
int nParts,nPanel;
ProtocolData *PD;
- int startoffset=DBGetContactSettingDword(NULL,"StatusBar","FirstIconOffset",0);
+ int startoffset = DBGetContactSettingDword(NULL,"StatusBar","FirstIconOffset",0);
- if (!UseOwnerDrawStatusBar) startoffset=0;
+ if (!UseOwnerDrawStatusBar) startoffset = 0;
- nParts=SendMessage(hwnd,SB_GETPARTS,0,0);
+ nParts = SendMessage(hwnd,SB_GETPARTS,0,0);
FillMemory(rc,sizeof(RECT),0);
- for (nPanel=0;nPanel<nParts;nPanel++)
+ for (nPanel = 0;nPanel<nParts;nPanel++)
{
- PD=(ProtocolData *)SendMessage(pcli->hwndStatus,SB_GETTEXT,(WPARAM)nPanel,(LPARAM)0);
+ PD = (ProtocolData *)SendMessage(pcli->hwndStatus,SB_GETTEXT,(WPARAM)nPanel,(LPARAM)0);
if ( PD == NULL )
- return(0);
+ return 0;
if (!strcmp(szProto,PD->RealName))
{
SendMessage(hwnd,SB_GETRECT,(WPARAM)nPanel,(LPARAM)rc);
- rc->left+=startoffset;
- rc->right+=startoffset;
- return(0);
+ rc->left += startoffset;
+ rc->right += startoffset;
+ return 0;
}
}
- return (0);
+ return 0;
}
extern LRESULT ( CALLBACK *saveContactListWndProc )(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
@@ -538,22 +512,23 @@ LRESULT CALLBACK ContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
The caller is expected to create this mapping object and tell us the ID we need to open ours.
*/
- if (msg==hMsgGetProfile && wParam != 0) { /* got IPC message */
+
+ if (msg == hMsgGetProfile && wParam != 0) { /* got IPC message */
HANDLE hMap;
char szName[MAX_PATH];
- int rc=0;
+ int rc = 0;
_snprintf(szName,SIZEOF(szName),"Miranda::%u", wParam); // caller will tell us the ID of the map
hMap = OpenFileMappingA(FILE_MAP_ALL_ACCESS,FALSE,szName);
if (hMap != NULL) {
- void *hView=NULL;
- hView=MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, MAX_PATH);
+ void *hView = NULL;
+ hView = MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, MAX_PATH);
if (hView) {
char szFilePath[MAX_PATH], szProfile[MAX_PATH];
CallService(MS_DB_GETPROFILEPATH,MAX_PATH,(LPARAM)&szFilePath);
CallService(MS_DB_GETPROFILENAME,MAX_PATH,(LPARAM)&szProfile);
- _snprintf(hView,MAX_PATH,"%s\\%s",szFilePath,szProfile);
+ _snprintf((char*)hView, MAX_PATH, "%s\\%s", szFilePath, szProfile);
UnmapViewOfFile(hView);
- rc=1;
+ rc = 1;
}
CloseHandle(hMap);
}
@@ -564,10 +539,10 @@ LRESULT CALLBACK ContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
case WM_CREATE:
CallService(MS_LANGPACK_TRANSLATEMENU,(WPARAM)GetMenu(hwnd),0);
DrawMenuBar(hwnd);
- showOpts=DBGetContactSettingByte(NULL,"CLUI","SBarShow",1);
+ showOpts = DBGetContactSettingByte(NULL,"CLUI","SBarShow",1);
//create the status wnd
- //pcli->hwndStatus = CreateStatusWindow(WS_CHILD | (DBGetContactSettingByte(NULL,"CLUI","ShowSBar",1)?WS_VISIBLE:0), "", hwnd, 0);
+ //pcli->hwndStatus == CreateStatusWindow(WS_CHILD | (DBGetContactSettingByte(NULL,"CLUI","ShowSBar",1)?WS_VISIBLE:0), "", hwnd, 0);
CluiProtocolStatusChanged(0,0);
hMsgGetProfile = RegisterWindowMessageA( "Miranda::GetProfile" ); // don't localise
@@ -577,7 +552,7 @@ LRESULT CALLBACK ContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
if ( MySetLayeredWindowAttributes )
MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), (BYTE)DBGetContactSettingByte(NULL,"CList","Alpha",SETTING_ALPHA_DEFAULT), LWA_ALPHA);
}
- transparentFocus=1;
+ transparentFocus = 1;
return FALSE;
case M_SETALLEXTRAICONS:
@@ -627,26 +602,26 @@ LRESULT CALLBACK ContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
if ((int)wParam>=TM_STATUSBARUPDATE&&(int)wParam<=TM_STATUSBARUPDATE+64) {
int status,i;
- ProtoTicks *pt=NULL;
- for (i=0;i<64;i++) {
- pt=&CycleStartTick[i];
- if (pt->szProto!=NULL&&pt->TimerCreated==1) {
- status=CallProtoService(pt->szProto,PS_GETSTATUS,0,0);
+ ProtoTicks *pt = NULL;
+ for (i = 0;i<64;i++) {
+ pt = &CycleStartTick[i];
+ if (pt->szProto != NULL&&pt->TimerCreated == 1) {
+ status = CallProtoService(pt->szProto,PS_GETSTATUS,0,0);
if (!(status>=ID_STATUS_CONNECTING&&status<=ID_STATUS_CONNECTING+MAX_CONNECT_RETRIES))
{
- pt->CycleStartTick=0;
+ pt->CycleStartTick = 0;
KillTimer(hwnd,TM_STATUSBARUPDATE+pt->n);
- pt->TimerCreated=0;
+ pt->TimerCreated = 0;
} } }
- pt=&CycleStartTick[wParam-TM_STATUSBARUPDATE];
+ pt = &CycleStartTick[wParam-TM_STATUSBARUPDATE];
{
RECT rc;
GetStatsuBarProtoRect(pcli->hwndStatus,pt->szProto,&rc);
- rc.right=rc.left+GetSystemMetrics(SM_CXSMICON)+1;
- rc.top=0;
+ rc.right = rc.left+GetSystemMetrics(SM_CXSMICON)+1;
+ rc.top = 0;
- if(IsWindowVisible(pcli->hwndStatus)) InvalidateRect(pcli->hwndStatus,&rc,TRUE);
+ if (IsWindowVisible(pcli->hwndStatus)) InvalidateRect(pcli->hwndStatus,&rc,TRUE);
pcli->pfnTrayIconUpdateBase(pt->szProto);
}
//SendMessage(pcli->hwndStatus,WM_PAINT,0,0);
@@ -668,14 +643,14 @@ LRESULT CALLBACK ContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
}
case WM_KEYDOWN:
CallService(MS_CLIST_MENUPROCESSHOTKEY,wParam,MPCF_MAINMENU|MPCF_CONTACTMENU);
- if (wParam==VK_F5)
+ if (wParam == VK_F5)
SendMessage(pcli->hwndContactTree,CLM_AUTOREBUILD,0,0);
return TRUE;
case WM_GETMINMAXINFO:
DefWindowProc(hwnd,msg,wParam,lParam);
- ((LPMINMAXINFO)lParam)->ptMinTrackSize.x=18;
- if (requr==0){((LPMINMAXINFO)lParam)->ptMinTrackSize.y=CLUIFramesGetMinHeight();}
+ ((LPMINMAXINFO)lParam)->ptMinTrackSize.x = 18;
+ if (requr == 0){((LPMINMAXINFO)lParam)->ptMinTrackSize.y = CLUIFramesGetMinHeight();}
return 0;
//MSG FROM CHILD CONTROL
@@ -684,8 +659,8 @@ LRESULT CALLBACK ContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
switch (((LPNMHDR)lParam)->code) {
case CLN_NEWCONTACT:
{
- NMCLISTCONTROL *nm=(NMCLISTCONTROL *)lParam;
- if (nm!=NULL) SetAllExtraIcons(pcli->hwndContactTree,nm->hItem );
+ NMCLISTCONTROL *nm = (NMCLISTCONTROL *)lParam;
+ if (nm != NULL) SetAllExtraIcons(pcli->hwndContactTree,nm->hItem );
return TRUE;
}
case CLN_LISTREBUILT:
@@ -694,44 +669,44 @@ LRESULT CALLBACK ContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
case CLN_LISTSIZECHANGE:
{
- NMCLISTCONTROL *nmc=(NMCLISTCONTROL*)lParam;
+ NMCLISTCONTROL *nmc = (NMCLISTCONTROL*)lParam;
RECT rcWindow,rcTree,rcWorkArea;
int maxHeight,newHeight;
int winstyle;
if ( !disableautoupd && DBGetContactSettingByte( NULL, "CLUI", "AutoSize", 0 )) {
if ( !CallService(MS_CLIST_DOCKINGISDOCKED,0,0) && hFrameContactTree != 0 ) {
- maxHeight=DBGetContactSettingByte(NULL,"CLUI","MaxSizeHeight",75);
+ maxHeight = DBGetContactSettingByte(NULL,"CLUI","MaxSizeHeight",75);
GetWindowRect(hwnd,&rcWindow);
GetWindowRect(pcli->hwndContactTree,&rcTree);
- winstyle=GetWindowLongPtr(pcli->hwndContactTree,GWL_STYLE);
+ winstyle = GetWindowLongPtr(pcli->hwndContactTree,GWL_STYLE);
SystemParametersInfo(SPI_GETWORKAREA,0,&rcWorkArea,FALSE);
- lastreqh=nmc->pt.y;
- newHeight=max(nmc->pt.y,3)+1+((winstyle&WS_BORDER)?2:0)+(rcWindow.bottom-rcWindow.top)-(rcTree.bottom-rcTree.top);
+ lastreqh = nmc->pt.y;
+ newHeight = max(nmc->pt.y,3)+1+((winstyle&WS_BORDER)?2:0)+(rcWindow.bottom-rcWindow.top)-(rcTree.bottom-rcTree.top);
if (newHeight != rcWindow.bottom - rcWindow.top ) {
- if(newHeight>(rcWorkArea.bottom-rcWorkArea.top)*maxHeight/100)
- newHeight=(rcWorkArea.bottom-rcWorkArea.top)*maxHeight/100;
- if(DBGetContactSettingByte(NULL,"CLUI","AutoSizeUpward",0)) {
- rcWindow.top=rcWindow.bottom-newHeight;
- if(rcWindow.top<rcWorkArea.top) rcWindow.top=rcWorkArea.top;
+ if (newHeight>(rcWorkArea.bottom-rcWorkArea.top)*maxHeight/100)
+ newHeight = (rcWorkArea.bottom-rcWorkArea.top)*maxHeight/100;
+ if (DBGetContactSettingByte(NULL,"CLUI","AutoSizeUpward",0)) {
+ rcWindow.top = rcWindow.bottom-newHeight;
+ if (rcWindow.top<rcWorkArea.top) rcWindow.top = rcWorkArea.top;
}
else {
- rcWindow.bottom=rcWindow.top+newHeight;
- if(rcWindow.bottom>rcWorkArea.bottom) rcWindow.bottom=rcWorkArea.bottom;
+ rcWindow.bottom = rcWindow.top+newHeight;
+ if (rcWindow.bottom>rcWorkArea.bottom) rcWindow.bottom = rcWorkArea.bottom;
}
if (requr == 0) {
- requr=1;
+ requr = 1;
SetWindowPos(hwnd,0,rcWindow.left,rcWindow.top,rcWindow.right-rcWindow.left,rcWindow.bottom-rcWindow.top,SWP_NOZORDER|SWP_NOACTIVATE);
GetWindowRect(hwnd,&rcWindow);
- requr=0;
+ requr = 0;
} } } }
return TRUE;
}
case NM_CLICK:
{
- NMCLISTCONTROL *nm=(NMCLISTCONTROL*)lParam;
+ NMCLISTCONTROL *nm = (NMCLISTCONTROL*)lParam;
DWORD hitFlags;
HANDLE hItem = (HANDLE)SendMessage(pcli->hwndContactTree,CLM_HITTEST,(WPARAM)&hitFlags,MAKELPARAM(nm->pt.x,nm->pt.y));
@@ -742,7 +717,7 @@ LRESULT CALLBACK ContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
pdisplayNameCacheEntry pdnce;
pdnce = (pdisplayNameCacheEntry)pcli->pfnGetCacheEntry(nm->hItem);
- if (pdnce==NULL) return 0;
+ if (pdnce == NULL) return 0;
extra = ColumnNumToExtra(nm->iColumn);
NotifyEventHooks(hExtraImageClick, (WPARAM)nm->hItem, extra);
@@ -750,34 +725,34 @@ LRESULT CALLBACK ContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
if (!ServiceExists("ExtraIcon/Register"))
{
int v,e,w;
- v=ExtraToColumnNum(EXTRA_ICON_PROTO);
- e=ExtraToColumnNum(EXTRA_ICON_EMAIL);
- w=ExtraToColumnNum(EXTRA_ICON_ADV1);
+ v = ExtraToColumnNum(EXTRA_ICON_PROTO);
+ e = ExtraToColumnNum(EXTRA_ICON_EMAIL);
+ w = ExtraToColumnNum(EXTRA_ICON_ADV1);
- if(nm->iColumn==v)
+ if (nm->iColumn == v)
CallService(MS_USERINFO_SHOWDIALOG,(WPARAM)nm->hItem,0);
- if(nm->iColumn==e) {
+ if (nm->iColumn == e) {
//CallService(MS_USERINFO_SHOWDIALOG,(WPARAM)nm->hItem,0);
char *email,buf[4096];
- email=DBGetStringA(nm->hItem,"UserInfo", "Mye-mail0");
+ email = DBGetStringA(nm->hItem,"UserInfo", "Mye-mail0");
if (email) {
sprintf(buf,"mailto:%s",email);
ShellExecuteA(hwnd,"open",buf,NULL,NULL,SW_SHOW);
}
}
- if(nm->iColumn==w) {
+ if (nm->iColumn == w) {
char *homepage;
- homepage=DBGetStringA(pdnce->hContact,pdnce->szProto, "Homepage");
- if (homepage!=NULL)
+ homepage = DBGetStringA(pdnce->hContact,pdnce->szProto, "Homepage");
+ if (homepage != NULL)
ShellExecuteA(hwnd,"open",homepage,NULL,NULL,SW_SHOW);
} } } }
- if(hItem) break;
- if ((hitFlags&(CLCHT_NOWHERE|CLCHT_INLEFTMARGIN|CLCHT_BELOWITEMS))==0) break;
+ if (hItem) break;
+ if ((hitFlags&(CLCHT_NOWHERE|CLCHT_INLEFTMARGIN|CLCHT_BELOWITEMS)) == 0) break;
if (DBGetContactSettingByte(NULL,"CLUI","ClientAreaDrag",SETTING_CLIENTDRAG_DEFAULT)) {
POINT pt;
- pt=nm->pt;
+ pt = nm->pt;
ClientToScreen(pcli->hwndContactTree,&pt);
return SendMessage(hwnd, WM_SYSCOMMAND, SC_MOVE|HTCAPTION,MAKELPARAM(pt.x,pt.y));
}
@@ -785,32 +760,32 @@ LRESULT CALLBACK ContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
}
}
}
- else if (((LPNMHDR)lParam)->hwndFrom==pcli->hwndStatus) {
+ else if (((LPNMHDR)lParam)->hwndFrom == pcli->hwndStatus) {
if (((LPNMHDR)lParam)->code == NM_CLICK ) {
- int nParts=0, nPanel=0;
- NMMOUSE *nm=(NMMOUSE*)lParam;
+ int nParts = 0, nPanel = 0;
+ NMMOUSE *nm = (NMMOUSE*)lParam;
HMENU hMenu;
RECT rc;
POINT pt;
int totcount;
ProtocolData *PD;
int menuid;
- int startoffset=DBGetContactSettingDword(NULL,"StatusBar","FirstIconOffset",0);
- int extraspace=DBGetContactSettingDword(NULL,"StatusBar","BkExtraSpace",0);
- boolean UseOwnerDrawStatusBar=DBGetContactSettingByte(NULL,"CLUI","UseOwnerDrawStatusBar",0);
+ int startoffset = DBGetContactSettingDword(NULL,"StatusBar","FirstIconOffset",0);
+ int extraspace = DBGetContactSettingDword(NULL,"StatusBar","BkExtraSpace",0);
+ boolean UseOwnerDrawStatusBar = DBGetContactSettingByte(NULL,"CLUI","UseOwnerDrawStatusBar",0);
- hMenu=(HMENU)CallService(MS_CLIST_MENUGETSTATUS,0,0);
- nParts=SendMessage(pcli->hwndStatus,SB_GETPARTS,0,0);
+ hMenu = (HMENU)CallService(MS_CLIST_MENUGETSTATUS,0,0);
+ nParts = SendMessage(pcli->hwndStatus,SB_GETPARTS,0,0);
- if (nm->dwItemSpec==0xFFFFFFFE) {
- nPanel=nParts-1;
+ if (nm->dwItemSpec == 0xFFFFFFFE) {
+ nPanel = nParts-1;
SendMessage(pcli->hwndStatus,SB_GETRECT,nPanel,(LPARAM)&rc);
if (nm->pt.x < rc.left) return FALSE;
}
else {
- if (!((startoffset)!=0&&UseOwnerDrawStatusBar))
+ if (!((startoffset) != 0&&UseOwnerDrawStatusBar))
{
- nPanel=nm->dwItemSpec;
+ nPanel = nm->dwItemSpec;
SendMessage(pcli->hwndStatus,SB_GETRECT,nPanel,(LPARAM)&rc);
}
else {
@@ -819,44 +794,44 @@ LRESULT CALLBACK ContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
memset(&rc,0,sizeof(RECT));
GetClientRect(pcli->hwndStatus,&clrc);
- clrc.right-=clrc.left;
- clrc.right-=startoffset;
- sectwidth=clrc.right/nParts;
+ clrc.right -= clrc.left;
+ clrc.right -= startoffset;
+ sectwidth = clrc.right/nParts;
- for (nPanel=0;nPanel<nParts;nPanel++) {
- PD=(ProtocolData *)SendMessage(pcli->hwndStatus,SB_GETTEXT,(WPARAM)nPanel,(LPARAM)0);
- if(PD==NULL)
+ for (nPanel = 0;nPanel<nParts;nPanel++) {
+ PD = (ProtocolData *)SendMessage(pcli->hwndStatus,SB_GETTEXT,(WPARAM)nPanel,(LPARAM)0);
+ if (PD == NULL)
continue;
- rc.top=0;
- rc.bottom=clrc.bottom;
- rc.left=nPanel*sectwidth+startoffset;
- rc.right=rc.left+sectwidth-1;
+ rc.top = 0;
+ rc.bottom = clrc.bottom;
+ rc.left = nPanel*sectwidth+startoffset;
+ rc.right = rc.left+sectwidth-1;
if (PtInRect(&rc,nm->pt))
break;
} } }
- totcount=DBGetContactSettingDword(0,"Protocols","ProtoCount",0);
- PD=(ProtocolData *)SendMessage(pcli->hwndStatus,SB_GETTEXT,(WPARAM)nPanel,(LPARAM)0);
- if(PD==NULL){return(0);}
- menuid=nPanel;
+ totcount = DBGetContactSettingDword(0,"Protocols","ProtoCount",0);
+ PD = (ProtocolData *)SendMessage(pcli->hwndStatus,SB_GETTEXT,(WPARAM)nPanel,(LPARAM)0);
+ if (PD == NULL){return 0;}
+ menuid = nPanel;
if (menuid<0){break;}
- hMenu=(HMENU)CallService(MS_CLIST_MENUGETSTATUS,0,0);
- {
- int i;
- unsigned int cpnl = 0;
- int mcnt = GetMenuItemCount(hMenu);
- for (i=0; i<mcnt; ++i) {
- HMENU hMenus = GetSubMenu(hMenu, i);
- if (hMenus && cpnl++ == menuid) {
- hMenu = hMenus;
- break;
- }
- }
- }
- {
+ hMenu = (HMENU)CallService(MS_CLIST_MENUGETSTATUS,0,0);
+ {
+ int i;
+ unsigned int cpnl = 0;
+ int mcnt = GetMenuItemCount(hMenu);
+ for (i = 0; i<mcnt; ++i) {
+ HMENU hMenus = GetSubMenu(hMenu, i);
+ if (hMenus && cpnl++ == menuid) {
+ hMenu = hMenus;
+ break;
+ }
+ }
+ }
+ {
char buf[256];
sprintf(buf,"nPanel: %d, PD->protopos: %d,PD->RealName %s\r\n",nPanel,PD->protopos,PD->RealName);
OutputDebugStringA(buf);
@@ -884,7 +859,7 @@ LRESULT CALLBACK ContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
CallService(MS_CLIST_FRAMES_REMOVEFRAME,(WPARAM)hFrameContactTree,(LPARAM)0);
DestroyWindow(pcli->hwndContactTree);
- pcli->hwndContactList=NULL;
+ pcli->hwndContactList = NULL;
UnLoadCLUIFramesModule();
DBWriteContactSettingByte(NULL,"CList","State",(BYTE)state);
@@ -901,45 +876,45 @@ int LoadCLUIModule(void)
DBVARIANT dbv;
TCHAR titleText[256];
int laster;
- canloadstatusbar=FALSE;
- hFrameContactTree=0;
+ canloadstatusbar = FALSE;
+ hFrameContactTree = 0;
hUserDll = LoadLibraryA("user32.dll");
if (hUserDll) {
MySetLayeredWindowAttributes = (BOOL (WINAPI *)(HWND,COLORREF,BYTE,DWORD))GetProcAddress(hUserDll, "SetLayeredWindowAttributes");
- MyAnimateWindow=(BOOL (WINAPI*)(HWND,DWORD,DWORD))GetProcAddress(hUserDll,"AnimateWindow");
+ MyAnimateWindow = (BOOL (WINAPI*)(HWND,DWORD,DWORD))GetProcAddress(hUserDll,"AnimateWindow");
}
HookEvent(ME_SYSTEM_MODULESLOADED,CluiModulesLoaded);
HookEvent(ME_OPT_INITIALISE,CluiOptInit);
- hContactDraggingEvent=CreateHookableEvent(ME_CLUI_CONTACTDRAGGING);
- hContactDroppedEvent=CreateHookableEvent(ME_CLUI_CONTACTDROPPED);
- hContactDragStopEvent=CreateHookableEvent(ME_CLUI_CONTACTDRAGSTOP);
+ hContactDraggingEvent = CreateHookableEvent(ME_CLUI_CONTACTDRAGGING);
+ hContactDroppedEvent = CreateHookableEvent(ME_CLUI_CONTACTDROPPED);
+ hContactDragStopEvent = CreateHookableEvent(ME_CLUI_CONTACTDRAGSTOP);
CreateServiceFunction("CLUI/GetConnectingIconForProtocol",GetConnectingIconService);
- if(DBGetContactSettingTString(NULL,"CList","TitleText",&dbv))
+ if (DBGetContactSettingTString(NULL,"CList","TitleText",&dbv))
lstrcpyn(titleText,_T(MIRANDANAME),SIZEOF(titleText));
else {
lstrcpyn(titleText,dbv.ptszVal,SIZEOF(titleText));
DBFreeVariant(&dbv);
}
- oldhideoffline=DBGetContactSettingByte(NULL,"CList","HideOffline",SETTING_HIDEOFFLINE_DEFAULT);
+ oldhideoffline = DBGetContactSettingByte(NULL,"CList","HideOffline",SETTING_HIDEOFFLINE_DEFAULT);
- laster=GetLastError();
+ laster = GetLastError();
PreCreateCLC(pcli->hwndContactList);
// create status bar frame
CreateStatusBarhWnd(pcli->hwndContactList);
- { //int state=DBGetContactSettingByte(NULL,"CList","State",SETTING_STATE_NORMAL);
- hMenuMain=GetMenu(pcli->hwndContactList);
+ { //int state = DBGetContactSettingByte(NULL,"CList","State",SETTING_STATE_NORMAL);
+ hMenuMain = GetMenu(pcli->hwndContactList);
if (!DBGetContactSettingByte(NULL,"CLUI","ShowMainMenu",SETTING_SHOWMAINMENU_DEFAULT)) SetMenu(pcli->hwndContactList,NULL);
SetWindowPos(pcli->hwndContactList, DBGetContactSettingByte(NULL,"CList","OnTop",SETTING_ONTOP_DEFAULT) ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
}
- lastreqh=0;
+ lastreqh = 0;
return 0;
}
@@ -947,7 +922,7 @@ void UnloadCLUIModule()
{
int i;
- for ( i=0; i < SIZEOF(CycleStartTick); i++ )
+ for ( i = 0; i < SIZEOF(CycleStartTick); i++ )
if ( CycleStartTick[i].szProto != NULL )
mir_free(CycleStartTick[i].szProto);
} \ No newline at end of file
diff --git a/plugins/Mwclist/cluiopts.c b/plugins/Mwclist/cluiopts.cpp
index 04bf352aa0..fe7762fe0b 100644
--- a/plugins/Mwclist/cluiopts.c
+++ b/plugins/Mwclist/cluiopts.cpp
@@ -27,36 +27,37 @@ extern BOOL (WINAPI *MySetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD);
static INT_PTR CALLBACK DlgProcCluiOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
static INT_PTR CALLBACK DlgProcSBarOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
extern HANDLE hFrameHelperStatusBar;
-extern void ReAssignExtraIcons();
-extern int CluiProtocolStatusChanged(WPARAM wParam,LPARAM lParam);
extern int UseOwnerDrawStatusBar;
-extern int OnStatusBarBackgroundChange();
-static UINT expertOnlyControls[]={IDC_BRINGTOFRONT, IDC_AUTOSIZE,IDC_STATIC21,IDC_MAXSIZEHEIGHT,IDC_MAXSIZESPIN,IDC_STATIC22,IDC_AUTOSIZEUPWARD,IDC_SHOWMAINMENU,IDC_SHOWCAPTION,IDC_CLIENTDRAG};
+void ReAssignExtraIcons();
+void CluiProtocolStatusChanged(int parStatus, const char* szProto);
+int OnStatusBarBackgroundChange();
+
+static UINT expertOnlyControls[] = {IDC_BRINGTOFRONT, IDC_AUTOSIZE,IDC_STATIC21,IDC_MAXSIZEHEIGHT,IDC_MAXSIZESPIN,IDC_STATIC22,IDC_AUTOSIZEUPWARD,IDC_SHOWMAINMENU,IDC_SHOWCAPTION,IDC_CLIENTDRAG};
int CluiOptInit(WPARAM wParam,LPARAM lParam)
{
OPTIONSDIALOGPAGE odp;
ZeroMemory(&odp,sizeof(odp));
- odp.cbSize=sizeof(odp);
- odp.position=0;
- odp.hInstance=g_hInst;
- odp.pszTemplate=MAKEINTRESOURCEA(IDD_OPT_CLUI);
- odp.pszTitle=LPGEN("Window");
- odp.pszGroup=LPGEN("Contact List");
- odp.pfnDlgProc=DlgProcCluiOpts;
- odp.flags=ODPF_BOLDGROUPS;
- odp.nIDBottomSimpleControl=IDC_STWINDOWGROUP;
- odp.expertOnlyControls=expertOnlyControls;
- odp.nExpertOnlyControls=sizeof(expertOnlyControls)/sizeof(expertOnlyControls[0]);
+ odp.cbSize = sizeof(odp);
+ odp.position = 0;
+ odp.hInstance = g_hInst;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_CLUI);
+ odp.pszTitle = LPGEN("Window");
+ odp.pszGroup = LPGEN("Contact List");
+ odp.pfnDlgProc = DlgProcCluiOpts;
+ odp.flags = ODPF_BOLDGROUPS;
+ odp.nIDBottomSimpleControl = IDC_STWINDOWGROUP;
+ odp.expertOnlyControls = expertOnlyControls;
+ odp.nExpertOnlyControls = sizeof(expertOnlyControls)/sizeof(expertOnlyControls[0]);
CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp);
- odp.pszTemplate=MAKEINTRESOURCEA(IDD_OPT_SBAR);
- odp.pszTitle=LPGEN("Status Bar");
- odp.pfnDlgProc=DlgProcSBarOpts;
- odp.flags=ODPF_BOLDGROUPS|ODPF_EXPERTONLY;
- odp.nIDBottomSimpleControl=0;
- odp.nExpertOnlyControls=0;
- odp.expertOnlyControls=NULL;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_SBAR);
+ odp.pszTitle = LPGEN("Status Bar");
+ odp.pfnDlgProc = DlgProcSBarOpts;
+ odp.flags = ODPF_BOLDGROUPS|ODPF_EXPERTONLY;
+ odp.nIDBottomSimpleControl = 0;
+ odp.nExpertOnlyControls = 0;
+ odp.expertOnlyControls = NULL;
CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp);
return 0;
}
@@ -71,7 +72,7 @@ static INT_PTR CALLBACK DlgProcCluiOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
CheckDlgButton(hwndDlg, IDC_ONTOP, DBGetContactSettingByte(NULL,"CList","OnTop",SETTING_ONTOP_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_TOOLWND, DBGetContactSettingByte(NULL,"CList","ToolWindow",SETTING_TOOLWINDOW_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_MIN2TRAY, DBGetContactSettingByte(NULL,"CList","Min2Tray",SETTING_MIN2TRAY_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
- if(IsDlgButtonChecked(hwndDlg,IDC_TOOLWND)) EnableWindow(GetDlgItem(hwndDlg,IDC_MIN2TRAY),FALSE);
+ if (IsDlgButtonChecked(hwndDlg,IDC_TOOLWND)) EnableWindow(GetDlgItem(hwndDlg,IDC_MIN2TRAY),FALSE);
CheckDlgButton(hwndDlg, IDC_SHOWCAPTION, DBGetContactSettingByte(NULL,"CLUI","ShowCaption",SETTING_SHOWCAPTION_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SHOWMAINMENU, DBGetContactSettingByte(NULL,"CLUI","ShowMainMenu",SETTING_SHOWMAINMENU_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CLIENTDRAG, DBGetContactSettingByte(NULL,"CLUI","ClientAreaDrag",SETTING_CLIENTDRAG_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
@@ -105,17 +106,17 @@ static INT_PTR CALLBACK DlgProcCluiOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
char *s;
char szUin[20];
- if(DBGetContactSettingString(NULL,"CList","TitleText",&dbv)==0&&(dbv.pszVal))
+ if (DBGetContactSettingString(NULL,"CList","TitleText",&dbv) == 0&&(dbv.pszVal))
{
- s=mir_strdup(dbv.pszVal);
+ s = mir_strdup(dbv.pszVal);
mir_free(dbv.pszVal);
}
else
{
- s=mir_strdup(MIRANDANAME);
+ s = mir_strdup(MIRANDANAME);
}
- if(s)
+ if (s)
{
SetDlgItemTextA(hwndDlg,IDC_TITLETEXT,s);
mir_free(s);
@@ -128,17 +129,17 @@ static INT_PTR CALLBACK DlgProcCluiOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
if (!DBGetContactSettingString(NULL,"ICQ","Nick",&dbv)) {
SendDlgItemMessage(hwndDlg,IDC_TITLETEXT,CB_ADDSTRING,0,(LPARAM)dbv.pszVal);
mir_free(dbv.pszVal);
- dbv.pszVal=NULL;
+ dbv.pszVal = NULL;
}
if (!DBGetContactSettingString(NULL,"ICQ","FirstName",&dbv)) {
SendDlgItemMessage(hwndDlg,IDC_TITLETEXT,CB_ADDSTRING,0,(LPARAM)dbv.pszVal);
mir_free(dbv.pszVal);
- dbv.pszVal=NULL;
+ dbv.pszVal = NULL;
}
if (!DBGetContactSettingString(NULL,"ICQ","e-mail",&dbv)) {
SendDlgItemMessage(hwndDlg,IDC_TITLETEXT,CB_ADDSTRING,0,(LPARAM)dbv.pszVal);
mir_free(dbv.pszVal);
- dbv.pszVal=NULL;
+ dbv.pszVal = NULL;
}
}
if (!IsWinVer2000Plus()) {
@@ -185,12 +186,12 @@ static INT_PTR CALLBACK DlgProcCluiOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
return TRUE;
case WM_COMMAND:
- if(LOWORD(wParam)==IDC_AUTOHIDE) {
+ if (LOWORD(wParam) == IDC_AUTOHIDE) {
EnableWindow(GetDlgItem(hwndDlg,IDC_HIDETIME),IsDlgButtonChecked(hwndDlg,IDC_AUTOHIDE));
EnableWindow(GetDlgItem(hwndDlg,IDC_HIDETIMESPIN),IsDlgButtonChecked(hwndDlg,IDC_AUTOHIDE));
EnableWindow(GetDlgItem(hwndDlg,IDC_STATIC01),IsDlgButtonChecked(hwndDlg,IDC_AUTOHIDE));
}
- else if(LOWORD(wParam)==IDC_TRANSPARENT) {
+ else if (LOWORD(wParam) == IDC_TRANSPARENT) {
EnableWindow(GetDlgItem(hwndDlg,IDC_STATIC11),IsDlgButtonChecked(hwndDlg,IDC_TRANSPARENT));
EnableWindow(GetDlgItem(hwndDlg,IDC_STATIC12),IsDlgButtonChecked(hwndDlg,IDC_TRANSPARENT));
EnableWindow(GetDlgItem(hwndDlg,IDC_TRANSACTIVE),IsDlgButtonChecked(hwndDlg,IDC_TRANSPARENT));
@@ -198,24 +199,24 @@ static INT_PTR CALLBACK DlgProcCluiOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
EnableWindow(GetDlgItem(hwndDlg,IDC_ACTIVEPERC),IsDlgButtonChecked(hwndDlg,IDC_TRANSPARENT));
EnableWindow(GetDlgItem(hwndDlg,IDC_INACTIVEPERC),IsDlgButtonChecked(hwndDlg,IDC_TRANSPARENT));
}
- else if(LOWORD(wParam)==IDC_AUTOSIZE) {
+ else if (LOWORD(wParam) == IDC_AUTOSIZE) {
EnableWindow(GetDlgItem(hwndDlg,IDC_STATIC21),IsDlgButtonChecked(hwndDlg,IDC_AUTOSIZE));
EnableWindow(GetDlgItem(hwndDlg,IDC_STATIC22),IsDlgButtonChecked(hwndDlg,IDC_AUTOSIZE));
EnableWindow(GetDlgItem(hwndDlg,IDC_MAXSIZEHEIGHT),IsDlgButtonChecked(hwndDlg,IDC_AUTOSIZE));
EnableWindow(GetDlgItem(hwndDlg,IDC_MAXSIZESPIN),IsDlgButtonChecked(hwndDlg,IDC_AUTOSIZE));
EnableWindow(GetDlgItem(hwndDlg,IDC_AUTOSIZEUPWARD),IsDlgButtonChecked(hwndDlg,IDC_AUTOSIZE));
}
- else if(LOWORD(wParam)==IDC_TOOLWND) {
+ else if (LOWORD(wParam) == IDC_TOOLWND) {
EnableWindow(GetDlgItem(hwndDlg,IDC_MIN2TRAY),!IsDlgButtonChecked(hwndDlg,IDC_TOOLWND));
}
- else if(LOWORD(wParam)==IDC_SHOWCAPTION) {
+ else if (LOWORD(wParam) == IDC_SHOWCAPTION) {
EnableWindow(GetDlgItem(hwndDlg,IDC_TOOLWND),IsDlgButtonChecked(hwndDlg,IDC_SHOWCAPTION));
EnableWindow(GetDlgItem(hwndDlg,IDC_MIN2TRAY),!IsDlgButtonChecked(hwndDlg,IDC_TOOLWND) && IsDlgButtonChecked(hwndDlg,IDC_SHOWCAPTION));
EnableWindow(GetDlgItem(hwndDlg,IDC_TITLETEXT),IsDlgButtonChecked(hwndDlg,IDC_SHOWCAPTION));
}
- if ((LOWORD(wParam)==IDC_HIDETIME || LOWORD(wParam)==IDC_TITLETEXT || LOWORD(wParam)==IDC_MAXSIZEHEIGHT) &&
- (HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus()))
+ if ((LOWORD(wParam) == IDC_HIDETIME || LOWORD(wParam) == IDC_TITLETEXT || LOWORD(wParam) == IDC_MAXSIZEHEIGHT) &&
+ (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()))
return 0;
// Enable apply button
@@ -229,7 +230,7 @@ static INT_PTR CALLBACK DlgProcCluiOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
wsprintfA(str,"%d%%",100*SendDlgItemMessage(hwndDlg,IDC_TRANSACTIVE,TBM_GETPOS,0,0)/255);
SetDlgItemTextA(hwndDlg,IDC_ACTIVEPERC,str);
}
- if(wParam!=0x12345678) SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ if (wParam != 0x12345678) SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case WM_NOTIFY:
switch (((LPNMHDR)lParam)->code)
@@ -240,7 +241,7 @@ static INT_PTR CALLBACK DlgProcCluiOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
DBWriteContactSettingByte(NULL,"CList","ToolWindow",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_TOOLWND));
DBWriteContactSettingByte(NULL,"CList","BringToFront",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_BRINGTOFRONT));
- if(IsDlgButtonChecked(hwndDlg,IDC_TOOLWND)) {
+ if (IsDlgButtonChecked(hwndDlg,IDC_TOOLWND)) {
// Window must be hidden to dynamically remove the taskbar button.
// See http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/programmersguide/shell_int/shell_int_programming/taskbar.asp
WINDOWPLACEMENT p;
@@ -254,7 +255,7 @@ static INT_PTR CALLBACK DlgProcCluiOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
SetWindowLongPtr(pcli->hwndContactList,GWL_EXSTYLE,GetWindowLongPtr(pcli->hwndContactList,GWL_EXSTYLE)&~WS_EX_TOOLWINDOW);
if (IsDlgButtonChecked(hwndDlg,IDC_ONDESKTOP)) {
- HWND hProgMan=FindWindowA("Progman",NULL);
+ HWND hProgMan = FindWindowA("Progman",NULL);
if (IsWindow(hProgMan)) SetParent(pcli->hwndContactList,hProgMan);
} else {
SetParent(pcli->hwndContactList,NULL);
@@ -264,7 +265,7 @@ static INT_PTR CALLBACK DlgProcCluiOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
DBWriteContactSettingByte(NULL,"CLUI","ShowMainMenu",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_SHOWMAINMENU));
DBWriteContactSettingByte(NULL,"CLUI","ClientAreaDrag",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_CLIENTDRAG));
- if(IsDlgButtonChecked(hwndDlg,IDC_SHOWCAPTION))
+ if (IsDlgButtonChecked(hwndDlg,IDC_SHOWCAPTION))
SetWindowLongPtr(pcli->hwndContactList,GWL_STYLE,GetWindowLongPtr(pcli->hwndContactList,GWL_STYLE)|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX);
else
SetWindowLongPtr(pcli->hwndContactList,GWL_STYLE,GetWindowLongPtr(pcli->hwndContactList,GWL_STYLE)&~(WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX));
@@ -276,7 +277,7 @@ static INT_PTR CALLBACK DlgProcCluiOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
RedrawWindow(pcli->hwndContactList,NULL,NULL,RDW_FRAME|RDW_INVALIDATE);
DBWriteContactSettingByte(NULL,"CList","Min2Tray",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_MIN2TRAY));
- if(IsIconic(pcli->hwndContactList) && !IsDlgButtonChecked(hwndDlg,IDC_TOOLWND))
+ if (IsIconic(pcli->hwndContactList) && !IsDlgButtonChecked(hwndDlg,IDC_TOOLWND))
ShowWindow(pcli->hwndContactList,IsDlgButtonChecked(hwndDlg,IDC_MIN2TRAY)?SW_HIDE:SW_SHOW);
{ TCHAR title[256];
@@ -296,9 +297,9 @@ static INT_PTR CALLBACK DlgProcCluiOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
DBWriteContactSettingByte(NULL,"CList","AutoAlpha",(BYTE)SendDlgItemMessage(hwndDlg,IDC_TRANSINACTIVE,TBM_GETPOS,0,0));
DBWriteContactSettingByte(NULL,"CList","WindowShadow",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_DROPSHADOW));
DBWriteContactSettingByte(NULL,"CList","OnDesktop",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_ONDESKTOP));
- if(IsDlgButtonChecked(hwndDlg,IDC_TRANSPARENT)) {
+ if (IsDlgButtonChecked(hwndDlg,IDC_TRANSPARENT)) {
SetWindowLongPtr(pcli->hwndContactList, GWL_EXSTYLE, GetWindowLongPtr(pcli->hwndContactList, GWL_EXSTYLE) | WS_EX_LAYERED);
- if(MySetLayeredWindowAttributes) MySetLayeredWindowAttributes(pcli->hwndContactList, RGB(0,0,0), (BYTE)DBGetContactSettingByte(NULL,"CList","AutoAlpha",SETTING_AUTOALPHA_DEFAULT), LWA_ALPHA);
+ if (MySetLayeredWindowAttributes) MySetLayeredWindowAttributes(pcli->hwndContactList, RGB(0,0,0), (BYTE)DBGetContactSettingByte(NULL,"CList","AutoAlpha",SETTING_AUTOALPHA_DEFAULT), LWA_ALPHA);
}
else {
SetWindowLongPtr(pcli->hwndContactList, GWL_EXSTYLE, GetWindowLongPtr(pcli->hwndContactList, GWL_EXSTYLE) & ~WS_EX_LAYERED);
@@ -332,7 +333,7 @@ static INT_PTR CALLBACK DlgProcSBarOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
TranslateDialogDefault(hwndDlg);
CheckDlgButton(hwndDlg, IDC_SHOWSBAR, DBGetContactSettingByte(NULL,"CLUI","ShowSBar",1) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_USECONNECTINGICON, DBGetContactSettingByte(NULL,"CLUI","UseConnectingIcon",1) ? BST_CHECKED : BST_UNCHECKED);
- { BYTE showOpts=DBGetContactSettingByte(NULL,"CLUI","SBarShow",1);
+ { BYTE showOpts = DBGetContactSettingByte(NULL,"CLUI","SBarShow",1);
CheckDlgButton(hwndDlg, IDC_SHOWICON, showOpts&1 ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SHOWPROTO, showOpts&2 ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SHOWSTATUS, showOpts&4 ? BST_CHECKED : BST_UNCHECKED);
@@ -362,7 +363,7 @@ static INT_PTR CALLBACK DlgProcSBarOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
}
return TRUE;
case WM_COMMAND:
- if(LOWORD(wParam)==IDC_SHOWSBAR) {
+ if (LOWORD(wParam) == IDC_SHOWSBAR) {
EnableWindow(GetDlgItem(hwndDlg,IDC_SHOWICON),IsDlgButtonChecked(hwndDlg,IDC_SHOWSBAR));
EnableWindow(GetDlgItem(hwndDlg,IDC_SHOWPROTO),IsDlgButtonChecked(hwndDlg,IDC_SHOWSBAR));
EnableWindow(GetDlgItem(hwndDlg,IDC_SHOWSTATUS),IsDlgButtonChecked(hwndDlg,IDC_SHOWSBAR));
@@ -375,7 +376,7 @@ static INT_PTR CALLBACK DlgProcSBarOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
EnableWindow(GetDlgItem(hwndDlg,IDC_USEOWNERDRAW),IsDlgButtonChecked(hwndDlg,IDC_SHOWSBAR));
}
- if (LOWORD(wParam)==IDC_DEFBKCOLOR)
+ if (LOWORD(wParam) == IDC_DEFBKCOLOR)
{
SendDlgItemMessage(hwndDlg,IDC_BKGCOLOUR,CPM_SETCOLOUR,0,CLR_DEFAULT);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
@@ -391,7 +392,7 @@ static INT_PTR CALLBACK DlgProcSBarOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
int frameopt;
COLORREF col;
- col=SendDlgItemMessage(hwndDlg,IDC_BKGCOLOUR,CPM_GETCOLOUR,0,0);
+ col = SendDlgItemMessage(hwndDlg,IDC_BKGCOLOUR,CPM_GETCOLOUR,0,0);
DBWriteContactSettingDword(NULL,"CLUI","SBarBKColor",col);
@@ -405,17 +406,17 @@ static INT_PTR CALLBACK DlgProcSBarOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
DBWriteContactSettingByte(NULL,"CLUI","UseConnectingIcon",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_USECONNECTINGICON));
DBWriteContactSettingByte(NULL,"CLUI","UseOwnerDrawStatusBar",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_USEOWNERDRAW));
- UseOwnerDrawStatusBar=DBGetContactSettingByte(NULL,"CLUI","UseOwnerDrawStatusBar",0);
+ UseOwnerDrawStatusBar = DBGetContactSettingByte(NULL,"CLUI","UseOwnerDrawStatusBar",0);
/*
- if(IsDlgButtonChecked(hwndDlg,IDC_SHOWSBAR)) ShowWindow(pcli->hwndStatus,SW_SHOW);
+ if (IsDlgButtonChecked(hwndDlg,IDC_SHOWSBAR)) ShowWindow(pcli->hwndStatus,SW_SHOW);
else ShowWindow(pcli->hwndStatus,SW_HIDE);
*/
- frameopt=CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS,MAKEWPARAM(FO_FLAGS,hFrameHelperStatusBar),0);
+ frameopt = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS,MAKEWPARAM(FO_FLAGS,hFrameHelperStatusBar),0);
- frameopt=frameopt & (~F_VISIBLE);
+ frameopt = frameopt & (~F_VISIBLE);
- if(IsDlgButtonChecked(hwndDlg,IDC_SHOWSBAR))
+ if (IsDlgButtonChecked(hwndDlg,IDC_SHOWSBAR))
{
ShowWindow(pcli->hwndStatus,SW_SHOW);
frameopt|=F_VISIBLE;
diff --git a/plugins/Mwclist/cluiservices.c b/plugins/Mwclist/cluiservices.cpp
index 7759ebd97f..f31fa1c0eb 100644
--- a/plugins/Mwclist/cluiservices.c
+++ b/plugins/Mwclist/cluiservices.cpp
@@ -30,19 +30,18 @@ void FreeProtocolData( void )
{
//free protocol data
int nPanel;
- int nParts=SendMessage(pcli->hwndStatus,SB_GETPARTS,0,0);
- for (nPanel=0;nPanel<nParts;nPanel++)
+ int nParts = SendMessage(pcli->hwndStatus,SB_GETPARTS,0,0);
+ for (nPanel = 0;nPanel<nParts;nPanel++)
{
ProtocolData *PD;
- PD=(ProtocolData *)SendMessage(pcli->hwndStatus,SB_GETTEXT,(WPARAM)nPanel,(LPARAM)0);
- if (PD!=NULL&&!IsBadCodePtr((void *)PD))
- {
+ PD = (ProtocolData *)SendMessage(pcli->hwndStatus,SB_GETTEXT,(WPARAM)nPanel,(LPARAM)0);
+ if (PD != NULL && !IsBadCodePtr(( FARPROC )PD)) {
SendMessage(pcli->hwndStatus,SB_SETTEXT,(WPARAM)nPanel|SBT_OWNERDRAW,(LPARAM)0);
if (PD->RealName) mir_free(PD->RealName);
if (PD) mir_free(PD);
} } }
-void CluiProtocolStatusChanged( int parStatus, const char* szProto )
+void CluiProtocolStatusChanged(int parStatus, const char* szProto)
{
int protoCount,i;
PROTOACCOUNT **accs;
@@ -54,7 +53,7 @@ void CluiProtocolStatusChanged( int parStatus, const char* szProto )
if ( pcli->hwndStatus == 0 )
return;
- FirstIconOffset=DBGetContactSettingDword(NULL,"CLUI","FirstIconOffset",0);
+ FirstIconOffset = DBGetContactSettingDword(NULL,"CLUI","FirstIconOffset",0);
ProtoEnumAccounts( &protoCount, &accs );
if ( protoCount == 0 )
@@ -68,17 +67,17 @@ void CluiProtocolStatusChanged( int parStatus, const char* szProto )
SendMessage(pcli->hwndStatus,SB_SETBKCOLOR,0,DBGetContactSettingDword(0,"CLUI","SBarBKColor",CLR_DEFAULT));
partWidths = (int*)alloca((protoCount+1)*sizeof(int));
- //partWidths[0]=FirstIconOffset;
- if(DBGetContactSettingByte(NULL,"CLUI","UseOwnerDrawStatusBar",0)||DBGetContactSettingByte(NULL,"CLUI","EqualSections",1))
+ //partWidths[0] = FirstIconOffset;
+ if (DBGetContactSettingByte(NULL,"CLUI","UseOwnerDrawStatusBar",0)||DBGetContactSettingByte(NULL,"CLUI","EqualSections",1))
{
RECT rc;
int toshow, part;
SendMessage(pcli->hwndStatus,WM_SIZE,0,0);
GetClientRect(pcli->hwndStatus,&rc);
- rc.right-=borders[0]*2;
- toshow=0;
- for (i=0;i<protoCount;i++)
+ rc.right -= borders[0]*2;
+ toshow = 0;
+ for (i = 0;i<protoCount;i++)
{
if ( !pcli->pfnGetProtocolVisibility( accs[i]->szModuleName ))
continue;
@@ -88,93 +87,93 @@ void CluiProtocolStatusChanged( int parStatus, const char* szProto )
if (toshow>0)
{
- for (part=0,i=0;i<protoCount;i++)
+ for (part = 0,i = 0;i<protoCount;i++)
{
if ( !pcli->pfnGetProtocolVisibility( accs[i]->szModuleName ))
continue;
- partWidths[part]=((part+1)*(rc.right/toshow))-(borders[2]>>1);
- //partWidths[part]=40*part+40;
+ partWidths[part] = ((part+1)*(rc.right/toshow))-(borders[2]>>1);
+ //partWidths[part] = 40*part+40;
part++;
}
- //partCount=part;
+ //partCount = part;
}
- partCount=toshow;
+ partCount = toshow;
}
else {
HDC hdc;
SIZE textSize;
- BYTE showOpts=DBGetContactSettingByte(NULL,"CLUI","SBarShow",5);
- DWORD extraspace=DBGetContactSettingDword(NULL,"StatusBar","BkExtraSpace",0);
- DWORD startoffset=DBGetContactSettingDword(NULL,"StatusBar","FirstIconOffset",0);
+ BYTE showOpts = DBGetContactSettingByte(NULL,"CLUI","SBarShow",5);
+ DWORD extraspace = DBGetContactSettingDword(NULL,"StatusBar","BkExtraSpace",0);
+ DWORD startoffset = DBGetContactSettingDword(NULL,"StatusBar","FirstIconOffset",0);
int x;
- hdc=GetDC(pcli->hwndStatus);
+ hdc = GetDC(pcli->hwndStatus);
- for(partCount=0,i=0;i<protoCount;i++) //count down since built in ones tend to go at the end
- {
- int ind = pcli->pfnGetAccountIndexByPos(i);
- if (ind < 0) continue;
+ for (partCount = 0,i = 0;i<protoCount;i++) { //count down since built in ones tend to go at the end
+ int ind = pcli->pfnGetAccountIndexByPos(i);
+ if (ind < 0)
+ continue;
if (!pcli->pfnGetProtocolVisibility(accs[ind]->szModuleName))
continue;
- x=2;
- if (showOpts&1) x+=GetSystemMetrics(SM_CXSMICON);
- if (showOpts&2)
- {
- TCHAR szName[64];
- mir_sntprintf(szName, SIZEOF(szName), _T("%s%s"), accs[ind]->tszAccountName, showOpts&4 ? _T(" ") : _T(""));
+ x = 2;
+ if (showOpts & 1) x += GetSystemMetrics(SM_CXSMICON);
+ if (showOpts & 2) {
+ TCHAR szName[64];
+ mir_sntprintf(szName, SIZEOF(szName), _T("%s%s"), accs[ind]->tszAccountName, showOpts&4 ? _T(" ") : _T(""));
GetTextExtentPoint32(hdc, szName, (int)_tcslen(szName), &textSize);
x += textSize.cx;
}
- if (showOpts&4)
- {
- int status = CallProtoService(accs[ind]->szModuleName, PS_GETSTATUS, 0, 0);
- TCHAR *szStatus = pcli->pfnGetStatusModeDescription(status, 0);
- if (!szStatus) szStatus = _T("");
- GetTextExtentPoint32(hdc, szStatus, (int)_tcslen(szStatus), &textSize);
- x += textSize.cx;
+ if (showOpts & 4) {
+ int status = CallProtoService(accs[ind]->szModuleName, PS_GETSTATUS, 0, 0);
+ TCHAR *szStatus = pcli->pfnGetStatusModeDescription(status, 0);
+ if (!szStatus)
+ szStatus = _T("");
+ GetTextExtentPoint32(hdc, szStatus, (int)_tcslen(szStatus), &textSize);
+ x += textSize.cx;
}
if (showOpts&6) x += 2;
- partWidths[partCount]=(partCount?partWidths[partCount-1]:startoffset)+x+extraspace;
+ partWidths[partCount] = (partCount?partWidths[partCount-1]:startoffset)+x+extraspace;
partCount++;
}
ReleaseDC(pcli->hwndStatus,hdc);
}
- if(partCount==0) {
+ if (partCount == 0) {
SendMessage(pcli->hwndStatus,SB_SIMPLE,TRUE,0);
return;
}
SendMessage(pcli->hwndStatus,SB_SIMPLE,FALSE,0);
- partWidths[partCount-1]=-1;
+ partWidths[partCount-1] = -1;
SendMessage(pcli->hwndStatus,SB_SETMINHEIGHT,GetSystemMetrics(SM_CYSMICON)+2,0);
SendMessage(pcli->hwndStatus,SB_SETPARTS,partCount,(LPARAM)partWidths);
flags = SBT_OWNERDRAW;
- if (!DBGetContactSettingByte(NULL, "CLUI", "SBarBevel", 1)) flags |= SBT_NOBORDERS;
+ if ( !DBGetContactSettingByte(NULL, "CLUI", "SBarBevel", 1))
+ flags |= SBT_NOBORDERS;
- for (partCount=0, i=0; i<protoCount; i++) //count down since built in ones tend to go at the end
- {
+ for (partCount = 0, i = 0; i<protoCount; i++) //count down since built in ones tend to go at the end
+ {
ProtocolData *PD;
- int ind = pcli->pfnGetAccountIndexByPos(i);
- if (ind < 0) continue;
+ int ind = pcli->pfnGetAccountIndexByPos(i);
+ if (ind < 0) continue;
if (!pcli->pfnGetProtocolVisibility(accs[ind]->szModuleName))
continue;
PD = (ProtocolData*)mir_alloc(sizeof(ProtocolData));
- PD->RealName = mir_strdup(accs[ind]->szModuleName);
- PD->protopos = accs[ind]->iOrder;
+ PD->RealName = mir_strdup(accs[ind]->szModuleName);
+ PD->protopos = accs[ind]->iOrder;
SendMessage(pcli->hwndStatus, SB_SETTEXT, partCount++ | flags, (LPARAM)PD);
}
- CreateTimerForConnectingIcon(parStatus, (LPARAM)szProto);
+ CreateTimerForConnectingIcon(parStatus, (LPARAM)szProto);
InvalidateRect(pcli->hwndStatus, NULL, FALSE);
return;
}
diff --git a/plugins/Mwclist/commonheaders.c b/plugins/Mwclist/commonheaders.cpp
index 98a5b66473..df68c5385c 100644
--- a/plugins/Mwclist/commonheaders.c
+++ b/plugins/Mwclist/commonheaders.cpp
@@ -1,12 +1,12 @@
#include "commonheaders.h"
-#define SAFE_PTR(a) a?(IsBadReadPtr(a,1)?a=NULL:a):a
+#define SAFE_PTR(a) a?(IsBadReadPtr(a,1)?a = NULL:a):a
int __cdecl MyStrCmp (const char *a, const char *b)
{
SAFE_PTR(a);
SAFE_PTR(b);
- if (!(a&&b)) return a!=b;
+ if ( !(a && b)) return a != b;
return (strcmp(a,b));
}
diff --git a/plugins/Mwclist/commonheaders.h b/plugins/Mwclist/commonheaders.h
index e8333401b2..7115bf4978 100644
--- a/plugins/Mwclist/commonheaders.h
+++ b/plugins/Mwclist/commonheaders.h
@@ -105,18 +105,18 @@ extern int ( *saveIconFromStatusMode )( const char *szProto,int nStatus, HAN
// Register of plugin's user
//
-// wParam = (WPARAM)szSetting - string that describes a user
+// wParam == (WPARAM)szSetting - string that describes a user
// format: Category/ModuleName,
// eg: "Contact list background/CLUI",
// "Status bar background/StatusBar"
-// lParam = (LPARAM)dwFlags
+// lParam == (LPARAM)dwFlags
//
#define MS_BACKGROUNDCONFIG_REGISTER "BkgrCfg/Register"
//
// Notification about changed background
-// wParam = ModuleName
-// lParam = 0
+// wParam == ModuleName
+// lParam == 0
#define ME_BACKGROUNDCONFIG_CHANGED "BkgrCfg/Changed"
diff --git a/plugins/Mwclist/contact.c b/plugins/Mwclist/contact.cpp
index 578dae5441..54474e3b85 100644
--- a/plugins/Mwclist/contact.c
+++ b/plugins/Mwclist/contact.cpp
@@ -33,7 +33,7 @@ static int sortByProto;
static int sortNoOfflineBottom;
struct {
int status,order;
-} statusModeOrder[]={
+} statusModeOrder[] = {
{ID_STATUS_OFFLINE,500},
{ID_STATUS_ONLINE,0},
{ID_STATUS_AWAY,200},
@@ -51,8 +51,8 @@ static int GetContactStatus(HANDLE hContact)
char *szProto;
- szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0);
- if(szProto==NULL) return ID_STATUS_OFFLINE;
+ szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0);
+ if (szProto == NULL) return ID_STATUS_OFFLINE;
return DBGetContactSettingWord(hContact,szProto,"Status",ID_STATUS_OFFLINE);
*/
return (GetContactCachedStatus(hContact));
@@ -68,8 +68,8 @@ void ChangeContactIcon(HANDLE hContact,int iIcon,int add)
static int GetStatusModeOrdering(int statusMode)
{
int i;
- for(i=0; i< SIZEOF(statusModeOrder); i++)
- if(statusModeOrder[i].status==statusMode) return statusModeOrder[i].order;
+ for (i = 0; i< SIZEOF(statusModeOrder); i++)
+ if (statusModeOrder[i].status == statusMode) return statusModeOrder[i].order;
return 1000;
}
@@ -81,36 +81,36 @@ void LoadContactTree(void)
- tick=GetTickCount();
+ tick = GetTickCount();
CallService(MS_CLUI_LISTBEGINREBUILD,0,0);
- for(i=1;;i++) {
- if ((char*)CallService(MS_CLIST_GROUPGETNAME2,i,(LPARAM)(int*)NULL)==NULL) break;
+ for (i = 1;;i++) {
+ if ((char*)CallService(MS_CLIST_GROUPGETNAME2,i,(LPARAM)(int*)NULL) == NULL) break;
CallService(MS_CLUI_GROUPADDED,i,0);
}
- hideOffline=DBGetContactSettingByte(NULL,"CList","HideOffline",SETTING_HIDEOFFLINE_DEFAULT);
- hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0);
+ hideOffline = DBGetContactSettingByte(NULL,"CList","HideOffline",SETTING_HIDEOFFLINE_DEFAULT);
+ hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0);
- while(hContact!=NULL) {
- cacheEntry=GetContactFullCacheEntry(hContact);
- if (cacheEntry==NULL)
+ while(hContact != NULL) {
+ cacheEntry = GetContactFullCacheEntry(hContact);
+ if (cacheEntry == NULL)
{
MessageBoxA(0,"Fail To Get CacheEntry for hContact","!!!!!",0);
break;
}
- status=cacheEntry->status;
- if ((!hideOffline || status!=ID_STATUS_OFFLINE) && !cacheEntry->Hidden)
+ status = cacheEntry->status;
+ if ((!hideOffline || status != ID_STATUS_OFFLINE) && !cacheEntry->Hidden)
ChangeContactIcon(hContact,ExtIconFromStatusMode(hContact,(char*)cacheEntry->szProto,status),1);
- hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0);
+ hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0);
}
- sortByStatus=DBGetContactSettingByte(NULL,"CList","SortByStatus",SETTING_SORTBYSTATUS_DEFAULT);
- sortByProto=DBGetContactSettingByte(NULL,"CList","SortByProto",SETTING_SORTBYPROTO_DEFAULT);
- sortNoOfflineBottom=DBGetContactSettingByte(NULL,"CList","NoOfflineBottom",SETTING_NOOFFLINEBOTTOM_DEFAULT);
+ sortByStatus = DBGetContactSettingByte(NULL,"CList","SortByStatus",SETTING_SORTBYSTATUS_DEFAULT);
+ sortByProto = DBGetContactSettingByte(NULL,"CList","SortByProto",SETTING_SORTBYPROTO_DEFAULT);
+ sortNoOfflineBottom = DBGetContactSettingByte(NULL,"CList","NoOfflineBottom",SETTING_NOOFFLINEBOTTOM_DEFAULT);
CallService(MS_CLUI_SORTLIST,0,0);
CallService(MS_CLUI_LISTENDREBUILD,0,0);
- tick=GetTickCount()-tick;
+ tick = GetTickCount()-tick;
{
char buf[255];
//sprintf(buf,"%s %s took %i ms",__FILE__,__LINE__,tick);
@@ -136,28 +136,28 @@ int CompareContacts( const struct ClcContact *contact1, const struct ClcContact
if (sortByProto) {
/* deal with statuses, online contacts have to go above offline */
- if (sortNoOfflineBottom==0)
- if ((statusa==ID_STATUS_OFFLINE)!=(statusb==ID_STATUS_OFFLINE)) {
- return 2*(statusa==ID_STATUS_OFFLINE)-1;
+ if (sortNoOfflineBottom == 0)
+ if ((statusa == ID_STATUS_OFFLINE) != (statusb == ID_STATUS_OFFLINE)) {
+ return 2*(statusa == ID_STATUS_OFFLINE)-1;
}
/* both are online, now check protocols */
- rc=strcmp(SAFESTRING(szProto1),SAFESTRING(szProto2)); /* strcmp() doesn't like NULL so feed in "" as needed */
+ rc = strcmp(SAFESTRING(szProto1),SAFESTRING(szProto2)); /* strcmp() doesn't like NULL so feed in "" as needed */
if (rc != 0 && (szProto1 != NULL && szProto2 != NULL)) return rc;
/* protocols are the same, order by display name */
}
- if(sortByStatus) {
+ if (sortByStatus) {
int ordera,orderb;
- ordera=GetStatusModeOrdering(statusa);
- orderb=GetStatusModeOrdering(statusb);
- if(ordera!=orderb) return ordera-orderb;
+ ordera = GetStatusModeOrdering(statusa);
+ orderb = GetStatusModeOrdering(statusb);
+ if (ordera != orderb) return ordera-orderb;
}
else {
//one is offline: offline goes below online
- if (sortNoOfflineBottom==0)
+ if (sortNoOfflineBottom == 0)
{
- if ((statusa==ID_STATUS_OFFLINE)!=(statusb==ID_STATUS_OFFLINE)) {
- return 2*(statusa==ID_STATUS_OFFLINE)-1;
+ if ((statusa == ID_STATUS_OFFLINE) != (statusb == ID_STATUS_OFFLINE)) {
+ return 2*(statusa == ID_STATUS_OFFLINE)-1;
}
}
}
@@ -168,27 +168,27 @@ int CompareContacts( const struct ClcContact *contact1, const struct ClcContact
#undef SAFESTRING
-static UINT_PTR resortTimerId=0;
+static UINT_PTR resortTimerId = 0;
static VOID CALLBACK SortContactsTimer(HWND hwnd,UINT message,UINT_PTR idEvent,DWORD dwTime)
{
KillTimer(NULL,resortTimerId);
- resortTimerId=0;
+ resortTimerId = 0;
CallService(MS_CLUI_SORTLIST,0,0);
}
void SortContacts(void)
{
//avoid doing lots of resorts in quick succession
- sortByStatus=DBGetContactSettingByte(NULL,"CList","SortByStatus",SETTING_SORTBYSTATUS_DEFAULT);
- sortByProto=DBGetContactSettingByte(NULL,"CList","SortByProto",SETTING_SORTBYPROTO_DEFAULT);
- if(resortTimerId) KillTimer(NULL,resortTimerId);
- resortTimerId=SetTimer(NULL,0,50,SortContactsTimer);
+ sortByStatus = DBGetContactSettingByte(NULL,"CList","SortByStatus",SETTING_SORTBYSTATUS_DEFAULT);
+ sortByProto = DBGetContactSettingByte(NULL,"CList","SortByProto",SETTING_SORTBYPROTO_DEFAULT);
+ if (resortTimerId) KillTimer(NULL,resortTimerId);
+ resortTimerId = SetTimer(NULL,0,50,SortContactsTimer);
}
INT_PTR ContactChangeGroup(WPARAM wParam,LPARAM lParam)
{
CallService(MS_CLUI_CONTACTDELETED,wParam,0);
- if ((HANDLE)lParam==NULL)
+ if ((HANDLE)lParam == NULL)
DBDeleteContactSetting((HANDLE)wParam,"CList","Group");
else
DBWriteContactSettingString((HANDLE)wParam,"CList","Group",(char*)CallService(MS_CLIST_GROUPGETNAME2,lParam,(LPARAM)(int*)NULL));
diff --git a/plugins/Mwclist/groupmenu.c b/plugins/Mwclist/groupmenu.c
deleted file mode 100644
index d087b43754..0000000000
--- a/plugins/Mwclist/groupmenu.c
+++ /dev/null
@@ -1,751 +0,0 @@
-/*
-
-Miranda IM: the free IM client for Microsoft* Windows*
-
-Copyright 2000-2003 Miranda ICQ/IM project,
-all portions of this codebase are copyrighted to the people
-listed in contributors.txt.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-#include "commonheaders.h"
-#include "m_clui.h"
-#include "clist.h"
-#include "clc.h"
-
-//////////////////////////////Group MENU/////////////////////////
-HANDLE hGroupMenuObject;
-
-HANDLE hGroupMainMenuItemProxy;
-HANDLE hHideShowMainMenuItem;
-HANDLE hGroupStatusMenuItemProxy;
-HANDLE hPreBuildGroupMenuEvent;
-
-HANDLE hHideOfflineUsersMenuItem;
-HANDLE hHideOfflineUsersOutHereMenuItem;
-HANDLE hHideEmptyGroupsMenuItem;
-HANDLE hDisableGroupsMenuItem;
-HANDLE hNewGroupMenuItem;
-HANDLE hNewSubGroupMenuItem;
-
-int NewGroupIconidx;
-
-extern HIMAGELIST hCListImages;
-extern HICON LoadIconFromExternalFile (char *filename,int i,boolean UseLibrary,boolean registerit,char *IconName,char *SectName,char *Description,int internalidx,HICON DefIcon);
-
-void InitSubGroupMenus(void);
-
-//Groupmenu exec param(ownerdata)
-typedef struct{
-char *szServiceName;
-int Param1,Param2;
-}GroupMenuExecParam,*lpGroupMenuExecParam;
-
-/*
-wparam=handle to the menu item returned by MS_CLIST_ADDCONTACTMENUITEM
-return 0 on success.
-*/
-static INT_PTR RemoveGroupMenuItem(WPARAM wParam,LPARAM lParam)
-{
- CallService(MO_REMOVEMENUITEM,wParam,0);
- return 0;
-}
-
-
-static INT_PTR BuildGroupMenu(WPARAM wParam,LPARAM lParam)
-{
- int tick;
- HMENU hMenu;
- ListParam param = { 0 };
- param.MenuObjectHandle=hGroupMenuObject;
-
- //hMenu=hMainMenu;
- hMenu=CreatePopupMenu();
- //hMenu=wParam;
- tick=GetTickCount();
-
- NotifyEventHooks(hPreBuildGroupMenuEvent,0,0);
-
- CallService(MO_BUILDMENU,(WPARAM)hMenu,(LPARAM)&param);
- //DrawMenuBar((HWND)CallService("CLUI/GetHwnd",0,0));
- tick=GetTickCount()-tick;
- return (INT_PTR)hMenu;
-}
-
-static INT_PTR AddGroupMenuItem(WPARAM wParam,LPARAM lParam)
-{
- CLISTMENUITEM *mi=(CLISTMENUITEM*)lParam;
- lpGroupMenuParam gmp=(lpGroupMenuParam)wParam;
- char buf[1024];
-
- TMO_MenuItem tmi;
- OptParam op;
-
- if(mi->cbSize!=sizeof(CLISTMENUITEM)) return 0;
-
- memset(&tmi,0,sizeof(tmi));
- tmi.cbSize=sizeof(tmi);
- tmi.flags=mi->flags;
- tmi.hIcon=mi->hIcon;
- tmi.hotKey=mi->hotKey;
- tmi.pszName=mi->pszName;
- tmi.position=mi->position;
-
- //pszPopupName for new system mean root level
- //pszPopupName for old system mean that exists popup
- tmi.root = mi->hParentMenu;
-
- tmi.ownerdata=NULL;
-
- {
- lpGroupMenuExecParam mmep;
- mmep=(lpGroupMenuExecParam)mir_calloc(sizeof(GroupMenuExecParam));
- if(mmep==NULL){return(0);}
-
- //we need just one parametr.
- mmep->szServiceName=mir_strdup(mi->pszService);
- mmep->Param1=mi->popupPosition;
- if (gmp!=NULL)
- {
- mmep->Param1=gmp->wParam;
- mmep->Param2=gmp->lParam;
-
- }
-
-
- tmi.ownerdata=mmep;
- }
- op.Handle=(HANDLE)CallService(MO_ADDNEWMENUITEM,(WPARAM)hGroupMenuObject,(LPARAM)&tmi);
- op.Setting=OPT_MENUITEMSETUNIQNAME;
- sprintf(buf,"%s/%s",mi->pszService,mi->pszName);
- op.Value=(INT_PTR)buf;
- CallService(MO_SETOPTIONSMENUITEM,(WPARAM)0,(LPARAM)&op);
- return (INT_PTR)op.Handle;
-
-// mainItemCount++;
-// return MENU_CUSTOMITEMMAIN|(mainMenuItem[mainItemCount-1].id);
-}
-
-INT_PTR GroupMenuCheckService(WPARAM wParam,LPARAM lParam) {
-//not used
- return(0);
-}
-
-INT_PTR GroupMenuonAddService(WPARAM wParam,LPARAM lParam) {
-
- MENUITEMINFO *mii=(MENUITEMINFO* )wParam;
- if (mii==NULL) return 0;
-
- if (hHideShowMainMenuItem==(HANDLE)lParam)
- {
- mii->fMask|=MIIM_STATE;
- mii->fState|=MFS_DEFAULT;
-
- }
- if (hGroupMainMenuItemProxy==(HANDLE)lParam)
- {
- mii->fMask|=MIIM_SUBMENU;
- //mi.fType=MFT_STRING;
- mii->hSubMenu=(HMENU)CallService(MS_CLIST_MENUGETMAIN,0,0);
- }
-
- if (hGroupStatusMenuItemProxy==(HANDLE)lParam)
- {
- mii->fMask|=MIIM_SUBMENU;
- //mi.fType=MFT_STRING;
- mii->hSubMenu=(HMENU)CallService(MS_CLIST_MENUGETSTATUS,0,0);
- }
-
- return(TRUE);
-}
-
-
-//called with:
-//wparam - ownerdata
-//lparam - lparam from winproc
-INT_PTR GroupMenuExecService(WPARAM wParam,LPARAM lParam) {
- if (wParam!=0)
- {
- lpGroupMenuExecParam mmep=(lpGroupMenuExecParam)wParam;
- if (!strcmp(mmep->szServiceName,"Help/AboutCommand"))
- {
- //bug in help.c,it used wparam as parent window handle without reason.
- mmep->Param1=0;
- CallService(mmep->szServiceName,mmep->Param1,lParam);
- }else
- {
- CallService(mmep->szServiceName,mmep->Param1,mmep->Param2);
- }
-
- }
- return(1);
-}
-INT_PTR FreeOwnerDataGroupMenu (WPARAM wParam,LPARAM lParam)
-{
-
- lpGroupMenuExecParam mmep;
- mmep=(lpGroupMenuExecParam)lParam;
- if (mmep!=NULL){
- FreeAndNil(&mmep->szServiceName);
- FreeAndNil(&mmep);
- }
-
-return(0);
-}
-
-INT_PTR HideGroupsHelper(WPARAM wParam,LPARAM lParam)
-{
- int newVal=!(GetWindowLongPtr(pcli->hwndContactTree,GWL_STYLE)&CLS_HIDEEMPTYGROUPS);
- DBWriteContactSettingByte(NULL,"CList","HideEmptyGroups",(BYTE)newVal);
- SendMessage(pcli->hwndContactTree,CLM_SETHIDEEMPTYGROUPS,newVal,0);
- return 0;
-}
-
-INT_PTR UseGroupsHelper(WPARAM wParam,LPARAM lParam)
-{
- int newVal=!(GetWindowLongPtr(pcli->hwndContactTree,GWL_STYLE)&CLS_USEGROUPS);
- DBWriteContactSettingByte(NULL,"CList","UseGroups",(BYTE)newVal);
- SendMessage(pcli->hwndContactTree,CLM_SETUSEGROUPS,newVal,0);
- return 0;
-}
-
-INT_PTR HideOfflineRootHelper(WPARAM wParam,LPARAM lParam)
-{
-SendMessage(
- pcli->hwndContactTree,
- CLM_SETHIDEOFFLINEROOT,
- !SendMessage(pcli->hwndContactTree,CLM_GETHIDEOFFLINEROOT,0,0),
- 0);
- return 0;
-}
-
-static int OnBuildGroupMenu(WPARAM wParam,LPARAM lParam)
-{
- CLISTMENUITEM mi;
-
-
- ZeroMemory(&mi,sizeof(mi));
- mi.cbSize = sizeof(mi);
- mi.flags = CMIM_FLAGS | (DBGetContactSettingByte(NULL,"CList","HideOffline",SETTING_HIDEOFFLINE_DEFAULT)?CMIF_CHECKED:0);
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hHideOfflineUsersMenuItem, (LPARAM)&mi);
-
- ZeroMemory(&mi,sizeof(mi));
- mi.cbSize = sizeof(mi);
- mi.flags = CMIM_FLAGS | (SendMessage(pcli->hwndContactTree,CLM_GETHIDEOFFLINEROOT,0,0)?CMIF_CHECKED:0);
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hHideOfflineUsersOutHereMenuItem, (LPARAM)&mi);
-
- ZeroMemory(&mi,sizeof(mi));
- mi.cbSize = sizeof(mi);
- mi.flags = CMIM_FLAGS | (GetWindowLongPtr(pcli->hwndContactTree,GWL_STYLE)&CLS_HIDEEMPTYGROUPS?CMIF_CHECKED:0);
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hHideEmptyGroupsMenuItem, (LPARAM)&mi);
-
- ZeroMemory(&mi,sizeof(mi));
- mi.cbSize = sizeof(mi);
- mi.flags = CMIM_FLAGS | (GetWindowLongPtr(pcli->hwndContactTree,GWL_STYLE)&CLS_USEGROUPS?0:CMIF_CHECKED);
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hDisableGroupsMenuItem, (LPARAM)&mi);
-
- return 0;
-}
-
-int static OnIconLibIconChanged(WPARAM wParam,LPARAM lParam)
-{
- HICON hicon;
- CLISTMENUITEM clmi={0};
-
- hicon=LoadIconFromExternalFile("clisticons.dll",2,TRUE,FALSE,"NewGroup","Contact List","New Group",-IDI_NEWGROUP,0);
- NewGroupIconidx=ImageList_ReplaceIcon(hCListImages,NewGroupIconidx,hicon);
-
- clmi.cbSize=sizeof(clmi);
- clmi.flags=CMIM_ICON;
- clmi.hIcon=ImageList_GetIcon(hCListImages,NewGroupIconidx,0);
- CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)hNewSubGroupMenuItem,(LPARAM)&clmi);
- CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)hNewGroupMenuItem,(LPARAM)&clmi);
- return 0;
-}
-
-void InitGroupMenus(void)
-{
- TMenuParam tmp;
- OptParam op;
- HICON hicon;
- hicon=LoadIconFromExternalFile("clisticons.dll",2,TRUE,TRUE,"NewGroup","Contact List","New Group",-IDI_NEWGROUP2,0);
- NewGroupIconidx=ImageList_AddIcon(hCListImages,hicon );
-
- CreateServiceFunction("CLISTMENUSGroup/ExecService",GroupMenuExecService);
- CreateServiceFunction("CLISTMENUSGroup/FreeOwnerDataGroupMenu",FreeOwnerDataGroupMenu);
- CreateServiceFunction("CLISTMENUSGroup/GroupMenuonAddService",GroupMenuonAddService);
- CreateServiceFunction("CLISTMENUSGroup/HideGroupsHelper",HideGroupsHelper);
- CreateServiceFunction("CLISTMENUSGroup/UseGroupsHelper",UseGroupsHelper);
- CreateServiceFunction("CLISTMENUSGroup/HideOfflineRootHelper",HideOfflineRootHelper);
-
- CreateServiceFunction(MS_CLIST_ADDGROUPMENUITEM,AddGroupMenuItem);
- CreateServiceFunction(MS_CLIST_REMOVEGROUPMENUITEM,RemoveGroupMenuItem);
- CreateServiceFunction(MS_CLIST_MENUBUILDGROUP,BuildGroupMenu);
- hPreBuildGroupMenuEvent=CreateHookableEvent(ME_CLIST_PREBUILDGROUPMENU);
- HookEvent(ME_CLIST_PREBUILDGROUPMENU,OnBuildGroupMenu);
-
- InitSubGroupMenus();
-
- //Group menu
- memset(&tmp,0,sizeof(tmp));
- tmp.cbSize=sizeof(tmp);
- tmp.CheckService=NULL;
- tmp.ExecService="CLISTMENUSGroup/ExecService";
- tmp.name="Group Menu";
- hGroupMenuObject=(HANDLE)CallService(MO_CREATENEWMENUOBJECT,(WPARAM)0,(LPARAM)&tmp);
-
-
- op.Handle=hGroupMenuObject;
- op.Setting=OPT_USERDEFINEDITEMS;
- op.Value=TRUE;
- CallService(MO_SETOPTIONSMENUOBJECT,(WPARAM)0,(LPARAM)&op);
-
- op.Handle=hGroupMenuObject;
- op.Setting=OPT_MENUOBJECT_SET_FREE_SERVICE;
- op.Value=(INT_PTR)"CLISTMENUSGroup/FreeOwnerDataGroupMenu";
- CallService(MO_SETOPTIONSMENUOBJECT,(WPARAM)0,(LPARAM)&op);
-
- op.Handle=hGroupMenuObject;
- op.Setting=OPT_MENUOBJECT_SET_ONADD_SERVICE;
- op.Value=(INT_PTR)"CLISTMENUSGroup/GroupMenuonAddService";
- CallService(MO_SETOPTIONSMENUOBJECT,(WPARAM)0,(LPARAM)&op);
-
- {
- //add exit command to menu
- CLISTMENUITEM mi;
- GroupMenuParam gmp;
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize=sizeof(mi);
- mi.position=1900000;
- mi.pszService="CloseAction";
- mi.pszName=LPGEN("E&xit");
- AddGroupMenuItem((WPARAM)0,(LPARAM)&mi);
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize=sizeof(mi);
- mi.position=500;
- mi.pszService=MS_CLIST_SHOWHIDE;
- mi.pszName=LPGEN("&Hide/Show");
- hHideShowMainMenuItem=(HANDLE)AddGroupMenuItem((WPARAM)0,(LPARAM)&mi);
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize=sizeof(mi);
- mi.position=200000;
- mi.hIcon=LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_FINDUSER));
- mi.pszService="FindAdd/FindAddCommand";
- mi.pszName=LPGEN("&Find/Add Contacts...");
- AddGroupMenuItem((WPARAM)0,(LPARAM)&mi);
-
-
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize=sizeof(mi);
- mi.position=300000;
- mi.pszService="";
- mi.pszName=LPGEN("&Main Menu");
- hGroupMainMenuItemProxy=(HANDLE)AddGroupMenuItem((WPARAM)0,(LPARAM)&mi);
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize=sizeof(mi);
- mi.position=300100;
- mi.pszService="";
- mi.pszName=LPGEN("&Status");
- hGroupStatusMenuItemProxy=(HANDLE)AddGroupMenuItem((WPARAM)0,(LPARAM)&mi);
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize=sizeof(mi);
- mi.position=400000;
- mi.hIcon=LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_OPTIONS));
- mi.pszService="Options/OptionsCommand";
- mi.pszName=LPGEN("&Options...");
-
- AddGroupMenuItem((WPARAM)0,(LPARAM)&mi);
-
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize=sizeof(mi);
- mi.position=500000;
- mi.hIcon=LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_CLIENTMIRANDA));
- mi.pszService="Help/AboutCommand";
- mi.pszName=LPGEN("&About");
-
- //AddGroupMenuItem((WPARAM)0,(LPARAM)&mi);
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize=sizeof(mi);
- mi.position=100000;
- mi.hIcon=ImageList_GetIcon(hCListImages,NewGroupIconidx,0);
- mi.pszService=MS_CLIST_GROUPCREATE;
- mi.pszName=LPGEN("&New Group");
- hNewGroupMenuItem=(HANDLE)AddGroupMenuItem((WPARAM)0,(LPARAM)&mi);
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize=sizeof(mi);
- mi.position=100001;
- mi.hIcon=NULL;
- mi.pszService=MS_CLIST_SETHIDEOFFLINE;
- mi.pszName=LPGEN("&Hide Offline Users");
- gmp.lParam=0;gmp.wParam=-1;
- hHideOfflineUsersMenuItem=(HANDLE)AddGroupMenuItem((WPARAM)&gmp,(LPARAM)&mi);
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize=sizeof(mi);
- mi.position=100002;
- mi.hIcon=NULL;
- mi.pszService="CLISTMENUSGroup/HideOfflineRootHelper";
- mi.pszName=LPGEN("Hide &Offline Users out here");
- hHideOfflineUsersOutHereMenuItem=(HANDLE)AddGroupMenuItem((WPARAM)0,(LPARAM)&mi);
-
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize=sizeof(mi);
- mi.position=100003;
- mi.hIcon=NULL;
- mi.pszService="CLISTMENUSGroup/HideGroupsHelper";
- mi.pszName=LPGEN("Hide &Empty Groups");
- hHideEmptyGroupsMenuItem=(HANDLE)AddGroupMenuItem((WPARAM)0,(LPARAM)&mi);
-
-
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize=sizeof(mi);
- mi.position=100004;
- mi.hIcon=NULL;
- mi.pszService="CLISTMENUSGroup/UseGroupsHelper";
- mi.pszName=LPGEN("Disable &Groups");
- hDisableGroupsMenuItem=(HANDLE)AddGroupMenuItem((WPARAM)0,(LPARAM)&mi);
-
-
- HookEvent(ME_SKIN2_ICONSCHANGED,OnIconLibIconChanged);
-
- //MS_CLIST_GROUPCREATE
-
- }
-}
-
-//////////////////////////////END Group MENU/////////////////////////
-
-
-
-
-//////////////////////////////SubGroup MENU/////////////////////////
-HANDLE hSubGroupMenuObject;
-
-HANDLE hSubGroupMainMenuItemProxy;
-HANDLE hHideShowMainMenuItem;
-HANDLE hSubGroupStatusMenuItemProxy;
-HANDLE hPreBuildSubGroupMenuEvent;
-HANDLE hHideOfflineUsersHereMenuItem;
-
-//SubGroupmenu exec param(ownerdata)
-typedef struct{
-char *szServiceName;
-int Param1,Param2;
-}SubGroupMenuExecParam,*lpSubGroupMenuExecParam;
-
-/*
-wparam=handle to the menu item returned by MS_CLIST_ADDCONTACTMENUITEM
-return 0 on success.
-*/
-static INT_PTR RemoveSubGroupMenuItem(WPARAM wParam,LPARAM lParam)
-{
- CallService(MO_REMOVEMENUITEM,wParam,0);
- return 0;
-}
-
-static int OnBuildSubGroupMenu(WPARAM wParam,LPARAM lParam)
-{
- CLISTMENUITEM mi;
- struct ClcGroup *group=(struct ClcGroup *)wParam;
- if (wParam==0) return 0;
-
-
- //contact->group
-
-
-
- ZeroMemory(&mi,sizeof(mi));
- mi.cbSize = sizeof(mi);
- mi.flags = CMIM_FLAGS | (group->hideOffline?CMIF_CHECKED:0);
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hHideOfflineUsersHereMenuItem, (LPARAM)&mi);
-
- return 0;
-}
-static INT_PTR BuildSubGroupMenu(WPARAM wParam,LPARAM lParam)
-{
- int tick;
- HMENU hMenu;
- ListParam param = { 0 };
- param.MenuObjectHandle=hSubGroupMenuObject;
- param.wParam=wParam;
-
- //hMenu=hMainMenu;
- hMenu=CreatePopupMenu();
- //hMenu=wParam;
- tick=GetTickCount();
-
- NotifyEventHooks(hPreBuildSubGroupMenuEvent,wParam,0);
-
- CallService(MO_BUILDMENU,(WPARAM)hMenu,(LPARAM)&param);
- //DrawMenuBar((HWND)CallService("CLUI/GetHwnd",0,0));
- tick=GetTickCount()-tick;
- return (INT_PTR)hMenu;
-}
-
-static INT_PTR AddSubGroupMenuItem(WPARAM wParam,LPARAM lParam)
-{
- CLISTMENUITEM *mi=(CLISTMENUITEM*)lParam;
- lpGroupMenuParam gmp=(lpGroupMenuParam)wParam;
- char buf[1024];
- TMO_MenuItem tmi;
- OptParam op;
-
- if(mi->cbSize!=sizeof(CLISTMENUITEM)) return 0;
- memset(&tmi,0,sizeof(tmi));
- tmi.cbSize=sizeof(tmi);
- tmi.flags=mi->flags;
- tmi.hIcon=mi->hIcon;
- tmi.hotKey=mi->hotKey;
- tmi.pszName=mi->pszName;
- tmi.position=mi->position;
-
- //pszPopupName for new system mean root level
- //pszPopupName for old system mean that exists popup
- tmi.root = mi->hParentMenu;
-
- tmi.ownerdata=NULL;
-
- { lpSubGroupMenuExecParam mmep = (lpSubGroupMenuExecParam)mir_calloc(sizeof(SubGroupMenuExecParam));
- if ( mmep == NULL)
- return 0;
-
- //we need just one parametr.
- mmep->szServiceName=mir_strdup(mi->pszService);
- mmep->Param1=mi->popupPosition;
- if ( gmp != NULL ) {
- mmep->Param1 = gmp->wParam;
- mmep->Param2 = gmp->lParam;
- }
-
- tmi.ownerdata=mmep;
- }
- op.Handle=(HANDLE)CallService(MO_ADDNEWMENUITEM,(WPARAM)hSubGroupMenuObject,(LPARAM)&tmi);
- op.Setting=OPT_MENUITEMSETUNIQNAME;
- sprintf(buf,"%s/%s",mi->pszService,mi->pszName);
- op.Value=(INT_PTR)buf;
- CallService(MO_SETOPTIONSMENUITEM,(WPARAM)0,(LPARAM)&op);
- return (INT_PTR)op.Handle;
-
-// mainItemCount++;
-// return MENU_CUSTOMITEMMAIN|(mainMenuItem[mainItemCount-1].id);
-}
-
-INT_PTR SubGroupMenuCheckService(WPARAM wParam,LPARAM lParam) {
-//not used
- return(0);
-}
-
-INT_PTR SubGroupMenuonAddService(WPARAM wParam,LPARAM lParam) {
-
- MENUITEMINFO *mii=(MENUITEMINFO* )wParam;
-
- if (mii==NULL) return 0;
-
-/*
- if (hHideShowMainMenuItem==(HANDLE)lParam)
- {
- mii->fMask|=MIIM_STATE;
- mii->fState|=MFS_DEFAULT;
-
- }
- if (hSubGroupMainMenuItemProxy==(HANDLE)lParam)
- {
- mii->fMask|=MIIM_SUBMENU;
- //mi.fType=MFT_STRING;
- mii->hSubMenu=(HMENU)CallService(MS_CLIST_MENUGETMAIN,0,0);
- }
-
- if (hSubGroupStatusMenuItemProxy==(HANDLE)lParam)
- {
- mii->fMask|=MIIM_SUBMENU;
- //mi.fType=MFT_STRING;
- mii->hSubMenu=(HMENU)CallService(MS_CLIST_MENUGETSTATUS,0,0);
- }
-*/
- return(TRUE);
-}
-
-
-//called with:
-//wparam - ownerdata
-//lparam - lparam from winproc
-INT_PTR SubGroupMenuExecService(WPARAM wParam,LPARAM lParam) {
- if (wParam!=0)
- {
- lpSubGroupMenuExecParam mmep=(lpSubGroupMenuExecParam)wParam;
- if (!strcmp(mmep->szServiceName,"Help/AboutCommand"))
- {
- //bug in help.c,it used wparam as parent window handle without reason.
- mmep->Param1=0;
- CallService(mmep->szServiceName,mmep->Param1,lParam);
- }else
- {
- CallService(mmep->szServiceName,mmep->Param1,mmep->Param2);
- }
-
- }
- return(1);
-}
-INT_PTR FreeOwnerDataSubGroupMenu (WPARAM wParam,LPARAM lParam)
-{
-
- lpSubGroupMenuExecParam mmep;
- mmep=(lpSubGroupMenuExecParam)lParam;
- if (mmep!=NULL){
- FreeAndNil(&mmep->szServiceName);
- FreeAndNil(&mmep);
- }
-
-return(0);
-}
-/*
-int HideSubGroupsHelper(WPARAM wParam,LPARAM lParam)
-{
- int newVal=!(GetWindowLongPtr(pcli->hwndContactTree,GWL_STYLE)&CLS_HIDEEMPTYSubGroupS);
- DBWriteContactSettingByte(NULL,"CList","HideEmptySubGroups",(BYTE)newVal);
- SendMessage(pcli->hwndContactTree,CLM_SETHIDEEMPTYSubGroupS,newVal,0);
- return 0;
-}
-
-int UseSubGroupsHelper(WPARAM wParam,LPARAM lParam)
-{
- int newVal=!(GetWindowLongPtr(pcli->hwndContactTree,GWL_STYLE)&CLS_USESubGroupS);
- DBWriteContactSettingByte(NULL,"CList","UseSubGroups",(BYTE)newVal);
- SendMessage(pcli->hwndContactTree,CLM_SETUSESubGroupS,newVal,0);
- return 0;
-}
-
-int HideOfflineRootHelper(WPARAM wParam,LPARAM lParam)
-{
-SendMessage(
- pcli->hwndContactTree,
- CLM_SETHIDEOFFLINEROOT,
- !SendMessage(pcli->hwndContactTree,CLM_GETHIDEOFFLINEROOT,0,0),
- 0);
- return 0;
-}
-*/
-//wparam menu handle to pass to clc.c
-INT_PTR GroupMenuExecProxy(WPARAM wParam,LPARAM lParam)
-{
- SendMessage(pcli->hwndContactTree,WM_COMMAND,wParam,0);
- return 0;
-}
-
-void InitSubGroupMenus(void)
-{
- TMenuParam tmp;
- OptParam op;
-
- CreateServiceFunction("CLISTMENUSSubGroup/ExecService",SubGroupMenuExecService);
- CreateServiceFunction("CLISTMENUSSubGroup/FreeOwnerDataSubGroupMenu",FreeOwnerDataSubGroupMenu);
- CreateServiceFunction("CLISTMENUSSubGroup/SubGroupMenuonAddService",SubGroupMenuonAddService);
- CreateServiceFunction("CLISTMENUSSubGroup/GroupMenuExecProxy",GroupMenuExecProxy);
-
- //CreateServiceFunction("CLISTMENUSSubGroup/HideSubGroupsHelper",HideSubGroupsHelper);
- //CreateServiceFunction("CLISTMENUSSubGroup/UseSubGroupsHelper",UseSubGroupsHelper);
- //CreateServiceFunction("CLISTMENUSSubGroup/HideOfflineRootHelper",HideOfflineRootHelper);
-
- CreateServiceFunction(MS_CLIST_ADDSUBGROUPMENUITEM,AddSubGroupMenuItem);
- CreateServiceFunction(MS_CLIST_REMOVESUBGROUPMENUITEM,RemoveSubGroupMenuItem);
- CreateServiceFunction(MS_CLIST_MENUBUILDSUBGROUP,BuildSubGroupMenu);
- hPreBuildSubGroupMenuEvent=CreateHookableEvent(ME_CLIST_PREBUILDSUBGROUPMENU);
- HookEvent(ME_CLIST_PREBUILDSUBGROUPMENU,OnBuildSubGroupMenu);
-
-
- //SubGroup menu
- memset(&tmp,0,sizeof(tmp));
- tmp.cbSize=sizeof(tmp);
- tmp.CheckService=NULL;
- tmp.ExecService="CLISTMENUSSubGroup/ExecService";
- tmp.name="SubGroupMenu";
- hSubGroupMenuObject=(HANDLE)CallService(MO_CREATENEWMENUOBJECT,(WPARAM)0,(LPARAM)&tmp);
-
-
- op.Handle=hSubGroupMenuObject;
- op.Setting=OPT_USERDEFINEDITEMS;
- op.Value=TRUE;
- CallService(MO_SETOPTIONSMENUOBJECT,(WPARAM)0,(LPARAM)&op);
-
- op.Handle=hSubGroupMenuObject;
- op.Setting=OPT_MENUOBJECT_SET_FREE_SERVICE;
- op.Value=(INT_PTR)"CLISTMENUSSubGroup/FreeOwnerDataSubGroupMenu";
- CallService(MO_SETOPTIONSMENUOBJECT,(WPARAM)0,(LPARAM)&op);
-
- op.Handle=hSubGroupMenuObject;
- op.Setting=OPT_MENUOBJECT_SET_ONADD_SERVICE;
- op.Value=(INT_PTR)"CLISTMENUSSubGroup/SubGroupMenuonAddService";
- CallService(MO_SETOPTIONSMENUOBJECT,(WPARAM)0,(LPARAM)&op);
-
- {
- //add exit command to menu
- CLISTMENUITEM mi;
- GroupMenuParam gmp;
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize=sizeof(mi);
- mi.position=1000;
- mi.hIcon=ImageList_GetIcon(hCListImages,NewGroupIconidx,0);
- mi.pszService="CLISTMENUSSubGroup/GroupMenuExecProxy";
- mi.pszName=LPGEN("&New SubGroup");
- gmp.lParam=0;gmp.wParam=POPUP_NEWSUBGROUP;
- hNewSubGroupMenuItem=(HANDLE)AddSubGroupMenuItem((WPARAM)&gmp,(LPARAM)&mi);
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize=sizeof(mi);
- mi.position=1001;
- mi.hIcon=NULL;
- mi.pszService="CLISTMENUSSubGroup/GroupMenuExecProxy";
- mi.pszName=LPGEN("&Hide Offline Users in here");
- gmp.lParam=0;gmp.wParam=POPUP_GROUPHIDEOFFLINE;
- hHideOfflineUsersHereMenuItem=(HANDLE)AddSubGroupMenuItem((WPARAM)&gmp,(LPARAM)&mi);
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize=sizeof(mi);
- mi.position=900001;
- mi.flags = CMIF_ICONFROMICOLIB;
- mi.icolibItem=LoadSkinnedIconHandle(SKINICON_OTHER_RENAME); //LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_RENAME));
- mi.pszService="CLISTMENUSSubGroup/GroupMenuExecProxy";
- mi.pszName=LPGEN("&Rename Group");
- gmp.lParam=0;gmp.wParam=POPUP_RENAMEGROUP;
- AddSubGroupMenuItem((WPARAM)&gmp,(LPARAM)&mi);
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize=sizeof(mi);
- mi.position=900002;
- mi.flags = CMIF_ICONFROMICOLIB;
- mi.icolibItem=LoadSkinnedIconHandle(SKINICON_OTHER_DELETE); //LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_DELETE));
- mi.pszService="CLISTMENUSSubGroup/GroupMenuExecProxy";
- mi.pszName=LPGEN("&Delete Group");
- gmp.lParam=0;gmp.wParam=POPUP_DELETEGROUP;
- AddSubGroupMenuItem((WPARAM)&gmp,(LPARAM)&mi);
-
- //MS_CLIST_SubGroupCREATE
-
- }
-}
-
-//////////////////////////////END SubGroup MENU/////////////////////////
diff --git a/plugins/Mwclist/groupmenu.cpp b/plugins/Mwclist/groupmenu.cpp
new file mode 100644
index 0000000000..7e126708c5
--- /dev/null
+++ b/plugins/Mwclist/groupmenu.cpp
@@ -0,0 +1,685 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2003 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+#include "commonheaders.h"
+#include "m_clui.h"
+#include "clist.h"
+#include "clc.h"
+
+//////////////////////////////Group MENU/////////////////////////
+
+extern HANDLE hHideShowMainMenuItem;
+HANDLE hGroupMenuObject;
+
+HANDLE hGroupMainMenuItemProxy;
+HANDLE hGroupStatusMenuItemProxy;
+HANDLE hPreBuildGroupMenuEvent;
+
+HANDLE hHideOfflineUsersMenuItem;
+HANDLE hHideOfflineUsersOutHereMenuItem;
+HANDLE hHideEmptyGroupsMenuItem;
+HANDLE hDisableGroupsMenuItem;
+HANDLE hNewGroupMenuItem;
+HANDLE hNewSubGroupMenuItem;
+
+int NewGroupIconidx;
+
+extern HIMAGELIST hCListImages;
+HICON LoadIconFromExternalFile(char *filename,int i,boolean UseLibrary,boolean registerit,char *IconName,char *SectName,char *Description,int internalidx,HICON DefIcon);
+
+void InitSubGroupMenus(void);
+
+//Groupmenu exec param(ownerdata)
+typedef struct{
+char *szServiceName;
+int Param1,Param2;
+}GroupMenuExecParam,*lpGroupMenuExecParam;
+
+/*
+wparam = handle to the menu item returned by MS_CLIST_ADDCONTACTMENUITEM
+return 0 on success.
+*/
+static INT_PTR RemoveGroupMenuItem(WPARAM wParam,LPARAM lParam)
+{
+ CallService(MO_REMOVEMENUITEM,wParam,0);
+ return 0;
+}
+
+
+static INT_PTR BuildGroupMenu(WPARAM wParam,LPARAM lParam)
+{
+ int tick;
+ HMENU hMenu;
+ ListParam param = { 0 };
+ param.MenuObjectHandle = hGroupMenuObject;
+
+ //hMenu = hMainMenu;
+ hMenu = CreatePopupMenu();
+ //hMenu = wParam;
+ tick = GetTickCount();
+
+ NotifyEventHooks(hPreBuildGroupMenuEvent,0,0);
+
+ CallService(MO_BUILDMENU,(WPARAM)hMenu,(LPARAM)&param);
+ //DrawMenuBar((HWND)CallService("CLUI/GetHwnd",0,0));
+ tick = GetTickCount()-tick;
+ return (INT_PTR)hMenu;
+}
+
+static INT_PTR AddGroupMenuItem(WPARAM wParam,LPARAM lParam)
+{
+ CLISTMENUITEM *mi = (CLISTMENUITEM*)lParam;
+ lpGroupMenuParam gmp = (lpGroupMenuParam)wParam;
+ char buf[1024];
+
+ TMO_MenuItem tmi;
+ OptParam op;
+
+ if (mi->cbSize != sizeof(CLISTMENUITEM)) return 0;
+
+ memset(&tmi,0,sizeof(tmi));
+ tmi.cbSize = sizeof(tmi);
+ tmi.flags = mi->flags;
+ tmi.hIcon = mi->hIcon;
+ tmi.hotKey = mi->hotKey;
+ tmi.pszName = mi->pszName;
+ tmi.position = mi->position;
+ tmi.root = mi->hParentMenu;
+ tmi.ownerdata = NULL;
+
+ {
+ lpGroupMenuExecParam mmep;
+ mmep = (lpGroupMenuExecParam)mir_calloc(sizeof(GroupMenuExecParam));
+ if (mmep == NULL){return 0;}
+
+ //we need just one parametr.
+ mmep->szServiceName = mir_strdup(mi->pszService);
+ mmep->Param1 = mi->popupPosition;
+ if (gmp != NULL)
+ {
+ mmep->Param1 = gmp->wParam;
+ mmep->Param2 = gmp->lParam;
+
+ }
+
+
+ tmi.ownerdata = mmep;
+ }
+ op.Handle = (HANDLE)CallService(MO_ADDNEWMENUITEM,(WPARAM)hGroupMenuObject,(LPARAM)&tmi);
+ op.Setting = OPT_MENUITEMSETUNIQNAME;
+ sprintf(buf,"%s/%s",mi->pszService,mi->pszName);
+ op.Value = (INT_PTR)buf;
+ CallService(MO_SETOPTIONSMENUITEM,(WPARAM)0,(LPARAM)&op);
+ return (INT_PTR)op.Handle;
+
+// mainItemCount++;
+// return MENU_CUSTOMITEMMAIN|(mainMenuItem[mainItemCount-1].id);
+}
+
+INT_PTR GroupMenuCheckService(WPARAM wParam,LPARAM lParam) {
+//not used
+ return 0;
+}
+
+INT_PTR GroupMenuonAddService(WPARAM wParam,LPARAM lParam) {
+
+ MENUITEMINFO *mii = (MENUITEMINFO* )wParam;
+ if (mii == NULL) return 0;
+
+ if (hHideShowMainMenuItem == (HANDLE)lParam)
+ {
+ mii->fMask|=MIIM_STATE;
+ mii->fState|=MFS_DEFAULT;
+
+ }
+ if (hGroupMainMenuItemProxy == (HANDLE)lParam)
+ {
+ mii->fMask|=MIIM_SUBMENU;
+ //mi.fType = MFT_STRING;
+ mii->hSubMenu = (HMENU)CallService(MS_CLIST_MENUGETMAIN,0,0);
+ }
+
+ if (hGroupStatusMenuItemProxy == (HANDLE)lParam)
+ {
+ mii->fMask|=MIIM_SUBMENU;
+ //mi.fType = MFT_STRING;
+ mii->hSubMenu = (HMENU)CallService(MS_CLIST_MENUGETSTATUS,0,0);
+ }
+
+ return(TRUE);
+}
+
+
+//called with:
+//wparam - ownerdata
+//lparam - lparam from winproc
+INT_PTR GroupMenuExecService(WPARAM wParam,LPARAM lParam) {
+ if (wParam != 0)
+ {
+ lpGroupMenuExecParam mmep = (lpGroupMenuExecParam)wParam;
+ if (!strcmp(mmep->szServiceName,"Help/AboutCommand"))
+ {
+ //bug in help.c,it used wparam as parent window handle without reason.
+ mmep->Param1 = 0;
+ CallService(mmep->szServiceName,mmep->Param1,lParam);
+ }else
+ {
+ CallService(mmep->szServiceName,mmep->Param1,mmep->Param2);
+ }
+
+ }
+ return(1);
+}
+INT_PTR FreeOwnerDataGroupMenu (WPARAM wParam,LPARAM lParam)
+{
+
+ lpGroupMenuExecParam mmep;
+ mmep = (lpGroupMenuExecParam)lParam;
+ if (mmep != NULL){
+ FreeAndNil((void**)&mmep->szServiceName);
+ FreeAndNil((void**)&mmep);
+ }
+
+return 0;
+}
+
+INT_PTR HideGroupsHelper(WPARAM wParam,LPARAM lParam)
+{
+ int newVal = !(GetWindowLongPtr(pcli->hwndContactTree,GWL_STYLE)&CLS_HIDEEMPTYGROUPS);
+ DBWriteContactSettingByte(NULL,"CList","HideEmptyGroups",(BYTE)newVal);
+ SendMessage(pcli->hwndContactTree,CLM_SETHIDEEMPTYGROUPS,newVal,0);
+ return 0;
+}
+
+INT_PTR UseGroupsHelper(WPARAM wParam,LPARAM lParam)
+{
+ int newVal = !(GetWindowLongPtr(pcli->hwndContactTree,GWL_STYLE)&CLS_USEGROUPS);
+ DBWriteContactSettingByte(NULL,"CList","UseGroups",(BYTE)newVal);
+ SendMessage(pcli->hwndContactTree,CLM_SETUSEGROUPS,newVal,0);
+ return 0;
+}
+
+INT_PTR HideOfflineRootHelper(WPARAM wParam,LPARAM lParam)
+{
+SendMessage(
+ pcli->hwndContactTree,
+ CLM_SETHIDEOFFLINEROOT,
+ !SendMessage(pcli->hwndContactTree,CLM_GETHIDEOFFLINEROOT,0,0),
+ 0);
+ return 0;
+}
+
+static int OnBuildGroupMenu(WPARAM wParam,LPARAM lParam)
+{
+ CLISTMENUITEM mi;
+
+
+ ZeroMemory(&mi,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.flags = CMIM_FLAGS | (DBGetContactSettingByte(NULL,"CList","HideOffline",SETTING_HIDEOFFLINE_DEFAULT)?CMIF_CHECKED:0);
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hHideOfflineUsersMenuItem, (LPARAM)&mi);
+
+ ZeroMemory(&mi,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.flags = CMIM_FLAGS | (SendMessage(pcli->hwndContactTree,CLM_GETHIDEOFFLINEROOT,0,0)?CMIF_CHECKED:0);
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hHideOfflineUsersOutHereMenuItem, (LPARAM)&mi);
+
+ ZeroMemory(&mi,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.flags = CMIM_FLAGS | (GetWindowLongPtr(pcli->hwndContactTree,GWL_STYLE)&CLS_HIDEEMPTYGROUPS?CMIF_CHECKED:0);
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hHideEmptyGroupsMenuItem, (LPARAM)&mi);
+
+ ZeroMemory(&mi,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.flags = CMIM_FLAGS | (GetWindowLongPtr(pcli->hwndContactTree,GWL_STYLE)&CLS_USEGROUPS?0:CMIF_CHECKED);
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hDisableGroupsMenuItem, (LPARAM)&mi);
+
+ return 0;
+}
+
+int static OnIconLibIconChanged(WPARAM wParam,LPARAM lParam)
+{
+ HICON hicon;
+ CLISTMENUITEM clmi = {0};
+
+ hicon = LoadIconFromExternalFile("clisticons.dll",2,TRUE,FALSE,"NewGroup","Contact List","New Group",-IDI_NEWGROUP,0);
+ NewGroupIconidx = ImageList_ReplaceIcon(hCListImages,NewGroupIconidx,hicon);
+
+ clmi.cbSize = sizeof(clmi);
+ clmi.flags = CMIM_ICON;
+ clmi.hIcon = ImageList_GetIcon(hCListImages,NewGroupIconidx,0);
+ CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)hNewSubGroupMenuItem,(LPARAM)&clmi);
+ CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)hNewGroupMenuItem,(LPARAM)&clmi);
+ return 0;
+}
+
+void InitGroupMenus(void)
+{
+ TMenuParam tmp;
+ OptParam op;
+ HICON hicon;
+ hicon = LoadIconFromExternalFile("clisticons.dll",2,TRUE,TRUE,"NewGroup","Contact List","New Group",-IDI_NEWGROUP2,0);
+ NewGroupIconidx = ImageList_AddIcon(hCListImages,hicon );
+
+ CreateServiceFunction("CLISTMENUSGroup/ExecService",GroupMenuExecService);
+ CreateServiceFunction("CLISTMENUSGroup/FreeOwnerDataGroupMenu",FreeOwnerDataGroupMenu);
+ CreateServiceFunction("CLISTMENUSGroup/GroupMenuonAddService",GroupMenuonAddService);
+ CreateServiceFunction("CLISTMENUSGroup/HideGroupsHelper",HideGroupsHelper);
+ CreateServiceFunction("CLISTMENUSGroup/UseGroupsHelper",UseGroupsHelper);
+ CreateServiceFunction("CLISTMENUSGroup/HideOfflineRootHelper",HideOfflineRootHelper);
+
+ CreateServiceFunction(MS_CLIST_ADDGROUPMENUITEM,AddGroupMenuItem);
+ CreateServiceFunction(MS_CLIST_REMOVEGROUPMENUITEM,RemoveGroupMenuItem);
+ CreateServiceFunction(MS_CLIST_MENUBUILDGROUP,BuildGroupMenu);
+ hPreBuildGroupMenuEvent = CreateHookableEvent(ME_CLIST_PREBUILDGROUPMENU);
+ HookEvent(ME_CLIST_PREBUILDGROUPMENU,OnBuildGroupMenu);
+
+ InitSubGroupMenus();
+
+ //Group menu
+ memset(&tmp,0,sizeof(tmp));
+ tmp.cbSize = sizeof(tmp);
+ tmp.CheckService = NULL;
+ tmp.ExecService = "CLISTMENUSGroup/ExecService";
+ tmp.name = "Group Menu";
+ hGroupMenuObject = (HANDLE)CallService(MO_CREATENEWMENUOBJECT,(WPARAM)0,(LPARAM)&tmp);
+
+
+ op.Handle = hGroupMenuObject;
+ op.Setting = OPT_USERDEFINEDITEMS;
+ op.Value = TRUE;
+ CallService(MO_SETOPTIONSMENUOBJECT,(WPARAM)0,(LPARAM)&op);
+
+ op.Handle = hGroupMenuObject;
+ op.Setting = OPT_MENUOBJECT_SET_FREE_SERVICE;
+ op.Value = (INT_PTR)"CLISTMENUSGroup/FreeOwnerDataGroupMenu";
+ CallService(MO_SETOPTIONSMENUOBJECT,(WPARAM)0,(LPARAM)&op);
+
+ op.Handle = hGroupMenuObject;
+ op.Setting = OPT_MENUOBJECT_SET_ONADD_SERVICE;
+ op.Value = (INT_PTR)"CLISTMENUSGroup/GroupMenuonAddService";
+ CallService(MO_SETOPTIONSMENUOBJECT,(WPARAM)0,(LPARAM)&op);
+
+ {
+ //add exit command to menu
+ CLISTMENUITEM mi;
+ GroupMenuParam gmp;
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 1900000;
+ mi.pszService = "CloseAction";
+ mi.pszName = LPGEN("E&xit");
+ AddGroupMenuItem((WPARAM)0,(LPARAM)&mi);
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 500;
+ mi.pszService = MS_CLIST_SHOWHIDE;
+ mi.pszName = LPGEN("&Hide/Show");
+ hHideShowMainMenuItem = (HANDLE)AddGroupMenuItem((WPARAM)0,(LPARAM)&mi);
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 200000;
+ mi.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_FINDUSER));
+ mi.pszService = "FindAdd/FindAddCommand";
+ mi.pszName = LPGEN("&Find/Add Contacts...");
+ AddGroupMenuItem((WPARAM)0,(LPARAM)&mi);
+
+
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 300000;
+ mi.pszService = "";
+ mi.pszName = LPGEN("&Main Menu");
+ hGroupMainMenuItemProxy = (HANDLE)AddGroupMenuItem((WPARAM)0,(LPARAM)&mi);
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 300100;
+ mi.pszService = "";
+ mi.pszName = LPGEN("&Status");
+ hGroupStatusMenuItemProxy = (HANDLE)AddGroupMenuItem((WPARAM)0,(LPARAM)&mi);
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 400000;
+ mi.hIcon = LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_OPTIONS));
+ mi.pszService = "Options/OptionsCommand";
+ mi.pszName = LPGEN("&Options...");
+
+ AddGroupMenuItem((WPARAM)0,(LPARAM)&mi);
+
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 500000;
+ mi.hIcon = LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_CLIENTMIRANDA));
+ mi.pszService = "Help/AboutCommand";
+ mi.pszName = LPGEN("&About");
+
+ //AddGroupMenuItem((WPARAM)0,(LPARAM)&mi);
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 100000;
+ mi.hIcon = ImageList_GetIcon(hCListImages,NewGroupIconidx,0);
+ mi.pszService = MS_CLIST_GROUPCREATE;
+ mi.pszName = LPGEN("&New Group");
+ hNewGroupMenuItem = (HANDLE)AddGroupMenuItem((WPARAM)0,(LPARAM)&mi);
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 100001;
+ mi.hIcon = NULL;
+ mi.pszService = MS_CLIST_SETHIDEOFFLINE;
+ mi.pszName = LPGEN("&Hide Offline Users");
+ gmp.lParam = 0;gmp.wParam = -1;
+ hHideOfflineUsersMenuItem = (HANDLE)AddGroupMenuItem((WPARAM)&gmp,(LPARAM)&mi);
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 100002;
+ mi.hIcon = NULL;
+ mi.pszService = "CLISTMENUSGroup/HideOfflineRootHelper";
+ mi.pszName = LPGEN("Hide &Offline Users out here");
+ hHideOfflineUsersOutHereMenuItem = (HANDLE)AddGroupMenuItem((WPARAM)0,(LPARAM)&mi);
+
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 100003;
+ mi.hIcon = NULL;
+ mi.pszService = "CLISTMENUSGroup/HideGroupsHelper";
+ mi.pszName = LPGEN("Hide &Empty Groups");
+ hHideEmptyGroupsMenuItem = (HANDLE)AddGroupMenuItem((WPARAM)0,(LPARAM)&mi);
+
+
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 100004;
+ mi.hIcon = NULL;
+ mi.pszService = "CLISTMENUSGroup/UseGroupsHelper";
+ mi.pszName = LPGEN("Disable &Groups");
+ hDisableGroupsMenuItem = (HANDLE)AddGroupMenuItem((WPARAM)0,(LPARAM)&mi);
+
+
+ HookEvent(ME_SKIN2_ICONSCHANGED,OnIconLibIconChanged);
+
+ //MS_CLIST_GROUPCREATE
+
+ }
+}
+
+//////////////////////////////END Group MENU/////////////////////////
+
+
+
+
+//////////////////////////////SubGroup MENU/////////////////////////
+HANDLE hSubGroupMenuObject;
+
+HANDLE hSubGroupMainMenuItemProxy;
+HANDLE hSubGroupStatusMenuItemProxy;
+HANDLE hPreBuildSubGroupMenuEvent;
+HANDLE hHideOfflineUsersHereMenuItem;
+
+//SubGroupmenu exec param(ownerdata)
+typedef struct{
+char *szServiceName;
+int Param1,Param2;
+}SubGroupMenuExecParam,*lpSubGroupMenuExecParam;
+
+/*
+wparam = handle to the menu item returned by MS_CLIST_ADDCONTACTMENUITEM
+return 0 on success.
+*/
+static INT_PTR RemoveSubGroupMenuItem(WPARAM wParam,LPARAM lParam)
+{
+ CallService(MO_REMOVEMENUITEM,wParam,0);
+ return 0;
+}
+
+static int OnBuildSubGroupMenu(WPARAM wParam,LPARAM lParam)
+{
+ CLISTMENUITEM mi;
+ struct ClcGroup *group = (struct ClcGroup *)wParam;
+ if (wParam == 0) return 0;
+
+ //contact->group
+
+ ZeroMemory(&mi,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.flags = CMIM_FLAGS | (group->hideOffline?CMIF_CHECKED:0);
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hHideOfflineUsersHereMenuItem, (LPARAM)&mi);
+
+ return 0;
+}
+static INT_PTR BuildSubGroupMenu(WPARAM wParam,LPARAM lParam)
+{
+ int tick;
+ HMENU hMenu;
+ ListParam param = { 0 };
+ param.MenuObjectHandle = hSubGroupMenuObject;
+ param.wParam = wParam;
+
+ //hMenu = hMainMenu;
+ hMenu = CreatePopupMenu();
+ //hMenu = wParam;
+ tick = GetTickCount();
+
+ NotifyEventHooks(hPreBuildSubGroupMenuEvent,wParam,0);
+
+ CallService(MO_BUILDMENU,(WPARAM)hMenu,(LPARAM)&param);
+ //DrawMenuBar((HWND)CallService("CLUI/GetHwnd",0,0));
+ tick = GetTickCount()-tick;
+ return (INT_PTR)hMenu;
+}
+
+static INT_PTR AddSubGroupMenuItem(WPARAM wParam,LPARAM lParam)
+{
+ CLISTMENUITEM *mi = (CLISTMENUITEM*)lParam;
+ lpGroupMenuParam gmp = (lpGroupMenuParam)wParam;
+ char buf[1024];
+ TMO_MenuItem tmi;
+ OptParam op;
+
+ if (mi->cbSize != sizeof(CLISTMENUITEM)) return 0;
+ memset(&tmi,0,sizeof(tmi));
+ tmi.cbSize = sizeof(tmi);
+ tmi.flags = mi->flags;
+ tmi.hIcon = mi->hIcon;
+ tmi.hotKey = mi->hotKey;
+ tmi.pszName = mi->pszName;
+ tmi.position = mi->position;
+
+ //pszPopupName for new system mean root level
+ //pszPopupName for old system mean that exists popup
+ tmi.root = mi->hParentMenu;
+
+ tmi.ownerdata = NULL;
+
+ { lpSubGroupMenuExecParam mmep = (lpSubGroupMenuExecParam)mir_calloc(sizeof(SubGroupMenuExecParam));
+ if ( mmep == NULL)
+ return 0;
+
+ //we need just one parametr.
+ mmep->szServiceName = mir_strdup(mi->pszService);
+ mmep->Param1 = mi->popupPosition;
+ if ( gmp != NULL ) {
+ mmep->Param1 = gmp->wParam;
+ mmep->Param2 = gmp->lParam;
+ }
+
+ tmi.ownerdata = mmep;
+ }
+ op.Handle = (HANDLE)CallService(MO_ADDNEWMENUITEM,(WPARAM)hSubGroupMenuObject,(LPARAM)&tmi);
+ op.Setting = OPT_MENUITEMSETUNIQNAME;
+ sprintf(buf,"%s/%s",mi->pszService,mi->pszName);
+ op.Value = (INT_PTR)buf;
+ CallService(MO_SETOPTIONSMENUITEM,(WPARAM)0,(LPARAM)&op);
+ return (INT_PTR)op.Handle;
+}
+
+INT_PTR SubGroupMenuCheckService(WPARAM wParam,LPARAM lParam)
+{
+ return 0;
+}
+
+INT_PTR SubGroupMenuonAddService(WPARAM wParam,LPARAM lParam)
+{
+ MENUITEMINFO *mii = (MENUITEMINFO* )wParam;
+ if (mii == NULL)
+ return 0;
+
+ return TRUE;
+}
+
+//called with:
+//wparam - ownerdata
+//lparam - lparam from winproc
+INT_PTR SubGroupMenuExecService(WPARAM wParam,LPARAM lParam)
+{
+ if (wParam != 0) {
+ lpSubGroupMenuExecParam mmep = (lpSubGroupMenuExecParam)wParam;
+ if (!strcmp(mmep->szServiceName,"Help/AboutCommand")) {
+ //bug in help.c,it used wparam as parent window handle without reason.
+ mmep->Param1 = 0;
+ CallService(mmep->szServiceName,mmep->Param1,lParam);
+ }
+ else CallService(mmep->szServiceName,mmep->Param1,mmep->Param2);
+ }
+
+ return 1;
+}
+
+INT_PTR FreeOwnerDataSubGroupMenu (WPARAM wParam,LPARAM lParam)
+{
+ lpSubGroupMenuExecParam mmep;
+ mmep = (lpSubGroupMenuExecParam)lParam;
+ if (mmep != NULL) {
+ FreeAndNil((void**)&mmep->szServiceName);
+ FreeAndNil((void**)&mmep);
+ }
+
+ return 0;
+}
+
+//wparam menu handle to pass to clc.c
+INT_PTR GroupMenuExecProxy(WPARAM wParam,LPARAM lParam)
+{
+ SendMessage(pcli->hwndContactTree,WM_COMMAND,wParam,0);
+ return 0;
+}
+
+void InitSubGroupMenus(void)
+{
+ TMenuParam tmp;
+ OptParam op;
+
+ CreateServiceFunction("CLISTMENUSSubGroup/ExecService",SubGroupMenuExecService);
+ CreateServiceFunction("CLISTMENUSSubGroup/FreeOwnerDataSubGroupMenu",FreeOwnerDataSubGroupMenu);
+ CreateServiceFunction("CLISTMENUSSubGroup/SubGroupMenuonAddService",SubGroupMenuonAddService);
+ CreateServiceFunction("CLISTMENUSSubGroup/GroupMenuExecProxy",GroupMenuExecProxy);
+
+ CreateServiceFunction(MS_CLIST_ADDSUBGROUPMENUITEM,AddSubGroupMenuItem);
+ CreateServiceFunction(MS_CLIST_REMOVESUBGROUPMENUITEM,RemoveSubGroupMenuItem);
+ CreateServiceFunction(MS_CLIST_MENUBUILDSUBGROUP,BuildSubGroupMenu);
+ hPreBuildSubGroupMenuEvent = CreateHookableEvent(ME_CLIST_PREBUILDSUBGROUPMENU);
+ HookEvent(ME_CLIST_PREBUILDSUBGROUPMENU,OnBuildSubGroupMenu);
+
+ //SubGroup menu
+ memset(&tmp,0,sizeof(tmp));
+ tmp.cbSize = sizeof(tmp);
+ tmp.CheckService = NULL;
+ tmp.ExecService = "CLISTMENUSSubGroup/ExecService";
+ tmp.name = "SubGroupMenu";
+ hSubGroupMenuObject = (HANDLE)CallService(MO_CREATENEWMENUOBJECT,(WPARAM)0,(LPARAM)&tmp);
+
+
+ op.Handle = hSubGroupMenuObject;
+ op.Setting = OPT_USERDEFINEDITEMS;
+ op.Value = TRUE;
+ CallService(MO_SETOPTIONSMENUOBJECT,(WPARAM)0,(LPARAM)&op);
+
+ op.Handle = hSubGroupMenuObject;
+ op.Setting = OPT_MENUOBJECT_SET_FREE_SERVICE;
+ op.Value = (INT_PTR)"CLISTMENUSSubGroup/FreeOwnerDataSubGroupMenu";
+ CallService(MO_SETOPTIONSMENUOBJECT,(WPARAM)0,(LPARAM)&op);
+
+ op.Handle = hSubGroupMenuObject;
+ op.Setting = OPT_MENUOBJECT_SET_ONADD_SERVICE;
+ op.Value = (INT_PTR)"CLISTMENUSSubGroup/SubGroupMenuonAddService";
+ CallService(MO_SETOPTIONSMENUOBJECT,(WPARAM)0,(LPARAM)&op);
+
+ {
+ //add exit command to menu
+ CLISTMENUITEM mi;
+ GroupMenuParam gmp;
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 1000;
+ mi.hIcon = ImageList_GetIcon(hCListImages,NewGroupIconidx,0);
+ mi.pszService = "CLISTMENUSSubGroup/GroupMenuExecProxy";
+ mi.pszName = LPGEN("&New SubGroup");
+ gmp.lParam = 0;gmp.wParam = POPUP_NEWSUBGROUP;
+ hNewSubGroupMenuItem = (HANDLE)AddSubGroupMenuItem((WPARAM)&gmp,(LPARAM)&mi);
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 1001;
+ mi.hIcon = NULL;
+ mi.pszService = "CLISTMENUSSubGroup/GroupMenuExecProxy";
+ mi.pszName = LPGEN("&Hide Offline Users in here");
+ gmp.lParam = 0;gmp.wParam = POPUP_GROUPHIDEOFFLINE;
+ hHideOfflineUsersHereMenuItem = (HANDLE)AddSubGroupMenuItem((WPARAM)&gmp,(LPARAM)&mi);
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 900001;
+ mi.flags = CMIF_ICONFROMICOLIB;
+ mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_RENAME); //LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_RENAME));
+ mi.pszService = "CLISTMENUSSubGroup/GroupMenuExecProxy";
+ mi.pszName = LPGEN("&Rename Group");
+ gmp.lParam = 0;gmp.wParam = POPUP_RENAMEGROUP;
+ AddSubGroupMenuItem((WPARAM)&gmp,(LPARAM)&mi);
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 900002;
+ mi.flags = CMIF_ICONFROMICOLIB;
+ mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_DELETE); //LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_DELETE));
+ mi.pszService = "CLISTMENUSSubGroup/GroupMenuExecProxy";
+ mi.pszName = LPGEN("&Delete Group");
+ gmp.lParam = 0;gmp.wParam = POPUP_DELETEGROUP;
+ AddSubGroupMenuItem((WPARAM)&gmp,(LPARAM)&mi);
+
+ //MS_CLIST_SubGroupCREATE
+
+ }
+}
+
+//////////////////////////////END SubGroup MENU/////////////////////////
diff --git a/plugins/Mwclist/init.c b/plugins/Mwclist/init.cpp
index 7f026bd95f..970004f73b 100644
--- a/plugins/Mwclist/init.c
+++ b/plugins/Mwclist/init.cpp
@@ -72,7 +72,8 @@ INT_PTR TrayIconProcessMessage(WPARAM wParam,LPARAM lParam);
int (*saveIconFromStatusMode)(const char *szProto,int nStatus, HANDLE hContact);
int cli_IconFromStatusMode(const char *szProto,int nStatus, HANDLE hContact);
-
+//from clcfonts
+void RegisterCListFonts( void );
//from bgrcfg
extern int BGModuleLoad();
extern int BGModuleUnload();
@@ -122,7 +123,7 @@ static int systemModulesLoaded(WPARAM wParam, LPARAM lParam)
{
__try {
int *disableDefaultModule = 0;
- disableDefaultModule=(int*)CallService(MS_PLUGINS_GETDISABLEDEFAULTARRAY,0,0);
+ disableDefaultModule = (int*)CallService(MS_PLUGINS_GETDISABLEDEFAULTARRAY,0,0);
if (!disableDefaultModule[DEFMOD_UICLUI]) if ( LoadCLUIModule()) return 1;
}
__except (exceptFunction(GetExceptionInformation()) )
@@ -131,21 +132,22 @@ static int systemModulesLoaded(WPARAM wParam, LPARAM lParam)
}
InitSkinHotKeys();
+ RegisterCListFonts();
return 0;
}
INT_PTR SetDrawer(WPARAM wParam,LPARAM lParam)
{
- pDrawerServiceStruct DSS=(pDrawerServiceStruct)wParam;
- if (DSS->cbSize!=sizeof(*DSS)) return -1;
- if (DSS->PluginName==NULL) return -1;
- if (DSS->PluginName==NULL) return -1;
+ pDrawerServiceStruct DSS = (pDrawerServiceStruct)wParam;
+ if (DSS->cbSize != sizeof(*DSS)) return -1;
+ if (DSS->PluginName == NULL) return -1;
+ if (DSS->PluginName == NULL) return -1;
if (!ServiceExists(DSS->GetDrawFuncsServiceName)) return -1;
- SED.cbSize=sizeof(SED);
- SED.PaintClc=(void (__cdecl *)(HWND,struct ClcData *,HDC,RECT *,int ,ClcProtoStatus *,HIMAGELIST))CallService(DSS->GetDrawFuncsServiceName,CLUI_EXT_FUNC_PAINTCLC,0);
+ SED.cbSize = sizeof(SED);
+ SED.PaintClc = (void (__cdecl *)(HWND,struct ClcData *,HDC,RECT *,int ,ClcProtoStatus *,HIMAGELIST))CallService(DSS->GetDrawFuncsServiceName,CLUI_EXT_FUNC_PAINTCLC,0);
if (!SED.PaintClc) return -1;
return 0;
}
@@ -165,8 +167,8 @@ static ClcCacheEntryBase* fnCreateCacheItem( HANDLE hContact )
int __declspec(dllexport) CListInitialise(PLUGINLINK * link)
{
- int rc=0;
- pluginLink=link;
+ int rc = 0;
+ pluginLink = link;
#ifdef _DEBUG
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif
@@ -207,7 +209,7 @@ LBL_Error:
pcli->pfnRecalcScrollBar = RecalcScrollBar;
pcli->pfnScrollTo = ScrollTo;
- saveIconFromStatusMode = pcli->pfnIconFromStatusMode;
+ saveIconFromStatusMode = pcli->pfnIconFromStatusMode;
pcli->pfnIconFromStatusMode = cli_IconFromStatusMode;
saveAddGroup = pcli->pfnAddGroup; pcli->pfnAddGroup = AddGroup;
@@ -225,8 +227,8 @@ LBL_Error:
memset(&SED,0,sizeof(SED));
CreateServiceFunction(CLUI_SetDrawerService,SetDrawer);
- rc=LoadContactListModule();
- if (rc==0) rc=LoadCLCModule();
+ rc = LoadContactListModule();
+ if (rc == 0) rc = LoadCLCModule();
HookEvent(ME_SYSTEM_MODULESLOADED, systemModulesLoaded);
BGModuleLoad();
@@ -255,6 +257,6 @@ int __declspec(dllexport) Unload(void)
OutputDebugStringA("Unloading ClistMW\r\n");
if (IsWindow(pcli->hwndContactList)) DestroyWindow(pcli->hwndContactList);
BGModuleUnload();
- pcli->hwndContactList=0;
+ pcli->hwndContactList = 0;
return 0;
}
diff --git a/plugins/Mwclist/keyboard.c b/plugins/Mwclist/keyboard.cpp
index 11317e3e90..361a4f56f5 100644
--- a/plugins/Mwclist/keyboard.c
+++ b/plugins/Mwclist/keyboard.cpp
@@ -32,32 +32,32 @@ INT_PTR hkCloseMiranda(WPARAM wParam,LPARAM lParam)
INT_PTR hkRestoreStatus(WPARAM wParam,LPARAM lParam)
{
int nStatus = DBGetContactSettingWord(NULL, "CList", "Status", ID_STATUS_OFFLINE);
- CallService(MS_CLIST_SETSTATUSMODE, nStatus, 0);
+ CallService(MS_CLIST_SETSTATUSMODE, nStatus, 0);
return 0;
}
int InitSkinHotKeys(void)
{
- HOTKEYDESC shk={0};
+ HOTKEYDESC shk = {0};
CreateServiceFunction("CLIST/HK/CloseMiranda",hkCloseMiranda);
CreateServiceFunction("CLIST/HK/RestoreStatus",hkRestoreStatus);
- shk.cbSize=sizeof(shk);
+ shk.cbSize = sizeof(shk);
- shk.pszDescription="Close Miranda";
- shk.pszName="CloseMiranda";
- shk.pszSection="Main";
- shk.pszService="CLIST/HK/CloseMiranda";
- shk.DefHotKey=0;
+ shk.pszDescription = "Close Miranda";
+ shk.pszName = "CloseMiranda";
+ shk.pszSection = "Main";
+ shk.pszService = "CLIST/HK/CloseMiranda";
+ shk.DefHotKey = 0;
CallService(MS_HOTKEY_REGISTER,0,(LPARAM)&shk);
- shk.pszDescription="Restore last status";
- shk.pszName="RestoreLastStatus";
- shk.pszSection="Status";
- shk.pszService="CLIST/HK/RestoreStatus";
- shk.DefHotKey=0;
+ shk.pszDescription = "Restore last status";
+ shk.pszName = "RestoreLastStatus";
+ shk.pszSection = "Status";
+ shk.pszService = "CLIST/HK/RestoreStatus";
+ shk.DefHotKey = 0;
CallService(MS_HOTKEY_REGISTER,0,(LPARAM)&shk);
return 0;
diff --git a/plugins/Mwclist/resource.h b/plugins/Mwclist/resource.h
index ff11dc2f90..06c9b4c9df 100644
--- a/plugins/Mwclist/resource.h
+++ b/plugins/Mwclist/resource.h
@@ -87,7 +87,6 @@
#define IDD_ADDEMAIL 226
#define IDD_ICONINDEX 227
#define IDD_OPT_CLC 228
-#define IDD_OPT_CLCTEXT 229
#define IDD_OPT_CLCBKG 230
#define IDD_INFO_LOCATION 231
#define IDD_INFO_WORK 232
@@ -96,7 +95,6 @@
#define IDD_INSTALLINI 235
#define IDD_WARNINICHANGE 236
#define IDD_INIIMPORTDONE 237
-#define IDD_OPT_CLCTEXTSIMPLE 239
#define IDB_SORTCOLUP 239
#define IDB_SORTCOLDOWN 240
#define IDD_OPT_NETLIB 246
@@ -592,12 +590,8 @@
#define IDC_AALONGIDLE 1656
#define IDC_NOOFFLINEMOVE 1657
#define IDC_HOTKEYTREE 1657
-#define IDC_HILIGHTMODE 1658
-#define IDC_HILIGHTMODE2 1659
#define IDC_LOCATION 1659
-#define IDC_HILIGHTMODE1 1660
#define IDC_SGROUP 1660
-#define IDC_HILIGHTMODE3 1661
#define IDC_SLOC 1661
#define IDC_ONDESKTOP 1662
#define IDC_SETHOTKEY 1759
diff --git a/plugins/Mwclist/resource.rc b/plugins/Mwclist/resource.rc
index 8e7cf8a215..cb5632154a 100644
--- a/plugins/Mwclist/resource.rc
+++ b/plugins/Mwclist/resource.rc
@@ -171,7 +171,7 @@ BEGIN
IDC_STATIC,7,18,239,14
END
-IDD_OPT_CLIST DIALOGEX 0, 0, 314, 206
+IDD_OPT_CLIST DIALOGEX 0, 0, 314, 232
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
@@ -244,9 +244,20 @@ BEGIN
WS_TABSTOP,10,120,125,15
CONTROL "Disable icon blinking",IDC_ICONBLINK,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,10,84,97,10
+
+ GROUPBOX "Rows",IDC_STATIC,2,199,174,31
+ LTEXT "Row height:",IDC_STATIC,10,213,65,8
+ EDITTEXT IDC_ROWHEIGHT,77,211,31,12,ES_RIGHT | ES_NUMBER
+ CONTROL "Spin1",IDC_ROWHEIGHTSPIN,"msctls_updown32",
+ UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY |
+ UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,97,210,10,14
+ LTEXT "pixels",IDC_STATIC,112,213,62,8
+
+ CONTROL "Gamma correction",IDC_GAMMACORRECT,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,180,211,95,10
END
-IDD_OPT_CLUI DIALOGEX 0, 0, 313, 232
+IDD_OPT_CLUI DIALOGEX 0, 0, 314, 232
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
@@ -401,73 +412,6 @@ BEGIN
BS_AUTOCHECKBOX | WS_TABSTOP,165,160,140,10
END
-IDD_OPT_CLCTEXT DIALOGEX 0, 0, 277, 256
-STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE
-EXSTYLE WS_EX_CONTROLPARENT
-FONT 8, "MS Shell Dlg", 0, 0, 0x1
-BEGIN
- GROUPBOX "Fonts",IDC_STATIC,5,5,269,125
- COMBOBOX IDC_FONTID,12,17,253,87,CBS_DROPDOWNLIST | WS_VSCROLL |
- WS_TABSTOP
- LTEXT "same",IDC_STSAMETEXT,19,32,45,10,SS_CENTERIMAGE
- CONTROL "Typeface",IDC_SAMETYPE,"Button",BS_AUTOCHECKBOX |
- WS_TABSTOP,64,32,52,10
- CONTROL "Size",IDC_SAMESIZE,"Button",BS_AUTOCHECKBOX |
- WS_TABSTOP,117,32,45,10
- CONTROL "Style",IDC_SAMESTYLE,"Button",BS_AUTOCHECKBOX |
- WS_TABSTOP,163,32,48,10
- CONTROL "Colour",IDC_SAMECOLOUR,"Button",BS_AUTOCHECKBOX |
- WS_TABSTOP,212,32,53,10
- LTEXT "as:",IDC_STASTEXT,19,46,45,10,SS_CENTERIMAGE
- COMBOBOX IDC_SAMEAS,64,45,196,88,CBS_DROPDOWNLIST | WS_VSCROLL |
- WS_TABSTOP
- CONTROL "",IDC_STHORZBAR,"Static",SS_ETCHEDFRAME,9,60,259,5
- COMBOBOX IDC_TYPEFACE,12,72,136,182,CBS_DROPDOWN | CBS_SORT |
- WS_VSCROLL | WS_TABSTOP
- COMBOBOX IDC_SCRIPT,156,72,60,68,CBS_DROPDOWNLIST | WS_VSCROLL |
- WS_TABSTOP
- COMBOBOX IDC_FONTSIZE,225,72,40,69,CBS_DROPDOWN | WS_VSCROLL |
- WS_TABSTOP
- CONTROL "Bold",IDC_BOLD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,
- 88,45,10
- CONTROL "Italic",IDC_ITALIC,"Button",BS_AUTOCHECKBOX |
- WS_TABSTOP,65,88,52,10
- CONTROL "Underline",IDC_UNDERLINE,"Button",BS_AUTOCHECKBOX |
- WS_TABSTOP,117,88,66,10
- CONTROL "",IDC_COLOUR,"ColourPicker",WS_TABSTOP,206,87,59,12
- EDITTEXT IDC_SAMPLE,63,104,151,16,ES_CENTER | ES_READONLY | NOT
- WS_TABSTOP
- GROUPBOX "Rows",IDC_STATIC,4,134,269,31
- LTEXT "Row height:",IDC_STATIC,12,148,65,8
- EDITTEXT IDC_ROWHEIGHT,77,146,31,12,ES_RIGHT | ES_NUMBER
- CONTROL "Spin1",IDC_ROWHEIGHTSPIN,"msctls_updown32",
- UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY |
- UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,97,145,10,
- 14
- LTEXT "pixels",IDC_STATIC,112,148,62,8
- GROUPBOX "Additional Colours",IDC_STATIC,4,171,121,79
- LTEXT "Selected text:",IDC_STATIC,12,186,65,8
- CONTROL "",IDC_SELCOLOUR,"ColourPicker",WS_TABSTOP,77,184,29,12
- LTEXT "Hottrack text:",IDC_STATIC,12,201,65,8
- CONTROL "",IDC_HOTCOLOUR,"ColourPicker",WS_TABSTOP,77,199,29,12
- CONTROL "Gamma correction",IDC_GAMMACORRECT,"Button",
- BS_AUTOCHECKBOX | WS_TABSTOP,12,235,95,10
- LTEXT "Quicksearch text:",IDC_STATIC,12,218,65,8
- CONTROL "",IDC_QUICKCOLOUR,"ColourPicker",WS_TABSTOP,77,216,29,
- 12
- LTEXT "Size:",IDC_STSIZETEXT,231,114,34,8,NOT WS_VISIBLE
- LTEXT "Colour:",IDC_STCOLOURTEXT,228,102,37,8,NOT WS_VISIBLE
- GROUPBOX "Selection Mode",IDC_STATIC,130,171,144,79
- CONTROL "Default",IDC_HILIGHTMODE,"Button",BS_AUTORADIOBUTTON,
- 145,185,120,10
- CONTROL "Less selection",IDC_HILIGHTMODE2,"Button",
- BS_AUTORADIOBUTTON,145,215,120,10
- CONTROL "Full selection",IDC_HILIGHTMODE1,"Button",
- BS_AUTORADIOBUTTON,145,200,120,10
- CONTROL "No selection",IDC_HILIGHTMODE3,"Button",
- BS_AUTORADIOBUTTON,145,230,120,10
-END
-
IDD_OPT_CLCBKG DIALOGEX 0, 0, 235, 151
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE
EXSTYLE WS_EX_CONTROLPARENT
@@ -498,53 +442,6 @@ BEGIN
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,125,205,10
END
-IDD_OPT_CLCTEXTSIMPLE DIALOGEX 0, 0, 277, 240
-STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE
-EXSTYLE WS_EX_CONTROLPARENT
-FONT 8, "MS Shell Dlg", 0, 0, 0x1
-BEGIN
- GROUPBOX "Fonts",IDC_STATIC,4,4,269,125
- COMBOBOX IDC_FONTID,12,17,253,87,CBS_DROPDOWNLIST | WS_VSCROLL |
- WS_TABSTOP
- LTEXT "as:",IDC_STASTEXT,25,34,52,10,SS_CENTERIMAGE
- COMBOBOX IDC_SAMEAS,77,33,163,88,CBS_DROPDOWNLIST | WS_VSCROLL |
- WS_TABSTOP
- CONTROL "",IDC_STHORZBAR,"Static",SS_ETCHEDHORZ,9,51,259,1
- COMBOBOX IDC_TYPEFACE,12,58,172,182,CBS_DROPDOWN | CBS_SORT |
- WS_VSCROLL | WS_TABSTOP
- COMBOBOX IDC_SCRIPT,192,58,73,68,CBS_DROPDOWNLIST | WS_VSCROLL |
- WS_TABSTOP
- LTEXT "Size:",IDC_STSIZETEXT,33,76,34,8
- COMBOBOX IDC_FONTSIZE,67,74,54,69,CBS_DROPDOWN | WS_VSCROLL |
- WS_TABSTOP
- LTEXT "Colour:",IDC_STCOLOURTEXT,147,76,37,8
- CONTROL "",IDC_COLOUR,"ColourPicker",WS_TABSTOP,184,74,59,12
- CONTROL "Bold",IDC_BOLD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,58,
- 90,45,10
- CONTROL "Italic",IDC_ITALIC,"Button",BS_AUTOCHECKBOX |
- WS_TABSTOP,117,90,52,10
- CONTROL "Underline",IDC_UNDERLINE,"Button",BS_AUTOCHECKBOX |
- WS_TABSTOP,179,90,66,10
- EDITTEXT IDC_SAMPLE,63,104,151,16,ES_CENTER | ES_READONLY | NOT
- WS_TABSTOP
- GROUPBOX "Rows",IDC_STATIC,4,134,269,31
- LTEXT "Row height:",IDC_STATIC,12,148,65,8
- EDITTEXT IDC_ROWHEIGHT,77,146,31,12,ES_RIGHT | ES_NUMBER
- CONTROL "Spin1",IDC_ROWHEIGHTSPIN,"msctls_updown32",
- UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY |
- UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,97,145,10,
- 14
- LTEXT "pixels",IDC_STATIC,112,148,62,8
- GROUPBOX "Additional Colours",IDC_STATIC,4,171,269,65
- LTEXT "Selected text:",IDC_STATIC,12,186,65,8
- CONTROL "",IDC_SELCOLOUR,"ColourPicker",WS_TABSTOP,77,184,29,12
- LTEXT "Hottrack text:",IDC_STATIC,12,202,65,8
- CONTROL "",IDC_HOTCOLOUR,"ColourPicker",WS_TABSTOP,77,200,29,12
- LTEXT "Quicksearch text:",IDC_STATIC,12,218,65,8
- CONTROL "",IDC_QUICKCOLOUR,"ColourPicker",WS_TABSTOP,77,216,29,
- 12
-END
-
IDD_OPT_META_CLC DIALOGEX 0, 0, 259, 97
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE
EXSTYLE WS_EX_CONTROLPARENT
@@ -629,27 +526,6 @@ BEGIN
HORZGUIDE, 222
END
- IDD_OPT_CLCTEXT, DIALOG
- BEGIN
- LEFTMARGIN, 4
- RIGHTMARGIN, 273
- VERTGUIDE, 12
- VERTGUIDE, 19
- VERTGUIDE, 77
- VERTGUIDE, 258
- VERTGUIDE, 265
- TOPMARGIN, 4
- BOTTOMMARGIN, 252
- HORZGUIDE, 37
- HORZGUIDE, 51
- HORZGUIDE, 79
- HORZGUIDE, 94
- HORZGUIDE, 152
- HORZGUIDE, 190
- HORZGUIDE, 205
- HORZGUIDE, 222
- END
-
IDD_OPT_CLCBKG, DIALOG
BEGIN
LEFTMARGIN, 4
@@ -667,27 +543,6 @@ BEGIN
HORZGUIDE, 115
END
- IDD_OPT_CLCTEXTSIMPLE, DIALOG
- BEGIN
- LEFTMARGIN, 4
- RIGHTMARGIN, 273
- VERTGUIDE, 12
- VERTGUIDE, 19
- VERTGUIDE, 77
- VERTGUIDE, 258
- VERTGUIDE, 265
- TOPMARGIN, 4
- BOTTOMMARGIN, 236
- HORZGUIDE, 37
- HORZGUIDE, 64
- HORZGUIDE, 80
- HORZGUIDE, 95
- HORZGUIDE, 152
- HORZGUIDE, 190
- HORZGUIDE, 206
- HORZGUIDE, 222
- END
-
IDD_OPT_META_CLC, DIALOG
BEGIN
LEFTMARGIN, 2