MiniScroller.st
author Claus Gittinger <cg@exept.de>
Tue, 23 Apr 2019 19:19:21 +0200
changeset 6574 6c054f170606
parent 6493 8707ca079e1f
permissions -rw-r--r--
#BUGFIX by cg class: CheckLabel comment/format in: #hasFocus: changed: #hasFocus
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6493
8707ca079e1f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5948
diff changeset
     1
"{ Encoding: utf8 }"
8707ca079e1f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5948
diff changeset
     2
37
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
     3
"
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
     4
 COPYRIGHT (c) 1994 by Claus Gittinger
64
c4e3323a5348 *** empty log message ***
claus
parents: 37
diff changeset
     5
	      All Rights Reserved
37
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
     6
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
     7
 This software is furnished under a license and may be used
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    12
 hereby transferred.
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    13
"
3165
58b08c376a6e *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 1519
diff changeset
    14
"{ Package: 'stx:libwidg' }"
58b08c376a6e *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 1519
diff changeset
    15
5628
57821ff41509 device access
Claus Gittinger <cg@exept.de>
parents: 4901
diff changeset
    16
"{ NameSpace: Smalltalk }"
57821ff41509 device access
Claus Gittinger <cg@exept.de>
parents: 4901
diff changeset
    17
37
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    18
Scroller subclass:#MiniScroller
539
c7c5585e77f6 use common code for H/V miniScrollers
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    19
	instanceVariableNames:''
1305
02af46047b4a allow miniscrollers thickness to be defined in styleSheet
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    20
	classVariableNames:'MiniScrollerSize'
539
c7c5585e77f6 use common code for H/V miniScrollers
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    21
	poolDictionaries:''
c7c5585e77f6 use common code for H/V miniScrollers
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    22
	category:'Views-Interactors'
37
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    23
!
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    24
968
ba32bbfb7aad commentary
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
    25
!MiniScroller class methodsFor:'documentation'!
37
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    26
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    27
copyright
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    28
"
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    29
 COPYRIGHT (c) 1994 by Claus Gittinger
64
c4e3323a5348 *** empty log message ***
claus
parents: 37
diff changeset
    30
	      All Rights Reserved
37
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    31
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    32
 This software is furnished under a license and may be used
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    33
 only in accordance with the terms of that license and with the
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    35
 be provided or otherwise made available to, or used by, any
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    36
 other person.  No title to or ownership of the software is
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    37
 hereby transferred.
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    38
"
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    39
!
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    40
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    41
documentation
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    42
"
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    43
    like a scroller, but taking less screen space
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    44
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    45
    [author:]
1427
f73bcbd3b994 dont let miniscroller become too small (motif style)
Claus Gittinger <cg@exept.de>
parents: 1386
diff changeset
    46
	Claus Gittinger
37
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    47
"
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    48
! !
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    49
1305
02af46047b4a allow miniscrollers thickness to be defined in styleSheet
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    50
!MiniScroller class methodsFor:'defaults'!
02af46047b4a allow miniscrollers thickness to be defined in styleSheet
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    51
02af46047b4a allow miniscrollers thickness to be defined in styleSheet
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    52
updateStyleCache
02af46047b4a allow miniscrollers thickness to be defined in styleSheet
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    53
    "extract values from the styleSheet and cache them in class variables"
02af46047b4a allow miniscrollers thickness to be defined in styleSheet
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    54
1354
c260c896ea66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1305
diff changeset
    55
    <resource: #style (#'miniScroller.size')>
1305
02af46047b4a allow miniscrollers thickness to be defined in styleSheet
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    56
1354
c260c896ea66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1305
diff changeset
    57
    MiniScrollerSize := StyleSheet at:'miniScroller.size'.
1305
02af46047b4a allow miniscrollers thickness to be defined in styleSheet
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    58
02af46047b4a allow miniscrollers thickness to be defined in styleSheet
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    59
    "
