BlockValue.st
author Claus Gittinger <cg@exept.de>
Sun, 23 Nov 2014 14:42:46 +0100
changeset 3398 27762e2393d8
parent 3349 ffebc3c4e212
child 3474 9e58c4c4dedb
permissions -rw-r--r--
class: MIMETypeIconLibrary added: #flushIcons comment/format in: #fileTypeIconKeyFor:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
158
16f2237474fe only init once
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
     3
	      All Rights Reserved
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
1665
096ca1b11ce1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1352
diff changeset
    12
"{ Package: 'stx:libview2' }"
096ca1b11ce1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1352
diff changeset
    13
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
ValueModel subclass:#BlockValue
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
	instanceVariableNames:'cachedValue arguments block'
146
9603cec98ac2 oops change notification was wrong
Claus Gittinger <cg@exept.de>
parents: 145
diff changeset
    16
	classVariableNames:'NeverComputed'
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	category:'Interface-Support-Models'
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!BlockValue class methodsFor:'documentation'!
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
copyright
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
"
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
 COPYRIGHT (c) 1995 by Claus Gittinger
158
16f2237474fe only init once
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
    26
	      All Rights Reserved
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
 This software is furnished under a license and may be used
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 only in accordance with the terms of that license and with the
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 be provided or otherwise made available to, or used by, any
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 other person.  No title to or ownership of the software is
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 hereby transferred.
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
"
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
!
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
documentation
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
"
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
    BlockValues depend on multiple other objects (typically valueHolders)
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    and recompute a value whenever one of them changes.
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    If the new value is different, it triggers itself a change to its dependents.
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    Example use is to base an enableChannels value on multiple other boolean values.
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    (See example for how this is done)
223
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    46
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    47
    Notice: 
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    48
        this class was implemented using protocol information
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    49
        from alpha testers - it may not be complete or compatible to
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    50
        the corresponding ST-80 class. 
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    51
        If you encounter any incompatibilities, please forward a note 
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    52
        describing the incompatibility verbal (i.e. no code) to the ST/X team.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    53
2760
653b3c3fd7a7 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 2530
diff changeset
    54
    Warning:
653b3c3fd7a7 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 2530
diff changeset
    55
        BlockValues only work ine one direction; changing the blockValue's value
653b3c3fd7a7 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 2530
diff changeset
    56
        does not affect the original model's value.
653b3c3fd7a7 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 2530
diff changeset
    57
223
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    58
    [author:]
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    59
        Claus Gittinger
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
"
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
!
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
examples
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
"
155
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
    65
    checkToggle 3 shows the value of toggle1 AND toggle2
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    66
                                                                        [exBegin]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    67
        |val1 val2 both box|
155
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
    68
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    69
        val1 := false asValue.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    70
        val2 := false asValue.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    71
        both := BlockValue 
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    72
                    with:[:v1 :v2 | 
268
1998023f12dc showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
    73
                            Transcript showCR:'evaluating ...'.
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    74
                            v1 value and:[v2 value]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    75
                         ] 
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    76
                    arguments:(Array with:val1 with:val2).
155
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
    77
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    78
        box := Dialog new.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    79
        box addCheckBox:'one' on:val1.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    80
        box addCheckBox:'two' on:val2.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    81
        box addHorizontalLine.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    82
        box addCheckBox:'both' on:both.
911
97b17322f0fb fixed logicalOrAll / locicalAndAll:
ca
parents: 606
diff changeset
    83
        box addOkButton.
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    84
        box open
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    85
                                                                        [exEnd]
155
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
    86
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
    87
    the same, using a convenient instance creation message:
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    88
                                                                        [exBegin]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    89
        |val1 val2 both box|
155
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
    90
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    91
        val1 := false asValue.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    92
        val2 := false asValue.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    93
        both := BlockValue forLogical:val1 and:val2.
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    95
        box := Dialog new.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    96
        box addCheckBox:'one' on:val1.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    97
        box addCheckBox:'two' on:val2.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    98
        box addHorizontalLine.
911
97b17322f0fb fixed logicalOrAll / locicalAndAll:
ca
parents: 606
diff changeset
    99
        (box addCheckBox:'both' on:both) disable.
