fixed check-item drawing.
--- a/MenuView.st Tue May 19 16:28:27 1998 +0200
+++ b/MenuView.st Tue May 19 22:19:17 1998 +0200
@@ -14,13 +14,14 @@
instanceVariableNames:'selectors args receiver enableFlags disabledFgColor onOffFlags
subMenus subMenuShown superMenu checkColor lineLevel lineInset
masterView needResize hideOnRelease sizeFixed shortKeys
- maxShortKeyStringLen actions'
+ maxShortKeyStringLen actions checkOnImage checkOffImage'
classVariableNames:'DefaultCheckColor DefaultViewBackground DefaultForegroundColor
DefaultBackgroundColor DefaultDisabledForegroundColor
DefaultHilightForegroundColor DefaultHilightBackgroundColor
DefaultHilightLevel DefaultHilightStyle DefaultHilightFrameColor
DefaultLineLevel DefaultLineInset DefaultShadowColor
- DefaultLightColor ShowAcceleratorKeys'
+ DefaultLightColor ShowAcceleratorKeys DefaultCheckOnImage
+ DefaultCheckOffImage'
poolDictionaries:''
category:'Views-Menus'
!
@@ -43,6 +44,10 @@
documentation
"
+ Notice:
+ MenuView is going to be obsoleted - use Menu & MenuItem for
+ new applications.
+
a menu view used for both pull-down-menus and pop-up-menus (and also,
for nonModal menus, such as the OldLaunchers click-menu).
the action to be performed can be defined either as:
@@ -69,37 +74,37 @@
StyleSheet defaults:
- menuFont font to use for menus
-
- menuViewBackground view background (should be same as menuBackgroundColor)
- menuForegroundColor foreground color
- menuBackgroundColor background color
-
- menuShadowColor shadow color for 3D effects
- menuLightColor lightColor for 3D effects
- menuHilightForegroundColor hilighted items foregroundColor
- menuHilightBackgroundColor hilighted items backgroundColor
-
- menuHilightFrameColor frame arounf hilighted items (or nil, if none)
- defaults to selectionHilightFrameColor
- menuHilightLevel 3D level of selected items
- menuHilightStyle #openwin or nil (special kludge)
- menuSeparatingLineLevel 3D level of sep. lines
- menuSeparatingLineInset left/right inset of sep. lines
- menuDisabledForegroundColor foreground color of disabled items
- menuCheckColor color to use for check marks
- menuFont font to use
+ menuFont font to use for menus
+
+ menuViewBackground view background (should be same as menuBackgroundColor)
+ menuForegroundColor foreground color
+ menuBackgroundColor background color
+
+ menuShadowColor shadow color for 3D effects
+ menuLightColor lightColor for 3D effects
+ menuHilightForegroundColor hilighted items foregroundColor
+ menuHilightBackgroundColor hilighted items backgroundColor
+
+ menuHilightFrameColor frame arounf hilighted items (or nil, if none)
+ defaults to selectionHilightFrameColor
+ menuHilightLevel 3D level of selected items
+ menuHilightStyle #openwin or nil (special kludge)
+ menuSeparatingLineLevel 3D level of sep. lines
+ menuSeparatingLineInset left/right inset of sep. lines
+ menuDisabledForegroundColor foreground color of disabled items
+ menuCheckColor color to use for check marks
+ menuFont font to use
other values and some defaults are inherited via SelectionInListViews
styles (i.e. look for selectionForegroundColor ...)
[author:]
- Claus Gittinger
+ Claus Gittinger
[see also:]
- PopUpMenu PullDownMenu
- ClickMenuView
- LineMenu PatternMenu
+ PopUpMenu PullDownMenu
+ ClickMenuView
+ LineMenu PatternMenu
"
!
@@ -310,14 +315,15 @@
"extract values from the styleSheet and cache them in class variables"
<resource: #style (#'menu.foregroundColor' #'menu.backgroundColor'
- #'menu.viewBackground'
- #'menu.shadowColor' #'menu.lightColor'
- #'menu.hilightForegroundColor' #'menu.hilightBackgroundColor'
- #'menu.hilightFrameColor' #'selection.hilightFrameColor'
- #'menu.hilightLevel' #'menu.hilightStyle'
- #'menu.separatingLineLevel' #'menu.separatingLineInset'
- #'menu.disabledForegroundColor' #'menu.checkColor'
- #'menu.font' #'menu.showAccelerators')>
+ #'menu.viewBackground'
+ #'menu.shadowColor' #'menu.lightColor'
+ #'menu.hilightForegroundColor' #'menu.hilightBackgroundColor'
+ #'menu.hilightFrameColor' #'selection.hilightFrameColor'
+ #'menu.hilightLevel' #'menu.hilightStyle'
+ #'menu.separatingLineLevel' #'menu.separatingLineInset'
+ #'menu.disabledForegroundColor'
+ #'menu.checkColor' #'menu.checkOnImage' #'menu.checkOffImage'
+ #'menu.font' #'menu.showAccelerators')>
DefaultViewBackground := StyleSheet colorAt:'menu.viewBackground'.
DefaultForegroundColor := StyleSheet colorAt:'menu.foregroundColor'.
@@ -327,13 +333,15 @@
DefaultHilightForegroundColor := StyleSheet colorAt:'menu.hilightForegroundColor'.
DefaultHilightBackgroundColor := StyleSheet colorAt:'menu.hilightBackgroundColor'.
DefaultHilightFrameColor := StyleSheet colorAt:'menu.hilightFrameColor'
- default:(StyleSheet colorAt:'selection.hilightFrameColor').
+ default:(StyleSheet colorAt:'selection.hilightFrameColor').
DefaultHilightLevel := StyleSheet at:'menu.hilightLevel'.
DefaultHilightStyle := StyleSheet at:'menu.hilightStyle'.
DefaultLineLevel := StyleSheet at:'menu.separatingLineLevel'.
DefaultLineInset := StyleSheet at:'menu.separatingLineInset'.
DefaultDisabledForegroundColor := StyleSheet colorAt:'menu.disabledForegroundColor' default:Color darkGray.
DefaultCheckColor := StyleSheet colorAt:'menu.checkColor'.
+ DefaultCheckOnImage := StyleSheet at:'menu.checkOnImage'.
+ DefaultCheckOffImage := StyleSheet at:'menu.checkOffImage'.
DefaultFont := StyleSheet fontAt:'menu.font'.
ShowAcceleratorKeys := StyleSheet at:'menu.showAccelerators' default:true.
@@ -341,7 +349,7 @@
self updateStyleCache
"
- "Modified: / 1.11.1997 / 03:25:18 / cg"
+ "Modified: / 19.5.1998 / 22:02:30 / cg"
! !
!MenuView methodsFor:'accessing-behavior'!
@@ -1377,24 +1385,23 @@
drawCheckLine:line inVisibleLine:visLineNr with:fg and:bg
"draw an on/off-mark (or the space for it).
Supported checkmark types:
- \c simple mark; space if off
- \b box mark
- \t thumbsUp/thumbsDown mark
+ \c simple mark; space if off
+ \b box mark
+ \t thumbsUp/thumbsDown mark
"
|w h y x l check xR yB form markIndex i2 markType|
l := self visibleLineToListLine:visLineNr.
- onOffFlags isNil ifTrue:[
- check := false
- ] ifFalse:[
- check := (onOffFlags at:l) == true.
- ].
-
- i2 := markIndex := 1.
+ onOffFlags isNil ifTrue:[^ false]. "/ not a check-item line
+ check := onOffFlags at:l ifAbsent:nil.
+ check isNil ifTrue:[^ false]. "/ not a check-item line
+ check := check value.
+
+ markIndex := 1.
[markIndex ~~ 0 and:[i2 ~~ (markIndex+1)]] whileTrue:[
- markIndex := line indexOf:$\ startingAt:i2+1.
- i2 := line indexOfAny:'cbt' startingAt:markIndex+1.
+ markIndex := line indexOf:$\ startingAt:markIndex.
+ i2 := line indexOfAny:'cbt' startingAt:markIndex+1.
].
markType := line at:i2.
@@ -1404,21 +1411,29 @@
self paint:bg.
self fillRectangleX:margin y:y width:(width-(margin*2)) height:fontHeight.
markIndex ~~ 1 ifTrue:[
- super drawVisibleLine:visLineNr from:1 to:(markIndex-1) with:fg and:bg.
+ super drawVisibleLine:visLineNr from:1 to:(markIndex-1) with:fg and:bg.
].
(markType == $c) ifTrue:[
- w := font widthOf:'V'.
+ w := font widthOf:'V'.
+ check ifTrue:[
+ form := checkOnImage.
+ ] ifFalse:[
+ form := checkOffImage.
+ ]
] ifFalse:[
- (markType == $b) ifTrue:[
- w := font maxWidth. "/ font widthOf:' '.
- ] ifFalse:[
- (markType == $t) ifTrue:[
- w := 16.
- check ifTrue:[form := Cursor thumbsUp sourceForm]
- ifFalse:[form := Cursor thumbsDown sourceForm]
- ]
- ]
+ (markType == $b) ifTrue:[
+ w := font maxWidth. "/ font widthOf:' '.
+ ] ifFalse:[
+ (markType == $t) ifTrue:[
+ check ifTrue:[form := Cursor thumbsUp sourceForm]
+ ifFalse:[form := Cursor thumbsDown sourceForm]
+ ]
+ ]
+ ].
+
+ form notNil ifTrue:[
+ w := form width.
].
self drawLine:(line copyFrom:markIndex+2) fromX:x+w inVisible:visLineNr with:fg and:bg.
@@ -1428,30 +1443,31 @@
y := y + (font height - h // 2).
yB := y + h - 1.
- (markType == $c) ifTrue:[
- check ifTrue:[
- xR := x + (w // 3).
- self displayLineFromX:x y:(y + (h // 2)) toX:xR y:yB.
- self displayLineFromX:xR y:yB toX:(x + w - 1) y:y
- ]
+ form notNil ifTrue:[
+ self displayForm:form x:x y:y
] ifFalse:[
- (markType == $t) ifTrue:[
- self displayForm:form x:x y:y
- ] ifFalse:[
- (markType == $b) ifTrue:[
- check ifTrue:[
- xR := x + w - 2.
- self displayLineFromX:x y:y toX:xR y:yB.
- self displayLineFromX:xR y:y toX:x y:yB.
- ].
- self paint:fg.
- self displayRectangleX:x y:y width:h height:h.
- ]
- ]
- ]
-
- "Modified: 28.2.1996 / 14:14:29 / cg"
- "Modified: 6.5.1997 / 18:04:38 / stefan"
+ (markType == $c) ifTrue:[
+ check ifTrue:[
+ xR := x + (w // 3).
+ self displayLineFromX:x y:(y + (h // 2)) toX:xR y:yB.
+ self displayLineFromX:xR y:yB toX:(x + w - 1) y:y
+ ]
+ ] ifFalse:[
+ (markType == $b) ifTrue:[
+ check ifTrue:[
+ xR := x + w - 2.
+ self displayLineFromX:x y:y toX:xR y:yB.
+ self displayLineFromX:xR y:y toX:x y:yB.
+ ].
+ self paint:fg.
+ self displayRectangleX:x y:y width:h height:h.
+ ]
+ ].
+ ].
+ ^ true
+
+ "Modified: / 6.5.1997 / 18:04:38 / stefan"
+ "Modified: / 19.5.1998 / 22:16:43 / cg"
!
drawVisibleLine:visLineNr with:fg and:bg
@@ -1462,22 +1478,19 @@
isSpecial := lineString notNil and:[lineString includes:$\].
isSpecial ifFalse:[
- "
- a normal entry
- "
- super drawVisibleLine:visLineNr with:fg and:bg
+ "
+ a normal entry
+ "
+ super drawVisibleLine:visLineNr with:fg and:bg
] ifTrue:[
- "
- some speciality in this line
- "
- (self isCheckItem:lineString) ifTrue:[
- "
- (check-mark)
- "
- self drawCheckLine:lineString inVisibleLine:visLineNr with:fg and:bg
- ] ifFalse:[
- super drawLine:lineString inVisible:visLineNr with:fg and:bg.
- ].
+ "
+ some speciality in this line; try checkMark
+ "
+ ((self isCheckItem:lineString)
+ and:[self drawCheckLine:lineString inVisibleLine:visLineNr with:fg and:bg])
+ ifFalse:[
+ super drawLine:lineString inVisible:visLineNr with:fg and:bg.
+ ].
].
"/
@@ -1486,10 +1499,10 @@
((ShowAcceleratorKeys ~~ false)
and:[shortKeys notNil
and:[(key := shortKeys at:l ifAbsent:nil) notNil]]) ifTrue:[
- self drawAccelerator:key inVisibleLine:visLineNr with:fg and:bg
+ self drawAccelerator:key inVisibleLine:visLineNr with:fg and:bg
]
- "Modified: 2.3.1996 / 14:54:43 / cg"
+ "Modified: / 19.5.1998 / 21:59:07 / cg"
!
drawVisibleLineSelected:visLineNr with:fg and:bg
@@ -2686,5 +2699,5 @@
!MenuView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/MenuView.st,v 1.112 1998-01-29 11:59:11 ca Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/MenuView.st,v 1.113 1998-05-19 20:19:17 cg Exp $'
! !