2009-07-11 02:45:49 +02:00
|
|
|
' Gambas class file
|
|
|
|
|
|
|
|
Export
|
|
|
|
|
|
|
|
Inherits UserControl
|
|
|
|
|
|
|
|
Public Const _Properties As String = "*,Text,Picture,ReadOnly"
|
|
|
|
Public Const _DefaultEvent As String = "Click"
|
|
|
|
|
|
|
|
Event Click
|
2009-07-27 11:32:17 +02:00
|
|
|
Event Change
|
2009-07-11 02:45:49 +02:00
|
|
|
|
|
|
|
Property Picture As Picture
|
|
|
|
Property Text As String
|
2009-09-05 22:54:36 +02:00
|
|
|
Property Read Length As Integer
|
2009-07-11 02:45:49 +02:00
|
|
|
Property ReadOnly As Boolean
|
|
|
|
|
|
|
|
Private $hPanel As Panel
|
|
|
|
Private $hBackground As TextBox
|
|
|
|
Private $hTextBox As TextBox
|
|
|
|
Private $hButton As Button
|
2009-07-12 23:49:13 +02:00
|
|
|
Private $hObserver As Observer
|
2009-07-11 02:45:49 +02:00
|
|
|
|
|
|
|
Public Sub _new()
|
|
|
|
|
2009-07-12 23:49:13 +02:00
|
|
|
Dim sEventName As String = Object.LastEventName
|
|
|
|
|
|
|
|
$hObserver = New Observer(Me) As "Observer"
|
|
|
|
|
2009-07-11 02:45:49 +02:00
|
|
|
$hPanel = New Panel(Me) As "Panel"
|
|
|
|
'$hPanel.Border = Border.Sunken
|
|
|
|
'$hPanel.Background = Color.TextBackground
|
|
|
|
$hPanel.Arrangement = Arrange.Horizontal
|
2009-09-01 03:14:13 +02:00
|
|
|
$hPanel.Padding = 3
|
2009-07-11 02:45:49 +02:00
|
|
|
|
|
|
|
$hBackground = New TextBox($hPanel) As "Background"
|
|
|
|
$hBackground.ReadOnly = True
|
|
|
|
$hBackground.Ignore = True
|
|
|
|
'$hBackground.Enabled = False
|
|
|
|
|
2009-07-12 23:49:13 +02:00
|
|
|
$hTextBox = New TextBox($hPanel)
|
2009-07-11 02:45:49 +02:00
|
|
|
$hTextBox.Expand = True
|
|
|
|
$hTextBox.Border = False
|
2009-07-12 23:49:13 +02:00
|
|
|
Object.Attach($hTextBox, Object.Parent(Me), sEventName)
|
2009-07-11 02:45:49 +02:00
|
|
|
|
|
|
|
$hButton = New Button($hPanel) As "Button"
|
2009-09-01 03:14:13 +02:00
|
|
|
$hButton.W = Desktop.Scale * 4
|
2009-07-11 02:45:49 +02:00
|
|
|
$hButton.Picture = Picture["img/select.png"]
|
|
|
|
|
|
|
|
$hTextBox.SetFocus
|
|
|
|
|
|
|
|
End
|
|
|
|
|
2009-07-12 23:49:13 +02:00
|
|
|
Public Sub _attach(Parent As Object, Name As String)
|
|
|
|
|
|
|
|
If Not Name Then Return
|
|
|
|
If $hTextBox Then Object.Attach($hTextBox, Parent, Name)
|
|
|
|
|
|
|
|
End
|
|
|
|
|
|
|
|
|
2009-07-11 02:45:49 +02:00
|
|
|
Private Function Picture_Read() As Picture
|
|
|
|
|
|
|
|
Return $hButton.Picture
|
|
|
|
|
|
|
|
End
|
|
|
|
|
|
|
|
Private Sub Picture_Write(Value As Picture)
|
|
|
|
|
|
|
|
If Not Value Then Value = Picture["img/select.png"]
|
|
|
|
$hButton.Picture = Value
|
|
|
|
|
|
|
|
End
|
|
|
|
|
|
|
|
Private Function Text_Read() As String
|
|
|
|
|
|
|
|
Return $hTextBox.Text
|
|
|
|
|
|
|
|
End
|
|
|
|
|
|
|
|
Private Sub Text_Write(Value As String)
|
|
|
|
|
|
|
|
$hTextBox.Text = Value
|
|
|
|
|
|
|
|
End
|
|
|
|
|
|
|
|
Public Sub Button_Click()
|
|
|
|
|
|
|
|
$hTextBox.SetFocus
|
|
|
|
Raise Click
|
|
|
|
|
|
|
|
End
|
|
|
|
|
|
|
|
Private Function ReadOnly_Read() As Boolean
|
|
|
|
|
|
|
|
Return $hTextBox.ReadOnly
|
|
|
|
|
|
|
|
End
|
|
|
|
|
|
|
|
Private Sub ReadOnly_Write(Value As Boolean)
|
|
|
|
|
|
|
|
$hTextBox.ReadOnly = Value
|
|
|
|
|
|
|
|
End
|
|
|
|
|
|
|
|
Public Sub Panel_Arrange()
|
|
|
|
|
|
|
|
$hBackground.Move(0, 0, $hPanel.W, $hPanel.H)
|
|
|
|
|
|
|
|
End
|
|
|
|
|
|
|
|
Public Sub Background_GotFocus()
|
|
|
|
|
|
|
|
$hTextBox.SetFocus
|
|
|
|
|
|
|
|
End
|
2009-07-12 23:49:13 +02:00
|
|
|
|
|
|
|
Public Sub Observer_GotFocus()
|
|
|
|
|
|
|
|
$hTextBox.SetFocus
|
|
|
|
|
|
|
|
End
|
|
|
|
|
2009-07-27 11:32:17 +02:00
|
|
|
Public Sub Clear()
|
|
|
|
|
|
|
|
$hTextBox.Clear
|
|
|
|
|
|
|
|
End
|
2009-09-05 22:54:36 +02:00
|
|
|
|
|
|
|
Private Function Length_Read() As Integer
|
|
|
|
|
|
|
|
Return $hTextBox.Length
|
|
|
|
|
|
|
|
End
|