author | ca |
Mon, 14 Oct 2002 09:01:38 +0200 | |
changeset 2288 | 43db53a74240 |
parent 2287 | c9337aecb335 |
child 2289 | d09c42411c8d |
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 |
17 |
instanceVariableNames:'list listHolder foregroundColor selection enabled action useIndex |
|
2280 | 18 |
direction numberOfLines selectConditionBlock accessTabMenuAction |
19 |
canvas canvasInset canvasHolder halfLightColor halfShadowColor |
|
20 |
fitLastRow tabModus lastComputedExtent keepCanvas |
|
2287 | 21 |
activeForegroundColor drawLightColor edgeStyle |
22 |
disabledForegroundColor tabLevel tabTopMargin tabBottomMargin |
|
23 |
selectionInsetX selectionInsetY' |
|
1682 | 24 |
classVariableNames:'DefaultForegroundColor DefaultActiveForegroundColor |
25 |
DefaultShadowColor DefaultHalfShadowColor DefaultLightColor |
|
1700 | 26 |
DefaultHalfLightColor DefaultEdgeStyle DisabledForegroundColor' |
1401 | 27 |
poolDictionaries:'' |
28 |
category:'Views-Layout' |
|
29 |
! |
|
30 |
||
31 |
Object subclass:#Tab |
|
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
32 |
instanceVariableNames:'label model printableLabel disabledLabel lineNr layout extent |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
33 |
accessCharacter' |
1401 | 34 |
classVariableNames:'' |
35 |
poolDictionaries:'' |
|
36 |
privateIn:NoteBookView |
|
37 |
! |
|
38 |
||
39 |
!NoteBookView class methodsFor:'documentation'! |
|
40 |
||
41 |
copyright |
|
42 |
" |
|
43 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
44 |
All Rights Reserved |
|
375 | 45 |
|
46 |
This software is furnished under a license and may be used |
|
47 |
only in accordance with the terms of that license and with the |
|
48 |
inclusion of the above copyright notice. This software may not |
|
49 |
be provided or otherwise made available to, or used by, any |
|
50 |
other person. No title to or ownership of the software is |
|
51 |
hereby transferred. |
|
52 |
" |
|
53 |
||
355 | 54 |
! |
55 |
||
56 |
documentation |
|
57 |
" |
|
1401 | 58 |
implements the noteBook. |
59 |
May also be used on its own (without a surrounding noteBook). |
|
60 |
||
61 |
[author:] |
|
62 |
Claus Atzkern |
|
408 | 63 |
|
64 |
[see also:] |
|
65 |
TabView |
|
355 | 66 |
" |
1401 | 67 |
|
408 | 68 |
! |
355 | 69 |
|
408 | 70 |
examples |
71 |
" |
|
72 |
tabs at top ( default ) |
|
73 |
[exBegin] |
|
1401 | 74 |
|top tab| |
375 | 75 |
|
1401 | 76 |
top := StandardSystemView extent:250@100. |
1683 | 77 |
tab := NoteBookView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top. |
1401 | 78 |
tab list:#( 'Foo' 'Bar' 'Baz' ). |
79 |
tab action:[:aName| Transcript showCR:aName]. |
|
408 | 80 |
top open. |
81 |
[exEnd] |
|
82 |
||
83 |
||
84 |
tabs at bottom |
|
85 |
[exBegin] |
|
1401 | 86 |
|top tab| |
375 | 87 |
|
1401 | 88 |
top := StandardSystemView extent:250@100. |
1683 | 89 |
tab := NoteBookView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top. |
1401 | 90 |
tab direction:#bottom. |
91 |
tab list:#( 'Foo' 'Bar' 'Baz' ). |
|
92 |
tab action:[:aName| Transcript showCR:aName]. |
|
375 | 93 |
top open. |
408 | 94 |
[exEnd] |
375 | 95 |
|
408 | 96 |
tabs at left |
97 |
[exBegin] |
|
1401 | 98 |
|top tab| |
375 | 99 |
|
1401 | 100 |
top := StandardSystemView extent:100@200. |
1683 | 101 |
tab := NoteBookView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top. |
1401 | 102 |
tab direction:#left. |
103 |
tab list:#( 'Foo' 'Bar' 'Baz' ). |
|
104 |
tab action:[:aName| Transcript showCR:aName]. |
|
408 | 105 |
top open. |
106 |
[exEnd] |
|
375 | 107 |
|
408 | 108 |
tabs at right |
109 |
[exBegin] |
|
1401 | 110 |
|top tab| |
375 | 111 |
|
1401 | 112 |
top := StandardSystemView extent:100@200. |
1683 | 113 |
tab := NoteBookView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top. |
1401 | 114 |
tab direction:#right. |
115 |
tab list:#( 'Foo' 'Bar' 'Baz' ). |
|
116 |
tab action:[:aName| Transcript showCR:aName]. |
|
375 | 117 |
top open. |
408 | 118 |
[exEnd] |
375 | 119 |
|
120 |
||
408 | 121 |
" |
1401 | 122 |
! ! |
123 |
||
124 |
!NoteBookView class methodsFor:'defaults'! |
|
125 |
||
126 |
defaultFont |
|
127 |
^ MenuView defaultFont |
|
1682 | 128 |
! |
129 |
||
130 |
updateStyleCache |
|
131 |
" |
|
132 |
self updateStyleCache |
|
133 |
" |
|
134 |
DefaultForegroundColor := StyleSheet colorAt:#'noteBook.foregroundColor'. |
|
135 |
DefaultForegroundColor isNil ifTrue:[ |
|
136 |
DefaultForegroundColor := StyleSheet colorAt:#'button.foregroundColor'. |
|
137 |
]. |
|
138 |
||
139 |
DefaultActiveForegroundColor := StyleSheet colorAt:#'noteBook.activeForegroundColor'. |
|
140 |
DefaultActiveForegroundColor isNil ifTrue:[ |
|
141 |
DefaultActiveForegroundColor := StyleSheet colorAt:#'button.activeForegroundColor' |
|
142 |
]. |
|
143 |
||
144 |
DefaultLightColor := StyleSheet colorAt:#'noteBook.lightColor'. |
|
145 |
DefaultLightColor isNil ifTrue:[ |
|
146 |
DefaultLightColor := StyleSheet colorAt:'button.lightColor' |
|
147 |
]. |
|
148 |
DefaultHalfLightColor := StyleSheet colorAt:#'noteBook.halfLightColor'. |
|
149 |
DefaultHalfLightColor isNil ifTrue:[ |
|
150 |
DefaultHalfLightColor := StyleSheet colorAt:#'button.halfLightColor' |
|
151 |
]. |
|
152 |
||
153 |
DefaultShadowColor := StyleSheet colorAt:#'noteBook.shadowColor'. |
|
154 |
DefaultShadowColor isNil ifTrue:[ |
|
155 |
DefaultShadowColor := StyleSheet colorAt:'button.shadowColor' |
|
156 |
]. |
|
157 |
DefaultHalfShadowColor := StyleSheet colorAt:#'noteBook.halfShadowColor'. |
|
158 |
DefaultHalfShadowColor isNil ifTrue:[ |
|
159 |
DefaultHalfShadowColor := StyleSheet colorAt:#'button.halfShadowColor' |
|
160 |
]. |
|
161 |
DefaultEdgeStyle := StyleSheet at:#'noteBook.edgeStyle'. |
|
162 |
DefaultEdgeStyle isNil ifTrue:[ |
|
163 |
DefaultEdgeStyle := StyleSheet at:#'button.edgeStyle' |
|
164 |
]. |
|
165 |
||
1683 | 166 |
DefaultEdgeStyle == #softWin95 ifFalse:[ |
1682 | 167 |
DefaultEdgeStyle := nil |
168 |
]. |
|
169 |
||
375 | 170 |
! ! |
171 |
||
1724
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
172 |
!NoteBookView methodsFor:'accepting - items'! |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
173 |
|
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
174 |
tabAtIndex:tabIndex put:newLabel |
1880 | 175 |
|tab layout prefX prefY| |
1724
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
176 |
|
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
177 |
"/ 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
|
178 |
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
|
179 |
tab notNil ifTrue:[ |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
180 |
tab label:newLabel on:self. |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
181 |
|
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
182 |
"/ 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
|
183 |
"/ and is not too small for current tab-layout |
1880 | 184 |
layout := tab layout. |
185 |
||
186 |
( (prefX := tab preferredExtentX) <= layout width |
|
187 |
and:[(prefY := tab preferredExtentY) <= layout height] |
|
188 |
) ifTrue:[ |
|
189 |
"/ the new string fits into current tab-layout |
|
190 |
||
191 |
numberOfLines == 1 ifTrue:[ "/ do not change the layout |
|
192 |
^ self invalidateTab:tab |
|
193 |
]. |
|
194 |
||
195 |
"/ check whether the string is not too small for current tab-layout |
|
196 |
((layout width <= (prefX * 1.5)) and:[layout height <= (prefY * 1.5)]) ifTrue:[ |
|
197 |
^ 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
|
198 |
]. |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
199 |
]. |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
200 |
self recomputeList. |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
201 |
self invalidate. |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
202 |
^ self. |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
203 |
]. |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
204 |
"/ can this happen ? |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
205 |
|
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
206 |
"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
|
207 |
! ! |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
208 |
|
375 | 209 |
!NoteBookView methodsFor:'accessing'! |
355 | 210 |
|
375 | 211 |
canvas |
212 |
^ canvas |
|
213 |
! |
|
214 |
||
215 |
canvas:aCanvas |
|
2010 | 216 |
"change the canvas; the containter view |
375 | 217 |
" |
1401 | 218 |
aCanvas == canvas ifFalse:[ |
219 |
canvas notNil ifTrue:[ |
|
1759 | 220 |
(keepCanvas or:[(canvas objectAttributeAt:#isTabItem) == true]) ifTrue:[ |
1413 | 221 |
canvas unmap. |
222 |
] ifFalse:[ |
|
223 |
canvas destroy. |
|
224 |
]. |
|
1401 | 225 |
]. |
226 |
(canvas := aCanvas) notNil ifTrue:[ |
|
227 |
tabModus := false. |
|
2035
6cc4d73f17e1
bug fix when chaning the canvas before being realized
Claus Gittinger <cg@exept.de>
parents:
2010
diff
changeset
|
228 |
|
1680 | 229 |
self resizeCanvas. |
230 |
||
1759 | 231 |
(subViews size == 0 or:[(subViews includesIdentical:canvas) not]) ifTrue:[ |
232 |
self addSubView:canvas |
|
1549 | 233 |
]. |
1759 | 234 |
|
1687 | 235 |
realized ifTrue:[ |
1892 | 236 |
(keepCanvas or:[(canvas objectAttributeAt:#isTabItem) == true]) ifTrue:[ |
237 |
canvas id isNil ifTrue:[ |
|
238 |
canvas realize |
|
239 |
] ifFalse:[ |
|
240 |
canvas map. |
|
241 |
] |
|
242 |
] ifFalse:[ |
|
243 |
canvas realize. |
|
244 |
]. |
|
2036 | 245 |
canvas raise. |
1687 | 246 |
]. |
1401 | 247 |
] |
248 |
]. |
|
249 |
! |
|
250 |
||
251 |
list |
|
252 |
"return the list of Tabs or Labels |
|
253 |
" |
|
254 |
^ list collect:[:aTab| aTab label ] |
|
255 |
||
256 |
! |
|
375 | 257 |
|
1401 | 258 |
list:aList |
259 |
"set the list |
|
260 |
" |
|
2278 | 261 |
|name newList| |
1401 | 262 |
|
1771 | 263 |
name := self selection. |
264 |
newList := OrderedCollection new. |
|
1401 | 265 |
|
1771 | 266 |
aList size == 0 ifTrue:[ |
267 |
list do:[:aTab| aTab removeDependent:self]. |
|
1401 | 268 |
] ifFalse:[ |
1771 | 269 |
list do:[:aTab| |m| |
270 |
( (m := aTab model) notNil |
|
271 |
and:[(aList includesIdentical:m)] |
|
272 |
) ifFalse:[ |
|
273 |
aTab removeDependent:self |
|
274 |
] |
|
275 |
]. |
|
276 |
||
277 |
aList do:[:el| |i tab| |
|
278 |
( el isNil |
|
279 |
or:[(tab := list detect:[:t| t model == el] ifNone:nil) isNil] |
|
280 |
) ifTrue:[ |
|
281 |
tab := Tab label:el on:self. |
|
282 |
tab addDependent:self. |
|
283 |
]. |
|
284 |
newList add:tab |
|
285 |
] |
|
1401 | 286 |
]. |
1771 | 287 |
|
288 |
list := newList. |
|
1401 | 289 |
preferredExtent := nil. |
290 |
numberOfLines := nil. |
|
291 |
||
292 |
selection notNil ifTrue:[ |
|
1433 | 293 |
useIndex ifTrue:[ |
294 |
selection > list size ifTrue:[ |
|
295 |
selection := nil. |
|
296 |
self selectionChanged. |
|
297 |
] |
|
298 |
] ifFalse:[ |
|
299 |
selection := list findFirst:[:el| el label = name ]. |
|
300 |
selection == 0 ifTrue:[ |
|
301 |
selection := nil. |
|
302 |
self selectionChanged. |
|
303 |
] |
|
1401 | 304 |
] |
305 |
]. |
|
1680 | 306 |
self recomputeList. |
307 |
self invalidate. |
|
1401 | 308 |
! |
375 | 309 |
|
1401 | 310 |
listIndexOf:something |
311 |
"convert something to an index into list or nil. |
|
312 |
" |
|
313 |
|index| |
|
314 |
||
315 |
something isNil ifTrue:[^ nil ]. |
|
316 |
||
317 |
something isNumber ifTrue:[ |
|
318 |
index := something |
|
319 |
] ifFalse:[ |
|
320 |
index := list findFirst:[:aTab|aTab label = something]. |
|
321 |
index == 0 ifTrue:[ |
|
322 |
index := list findFirst:[:aTab|aTab printableLabel = something] |
|
323 |
] |
|
324 |
]. |
|
325 |
^ (index between:1 and:list size) ifTrue:[index] ifFalse:[nil] |
|
326 |
||
327 |
||
328 |
! |
|
329 |
||
330 |
useIndex |
|
331 |
"use index instead of name |
|
332 |
" |
|
333 |
^ useIndex |
|
334 |
||
335 |
||
336 |
! |
|
337 |
||
338 |
useIndex:aBoolean |
|
339 |
"set/clear the useIndex flag. If set, both actionBlock and change-messages |
|
340 |
are passed the index(indices) of the selection as argument. |
|
341 |
If clear, the value(s) (i.e. the selected string) is passed. |
|
342 |
Default is false." |
|
343 |
||
344 |
useIndex := aBoolean |
|
345 |
||
346 |
||
347 |
! ! |
|
348 |
||
1818 | 349 |
!NoteBookView methodsFor:'accessing-actions'! |
1802 | 350 |
|
351 |
accessTabMenuAction |
|
352 |
"callback to retrieve the menu for a specific tab. |
|
353 |
the argument to the block is the index of the tab |
|
354 |
" |
|
355 |
^ accessTabMenuAction |
|
356 |
! |
|
357 |
||
358 |
accessTabMenuAction:aOneArgAction |
|
359 |
"callback to retrieve the menu for a specific tab. |
|
360 |
the argument to the block is the index of the tab |
|
361 |
" |
|
362 |
accessTabMenuAction := aOneArgAction. |
|
363 |
! |
|
364 |
||
365 |
action |
|
366 |
"get the action block to be performed on select; the argument to |
|
367 |
the block is the selected index or nil in case of no selection. |
|
368 |
" |
|
369 |
^ action |
|
370 |
! |
|
371 |
||
372 |
action:oneArgBlock |
|
373 |
"set the action block to be performed on select; the argument to |
|
374 |
the block is the selected index or nil in case of no selection. |
|
375 |
" |
|
376 |
action := oneArgBlock. |
|
377 |
||
378 |
! ! |
|
379 |
||
1818 | 380 |
!NoteBookView methodsFor:'accessing-behavior'! |
1401 | 381 |
|
382 |
enabled |
|
383 |
"returns true if tabs are enabled |
|
384 |
" |
|
385 |
^ enabled |
|
386 |
! |
|
387 |
||
388 |
enabled:aState |
|
389 |
"set enabled state |
|
390 |
" |
|
391 |
|state| |
|
392 |
||
393 |
state := aState ? true. |
|
394 |
||
395 |
enabled ~~ state ifTrue:[ |
|
396 |
enabled := state. |
|
397 |
self invalidate. |
|
375 | 398 |
] |
399 |
! |
|
400 |
||
1413 | 401 |
keepCanvas:aBoolean |
402 |
"if false (the default), the previous canvas is destroyed, whenever |
|
403 |
a new canvas is set. |
|
404 |
if true, it is unmapped and kept. |
|
405 |
Set this flag, if the application changes the canvas but wants |
|
406 |
them to be kept for fast switching." |
|
407 |
||
408 |
keepCanvas := aBoolean. |
|
409 |
! |
|
410 |
||
1401 | 411 |
selectConditionBlock |
412 |
"get the conditionBlock; this block is evaluated before a selection |
|
413 |
change is performed; the change will not be done, if the evaluation |
|
414 |
returns false. The argument to the block is the selection index |
|
415 |
" |
|
416 |
^ selectConditionBlock |
|
432 | 417 |
! |
418 |
||
1401 | 419 |
selectConditionBlock:aOneArgBlock |
420 |
"get the conditionBlock; this block is evaluated before a selection |
|
421 |
change is performed; the change will not be done, if the evaluation |
|
422 |
returns false. The argument to the block is the selection index |
|
423 |
" |
|
424 |
selectConditionBlock := aOneArgBlock |
|
432 | 425 |
! ! |
426 |
||
1818 | 427 |
!NoteBookView methodsFor:'accessing-channels/holders'! |
432 | 428 |
|
375 | 429 |
canvasHolder |
1401 | 430 |
"get the model, which keeps the canvas, a kind of SimpleView |
431 |
" |
|
375 | 432 |
^ canvasHolder |
355 | 433 |
! |
434 |
||
375 | 435 |
canvasHolder:aValueHolder |
1401 | 436 |
"set the model, which keeps the canvas, a kind of SimpleView |
437 |
" |
|
438 |
canvasHolder removeDependent:self. |
|
439 |
||
440 |
(canvasHolder := aValueHolder) notNil ifTrue:[ |
|
441 |
canvasHolder addDependent:self. |
|
442 |
self canvas:(canvasHolder value) |
|
443 |
] |
|
444 |
||
445 |
||
446 |
! |
|
447 |
||
448 |
listHolder |
|
449 |
"get the model, which keeps the list of Tabs or Labels |
|
450 |
" |
|
451 |
^ listHolder |
|
452 |
! |
|
453 |
||
454 |
listHolder:aValueHolder |
|
455 |
"set the model, which keeps the list of Tabs or Labels |
|
456 |
" |
|
457 |
listHolder removeDependent:self. |
|
458 |
||
459 |
(listHolder := aValueHolder) notNil ifTrue:[ |
|
460 |
listHolder addDependent:self. |
|
461 |
self list:listHolder value. |
|
375 | 462 |
]. |
432 | 463 |
! |
464 |
||
1401 | 465 |
model:aValueHolder |
466 |
"set the model, which keeps the selection |
|
467 |
" |
|
468 |
super model:aValueHolder. |
|
469 |
||
470 |
model notNil ifTrue:[ |
|
471 |
self selection:(model value) |
|
472 |
] |
|
473 |
! ! |
|
474 |
||
2279 | 475 |
!NoteBookView methodsFor:'accessing-colors'! |
419 | 476 |
|
1442 | 477 |
activeForegroundColor |
478 |
"get the color to be used for drawing text |
|
479 |
" |
|
480 |
^ activeForegroundColor |
|
481 |
! |
|
482 |
||
1401 | 483 |
backgroundColor |
484 |
"get backgroundColor of the notebook view |
|
419 | 485 |
" |
1401 | 486 |
^ viewBackground |
408 | 487 |
! |
488 |
||
1700 | 489 |
disabledForegroundColor |
490 |
^ disabledForegroundColor |
|
491 |
! |
|
492 |
||
1682 | 493 |
drawLightColor |
494 |
"get the color to be used for lighted edges; bug fix caused by common |
|
495 |
drawEdge |
|
496 |
" |
|
497 |
^ drawLightColor |
|
498 |
! |
|
499 |
||
1401 | 500 |
foregroundColor |
501 |
"get the color to be used for drawing text |
|
419 | 502 |
" |
1401 | 503 |
^ foregroundColor |
504 |
! |
|
505 |
||
506 |
foregroundColor:aColor |
|
507 |
"set the color to be used for drawing text |
|
508 |
" |
|
509 |
aColor ~= foregroundColor ifTrue:[ |
|
510 |
foregroundColor := aColor. |
|
511 |
||
512 |
shown ifTrue:[ |
|
513 |
self invalidate |
|
514 |
] |
|
515 |
] |
|
408 | 516 |
|
419 | 517 |
! |
518 |
||
1401 | 519 |
halfLightColor |
520 |
"get the color to be used for drawing text |
|
419 | 521 |
" |
1401 | 522 |
^ halfLightColor |
523 |
! |
|
524 |
||
525 |
halfShadowColor |
|
526 |
^ halfShadowColor |
|
527 |
! |
|
528 |
||
1684 | 529 |
viewBackground:aColor |
530 |
"get backgroundColor of the notebook view |
|
531 |
" |
|
532 |
super viewBackground:aColor. |
|
533 |
||
534 |
(edgeStyle isNil and:[viewBackground isColor]) ifTrue:[ |
|
535 |
halfShadowColor := shadowColor. |
|
536 |
halfLightColor := lightColor. |
|
537 |
drawLightColor := lightColor. |
|
538 |
]. |
|
1689
ecb51abe4a6b
preps to allow for tabColor and activeTabColor to be
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
539 |
|
ecb51abe4a6b
preps to allow for tabColor and activeTabColor to be
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
540 |
DefaultShadowColor isNil ifTrue:[ |
ecb51abe4a6b
preps to allow for tabColor and activeTabColor to be
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
541 |
shadowColor := aColor darkened onDevice:device |
ecb51abe4a6b
preps to allow for tabColor and activeTabColor to be
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
542 |
]. |
ecb51abe4a6b
preps to allow for tabColor and activeTabColor to be
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
543 |
DefaultLightColor isNil ifTrue:[ |
ecb51abe4a6b
preps to allow for tabColor and activeTabColor to be
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
544 |
lightColor := aColor lightened onDevice:device |
ecb51abe4a6b
preps to allow for tabColor and activeTabColor to be
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
545 |
]. |
375 | 546 |
! ! |
547 |
||
2279 | 548 |
!NoteBookView methodsFor:'accessing-dimension'! |
549 |
||
2280 | 550 |
preferredExtent |
551 |
"compute max extent x/y based on one line |
|
552 |
" |
|
2284 | 553 |
|level size x y isHorizontal insetX insetY extent| |
2280 | 554 |
|
555 |
preferredExtent notNil ifTrue:[ ^ preferredExtent ]. |
|
556 |
||
557 |
x := y := 0. |
|
558 |
level := (tabLevel abs) max:1. |
|
559 |
size := list size. |
|
560 |
||
561 |
size ~~ 0 ifTrue:[ |
|
562 |
list do:[:aTab| |
|
563 |
x := x + (aTab preferredExtentX). |
|
564 |
y := y max:(aTab preferredExtentY). |
|
565 |
]. |
|
566 |
]. |
|
567 |
y := y + selectionInsetY + level + tabTopMargin + tabBottomMargin. |
|
568 |
x := x + selectionInsetX + selectionInsetX + (level + level * size). |
|
569 |
||
2284 | 570 |
isHorizontal := self isHorizontal. |
571 |
||
572 |
tabModus ifFalse:[ |
|
573 |
canvasInset isPoint ifTrue:[ |
|
574 |
insetX := canvasInset x. |
|
575 |
insetY := canvasInset y. |
|
576 |
] ifFalse:[ |
|
577 |
insetX := insetY := canvasInset. |
|
578 |
]. |
|
579 |
canvas notNil ifTrue:[ extent := canvas preferredExtent ] |
|
580 |
ifFalse:[ extent := 100@100 ]. |
|
581 |
||
582 |
y := y + insetY + insetY + extent y. |
|
583 |
x := x max:extent x. |
|
584 |
x := x + insetX + insetX + level + level. |
|
585 |
]. |
|
586 |
||
587 |
isHorizontal ifTrue:[ ^ x @ y ]. |
|
588 |
^ y @ x |
|
2279 | 589 |
! ! |
590 |
||
1818 | 591 |
!NoteBookView methodsFor:'accessing-style'! |
1401 | 592 |
|
2279 | 593 |
canvasInset |
594 |
"inset of the canvas relative to my frame |
|
595 |
tabLevel + canvasInset == origin of canvas |
|
596 |
" |
|
597 |
^ canvasInset |
|
598 |
! |
|
599 |
||
600 |
canvasInset:anInset |
|
601 |
"inset of the canvas relative to my frame |
|
602 |
tabLevel + canvasInset == origin of canvas |
|
603 |
" |
|
604 |
anInset ~~ canvasInset ifTrue:[ |
|
605 |
canvasInset := anInset. |
|
2282 | 606 |
self styleChanged. |
2279 | 607 |
]. |
608 |
! |
|
609 |
||
1401 | 610 |
direction |
611 |
"returns the direction of tabs as symbol. On default the value is |
|
612 |
set to #top. Valid symbols are: |
|
613 |
#top arrange tabs to be on top of a view |
|
614 |
#bottom arrange tabs to be on bottom of a view |
|
615 |
#left arrange tabs to be on left of a view |
|
616 |
#right arrange tabs to be on right of a view |
|
617 |
" |
|
618 |
^ direction |
|
619 |
||
620 |
! |
|
621 |
||
622 |
direction:aDirection |
|
623 |
"change the direction of tabs. On default the value is set to #top. |
|
624 |
Valid symbols are: |
|
625 |
#top arrange tabs to be on top of a view |
|
626 |
#bottom arrange tabs to be on bottom of a view |
|
627 |
#left arrange tabs to be on left of a view |
|
628 |
#right arrange tabs to be on right of a view |
|
629 |
" |
|
630 |
direction ~~ aDirection ifTrue:[ |
|
2282 | 631 |
direction := aDirection. |
632 |
self styleChanged. |
|
1401 | 633 |
]. |
634 |
! |
|
375 | 635 |
|
1401 | 636 |
fitLastRow |
637 |
"in case of true, the last row is expanded to the view size like all |
|
638 |
other raws. In case of false all the tabs in the last raw keep their |
|
639 |
preferred extent (x or y) dependant on the direction. |
|
640 |
" |
|
641 |
^ fitLastRow |
|
642 |
! |
|
643 |
||
644 |
fitLastRow:aBool |
|
645 |
"in case of true, the last row is expanded to the view size like all |
|
646 |
other raws. In case of false all the tabs in the last raw keep their |
|
647 |
preferred extent (x or y) dependant on the direction. |
|
375 | 648 |
" |
2282 | 649 |
|
650 |
fitLastRow ~~ aBool ifTrue:[ |
|
651 |
fitLastRow := aBool. |
|
652 |
self styleChanged. |
|
653 |
]. |
|
654 |
! |
|
655 |
||
656 |
tabBottomMargin |
|
657 |
"returns the margin between the tabs and the canvas |
|
658 |
" |
|
659 |
^ tabBottomMargin |
|
660 |
! |
|
661 |
||
662 |
tabBottomMargin:aMargin |
|
663 |
"set the margin between the tabs and the canvas |
|
664 |
" |
|
665 |
|margin| |
|
666 |
||
667 |
margin := aMargin max:0. |
|
668 |
||
669 |
margin ~~ tabBottomMargin ifTrue:[ |
|
670 |
tabBottomMargin := margin. |
|
671 |
self styleChanged. |
|
672 |
]. |
|
1401 | 673 |
! |
674 |
||
2279 | 675 |
tabLevel |
676 |
"the level of the tabs and noteBook frame |
|
677 |
" |
|
678 |
^ tabLevel |
|
1401 | 679 |
! |
375 | 680 |
|
2279 | 681 |
tabLevel:aLevel |
682 |
"the level of the tabs and noteBook frame |
|
683 |
" |
|
684 |
aLevel ~~ tabLevel ifTrue:[ |
|
685 |
tabLevel := aLevel. |
|
2282 | 686 |
self styleChanged. |
687 |
]. |
|
688 |
! |
|
689 |
||
690 |
tabTopMargin |
|
691 |
"returns the margin between the tabs and the widget |
|
692 |
" |
|
693 |
^ tabTopMargin |
|
694 |
! |
|
695 |
||
696 |
tabTopMargin:aMargin |
|
697 |
"set the margin between the tabs and the widget |
|
698 |
" |
|
699 |
|margin| |
|
700 |
||
701 |
margin := aMargin max:0. |
|
702 |
||
703 |
margin ~~ tabTopMargin ifTrue:[ |
|
704 |
tabTopMargin := margin. |
|
705 |
self styleChanged. |
|
2279 | 706 |
]. |
375 | 707 |
! ! |
708 |
||
709 |
!NoteBookView methodsFor:'change & update'! |
|
710 |
||
2282 | 711 |
styleChanged |
712 |
"called if the tab style changed |
|
713 |
list must be recomputed |
|
714 |
" |
|
715 |
preferredExtent := nil. |
|
716 |
||
717 |
numberOfLines isNil ifTrue:[ |
|
718 |
^ self. "/ layout not yet computed |
|
719 |
]. |
|
720 |
self recomputeList. |
|
721 |
||
722 |
shown ifTrue:[ |
|
723 |
self invalidate |
|
724 |
]. |
|
725 |
! |
|
726 |
||
1401 | 727 |
update:something with:aParameter from:changedObject |
728 |
"one of my models changed its value |
|
729 |
" |
|
730 |
|idx tab| |
|
731 |
||
732 |
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
|
733 |
changedObject == listHolder ifTrue:[ |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
734 |
something == #at: ifTrue:[ |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
735 |
"/ 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
|
736 |
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
|
737 |
^ self. |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
738 |
]. |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
739 |
^ self list:(listHolder value) |
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
740 |
]. |
1401 | 741 |
changedObject == enableChannel ifTrue:[^ self enabled:enableChannel value]. |
1413 | 742 |
changedObject == canvasHolder ifTrue:[^ self canvas:canvasHolder value]. |
1401 | 743 |
|
744 |
(idx := list findFirst:[:aTab| aTab label == changedObject]) ~~ 0 ifTrue:[ |
|
745 |
tab := list at:idx. |
|
746 |
||
747 |
idx == selection ifTrue:[ |
|
748 |
tab isEnabled ifFalse:[ |
|
749 |
^ self selection:nil |
|
750 |
] |
|
751 |
]. |
|
752 |
tab label:(tab label) on:self. |
|
753 |
self invalidateTab:tab |
|
754 |
] |
|
1724
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
755 |
|
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
756 |
"Modified: / 25.2.2000 / 14:14:29 / cg" |
1401 | 757 |
! ! |
758 |
||
1700 | 759 |
!NoteBookView methodsFor:'defaults'! |
760 |
||
761 |
updateStyleCache |
|
762 |
" |
|
763 |
self updateStyleCache |
|
764 |
" |
|
765 |
DefaultForegroundColor := StyleSheet colorAt:#'noteBook.foregroundColor'. |
|
766 |
DefaultForegroundColor isNil ifTrue:[ |
|
767 |
DefaultForegroundColor := StyleSheet colorAt:#'button.foregroundColor'. |
|
768 |
]. |
|
769 |
||
770 |
DefaultActiveForegroundColor := StyleSheet colorAt:#'noteBook.activeForegroundColor'. |
|
771 |
DefaultActiveForegroundColor isNil ifTrue:[ |
|
772 |
DefaultActiveForegroundColor := StyleSheet colorAt:#'button.activeForegroundColor' |
|
773 |
]. |
|
774 |
||
775 |
DefaultLightColor := StyleSheet colorAt:#'noteBook.lightColor'. |
|
776 |
DefaultLightColor isNil ifTrue:[ |
|
777 |
DefaultLightColor := StyleSheet colorAt:'button.lightColor' |
|
778 |
]. |
|
779 |
DefaultHalfLightColor := StyleSheet colorAt:#'noteBook.halfLightColor'. |
|
780 |
DefaultHalfLightColor isNil ifTrue:[ |
|
781 |
DefaultHalfLightColor := StyleSheet colorAt:#'button.halfLightColor' |
|
782 |
]. |
|
783 |
||
784 |
DefaultShadowColor := StyleSheet colorAt:#'noteBook.shadowColor'. |
|
785 |
DefaultShadowColor isNil ifTrue:[ |
|
786 |
DefaultShadowColor := StyleSheet colorAt:'button.shadowColor' |
|
787 |
]. |
|
788 |
DefaultHalfShadowColor := StyleSheet colorAt:#'noteBook.halfShadowColor'. |
|
789 |
DefaultHalfShadowColor isNil ifTrue:[ |
|
790 |
DefaultHalfShadowColor := StyleSheet colorAt:#'button.halfShadowColor' |
|
791 |
]. |
|
792 |
DefaultEdgeStyle := StyleSheet at:#'noteBook.edgeStyle'. |
|
793 |
DefaultEdgeStyle isNil ifTrue:[ |
|
794 |
DefaultEdgeStyle := StyleSheet at:#'button.edgeStyle' |
|
795 |
]. |
|
796 |
||
797 |
DisabledForegroundColor := StyleSheet at:#'noteBook.disabledForegroundColor'. |
|
798 |
||
799 |
DefaultEdgeStyle == #softWin95 ifFalse:[ |
|
800 |
DefaultEdgeStyle := nil |
|
801 |
]. |
|
802 |
||
803 |
||
804 |
||
805 |
! ! |
|
806 |
||
1401 | 807 |
!NoteBookView methodsFor:'drawing'! |
808 |
||
2283 | 809 |
drawBorderEdges |
810 |
|layout x0 x1 y0 y1| |
|
811 |
||
812 |
"/ test whether TabView and not NoteBookView |
|
813 |
tabModus ifTrue:[^ self]. |
|
814 |
||
815 |
layout := self computeBorderLayout. |
|
816 |
||
817 |
tabLevel ~~ 0 ifTrue:[ |
|
818 |
self drawEdgesForX:(layout left) |
|
819 |
y:(layout top) |
|
820 |
width:(layout width) |
|
821 |
height:(layout height) |
|
822 |
level:tabLevel. |
|
823 |
^ self |
|
824 |
]. |
|
825 |
list size > 1 ifFalse:[^ self]. |
|
826 |
||
827 |
self paint:lightColor ? lightColor. |
|
828 |
||
829 |
(direction == #top or:[direction == #bottom]) ifTrue:[ |
|
830 |
direction == #top ifTrue:[ y0 := layout top - 1 ] |
|
2284 | 831 |
ifFalse:[ y0 := layout bottom ]. |
2283 | 832 |
y1 := y0. |
833 |
x0 := 0. |
|
834 |
x1 := width. |
|
835 |
] ifFalse:[ |
|
836 |
direction == #left ifTrue:[ x0 := layout left - 1 ] |
|
837 |
ifFalse:[ x0 := layout right ]. |
|
838 |
y0 := 0. |
|
839 |
y1 := height. |
|
840 |
x1 := x0. |
|
841 |
]. |
|
842 |
self displayLineFromX:x0 y:y0 toX:x1 y:y1. |
|
843 |
! |
|
844 |
||
2278 | 845 |
drawTabEdgesFor:aTab |
2280 | 846 |
|layout count leftFg leftHalfFg rightFg x0 x1 y0 y1 isSelected |
2278 | 847 |
yT "{ Class:SmallInteger }" |
848 |
xL "{ Class:SmallInteger }" |
|
849 |
xR "{ Class:SmallInteger }" |
|
850 |
yB "{ Class:SmallInteger }" |
|
851 |
| |
|
2280 | 852 |
count := tabLevel. |
853 |
isSelected := (self selectedTab == aTab). |
|
2278 | 854 |
|
2283 | 855 |
count <= 0 ifTrue:[ |
2280 | 856 |
isSelected ifFalse:[ ^ self ]. |
857 |
||
2283 | 858 |
count == 0 ifTrue:[ |
859 |
list size > 1 ifFalse:[^ self]. |
|
860 |
count := 1 |
|
861 |
] ifFalse:[ |
|
862 |
count := count negated |
|
863 |
]. |
|
864 |
||
2278 | 865 |
rightFg := lightColor. |
866 |
leftFg := shadowColor. |
|
867 |
leftHalfFg := halfShadowColor. |
|
868 |
] ifFalse:[ |
|
2280 | 869 |
|
2278 | 870 |
((edgeStyle == #soft) and:[tabLevel > 1]) ifTrue:[ rightFg := halfShadowColor ] |
2280 | 871 |
ifFalse:[ rightFg := shadowColor ]. |
2278 | 872 |
leftFg := lightColor. |
873 |
leftHalfFg := halfLightColor. |
|
874 |
]. |
|
875 |
||
876 |
(leftHalfFg notNil and:[edgeStyle == #soft and:[tabLevel > 0]]) ifTrue:[ |
|
877 |
leftFg := leftHalfFg |
|
878 |
]. |
|
879 |
||
880 |
layout := aTab layout. |
|
881 |
xL := layout left. |
|
882 |
yT := layout top. |
|
883 |
xR := layout right - 1. |
|
884 |
yB := layout bottom - 1. |
|
885 |
||
886 |
x0 := xL + count. |
|
887 |
x1 := xR - count. |
|
888 |
y0 := yT + count. |
|
889 |
y1 := yB - count. |
|
890 |
||
891 |
direction == #top ifTrue:[ |
|
892 |
self paint:rightFg. |
|
893 |
||
894 |
0 to:count - 1 do:[:i| "/ vertical: right |
|
895 |
self displayLineFromX:xR - i y:yB toX:xR - i y:y0 - i. |
|
896 |
]. |
|
897 |
||
898 |
self paint:leftFg. |
|
899 |
||
900 |
0 to:count - 1 do:[:i| "/ horizontal: left |
|
901 |
self displayLineFromX:xL + i y:y0 - i toX:xL + i y:yB. |
|
902 |
]. |
|
903 |
||
904 |
0 to:count - 1 do:[:i| "/ horizontal: top |
|
905 |
self displayLineFromX:x0 - i y:yT + i toX:x1 y:yT + i. |
|
906 |
]. |
|
2280 | 907 |
(isSelected and:[count > 1]) ifFalse:[^ self]. |
908 |
(self isLastTabInLine:aTab) ifTrue:[^ self]. |
|
2278 | 909 |
|
910 |
y0 := yB + 1. |
|
911 |
x1 := x1 + 1. |
|
912 |
||
913 |
1 to:count - 1 do:[:i| "/ horizontal line |
|
914 |
self displayLineFromX:x1 + i y:y0 - i toX:xR y:y0 - i. |
|
915 |
]. |
|
916 |
^ self |
|
917 |
]. |
|
918 |
||
919 |
direction == #bottom ifTrue:[ |
|
920 |
self paint:leftFg. |
|
921 |
||
922 |
0 to:count - 1 do:[:i| "/ vertical : left |
|
923 |
self displayLineFromX:xL + i y:yT toX:xL + i y:y1+i. |
|
924 |
]. |
|
925 |
||
926 |
self paint:rightFg. |
|
927 |
||
928 |
0 to:count - 1 do:[:i| "/ horizontal: bottom |
|
929 |
self displayLineFromX:x0 y:yB-i toX:x1 + i y:yB-i. |
|
930 |
]. |
|
931 |
||
932 |
0 to:count - 1 do:[:i| "/ vertical: right |
|
933 |
self displayLineFromX:xR-i y:yT toX:xR-i y:y1+i. |
|
934 |
]. |
|
935 |
||
2280 | 936 |
(isSelected and:[count > 1]) ifFalse:[^ self]. |
937 |
(self isFirstTabInLine:aTab) ifTrue:[^ self]. |
|
2278 | 938 |
|
939 |
x0 := x0 - 1. |
|
940 |
y0 := yT - 1. |
|
941 |
||
942 |
1 to:count - 1 do:[:i| "/ selection shadow |
|
943 |
self displayLineFromX:xL y:y0 + i toX:x0-i y:y0 + i. |
|
944 |
]. |
|
945 |
^ self |
|
946 |
]. |
|
947 |
||
948 |
direction == #right ifTrue:[ |
|
949 |
self paint:leftFg. |
|
950 |
||
951 |
0 to:count - 1 do:[:i| "/ horizontal: top |
|
952 |
self displayLineFromX:xL y:yT + i toX:x1+i y:yT + i. |
|
953 |
]. |
|
954 |
||
955 |
self paint:rightFg. |
|
956 |
||
957 |
0 to:count - 1 do:[:i| "/ vertical: right |
|
958 |
self displayLineFromX:xR-i y:y0 toX:xR-i y:y1. |
|
959 |
]. |
|
960 |
||
961 |
1 to:count do:[:i| "/ horizontal: bottom |
|
962 |
self displayLineFromX:xL y:y1+i toX:xR-i y:y1+i. |
|
963 |
]. |
|
964 |
||
2280 | 965 |
(isSelected and:[count > 1]) ifFalse:[^ self]. |
2278 | 966 |
(self isFirstTabInLine:aTab) ifTrue:[^ self]. |
967 |
||
968 |
x0 := x0 - 1. |
|
969 |
y0 := yT - 1. |
|
970 |
||
971 |
1 to:count - 1 do:[:i| "/ selection shadow |
|
972 |
self displayLineFromX:xL y:y0 + i toX:x0-i y:y0 + i. |
|
973 |
]. |
|
974 |
^ self |
|
975 |
]. |
|
976 |
||
977 |
"/ direction == #left |
|
978 |
self paint:rightFg. |
|
979 |
||
980 |
x0 := xL + count. |
|
981 |
x1 := xR - count. |
|
982 |
y0 := yT + count. |
|
983 |
y1 := yB - count. |
|
984 |
||
985 |
0 to:count - 1 do:[:i| "/ horizontal: bottom |
|
986 |
self displayLineFromX:x0 - i y:yB - i toX:xR y:yB - i. |
|
987 |
]. |
|
988 |
||
989 |
self paint:leftFg. |
|
990 |
||
991 |
0 to:count - 1 do:[:i| "/ vertical: left |
|
992 |
self displayLineFromX:xL + i y:y0 toX:xL + i y:y1. |
|
993 |
]. |
|
994 |
||
995 |
1 to:count do:[:i| "/ horizontal: top |
|
996 |
self displayLineFromX:xL + i y:y0 - i toX:xR y:y0 - i. |
|
997 |
]. |
|
998 |
||
2280 | 999 |
(isSelected and:[count > 1]) ifFalse:[^ self]. |
1000 |
(self isLastTabInLine:aTab) ifTrue:[^ self]. |
|
2278 | 1001 |
|
1002 |
x1 := x1 + 1. |
|
1003 |
y0 := yB + 1. |
|
1004 |
||
1005 |
1 to:count - 1 do:[:i| "/ selection shadow |
|
1006 |
self displayLineFromX:x1+i y:yB + 1 - i toX:xR y:yB + 1 - i. |
|
1007 |
]. |
|
1008 |
! |
|
1009 |
||
1401 | 1010 |
invalidateTab:aTab |
1011 |
"invalidate a tab |
|
1012 |
" |
|
2213 | 1013 |
|tabBounds| |
1014 |
||
1401 | 1015 |
shown ifTrue:[ |
2213 | 1016 |
tabBounds := self computeLayoutForTab:aTab. |
1017 |
self invalidate:tabBounds. |
|
1401 | 1018 |
] |
1019 |
! |
|
1020 |
||
2288 | 1021 |
redrawTab:aTab |
1022 |
"redraw a tab |
|
1023 |
" |
|
1024 |
|isSelected layout fgColor extent voffs hoffs| |
|
1025 |
||
1026 |
isSelected := self selectedTab == aTab. |
|
1027 |
||
1028 |
layout := aTab layout. |
|
1029 |
||
1030 |
isSelected ifTrue:[ |
|
1031 |
self paint:(self viewBackground). |
|
1032 |
self fillRectangle:layout. |
|
1033 |
]. |
|
1034 |
||
1035 |
(enabled and:[aTab isEnabled]) ifFalse:[ |
|
1036 |
fgColor := disabledForegroundColor. |
|
1037 |
] ifTrue:[ |
|
1038 |
fgColor := aTab foregroundColor. |
|
1039 |
fgColor isNil ifTrue:[ |
|
1040 |
isSelected ifTrue:[ fgColor := activeForegroundColor ] |
|
1041 |
ifFalse:[ fgColor := foregroundColor ]. |
|
1042 |
] |
|
1043 |
]. |
|
1044 |
self paint:fgColor. |
|
1045 |
aTab displayOn:self inset:(tabLevel abs) direction:direction. |
|
1046 |
self drawTabEdgesFor:aTab. |
|
1047 |
||
1048 |
( isSelected |
|
1049 |
and:[self hasFocus |
|
1050 |
and:[self supportsFocusOnTab]] |
|
1051 |
) ifFalse:[ |
|
1052 |
^ self |
|
1053 |
]. |
|
1054 |
||
1055 |
"/ drawing the focus |
|
1056 |
||
1057 |
extent := aTab extent. |
|
1058 |
voffs := (layout height - extent y) // 2 max:0. |
|
1059 |
hoffs := (layout width - extent x) // 2 max:0. |
|
1060 |
||
1061 |
self paint:(Color black). |
|
1062 |
||
1063 |
self displayDottedRectangleX:(layout left + hoffs - 1) |
|
1064 |
y:(layout top + voffs - 1) |
|
1065 |
width:(layout width - hoffs - hoffs + 2) |
|
1066 |
height:(layout height - voffs - voffs + 2). |
|
1067 |
||
1068 |
||
1069 |
||
1070 |
||
1071 |
||
1072 |
"" |
|
1073 |
! |
|
1074 |
||
1401 | 1075 |
redrawX:x y:y width:w height:h |
1076 |
"a region must be redrawn |
|
375 | 1077 |
" |
2288 | 1078 |
|selectedTab line damage layout selectedLayout| |
1401 | 1079 |
|
2035
6cc4d73f17e1
bug fix when chaning the canvas before being realized
Claus Gittinger <cg@exept.de>
parents:
2010
diff
changeset
|
1080 |
shown ifFalse:[ ^ self ]. |
6cc4d73f17e1
bug fix when chaning the canvas before being realized
Claus Gittinger <cg@exept.de>
parents:
2010
diff
changeset
|
1081 |
|
2283 | 1082 |
numberOfLines isNil ifTrue:[ |
1401 | 1083 |
self recomputeList. |
2215 | 1084 |
|
2283 | 1085 |
numberOfLines notNil ifTrue:[ |
2215 | 1086 |
self invalidate |
1087 |
]. |
|
1088 |
^ self |
|
1401 | 1089 |
]. |
2213 | 1090 |
selectedTab := self selectedTab. |
1963 | 1091 |
|
2283 | 1092 |
selectedTab notNil ifTrue:[ |
2288 | 1093 |
(line := selectedTab lineNr) ~~ 1 ifTrue:[ |
1094 |
self makeToBaseLine:line. |
|
2283 | 1095 |
^ self |
1096 |
] |
|
1401 | 1097 |
]. |
1098 |
||
1099 |
self paint:(self viewBackground). |
|
1100 |
self fillRectangleX:x y:y width:w height:h. |
|
1101 |
||
2283 | 1102 |
list size == 0 ifTrue:[ ^ self ]. |
1103 |
||
2278 | 1104 |
damage := Rectangle left:x top:y width:w height:h. |
1105 |
||
1106 |
numberOfLines to:1 by:-1 do:[:aLnNr| |
|
1107 |
list reverseDo:[:aTab| |
|
1108 |
( aTab lineNr == aLnNr |
|
1109 |
and:[aTab ~~ selectedTab |
|
1110 |
and:[aTab intersects:damage]] |
|
1111 |
) ifTrue:[ |
|
2288 | 1112 |
self redrawTab:aTab. |
1401 | 1113 |
] |
1114 |
] |
|
1115 |
]. |
|
2283 | 1116 |
self drawBorderEdges. |
1117 |
||
1118 |
selectedTab isNil ifTrue:[^ self]. |
|
1119 |
||
2288 | 1120 |
layout := self computeLayoutForTab:selectedTab. |
1121 |
||
1122 |
(layout intersects:damage) ifTrue:[ |
|
1123 |
selectedLayout := selectedTab layout. |
|
1124 |
selectedTab layout:layout. |
|
1125 |
self redrawTab:selectedTab. |
|
1126 |
selectedTab layout:selectedLayout. |
|
1401 | 1127 |
]. |
1128 |
! ! |
|
1129 |
||
1130 |
!NoteBookView methodsFor:'event handling'! |
|
1131 |
||
1132 |
buttonPress:button x:x y:y |
|
1133 |
"a button is pressed; find tab under point and set the selection |
|
1134 |
" |
|
1802 | 1135 |
|idx tab recv menu| |
1401 | 1136 |
|
2279 | 1137 |
enabled ifFalse:[ ^ self ]. |
1138 |
list isEmpty ifTrue:[ ^ self ]. |
|
1139 |
||
1140 |
idx := list findFirst:[:aTab| aTab containsPointX:x y:y ]. |
|
1141 |
idx == 0 ifTrue:[ ^ self ]. |
|
1142 |
||
1143 |
tab := list at:idx. |
|
1144 |
tab isEnabled ifFalse:[ ^ self ]. |
|
375 | 1145 |
|
1802 | 1146 |
((button == 2) or:[button == #menu]) ifFalse:[ |
1147 |
"/ change the selection |
|
1148 |
^ self selection:idx |
|
1149 |
]. |
|
2279 | 1150 |
accessTabMenuAction isNil ifTrue:[ ^ self ]. |
1151 |
menu := accessTabMenuAction value:idx. |
|
1152 |
menu isNil ifTrue:[ ^ self ]. |
|
1153 |
||
1802 | 1154 |
menu isArray ifTrue:[ |
1155 |
menu := menu decodeAsLiteralArray |
|
1156 |
]. |
|
1157 |
||
1158 |
menu receiver isNil ifTrue:[ |
|
1159 |
(recv := self application) isNil ifTrue:[ |
|
1160 |
recv := tab model |
|
1161 |
]. |
|
1162 |
recv notNil ifTrue:[ |
|
1163 |
menu receiver:recv |
|
1164 |
] ifFalse:[ |
|
1165 |
Transcript showCR:('%1 : MENU HAS NO RECEIVER' bindWith:(self class name)). |
|
1401 | 1166 |
] |
1802 | 1167 |
]. |
1168 |
menu startUp |
|
1401 | 1169 |
! |
1170 |
||
1171 |
keyPress:aKey x:x y:y |
|
1172 |
"selection might change; look for corresponding list entry |
|
1173 |
" |
|
1659 | 1174 |
<resource: #keyboard (#CursorRight #CursorLeft #CursorUp #CursorDown)> |
1407 | 1175 |
|
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1176 |
|sensor size index n key| |
1401 | 1177 |
|
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1178 |
(enabled and:[(size := list size) ~~ 0]) ifFalse:[ |
1657
061c167ce3db
if disabled; call super keyPress:x:y to handle focusSequence
ca
parents:
1549
diff
changeset
|
1179 |
^ super keyPress:aKey x:x y:y |
1401 | 1180 |
]. |
1181 |
||
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1182 |
(self processAccessCharacter:aKey) ifTrue:[ |
1407 | 1183 |
^ self |
1184 |
]. |
|
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1185 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1186 |
(self processShortcutKey:aKey) ifTrue:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1187 |
^ self |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1188 |
]. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1189 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1190 |
(size > 1 and:[aKey isSymbol and:[aKey startsWith:'Cursor']]) ifFalse:[ |
1659 | 1191 |
^ super keyPress:aKey x:x y:y |
1192 |
]. |
|
1407 | 1193 |
|
1659 | 1194 |
self isHorizontal ifTrue:[ |
1195 |
(aKey == #CursorRight or:[aKey == #CursorLeft]) ifFalse:[ |
|
1196 |
^ self |
|
1197 |
]. |
|
1198 |
key := aKey. |
|
1199 |
] ifFalse:[ |
|
1200 |
aKey == #CursorUp ifTrue:[key := #CursorLeft] |
|
1201 |
ifFalse:[aKey == #CursorDown ifTrue:[key := #CursorRight] |
|
1202 |
ifFalse:[ ^ self]]. |
|
1401 | 1203 |
]. |
1204 |
||
1407 | 1205 |
(sensor := self sensor) notNil ifTrue:[ |
1206 |
n := 1 + (sensor compressKeyPressEventsWithKey:aKey). |
|
1207 |
n := (n \\ size) max:1. |
|
1208 |
||
1659 | 1209 |
key == #CursorRight ifTrue:[ |
1407 | 1210 |
index := selection ? 1. |
1211 |
[ (index := index + 1) > size ifTrue:[index := 1]. |
|
1212 |
(self isSelectable:index) ifTrue:[n := n - 1]. |
|
1213 |
n ~~ 0 |
|
1214 |
] whileTrue. |
|
1215 |
] ifFalse:[ |
|
1216 |
index := selection ? size. |
|
1217 |
[ (index := index - 1) == 0 ifTrue:[index := size]. |
|
1218 |
(self isSelectable:index) ifTrue:[n := n -1]. |
|
1219 |
n ~~ 0 |
|
1220 |
] whileTrue. |
|
1221 |
]. |
|
1222 |
self selection:index |
|
1223 |
] |
|
1401 | 1224 |
! |
1225 |
||
1677 | 1226 |
processShortcutKeyEvent:event |
1227 |
^ self processShortcutKey:(event key) |
|
1228 |
! |
|
1229 |
||
1401 | 1230 |
sizeChanged:how |
1231 |
"size of view changed |
|
1232 |
" |
|
1233 |
super sizeChanged:how. |
|
1234 |
||
1235 |
list notEmpty ifTrue:[ |
|
1403 | 1236 |
lastComputedExtent ~= self extent ifTrue:[ |
1237 |
numberOfLines := nil. |
|
1238 |
] |
|
1680 | 1239 |
]. |
1240 |
shown ifTrue:[self invalidate]. |
|
1241 |
self resizeCanvas. |
|
1401 | 1242 |
! ! |
1243 |
||
1659 | 1244 |
!NoteBookView methodsFor:'focus handling'! |
1245 |
||
1246 |
showFocus:explicit |
|
1247 |
"got the keyboard focus |
|
1248 |
" |
|
2279 | 1249 |
|selectedTab| |
1659 | 1250 |
|
2279 | 1251 |
self supportsFocusOnTab ifTrue:[ |
1252 |
selectedTab := self selectedTab. |
|
1253 |
selectedTab notNil ifTrue:[ |
|
1254 |
self invalidateTab:selectedTab |
|
1659 | 1255 |
] |
1256 |
] ifFalse:[ |
|
1257 |
super showFocus:explicit |
|
1258 |
] |
|
1259 |
! |
|
1260 |
||
1261 |
showNoFocus:explicit |
|
1262 |
"lost the keyboard focus |
|
1263 |
" |
|
2279 | 1264 |
|selectedTab| |
1659 | 1265 |
|
2279 | 1266 |
self supportsFocusOnTab ifTrue:[ |
1267 |
selectedTab := self selectedTab. |
|
1268 |
||
1269 |
selectedTab notNil ifTrue:[ |
|
1270 |
self invalidateTab:selectedTab |
|
1271 |
]. |
|
1659 | 1272 |
] ifFalse:[ |
1273 |
super showNoFocus:explicit |
|
1274 |
] |
|
2279 | 1275 |
! |
1276 |
||
1277 |
supportsFocusOnTab |
|
1278 |
"returns true if focus is supported |
|
1279 |
" |
|
1280 |
^ (styleSheet at:#'focusHighlightStyle') == #win95 |
|
1659 | 1281 |
! ! |
1282 |
||
1759 | 1283 |
!NoteBookView methodsFor:'help'! |
1284 |
||
1285 |
helpText |
|
1286 |
"return the helpText for the currently selected item (empty if none) |
|
1287 |
" |
|
1288 |
^ self helpTextForItemAt:selection |
|
1289 |
||
1290 |
||
1291 |
! |
|
1292 |
||
1293 |
helpTextAt:srcPoint |
|
1294 |
"return the helpText for aPoint (i.e. when mouse-pointer is moved over an item). |
|
1295 |
" |
|
1296 |
|x y i| |
|
1297 |
||
1298 |
x := srcPoint x. |
|
1299 |
y := srcPoint y. |
|
1300 |
i := list findFirst:[:aTab| aTab containsPointX:x y:y ]. |
|
1301 |
||
1302 |
^ self helpTextForItemAt:i |
|
1303 |
! |
|
1304 |
||
1305 |
helpTextForItemAt:anIndex |
|
1306 |
|tab| |
|
1307 |
||
1308 |
( anIndex notNil |
|
1309 |
and:[anIndex ~~ 0 |
|
1310 |
and:[(tab := list at:anIndex ifAbsent:nil) notNil |
|
1311 |
and:[(tab := tab model) notNil]]] |
|
1312 |
) ifTrue:[ |
|
1313 |
^ tab activeHelpText ? '' |
|
1314 |
]. |
|
1315 |
^ '' |
|
1316 |
! ! |
|
1317 |
||
1687 | 1318 |
!NoteBookView methodsFor:'initialization & release'! |
1401 | 1319 |
|
1320 |
destroy |
|
1321 |
"remove dependencies |
|
1322 |
" |
|
1323 |
list removeDependent:self. |
|
1324 |
||
1325 |
listHolder removeDependent:self. |
|
1326 |
canvasHolder removeDependent:self. |
|
1327 |
||
1328 |
super destroy. |
|
1329 |
! |
|
1330 |
||
1331 |
initStyle |
|
1332 |
"setup style attributes |
|
1333 |
" |
|
1442 | 1334 |
|clr| |
1335 |
||
1401 | 1336 |
super initStyle. |
1682 | 1337 |
tabModus := false. |
1338 |
edgeStyle := DefaultEdgeStyle. |
|
1442 | 1339 |
|
1401 | 1340 |
self font:self class defaultFont. |
1682 | 1341 |
drawLightColor := Color veryLightGray onDevice:device. |
1442 | 1342 |
|
1682 | 1343 |
clr := DefaultForegroundColor ? Black. |
1344 |
foregroundColor := clr onDevice:device. |
|
1345 |
||
1346 |
clr := DefaultForegroundColor ? foregroundColor. |
|
1347 |
activeForegroundColor := clr onDevice:device. |
|
1348 |
||
1988 | 1349 |
(clr := DefaultShadowColor) isNil ifTrue:[clr := viewBackground darkened]. |
1682 | 1350 |
shadowColor := clr onDevice:device. |
1351 |
||
1988 | 1352 |
(clr := DefaultLightColor) isNil ifTrue:[clr := viewBackground lightened]. |
1682 | 1353 |
lightColor := clr onDevice:device. |
1442 | 1354 |
|
1689
ecb51abe4a6b
preps to allow for tabColor and activeTabColor to be
Claus Gittinger <cg@exept.de>
parents:
1687
diff
changeset
|
1355 |
|
1682 | 1356 |
edgeStyle isNil ifTrue:[ |
1357 |
halfShadowColor := shadowColor. |
|
1358 |
halfLightColor := lightColor. |
|
1359 |
drawLightColor := lightColor. |
|
1360 |
] ifFalse:[ |
|
1361 |
||
1362 |
(clr := DefaultHalfShadowColor) isNil ifTrue:[ |
|
1363 |
clr := shadowColor lightened |
|
1442 | 1364 |
]. |
1682 | 1365 |
halfShadowColor := clr onDevice:device. |
1366 |
||
1367 |
(clr := DefaultHalfLightColor) isNil ifTrue:[ |
|
1368 |
clr := lightColor darkened. |
|
1369 |
]. |
|
1370 |
halfLightColor := clr onDevice:device. |
|
1371 |
||
1372 |
edgeStyle == #soft ifTrue:[ |
|
1373 |
drawLightColor := halfShadowColor |
|
1374 |
] ifFalse:[ |
|
1375 |
drawLightColor := Color veryLightGray onDevice:device. |
|
1376 |
] |
|
1442 | 1377 |
]. |
1700 | 1378 |
(clr := DisabledForegroundColor) notNil ifTrue:[ |
1379 |
disabledForegroundColor := clr onDevice:device |
|
1380 |
]ifFalse:[ |
|
1381 |
disabledForegroundColor := drawLightColor |
|
1382 |
]. |
|
1401 | 1383 |
! |
1384 |
||
1385 |
initialize |
|
1386 |
"setup default attributes |
|
1387 |
" |
|
1388 |
super initialize. |
|
1389 |
||
1390 |
self cursor:Cursor hand. |
|
1391 |
||
1680 | 1392 |
list := #(). |
1393 |
useIndex := true. |
|
1394 |
direction := #top. |
|
1395 |
fitLastRow := true. |
|
1396 |
enabled := true. |
|
1685 | 1397 |
canvasInset := StyleSheet at:#'noteBook.canvasInset' default:1@1. |
1680 | 1398 |
keepCanvas := false. |
2278 | 1399 |
tabLevel := StyleSheet at:#'noteBook.tabLevel' default:1. |
1401 | 1400 |
|
2280 | 1401 |
selectionInsetX := (2 max:(tabLevel abs)) + 1. |
1402 |
selectionInsetY := (2 max:(tabLevel abs)) + 1. |
|
1403 |
||
2285 | 1404 |
|
1405 |
tabTopMargin := StyleSheet at:#'noteBook.tabTopMargin' default:nil. |
|
1406 |
||
1407 |
tabTopMargin ifNil:[ |
|
1408 |
"/ menus has no button renderer.... |
|
1409 |
StyleSheet name == #win95 ifTrue:[ tabTopMargin := 1 ] |
|
1410 |
ifFalse:[ tabTopMargin := 4 ]. |
|
1411 |
]. |
|
1412 |
||
1413 |
tabBottomMargin := StyleSheet at:#'noteBook.tabBottomMargin' default:1. |
|
2280 | 1414 |
|
1401 | 1415 |
self lineWidth:0. |
1416 |
||
1417 |
canvas notNil ifTrue:[ |
|
1418 |
canvas := canvas in:self. |
|
1419 |
]. |
|
1403 | 1420 |
! |
1421 |
||
1422 |
realize |
|
1423 |
||
1424 |
(canvas notNil and:[numberOfLines isNil]) ifTrue:[ |
|
1425 |
self recomputeList |
|
1426 |
]. |
|
1427 |
super realize. |
|
1401 | 1428 |
! ! |
1429 |
||
1430 |
!NoteBookView methodsFor:'layout'! |
|
1431 |
||
1432 |
computeBorderLayout |
|
2035
6cc4d73f17e1
bug fix when chaning the canvas before being realized
Claus Gittinger <cg@exept.de>
parents:
2010
diff
changeset
|
1433 |
|xL yT xR yB tab l| |
1401 | 1434 |
|
1435 |
xL := 0. |
|
1436 |
yT := 0. |
|
1437 |
xR := width. |
|
1438 |
yB := height. |
|
1439 |
||
2278 | 1440 |
list notEmpty ifTrue:[ |
1441 |
tab := list detect:[:aTab| aTab lineNr == 1] ifNone:nil. |
|
1442 |
||
1443 |
tab notNil ifTrue:[ |
|
1444 |
l := tab layout. |
|
1445 |
||
2279 | 1446 |
direction == #top ifTrue:[ yT := l bottom ] |
1447 |
ifFalse:[ direction == #bottom ifTrue:[ yB := l top ] |
|
1448 |
ifFalse:[ direction == #left ifTrue:[ xL := l right ] |
|
1449 |
ifFalse:[ |
|
2278 | 1450 |
xR := l left |
1451 |
]]] |
|
1452 |
] |
|
1401 | 1453 |
]. |
1454 |
^ Rectangle left:xL top:yT right:xR bottom:yB |
|
1455 |
! |
|
1456 |
||
1457 |
computeLayoutForTab:aTab |
|
1458 |
"calculate extent of a tab |
|
1459 |
" |
|
2286 | 1460 |
|layout bwAbs left right top bottom inset| |
1401 | 1461 |
|
1462 |
layout := aTab layout. |
|
1658 | 1463 |
|
1464 |
self selectedTab == aTab ifFalse:[ |
|
1465 |
^ layout |
|
1466 |
]. |
|
1401 | 1467 |
|
2280 | 1468 |
bwAbs := tabLevel abs. |
2278 | 1469 |
left := layout left. |
1470 |
right := layout right. |
|
1471 |
top := layout top. |
|
1472 |
bottom := layout bottom. |
|
1658 | 1473 |
|
2286 | 1474 |
bwAbs == 0 ifTrue:[ inset := 2 ] |
1475 |
ifFalse:[ inset := 0 ]. |
|
1476 |
||
1658 | 1477 |
(direction == #top or:[direction == #bottom]) ifTrue:[ |
2286 | 1478 |
left := (left - selectionInsetX) max:inset. |
1479 |
right := (right + selectionInsetX) min:(width - inset). |
|
2283 | 1480 |
|
2278 | 1481 |
direction == #top ifTrue:[ |
1482 |
bottom := bottom + bwAbs. |
|
2280 | 1483 |
top := top - selectionInsetY. |
375 | 1484 |
] ifFalse:[ |
2278 | 1485 |
top := top - bwAbs. |
2280 | 1486 |
bottom := bottom + selectionInsetY. |
1658 | 1487 |
]. |
2278 | 1488 |
] ifFalse:[ |
2286 | 1489 |
top := (top - selectionInsetX) max:inset. |
1490 |
bottom := (bottom + selectionInsetX) min:(height - inset). |
|
2278 | 1491 |
|
1492 |
direction == #left ifTrue:[ |
|
1493 |
right := right + bwAbs. |
|
2280 | 1494 |
left := left - selectionInsetY |
2278 | 1495 |
] ifFalse:[ |
1496 |
left := left - bwAbs. |
|
2280 | 1497 |
right := right + selectionInsetY. |
2278 | 1498 |
] |
1401 | 1499 |
]. |
2278 | 1500 |
^ Rectangle left:left top:top right:right bottom:bottom |
1401 | 1501 |
! |
1502 |
||
1503 |
makeToBaseLine:aLnNr |
|
1962
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1504 |
"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
|
1505 |
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
|
1506 |
|
1963 | 1507 |
|lineTopsOrLefts isHorizontal| |
1508 |
||
1509 |
isHorizontal := self isHorizontal. |
|
1962
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1510 |
|
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1511 |
"collect per-lineNr offsets" |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1512 |
lineTopsOrLefts := (1 to:numberOfLines) collect:[:lnr | |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1513 |
|tabNr layout| |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1514 |
|
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1515 |
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
|
1516 |
layout := (list at:tabNr) layout. |
1963 | 1517 |
isHorizontal ifTrue:[ |
1962
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1518 |
layout top. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1519 |
] ifFalse:[ |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1520 |
layout left. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1521 |
]. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1522 |
]. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1523 |
|
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1524 |
"change offsets of all tabs" |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1525 |
list do:[:el | |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1526 |
|layout topOrLeft nr newNr| |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1527 |
|
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1528 |
nr := el lineNr. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1529 |
newNr := nr - aLnNr + 1. |
1964 | 1530 |
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
|
1531 |
newNr := ((newNr - 1) \\ numberOfLines) + 1. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1532 |
topOrLeft := lineTopsOrLefts at:newNr. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1533 |
layout := el layout. |
1963 | 1534 |
isHorizontal ifTrue:[ |
1962
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1535 |
layout setTop:topOrLeft. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1536 |
] ifFalse:[ |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1537 |
layout setLeft:topOrLeft. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1538 |
]. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1539 |
el lineNr:newNr. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1540 |
]. |
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1541 |
|
5b0098ec76a8
preserve the tabs order when selecting a tab
Claus Gittinger <cg@exept.de>
parents:
1892
diff
changeset
|
1542 |
self invalidate. |
1401 | 1543 |
! |
1544 |
||
1545 |
recomputeList |
|
1546 |
"recompute list |
|
1547 |
" |
|
2281 | 1548 |
numberOfLines := 1. |
1403 | 1549 |
lastComputedExtent := self extent. |
1401 | 1550 |
|
1680 | 1551 |
list size ~~ 0 ifTrue:[ |
2281 | 1552 |
self isHorizontal ifTrue:[ self recomputeListHorizontal ] |
1553 |
ifFalse:[ self recomputeListVertical ] |
|
1401 | 1554 |
]. |
1680 | 1555 |
self resizeCanvas. |
1401 | 1556 |
! |
1557 |
||
1558 |
recomputeListHorizontal |
|
1559 |
"recompute list |
|
1560 |
" |
|
2281 | 1561 |
|layout lastLyt |
1401 | 1562 |
xLeft "{ Class:SmallInteger }" |
2281 | 1563 |
xRight "{ Class:SmallInteger }" |
1401 | 1564 |
yTop "{ Class:SmallInteger }" |
1565 |
tabWidth "{ Class:SmallInteger }" |
|
1566 |
tabHeight "{ Class:SmallInteger }" |
|
1567 |
delta "{ Class:SmallInteger }" |
|
1568 |
first "{ Class:SmallInteger }" |
|
1569 |
last "{ Class:SmallInteger }" |
|
2278 | 1570 |
border "{ Class:SmallInteger }" |
2281 | 1571 |
lastLnNr "{ Class:SmallInteger }" |
2283 | 1572 |
tabLvlAbs "{ Class:SmallInteger }" |
2286 | 1573 |
minLeft "{ Class:SmallInteger }" |
1574 |
maxRight "{ Class:SmallInteger }" |
|
1401 | 1575 |
| |
2281 | 1576 |
numberOfLines := 1. |
2283 | 1577 |
tabLvlAbs := tabLevel abs max:1. |
1578 |
border := tabLevel * 2. |
|
2281 | 1579 |
tabHeight := 0. |
2286 | 1580 |
minLeft := selectionInsetX. |
1581 |
maxRight := width - selectionInsetX. |
|
1582 |
xLeft := minLeft. |
|
1401 | 1583 |
|
1584 |
list do:[:aTab| |
|
2281 | 1585 |
tabWidth := aTab preferredExtentX + border. |
1586 |
tabHeight := (aTab preferredExtentY) max:tabHeight. |
|
1587 |
xRight := xLeft + tabWidth. |
|
1401 | 1588 |
|
2286 | 1589 |
xRight > maxRight ifTrue:[ |
1590 |
xLeft ~~ minLeft ifTrue:[ |
|
2281 | 1591 |
numberOfLines := numberOfLines + 1. |
2286 | 1592 |
xLeft := minLeft. |
2281 | 1593 |
xRight := xLeft + tabWidth. |
1594 |
]. |
|
2286 | 1595 |
xRight > maxRight ifTrue:[ |
1596 |
tabWidth := maxRight - minLeft. |
|
1597 |
xRight := maxRight. |
|
2281 | 1598 |
]. |
1401 | 1599 |
]. |
1600 |
aTab lineNr:numberOfLines. |
|
2281 | 1601 |
aTab layout:(Rectangle left:xLeft top:0 width:tabWidth height:tabHeight). |
1602 |
xLeft := xRight. |
|
1401 | 1603 |
]. |
2283 | 1604 |
tabHeight := tabHeight + tabLvlAbs. |
1605 |
yTop := selectionInsetY + tabTopMargin. |
|
2281 | 1606 |
|
1607 |
direction == #bottom ifTrue:[ |
|
1608 |
yTop := height - tabHeight - yTop. |
|
1609 |
delta := tabHeight negated. |
|
1610 |
] ifFalse:[ |
|
1611 |
delta := tabHeight |
|
1612 |
]. |
|
1613 |
||
1614 |
lastLnNr := numberOfLines. |
|
1401 | 1615 |
|
2281 | 1616 |
list reverseDo:[:aTab| |
1617 |
aTab lineNr ~~ lastLnNr ifTrue:[ |
|
1618 |
lastLnNr := aTab lineNr. |
|
1619 |
yTop := yTop + delta |
|
1620 |
]. |
|
1621 |
layout := aTab layout. |
|
1622 |
layout setTop:yTop. |
|
1623 |
layout height:tabHeight. |
|
1401 | 1624 |
]. |
2281 | 1625 |
|
1401 | 1626 |
tabModus ifTrue:[ |
1627 |
layout := (list at:1) layout. |
|
2281 | 1628 |
delta := direction == #top ifTrue:[height - layout bottom] |
1401 | 1629 |
ifFalse:[layout top negated]. |
1630 |
||
1631 |
list do:[:aTab| aTab layout setTop:(aTab layout top + delta)]. |
|
1632 |
]. |
|
1633 |
||
1634 |
"/ FIT LINES |
|
1635 |
(numberOfLines ~~ 1 or:[fitLastRow]) ifFalse:[ |
|
1636 |
^ self |
|
1637 |
]. |
|
1638 |
||
1639 |
first := 1. |
|
1640 |
||
1641 |
1 to:numberOfLines do:[:aLnNr| |
|
1642 |
last := list findLast:[:t|t lineNr == aLnNr]. |
|
1643 |
lastLyt := (list at:last) layout. |
|
1644 |
||
2286 | 1645 |
(delta := maxRight - lastLyt right) ~~ 0 ifTrue:[ |
1646 |
xLeft := minLeft. |
|
1401 | 1647 |
delta := delta // (last - first + 1). |
1648 |
||
1649 |
delta ~~ 0 ifTrue:[ |
|
1650 |
list from:first to:last do:[:aTab| |
|
1651 |
layout := aTab layout. |
|
1652 |
tabWidth := layout width + delta. |
|
1653 |
layout setLeft:xLeft. |
|
1654 |
layout width:tabWidth. |
|
1655 |
xLeft := xLeft + tabWidth. |
|
1656 |
] |
|
1657 |
]. |
|
2286 | 1658 |
lastLyt width:(maxRight - lastLyt left) |
1401 | 1659 |
]. |
1660 |
first := last + 1. |
|
1661 |
] |
|
1662 |
! |
|
1663 |
||
1664 |
recomputeListVertical |
|
1665 |
"recompute list |
|
1666 |
" |
|
1667 |
|layout lastLyt |
|
1668 |
xTop "{ Class:SmallInteger }" |
|
1669 |
yTop "{ Class:SmallInteger }" |
|
2281 | 1670 |
yBottom "{ Class:SmallInteger }" |
1401 | 1671 |
tabWidth "{ Class:SmallInteger }" |
1672 |
tabHeight "{ Class:SmallInteger }" |
|
1673 |
delta "{ Class:SmallInteger }" |
|
1674 |
first "{ Class:SmallInteger }" |
|
1675 |
last "{ Class:SmallInteger }" |
|
2283 | 1676 |
border "{ Class:SmallInteger }" |
1677 |
tabLvlAbs "{ Class:SmallInteger }" |
|
2286 | 1678 |
minTop "{ Class:SmallInteger }" |
1679 |
maxBottom "{ Class:SmallInteger }" |
|
1401 | 1680 |
| |
2010 | 1681 |
|
2281 | 1682 |
numberOfLines := 1. |
2283 | 1683 |
tabLvlAbs := (tabLevel abs) max:1. |
1684 |
border := tabLvlAbs * 2. |
|
2281 | 1685 |
tabHeight := 0. |
2286 | 1686 |
minTop := selectionInsetX. |
1687 |
maxBottom := height - selectionInsetX. |
|
1688 |
yTop := minTop. |
|
1401 | 1689 |
|
1690 |
list do:[:aTab| |
|
2281 | 1691 |
tabWidth := aTab preferredExtentX + border. |
1692 |
tabHeight := (aTab preferredExtentY) max:tabHeight. |
|
1693 |
yBottom := yTop + tabWidth. |
|
1401 | 1694 |
|
2286 | 1695 |
yBottom > maxBottom ifTrue:[ |
1696 |
yTop ~~ minTop ifTrue:[ |
|
2281 | 1697 |
numberOfLines := numberOfLines + 1. |
2286 | 1698 |
yTop := minTop. |
2281 | 1699 |
yBottom := yTop + tabWidth. |
1700 |
]. |
|
2286 | 1701 |
yBottom > maxBottom ifTrue:[ |
1702 |
tabWidth := maxBottom - minTop. |
|
1703 |
yBottom := maxBottom. |
|
2281 | 1704 |
]. |
1401 | 1705 |
]. |
1706 |
aTab lineNr:numberOfLines. |
|
2281 | 1707 |
aTab layout:(Rectangle left:0 top:yTop width:tabHeight height:tabWidth). |
1708 |
yTop := yBottom |
|
1401 | 1709 |
]. |
2283 | 1710 |
tabHeight := tabHeight + tabLvlAbs. |
1711 |
xTop := selectionInsetY + tabTopMargin. |
|
2281 | 1712 |
|
1713 |
direction == #right ifTrue:[ |
|
1714 |
xTop := width - tabHeight - xTop. |
|
1715 |
delta := tabHeight negated. |
|
1716 |
] ifFalse:[ |
|
1717 |
delta := tabHeight. |
|
1718 |
]. |
|
1401 | 1719 |
|
2281 | 1720 |
last := numberOfLines. |
1721 |
||
1722 |
list reverseDo:[:aTab| |
|
1723 |
aTab lineNr ~~ last ifTrue:[ |
|
1724 |
last := aTab lineNr. |
|
1725 |
xTop := xTop + delta |
|
1726 |
]. |
|
1727 |
layout := aTab layout. |
|
1728 |
layout setLeft:xTop. |
|
1729 |
layout width:tabHeight. |
|
1401 | 1730 |
]. |
2281 | 1731 |
|
1401 | 1732 |
tabModus ifTrue:[ |
1733 |
layout := (list at:1) layout. |
|
2281 | 1734 |
delta := direction == #left ifTrue:[width - layout right] |
1401 | 1735 |
ifFalse:[layout left negated]. |
1736 |
||
1737 |
list do:[:aTab| aTab layout setLeft:(aTab layout left + delta)]. |
|
1738 |
]. |
|
1739 |
||
1740 |
"/ FIT LINES |
|
1741 |
(numberOfLines ~~ 1 or:[fitLastRow]) ifFalse:[ |
|
1742 |
^ self |
|
1743 |
]. |
|
1744 |
||
1745 |
first := 1. |
|
1746 |
||
1747 |
1 to:numberOfLines do:[:aLnNr| |
|
1748 |
last := list findLast:[:t|t lineNr == aLnNr]. |
|
1749 |
lastLyt := (list at:last) layout. |
|
1750 |
||
2286 | 1751 |
(delta := maxBottom - lastLyt bottom) ~~ 0 ifTrue:[ |
1752 |
yTop := minTop. |
|
1401 | 1753 |
delta := delta // (last - first + 1). |
1754 |
||
1755 |
delta ~~ 0 ifTrue:[ |
|
1756 |
list from:first to:last do:[:aTab| |
|
1757 |
layout := aTab layout. |
|
1758 |
tabWidth := layout height + delta. |
|
1759 |
layout setTop:yTop. |
|
1760 |
layout height:tabWidth. |
|
1761 |
yTop := yTop + tabWidth. |
|
1762 |
] |
|
1763 |
]. |
|
2286 | 1764 |
lastLyt height:(maxBottom - lastLyt top) |
1401 | 1765 |
]. |
1766 |
first := last + 1. |
|
1767 |
] |
|
1680 | 1768 |
! |
1769 |
||
1770 |
resizeCanvas |
|
2278 | 1771 |
|layout borderWd| |
1680 | 1772 |
|
1773 |
canvas notNil ifTrue:[ |
|
2002 | 1774 |
layout := self computeBorderLayout. |
2278 | 1775 |
|
1776 |
list notEmpty ifTrue:[ |
|
1777 |
borderWd := tabLevel abs. |
|
1778 |
layout := layout insetBy:(canvasInset + borderWd). |
|
2284 | 1779 |
|
1780 |
tabBottomMargin > 0 ifTrue:[ |
|
1781 |
(direction == #top or:[direction == #bottom]) ifTrue:[ |
|
1782 |
layout height:(layout height - tabBottomMargin). |
|
1783 |
direction == #top ifTrue:[ |
|
1784 |
layout setTop:(layout top + tabBottomMargin) |
|
1785 |
] |
|
1786 |
] ifFalse:[ |
|
1787 |
layout width:(layout width - tabBottomMargin). |
|
1788 |
||
1789 |
direction == #left ifTrue:[ |
|
1790 |
layout setLeft:(layout left + tabBottomMargin) |
|
1791 |
] |
|
1792 |
] |
|
1793 |
||
1794 |
]. |
|
2036 | 1795 |
]. |
2161
f62cdcac0e9f
do not change the layout, if the computation results in the
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
1796 |
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
|
1797 |
canvas layout:layout. |
2278 | 1798 |
]. |
1680 | 1799 |
] |
1401 | 1800 |
! ! |
1801 |
||
1802 |
!NoteBookView methodsFor:'obsolete'! |
|
1803 |
||
2279 | 1804 |
canvasFrameLevel |
1805 |
"ignorred |
|
1806 |
" |
|
1807 |
^ 0 |
|
1808 |
! |
|
1809 |
||
1810 |
canvasFrameLevel:anInteger |
|
1811 |
"ignorred |
|
1812 |
" |
|
1813 |
! |
|
1814 |
||
1401 | 1815 |
labels |
1816 |
"return the list of labels |
|
1817 |
" |
|
1818 |
^ self list |
|
1819 |
! |
|
1820 |
||
1821 |
labels:aListOfLabels |
|
1822 |
"set the list of labels |
|
1823 |
" |
|
1824 |
^ self list:aListOfLabels |
|
1825 |
! |
|
1826 |
||
1827 |
labelsHolder |
|
1828 |
"get the model, which keeps the list of Tabs or Labels |
|
1829 |
" |
|
1830 |
^ self listHolder |
|
1831 |
! |
|
1832 |
||
1833 |
labelsHolder:aValueHolder |
|
1834 |
"set the model, which keeps the list of Tabs or Labels |
|
1835 |
" |
|
1836 |
self listHolder:aValueHolder. |
|
1837 |
! ! |
|
1838 |
||
1839 |
!NoteBookView methodsFor:'private'! |
|
1840 |
||
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1841 |
processAccessCharacter:aKey |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1842 |
"a character is pressed; check for tab identified y the character |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1843 |
select the tab and return true or if no tab detected return false |
1401 | 1844 |
" |
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1845 |
|j size char blck| |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1846 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1847 |
(aKey isCharacter and:[(size := list size) ~~ 0]) ifFalse:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1848 |
^ false |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1849 |
]. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1850 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1851 |
size == selection ifTrue:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1852 |
size == 1 ifTrue:[^ false]. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1853 |
j := 1 |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1854 |
] ifFalse:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1855 |
j := selection isNil ifTrue:[1] ifFalse:[selection + 1] |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1856 |
]. |
1401 | 1857 |
|
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1858 |
char := aKey asLowercase. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1859 |
blck := [:i| ((list at:i) accessCharacter == char and:[self isSelectable:i]) ifTrue:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1860 |
self selection:i. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1861 |
^ true |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1862 |
] |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1863 |
]. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1864 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1865 |
j to:size do:blck. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1866 |
1 to:(j-1) do:blck. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1867 |
^ false |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1868 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1869 |
! |
1401 | 1870 |
|
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1871 |
processShortcutKey:aKey |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1872 |
"if there is a short-key for that character, process it |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1873 |
and return true. Otherwise, return false. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1874 |
" |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1875 |
|j k size rawKey blck| |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1876 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1877 |
(size := list size) == 0 ifTrue:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1878 |
^ false |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1879 |
]. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1880 |
rawKey := device keyboardMap keyAtValue:aKey ifAbsent:aKey. |
1401 | 1881 |
|
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1882 |
size == selection ifTrue:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1883 |
size == 1 ifTrue:[^ false]. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1884 |
j := 1 |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1885 |
] ifFalse:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1886 |
j := selection isNil ifTrue:[1] ifFalse:[selection + 1] |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1887 |
]. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1888 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1889 |
blck := [:i| k := (list at:i) shortcutKey. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1890 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1891 |
(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
|
1892 |
self selection:i. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1893 |
^ true |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1894 |
] |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1895 |
]. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1896 |
|
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1897 |
j to:size do:blck. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1898 |
1 to:(j-1) do:blck. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
1899 |
^ false |
1401 | 1900 |
! ! |
1901 |
||
1902 |
!NoteBookView methodsFor:'queries'! |
|
1903 |
||
1904 |
isEnabled |
|
1905 |
"returns enabled state |
|
1906 |
" |
|
1907 |
^ enabled |
|
1908 |
! |
|
1909 |
||
1910 |
isFirstTabInLine:aTab |
|
2279 | 1911 |
"returns true if the tab is the first tab in the line |
1912 |
used by drawing |
|
1913 |
" |
|
1914 |
|idx prevTab| |
|
1401 | 1915 |
|
1916 |
idx := list identityIndexOf:aTab. |
|
2279 | 1917 |
prevTab := list at:(idx - 1) ifAbsent:nil. |
1918 |
||
1919 |
^ prevTab isNil or:[prevTab lineNr ~~ aTab lineNr] |
|
1401 | 1920 |
! |
1921 |
||
1922 |
isHorizontal |
|
1923 |
"returns true in case of direction is #top or #bottom |
|
1924 |
" |
|
2279 | 1925 |
^ direction == #top or:[direction == #bottom] |
1401 | 1926 |
! |
1927 |
||
1928 |
isLastTabInLine:aTab |
|
2279 | 1929 |
"returns true if the tab is the last tab in the line |
1930 |
used by drawing |
|
1931 |
" |
|
1932 |
|index nextTab| |
|
1401 | 1933 |
|
2279 | 1934 |
index := list identityIndexOf:aTab. |
1935 |
nextTab := list at:(index + 1) ifAbsent:nil. |
|
1936 |
||
1937 |
^ nextTab isNil or:[nextTab lineNr ~~ aTab lineNr] |
|
1401 | 1938 |
! ! |
1939 |
||
1940 |
!NoteBookView methodsFor:'selection'! |
|
375 | 1941 |
|
1401 | 1942 |
isSelectable:anIndex |
1943 |
"returns true if tab at an index is selectable |
|
1944 |
" |
|
1945 |
(anIndex notNil and:[anIndex between:1 and:list size]) ifTrue:[ |
|
1946 |
(list at:anIndex) isEnabled ifTrue:[ |
|
1947 |
^ selectConditionBlock isNil ifTrue:[true] |
|
1948 |
ifFalse:[selectConditionBlock value:anIndex] |
|
1949 |
] |
|
1950 |
]. |
|
1951 |
^ false |
|
1952 |
! |
|
1953 |
||
1954 |
selectedTab |
|
1955 |
"returns the selected tab ot nil |
|
1956 |
" |
|
2279 | 1957 |
(selection notNil and:[selection ~~ 0]) ifTrue:[ |
1958 |
^ list at:selection ifAbsent:nil |
|
1959 |
]. |
|
1960 |
^ nil |
|
1401 | 1961 |
! |
1962 |
||
1963 |
selection |
|
1964 |
"return the selection or nil |
|
1965 |
" |
|
1966 |
selection isNil ifTrue:[ |
|
1967 |
^ useIndex ifTrue:[0] ifFalse:[nil] |
|
1968 |
]. |
|
2213 | 1969 |
^ useIndex ifTrue:[selection] ifFalse:[self selectedTab label] |
1401 | 1970 |
! |
1971 |
||
1972 |
selection:anIndexOrNil |
|
1973 |
"change the selection to index or nil. The model and/or actionBlock is notified |
|
1974 |
" |
|
1975 |
|oldSel| |
|
1976 |
||
1407 | 1977 |
anIndexOrNil ~~ selection ifTrue:[ |
1978 |
oldSel := selection. |
|
1979 |
self setSelection:anIndexOrNil. |
|
1980 |
oldSel ~~ selection ifTrue:[self selectionChanged] |
|
1981 |
] |
|
1401 | 1982 |
! |
1983 |
||
1984 |
selectionChanged |
|
1985 |
"selection has changed; raise notification |
|
1986 |
" |
|
1987 |
|sel| |
|
1988 |
||
1989 |
sel := self selection. |
|
1990 |
||
1991 |
model notNil ifTrue:[model value:sel]. |
|
1992 |
action notNil ifTrue:[action value:sel] |
|
1993 |
||
1994 |
! |
|
1995 |
||
1996 |
setSelection:anIndexOrNil |
|
1997 |
"change the selection to index or nil. No notifications are raised |
|
1998 |
" |
|
2215 | 1999 |
|newSel tappl model oldBounds newBounds| |
1401 | 2000 |
|
2001 |
newSel := self listIndexOf:anIndexOrNil. |
|
2002 |
||
2003 |
(newSel notNil and:[(self isSelectable:newSel) not]) ifTrue:[ |
|
2004 |
newSel := nil |
|
2005 |
]. |
|
2006 |
selection == newSel ifTrue:[^ self]. |
|
2007 |
||
2008 |
(shown and:[numberOfLines notNil]) ifFalse:[ |
|
2009 |
selection := newSel. |
|
2010 |
self invalidate |
|
2011 |
] ifTrue:[ |
|
2215 | 2012 |
oldBounds := newBounds := nil. |
2013 |
||
2014 |
selection ifNotNil:[ |
|
2015 |
oldBounds := self computeLayoutForTab:(self selectedTab) |
|
2016 |
]. |
|
1401 | 2017 |
selection := newSel. |
2215 | 2018 |
|
2019 |
selection ifNotNil:[ |
|
2020 |
newBounds := self computeLayoutForTab:(self selectedTab). |
|
2021 |
||
2022 |
(oldBounds notNil and:[newBounds intersects:oldBounds]) ifTrue:[ |
|
2023 |
oldBounds := oldBounds merge:newBounds. |
|
2024 |
newBounds := nil. |
|
2025 |
]. |
|
2026 |
]. |
|
2027 |
oldBounds ifNotNil:[ self invalidate:oldBounds ]. |
|
2028 |
newBounds ifNotNil:[ self invalidate:newBounds ]. |
|
1759 | 2029 |
]. |
2030 |
||
2031 |
(canvas notNil and:[(canvas objectAttributeAt:#isTabItem) == true]) ifTrue:[ |
|
2032 |
canvas unmap. |
|
2033 |
canvas := nil. |
|
2034 |
]. |
|
1724
6557e3112383
avoid redraw/resize if a tabItems label has changed,
Claus Gittinger <cg@exept.de>
parents:
1700
diff
changeset
|
2035 |
|
1759 | 2036 |
( selection notNil |
2213 | 2037 |
and:[(model := self selectedTab model) notNil |
1759 | 2038 |
and:[(tappl := model canvasView) notNil]] |
2039 |
) ifFalse:[ |
|
2040 |
^ self |
|
2041 |
]. |
|
2042 |
||
2043 |
canvasHolder notNil ifTrue:[ |
|
2044 |
canvasHolder value:tappl |
|
2045 |
] ifFalse:[ |
|
2046 |
self canvas:tappl |
|
2047 |
]. |
|
1401 | 2048 |
! ! |
2049 |
||
2050 |
!NoteBookView::Tab class methodsFor:'instance creation'! |
|
2051 |
||
2052 |
label:aLabel on:aGC |
|
2053 |
^ self basicNew label:aLabel on:aGC |
|
2054 |
||
2055 |
||
2056 |
! ! |
|
2057 |
||
2058 |
!NoteBookView::Tab methodsFor:'accessing'! |
|
2059 |
||
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2060 |
accessCharacter |
2279 | 2061 |
"returns the access character or nil |
2062 |
" |
|
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2063 |
^ accessCharacter |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2064 |
! |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2065 |
|
2288 | 2066 |
foregroundColor |
2067 |
"returns the foregroundColor or nil |
|
2068 |
" |
|
2069 |
model notNil ifTrue:[ |
|
2070 |
^ model foregroundColor |
|
2071 |
]. |
|
2072 |
^ nil |
|
2073 |
! |
|
2074 |
||
1401 | 2075 |
label |
2076 |
"returns my original label |
|
2077 |
" |
|
2078 |
^ label |
|
2079 |
||
2080 |
||
2081 |
! |
|
2082 |
||
2083 |
label:aLabel on:aGC |
|
2084 |
"initialize attributes |
|
2085 |
" |
|
1677 | 2086 |
label := aLabel. |
2087 |
model := (aLabel isKindOf:TabItem) ifTrue:[aLabel] ifFalse:[nil]. |
|
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2088 |
accessCharacter := nil. |
1677 | 2089 |
printableLabel := model notNil ifTrue:[model rawLabel] ifFalse:[aLabel]. |
1401 | 2090 |
|
2091 |
printableLabel notNil ifTrue:[ |
|
2092 |
printableLabel isImageOrForm ifTrue:[ |
|
2093 |
printableLabel := printableLabel onDevice:(aGC device) |
|
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2094 |
] ifFalse:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2095 |
printableLabel isString ifTrue:[ |
1677 | 2096 |
printableLabel := self resolveDisplayStringFor:printableLabel |
2097 |
] ifFalse:[ |
|
2098 |
printableLabel class == LabelAndIcon ifTrue:[ |
|
2099 |
printableLabel string:(self resolveDisplayStringFor:(printableLabel string)) |
|
2100 |
] |
|
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2101 |
]. |
375 | 2102 |
] |
1401 | 2103 |
] ifFalse:[ |
2104 |
printableLabel := '' |
|
2105 |
]. |
|
2106 |
extent := (printableLabel widthOn:aGC) @ (printableLabel heightOn:aGC). |
|
2107 |
||
2108 |
! |
|
2109 |
||
2110 |
lineNr |
|
2279 | 2111 |
"get the line number within the noteBook view |
2112 |
1 -> on top of the wizard |
|
1401 | 2113 |
" |
2114 |
^ lineNr |
|
2115 |
! |
|
2116 |
||
2117 |
lineNr:aLineNr |
|
2279 | 2118 |
"set the line number within the noteBook view |
2119 |
1 -> on top of the wizard |
|
1401 | 2120 |
" |
2121 |
lineNr := aLineNr |
|
2122 |
! |
|
2123 |
||
1759 | 2124 |
model |
2125 |
"returns the model, a TabItem or nil |
|
2126 |
" |
|
2127 |
^ model |
|
2128 |
! |
|
2129 |
||
1401 | 2130 |
printableLabel |
2131 |
"get my printable label |
|
2132 |
" |
|
2133 |
^ printableLabel |
|
2134 |
||
2135 |
! |
|
2136 |
||
1672
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2137 |
shortcutKey |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2138 |
"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
|
2139 |
" |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2140 |
model notNil ifTrue:[ |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2141 |
^ model shortcutKey |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2142 |
]. |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2143 |
^ nil |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2144 |
! |
31dcb579f88a
support accelerator and accessCharacter (position or &)
ca
parents:
1663
diff
changeset
|
2145 |
|
1401 | 2146 |
string |
2147 |
"access the printable string used for steping through a list |
|
2148 |
searching for an entry starting with a character. |
|
2149 |
" |
|
2150 |
^ printableLabel perform:#string ifNotUnderstood:nil |
|
2151 |
||
2152 |
! ! |
|
2153 |
||
1818 | 2154 |
!NoteBookView::Tab methodsFor:'accessing-dimensions'! |
1401 | 2155 |
|
2156 |
extent |
|
2279 | 2157 |
"returns the extent of the label, the minimum size required by the tab |
1401 | 2158 |
" |
2159 |
^ extent |
|
2160 |
! |
|
2161 |
||
2162 |
layout |
|
2279 | 2163 |
"get the tab's layout, set by the noteBook view |
1401 | 2164 |
" |
2165 |
^ layout |
|
2166 |
! |
|
2167 |
||
2168 |
layout:aLayout |
|
2169 |
"set the tab's layout |
|
2170 |
" |
|
2171 |
layout := aLayout |
|
2172 |
||
2173 |
||
2174 |
! |
|
2175 |
||
2176 |
preferredExtentX |
|
2177 |
"returns my preferred extent x |
|
2178 |
" |
|
2278 | 2179 |
^ 2 + extent x |
1401 | 2180 |
! |
2181 |
||
2182 |
preferredExtentY |
|
2183 |
"returns my preferred extent y |
|
2184 |
" |
|
2278 | 2185 |
^ 2 + extent y |
1401 | 2186 |
! ! |
2187 |
||
1818 | 2188 |
!NoteBookView::Tab methodsFor:'accessing-mvc'! |
1401 | 2189 |
|
2190 |
addDependent:aGC |
|
2191 |
"make the noteBook be a dependent of the tab model |
|
2192 |
" |
|
1759 | 2193 |
model notNil ifTrue:[ |
2194 |
model addDependent:aGC |
|
2195 |
] |
|
1401 | 2196 |
|
2197 |
||
2198 |
! |
|
2199 |
||
2200 |
removeDependent:aGC |
|
2201 |
"make the noteBook be independent of the tab model |
|
2202 |
" |
|
1759 | 2203 |
model notNil ifTrue:[ |
2204 |
model destroyCanvas. |
|
2205 |
model removeDependent:aGC. |
|
2206 |
] |
|
1401 | 2207 |
|
2208 |
||
2209 |
! ! |
|
2210 |
||
2211 |
!NoteBookView::Tab methodsFor:'drawing'! |
|
2212 |
||
2288 | 2213 |
displayOn:aGC inset:inset direction:aDirection |
1401 | 2214 |
"redraw tab |
2215 |
" |
|
2288 | 2216 |
|dispObj lft wdt top hgt |
1401 | 2217 |
y "{ Class:SmallInteger }" |
2218 |
x "{ Class:SmallInteger }" |
|
2219 |
| |
|
2220 |
||
2221 |
"/ REDRAW LABEL |
|
2222 |
(aGC isEnabled and:[self isEnabled]) ifTrue:[ |
|
2223 |
dispObj := printableLabel. |
|
2224 |
] ifFalse:[ |
|
2225 |
(dispObj := disabledLabel) isNil ifTrue:[ |
|
2226 |
(dispObj := printableLabel) isImageOrForm ifTrue:[ |
|
2227 |
disabledLabel := printableLabel lightened onDevice:(aGC device) |
|
375 | 2228 |
] |
1401 | 2229 |
] |
2230 |
]. |
|
1442 | 2231 |
|
1401 | 2232 |
(aDirection == #top or:[aDirection == #bottom]) ifTrue:[ |
2288 | 2233 |
lft := layout left + inset. |
2234 |
wdt := layout right - inset - lft. |
|
2235 |
wdt > 4 ifFalse:[^ self]. |
|
2236 |
||
2237 |
x := (wdt - extent x) // 2. |
|
2238 |
x < 0 ifTrue:[ |
|
2239 |
dispObj := '...'. |
|
2240 |
x := 0. |
|
2241 |
]. |
|
2242 |
x := x + lft. |
|
2243 |
y := layout top + (layout height - inset - extent y // 2). |
|
2244 |
||
2245 |
aDirection == #top ifTrue:[ y := y + inset ]. |
|
1401 | 2246 |
|
2247 |
dispObj isImageOrForm ifFalse:[ |
|
2248 |
y := y + aGC font ascent |
|
1683 | 2249 |
]. |
2283 | 2250 |
dispObj displayOn:aGC x:x y:y. |
2251 |
^ self |
|
2252 |
]. |
|
2288 | 2253 |
top := layout top + inset. |
2254 |
hgt := layout bottom - inset - top. |
|
2255 |
hgt > 4 ifFalse:[^ self]. |
|
2256 |
||
2257 |
y := (hgt - extent x) // 2. |
|
2258 |
y < 0 ifTrue:[ |
|
2259 |
dispObj := '...'. |
|
2260 |
y := 0. |
|
2261 |
]. |
|
2262 |
y := y + top. |
|
2263 |
x := layout left + (layout width - inset - extent y // 2). |
|
2264 |
||
2265 |
aDirection == #left ifTrue:[ x := x + inset ]. |
|
2283 | 2266 |
|
2267 |
dispObj isImageOrForm ifFalse:[ |
|
2268 |
dispObj isString ifTrue:[ |
|
2269 |
x := x + aGC font descent. |
|
1683 | 2270 |
]. |
2283 | 2271 |
"/ workaround for a bug in display-with-angle, |
2272 |
"/ iff displayed string is a labelAndIcon. |
|
2273 |
"/ (In this case, display is always opaque, and the current |
|
2274 |
"/ backgroundPaint color is used to fill the underlying rectangle) |
|
2275 |
"/ |
|
2276 |
aGC backgroundPaint:aGC backgroundColor. |
|
2277 |
aGC displayString:dispObj x:x y:y angle:90. |
|
2278 |
] ifTrue:[ |
|
2279 |
(dispObj rotated:90) displayOn:aGC x:x y:y. |
|
2280 |
]. |
|
375 | 2281 |
! ! |
2282 |
||
1677 | 2283 |
!NoteBookView::Tab methodsFor:'private'! |
2284 |
||
2285 |
resolveDisplayStringFor:aString |
|
2286 |
|string size rest pos idx| |
|
2287 |
||
2288 |
size := aString size. |
|
2289 |
string := aString. |
|
2290 |
pos := 0. |
|
2291 |
||
2292 |
size > 1 ifTrue:[ |
|
2293 |
(model notNil and:[(pos := model accessCharacterPosition) ~~ 0]) ifTrue:[ |
|
2294 |
pos > size ifTrue:[pos := 0] |
|
2295 |
] ifFalse:[ |
|
2296 |
idx := 1. |
|
2297 |
||
2298 |
[((idx := string indexOf:$& startingAt:idx) ~~ 0 and:[idx < size])] whileTrue:[ |
|
2299 |
rest := string copyFrom:(idx+1). |
|
2300 |
||
2301 |
idx == 1 ifTrue:[string := rest] |
|
2302 |
ifFalse:[string := (string copyFrom:1 to:(idx-1)), rest]. |
|
2303 |
||
2304 |
(string at:idx) == $& ifTrue:[idx := idx + 1] |
|
2305 |
ifFalse:[pos := idx]. |
|
2306 |
size := size - 1. |
|
2307 |
] |
|
2308 |
] |
|
2309 |
]. |
|
2310 |
size ~~ 0 ifTrue:[ |
|
2311 |
pos == 0 ifTrue:[ |
|
2312 |
pos := 1 |
|
2313 |
] ifFalse:[ |
|
2314 |
string isText ifFalse:[ |
|
2315 |
string := Text string:string |
|
2316 |
]. |
|
2317 |
string emphasisAt:pos add:#underline |
|
2318 |
]. |
|
2319 |
accessCharacter := (string at:pos) asLowercase |
|
2320 |
] ifFalse:[ |
|
2321 |
accessCharacter := nil |
|
2322 |
]. |
|
2323 |
^ string |
|
2324 |
! ! |
|
2325 |
||
1401 | 2326 |
!NoteBookView::Tab methodsFor:'testing'! |
375 | 2327 |
|
1401 | 2328 |
containsPointX:x y:y |
2329 |
"return true, if the point defined by x@y is contained in the tab. |
|
375 | 2330 |
" |
2279 | 2331 |
layout isNil ifTrue:[^ false]. |
2332 |
^ layout containsPointX:x y:y |
|
375 | 2333 |
! |
2334 |
||
1401 | 2335 |
intersects:aRectangle |
2336 |
"return true, if the intersection between the argument, aRectangle |
|
2337 |
and the tab is not empty |
|
375 | 2338 |
" |
2279 | 2339 |
layout isNil ifTrue:[^ false]. |
2340 |
^ layout intersects:aRectangle |
|
1401 | 2341 |
! |
432 | 2342 |
|
1401 | 2343 |
isEnabled |
2344 |
"returne true if no model exists or the model is enabled |
|
2345 |
" |
|
2346 |
^ (model isNil or:[model isEnabled]) |
|
375 | 2347 |
|
355 | 2348 |
|
386 | 2349 |
! ! |
2350 |
||
355 | 2351 |
!NoteBookView class methodsFor:'documentation'! |
2352 |
||
2353 |
version |
|
2288 | 2354 |
^ '$Header: /cvs/stx/stx/libwidg2/NoteBookView.st,v 1.70 2002-10-14 07:01:38 ca Exp $' |
355 | 2355 |
! ! |