'class BtnSoma
Sub Class_Globals
Private ImgMais As ImageView
Private ImgMenos As ImageView
Private ValorSoma As EditText
Private ValorTotal As Int
Private BordaC As Panel
Private Callback As Object
Private Left, Top, Width, Height As Float
End Sub
Public Sub Initialize(CallbackModule As Object, Parent As Object, Direita As Float, Topo As Float )
Callback = CallbackModule
BordaC.Initialize("BordaC")
ImgMais.Initialize("ImgMais")
ImgMenos.Initialize("ImgMenos")
ValorSoma.Initialize("ValorSoma")
ValorSoma.InputType = ValorSoma.INPUT_TYPE_NUMBERS
ValorSoma.Text = 0
ValorSoma.TextSize = 10
ImgMenos.SetBackgroundImage(LoadBitmap(File.DirAssets,"menosico.png"))
ImgMais.SetBackgroundImage(LoadBitmap(File.DirAssets,"maisico.png"))
BordaC.AddView(ImgMenos,0,0,48,48)
BordaC.AddView(ValorSoma,48,0,48,44)
BordaC.AddView(ImgMais,96,0,48,48)
Width = 155
Height = 50
If Parent Is Activity Then
Dim act As Activity
act = Parent
Left = Direita
Top = Topo
act.AddView(BordaC, Left, Top, Width, Height)
Else
Dim pnlp As Panel
pnlp = Parent
Left = Direita
Top = Topo
pnlp.AddView(BordaC, Left, Top, Width, Height)
End If
End Sub
Private Sub ImgMais_Click
ValorSoma.Text = NumberFormat2(ValorSoma.Text + 1,0,2,2,False)
ValorTotal = ValorSoma.Text
End Sub
Private Sub ImgMenos_Click
If ValorSoma.Text > 0 Then
ValorSoma.Text = NumberFormat2(ValorSoma.Text - 1,0,2,2,False)
ValorTotal = ValorSoma.Text
End If
End Sub
Public Sub GetValue As Int
Return ValorTotal
End Sub