Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCG/CoreGraphics Overlay Window/Overlay Window/Magician
Function:
Required plugins for this example: MBS MacCG Plugin, MBS Picture Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCG/CoreGraphics Overlay Window/Overlay Window/Magician
This example is the version from Sun, 17th Mar 2012.
Project "Magician.rbp"
Class Window1 Inherits Window
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() start End EventHandler
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() Window2.Show End EventHandler
End Control
Control PushButton3 Inherits PushButton
ControlInstance PushButton3 Inherits PushButton
EventHandler Sub Action() Window3.Show End EventHandler
End Control
Sub start() Dim o As New FadingInterfaceFx If o.create( Self.left, Self.top, 200, 50)=0 then o.MakeScreenshot // Make something appear or disapear here // it must be placed behind the created overlay window StaticText2.Visible=Not StaticText2.Visible o.show // Show the overlay window o.redraw // Draw screenshot and start fading effect end if End Sub
End Class
Class Window2 Inherits Window
Control Listbox1 Inherits Listbox
ControlInstance Listbox1 Inherits Listbox
EventHandler Function CellBackgroundPaint(g As Graphics, row As Integer, column As Integer) As Boolean if Me.Selected(row) and AboutToDelete then g.ForeColor=&cB6000A elseif Me.Selected(row) then g.ForeColor=&c2E75D8 else g.ForeColor=&cFFFFFF end if g.FillRect 0,0,g.Width,g.Height if Me.Selected(row) and Me.SelCount>0 then g.ForeColor=&cFFFFFF g.DrawLine 0,0,g.Width,0 end if return true End EventHandler
EventHandler Sub Change() if Me.SelCount>0 then PushButton1.Enabled=true else PushButton1.Enabled=false end if End EventHandler
EventHandler Sub Open() Me.AddRow "A first test row" Me.AddRow "A second test row" Me.AddRow "A third test row" Me.AddRow "A last one" End EventHandler
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() HighlightSelected End EventHandler
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action() RemoveSelected End EventHandler
End Control
Protected Sub HighlightSelected() // AboutToDelete is used to make the listbox change the // color of the select rows right before to delete them AboutToDelete=true for i as integer=0 to Listbox1.ListCount-1 if Listbox1.Selected(i) then Listbox1.InvalidateCell(i,0) next Timer1.Mode=1 End Sub
Protected Sub RemoveSelected() Dim i As Integer Dim o As New FadingInterfaceFx If o.create( Self.left+Listbox1.Left, Self.top+Listbox1.top, Listbox1.width,Listbox1.Height)=0 then o.MakeScreenshot // We delete the selected rows for i=Listbox1.ListCount-1 DownTo 0 if Listbox1.Selected(i) then Listbox1.RemoveRow(i) next o.show // Show the overlay window o.redraw // Draw screenshot and start fading effect end if AboutToDelete=false End Sub
Property Protected AboutToDelete As Boolean
End Class
Class Window3 Inherits Window
Control PPanel Inherits PagePanel
ControlInstance PPanel Inherits PagePanel
End Control
Control EditField1 Inherits TextField
ControlInstance EditField1(0) Inherits TextField
ControlInstance EditField1(1) Inherits TextField
ControlInstance EditField1(2) Inherits TextField
ControlInstance EditField1(3) Inherits TextField
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1(0) Inherits Label
ControlInstance StaticText1(1) Inherits Label
ControlInstance StaticText1(2) Inherits Label
ControlInstance StaticText1(3) Inherits Label
ControlInstance StaticText1(4) Inherits Label
End Control
Control RadioButton1 Inherits RadioButton
ControlInstance RadioButton1 Inherits RadioButton
End Control
Control RadioButton2 Inherits RadioButton
ControlInstance RadioButton2 Inherits RadioButton
End Control
Control Listbox1 Inherits Listbox
ControlInstance Listbox1 Inherits Listbox
EventHandler Sub Open() Me.AddRow "A first test row" Me.AddRow "A second test row" Me.AddRow "A third test row" Me.AddRow "A last one" End EventHandler
End Control
Control ToolbarWin31 Inherits ToolbarWin3
ControlInstance ToolbarWin31 Inherits ToolbarWin3
EventHandler Sub Action(item As ToolItem) Select case item.Name case "ToolItem1" ChangePanelPage(0) case "ToolItem2" ChangePanelPage(1) end select End EventHandler
End Control
Protected Sub ChangePanelPage(PageValue As integer) if PageValue<>PPanel.Value then Dim i As Integer Dim o As New FadingInterfaceFx If o.create( Self.left+PPanel.Left, Self.top+PPanel.top, PPanel.width,PPanel.Height)=0 then o.MakeScreenshot // We change the page PPanel.Value=PageValue o.show // Show the overlay window o.redraw // Draw screenshot and start fading effect end if end if End Sub
End Class
Class ToolbarWin3 Inherits Toolbar
ToolbarItem ToolItem1
ToolbarItem ToolItem2
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
EventHandler Sub Open() if TargetMachO then // ok else MsgBox "This example is only for Mac OS X." end if End EventHandler
End Class
Class FadingInterfaceFx Inherits OverlayWindowMBS
Sub MakeScreenshot() if TestMode then // Set TestMode=True for testing with a color rectangle instead of the screenshot screenshot=New Picture( width,height,32 ) screenshot.Graphics.ForeColor=RGB( 255,0,0 ) screenshot.Graphics.FillRect 0,0,width,height else // Make the screenshot of the area defined // by the overlay window's coordidates screenshot=ScreenshotRectMBS( Left,top,width,height ) end if End Sub
Protected Sub RunFx() // Create and start the timer ti=New FadingInterfaceFxTimer ti.Mode=0 ti.win=Self ti.StartFx(speed) End Sub
Sub redraw() // Display the screenshot picture if screenshot<>Nil then dim c as CGContextMBS dim r as CGRectMBS dim ci As CGImageMBS ci=CGCreateImageMBS( screenshot ) c=Context r=CGMakeRectMBS(0,0,Width,Height) c.DrawPicture ci, r c.Flush // Create and start the timer RunFx end if End Sub
Property TestMode As Boolean
Property Protected screenshot As Picture
Property speed As Integer = 5
Property Protected ti As FadingInterfaceFxTimer
End Class
Class FadingInterfaceFxTimer Inherits Timer
EventHandler Sub Action() if count>0.0 then win.Transparency=count win.Flush count=count-stp else Mode=0 Win.Close end if End EventHandler
Sub StartFx(speed As integer=5) // Speed goes from 1 to 10 if speed<1 then speed=1 elseif speed>10 then speed=10 end if Period=100/speed Count=1.0 stp=0.05 Mode=2 End Sub
Property Win As FadingInterfaceFx
Property Protected count As Single
Property Protected stp As Single
End Class
End Project

See also:

Feedback, Comments & Corrections

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





Links
MBS Xojo Chart Plugins