Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

IconMBS class

Type Topic Plugin Version macOS Windows Linux Console & Web iOS
class Icon Service MBS Picture Plugin 2.6 Yes No No Yes, macOS only No
Function: A class for an icon on Mac OS.
Example:
// A function which will try to return an icon for the given type/creator including the Mask.

Function GetIconPicture(macCreator as string, macType as string, size as Integer) As picture
dim icn as IconMBS
dim icf as IconFamilyMBS
dim pic, tmp as Picture

icn = new IconMBS(macType, macCreator)

if icn<>nil and icn.valid then
icf = icn.IconFamily
end if

if icf<>nil and icf.Valid then
pic = NewPicture(size, size, 32)

// Try Thumbnail
if size>32 then
tmp = icf.Thumbnail32BitData
if tmp<>nil then
pic.Graphics.DrawPicture tmp, 0, 0, size, size, 0, 0, tmp.width,tmp.Height

tmp = icf.Thumbnail8BitMask
if tmp<>nil then
pic.Mask.Graphics.DrawPicture tmp, 0, 0, size, size, 0, 0, tmp.width, tmp.Height
end if
Return pic
end if
end if

// Try Large Icon in 32 bit
tmp = icf.Large32BitData
if tmp<>nil then
pic.Graphics.DrawPicture tmp, 0, 0, size, size, 0, 0, tmp.width,tmp.Height

tmp = icf.Large8BitMask
if tmp<>nil then
pic.Mask.Graphics.DrawPicture tmp, 0, 0, size, size, 0, 0, tmp.width, tmp.Height
end if
Return pic
end if

// Try Large Icon in 8 bit
tmp = icf.Large8BitData
if tmp<>nil then
pic.Graphics.DrawPicture tmp, 0, 0, size, size, 0, 0, tmp.width,tmp.Height

tmp = icf.Large1BitMask
if tmp<>nil then
pic.Mask.Graphics.DrawPicture tmp, 0, 0, size, size, 0, 0, tmp.width, tmp.Height
end if
return pic
end if

// You may add more like e.g. Small or Huge Icons
end if


Exception // on any error, just return nil


// Call like:
// Backdrop=GetIconPicture("R*ch","TEXT",128)
End Function

Feedback, Comments & Corrections

  • 4 properties
  • 14 methods
    • method Constructor(f as folderitem, NoBadge as boolean = false)
    • method Constructor(type as string, creator as string)
    • method Constructor(type as string, creator as string, extension as string, mime as string)
    • method DrawIcon(g as graphics,x as Integer,y as Integer,width as Integer,height as Integer)
    • method DrawIcon(g as graphics,x as Integer,y as Integer,width as Integer,height as Integer,align as Integer)
    • method DrawIcon(g as graphics,x as Integer,y as Integer,width as Integer,height as Integer,align as Integer,transform as Integer)
    • method DrawIconCGContext(CGContextHandle as Integer,x as Integer,y as Integer,width as Integer,height as Integer, align as Integer, transform as Integer, flags as Integer, labelColor as color)
    • method GetBackground as IconMBS
    • method GetForeground as IconMBS
    • method IconFamily as IconFamilyMBS
    • method IsIconRefMaskEmpty as boolean
    • method PointInIcon(pointx as Integer,pointy as Integer,x as Integer,y as Integer,width as Integer,height as Integer,align as Integer) as boolean
    • method RectInIcon(rectx as Integer,recty as Integer,rectwidth as Integer,rectheight as Integer,x as Integer,y as Integer,width as Integer,height as Integer,align as Integer) as boolean
    • method RetainCount as Integer

This class has no sub classes.

Some useful global functions for this class:

Some methods using this class:

Some examples which use this class:


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


IconFamilyMBS   -   ICScannerBandDataMBS




Links
MBS Xojo Chart Plugins