-
Notifications
You must be signed in to change notification settings - Fork 1
/
UG_TXB.INC
384 lines (359 loc) · 9.55 KB
/
UG_TXB.INC
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
(*
unit UG_TXB;
interface
implementation
*)
procedure _UG_TextboxUpdate(wnd: PUG_WINDOW; obj: pUG_OBJECT);
{$ifdef VER70}far;{$endif}
var
txb: PUG_TEXTBOX;
a: UG_AREA;
txt: UG_TEXT;
(* Get object-specific data *)
begin
txb := PUG_TEXTBOX(obj^.Data);
(* -------------------------------------------------- *)
(* Object touch section *)
(* -------------------------------------------------- *)
(* Textbox doesn't support touch *)
(* -------------------------------------------------- *)
(* Object update section *)
(* -------------------------------------------------- *)
if (obj^.state and OBJ_STATE_UPDATE) <> 0 then
begin
if (obj^.state and OBJ_STATE_VISIBLE) <> 0 then
begin
(* Full redraw necessary? *)
if (obj^.state and OBJ_STATE_REDRAW) <> 0 then
begin
UG_WindowGetArea(wnd^, a);
obj^.a_abs.xs := obj^.a_rel.xs + a.xs;
obj^.a_abs.ys := obj^.a_rel.ys + a.ys;
obj^.a_abs.xe := obj^.a_rel.xe + a.xs;
obj^.a_abs.ye := obj^.a_rel.ye + a.ys;
if (obj^.a_abs.ye >= wnd^.ye) or (obj^.a_abs.xe >= wnd^.xe) then
exit;
{$ifdef USE_PRERENDER_EVENT}
_UG_SendObjectPrerenderEvent(wnd, obj);
{$endif}
txt.bc := txb^.bc;
txt.fc := txb^.fc;
UG_FillFrame(obj^.a_abs.xs, obj^.a_abs.ys, obj^.a_abs.xe,
obj^.a_abs.ye, txt.bc);
txt.a.xs := obj^.a_abs.xs;
txt.a.ys := obj^.a_abs.ys;
txt.a.xe := obj^.a_abs.xe;
txt.a.ye := obj^.a_abs.ye;
txt.align := txb^.align;
txt.font := txb^.font;
txt.h_space := txb^.h_space;
txt.v_space := txb^.v_space;
txt.str := txb^.str;
(* Draw Textbox text *)
_UG_PutText(txt);
obj^.state := obj^.state and (not OBJ_STATE_REDRAW);
{$ifdef USE_POSTRENDER_EVENT}
_UG_SendObjectPostrenderEvent(wnd, obj);
{$endif}
end;
end
else
begin
UG_FillFrame(obj^.a_abs.xs, obj^.a_abs.ys, obj^.a_abs.xe, obj^.a_abs.ye, wnd^.bc);
end;
obj^.state := obj^.state and (not OBJ_STATE_UPDATE);
end;
end;
function UG_TextboxCreate(const wnd: UG_WINDOW; var txb: UG_TEXTBOX;
id: UG_U8; xs, ys: UG_S16; xe, ye: UG_S16): UG_RESULT;
var
obj: PUG_OBJECT;
begin
obj := _UG_GetFreeObject(wnd);
if obj = nil then
begin
UG_TextboxCreate := RESULT_FAIL;
exit;
end;
(* Initialize object-specific parameters *)
txb.str := nil;
if gui <> nil then
txb.font := @(gui^.font)
else
txb.font := nil;
txb.style := 0;
txb.fc := wnd.fc;
txb.bc := wnd.bc;
txb.align := ALIGN_CENTER;
txb.h_space := 0;
txb.v_space := 0;
(* Initialize standard object parameters *)
obj^.update := _UG_TextboxUpdate;
obj^.touch_state := OBJ_TOUCH_STATE_INIT;
obj^.otype := OBJ_TYPE_TEXTBOX;
obj^.event := OBJ_EVENT_NONE;
obj^.a_rel.xs := xs;
obj^.a_rel.ys := ys;
obj^.a_rel.xe := xe;
obj^.a_rel.ye := ye;
obj^.a_abs.xs := -1;
obj^.a_abs.ys := -1;
obj^.a_abs.xe := -1;
obj^.a_abs.ye := -1;
obj^.id := id;
obj^.state := obj^.state or (OBJ_STATE_VISIBLE or OBJ_STATE_REDRAW or OBJ_STATE_VALID);
obj^.Data := @txb;
obj^.state := obj^.state and (not OBJ_STATE_FREE);
(* Update function: Do your thing! *)
UG_TextboxCreate := RESULT_OK;
end;
function UG_TextboxDelete(const wnd: UG_WINDOW; id: UG_U8): UG_RESULT;
begin
UG_TextboxDelete := _UG_DeleteObject(wnd, OBJ_TYPE_TEXTBOX, id);
end;
function UG_TextboxShow(const wnd: UG_WINDOW; id: UG_U8): UG_RESULT;
var
obj: PUG_OBJECT;
begin
obj := _UG_SearchObject(wnd, OBJ_TYPE_TEXTBOX, id);
if obj <> nil then
begin
obj^.state := obj^.state or (OBJ_STATE_VISIBLE);
obj^.state := obj^.state or (OBJ_STATE_UPDATE or OBJ_STATE_REDRAW);
UG_TextboxShow := RESULT_OK;
end
else
UG_TextboxShow := RESULT_FAIL;
end;
function UG_TextboxHide(const wnd: UG_WINDOW; id: UG_U8): UG_RESULT;
var
obj: PUG_OBJECT;
begin
obj := _UG_SearchObject(wnd, OBJ_TYPE_TEXTBOX, id);
if obj <> nil then
begin
obj^.state := obj^.state and (not OBJ_STATE_VISIBLE);
obj^.state := obj^.state or OBJ_STATE_UPDATE;
UG_TextboxHide := RESULT_OK;
end
else
UG_TextboxHide := RESULT_FAIL;
end;
(* Text box setters *)
function UG_TextboxSetForeColor(const wnd: UG_WINDOW; id: UG_U8;
fc: UG_COLOR): UG_RESULT;
var
obj: PUG_OBJECT;
txb: PUG_TEXTBOX;
begin
obj := _UG_SearchObject(wnd, OBJ_TYPE_TEXTBOX, id);
if obj <> nil then
begin
txb := PUG_TEXTBOX(obj^.Data);
txb^.fc := fc;
obj^.state := obj^.state or (OBJ_STATE_UPDATE or OBJ_STATE_REDRAW);
UG_TextboxSetForeColor := RESULT_OK;
end
else
UG_TextboxSetForeColor := RESULT_FAIL;
end;
function UG_TextboxSetBackColor(const wnd: UG_WINDOW; id: UG_U8;
bc: UG_COLOR): UG_RESULT;
var
obj: PUG_OBJECT;
txb: PUG_TEXTBOX;
begin
obj := _UG_SearchObject(wnd, OBJ_TYPE_TEXTBOX, id);
if obj <> nil then
begin
txb := PUG_TEXTBOX(obj^.Data);
txb^.bc := bc;
obj^.state := obj^.state or (OBJ_STATE_UPDATE or OBJ_STATE_REDRAW);
UG_TextboxSetBackColor := RESULT_OK;
end
else
UG_TextboxSetBackColor := RESULT_FAIL;
end;
function UG_TextboxSetText(const wnd: UG_WINDOW; id: UG_U8; str: PChar): UG_RESULT;
var
obj: PUG_OBJECT;
txb: PUG_TEXTBOX;
begin
obj := _UG_SearchObject(wnd, OBJ_TYPE_TEXTBOX, id);
if obj <> nil then
begin
txb := PUG_TEXTBOX(obj^.Data);
txb^.str := str;
obj^.state := obj^.state or (OBJ_STATE_UPDATE or OBJ_STATE_REDRAW);
UG_TextboxSetText := RESULT_OK;
end
else
UG_TextboxSetText := RESULT_FAIL;
end;
function UG_TextboxSetFont(const wnd: UG_WINDOW; id: UG_U8; font: PUG_FONT): UG_RESULT;
var
obj: PUG_OBJECT;
txb: PUG_TEXTBOX;
begin
obj := _UG_SearchObject(wnd, OBJ_TYPE_TEXTBOX, id);
if obj <> nil then
begin
txb := PUG_TEXTBOX(obj^.Data);
txb^.font := font;
obj^.state := obj^.state or (OBJ_STATE_UPDATE or OBJ_STATE_REDRAW);
UG_TextboxSetFont := RESULT_OK;
end
else
UG_TextboxSetFont := RESULT_FAIL;
end;
function UG_TextboxSetHSpace(const wnd: UG_WINDOW; id: UG_U8; hs: UG_S8): UG_RESULT;
var
obj: PUG_OBJECT;
txb: PUG_TEXTBOX;
begin
obj := _UG_SearchObject(wnd, OBJ_TYPE_TEXTBOX, id);
if obj <> nil then
begin
txb := PUG_TEXTBOX(obj^.Data);
txb^.h_space := hs;
obj^.state := obj^.state or (OBJ_STATE_UPDATE or OBJ_STATE_REDRAW);
UG_TextboxSetHSpace := RESULT_OK;
end
else
UG_TextboxSetHSpace := RESULT_FAIL;
end;
function UG_TextboxSetVSpace(const wnd: UG_WINDOW; id: UG_U8; vs: UG_S8): UG_RESULT;
var
obj: PUG_OBJECT;
txb: PUG_TEXTBOX;
begin
obj := _UG_SearchObject(wnd, OBJ_TYPE_TEXTBOX, id);
if obj <> nil then
begin
txb := PUG_TEXTBOX(obj^.Data);
txb^.v_space := vs;
obj^.state := obj^.state or (OBJ_STATE_UPDATE or OBJ_STATE_REDRAW);
UG_TextboxSetVSpace := RESULT_OK;
end
else
UG_TextboxSetVSpace := RESULT_FAIL;
end;
function UG_TextboxSetAlignment(const wnd: UG_WINDOW; id: UG_U8;
align: UG_U8): UG_RESULT;
var
obj: PUG_OBJECT;
txb: PUG_TEXTBOX;
begin
obj := _UG_SearchObject(wnd, OBJ_TYPE_TEXTBOX, id);
if obj <> nil then
begin
txb := PUG_TEXTBOX(obj^.Data);
txb^.align := align;
obj^.state := obj^.state or (OBJ_STATE_UPDATE or OBJ_STATE_REDRAW);
UG_TextboxSetAlignment := RESULT_OK;
end
else
UG_TextboxSetAlignment := RESULT_FAIL;
end;
(* Text box getters *)
function UG_TextboxGetForeColor(const wnd: UG_WINDOW; id: UG_U8): UG_COLOR;
var
obj: PUG_OBJECT;
txb: PUG_TEXTBOX;
begin
obj := _UG_SearchObject(wnd, OBJ_TYPE_TEXTBOX, id);
if obj <> nil then
begin
txb := PUG_TEXTBOX(obj^.Data);
UG_TextboxGetForeColor := txb^.fc;
end
else
UG_TextboxGetForeColor := C_BLACK;
end;
function UG_TextboxGetBackColor(const wnd: UG_WINDOW; id: UG_U8): UG_COLOR;
var
obj: PUG_OBJECT;
txb: PUG_TEXTBOX;
begin
obj := _UG_SearchObject(wnd, OBJ_TYPE_TEXTBOX, id);
if obj <> nil then
begin
txb := PUG_TEXTBOX(obj^.Data);
UG_TextboxGetBackColor := txb^.bc;
end
else
UG_TextboxGetBackColor := C_BLACK;
end;
function UG_TextboxGetText(const wnd: UG_WINDOW; id: UG_U8): PChar;
var
obj: PUG_OBJECT;
txb: PUG_TEXTBOX;
begin
obj := _UG_SearchObject(wnd, OBJ_TYPE_TEXTBOX, id);
if obj <> nil then
begin
txb := PUG_TEXTBOX(obj^.Data);
UG_TextboxGetText := txb^.str;
end
else
UG_TextboxGetText := nil;
end;
function UG_TextboxGetFont(const wnd: UG_WINDOW; id: UG_U8): PUG_FONT;
var
obj: PUG_OBJECT;
txb: PUG_TEXTBOX;
begin
obj := _UG_SearchObject(wnd, OBJ_TYPE_TEXTBOX, id);
if obj <> nil then
begin
txb := PUG_TEXTBOX(obj^.Data);
UG_TextboxGetFont := txb^.font;
end
else
UG_TextboxGetFont := nil;
end;
function UG_TextboxGetHSpace(const wnd: UG_WINDOW; id: UG_U8): UG_S8;
var
obj: PUG_OBJECT;
txb: PUG_TEXTBOX;
begin
obj := _UG_SearchObject(wnd, OBJ_TYPE_TEXTBOX, id);
if obj <> nil then
begin
txb := PUG_TEXTBOX(obj^.Data);
UG_TextboxGetHSpace := txb^.h_space;
end
else
UG_TextboxGetHSpace := 0;
end;
function UG_TextboxGetVSpace(const wnd: UG_WINDOW; id: UG_U8): UG_S8;
var
obj: PUG_OBJECT;
txb: PUG_TEXTBOX;
begin
obj := _UG_SearchObject(wnd, OBJ_TYPE_TEXTBOX, id);
if obj <> nil then
begin
txb := PUG_TEXTBOX(obj^.Data);
UG_TextboxGetVSpace := txb^.v_space;
end
else
UG_TextboxGetVSpace := 0;
end;
function UG_TextboxGetAlignment(const wnd: UG_WINDOW; id: UG_U8): UG_U8;
var
obj: PUG_OBJECT;
txb: PUG_TEXTBOX;
begin
obj := _UG_SearchObject(wnd, OBJ_TYPE_TEXTBOX, id);
if obj <> nil then
begin
txb := PUG_TEXTBOX(obj^.Data);
UG_TextboxGetAlignment := txb^.align;
end
else
UG_TextboxGetAlignment := 0;
end;
(*
end.
*)