UpDownButton.st
author Stefan Vogel <sv@exept.de>
Wed, 31 Mar 1999 08:09:00 +0200
changeset 1299 f088a69429be
parent 1264 dda5fc818ef0
child 1435 6343d644bf32
permissions -rw-r--r--
Move common channels to View. Add model behavior.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1299
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
     1
View subclass:#UpDownButton
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
     2
	instanceVariableNames:'orientation upButton downButton'
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
     3
	classVariableNames:''
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
	poolDictionaries:''
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
	category:'Views-Interactors'
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
!
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
!UpDownButton class methodsFor:'documentation'!
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
documentation
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
    an up/down button - simply two buttons in one view.
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
    [author:]
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
        Claus Gittinger
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
    [see also:]
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
        ArrowButton
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
        ComboUpDownView
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
"
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
examples
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
"
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
                                                                [exBegin]
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
     |top ud|
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
     top := StandardSystemView new.
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
     top extent:(300 @ 200).
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
     ud := UpDownButton in:top.
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
     ud origin:(10 @ 10).
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
     ud upAction:[Transcript showCR:'up'].
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
     ud downAction:[Transcript showCR:'down'].
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
     top open.
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
                                                                [exEnd]
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
    38
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
    39
                                                                [exBegin]
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
    40
     |top ud|
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
    41
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
    42
     top := StandardSystemView new.
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
    43
     top extent:(300 @ 200).
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
    44
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
    45
     ud := UpDownButton in:top.
1299
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
    46
     ud origin:(10 @ 10).
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
    47
     ud model:[:arg| Transcript showCR:arg].
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
    48
     top open.
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
    49
                                                                [exEnd]
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
    50
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
    51
                                                                [exBegin]
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
    52
     |top ud|
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
    53
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
    54
     top := StandardSystemView new.
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
    55
     top extent:(300 @ 200).
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
    56
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
    57
     ud := UpDownButton in:top.
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
    58
     ud orientation:#horizontal.
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
    59
     ud origin:(10 @ 10).
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
    60
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
    61
     ud upAction:[Transcript showCR:'up'].
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
    62
     ud downAction:[Transcript showCR:'down'].
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
    63
     top open.
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
    64
                                                                [exEnd]
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
"
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
! !
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
!UpDownButton methodsFor:'accessing-behavior'!
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
downAction:aBlock
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
    72
    "set the down-action"
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
    73
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
    downButton action:aBlock
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
!
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
1299
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
    77
enabled
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
    78
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
    79
    ^ upButton enabled.
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
    80
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
    81
    "Created: / 30.3.1999 / 17:01:43 / stefan"
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
    82
!
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    83
1299
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
    84
enabled:aBoolean
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
    85
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
    86
    upButton enabled:aBoolean.
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
    87
    downButton enabled:aBoolean.
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
    88
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
    89
    "Created: / 30.3.1999 / 15:47:11 / stefan"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    90
!
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    91
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
upAction:aBlock
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
    93
    "set the up-action"
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
    94
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
    upButton action:aBlock
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
! !
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    98
!UpDownButton methodsFor:'accessing-channels'!
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    99
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   100
backgroundChannel
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   101
    "return a valueHolder for the background color"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   102
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   103
    ^ upButton backgroundChannel
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   104
!
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   105
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   106
backgroundChannel: aValueHolder
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   107
    "set a valueHolder for the background color"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   108
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   109
    upButton backgroundChannel: aValueHolder.
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   110
    downButton backgroundChannel: aValueHolder
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   111
!
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   112
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   113
enableChannel
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   114
    "return a valueHolder for the enabled-state"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   115
1299
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   116
    ^ upButton enableChannel
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   117
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   118
    "Modified: / 30.3.1999 / 16:56:32 / stefan"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   119
!
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   120
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   121
enableChannel: aValueHolder
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   122
    "set a valueHolder for the enabled-state"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   123
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   124
    upButton enableChannel: aValueHolder.
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   125
    downButton enableChannel: aValueHolder
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   126
!
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   127
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   128
foregroundChannel
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   129
    "return a valueHolder for the foreground color"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   130
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   131
    ^ upButton foregroundChannel
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   132
!
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   133
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   134
foregroundChannel: aValueHolder
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   135
    "set a valueHolder for the foreground color"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   136
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   137
    upButton foregroundChannel: aValueHolder.
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   138
    downButton foregroundChannel: aValueHolder