97b17322f0fb fixed logicalOrAll / locicalAndAll:
ca
parents: 606
diff changeset
   100
        box addOkButton.
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   101
        box open
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   102
                                                                        [exEnd]
155
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
   103
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
   104
    logical or:
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   105
                                                                        [exBegin]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   106
        |val1 val2 both box|
155
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
   107
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   108
        val1 := false asValue.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   109
        val2 := false asValue.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   110
        both := BlockValue forLogical:val1 or:val2.
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   112
        box := Dialog new.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   113
        box addCheckBox:'one' on:val1.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   114
        box addCheckBox:'two' on:val2.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   115
        box addHorizontalLine.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   116
        box addCheckBox:'both' on:both.
911
97b17322f0fb fixed logicalOrAll / locicalAndAll:
ca
parents: 606
diff changeset
   117
        box addOkButton.
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   118
        box open
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   119
                                                                        [exEnd]
155
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
   120
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
   121
    example use: enabling an element depending on two others:
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   122
                                                                        [exBegin]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   123
        |val1 val2 enabler val3 box|
155
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
   124
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   125
        val1 := false asValue.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   126
        val2 := false asValue.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   127
        val3 := false asValue.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   128
        enabler := BlockValue forLogical:val1 and:val2.
155
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
   129
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   130
        box := Dialog new.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   131
        box addCheckBox:'one' on:val1.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   132
        box addCheckBox:'two' on:val2.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   133
        box addHorizontalLine.
911
97b17322f0fb fixed logicalOrAll / locicalAndAll:
ca
parents: 606
diff changeset
   134
        (box addCheckBox:'three (both of the above)' on:val3) enableChannel:enabler.
97b17322f0fb fixed logicalOrAll / locicalAndAll:
ca
parents: 606
diff changeset
   135
        box addOkButton.
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   136
        box open
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   137
                                                                        [exEnd]
382
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   138
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   139
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   140
    like above, using a logical-or block:
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   141
                                                                        [exBegin]
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   142
        |val1 val2 enabler val3 box|
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   143
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   144
        val1 := false asValue.
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   145
        val2 := false asValue.
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   146
        val3 := false asValue.
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   147
        enabler := BlockValue forLogical:val1 or:val2.
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   148
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   149
        box := Dialog new.
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   150
        box addCheckBox:'one' on:val1.
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   151
        box addCheckBox:'two' on:val2.
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   152
        box addHorizontalLine.
911
97b17322f0fb fixed logicalOrAll / locicalAndAll:
ca
parents: 606
diff changeset
   153
        (box addCheckBox:'three (any of the above)' on:val3) enableChannel:enabler.
97b17322f0fb fixed logicalOrAll / locicalAndAll:
ca
parents: 606
diff changeset
   154
        box addOkButton.
382
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   155
        box open
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   156
                                                                        [exEnd]
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   157
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   158
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   159
    like above, using a bunch of toggles:
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   160
                                                                        [exBegin]
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   161
        |values anyValue box|
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   162
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   163
        values := (1 to:10) collect:[:i | false asValue].
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   164
        anyValue := BlockValue forLogicalOrAll:values.
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   165
        anyValue onChangeSend:#value to:[Transcript showCR:'any is true'].
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   166
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   167
        box := Dialog new.
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   168
        values keysAndValuesDo:[:index :aValueHolder |
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   169
            box addCheckBox:index printString on:aValueHolder.
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   170
        ].
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   171
        box addHorizontalLine.
911
97b17322f0fb fixed logicalOrAll / locicalAndAll:
ca
parents: 606
diff changeset
   172
        (box addOkButton) enableChannel:anyValue.
382
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   173
        box open
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   174
                                                                        [exEnd]
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
"
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
! !
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
146
9603cec98ac2 oops change notification was wrong
Claus Gittinger <cg@exept.de>
parents: 145
diff changeset
   178
!BlockValue class methodsFor:'initialization'!
9603cec98ac2 oops change notification was wrong
Claus Gittinger <cg@exept.de>
parents: 145
diff changeset
   179
9603cec98ac2 oops change notification was wrong
Claus Gittinger <cg@exept.de>
parents: 145
diff changeset
   180
