Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim sv2d As ScrollView2D
Dim lbl1, lbl2 As Label
Private btn1 As Button
Private btn2 As Button
Private canv1 As Canvas
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("scrollMain")
sv2d.Initialize(6000dip, 50%y, "sv2d")
canv1.Initialize(sv2d.panel)
Activity.AddView(sv2d, 0, 0, 100%x, 50%y)
canv1.DrawColor(Colors.Yellow)
lbl2.TextSize = 30
lbl2.TextColor = Colors.Black
lbl2.Text = sv2d.HorizontalScrollPosition
lbl1.TextSize = 30
lbl1.TextColor = Colors.Red
lbl1.Text = sv2d.Width
makeLine
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub sv2d_ScrollChanged(PosX As Int, PosY As Int)
'Log(PosX & " / " & PosY)
lbl2.Text = PosX
End Sub
Sub btn2_Click
sv2d.panel.Width = sv2d.panel.Width - 160
lbl1.Text = sv2d.panel.Width
makeLine
End Sub
Sub btn1_Click
sv2d.panel.Width = sv2d.panel.Width + 160
lbl1.Text = sv2d.panel.Width
makeLine
End Sub
Sub makeLine
canv1.RemoveClip
canv1.Initialize(sv2d.panel)
canv1.DrawColor(Colors.Yellow)
Dim ste As Int
ste = Round(sv2d.panel.Width/40)
If sv2d.panel.Width < 9000 Then
ste = (sv2d.panel.Width/10)
End If
canv1.DrawLine(10dip, 150dip, (sv2d.panel.Width - 10), 150dip, Colors.Red, 2dip)
canv1.DrawLine((sv2d.panel.Width-20), 150dip, (sv2d.panel.Width-20) , 50dip, Colors.Red, 2dip)
Log(" sv2d.panel.Width - 10dip = : " & (sv2d.panel.Width - 10))
Log(" sv2d.panel.Width = : " & (sv2d.panel.Width ))
For i = 1 To sv2d.panel.Width
If i Mod (ste) = 0 Then
'Log (" i Mod = " & i & " ste : " & ste )
canv1.DrawLine(i, 150dip, i, 50dip, Colors.Red, 1dip)
End If
Next
Activity.Invalidate
End Sub