author | Claus Gittinger <cg@exept.de> |
Mon, 11 Sep 2017 09:08:06 +0200 | |
changeset 17686 | c6fc2da19287 |
parent 17648 | 7c379ff8a354 |
child 17687 | 01e713d1af75 |
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 |
||
17648 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
30 | 16 |
InspectorView subclass:#ImageInspectorView |
516 | 17 |
instanceVariableNames:'imageView' |
1872
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
18 |
classVariableNames:'LastRatio LastExtent' |
516 | 19 |
poolDictionaries:'' |
20 |
category:'Interface-Inspector' |
|
30 | 21 |
! |
22 |
||
1011
1022e80a1c60
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
23 |
!ImageInspectorView class methodsFor:'documentation'! |
110 | 24 |
|
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
38 |
||
128 | 39 |
documentation |
40 |
" |
|
41 |
this class allows better inspection of images, |
|
42 |
by adding another subView, which displays the image. |
|
43 |
" |
|
110 | 44 |
! ! |
45 |
||
1872
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
46 |
!ImageInspectorView class methodsFor:'defaults'! |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
47 |
|
7868 | 48 |
defaultTopViewExtent |
13766
d2f4defdd705
Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents:
13297
diff
changeset
|
49 |
|def| |
d2f4defdd705
Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents:
13297
diff
changeset
|
50 |
|
d2f4defdd705
Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents:
13297
diff
changeset
|
51 |
def := LastExtent ? self defaultExtent. |
d2f4defdd705
Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents:
13297
diff
changeset
|
52 |
^ def min:(Screen current usableExtent) |
1872
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
53 |
|
7868 | 54 |
"Created: / 23-10-2007 / 18:58:18 / cg" |
55 |
! |
|
56 |
||
57 |
rememberLastExtent:anExtent |
|
58 |
LastExtent := anExtent |
|
59 |
||
60 |
"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
|
61 |
! ! |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
62 |
|
7799 | 63 |
!ImageInspectorView class methodsFor:'menu specs'! |
64 |
||
65 |
imageMenu |
|
66 |
"This resource specification was automatically generated |
|
67 |
by the MenuEditor of ST/X." |
|
68 |
||
69 |
"Do not manually edit this!! If it is corrupted, |
|
70 |
the MenuEditor may not be able to read the specification." |
|
71 |
||
14420 | 72 |
|
7799 | 73 |
" |
74 |
MenuEditor new openOnClass:ImageInspectorView andSelector:#imageMenu |
|
75 |
(Menu new fromLiteralArrayEncoding:(ImageInspectorView imageMenu)) startUp |
|
76 |
" |
|
77 |
||
78 |
<resource: #menu> |
|
79 |
||
80 |
^ |
|
81 |
#(Menu |
|
82 |
( |
|
83 |
(MenuItem |
|
14420 | 84 |
enabled: hasImage |
8038 | 85 |
label: 'Edit' |
86 |
itemValue: menuEdit |
|
87 |
) |
|
88 |
(MenuItem |
|
14420 | 89 |
enabled: filenameOfImageKnown |
13297 | 90 |
label: 'File Browser' |
91 |
itemValue: menuFileBrowser |
|
92 |
) |
|
93 |
(MenuItem |
|
8038 | 94 |
label: '-' |
95 |
) |
|
96 |
(MenuItem |
|
7799 | 97 |
label: 'Magnification...' |
98 |
itemValue: menuMagnification |
|
99 |
) |
|
8672 | 100 |
(MenuItem |
101 |
label: 'Background' |
|
102 |
submenu: |
|
103 |
(Menu |
|
104 |
( |
|
105 |
(MenuItem |
|
106 |
label: 'White' |
|
107 |
itemValue: menuSetBackgroundColor: |
|
108 |
argument: white |
|
109 |
) |
|
110 |
(MenuItem |
|
111 |
label: 'Grey' |
|
112 |
itemValue: menuSetBackgroundColor: |
|
113 |
argument: grey |
|
114 |
) |
|
115 |
(MenuItem |
|
116 |
label: 'Black' |
|
117 |
itemValue: menuSetBackgroundColor: |
|
118 |
argument: black |
|
119 |
) |
|
120 |
(MenuItem |
|
121 |
label: '-' |
|
122 |
) |
|
123 |
(MenuItem |
|
124 |
label: 'Red' |
|
125 |
itemValue: menuSetBackgroundColor: |
|
126 |
argument: red |
|
127 |
) |
|
128 |
(MenuItem |
|
129 |
label: 'Green' |
|
130 |
itemValue: menuSetBackgroundColor: |
|
131 |
argument: green |
|
132 |
) |
|
133 |
(MenuItem |
|
134 |
label: 'Blue' |
|
135 |
itemValue: menuSetBackgroundColor: |
|
136 |
argument: blue |
|
137 |
) |
|
138 |
) |
|
139 |
nil |
|
140 |
nil |
|
141 |
) |
|
142 |
) |
|
7799 | 143 |
) |
144 |
nil |
|
145 |
nil |
|
146 |
) |
|
147 |
! ! |
|
148 |
||
30 | 149 |
!ImageInspectorView methodsFor:'accessing'! |
150 |
||
151 |
inspect:anObject |
|
8451 | 152 |
"set the object to be inspected" |
153 |
||
14617 | 154 |
|scrollToBottom prevViewOrigin prevImageSize| |
155 |
||
156 |
prevViewOrigin := imageView viewOrigin. |
|
14661 | 157 |
imageView image notNil ifTrue:[ |
158 |
prevImageSize := imageView image extent. |
|
159 |
]. |
|
30 | 160 |
super inspect:anObject. |
14350 | 161 |
"/ imageView image:anObject. |
162 |
||
14617 | 163 |
scrollToBottom := false. |
164 |
||
165 |
"/ scrollToBottom := |
|
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 |
17648 | 251 |
FileBrowser default |
13297 | 252 |
openOn:inspectedObject fileName |
17648 | 253 |
|
254 |
"Modified: / 01-09-2017 / 14:05:27 / cg" |
|
13297 | 255 |
! |
256 |
||
7799 | 257 |
menuMagnification |
258 |
|mag| |
|
259 |
||
260 |
mag := Dialog |
|
261 |
request:'Magnify by:' |
|
262 |
initialAnswer:1 |
|
263 |
list:#('0.5' '1' '2' '4' '8'). |
|
7875 | 264 |
mag := Number readFrom:mag onError:[nil]. |
265 |
mag notNil ifTrue:[ |
|
266 |
imageView image:(inspectedObject magnifiedBy:mag). |
|
267 |
] |
|
7799 | 268 |
|
269 |
"Created: / 28-05-2007 / 15:14:35 / cg" |
|
7875 | 270 |
"Modified: / 30-10-2007 / 16:49:16 / cg" |
8672 | 271 |
! |
272 |
||
273 |
menuSetBackgroundColor:colorNameSymbol |
|
274 |
imageView backgroundColor:(Color name:colorNameSymbol) |
|
30 | 275 |
! ! |
516 | 276 |
|
2271
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
277 |
!ImageInspectorView methodsFor:'queries'! |
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
278 |
|
13297 | 279 |
filenameOfImageKnown |
14420 | 280 |
^ [ inspectedObject isImage and:[inspectedObject fileName notNil] ] |
281 |
! |
|
282 |
||
283 |
hasImage |
|
284 |
"do we inspect an image and not a Form?" |
|
285 |
||
286 |
^ inspectedObject isImage |
|
13297 | 287 |
! |
288 |
||
2271
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
289 |
labelFor:anObject |
11659 | 290 |
|l fn| |
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 |
l := super labelFor:anObject. |
14420 | 293 |
(anObject isImage and:[(fn := anObject fileName) notNil]) ifTrue:[ |
11659 | 294 |
l := l , ' (''' , fn asFilename baseName, ''')' |
2271
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
295 |
]. |
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
296 |
^ l |
11659 | 297 |
|
298 |
"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
|
299 |
! ! |
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
300 |
|
1011
1022e80a1c60
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
301 |
!ImageInspectorView class methodsFor:'documentation'! |
516 | 302 |
|
303 |
version |
|
17648 | 304 |
^ '$Header$' |
8836 | 305 |
! |
306 |
||
307 |
version_CVS |
|
17648 | 308 |
^ '$Header$' |
516 | 309 |
! ! |
13077 | 310 |