The Trunk: System-mt.822.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: System-mt.822.mcz

commits-2
Marcel Taeumel uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-mt.822.mcz

==================== Summary ====================

Name: System-mt.822
Author: mt
Time: 4 May 2016, 3:41:22.823971 pm
UUID: 303d3668-90ba-ac46-b7d4-847e945efeb8
Ancestors: System-dtl.821

Until we find a better way, let projects provide generic means of composing DisplayText into a Form. Used, for example, for our emergency debugger.

=============== Diff against System-dtl.821 ===============

Item was added:
+ ----- Method: Project>>composeDisplayTextIntoForm: (in category 'utilities') -----
+ composeDisplayTextIntoForm: displayText
+ "Compose the given display text into a form. This is at project level so that UI-specific mechanisms can be used. We may want to make this independent from Morphic or MVC in the future. Good-looking text rendering is good for any user interface."
+
+ | port form font width height lines |
+ font := displayText textStyle defaultFont.
+ lines := displayText string lines.
+
+ width := lines
+ ifEmpty: [1]
+ ifNotEmpty: [(lines collect: [:line | font widthOfString: line]) max].
+ height := font height * lines size.
+
+ form := Form extent: width@height depth: 32.
+ port := BitBlt toForm: form.
+
+ "1) Fill background."
+ port
+ fill: form boundingBox
+ fillColor: displayText backgroundColor
+ rule: Form over.
+
+ "2) Draw text lines."
+ port combinationRule: Form paint.
+ font
+ installOn: port
+ foregroundColor: displayText foregroundColor
+ backgroundColor: Color transparent.
+
+ lines withIndexDo: [:line :index |
+ font
+ displayString: line
+ on: port
+ from: 1
+ to: line size
+ at: 0@((index-1) * font height)
+ kern: 0].
+
+ ^ form!