author | Claus Gittinger <cg@exept.de> |
Tue, 24 Jan 2006 18:56:28 +0100 | |
changeset 2894 | 28ba8be648fd |
parent 2893 | 209464e02455 |
child 2896 | 5c038332a9aa |
permissions | -rw-r--r-- |
375 | 1 |
" |
2 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
1401 | 3 |
All Rights Reserved |
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
||
1759 | 14 |
"{ Package: 'stx:libwidg2' }" |
15 |
||
1401 | 16 |
View subclass:#NoteBookView |
2760 | 17 |
instanceVariableNames:'list listHolder foregroundColor backgroundColor selection enabled |
18 |
action useIndex direction numberOfLines selectConditionBlock |
|
19 |
accessTabMenuAction canvas canvasInset canvasHolder |
|
20 |
halfLightColor halfShadowColor fitLastRow tabModus |
|
21 |
lastComputedExtent keepCanvas activeForegroundColor |
|
22 |
activeBackgroundColor drawLightColor edgeStyle tabInset |
|
2431 | 23 |
tabLabelInset disabledForegroundColor tabLevel tabTopMargin |
2686 | 24 |
tabBottomMargin selectionInsetX selectionInsetY translateLabel |
2875 | 25 |
buttonPrev buttonNext tabRightMargin tabLeftMargin |
2882 | 26 |
showDestroyTabButton destroyTabAction activeTabMarkerColor |
27 |
activeTabMarkerFGColor' |
|
2760 | 28 |
classVariableNames:'DefaultForegroundColor DefaultBackgroundColor |
29 |
DefaultActiveForegroundColor DefaultActiveBackgroundColor |
|
1682 | 30 |
DefaultShadowColor DefaultHalfShadowColor DefaultLightColor |
2758 | 31 |
DefaultHalfLightColor DefaultEdgeStyle DisabledForegroundColor |
2763 | 32 |
DefaultActiveTabMarkerColor DefaultActiveTabMarkerFgColor' |
1401 | 33 |
poolDictionaries:'' |
34 |
category:'Views-Layout' |
|
35 |
! |
|
36 |
||
37 |
Object subclass:#Tab |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
38 |
instanceVariableNames:'label model printableLabel disabledLabel lineNr unselectedLayout |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
39 |
selectedLayout layout extent accessCharacter' |
1401 | 40 |
classVariableNames:'' |
41 |
poolDictionaries:'' |
|
42 |
privateIn:NoteBookView |
|
43 |
! |
|
44 |
||
45 |
!NoteBookView class methodsFor:'documentation'! |
|
46 |
||
47 |
copyright |
|
48 |
" |
|
49 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
50 |
All Rights Reserved |
|
375 | 51 |
|
52 |
This software is furnished under a license and may be used |
|
53 |
only in accordance with the terms of that license and with the |
|
54 |
inclusion of the above copyright notice. This software may not |
|
55 |
be provided or otherwise made available to, or used by, any |
|
56 |
other person. No title to or ownership of the software is |
|
57 |
hereby transferred. |
|
58 |
" |
|
59 |
||
355 | 60 |
! |
61 |
||
62 |
documentation |
|
63 |
" |
|
1401 | 64 |
implements the noteBook. |
65 |
May also be used on its own (without a surrounding noteBook). |
|
66 |
||
67 |
[author:] |
|
68 |
Claus Atzkern |
|
408 | 69 |
|
70 |
[see also:] |
|
71 |
TabView |
|
355 | 72 |
" |
1401 | 73 |
|
408 | 74 |
! |
355 | 75 |
|
408 | 76 |
examples |
77 |
" |
|
78 |
tabs at top ( default ) |
|
79 |
[exBegin] |
|
1401 | 80 |
|top tab| |
375 | 81 |
|
1401 | 82 |
top := StandardSystemView extent:250@100. |
1683 | 83 |
tab := NoteBookView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top. |
1401 | 84 |
tab list:#( 'Foo' 'Bar' 'Baz' ). |
2529 | 85 |
tab action:[:index| Transcript showCR:index]. |
408 | 86 |
top open. |
87 |
[exEnd] |
|
88 |
||
89 |
||
90 |
tabs at bottom |
|
91 |
[exBegin] |
|
1401 | 92 |
|top tab| |
375 | 93 |
|
1401 | 94 |
top := StandardSystemView extent:250@100. |
1683 | 95 |
tab := NoteBookView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top. |
1401 | 96 |
tab direction:#bottom. |
97 |
tab list:#( 'Foo' 'Bar' 'Baz' ). |
|
2529 | 98 |
tab action:[:index| Transcript showCR:index]. |
375 | 99 |
top open. |
408 | 100 |
[exEnd] |
375 | 101 |
|
408 | 102 |
tabs at left |
103 |
[exBegin] |
|
1401 | 104 |
|top tab| |
375 | 105 |
|
1401 | 106 |
top := StandardSystemView extent:100@200. |
1683 | 107 |
tab := NoteBookView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top. |
1401 | 108 |
tab direction:#left. |
109 |
tab list:#( 'Foo' 'Bar' 'Baz' ). |
|
2529 | 110 |
tab action:[:index| Transcript showCR:index]. |
408 | 111 |
top open. |
112 |
[exEnd] |
|
375 | 113 |
|
408 | 114 |
tabs at right |
115 |
[exBegin] |
|
1401 | 116 |
|top tab| |
375 | 117 |
|
1401 | 118 |
top := StandardSystemView extent:100@200. |
1683 | 119 |
tab := NoteBookView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top. |
1401 | 120 |
tab direction:#right. |
121 |
tab list:#( 'Foo' 'Bar' 'Baz' ). |
|
2529 | 122 |
tab action:[:index| Transcript showCR:index]. |
375 | 123 |
top open. |
408 | 124 |
[exEnd] |
375 | 125 |
|
126 |
||
408 | 127 |
" |
1401 | 128 |
! ! |
129 |
||
130 |
!NoteBookView class methodsFor:'defaults'! |
|
131 |
||
132 |
defaultFont |
|
133 |
^ MenuView defaultFont |
|
1682 | 134 |
! |
135 |
||
136 |
updateStyleCache |
|
2777 | 137 |
"extract values from the styleSheet and cache them in class variables" |
138 |
||
139 |
<resource: #style (#'noteBook.foregroundColor' #'noteBook.backgroundColor' |
|
140 |
#'noteBook.activeForegroundColor' #'noteBook.activeBackgroundColor' |
|
141 |
#'noteBook.lightColor' #'noteBook.halfLightColor' #'noteBook.shadowColor' |
|
142 |
#'noteBook.halfShadowColor' #'noteBook.edgeStyle' |
|
143 |
#'noteBook.activeTabMarkerColor' |
|
144 |
)> |
|
145 |
||
1682 | 146 |
DefaultForegroundColor := StyleSheet colorAt:#'noteBook.foregroundColor'. |
147 |
DefaultForegroundColor isNil ifTrue:[ |
|
148 |
DefaultForegroundColor := StyleSheet colorAt:#'button.foregroundColor'. |
|
149 |
]. |
|
2760 | 150 |
DefaultBackgroundColor := StyleSheet colorAt:#'noteBook.backgroundColor'. |
1682 | 151 |
|
152 |
DefaultActiveForegroundColor := StyleSheet colorAt:#'noteBook.activeForegroundColor'. |
|
153 |
DefaultActiveForegroundColor isNil ifTrue:[ |
|
154 |
DefaultActiveForegroundColor := StyleSheet colorAt:#'button.activeForegroundColor' |
|
155 |
]. |
|
2760 | 156 |
DefaultActiveBackgroundColor := StyleSheet colorAt:#'noteBook.activeBackgroundColor'. |
1682 | 157 |
|
158 |
DefaultLightColor := StyleSheet colorAt:#'noteBook.lightColor'. |
|
159 |
DefaultLightColor isNil ifTrue:[ |
|
160 |
DefaultLightColor := StyleSheet colorAt:'button.lightColor' |
|
161 |
]. |
|
162 |
DefaultHalfLightColor := StyleSheet colorAt:#'noteBook.halfLightColor'. |
|
163 |
DefaultHalfLightColor isNil ifTrue:[ |
|
164 |
DefaultHalfLightColor := StyleSheet colorAt:#'button.halfLightColor' |
|
165 |
]. |
|
166 |
||
167 |
DefaultShadowColor := StyleSheet colorAt:#'noteBook.shadowColor'. |
|
168 |
DefaultShadowColor isNil ifTrue:[ |
|
169 |
DefaultShadowColor := StyleSheet colorAt:'button.shadowColor' |
|
170 |
]. |
|
171 |
DefaultHalfShadowColor := StyleSheet colorAt:#'noteBook.halfShadowColor'. |
|
172 |
DefaultHalfShadowColor isNil ifTrue:[ |
|
173 |
DefaultHalfShadowColor := StyleSheet colorAt:#'button.halfShadowColor' |
|
174 |
]. |
|
175 |
DefaultEdgeStyle := StyleSheet at:#'noteBook.edgeStyle'. |
|
176 |
DefaultEdgeStyle isNil ifTrue:[ |
|
177 |
DefaultEdgeStyle := StyleSheet at:#'button.edgeStyle' |
|
178 |
]. |
|
179 |
||
1683 | 180 |
DefaultEdgeStyle == #softWin95 ifFalse:[ |
1682 | 181 |
DefaultEdgeStyle := nil |
182 |
]. |
|
183 |
||
2758 | 184 |
DefaultActiveTabMarkerColor := StyleSheet colorAt:#'noteBook.activeTabMarkerColor'. |
2763 | 185 |
|
186 |
DefaultActiveTabMarkerColor isNil ifTrue:[ |
|
187 |
DefaultActiveTabMarkerFgColor := nil. |
|
188 |
] ifFalse:[ |
|
189 |
DefaultActiveTabMarkerFgColor := Color redByte:255 greenByte:138 blueByte:41. |
|
190 |
]. |
|
2777 | 191 |
|
192 |
" |
|
193 |
self updateStyleCache |
|
194 |
" |
|
375 | 195 |
! ! |
196 |
||
2496 | 197 |
!NoteBookView methodsFor:'accepting-items'! |
1724
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
198 |
|
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
199 |
tabAtIndex:tabIndex put:newLabel |
2691 | 200 |
"called if the contents of a tab changed; test whether the old layout can |
201 |
be reused otherwise we must recompute the whole list |
|
202 |
" |
|
2431 | 203 |
|tab layout prefX prefY tabExtent| |
1724
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
204 |
|
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
205 |
"/ a single items label has changed |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
206 |
tab := list at:tabIndex ifAbsent:nil. |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
207 |
tab notNil ifTrue:[ |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
208 |
tab label:newLabel on:self. |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
209 |
|
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
210 |
"/ no resizing, if the new string fits |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
211 |
"/ and is not too small for current tab-layout |
1880 | 212 |
layout := tab layout. |
2431 | 213 |
tabExtent := self preferredExtentForTab:tab. |
214 |
||
215 |
( (prefX := tabExtent x) <= layout width |
|
216 |
and:[(prefY := tabExtent y) <= layout height] |
|
1880 | 217 |
) ifTrue:[ |
218 |
"/ the new string fits into current tab-layout |
|
219 |
||
220 |
numberOfLines == 1 ifTrue:[ "/ do not change the layout |
|
221 |
^ self invalidateTab:tab |
|
222 |
]. |
|
223 |
||
224 |
"/ check whether the string is not too small for current tab-layout |
|
225 |
((layout width <= (prefX * 1.5)) and:[layout height <= (prefY * 1.5)]) ifTrue:[ |
|
226 |
^ self invalidateTab:tab. "/ do not change the layout |
|
1724
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
227 |
]. |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
228 |
]. |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
229 |
self recomputeList. |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
230 |
self invalidate. |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
231 |
^ self. |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
232 |
]. |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
233 |
"/ can this happen ? |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
234 |
|
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
235 |
"Created: / 25.2.2000 / 14:13:59 / cg" |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
236 |
! ! |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
237 |
|
375 | 238 |
!NoteBookView methodsFor:'accessing'! |
355 | 239 |
|
375 | 240 |
canvas |
2691 | 241 |
"returns the canvas; the containter view |
242 |
" |
|
375 | 243 |
^ canvas |
244 |
! |
|
245 |
||
2492 | 246 |
canvas:newCanvas |
2010 | 247 |
"change the canvas; the containter view |
375 | 248 |
" |
2492 | 249 |
|oldCanvas| |
250 |
||
251 |
oldCanvas := canvas. |
|
252 |
||
253 |
newCanvas ~~ oldCanvas ifTrue:[ |
|
254 |
oldCanvas notNil ifTrue:[ |
|
255 |
(keepCanvas or:[(oldCanvas objectAttributeAt:#isTabItem) == true]) ifTrue:[ |
|
256 |
oldCanvas unmap. |
|
1413 | 257 |
] ifFalse:[ |
2492 | 258 |
oldCanvas destroy. |
1413 | 259 |
]. |
1401 | 260 |
]. |
2492 | 261 |
canvas := newCanvas. |
262 |
newCanvas notNil ifTrue:[ |
|
1401 | 263 |
tabModus := false. |
2035
6cc4d73f17e1
bug fix when chaning the canvas before being realized
Claus Gittinger <cg@exept.de>
parents:
2010
diff
changeset
|
264 |
|
1680 | 265 |
self resizeCanvas. |
266 |
||
2492 | 267 |
(subViews size == 0 or:[(subViews includesIdentical:newCanvas) not]) ifTrue:[ |
268 |
self addSubView:newCanvas |
|
1549 | 269 |
]. |
1759 | 270 |
|
1687 | 271 |
realized ifTrue:[ |
2492 | 272 |
newCanvas realize. |
273 |
newCanvas raise. |
|
1687 | 274 |
]. |
1401 | 275 |
] |
276 |
]. |
|
277 |
! |
|
278 |
||
279 |
list |
|
280 |
"return the list of Tabs or Labels |
|
281 |
" |
|
282 |
^ list collect:[:aTab| aTab label ] |
|
283 |
||
284 |
! |
|
375 | 285 |
|
1401 | 286 |
list:aList |
287 |
"set the list |
|
288 |
" |
|
2278 | 289 |
|name newList| |
1401 | 290 |
|
1771 | 291 |
name := self selection. |
292 |
newList := OrderedCollection new. |
|
1401 | 293 |
|
1771 | 294 |
aList size == 0 ifTrue:[ |
295 |
list do:[:aTab| aTab removeDependent:self]. |
|
1401 | 296 |
] ifFalse:[ |
1771 | 297 |
list do:[:aTab| |m| |
298 |
( (m := aTab model) notNil |
|
299 |
and:[(aList includesIdentical:m)] |
|
300 |
) ifFalse:[ |
|
301 |
aTab removeDependent:self |
|
302 |
] |
|
303 |
]. |
|
304 |
||
305 |
aList do:[:el| |i tab| |
|
306 |
( el isNil |
|
307 |
or:[(tab := list detect:[:t| t model == el] ifNone:nil) isNil] |
|
308 |
) ifTrue:[ |
|
309 |
tab := Tab label:el on:self. |
|
310 |
tab addDependent:self. |
|
311 |
]. |
|
312 |
newList add:tab |
|
313 |
] |
|
1401 | 314 |
]. |
1771 | 315 |
|
316 |
list := newList. |
|
1401 | 317 |
preferredExtent := nil. |
318 |
numberOfLines := nil. |
|
319 |
||
320 |
selection notNil ifTrue:[ |
|
1433 | 321 |
useIndex ifTrue:[ |
322 |
selection > list size ifTrue:[ |
|
323 |
selection := nil. |
|
324 |
self selectionChanged. |
|
325 |
] |
|
326 |
] ifFalse:[ |
|
327 |
selection := list findFirst:[:el| el label = name ]. |
|
328 |
selection == 0 ifTrue:[ |
|
329 |
selection := nil. |
|
330 |
self selectionChanged. |
|
331 |
] |
|
1401 | 332 |
] |
333 |
]. |
|
1680 | 334 |
self recomputeList. |
335 |
self invalidate. |
|
1401 | 336 |
! |
375 | 337 |
|
1401 | 338 |
listIndexOf:something |
2691 | 339 |
"convert something to an index into the list; |
340 |
returns the index or nil if not found |
|
1401 | 341 |
" |
342 |
|index| |
|
343 |
||
344 |
something isNil ifTrue:[^ nil ]. |
|
345 |
||
346 |
something isNumber ifTrue:[ |
|
347 |
index := something |
|
348 |
] ifFalse:[ |
|
349 |
index := list findFirst:[:aTab|aTab label = something]. |
|
350 |
index == 0 ifTrue:[ |
|
351 |
index := list findFirst:[:aTab|aTab printableLabel = something] |
|
352 |
] |
|
353 |
]. |
|
354 |
^ (index between:1 and:list size) ifTrue:[index] ifFalse:[nil] |
|
355 |
! |
|
356 |
||
357 |
useIndex |
|
2691 | 358 |
"use index instead of tab name |
1401 | 359 |
" |
360 |
^ useIndex |
|
361 |
! |
|
362 |
||
363 |
useIndex:aBoolean |
|
364 |
"set/clear the useIndex flag. If set, both actionBlock and change-messages |
|
365 |
are passed the index(indices) of the selection as argument. |
|
366 |
If clear, the value(s) (i.e. the selected string) is passed. |
|
367 |
Default is false." |
|
368 |
||
369 |
useIndex := aBoolean |
|
370 |
||
371 |
||
372 |
! ! |
|
373 |
||
1818 | 374 |
!NoteBookView methodsFor:'accessing-actions'! |
1802 | 375 |
|
376 |
accessTabMenuAction |
|
377 |
"callback to retrieve the menu for a specific tab. |
|
378 |
the argument to the block is the index of the tab |
|
379 |
" |
|
380 |
^ accessTabMenuAction |
|
381 |
! |
|
382 |
||
383 |
accessTabMenuAction:aOneArgAction |
|
384 |
"callback to retrieve the menu for a specific tab. |
|
385 |
the argument to the block is the index of the tab |
|
386 |
" |
|
387 |
accessTabMenuAction := aOneArgAction. |
|
388 |
! |
|
389 |
||
390 |
action |
|
391 |
"get the action block to be performed on select; the argument to |
|
392 |
the block is the selected index or nil in case of no selection. |
|
393 |
" |
|
394 |
^ action |
|
395 |
! |
|
396 |
||
397 |
action:oneArgBlock |
|
398 |
"set the action block to be performed on select; the argument to |
|
399 |
the block is the selected index or nil in case of no selection. |
|
400 |
" |
|
401 |
action := oneArgBlock. |
|
402 |
||
403 |
! ! |
|
404 |
||
1818 | 405 |
!NoteBookView methodsFor:'accessing-behavior'! |
1401 | 406 |
|
2875 | 407 |
destroyTabAction |
408 |
^ destroyTabAction |
|
409 |
! |
|
410 |
||
411 |
destroyTabAction:aOneArgBlock |
|
412 |
destroyTabAction := aOneArgBlock |
|
413 |
! |
|
414 |
||
1401 | 415 |
enabled |
2875 | 416 |
"returns true if tabs are enabled" |
417 |
||
1401 | 418 |
^ enabled |
419 |
! |
|
420 |
||
421 |
enabled:aState |
|
2875 | 422 |
"set the enabled state of tabs" |
423 |
||
1401 | 424 |
|state| |
425 |
||
426 |
state := aState ? true. |
|
427 |
||
428 |
enabled ~~ state ifTrue:[ |
|
429 |
enabled := state. |
|
430 |
self invalidate. |
|
375 | 431 |
] |
432 |
! |
|
433 |
||
2698 | 434 |
isEnabled |
2875 | 435 |
"returns the enabled state" |
436 |
||
2698 | 437 |
^ enabled |
438 |
! |
|
439 |
||
1413 | 440 |
keepCanvas:aBoolean |
441 |
"if false (the default), the previous canvas is destroyed, whenever |
|
442 |
a new canvas is set. |
|
443 |
if true, it is unmapped and kept. |
|
444 |
Set this flag, if the application changes the canvas but wants |
|
445 |
them to be kept for fast switching." |
|
446 |
||
447 |
keepCanvas := aBoolean. |
|
448 |
! |
|
449 |
||
1401 | 450 |
selectConditionBlock |
451 |
"get the conditionBlock; this block is evaluated before a selection |
|
452 |
change is performed; the change will not be done, if the evaluation |
|
2875 | 453 |
returns false. The argument to the block is the selection index." |
454 |
||
1401 | 455 |
^ selectConditionBlock |
432 | 456 |
! |
457 |
||
1401 | 458 |
selectConditionBlock:aOneArgBlock |
459 |
"get the conditionBlock; this block is evaluated before a selection |
|
460 |
change is performed; the change will not be done, if the evaluation |
|
2875 | 461 |
returns false. The argument to the block is the selection index." |
462 |
||
1401 | 463 |
selectConditionBlock := aOneArgBlock |
2629 | 464 |
! |
465 |
||
466 |
translateLabel |
|
2875 | 467 |
"true if labels are translated" |
468 |
||
2629 | 469 |
^ translateLabel |
470 |
! |
|
471 |
||
472 |
translateLabel:aBoolean |
|
2875 | 473 |
"set to true if labels should be translated" |
474 |
||
2629 | 475 |
translateLabel := aBoolean. |
476 |
! |
|
477 |
||
478 |
translateToDisplayLabel:aString |
|
2875 | 479 |
"translate the label" |
480 |
||
2629 | 481 |
|application builder string| |
482 |
||
483 |
translateLabel ifFalse:[ ^ aString ]. |
|
484 |
||
485 |
aString isEmptyOrNil ifTrue:[ ^ aString ]. |
|
486 |
||
487 |
application := self application. |
|
488 |
application isNil ifTrue:[^ aString ]. |
|
489 |
||
490 |
builder := application builder. |
|
491 |
||
492 |
builder isNil ifTrue:[ |
|
493 |
string := application resources string:aString. |
|
494 |
] ifFalse:[ |
|
495 |
||
496 |
string := builder aspectAt:(aString asSymbol). |
|
497 |
string notNil ifTrue:[^ string ]. |
|
498 |
string := builder resources string:aString. |
|
499 |
]. |
|
500 |
^ string ? aString |
|
432 | 501 |
! ! |
502 |
||
2279 | 503 |
!NoteBookView methodsFor:'accessing-colors'! |
419 | 504 |
|
2760 | 505 |
activeBackgroundColor |
506 |
"returns the bg color used when drawing the active tabs label" |
|
507 |
||
508 |
^ activeBackgroundColor |
|
509 |
! |
|
510 |
||
1442 | 511 |
activeForegroundColor |
2760 | 512 |
"returns the color used when drawing the active tabs label" |
513 |
||
1442 | 514 |
^ activeForegroundColor |
515 |
! |
|
516 |
||
2758 | 517 |
activeTabMarkerColor |
518 |
"win-XP style marker" |
|
519 |
||
2882 | 520 |
^ activeTabMarkerColor |
2758 | 521 |
! |
522 |
||
2763 | 523 |
activeTabMarkerFgColor |
524 |
"win-XP style marker" |
|
525 |
||
2882 | 526 |
^ activeTabMarkerFGColor |
2763 | 527 |
! |
528 |
||
1401 | 529 |
backgroundColor |
2760 | 530 |
"return the backgroundColor of the notebook view" |
531 |
||
532 |
^ backgroundColor |
|
408 | 533 |
! |
534 |
||
2883 | 535 |
destroyTabForegroundColor |
536 |
"returns the color used to draw the destroy button" |
|
537 |
||
538 |
^ foregroundColor. |
|
539 |
||
540 |
"/ foregroundColor brightness < 0.5 ifTrue:[ |
|
541 |
"/ ^ Color grey:40 |
|
542 |
"/ ] ifFalse:[ |
|
543 |
"/ ^ Color grey:60 |
|
544 |
"/ ]. |
|
545 |
! |
|
546 |
||
1700 | 547 |
disabledForegroundColor |
2760 | 548 |
"returns the color used when drawing disabled tab labels" |
549 |
||
1700 | 550 |
^ disabledForegroundColor |
551 |
! |
|
552 |
||
1682 | 553 |
drawLightColor |
2760 | 554 |
"get the color to be used for lighted edges; bug fix caused by common drawEdge" |
555 |
||
1682 | 556 |
^ drawLightColor |
557 |
! |
|
558 |
||
1401 | 559 |
foregroundColor |
2760 | 560 |
"return the color used for drawing text" |
561 |
||
1401 | 562 |
^ foregroundColor |
563 |
! |
|
564 |
||
565 |
foregroundColor:aColor |
|
2760 | 566 |
"set the color to be used for drawing text" |
567 |
||
1401 | 568 |
aColor ~= foregroundColor ifTrue:[ |
569 |
foregroundColor := aColor. |
|
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2629
diff
changeset
|
570 |
self invalidate |
1401 | 571 |
] |
419 | 572 |
! |
573 |
||
1401 | 574 |
halfLightColor |
575 |
^ halfLightColor |
|
576 |
! |
|
577 |
||
578 |
halfShadowColor |
|
579 |
^ halfShadowColor |
|
580 |
! |
|
581 |
||
1684 | 582 |
viewBackground:aColor |
583 |
super viewBackground:aColor. |
|
584 |
||
2292 | 585 |
"/ (edgeStyle isNil and:[viewBackground isColor]) ifTrue:[ |
586 |
"/ halfShadowColor := shadowColor. |
|
587 |
"/ halfLightColor := lightColor. |
|
588 |
"/ drawLightColor := lightColor. |
|
589 |
"/ ]. |
|
590 |
"/ |
|
591 |
"/ DefaultShadowColor isNil ifTrue:[ |
|
592 |
"/ shadowColor := aColor darkened onDevice:device |
|
593 |
"/ ]. |
|
594 |
"/ DefaultLightColor isNil ifTrue:[ |
|
595 |
"/ lightColor := aColor lightened onDevice:device |
|
596 |
"/ ]. |
|
375 | 597 |
! ! |
598 |
||
2279 | 599 |
!NoteBookView methodsFor:'accessing-dimension'! |
600 |
||
2881 | 601 |
activeTabMarkerHeight |
602 |
^ 3 |
|
603 |
! |
|
604 |
||
605 |
destroyButtonFrameForTab:aTab |
|
606 |
|l bW bH dX dY bLeft bTop| |
|
607 |
||
608 |
bW := self destroyButtonWidth. |
|
609 |
bH := self destroyButtonHeight. |
|
610 |
dX := self destroyButtonSepX. |
|
611 |
dY := self destroyButtonSepY. |
|
2882 | 612 |
|
2881 | 613 |
l := aTab layout. |
2882 | 614 |
|
2881 | 615 |
bLeft := l right - bW - dX. |
616 |
bTop := l top + dY. |
|
2882 | 617 |
|
618 |
^ (bLeft @ bTop) extent:(bW @ bH ) |
|
2881 | 619 |
! |
620 |
||
2875 | 621 |
destroyButtonHeight |
622 |
^ 8 |
|
623 |
! |
|
624 |
||
625 |
destroyButtonSepX |
|
2881 | 626 |
"separating space between tabs right and the destroyButton" |
627 |
||
2882 | 628 |
^ 4 |
2875 | 629 |
! |
630 |
||
631 |
destroyButtonSepY |
|
2881 | 632 |
"separating space between tabs top and the destroyButton" |
633 |
||
2882 | 634 |
^ 3 |
2875 | 635 |
! |
636 |
||
637 |
destroyButtonWidth |
|
638 |
^ 8 |
|
639 |
! |
|
640 |
||
2280 | 641 |
preferredExtent |
2875 | 642 |
"compute max extent x/y based on one line" |
643 |
||
644 |
|lvl size x y isHorizontal insetX insetY ext| |
|
2280 | 645 |
|
646 |
preferredExtent notNil ifTrue:[ ^ preferredExtent ]. |
|
647 |
||
648 |
x := y := 0. |
|
2875 | 649 |
lvl := (tabLevel abs) max:1. |
2280 | 650 |
size := list size. |
651 |
||
652 |
size ~~ 0 ifTrue:[ |
|
653 |
list do:[:aTab| |
|
2875 | 654 |
|tabExtent| |
655 |
||
656 |
tabExtent := self preferredExtentForTab:aTab. |
|
657 |
x := tabExtent x + x. |
|
658 |
y := tabExtent y max:y. |
|
2280 | 659 |
]. |
660 |
]. |
|
2875 | 661 |
y := y + selectionInsetY + lvl + tabTopMargin + tabBottomMargin. |
662 |
x := x + selectionInsetX + selectionInsetX + (lvl + lvl * size). |
|
2280 | 663 |
|
2284 | 664 |
isHorizontal := self isHorizontal. |
665 |
||
2691 | 666 |
isHorizontal ifTrue:[ |
667 |
x := x + self tabLeftMargin + self tabRightMargin |
|
668 |
] ifFalse:[ |
|
669 |
y := y + self tabLeftMargin + self tabRightMargin |
|
670 |
]. |
|
671 |
||
2284 | 672 |
tabModus ifFalse:[ |
673 |
canvasInset isPoint ifTrue:[ |
|
674 |
insetX := canvasInset x. |
|
675 |
insetY := canvasInset y. |
|
676 |
] ifFalse:[ |
|
677 |
insetX := insetY := canvasInset. |
|
678 |
]. |
|
2875 | 679 |
canvas notNil ifTrue:[ ext := canvas preferredExtent ] |
680 |
ifFalse:[ ext := 100@100 ]. |
|
681 |
||
682 |
y := y + insetY + insetY + ext y. |
|
683 |
x := x max:ext x. |
|
684 |
x := x + insetX + insetX + lvl + lvl. |
|
2284 | 685 |
]. |
686 |
||
687 |
isHorizontal ifTrue:[ ^ x @ y ]. |
|
2431 | 688 |
^ y @ x |
689 |
! |
|
690 |
||
691 |
preferredExtentForTab:aTab |
|
2875 | 692 |
"returns the preferred extent of a specific tab" |
693 |
||
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
694 |
|e sepX| |
2875 | 695 |
|
696 |
e := aTab extent + tabLabelInset. |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
697 |
(showDestroyTabButton and:[destroyTabAction notNil]) ifTrue:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
698 |
sepX := self destroyButtonSepX. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
699 |
e := e + ((sepX + self destroyButtonWidth + sepX) @ 0). |
2875 | 700 |
]. |
701 |
^ e. |
|
2279 | 702 |
! ! |
703 |
||
2532 | 704 |
!NoteBookView methodsFor:'accessing-mvc'! |
705 |
||
2698 | 706 |
canvasHolder |
707 |
"get the model, which keeps the canvas, a kind of SimpleView |
|
708 |
" |
|
709 |
^ canvasHolder |
|
710 |
! |
|
711 |
||
712 |
canvasHolder:aValueHolder |
|
713 |
"set the model, which keeps the canvas, a kind of SimpleView |
|
714 |
" |
|
715 |
canvasHolder removeDependent:self. |
|
716 |
||
717 |
(canvasHolder := aValueHolder) notNil ifTrue:[ |
|
718 |
canvasHolder addDependent:self. |
|
719 |
self canvas:(canvasHolder value) |
|
720 |
] |
|
721 |
||
722 |
||
723 |
! |
|
724 |
||
725 |
listHolder |
|
726 |
"get the model, which keeps the list of Tabs or Labels |
|
727 |
" |
|
728 |
^ listHolder |
|
729 |
! |
|
730 |
||
731 |
listHolder:aValueHolder |
|
732 |
"set the model, which keeps the list of Tabs or Labels |
|
733 |
" |
|
734 |
listHolder removeDependent:self. |
|
735 |
||
736 |
(listHolder := aValueHolder) notNil ifTrue:[ |
|
737 |
listHolder addDependent:self. |
|
738 |
self list:listHolder value. |
|
739 |
]. |
|
740 |
! |
|
741 |
||
2532 | 742 |
model:aValueHolder |
2533 | 743 |
"set the model, which keeps the selection" |
744 |
||
2532 | 745 |
super model:aValueHolder. |
746 |
||
747 |
model notNil ifTrue:[ |
|
748 |
self selection:(model value) |
|
749 |
] |
|
750 |
! ! |
|
751 |
||
1818 | 752 |
!NoteBookView methodsFor:'accessing-style'! |
1401 | 753 |
|
2279 | 754 |
canvasInset |
755 |
"inset of the canvas relative to my frame |
|
756 |
tabLevel + canvasInset == origin of canvas |
|
757 |
" |
|
758 |
^ canvasInset |
|
759 |
! |
|
760 |
||
761 |
canvasInset:anInset |
|
762 |
"inset of the canvas relative to my frame |
|
763 |
tabLevel + canvasInset == origin of canvas |
|
764 |
" |
|
765 |
anInset ~~ canvasInset ifTrue:[ |
|
766 |
canvasInset := anInset. |
|
2282 | 767 |
self styleChanged. |
2279 | 768 |
]. |
769 |
! |
|
770 |
||
1401 | 771 |
direction |
772 |
"returns the direction of tabs as symbol. On default the value is |
|
773 |
set to #top. Valid symbols are: |
|
774 |
#top arrange tabs to be on top of a view |
|
775 |
#bottom arrange tabs to be on bottom of a view |
|
776 |
#left arrange tabs to be on left of a view |
|
777 |
#right arrange tabs to be on right of a view |
|
778 |
" |
|
779 |
^ direction |
|
780 |
||
781 |
! |
|
782 |
||
783 |
direction:aDirection |
|
784 |
"change the direction of tabs. On default the value is set to #top. |
|
785 |
Valid symbols are: |
|
786 |
#top arrange tabs to be on top of a view |
|
787 |
#bottom arrange tabs to be on bottom of a view |
|
788 |
#left arrange tabs to be on left of a view |
|
789 |
#right arrange tabs to be on right of a view |
|
790 |
" |
|
791 |
direction ~~ aDirection ifTrue:[ |
|
2282 | 792 |
direction := aDirection. |
793 |
self styleChanged. |
|
1401 | 794 |
]. |
795 |
! |
|
375 | 796 |
|
1401 | 797 |
fitLastRow |
798 |
"in case of true, the last row is expanded to the view size like all |
|
799 |
other raws. In case of false all the tabs in the last raw keep their |
|
800 |
preferred extent (x or y) dependant on the direction. |
|
801 |
" |
|
802 |
^ fitLastRow |
|
803 |
! |
|
804 |
||
805 |
fitLastRow:aBool |
|
806 |
"in case of true, the last row is expanded to the view size like all |
|
807 |
other raws. In case of false all the tabs in the last raw keep their |
|
808 |
preferred extent (x or y) dependant on the direction. |
|
375 | 809 |
" |
2282 | 810 |
|
811 |
fitLastRow ~~ aBool ifTrue:[ |
|
812 |
fitLastRow := aBool. |
|
813 |
self styleChanged. |
|
814 |
]. |
|
815 |
! |
|
816 |
||
2698 | 817 |
hasScrollButtons |
818 |
^ buttonNext notNil |
|
819 |
! |
|
820 |
||
821 |
hasScrollButtons:aBoolean |
|
822 |
|hasScrollButtons| |
|
823 |
||
824 |
hasScrollButtons := self hasScrollButtons. |
|
825 |
hasScrollButtons == aBoolean ifTrue:[^ self]. |
|
826 |
||
827 |
hasScrollButtons ifTrue:[ |
|
828 |
buttonNext destroy. |
|
829 |
buttonPrev destroy. |
|
830 |
buttonNext := buttonPrev := nil. |
|
831 |
] ifFalse:[ |
|
832 |
buttonNext := ArrowButton in:self. |
|
833 |
buttonPrev := ArrowButton in:self. |
|
834 |
||
835 |
buttonNext beInvisible. |
|
836 |
buttonPrev beInvisible. |
|
837 |
||
838 |
"/ realized ifTrue:[ |
|
839 |
"/ buttonNext create. "/ realize. |
|
840 |
"/ buttonPrev create. "/ realize. |
|
841 |
"/ ]. |
|
842 |
buttonNext action:[ self scrollButtonPressed:#scrollRight ]. |
|
843 |
buttonPrev action:[ self scrollButtonPressed:#scrollLeft ]. |
|
844 |
]. |
|
845 |
self styleChanged. |
|
846 |
! |
|
847 |
||
848 |
isHorizontal |
|
849 |
"returns true in case of direction is #top or #bottom |
|
850 |
" |
|
851 |
^ direction == #top or:[direction == #bottom] |
|
852 |
! |
|
853 |
||
2875 | 854 |
showDestroyTabButton |
855 |
^ showDestroyTabButton |
|
856 |
! |
|
857 |
||
858 |
showDestroyTabButton:aBoolean |
|
859 |
showDestroyTabButton == aBoolean ifTrue:[^ self]. |
|
860 |
showDestroyTabButton := aBoolean. |
|
861 |
||
862 |
self styleChanged. |
|
863 |
! |
|
864 |
||
2282 | 865 |
tabBottomMargin |
866 |
"returns the margin between the tabs and the canvas |
|
867 |
" |
|
868 |
^ tabBottomMargin |
|
869 |
! |
|
870 |
||
871 |
tabBottomMargin:aMargin |
|
872 |
"set the margin between the tabs and the canvas |
|
873 |
" |
|
874 |
|margin| |
|
875 |
||
876 |
margin := aMargin max:0. |
|
877 |
||
878 |
margin ~~ tabBottomMargin ifTrue:[ |
|
879 |
tabBottomMargin := margin. |
|
880 |
self styleChanged. |
|
881 |
]. |
|
1401 | 882 |
! |
883 |
||
2431 | 884 |
tabLabelInset |
885 |
"inset (a point) of the label relative to its frame |
|
886 |
preferredExtent of Tab: label extent + tabLabelInset |
|
887 |
" |
|
888 |
^ tabLabelInset |
|
889 |
! |
|
890 |
||
891 |
tabLabelInset:aPoint |
|
892 |
"inset (a point) of the label relative to its frame |
|
893 |
preferredExtent of Tab: label extent + tabLabelInset |
|
894 |
" |
|
895 |
|p| |
|
896 |
||
897 |
aPoint isNumber ifTrue:[ p := Point x:aPoint y:aPoint ] |
|
898 |
ifFalse:[ p := aPoint ]. |
|
899 |
||
900 |
p ~= tabLabelInset ifTrue:[ |
|
901 |
tabLabelInset := p. |
|
902 |
self styleChanged. |
|
903 |
]. |
|
904 |
! |
|
905 |
||
2691 | 906 |
tabLeftMargin |
907 |
"margin to the first visible tab or scroller button |
|
908 |
" |
|
909 |
^ tabLeftMargin |
|
910 |
! |
|
911 |
||
912 |
tabLeftMargin:aMargin |
|
913 |
"margin to the first visible tab or scroller button |
|
914 |
" |
|
915 |
|margin| |
|
916 |
||
917 |
margin := aMargin max:0. |
|
918 |
||
919 |
margin ~~ tabLeftMargin ifTrue:[ |
|
920 |
tabLeftMargin := margin. |
|
921 |
self styleChanged. |
|
922 |
]. |
|
923 |
! |
|
924 |
||
2279 | 925 |
tabLevel |
926 |
"the level of the tabs and noteBook frame |
|
927 |
" |
|
928 |
^ tabLevel |
|
1401 | 929 |
! |
375 | 930 |
|
2279 | 931 |
tabLevel:aLevel |
932 |
"the level of the tabs and noteBook frame |
|
933 |
" |
|
934 |
aLevel ~~ tabLevel ifTrue:[ |
|
935 |
tabLevel := aLevel. |
|
2282 | 936 |
self styleChanged. |
937 |
]. |
|
938 |
! |
|
939 |
||
2691 | 940 |
tabRightMargin |
941 |
"margin from the last visible tab or scroller button to the view |
|
942 |
" |
|
943 |
^ tabRightMargin |
|
944 |
! |
|
945 |
||
946 |
tabRightMargin:aMargin |
|
947 |
"margin from the last visible tab or scroller button to the view |
|
948 |
" |
|
949 |
|margin| |
|
950 |
||
951 |
margin := aMargin max:0. |
|
952 |
||
953 |
margin ~~ tabRightMargin ifTrue:[ |
|
954 |
tabRightMargin := margin. |
|
955 |
self styleChanged. |
|
956 |
]. |
|
957 |
! |
|
958 |
||
2282 | 959 |
tabTopMargin |
2691 | 960 |
"returns the margin between the tabs and the widget (not canvas) |
2282 | 961 |
" |
962 |
^ tabTopMargin |
|
963 |
! |
|
964 |
||
965 |
tabTopMargin:aMargin |
|
2691 | 966 |
"set the margin between the tabs and the widget (not canvas) |
2282 | 967 |
" |
968 |
|margin| |
|
969 |
||
970 |
margin := aMargin max:0. |
|
971 |
||
972 |
margin ~~ tabTopMargin ifTrue:[ |
|
973 |
tabTopMargin := margin. |
|
974 |
self styleChanged. |
|
2279 | 975 |
]. |
375 | 976 |
! ! |
977 |
||
978 |
!NoteBookView methodsFor:'change & update'! |
|
979 |
||
2282 | 980 |
styleChanged |
981 |
"called if the tab style changed |
|
982 |
list must be recomputed |
|
983 |
" |
|
984 |
preferredExtent := nil. |
|
985 |
||
986 |
numberOfLines isNil ifTrue:[ |
|
987 |
^ self. "/ layout not yet computed |
|
988 |
]. |
|
989 |
self recomputeList. |
|
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2629
diff
changeset
|
990 |
self invalidate |
2282 | 991 |
! |
992 |
||
1401 | 993 |
update:something with:aParameter from:changedObject |
994 |
"one of my models changed its value |
|
995 |
" |
|
996 |
|idx tab| |
|
997 |
||
998 |
changedObject == model ifTrue:[^ self selection:model value]. |
|
1724
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
999 |
changedObject == listHolder ifTrue:[ |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
1000 |
something == #at: ifTrue:[ |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
1001 |
"/ a single items label has changed |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
1002 |
self tabAtIndex:aParameter put:(listHolder value at:aParameter). |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
1003 |
^ self. |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
1004 |
]. |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
1005 |
^ self list:(listHolder value) |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
1006 |
]. |
1401 | 1007 |
changedObject == enableChannel ifTrue:[^ self enabled:enableChannel value]. |
1413 | 1008 |
changedObject == canvasHolder ifTrue:[^ self canvas:canvasHolder value]. |
1401 | 1009 |
|
1010 |
(idx := list findFirst:[:aTab| aTab label == changedObject]) ~~ 0 ifTrue:[ |
|
1011 |
tab := list at:idx. |
|
1012 |
||
1013 |
idx == selection ifTrue:[ |
|
1014 |
tab isEnabled ifFalse:[ |
|
1015 |
^ self selection:nil |
|
1016 |
] |
|
1017 |
]. |
|
1018 |
tab label:(tab label) on:self. |
|
2529 | 1019 |
self invalidateTab:tab. |
1020 |
^ self. |
|
1021 |
]. |
|
1022 |
||
1023 |
^ super update:something with:aParameter from:changedObject |
|
1724
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
1024 |
|
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
1025 |
"Modified: / 25.2.2000 / 14:14:29 / cg" |
1401 | 1026 |
! ! |
1027 |
||
1028 |
!NoteBookView methodsFor:'drawing'! |
|
1029 |
||
2691 | 1030 |
computeDrawingClipX:x y:y width:w height:h |
1031 |
|trans xOrY wOrHInset| |
|
1032 |
||
1033 |
self hasScrollButtons ifFalse:[^ nil]. |
|
1034 |
||
1035 |
trans := self transformation. |
|
1036 |
xOrY := self tabLeftMargin. |
|
1037 |
wOrHInset := self tabRightMargin + xOrY. |
|
1038 |
||
1039 |
self isHorizontal ifTrue:[ |
|
1040 |
trans notNil ifTrue:[ |
|
1041 |
xOrY := trans applyInverseToX:xOrY. |
|
1042 |
]. |
|
1043 |
^ Rectangle left:xOrY top:y width:(self width - wOrHInset) height:h. |
|
1044 |
]. |
|
1045 |
trans notNil ifTrue:[ |
|
1046 |
xOrY := trans applyInverseToY:xOrY. |
|
1047 |
]. |
|
1048 |
^ Rectangle left:x top:xOrY width:w height:(self height - wOrHInset) |
|
1049 |
! |
|
1050 |
||
2763 | 1051 |
drawActiveTabMarker:aTab |
1052 |
"draw a tabs focus-rectangle" |
|
1053 |
||
1054 |
|layout w h yRct yPnt xRct xPnt incY incX markerHeight fgColor bgColor| |
|
1055 |
||
1056 |
layout := aTab layout. |
|
2881 | 1057 |
markerHeight := self activeTabMarkerHeight. |
2763 | 1058 |
|
1059 |
bgColor := self activeTabMarkerColor. |
|
1060 |
fgColor := self activeTabMarkerFgColor. |
|
1061 |
||
1062 |
self isHorizontal ifTrue:[ |
|
1063 |
xPnt := layout left + 1. |
|
1064 |
w := layout width - 2. |
|
1065 |
h := markerHeight. |
|
1066 |
||
1067 |
direction == #top ifTrue:[ |
|
1068 |
yPnt := yRct := layout top. |
|
1069 |
incY := 1. |
|
1070 |
] ifFalse:[ |
|
1071 |
incY := -1. |
|
1072 |
yRct := layout bottom - h. |
|
1073 |
yPnt := layout bottom - 1. |
|
1074 |
]. |
|
1075 |
bgColor notNil ifTrue:[ |
|
1076 |
self paint:bgColor. |
|
1077 |
self fillRectangleX:xPnt y:yRct width:w height:h. |
|
1078 |
]. |
|
1079 |
fgColor notNil ifTrue:[ |
|
1080 |
self paint:fgColor. |
|
1081 |
self displayLineFromX:xPnt y:yPnt toX:(xPnt + w - 1) y:yPnt. |
|
1082 |
||
1083 |
(markerHeight - 1) timesRepeat:[ |
|
1084 |
yPnt := yPnt + incY. |
|
1085 |
self displayPointX:(xPnt - 1) y:yPnt. |
|
1086 |
self displayPointX:(xPnt + w) y:yPnt. |
|
1087 |
]. |
|
1088 |
]. |
|
1089 |
] ifFalse:[ |
|
1090 |
w := markerHeight. |
|
1091 |
h := layout height - 2. |
|
1092 |
yRct := layout top + 1. |
|
1093 |
||
1094 |
direction == #left ifTrue:[ |
|
1095 |
incX := 1. |
|
1096 |
xRct := xPnt := layout left. |
|
1097 |
] ifFalse:[ |
|
1098 |
incX := -1. |
|
1099 |
xRct := layout right - w. |
|
1100 |
xPnt := layout right - 1. |
|
1101 |
]. |
|
1102 |
||
1103 |
bgColor notNil ifTrue:[ |
|
1104 |
self paint:bgColor. |
|
1105 |
self fillRectangleX:xRct y:yRct width:w height:h. |
|
1106 |
]. |
|
1107 |
||
1108 |
fgColor notNil ifTrue:[ |
|
1109 |
self paint:fgColor. |
|
1110 |
self displayLineFromX:xPnt y:yRct toX:xPnt y:yRct + h - 1. |
|
1111 |
||
1112 |
(markerHeight - 1) timesRepeat:[ |
|
1113 |
xPnt := xPnt + incX. |
|
1114 |
self displayPointX:xPnt y:(yRct - 1). |
|
1115 |
self displayPointX:xPnt y:(yRct + h). |
|
1116 |
]. |
|
1117 |
]. |
|
1118 |
]. |
|
1119 |
||
1120 |
||
1121 |
||
1122 |
||
1123 |
||
1124 |
||
1125 |
||
1126 |
||
1127 |
||
1128 |
||
1129 |
||
1130 |
||
1131 |
||
1132 |
||
1133 |
||
1134 |
||
1135 |
||
1136 |
||
1137 |
||
1138 |
||
1139 |
||
1140 |
||
1141 |
||
1142 |
||
1143 |
||
1144 |
||
1145 |
||
1146 |
||
1147 |
||
1148 |
||
1149 |
||
1150 |
||
1151 |
||
1152 |
||
1153 |
||
1154 |
||
1155 |
||
1156 |
||
1157 |
||
1158 |
||
1159 |
||
1160 |
"" |
|
1161 |
! |
|
1162 |
||
2283 | 1163 |
drawBorderEdges |
2686 | 1164 |
|layout x0 x1 y0 y1 trans| |
2283 | 1165 |
|
1166 |
"/ test whether TabView and not NoteBookView |
|
1167 |
tabModus ifTrue:[^ self]. |
|
1168 |
||
1169 |
layout := self computeBorderLayout. |
|
1170 |
||
1171 |
tabLevel ~~ 0 ifTrue:[ |
|
1172 |
self drawEdgesForX:(layout left) |
|
1173 |
y:(layout top) |
|
1174 |
width:(layout width) |
|
1175 |
height:(layout height) |
|
1176 |
level:tabLevel. |
|
1177 |
^ self |
|
1178 |
]. |
|
1179 |
list size > 1 ifFalse:[^ self]. |
|
1180 |
||
1181 |
self paint:lightColor ? lightColor. |
|
2686 | 1182 |
trans := self transformation. |
2283 | 1183 |
|
1184 |
(direction == #top or:[direction == #bottom]) ifTrue:[ |
|
1185 |
direction == #top ifTrue:[ y0 := layout top - 1 ] |
|
2284 | 1186 |
ifFalse:[ y0 := layout bottom ]. |
2283 | 1187 |
y1 := y0. |
1188 |
x0 := 0. |
|
2686 | 1189 |
trans notNil ifTrue:[ |
1190 |
x0 := trans applyInverseToX:x0. |
|
1191 |
]. |
|
2691 | 1192 |
x1 := x0 + self width. |
2283 | 1193 |
] ifFalse:[ |
1194 |
direction == #left ifTrue:[ x0 := layout left - 1 ] |
|
1195 |
ifFalse:[ x0 := layout right ]. |
|
2686 | 1196 |
x1 := x0. |
2283 | 1197 |
y0 := 0. |
2686 | 1198 |
trans notNil ifTrue:[ |
1199 |
y0 := trans applyInverseToY:y0. |
|
1200 |
]. |
|
2691 | 1201 |
y1 := y0 + self height. |
2283 | 1202 |
]. |
1203 |
self displayLineFromX:x0 y:y0 toX:x1 y:y1. |
|
1204 |
! |
|
1205 |
||
2875 | 1206 |
drawDestroyButtonForTab:aTab |
1207 |
"redraw a tabs destroy button" |
|
1208 |
||
1209 |
|bFrame| |
|
1210 |
||
1211 |
bFrame := self destroyButtonFrameForTab:aTab. |
|
1212 |
||
2883 | 1213 |
self paint:(self destroyTabForegroundColor). |
2875 | 1214 |
self displayRectangle:bFrame. |
1215 |
self displayLineFrom:bFrame topLeft to:bFrame bottomRight-(1@1). |
|
1216 |
self displayLineFrom:bFrame topRight - (1@0) to:bFrame bottomLeft-(0@1). |
|
1217 |
! |
|
1218 |
||
2278 | 1219 |
drawTabEdgesFor:aTab |
2763 | 1220 |
|layout count leftFg leftHalfFg rightFg x0 x1 y0 y1 isSelected |
2278 | 1221 |
yT "{ Class:SmallInteger }" |
1222 |
xL "{ Class:SmallInteger }" |
|
1223 |
xR "{ Class:SmallInteger }" |
|
1224 |
yB "{ Class:SmallInteger }" |
|
1225 |
| |
|
2758 | 1226 |
|
2280 | 1227 |
count := tabLevel. |
1228 |
isSelected := (self selectedTab == aTab). |
|
2278 | 1229 |
|
2283 | 1230 |
count <= 0 ifTrue:[ |
2280 | 1231 |
isSelected ifFalse:[ ^ self ]. |
1232 |
||
2283 | 1233 |
count == 0 ifTrue:[ |
1234 |
list size > 1 ifFalse:[^ self]. |
|
1235 |
count := 1 |
|
1236 |
] ifFalse:[ |
|
1237 |
count := count negated |
|
1238 |
]. |
|
1239 |
||
2278 | 1240 |
rightFg := lightColor. |
1241 |
leftFg := shadowColor. |
|
1242 |
leftHalfFg := halfShadowColor. |
|
1243 |
] ifFalse:[ |
|
2280 | 1244 |
|
2278 | 1245 |
((edgeStyle == #soft) and:[tabLevel > 1]) ifTrue:[ rightFg := halfShadowColor ] |
2280 | 1246 |
ifFalse:[ rightFg := shadowColor ]. |
2278 | 1247 |
leftFg := lightColor. |
1248 |
leftHalfFg := halfLightColor. |
|
1249 |
]. |
|
1250 |
||
1251 |
(leftHalfFg notNil and:[edgeStyle == #soft and:[tabLevel > 0]]) ifTrue:[ |
|
1252 |
leftFg := leftHalfFg |
|
1253 |
]. |
|
1254 |
||
1255 |
layout := aTab layout. |
|
1256 |
xL := layout left. |
|
1257 |
yT := layout top. |
|
1258 |
xR := layout right - 1. |
|
1259 |
yB := layout bottom - 1. |
|
1260 |
||
1261 |
x0 := xL + count. |
|
1262 |
x1 := xR - count. |
|
1263 |
y0 := yT + count. |
|
1264 |
y1 := yB - count. |
|
1265 |
||
1266 |
direction == #top ifTrue:[ |
|
1267 |
self paint:rightFg. |
|
1268 |
||
1269 |
0 to:count - 1 do:[:i| "/ vertical: right |
|
1270 |
self displayLineFromX:xR - i y:yB toX:xR - i y:y0 - i. |
|
1271 |
]. |
|
1272 |
||
1273 |
self paint:leftFg. |
|
1274 |
||
1275 |
0 to:count - 1 do:[:i| "/ horizontal: left |
|
1276 |
self displayLineFromX:xL + i y:y0 - i toX:xL + i y:yB. |
|
1277 |
]. |
|
1278 |
||
1279 |
0 to:count - 1 do:[:i| "/ horizontal: top |
|
1280 |
self displayLineFromX:x0 - i y:yT + i toX:x1 y:yT + i. |
|
1281 |
]. |
|
2280 | 1282 |
(isSelected and:[count > 1]) ifFalse:[^ self]. |
1283 |
(self isLastTabInLine:aTab) ifTrue:[^ self]. |
|
2278 | 1284 |
|
1285 |
y0 := yB + 1. |
|
1286 |
x1 := x1 + 1. |
|
1287 |
||
1288 |
1 to:count - 1 do:[:i| "/ horizontal line |
|
1289 |
self displayLineFromX:x1 + i y:y0 - i toX:xR y:y0 - i. |
|
1290 |
]. |
|
2758 | 1291 |
|
2278 | 1292 |
^ self |
1293 |
]. |
|
1294 |
||
1295 |
direction == #bottom ifTrue:[ |
|
1296 |
self paint:leftFg. |
|
1297 |
||
1298 |
0 to:count - 1 do:[:i| "/ vertical : left |
|
1299 |
self displayLineFromX:xL + i y:yT toX:xL + i y:y1+i. |
|
1300 |
]. |
|
1301 |
||
1302 |
self paint:rightFg. |
|
1303 |
||
1304 |
0 to:count - 1 do:[:i| "/ horizontal: bottom |
|
1305 |
self displayLineFromX:x0 y:yB-i toX:x1 + i y:yB-i. |
|
1306 |
]. |
|
1307 |
||
1308 |
0 to:count - 1 do:[:i| "/ vertical: right |
|
1309 |
self displayLineFromX:xR-i y:yT toX:xR-i y:y1+i. |
|
1310 |
]. |
|
1311 |
||
2280 | 1312 |
(isSelected and:[count > 1]) ifFalse:[^ self]. |
1313 |
(self isFirstTabInLine:aTab) ifTrue:[^ self]. |
|
2278 | 1314 |
|
1315 |
x0 := x0 - 1. |
|
1316 |
y0 := yT - 1. |
|
1317 |
||
1318 |
1 to:count - 1 do:[:i| "/ selection shadow |
|
1319 |
self displayLineFromX:xL y:y0 + i toX:x0-i y:y0 + i. |
|
1320 |
]. |
|
1321 |
^ self |
|
1322 |
]. |
|
1323 |
||
1324 |
direction == #right ifTrue:[ |
|
1325 |
self paint:leftFg. |
|
1326 |
||
1327 |
0 to:count - 1 do:[:i| "/ horizontal: top |
|
1328 |
self displayLineFromX:xL y:yT + i toX:x1+i y:yT + i. |
|
1329 |
]. |
|
1330 |
||
1331 |
self paint:rightFg. |
|
1332 |
||
1333 |
0 to:count - 1 do:[:i| "/ vertical: right |
|
1334 |
self displayLineFromX:xR-i y:y0 toX:xR-i y:y1. |
|
1335 |
]. |
|
1336 |
||
1337 |
1 to:count do:[:i| "/ horizontal: bottom |
|
1338 |
self displayLineFromX:xL y:y1+i toX:xR-i y:y1+i. |
|
1339 |
]. |
|
1340 |
||
2280 | 1341 |
(isSelected and:[count > 1]) ifFalse:[^ self]. |
2278 | 1342 |
(self isFirstTabInLine:aTab) ifTrue:[^ self]. |
1343 |
||
1344 |
x0 := x0 - 1. |
|
1345 |
y0 := yT - 1. |
|
1346 |
||
1347 |
1 to:count - 1 do:[:i| "/ selection shadow |
|
1348 |
self displayLineFromX:xL y:y0 + i toX:x0-i y:y0 + i. |
|
1349 |
]. |
|
1350 |
^ self |
|
1351 |
]. |
|
1352 |
||
1353 |
"/ direction == #left |
|
1354 |
self paint:rightFg. |
|
1355 |
||
1356 |
x0 := xL + count. |
|
1357 |
x1 := xR - count. |
|
1358 |
y0 := yT + count. |
|
1359 |
y1 := yB - count. |
|
1360 |
||
1361 |
0 to:count - 1 do:[:i| "/ horizontal: bottom |
|
1362 |
self displayLineFromX:x0 - i y:yB - i toX:xR y:yB - i. |
|
1363 |
]. |
|
1364 |
||
1365 |
self paint:leftFg. |
|
1366 |
||
1367 |
0 to:count - 1 do:[:i| "/ vertical: left |
|
1368 |
self displayLineFromX:xL + i y:y0 toX:xL + i y:y1. |
|
1369 |
]. |
|
1370 |
||
1371 |
1 to:count do:[:i| "/ horizontal: top |
|
1372 |
self displayLineFromX:xL + i y:y0 - i toX:xR y:y0 - i. |
|
1373 |
]. |
|
1374 |
||
2280 | 1375 |
(isSelected and:[count > 1]) ifFalse:[^ self]. |
1376 |
(self isLastTabInLine:aTab) ifTrue:[^ self]. |
|
2278 | 1377 |
|
1378 |
x1 := x1 + 1. |
|
1379 |
y0 := yB + 1. |
|
1380 |
||
1381 |
1 to:count - 1 do:[:i| "/ selection shadow |
|
1382 |
self displayLineFromX:x1+i y:yB + 1 - i toX:xR y:yB + 1 - i. |
|
1383 |
]. |
|
1384 |
! |
|
1385 |
||
2762 | 1386 |
drawTabFocus:aTab |
1387 |
"draw a tabs focus-rectangle" |
|
1388 |
||
1389 |
|layout extent voffs hoffs| |
|
1390 |
||
2763 | 1391 |
self supportsFocusOnTab ifFalse:[ |
1392 |
^ self. |
|
1393 |
]. |
|
1394 |
||
1395 |
self activeTabMarkerColor notNil ifTrue:[ |
|
1396 |
self drawActiveTabMarker:aTab. |
|
1397 |
^ self. |
|
1398 |
]. |
|
1399 |
||
1400 |
self hasFocus ifFalse:[ |
|
1401 |
^ self. |
|
1402 |
]. |
|
2762 | 1403 |
layout := aTab layout. |
1404 |
extent := aTab extent. |
|
1405 |
||
1406 |
self isHorizontal ifTrue:[ |
|
1407 |
voffs := (layout height - extent y) // 2 max:0. |
|
1408 |
hoffs := (layout width - extent x) // 2 max:0. |
|
1409 |
] ifFalse:[ |
|
1410 |
voffs := (layout height - extent x) // 2 max:0. |
|
1411 |
hoffs := (layout width - extent y) // 2 max:0. |
|
1412 |
]. |
|
1413 |
||
1414 |
self paint:(Color black). |
|
1415 |
||
2763 | 1416 |
self displayDottedRectangleX:(layout left + hoffs - 1) |
1417 |
y:(layout top + voffs - 1) |
|
2762 | 1418 |
width:(layout width - hoffs - hoffs + 2) |
1419 |
height:(layout height - voffs - voffs + 2). |
|
1420 |
! |
|
1421 |
||
1422 |
invalidateSelectedTab |
|
1423 |
|selectedTab| |
|
1424 |
||
1425 |
selectedTab := self selectedTab. |
|
1426 |
selectedTab notNil ifTrue:[ |
|
1427 |
self invalidateTab:selectedTab |
|
1428 |
]. |
|
1429 |
! |
|
1430 |
||
1401 | 1431 |
invalidateTab:aTab |
2762 | 1432 |
"invalidate a tab (i.e. force it to be redrawn)" |
1433 |
||
2213 | 1434 |
|tabBounds| |
1435 |
||
1401 | 1436 |
shown ifTrue:[ |
2213 | 1437 |
tabBounds := self computeLayoutForTab:aTab. |
1438 |
self invalidate:tabBounds. |
|
1401 | 1439 |
] |
1440 |
! |
|
1441 |
||
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1442 |
redrawTab:aTab |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1443 |
"redraw a tab" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1444 |
|
2875 | 1445 |
|isSelected fgColor| |
2288 | 1446 |
|
1447 |
isSelected := self selectedTab == aTab. |
|
1448 |
||
2875 | 1449 |
self paint:(isSelected ifTrue:[self activeBackgroundColor] ifFalse:[self backgroundColor]). |
1450 |
self fillRectangle:(aTab layout). |
|
2288 | 1451 |
|
1452 |
(enabled and:[aTab isEnabled]) ifFalse:[ |
|
1453 |
fgColor := disabledForegroundColor. |
|
1454 |
] ifTrue:[ |
|
1455 |
fgColor := aTab foregroundColor. |
|
1456 |
fgColor isNil ifTrue:[ |
|
2875 | 1457 |
fgColor := isSelected ifTrue:[activeForegroundColor] ifFalse:[foregroundColor]. |
2288 | 1458 |
] |
1459 |
]. |
|
1460 |
self paint:fgColor. |
|
1461 |
aTab displayOn:self inset:(tabLevel abs) direction:direction. |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1462 |
(showDestroyTabButton and:[destroyTabAction notNil]) ifTrue:[ |
2875 | 1463 |
self drawDestroyButtonForTab:aTab. |
1464 |
]. |
|
2288 | 1465 |
self drawTabEdgesFor:aTab. |
1466 |
||
2763 | 1467 |
isSelected ifTrue:[ |
2762 | 1468 |
self drawTabFocus:aTab |
2288 | 1469 |
]. |
1470 |
! |
|
1471 |
||
1401 | 1472 |
redrawX:x y:y width:w height:h |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1473 |
"a region must be redrawn" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1474 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1475 |
|selectedTab line damage tabLayout clip| |
1401 | 1476 |
|
2035
6cc4d73f17e1
bug fix when chaning the canvas before being realized
Claus Gittinger <cg@exept.de>
parents:
2010
diff
changeset
|
1477 |
shown ifFalse:[ ^ self ]. |
6cc4d73f17e1
bug fix when chaning the canvas before being realized
Claus Gittinger <cg@exept.de>
parents:
2010
diff
changeset
|
1478 |
|
2283 | 1479 |
numberOfLines isNil ifTrue:[ |
1401 | 1480 |
self recomputeList. |
2215 | 1481 |
|
2283 | 1482 |
numberOfLines notNil ifTrue:[ |
2215 | 1483 |
self invalidate |
1484 |
]. |
|
1485 |
^ self |
|
1401 | 1486 |
]. |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1487 |
|
2213 | 1488 |
selectedTab := self selectedTab. |
2283 | 1489 |
selectedTab notNil ifTrue:[ |
2288 | 1490 |
(line := selectedTab lineNr) ~~ 1 ifTrue:[ |
1491 |
self makeToBaseLine:line. |
|
2760 | 1492 |
^ self |
2283 | 1493 |
] |
1401 | 1494 |
]. |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1495 |
"/ self paint:(self viewBackground). |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1496 |
"/ self fillRectangleX:x y:y width:w height:h. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1497 |
self clearRectangleX:x y:y width:w height:h. |
1401 | 1498 |
|
2283 | 1499 |
list size == 0 ifTrue:[ ^ self ]. |
1500 |
||
2691 | 1501 |
self drawBorderEdges. |
1502 |
||
2278 | 1503 |
damage := Rectangle left:x top:y width:w height:h. |
2691 | 1504 |
clip := self computeDrawingClipX:x y:y width:w height:h. |
2278 | 1505 |
|
1506 |
numberOfLines to:1 by:-1 do:[:aLnNr| |
|
1507 |
list reverseDo:[:aTab| |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1508 |
(aTab lineNr == aLnNr |
2278 | 1509 |
and:[aTab ~~ selectedTab |
1510 |
and:[aTab intersects:damage]] |
|
1511 |
) ifTrue:[ |
|
2691 | 1512 |
clip notNil ifTrue:[ |
1513 |
self clippingRectangle:clip. |
|
1514 |
clip := nil. |
|
1515 |
]. |
|
2288 | 1516 |
self redrawTab:aTab. |
1401 | 1517 |
] |
1518 |
] |
|
1519 |
]. |
|
2691 | 1520 |
selectedTab isNil ifTrue:[ |
1521 |
^ self |
|
1522 |
]. |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1523 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1524 |
tabLayout := self computeLayoutForTab:selectedTab. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1525 |
(tabLayout intersects:damage) ifTrue:[ |
2691 | 1526 |
clip notNil ifTrue:[ |
1527 |
self clippingRectangle:clip. |
|
1528 |
clip := nil. |
|
1529 |
]. |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1530 |
"/ selectedLayout := selectedTab layout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1531 |
"/ selectedTab layout:layout. |
2288 | 1532 |
self redrawTab:selectedTab. |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1533 |
"/ selectedTab layout:selectedLayout. |
1401 | 1534 |
]. |
1535 |
! ! |
|
1536 |
||
1537 |
!NoteBookView methodsFor:'event handling'! |
|
1538 |
||
1539 |
buttonPress:button x:x y:y |
|
2875 | 1540 |
"a button is pressed; find tab under point and set the selection" |
1541 |
||
1802 | 1542 |
|idx tab recv menu| |
1401 | 1543 |
|
2279 | 1544 |
enabled ifFalse:[ ^ self ]. |
1545 |
list isEmpty ifTrue:[ ^ self ]. |
|
1546 |
||
1547 |
idx := list findFirst:[:aTab| aTab containsPointX:x y:y ]. |
|
1548 |
idx == 0 ifTrue:[ ^ self ]. |
|
1549 |
||
1550 |
tab := list at:idx. |
|
2875 | 1551 |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1552 |
"/ uncomment, for destroy-on-press |
2877 | 1553 |
"/ (showDestroyTabButton and:[destroyTabAction notNil]) ifTrue:[ |
1554 |
"/ ((self destroyButtonFrameForTab:tab) containsPointX:x y:y) ifTrue:[ |
|
1555 |
"/ destroyTabAction value:idx. |
|
1556 |
"/ ^ self. |
|
1557 |
"/ ]. |
|
1558 |
"/ ]. |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1559 |
|
2279 | 1560 |
tab isEnabled ifFalse:[ ^ self ]. |
375 | 1561 |
|
2875 | 1562 |
((button ~~ 2) and:[button ~~ #menu]) ifTrue:[ |
1802 | 1563 |
"/ change the selection |
2875 | 1564 |
tab ~~ self selectedTab ifTrue:[ |
1565 |
self selection:idx |
|
1566 |
]. |
|
1567 |
^ self. |
|
1802 | 1568 |
]. |
2875 | 1569 |
|
2279 | 1570 |
accessTabMenuAction isNil ifTrue:[ ^ self ]. |
1571 |
menu := accessTabMenuAction value:idx. |
|
1572 |
menu isNil ifTrue:[ ^ self ]. |
|
1573 |
||
1802 | 1574 |
menu isArray ifTrue:[ |
1575 |
menu := menu decodeAsLiteralArray |
|
1576 |
]. |
|
1577 |
||
1578 |
menu receiver isNil ifTrue:[ |
|
1579 |
(recv := self application) isNil ifTrue:[ |
|
1580 |
recv := tab model |
|
1581 |
]. |
|
1582 |
recv notNil ifTrue:[ |
|
1583 |
menu receiver:recv |
|
1584 |
] ifFalse:[ |
|
2875 | 1585 |
Transcript showCR:('%1 : Menu has no receiver' bindWith:(self class name)). |
1401 | 1586 |
] |
1802 | 1587 |
]. |
2333 | 1588 |
self startUpMenu:menu |
1401 | 1589 |
! |
1590 |
||
2877 | 1591 |
buttonRelease:button x:x y:y |
1592 |
"a button is released; see if its the destroyTab button" |
|
1593 |
||
1594 |
|idx tab| |
|
1595 |
||
1596 |
enabled ifFalse:[ ^ self ]. |
|
1597 |
list isEmpty ifTrue:[ ^ self ]. |
|
1598 |
||
1599 |
idx := list findFirst:[:aTab| aTab containsPointX:x y:y ]. |
|
1600 |
idx == 0 ifTrue:[ ^ self ]. |
|
1601 |
||
1602 |
tab := list at:idx. |
|
1603 |
||
1604 |
(showDestroyTabButton and:[destroyTabAction notNil]) ifTrue:[ |
|
1605 |
((self destroyButtonFrameForTab:tab) containsPointX:x y:y) ifTrue:[ |
|
1606 |
destroyTabAction value:idx. |
|
1607 |
^ self. |
|
1608 |
]. |
|
1609 |
]. |
|
1610 |
super buttonRelease:button x:x y:y |
|
1611 |
! |
|
1612 |
||
1401 | 1613 |
keyPress:aKey x:x y:y |
1614 |
"selection might change; look for corresponding list entry |
|
1615 |
" |
|
1659 | 1616 |
<resource: #keyboard (#CursorRight #CursorLeft #CursorUp #CursorDown)> |
1407 | 1617 |
|
2758 | 1618 |
|sensor size index n selectNext selectPrev| |
1401 | 1619 |
|
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1620 |
(enabled and:[(size := list size) ~~ 0]) ifFalse:[ |
1657
061c167ce3db
if disabled; call super keyPress:x:y to handle focusSequence
ca
parents:
1549
diff
changeset
|
1621 |
^ super keyPress:aKey x:x y:y |
1401 | 1622 |
]. |
1623 |
||
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1624 |
(self processAccessCharacter:aKey) ifTrue:[ |
1407 | 1625 |
^ self |
1626 |
]. |
|
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1627 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1628 |
(self processShortcutKey:aKey) ifTrue:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1629 |
^ self |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1630 |
]. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1631 |
|
2758 | 1632 |
selectNext := selectPrev := false. |
1633 |
||
1634 |
((aKey == #CursorRight) or:[aKey == #CursorDown]) ifTrue:[ |
|
1635 |
selectNext := true. |
|
1636 |
] ifFalse:[ ((aKey == #CursorLeft) or:[aKey == #CursorUp]) ifTrue:[ |
|
1637 |
selectPrev := true. |
|
1638 |
] ifFalse:[ aKey == #Tab ifTrue:[ |
|
1639 |
selectNext := true. |
|
1640 |
] ifFalse:[ |
|
1659 | 1641 |
^ super keyPress:aKey x:x y:y |
2758 | 1642 |
]]]. |
1643 |
||
2396
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
1644 |
sensor := self sensor. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
1645 |
sensor notNil ifTrue:[ |
1407 | 1646 |
n := 1 + (sensor compressKeyPressEventsWithKey:aKey). |
1647 |
n := (n \\ size) max:1. |
|
2396
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
1648 |
] ifFalse:[ |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
1649 |
n := 1. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
1650 |
]. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
1651 |
index := selection ? 0. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
1652 |
|
2758 | 1653 |
selectNext ifTrue:[ |
2396
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
1654 |
n timesRepeat:[ |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
1655 |
index := self nextSelectableAfter:index wrapAtEnd:true. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
1656 |
index == 0 ifTrue:[^ self]. |
1407 | 1657 |
]. |
2396
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
1658 |
] ifFalse:[ |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
1659 |
n timesRepeat:[ |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
1660 |
index := self previousSelectableBefore:index wrapAtBegin:true. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
1661 |
index == 0 ifTrue:[^ self]. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
1662 |
]. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
1663 |
]. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
1664 |
self selection:index. |
1401 | 1665 |
! |
1666 |
||
1677 | 1667 |
processShortcutKeyEvent:event |
1668 |
^ self processShortcutKey:(event key) |
|
1669 |
! |
|
1670 |
||
1401 | 1671 |
sizeChanged:how |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1672 |
"size of my view changed" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1673 |
|
1401 | 1674 |
super sizeChanged:how. |
1675 |
||
1676 |
list notEmpty ifTrue:[ |
|
1403 | 1677 |
lastComputedExtent ~= self extent ifTrue:[ |
1678 |
numberOfLines := nil. |
|
1679 |
] |
|
1680 | 1680 |
]. |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1681 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1682 |
"/ self invalidate. |
1680 | 1683 |
self resizeCanvas. |
1401 | 1684 |
! ! |
1685 |
||
1659 | 1686 |
!NoteBookView methodsFor:'focus handling'! |
1687 |
||
1688 |
showFocus:explicit |
|
2762 | 1689 |
"got the keyboard focus" |
1659 | 1690 |
|
2279 | 1691 |
self supportsFocusOnTab ifTrue:[ |
2762 | 1692 |
self invalidateSelectedTab |
1659 | 1693 |
] ifFalse:[ |
1694 |
super showFocus:explicit |
|
1695 |
] |
|
1696 |
! |
|
1697 |
||
1698 |
showNoFocus:explicit |
|
2762 | 1699 |
"lost the keyboard focus" |
1659 | 1700 |
|
2279 | 1701 |
self supportsFocusOnTab ifTrue:[ |
2762 | 1702 |
self invalidateSelectedTab |
1659 | 1703 |
] ifFalse:[ |
1704 |
super showNoFocus:explicit |
|
1705 |
] |
|
2279 | 1706 |
! |
1707 |
||
1708 |
supportsFocusOnTab |
|
1709 |
"returns true if focus is supported |
|
1710 |
" |
|
1711 |
^ (styleSheet at:#'focusHighlightStyle') == #win95 |
|
1659 | 1712 |
! ! |
1713 |
||
1759 | 1714 |
!NoteBookView methodsFor:'help'! |
1715 |
||
2877 | 1716 |
flyByHelpTextAt:srcPoint |
1717 |
^ self helpTextAt:srcPoint |
|
1718 |
! |
|
1719 |
||
1759 | 1720 |
helpText |
2877 | 1721 |
"return the helpText for the currently selected item (empty if none)" |
1722 |
||
1759 | 1723 |
^ self helpTextForItemAt:selection |
1724 |
! |
|
1725 |
||
1726 |
helpTextAt:srcPoint |
|
2877 | 1727 |
"return the helpText for aPoint (i.e. when mouse-pointer is moved over an item)." |
1728 |
||
1729 |
|x y idx tab| |
|
1759 | 1730 |
|
1731 |
x := srcPoint x. |
|
1732 |
y := srcPoint y. |
|
2877 | 1733 |
idx := list findFirst:[:aTab| aTab containsPointX:x y:y ]. |
1734 |
||
1735 |
idx ~~ 0 ifTrue:[ |
|
1736 |
(showDestroyTabButton and:[destroyTabAction notNil]) ifTrue:[ |
|
1737 |
tab := list at:idx. |
|
1738 |
((self destroyButtonFrameForTab:tab) containsPointX:x y:y) ifTrue:[ |
|
1739 |
^ resources string:'Remove this Tab' |
|
1740 |
]. |
|
1741 |
]. |
|
1742 |
]. |
|
1743 |
^ self helpTextForItemAt:idx |
|
1759 | 1744 |
! |
1745 |
||
1746 |
helpTextForItemAt:anIndex |
|
1747 |
|tab| |
|
1748 |
||
1749 |
( anIndex notNil |
|
1750 |
and:[anIndex ~~ 0 |
|
1751 |
and:[(tab := list at:anIndex ifAbsent:nil) notNil |
|
1752 |
and:[(tab := tab model) notNil]]] |
|
1753 |
) ifTrue:[ |
|
2877 | 1754 |
^ tab activeHelpText "/ ? '' |
1759 | 1755 |
]. |
2877 | 1756 |
^ nil "/ '' |
1759 | 1757 |
! ! |
1758 |
||
1687 | 1759 |
!NoteBookView methodsFor:'initialization & release'! |
1401 | 1760 |
|
1761 |
destroy |
|
1762 |
"remove dependencies |
|
1763 |
" |
|
1764 |
list removeDependent:self. |
|
1765 |
||
1766 |
listHolder removeDependent:self. |
|
1767 |
canvasHolder removeDependent:self. |
|
1768 |
||
2723 | 1769 |
list notEmptyOrNil ifTrue:[ |
1770 |
list do:[:anItem| |model| |
|
1771 |
model := anItem model. |
|
1772 |
model notNil ifTrue:[ |
|
1773 |
model destroyCanvas. |
|
1774 |
] |
|
1775 |
] |
|
1776 |
]. |
|
1401 | 1777 |
super destroy. |
1778 |
! |
|
1779 |
||
1780 |
initStyle |
|
1781 |
"setup style attributes |
|
1782 |
" |
|
1442 | 1783 |
|clr| |
1784 |
||
1401 | 1785 |
super initStyle. |
1682 | 1786 |
tabModus := false. |
1787 |
edgeStyle := DefaultEdgeStyle. |
|
1442 | 1788 |
|
2760 | 1789 |
clr := styleSheet colorAt:#'noteBook.viewBackground'. |
1790 |
clr notNil ifTrue:[ viewBackground := clr ]. |
|
1791 |
||
1401 | 1792 |
self font:self class defaultFont. |
1682 | 1793 |
drawLightColor := Color veryLightGray onDevice:device. |
1442 | 1794 |
|
1682 | 1795 |
clr := DefaultForegroundColor ? Black. |
1796 |
foregroundColor := clr onDevice:device. |
|
1797 |
||
2760 | 1798 |
clr := DefaultBackgroundColor ? viewBackground. |
1799 |
backgroundColor := clr onDevice:device. |
|
1800 |
||
1801 |
clr := DefaultActiveBackgroundColor ? backgroundColor. |
|
1802 |
activeBackgroundColor := clr onDevice:device. |
|
1803 |
||
1804 |
clr := DefaultActiveForegroundColor ? foregroundColor. |
|
1682 | 1805 |
activeForegroundColor := clr onDevice:device. |
1806 |
||
2292 | 1807 |
"/ (clr := DefaultShadowColor) isNil ifTrue:[clr := viewBackground darkened]. |
1808 |
"/ shadowColor := clr onDevice:device. |
|
1809 |
"/ (clr := DefaultLightColor) isNil ifTrue:[clr := viewBackground lightened]. |
|
1810 |
"/ lightColor := clr onDevice:device. |
|
1811 |
||
1812 |
(clr := DefaultShadowColor) notNil ifTrue:[shadowColor := clr onDevice:device]. |
|
1813 |
(clr := DefaultLightColor) notNil ifTrue:[lightColor := clr onDevice:device]. |
|
1689
ecb51abe4a6b
preps to allow for tabColor and activeTabColor to be
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
1814 |
|
1682 | 1815 |
edgeStyle isNil ifTrue:[ |
1816 |
halfShadowColor := shadowColor. |
|
1817 |
halfLightColor := lightColor. |
|
1818 |
drawLightColor := lightColor. |
|
1819 |
] ifFalse:[ |
|
2292 | 1820 |
"/ (clr := DefaultHalfShadowColor) isNil ifTrue:[ |
1821 |
"/ clr := shadowColor lightened |
|
1822 |
"/ ]. |
|
1823 |
"/ halfShadowColor := clr onDevice:device. |
|
1824 |
"/ |
|
1825 |
"/ (clr := DefaultHalfLightColor) isNil ifTrue:[ |
|
1826 |
"/ clr := lightColor darkened. |
|
1827 |
"/ ]. |
|
1828 |
"/ halfLightColor := clr onDevice:device. |
|
1829 |
||
1830 |
(clr := DefaultHalfShadowColor) notNil ifTrue:[ |
|
1831 |
halfShadowColor := clr onDevice:device. |
|
1442 | 1832 |
]. |
2292 | 1833 |
|
1834 |
(clr := DefaultHalfLightColor) notNil ifTrue:[ |
|
1835 |
halfLightColor := clr onDevice:device. |
|
1682 | 1836 |
]. |
1837 |
||
1838 |
edgeStyle == #soft ifTrue:[ |
|
1839 |
drawLightColor := halfShadowColor |
|
1840 |
] ifFalse:[ |
|
1841 |
drawLightColor := Color veryLightGray onDevice:device. |
|
1842 |
] |
|
1442 | 1843 |
]. |
1700 | 1844 |
(clr := DisabledForegroundColor) notNil ifTrue:[ |
1845 |
disabledForegroundColor := clr onDevice:device |
|
1846 |
]ifFalse:[ |
|
1847 |
disabledForegroundColor := drawLightColor |
|
1848 |
]. |
|
2882 | 1849 |
|
1850 |
activeTabMarkerColor := DefaultActiveTabMarkerColor. |
|
1851 |
activeTabMarkerFGColor := DefaultActiveTabMarkerFgColor. |
|
1401 | 1852 |
! |
1853 |
||
1854 |
initialize |
|
2746
2c614cc1559c
Do not hardcode noteBook.tabTobMargin for windows
Stefan Vogel <sv@exept.de>
parents:
2740
diff
changeset
|
1855 |
|
1401 | 1856 |
super initialize. |
1857 |
||
2877 | 1858 |
self enableMotionEvents. "/ for flyByHelp |
1401 | 1859 |
self cursor:Cursor hand. |
1860 |
||
1680 | 1861 |
list := #(). |
1862 |
useIndex := true. |
|
1863 |
direction := #top. |
|
1864 |
fitLastRow := true. |
|
1865 |
enabled := true. |
|
2875 | 1866 |
showDestroyTabButton := false. |
2882 | 1867 |
canvasInset := styleSheet at:#'noteBook.canvasInset' default:1@1. |
1680 | 1868 |
keepCanvas := false. |
2882 | 1869 |
tabLevel := styleSheet at:#'noteBook.tabLevel' default:1. |
1870 |
tabLabelInset := styleSheet at:#'noteBook.tabLabelInset' default:6@4. |
|
2280 | 1871 |
selectionInsetX := (2 max:(tabLevel abs)) + 1. |
1872 |
selectionInsetY := (2 max:(tabLevel abs)) + 1. |
|
2629 | 1873 |
translateLabel := false. |
2285 | 1874 |
|
2691 | 1875 |
tabRightMargin := 0. |
1876 |
tabLeftMargin := 0. |
|
1877 |
||
2882 | 1878 |
tabTopMargin := styleSheet at:#'noteBook.tabTopMargin' default:4. |
1879 |
tabBottomMargin := styleSheet at:#'noteBook.tabBottomMargin' default:1. |
|
2280 | 1880 |
|
1401 | 1881 |
self lineWidth:0. |
1882 |
||
2529 | 1883 |
"/ canvas notNil ifTrue:[ |
1884 |
"/ canvas := canvas in:self. |
|
1885 |
"/ ]. |
|
1403 | 1886 |
! |
1887 |
||
2682 | 1888 |
mapped |
1889 |
||
1890 |
super mapped. |
|
2691 | 1891 |
|
2682 | 1892 |
canvas notNil ifTrue:[ |
1893 |
canvas raise |
|
1894 |
]. |
|
1895 |
! |
|
1896 |
||
2739 | 1897 |
postRealize |
1898 |
"automatically set the initially selected notebook tab; |
|
1899 |
unless it has been set already (by setup code)" |
|
1900 |
||
1901 |
selection isNil ifTrue:[ |
|
1902 |
self setSelection:1. |
|
1903 |
]. |
|
1904 |
super postRealize. |
|
1905 |
! |
|
1906 |
||
1403 | 1907 |
realize |
1908 |
||
1909 |
(canvas notNil and:[numberOfLines isNil]) ifTrue:[ |
|
1910 |
self recomputeList |
|
1911 |
]. |
|
1912 |
super realize. |
|
1401 | 1913 |
! ! |
1914 |
||
1915 |
!NoteBookView methodsFor:'layout'! |
|
1916 |
||
1917 |
computeBorderLayout |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1918 |
"returns the layout of the frame araound the canvas" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1919 |
|
2035
6cc4d73f17e1
bug fix when chaning the canvas before being realized
Claus Gittinger <cg@exept.de>
parents:
2010
diff
changeset
|
1920 |
|xL yT xR yB tab l| |
1401 | 1921 |
|
1922 |
xL := 0. |
|
1923 |
yT := 0. |
|
2691 | 1924 |
xR := self width. |
1925 |
yB := self height. |
|
1401 | 1926 |
|
2278 | 1927 |
list notEmpty ifTrue:[ |
1928 |
tab := list detect:[:aTab| aTab lineNr == 1] ifNone:nil. |
|
1929 |
||
1930 |
tab notNil ifTrue:[ |
|
1931 |
l := tab layout. |
|
1932 |
||
2279 | 1933 |
direction == #top ifTrue:[ yT := l bottom ] |
1934 |
ifFalse:[ direction == #bottom ifTrue:[ yB := l top ] |
|
1935 |
ifFalse:[ direction == #left ifTrue:[ xL := l right ] |
|
1936 |
ifFalse:[ |
|
2278 | 1937 |
xR := l left |
1938 |
]]] |
|
1939 |
] |
|
1401 | 1940 |
]. |
2686 | 1941 |
self buttonLayoutUpdate. |
1942 |
||
1401 | 1943 |
^ Rectangle left:xL top:yT right:xR bottom:yB |
1944 |
! |
|
1945 |
||
1946 |
computeLayoutForTab:aTab |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1947 |
"calculate the effective bounds of a tab. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1948 |
This includes any size changes for the active tab (overlap etc.)." |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1949 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1950 |
|unselectedLayout selectedLayout computedLayout bwAbs tabLeft tabRight tabTop tabBottom| |
1401 | 1951 |
|
2687 | 1952 |
aTab isNil ifTrue:[^ nil]. |
1953 |
||
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1954 |
unselectedLayout := aTab unselectedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1955 |
(self hasTabSelected:aTab) ifFalse:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1956 |
^ unselectedLayout |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1957 |
]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1958 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1959 |
selectedLayout := aTab selectedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1960 |
selectedLayout notNil ifTrue:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1961 |
^ selectedLayout |
1658 | 1962 |
]. |
1401 | 1963 |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1964 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1965 |
"/ compute and remember |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1966 |
bwAbs := tabLevel abs. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1967 |
tabLeft := unselectedLayout left. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1968 |
tabRight := unselectedLayout right. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1969 |
tabTop := unselectedLayout top. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1970 |
tabBottom := unselectedLayout bottom. |
1658 | 1971 |
|
1972 |
(direction == #top or:[direction == #bottom]) ifTrue:[ |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1973 |
tabLeft := tabLeft - selectionInsetX. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1974 |
tabRight := tabRight + selectionInsetX. |
2686 | 1975 |
|
2289 | 1976 |
bwAbs == 0 ifTrue:[ |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1977 |
tabLeft == 0 ifTrue:[ tabLeft := tabLeft - 1 ]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1978 |
tabRight == self width ifTrue:[ tabRight := tabRight + 1 ]. |
2289 | 1979 |
]. |
2283 | 1980 |
|
2278 | 1981 |
direction == #top ifTrue:[ |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1982 |
tabBottom := tabBottom + bwAbs. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1983 |
tabTop := tabTop - selectionInsetY. |
375 | 1984 |
] ifFalse:[ |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1985 |
tabTop := tabTop - bwAbs. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1986 |
tabBottom := tabBottom + selectionInsetY. |
1658 | 1987 |
]. |
2278 | 1988 |
] ifFalse:[ |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1989 |
tabTop := tabTop - selectionInsetX. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1990 |
tabBottom := tabBottom + selectionInsetX. |
2686 | 1991 |
|
2289 | 1992 |
bwAbs == 0 ifTrue:[ |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1993 |
tabTop == 0 ifTrue:[ tabTop := tabTop - 1 ]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1994 |
tabBottom == self height ifTrue:[ tabBottom := tabBottom + 1 ]. |
2289 | 1995 |
]. |
2278 | 1996 |
|
1997 |
direction == #left ifTrue:[ |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1998 |
tabRight := tabRight + bwAbs. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
1999 |
tabLeft := tabLeft - selectionInsetY |
2278 | 2000 |
] ifFalse:[ |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2001 |
tabLeft := tabLeft - bwAbs. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2002 |
tabRight := tabRight + selectionInsetY. |
2278 | 2003 |
] |
1401 | 2004 |
]. |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2005 |
computedLayout := Rectangle left:tabLeft top:tabTop right:tabRight bottom:tabBottom. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2006 |
aTab selectedLayout:computedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2007 |
^ computedLayout |
1401 | 2008 |
! |
2009 |
||
2010 |
makeToBaseLine:aLnNr |
|
1962
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2011 |
"rotate lines to make the line #aLnNr be the new base line (i.e. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2012 |
subtract (aLnNr-1) from all lines and take modulu the number of lines" |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2013 |
|
1963 | 2014 |
|lineTopsOrLefts isHorizontal| |
2015 |
||
2016 |
isHorizontal := self isHorizontal. |
|
1962
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2017 |
|
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2018 |
"collect per-lineNr offsets" |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2019 |
lineTopsOrLefts := (1 to:numberOfLines) collect:[:lnr | |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2020 |
|tabNr layout| |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2021 |
|
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2022 |
tabNr := list findFirst:[:aTab| aTab lineNr == lnr]. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2023 |
layout := (list at:tabNr) layout. |
1963 | 2024 |
isHorizontal ifTrue:[ |
1962
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2025 |
layout top. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2026 |
] ifFalse:[ |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2027 |
layout left. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2028 |
]. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2029 |
]. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2030 |
|
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2031 |
"change offsets of all tabs" |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2032 |
list do:[:el | |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2033 |
|layout topOrLeft nr newNr| |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2034 |
|
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2035 |
nr := el lineNr. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2036 |
newNr := nr - aLnNr + 1. |
1964 | 2037 |
newNr <= 0 ifTrue:[ newNr := newNr + numberOfLines]. |
1962
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2038 |
newNr := ((newNr - 1) \\ numberOfLines) + 1. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2039 |
topOrLeft := lineTopsOrLefts at:newNr. |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2040 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2041 |
layout := el layout copy. |
1963 | 2042 |
isHorizontal ifTrue:[ |
1962
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2043 |
layout setTop:topOrLeft. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2044 |
] ifFalse:[ |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2045 |
layout setLeft:topOrLeft. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2046 |
]. |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2047 |
el layout:layout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2048 |
el unselectedLayout:layout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2049 |
el selectedLayout:nil. |
1962
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2050 |
el lineNr:newNr. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2051 |
]. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2052 |
|
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
2053 |
self invalidate. |
1401 | 2054 |
! |
2055 |
||
2056 |
recomputeList |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2057 |
"recompute list" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2058 |
|
2686 | 2059 |
|tab| |
2060 |
||
2281 | 2061 |
numberOfLines := 1. |
1403 | 2062 |
lastComputedExtent := self extent. |
1401 | 2063 |
|
2686 | 2064 |
self transformation:nil. |
2065 |
||
1680 | 2066 |
list size ~~ 0 ifTrue:[ |
2281 | 2067 |
self isHorizontal ifTrue:[ self recomputeListHorizontal ] |
2686 | 2068 |
ifFalse:[ self recomputeListVertical ]. |
2069 |
||
2070 |
tab := self selectedTab. |
|
2071 |
tab isNil ifTrue:[tab := list first]. |
|
2893 | 2072 |
tab layout:(self computeLayoutForTab:tab). |
2686 | 2073 |
|
1401 | 2074 |
]. |
2725 | 2075 |
self validateVisibleCanvas. |
1680 | 2076 |
self resizeCanvas. |
2686 | 2077 |
|
2078 |
self hasScrollButtons ifTrue:[ |
|
2079 |
self isHorizontal ifTrue:[ |
|
2080 |
buttonNext direction:#right. |
|
2081 |
buttonPrev direction:#left. |
|
2082 |
] ifFalse:[ |
|
2083 |
buttonNext direction:#down. |
|
2084 |
buttonPrev direction:#up. |
|
2085 |
]. |
|
2086 |
self makeVisible:tab. |
|
2087 |
]. |
|
1401 | 2088 |
! |
2089 |
||
2090 |
recomputeListHorizontal |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2091 |
"compute layouts for all tabs" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2092 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2093 |
|lastLyt tabExtent isScrollable |
2691 | 2094 |
xLeft "{ Class:SmallInteger }" |
2095 |
xRight "{ Class:SmallInteger }" |
|
2096 |
yTop "{ Class:SmallInteger }" |
|
2097 |
tabWidth "{ Class:SmallInteger }" |
|
2098 |
tabHeight "{ Class:SmallInteger }" |
|
2099 |
delta "{ Class:SmallInteger }" |
|
2100 |
first "{ Class:SmallInteger }" |
|
2101 |
border "{ Class:SmallInteger }" |
|
2102 |
lastLnNr "{ Class:SmallInteger }" |
|
2103 |
tabLvlAbs "{ Class:SmallInteger }" |
|
2104 |
minLeft "{ Class:SmallInteger }" |
|
2105 |
maxRight "{ Class:SmallInteger }" |
|
2106 |
leftMargin "{ Class:SmallInteger }" |
|
2107 |
rightMargin "{ Class:SmallInteger }" |
|
1401 | 2108 |
| |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2109 |
|
2283 | 2110 |
tabLvlAbs := tabLevel abs max:1. |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2111 |
border := tabLvlAbs * 2. |
2281 | 2112 |
tabHeight := 0. |
2691 | 2113 |
leftMargin := self tabLeftMargin. |
2114 |
rightMargin := self tabRightMargin. |
|
2115 |
minLeft := leftMargin + selectionInsetX. |
|
2116 |
maxRight := self width - rightMargin - selectionInsetX. |
|
2286 | 2117 |
xLeft := minLeft. |
2686 | 2118 |
isScrollable := self hasScrollButtons. |
1401 | 2119 |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2120 |
list do:[:aTab| aTab layout:nil; unselectedLayout:nil; selectedLayout:nil]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2121 |
|
1401 | 2122 |
list do:[:aTab| |
2431 | 2123 |
tabExtent := self preferredExtentForTab:aTab. |
2124 |
tabWidth := tabExtent x + border. |
|
2125 |
tabHeight := tabExtent y max:tabHeight. |
|
2281 | 2126 |
xRight := xLeft + tabWidth. |
1401 | 2127 |
|
2686 | 2128 |
(isScrollable not and:[xRight > maxRight]) ifTrue:[ |
2286 | 2129 |
xLeft ~~ minLeft ifTrue:[ |
2281 | 2130 |
numberOfLines := numberOfLines + 1. |
2286 | 2131 |
xLeft := minLeft. |
2281 | 2132 |
xRight := xLeft + tabWidth. |
2133 |
]. |
|
2286 | 2134 |
xRight > maxRight ifTrue:[ |
2135 |
tabWidth := maxRight - minLeft. |
|
2136 |
xRight := maxRight. |
|
2281 | 2137 |
]. |
1401 | 2138 |
]. |
2139 |
aTab lineNr:numberOfLines. |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2140 |
aTab unselectedLayout:(Rectangle left:xLeft top:0 width:tabWidth height:tabHeight). |
2281 | 2141 |
xLeft := xRight. |
1401 | 2142 |
]. |
2283 | 2143 |
tabHeight := tabHeight + tabLvlAbs. |
2144 |
yTop := selectionInsetY + tabTopMargin. |
|
2281 | 2145 |
|
2146 |
direction == #bottom ifTrue:[ |
|
2691 | 2147 |
yTop := self height - tabHeight - yTop. |
2281 | 2148 |
delta := tabHeight negated. |
2149 |
] ifFalse:[ |
|
2150 |
delta := tabHeight |
|
2151 |
]. |
|
2152 |
||
2153 |
lastLnNr := numberOfLines. |
|
1401 | 2154 |
|
2281 | 2155 |
list reverseDo:[:aTab| |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2156 |
|tabLayout| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2157 |
|
2281 | 2158 |
aTab lineNr ~~ lastLnNr ifTrue:[ |
2159 |
lastLnNr := aTab lineNr. |
|
2160 |
yTop := yTop + delta |
|
2161 |
]. |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2162 |
tabLayout := aTab unselectedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2163 |
tabLayout setTop:yTop. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2164 |
tabLayout height:tabHeight. |
1401 | 2165 |
]. |
2281 | 2166 |
|
1401 | 2167 |
tabModus ifTrue:[ |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2168 |
|firstTabLayout| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2169 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2170 |
firstTabLayout := list first unselectedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2171 |
delta := direction == #top |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2172 |
ifTrue:[self height - firstTabLayout bottom] |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2173 |
ifFalse:[firstTabLayout top negated]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2174 |
|
2894 | 2175 |
list do:[:aTab | |l| |
2176 |
l := aTab unselectedLayout. |
|
2177 |
l setTop:(l top + delta). |
|
2178 |
]. |
|
1401 | 2179 |
]. |
2180 |
||
2181 |
"/ FIT LINES |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2182 |
(numberOfLines ~~ 1 or:[fitLastRow]) ifTrue:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2183 |
first := 1. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2184 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2185 |
1 to:numberOfLines do:[:aLnNr| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2186 |
|last| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2187 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2188 |
last := list findLast:[:t|t lineNr == aLnNr]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2189 |
lastLyt := (list at:last) unselectedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2190 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2191 |
(delta := maxRight - lastLyt right) > 0 ifTrue:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2192 |
xLeft := minLeft. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2193 |
delta := delta // (last - first + 1). |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2194 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2195 |
delta ~~ 0 ifTrue:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2196 |
list from:first to:last do:[:aTab| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2197 |
|tabLayout| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2198 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2199 |
tabLayout := aTab unselectedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2200 |
tabWidth := tabLayout width + delta. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2201 |
tabLayout setLeft:xLeft. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2202 |
tabLayout width:tabWidth. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2203 |
xLeft := xLeft + tabWidth. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2204 |
] |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2205 |
]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2206 |
lastLyt width:(maxRight - lastLyt left) |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2207 |
]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2208 |
first := last + 1. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2209 |
] |
1401 | 2210 |
]. |
2211 |
||
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2212 |
list do:[:aTab | aTab layout:aTab unselectedLayout; selectedLayout:nil ]. |
1401 | 2213 |
! |
2214 |
||
2215 |
recomputeListVertical |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2216 |
"compute layouts for all tabs" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2217 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2218 |
|lastLyt tabExtent isScrollable |
2691 | 2219 |
xTop "{ Class:SmallInteger }" |
2220 |
yTop "{ Class:SmallInteger }" |
|
2221 |
yBottom "{ Class:SmallInteger }" |
|
2222 |
tabWidth "{ Class:SmallInteger }" |
|
2223 |
tabHeight "{ Class:SmallInteger }" |
|
2224 |
delta "{ Class:SmallInteger }" |
|
2225 |
first "{ Class:SmallInteger }" |
|
2226 |
border "{ Class:SmallInteger }" |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2227 |
lastLnNr "{ Class:SmallInteger }" |
2691 | 2228 |
tabLvlAbs "{ Class:SmallInteger }" |
2229 |
minTop "{ Class:SmallInteger }" |
|
2230 |
maxBottom "{ Class:SmallInteger }" |
|
2231 |
leftMargin "{ Class:SmallInteger }" |
|
2232 |
rightMargin "{ Class:SmallInteger }" |
|
1401 | 2233 |
| |
2010 | 2234 |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2235 |
tabLvlAbs := tabLevel abs max:1. |
2283 | 2236 |
border := tabLvlAbs * 2. |
2281 | 2237 |
tabHeight := 0. |
2691 | 2238 |
leftMargin := self tabLeftMargin. |
2239 |
rightMargin := self tabRightMargin. |
|
2240 |
minTop := leftMargin + selectionInsetX. |
|
2241 |
maxBottom := self height - rightMargin - selectionInsetX. |
|
2286 | 2242 |
yTop := minTop. |
2686 | 2243 |
isScrollable := self hasScrollButtons. |
1401 | 2244 |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2245 |
list do:[:aTab| aTab layout:nil; unselectedLayout:nil; selectedLayout:nil]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2246 |
|
1401 | 2247 |
list do:[:aTab| |
2431 | 2248 |
tabExtent := self preferredExtentForTab:aTab. |
2249 |
tabWidth := tabExtent x + border. |
|
2250 |
tabHeight := tabExtent y max:tabHeight. |
|
2281 | 2251 |
yBottom := yTop + tabWidth. |
1401 | 2252 |
|
2686 | 2253 |
(isScrollable not and:[yBottom > maxBottom]) ifTrue:[ |
2286 | 2254 |
yTop ~~ minTop ifTrue:[ |
2281 | 2255 |
numberOfLines := numberOfLines + 1. |
2286 | 2256 |
yTop := minTop. |
2281 | 2257 |
yBottom := yTop + tabWidth. |
2258 |
]. |
|
2286 | 2259 |
yBottom > maxBottom ifTrue:[ |
2260 |
tabWidth := maxBottom - minTop. |
|
2261 |
yBottom := maxBottom. |
|
2281 | 2262 |
]. |
1401 | 2263 |
]. |
2264 |
aTab lineNr:numberOfLines. |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2265 |
aTab unselectedLayout:(Rectangle left:0 top:yTop width:tabHeight height:tabWidth). |
2281 | 2266 |
yTop := yBottom |
1401 | 2267 |
]. |
2283 | 2268 |
tabHeight := tabHeight + tabLvlAbs. |
2269 |
xTop := selectionInsetY + tabTopMargin. |
|
2281 | 2270 |
|
2271 |
direction == #right ifTrue:[ |
|
2691 | 2272 |
xTop := self width - tabHeight - xTop. |
2281 | 2273 |
delta := tabHeight negated. |
2274 |
] ifFalse:[ |
|
2275 |
delta := tabHeight. |
|
2276 |
]. |
|
1401 | 2277 |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2278 |
lastLnNr := numberOfLines. |
2281 | 2279 |
|
2280 |
list reverseDo:[:aTab| |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2281 |
|tabLayout| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2282 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2283 |
aTab lineNr ~~ lastLnNr ifTrue:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2284 |
lastLnNr := aTab lineNr. |
2281 | 2285 |
xTop := xTop + delta |
2286 |
]. |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2287 |
tabLayout := aTab unselectedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2288 |
tabLayout setLeft:xTop. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2289 |
tabLayout width:tabHeight. |
1401 | 2290 |
]. |
2281 | 2291 |
|
1401 | 2292 |
tabModus ifTrue:[ |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2293 |
|firstTabLayout| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2294 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2295 |
firstTabLayout := list first unselectedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2296 |
delta := direction == #left |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2297 |
ifTrue:[self width - firstTabLayout right] |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2298 |
ifFalse:[firstTabLayout left negated]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2299 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2300 |
list do:[:aTab | |l| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2301 |
l := aTab unselectedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2302 |
l setLeft:(l left + delta). |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2303 |
]. |
1401 | 2304 |
]. |
2305 |
||
2306 |
"/ FIT LINES |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2307 |
(numberOfLines ~~ 1 or:[fitLastRow]) ifTrue:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2308 |
first := 1. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2309 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2310 |
1 to:numberOfLines do:[:aLnNr| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2311 |
|last| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2312 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2313 |
last := list findLast:[:t|t lineNr == aLnNr]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2314 |
lastLyt := (list at:last) unselectedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2315 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2316 |
(delta := maxBottom - lastLyt bottom) > 0 ifTrue:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2317 |
yTop := minTop. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2318 |
delta := delta // (last - first + 1). |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2319 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2320 |
delta ~~ 0 ifTrue:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2321 |
list from:first to:last do:[:aTab| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2322 |
|tabLayout| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2323 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2324 |
tabLayout := aTab unselectedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2325 |
tabWidth := tabLayout height + delta. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2326 |
tabLayout setTop:yTop. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2327 |
tabLayout height:tabWidth. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2328 |
yTop := yTop + tabWidth. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2329 |
] |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2330 |
]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2331 |
lastLyt height:(maxBottom - lastLyt top) |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2332 |
]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2333 |
first := last + 1. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2334 |
]. |
1401 | 2335 |
]. |
2336 |
||
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2337 |
list do:[:aTab | aTab layout:aTab unselectedLayout; selectedLayout:nil ]. |
1680 | 2338 |
! |
2339 |
||
2340 |
resizeCanvas |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2341 |
|newLayout borderWd| |
1680 | 2342 |
|
2343 |
canvas notNil ifTrue:[ |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2344 |
newLayout := self computeBorderLayout. |
2278 | 2345 |
|
2346 |
list notEmpty ifTrue:[ |
|
2347 |
borderWd := tabLevel abs. |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2348 |
newLayout := newLayout insetBy:(canvasInset + borderWd). |
2284 | 2349 |
|
2350 |
tabBottomMargin > 0 ifTrue:[ |
|
2351 |
(direction == #top or:[direction == #bottom]) ifTrue:[ |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2352 |
newLayout height:(newLayout height - tabBottomMargin). |
2284 | 2353 |
direction == #top ifTrue:[ |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2354 |
newLayout setTop:(newLayout top + tabBottomMargin) |
2284 | 2355 |
] |
2356 |
] ifFalse:[ |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2357 |
newLayout width:(newLayout width - tabBottomMargin). |
2284 | 2358 |
|
2359 |
direction == #left ifTrue:[ |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2360 |
newLayout setLeft:(newLayout left + tabBottomMargin) |
2284 | 2361 |
] |
2362 |
] |
|
2363 |
||
2364 |
]. |
|
2036 | 2365 |
]. |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2366 |
newLayout ~= canvas layout ifTrue:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2367 |
canvas layout:newLayout. |
2278 | 2368 |
]. |
1680 | 2369 |
] |
1401 | 2370 |
! ! |
2371 |
||
2372 |
!NoteBookView methodsFor:'obsolete'! |
|
2373 |
||
2279 | 2374 |
canvasFrameLevel |
2375 |
"ignorred |
|
2376 |
" |
|
2377 |
^ 0 |
|
2378 |
! |
|
2379 |
||
2380 |
canvasFrameLevel:anInteger |
|
2381 |
"ignorred |
|
2382 |
" |
|
2383 |
! |
|
2384 |
||
1401 | 2385 |
labels |
2386 |
"return the list of labels |
|
2387 |
" |
|
2388 |
^ self list |
|
2389 |
! |
|
2390 |
||
2391 |
labels:aListOfLabels |
|
2392 |
"set the list of labels |
|
2393 |
" |
|
2394 |
^ self list:aListOfLabels |
|
2395 |
! |
|
2396 |
||
2397 |
labelsHolder |
|
2398 |
"get the model, which keeps the list of Tabs or Labels |
|
2399 |
" |
|
2400 |
^ self listHolder |
|
2401 |
! |
|
2402 |
||
2403 |
labelsHolder:aValueHolder |
|
2404 |
"set the model, which keeps the list of Tabs or Labels |
|
2405 |
" |
|
2406 |
self listHolder:aValueHolder. |
|
2407 |
! ! |
|
2408 |
||
2409 |
!NoteBookView methodsFor:'private'! |
|
2410 |
||
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2411 |
processAccessCharacter:aKey |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2412 |
"a character is pressed; check for tab identified y the character |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2413 |
select the tab and return true or if no tab detected return false |
1401 | 2414 |
" |
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2415 |
|j size char blck| |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2416 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2417 |
(aKey isCharacter and:[(size := list size) ~~ 0]) ifFalse:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2418 |
^ false |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2419 |
]. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2420 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2421 |
size == selection ifTrue:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2422 |
size == 1 ifTrue:[^ false]. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2423 |
j := 1 |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2424 |
] ifFalse:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2425 |
j := selection isNil ifTrue:[1] ifFalse:[selection + 1] |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2426 |
]. |
1401 | 2427 |
|
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2428 |
char := aKey asLowercase. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2429 |
blck := [:i| ((list at:i) accessCharacter == char and:[self isSelectable:i]) ifTrue:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2430 |
self selection:i. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2431 |
^ true |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2432 |
] |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2433 |
]. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2434 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2435 |
j to:size do:blck. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2436 |
1 to:(j-1) do:blck. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2437 |
^ false |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2438 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2439 |
! |
1401 | 2440 |
|
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2441 |
processShortcutKey:aKey |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2442 |
"if there is a short-key for that character, process it |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2443 |
and return true. Otherwise, return false. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2444 |
" |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2445 |
|j k size rawKey blck| |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2446 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2447 |
(size := list size) == 0 ifTrue:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2448 |
^ false |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2449 |
]. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2450 |
rawKey := device keyboardMap keyAtValue:aKey ifAbsent:aKey. |
1401 | 2451 |
|
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2452 |
size == selection ifTrue:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2453 |
size == 1 ifTrue:[^ false]. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2454 |
j := 1 |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2455 |
] ifFalse:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2456 |
j := selection isNil ifTrue:[1] ifFalse:[selection + 1] |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2457 |
]. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2458 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2459 |
blck := [:i| k := (list at:i) shortcutKey. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2460 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2461 |
(k notNil and:[(self isSelectable:i) and:[(k == aKey or:[k == rawKey])]]) ifTrue:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2462 |
self selection:i. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2463 |
^ true |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2464 |
] |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2465 |
]. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2466 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2467 |
j to:size do:blck. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2468 |
1 to:(j-1) do:blck. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2469 |
^ false |
1401 | 2470 |
! ! |
2471 |
||
2686 | 2472 |
!NoteBookView methodsFor:'private-buttons'! |
2473 |
||
2474 |
buttonLayoutUpdate |
|
2691 | 2475 |
|layout bW h y w x e| |
2686 | 2476 |
|
2477 |
self hasScrollButtons ifFalse:[^ self]. |
|
2478 |
||
2479 |
(numberOfLines isNil or:[list size == 0]) ifTrue:[ |
|
2480 |
self transformation:nil. |
|
2706 | 2481 |
self hideButton:buttonPrev. |
2482 |
self hideButton:buttonNext. |
|
2686 | 2483 |
^ self |
2484 |
]. |
|
2485 |
layout := list first layout. |
|
2691 | 2486 |
bW := self buttonWidth. |
2487 |
||
2488 |
self isHorizontal ifTrue:[ |
|
2489 |
y := layout top. |
|
2490 |
h := layout height. |
|
2491 |
e := bW @ h. |
|
2492 |
buttonPrev origin:(self tabLeftMargin)@y extent:e. |
|
2493 |
buttonNext origin:(self width - self tabRightMargin - bW) @ y extent:e. |
|
2494 |
] ifFalse:[ |
|
2495 |
x := layout left. |
|
2496 |
w := layout width. |
|
2497 |
e := w @ bW. |
|
2498 |
buttonPrev origin:x@(self tabLeftMargin) extent:e. |
|
2499 |
buttonNext origin:x@(self height - self tabRightMargin - bW) extent:e. |
|
2686 | 2500 |
]. |
2501 |
! |
|
2502 |
||
2503 |
buttonWidth |
|
2504 |
"returns the button extent x or y dependent on the layout |
|
2505 |
" |
|
2506 |
^ 16 |
|
2507 |
! |
|
2508 |
||
2706 | 2509 |
hideButton:aButton |
2510 |
aButton controller buttonRelease:#select x:0 y:0. |
|
2511 |
aButton unmap. |
|
2512 |
! |
|
2513 |
||
2686 | 2514 |
makeVisible:aTab |
2515 |
"setup transformation to make the selection visible; |
|
2516 |
returns true if the transformation has changed otherwise false. |
|
2517 |
" |
|
2691 | 2518 |
|layoutLast isHorizontal max maxAllowed oldTrans newTrans leftMargin rightMargin| |
2519 |
||
2520 |
(numberOfLines notNil and:[self hasScrollButtons]) ifFalse:[ |
|
2521 |
^ false |
|
2522 |
]. |
|
2686 | 2523 |
|
2687 | 2524 |
aTab isNil ifTrue:[ |
2525 |
list size == 0 ifTrue:[ |
|
2706 | 2526 |
self hideButton:buttonPrev. |
2527 |
self hideButton:buttonNext. |
|
2687 | 2528 |
self transformation:nil. |
2529 |
]. |
|
2530 |
^ false. |
|
2531 |
]. |
|
2686 | 2532 |
oldTrans := self transformation. |
2533 |
isHorizontal := self isHorizontal. |
|
2534 |
layoutLast := list last layout. |
|
2691 | 2535 |
leftMargin := self tabLeftMargin. |
2536 |
rightMargin := self tabRightMargin. |
|
2686 | 2537 |
|
2538 |
isHorizontal ifTrue:[ |
|
2691 | 2539 |
max := layoutLast right. |
2540 |
maxAllowed := self width - rightMargin. |
|
2686 | 2541 |
|
2542 |
max > maxAllowed ifTrue:[ |
|
2543 |
self makeVisibleHorizontal:aTab. |
|
2544 |
] ifFalse:[ |
|
2545 |
self transformation:nil. |
|
2546 |
]. |
|
2547 |
] ifFalse:[ |
|
2691 | 2548 |
max := layoutLast bottom. |
2549 |
maxAllowed := self height - rightMargin. |
|
2686 | 2550 |
|
2551 |
max > maxAllowed ifTrue:[ |
|
2552 |
self makeVisibleVertical:aTab. |
|
2553 |
] ifFalse:[ |
|
2554 |
self transformation:nil. |
|
2555 |
]. |
|
2556 |
]. |
|
2557 |
newTrans := self transformation. |
|
2558 |
||
2559 |
newTrans isNil ifTrue:[ |
|
2706 | 2560 |
self hideButton:buttonPrev. |
2686 | 2561 |
] ifFalse:[ |
2562 |
buttonPrev map. |
|
2563 |
||
2564 |
max := isHorizontal ifTrue:[newTrans applyToX:max] |
|
2565 |
ifFalse:[newTrans applyToY:max]. |
|
2566 |
]. |
|
2567 |
||
2568 |
max > maxAllowed ifTrue:[ |
|
2569 |
buttonNext map |
|
2570 |
] ifFalse:[ |
|
2706 | 2571 |
self hideButton:buttonNext. |
2686 | 2572 |
]. |
2573 |
^ oldTrans ~~ newTrans |
|
2574 |
! |
|
2575 |
||
2576 |
makeVisibleHorizontal:aTab |
|
2577 |
"setup transformation to make the horizontal selection visible |
|
2578 |
" |
|
2691 | 2579 |
|trans bounds xL xR xI minLeft maxRight| |
2580 |
||
2581 |
trans := self transformation. |
|
2582 |
bounds := self computeLayoutForTab:aTab. |
|
2583 |
xL := bounds left. |
|
2584 |
xI := self buttonWidth. |
|
2686 | 2585 |
|
2586 |
trans notNil ifTrue:[ xL := trans applyToX:xL ]. |
|
2587 |
||
2691 | 2588 |
minLeft := self tabLeftMargin. |
2589 |
||
2590 |
xL < (xI + minLeft) ifTrue:[ |
|
2686 | 2591 |
list first == aTab ifTrue:[ |
2592 |
trans := nil. |
|
2593 |
] ifFalse:[ |
|
2691 | 2594 |
trans := WindowingTransformation scale:nil translation:(((xI + minLeft) - bounds left) @ 0). |
2686 | 2595 |
]. |
2596 |
self transformation:trans. |
|
2597 |
^ self |
|
2598 |
]. |
|
2691 | 2599 |
xR := xL + bounds width. |
2600 |
maxRight := self width - self tabRightMargin. |
|
2601 |
||
2602 |
xR > (maxRight - xI) ifTrue:[ |
|
2686 | 2603 |
list last == aTab ifTrue:[ |
2604 |
xI := 0. |
|
2605 |
]. |
|
2691 | 2606 |
trans := WindowingTransformation scale:nil translation:((maxRight - xI - bounds right) @ 0). |
2686 | 2607 |
self transformation:trans. |
2608 |
]. |
|
2609 |
! |
|
2610 |
||
2611 |
makeVisibleVertical:aTab |
|
2612 |
"setup transformation to make the vertical selection visible |
|
2613 |
" |
|
2691 | 2614 |
|trans bounds xL xR xI minTop maxBot| |
2686 | 2615 |
|
2616 |
trans := self transformation. |
|
2617 |
bounds := self computeLayoutForTab:aTab. |
|
2618 |
xL := bounds top. |
|
2619 |
xI := self buttonWidth. |
|
2620 |
||
2621 |
trans notNil ifTrue:[ xL := trans applyToY:xL ]. |
|
2691 | 2622 |
minTop := self tabLeftMargin. |
2623 |
||
2624 |
xL < (xI + minTop) ifTrue:[ |
|
2686 | 2625 |
list first == aTab ifTrue:[ |
2626 |
trans := nil |
|
2627 |
] ifFalse:[ |
|
2691 | 2628 |
trans := WindowingTransformation scale:nil translation:(0@((minTop + xI) - bounds top)). |
2686 | 2629 |
]. |
2630 |
self transformation:trans. |
|
2631 |
^ self |
|
2632 |
]. |
|
2633 |
xR := xL + bounds height. |
|
2691 | 2634 |
maxBot := self height - self tabRightMargin. |
2635 |
||
2636 |
xR > (maxBot - xI) ifTrue:[ |
|
2686 | 2637 |
list last == aTab ifTrue:[ |
2638 |
xI := 0. |
|
2639 |
]. |
|
2691 | 2640 |
trans := WindowingTransformation scale:nil translation:(0@ (maxBot - xI - bounds bottom)). |
2686 | 2641 |
self transformation:trans. |
2642 |
]. |
|
2698 | 2643 |
! |
2644 |
||
2645 |
scrollButtonPressed:whichButton |
|
2706 | 2646 |
|trans idx isNext nIdx pIdx| |
2647 |
||
2648 |
list isEmptyOrNil ifTrue:[^ self]. |
|
2698 | 2649 |
|
2650 |
whichButton == #scrollRight ifTrue:[ |
|
2651 |
isNext := true |
|
2652 |
] ifFalse:[ |
|
2653 |
whichButton == #scrollLeft ifFalse:[^ self]. |
|
2654 |
isNext := false. |
|
2655 |
]. |
|
2706 | 2656 |
trans := self transformation. |
2657 |
||
2658 |
self isHorizontal ifTrue:[ |y xN xP| |
|
2659 |
y := list first layout top. |
|
2660 |
xN := buttonNext origin x + 2. |
|
2661 |
xP := buttonPrev corner x - 2. |
|
2662 |
||
2663 |
trans notNil ifTrue:[ |
|
2664 |
xN := trans applyInverseToX:xN. |
|
2665 |
xP := trans applyInverseToX:xP. |
|
2698 | 2666 |
]. |
2706 | 2667 |
nIdx := list findFirst:[:aTab| aTab containsPointX:xN y:y ]. |
2668 |
pIdx := list findFirst:[:aTab| aTab containsPointX:xP y:y ]. |
|
2669 |
] ifFalse:[ |x yN yP| |
|
2670 |
x := list first layout left. |
|
2671 |
yN := buttonNext origin y + 2. |
|
2672 |
yP := buttonPrev corner y - 2. |
|
2673 |
||
2674 |
trans notNil ifTrue:[ |
|
2675 |
yN := trans applyInverseToY:yN. |
|
2676 |
yP := trans applyInverseToY:yP. |
|
2698 | 2677 |
]. |
2706 | 2678 |
nIdx := list findFirst:[:aTab| aTab containsPointX:x y:yN ]. |
2679 |
pIdx := list findFirst:[:aTab| aTab containsPointX:x y:yP ]. |
|
2698 | 2680 |
]. |
2706 | 2681 |
idx := isNext ifTrue:[nIdx] ifFalse:[pIdx]. |
2682 |
||
2698 | 2683 |
idx == 0 ifTrue:[ |
2684 |
idx := isNext ifTrue:[list size] ifFalse:[1]. |
|
2706 | 2685 |
] ifFalse:[ |revIdx| |
2686 |
revIdx := isNext ifTrue:[pIdx] ifFalse:[nIdx]. |
|
2687 |
||
2688 |
revIdx == idx ifTrue:[ |
|
2689 |
isNext ifTrue:[ |
|
2690 |
idx := revIdx + 1 min:(list size). |
|
2691 |
] ifFalse:[ |
|
2692 |
idx := revIdx - 1 max:1. |
|
2693 |
] |
|
2694 |
]. |
|
2698 | 2695 |
]. |
2696 |
||
2697 |
(self makeVisible:(list at:idx ifAbsent:nil)) ifTrue:[ |
|
2698 |
self invalidate. |
|
2699 |
]. |
|
2686 | 2700 |
! ! |
2701 |
||
1401 | 2702 |
!NoteBookView methodsFor:'queries'! |
2703 |
||
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2704 |
hasTabSelected:aTab |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2705 |
^ aTab == self selectedTab |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2706 |
! |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2707 |
|
1401 | 2708 |
isFirstTabInLine:aTab |
2279 | 2709 |
"returns true if the tab is the first tab in the line |
2710 |
used by drawing |
|
2711 |
" |
|
2712 |
|idx prevTab| |
|
1401 | 2713 |
|
2714 |
idx := list identityIndexOf:aTab. |
|
2279 | 2715 |
prevTab := list at:(idx - 1) ifAbsent:nil. |
2716 |
||
2717 |
^ prevTab isNil or:[prevTab lineNr ~~ aTab lineNr] |
|
1401 | 2718 |
! |
2719 |
||
2720 |
isLastTabInLine:aTab |
|
2279 | 2721 |
"returns true if the tab is the last tab in the line |
2722 |
used by drawing |
|
2723 |
" |
|
2724 |
|index nextTab| |
|
1401 | 2725 |
|
2279 | 2726 |
index := list identityIndexOf:aTab. |
2727 |
nextTab := list at:(index + 1) ifAbsent:nil. |
|
2728 |
||
2729 |
^ nextTab isNil or:[nextTab lineNr ~~ aTab lineNr] |
|
1401 | 2730 |
! ! |
2731 |
||
2732 |
!NoteBookView methodsFor:'selection'! |
|
375 | 2733 |
|
1401 | 2734 |
isSelectable:anIndex |
2735 |
"returns true if tab at an index is selectable |
|
2736 |
" |
|
2737 |
(anIndex notNil and:[anIndex between:1 and:list size]) ifTrue:[ |
|
2738 |
(list at:anIndex) isEnabled ifTrue:[ |
|
2739 |
^ selectConditionBlock isNil ifTrue:[true] |
|
2740 |
ifFalse:[selectConditionBlock value:anIndex] |
|
2741 |
] |
|
2742 |
]. |
|
2743 |
^ false |
|
2744 |
! |
|
2745 |
||
2396
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2746 |
nextSelectableAfter:anIndex wrapAtEnd:wrapAtEnd |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2747 |
"return the index of the next selectable entry after the index; |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2748 |
wrap at end if the wrapAtEnd flag is set to true. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2749 |
" |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2750 |
|size idx| |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2751 |
|
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2752 |
size := list size. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2753 |
|
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2754 |
size > 1 ifTrue:[ |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2755 |
idx := anIndex + 1. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2756 |
idx to:size do:[:i| (self isSelectable:i) ifTrue:[^ i] ]. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2757 |
|
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2758 |
wrapAtEnd ifTrue:[ |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2759 |
idx := anIndex - 1. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2760 |
1 to:idx do:[:i| (self isSelectable:i) ifTrue:[^ i] ]. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2761 |
] |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2762 |
]. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2763 |
^ 0 |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2764 |
! |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2765 |
|
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2766 |
previousSelectableBefore:anIndex wrapAtBegin:wrapAtBegin |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2767 |
"return the index of the previous selectable entry before the index; |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2768 |
wrap at begin if the wrapAtBegin flag is set to true. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2769 |
" |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2770 |
|size idx| |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2771 |
|
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2772 |
size := list size. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2773 |
|
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2774 |
size > 1 ifTrue:[ |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2775 |
idx := anIndex - 1. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2776 |
idx to:1 by:-1 do:[:i| (self isSelectable:i) ifTrue:[^ i] ]. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2777 |
|
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2778 |
wrapAtBegin ifTrue:[ |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2779 |
idx := anIndex + 1. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2780 |
size to:idx by:-1 do:[:i| (self isSelectable:i) ifTrue:[^ i] ]. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2781 |
] |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2782 |
]. |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2783 |
^ 0 |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2784 |
! |
775112222b05
add #nextSelectableAfter:.. and #previousSelectableBefore:...; prepared for Tabbing
ca
parents:
2391
diff
changeset
|
2785 |
|
1401 | 2786 |
selectedTab |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2787 |
"returns the selected tab or nil" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2788 |
|
2279 | 2789 |
(selection notNil and:[selection ~~ 0]) ifTrue:[ |
2790 |
^ list at:selection ifAbsent:nil |
|
2791 |
]. |
|
2792 |
^ nil |
|
1401 | 2793 |
! |
2794 |
||
2795 |
selection |
|
2740 | 2796 |
"return the selection or nil/o; caring for the useIndex setting. |
1401 | 2797 |
" |
2798 |
selection isNil ifTrue:[ |
|
2799 |
^ useIndex ifTrue:[0] ifFalse:[nil] |
|
2800 |
]. |
|
2213 | 2801 |
^ useIndex ifTrue:[selection] ifFalse:[self selectedTab label] |
1401 | 2802 |
! |
2803 |
||
2804 |
selection:anIndexOrNil |
|
2805 |
"change the selection to index or nil. The model and/or actionBlock is notified |
|
2806 |
" |
|
2807 |
|oldSel| |
|
2808 |
||
1407 | 2809 |
anIndexOrNil ~~ selection ifTrue:[ |
2810 |
oldSel := selection. |
|
2811 |
self setSelection:anIndexOrNil. |
|
2812 |
oldSel ~~ selection ifTrue:[self selectionChanged] |
|
2813 |
] |
|
1401 | 2814 |
! |
2815 |
||
2816 |
selectionChanged |
|
2532 | 2817 |
"selection has changed; update model and evaluate change action" |
2818 |
||
1401 | 2819 |
|sel| |
2820 |
||
2821 |
sel := self selection. |
|
2822 |
||
2823 |
model notNil ifTrue:[model value:sel]. |
|
2824 |
action notNil ifTrue:[action value:sel] |
|
2825 |
! |
|
2826 |
||
2827 |
setSelection:anIndexOrNil |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2828 |
"change the selection to anIndexOrNil. No notifications are raised" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2829 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2830 |
|newSelIndex newSelTab oldSelTab oldBounds newBounds| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2831 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2832 |
newSelIndex := self listIndexOf:anIndexOrNil. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2833 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2834 |
(newSelIndex notNil and:[(self isSelectable:newSelIndex) not]) ifTrue:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2835 |
newSelIndex := nil |
1401 | 2836 |
]. |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2837 |
selection == newSelIndex ifTrue:[^ self]. |
1401 | 2838 |
|
2686 | 2839 |
numberOfLines isNil ifTrue:[ |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2840 |
selection := newSelIndex. |
2686 | 2841 |
^ self. |
2842 |
]. |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2843 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2844 |
oldSelTab := self selectedTab. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2845 |
oldSelTab notNil ifTrue:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2846 |
oldBounds := (self computeLayoutForTab:oldSelTab) merge:oldSelTab unselectedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2847 |
oldSelTab layout:(oldSelTab unselectedLayout). |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2848 |
]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2849 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2850 |
selection := newSelIndex. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2851 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2852 |
newSelTab := self selectedTab. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2853 |
newSelTab notNil ifTrue:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2854 |
newBounds := self computeLayoutForTab:newSelTab. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2855 |
newSelTab layout:newBounds. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2856 |
newBounds := newSelTab selectedLayout merge:newSelTab unselectedLayout. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2857 |
]. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2858 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2859 |
(self makeVisible:newSelTab) ifTrue:[ |
2686 | 2860 |
self invalidate. |
2861 |
] ifFalse:[ |
|
2862 |
shown ifTrue:[ |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2863 |
oldBounds notNil ifTrue:[ |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2864 |
self invalidate:oldBounds |
2215 | 2865 |
]. |
2686 | 2866 |
newBounds notNil ifTrue:[ |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2867 |
self invalidate:newBounds |
2686 | 2868 |
] |
2215 | 2869 |
]. |
1759 | 2870 |
]. |
2725 | 2871 |
self validateVisibleCanvas. |
2872 |
! |
|
2873 |
||
2874 |
validateVisibleCanvas |
|
2875 |
|model newCanvas selectedTab| |
|
2876 |
||
2877 |
selectedTab := self selectedTab. |
|
2878 |
||
2879 |
selectedTab notNil ifTrue:[ |
|
2880 |
model := selectedTab model. |
|
2881 |
||
2882 |
model isNil ifTrue:[ |
|
2883 |
^ self |
|
2884 |
]. |
|
2885 |
newCanvas := model canvasView. |
|
1759 | 2886 |
]. |
1724
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
2887 |
|
2725 | 2888 |
newCanvas == canvas ifTrue:[ |
1759 | 2889 |
^ self |
2890 |
]. |
|
2891 |
||
2725 | 2892 |
canvas notNil ifTrue:[ |
2893 |
(canvas objectAttributeAt:#isTabItem) == true ifFalse:[ |
|
2894 |
^ self. |
|
2895 |
] |
|
2896 |
]. |
|
2897 |
self canvas:newCanvas. |
|
2898 |
||
1759 | 2899 |
canvasHolder notNil ifTrue:[ |
2725 | 2900 |
canvasHolder value:newCanvas. |
1759 | 2901 |
]. |
1401 | 2902 |
! ! |
2903 |
||
2904 |
!NoteBookView::Tab class methodsFor:'instance creation'! |
|
2905 |
||
2906 |
label:aLabel on:aGC |
|
2907 |
^ self basicNew label:aLabel on:aGC |
|
2908 |
||
2909 |
||
2910 |
! ! |
|
2911 |
||
2912 |
!NoteBookView::Tab methodsFor:'accessing'! |
|
2913 |
||
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2914 |
accessCharacter |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2915 |
"returns the access character or nil" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2916 |
|
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2917 |
^ accessCharacter |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2918 |
! |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2919 |
|
2288 | 2920 |
foregroundColor |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2921 |
"returns the foregroundColor or nil" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2922 |
|
2288 | 2923 |
model notNil ifTrue:[ |
2924 |
^ model foregroundColor |
|
2925 |
]. |
|
2926 |
^ nil |
|
2927 |
! |
|
2928 |
||
1401 | 2929 |
label |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2930 |
"returns my original label" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2931 |
|
1401 | 2932 |
^ label |
2933 |
! |
|
2934 |
||
2935 |
label:aLabel on:aGC |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2936 |
"initialize attributes" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2937 |
|
1677 | 2938 |
label := aLabel. |
2939 |
model := (aLabel isKindOf:TabItem) ifTrue:[aLabel] ifFalse:[nil]. |
|
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2940 |
accessCharacter := nil. |
1677 | 2941 |
printableLabel := model notNil ifTrue:[model rawLabel] ifFalse:[aLabel]. |
1401 | 2942 |
|
2943 |
printableLabel notNil ifTrue:[ |
|
2944 |
printableLabel isImageOrForm ifTrue:[ |
|
2945 |
printableLabel := printableLabel onDevice:(aGC device) |
|
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2946 |
] ifFalse:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2947 |
printableLabel isString ifTrue:[ |
2629 | 2948 |
printableLabel := self resolveDisplayStringFor:printableLabel on:aGC. |
1677 | 2949 |
] ifFalse:[ |
2950 |
printableLabel class == LabelAndIcon ifTrue:[ |
|
2629 | 2951 |
printableLabel string:(self resolveDisplayStringFor:(printableLabel string) on:aGC) |
1677 | 2952 |
] |
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2953 |
]. |
375 | 2954 |
] |
1401 | 2955 |
] ifFalse:[ |
2956 |
printableLabel := '' |
|
2957 |
]. |
|
2958 |
extent := (printableLabel widthOn:aGC) @ (printableLabel heightOn:aGC). |
|
2959 |
! |
|
2960 |
||
2961 |
lineNr |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2962 |
"get the line number within the noteBook view" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2963 |
|
1401 | 2964 |
^ lineNr |
2965 |
! |
|
2966 |
||
2967 |
lineNr:aLineNr |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2968 |
"set the line number within the noteBook view" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2969 |
|
1401 | 2970 |
lineNr := aLineNr |
2971 |
! |
|
2972 |
||
1759 | 2973 |
model |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2974 |
"returns the model, a TabItem or nil" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2975 |
|
1759 | 2976 |
^ model |
2977 |
! |
|
2978 |
||
1401 | 2979 |
printableLabel |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2980 |
"get my printable label" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2981 |
|
1401 | 2982 |
^ printableLabel |
2983 |
! |
|
2984 |
||
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2985 |
shortcutKey |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2986 |
"get the key to press to select the tab item from the keyboard" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2987 |
|
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2988 |
model notNil ifTrue:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2989 |
^ model shortcutKey |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2990 |
]. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2991 |
^ nil |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2992 |
! |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2993 |
|
1401 | 2994 |
string |
2995 |
"access the printable string used for steping through a list |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2996 |
searching for an entry starting with a character." |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
2997 |
|
1401 | 2998 |
^ printableLabel perform:#string ifNotUnderstood:nil |
2999 |
! ! |
|
3000 |
||
1818 | 3001 |
!NoteBookView::Tab methodsFor:'accessing-dimensions'! |
1401 | 3002 |
|
3003 |
extent |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3004 |
"returns the extent of the label, the minimum size required by the tab" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3005 |
|
1401 | 3006 |
^ extent |
3007 |
! |
|
3008 |
||
3009 |
layout |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3010 |
"get the tab's current layout, set by the noteBook view" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3011 |
|
1401 | 3012 |
^ layout |
3013 |
! |
|
3014 |
||
3015 |
layout:aLayout |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3016 |
"set the tab's current layout" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3017 |
|
1401 | 3018 |
layout := aLayout |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3019 |
! |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3020 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3021 |
selectedLayout |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3022 |
"get the tab's selectedLayout, set by the noteBook view" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3023 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3024 |
^ selectedLayout |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3025 |
! |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3026 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3027 |
selectedLayout:aLayout |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3028 |
"set the tab's selectedLayout" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3029 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3030 |
selectedLayout := aLayout |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3031 |
! |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3032 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3033 |
unselectedLayout |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3034 |
"get the tab's unselectedLayout, set by the noteBook view" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3035 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3036 |
^ unselectedLayout |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3037 |
! |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3038 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3039 |
unselectedLayout:aLayout |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3040 |
"set the tab's unselectedLayout" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3041 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3042 |
unselectedLayout := aLayout |
1401 | 3043 |
! ! |
3044 |
||
1818 | 3045 |
!NoteBookView::Tab methodsFor:'accessing-mvc'! |
1401 | 3046 |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3047 |
addDependent:aGC |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3048 |
"make the noteBook be a dependent of the tab model" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3049 |
|
1759 | 3050 |
model notNil ifTrue:[ |
3051 |
model addDependent:aGC |
|
3052 |
] |
|
1401 | 3053 |
! |
3054 |
||
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3055 |
removeDependent:aGC |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3056 |
"make the noteBook be independent of the tab model" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3057 |
|
1759 | 3058 |
model notNil ifTrue:[ |
3059 |
model destroyCanvas. |
|
3060 |
model removeDependent:aGC. |
|
3061 |
] |
|
1401 | 3062 |
! ! |
3063 |
||
3064 |
!NoteBookView::Tab methodsFor:'drawing'! |
|
3065 |
||
2288 | 3066 |
displayOn:aGC inset:inset direction:aDirection |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3067 |
"redraw this tab" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3068 |
|
2288 | 3069 |
|dispObj lft wdt top hgt |
1401 | 3070 |
y "{ Class:SmallInteger }" |
3071 |
x "{ Class:SmallInteger }" |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3072 |
layoutLeft layoutRight layoutTop layoutBottom| |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3073 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3074 |
layoutLeft := layout left. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3075 |
layoutRight := layout right. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3076 |
layoutTop := layout top. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3077 |
layoutBottom := layout bottom. |
1401 | 3078 |
|
3079 |
"/ REDRAW LABEL |
|
3080 |
(aGC isEnabled and:[self isEnabled]) ifTrue:[ |
|
3081 |
dispObj := printableLabel. |
|
3082 |
] ifFalse:[ |
|
3083 |
(dispObj := disabledLabel) isNil ifTrue:[ |
|
3084 |
(dispObj := printableLabel) isImageOrForm ifTrue:[ |
|
3085 |
disabledLabel := printableLabel lightened onDevice:(aGC device) |
|
375 | 3086 |
] |
1401 | 3087 |
] |
3088 |
]. |
|
1442 | 3089 |
|
1401 | 3090 |
(aDirection == #top or:[aDirection == #bottom]) ifTrue:[ |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3091 |
lft := layoutLeft + inset. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3092 |
wdt := layoutRight - inset - lft. |
2288 | 3093 |
wdt > 4 ifFalse:[^ self]. |
3094 |
||
3095 |
x := (wdt - extent x) // 2. |
|
3096 |
x < 0 ifTrue:[ |
|
3097 |
dispObj := '...'. |
|
3098 |
x := 0. |
|
3099 |
]. |
|
3100 |
x := x + lft. |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3101 |
y := layoutTop + (layout height - inset - extent y // 2). |
2288 | 3102 |
|
3103 |
aDirection == #top ifTrue:[ y := y + inset ]. |
|
1401 | 3104 |
|
2485
b3d92f4a5f7b
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
2431
diff
changeset
|
3105 |
y := y + (dispObj ascentOn:aGC). |
b3d92f4a5f7b
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
2431
diff
changeset
|
3106 |
"/ dispObj isImageOrForm ifFalse:[ |
b3d92f4a5f7b
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
2431
diff
changeset
|
3107 |
"/ y := y + aGC font ascent |
b3d92f4a5f7b
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
2431
diff
changeset
|
3108 |
"/ ]. |
2283 | 3109 |
dispObj displayOn:aGC x:x y:y. |
2485
b3d92f4a5f7b
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
2431
diff
changeset
|
3110 |
^ self |
2283 | 3111 |
]. |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3112 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3113 |
top := layoutTop + inset. |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3114 |
hgt := layoutBottom - inset - top. |
2288 | 3115 |
hgt > 4 ifFalse:[^ self]. |
3116 |
||
3117 |
y := (hgt - extent x) // 2. |
|
3118 |
y < 0 ifTrue:[ |
|
3119 |
dispObj := '...'. |
|
3120 |
y := 0. |
|
3121 |
]. |
|
3122 |
y := y + top. |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3123 |
x := layoutLeft + (layout width - inset - extent y // 2). |
2288 | 3124 |
|
3125 |
aDirection == #left ifTrue:[ x := x + inset ]. |
|
2283 | 3126 |
|
3127 |
dispObj isImageOrForm ifFalse:[ |
|
3128 |
dispObj isString ifTrue:[ |
|
3129 |
x := x + aGC font descent. |
|
1683 | 3130 |
]. |
2283 | 3131 |
"/ workaround for a bug in display-with-angle, |
3132 |
"/ iff displayed string is a labelAndIcon. |
|
3133 |
"/ (In this case, display is always opaque, and the current |
|
3134 |
"/ backgroundPaint color is used to fill the underlying rectangle) |
|
3135 |
"/ |
|
3136 |
aGC backgroundPaint:aGC backgroundColor. |
|
3137 |
aGC displayString:dispObj x:x y:y angle:90. |
|
3138 |
] ifTrue:[ |
|
3139 |
(dispObj rotated:90) displayOn:aGC x:x y:y. |
|
3140 |
]. |
|
375 | 3141 |
! ! |
3142 |
||
1677 | 3143 |
!NoteBookView::Tab methodsFor:'private'! |
3144 |
||
2629 | 3145 |
resolveDisplayStringFor:aString on:aNoteBook |
1677 | 3146 |
|string size rest pos idx| |
3147 |
||
2629 | 3148 |
accessCharacter := nil. |
3149 |
string := aNoteBook translateToDisplayLabel:aString. |
|
3150 |
size := string size. |
|
1677 | 3151 |
pos := 0. |
3152 |
||
2629 | 3153 |
size == 0 ifTrue:[ ^ string ]. |
3154 |
||
3155 |
(model notNil and:[(pos := model accessCharacterPosition) ~~ 0]) ifTrue:[ |
|
3156 |
pos > size ifTrue:[pos := 0] |
|
3157 |
] ifFalse:[ |
|
3158 |
idx := 1. |
|
3159 |
||
3160 |
[((idx := string indexOf:$& startingAt:idx) ~~ 0 and:[idx < size])] whileTrue:[ |
|
3161 |
rest := string copyFrom:(idx+1). |
|
3162 |
||
3163 |
idx == 1 ifTrue:[string := rest] |
|
3164 |
ifFalse:[string := (string copyFrom:1 to:(idx-1)), rest]. |
|
3165 |
||
3166 |
(string at:idx) == $& ifTrue:[idx := idx + 1] |
|
3167 |
ifFalse:[pos := idx]. |
|
3168 |
size := size - 1. |
|
1677 | 3169 |
] |
3170 |
]. |
|
2629 | 3171 |
|
1677 | 3172 |
size ~~ 0 ifTrue:[ |
3173 |
pos == 0 ifTrue:[ |
|
3174 |
pos := 1 |
|
3175 |
] ifFalse:[ |
|
3176 |
string isText ifFalse:[ |
|
3177 |
string := Text string:string |
|
3178 |
]. |
|
3179 |
string emphasisAt:pos add:#underline |
|
3180 |
]. |
|
3181 |
accessCharacter := (string at:pos) asLowercase |
|
3182 |
]. |
|
3183 |
^ string |
|
3184 |
! ! |
|
3185 |
||
1401 | 3186 |
!NoteBookView::Tab methodsFor:'testing'! |
375 | 3187 |
|
1401 | 3188 |
containsPointX:x y:y |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3189 |
"return true, if the point defined by x@y is contained in the tab." |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3190 |
|
2279 | 3191 |
layout isNil ifTrue:[^ false]. |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3192 |
^ layout containsPointX:x y:y |
375 | 3193 |
! |
3194 |
||
1401 | 3195 |
intersects:aRectangle |
3196 |
"return true, if the intersection between the argument, aRectangle |
|
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3197 |
and the tab is not empty" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3198 |
|
2279 | 3199 |
layout isNil ifTrue:[^ false]. |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3200 |
^ layout intersects:aRectangle |
1401 | 3201 |
! |
432 | 3202 |
|
1401 | 3203 |
isEnabled |
2887
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3204 |
"returne true if no model exists or the model is enabled" |
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3205 |
|
feaa44edde35
code cleanup to avoid side effects in layouts.
Claus Gittinger <cg@exept.de>
parents:
2883
diff
changeset
|
3206 |
^ (model isNil or:[ model isEnabled ]) |
386 | 3207 |
! ! |
3208 |
||
355 | 3209 |
!NoteBookView class methodsFor:'documentation'! |
3210 |
||
3211 |
version |
|
2894 | 3212 |
^ '$Header: /cvs/stx/stx/libwidg2/NoteBookView.st,v 1.112 2006-01-24 17:56:28 cg Exp $' |
355 | 3213 |
! ! |