Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example: MBS MacCF Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCF/Timer Comparison
This example is the version from Mon, 5th May 2019.
Project "Timer Comparison.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action()
Canvas1.update
End EventHandler
End Control
Control Slider1 Inherits Slider
ControlInstance Slider1 Inherits Slider
EventHandler Sub ValueChanged()
m.Period=me.Value
timer1.Period=me.Value
End EventHandler
End Control
Control Canvas1 Inherits MyCanvas
ControlInstance Canvas1 Inherits MyCanvas
End Control
Control Canvas2 Inherits MyCanvas
ControlInstance Canvas2 Inherits MyCanvas
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
Control StaticText3 Inherits Label
ControlInstance StaticText3 Inherits Label
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
End Control
EventHandler Sub Open()
m=new MyTimer
m.Period=100
m.Mode=2
End EventHandler
Private Sub draw()
End Sub
Property m As mytimer
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class MyCanvas Inherits Canvas
EventHandler Sub Open()
p = new Picture(me.Width,me.Height,32)
End EventHandler
EventHandler Sub Paint(g As Graphics, areas() As REALbasic.Rect)
g.DrawPicture p,0,0
End EventHandler
Sub update()
dim pos,w,r,g,b,i as integer
w=p.Width
p.Graphics.ForeColor=&c000000
counter=counter+4
posr=counter mod 512
posg=counter mod 512
posb=counter mod 512
for i=0 to w-1
posr=posr+4
posr=posr mod 512
if posr>255 then
r=511-posr
else
r=posr
end if
posg=posg+8
posg=posg mod 512
if posg>255 then
g=511-posg
else
g=posg
end if
posb=posb+16
posb=posb mod 512
if posb>255 then
b=511-posb
else
b=posb
end if
p.Graphics.ForeColor=rgb(r,g,b)
p.Graphics.DrawLine i,0,i,p.Height
next
me.Invalidate
End Sub
Property counter As Integer
Property Private p As picture
Property posb As Integer
Property posg As Integer
Property posr As Integer
End Class
Class MyTimer Inherits CarbonEventsTimerMBS
EventHandler Sub Action()
window1.Canvas2.update
End EventHandler
End Class
End Project
The items on this page are in the following plugins: MBS MacCF Plugin.