ListModelView.st
author Claus Gittinger <cg@exept.de>
Mon, 06 May 2002 07:59:05 +0200
changeset 2097 78bfd62fdcbc
parent 1995 ede7d0221fa0
child 2099 64402b3555eb
permissions -rw-r--r--
on: -> onDevice:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1431
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     1
"
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     2
 COPYRIGHT (c) 1999 by eXept Software AG
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     3
              All Rights Reserved
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     4
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     5
 This software is furnished under a license and may be used
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     6
 only in accordance with the terms of that license and with the
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     8
 be provided or otherwise made available to, or used by, any
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     9
 other person.  No title to or ownership of the software is
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    10
 hereby transferred.
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    11
"
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    12
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    13
1752
1c11b6e4ab37 use isHierarchicalItem instead of hack variable
ca
parents: 1748
diff changeset
    14
"{ Package: 'stx:libwidg2' }"
1c11b6e4ab37 use isHierarchicalItem instead of hack variable
ca
parents: 1748
diff changeset
    15
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
View subclass:#ListModelView
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	instanceVariableNames:'list listHolder textStartLeft viewOrigin enabled fgColor bgColor
1399
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
    18
		lineSpacing widthOfContents computeWidthInRange startOfLinesY
1827
54e8a0fc8a42 scrollWhenUpdating
Claus Gittinger <cg@exept.de>
parents: 1820
diff changeset
    19
		displayedFrames syncronizeEvents autoScroll autoScrollBlock
54e8a0fc8a42 scrollWhenUpdating
Claus Gittinger <cg@exept.de>
parents: 1820
diff changeset
    20
		scrollWhenUpdating'
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	classVariableNames:'DefaultForegroundColor DefaultBackgroundColor DefaultShadowColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
		DefaultLightColor StopRedrawSignal'
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
	poolDictionaries:''
1430
ae9e48cc7b9d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
    24
	category:'Views-Lists'
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
!ListModelView class methodsFor:'documentation'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
1431
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    29
copyright
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    30
"
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    31
 COPYRIGHT (c) 1999 by eXept Software AG
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    32
              All Rights Reserved
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    33
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    34
 This software is furnished under a license and may be used
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    35
 only in accordance with the terms of that license and with the
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    36
 inclusion of the above copyright notice.   This software may not
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    37
 be provided or otherwise made available to, or used by, any
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    38
 other person.  No title to or ownership of the software is
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    39
 hereby transferred.
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    40
"
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    41
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    42
!
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    43
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
documentation
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
"
1431
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    46
    This widget is a new improved revision of the good-old ListView.
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    47
    In contrast to ListView, this one reacts on changes of the
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    48
    underlying model and performs optimized redraws.
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    49
    It requires a List (or alike) as model.
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    50
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
    This class can only passively display collections of elements.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
    The class doesn't keep its own list, it works directly on
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    the model( List or HierarchicalList ).
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    Each list item is obligated to provide 3 services:
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
        - heightOn:aGC
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
        - widthOn:aGC
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
        - displayOn:aGC x:x y:y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
    [Instance variables:]
1399
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
    61
        list                   <List-Model>     List or HierarchicalList ...
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
    62
        listHolder             <Model>          Model, which keeps a List
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
    63
        textStartLeft          <Number>         left inset of text
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
    64
        viewOrigin             <Point>          the current origin
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
    65
        enabled                <Boolean>        widget is enabled/disabeled
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
    66
        fgColor                <Color>          color to draw characters
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
    67
        bgColor                <Color>          the background
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
    68
        lineSpacing            <Number>         pixels between lines
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
    69
        widthOfContents        <Number>         cached width of widest line
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
    70
        computeWidthInRange    <Point>          used for recompute width of contents
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
    71
        startOfLinesY          <Collection>     keeps all the absolute Y-start positions
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
                                                for each line in the list. The first
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
                                                entry into the list is the top Y inset.
1399
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
    74
        supportsDisplayInRange <Boolean>        set to true if the list elements
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
    75
                                                supports the service:
1535
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
    76
                                                    #displayOn:x:y:h:
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
    77
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
    78
        displayedFrames        <WeakIdentityDictionary>
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
    79
                                                keep the frames within the widget
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
    81
        syncronizeEvents       <Boolean>        set to true if list and model changes
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
    82
                                                should be handled synchronized; an event
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
    83
                                                will be pushed on the event loop.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
    84
                                                on default it is disabled.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
    85
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    [author:]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
        Claus Atzkern
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    [see also:]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
        SelectionInListModelView
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
        HierarchicalListView
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
        List
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
        HierarchicalList
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
examples
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
                                                                        [exBegin]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
    |top list view up index|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
    list := List new.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
    top  := StandardSystemView new; extent:300@300.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
    view := ScrollableView for:ListModelView miniScroller:true
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
                        origin:0.0@0.0 corner:1.0@1.0 in:top.
1827
54e8a0fc8a42 scrollWhenUpdating
Claus Gittinger <cg@exept.de>
parents: 1820
diff changeset
   111
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    view list:list.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    top  openAndWait.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    up := true.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
    [top shown] whileTrue:[
1399
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   117
        Delay waitForSeconds:0.2.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
        up ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
            index := 1 + (list size).
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
            list add:('element: ', index printString).
1827
54e8a0fc8a42 scrollWhenUpdating
Claus Gittinger <cg@exept.de>
parents: 1820
diff changeset
   122
            up := index < 20
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
        ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
            list removeIndex:1.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
            up := list isEmpty.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
                                                                        [exEnd]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
!ListModelView class methodsFor:'initialization'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
initialize
1409
e46f8d30a9c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   137
    "setup the signals
e46f8d30a9c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   138
    "
e46f8d30a9c9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   139
    super initialize.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
1736
eda99db343be StopRedrawSignal is a Notification, not an Error.
Stefan Vogel <sv@exept.de>
parents: 1732
diff changeset
   141
    StopRedrawSignal := Notification newSignalMayProceed:false.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
!ListModelView class methodsFor:'Signal constants'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
stopRedrawSignal
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
    ^ StopRedrawSignal
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
!ListModelView class methodsFor:'defaults'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
updateStyleCache
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
    "extract values from the styleSheet and cache them in class variables"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
    <resource: #style   (
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
                        #'text.backgroundColor'  #'text.foregroundColor'
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
                        #'selection.shadowColor' #'selection.lightColor'
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
                        #'text.font'
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
                        )>
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
    DefaultForegroundColor         := StyleSheet colorAt:'text.foregroundColor' default:Black.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
    DefaultBackgroundColor         := StyleSheet colorAt:'text.backgroundColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
    DefaultShadowColor             := StyleSheet colorAt:'selection.shadowColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
    DefaultLightColor              := StyleSheet colorAt:'selection.lightColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
    DefaultFont                    := StyleSheet  fontAt:'text.font'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
     self updateStyleCache
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
!ListModelView methodsFor:'accessing'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
list
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
    "get the list of items
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
    ^ list
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
list:aList
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
    "set the list of items
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
    "
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   187
    |size negatedOrg|
1443
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   188
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   189
    self syncFlushEvent:#syncUpdate:with:.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
1535
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   191
    displayedFrames keys do:[:aView| aView destroy].
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   192
    displayedFrames := WeakIdentityDictionary new.
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   193
1452
Claus Gittinger <cg@exept.de>
parents: 1451
diff changeset
   194
    list ~~ aList ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1451
diff changeset
   195
        list removeDependent:self.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
    ].
1452
Claus Gittinger <cg@exept.de>
parents: 1451
diff changeset
   197
    (list := aList) notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1451
diff changeset
   198
        list addDependent:self
Claus Gittinger <cg@exept.de>
parents: 1451
diff changeset
   199
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
    self recomputeHeightOfContents.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
    preferredExtent := nil.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
    widthOfContents := nil.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
1827
54e8a0fc8a42 scrollWhenUpdating
Claus Gittinger <cg@exept.de>
parents: 1820
diff changeset
   205
    scrollWhenUpdating == #beginOfText ifTrue:[
54e8a0fc8a42 scrollWhenUpdating
Claus Gittinger <cg@exept.de>
parents: 1820
diff changeset
   206
        viewOrigin = (0@0) ifFalse:[
54e8a0fc8a42 scrollWhenUpdating
Claus Gittinger <cg@exept.de>
parents: 1820
diff changeset
   207
            self originWillChange.
54e8a0fc8a42 scrollWhenUpdating
Claus Gittinger <cg@exept.de>
parents: 1820
diff changeset
   208
            negatedOrg := viewOrigin negated.
54e8a0fc8a42 scrollWhenUpdating
Claus Gittinger <cg@exept.de>
parents: 1820
diff changeset
   209
            viewOrigin := (0@0).
54e8a0fc8a42 scrollWhenUpdating
Claus Gittinger <cg@exept.de>
parents: 1820
diff changeset
   210
            self originChanged:negatedOrg.
54e8a0fc8a42 scrollWhenUpdating
Claus Gittinger <cg@exept.de>
parents: 1820
diff changeset
   211
        ].
54e8a0fc8a42 scrollWhenUpdating
Claus Gittinger <cg@exept.de>
parents: 1820
diff changeset
   212
    ] ifFalse:[
54e8a0fc8a42 scrollWhenUpdating
Claus Gittinger <cg@exept.de>
parents: 1820
diff changeset
   213
        scrollWhenUpdating == #endOfText ifTrue:[
54e8a0fc8a42 scrollWhenUpdating
Claus Gittinger <cg@exept.de>
parents: 1820
diff changeset
   214
            self scrollTo:(0 @ self heightOfContents - self innerHeight) redraw:false
54e8a0fc8a42 scrollWhenUpdating
Claus Gittinger <cg@exept.de>
parents: 1820
diff changeset
   215
        ]
1422
98c0e3978fcf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   216
    ].
