"
COPYRIGHT (c) 2006 by eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
"{ Package: 'stx:libtool' }"
SimpleView subclass:#ViewWithAcceptAndCancelBar
instanceVariableNames:'slaveView bar reallyModifiedHolder acceptAction cancelAction'
classVariableNames:''
poolDictionaries:''
category:'Views-Basic'
!
SimpleView subclass:#AcceptAndCancelBar
instanceVariableNames:'acceptButton cancelButton'
classVariableNames:''
poolDictionaries:''
privateIn:ViewWithAcceptAndCancelBar
!
Button subclass:#ButtonWithHelpText
instanceVariableNames:'helpText'
classVariableNames:''
poolDictionaries:''
privateIn:ViewWithAcceptAndCancelBar::AcceptAndCancelBar
!
!ViewWithAcceptAndCancelBar class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 2006 by eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
!
documentation
"
experimental - self like accept/cancel bar in the browsers
code view.
Enable with:
UserPreferences current showAcceptCancelBarInBrowser:true
"
! !
!ViewWithAcceptAndCancelBar methodsFor:'accessing'!
accept
acceptAction value
!
acceptAction:something
acceptAction := something.
!
cancel
cancelAction value
!
cancelAction:something
cancelAction := something.
!
reallyModifiedHolder:aValueHolder
reallyModifiedHolder := aValueHolder.
reallyModifiedHolder addDependent:self.
! !
!ViewWithAcceptAndCancelBar methodsFor:'change & update'!
hideBar
bar unmap.
bar hiddenOnRealize:true.
slaveView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
!
showBar
slaveView origin:(20 @ 0.0) corner:(1.0 @ 1.0).
bar hiddenOnRealize:false.
bar realize.
!
update:something with:aParameter from:changedObject
slaveView notNil ifTrue:[
changedObject == reallyModifiedHolder ifTrue:[
self application
enqueueMessage:#updateBarVisibility
for:self arguments:#().
].
changedObject == slaveView modifiedChannel ifTrue:[
self application
enqueueMessage:#updateBarVisibility
for:self arguments:#().
].
].
super update:something with:aParameter from:changedObject
!
updateBarVisibility
|modified|
modified := reallyModifiedHolder notNil
ifTrue:[ reallyModifiedHolder value ]
ifFalse:[ slaveView modifiedChannel value ].
modified ifTrue:[
self showBar
] ifFalse:[
self hideBar
].
! !
!ViewWithAcceptAndCancelBar methodsFor:'initialization'!
initialize
super initialize.
bar := AcceptAndCancelBar in:self.
bar origin:(0.0 @ 0.0) corner:(20 @ 1.0).
bar hiddenOnRealize:true.
bar acceptButton action:[ self accept ].
bar cancelButton action:[ self cancel ].
acceptAction := [ slaveView notNil ifTrue:[ slaveView accept ] ].
cancelAction := [ ].
"
self new open
"
!
slaveView:aView
self add:aView.
slaveView := aView.
aView origin:(0.0@0.0) corner:(1.0@1.0).
aView modifiedChannel addDependent:self.
"
|v|
v := self new.
v slaveView:CodeView new.
v open
"
! !
!ViewWithAcceptAndCancelBar::AcceptAndCancelBar methodsFor:'accessing'!
acceptButton
^ acceptButton
!
cancelButton
^ cancelButton
!
flyByHelpTextAt:srcPoint
"return the helpText for aPoint (i.e. when mouse-pointer is moved over an item)."
(acceptButton bounds containsPoint:srcPoint) ifTrue:[
^ 'Accept'
].
(acceptButton bounds containsPoint:srcPoint) ifTrue:[
^ 'Cancel'
].
^ nil
! !
!ViewWithAcceptAndCancelBar::AcceptAndCancelBar methodsFor:'initialization'!
initialize
super initialize.
acceptButton := ButtonWithHelpText new.
acceptButton origin:0.0 @ 0.0 corner:1.0@0.80.
acceptButton backgroundColor:Color green.
acceptButton flyByHelpText:'Accept'.
self add:acceptButton.
cancelButton := ButtonWithHelpText new.
cancelButton origin:0.0 @ 0.80 corner:1.0@1.0.
cancelButton backgroundColor:Color red.
cancelButton flyByHelpText:'Cancel'.
self add:cancelButton.
"
AcceptAndCancelBar new open
"
! !
!ViewWithAcceptAndCancelBar::AcceptAndCancelBar::ButtonWithHelpText methodsFor:'accessing'!
flyByHelpText
^ helpText
!
flyByHelpText:something
helpText := something.
! !
!ViewWithAcceptAndCancelBar class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/libtool/ViewWithAcceptAndCancelBar.st,v 1.2 2006-04-24 11:44:46 cg Exp $'
! !