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