Platforms to show: All Mac Windows Linux Cross-Platform

Back to IconMBS class.

IconMBS.Constructor(f as folderitem, NoBadge as boolean = false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Icon Service MBS Picture Plugin 2.6 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Loads the icon for this file/folder/volume.
Example
// in a paint event:

dim i as new IconMBS(SpecialFolder.Desktop)

i.DrawIcon(g, 0, 0, 128, 128)

The example "GetIcon.rb" shows how to get the file icons.
A custom icon is preferred (ID -16455).

NoBadge can be set to true to have no badges on the icon.

See also:

IconMBS.Constructor(type as string, creator as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Icon Service MBS Picture Plugin 2.6 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Loads the icon for this type and creator code combination.
Example
// in a paint event:

dim i as new IconMBS("FNDR", "MACS")

i.DrawIcon(g, 0, 0, 128, 128)

The example "GetIcon.rb" shows how to get the predefined icons from the system.

See also:

IconMBS.Constructor(type as string, creator as string, extension as string, mime as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Icon Service MBS Picture Plugin 9.2 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Loads the icon base on the given information.
Example
Sub Paint(g As Graphics)
// in a window paint event:

dim i as IconMBS
dim type, creator, extension, mime as string

type=""
creator=""
extension="jpg"
mime=""

i=new iconmbs(type, creator, extension, mime)
// draws jpeg icon
i.DrawIcon(g,0,0,128,128)

type=""
creator=""
extension=""
mime="video/quicktime"

i=new iconmbs(type, creator, extension, mime)
// draws quicktime movie icon
i.DrawIcon(g,128,0,128,128)

type="TEXT"
creator="MSWD"
extension=""
mime=""

i=new iconmbs(type, creator, extension, mime)
// draws microsoft word text file icon
i.DrawIcon(g,0,128,128,128)

type=""
creator="GKON"
extension="jpg"
mime=""

i=new iconmbs(type, creator, extension, mime)
// draws graphic converter jpeg file icon
i.DrawIcon(g,128,128,128,128)

End Sub

All parameters can be empty strings if you don't know this information.
Requires Mac OS X 10.3 to work properly.

See also:

IconMBS.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)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Icon Service MBS Picture Plugin 8.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Draws the icon in a CoreGraphics Context.
Example
Function GetIconImage(i as iconmbs, w as Integer, h as Integer) As picture
dim c as new CGPictureContextMBS(w,h)

const DrawNormal=0
const DrawNoImage=2
const DrawNoMask=4
const DrawSelected=&h8000

i.DrawIconCGContext(c.Handle, 0,0,w,h,0,0,DrawNoMask,&c000000)

c.Flush

Return c.CopyPicture
End Function

You must make sure that the CGContext handle you pass in is valid. You can use CGContextMBS class for this and use GetCurrentCGContextMBS or Window.CGContextMBS to get a context. Please note that coordinates have the origin typically on the lower left.

Flags:
DrawNormal0
DrawNoImage2
DrawNoMask4
DrawSelected32768

Align constants:
None 0
VerticalCenter 1
Top 2
Bottom 3
HorizontalCenter 4
AbsoluteCenter 5
CenterTop 6
CenterBottom 7
Left 8
CenterLeft 9
TopLeft 10
BottomLeft 11
Right 12
CenterRight 13
TopRight 14
BottomRight 15

Transform constants:
None 0
Disabled 1
Offline 2
Open 3
Label1 &h0100
Label2 &h0200
Label3 &h0300
Label4 &h0400
Label5 &h0500
Label6 &h0600
Label7 &h0700
Selected &h4000
SelectedDisabled &h4001
SelectedOffline &h4002
SelectedOpen &h4003

Some examples using this method:

IconMBS.GetBackground as IconMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Icon Service MBS Picture Plugin 2.7 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
If the icon is a composited one, this function returns the icon used for the background.

Returns nil on any error.
Lasterror ist set.

IconMBS.GetForeground as IconMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Icon Service MBS Picture Plugin 2.7 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
If the icon is a composited one, this function returns the icon used for the foreground.

Returns nil on any error.
Lasterror ist set.

IconMBS.IsIconRefMaskEmpty as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Icon Service MBS Picture Plugin 2.6 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns true if the mask of the icon is empty.
Example
dim i as new IconMBS("FNDR", "MACS")

MsgBox str(i.IsIconRefMaskEmpty)

Lasterror is set.

IconMBS.PointInIcon(pointx as Integer,pointy as Integer,x as Integer,y as Integer,width as Integer,height as Integer,align as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Icon Service MBS Picture Plugin 2.6 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Tests whether a point is inside the icon's picture.

The coordinates for pointx/pointy and x/y must be in the same system.

Align constants:
None 0
VerticalCenter 1
Top 2
Bottom 3
HorizontalCenter 4
AbsoluteCenter 5
CenterTop 6
CenterBottom 7
Left 8
CenterLeft 9
TopLeft 10
BottomLeft 11
Right 12
CenterRight 13
TopRight 14
BottomRight 15

IconMBS.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

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Icon Service MBS Picture Plugin 2.6 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Tests whether a rectangle is inside the icon's picture.

The coordinates for both rectangles must be in the same coordinate system.

Align constants:
None 0
VerticalCenter 1
Top 2
Bottom 3
HorizontalCenter 4
AbsoluteCenter 5
CenterTop 6
CenterBottom 7
Left 8
CenterLeft 9
TopLeft 10
BottomLeft 11
Right 12
CenterRight 13
TopRight 14
BottomRight 15

This call may fail in some RB versions because of the count of parameters.

IconMBS.RetainCount as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Icon Service MBS Picture Plugin 2.7 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
How many references to this icon are hold on this Mac.
Example
dim i as new IconMBS("FNDR", "MACS") // Finder Icon

MsgBox str(i.RetainCount)

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


The biggest plugin in space...