Model.st
changeset 163 80f4fe3bcc71
parent 153 0a44627e1712
child 188 38e92ed0e1b9
equal deleted inserted replaced
162:cbbd2f3422a3 163:80f4fe3bcc71
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
    12 
    13 Object subclass:#Model
    13 Object subclass:#Model
    14 	 instanceVariableNames:'dependents'
    14 	instanceVariableNames:'dependents'
    15 	 classVariableNames:''
    15 	classVariableNames:''
    16 	 poolDictionaries:''
    16 	poolDictionaries:''
    17 	 category:'Interface-Support-Models'
    17 	category:'Interface-Support-Models'
    18 !
    18 !
    19 
    19 
    20 !Model class methodsFor:'documentation'!
    20 !Model class methodsFor:'documentation'!
    21 
    21 
    22 copyright
    22 copyright
    64 addDependent:anObject
    64 addDependent:anObject
    65     "make the argument, anObject be a dependent of the receiver"
    65     "make the argument, anObject be a dependent of the receiver"
    66 
    66 
    67     |deps|
    67     |deps|
    68 
    68 
    69     deps := dependents.
    69     [
    70     (deps isNil and:[anObject isCollection not]) ifTrue:[
    70         deps := dependents.
    71 	dependents := anObject
    71         (deps isNil and:[anObject isCollection not]) ifTrue:[
    72     ] ifFalse:[
    72             dependents := anObject
    73 	deps isCollection ifTrue:[
    73         ] ifFalse:[
    74 	    deps add:anObject
    74             deps isCollection ifTrue:[
    75 	] ifFalse:[
    75                 deps add:anObject
    76 	    dependents := IdentitySet with:dependents with:anObject
    76             ] ifFalse:[
    77 	]
    77                 dependents := IdentitySet with:dependents with:anObject
    78     ]
    78             ]
       
    79         ]
       
    80     ] valueUninterruptably
       
    81 
       
    82     "Modified: 20.2.1996 / 19:22:53 / cg"
    79 !
    83 !
    80 
    84 
    81 dependents
    85 dependents
    82     "return a Collection of dependents - nil if there is none"
    86     "return a Collection of dependents - nil if there is none"
    83 
    87 
   112 removeDependent:anObject
   116 removeDependent:anObject
   113     "make the argument, anObject be independent of the receiver"
   117     "make the argument, anObject be independent of the receiver"
   114 
   118 
   115     |deps sz|
   119     |deps sz|
   116 
   120 
   117     deps := dependents.
   121     [
   118     deps notNil ifTrue:[
   122         deps := dependents.
   119 	deps isCollection ifTrue:[
   123         deps notNil ifTrue:[
   120 	    deps remove:anObject ifAbsent:[].
   124             deps isCollection ifTrue:[
   121 	    (sz := deps size) == 0 ifTrue:[
   125                 deps remove:anObject ifAbsent:[].
   122 		dependents := nil
   126                 (sz := deps size) == 0 ifTrue:[
   123 	    ]
   127                     dependents := nil
   124 	] ifFalse:[
   128                 ]
   125 	    dependents := nil
   129             ] ifFalse:[
   126 	]
   130                 dependents := nil
   127     ]
   131             ]
       
   132         ]
       
   133     ] valueUninterruptably
       
   134 
       
   135     "Modified: 20.2.1996 / 19:23:26 / cg"
   128 ! !
   136 ! !
   129 
   137 
   130 !Model methodsFor:'drawing'!
   138 !Model methodsFor:'drawing'!
   131 
   139 
   132 displayOn:aGraphicsContext
   140 displayOn:aGraphicsContext
   142 ! !
   150 ! !
   143 
   151 
   144 !Model class methodsFor:'documentation'!
   152 !Model class methodsFor:'documentation'!
   145 
   153 
   146 version
   154 version
   147     ^ '$Header: /cvs/stx/stx/libview2/Model.st,v 1.18 1996-01-15 17:37:08 cg Exp $'
   155     ^ '$Header: /cvs/stx/stx/libview2/Model.st,v 1.19 1996-02-20 18:24:36 cg Exp $'
   148 ! !
   156 ! !