SharpThemeAPI Library
The global library for getting informations about the currently loaded theme is Sharpthemeapi.dll
To use SharpThemeAPI in any project just include the SharpThemeAPI.pas header file in your project
DLL header file: svn\common\libraries\SharpThemeApi\SharpThemeApi.pas
The SharpThemeAPI.dll library will load the current theme informations into a record stored in the memory of the dll. This means that if an application like SharpBar? is using SharpThemeAPI.dll then all other dll files (modules, ...) which are used by this application are using the same instance of this dll file. So if the theme changes the host application (example: SharpBar?) will reload the theme using SharpThemeAPI.dll and all modules will receive the updated theme informations the next time the Sharpthemeapi.dll file is used because host application(SharpBar?) and all other dlls(Modules) are sharing the same SharpThemeAPI.dll. Keep this in mind to reduce unnecessary reloading of the theme data.
The data record of SharpThemeAPI can not be access directly. To access the theme informations several data gathering functions are exported by the dll.
For applications like SharpBar? or SharpDesk? it should be safe to assume that the theme data for any module/object/plugin is always kept up to date by the host application. This means that it should not be necessary to reload the theme out of any module/object/plugin.
Initializing and Loading a Theme
When using Sharpthemeapi for the first time it's important that the data record of the dll is properly initialized. So make sure to check the initialized property of the dll before loading a theme for the first time.
if not SharpThemeApi.Initialized then SharpThemeApi.InitializeTheme;
After this has been done one time in a project (most likely at startup) the LoadTheme functions can be used.
Loading a theme can be done in different ways:
function LoadTheme(pName: PChar; ForceReload: Boolean = False; ThemeParts : TThemeParts = ALL_THEME_PARTS) : boolean; function LoadTheme(ForceReload: Boolean = False; ThemeParts : TThemeParts = ALL_THEME_PARTS) : boolean;
If no Name parameter is specified the current theme will loaded (updated).
The Forcereload parameter can be used to ignore the reload block of the dll (it is only possible to reload the theme settings one time in a second).
By using the Themeparts parameter it is possible to specify which parts of the theme will be loaded. The ALL_THEME_PARTS paramter means that the complete theme is going to be loaded. However if you only need certain informations of theme like then make sure to leave those theme parts out which you do not need.
The Themeparts parameter can be a set of: tpSkin,tpScheme,tpInfo,tpIconSet,tpDesktopIcon,tpDesktopAnimation.
Example calls:
LoadTheme(); // Reload the current Theme, no ForceReload, load ALL_THEME_PARTS LoadTheme(False,[tpSkin,tpScheme]); // Reload the current Theme, no ForceReload, load/update only the Skin and Scheme settings
Exported Functions
Global Data
function GetCurrentSharpEThemeName : PChar;
Theme Informations
function GetThemeName: PChar; function GetThemeAuthor: PChar; function GetThemeComment: PChar; function GetThemeWebsite: PChar; function GetThemeDirectory: PChar; function GetThemeDirectory(pName : PChar): PChar;
Color Scheme
The scheme color functions can be used to access the current theme color settings
There are two different function types. The data gathering functions are used to just return the scheme data. Therefore two new records are defined for those functions.
TSharpESkinColor = record Name: string; Tag: string; Info: string; Color: integer; end; TSharpEColorSet = array of TSharpESkinColor; function GetSchemeColorSet(pSet : integer) : TSharpEColorSet; function GetSchemeName : PChar; function GetSchemeColorCount: Integer; function GetSchemeColorByIndex(pIndex: integer): TSharpESkinColor; function GetSchemeColorIndexByTag(pTag: string): Integer; function GetSchemeColorByTag(pTag: string): TSharpESkinColor; function GetSchemeDirectory : PChar;
There are also some tool functions exported to make using the color schemes easier.
The SchemeCodeToColor? and ColorToSchemeCode? functions can be used to convert any integer color to a color code which can be saved to xml. Those functions are comparing the given color to all current scheme colors and if the color is indeed a scheme color then it will be converted to a negative index value.
The ParseColor? function can be used to parse any color string into the color integer value. Color strings can be RGB(128,64,0) for example.
function ColorToSchemeCode(pColor : integer) : integer; function SchemeCodeToColor(pCode : integer) : integer; function ParseColor(AColorStr:PChar):Integer;
Skin Data
function GetSkinName : PChar; function GetSkinColorCount : integer function GetSkinColor(pIndex : integer) : TSharpESkinColor; function GetSkinDirectory : PChar; function GetSkinGEBlurRadius : integer; // glass effect params function GetSkinGEBlurIterations : integer; function GetSkinGEBlend : boolean; function GetSkinGEBlendColor : integer; function GetSkinGEBlendAlpha : integer; function GetSkinGELighten : boolean; function GetSkinGELightenAmount : integer;
Icon Set
TSharpEIcon = record FileName: string; Tag: string; end; function GetIconSetName : PChar; function GetIconSetAuthor : PChar; function GetIconSetWebsite : PChar; function GetIconSetDirectory : PChar; function GetIconSetIconsCount : integer; function GetIconSetIcon(pIndex : integer) : TSharpEIcon; function GetIconSetIcon(pTag : PChar) : TSharpEIcon; function IsIconInIconSet(pTag : PChar) : boolean;
Desktop Icon Settings
function GetDesktopIconSize : integer; function GetDesktopIconAlphaBlend : boolean; function GetDesktopIconAlpha : integer; function GetDesktopIconBlending : boolean; function GetDesktopIconBlendColor : integer; function GetDesktopIconBlendAlpha : integer; function GetDesktopIconShadow : boolean; function GetDesktopIconShadowColor : integer; function GetDesktopIconShadowAlpha : integer; function GetDesktopFontName : PChar; function GetDesktopDisplayText : boolean; function GetDesktopTextSize : integer; function GetDesktopTextBold : boolean; function GetDesktopTextItalic : boolean; function GetDesktopTextUnderline : boolean; function GetDesktopTextColor : integer; function GetDesktopTextAlpha : boolean; function GetDesktopTextAlphaValue : integer; function GetDesktopTextShadow : boolean; function GetDesktopTextShadowAlpha : integer; function GetDesktopTextShadowColor : integer; function GetDesktopTextShadowType : integer; function GetDesktopTextShadowSize : integer;
Desktop Animation Settings
function GetDesktopAnimUseAnimations : boolean; function GetDesktopAnimScale : boolean; function GetDesktopAnimScaleValue : integer; function GetDesktopAnimAlpha : boolean; function GetDesktopAnimAlphaValue : integer; function GetDesktopAnimBlend : boolean; function GetDesktopAnimBlendValue : integer; function GetDesktopAnimBlendColor : integer; function GetDesktopAnimBrightness : boolean; function GetDesktopAnimBrightnessValue : integer;
