1
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
|
3 |
All Rights Reserved
|
|
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 |
"
|
|
12 |
|
|
13 |
View subclass:#ImageView
|
|
14 |
instanceVariableNames:'image'
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Views-Misc'
|
|
18 |
!
|
|
19 |
|
|
20 |
ImageView comment:'
|
|
21 |
|
|
22 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
|
23 |
All Rights Reserved
|
|
24 |
|
|
25 |
$Header: /cvs/stx/stx/libwidg2/ImageView.st,v 1.1 1993-10-13 01:02:30 claus Exp $
|
|
26 |
'!
|
|
27 |
|
|
28 |
!ImageView class methodsFor:'startup'!
|
|
29 |
|
|
30 |
startOn:aFileName
|
|
31 |
"startup an image viewer"
|
|
32 |
|
|
33 |
|top v imageView|
|
|
34 |
|
|
35 |
top := StandardSystemView label:aFileName.
|
|
36 |
|
|
37 |
v := HVScrollableView for:self in:top.
|
|
38 |
v origin:0@0 extent:1.0@1.0.
|
|
39 |
imageView := v scrolledView.
|
|
40 |
|
|
41 |
imageView image:(Image fromFile:aFileName).
|
|
42 |
top realize
|
|
43 |
|
|
44 |
"ImageView startOn:'bitmaps/garfield.gif'"
|
|
45 |
! !
|
|
46 |
|
|
47 |
!ImageView class methodsFor:'documentation'!
|
|
48 |
|
|
49 |
documentation
|
|
50 |
"
|
|
51 |
This View knows how to display an image (or form).
|
|
52 |
|
|
53 |
You can display an image with:
|
|
54 |
|
|
55 |
(ImageView new image:anImage) realize
|
|
56 |
|
|
57 |
i.e.
|
|
58 |
|
|
59 |
(ImageView new image:(Image fromFile:''bitmaps/garfield.gif'')) realize
|
|
60 |
(ImageView new image:(Image fromFile:''bitmaps/dano.tiff'')) realize
|
|
61 |
(ImageView new image:(Form fromFile:''SBrowser.xbm'')) realize
|
|
62 |
|
|
63 |
or simply by:
|
|
64 |
|
|
65 |
ImageView startOn:''bitmaps/garfield.gif''
|
|
66 |
|
|
67 |
"
|
|
68 |
! !
|
|
69 |
|
|
70 |
!ImageView methodsFor:'release'!
|
|
71 |
|
|
72 |
destroy
|
|
73 |
image := nil.
|
|
74 |
super destroy.
|
|
75 |
! !
|
|
76 |
|
|
77 |
!ImageView methodsFor:'drawing'!
|
|
78 |
|
|
79 |
redraw
|
|
80 |
image notNil ifTrue:[
|
|
81 |
image := image on:device.
|
|
82 |
self clear.
|
|
83 |
self foreground:Black background:White.
|
|
84 |
self function:#copy.
|
|
85 |
self drawOpaqueForm:image x:(0 - viewOrigin x) y:(0 - viewOrigin y)
|
|
86 |
]
|
|
87 |
! !
|
|
88 |
|
|
89 |
!ImageView methodsFor:'accessing'!
|
|
90 |
|
|
91 |
image:anImage
|
|
92 |
"set the image - show a wait cursor, since image dithering may take a while"
|
|
93 |
|
|
94 |
self cursor:Cursor wait.
|
|
95 |
image := anImage.
|
|
96 |
shown ifTrue:[
|
|
97 |
self redraw
|
|
98 |
].
|
|
99 |
self contentsChanged.
|
|
100 |
self cursor:(Cursor normal).
|
|
101 |
|
|
102 |
"ImageView new realize image:(Image fromFile:'bitmaps/claus.gif')"
|
|
103 |
!
|
|
104 |
|
|
105 |
image
|
|
106 |
"return the image"
|
|
107 |
|
|
108 |
^ image
|
|
109 |
! !
|
|
110 |
|
|
111 |
!ImageView methodsFor:'queries'!
|
|
112 |
|
|
113 |
widthOfContents
|
|
114 |
"return the images width - scrollbar needs this info"
|
|
115 |
|
|
116 |
image isNil ifTrue:[^ 0].
|
|
117 |
^ image width
|
|
118 |
!
|
|
119 |
|
|
120 |
heightOfContents
|
|
121 |
"return the images height - scrollbar needs this info"
|
|
122 |
|
|
123 |
image isNil ifTrue:[^ 0].
|
|
124 |
^ image height
|
|
125 |
! !
|