02af46047b4a allow miniscrollers thickness to be defined in styleSheet
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    60
     self updateStyleCache
02af46047b4a allow miniscrollers thickness to be defined in styleSheet
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    61
    "
02af46047b4a allow miniscrollers thickness to be defined in styleSheet
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    62
02af46047b4a allow miniscrollers thickness to be defined in styleSheet
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    63
    "Created: 15.8.1997 / 01:51:38 / cg"
1354
c260c896ea66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1305
diff changeset
    64
    "Modified: 20.10.1997 / 15:06:36 / cg"
1305
02af46047b4a allow miniscrollers thickness to be defined in styleSheet
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    65
! !
02af46047b4a allow miniscrollers thickness to be defined in styleSheet
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
    66
130
claus
parents: 119
diff changeset
    67
!MiniScroller methodsFor:'initialization'!
37
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    68
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    69
initStyle
968
ba32bbfb7aad commentary
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
    70
    "setup viewStyle specifics"
ba32bbfb7aad commentary
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
    71
119
claus
parents: 64
diff changeset
    72
    |style lvl|
claus
parents: 64
diff changeset
    73
37
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    74
    super initStyle.
119
claus
parents: 64
diff changeset
    75
    style := StyleSheet name.
37
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    76
    style == #iris ifTrue:[
1519
7be06f0bb911 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1427
diff changeset
    77
        tallyLevel := tallyMarks := 0.
7be06f0bb911 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1427
diff changeset
    78
        thumbEdgeStyle := nil.
7be06f0bb911 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1427
diff changeset
    79
        thumbLevel := thumbActiveLevel := 2.
37
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    80
    ].
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    81
    ((style ~~ #normal) and:[style ~~ #mswindows]) ifTrue:[
1519
7be06f0bb911 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1427
diff changeset
    82
        style == #st80 ifTrue:[
7be06f0bb911 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1427
diff changeset
    83
            lvl := 1.
7be06f0bb911 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1427
diff changeset
    84
            "/ lvl := 0.
7be06f0bb911 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1427
diff changeset
    85
        ] ifFalse:[
7be06f0bb911 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1427
diff changeset
    86
            lvl := -1.
7be06f0bb911 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1427
diff changeset
    87
        ].
7be06f0bb911 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1427
diff changeset
    88
        self level:lvl.
7be06f0bb911 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1427
diff changeset
    89
        self borderWidth:0
37
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    90
    ].
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    91
    shadowForm := lightForm := nil.
1519
7be06f0bb911 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1427
diff changeset
    92
    fixThumbHeight := false.
539
c7c5585e77f6 use common code for H/V miniScrollers
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    93
1519
7be06f0bb911 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1427
diff changeset
    94
    thumbImage := nil.
7be06f0bb911 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1427
diff changeset
    95
7be06f0bb911 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1427
diff changeset
    96
    "Modified: / 12.5.1998 / 20:41:52 / cg"
37
8dd71a2e79cd Initial revision
claus
parents:
diff changeset
    97
! !
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    98
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    99
!MiniScroller methodsFor:'queries'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   100
6493
8707ca079e1f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5948
diff changeset
   101
computePreferredExtent
572
121735c2aff6 commentary
Claus Gittinger <cg@exept.de>
parents: 556
diff changeset
   102
    "return my preferredExtent - make my width very small"
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   103
539
c7c5585e77f6 use common code for H/V miniScrollers
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   104
    |defExt w h mm|
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   105
539
c7c5585e77f6 use common code for H/V miniScrollers
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   106
    defExt := self class defaultExtent.
1114
ddd752f834d5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 968
diff changeset
   107