initialize
158
16f2237474fe only init once
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   181
    NeverComputed isNil ifTrue:[
16f2237474fe only init once
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   182
	NeverComputed := Object new.
16f2237474fe only init once
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   183
    ]
146
9603cec98ac2 oops change notification was wrong
Claus Gittinger <cg@exept.de>
parents: 145
diff changeset
   184
! !
9603cec98ac2 oops change notification was wrong
Claus Gittinger <cg@exept.de>
parents: 145
diff changeset
   185
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
!BlockValue class methodsFor:'instance creation'!
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
979
cd28a5d673c9 added #block:arguments: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
   188
block:aBlock arguments:aCollectionOfArguments
cd28a5d673c9 added #block:arguments: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
   189
    "return a new BlockValue computing aBlock.
cd28a5d673c9 added #block:arguments: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
   190
     Same as #with:arguments: for ST80 compatibility"
cd28a5d673c9 added #block:arguments: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
   191
cd28a5d673c9 added #block:arguments: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
   192
    ^ self with:aBlock arguments:aCollectionOfArguments
cd28a5d673c9 added #block:arguments: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
   193
cd28a5d673c9 added #block:arguments: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
   194
    "Created: / 20.6.1998 / 14:00:16 / cg"
cd28a5d673c9 added #block:arguments: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
   195
!
cd28a5d673c9 added #block:arguments: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
   196
155
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
   197
forLogical:arg1 and:arg2
1326
1ee8b02dd6ab comments
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
   198
    "return a new BlockValue computing the logical AND of its args
1ee8b02dd6ab comments
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
   199
     (which are usually other valueHolders)"
155
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
   200
1815
5f6fb98a3479 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1788
diff changeset
   201
    ^ (self new) 
1326
1ee8b02dd6ab comments
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
   202
        setBlock:[:a :b | a value and:[b value]]
1ee8b02dd6ab comments
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
   203
        arguments:(Array with:arg1 with:arg2)
155
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
   204
1326
1ee8b02dd6ab comments
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
   205
    "Created: / 16.12.1995 / 19:20:14 / cg"
1ee8b02dd6ab comments
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
   206
    "Modified: / 30.1.2000 / 23:24:50 / cg"
155
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
   207
!
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
   208
2800
Claus Gittinger <cg@exept.de>
parents: 2760
diff changeset
   209
forLogical:arg1 and:arg2 and:arg3
Claus Gittinger <cg@exept.de>
parents: 2760
diff changeset
   210
    "return a new BlockValue computing the logical AND of its args
Claus Gittinger <cg@exept.de>
parents: 2760
diff changeset
   211
     (which are usually other valueHolders)"
Claus Gittinger <cg@exept.de>
parents: 2760
diff changeset
   212
Claus Gittinger <cg@exept.de>
parents: 2760
diff changeset
   213
    ^ (self new) 
Claus Gittinger <cg@exept.de>
parents: 2760
diff changeset
   214
        setBlock:[:a :b :c | a value and:[b value and:[c value]]]
Claus Gittinger <cg@exept.de>
parents: 2760
diff changeset
   215
        arguments:(Array with:arg1 with:arg2 with:arg3)
Claus Gittinger <cg@exept.de>
parents: 2760
diff changeset
   216
!
Claus Gittinger <cg@exept.de>
parents: 2760
diff changeset
   217
155
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
   218
forLogical:arg1 or:arg2
1326
1ee8b02dd6ab comments
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
   219
    "return a new BlockValue computing the logical OR of its args
1ee8b02dd6ab comments
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
   220
     (which are usually other valueHolders)"
155
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
   221
1815
5f6fb98a3479 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1788
diff changeset
   222
    ^ (self new) 
1326
1ee8b02dd6ab comments
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
   223
        setBlock:[:a :b | a value or:[b value]]
1ee8b02dd6ab comments
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
   224
        arguments:(Array with:arg1 with:arg2)
155
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
   225
1326
1ee8b02dd6ab comments
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
   226
    "Created: / 16.12.1995 / 19:20:14 / cg"
1ee8b02dd6ab comments
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
   227
    "Modified: / 30.1.2000 / 23:24:46 / cg"
155
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
   228
!
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
   229
2800
Claus Gittinger <cg@exept.de>
parents: 2760
diff changeset
   230
