The idea is to have a single component to step though an index of items, e.g. a collection of photos.
So far the project works but I'd like to fix the overall dimensions of the component, at the moment, when selected from the 'Form' controls the control is completely the wrong shape.
' Gambas class file
Export
Inherits UserControl
Public Const _DefaultEvent As String = "Click"
Property ItemCount As Integer
Event Click
Private sPicture As String[] = ["icon:/22/start", "icon:/22/right", "icon:/22/left", "icon:/22/end"]
Private hBox As DrawingArea
Private hBtn[4] As Button
Private hLabel As Label
Private iBtnLeft As Integer[] = [5, 35, 145, 180]
Public iIndex As Integer
Private iItemCount As Integer
Public Sub _new()
Dim i, iBtnSize As Integer
iBtnSize = 30
hBox = New DrawingArea(Me)
hBox.Border = Border.Plain
With hLabel = New Label(HBox)
.X = iBtnLeft[1] + iBtnSize + 5
.Y = 5
.H = iBtnSize
.W = 70
.Alignment = Align.Center
.Text = "1 of " & Me.ItemCount
End With
For i = 0 To 3
hBtn = New Button(HBox) As "btn_Event"
With hBtn
.X = iBtnLeft
.Y = 5
.H = iBtnSize
.W = iBtnSize
.tag = i
.Picture = Picture[sPicture]
End With
Next
End
Public Sub btn_Event_Click()
Select Case Last.Tag
Case 0
iIndex = 0
Case 1
If iIndex < iItemCount - 1 Then Inc iIndex
Case 2
If iIndex >= 1 Then Dec iIndex
Case 3
iIndex = iItemCount - 1
End Select
ShowItems
hBtn[Last.Tag].SetFocus
Raise Click
End
Private Sub ShowItems()
hLabel.Text = (iIndex + 1) & " of " & iItemCount
End
Private Function ItemCount_Read() As Integer
End
Private Function ItemCount_Write(i As Integer)
iItemCount = i
hLabel.Text = (iIndex + 1) & " of " & iItemCount
End
Any help would be appreciated