Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/Overlay/Overlay and window level
Function:
Required plugins for this example: MBS MacBase Plugin, MBS Main Plugin, MBS Overlay Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Overlay/Overlay and window level
This example is the version from Sun, 10th Dec 2016.
Project "Overlay and window level.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 PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() create true 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 RadioButton1 Inherits RadioButton
ControlInstance RadioButton1 Inherits RadioButton
EventHandler Sub Action() if TargetCocoa then dim n as NSWindowMBS = o.NSWindow n.Level = n.NSFloatingWindowLevel elseif TargetWin32 then o.WinIsTopMost = true else MsgBox "not supported." end if End EventHandler
End Control
Control RadioButton2 Inherits RadioButton
ControlInstance RadioButton2 Inherits RadioButton
EventHandler Sub Action() if TargetCocoa then dim n as NSWindowMBS = o.NSWindow n.Level = n.NSNormalWindowLevel elseif TargetWin32 then o.WinIsTopMost = false else MsgBox "not supported." end if 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(128,150,32) m = new Picture(128,150,32) p.Graphics.DrawPicture IconPict,0,0 m.Graphics.DrawPicture IconMask,0,0 o=new MyOverlay(500,100,128,150,b) o.Pict=p o.Mask=m updatebar o.Show timer1.Mode=2 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=m.Width 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.




Links
MBS Xojo Plugins