1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
PROGRAM GadgetDemo;
uses triton, tritonmacros, utility;
{
If you have seen gadtoolsgadgets.c in the RKRM's then you
have seen this program. One diffs is that this example
is made in Triton. Much better.:)
Jun 06 1998
Updated for fpc 1.0.7
11 Jan 2003.
nils.sjoholm@mailbox.swipnet.se
}
CONST
MYGAD_SLIDER = 1;
MYGAD_SLIDERTEXT = 10;
MYGAD_STRING1 = 2;
MYGAD_STRING2 = 3;
MYGAD_STRING3 = 4;
MYGAD_BUTTON = 5;
(* Range for the slider: *)
SLIDER_MIN = 1;
SLIDER_MAX = 20;
SLIDER_DEF = 10;
VAR
Project : pTR_Project;
trmsg : pTR_Message;
quit : Boolean;
dummy : longint;
Triton_App : pTR_App;
Function longToStr (I : Longint) : String;
Var S : String;
begin
Str (I,S);
longToStr:=S;
end;
PROCEDURE CleanExit(errstring : STRING; rc : Integer);
BEGIN
IF Project <> NIL THEN TR_CloseProject(Project);
if Triton_App <> nil then TR_DeleteApp(Triton_App);
IF errstring <> '' THEN WriteLn(errstring);
Halt(rc)
END;
begin
Triton_App := TR_CreateAppTags([
TRCA_Name,'TritonGadtools',
TRCA_LongName,'GadToolsDemo in Triton',
TRCA_Version,'0.01',
TRCA_Info,'Just a test of Triton',
TRCA_Release,'1.0',
TRCA_Date,'26-05-1998',
TAG_DONE]);
if Triton_App = nil then CleanExit('Can''t create Application',20);
ProjectStart;
WindowID(1);
WindowTitle('Instead of GadTools :)');
WindowPosition(TRWP_CENTERTOP);
HorizGroupA;
Space;
VertGroupA;
Space;
LineArray;
BeginLine;
Space;
TextID('_Volume:',MYGAD_SLIDER); SetTRTag(TRAT_Flags,TROF_RIGHTALIGN);
Space;
SliderGadget(SLIDER_MIN,SLIDER_MAX,5,MYGAD_SLIDER);
Space;
TextID('5',MYGAD_SLIDERTEXT); SetTRTag(TRAT_MinWidth, 2);
Space;
EndLine;
SpaceS;
BeginLine;
Space;
TextID('_First:',MYGAD_STRING1); SetTRTag(TRAT_Flags, TROF_RIGHTALIGN);
Space;
StringGadget('Try pressing',MYGAD_STRING1); SetTRTag(TRAT_Value,50);
Space;
EndLine;
SpaceS;
BeginLine;
Space;
TextID('_Second:',MYGAD_STRING2); SetTRTag(TRAT_Flags, TROF_RIGHTALIGN);
Space;
StringGadget('TAB or Shift-TAB',MYGAD_STRING2); SetTRTag(TRAT_Value,50);
Space;
EndLine;
SpaceS;
BeginLine;
Space;
TextID('_Third:',MYGAD_STRING3); SetTRTag(TRAT_Flags, TROF_RIGHTALIGN);
Space;
StringGadget('To see what happens!',MYGAD_STRING3); SetTRTag(TRAT_Value,50);
Space;
EndLine;
EndArray;
Space;
CenteredButton('_Click Here',MYGAD_BUTTON);
Space;
EndGroup;
Space;
EndGroup;
EndProject;
Project := TR_OpenProject(Triton_App,@tritontags);
IF Project = NIL THEN CleanExit('No project',20);
quit := False;
WHILE NOT quit DO BEGIN
dummy := TR_Wait(Triton_App,0);
REPEAT
trmsg := TR_GetMsg(Triton_App);
IF trmsg <> NIL THEN BEGIN
IF (trmsg^.trm_Project = Project) THEN BEGIN
CASE trmsg^.trm_Class OF
TRMS_CLOSEWINDOW : quit := True;
TRMS_NEWVALUE :
BEGIN
case trmsg^.trm_ID of
MYGAD_SLIDER : begin
TR_SetText(Project,MYGAD_SLIDERTEXT,LongToStr(trmsg^.trm_Data));
writeln('Slider at level ',trmsg^.trm_Data);
end;
MYGAD_STRING1 : writeln('String Gadget 1: "',TR_GetString(Project,MYGAD_STRING1),'".');
MYGAD_STRING2 : writeln('String Gadget 2: "',TR_GetString(Project,MYGAD_STRING2),'".');
MYGAD_STRING3 : writeln('String Gadget 3: "',TR_GetString(Project,MYGAD_STRING3),'".');
END;
END;
TRMS_ACTION :
BEGIN
if trmsg^.trm_ID = MYGAD_BUTTON then begin
TR_SetValue(Project,MYGAD_SLIDER,SLIDER_DEF);
TR_SetText(Project,MYGAD_SLIDERTEXT,LongToStr(SLIDER_DEF));
writeln('Button was pressed, slider reset to 10.');
end;
END;
TRMS_ERROR: WriteLN(TR_GetErrorString(trmsg^.trm_Data));
END;
END;
TR_ReplyMsg(trmsg);
END;
UNTIL quit OR (trmsg = NIL);
END;
CleanExit('',0);
END.
|