Xojo Developer Conference
Join us from 25th to 27th April 2018 in Denver.

Platforms to show: All Mac Windows Linux Cross-Platform

NSGraphicsMBS class

class, Cocoa Drawing, MBS Cocoa Plugin (NSGraphics), class NSGraphicsMBS,
Plugin version: 7.7, Mac: Yes, Win: No, Linux: No, Console & Web: Yes, Feedback.

Function: The Cocoa class for drawing.
// make new image
dim myImage as new NSImageMBS(500,500)
dim myGraphics as new NSGraphicsMBS(myImage)

// make logo image
dim myPicture as Picture = LogoMBS(500)
dim anotherImage as new NSImageMBS(myPicture)

// draw logo image to new image
myGraphics.drawInRect(anotherImage, 0, 0, myImage.width, myImage.height, 0, 0, anotherImage.width, anotherImage.height, myGraphics.NSCompositeSourceOver, 1.0)
myGraphics = nil // flush drawing

// save to file
dim f as FolderItem = SpecialFolder.Desktop.Child("test.jpg")
dim b as BinaryStream = BinaryStream.Create(f, True)
if b<>nil then
b.Write myImage.JPEGRepresentation
end if
The plugin often provides in events such objects for drawing. In that case please only use the object in the event and don't store it for later use. It is only valid with in a draw event.

Internally this is a NSGraphicsContext object.

If you create objects on your own, make sure you only use the methods while the object is valid.

Drawing Option Constants

Constant Value Description
NSStringDrawingDisableScreenFontSubstitution 4 Disable screen font substitution (equivalent to NSLayoutManager.setUsesScreenFonts(false)).
NSStringDrawingOneShot 16 Suppresses caching layout information.
NSStringDrawingTruncatesLastVisibleLine 32 Truncates and adds the ellipsis character to the last visible line if the text doesn't fit into the bounds specified.
This option is ignored if NSStringDrawingUsesLineFragmentOrigin is not also set. In addition, the line break mode must be either NSLineBreakByWordWrapping or NSLineBreakByCharWrapping for this option to take effect. The line break mode can be specified in a paragraph style passed in the attributes dictionary argument of the drawing methods.
Available in Mac OS X v10.5 and later.
NSStringDrawingUsesDeviceMetrics 8 Uses image glyph bounds instead of typographic bounds.
NSStringDrawingUsesFontLeading 2 Uses the font leading for calculating line heights.
NSStringDrawingUsesLineFragmentOrigin 1 The specified origin is the line fragment origin, not the baseline origin.

This class has no sub classes.

Some methods using this class:

Some events for this class:

Some examples which use this class:

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

NSFontPanelMBS   -   NSGroupTouchBarItemMBS

MBS FileMaker Plugins