1827
54e8a0fc8a42 scrollWhenUpdating
Claus Gittinger <cg@exept.de>
parents: 1820
diff changeset
   217
1422
98c0e3978fcf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   218
    self invalidate.
1457
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   219
    self contentsChanged
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
1818
fe99c5c721e9 category changes
Claus Gittinger <cg@exept.de>
parents: 1796
diff changeset
   223
!ListModelView methodsFor:'accessing-behavior'!
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
1748
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
   225
autoScroll
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
   226
    "returns true if auto scrolling is enabled
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
   227
    "
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
   228
    ^ autoScroll
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
   229
!
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
   230
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
   231
autoScroll:aBool
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
   232
    "returns true if auto scrolling is enabled
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
   233
    "
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
   234
    autoScroll := aBool ? true.
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
   235
!
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
   236
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
enabled
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
   "returns the enabled state
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
   "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
   ^ enabled
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
enabled:aBoolean
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
   "set the enabled state
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
   "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
   enabled := aBoolean
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
1742
28c2834d7c3c add #scrollWhenUpdating: - but not yet supported
ca
parents: 1736
diff changeset
   251
!
28c2834d7c3c add #scrollWhenUpdating: - but not yet supported
ca
parents: 1736
diff changeset
   252
28c2834d7c3c add #scrollWhenUpdating: - but not yet supported
ca
parents: 1736
diff changeset
   253
scrollWhenUpdating:aSymbolOrNil
28c2834d7c3c add #scrollWhenUpdating: - but not yet supported
ca
parents: 1736
diff changeset
   254
    "define how to scroll, when I get a new text 
