From 02ed4455c23e3562d71bfc80a0e2c4fede8708f1 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 14 Jun 2015 13:17:26 +0000 Subject: - all icolib services removed; - IcoLib_* functions are bound directly to the code git-svn-id: http://svn.miranda-ng.org/main/trunk@14161 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- include/delphi/m_helpers.inc | 2 +- include/delphi/m_icolib.inc | 61 ++++++++-------- include/m_core.h | 2 +- include/m_icolib.h | 168 +++++++++++++------------------------------ include/m_skin.h | 11 +++ 5 files changed, 93 insertions(+), 151 deletions(-) (limited to 'include') diff --git a/include/delphi/m_helpers.inc b/include/delphi/m_helpers.inc index 2eb70b9478..550a766780 100644 --- a/include/delphi/m_helpers.inc +++ b/include/delphi/m_helpers.inc @@ -553,7 +553,7 @@ end; function Skin_AddIcon(si:PSKINICONDESC):THANDLE; begin - result:=CallService(MS_SKIN2_ADDICON, hLangpack, LPARAM(si)); + result:=IcoLib_AddIcon(si, hLangpack); end; procedure Icon_Register(hInst:HINST; const szSection:PAnsiChar; pIcons:pIconItem; iCount:size_t; prefix:PAnsiChar); diff --git a/include/delphi/m_icolib.inc b/include/delphi/m_icolib.inc index f20a919b17..89b1701b21 100644 --- a/include/delphi/m_icolib.inc +++ b/include/delphi/m_icolib.inc @@ -28,24 +28,24 @@ const SIDF_PATH_UNICODE = $200; // Default File is in UCS-2 SIDF_ALL_UNICODE = SIDF_PATH_UNICODE or SIDF_UNICODE; -const { Add a icon into options UI - - wParam = 0 - lParam = PSKINICONDESC returns a handle to the newly added item } - MS_SKIN2_ADDICON:PAnsiChar = 'Skin2/Icons/AddIcon'; + +function IcoLib_AddIcon(pIcon:PSKINICONDESC; iLang:int):THANDLE; stdcall; + external AppDLL name 'IcoLib_AddIcon'; { Remove a icon from options UI - - wParam = (THANDLE)icon handle - lParam = (PChar)icon name, one of them must be specified WARNING: This will invalidate all HICONs retrieved for specified pszName } - MS_SKIN2_REMOVEICON:PAnsiChar = 'Skin2/Icons/RemoveIcon'; + +procedure IcoLib_RemoveIcon(iconName:PAnsiChar); stdcall; + external AppDLL name 'IcoLib_RemoveIcon'; +procedure IcoLib_RemoveIconByHandle(icon:THandle); stdcall; + external AppDLL name 'IcoLib_RemoveIconByHandle'; + { Retrieve HICON with name specified in lParam Returned HICON SHOULDN'T be destroyed, it managed by IcoLib @@ -53,24 +53,23 @@ const wParam = 0 - small 1 - big lParam = pszName } - MS_SKIN2_GETICON :PAnsiChar = 'Skin2/Icons/GetIcon'; -{ - Retrieve an icolib handle for icon by name specified in lParam - - wParam = 0 - lParam = (LPARAM)(char*)pszName -} - MS_SKIN2_GETICONHANDLE:PAnsiChar = 'Skin2/Icons/GetIconHandle'; +function IcoLib_GetIcon(iconName:PAnsiChar; big:byte) : HICON; stdcall; + external AppDLL name 'IcoLib_GetIcon'; { Retrieve HICON with HANDLE specified in lParam Returned HICON SHOULDN'T be destroyed, it is managed by IcoLib +} - wParam = (WPARAM)0 - small 1 - big - lParam = (HANDLE)hIcoLibIcon +function IcoLib_GetIconByHandle(icon:THandle; big:byte) : HICON; stdcall; + external AppDLL name 'IcoLib_GetIconByHandle'; +{ + Retrieve an icolib handle for icon by name specified in lParam } - MS_SKIN2_GETICONBYHANDLE:PAnsiChar = 'Skin2/Icons/GetIconByHandle'; + +function IcoLib_GetIconHandle(iconName:PAnsiChar):THandle; stdcall; + external AppDLL name 'IcoLib_GetIconHandle'; { Add reference to HICON @@ -78,28 +77,30 @@ const wParam = (WPARAM)HICON lParam = 0 - small 1 - big } - MS_SKIN2_ADDREFICON:PAnsiChar = 'Skin2/Icons/AddRef'; + +function IcoLib_AddRef(icon:HICON) : int; stdcall; + external AppDLL name 'IcoLib_AddRef'; { Retrieved HICON is not needed anymore (this helps optimize GDI usage) - - wParam = HICON (optional) - lParam = pszName (optional) // at least one needs to be specified } - MS_SKIN2_RELEASEICON :PAnsiChar = 'Skin2/Icons/ReleaseIcon'; - MS_SKIN2_RELEASEICONBIG:PAnsiChar = 'Skin2/Icons/ReleaseIconBig'; + +function IcoLib_Release(iconName:PAnsiChar; big:byte) : int; stdcall; + external AppDLL name 'IcoLib_Release'; +function IcoLib_ReleaseIcon(icon:THandle; big:byte) : int; stdcall; + external AppDLL name 'IcoLib_ReleaseIcon'; { Check whether HICON is managed by IcoLib - - wParam = (WPARAM)HICON - lParam = 0 } - MS_SKIN2_ISMANAGEDICON:PAnsiChar = 'Skin2/Icons/IsManaged'; + +function IcoLib_IsManaged(icon:HICON) : THandle; stdcall; + external AppDLL name 'IcoLib_IsManaged'; { Icons change notification } +const ME_SKIN2_ICONSCHANGED:PAnsiChar = 'Skin2/IconsChanged'; {$ENDIF} diff --git a/include/m_core.h b/include/m_core.h index 788d82e96d..b39b0fd703 100644 --- a/include/m_core.h +++ b/include/m_core.h @@ -699,7 +699,7 @@ public: return res; } - __forceinline char& operator[](int idx) const { return m_str[idx]; } + __forceinline char& operator[](size_t idx) const { return m_str[idx]; } __forceinline operator char*() const { return m_str; } __forceinline operator unsigned char*() const { return (unsigned char*)m_str; } __forceinline operator LPARAM() const { return (LPARAM)m_str; } diff --git a/include/m_icolib.h b/include/m_icolib.h index e738df1d89..42f0258ab7 100644 --- a/include/m_icolib.h +++ b/include/m_icolib.h @@ -36,17 +36,6 @@ extern int hLangpack; // are translated by the core, which may lead to double translation. // Use LPGEN instead which are just dummy wrappers/markers for "lpgen.pl". -typedef struct { - MAllStrings section; // section name used to group icons - MAllStrings description; // description for options dialog - char *pszName; // name to refer to icon when playing and in db - MAllStrings defaultFile; // default icon file to use - int iDefaultIndex; // index of icon in default file - HICON hDefaultIcon; // handle to default icon - int cx,cy; // dimensions of icon (if 0 then standard size icon (big and small options available) - int flags; // combination of SIDF_* -} SKINICONDESC; - #define SIDF_SORTED 0x01 // Icons in section are sorted by name #define SIDF_UNICODE 0x100 // Section and Description are in UCS-2 #define SIDF_PATH_UNICODE 0x200 // Default File is in UCS-2 @@ -62,142 +51,83 @@ typedef struct { #define SIDF_ALL_TCHAR 0 #endif -MIR_APP_DLL(HICON) LoadSkinProtoIcon(const char *szProto, int status, bool big = false); -MIR_APP_DLL(HICON) LoadSkinIcon(int idx, bool big = false); -MIR_APP_DLL(HANDLE) GetSkinIconHandle(int idx); - -MIR_APP_DLL(HANDLE) IcoLib_AddNewIcon(int hLangpack, SKINICONDESC *sid); -MIR_APP_DLL(HICON) IcoLib_GetIcon(const char* pszIconName, bool big); -MIR_APP_DLL(HANDLE) IcoLib_GetIconHandle(const char* pszIconName); -MIR_APP_DLL(HICON) IcoLib_GetIconByHandle(HANDLE hItem, bool big); -MIR_APP_DLL(HANDLE) IcoLib_IsManaged(HICON hIcon); -MIR_APP_DLL(int) IcoLib_ReleaseIcon(HICON hIcon, char* szIconName, bool big = false); - -MIR_APP_DLL(void) Button_SetIcon_IcoLib(HWND hDlg, int itemId, int iconId, const char* tooltip); -MIR_APP_DLL(void) Button_FreeIcon_IcoLib(HWND hDlg, int itemId); - -MIR_APP_DLL(void) Window_SetIcon_IcoLib(HWND hWnd, int iconId); -MIR_APP_DLL(void) Window_SetProtoIcon_IcoLib(HWND hWnd, const char *szProto, int iconId); -MIR_APP_DLL(void) Window_FreeIcon_IcoLib(HWND hWnd); - -/////////////////////////////////////////////////////////////////////////////// -// Adds an icon into options UI -// -// wParam = (WPARAM)0 -// lParam = (LPARAM)(SKINICONDESC*)sid; -// returns a handle to the newly added item - -__forceinline HANDLE Skin_AddIcon(SKINICONDESC* si) -{ return (HANDLE)CallService("Skin2/Icons/AddIcon", hLangpack, (LPARAM)si); -} +struct SKINICONDESC +{ + MAllStrings section; // section name used to group icons + MAllStrings description; // description for options dialog + char *pszName; // name to refer to icon when playing and in db + MAllStrings defaultFile; // default icon file to use + int iDefaultIndex; // index of icon in default file + HICON hDefaultIcon; // handle to default icon + int cx, cy; // dimensions of icon (if 0 then standard size icon (big and small options available) + int flags; // combination of SIDF_* +}; + +#if defined(__cplusplus) +extern "C" +{ +#endif /////////////////////////////////////////////////////////////////////////////// -// Removes an icon from options UI -// -// wParam = (WPARAM)(HANDLE)hIcolib (optional) -// lParam = (LPARAM)(char*)pszName (optional) -// at least one needs to be specified +// Adds an icon into the icon library +// returns a handle to the newly added item -#define MS_SKIN2_REMOVEICON "Skin2/Icons/RemoveIcon" +MIR_APP_DLL(HANDLE) IcoLib_AddIcon(SKINICONDESC *sid, int _lang = hLangpack); -__forceinline void Skin_RemoveIcon(const char* szIconName) -{ CallService(MS_SKIN2_REMOVEICON, 0, (LPARAM)szIconName); -} +/////////////////////////////////////////////////////////////////////////////// +// Removes an icon from icon library by icon's name or handle -__forceinline void Skin_RemoveIconHandle(HANDLE hIcolib) -{ CallService(MS_SKIN2_REMOVEICON, (WPARAM)hIcolib, 0); -} +MIR_APP_DLL(void) IcoLib_RemoveIcon(const char *pszIconName); +MIR_APP_DLL(void) IcoLib_RemoveIconByHandle(HANDLE hItem); /////////////////////////////////////////////////////////////////////////////// -// Retrieves HICON with the name specified in lParam -// -// wParam = (WPARAM)0 - small 1 - big -// lParam = (LPARAM)(char*)pszName -// Returned HICON SHOULDN'T be destroyed, it is managed by IcoLib +// Retrieves HICON with the name specified in lParam +// Returned HICON SHOULDN'T be destroyed, it is managed by IcoLib -#define MS_SKIN2_GETICON "Skin2/Icons/GetIcon" - -#ifdef __cplusplus -__forceinline HICON Skin_GetIcon(const char* szIconName, int size=0) -#else -__forceinline HICON Skin_GetIcon(const char* szIconName, int size) -#endif -{ return (HICON)CallService(MS_SKIN2_GETICON, size, (LPARAM)szIconName); -} +MIR_APP_DLL(HICON) IcoLib_GetIcon(const char *pszIconName, bool big = false); +MIR_APP_DLL(HICON) IcoLib_GetIconByHandle(HANDLE hItem, bool big = false); /////////////////////////////////////////////////////////////////////////////// -// Retrieves an icolib handle by the icon's name specified in lParam -// -// wParam = (WPARAM)0 -// lParam = (LPARAM)(char*)pszName +// Retrieves an icolib handle by the icon's name specified in lParam -#define MS_SKIN2_GETICONHANDLE "Skin2/Icons/GetIconHandle" - -__forceinline HANDLE Skin_GetIconHandle(const char* szIconName) -{ return (HANDLE)CallService(MS_SKIN2_GETICONHANDLE, 0, (LPARAM)szIconName); -} +MIR_APP_DLL(HANDLE) IcoLib_GetIconHandle(const char *pszIconName); /////////////////////////////////////////////////////////////////////////////// -// Retrieves HICON with HANDLE specified in lParam -// -// wParam = (WPARAM)0 - small 1 - big -// lParam = (LPARAM)(HANDLE)hIcoLibIcon -// Returned HICON SHOULDN'T be destroyed, it is managed by IcoLib - -#define MS_SKIN2_GETICONBYHANDLE "Skin2/Icons/GetIconByHandle" +// Adds 1 to an icon's ref counter. prevents an icon from being unloaded -#ifdef __cplusplus -__forceinline HICON Skin_GetIconByHandle(HANDLE hIcolibIcon, int size=0) -#else -__forceinline HICON Skin_GetIconByHandle(HANDLE hIcolibIcon, int size) -#endif -{ return (HICON)CallService(MS_SKIN2_GETICONBYHANDLE, size, (LPARAM)hIcolibIcon); -} +MIR_APP_DLL(int) IcoLib_AddRef(HICON hIcon); /////////////////////////////////////////////////////////////////////////////// -// Adds a reference to HICON -// -// wParam = (WPARAM)HICON -// lParam = 0 - small 1 - big +// Retrieved HICON is not needed anymore (releases a reference; thus helps to optimize GDI usage) -#define MS_SKIN2_ADDREFICON "Skin2/Icons/AddRef" +MIR_APP_DLL(int) IcoLib_Release(const char *pszIconName, bool big = false); +MIR_APP_DLL(int) IcoLib_ReleaseIcon(HICON hIcon, bool big = false); /////////////////////////////////////////////////////////////////////////////// -// Retrieved HICON is not needed anymore (releases a reference; thus helps to optimize GDI usage) -// -// wParam = (WPARAM)HICON (optional) -// lParam = (LPARAM)(char*)pszName (optional) // at least one needs to be specified - -#define MS_SKIN2_RELEASEICON "Skin2/Icons/ReleaseIcon" -#define MS_SKIN2_RELEASEICONBIG "Skin2/Icons/ReleaseIconBig" +// Checks whether HICON is managed by IcoLib -__forceinline void Skin_ReleaseIcon(const char* szIconName) -{ CallService(MS_SKIN2_RELEASEICON, 0, (LPARAM)szIconName); -} +MIR_APP_DLL(HANDLE) IcoLib_IsManaged(HICON hIcon); -#ifdef __cplusplus -__forceinline void Skin_ReleaseIcon(const char* szIconName, int big) -{ CallService((big) ? MS_SKIN2_RELEASEICONBIG : MS_SKIN2_RELEASEICON, 0, (LPARAM)szIconName); -} +/////////////////////////////////////////////////////////////////////////////// +// Helper to apply an icolib's icon to a button -__forceinline void Skin_ReleaseIcon(HICON hIcon) -#else -__forceinline void Skin_ReleaseIcon2(HICON hIcon) -#endif -{ CallService(MS_SKIN2_RELEASEICON, (WPARAM)hIcon, 0); -} +MIR_APP_DLL(void) Button_SetIcon_IcoLib(HWND hDlg, int itemId, int iconId, const char* tooltip); +MIR_APP_DLL(void) Button_FreeIcon_IcoLib(HWND hDlg, int itemId); /////////////////////////////////////////////////////////////////////////////// -// Checks whether HICON is managed by IcoLib -// -// wParam = (WPARAM)HICON -// lParam = 0 +// Helper to apply an icolib's icon to a window -#define MS_SKIN2_ISMANAGEDICON "Skin2/Icons/IsManaged" +MIR_APP_DLL(void) Window_SetIcon_IcoLib(HWND hWnd, int iconId); +MIR_APP_DLL(void) Window_SetProtoIcon_IcoLib(HWND hWnd, const char *szProto, int iconId); +MIR_APP_DLL(void) Window_FreeIcon_IcoLib(HWND hWnd); /////////////////////////////////////////////////////////////////////////////// -// Icons' change notification +// Icons' change notification event #define ME_SKIN2_ICONSCHANGED "Skin2/IconsChanged" +#if defined(__cplusplus) +} +#endif + #endif /* M_ICOLIB_H__ */ diff --git a/include/m_skin.h b/include/m_skin.h index 2dfa5db917..7537e4a918 100644 --- a/include/m_skin.h +++ b/include/m_skin.h @@ -26,6 +26,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern int hLangpack; +#ifndef M_CORE_H__ +#include +#endif + //loads an icon from the user's custom skin library, or from the exe if there //isn't one of them //wParam = id of icon to load - see below @@ -39,6 +43,13 @@ __forceinline HANDLE LoadSkinnedIconHandle(int id) { return (HANDLE)CallService( __forceinline HICON LoadSkinnedIconBig(int id) { return (HICON) CallService(MS_SKIN_LOADICON, id, 2); } __forceinline LPCSTR LoadSkinnedIconName(int id) { return (LPCSTR)CallService(MS_SKIN_LOADICON, id, 3); } +/////////////////////////////////////////////////////////////////////////////// +// Miranda skin + +MIR_APP_DLL(HICON) LoadSkinProtoIcon(const char *szProto, int status, bool big = false); +MIR_APP_DLL(HICON) LoadSkinIcon(int idx, bool big = false); +MIR_APP_DLL(HANDLE) GetSkinIconHandle(int idx); + // event icons #define SKINICON_EVENT_MESSAGE 100 #define SKINICON_EVENT_URL 101 -- cgit v1.2.3