home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BURKS 2
/
BURKS_AUG97.ISO
/
BURKS
/
LANGUAGE
/
SMALTALK
/
TEXTBOOK
/
AP01.ST
(
.txt
)
< prev
next >
Wrap
Text File
|
1997-04-22
|
8KB
|
312 lines
'Smalltalk Textbook Appendix 01'!
CompositePart subclass: #EngiTopView
instanceVariableNames: 'model label extent '
classVariableNames: ''
poolDictionaries: ''
category: 'Engi-Interface'!
EngiTopView comment:
'
Engi 0.01 (10 January 1994)
Copyright (C) 1994 by Atsushi Aoki
'!
!EngiTopView methodsFor: 'accessing'!
label
^label!
label: aString
label := aString.
self topComponent isNil ifFalse: [self topComponent label: aString]!
minimumSize
^extent!
minimumSize: aPoint
extent := aPoint.
self topComponent isNil ifFalse: [self topComponent minimumSize: aPoint]!
model
^model!
model: aModel
model := aModel.
self topComponent isNil ifFalse: [self topComponent model: aModel]! !
!EngiTopView methodsFor: 'scheduling'!
close
self topComponent isNil ifFalse: [self topComponent close]!
open
| topWindow |
topWindow := ScheduledWindow
model: model
label: label
minimumSize: extent.
topWindow component: self.
topWindow open!
popUp
^self
popUp: true
trueLabel: 'accept'
falseLabel: 'cancel'!
popUp: aBooleanOrNil label: labelString
| topWindow compositePart aModel trueButton aRectangle |
topWindow := ScheduledWindow
model: model
label: label
minimumSize: extent.
topWindow controller: EngiTopPreemptor new.
compositePart := CompositePart new.
aModel := ValueHolder new.
trueButton := Button trigger.
aBooleanOrNil = true ifTrue: [trueButton beDefault].
trueButton label: labelString.
trueButton model: ((PluggableAdaptor on: aModel)
getBlock: [:m | false]
putBlock:
[:m :v |
aModel value: true.
self close]
updateBlock: [:m :a :v | false]).
compositePart add: self in: (self frameFraction: (0 @ 0 corner: 1 @ 1)
offset: (0 @ 0 corner: 0 @ -40)).
compositePart add: trueButton in: (self frameFraction: (0.5 @ 1 corner: 0.5 @ 1)
offset: (-40 @ -35 corner: 40 @ -5)).
topWindow component: compositePart.
aRectangle := Point zero extent: (topWindow minimumSize max: self defaultPopUpMinimumSize).
aRectangle := aRectangle align: aRectangle center with: InputState default mousePoint.
topWindow openDialogIn: aRectangle.
^aModel value!
popUp: aBooleanOrNil trueLabel: trueString falseLabel: falseString
| topWindow compositePart aModel trueButton falseButton aRectangle |
topWindow := ScheduledWindow
model: model
label: label
minimumSize: extent.
topWindow controller: EngiTopPreemptor new.
compositePart := CompositePart new.
aModel := ValueHolder new.
trueButton := Button trigger.
aBooleanOrNil = true ifTrue: [trueButton beDefault].
trueButton label: trueString.
trueButton model: ((PluggableAdaptor on: aModel)
getBlock: [:m | false]
putBlock:
[:m :v |
aModel value: true.
self close]
updateBlock: [:m :a :v | false]).
falseButton := Button trigger.
aBooleanOrNil = false ifTrue: [falseButton beDefault].
falseButton label: falseString.
falseButton model: ((PluggableAdaptor on: aModel)
getBlock: [:m | false]
putBlock:
[:m :v |
aModel value: false.
self close]
updateBlock: [:m :a :v | false]).
compositePart add: self in: (self frameFraction: (0 @ 0 corner: 1 @ 1)
offset: (0 @ 0 corner: 0 @ -40)).
compositePart add: trueButton in: (self frameFraction: (0.3 @ 1 corner: 0.3 @ 1)
offset: (-40 @ -35 corner: 40 @ -5)).
compositePart add: falseButton in: (self frameFraction: (0.7 @ 1 corner: 0.7 @ 1)
offset: (-40 @ -35 corner: 40 @ -5)).
topWindow component: compositePart.
aRectangle := Point zero extent: (topWindow minimumSize max: self defaultPopUpMinimumSize).
aRectangle := aRectangle align: aRectangle center with: InputState default mousePoint.
topWindow openDialogIn: aRectangle.
^aModel value!
popUpAcceptCancel: aBooleanOrNil
^self
popUp: aBooleanOrNil
trueLabel: 'accept'
falseLabel: 'cancel'!
popUpOkay: aBooleanOrNil
^self popUp: aBooleanOrNil label: 'okay'!
popUpYesNo: aBooleanOrNil
^self
popUp: aBooleanOrNil
trueLabel: 'yes'
falseLabel: 'no'! !
!EngiTopView methodsFor: 'framing'!
frameFraction: fractionRectangle
^self class frameFraction: fractionRectangle!
frameFraction: fractionRectangle offset: offsetRectangle
^self class frameFraction: fractionRectangle offset: offsetRectangle!
frameFractionOffset: offsetRectangle
^self class frameOffset: offsetRectangle! !
!EngiTopView methodsFor: 'defaults'!
defaultPopUpMinimumSize
^250 @ 100! !
!EngiTopView methodsFor: 'private'!
model: aModel label: labelText minimumSize: minimumSize
model := aModel.
label := labelText.
extent := minimumSize.
^self! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
EngiTopView class
instanceVariableNames: ''!
!EngiTopView class methodsFor: 'instance creation'!
model: aModel label: labelString minimumSize: minimumSize
^super new
model: aModel
label: labelString
minimumSize: minimumSize!
new
^self
model: nil
label: nil
minimumSize: 100 @ 100! !
!EngiTopView class methodsFor: 'framing'!
frameFraction: fractionRectangle
^self frameFraction: fractionRectangle offset: (0 @ 0 corner: 0 @ 0)!
frameFraction: fractionRectangle offset: offsetRectangle
^LayoutFrame
leftFraction: fractionRectangle left
offset: offsetRectangle left
rightFraction: fractionRectangle right
offset: offsetRectangle right
topFraction: fractionRectangle top
offset: offsetRectangle top
bottomFraction: fractionRectangle bottom
offset: offsetRectangle bottom!
frameOffset: offsetRectangle
^self frameFraction: (0 @ 0 corner: 0 @ 0)
offset: offsetRectangle! !
!EngiTopView class methodsFor: 'examples'!
example1
"EngiTopView example1."
| topView edgeDecorator1 edgeDecorator2 |
topView := EngiTopView
model: nil
label: 'TopView'
minimumSize: 250 @ 250.
edgeDecorator1 := LookPreferences edgeDecorator on: View new.
edgeDecorator1 noMenuBar.
edgeDecorator1 noVerticalScrollBar.
edgeDecorator1 noHorizontalScrollBar.
edgeDecorator2 := LookPreferences edgeDecorator on: View new.
edgeDecorator2 noMenuBar.
edgeDecorator2 noVerticalScrollBar.
edgeDecorator2 noHorizontalScrollBar.
topView add: edgeDecorator1 in: (0 @ 0 corner: 1 @ 0.5).
topView add: edgeDecorator2 in: (0 @ 0.5 corner: 1 @ 1).
topView open!
example2
"EngiTopView example2."
| topView edgeDecorator1 edgeDecorator2 aBoolan |
topView := EngiTopView new.
topView minimumSize: 250 @ 290.
edgeDecorator1 := LookPreferences edgeDecorator on: View new.
edgeDecorator1 noMenuBar.
edgeDecorator1 noVerticalScrollBar.
edgeDecorator1 noHorizontalScrollBar.
edgeDecorator2 := LookPreferences edgeDecorator on: View new.
edgeDecorator2 noMenuBar.
edgeDecorator2 noVerticalScrollBar.
edgeDecorator2 noHorizontalScrollBar.
topView add: edgeDecorator1 in: (0 @ 0 corner: 1 @ 0.5).
topView add: edgeDecorator2 in: (0 @ 0.5 corner: 1 @ 1).
aBoolan := topView popUp.
^aBoolan!
example3
"EngiTopView example3."
EngiTopView new popUpAcceptCancel: true.
EngiTopView new popUpAcceptCancel: nil.
EngiTopView new popUpAcceptCancel: false.
EngiTopView new popUpYesNo: true.
EngiTopView new popUpYesNo: nil.
EngiTopView new popUpYesNo: false.
EngiTopView new
popUp: true
trueLabel: 'agree'
falseLabel: 'retract'.
EngiTopView new popUpOkay: true.
EngiTopView new popUpOkay: nil.
EngiTopView new popUp: true label: 'I see'! !
StandardSystemController subclass: #EngiTopPreemptor
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Engi-Interface'!
EngiTopPreemptor comment:
'
Engi 0.01 (10 January 1994)
Copyright (C) 1994 by Atsushi Aoki
'!
!EngiTopPreemptor methodsFor: 'accessing'!
restartAfterError
self locked: false!
shutdownBecauseOfError
self locked: true! !
!EngiTopPreemptor methodsFor: 'control defaults'!
controlActivity
^self controlToNextLevel!
controlInitialize
self locked: false.
super controlInitialize!
controlTerminate
self locked: true.
super controlTerminate!
isControlActive
^true! !