@@ -93,6 +93,7 @@ Module Control
93
93
ctrl.PaddingTop = 0
94
94
ctrl.Text = ""
95
95
ctrl.Value = 0
96
+ ctrl.CalcVisible = 0
96
97
End
97
98
98
99
Sub GenericControlPaint(ctrl as Control)
@@ -147,6 +148,8 @@ Module Control
147
148
148
149
Public Sub Add(ctrl as Control, child as Control)
149
150
Dim tmp as PtrByteArray
151
+ Dim parent as Control
152
+ parent = ctrl
150
153
If ctrl.HasChild Then
151
154
#tmp = #ctrl.Child
152
155
@tmp = @ctrl.Child
@@ -163,14 +166,14 @@ Module Control
163
166
@tmp = @child
164
167
ctrl.NextControl = tmp
165
168
child.HasParent = 1
166
- child.Parent = ctrl
169
+ child.Parent = parent
167
170
Else
168
171
ctrl.HasChild = 1
169
172
#tmp = #child
170
173
@tmp = @child
171
174
ctrl.Child = tmp
172
175
child.HasParent = 1
173
- child.Parent = ctrl
176
+ child.Parent = parent
174
177
End
175
178
End
176
179
@@ -290,13 +293,40 @@ Module Control
290
293
End
291
294
End
292
295
If ctrl.HasParent Then
293
- Focus ctrl.Parent
296
+ Dim i as UInt16
297
+ Dim max as UInt16
298
+ max = Count(ctrl.Parent)
299
+ For i = 1 to max
300
+ next = Item(ctrl.Parent, i)
301
+ If next.Focusable Then
302
+ Focus next
303
+ Return
304
+ End
305
+ End
294
306
End
295
307
Else
296
308
ctrl.ControlKeyboardInteracion.Invoke e
297
309
End
298
310
End
299
311
312
+ Public Sub Show(ctrl as Control)
313
+ If ctrl.HasParent == 0 Then
314
+ Add Screen.ScreenControl, ctrl
315
+ End
316
+ ctrl.Visible = 1
317
+ Dim parent as Control
318
+ parent = ctrl.Parent
319
+ If parent.CalcVisible Then Redraw ctrl
320
+ End
321
+
322
+ Public Sub Hide(ctrl as Control)
323
+ If ctrl.HasParent == 0 Then Return
324
+ ctrl.Visible = 0
325
+ Dim parent as Control
326
+ parent = ctrl.Parent
327
+ If parent.CalcVisible Then Redraw parent
328
+ End
329
+
300
330
End
301
331
302
332
Module Screen
@@ -309,15 +339,68 @@ Module Screen
309
339
ScreenControl.Width = Graphics.GetWidth()
310
340
ScreenControl.Height = Graphics.GetHeight()
311
341
ScreenControl.Visible = 1
342
+ ScreenControl.CalcVisible = 0
312
343
ScreenControl.ControlPaint = AddressOf(ControlPaint)
313
344
End
314
345
315
346
Sub ControlPaint(ctrl as Control)
347
+ ScreenControl.CalcVisible = 1
316
348
Graphics.ClearScreen SystemColors.BackgroundColor()
317
349
Control.DrawChildren ctrl
318
350
End
319
351
End
320
352
353
+ Module TextBox
354
+ Public Sub Initialize(ctrl as Control)
355
+ Control.Initialize ctrl
356
+ ctrl.ControlPaint = AddressOf(ControlPaint)
357
+ ctrl.ControlKeyboardInteracion = AddressOf(ControlKeyboardInteracion)
358
+ End
359
+
360
+ Sub ControlKeyboardInteracion(ctrl as Control, e as KeyboardEventArgs)
361
+ If e.Pressed Then
362
+ Dim ptr as PtrByteArray
363
+ Dim len as UInt16
364
+ e.Cancel = 0
365
+ ctrl.OnKeyPress.Invoke e
366
+ If e.Cancel == 0 Then
367
+ If e.AsciiChar == 8 Then
368
+ ptr = ctrl.Text
369
+ len = String.Length(ctrl.Text)
370
+ If len > 0 Then
371
+ @ptr = @ptr + len
372
+ ptr = 0
373
+ Control.Redraw ctrl
374
+ End
375
+ Return
376
+ End
377
+ If (e.AsciiChar <> 13) AndAlso (e.AsciiChar <> 10) Then
378
+ Dim txt as String
379
+ len = String.Length(ctrl.Text)
380
+ ptr = ctrl.Text
381
+ If ptr < (len + 2) Then Return
382
+ txt = New
383
+ ptr = txt
384
+ @ptr++
385
+ ptr = e.AsciiChar
386
+ @ptr++
387
+ ptr = 0
388
+ String.Concat ctrl.Text, txt
389
+ Control.Redraw ctrl
390
+ End
391
+ End
392
+ Else
393
+ ctrl.OnKeyRelease.Invoke e
394
+ End
395
+ End
396
+
397
+ Sub ControlPaint(ctrl as Control)
398
+ Graphics.DrawRectangle ctrl.CalcX1, ctrl.CalcY1, ctrl.CalcX2, ctrl.CalcY2, SystemColors.WindowBorderColor(), SystemColors.WindowColor()
399
+ If ctrl.HasFocus <> 0 Then Graphics.DrawLine ctrl.CalcX1 + 4, ctrl.CalcY2 - 2, ctrl.CalcX2 - 4, Ctrl.CalcY2 - 2, SystemColors.WindowBorderColor()
400
+ Graphics.DrawText ctrl.Font, ctrl.Text, ctrl.CalcX1 + 4, ctrl.CalcY1 + 4, ctrl.CalcX2 - 4, ctrl.CalcY2 - 4, SystemColors.TextColor(), 1
401
+ End
402
+ End
403
+
321
404
Module Button
322
405
Public Sub Initialize(ctrl as Control)
323
406
Control.Initialize ctrl
0 commit comments