ScrollBar.st
author Claus Gittinger <cg@exept.de>
Fri, 01 Mar 1996 19:44:55 +0100
changeset 447 ed41e1bbd9a1
parent 446 98f38de97099
child 448 e23465aad9e8
permissions -rw-r--r--
also support goto-default (use selection if any)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     1
"
5
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
     3
	      All Rights Reserved
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     4
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    11
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    12
119
claus
parents: 110
diff changeset
    13
SimpleView subclass:#ScrollBar
345
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    14
	instanceVariableNames:'thumb button1 button2 buttonLayout elementSpacing'
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    15
	classVariableNames:'DefaultButtonPositions DefaultLevel DefaultElementSpacing
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    16
		DefaultScrollerBordered'
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    17
	poolDictionaries:''
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    18
	category:'Views-Interactors'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    19
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    20
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    21
!ScrollBar class methodsFor:'documentation'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    22
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    23
copyright
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    24
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    25
 COPYRIGHT (c) 1989 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    26
	      All Rights Reserved
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    27
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    28
 This software is furnished under a license and may be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    29
 only in accordance with the terms of that license and with the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    31
 be provided or otherwise made available to, or used by, any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    32
 other person.  No title to or ownership of the software is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    33
 hereby transferred.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    34
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    35
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    36
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    37
documentation
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    38
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    39
    this class implements vertical scrollbars with scroller and
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    40
    2 step-scroll buttons. when moved or stepped, it performs a
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    41
    predefined action.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    42
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    43
    The action is specified by:                 the block to be evaluated for step-up
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    44
	aScrollBar scrollUpAction:aBlock 
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    45
	(scrollLeftAction for hor-Scrollbars)
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    46
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    47
	aScrollBar scrollDownAction:aBlock      the block to be evaluated for step-down
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    48
	(scrollRightAction for hor-Scrollbars)
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    49
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    50
	aScrollbar scrollAction:aBlock          the block to be evaluated for scroll
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    51
						passing percentage as argument.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    52
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    53
    Scrollbars can scroll syncronous (i.e. every movement is notified immediately via the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    54
    scrollAction) or asynchronous (i.e. only one notification takes place at the end of the movement).
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    55
    The choice is up to the user of the scrollbar (typically, views which are complicated to redraw,
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    56
    will set it to asynchronous.)
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    57
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    58
    Most often scrollbars are used hidden with ScrollableView or HVScrollableView (i.e. you
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    59
    dont have to care for all the details).
128
claus
parents: 119
diff changeset
    60
claus
parents: 119
diff changeset
    61
    The scrollBars and scrollers protocols have been made similar enough to
claus
parents: 119
diff changeset
    62
    allow transparent use of either a scroller or a scrollBar in applications.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    63
"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    64
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    65
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    66
!ScrollBar class methodsFor:'style changes'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    67
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    68
updateStyleCache
440
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
    69
    "extract values from the styleSheet and cache them in class variables"
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
    70
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
    71
    <resource: #style (#scrollBarButtonPositions #scrollBarLevel
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
    72
                       #scrollBarScrollerBordered #scrollBarElementSpacing)>
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
    73
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    74
    DefaultButtonPositions := StyleSheet at:'scrollBarButtonPositions' default:#bottom.
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    75
    DefaultLevel := StyleSheet at:'scrollBarLevel'.
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    76
    DefaultScrollerBordered := StyleSheet at:'scrollBarScrollerBordered' default:false.
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    77
    DefaultElementSpacing := StyleSheet at:'scrollBarElementSpacing' 
440
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
    78
                                        default:(StyleSheet is3D ifTrue:[1] ifFalse:[0]).
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
    79
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
    80
    "Modified: 1.3.1996 / 13:46:29 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    81
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    82
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    83
!ScrollBar methodsFor:'accessing'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    84
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    85
thumbColor:aColor
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    86
    "set the thumbs color"
128
claus
parents: 119
diff changeset
    87
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    88
    thumb thumbColor:aColor
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    89
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    90
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    91
thumbHeight
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    92
    "return height of thumb in percent"
128
claus
parents: 119
diff changeset
    93
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    94
    ^ thumb thumbHeight
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    95
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    96
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    97
thumbHeight:newHeight
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    98
    "set height of thumb in percent"
