UpDownButton.st
author Claus Gittinger <cg@exept.de>
Sat, 06 Jun 1998 19:54:02 +0200
changeset 912 e4b45ee7df6d
parent 899 68770c9d162d
child 1264 dda5fc818ef0
permissions -rw-r--r--
redrawNow, when colors change.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
SimpleView 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.
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
    46
     ud orientation:#horizontal.
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
    47
     ud origin:(10 @ 10).
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
    48
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
    49
     ud upAction:[Transcript showCR:'up'].
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
    50
     ud downAction:[Transcript showCR:'down'].
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
    51
     top open.
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
    52
                                                                [exEnd]
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
"
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
! !
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
!UpDownButton methodsFor:'accessing-behavior'!
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    59
disable
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
    60
    "disable the upDown button"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    61
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    62
    upButton disable.
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    63
    downButton disable.
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    64
!
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    65
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
downAction:aBlock
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
    67
    "set the down-action"
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
    68
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
    downButton action:aBlock
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
!
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    72
enable
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    73
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    74
    upButton enable.
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    75
    downButton enable.
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    76
!
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    77
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
upAction:aBlock
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
    79
    "set the up-action"
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
    80
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    upButton action:aBlock
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
! !
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    84
!UpDownButton methodsFor:'accessing-channels'!
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    85
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    86
backgroundChannel
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
    87
    "return a valueHolder for the background color"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    88
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
    89
    ^ upButton backgroundChannel
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    90
!
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    91
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    92
backgroundChannel: aValueHolder
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
    93
    "set a valueHolder for the background color"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    94
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    95
    upButton backgroundChannel: aValueHolder.
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    96
    downButton backgroundChannel: aValueHolder
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    97
!
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    98
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
    99
enableChannel
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   100
    "return a valueHolder for the enabled-state"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   101
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   102
    upButton enableChannel
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   103
!
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   104
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   105
enableChannel: aValueHolder
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   106
    "set a valueHolder for the enabled-state"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   107
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   108
    upButton enableChannel: aValueHolder.
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   109
    downButton enableChannel: aValueHolder
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   110
!
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   111
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   112
foregroundChannel
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   113
    "return a valueHolder for the foreground color"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   114
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   115
    ^ upButton foregroundChannel
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   116
!
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   117
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   118
foregroundChannel: aValueHolder
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   119
    "set a valueHolder for the foreground color"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   120
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   121
    upButton foregroundChannel: aValueHolder.
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   122
    downButton foregroundChannel: aValueHolder
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   123
! !
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   124
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   125
!UpDownButton methodsFor:'accessing-colors'!
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   126
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   127
backgroundColor
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   128
    "return the backgroundColor"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   129
852
89c5dd6f6809 wrong color accessings
tz
parents: 818
diff changeset
   130
    ^upButton backgroundColor
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   131
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
backgroundColor:aColor
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   135
    "set the backgroundColor"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   136
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   137
    aColor ~~ upButton backgroundColor ifTrue:[
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   138
        upButton backgroundColor:aColor.
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   139
        downButton backgroundColor:aColor.
912
e4b45ee7df6d redrawNow, when colors change.
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   140
        shown ifTrue:[
e4b45ee7df6d redrawNow, when colors change.
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   141
            self invalidateRepairNow:true
e4b45ee7df6d redrawNow, when colors change.
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   142
        ]
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   143
    ]
912
e4b45ee7df6d redrawNow, when colors change.
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   144
e4b45ee7df6d redrawNow, when colors change.
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   145
    "Modified: / 6.6.1998 / 19:53:50 / cg"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   146
!
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   147
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   148
foregroundColor
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   149
    "return the foregroundColor"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   150
852
89c5dd6f6809 wrong color accessings
tz
parents: 818
diff changeset
   151
    ^upButton foregroundColor
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   152
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   153
!
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   154
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   155
foregroundColor:aColor
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   156
    "set the foregroundColor"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   157
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   158
    aColor ~~ upButton foregroundColor ifTrue:[
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   159
        upButton foregroundColor:aColor.
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   160
        downButton foregroundColor:aColor.
912
e4b45ee7df6d redrawNow, when colors change.
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   161
        shown ifTrue:[
e4b45ee7df6d redrawNow, when colors change.
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   162
            self invalidateRepairNow:true
e4b45ee7df6d redrawNow, when colors change.
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   163
        ]
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   164
    ]
912
e4b45ee7df6d redrawNow, when colors change.
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   165
e4b45ee7df6d redrawNow, when colors change.
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   166
    "Modified: / 6.6.1998 / 19:53:44 / cg"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   167
