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