From fda46e22fa15bd77a6d1e2610e9fd9b272dc04fa Mon Sep 17 00:00:00 2001 From: pescuma Date: Sat, 11 Apr 2009 18:09:04 +0000 Subject: extraicons: - Added visibility icons - Added handling of CLUICAPS_FLAGS2 git-svn-id: http://pescuma.googlecode.com/svn/trunk/Miranda@160 c086bb3d-8645-0410-b8da-73a8550f86e7 --- Plugins/extraicons/commons.h | 1 - Plugins/extraicons/extraicons.cpp | 51 +++-- Plugins/extraicons/extraicons.dsp | 12 ++ Plugins/extraicons/res/AlwaysVis.ico | Bin 0 -> 2038 bytes Plugins/extraicons/res/Chatchannel.ico | Bin 0 -> 2038 bytes Plugins/extraicons/res/NeverVis.ico | Bin 0 -> 2038 bytes Plugins/extraicons/resource.h | 7 +- Plugins/extraicons/resource.rc | 11 ++ Plugins/extraicons/sdk/m_cluiframes.h | 350 --------------------------------- 9 files changed, 68 insertions(+), 364 deletions(-) create mode 100644 Plugins/extraicons/res/AlwaysVis.ico create mode 100644 Plugins/extraicons/res/Chatchannel.ico create mode 100644 Plugins/extraicons/res/NeverVis.ico delete mode 100644 Plugins/extraicons/sdk/m_cluiframes.h diff --git a/Plugins/extraicons/commons.h b/Plugins/extraicons/commons.h index 4320025..33835a3 100644 --- a/Plugins/extraicons/commons.h +++ b/Plugins/extraicons/commons.h @@ -83,7 +83,6 @@ extern vector hHooks; extern vector extraIcons; ExtraIcon * GetExtraIconBySlot(int slot); -int GetClistNumberOfSlots(); int GetNumberOfSlots(); int ConvertToClistSlot(int slot); diff --git a/Plugins/extraicons/extraicons.cpp b/Plugins/extraicons/extraicons.cpp index 2e3a636..61b8c68 100644 --- a/Plugins/extraicons/extraicons.cpp +++ b/Plugins/extraicons/extraicons.cpp @@ -47,6 +47,9 @@ vector extraIcons; char *metacontacts_proto = NULL; BOOL clistRebuildAlreadyCalled = FALSE; +int clistFirstSlot = 0; +int clistSlotCount = 0; + int ModulesLoaded(WPARAM wParam, LPARAM lParam); int PreShutdown(WPARAM wParam, LPARAM lParam); int IconsChanged(WPARAM wParam, LPARAM lParam); @@ -83,6 +86,28 @@ extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) return interfaces; } +static void RegisterIcon(char *name, char *section, char *description, int id) +{ + HICON hIcon = (HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM) name); + if (hIcon != NULL) + return; + + SKINICONDESC sid = { 0 }; + sid.cbSize = sizeof(SKINICONDESC); + sid.flags = SIDF_TCHAR; + sid.pszName = name; + sid.pszSection = section; + sid.pszDescription = description; + + int cx = GetSystemMetrics(SM_CXSMICON); + sid.hDefaultIcon = (HICON) LoadImage(hInst, MAKEINTRESOURCE(id), IMAGE_ICON, cx, cx, LR_DEFAULTCOLOR | LR_SHARED); + + CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid); + + if (sid.hDefaultIcon) + DestroyIcon(sid.hDefaultIcon); +} + extern "C" int __declspec(dllexport) Load(PLUGINLINK *link) { pluginLink = link; @@ -90,8 +115,18 @@ extern "C" int __declspec(dllexport) Load(PLUGINLINK *link) mir_getMMI(&mmi); mir_getUTFI(&utfi); + DWORD ret = CallService(MS_CLUI_GETCAPS, CLUICAPS_FLAGS2, 0); + clistFirstSlot = HIWORD(ret); + clistSlotCount = LOWORD(ret); + - // hooks + // Icons + RegisterIcon("AlwaysVis", "Contact List", "Always Visible", IDI_ALWAYSVIS); + RegisterIcon("NeverVis", "Contact List", "Never Visible", IDI_NEVERVIS); + RegisterIcon("ChatActivity", "Contact List", "Chat Activity", IDI_CHAT); + + + // Hooks hHooks.push_back(HookEvent(ME_SYSTEM_MODULESLOADED, &ModulesLoaded)); hHooks.push_back(HookEvent(ME_SYSTEM_PRESHUTDOWN, &PreShutdown)); hHooks.push_back(HookEvent(ME_CLIST_EXTRA_LIST_REBUILD, &ClistExtraListRebuild)); @@ -175,17 +210,9 @@ int PreShutdown(WPARAM wParam, LPARAM lParam) return 0; } -int GetClistNumberOfSlots() -{ - if (!ServiceExists(MS_CLUI_GETCAPS)) - return 0; - - return CallService(MS_CLUI_GETCAPS, 0, CLUIF2_EXTRACOLUMNCOUNT); -} - int GetNumberOfSlots() { - return MIN(GetClistNumberOfSlots(), extraIcons.size()); + return MIN(clistSlotCount, extraIcons.size()); } int ConvertToClistSlot(int slot) @@ -193,7 +220,7 @@ int ConvertToClistSlot(int slot) if (slot < 0) return slot; - return GetClistNumberOfSlots() - 1 - slot; + return clistSlotCount + clistFirstSlot - 1 - slot; } int Clist_SetExtraIcon(HANDLE hContact, int slot, HANDLE hImage) @@ -287,6 +314,8 @@ int ExtraIcon_Register(WPARAM wParam, LPARAM lParam) slot = -1; else if (slot == (WORD) -2) slot = -2; + else if (slot >= clistSlotCount) + slot = -2; int origSlot = slot; diff --git a/Plugins/extraicons/extraicons.dsp b/Plugins/extraicons/extraicons.dsp index 02d7df6..fea1d82 100644 --- a/Plugins/extraicons/extraicons.dsp +++ b/Plugins/extraicons/extraicons.dsp @@ -204,6 +204,18 @@ SOURCE=.\usedIcons.h # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # Begin Source File +SOURCE=.\res\AlwaysVis.ico +# End Source File +# Begin Source File + +SOURCE=.\res\Chatchannel.ico +# End Source File +# Begin Source File + +SOURCE=.\res\NeverVis.ico +# End Source File +# Begin Source File + SOURCE=.\resource.rc # End Source File # End Group diff --git a/Plugins/extraicons/res/AlwaysVis.ico b/Plugins/extraicons/res/AlwaysVis.ico new file mode 100644 index 0000000..05013a0 Binary files /dev/null and b/Plugins/extraicons/res/AlwaysVis.ico differ diff --git a/Plugins/extraicons/res/Chatchannel.ico b/Plugins/extraicons/res/Chatchannel.ico new file mode 100644 index 0000000..2e48365 Binary files /dev/null and b/Plugins/extraicons/res/Chatchannel.ico differ diff --git a/Plugins/extraicons/res/NeverVis.ico b/Plugins/extraicons/res/NeverVis.ico new file mode 100644 index 0000000..6aebec2 Binary files /dev/null and b/Plugins/extraicons/res/NeverVis.ico differ diff --git a/Plugins/extraicons/resource.h b/Plugins/extraicons/resource.h index 5f5e7f5..d5dd729 100644 --- a/Plugins/extraicons/resource.h +++ b/Plugins/extraicons/resource.h @@ -3,17 +3,20 @@ // Used by resource.rc // #define IDD_OPTIONS 119 +#define IDI_ALWAYSVIS 120 +#define IDI_NEVERVIS 121 +#define IDI_CHAT 122 #define IDC_SLOT_L 1075 #define IDC_SLOT 1076 #define IDC_STATIC -1 // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NO_MFC 1 #define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 120 +#define _APS_NEXT_RESOURCE_VALUE 123 #define _APS_NEXT_COMMAND_VALUE 40005 #define _APS_NEXT_CONTROL_VALUE 1077 #define _APS_NEXT_SYMED_VALUE 101 diff --git a/Plugins/extraicons/resource.rc b/Plugins/extraicons/resource.rc index 570d21f..3fb9549 100644 --- a/Plugins/extraicons/resource.rc +++ b/Plugins/extraicons/resource.rc @@ -59,6 +59,17 @@ BEGIN END #endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_ALWAYSVIS ICON DISCARDABLE "res\\AlwaysVis.ico" +IDI_NEVERVIS ICON DISCARDABLE "res\\NeverVis.ico" +IDI_CHAT ICON DISCARDABLE "res\\Chatchannel.ico" #endif // Neutral resources ///////////////////////////////////////////////////////////////////////////// diff --git a/Plugins/extraicons/sdk/m_cluiframes.h b/Plugins/extraicons/sdk/m_cluiframes.h deleted file mode 100644 index 73ca5e9..0000000 --- a/Plugins/extraicons/sdk/m_cluiframes.h +++ /dev/null @@ -1,350 +0,0 @@ -/* -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 -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. -*/ - -/************************************************************************/ -/* Extra Image Column Support +0.5.0.0 */ -/************************************************************************/ -/* - HINT: Common usage of Extra icons by modules - Usage sequence is next: - The Plugin have to be subscribed to ME_CLIST_EXTRA_LIST_REBUILD and - ME_CLIST_EXTRA_IMAGE_APPLY notifications. - - During .._REBUILD Notification handle plugin should register required - icons in CList internal list via MS_CLIST_EXTRA_ADD_ICON servise - and should to keep returned icon indexes. - - Note: _REBUILD notification means that list was rebuilded and - all previously registered icon indexes became invalid and can not be used. - - Note: After calling _ADD_ICON services the icon handle you provided is not - need for extra images porpouses and have to be released by you in order - to reduce GDI resources consumptions. - - Note: Don't forget that icon handle loaded by LoadIcon GDI function is - shared and will be kept in memory till plugin unloading. So it is not - better way to load icon. Please use appropriate Iconlib services. - - Note: The icon can be registered in Clist at any time. - - During .._ME_CLIST_EXTRA_IMAGE_APPLY the plugin has to call - MS_CLIST_EXTRA_SET_ICON passing appropriate icon index for contact. This - service can be called any time in order to change current extra image. - - ATTENTION: Currently Module support only 254 registered extra icons. The returned - value 0xFF internally means 'No extra icon' so thry t register only realy required - icons. The best solution - register not registered/invalidated icon just before - setting of extra image. - - ATTENTION: Due to different module may use same extra icons slot - they will be conflicted. - Please provide ability to end-user to change extra image slot to be used to show - your plugin information. - -*/ - -//Extra columns type. -//column arranged in this way -// -// [statusicon] ContactName [WEB][ADV1][ADV2][SMS][EMAIL][PROTO][CLIENT] -// -#define EXTRA_ICON_RES0 0 // only used by nicer -#define EXTRA_ICON_EMAIL 1 -#define EXTRA_ICON_WEB 2 -#define EXTRA_ICON_SMS 3 -#define EXTRA_ICON_ADV1 4 -#define EXTRA_ICON_ADV2 5 -#define EXTRA_ICON_ADV3 6 -#define EXTRA_ICON_CLIENT 7 -#define EXTRA_ICON_ADV4 8 -#define EXTRA_ICON_RES1 9 // only used by nicer -#define EXTRA_ICON_PROTO 9 // used by mwclist and modern -#define EXTRA_ICON_RES2 10 // only used by nicer -#define EXTRA_ICON_VISMODE 10 // only used by modern - -#define EXTRA_ICON_COUNT 10 - -typedef struct -{ - int cbSize; //must be sizeof(IconExtraColumn) - int ColumnType; - HANDLE hImage; //return value from MS_CLIST_EXTRA_ADD_ICON -}IconExtraColumn,*pIconExtraColumn; - -//Set icon for contact at needed column -//wparam=hContact -//lparam=pIconExtraColumn -//return 0 on success,-1 on failure -// -//See above for supported columns -#define MS_CLIST_EXTRA_SET_ICON "CListFrames/SetIconForExraColumn" - -//Adding icon to extra image list. -//Call this in ME_CLIST_EXTRA_LIST_REBUILD event -// -//wparam=hIcon -//lparam=0 -//return hImage on success,-1 on failure -#define MS_CLIST_EXTRA_ADD_ICON "CListFrames/AddIconToExtraImageList" - -#define ME_CLIST_EXTRA_LIST_REBUILD "CListFrames/OnExtraListRebuild" - -//called with wparam=hContact -#define ME_CLIST_EXTRA_IMAGE_APPLY "CListFrames/OnExtraImageApply" - -//called with wparam=hContact lparam=extra -#define ME_CLIST_EXTRA_CLICK "CListFrames/OnExtraClick" - -//End of extra images header. TODO move it to separate m_extraimages.h file -//Cause it has not any relationship to cluiframes engine - - -/************************************************************************/ -/* CLUI Frames Support */ -/************************************************************************/ - -// NOTE: Clui frames engine is in to be reconsructed.. - -// Constants used below -typedef struct tagCLISTFrame { - DWORD cbSize; - HWND hWnd ; - HICON hIcon; - int align; //al flags below - union { - int height; - int minSize; //the actual meaning depends from type of frame - }; - int Flags; //F_flags below - union { - char *name; //frame window name indentifier (DO NOT TRANSLATE) - wchar_t *wname; - LPTSTR tname; - }; - union { - char *TBname; //titlebar & menu caption - wchar_t *TBwname; - LPTSTR TBtname; - }; -} CLISTFrame; - -#define F_VISIBLE 1 //Frame visible -#define F_SHOWTB 2 //Show TitleBar -#define F_UNCOLLAPSED 4 //UnCollapse frame -#define F_LOCKED 8 //Lock Frame -#define F_NOBORDER 16 //Dont apply WS_BORDER style for window -#define F_SHOWTBTIP 32 //Show titlebar tooltip -#define F_CANBEVERTICAL 64 //frames can be vertical -#define F_CANNOTBEHORIZONTAL 128 //frames can NOT be horizontal F_CANBEVERTICAL have to be set -#define F_NO_SUBCONTAINER 1024 //Support skining no subcontainer needed -#define F_UNICODE 32768 //Use unicode text -#ifdef _UNICODE -# define F_TCHAR F_UNICODE -#else -# define F_TCHAR 0 -#endif - -// frame alignment -#define alTop 0x00000001 -#define alBottom 0x00000002 -#define alClient 0x00000004 //only one alClient frame - -// since 0.7.0.20 -#define alLeft 0x00000011 // frame is vertical -#define alRight 0x00000012 - -#define alVertFrameMask 0x00000010 - -#define FU_TBREDRAW 1 //redraw titlebar -#define FU_FMREDRAW 2 //redraw Frame -#define FU_FMPOS 4 //update Frame position - -#define FO_FLAGS 0x0001 //return set of F_VISIBLE,F_SHOWTB,F_UNCOLLAPSED,F_LOCKED,F_NOBORDER,F_SHOWTBTIP -#define FO_NAME 0x0002 //Change m_cacheTName -#define FO_TBNAME 0x0003 //Change TB caption -#define FO_TBSTYLE 0x0004 //Change TB style -#define FO_TBEXSTYLE 0x0005 //Change TB exstyle -#define FO_ICON 0x0006 //Change icon -#define FO_HEIGHT 0x0007 //Change height -#define FO_ALIGN 0x0008 //Change align -#define FO_TBTIPNAME 0x0009 //Change TB tooltip -#define FO_FLOATING 0x000a //Change floating mode - -#define FO_UNICODETEXT 0x8000 // flag for FO_NAME,FO_TBNAME, FO_TBTIPNAME set/get lPAram as unicode wchar_t -#ifdef _UNICODE - #define FO_TCHAR FO_UNICODETEXT -#else - #define FO_TCHAR 0x0000 -#endif - - -////////////////////////////////////////////////////////////////////////// -//want show tooltip for statusbar -//wparam=(char *)protocolname -//lparam=0 -#define ME_CLIST_FRAMES_SB_SHOW_TOOLTIP "CListFrames/StatusBarShowToolTip" - -////////////////////////////////////////////////////////////////////////// -//want hide tooltip for statusbar -//wparam=lparam=0 -#define ME_CLIST_FRAMES_SB_HIDE_TOOLTIP "CListFrames/StatusBarHideToolTip" - -////////////////////////////////////////////////////////////////////////// -//adds a frame window -//wParam=(CLISTFrame*) -//lParam=0 -//returns an integer, the frame id. -#define MS_CLIST_FRAMES_ADDFRAME "CListFrames/AddFrame" - -////////////////////////////////////////////////////////////////////////// -// remove frame. It destroy your window -// -#define MS_CLIST_FRAMES_REMOVEFRAME "CListFrames/RemoveFrame" - -////////////////////////////////////////////////////////////////////////// -//shows all frames -//wParam=lParam=0 -//returns 0 on success, -1 on failure -#define MS_CLIST_FRAMES_SHOWALLFRAMES "CListFrames/ShowALLFrames" - -////////////////////////////////////////////////////////////////////////// -//shows the titlebars of all frames -//wParam=lParam=0 -//returns 0 on success, -1 on failure -#define MS_CLIST_FRAMES_SHOWALLFRAMESTB "CListFrames/ShowALLFramesTB" - -////////////////////////////////////////////////////////////////////////// -//hides the titlebars of all frames -//wParam=lParam=0 -//returns 0 on success, -1 on failure -#define MS_CLIST_FRAMES_HIDEALLFRAMESTB "CListFrames/HideALLFramesTB" - -////////////////////////////////////////////////////////////////////////// -//shows the frame if it is hidden, -//hides the frame if it is shown -//wParam = FrameId -//lParam = Frame number (can be shown in profile in CLUIFrames key) -//returns 0 on success, -1 on failure -//note that Frame number will be taken only if wParam == 0 -#define MS_CLIST_FRAMES_SHFRAME "CListFrames/SHFrame" - -////////////////////////////////////////////////////////////////////////// -//shows the frame titlebar if it is hidden, -//hides the frame titlebar if it is shown -//wParam=FrameId -//lParam = Frame number (can be shown in profile in CLUIFrames key) -//returns 0 on success, -1 on failure -//note that Frame number will be taken only if wParam == 0 -#define MS_CLIST_FRAMES_SHFRAMETITLEBAR "CListFrame/SHFrameTitleBar" - -////////////////////////////////////////////////////////////////////////// -//locks the frame if it is unlocked, -//unlock the frame if it is locked -//wParam=FrameId -//lParam = Frame number (can be shown in profile in CLUIFrames key) -//returns 0 on success, -1 on failure -//note that Frame number will be taken only if wParam == 0 -#define MS_CLIST_FRAMES_ULFRAME "CListFrame/ULFrame" - -////////////////////////////////////////////////////////////////////////// -//collapses the frame if it is uncollapsed, -//uncollapses the frame if it is collapsed -//wParam=FrameId -//lParam = Frame number (can be shown in profile in CLUIFrames key) -//returns 0 on success, -1 on failure -//note that Frame number will be taken only if wParam == 0 -#define MS_CLIST_FRAMES_UCOLLFRAME "CListFrame/UCOLLFrame" - -////////////////////////////////////////////////////////////////////////// -//trigger border flags -//wparam=frameid -//lParam = Frame number (can be shown in profile in CLUIFrames key) -//returns 0 on success, -1 on failure -//note that Frame number will be taken only if wParam == 0 -#define MS_CLIST_FRAMES_SETUNBORDER "CListFrame/SetUnBorder" - -////////////////////////////////////////////////////////////////////////// -//redraws the frame -//wParam=FrameId, -1 for all frames -//lparam=FU_flags -//returns a pointer to option, -1 on failure -#define MS_CLIST_FRAMES_UPDATEFRAME "CListFrame/UpdateFrame" - -////////////////////////////////////////////////////////////////////////// -//gets the frame options -//(HIWORD)wParam=FrameId -//(LOWORD)wParam=FO_flag -//lParam=0 -//returns a pointer to option, -1 on failure -#define MS_CLIST_FRAMES_GETFRAMEOPTIONS "CListFrame/GetFrameOptions" - -//sets the frame options -//(HIWORLD)wParam=FrameId -//(LOWORD)wParam=FO_flag -//lParam=value -//returns 0 on success, -1 on failure -#define MS_CLIST_FRAMES_SETFRAMEOPTIONS "CListFrame/SetFrameOptions" - -////////////////////////////////////////////////////////////////////////// -//Frames related menu stuff -////////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////////// -//add a new item to the context frame menu -//wParam=0 -//lParam=(LPARAM)(CLISTMENUITEM*)&mi -//returns a handle to the new item -//popupposition=frameid -//contactowner=advanced parameter -#define MS_CLIST_ADDCONTEXTFRAMEMENUITEM "CList/AddContextFrameMenuItem" - -////////////////////////////////////////////////////////////////////////// -//remove a item from context frame menu -//wParam=hMenuItem returned by MS_CLIST_ADDCONTACTMENUITEM -//lParam=0 -//returns 0 on success, nonzero on failure -#define MS_CLIST_REMOVECONTEXTFRAMEMENUITEM "CList/RemoveContextFrameMenuItem" - -////////////////////////////////////////////////////////////////////////// -//builds the context menu for a frame -//wparam=frameid -//lParam=0 -//returns a HMENU on success, or NULL on failure -#define MS_CLIST_MENUBUILDFRAMECONTEXT "CList/BuildContextFrameMenu" - -////////////////////////////////////////////////////////////////////////// -// the frame menu is about to be built -// wparam=frameid -// lparam= -// -1 for build from titlebar, -// use -// MS_CLIST_ADDCONTEXTFRAMEMENUITEM -// MS_CLIST_REMOVECONTEXTFRAMEMENUITEM -// -// >0 for build in main menu, -// must be popupname=lparam to place your items in right popup of main menu. -// use -// MS_CLIST_ADDMAINMENUITEM -// MS_CLIST_REMOVEMAINMENUITEM -// -#define ME_CLIST_PREBUILDFRAMEMENU "CList/PreBuildFrameMenu" - -////////////////////////////////////////////////////////////////////////// -//needed by cluiframes module to add frames menu to main menu. -//it just calls NotifyEventHooks(hPreBuildFrameMenuEvent,wParam,lParam); -#define MS_CLIST_FRAMEMENUNOTIFY "CList/ContextFrameMenuNotify" -- cgit v1.2.3