forLogical:arg1 or:arg2 or:arg3
Claus Gittinger <cg@exept.de>
parents: 2760
diff changeset
   231
    "return a new BlockValue computing the logical OR of its args
Claus Gittinger <cg@exept.de>
parents: 2760
diff changeset
   232
     (which are usually other valueHolders)"
Claus Gittinger <cg@exept.de>
parents: 2760
diff changeset
   233
Claus Gittinger <cg@exept.de>
parents: 2760
diff changeset
   234
    ^ (self new) 
Claus Gittinger <cg@exept.de>
parents: 2760
diff changeset
   235
        setBlock:[:a :b :c | a value or:[b value or:[c value]]]
Claus Gittinger <cg@exept.de>
parents: 2760
diff changeset
   236
        arguments:(Array with:arg1 with:arg2 with:arg3)
Claus Gittinger <cg@exept.de>
parents: 2760
diff changeset
   237
!
Claus Gittinger <cg@exept.de>
parents: 2760
diff changeset
   238
382
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   239
forLogicalAndAll:argArray
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   240
    "return a new BlockValue computing the logical OR of all elements
1326
1ee8b02dd6ab comments
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
   241
     in the passed argArray (which are usually other valueHolders)"
382
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   242
1815
5f6fb98a3479 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1788
diff changeset
   243
    ^ (self new) 
382
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   244
        setBlock:[:a | (argArray findFirst:[:a | a value not]) == 0]
911
97b17322f0fb fixed logicalOrAll / locicalAndAll:
ca
parents: 606
diff changeset
   245
        argumentArray:argArray asArray
382
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   246
911
97b17322f0fb fixed logicalOrAll / locicalAndAll:
ca
parents: 606
diff changeset
   247
    "Created: / 22.1.1997 / 19:12:44 / cg"
97b17322f0fb fixed logicalOrAll / locicalAndAll:
ca
parents: 606
diff changeset
   248
    "Modified: / 28.4.1998 / 20:16:38 / ca"
1326
1ee8b02dd6ab comments
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
   249
    "Modified: / 30.1.2000 / 23:24:40 / cg"
382
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   250
!
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   251
1045
c501e3553048 added #forLogicalNot:
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   252
forLogicalNot:arg
1326
1ee8b02dd6ab comments
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
   253
    "return a new BlockValue computing the logical NOT of its arg 
1ee8b02dd6ab comments
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
   254
     (which is usually another valueHolder)"
1045
c501e3553048 added #forLogicalNot:
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   255
1815
5f6fb98a3479 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1788
diff changeset
   256
    ^ (self new) 
1045
c501e3553048 added #forLogicalNot:
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   257
        setBlock:[:a | a value not]
c501e3553048 added #forLogicalNot:
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   258
        arguments:(Array with:arg)
c501e3553048 added #forLogicalNot:
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   259
3349
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   260
    "
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   261
        |v1 v2|
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   262
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   263
        v1 := ValueHolder new.
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   264
        v1 value:true.
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   265
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   266
        v2 := BlockValue forLogicalNot:v1.
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   267
        v2 onChangeEvaluate:[ Transcript showCR:v2 value].
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   268
        Transcript showCR:v2 value.         'shows a false already'. 
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   269
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   270
        v1 value:true.                      'no change signalled here'.
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   271
        v1 value:false.
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   272
        v1 value:true.
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   273
    "
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   274
1045
c501e3553048 added #forLogicalNot:
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   275
    "Created: / 17.8.1998 / 10:06:41 / cg"
1326
1ee8b02dd6ab comments
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
   276
    "Modified: / 30.1.2000 / 23:24:18 / cg"
1045
c501e3553048 added #forLogicalNot:
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   277
!
c501e3553048 added #forLogicalNot:
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   278
382
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   279
forLogicalOrAll:argArray
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   280
    "return a new BlockValue computing the logical OR of all elements
1326
1ee8b02dd6ab comments
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
   281
     in the passed argArray (which are usually other valueHolders)"
382
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   282
1815
5f6fb98a3479 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1788
diff changeset
   283
    ^ (self new) 
606
8a8b36a9e67d removed debugHalt
Claus Gittinger <cg@exept.de>
parents: 491
diff changeset
   284
        setBlock:[:arg | (arg findFirst:[:el | el value]) ~~ 0]
