Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/Util/Rotate Text
Function:
Required plugins for this example: MBS Util Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Util/Rotate Text
This example is the version from Sat, 4th May 2018.
Project "Rotate Text.rbp"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control Canvas1 Inherits Canvas
ControlInstance Canvas1 Inherits Canvas
EventHandler Sub Open() dim p as new Picture(me.Width, me.Height, 32) dim g as Graphics = p.Graphics draw g me.Backdrop = p End EventHandler
End Control
Control CheckBoxes Inherits CheckBox
ControlInstance CheckBoxes Inherits CheckBox
EventHandler Sub Action() ShowRectangles = me.Value Refresh End EventHandler
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() dim g as Graphics = OpenPrinterDialog if g = nil then Return draw g End EventHandler
End Control
EventHandler Sub Open() dim platform as string if TargetCocoa then platform = "Cocoa" elseif TargetMachO then platform = "Carbon" elseif TargetWin32 then platform = "Win32" elseif TargetLinux then platform = "Linux" else break end if Title = platform+" - "+RBVersionString+" - MBS "+mbs.VersionString End EventHandler
EventHandler Sub Paint(g As Graphics, areas() As REALbasic.Rect) draw g End EventHandler
Sub Draw(g as Graphics, rotation as double, text as string, x as integer, y as integer) if ShowRectangles then dim width, height as Double if g.MeasureRotatedTextMBS(text, width, height) then g.DrawRect x, y-height, width, height end if end if g.DrawRotatedTextMBS rotation, text, x, y End Sub
Sub draw(g as Graphics) g.TextSize = 10 g.TextFont = "Times" Draw g, 0, "Times 10pt", 200,100 g.TextSize = 12 g.Bold = true g.TextFont = "Times" Draw g, 0, "Times 12pt bold", 200,200 g.TextSize = 14 g.Bold = false g.TextFont = "Times" Draw g, 0, "Times 14pt", 200,300 g.TextSize = 18 g.italic = true g.TextFont = "Times" Draw g, 0, "Times 18pt italic", 200,400 g.TextSize = 10 g.TextFont = "Times" Draw g, 30, "Times 10pt", 150,100 g.TextSize = 12 g.Bold = true g.TextFont = "Times" Draw g, 30, "Times 12pt bold", 150,200 g.TextSize = 14 g.Bold = false g.TextFont = "Times" Draw g, 30, "Times 14pt", 150,300 g.TextSize = 18 g.italic = true g.TextFont = "Times" Draw g, 30, "Times 18pt italic", 150,400 g.TextSize = 10 g.TextFont = "Arial" Draw g, 45, "Arial 10pt", 100,100 g.TextSize = 12 g.Bold = true g.TextFont = "Arial" Draw g, 45, "Arial 12pt bold", 100,200 g.TextSize = 14 g.Bold = false g.TextFont = "Arial" Draw g, 45, "Arial 14pt", 100,300 g.TextSize = 18 g.italic = true g.TextFont = "Arial" Draw g, 45, "Arial 18pt italic", 100,400 g.TextSize = 10 g.TextFont = "Verdana" Draw g, 70, "Verdana 10pt", 50,100 g.TextSize = 12 g.Bold = true g.TextFont = "Verdana" Draw g, 70, "Verdana 12pt bold", 50,200 g.TextSize = 14 g.Bold = false g.TextFont = "Verdana" Draw g, 70, "Verdana 14pt", 50,300 g.TextSize = 18 g.italic = true g.TextFont = "Verdana" Draw g, 70, "Verdana 18pt italic", 50,400 End Sub
Property ShowRectangles As Boolean
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
End Project

Feedback, Comments & Corrections

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




Links
MBS Xojo Plugins