author | Claus Gittinger <cg@exept.de> |
Sat, 11 Nov 1995 17:30:31 +0100 | |
changeset 86 | 4d7dbb5f1719 |
parent 72 | f17df5ea35ed |
child 202 | e00b0bb1d439 |
permissions | -rw-r--r-- |
64 | 1 |
" |
2 |
COPYRIGHT (c) 1995 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 |
'From Smalltalk/X, Version:2.10.5 on 28-jun-1995 at 6:45:45 am'! |
|
14 |
||
15 |
FileSelectionBox subclass:#ImageSelectionBox |
|
16 |
instanceVariableNames:'previewField preview info' |
|
17 |
classVariableNames:'' |
|
18 |
poolDictionaries:'' |
|
19 |
category:'Views-DialogBoxes' |
|
20 |
! |
|
21 |
||
22 |
!ImageSelectionBox class methodsFor:'documentation'! |
|
23 |
||
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
27 |
All Rights Reserved |
|
28 |
||
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
38 |
documentation |
|
39 |
" |
|
40 |
Like a fileSelectionBox, but adds a little preview field. |
|
41 |
Nice. |
|
42 |
" |
|
86
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
72
diff
changeset
|
43 |
! |
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
72
diff
changeset
|
44 |
|
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
72
diff
changeset
|
45 |
version |
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
72
diff
changeset
|
46 |
^ '$Header: /cvs/stx/stx/libwidg2/ImageSelectionBox.st,v 1.3 1995-11-11 16:29:01 cg Exp $' |
64 | 47 |
! ! |
48 |
||
49 |
!ImageSelectionBox methodsFor:'user actions'! |
|
50 |
||
51 |
selectionChanged |
|
52 |
"selections in list show the image" |
|
53 |
||
54 |
super selectionChanged. |
|
55 |
self showPreview |
|
56 |
! |
|
57 |
||
58 |
showPreview |
|
59 |
"show the image as thumbNail" |
|
60 |
||
61 |
|fileNameString fileName image| |
|
62 |
||
63 |
previewField label:nil. |
|
64 |
info label:nil. |
|
65 |
||
66 |
preview value ifFalse:[ |
|
67 |
^ self |
|
68 |
]. |
|
69 |
||
70 |
" |
|
71 |
show the image in the previewLabel |
|
72 |
" |
|
73 |
fileNameString := self contents. |
|
74 |
(fileNameString notNil and:[fileNameString notEmpty]) ifTrue:[ |
|
75 |
fileName := fileNameString asFilename. |
|
76 |
(fileName exists |
|
77 |
and:[fileName isDirectory not |
|
78 |
and:[fileName isReadable]]) ifTrue:[ |
|
79 |
||
80 |
self topView withWaitCursorDo:[ |
|
81 |
image := Image fromFile:fileNameString. |
|
82 |
image notNil ifTrue:[ |
|
72 | 83 |
info label:(resources string:'Size: %1 x %2' |
84 |
with:image width printString |
|
85 |
with:image height printString), |
|
86 |
(resources string:' Depth: %1' |
|
87 |
with:image depth printString). |
|
64 | 88 |
|
89 |
(image width <= 64 and:[image height <= 64]) ifFalse:[ |
|
90 |
image := image magnifiedPreservingRatioTo:64@64. |
|
91 |
]. |
|
92 |
" |
|
93 |
for the thumbNail picture, |
|
94 |
we can temporarily switch to a rough dither. |
|
95 |
(this speeds up the thing quite a bit |
|
96 |
" |
|
97 |
(image depth > 2 |
|
98 |
and:[Color fixColors isNil]) ifTrue:[ |
|
99 |
"temporarily go to a 3x3x2 colormap ..." |
|
100 |
Object errorSignal handle:[:ex | |
|
101 |
'very low resolution colors' infoPrintNL. |
|
102 |
Object errorSignal handle:[:ex | |
|
103 |
'cannot allocate dither colors' infoPrintNL. |
|
104 |
ex return |
|
105 |
] do:[ |
|
106 |
Color getColorsRed:2 green:2 blue:2. |
|
107 |
] |
|
108 |
] do:[ |
|
109 |
Color getColorsRed:5 green:5 blue:3. |
|
110 |
]. |
|
111 |
previewField label:image. |
|
112 |
Color releaseDitherColors. |
|
113 |
] ifFalse:[ |
|
114 |
previewField label:image. |
|
115 |
] |
|
116 |
] |
|
117 |
] |
|
118 |
] |
|
119 |
] |
|
120 |
! ! |
|
121 |
||
122 |
!ImageSelectionBox methodsFor:'initialization'! |
|
123 |
||
124 |
initialize |
|
125 |
|v check lw lh prefY frame previewSize| |
|
126 |
||
127 |
previewSize := 64@64. |
|
128 |
||
129 |
super initialize. |
|
130 |
||
72 | 131 |
label := (resources string:'Image dialog'). |
64 | 132 |
labelField label:(resources string:'select an image file:'). |
133 |
||
134 |
prefY := buttonPanel preferredExtent y. |
|
135 |
||
136 |
check := CheckBox label:(resources string:'preview') in:self. |
|
137 |
check model:(preview := false asValue). |
|
138 |
preview onChangeSend:#showPreview to:self. |
|
139 |
info := Label label:'' in:self. |
|
140 |
info adjust:#left. |
|
141 |
||
142 |
lh := check preferredExtent y. |
|
143 |
lw := check preferredExtent x. |
|
144 |
||
145 |
check |
|
146 |
origin:(0.0 @ 1.0) |
|
147 |
corner:(0.0 @ 1.0). |
|
148 |
check |
|
149 |
topInset:(prefY + ViewSpacing + previewSize y) negated; |
|
150 |
bottomInset:(prefY + ViewSpacing + (previewSize y - check preferredExtent y)); |
|
151 |
rightInset:(ViewSpacing + lw) negated. |
|
152 |
||
153 |
info |
|
154 |
origin:(0.0 @ 1.0) |
|
155 |
corner:(1.0 @ 1.0). |
|
156 |
info |
|
157 |
topInset:(prefY + ViewSpacing + info preferredExtent y + ViewSpacing) negated; |
|
158 |
bottomInset:(prefY + ViewSpacing); |
|
159 |
leftInset:ViewSpacing; |
|
160 |
rightInset:(ViewSpacing + previewSize x + ViewSpacing) negated. |
|
161 |
||
162 |
StyleSheet is3D ifTrue:[ |
|
163 |
v := View in:self. |
|
164 |
previewField := Label origin:0.0@0.0 corner:1.0@1.0 in:v. |
|
165 |
previewField allInset:ViewSpacing//2. |
|
166 |
frame := v. |
|
167 |
previewField level:-1. |
|
168 |
frame level:1. |
|
169 |
] ifFalse:[ |
|
170 |
previewField := frame := Label in:self. |
|
171 |
]. |
|
172 |
frame |
|
173 |
origin:(1.0 @ 1.0) |
|
174 |
corner:(1.0 @ 1.0). |
|
175 |
frame |
|
176 |
topInset:(prefY + ViewSpacing + previewSize y + (frame borderWidth * 2)) negated; |
|
177 |
bottomInset:(prefY + frame borderWidth + ViewSpacing); |
|
178 |
leftInset:(ViewSpacing + previewSize x + ViewSpacing) negated; |
|
179 |
rightInset:ViewSpacing. |
|
180 |
previewField sizeFixed:true. |
|
181 |
||
182 |
selectionList superView |
|
183 |
bottomInset:(prefY + ViewSpacing + previewSize y + (frame borderWidth * 2) + ViewSpacing). |
|
184 |
! ! |
|
185 |