911
97b17322f0fb fixed logicalOrAll / locicalAndAll:
ca
parents: 606
diff changeset
   285
        argumentArray:argArray asArray
382
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   286
911
97b17322f0fb fixed logicalOrAll / locicalAndAll:
ca
parents: 606
diff changeset
   287
    "Created: / 22.1.1997 / 19:13:01 / cg"
97b17322f0fb fixed logicalOrAll / locicalAndAll:
ca
parents: 606
diff changeset
   288
    "Modified: / 28.4.1998 / 20:20:09 / ca"
1326
1ee8b02dd6ab comments
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
   289
    "Modified: / 30.1.2000 / 23:24:34 / cg"
382
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   290
!
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   291
3349
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   292
forValue:someValue equalTo:someConstant
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   293
    "return a new BlockValue generating a true, 
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   294
     if someValue (usually another holder) contains a value equal to someConstant.
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   295
     Useful, if the other valueHolder is a radioButton group model,
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   296
     and you want to automatically enable/disable other items based on the value
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   297
     (i.e. via the enableChannel)"
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   298
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   299
    ^ (self new) 
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   300
        setBlock:[:a | a = someConstant]
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   301
        arguments:(Array with:someValue)
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   302
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   303
    "
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   304
        |v1 v2|
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   305
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   306
        v1 := ValueHolder new.
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   307
        v1 value:'blah'.
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   308
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   309
        v2 := BlockValue forValue:v1 equalTo:'hello'.
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   310
        v2 onChangeEvaluate:[ Transcript showCR:v2 value].
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   311
        Transcript showCR:v2 value.         'shows a false already'. 
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   312
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   313
        v1 value:'blah'.                      'no change signalled here'.
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   314
        v1 value:'oops'.                      'remains false'.
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   315
        v1 value:'hello'.                     'changes to true'.
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   316
        v2 value      
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   317
    "
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   318
!
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   319
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
with:aBlock
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
    "return a new BlockValue computing aBlock"
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
1815
5f6fb98a3479 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1788
diff changeset
   323
    ^ (self new) setBlock:aBlock
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
    "Created: 16.12.1995 / 19:16:33 / cg"
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
!
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
146
9603cec98ac2 oops change notification was wrong
Claus Gittinger <cg@exept.de>
parents: 145
diff changeset
   328
with:aBlock argument:anArgument
9603cec98ac2 oops change notification was wrong
Claus Gittinger <cg@exept.de>
parents: 145
diff changeset
   329
    "return a new BlockValue computing aBlock"
9603cec98ac2 oops change notification was wrong
Claus Gittinger <cg@exept.de>
parents: 145
diff changeset
   330
1815
5f6fb98a3479 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1788
diff changeset
   331
    ^ (self new) 
1352
cd83d6348a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   332
        setBlock:aBlock 
cd83d6348a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   333
        arguments:(Array with:anArgument)
146
9603cec98ac2 oops change notification was wrong
Claus Gittinger <cg@exept.de>
parents: 145
diff changeset
   334
9603cec98ac2 oops change notification was wrong
Claus Gittinger <cg@exept.de>
parents: 145
diff changeset
   335
    "Created: 16.12.1995 / 19:20:14 / cg"
9603cec98ac2 oops change notification was wrong
Claus Gittinger <cg@exept.de>
parents: 145
diff changeset
   336
!
9603cec98ac2 oops change notification was wrong
Claus Gittinger <cg@exept.de>
parents: 145
diff changeset
   337
1255
39081e9cddf1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1045
diff changeset
   338
with:aBlock argument:anArgument1 argument:anArgument2
39081e9cddf1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1045
diff changeset
   339
    "return a new BlockValue computing aBlock"
39081e9cddf1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1045
diff changeset
   340
1815
5f6fb98a3479 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1788
diff changeset
   341
    ^ (self new) 
1352
cd83d6348a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   342
        setBlock:aBlock 
cd83d6348a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   343
        arguments:(Array with:anArgument1 with:anArgument2)
1255
39081e9cddf1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1045
diff changeset
   344
39081e9cddf1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1045
diff changeset
   345
    "Created: 16.12.1995 / 19:20:14 / cg"
