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