-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbase.gfx.gui.textbox.bmx
executable file
·89 lines (60 loc) · 1.85 KB
/
base.gfx.gui.textbox.bmx
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
Rem
===========================================================
GUI Textbox
===========================================================
End Rem
SuperStrict
Import "base.gfx.gui.bmx"
Type TGUITextBox Extends TGUIobject
Field valueAlignment:SVec2F = New SVec2F(0,0)
Field valueColor:SColor8 = SColor8.Black
Field valueEffect:TDrawTextEffect
Field _autoAdjustHeight:Int = False
Method GetClassName:String()
Return "tguitextbox"
End Method
Method Create:TGUITextBox(position:TVec2D = null, dimension:TVec2D = null, text:String, limitState:String="")
Super.CreateBase(position, dimension, limitState)
SetValue(text)
GUIManager.Add(Self)
Return Self
End Method
Method SetAutoAdjustHeight(bool:Int=True)
_autoAdjustHeight = bool
End Method
Method GetHeightWithMax:Int(maxHeight:Int=800)
If _autoAdjustHeight
Return Min(maxHeight, GetFont().GetBoxHeight(value, int(rect.GetW()), maxHeight))
Else
Return rect.GetH()
EndIf
End Method
Method SetValueColor(color:TColor)
if color
valueColor = color.ToSColor8()
else
valueColor = SColor8.Black
endif
End Method
Method SetValueColor(color:SColor8)
valueColor = color
End Method
Method SetValuePosition:Int(valueLeft:Float=0.0, valueTop:Float=0.0)
rect.position.SetXY(valueLeft, valueTop)
End Method
Method SetValueAlignment(alignment:TVec2D)
valueAlignment = new SVec2F(alignment.x, alignment.y)
End Method
Method SetValueAlignment(alignment:SVec2F)
valueAlignment = alignment
End Method
Method DrawContent()
local oldColA:Float = GetAlpha()
SetAlpha oldColA * GetScreenAlpha()
Local scrRect:TRectangle = GetScreenRect()
GetFont().DrawBox(value, scrRect.GetIntX(), scrRect.GetIntY(), rect.GetW(), rect.GetH(), valueAlignment, valueColor, EDrawTextEffect.Shadow, 0.25)
SetAlpha(oldColA)
End Method
Method UpdateLayout()
End Method
End Type