author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Wed, 19 Jul 2017 09:42:32 +0200 | |
branch | jv |
changeset 17619 | edb119820fcb |
parent 15566 | 184cea584be5 |
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 |
||
14617 | 152 |
|scrollToBottom prevViewOrigin prevImageSize| |
153 |
||
154 |
prevViewOrigin := imageView viewOrigin. |
|
14661 | 155 |
imageView image notNil ifTrue:[ |
156 |
prevImageSize := imageView image extent. |
|
157 |
]. |
|
30 | 158 |
super inspect:anObject. |
14350 | 159 |
"/ imageView image:anObject. |
160 |
||
14617 | 161 |
scrollToBottom := false. |
162 |
||
163 |
"/ scrollToBottom := |
|
164 |
"/ anObject notNil |
|
165 |
"/ and:[imageView image notNil |
|
166 |
"/ and:[ imageView viewOrigin y + imageView image height >= imageView height ]]. |
|
14349 | 167 |
|
14350 | 168 |
imageView image:anObject scroll:scrollToBottom not invalidate:false. |
14349 | 169 |
scrollToBottom ifTrue:[ |
14350 | 170 |
imageView |
14351 | 171 |
scrollTo:(0 @ ((anObject height - imageView height) max:0)) |
14350 | 172 |
redraw:false. |
14349 | 173 |
]. |
14350 | 174 |
imageView invalidate. |
30 | 175 |
|
45 | 176 |
" |
177 |
ImageInspectorView inspect:(Image fromScreen:(0@0 corner:800@800)) |
|
178 |
" |
|
30 | 179 |
! ! |
180 |
||
181 |
!ImageInspectorView methodsFor:'initialization'! |
|
182 |
||
1872
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
183 |
destroy |
2236
257f587ad7dc
migrate instvars 'inspectedObject' to 'object'
Claus Gittinger <cg@exept.de>
parents:
1963
diff
changeset
|
184 |
|imageViewsSuperView| |
257f587ad7dc
migrate instvars 'inspectedObject' to 'object'
Claus Gittinger <cg@exept.de>
parents:
1963
diff
changeset
|
185 |
|
257f587ad7dc
migrate instvars 'inspectedObject' to 'object'
Claus Gittinger <cg@exept.de>
parents:
1963
diff
changeset
|
186 |
imageViewsSuperView := imageView superView. |
13077 | 187 |
imageViewsSuperView notNil ifTrue:[ |
188 |
LastRatio := 1.0 - |
|
189 |
(imageViewsSuperView relativeCorner y - imageViewsSuperView relativeOrigin y). |
|
190 |
]. |
|
1872
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
191 |
super destroy |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
192 |
|
7868 | 193 |
"Created: / 07-09-1998 / 13:13:43 / cg" |
194 |
"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
|
195 |
! |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
196 |
|
30 | 197 |
initialize |
107 | 198 |
|v newPanel sub| |
30 | 199 |
|
200 |
super initialize. |
|
201 |
||
1872
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
202 |
LastRatio isNil ifTrue:[ |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
203 |
LastRatio := 0.3 |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
204 |
]. |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
205 |
|
45 | 206 |
newPanel := VariableVerticalPanel in:self. |
207 |
newPanel origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
2831 | 208 |
newPanel snapMode:#both. |
30 | 209 |
|
45 | 210 |
" |
211 |
wrap my existing subview into the new |
|
212 |
variable panel |
|
213 |
" |
|
1011
1022e80a1c60
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
214 |
sub := self subViews first. |
45 | 215 |
self removeSubView:sub. |
1872
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
216 |
sub origin:0.0@0.0 corner:1.0@LastRatio. |
45 | 217 |
newPanel addSubView:sub. |
218 |
||
1379 | 219 |
v := HVScrollableView for:ImageView in:newPanel. |
1872
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
220 |
v origin:(0.0 @ LastRatio) corner:(1.0 @ 1.0). |
30 | 221 |
imageView := v scrolledView. |
7799 | 222 |
imageView menuHolder:self; menuMessage:#imageMenu; menuPerformer:self. |
30 | 223 |
|
1872
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
224 |
LastExtent notNil ifTrue:[ |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
225 |
self extent:LastExtent |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
226 |
]. |
1c3c80a1973f
remember last extent and variable frame ratio;
Claus Gittinger <cg@exept.de>
parents:
1379
diff
changeset
|
227 |
|
45 | 228 |
" |
229 |
ImageInspectorView new realize |
|
230 |
ImageInspectorView inspect:(Image fromFile:'bitmaps/claus.gif') |
|
231 |
" |
|
1011
1022e80a1c60
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
232 |
|
7799 | 233 |
"Modified: / 28-05-2007 / 15:15:32 / cg" |
234 |
! ! |
|
235 |
||
236 |
!ImageInspectorView methodsFor:'menu'! |
|
237 |
||
238 |
imageMenu |
|
239 |
^ self class imageMenu |
|
240 |
||
241 |
"Created: / 28-05-2007 / 15:12:56 / cg" |
|
242 |
! |
|
243 |
||
8038 | 244 |
menuEdit |
245 |
inspectedObject edit |
|
246 |
! |
|
247 |
||
13297 | 248 |
menuFileBrowser |
14795 | 249 |
UserPreferences fileBrowserClass |
13297 | 250 |
openOn:inspectedObject fileName |
251 |
! |
|
252 |
||
7799 | 253 |
menuMagnification |
254 |
|mag| |
|
255 |
||
256 |
mag := Dialog |
|
257 |
request:'Magnify by:' |
|
258 |
initialAnswer:1 |
|
259 |
list:#('0.5' '1' '2' '4' '8'). |
|
7875 | 260 |
mag := Number readFrom:mag onError:[nil]. |
261 |
mag notNil ifTrue:[ |
|
262 |
imageView image:(inspectedObject magnifiedBy:mag). |
|
263 |
] |
|
7799 | 264 |
|
265 |
"Created: / 28-05-2007 / 15:14:35 / cg" |
|
7875 | 266 |
"Modified: / 30-10-2007 / 16:49:16 / cg" |
8672 | 267 |
! |
268 |
||
269 |
menuSetBackgroundColor:colorNameSymbol |
|
270 |
imageView backgroundColor:(Color name:colorNameSymbol) |
|
30 | 271 |
! ! |
516 | 272 |
|
2271
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
273 |
!ImageInspectorView methodsFor:'queries'! |
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
274 |
|
13297 | 275 |
filenameOfImageKnown |
14420 | 276 |
^ [ inspectedObject isImage and:[inspectedObject fileName notNil] ] |
277 |
! |
|
278 |
||
279 |
hasImage |
|
280 |
"do we inspect an image and not a Form?" |
|
281 |
||
282 |
^ inspectedObject isImage |
|
13297 | 283 |
! |
284 |
||
2271
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
285 |
labelFor:anObject |
11659 | 286 |
|l fn| |
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 := super labelFor:anObject. |
14420 | 289 |
(anObject isImage and:[(fn := anObject fileName) notNil]) ifTrue:[ |
11659 | 290 |
l := l , ' (''' , fn asFilename baseName, ''')' |
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 |
11659 | 293 |
|
294 |
"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
|
295 |
! ! |
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
296 |
|
1011
1022e80a1c60
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
297 |
!ImageInspectorView class methodsFor:'documentation'! |
516 | 298 |
|
299 |
version |
|
14795 | 300 |
^ '$Header: /cvs/stx/stx/libtool/ImageInspectorView.st,v 1.36 2014-10-23 11:15:46 cg Exp $' |
8836 | 301 |
! |
302 |
||
303 |
version_CVS |
|
14795 | 304 |
^ '$Header: /cvs/stx/stx/libtool/ImageInspectorView.st,v 1.36 2014-10-23 11:15:46 cg Exp $' |
516 | 305 |
! ! |
13077 | 306 |