draw strings half a lineSpacing lower - highlight frames look better
authorClaus Gittinger <cg@exept.de>
Thu, 23 Nov 1995 00:08:01 +0100
changeset 191 5ccbde40bb6b
parent 190 9008bbd8d9df
child 192 fc2fc4347d5d
draw strings half a lineSpacing lower - highlight frames look better with motif style
ListView.st
MenuView.st
SelListV.st
SelectionInListView.st
--- a/ListView.st	Wed Nov 22 22:19:31 1995 +0100
+++ b/ListView.st	Thu Nov 23 00:08:01 1995 +0100
@@ -52,7 +52,7 @@
 !
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.39 1995-11-22 21:19:31 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.40 1995-11-22 23:07:31 cg Exp $'
 !
 
 documentation
@@ -1008,7 +1008,7 @@
 
     y := self yOfVisibleLine:startVisLineNr.
     self paint:bg.
-    self fillRectangleX:margin y:y
+    self fillRectangleX:margin y:y-(lineSpacing//2)
 		  width:(width - (margin * 2))
 		 height:(endVisLineNr - startVisLineNr + 1) * fontHeight.
     list isNil ifTrue:[^ self].
@@ -1040,6 +1040,7 @@
 	]
     ]
 
+    "Modified: 22.11.1995 / 23:42:37 / cg"
 !
 
 drawLine:line atX:x inVisible:visLineNr with:fg and:bg
@@ -1051,13 +1052,15 @@
 
     y := self yOfVisibleLine:visLineNr.
     self paint:bg.
-    self fillRectangleX:margin y:y
+    self fillRectangleX:margin y:y - (lineSpacing//2)
 		  width:(width - (margin * 2)) 
 		 height:fontHeight.
     line notNil ifTrue:[
 	self paint:fg.
 	self displayString:line x:x y:(y + fontAscent)
     ]
+
+    "Modified: 22.11.1995 / 23:42:45 / cg"
 !
 
 drawLine:line inVisible:visLineNr with:fg and:bg
@@ -1075,7 +1078,7 @@
 drawVisibleLine:visLineNr col:col with:fg and:bg
     "draw single character at col index of visible line in fg/bg"
 
-    |y x lineString characterString|
+    |y yf x lineString characterString|
 
     lineString := self visibleAt:visLineNr.
     x := (self xOfCol:col inVisibleLine:visLineNr) - leftOffset.
@@ -1086,18 +1089,21 @@
     (lineString notNil and:[lineString isString not]) ifTrue:[
 	self drawVisibleLine:visLineNr with:fg and:bg
     ] ifFalse:[
+	yf := y - (lineSpacing//2).
 	col > lineString size ifTrue:[
-	    self fillRectangleX:x y:y width:(font width) height:fontHeight.
+	    self fillRectangleX:x y:yf width:(font width) height:fontHeight.
 	    self paint:fg
 	] ifFalse:[
 	    characterString := (lineString at:col) asString.
-	    self fillRectangleX:x y:y 
+	    self fillRectangleX:x y:yf 
 			  width:(font widthOf:characterString)
 			 height:fontHeight.
 	    self paint:fg.
 	    self displayString:characterString x:x y:(y + fontAscent)
 	]
     ]
+
+    "Modified: 22.11.1995 / 23:42:27 / cg"
 !
 
 drawVisibleLine:visLineNr from:startCol with:fg and:bg
@@ -1113,7 +1119,7 @@
     y := self yOfVisibleLine:visLineNr.
     x := (self xOfCol:index1 inVisibleLine:visLineNr) - leftOffset.
     self paint:bg.
-    self fillRectangleX:x y:y
+    self fillRectangleX:x y:y - (lineSpacing // 2)
 		  width:(width + leftOffset - x)
 		 height:fontHeight.
 
@@ -1130,12 +1136,14 @@
 	    ]
 	]
     ]
+
+    "Modified: 22.11.1995 / 23:43:37 / cg"
 !
 
 drawVisibleLine:visLineNr from:startCol to:endCol with:fg and:bg
     "draw part of a visible line in fg/bg"
 
-    |y x lineString len characterString|
+    |y yf x lineString len characterString|
 
     (endCol >= startCol) ifTrue:[
 	lineString := self visibleAt:visLineNr.
@@ -1145,11 +1153,12 @@
 	] ifFalse:[
 	    x := (self xOfCol:startCol inVisibleLine:visLineNr) - leftOffset.
 	    y := (self yOfVisibleLine:visLineNr).
+	    yf := y - (lineSpacing // 2).
 	    len := lineString size.
 	    (startCol > len) ifTrue:[
 		len := endCol - startCol + 1.
 		self paint:bg.
-		self fillRectangleX:x y:y 
+		self fillRectangleX:x y:yf 
 			      width:(fontWidth * len) 
 			     height:fontHeight
 	    ] ifFalse:[
@@ -1159,13 +1168,15 @@
 		    lineString := characterString
 		].
 		self paint:bg.
-		self fillRectangleX:x y:y width:(font widthOf:lineString from:startCol to:endCol)
+		self fillRectangleX:x y:yf width:(font widthOf:lineString from:startCol to:endCol)
 					  height:fontHeight.
 		self paint:fg.
 		self displayString:lineString from:startCol to:endCol x:x y:(y + fontAscent)
 	    ]
 	]
     ]
