[Pas2js] Picture serialisation into Pascal
warleyalex
warleyalex at yahoo.com.br
Sun Dec 9 23:00:24 CET 2018
The unit "CompWriterPas" component serialisation into Pascal have issue
Example: component serialization
--------------------------------------------------
WebLabel1 := TLabel.Create(Self);
WebEdit1 := TEdit.Create(Self);
WebButton1 := TButton.Create(Self);
WebMemo1 := TMemo.Create(Self);
WebComboBox1 := TComboBox.Create(Self);
WebPanel1 := TPanel.Create(Self);
WebLabel2 := TLabel.Create(WebPanel1);
WebImageControl1 := TImageControl.Create(WebPanel1);
WebLabel1.BeginUpdate;
WebEdit1.BeginUpdate;
WebButton1.BeginUpdate;
WebMemo1.BeginUpdate;
WebComboBox1.BeginUpdate;
WebPanel1.BeginUpdate;
WebLabel2.BeginUpdate;
WebImageControl1.BeginUpdate;
try
Self.Name := 'Form1';
Self.Left := 0;
Self.Top := 0;
Self.Width := 640;
Self.Height := 480;
Self.Font.Charset := 1;
Self.Font.Color := 0;
Self.Font.Height := -13;
Self.Font.Name := 'Tahoma';
Self.Font.Style := [fsBold];
Self.FFormContainer := 'appcontent';
Self.TabOrder := 1;
WebLabel1.Parent := Self;
WebLabel1.Name := 'WebLabel1';
WebLabel1.Left := 64;
WebLabel1.Top := 232;
WebLabel1.Width := 40;
WebLabel1.Height := 16;
WebLabel1.Caption := '-Label-';
WebEdit1.Parent := Self;
WebEdit1.Name := 'WebEdit1';
WebEdit1.Left := 64;
WebEdit1.Top := 42;
WebEdit1.Width := 121;
WebEdit1.Height := 24;
WebEdit1.TabOrder := 0;
WebEdit1.TextHint := 'Add some text ...';
WebButton1.Parent := Self;
WebButton1.Name := 'WebButton1';
WebButton1.Left := 204;
WebButton1.Top := 40;
WebButton1.Width := 75;
WebButton1.Height := 25;
WebButton1.Caption := 'Add';
WebButton1.OnClick := @WebButton1Click;
WebButton1.TabOrder := 1;
WebMemo1.Parent := Self;
WebMemo1.Name := 'WebMemo1';
WebMemo1.Left := 64;
WebMemo1.Top := 88;
WebMemo1.Width := 215;
WebMemo1.Height := 89;
WebMemo1.AutoSize := false;
WebMemo1.SelLength := 0;
WebMemo1.SelStart := 0;
WebMemo1.TabOrder := 2;
WebComboBox1.Parent := Self;
WebComboBox1.Name := 'WebComboBox1';
WebComboBox1.Left := 64;
WebComboBox1.Top := 197;
WebComboBox1.Width := 215;
WebComboBox1.Height := 24;
WebComboBox1.ItemIndex := -1;
WebComboBox1.TabOrder := 3;
WebComboBox1.Text := 'WebComboBox1';
WebComboBox1.OnChange := @WebComboBox1Change;
WebPanel1.Parent := Self;
WebPanel1.Name := 'WebPanel1';
WebPanel1.Left := 64;
WebPanel1.Top := 272;
WebPanel1.Width := 513;
WebPanel1.Height := 89;
WebPanel1.WidthStyle := TSizeStyle.ssPercent;
WebPanel1.WidthPercent:= 80;
WebPanel1.BorderStyle := TBorderStyle.bsSingle;
WebLabel2.Parent := WebPanel1;
WebLabel2.Name := 'WebLabel2';
WebLabel2.Left := 3;
WebLabel2.Top := 29;
WebLabel2.Width := 411;
WebLabel2.Height := 32;
WebLabel2.Caption := 'This demo shows the use of basic controls like
TEdit, TButton, TComboBox, TMemo and TLabel.';
WebLabel2.WordWrap := true;
WebLabel2.WidthStyle := TSizeStyle.ssPercent;
WebImageControl1.Parent := WebPanel1;
WebImageControl1.Name := 'WebImageControl1';
WebImageControl1.Left := 6;
WebImageControl1.Top := 7;
WebImageControl1.Width := 16;
WebImageControl1.Height := 16;
WebImageControl1.AutoSize := true;
WebImageControl1.Picture.LoadFromFile('Picture.png');
finally
//Button1.EndUpdate;
WebLabel1.EndUpdate;
WebEdit1.EndUpdate;
WebButton1.EndUpdate;
WebMemo1.EndUpdate;
WebComboBox1.EndUpdate;
WebPanel1.EndUpdate;
WebLabel2.EndUpdate;
WebImageControl1.EndUpdate;
end;
--------------------------------------------------
I) Parent property, this property should be the first property, for
instance:
with WMemo1 do begin
Parent:=Self;
Name:='WMemo1';
Left:=40;
Height:=90;
Top:=144;
Width:=150;
with Lines do begin
Clear;
Add('WMemo1');
end;
TabOrder:=0;
end;
III) Signature BeginUpdate / EndUpdate for visual components
The visual components should be enclosed with a BeginUpdate / EndUpdate
methods but
the non visual components which inherits from TComponent shouldn't be
enclosed.
II) when we use a Image component with streams, for instance, it generates
a wierd property ExecCustomCSP for the WebImage, which it's due a fix up;
with WebImage1 do begin
Name:='WebImage1';
Parent:=Self;
Left:=8;
Height:=90;
Top:=24;
Width:=90;
ExecCustomCSP(Picture,[#4'Data'#10'e'#3#0#0#23'TPortableNetworkGraphicI'#3,
#0#0#137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#16#0#0#0#16#8#6#0#0#0#31,
#243#255'a'#0#0#0#4'gAMA'#0#0#175#200'7'#5#138#233#0#0#0#25'tEXtSoftware',
#0'Adobe
ImageReadyq'#201'e<'#0#0#2#219'IDATx'#218#165#147'[HTQ'#20#134,
#255#227'5'#29''m'#236#226#140#201'4'#206#136#148#166')9'#129#169'`)'#148,
#152'EC'#5#6'J'#244' db'#5#221'C'#177#135#160#30',RP#"'#13'$I'#157'
'#8,
'*'#180'R'#153#240#24#21#154#149'3^R'#243'R'#227#164#166#227#232#156#203,
'n'#159'c'#249#208#229#165#22#28'6g'#239#189#190#181#214#191#214'f'#8'!',
#248#31'c~'#5#152#170'z'#244#156#200'g'#19'^'#204'Yps!<'#17'A
'#142#3'b',
#141#192#139#181'-g'#18#251#254#10#216'S'#249#222#228'vse'#186'@'#162'6j',
#131#176#220#199'S'#222#159'v'#241'h'#181'}F'#215#168's'#140'z'#20#176'%',
#219#27'~'#3'dUt'#155#220'.'#174':='#194'_'#17#29#170#196#136#195#141#241,
'i'#23#4#145'
'#208#223#19#154#192'e'#176'M'#204#192#220#212#231#132#23,
'r'#217'kY'#13'K'#128']'#229']'#225#28#199#183#166#27#20#154#200#16'%',
#216#129')'#240'<'#135'X'#237#10#128#158#191#26#152#4#227#193'
J'#29#128,
#225#201#25#220#127'l'#27#5#17#147#217#27#251#251'e'#192#142#235#175#139,
't'#10'R'#146#25#171#129#197#234#128#192#241'r'#228#146#236'h9'#187#11,
#181'o('#8#240#241#242'@'#140'V'#133#135#172#21'='#157#246#226#142';'#7,
'/'#202#128'mW_'#218'rbV'#25'f]'#28#134#28#179#212#153#10'G'#191'x'#189,
'J'#242'C'#187'u|'#177'`zW'#19#172#132'*'#208#23#183'nZz'#217#186'C'#17,
'2
'#233#146'e'#238'd'#154#214#143#181'N'#192#229#230#193#9#156#12'('#207,
'K'#148#1#249#21'm'#242'?'#173#24#222'^'#12'R6'#174#197#229#210#135#174,
#142#250'#'#254'2'#192'X'#252'l'#238#220'N'#131#223#11#155#3'N'#151#147,
'^&R0'#228'gl'#192#186'5J'#156#168#162#0#186'!'#193#188'icR7'#235'p'#229,
#202#3'W'#135#185#224'''#160#201#150#151#162'58'#166#221#24#182#127#131,
' '#240#16'i'#196#163#153#209#208'QQ'#11#203#159#211#244#165'y
XMK'#8#165,
']'#170#169'j'#238'e'#27#11#23'K0'#158'}T'#180'^'#237'['#146#17#167'C',
#219#219#17'*'#162#128#221#137'Z'#164#197#135#193#131#170#223#217'gGi'#29,
'+'#137#128#173#155'th'#178'X1'#240'n'#176#152'm<'#182'('#162#241#248#253,
'p,'#240#173#153#169#6#141'N'#165'@['#247'''#240'R''#4#1#132#174#228'G',
#244#184#200'0Lp'#11'xr'#175'u'#148#1#146'Y'#243#169#254#165'AJ8|'#215'D',
'f'#230#171'3'#246'F+'#194'W*'#241'a'#208#14#251#215#25#136#188#8'U'#144,
'?"'#194#130#241'qj'#22#205#245'O'#157'`'#188's'#169's'#195'o'#163#156'p',
#224#182#9#196']'#166#143'R'#171#147#182#232#17#28#224'#'#167#253'ez'#30,
'-'#150#30#12'u'#219#198#24#198#163#128'5'#159'n'#248#227'['#144#204#184,
#175'RO'#136#144'ME'#203#129'8'#31'"'#137#199'0'#140'4'#8'5'#12#184#218,
'v'#243#249#191'?'#166#127#177#239#194#251#133#240'"N('#148#0#0#0#0'IEND',
#174'B`'#130#0]);
end;
The correct should
Picture.Data :=
'url("data:image/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MuNp28/m/P6Z/se/C+4XwIk4olAAAAABJRU5ErkJggg==")';
--
Sent from: http://pas2js.38893.n8.nabble.com/
More information about the Pas2js
mailing list