From 1a69d21a165c1b952d697aab49b7cb4e14573c58 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 17 Dec 2013 22:39:14 +0000 Subject: further frames code merging git-svn-id: http://svn.miranda-ng.org/main/trunk@7266 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Clist_modern/src/CLUIFrames/cluiframes.cpp | 40 +++--- plugins/Clist_modern/src/CLUIFrames/cluiframes.h | 18 +-- plugins/Clist_modern/src/CLUIFrames/framesmenu.cpp | 47 +++---- .../Clist_modern/src/hdr/modern_commonprototypes.h | 1 - .../Clist_modern/src/hdr/modern_global_structure.h | 1 - plugins/Clist_modern/src/init.cpp | 1 - plugins/Clist_mw/src/CLUIFrames/cluiframes.cpp | 115 +++------------- plugins/Clist_mw/src/CLUIFrames/cluiframes.h | 87 +++++++++++- plugins/Clist_mw/src/CLUIFrames/framesmenu.cpp | 74 ++++------ plugins/Clist_mw/src/clc.h | 2 - plugins/Clist_mw/src/clisttray.cpp | 4 +- plugins/Clist_mw/src/groupmenu.cpp | 22 ++- plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp | 52 +++---- plugins/Clist_nicer/src/CLUIFrames/cluiframes.h | 152 ++++++++++++--------- plugins/Clist_nicer/src/CLUIFrames/framesmenu.cpp | 131 +++++++----------- plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp | 31 ++--- plugins/Clist_nicer/src/Include/commonheaders.h | 2 - plugins/Clist_nicer/src/clc.cpp | 2 +- plugins/Clist_nicer/src/clistevents.cpp | 2 +- plugins/Clist_nicer/src/clui.cpp | 10 +- plugins/Clist_nicer/src/cluiservices.cpp | 2 +- plugins/Clist_nicer/src/viewmodes.cpp | 2 +- 22 files changed, 371 insertions(+), 427 deletions(-) diff --git a/plugins/Clist_modern/src/CLUIFrames/cluiframes.cpp b/plugins/Clist_modern/src/CLUIFrames/cluiframes.cpp index f30b090a19..6b3fa35d5f 100644 --- a/plugins/Clist_modern/src/CLUIFrames/cluiframes.cpp +++ b/plugins/Clist_modern/src/CLUIFrames/cluiframes.cpp @@ -698,7 +698,7 @@ static int DBStoreFrameSettingsAtPos(int pos,int Frameid) _itoa(pos,sadd,10); - db_set_ws(0, CLUIFrameModule,AS(buf,"Name",sadd),g_pfwFrames[Frameid].Name); + db_set_ws(0, CLUIFrameModule,AS(buf,"Name",sadd),g_pfwFrames[Frameid].name); //bool db_set_b(0, CLUIFrameModule,AS(buf,"Collapse",sadd),(BYTE)btoint(g_pfwFrames[Frameid].collapsed)); db_set_b(0, CLUIFrameModule,AS(buf,"Locked",sadd),(BYTE)btoint(g_pfwFrames[Frameid].Locked)); @@ -722,7 +722,7 @@ static int DBStoreFrameSettingsAtPos(int pos,int Frameid) static int LocateStorePosition(int Frameid,int maxstored) { - if (g_pfwFrames[Frameid].Name == NULL) + if (g_pfwFrames[Frameid].name == NULL) return -1; char settingname[255]; @@ -732,7 +732,7 @@ static int LocateStorePosition(int Frameid,int maxstored) if ( db_get_ts( NULL, CLUIFrameModule, settingname, &dbv )) continue; - if ( lstrcmpi(dbv.ptszVal, g_pfwFrames[Frameid].Name) == 0) { + if ( lstrcmpi(dbv.ptszVal, g_pfwFrames[Frameid].name) == 0) { db_free( &dbv ); return i; } @@ -995,7 +995,7 @@ static int CLUIFramesModifyContextMenuForFrame(WPARAM wParam,LPARAM lParam) CLISTMENUITEM mi = { sizeof(mi) }; mi.flags = CMIM_FLAGS|CMIM_NAME|CMIF_CHILDPOPUP|CMIF_TCHAR; if (g_pfwFrames[pos].visible) mi.flags |= CMIF_CHECKED; - mi.ptszName = g_pfwFrames[pos].TitleBar.tbname ? g_pfwFrames[pos].TitleBar.tbname : g_pfwFrames[pos].Name; + mi.ptszName = g_pfwFrames[pos].TitleBar.tbname ? g_pfwFrames[pos].TitleBar.tbname : g_pfwFrames[pos].name; ModifyMItem((WPARAM)_hmiVisible,(LPARAM)&mi); mi.flags = CMIM_FLAGS|CMIF_CHILDPOPUP; @@ -1047,7 +1047,7 @@ static int CLUIFramesModifyMainMenuItems(WPARAM wParam,LPARAM lParam) CLISTMENUITEM mi = { sizeof(mi) }; mi.flags = CMIM_FLAGS|CMIM_NAME|CMIF_CHILDPOPUP|CMIF_TCHAR; if (g_pfwFrames[pos].visible) mi.flags |= CMIF_CHECKED; - mi.ptszName = g_pfwFrames[pos].TitleBar.tbname ? g_pfwFrames[pos].TitleBar.tbname : g_pfwFrames[pos].Name; + mi.ptszName = g_pfwFrames[pos].TitleBar.tbname ? g_pfwFrames[pos].TitleBar.tbname : g_pfwFrames[pos].name; Menu_ModifyItem(g_pfwFrames[pos].MenuHandles.MIVisible, &mi); mi.flags = CMIM_FLAGS|CMIF_CHILDPOPUP; @@ -1120,7 +1120,7 @@ static INT_PTR _us_DoGetFrameOptions(WPARAM wParam,LPARAM lParam) case FO_NAME: if (bUnicodeText) - retval = (INT_PTR)g_pfwFrames[pos].Name; + retval = (INT_PTR)g_pfwFrames[pos].name; else retval = (INT_PTR)g_pfwFrames[pos].szName; break; @@ -1234,15 +1234,15 @@ static int _us_DoSetFrameOptions(WPARAM wParam,LPARAM lParam) if (lParam == 0) return -1; - mir_free(fw.Name); + mir_free(fw.name); mir_free(fw.szName); if (bUnicodeText) { - fw.Name = mir_tstrdup((LPTSTR)lParam); + fw.name = mir_tstrdup((LPTSTR)lParam); fw.szName = mir_t2a((LPTSTR)lParam); } else { fw.szName = mir_strdup((char*)lParam); - fw.Name = mir_a2t((char *)lParam); + fw.name = mir_a2t((char *)lParam); } return 0; @@ -1724,7 +1724,7 @@ static int CLUIFramesLoadMainMenu() mi.flags = CMIF_ROOTHANDLE | CMIF_TCHAR; mi.position = separator; mi.hParentMenu = _hmiRoot; - mi.ptszName = g_pfwFrames[i].TitleBar.tbname ? g_pfwFrames[i].TitleBar.tbname : g_pfwFrames[i].Name; + mi.ptszName = g_pfwFrames[i].TitleBar.tbname ? g_pfwFrames[i].TitleBar.tbname : g_pfwFrames[i].name; mi.pszService = 0; g_pfwFrames[i].MenuHandles.MainMenuItem = Menu_AddMainMenuItem(&mi); CLUIFramesCreateMenuForFrame(g_pfwFrames[i].id,(int)g_pfwFrames[i].MenuHandles.MainMenuItem,separator,Menu_AddMainMenuItem); @@ -1809,17 +1809,17 @@ static int _us_DoAddFrame(WPARAM wParam,LPARAM lParam) g_pfwFrames[g_nFramesCount].dwFlags = clfrm->Flags; if (clfrm->name == NULL || ((clfrm->Flags&F_UNICODE) ? lstrlenW(clfrm->wname) : lstrlenA(clfrm->name)) == 0) { - g_pfwFrames[g_nFramesCount].Name = (LPTSTR)mir_alloc(255 * sizeof(TCHAR)); - GetClassName(g_pfwFrames[g_nFramesCount].hWnd,g_pfwFrames[g_nFramesCount].Name,255); + g_pfwFrames[g_nFramesCount].name = (LPTSTR)mir_alloc(255 * sizeof(TCHAR)); + GetClassName(g_pfwFrames[g_nFramesCount].hWnd,g_pfwFrames[g_nFramesCount].name,255); } else { - g_pfwFrames[g_nFramesCount].Name = (clfrm->Flags&F_UNICODE) ? mir_u2t(clfrm->wname) : mir_a2t(clfrm->name); + g_pfwFrames[g_nFramesCount].name = (clfrm->Flags&F_UNICODE) ? mir_u2t(clfrm->wname) : mir_a2t(clfrm->name); } - g_pfwFrames[g_nFramesCount].szName = mir_t2a(g_pfwFrames[g_nFramesCount].Name); + g_pfwFrames[g_nFramesCount].szName = mir_t2a(g_pfwFrames[g_nFramesCount].name); if (IsBadCodePtr((FARPROC)clfrm->TBname) || clfrm->TBname == NULL || ((clfrm->Flags&F_UNICODE) ? lstrlenW(clfrm->TBwname) : lstrlenA(clfrm->TBname)) == 0) - g_pfwFrames[g_nFramesCount].TitleBar.tbname = mir_tstrdup(g_pfwFrames[g_nFramesCount].Name); + g_pfwFrames[g_nFramesCount].TitleBar.tbname = mir_tstrdup(g_pfwFrames[g_nFramesCount].name); else g_pfwFrames[g_nFramesCount].TitleBar.tbname = (clfrm->Flags&F_UNICODE) ? mir_u2t(clfrm->TBwname) : mir_a2t(clfrm->TBname); g_pfwFrames[g_nFramesCount].TitleBar.sztbname = mir_t2a(g_pfwFrames[g_nFramesCount].TitleBar.tbname); @@ -1840,7 +1840,7 @@ static int _us_DoAddFrame(WPARAM wParam,LPARAM lParam) g_pfwFrames[g_nFramesCount].TitleBar.hwnd - = CreateWindow(CLUIFrameTitleBarClassName,g_pfwFrames[g_nFramesCount].Name, + = CreateWindow(CLUIFrameTitleBarClassName,g_pfwFrames[g_nFramesCount].name, ( db_get_b(0, CLUIFrameModule,"RemoveAllTitleBarBorders",1)?0:WS_BORDER) |WS_CHILD|WS_CLIPCHILDREN| @@ -1954,7 +1954,7 @@ static int _us_DoRemoveFrame(WPARAM wParam,LPARAM lParam) if (pos < 0 || pos>g_nFramesCount){return(-1);}; - mir_free_and_nil(g_pfwFrames[pos].Name); + mir_free_and_nil(g_pfwFrames[pos].name); mir_free_and_nil(g_pfwFrames[pos].szName); mir_free_and_nil(g_pfwFrames[pos].TitleBar.tbname); mir_free_and_nil(g_pfwFrames[pos].TitleBar.sztbname); @@ -2998,7 +2998,7 @@ static LRESULT CALLBACK CLUIFrameTitleBarProc(HWND hwnd, UINT msg, WPARAM wParam if (framepos == -1){break;}; hmenu = CreatePopupMenu(); // Frames[Frameid].TitleBar.hmenu = hmenu; - AppendMenu(hmenu,MF_STRING|MF_DISABLED|MF_GRAYED,15,g_pfwFrames[framepos].Name); + AppendMenu(hmenu,MF_STRING|MF_DISABLED|MF_GRAYED,15,g_pfwFrames[framepos].name); AppendMenu(hmenu,MF_SEPARATOR,16,_T("")); if (g_pfwFrames[framepos].Locked) @@ -3916,8 +3916,6 @@ int UnLoadCLUIFramesModule(void) CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,0); CLUIFramesStoreAllFrames(); - - UnitFramesMenu(); UnloadMainMenu(); for (i=0; i < g_nFramesCount; i++) { @@ -3935,7 +3933,7 @@ int UnLoadCLUIFramesModule(void) g_pfwFrames[i].OwnerWindow = (HWND)-2; if (g_pfwFrames[i].UpdateRgn) DeleteObject(g_pfwFrames[i].UpdateRgn); - mir_free_and_nil(g_pfwFrames[i].Name); + mir_free_and_nil(g_pfwFrames[i].name); mir_free_and_nil(g_pfwFrames[i].szName); mir_free_and_nil(g_pfwFrames[i].TitleBar.tbname); mir_free_and_nil(g_pfwFrames[i].TitleBar.sztbname); diff --git a/plugins/Clist_modern/src/CLUIFrames/cluiframes.h b/plugins/Clist_modern/src/CLUIFrames/cluiframes.h index 75bf89a8bd..4e9f831250 100644 --- a/plugins/Clist_modern/src/CLUIFrames/cluiframes.h +++ b/plugins/Clist_modern/src/CLUIFrames/cluiframes.h @@ -60,8 +60,8 @@ typedef struct struct FrameMenuHandles { HGENMENU MainMenuItem; - HGENMENU MIVisible,MITitle,MITBVisible,MILock,MIColl,MIFloating,MIAlignRoot; - HGENMENU MIAlignTop,MIAlignClient,MIAlignBottom; + HGENMENU MIVisible, MITitle, MITBVisible, MILock, MIColl, MIFloating, MIAlignRoot; + HGENMENU MIAlignTop, MIAlignClient, MIAlignBottom; HGENMENU MIBorder, MIPosRoot, MIPosUp, MIPosDown; }; @@ -71,8 +71,8 @@ struct FrameTitleBar HWND TitleBarbutt; HWND hwndTip; - TCHAR* tbname; - TCHAR* tooltip; + LPTSTR tbname; + LPTSTR tooltip; char * sztbname; char * sztooltip; @@ -98,10 +98,10 @@ struct DockOpt struct FRAMEWND { int id; - HWND hWnd ; + HWND hWnd; RECT wndSize; - TCHAR * Name; - char * szName; + LPTSTR name; + LPSTR szName; int align; int height; int dwFlags; @@ -137,7 +137,3 @@ struct FRAMEWND #define CLUIFrameModule "CLUIFrames" #endif - - - - diff --git a/plugins/Clist_modern/src/CLUIFrames/framesmenu.cpp b/plugins/Clist_modern/src/CLUIFrames/framesmenu.cpp index 8473c9403b..80ba3433c0 100644 --- a/plugins/Clist_modern/src/CLUIFrames/framesmenu.cpp +++ b/plugins/Clist_modern/src/CLUIFrames/framesmenu.cpp @@ -3,6 +3,7 @@ //========================== Frames HANDLE hFrameMenuObject; +static HANDLE hPreBuildFrameMenuEvent; //contactmenu exec param(ownerdata) //also used in checkservice @@ -10,8 +11,17 @@ typedef struct{ char *szServiceName; int Frameid; INT_PTR param1; +}FrameMenuExecParam,*lpFrameMenuExecParam; + +INT_PTR FreeOwnerDataFrameMenu(WPARAM wParam, LPARAM lParam) +{ + lpFrameMenuExecParam cmep = (lpFrameMenuExecParam)lParam; + if (cmep != NULL){ + mir_free(cmep->szServiceName); + mir_free(cmep); + } + return 0; } - FrameMenuExecParam,*lpFrameMenuExecParam; static INT_PTR AddContextFrameMenuItem(WPARAM wParam, LPARAM lParam) { @@ -27,23 +37,16 @@ static INT_PTR AddContextFrameMenuItem(WPARAM wParam, LPARAM lParam) if (fmep == NULL) return 0; - memset(fmep, 0, sizeof(FrameMenuExecParam)); fmep->szServiceName = mir_strdup(mi->pszService); fmep->Frameid = mi->popupPosition; fmep->param1 = (INT_PTR)mi->pszContactOwner; tmi.ownerdata = fmep; + return CallService(MO_ADDNEWMENUITEM, (WPARAM)hFrameMenuObject, (LPARAM)&tmi); } static INT_PTR RemoveContextFrameMenuItem(WPARAM wParam, LPARAM lParam) { - lpFrameMenuExecParam fmep = (lpFrameMenuExecParam)CallService(MO_MENUITEMGETOWNERDATA, wParam, lParam); - if (fmep != NULL) { - if (fmep->szServiceName != NULL) - mir_free(fmep->szServiceName); - mir_free(fmep); - } - if (lParam != 1) CallService(MO_REMOVEMENUITEM, wParam, 0); @@ -56,7 +59,7 @@ static INT_PTR RemoveContextFrameMenuItem(WPARAM wParam, LPARAM lParam) INT_PTR FrameMenuExecService(WPARAM wParam, LPARAM lParam) { lpFrameMenuExecParam fmep = (lpFrameMenuExecParam)wParam; - if (fmep ==NULL) + if (fmep == NULL) return -1; CallService(fmep->szServiceName, lParam, fmep->param1); @@ -71,7 +74,7 @@ INT_PTR FrameMenuCheckService(WPARAM wParam, LPARAM lParam) return FALSE; TMO_MenuItem mi; - if ( CallService(MO_GETMENUITEM, (WPARAM)pcpp->MenuItemHandle, (LPARAM)&mi) == 0) { + if (CallService(MO_GETMENUITEM, (WPARAM)pcpp->MenuItemHandle, (LPARAM)&mi) == 0) { lpFrameMenuExecParam fmep = (lpFrameMenuExecParam)mi.ownerdata; if (fmep != NULL) { //pcpp->wParam - frameid @@ -84,7 +87,7 @@ INT_PTR FrameMenuCheckService(WPARAM wParam, LPARAM lParam) static INT_PTR ContextFrameMenuNotify(WPARAM wParam, LPARAM lParam) { - NotifyEventHooks(g_CluiData.hEventPreBuildFrameMenu, wParam, lParam); + NotifyEventHooks(hPreBuildFrameMenuEvent,wParam,lParam); return 0; } @@ -105,20 +108,18 @@ static INT_PTR BuildContextFrameMenu(WPARAM wParam,LPARAM lParam) int InitFramesMenus(void) { - CreateServiceFunction("FrameMenuExecService",FrameMenuExecService); - CreateServiceFunction("FrameMenuCheckService",FrameMenuCheckService); + CreateServiceFunction("FrameMenuExecService", FrameMenuExecService); + CreateServiceFunction("FrameMenuCheckService", FrameMenuCheckService); + CreateServiceFunction("FrameMenuFreeService", FreeOwnerDataFrameMenu); - CreateServiceFunction(MS_CLIST_REMOVECONTEXTFRAMEMENUITEM,RemoveContextFrameMenuItem); - CreateServiceFunction("CList/AddContextFrameMenuItem",AddContextFrameMenuItem); - CreateServiceFunction(MS_CLIST_MENUBUILDFRAMECONTEXT,BuildContextFrameMenu); - CreateServiceFunction(MS_CLIST_FRAMEMENUNOTIFY,ContextFrameMenuNotify); + CreateServiceFunction(MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, RemoveContextFrameMenuItem); + CreateServiceFunction("CList/AddContextFrameMenuItem", AddContextFrameMenuItem); + CreateServiceFunction(MS_CLIST_MENUBUILDFRAMECONTEXT, BuildContextFrameMenu); + CreateServiceFunction(MS_CLIST_FRAMEMENUNOTIFY, ContextFrameMenuNotify); + hPreBuildFrameMenuEvent = CreateHookableEvent(ME_CLIST_PREBUILDFRAMEMENU); // frame menu object hFrameMenuObject = MO_CreateMenuObject("FrameMenu", LPGEN("Frame menu"), "FrameMenuCheckService", "FrameMenuExecService"); - return 0; -} - -int UnitFramesMenu() -{ + MO_SetMenuObjectParam(hFrameMenuObject, OPT_MENUOBJECT_SET_FREE_SERVICE, "FrameMenuFreeService"); return 0; } diff --git a/plugins/Clist_modern/src/hdr/modern_commonprototypes.h b/plugins/Clist_modern/src/hdr/modern_commonprototypes.h index 449bc44caf..5f7b6cbf0e 100644 --- a/plugins/Clist_modern/src/hdr/modern_commonprototypes.h +++ b/plugins/Clist_modern/src/hdr/modern_commonprototypes.h @@ -242,7 +242,6 @@ INT_PTR ToggleHideOffline(WPARAM wParam,LPARAM lParam); INT_PTR ToggleGroups(WPARAM wParam,LPARAM lParam); //contact.c INT_PTR SetUseGroups(WPARAM wParam,LPARAM lParam); //contact.c INT_PTR ToggleSounds(WPARAM wParam,LPARAM lParam); //contact.c -int UnitFramesMenu(); //framesmenu.c void ClcOptionsChanged(); //clc.c void Docking_GetMonitorRectFromWindow(HWND hWnd,RECT *rc); //Docking.c void DrawAvatarImageWithGDIp(HDC hDestDC,int x, int y, DWORD width, DWORD height, HBITMAP hbmp, int x1, int y1, DWORD width1, DWORD height1,DWORD flag,BYTE alpha); //gdiplus.cpp diff --git a/plugins/Clist_modern/src/hdr/modern_global_structure.h b/plugins/Clist_modern/src/hdr/modern_global_structure.h index b8742177a0..f76999b8c1 100644 --- a/plugins/Clist_modern/src/hdr/modern_global_structure.h +++ b/plugins/Clist_modern/src/hdr/modern_global_structure.h @@ -76,7 +76,6 @@ typedef struct tagCLUIDATA HANDLE hEventExtraClick; HANDLE hEventBkgrChanged; HANDLE hEventPreBuildTrayMenu; - HANDLE hEventPreBuildFrameMenu; HANDLE hEventPreBuildGroupMenu; HANDLE hEventPreBuildSubGroupMenu; HANDLE hEventStatusBarShowToolTip; diff --git a/plugins/Clist_modern/src/init.cpp b/plugins/Clist_modern/src/init.cpp index 86d22f0929..1d14999269 100644 --- a/plugins/Clist_modern/src/init.cpp +++ b/plugins/Clist_modern/src/init.cpp @@ -202,7 +202,6 @@ static HRESULT CreateHookableEvents() { g_CluiData.hEventBkgrChanged = CreateHookableEvent(ME_BACKGROUNDCONFIG_CHANGED); g_CluiData.hEventPreBuildTrayMenu = CreateHookableEvent(ME_CLIST_PREBUILDTRAYMENU); - g_CluiData.hEventPreBuildFrameMenu = CreateHookableEvent(ME_CLIST_PREBUILDFRAMEMENU); g_CluiData.hEventPreBuildGroupMenu = CreateHookableEvent(ME_CLIST_PREBUILDGROUPMENU); g_CluiData.hEventPreBuildSubGroupMenu = CreateHookableEvent(ME_CLIST_PREBUILDSUBGROUPMENU); g_CluiData.hEventStatusBarShowToolTip = CreateHookableEvent(ME_CLIST_FRAMES_SB_SHOW_TOOLTIP); diff --git a/plugins/Clist_mw/src/CLUIFrames/cluiframes.cpp b/plugins/Clist_mw/src/CLUIFrames/cluiframes.cpp index cadc31aadd..c62eee2855 100644 --- a/plugins/Clist_mw/src/CLUIFrames/cluiframes.cpp +++ b/plugins/Clist_mw/src/CLUIFrames/cluiframes.cpp @@ -46,13 +46,6 @@ LOGFONTA TitleBarLogFont = {0}; boolean FramesSysNotStarted = TRUE; -typedef struct -{ - int order; - int realpos; -} - SortData; - static int sortfunc(const void *a,const void *b) { SortData *sd1,*sd2; @@ -64,76 +57,8 @@ static int sortfunc(const void *a,const void *b) return 0; } - -//============ -#define CLUIFRAMESSETALIGN "CLUIFramesSetAlign" - -#define CLUIFRAMESSETALIGNALTOP "CLUIFramesSetAlignalTop" -#define CLUIFRAMESSETALIGNALCLIENT "CLUIFramesSetAlignalClient" -#define CLUIFRAMESSETALIGNALBOTTOM "CLUIFramesSetAlignalBottom" - -#define CLUIFRAMESMOVEUPDOWN "CLUIFramesMoveUpDown" -typedef struct tagMenuHandles -{ - HGENMENU MainMenuItem; - HGENMENU MIVisible,MITitle,MITBVisible,MILock,MIColl,MIFloating,MIAlignRoot; - HGENMENU MIAlignTop,MIAlignClient,MIAlignBottom,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 FRAMEWND Frames[MAX_FRAMES]; +static FRAMEWND *Frames = NULL; static int nFramescount = 0; static int alclientFrame = -1;//for fast access to frame with alclient properties @@ -160,15 +85,15 @@ static int curdragbar = -1; static CRITICAL_SECTION csFrameHook; static BOOLEAN CLUIFramesFitInSize(void); -static int RemoveItemFromList(int pos,wndFrame **lpFrames,int *FrameItemCount); +static int RemoveItemFromList(int pos,FRAMEWND **lpFrames,int *FrameItemCount); HWND hWndExplorerToolBar; static int GapBetweenFrames = 1; -static int RemoveItemFromList(int pos,wndFrame **lpFrames,int *FrameItemCount) +static int RemoveItemFromList(int pos,FRAMEWND **lpFrames,int *FrameItemCount) { - memcpy(&((*lpFrames)[pos]),&((*lpFrames)[pos+1]),sizeof(wndFrame)*(*FrameItemCount-pos-1)); + memcpy(&((*lpFrames)[pos]),&((*lpFrames)[pos+1]),sizeof(FRAMEWND)*(*FrameItemCount-pos-1)); (*FrameItemCount)--; - (*lpFrames) = (wndFrame*)realloc((*lpFrames),sizeof(wndFrame)*(*FrameItemCount)); + (*lpFrames) = (FRAMEWND*)realloc((*lpFrames),sizeof(FRAMEWND)*(*FrameItemCount)); return 0; } @@ -202,7 +127,7 @@ static void __inline ulockfrm() //////////screen docking,code from "floating contacts" plugin. -static wndFrame* FindFrameByWnd( HWND hwnd ) +static FRAMEWND* FindFrameByWnd( HWND hwnd ) { if ( hwnd == NULL ) return NULL; @@ -214,7 +139,7 @@ static wndFrame* FindFrameByWnd( HWND hwnd ) return NULL; } -static void DockThumbs( wndFrame *pThumbLeft, wndFrame *pThumbRight, BOOL bMoveLeft ) +static void DockThumbs( FRAMEWND *pThumbLeft, FRAMEWND *pThumbRight, BOOL bMoveLeft ) { if ( pThumbRight->dockOpt.hwndLeft == NULL && pThumbLeft->dockOpt.hwndRight == NULL ) { pThumbRight->dockOpt.hwndLeft = pThumbLeft->ContainerWnd; @@ -222,7 +147,7 @@ static void DockThumbs( wndFrame *pThumbLeft, wndFrame *pThumbRight, BOOL bMoveL } } -static void UndockThumbs( wndFrame *pThumb1, wndFrame *pThumb2 ) +static void UndockThumbs( FRAMEWND *pThumb1, FRAMEWND *pThumb2 ) { if ( pThumb1 == NULL || pThumb2 == NULL ) return; @@ -242,12 +167,12 @@ static void UndockThumbs( wndFrame *pThumb1, wndFrame *pThumb2 ) BOOLEAN bMoveTogether; -static void PositionThumb( wndFrame *pThumb, short nX, short nY ) +static void PositionThumb( FRAMEWND *pThumb, short nX, short nY ) { - wndFrame *pCurThumb = &Frames[0]; - wndFrame *pDockThumb = pThumb; - wndFrame fakeMainWindow; - wndFrame fakeTaskBarWindow; + FRAMEWND *pCurThumb = &Frames[0]; + FRAMEWND *pDockThumb = pThumb; + FRAMEWND fakeMainWindow; + FRAMEWND fakeTaskBarWindow; RECT rc; RECT rcThumb; RECT rcOld; @@ -1501,9 +1426,9 @@ INT_PTR CLUIFramesAddFrame(WPARAM wParam,LPARAM lParam) lockfrm(); if (nFramescount>=MAX_FRAMES) { ulockfrm(); return -1;} - Frames = (wndFrame*)realloc(Frames,sizeof(wndFrame)*(nFramescount+1)); + Frames = (FRAMEWND*)realloc(Frames,sizeof(FRAMEWND)*(nFramescount+1)); - memset(&Frames[nFramescount],0,sizeof(wndFrame)); + memset(&Frames[nFramescount],0,sizeof(FRAMEWND)); Frames[nFramescount].id = NextFrameId++; Frames[nFramescount].align = clfrm->align; Frames[nFramescount].hWnd = clfrm->hWnd; @@ -1626,14 +1551,14 @@ static INT_PTR CLUIFramesRemoveFrame(WPARAM wParam,LPARAM lParam) } -int CLUIFramesForceUpdateTB(const wndFrame *Frame) +int CLUIFramesForceUpdateTB(const FRAMEWND *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) +int CLUIFramesForceUpdateFrame(const FRAMEWND *Frame) { if (Frame->hWnd != 0) { RedrawWindow(Frame->hWnd,NULL,NULL,RDW_UPDATENOW|RDW_FRAME|RDW_ERASE|RDW_INVALIDATE); @@ -1646,7 +1571,7 @@ int CLUIFramesForceUpdateFrame(const wndFrame *Frame) return 0; } -int CLUIFrameMoveResize(const wndFrame *Frame) +int CLUIFrameMoveResize(const FRAMEWND *Frame) { //int b; // we need to show or hide the frame? @@ -2684,7 +2609,7 @@ static HWND CreateContainerWindow(HWND parent,int x,int y,int width,int height) INT_PTR CLUIFrameSetFloat(WPARAM wParam,LPARAM lParam) { HWND hwndtmp, hwndtooltiptmp; - wndFrame *frame; + FRAMEWND *frame; int pos; lockfrm(); diff --git a/plugins/Clist_mw/src/CLUIFrames/cluiframes.h b/plugins/Clist_mw/src/CLUIFrames/cluiframes.h index d36dff07da..2161b6623b 100644 --- a/plugins/Clist_mw/src/CLUIFrames/cluiframes.h +++ b/plugins/Clist_mw/src/CLUIFrames/cluiframes.h @@ -1,5 +1,5 @@ /* -Miranda ICQ: the free icq client for MS Windows +Miranda ICQ: the free icq client for MS Windows Copyright (C) 2000-2 Richard Hughes, Roland Rabien & Tristan Van de Vreede This program is free software; you can redistribute it and/or @@ -17,6 +17,11 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#pragma once + +#ifndef _CLUIFRAMES_H_ +#define _CLUIFRAMES_H_ + int LoadCLUIFramesModule(void); int UnLoadCLUIFramesModule(void); int CLUIFramesGetMinHeight(); @@ -28,8 +33,88 @@ typedef struct tagProtocolData { boolean show; } ProtocolData; +typedef struct +{ + int order; + int realpos; +}SortData; + + + + +//============ +#define CLUIFRAMESSETALIGN "CLUIFramesSetAlign" + +#define CLUIFRAMESSETALIGNALTOP "CLUIFramesSetAlignalTop" +#define CLUIFRAMESSETALIGNALCLIENT "CLUIFramesSetAlignalClient" +#define CLUIFRAMESSETALIGNALBOTTOM "CLUIFramesSetAlignalBottom" + +#define CLUIFRAMESMOVEUPDOWN "CLUIFramesMoveUpDown" + +struct FrameMenuHandles +{ + HGENMENU MainMenuItem; + HGENMENU MIVisible, MITitle, MITBVisible, MILock, MIColl, MIFloating, MIAlignRoot; + HGENMENU MIAlignTop, MIAlignClient, MIAlignBottom, MIBorder; +}; + +struct FrameTitleBar +{ + 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; +}; + +struct DockOpt +{ + HWND hwndLeft; + HWND hwndRight; +}; + +struct FRAMEWND +{ + 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; +}; + #define OFFSET_PROTOPOS 200 #define OFFSET_VISIBLE 400 #define CLUIFrameTitleBarClassName _T("CLUIFrameTitleBar") #define CLUIFrameModule "CLUIFrames" + +#endif diff --git a/plugins/Clist_mw/src/CLUIFrames/framesmenu.cpp b/plugins/Clist_mw/src/CLUIFrames/framesmenu.cpp index 4e94c8b75f..7c1832e177 100644 --- a/plugins/Clist_mw/src/CLUIFrames/framesmenu.cpp +++ b/plugins/Clist_mw/src/CLUIFrames/framesmenu.cpp @@ -1,6 +1,6 @@ #include "../commonheaders.h" -// == == == == == == == == == == == == == Frames +//========================== Frames HANDLE hFrameMenuObject; static HANDLE hPreBuildFrameMenuEvent; extern int InitCustomMenus(void); @@ -13,37 +13,25 @@ typedef struct{ INT_PTR param1; }FrameMenuExecParam,*lpFrameMenuExecParam; -void FreeAndNil( void **p ) +INT_PTR FreeOwnerDataFrameMenu(WPARAM wParam, LPARAM lParam) { - if ( p == NULL ) - return; - - if ( *p != NULL ) { - mir_free( *p ); - *p = NULL; -} } - -INT_PTR FreeOwnerDataFrameMenu (WPARAM wParam,LPARAM lParam) -{ - lpFrameMenuExecParam cmep; - - cmep = (lpFrameMenuExecParam)lParam; + lpFrameMenuExecParam cmep = (lpFrameMenuExecParam)lParam; if (cmep != NULL){ - FreeAndNil((void**)&cmep->szServiceName); - FreeAndNil((void**)&cmep); + mir_free(cmep->szServiceName); + mir_free(cmep); } return 0; } -static INT_PTR AddContextFrameMenuItem(WPARAM wParam,LPARAM lParam) +static INT_PTR AddContextFrameMenuItem(WPARAM wParam, LPARAM lParam) { - TMO_MenuItem tmi; CLISTMENUITEM *mi = (CLISTMENUITEM*)lParam; + + TMO_MenuItem tmi; if ( !pcli->pfnConvertMenu(mi, &tmi)) - return 0; + return NULL; - if ((mi->flags & CMIF_ROOTPOPUP) || (mi->flags & CMIF_CHILDPOPUP)) - tmi.root = mi->hParentMenu; + tmi.root = (mi->flags & CMIF_ROOTHANDLE) ? mi->hParentMenu : NULL; lpFrameMenuExecParam fmep = (lpFrameMenuExecParam)mir_alloc(sizeof(FrameMenuExecParam)); if (fmep == NULL) @@ -57,19 +45,8 @@ static INT_PTR AddContextFrameMenuItem(WPARAM wParam,LPARAM lParam) return CallService(MO_ADDNEWMENUITEM, (WPARAM)hFrameMenuObject, (LPARAM)&tmi); } -static INT_PTR RemoveContextFrameMenuItem(WPARAM wParam,LPARAM lParam) +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){ - mir_free(fmep->szServiceName); - fmep->szServiceName = NULL; - } - mir_free(fmep); - } - */ CallService(MO_REMOVEMENUITEM,wParam,0); return 0; } @@ -77,34 +54,36 @@ static INT_PTR RemoveContextFrameMenuItem(WPARAM wParam,LPARAM lParam) //called with: //wparam - ownerdata //lparam - lparam from winproc -INT_PTR FrameMenuExecService(WPARAM wParam,LPARAM lParam) +INT_PTR FrameMenuExecService(WPARAM wParam, LPARAM lParam) { lpFrameMenuExecParam fmep = (lpFrameMenuExecParam)wParam; - if (fmep == NULL){return(-1);} - CallService(fmep->szServiceName,lParam,fmep->param1); + if (fmep == NULL) + return -1; + CallService(fmep->szServiceName, lParam, fmep->param1); return 0; } //true - ok,false ignore -INT_PTR FrameMenuCheckService(WPARAM wParam,LPARAM lParam) +INT_PTR FrameMenuCheckService(WPARAM wParam, LPARAM lParam) { PCheckProcParam pcpp = (PCheckProcParam)wParam; if (pcpp == NULL) return FALSE; TMO_MenuItem mi; - if (CallService(MO_GETMENUITEM,(WPARAM)pcpp->MenuItemHandle,(LPARAM)&mi) == 0) { - lpFrameMenuExecParam fmep = (lpFrameMenuExecParam)mi.ownerdata; + 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; } -static INT_PTR ContextFrameMenuNotify(WPARAM wParam,LPARAM lParam) +static INT_PTR ContextFrameMenuNotify(WPARAM wParam, LPARAM lParam) { NotifyEventHooks(hPreBuildFrameMenuEvent,wParam,lParam); return 0; @@ -112,21 +91,18 @@ static INT_PTR ContextFrameMenuNotify(WPARAM wParam,LPARAM lParam) static INT_PTR BuildContextFrameMenu(WPARAM wParam,LPARAM lParam) { - CLISTMENUITEM *mi = (CLISTMENUITEM*)lParam; - HMENU hMenu; ListParam param = { 0 }; param.MenuObjectHandle = hFrameMenuObject; param.wParam = wParam; param.lParam = lParam; - hMenu = CreatePopupMenu(); - //NotifyEventHooks(hPreBuildFrameMenuEvent,wParam,-1); - ContextFrameMenuNotify(wParam,-1); - CallService(MO_BUILDMENU,(WPARAM)hMenu,(LPARAM)¶m); + HMENU hMenu = CreatePopupMenu(); + ContextFrameMenuNotify(wParam, -1); + CallService(MO_BUILDMENU, (WPARAM)hMenu, (LPARAM)¶m); return (INT_PTR)hMenu; } -// == == == == == == == == == == == == == Frames end +//========================== Frames end int InitFramesMenus(void) { diff --git a/plugins/Clist_mw/src/clc.h b/plugins/Clist_mw/src/clc.h index 7d8e8c7e82..58dea44696 100644 --- a/plugins/Clist_mw/src/clc.h +++ b/plugins/Clist_mw/src/clc.h @@ -144,6 +144,4 @@ typedef struct { extern ExternDrawer SED; -void FreeAndNil( void** p ); - #endif /* _CLC_H_ */ diff --git a/plugins/Clist_mw/src/clisttray.cpp b/plugins/Clist_mw/src/clisttray.cpp index ddfcb22811..65ff0b8cec 100644 --- a/plugins/Clist_mw/src/clisttray.cpp +++ b/plugins/Clist_mw/src/clisttray.cpp @@ -183,8 +183,8 @@ INT_PTR FreeOwnerDataTrayMenu (WPARAM wParam,LPARAM lParam) lpTrayMenuExecParam mmep; mmep = (lpTrayMenuExecParam)lParam; if (mmep != NULL){ - FreeAndNil((void**)&mmep->szServiceName); - FreeAndNil((void**)&mmep); + mir_free(mmep->szServiceName); + mir_free(mmep); } return 0; diff --git a/plugins/Clist_mw/src/groupmenu.cpp b/plugins/Clist_mw/src/groupmenu.cpp index ba13c66479..c6fd1ea357 100644 --- a/plugins/Clist_mw/src/groupmenu.cpp +++ b/plugins/Clist_mw/src/groupmenu.cpp @@ -164,17 +164,15 @@ INT_PTR GroupMenuExecService(WPARAM wParam,LPARAM lParam) { } return(1); } + INT_PTR FreeOwnerDataGroupMenu (WPARAM wParam,LPARAM lParam) { - - lpGroupMenuExecParam mmep; - mmep = (lpGroupMenuExecParam)lParam; - if (mmep != NULL){ - FreeAndNil((void**)&mmep->szServiceName); - FreeAndNil((void**)&mmep); + lpGroupMenuExecParam mmep = (lpGroupMenuExecParam)lParam; + if (mmep != NULL) { + mir_free(mmep->szServiceName); + mir_free(mmep); } - -return 0; + return 0; } INT_PTR HideGroupsHelper(WPARAM wParam,LPARAM lParam) @@ -489,13 +487,11 @@ INT_PTR SubGroupMenuExecService(WPARAM wParam,LPARAM lParam) INT_PTR FreeOwnerDataSubGroupMenu (WPARAM wParam,LPARAM lParam) { - lpSubGroupMenuExecParam mmep; - mmep = (lpSubGroupMenuExecParam)lParam; + lpSubGroupMenuExecParam mmep = (lpSubGroupMenuExecParam)lParam; if (mmep != NULL) { - FreeAndNil((void**)&mmep->szServiceName); - FreeAndNil((void**)&mmep); + mir_free(mmep->szServiceName); + mir_free(mmep); } - return 0; } diff --git a/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp b/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp index a888833508..0907646b2b 100644 --- a/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp +++ b/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp @@ -58,17 +58,11 @@ static int UpdateTBToolTip(int framepos); INT_PTR CLUIFrameSetFloat(WPARAM wParam, LPARAM lParam); int CLUIFrameResizeFloatingFrame(int framepos); extern int InitFramesMenus(void); -extern int UnitFramesMenu(); static int CLUIFramesReSort(); boolean FramesSysNotStarted = TRUE; HPEN g_hPenCLUIFrames = 0; -typedef struct { - int order; - int realpos; -} SortData; - static SortData g_sd[MAX_FRAMES]; static HHOOK g_hFrameHook = 0; @@ -85,16 +79,9 @@ static int sortfunc(const void *a, const void *b) return 0; } -#define CLUIFRAMESSETALIGN "CLUIFramesSetAlign" -#define CLUIFRAMESSETALIGNALTOP "CLUIFramesSetAlignalTop" -#define CLUIFRAMESSETALIGNALCLIENT "CLUIFramesSetAlignalClient" -#define CLUIFRAMESSETALIGNALBOTTOM "CLUIFramesSetAlignalBottom" -#define CLUIFRAMESMOVEUP "CLUIFramesMoveUp" -#define CLUIFRAMESMOVEDOWN "CLUIFramesMoveDown" - -static wndFrame *Frames = NULL; +static FRAMEWND *Frames = NULL; -wndFrame *wndFrameCLC = NULL, *wndFrameEventArea = NULL, *wndFrameViewMode = NULL; +FRAMEWND *wndFrameCLC = NULL, *wndFrameEventArea = NULL, *wndFrameViewMode = NULL; static int nFramescount = 0; static int alclientFrame = -1;//for fast access to frame with alclient properties @@ -123,9 +110,9 @@ static BOOLEAN CLUIFramesFitInSize(void); HWND hWndExplorerToolBar; static int GapBetweenFrames = 1; -static int RemoveItemFromList(int pos, wndFrame **lpFrames, int *FrameItemCount) +static int RemoveItemFromList(int pos, FRAMEWND **lpFrames, int *FrameItemCount) { - memcpy(&((*lpFrames)[pos]), &((*lpFrames)[pos+1]), sizeof(wndFrame)*(*FrameItemCount - pos - 1)); + memcpy(&((*lpFrames)[pos]), &((*lpFrames)[pos+1]), sizeof(FRAMEWND)*(*FrameItemCount - pos - 1)); (*FrameItemCount)--; return 0; } @@ -160,7 +147,7 @@ void __forceinline ulockfrm() LeaveCriticalSection(&csFrameHook); } -static wndFrame* FindFrameByWnd(HWND hwnd) +static FRAMEWND* FindFrameByWnd(HWND hwnd) { BOOL bFound = FALSE; int i; @@ -176,7 +163,7 @@ static wndFrame* FindFrameByWnd(HWND hwnd) } -static void DockThumbs(wndFrame *pThumbLeft, wndFrame *pThumbRight, BOOL bMoveLeft) +static void DockThumbs(FRAMEWND *pThumbLeft, FRAMEWND *pThumbRight, BOOL bMoveLeft) { if ((pThumbRight->dockOpt.hwndLeft == NULL) && (pThumbLeft->dockOpt.hwndRight == NULL)) { pThumbRight->dockOpt.hwndLeft = pThumbLeft->ContainerWnd; @@ -185,7 +172,7 @@ static void DockThumbs(wndFrame *pThumbLeft, wndFrame *pThumbRight, BOOL bMoveLe } -static void UndockThumbs(wndFrame *pThumb1, wndFrame *pThumb2) +static void UndockThumbs(FRAMEWND *pThumb1, FRAMEWND *pThumb2) { if ((pThumb1 == NULL) || (pThumb2 == NULL)) return; @@ -205,12 +192,12 @@ static void UndockThumbs(wndFrame *pThumb1, wndFrame *pThumb2) BOOLEAN bMoveTogether; -static void PositionThumb(wndFrame *pThumb, short nX, short nY) +static void PositionThumb(FRAMEWND *pThumb, short nX, short nY) { - wndFrame *pCurThumb = &Frames[0]; - wndFrame *pDockThumb = pThumb; - wndFrame fakeMainWindow; - wndFrame fakeTaskBarWindow; + FRAMEWND *pCurThumb = &Frames[0]; + FRAMEWND *pDockThumb = pThumb; + FRAMEWND fakeMainWindow; + FRAMEWND fakeTaskBarWindow; RECT rc; RECT rcThumb; RECT rcOld; @@ -1819,10 +1806,10 @@ INT_PTR CLUIFramesAddFrame(WPARAM wParam, LPARAM lParam) return -1; } if (Frames == NULL) { - Frames = (wndFrame*)malloc(sizeof(wndFrame) * (MAX_FRAMES + 2)); - ZeroMemory(Frames, sizeof(wndFrame) * (MAX_FRAMES + 2)); + Frames = (FRAMEWND*)malloc(sizeof(FRAMEWND) * (MAX_FRAMES + 2)); + ZeroMemory(Frames, sizeof(FRAMEWND) * (MAX_FRAMES + 2)); } - memset(&Frames[nFramescount], 0, sizeof(wndFrame)); + memset(&Frames[nFramescount], 0, sizeof(FRAMEWND)); Frames[nFramescount].id = NextFrameId++; Frames[nFramescount].align = clfrm->align; @@ -1957,7 +1944,7 @@ static INT_PTR CLUIFramesRemoveFrame(WPARAM wParam, LPARAM lParam) } { - wndFrame* F = &Frames[pos]; + FRAMEWND* F = &Frames[pos]; if (F->hWnd == g_hwndEventArea) wndFrameEventArea = NULL; else if (F->hWnd == pcli->hwndContactTree) @@ -1989,14 +1976,14 @@ static INT_PTR CLUIFramesRemoveFrame(WPARAM wParam, LPARAM lParam) return 0; } -INT_PTR CLUIFramesForceUpdateTB(const wndFrame *Frame) +INT_PTR CLUIFramesForceUpdateTB(const FRAMEWND *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_PTR CLUIFramesForceUpdateFrame(const wndFrame *Frame) +INT_PTR CLUIFramesForceUpdateFrame(const FRAMEWND *Frame) { if (Frame->hWnd != 0) RedrawWindow(Frame->hWnd, NULL, NULL, RDW_UPDATENOW | RDW_FRAME | RDW_ERASE | RDW_INVALIDATE); @@ -2006,7 +1993,7 @@ INT_PTR CLUIFramesForceUpdateFrame(const wndFrame *Frame) return 0; } -int CLUIFrameMoveResize(const wndFrame *Frame) +int CLUIFrameMoveResize(const FRAMEWND *Frame) { TitleBarH = cfg::dat.titleBarHeight; // we need to show or hide the frame? @@ -3365,6 +3352,5 @@ int UnLoadCLUIFramesModule(void) UnregisterClass(CLUIFrameTitleBarClassName, g_hInst); LeaveCriticalSection(&csFrameHook); DeleteCriticalSection(&csFrameHook); - UnitFramesMenu(); return 0; } diff --git a/plugins/Clist_nicer/src/CLUIFrames/cluiframes.h b/plugins/Clist_nicer/src/CLUIFrames/cluiframes.h index 2c2375a351..0174e37743 100644 --- a/plugins/Clist_nicer/src/CLUIFrames/cluiframes.h +++ b/plugins/Clist_nicer/src/CLUIFrames/cluiframes.h @@ -1,5 +1,5 @@ /* -Miranda ICQ: the free icq client for MS Windows +Miranda ICQ: the free icq client for MS Windows Copyright (C) 2000-2 Richard Hughes, Roland Rabien & Tristan Van de Vreede This program is free software; you can redistribute it and/or @@ -17,6 +17,11 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#pragma once + +#ifndef _CLUIFRAMES_H_ +#define _CLUIFRAMES_H_ + int LoadCLUIFramesModule(void); int UnLoadCLUIFramesModule(void); int CLUIFramesGetMinHeight(); @@ -26,73 +31,96 @@ int CLUIFramesResizeFrames(RECT *rc); typedef struct tagProtocolData { char *RealName; - int statusbarpos; + int protopos; boolean show; } ProtocolData; +typedef struct +{ + int order; + int realpos; +}SortData; + + + + +//============ +#define CLUIFRAMESSETALIGN "CLUIFramesSetAlign" + +#define CLUIFRAMESSETALIGNALTOP "CLUIFramesSetAlignalTop" +#define CLUIFRAMESSETALIGNALCLIENT "CLUIFramesSetAlignalClient" +#define CLUIFRAMESSETALIGNALBOTTOM "CLUIFramesSetAlignalBottom" +#define CLUIFRAMESMOVEUP "CLUIFramesMoveUp" +#define CLUIFRAMESMOVEDOWN "CLUIFramesMoveDown" + +struct FrameMenuHandles +{ + HGENMENU MainMenuItem; + HGENMENU MIVisible, MITitle, MITBVisible, MILock, MIColl, MIFloating, MIAlignRoot; + HGENMENU MIAlignTop, MIAlignClient, MIAlignBottom; + HGENMENU MIBorder, MISkinned; +}; + +struct FrameTitleBar +{ + HWND hwnd; + HWND TitleBarbutt; + HWND hwndTip; + + LPTSTR tbname; + LPTSTR tooltip; + HMENU hmenu; + HICON hicon; + + BOOLEAN ShowTitleBar; + BOOLEAN ShowTitleBarTip; + int oldstyles; + POINT oldpos; + RECT wndSize; +}; + +struct DockOpt +{ + HWND hwndLeft; + HWND hwndRight; +}; + +struct FRAMEWND +{ + int id; + HWND hWnd; + RECT wndSize; + RECT oldWndSize; + LPTSTR name; + int align; + int height; + int dwFlags; + BOOLEAN Locked; + BOOLEAN Skinned; + 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; + HWND OwnerWindow; + WNDPROC wndProc; +}; + #define OFFSET_PROTOPOS 200 #define OFFSET_VISIBLE 400 #define CLUIFrameTitleBarClassName _T("CLUIFrameTitleBar") #define CLUIFrameModule "CLUIFrames" -typedef struct _DockOpt { - HWND hwndLeft; - HWND hwndRight; -} -DockOpt; - -typedef struct tagMenuHandles { - HGENMENU MainMenuItem; - HGENMENU MIVisible,MITitle,MITBVisible,MILock,MIColl,MIFloating,MIAlignRoot; - HGENMENU MIAlignTop,MIAlignClient,MIAlignBottom,MIBorder,MISkinned; -} FrameMenuHandles; - -typedef struct tagFrameTitleBar { - HWND hwnd; - HWND TitleBarbutt; - HWND hwndTip; - - LPTSTR tbname; - LPTSTR tooltip; - HMENU hmenu; - HICON hicon; - - BOOLEAN ShowTitleBar; - BOOLEAN ShowTitleBarTip; - int oldstyles; - POINT oldpos; - RECT wndSize; -} FrameTitleBar; - -typedef struct { - int id; - HWND hWnd ; - RECT wndSize; - RECT oldWndSize; - LPTSTR name; - int align; - int height; - int dwFlags; - BOOLEAN Locked; - BOOLEAN Skinned; - 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; - HWND OwnerWindow; - WNDPROC wndProc; -} wndFrame; - +#endif diff --git a/plugins/Clist_nicer/src/CLUIFrames/framesmenu.cpp b/plugins/Clist_nicer/src/CLUIFrames/framesmenu.cpp index 79c00914fe..a8974665cc 100644 --- a/plugins/Clist_nicer/src/CLUIFrames/framesmenu.cpp +++ b/plugins/Clist_nicer/src/CLUIFrames/framesmenu.cpp @@ -1,10 +1,9 @@ #include #include "cluiframes.h" -//==========================Frames +//========================== Frames HANDLE hFrameMenuObject; static HANDLE hPreBuildFrameMenuEvent; -extern int InitCustomMenus(void); //contactmenu exec param(ownerdata) //also used in checkservice @@ -14,38 +13,21 @@ typedef struct{ INT_PTR param1; }FrameMenuExecParam,*lpFrameMenuExecParam; -void FreeAndNil( void **p ) +INT_PTR FreeOwnerDataFrameMenu(WPARAM wParam, LPARAM lParam) { - if (p!=NULL) - { - if (*p!=NULL) - { - if ( !IsBadCodePtr((FARPROC)*p)) - { - mir_free(*p); - } - *p=NULL; - } - } -} - -INT_PTR FreeOwnerDataFrameMenu (WPARAM wParam,LPARAM lParam) -{ - - lpFrameMenuExecParam cmep; - - cmep=(lpFrameMenuExecParam)lParam; - if (cmep!=NULL){ - FreeAndNil((void **)&cmep->szServiceName); - FreeAndNil((void **)&cmep); + lpFrameMenuExecParam cmep = (lpFrameMenuExecParam)lParam; + if (cmep != NULL){ + mir_free(cmep->szServiceName); + mir_free(cmep); } return 0; } -static INT_PTR AddContextFrameMenuItem(WPARAM wParam,LPARAM lParam) +static INT_PTR AddContextFrameMenuItem(WPARAM wParam, LPARAM lParam) { - TMO_MenuItem tmi; CLISTMENUITEM *mi = (CLISTMENUITEM*)lParam; + + TMO_MenuItem tmi; if ( !pcli->pfnConvertMenu(mi, &tmi)) return NULL; @@ -60,22 +42,11 @@ static INT_PTR AddContextFrameMenuItem(WPARAM wParam,LPARAM lParam) fmep->param1 = (INT_PTR)mi->pszContactOwner; tmi.ownerdata = fmep; - return CallService(MO_ADDNEWMENUITEM,(WPARAM)hFrameMenuObject,(LPARAM)&tmi); + return CallService(MO_ADDNEWMENUITEM, (WPARAM)hFrameMenuObject, (LPARAM)&tmi); } -static INT_PTR RemoveContextFrameMenuItem(WPARAM wParam,LPARAM lParam) +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){ - mir_free(fmep->szServiceName); - fmep->szServiceName=NULL; - }; - mir_free(fmep); - } - */ CallService(MO_REMOVEMENUITEM,wParam,0); return 0; } @@ -83,37 +54,37 @@ static INT_PTR RemoveContextFrameMenuItem(WPARAM wParam,LPARAM lParam) //called with: //wparam - ownerdata //lparam - lparam from winproc -INT_PTR FrameMenuExecService(WPARAM wParam,LPARAM lParam) { - lpFrameMenuExecParam fmep=(lpFrameMenuExecParam)wParam; - if (fmep==NULL) - return(-1); +INT_PTR FrameMenuExecService(WPARAM wParam, LPARAM lParam) +{ + lpFrameMenuExecParam fmep = (lpFrameMenuExecParam)wParam; + if (fmep == NULL) + return -1; - CallService(fmep->szServiceName,lParam,fmep->param1); + CallService(fmep->szServiceName, lParam, fmep->param1); RedrawWindow(pcli->hwndContactList,NULL,NULL,RDW_INVALIDATE|RDW_ERASE|RDW_FRAME|RDW_UPDATENOW|RDW_ALLCHILDREN); return 0; } //true - ok,false ignore -INT_PTR FrameMenuCheckService(WPARAM wParam,LPARAM lParam) { +INT_PTR FrameMenuCheckService(WPARAM wParam, LPARAM lParam) +{ + PCheckProcParam pcpp = (PCheckProcParam)wParam; + if (pcpp == NULL) + return FALSE; - PCheckProcParam pcpp=(PCheckProcParam)wParam; - lpFrameMenuExecParam fmep; TMO_MenuItem mi; - - if (pcpp==NULL){return(FALSE);}; - if (CallService(MO_GETMENUITEM,(WPARAM)pcpp->MenuItemHandle,(LPARAM)&mi)==0) - { - fmep = reinterpret_cast(mi.ownerdata); - if (fmep!=NULL) - { + 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) +static INT_PTR ContextFrameMenuNotify(WPARAM wParam, LPARAM lParam) { NotifyEventHooks(hPreBuildFrameMenuEvent,wParam,lParam); return 0; @@ -121,41 +92,33 @@ static INT_PTR ContextFrameMenuNotify(WPARAM wParam,LPARAM lParam) static INT_PTR BuildContextFrameMenu(WPARAM wParam,LPARAM lParam) { - CLISTMENUITEM *mi=(CLISTMENUITEM*)lParam; - HMENU hMenu; ListParam param = { 0 }; - param.MenuObjectHandle=hFrameMenuObject; - param.wParam=wParam; - param.lParam=lParam; - - hMenu=CreatePopupMenu(); - //NotifyEventHooks(hPreBuildFrameMenuEvent,wParam,-1); - ContextFrameMenuNotify(wParam,-1); - CallService(MO_BUILDMENU,(WPARAM)hMenu,(LPARAM)¶m); + param.MenuObjectHandle = hFrameMenuObject; + param.wParam = wParam; + param.lParam = lParam; + + HMENU hMenu = CreatePopupMenu(); + ContextFrameMenuNotify(wParam, -1); + CallService(MO_BUILDMENU, (WPARAM)hMenu, (LPARAM)¶m); return (INT_PTR)hMenu; } -//==========================Frames end +//========================== Frames end int InitFramesMenus(void) { - CreateServiceFunction("FrameMenuExecService",FrameMenuExecService); - CreateServiceFunction("FrameMenuCheckService",FrameMenuCheckService); - CreateServiceFunction("FrameMenuFreeService",FreeOwnerDataFrameMenu); - - CreateServiceFunction(MS_CLIST_REMOVECONTEXTFRAMEMENUITEM,RemoveContextFrameMenuItem); - CreateServiceFunction("CList/AddContextFrameMenuItem",AddContextFrameMenuItem); - CreateServiceFunction(MS_CLIST_MENUBUILDFRAMECONTEXT,BuildContextFrameMenu); - CreateServiceFunction(MS_CLIST_FRAMEMENUNOTIFY,ContextFrameMenuNotify); + CreateServiceFunction("FrameMenuExecService", FrameMenuExecService); + CreateServiceFunction("FrameMenuCheckService", FrameMenuCheckService); + CreateServiceFunction("FrameMenuFreeService", FreeOwnerDataFrameMenu); + + CreateServiceFunction(MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, RemoveContextFrameMenuItem); + CreateServiceFunction("CList/AddContextFrameMenuItem", AddContextFrameMenuItem); + CreateServiceFunction(MS_CLIST_MENUBUILDFRAMECONTEXT, BuildContextFrameMenu); + CreateServiceFunction(MS_CLIST_FRAMEMENUNOTIFY, ContextFrameMenuNotify); hPreBuildFrameMenuEvent = CreateHookableEvent(ME_CLIST_PREBUILDFRAMEMENU); - //frame menu object - hFrameMenuObject = MO_CreateMenuObject("Frames_Menu", LPGEN("Frames menu"), "FrameMenuCheckService", "FrameMenuExecService"); + // frame menu object + hFrameMenuObject = MO_CreateMenuObject("FrameMenu", LPGEN("Frame menu"), "FrameMenuCheckService", "FrameMenuExecService"); MO_SetMenuObjectParam(hFrameMenuObject, OPT_MENUOBJECT_SET_FREE_SERVICE, "FrameMenuFreeService"); return 0; } - -int UnitFramesMenu() -{ - return 0; -} diff --git a/plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp b/plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp index 7059a5563d..002da5d970 100644 --- a/plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp +++ b/plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp @@ -162,7 +162,8 @@ INT_PTR GroupMenuonAddService(WPARAM wParam,LPARAM lParam) //called with: //wparam - ownerdata //lparam - lparam from winproc -INT_PTR GroupMenuExecService(WPARAM wParam,LPARAM lParam) { +INT_PTR GroupMenuExecService(WPARAM wParam,LPARAM lParam) +{ if (wParam!=0) { lpGroupMenuExecParam mmep=(lpGroupMenuExecParam)wParam; if ( !strcmp(mmep->szServiceName,"Help/AboutCommand")) { @@ -176,19 +177,17 @@ INT_PTR GroupMenuExecService(WPARAM wParam,LPARAM lParam) { }; return(1); -}; -INT_PTR FreeOwnerDataGroupMenu (WPARAM wParam,LPARAM lParam) -{ +} - lpGroupMenuExecParam mmep; - mmep=(lpGroupMenuExecParam)lParam; - if (mmep!=NULL) { - FreeAndNil((void **)&mmep->szServiceName); - FreeAndNil((void **)&mmep); +INT_PTR FreeOwnerDataGroupMenu(WPARAM wParam, LPARAM lParam) +{ + lpGroupMenuExecParam mmep = (lpGroupMenuExecParam)lParam; + if (mmep != NULL) { + mir_free(mmep->szServiceName); + mir_free(mmep); } - return 0; -}; +} INT_PTR HideGroupsHelper(WPARAM wParam,LPARAM lParam) { @@ -519,13 +518,11 @@ INT_PTR SubGroupMenuExecService(WPARAM wParam,LPARAM lParam) { INT_PTR FreeOwnerDataSubGroupMenu (WPARAM wParam,LPARAM lParam) { - lpSubGroupMenuExecParam mmep; - mmep=(lpSubGroupMenuExecParam)lParam; - if (mmep!=NULL) { - FreeAndNil((void **)&mmep->szServiceName); - FreeAndNil((void **)&mmep); + lpSubGroupMenuExecParam mmep = (lpSubGroupMenuExecParam)lParam; + if (mmep != NULL) { + mir_free(mmep->szServiceName); + mir_free(mmep); } - return 0; } diff --git a/plugins/Clist_nicer/src/Include/commonheaders.h b/plugins/Clist_nicer/src/Include/commonheaders.h index 0dbcc52508..accb1f265b 100644 --- a/plugins/Clist_nicer/src/Include/commonheaders.h +++ b/plugins/Clist_nicer/src/Include/commonheaders.h @@ -192,5 +192,3 @@ BOOL __forceinline GetItemByStatus(int status, StatusItems_t *retitem); void DrawAlpha(HDC hdcwnd, PRECT rc, DWORD basecolor, int alpha, DWORD basecolor2, BOOL transparent, BYTE FLG_GRADIENT, BYTE FLG_CORNER, DWORD BORDERSTYLE, ImageItem *item); void CustomizeButton(HWND hWnd, bool bIsSkinned, bool bIsThemed, bool bIsFlat); - -void FreeAndNil( void** ); diff --git a/plugins/Clist_nicer/src/clc.cpp b/plugins/Clist_nicer/src/clc.cpp index 067b6116ad..42ac37f5fd 100644 --- a/plugins/Clist_nicer/src/clc.cpp +++ b/plugins/Clist_nicer/src/clc.cpp @@ -41,7 +41,7 @@ void CSH_Destroy(); int DefaultImageListColorDepth = ILC_COLOR32; extern HPEN g_hPenCLUIFrames; -extern wndFrame *wndFrameCLC; +extern FRAMEWND *wndFrameCLC; extern ButtonItem *g_ButtonItems; extern int during_sizing; diff --git a/plugins/Clist_nicer/src/clistevents.cpp b/plugins/Clist_nicer/src/clistevents.cpp index ee76cbb8a7..6d4150a3d7 100644 --- a/plugins/Clist_nicer/src/clistevents.cpp +++ b/plugins/Clist_nicer/src/clistevents.cpp @@ -28,7 +28,7 @@ HFONT __fastcall ChangeToFont(HDC hdc, struct ClcData *dat, int id, int *fontHei extern struct CListEvent* ( *saveAddEvent )(CLISTEVENT *cle); extern int ( *saveRemoveEvent )(HANDLE hContact, HANDLE hDbEvent); -extern wndFrame *wndFrameEventArea; +extern FRAMEWND *wndFrameEventArea; extern HPEN g_hPenCLUIFrames; diff --git a/plugins/Clist_nicer/src/clui.cpp b/plugins/Clist_nicer/src/clui.cpp index 870b4c5533..ae46dd959d 100644 --- a/plugins/Clist_nicer/src/clui.cpp +++ b/plugins/Clist_nicer/src/clui.cpp @@ -60,7 +60,7 @@ extern HBRUSH g_CLUISkinnedBkColor; extern HWND g_hwndSFL; extern ButtonItem *g_ButtonItems; extern COLORREF g_CLUISkinnedBkColorRGB; -extern wndFrame *wndFrameCLC; +extern FRAMEWND *wndFrameCLC; static BYTE old_cliststate, show_on_first_autosize = FALSE; @@ -1702,9 +1702,9 @@ buttons_done: if ( !(showOpts & 6) && cfg::dat.bEqualSections) x = (dis->rcItem.left + dis->rcItem.right - 16) >> 1; - if (pd->statusbarpos == 0) + if (pd->protopos == 0) x += (cfg::dat.bEqualSections ? (cfg::dat.bCLeft / 2) : cfg::dat.bCLeft); - else if (pd->statusbarpos == nParts - 1) + else if (pd->protopos == nParts - 1) x -= (cfg::dat.bCRight / 2); DrawIconEx(dis->hDC, x, (dis->rcItem.top + dis->rcItem.bottom - 16) >> 1, hIcon, 16, 16, 0, NULL, DI_NORMAL); Skin_ReleaseIcon(hIcon); @@ -1722,9 +1722,9 @@ buttons_done: } else { x += 2; - if (pd->statusbarpos == 0) + if (pd->protopos == 0) x += (cfg::dat.bEqualSections ? (cfg::dat.bCLeft / 2) : cfg::dat.bCLeft); - else if (pd->statusbarpos == nParts - 1) + else if (pd->protopos == nParts - 1) x -= (cfg::dat.bCRight / 2); } diff --git a/plugins/Clist_nicer/src/cluiservices.cpp b/plugins/Clist_nicer/src/cluiservices.cpp index d6e5939c86..cd8cdbcaf7 100644 --- a/plugins/Clist_nicer/src/cluiservices.cpp +++ b/plugins/Clist_nicer/src/cluiservices.cpp @@ -182,7 +182,7 @@ void CluiProtocolStatusChanged( int parStatus, const char* szProto ) status = CallProtoService( pa->szModuleName,PS_GETSTATUS,0,0); ProtocolData *PD = ( ProtocolData* )mir_alloc(sizeof(ProtocolData)); PD->RealName = mir_strdup( pa->szModuleName ); - PD->statusbarpos = partCount; + PD->protopos = partCount; { int flags; flags = SBT_OWNERDRAW; diff --git a/plugins/Clist_nicer/src/viewmodes.cpp b/plugins/Clist_nicer/src/viewmodes.cpp index 06340ca3e3..458f03ce08 100644 --- a/plugins/Clist_nicer/src/viewmodes.cpp +++ b/plugins/Clist_nicer/src/viewmodes.cpp @@ -33,7 +33,7 @@ $Id: viewmodes.cpp 13824 2011-09-03 06:32:11Z borkra $ extern HIMAGELIST hCListImages; extern HPEN g_hPenCLUIFrames; -extern wndFrame *wndFrameViewMode; +extern FRAMEWND *wndFrameViewMode; typedef int (__cdecl *pfnEnumCallback)(char *szName); static HWND clvmHwnd = 0; -- cgit v1.2.3