Scroller.st
changeset 2176 7069af4213d6
parent 2175 5042e15f3cf6
child 2177 f554919e10ab
equal deleted inserted replaced
2175:5042e15f3cf6 2176:7069af4213d6
  1037     |handleX handleY l t lvl
  1037     |handleX handleY l t lvl
  1038      w "{ Class: SmallInteger }"
  1038      w "{ Class: SmallInteger }"
  1039      h "{ Class: SmallInteger }"
  1039      h "{ Class: SmallInteger }"
  1040      x "{ Class: SmallInteger }"
  1040      x "{ Class: SmallInteger }"
  1041      y "{ Class: SmallInteger }"
  1041      y "{ Class: SmallInteger }"
  1042      mm xL xR yT yB color1 color2|
  1042      mm xL xR yT yB color1 color2 b r|
  1043 
  1043 
  1044     (thumbHeight >= 100) ifTrue:[^ self].
  1044     (thumbHeight >= 100) ifTrue:[^ self].
  1045 
  1045 
  1046     w := thumbFrame width.
  1046     w := thumbFrame width.
  1047     h := thumbFrame height.
  1047     h := thumbFrame height.
  1048 
       
  1049     orientation == #vertical ifTrue:[
       
  1050 	h >= height ifTrue:[^ self].
       
  1051     ] ifFalse:[
       
  1052 	w >= width ifTrue:[^ self].
       
  1053     ].
       
  1054 
       
  1055     l := thumbFrame left.
  1048     l := thumbFrame left.
  1056     t := thumbFrame top.
  1049     t := thumbFrame top.
  1057 
  1050 
       
  1051     orientation == #vertical ifTrue:[
       
  1052         b := thumbFrame bottom.
       
  1053         b >= (height - margin) ifTrue:[
       
  1054             t <= margin ifTrue:[
       
  1055                 ^ self
       
  1056             ]
       
  1057         ].
       
  1058     ] ifFalse:[
       
  1059         r := thumbFrame right.
       
  1060         r >= (width - margin) ifTrue:[
       
  1061             l <= margin ifTrue:[
       
  1062                 ^ self
       
  1063             ]
       
  1064         ].
       
  1065     ].
       
  1066 
  1058     self paint:(entered ifTrue:[thumbEnteredColor] ifFalse:[thumbColor]).
  1067     self paint:(entered ifTrue:[thumbEnteredColor] ifFalse:[thumbColor]).
  1059     self fillRectangleX:l y:t width:w-1 height:h.
  1068     self fillRectangleX:l y:t width:w-1 height:h.
  1060 
  1069 
  1061     lvl := thumbLevel.
  1070     lvl := thumbLevel.
  1062     scrolling ifTrue:[
  1071     scrolling ifTrue:[
  1063 	lvl := thumbActiveLevel
  1072         lvl := thumbActiveLevel
  1064     ].
  1073     ].
  1065 
  1074 
  1066     lvl == 0 ifTrue:[
  1075     lvl == 0 ifTrue:[
  1067 	thumbFrameColor notNil ifTrue:[
  1076         thumbFrameColor notNil ifTrue:[
  1068 	    self paint:thumbFrameColor.
  1077             self paint:thumbFrameColor.
  1069 	    self displayRectangleX:l y:t width:w height:h.
  1078             self displayRectangleX:l y:t width:w height:h.
  1070 	].
  1079         ].
  1071 	thumbImage notNil ifTrue:[
  1080         thumbImage notNil ifTrue:[
  1072 	    thumbImage displayOn:self x:l y:t
  1081             thumbImage displayOn:self x:l y:t
  1073 	].
  1082         ].
  1074 	^ self
  1083         ^ self
  1075     ].
  1084     ].
  1076 
  1085 
  1077     self drawEdgesForX:l y:t width:w height:h level:lvl
  1086     self drawEdgesForX:l y:t width:w height:h level:lvl
  1078 		shadow:thumbShadowColor light:thumbLightColor
  1087                 shadow:thumbShadowColor light:thumbLightColor
  1079 		halfShadow:thumbHalfShadowColor halfLight:thumbHalfLightColor
  1088                 halfShadow:thumbHalfShadowColor halfLight:thumbHalfLightColor
  1080 		style:thumbEdgeStyle.
  1089                 style:thumbEdgeStyle.
  1081 
  1090 
  1082     thumbFrameColor notNil ifTrue:[
  1091     thumbFrameColor notNil ifTrue:[
  1083 	self paint:thumbFrameColor.
  1092         self paint:thumbFrameColor.
  1084 	self displayRectangleX:l y:t width:w height:h.
  1093         self displayRectangleX:l y:t width:w height:h.
  1085     ].
  1094     ].
  1086 
  1095 
  1087     thumbImage notNil ifTrue:[
  1096     thumbImage notNil ifTrue:[
  1088 	thumbImage displayOn:self x:l y:t
  1097         thumbImage displayOn:self x:l y:t
  1089     ].
  1098     ].
  1090 
  1099 
  1091     (tallyLevel == 0 or:[tallyMarks == 0]) ifTrue:[
  1100     (tallyLevel == 0 or:[tallyMarks == 0]) ifTrue:[
  1092 	shadowForm notNil ifTrue:[
  1101         shadowForm notNil ifTrue:[
  1093 	    handleX := l + ((w - 8) // 2).
  1102             handleX := l + ((w - 8) // 2).
  1094 	    handleY := t + ((h - 8) // 2).
  1103             handleY := t + ((h - 8) // 2).
  1095 	    self drawHandleFormAtX:handleX y:handleY
  1104             self drawHandleFormAtX:handleX y:handleY
  1096 	].
  1105         ].
  1097 	^ self
  1106         ^ self
  1098     ].
  1107     ].
  1099 
  1108 
  1100     "iris style - draw tallys"
  1109     "iris style - draw tallys"
  1101 
  1110 
  1102     tallyLevel > 0 ifTrue:[
  1111     tallyLevel > 0 ifTrue:[
  1103 	color1 := thumbLightColor.
  1112         color1 := thumbLightColor.
  1104 	color2 := thumbShadowColor.
  1113         color2 := thumbShadowColor.
  1105     ] ifFalse:[
  1114     ] ifFalse:[
  1106 	color1 := thumbShadowColor.
  1115         color1 := thumbShadowColor.
  1107 	color2 := thumbLightColor.
  1116         color2 := thumbLightColor.
  1108     ].
  1117     ].
  1109 
  1118 
  1110     "draw tally marks"
  1119     "draw tally marks"
  1111 
  1120 
  1112     (orientation == #vertical) ifTrue:[
  1121     (orientation == #vertical) ifTrue:[
  1113 	self paint:color1.
  1122         self paint:color1.
  1114 	y := t + (h // 2) - 1.
  1123         y := t + (h // 2) - 1.
  1115 	xL := l + lvl - 1.
  1124         xL := l + lvl - 1.
  1116 	xR := l + w - lvl "+ 1".
  1125         xR := l + w - lvl "+ 1".
  1117 	self displayLineFromX:xL y:y toX:xR y:y.
  1126         self displayLineFromX:xL y:y toX:xR y:y.
  1118 	y := y + 1.
  1127         y := y + 1.
  1119 	self paint:color2.
  1128         self paint:color2.
  1120 	self displayLineFromX:xL y:y toX:xR y:y.
  1129         self displayLineFromX:xL y:y toX:xR y:y.
  1121 
  1130 
  1122 	tallyMarks > 1 ifTrue:[
  1131         tallyMarks > 1 ifTrue:[
  1123 	    "dont draw other marks if there is not enough space"
  1132             "dont draw other marks if there is not enough space"
  1124 
  1133 
  1125 	    mm := device verticalPixelPerMillimeter rounded.
  1134             mm := device verticalPixelPerMillimeter rounded.
  1126 	    h > (mm * (tallyMarks * 2)) ifTrue:[
  1135             h > (mm * (tallyMarks * 2)) ifTrue:[
  1127 		y := y - 1 - mm.
  1136                 y := y - 1 - mm.
  1128 		self paint:color1.
  1137                 self paint:color1.
  1129 		self displayLineFromX:xL y:y toX:xR y:y.
  1138                 self displayLineFromX:xL y:y toX:xR y:y.
  1130 		y := y + 1.
  1139                 y := y + 1.
  1131 		self paint:color2.
  1140                 self paint:color2.
  1132 		self displayLineFromX:xL y:y toX:xR y:y.
  1141                 self displayLineFromX:xL y:y toX:xR y:y.
  1133 
  1142 
  1134 		y := y - 1 + mm + mm.
  1143                 y := y - 1 + mm + mm.
  1135 		self paint:color1.
  1144                 self paint:color1.
  1136 		self displayLineFromX:xL y:y toX:xR y:y.
  1145                 self displayLineFromX:xL y:y toX:xR y:y.
  1137 		y := y + 1.
  1146                 y := y + 1.
  1138 		self paint:color2.
  1147                 self paint:color2.
  1139 		self displayLineFromX:xL y:y toX:xR y:y
  1148                 self displayLineFromX:xL y:y toX:xR y:y
  1140 	    ]
  1149             ]
  1141 	]
  1150         ]
  1142     ] ifFalse:[
  1151     ] ifFalse:[
  1143 	x := l + (w // 2) - 1.
  1152         x := l + (w // 2) - 1.
  1144 	yT := t + lvl - 1.
  1153         yT := t + lvl - 1.
  1145 	yB := t + h - lvl "+ 1".
  1154         yB := t + h - lvl "+ 1".
  1146 	self paint:color1.
  1155         self paint:color1.
  1147 	self displayLineFromX:x y:yT toX:x y:yB.
  1156         self displayLineFromX:x y:yT toX:x y:yB.
  1148 	self paint:color2.
  1157         self paint:color2.
  1149 	x := x + 1.
  1158         x := x + 1.
  1150 	self displayLineFromX:x y:yT toX:x y:yB.
  1159         self displayLineFromX:x y:yT toX:x y:yB.
  1151 
  1160 
  1152 	tallyMarks > 1 ifTrue:[
  1161         tallyMarks > 1 ifTrue:[
  1153 	    "dont draw other marks if there is not enough space"
  1162             "dont draw other marks if there is not enough space"
  1154 
  1163 
  1155 	    mm := device horizontalPixelPerMillimeter rounded.
  1164             mm := device horizontalPixelPerMillimeter rounded.
  1156 	    w > (mm * (tallyMarks * 2)) ifTrue:[
  1165             w > (mm * (tallyMarks * 2)) ifTrue:[
  1157 		x := x - 1 - mm.
  1166                 x := x - 1 - mm.
  1158 		self paint:color1.
  1167                 self paint:color1.
  1159 		self displayLineFromX:x y:yT toX:x y:yB.
  1168                 self displayLineFromX:x y:yT toX:x y:yB.
  1160 		x := x + 1.
  1169                 x := x + 1.
  1161 		self paint:color2.
  1170                 self paint:color2.
  1162 		self displayLineFromX:x y:yT toX:x y:yB.
  1171                 self displayLineFromX:x y:yT toX:x y:yB.
  1163 
  1172 
  1164 		x := x - 1 + mm + mm.
  1173                 x := x - 1 + mm + mm.
  1165 		self paint:color1.
  1174                 self paint:color1.
  1166 		self displayLineFromX:x y:yT toX:x y:yB.
  1175                 self displayLineFromX:x y:yT toX:x y:yB.
  1167 		x := x + 1.
  1176                 x := x + 1.
  1168 		self paint:color2.
  1177                 self paint:color2.
  1169 		self displayLineFromX:x y:yT toX:x y:yB
  1178                 self displayLineFromX:x y:yT toX:x y:yB
  1170 	    ]
  1179             ]
  1171 	]
  1180         ]
  1172     ]
  1181     ]
  1173 
  1182 
  1174     "Modified: / 29.4.1999 / 09:35:52 / cg"
  1183     "Modified: / 29.4.1999 / 09:35:52 / cg"
  1175 !
  1184 !
  1176 
  1185 
  1639         oldThumbFrame notNil ifTrue:[
  1648         oldThumbFrame notNil ifTrue:[
  1640             self computeThumbFrame.
  1649             self computeThumbFrame.
  1641             "/ any change ?
  1650             "/ any change ?
  1642             thumbFrame = oldThumbFrame ifTrue:[
  1651             thumbFrame = oldThumbFrame ifTrue:[
  1643                 ^ self
  1652                 ^ self
  1644             ].
       
  1645 
       
  1646             thumbHeight >= 100 ifTrue:[
       
  1647                 self invalidate:oldThumbFrame.
       
  1648                 ^ self.
       
  1649             ].
  1653             ].
  1650 
  1654 
  1651             "/ try to redraw as little as possible
  1655             "/ try to redraw as little as possible
  1652 
  1656 
  1653             oldTop := oldThumbFrame top.
  1657             oldTop := oldThumbFrame top.
  2421 ! !
  2425 ! !
  2422 
  2426 
  2423 !Scroller class methodsFor:'documentation'!
  2427 !Scroller class methodsFor:'documentation'!
  2424 
  2428 
  2425 version
  2429 version
  2426     ^ '$Header: /cvs/stx/stx/libwidg/Scroller.st,v 1.142 2000-04-03 14:39:12 cg Exp $'
  2430     ^ '$Header: /cvs/stx/stx/libwidg/Scroller.st,v 1.143 2000-04-03 15:34:39 cg Exp $'
  2427 ! !
  2431 ! !