Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCocoa/NSWorkSpace DropFile to see icon parts
Function:
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCocoa/NSWorkSpace DropFile to see icon parts
This example is the version from Mon, 3rd Dec 2017.
Project "NSWorkSpace DropFile to see icon parts.rbp"
FileTypes
Filetype special/any
End FileTypes
Class MainWindow Inherits Window
Control Icon128 Inherits myCanvas
ControlInstance Icon128 Inherits myCanvas
End Control
Control Mask128 Inherits myCanvas
ControlInstance Mask128 Inherits myCanvas
End Control
Control Icon256 Inherits myCanvas
ControlInstance Icon256 Inherits myCanvas
End Control
Control Mask256 Inherits myCanvas
ControlInstance Mask256 Inherits myCanvas
End Control
Control Icon512 Inherits myCanvas
ControlInstance Icon512 Inherits myCanvas
End Control
Control Mask512 Inherits myCanvas
ControlInstance Mask512 Inherits myCanvas
End Control
Control Icon1024 Inherits myCanvas
ControlInstance Icon1024 Inherits myCanvas
End Control
Control Mask1024 Inherits myCanvas
ControlInstance Mask1024 Inherits myCanvas
End Control
Control Image1024 Inherits myCanvas
ControlInstance Image1024 Inherits myCanvas
End Control
Control Image256 Inherits myCanvas
ControlInstance Image256 Inherits myCanvas
End Control
Control Image512 Inherits myCanvas
ControlInstance Image512 Inherits myCanvas
End Control
Control Image128 Inherits myCanvas
ControlInstance Image128 Inherits myCanvas
End Control
Control Icon64 Inherits myCanvas
ControlInstance Icon64 Inherits myCanvas
End Control
Control Mask64 Inherits myCanvas
ControlInstance Mask64 Inherits myCanvas
End Control
Control Image64 Inherits myCanvas
ControlInstance Image64 Inherits myCanvas
End Control
Control Icon32 Inherits myCanvas
ControlInstance Icon32 Inherits myCanvas
End Control
Control Mask32 Inherits myCanvas
ControlInstance Mask32 Inherits myCanvas
End Control
Control Image32 Inherits myCanvas
ControlInstance Image32 Inherits myCanvas
End Control
Control Icon16 Inherits myCanvas
ControlInstance Icon16 Inherits myCanvas
End Control
Control Mask16 Inherits myCanvas
ControlInstance Mask16 Inherits myCanvas
End Control
Control Image16 Inherits myCanvas
ControlInstance Image16 Inherits myCanvas
End Control
EventHandler Sub DropObject(obj As DragItem, action As Integer) dim p,m as Picture do if obj.folderItemavailable then dim n as NSImageMBS = NSWorkspaceMBS.iconForFile(obj.FolderItem) if n <> nil then dim ScaleFactor as integer = 1 #if RBVersion > 2015 then ScaleFactor = self.ScaleFactor #endif dim size as integer size = 16 * ScaleFactor if HasSize(n, 16) then Icon16.picture = GetIcon(n, size) Mask16.picture = GetMask(n, size) Image16.picture = GetImage(n, size) end if size = 32 * ScaleFactor if HasSize(n, 32) then Icon32.picture = GetIcon(n, size) Mask32.picture = GetMask(n, size) Image32.picture = GetImage(n, size) end if size = 64 * ScaleFactor if HasSize(n, 64) then Icon64.picture = GetIcon(n, size) Mask64.picture = GetMask(n, size) Image64.picture = GetImage(n, size) end if size = 128 * ScaleFactor if HasSize(n, 128) then Icon128.picture = GetIcon(n, size) Mask128.picture = GetMask(n, size) Image128.picture = GetImage(n, size) end if size = 256 * ScaleFactor if HasSize(n, 256) then Icon256.picture = GetIcon(n, size) Mask256.picture = GetMask(n, size) Image256.picture = GetImage(n, size) end if size = 512 * ScaleFactor if HasSize(n, 512) then Icon512.picture = GetIcon(n, size) Mask512.picture = GetMask(n, size) Image512.picture = GetImage(n, size) end if size = 1024 * ScaleFactor if HasSize(n, 1024) then Icon1024.picture = GetIcon(n, size) Mask1024.picture = GetMask(n, size) Image1024.picture = GetImage(n, size) end if else beep end if end if loop until not obj.nextItem End EventHandler
EventHandler Sub Open() acceptfileDrop "special/any" me.Maximize End EventHandler
Function GetIcon(n as NSImageMBS, Size as integer) As Picture n.setSize size, size Return n.CopyPictureWithMask End Function
Function GetImage(n as NSImageMBS, Size as integer) As Picture n.setSize size, size Return n.CopyPicture End Function
Function GetMask(n as NSImageMBS, Size as integer) As Picture n.setSize size, size Return n.CopyPictureWithMask.Mask End Function
Function HasSize(n as NSImageMBS, size as integer) As Boolean dim representations() as NSImageRepMBS = n.representations for each rep as NSImageRepMBS in representations if rep.pixelsWide = size then Return true end if next End Function
Property Protected i As iconMBS
Property Protected s As iconfamilyMBS
End Class
MenuBar Menu
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"
MenuItem UntitledMenu4 = ""
End MenuBar
Class App Inherits Application
End Class
Class myCanvas Inherits Canvas
ComputedProperty Picture As Picture
Sub Set() mPicture = value self.Invalidate End Set
Sub Get() return mPicture End Get
End ComputedProperty
EventHandler Sub Paint(g As Graphics, areas() As REALbasic.Rect) if self.Picture <> nil then g.DrawPicture self.Picture, 0, 0, g.Width, g.Height, 0, 0, self.Picture.Width, self.Picture.Height end if End EventHandler
Property Private mPicture As Picture
End Class
End Project

See also:

Feedback, Comments & Corrections

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





Links
MBS FileMaker Plugins