245
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1996 by Claus Gittinger
|
|
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:#VisualComponent
|
|
16 |
instanceVariableNames:'bounds fgColor bgColor'
|
|
17 |
classVariableNames:''
|
|
18 |
poolDictionaries:''
|
|
19 |
category:'Graphics-Display Objects'
|
|
20 |
!
|
|
21 |
|
|
22 |
!VisualComponent class methodsFor:'documentation'!
|
|
23 |
|
|
24 |
copyright
|
|
25 |
"
|
|
26 |
COPYRIGHT (c) 1996 by Claus Gittinger
|
|
27 |
All Rights Reserved
|
|
28 |
|
|
29 |
This software is furnished under a license and may be used
|
|
30 |
only in accordance with the terms of that license and with the
|
|
31 |
inclusion of the above copyright notice. This software may not
|
|
32 |
be provided or otherwise made available to, or used by, any
|
|
33 |
other person. No title to or ownership of the software is
|
|
34 |
hereby transferred.
|
|
35 |
"
|
|
36 |
|
|
37 |
|
|
38 |
!
|
|
39 |
|
|
40 |
documentation
|
|
41 |
"
|
246
|
42 |
abstract superclass for all kinds of visual components.
|
265
|
43 |
This class and its subclasses (currently) exist mostly for
|
|
44 |
ST-80 compatibility - to provide a home for ported PD classes,
|
|
45 |
which depend on the VisualComponent hierarchy.
|
|
46 |
|
|
47 |
Notice:
|
|
48 |
this class was implemented using protocol information
|
|
49 |
from alpha testers and from the Hopkins/Horan book.
|
|
50 |
- it may not be complete or compatible to the corresponding ST-80 class.
|
|
51 |
If you encounter any incompatibilities, please forward a note
|
|
52 |
describing the incompatibility verbal (i.e. no code) to the ST/X team.
|
|
53 |
This is still being constructed - not yet finished.
|
245
|
54 |
|
|
55 |
[author:]
|
|
56 |
Claus Gittinger
|
265
|
57 |
|
|
58 |
[see also:]
|
|
59 |
GeometricWrapper
|
245
|
60 |
"
|
|
61 |
|
|
62 |
! !
|
|
63 |
|
|
64 |
!VisualComponent class methodsFor:'instance creation'!
|
|
65 |
|
|
66 |
new
|
|
67 |
^ self basicNew initialize
|
|
68 |
! !
|
|
69 |
|
|
70 |
!VisualComponent methodsFor:'accessing'!
|
|
71 |
|
|
72 |
bounds
|
246
|
73 |
"return my bounds"
|
|
74 |
|
245
|
75 |
^ bounds
|
|
76 |
|
|
77 |
"Created: 8.5.1996 / 23:35:19 / cg"
|
246
|
78 |
"Modified: 9.5.1996 / 00:12:00 / cg"
|
245
|
79 |
!
|
|
80 |
|
246
|
81 |
bounds:aRectangle
|
|
82 |
"set my bounds"
|
|
83 |
|
|
84 |
bounds := aRectangle
|
245
|
85 |
|
|
86 |
"Created: 8.5.1996 / 23:36:07 / cg"
|
246
|
87 |
"Modified: 9.5.1996 / 00:13:12 / cg"
|
245
|
88 |
!
|
|
89 |
|
250
|
90 |
container:someContainer
|
|
91 |
"ignored here"
|
|
92 |
|
|
93 |
"Created: 9.5.1996 / 00:48:54 / cg"
|
|
94 |
!
|
|
95 |
|
245
|
96 |
preferredBounds
|
246
|
97 |
"return my preferredBounds"
|
|
98 |
|
245
|
99 |
^ 100@100
|
|
100 |
|
|
101 |
"Created: 8.5.1996 / 23:36:29 / cg"
|
246
|
102 |
"Modified: 9.5.1996 / 00:13:22 / cg"
|
247
|
103 |
!
|
|
104 |
|
|
105 |
setParentViewIn:aView
|
|
106 |
"ignored here - for now"
|
|
107 |
|
|
108 |
"Created: 9.5.1996 / 00:19:39 / cg"
|
245
|
109 |
! !
|
|
110 |
|
|
111 |
!VisualComponent methodsFor:'accessing - look'!
|
|
112 |
|
|
113 |
backgroundColor:aColor
|
246
|
114 |
"set my backgroundColor"
|
|
115 |
|
245
|
116 |
bgColor := aColor
|
|
117 |
|
|
118 |
"Created: 8.5.1996 / 23:47:11 / cg"
|
246
|
119 |
"Modified: 9.5.1996 / 00:13:33 / cg"
|
245
|
120 |
!
|
|
121 |
|
|
122 |
foregroundColor:aColor
|
246
|
123 |
"set my foregroundColor"
|
|
124 |
|
245
|
125 |
fgColor := aColor
|
|
126 |
|
|
127 |
"Created: 8.5.1996 / 23:47:05 / cg"
|
246
|
128 |
"Modified: 9.5.1996 / 00:13:39 / cg"
|
245
|
129 |
! !
|
|
130 |
|
265
|
131 |
!VisualComponent methodsFor:'displaying'!
|
|
132 |
|
|
133 |
displayOn:aGC x:x y:y
|
|
134 |
|oldTranslation|
|
|
135 |
|
|
136 |
oldTranslation := aGC translation.
|
|
137 |
aGC translation:(x @ y).
|
|
138 |
|
|
139 |
self displayOn:aGC.
|
|
140 |
|
|
141 |
aGC translation:oldTranslation
|
|
142 |
|
|
143 |
"Created: 13.5.1996 / 10:18:43 / cg"
|
|
144 |
! !
|
|
145 |
|
245
|
146 |
!VisualComponent methodsFor:'event handling'!
|
|
147 |
|
|
148 |
buttonPress:button x:x y:y
|
246
|
149 |
"button was pressed over me - ignored here"
|
245
|
150 |
|
246
|
151 |
"Modified: 9.5.1996 / 00:14:08 / cg"
|
245
|
152 |
!
|
|
153 |
|
|
154 |
buttonRelease:button x:x y:y
|
246
|
155 |
"button was released over me - ignored here"
|
245
|
156 |
|
|
157 |
"Created: 8.5.1996 / 23:38:30 / cg"
|
246
|
158 |
"Modified: 9.5.1996 / 00:14:04 / cg"
|
245
|
159 |
!
|
|
160 |
|
|
161 |
keyPress:key x:x y:y
|
246
|
162 |
"key was pressed over me - ignored here"
|
245
|
163 |
|
|
164 |
"Created: 8.5.1996 / 23:46:03 / cg"
|
246
|
165 |
"Modified: 9.5.1996 / 00:14:14 / cg"
|
245
|
166 |
!
|
|
167 |
|
|
168 |
keyRelease:key x:x y:y
|
246
|
169 |
"key was released over me - ignored here"
|
245
|
170 |
|
|
171 |
"Created: 8.5.1996 / 23:46:07 / cg"
|
246
|
172 |
"Modified: 9.5.1996 / 00:14:19 / cg"
|
245
|
173 |
! !
|
|
174 |
|
|
175 |
!VisualComponent methodsFor:'initialization'!
|
|
176 |
|
|
177 |
initialize
|
|
178 |
fgColor := Color black.
|
|
179 |
bgColor := Color white.
|
|
180 |
|
|
181 |
"Created: 8.5.1996 / 23:49:54 / cg"
|
|
182 |
! !
|
|
183 |
|
265
|
184 |
!VisualComponent methodsFor:'queries'!
|
|
185 |
|
|
186 |
heightOn:aGC
|
|
187 |
"return my height, if displayed on aGC;
|
|
188 |
I assume that my height is independent of the device, and return
|
|
189 |
the bounds height"
|
|
190 |
|
|
191 |
^ self bounds height
|
|
192 |
|
|
193 |
"Modified: 13.5.1996 / 10:15:13 / cg"
|
|
194 |
!
|
|
195 |
|
|
196 |
widthOn:aGC
|
|
197 |
"return my width, if displayed on aGC;
|
|
198 |
I assume that my width is independent of the device, and return
|
|
199 |
the bounds width"
|
|
200 |
|
|
201 |
^ self bounds width
|
|
202 |
|
|
203 |
"Created: 13.5.1996 / 10:14:44 / cg"
|
|
204 |
"Modified: 13.5.1996 / 10:15:17 / cg"
|
|
205 |
! !
|
|
206 |
|
247
|
207 |
!VisualComponent methodsFor:'testing'!
|
|
208 |
|
|
209 |
containsPoint:aPoint
|
|
210 |
"return true, if the receiver contains aPoint"
|
|
211 |
|
|
212 |
^ self bounds containsPoint:aPoint
|
|
213 |
|
|
214 |
"Created: 9.5.1996 / 00:21:44 / cg"
|
|
215 |
"Modified: 9.5.1996 / 00:22:00 / cg"
|
|
216 |
!
|
|
217 |
|
|
218 |
hasBorder
|
|
219 |
"return true, if the receiver shows a border"
|
|
220 |
|
|
221 |
^ false
|
|
222 |
|
|
223 |
"Modified: 9.5.1996 / 00:21:29 / cg"
|
|
224 |
!
|
|
225 |
|
|
226 |
intersects:aRectangle
|
|
227 |
"return true, if the receivers bounds intersects aRectangle"
|
|
228 |
|
|
229 |
^ self bounds intersects:aRectangle
|
|
230 |
|
|
231 |
"Created: 9.5.1996 / 00:21:18 / cg"
|
|
232 |
"Modified: 9.5.1996 / 00:22:04 / cg"
|
|
233 |
! !
|
|
234 |
|
245
|
235 |
!VisualComponent class methodsFor:'documentation'!
|
|
236 |
|
|
237 |
version
|
265
|
238 |
^ '$Header: /cvs/stx/stx/libview2/VisualComponent.st,v 1.5 1996-05-13 08:50:38 cg Exp $'
|
245
|
239 |
! !
|