initial checkin
authorClaus Gittinger <cg@exept.de>
Fri, 21 Apr 2006 17:38:32 +0200
changeset 6772 07a067c578d5
parent 6771 874265f4e70a
child 6773 02e2c886707e
initial checkin
ViewWithAcceptAndCancelBar.st
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ViewWithAcceptAndCancelBar.st	Fri Apr 21 17:38:32 2006 +0200
@@ -0,0 +1,191 @@
+"
+ 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
+!
+
+!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).
+!
+
+showBar
+    slaveView origin:(20 @ 0.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
+! !
+
+!ViewWithAcceptAndCancelBar::AcceptAndCancelBar methodsFor:'initialization'!
+
+initialize
+    super initialize.
+
+    acceptButton := Button new.
+    acceptButton origin:0.0 @ 0.0 corner:1.0@0.75.
+    acceptButton backgroundColor:Color green.
+    self add:acceptButton.
+
+    cancelButton := Button new.
+    cancelButton origin:0.0 @ 0.75 corner:1.0@1.0.
+    cancelButton backgroundColor:Color red.
+    self add:cancelButton.
+
+    "
+     AcceptAndCancelBar new open
+    "
+! !
+
+!ViewWithAcceptAndCancelBar class methodsFor:'documentation'!
+
+version
+    ^ '$Header: /cvs/stx/stx/libtool/ViewWithAcceptAndCancelBar.st,v 1.1 2006-04-21 15:38:32 cg Exp $'
+! !