Platforms to show: All Mac Windows Linux Cross-Platform

/Swift/ImagePlayground


Required plugins for this example: MBS Swift Plugin

Last modified Tue, 16th Dec 2024.

You find this example project in your MBS Xojo Plugin download as a Xojo project file within the examples folder: /Swift/ImagePlayground

Download this example: ImagePlayground.zip

Project "ImagePlayground.xojo_binary_project"
Class App Inherits DesktopApplication
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class MainWindow Inherits DesktopWindow
Control AvailableLabel Inherits DesktopLabel
ControlInstance AvailableLabel Inherits DesktopLabel
End Control
Control ShowButton Inherits DesktopButton
ControlInstance ShowButton Inherits DesktopButton
EventHandler Sub Pressed() controller = New MyImagePlayground controller.Present Exception u As UnsupportedOperationException // not available End EventHandler
End Control
Control Output Inherits DesktopCanvas
ControlInstance Output Inherits DesktopCanvas
EventHandler Sub Paint(g As Graphics, areas() As Rect) If pic <> Nil Then Var faktor As Double = Min( g.Height / Pic.Height, g.Width / Pic.Width) // Calculate new size Var w As Integer = Pic.Width * faktor Var h As Integer = Pic.Height * faktor // create new picture Var NewPic As New Picture(w,h,32) // draw picture in the new size g.DrawPicture Pic, 0, 0, w, h, 0, 0, Pic.Width, Pic.Height End If End EventHandler
End Control
EventHandler Sub Opening() Var a As Integer = ImagePlaygroundMBS.Available Select Case a Case ImagePlaygroundMBS.AvailabilityAvailable AvailableLabel.Text = "Available" Case ImagePlaygroundMBS.AvailabilityNotAvailable AvailableLabel.Text = "Not Available" Case ImagePlaygroundMBS.AvailabilityOldOS AvailableLabel.Text = "OldOS" Case ImagePlaygroundMBS.AvailabilityUnknown AvailableLabel.Text = "Unknown" Case ImagePlaygroundMBS.AvailabilityUnsupportedPlatform AvailableLabel.Text = "Unsupported Platform" End Select End EventHandler
Sub SetPicture(file as FolderItem) pic = Picture.Open(file) Output.Refresh End Sub
Property controller As MyImagePlayground
Property pic As Picture
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
MenuItem HelpMenu = "&Help"
End MenuBar
Sign
End Sign
Class MyImagePlayground Inherits ImagePlaygroundMBS
EventHandler Sub Cancelled() End EventHandler
EventHandler Sub CreatedImage(file as FolderItem) MainWindow.SetPicture file End EventHandler
EventHandler Sub Hidden() End EventHandler
End Class
End Project

Download this example: ImagePlayground.zip

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


The biggest plugin in space...