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