author | Claus Gittinger <cg@exept.de> |
Thu, 20 May 1999 19:29:18 +0200 | |
changeset 1381 | af7df1844287 |
parent 1350 | 3425b715c379 |
child 1476 | a2bd9f16d320 |
permissions | -rw-r--r-- |
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 |
|
697 | 16 |
instanceVariableNames:'model tabView label disabledLabel printableLabel anchor extent |
17 |
lineNr fgColor labelType' |
|
343 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
20 |
category:'Views-Interactors' |
|
21 |
! |
|
22 |
||
549 | 23 |
TabWidget subclass:#Mac |
343 | 24 |
instanceVariableNames:'' |
25 |
classVariableNames:'' |
|
26 |
poolDictionaries:'' |
|
27 |
privateIn:TabWidget |
|
28 |
! |
|
29 |
||
549 | 30 |
TabWidget subclass:#Window |
343 | 31 |
instanceVariableNames:'' |
32 |
classVariableNames:'' |
|
33 |
poolDictionaries:'' |
|
34 |
privateIn:TabWidget |
|
35 |
! |
|
36 |
||
37 |
!TabWidget class methodsFor:'documentation'! |
|
38 |
||
39 |
copyright |
|
40 |
" |
|
41 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
42 |
All Rights Reserved |
|
43 |
||
44 |
This software is furnished under a license and may be used |
|
45 |
only in accordance with the terms of that license and with the |
|
46 |
inclusion of the above copyright notice. This software may not |
|
47 |
be provided or otherwise made available to, or used by, any |
|
48 |
other person. No title to or ownership of the software is |
|
49 |
hereby transferred. |
|
50 |
" |
|
51 |
||
52 |
||
53 |
! |
|
54 |
||
55 |
documentation |
|
56 |
" |
|
57 |
instances represent (& draw) the tabs of a tabWidget. |
|
58 |
||
59 |
[author:] |
|
60 |
Claus Atzkern |
|
61 |
||
62 |
[see also:] |
|
63 |
TabView |
|
64 |
" |
|
65 |
! ! |
|
66 |
||
67 |
!TabWidget class methodsFor:'instance creation'! |
|
68 |
||
367 | 69 |
labels:aList for:aTabView |
70 |
"create tabs based on labels for a tabview |
|
343 | 71 |
" |
367 | 72 |
|list maxX maxY lftIns topIns level style| |
73 |
||
74 |
maxX := 0. |
|
75 |
maxY := 0. |
|
76 |
style := aTabView style. |
|
77 |
lftIns := style at:#labelLeftInset. |
|
1350 | 78 |
topIns := style at:#labelTopInset. |
367 | 79 |
level := style at:#tabLevel. |
80 |
||
409 | 81 |
aTabView device isNil ifTrue:[ |
82 |
self halt |
|
83 |
]. |
|
697 | 84 |
|
85 |
list := aList collect:[:anEntry||y x tab lbl| |
|
86 |
tab := self new label:anEntry for:aTabView. |
|
87 |
lbl := tab printableLabel. |
|
88 |
||
89 |
(y := lbl heightOn:aTabView) > maxY ifTrue:[maxY := y]. |
|
90 |
(x := lbl widthOn:aTabView) > maxX ifTrue:[maxX := x]. |
|
91 |
||
92 |
tab |
|
367 | 93 |
]. |
94 |
||
95 |
style at:#labelMaxX put:maxX. |
|
96 |
style at:#labelMaxY put:maxY. |
|
97 |
||
98 |
maxY := maxY + topIns |
|
99 |
+ (style at:#labelBottomInset) |
|
100 |
+ (2 * level). |
|
101 |
||
102 |
maxX := maxX + lftIns + (style at:#labelRightInset). |
|
103 |
||
104 |
style at:#maxX put:maxX. |
|
105 |
style at:#maxY put:maxY. |
|
106 |
style at:#labelAnchor put:( lftIns @ (topIns +level) ). |
|
107 |
||
108 |
self validateDimensions:style. |
|
369 | 109 |
maxY := style at:#maxY. |
110 |
maxX := style at:#maxX. |
|
111 |
||
112 |
"/ caused by vertical layout for images |
|
113 |
maxX < maxY ifTrue:[style at:#maxX put:maxY]. |
|
367 | 114 |
^ list |
1350 | 115 |
|
116 |
"Modified: / 4.5.1999 / 02:15:33 / cg" |
|
367 | 117 |
! |
118 |
||
119 |
validateDimensions:aStyle |
|
120 |
"validate dimensions for a style; could be redifined |
|
121 |
" |
|
343 | 122 |
! ! |
123 |
||
124 |
!TabWidget class methodsFor:'accessing'! |
|
125 |
||
419 | 126 |
computeColorsOn:aView style:aStyle |
127 |
"set colors dependent on selection color |
|
128 |
" |
|
1335 | 129 |
|unselectedColor selectedColor avgSelectedColor avgUnSelectedColor| |
419 | 130 |
|
131 |
selectedColor := aView viewBackground. |
|
132 |
unselectedColor := selectedColor lightened. |
|
1335 | 133 |
avgSelectedColor := selectedColor averageColorIn:(0@0 corner:7@7). |
134 |
avgUnSelectedColor := unselectedColor averageColorIn:(0@0 corner:7@7). |
|
419 | 135 |
|
1335 | 136 |
aStyle at:#shadowColorSelected put:(avgSelectedColor darkened on:aView device). |
137 |
aStyle at:#lightColorSelected put:(avgSelectedColor lightened on:aView device). |
|
138 |
aStyle at:#shadowColorUnselected put:(avgUnSelectedColor darkened on:aView device). |
|
139 |
aStyle at:#lightColorUnselected put:(avgUnSelectedColor lightened on:aView device). |
|
419 | 140 |
|
141 |
aStyle at:#unselectedColor put:unselectedColor. |
|
142 |
aStyle at:#selectedColor put:selectedColor. |
|
143 |
aStyle at:#labelColor put:Color black. |
|
1350 | 144 |
|
145 |
"Modified: / 4.5.1999 / 02:16:32 / cg" |
|
419 | 146 |
! |
147 |
||
148 |
computeColorsOn:aView style:aStyle selectionColor:aSelectedColor |
|
149 |
"set colors dependent on selection color |
|
150 |
" |
|
1335 | 151 |
|unselectedColor selectedColor avgSelectedColor avgUnSelectedColor| |
152 |
||
153 |
"/ CG: this seems to be no longer needed ... |
|
419 | 154 |
|
155 |
unselectedColor := aView viewBackground. |
|
156 |
selectedColor := unselectedColor lightened. |
|
157 |
||
1335 | 158 |
avgSelectedColor := selectedColor averageColorIn:(0@0 corner:7@7). |
159 |
avgUnSelectedColor := unselectedColor averageColorIn:(0@0 corner:7@7). |
|
419 | 160 |
|
1335 | 161 |
aStyle at:#shadowColorSelected put:(avgSelectedColor darkened on:aView device). |
162 |
aStyle at:#lightColorSelected put:(avgSelectedColor lightened on:aView device). |
|
163 |
aStyle at:#shadowColorUnselected put:(avgUnSelectedColor darkened on:aView device). |
|
164 |
aStyle at:#lightColorUnselected put:(avgUnSelectedColor lightened on:aView device). |
|
419 | 165 |
|
166 |
aStyle at:#unselectedColor put:unselectedColor. |
|
167 |
aStyle at:#selectedColor put:selectedColor. |
|
168 |
aStyle at:#labelColor put:Color black. |
|
169 |
! |
|
170 |
||
343 | 171 |
tabStyleOn:aView |
172 |
"returns default tab style |
|
173 |
" |
|
419 | 174 |
|style| |
343 | 175 |
|
419 | 176 |
style := IdentityDictionary new. |
343 | 177 |
|
178 |
style at:#widget put:self. |
|
419 | 179 |
self computeColorsOn:aView style:style. |
343 | 180 |
|
367 | 181 |
style at:#expandSelection put:0@0. "/ expand selection extent x y when raised |
182 |
style at:#tabLevel put:0. "/ level |
|
1350 | 183 |
style at:#labelTopInset put:4. "/ additional top label inset |
351 | 184 |
style at:#labelBottomInset put:4. "/ additional bottom inset |
367 | 185 |
style at:#labelLeftInset put:4. "/ label left inset |
186 |
style at:#labelRightInset put:4. "/ label right inset |
|
187 |
style at:#rightCovered put:0. "/ covers right tab for n pixels |
|
343 | 188 |
|
189 |
^ style |
|
1350 | 190 |
|
191 |
"Modified: / 4.5.1999 / 02:15:50 / cg" |
|
343 | 192 |
! |
193 |
||
194 |
widgetClass:aWidget |
|
367 | 195 |
|wdgt name| |
343 | 196 |
|
367 | 197 |
name := aWidget asString. |
198 |
wdgt := Smalltalk classNamed:( self name asString, '::', name ). |
|
343 | 199 |
|
367 | 200 |
wdgt notNil ifTrue:[ |
201 |
^ wdgt |
|
343 | 202 |
]. |
367 | 203 |
^ Smalltalk classNamed:name |
343 | 204 |
! ! |
205 |
||
367 | 206 |
!TabWidget methodsFor:'accessing'! |
207 |
||
208 |
label |
|
209 |
^ label |
|
210 |
! |
|
211 |
||
212 |
lineNr |
|
213 |
"returns line number |
|
214 |
" |
|
215 |
^ lineNr |
|
216 |
! |
|
217 |
||
218 |
lineNr:aLineNr |
|
219 |
"change line number |
|
220 |
" |
|
221 |
lineNr := aLineNr |
|
697 | 222 |
! |
223 |
||
224 |
printableLabel |
|
225 |
||
226 |
|lbl dev| |
|
227 |
||
228 |
printableLabel notNil ifTrue:[ |
|
229 |
^ printableLabel |
|
230 |
]. |
|
231 |
||
232 |
model isNil ifTrue:[ |
|
233 |
lbl := label |
|
234 |
] ifFalse:[ |
|
235 |
lbl := model rawLabel |
|
236 |
]. |
|
237 |
||
238 |
dev := tabView device. |
|
239 |
||
240 |
lbl isImage ifTrue:[ |
|
241 |
labelType := #image. |
|
242 |
printableLabel := lbl onDevice:dev. |
|
243 |
disabledLabel := printableLabel lightened onDevice:dev. |
|
244 |
] ifFalse:[ |
|
245 |
labelType := #string. |
|
246 |
||
247 |
printableLabel := lbl ? ''. |
|
248 |
disabledLabel := printableLabel copy. |
|
249 |
||
250 |
lbl class == LabelAndIcon ifTrue:[ |
|
251 |
lbl := printableLabel icon onDevice:dev. |
|
252 |
printableLabel icon:lbl. |
|
253 |
disabledLabel icon:(lbl lightened onDevice:dev). |
|
254 |
] |
|
255 |
]. |
|
256 |
^ printableLabel |
|
367 | 257 |
! ! |
258 |
||
259 |
!TabWidget methodsFor:'accessing dimensions'! |
|
343 | 260 |
|
367 | 261 |
anchor |
262 |
"returns the tab origin |
|
263 |
" |
|
264 |
^ anchor |
|
265 |
||
266 |
! |
|
267 |
||
268 |
anchor:anAnchor |
|
269 |
"change the tab anchor; no redraw |
|
270 |
" |
|
271 |
anchor := anAnchor |
|
272 |
||
273 |
! |
|
274 |
||
275 |
anchor:anAnchor extent:anExtent |
|
276 |
"change anchor and extent; no redraw |
|
277 |
" |
|
278 |
anchor := anAnchor. |
|
279 |
extent := anExtent. |
|
343 | 280 |
|
281 |
||
282 |
! |
|
283 |
||
284 |
extent |
|
285 |
"return the tab extent |
|
286 |
" |
|
287 |
^ extent |
|
288 |
! |
|
289 |
||
290 |
extent:anExtent |
|
291 |
"change the tab extent; no redraw |
|
292 |
" |
|
293 |
extent := anExtent |
|
294 |
! |
|
295 |
||
367 | 296 |
preferredExtentX |
297 |
"returns my preferred extent x |
|
343 | 298 |
" |
367 | 299 |
^ (tabView styleAt:#maxX) |
300 |
- (tabView styleAt:#labelMaxX) |
|
697 | 301 |
+ (self printableLabel widthOn:tabView). |
350 | 302 |
! |
303 |
||
367 | 304 |
preferredExtentY |
305 |
"returns my preferred extent y |
|
343 | 306 |
" |
367 | 307 |
^ (tabView styleAt:#maxY) |
308 |
- (tabView styleAt:#labelMaxY) |
|
697 | 309 |
+ (self printableLabel heightOn:tabView). |
367 | 310 |
! ! |
343 | 311 |
|
367 | 312 |
!TabWidget methodsFor:'basic drawing'! |
343 | 313 |
|
367 | 314 |
redrawAtBottom:isSelected |
315 |
"redraw tab at bottom of view |
|
343 | 316 |
" |
367 | 317 |
^ self subclassResponsibility |
343 | 318 |
! |
319 |
||
367 | 320 |
redrawAtLeft:isSelected |
321 |
"redraw tab at left of view |
|
343 | 322 |
" |
367 | 323 |
^ self subclassResponsibility |
343 | 324 |
! |
325 |
||
367 | 326 |
redrawAtRight:isSelected |
327 |
"redraw tab at right of view |
|
343 | 328 |
" |
367 | 329 |
^ self subclassResponsibility |
330 |
! |
|
343 | 331 |
|
367 | 332 |
redrawAtTop:isSelected |
333 |
"redraw tab at top of view |
|
334 |
" |
|
335 |
^ self subclassResponsibility |
|
343 | 336 |
! ! |
337 |
||
697 | 338 |
!TabWidget methodsFor:'change & update'! |
339 |
||
340 |
labelChanged |
|
341 |
printableLabel := nil |
|
342 |
! ! |
|
343 |
||
343 | 344 |
!TabWidget methodsFor:'drawing'! |
345 |
||
369 | 346 |
redraw:isSelected |
347 |
"redraw tab |
|
348 |
" |
|
697 | 349 |
|direction| |
369 | 350 |
|
351 |
direction := tabView direction. |
|
352 |
||
697 | 353 |
direction == #top ifTrue:[ |
354 |
self redrawAtTop:isSelected |
|
369 | 355 |
] ifFalse:[ |
697 | 356 |
direction == #bottom ifTrue:[ |
357 |
self redrawAtBottom:isSelected |
|
369 | 358 |
] ifFalse:[ |
697 | 359 |
direction == #right ifTrue:[ self redrawAtRight:isSelected ] |
360 |
ifFalse:[ self redrawAtLeft:isSelected ] |
|
361 |
] |
|
369 | 362 |
]. |
697 | 363 |
self redrawLabel |
392 | 364 |
! |
365 |
||
419 | 366 |
redrawLabel |
367 |
"redraw label only |
|
368 |
" |
|
703 | 369 |
|fg direction origin originX originY anchor anchorX anchorY x y label| |
419 | 370 |
|
697 | 371 |
label := self printableLabel. |
419 | 372 |
direction := tabView direction. |
373 |
anchor := tabView styleAt:#labelAnchor. |
|
703 | 374 |
anchorX := anchor x. |
375 |
anchorY := anchor y. |
|
419 | 376 |
origin := self computeOrigin. |
703 | 377 |
originX := origin x. |
378 |
originY := origin y. |
|
419 | 379 |
|
697 | 380 |
"/ set label color |
381 |
||
382 |
self printableLabel. |
|
383 |
||
384 |
self isEnabled ifTrue:[ |
|
385 |
label := printableLabel. |
|
386 |
(model notNil and:[(fg := model foregroundColor) notNil]) ifTrue:[ |
|
387 |
fgColor = fg ifFalse:[ |
|
388 |
fgColor := fg on:(tabView device) |
|
389 |
]. |
|
390 |
tabView paint:fgColor |
|
391 |
] ifFalse:[ |
|
392 |
tabView paintColor:#labelColor |
|
393 |
] |
|
394 |
] ifFalse:[ |
|
395 |
label := disabledLabel. |
|
396 |
tabView paintColor:#shadowColorUnselected. |
|
397 |
]. |
|
419 | 398 |
|
399 |
(direction == #top or:[direction == #bottom]) ifTrue:[ |
|
703 | 400 |
y := originY. |
401 |
x := originX + anchorX. |
|
419 | 402 |
|
403 |
direction == #top ifTrue:[ |
|
703 | 404 |
y := y + anchorY. |
419 | 405 |
] ifFalse:[ |
703 | 406 |
y := y - anchorY - (label heightOn:tabView). |
419 | 407 |
]. |
697 | 408 |
labelType == #string ifTrue:[ |
409 |
y := y + tabView fontAscent |
|
410 |
]. |
|
419 | 411 |
] ifFalse:[ |
412 |
direction == #right ifTrue:[ |
|
703 | 413 |
x := originX - anchorY - (label heightOn:tabView). |
419 | 414 |
] ifFalse:[ |
703 | 415 |
x := originX + anchorY. |
419 | 416 |
]. |
703 | 417 |
y := originY + anchorX. |
419 | 418 |
|
697 | 419 |
labelType == #string ifTrue:[ |
420 |
x := x + tabView fontDescent. |
|
703 | 421 |
"/ workaround for a bug in display-with-angle, |
422 |
"/ iff displayed string is a labelAndIcon. |
|
423 |
"/ (In this case, display is always opaque, and the current |
|
424 |
"/ backgroundPaint color is used to fill the underlying rectangle) |
|
425 |
"/ |
|
426 |
tabView backgroundPaint:(tabView getBackgroundPaintForTab:self). |
|
419 | 427 |
tabView displayString:label x:x y:y angle:90. |
428 |
^ self. |
|
429 |
]. |
|
430 |
]. |
|
431 |
label displayOn:tabView x:x y:y. |
|
369 | 432 |
! ! |
433 |
||
434 |
!TabWidget methodsFor:'initialization'! |
|
435 |
||
436 |
label:aLabel for:aTabView |
|
437 |
"initialize attributes |
|
438 |
" |
|
439 |
tabView := aTabView. |
|
440 |
label := aLabel. |
|
697 | 441 |
model := (label isKindOf:TabItem) ifTrue:[label] ifFalse:[nil] |
442 |
||
369 | 443 |
! ! |
444 |
||
445 |
!TabWidget methodsFor:'private'! |
|
446 |
||
367 | 447 |
computeCorner |
448 |
"compute corner |
|
449 |
" |
|
450 |
|d c| |
|
451 |
||
452 |
c := anchor + extent. |
|
453 |
d := tabView direction. |
|
454 |
||
455 |
d == #top ifTrue:[^ ( c x @ (tabView extent y) )]. |
|
456 |
d == #left ifTrue:[^ ( (tabView extent x) @ c y ) ]. |
|
457 |
d == #right ifTrue:[^ ( 0 @ c y )]. |
|
458 |
d == #bottom ifTrue:[^ ( c x @ 0 )]. |
|
459 |
||
460 |
self error. |
|
461 |
! |
|
462 |
||
463 |
computeOrigin |
|
464 |
"compute origin |
|
465 |
" |
|
466 |
|d| |
|
467 |
||
468 |
d := tabView direction. |
|
469 |
||
470 |
d == #top ifTrue:[ ^ anchor x @ ((tabView extent y) - anchor y) ]. |
|
471 |
d == #left ifTrue:[ ^ ((tabView extent x) - anchor x) @ anchor y ]. |
|
472 |
d == #right ifTrue:[ ^ anchor ]. |
|
473 |
d == #bottom ifTrue:[ ^ anchor ]. |
|
474 |
||
475 |
self error |
|
343 | 476 |
! ! |
477 |
||
478 |
!TabWidget methodsFor:'queries'! |
|
479 |
||
480 |
containsPoint:aPoint |
|
367 | 481 |
"return true, if a point is contained in the tab |
343 | 482 |
" |
1220 | 483 |
|d origin |
484 |
originX "{ Class: SmallInteger }" |
|
485 |
originY "{ Class: SmallInteger }" |
|
486 |
w "{ Class: SmallInteger }" |
|
487 |
h "{ Class: SmallInteger }" |
|
488 |
x "{ Class: SmallInteger }" |
|
489 |
y "{ Class: SmallInteger }"| |
|
343 | 490 |
|
367 | 491 |
d := tabView direction. |
343 | 492 |
x := aPoint x. |
367 | 493 |
y := aPoint y. |
343 | 494 |
|
367 | 495 |
origin := self computeOrigin. |
1220 | 496 |
originX := origin x. |
497 |
originY := origin y. |
|
498 |
w := extent x. |
|
499 |
h := extent y. |
|
367 | 500 |
|
501 |
(d == #top or:[d == #bottom]) ifTrue:[ |
|
1220 | 502 |
((x >= originX) and:[x <= (originX + w)]) ifTrue:[ |
367 | 503 |
d == #top ifTrue:[ |
1220 | 504 |
^ ((y >= originY) and:[y <= (originY + h)]) |
367 | 505 |
]. |
1220 | 506 |
^ ((y <= originY) and:[y >= (originY - h)]) |
367 | 507 |
] |
508 |
] ifFalse:[ |
|
1220 | 509 |
((y >= originY) and:[y <= (originY + h)]) ifTrue:[ |
367 | 510 |
d == #right ifTrue:[ |
1220 | 511 |
^ ((x <= originX) and:[x >= (originX - w)]) |
367 | 512 |
]. |
1220 | 513 |
^ ((x >= originX) and:[x <= (originX + w)]) |
367 | 514 |
] |
343 | 515 |
]. |
367 | 516 |
^ false |
549 | 517 |
! |
518 |
||
519 |
intersects:aRectangle |
|
520 |
"return true, if the intersection between the tab widget and |
|
521 |
the argument, aRectangle is not empty |
|
522 |
" |
|
551 | 523 |
|origin corner direction irect| |
549 | 524 |
|
525 |
origin := self computeOrigin. |
|
526 |
corner := self computeCorner. |
|
527 |
||
528 |
direction := tabView direction. |
|
529 |
||
530 |
direction == #top ifTrue:[ |
|
551 | 531 |
irect := (Rectangle origin:origin corner:corner) |
532 |
] ifFalse:[ |
|
533 |
direction == #bottom ifTrue:[ |
|
534 |
irect := (Rectangle origin:(origin x @ corner y) corner:(corner x @ origin y)) |
|
535 |
] ifFalse:[ |
|
536 |
direction == #right ifTrue:[ |
|
537 |
irect := (Rectangle origin:(corner x @ origin y) corner:(origin x @ corner y)) |
|
538 |
] ifFalse:[ |
|
539 |
irect := (Rectangle origin:origin corner:corner) |
|
540 |
] |
|
541 |
] |
|
549 | 542 |
]. |
543 |
||
551 | 544 |
^ aRectangle intersects:irect |
697 | 545 |
! |
546 |
||
547 |
isEnabled |
|
548 |
||
549 |
^ (tabView isEnabled and:[(model isNil or:[model isEnabled])]) |
|
550 |
||
551 |
! |
|
552 |
||
553 |
model |
|
554 |
^ model |
|
555 |
||
549 | 556 |
! ! |
557 |
||
558 |
!TabWidget::Mac class methodsFor:'accessing'! |
|
559 |
||
560 |
tabStyleOn:aView |
|
561 |
|style| |
|
562 |
||
563 |
style := super tabStyleOn:aView. |
|
564 |
style at:#tabLevel put:2. |
|
565 |
^ style. |
|
566 |
! ! |
|
567 |
||
568 |
!TabWidget::Mac class methodsFor:'calculate dimensions'! |
|
569 |
||
570 |
validateDimensions:aStyle |
|
571 |
"validate dimensions for a style; could be redifined |
|
572 |
" |
|
573 |
|maxY maxX anchor lftIns| |
|
574 |
||
575 |
maxY := aStyle at:#maxY. |
|
576 |
maxX := (aStyle at:#maxX) - (aStyle at:#labelLeftInset). |
|
577 |
anchor := aStyle at:#labelAnchor. |
|
578 |
lftIns := maxY // 2. |
|
579 |
||
580 |
anchor x:lftIns. |
|
581 |
||
582 |
aStyle at:#maxX put:(maxX + lftIns + maxY). |
|
583 |
aStyle at:#rightCovered put:(maxY // 2). |
|
584 |
! ! |
|
585 |
||
586 |
!TabWidget::Mac methodsFor:'drawing'! |
|
587 |
||
588 |
redrawAtBottom:isSelected |
|
589 |
"redraw tab at bottom of view |
|
590 |
" |
|
591 |
|origin corner level polygon x y x1 eX eY shadowColor lightColor| |
|
592 |
||
593 |
isSelected ifFalse:[ |
|
594 |
lightColor := tabView styleAt:#lightColorUnselected. |
|
595 |
shadowColor := tabView styleAt:#shadowColorUnselected. |
|
596 |
tabView paint:(tabView styleAt:#unselectedColor). |
|
597 |
] ifTrue:[ |
|
598 |
lightColor := tabView styleAt:#lightColorSelected. |
|
599 |
shadowColor := tabView styleAt:#shadowColorSelected. |
|
600 |
tabView paint:(tabView styleAt:#selectedColor). |
|
601 |
]. |
|
602 |
polygon := Array new:5. |
|
603 |
origin := self computeOrigin. |
|
604 |
corner := self computeCorner. |
|
605 |
level := tabView styleAt:#tabLevel. |
|
606 |
||
607 |
x := origin x. |
|
608 |
y := origin y. |
|
609 |
eX := corner x. |
|
610 |
eY := corner y. |
|
611 |
x1 := eX - (tabView styleAt:#maxY). |
|
612 |
||
613 |
polygon at:1 put:(Point x:x y:eY). |
|
614 |
polygon at:2 put:(Point x:x y:y). |
|
615 |
polygon at:3 put:(Point x:x1 y:y). |
|
616 |
polygon at:4 put:(Point x:eX y:(y-extent y)). |
|
617 |
polygon at:5 put:(Point x:eX y:eY). |
|
618 |
||
619 |
tabView fillPolygon:polygon. |
|
620 |
tabView paint:lightColor. |
|
621 |
||
622 |
1 to:level do:[:i| |
|
894
d5a703c21f7a
fixed shadow/light colors in tab-drawing
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
623 |
"/ removed: cg |
d5a703c21f7a
fixed shadow/light colors in tab-drawing
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
624 |
"/ tabView displayLineFromX:x+1 y:y-i toX:x1+i y:y-i. |
549 | 625 |
tabView displayLineFromX:x+i y:y-1 toX:x+i y:1. |
626 |
]. |
|
627 |
tabView paint:shadowColor. |
|
894
d5a703c21f7a
fixed shadow/light colors in tab-drawing
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
628 |
|
d5a703c21f7a
fixed shadow/light colors in tab-drawing
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
629 |
"/ added: cg |
d5a703c21f7a
fixed shadow/light colors in tab-drawing
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
630 |
1 to:(level-2) do:[:i| |
d5a703c21f7a
fixed shadow/light colors in tab-drawing
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
631 |
tabView displayLineFromX:x+1 y:y-i toX:x1+i y:y-i. |
d5a703c21f7a
fixed shadow/light colors in tab-drawing
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
632 |
]. |
549 | 633 |
tabView displayPolygon:polygon. |
634 |
||
635 |
isSelected ifFalse:[ |
|
636 |
tabView displayLineFromX:x y:eY toX:eX y:eY. |
|
637 |
] |
|
894
d5a703c21f7a
fixed shadow/light colors in tab-drawing
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
638 |
|
d5a703c21f7a
fixed shadow/light colors in tab-drawing
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
639 |
"Modified: / 21.5.1998 / 01:16:32 / cg" |
549 | 640 |
! |
641 |
||
642 |
redrawAtLeft:isSelected |
|
643 |
"redraw tab at left of view |
|
644 |
" |
|
645 |
|origin corner polygon level x y y1 eX eY shadowColor lightColor| |
|
646 |
||
647 |
isSelected ifFalse:[ |
|
648 |
lightColor := tabView styleAt:#lightColorUnselected. |
|
649 |
shadowColor := tabView styleAt:#shadowColorUnselected. |
|
650 |
tabView paint:(tabView styleAt:#unselectedColor). |
|
651 |
] ifTrue:[ |
|
652 |
lightColor := tabView styleAt:#lightColorSelected. |
|
653 |
shadowColor := tabView styleAt:#shadowColorSelected. |
|
654 |
tabView paint:(tabView styleAt:#selectedColor). |
|
655 |
]. |
|
656 |
polygon := Array new:5. |
|
657 |
origin := self computeOrigin. |
|
658 |
corner := self computeCorner. |
|
659 |
level := tabView styleAt:#tabLevel. |
|
660 |
||
661 |
x := origin x. |
|
662 |
y := origin y. |
|
663 |
eX := corner x. |
|
664 |
eY := corner y. |
|
665 |
y1 := eY - (tabView styleAt:#maxY). |
|
666 |
||
667 |
polygon at:1 put:(Point x:eX y:y). |
|
668 |
polygon at:2 put:(Point x:x y:y). |
|
669 |
polygon at:3 put:(Point x:x y:y1). |
|
670 |
polygon at:4 put:(Point x:(x+extent x) y:eY). |
|
671 |
polygon at:5 put:(Point x:eX y:eY). |
|
672 |
||
673 |
tabView fillPolygon:polygon. |
|
674 |
tabView paint:lightColor. |
|
675 |
||
676 |
1 to:level do:[:i| |
|
677 |
tabView displayLineFromX:eX y:y+i toX:x+2 y:y+i. |
|
678 |
tabView displayLineFromX:x+i y:y+1 toX:x+i y:y1+i. |
|
679 |
]. |
|
680 |
tabView paint:shadowColor. |
|
681 |
tabView displayPolygon:polygon. |
|
682 |
||
683 |
isSelected ifFalse:[ |
|
684 |
tabView displayLineFromX:eX-1 y:y toX:eX-1 y:eY. |
|
685 |
] |
|
686 |
! |
|
687 |
||
688 |
redrawAtRight:isSelected |
|
689 |
"redraw tab at right of view |
|
690 |
" |
|
691 |
|origin corner level polygon x y y1 eY shadowColor lightColor| |
|
692 |
||
693 |
isSelected ifFalse:[ |
|
694 |
lightColor := tabView styleAt:#lightColorUnselected. |
|
695 |
shadowColor := tabView styleAt:#shadowColorUnselected. |
|
696 |
tabView paint:(tabView styleAt:#unselectedColor). |
|
697 |
] ifTrue:[ |
|
698 |
lightColor := tabView styleAt:#lightColorSelected. |
|
699 |
shadowColor := tabView styleAt:#shadowColorSelected. |
|
700 |
tabView paint:(tabView styleAt:#selectedColor). |
|
701 |
]. |
|
702 |
polygon := Array new:5. |
|
703 |
origin := self computeOrigin. |
|
704 |
corner := self computeCorner. |
|
705 |
level := tabView styleAt:#tabLevel. |
|
706 |
||
707 |
x := origin x. |
|
708 |
y := origin y. |
|
709 |
eY := corner y. |
|
710 |
y1 := eY - (tabView styleAt:#maxY). |
|
711 |
||
712 |
polygon at:1 put:(Point x:0 y:y). |
|
713 |
polygon at:2 put:(Point x:x y:y). |
|
714 |
polygon at:3 put:(Point x:x y:y1). |
|
715 |
polygon at:4 put:(Point x:(x-extent x) y:eY). |
|
716 |
polygon at:5 put:(Point x:0 y:eY). |
|
717 |
||
718 |
tabView fillPolygon:polygon. |
|
719 |
tabView paint:lightColor. |
|
720 |
||
721 |
1 to:level do:[:i| |
|
722 |
tabView displayLineFromX:0 y:y+i toX:x-1 y:y+i. |
|
894
d5a703c21f7a
fixed shadow/light colors in tab-drawing
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
723 |
"/ removed: cg |
d5a703c21f7a
fixed shadow/light colors in tab-drawing
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
724 |
"/ tabView displayLineFromX:x-i y:y+1 toX:x-i y:y1+i. |
549 | 725 |
]. |
726 |
tabView paint:shadowColor. |
|
727 |
tabView displayPolygon:polygon. |
|
728 |
||
894
d5a703c21f7a
fixed shadow/light colors in tab-drawing
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
729 |
"/ added: cg |
d5a703c21f7a
fixed shadow/light colors in tab-drawing
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
730 |
1 to:level-2 do:[:i| |
d5a703c21f7a
fixed shadow/light colors in tab-drawing
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
731 |
tabView displayLineFromX:x-i y:y+1 toX:x-i y:y1+i. |
d5a703c21f7a
fixed shadow/light colors in tab-drawing
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
732 |
]. |
d5a703c21f7a
fixed shadow/light colors in tab-drawing
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
733 |
|
549 | 734 |
isSelected ifFalse:[ |
735 |
tabView displayLineFromX:0 y:y toX:0 y:eY. |
|
736 |
] |
|
737 |
||
894
d5a703c21f7a
fixed shadow/light colors in tab-drawing
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
738 |
"Modified: / 21.5.1998 / 01:16:24 / cg" |
549 | 739 |
! |
740 |
||
741 |
redrawAtTop:isSelected |
|
742 |
"redraw tab at top of view |
|
743 |
" |
|
744 |
|origin corner level polygon x y x1 eX eY shadowColor lightColor| |
|
745 |
||
746 |
isSelected ifFalse:[ |
|
747 |
lightColor := tabView styleAt:#lightColorUnselected. |
|
748 |
shadowColor := tabView styleAt:#shadowColorUnselected. |
|
749 |
tabView paint:(tabView styleAt:#unselectedColor). |
|
750 |
] ifTrue:[ |
|
751 |
lightColor := tabView styleAt:#lightColorSelected. |
|
752 |
shadowColor := tabView styleAt:#shadowColorSelected. |
|
753 |
tabView paint:(tabView styleAt:#selectedColor). |
|
754 |
]. |
|
755 |
polygon := Array new:5. |
|
756 |
origin := self computeOrigin. |
|
757 |
corner := self computeCorner. |
|
758 |
level := tabView styleAt:#tabLevel. |
|
759 |
||
760 |
x := origin x. |
|
761 |
y := origin y. |
|
762 |
eX := corner x - 1. |
|
763 |
eY := corner y. |
|
764 |
x1 := eX - (tabView styleAt:#maxY). |
|
765 |
||
766 |
polygon at:1 put:(Point x:x y:eY). |
|
767 |
polygon at:2 put:(Point x:x y:y). |
|
768 |
polygon at:3 put:(Point x:x1 y:y). |
|
769 |
polygon at:4 put:(Point x:eX y:(y+extent y)). |
|
770 |
polygon at:5 put:(Point x:eX y:eY). |
|
771 |
||
772 |
tabView fillPolygon:polygon. |
|
773 |
tabView paint:lightColor. |
|
774 |
||
775 |
1 to:level do:[:i| |
|
776 |
tabView displayLineFromX:x+i y:eY toX:x+i y:y+1. |
|
777 |
tabView displayLineFromX:x+1 y:y+i toX:x1+i y:y+i. |
|
778 |
]. |
|
779 |
tabView paint:shadowColor. |
|
780 |
tabView displayPolygon:polygon. |
|
781 |
||
782 |
isSelected ifFalse:[ |
|
783 |
tabView displayLineFromX:x y:eY-1 toX:eX y:eY-1. |
|
784 |
] |
|
785 |
||
786 |
||
343 | 787 |
! ! |
788 |
||
367 | 789 |
!TabWidget::Window class methodsFor:'accessing'! |
350 | 790 |
|
791 |
tabStyleOn:aView |
|
474 | 792 |
|style| |
350 | 793 |
|
794 |
style := super tabStyleOn:aView. |
|
795 |
||
367 | 796 |
style at:#expandSelection put:4@4. |
797 |
style at:#tabLevel put:2. |
|
1381 | 798 |
style at:#labelTopInset put:0. |
799 |
style at:#labelBottomInset put:0. |
|
367 | 800 |
style at:#roundedEdges put:true. |
801 |
^ style |
|
350 | 802 |
|
1381 | 803 |
"Modified: / 20.5.1999 / 19:18:04 / cg" |
350 | 804 |
! ! |
805 |
||
367 | 806 |
!TabWidget::Window class methodsFor:'calculate dimensions'! |
807 |
||
808 |
validateDimensions:aStyle |
|
809 |
"validate dimensions for a style; could be redifined |
|
810 |
" |
|
811 |
|maxY anchor| |
|
350 | 812 |
|
367 | 813 |
(aStyle at:#roundedEdges) ifTrue:[ |
814 |
maxY := aStyle at:#maxY. |
|
815 |
aStyle at:#maxY put:(maxY + 3). |
|
816 |
anchor := aStyle at:#labelAnchor. |
|
817 |
anchor y:(anchor y + 1). |
|
818 |
aStyle at:#labelAnchor put:anchor. |
|
819 |
] |
|
820 |
||
821 |
||
822 |
||
350 | 823 |
|
824 |
||
825 |
! ! |
|
826 |
||
367 | 827 |
!TabWidget::Window methodsFor:'drawing'! |
828 |
||
829 |
redrawAtBottom:isSelected |
|
830 |
"redraw tab at bottom of view |
|
831 |
" |
|
474 | 832 |
|origin corner y x xR yB tabLevel roundedEdges shadowColor lightColor| |
367 | 833 |
|
834 |
origin := self computeOrigin. |
|
835 |
corner := self computeCorner. |
|
836 |
x := origin x. |
|
837 |
y := origin y. |
|
838 |
xR := corner x - 1. |
|
839 |
yB := 0. |
|
840 |
||
841 |
roundedEdges := tabView styleAt:#roundedEdges. |
|
842 |
tabLevel := (tabView styleAt:#tabLevel) - 1. |
|
843 |
||
844 |
isSelected ifFalse:[ |
|
845 |
tabView paint:(tabView styleAt:#unselectedColor). |
|
846 |
shadowColor := tabView styleAt:#shadowColorUnselected. |
|
847 |
lightColor := tabView styleAt:#lightColorUnselected. |
|
848 |
] ifTrue:[ |
|
849 |
tabView paint:(tabView styleAt:#selectedColor). |
|
850 |
shadowColor := tabView styleAt:#shadowColorSelected. |
|
851 |
lightColor := tabView styleAt:#lightColorSelected. |
|
852 |
]. |
|
853 |
||
854 |
roundedEdges ifTrue:[y := y - 2]. |
|
855 |
tabView fillRectangle:(Rectangle left:x top:yB extent:(extent x @ y)). |
|
350 | 856 |
|
367 | 857 |
roundedEdges ifTrue:[ |
858 |
tabView displayLineFromX:x-1 y:y toX:xR y:y. |
|
859 |
y := y - 1. |
|
860 |
||
861 |
tabView paint:lightColor. |
|
862 |
tabView displayPointX:x y:y+1. |
|
863 |
tabView displayPointX:x+1 y:y+1. |
|
894
d5a703c21f7a
fixed shadow/light colors in tab-drawing
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
864 |
|
d5a703c21f7a
fixed shadow/light colors in tab-drawing
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
865 |
tabView paint:shadowColor. |
367 | 866 |
tabView displayLineFromX:x+1 y:y+2 toX:xR-1 y:y+2. |
867 |
tabView displayLineFromX:x+2 y:y+3 toX:xR-2 y:y+3. |
|
868 |
||
869 |
0 to:tabLevel do:[:i | |
|
870 |
tabView displayPointX:xR-i y:y. |
|
871 |
tabView displayPointX:xR-i y:y+1. |
|
872 |
tabView displayPointX:xR-1-i y:y+2. |
|
873 |
]. |
|
874 |
tabView displayPointX:xR-2 y:y+3. |
|
875 |
tabView displayPointX:xR-3 y:y+3. |
|
876 |
]. |
|
877 |
||
878 |
tabView paint:lightColor. |
|
879 |
||
880 |
0 to:tabLevel do:[:i | |
|
881 |
roundedEdges ifFalse:[ |
|
882 |
tabView displayLineFromX:x y:y-i toX:xR y:y-i "/ upper edge |
|
883 |
]. |
|
884 |
tabView displayLineFromX:x+i y:y+1 toX:x+i y:yB. "/ left edge |
|
885 |
]. |
|
886 |
y := y + 1. |
|
887 |
tabView paint:shadowColor. |
|
888 |
||
889 |
0 to:tabLevel do:[:i | |
|
890 |
tabView displayLineFromX:xR-i y:y-i toX:xR-i y:yB. "/ right edge |
|
891 |
]. |
|
350 | 892 |
|
894
d5a703c21f7a
fixed shadow/light colors in tab-drawing
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
893 |
"Modified: / 21.5.1998 / 01:07:01 / cg" |
350 | 894 |
! |
895 |
||
367 | 896 |
redrawAtLeft:isSelected |
897 |
"redraw tab at left of view |
|
350 | 898 |
" |
474 | 899 |
|origin corner y x xR yB tabLevel roundedEdges shadowColor lightColor| |
367 | 900 |
|
901 |
origin := self computeOrigin. |
|
902 |
corner := self computeCorner. |
|
903 |
x := origin x. |
|
904 |
y := origin y. |
|
905 |
xR := corner x. |
|
906 |
yB := corner y. |
|
907 |
||
908 |
roundedEdges := tabView styleAt:#roundedEdges. |
|
909 |
tabLevel := (tabView styleAt:#tabLevel) - 1. |
|
910 |
||
911 |
isSelected ifFalse:[ |
|
912 |
tabView paint:(tabView styleAt:#unselectedColor). |
|
913 |
shadowColor := tabView styleAt:#shadowColorUnselected. |
|
914 |
lightColor := tabView styleAt:#lightColorUnselected. |
|
915 |
] ifTrue:[ |
|
916 |
tabView paint:(tabView styleAt:#selectedColor). |
|
917 |
shadowColor := tabView styleAt:#shadowColorSelected. |
|
918 |
lightColor := tabView styleAt:#lightColorSelected. |
|
919 |
]. |
|
920 |
tabView fillRectangle:(Rectangle left:x top:y extent:(xR @ extent y)). |
|
921 |
||
922 |
roundedEdges ifTrue:[ |
|
923 |
tabView displayLineFromX:x y:y toX:x y:yB. |
|
924 |
||
925 |
tabView paint:lightColor. |
|
926 |
tabView displayPointX:x y:y+1. |
|
927 |
tabView displayPointX:x y:y+2. |
|
928 |
tabView displayLineFromX:x-1 y:y+2 toX:x-1 y:yB-1. |
|
929 |
tabView displayLineFromX:x-2 y:y+3 toX:x-2 y:yB-1. |
|
930 |
||
931 |
tabView paint:shadowColor. |
|
350 | 932 |
|
367 | 933 |
0 to:tabLevel do:[:i | |
934 |
tabView displayPointX:x y:yB-i. |
|
935 |
tabView displayPointX:x-1 y:yB-i-1. |
|
936 |
tabView displayPointX:x-2 y:yB-i-2. |
|
937 |
]. |
|
938 |
]. |
|
939 |
tabView paint:lightColor. |
|
940 |
||
941 |
0 to:tabLevel do:[:i | |
|
942 |
roundedEdges ifFalse:[ |
|
943 |
tabView displayLineFromX:x+i y:y+i toX:x+i y:yB. "/ upper edge |
|
944 |
]. |
|
945 |
tabView displayLineFromX:x y:y+i toX:xR y:y+i. "/ left edge |
|
946 |
]. |
|
947 |
tabView paint:shadowColor. |
|
350 | 948 |
|
367 | 949 |
0 to:tabLevel do:[:i | |
950 |
tabView displayLineFromX:x+i y:yB-i toX:xR y:yB-i. |
|
951 |
]. |
|
952 |
||
953 |
! |
|
954 |
||
955 |
redrawAtRight:isSelected |
|
956 |
"redraw tab at right of view |
|
957 |
" |
|
474 | 958 |
|origin corner y x xR yB tabLevel roundedEdges shadowColor lightColor| |
367 | 959 |
|
960 |
origin := self computeOrigin. |
|
961 |
corner := self computeCorner. |
|
962 |
x := origin x. |
|
963 |
y := origin y. |
|
964 |
xR := corner x - 1. |
|
965 |
yB := corner y. |
|
966 |
||
967 |
roundedEdges := tabView styleAt:#roundedEdges. |
|
968 |
tabLevel := (tabView styleAt:#tabLevel) - 1. |
|
350 | 969 |
|
970 |
isSelected ifFalse:[ |
|
367 | 971 |
tabView paint:(tabView styleAt:#unselectedColor). |
350 | 972 |
shadowColor := tabView styleAt:#shadowColorUnselected. |
367 | 973 |
lightColor := tabView styleAt:#lightColorUnselected. |
350 | 974 |
] ifTrue:[ |
367 | 975 |
tabView paint:(tabView styleAt:#selectedColor). |
350 | 976 |
shadowColor := tabView styleAt:#shadowColorSelected. |
367 | 977 |
lightColor := tabView styleAt:#lightColorSelected. |
350 | 978 |
]. |
367 | 979 |
tabView fillRectangle:(Rectangle left:0 top:y extent:(x @ extent y)). |
980 |
||
981 |
roundedEdges ifTrue:[ |
|
982 |
tabView displayLineFromX:x y:y toX:x y:yB. |
|
350 | 983 |
|
367 | 984 |
tabView paint:lightColor. |
985 |
tabView displayPointX:x y:y+1. |
|
986 |
tabView displayPointX:x y:y+2. |
|
894
d5a703c21f7a
fixed shadow/light colors in tab-drawing
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
987 |
|
d5a703c21f7a
fixed shadow/light colors in tab-drawing
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
988 |
tabView paint:shadowColor. |
367 | 989 |
tabView displayLineFromX:x+1 y:y+2 toX:x+1 y:yB-1. |
990 |
tabView displayLineFromX:x+2 y:y+3 toX:x+2 y:yB-1. |
|
991 |
||
992 |
0 to:tabLevel do:[:i | |
|
993 |
tabView displayPointX:x y:yB-i. |
|
994 |
tabView displayPointX:x+1 y:yB-i-1. |
|
995 |
tabView displayPointX:x+2 y:yB-i-2. |
|
996 |
]. |
|
997 |
]. |
|
350 | 998 |
tabView paint:lightColor. |
999 |
||
367 | 1000 |
0 to:tabLevel do:[:i | |
1001 |
roundedEdges ifFalse:[ |
|
1002 |
tabView displayLineFromX:x-i y:y+i toX:x-i y:yB. "/ upper edge |
|
1003 |
]. |
|
1004 |
tabView displayLineFromX:x y:y+i+1 toX:0 y:y+i+1. "/ left edge |
|
1005 |
]. |
|
1006 |
tabView paint:shadowColor. |
|
1007 |
||
1008 |
0 to:tabLevel do:[:i | |
|
1009 |
tabView displayLineFromX:x-i+1 y:yB-i toX:1 y:yB-i. |
|
1010 |
]. |
|
894
d5a703c21f7a
fixed shadow/light colors in tab-drawing
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
1011 |
|
d5a703c21f7a
fixed shadow/light colors in tab-drawing
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
1012 |
"Modified: / 21.5.1998 / 01:04:41 / cg" |
367 | 1013 |
! |
1014 |
||
1015 |
redrawAtTop:isSelected |
|
1016 |
"redraw tab at top of view |
|
1017 |
" |
|
474 | 1018 |
|origin corner y x xR yB tabLevel roundedEdges shadowColor lightColor| |
367 | 1019 |
|
1020 |
origin := self computeOrigin. |
|
1021 |
corner := self computeCorner. |
|
1022 |
x := origin x. |
|
1023 |
y := origin y. |
|
1024 |
xR := corner x - 1. |
|
1025 |
yB := corner y. |
|
1026 |
||
1027 |
roundedEdges := tabView styleAt:#roundedEdges. |
|
1028 |
tabLevel := (tabView styleAt:#tabLevel) - 1. |
|
1029 |
||
1030 |
isSelected ifFalse:[ |
|
1031 |
tabView paint:(tabView styleAt:#unselectedColor). |
|
1032 |
shadowColor := tabView styleAt:#shadowColorUnselected. |
|
1033 |
lightColor := tabView styleAt:#lightColorUnselected. |
|
1034 |
] ifTrue:[ |
|
1035 |
tabView paint:(tabView styleAt:#selectedColor). |
|
1036 |
shadowColor := tabView styleAt:#shadowColorSelected. |
|
1037 |
lightColor := tabView styleAt:#lightColorSelected. |
|
350 | 1038 |
]. |
1039 |
||
367 | 1040 |
roundedEdges ifTrue:[ y := y + 2]. |
1041 |
tabView fillRectangle:(Rectangle left:x top:y extent:((extent x) @ yB)). |
|
1042 |
||
1043 |
roundedEdges ifTrue:[ |
|
1044 |
y := y + 1. |
|
1045 |
tabView displayLineFromX:x y:y-1 toX:xR y:y-1. |
|
1046 |
tabView displayLineFromX:x+1 y:y-2 toX:xR-1 y:y-2. |
|
1047 |
tabView displayLineFromX:x+2 y:y-3 toX:xR-2 y:y-3. |
|
1048 |
||
1049 |
tabView paint:lightColor. |
|
1050 |
||
1051 |
0 to:tabLevel do:[:i | |
|
1052 |
tabView displayPointX:x+i y:y-1. |
|
1053 |
tabView displayPointX:x+1+i y:y-1-1. |
|
1054 |
tabView displayLineFromX:x+2+i y:y-3-i toX:xR-1-i y:y-3-i. "/ top |
|
1055 |
]. |
|
1056 |
||
1057 |
tabView paint:shadowColor. |
|
1058 |
0 to:tabLevel do:[:i | |
|
1059 |
tabView displayPointX:xR-i y:y. |
|
1060 |
tabView displayPointX:xR-i y:y-1. |
|
1061 |
tabView displayPointX:xR-1-i y:y-1-1. |
|
1062 |
]. |
|
1063 |
tabView displayPointX:xR-2 y:y-1-1-1. |
|
1064 |
tabView displayPointX:xR-3 y:y-1-1-1. |
|
350 | 1065 |
]. |
1066 |
||
367 | 1067 |
tabView paint:lightColor. |
1068 |
0 to:tabLevel do:[:i | |
|
1069 |
roundedEdges ifFalse:[ |
|
1070 |
tabView displayLineFromX:x y:y+i toX:xR y:y+i. "/ upper edge |
|
1071 |
]. |
|
1072 |
tabView displayLineFromX:x+i y:y toX:x+i y:yB. "/ left edge |
|
1073 |
]. |
|
1074 |
tabView paint:shadowColor. |
|
1075 |
0 to:tabLevel do:[:i | |
|
1076 |
tabView displayLineFromX:xR-i y:y+i toX:xR-i y:yB. "/ right edge |
|
1077 |
]. |
|
350 | 1078 |
! ! |
1079 |
||
343 | 1080 |
!TabWidget class methodsFor:'documentation'! |
1081 |
||
1082 |
version |
|
1381 | 1083 |
^ '$Header: /cvs/stx/stx/libwidg2/TabWidget.st,v 1.20 1999-05-20 17:29:18 cg Exp $' |
343 | 1084 |
! ! |