!
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   168
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   169
model:aModel
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   170
    "ignore models"
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   171
! !
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   172
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
!UpDownButton methodsFor:'accessing-components'!
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
downButton
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   176
    "return the downButton"
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   177
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
    ^ downButton
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
!
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
upButton
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   182
    "return the upButton"
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   183
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
    ^ upButton
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
! !
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   187
!UpDownButton methodsFor:'accessing-look'!
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   188
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   189
orientation
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   190
    "return the orientation (a symbol)"
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   191
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   192
    ^ orientation
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   193
!
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   194
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   195
orientation:aSymbol
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   196
    "set the orientation (#horizontal or #vertical)"
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   197
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   198
    orientation := aSymbol.
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   199
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   200
    self initializeButtonDimensions.
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   201
    self initializeButtonForms
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   202
! !
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   203
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   204
!UpDownButton methodsFor:'change & update'!
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   205
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   206
sizeChanged:how
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   207
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   208
    super sizeChanged:how.
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   209
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   210
    self initializeButtonDimensions
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   211
! !
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   212
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   213
!UpDownButton methodsFor:'displaying'!
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   214
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   215
showFocus:explicit 
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   216
    "display myself as having-focus"
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   217
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   218
    (upButton enabled or:[downButton enabled]) ifTrue: [super showFocus:explicit]
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   219
! !
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   220
868
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   221
!UpDownButton methodsFor:'event handling'!
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   222
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   223
keyPress:aKey x:x y:y
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   224
    "simulate a buttonPress/release"
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   225
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   226
    |theButton theController|
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   227
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   228
    ((aKey == #CursorUp)
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   229
    or:[aKey == #CursorRight
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   230
    or:[aKey == $+]]) ifTrue:[
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   231
        theButton := upButton
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   232
    ] ifFalse:[
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   233
        ((aKey == #CursorDown)
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   234
        or:[aKey == #CursorLeft 
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   235
        or:[aKey == $-]]) ifTrue:[
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   236
            theButton := downButton
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   237
        ].
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   238
    ].
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   239
    theButton notNil ifTrue:[
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   240
        theController := theButton controller.
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   241
        theController pressed:true.
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   242
        theController pressed:false.
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   243
        ^ self
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   244
    ].
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   245
    ^ super keyPress:aKey x:x y:y
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   246
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   247
    "Created: / 21.4.1998 / 19:48:28 / cg"
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   248
    "Modified: / 21.4.1998 / 19:56:28 / cg"
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   249
! !
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   250
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
!UpDownButton methodsFor:'initialization'!
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
initialize
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   254
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   255
    orientation := #vertical.
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   256
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
    super initialize.
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
    self initializeButtons
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   259
!
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   260
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   261
initializeButtonDimensions
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   262
    |upOrigin downOrigin upCorner downCorner|
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   263
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   264
    upOrigin := 0@0.
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   265
    orientation == #vertical ifTrue:[
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   266
        upCorner := (width - 1) @ (height // 2).
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   267
        downOrigin := 0 @ (height // 2 + 1).
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   268
        downCorner := (width - 1) @ (height - 1)
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   269
    ] ifFalse:[
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   270
        upCorner := (width // 2) @ (height - 1).
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   271
        downOrigin := (width // 2 + 1) @ 0.
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   272
        downCorner := (width - 1) @ (height - 1)
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   273
    ].
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   274
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   275
    upButton   origin:upOrigin.
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   276
    upButton   corner:upCorner.
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   277
    downButton origin:downOrigin.
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   278
    downButton corner:downCorner.
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   279
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   280
!
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   281
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   282
initializeButtonForms
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   283
    |upLabel downLabel|
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   284
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   285
    orientation == #vertical ifTrue:[
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   286
        upLabel := ArrowButton UpArrowForm.
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   287
        downLabel := ArrowButton DownArrowForm.
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   288
    ] ifFalse:[
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   289
        upLabel := ArrowButton LeftArrowForm.
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   290
        downLabel := ArrowButton RightArrowForm.
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   291
    ].
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   292
    upButton label:upLabel.
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   293
    downButton label:downLabel.
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   294
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
!
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
initializeButtons
779
0abab228a8fd do not define callbacks in action blocks which do not exist
tz
parents: 651
diff changeset
   298
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
    upButton := ArrowButton upIn:self.
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
    upButton autoRepeat:true.
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
    downButton := ArrowButton downIn:self.
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
    downButton autoRepeat:true.
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   305
    self initializeButtonDimensions.
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   306
    self initializeButtonForms
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
! !
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
!UpDownButton class methodsFor:'documentation'!
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
version
912
e4b45ee7df6d redrawNow, when colors change.
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   312
    ^ '$Header: /cvs/stx/stx/libwidg2/UpDownButton.st,v 1.11 1998-06-06 17:54:02 cg Exp $'
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
! !