SteppingSlider.st
author Claus Gittinger <cg@exept.de>
Wed, 28 May 1997 16:21:05 +0200
changeset 402 db4b13aff9c9
parent 400 d176fd820716
child 871 831b19654aae
permissions -rw-r--r--
more code moved to superclass
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23
1e6bf473d863 Initial revision
claus
parents:
diff changeset
     1
"
1e6bf473d863 Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1994 by Claus Gittinger
49
claus
parents: 23
diff changeset
     3
	      All Rights Reserved
23
1e6bf473d863 Initial revision
claus
parents:
diff changeset
     4
1e6bf473d863 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
1e6bf473d863 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
1e6bf473d863 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
1e6bf473d863 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
1e6bf473d863 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    11
"
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    12
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    13
ScrollBar subclass:#SteppingSlider
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    14
	instanceVariableNames:'stepIncrement'
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    15
	classVariableNames:''
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    16
	poolDictionaries:''
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    17
	category:'Views-Interactors'
23
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    18
!
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    19
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    20
!SteppingSlider class methodsFor:'documentation'!
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    21
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    22
copyright
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    23
"
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    24
 COPYRIGHT (c) 1994 by Claus Gittinger
49
claus
parents: 23
diff changeset
    25
	      All Rights Reserved
23
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    26
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    27
 This software is furnished under a license and may be used
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    28
 only in accordance with the terms of that license and with the
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    30
 be provided or otherwise made available to, or used by, any
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    31
 other person.  No title to or ownership of the software is
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    32
 hereby transferred.
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    33
"
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    34
!
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    35
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    36
documentation
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    37
"
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    38
    SteppingSliders are like Sliders, but add step-up and step-down
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    39
    buttons (which increment/decrement the value).
57
claus
parents: 49
diff changeset
    40
    (you can also think of them as a ScrollBar with a slider instead of
claus
parents: 49
diff changeset
    41
     a scroller as component)
23
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    42
"
49
claus
parents: 23
diff changeset
    43
!
claus
parents: 23
diff changeset
    44
claus
parents: 23
diff changeset
    45
examples 
claus
parents: 23
diff changeset
    46
"
claus
parents: 23
diff changeset
    47
    non model operation:
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    48
                                                                [exBegin]
49
claus
parents: 23
diff changeset
    49
      |top sl|
claus
parents: 23
diff changeset
    50
claus
parents: 23
diff changeset
    51
      top := StandardSystemView extent:200@200.
claus
parents: 23
diff changeset
    52
      sl := SteppingSlider in:top.
claus
parents: 23
diff changeset
    53
      sl origin:(0.0@0.0) corner:(sl width@1.0).
184
13a2f3677c68 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    54
      sl scrollAction:[:pos | Transcript showCR:pos].    
49
claus
parents: 23
diff changeset
    55
      top open
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    56
                                                                [exEnd]
49
claus
parents: 23
diff changeset
    57
claus
parents: 23
diff changeset
    58
57
claus
parents: 49
diff changeset
    59
    change the step:
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    60
                                                                [exBegin]
57
claus
parents: 49
diff changeset
    61
      |top sl|
49
claus
parents: 23
diff changeset
    62
claus
parents: 23
diff changeset
    63
      top := StandardSystemView extent:200@200.
claus
parents: 23
diff changeset
    64
      sl := SteppingSlider in:top.
claus
parents: 23
diff changeset
    65
      sl origin:(0.0@0.0) corner:(sl width@1.0).
184
13a2f3677c68 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    66
      sl scrollAction:[:pos | Transcript showCR:pos].    
57
claus
parents: 49
diff changeset
    67
      sl stepIncrement:10.
claus
parents: 49
diff changeset
    68
      top open
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    69
                                                                [exEnd]
57
claus
parents: 49
diff changeset
    70
claus
parents: 49
diff changeset
    71
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    72
    model operation (watch the value):
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    73
                                                                [exBegin]
57
claus
parents: 49
diff changeset
    74
      |model top sl fld|
claus
parents: 49
diff changeset
    75
claus
parents: 49
diff changeset
    76
      model := 0 asValue.
claus
parents: 49
diff changeset
    77
claus
parents: 49
diff changeset
    78
      top := StandardSystemView extent:200@200.
claus
parents: 49
diff changeset
    79
      top label:'slider on model'.
claus
parents: 49
diff changeset
    80
      sl := SteppingSlider in:top.
claus
parents: 49
diff changeset
    81
      sl origin:(0.0@0.0) corner:(sl width@1.0).
49
claus
parents: 23
diff changeset
    82
      sl model:model.