128
claus
parents: 119
diff changeset
    99
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   100
    thumb thumbHeight:newHeight.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   101
    self enableDisableButtons
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   102
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   103
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   104
thumbOrigin
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   105
    "return position of (top of) thumb in percent"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   106
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   107
    ^ thumb thumbOrigin
128
claus
parents: 119
diff changeset
   108
!
claus
parents: 119
diff changeset
   109
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   110
thumbOrigin:newOrigin
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   111
    "set position of (top of) thumb in percent"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   112
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   113
    thumb thumbOrigin:newOrigin.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   114
    self enableDisableButtons
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   115
!
128
claus
parents: 119
diff changeset
   116
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   117
thumbOrigin:newOrigin thumbHeight:newHeight
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   118
    "set origin and height of thumb (both in percent)"
128
claus
parents: 119
diff changeset
   119
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   120
    thumb thumbOrigin:newOrigin thumbHeight:newHeight.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   121
    self enableDisableButtons
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   122
!
128
claus
parents: 119
diff changeset
   123
133
claus
parents: 130
diff changeset
   124
upButtonLabel:label1 downButtonLabel:label2
446
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   125
    "set the labels shown in the buttons.
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   126
     Because of the fixed button sizes, this only makes sense with 
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   127
     single-character strings or small bitmaps."
133
claus
parents: 130
diff changeset
   128
claus
parents: 130
diff changeset
   129
    button1 label:label1.
claus
parents: 130
diff changeset
   130
    button2 label:label2.
claus
parents: 130
diff changeset
   131
    self setElementPositions.
claus
parents: 130
diff changeset
   132
446
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   133
    "not bad:
133
claus
parents: 130
diff changeset
   134
     |v|
claus
parents: 130
diff changeset
   135
claus
parents: 130
diff changeset
   136
     v := ScrollableView for:EditTextView.
claus
parents: 130
diff changeset
   137
     v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile).
claus
parents: 130
diff changeset
   138
     v scrollBar upButtonLabel:'+' downButtonLabel:'-'.
claus
parents: 130
diff changeset
   139
     v open
claus
parents: 130
diff changeset
   140
    "
446
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   141
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   142
    "also possible :
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   143
     |v|
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   144
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   145
     v := ScrollableView for:EditTextView.
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   146
     v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile).
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   147
     v scrollBar upButtonLabel:'u' downButtonLabel:'d'.
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   148
     v open
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   149
    "
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   150
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   151
    "BAD example:
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   152
     |v|
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   153
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   154
     v := ScrollableView for:EditTextView.
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   155
     v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile).
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   156
     v scrollBar upButtonLabel:'up' downButtonLabel:'down'.
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   157
     v open
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   158
    "
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   159
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   160
    "Modified: 1.3.1996 / 19:06:50 / cg"
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   161
! !
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   162
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   163
!ScrollBar methodsFor:'accessing-behavior'!
133
claus
parents: 130
diff changeset
   164
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   165
asynchronousOperation
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   166
    "set asynchronous-mode - scroll action is performed after movement
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   167
     of scroller (i.e. when mouse-button is finally released).
128
claus
parents: 119
diff changeset
   168
     This is forwarded to the scroller here."
claus
parents: 119
diff changeset
   169
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   170
    thumb asynchronousOperation
128
claus
parents: 119
diff changeset
   171
!
claus
parents: 119
diff changeset
   172
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   173
scrollAction:aBlock
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   174
    "set the action, aBlock to be performed when the scroller is moved.
128
claus
parents: 119
diff changeset
   175
     This is forwarded to the scroller here."
claus
parents: 119
diff changeset
   176
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   177
    thumb scrollAction:aBlock
128
claus
parents: 119
diff changeset
   178
!
claus
parents: 119
diff changeset
   179
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   180
scrollDownAction:aBlock
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   181
    "set the action, aBlock to be performed when the down-button is pressed."
128
claus
parents: 119
diff changeset
   182
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   183
    button2 action:aBlock
128
claus
parents: 119
diff changeset
   184
