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