1305
02af46047b4a allow miniscrollers thickness to be defined in styleSheet
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   108
    (mm := MiniScrollerSize) isNil ifTrue:[
3498
1170b64bde6e default thicknes changed a bit
Claus Gittinger <cg@exept.de>
parents: 3165
diff changeset
   109
        mm := (thumbLevel ~~ 0) ifTrue:[1.8] ifFalse:[1.5].
1170b64bde6e default thicknes changed a bit
Claus Gittinger <cg@exept.de>
parents: 3165
diff changeset
   110
        mm := (thumbLevel ~~ 0) ifTrue:[2.5] ifFalse:[2].
1170b64bde6e default thicknes changed a bit
Claus Gittinger <cg@exept.de>
parents: 3165
diff changeset
   111
        styleSheet name == #st80 ifTrue:[
1170b64bde6e default thicknes changed a bit
Claus Gittinger <cg@exept.de>
parents: 3165
diff changeset
   112
            mm := 2
1170b64bde6e default thicknes changed a bit
Claus Gittinger <cg@exept.de>
parents: 3165
diff changeset
   113
        ].
1305
02af46047b4a allow miniscrollers thickness to be defined in styleSheet
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   114
    ].
02af46047b4a allow miniscrollers thickness to be defined in styleSheet
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
   115
1114
ddd752f834d5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 968
diff changeset
   116
    w := defExt x.
ddd752f834d5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 968
diff changeset
   117
    h := defExt y.
ddd752f834d5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 968
diff changeset
   118
539
c7c5585e77f6 use common code for H/V miniScrollers
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   119
    orientation == #vertical ifTrue:[
5628
57821ff41509 device access
Claus Gittinger <cg@exept.de>
parents: 4901
diff changeset
   120
        w := (device horizontalPixelPerMillimeter asFloat * mm) rounded.
5948
fd5f4677ea52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5628
diff changeset
   121
        "/ don't let it become too small for thumb ...
3498
1170b64bde6e default thicknes changed a bit
Claus Gittinger <cg@exept.de>
parents: 3165
diff changeset
   122
        w := w max:((level abs + thumbLevel) * 2 + 1).
539
c7c5585e77f6 use common code for H/V miniScrollers
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   123
    ] ifFalse:[
5628
57821ff41509 device access
Claus Gittinger <cg@exept.de>
parents: 4901
diff changeset
   124
        h := (device verticalPixelPerMillimeter asFloat * mm) rounded.
5948
fd5f4677ea52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5628
diff changeset
   125
        "/ don't let it become too small for thumb ...
3498
1170b64bde6e default thicknes changed a bit
Claus Gittinger <cg@exept.de>
parents: 3165
diff changeset
   126
        h := h max:((level abs + thumbLevel) * 2 + 1).
539
c7c5585e77f6 use common code for H/V miniScrollers
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   127
    ].
797
2f9cd56f48ee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   128
    preferredExtent := w @ h.
2f9cd56f48ee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   129
    ^ preferredExtent.
539
c7c5585e77f6 use common code for H/V miniScrollers
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   130
6493
8707ca079e1f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5948
diff changeset
   131
    "Created: / 09-11-2018 / 19:57:23 / Claus Gittinger"
8707ca079e1f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5948
diff changeset
   132
!
8707ca079e1f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5948
diff changeset
   133
8707ca079e1f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5948
diff changeset
   134
isMiniScroller
8707ca079e1f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5948
diff changeset
   135
    ^ true
8707ca079e1f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5948
diff changeset
   136
8707ca079e1f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5948
diff changeset
   137
    "Created: 7.3.1997 / 16:20:22 / cg"
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   138
! !
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   139
968
ba32bbfb7aad commentary
Claus Gittinger <cg@exept.de>
parents: 797
diff changeset
   140
!MiniScroller class methodsFor:'documentation'!
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   141
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   142
version
5628
57821ff41509 device access
Claus Gittinger <cg@exept.de>
parents: 4901
diff changeset
   143
    ^ '$Header$'
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   144
! !
4901
4fc7b7366975 class: MiniScroller
Stefan Vogel <sv@exept.de>
parents: 3762
diff changeset
   145