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