39081e9cddf1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1045
diff changeset
   346
!
39081e9cddf1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1045
diff changeset
   347
1352
cd83d6348a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   348
with:aBlock argument:anArgument1 argument:anArgument2 argument:anArgument3
cd83d6348a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   349
    "return a new BlockValue computing aBlock"
cd83d6348a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   350
1815
5f6fb98a3479 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1788
diff changeset
   351
    ^ (self new) 
1352
cd83d6348a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   352
        setBlock:aBlock 
cd83d6348a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   353
        arguments:(Array with:anArgument1 with:anArgument2 with:anArgument3)
1815
5f6fb98a3479 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1788
diff changeset
   354
!
1352
cd83d6348a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   355
1815
5f6fb98a3479 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1788
diff changeset
   356
with:aBlock argument:anArgument1 argument:anArgument2 argument:anArgument3 argument:anArgument4
5f6fb98a3479 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1788
diff changeset
   357
    "return a new BlockValue computing aBlock"
5f6fb98a3479 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1788
diff changeset
   358
5f6fb98a3479 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1788
diff changeset
   359
    ^ (self new) 
5f6fb98a3479 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1788
diff changeset
   360
        setBlock:aBlock 
5f6fb98a3479 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1788
diff changeset
   361
        arguments:(Array with:anArgument1 with:anArgument2 with:anArgument3 with:anArgument4)
1352
cd83d6348a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   362
!
cd83d6348a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   363
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
with:aBlock arguments:aCollectionOfArguments
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
    "return a new BlockValue computing aBlock"
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
1815
5f6fb98a3479 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1788
diff changeset
   367
    ^ (self new) 
1352
cd83d6348a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   368
        setBlock:aBlock 
cd83d6348a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   369
        arguments:aCollectionOfArguments
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
    "Created: 16.12.1995 / 19:20:14 / cg"
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
! !
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
!BlockValue methodsFor:'accessing'!
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
setBlock:aBlock
382
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   377
    "set the receivers action block"
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   378
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
    block := aBlock.
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
    arguments notNil ifTrue:[
382
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   381
        self release
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
    ].
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
    arguments := nil.
146
9603cec98ac2 oops change notification was wrong
Claus Gittinger <cg@exept.de>
parents: 145
diff changeset
   384
    cachedValue := NeverComputed.
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
    "Created: 16.12.1995 / 19:16:59 / cg"
382
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   387
    "Modified: 22.1.1997 / 19:05:54 / cg"
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   388
!
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   389
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   390
setBlock:aBlock argumentArray:anArgumentCollection
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   391
    "set the receivers action block, and define an arguments collection
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   392
     to be passed to it.
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   393
     A change in any element of the collection will force reevaluation of the 
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   394
     action block (passing the collection as a single argument)
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   395
     - possibly generating another change from myself"
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   396
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   397
    block := aBlock.
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   398
    arguments notNil ifTrue:[
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   399
        self release
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   400
    ].
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   401
    arguments := Array with:anArgumentCollection.
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   402
    anArgumentCollection do:[:arg |
2530
a40d597a31ed Do not set dependencies on nil
Stefan Vogel <sv@exept.de>
parents: 1815
diff changeset
   403
        arg notNil ifTrue:[
a40d597a31ed Do not set dependencies on nil
Stefan Vogel <sv@exept.de>
parents: 1815
diff changeset
   404
            arg addDependent:self
a40d597a31ed Do not set dependencies on nil
Stefan Vogel <sv@exept.de>
parents: 1815
diff changeset
   405
        ].
382
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   406
    ].
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   407
    cachedValue := NeverComputed.
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   408
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   409
    "Modified: 22.1.1997 / 19:08:51 / cg"
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   410
    "Created: 22.1.1997 / 19:22:13 / cg"
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
!
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   412
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
setBlock:aBlock arguments:aCollectionOfArguments
382
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   414
    "set the receivers action block, and define arguments to be passed to it.
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   415
     A change in any of the arguments will force reevaluation of the action
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   416
     block - possibly generating another change from myself"
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   417
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   418
    block := aBlock.
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   419
    arguments notNil ifTrue:[
382
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   420
        self release
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   421
    ].
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   422
    arguments := aCollectionOfArguments.
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   423
    arguments do:[:arg |
2530
a40d597a31ed Do not set dependencies on nil
Stefan Vogel <sv@exept.de>
parents: 1815
diff changeset
   424
        "arg maybe some constant..."
a40d597a31ed Do not set dependencies on nil
Stefan Vogel <sv@exept.de>
parents: 1815
diff changeset
   425
        arg notNil ifTrue:[
a40d597a31ed Do not set dependencies on nil
Stefan Vogel <sv@exept.de>
parents: 1815
diff changeset
   426
            arg addDependent:self
a40d597a31ed Do not set dependencies on nil
Stefan Vogel <sv@exept.de>
parents: 1815
diff changeset
   427
        ].
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   428
    ].
