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

4262 lines
118 KiB
Plaintext

{
This file is part of RnQ.
Under same license
}
unit RQThemes;
{$I ForRnQConfig.inc}
{$I NoRTTI.inc}
{ $DEFINE RQDEBUG2 }
{ $DEFINE USE_32Aplha_Images }
{$WRITEABLECONST OFF} // Read-only typed constants
interface
uses
Winapi.Windows, System.SysUtils, System.Classes, System.RegularExpressionsCore, System.NetEncoding,
Vcl.Forms, Vcl.Graphics, Vcl.Imaging.PNGImage, Generics.Collections,
RnQGraphics32, RDGlobal,
{$IFDEF USE_ZIP}
RnQZip,
{$ENDIF USE_ZIP}
{$IFDEF USE_RAR}
UnRAR,
{$ENDIF USE_RAR}
{$IFDEF USE_7Z}
SevenZip,
{$ENDIF USE_7Z}
RDFileUtil, GR32;
{$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;
pic: TMemoryStream;
// 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;
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;
color: TColor;
Canvas: TCanvas;
selected: Boolean;
// bg : TRnQBitmap;
// Count: Integer;
end;
TAniSmileParamsArray = array of TAniPicParams;
TThemeSubClass = (tsc_all, tsc_pics, tsc_smiles, tsc_sounds, tsc_emojis);
// 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 = TStringList;
{$ELSE ~UNICODE}
TObjList = TStringList;
{$ENDIF UNICODE}
TFontList = TDictionary;
type
TRQtheme = class
private
curToken: Integer;
fDPI: Integer;
fEmojisCnt: Integer;
// FBigPics : TObjList;
// FSmileBigPics : TObjList;
// FFonts : TFontList;
FBigPics, FSmileBigPics: array of TPicObj;
FThemePics, FSmilePics,
// FGPpics : ThaStringList;
// FFonts : TObjList;
FFonts2, FClr, FStr, FSmiles, FSounds, FIntPics: TObjList;
FIntPicsIL: THandle;
FAniSmls: TObjList;
// FAniPics: TObjList;
// FAniSmls: TStrListEx;
// 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; origSmile: TMemoryStream; var pTP: TThemePic;
Ani: Boolean = false; AniIdx: Integer = -1); overload;
// function GetIco2(name : String; ico : TIcon) : Boolean;
function GetSmlCnt: Integer;
function GetEmojisCnt: Integer;
// procedure GetPic(name : String; var pic : TRnQBitmap); overload;
public
ThemePath: TThemePath;
// MasterFN, subfn :string;
// fs : TPathType;
// fs : TThemeSourcePath;
// path : String;
title, desc: string;
useTSC: TThemeSubClass;
// supSmiles : Boolean;
useAnimated: Boolean;
// Anipicbg : Boolean;
AnibgPic: TBitmap32;
// logo:TRnQBitmap;
themelist2: aThemeInfo;
smileList: aThemeInfo;
emojiList: aThemeInfo;
soundList: aThemeInfo;
fBasePath: String;
smileRegex: TPerlRegEx;
smileArray: TDictionary>;
smileNotify: procedure of object;
emojisNotify: procedure of object;
procedure Debug;
constructor Create;
destructor Destroy; override;
procedure Clear(pTSC: TThemeSubClass);
procedure FreeResource;
procedure load(const 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; var origPic: TMemoryStream): Integer;
function addBigSmile(var pBmp: TRnQBitmap; var origPic: TMemoryStream): 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);
function addProp(const name: TPicName; pic: TRnQAni): Integer; overload;
// function addProp(name:string; pic: TRnQBitmap) : Integer; overload;
public
procedure addHIco(const name: TPicName; hi: HICON; Internal: Boolean = false);
function GetBrush(const name: TPicName): HBRUSH;
// procedure initPic(name : String; var ThemeToken : Integer;
// var picLoc : TPicLocation; var picIdx : Integer); overload;
procedure initPic(var picElm: TRnQThemedElementDtls); overload;
function HasOrigPic(const picName: TPicName): Boolean;
function GetOrigPic(const picName: TPicName; var mem: TMemoryStream): Boolean;
function GetOrigSmile(const picName: TPicName; var mem: TMemoryStream): Boolean;
function GetPicSize(pTE: TRnQThemedElement; const name: TPicName; minSize: Integer = 0; DPI: Integer = cDefaultDPI): Tsize; overload;
function GetPicSprite(pTE: TRnQThemedElement; const picName: TPicName): TPicName;
// 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 GetPicRect(pTE: TRnQThemedElement; const name: TPicName; minSize: Integer = 0): TGPRect;
function GetPicOld(const picName: TPicName; pic: TBitmap32): 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;
function pic2ico(pTE: TRnQThemedElement; const picName: TPicName; ico: Ticon): Boolean;
function pic2hIcon(const picName: TPicName; var ico: HICON): Boolean;
function Pic2PNG(const PicName: TPicName; var PNG: TPNGImage): 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;
// 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;
function GetSmilePic(i: Integer): TThemePic;
procedure checkAnimationTime;
function GetAniPic(IDX: Integer): TRnQAni;
property SmilesCount: Integer read GetSmlCnt;
property EmojisCount: Integer read GetEmojisCnt;
property Token: Integer read curToken;
procedure getprops(var PropList: aTthemeProperty);
procedure initThemeIcons;
procedure drawTiled(Canvas: TCanvas; const picName: TPicName); overload;
procedure Draw_wallpaper(DC: HDC; r: TRect); // inline;
procedure refreshThemeList;
// procedure refreshSmilesList;
procedure ClearThemelist;
procedure UpdateSmileHelpers;
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
Winapi.CommCtrl, System.Types, System.StrUtils, System.Math,
{$IFDEF UNICODE}
System.AnsiStrings,
{$ENDIF UNICODE}
{$IFDEF RNQ}
RQlog,
{$ENDIF RNQ}
RDUtils, RnQGlobal, RnQLangs, RQUtil;
type
// Tsection=(_null,_roaster,_tip,_pics,_icons,_history,_smiles,_sounds,_menu);
TRQsection = (_null, _pics, _icons, _smiles, _sounds, _ico, _smile, _str, _desc, _fontfile, _emojis);
const
// sectionLabels:array [Tsection] of string=('','roaster','tip','pics','icons',
// 'history','smiles','sounds','menu');
RQsectionLabels: array [TRQsection] of String = ('', 'pics', 'icons', 'smiles', 'sounds', 'rnqpics', 'rnqsmiles', 'strings', 'desc', 'font', 'emojis');
{$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 .. 3] of string = ('theme.ini', 'smiles.ini', 'sounds.ini', 'emojis.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; const fn: String);
var
fn_Ext: String;
begin
fn_Ext := LowerCase(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;
name := nil;
end;
destructor TFontObj.Destroy;
begin
if Assigned(name) then
StrDispose(name);
name := nil;
inherited;
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 := StrAlloc(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;
fDPI := cDefaultDPI;
useTSC := tsc_all;
// supSmiles := False;
// 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;
FAniSmls := TObjList.Create;
// FAniSmls := NewStrListEx^;
FSmiles.CaseSensitive := True;
FAniSmls.CaseSensitive := True;
// FSmiles.Sorted := True;
// FAniSmls.Sorted := True;
AnibgPic := nil;
smileNotify := nil;
smileRegex := nil;
smileArray := TDictionary>.Create;
emojisNotify := 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);
FreeAndNil(AnibgPic);
// 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;
smileArray.Free;
FreeAndNil(smileRegex);
// FIntIPs.Free;
FAniSmls.Free;
inherited;
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; }
// 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
FreeAndNil(po.bmp);
FreeAndNil(po.pic);
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;
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
FreeAndNil(po.bmp);
FreeAndNil(po.pic);
except end;
po.Free;
end;
end;
// FBigPics.Clear;
SetLength(FSmileBigPics, 0);
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;
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
begin
FreeAndNil(po.bmp);
FreeAndNil(po.pic);
end;
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
begin
FreeAndNil(po.bmp);
FreeAndNil(po.pic);
end;
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(const 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;
if subClass in [tsc_all, tsc_smiles] then
begin
useAnimated := false;
FreeAndNil(AnibgPic);
end;
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;
// if useAnimated then
// CreateWaitableTimer()
inc(curToken);
if (subClass = tsc_smiles) then
begin
UpdateSmileHelpers;
if Assigned(smileNotify) then
smileNotify;
end;
if (subClass = tsc_emojis) then
begin
if Assigned(emojisNotify) then
emojisNotify;
end;
end; // loadTheme
procedure TRQtheme.UpdateSmileHelpers;
var
i, j: Integer;
smileObj: TSmlObj;
smilePair: TPair;
smile: String;
smileRegStr: String;
// testRegex: TPerlRegEx;
// bytes: TBytes;
// s: String;
begin
smileRegStr := '';
smileArray.Clear;
if theme.SmilesCount = 0 then
Exit;
for i := 0 to theme.SmilesCount - 1 do
begin
smileObj := theme.GetSmileObj(i);
if smileObj.SmlStr.Count > 0 then
for j := 0 to smileObj.SmlStr.Count - 1 do
begin
smile := THTMLEncoding.HTML.Encode(smileObj.SmlStr[j]);
smileRegStr := smileRegStr + TPerlRegEx.EscapeRegExChars(smile) + '|';
smilePair := TPair.Create(i, theme.GetPicRect(RQteDefault, smileObj.SmlStr[0]));
smileArray.AddOrSetValue(smile, smilePair);
end;
end;
FreeAndNil(smileRegex);
if Length(smileRegStr) > 0 then
begin
delete(smileRegStr, Length(smileRegStr), 1);
smileRegex := TPerlRegex.Create;
smileRegex.RegEx := '(?<=^|\s)(' + smileRegStr + ')(?=$|\s)';
smileRegex.State := [preNotEmpty];
smileRegex.Options := [preCaseLess, preUnGreedy];
smileRegex.Study;
end;
{
testRegex := TPerlRegex.Create;
testRegex.RegEx := '(?<=^|\s)(:смайл:|:verylongsmile:)(?=$|\s)';
testRegex.State := [preNotEmpty];
testRegex.Options := [preCaseLess];
testRegex.Subject := ':смайл:';
testRegex.Match;
OutputDebugString(PChar((testRegex.MatchedText)));
testRegex.Subject := ':verylongsmile:';
testRegex.Match;
OutputDebugString(PChar((testRegex.MatchedText)));
testRegex.Subject := ':смайл:';
testRegex.Replacement := '$1';
testRegex.ReplaceAll;
bytes := TEncoding.Unicode.GetBytes(testRegex.Subject);
for i := 0 to Length(bytes)-1 do
s := s + bytes[i].ToHexString + ' ';
OutputDebugString(PChar(s));
}
end;
function TRQtheme.GetPicOld(const picName: TPicName; pic: TBitmap32): 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 := LowerCase(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;
function TRQtheme.GetBrush(const name: TPicName): HBRUSH;
var
i: Integer;
bmp: TRnQBitmap;
begin
Result := 0;
// i := Fpics.IndexOf(LowerCase(name));
i := FThemePics.IndexOf(LowerCase(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;
function TRQtheme.GetPicSprite(pTE: TRnQThemedElement; const picName: TPicName): TPicName;
var
i, j: integer;
s: TPicName;
begin
Result := picName;
i := -1;
if not (pTE = RQteDefault) then
begin
s := TE2Str[pTE] + LowerCase(picName);
i := FThemePics.IndexOf(s);
end;
if i < 0 then
i := FThemePics.IndexOf(LowerCase(picName));
if i >= 0 then
begin
for j := 0 to FThemePics.Count - 1 do
if TThemePic(FThemePics.Objects[j]).picIdx = TThemePic(FThemePics.Objects[i]).picIdx then
begin
if not (picName = FThemePics.Strings[j]) then
begin
Result := FThemePics.Strings[j];
Exit;
end else
Break;
end;
end else
begin
i := FSmilePics.IndexOf(LowerCase(picName));
if i >= 0 then
for j := 0 to FSmilePics.Count - 1 do
if TThemePic(FSmilePics.Objects[j]).picIdx = TThemePic(FSmilePics.Objects[i]).picIdx then
begin
if not (picName = FSmilePics.Strings[j]) then
begin
Result := FSmilePics.Strings[j];
Exit;
end else
Break;
end;
end;
end;
function TRQtheme.GetOrigPic(const picName: TPicName; var mem: TMemoryStream): Boolean;
var
i: integer;
begin
if picName = '' then
begin
Result := False;
Exit;
end;
Result := False;
i := FThemePics.IndexOf(LowerCase(picName));
if i >= 0 then
begin
with TThemePic(FThemePics.Objects[i]) do
if Assigned(FBigPics[picIdx].pic) then
begin
mem := TMemoryStream.Create;
mem.LoadFromStream(FBigPics[picIdx].pic);
Result := True;
end
end;
end;
function TRQtheme.HasOrigPic(const picName: TPicName): Boolean;
var
i: integer;
begin
if picName = '' then
begin
Result := False;
Exit;
end;
Result := False;
i := FThemePics.IndexOf(LowerCase(picName));
if i >= 0 then
with TThemePic(FThemePics.Objects[i]) do
if Assigned(FBigPics[picIdx].pic) then
Result := True;
end;
function TRQtheme.GetOrigSmile(const picName: TPicName; var mem: TMemoryStream): Boolean;
var
i: integer;
begin
if picName = '' then
begin
Result := False;
Exit;
end;
Result := False;
if TryStrToInt(picName, i) then
begin
if i < FSmilePics.Count then
with TThemePic(FSmilePics.Objects[i]) do
if (picIdx < Length(FSmileBigPics)) and Assigned(FSmileBigPics[picIdx].pic) then
begin
mem := TMemoryStream.Create;
mem.LoadFromStream(FSmileBigPics[picIdx].pic);
Result := True;
end;
end;
end;
function TRQtheme.GetPicSize(pTE: TRnQThemedElement; const name: TPicName; minSize: Integer = 0; DPI: Integer = cDefaultDPI): Tsize;
var
i: Integer;
s, s1: TPicName;
begin
s1 := LowerCase(name);
s := TE2Str[pTE] + s1;
i := FThemePics.IndexOf(s);
if (i < 0) and not (pte = RQteDefault) 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) and not (pte = RQteDefault)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
// 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
begin
// 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
begin
Result.cx := minSize;
Result.cy := minSize;
end;
end;
end;
end;
if dpi <> fDPI then
begin
result.cx := MulDiv(result.cx, dpi, fDPI);
result.cy := MulDiv(result.cy, dpi, fDPI);
end;
end;
function TRQtheme.GetPicRect(pTE: TRnQThemedElement; const name: TPicName; minSize: Integer = 0): TGPRect;
var
i: Integer;
s, s1: TPicName;
begin
s1 := LowerCase(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
Result := r
else
begin
i := FIntPics.IndexOf(s);
if i < 0 then
i := FIntPics.IndexOf(s1);
if i >= 0 then
begin
Result.X := 0;
Result.Y := 0;
Result.Width := icon_size;
Result.Height := icon_size;
end
else
begin
// i := FAniSmls.IndexOf(s);
// if i < 0 then
i := FAniSmls.IndexOf(name);
if i >= 0 then
with TRnQAni(FAniSmls.Objects[i]) do
begin
Result.X := 0;
Result.Y := 0;
Result.Width := Width;
Result.Height := Height;
end
else
begin
// i := FSmilePics.IndexOf(s);
// if i < 0 then
i := FSmilePics.IndexOf(name);
if i >= 0 then
with TThemePic(FSmilePics.Objects[i]) do
Result := r
else
begin
Result.X := 0;
Result.Y := 0;
Result.Width := minSize;
Result.Height := 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 := LowerCase(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) and not (picElm.Element = RQteDefault) 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
// 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
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.GetSmilePic(i: Integer): TThemePic;
begin
if i >= 0 then
if Assigned(FSmilePics.Objects[i]) then
Result := TThemePic(FSmilePics.Strings[i])
else
Result := nil
else
Result := nil;
end;
function TRQtheme.GetSmlCnt: Integer;
begin
Result := FSmiles.Count;
end;
function TRQtheme.GetEmojisCnt: Integer;
begin
Result := fEmojisCnt;
end;
function TRQtheme.GetString(const name: TPicName; isAdd: Boolean = True): String;
var
i: Integer;
ts: TThemeSourcePath;
begin
i := FStr.IndexOf(LowerCase(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(LowerCase(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(LowerCase(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(LowerCase(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(LowerCase(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(LowerCase(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(LowerCase(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(LowerCase(name));
if i >= 0 then
// result := ColorFromAlphaColor($FF, ABCD_ADCB(ColorToRGB(TColor(FClr.Objects[i]))))
{$WARN UNSAFE_CAST OFF}
Result := AlphaMask or ColorToRGB(TColor(FClr.Objects[i]))
{$WARN UNSAFE_CAST ON}
else
begin
// addProp(name, pDefColor);
// result := ColorFromAlphaColor($FF, ABCD_ADCB(ColorToRGB(pDefColor)));
Result := AlphaMask or ColorToRGB(pDefColor)
end
end;
function TRQtheme.GetTColor(const name: TPicName; pDefColor: Cardinal): Cardinal;
var
i: Integer;
begin
i := FClr.IndexOf(LowerCase(name));
if i >= 0 then
// result := ColorFromAlphaColor($FF, ABCD_ADCB(ColorToRGB(TColor(FClr.Objects[i]))))
{$WARN UNSAFE_CAST OFF}
Result := Cardinal(FClr.Objects[i])
{$WARN UNSAFE_CAST ON}
else
begin
// addProp(name, pDefColor);
// result := ColorFromAlphaColor($FF, ABCD_ADCB(ColorToRGB(pDefColor)));
Result := pDefColor
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 not (pTE = RQteDefault) then
begin
s := TE2Str[pTE] + LowerCase(picName);
i := FThemePics.IndexOf(s);
end;
if i < 0 then
i := FThemePics.IndexOf(LowerCase(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);
if Assigned(bmp) then
begin
bmp.GetHICON(hi);
FreeAndNil(bmp);
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(LowerCase(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(LowerCase(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);
if Assigned(bmp) then
begin
bmp.GetHICON(ico);
FreeAndNil(bmp);
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(LowerCase(picName));
if i >= 0 then
begin
ico := ImageList_ExtractIcon(0, FIntPicsIL, i);
Result := True;
end
// else
// Result := False;
end;
end;
function TRQtheme.Pic2PNG(const PicName: TPicName; var PNG: TPNGImage): Boolean;
var
bmp: TRnQBitmap;
bmp32: TBitmap32;
hi: HIcon;
ico: TIcon;
i: Integer;
begin
if PicName = '' then
begin
Result := False;
Exit;
end;
PNG := nil;
Result := False;
bmp32 := TBitmap32.Create;
i := FThemePics.IndexOf(LowerCase(PicName));
if i >= 0 then
begin
with TThemePic(FThemePics.Objects[i]) do
if Assigned(FBigPics[picIdx].bmp) then
begin
if isWholeBig then
begin
bmp32.SetSize(FBigPics[picIdx].bmp.Width, FBigPics[picIdx].bmp.Height);
FBigPics[picIdx].bmp.Draw(bmp32.Canvas.Handle, 0, 0);
Result := True;
end
else
begin
bmp := FBigPics[picIdx].bmp.Clone(r);
if Assigned(bmp) then
begin
bmp32.SetSize(r.Width, r.Height);
bmp.Draw(bmp32.Canvas.Handle, 0, 0);
FreeAndNil(bmp);
Result := True;
end
end;
end
end
else
begin
i := FIntPics.IndexOf(LowerCase(PicName));
if i >= 0 then
begin
hi := ImageList_ExtractIcon(0, FIntPicsIL, i);
if hi > 0 then
begin
ico := TIcon.Create;
ico.Handle := hi;
bmp32.SetSize(ico.Width, ico.Height);
bmp32.Canvas.Draw(0, 0, ico);
Result := True;
DeleteObject(hi);
ico.Free;
end;
end
end;
if Result then
PNG := Bitmap32ToPNG(bmp32);
bmp32.Free;
end;
function TRQtheme.addBigPic(var pBmp: TRnQBitmap; var origPic: TMemoryStream): Integer;
// var
// tempPic :TPicObj;
begin
Result := Length(FBigPics);
SetLength(FBigPics, Result + 1);
FBigPics[Result] := TPicObj.Create;
FBigPics[Result].bmp := pBmp;
pBmp := nil;
FBigPics[Result].pic := TMemoryStream.Create;
FBigPics[Result].pic.LoadFromStream(origPic);
FBigPics[Result].pic.Seek(0, soFromBeginning);
FreeAndNil(origPic);
FBigPics[Result].ref := 0;
end;
function TRQtheme.addBigSmile(var pBmp: TRnQBitmap; var origPic: TMemoryStream): Integer;
// var
// tempPic :TPicObj;
begin
Result := Length(FSmileBigPics);
SetLength(FSmileBigPics, Result + 1);
FSmileBigPics[Result] := TPicObj.Create;
FSmileBigPics[Result].bmp := pBmp;
pBmp := nil;
FSmileBigPics[Result].pic := TMemoryStream.Create;
FSmileBigPics[Result].pic.LoadFromStream(origPic);
FSmileBigPics[Result].pic.Seek(0, soFromBeginning);
FreeAndNil(origPic);
FSmileBigPics[Result].ref := 0;
end;
function TRQtheme.addProp(const name: TPicName; kind: TthemePropertyKind; var pBmp: TRnQBitmap): Integer;
var
i: Integer;
thp: TThemePic;
origPic: TMemoryStream;
zeroBMP: TBitmap;
begin
Result := -1;
if not Assigned(pBmp) then
Exit;
if kind = TP_smile then
begin // pic for smile
{ i := FSmileBigPics.IndexOf(LowerCase(name));
if i < 0 then
begin
tempPic :=TPicObj.Create;
tempPic.bmp := pBmp;
pBmp := nil;
tempPic.ref := 0;
result := FSmileBigPics.AddObject(LowerCase(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
zeroBMP := TBitmap.Create;
zeroBMP.SetSize(0, 0);
origPic := TMemoryStream.Create;
zeroBMP.SaveToStream(origPic);
zeroBMP.Free;
origPic.Seek(0, 0);
// i := FBigPics.IndexOf(LowerCase(name));
i := FThemePics.IndexOf(LowerCase(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, origPic);
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(LowerCase(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, origPic);
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(LowerCase(name));
i := IndexOf(name);
if i < 0 then
begin
// AddObject(LowerCase(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(LowerCase(name));
if i < 0 then
begin
AddObject(LowerCase(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(LowerCase(name));
if i < 0 then
begin
// TRnQBitmap.c
// i :=
FBigPics.AddObject(LowerCase(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(LowerCase(name));
if i < 0 then
begin
// i :=
FIntPics.Add(LowerCase(name));
ImageList_AddIcon(FIntPicsIL, hi);
// FIntPicsIL
// i := FIntPics.AddObject(LowerCase(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; origSmile: TMemoryStream; var pTP: TThemePic;
Ani: Boolean = false; AniIdx: Integer = -1);
function uStr(const str: String): String;
var
l: Integer;
ca: TArray;
begin
if str.StartsWith('\u') then
try
l := Round((Length(str) - 2) / 2);
SetLength(ca, l);
if l >= 1 then ca[0] := StrToInt('$' + str[3] + str[4]);
if l >= 2 then ca[1] := StrToInt('$' + str[5] + str[6]);
if l >= 3 then ca[2] := StrToInt('$' + str[7] + str[8]);
if l >= 4 then ca[3] := StrToInt('$' + str[9] + str[10]);
Result := TEncoding.UTF8.GetString(ca);
except
Result := str;
end else
Result := str;
end;
var
i, j: Integer;
NewSmile: TSmlObj;
vST: TthemePropertyKind;
tp: TThemePic;
pic: TRnQBitmap;
origPic: TMemoryStream;
uname, ucaption: String;
begin
uname := uStr(name);
ucaption := uStr(smlCaption);
vST := TP_smile;
i := FSmiles.IndexOf(uname);
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(ucaption);
NewSmile.AniIdx := AniIdx;
FSmiles.AddObject(uname, 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;
origPic := origSmile;
tp.picIdx := addBigSmile(pic, origPic);
// NewSmile.AniIdx :=
addProp(uname, vST, tp);
end
else
addProp(uname, vST, pTP);
pTP := NIL;
// NewSmile := NIL;
end
else
begin
j := TSmlObj(FSmiles.Objects[i]).SmlStr.IndexOf(ucaption);
if j < 0 then
TSmlObj(FSmiles.Objects[i]).SmlStr.Add(ucaption)
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;
origPic := origSmile;
tp.picIdx := addBigSmile(pic, origPic);
addProp(uname, vST, tp);
end
else
addProp(uname, vST, pTP);
pTP := NIL;
// addprop(uname, 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 := LowerCase(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(LowerCase(name));
if i < 0 then
FFonts.AddObject(LowerCase(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(LowerCase(pName));
if i < 0 then
begin
fo := fnt.Clone;
// SetLength(fo.prop, 1);
// fo.prop[0] := fnt;
FFonts2.AddObject(LowerCase(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 := StrAlloc(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(LowerCase(name));
if i < 0 then
FClr.AddObject(LowerCase(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(const fn: string): string;
begin
if pos(':', fn) = 0 then
Result := ts.path + fn
else
Result := fn
end;
// function fullpath(fn:string):string;
// begin if pos(':',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 StartsText('@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; const v: String; const picName: TPicName = ''): TThemePic;
var
s: RawByteString;
fn: String;
x, y, dx, dy, IDX: Integer;
w, h: Integer;
tempPic: TRnQBitmap;
origPic: TMemoryStream;
i: Integer;
begin
tempPic := nil;
origPic := nil;
s := v;
Result := nil;
fn := chop(RawByteString(';'), s);
if fn = '' then
Exit;
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
end
// fn := LastPicFName
else
begin
if StartsText('@pics.', fn) then
begin
LastPicIDX := -1;
s := LowerCase(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;
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
FreeAndNil(tempPic);
Result := nil;
Exit;
end;
if not loadFile(ts, fn, TStream(origPic)) then
begin
FreeAndNil(origPic);
Result := nil;
Exit;
end;
w := tempPic.GetWidth;
h := tempPic.GetHeight;
// LastPicIDX := addProp(fn, TP_pic, tempPic);
LastPicIDX := addBigPic(tempPic, origPic);
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;
end;
end;
end;
end; // parsePic
function fontAvailable(list: RawByteString): String;
var
s: String;
begin
repeat
Result := chop(';', list);
s := Result;
until (list = '') or (Screen.fonts.IndexOf(s) >= 0);
{ s := chop(';',list);
while (list>'') and (screen.fonts.IndexOf(s) < 0) do
s:=chop(';', 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(const prefix: String; const k, v, ppar: String): Boolean;
var
i: Integer;
s: String;
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 := WideStrAlloc(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: String; picName: TPicName = '');
(* var
s : RawByteString;
fn: String;
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, txt, line,
param, // roaster, menu, tip, history
prefix, // Prefix for Font and other...
par, LastSmile: String;
lPos, ltxtL, i: Integer;
loadedpic: TRnQBitmap;
origPic: TMemoryStream;
themePic: TThemePic;
// loadedpic : TRnQBitmap;
loadedAniPic: TRnQAni;
// loadedAniPic : TRnQBitmap;
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);
loadedpic := TRnQBitmap.Create(icon_size, icon_size);
loadedpic.MakeEmpty;
addProp(PIC_EMPTY, TP_ico, loadedpic);
origPic := nil;
FreeAndNil(loadedpic);
loadedAniPic := nil;
NonAnimated := True;
themePic := nil;
LastPicIDX := -1;
hasSmilePic := false;
section := _null;
SetLength(prefix, 0);
txt := loadfile(ts, fn);
lPos := 1;
lTxtL := Length(txt);
fEmojisCnt := 0;
while lPos < lTxtL do
try
line := choplineV(txt, lPos);
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 := LowerCase(copy(line, 2, Length(line) - 2));
i := pos('.', param);
if i > 0 then
begin
k := copy(param, 1, i - 1);
prefix := copy(param, i + 1, 100) + '.';
i := IndexStr(k, RQsectionLabels);
k := '';
end
else
begin
i := IndexStr(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
FreeAndNil(loadedpic);
NonAnimated := True;
line := k;
i := str2valor(chop(';', v));
LastSmile := '';
// loadedPic := TRnQBitmap.Create;
hasSmilePic := loadPic(ts, UnUTF(line), loadedpic, i);
if hasSmilePic then
begin
if not loadFile(ts, UnUTF(line), TStream(origPic)) then
begin
FreeAndNil(origPic);
msgDlg(getTranslation('Can''t load smile file: ') + UnUTF(line), false, mtError);
end;
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 StartsText('@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;
if not NonAnimated then
i := addProp(LastSmile, loadedAniPic)
else
FreeAndNil(loadedAniPic);
loadedAniPic := nil;
end;
//if section = _smile then
// Parsed := True
//else
// Parsed := False;
// addProp(LastSmile, line, loadedPic, Parsed, not NonAnimated, i);
addProp(LastSmile, par, loadedpic, origPic, themePic, not NonAnimated, i);
origPic := nil;
loadedpic := nil;
// FreeAndNil(loadedPic);
FreeAndNil(loadedAniPic);
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(ReplaceStr(v, '\n', CRLF)));
end
else if section = _desc then
begin
if desc > '' then
desc := desc + CRLF;
desc := desc + UnUTF(ReplaceStr(line, '\n', CRLF));
// v := GetString('desc', false) + CRLF + ReplaceStr(line,'\n',CRLF);
addProp('desc', ts, TP_string, desc);
end
else if section = _fontfile then
begin
parseFontFile(v);
end
else if section = _emojis then
begin
if Length(k) = 0 then
Continue;
k := LowerCase(k);
i := pos('.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;
FreeAndNil(themePic);
themePic := parsePic(false, v);
addProp(par, TP_pic, themePic);
FreeAndNil(themePic);
Parsed := True;
end
else
begin
par := 'emojis.' + prefix + k;
addProp(par, ts, TP_string, v);
if prefix = 'data.' then
Inc(fEmojisCnt);
end;
end
else if section = _null then
begin
Parsed := False;
k := LowerCase(k);
i := pos('.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;
FreeAndNil(themePic);
themePic := parsePic(false, v);
addProp(par, TP_pic, themePic);
FreeAndNil(themePic);
Parsed := True;
end;
i := pos('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('color', k) > 0 then
begin
i := pos('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('sound', k) > 0 then
begin
i := pos('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(ReplaceStr(v, '\n', CRLF)));
end;
end;
except
end;
FreeAndNil(loadedpic);
FreeAndNil(loadedAniPic);
// 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(LowerCase(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(LowerCase(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(LowerCase(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(LowerCase(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;
// 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;
procedure TRQtheme.ClearThemelist;
procedure Clear1ThemeList(var tl: aThemeInfo);
var
t: ToThemeinfo;
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(emojiList);
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 := LowerCase(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 := ReplaceStr(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
InternalprocessTheme(themelist2)
else if (line = 'R&Q smiles file version 1') then
InternalprocessTheme(smileList)
else if (line = 'R&Q emojis file version 1') then
InternalprocessTheme(emojiList)
else if (line = 'R&Q sounds file version 1') then
InternalprocessTheme(soundList);
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(emojiList);
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) or RnQEndsText(ThemeInis[3], 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) or RnQEndsText(ThemeInis[3], 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 := LowerCase(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) or RnQEndsText(ThemeInis[3], 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
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
if FIntPics.Strings[i].StartsWith('pluginbtn') then
Continue;
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
if FStr.Strings[i].StartsWith('emojis.cats') or
FStr.Strings[i].StartsWith('emojis.data') or
FStr.Strings[i].StartsWith('r&q theme file version') or
FStr.Strings[i].StartsWith('r&q smiles file version') or
FStr.Strings[i].StartsWith('r&q emojis file version') then
Continue;
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;
function TRQtheme.addProp(const name: String; 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(LowerCase(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.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;
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;
FillRect(Canvas.Handle, Canvas.ClipRect, Hdl);
Canvas.Unlock;
DeleteObject(Hdl);
end;
bmp.Free;
end;
procedure TRQtheme.Draw_wallpaper(DC: HDC; r: TRect);
var
// bmp : TRnQBitmap;
Hbr: HBRUSH;
begin
begin
// if theme.GetPicSize(PIC_WALLPAPER).cx = 0 then exit;
// 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);
FillRect(DC, r, Hbr);
DeleteObject(Hbr);
end;
// if Assigned(bmp) then
// Bmp.Free;
end;
end; // wallpaperize
initialization
theme := TRQtheme.Create;
// RQSmiles := TRQtheme.Create;
// RQSmiles.supSmiles := True;
if (csDesigning in Application.ComponentState) then
begin
logpref.evts.onfile := True;
LogEvent('default theme loading', '', True);
theme.load('', '', True);
end;
finalization
// loggaEvt('Before theme unloading', '', True);
theme.Free;
theme := nil;
LogEvent('Theme unloaded', '', True);
// RQSmiles.free;
// RQSmiles := NIL;
end.