UpDownButton.st
author Claus Gittinger <cg@exept.de>
Fri, 22 May 1998 14:09:01 +0200
changeset 899 68770c9d162d
parent 868 0fa479aee842
child 912 e4b45ee7df6d
permissions -rw-r--r--
checkin from browser
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.
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   140
        shown ifTrue:[self invalidate]
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   141
    ]
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   142
!
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   143
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   144
foregroundColor
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   145
    "return the foregroundColor"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   146
852
89c5dd6f6809 wrong color accessings
tz
parents: 818
diff changeset
   147
    ^upButton foregroundColor
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   148
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   149
!
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   150
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   151
foregroundColor:aColor
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   152
    "set the foregroundColor"
818
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   153
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   154
    aColor ~~ upButton foregroundColor ifTrue:[
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   155
        upButton foregroundColor:aColor.
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   156
        downButton foregroundColor:aColor.
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   157
        shown ifTrue:[self invalidate]
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   158
    ]
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   159
!
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   160
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   161
model:aModel
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   162
    "ignore models"
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   163
! !
fbd05e92d506 revised for the docu
tz
parents: 788
diff changeset
   164
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
!UpDownButton methodsFor:'accessing-components'!
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
downButton
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   168
    "return the downButton"
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   169
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
    ^ downButton
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
!
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
upButton
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   174
    "return the upButton"
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   175
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
    ^ upButton
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
! !
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   179
!UpDownButton methodsFor:'accessing-look'!
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   180
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   181
orientation
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   182
    "return the orientation (a symbol)"
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   183
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   184
    ^ orientation
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   185
!
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   186
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   187
orientation:aSymbol
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   188
    "set the orientation (#horizontal or #vertical)"
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   189
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   190
    orientation := aSymbol.
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   191
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   192
    self initializeButtonDimensions.
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   193
    self initializeButtonForms
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   194
! !
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   195
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   196
!UpDownButton methodsFor:'change & update'!
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   197
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   198
sizeChanged:how
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
    super sizeChanged:how.
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   201
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   202
    self initializeButtonDimensions
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   203
! !
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   204
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   205
!UpDownButton methodsFor:'displaying'!
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   206
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   207
showFocus:explicit 
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   208
    "display myself as having-focus"
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   209
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   210
    (upButton enabled or:[downButton enabled]) ifTrue: [super showFocus:explicit]
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   211
! !
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   212
868
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   213
!UpDownButton methodsFor:'event handling'!
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   214
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   215
keyPress:aKey x:x y:y
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   216
    "simulate a buttonPress/release"
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   217
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   218
    |theButton theController|
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   219
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   220
    ((aKey == #CursorUp)
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   221
    or:[aKey == #CursorRight
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   222
    or:[aKey == $+]]) ifTrue:[
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   223
        theButton := upButton
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   224
    ] ifFalse:[
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   225
        ((aKey == #CursorDown)
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   226
        or:[aKey == #CursorLeft 
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   227
        or:[aKey == $-]]) ifTrue:[
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   228
            theButton := downButton
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   229
        ].
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   230
    ].
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   231
    theButton notNil ifTrue:[
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   232
        theController := theButton controller.
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   233
        theController pressed:true.
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   234
        theController pressed:false.
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   235
        ^ self
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   236
    ].
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   237
    ^ super keyPress:aKey x:x y:y
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
    "Created: / 21.4.1998 / 19:48:28 / cg"
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   240
    "Modified: / 21.4.1998 / 19:56:28 / cg"
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   241
! !
0fa479aee842 handle cursorUp/Down and +/-
Claus Gittinger <cg@exept.de>
parents: 852
diff changeset
   242
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
!UpDownButton methodsFor:'initialization'!
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
initialize
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   246
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   247
    orientation := #vertical.
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   248
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
    super initialize.
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
    self initializeButtons
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   251
!
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   252
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   253
initializeButtonDimensions
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   254
    |upOrigin downOrigin upCorner downCorner|
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   255
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   256
    upOrigin := 0@0.
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   257
    orientation == #vertical ifTrue:[
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   258
        upCorner := (width - 1) @ (height // 2).
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   259
        downOrigin := 0 @ (height // 2 + 1).
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   260
        downCorner := (width - 1) @ (height - 1)
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   261
    ] ifFalse:[
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   262
        upCorner := (width // 2) @ (height - 1).
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   263
        downOrigin := (width // 2 + 1) @ 0.
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   264
        downCorner := (width - 1) @ (height - 1)
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   265
    ].
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   266
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   267
    upButton   origin:upOrigin.
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   268
    upButton   corner:upCorner.
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   269
    downButton origin:downOrigin.
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   270
    downButton corner:downCorner.
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   271
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   272
!
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   273
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   274
initializeButtonForms
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   275
    |upLabel downLabel|
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   276
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   277
    orientation == #vertical ifTrue:[
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   278
        upLabel := ArrowButton UpArrowForm.
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   279
        downLabel := ArrowButton DownArrowForm.
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   280
    ] ifFalse:[
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   281
        upLabel := ArrowButton LeftArrowForm.
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   282
        downLabel := ArrowButton RightArrowForm.
340
c02e5db9b6f5 added left-right orientation.
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   283
    ].
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   284
    upButton label:upLabel.
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   285
    downButton label:downLabel.
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   286
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
!
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
initializeButtons
779
0abab228a8fd do not define callbacks in action blocks which do not exist
tz
parents: 651
diff changeset
   290
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
    upButton := ArrowButton upIn:self.
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
    upButton autoRepeat:true.
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
    downButton := ArrowButton downIn:self.
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
    downButton autoRepeat:true.
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
788
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   297
    self initializeButtonDimensions.
826f9374823b take forms from the ArrowButton + resizing behavior added
tz
parents: 779
diff changeset
   298
    self initializeButtonForms
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
! !
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
!UpDownButton class methodsFor:'documentation'!
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
version
899
68770c9d162d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 868
diff changeset
   304
    ^ '$Header: /cvs/stx/stx/libwidg2/UpDownButton.st,v 1.10 1998-05-22 12:09:01 cg Exp $'
338
d779aad63356 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
! !