278
|
1 |
BoundedWrapper subclass:#BorderedWrapper
|
|
2 |
instanceVariableNames:'border inset insideColor'
|
|
3 |
classVariableNames:''
|
|
4 |
poolDictionaries:''
|
|
5 |
category:'Graphics-Display Objects'
|
|
6 |
!
|
|
7 |
|
|
8 |
!BorderedWrapper class methodsFor:'documentation'!
|
|
9 |
|
283
|
10 |
documentation
|
|
11 |
"
|
|
12 |
a wrapper which controls the layout (origin & extent)
|
|
13 |
of its wrapped component and also draws a border around.
|
|
14 |
|
|
15 |
If insideColor is nonNil, the area is cleared to that color,
|
|
16 |
making the overall look be opaque.
|
|
17 |
|
|
18 |
Notice:
|
|
19 |
this class was implemented using protocol information
|
|
20 |
from alpha testers and from the Hopkins/Horan book.
|
|
21 |
- it may not be complete or compatible to the corresponding ST-80 class.
|
|
22 |
If you encounter any incompatibilities, please forward a note
|
|
23 |
describing the incompatibility verbal (i.e. no code) to the ST/X team.
|
|
24 |
|
|
25 |
[see also:]
|
|
26 |
Wrapper TranslatingWrapper GeometricWrapper
|
|
27 |
|
|
28 |
[author:]
|
|
29 |
Claus Gittinger
|
|
30 |
"
|
|
31 |
|
|
32 |
!
|
|
33 |
|
278
|
34 |
examples
|
|
35 |
"
|
|
36 |
[exBegin]
|
|
37 |
|t s v e component|
|
|
38 |
|
|
39 |
t := StandardSystemView extent:250@200.
|
|
40 |
s := HVScrollableView for:View miniScroller:true in:t.
|
|
41 |
s origin:0.0@0.0 corner:1.0@1.0.
|
|
42 |
v := s scrolledView.
|
|
43 |
|
|
44 |
e := Rectangle origin:0@0 corner:80@80.
|
|
45 |
component := FillingWrapper on:e.
|
|
46 |
component foregroundColor:Color red.
|
|
47 |
v addComponent:(BorderedWrapper on:component at:10@10).
|
|
48 |
|
|
49 |
e := EllipticalArc boundingBox:(0@0 corner:80@80)
|
|
50 |
startAngle:0 sweepAngle:360.
|
|
51 |
component := StrokingWrapper on:e.
|
283
|
52 |
component lineWidth:5; foregroundColor:Color yellow.
|
|
53 |
v addComponent:((BorderedWrapper on:component at:50@50)
|
|
54 |
insideColor:Color blue).
|
278
|
55 |
|
|
56 |
e := Arrow from:0@0 to:50@150.
|
|
57 |
component := StrokingWrapper on:e.
|
|
58 |
component lineWidth:2.
|
|
59 |
v addComponent:(BorderedWrapper on:component at:100@100).
|
|
60 |
|
|
61 |
t open
|
|
62 |
[exEnd]
|
|
63 |
"
|
|
64 |
! !
|
|
65 |
|
|
66 |
!BorderedWrapper class methodsFor:'instance creation'!
|
|
67 |
|
|
68 |
on:aComponent in:aLayout border:aBorder
|
|
69 |
^ (super on:aComponent in:aLayout) border:aBorder
|
|
70 |
|
|
71 |
"Created: 28.5.1996 / 23:15:00 / cg"
|
|
72 |
! !
|
|
73 |
|
|
74 |
!BorderedWrapper methodsFor:'accessing'!
|
|
75 |
|
|
76 |
border
|
|
77 |
"return border"
|
|
78 |
|
|
79 |
^ border
|
|
80 |
|
|
81 |
"Created: 28.5.1996 / 23:15:15 / cg"
|
|
82 |
!
|
|
83 |
|
|
84 |
border:something
|
|
85 |
"set border"
|
|
86 |
|
|
87 |
border := something.
|
|
88 |
|
|
89 |
"Created: 28.5.1996 / 23:15:15 / cg"
|
283
|
90 |
!
|
|
91 |
|
|
92 |
insideColor
|
|
93 |
"return the insideColor"
|
|
94 |
|
|
95 |
^ insideColor
|
|
96 |
|
|
97 |
"Created: 29.5.1996 / 11:09:58 / cg"
|
|
98 |
!
|
|
99 |
|
|
100 |
insideColor:aColorOrPixmap
|
|
101 |
"set the insideColor"
|
|
102 |
|
|
103 |
insideColor := aColorOrPixmap
|
|
104 |
|
|
105 |
"Created: 29.5.1996 / 11:10:16 / cg"
|
|
106 |
! !
|
|
107 |
|
|
108 |
!BorderedWrapper methodsFor:'accessing - bounds'!
|
|
109 |
|
|
110 |
bounds
|
|
111 |
^ component bounds + origin
|
|
112 |
|
|
113 |
"Created: 29.5.1996 / 11:09:39 / cg"
|
278
|
114 |
! !
|
|
115 |
|
|
116 |
!BorderedWrapper methodsFor:'displaying'!
|
|
117 |
|
|
118 |
displayOn:aGC
|
|
119 |
|bounds x y w h tX tY|
|
|
120 |
|
|
121 |
bounds := self bounds.
|
|
122 |
x := bounds left rounded.
|
|
123 |
y := bounds top rounded.
|
|
124 |
w := bounds width rounded.
|
|
125 |
h := bounds height rounded.
|
|
126 |
|
283
|
127 |
insideColor notNil ifTrue:[
|
|
128 |
aGC paint:insideColor.
|
|
129 |
aGC fillRectangleX:x y:y width:w height:h
|
|
130 |
].
|
|
131 |
|
|
132 |
super displayOn:aGC.
|
|
133 |
|
|
134 |
"/ drawEdgesForX: draws in deviceCoordinates - have to translate here.
|
|
135 |
|
278
|
136 |
tX := aGC translation x.
|
|
137 |
tY := aGC translation y.
|
|
138 |
|
|
139 |
aGC drawEdgesForX:x+tX
|
|
140 |
y:y+tY
|
|
141 |
width:w
|
|
142 |
height:h
|
|
143 |
level:1
|
|
144 |
shadow:Color black
|
|
145 |
light:Color white
|
|
146 |
halfShadow:Color grey
|
|
147 |
halfLight:Color grey
|
|
148 |
style:#iris
|
|
149 |
|
283
|
150 |
"Modified: 29.5.1996 / 11:30:34 / cg"
|
278
|
151 |
! !
|
|
152 |
|
|
153 |
!BorderedWrapper class methodsFor:'documentation'!
|
|
154 |
|
|
155 |
version
|
283
|
156 |
^ '$Header: /cvs/stx/stx/libview2/BorderedWrapper.st,v 1.2 1996-05-29 09:36:48 cg Exp $'
|
278
|
157 |
! !
|