+
+    "Modified: 22.11.1995 / 23:43:21 / cg"
 ! !
 
 !ListView methodsFor:'queries'!
@@ -2316,6 +2327,9 @@
 initStyle
     super initStyle.
 
+    self topMargin:(self verticalPixelPerMillimeter:0.5) rounded.
+    self leftMargin:(self horizontalPixelPerMillimeter:0.5) rounded.
+
     lineSpacing := 0.
     fgColor := DefaultForegroundColor on:device.
     bgColor := DefaultBackgroundColor on:device.
@@ -2327,8 +2341,6 @@
 
     viewOrigin := 0@0.
 
-    topMargin := (self verticalPixelPerMillimeter:0.5) rounded.
-    self leftMargin:(self horizontalPixelPerMillimeter:0.5) rounded.
     textStartTop := topMargin + margin.
 
     bitGravity := #NorthWest.
--- a/MenuView.st	Wed Nov 22 22:19:31 1995 +0100
+++ b/MenuView.st	Thu Nov 23 00:08:01 1995 +0100
@@ -45,7 +45,7 @@
 !
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/MenuView.st,v 1.34 1995-11-11 16:21:32 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/MenuView.st,v 1.35 1995-11-22 23:07:45 cg Exp $'
 !
 
 documentation
@@ -243,6 +243,7 @@
 
     super initialize.
     hideOnRelease := false.
