author | Claus Gittinger <cg@exept.de> |
Sat, 31 May 2014 13:17:33 +0200 | |
changeset 14431 | db727d8b39c6 |
parent 14420 | 250bcc5188a6 |
child 14617 | fad83ee04023 |
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 |
||
14420 | 70 |
|
7799 | 71 |
" |
72 |
MenuEditor new openOnClass:ImageInspectorView andSelector:#imageMenu |
|
73 |
(Menu new fromLiteralArrayEncoding:(ImageInspectorView imageMenu)) startUp |
|
74 |
" |
|
75 |
||
76 |
<resource: #menu> |
|
77 |
||
78 |
^ |
|
79 |
#(Menu |
|
80 |
( |
|
81 |
(MenuItem |
|
14420 | 82 |
enabled: hasImage |
8038 | 83 |
label: 'Edit' |
84 |
itemValue: menuEdit |
|
85 |
) |
|
86 |
(MenuItem |
|
14420 | 87 |
enabled: filenameOfImageKnown |
13297 | 88 |
label: 'File Browser' |
89 |
itemValue: menuFileBrowser |
|
90 |
) |
|
91 |
(MenuItem |
|
8038 | 92 |
label: '-' |
93 |
) |
|
94 |
(MenuItem |
|
7799 | 95 |
label: 'Magnification...' |
96 |
itemValue: menuMagnification |
|
97 |
) |
|
8672 | 98 |
(MenuItem |
99 |
label: 'Background' |
|
100 |
submenu: |
|
101 |
(Menu |
|
102 |
( |
|
103 |
(MenuItem |
|
104 |
label: 'White' |
|
105 |
itemValue: menuSetBackgroundColor: |
|
106 |
argument: white |
|
107 |
) |
|
108 |
(MenuItem |
|
109 |
label: 'Grey' |
|
110 |
itemValue: menuSetBackgroundColor: |
|
111 |
argument: grey |
|
112 |
) |
|
113 |
(MenuItem |
|
114 |
label: 'Black' |
|
115 |
itemValue: menuSetBackgroundColor: |
|
116 |
argument: black |
|
117 |
) |
|
118 |
(MenuItem |
|
119 |
label: '-' |
|
120 |
) |
|
121 |
(MenuItem |
|
122 |
label: 'Red' |
|
123 |
itemValue: menuSetBackgroundColor: |
|
124 |
argument: red |
|
125 |
) |
|
126 |
(MenuItem |
|
127 |
label: 'Green' |
|
128 |
itemValue: menuSetBackgroundColor: |
|
129 |
argument: green |
|
130 |
) |
|
131 |
(MenuItem |
|
132 |
label: 'Blue' |
|
133 |
itemValue: menuSetBackgroundColor: |
|
134 |
argument: blue |
|
135 |
) |
|
136 |
) |
|
137 |
nil |
|
138 |
nil |
|
139 |
) |
|
140 |
) |
|
7799 | 141 |
) |
142 |
nil |
|
143 |
nil |
|
144 |
) |
|
145 |
! ! |
|
146 |
||
30 | 147 |
!ImageInspectorView methodsFor:'accessing'! |
148 |
||
149 |
inspect:anObject |
|
8451 | 150 |
"set the object to be inspected" |
151 |
||
14349 | 152 |
|scrollToBottom| |
153 |
||
30 | 154 |
super inspect:anObject. |
14350 | 155 |
"/ imageView image:anObject. |
156 |
||
14349 | 157 |
scrollToBottom := |
14351 | 158 |
anObject notNil |
159 |
and:[imageView image notNil |
|
160 |
and:[ imageView viewOrigin y + imageView image height >= imageView height ]]. |
|
14349 | 161 |
|
14350 | 162 |
imageView image:anObject scroll:scrollToBottom not invalidate:false. |
14349 | 163 |
scrollToBottom ifTrue:[ |
14350 | 164 |
imageView |
14351 | 165 |
scrollTo:(0 @ ((anObject height - imageView height) max:0)) |
14350 | 166 |
redraw:false. |
14349 | 167 |
]. |
14350 | 168 |
imageView invalidate. |
30 | 169 |
|
45 | 170 |
" |
171 |
ImageInspectorView inspect:(Image fromScreen:(0@0 corner:800@800)) |
|
172 |
" |
|
30 | 173 |
! ! |
174 |
||
175 |
!ImageInspectorView methodsFor:'initialization'! |
|
176 |
||
1872
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
177 |
destroy |
2236
257f587ad7dc
migrate instvars 'inspectedObject' to 'object'
Claus Gittinger <cg@exept.de>
parents:
1963
diff
changeset
|
178 |
|imageViewsSuperView| |
257f587ad7dc
migrate instvars 'inspectedObject' to 'object'
Claus Gittinger <cg@exept.de>
parents:
1963
diff
changeset
|
179 |
|
257f587ad7dc
migrate instvars 'inspectedObject' to 'object'
Claus Gittinger <cg@exept.de>
parents:
1963
diff
changeset
|
180 |
imageViewsSuperView := imageView superView. |
13077 | 181 |
imageViewsSuperView notNil ifTrue:[ |
182 |
LastRatio := 1.0 - |
|
183 |
(imageViewsSuperView relativeCorner y - imageViewsSuperView relativeOrigin y). |
|
184 |
]. |
|
1872
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
185 |
super destroy |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
186 |
|
7868 | 187 |
"Created: / 07-09-1998 / 13:13:43 / cg" |
188 |
"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
|
189 |
! |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
190 |
|
30 | 191 |
initialize |
107 | 192 |
|v newPanel sub| |
30 | 193 |
|
194 |
super initialize. |
|
195 |
||
1872
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
196 |
LastRatio isNil ifTrue:[ |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
197 |
LastRatio := 0.3 |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
198 |
]. |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
199 |
|
45 | 200 |
newPanel := VariableVerticalPanel in:self. |
201 |
newPanel origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
2831 | 202 |
newPanel snapMode:#both. |
30 | 203 |
|
45 | 204 |
" |
205 |
wrap my existing subview into the new |
|
206 |
variable panel |
|
207 |
" |
|
1011
1022e80a1c60
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
208 |
sub := self subViews first. |
45 | 209 |
self removeSubView:sub. |
1872
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
210 |
sub origin:0.0@0.0 corner:1.0@LastRatio. |
45 | 211 |
newPanel addSubView:sub. |
212 |
||
1379 | 213 |
v := HVScrollableView for:ImageView in:newPanel. |
1872
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
214 |
v origin:(0.0 @ LastRatio) corner:(1.0 @ 1.0). |
30 | 215 |
imageView := v scrolledView. |
7799 | 216 |
imageView menuHolder:self; menuMessage:#imageMenu; menuPerformer:self. |
30 | 217 |
|
1872
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
218 |
LastExtent notNil ifTrue:[ |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
219 |
self extent:LastExtent |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
220 |
]. |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
221 |
|
45 | 222 |
" |
223 |
ImageInspectorView new realize |
|
224 |
ImageInspectorView inspect:(Image fromFile:'bitmaps/claus.gif') |
|
225 |
" |
|
1011
1022e80a1c60
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
226 |
|
7799 | 227 |
"Modified: / 28-05-2007 / 15:15:32 / cg" |
228 |
! ! |
|
229 |
||
230 |
!ImageInspectorView methodsFor:'menu'! |
|
231 |
||
232 |
imageMenu |
|
233 |
^ self class imageMenu |
|
234 |
||
235 |
"Created: / 28-05-2007 / 15:12:56 / cg" |
|
236 |
! |
|
237 |
||
8038 | 238 |
menuEdit |
239 |
inspectedObject edit |
|
240 |
! |
|
241 |
||
13297 | 242 |
menuFileBrowser |
243 |
UserPreferences current fileBrowserClass |
|
244 |
openOn:inspectedObject fileName |
|
245 |
! |
|
246 |
||
7799 | 247 |
menuMagnification |
248 |
|mag| |
|
249 |
||
250 |
mag := Dialog |
|
251 |
request:'Magnify by:' |
|
252 |
initialAnswer:1 |
|
253 |
list:#('0.5' '1' '2' '4' '8'). |
|
7875 | 254 |
mag := Number readFrom:mag onError:[nil]. |
255 |
mag notNil ifTrue:[ |
|
256 |
imageView image:(inspectedObject magnifiedBy:mag). |
|
257 |
] |
|
7799 | 258 |
|
259 |
"Created: / 28-05-2007 / 15:14:35 / cg" |
|
7875 | 260 |
"Modified: / 30-10-2007 / 16:49:16 / cg" |
8672 | 261 |
! |
262 |
||
263 |
menuSetBackgroundColor:colorNameSymbol |
|
264 |
imageView backgroundColor:(Color name:colorNameSymbol) |
|
30 | 265 |
! ! |
516 | 266 |
|
2271
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
267 |
!ImageInspectorView methodsFor:'queries'! |
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
268 |
|
13297 | 269 |
filenameOfImageKnown |
14420 | 270 |
^ [ inspectedObject isImage and:[inspectedObject fileName notNil] ] |
271 |
! |
|
272 |
||
273 |
hasImage |
|
274 |
"do we inspect an image and not a Form?" |
|
275 |
||
276 |
^ inspectedObject isImage |
|
13297 | 277 |
! |
278 |
||
2271
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
279 |
labelFor:anObject |
11659 | 280 |
|l fn| |
2271
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
281 |
|
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
282 |
l := super labelFor:anObject. |
14420 | 283 |
(anObject isImage and:[(fn := anObject fileName) notNil]) ifTrue:[ |
11659 | 284 |
l := l , ' (''' , fn asFilename baseName, ''')' |
2271
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
285 |
]. |
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
286 |
^ l |
11659 | 287 |
|
288 |
"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
|
289 |
! ! |
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
290 |
|
1011
1022e80a1c60
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
291 |
!ImageInspectorView class methodsFor:'documentation'! |
516 | 292 |
|
293 |
version |
|
14420 | 294 |
^ '$Header: /cvs/stx/stx/libtool/ImageInspectorView.st,v 1.33 2014-05-23 14:34:32 stefan Exp $' |
8836 | 295 |
! |
296 |
||
297 |
version_CVS |
|
14420 | 298 |
^ '$Header: /cvs/stx/stx/libtool/ImageInspectorView.st,v 1.33 2014-05-23 14:34:32 stefan Exp $' |
516 | 299 |
! ! |
13077 | 300 |