Popupmenu Hack
Stefan Matthias Aust
sma at baltic-online.de
Mon May 29 11:42:37 UTC 2000
Not really useful for anything, the attached code will add transparency
to MVC popup menus. This was just the result to a test whether it could
be done. Obviously, it could :-)
bye
--
Stefan Matthias Aust Projektleiter/Softwareentwicklung
Baltic Online Computer GmbH, Alter Markt 1-2, 24103 Kiel
Fon: +49 (0) 431-54003-0 Fax: -99 http://www.baltic-online.de
-------------- next part --------------
'From Squeak2.8alpha of 4 February 2000 [latest update: #2158] on 26 May 2000 at 4:10:38 pm'!
!PopUpMenu methodsFor: 'displaying' stamp: 'sma 5/26/2000 10:28'!
displayAt: aPoint withCaption: captionOrNil during: aBlock
"Display the receiver just to the right of aPoint while aBlock is evaluated. If the receiver is forced off screen, display it just to the right."
| delta savedArea captionForm captionSave outerFrame captionText tFrame frameSaveLoc captionBox |
marker ifNil: [self computeForm].
frame _ frame align: marker leftCenter with: aPoint + (2 at 0).
outerFrame _ frame.
captionOrNil notNil ifTrue:
[captionText _ (DisplayText
text: captionOrNil asText
textStyle: MenuStyle copy centered)
foregroundColor: Color black
backgroundColor: Color white.
tFrame _ captionText boundingBox insetBy: -2.
outerFrame _ frame merge: (tFrame align: tFrame bottomCenter
with: frame topCenter + (0 at 2))].
delta _ outerFrame amountToTranslateWithin: Display boundingBox.
frame right > Display boundingBox right
ifTrue: [delta _ 0 - frame width @ delta y].
frame _ frame translateBy: delta.
captionOrNil notNil ifTrue:
[captionForm _ captionText form.
captionBox _ captionForm boundingBox expandBy: 4.
captionBox _ captionBox align: captionBox bottomCenter
with: frame topCenter + (0 at 2).
captionSave _ Form fromDisplay: captionBox.
Display border: captionBox width: 4 fillColor: Color white.
Display border: captionBox width: 2 fillColor: Color black.
captionForm displayAt: captionBox topLeft + 4].
marker _ marker align: marker leftCenter with: aPoint + delta + (2 at 0).
savedArea _ Form fromDisplay: frame.
self menuForm displayOn: Display at: (frameSaveLoc _ frame topLeft) rule: Form blend.
"Display slideImage: self menuForm at: (frameSaveLoc _ frame topLeft) delta: 3 at 4."
selection ~= 0 ifTrue: [Display reverse: marker].
Cursor normal showWhile: [aBlock value].
savedArea displayOn: Display at: frameSaveLoc.
captionOrNil notNil ifTrue:
[captionSave displayOn: Display at: captionBox topLeft]! !
!PopUpMenu methodsFor: 'private' stamp: 'sma 5/26/2000 10:21'!
computeForm
"Compute and answer a Form to be displayed for this menu."
| borderInset paraForm menuForm inside |
borderInset _ 4 at 4.
paraForm _ (DisplayText text: labelString asText textStyle: MenuStyle) form.
menuForm _ Form extent: paraForm extent + (borderInset * 2) depth: Display depth.
menuForm fillColor: (Color white alpha: 0.8).
menuForm border: (0 at 0 extent: menuForm extent) width: 1.
paraForm displayOn: menuForm at: borderInset rule: 25.
lineArray == nil ifFalse:
[lineArray do:
[ :line |
menuForm fillBlack:
(2 @ ((line * font height) + borderInset y) extent: (menuForm width - 4 @ 1))]].
frame _ Quadrangle new.
frame region: menuForm boundingBox.
frame borderWidth: 4.
inside _ frame inside.
marker _ inside topLeft extent: (inside width @ MenuStyle lineGrid).
selection _ 1.
^ form _ menuForm
! !
More information about the Squeak-dev
mailing list
|