Platforms to show: All Mac Windows Linux Cross-Platform
NSGraphicsMBS class
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
class | Cocoa Drawing | MBS MacCocoa Plugin | 7.7 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
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.
- 5 properties
- property Handle as Integer
- property Owner as Variant
- property Valid as Boolean
- property imageInterpolation as Integer
- property shouldAntialias as boolean
- 54 methods
- method addClip(path as NSBezierPathMBS)
- method boundingRectWithSize(text as NSAttributedStringMBS, size as NSSizeMBS, options as Integer = 0) as NSRectMBS
- method boundingRectWithSize(text as string, size as NSSizeMBS, options as Integer = 0, DicAttributes as dictionary = nil) as NSRectMBS
- method clipRect(r as NSRectMBS)
- method concat(transform as NSAffineTransformMBS)
- method ConcatTransform(NSAffineTransform as Variant)
- method Constructor
- method Constructor(targetImage as NSBitmapImageRepMBS)
- method Constructor(targetImage as NSImageMBS)
- method Constructor(targetView as NSViewMBS)
- method Constructor(targetWindow as DesktopWindow)
- method Constructor(targetWindow as NSWindowMBS)
- method Constructor(targetWindow as window)
- method drawAtPoint(image as NSImageMBS, x as Double, y as Double, sx as Double, sy as Double, sw as Double, sh as Double, Operation as Integer, fraction as Double)
- method drawAtPoint(text as NSAttributedStringMBS, point as NSPointMBS)
- method drawAtPoint(text as string, point as NSPointMBS, DicAttributes as dictionary = nil)
- method drawInRect(image as NSImageMBS, x as Double, y as Double, w as Double, h as Double, sx as Double, sy as Double, sw as Double, sh as Double, Operation as Integer, fraction as Double)
- method drawInRect(text as NSAttributedStringMBS, rect as NSRectMBS)
- method drawInRect(text as string, rect as NSRectMBS, DicAttributes as dictionary = nil)
- method drawPicture(image as Picture, x as Double, y as Double, w as Double, h as Double, sx as Double, sy as Double, sw as Double, sh as Double, Operation as Integer, fraction as Double)
- method drawRect(x as Double, y as Double, w as Double, h as Double)
- method DrawWindowBackground(x as Double, y as Double, w as Double, h as Double)
- method drawWithRect(text as NSAttributedStringMBS, rect as NSRectMBS, options as Integer)
- method eraseRect(x as Double, y as Double, w as Double, h as Double)
- method fill(path as NSBezierPathMBS)
- method fillRect(r as NSRectMBS)
- method fillRect(x as Double, y as Double, w as Double, h as Double)
- method fillRect(x as Double, y as Double, w as Double, h as Double, operation as Integer)
- method flushGraphics
- method graphicsPort as Variant
- method highlightRect(x as Double, y as Double, w as Double, h as Double)
- method invalidate
- method isDrawingToScreen as boolean
- method isFlipped as boolean
- method restoreGraphicsState
- method saveGraphicsState
- method ScaleCoordinates(x as Double, y as Double)
- method set(transform as NSAffineTransformMBS)
- method setClip(path as NSBezierPathMBS)
- method setColor(c as NSColorMBS)
- method SetColorBW(white as Double, alpha as Double = 1.0)
- method SetColorCMYK(cyan as Double, magenta as Double, yellow as Double, black as Double, alpha as Double = 1.0)
- method SetColorHSV(hue as Double, saturation as Double, brightness as Double, alpha as Double = 1.0)
- method SetColorRGB(red as Double, green as Double, blue as Double, alpha as Double = 1.0)
- method setCurrentContext
- method setFillColor(c as NSColorMBS)
- method setStrokeColor(c as NSColorMBS)
- method SetTransform(NSAffineTransform as Variant)
- method sizeWithAttributes(text as string, DicAttributes as dictionary = nil) as NSSizeMBS
- method stroke(path as NSBezierPathMBS)
- method strokeLine(point1 as NSPointMBS, point2 as NSPointMBS)
- method strokeLine(x1 as Double, y1 as Double, x2 as Double, y2 as Double)
- method strokeRect(r as NSRectMBS)
- method TranslateCoordinates(x as Double, y as Double)
- 10 shared methods
- shared method graphicsContext as NSGraphicsMBS
- shared method graphicsContextWithCGContext(targetCGContext as Variant, initialFlippedState as boolean = false) as NSGraphicsMBS
- shared method graphicsContextWithCGContextHandle(targetCGContextRef as Integer, initialFlippedState as boolean = false) as NSGraphicsMBS
- shared method graphicsContextWithCGContextHandle(targetCGContextRef as Ptr, initialFlippedState as boolean = false) as NSGraphicsMBS
- shared method graphicsContextWithNSBitmapImageRep(targetImage as NSBitmapImageRepMBS) as NSGraphicsMBS
- shared method graphicsContextWithNSImage(targetImage as NSImageMBS) as NSGraphicsMBS
- shared method graphicsContextWithNSView(targetView as NSViewMBS) as NSGraphicsMBS
- shared method graphicsContextWithNSWindow(targetNSWindow as NSWindowMBS) as NSGraphicsMBS
- shared method graphicsContextWithWindow(targetWindow as DesktopWindow) as NSGraphicsMBS
- shared method graphicsContextWithWindow(targetWindow as window) as NSGraphicsMBS
- 25 constants
Constants
Constant | Value | Description |
---|---|---|
NSCompositeClear | 0 | Transparent. (R = 0) |
NSCompositeCopy | 1 | Source image. (R = S) |
NSCompositeDestinationAtop | 9 | Destination image wherever both images are opaque, source image wherever source image is opaque but destination image is transparent, and transparent elsewhere. (R = S*(1 - Da) + D*Sa) |
NSCompositeDestinationIn | 7 | Destination image wherever both images are opaque, and transparent elsewhere. (R = D*Sa) |
NSCompositeDestinationOut | 8 | Destination image wherever destination image is opaque but source image is transparent, and transparent elsewhere. (R = D*(1 - Sa)) |
NSCompositeDestinationOver | 6 | Destination image wherever destination image is opaque, and source image elsewhere. (R = S*(1 - Da) + D) |
NSCompositeHighlight | 12 | Source image wherever source image is opaque, and destination image elsewhere. (Deprecated. Mapped to NSCompositeSourceOver.) |
NSCompositePlusDarker | 11 | Sum of source and destination images, with color values approaching 0 as a limit. (R = MAX(0, (1 - D) + (1 - S))) |
NSCompositePlusLighter | 13 | Sum of source and destination images, with color values approaching 1 as a limit. (R = MIN(1, S + D)) |
NSCompositeSourceAtop | 5 | Source image wherever both images are opaque, destination image wherever destination image is opaque but source image is transparent, and transparent elsewhere. (R = S*Da + D*(1 - Sa)) |
NSCompositeSourceIn | 3 | Source image wherever both images are opaque, and transparent elsewhere. (R = S*Da) |
NSCompositeSourceOut | 4 | Source image wherever source image is opaque but destination image is transparent, and transparent elsewhere. (R = S*(1 - Da)) |
NSCompositeSourceOver | 2 | Source image wherever source image is opaque, and destination image elsewhere. (R = S + D*(1 - Sa)) |
NSCompositeXOR | 10 |
Exclusive OR of source and destination images. (R = S*(1 - Da) + D*(1 - Sa))
Works only with black and white images and is not recommended for color contexts. |
NSImageInterpolationDefault | 0 |
One of the interpolation contants.
Use the context's default interpolation. |
NSImageInterpolationHigh | 3 |
One of the interpolation contants.
Slower, higher-quality interpolation. |
NSImageInterpolationLow | 2 |
One of the interpolation contants.
Fast, low-quality interpolation. |
NSImageInterpolationMedium | 4 |
One of the interpolation contants.
Medium quality, slower than NSImageInterpolationLow. Available in Mac OS X v10.6 and later. |
NSImageInterpolationNone | 1 |
One of the interpolation contants.
No interpolation. |
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. more |
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. Example |
This class has no sub classes.
Some methods using this class:
- NSPrintOperationMBS.context as NSGraphicsMBS
- PDFPageMBS.Draw(g as NSGraphicsMBS, box as Integer = 0)
Some events using this class:
- CustomNSScrollerMBS.drawArrow(g as NSGraphicsMBS, Arrow as Integer, highlight as boolean)
- CustomNSScrollerMBS.drawParts(g as NSGraphicsMBS)
- CustomNSViewMBS.drawFocusRingMask(g as NSGraphicsMBS) as boolean
- CustomPDFViewMBS.AfterDrawPage(graphics as NSGraphicsMBS, page as PDFPageMBS)
- CustomPDFViewMBS.AfterDrawPagePost(graphics as NSGraphicsMBS, page as PDFPageMBS)
- CustomPDFViewMBS.BeforeDrawPage(graphics as NSGraphicsMBS, page as PDFPageMBS) as boolean
- PDFAnnotationChoiceWidgetMBS.drawWithBox(box as Integer, g as NSGraphicsMBS) as boolean
- PDFAnnotationCircleMBS.drawWithBox(box as Integer, g as NSGraphicsMBS) as boolean
- PDFAnnotationPopupMBS.drawWithBox(box as Integer, g as NSGraphicsMBS) as boolean
- PDFViewControlMBS.BeforeDrawRect(graphics as NSGraphicsMBS, x as Double, y as Double, w as Double, h as Double) as boolean
Some examples using this class:
- /MacCocoa/Font PopupMenu in Cocoa
- /MacCocoa/NSColor and Colorspaces
- /MacCocoa/NSStatusItem/StatusItem with NSView
- /MacCocoa/NSWindow transparent
- /MacCocoa/RTF Printing
- /MacControls/Custom NSView Drop
- /MacControls/Listbox and TableView Demos/ListboxTV drop-in/Flat Only/ListBoxTV Simple Demo with DataSource
- /MacControls/Listbox and TableView Demos/ListboxTV drop-in/Flat Only/ListBoxTV TableView
- /MacControls/Listbox and TableView Demos/ListboxTV drop-in/Hierarchical & Flat/ListBoxTV OutlineView
- /PDFKit/Create Page with custom stamp annotation
Blog Entries
- MBS Xojo Plugins, version 19.6pr3
- MBS Xojo / Real Studio Plugins, version 15.4pr4
- Apply fonts to font PopupMenu
- MBS Xojo / Real Studio Plugins, version 14.2pr12
- MBS Real Studio Plugins, version 12.5pr4
- MBS Real Studio Plugins, version 12.4pr7
- MBS Real Studio Plugins, version 12.3pr7
- MBS Real Studio Plugins, version 12.3pr6
- MonkeyBread Software Releases the MBS Real Studio plug-ins in version 12.2
- MBS Plugins 10.3 Release Notes
Xojo Developer Magazine
Release notes
- Version 20.0
- Added CGContextMBS.contextWithCGContext and NSGraphicsMBS.graphicsContextWithCGContextHandle taking ptr for better coding in Xojo 2019r2 and newer.
The items on this page are in the following plugins: MBS MacCocoa Plugin.
NSFontPanelMBS - NSGroupTouchBarItemMBS