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