57
claus
parents: 49
diff changeset
    83
      top open.
claus
parents: 49
diff changeset
    84
claus
parents: 49
diff changeset
    85
      top := StandardSystemView extent:200@200.
claus
parents: 49
diff changeset
    86
      top label:'inputField on model'.
claus
parents: 49
diff changeset
    87
      fld := EditField in:top.
claus
parents: 49
diff changeset
    88
      fld origin:(0.0@0.0) corner:(1.0 @ fld height).
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    89
      fld converter:(PrintConverter new initForNumber); model:model.
49
claus
parents: 23
diff changeset
    90
      top open
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    91
                                                                [exEnd]
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    92
23
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    93
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    94
    two views on the same model:
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    95
                                                                [exBegin]
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    96
      |model top sl fld|
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    97
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    98
      model := 0 asValue.
23
1e6bf473d863 Initial revision
claus
parents:
diff changeset
    99
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   100
      top := StandardSystemView extent:200@200.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   101
      top label:'slider on model'.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   102
      sl := SteppingSlider in:top.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   103
      sl origin:(0.0@0.0) corner:(sl width@1.0).
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   104
      sl model:model.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   105
      top open.
23
1e6bf473d863 Initial revision
claus
parents:
diff changeset
   106
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   107
      top := StandardSystemView extent:200@200.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   108
      top label:'slider on model'.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   109
      sl := ThumbWheel in:top.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   110
      sl origin:(0.0@0.0) corner:(20@1.0).
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   111
      sl model:model.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   112
      top open.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   113
                                                                [exEnd]
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   114
"
49
claus
parents: 23
diff changeset
   115
! !
claus
parents: 23
diff changeset
   116
claus
parents: 23
diff changeset
   117
!SteppingSlider methodsFor:'accessing'!
claus
parents: 23
diff changeset
   118
claus
parents: 23
diff changeset
   119
model:aModel
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   120
    "set the model - forwarded to the thumb.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   121
     if nonNil, this will get the thumbs origin
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   122
     via #value: messages"
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   123
49
claus
parents: 23
diff changeset
   124
    thumb model:aModel
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   125
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   126
    "Modified: 28.5.1997 / 15:07:55 / cg"
57
claus
parents: 49
diff changeset
   127
!
claus
parents: 49
diff changeset
   128
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   129
start:start stop:stop step:step
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   130
    "set start (min), stop (max) and step increment.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   131
     The increment is used when clicking on a step button"
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   132
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   133
    thumb start:start stop:stop.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   134
    stepIncrement := step
57
claus
parents: 49
diff changeset
   135
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   136
    "Modified: 28.5.1997 / 15:03:56 / cg"
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   137
!
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   138
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   139
step
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   140
    "return the step increment.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   141
     The increment is used when clicking on a step button"
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   142
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   143
    ^ stepIncrement
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   144
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   145
    "Modified: 28.5.1997 / 15:04:01 / cg"
65
claus
parents: 57
diff changeset
   146
!
claus
parents: 57
diff changeset
   147
claus
parents: 57
diff changeset
   148
step:aNumber
claus
parents: 57
diff changeset
   149
    "same as stepIncrement;
claus
parents: 57
diff changeset
   150
     set the value used for stepping (defaults to 1)"
claus
parents: 57
diff changeset
   151
claus
parents: 57
diff changeset
   152
    stepIncrement := aNumber
claus
parents: 57
diff changeset
   153
!
claus
parents: 57
diff changeset
   154
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   155
stepIncrement:aNumber 
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   156
    "set the value used for stepping (defaults to 1).
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   157
     Same as #step: for compatibility."
65
claus
parents: 57
diff changeset
   158
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   159
    stepIncrement := aNumber
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   160
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   161
    "Modified: 28.5.1997 / 15:04:25 / cg"
65
claus
parents: 57
diff changeset
   162
! !
claus
parents: 57
diff changeset
   163
claus
parents: 57
diff changeset
   164
!SteppingSlider methodsFor:'events'!
claus
parents: 57
diff changeset
   165
claus
parents: 57
diff changeset
   166
keyPress:key x:x y:y
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   167
    "handle cursor left/right for stepping"
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   168
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   169
    (key == #CursorRight or:[key == #CursorUp]) ifTrue:[
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   170
        self scrollStepUp.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   171
        ^ self
65
claus
parents: 57
diff changeset
   172
    ].
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   173
    (key == #CursorLeft or:[key == #CursorDown]) ifTrue:[
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   174
        self scrollStepDown.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   175
        ^ self
65
claus
parents: 57
diff changeset
   176
    ].
