Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/Overlay/Overlay Test with Text
Required plugins for this example: MBS Overlay Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Overlay/Overlay Test with Text
This example is the version from Sun, 10th Dec 2016.
Project "Overlay Test with Text.rbp"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control Listbox1 Inherits Listbox
ControlInstance Listbox1 Inherits Listbox
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action() updatebar End EventHandler
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() create false End EventHandler
End Control
Control CheckBox1 Inherits CheckBox
ControlInstance CheckBox1 Inherits CheckBox
EventHandler Sub Action() if o<>Nil then o.IgnoreMouseClicks=me.Value end if End EventHandler
End Control
Control iText Inherits TextArea
ControlInstance iText Inherits TextArea
EventHandler Sub TextChange() UpdateText End EventHandler
End Control
EventHandler Function KeyDown(Key As String) As Boolean Select case asc(key) case 28 'left move -10,0 Return true case 29 'right move 10,0 Return true case 30 'top move 0,-10 Return true case 31 'down move 0,10 Return true end Select End EventHandler
Sub Create(b as Boolean) p = new Picture(400,150,32) m = new Picture(400,150,32) p.Graphics.DrawPicture IconPict,0,0 m.Graphics.DrawPicture IconMask,0,0 o=new MyOverlay(500,100,400,150,b) o.Pict=p o.Mask=m updatebar o.Show timer1.Mode=2 UpdateText End Sub
Sub UpdateText() dim pg as Graphics = o.Pict.Graphics dim mg as Graphics = o.Mask.Graphics pg.ForeColor=&ccccccc pg.FillRoundRect 190,10,200,120,50,50 pg.ForeColor=&c000000 dim stp as StyledTextPrinter stp=iText.StyledTextPrinter(pg,180) stp.DrawBlock 200,20,100 mg.ForeColor=&c333333 mg.FillRoundRect 190,10,200,120,50,50 End Sub
Private Sub move(x as integer, y as integer) o.Move o.Left+x,o.top+y End Sub
Private Sub updatebar() dim pos,w,r,i as integer w=128 m.Graphics.ForeColor=&c000000 m.Graphics.FillOval 0,130,w,20 p.Graphics.ForeColor=&c000000 counter=counter+4 pos=counter mod 512 for i=0 to w-1 pos=pos+4 pos=pos mod 512 if pos>255 then r=511-pos else r=pos end if p.Graphics.ForeColor=rgb(r,0,0) p.Graphics.DrawLine i,130,i,150 next o.Update End Sub
Property Private counter As Integer
Property Private m As picture
Property Private o As MyOverlay
Property Private p As picture
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
ExternalFile IconMask
End ExternalFile
ExternalFile IconPict
End ExternalFile
Class MyOverlay Inherits OverlayMBS
EventHandler Function MouseDown(x as integer, y as integer) As boolean log "mousedown "+str(x)+" "+str(y) End EventHandler
EventHandler Function MouseMoved(x as integer, y as integer) As boolean log "mousemoved "+str(x)+" "+str(y) End EventHandler
EventHandler Function MouseUp(x as integer, y as integer) As boolean log "mouseup "+str(x)+" "+str(y) End EventHandler
EventHandler Sub WindowBoundsChanged() log "windowboundschanged" End EventHandler
EventHandler Sub WindowClosed() log "windowclosed" End EventHandler
EventHandler Sub WindowHidden() log "windowhidden" End EventHandler
EventHandler Sub WindowShown() log "windowShown" End EventHandler
Private Function Window1open() As Boolean dim i,c as integer c=WindowCount-1 for i=0 to c if window(i) isa window1 then Return true end if next End Function
Private Sub log(s as string) System.DebugLog s if Window1open then window1.Listbox1.InsertRow 0,s end if End Sub
End Class
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS Overlay Plugin.

MBS Xojo blog