!
claus
parents: 119
diff changeset
   185
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   186
scrollUpAction:aBlock
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   187
    "set the action, aBlock to be performed when the up-button is pressed."
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
   188
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   189
    button1 action:aBlock
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   190
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   191
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   192
synchronousOperation
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   193
    "set synchronous-mode - scroll action is performed for every movement
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   194
     of scroller.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   195
     This is forwarded to the scroller here."
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   196
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   197
    thumb synchronousOperation
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   198
! !
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   199
446
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   200
!ScrollBar methodsFor:'accessing-components'!
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   201
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   202
downButton
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   203
    "return the down-button
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   204
     (Please: only use this direct access for special applications)"
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   205
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   206
    ^ button2
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   207
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   208
    "
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   209
     |v|
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   210
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   211
     v := ScrollableView for:EditTextView.
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   212
     v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile).
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   213
     v scrollBar upButton activeForegroundColor:Color red.
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   214
     v scrollBar downButton activeForegroundColor:Color red.
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   215
     v open
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   216
    "
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   217
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   218
    "Modified: 1.3.1996 / 19:04:43 / cg"
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   219
!
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   220
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   221
thumb 
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   222
    "return the thumb (i.e. the scroller subview)
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   223
     (Please: only use this direct access for special applications)"
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   224
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   225
    ^ thumb
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   226
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   227
    "
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   228
     |v|
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   229
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   230
     v := ScrollableView for:EditTextView.
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   231
     v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile).
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   232
     v scrollBar thumb thumbColor:(Color red).
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   233
     v open
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   234
    "
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   235
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   236
    "Modified: 1.3.1996 / 19:15:50 / cg"
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   237
!
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   238
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   239
upButton
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   240
    "return the up-button
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   241
     (Please: only use this direct access for special applications)"
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   242
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   243
    ^ button1
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   244
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   245
    "
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   246
     |v|
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   247
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   248
     v := ScrollableView for:EditTextView.
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   249
     v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile).
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   250
     v scrollBar upButton foregroundColor:(Color red).
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   251
     v scrollBar upButton enteredForegroundColor:(Color red lightened).
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   252
     v scrollBar downButton foregroundColor:(Color green).
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   253
     v scrollBar downButton enteredForegroundColor:(Color green lightened).
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   254
     v open
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   255
    "
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   256
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   257
    "Modified: 1.3.1996 / 19:04:48 / cg"
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   258
! !
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   259
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   260
!ScrollBar methodsFor:'change & update'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   261
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   262
update:something with:aParameter from:changedObject
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   263
    changedObject == thumb ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   264
	self enableDisableButtons
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   265
    ]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   266
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   267
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   268
!ScrollBar methodsFor:'events'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   269
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   270
sizeChanged:how
128
claus
parents: 119
diff changeset
   271
    "when my size changes, I have to resize/reposition the subviews.
claus
parents: 119
diff changeset
   272
     Also, if I became too small, hide thumb/buttons."
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   273
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   274
    |upHeight downHeight thumbHeight upAndDownHeight bwn sep2
130
claus
parents: 128
diff changeset
   275
     thumbWidth w style b1Hidden b2Hidden thumbHidden bY|
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   276
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   277
    button1 isNil ifTrue:[^ self].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   278
    thumb isNil ifTrue:[^ self].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   279
    button2 isNil ifTrue:[^ self].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   280
130
claus
parents: 128
diff changeset
   281
    style := styleSheet name.
128
claus
parents: 119
diff changeset
   282
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   283
    upHeight := button1 height + borderWidth.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   284
    downHeight := button2 height + borderWidth.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   285
    upAndDownHeight := upHeight + downHeight.
3
claus
parents: 0
diff changeset
   286
    bwn := borderWidth negated + margin.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   287
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   288
    thumbHeight := height - upAndDownHeight - borderWidth - (elementSpacing * 3).
3
claus
parents: 0
diff changeset
   289
"
130
claus
parents: 128
diff changeset
   290
    ((buttonLayout ~~ #top) and:[buttonLayout ~~ #bottom]) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   291
	thumbHeight := thumbHeight - borderWidth
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   292
    ].
3
claus
parents: 0
diff changeset
   293
"
130
claus
parents: 128
diff changeset
   294
    buttonLayout == #around ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   295
	thumbHeight := thumbHeight + borderWidth
3
claus
parents: 0
diff changeset
   296
    ].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   297
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   298
    "if I become too small, hide buttons and thumb"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   299
