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