author | ca |
Wed, 10 Mar 2004 17:36:19 +0100 | |
changeset 2938 | fc770ff23ced |
parent 2937 | cee2b9a5e360 |
child 2939 | 1c23ad9aa8be |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1991 by Claus Gittinger |
59 | 3 |
All Rights Reserved |
0 | 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 |
||
77 | 13 |
|
14 |
||
2275 | 15 |
"{ Package: 'stx:libwidg' }" |
16 |
||
77 | 17 |
DialogBox subclass:#FontPanel |
2878 | 18 |
instanceVariableNames:'previewField listOfEncodings familyList faceList sizeList |
19 |
revertButton currentFamily currentFace currentStyle |
|
20 |
currentFaceAndStyle currentSize currentEncoding selectedFont |
|
21 |
nameLabel encodingFilter encodingLabel filter encoding' |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
22 |
classVariableNames:'' |
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
23 |
poolDictionaries:'' |
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
24 |
category:'Views-DialogBoxes' |
0 | 25 |
! |
26 |
||
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
27 |
!FontPanel class methodsFor:'documentation'! |
77 | 28 |
|
197 | 29 |
copyright |
30 |
" |
|
31 |
COPYRIGHT (c) 1991 by Claus Gittinger |
|
32 |
All Rights Reserved |
|
33 |
||
34 |
This software is furnished under a license and may be used |
|
35 |
only in accordance with the terms of that license and with the |
|
36 |
inclusion of the above copyright notice. This software may not |
|
37 |
be provided or otherwise made available to, or used by, any |
|
38 |
other person. No title to or ownership of the software is |
|
39 |
hereby transferred. |
|
40 |
" |
|
41 |
||
42 |
||
77 | 43 |
! |
44 |
||
45 |
documentation |
|
46 |
" |
|
47 |
this class implements a font chooser. |
|
48 |
||
2826 | 49 |
Notice: |
50 |
this is a very old dialog; |
|
51 |
it was written before the UI-framework was available and is completely |
|
52 |
setup manually (initialize method). |
|
53 |
Therefore, it desperately asks to be rewritten using the UIPainter... |
|
54 |
||
595 | 55 |
[author:] |
56 |
Claus Gittinger |
|
57 |
||
58 |
[see also:] |
|
59 |
Font FontDescription |
|
60 |
View Dialog |
|
61 |
" |
|
62 |
! |
|
63 |
||
64 |
examples |
|
65 |
" |
|
66 |
very simple: |
|
67 |
[exBegin] |
|
68 |
|font| |
|
69 |
||
70 |
font := FontPanel fontFromUser. |
|
655 | 71 |
Transcript showCR:font |
595 | 72 |
[exEnd] |
73 |
||
74 |
||
75 |
with initial font: |
|
76 |
[exBegin] |
|
77 |
|font| |
|
78 |
||
79 |
font := FontPanel |
|
80 |
fontFromUserInitial:(Font |
|
81 |
family:'courier' |
|
82 |
size:12). |
|
655 | 83 |
Transcript showCR:font |
595 | 84 |
[exEnd] |
85 |
||
86 |
||
87 |
with initial font & title: |
|
88 |
[exBegin] |
|
89 |
|font| |
|
90 |
||
91 |
font := FontPanel |
|
92 |
fontFromUserInitial:(Font |
|
93 |
family:'courier' |
|
94 |
size:12) |
|
95 |
title:'select a fooBar font'. |
|
655 | 96 |
Transcript showCR:font |
595 | 97 |
[exEnd] |
98 |
||
99 |
||
100 |
full setup; setting a filter to only present iso fonts |
|
101 |
and callBack action: |
|
102 |
[exBegin] |
|
0 | 103 |
|
585 | 104 |
|panel| |
77 | 105 |
|
585 | 106 |
panel := FontPanel new. |
595 | 107 |
panel label:'hi there - which iso font ?'. |
108 |
panel filter:[:fd | fd encoding notNil |
|
109 |
and:[fd encoding startsWith:'iso']]. |
|
110 |
panel action:[:family :face :style :size | |
|
655 | 111 |
Transcript showCR:'family:' , family. |
112 |
Transcript showCR:'face:' , face. |
|
113 |
Transcript showCR:'style:' , style. |
|
114 |
Transcript showCR:'size:' , size printString. |
|
595 | 115 |
]. |
116 |
panel open |
|
117 |
[exEnd] |
|
77 | 118 |
" |
119 |
! ! |
|
0 | 120 |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
121 |
!FontPanel class methodsFor:'defaults'! |
0 | 122 |
|
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
123 |
defaultAsciiSampleString |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
124 |
^ (self sampleStringWithAllLetters) , ' |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
125 |
|
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
126 |
ABCDEFGHIJKLMNOPQRSTUVWXYZ |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
127 |
abcdefghijklmnopqrstuvwxyz |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
128 |
1234567890 !!@#$%^&*(){}[]:"~;,./<>? |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
129 |
' |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
130 |
! |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
131 |
|
197 | 132 |
defaultExtent |
571 | 133 |
"return the default extent of my instances. |
134 |
The value returned here is usually ignored, and |
|
135 |
the value from preferredExtent taken instead." |
|
136 |
||
2842 | 137 |
^ (Screen current pixelPerMillimeter * (150 @ 100)) rounded |
571 | 138 |
|
139 |
"Modified: 22.4.1996 / 23:36:19 / cg" |
|
197 | 140 |
! |
141 |
||
2860 | 142 |
defaultJIS0201SampleString |
143 |
"return the sample jis preview text" |
|
144 |
||
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
145 |
^ (self defaultLatin1SampleString). |
2860 | 146 |
! |
147 |
||
382 | 148 |
defaultJISSampleString |
595 | 149 |
"return the sample jis preview text" |
150 |
||
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
151 |
^ |
2888 | 152 |
'The quick brown fox |
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
153 |
jumps over the lazy dog. |
2860 | 154 |
|
2936 | 155 |
' , (UnicodeString fromString:(#(16r65E5 16r672C 16r8A9E) collect:[:c | Character value:c])) |
382 | 156 |
! |
157 |
||
2847 | 158 |
defaultLatin1SampleString |
159 |
"return the sample latin1 preview text" |
|
160 |
||
2935 | 161 |
^ (self defaultAsciiSampleString) , 'äöüÄÖÜßéèêå©' |
2847 | 162 |
! |
163 |
||
2899 | 164 |
defaultSampleStringForEncoding:enc |
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
165 |
|string lines| |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
166 |
|
2899 | 167 |
enc notNil ifTrue:[ |
168 |
((enc startsWith:'unicode') or:[enc startsWith:'iso10646-']) ifTrue:[ |
|
169 |
^ self defaultUnicodeSampleString. |
|
170 |
]. |
|
171 |
(enc startsWith:'ms-ansi') ifTrue:[ |
|
172 |
^ self defaultUnicodeSampleString. |
|
173 |
]. |
|
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
174 |
|
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
175 |
(enc startsWith:'jis') ifTrue:[ |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
176 |
(enc includesString:'0201') ifTrue:[ |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
177 |
string := self defaultJIS0201SampleString |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
178 |
] ifFalse:[ |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
179 |
string := self defaultJISSampleString |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
180 |
] |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
181 |
] ifFalse:[ |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
182 |
] |
2899 | 183 |
]. |
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
184 |
string isNil ifTrue:[ |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
185 |
string := self defaultLatin1SampleString. |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
186 |
]. |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
187 |
lines := string asStringCollection. |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
188 |
Error handle:[:ex | |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
189 |
] do:[ |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
190 |
lines := lines encodeFrom:#unicode into:enc |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
191 |
]. |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
192 |
^ lines. |
2899 | 193 |
! |
194 |
||
2847 | 195 |
defaultUnicodeSampleString |
196 |
"return the sample unicode preview text" |
|
595 | 197 |
|
2275 | 198 |
|t| |
199 |
||
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
200 |
t := (self defaultAsciiSampleString) , ' |
2935 | 201 |
diaresis: äöüÄÖÜß |
202 |
accent: éèêåÅ |
|
2936 | 203 |
cyrillic: ' , (UnicodeString fromString:(#(16r420 16r443 16r441 16r441 16r43A 16r43E) collect:[:c | Character value:c])) , ' |
2933 | 204 |
greek: ' , |
205 |
(UnicodeString fromString:(#(16r395 16r3BB 16r3BB 16r3B7 16r3BD 16r3B9 16r3BA 16r3AC) collect:[:c | Character value:c])) , |
|
206 |
' |
|
207 |
japanese: ' , |
|
208 |
(UnicodeString fromString:(#(16r65E5 16r672C 16r8A9E) collect:[:c | Character value:c])) , |
|
209 |
' |
|
210 |
'. |
|
2276 | 211 |
^ t |
2933 | 212 |
|
213 |
"Modified: 29.4.1996 / 09:46:19 / cg" |
|
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
214 |
! |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
215 |
|
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
216 |
sampleStringWithAllLetters |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
217 |
^ (self classResources at:'CHARSET_TEST_SENTENCE' ifAbsent:'The quick brown fox jumps over the lazy dog') withCRs |
0 | 218 |
! ! |
219 |
||
2852 | 220 |
!FontPanel class methodsFor:'menu specs'! |
221 |
||
222 |
previewMenu |
|
223 |
"This resource specification was automatically generated |
|
224 |
by the MenuEditor of ST/X." |
|
225 |
||
226 |
"Do not manually edit this!! If it is corrupted, |
|
227 |
the MenuEditor may not be able to read the specification." |
|
228 |
||
229 |
" |
|
230 |
MenuEditor new openOnClass:FontPanel andSelector:#previewMenu |
|
231 |
(Menu new fromLiteralArrayEncoding:(FontPanel previewMenu)) startUp |
|
232 |
" |
|
233 |
||
234 |
<resource: #menu> |
|
235 |
||
236 |
^ |
|
237 |
#(Menu |
|
238 |
( |
|
239 |
(MenuItem |
|
240 |
label: 'Copy' |
|
241 |
itemValue: previewCopySelection |
|
242 |
translateLabel: true |
|
243 |
) |
|
244 |
(MenuItem |
|
245 |
label: '-' |
|
246 |
) |
|
247 |
(MenuItem |
|
248 |
label: 'Show Character Set' |
|
249 |
itemValue: previewShowCharacterSet |
|
250 |
translateLabel: true |
|
251 |
) |
|
2875 | 252 |
(MenuItem |
253 |
label: 'Show Character Set (Using xfd)' |
|
254 |
itemValue: previewShowCharacterSetUsingXFD |
|
255 |
translateLabel: true |
|
256 |
isVisible: false |
|
257 |
) |
|
2935 | 258 |
(MenuItem |
259 |
label: '-' |
|
260 |
) |
|
261 |
(MenuItem |
|
262 |
label: 'Inspect Font' |
|
263 |
itemValue: previewInspectFont |
|
264 |
translateLabel: true |
|
265 |
) |
|
2852 | 266 |
) |
267 |
nil |
|
268 |
nil |
|
269 |
) |
|
270 |
! ! |
|
271 |
||
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
272 |
!FontPanel class methodsFor:'startup'! |
0 | 273 |
|
274 |
fontFromUser |
|
77 | 275 |
"open a fontPanel and return the selected font, or nil |
276 |
if abort is pressed" |
|
277 |
||
410 | 278 |
^ self fontFromUserInitial:nil |
279 |
||
280 |
" |
|
281 |
FontPanel fontFromUser |
|
282 |
" |
|
283 |
||
284 |
"Modified: 27.2.1996 / 00:51:59 / cg" |
|
285 |
! |
|
286 |
||
287 |
fontFromUserInitial:aFont |
|
595 | 288 |
"open a fontPanel showing aFont initially, |
289 |
and return the selected font, or nil if abort is pressed" |
|
410 | 290 |
|
413 | 291 |
^ self fontFromUserInitial:aFont title:nil |
292 |
||
293 |
" |
|
294 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) |
|
295 |
" |
|
296 |
||
297 |
"Created: 27.2.1996 / 00:51:44 / cg" |
|
595 | 298 |
"Modified: 29.4.1996 / 09:45:52 / cg" |
413 | 299 |
! |
300 |
||
301 |
fontFromUserInitial:aFont title:someTitle |
|
595 | 302 |
"open a fontPanel with title and return the selected font, |
303 |
or nil if abort is pressed" |
|
413 | 304 |
|
415 | 305 |
^ self fontFromUserInitial:aFont title:someTitle filter:nil |
306 |
||
307 |
" |
|
308 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font' |
|
309 |
" |
|
310 |
||
311 |
"Created: 27.2.1996 / 00:59:46 / cg" |
|
595 | 312 |
"Modified: 29.4.1996 / 09:45:34 / cg" |
415 | 313 |
! |
314 |
||
2849 | 315 |
fontFromUserInitial:initialFont title:someTitle filter:aFilterBlock |
595 | 316 |
"open a fontPanel with title and font-filter |
317 |
and return the selected font, or nil if abort is pressed" |
|
415 | 318 |
|
2887 | 319 |
^ self fontFromUserInitial:initialFont title:someTitle filter:aFilterBlock encoding:nil |
320 |
||
321 |
" |
|
322 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font' |
|
323 |
" |
|
324 |
||
325 |
"Created: 27.2.1996 / 00:59:46 / cg" |
|
326 |
"Modified: 10.4.1997 / 09:53:03 / cg" |
|
327 |
! |
|
328 |
||
329 |
fontFromUserInitial:initialFont title:someTitle filter:aFilterBlock encoding:encoding |
|
330 |
"open a fontPanel with title and font-filter |
|
331 |
and return the selected font, or nil if abort is pressed" |
|
332 |
||
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
333 |
|fontPanel selectedFont| |
77 | 334 |
|
0 | 335 |
fontPanel := FontPanel new. |
415 | 336 |
fontPanel filter:aFilterBlock. |
413 | 337 |
someTitle notNil ifTrue:[ |
338 |
fontPanel label:someTitle |
|
339 |
]. |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
340 |
fontPanel action:[:aFontDescription | selectedFont := aFontDescription]. |
2849 | 341 |
initialFont notNil ifTrue:[ |
342 |
fontPanel initialFont:initialFont. |
|
410 | 343 |
]. |
2888 | 344 |
encoding notNil ifTrue:[ |
345 |
fontPanel encoding:encoding. |
|
2937 | 346 |
] ifFalse:[ |
347 |
initialFont notNil ifTrue:[ |
|
348 |
fontPanel encoding:initialFont encoding |
|
349 |
]. |
|
2888 | 350 |
]. |
0 | 351 |
fontPanel showAtPointer. |
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
352 |
fontPanel destroy. |
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
353 |
^ selectedFont |
0 | 354 |
|
77 | 355 |
" |
413 | 356 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font' |
77 | 357 |
" |
410 | 358 |
|
413 | 359 |
"Created: 27.2.1996 / 00:59:46 / cg" |
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
360 |
"Modified: 10.4.1997 / 09:53:03 / cg" |
0 | 361 |
! ! |
362 |
||
363 |
!FontPanel methodsFor:'accessing'! |
|
364 |
||
595 | 365 |
action:aFourArgBlock |
366 |
"set the action to be evaluated on ok. |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
367 |
The block will be evaluated with family, face, style, size and encoding." |
595 | 368 |
|
369 |
okAction := aFourArgBlock |
|
370 |
||
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
371 |
"Modified: 10.4.1997 / 09:49:58 / cg" |
197 | 372 |
! |
373 |
||
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
374 |
encoding:aPattern |
595 | 375 |
"set the encoding goal" |
376 |
||
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
377 |
encoding := aPattern. |
2843 | 378 |
encodingFilter contents:encoding. |
379 |
||
380 |
self encodingFilterSelected:encoding. |
|
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
381 |
shown ifTrue:[ |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
382 |
self updateFamilyList |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
383 |
]. |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
384 |
|
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
385 |
"Created: 29.2.1996 / 04:05:31 / cg" |
595 | 386 |
"Modified: 29.4.1996 / 09:40:18 / cg" |
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
387 |
! |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
388 |
|
415 | 389 |
filter:aOneArgBlock |
595 | 390 |
"set a filter; if non-nil, only fonts for which the filterBlock |
391 |
returns true will be offered" |
|
392 |
||
415 | 393 |
filter := aOneArgBlock. |
2826 | 394 |
familyList list:nil. |
415 | 395 |
shown ifTrue:[ |
396 |
self updateFamilyList |
|
397 |
]. |
|
398 |
||
399 |
"Created: 27.2.1996 / 01:40:08 / cg" |
|
595 | 400 |
"Modified: 29.4.1996 / 09:40:49 / cg" |
415 | 401 |
! |
402 |
||
0 | 403 |
initialFont:aFont |
128 | 404 |
"set the font to be selected initially" |
0 | 405 |
|
2849 | 406 |
|encoding| |
407 |
||
128 | 408 |
selectedFont := aFont. |
2849 | 409 |
encoding := aFont encoding. |
410 |
"/ self halt. |
|
411 |
encodingFilter contents:encoding. |
|
412 |
self encodingFilterSelected:encoding. |
|
382 | 413 |
self showSelectedFont. |
414 |
||
415 |
"Modified: 23.2.1996 / 00:51:32 / cg" |
|
101 | 416 |
! ! |
417 |
||
77 | 418 |
!FontPanel methodsFor:'initialization'! |
419 |
||
420 |
initialize |
|
382 | 421 |
|familyLabel faceLabel sizeLabel panel fontBrowserView v1 v2 v3 |
2847 | 422 |
mm fH eH l box showFontNameLabel| |
77 | 423 |
|
424 |
super initialize. |
|
425 |
||
2847 | 426 |
showFontNameLabel := device platformName ~= 'WIN32'. |
427 |
||
382 | 428 |
mm := ViewSpacing. |
429 |
||
1763 | 430 |
self addAbortAndOkButtons. |
77 | 431 |
|
390
1d54a9b41463
say Hello world in JIS font ;-)
Claus Gittinger <cg@exept.de>
parents:
382
diff
changeset
|
432 |
panel := View origin:0.0@0.0 corner:1.0@1.0 in:self. |
2847 | 433 |
panel bottomInset:(buttonPanel preferredExtent y |
434 |
+ (mm*3) |
|
435 |
+ (showFontNameLabel ifTrue:24 ifFalse:0) ). |
|
77 | 436 |
|
150 | 437 |
label := resources string:'Font dialog'. |
77 | 438 |
|
2842 | 439 |
box := HorizontalPanelView in:panel. |
440 |
box horizontalLayout:#leftFit. |
|
441 |
box origin:0.0@1.0 corner:0.6@1.0. |
|
442 |
||
443 |
l := Label label:(resources string:'Encoding:') in:box. |
|
444 |
l borderWidth:0. |
|
445 |
l adjust:#left. |
|
446 |
||
447 |
encodingFilter := ComboBoxView in:box. |
|
2826 | 448 |
encodingFilter level:-1. |
449 |
encodingFilter contents:'*'. |
|
2842 | 450 |
encodingFilter list:(self listOfEncodingsInFilterCombo). |
2826 | 451 |
encodingFilter action:[:pattern | self encodingFilterSelected:pattern]. |
452 |
encodingFilter immediateAccept:true. |
|
2842 | 453 |
encodingFilter font:l font. |
454 |
encodingFilter editor font:l font. |
|
455 |
||
456 |
eH := encodingFilter preferredExtent y. |
|
457 |
box topInset:(eH negated-1); horizontalInset:mm. |
|
458 |
||
2826 | 459 |
"/ encodingFilter acceptOnReturn:true. |
460 |
"/ encodingFilter acceptOnTab:true. |
|
461 |
"/ encodingFilter acceptOnLeave:true. |
|
462 |
"/ encodingFilter acceptOnLostFocus:true. |
|
463 |
"/ encodingFilter acceptOnPointerLeave:true. |
|
464 |
||
382 | 465 |
encodingLabel := Label label:' ' in:panel. |
2842 | 466 |
"/ eH := encodingLabel preferredExtent y. |
467 |
encodingLabel origin:0.6@1.0 corner:1.0@1.0. |
|
382 | 468 |
encodingLabel topInset:(eH negated); horizontalInset:mm. |
2842 | 469 |
encodingLabel level:0; adjust:#left. |
470 |
encodingLabel adjust:#right. |
|
382 | 471 |
|
2847 | 472 |
showFontNameLabel ifTrue:[ |
473 |
nameLabel := Label label:'' in:self. |
|
474 |
nameLabel origin:0.0@1.0 corner:1.0@1.0. |
|
475 |
nameLabel bottomInset:(buttonPanel preferredExtent y + (mm*2)). |
|
476 |
nameLabel topInset:(buttonPanel preferredExtent y + (mm*2) + 24) negated; horizontalInset:mm. |
|
477 |
nameLabel level:0; adjust:#left. |
|
478 |
nameLabel font:(FontDescription family:'helvetica' face:'medium' style:'roman' size:9). |
|
479 |
]. |
|
382 | 480 |
|
2842 | 481 |
previewField := HVScrollableView for:TextView in:panel. |
482 |
previewField origin:0.0@0.0 corner:1.0@0.4. |
|
483 |
previewField autoHideScrollBars:true. |
|
484 |
previewField := previewField scrolledView. |
|
382 | 485 |
previewField inset:mm. |
77 | 486 |
|
487 |
self is3D ifTrue:[ |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
488 |
previewField level:-1. |
77 | 489 |
] ifFalse:[ |
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
490 |
previewField borderWidth:1. |
77 | 491 |
]. |
492 |
||
390
1d54a9b41463
say Hello world in JIS font ;-)
Claus Gittinger <cg@exept.de>
parents:
382
diff
changeset
|
493 |
fontBrowserView := View origin:0.0@0.4 corner:1.0@1.0 in:panel. |
382 | 494 |
fontBrowserView bottomInset:(eH + mm). |
77 | 495 |
|
496 |
v1 := View origin:0.0@0.0 corner:0.4@1.0 in:fontBrowserView. |
|
497 |
||
2842 | 498 |
familyLabel := Label label:(resources string:'Family') in:v1. |
77 | 499 |
familyLabel borderWidth:0. |
500 |
familyLabel origin:(0.0 @ 0.0) extent:(1.0 @ nil). |
|
382 | 501 |
fH := familyLabel preferredExtent y. |
77 | 502 |
|
503 |
familyList := ScrollableView for:SelectionInListView in:v1. |
|
382 | 504 |
familyList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
505 |
familyList inset:mm. |
|
506 |
familyList topInset:fH. |
|
507 |
||
128 | 508 |
familyList := familyList scrolledView. |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
509 |
self makeTabable:familyList. |
77 | 510 |
|
511 |
v2 := View origin:0.4@0.0 corner:0.8@1.0 |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
512 |
in:fontBrowserView. |
77 | 513 |
|
2842 | 514 |
faceLabel := Label label:(resources string:'Typeface') in:v2. |
77 | 515 |
faceLabel borderWidth:0. |
516 |
faceLabel origin:(0.0 @ 0.0) extent:(1.0 @ nil). |
|
517 |
||
518 |
faceList := ScrollableView for:SelectionInListView in:v2. |
|
382 | 519 |
faceList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
520 |
faceList inset:mm. |
|
521 |
faceList topInset:fH. |
|
128 | 522 |
faceList := faceList scrolledView. |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
523 |
self makeTabable:faceList. |
77 | 524 |
|
2842 | 525 |
v3 := View origin:0.8@0.0 corner:1.0@1.0 in:fontBrowserView. |
77 | 526 |
|
2842 | 527 |
sizeLabel := Label label:(resources string:'Size') in:v3. |
77 | 528 |
sizeLabel borderWidth:0. |
529 |
sizeLabel origin:(0.0 @ 0.0)extent:(1.0 @ nil). |
|
530 |
||
531 |
sizeList := ScrollableView for:SelectionInListView in:v3. |
|
382 | 532 |
sizeList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
533 |
sizeList inset:mm. |
|
534 |
sizeList topInset:fH. |
|
128 | 535 |
sizeList := sizeList scrolledView. |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
536 |
self makeTabable:sizeList. |
77 | 537 |
|
538 |
familyList action:[:lineNr | self familySelected:(familyList selectionValue)]. |
|
539 |
faceList action:[:lineNr | self faceSelected:(faceList selectionValue)]. |
|
540 |
sizeList action:[:lineNr | self sizeSelected:(sizeList selectionValue)]. |
|
541 |
||
2852 | 542 |
previewField menuHolder:self previewMenu. |
543 |
||
77 | 544 |
" |
545 |
FontPanel new showAtPointer |
|
546 |
" |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
547 |
|
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
548 |
"Modified: 31.5.1996 / 22:01:45 / cg" |
77 | 549 |
! |
550 |
||
2842 | 551 |
listOfEncodingsInFilterCombo |
2878 | 552 |
|availableEncodings listPresentedToUser| |
2842 | 553 |
|
2878 | 554 |
listOfEncodings := OrderedCollection new. |
2849 | 555 |
device platformName = 'WIN32' ifTrue:[ |
2878 | 556 |
listOfEncodings |
2849 | 557 |
addAll: |
558 |
#( |
|
559 |
'*' |
|
560 |
nil |
|
561 |
). |
|
562 |
] ifFalse:[ |
|
2878 | 563 |
listOfEncodings |
2849 | 564 |
addAll: |
565 |
#( |
|
566 |
'*' |
|
567 |
'iso8859*' |
|
568 |
'iso10646-1' |
|
569 |
'jis*' |
|
570 |
nil |
|
571 |
). |
|
572 |
]. |
|
2842 | 573 |
|
574 |
availableEncodings := Set new. |
|
2845 | 575 |
device listOfAvailableFonts do:[:f | availableEncodings add:(f encoding ? '?')]. |
2842 | 576 |
availableEncodings := availableEncodings asSortedCollection. |
2878 | 577 |
listOfEncodings addAll:availableEncodings. |
578 |
||
579 |
listPresentedToUser := listOfEncodings collect:[:enc | |
|
580 |
|encoder userFriendlyName| |
|
581 |
||
2938 | 582 |
"/ |
583 |
"/ disabled to avoid autoloading of encoders. |
|
584 |
"/ (enc notNil and:[enc ~= '*']) ifTrue:[ |
|
585 |
"/ encoder := CharacterEncoder encoderFor:enc ifAbsent:nil. |
|
586 |
"/ encoder notNil ifTrue:[ |
|
587 |
"/ userFriendlyName := encoder userFriendlyNameOfEncoding. |
|
588 |
"/ ]. |
|
589 |
"/ ]. |
|
2937 | 590 |
(userFriendlyName notNil and:[(userFriendlyName sameAs: enc) not]) ifTrue:[ |
2878 | 591 |
enc , ' (' , userFriendlyName , ')' |
592 |
] ifFalse:[ |
|
593 |
enc |
|
594 |
] |
|
595 |
]. |
|
596 |
^ listPresentedToUser. |
|
2842 | 597 |
! |
598 |
||
1277 | 599 |
postRealize |
197 | 600 |
"kludge for sco - xlsfont fails sometimes - try again here" |
601 |
||
415 | 602 |
self updateFamilyList. |
1277 | 603 |
super postRealize |
415 | 604 |
|
605 |
"Modified: 27.2.1996 / 01:40:47 / cg" |
|
1277 | 606 |
"Created: 24.7.1997 / 18:12:42 / cg" |
2852 | 607 |
! |
608 |
||
609 |
previewMenu |
|
610 |
<resource: #programMenu > |
|
611 |
||
612 |
|menu| |
|
613 |
||
614 |
menu := Menu new fromLiteralArrayEncoding:self class previewMenu. |
|
615 |
menu findGuiResourcesIn:self. |
|
616 |
menu receiver:self. |
|
2875 | 617 |
|
618 |
OperatingSystem isUNIXlike ifTrue:[ |
|
619 |
(menu menuItemWithValue:#previewShowCharacterSetUsingXFD) isVisible: true |
|
620 |
]. |
|
2852 | 621 |
^ menu |
77 | 622 |
! ! |
623 |
||
0 | 624 |
!FontPanel methodsFor:'private'! |
625 |
||
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
626 |
clearPreview |
595 | 627 |
"clear the preview subview" |
628 |
||
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
629 |
shown ifTrue:[ |
1297
f5ea02391a59
use #contents: instead of #clear
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
630 |
previewField contents:nil. |
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
631 |
encodingLabel label:''. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
632 |
]. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
633 |
|
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
634 |
"Created: 17.4.1996 / 15:19:16 / cg" |
1297
f5ea02391a59
use #contents: instead of #clear
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
635 |
"Modified: 11.8.1997 / 03:01:42 / cg" |
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
636 |
! |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
637 |
|
197 | 638 |
extractFaceAndStyleFrom:aString |
595 | 639 |
"given a string, extract currentFace and currentStyle" |
640 |
||
197 | 641 |
|index| |
642 |
||
643 |
index := aString indexOf:$-. |
|
644 |
(index ~~ 0) ifTrue:[ |
|
595 | 645 |
currentFaceAndStyle := aString. |
646 |
currentFace := aString copyTo:(index - 1). |
|
647 |
currentStyle := aString copyFrom:(index + 1) |
|
197 | 648 |
] |
649 |
||
595 | 650 |
"Modified: 29.4.1996 / 09:41:47 / cg" |
197 | 651 |
! |
652 |
||
653 |
showPreview |
|
595 | 654 |
"show the preview text" |
655 |
||
2899 | 656 |
|font deviceFont enc allFonts fonts fontName| |
382 | 657 |
|
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
658 |
self clearPreview. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
659 |
|
197 | 660 |
" |
661 |
show a wait cursor: for some fonts (kanji etc) the |
|
2890 | 662 |
X-server needs quite some time to load the font |
197 | 663 |
" |
255 | 664 |
self withWaitCursorDo:[ |
2842 | 665 |
allFonts := device |
1257 | 666 |
fontsInFamily:(currentFamily ? '*') |
667 |
face:(currentFace ? '*') |
|
668 |
style:(currentStyle ? '*') |
|
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
669 |
filtering:filter. |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
670 |
|
2848 | 671 |
fonts := allFonts select:[:f | f size = currentSize]. |
450 | 672 |
fonts notEmpty ifTrue:[ |
2843 | 673 |
font := fonts anElement. |
450 | 674 |
] ifFalse:[ |
2848 | 675 |
"/ mhmh: |
676 |
"/ size=0 is returned for scalable fonts. |
|
677 |
"/ Any size is possible. |
|
450 | 678 |
"/ |
2848 | 679 |
fonts := allFonts select:[:f | f size = 0]. |
450 | 680 |
fonts notEmpty ifTrue:[ |
2843 | 681 |
font := Font family:currentFamily |
450 | 682 |
face:currentFace |
683 |
style:currentStyle |
|
684 |
size:currentSize |
|
685 |
encoding:(fonts anElement encoding). |
|
686 |
] |
|
687 |
]. |
|
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
688 |
|
2843 | 689 |
font notNil ifTrue:[ |
2890 | 690 |
deviceFont := font onDevice:device. |
691 |
enc := deviceFont encoding. |
|
2916 | 692 |
enc isNil ifTrue:[enc := #'fontspecific']. |
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
693 |
|
2874 | 694 |
previewField font:deviceFont. |
695 |
previewField characterEncoding:enc. |
|
696 |
||
2287
b33ad40d7538
preview fixed when font is bad
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
697 |
encodingLabel label:enc. |
2843 | 698 |
currentEncoding := enc. |
699 |
fontName := deviceFont fullName. |
|
2899 | 700 |
previewField contents:(self class defaultSampleStringForEncoding:enc). |
382 | 701 |
] ifFalse:[ |
2842 | 702 |
previewField contents:nil. |
703 |
encodingLabel label:nil. |
|
2843 | 704 |
currentEncoding := nil. |
2842 | 705 |
fontName := nil. |
382 | 706 |
]. |
2842 | 707 |
nameLabel notNil ifTrue:[nameLabel label:fontName]. |
197 | 708 |
] |
255 | 709 |
|
1257 | 710 |
"Modified: 30.6.1997 / 17:26:22 / cg" |
197 | 711 |
! |
712 |
||
128 | 713 |
showSelectedFont |
2843 | 714 |
|fam face faceAndStyle style sz| |
128 | 715 |
|
716 |
fam := selectedFont family. |
|
2843 | 717 |
currentEncoding := selectedFont encoding. |
718 |
||
2888 | 719 |
self familySelected:fam showPreview:false. |
128 | 720 |
fam notNil ifTrue:[ |
2842 | 721 |
face := selectedFont face. |
722 |
(face notNil and:[(style := selectedFont style) notNil]) ifTrue:[ |
|
723 |
faceAndStyle := face , '-' , style. |
|
724 |
]. |
|
2888 | 725 |
self faceSelected:faceAndStyle showPreview:false. |
2842 | 726 |
faceAndStyle notNil ifTrue:[ |
727 |
sz := selectedFont size. |
|
2888 | 728 |
self sizeSelected:sz showPreview:false. |
2842 | 729 |
] |
730 |
]. |
|
2888 | 731 |
|
732 |
self showPreview |
|
2826 | 733 |
! |
734 |
||
735 |
updateFamilyList |
|
736 |
"update the list of font families" |
|
737 |
||
738 |
|families| |
|
739 |
||
740 |
familyList list isNil ifTrue:[ |
|
741 |
families := device fontFamiliesFiltering:filter. |
|
742 |
families notNil ifTrue:[ |
|
743 |
families := families asOrderedCollection sort |
|
744 |
]. |
|
745 |
familyList list:families |
|
746 |
]. |
|
747 |
selectedFont notNil ifTrue:[ |
|
748 |
self showSelectedFont |
|
749 |
]. |
|
750 |
||
751 |
"Modified: 27.2.1996 / 01:39:42 / cg" |
|
752 |
"Created: 27.2.1996 / 01:40:37 / cg" |
|
197 | 753 |
! ! |
128 | 754 |
|
197 | 755 |
!FontPanel methodsFor:'queries'! |
0 | 756 |
|
197 | 757 |
preferredExtent |
595 | 758 |
"return the boxes preferredExtent" |
572 | 759 |
|
797 | 760 |
"/ If I have an explicit preferredExtent .. |
761 |
||
713
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
762 |
preferredExtent notNil ifTrue:[ |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
763 |
^ preferredExtent |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
764 |
]. |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
765 |
|
2842 | 766 |
^ 450@350 |
572 | 767 |
|
797 | 768 |
"Modified: 19.7.1996 / 20:44:08 / cg" |
0 | 769 |
! ! |
77 | 770 |
|
771 |
!FontPanel methodsFor:'user interaction'! |
|
772 |
||
2826 | 773 |
encodingFilterSelected:anEncodingPattern |
774 |
"another encoding was selected; find available fonts and update lists" |
|
775 |
||
776 |
|pattern| |
|
777 |
||
2887 | 778 |
anEncodingPattern isNil ifTrue:[ |
779 |
self filter:nil. |
|
780 |
^ self. |
|
781 |
]. |
|
782 |
||
2878 | 783 |
pattern := (anEncodingPattern upTo:$( ) withoutSeparators. |
784 |
||
785 |
pattern = '?' ifTrue:[ |
|
2845 | 786 |
pattern := '' |
787 |
] ifFalse:[ |
|
2878 | 788 |
pattern := (pattern isEmptyOrNil ifTrue:'*' ifFalse:pattern). |
2845 | 789 |
]. |
2826 | 790 |
self |
791 |
filter: |
|
792 |
[:f | |
|
793 |
|encoding| |
|
794 |
||
795 |
encoding := f encoding ? ''. |
|
796 |
pattern match:encoding |
|
797 |
]. |
|
798 |
! |
|
799 |
||
197 | 800 |
faceSelected:aFaceAndStyleName |
2826 | 801 |
"a fonts face was selected; find available sizes and update lists" |
595 | 802 |
|
2842 | 803 |
self faceSelected:aFaceAndStyleName showPreview:true |
804 |
! |
|
805 |
||
806 |
faceSelected:aFaceAndStyleName showPreview:showPreview |
|
807 |
"a fonts face was selected; find available sizes and update lists" |
|
808 |
||
2890 | 809 |
|sizes didShow| |
197 | 810 |
|
811 |
aFaceAndStyleName notNil ifTrue:[ |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
812 |
self extractFaceAndStyleFrom:aFaceAndStyleName. |
197 | 813 |
]. |
814 |
sizes := device |
|
1257 | 815 |
sizesInFamily:(currentFamily ? '*') |
816 |
face:(currentFace ? '*') |
|
817 |
style:(currentStyle ? '*') |
|
415 | 818 |
filtering:filter. |
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
819 |
|
197 | 820 |
(sizes isNil or:[sizes isEmpty]) ifTrue:[ |
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
821 |
sizeList list:nil. |
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
822 |
currentSize := nil. |
2842 | 823 |
showPreview ifTrue:[ |
824 |
self showPreview. |
|
825 |
]. |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
826 |
^ self |
197 | 827 |
]. |
828 |
||
2890 | 829 |
didShow := false. |
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
830 |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
831 |
sizes := (sizes asOrderedCollection sort) collect:[:entry | entry printString]. |
197 | 832 |
sizeList list:sizes. |
833 |
currentSize notNil ifTrue:[ |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
834 |
(sizes includes:(currentSize printString)) ifTrue:[ |
2170 | 835 |
sizeList setSelectElement:currentSize printString. |
2842 | 836 |
showPreview ifTrue:[ |
2890 | 837 |
self showPreview. |
838 |
didShow := true. |
|
2842 | 839 |
] |
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
840 |
] |
2890 | 841 |
]. |
842 |
didShow ifFalse:[ |
|
843 |
self clearPreview |
|
844 |
]. |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
845 |
|
1257 | 846 |
"Modified: 30.6.1997 / 17:25:46 / cg" |
197 | 847 |
! |
848 |
||
77 | 849 |
familySelected:aFamilyName |
2826 | 850 |
"a fonts family was selected; find available faces and update lists" |
595 | 851 |
|
2842 | 852 |
self familySelected:aFamilyName showPreview:true |
853 |
! |
|
854 |
||
855 |
familySelected:aFamilyName showPreview:showPreview |
|
856 |
"a fonts family was selected; find available faces and update lists" |
|
857 |
||
77 | 858 |
|faces styles list| |
859 |
||
690 | 860 |
familyList setSelectElement:aFamilyName. |
77 | 861 |
|
862 |
currentFamily := aFamilyName. |
|
415 | 863 |
faces := device facesInFamily:aFamilyName filtering:filter. |
2353 | 864 |
(faces size = 0) ifTrue:[ |
415 | 865 |
currentFace := currentStyle := currentFaceAndStyle := nil. |
866 |
faceList list:nil. |
|
2842 | 867 |
self faceSelected:nil showPreview:showPreview. |
415 | 868 |
^ self. |
77 | 869 |
]. |
870 |
||
2353 | 871 |
list := SortedCollection new. |
77 | 872 |
faces do:[:aFace | |
415 | 873 |
styles := device stylesInFamily:aFamilyName face:aFace filtering:filter. |
874 |
styles do:[:aStyle | |
|
875 |
list add:(aFace , '-' , aStyle) |
|
876 |
] |
|
77 | 877 |
]. |
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
878 |
|
77 | 879 |
faceList list:list. |
880 |
currentFaceAndStyle notNil ifTrue:[ |
|
415 | 881 |
(list includes:currentFaceAndStyle) ifTrue:[ |
690 | 882 |
faceList setSelectElement:currentFaceAndStyle. |
2842 | 883 |
self faceSelected:currentFaceAndStyle showPreview:showPreview. |
415 | 884 |
^ self |
885 |
] |
|
77 | 886 |
]. |
2842 | 887 |
|
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
888 |
sizeList list:nil. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
889 |
self clearPreview. |
415 | 890 |
|
690 | 891 |
"Modified: 26.5.1996 / 15:04:29 / cg" |
77 | 892 |
! |
893 |
||
894 |
okPressed |
|
595 | 895 |
"ok was pressed; hide myself and evaluate the okAction, passing |
896 |
family, face, style and size as arguments" |
|
897 |
||
77 | 898 |
self hide. |
899 |
okAction notNil ifTrue:[ |
|
410 | 900 |
currentFamily notNil ifTrue:[ |
2842 | 901 |
okAction |
902 |
value:(FontDescription |
|
903 |
family:currentFamily |
|
904 |
face:currentFace |
|
905 |
style:currentStyle |
|
906 |
size:currentSize |
|
2843 | 907 |
encoding:(currentEncoding ? encoding)). |
410 | 908 |
] |
77 | 909 |
] |
410 | 910 |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
911 |
"Modified: 10.4.1997 / 09:51:31 / cg" |
77 | 912 |
! |
913 |
||
2852 | 914 |
previewCopySelection |
915 |
previewField copySelection. |
|
916 |
! |
|
917 |
||
2935 | 918 |
previewInspectFont |
919 |
previewField font inspect. |
|
920 |
! |
|
921 |
||
2852 | 922 |
previewShowCharacterSet |
923 |
CharacterSetView openOn:(previewField font) |
|
924 |
! |
|
925 |
||
2875 | 926 |
previewShowCharacterSetUsingXFD |
2878 | 927 |
[ |
928 |
OperatingSystem executeCommand:'xfd -fn ' , previewField font fullName. |
|
929 |
] fork. |
|
2875 | 930 |
! |
931 |
||
77 | 932 |
sizeSelected:aNumberOrString |
2826 | 933 |
"a size was selected; update preview" |
595 | 934 |
|
2842 | 935 |
self sizeSelected:aNumberOrString showPreview:true. |
936 |
! |
|
937 |
||
938 |
sizeSelected:aNumberOrString showPreview:showPreview |
|
939 |
"a size was selected; update preview" |
|
940 |
||
77 | 941 |
aNumberOrString isNumber ifTrue:[ |
595 | 942 |
currentSize := aNumberOrString |
77 | 943 |
] ifFalse:[ |
2826 | 944 |
currentSize := Number readFromString:aNumberOrString onError:nil |
77 | 945 |
]. |
2842 | 946 |
showPreview ifTrue:[self showPreview] |
595 | 947 |
|
948 |
"Modified: 29.4.1996 / 09:43:23 / cg" |
|
77 | 949 |
! ! |
197 | 950 |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
951 |
!FontPanel class methodsFor:'documentation'! |
243 | 952 |
|
953 |
version |
|
2938 | 954 |
^ '$Header: /cvs/stx/stx/libwidg/FontPanel.st,v 1.82 2004-03-10 16:36:19 ca Exp $' |
243 | 955 |
! ! |