130
claus
parents: 128
diff changeset
   300
    height < upAndDownHeight ifTrue:[
claus
parents: 128
diff changeset
   301
	b1Hidden := b2Hidden := thumbHidden := true.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   302
    ] ifFalse:[
130
claus
parents: 128
diff changeset
   303
	b1Hidden := b2Hidden := thumbHidden := false.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   304
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   305
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   306
    (thumbHeight < 10) ifTrue:[
130
claus
parents: 128
diff changeset
   307
	thumbHidden := true.
claus
parents: 128
diff changeset
   308
    ] ifFalse:[
claus
parents: 128
diff changeset
   309
	thumbHidden := false.
claus
parents: 128
diff changeset
   310
    ].
claus
parents: 128
diff changeset
   311
claus
parents: 128
diff changeset
   312
    button1 hiddenOnRealize:b1Hidden.
claus
parents: 128
diff changeset
   313
    b1Hidden ifTrue:[
claus
parents: 128
diff changeset
   314
	button1 unrealize
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   315
    ] ifFalse:[
130
claus
parents: 128
diff changeset
   316
	shown ifTrue:[button1 realize]
claus
parents: 128
diff changeset
   317
    ].
claus
parents: 128
diff changeset
   318
    button2 hiddenOnRealize:b1Hidden.
claus
parents: 128
diff changeset
   319
    b2Hidden ifTrue:[
claus
parents: 128
diff changeset
   320
	button2 unrealize
claus
parents: 128
diff changeset
   321
    ] ifFalse:[
claus
parents: 128
diff changeset
   322
	shown ifTrue:[button2 realize]
claus
parents: 128
diff changeset
   323
    ].
claus
parents: 128
diff changeset
   324
    thumb hiddenOnRealize:thumbHidden.
claus
parents: 128
diff changeset
   325
    thumbHidden ifTrue:[
claus
parents: 128
diff changeset
   326
	thumb unrealize
claus
parents: 128
diff changeset
   327
    ] ifFalse:[
claus
parents: 128
diff changeset
   328
	shown ifTrue:[thumb realize]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   329
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   330
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   331
    "width of buttons is always my width"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   332
3
claus
parents: 0
diff changeset
   333
    w := width - (margin * 2).
claus
parents: 0
diff changeset
   334
    (w ~~ button1 width) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   335
	button1 width:w.
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   336
	button2 width:w
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   337
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   338
3
claus
parents: 0
diff changeset
   339
    thumbWidth := w.
128
claus
parents: 119
diff changeset
   340
    style == #next ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   341
	thumbWidth := thumbWidth - (thumb borderWidth * 2).
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   342
	thumbHeight := thumbHeight - 1
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   343
    ].
128
claus
parents: 119
diff changeset
   344
    style == #motif ifTrue:[
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   345
	thumbHeight := thumbHeight - margin
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   346
    ].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   347
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   348
    "
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   349
     a kludge: views with width or height of 0 are illegal
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   350
     avoid error from view-creation (it will be hidden anyway)
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   351
    "
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   352
    thumbHeight <= 0 ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   353
	thumbHeight := 1
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   354
    ].
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   355
130
claus
parents: 128
diff changeset
   356
    (buttonLayout == #top) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   357
	"buttons at top"
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   358
	thumb extent:(thumbWidth @ thumbHeight).
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   359
	^ self
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   360
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   361
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   362
    sep2 := elementSpacing * 2.
130
claus
parents: 128
diff changeset
   363
    (buttonLayout == #bottom) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   364
	"buttons at bottom"
143
claus
parents: 140
diff changeset
   365
"/
claus
parents: 140
diff changeset
   366
"/ XX: I thought, that viewGravity shuld fix things automatically
claus
parents: 140
diff changeset
   367
"/ XX: it seems not to do it (or I misused it ;-)
claus
parents: 140
diff changeset
   368
"/ XX: anyway, viewGravity is an X special feature which is probably
claus
parents: 140
diff changeset
   369
"/ XX: not available with other windowing systems. Therefore,
claus
parents: 140
diff changeset
   370
"/ XX: the viewGravity depending code below is disabled.
claus
parents: 140
diff changeset
   371
"/ XX: resize is somewhat slower, though.
claus
parents: 140
diff changeset
   372
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   373
	thumbHeight := thumbHeight + borderWidth.
143
claus
parents: 140
diff changeset
   374
"/ XX        thumbHidden ifTrue:[
claus
parents: 140
diff changeset
   375
"/ XX           bY := elementSpacing
claus
parents: 140
diff changeset
   376
"/ XX       ] ifFalse:[
130
claus
parents: 128
diff changeset
   377
	    bY := thumbHeight + sep2.
143
claus
parents: 140
diff changeset
   378
"/ XX       ].
claus
parents: 140
diff changeset
   379
"XX"            button1 viewGravity:#North. 
claus
parents: 140
diff changeset
   380
"XX"            button2 viewGravity:#North. 
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   381
	(how == #smaller) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   382
	    thumb extent:(thumbWidth @ thumbHeight).
143
claus
parents: 140
diff changeset
   383
"XX"            button1 origin:(bwn @ (thumbHeight + sep2)).
claus
parents: 140
diff changeset
   384
"XX"            button2 origin:(bwn @ (thumbHeight + sep2 + upHeight))
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   385
	] ifFalse:[
130
claus
parents: 128
diff changeset
   386
	    button1 origin:(bwn @ bY).
claus
parents: 128
diff changeset
   387
	    button2 origin:(bwn @ (bY + upHeight)).
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   388
	    thumb extent:(thumbWidth @ thumbHeight)
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   389
	].
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   390
	^ self
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   391
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   392
    "buttons around thumb"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   393
128
claus
parents: 119
diff changeset
   394
    style == #motif ifTrue:[
claus
parents: 119
diff changeset
   395
	sep2 := sep2 + 1
claus
parents: 119
diff changeset
   396
    ].
3
claus
parents: 0
diff changeset
   397
    button1 origin:(bwn @ bwn).
128
claus
parents: 119
diff changeset
   398
claus
parents: 119
diff changeset
   399
    style == #os2 ifTrue:[
claus
parents: 119
diff changeset
   400
	button2 origin:(bwn @ (upHeight + thumbHeight + sep2 - margin "+ borderWidth")).
claus
parents: 119
diff changeset
   401
	thumb extent:(thumbWidth @ (thumbHeight - margin - margin "+ margin - (margin // 2)")).
claus
parents: 119
diff changeset
   402
	thumb origin:(bwn @ (upHeight - borderWidth + elementSpacing + margin))
claus
parents: 119
diff changeset
   403
    ] ifFalse:[
claus
parents: 119
diff changeset
   404
	button2 origin:(bwn @ (upHeight + thumbHeight + sep2 - (margin // 2) "+ borderWidth")).
claus
parents: 119
diff changeset
   405
	thumb extent:(thumbWidth @ (thumbHeight + margin - (margin // 2))).
claus
parents: 119
diff changeset
   406
	thumb origin:(bwn @ (upHeight - borderWidth + elementSpacing))
claus
parents: 119
diff changeset
   407
    ].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   408
! !
110
eb59f6e31e84 *** empty log message ***
claus
parents: 77
diff changeset
   409
eb59f6e31e84 *** empty log message ***
claus
parents: 77
diff changeset
   410
!ScrollBar methodsFor:'forced scroll'!
eb59f6e31e84 *** empty log message ***
claus
parents: 77
diff changeset
   411
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   412
pageDown
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   413
    "page down/right"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   414
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   415
    thumb pageDown
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   416
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   417
110
eb59f6e31e84 *** empty log message ***
claus
parents: 77
diff changeset
   418
pageUp
eb59f6e31e84 *** empty log message ***
claus
parents: 77
diff changeset
   419
    "page up/left"
eb59f6e31e84 *** empty log message ***
claus
parents: 77
diff changeset
   420
eb59f6e31e84 *** empty log message ***
claus
parents: 77
diff changeset
   421
    thumb pageUp
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   422
! !
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   423
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   424
!ScrollBar methodsFor:'initialization'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   425
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   426
computeInitialExtent
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   427
    "compute my extent from sub-components"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   428
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   429
    self extent:(self preferredExtent).
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   430
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   431
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   432
createElements
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   433
    button1 := ArrowButton upIn:self.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   434
    button2 := ArrowButton downIn:self.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   435
    thumb := Scroller in:self.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   436
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   437
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   438
initStyle
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   439
    super initStyle.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   440
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   441
    buttonLayout := DefaultButtonPositions.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   442
    DefaultLevel notNil ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   443
	self level:DefaultLevel
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   444
    ].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   445
    elementSpacing := DefaultElementSpacing
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   446
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   447
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   448
initialize
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   449
    "setup; create the 2 buttons and a scroller"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   450
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   451
    |clr style|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   452
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   453
    super initialize.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   454
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   455
    self createElements.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   456
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   457
    (styleSheet at:'scrollBarDisableButtons' default:false) ifTrue:[
345
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   458
        thumb addDependent:self
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   459
    ].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   460
345
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   461
    button1 autoRepeat:true.
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   462
    button2 autoRepeat:true.
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   463
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   464
    self computeInitialExtent.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   465
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   466
    button1 borderWidth:borderWidth.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   467
    DefaultScrollerBordered ifFalse:[
345
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   468
        thumb borderWidth:borderWidth.
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   469
    ].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   470
    button2 borderWidth:borderWidth.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   471
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   472
    style := styleSheet name.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   473
    ((style = #iris) and:[Display hasGreyscales]) ifTrue:[
345
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   474
        "have to change some of Buttons defaults"
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   475
        clr := (Color grey:25) on:device.
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   476
        button1 offLevel:2.
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   477
        button2 offLevel:2.
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   478
        button1 foregroundColor:clr.
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   479
        button1 activeForegroundColor:clr.
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   480
        button1 enteredForegroundColor:clr.
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   481
        button2 foregroundColor:clr.
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   482
        button2 activeForegroundColor:clr.
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   483
        button2 enteredForegroundColor:clr.
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   484
    ].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   485
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   486
    self setElementPositions.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   487
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   488
    style = #motif ifTrue:[
345
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   489
        clr := thumb thumbColor.
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   490
        button1 foregroundColor:clr.
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   491
        button2 foregroundColor:clr.
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   492
345
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   493
        clr := thumb viewBackground.
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   494
        button1 viewBackground:clr.
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   495
        button2 viewBackground:clr.
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   496
        button1 backgroundColor:clr.
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   497
        button2 backgroundColor:clr.
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   498
        button1 activeBackgroundColor:clr.
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   499
        button2 activeBackgroundColor:clr.
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   500
        device hasGreyscales ifFalse:[
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   501
            button1 activeForegroundColor:Black.
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   502
            button2 activeForegroundColor:Black.
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   503
        ]
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   504
    ]
345
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   505
00abc00e73a9 use #autoRepeat:
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   506
    "Modified: 9.2.1996 / 22:42:16 / cg"
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   507
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   508
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   509
reinitialize
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   510
    super reinitialize.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   511
    self setElementPositions.
110
eb59f6e31e84 *** empty log message ***
claus
parents: 77
diff changeset
   512
!
eb59f6e31e84 *** empty log message ***
claus
parents: 77
diff changeset
   513
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   514
setElementPositions
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   515
    "position sub-components"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   516
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   517
    |bwn|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   518
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   519
    bwn := borderWidth negated + margin.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   520
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   521
    (buttonLayout == #top) ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   522
	button1 origin:(bwn @ bwn).
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   523
	button1 viewGravity:#North.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   524
	button2 origin:(bwn @ (button1 height)).
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   525
	button2 viewGravity:#North.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   526
	thumb origin:(bwn @ (button1 height 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   527
			     + borderWidth 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   528
			     + button2 height 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   529
			     + elementSpacing 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   530
			     + elementSpacing)).
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   531
	thumb viewGravity:#North.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   532
	^ self
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   533
    ].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   534
    (buttonLayout == #bottom) ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   535
	device supportsViewGravity ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   536
	    button1 viewGravity:#South. 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   537
	    button2 viewGravity:#South. 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   538
	    thumb viewGravity:#North.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   539
	].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   540
	thumb origin:(bwn @ bwn).
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   541
	^ self
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   542
    ].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   543
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   544
    "buttonLayout == #around"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   545
    button1 origin:(bwn @ bwn).
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   546
    button1 viewGravity:#North.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   547
"/    button2 viewGravity:#North.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   548
    thumb origin:(bwn @ (button1 height + elementSpacing)).
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   549
    thumb viewGravity:#North
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   550
! !
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   551
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   552
!ScrollBar methodsFor:'private'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   553
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   554
enableDisableButtons
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   555
    "only used with styles which disable their buttons if the
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   556
     thumb is at either end. Check where the thumb is and enable/disable
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   557
     as appropriate."
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   558
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   559
    |e1 e2 th to|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   560
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   561
    (styleSheet at:'scrollBarDisableButtons' default:false) ifFalse:[^ self].
110
eb59f6e31e84 *** empty log message ***
claus
parents: 77
diff changeset
   562
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   563
    e1 := e2 := true.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   564
    (th := thumb thumbHeight) notNil ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   565
	(th >= (thumb stop)) ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   566
	    e1 := false.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   567
	    e2 := false
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   568
	]
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   569
    ].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   570
    ((to := thumb thumbOrigin) <= thumb start) ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   571
	e1 := false
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   572
    ] ifFalse:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   573
	th isNil ifTrue:[th := 0].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   574
	(to + th) >= thumb stop ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   575
	    e2 := false
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   576
	]
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   577
    ].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   578
    e1 ifTrue:[button1 enable] ifFalse:[button1 disable].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   579
    e2 ifTrue:[button2 enable] ifFalse:[button2 disable].
