--- a/OptBox.st Mon Dec 20 18:24:24 1993 +0100
+++ b/OptBox.st Mon Dec 20 18:26:25 1993 +0100
@@ -22,7 +22,7 @@
COPYRIGHT (c) 1991 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libwidg/Attic/OptBox.st,v 1.4 1993-12-11 01:47:26 claus Exp $
+$Header: /cvs/stx/stx/libwidg/Attic/OptBox.st,v 1.5 1993-12-20 17:26:25 claus Exp $
written Nov 91 by claus
'!
@@ -55,20 +55,24 @@
!OptionBox methodsFor:'accessing'!
title:aString numberOfOptions:nOptions
- "set the title and number of options"
+ "set the boxes title and number of options"
- textLabel label:aString.
- textLabel resize.
+ aString ~= textLabel label ifTrue:[
+ textLabel label:aString.
+ textLabel resize.
+ ].
buttons grow:nOptions.
actions grow:nOptions
!
title:aString
- "set the title"
+ "set the boxes title"
- textLabel label:aString.
- textLabel resize.
- self resize
+ aString ~= textLabel label ifTrue:[
+ textLabel label:aString withoutSeparators.
+ textLabel resize.
+ self resize
+ ]
!
numberOfOptions:nOptions
@@ -92,6 +96,7 @@
index := 1.
titles do:[:aString |
(buttons at:index) label:aString.
+ (buttons at:index) resize.
index := index + 1
].
self resize
@@ -133,13 +138,13 @@
nButt := buttons size.
1 to:nButt do:[:index |
- |button|
+ |button|
button := Button label:'press'
action:[
- |action|
+ |action|
- (buttons at:index) turnOff.
+ (buttons at:index) turnOff.
self hide.
action := actions at:index.
action notNil ifTrue:[
@@ -152,13 +157,21 @@
@
(height - ViewSpacing - (buttons at:index) height)].
button extent:[(width // nButt - ViewSpacing)
- @
- (buttons at:index) height]
+ @
+ (buttons at:index) height]
]
! !
!OptionBox methodsFor:'private'!
+positionOffset
+ "return the delta, by which the box should be displayed
+ from the mouse pointer. Value returned here makes
+ okButton appear under the cursor"
+
+ ^ (buttons last originRelativeTo:self) + (buttons last extent // 2)
+!
+
resize
"resize myself to make everything fit into myself"
@@ -180,7 +193,6 @@
+ (buttons at:1) height
+ ViewSpacing.
- extra := margin * 2.
- super extent:(w + extra) @ (h + extra)
+ "extra := margin * 2."
+ super extent:(w "+ extra") @ (h "+ extra")
! !
-