1299
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   139
!
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   140
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   141
model:aModel
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   142
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   143
    |m|
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   144
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   145
    aModel notNil ifTrue:[
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   146
        m := self.
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   147
        upButton changeMessage:#changeUp:.
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   148
        downButton changeMessage:#changeDown:.
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   149
    ].
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   150
    upButton model:m.
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   151
    downButton model:m.
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   152
    ^ super model:aModel
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   153
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   154
    "Modified: / 30.3.1999 / 17:45:59 / stefan"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   155
! !
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   156
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   157
!UpDownButton methodsFor:'accessing-colors'!
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   158
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   159
backgroundColor
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   160
    "return the backgroundColor"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   161
852
89c5dd6f6809 wrong color accessings
tz
parents: 818
diff changeset
   162
    ^upButton backgroundColor
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   163
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   164
!
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   165
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   166
backgroundColor:aColor
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   167
    "set the backgroundColor"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   168
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   169
    aColor ~~ upButton backgroundColor ifTrue:[
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   170
        upButton backgroundColor:aColor.
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   171
        downButton backgroundColor:aColor.
912
e4b45ee7df6d redrawNow, when colors change.
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   172
        shown ifTrue:[
e4b45ee7df6d redrawNow, when colors change.
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   173
            self invalidateRepairNow:true
e4b45ee7df6d redrawNow, when colors change.
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   174
        ]
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   175
    ]
912
e4b45ee7df6d redrawNow, when colors change.
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   176
e4b45ee7df6d redrawNow, when colors change.
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   177
    "Modified: / 6.6.1998 / 19:53:50 / cg"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   178
!
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   179
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   180
foregroundColor
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   181
    "return the foregroundColor"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   182
852
89c5dd6f6809 wrong color accessings
tz
parents: 818
diff changeset
   183
    ^upButton foregroundColor
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   184
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   185
!
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   186
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   187
foregroundColor:aColor
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   188
    "set the foregroundColor"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   189
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   190
    aColor ~~ upButton foregroundColor ifTrue:[
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   191
        upButton foregroundColor:aColor.
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   192
        downButton foregroundColor:aColor.
912
e4b45ee7df6d redrawNow, when colors change.
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   193
        shown ifTrue:[
e4b45ee7df6d redrawNow, when colors change.
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   194
            self invalidateRepairNow:true
e4b45ee7df6d redrawNow, when colors change.
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   195
        ]
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   196
    ]
912
e4b45ee7df6d redrawNow, when colors change.
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   197
e4b45ee7df6d redrawNow, when colors change.
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   198
    "Modified: / 6.6.1998 / 19:53:44 / cg"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   199
