Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Platforms to show: All Mac Windows Linux Cross-Platform

/MacOSX/Attributed String print
Function:
You find this example project in your Plugins Download as a Xojo (Real Studio) project file within the examples folder: /MacOSX/Attributed String print
This example is the version from Fri, 5th Jun 2014.
Project "Attributed String print.rbp"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control TextArea1 Inherits TextArea
ControlInstance TextArea1 Inherits TextArea
EventHandler Sub Open() me.SelStart =0 me.SelLength = 12 me.SelBold = True me.SelStart = 0 me.SelLength = 0 End EventHandler
End Control
Control BevelButton1 Inherits BevelButton
ControlInstance BevelButton1 Inherits BevelButton
EventHandler Sub Action() dim g as Graphics = OpenPrinterDialog if g = nil then Return dim textView as NSTextViewMBS = TextArea1.NSTextViewMBS //this just gets the stored text (cannot use textView otherwise) dim t as NSAttributedStringMBS = textView.textStorage.copy //define the location to put the text dim rect as new CGRectMBS(100,100, g.Width-200, g.height-200) //and a new graphics object for the view dim h as integer = g.Handle(g.HandleTypeCGContextRef) dim c as CGContextMBS = CGContextMBS.contextWithCGContext(h) dim path as new CGMutablePathMBS path.AddRect nil, rect dim ca as CFAttributedStringMBS = t.AsCFAttributedString dim fs as CTFramesetterMBS = CTFramesetterMBS.CreateWithAttributedString(ca) dim fr as CTFrameMBS = fs.CreateFrame(0, 0, path, nil) fr.Draw(c) fr = nil fs = nil c.Flush c = nil g = nil ' End EventHandler
End Control
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

Feedback, Comments & Corrections

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




Links
MBS FileMaker blog