--- a/SmallSense__PO.st Thu Jun 19 13:15:27 2014 +0100
+++ b/SmallSense__PO.st Thu Jun 19 15:19:22 2014 +0100
@@ -231,8 +231,8 @@
!PO methodsFor:'displaying'!
-displayLabel:aLabel h:lH on:aGC x:x y:y h:h
- | cx iconOrNil |
+displayLabel:lab h:lH on:gc x:x y:y0 h:h
+ | cx hint hintW cy |
cx := x.
@@ -242,10 +242,54 @@
"/ ].
"/ cx := cx + IconWidth.
- super displayLabel:aLabel h:lH on:aGC x:cx y:y h:h
+ "/ Display label
+ super displayLabel:lab h:lH on:gc x:cx y:y0 h:h.
+
+ "/ Display hint
+ hint := self hint.
+ hint notNil ifTrue:[
+ cx := cx + (lab widthOn: gc).
+ hintW := hint widthOn: gc.
+ "/ Check whether there's enougn space fit the hint
+ (gc width) > (cx + hintW + 10"spacing") ifFalse:[
+ hint isString ifFalse:[
+ "/ There's nothing to do for non-strings
+ ^ self
+ ].
+ "/ Try to shorten the text.
+ hint := hint contractAtEndTo: ((gc width - cx - 10) // ('m' widthOn: gc)).
+ hint size < 6 ifTrue:[
+ "/ To short to be meaningfull, give up.
+ ^ self.
+ ].
+ hintW := hint widthOn: gc.
+ "/ Check again if it can fit...
+ (gc width) > (cx + hintW + 10"spacing") ifFalse:[
+ "/ Give up.
+ ^ self.
+ ]
+ ].
+
+ cx := gc width - hintW - 3"right padding".
+ cy := y0 - ((lH + 1 - h) // 2).
+ (hint isString and:[hint isText not]) ifTrue:[
+ | savPaint |
+
+ cy := cy + (hint ascentOn:gc).
+ savPaint := gc paint.
+ gc paint: (Color gray: 40).
+ hint displayOn:gc x: cx y:cy.
+ gc paint: savPaint
+ ] ifFalse:[
+ hint isText ifTrue:[
+ cy := cy + (hint ascentOn:gc).
+ ].
+ hint displayOn:gc x: cx y:cy.
+ ].
+ ].
"Created: / 24-07-2013 / 00:22:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 28-04-2014 / 00:16:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 19-06-2014 / 15:18:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
displayOn:aGC x:x y:y h:h