claus
parents: 57
diff changeset
   177
    super keyPress:key x:x y:y
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   178
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   179
    "Modified: 28.5.1997 / 15:08:36 / cg"
65
claus
parents: 57
diff changeset
   180
! !
claus
parents: 57
diff changeset
   181
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   182
!SteppingSlider methodsFor:'initialization'!
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   183
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   184
createElements
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   185
    "create the scroller and the two step buttons"
65
claus
parents: 57
diff changeset
   186
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   187
    self orientation == #horizontal ifTrue:[
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   188
        button1 := ArrowButton leftIn:self.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   189
        button1 name:'LeftButton'.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   190
        button2 := ArrowButton rightIn:self.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   191
        button2 name:'RightButton'.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   192
        thumb := HorizontalSlider in:self.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   193
    ] ifFalse:[
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   194
        button1 := ArrowButton upIn:self.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   195
        button1 name:'UpButton'.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   196
        button2 := ArrowButton downIn:self.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   197
        button2 name:'DownButton'.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   198
        thumb := Slider in:self.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   199
    ].
65
claus
parents: 57
diff changeset
   200
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   201
    "Modified: 28.5.1997 / 15:09:50 / cg"
65
claus
parents: 57
diff changeset
   202
!
claus
parents: 57
diff changeset
   203
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   204
initialize
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   205
    "initialize; the increment is set to 1 (one)"
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   206
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   207
    super initialize.
65
claus
parents: 57
diff changeset
   208
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   209
    stepIncrement := 1.
402
db4b13aff9c9 more code moved to superclass
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   210
    buttonLayout := #around.
db4b13aff9c9 more code moved to superclass
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   211
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   212
    self scrollDownAction:[self scrollStepUp].
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   213
    self scrollUpAction:[self scrollStepDown].
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   214
402
db4b13aff9c9 more code moved to superclass
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   215
    "Modified: 28.5.1997 / 16:12:04 / cg"
23
1e6bf473d863 Initial revision
claus
parents:
diff changeset
   216
! !
1e6bf473d863 Initial revision
claus
parents:
diff changeset
   217
1e6bf473d863 Initial revision
claus
parents:
diff changeset
   218
!SteppingSlider methodsFor:'misc'!
1e6bf473d863 Initial revision
claus
parents:
diff changeset
   219
1e6bf473d863 Initial revision
claus
parents:
diff changeset
   220
doesNotUnderstand:aMessage
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   221
    "forward any unimplemented message to the scroller"
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   222
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   223
    ^ aMessage sendTo:thumb
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   224
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   225
    "Modified: 28.5.1997 / 15:05:37 / cg"
23
1e6bf473d863 Initial revision
claus
parents:
diff changeset
   226
! !
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   227
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   228
!SteppingSlider methodsFor:'private'!
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   229
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   230
scrollStep:delta
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   231
    "step by some delta"
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   232
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   233
    |oldOrg newOrg|
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   234
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   235
    oldOrg := thumb thumbOrigin.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   236
    newOrg := ((oldOrg + delta) max:thumb start) min:thumb stop.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   237
    oldOrg ~= newOrg ifTrue:[
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   238
        thumb thumbOrigin:newOrg.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   239
        thumb tellOthers.
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   240
    ]
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   241
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   242
    "Created: 28.5.1997 / 15:10:51 / cg"
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   243
!
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   244
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   245
scrollStepDown
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   246
    "sent when the step-down button is pressd"
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   247
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   248
    self scrollStep:stepIncrement negated
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   249
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   250
    "Modified: 28.5.1997 / 15:11:02 / cg"
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   251
!
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   252
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   253
scrollStepUp
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   254
    "sent when the step-up button is pressd"
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   255
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   256
    self scrollStep:stepIncrement
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   257
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   258
    "Modified: 28.5.1997 / 15:11:08 / cg"
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   259
! !
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   260
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   261
!SteppingSlider methodsFor:'queries'!
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   262
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   263
orientation
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   264
    ^ #vertical
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   265
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   266
    "Created: 28.5.1997 / 15:11:24 / cg"
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   267
! !
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   268
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   269
!SteppingSlider class methodsFor:'documentation'!
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   270
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   271
version
402
db4b13aff9c9 more code moved to superclass
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   272
    ^ '$Header: /cvs/stx/stx/libwidg2/SteppingSlider.st,v 1.9 1997-05-28 14:21:01 cg Exp $'
400
d176fd820716 merged common code from steppingSlider & horizontalSteppingSlider
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   273
! !