696
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1997 by eXept Software AG
|
|
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 |
|
696
|
16 |
Model subclass:#TabItem
|
1759
|
17 |
instanceVariableNames:'rawLabel label enabled argument canvas adornments activeHelpText'
|
696
|
18 |
classVariableNames:''
|
|
19 |
poolDictionaries:''
|
|
20 |
category:'Views-Support'
|
|
21 |
!
|
|
22 |
|
|
23 |
!TabItem class methodsFor:'documentation'!
|
|
24 |
|
|
25 |
copyright
|
|
26 |
"
|
|
27 |
COPYRIGHT (c) 1997 by eXept Software AG
|
|
28 |
All Rights Reserved
|
|
29 |
|
|
30 |
This software is furnished under a license and may be used
|
|
31 |
only in accordance with the terms of that license and with the
|
|
32 |
inclusion of the above copyright notice. This software may not
|
|
33 |
be provided or otherwise made available to, or used by, any
|
|
34 |
other person. No title to or ownership of the software is
|
|
35 |
hereby transferred.
|
|
36 |
"
|
|
37 |
|
|
38 |
!
|
|
39 |
|
|
40 |
documentation
|
|
41 |
"
|
|
42 |
describes one tab entry; could be used for tabs instead of a string. Whenever
|
|
43 |
a value changed, a change notification is raised
|
|
44 |
|
|
45 |
[see also:]
|
|
46 |
TabItemEditor
|
|
47 |
TabView
|
|
48 |
NoteBookView
|
|
49 |
UIPainter
|
|
50 |
|
|
51 |
[author:]
|
|
52 |
Claus Atzkern
|
|
53 |
"
|
|
54 |
|
|
55 |
|
|
56 |
!
|
|
57 |
|
|
58 |
examples
|
|
59 |
"
|
|
60 |
labels derived from item
|
|
61 |
[exBegin]
|
|
62 |
|top tab|
|
|
63 |
|
|
64 |
top := StandardSystemView new label:'tabs at top'; extent:250@100.
|
|
65 |
tab := TabView origin:0.0 @ 0.0 corner:1.0 @ 0.5 in:top.
|
|
66 |
|
|
67 |
tab direction:#top.
|
|
68 |
tab list:(#( 'Foo' 'Bar' 'Baz' ) collect:[:l| TabItem label:l ]).
|
|
69 |
tab action:[:aName|Transcript showCR:aName].
|
|
70 |
top open.
|
|
71 |
[exEnd]
|
|
72 |
|
|
73 |
|
|
74 |
testing tab configuration and change notifications
|
|
75 |
[exBegin]
|
|
76 |
|top tab list idx label|
|
|
77 |
|
|
78 |
top := StandardSystemView new label:'tabs at top'; extent:250@100.
|
|
79 |
tab := TabView origin:0.0 @ 0.0 corner:1.0 @ 0.5 in:top.
|
|
80 |
|
|
81 |
tab direction:#top.
|
|
82 |
list := (#( 'Foo' 'Bar' 'Baz' ) collect:[:l| TabItem label:l ]).
|
|
83 |
tab list:list.
|
|
84 |
tab action:[:aName|Transcript showCR:aName].
|
|
85 |
top openAndWait.
|
|
86 |
|
|
87 |
[
|
|
88 |
idx := 0.
|
|
89 |
label := LabelAndIcon icon:(Image fromFile:('xpmBitmaps/document_images/tiny_yellow_dir.xpm' ))
|
|
90 |
string:'Test Tab'.
|
|
91 |
|
|
92 |
[top shown] whileTrue:[
|
|
93 |
|aTab lbl|
|
|
94 |
|
|
95 |
(idx := idx + 1) > list size ifTrue:[idx := 1].
|
|
96 |
|
|
97 |
aTab := list at:idx.
|
|
98 |
lbl := aTab label.
|
|
99 |
|
|
100 |
Delay waitForSeconds:0.5. aTab label:label.
|
|
101 |
Delay waitForSeconds:0.5. aTab enabled:false.
|
|
102 |
Delay waitForSeconds:0.5. aTab enabled:true.
|
|
103 |
Delay waitForSeconds:0.5. aTab foregroundColor:(Color red).
|
|
104 |
Delay waitForSeconds:0.5. aTab foregroundColor:nil.
|
|
105 |
aTab label:lbl.
|
|
106 |
]
|
|
107 |
] forkAt:1.
|
|
108 |
[exEnd]
|
|
109 |
|
|
110 |
"
|
|
111 |
! !
|
|
112 |
|
|
113 |
!TabItem class methodsFor:'instance creation'!
|
|
114 |
|
|
115 |
label:aLabel
|
|
116 |
^ self new label:aLabel
|
|
117 |
!
|
|
118 |
|
|
119 |
new
|
|
120 |
^ self basicNew initialize
|
|
121 |
! !
|
|
122 |
|
1759
|
123 |
!TabItem class methodsFor:'tests'!
|
|
124 |
|
|
125 |
test
|
|
126 |
|top tab list item|
|
|
127 |
|
|
128 |
top := StandardSystemView new label:'tabs at top'; extent:400@400.
|
|
129 |
tab := NoteBookView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
|
|
130 |
|
|
131 |
tab direction:#top.
|
|
132 |
list := #( 'Foo' 'Bar' 'Baz' ) collect:[:l| TabItem label:l ].
|
|
133 |
item := list at:1.
|
|
134 |
item majorKey:ClockView.
|
|
135 |
item := list at:2.
|
|
136 |
item majorKey:CodingExamples_GUI::GUIDemoNoteBook.
|
|
137 |
|
|
138 |
item := list at:3.
|
|
139 |
item majorKey:CodingExamples_GUI::GUIDemoMenu.
|
|
140 |
|
|
141 |
tab list:list.
|
|
142 |
top open.
|
|
143 |
! !
|
|
144 |
|
696
|
145 |
!TabItem methodsFor:'accessing'!
|
|
146 |
|
1671
|
147 |
accessCharacterPosition
|
|
148 |
"get the index of the access character in the label text or string, or 0 if none
|
|
149 |
"
|
1759
|
150 |
^ self adornmentAt:#accessCharacterPosition ifAbsent:0
|
1671
|
151 |
!
|
|
152 |
|
1759
|
153 |
accessCharacterPosition:anIndex
|
1671
|
154 |
"get the index of the access character in the label text or string, or 0 if none
|
|
155 |
"
|
1759
|
156 |
|idx|
|
|
157 |
|
|
158 |
anIndex ~~ 0 ifTrue:[
|
|
159 |
idx := anIndex
|
|
160 |
].
|
|
161 |
self adornmentAt:#accessCharacterPosition put:idx
|
1671
|
162 |
!
|
|
163 |
|
716
|
164 |
argument
|
|
165 |
"returns a user defined argument or nil
|
|
166 |
"
|
|
167 |
^ argument
|
|
168 |
!
|
|
169 |
|
|
170 |
argument:anArgument
|
|
171 |
"set a user defined argument
|
|
172 |
"
|
1674
|
173 |
(anArgument isString and:[anArgument isEmpty]) ifTrue:[
|
|
174 |
argument := nil
|
|
175 |
] ifFalse:[
|
|
176 |
argument := anArgument
|
|
177 |
].
|
716
|
178 |
argument := anArgument
|
|
179 |
!
|
|
180 |
|
1759
|
181 |
createNewBuilder
|
|
182 |
"returns true if a new builder is used to create the canvas;
|
|
183 |
the default is true
|
|
184 |
"
|
|
185 |
^ self adornmentAt:#createNewBuilder ifAbsent:true
|
|
186 |
|
|
187 |
!
|
|
188 |
|
|
189 |
createNewBuilder:aBool
|
|
190 |
"returns true if a new builder is used to create the canvas;
|
|
191 |
the default is true
|
|
192 |
"
|
|
193 |
|flag|
|
|
194 |
|
|
195 |
aBool == false ifTrue:[
|
|
196 |
flag := false
|
|
197 |
].
|
|
198 |
^ self adornmentAt:#createNewBuilder put:flag
|
|
199 |
|
|
200 |
!
|
|
201 |
|
696
|
202 |
enabled
|
|
203 |
"get the enabled state of the tab
|
|
204 |
"
|
|
205 |
^ enabled ? true
|
|
206 |
!
|
|
207 |
|
|
208 |
enabled:aState
|
|
209 |
"set the enabled state of the tab
|
|
210 |
"
|
|
211 |
|s|
|
|
212 |
|
|
213 |
s := aState ? true.
|
|
214 |
|
|
215 |
self enabled ~~ s ifTrue:[
|
|
216 |
enabled := s.
|
|
217 |
self changed:#enabled
|
|
218 |
]
|
|
219 |
!
|
|
220 |
|
|
221 |
foregroundColor
|
|
222 |
"get the label color or nil
|
|
223 |
"
|
1759
|
224 |
^ self adornmentAt:#foregroundColor
|
696
|
225 |
!
|
|
226 |
|
|
227 |
foregroundColor:aColor
|
|
228 |
"set the label color or nil
|
|
229 |
"
|
1759
|
230 |
self foregroundColor ~= aColor ifTrue:[
|
|
231 |
self adornmentAt:#foregroundColor put:aColor.
|
696
|
232 |
self changed:#foregroundColor
|
1759
|
233 |
].
|
696
|
234 |
!
|
|
235 |
|
|
236 |
label
|
|
237 |
"get the label or selector to access a label/bitmap. To get the label to be shown
|
|
238 |
use: #rawLabel
|
|
239 |
"
|
|
240 |
^ label
|
|
241 |
!
|
|
242 |
|
|
243 |
label:aLabel
|
|
244 |
"set the label or selector to access the label/bitmap
|
|
245 |
"
|
|
246 |
label := aLabel.
|
|
247 |
|
|
248 |
aLabel = rawLabel ifFalse:[
|
|
249 |
rawLabel := aLabel.
|
|
250 |
self changed
|
|
251 |
]
|
|
252 |
!
|
|
253 |
|
|
254 |
labelForegroundColor
|
|
255 |
"get the label color or nil
|
|
256 |
"
|
|
257 |
^ self foregroundColor
|
|
258 |
!
|
|
259 |
|
|
260 |
labelForegroundColor:aColor
|
|
261 |
"set the label color or nil
|
|
262 |
"
|
|
263 |
self foregroundColor:aColor
|
1671
|
264 |
!
|
|
265 |
|
|
266 |
shortcutKey
|
|
267 |
"get the key to press to select the tab item from the keyboard; a symbol or nil
|
|
268 |
"
|
1759
|
269 |
^ self adornmentAt:#shortcutKey
|
1671
|
270 |
!
|
|
271 |
|
|
272 |
shortcutKey:aKeyOrNil
|
|
273 |
"set the key to press to select the tab item from the keyboard; a symbol or nil
|
|
274 |
"
|
1759
|
275 |
|key|
|
|
276 |
|
|
277 |
aKeyOrNil size ~~ 0 ifTrue:[
|
|
278 |
key := aKeyOrNil asSymbol
|
|
279 |
].
|
|
280 |
self adornmentAt:#shortcutKey put:key
|
|
281 |
|
|
282 |
|
|
283 |
! !
|
|
284 |
|
|
285 |
!TabItem methodsFor:'accessing canvas'!
|
|
286 |
|
|
287 |
canvas
|
|
288 |
"returns the application or nil
|
|
289 |
"
|
|
290 |
|view cls wsel ckey builder|
|
|
291 |
|
|
292 |
canvas notNil ifTrue:[
|
|
293 |
^ canvas
|
|
294 |
].
|
|
295 |
|
|
296 |
(ckey := self majorKey) notNil ifTrue:[
|
|
297 |
(cls := Smalltalk resolveName:ckey inClass:self class) isNil ifTrue:[
|
|
298 |
self majorKey:nil.
|
|
299 |
].
|
|
300 |
canvas := cls new.
|
|
301 |
|
|
302 |
(canvas isKindOf:ApplicationModel) ifTrue:[
|
|
303 |
view := SimpleView new.
|
|
304 |
wsel := self minorKey ? #windowSpec.
|
|
305 |
builder := self adornmentAt:#builder ifAbsent:[ canvas createBuilder. canvas builder ].
|
|
306 |
view client:canvas spec:wsel builder:builder.
|
|
307 |
canvas window:(self setupCanvasView:view).
|
|
308 |
] ifFalse:[
|
|
309 |
canvas := self setupCanvasView:canvas
|
|
310 |
].
|
|
311 |
].
|
|
312 |
^ canvas
|
|
313 |
!
|
|
314 |
|
|
315 |
canvasView
|
|
316 |
"returns the view the canvas is running in or nil if no canvas
|
|
317 |
specified or not yet created
|
|
318 |
"
|
|
319 |
|canvas|
|
|
320 |
|
|
321 |
(canvas := self canvas) notNil ifTrue:[
|
|
322 |
^ canvas perform:#window ifNotUnderstood:[canvas]
|
|
323 |
].
|
|
324 |
^ nil
|
|
325 |
!
|
|
326 |
|
|
327 |
destroyCanvas
|
|
328 |
|
|
329 |
canvas notNil ifTrue:[
|
|
330 |
self canvasView destroy.
|
|
331 |
canvas := nil
|
|
332 |
].
|
|
333 |
!
|
|
334 |
|
|
335 |
majorKey
|
|
336 |
^ self adornmentAt:#majorKey
|
|
337 |
!
|
|
338 |
|
|
339 |
majorKey:aMajorKey
|
|
340 |
|key|
|
|
341 |
|
|
342 |
aMajorKey notNil ifTrue:[
|
|
343 |
aMajorKey isBehavior ifTrue:[
|
|
344 |
key := aMajorKey name asSymbol
|
|
345 |
] ifFalse:[
|
|
346 |
aMajorKey size ~~ 0 ifTrue:[
|
|
347 |
key := aMajorKey asSymbol
|
|
348 |
]
|
|
349 |
]
|
|
350 |
].
|
|
351 |
|
|
352 |
self majorKey ~~ key ifTrue:[
|
|
353 |
self destroyCanvas
|
|
354 |
].
|
|
355 |
self adornmentAt:#majorKey put:key.
|
|
356 |
!
|
|
357 |
|
|
358 |
minorKey
|
|
359 |
^ self adornmentAt:#minorKey
|
|
360 |
!
|
|
361 |
|
|
362 |
minorKey:aMinorKey
|
|
363 |
self adornmentAt:#minorKey put:aMinorKey.
|
|
364 |
!
|
1671
|
365 |
|
1759
|
366 |
setupCanvasView:aView
|
|
367 |
|frame isV isH auto|
|
|
368 |
|
|
369 |
isH := self hasHorizontalScrollBar.
|
|
370 |
isV := self hasVerticalScrollBar.
|
|
371 |
|
|
372 |
(isH or:[isV]) ifFalse:[
|
|
373 |
frame := aView
|
|
374 |
] ifTrue:[
|
|
375 |
frame := ScrollableView for:ViewScroller.
|
|
376 |
|
|
377 |
frame horizontalScrollable:isH.
|
|
378 |
frame verticalScrollable:isV.
|
|
379 |
|
|
380 |
isH ifTrue:[frame horizontalMini:(self miniScrollerHorizontal)].
|
|
381 |
isV ifTrue:[frame verticalMini:(self miniScrollerVertical)].
|
|
382 |
|
|
383 |
(auto := self autoHideScrollBars) notNil ifTrue:[
|
|
384 |
frame autoHideScrollBars:auto
|
|
385 |
].
|
|
386 |
frame scrolledView scrolledView:aView.
|
|
387 |
].
|
|
388 |
frame objectAttributeAt:#isTabItem put:true.
|
|
389 |
^ frame
|
|
390 |
! !
|
|
391 |
|
|
392 |
!TabItem methodsFor:'accessing scrolling'!
|
|
393 |
|
|
394 |
autoHideScrollBars
|
|
395 |
^ self adornmentAt:#autoHideScrollBars
|
|
396 |
!
|
|
397 |
|
|
398 |
autoHideScrollBars:aBoolOrNil
|
|
399 |
self adornmentAt:#autoHideScrollBars put:aBoolOrNil
|
|
400 |
|
|
401 |
!
|
|
402 |
|
|
403 |
hasHorizontalScrollBar
|
|
404 |
^ self adornmentAt:#hasHorizontalScrollBar ifAbsent:false
|
|
405 |
|
|
406 |
!
|
|
407 |
|
|
408 |
hasHorizontalScrollBar:aBool
|
|
409 |
|flag|
|
|
410 |
|
|
411 |
aBool == true ifTrue:[flag := true]
|
|
412 |
ifFalse:[self miniScrollerHorizontal:false].
|
|
413 |
|
|
414 |
self adornmentAt:#hasHorizontalScrollBar put:flag
|
|
415 |
|
|
416 |
!
|
|
417 |
|
|
418 |
hasVerticalScrollBar
|
|
419 |
^ self adornmentAt:#hasVerticalScrollBar ifAbsent:false
|
|
420 |
|
|
421 |
!
|
|
422 |
|
|
423 |
hasVerticalScrollBar:aBool
|
|
424 |
|flag|
|
|
425 |
|
|
426 |
aBool == true ifTrue:[flag := true]
|
|
427 |
ifFalse:[self miniScrollerVertical:false].
|
|
428 |
|
|
429 |
self adornmentAt:#hasVerticalScrollBar put:flag
|
|
430 |
|
|
431 |
!
|
|
432 |
|
|
433 |
miniScrollerHorizontal
|
|
434 |
^ self adornmentAt:#miniScrollerHorizontal ifAbsent:false
|
|
435 |
|
|
436 |
!
|
|
437 |
|
|
438 |
miniScrollerHorizontal:aBool
|
|
439 |
|flag|
|
|
440 |
|
|
441 |
aBool == true ifTrue:[
|
|
442 |
flag := true
|
|
443 |
].
|
|
444 |
self adornmentAt:#miniScrollerHorizontal put:flag
|
|
445 |
|
|
446 |
!
|
|
447 |
|
|
448 |
miniScrollerVertical
|
|
449 |
^ self adornmentAt:#miniScrollerVertical ifAbsent:false
|
|
450 |
|
|
451 |
!
|
|
452 |
|
|
453 |
miniScrollerVertical:aBool
|
|
454 |
|flag|
|
|
455 |
|
|
456 |
aBool == true ifTrue:[
|
|
457 |
flag := true
|
|
458 |
].
|
|
459 |
self adornmentAt:#miniScrollerVertical put:flag
|
1671
|
460 |
|
696
|
461 |
! !
|
|
462 |
|
|
463 |
!TabItem methodsFor:'building'!
|
|
464 |
|
716
|
465 |
editAgument
|
|
466 |
"used by TabItemEditor to get the argument
|
|
467 |
"
|
|
468 |
^ argument isSymbol ifTrue:['#', argument] ifFalse:[argument]
|
|
469 |
!
|
|
470 |
|
|
471 |
editAgument:anArgument
|
|
472 |
"used by TabItemEditor to set the argument
|
|
473 |
"
|
|
474 |
|arg size|
|
|
475 |
|
|
476 |
anArgument size ~~ 0 ifTrue:[
|
|
477 |
argument := anArgument withoutSeparators.
|
|
478 |
|
|
479 |
(size := argument size) == 0 ifTrue:[
|
|
480 |
argument := nil
|
|
481 |
] ifFalse:[
|
|
482 |
(argument startsWith:$#) ifTrue:[
|
|
483 |
size > 1 ifTrue:[
|
|
484 |
argument := (argument copyFrom:2) asSymbol
|
|
485 |
] ifFalse:[
|
|
486 |
argument := nil
|
|
487 |
]
|
|
488 |
]
|
|
489 |
]
|
|
490 |
] ifFalse:[
|
|
491 |
argument := nil
|
|
492 |
]
|
|
493 |
!
|
|
494 |
|
696
|
495 |
rawLabel
|
|
496 |
"returns the label to be shown
|
|
497 |
"
|
|
498 |
^ rawLabel ? ' '
|
|
499 |
|
|
500 |
|
|
501 |
!
|
|
502 |
|
702
|
503 |
setAttributesFromClass:aClass
|
|
504 |
"setup attributes from class
|
|
505 |
"
|
|
506 |
(aClass notNil and:[self translateLabel and:[label isString]]) ifTrue:[
|
|
507 |
Object messageNotUnderstoodSignal handle:[:ex|
|
|
508 |
rawLabel := nil
|
|
509 |
] do:[
|
|
510 |
rawLabel := aClass perform:(label asSymbol)
|
|
511 |
].
|
|
512 |
rawLabel notNil ifTrue:[^ rawLabel ]
|
|
513 |
].
|
|
514 |
rawLabel := label printString
|
|
515 |
!
|
|
516 |
|
696
|
517 |
setAttributesWithBuilder:aBuilder
|
|
518 |
"setup attributes dependent on the builder
|
|
519 |
"
|
1759
|
520 |
|appl key builder |
|
|
521 |
|
|
522 |
self createNewBuilder ifFalse:[builder := aBuilder].
|
|
523 |
self adornmentAt:#builder put:builder.
|
|
524 |
|
696
|
525 |
(self translateLabel and:[label isString]) ifTrue:[
|
|
526 |
rawLabel := aBuilder labelFor:(label asSymbol).
|
1759
|
527 |
].
|
696
|
528 |
|
1759
|
529 |
rawLabel isNil ifTrue:[
|
|
530 |
rawLabel := label printString.
|
696
|
531 |
].
|
1759
|
532 |
|
|
533 |
(aBuilder isEditing or:[(appl := aBuilder application) isNil]) ifFalse:[
|
|
534 |
(key := self activeHelpKey) notNil ifTrue:[
|
|
535 |
activeHelpText := appl helpTextForKey:key.
|
|
536 |
].
|
|
537 |
|
|
538 |
(self majorKey isNil and:[(key := self minorKey) notNil]) ifTrue:[
|
|
539 |
canvas := SimpleView new.
|
|
540 |
canvas client:appl spec:key.
|
|
541 |
canvas := self setupCanvasView:canvas.
|
|
542 |
]
|
|
543 |
].
|
|
544 |
|
696
|
545 |
!
|
|
546 |
|
|
547 |
translateLabel
|
|
548 |
"returns true if the label derives from the application
|
|
549 |
"
|
1759
|
550 |
^ self adornmentAt:#translateLabel ifAbsent:false
|
696
|
551 |
!
|
|
552 |
|
|
553 |
translateLabel:aBool
|
|
554 |
"returns true if the label derives from the application
|
|
555 |
"
|
1759
|
556 |
|flag|
|
|
557 |
|
|
558 |
aBool == true ifTrue:[
|
|
559 |
flag := true.
|
|
560 |
].
|
1760
|
561 |
^ self adornmentAt:#translateLabel put:flag
|
696
|
562 |
! !
|
|
563 |
|
|
564 |
!TabItem methodsFor:'converting'!
|
|
565 |
|
|
566 |
fromLiteralArrayEncoding:aLiteralEncodedArray
|
|
567 |
"read my contents from a aLiteralEncodedArray
|
|
568 |
"
|
|
569 |
2 to:aLiteralEncodedArray size by:2 do:[:i |
|
|
570 |
|selector value|
|
|
571 |
|
|
572 |
selector := aLiteralEncodedArray at:i.
|
1759
|
573 |
|
696
|
574 |
(self respondsTo:selector) ifTrue:[
|
1759
|
575 |
value := (aLiteralEncodedArray at:i+1) decodeAsLiteralArray.
|
696
|
576 |
self perform:selector with:value
|
|
577 |
]
|
|
578 |
].
|
|
579 |
|
|
580 |
|
|
581 |
"
|
|
582 |
|
|
583 |
#(#TabItem
|
|
584 |
#label: 'claus'
|
|
585 |
#foregroundColor: #(#Color 0.0 0.0 100.0)
|
|
586 |
#enabled: false
|
|
587 |
|
|
588 |
) decodeAsLiteralArray
|
|
589 |
|
|
590 |
|
|
591 |
"
|
|
592 |
|
|
593 |
|
|
594 |
!
|
|
595 |
|
|
596 |
literalArrayEncoding
|
|
597 |
"return myself encoded as a literal array
|
|
598 |
"
|
|
599 |
|coll val|
|
|
600 |
|
|
601 |
coll := OrderedCollection new.
|
|
602 |
coll add:#TabItem.
|
|
603 |
coll add:#label: ; add:(label literalArrayEncoding).
|
|
604 |
|
|
605 |
self enabled ifFalse:[
|
1671
|
606 |
coll add:#enabled: ; add:false.
|
696
|
607 |
].
|
|
608 |
|
716
|
609 |
argument notNil ifTrue:[
|
|
610 |
coll add:#argument: ; add:(argument literalArrayEncoding).
|
|
611 |
].
|
|
612 |
|
1759
|
613 |
adornments size ~~ 0 ifTrue:[
|
|
614 |
adornments keysAndValuesDo:[:key :val|
|
|
615 |
key ~~ #builder ifTrue:[
|
|
616 |
coll add:((key, ':') asSymbol).
|
|
617 |
coll add:(val literalArrayEncoding).
|
|
618 |
]
|
|
619 |
]
|
|
620 |
].
|
|
621 |
|
|
622 |
^ coll asArray
|
696
|
623 |
"
|
|
624 |
|
|
625 |
#(#TabItem
|
|
626 |
#label: 'claus'
|
|
627 |
#translateLabel: true
|
|
628 |
#foregroundColor: #(#Color 0.0 0.0 100.0)
|
|
629 |
#enabled: false
|
|
630 |
|
|
631 |
) decodeAsLiteralArray literalArrayEncoding
|
|
632 |
|
|
633 |
"
|
|
634 |
! !
|
|
635 |
|
1759
|
636 |
!TabItem methodsFor:'displaying'!
|
|
637 |
|
|
638 |
displayOn:aGC x:x y:y
|
|
639 |
|s|
|
|
640 |
|
|
641 |
(s := rawLabel ? label) isNil ifTrue:[
|
|
642 |
^ self
|
|
643 |
].
|
|
644 |
s isNumber ifTrue:[
|
|
645 |
s := s printString
|
|
646 |
].
|
|
647 |
s displayOn:aGC x:x y:y
|
|
648 |
!
|
|
649 |
|
|
650 |
heightOn:aGC
|
|
651 |
|s|
|
|
652 |
|
|
653 |
(s := rawLabel ? label) isNil ifTrue:[
|
|
654 |
^ aGC font height
|
|
655 |
].
|
|
656 |
^ s heightOn:aGC
|
|
657 |
!
|
|
658 |
|
|
659 |
widthOn:aGC
|
|
660 |
|s|
|
|
661 |
|
|
662 |
(s := rawLabel ? label) isNil ifTrue:[
|
|
663 |
^ 4
|
|
664 |
].
|
|
665 |
^ s widthOn:aGC
|
|
666 |
! !
|
|
667 |
|
|
668 |
!TabItem methodsFor:'help'!
|
|
669 |
|
|
670 |
activeHelpKey
|
|
671 |
^ self adornmentAt:#activeHelpKey
|
|
672 |
!
|
|
673 |
|
|
674 |
activeHelpKey:aKey
|
|
675 |
|key|
|
|
676 |
|
|
677 |
aKey size > 0 ifTrue:[key := aKey asSymbol].
|
|
678 |
self adornmentAt:#activeHelpKey put:key
|
|
679 |
!
|
|
680 |
|
|
681 |
activeHelpText
|
|
682 |
^ activeHelpText
|
|
683 |
! !
|
|
684 |
|
|
685 |
!TabItem methodsFor:'private'!
|
|
686 |
|
|
687 |
adornmentAt:aKey
|
|
688 |
^ self adornmentAt:aKey ifAbsent:nil
|
|
689 |
!
|
|
690 |
|
|
691 |
adornmentAt:aKey ifAbsent:exceptionBlock
|
|
692 |
adornments isNil ifTrue:[
|
|
693 |
^ exceptionBlock value
|
|
694 |
].
|
|
695 |
^ adornments at:aKey ifAbsent:exceptionBlock
|
|
696 |
!
|
|
697 |
|
|
698 |
adornmentAt:aKey put:something
|
|
699 |
|
|
700 |
something isNil ifTrue:[
|
|
701 |
adornments notNil ifTrue:[
|
|
702 |
adornments removeKey:aKey ifAbsent:nil.
|
|
703 |
]
|
|
704 |
] ifFalse:[
|
|
705 |
adornments isNil ifTrue:[
|
|
706 |
adornments := IdentityDictionary new.
|
|
707 |
].
|
|
708 |
adornments at:aKey put:something.
|
|
709 |
].
|
|
710 |
^ something
|
|
711 |
! !
|
|
712 |
|
|
713 |
!TabItem methodsFor:'queries'!
|
696
|
714 |
|
|
715 |
isEnabled
|
|
716 |
^ self enabled
|
|
717 |
! !
|
|
718 |
|
|
719 |
!TabItem class methodsFor:'documentation'!
|
|
720 |
|
|
721 |
version
|
1760
|
722 |
^ '$Header: /cvs/stx/stx/libwidg2/TabItem.st,v 1.8 2000-04-13 16:12:57 ca Exp $'
|
696
|
723 |
! !
|