author | Claus Gittinger <cg@exept.de> |
Tue, 13 Apr 2010 16:32:34 +0200 | |
changeset 4147 | 150b7dff3b6a |
parent 4094 | 257521b4e80f |
child 4161 | bda1fae34c83 |
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 |
" |
|
2275 | 12 |
"{ Package: 'stx:libwidg' }" |
13 |
||
77 | 14 |
DialogBox subclass:#FontPanel |
2878 | 15 |
instanceVariableNames:'previewField listOfEncodings familyList faceList sizeList |
16 |
revertButton currentFamily currentFace currentStyle |
|
3832 | 17 |
currentFaceAndStyle currentSize sizeUnit currentEncoding |
18 |
selectedFont nameLabel encodingFilter encodingLabel filter |
|
3841 | 19 |
encoding sizeLabelHolder pixelPointSwitch' |
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
20 |
classVariableNames:'' |
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
21 |
poolDictionaries:'' |
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
22 |
category:'Views-DialogBoxes' |
0 | 23 |
! |
24 |
||
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
25 |
!FontPanel class methodsFor:'documentation'! |
77 | 26 |
|
197 | 27 |
copyright |
28 |
" |
|
29 |
COPYRIGHT (c) 1991 by Claus Gittinger |
|
30 |
All Rights Reserved |
|
31 |
||
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
||
40 |
||
77 | 41 |
! |
42 |
||
43 |
documentation |
|
44 |
" |
|
45 |
this class implements a font chooser. |
|
46 |
||
2826 | 47 |
Notice: |
48 |
this is a very old dialog; |
|
49 |
it was written before the UI-framework was available and is completely |
|
50 |
setup manually (initialize method). |
|
51 |
Therefore, it desperately asks to be rewritten using the UIPainter... |
|
52 |
||
595 | 53 |
[author:] |
54 |
Claus Gittinger |
|
55 |
||
56 |
[see also:] |
|
57 |
Font FontDescription |
|
58 |
View Dialog |
|
59 |
" |
|
60 |
! |
|
61 |
||
62 |
examples |
|
63 |
" |
|
64 |
very simple: |
|
65 |
[exBegin] |
|
66 |
|font| |
|
67 |
||
68 |
font := FontPanel fontFromUser. |
|
655 | 69 |
Transcript showCR:font |
595 | 70 |
[exEnd] |
71 |
||
72 |
||
73 |
with initial font: |
|
74 |
[exBegin] |
|
75 |
|font| |
|
76 |
||
77 |
font := FontPanel |
|
78 |
fontFromUserInitial:(Font |
|
79 |
family:'courier' |
|
80 |
size:12). |
|
655 | 81 |
Transcript showCR:font |
595 | 82 |
[exEnd] |
83 |
||
84 |
||
85 |
with initial font & title: |
|
86 |
[exBegin] |
|
87 |
|font| |
|
88 |
||
89 |
font := FontPanel |
|
90 |
fontFromUserInitial:(Font |
|
91 |
family:'courier' |
|
92 |
size:12) |
|
93 |
title:'select a fooBar font'. |
|
655 | 94 |
Transcript showCR:font |
595 | 95 |
[exEnd] |
96 |
||
97 |
||
98 |
full setup; setting a filter to only present iso fonts |
|
99 |
and callBack action: |
|
100 |
[exBegin] |
|
0 | 101 |
|
585 | 102 |
|panel| |
77 | 103 |
|
585 | 104 |
panel := FontPanel new. |
595 | 105 |
panel label:'hi there - which iso font ?'. |
106 |
panel filter:[:fd | fd encoding notNil |
|
107 |
and:[fd encoding startsWith:'iso']]. |
|
108 |
panel action:[:family :face :style :size | |
|
655 | 109 |
Transcript showCR:'family:' , family. |
110 |
Transcript showCR:'face:' , face. |
|
111 |
Transcript showCR:'style:' , style. |
|
112 |
Transcript showCR:'size:' , size printString. |
|
595 | 113 |
]. |
114 |
panel open |
|
115 |
[exEnd] |
|
77 | 116 |
" |
117 |
! ! |
|
0 | 118 |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
119 |
!FontPanel class methodsFor:'defaults'! |
0 | 120 |
|
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
121 |
defaultAsciiSampleString |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
122 |
^ (self sampleStringWithAllLetters) , ' |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
123 |
|
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
124 |
ABCDEFGHIJKLMNOPQRSTUVWXYZ |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
125 |
abcdefghijklmnopqrstuvwxyz |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
126 |
1234567890 !!@#$%^&*(){}[]:"~;,./<>? |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
127 |
' |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
128 |
! |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
129 |
|
197 | 130 |
defaultExtent |
571 | 131 |
"return the default extent of my instances. |
132 |
The value returned here is usually ignored, and |
|
133 |
the value from preferredExtent taken instead." |
|
134 |
||
2842 | 135 |
^ (Screen current pixelPerMillimeter * (150 @ 100)) rounded |
571 | 136 |
|
137 |
"Modified: 22.4.1996 / 23:36:19 / cg" |
|
197 | 138 |
! |
139 |
||
2860 | 140 |
defaultJIS0201SampleString |
141 |
"return the sample jis preview text" |
|
142 |
||
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
143 |
^ (self defaultLatin1SampleString). |
2860 | 144 |
! |
145 |
||
382 | 146 |
defaultJISSampleString |
595 | 147 |
"return the sample jis preview text" |
148 |
||
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
149 |
^ |
2888 | 150 |
'The quick brown fox |
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
151 |
jumps over the lazy dog. |
2860 | 152 |
|
2939 | 153 |
' , #(16r65E5 16r672C 16r8A9E) asUnicodeString |
382 | 154 |
! |
155 |
||
2847 | 156 |
defaultLatin1SampleString |
157 |
"return the sample latin1 preview text" |
|
158 |
||
2935 | 159 |
^ (self defaultAsciiSampleString) , 'äöüÄÖÜßéèêå©' |
2847 | 160 |
! |
161 |
||
2899 | 162 |
defaultSampleStringForEncoding:enc |
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
163 |
|string lines| |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
164 |
|
2899 | 165 |
enc notNil ifTrue:[ |
166 |
((enc startsWith:'unicode') or:[enc startsWith:'iso10646-']) ifTrue:[ |
|
167 |
^ self defaultUnicodeSampleString. |
|
168 |
]. |
|
169 |
(enc startsWith:'ms-ansi') ifTrue:[ |
|
170 |
^ self defaultUnicodeSampleString. |
|
171 |
]. |
|
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
172 |
|
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
173 |
(enc startsWith:'jis') ifTrue:[ |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
174 |
(enc includesString:'0201') ifTrue:[ |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
175 |
string := self defaultJIS0201SampleString |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
176 |
] ifFalse:[ |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
177 |
string := self defaultJISSampleString |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
178 |
] |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
179 |
] ifFalse:[ |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
180 |
] |
2899 | 181 |
]. |
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
182 |
string isNil ifTrue:[ |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
183 |
string := self defaultLatin1SampleString. |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
184 |
]. |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
185 |
lines := string asStringCollection. |
3481
a1fbc8d2494d
Catch CharacterEncoderError instead of Error
Stefan Vogel <sv@exept.de>
parents:
3475
diff
changeset
|
186 |
[ |
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
187 |
lines := lines encodeFrom:#unicode into:enc |
3481
a1fbc8d2494d
Catch CharacterEncoderError instead of Error
Stefan Vogel <sv@exept.de>
parents:
3475
diff
changeset
|
188 |
] on:CharacterEncoderError do:[:ex| |
a1fbc8d2494d
Catch CharacterEncoderError instead of Error
Stefan Vogel <sv@exept.de>
parents:
3475
diff
changeset
|
189 |
"substitute a default value for codes that cannot be represented |
a1fbc8d2494d
Catch CharacterEncoderError instead of Error
Stefan Vogel <sv@exept.de>
parents:
3475
diff
changeset
|
190 |
in the new character set" |
a1fbc8d2494d
Catch CharacterEncoderError instead of Error
Stefan Vogel <sv@exept.de>
parents:
3475
diff
changeset
|
191 |
ex proceedWith:ex defaultValue. |
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
192 |
]. |
3481
a1fbc8d2494d
Catch CharacterEncoderError instead of Error
Stefan Vogel <sv@exept.de>
parents:
3475
diff
changeset
|
193 |
|
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
194 |
^ lines. |
2899 | 195 |
! |
196 |
||
2847 | 197 |
defaultUnicodeSampleString |
198 |
"return the sample unicode preview text" |
|
595 | 199 |
|
2275 | 200 |
|t| |
201 |
||
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
202 |
t := (self defaultAsciiSampleString) , ' |
2935 | 203 |
diaresis: äöüÄÖÜß |
204 |
accent: éèêåÅ |
|
3187 | 205 |
special:' , |
206 |
#(16r20AC) asUnicodeString , ' |
|
2939 | 207 |
cyrillic: ' , |
208 |
#(16r440 16r443 16r441 16r441 16r43A 16r438 16r439 16r20 16r44F 16r437 16r44B 16r43A) asUnicodeString , ' |
|
2933 | 209 |
greek: ' , |
2939 | 210 |
#(16r395 16r3BB 16r3BB 16r3B7 16r3BD 16r3B9 16r3BA 16r3AC) asUnicodeString , |
2933 | 211 |
' |
212 |
japanese: ' , |
|
2939 | 213 |
#(16r65E5 16r672C 16r8A9E) asUnicodeString , |
2933 | 214 |
' |
215 |
'. |
|
2276 | 216 |
^ t |
2933 | 217 |
|
218 |
"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
|
219 |
! |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
220 |
|
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
221 |
sampleStringWithAllLetters |
4147
150b7dff3b6a
comment/format in: #sampleStringWithAllLetters
Claus Gittinger <cg@exept.de>
parents:
4094
diff
changeset
|
222 |
^ (self classResources |
150b7dff3b6a
comment/format in: #sampleStringWithAllLetters
Claus Gittinger <cg@exept.de>
parents:
4094
diff
changeset
|
223 |
at:'CHARSET_TEST_SENTENCE' |
150b7dff3b6a
comment/format in: #sampleStringWithAllLetters
Claus Gittinger <cg@exept.de>
parents:
4094
diff
changeset
|
224 |
ifAbsent:'The quick brown fox jumps over the lazy dog') withCRs |
0 | 225 |
! ! |
226 |
||
2852 | 227 |
!FontPanel class methodsFor:'menu specs'! |
228 |
||
229 |
previewMenu |
|
230 |
"This resource specification was automatically generated |
|
231 |
by the MenuEditor of ST/X." |
|
232 |
||
233 |
"Do not manually edit this!! If it is corrupted, |
|
234 |
the MenuEditor may not be able to read the specification." |
|
235 |
||
236 |
" |
|
237 |
MenuEditor new openOnClass:FontPanel andSelector:#previewMenu |
|
238 |
(Menu new fromLiteralArrayEncoding:(FontPanel previewMenu)) startUp |
|
239 |
" |
|
240 |
||
241 |
<resource: #menu> |
|
242 |
||
243 |
^ |
|
244 |
#(Menu |
|
245 |
( |
|
246 |
(MenuItem |
|
247 |
label: 'Copy' |
|
248 |
itemValue: previewCopySelection |
|
249 |
translateLabel: true |
|
250 |
) |
|
251 |
(MenuItem |
|
252 |
label: '-' |
|
253 |
) |
|
254 |
(MenuItem |
|
255 |
label: 'Show Character Set' |
|
256 |
itemValue: previewShowCharacterSet |
|
257 |
translateLabel: true |
|
3405
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
258 |
isVisible: characterSetViewClassAvailable |
2852 | 259 |
) |
2875 | 260 |
(MenuItem |
261 |
label: 'Show Character Set (Using xfd)' |
|
262 |
itemValue: previewShowCharacterSetUsingXFD |
|
263 |
translateLabel: true |
|
3405
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
264 |
isVisible: osIsUNIX |
2875 | 265 |
) |
2935 | 266 |
(MenuItem |
267 |
label: '-' |
|
3405
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
268 |
isVisible: characterSetViewClassAvailableOrOSIsUNIX |
2935 | 269 |
) |
270 |
(MenuItem |
|
271 |
label: 'Inspect Font' |
|
272 |
itemValue: previewInspectFont |
|
273 |
translateLabel: true |
|
274 |
) |
|
3604 | 275 |
(MenuItem |
276 |
label: 'Copy Fontname' |
|
277 |
itemValue: copyFontName |
|
278 |
translateLabel: true |
|
279 |
) |
|
2852 | 280 |
) |
281 |
nil |
|
282 |
nil |
|
283 |
) |
|
3405
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
284 |
|
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
285 |
"Modified: / 11-10-2006 / 21:51:02 / cg" |
2852 | 286 |
! ! |
287 |
||
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
288 |
!FontPanel class methodsFor:'startup'! |
0 | 289 |
|
290 |
fontFromUser |
|
77 | 291 |
"open a fontPanel and return the selected font, or nil |
292 |
if abort is pressed" |
|
293 |
||
3740 | 294 |
^ self |
295 |
fontFromUserInitial:nil |
|
296 |
title:nil |
|
297 |
filter:nil |
|
298 |
encoding:nil |
|
299 |
enabled:true |
|
410 | 300 |
|
301 |
" |
|
302 |
FontPanel fontFromUser |
|
303 |
" |
|
304 |
||
305 |
"Modified: 27.2.1996 / 00:51:59 / cg" |
|
306 |
! |
|
307 |
||
308 |
fontFromUserInitial:aFont |
|
595 | 309 |
"open a fontPanel showing aFont initially, |
310 |
and return the selected font, or nil if abort is pressed" |
|
410 | 311 |
|
3740 | 312 |
^ self |
313 |
fontFromUserInitial:aFont |
|
314 |
title:nil |
|
315 |
filter:nil |
|
316 |
encoding:nil |
|
317 |
enabled:true |
|
413 | 318 |
|
319 |
" |
|
320 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) |
|
3740 | 321 |
FontPanel fontFromUserInitial:MenuPanel defaultFont |
413 | 322 |
" |
323 |
! |
|
324 |
||
325 |
fontFromUserInitial:aFont title:someTitle |
|
595 | 326 |
"open a fontPanel with title and return the selected font, |
327 |
or nil if abort is pressed" |
|
413 | 328 |
|
3740 | 329 |
^ self |
330 |
fontFromUserInitial:aFont |
|
331 |
title:someTitle |
|
332 |
filter:nil |
|
333 |
encoding:nil |
|
334 |
enabled:true |
|
415 | 335 |
|
336 |
" |
|
337 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font' |
|
338 |
" |
|
339 |
||
340 |
"Created: 27.2.1996 / 00:59:46 / cg" |
|
595 | 341 |
"Modified: 29.4.1996 / 09:45:34 / cg" |
415 | 342 |
! |
343 |
||
2849 | 344 |
fontFromUserInitial:initialFont title:someTitle filter:aFilterBlock |
595 | 345 |
"open a fontPanel with title and font-filter |
346 |
and return the selected font, or nil if abort is pressed" |
|
415 | 347 |
|
3740 | 348 |
^ self |
349 |
fontFromUserInitial:initialFont |
|
350 |
title:someTitle |
|
351 |
filter:aFilterBlock |
|
352 |
encoding:nil |
|
353 |
enabled:true |
|
2887 | 354 |
|
355 |
" |
|
356 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font' |
|
357 |
" |
|
358 |
||
359 |
"Created: 27.2.1996 / 00:59:46 / cg" |
|
360 |
"Modified: 10.4.1997 / 09:53:03 / cg" |
|
361 |
! |
|
362 |
||
363 |
fontFromUserInitial:initialFont title:someTitle filter:aFilterBlock encoding:encoding |
|
364 |
"open a fontPanel with title and font-filter |
|
365 |
and return the selected font, or nil if abort is pressed" |
|
366 |
||
3740 | 367 |
^ self |
368 |
fontFromUserInitial:initialFont |
|
369 |
title:someTitle |
|
370 |
filter:aFilterBlock |
|
371 |
encoding:encoding |
|
372 |
enabled:true |
|
373 |
||
374 |
" |
|
375 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font' |
|
376 |
" |
|
377 |
! |
|
378 |
||
379 |
fontFromUserInitial:initialFont title:someTitle filter:aFilterBlock encoding:encoding enabled:enabled |
|
380 |
"open a fontPanel with title and font-filter |
|
381 |
and return the selected font, or nil if abort is pressed" |
|
382 |
||
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
383 |
|fontPanel selectedFont| |
77 | 384 |
|
3817 | 385 |
fontPanel := self new. |
415 | 386 |
fontPanel filter:aFilterBlock. |
413 | 387 |
someTitle notNil ifTrue:[ |
388 |
fontPanel label:someTitle |
|
389 |
]. |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
390 |
fontPanel action:[:aFontDescription | selectedFont := aFontDescription]. |
2849 | 391 |
initialFont notNil ifTrue:[ |
392 |
fontPanel initialFont:initialFont. |
|
410 | 393 |
]. |
2888 | 394 |
encoding notNil ifTrue:[ |
395 |
fontPanel encoding:encoding. |
|
2937 | 396 |
] ifFalse:[ |
397 |
initialFont notNil ifTrue:[ |
|
398 |
fontPanel encoding:initialFont encoding |
|
399 |
]. |
|
2888 | 400 |
]. |
3740 | 401 |
fontPanel enabled:enabled. |
0 | 402 |
fontPanel showAtPointer. |
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
403 |
fontPanel destroy. |
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
404 |
^ selectedFont |
0 | 405 |
|
77 | 406 |
" |
413 | 407 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font' |
77 | 408 |
" |
410 | 409 |
|
413 | 410 |
"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
|
411 |
"Modified: 10.4.1997 / 09:53:03 / cg" |
3740 | 412 |
! |
413 |
||
414 |
openOn:aFont |
|
415 |
"open a fontPanel showing aFont initially. |
|
416 |
This panel is for information only - no font selection is possible." |
|
417 |
||
418 |
^ self |
|
419 |
fontFromUserInitial:aFont |
|
420 |
title:(aFont userFriendlyName) |
|
421 |
filter:nil |
|
422 |
encoding:nil |
|
423 |
enabled:false |
|
424 |
||
425 |
" |
|
426 |
FontPanel openOn:(Font family:'courier' size:12) |
|
427 |
FontPanel openOn:MenuPanel defaultFont |
|
428 |
" |
|
0 | 429 |
! ! |
430 |
||
431 |
!FontPanel methodsFor:'accessing'! |
|
432 |
||
595 | 433 |
action:aFourArgBlock |
434 |
"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
|
435 |
The block will be evaluated with family, face, style, size and encoding." |
595 | 436 |
|
437 |
okAction := aFourArgBlock |
|
438 |
||
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
439 |
"Modified: 10.4.1997 / 09:49:58 / cg" |
197 | 440 |
! |
441 |
||
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
442 |
encoding:aPattern |
595 | 443 |
"set the encoding goal" |
444 |
||
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
445 |
encoding := aPattern. |
2843 | 446 |
encodingFilter contents:encoding. |
447 |
||
448 |
self encodingFilterSelected:encoding. |
|
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
449 |
shown ifTrue:[ |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
450 |
self updateFamilyList |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
451 |
]. |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
452 |
|
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
453 |
"Created: 29.2.1996 / 04:05:31 / cg" |
595 | 454 |
"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
|
455 |
! |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
456 |
|
415 | 457 |
filter:aOneArgBlock |
595 | 458 |
"set a filter; if non-nil, only fonts for which the filterBlock |
459 |
returns true will be offered" |
|
460 |
||
415 | 461 |
filter := aOneArgBlock. |
2826 | 462 |
familyList list:nil. |
415 | 463 |
shown ifTrue:[ |
464 |
self updateFamilyList |
|
465 |
]. |
|
466 |
||
467 |
"Created: 27.2.1996 / 01:40:08 / cg" |
|
595 | 468 |
"Modified: 29.4.1996 / 09:40:49 / cg" |
415 | 469 |
! |
470 |
||
0 | 471 |
initialFont:aFont |
128 | 472 |
"set the font to be selected initially" |
0 | 473 |
|
2849 | 474 |
|encoding| |
475 |
||
128 | 476 |
selectedFont := aFont. |
2849 | 477 |
encoding := aFont encoding. |
3841 | 478 |
sizeUnit := aFont sizeUnit. |
479 |
||
2849 | 480 |
"/ self halt. |
481 |
encodingFilter contents:encoding. |
|
482 |
self encodingFilterSelected:encoding. |
|
382 | 483 |
self showSelectedFont. |
484 |
||
485 |
"Modified: 23.2.1996 / 00:51:32 / cg" |
|
101 | 486 |
! ! |
487 |
||
77 | 488 |
!FontPanel methodsFor:'initialization'! |
489 |
||
3740 | 490 |
enabled:aBoolean |
491 |
familyList enabled:aBoolean. |
|
492 |
faceList enabled:aBoolean. |
|
493 |
sizeList enabled:aBoolean. |
|
3817 | 494 |
encodingFilter notNil ifTrue:[ |
495 |
encodingFilter enabled:aBoolean. |
|
496 |
] |
|
3740 | 497 |
! |
498 |
||
77 | 499 |
initialize |
382 | 500 |
|familyLabel faceLabel sizeLabel panel fontBrowserView v1 v2 v3 |
3841 | 501 |
mm fH eH l box1 box2 showFontNameLabel sep| |
77 | 502 |
|
503 |
super initialize. |
|
504 |
||
4094 | 505 |
showFontNameLabel := device platformName ~= #WIN32. |
3837 | 506 |
sizeUnit := #pt. |
2847 | 507 |
|
382 | 508 |
mm := ViewSpacing. |
509 |
||
1763 | 510 |
self addAbortAndOkButtons. |
77 | 511 |
|
390
1d54a9b41463
say Hello world in JIS font ;-)
Claus Gittinger <cg@exept.de>
parents:
382
diff
changeset
|
512 |
panel := View origin:0.0@0.0 corner:1.0@1.0 in:self. |
3607
242d08639bcc
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3604
diff
changeset
|
513 |
panel bottomInset:(buttonPanel preferredHeight |
2847 | 514 |
+ (mm*3) |
515 |
+ (showFontNameLabel ifTrue:24 ifFalse:0) ). |
|
77 | 516 |
|
150 | 517 |
label := resources string:'Font dialog'. |
77 | 518 |
|
3832 | 519 |
box1 := HorizontalPanelView in:panel. |
520 |
"/ box horizontalLayout:#leftFit. |
|
521 |
box1 horizontalLayout:#left. |
|
522 |
box1 origin:0.0@1.0 corner:0.8@1.0. |
|
2842 | 523 |
|
3832 | 524 |
box2 := HorizontalPanelView in:panel. |
525 |
"/ box horizontalLayout:#leftFit. |
|
526 |
box2 horizontalLayout:#right. |
|
527 |
box2 origin:0.8@1.0 corner:1.0@1.0. |
|
528 |
||
529 |
l := Label label:(resources string:'Encoding:') in:box1. |
|
2842 | 530 |
l borderWidth:0. |
531 |
l adjust:#left. |
|
532 |
||
3817 | 533 |
eH := 0. |
534 |
||
3832 | 535 |
encodingFilter := ComboBoxView in:box1. |
2942 | 536 |
"/ encodingFilter font:l font. |
2826 | 537 |
encodingFilter level:-1. |
538 |
encodingFilter contents:'*'. |
|
2842 | 539 |
encodingFilter list:(self listOfEncodingsInFilterCombo). |
2826 | 540 |
encodingFilter action:[:pattern | self encodingFilterSelected:pattern]. |
541 |
encodingFilter immediateAccept:true. |
|
2942 | 542 |
"/ encodingFilter editor font:l font. |
2842 | 543 |
|
3817 | 544 |
self showEncodingFilter ifTrue:[ |
545 |
eH := encodingFilter preferredHeight. |
|
3832 | 546 |
box1 topInset:(eH negated-4); horizontalInset:mm. |
3817 | 547 |
] ifFalse:[ |
548 |
encodingFilter beInvisible |
|
549 |
]. |
|
2842 | 550 |
|
2826 | 551 |
"/ encodingFilter acceptOnReturn:true. |
552 |
"/ encodingFilter acceptOnTab:true. |
|
553 |
"/ encodingFilter acceptOnLeave:true. |
|
554 |
"/ encodingFilter acceptOnLostFocus:true. |
|
555 |
"/ encodingFilter acceptOnPointerLeave:true. |
|
556 |
||
3832 | 557 |
encodingLabel := Label label:' ' in:box1. |
2842 | 558 |
"/ eH := encodingLabel preferredExtent y. |
3832 | 559 |
"/ encodingLabel origin:0.6@1.0 corner:1.0@1.0. |
560 |
"/ encodingLabel topInset:(eH negated); horizontalInset:mm. |
|
2842 | 561 |
encodingLabel level:0; adjust:#left. |
562 |
encodingLabel adjust:#right. |
|
3817 | 563 |
self showEncodingFilter ifFalse:[ |
564 |
encodingLabel beInvisible |
|
565 |
]. |
|
382 | 566 |
|
3832 | 567 |
sep := View in:box1. |
568 |
sep width:20 height:10. |
|
569 |
||
570 |
pixelPointSwitch := ComboListView in:box2. |
|
571 |
"/ encodingFilter font:l font. |
|
572 |
pixelPointSwitch level:-1. |
|
3841 | 573 |
pixelPointSwitch contents:'pt'. |
3837 | 574 |
pixelPointSwitch list:#(#pt #px). |
3832 | 575 |
pixelPointSwitch action:[:sizeUnit | self sizeUnitSelected:sizeUnit]. |
576 |
box2 topInset:(pixelPointSwitch preferredHeight negated-4); horizontalInset:mm. |
|
577 |
"/ encodingFilter editor font:l font. |
|
578 |
||
579 |
self showEncodingFilter ifTrue:[ |
|
580 |
eH := encodingFilter preferredHeight. |
|
581 |
box1 topInset:(eH negated-4); horizontalInset:mm. |
|
582 |
] ifFalse:[ |
|
583 |
encodingFilter beInvisible |
|
584 |
]. |
|
585 |
||
2847 | 586 |
showFontNameLabel ifTrue:[ |
587 |
nameLabel := Label label:'' in:self. |
|
588 |
nameLabel origin:0.0@1.0 corner:1.0@1.0. |
|
3607
242d08639bcc
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3604
diff
changeset
|
589 |
nameLabel bottomInset:(buttonPanel preferredHeight + (mm*2)). |
242d08639bcc
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3604
diff
changeset
|
590 |
nameLabel topInset:(buttonPanel preferredHeight + (mm*2) + 24) negated; horizontalInset:mm. |
2847 | 591 |
nameLabel level:0; adjust:#left. |
592 |
nameLabel font:(FontDescription family:'helvetica' face:'medium' style:'roman' size:9). |
|
593 |
]. |
|
382 | 594 |
|
2842 | 595 |
previewField := HVScrollableView for:TextView in:panel. |
596 |
previewField origin:0.0@0.0 corner:1.0@0.4. |
|
597 |
previewField autoHideScrollBars:true. |
|
598 |
previewField := previewField scrolledView. |
|
382 | 599 |
previewField inset:mm. |
77 | 600 |
|
601 |
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
|
602 |
previewField level:-1. |
77 | 603 |
] ifFalse:[ |
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
604 |
previewField borderWidth:1. |
77 | 605 |
]. |
606 |
||
390
1d54a9b41463
say Hello world in JIS font ;-)
Claus Gittinger <cg@exept.de>
parents:
382
diff
changeset
|
607 |
fontBrowserView := View origin:0.0@0.4 corner:1.0@1.0 in:panel. |
382 | 608 |
fontBrowserView bottomInset:(eH + mm). |
77 | 609 |
|
610 |
v1 := View origin:0.0@0.0 corner:0.4@1.0 in:fontBrowserView. |
|
611 |
||
2842 | 612 |
familyLabel := Label label:(resources string:'Family') in:v1. |
77 | 613 |
familyLabel borderWidth:0. |
614 |
familyLabel origin:(0.0 @ 0.0) extent:(1.0 @ nil). |
|
3607
242d08639bcc
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3604
diff
changeset
|
615 |
fH := familyLabel preferredHeight. |
77 | 616 |
|
617 |
familyList := ScrollableView for:SelectionInListView in:v1. |
|
382 | 618 |
familyList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
619 |
familyList inset:mm. |
|
620 |
familyList topInset:fH. |
|
621 |
||
128 | 622 |
familyList := familyList scrolledView. |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
623 |
self makeTabable:familyList. |
77 | 624 |
|
625 |
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
|
626 |
in:fontBrowserView. |
77 | 627 |
|
2842 | 628 |
faceLabel := Label label:(resources string:'Typeface') in:v2. |
77 | 629 |
faceLabel borderWidth:0. |
630 |
faceLabel origin:(0.0 @ 0.0) extent:(1.0 @ nil). |
|
631 |
||
632 |
faceList := ScrollableView for:SelectionInListView in:v2. |
|
382 | 633 |
faceList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
634 |
faceList inset:mm. |
|
635 |
faceList topInset:fH. |
|
128 | 636 |
faceList := faceList scrolledView. |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
637 |
self makeTabable:faceList. |
77 | 638 |
|
2842 | 639 |
v3 := View origin:0.8@0.0 corner:1.0@1.0 in:fontBrowserView. |
77 | 640 |
|
3832 | 641 |
sizeLabelHolder := (resources string:'Size') asValue. |
642 |
sizeLabel := Label in:v3. |
|
643 |
sizeLabel labelChannel:sizeLabelHolder. |
|
77 | 644 |
sizeLabel borderWidth:0. |
645 |
sizeLabel origin:(0.0 @ 0.0)extent:(1.0 @ nil). |
|
646 |
||
647 |
sizeList := ScrollableView for:SelectionInListView in:v3. |
|
382 | 648 |
sizeList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
649 |
sizeList inset:mm. |
|
650 |
sizeList topInset:fH. |
|
128 | 651 |
sizeList := sizeList scrolledView. |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
652 |
self makeTabable:sizeList. |
77 | 653 |
|
654 |
familyList action:[:lineNr | self familySelected:(familyList selectionValue)]. |
|
655 |
faceList action:[:lineNr | self faceSelected:(faceList selectionValue)]. |
|
656 |
sizeList action:[:lineNr | self sizeSelected:(sizeList selectionValue)]. |
|
657 |
||
2852 | 658 |
previewField menuHolder:self previewMenu. |
659 |
||
77 | 660 |
" |
661 |
FontPanel new showAtPointer |
|
662 |
" |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
663 |
|
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
664 |
"Modified: 31.5.1996 / 22:01:45 / cg" |
77 | 665 |
! |
666 |
||
2842 | 667 |
listOfEncodingsInFilterCombo |
2878 | 668 |
|availableEncodings listPresentedToUser| |
2842 | 669 |
|
2878 | 670 |
listOfEncodings := OrderedCollection new. |
4094 | 671 |
device platformName = #WIN32 ifTrue:[ |
2878 | 672 |
listOfEncodings |
2849 | 673 |
addAll: |
674 |
#( |
|
675 |
'*' |
|
676 |
nil |
|
677 |
). |
|
678 |
] ifFalse:[ |
|
2878 | 679 |
listOfEncodings |
2849 | 680 |
addAll: |
681 |
#( |
|
682 |
'*' |
|
683 |
'iso8859*' |
|
684 |
'iso10646-1' |
|
685 |
'jis*' |
|
686 |
nil |
|
687 |
). |
|
688 |
]. |
|
2842 | 689 |
|
690 |
availableEncodings := Set new. |
|
2845 | 691 |
device listOfAvailableFonts do:[:f | availableEncodings add:(f encoding ? '?')]. |
2842 | 692 |
availableEncodings := availableEncodings asSortedCollection. |
2878 | 693 |
listOfEncodings addAll:availableEncodings. |
694 |
||
695 |
listPresentedToUser := listOfEncodings collect:[:enc | |
|
696 |
|encoder userFriendlyName| |
|
697 |
||
2938 | 698 |
"/ |
699 |
"/ disabled to avoid autoloading of encoders. |
|
700 |
"/ (enc notNil and:[enc ~= '*']) ifTrue:[ |
|
701 |
"/ encoder := CharacterEncoder encoderFor:enc ifAbsent:nil. |
|
702 |
"/ encoder notNil ifTrue:[ |
|
703 |
"/ userFriendlyName := encoder userFriendlyNameOfEncoding. |
|
704 |
"/ ]. |
|
705 |
"/ ]. |
|
2937 | 706 |
(userFriendlyName notNil and:[(userFriendlyName sameAs: enc) not]) ifTrue:[ |
2878 | 707 |
enc , ' (' , userFriendlyName , ')' |
708 |
] ifFalse:[ |
|
709 |
enc |
|
710 |
] |
|
711 |
]. |
|
712 |
^ listPresentedToUser. |
|
2842 | 713 |
! |
714 |
||
1277 | 715 |
postRealize |
197 | 716 |
"kludge for sco - xlsfont fails sometimes - try again here" |
717 |
||
415 | 718 |
self updateFamilyList. |
1277 | 719 |
super postRealize |
415 | 720 |
|
721 |
"Modified: 27.2.1996 / 01:40:47 / cg" |
|
1277 | 722 |
"Created: 24.7.1997 / 18:12:42 / cg" |
2852 | 723 |
! |
724 |
||
725 |
previewMenu |
|
726 |
<resource: #programMenu > |
|
727 |
||
728 |
|menu| |
|
729 |
||
3475 | 730 |
menu := Menu decodeFromLiteralArray:(self class previewMenu). |
2852 | 731 |
menu findGuiResourcesIn:self. |
3405
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
732 |
^ menu |
2875 | 733 |
|
3475 | 734 |
"Modified: / 27-03-2007 / 11:15:53 / cg" |
3817 | 735 |
! |
736 |
||
737 |
showEncodingFilter |
|
738 |
^ true |
|
77 | 739 |
! ! |
740 |
||
0 | 741 |
!FontPanel methodsFor:'private'! |
742 |
||
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
743 |
clearPreview |
595 | 744 |
"clear the preview subview" |
745 |
||
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
746 |
shown ifTrue:[ |
1297
f5ea02391a59
use #contents: instead of #clear
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
747 |
previewField contents:nil. |
3817 | 748 |
encodingLabel notNil ifTrue:[ |
749 |
encodingLabel label:''. |
|
750 |
]. |
|
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
751 |
]. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
752 |
|
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
753 |
"Created: 17.4.1996 / 15:19:16 / cg" |
1297
f5ea02391a59
use #contents: instead of #clear
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
754 |
"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
|
755 |
! |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
756 |
|
197 | 757 |
extractFaceAndStyleFrom:aString |
595 | 758 |
"given a string, extract currentFace and currentStyle" |
759 |
||
197 | 760 |
|index| |
761 |
||
762 |
index := aString indexOf:$-. |
|
763 |
(index ~~ 0) ifTrue:[ |
|
595 | 764 |
currentFaceAndStyle := aString. |
765 |
currentFace := aString copyTo:(index - 1). |
|
766 |
currentStyle := aString copyFrom:(index + 1) |
|
197 | 767 |
] |
768 |
||
595 | 769 |
"Modified: 29.4.1996 / 09:41:47 / cg" |
197 | 770 |
! |
771 |
||
3817 | 772 |
fontForPreview |
773 |
"get the preview font" |
|
774 |
||
3837 | 775 |
|font allFonts fonts| |
3817 | 776 |
|
3853 | 777 |
currentSize isNil ifTrue:[ |
778 |
^ nil. |
|
779 |
]. |
|
3841 | 780 |
|
3817 | 781 |
allFonts := device |
3837 | 782 |
fontsInFamily:(currentFamily ? '*') |
783 |
face:(currentFace ? '*') |
|
784 |
style:(currentStyle ? '*') |
|
785 |
filtering:filter. |
|
3817 | 786 |
|
3837 | 787 |
sizeUnit == #px ifTrue:[ |
3834 | 788 |
fonts := allFonts select:[:f | f pixelSize = currentSize]. |
789 |
] ifFalse:[ |
|
790 |
fonts := allFonts select:[:f | f size = currentSize]. |
|
791 |
]. |
|
3817 | 792 |
fonts notEmpty ifTrue:[ |
793 |
font := fonts anElement. |
|
794 |
] ifFalse:[ |
|
795 |
"/ mhmh: |
|
796 |
"/ size=0 is returned for scalable fonts. |
|
797 |
"/ Any size is possible. |
|
798 |
"/ |
|
799 |
fonts := allFonts select:[:f | f size = 0]. |
|
800 |
fonts notEmpty ifTrue:[ |
|
801 |
font := Font family:currentFamily |
|
802 |
face:currentFace |
|
803 |
style:currentStyle |
|
3837 | 804 |
size:currentSize |
805 |
sizeUnit:sizeUnit |
|
3817 | 806 |
encoding:(fonts anElement encoding). |
807 |
] |
|
808 |
]. |
|
809 |
^ font |
|
810 |
! |
|
811 |
||
812 |
getFacesForFamily:aFamilyName filtering:filter |
|
813 |
"the list of font faces for a given family" |
|
814 |
||
815 |
^ device facesInFamily:aFamilyName filtering:filter |
|
816 |
! |
|
817 |
||
818 |
getFamilyList |
|
819 |
"the list of font families" |
|
820 |
||
821 |
^ device fontFamiliesFiltering:filter. |
|
822 |
! |
|
823 |
||
824 |
getSizesInFamily:aFamilyName face:face style:style filtering:filter |
|
3837 | 825 |
sizeUnit == #px ifTrue:[ |
3834 | 826 |
^ device |
827 |
pixelSizesInFamily:(currentFamily ? '*') |
|
828 |
face:(currentFace ? '*') |
|
829 |
style:(currentStyle ? '*') |
|
830 |
filtering:filter. |
|
831 |
]. |
|
832 |
||
3817 | 833 |
^ device |
834 |
sizesInFamily:(currentFamily ? '*') |
|
835 |
face:(currentFace ? '*') |
|
836 |
style:(currentStyle ? '*') |
|
837 |
filtering:filter. |
|
838 |
! |
|
839 |
||
840 |
getStylesInFamily:aFamilyName face:aFace filtering:filter |
|
841 |
"the list of font styles for a given family-face" |
|
842 |
||
843 |
^ device stylesInFamily:aFamilyName face:aFace filtering:filter. |
|
844 |
! |
|
845 |
||
197 | 846 |
showPreview |
595 | 847 |
"show the preview text" |
848 |
||
3817 | 849 |
|font deviceFont enc fontName| |
382 | 850 |
|
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
851 |
self clearPreview. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
852 |
|
197 | 853 |
" |
854 |
show a wait cursor: for some fonts (kanji etc) the |
|
2890 | 855 |
X-server needs quite some time to load the font |
197 | 856 |
" |
255 | 857 |
self withWaitCursorDo:[ |
3817 | 858 |
font := self fontForPreview. |
2843 | 859 |
font notNil ifTrue:[ |
2890 | 860 |
deviceFont := font onDevice:device. |
861 |
enc := deviceFont encoding. |
|
2916 | 862 |
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
|
863 |
|
2874 | 864 |
previewField font:deviceFont. |
865 |
previewField characterEncoding:enc. |
|
866 |
||
2287
b33ad40d7538
preview fixed when font is bad
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
867 |
encodingLabel label:enc. |
2843 | 868 |
currentEncoding := enc. |
869 |
fontName := deviceFont fullName. |
|
2899 | 870 |
previewField contents:(self class defaultSampleStringForEncoding:enc). |
382 | 871 |
] ifFalse:[ |
2842 | 872 |
previewField contents:nil. |
873 |
encodingLabel label:nil. |
|
2843 | 874 |
currentEncoding := nil. |
2842 | 875 |
fontName := nil. |
382 | 876 |
]. |
2842 | 877 |
nameLabel notNil ifTrue:[nameLabel label:fontName]. |
197 | 878 |
] |
255 | 879 |
|
1257 | 880 |
"Modified: 30.6.1997 / 17:26:22 / cg" |
197 | 881 |
! |
882 |
||
128 | 883 |
showSelectedFont |
2843 | 884 |
|fam face faceAndStyle style sz| |
128 | 885 |
|
886 |
fam := selectedFont family. |
|
2843 | 887 |
currentEncoding := selectedFont encoding. |
888 |
||
2888 | 889 |
self familySelected:fam showPreview:false. |
128 | 890 |
fam notNil ifTrue:[ |
2842 | 891 |
face := selectedFont face. |
892 |
(face notNil and:[(style := selectedFont style) notNil]) ifTrue:[ |
|
893 |
faceAndStyle := face , '-' , style. |
|
894 |
]. |
|
2888 | 895 |
self faceSelected:faceAndStyle showPreview:false. |
2842 | 896 |
faceAndStyle notNil ifTrue:[ |
3841 | 897 |
sz := sizeUnit == #px ifTrue:[selectedFont pixelSize] ifFalse:[selectedFont size]. |
898 |
pixelPointSwitch contents:sizeUnit. |
|
2888 | 899 |
self sizeSelected:sz showPreview:false. |
2842 | 900 |
] |
901 |
]. |
|
2888 | 902 |
|
903 |
self showPreview |
|
2826 | 904 |
! |
905 |
||
906 |
updateFamilyList |
|
907 |
"update the list of font families" |
|
908 |
||
909 |
|families| |
|
910 |
||
911 |
familyList list isNil ifTrue:[ |
|
3817 | 912 |
families := self getFamilyList. |
2826 | 913 |
families notNil ifTrue:[ |
914 |
families := families asOrderedCollection sort |
|
915 |
]. |
|
916 |
familyList list:families |
|
917 |
]. |
|
918 |
selectedFont notNil ifTrue:[ |
|
919 |
self showSelectedFont |
|
920 |
]. |
|
921 |
||
922 |
"Modified: 27.2.1996 / 01:39:42 / cg" |
|
923 |
"Created: 27.2.1996 / 01:40:37 / cg" |
|
197 | 924 |
! ! |
128 | 925 |
|
197 | 926 |
!FontPanel methodsFor:'queries'! |
0 | 927 |
|
3405
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
928 |
characterSetViewClassAvailable |
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
929 |
^ CharacterSetView notNil |
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
930 |
|
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
931 |
"Created: / 11-10-2006 / 21:27:51 / cg" |
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
932 |
! |
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
933 |
|
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
934 |
characterSetViewClassAvailableOrOSIsUNIX |
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
935 |
^ self characterSetViewClassAvailable or:[self osIsUNIX] |
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
936 |
|
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
937 |
"Created: / 11-10-2006 / 21:29:20 / cg" |
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
938 |
! |
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
939 |
|
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
940 |
osIsUNIX |
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
941 |
^ OperatingSystem isUNIXlike |
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
942 |
|
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
943 |
"Modified: / 11-10-2006 / 21:28:59 / cg" |
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
944 |
! |
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
945 |
|
197 | 946 |
preferredExtent |
595 | 947 |
"return the boxes preferredExtent" |
572 | 948 |
|
3769
758f8b0b6cf2
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3740
diff
changeset
|
949 |
"/ If I have an explicit preferredExtent.. |
758f8b0b6cf2
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3740
diff
changeset
|
950 |
explicitExtent notNil ifTrue:[ |
758f8b0b6cf2
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3740
diff
changeset
|
951 |
^ explicitExtent |
758f8b0b6cf2
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3740
diff
changeset
|
952 |
]. |
797 | 953 |
|
3769
758f8b0b6cf2
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3740
diff
changeset
|
954 |
"/ If I have a cached preferredExtent value.. |
713
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
955 |
preferredExtent notNil ifTrue:[ |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
956 |
^ preferredExtent |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
957 |
]. |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
958 |
|
2842 | 959 |
^ 450@350 |
572 | 960 |
|
797 | 961 |
"Modified: 19.7.1996 / 20:44:08 / cg" |
0 | 962 |
! ! |
77 | 963 |
|
964 |
!FontPanel methodsFor:'user interaction'! |
|
965 |
||
3604 | 966 |
copyFontName |
967 |
self setClipboardText:(previewField font storeString). |
|
968 |
! |
|
969 |
||
2826 | 970 |
encodingFilterSelected:anEncodingPattern |
971 |
"another encoding was selected; find available fonts and update lists" |
|
972 |
||
973 |
|pattern| |
|
974 |
||
2887 | 975 |
anEncodingPattern isNil ifTrue:[ |
976 |
self filter:nil. |
|
977 |
^ self. |
|
978 |
]. |
|
979 |
||
2878 | 980 |
pattern := (anEncodingPattern upTo:$( ) withoutSeparators. |
981 |
||
982 |
pattern = '?' ifTrue:[ |
|
2845 | 983 |
pattern := '' |
984 |
] ifFalse:[ |
|
2878 | 985 |
pattern := (pattern isEmptyOrNil ifTrue:'*' ifFalse:pattern). |
2845 | 986 |
]. |
2826 | 987 |
self |
988 |
filter: |
|
989 |
[:f | |
|
3899
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
990 |
|doesMatch encoding| |
2826 | 991 |
|
3899
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
992 |
"/ k&d hack for mswindows names... |
3848 | 993 |
"/ Transcript showCR:f encoding. |
3899
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
994 |
encoding := f encoding ? ''. |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
995 |
doesMatch := (pattern match:encoding). |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
996 |
doesMatch ifFalse:[ |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
997 |
encoding = 'ms-ansi' ifTrue:[ |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
998 |
doesMatch := (pattern = 'iso8859-1') |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
999 |
or:[ (pattern = 'iso10646-1') |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1000 |
or:[ (pattern = 'unicode') ]] |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1001 |
]. |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1002 |
(encoding = 'iso8859-1' |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1003 |
or:[encoding = 'iso10646-1' |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1004 |
or:[encoding = 'unicode']]) ifTrue:[ |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1005 |
doesMatch := (pattern = 'ms-ansi') |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1006 |
]. |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1007 |
]. |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1008 |
doesMatch |
2826 | 1009 |
]. |
1010 |
! |
|
1011 |
||
197 | 1012 |
faceSelected:aFaceAndStyleName |
2826 | 1013 |
"a fonts face was selected; find available sizes and update lists" |
595 | 1014 |
|
2842 | 1015 |
self faceSelected:aFaceAndStyleName showPreview:true |
1016 |
! |
|
1017 |
||
1018 |
faceSelected:aFaceAndStyleName showPreview:showPreview |
|
1019 |
"a fonts face was selected; find available sizes and update lists" |
|
1020 |
||
3740 | 1021 |
|sizes sizeStrings didShow| |
197 | 1022 |
|
1023 |
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
|
1024 |
self extractFaceAndStyleFrom:aFaceAndStyleName. |
197 | 1025 |
]. |
3834 | 1026 |
self updateSizeList. |
1027 |
showPreview ifTrue:[ |
|
1028 |
self showPreview. |
|
1029 |
]. |
|
1030 |
^ self. |
|
1031 |
||
3817 | 1032 |
sizes := self |
1033 |
getSizesInFamily:(currentFamily ? '*') |
|
1034 |
face:(currentFace ? '*') |
|
1035 |
style:(currentStyle ? '*') |
|
1036 |
filtering:filter. |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
1037 |
|
3238
7b868226a0c0
isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents:
3187
diff
changeset
|
1038 |
(sizes isEmptyOrNil) ifTrue:[ |
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
1039 |
sizeList list:nil. |
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
1040 |
currentSize := nil. |
3841 | 1041 |
self halt. |
2842 | 1042 |
showPreview ifTrue:[ |
1043 |
self showPreview. |
|
1044 |
]. |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
1045 |
^ self |
197 | 1046 |
]. |
1047 |
||
2890 | 1048 |
didShow := false. |
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
1049 |
|
3740 | 1050 |
sizes := sizes asOrderedCollection. |
1051 |
selectedFont notNil ifTrue:[ |
|
1052 |
(sizes includes:selectedFont size) ifFalse:[ |
|
1053 |
sizes add:selectedFont size |
|
1054 |
]. |
|
1055 |
]. |
|
1056 |
sizes sort. |
|
1057 |
||
1058 |
sizeStrings := sizes collect:[:entry | entry printString]. |
|
1059 |
sizeList list:sizeStrings. |
|
197 | 1060 |
currentSize notNil ifTrue:[ |
3740 | 1061 |
(sizeStrings includes:(currentSize printString)) ifTrue:[ |
2170 | 1062 |
sizeList setSelectElement:currentSize printString. |
2842 | 1063 |
showPreview ifTrue:[ |
2890 | 1064 |
self showPreview. |
1065 |
didShow := true. |
|
2842 | 1066 |
] |
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
1067 |
] |
2890 | 1068 |
]. |
1069 |
didShow ifFalse:[ |
|
1070 |
self clearPreview |
|
1071 |
]. |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
1072 |
|
1257 | 1073 |
"Modified: 30.6.1997 / 17:25:46 / cg" |
197 | 1074 |
! |
1075 |
||
77 | 1076 |
familySelected:aFamilyName |
2826 | 1077 |
"a fonts family was selected; find available faces and update lists" |
595 | 1078 |
|
2842 | 1079 |
self familySelected:aFamilyName showPreview:true |
1080 |
! |
|
1081 |
||
1082 |
familySelected:aFamilyName showPreview:showPreview |
|
1083 |
"a fonts family was selected; find available faces and update lists" |
|
1084 |
||
77 | 1085 |
|faces styles list| |
1086 |
||
690 | 1087 |
familyList setSelectElement:aFamilyName. |
77 | 1088 |
|
1089 |
currentFamily := aFamilyName. |
|
3817 | 1090 |
faces := self getFacesForFamily:aFamilyName filtering:filter. |
3899
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1091 |
faces isEmptyOrNil ifTrue:[ |
415 | 1092 |
currentFace := currentStyle := currentFaceAndStyle := nil. |
1093 |
faceList list:nil. |
|
2842 | 1094 |
self faceSelected:nil showPreview:showPreview. |
415 | 1095 |
^ self. |
77 | 1096 |
]. |
1097 |
||
2353 | 1098 |
list := SortedCollection new. |
77 | 1099 |
faces do:[:aFace | |
3899
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1100 |
styles := (self getStylesInFamily:aFamilyName face:aFace filtering:filter) ? #(). |
415 | 1101 |
styles do:[:aStyle | |
1102 |
list add:(aFace , '-' , aStyle) |
|
1103 |
] |
|
77 | 1104 |
]. |
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
1105 |
|
77 | 1106 |
faceList list:list. |
1107 |
currentFaceAndStyle notNil ifTrue:[ |
|
415 | 1108 |
(list includes:currentFaceAndStyle) ifTrue:[ |
690 | 1109 |
faceList setSelectElement:currentFaceAndStyle. |
2842 | 1110 |
self faceSelected:currentFaceAndStyle showPreview:showPreview. |
415 | 1111 |
^ self |
1112 |
] |
|
77 | 1113 |
]. |
2842 | 1114 |
|
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
1115 |
sizeList list:nil. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
1116 |
self clearPreview. |
415 | 1117 |
|
690 | 1118 |
"Modified: 26.5.1996 / 15:04:29 / cg" |
77 | 1119 |
! |
1120 |
||
1121 |
okPressed |
|
595 | 1122 |
"ok was pressed; hide myself and evaluate the okAction, passing |
1123 |
family, face, style and size as arguments" |
|
1124 |
||
77 | 1125 |
self hide. |
1126 |
okAction notNil ifTrue:[ |
|
410 | 1127 |
currentFamily notNil ifTrue:[ |
2842 | 1128 |
okAction |
1129 |
value:(FontDescription |
|
1130 |
family:currentFamily |
|
1131 |
face:currentFace |
|
1132 |
style:currentStyle |
|
1133 |
size:currentSize |
|
3841 | 1134 |
sizeUnit:(sizeUnit ? #pt) |
2843 | 1135 |
encoding:(currentEncoding ? encoding)). |
410 | 1136 |
] |
77 | 1137 |
] |
410 | 1138 |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
1139 |
"Modified: 10.4.1997 / 09:51:31 / cg" |
77 | 1140 |
! |
1141 |
||
2852 | 1142 |
previewCopySelection |
1143 |
previewField copySelection. |
|
1144 |
! |
|
1145 |
||
2935 | 1146 |
previewInspectFont |
1147 |
previewField font inspect. |
|
1148 |
! |
|
1149 |
||
2852 | 1150 |
previewShowCharacterSet |
1151 |
CharacterSetView openOn:(previewField font) |
|
1152 |
! |
|
1153 |
||
2875 | 1154 |
previewShowCharacterSetUsingXFD |
2878 | 1155 |
[ |
1156 |
OperatingSystem executeCommand:'xfd -fn ' , previewField font fullName. |
|
1157 |
] fork. |
|
2875 | 1158 |
! |
1159 |
||
77 | 1160 |
sizeSelected:aNumberOrString |
2826 | 1161 |
"a size was selected; update preview" |
595 | 1162 |
|
2842 | 1163 |
self sizeSelected:aNumberOrString showPreview:true. |
1164 |
! |
|
1165 |
||
1166 |
sizeSelected:aNumberOrString showPreview:showPreview |
|
1167 |
"a size was selected; update preview" |
|
1168 |
||
77 | 1169 |
aNumberOrString isNumber ifTrue:[ |
595 | 1170 |
currentSize := aNumberOrString |
77 | 1171 |
] ifFalse:[ |
2826 | 1172 |
currentSize := Number readFromString:aNumberOrString onError:nil |
77 | 1173 |
]. |
2842 | 1174 |
showPreview ifTrue:[self showPreview] |
595 | 1175 |
|
1176 |
"Modified: 29.4.1996 / 09:43:23 / cg" |
|
3832 | 1177 |
! |
1178 |
||
1179 |
sizeUnitSelected:unitSymbol |
|
1180 |
sizeUnit := unitSymbol. |
|
1181 |
sizeLabelHolder value:(resources |
|
3837 | 1182 |
string:(sizeUnit == #px |
3832 | 1183 |
ifTrue:'Size (px)' |
1184 |
ifFalse:'Size')). |
|
3834 | 1185 |
|
1186 |
self showPreview |
|
1187 |
! |
|
1188 |
||
1189 |
updateSizeList |
|
1190 |
|sizes sizeStrings| |
|
1191 |
||
1192 |
sizes := self |
|
3841 | 1193 |
getSizesInFamily:(currentFamily ? '*') |
1194 |
face:(currentFace ? '*') |
|
1195 |
style:(currentStyle ? '*') |
|
1196 |
filtering:filter. |
|
3834 | 1197 |
|
1198 |
(sizes isEmptyOrNil) ifTrue:[ |
|
1199 |
sizeList list:nil. |
|
1200 |
currentSize := nil. |
|
3940
38addf9c9d42
changed: #updateSizeList - oops, a halt.
Claus Gittinger <cg@exept.de>
parents:
3899
diff
changeset
|
1201 |
"/ self halt. |
3834 | 1202 |
^ self |
1203 |
]. |
|
1204 |
||
1205 |
sizes := sizes asOrderedCollection. |
|
1206 |
selectedFont notNil ifTrue:[ |
|
3841 | 1207 |
currentSize := (selectedFont sizeUnit == #px) |
1208 |
ifTrue:[ selectedFont pixelSize ] |
|
1209 |
ifFalse:[ selectedFont size ]. |
|
1210 |
||
1211 |
(sizes includes:currentSize) ifFalse:[ |
|
1212 |
sizes add:currentSize |
|
3834 | 1213 |
]. |
1214 |
]. |
|
1215 |
sizes sort. |
|
1216 |
||
1217 |
sizeStrings := sizes collect:[:entry | entry printString]. |
|
1218 |
sizeList list:sizeStrings. |
|
1219 |
currentSize notNil ifTrue:[ |
|
1220 |
(sizeStrings includes:(currentSize printString)) ifTrue:[ |
|
1221 |
sizeList setSelectElement:currentSize printString. |
|
1222 |
] |
|
1223 |
]. |
|
77 | 1224 |
! ! |
197 | 1225 |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
1226 |
!FontPanel class methodsFor:'documentation'! |
243 | 1227 |
|
1228 |
version |
|
4147
150b7dff3b6a
comment/format in: #sampleStringWithAllLetters
Claus Gittinger <cg@exept.de>
parents:
4094
diff
changeset
|
1229 |
^ '$Header: /cvs/stx/stx/libwidg/FontPanel.st,v 1.105 2010-04-13 14:32:34 cg Exp $' |
4094 | 1230 |
! |
1231 |
||
1232 |
version_CVS |
|
4147
150b7dff3b6a
comment/format in: #sampleStringWithAllLetters
Claus Gittinger <cg@exept.de>
parents:
4094
diff
changeset
|
1233 |
^ '$Header: /cvs/stx/stx/libwidg/FontPanel.st,v 1.105 2010-04-13 14:32:34 cg Exp $' |
243 | 1234 |
! ! |