4
This is just a test on how to make a unit EasyGadtools.
6
Feel free to make any changes or improvements on this
7
example. If you make a unit or have a unit to handle
8
gadtools in an easy way let me know.
11
Changed to use systemvartags.
14
nils.sjoholm@mailbox.swipnet.se
18
USES Intuition, Exec, Graphics, GadTools, Utility, pastoc,systemvartags;
22
strarray : array[0..4] of PChar = ('A cycle',
41
function NewGadget(left,top,width,height : Integer; txt : PChar; txtattr: pTextAttr;
42
id : word; flags: Longint; visinfo, userdata : Pointer): tNewGadget;
52
ng_TextAttr := txtattr;
55
ng_VisualInfo := visinfo;
56
ng_UserData := userdata;
61
PROCEDURE CleanUp(why : string; rc : BYTE);
63
IF assigned(wp) THEN CloseWindow(wp);
64
IF assigned(glist) THEN FreeGadgets(glist);
65
IF assigned(vi) THEN FreeVisualInfo(vi);
66
if why <> '' then writeln(why);
70
{ Clones some datas from default pubscreen for fontsensitive
74
ps := LockPubScreen(NIL);
75
IF ps = NIL THEN CleanUp('Can''t get a lock on public screen',20)
78
HFont := ps^.Font^.ta_YSize;
80
vi := GetVisualInfoA(ps,NIL);
81
UnLockPubScreen(NIL, ps);
82
IF vi = NIL THEN CleanUp('Can''t get VisualInfo', 20);
86
function ButtonGadget(id,left,top,width,height:word; txt:pchar): pGadget;
88
ng := NewGadget(left,top,width,height,txt,attr,id,PLACETEXT_IN,vi,nil);
89
gad := CreateGadgetA(BUTTON_KIND,gad,@ng,nil);
93
function ButtonGadget(id,left,top,width,height:word; txt: string): pGadget;
95
ButtonGadget := ButtonGadget(id,left,top,width,height,pas2c(txt));
98
function CycleGadget(id,left,top,width,height:word; txt:pchar ; thearr : Pointer): pGadget;
100
ng := NewGadget(left,top,width,height,txt,attr,id,PLACETEXT_LEFT,vi,nil);
101
gad := CreateGadget(CYCLE_KIND,gad,@ng,[
107
PROCEDURE GenerateWindow;
109
glist := NIL; gad := CreateContext(addr(glist));
110
IF gad = NIL THEN CleanUp('Can''t create GadList', 20);
112
gad := ButtonGadget(0,10,HG,200,HGadget,'File Requester');
115
gad := ButtonGadget(1,10,HG,200,HGadget,'Font Requester');
118
gad := ButtonGadget(2,10,HG,200,HGadget,'Screen Requester');
119
HG := HG + DistGad + 3;
121
gad := CycleGadget(3,100,HG,100,HGadget,'Cycle me',@strarray);
122
HG := HG + DistGad+4;
124
gad := ButtonGadget(4,10,HG,96,HGadget,'OK');
125
gad := ButtonGadget(5,115,HG,96,HGadget,'Cancel');
129
if gad = nil then CleanUp('Can''t create gadgets',20);
131
wp := OpenWindowTags(NIL,[
133
WA_Title, 'Test of EasyGadtools',
136
WA_Flags, WFLG_SMART_REFRESH OR WFLG_NOCAREREFRESH OR
137
WFLG_DEPTHGADGET OR WFLG_DRAGBAR OR WFLG_CLOSEGADGET OR
139
WA_Idcmp, IDCMP_GADGETUP OR IDCMP_CLOSEWINDOW,
144
IF wp = NIL THEN CleanUp('Can''t open window', 20);
155
msg := pIntuiMessage(WaitPort(wp^.UserPort));
156
msg := GT_GetIMsg(wp^.UserPort);
159
iclass := msg^.IClass;
162
IDCMP_CLOSEWINDOW : ende := TRUE;
163
IDCMP_GADGETUP : writeln('You clicked on a gadget');
165
msg := GT_GetIMsg(wp^.UserPort);
173
DistGad := HGadget +4;