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