1
0
Files
applications
bindings
components
Comba_Animation
aboutcomponent
acs
beepfp
callite
chelper
chemtext
cmdline
cmdlinecfg
colorpalette
cryptini
csvdocument
epiktimer
examplecomponent
extrasyn
fpexif
fpsound
fpspreadsheet
fractions
freetypepascal
geckoport
gradcontrols
grid_semaphor
industrialstuff
iosdesigner
iphonelazext
jujiboutils
jvcllaz
kcontrols
lazautoupdate
lazbarcodes
lazmapviewer
lclextensions
longtimer
manualdock
mbColorLib
mplayer
multithreadprocs
nvidia-widgets
onguard
orpheus
playsoundpackage
poweredby
powerpdf
rgbgraphics
richmemo
richview
rtfview
rx
scrolltext
smnetgradient
spktoolbar
SpkGUITools
SpkGraphTools
SpkMath
SpkToolbar
SpkXML
SpkXMLIni.pas
SpkXMLParser.pas
SpkXMLTools.pas
demos
designtime
license.txt
readme.txt
registerspktoolbar.pas
spktoolbarpackage.lpk
spktoolbarpackage.pas
svn
systools
tdi
thtmlport
tparadoxdataset
tvplanit
xdev_toolkit
zlibar
zmsql
examples
image_sources
lclbindings
wst
lazarus-ccr/components/spktoolbar/SpkXML/SpkXMLTools.pas
blikblum e943f03a21 * Fix compilation of various units
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1705 8e941d3f-bd1b-0410-a28a-d453659cc2b4
2011-06-18 16:17:03 +00:00

120 lines
2.9 KiB
ObjectPascal

unit SpkXMLTools;
{$mode ObjFpc}
{$H+}
interface
uses
Graphics, SysUtils, SpkXMLParser;
type TSpkXMLTools = class
private
protected
public
class procedure Save(Node : TSpkXMLNode; Font : TFont); overload;
class procedure Load(Node : TSpkXMLNode; Font : TFont); overload;
end;
implementation
{ TXMLTools }
class procedure TSpkXMLTools.Load(Node: TSpkXMLNode; Font: TFont);
var Subnode, Subnode2 : TSpkXMLNode;
begin
if not(assigned(Node)) then
raise exception.create('TSpkXMLTools.Load: Nieprawid³owa ga³¹Ÿ XML!');
if not(assigned(Font)) then
raise exception.create('TSpkXMLTools.Load: Brak obiektu czcionki do wczytania!');
Subnode:=Node['Charset',false];
if assigned(Subnode) then
Font.Charset:=TFontCharset(Subnode.TextAsInteger);
Subnode:=Node['Color',false];
if assigned(Subnode) then
Font.Color:=Subnode.TextAsInteger;
Subnode:=Node['Name',false];
if assigned(Subnode) then
Font.Name:=Subnode.Text;
Subnode:=Node['Orientation',false];
if assigned(Subnode) then
Font.Orientation:=Subnode.TextAsInteger;
Subnode:=Node['Pitch',false];
if assigned(Subnode) then
Font.Pitch:=TFontPitch(Subnode.TextAsInteger);
Subnode:=Node['Size',false];
if assigned(Subnode) then
Font.Size:=Subnode.TextAsInteger;
Subnode:=Node['Style',false];
if assigned(Subnode) then
begin
Subnode2:=Subnode['Bold',false];
if assigned(Subnode2) then
if Subnode2.TextAsBoolean then
Font.Style:=Font.Style + [fsBold] else
Font.Style:=Font.Style - [fsBold];
Subnode2:=Subnode['Italic',false];
if assigned(Subnode2) then
if Subnode2.TextAsBoolean then
Font.Style:=Font.Style + [fsItalic] else
Font.Style:=Font.Style - [fsItalic];
Subnode2:=Subnode['Underline',false];
if assigned(Subnode2) then
if Subnode2.TextAsBoolean then
Font.Style:=Font.Style + [fsUnderline] else
Font.Style:=Font.Style - [fsUnderline];
end;
end;
class procedure TSpkXMLTools.Save(Node: TSpkXMLNode; Font: TFont);
var Subnode, Subnode2 : TSpkXMLNode;
begin
if not(assigned(Node)) then
raise exception.create('TSpkXMLTools.Save: Nieprawid³owa ga³¹Ÿ XML!');
if not(assigned(Font)) then
raise exception.create('TSpkXMLTools.Save: Brak obiektu czcionki do zapisania!');
Subnode:=Node['Charset',true];
Subnode.TextAsInteger:=Font.Charset;
Subnode:=Node['Color',true];
Subnode.TextAsInteger:=Font.Color;
Subnode:=Node['Name',true];
Subnode.Text:=Font.Name;
Subnode:=Node['Orientation',true];
Subnode.TextAsInteger:=Font.Orientation;
Subnode:=Node['Pitch',true];
Subnode.TextAsInteger:=ord(Font.Pitch);
Subnode:=Node['Size',true];
Subnode.TextAsInteger:=Font.Size;
Subnode:=Node['Style',true];
Subnode2:=Subnode['Bold',true];
Subnode2.TextAsBoolean:=fsBold in Font.Style;
Subnode2:=Subnode['Italic',true];
Subnode2.TextAsBoolean:=fsItalic in Font.Style;
Subnode2:=Subnode['Underline',true];
Subnode2.TextAsBoolean:=fsUnderline in Font.Style;
end;
end.