author | Claus Gittinger <cg@exept.de> |
Sun, 11 May 2014 13:33:42 +0200 | |
changeset 14351 | 691c1569babc |
parent 14350 | bb47c314b586 |
child 14420 | 250bcc5188a6 |
permissions | -rw-r--r-- |
30 | 1 |
" |
2 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
45 | 3 |
All Rights Reserved |
30 | 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 |
" |
|
2831 | 12 |
"{ Package: 'stx:libtool' }" |
13 |
||
30 | 14 |
InspectorView subclass:#ImageInspectorView |
516 | 15 |
instanceVariableNames:'imageView' |
1872
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
16 |
classVariableNames:'LastRatio LastExtent' |
516 | 17 |
poolDictionaries:'' |
18 |
category:'Interface-Inspector' |
|
30 | 19 |
! |
20 |
||
1011
1022e80a1c60
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
21 |
!ImageInspectorView class methodsFor:'documentation'! |
110 | 22 |
|
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
128 | 37 |
documentation |
38 |
" |
|
39 |
this class allows better inspection of images, |
|
40 |
by adding another subView, which displays the image. |
|
41 |
" |
|
110 | 42 |
! ! |
43 |
||
1872
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
44 |
!ImageInspectorView class methodsFor:'defaults'! |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
45 |
|
7868 | 46 |
defaultTopViewExtent |
13766
d2f4defdd705
Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents:
13297
diff
changeset
|
47 |
|def| |
d2f4defdd705
Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents:
13297
diff
changeset
|
48 |
|
d2f4defdd705
Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents:
13297
diff
changeset
|
49 |
def := LastExtent ? self defaultExtent. |
d2f4defdd705
Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents:
13297
diff
changeset
|
50 |
^ def min:(Screen current usableExtent) |
1872
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
51 |
|
7868 | 52 |
"Created: / 23-10-2007 / 18:58:18 / cg" |
53 |
! |
|
54 |
||
55 |
rememberLastExtent:anExtent |
|
56 |
LastExtent := anExtent |
|
57 |
||
58 |
"Created: / 23-10-2007 / 19:09:34 / cg" |
|
1872
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
59 |
! ! |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
60 |
|
7799 | 61 |
!ImageInspectorView class methodsFor:'menu specs'! |
62 |
||
63 |
imageMenu |
|
64 |
"This resource specification was automatically generated |
|
65 |
by the MenuEditor of ST/X." |
|
66 |
||
67 |
"Do not manually edit this!! If it is corrupted, |
|
68 |
the MenuEditor may not be able to read the specification." |
|
69 |
||
70 |
" |
|
71 |
MenuEditor new openOnClass:ImageInspectorView andSelector:#imageMenu |
|
72 |
(Menu new fromLiteralArrayEncoding:(ImageInspectorView imageMenu)) startUp |
|
73 |
" |
|
74 |
||
75 |
<resource: #menu> |
|
76 |
||
77 |
^ |
|
78 |
#(Menu |
|
79 |
( |
|
80 |
(MenuItem |
|
8038 | 81 |
label: 'Edit' |
82 |
itemValue: menuEdit |
|
83 |
translateLabel: true |
|
84 |
) |
|
85 |
(MenuItem |
|
13297 | 86 |
label: 'File Browser' |
87 |
itemValue: menuFileBrowser |
|
88 |
translateLabel: true |
|
89 |
enabled: filenameOfImageKnown |
|
90 |
) |
|
91 |
(MenuItem |
|
8038 | 92 |
label: '-' |
93 |
) |
|
94 |
(MenuItem |
|
7799 | 95 |
label: 'Magnification...' |
96 |
itemValue: menuMagnification |
|
97 |
translateLabel: true |
|
98 |
) |
|
8672 | 99 |
(MenuItem |
100 |
label: 'Background' |
|
101 |
translateLabel: true |
|
102 |
submenu: |
|
103 |
(Menu |
|
104 |
( |
|
105 |
(MenuItem |
|
106 |
label: 'White' |
|
107 |
itemValue: menuSetBackgroundColor: |
|
108 |
translateLabel: true |
|
109 |
argument: white |
|
110 |
) |
|
111 |
(MenuItem |
|
112 |
label: 'Grey' |
|
113 |
itemValue: menuSetBackgroundColor: |
|
114 |
translateLabel: true |
|
115 |
argument: grey |
|
116 |
) |
|
117 |
(MenuItem |
|
118 |
label: 'Black' |
|
119 |
itemValue: menuSetBackgroundColor: |
|
120 |
translateLabel: true |
|
121 |
argument: black |
|
122 |
) |
|
123 |
(MenuItem |
|
124 |
label: '-' |
|
125 |
) |
|
126 |
(MenuItem |
|
127 |
label: 'Red' |
|
128 |
itemValue: menuSetBackgroundColor: |
|
129 |
translateLabel: true |
|
130 |
argument: red |
|
131 |
) |
|
132 |
(MenuItem |
|
133 |
label: 'Green' |
|
134 |
itemValue: menuSetBackgroundColor: |
|
135 |
translateLabel: true |
|
136 |
argument: green |
|
137 |
) |
|
138 |
(MenuItem |
|
139 |
label: 'Blue' |
|
140 |
itemValue: menuSetBackgroundColor: |
|
141 |
translateLabel: true |
|
142 |
argument: blue |
|
143 |
) |
|
144 |
) |
|
145 |
nil |
|
146 |
nil |
|
147 |
) |
|
148 |
) |
|
7799 | 149 |
) |
150 |
nil |
|
151 |
nil |
|
152 |
) |
|
153 |
! ! |
|
154 |
||
30 | 155 |
!ImageInspectorView methodsFor:'accessing'! |
156 |
||
157 |
inspect:anObject |
|
8451 | 158 |
"set the object to be inspected" |
159 |
||
14349 | 160 |
|scrollToBottom| |
161 |
||
30 | 162 |
super inspect:anObject. |
14350 | 163 |
"/ imageView image:anObject. |
164 |
||
14349 | 165 |
scrollToBottom := |
14351 | 166 |
anObject notNil |
167 |
and:[imageView image notNil |
|
168 |
and:[ imageView viewOrigin y + imageView image height >= imageView height ]]. |
|
14349 | 169 |
|
14350 | 170 |
imageView image:anObject scroll:scrollToBottom not invalidate:false. |
14349 | 171 |
scrollToBottom ifTrue:[ |
14350 | 172 |
imageView |
14351 | 173 |
scrollTo:(0 @ ((anObject height - imageView height) max:0)) |
14350 | 174 |
redraw:false. |
14349 | 175 |
]. |
14350 | 176 |
imageView invalidate. |
30 | 177 |
|
45 | 178 |
" |
179 |
ImageInspectorView inspect:(Image fromScreen:(0@0 corner:800@800)) |
|
180 |
" |
|
30 | 181 |
! ! |
182 |
||
183 |
!ImageInspectorView methodsFor:'initialization'! |
|
184 |
||
1872
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
185 |
destroy |
2236
257f587ad7dc
migrate instvars 'inspectedObject' to 'object'
Claus Gittinger <cg@exept.de>
parents:
1963
diff
changeset
|
186 |
|imageViewsSuperView| |
257f587ad7dc
migrate instvars 'inspectedObject' to 'object'
Claus Gittinger <cg@exept.de>
parents:
1963
diff
changeset
|
187 |
|
257f587ad7dc
migrate instvars 'inspectedObject' to 'object'
Claus Gittinger <cg@exept.de>
parents:
1963
diff
changeset
|
188 |
imageViewsSuperView := imageView superView. |
13077 | 189 |
imageViewsSuperView notNil ifTrue:[ |
190 |
LastRatio := 1.0 - |
|
191 |
(imageViewsSuperView relativeCorner y - imageViewsSuperView relativeOrigin y). |
|
192 |
]. |
|
1872
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
193 |
super destroy |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
194 |
|
7868 | 195 |
"Created: / 07-09-1998 / 13:13:43 / cg" |
196 |
"Modified: / 23-10-2007 / 19:10:48 / cg" |
|
1872
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
197 |
! |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
198 |
|
30 | 199 |
initialize |
107 | 200 |
|v newPanel sub| |
30 | 201 |
|
202 |
super initialize. |
|
203 |
||
1872
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
204 |
LastRatio isNil ifTrue:[ |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
205 |
LastRatio := 0.3 |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
206 |
]. |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
207 |
|
45 | 208 |
newPanel := VariableVerticalPanel in:self. |
209 |
newPanel origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
2831 | 210 |
newPanel snapMode:#both. |
30 | 211 |
|
45 | 212 |
" |
213 |
wrap my existing subview into the new |
|
214 |
variable panel |
|
215 |
" |
|
1011
1022e80a1c60
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
216 |
sub := self subViews first. |
45 | 217 |
self removeSubView:sub. |
1872
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
218 |
sub origin:0.0@0.0 corner:1.0@LastRatio. |
45 | 219 |
newPanel addSubView:sub. |
220 |
||
1379 | 221 |
v := HVScrollableView for:ImageView in:newPanel. |
1872
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
222 |
v origin:(0.0 @ LastRatio) corner:(1.0 @ 1.0). |
30 | 223 |
imageView := v scrolledView. |
7799 | 224 |
imageView menuHolder:self; menuMessage:#imageMenu; menuPerformer:self. |
30 | 225 |
|
1872
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
226 |
LastExtent notNil ifTrue:[ |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
227 |
self extent:LastExtent |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
228 |
]. |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
229 |
|
45 | 230 |
" |
231 |
ImageInspectorView new realize |
|
232 |
ImageInspectorView inspect:(Image fromFile:'bitmaps/claus.gif') |
|
233 |
" |
|
1011
1022e80a1c60
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
234 |
|
7799 | 235 |
"Modified: / 28-05-2007 / 15:15:32 / cg" |
236 |
! ! |
|
237 |
||
238 |
!ImageInspectorView methodsFor:'menu'! |
|
239 |
||
240 |
imageMenu |
|
241 |
^ self class imageMenu |
|
242 |
||
243 |
"Created: / 28-05-2007 / 15:12:56 / cg" |
|
244 |
! |
|
245 |
||
8038 | 246 |
menuEdit |
247 |
inspectedObject edit |
|
248 |
! |
|
249 |
||
13297 | 250 |
menuFileBrowser |
251 |
UserPreferences current fileBrowserClass |
|
252 |
openOn:inspectedObject fileName |
|
253 |
! |
|
254 |
||
7799 | 255 |
menuMagnification |
256 |
|mag| |
|
257 |
||
258 |
mag := Dialog |
|
259 |
request:'Magnify by:' |
|
260 |
initialAnswer:1 |
|
261 |
list:#('0.5' '1' '2' '4' '8'). |
|
7875 | 262 |
mag := Number readFrom:mag onError:[nil]. |
263 |
mag notNil ifTrue:[ |
|
264 |
imageView image:(inspectedObject magnifiedBy:mag). |
|
265 |
] |
|
7799 | 266 |
|
267 |
"Created: / 28-05-2007 / 15:14:35 / cg" |
|
7875 | 268 |
"Modified: / 30-10-2007 / 16:49:16 / cg" |
8672 | 269 |
! |
270 |
||
271 |
menuSetBackgroundColor:colorNameSymbol |
|
272 |
imageView backgroundColor:(Color name:colorNameSymbol) |
|
30 | 273 |
! ! |
516 | 274 |
|
2271
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
275 |
!ImageInspectorView methodsFor:'queries'! |
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
276 |
|
13297 | 277 |
filenameOfImageKnown |
278 |
^ [ inspectedObject fileName notNil ] |
|
279 |
! |
|
280 |
||
2271
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
281 |
labelFor:anObject |
11659 | 282 |
|l fn| |
2271
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
283 |
|
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
284 |
l := super labelFor:anObject. |
11659 | 285 |
(anObject notNil and:[(fn := anObject fileName) notNil]) ifTrue:[ |
286 |
l := l , ' (''' , fn asFilename baseName, ''')' |
|
2271
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
287 |
]. |
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
288 |
^ l |
11659 | 289 |
|
290 |
"Modified: / 25-07-2012 / 12:53:13 / cg" |
|
2271
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
291 |
! ! |
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
292 |
|
1011
1022e80a1c60
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
293 |
!ImageInspectorView class methodsFor:'documentation'! |
516 | 294 |
|
295 |
version |
|
14351 | 296 |
^ '$Header: /cvs/stx/stx/libtool/ImageInspectorView.st,v 1.32 2014-05-11 11:33:42 cg Exp $' |
8836 | 297 |
! |
298 |
||
299 |
version_CVS |
|
14351 | 300 |
^ '$Header: /cvs/stx/stx/libtool/ImageInspectorView.st,v 1.32 2014-05-11 11:33:42 cg Exp $' |
516 | 301 |
! ! |
13077 | 302 |