You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
RnQ/for.RnQ/RQThemes.pas

4776 lines
134 KiB
Plaintext

{
This file is part of RaDIuM.
Under same license
}
unit RQThemes;
{$I NoRTTI.inc}
{$I ForRnQConfig.inc}
{ $DEFINE RQDEBUG2 }
{ $DEFINE USE_32Aplha_Images }
{ $DEFINE NOT_USE_GDIPLUS }
{$WRITEABLECONST OFF} // Read-only typed constants
interface
uses
Windows, Forms, SysUtils, Classes, Graphics,
{$IFNDEF NOT_USE_GDIPLUS}
GDIPAPI,
GDIPOBJ,
RnQGraphics,
{$ELSE}
RnQGraphics32,
{$ENDIF NOT_USE_GDIPLUS}
RDGlobal,
// ImgList,
{$IFDEF RNQ_FULL}
{$IFNDEF andRQ}
// RnQAni,
// Controls,
ExtCtrls, SyncObjs,
{$ENDIF andRQ}
{$ENDIF RNQ_FULL}
{$IFDEF UNICODE}
AnsiClasses,
{$ENDIF UNICODE}
Generics.Collections,
{$IFDEF USE_ZIP}
// kazip,
// VCLUnZip,
// SXZipUtils,
RnQZip,
{$ENDIF USE_ZIP}
{$IFDEF USE_RAR}
// ztvUnRar,
UnRAR,
{$ENDIF USE_RAR}
{$IFDEF USE_7Z}
SevenZip,
{$ENDIF USE_7Z}
RDFileUtil,
GR32, GR32_backends;
{$I NoRTTI.inc}
type
TRnQAni = TRnQBitmap;
TRnQThemedElement = (RQteDefault, RQteButton, RQteMenu, RQteTrayNotify, RQteFormIcon);
const
TE2Str: array [TRnQThemedElement] of TPicName = ('', 'button.', 'menu.', 'tray.', 'formicon.');
type
TPicLocation = (PL_pic, PL_icon, PL_int, PL_Ani, PL_Smile);
TthemePropertyKind = (TP_font, TP_color, TP_file, TP_pic, TP_ico, TP_string, TP_sound, TP_smile);
// PRnQThemedElementDtls = ^TRnQThemedElementDtls;
TRnQThemedElementDtls = record
ThemeToken: Integer;
Loc: TPicLocation;
picIdx: Integer;
picName: TPicName;
Element: TRnQThemedElement;
pEnabled: Boolean;
end;
type
TSmlObj = class(TObject)
public
SmlStr: TStringList;
Animated: Boolean;
AniIdx: Integer;
end;
TSndObj = class(TObject)
public
str: String;
s3m: TMemoryStream;
end;
TPicObj = class(TObject)
public
// TPicObj = record
bmp: TRnQBitmap;
// bmp : TGPImage;
ref: Integer;
// AniIdx : Integer;
end;
const
FPT_CHARSET = 1 shl 0;
FPT_SIZE = 1 shl 1;
FPT_COLOR = 1 shl 2;
FPT_STYLE = 1 shl 3;
FPT_NAME = 1 shl 4;
// FPT_UNK
{ TFontPropsTypes = (FPT_CHARSET, FPT_SIZE, FPT_COLOR, FPT_STYLE, FPT_NAME, FPT_UNK);
TFontProps = record
fpType : TFontPropsTypes;
case TFontPropsTypes of
FPT_CHARSET: (charset : Integer);
FPT_SIZE: (size : Integer);
FPT_COLOR: (color : Cardinal);
FPT_STYLE: (style : set of TFontStyle);
FPT_NAME: (name : PAnsiChar);
// end;
end;
}
type
TFontObj = class(TObject)
protected
flags: byte;
charset: Integer;
size: Integer;
color: Cardinal;
style: set of TFontStyle;
name: PChar;
public
constructor Create;
destructor Destroy; override;
function Clone: TFontObj;
end;
{$IFDEF RNQ_FULL}
TThemePic = class(TObject)
public
picIdx: Integer;
// Name : String;
r: TGPRect;
isWholeBig: Boolean;
// constructor Create;
// destructor Destroy; override;
// procedure SetPicIDX(idx : Integer);
// property PicIDX : Integer read FPicIDX write SetPicIDX;
// Left, Top : Integer;
// Width, Height : Integer;
// bmp : TRnQBitmap;
end;
TAniPicParams = record
// Name : String;
IDX: Integer;
SmileIDX: Integer;
// Bounds: TRect;
Bounds: TGPRect;
{$IFDEF NOT_USE_GDIPLUS}
color: TColor;
{$ELSE NOT_USE_GDIPLUS}
color: Cardinal;
// DC : HDC;
{$ENDIF NOT_USE_GDIPLUS}
Canvas: TCanvas;
selected: Boolean;
// bg : TRnQBitmap;
// Count: Integer;
end;
TAniSmileParamsArray = array of TAniPicParams;
{$ENDIF RNQ_FULL}
TThemeSubClass = (tsc_all, tsc_pics, tsc_smiles, tsc_sounds);
// Pthemeinfo=^Tthemeinfo;
ToThemeinfo = Class(TObject)
public
// Tthemeinfo=record
fn, subFile, title, desc, logo: string;
Ver: byte;
end;
aThemeInfo = array of ToThemeinfo;
PTthemeProperty = ^TthemeProperty;
TthemeProperty = record
// section : String;
section: AnsiString;
name: TPicName;
kind: TthemePropertyKind;
// ptr:pointer;
end;
aTthemeProperty = array of TthemeProperty;
{$IFDEF UNICODE}
TObjList = TAnsiStringList;
{$ELSE ~UNICODE}
TObjList = TStringList;
{$ENDIF UNICODE}
TFontList = TDictionary;
type
TRQtheme = class
private
curToken: Integer;
{ $IFDEF NOT_USE_GDIPLUS }
// Fpics : TObjList;
{ $ELSE USE_GDIPLUS }
// FBigPics : TObjList;
// FSmileBigPics : TObjList;
// FFonts : TFontList;
FBigPics, FSmileBigPics: array of TPicObj;
FThemePics, FSmilePics,
// FGPpics : ThaStringList;
{ $ENDIF NOT_USE_GDIPLUS }
// FFonts : TObjList;
FFonts2, FClr, FStr, FSmiles, FSounds, FIntPics: TObjList;
FIntPicsIL: THandle;
{$IFDEF RNQ_FULL}
FAniSmls: TObjList;
// FAniPics: TObjList;
// FAniSmls: TStrListEx;
FAniParamList: TAniSmileParamsArray;
FAniDrawCnt: Integer;
FAniTimer: TTimer;
FdrawCS: TCriticalSection;
{$ENDIF RNQ_FULL}
// addProp : procedure (name:string;kind:TthemePropertyKind; s: String);
procedure addProp(name: TPicName; ts: TThemeSourcePath; kind: TthemePropertyKind; const s: String); overload;
// procedure addProp(name:string; ico: TIcon); overload;
// procedure addProp(name:string; fnt: TFont); overload;
procedure addProp(const pName: TPicName; fnt: TFontObj); overload;
// procedure addprop(name:string; fnt: TFontProps); overload;
procedure addProp(const name: TPicName; c: TColor); overload;
procedure addProp(const name: TPicName; const SmlCaption: String; Smile: TRnQBitmap; var pTP: TThemePic;
bStretch: Boolean = false; Ani: Boolean = false; AniIdx: Integer = -1); overload;
// function GetIco2(name : String; ico : TIcon) : Boolean;
{$IFNDEF NOT_USE_GDIPLUS}
function GetPic13(name: TPicName; var pic: TGPImage; AddPic: Boolean = True): Boolean;
{$ENDIF NOT_USE_GDIPLUS}
function GetSmlCnt: Integer;
// procedure GetPic(name : String; var pic : TRnQBitmap); overload;
{$IFDEF RNQ_FULL}
procedure TickAniTimer(Sender: TObject);
{$ENDIF RNQ_FULL}
public
ThemePath: TThemePath;
// MasterFN, subfn :string;
// fs : TPathType;
// fs : TThemeSourcePath;
// path : String;
title, desc: string;
useTSC: TThemeSubClass;
// supSmiles : Boolean;
{$IFDEF RNQ_FULL}
useAnimated: Boolean;
// Anipicbg : Boolean;
AnibgPic: TBitmap32;
{$ENDIF RNQ_FULL}
// logo:TRnQBitmap;
themelist2: aThemeInfo;
smileList: aThemeInfo;
soundList: aThemeInfo;
fBasePath: String;
procedure Debug;
constructor Create;
destructor Destroy; override;
procedure Clear(pTSC: TThemeSubClass);
procedure FreeResource;
procedure load(fn0: string; subFile: String = ''; loadBase: Boolean = True; subClass: TThemeSubClass = tsc_all);
procedure loadThemeScript(const fn: string; const path: string); overload;
procedure loadThemeScript(fn: string; ts: TThemeSourcePath); overload;
private
function addBigPic(var pBmp: TRnQBitmap): Integer;
function addBigSmile(var pBmp: TRnQBitmap): Integer;
// procedure addprop(name:string;hi: HICON; Internal : Boolean = false); overload;
function addProp(const name: TPicName; kind: TthemePropertyKind; var pBmp: TRnQBitmap): Integer; overload;
procedure addProp(const name: TPicName; kind: TthemePropertyKind; var pic: TThemePic); overload;
// procedure delProp(name:String;kind:TthemePropertyKind);
{$IFDEF RNQ_FULL}
function addProp(name: AnsiString; pic: TRnQAni): Integer; overload;
// function addProp(name:string; pic: TRnQBitmap) : Integer; overload;
{$ENDIF RNQ_FULL}
public
procedure addHIco(const name: TPicName; hi: HICON; Internal: Boolean = false);
{$IFDEF NOT_USE_GDIPLUS}
function GetBrush(name: TPicName): HBRUSH;
{$ENDIF NOT_USE_GDIPLUS}
// procedure initPic(name : String; var ThemeToken : Integer;
// var picLoc : TPicLocation; var picIdx : Integer); overload;
procedure initPic(var picElm: TRnQThemedElementDtls); overload;
function GetPicSize(pTE: TRnQThemedElement; const name: TPicName; minSize: Integer = 0): Tsize; overload;
// function GetPicSize(name : String; var ThemeToken : Integer;
// var picLoc : TPicLocation; var picIdx : Integer; minSize : Integer = 0):Tsize; overload;
function GetPicSize(var picElm: TRnQThemedElementDtls; minSize: Integer = 0): Tsize; overload;
function GetPicOld(const picName: TPicName; pic: TBitmap32; AddPic: Boolean = True): Boolean;
// function GetIcoBad(name : String) : TIcon;
function GetString(const name: TPicName; isAdd: Boolean = True): String;
function GetSound(const name: TPicName): String;
function PlaySound(const name: TPicName): Boolean;
// procedure ApplyFont(name : String; var fnt : TFont); overload;
procedure ApplyFont(const pName: TPicName; fnt: TFont);
// function GetFontProp(name : String; Prop : TFontPropsTypes) : TFontProps;
function GetFontName(const pName: TPicName): String;
function GetColor(const name: TPicName; pDefColor: TColor = clDefault): TColor;
function GetAColor(const name: TPicName; pDefColor: Integer = clDefault): Cardinal;
function GetTColor(const name: TPicName; pDefColor: Cardinal): Cardinal;
{$IFNDEF NOT_USE_GDIPLUS}
// function pic2ico2(picName:String; ico:Ticon) : Boolean;
{$ENDIF NOT_USE_GDIPLUS}
function pic2ico(pTE: TRnQThemedElement; const picName: TPicName; ico: Ticon): Boolean;
function pic2hIcon(const picName: TPicName; var ico: HICON): Boolean;
// function drawPic(cnv:Tcanvas; x,y:integer; pic:TRnQBitmap):Tsize; overload;
function drawPic(DC: HDC; pX, pY: Integer; const picName: TPicName; pEnabled: Boolean = True): Tsize; overload;
// function drawPic(DC: HDC; x,y:integer; picName:string; var ThemeToken : Integer;
// var picLoc : TPicLocation; var picIdx : Integer; pEnabled : Boolean = true):Tsize; overload;
// function drawPic(DC: HDC; x,y:integer; var picElm : TRnQThemedElementDtls):Tsize; overload;
function drawPic(DC: HDC; pR: TGPRect; const picName: TPicName; pEnabled: Boolean = True): Tsize; overload;
function drawPic(DC: HDC; p: TPoint; var picElm: TRnQThemedElementDtls): Tsize; overload;
function drawPic(DC: HDC; pR: TGPRect; var picElm: TRnQThemedElementDtls): Tsize; overload;
function getPic(DC: HDC; p: TPoint; var picElm: TRnQThemedElementDtls; var is32Alpha: Boolean): Tsize; overload;
{$IFNDEF NOT_USE_GDIPLUS}
function drawPic(gr: TGPGraphics; x, y: Integer; picName: string; pEnabled: Boolean = True): Tsize; overload;
function drawPic(gr: TGPGraphics; x, y: Integer; picName: string; var ThemeToken: Integer; var picLoc: TPicLocation;
var picIdx: Integer; pEnabled: Boolean = True): Tsize; overload;
function drawPic(gr: TGPGraphics; x, y: Integer; picElm: Prnq): Tsize; overload;
{$ENDIF NOT_USE_GDIPLUS}
// function GetPicRGN(picName:string; var ThemeToken : Integer;
// var picLoc : TPicLocation; var picIdx : Integer):HRGN;
// function drawPic(cnv:Tcanvas; x,y:integer; picName:String):Tsize; overload;
function GetSmileName(i: Integer): TPicName;
function GetSmileObj(i: Integer): TSmlObj;
procedure checkAnimationTime;
{$IFDEF RNQ_FULL}
function GetAniPic(IDX: Integer): TRnQAni;
procedure AddAniParam(picIdx: Integer; Bounds: TGPRect; color: TColor; cnv, cnvSrc: TCanvas; Sel: Boolean = false);
procedure ClearAniParams;
procedure ClearAniMNUParams;
{$ENDIF RNQ_FULL}
Property SmilesCount: Integer read GetSmlCnt;
Property token: Integer read curToken;
{$IFNDEF RNQ_LITE}
procedure getprops(var PropList: aTthemeProperty);
{$ENDIF RNQ_LITE}
procedure initThemeIcons;
{$IFNDEF NOT_USE_GDIPLUS}
procedure drawTiled(gr: TGPGraphics; r: TGPRectF; const picName: TPicName); overload;
procedure drawStratch(gr: TGPGraphics; r: TGPRectF; const picName: TPicName); overload;
procedure drawStratch(gr: TGPGraphics; x, y, w, h: Integer; const picName: TPicName); overload;
{$ENDIF NOT_USE_GDIPLUS}
procedure drawTiled(Canvas: TCanvas; const picName: TPicName); overload;
procedure drawTiled(DC: HDC; ClipRect: TRect; const picName: TPicName); overload;
procedure Draw_wallpaper(DC: HDC; r: TRect); // inline;
procedure refreshThemeList;
// procedure refreshSmilesList;
procedure ClearThemelist;
end;
// function TE2Str(pTE : TRnQThemedElement) : TPicName;
const
// theme_def_file = 'RnQ.theme.ini';
PIC_EMPTY = TPicName('empty');
PIC_HISTORY = TPicName('history'); // 51;
PIC_WALLPAPER = TPicName('wallpaper'); // 69;
PIC_CURRENT = TPicName('current');
// PIC_WARNING = 'warning';
// PIC_ERROR = 'error';
var
theme: TRQtheme;
implementation
uses
strUtils,
math,
{$IFDEF UNICODE}
AnsiStrings,
{$ENDIF UNICODE}
RDUtils,
RnQGlobal, RnQLangs,
RQUtil,
{$IFDEF RNQ}
RQlog,
{$ENDIF RNQ}
RnQDialogs,
CommCtrl, mmSystem, Types;
type
// Tsection=(_null,_roaster,_tip,_pics,_icons,_history,_smiles,_sounds,_menu);
TRQsection = (_null, _pics, _icons, _smiles, _sounds, _ico, _smile, _str, _desc, _fontfile);
const
// sectionLabels:array [Tsection] of string=('','roaster','tip','pics','icons',
// 'history','smiles','sounds','menu');
RQsectionLabels: array [TRQsection] of AnsiString = ('', 'pics', 'icons', 'smiles', 'sounds', 'rnqpics', 'rnqsmiles', 'strings',
'desc', 'font');
{$IFDEF USE_7Z}
const
SevenZipThemes: array [0 .. 2] of string = ('.7z', '.7zip', '.rt7');
{$ENDIF USE_7Z}
{$IFDEF USE_RAR}
const
RARThemes: array [0 .. 1] of string = ('.rar', '.rtr');
{$ENDIF USE_RAR}
{$IFDEF USE_ZIP}
const
ZipThemes: array [0 .. 1] of string = ('.zip', '.rtz');
ThemeInis: array [0 .. 2] of string = ('theme.ini', 'smiles.ini', 'sounds.ini');
{$ENDIF USE_ZIP}
function MakeRectI(x, y, width, height: Integer): TGPRect; inline;
begin
Result.x := x;
Result.y := y;
Result.width := width;
Result.height := height;
end;
procedure InitThemePath(var ts: TThemeSourcePath; fn: String);
var
fn_Ext: String;
begin
fn_Ext := AnsiLowerCase(ExtractFileExt(fn));
{$IFDEF USE_ZIP}
if (fn_Ext = '.rtz') or (fn_Ext = '.zip') then
begin
// fs := pt_zip;
ts.pathType := pt_zip;
ts.path := '';
ts.ArcFile := fn;
{ ts.zp := TZipFile.Create;
try
ts.zp.LoadFromFile(Fn);
except
ts.zp.Free;
ts.zp := NIL;
end;
end; }
end
else
{$ENDIF USE_ZIP}
{$IFDEF USE_7Z}
if (SevenZipThemes[0] = fn_Ext) or (SevenZipThemes[1] = fn_Ext) or (SevenZipThemes[2] = fn_Ext) then
begin
// fs := pt_7z;
ts.pathType := pt_7z;
ts.path := '';
ts.ArcFile := fn;
end
else
{$ENDIF USE_7Z}
{$IFDEF USE_RAR}
if (RARThemes[0] = fn_Ext) or (RARThemes[1] = fn_Ext) then
begin
// fs := pt_7z;
ts.pathType := pt_rar;
ts.path := '';
ts.ArcFile := fn;
ts.RarHnd := 0;
end
else
{$ENDIF USE_7Z}
begin
ts.pathType := pt_path;
ts.path := ExtractFileDir(fn);
ts.path := includeTrailingPathDelimiter(ts.path);
ts.ArcFile := '';
end;
end;
constructor TFontObj.Create;
begin
inherited;
flags := 0;
// pr
name := NIL;
// if StrLen(name)>0 then
// StrDispose(name);
// SetLength(prop, 0);
end;
destructor TFontObj.Destroy;
// var
// I: Integer;
begin
if name <> NIL then
StrDispose(name);
name := NIL;
// for I := 0 to Length(prop) - 1 do
// if Self.prop[i].fpType = FPT_NAME then
// StrDispose(prop[i].name);
// SetLength(prop, 0);
end;
function TFontObj.Clone: TFontObj;
begin
Result := TFontObj.Create;
Result.flags := flags;
if FPT_CHARSET and flags > 0 then
begin
Result.flags := Result.flags or FPT_CHARSET;
Result.charset := charset;
end;
// else
// Result.flags := Result.flags and not FPT_CHARSET;
if FPT_SIZE and flags > 0 then
begin
Result.flags := Result.flags or FPT_SIZE;
Result.size := size;
end;
// else
// Result.flags := Result.flags and not FPT_SIZE;
if FPT_COLOR and flags > 0 then
begin
Result.flags := Result.flags or FPT_COLOR;
Result.color := color;
end;
// else
// Result.flags := Result.flags and not FPT_COLOR;
if FPT_STYLE and flags > 0 then
begin
Result.flags := Result.flags or FPT_STYLE;
Result.style := style;
end;
// else
// Result.flags := Result.flags and not FPT_STYLE;
if FPT_NAME and flags > 0 then
begin
Result.flags := Result.flags or FPT_NAME;
StrDispose(Result.name);
{$IFDEF UNICODE}
// Result.Name := AnsiStrAlloc(StrLen(name)+1);
Result.name := StrAlloc(StrLen(name) + 1);
{$ELSE nonUNICODE}
Result.name := StrAlloc(StrLen(name) + 1);
{$ENDIF UNICODE}
StrCopy(Result.name, name);
end;
// else
// begin
// TFontObj(FFonts2.Objects[i]).flags := TFontObj(FFonts2.Objects[i]).flags and not FPT_NAME;
// StrDispose(TFontObj(FFonts2.Objects[i]).Name);
// end;
end;
{ constructor TThemePic.Create;
begin
inherited;
FPicIDX := -1;
end;
destructor TThemePic.Destroy;
begin
inherited;
end;
procedure TThemePic.SetPicIDX(idx : Integer);
begin
// if FPicIDX >=0 then
// if Assigned(f) then
end;
}
procedure TRQtheme.Debug;
begin
{$IFDEF RQDEBUG2}
Fpics.SaveToFile('FPics');
FFonts.SaveToFile('FFonts');
// FIcons.SaveToFile('FIcons');
FIPNames.SaveToFile('FIcons');
FStr.SaveToFile('FStr');
FSmiles.SaveToFile('FSmiles');
FClr.SaveToFile('FClr');
FSounds.SaveToFile('FSounds');
FAniSmls.SaveToFile('FaniSmiles');
{$ENDIF}
end;
constructor TRQtheme.Create;
begin
curToken := 101;
FAniTimer := NIL;
useTSC := tsc_all;
// supSmiles := False;
FdrawCS := TCriticalSection.Create;
// FGPpics := TStringList.Create;
// FBigPics := TStringList.Create;
// FSmileBigPics := TStringList.Create;
FThemePics := TObjList.Create;
FSmilePics := TObjList.Create;
FIntPics := TObjList.Create;
FSmiles := TObjList.Create;
FStr := TObjList.Create;
FClr := TObjList.Create;
FSounds := TObjList.Create;
FFonts2 := TObjList.Create;
// FFonts := TFontList.Create;
FIntPicsIL := ImageList_Create(icon_size, icon_size, ILC_COLOR32 or ILC_MASK, 0, 0);
// FIconPics.BkColor := clNone;
FSmiles.CaseSensitive := True;
// FFonts := TStringList.Create;
{$IFDEF RNQ_FULL}
FAniSmls := TObjList.Create;
// FAniSmls := NewStrListEx^;
FSmiles.CaseSensitive := True;
FAniSmls.CaseSensitive := True;
// FSmiles.Sorted := True;
// FAniSmls.Sorted := True;
{$ENDIF RNQ_FULL}
AnibgPic := NIL;
initThemeIcons;
end;
destructor TRQtheme.Destroy;
begin
Clear(tsc_all);
// FGPpics.Free;
SetLength(ThemePath.fn, 0);
SetLength(ThemePath.subfn, 0);
// SetLength(title, 0);
// SetLength(desc, 0);
if Assigned(AnibgPic) then
AnibgPic.Free;
AnibgPic := NIL;
if Assigned(FAniTimer) then
FreeAndNil(FAniTimer);
// FBigPics.Free;
// FSmileBigPics.Free;
FSmilePics.Free;
FThemePics.Free;
FIntPics.Free;
ImageList_Destroy(FIntPicsIL);
FSmiles.Free;
// FFonts.Free;
FFonts2.Free;
FStr.Free;
FClr.Free;
FSounds.Free;
// FIntIPs.Free;
{$IFDEF RNQ_FULL}
FAniSmls.Free;
{$ENDIF RNQ_FULL}
FdrawCS.Free;
end;
procedure TRQtheme.Clear(pTSC: TThemeSubClass);
var
i: Integer;
po: TPicObj;
so: TSndObj;
begin
{ WITH FIntPics do
For i := 0 to Count-1 do
begin
TRnQBitmap(Objects[i]).Free;
end;
FIntPics.Clear; }
// <20><> <20><> <20><> <20><>
// ImageList_RemoveAll(FIntPicsIL);
// FIntPics.Clear;
if pTSC = tsc_all then
begin
SetLength(title, 0);
SetLength(desc, 0);
end;
if pTSC in [tsc_all, tsc_pics] then
begin
for i := 0 to FThemePics.Count - 1 do
begin
// TThemePic(FThemePics.Objects[i]);
TThemePic(FThemePics.Objects[i]).Free;
FThemePics.Objects[i] := NIL;
end;
FThemePics.Clear;
for po in FBigPics do
begin
if Assigned(po) then
begin
try
if Assigned(po.bmp) then
po.bmp.Free;
po.bmp := NIL;
except
end;
po.Free;
// FBigPics.Objects[i].Free;
// FBigPics.Objects[i] := NIL;
end;
end;
// FBigPics.Clear;
SetLength(FBigPics, 0);
{ WITH FGPpics do
For i := 0 to Count-1 do
begin
TRnQBitmap(Objects[i]).Free;
Objects[i] := nil;
end;
FGPpics.Clear;
}
// For i := 0 to FIcons.Count-1 do TIcon(FIcons.Objects[i]).Free;
// FFonts.Clear;
For i := 0 to FFonts2.Count - 1 do
begin
TFontObj(FFonts2.Objects[i]).Free;
end;
FFonts2.Clear;
For i := 0 to FStr.Count - 1 do
TStrObj(FStr.Objects[i]).Free;
FStr.Clear;
// For i := 0 to FClr.Count-1 do FClr.Objects[i].Free;
FClr.Clear;
end;
// if pTSC = tsc_smiles then
// add
if pTSC in [tsc_all, tsc_smiles] then
begin
For i := 0 to FSmiles.Count - 1 do
begin
// try
// TSmlObj(FSmiles.Objects[i]).Smile.Free;
// except
// end;
TSmlObj(FSmiles.Objects[i]).SmlStr.Clear;
TSmlObj(FSmiles.Objects[i]).SmlStr.Free;
TSmlObj(FSmiles.Objects[i]).Free;
// FSmiles.Objects[i] := NIL;
end;
FSmiles.Clear;
{$IFDEF RNQ_FULL}
For i := 0 to FAniSmls.Count - 1 do
// TRnQBitmap(FAniPics.Objects[i]).Free;
TRnQAni(FAniSmls.Objects[i]).Free;
// TRnQAni(Pointer(FAnismls.Objects[i])^).Free;
FAniSmls.Clear;
for i := 0 to FSmilePics.Count - 1 do
begin
// TThemePic(FSmilePics.Objects[i]).;
TThemePic(FSmilePics.Objects[i]).Free;
FSmilePics.Objects[i] := NIL;
end;
FSmilePics.Clear;
{ for I := 0 to FSmileBigPics.Count - 1 do
begin
with TPicObj(FSmileBigPics.Objects[i]) do
try
if Assigned(bmp) then
bmp.Free;
bmp := NIL;
except
end;
TPicObj(FSmileBigPics.Objects[i]).Free;
FSmileBigPics.Objects[i] := NIL;
end;
FSmileBigPics.Clear;
}
for po in FSmileBigPics do
begin
if Assigned(po) then
begin
try
if Assigned(po.bmp) then
po.bmp.Free;
po.bmp := NIL;
except
end;
po.Free;
end;
end;
// FBigPics.Clear;
SetLength(FSmileBigPics, 0);
if Assigned(AnibgPic) then
begin
// AnibgPic. := 0;
// AnibgPic.GetHeight := 0;
end;
{$ENDIF RNQ_FULL}
end;
if pTSC in [tsc_all, tsc_sounds] then
begin
if FSounds.Count > 0 then
SoundStop;
For i := 0 to FSounds.Count - 1 do
begin
so := TSndObj(FSounds.Objects[i]);
FSounds.Objects[i] := NIL;
if Assigned(so.s3m) then
FreeAndNil(so.s3m);
so.Free;
end;
FSounds.Clear;
end;
// FIntIPNames.Clear;
// FIntIPs.Clear;
// SetLength(smlList, 0);
// smlList:= nil;
end;
procedure TRQtheme.FreeResource;
var
i, k: Integer;
po: TPicObj;
// var
// i : Integer;
begin
for po in FBigPics do
begin
if Assigned(po) then
po.ref := 0;
end;
for i := 0 to FThemePics.Count - 1 do
begin
with TThemePic(FThemePics.Objects[i]) do
begin
if (picIdx < Length(FBigPics)) then
begin
inc(FBigPics[picIdx].ref);
if (r.x = 0) and (r.y = 0) and (FBigPics[picIdx].bmp.width = r.width) and (FBigPics[picIdx].bmp.height = r.height) then
isWholeBig := True; // ThemePic= BigPic
end
else
isWholeBig := false;
end;
end;
for po in FBigPics do
begin
if Assigned(po) then
if po.ref = 0 then
FreeAndNil(po.bmp);
end;
for po in FSmileBigPics do
begin
if Assigned(po) then
po.ref := 0;
end;
for i := 0 to FSmilePics.Count - 1 do
begin
k := TThemePic(FSmilePics.Objects[i]).picIdx;
if (k >= 0) and (k < Length(FSmileBigPics)) then
inc(FSmileBigPics[k].ref);
end;
for po in FSmileBigPics do
begin
if Assigned(po) then
if po.ref = 0 then
FreeAndNil(po.bmp);
end;
{ For i := 0 to Fpics.Count-1 do
begin
TRnQBitmap(FPics.Objects[i]).Dormant;
end;
For i := 0 to FSmiles.Count-1 do
begin
if TSmlObj(FSmiles.Objects[i]).Smile <> NIL then
TSmlObj(FSmiles.Objects[i]).Smile.Dormant;
end;
}
end;
procedure TRQtheme.load(fn0: string; subFile: String = ''; loadBase: Boolean = True; subClass: TThemeSubClass = tsc_all);
var
// path : string;
// f,
{$IFDEF USE_ZIP}
// baseArc : string;
baseThemePath: TThemePath;
{$ENDIF USE_ZIP}
s, fn_full, fn_Only, fn_Ext: String;
s1: String;
ts: TThemeSourcePath;
i: Integer;
begin
fn_Only := ExtractFileName(fn0);
if fn_Only = '' then
if not loadBase then
Exit
else
begin
// loggaEvt(getTranslation('Theme not selected'));
msgDlg('Theme not selected', True, mtError);
// Exit;
end;
s := ExtractFileDir(fn0);
if s > '' then
fn_full := fn0
else
fn_full := fBasePath + themesPath + fn_Only;
if (Length(fn_Only) > 0) and not FileExists(fn_full) then
begin
// loggaEvt(getTranslation('Can''t find theme %s',[fn]));
msgDlg(getTranslation('Can''t find theme %s', [fn_full]), false, mtError);
// self.fn := '';
subFile := '';
if subClass = tsc_all then
begin
ThemePath.fn := '';
// ThemePath.subfn := '';
end;
Exit;
end;
{$IFDEF RNQ_FULL}
if subClass in [tsc_all, tsc_smiles] then
begin
// UnInitGDIP;
// InitGDIP;
useAnimated := false;
if Assigned(AnibgPic) then
begin
AnibgPic.Free;
AnibgPic := NIL;
// Anipicbg := False;
end;
end;
{$ENDIF RNQ_FULL}
Clear(subClass);
ts.ArcFile := '';
{$IFDEF USE_ZIP}
ts.zp := NIL;
{$ENDIF USE_ZIP}
{$IFDEF USE_7Z}
ts.z7 := NIL;
{$ENDIF USE_7Z}
{$IFDEF USE_RAR}
ts.RarHnd := 0;
{$ENDIF USE_RAR}
if subClass = tsc_all then
ThemePath.fn := fn_Only;
if loadBase then
begin
{$IFDEF USE_ZIP}
// baseArc := mypath+themesPath+'RnQ.theme.rtz';
baseThemePath.pathType := pt_zip;
baseThemePath.fn := fBasePath + themesPath + 'RnQ.theme.rtz';
{$ENDIF USE_ZIP}
if not FileExists(fn_full) then
{$IFDEF USE_ZIP}
if FileExists(baseThemePath.fn) then
begin
fn_full := baseThemePath.fn;
fn_Only := 'RnQ.theme.rtz';
subFile := defaultThemePrefix + defaultThemePostfix;
end
else
{$ENDIF USE_ZIP}
begin
fn_full := fBasePath + themesPath + defaultThemePrefix + defaultThemePostfix;
fn_Only := defaultThemePrefix + defaultThemePostfix;
subFile := '';
end;
{$IFDEF USE_ZIP}
if FileExists(baseThemePath.fn) then
begin
// fs := pt_zip;
ts.pathType := pt_zip;
ts.path := '';
// ts.zp := TKAZip.Create(NIL);
ts.zp := TZipFile.Create;
// ts.zp.ReadOnly := True;
// ts.zp.Open(baseArc);
ts.zp.LoadFromFile(baseThemePath.fn);
end
else
{$ENDIF USE_ZIP}
begin
// fs := pt_path;
ts.pathType := pt_path;
ts.path := fBasePath + themesPath;
end;
loadThemeScript(defaultThemePrefix + 'Base.' + defaultThemePostfix, ts);
{$IFDEF USE_ZIP}
if (fn_full <> baseThemePath.fn) and Assigned(ts.zp) then
FreeAndNil(ts.zp);
{$ENDIF USE_ZIP}
end;
fn_Ext := ExtractFileExt(fn_Only);
InitThemePath(ts, fn_full);
case ts.pathType of
pt_path:
begin
subFile := fn_Only;
// subfn := '';
if subClass = tsc_all then
begin
// ThemePath.fn := '';
ThemePath.subfn := '';
end;
{$IFDEF USE_ZIP}
FreeAndNil(ts.zp);
{$ENDIF USE_ZIP}
{$IFDEF USE_7Z}
// FreeAndNil(ts.7z);
ts.z7 := NIL;
{$ENDIF USE_7Z}
end;
{$IFDEF USE_ZIP}
pt_zip:
begin
if subClass = tsc_all then
ThemePath.fn := fn_Only;
if (fn_full <> baseThemePath.fn) or not Assigned(ts.zp) then
begin
// ts.zp := TKAZip.Create(NIL);
ts.zp := TZipFile.Create;
// ts.zp.ReadOnly := True;
// ts.zp.Open(Fn);
try
ts.zp.LoadFromFile(fn_full);
except
ts.zp.Free;
ts.zp := NIL;
end;
end;
if subFile = '' then
begin
for i := 0 to ts.zp.Count - 1 do
begin
s1 := ts.zp.name[i];
if (LastDelimiter('\/:', s1) <= 0) and RnQEndsText('theme.ini', s1) then
begin
subFile := s1;
break;
end;
end;
end;
// else
// Self.fn := subFile;
if subClass = tsc_all then
ThemePath.subfn := subFile;
end;
{$ENDIF USE_ZIP}
{$IFDEF USE_7Z}
pt_7z:
begin
if subClass = tsc_all then
ThemePath.fn := fn_Only;
try
// ts.z7 := TSevenZip.Create(NIL);
ts.z7 := CreateInArchive(CLSID_CFormat7z);
except
ts.z7 := NIL;
end;
if Assigned(ts.z7) then
begin
// ts.z7.SZFileName := Fn;
// ts.z7.List;
ts.z7.OpenFile(fn_full);
if subFile = '' then
begin
{ for I := 0 to ts.zp.Entries.Count - 1 do
if (LastDelimiter('\/:', ts.zp.Entries.Items[i].FileName) <= 0)and
(ExtractFileExt(ts.zp.Entries.Items[i].FileName) = '.ini') then
subFile := ts.zp.Entries.Items[i].FileName; }
// for I := 0 to ts.z7.Files.Count - 1 do
for i := 0 to ts.z7.NumberOfItems - 1 do
begin
// s1 := ts.z7.Files.WStrings[i]
s1 := ts.z7.getItemPath(i);
if (LastDelimiter('\/:', s1) <= 0) and RnQEndsText('theme.ini', s1) then
begin
subFile := s1;
break;
end;
end;
end;
// ts.z7.Close;
if subClass = tsc_all then
ThemePath.subfn := subFile;
end
else
begin
loggaEvt('Can''t load theme ' + fn_full + '; Need 7za.dll or 7zxa.dll!');
subFile := '';
if subClass = tsc_all then
begin
ThemePath.fn := '';
ThemePath.subfn := '';
end;
end;
end;
{$ENDIF USE_7Z}
{$IFDEF USE_RAR}
pt_rar:
begin
if subClass = tsc_all then
ThemePath.fn := fn_Only;
if subFile = '' then
begin
ts.ArcFile := '';
{ for I := 0 to ts.zp.Count - 1 do
if (LastDelimiter('\/:', ts.zp.Name[i]) <= 0)and
RnQEndsText('theme.ini', ts.zp.Name[i]) then
subFile := ts.zp.Name[i]; }
if subClass = tsc_all then
begin
ThemePath.fn := '';
ThemePath.subfn := '';
end;
end;
if subClass = tsc_all then
ThemePath.subfn := subFile;
end;
{$ENDIF USE_RAR}
end;
if loadBase and not FileExists(fn_full) then
begin
// loggaEvt(getTranslation('Can''t find theme %s',[fn]));
msgDlg(getTranslation('Can''t find theme %s', [fn_full]), false, mtError);
// self.fn := '';
subFile := '';
if subClass = tsc_all then
begin
ThemePath.fn := '';
// ThemePath.subfn := '';
end;
end;
{$IFDEF USE_RAR}
if (ts.pathType = pt_rar) and not IsRARDLLLoaded then
LoadRarLibrary;
{$ENDIF USE_RAR}
loadThemeScript(subFile, ts);
{$IFDEF USE_RAR}
if (ts.pathType = pt_rar) then
begin
if ts.RarHnd > 0 then
RARCloseArchive(ts.RarHnd);
ts.RarHnd := 0;
if IsRARDLLLoaded then
UnLoadRarLibrary;
end;
{$ENDIF USE_RAR}
{$IFDEF USE_ZIP}
FreeAndNil(ts.zp);
{$ENDIF USE_ZIP}
{$IFDEF USE_7Z}
// FreeAndNil(ts.z7);
ts.z7 := NIL;
{$ENDIF USE_7Z}
FThemePics.Sorted := True;
// FGPpics.Sorted := True;
// FIntPics.Sorted := True;
FreeResource;
{$IFDEF RNQ_FULL}
if subClass in [tsc_all, tsc_smiles] then
begin
if useAnimated then
begin
if not Assigned(FAniTimer) then
FAniTimer := TTimer.Create(nil);
FAniTimer.Enabled := false;
FAniTimer.Interval := 40;
// timer.Enabled:= UseAnime;
FAniTimer.OnTimer := TickAniTimer;
end
else if (FAniTimer <> NIL) and Assigned(FAniTimer) then
FreeAndNil(FAniTimer);
end;
{$ENDIF RNQ_FULL}
// msgDlg(IntToStr(GDIPlus.Version), mtInformation);
// if useAnimated then
// CreateWaitableTimer()
inc(curToken);
end; // loadTheme
{$IFNDEF NOT_USE_GDIPLUS}
function TRQtheme.GetPic13(const name: TPicName; var pic: TGPImage; AddPic: Boolean = True): Boolean;
var
i: Integer;
// bmp : TRnQBitmap;
// hb : HBITMAP;
begin
Result := false;
i := FThemePics.IndexOf(AnsiLowerCase(name));
if i >= 0 then
begin
if Assigned(pic) then
pic.Free;
pic := NIL;
// if True then
// if FBigPics.Objects[TThemePic(FThemePics.Objects[i]).PicIDX] is TPicObj then
if Assigned(FBigPics.Objects[TThemePic(FThemePics.Objects[i]).picIdx]) then
pic := TPicObj(FBigPics.Objects[TThemePic(FThemePics.Objects[i]).picIdx]).bmp;
if Assigned(pic) then
Result := True
end
{ else
begin
i := FIntPics.IndexOf(AnsiLowerCase(name));
if i >= 0 then
begin
if Assigned(pic) then
pic.Free;
pic := TRnQBitmap(FIntPics.Objects[i]);
result := true;
end
else
if AddPic then
begin
bmp := TRnQBitmap.Create(icon_size, icon_size);
if picDrawFirstLtr then
begin
// bmp.Canvas.Pen.Color := clBlue;
// bmp.Canvas.Font.Color := clBlue;
// bmp.Canvas.TextOut((bmp.Width - 4) div 2, (bmp.Height - 12) div 2 , name[1]);
end;
// pic.Height := 0;
// pic.Width := 0;
// pic.Width := FIconPics.Width;
// pic.Height := FIconPics.Height;
addProp(name, TP_pic, bmp);
pic := bmp;
// pic.Assign(bmp);
bmp.Free;
end;
end; }
end;
{$ENDIF NOT_USE_GDIPLUS}
{$IFNDEF NOT_USE_GDIPLUS}
function TRQtheme.GetPicOld(const name: TPicName; pic: TBitmap32; AddPic: Boolean = True): Boolean;
var
// i : Integer;
// bmp : TRnQBitmap;
// hb : HBITMAP;
gr: TGPGraphics;
tt, IDX: Integer;
pl: TPicLocation;
begin
Result := false;
with GetPicSize(name, tt, pl, IDX) do
if (cx > 0) and (cy > 0) then
begin
pic.SetSize(cx, cy);
gr := TGPGraphics.Create(pic.Canvas.Handle);
gr.Clear(aclWhite);
gr.Free;
drawPic(pic.Canvas.Handle, 0, 0, name, tt, pl, IDX);
Result := True;
end
else
begin
pic.SetSize(0, 0);
end;
{
i := FGPpics.IndexOf(AnsiLowerCase(name));
if i >= 0 then
begin
TRnQBitmap(FGPpics.Objects[i]).GetHBITMAP(0, hb);
pic.SetSize(TRnQBitmap(FGPpics.Objects[i]).GetWidth,
TRnQBitmap(FGPpics.Objects[i]).GetHeight);
// pic.Handle := hb;
// pic := TRnQBitmap(Fgppics.Objects[i]).g;
// pic.Handle := hb;
result := true;
end
else
begin
i := FIntPics.IndexOf(AnsiLowerCase(name));
if i >= 0 then
begin
TRnQBitmap(FIntPics.Objects[i]).GetHBITMAP(0, hb);
pic.Handle := hb;
// pic := TRnQBitmap(FIntPics.Objects[i]);
result := true;
end
// else
end; }
end;
{$ELSE NOT_USE_GDIPLUS}
function TRQtheme.GetPicOld(const picName: TPicName; pic: TBitmap32; AddPic: Boolean = True): Boolean;
var
i: Integer;
// bmp : TRnQBitmap;
// hb : HBITMAP;
// gr : TGPGraphics;
// tt, idx : Integer;
// pl : TPicLocation;
s: TPicName;
tbmp: TRnQBitmap;
hi: HICON;
ico: Ticon;
begin
Result := false;
// s := AnsiLowerCase(PicName);
s := picName;
(* with GetPicSize(name, tt, pl, idx) do
if (cx > 0) and (cy > 0) then
begin
pic.SetSize(cx,cy);
pic.Assign();
pic.Canvas.Brush.Color := clWhite;
pic.Canvas.FillRect(pic.Canvas.ClipRect);
drawPic(pic.Canvas.Handle, 0, 0, name, tt, pl, idx);
result := True;
end
else
begin
pic.SetSize(0,0);
end;
*)
i := FThemePics.IndexOf(s);
if i >= 0 then
begin
with TThemePic(FThemePics.Objects[i]) do
if isWholeBig then
pic.Assign(FBigPics[picIdx].bmp.fBmp)
else
begin
tbmp := FBigPics[picIdx].bmp.Clone(r);
pic.Assign(tbmp.fBmp);
tbmp.Free;
end;
// TThemePic(FThemePics.Objects[i]).
// TRnQBitmap(FGPpics.Objects[i]).GetHBITMAP(0, hb);
// pic.SetSize(TRnQBitmap(FGPpics.Objects[i]).GetWidth,
// TRnQBitmap(FGPpics.Objects[i]).GetHeight);
// pic.Handle := hb;
// pic := TRnQBitmap(Fgppics.Objects[i]).g;
// pic.Handle := hb;
Result := True;
end
else
begin
i := FIntPics.IndexOf(s);
if i >= 0 then
begin
hi := ImageList_ExtractIcon(0, FIntPicsIL, i);
ico := Ticon.Create;
ico.Handle := hi;
pic.width := ico.width;
pic.height := ico.height;
pic.Canvas.Draw(0, 0, ico);
// pic.Assign(ico); //CopyImage(hi, IMAGE_ICON, 0, 0, LR_CREATEDIBSECTION)
DestroyIcon(hi);
ico.Free;
// ico2bmp();
// TRnQBitmap(FIntPics.Objects[i]).GetHBITMAP(0, hb);
// pic.Handle := hb;
// pic := TRnQBitmap(FIntPics.Objects[i]);
Result := True;
end
// else
end;
end;
{$ENDIF NOT_USE_GDIPLUS}
{$IFDEF NOT_USE_GDIPLUS}
function TRQtheme.GetBrush(name: TPicName): HBRUSH;
var
i: Integer;
bmp: TRnQBitmap;
begin
Result := 0;
// i := Fpics.IndexOf(LowerCase(name));
i := FThemePics.IndexOf(AnsiLowerCase(name));
if i >= 0 then
begin
with TThemePic(FThemePics.Objects[i]) do
// bmp := TPicObj(FBigPics.Objects[PicIDX]).bmp.Clone(r);
bmp := FBigPics[picIdx].bmp.Clone(r);
// Clone(TThemePic(FThemePics.Objects[i]).Left, TThemePic(FThemePics.Objects[i]).Top,
// TThemePic(FThemePics.Objects[i]).Width, TThemePic(FThemePics.Objects[i]).Height);
Result := CreatePatternBrush(bmp.fBmp.Handle);
bmp.Free;
// result := CreatePatternBrush(TRnQBitmap(Fpics.Objects[i]).Handle);
// result := true;
end
end;
{$ENDIF NOT_USE_GDIPLUS}
function TRQtheme.GetPicSize(pTE: TRnQThemedElement; const name: TPicName; minSize: Integer = 0): Tsize;
var
i: Integer;
s, s1: TPicName;
begin
s1 := AnsiLowerCase(name);
s := TE2Str[pTE] + s1;
i := FThemePics.IndexOf(s);
if i < 0 then
i := FThemePics.IndexOf(s1);
if i >= 0 then
with TThemePic(FThemePics.Objects[i]) do
begin
// result.cx := r.width;
// result.cy := r.Height;
Result := Tsize(r.size);
end
else
begin
i := FIntPics.IndexOf(s);
if i < 0 then
i := FIntPics.IndexOf(s1);
if i >= 0 then
begin
Result.cx := icon_size;
Result.cy := icon_size;
// result.cx := TRnQBitmap(FIntPics.Objects[i]).GetWidth;
// result.cy := TRnQBitmap(FIntPics.Objects[i]).GetHeight;
end
else
begin
{$IFDEF RNQ_FULL}
// i := FAniSmls.IndexOf(s);
// if i < 0 then
i := FAniSmls.IndexOf(name);
if i >= 0 then
with TRnQAni(FAniSmls.Objects[i]) do
begin
Result.cx := width;
Result.cy := height;
end
else
{$ENDIF RNQ_FULL}
begin
{$IFDEF RNQ_FULL}
// i := FSmilePics.IndexOf(s);
// if i < 0 then
i := FSmilePics.IndexOf(name);
if i >= 0 then
with TThemePic(FSmilePics.Objects[i]) do
begin
// Result.cx := r.Width;
// Result.cy := r.Height;
Result := Tsize(r.size);
end
else
{$ENDIF RNQ_FULL}
begin
Result.cx := minSize;
Result.cy := minSize;
end;
end;
end;
end
end;
function TRQtheme.GetPicSize(var picElm: TRnQThemedElementDtls; minSize: Integer = 0): Tsize;
// var
// i : Integer;
begin
initPic(picElm);
if picElm.picIdx < 0 then
begin
Result.cx := minSize;
Result.cy := minSize;
Exit;
end;
case picElm.Loc of
PL_pic:
with TThemePic(FThemePics.Objects[picElm.picIdx]) do
begin
// result.cx := r.Width;
// result.cy := r.Height;
Result := Tsize(r.size);
end;
PL_int:
begin
Result.cx := icon_size;
Result.cy := icon_size;
// result.cx := TRnQBitmap(FIntPics.Objects[picIdx]).GetWidth;
// result.cy := TRnQBitmap(FIntPics.Objects[picIdx]).GetHeight;
end;
PL_Ani:
with TRnQAni(FAniSmls.Objects[picElm.picIdx]) do
begin
Result.cx := width;
Result.cy := height;
end;
PL_Smile:
with TThemePic(FSmilePics.Objects[picElm.picIdx]) do
begin
// result.cx := r.Width;
// result.cy := r.Height;
Result := Tsize(r.size);
end;
else
begin
Result.cx := minSize;
Result.cy := minSize;
end;
end
end;
procedure TRQtheme.initPic(var picElm: TRnQThemedElementDtls);
var
i: Integer;
s: TPicName;
begin
if picElm.ThemeToken = curToken then
begin
if picElm.picIdx = -1 then
Exit;
case picElm.Loc of
PL_pic:
i := FThemePics.Count;
PL_int:
i := FIntPics.Count;
PL_Ani:
i := FAniSmls.Count;
PL_Smile:
i := FSmilePics.Count;
else
i := -1;
end;
if (picElm.picIdx < 0) or (picElm.picIdx > i) then
picElm.picIdx := -1;
if picElm.picIdx = -1 then
picElm.ThemeToken := -1;
Exit;
end;
picElm.ThemeToken := curToken;
if picElm.picName = '' then
begin
picElm.picIdx := -1;
Exit;
end;
s := AnsiLowerCase(picElm.picName);
picElm.picName := s;
if not(picElm.Element in [RQteDefault .. RQteFormIcon]) then
picElm.Element := RQteDefault;
s := TE2Str[picElm.Element] + picElm.picName;
i := FThemePics.IndexOf(s);
if i < 0 then
i := FThemePics.IndexOf(picElm.picName);
if i >= 0 then
begin
picElm.Loc := PL_pic;
picElm.picIdx := i;
end
else
begin
begin
i := FIntPics.IndexOf(s);
if i < 0 then
i := FIntPics.IndexOf(picElm.picName);
if i >= 0 then
begin
picElm.Loc := PL_int;
picElm.picIdx := i;
end
else
begin
i := FSmilePics.IndexOf(picElm.picName);
if i >= 0 then
begin
picElm.Loc := PL_Smile;
picElm.picIdx := i;
end
else
begin
{$IFDEF RNQ_FULL}
// i := FAniSmls.IndexOf(s);
// if i < 0 then
i := FAniSmls.IndexOf(picElm.picName);
if i >= 0 then
begin
picElm.Loc := PL_Ani;
picElm.picIdx := i;
end
else
{$ENDIF RNQ_FULL}
begin
// picLoc := 0;
picElm.picIdx := -1;
end;
end;
end
end;
end
end;
function TRQtheme.GetSmileName(i: Integer): TPicName;
begin
if i >= 0 then
Result := FSmiles.Strings[i]
else
Result := '';
end;
function TRQtheme.GetSmileObj(i: Integer): TSmlObj;
begin
if i >= 0 then
if Assigned(FSmiles.Objects[i]) then
Result := TSmlObj(FSmiles.Objects[i])
else
Result := NIL
else
Result := NIL;
end;
function TRQtheme.GetSmlCnt: Integer;
begin
Result := FSmiles.Count;
end;
function TRQtheme.GetString(const name: TPicName; isAdd: Boolean = True): String;
var
i: Integer;
ts: TThemeSourcePath;
begin
i := FStr.IndexOf(AnsiLowerCase(name));
if i >= 0 then
Result := TStrObj(FStr.Objects[i]).str
else
begin
Result := '';
if isAdd then
begin
ts.pathType := pt_path;
addProp(name, ts, TP_string, '');
end;
end;
end;
function TRQtheme.GetSound(const name: TPicName): String;
var
i: Integer;
begin
i := FSounds.IndexOf(AnsiLowerCase(name));
if i >= 0 then
Result := TSndObj(FSounds.Objects[i]).str
else
Result := '';
end;
function TRQtheme.PlaySound(const name: TPicName): Boolean;
var
i: Integer;
// s : String;
begin
Result := True;
i := FSounds.IndexOf(AnsiLowerCase(name));
if i >= 0 then
begin
if not Assigned(TSndObj(FSounds.Objects[i]).s3m) then
SoundPlay(TSndObj(FSounds.Objects[i]).str)
else
SoundPlay(TSndObj(FSounds.Objects[i]).s3m)
end
else
Result := false;
end;
procedure TRQtheme.ApplyFont(const pName: TPicName; fnt: TFont);
var
i: Integer;
begin
if not Assigned(fnt) then
// fnt := Screen.MenuFont;
Exit;
// i := FFonts2.IndexOf(AnsiLowerCase(name));
i := FFonts2.IndexOf(pName);
if i >= 0 then
with TFontObj(FFonts2.Objects[i]) do
if flags > 0 then
begin
if flags and FPT_CHARSET > 0 then
fnt.charset := charset;
if flags and FPT_SIZE > 0 then
fnt.size := size;
if flags and FPT_COLOR > 0 then
fnt.color := color;
if flags and FPT_STYLE > 0 then
fnt.style := style;
if flags and FPT_NAME > 0 then
fnt.name := TFontName(Name);
end;
end;
{
function TRQtheme.GetFontProp(name : String; Prop : TFontPropsTypes) : TFontProps;
var
i, j : Integer;
found : Boolean;
begin
found := False;
Result.fpType := Prop;
i := FFonts2.IndexOf(AnsiLowerCase(name));
if i >= 0 then
begin
for J := 0 to Length(TFontObj(FFonts2.Objects[i]).prop) - 1 do
if Prop = TFontObj(FFonts2.Objects[i]).prop[j].fpType then
begin
case Prop of
FPT_CHARSET: Result.charset := TFontObj(FFonts2.Objects[i]).prop[j].charset;
FPT_SIZE: Result.Size := TFontObj(FFonts2.Objects[i]).prop[j].size;
FPT_COLOR: Result.Color := TFontObj(FFonts2.Objects[i]).prop[j].color;
FPT_STYLE: Result.Style := TFontObj(FFonts2.Objects[i]).prop[j].style;
FPT_NAME: Result.Name := TFontObj(FFonts2.Objects[i]).prop[j].name;
end;
found := True;
end;
end;
if not found then
case Prop of
FPT_CHARSET: Result.charset := Screen.MenuFont.charset;
FPT_SIZE: Result.Size := Screen.MenuFont.size;
FPT_COLOR: Result.Color := Screen.MenuFont.color;
FPT_STYLE: Result.Style := Screen.MenuFont.style;
FPT_NAME: StrPCopy(Result.Name, Screen.MenuFont.Name);
end;
end;
}
function TRQtheme.GetFontName(const pName: TPicName): String;
var
i: Integer;
found: Boolean;
begin
found := false;
i := FFonts2.IndexOf(AnsiLowerCase(pName));
if i >= 0 then
begin
if TFontObj(FFonts2.Objects[i]).flags and FPT_NAME > 0 then
begin
Result := TFontObj(FFonts2.Objects[i]).name;
found := True;
end;
end;
if not found then
Result := Screen.MenuFont.name;
end;
function TRQtheme.GetColor(const name: TPicName; pDefColor: TColor = clDefault): TColor;
var
i: Integer;
begin
i := FClr.IndexOf(AnsiLowerCase(name));
if i >= 0 then
{$WARN UNSAFE_CAST OFF}
Result := TColor(FClr.Objects[i])
{$WARN UNSAFE_CAST ON}
else
begin
// addProp(name, pDefColor);
Result := pDefColor;
end
end;
function TRQtheme.GetAColor(const name: TPicName; pDefColor: Integer = clDefault): Cardinal;
var
i: Integer;
begin
i := FClr.IndexOf(AnsiLowerCase(name));
if i >= 0 then
// result := ColorFromAlphaColor($FF, ABCD_ADCB(ColorToRGB(TColor(FClr.Objects[i]))))
{$WARN UNSAFE_CAST OFF}
{$IFNDEF NOT_USE_GDIPLUS}
Result := AlphaMask or ABCD_ADCB(ColorToRGB(TColor(FClr.Objects[i])))
{$ELSE NOT_USE_GDIPLUS}
Result := AlphaMask or ColorToRGB(TColor(FClr.Objects[i]))
{$ENDIF NOT_USE_GDIPLUS}
{$WARN UNSAFE_CAST ON}
else
begin
// addProp(name, pDefColor);
// result := ColorFromAlphaColor($FF, ABCD_ADCB(ColorToRGB(pDefColor)));
{$IFNDEF NOT_USE_GDIPLUS}
Result := AlphaMask or ABCD_ADCB(ColorToRGB(pDefColor));
{$ELSE NOT_USE_GDIPLUS}
Result := AlphaMask or ColorToRGB(pDefColor)
{$ENDIF NOT_USE_GDIPLUS}
end
end;
function TRQtheme.GetTColor(const name: TPicName; pDefColor: Cardinal): Cardinal;
var
i: Integer;
begin
i := FClr.IndexOf(AnsiLowerCase(name));
if i >= 0 then
// result := ColorFromAlphaColor($FF, ABCD_ADCB(ColorToRGB(TColor(FClr.Objects[i]))))
{$WARN UNSAFE_CAST OFF}
{$IFNDEF NOT_USE_GDIPLUS}
Result := Cardinal(FClr.Objects[i])
{$ELSE NOT_USE_GDIPLUS}
Result := Cardinal(FClr.Objects[i])
{$ENDIF NOT_USE_GDIPLUS}
{$WARN UNSAFE_CAST ON}
else
begin
// addProp(name, pDefColor);
// result := ColorFromAlphaColor($FF, ABCD_ADCB(ColorToRGB(pDefColor)));
{$IFNDEF NOT_USE_GDIPLUS}
Result := pDefColor;
{$ELSE NOT_USE_GDIPLUS}
Result := pDefColor
{$ENDIF NOT_USE_GDIPLUS}
end
end;
function TRQtheme.pic2ico(pTE: TRnQThemedElement; const picName: TPicName; ico: Ticon): Boolean;
var
bmp: TRnQBitmap;
// vIco : TIcon;
i: Integer;
hi: HICON;
s: TPicName;
begin
if picName = '' then
begin
Result := false;
Exit;
end;
// if not GetIco2(picName, ico) then
(* if (Win32MajorVersion < 5) or (IsWin2K) then
begin
{ with GetPicSize(picName) do
if (cx > 0) and (cy > 0) then
begin
bmp := createBitmap(cx, cy);
bmp.PixelFormat := pf24bit;
// bmp.Canvas.Brush.Color:= $007f017f;
bmp.Canvas.Brush.Color:= ColorToRGB(clBtnFace);
bmp.Canvas.FillRect(bmp.Canvas.ClipRect);
drawPic(bmp.Canvas, 0, 0, picName);
// bmp.TransparentColor := $007f017f;
bmp.TransparentColor := ColorToRGB(clBtnFace);
bmp.Transparent := True;
vIco := bmp2ico(bmp);
ico.Assign(vIco);
vIco.Free;
bmp.Free;
Result := True;
end;}
end
else *)
begin
// bmp :=TRnQBitmap.Create;
Result := false;
i := -1;
if pTE <> RQteDefault then
begin
s := TE2Str[pTE] + AnsiLowerCase(picName);
i := FThemePics.IndexOf(s);
end;
if i < 0 then
i := FThemePics.IndexOf(AnsiLowerCase(picName));
if i >= 0 then
begin
with TThemePic(FThemePics.Objects[i]) do
// if Assigned(TPicObj(FBigPics.Objects[PicIDX]).bmp) then
if Assigned(FBigPics[picIdx].bmp) then
begin
hi := 0;
// TPicObj(FBigPics.Objects[TThemePic(FThemePics.Objects[i]).PicIDX]).bmp.GetHICON(hi);
// {
// bmp := TPicObj(FBigPics.Objects[PicIDX]).bmp.Clone(r
if isWholeBig then
FBigPics[picIdx].bmp.GetHICON(hi)
else
begin
bmp := FBigPics[picIdx].bmp.Clone(r
{$IFNDEF NOT_USE_GDIPLUS}
, TPicObj(FBigPics.Objects[picIdx]).bmp.GetPixelFormat
{$ENDIF NOT_USE_GDIPLUS}
);
if Assigned(bmp) then
begin
bmp.GetHICON(hi);
if Assigned(bmp) then
bmp.Free;
end
else
hi := 0;
end;
// }
// TPicObj(FBigPics.Objects[TThemePic(FThemePics.Objects[i]).PicIDX]).bmp.GetHICON(hi);
ico.Handle := hi;
if hi > 0 then
begin
Result := True;
DeleteObject(hi);
end
// else
// result := False;
end
// else
// result := False;
end
else
begin
i := FIntPics.IndexOf(AnsiLowerCase(picName));
if i >= 0 then
begin
hi := ImageList_ExtractIcon(0, FIntPicsIL, i);
ico.Handle := hi;
if hi > 0 then
begin
Result := True;
DeleteObject(hi);
end
end
// else
// Result := False;
end;
end
// else
// Result := True;
end;
function TRQtheme.pic2hIcon(const picName: TPicName; var ico: HICON): Boolean;
var
bmp: TRnQBitmap;
// vIco : TIcon;
i: Integer;
// hi : HICON;
begin
// bmp :=TRnQBitmap.Create;
if ico <> 0 then
DeleteObject(ico);
ico := 0;
Result := false;
i := FThemePics.IndexOf(AnsiLowerCase(picName));
if i >= 0 then
begin
with TThemePic(FThemePics.Objects[i]) do
// if Assigned(TPicObj(FBigPics.Objects[PicIDX]).bmp) then
if Assigned(FBigPics[picIdx].bmp) then
begin
// TPicObj(FBigPics.Objects[TThemePic(FThemePics.Objects[i]).PicIDX]).bmp.GetHICON(hi);
// {
bmp := FBigPics[picIdx].bmp.Clone(r
{$IFNDEF NOT_USE_GDIPLUS}
, TPicObj(FBigPics.Objects[picIdx]).bmp.GetPixelFormat
{$ENDIF NOT_USE_GDIPLUS}
);
if Assigned(bmp) then
begin
bmp.GetHICON(ico);
if Assigned(bmp) then
bmp.Free;
end
else
ico := 0;
// }
// TPicObj(FBigPics.Objects[TThemePic(FThemePics.Objects[i]).PicIDX]).bmp.GetHICON(hi);
// result := True;
// ico.Handle := hi;
// DeleteObject(hi);
Result := True;
end
// else
// result := False;
end
else
begin
i := FIntPics.IndexOf(AnsiLowerCase(picName));
if i >= 0 then
begin
ico := ImageList_ExtractIcon(0, FIntPicsIL, i);
Result := True;
end
// else
// Result := False;
end;
end;
function TRQtheme.addBigPic(var pBmp: TRnQBitmap): Integer;
// var
// tempPic :TPicObj;
begin
Result := Length(FBigPics);
SetLength(FBigPics, Result + 1);
FBigPics[Result] := TPicObj.Create;
FBigPics[Result].bmp := pBmp;
pBmp := nil;
FBigPics[Result].ref := 0;
// FBigPics.AddObject(AnsiLowerCase(name), tempPic)
end;
function TRQtheme.addBigSmile(var pBmp: TRnQBitmap): Integer;
// var
// tempPic :TPicObj;
begin
Result := Length(FSmileBigPics);
SetLength(FSmileBigPics, Result + 1);
FSmileBigPics[Result] := TPicObj.Create;
FSmileBigPics[Result].bmp := pBmp;
pBmp := nil;
FSmileBigPics[Result].ref := 0;
// FBigPics.AddObject(AnsiLowerCase(name), tempPic)
end;
function TRQtheme.addProp(const name: TPicName; kind: TthemePropertyKind; var pBmp: TRnQBitmap): Integer;
var
i: Integer;
// tempPic :TPicObj;
thp: TThemePic;
begin
Result := -1;
if not Assigned(pBmp) then
Exit;
if kind = TP_smile then
begin // pic for smile
{ i := FSmileBigPics.IndexOf(AnsiLowerCase(name));
if i < 0 then
begin
tempPic :=TPicObj.Create;
tempPic.bmp := pBmp;
pBmp := nil;
tempPic.ref := 0;
result := FSmileBigPics.AddObject(AnsiLowerCase(name), tempPic)
end
else
with TPicObj(FSmileBigPics.Objects[i]) do
begin
if Assigned(bmp) then
bmp.Free;
bmp := NIL;
bmp := pBmp;
pBmp := nil;
result := i;
end; }
end
else // just pic
begin
// i := FBigPics.IndexOf(AnsiLowerCase(name));
i := FThemePics.IndexOf(AnsiLowerCase(name));
if i < 0 then
begin
thp := TThemePic.Create;
thp.r.x := 0;
thp.r.y := 0;
thp.r.width := pBmp.width;
thp.r.height := pBmp.height;
thp.picIdx := addBigPic(pBmp);
inc(FBigPics[thp.picIdx].ref);
// tempPic.bmp := Bmp.Clone(1, 1, Bmp.GetWidth, bmp.GetHeight, bmp.GetPixelFormat);
// tempPic.bmp := Bmp.Clone;
{ tempPic :=TPicObj.Create;
tempPic.bmp := pBmp;
pBmp := nil;
tempPic.ref := 0;
result := FBigPics.AddObject(AnsiLowerCase(name), tempPic) }
Result := FThemePics.AddObject(name, thp);
end
else
// with TPicObj(FBigPics.Objects[i]) do
begin
thp := TThemePic(FThemePics.Objects[i]);
thp.r.x := 0;
thp.r.y := 0;
thp.r.width := pBmp.width;
thp.r.height := pBmp.height;
if Assigned(FBigPics[thp.picIdx]) then
dec(FBigPics[thp.picIdx].ref);
thp.picIdx := addBigPic(pBmp);
inc(FBigPics[thp.picIdx].ref);
// if Assigned(bmp) then
// bmp.Free;
// bmp := NIL;
// TPicObj(FBigPics.Objects[i]).bmp := Bmp.Clone(0, 0, Bmp.GetWidth, bmp.GetHeight, bmp.GetPixelFormat);
// bmp := pBmp;
// pBmp := nil;
// TPicObj(FBigPics.Objects[i]).ref := 0;
// TPicObj(FBigPics.Objects[i]).Free;
// FBigPics.Objects[i] := Bmp.Clone;
Result := i;
end;
end
end; // addthemeprop
procedure TRQtheme.addProp(const name: TPicName; kind: TthemePropertyKind; var pic: TThemePic);
var
i: Integer;
begin
if not Assigned(pic) then
Exit;
if kind = TP_smile then
with FSmilePics do
begin // pic for smile
// i := IndexOf(AnsiLowerCase(name));
i := IndexOf(name);
if i < 0 then
begin
// AddObject(AnsiLowerCase(name), pic);
AddObject(name, pic);
pic := nil;
end
else
begin
with TThemePic(Objects[i]) do
begin
r := pic.r;
picIdx := pic.picIdx;
end;
FreeAndNil(pic);
end;
end
else // just pic
with FThemePics do
begin
i := IndexOf(AnsiLowerCase(name));
if i < 0 then
begin
AddObject(AnsiLowerCase(name), pic);
pic := nil;
end
else
begin
with TThemePic(Objects[i]) do
begin
r := pic.r;
picIdx := pic.picIdx;
end;
FreeAndNil(pic);
end;
end
end;
procedure TRQtheme.addHIco(const name: TPicName; hi: HICON; Internal: Boolean = false);
// procedure TRQtheme.addprop(name:string;hi: HICON; Internal : Boolean = false);
var
i: Integer;
// j, cnt : Integer;
// bmp : TRnQBitmap;
// ff : TGUID;
begin
if hi = 0 then
Exit;
if not Internal then
begin
{ i := FBigPics.IndexOf(AnsiLowerCase(name));
if i < 0 then
begin
// TRnQBitmap.c
// i :=
FBigPics.AddObject(AnsiLowerCase(name), TRnQBitmap.Create(hi));
// TRnQBitmap(FGPpics.Objects[i]).
end
else
begin
TRnQBitmap(FBigPics.Objects[i]).Free;
FBigPics.Objects[i] := TRnQBitmap.Create(hi);
end;
{ cnt := TRnQBitmap(FGPpics.Objects[i]).GetFrameCount(FrameDimensionResolution);
if cnt > 1 then
for j := 0 to cnt-1 do
begin
TRnQBitmap(FGPpics.Objects[i]).SelectActiveFrame(FrameDimensionResolution, j);
if (TRnQBitmap(FGPpics.Objects[i]).GetWidth = icon_size)
or (TRnQBitmap(FGPpics.Objects[i]).GetHeight = icon_size) then
break;
end;
}
end;
if Internal then
begin
i := FIntPics.IndexOf(AnsiLowerCase(name));
if i < 0 then
begin
// i :=
FIntPics.Add(AnsiLowerCase(name));
ImageList_AddIcon(FIntPicsIL, hi);
// FIntPicsIL
// i := FIntPics.AddObject(AnsiLowerCase(name), TRnQBitmap.Create(hi));
end
else
begin
ImageList_ReplaceIcon(FIntPicsIL, i, hi)
// TRnQBitmap(FIntPics.Objects[i]).Free;
// FIntPics.Objects[i] := TRnQBitmap.Create(hi);
end;
{ if TRnQBitmap(FIntPics.Objects[i]).GetFrameDimensionsCount > 0 then
begin
TRnQBitmap(FIntPics.Objects[i]).GetFrameDimensionsList(@ff, 1);
// cnt := TRnQBitmap(FIntPics.Objects[i]).GetFrameCount(FrameDimensionResolution);
cnt := TRnQBitmap(FIntPics.Objects[i]).GetFrameCount(ff);
// cnt := TRnQBitmap(FIntPics.Objects[i]).GetFrameCount(FrameDimensionTime);
if cnt > 1 then
for j := 0 to cnt-1 do
begin
TRnQBitmap(FIntPics.Objects[i]).SelectActiveFrame(FrameDimensionResolution, j);
if (TRnQBitmap(FIntPics.Objects[i]).GetWidth = icon_size)
or (TRnQBitmap(FIntPics.Objects[i]).GetHeight = icon_size) then
break;
end;
end; }
end
end; // addthemeprop
procedure TRQtheme.addProp(const name: TPicName; const SmlCaption: String; Smile: TRnQBitmap; var pTP: TThemePic;
bStretch: Boolean = false; Ani: Boolean = false; AniIdx: Integer = -1);
var
i, j: Integer;
NewSmile: TSmlObj;
vST: TthemePropertyKind;
tp: TThemePic;
pic: TRnQBitmap;
begin
// if bStretch then
// vST := TP_ico
// else
// vST := TP_pic;
vST := TP_smile;
i := FSmiles.IndexOf(name);
if i < 0 then
begin
if not Assigned(Smile) and not Assigned(pTP) then
Exit;
NewSmile := TSmlObj.Create;
NewSmile.Animated := Ani;
NewSmile.SmlStr := TStringList.Create;
NewSmile.SmlStr.CaseSensitive := True;
NewSmile.SmlStr.Add(SmlCaption);
NewSmile.AniIdx := AniIdx;
FSmiles.AddObject(name, NewSmile);
if not Assigned(pTP) then
begin
tp := TThemePic.Create;
with tp.r do
begin
x := 0;
y := 0;
width := Smile.GetWidth;
height := Smile.GetHeight;
end;
// pic := Smile.Clone(0, 0, tp.Width, tp.Height, Smile.GetPixelFormat);
pic := Smile;
tp.picIdx := addBigSmile(pic);
// NewSmile.AniIdx :=
addProp(name, vST, tp);
end
else
addProp(name, vST, pTP);
pTP := NIL;
// NewSmile := NIL;
end
else
begin
j := TSmlObj(FSmiles.Objects[i]).SmlStr.IndexOf(SmlCaption);
if j < 0 then
TSmlObj(FSmiles.Objects[i]).SmlStr.Add(SmlCaption)
else if Assigned(Smile) or Assigned(pTP) then
begin
if not Assigned(pTP) then
begin
tp := TThemePic.Create;
with tp.r do
begin
x := 0;
y := 0;
width := Smile.GetWidth;
height := Smile.GetHeight;
end;
// pic := Smile.Clone(0, 0, tp.Width, tp.Height, Smile.GetPixelFormat);
pic := Smile;
tp.picIdx := addBigSmile(pic);
addProp(name, vST, tp);
end
else
addProp(name, vST, pTP);
pTP := NIL;
// addprop(name, vST, Smile);
end;
end;
end; // theme.addprop
procedure TRQtheme.addProp(name: TPicName; ts: TThemeSourcePath; kind: TthemePropertyKind; const s: String);
var
StrObj: TStrObj;
sndObj: TSndObj;
i: Integer;
curList: TObjList;
begin
if name = '' then
Exit;
name := AnsiLowerCase(name);
if kind = TP_sound then
begin
i := FSounds.IndexOf(name);
if i < 0 then
begin
sndObj := TSndObj.Create;
i := FSounds.AddObject(name, sndObj);
end;
TSndObj(FSounds.Objects[i]).str := s;
FreeAndNil(TSndObj(FSounds.Objects[i]).s3m);
if ts.pathType <> pt_path then
begin
TSndObj(FSounds.Objects[i]).s3m := TMemoryStream.Create;
ts.path := '';
if not loadFile(ts, s, TStream(TSndObj(FSounds.Objects[i]).s3m)) then
FreeAndNil(TSndObj(FSounds.Objects[i]).s3m);
end;
Exit;
end;
case kind of
TP_string:
curList := FStr;
else
Exit;
end;
begin
i := curList.IndexOf(name);
if i < 0 then
begin
StrObj := TStrObj.Create;
StrObj.str := s;
curList.AddObject(name, StrObj);
end
else
begin
TStrObj(curList.Objects[i]).str := s;
end;
end
end; // addthemeprop
{
procedure TRQtheme.addprop(name:string; fnt: TFont);
var
i : Integer;
begin
i := FFonts.IndexOf(AnsiLowerCase(name));
if i < 0 then
FFonts.AddObject(AnsiLowerCase(name), fnt)
else
begin
FFonts.Objects[i].Free;
FFonts.Objects[i] := fnt;
end;
end;
}
procedure TRQtheme.addProp(const pName: TPicName; fnt: TFontObj);
var
i: Integer;
fo: TFontObj;
// j: Integer;
// Found : Boolean;
begin
i := FFonts2.IndexOf(AnsiLowerCase(pName));
if i < 0 then
begin
fo := fnt.Clone;
// SetLength(fo.prop, 1);
// fo.prop[0] := fnt;
FFonts2.AddObject(AnsiLowerCase(pName), fo)
end
else
begin
if FPT_CHARSET and fnt.flags > 0 then
begin
TFontObj(FFonts2.Objects[i]).flags := TFontObj(FFonts2.Objects[i]).flags or FPT_CHARSET;
TFontObj(FFonts2.Objects[i]).charset := fnt.charset;
end;
// else
// TFontObj(FFonts2.Objects[i]).flags := TFontObj(FFonts2.Objects[i]).flags and not FPT_CHARSET;
if FPT_SIZE and fnt.flags > 0 then
begin
TFontObj(FFonts2.Objects[i]).flags := TFontObj(FFonts2.Objects[i]).flags or FPT_SIZE;
TFontObj(FFonts2.Objects[i]).size := fnt.size;
end;
// else
// TFontObj(FFonts2.Objects[i]).flags := TFontObj(FFonts2.Objects[i]).flags and not FPT_SIZE;
if FPT_COLOR and fnt.flags > 0 then
begin
TFontObj(FFonts2.Objects[i]).flags := TFontObj(FFonts2.Objects[i]).flags or FPT_COLOR;
TFontObj(FFonts2.Objects[i]).color := fnt.color;
end;
// else
// TFontObj(FFonts2.Objects[i]).flags := TFontObj(FFonts2.Objects[i]).flags and not FPT_COLOR;
if FPT_STYLE and fnt.flags > 0 then
begin
TFontObj(FFonts2.Objects[i]).flags := TFontObj(FFonts2.Objects[i]).flags or FPT_STYLE;
TFontObj(FFonts2.Objects[i]).style := fnt.style;
end;
// else
// TFontObj(FFonts2.Objects[i]).flags := TFontObj(FFonts2.Objects[i]).flags and not FPT_STYLE;
if FPT_NAME and fnt.flags > 0 then
begin
TFontObj(FFonts2.Objects[i]).flags := TFontObj(FFonts2.Objects[i]).flags or FPT_NAME;
if TFontObj(FFonts2.Objects[i]).name <> NIL then
StrDispose(TFontObj(FFonts2.Objects[i]).name);
{$IFDEF UNICODE}
// TFontObj(FFonts2.Objects[i]).Name := AnsiStrAlloc(StrLen(fnt.name)+1);
TFontObj(FFonts2.Objects[i]).name := StrAlloc(StrLen(fnt.name) + 1);
{$ELSE nonUNICODE}
TFontObj(FFonts2.Objects[i]).name := StrAlloc(StrLen(fnt.name) + 1);
{$ENDIF UNICODE}
StrCopy(TFontObj(FFonts2.Objects[i]).name, fnt.name);
end;
// else
// begin
// TFontObj(FFonts2.Objects[i]).flags := TFontObj(FFonts2.Objects[i]).flags and not FPT_NAME;
// if TFontObj(FFonts2.Objects[i]).Name <> NIL then
// StrDispose(TFontObj(FFonts2.Objects[i]).Name);
// end;
end;
end;
procedure TRQtheme.addProp(const name: TPicName; c: TColor);
var
i: Integer;
begin
i := FClr.IndexOf(AnsiLowerCase(name));
if i < 0 then
FClr.AddObject(AnsiLowerCase(name), TObject(c))
else
begin
FClr.Objects[i] := TObject(c);
end;
end;
procedure TRQtheme.loadThemeScript(const fn: string; const path: string);
var
ts: TThemeSourcePath;
begin
ts.pathType := pt_path;
{$IFDEF USE_ZIP}
ts.zp := nil;
{$ENDIF USE_ZIP}
{$IFDEF USE_7Z}
ts.z7 := nil;
{$ENDIF USE_7Z}
ts.ArcFile := '';
ts.path := path;
loadThemeScript(fn, ts);
end;
procedure TRQtheme.loadThemeScript(fn: string; ts: TThemeSourcePath);
var
// LastPicFName : String; // For support '@' at pics
// LastLoadedPic : TRnQBitmap;
LastPicIDX: Integer; // For support '@' at pics
function fullpath(fn: string): string;
begin
if ansipos(':', fn) = 0 then
Result := ts.path + fn
else
Result := fn
end;
// function fullpath(fn:string):string;
// begin if ansipos(':',fn)=0 then result:=path+fn else result:=fn end;
(* procedure crop(bmp:TRnQBitmap; x,y,dx,dy:integer);
begin
if dy < 0 then exit;
// bmp.Transparent := True;
// bmp.TransparentColor := bmp.Canvas.Pixels[x, y];
{$IFDEF USE_32Aplha_Images}
bmp.PixelFormat:= bmp.PixelFormat;
{$ENDIF}
if (x<>0) or (y<>0) then
bmp.canvas.copyRect(rect(0,0,dx,dy), bmp.canvas, rect(x,y,x+dx,y+dy));
bmp.Width:=dx;
bmp.height:=dy;
bmp.TransparentMode := tmAuto;
bmp.Transparent := True;
// bmp.TransparentColor := bmp.Canvas.Pixels[x, y];
end; // crop
*)
{ procedure parsePic(v : String;var bmp:TRnQBitmap);
var
s,fn:string;
x,y,dx,dy, idx:integer;
begin
s:=v;
fn:=chop(';',s);
if fn='' then exit;
// if bmp=NIL then bmp:=TRnQBitmap.create;
if bmp <> NIL then FreeAndNil(bmp);
x:=str2valor(chop(';',s));
y:=str2valor(chop(';',s));
if (y = -1) and (x <> -1)and (s = '') then
begin
idx := x;
x := -1;
dx:=-1;
dy:=-1;
end
else
begin
dx:=str2valor(chop(';',s));
dy:=str2valor(chop(';',s));
idx := str2valor(chop(';',s));
end;
if fn = '@' then
begin
if Assigned(LastLoadedPic) then
begin
// if (LastLoadedPic.GetHorizontalResolution <> Screen.PixelsPerInch)
// or (LastLoadedPic.GetVerticalResolution <> Screen.PixelsPerInch) then
// LastLoadedPic.SetResolution(Screen.PixelsPerInch, Screen.PixelsPerInch);
bmp := LastLoadedPic.Clone(x,y,dx, dy, LastLoadedPic.GetPixelFormat);
if Assigned(bmp) then
if (bmp.GetHorizontalResolution <> Screen.PixelsPerInch)
or (bmp.GetVerticalResolution <> Screen.PixelsPerInch) then
bmp.SetResolution(Screen.PixelsPerInch, Screen.PixelsPerInch);
end
// else
// bmp := nil;
end
// bmp := LastLoadedPic.Clone(0,0,LastLoadedPic.GetWidth, LastLoadedPic.GetHeight, PixelFormat32bppARGB)
// fn := LastPicFName
else
if AnsiStartsText('@pics.', fn) then
begin
getPic13(copy(fn,6,length(fn)), bmp);
end
else
begin
FreeAndNil(LastLoadedPic);
// LastLoadedPic := TRnQBitmap.Create;
if not loadPic(ts, fn, LastLoadedPic, idx) then
begin
LastLoadedPic := NIL;
FreeAndNil(bmp);
Exit;
end;
if dy < 0 then
begin
x := 0; y := 0;
if Assigned(LastLoadedPic) then
begin
dx := LastLoadedPic.GetWidth;
dy := LastLoadedPic.GetHeight;
end
else
begin
dx := 0; dy := 0;
end;
// LastLoadedPic.Clone;
end;
// else
begin
if x < 0 then x := 0;
if y < 0 then y := 0;
// if (LastLoadedPic.GetHorizontalResolution <> Screen.PixelsPerInch)
// or (LastLoadedPic.GetVerticalResolution <> Screen.PixelsPerInch) then
// LastLoadedPic.SetResolution(Screen.PixelsPerInch, Screen.PixelsPerInch);
bmp := LastLoadedPic.Clone(x,y,dx, dy,LastLoadedPic.GetPixelFormat);
// bmp.Assign(LastLoadedPic);
end;
end;
// crop(bmp,x,y,dx,dy);
end; // parsePic
}
function parsePic(IsSmile: Boolean; v: AnsiString; picName: TPicName = ''): TThemePic;
var
s: RawByteString;
fn: AnsiString;
x, y, dx, dy, IDX: Integer;
w, h: Integer;
tempPic: TRnQBitmap;
i: Integer;
// bmp : TRnQBitmap;
begin
// bmp := NIL;
tempPic := nil;
s := v;
Result := nil;
fn := chop(RawByteString(';'), s);
if fn = '' then
Exit;
// if bmp=NIL then bmp:=TRnQBitmap.create;
// if bmp <> NIL then FreeAndNil(bmp);
x := str2valor(chop(RawByteString(';'), s));
y := str2valor(chop(RawByteString(';'), s));
if (y = -1) and (x <> -1) and (s = '') then
begin
IDX := x;
x := -1;
dx := -1;
dy := -1;
end
else
begin
dx := str2valor(chop(';', s));
dy := str2valor(chop(';', s));
IDX := str2valor(chop(';', s));
end;
if fn = '@' then
begin
// if Assigned(LastLoadedPic) then
if LastPicIDX >= 0 then
begin
// if (LastLoadedPic.GetHorizontalResolution <> Screen.PixelsPerInch)
// or (LastLoadedPic.GetVerticalResolution <> Screen.PixelsPerInch) then
// LastLoadedPic.SetResolution(Screen.PixelsPerInch, Screen.PixelsPerInch);
Result := TThemePic.Create;
{ Result.Left := x;
Result.Top := y;
Result.Width := dx;
Result.Height := dy; }
Result.r := MakeRectI(x, y, dx, dy);
Result.picIdx := LastPicIDX;
end
// else
// bmp := nil;
end
// bmp := LastLoadedPic.Clone(0,0,LastLoadedPic.GetWidth, LastLoadedPic.GetHeight, PixelFormat32bppARGB)
// fn := LastPicFName
else
begin
if AnsiStartsText(AnsiString('@pics.'), fn) then
begin
LastPicIDX := -1;
s := AnsiLowerCase(copy(fn, 7, Length(fn)));
if picName = s then
begin
tempPic := NIL;
Result := nil;
Exit;
end;
w := 0;
h := 0;
i := FThemePics.IndexOf(s);
// for I := 0 to FThemePics.Count - 1 do
// if FThemePics.Strings[i] = s then
if i >= 0 then
with TThemePic(FThemePics.Objects[i]) do
begin
LastPicIDX := picIdx;
if x >= 0 then
x := r.x + x
else
x := r.x;
if y >= 0 then
y := r.y + y
else
y := r.y;
if dx < 0 then
dx := r.width
else
dx := min(dx, r.width);
if dy < 0 then
dy := r.height
else
dy := min(dy, r.height);
// break;
end;
// getPic13(copy(fn,6,length(fn)), bmp);
end
else
begin
// FreeAndNil(LastLoadedPic);
LastPicIDX := -1;
// LastLoadedPic := TRnQBitmap.Create;
// if not loadPic(ts, fn, LastLoadedPic, idx) then
if not loadPic(ts, UnUTF(fn), tempPic, IDX) then
begin
if Assigned(tempPic) then
tempPic.Free;
tempPic := NIL;
Result := nil;
// FreeAndNil(bmp);
Exit;
end;
w := tempPic.GetWidth;
h := tempPic.GetHeight;
// LastPicIDX := addProp(fn, TP_pic, tempPic);
LastPicIDX := addBigPic(tempPic);
end;
if LastPicIDX >= 0 then
begin
if dy < 0 then
begin
x := 0;
y := 0;
// if LastPicIDX >=0 then
begin
dx := w;
dy := h;
end
{ else
begin
dx := 0; dy := 0;
end; }
// LastLoadedPic.Clone;
end;
// else
begin
if x < 0 then
x := 0;
if y < 0 then
y := 0;
// if (LastLoadedPic.GetHorizontalResolution <> Screen.PixelsPerInch)
// or (LastLoadedPic.GetVerticalResolution <> Screen.PixelsPerInch) then
// LastLoadedPic.SetResolution(Screen.PixelsPerInch, Screen.PixelsPerInch);
Result := TThemePic.Create;
{ Result.Left := x;
Result.Top := y;
Result.Width := dx;
Result.Height := dy; }
Result.r := MakeRectI(x, y, dx, dy);
Result.picIdx := LastPicIDX;
// bmp := LastLoadedPic.Clone(x,y,dx, dy,LastLoadedPic.GetPixelFormat);
// bmp.Assign(LastLoadedPic);
end;
end;
end;
// crop(bmp,x,y,dx,dy);
end; // parsePic
function fontAvailable(list: RawByteString): AnsiString;
var
s: String;
begin
repeat
Result := chop(AnsiString(';'), list);
s := string(Result);
until (list = '') or (Screen.fonts.IndexOf(s) >= 0);
{ s := chop(AnsiString(';'),list);
while (list>'') and (screen.fonts.IndexOf(s) < 0) do
s:=chop(AnsiString(';'), list);
result:= s; }
end; // fontAvailable
// function parseFont(prefix:string; k, v : String; font : TFont):boolean;
// function parseFont(prefix:string; k, v : String; var fontProp : TFontObj):boolean;
function parseFont(prefix: AnsiString; k, v, ppar: AnsiString): Boolean;
var
i: Integer;
s: AnsiString;
fontProp: TFontObj;
begin
Result := True;
fontProp := TFontObj.Create;
if k = prefix + '.name' then
begin
fontProp.flags := fontProp.flags or FPT_NAME;
s := fontAvailable(v);
{$IFDEF UNICODE}
// fontProp.name := AnsiStrAlloc(Length(s)+1);
fontProp.name := StrAlloc(Length(s) + 1);
{$ELSE nonUNICODE}
fontProp.name := StrAlloc(Length(s) + 1);
{$ENDIF UNICODE}
StrPCopy(fontProp.name, s);
// font.name:=fontAvailable(v);
end
else if k = prefix + '.size' then
begin
fontProp.flags := fontProp.flags or FPT_SIZE;
fontProp.size := strToInt(v)
// font.size:=strToInt(v)
end
else if k = prefix + '.color' then
begin
fontProp.flags := fontProp.flags or FPT_COLOR;
fontProp.color := str2color(v)
// font.color:=str2color(v)
end
else if k = prefix + '.charset' then
begin
fontProp.flags := fontProp.flags or FPT_CHARSET;
if isOnlyDigits(v) then
fontProp.charset := strToInt(v)
// font.charset:=strToInt(v)
else if IdentToCharset(v, i) then
fontProp.charset := i
// font.charset:=i
else if IdentToCharset(v + '_CHARSET', i) then
fontProp.charset := i
// font.charset:=i
else
begin
Result := false;
// Exit;
end;
end
else if k = prefix + '.style' then
begin
fontProp.flags := fontProp.flags or FPT_STYLE;
fontProp.style := str2fontstyle(v)
// font.style:=str2fontstyle(v)
end
else
Result := false;
if Result then
addProp(ppar, fontProp);
fontProp.Free;
end; // parseFont
procedure parseFontFile(v: AnsiString; picName: TPicName = '');
(* var
s : RawByteString;
fn: AnsiString;
x,y,dx,dy, idx:integer;
w, h : Integer;
tempFont : RawByteString;
hnd : THandle;
I: Integer;
fCnt : DWORD; *)
begin
{ s:=v;
fn:=chop(RawByteString(';'),s);
if fn='' then exit;
{ tempFont := loadFromZipOrFile(ts.zp, ts.path, fn);
hnd := AddFontMemResourceEx(@tempFont[1], Length(tempFont), 0, @fCnt);
if hnd > 0 then
begin
end;
}
end;
var
k, v: RawByteString;
txt, line: RawByteString;
param: AnsiString; // <20><> <20><> <20><>: roaster, menu, tip, history
prefix: AnsiString; // Prefix for Font and other...
par: AnsiString;
LastSmile: AnsiString;
i: Integer;
loadedpic: TRnQBitmap;
themePic: TThemePic;
// loadedpic : TRnQBitmap;
{$IFDEF RNQ_FULL}
loadedAniPic: TRnQAni;
// loadedAniPic : TRnQBitmap;
{$ENDIF RNQ_FULL}
section: TRQsection;
NonAnimated: Boolean;
hasSmilePic: Boolean;
Parsed: Boolean;
// loadedFontProp : TFontProps;
begin
ts.path := ts.path + ExtractFilePath(fn);
ts.path := includeTrailingPathDelimiter(ts.path);
if IsPathDelimiter(ts.path, 1) then
Delete(ts.path, 1, 1);
fn := ExtractFileName(fn);
if fn = '' then
Exit;
// path:=ExtractFilePath(fn);
inc(curToken);
{$IFNDEF NOT_USE_GDIPLUS}
loadedpic := TRnQBitmap.Create(icon_size, icon_size, PixelFormat32bppARGB);
{$ELSE NOT_USE_GDIPLUS}
loadedpic := TRnQBitmap.Create(icon_size, icon_size);
loadedpic.MakeEmpty;
{$ENDIF NOT_USE_GDIPLUS}
addProp(PIC_EMPTY, TP_ico, loadedpic);
loadedpic.Free;
loadedpic := NIL;
loadedAniPic := NIL;
NonAnimated := True;
themePic := NIL;
LastPicIDX := -1;
hasSmilePic := false;
section := _null;
SetLength(prefix, 0);
txt := loadFile(ts, fn);
while txt > '' do
try
line := chopline(txt);
par := trim(line);
line := trim(chop('#', line));
if (line = '') or ((line[1] = ';') and not((section = _smiles) and hasSmilePic)) then
continue;
if (line[1] = '[') and (line[Length(line)] = ']') then
begin
param := AnsiLowerCase(copy(line, 2, Length(line) - 2));
i := pos(AnsiString('.'), param);
if i > 0 then
begin
k := copy(param, 1, i - 1);
prefix := copy(param, i + 1, 100) + '.';
i := findInStrings(k, RQsectionLabels);
k := '';
end
else
begin
i := findInStrings(param, RQsectionLabels);
SetLength(prefix, 0);
end;
if i < 0 then
begin
if (section = _smiles) and hasSmilePic then
else
begin
section := _null;
continue;
end;
end
else
begin
section := TRQsection(i);
continue;
end;
end;
v := line;
k := trim(chop('=', v));
v := trim(v);
if k = 'include' then
begin
loadThemeScript(UnUTF(v), ts);
continue;
end;
if section in [_smiles, _smile] then
begin
if useTSC in [tsc_all, tsc_smiles] then
begin
v := line;
k := trim(chop(';', v));
if isSupportedPicFile(UnUTF(k)) then
begin
if Assigned(loadedpic) then
loadedpic.Free;
loadedpic := NIL;
NonAnimated := True;
line := k;
i := str2valor(chop(';', v));
LastSmile := '';
// loadedPic := TRnQBitmap.Create;
hasSmilePic := loadPic(ts, UnUTF(line), loadedpic, i);
if hasSmilePic then
begin
NonAnimated := not loadedpic.Animated;
if not NonAnimated then
begin
loadedAniPic := loadedpic;
// loadedpic := loadedAniPic.CloneFrame(-1);
if (i < 1) or (i > loadedAniPic.NumFrames) then
i := 1;
loadedAniPic.CurrentFrame := i;
loadedpic := loadedAniPic.CloneFrame(-1);
end;
end
else
msgDlg(getTranslation('Can''t load smile file: ') + UnUTF(line), false, mtError);
end
else if AnsiStartsText(AnsiString('@pics.'), k) then
begin
LastSmile := '';
FreeAndNil(themePic);
NonAnimated := True;
themePic := parsePic(True, line);
if Assigned(themePic) then
hasSmilePic := True;
// loadedPic := TRnQBitmap.Create;
// hasSmilePic := loadPic(ts, line, loadedpic, i);
// addSmile(
end
else if hasSmilePic then
begin
i := -1;
if LastSmile = '' then
begin
// LastSmile := line;
LastSmile := par;
{$IFDEF RNQ_FULL}
if not NonAnimated then
i := addProp(LastSmile, loadedAniPic)
else if Assigned(loadedAniPic) then
loadedAniPic.Free;
loadedAniPic := NIL;
{$ENDIF RNQ_FULL}
end;
if section = _smile then
Parsed := True // <20><> Stretch <20><> <20><>
else
Parsed := false;
// addProp(LastSmile, line, loadedPic, Parsed, not NonAnimated, i);
addProp(LastSmile, string(par), loadedpic, themePic, Parsed, not NonAnimated, i);
loadedpic := NIL;
// FreeAndNil(loadedPic);
{$IFDEF RNQ_FULL}
if Assigned(loadedAniPic) then
loadedAniPic.Free;
loadedAniPic := NIL;
{$ENDIF RNQ_FULL}
end;
end;
continue;
end
else // not in [_smiles, _smile]
// if (section in [_pics, _icons]) then
if (section in [_pics, _icons, _ico]) then
begin
FreeAndNil(themePic);
themePic := parsePic(false, v);
addProp(prefix + k, TP_pic, themePic);
FreeAndNil(themePic);
end
else if section = _sounds then
begin
addProp(k, ts, TP_sound, fullpath(UnUTF(v)));
end
else if section = _str then
begin
addProp(k, ts, TP_string, UnUTF(ansiReplaceStr(v, AnsiString('\n'), CRLF)));
end
else if section = _desc then
begin
if desc > '' then
desc := desc + CRLF;
desc := desc + UnUTF(ansiReplaceStr(line, AnsiString('\n'), CRLF));
// v := GetString('desc', false) + CRLF + ansiReplaceStr(line,'\n',CRLF);
addProp('desc', ts, TP_string, desc);
end
else if section = _fontfile then
begin
parseFontFile(v);
end
else if section = _null then
begin
Parsed := false;
k := AnsiLowerCase(k);
i := pos(AnsiString('.pic'), k);
if i > 0 then
begin
prefix := copy(k, 1, i - 1);
if prefix = '' then
par := param
else if param > '' then
par := param + '.' + prefix
else
par := prefix;
begin
FreeAndNil(themePic);
themePic := parsePic(false, v);
addProp(par, TP_pic, themePic);
FreeAndNil(themePic);
// FreeAndNil(loadedPic);
// parsePic(v, loadedPic);
// addProp(par, TP_pic, loadedPic);
// FreeAndNil(loadedPic);
end;
Parsed := True;
end;
i := pos(AnsiString('font'), k);
if i > 0 then
begin
prefix := copy(k, 1, i - 2);
if prefix = '' then
par := param
else if param = '' then
par := prefix
else
par := param + '.' + prefix;
if prefix = '' then
// parsed := parseFont('font', k, v, loadedFontProp)
Parsed := parseFont('font', k, v, par)
else
// parsed := parseFont(prefix + '.font', k, v, loadedFontProp);
Parsed := parseFont(prefix + '.font', k, v, par);
end;
if Parsed then
// addProp(par, loadedFontProp)
else if pos(AnsiString('color'), k) > 0 then
begin
i := pos(AnsiString('color'), k);
prefix := copy(k, 1, i - 2) + copy(k, i + 5, Length(k));
if Length(param) > 0 then
if Length(prefix) > 0 then
par := param + '.' + prefix
else
par := param
else
par := prefix;
addProp(par, str2color(v))
end
else if pos(AnsiString('sound'), k) > 0 then
begin
i := pos(AnsiString('sound'), k);
prefix := copy(k, 1, i - 2) + copy(k, i + 5, Length(k));
if Length(param) > 0 then
if Length(prefix) > 0 then
par := param + '.' + prefix
else
par := param
else
par := prefix;
addProp(par, ts, TP_sound, fullpath(UnUTF(v)));
end
else
begin
if Length(param) > 0 then
if Length(k) > 0 then
par := param + '.' + k
else
par := param
else if Length(k) > 0 then
par := k
else
par := v;
addProp(par, ts, TP_string, UnUTF(ansiReplaceStr(v, AnsiString('\n'), CRLF)));
end;
end;
except
end;
if Assigned(loadedpic) then
loadedpic.Free;
loadedpic := NIL;
if Assigned(loadedAniPic) then
loadedAniPic.Free;
loadedAniPic := NIL;
// FreeAndNil(LastLoadedPic);
end; // loadThemeScript
function TRQtheme.drawPic(DC: HDC; pX, pY: Integer; const picName: TPicName; pEnabled: Boolean = True): Tsize;
var
i: Integer;
// gr : TGPGraphics;
// ia : timage
// pic : TRnQBitmap;
begin
{ pic := TRnQBitmap.Create;
GetPic(picName, pic);
result:=drawPic(cnv,x,y, pic);
pic.Free; }
try
i := FThemePics.IndexOf(AnsiLowerCase(picName));
if i >= 0 then
begin
with TThemePic(FThemePics.Objects[i]) do
if FBigPics[picIdx].bmp <> nil then
begin
Result.cx := r.width;
Result.cy := r.height;
DrawRbmp(DC, FBigPics[picIdx].bmp, MakeRectI(pX, pY, Result.cx, Result.cy), r, pEnabled);
end
end
else
begin
i := FIntPics.IndexOf(AnsiLowerCase(picName));
if i >= 0 then
begin
// result.cx:=TRnQBitmap(FIntPics.Objects[i]).GetWidth;
// result.cy:=TRnQBitmap(FIntPics.Objects[i]).GetHeight;
Result.cx := icon_size;
Result.cy := icon_size;
if pEnabled then
ImageList_Draw(FIntPicsIL, i, DC, pX, pY, ILD_TRANSPARENT)
else
ImageList_Draw(FIntPicsIL, i, DC, pX, pY, ILD_TRANSPARENT or ILD_BLEND25);
// gr := TGPGraphics.Create(cnv.Handle);
// gr.DrawImage(TRnQBitmap(FIntPics.Objects[i]), x, y, icon_size, icon_size);
// gr.Free;
end
else
begin
i := FSmilePics.IndexOf(picName);
if i >= 0 then
with TThemePic(FSmilePics.Objects[i]) do
begin
Result.cx := r.width;
Result.cy := r.height;
DrawRbmp(DC, TPicObj(FSmileBigPics[picIdx]).bmp, MakeRectI(pX, pY, Result.cx, Result.cy), r, pEnabled);
end
else
begin
Result.cx := 0;
Result.cy := 0;
// pic := TRnQBitmap.Create;
// pic.Height := 0;
// pic.Width := 0;
// addProp(picName, TP_pic, pic);
// pic.Free;
end
end;
end;
except
Result.cx := 0;
Result.cy := 0;
end;
end;
function TRQtheme.drawPic(DC: HDC; pR: TGPRect; const picName: TPicName; pEnabled: Boolean = True): Tsize;
var
i: Integer;
r1: TGPRect;
begin
if Length(picName) = 0 then
begin
Result.cx := 0;
Result.cy := 0;
Exit;
end;
i := FThemePics.IndexOf(AnsiLowerCase(picName));
if i >= 0 then
with TThemePic(FThemePics.Objects[i]) do
if FBigPics[picIdx].bmp <> nil then
begin
// result.cx := r.Width;
// result.cy := r.Height;
r1 := DestRect(r.size, pR.size);
inc(r1.x, pR.x);
inc(r1.y, pR.y);
Result := GetSize(pR.size);
DrawRbmp(DC, FBigPics[picIdx].bmp, r1, r, pEnabled);
end
else
else
begin
i := FIntPics.IndexOf(AnsiLowerCase(picName));
if i >= 0 then
begin
// result.cx:=TRnQBitmap(FIntPics.Objects[i]).GetWidth;
// result.cy:=TRnQBitmap(FIntPics.Objects[i]).GetHeight;
Result.cx := icon_size;
Result.cy := icon_size;
if pEnabled then
ImageList_Draw(FIntPicsIL, i, DC, pR.x, pR.y, ILD_TRANSPARENT)
// ImageList_DrawEx(FIntPicsIL, i, DC, pX, pY, ILD_TRANSPARENT)
else
ImageList_Draw(FIntPicsIL, i, DC, pR.x, pR.y, ILD_TRANSPARENT or ILD_BLEND25)
// gr := TGPGraphics.Create(cnv.Handle);
// gr.DrawImage(TRnQBitmap(FIntPics.Objects[i]), x, y, icon_size, icon_size);
// gr.Free;
end
else
begin
i := FSmilePics.IndexOf(picName);
if i >= 0 then
with TThemePic(FSmilePics.Objects[i]) do
begin
// result.cx := r.Width;
// result.cy := r.Height;
r1 := DestRect(r.size, pR.size);
Result := GetSize(pR.size);
inc(r1.x, pR.x);
inc(r1.y, pR.y);
DrawRbmp(DC, TPicObj(FSmileBigPics[picIdx]).bmp, r1, r, pEnabled);
end
else
begin
Result.cx := 0;
Result.cy := 0;
// pic := TRnQBitmap.Create;
// pic.Height := 0;
// pic.Width := 0;
// addProp(picName, TP_pic, pic);
// pic.Free;
end
end;
end;
end;
{$IFNDEF NOT_USE_GDIPLUS}
function TRQtheme.drawPic(gr: TGPGraphics; x, y: Integer; picName: string; pEnabled: Boolean = True): Tsize;
var
i: Integer;
// pic : TRnQBitmap;
begin
{ pic := TRnQBitmap.Create;
GetPic(picName, pic);
result:=drawPic(cnv,x,y, pic);
pic.Free; }
i := FThemePics.IndexOf(AnsiLowerCase(picName));
if i >= 0 then
if TPicObj(FBigPics.Objects[TThemePic(FThemePics.Objects[i]).picIdx]).bmp <> nil then
begin
Result.cx := TThemePic(FThemePics.Objects[i]).width;
Result.cy := TThemePic(FThemePics.Objects[i]).height;
// gr.DrawImage(TRnQBitmap(FGPpics.Objects[i]), x, y,result.cx, result.cy);
gr.DrawImage(TPicObj(FBigPics.Objects[TThemePic(FThemePics.Objects[i]).picIdx]).bmp, MakeRect(x, y, Result.cx, Result.cy),
// x, y,
TThemePic(FThemePics.Objects[i]).Left, TThemePic(FThemePics.Objects[i]).Top, Result.cx, Result.cy, UnitPixel);
// gr.DrawImage(TRnQBitmap(FGPpics.Objects[i]), x, y, 0, 0,
// result.cx, result.cy, UnitPixel);
end
else
else
begin
{ i := FIntPics.IndexOf(AnsiLowerCase(picName));
if i >= 0 then
begin
// result.cx:=TRnQBitmap(FIntPics.Objects[i]).GetWidth;
// result.cy:=TRnQBitmap(FIntPics.Objects[i]).GetHeight;
// gr.DrawImage(TRnQBitmap(FIntPics.Objects[i]), x, y);
// gr.DrawImage(TRnQBitmap(FIntPics.Objects[i]), x, y, 0, 0,
// result.cx, result.cy, UnitPixel);
result.cx:= icon_size;
result.cy:= icon_size;
imageList_
if pEnabled then
ImageList_Draw(FIntPicsIL, i, cnv.Handle, x, y, ILD_TRANSPARENT)
else
ImageList_Draw(FIntPicsIL, i, cnv.Handle, x, y, ILD_TRANSPARENT or ILD_BLEND);
gr.DrawImage(TRnQBitmap(FIntPics.Objects[i]), x, y,result.cx, result.cy);
// gr.DrawImage(TRnQBitmap(FIntPics.Objects[i]), x, y, 0, 0,
// result.cx, result.cy, UnitPixel);
end
else }
begin
Result.cx := 0;
Result.cy := 0;
// pic := TRnQBitmap.Create;
// pic.Height := 0;
// pic.Width := 0;
// addProp(picName, TP_pic, pic);
// pic.Free;
end
end;
end;
{$ENDIF NOT_USE_GDIPLUS}
// function TRQtheme.drawPic(DC: HDC; x,y:integer; var picElm : TRnQThemedElementDtls):Tsize;
function TRQtheme.drawPic(DC: HDC; p: TPoint; var picElm: TRnQThemedElementDtls): Tsize;
var
po: TPicObj;
crd: Cardinal;
begin
initPic(picElm);
if picElm.picIdx = -1 then
begin
Result.cx := 0;
Result.cy := 0;
Exit;
end;
case picElm.Loc of
PL_pic:
begin
// TRnQBitmap(FGPpics.Objects[picIdx]).SetResolution(
with TThemePic(FThemePics.Objects[picElm.picIdx]) do
begin
Result.cx := r.width;
Result.cy := r.height;
po := FBigPics[picIdx];
// if po is TPicObj then
if Assigned(po) then
begin
DrawRbmp(DC, po.bmp,
// MakeRect(p.X, p.Y, result.cx, result.cy),
MakeRect(MakePoint(p), r.size), r, picElm.pEnabled);
end;
end;
end;
PL_int:
begin
if picElm.pEnabled then
crd := ILD_TRANSPARENT
else
crd := ILD_TRANSPARENT or ILD_BLEND25;
ImageList_Draw(FIntPicsIL, picElm.picIdx, DC, p.x, p.y, crd);
{
gr := TGPGraphics.Create(cnv.Handle);
gr.SetInterpolationMode(InterpolationModeHighQualityBicubic);
gr.DrawImage(TRnQBitmap(FIntPics.Objects[picIdx]), x, y, icon_size, icon_size);
// gr.DrawImage(TRnQBitmap(FIntPics.Objects[picIdx]), x, y);
gr.Free; }
Result.cx := icon_size;
Result.cy := icon_size;
// result.cx:=TRnQBitmap(FIntPics.Objects[picIdx]).GetWidth;
// result.cy:=TRnQBitmap(FIntPics.Objects[picIdx]).GetHeight;
end;
PL_Ani:
begin
// gr := TGPGraphics.Create(cnv.Handle);
// gr.DrawImage(TRnQAni(FAniSmls.Objects[picIdx]), x, y);
// gr.Free;
with TRnQAni(FAniSmls.Objects[picElm.picIdx]) do
begin
Draw(DC, p.x, p.y);
Result.cx := width;
Result.cy := height;
end;
end;
PL_Smile:
with TThemePic(FSmilePics.Objects[picElm.picIdx]) do
begin
Result.cx := r.width;
Result.cy := r.height;
po := FSmileBigPics[picIdx];
if Assigned(po) then
begin
DrawRbmp(DC, po.bmp,
// MakeRect(p.X, p.Y, result.cx, result.cy),
MakeRect(MakePoint(p), r.size), r, picElm.pEnabled);
end;
end;
else
begin
Result.cx := 0;
Result.cy := 0;
end;
end
end;
function TRQtheme.drawPic(DC: HDC; pR: TGPRect; var picElm: TRnQThemedElementDtls): Tsize;
var
// i : Integer;
r1: TGPRect;
po: TPicObj;
crd: Cardinal;
begin
initPic(picElm);
if picElm.picIdx = -1 then
begin
Result.cx := 0;
Result.cy := 0;
Exit;
end;
case picElm.Loc of
PL_pic:
with TThemePic(FThemePics.Objects[picElm.picIdx]) do
if FBigPics[picIdx].bmp <> nil then
begin
// result.cx := r.Width;
// result.cy := r.Height;
r1 := DestRect(r.size, pR.size);
Result.cx := r1.x + r1.width;
Result.cy := r1.y + r1.height;
// inc(r1.X, pR.X);
// inc(r1.Y, pR.Y);
r1.TopLeft := pR.TopLeft;
// result := tsize(r1.size);
po := FBigPics[picIdx];
// if po is TPicObj then
if Assigned(po) then
begin
DrawRbmp(DC, po.bmp,
// MakeRect(p.X, p.Y, result.cx, result.cy),
r1, r, picElm.pEnabled);
end;
end;
PL_int:
begin
r1 := DestRect(icon_size, icon_size, pR.width, pR.height);
Result.cx := r1.x + r1.width;
Result.cy := r1.y + r1.height;
// result.cx:= icon_size;
// result.cy:= icon_size;
inc(r1.x, pR.x);
inc(r1.y, pR.y);
if picElm.pEnabled then
crd := ILD_TRANSPARENT
else
crd := ILD_TRANSPARENT or ILD_BLEND25;
// ImageList_Draw(FIntPicsIL, picElm.picIdx, DC, pR.X, pR.Y, crd);
ImageList_DrawEx(FIntPicsIL, picElm.picIdx, DC, r1.x, r1.y, r1.width, r1.height, CLR_NONE, CLR_NONE, crd);
end;
PL_Ani:
begin
// gr := TGPGraphics.Create(cnv.Handle);
// gr.DrawImage(TRnQAni(FAniSmls.Objects[picIdx]), x, y);
// gr.Free;
with TRnQAni(FAniSmls.Objects[picElm.picIdx]) do
begin
r1 := DestRect(width, height, pR.width, pR.height);
inc(r1.x, pR.x);
inc(r1.y, pR.y);
Draw(DC, r1);
// result.cx := Width;
// result.cy := Height;
Result := GetSize(pR.size);
end;
end;
PL_Smile:
with TThemePic(FSmilePics.Objects[picElm.picIdx]) do
begin
Result.cx := r.width;
Result.cy := r.height;
po := FSmileBigPics[picIdx];
if Assigned(po) then
begin
r1 := DestRect(r.size, pR.size);
Result := GetSize(pR.size);
inc(r1.x, pR.x);
inc(r1.y, pR.y);
DrawRbmp(DC, po.bmp, r1, r, picElm.pEnabled);
end;
end;
else
begin
Result.cx := 0;
Result.cy := 0;
end;
end;
end;
// To Get pic with Alpha channel
function TRQtheme.getPic(DC: HDC; p: TPoint; var picElm: TRnQThemedElementDtls; var is32Alpha: Boolean): Tsize;
var
po: TPicObj;
begin
initPic(picElm);
if picElm.picIdx = -1 then
begin
Result.cx := 0;
Result.cy := 0;
Exit;
end;
case picElm.Loc of
PL_pic:
begin
// TRnQBitmap(FGPpics.Objects[picIdx]).SetResolution(
with TThemePic(FThemePics.Objects[picElm.picIdx]) do
begin
Result.cx := r.width;
Result.cy := r.height;
po := FBigPics[picIdx];
if Assigned(po) then
// if po is TPicObj then
begin
is32Alpha := po.bmp.f32Alpha;
// GetBmp32(DC, po.bmp,
DrawRbmp(DC, po.bmp,
// MakeRect(p.X, p.Y, result.cx, result.cy),
MakeRect(MakePoint(p), r.size), r, picElm.pEnabled, True);
end;
end;
end;
else
begin
Result.cx := 0;
Result.cy := 0;
end;
end
end;
{$IFNDEF NOT_USE_GDIPLUS}
function TRQtheme.drawPic(gr: TGPGraphics; x, y: Integer; picName: string; var ThemeToken: Integer; var picLoc: TPicLocation;
var picIdx: Integer; pEnabled: Boolean = True): Tsize;
var
DC: HDC;
ia: TGPImageAttributes;
// tb : TRnQBitmap;
// tgr : TGPGraphics;
begin
initPic(picName, ThemeToken, picLoc, picIdx);
if picIdx = -1 then
begin
Result.cx := 0;
Result.cy := 0;
Exit;
end;
case picLoc of
PL_pic:
begin
// TRnQBitmap(FGPpics.Objects[picIdx]).SetResolution(
Result.cx := TThemePic(FThemePics.Objects[picIdx]).width;
Result.cy := TThemePic(FThemePics.Objects[picIdx]).height;
if FBigPics.Objects[TThemePic(FThemePics.Objects[picIdx]).picIdx] is TPicObj then
begin
// gr.DrawImage(TRnQBitmap(FGPpics.Objects[i]), x, y,result.cx, result.cy);
DrawRbmp(gr, TPicObj(FBigPics.Objects[TThemePic(FThemePics.Objects[picIdx]).picIdx]).bmp,
MakeRect(x + 1, y + 1, Result.cx, Result.cy), TThemePic(FThemePics.Objects[picIdx]).Left,
TThemePic(FThemePics.Objects[picIdx]).Top, Result.cx, Result.cy, pEnabled);
end;
end;
PL_int:
begin
// tb := TRnQBitmap.Create(icon_size, icon_size, gr);
// tgr := TGPGraphics.Create(tb);
DC := gr.GetHDC;
if pEnabled then
ImageList_Draw(FIntPicsIL, picIdx, DC, x, y, ILD_TRANSPARENT)
else
ImageList_Draw(FIntPicsIL, picIdx, DC, x, y, ILD_TRANSPARENT or ILD_BLEND25);
// gr.DrawImage(TRnQBitmap(FIntPics.Objects[picIdx]), x, y, icon_size, icon_size);
// gr.DrawImage(TRnQBitmap(FIntPics.Objects[picIdx]), x, y);
gr.ReleaseHDC(DC);
// tgr.Free;
// gr.DrawImage(tb, 0, 0, icon_size, icon_size);
// tb.Free;
Result.cx := icon_size;
Result.cy := icon_size;
// result.cx:=TRnQBitmap(FIntPics.Objects[picIdx]).GetWidth;
// result.cy:=TRnQBitmap(FIntPics.Objects[picIdx]).GetHeight;
end;
{ PL_Ani:
begin
// gr := TGPGraphics.Create(cnv.Handle);
// gr.DrawImage(TRnQAni(FAniSmls.Objects[picIdx]), x, y);
// gr.Free;
// TRnQAni(FAniSmls.Objects[picIdx]).Draw(gr, x, y);
// dc := gr.GetHDC;
// TRnQAni(FAniSmls.Objects[picIdx]).Draw(dc, x, y);
// gr.ReleaseHDC(dc);
result.cx:=TRnQAni(FAniSmls.Objects[picIdx]).Width;
result.cy:=TRnQAni(FAniSmls.Objects[picIdx]).Height;
end; }
else
begin
Result.cx := 0;
Result.cy := 0;
end;
end
end;
{$ENDIF NOT_USE_GDIPLUS}
{
function TRQtheme.drawPic(cnv:Tcanvas; x,y:integer; pic:TRnQBitmap):Tsize;
//var
// b : Boolean;
begin
if pic=NIL then exit;
// b := pic.Transparent;
cnv.draw(x,y,pic);
result.cx:=pic.width;
result.cy:=pic.height;
end; // drawPic
}
procedure TRQtheme.ClearThemelist;
procedure Clear1ThemeList(var tl: aThemeInfo);
var
t: ToThemeinfo;
i: Integer;
begin
for t in tl do
begin
begin
SetLength(t.fn, 0);
SetLength(t.subFile, 0);
SetLength(t.title, 0);
SetLength(t.desc, 0);
SetLength(t.logo, 0);
t.Free;
end;
end;
SetLength(tl, 0);
end;
begin
Clear1ThemeList(themelist2);
Clear1ThemeList(smileList);
Clear1ThemeList(soundList);
end;
procedure TRQtheme.refreshThemeList;
procedure ProcessFile(Const fn, subFile: String; s: RawByteString);
var
line, k, v, section: RawByteString;
procedure InternalprocessTheme(var ati: aThemeInfo);
var
n: Integer;
begin
n := Length(ati);
SetLength(ati, n + 1);
ati[n] := ToThemeinfo.Create;
ati[n].fn := fn;
ati[n].subFile := subFile;
section := '';
while s > '' do
begin
line := chopline(s);
if (line > '') and (line[1] = '[') then
begin
line := trim(line);
if line[Length(line)] = ']' then
section := copy(line, 2, Length(line) - 2);
continue;
end;
v := trim(line);
k := AnsiLowerCase(trim(chop('=', v)));
v := trim(v);
if section = '' then
begin
if k = 'logo' then
ati[n].logo := UnUTF(v);
if k = 'title' then
ati[n].title := UnUTF(v);
if k = 'desc' then
ati[n].desc := ansiReplaceStr(UnUTF(v), '\n', CRLF);
end;
v := '';
if section = 'desc' then
with ati[n] do
desc := desc + UnUTF(line) + CRLF;
end;
with ati[n] do
desc := trimright(desc);
end;
begin
line := trim(chopline(s));
if (line = '&RQ theme file version 1') or (line = 'R&Q theme file version 1') then
begin
InternalprocessTheme(themelist2);
end
else if (line = 'R&Q smiles file version 1') then
begin
InternalprocessTheme(smileList);
end;
if (line = 'R&Q sounds file version 1') then
begin
InternalprocessTheme(soundList);
end;
end;
procedure addDefTheme(var ati: aThemeInfo);
var
n: Integer;
// line,k,v,section : String;
begin
n := Length(ati);
SetLength(ati, n + 1);
ati[n] := ToThemeinfo.Create;
ati[n].fn := '';
ati[n].subFile := '';
ati[n].title := 'From theme';
end;
var
sr: TSearchRec;
i, e: Integer;
// str: TStringStream;
str2: TMemoryStream;
ts: TThemeSourcePath;
fn: String;
// subFile,
sA: RawByteString;
w: string;
// theme_paths : array[0..1] of string;
theme_paths: array [0 .. 0] of string;
// for RAR
{$IFDEF USE_RAR}
// hArcData: THandle;
RHCode, PFCode: Integer;
CmtBuf: array [0 .. Pred(16384)] of Char;
HeaderData: RARHeaderDataEx;
OpenArchiveData: RAROpenArchiveDataEx;
Operation: Integer;
{ IsDirectory : Boolean; }
StreamPointer: Pointer;
{$ENDIF USE_RAR}
ti: Integer;
begin
theme_paths[0] := fBasePath + themesPath;
// theme_paths[1] := myPath; // For *.rtz
// n:=0;
ClearThemelist;
addDefTheme(smileList);
addDefTheme(soundList);
for e := 0 to Length(ThemeInis) - 1 do
begin
if findFirst(theme_paths[0] + '*' + ThemeInis[e], faAnyFile, sr) = 0 then
repeat
if sr.name[1] <> '.' then
begin
fn := sr.name;
sA := loadFileA(theme_paths[0] + fn);
ProcessFile(fn, '', sA);
end;
until findNext(sr) <> 0;
findClose(sr);
end;
{$IFDEF USE_ZIP}
for ti := Low(theme_paths) to High(theme_paths) do
for e := 0 to Length(ZipThemes) - 1 do
begin
if findFirst(theme_paths[ti] + '*' + ZipThemes[e], faAnyFile, sr) = 0 then
repeat
if sr.name[1] <> '.' then
begin
fn := sr.name;
// zp := TKAZip.Create(NIL);
// zp.Open(myPath+themesPath+fn);
// if zp.IsZipFile > 0 then
ts.zp := TZipFile.Create;
ts.zp.LoadFromFile(theme_paths[ti] + fn);
if ts.zp.Count > 0 then
begin
{ for I := 0 to zp.Entries.Count - 1 do
if (LastDelimiter('\/:', zp.Entries.Items[i].FileName) <= 0)and
(ExtractFileExt(zp.Entries.Items[i].FileName) = '.ini') then }
for i := 0 to ts.zp.Count - 1 do
begin
w := ts.zp.name[i];
if (LastDelimiter('\/:', w) <= 0) and (RnQEndsText(ThemeInis[0], w) or RnQEndsText(ThemeInis[1], w) or
RnQEndsText(ThemeInis[2], w)) then
// (ExtractFileExt(zp.Name[i]) = '.ini') then
begin
// str := TStringStream.Create('');
// zp.ExtractToStream(zp.Entries.Items[i], str);
sA := ts.zp.Data[i];
ProcessFile(fn, w, sA);
sA := '';
end;
end;
ts.zp.Free;
end;
end;
until findNext(sr) <> 0;
findClose(sr);
end;
{$ENDIF USE_ZIP}
{$IFDEF USE_7Z}
// '*.7z;*.7zip;*.rt7'
try
// ts.z7 := TSevenZip.Create(NIL);
// ts.z7 := T7zInArchive.Create('7za.dll');
ts.z7 := CreateInArchive(CLSID_CFormat7z);
except
ts.z7 := NIL;
end;
if Assigned(ts.z7) then
for e := 0 to Length(SevenZipThemes) - 1 do
begin
if findFirst(theme_paths[0] + '*' + SevenZipThemes[e], faAnyFile, sr) = 0 then
repeat
if sr.name[1] <> '.' then
begin
fn := sr.name;
// zp := TKAZip.Create(NIL);
// zp.Open(myPath+themesPath+fn);
// if zp.IsZipFile > 0 then
// ts.z7.SZFileName := theme_paths[0] + fn;
// zp.LoadFromFile(myPath+themesPath+fn);
ts.z7.OpenFile(theme_paths[0] + fn);
if ts.z7.NumberOfItems > 0 then
begin
for i := 0 to ts.z7.NumberOfItems - 1 do
begin
// w := ts.z7.Files.WStrings[i];
w := ts.z7.getItemPath(i);
if (LastDelimiter('\/:', w) <= 0) and
// (ExtractFileExt(zp.Name[i]) = '.ini')
(RnQEndsText(ThemeInis[0], w) or RnQEndsText(ThemeInis[1], w) or RnQEndsText(ThemeInis[2], w)) then
begin
// subFile := ;
// str := TStringStream.Create('');
str2 := TMemoryStream.Create();
try
ts.z7.ExtractItem(i, str2, false);
if str2.size > 0 then
begin
SetLength(sA, str2.size);
CopyMemory(Pointer(sA), str2.Memory, Length(sA));
ProcessFile(fn, w, sA);
end;
finally
sA := '';
str2.Free;
end;
end;
end;
ts.z7.Close;
end;
end;
until findNext(sr) <> 0;
findClose(sr);
end;
// FreeAndNil(ts.z7);
ts.z7 := NIL;
{$ENDIF USE_7Z}
{$IFDEF USE_RAR}
// '*.rar;*.rtr'
for e := 0 to Length(RARThemes) - 1 do
begin
if findFirst(theme_paths[0] + '*' + RARThemes[e], faAnyFile, sr) = 0 then
repeat
if sr.name[1] <> '.' then
begin
if not IsRARDLLLoaded then
begin
// if aRARGetDllVersion > 0 then
LoadRarLibrary;
if not IsRARDLLLoaded then
break;
end;
fn := sr.name;
ts.pathType := pt_rar;
ts.ArcFile := theme_paths[0] + fn;
ts.path := '';
// FillMemory(@OpenArchiveData.Reserved, SizeOf(OpenArchiveData.Reserved), 0);
FillMemory(@OpenArchiveData, SizeOf(OpenArchiveData), 0);
{$IFDEF UNICODE}
OpenArchiveData.ArcName := '';
OpenArchiveData.ArcNameW := PWideChar(ts.ArcFile);
{$ELSE nonUNICODE}
OpenArchiveData.ArcName := PAnsiChar(ts.ArcFile);
OpenArchiveData.ArcNameW := '';
{$ENDIF UNICODE}
OpenArchiveData.CmtBuf := @CmtBuf;
OpenArchiveData.CmtBufSize := SizeOf(CmtBuf);
// OpenArchiveData.OpenMode := RAR_OM_LIST;
OpenArchiveData.OpenMode := RAR_OM_EXTRACT;
try
ts.RarHnd := RAROpenArchiveEx(OpenArchiveData);
except
ts.RarHnd := 0;
OpenArchiveData.OpenResult := MAXWORD;
end;
if (OpenArchiveData.OpenResult = 0) then
begin
// RARSetCallback (ts.RarHnd, CallbackProc, 0);
FillMemory(@HeaderData, SizeOf(HeaderData), 0);
HeaderData.CmtBuf := @CmtBuf;
HeaderData.CmtBufSize := SizeOf(CmtBuf);
repeat
RHCode := RARReadHeaderEx(ts.RarHnd, HeaderData);
if RHCode <> 0 then
break;
// Write(CR, SFmt(HeaderData.FileName, 39), ' ',
// (HeaderData.UnpSize + HeaderData.UnpSizeHigh * 4294967296.0):10:0);
{ IsDirectory := (HeaderData.Flags and $00000070) = $00000070; }
// if not IsDirectory then
begin
// ListView1.AddItem(HeaderData.FileName, nil);
{$IFDEF UNICODE}
w := AnsiLowerCase(StrPas(HeaderData.FileNameW));
{$ELSE ~UNICODE}
w := AnsiLowerCase(StrPas(HeaderData.FileName));
{$ENDIF ~UNICODE}
if (LastDelimiter('\/:', w) <= 0) and
// (ExtractFileExt(zp.Name[i]) = '.ini')
RnQEndsText(ThemeInis[0], w) or RnQEndsText(ThemeInis[1], w) or RnQEndsText(ThemeInis[2], w) then
begin
Operation := RAR_TEST;
end
else
Operation := RAR_SKIP;
end;
// if (HeaderData.CmtState = 1) then
// ShowComment(CmtBuf);
// if loadfile(ts, w, TStream(str)) then
// if ts.z7.ExtractToStreamF(i, str) >= 0 then
if Operation = RAR_TEST then
begin
str2 := TMemoryStream.Create();
StreamPointer := @str2;
end
else
StreamPointer := NIL;
try
RARSetCallback(ts.RarHnd, RARCallbackProc, Integer(StreamPointer));
PFCode := RARProcessFile(ts.RarHnd, Operation, nil, nil);
if (PFCode <> 0) then
begin
// OutProcessFileError(PFCode);
continue;
end;
if Operation = RAR_TEST then
begin
if str2.size > 0 then
begin
SetLength(sA, str2.size);
CopyMemory(Pointer(sA), str2.Memory, Length(sA));
ProcessFile(fn, w, sA);
end;
end;
finally
if Operation = RAR_TEST then
str2.Free;
end;
until false;
// if (RHCode = ERAR_BAD_DATA) then
// Write(CR, 'File header broken');
RARCloseArchive(ts.RarHnd);
end;
ts.RarHnd := 0;
// end;
end;
until findNext(sr) <> 0;
findClose(sr);
// end;
if IsRARDLLLoaded then
UnLoadRarLibrary;
end;
ts.RarHnd := 0;
{$ENDIF USE_RAR}
end; // refreshThemelist
{$IFNDEF RNQ_LITE}
procedure TRQtheme.getprops(var PropList: aTthemeProperty);
var
i, l: Integer;
tp: TthemeProperty;
begin
{ for i := 0 to FFonts.Count-1 do
begin
tp.kind := TP_font;
tp.section := RQsectionLabels[_null];
tp.name := FFonts.Strings[i] + '.font';
l := Length(PropList);
SetLength(PropList, l+1);
PropList[l] := tp;
end;
}
for i := 0 to FFonts2.Count - 1 do
begin
tp.kind := TP_font;
tp.section := RQsectionLabels[_null];
tp.name := FFonts2.Strings[i] + '.font';
l := Length(PropList);
SetLength(PropList, l + 1);
PropList[l] := tp;
end;
for i := 0 to FClr.Count - 1 do
begin
tp.kind := TP_color;
tp.section := RQsectionLabels[_null];
tp.name := FClr.Strings[i] + '.color';
l := Length(PropList);
SetLength(PropList, l + 1);
PropList[l] := tp;
end;
for i := 0 to FSounds.Count - 1 do
begin
tp.kind := TP_sound;
tp.section := RQsectionLabels[_sounds];
tp.name := FSounds.Strings[i];
l := Length(PropList);
SetLength(PropList, l + 1);
PropList[l] := tp;
end;
for i := 0 to FThemePics.Count - 1 do
begin
tp.kind := TP_pic;
tp.section := RQsectionLabels[_pics];
tp.name := FThemePics.Strings[i];
l := Length(PropList);
SetLength(PropList, l + 1);
PropList[l] := tp;
end;
for i := 0 to FIntPics.Count - 1 do
begin
tp.kind := TP_ico;
tp.section := RQsectionLabels[_icons];
tp.name := FIntPics.Strings[i];
l := Length(PropList);
SetLength(PropList, l + 1);
PropList[l] := tp;
end;
{ FSmiles : TStringList;
FStr : TStringList; }
for i := 0 to FStr.Count - 1 do
begin
tp.kind := TP_string;
tp.section := RQsectionLabels[_str];
tp.name := FStr.Strings[i];
l := Length(PropList);
SetLength(PropList, l + 1);
PropList[l] := tp;
end;
end;
{$ENDIF RNQ_LITE}
{$IFDEF RNQ_FULL}
function TRQtheme.addProp(name: AnsiString; pic: TRnQAni): Integer;
// var
// Index: Integer;
begin
Result := FAniSmls.Add(name);
FAniSmls.Objects[Result] := pic;
with TRnQAni(FAniSmls.Objects[Result]) do
begin
CurrentFrame := 1;
end;
useAnimated := True;
// result :=index;
end;
{
function TRQtheme.addProp(name:string; pic: TRnQBitmap) : Integer;
//var
// Index: Integer;
begin
// Index:= Length(FsmlList);
// SetLength(smlList, Index+1);
result := FAniSmls.Add(name);
TRnQAni
pic.SelectActiveFrame(FrameDimensionTime, 0);
FAniSmls.Objects[result] := pic;
with TRnQAni(FAniSmls.Objects[result]) do
begin
Visible:= true;
// Animate:= true;
ShowIt:= true;
CurrentFrame := 1;
end;
useAnimated := True;
// result :=index;
end; }
function TRQtheme.GetAniPic(IDX: Integer): TRnQAni;
// var
// i : Integer;
begin
// i := FAnismls.IndexOf(AnsiLowerCase(name));
// if i >= 0 then
// begin
try
Result := TRnQAni(FAniSmls.Objects[IDX]);
except
Result := NIL;
end;
// end
end;
procedure TRQtheme.checkAnimationTime;
var
i: Integer;
begin
// for I:= 0 to Count-1 do
for i := 0 to FAniSmls.Count - 1 do
TRnQAni(FAniSmls.Objects[i]).RnQCheckTime;
end;
procedure TRQtheme.TickAniTimer(Sender: TObject);
var
i: Integer;
// bmp, b1: TRnQBitmap;
b2: TBitmap32;
b2DC: HDC;
paramSmile: TAniPicParams;
// gr, grb : TGPGraphics;
// br : TGPBrush;
begin
// if not UseAnime then Exit;
checkAnimationTime;
(*
if Length(FAniParamList) > 0 then
begin
for i:= 0 to Length(FAniParamList)-1 do
begin
if FAniDrawCnt = 0 then Exit;
if (paramSmile.Bounds.Left = 0) and (paramSmile.Bounds.Top = 0)
then Continue;
paramSmile:= FAniParamList[i];
InvalidateRect(chatFrm.ThisChat.historyBox.Handle, @paramSmile.Bounds, false);
end;
end;
( *)
// tmp_sml := NIL;
// for i := Low(items) to High(items) do
// if items[i].
if Length(FAniParamList) > 0 then
begin
b2 := TBitmap32.Create;
b2.SetSize(1, 1);
b2.height := 0;
for i := 0 to Length(FAniParamList) - 1 do
// for i:= Length(smlList)-1 to 0 do
begin
if (FAniDrawCnt = 0) or not useAnimated then
Exit;
if (paramSmile.Bounds.x = 0) and (paramSmile.Bounds.y = 0)
// <20><> <20><> <20><> <20><>
then
continue;
{ //<2F><> <20><> <20><> <20><>
if hasDownArrow then
if paramSmile.Bounds.Bottom > (Height - hDownArrow)
then Continue;
}
// if (i > Low(FAniParamList)) and (i < High(FAniParamList)) then
paramSmile := FAniParamList[i];
// if paramSmile <> nil then
// if paramSmile.ID = -1 then Continue;
if Assigned(paramSmile.Canvas) then
if paramSmile.IDX >= 0 then
begin
// gr := TGPGraphics.Create(paramSmile.Canvas.Handle);
// if gr.IsVisible(MakeRect(paramSmile.Bounds)) then
with GetAniPic(paramSmile.IDX) do
begin
// bmp:= TRnQBitmap.Create(Width, Height, PixelFormat32bppRGB);
if (b2.width <> width) or (b2.height <> height) then
begin
b2.height := 0;
b2.SetSize(width, height);
end;
b2DC := b2.Canvas.Handle;
{ if Assigned(paramSmile.bg) then
BitBlt(bmp.Canvas.Handle, 0, 0,
bmp.Width, bmp.Height, paramSmile.bg.Canvas.Handle, 0, 0, SRCCOPY)
else }
// grb := TGPGraphics.Create(b2.Canvas.Handle);
// grb.Clear(aclBlack);
// grb := TGPGraphics.c
{ if Assigned(AnibgPic) and (not paramSmile.selected) then
grb.DrawImage(AnibgPic, 0, 0,
paramSmile.Bounds.Left, paramSmile.Bounds.Top,
Width, Height, UnitPixel)
else
begin
grb.Clear(paramSmile.color);
// br := TGPSolidBrush.Create(paramSmile.color);
// grb.FillRectangle(br, 0, 0, Width, Height);
// br.Free;
end;
}
if Assigned(AnibgPic) and (not paramSmile.selected) then
BitBlt(b2DC, 0, 0, b2.width, b2.height, AnibgPic.Canvas.Handle, paramSmile.Bounds.x, paramSmile.Bounds.y, SRCCOPY)
else
begin
b2.Canvas.Brush.color := paramSmile.color;
b2.Canvas.FillRect(b2.Canvas.ClipRect);
end;
// b1 := GeTRnQBitmap;
// b1.SelectActiveFrame(FrameDimensionTime, CurrentFrame-1);
// Draw(grb, 0, 0);
// grb.DrawImage(b1, 0, 0);
// b1.Free;
// grb.Free;
Draw(b2DC, 0, 0);
// BitBlt()
// paramSmile.Canvas.FillRect(paramSmile.Bounds);
// Draw(paramSmile.Canvas, paramSmile.Bounds.Left, paramSmile.Bounds.Top);
// bmp.Transparent := True;
// bmp.TransparentMode := tmAuto;
end;
// if paramSmile.Canvas.HandleAllocated then
// try
// if chat
// gr.DrawImage(bmp, paramSmile.Bounds.Left, paramSmile.Bounds.Top);
// gr.DrawImage(bmp, MakeRect(paramSmile.Bounds));
// gr.Free;
if Assigned(paramSmile.Canvas)
// and (paramSmile.Canvas.HandleAllocated )
then
// BitBlt(paramSmile.Canvas.Handle, paramSmile.Bounds.Left, paramSmile.Bounds.Top,
// bmp.Width, bmp.Height, paramSmile.bg.Canvas.Handle, 0, 0, SRCCOPY);
// TransparentBlt(paramSmile.Canvas.Handle, paramSmile.Bounds.Left, paramSmile.Bounds.Top,
// bmp.Width, bmp.Height, bmp.Canvas.Handle, 0, 0,
// bmp.Width, bmp.Height, bmp.TransparentColor); {LDB}
BitBlt(paramSmile.Canvas.Handle, paramSmile.Bounds.x, paramSmile.Bounds.y, b2.width, b2.height, b2DC, 0, 0, SRCCOPY);
// paramSmile.Canvas.Draw(paramSmile.Bounds.Left,
// paramSmile.Bounds.Top, bmp);
// except
// end;
{ for j:= 0 to paramSmile.Count-1 do
begin
Canvas.Draw((paramSmile.Bounds.Left - j*tmp_sml.Width),
(paramSmile.Bounds.Top), tmp_sml);
end;
}
end;
end;
b2.Free;
end;
end;
procedure TRQtheme.AddAniParam(picIdx: Integer; Bounds: TGPRect; color: TColor; cnv, cnvSrc: TCanvas; Sel: Boolean = false);
begin
inc(FAniDrawCnt);
SetLength(FAniParamList, FAniDrawCnt);
FAniParamList[FAniDrawCnt - 1].IDX := picIdx;
FAniParamList[FAniDrawCnt - 1].Bounds := Bounds;
FAniParamList[FAniDrawCnt - 1].color := color;
FAniParamList[FAniDrawCnt - 1].Canvas := cnv;
FAniParamList[FAniDrawCnt - 1].selected := Sel;
// GetAniPic(PicIdx).Animate := True;
{ if Anipicbg then
begin
FAniParamList[FAniDrawCnt-1].bg := TRnQBitmap.Create;
with FAniParamList[FAniDrawCnt-1].bg do
begin
Height := Bounds.Bottom - Bounds.Top;
Width := Bounds.Right - Bounds.Left;
BitBlt(Canvas.Handle, 0, 0, Width, Height, cnvSrc.Handle,
Bounds.Left, Bounds.Top, SRCCOPY)
end;
end
else
FAniParamList[FAniDrawCnt-1].bg := NIL; }
if not FAniTimer.Enabled then
FAniTimer.Enabled := True;
end;
procedure TRQtheme.ClearAniParams;
// var
// i : Integer;
begin
FAniDrawCnt := 0;
SetLength(FAniParamList, 0);
{ for i := 1 to FAniSmls.Count-1 do
begin
GetAniPic(i).Animate := False;
end;
}
if Assigned(FAniTimer) then
FAniTimer.Enabled := false;
end;
procedure TRQtheme.ClearAniMNUParams;
// var
// i : Integer;
begin
{ FAniDrawMNUCnt:= 0;
SetLength(FAniMNUParamList,0);
for i := 1 to FAniSmls.Count-1 do
begin
GetAniPic(i).Animate := False;
end;
if Assigned(FAniTimer) then
FAniTimer.Enabled := false; }
end;
{$ENDIF RNQ_FULL}
procedure TRQtheme.initThemeIcons;
// var
// i: HICON;
// ic : TIcon;
// icn : TMsgDlgType;
// i : byte;
// hi: HICON;
begin
// ic := TIcon.Create;
// for icn in TMsgDlgTypes do
// for i := Low(TMsgDlgType)
// begin
// ic.handle := LoadIcon(0, IconIDs[icn]);
// addprop(IconNames[icn], ic, true);
// end;
// FIntPics.Objects[FIntPics.Add(PIC_EXCLAMATION)] := TRnQBitmap.Create(0, PWidechar(IDI_EXCLAMATION));
addHIco(PIC_EXCLAMATION, LoadIcon(0, IDI_EXCLAMATION), True);
addHIco(PIC_HAND, LoadIcon(0, IDI_HAND), True);
addHIco(PIC_ASTERISK, LoadIcon(0, IDI_ASTERISK), True);
addHIco(PIC_QUEST, LoadIcon(0, IDI_QUESTION), True);
{
ic.Handle := LoadIcon(0, IDI_EXCLAMATION);
addprop(PIC_EXCLAMATION, LoadIcon(0, IDI_EXCLAMATION), true);
// addprop(PIC_EXCLAMATION, ic, true);
// DestroyIcon(h);
ic.Handle := LoadIcon(0, IDI_HAND);
addprop(PIC_HAND, ic, true);
ic.Handle := LoadIcon(0, IDI_ASTERISK);
addprop(PIC_ASTERISK, ic, true);
ic.Handle := LoadIcon(0, IDI_QUESTION);
addprop(PIC_QUEST, ic, true);
// ic.Handle := LoadIcon(0, IDI_WARNING);
// addprop(PIC_WARNING, ic, true);
// ic.Handle := LoadIcon(0, IDI_ERROR);
// addprop(PIC_ERROR, ic, true);
ic.Free;
}
end;
{$IFDEF NOT_USE_GDIPLUS}
procedure TRQtheme.drawTiled(Canvas: TCanvas; const picName: TPicName);
var
bmp: TBitmap32;
Hdl: HBRUSH;
begin
bmp := TBitmap32.Create;
if GetPicOld(picName, bmp) then
begin
Hdl := CreatePatternBrush(bmp.BitmapHandle);
Canvas.Lock;
Windows.FillRect(Canvas.Handle, Canvas.ClipRect, Hdl);
Canvas.Unlock;
DeleteObject(Hdl);
end;
bmp.Free;
end;
{$ENDIF USE_GDIPLUS}
{$IFNDEF NOT_USE_GDIPLUS}
procedure TRQtheme.drawTiled(Canvas: TCanvas; const picName: TPicName);
var
gr: TGPGraphics;
// bmp : TRnQBitmap;
// Handle : HBrush;
r: TGPRectF;
begin
r.x := 0;
r.y := 0;
r.width := Canvas.ClipRect.Right;
r.height := Canvas.ClipRect.Bottom;
gr := TGPGraphics.Create(Canvas.Handle);
drawTiled(gr, r, picName);
gr.Free;
end;
procedure TRQtheme.drawTiled(gr: TGPGraphics; r: TGPRectF; const picName: TPicName);
var
bmp: TGPImage;
// ia : TGPImageAttributes;
// br : TGPTextureBrush;
br: TGPBrush;
// Handle : HBrush;
begin
// bmp := TRnQBitmap.Create;
bmp := nil;
FdrawCS.Acquire;
try
if GetPic13(picName, bmp) then
begin
// ia := TGPImageAttributes.Create;
// ia.SetWrapMode(WrapModeTile);
// gr.DrawImage(bmp, r, 0, 0 , bmp.GetWidth, bmp.GetHeight, UnitPixel, ia);
// ia.Free;
try
br := TGPTextureBrush.Create(bmp); // , WrapModeTile);
// br := TGPLinearGradientBrush.Create(r, aclAliceBlue, aclLightCyan, 0);
gr.FillRectangle(br, r);
br.Free;
except
end;
end;
finally
FdrawCS.Release;
end;
// Bmp.Free;
end;
procedure TRQtheme.drawStratch(gr: TGPGraphics; r: TGPRectF; const picName: TPicName);
var
bmp: TGPImage;
// br : TGPTextureBrush;
// Handle : HBrush;
begin
// bmp := TRnQBitmap.Create;
bmp := nil;
if GetPic13(picName, bmp) then
begin
gr.DrawImage(bmp, r);
// br := TGPTextureBrush.Create(bmp);//, WrapModeTile);
// gr.FillRectangle(br, r);
// br.Free;
// Handle := CreatePatternBrush(bmp.Handle);
// windows.FillRect(canvas.Handle, canvas.ClipRect, Handle);
// DeleteObject(Handle);
end;
// Bmp.Free;
end;
procedure TRQtheme.drawStratch(gr: TGPGraphics; x, y, w, h: Integer; const picName: TPicName);
var
bmp: TGPImage;
// br : TGPTextureBrush;
// Handle : HBrush;
begin
// bmp := TRnQBitmap.Create;
bmp := nil;
if GetPic13(picName, bmp) then
begin
gr.DrawImage(bmp, x, y, w, h);
end;
end;
{$ENDIF NOT_USE_GDIPLUS}
procedure TRQtheme.drawTiled(DC: HDC; ClipRect: TRect; const picName: TPicName);
// var
// br : TBrush;
begin
{ br := TBrush.Create;
br.bitmap := TRnQBitmap.Create;
getPic13(picName, br.bitmap);
// FillRect(dc, trect(0, 0, 5, 5), br.)
FillRect(dc, ClipRect, br.Handle);
// fillRect(clipRect);
// Windows.FillRect(Handle, ClipRect, Brush.GetHandle);
br.bitmap.Free;
br.free; }
end;
// var
// wallThTkn : Integer;
// wallImgLoc : TPicLocation;
// wallImgIdx : Integer;
{$IFDEF NOT_USE_GDIPLUS}
procedure TRQtheme.Draw_wallpaper(DC: HDC; r: TRect);
var
// bmp : TRnQBitmap;
Hbr: HBRUSH;
begin
begin
// if theme.GetPicSize(PIC_WALLPAPER).cx = 0 then exit;
// GDIPlus.Brush := NewGPTextureBrush(theme.getGPimage(WALLPAPER))
// GDIPlus.FillRectangle(canvas.ClipRect);
// drawTiled(canvas, PIC_WALLPAPER)
Hbr := theme.GetBrush(PIC_WALLPAPER);
// if Hbr = 0 then
{ begin
bmp := TRnQBitmap.Create;
if getPic13(PIC_WALLPAPER, bmp, false) then
Hbr := CreatePatternBrush(bmp.Handle);
end }
// else
// bmp := NIL;
if Hbr > 0 then
begin
// drawTiled(canvas, bmp);
Windows.FillRect(DC, r, Hbr);
DeleteObject(Hbr);
end;
// if Assigned(bmp) then
// Bmp.Free;
end;
end; // wallpaperize
{$ELSE USE_GDIPLUS}
procedure TRQtheme.Draw_wallpaper(DC: HDC; r: TRect);
var
// bmp : TRnQBitmap;
// Hbr : HBrush;
gr: TGPGraphics;
// bmp : TRnQBitmap;
// Handle : HBrush;
r1: TGPRectF;
begin
r1.x := r.Left;
r1.y := r.Top;
r1.width := r.Right - r.Left;
r1.height := r.Bottom - r.Top;
// if theme.GetPicSize(PIC_WALLPAPER).cx = 0 then exit;
// GDIPlus.Brush := NewGPTextureBrush(theme.getGPimage(WALLPAPER))
// GDIPlus.FillRectangle(canvas.ClipRect);
gr := TGPGraphics.Create(DC);
drawTiled(gr, r1, PIC_WALLPAPER);
gr.Free;
end; // wallpaperize
{$ENDIF NOT_USE_GDIPLUS}
{
function TRQtheme.GetPicRGN(picName:string; var ThemeToken : Integer;
var picLoc : TPicLocation; var picIdx : Integer):HRGN;
var
bmp : TRnQBitmap;
Hbr : HBrush;
gr : TGPGraphics;
r : TGPRegion;
// bmp : TRnQBitmap;
// Handle : HBrush;
r1 : TGPRectF;
begin
// if ThemeToken <> curToken then
initPic(picName, ThemeToken, picLoc, picIdx);
if picIdx = -1 then
begin
Result := 0;
exit;
end;
case picLoc of
PL_pic:
begin
gr := TGPGraphics.Create(TRnQBitmap(FGPpics.Objects[picIdx]));
r := TGPRegion.Create;
result := r.GetHRGN(gr);
r.Free;
gr.Free;
end;
(* PL_int:
begin
gr := TGPGraphics.Create(TRnQBitmap(FIntPics.Objects[picIdx]));
r := TGPRegion.Create;
result := r.GetHRGN(gr);
r.Free;
gr.Free;
end;
(* PL_Ani:
begin
// gr := TGPGraphics.Create(cnv.Handle);
// gr.DrawImage(TRnQAni(FAniSmls.Objects[picIdx]), x, y);
// gr.Free;
(* TRnQAni(FAniSmls.Objects[picIdx]).Draw(cnv, x, y);
gr := TGPGraphics.Create(TRnQAni(FAniSmls.Objects[picIdx]).);
r := TGPRegion.Create;
result := r.GetHRGN(gr);
r.Free;
gr.Free;*)
result := 0
end; *)
else
begin
result := 0
end;
end
end;
}
{$IFNDEF NOT_USE_GDIPLUS}
procedure drawdisabled(bmp: TRnQBitmap; gr: TGPGraphics; x, y: Integer);
var
FMonoBitmap: TRnQBitmap;
ia: TGPImageAttributes;
fgr: TGPGraphics;
cm: TColorMatrix;
cm2: TColorMatrix;
i, j, w, h: Integer;
begin
w := bmp.GetWidth;
h := bmp.GetHeight;
// FMonoBitmap := TRnQBitmap.Create(w, h, PixelFormat1bppIndexed);
FMonoBitmap := TRnQBitmap.Create(w, h, PixelFormat32bppARGB);
{ Store masked version of image temporarily in FBitmap }
fgr := TGPGraphics.Create(FMonoBitmap);
ia := TGPImageAttributes.Create;
// ia.SetColorKey(0, 0);
for i := 0 to 2 do
begin
cm[0][i] := 0.3;
cm[1][i] := 0.59;
cm[2][i] := 0.11;
cm[3][i] := 0;
cm[4][i] := 0;
// cm[i][0] := 0.3;
// cm[i][1] := 0.3;
// cm[i][2] := 0.3;
// cm[i][3] := 0;
// cm[i][4] := 0;
end;
for i := 3 to 4 do
for j := 0 to 4 do
begin
cm[j][i] := 0;
cm2[j][i] := 0;
// cm[i][j] := 0;
end;
for i := 0 to 2 do
begin
cm2[0][i] := 0.5 * 0.3;
cm2[1][i] := 0.5 * 0.59;
cm2[2][i] := 0.5 * 0.11;
cm2[3][i] := 0;
cm2[4][i] := 0;
// cm[i][0] := 0.3;
// cm[i][1] := 0.3;
// cm[i][2] := 0.3;
// cm[i][3] := 0;
// cm[i][4] := 0;
end;
cm[3][3] := 1;
cm2[3][3] := 0.5;
fgr.Clear(aclTransparent);
// FMonoBitmap.se
// fgr.
// FMonoBitmap.Canvas.Brush.Color := clWhite;
// FMonoBitmap.Canvas.FillRect(Rect(0, 0, Self.Width, Self.Height));
fgr.DrawImage(bmp, 0, 0, w, h);
// ImageList_DrawEx(Handle, Index, FMonoBitmap.Canvas.Handle, 0,0,0,0,
// CLR_NONE, 0, ILD_NORMAL);
fgr.Free;
ia.SetColorMatrix(cm2);
gr.DrawImage(FMonoBitmap, MakeRect(x + 1, y + 1, w, h), 0, 0, w, h, UnitPixel, ia);
ia.SetColorMatrix(cm);
gr.DrawImage(FMonoBitmap, MakeRect(x, y, w, h), 0, 0, w, h, UnitPixel, ia);
// gr.DrawImage(FMonoBitmap, x, y, w, h);
ia.Free;
FMonoBitmap.Free;
(* R := Rect(X, Y, X+Width, Y+Height);
SrcDC := FMonoBitmap.Canvas.Handle;
{ Convert Black to clBtnHighlight }
Canvas.Brush.Color := clBtnHighlight;
DestDC := Canvas.Handle;
Windows.SetTextColor(DestDC, clWhite);
Windows.SetBkColor(DestDC, clBlack);
BitBlt(DestDC, X+1, Y+1, Width, Height, SrcDC, 0, 0, ROP_DSPDxax);
{ Convert Black to clBtnShadow }
Canvas.Brush.Color := clBtnShadow;
DestDC := Canvas.Handle;
Windows.SetTextColor(DestDC, clWhite);
Windows.SetBkColor(DestDC, clBlack);
BitBlt(DestDC, X, Y, Width, Height, SrcDC, 0, 0, ROP_DSPDxax);
*)
end;
{$ENDIF NOT_USE_GDIPLUS}
{ function TE2Str(pTE : TRnQThemedElement) : TPicName;
begin
case pTE of
RQteButton: Result := TPicName('button.');
RQteMenu: Result := 'menu.';
RQteTrayNotify: Result := 'tray.';
RQteFormIcon: Result := 'formicon.';
else
Result := '';
end;
end; }
initialization
theme := TRQtheme.Create;
// RQSmiles := TRQtheme.Create;
// RQSmiles.supSmiles := True;
if (csDesigning in Application.ComponentState) then
begin
logpref.evts.onfile := True;
loggaEvtS('default theme loading', '', True);
theme.load('', '', True);
end;
finalization
// loggaEvt('Before theme unloading', '', True);
theme.Free;
theme := NIL;
loggaEvtS('Theme unloaded', '', True);
// RQSmiles.free;
// RQSmiles := NIL;
end.