+    autoScroll := false.
 
     (((style := styleSheet name) ~~ #normal) 
     and:[style ~~ #mswindows]) ifTrue:[
@@ -255,7 +256,6 @@
 	"add some space for rounded-hilight area"
 	self leftMargin:10.
     ].
-
 !
 
 reinitialize
@@ -367,6 +367,11 @@
     hilightStyle == #openwin ifTrue:[
 	"add some space for rounded-hilight area"
 	self leftMargin:10.
+    ] ifFalse:[
+	(hilightLevel ~~ 0) ifTrue:[
+	    self leftMargin:hilightLevel abs + self margin abs + 1.
+	    lineSpacing := lineSpacing max:(hilightLevel abs * 2).
+	]
     ].
     (style == #st80) ifTrue:[
 	level := 0.
@@ -374,6 +379,8 @@
     DefaultViewBackground notNil ifTrue:[
 	viewBackground := DefaultViewBackground on:device
     ].
+
+    "Modified: 22.11.1995 / 23:18:54 / cg"
 !
 
 initEvents
@@ -426,7 +433,7 @@
 
     margin2 := margin * 2.
     w := self widthOfContents + leftMargin + leftMargin + margin2.
-    h := (self numberOfLines) * fontHeight + (2 * topMargin) + margin2.
+    h := (self numberOfLines) * fontHeight - lineSpacing + (2 * topMargin) + margin2.
     "if there is a submenu, add some space for the right arrow"
     subMenus notNil ifTrue:[
 	w := w + 16
@@ -1313,7 +1320,7 @@
     ].
 
     x := (self xOfCol:1 inVisibleLine:visLineNr) - leftOffset.
-    y := self yOfVisibleLine:visLineNr.
+    y := (self yOfVisibleLine:visLineNr) - (lineSpacing//2).
 
     (markType == $c) ifTrue:[
 	w := font widthOf:'  '.
@@ -1363,6 +1370,7 @@
     ]
 
     "Modified: 31.8.1995 / 19:27:02 / claus"
+    "Modified: 22.11.1995 / 23:24:13 / cg"
 !
 
 drawVisibleLine:visLineNr with:fg and:bg
@@ -1416,7 +1424,7 @@
     listLine notNil ifTrue:[
 
 	self drawVisibleLine:visLineNr with:fg and:bg.
-	y := self yOfVisibleLine:visLineNr.
+	y := (self yOfVisibleLine:visLineNr)  - (lineSpacing//2).
 	y2 := y + fontHeight - 1.
 	r2 := font height.
 	radius := r2 // 2.
@@ -1473,17 +1481,25 @@
 	^ self
     ].
     ^ super drawVisibleLine:visLineNr with:fg and:bg
+
+    "Modified: 22.11.1995 / 23:28:47 / cg"
 !
 
 redrawVisibleLine:visLine col:col
+    "redefined to always draw a full line - for openwin handling"
+
     self redrawVisibleLine:visLine
 !
 
 redrawVisibleLine:visLine from:startCol
+    "redefined to always draw a full line - for openwin handling"
+
     self redrawVisibleLine:visLine
 !
 
 redrawVisibleLine:visLine from:startCol to:endCol
+    "redefined to always draw a full line - for openwin handling"
+
     self redrawVisibleLine:visLine
 !
 
@@ -1636,6 +1652,12 @@
     ]
 ! !
 
+!MenuView methodsFor:'disabled scrolling'!
+
+makeSelectionVisible
+    ^ self
+! !
+
 !MenuView methodsFor:'submenu notifications'!
 
 submenuTriggered
--- a/SelListV.st	Wed Nov 22 22:19:31 1995 +0100
+++ b/SelListV.st	Thu Nov 23 00:08:01 1995 +0100
@@ -49,7 +49,7 @@
 !
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/Attic/SelListV.st,v 1.44 1995-11-17 08:54:42 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/Attic/SelListV.st,v 1.45 1995-11-22 23:08:01 cg Exp $'
 !
 
 documentation
@@ -1220,17 +1220,10 @@
      y2 "{ Class: SmallInteger }" 
      wEdge|
 
-
     bg := hilightBgColor.
     fg := hilightFgColor.
     listLine := self visibleLineToListLine:visLineNr.
     listLine notNil ifTrue:[
-"XXX only if -1/+1"
-"/        hilightLevel ~~ 0 ifTrue:[
-"/          self paint:bg.
-"/          self fillRectangleX:0 y:(self yOfVisibleLine:visLineNr)-1 width:width height:1
-"/      ].
-
 	strikeOut ifTrue:[
 	    self drawVisibleLine:visLineNr with:fgColor and:bgColor.
 	    y := self yOfVisibleLine:visLineNr.
@@ -1242,7 +1235,7 @@
 	].
 
 	self drawVisibleLine:visLineNr with:fg and:bg.
-	y := self yOfVisibleLine:visLineNr.
+	y := (self yOfVisibleLine:visLineNr) - (lineSpacing//2).
 
 	"
 	 a line above and below
@@ -1261,20 +1254,15 @@
 	 an edge it around
 	"
 	(hilightLevel ~~ 0) ifTrue:[
-"XXX the -1/+1 need some more work"
-"/                self drawEdgesForX:0 y:y-1 
-"/                             width:width height:fontHeight+1 
-"/                             level:hilightLevel.
-
 	    "
 	     let edge start at left, extending to the full width
 	     XXX: widthOfContents should be cached in ListView
 		  (instead of recomputing all over)
 	    "
 	    wEdge := width-(2 * margin).
-includesNonStrings ifFalse:[
-	    wEdge := wEdge max:(self widthOfContents).
-].
+	    includesNonStrings ifFalse:[
+		wEdge := wEdge max:(self widthOfContents).
+	    ].
 	    self drawEdgesForX:(margin - leftOffset) y:y 
 			 width:wEdge height:fontHeight 
 			 level:hilightLevel.
--- a/SelectionInListView.st	Wed Nov 22 22:19:31 1995 +0100
+++ b/SelectionInListView.st	Thu Nov 23 00:08:01 1995 +0100
@@ -49,7 +49,7 @@
 !
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/SelectionInListView.st,v 1.44 1995-11-17 08:54:42 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/SelectionInListView.st,v 1.45 1995-11-22 23:08:01 cg Exp $'
 !
 
 documentation
@@ -1220,17 +1220,10 @@
      y2 "{ Class: SmallInteger }" 
      wEdge|
 
-
     bg := hilightBgColor.
     fg := hilightFgColor.
     listLine := self visibleLineToListLine:visLineNr.
     listLine notNil ifTrue:[
-"XXX only if -1/+1"
-"/        hilightLevel ~~ 0 ifTrue:[
-"/          self paint:bg.
-"/          self fillRectangleX:0 y:(self yOfVisibleLine:visLineNr)-1 width:width height:1
-"/      ].
-
 	strikeOut ifTrue:[
 	    self drawVisibleLine:visLineNr with:fgColor and:bgColor.
 	    y := self yOfVisibleLine:visLineNr.
@@ -1242,7 +1235,7 @@
 	].
 
 	self drawVisibleLine:visLineNr with:fg and:bg.
-	y := self yOfVisibleLine:visLineNr.
+	y := (self yOfVisibleLine:visLineNr) - (lineSpacing//2).
 
 	"
 	 a line above and below
@@ -1261,20 +1254,15 @@
 	 an edge it around
 	"
 	(hilightLevel ~~ 0) ifTrue:[
-"XXX the -1/+1 need some more work"
-"/                self drawEdgesForX:0 y:y-1 
-"/                             width:width height:fontHeight+1 
-"/                             level:hilightLevel.
-
 	    "
 	     let edge start at left, extending to the full width
 	     XXX: widthOfContents should be cached in ListView
 		  (instead of recomputing all over)
 	    "
 	    wEdge := width-(2 * margin).
-includesNonStrings ifFalse:[
-	    wEdge := wEdge max:(self widthOfContents).
-].
+	    includesNonStrings ifFalse:[
+		wEdge := wEdge max:(self widthOfContents).
+	    ].
 	    self drawEdgesForX:(margin - leftOffset) y:y 
 			 width:wEdge height:fontHeight 
 			 level:hilightLevel.