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