446
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   580
!
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   581
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   582
setThumbHeightFor:aView
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   583
    "adjust thumbs height for aViews size & contents.
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   584
     This is forwarded to the scroller here."
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   585
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   586
    thumb setThumbHeightFor:aView.
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   587
    self enableDisableButtons
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   588
! !
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   589
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   590
!ScrollBar methodsFor:'private scrollView interface'!
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   591
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   592
setThumbFor:aView
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   593
    "adjust thumb for aView 
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   594
     (i.e. adjust thumbs origin & size for views size & views contents).
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   595
     This is forwarded to the scroller here."
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   596
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   597
    thumb setThumbFor:aView.
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   598
    self enableDisableButtons
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   599
!
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   600
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   601
setThumbOriginFor:aView
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   602
    "adjust thumbs origin for aViews size & contents.
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   603
     This is forwarded to the scroller here."
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   604
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   605
    thumb setThumbOriginFor:aView.
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   606
    self enableDisableButtons
110
eb59f6e31e84 *** empty log message ***
claus
parents: 77
diff changeset
   607
! !
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   608
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   609
!ScrollBar methodsFor:'queries'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   610
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   611
preferredExtent
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   612
    "compute my extent from sub-components"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   613
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   614
    |w h upForm downForm
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   615
     upHeight   "{ Class: SmallInteger }"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   616
     downHeight "{ Class: SmallInteger }"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   617
     upWidth downWidth style|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   618
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   619
    "
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   620
     need fix - this is a kludge;
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   621
     the if should not be needed ...
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   622
    "
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   623
    style := styleSheet name.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   624
    style == #mswindows ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   625
	w := button1 width max:button2 width.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   626
	h := button1 height + button2 height + (Scroller defaultExtent y).
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   627
    ] ifFalse:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   628
	upForm  := ArrowButton upArrowButtonForm:style on:device.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   629
	downForm := ArrowButton downArrowButtonForm:style on:device.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   630
	upForm isNil ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   631
	    upHeight := upWidth := 16.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   632
	] ifFalse:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   633
	    upHeight := upForm height.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   634
	    upWidth := upForm width
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   635
	].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   636
	downForm isNil ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   637
	    downHeight := downWidth := 16
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   638
	] ifFalse:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   639
	    downHeight := downForm height.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   640
	    downWidth := downForm width
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   641
	].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   642
	h := upHeight + downHeight + (1 * 2) + (Scroller defaultExtent y).
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   643
	w := upWidth max:downWidth.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   644
	style ~~ #normal ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   645
	    h := h + 4.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   646
	    w := w + 4
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   647
	].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   648
    ].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   649
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   650
    ^ w @ h.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   651
! !
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   652
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   653
!ScrollBar class methodsFor:'documentation'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   654
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   655
version
446
98f38de97099 category organization
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   656
    ^ '$Header: /cvs/stx/stx/libwidg/ScrollBar.st,v 1.23 1996-03-01 18:16:26 cg Exp $'
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   657
! !