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