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