146
9603cec98ac2 oops change notification was wrong
Claus Gittinger <cg@exept.de>
parents: 145
diff changeset
   429
    cachedValue := NeverComputed.
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   430
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   431
    "Created: 16.12.1995 / 19:21:41 / cg"
382
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   432
    "Modified: 22.1.1997 / 19:08:51 / cg"
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   433
!
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   434
155
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
   435
setValue:newValue 
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
   436
    "physically set my value, without change notifications.
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
   437
     This is a noop here, since my value is computed."
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
   438
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
   439
    ^ self
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
   440
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
   441
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
   442
!
7b88cc365866 ignore setValue: / another comment
ah
parents: 146
diff changeset
   443
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   444
value
382
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   445
    "retrieve my value - this does not always evaluate the action block,
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   446
     since the returned value is cached internally"
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   447
146
9603cec98ac2 oops change notification was wrong
Claus Gittinger <cg@exept.de>
parents: 145
diff changeset
   448
    cachedValue == NeverComputed ifTrue:[
491
c5174fe6f09c allow valueHolder(s) as arg(s)
ca
parents: 382
diff changeset
   449
        cachedValue := self computeValue
146
9603cec98ac2 oops change notification was wrong
Claus Gittinger <cg@exept.de>
parents: 145
diff changeset
   450
    ].
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
    ^ cachedValue
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
    "Created: 16.12.1995 / 19:23:26 / cg"
382
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   454
    "Modified: 22.1.1997 / 19:06:59 / cg"
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
! !
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
347
2a795646e985 category rename
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   457
!BlockValue methodsFor:'change & update'!
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
1788
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   459
recomputeValue
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   460
    "reevaluate my actionBlock, and possibly send a change notification to my dependents"
382
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   461
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   462
    |oldValue|
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   464
    oldValue := cachedValue.
491
c5174fe6f09c allow valueHolder(s) as arg(s)
ca
parents: 382
diff changeset
   465
    cachedValue := self computeValue.
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
    oldValue ~~ cachedValue ifTrue:[
382
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   467
        self changed:#value
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   468
    ].
1788
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   469
!
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   470
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   471
update:something with:aParameter from:someone
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   472
    "the one I depend on has changed - reevaluate my actionBlock,
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   473
     and possibly send a change notification to my dependents"
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   474
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   475
    self recomputeValue
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   476
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   477
    "Created: 16.12.1995 / 19:22:54 / cg"
382
d64197ef1c9b commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   478
    "Modified: 22.1.1997 / 19:07:39 / cg"
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   479
! !
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   480
2985
bcda0efbb554 category of: #release
Claus Gittinger <cg@exept.de>
parents: 2800
diff changeset
   481
!BlockValue methodsFor:'dependents access'!
bcda0efbb554 category of: #release
Claus Gittinger <cg@exept.de>
parents: 2800
diff changeset
   482
bcda0efbb554 category of: #release
Claus Gittinger <cg@exept.de>
parents: 2800
diff changeset
   483
release
bcda0efbb554 category of: #release
Claus Gittinger <cg@exept.de>
parents: 2800
diff changeset
   484
    "release any dependencies upon the arguments"
bcda0efbb554 category of: #release
Claus Gittinger <cg@exept.de>
parents: 2800
diff changeset
   485