28c2834d7c3c add #scrollWhenUpdating: - but not yet supported
ca
parents: 1736
diff changeset
   255
     (via the model or the #contents/#list)
28c2834d7c3c add #scrollWhenUpdating: - but not yet supported
ca
parents: 1736
diff changeset
   256
     Allowed arguments are:
28c2834d7c3c add #scrollWhenUpdating: - but not yet supported
ca
parents: 1736
diff changeset
   257
        #keep / nil     -> no change
28c2834d7c3c add #scrollWhenUpdating: - but not yet supported
ca
parents: 1736
diff changeset
   258
        #endOfText      -> scroll to the end
28c2834d7c3c add #scrollWhenUpdating: - but not yet supported
ca
parents: 1736
diff changeset
   259
        #beginOfText    -> scroll to the top
28c2834d7c3c add #scrollWhenUpdating: - but not yet supported
ca
parents: 1736
diff changeset
   260
     The default is #beginOfText.
28c2834d7c3c add #scrollWhenUpdating: - but not yet supported
ca
parents: 1736
diff changeset
   261
     This may be useful for fields which get new values assigned from
28c2834d7c3c add #scrollWhenUpdating: - but not yet supported
ca
parents: 1736
diff changeset
   262
     the program (i.e. not from the user)
28c2834d7c3c add #scrollWhenUpdating: - but not yet supported
ca
parents: 1736
diff changeset
   263
    "
28c2834d7c3c add #scrollWhenUpdating: - but not yet supported
ca
parents: 1736
diff changeset
   264
1827
54e8a0fc8a42 scrollWhenUpdating
Claus Gittinger <cg@exept.de>
parents: 1820
diff changeset
   265
    scrollWhenUpdating := aSymbolOrNil
1742
28c2834d7c3c add #scrollWhenUpdating: - but not yet supported
ca
parents: 1736
diff changeset
   266
28c2834d7c3c add #scrollWhenUpdating: - but not yet supported
ca
parents: 1736
diff changeset
   267
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
1818
fe99c5c721e9 category changes
Claus Gittinger <cg@exept.de>
parents: 1796
diff changeset
   270
!ListModelView methodsFor:'accessing-items'!
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
at:anIndex
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
    "return the list element at an index
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
    ^ list at:anIndex
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
at:anIndex ifAbsent:exceptionBlock
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
    "return the list element at an index if valid. 
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
     If the index is invalid, return the result of evaluating 
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
     the exceptionblock.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
    list notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
        ^ list at:anIndex ifAbsent:exceptionBlock
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
    ^ nil.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
identityIndexOf:anElement
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
    "returns the index of an element or nil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
    ^ list notNil ifTrue:[list identityIndexOf:anElement]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
                 ifFalse:[0]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
1818
fe99c5c721e9 category changes
Claus Gittinger <cg@exept.de>
parents: 1796
diff changeset
   298
!ListModelView methodsFor:'accessing-look'!
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
backgroundColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
    "get the background color
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
    ^ bgColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
backgroundColor:aColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
    "set the background color
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
    (aColor notNil and:[bgColor ~~ aColor]) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
        super viewBackground:bgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
        self realized ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
            bgColor := aColor on:device.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
            self invalidate
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
        ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
            bgColor := aColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
    ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
font:aFont
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
    "set a new font
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
    |oldWidth oldHeight|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
    (aFont isNil or:[aFont = font]) ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
        oldWidth  := font width.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
        oldHeight := font height.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   332
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   333
        super font:aFont.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
1845
3eedddfdfc54 dont ask deviceIndependent font for its dimension
martin
parents: 1832
diff changeset
   335
        (font widthOn:device) ~~ oldWidth ifTrue:[       "/ force a recomputation
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
            preferredExtent := nil.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
            widthOfContents := nil.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
        ].
1845
3eedddfdfc54 dont ask deviceIndependent font for its dimension
martin
parents: 1832
diff changeset
   339
        oldHeight ~~ (font heightOn:device) ifTrue:[
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
            self recomputeHeightOfContents.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
        shown ifTrue:[ self invalidate ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
foregroundColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
    "get the foreground color
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
    ^ fgColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
foregroundColor:aColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
    "set the foreground color
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
    (aColor notNil and:[fgColor ~~ aColor]) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
        self realized ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   358
            fgColor := aColor on:device.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
            self invalidate
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
        ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
            fgColor := aColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
    ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
1945
694ea5d18b60 add access methods for lineSpacing
martin
parents: 1845
diff changeset
   365
!
694ea5d18b60 add access methods for lineSpacing
martin
parents: 1845
diff changeset
   366
694ea5d18b60 add access methods for lineSpacing
martin
parents: 1845
diff changeset
   367
lineSpacing
694ea5d18b60 add access methods for lineSpacing
martin
parents: 1845
diff changeset
   368
    "get the lineSpacing - thats an additional number of pixels,
694ea5d18b60 add access methods for lineSpacing
martin
parents: 1845
diff changeset
   369
     by which lines are vertically separated.
694ea5d18b60 add access methods for lineSpacing
martin
parents: 1845
diff changeset
   370
    "
694ea5d18b60 add access methods for lineSpacing
martin
parents: 1845
diff changeset
   371
    ^ lineSpacing
694ea5d18b60 add access methods for lineSpacing
martin
parents: 1845
diff changeset
   372
!
694ea5d18b60 add access methods for lineSpacing
martin
parents: 1845
diff changeset
   373
694ea5d18b60 add access methods for lineSpacing
martin
parents: 1845
diff changeset
   374
lineSpacing:aNumber
694ea5d18b60 add access methods for lineSpacing
martin
parents: 1845
diff changeset
   375
    "set the lineSpacing - thats an additional number of pixels,
694ea5d18b60 add access methods for lineSpacing
martin
parents: 1845
diff changeset
   376
     by which lines are vertically separated.
694ea5d18b60 add access methods for lineSpacing
martin
parents: 1845
diff changeset
   377
    "
694ea5d18b60 add access methods for lineSpacing
martin
parents: 1845
diff changeset
   378
    lineSpacing ~= aNumber ifTrue:[
694ea5d18b60 add access methods for lineSpacing
martin
parents: 1845
diff changeset
   379
        lineSpacing := aNumber.
694ea5d18b60 add access methods for lineSpacing
martin
parents: 1845
diff changeset
   380
694ea5d18b60 add access methods for lineSpacing
martin
parents: 1845
diff changeset
   381
        self recomputeHeightOfContents.
694ea5d18b60 add access methods for lineSpacing
martin
parents: 1845
diff changeset
   382
694ea5d18b60 add access methods for lineSpacing
martin
parents: 1845
diff changeset
   383
        shown ifTrue:[
694ea5d18b60 add access methods for lineSpacing
martin
parents: 1845
diff changeset
   384
            self invalidate
694ea5d18b60 add access methods for lineSpacing
martin
parents: 1845
diff changeset
   385
        ]
694ea5d18b60 add access methods for lineSpacing
martin
parents: 1845
diff changeset
   386
    ]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
1818
fe99c5c721e9 category changes
Claus Gittinger <cg@exept.de>
parents: 1796
diff changeset
   389
!ListModelView methodsFor:'accessing-mvc'!
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
listHolder
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
    "returns the listHolder or nil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
    ^ listHolder
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
listHolder:aListHolder
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
    "set a new listHolder
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
    |newList|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
    listHolder removeDependent:self.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
    (listHolder := aListHolder) notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
        listHolder addDependent:self.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
    self list:(listHolder value).
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
1818
fe99c5c721e9 category changes
Claus Gittinger <cg@exept.de>
parents: 1796
diff changeset
   410
!ListModelView methodsFor:'accessing-views'!
1535
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   411
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   412
destroyFrame:aFrame
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   413
    "destroy a frame
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   414
    "
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   415
    aFrame notNil ifTrue:[
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   416
        displayedFrames removeKey:aFrame ifAbsent:nil.
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   417
        aFrame destroy.
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   418
    ].
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   419
!
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   420
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   421
registerFrame:aView atLine:aLineNr x:logX width:w
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   422
    "register a frame for a line and set the origin@corner of the frame
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   423
    "
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   424
    |x y h item index|
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   425
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   426
    (item := list at:aLineNr ifAbsent:nil) isNil ifTrue:[
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   427
        ^ self
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   428
    ].
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   429
    y := self yVisibleOfLine:aLineNr.
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   430
    x := logX - viewOrigin x.
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   431
    h := (startOfLinesY at:(aLineNr + 1)) - (startOfLinesY at:aLineNr).
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   432
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   433
    aView origin:(x@y) extent:(w@h).
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   434
    self addSubView:aView.
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   435
    displayedFrames at:aView put:item.
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   436
    realized ifTrue:[aView realize].
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   437
! !
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   438
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
!ListModelView methodsFor:'change & update'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   440
1535
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   441
contentsChanged
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   442
    "contents changed; recompute origin Y of registered views
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   443
    "
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   444
    |idx y x|
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   445
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   446
    displayedFrames keysAndValuesDo:[:aFrame :anItem|
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   447
        (idx := list identityIndexOf:anItem) == 0 ifTrue:[
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   448
            aFrame beInvisible.
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   449
        ] ifFalse:[
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   450
            y := self yVisibleOfLine:idx.
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   451
            x := aFrame origin x.
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   452
            aFrame origin:(x @ y).
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   453
            aFrame beVisible.
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   454
        ]
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   455
    ].
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   456
    super contentsChanged.
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   457
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   458
!
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   459
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   460
lineChangedAt:aLnNr with:arg
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   461
    "line changed at position; check whether line height changed
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   462
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
    |
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   464
     oldHeight "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   465
     dltHeight "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
    |
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   467
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   468
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   469
    (arg notNil and:[(arg == #icon or:[arg == #hierarchy])]) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   470
        ^ self
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   471
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   472
    oldHeight := (self yVisibleOfLine:(aLnNr + 1)) - (self yVisibleOfLine:aLnNr).
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   473
    dltHeight := (self heightOfLineAt:aLnNr) - oldHeight.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   474
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   475
    dltHeight == 0 ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   476
        ^ self redrawLineAt:aLnNr
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   477
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   478
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   479
    aLnNr + 1 to:startOfLinesY size do:[:i|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   480
        startOfLinesY at:i put:((startOfLinesY at:i) + dltHeight)
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   481
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   482
    self invalidate.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   483
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   484
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   485
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   486
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   487
listChangedInsert:start nItems:nLines
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   488
    "list changed; items are added
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   489
    "
1457
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   490
    |
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   491
     run    "{ Class: SmallInteger }"
1457
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   492
     newSz  "{ Class: SmallInteger }"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   493
     cpyHg  "{ Class: SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   494
     absY0  "{ Class: SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   495
     absY1  "{ Class: SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   496
     visY0  "{ Class: SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   497
     visY1  "{ Class: SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   498
     orgY   "{ Class: SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   499
     dltY   "{ Class: SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   500
     maxHg  "{ Class: SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   501
   |
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   502
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   503
    nLines == 0 ifTrue:[^ self ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   504
    self listSizeChanged:start nLines:nLines.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   505
    shown not ifTrue:[^ self].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   506
1457
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   507
    newSz := startOfLinesY size + nLines.
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   508
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   509
    (newSz - 1) ~~ list size ifTrue:[
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   510
        "/
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   511
        "/ no longer synchrounous
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   512
        "/
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   513
        ^ self lostSynchronisation
1451
85e0df1771e5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
   514
    ].
85e0df1771e5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
   515
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   516
    startOfLinesY addAll:(Array new:nLines) beforeIndex:start + 1.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   517
    absY0 := startOfLinesY at:start.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   518
    absY1 := absY0.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   519
    run   := start.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   520
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   521
    nLines timesRepeat:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   522
        absY1 := absY1 + (self heightOfLineAt:run).
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   523
        run   := run + 1.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   524
        startOfLinesY at:run put:absY1.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   525
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   526
    dltY := absY1 - absY0.
1457
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   527
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   528
    run + 1 to:newSz do:[:i||v|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   529
        startOfLinesY at:i put:((startOfLinesY at:i) + dltY)
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   530
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   531
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   532
    orgY  := viewOrigin y.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   533
    absY1 := absY0 + dltY.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   534
    visY0 := absY0 - orgY.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   535
    visY1 := absY1 - orgY.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   536
    maxHg := height - margin.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   537
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   538
    absY0 < orgY ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   539
        self originWillChange.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   540
        viewOrigin y:(dltY + orgY).
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   541
        self originChanged:(0 @ dltY).
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   542
    ].
1457
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   543
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   544
    (visY0 >= maxHg or:[visY1 <= margin]) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   545
        ^ self contentsChanged
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   546
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   547
    visY0 := visY0 max:margin.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   548
    visY1 := visY1 min:maxHg.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   549
1773
9dba0f0dda0e invalidate uptoend not all if a damage exists (insert/remove)
ca
parents: 1753
diff changeset
   550
    self hasDamage ifTrue:[
9dba0f0dda0e invalidate uptoend not all if a damage exists (insert/remove)
ca
parents: 1753
diff changeset
   551
        self invalidate:(Rectangle left:0
9dba0f0dda0e invalidate uptoend not all if a damage exists (insert/remove)
ca
parents: 1753
diff changeset
   552
                                    top:visY0 
9dba0f0dda0e invalidate uptoend not all if a damage exists (insert/remove)
ca
parents: 1753
diff changeset
   553
                                  width:width 
9dba0f0dda0e invalidate uptoend not all if a damage exists (insert/remove)
ca
parents: 1753
diff changeset
   554
                                 height:height - visY0).
9dba0f0dda0e invalidate uptoend not all if a damage exists (insert/remove)
ca
parents: 1753
diff changeset
   555
9dba0f0dda0e invalidate uptoend not all if a damage exists (insert/remove)
ca
parents: 1753
diff changeset
   556
      ^ self contentsChanged.
9dba0f0dda0e invalidate uptoend not all if a damage exists (insert/remove)
ca
parents: 1753
diff changeset
   557
    ].
9dba0f0dda0e invalidate uptoend not all if a damage exists (insert/remove)
ca
parents: 1753
diff changeset
   558
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   559
    (start == list size or:[(cpyHg := maxHg - visY1) < 20]) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   560
        visY1 := maxHg
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   561
    ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   562
        self catchExpose.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   563
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   564
        self copyFrom:self x:0 y:visY0
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   565
                         toX:0 y:visY1
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   566
                       width:width height:cpyHg async:true.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   567
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   568
        self waitForExpose
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   569
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   570
1457
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   571
    self invalidateX:margin
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   572
                   y:visY0
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   573
               width:width - margin - margin
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   574
              height:(visY1 - visY0).
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   575
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   576
    self contentsChanged.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   577
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   578
1457
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   579
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   580
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   581
1446
fb46beba2d0c startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents: 1444
diff changeset
   582
listChangedRemove:aStart toIndex:aStop
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   583
    "list changed; items are removed
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   584
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   585
    |noRedraw
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   586
     size  "{ Class: SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   587
     absY0 "{ Class: SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   588
     absY1 "{ Class: SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   589
     visY0 "{ Class: SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   590
     visY1 "{ Class: SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   591
     orgY  "{ Class: SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   592
     orgX  "{ Class: SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   593
     dltY  "{ Class: SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   594
     cpyHg "{ Class: SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   595
     maxHg "{ Class: SmallInteger }"
1444
0b7cd00e2537 check range before delete lines
Claus Gittinger <cg@exept.de>
parents: 1443
diff changeset
   596
     stop  "{ Class: SmallInteger }"
1446
fb46beba2d0c startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents: 1444
diff changeset
   597
     start "{ Class: SmallInteger }"
1457
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   598
     newSz "{ Class: SmallInteger }"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   599
    |
1446
fb46beba2d0c startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents: 1444
diff changeset
   600
    stop  := aStop.
fb46beba2d0c startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents: 1444
diff changeset
   601
    start := aStart.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   602
1446
fb46beba2d0c startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents: 1444
diff changeset
   603
    (size := stop - start + 1) == 0 ifTrue:[
fb46beba2d0c startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents: 1444
diff changeset
   604
        ^ self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   605
    ].
1446
fb46beba2d0c startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents: 1444
diff changeset
   606
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   607
    self listSizeChanged:start nLines:(size negated).
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   608
    shown not ifTrue:[^ self].
1451
85e0df1771e5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
   609
1457
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   610
    newSz := startOfLinesY size - size.
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   611
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   612
    (newSz - 1) ~~ list size ifTrue:[
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   613
        "/
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   614
        "/ no longer synchrounous
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   615
        "/
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   616
        ^ self lostSynchronisation
1451
85e0df1771e5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
   617
    ].
85e0df1771e5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
   618
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   619
    absY0 := self yAbsoluteOfLine:start.
1457
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   620
    absY1 := self yAbsoluteOfLine:stop + 1.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   621
    dltY  := absY1 - absY0.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   622
1457
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   623
    startOfLinesY removeFromIndex:(start + 1) toIndex:(stop + 1).
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   624
1457
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   625
    (start + 1) to:newSz do:[:i|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   626
        absY0 := startOfLinesY at:i.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   627
        startOfLinesY at:i put:(absY0 - dltY).
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   628
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   629
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   630
    orgY  := viewOrigin y.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   631
    orgX  := viewOrigin x.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   632
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   633
    absY0 := self yAbsoluteOfLine:start.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   634
    absY1 := absY0 + dltY.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   635
    visY0 := absY0 - orgY.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   636
    visY1 := absY1 - orgY.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   637
    maxHg := height - margin.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   638
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   639
    (list size == 0 or:[(orgY ~~ 0 and:[self maxViewOriginY == 0])]) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   640
        (orgX ~~ 0 or:[orgY ~~ 0]) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   641
            self originWillChange.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   642
            viewOrigin := 0@0.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   643
            self originChanged:((orgX @ orgY) negated).
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   644
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   645
        self invalidate.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   646
      ^ self contentsChanged    
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   647
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   648
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   649
    visY0 < margin ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   650
        noRedraw := visY1 <= margin.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   651
        noRedraw ifTrue:[dltY := dltY negated] ifFalse:[dltY := visY0].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   652
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   653
        self originWillChange.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   654
        viewOrigin y:(dltY + orgY).
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   655
        self originChanged:(0 @ dltY).        
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   656
    ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   657
        noRedraw := visY0 >= maxHg
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   658
    ].
1773
9dba0f0dda0e invalidate uptoend not all if a damage exists (insert/remove)
ca
parents: 1753
diff changeset
   659
    visY0 := visY0 max:margin.
9dba0f0dda0e invalidate uptoend not all if a damage exists (insert/remove)
ca
parents: 1753
diff changeset
   660
1457
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   661
    self hasDamage ifTrue:[
1773
9dba0f0dda0e invalidate uptoend not all if a damage exists (insert/remove)
ca
parents: 1753
diff changeset
   662
        self invalidate:(Rectangle left:0
9dba0f0dda0e invalidate uptoend not all if a damage exists (insert/remove)
ca
parents: 1753
diff changeset
   663
                                    top:visY0 
9dba0f0dda0e invalidate uptoend not all if a damage exists (insert/remove)
ca
parents: 1753
diff changeset
   664
                                  width:width 
9dba0f0dda0e invalidate uptoend not all if a damage exists (insert/remove)
ca
parents: 1753
diff changeset
   665
                                 height:height - visY0).
9dba0f0dda0e invalidate uptoend not all if a damage exists (insert/remove)
ca
parents: 1753
diff changeset
   666
1457
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   667
        noRedraw := true
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   668
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   669
1457
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   670
    noRedraw ifFalse:[
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   671
        cpyHg := maxHg - visY1.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   672
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   673
        cpyHg > 20 ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   674
            self catchExpose.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   675
            self copyFrom:self x:0 y:visY1 toX:0 y:visY0
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   676
                    width:width height:cpyHg async:true.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   677
            self waitForExpose.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   678
            visY0 := visY0 + cpyHg.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   679
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   680
1457
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   681
        self invalidateX:margin
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   682
                       y:visY0
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   683
                   width:width - margin - margin
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
   684
                  height:(maxHg - visY0).
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   685
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   686
    self contentsChanged.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   687
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   688
1535
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   689
originChanged:aDelta
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   690
    "change origin of registered views
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   691
    "
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   692
    displayedFrames keys do:[:aFrame|
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   693
        aFrame origin:(aFrame origin - aDelta)
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   694
    ].
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   695
    super originChanged:aDelta.
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   696
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   697
!
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
   698
1443
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   699
syncUpdate:what with:args
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   700
    "handle synchronous change
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   701
    "
1443
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   702
    |a1 a2|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   703
1443
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   704
    args isCollection ifFalse:[
1995
ede7d0221fa0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1945
diff changeset
   705
        what == #at:     ifTrue:[self lineChangedAt:args        with:nil.  ^ self].
ede7d0221fa0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1945
diff changeset
   706
        what == #insert: ifTrue:[self listChangedInsert:args  nItems:1.    ^ self].
ede7d0221fa0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1945
diff changeset
   707
        what == #remove: ifTrue:[self listChangedRemove:args toIndex:args. ^ self].
ede7d0221fa0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1945
diff changeset
   708
        ^ self.
ede7d0221fa0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1945
diff changeset
   709
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   710
1995
ede7d0221fa0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1945
diff changeset
   711
    a1 := args at:1.
ede7d0221fa0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1945
diff changeset
   712
    a2 := args at:2.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   713
1995
ede7d0221fa0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1945
diff changeset
   714
    what == #at:               ifTrue:[self lineChangedAt:a1        with:a2. ^ self].
ede7d0221fa0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1945
diff changeset
   715
    what == #insertCollection: ifTrue:[self listChangedInsert:a1  nItems:a2. ^ self].
ede7d0221fa0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1945
diff changeset
   716
    what == #removeFrom:       ifTrue:[self listChangedRemove:a1 toIndex:a2. ^ self].
ede7d0221fa0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1945
diff changeset
   717
    what == #replace:          ifTrue:[
ede7d0221fa0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1945
diff changeset
   718
        a1 to:a2 do:[:i|self lineChangedAt:i with:nil].
ede7d0221fa0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1945
diff changeset
   719
        ^ self
ede7d0221fa0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1945
diff changeset
   720
    ].
1443
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   721
!
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   722
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   723
update:what with:aPara from:chgObj
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   724
    "catch and handle any notification raised from the list model
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   725
     or list holder
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   726
    "
1773
9dba0f0dda0e invalidate uptoend not all if a damage exists (insert/remove)
ca
parents: 1753
diff changeset
   727
1443
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   728
    chgObj ~~ list ifTrue:[
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   729
        chgObj == listHolder ifTrue:[
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   730
            self syncPushEvent:#list: with:(listHolder value)
1443
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   731
        ] ifFalse:[
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   732
            super update:what with:aPara from:chgObj
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   733
        ].
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   734
        ^ self
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   735
    ].
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   736
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   737
    ( #(    insert:
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   738
            remove:
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   739
            removeFrom:
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   740
            insertCollection:
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   741
            at:
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   742
            replace:
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   743
        ) includes:what
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   744
    ) ifTrue:[
1456
bf3d23b45b7d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
   745
        (aPara isCollection and:[(aPara at:1) == 1 and:[(aPara at:2) == list size]]) ifTrue:[
1451
85e0df1771e5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
   746
            self list:list
1443
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   747
        ] ifFalse:[
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   748
            self syncPushEvent:#syncUpdate:with: with:what with:aPara
1443
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   749
        ]
c9ef29f36c29 bug fix:
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
   750
    ]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   751
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   752
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   753
!ListModelView methodsFor:'drawing'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   754
1532
56e0fafc4349 change display protocol for item
Claus Gittinger <cg@exept.de>
parents: 1531
diff changeset
   755
displayElement:anItem x:x y:y h:h
56e0fafc4349 change display protocol for item
Claus Gittinger <cg@exept.de>
parents: 1531
diff changeset
   756
    "draw a label at x/y; fg/bg colors are already set
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   757
    "
1634
59bbf1876ddc checkin from browser
ps
parents: 1631
diff changeset
   758
    |ok label
1532
56e0fafc4349 change display protocol for item
Claus Gittinger <cg@exept.de>
parents: 1531
diff changeset
   759
     y0 "{ Class: SmallInteger }"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   760
    |
1752
1c11b6e4ab37 use isHierarchicalItem instead of hack variable
ca
parents: 1748
diff changeset
   761
    anItem isHierarchicalItem ifTrue:[
1532
56e0fafc4349 change display protocol for item
Claus Gittinger <cg@exept.de>
parents: 1531
diff changeset
   762
        anItem displayOn:self x:x y:y h:h
1399
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   763
    ] ifFalse:[
1634
59bbf1876ddc checkin from browser
ps
parents: 1631
diff changeset
   764
        y0    := y - ((anItem heightOn:self) + 1 - h // 2).
59bbf1876ddc checkin from browser
ps
parents: 1631
diff changeset
   765
        label := anItem.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   766
1634
59bbf1876ddc checkin from browser
ps
parents: 1631
diff changeset
   767
        label isImageOrForm ifFalse:[
59bbf1876ddc checkin from browser
ps
parents: 1631
diff changeset
   768
            label isNumber ifTrue:[
59bbf1876ddc checkin from browser
ps
parents: 1631
diff changeset
   769
                label := label printString
59bbf1876ddc checkin from browser
ps
parents: 1631
diff changeset
   770
            ].
59bbf1876ddc checkin from browser
ps
parents: 1631
diff changeset
   771
            y0 := y0 + font ascent
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   772
        ].
1634
59bbf1876ddc checkin from browser
ps
parents: 1631
diff changeset
   773
        label displayOn:self x:x y:y0
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   774
    ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   775
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   776
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   777
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   778
1391
83ed7574be4c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   779
invalidateX:x y:y width:w height:h
83ed7574be4c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   780
    "add a damage to redraw part of the view
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   781
    "
1399
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   782
    shown ifTrue:[
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   783
        self invalidate:(Rectangle left:x top:y width:w height:h) 
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   784
              repairNow:false
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   785
    ]
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   786
!
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   787
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   788
redraw
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   789
    "redraw complete view
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   790
    "
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   791
    self redrawX:0 y:0 width:width height:height.
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   792
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   793
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   794
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   795
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   796
redrawLineAt:aLineNr
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   797
    "redraw a specific line
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   798
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   799
    |y0 "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   800
     y1 "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   801
     yB "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   802
    |
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   803
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   804
    (shown and:[aLineNr notNil]) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   805
        yB := height - margin.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   806
        y0 := (self yVisibleOfLine:aLineNr) max:margin.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   807
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   808
        y0 < yB ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   809
            y1 := (self yVisibleOfLine:(aLineNr + 1)) min:yB.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   810
            y1 > margin ifTrue:[
1566
ca
parents: 1562
diff changeset
   811
                self invalidateX:0 y:y0 width:width height:(y1 - y0)
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   812
            ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   813
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   814
    ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   815
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   816
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   817
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   818
redrawX:x y:y width:w height:h
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   819
    "redraw part of myself immediately, given logical coordinates 
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   820
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   821
    |savClip start stop yAbs|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   822
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   823
    shown ifFalse:[^ self].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   824
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   825
    self paint:bgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   826
    self fillRectangleX:x y:y width:w height:h.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   827
1615
b865f77ce29e test whether widthOfContents is computed
ca
parents: 1595
diff changeset
   828
    widthOfContents isNil ifTrue:[self preferredExtent].
b865f77ce29e test whether widthOfContents is computed
ca
parents: 1595
diff changeset
   829
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   830
    (start := self yVisibleToLineNr:y) isNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   831
        ^ self
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   832
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   833
    yAbs := y + h.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   834
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   835
    (stop := self yVisibleToLineNr:yAbs) isNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   836
        stop := list size.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   837
    ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   838
        yAbs == (startOfLinesY at:stop) ifTrue:[
1531
42dcb9760f0f checkin from browser
Stefan Vogel <sv@exept.de>
parents: 1508
diff changeset
   839
            stop := (stop - 1) max:start
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   840
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   841
    ].    
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   842
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   843
    savClip := clipRect.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   844
    self clippingRectangle:(Rectangle left:x top:y width:w height:h).
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   845
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   846
    StopRedrawSignal handle:[:ex|  self invalidate.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   847
                                   ex return
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   848
                            ] do:[ self drawFrom:start
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   849
                                              to:stop 
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   850
                                               x:x
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   851
                                               y:(self yVisibleOfLine:start)
1532
56e0fafc4349 change display protocol for item
Claus Gittinger <cg@exept.de>
parents: 1531
diff changeset
   852
                                               w:w
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   853
                            ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   854
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   855
    self clippingRectangle:savClip.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   856
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   857
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   858
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   859
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   860
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   861
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   862
!ListModelView methodsFor:'event handling'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   863
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   864
keyPress:aKey x:x y:y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   865
    "a key was pressed - handle page-keys here
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   866
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   867
    <resource: #keyboard( #PreviousPage #NextPage  #HalfPageUp #HalfPageDown
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   868
                          #BeginOfText  #EndOfText #ScrollUp   #ScrollDown
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   869
                        )>
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   870
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   871
    |n sensor|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   872
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   873
    list size ~~ 0 ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   874
        (aKey == #PreviousPage) ifTrue:[^ self pageUp].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   875
        (aKey == #NextPage)     ifTrue:[^ self pageDown].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   876
        (aKey == #HalfPageUp)   ifTrue:[^ self halfPageUp].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   877
        (aKey == #HalfPageDown) ifTrue:[^ self halfPageDown].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   878
        (aKey == #BeginOfText)  ifTrue:[^ self scrollToTop].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   879
        (aKey == #EndOfText)    ifTrue:[^ self scrollToBottom].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   880
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   881
        (aKey == #ScrollUp or:[aKey == #ScrollDown]) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   882
            sensor := self sensor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   883
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   884
            n := sensor notNil ifTrue:[1 + (sensor compressKeyPressEventsWithKey:aKey)]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   885
                              ifFalse:[1].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   886
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   887
            n := n * self verticalScrollStep.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   888
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   889
            aKey == #ScrollUp ifTrue:[self scrollUp:n]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   890
                             ifFalse:[self scrollDown:n].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   891
            ^ self
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   892
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   893
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   894
    super keyPress:aKey x:x y:y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   895
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   896
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   897
!ListModelView methodsFor:'event simulation'!
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   898
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   899
syncFlushEvent:aSelector
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   900
    "throw away all pending syncronization events for a specific selector
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   901
    "
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   902
    |sensor|
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   903
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   904
    (syncronizeEvents and:[(sensor := self sensor) notNil]) ifTrue:[
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   905
        sensor flushUserEventsFor:self withType:aSelector
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   906
    ]
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   907
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   908
!
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   909
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   910
syncPushEvent:aSelector
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   911
    "if events are synchronized, the message send is pushed into my
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   912
     event queue and will be performed when its time to handle events.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   913
     Otherwise the event is handled immediately
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   914
    "
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   915
    |sensor|
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   916
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   917
    (syncronizeEvents and:[(sensor := self sensor) notNil]) ifTrue:[
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   918
        sensor pushUserEvent:aSelector for:self withArguments:#()
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   919
    ] ifFalse:[
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   920
        self perform:aSelector
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   921
    ]
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   922
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   923
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   924
!
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   925
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   926
syncPushEvent:aSelector with:arg
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   927
    "if events are synchronized, the message send is pushed into my
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   928
     event queue and will be performed when its time to handle events.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   929
     Otherwise the event is handled immediately
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   930
    "
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   931
    |sensor|
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   932
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   933
    (syncronizeEvents and:[(sensor := self sensor) notNil]) ifTrue:[
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   934
        sensor pushUserEvent:aSelector for:self withArguments:(Array with:arg)
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   935
    ] ifFalse:[
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   936
        self perform:aSelector with:arg
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   937
    ]
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   938
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   939
!
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   940
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   941
syncPushEvent:aSelector with:arg1 with:arg2
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   942
    "if events are synchronized, the message send is pushed into my
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   943
     event queue and will be performed when its time to handle events.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   944
     Otherwise the event is handled immediately
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   945
    "
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   946
    |sensor|
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   947
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   948
    (syncronizeEvents and:[(sensor := self sensor) notNil]) ifTrue:[
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   949
        sensor pushUserEvent:aSelector for:self withArguments:(Array with:arg1 with:arg2)
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   950
    ] ifFalse:[
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   951
        self perform:aSelector with:arg1 with:arg2
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   952
    ]
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   953
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   954
!
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   955
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   956
syncronizeEvents
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   957
    "if true, all asynchronous events are pushed into my event queue
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   958
     and will be performed when its time to handle the events.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   959
     Otherwise these events are handled immediately. On default disabled.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   960
    "
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   961
    ^ syncronizeEvents
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   962
!
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   963
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   964
syncronizeEvents:aBoolean
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   965
    "if true, all asynchronous events are pushed into my event queue
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   966
     and will be performed when its time to handle the events.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   967
     Otherwise these events are handled immediately. On default disabled.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   968
    "
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   969
    syncronizeEvents := aBoolean ? false.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   970
! !
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
   971
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   972
!ListModelView methodsFor:'fetch resources'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   973
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   974
colorOnDevice:aColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   975
    "fetch a device colors
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   976
    "
2097
78bfd62fdcbc on: -> onDevice:
Claus Gittinger <cg@exept.de>
parents: 1995
diff changeset
   977
    ^ aColor notNil ifTrue:[aColor onDevice:device] ifFalse:[nil]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   978
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   979
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   980
imageOnDevice:anImage
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   981
    "associate image to device and clear pixel mask
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   982
     returns the new image.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   983
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   984
    |image|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   985
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   986
    (image := anImage) notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   987
        image device ~~ device ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   988
            image := image copy.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   989
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   990
        image := image on:device.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   991
        image := image clearMaskedPixels.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   992
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   993
    ^ image
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   994
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   995
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   996
1417
3d331ae2d2b6 implements:
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
   997
!ListModelView methodsFor:'focus handling'!
3d331ae2d2b6 implements:
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
   998
3d331ae2d2b6 implements:
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
   999
wantsFocusWithButtonPress
3d331ae2d2b6 implements:
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1000
    "catch the keyboard focus on button click
3d331ae2d2b6 implements:
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1001
    "
3d331ae2d2b6 implements:
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1002
    ^  true
3d331ae2d2b6 implements:
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1003
3d331ae2d2b6 implements:
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1004
3d331ae2d2b6 implements:
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1005
!
3d331ae2d2b6 implements:
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1006
3d331ae2d2b6 implements:
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1007
wantsFocusWithPointerEnter
3d331ae2d2b6 implements:
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1008
    "views which like to take the keyboard focus
3d331ae2d2b6 implements:
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1009
     when the pointer enters can do so by redefining this
3d331ae2d2b6 implements:
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1010
     to return true"
3d331ae2d2b6 implements:
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1011
3d331ae2d2b6 implements:
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1012
    ^ true
3d331ae2d2b6 implements:
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1013
3d331ae2d2b6 implements:
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1014
! !
3d331ae2d2b6 implements:
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1015
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1016
!ListModelView methodsFor:'initialize / release'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1017
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1018
create
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1019
    "fetch device dependent resources
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1020
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1021
    super create.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1022
    self fetchResources.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1023
    self recomputeHeightOfContents.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1024
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1025
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1026
destroy
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1027
    "remove dependencies
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1028
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1029
    listHolder removeDependent:self.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1030
    list       removeDependent:self.
1535
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  1031
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1032
    super destroy
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1033
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1034
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1035
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1036
initStyle
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1037
    "setup viewStyle specifics
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1038
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1039
    super initStyle.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1040
1595
0bf8a4b72e88 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
  1041
    DefaultForegroundColor isNil ifTrue:[
0bf8a4b72e88 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
  1042
        self updateStyleCache
0bf8a4b72e88 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
  1043
    ].
0bf8a4b72e88 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
  1044
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1045
    DefaultBackgroundColor notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1046
        viewBackground := DefaultBackgroundColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1047
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1048
    lineSpacing   := 0.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1049
    textStartLeft := 2.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1050
    fgColor       := DefaultForegroundColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1051
    bgColor       := viewBackground.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1052
    startOfLinesY := OrderedCollection new.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1053
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1054
    startOfLinesY add:(2 + margin). "/ top inset of first line
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1055
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1056
    DefaultShadowColor notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1057
        shadowColor := DefaultShadowColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1058
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1059
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1060
    DefaultLightColor notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1061
        lightColor := DefaultLightColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1062
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1063
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1064
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1065
initialize
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1066
    "setup default attributes
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1067
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1068
    super initialize.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1069
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
  1070
    viewOrigin       := 0@0.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
  1071
    bitGravity       := #NorthWest.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
  1072
    enabled          := true.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
  1073
    displayedFrames  := WeakIdentityDictionary new.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
  1074
    syncronizeEvents := false.
1748
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1075
    autoScroll       := true.
1827
54e8a0fc8a42 scrollWhenUpdating
Claus Gittinger <cg@exept.de>
parents: 1820
diff changeset
  1076
    scrollWhenUpdating := #beginOfText.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1077
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1078
1562
342e61e7bc99 recompute height of contents after mapped
ca
parents: 1554
diff changeset
  1079
mapped
342e61e7bc99 recompute height of contents after mapped
ca
parents: 1554
diff changeset
  1080
    "recompute list
342e61e7bc99 recompute height of contents after mapped
ca
parents: 1554
diff changeset
  1081
    "
342e61e7bc99 recompute height of contents after mapped
ca
parents: 1554
diff changeset
  1082
    shown ifFalse:[
342e61e7bc99 recompute height of contents after mapped
ca
parents: 1554
diff changeset
  1083
        self recomputeHeightOfContents.
342e61e7bc99 recompute height of contents after mapped
ca
parents: 1554
diff changeset
  1084
        self contentsChanged.
342e61e7bc99 recompute height of contents after mapped
ca
parents: 1554
diff changeset
  1085
    ].    
342e61e7bc99 recompute height of contents after mapped
ca
parents: 1554
diff changeset
  1086
    super mapped
342e61e7bc99 recompute height of contents after mapped
ca
parents: 1554
diff changeset
  1087
342e61e7bc99 recompute height of contents after mapped
ca
parents: 1554
diff changeset
  1088
!
342e61e7bc99 recompute height of contents after mapped
ca
parents: 1554
diff changeset
  1089
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1090
recreate
1832
f6e6640e99a3 comment
Claus Gittinger <cg@exept.de>
parents: 1828
diff changeset
  1091
    "sent after a snapin or a migration, reinit for new device"
1828
ea1f39c639f8 comment
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
  1092
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1093
    super recreate.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1094
    self fetchResources.
1796
c9d801c011f7 recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents: 1773
diff changeset
  1095
!
c9d801c011f7 recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents: 1773
diff changeset
  1096
c9d801c011f7 recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents: 1773
diff changeset
  1097
reinitialize
c9d801c011f7 recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents: 1773
diff changeset
  1098
    "reinit after snapIn (font geometry might be different)
c9d801c011f7 recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents: 1773
diff changeset
  1099
    "
c9d801c011f7 recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents: 1773
diff changeset
  1100
    super reinitialize.
c9d801c011f7 recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents: 1773
diff changeset
  1101
    self recomputeHeightOfContents.
c9d801c011f7 recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents: 1773
diff changeset
  1102
    self contentsChanged.
c9d801c011f7 recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents: 1773
diff changeset
  1103
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1104
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1105
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1106
!ListModelView methodsFor:'private'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1107
1457
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
  1108
hasDamage
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
  1109
    "return true, if any damage events (i.e. expose or resize) are pending.
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
  1110
    "
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
  1111
    |sensor|
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
  1112
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
  1113
    ^ (sensor := self sensor) isNil or:[sensor hasDamageFor:self]
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
  1114
!
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
  1115
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1116
yAbsoluteOfLine:aLineNr
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1117
    "given a lineNr, return y-coordinate absolute
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1118
    "
1744
2447f4a3dd7c computation of absoluteY for a line
ca
parents: 1743
diff changeset
  1119
    |y y2 y1 cash|
1446
fb46beba2d0c startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents: 1444
diff changeset
  1120
1744
2447f4a3dd7c computation of absoluteY for a line
ca
parents: 1743
diff changeset
  1121
    cash := startOfLinesY.
1446
fb46beba2d0c startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents: 1444
diff changeset
  1122
1744
2447f4a3dd7c computation of absoluteY for a line
ca
parents: 1743
diff changeset
  1123
    (y := cash at:aLineNr ifAbsent:nil) notNil ifTrue:[
2447f4a3dd7c computation of absoluteY for a line
ca
parents: 1743
diff changeset
  1124
        ^ y
1446
fb46beba2d0c startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents: 1444
diff changeset
  1125
    ].
1744
2447f4a3dd7c computation of absoluteY for a line
ca
parents: 1743
diff changeset
  1126
2447f4a3dd7c computation of absoluteY for a line
ca
parents: 1743
diff changeset
  1127
    "/ recompute a y position
2447f4a3dd7c computation of absoluteY for a line
ca
parents: 1743
diff changeset
  1128
    y1 := startOfLinesY at:1 ifAbsent:2.
2447f4a3dd7c computation of absoluteY for a line
ca
parents: 1743
diff changeset
  1129
    y2 := startOfLinesY at:2 ifAbsent:10.
2447f4a3dd7c computation of absoluteY for a line
ca
parents: 1743
diff changeset
  1130
  ^ aLineNr * (y2 - y1) + y1
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1131
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1132
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1133
yVisibleOfLine:aLineNr
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1134
    "given a lineNr, return y-coordinate in view
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1135
    "
1744
2447f4a3dd7c computation of absoluteY for a line
ca
parents: 1743
diff changeset
  1136
    ^ (self yAbsoluteOfLine:aLineNr) - viewOrigin y
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1137
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1138
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1139
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1140
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1141
yVisibleToLineNr:yVisible
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1142
    "returns the line number assigned to a physical y or nil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1143
    "
1643
cabafd70be77 checkin from browser
ps
parents: 1642
diff changeset
  1144
    |eol cash
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1145
     yAbs    "{ Class: SmallInteger}"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1146
     yMid    "{ Class: SmallInteger}"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1147
     size    "{ Class: SmallInteger}"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1148
     next    "{ Class: SmallInteger}"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1149
     low     "{ Class: SmallInteger}"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1150
     high    "{ Class: SmallInteger}"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1151
     middle  "{ Class: SmallInteger}"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1152
    |
1643
cabafd70be77 checkin from browser
ps
parents: 1642
diff changeset
  1153
    cash := startOfLinesY.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1154
1643
cabafd70be77 checkin from browser
ps
parents: 1642
diff changeset
  1155
    (size := cash size) == 1 ifTrue:[^ nil].   "/ EMPTY LIST
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1156
    yAbs := yVisible + viewOrigin y.
1643
cabafd70be77 checkin from browser
ps
parents: 1642
diff changeset
  1157
    eol  := cash at:size ifAbsent:nil.
1642
461df665a230 bugfix; click events faster as updating the list
ps
parents: 1634
diff changeset
  1158
    (eol isNil or:[yAbs > eol]) ifTrue:[^ nil].         "/ END OF LIST
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1159
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1160
    middle := size.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1161
    size   := size - 1.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1162
    high   := size.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1163
    low    := 1.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1164
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1165
    [(next := low + high // 2) ~~ middle] whileTrue:[
1643
cabafd70be77 checkin from browser
ps
parents: 1642
diff changeset
  1166
        (eol := cash at:next ifAbsent:nil) isNil ifTrue:[
cabafd70be77 checkin from browser
ps
parents: 1642
diff changeset
  1167
            ^ nil "/ LIST CHANGED
cabafd70be77 checkin from browser
ps
parents: 1642
diff changeset
  1168
        ].
cabafd70be77 checkin from browser
ps
parents: 1642
diff changeset
  1169
        middle := next.
cabafd70be77 checkin from browser
ps
parents: 1642
diff changeset
  1170
        yMid   := eol.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1171
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1172
        yMid < yAbs ifTrue:[low  := middle]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1173
                   ifFalse:[high := middle]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1174
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1175
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1176
    yAbs < yMid ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1177
        ^ (middle - 1) max:1.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1178
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1179
    middle < size ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1180
        next := middle + 1.
1643
cabafd70be77 checkin from browser
ps
parents: 1642
diff changeset
  1181
        (eol := cash at:next ifAbsent:nil) isNil ifTrue:[
cabafd70be77 checkin from browser
ps
parents: 1642
diff changeset
  1182
            ^ nil "/ LIST CHANGED
cabafd70be77 checkin from browser
ps
parents: 1642
diff changeset
  1183
        ].
cabafd70be77 checkin from browser
ps
parents: 1642
diff changeset
  1184
        ^ eol > yAbs ifTrue:[middle] ifFalse:[next]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1185
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1186
    ^ size
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1187
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1188
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1189
!ListModelView methodsFor:'protocol'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1190
1532
56e0fafc4349 change display protocol for item
Claus Gittinger <cg@exept.de>
parents: 1531
diff changeset
  1191
drawFrom:start to:stop x:x y:y w:w
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1192
    "draw lines from start to stop.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1193
     clipping and clearing the background is already done
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1194
    "
1399
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
  1195
    |item
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
  1196
     y0 "{ Class:SmallInteger }"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1197
     y1 "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1198
     x0 "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1199
    |
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1200
    self paint:fgColor on:bgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1201
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1202
    x0 := textStartLeft - viewOrigin x.
1532
56e0fafc4349 change display protocol for item
Claus Gittinger <cg@exept.de>
parents: 1531
diff changeset
  1203
    y1 := y.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1204
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1205
    start to:stop do:[:i|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1206
        y0 := y1.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1207
        y1 := self yVisibleOfLine:(i + 1).
1399
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
  1208
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
  1209
        (item := list at:i ifAbsent:nil) notNil ifTrue:[
1532
56e0fafc4349 change display protocol for item
Claus Gittinger <cg@exept.de>
parents: 1531
diff changeset
  1210
            self displayElement:item x:x0 y:y0 h:(y1 - y0)
1399
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
  1211
        ]
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
  1212
    ]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1213
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1214
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1215
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1216
fetchResources
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1217
    "fetch device colors and ..., to avoid reallocation at redraw time;
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1218
     *** called after a create or snapin to fetch all device resources
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1219
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1220
    fgColor    := self colorOnDevice:fgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1221
    bgColor    := self colorOnDevice:bgColor.
2097
78bfd62fdcbc on: -> onDevice:
Claus Gittinger <cg@exept.de>
parents: 1995
diff changeset
  1222
    font       := font onDevice:device.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1223
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1224
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1225
heightOfLineAt:aLineNr
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1226
    "returns the total height for a line at an index( including lineSpacing ... )
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1227
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1228
    |item|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1229
1508
9c54f2e53da1 check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents: 1457
diff changeset
  1230
    item := list at:aLineNr ifAbsent:nil.
9c54f2e53da1 check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents: 1457
diff changeset
  1231
9c54f2e53da1 check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents: 1457
diff changeset
  1232
  ^ item notNil ifTrue:[lineSpacing + (item heightOn:self)]
9c54f2e53da1 check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents: 1457
diff changeset
  1233
               ifFalse:[4]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1234
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1235
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1236
listSizeChanged:anIndex nLines:noLines
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1237
    "list size changed; information is stored to recompute the
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1238
     width if required( preferredExtent, horizontal scroller ... ).
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1239
     see: widthOfContents
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1240
     *** if nLines is negative, lines are removed otherwise added.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1241
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1242
    |start "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1243
     stop  "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1244
     size  "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1245
    |
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1246
    preferredExtent := nil.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1247
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1248
    widthOfContents isNil ifTrue:[      "/ recompute whole list
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1249
        ^ self
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1250
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1251
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1252
    (noLines < 0 or:[(size := list size) <= noLines]) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1253
        widthOfContents := nil.         "/ force recompute whole list
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1254
        ^ self
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1255
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1256
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1257
    stop  := anIndex + noLines - 1.     "/ recompute a range
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1258
    start := anIndex.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1259
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1260
    computeWidthInRange notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1261
        start := computeWidthInRange y.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1262
        stop  <  start ifTrue:[stop := start min:size].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1263
        start := (computeWidthInRange x) min:anIndex.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1264
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1265
    computeWidthInRange := start@stop
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1266
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1267
1457
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
  1268
lostSynchronisation
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
  1269
    "called when the changes derived from the model are faster than the handling
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
  1270
    "
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
  1271
    shown ifTrue:[
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1538
diff changeset
  1272
        self syncFlushEvent:#syncUpdate:with:.
1457
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
  1273
        self recomputeHeightOfContents.
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
  1274
        self invalidate.
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
  1275
        self contentsChanged
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
  1276
    ].
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
  1277
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
  1278
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
  1279
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
  1280
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
  1281
!
76491c5ae369 lostSynchronisation:
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
  1282
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1283
widthOfWidestLineBetween:firstLine and:lastLine
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1284
    "return the width in pixels of the widest line in a range
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1285
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1286
    |lbl item
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1287
     width    "{ Class: SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1288
    |
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1289
    width := textStartLeft.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1290
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1291
    firstLine to:lastLine do:[:anIndex|
1508
9c54f2e53da1 check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents: 1457
diff changeset
  1292
        item := list at:anIndex ifAbsent:nil.
9c54f2e53da1 check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents: 1457
diff changeset
  1293
9c54f2e53da1 check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents: 1457
diff changeset
  1294
        item isNil ifTrue:[^ width + textStartLeft].
9c54f2e53da1 check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents: 1457
diff changeset
  1295
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1296
        width := (item widthOn:self) max:width
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1297
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1298
    ^ width + textStartLeft
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1299
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1300
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1301
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1302
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1303
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1304
1820
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1818
diff changeset
  1305
!ListModelView methodsFor:'queries'!
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1818
diff changeset
  1306
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1818
diff changeset
  1307
size
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1818
diff changeset
  1308
    "returns number of raws
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1818
diff changeset
  1309
    "
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1818
diff changeset
  1310
    ^ list size
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1818
diff changeset
  1311
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1818
diff changeset
  1312
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1818
diff changeset
  1313
! !
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1818
diff changeset
  1314
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1315
!ListModelView methodsFor:'recomputation'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1316
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1317
preferredExtent
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1318
    "returns the preferred extent
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1319
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1320
    |x y|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1321
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1322
    preferredExtent isNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1323
        y := self heightOfContents.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1324
        x := self widthOfContents.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1325
        preferredExtent := x@y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1326
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1327
  ^ preferredExtent
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1328
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1329
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1330
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1331
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1332
recomputeHeightOfContents
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1333
    "recompute all the y positions
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1334
    "
1643
cabafd70be77 checkin from browser
ps
parents: 1642
diff changeset
  1335
    |newList
cabafd70be77 checkin from browser
ps
parents: 1642
diff changeset
  1336
     yAbs "{ Class: SmallInteger }"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1337
     lnHg "{ Class: SmallInteger }"
1643
cabafd70be77 checkin from browser
ps
parents: 1642
diff changeset
  1338
     size "{ Class: SmallInteger }"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1339
    |
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1340
1643
cabafd70be77 checkin from browser
ps
parents: 1642
diff changeset
  1341
    yAbs    := startOfLinesY at:1.   "/ top inset of first line
cabafd70be77 checkin from browser
ps
parents: 1642
diff changeset
  1342
    size    := list size.
cabafd70be77 checkin from browser
ps
parents: 1642
diff changeset
  1343
    newList := OrderedCollection new:(size + 1).
cabafd70be77 checkin from browser
ps
parents: 1642
diff changeset
  1344
cabafd70be77 checkin from browser
ps
parents: 1642
diff changeset
  1345
    newList add:yAbs.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1346
1643
cabafd70be77 checkin from browser
ps
parents: 1642
diff changeset
  1347
    1 to:size do:[:anIndex|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1348
        lnHg := self heightOfLineAt:anIndex.
1643
cabafd70be77 checkin from browser
ps
parents: 1642
diff changeset
  1349
        newList add:(yAbs := yAbs + lnHg)
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1350
    ].
1643
cabafd70be77 checkin from browser
ps
parents: 1642
diff changeset
  1351
    startOfLinesY := newList.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1352
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1353
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1354
!ListModelView methodsFor:'scroller interface'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1355
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1356
heightOfContents
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1357
    "return the height of the contents in pixels
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1358
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1359
    ^ startOfLinesY last
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1360
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1361
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1362
innerHeight
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1363
    "returns the inner height of the contents shown
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1364
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1365
    ^ height - margin - margin
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1366
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1367
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1368
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1369
innerWidth
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1370
    "returns the inner width of the contents shown
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1371
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1372
    ^ width - margin - margin
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1373
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1374
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1375
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1376
maxViewOriginY
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1377
    "returns the maximum possible y of the view origin
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1378
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1379
    ^ (self heightOfContents - self innerHeight) max:0
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1380
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1381
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1382
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1383
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1384
verticalScrollStep
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1385
    "return the amount to scroll when stepping up/down.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1386
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1387
    ^ 10
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1388
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1389
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1391
viewOrigin
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1392
    "return the viewOrigin; thats the coordinate of the contents 
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1393
     which is shown topLeft in the view.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1394
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1395
    ^ viewOrigin
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1396
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1397
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1398
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1399
widthOfContents
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1400
    "return the width of the contents in pixels
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1401
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1402
    |range
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1403
     size  "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1404
     start "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1405
     stop  "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1406
    |
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1407
    (widthOfContents notNil and:[computeWidthInRange isNil]) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1408
        ^ widthOfContents + textStartLeft
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1409
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1410
    range               := computeWidthInRange.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1411
    computeWidthInRange := nil.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1412
    preferredExtent     := nil.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1413
    size                := list size.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1414
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1415
    size == 0 ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1416
        widthOfContents := 20.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1417
    ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1418
        widthOfContents isNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1419
            widthOfContents := self widthOfWidestLineBetween:1 and:size
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1420
        ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1421
            start := range x.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1422
            stop  := range y min:size.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1423
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1424
            start > stop ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1425
                size := self widthOfWidestLineBetween:start and:stop.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1426
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1427
                widthOfContents < size ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1428
                    widthOfContents := size
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1429
                ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1430
            ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1431
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1432
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1433
    ^ widthOfContents + textStartLeft
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1434
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1435
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1436
xOriginOfContents
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1437
    "return the horizontal origin of the contents in pixels
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1438
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1439
    ^ viewOrigin x 
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1440
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1441
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1442
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1443
yOriginOfContents
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1444
    "return the vertical origin of the contents in pixels
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1445
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1446
    ^ viewOrigin y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1447
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1448
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1449
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1450
!ListModelView methodsFor:'scrolling'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1451
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1452
halfPageDown
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1453
    "scroll down half a page
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1454
    "
1827
54e8a0fc8a42 scrollWhenUpdating
Claus Gittinger <cg@exept.de>
parents: 1820
diff changeset
  1455
    self scrollDown:(height // 2).
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1456
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1457
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1458
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1459
halfPageUp
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1460
    "scroll up half a page
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1461
    "
1827
54e8a0fc8a42 scrollWhenUpdating
Claus Gittinger <cg@exept.de>
parents: 1820
diff changeset
  1462
    self scrollUp:(height // 2).
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1463
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1464
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1465
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1466
scrollTo:anOrigin redraw:doRedraw
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1467
    "change origin to have newOrigin be visible at the top-left.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1468
    "
1538
ef0eea7c074a check for windowGroup
Claus Gittinger <cg@exept.de>
parents: 1535
diff changeset
  1469
    |newOrg dltOrg winGrp
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1470
     innerWT    "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1471
     innerHG    "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1472
     h          "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1473
     x          "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1474
     x0         "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1475
     x1         "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1476
     y          "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1477
     w          "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1478
     y0         "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1479
     y1         "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1480
     dX         "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1481
     dY         "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1482
    |
1531
42dcb9760f0f checkin from browser
Stefan Vogel <sv@exept.de>
parents: 1508
diff changeset
  1483
1580
523119ab4e30 scrollTo:anOrigin redraw:doRedraw
ca
parents: 1566
diff changeset
  1484
    realized ifFalse:[
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1485
        ^ self
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1486
    ].
1580
523119ab4e30 scrollTo:anOrigin redraw:doRedraw
ca
parents: 1566
diff changeset
  1487
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1488
    innerWT := self innerWidth.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1489
    innerHG := self innerHeight.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1490
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1491
    h := viewOrigin y.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1492
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1493
    (y := anOrigin y) > h ifTrue:[              "/ end of contents
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1494
        y > (dY := self maxViewOriginY) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1495
            y := dY max:h
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1496
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1497
    ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1498
        y := y max:0.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1499
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1500
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1501
    (x := anOrigin x) > 0 ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1502
        x := x min:(self widthOfContents - innerWT).
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1503
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1504
    x      := x max:0.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1505
    newOrg := (x @ y).
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1506
    dltOrg := newOrg - viewOrigin.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1507
    dX     := dltOrg x.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1508
    dY     := dltOrg y.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1509
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1510
    (dX == 0 and:[dY == 0]) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1511
        ^ self
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1512
    ].
1534
8c4272e42539 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1532
diff changeset
  1513
    dY := dY abs.
8c4272e42539 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1532
diff changeset
  1514
    dX := dX abs.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1515
1534
8c4272e42539 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1532
diff changeset
  1516
    (   (dX ~~ 0 and:[dY ~~ 0])                         "/ scroll vertical & horizontal
8c4272e42539 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1532
diff changeset
  1517
     or:[(innerHG - dY < 20 or:[innerWT - dX < 20])]    "/ faster to invalidate screen
8c4272e42539 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1532
diff changeset
  1518
    ) ifTrue:[
8c4272e42539 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1532
diff changeset
  1519
        viewOrigin := newOrg.
8c4272e42539 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1532
diff changeset
  1520
        self originChanged:dltOrg.
8c4272e42539 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1532
diff changeset
  1521
      ^ self invalidate
8c4272e42539 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1532
diff changeset
  1522
    ].
1753
17769f8df493 #scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents: 1752
diff changeset
  1523
17769f8df493 #scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents: 1752
diff changeset
  1524
    (winGrp := self windowGroup) notNil ifTrue:[
17769f8df493 #scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents: 1752
diff changeset
  1525
        winGrp processRealExposeEventsFor:self.
17769f8df493 #scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents: 1752
diff changeset
  1526
    ].
17769f8df493 #scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents: 1752
diff changeset
  1527
17769f8df493 #scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents: 1752
diff changeset
  1528
    self originWillChange.
17769f8df493 #scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents: 1752
diff changeset
  1529
17769f8df493 #scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents: 1752
diff changeset
  1530
    doRedraw ifFalse:[
17769f8df493 #scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents: 1752
diff changeset
  1531
        viewOrigin := newOrg.
17769f8df493 #scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents: 1752
diff changeset
  1532
        ^ self originChanged:dltOrg
17769f8df493 #scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents: 1752
diff changeset
  1533
    ].
17769f8df493 #scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents: 1752
diff changeset
  1534
1531
42dcb9760f0f checkin from browser
Stefan Vogel <sv@exept.de>
parents: 1508
diff changeset
  1535
    self catchExpose.
42dcb9760f0f checkin from browser
Stefan Vogel <sv@exept.de>
parents: 1508
diff changeset
  1536
    viewOrigin := newOrg.
42dcb9760f0f checkin from browser
Stefan Vogel <sv@exept.de>
parents: 1508
diff changeset
  1537
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1538
    dY ~~ 0 ifTrue:[                            "/ SCROLL VERTICAL
1534
8c4272e42539 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1532
diff changeset
  1539
        y0 := y1 := margin + dY.
8c4272e42539 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1532
diff changeset
  1540
        h  := innerHG - dY.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1541
1534
8c4272e42539 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1532
diff changeset
  1542
        dltOrg y < 0 ifTrue:[y0 := margin. y := y0]
8c4272e42539 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1532
diff changeset
  1543
                    ifFalse:[y1 := margin. y := y1 + h].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1544
1534
8c4272e42539 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1532
diff changeset
  1545
        self copyFrom:self x:margin y:y0 toX:margin y:y1 width:innerWT height:h async:true.
1535
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  1546
        self invalidateX:margin y:y width:innerWT height:(innerHG - h).
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1547
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1548
    ] ifFalse:[                                 "/ SCROLL HORIZONTAL
1534
8c4272e42539 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1532
diff changeset
  1549
        x0 := x1 := dX + margin.
8c4272e42539 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1532
diff changeset
  1550
        w  := innerWT - dX.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1551
1534
8c4272e42539 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1532
diff changeset
  1552
        dltOrg x < 0 ifTrue:[x0 := x := margin ]
8c4272e42539 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1532
diff changeset
  1553
                    ifFalse:[x1 := margin. x := w].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1554
1534
8c4272e42539 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1532
diff changeset
  1555
        self copyFrom:self x:x0 y:margin toX:x1 y:margin width:w height:innerHG async:true.
1535
872422bc0e81 support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  1556
        self invalidateX:x y:margin width:(width - w) height:innerHG.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1557
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1558
    self originChanged:dltOrg.
1531
42dcb9760f0f checkin from browser
Stefan Vogel <sv@exept.de>
parents: 1508
diff changeset
  1559
    self waitForExpose.
42dcb9760f0f checkin from browser
Stefan Vogel <sv@exept.de>
parents: 1508
diff changeset
  1560
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1561
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1562
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1563
scrollToLine:aLineNumber
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1564
    "make line visible
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1565
    "
1744
2447f4a3dd7c computation of absoluteY for a line
ca
parents: 1743
diff changeset
  1566
    |inHg "{ Class:SmallInteger }"
2447f4a3dd7c computation of absoluteY for a line
ca
parents: 1743
diff changeset
  1567
     yTop "{ Class:SmallInteger }"
2447f4a3dd7c computation of absoluteY for a line
ca
parents: 1743
diff changeset
  1568
     orgY "{ Class:SmallInteger }"
2447f4a3dd7c computation of absoluteY for a line
ca
parents: 1743
diff changeset
  1569
     yBot "{ Class:SmallInteger }"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1570
    |
1744
2447f4a3dd7c computation of absoluteY for a line
ca
parents: 1743
diff changeset
  1571
    (shown and:[aLineNumber notNil and:[aLineNumber between:1 and:list size]]) ifFalse:[
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1572
        ^ self
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1573
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1574
1744
2447f4a3dd7c computation of absoluteY for a line
ca
parents: 1743
diff changeset
  1575
    yTop := self yAbsoluteOfLine:aLineNumber.
2447f4a3dd7c computation of absoluteY for a line
ca
parents: 1743
diff changeset
  1576
    inHg := self innerHeight.
2447f4a3dd7c computation of absoluteY for a line
ca
parents: 1743
diff changeset
  1577
    orgY := viewOrigin y.
2447f4a3dd7c computation of absoluteY for a line
ca
parents: 1743
diff changeset
  1578
2447f4a3dd7c computation of absoluteY for a line
ca
parents: 1743
diff changeset
  1579
    yTop > orgY ifTrue:[
2447f4a3dd7c computation of absoluteY for a line
ca
parents: 1743
diff changeset
  1580
        yBot := self yAbsoluteOfLine:(aLineNumber + 1).
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1581
1744
2447f4a3dd7c computation of absoluteY for a line
ca
parents: 1743
diff changeset
  1582
        yBot <= (orgY + inHg) ifTrue:[
2447f4a3dd7c computation of absoluteY for a line
ca
parents: 1743
diff changeset
  1583
            ^ self
2447f4a3dd7c computation of absoluteY for a line
ca
parents: 1743
diff changeset
  1584
        ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1585
    ].
1744
2447f4a3dd7c computation of absoluteY for a line
ca
parents: 1743
diff changeset
  1586
    yTop := (yTop - (inHg // 2)) max:0.
2447f4a3dd7c computation of absoluteY for a line
ca
parents: 1743
diff changeset
  1587
    self scrollTo:(viewOrigin x @ yTop).
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1588
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1589
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1590
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1591
1748
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1592
!ListModelView methodsFor:'scrolling auto'!
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1593
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1594
startAutoScroll:aBlock distance:aDistance
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1595
    "setup for auto-scroll (when button-press-moving below view);
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1596
     - timeDelta for scroll is computed from distance
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1597
    "
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1598
    |timeDelta|
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1599
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1600
    (autoScroll and:[aBlock notNil]) ifFalse:[
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1601
        ^ self stopAutoScroll
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1602
    ].
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1603
    autoScrollBlock notNil ifTrue:[
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1604
        Processor removeTimedBlock:autoScrollBlock.
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1605
    ] ifFalse:[
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1606
        self compressMotionEvents:false.
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1607
    ].
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1608
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1609
    timeDelta := 0.5 / (aDistance abs).
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1610
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1611
    autoScrollBlock := [
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1612
        aBlock value.
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1613
        Processor addTimedBlock:autoScrollBlock afterSeconds:timeDelta.
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1614
    ].
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1615
    Processor addTimedBlock:autoScrollBlock afterSeconds:timeDelta.
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1616
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1617
!
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1618
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1619
stopAutoScroll
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1620
    "stop any autoScroll
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1621
    "
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1622
    autoScrollBlock notNil ifTrue:[
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1623
        Processor removeTimedBlock:autoScrollBlock.
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1624
        autoScrollBlock := nil.
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1625
        self compressMotionEvents:true.
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1626
    ].
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1627
! !
0a2213a15e06 support of auto scrolling
ca
parents: 1744
diff changeset
  1628
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1629
!ListModelView class methodsFor:'documentation'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1630
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1631
version
2097
78bfd62fdcbc on: -> onDevice:
Claus Gittinger <cg@exept.de>
parents: 1995
diff changeset
  1632
    ^ '$Header: /cvs/stx/stx/libwidg2/ListModelView.st,v 1.53 2002-05-06 05:59:05 cg Exp $'
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1633
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1634
ListModelView initialize!