343
|
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 |
|
|
14 |
|
|
15 |
Object subclass:#TabWidget
|
367
|
16 |
instanceVariableNames:'tabView label anchor extent lineNr'
|
343
|
17 |
classVariableNames:''
|
|
18 |
poolDictionaries:''
|
|
19 |
category:'Views-Interactors'
|
|
20 |
!
|
|
21 |
|
369
|
22 |
TabWidget subclass:#Window
|
343
|
23 |
instanceVariableNames:''
|
|
24 |
classVariableNames:''
|
|
25 |
poolDictionaries:''
|
|
26 |
privateIn:TabWidget
|
|
27 |
!
|
|
28 |
|
369
|
29 |
TabWidget subclass:#Mac
|
343
|
30 |
instanceVariableNames:''
|
|
31 |
classVariableNames:''
|
|
32 |
poolDictionaries:''
|
|
33 |
privateIn:TabWidget
|
|
34 |
!
|
|
35 |
|
|
36 |
!TabWidget class methodsFor:'documentation'!
|
|
37 |
|
|
38 |
copyright
|
|
39 |
"
|
|
40 |
COPYRIGHT (c) 1997 by eXept Software AG
|
|
41 |
All Rights Reserved
|
|
42 |
|
|
43 |
This software is furnished under a license and may be used
|
|
44 |
only in accordance with the terms of that license and with the
|
|
45 |
inclusion of the above copyright notice. This software may not
|
|
46 |
be provided or otherwise made available to, or used by, any
|
|
47 |
other person. No title to or ownership of the software is
|
|
48 |
hereby transferred.
|
|
49 |
"
|
|
50 |
|
|
51 |
|
|
52 |
!
|
|
53 |
|
|
54 |
documentation
|
|
55 |
"
|
|
56 |
instances represent (& draw) the tabs of a tabWidget.
|
|
57 |
|
|
58 |
[author:]
|
|
59 |
Claus Atzkern
|
|
60 |
|
|
61 |
[see also:]
|
|
62 |
TabView
|
|
63 |
"
|
|
64 |
! !
|
|
65 |
|
|
66 |
!TabWidget class methodsFor:'instance creation'!
|
|
67 |
|
367
|
68 |
labels:aList for:aTabView
|
|
69 |
"create tabs based on labels for a tabview
|
343
|
70 |
"
|
367
|
71 |
|list maxX maxY lftIns topIns level style|
|
|
72 |
|
|
73 |
maxX := 0.
|
|
74 |
maxY := 0.
|
|
75 |
style := aTabView style.
|
|
76 |
lftIns := style at:#labelLeftInset.
|
|
77 |
topIns := style at:#lableTopInset.
|
|
78 |
level := style at:#tabLevel.
|
|
79 |
|
|
80 |
list := aList collect:[:aLabel||y x|
|
|
81 |
(y := aLabel heightOn:aTabView) > maxY ifTrue:[maxY := y].
|
|
82 |
(x := aLabel widthOn:aTabView) > maxX ifTrue:[maxX := x].
|
|
83 |
self new label:aLabel for:aTabView
|
|
84 |
].
|
|
85 |
|
|
86 |
style at:#labelMaxX put:maxX.
|
|
87 |
style at:#labelMaxY put:maxY.
|
|
88 |
|
|
89 |
maxY := maxY + topIns
|
|
90 |
+ (style at:#labelBottomInset)
|
|
91 |
+ (2 * level).
|
|
92 |
|
|
93 |
maxX := maxX + lftIns + (style at:#labelRightInset).
|
|
94 |
|
|
95 |
style at:#maxX put:maxX.
|
|
96 |
style at:#maxY put:maxY.
|
|
97 |
style at:#labelAnchor put:( lftIns @ (topIns +level) ).
|
|
98 |
|
|
99 |
self validateDimensions:style.
|
369
|
100 |
maxY := style at:#maxY.
|
|
101 |
maxX := style at:#maxX.
|
|
102 |
|
|
103 |
"/ caused by vertical layout for images
|
|
104 |
maxX < maxY ifTrue:[style at:#maxX put:maxY].
|
367
|
105 |
^ list
|
|
106 |
!
|
|
107 |
|
|
108 |
validateDimensions:aStyle
|
|
109 |
"validate dimensions for a style; could be redifined
|
|
110 |
"
|
343
|
111 |
! !
|
|
112 |
|
|
113 |
!TabWidget class methodsFor:'accessing'!
|
|
114 |
|
|
115 |
tabStyleOn:aView
|
|
116 |
"returns default tab style
|
|
117 |
"
|
|
118 |
|style selectedColor unselectedColor|
|
|
119 |
|
|
120 |
style := IdentityDictionary new.
|
|
121 |
selectedColor := Color gray:90.
|
|
122 |
unselectedColor := Color gray:75.
|
|
123 |
|
|
124 |
style at:#widget put:self.
|
|
125 |
|
|
126 |
style at:#shadowColorSelected
|
|
127 |
put:((selectedColor averageColorIn:(0@0 corner:7@7)) darkened on:aView device).
|
|
128 |
|
|
129 |
style at:#lightColorSelected
|
|
130 |
put:((selectedColor averageColorIn:(0@0 corner:7@7)) lightened on:aView device).
|
|
131 |
|
|
132 |
style at:#shadowColorUnselected
|
|
133 |
put:((unselectedColor averageColorIn:(0@0 corner:7@7)) darkened on:aView device).
|
|
134 |
|
|
135 |
style at:#lightColorUnselected
|
|
136 |
put:((unselectedColor averageColorIn:(0@0 corner:7@7)) lightened on:aView device).
|
|
137 |
|
351
|
138 |
style at:#unselectedColor put:unselectedColor.
|
|
139 |
style at:#selectedColor put:selectedColor.
|
|
140 |
style at:#labelColor put:(Color black).
|
343
|
141 |
|
367
|
142 |
style at:#expandSelection put:0@0. "/ expand selection extent x y when raised
|
|
143 |
style at:#tabLevel put:0. "/ level
|
351
|
144 |
style at:#lableTopInset put:4. "/ additional top label inset
|
|
145 |
style at:#labelBottomInset put:4. "/ additional bottom inset
|
367
|
146 |
style at:#labelLeftInset put:4. "/ label left inset
|
|
147 |
style at:#labelRightInset put:4. "/ label right inset
|
|
148 |
style at:#rightCovered put:0. "/ covers right tab for n pixels
|
343
|
149 |
|
|
150 |
^ style
|
|
151 |
!
|
|
152 |
|
|
153 |
widgetClass:aWidget
|
367
|
154 |
|wdgt name|
|
343
|
155 |
|
367
|
156 |
name := aWidget asString.
|
|
157 |
wdgt := Smalltalk classNamed:( self name asString, '::', name ).
|
343
|
158 |
|
367
|
159 |
wdgt notNil ifTrue:[
|
|
160 |
^ wdgt
|
343
|
161 |
].
|
367
|
162 |
^ Smalltalk classNamed:name
|
343
|
163 |
! !
|
|
164 |
|
367
|
165 |
!TabWidget methodsFor:'accessing'!
|
|
166 |
|
|
167 |
label
|
|
168 |
^ label
|
|
169 |
!
|
|
170 |
|
|
171 |
lineNr
|
|
172 |
"returns line number
|
|
173 |
"
|
|
174 |
^ lineNr
|
|
175 |
!
|
|
176 |
|
|
177 |
lineNr:aLineNr
|
|
178 |
"change line number
|
|
179 |
"
|
|
180 |
lineNr := aLineNr
|
|
181 |
! !
|
|
182 |
|
|
183 |
!TabWidget methodsFor:'accessing dimensions'!
|
343
|
184 |
|
367
|
185 |
anchor
|
|
186 |
"returns the tab origin
|
|
187 |
"
|
|
188 |
^ anchor
|
|
189 |
|
|
190 |
!
|
|
191 |
|
|
192 |
anchor:anAnchor
|
|
193 |
"change the tab anchor; no redraw
|
|
194 |
"
|
|
195 |
anchor := anAnchor
|
|
196 |
|
|
197 |
!
|
|
198 |
|
|
199 |
anchor:anAnchor extent:anExtent
|
|
200 |
"change anchor and extent; no redraw
|
|
201 |
"
|
|
202 |
anchor := anAnchor.
|
|
203 |
extent := anExtent.
|
343
|
204 |
|
|
205 |
|
|
206 |
!
|
|
207 |
|
|
208 |
extent
|
|
209 |
"return the tab extent
|
|
210 |
"
|
|
211 |
^ extent
|
|
212 |
!
|
|
213 |
|
|
214 |
extent:anExtent
|
|
215 |
"change the tab extent; no redraw
|
|
216 |
"
|
|
217 |
extent := anExtent
|
|
218 |
!
|
|
219 |
|
367
|
220 |
preferredExtentX
|
|
221 |
"returns my preferred extent x
|
343
|
222 |
"
|
367
|
223 |
^ (tabView styleAt:#maxX)
|
|
224 |
- (tabView styleAt:#labelMaxX)
|
|
225 |
+ (label widthOn:tabView).
|
350
|
226 |
!
|
|
227 |
|
367
|
228 |
preferredExtentY
|
|
229 |
"returns my preferred extent y
|
343
|
230 |
"
|
367
|
231 |
^ (tabView styleAt:#maxY)
|
|
232 |
- (tabView styleAt:#labelMaxY)
|
|
233 |
+ (label heightOn:tabView).
|
|
234 |
! !
|
343
|
235 |
|
367
|
236 |
!TabWidget methodsFor:'basic drawing'!
|
343
|
237 |
|
367
|
238 |
redrawAtBottom:isSelected
|
|
239 |
"redraw tab at bottom of view
|
343
|
240 |
"
|
367
|
241 |
^ self subclassResponsibility
|
343
|
242 |
!
|
|
243 |
|
367
|
244 |
redrawAtLeft:isSelected
|
|
245 |
"redraw tab at left of view
|
343
|
246 |
"
|
367
|
247 |
^ self subclassResponsibility
|
343
|
248 |
!
|
|
249 |
|
367
|
250 |
redrawAtRight:isSelected
|
|
251 |
"redraw tab at right of view
|
343
|
252 |
"
|
367
|
253 |
^ self subclassResponsibility
|
|
254 |
!
|
343
|
255 |
|
367
|
256 |
redrawAtTop:isSelected
|
|
257 |
"redraw tab at top of view
|
|
258 |
"
|
|
259 |
^ self subclassResponsibility
|
343
|
260 |
! !
|
|
261 |
|
|
262 |
!TabWidget methodsFor:'drawing'!
|
|
263 |
|
369
|
264 |
redraw:isSelected
|
|
265 |
"redraw tab
|
|
266 |
"
|
|
267 |
|direction origin anchor x y|
|
|
268 |
|
|
269 |
direction := tabView direction.
|
|
270 |
anchor := tabView styleAt:#labelAnchor.
|
|
271 |
origin := self computeOrigin.
|
|
272 |
|
|
273 |
(direction == #top or:[direction == #bottom]) ifTrue:[
|
|
274 |
y := origin y.
|
|
275 |
x := origin x + anchor x.
|
|
276 |
|
|
277 |
direction == #top ifTrue:[
|
|
278 |
self redrawAtTop:isSelected.
|
|
279 |
y := y + anchor y.
|
|
280 |
] ifFalse:[
|
|
281 |
self redrawAtBottom:isSelected.
|
|
282 |
y := y - anchor y - (label heightOn:tabView).
|
|
283 |
].
|
|
284 |
label isString ifTrue:[y := y + tabView font ascent].
|
|
285 |
tabView paintColor:#labelColor.
|
|
286 |
] ifFalse:[
|
|
287 |
direction == #right ifTrue:[
|
|
288 |
self redrawAtRight:isSelected.
|
|
289 |
x := origin x - anchor y - (label widthOn:tabView).
|
|
290 |
] ifFalse:[
|
|
291 |
self redrawAtLeft:isSelected.
|
|
292 |
x := origin x + anchor y.
|
|
293 |
].
|
|
294 |
tabView paintColor:#labelColor.
|
|
295 |
y := origin y + anchor x.
|
|
296 |
|
|
297 |
label isString ifTrue:[
|
|
298 |
direction == #right ifTrue:[
|
|
299 |
x := x + tabView font ascent.
|
|
300 |
] ifFalse:[
|
|
301 |
x := x + tabView font descent.
|
|
302 |
].
|
|
303 |
tabView paintColor:#labelColor.
|
|
304 |
tabView displayString:label x:x y:y angle:90.
|
|
305 |
^ self.
|
|
306 |
].
|
|
307 |
].
|
|
308 |
label displayOn:tabView x:x y:y.
|
|
309 |
|
|
310 |
! !
|
|
311 |
|
|
312 |
!TabWidget methodsFor:'initialization'!
|
|
313 |
|
|
314 |
label:aLabel for:aTabView
|
|
315 |
"initialize attributes
|
|
316 |
"
|
|
317 |
tabView := aTabView.
|
|
318 |
label := aLabel.
|
|
319 |
! !
|
|
320 |
|
|
321 |
!TabWidget methodsFor:'private'!
|
|
322 |
|
367
|
323 |
computeCorner
|
|
324 |
"compute corner
|
|
325 |
"
|
|
326 |
|d c|
|
|
327 |
|
|
328 |
c := anchor + extent.
|
|
329 |
d := tabView direction.
|
|
330 |
|
|
331 |
d == #top ifTrue:[^ ( c x @ (tabView extent y) )].
|
|
332 |
d == #left ifTrue:[^ ( (tabView extent x) @ c y ) ].
|
|
333 |
d == #right ifTrue:[^ ( 0 @ c y )].
|
|
334 |
d == #bottom ifTrue:[^ ( c x @ 0 )].
|
|
335 |
|
|
336 |
self error.
|
|
337 |
!
|
|
338 |
|
|
339 |
computeOrigin
|
|
340 |
"compute origin
|
|
341 |
"
|
|
342 |
|d|
|
|
343 |
|
|
344 |
d := tabView direction.
|
|
345 |
|
|
346 |
d == #top ifTrue:[ ^ anchor x @ ((tabView extent y) - anchor y) ].
|
|
347 |
d == #left ifTrue:[ ^ ((tabView extent x) - anchor x) @ anchor y ].
|
|
348 |
d == #right ifTrue:[ ^ anchor ].
|
|
349 |
d == #bottom ifTrue:[ ^ anchor ].
|
|
350 |
|
|
351 |
self error
|
343
|
352 |
! !
|
|
353 |
|
|
354 |
!TabWidget methodsFor:'queries'!
|
|
355 |
|
|
356 |
containsPoint:aPoint
|
367
|
357 |
"return true, if a point is contained in the tab
|
343
|
358 |
"
|
367
|
359 |
|d x y top bot origin|
|
343
|
360 |
|
367
|
361 |
d := tabView direction.
|
343
|
362 |
x := aPoint x.
|
367
|
363 |
y := aPoint y.
|
343
|
364 |
|
367
|
365 |
origin := self computeOrigin.
|
|
366 |
|
|
367 |
(d == #top or:[d == #bottom]) ifTrue:[
|
|
368 |
((x >= origin x) and:[x <= (origin x + extent x)]) ifTrue:[
|
|
369 |
d == #top ifTrue:[
|
|
370 |
^ ((y >= origin y) and:[y <= (origin y + extent y)])
|
|
371 |
].
|
|
372 |
^ ((y <= origin y) and:[y >= (origin y - extent y)])
|
|
373 |
]
|
|
374 |
] ifFalse:[
|
|
375 |
((y >= origin y) and:[y <= (origin y + extent y)]) ifTrue:[
|
|
376 |
d == #right ifTrue:[
|
|
377 |
^ ((x <= origin x) and:[x >= (origin x - extent x)])
|
|
378 |
].
|
|
379 |
^ ((x >= origin x) and:[x <= (origin x + extent x)])
|
|
380 |
]
|
343
|
381 |
].
|
367
|
382 |
^ false
|
343
|
383 |
! !
|
|
384 |
|
367
|
385 |
!TabWidget::Window class methodsFor:'accessing'!
|
350
|
386 |
|
|
387 |
tabStyleOn:aView
|
367
|
388 |
|style col|
|
350
|
389 |
|
|
390 |
style := super tabStyleOn:aView.
|
|
391 |
|
367
|
392 |
style at:#expandSelection put:4@4.
|
|
393 |
style at:#tabLevel put:2.
|
|
394 |
style at:#lableTopInset put:2.
|
|
395 |
style at:#labelBottomInset put:2.
|
|
396 |
style at:#roundedEdges put:true.
|
|
397 |
^ style
|
350
|
398 |
|
|
399 |
|
|
400 |
|
|
401 |
! !
|
|
402 |
|
367
|
403 |
!TabWidget::Window class methodsFor:'calculate dimensions'!
|
|
404 |
|
|
405 |
validateDimensions:aStyle
|
|
406 |
"validate dimensions for a style; could be redifined
|
|
407 |
"
|
|
408 |
|maxY anchor|
|
350
|
409 |
|
367
|
410 |
(aStyle at:#roundedEdges) ifTrue:[
|
|
411 |
maxY := aStyle at:#maxY.
|
|
412 |
aStyle at:#maxY put:(maxY + 3).
|
|
413 |
anchor := aStyle at:#labelAnchor.
|
|
414 |
anchor y:(anchor y + 1).
|
|
415 |
aStyle at:#labelAnchor put:anchor.
|
|
416 |
]
|
|
417 |
|
|
418 |
|
|
419 |
|
350
|
420 |
|
|
421 |
|
|
422 |
! !
|
|
423 |
|
367
|
424 |
!TabWidget::Window methodsFor:'drawing'!
|
|
425 |
|
|
426 |
redrawAtBottom:isSelected
|
|
427 |
"redraw tab at bottom of view
|
|
428 |
"
|
|
429 |
|origin corner y x xR yB tabLevel light roundedEdges shadowColor lightColor|
|
|
430 |
|
|
431 |
origin := self computeOrigin.
|
|
432 |
corner := self computeCorner.
|
|
433 |
x := origin x.
|
|
434 |
y := origin y.
|
|
435 |
xR := corner x - 1.
|
|
436 |
yB := 0.
|
|
437 |
|
|
438 |
roundedEdges := tabView styleAt:#roundedEdges.
|
|
439 |
tabLevel := (tabView styleAt:#tabLevel) - 1.
|
|
440 |
|
|
441 |
isSelected ifFalse:[
|
|
442 |
tabView paint:(tabView styleAt:#unselectedColor).
|
|
443 |
shadowColor := tabView styleAt:#shadowColorUnselected.
|
|
444 |
lightColor := tabView styleAt:#lightColorUnselected.
|
|
445 |
] ifTrue:[
|
|
446 |
tabView paint:(tabView styleAt:#selectedColor).
|
|
447 |
shadowColor := tabView styleAt:#shadowColorSelected.
|
|
448 |
lightColor := tabView styleAt:#lightColorSelected.
|
|
449 |
].
|
|
450 |
|
|
451 |
roundedEdges ifTrue:[y := y - 2].
|
|
452 |
tabView fillRectangle:(Rectangle left:x top:yB extent:(extent x @ y)).
|
350
|
453 |
|
367
|
454 |
roundedEdges ifTrue:[
|
|
455 |
tabView displayLineFromX:x-1 y:y toX:xR y:y.
|
|
456 |
y := y - 1.
|
|
457 |
|
|
458 |
tabView paint:lightColor.
|
|
459 |
tabView displayPointX:x y:y+1.
|
|
460 |
tabView displayPointX:x+1 y:y+1.
|
|
461 |
tabView displayLineFromX:x+1 y:y+2 toX:xR-1 y:y+2.
|
|
462 |
tabView displayLineFromX:x+2 y:y+3 toX:xR-2 y:y+3.
|
|
463 |
|
|
464 |
tabView paint:shadowColor.
|
350
|
465 |
|
367
|
466 |
0 to:tabLevel do:[:i |
|
|
467 |
tabView displayPointX:xR-i y:y.
|
|
468 |
tabView displayPointX:xR-i y:y+1.
|
|
469 |
tabView displayPointX:xR-1-i y:y+2.
|
|
470 |
].
|
|
471 |
tabView displayPointX:xR-2 y:y+3.
|
|
472 |
tabView displayPointX:xR-3 y:y+3.
|
|
473 |
].
|
|
474 |
|
|
475 |
tabView paint:lightColor.
|
|
476 |
|
|
477 |
0 to:tabLevel do:[:i |
|
|
478 |
roundedEdges ifFalse:[
|
|
479 |
tabView displayLineFromX:x y:y-i toX:xR y:y-i "/ upper edge
|
|
480 |
].
|
|
481 |
tabView displayLineFromX:x+i y:y+1 toX:x+i y:yB. "/ left edge
|
|
482 |
].
|
|
483 |
y := y + 1.
|
|
484 |
tabView paint:shadowColor.
|
|
485 |
|
|
486 |
0 to:tabLevel do:[:i |
|
|
487 |
tabView displayLineFromX:xR-i y:y-i toX:xR-i y:yB. "/ right edge
|
|
488 |
].
|
350
|
489 |
|
|
490 |
!
|
|
491 |
|
367
|
492 |
redrawAtLeft:isSelected
|
|
493 |
"redraw tab at left of view
|
350
|
494 |
"
|
367
|
495 |
|origin corner y x xR yB tabLevel light roundedEdges shadowColor lightColor|
|
|
496 |
|
|
497 |
origin := self computeOrigin.
|
|
498 |
corner := self computeCorner.
|
|
499 |
x := origin x.
|
|
500 |
y := origin y.
|
|
501 |
xR := corner x.
|
|
502 |
yB := corner y.
|
|
503 |
|
|
504 |
roundedEdges := tabView styleAt:#roundedEdges.
|
|
505 |
tabLevel := (tabView styleAt:#tabLevel) - 1.
|
|
506 |
|
|
507 |
isSelected ifFalse:[
|
|
508 |
tabView paint:(tabView styleAt:#unselectedColor).
|
|
509 |
shadowColor := tabView styleAt:#shadowColorUnselected.
|
|
510 |
lightColor := tabView styleAt:#lightColorUnselected.
|
|
511 |
] ifTrue:[
|
|
512 |
tabView paint:(tabView styleAt:#selectedColor).
|
|
513 |
shadowColor := tabView styleAt:#shadowColorSelected.
|
|
514 |
lightColor := tabView styleAt:#lightColorSelected.
|
|
515 |
].
|
|
516 |
tabView fillRectangle:(Rectangle left:x top:y extent:(xR @ extent y)).
|
|
517 |
|
|
518 |
roundedEdges ifTrue:[
|
|
519 |
tabView displayLineFromX:x y:y toX:x y:yB.
|
|
520 |
|
|
521 |
tabView paint:lightColor.
|
|
522 |
tabView displayPointX:x y:y+1.
|
|
523 |
tabView displayPointX:x y:y+2.
|
|
524 |
tabView displayLineFromX:x-1 y:y+2 toX:x-1 y:yB-1.
|
|
525 |
tabView displayLineFromX:x-2 y:y+3 toX:x-2 y:yB-1.
|
|
526 |
|
|
527 |
tabView paint:shadowColor.
|
350
|
528 |
|
367
|
529 |
0 to:tabLevel do:[:i |
|
|
530 |
tabView displayPointX:x y:yB-i.
|
|
531 |
tabView displayPointX:x-1 y:yB-i-1.
|
|
532 |
tabView displayPointX:x-2 y:yB-i-2.
|
|
533 |
].
|
|
534 |
].
|
|
535 |
tabView paint:lightColor.
|
|
536 |
|
|
537 |
0 to:tabLevel do:[:i |
|
|
538 |
roundedEdges ifFalse:[
|
|
539 |
tabView displayLineFromX:x+i y:y+i toX:x+i y:yB. "/ upper edge
|
|
540 |
].
|
|
541 |
tabView displayLineFromX:x y:y+i toX:xR y:y+i. "/ left edge
|
|
542 |
].
|
|
543 |
tabView paint:shadowColor.
|
350
|
544 |
|
367
|
545 |
0 to:tabLevel do:[:i |
|
|
546 |
tabView displayLineFromX:x+i y:yB-i toX:xR y:yB-i.
|
|
547 |
].
|
|
548 |
|
|
549 |
!
|
|
550 |
|
|
551 |
redrawAtRight:isSelected
|
|
552 |
"redraw tab at right of view
|
|
553 |
"
|
|
554 |
|origin corner y x xR yB tabLevel light roundedEdges shadowColor lightColor|
|
|
555 |
|
|
556 |
origin := self computeOrigin.
|
|
557 |
corner := self computeCorner.
|
|
558 |
x := origin x.
|
|
559 |
y := origin y.
|
|
560 |
xR := corner x - 1.
|
|
561 |
yB := corner y.
|
|
562 |
|
|
563 |
roundedEdges := tabView styleAt:#roundedEdges.
|
|
564 |
tabLevel := (tabView styleAt:#tabLevel) - 1.
|
350
|
565 |
|
|
566 |
isSelected ifFalse:[
|
367
|
567 |
tabView paint:(tabView styleAt:#unselectedColor).
|
350
|
568 |
shadowColor := tabView styleAt:#shadowColorUnselected.
|
367
|
569 |
lightColor := tabView styleAt:#lightColorUnselected.
|
350
|
570 |
] ifTrue:[
|
367
|
571 |
tabView paint:(tabView styleAt:#selectedColor).
|
350
|
572 |
shadowColor := tabView styleAt:#shadowColorSelected.
|
367
|
573 |
lightColor := tabView styleAt:#lightColorSelected.
|
350
|
574 |
].
|
367
|
575 |
tabView fillRectangle:(Rectangle left:0 top:y extent:(x @ extent y)).
|
|
576 |
|
|
577 |
roundedEdges ifTrue:[
|
|
578 |
tabView displayLineFromX:x y:y toX:x y:yB.
|
350
|
579 |
|
367
|
580 |
tabView paint:lightColor.
|
|
581 |
tabView displayPointX:x y:y+1.
|
|
582 |
tabView displayPointX:x y:y+2.
|
|
583 |
tabView displayLineFromX:x+1 y:y+2 toX:x+1 y:yB-1.
|
|
584 |
tabView displayLineFromX:x+2 y:y+3 toX:x+2 y:yB-1.
|
|
585 |
|
|
586 |
tabView paint:shadowColor.
|
|
587 |
|
|
588 |
0 to:tabLevel do:[:i |
|
|
589 |
tabView displayPointX:x y:yB-i.
|
|
590 |
tabView displayPointX:x+1 y:yB-i-1.
|
|
591 |
tabView displayPointX:x+2 y:yB-i-2.
|
|
592 |
].
|
|
593 |
].
|
350
|
594 |
tabView paint:lightColor.
|
|
595 |
|
367
|
596 |
0 to:tabLevel do:[:i |
|
|
597 |
roundedEdges ifFalse:[
|
|
598 |
tabView displayLineFromX:x-i y:y+i toX:x-i y:yB. "/ upper edge
|
|
599 |
].
|
|
600 |
tabView displayLineFromX:x y:y+i+1 toX:0 y:y+i+1. "/ left edge
|
|
601 |
].
|
|
602 |
tabView paint:shadowColor.
|
|
603 |
|
|
604 |
0 to:tabLevel do:[:i |
|
|
605 |
tabView displayLineFromX:x-i+1 y:yB-i toX:1 y:yB-i.
|
|
606 |
].
|
|
607 |
!
|
|
608 |
|
|
609 |
redrawAtTop:isSelected
|
|
610 |
"redraw tab at top of view
|
|
611 |
"
|
|
612 |
|polygon origin corner y x xR yB tabLevel light roundedEdges shadowColor lightColor|
|
|
613 |
|
|
614 |
origin := self computeOrigin.
|
|
615 |
corner := self computeCorner.
|
|
616 |
x := origin x.
|
|
617 |
y := origin y.
|
|
618 |
xR := corner x - 1.
|
|
619 |
yB := corner y.
|
|
620 |
|
|
621 |
roundedEdges := tabView styleAt:#roundedEdges.
|
|
622 |
tabLevel := (tabView styleAt:#tabLevel) - 1.
|
|
623 |
|
|
624 |
isSelected ifFalse:[
|
|
625 |
tabView paint:(tabView styleAt:#unselectedColor).
|
|
626 |
shadowColor := tabView styleAt:#shadowColorUnselected.
|
|
627 |
lightColor := tabView styleAt:#lightColorUnselected.
|
|
628 |
] ifTrue:[
|
|
629 |
tabView paint:(tabView styleAt:#selectedColor).
|
|
630 |
shadowColor := tabView styleAt:#shadowColorSelected.
|
|
631 |
lightColor := tabView styleAt:#lightColorSelected.
|
350
|
632 |
].
|
|
633 |
|
367
|
634 |
roundedEdges ifTrue:[ y := y + 2].
|
|
635 |
tabView fillRectangle:(Rectangle left:x top:y extent:((extent x) @ yB)).
|
|
636 |
|
|
637 |
roundedEdges ifTrue:[
|
|
638 |
y := y + 1.
|
|
639 |
tabView displayLineFromX:x y:y-1 toX:xR y:y-1.
|
|
640 |
tabView displayLineFromX:x+1 y:y-2 toX:xR-1 y:y-2.
|
|
641 |
tabView displayLineFromX:x+2 y:y-3 toX:xR-2 y:y-3.
|
|
642 |
|
|
643 |
tabView paint:lightColor.
|
|
644 |
|
|
645 |
0 to:tabLevel do:[:i |
|
|
646 |
tabView displayPointX:x+i y:y-1.
|
|
647 |
tabView displayPointX:x+1+i y:y-1-1.
|
|
648 |
tabView displayLineFromX:x+2+i y:y-3-i toX:xR-1-i y:y-3-i. "/ top
|
|
649 |
].
|
|
650 |
|
|
651 |
tabView paint:shadowColor.
|
|
652 |
0 to:tabLevel do:[:i |
|
|
653 |
tabView displayPointX:xR-i y:y.
|
|
654 |
tabView displayPointX:xR-i y:y-1.
|
|
655 |
tabView displayPointX:xR-1-i y:y-1-1.
|
|
656 |
].
|
|
657 |
tabView displayPointX:xR-2 y:y-1-1-1.
|
|
658 |
tabView displayPointX:xR-3 y:y-1-1-1.
|
350
|
659 |
].
|
|
660 |
|
367
|
661 |
tabView paint:lightColor.
|
|
662 |
0 to:tabLevel do:[:i |
|
|
663 |
roundedEdges ifFalse:[
|
|
664 |
tabView displayLineFromX:x y:y+i toX:xR y:y+i. "/ upper edge
|
|
665 |
].
|
|
666 |
tabView displayLineFromX:x+i y:y toX:x+i y:yB. "/ left edge
|
|
667 |
].
|
|
668 |
tabView paint:shadowColor.
|
|
669 |
0 to:tabLevel do:[:i |
|
|
670 |
tabView displayLineFromX:xR-i y:y+i toX:xR-i y:yB. "/ right edge
|
|
671 |
].
|
350
|
672 |
! !
|
|
673 |
|
369
|
674 |
!TabWidget::Mac class methodsFor:'accessing'!
|
|
675 |
|
|
676 |
tabStyleOn:aView
|
|
677 |
|style|
|
|
678 |
|
|
679 |
style := super tabStyleOn:aView.
|
|
680 |
style at:#tabLevel put:2.
|
|
681 |
^ style.
|
|
682 |
! !
|
|
683 |
|
|
684 |
!TabWidget::Mac class methodsFor:'calculate dimensions'!
|
|
685 |
|
|
686 |
validateDimensions:aStyle
|
|
687 |
"validate dimensions for a style; could be redifined
|
|
688 |
"
|
|
689 |
|maxY maxX anchor lftIns|
|
|
690 |
|
|
691 |
maxY := aStyle at:#maxY.
|
|
692 |
maxX := (aStyle at:#maxX) - (aStyle at:#labelLeftInset).
|
|
693 |
anchor := aStyle at:#labelAnchor.
|
|
694 |
lftIns := maxY // 2.
|
|
695 |
|
|
696 |
anchor x:lftIns.
|
|
697 |
|
|
698 |
aStyle at:#maxX put:(maxX + lftIns + maxY).
|
|
699 |
aStyle at:#rightCovered put:(maxY // 2).
|
|
700 |
! !
|
|
701 |
|
|
702 |
!TabWidget::Mac methodsFor:'drawing'!
|
|
703 |
|
|
704 |
redrawAtBottom:isSelected
|
|
705 |
"redraw tab at bottom of view
|
|
706 |
"
|
|
707 |
|origin corner level polygon x y x1 eX eY shadowColor lightColor|
|
|
708 |
|
|
709 |
isSelected ifFalse:[
|
|
710 |
lightColor := tabView styleAt:#lightColorUnselected.
|
|
711 |
shadowColor := tabView styleAt:#shadowColorUnselected.
|
|
712 |
tabView paint:(tabView styleAt:#unselectedColor).
|
|
713 |
] ifTrue:[
|
|
714 |
lightColor := tabView styleAt:#lightColorSelected.
|
|
715 |
shadowColor := tabView styleAt:#shadowColorSelected.
|
|
716 |
tabView paint:(tabView styleAt:#selectedColor).
|
|
717 |
].
|
|
718 |
polygon := Array new:5.
|
|
719 |
origin := self computeOrigin.
|
|
720 |
corner := self computeCorner.
|
|
721 |
level := tabView styleAt:#tabLevel.
|
|
722 |
|
|
723 |
x := origin x.
|
|
724 |
y := origin y.
|
|
725 |
eX := corner x.
|
|
726 |
eY := corner y.
|
|
727 |
x1 := eX - (tabView styleAt:#maxY).
|
|
728 |
|
|
729 |
polygon at:1 put:(Point x:x y:eY).
|
|
730 |
polygon at:2 put:(Point x:x y:y).
|
|
731 |
polygon at:3 put:(Point x:x1 y:y).
|
|
732 |
polygon at:4 put:(Point x:eX y:(y-extent y)).
|
|
733 |
polygon at:5 put:(Point x:eX y:eY).
|
|
734 |
|
|
735 |
tabView fillPolygon:polygon.
|
|
736 |
tabView paint:lightColor.
|
|
737 |
|
|
738 |
1 to:level do:[:i|
|
|
739 |
tabView displayLineFromX:x+1 y:y-i toX:x1+i y:y-i.
|
|
740 |
tabView displayLineFromX:x+i y:y-1 toX:x+i y:1.
|
|
741 |
].
|
|
742 |
tabView paint:shadowColor.
|
|
743 |
tabView displayPolygon:polygon.
|
|
744 |
|
|
745 |
isSelected ifFalse:[
|
|
746 |
tabView displayLineFromX:x y:eY toX:eX y:eY.
|
|
747 |
]
|
|
748 |
!
|
|
749 |
|
|
750 |
redrawAtLeft:isSelected
|
|
751 |
"redraw tab at left of view
|
|
752 |
"
|
|
753 |
|origin corner polygon level x y y1 eX eY shadowColor lightColor|
|
|
754 |
|
|
755 |
isSelected ifFalse:[
|
|
756 |
lightColor := tabView styleAt:#lightColorUnselected.
|
|
757 |
shadowColor := tabView styleAt:#shadowColorUnselected.
|
|
758 |
tabView paint:(tabView styleAt:#unselectedColor).
|
|
759 |
] ifTrue:[
|
|
760 |
lightColor := tabView styleAt:#lightColorSelected.
|
|
761 |
shadowColor := tabView styleAt:#shadowColorSelected.
|
|
762 |
tabView paint:(tabView styleAt:#selectedColor).
|
|
763 |
].
|
|
764 |
polygon := Array new:5.
|
|
765 |
origin := self computeOrigin.
|
|
766 |
corner := self computeCorner.
|
|
767 |
level := tabView styleAt:#tabLevel.
|
|
768 |
|
|
769 |
x := origin x.
|
|
770 |
y := origin y.
|
|
771 |
eX := corner x.
|
|
772 |
eY := corner y.
|
|
773 |
y1 := eY - (tabView styleAt:#maxY).
|
|
774 |
|
|
775 |
polygon at:1 put:(Point x:eX y:y).
|
|
776 |
polygon at:2 put:(Point x:x y:y).
|
|
777 |
polygon at:3 put:(Point x:x y:y1).
|
|
778 |
polygon at:4 put:(Point x:(x+extent x) y:eY).
|
|
779 |
polygon at:5 put:(Point x:eX y:eY).
|
|
780 |
|
|
781 |
tabView fillPolygon:polygon.
|
|
782 |
tabView paint:lightColor.
|
|
783 |
|
|
784 |
1 to:level do:[:i|
|
|
785 |
tabView displayLineFromX:eX y:y+i toX:x+2 y:y+i.
|
|
786 |
tabView displayLineFromX:x+i y:y+1 toX:x+i y:y1+i.
|
|
787 |
].
|
|
788 |
tabView paint:shadowColor.
|
|
789 |
tabView displayPolygon:polygon.
|
|
790 |
|
|
791 |
isSelected ifFalse:[
|
|
792 |
tabView displayLineFromX:eX-1 y:y toX:eX-1 y:eY.
|
|
793 |
]
|
|
794 |
!
|
|
795 |
|
|
796 |
redrawAtRight:isSelected
|
|
797 |
"redraw tab at right of view
|
|
798 |
"
|
|
799 |
|origin corner level polygon x y y1 eY shadowColor lightColor|
|
|
800 |
|
|
801 |
isSelected ifFalse:[
|
|
802 |
lightColor := tabView styleAt:#lightColorUnselected.
|
|
803 |
shadowColor := tabView styleAt:#shadowColorUnselected.
|
|
804 |
tabView paint:(tabView styleAt:#unselectedColor).
|
|
805 |
] ifTrue:[
|
|
806 |
lightColor := tabView styleAt:#lightColorSelected.
|
|
807 |
shadowColor := tabView styleAt:#shadowColorSelected.
|
|
808 |
tabView paint:(tabView styleAt:#selectedColor).
|
|
809 |
].
|
|
810 |
polygon := Array new:5.
|
|
811 |
origin := self computeOrigin.
|
|
812 |
corner := self computeCorner.
|
|
813 |
level := tabView styleAt:#tabLevel.
|
|
814 |
|
|
815 |
x := origin x.
|
|
816 |
y := origin y.
|
|
817 |
eY := corner y.
|
|
818 |
y1 := eY - (tabView styleAt:#maxY).
|
|
819 |
|
|
820 |
polygon at:1 put:(Point x:0 y:y).
|
|
821 |
polygon at:2 put:(Point x:x y:y).
|
|
822 |
polygon at:3 put:(Point x:x y:y1).
|
|
823 |
polygon at:4 put:(Point x:(x-extent x) y:eY).
|
|
824 |
polygon at:5 put:(Point x:0 y:eY).
|
|
825 |
|
|
826 |
tabView fillPolygon:polygon.
|
|
827 |
tabView paint:lightColor.
|
|
828 |
|
|
829 |
1 to:level do:[:i|
|
|
830 |
tabView displayLineFromX:0 y:y+i toX:x-1 y:y+i.
|
|
831 |
tabView displayLineFromX:x-i y:y+1 toX:x-i y:y1+i.
|
|
832 |
].
|
|
833 |
tabView paint:shadowColor.
|
|
834 |
tabView displayPolygon:polygon.
|
|
835 |
|
|
836 |
isSelected ifFalse:[
|
|
837 |
tabView displayLineFromX:0 y:y toX:0 y:eY.
|
|
838 |
]
|
|
839 |
|
|
840 |
!
|
|
841 |
|
|
842 |
redrawAtTop:isSelected
|
|
843 |
"redraw tab at top of view
|
|
844 |
"
|
|
845 |
|origin corner level polygon x y x1 eX eY color shadowColor lightColor|
|
|
846 |
|
|
847 |
isSelected ifFalse:[
|
|
848 |
lightColor := tabView styleAt:#lightColorUnselected.
|
|
849 |
shadowColor := tabView styleAt:#shadowColorUnselected.
|
|
850 |
tabView paint:(tabView styleAt:#unselectedColor).
|
|
851 |
] ifTrue:[
|
|
852 |
lightColor := tabView styleAt:#lightColorSelected.
|
|
853 |
shadowColor := tabView styleAt:#shadowColorSelected.
|
|
854 |
tabView paint:(tabView styleAt:#selectedColor).
|
|
855 |
].
|
|
856 |
polygon := Array new:5.
|
|
857 |
origin := self computeOrigin.
|
|
858 |
corner := self computeCorner.
|
|
859 |
level := tabView styleAt:#tabLevel.
|
|
860 |
|
|
861 |
x := origin x.
|
|
862 |
y := origin y.
|
|
863 |
eX := corner x - 1.
|
|
864 |
eY := corner y.
|
|
865 |
x1 := eX - (tabView styleAt:#maxY).
|
|
866 |
|
|
867 |
polygon at:1 put:(Point x:x y:eY).
|
|
868 |
polygon at:2 put:(Point x:x y:y).
|
|
869 |
polygon at:3 put:(Point x:x1 y:y).
|
|
870 |
polygon at:4 put:(Point x:eX y:(y+extent y)).
|
|
871 |
polygon at:5 put:(Point x:eX y:eY).
|
|
872 |
|
|
873 |
tabView fillPolygon:polygon.
|
|
874 |
tabView paint:lightColor.
|
|
875 |
|
|
876 |
1 to:level do:[:i|
|
|
877 |
tabView displayLineFromX:x+i y:eY toX:x+i y:y+1.
|
|
878 |
tabView displayLineFromX:x+1 y:y+i toX:x1+i y:y+i.
|
|
879 |
].
|
|
880 |
tabView paint:shadowColor.
|
|
881 |
tabView displayPolygon:polygon.
|
|
882 |
|
|
883 |
isSelected ifFalse:[
|
|
884 |
tabView displayLineFromX:x y:eY-1 toX:eX y:eY-1.
|
|
885 |
]
|
|
886 |
|
|
887 |
|
|
888 |
! !
|
|
889 |
|
343
|
890 |
!TabWidget class methodsFor:'documentation'!
|
|
891 |
|
|
892 |
version
|
369
|
893 |
^ '$Header: /cvs/stx/stx/libwidg2/TabWidget.st,v 1.5 1997-04-23 15:17:21 ca Exp $'
|
343
|
894 |
! !
|