Example: /MacCocoa/Window Colorspace

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCocoa/Window Colorspace


Required plugins for this example: MBS MacBase Plugin, MBS Main Plugin, MBS MacCocoa Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCocoa/Window Colorspace

This example is the version from Tue, 22th Dec 2014.

Project "Window Colorspace.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open() dim w1 as new window1(NSColorSpaceMBS.adobeRGB1998ColorSpace) dim w2 as new window1(NSColorSpaceMBS.genericRGBColorSpace) dim w3 as new window1(NSColorSpaceMBS.deviceRGBColorSpace) dim w4 as new window1(NSColorSpaceMBS.sRGBColorSpace) dim s as NSScreenMBS = NSScreenMBS.mainScreen dim c as NSColorSpaceMBS = s.colorSpace dim w5 as new window1(c) End EventHandler
End Class
Class Window1 Inherits Window
EventHandler Sub Paint(g As Graphics, areas() As REALbasic.Rect) dim x as integer = ceil(g.Width/5) dim y as integer = ceil(g.Height/2) // top with Xojo drawing in generic RGB g.ForeColor = &c000000 g.FillRect 0, 0, x, y g.ForeColor = &cFFFFFF g.FillRect x , 0, x, y g.ForeColor = &cFF0000 g.FillRect x*2, 0, x, y g.ForeColor = &c00FF00 g.FillRect x*3, 0, x, y g.ForeColor = &c0000FF g.FillRect x*4, 0, x, y // below we draw with Cocoa directly in colorspace of window dim ng as NSGraphicsMBS = NSGraphicsMBS.graphicsContext dim c1 as NSColorMBS = NSColorMBS.colorWithColorSpace(me.colorspace, 0.0, 0.0, 0.0, 1.0) dim r1 as new NSRectMBS(x*0, 0, x, y) ng.setColor c1 ng.fillRect r1 dim c2 as NSColorMBS = NSColorMBS.colorWithColorSpace(me.colorspace, 1.0, 1.0, 1.0, 1.0) dim r2 as new NSRectMBS(x*1, 0, x, y) ng.setColor c2 ng.fillRect r2 dim c3 as NSColorMBS = NSColorMBS.colorWithColorSpace(me.colorspace, 1.0, 0.0, 0.0, 1.0) dim r3 as new NSRectMBS(x*2, 0, x, y) ng.setColor c3 ng.fillRect r3 dim c4 as NSColorMBS = NSColorMBS.colorWithColorSpace(me.colorspace, 0.0, 1.0, 0.0, 1.0) dim r4 as new NSRectMBS(x*3, 0, x, y) ng.setColor c4 ng.fillRect r4 dim c5 as NSColorMBS = NSColorMBS.colorWithColorSpace(me.colorspace, 0.0, 0.0, 1.0, 1.0) dim r5 as new NSRectMBS(x*4, 0, x, y) ng.setColor c5 ng.fillRect r5 End EventHandler
Sub Constructor(c as NSColorSpaceMBS) // Calling the overridden superclass constructor. Super.Constructor me.colorspace = c dim w as new NSWindowMBS(self) w.colorSpace = c Title = c.localizedName End Sub
Property colorspace As NSColorSpaceMBS
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project

See also:

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


💬 Ask a question or report a problem