bcda0efbb554 category of: #release
Claus Gittinger <cg@exept.de>
parents: 2800
diff changeset
   486
    arguments notNil ifTrue:[
bcda0efbb554 category of: #release
Claus Gittinger <cg@exept.de>
parents: 2800
diff changeset
   487
        arguments do:[:arg | arg removeDependent:self].
bcda0efbb554 category of: #release
Claus Gittinger <cg@exept.de>
parents: 2800
diff changeset
   488
    ].
3291
8690be2779fc class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 2985
diff changeset
   489
    super release
2985
bcda0efbb554 category of: #release
Claus Gittinger <cg@exept.de>
parents: 2800
diff changeset
   490
bcda0efbb554 category of: #release
Claus Gittinger <cg@exept.de>
parents: 2800
diff changeset
   491
    "Modified: 22.1.1997 / 19:08:06 / cg"
bcda0efbb554 category of: #release
Claus Gittinger <cg@exept.de>
parents: 2800
diff changeset
   492
! !
bcda0efbb554 category of: #release
Claus Gittinger <cg@exept.de>
parents: 2800
diff changeset
   493
1788
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   494
!BlockValue methodsFor:'misc'!
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   495
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   496
computeValue
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   497
    "evaluate the receivers action block"
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   498
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   499
    |sz arg1 arg2 argValues|
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   500
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   501
    arguments isNil ifTrue:[
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   502
        ^ block value
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   503
    ].
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   504
    sz := arguments size.
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   505
    sz == 0 ifTrue:[
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   506
        ^ block value
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   507
    ].
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   508
    arg1 := (arguments at:1) value.
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   509
    sz == 1 ifTrue:[
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   510
        ^ block value:arg1
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   511
    ].
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   512
    arg2 := (arguments at:2) value.
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   513
    sz == 2 ifTrue:[
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   514
        ^ block value:arg1 value:arg2
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   515
    ].
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   516
    "/ do not evaluate arg[1-2] twice
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   517
    argValues := Array new:arguments size.
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   518
    argValues at:1 put:arg1.    "/ do not evaluate twice
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   519
    argValues at:2 put:arg2.    "/ do not evaluate twice
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   520
    3 to:arguments size do:[:i | argValues at:i put:(arguments at:i) value].
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   521
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   522
    ^ block valueWithArguments:argValues
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   523
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   524
    "Created: 16.12.1995 / 19:27:40 / cg"
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   525
    "Modified: 22.1.1997 / 19:05:57 / cg"
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   526
!
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   527
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   528
dependOn:someObject
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   529
    "arrange for the blockValue to be reevaluated, whenever someObject
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   530
     changes (i.e. sends a change notification)"
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   531
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   532
    arguments isNil ifTrue:[
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   533
        arguments := Array with:someObject
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   534
    ] ifFalse:[
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   535
        arguments := arguments copyWith:someObject
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   536
    ].
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   537
    someObject addDependent:self
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   538
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   539
    "Modified: 22.1.1997 / 19:05:26 / cg"
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   540
!
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   541
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   542
resetValue
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   543
    "evaluate the receivers action block"
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   544
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   545
    cachedValue := self computeValue
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   546
! !
7edafbabe844 +recomputeValue
Claus Gittinger <cg@exept.de>
parents: 1701
diff changeset
   547
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   548
!BlockValue class methodsFor:'documentation'!
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   549
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   550
version
3349
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   551
    ^ '$Header: /cvs/stx/stx/libview2/BlockValue.st,v 1.27 2014-06-18 16:51:25 cg Exp $'
2760
653b3c3fd7a7 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 2530
diff changeset
   552
!
653b3c3fd7a7 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 2530
diff changeset
   553
653b3c3fd7a7 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 2530
diff changeset
   554
version_CVS
3349
ffebc3c4e212 class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 3291
diff changeset
   555
    ^ '$Header: /cvs/stx/stx/libview2/BlockValue.st,v 1.27 2014-06-18 16:51:25 cg Exp $'
145
cb162538d41a intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   556
! !
1665
096ca1b11ce1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1352
diff changeset
   557
3291
8690be2779fc class: BlockValue
Claus Gittinger <cg@exept.de>
parents: 2985
diff changeset
   558
146
9603cec98ac2 oops change notification was wrong
Claus Gittinger <cg@exept.de>
parents: 145
diff changeset
   559
BlockValue initialize!