! !
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   200
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
!UpDownButton methodsFor:'accessing-components'!
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
downButton
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   204
    "return the downButton"
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   205
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
    ^ downButton
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
!
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
upButton
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   210
    "return the upButton"
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   211
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
    ^ upButton
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
! !
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   215
!UpDownButton methodsFor:'accessing-look'!
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   216
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   217
orientation
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   218
    "return the orientation (a symbol)"
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   219
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   220
    ^ orientation
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   221
!
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   222
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   223
orientation:aSymbol
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   224
    "set the orientation (#horizontal or #vertical)"
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   225
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   226
    orientation := aSymbol.
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   227
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   228
    self initializeButtonDimensions.
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   229
    self initializeButtonForms
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   230
! !
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   231
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   232
!UpDownButton methodsFor:'change & update'!
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   233
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   234
sizeChanged:how
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   235
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   236
    super sizeChanged:how.
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   237
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   238
    self initializeButtonDimensions
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   239
! !
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   240
868
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   241
!UpDownButton methodsFor:'event handling'!
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   242
1299
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   243
changeDown:aValue
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   244
    "down button was pressed, send to my model"
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   245
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   246
    self sendChangeMessageWith:#down
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   247
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   248
    "Modified: / 30.3.1999 / 17:28:50 / stefan"
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   249
!
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   250
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   251
changeUp:aValue
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   252
    "up button was pressed, send to my model"
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   253
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   254
    self sendChangeMessageWith:#up
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   255
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   256
    "Created: / 30.3.1999 / 17:28:26 / stefan"
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   257
!
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   258
868
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   259
keyPress:aKey x:x y:y
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   260
    "simulate a buttonPress/release"
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   261
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   262
    |theButton theController|
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   263
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   264
    ((aKey == #CursorUp)
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   265
    or:[aKey == #CursorRight
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   266
    or:[aKey == $+]]) ifTrue:[
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   267
        theButton := upButton
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   268
    ] ifFalse:[
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   269
        ((aKey == #CursorDown)
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   270
        or:[aKey == #CursorLeft 
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   271
        or:[aKey == $-]]) ifTrue:[
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   272
            theButton := downButton
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   273
        ].
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   274
    ].
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   275
    theButton notNil ifTrue:[
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   276
        theController := theButton controller.
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   277
        theController pressed:true.
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   278
        theController pressed:false.
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   279
        ^ self
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   280
    ].
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   281
    ^ super keyPress:aKey x:x y:y
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   282
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   283
    "Created: / 21.4.1998 / 19:48:28 / cg"
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   284
    "Modified: / 21.4.1998 / 19:56:28 / cg"
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   285
! !
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   286
1264
dda5fc818ef0 category change
Claus Gittinger <cg@exept.de>
parents: 912
diff changeset
   287
!UpDownButton methodsFor:'focus handling'!
dda5fc818ef0 category change
Claus Gittinger <cg@exept.de>
parents: 912
diff changeset
   288
dda5fc818ef0 category change
Claus Gittinger <cg@exept.de>
parents: 912
diff changeset
   289
showFocus:explicit 
dda5fc818ef0 category change
Claus Gittinger <cg@exept.de>
parents: 912
diff changeset
   290
    "display myself as having-focus"
dda5fc818ef0 category change
Claus Gittinger <cg@exept.de>
parents: 912
diff changeset
   291
dda5fc818ef0 category change
Claus Gittinger <cg@exept.de>
parents: 912
diff changeset
   292
    (upButton enabled or:[downButton enabled]) ifTrue: [
dda5fc818ef0 category change
Claus Gittinger <cg@exept.de>
parents: 912
diff changeset
   293
        super showFocus:explicit
dda5fc818ef0 category change
Claus Gittinger <cg@exept.de>
parents: 912
diff changeset
   294
    ]
dda5fc818ef0 category change
Claus Gittinger <cg@exept.de>
parents: 912
diff changeset
   295
! !
dda5fc818ef0 category change
Claus Gittinger <cg@exept.de>
parents: 912
diff changeset
   296
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
!UpDownButton methodsFor:'initialization'!
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
initialize
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   300
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   301
    orientation := #vertical.
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   302
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
    super initialize.
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
    self initializeButtons
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   305
!
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   306
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   307
initializeButtonDimensions
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   308
    |upOrigin downOrigin upCorner downCorner|
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   309
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   310
    upOrigin := 0@0.
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   311
    orientation == #vertical ifTrue:[
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   312
        upCorner := (width - 1) @ (height // 2).
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   313
        downOrigin := 0 @ (height // 2 + 1).
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   314
        downCorner := (width - 1) @ (height - 1)
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   315
    ] ifFalse:[
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   316
        upCorner := (width // 2) @ (height - 1).
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   317
        downOrigin := (width // 2 + 1) @ 0.
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   318
        downCorner := (width - 1) @ (height - 1)
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   319
    ].
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   320
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   321
    upButton   origin:upOrigin.
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   322
    upButton   corner:upCorner.
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   323
    downButton origin:downOrigin.
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   324
    downButton corner:downCorner.
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   325
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   326
!
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   327
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   328
initializeButtonForms
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   329
    |upLabel downLabel|
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   330
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   331
    orientation == #vertical ifTrue:[
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   332
        upLabel := ArrowButton UpArrowForm.
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   333
        downLabel := ArrowButton DownArrowForm.
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   334
    ] ifFalse:[
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   335
        upLabel := ArrowButton LeftArrowForm.
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   336
        downLabel := ArrowButton RightArrowForm.
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   337
    ].
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   338
    upButton label:upLabel.
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   339
    downButton label:downLabel.
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   340
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
!
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
initializeButtons
779
0abab228a8fd do not define callbacks in action blocks which do not exist
tz
parents: 651
diff changeset
   344
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
    upButton := ArrowButton upIn:self.
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
    upButton autoRepeat:true.
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
    downButton := ArrowButton downIn:self.
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
    downButton autoRepeat:true.
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   351
    self initializeButtonDimensions.
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   352
    self initializeButtonForms
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
! !
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
!UpDownButton class methodsFor:'documentation'!
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
version
1299
f088a69429be Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1264
diff changeset
   358
    ^ '$Header: /cvs/stx/stx/libwidg2/UpDownButton.st,v 1.13 1999-03-31 06:09:00 stefan Exp $'
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
! !