Skip to content

Commit f6c4a5d

Browse files
Melhorias na System.Forms
1 parent d5d6f8e commit f6c4a5d

File tree

5 files changed

+5008
-3219
lines changed

5 files changed

+5008
-3219
lines changed

Plataformas/8086-DOS/System.OS.hcb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ module OS
119119
Catch Error
120120
Console.WriteLine "Ocorreu um erro não tratado"
121121
EscreveErro:
122+
asm "mov ax, 0x3"
123+
asm "int 0x10"
122124
Console.Write ErrorFile()
123125
Console.Write ": "
124126
Console.WriteUInt16 ErrorLine()

Plataformas/8086/System.Forms.hcb

Lines changed: 86 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ Module Control
9393
ctrl.PaddingTop = 0
9494
ctrl.Text = ""
9595
ctrl.Value = 0
96+
ctrl.CalcVisible = 0
9697
End
9798

9899
Sub GenericControlPaint(ctrl as Control)
@@ -147,6 +148,8 @@ Module Control
147148

148149
Public Sub Add(ctrl as Control, child as Control)
149150
Dim tmp as PtrByteArray
151+
Dim parent as Control
152+
parent = ctrl
150153
If ctrl.HasChild Then
151154
#tmp = #ctrl.Child
152155
@tmp = @ctrl.Child
@@ -163,14 +166,14 @@ Module Control
163166
@tmp = @child
164167
ctrl.NextControl = tmp
165168
child.HasParent = 1
166-
child.Parent = ctrl
169+
child.Parent = parent
167170
Else
168171
ctrl.HasChild = 1
169172
#tmp = #child
170173
@tmp = @child
171174
ctrl.Child = tmp
172175
child.HasParent = 1
173-
child.Parent = ctrl
176+
child.Parent = parent
174177
End
175178
End
176179

@@ -290,13 +293,40 @@ Module Control
290293
End
291294
End
292295
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
294306
End
295307
Else
296308
ctrl.ControlKeyboardInteracion.Invoke e
297309
End
298310
End
299311

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+
300330
End
301331

302332
Module Screen
@@ -309,15 +339,68 @@ Module Screen
309339
ScreenControl.Width = Graphics.GetWidth()
310340
ScreenControl.Height = Graphics.GetHeight()
311341
ScreenControl.Visible = 1
342+
ScreenControl.CalcVisible = 0
312343
ScreenControl.ControlPaint = AddressOf(ControlPaint)
313344
End
314345

315346
Sub ControlPaint(ctrl as Control)
347+
ScreenControl.CalcVisible = 1
316348
Graphics.ClearScreen SystemColors.BackgroundColor()
317349
Control.DrawChildren ctrl
318350
End
319351
End
320352

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+
321404
Module Button
322405
Public Sub Initialize(ctrl as Control)
323406
Control.Initialize ctrl

0 commit comments

Comments
 (0)