From 0976190894d653d5062f8ef6befabf46218f2d24 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 3 Oct 2016 16:48:12 +0000 Subject: - inlined helpers for fonts, colors & effects creation replaced with functions; - services for getting fonts, colors & effects removed; - some memory corruptions removed git-svn-id: http://svn.miranda-ng.org/main/trunk@17347 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- include/delphi/m_fontservice.inc | 51 +++--------------------------- include/delphi/m_helpers.inc | 31 +++---------------- include/m_fontservice.h | 67 +++++++++++++++------------------------- 3 files changed, 34 insertions(+), 115 deletions(-) (limited to 'include') diff --git a/include/delphi/m_fontservice.inc b/include/delphi/m_fontservice.inc index b93f7cf653..c6dacc42e1 100644 --- a/include/delphi/m_fontservice.inc +++ b/include/delphi/m_fontservice.inc @@ -112,22 +112,12 @@ type PFontIDW = ^TFontIDW; const - { register a font } - { wparam = pointer to FontID structure} - { lparam = hLangpack } - MS_FONT_REGISTERA:PAnsiChar = 'Font/Register'; - MS_FONT_REGISTERW:PAnsiChar = 'Font/RegisterW'; - - { get a font } - { wparam = pointer to FontID structure (only name and group matter) } - { lParam = pointer to LOGFONT structure } - { returns the font's colour } - MS_FONT_GETA:PAnsiChar = 'Font/Get'; - MS_FONT_GETW:PAnsiChar = 'Font/GetW'; - { fired when a user modifies font settings, so reget your fonts } ME_FONT_RELOAD:PAnsiChar = 'Font/Reload'; +function Font_Register(pFont:pFontID; hLang:int) : int; stdcall; external AppDll; +function Font_Get(pGroup,pName:pAnsiChar; pFont:pLogFontA) : longint; stdcall; external AppDll; + type PColourID_tag = ^TColourID_tag; TColourID_tag = record @@ -158,29 +148,11 @@ type PColourIDW = ^TColourIDW; const - { register a colour (this should be used for everything except actual text colour for registered fonts) } - { [note - a colour with name 'Background' has special meaning and will be used as the background colour of } - { the font list box in the options, for the given group] } - { wparam = pointer to ColourID structure } - { lparam = hLangpack } - MS_COLOUR_REGISTERA:PAnsiChar = 'Colour/Register'; - MS_COLOUR_REGISTERW:PAnsiChar = 'Colour/RegisterW'; - - { get a colour } - { wparam = pointer to ColourID structure (only name and group matter) } - { returns the colour (as COLORREF), or -1 if not found } - MS_COLOUR_GETA:PAnsiChar = 'Colour/Get'; - MS_COLOUR_GETW:PAnsiChar = 'Colour/GetW'; - { fired when a user modifies font settings, so reget your fonts and colours } ME_COLOUR_RELOAD:PAnsiChar = 'Colour/Reload'; -var - MS_FONT_REGISTER :PAnsiChar absolute MS_FONT_REGISTERW; - MS_FONT_GET :PAnsiChar absolute MS_FONT_GETW; - MS_COLOUR_REGISTER:PAnsiChar absolute MS_COLOUR_REGISTERW; - MS_COLOUR_GET :PAnsiChar absolute MS_COLOUR_GETW; - +function Colour_Register(pColour:pColourID; hLang:int) : int; stdcall; external AppDll; +function Colour_Get(pGroup,pName:pAnsiChar) : longint; stdcall; external AppDll; ////////////////////////////////////////////////////////////////////////// // @@ -225,19 +197,6 @@ type TEffectIDW = EffectIDW_tag; const -// register an effect -// wparam = (EffectID *)&effect_id -// lparam = hLangpack - MS_EFFECT_REGISTERA:PAnsiChar = 'Effect/Register'; - MS_EFFECT_REGISTERW:PAnsiChar = 'Effect/RegisterW'; - -// get a effect -// wparam = (EffectID *)&effect_id (only name and group matter) -// lparam = (FONTEFFECT *)&effect -// rerturns 0, or -1 if not found - MS_EFFECT_GET :PAnsiChar = 'Effect/Get'; - MS_EFFECT_GETW:PAnsiChar = 'Effect/GetW'; - // fired when a user modifies font settings, so reget your fonts and colours // wparam = lparam = 0 ME_EFFECT_RELOAD:PAnsiChar = 'Effect/Reload'; diff --git a/include/delphi/m_helpers.inc b/include/delphi/m_helpers.inc index 62bdd92c10..f923dcc8d9 100644 --- a/include/delphi/m_helpers.inc +++ b/include/delphi/m_helpers.inc @@ -60,14 +60,8 @@ function Skin_AddIcon(si:PSKINICONDESC):THANDLE; procedure Icon_Register (hInst:HINST; const szSection:PAnsiChar; pIcons:pIconItem ; iCount:size_t; prefix:PAnsiChar); procedure Icon_RegisterW(hInst:HINST; const szSection:PWideChar; pIcons:pIconItemW; iCount:size_t; prefix:PAnsiChar); -procedure FontRegister (pFontID:pFontID); -procedure FontRegisterW(pFontID:pFontIDW); - -procedure ColourRegister (pColorID:pColourID); -procedure ColourRegisterW(pColorID:pColourIDW); - -procedure EffectRegister (pEffectID:pEffectID); -procedure EffectRegisterW(pEffectID:pEffectIDW); +procedure FontRegister(pFontID:pFontID); +procedure ColourRegister(pColorID:pColourID); function TopToolbar_AddButton(pButton:PTTBButton):THANDLE; @@ -421,29 +415,12 @@ end; procedure FontRegister(pFontID:pFontID); begin - CallService(MS_FONT_REGISTERA, WPARAM(pFontID), hLangpack); -end; -procedure FontRegisterW(pFontID:pFontIDW); -begin - CallService(MS_FONT_REGISTERW, WPARAM(pFontID), hLangpack); + Font_Register(pFontID, hLangpack); end; procedure ColourRegister(pColorID:pColourID); begin - CallService(MS_COLOUR_REGISTERA, WPARAM(pColorID), hLangpack); -end; -procedure ColourRegisterW(pColorID:pColourIDW); -begin - CallService(MS_COLOUR_REGISTERW, WPARAM(pColorID), hLangpack); -end; - -procedure EffectRegister(pEffectID:pEffectID); -begin - CallService(MS_EFFECT_REGISTERA, WPARAM(pEffectID), hLangpack); -end; -procedure EffectRegisterW(pEffectID:pEffectIDW); -begin - CallService(MS_EFFECT_REGISTERW, WPARAM(pEffectID), hLangpack); + Colour_Register(pColorID, hLangpack); end; function TopToolbar_AddButton(pButton:PTTBButton):THANDLE; diff --git a/include/m_fontservice.h b/include/m_fontservice.h index ad89aeab34..022e03e140 100644 --- a/include/m_fontservice.h +++ b/include/m_fontservice.h @@ -93,30 +93,26 @@ struct FontIDW }; // register a font -// wparam = (FontID *)&font_id -// lparam = hLangpack - extern int hLangpack; -__forceinline void FontRegister(FontID* pFontID) -{ - CallService("Font/Register", (WPARAM)pFontID, hLangpack); -} - -__forceinline void FontRegisterW(FontIDW* pFontID) -{ - CallService("Font/RegisterW", (WPARAM)pFontID, hLangpack); -} +EXTERN_C MIR_APP_DLL(int) Font_Register(FontID *pFont, int = hLangpack); +EXTERN_C MIR_APP_DLL(int) Font_RegisterW(FontIDW *pFont, int = hLangpack); // get a font // will fill the logfont structure passed in with the user's choices, or the default if it was set and the user has not chosen a font yet, // or the global default font settings otherwise (i.e. no user choice and default set, or font not registered) // global default font is gotten using SPI_GETICONTITLELOGFONT, color COLOR_WINDOWTEXT, size 8. -// wparam = (FontID *)&font_id (only name and group matter) -// lParam = (LOGFONT *)&logfont // returns the font's colour -#define MS_FONT_GET "Font/Get" -#define MS_FONT_GETW "Font/GetW" + +EXTERN_C MIR_APP_DLL(COLORREF) Font_Get(const char *szGroup, const char *szName, LOGFONTA *pFont); +EXTERN_C MIR_APP_DLL(COLORREF) Font_GetW(const wchar_t *wszGroup, const wchar_t *wszName, LOGFONTW *pFont); + +__forceinline COLORREF Font_Get(FontID &p, LOGFONTA *pFont) +{ return Font_Get(p.group, p.name, pFont); +} +__forceinline COLORREF Font_GetW(FontIDW &p, LOGFONTW *pFont) +{ return Font_GetW(p.group, p.name, pFont); +} // fired when a user modifies font settings, so reload your fonts // wparam = lparam = 0 @@ -162,24 +158,17 @@ struct ColourIDW // register a colour (this should be used for everything except actual text colour for registered fonts) // [note - a colour with name 'Background' [translated!] has special meaning and will be used as the background colour of // the font list box in the options, for the given group] -// wparam = (ColourID *)&colour_id -// lparam = hLangpack -__forceinline void ColourRegister(ColourID* pColorID) -{ - CallService("Colour/Register", (WPARAM)pColorID, hLangpack); -} - -__forceinline void ColourRegisterW(ColourIDW* pColorID) -{ - CallService("Colour/RegisterW", (WPARAM)pColorID, hLangpack); -} +EXTERN_C MIR_APP_DLL(int) Colour_Register(ColourID *pFont, int = hLangpack); +EXTERN_C MIR_APP_DLL(int) Colour_RegisterW(ColourIDW *pFont, int = hLangpack); // get a colour -// wparam = (ColourID *)&colour_id (only name and group matter) -// rerturns the colour (as COLORREF), or -1 if not found -#define MS_COLOUR_GET "Colour/Get" -#define MS_COLOUR_GETW "Colour/GetW" +EXTERN_C MIR_APP_DLL(COLORREF) Colour_Get(const char *szGroup, const char *szName); +EXTERN_C MIR_APP_DLL(COLORREF) Colour_GetW(const wchar_t *wszGroup, const wchar_t *wszName); + +__forceinline COLORREF Colour_GetW(ColourIDW &p) +{ return Colour_GetW(p.group, p.name); +} // fired when a user modifies font settings, so reget your fonts and colours // wparam = lparam = 0 @@ -230,22 +219,16 @@ struct EffectIDW // wparam = (EffectID *)&effect_id // lparam = 0 -__forceinline void EffectRegister(EffectID* pEffectID) -{ - CallService("Effect/Register", (WPARAM)pEffectID, hLangpack); -} - -__forceinline void EffectRegisterW(EffectIDW* pEffectID) -{ - CallService("Effect/RegisterW", (WPARAM)pEffectID, hLangpack); -} +EXTERN_C MIR_APP_DLL(int) Effect_Register(EffectID *pEffect, int = hLangpack); +EXTERN_C MIR_APP_DLL(int) Effect_RegisterW(EffectIDW *pEffect, int = hLangpack); // get a effect // wparam = (EffectID *)&effect_id (only name and group matter) // lparam = (FONTEFFECT *)&effect // rerturns 0, or -1 if not found -#define MS_EFFECT_GET "Effect/Get" -#define MS_EFFECT_GETW "Effect/GetW" + +EXTERN_C MIR_APP_DLL(int) Effect_Get(const char *szGroup, const char *wszName, FONTEFFECT *pEffect); +EXTERN_C MIR_APP_DLL(int) Effect_GetW(const wchar_t *wszGroup, const wchar_t *szName, FONTEFFECT *pEffect); // fired when a user modifies font settings, so reget your fonts and colours // wparam = lparam = 0 -- cgit v1.2.3