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