3
{ ---------------------------------------------------------------------------
4
Program to convert forms fdesign file to pascal code
5
Copyright (C) 1997 Michael Van Canneyt
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 1, or (at your option)
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
--------------------------------------------------------------------------- }
28
Const RevString = '$Revision: 1.5 $';
30
Options : Array[0..NrOptions] Of String[20] =
31
('v','callback','main','altformat','compensate');
34
{ Properties of an object }
35
ContProps=(CPclass,CPtype,CPbox,CPBoxtype,CPColors,CPalignment,CPstyle,CPsize,
36
CPlcol,CPlabel,CPShortcut,CPresize,CPgravity,CPname,CPCallback,
39
{ Properties of an object for which defaults must be set }
40
AdjProps=(APClass,APBoxtype,ApColors,APAlignment,APSize,APLcol,APstyle,APgravity);
41
{ List of all object classes }
42
ObjClasses=(FL_INVALID,FL_BUTTON, FL_LIGHTBUTTON,FL_ROUNDBUTTON, FL_ROUND3DBUTTON,
43
FL_CHECKBUTTON, FL_BITMAPBUTTON, FL_PIXMAPBUTTON,FL_BITMAP, FL_PIXMAP,
44
FL_BOX, FL_TEXT, FL_MENU, FL_CHART, FL_CHOICE, FL_COUNTER, FL_SLIDER, FL_VALSLIDER, FL_INPUT,
45
FL_BROWSER,FL_DIAL,FL_TIMER,FL_CLOCK, FL_POSITIONER, FL_FREE,
46
FL_XYPLOT,FL_FRAME, FL_LABELFRAME, FL_CANVAS, FL_GLCANVAS,
47
FL_IMAGECANVAS, FL_FOLDER);
48
{ Properties in preamble }
49
PreProps=(PPmagic,PPNrforms,PPUnitofMeasure,PPinvalid);
50
{ Properties of a form }
51
FormProps=(FPName,FPWidth,FPHeight,FPnumObjs,FPinvalid);
54
{ Names of all object properties }
55
ContPropNames : Array[ContProps] of string[20] =
56
('class','type','box','boxtype','colors','alignment','style','size',
57
'lcol','label','shortcut','resize','gravity','name','callback',
60
{ Names of all object properties which must be checked.}
61
AdjPropsNames : Array[AdjProps] of string[20] =
62
('class','boxtype','colors','alignment','size','lcol','style','gravity');
63
{ Names of all preamble properties }
64
PrePropNames : Array[PreProps] of string[20] =
65
('Magic','Number of forms','Unit of measure','Invalid');
66
{ Names of all form properties }
67
FormPropNames : Array[FormProps] of string[20] =
68
('Name','Width','Height','Number of Objects','Invalid');
69
{ Names of all object classes }
70
FObjClassNames : Array[ObjClasses] of string[20]=
71
('FL_INVALID','BUTTON', 'LIGHTBUTTON','ROUNDBUTTON', 'ROUND3DBUTTON',
72
'CHECKBUTTON', 'BITMAPBUTTON', 'PIXMAPBUTTON','BITMAP', 'PIXMAP',
73
'BOX', 'TEXT', 'MENU', 'CHART', 'CHOICE', 'COUNTER', 'SLIDER', 'VALSLIDER', 'INPUT',
74
'BROWSER','DIAL','TIMER','CLOCK', 'POSITIONER', 'FREE',
75
'XYPLOT','FRAME', 'LABELFRAME', 'CANVAS', 'GLCANVAS',
76
'IMAGECANVAS', 'FOLDER');
78
{ Default properties. If empty a property is ignored.
79
To force setting of a property, put 'FL_FORCE' as a string.
80
Mind : Case sensitive }
82
DefProps : array[ObjClasses,AdjProps] of string[30] =
83
(('FL_INVALID','','','','','','FL_NORMAL_STYLE','FL_FORCE'),
84
('BUTTON','FL_UP_BOX','FL_COL1 FL_COL1','FL_ALIGN_CENTER','','FL_LCOL','FL_NORMAL_STYLE','FL_FORCE'),
85
('LIGHTBUTTON','FL_UP_BOX','FL_COL1 FL_YELLOW','FL_ALIGN_CENTER','','FL_LCOL','FL_NORMAL_STYLE','FL_FORCE'),
86
('ROUNDBUTTON','FL_NO_BOX','FL_MCOL FL_YELLOW','FL_ALIGN_CENTER','','FL_LCOL','FL_NORMAL_STYLE','FL_FORCE'),
87
('ROUND3DBUTTON','FL_NO_BOX','FL_COL1 FL_BLACK','FL_ALIGN_CENTER','','FL_LCOL','FL_NORMAL_STYLE','FL_FORCE'),
88
('CHECKBUTTON','FL_NO_BOX','FL_COL1 FL_YELLOW','FL_ALIGN_CENTER','','FL_LCOL','FL_NORMAL_STYLE','FL_FORCE'),
89
('BITMAPBUTTON','FL_UP_BOX','FL_COL1 FL_BLUE','FL_ALIGN_BOTTOM','','FL_LCOL','FL_NORMAL_STYLE','FL_FORCE'),
90
('PIXMAPBUTTON','FL_UP_BOX','FL_COL1 FL_YELLOW','FL_ALIGN_BOTTOM','','FL_LCOL','FL_NORMAL_STYLE','FL_FORCE'),
91
('BITMAP','FL_NO_BOX','FL_COL1 FL_COL1','FL_ALIGN_BOTTOM','','FL_LCOL','FL_NORMAL_STYLE','FL_FORCE'),
92
('PIXMAP','FL_NO_BOX','FL_COL1 FL_COL1','FL_ALIGN_BOTTOM','','FL_LCOL','FL_NORMAL_STYLE','FL_FORCE'),
93
('BOX','','','','','','FL_NORMAL_STYLE','FL_FORCE'),
94
('TEXT','FL_FLAT_BOX','FL_COL1 FL_MCOL','FL_ALIGN_LEFT','','FL_LCOL','FL_NORMAL_STYLE','FL_FORCE'),
95
('MENU','FL_BORDER_BOX','FL_COL1 FL_MCOL','FL_ALIGN_CENTER','','FL_LCOL','FL_NORMAL_STYLE','FL_FORCE'),
96
('CHART','FL_BORDER_BOX','FL_COL1','FL_ALIGN_BOTTOM','','FL_LCOL','FL_NORMAL_STYLE','FL_FORCE'),
97
('CHOICE','FL_ROUNDED_BOX','FL_COL1 FL_LCOL','FL_ALIGN_LEFT','','FL_LCOL','FL_NORMAL_STYLE','FL_FORCE'),
98
('COUNTER','FL_UP_BOX','FL_COL1 FL_BLUE','FL_ALIGN_BOTTOM','','FL_LCOL','FL_NORMAL_STYLE','FL_FORCE'),
99
('SLIDER','FL_DOWN_BOX','FL_COL1 FL_COL1','FL_ALIGN_BOTTOM','','FL_LCOL','FL_NORMAL_STYLE','FL_FORCE'),
100
('VALSLIDER','FL_DOWN_BOX','FL_COL1 FL_COL1','FL_ALIGN_BOTTOM','','FL_LCOL','FL_NORMAL_STYLE','FL_FORCE'),
101
('INPUT','FL_DOWN_BOX','FL_COL1 FL_MCOL','FL_ALIGN_LEFT','','FL_LCOL','FL_NORMAL_STYLE','FL_FORCE'),
102
('BROWSER','FL_DOWN_BOX','FL_COL1 FL_YELLOW','FL_ALIGN_BOTTOM','FL_SMALL_FONT','FL_LCOL','FL_NORMAL_STYLE','FL_FORCE'),
103
('DIAL','FL_FLAT_BOX','FL_COL1 FL_RIGHT_BCOL','FL_ALIGN_BOTTOM','','FL_LCOL','FL_NORMAL_STYLE','FL_FORCE'),
104
('TIMER','FL_DOWN_BOX','FL_COL1 FL_RED','FL_ALIGN_CENTER','','FL_LCOL','FL_NORMAL_STYLE','FL_FORCE'),
105
('CLOCK','FL_UP_BOX','FL_INACTIVE_COL FL_BOTTOM_BCOL','FL_ALIGN_BOTTOM','','FL_BLACK','FL_NORMAL_STYLE','FL_FORCE'),
106
('POSITIONER','FL_DOWN_BOX','FL_COL1 FL_RED','FL_ALIGN_BOTTOM','','FL_LCOL','FL_NORMAL_STYLE','FL_FORCE'),
107
('FREE','','','','','','FL_NORMAL_STYLE','FL_FORCE'),
108
('XYPLOT','FL_FLAT_BOX','FL_COL1','FL_ALIGN_BOTTOM','','FL_LCOL','FL_NORMAL_STYLE','FL_FORCE'),
109
('FRAME','','FL_BLACK FL_COL1','','','FL_BLACK','FL_NORMAL_STYLE','FL_FORCE'),
110
('LABELFRAME','','','','','','FL_NORMAL_STYLE','FL_FORCE'),
111
('CANVAS','FL_NO_BOX','','FL_ALIGN_TOP','','','FL_NORMAL_STYLE','FL_FORCE'),
112
('GLCANVAS','','','','','','FL_NORMAL_STYLE','FL_FORCE'),
113
('IMAGECANVAS','','','','','','FL_NORMAL_STYLE','FL_FORCE'),
114
('FOLDER','','','','','','FL_NORMAL_STYLE','FL_FORCE'));
118
PControl = ^TControl;
120
Props : array[ContProps] of string;
121
NextControl : PControl;
125
PFormRec = ^TFormRec;
128
Width,Height : String[5];
132
{ Callback data type }
138
{ Property emitting procedures }
139
EmitProp = Procedure (Data : PControl;ObjClass : ObjClasses);
142
OptionsSet : Array[1..NrOptions] Of Boolean;
144
Infile,outfile : Text;
146
NrForms,NrControls : Longint;
149
{ Default properties emitters }
150
EmitProcs : array [AdjProps] of EmitProp;
151
{ Class specific property emitters. Nil pointers are ignored.}
152
ClassEmitters : Array[ObjClasses] of EmitProp;
154
{ ------------------------------------------------------------------------
156
------------------------------------------------------------------------ }
159
Function IntTostr (s : Longint) : String;
169
Procedure EmitError (Const s : String);
172
writeln (stderr,'Error: ',s);
176
Procedure EmitLineError (Const s : string);
179
EmitError('Line '+IntToStr(LineNr)+': '+s)
183
{ ------------------------------------------------------------------------
185
------------------------------------------------------------------------ }
193
Procedure ShowVersion;
196
Writeln ('fd2pascal : ',RevString);
203
Writeln ('fd2pascal : usage :');
204
writeln (' fd2pascal [options] filename');
205
writeln (' Where [options] may be zero or more of :');
206
writeln (' -compensate Emit size-compensation code.');
207
writeln (' -altformat Emit code in alternate format.');
208
writeln (' -main Emit program instead of unit.');
209
writeln (' -callback Emit callback stubs.');
218
for i:=1 to paramcount do
220
if paramstr(i)[1]<>'-' then
222
EmitError('Only one filename supported. Ignoring :'+paramstr(i))
224
Filename:=Paramstr(i)
227
os:=copy(paramstr(i),2,length(paramstr(i))-1);
229
for j:=0 to NrOptions do
230
if os=options[j] then k:=j;
231
if k=NrOptions+1 then
232
EmitError('Option not recognised : '+paramstr(i))
234
if k=0 then ShowVersion else OptionsSet[k]:=True;
239
EmitError('No filename supplied. Exiting.');
244
{ ------------------------------------------------------------------------
245
Code for reading the input file.
246
------------------------------------------------------------------------ }
251
if pos('.fd',FileName)=0 then
252
FileName:=FileName+'.fd';
253
assign(infile,Filename);
259
EmitError('Can''t open : '+filename);
271
Procedure GetLine(Var S : String);
277
writeln ('Reading line : ',linenr)
281
Procedure ProcessPreAmbleLine (Const s: String);
283
var key,value : string;
293
Key:=Copy(s,1,ppos-1);
294
Value:=Copy(s,ppos+2,length(s)-ppos-1);
296
for i:=PPmagic to PPinvalid do
297
if key=PrePropNames[i] then k:=i;
299
EmitLineError('Unknown keyword : '+Key)
305
val(value,NrForms,code);
306
if code<>0 then EmitLineError('Invalid number of forms');
311
{ ------------------------------------------------------------------------
312
Code for reading preamble.
313
------------------------------------------------------------------------ }
316
Procedure DoPreamble;
322
writeln ('Starting preamble');
325
while pos('= FORM =',line)=0 do
327
ProcessPreAmbleLine(line);
332
{ ------------------------------------------------------------------------
333
Code for reading 1 object.
334
------------------------------------------------------------------------ }
337
Procedure ProcessControlLine (PC : PControl; const S : String);
339
Var Key,Value : String;
348
Key:=Copy(s,1,ppos-1);
349
Value:=Copy(s,ppos+2,length(s)-ppos-1);
351
For i:=CPclass to CPInvalid do
352
if ContPropNames[i]=Key then k:=i;
355
EmitLineError('Unknown keyword'+key);
361
Procedure ProcessControl (PC : PControl);
367
Writeln ('Starting Control');
372
ProcessControlLine (PC,line);
378
{ ------------------------------------------------------------------------
379
Code for reading 1 form.
380
------------------------------------------------------------------------ }
382
Procedure ProcessFormLine (PF : PFormRec; const S : String);
384
Var Key,Value : String;
393
Key:=Copy(s,1,ppos-1);
394
Value:=Copy(s,ppos+2,length(s)-ppos-1);
396
For i:=FPName to FPInvalid do
397
if FormPropNames[i]=Key then k:=i;
400
EmitLineError('Unknown keyword'+key);
404
FPname : PF^.name:=value;
405
FPWidth : PF^.width:=value;
406
FPHeight : PF^.height:=value;
408
val(value,Nrcontrols,code);
409
If Code<>0 then EmitLineError('Invalid number of objects : '+value)
414
Procedure ProcessForm (PF : PFormRec);
417
CurrentControl : PControl;
422
writeln('Starting form');
434
ProcessFormLine(PF,Line);
443
CurrentControl:=Controls;
444
for i:=1 to nrcontrols do
446
ProcessControl(CurrentControl);
448
New(CurrentControl^.NextControl)
450
CurrentControl^.NextControl:=nil;
451
CurrentControl:=CurrentControl^.NextControl
457
{ ------------------------------------------------------------------------
458
Code for reading the forms.
459
------------------------------------------------------------------------ }
466
CurrentForm: PformRec;
470
if NrForms=0 then exit;
472
Currentform:=FormRoot;
473
for i:=1 to nrforms do
475
ProcessForm (CurrentForm);
477
Currentform^.NextForm:=nil
479
New(CurrentForm^.NextForm);
480
CurrentForm:=CurrentForm^.NextForm;
484
{ ------------------------------------------------------------------------
485
Code for reading the postamble.
486
------------------------------------------------------------------------ }
489
Procedure DoPostamble;
494
{ ------------------------------------------------------------------------
495
Code for writing the output file.
496
------------------------------------------------------------------------ }
498
Procedure OpenOutFile;
503
FileName:=Copy(Filename,1,Length(Filename)-3)+'.pp';
504
if fpstat(FileName,info)<>-1 Then
506
{ File exists, move to .bak}
507
fplink (FileName,FileName+'.bak');
511
assign(outfile,filename);
517
EmitError('Couldn''t open output file : '+filename);
522
Procedure CloseOutFile;
528
{ ------------------------------------------------------------------------
529
Code to emit Header/variable/type declarations
530
------------------------------------------------------------------------ }
533
Procedure EmitType (fp : Pformrec);
538
writeln (OutFile,' TFD_',fp^.name,' = record');
539
writeln (OutFile,' ',fp^.name,' : PFL_FORM;');
540
writeln (OutFile,' vdata : Pointer;');
541
writeln (OutFile,' ldata : Longint;');
543
{Skip first control, is formbackground }
544
if cp<>nil then cp:=cp^.nextcontrol;
547
if cp^.props[CPclass]<>'FL_END_GROUP' then
549
write (Outfile,' ',cp^.props[CPname]);
550
if cp^.nextcontrol<>nil then
551
writeln (OutFile,',')
553
writeln (OutFile,' : PFL_OBJECT;');
557
writeln (OutFile,' end;');
558
writeln (OutFile,' PFD_',fp^.name,' = ^TFD_',fp^.name,';');
562
Procedure EmitVar (fp : Pformrec);
567
writeln (OutFile,' ',fp^.name,' : PFL_FORM;');
569
{Skip first control, is formbackground }
570
if cp<>nil then cp:=cp^.nextcontrol;
573
if cp^.props[CPclass]<>'FL_END_GROUP' then
575
write (Outfile,' ',cp^.props[CPname]);
576
if cp^.nextcontrol<>nil then
577
writeln (OutFile,',')
579
writeln (OutFile,' : PFL_OBJECT;');
586
Procedure EmitHeader;
591
if OptionsSet[2] then
592
write (OutFile,'Program ')
594
write (OutFile,'Unit ');
595
writeln (OutFile,basename(filename,'.pp'),';');
597
writeln (OutFile,'{ Form definition file generated by fd2pascal }');
599
if not OptionsSet[2] then
601
writeln (OutFile,'Interface');
604
writeln (OutFile,'Uses forms;');
606
writeln (OutFile,' { Variable / Type definitions. }');
607
if Optionsset[3] then
608
writeln (OutFile,'Var')
610
writeln (OutFile,'Type');
614
if not optionsset[3] then
615
EmitType(fp) { Emit Type definitions }
617
EmitVar(fp); { Emit Variable declaration}
620
if not optionsset[2] then
622
{ No program, we must emit interface stuff }
623
if not (optionsset[3]) then
625
{ Emit normal interface declarations
631
writeln (OutFile,'Function create_form_',name,' : PFD_',name,';');
637
{ Emit alternate interface declaration
638
-> 1 function to create all forms.}
639
writeln (OutFile,'Procedure Create_The_Forms;');
642
writeln (OutFile,'Implementation');
646
{ We must make a program. }
647
if not(optionsset[3]) then
649
{ Normal format, so we need to emit variables for the forms.}
650
writeln (OutFile,'Var');
654
writeln (OutFile,' ',fp^.name,' : PFD_',fp^.name,';');
663
{ ------------------------------------------------------------------------
664
Code to emit footer/main program
665
------------------------------------------------------------------------ }
668
Procedure EmitCreateforms;
673
writeln (OutFile,'Procedure Create_The_Forms;');
675
writeln (OutFile,'begin');
679
writeln(OutFile,'create_form_',fp^.name,';');
682
writeln (outFile,'End;');
686
Procedure EmitAlternateMain;
688
{ Alternate format, we just call creatallforms to create all forms}
689
writeln (OutFile,'Create_The_Forms;');
690
writeln (OutFile,' fl_show_form(',formroot^.name,
691
',FL_PLACE_CENTER,FL_FULLBORDER,''',
692
FormRoot^.name,''');');
700
{ variables are emitted in the header }
705
writeln (OutFile,' ',fp^.name,' :=Create_Form_',fp^.name,';');
708
{ Show the first form }
709
writeln (OutFile,' fl_show_form(',formroot^.name,'^.',Formroot^.name,
710
',FL_PLACE_CENTER,FL_FULLBORDER,''',
711
FormRoot^.name,''');');
714
Procedure EmitFooter;
716
if OptionsSet[3] then {Alternate format.}
718
if Optionsset[2] then
722
writeln (OutFile,'Begin');
723
writeln (OutFile,' fl_initialize (@argc,argv,''',
724
basename(Filename,'.pp'),''',nil,0);');
725
if Not(OptionsSet[3]) then
729
writeln (OutFile,' fl_do_forms;');
732
writeln (OutFile,'begin');
733
writeln (OutFile,'end.')
739
{ ------------------------------------------------------------------------
740
Code to emit properties
741
------------------------------------------------------------------------ }
744
Function EmitString(S : string) : String;
751
for i:=1 to length(s) do
752
if s[i]<>'''' then temp:=temp+s[i] else temp:=temp+'''''';
757
Procedure EmitBoxtype (cp : PControl;ObjClass : ObjClasses);
761
writeln ('EmitBoxType called with args:');
762
writeln (cp^.props[cpboxtype]);
763
writeln (defprops[objclass,APboxtype]);
764
writeln ('for object : ',defprops[objclass,apclass]);
765
writeln ('With object : ',cp^.props[cpclass]);
767
if cp^.props[cpboxtype]<>defprops[objclass,APboxtype] then
768
writeln (OutFile,' fl_set_object_boxtype(obj,',
769
cp^.props[cpboxtype],');')
772
Procedure EmitColors (cp : PControl;ObjClass : ObjClasses);
777
if cp^.props[cpcolors]<>defprops[objclass,APcolors] then
779
temp:=cp^.props[cpcolors];
780
if pos(' ',temp)=0 then exit;
781
temp[pos(' ',temp)]:=',';
782
writeln (OutFile,' fl_set_object_color(obj,',temp,');');
786
Procedure EmitAlignment (cp : PControl;ObjClass : ObjClasses);
789
if cp^.props[cpalignment]<>defprops[objclass,APalignment] then
790
writeln (OutFile,' fl_set_object_alignment(obj,',
791
cp^.props[cpalignment],');');
794
Procedure EmitLcol (cp : PControl;ObjClass : ObjClasses);
797
if cp^.props[cplcol]<>defprops[objclass,APlcol] then
798
writeln (OutFile,' fl_set_object_lcol(obj,',
799
cp^.props[cplcol],');');
803
Procedure EmitSize (cp : PControl;ObjClass : ObjClasses);
806
if cp^.props[cpsize]<>defprops[objclass,APsize] then
807
writeln (OutFile,' fl_set_object_lsize(obj,',
808
cp^.props[cpsize],');');
811
Procedure EmitStyle (cp : PControl;ObjClass : ObjClasses);
814
if cp^.props[cpstyle]<>defprops[objclass,APstyle] then
815
writeln (OutFile,' fl_set_object_lstyle(obj,',
816
cp^.props[cpstyle],');');
819
Procedure EmitGravity (cp : PControl;ObjClass : ObjClasses);
824
if cp^.props[cpstyle]<>'FL_NoGravity FL_NoGravity' then
826
temp:=cp^.props[cpstyle];
827
if pos(' ',temp)=0 then exit;
828
temp[pos(' ',temp)]:=',';
829
writeln (OutFile,' fl_set_object_gravity(obj,',
835
Procedure EmitProperties (Cp : PControl; Objclass : ObjClasses);
840
for i:=APboxtype to APgravity do
841
if DefProps[ObjClass,i]<>'' then
842
EmitProcs[i](cp,objclass);
845
{ ------------------------------------------------------------------------
847
------------------------------------------------------------------------ }
849
Procedure EmitObject(cp : PControl);
858
temp:=lowercase(props[CPclass]);
860
if temp='begin_group' then
864
if not (Optionsset[3]) then Write (OutFile,'fdui^.');
865
writeln (OutFile,props[cpname],':=fl_bgn_group;');
868
else if temp='end_group' then
870
writeln (OutFile,' fl_end_group;');
874
{ Normal object. Emit creation code. }
875
write (OutFile,' obj:=fl_add_',temp,' (FL_',props[Cptype],',');
879
write (OutFile,copy(temp,1,pos(' ',temp)-1),',');
880
delete (temp,1,pos(' ',temp));
882
writeln (OutFile,temp,',',EmitString(props[cplabel]),');');
883
{ Emit Callback code if needed }
884
if props[cpcallback]<>'' then
886
write (OutFile,' fl_set_object_callback(obj,PFL_CALLBACKPTR(@');
887
write (OutFile,props[CPcallback],'),');
888
if props[CPargument]<>'' then
889
writeln (OutFile,props[CPargument],');')
891
writeln (OutFile,'0);');
893
{ If known object, start emitting properties }
894
temp:=props[CPclass];
897
for j:=FL_BUTTON to FL_FOLDER do
898
if temp=DefProps[j,apclass] then k:=j;
899
if k<>FL_INVALID then
902
EmitProperties (cp,k);
903
{ If A class-specific emitter exists, call it.}
904
if Assigned(ClassEmitters[k]) then
905
ClassEmitters[k] (cp,k);
907
{ Assign to needed object. }
908
if Optionsset[3] then
909
Writeln (OutFile,' ',props[cpname],':=obj;')
911
Writeln (OutFile,' fdui^.',props[cpname],':=obj;');
915
{ ------------------------------------------------------------------------
917
------------------------------------------------------------------------ }
919
Procedure EmitForm(fp : PFormRec);
927
if Optionsset[3] then
929
writeln (OutFile,'Procedure create_form_',name,';');
931
writeln (OutFile,'Var obj : PFL_OBJECT;');
933
writeln (OutFile,'Begin');
934
writeln (OutFile,' If ',name,'<>nil then exit;');
935
write (OutFile,' ',name);
939
writeln (OutFile,'Function create_form_',name,' : PFD_',name,';');
941
writeln (OutFile,'Var obj : PFL_OBJECT;');
942
writeln (OutFile,' fdui : PFD_',name,';');
944
writeln (OutFile,'Begin');
945
writeln (OutFile,' New(fdui);');
946
write (OutFile,' fdui^.',name);
948
writeln (OutFile,':=fl_bgn_form(FL_NO_BOX,'
952
writeln (OutFile,' obj:=fl_add_box(',cp^.props[CPboxtype],',0,0,',
955
EmitString (cp^.props[CPname]),');');
963
writeln (OutFile,' fl_end_form;');
964
if Optionsset[4] then
966
{ Emit Compensation code }
967
write (OutFile,' fl_adjust_form_size(');
968
if not(OptionsSet[3]) then write (OutFile,'fdui^.');
969
writeln(OutFile,fp^.name,');');
971
if not(OptionsSet[3]) then
973
writeln (OutFile,' fdui^.',fp^.name,'^.fdui:=fdui;');
974
writeln (OutFile,' create_form_',fp^.name,':=fdui;');
976
writeln (OutFile,'end;');
986
{ Start emitting forms }
995
{ ------------------------------------------------------------------------
996
Code to emit callbacks
997
------------------------------------------------------------------------ }
999
Procedure CollectCallbacks;
1001
Var CurrentCb,CBwalk : PCBrec;
1014
if cp^.props[CPcallback]<>'' then
1018
while cbwalk<>nil do
1019
if upcase(cbwalk^.name)=upcase(cp^.props[CPcallback]) then
1022
cbwalk:=cbwalk^.next;
1025
new(currentcb^.next);
1026
currentcb:=currentcb^.next;
1027
currentcb^.name:=cp^.props[CPcallback];
1028
currentcb^.next:=nil;
1035
cbroot^.name:=cp^.props[CPcallback];
1038
cp:=cp^.nextcontrol;
1044
Procedure EmitCallback (Const s : string);
1047
writeln (OutFile,'Procedure ',s,' (Sender: PFL_OBJECT; Data : Longint); export;');
1049
writeln (OutFile,'begin');
1050
writeln (OutFile,' { Place your code here }');
1051
writeln (OutFile,'end;');
1055
Procedure EmitCallBacks;
1060
{ See if we must emit callback stubs }
1061
If Optionsset[1] then
1066
EmitCallBack(cb^.Name);
1073
{ ------------------------------------------------------------------------
1074
EmitterTable initialization Code
1075
------------------------------------------------------------------------ }
1077
Procedure EmitDummy (cp : PControl;ObjClass : ObjClasses);
1082
Procedure InitEmitters;
1087
EmitProcs[APClass]:=@EmitDummy;
1088
EmitProcs[APBoxtype]:=@EmitBoxType;
1089
EmitProcs[APColors]:=@EmitColors;
1090
EmitProcs[APAlignment]:=@EmitAlignment;
1091
EmitProcs[APlcol]:=@EmitLcol;
1092
EmitProcs[APsize]:=@EmitSize;
1093
EmitProcs[APStyle]:=@EmitStyle;
1094
EmitProcs[APgravity]:=@EmitGravity;
1095
for i:=FL_INVALID to FL_FOLDER do
1096
ClassEmitters[i]:=EmitProp(Nil);
1099
{ ------------------------------------------------------------------------
1101
------------------------------------------------------------------------ }
1113
{ Write output file }