ToggleC.st
author Claus Gittinger <cg@exept.de>
Fri, 13 Nov 1998 15:20:00 +0100
changeset 1720 896886032334
parent 973 bcc8b920dccc
permissions -rw-r--r--
added opaqueResize option.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
88
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
     1
"
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
     3
	      All Rights Reserved
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
     4
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
     5
 This software is furnished under a license and may be used
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
     6
 only in accordance with the terms of that license and with the
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
     8
 be provided or otherwise made available to, or used by, any
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
     9
 other person.  No title to or ownership of the software is
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    10
 hereby transferred.
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    11
"
78
1122ab450f80 Initial revision
claus
parents:
diff changeset
    12
1122ab450f80 Initial revision
claus
parents:
diff changeset
    13
ButtonController subclass:#ToggleController
582
e151eeae2c9a documentation
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
    14
	instanceVariableNames:'action'
e151eeae2c9a documentation
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
    15
	classVariableNames:''
e151eeae2c9a documentation
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
    16
	poolDictionaries:''
e151eeae2c9a documentation
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
    17
	category:'Interface-Support-Controllers'
78
1122ab450f80 Initial revision
claus
parents:
diff changeset
    18
!
1122ab450f80 Initial revision
claus
parents:
diff changeset
    19
88
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    20
!ToggleController class methodsFor:'documentation'!
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    21
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    22
copyright
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    23
"
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    24
 COPYRIGHT (c) 1995 by Claus Gittinger
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    25
	      All Rights Reserved
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    26
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    27
 This software is furnished under a license and may be used
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    28
 only in accordance with the terms of that license and with the
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    30
 be provided or otherwise made available to, or used by, any
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    31
 other person.  No title to or ownership of the software is
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    32
 hereby transferred.
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    33
"
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    34
!
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    35
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    36
documentation
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    37
"
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    38
    ToggleControllers redefine some of ButtonControllers behavior;
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    39
    user interaction: they always triggerOnDown, and ignore buttonrelease.
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    40
    Finally, every buttonPress leads to a toggle action.
125
claus
parents: 120
diff changeset
    41
128
claus
parents: 126
diff changeset
    42
    ToggleController adds another actionBlock, since it inherits press-
125
claus
parents: 120
diff changeset
    43
    and releaseActions, while we want one actionBlock to be used for both
claus
parents: 120
diff changeset
    44
    on- and off. The actionBlock (if any) is evaluated with the current
claus
parents: 120
diff changeset
    45
    toggles state if it expects an argument, or without argument if its a no-arg
claus
parents: 120
diff changeset
    46
    block.
128
claus
parents: 126
diff changeset
    47
claus
parents: 126
diff changeset
    48
    Other than that, all model relations are inherited - i.e. if the view has a model,
claus
parents: 126
diff changeset
    49
    that one gets change-messages and the toggle updates on aspect changes.
582
e151eeae2c9a documentation
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
    50
e151eeae2c9a documentation
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
    51
    [author:]
e151eeae2c9a documentation
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
    52
        Claus Gittinger
88
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    53
"
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    54
! !
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    55
200
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    56
!ToggleController methodsFor:'accessing'!
78
1122ab450f80 Initial revision
claus
parents:
diff changeset
    57
200
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    58
action:aBlock
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    59
    "set the action to be performed. This is called
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    60
     with the toggles state as argument."
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    61
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    62
    action := aBlock
119
claus
parents: 88
diff changeset
    63
! !
claus
parents: 88
diff changeset
    64
claus
parents: 88
diff changeset
    65
!ToggleController methodsFor:'events'!
claus
parents: 88
diff changeset
    66
claus
parents: 88
diff changeset
    67
performAction
973
bcc8b920dccc model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
    68
    "the toggle changed its state; first tell the model and
bcc8b920dccc model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
    69
     channels, then evaluate any (optional) press/release actions,
bcc8b920dccc model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
    70
     finally evaluate my real action, the toggle action.
bcc8b920dccc model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
    71
     Individual press/release actions are usually nil for toggles."
bcc8b920dccc model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
    72
bcc8b920dccc model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
    73
    super performAction.
bcc8b920dccc model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
    74
120
claus
parents: 119
diff changeset
    75
    action notNil ifTrue:[
973
bcc8b920dccc model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
    76
        active := true.
bcc8b920dccc model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
    77
        action numArgs == 0 ifTrue:[
bcc8b920dccc model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
    78
            action value
bcc8b920dccc model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
    79
        ] ifFalse:[
bcc8b920dccc model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
    80
            action value:pressed
bcc8b920dccc model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
    81
        ].
bcc8b920dccc model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
    82
        active := false.
120
claus
parents: 119
diff changeset
    83
    ].
973
bcc8b920dccc model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
    84
bcc8b920dccc model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
    85
    "Modified: 24.1.1997 / 15:42:14 / cg"
78
1122ab450f80 Initial revision
claus
parents:
diff changeset
    86
! !
1122ab450f80 Initial revision
claus
parents:
diff changeset
    87
200
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    88
!ToggleController methodsFor:'initialization'!
78
1122ab450f80 Initial revision
claus
parents:
diff changeset
    89
200
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    90
initialize
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    91
    super initialize.
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    92
    self beToggle
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    93
! !
78
1122ab450f80 Initial revision
claus
parents:
diff changeset
    94
203
8a38b0b03233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
    95
!ToggleController class methodsFor:'documentation'!
8a38b0b03233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
    96
8a38b0b03233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
    97
version
973
bcc8b920dccc model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
    98
    ^ '$Header: /cvs/stx/stx/libwidg/Attic/ToggleC.st,v 1.12 1997-01-24 14:42:55 cg Exp $'
203
8a38b0b03233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
    99
! !