EditField.st
branchdelegated_gc_text-view-selection-refactoring
changeset 5086 6f3514837c99
parent 5044 db43a967ff95
child 5055 392e14014bba
--- a/EditField.st	Thu May 01 10:47:38 2014 +0100
+++ b/EditField.st	Wed Jun 04 22:40:15 2014 +0100
@@ -1385,7 +1385,7 @@
 
 font:aFont
     super font:aFont.
-    self computeTopMargin.
+    realized ifTrue:[ self computeTopMargin ].
 !
 
 maxChars
@@ -1894,12 +1894,22 @@
 !EditField methodsFor:'initialization & release'!
 
 computeTopMargin
-    |innerHeight rest|
+    |innerHeight rest font fontHeight fontDescent|
 
     innerHeight := self innerHeight.
-    rest := innerHeight - (gc font height + (gc font descent // 2)).
+    innerHeight <= 0 ifTrue:[ textStartTop := 0. ^ self ].
+
+    font := gc font.
+    fontHeight := font height.
+    fontDescent := font descent.
+    rest := innerHeight - (fontHeight + (fontDescent // 2)).
     rest > 1 ifTrue:[
         textStartTop := (rest // 2) + margin + topMargin
+    ] ifFalse:[
+        "/ care if font is too high for my height: 
+        "/ shift baseline towards the top, so that the same is cut off at both ends.
+        "/ (the heuristic fontDescent//3) gives a few pixels more at the top)
+        textStartTop := 1 "(fontDescent//3)" - ((font ascent + fontDescent - innerHeight) // 2).
     ].
 !
 
@@ -2352,6 +2362,25 @@
     ]
 !
 
+setClipboardText:something
+    "redefined to refuse to copy the password to the clipboard"
+
+    passwordCharacter notNil ifTrue:[
+        self beep.
+        ^ self
+    ].
+    ^ super setClipboardText:something
+!
+
+setLastStringToReplace: sel
+    "redefined to refuse to remember the password"
+
+    passwordCharacter notNil ifTrue:[
+        ^ self
+    ].
+    ^ super setLastStringToReplace: sel
+!
+
 validateNewSelection
     "make certain that only one line is ever selected"
 
@@ -2365,10 +2394,10 @@
 !EditField class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.235 2014-04-13 21:00:32 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.239 2014-05-29 10:25:42 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.235 2014-04-13 21:00:32 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.239 2014-05-29 10:25:42 cg Exp $'
 ! !