author | Claus Gittinger <cg@exept.de> |
Mon, 23 Jun 2014 15:02:55 +0200 | |
changeset 5073 | f175c1bfb3b0 |
parent 5008 | 2af062c3a407 |
child 5102 | 30b7e7cc2d99 |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1991 by Claus Gittinger |
59 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
2275 | 12 |
"{ Package: 'stx:libwidg' }" |
13 |
||
77 | 14 |
DialogBox subclass:#FontPanel |
2878 | 15 |
instanceVariableNames:'previewField listOfEncodings familyList faceList sizeList |
16 |
revertButton currentFamily currentFace currentStyle |
|
3832 | 17 |
currentFaceAndStyle currentSize sizeUnit currentEncoding |
18 |
selectedFont nameLabel encodingFilter encodingLabel filter |
|
4944 | 19 |
combinedFilter encoding sizeLabelHolder pixelPointSwitch |
20 |
xftFontsOnlyHolder' |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
21 |
classVariableNames:'' |
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
22 |
poolDictionaries:'' |
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
23 |
category:'Views-DialogBoxes' |
0 | 24 |
! |
25 |
||
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
26 |
!FontPanel class methodsFor:'documentation'! |
77 | 27 |
|
197 | 28 |
copyright |
29 |
" |
|
30 |
COPYRIGHT (c) 1991 by Claus Gittinger |
|
31 |
All Rights Reserved |
|
32 |
||
33 |
This software is furnished under a license and may be used |
|
34 |
only in accordance with the terms of that license and with the |
|
35 |
inclusion of the above copyright notice. This software may not |
|
36 |
be provided or otherwise made available to, or used by, any |
|
37 |
other person. No title to or ownership of the software is |
|
38 |
hereby transferred. |
|
39 |
" |
|
40 |
||
41 |
||
77 | 42 |
! |
43 |
||
44 |
documentation |
|
45 |
" |
|
46 |
this class implements a font chooser. |
|
47 |
||
2826 | 48 |
Notice: |
49 |
this is a very old dialog; |
|
50 |
it was written before the UI-framework was available and is completely |
|
51 |
setup manually (initialize method). |
|
52 |
Therefore, it desperately asks to be rewritten using the UIPainter... |
|
53 |
||
595 | 54 |
[author:] |
55 |
Claus Gittinger |
|
56 |
||
57 |
[see also:] |
|
58 |
Font FontDescription |
|
59 |
View Dialog |
|
60 |
" |
|
61 |
! |
|
62 |
||
63 |
examples |
|
64 |
" |
|
65 |
very simple: |
|
66 |
[exBegin] |
|
67 |
|font| |
|
68 |
||
69 |
font := FontPanel fontFromUser. |
|
655 | 70 |
Transcript showCR:font |
595 | 71 |
[exEnd] |
72 |
||
73 |
||
74 |
with initial font: |
|
75 |
[exBegin] |
|
76 |
|font| |
|
77 |
||
78 |
font := FontPanel |
|
79 |
fontFromUserInitial:(Font |
|
80 |
family:'courier' |
|
81 |
size:12). |
|
655 | 82 |
Transcript showCR:font |
595 | 83 |
[exEnd] |
84 |
||
85 |
||
86 |
with initial font & title: |
|
87 |
[exBegin] |
|
88 |
|font| |
|
89 |
||
90 |
font := FontPanel |
|
91 |
fontFromUserInitial:(Font |
|
92 |
family:'courier' |
|
93 |
size:12) |
|
94 |
title:'select a fooBar font'. |
|
655 | 95 |
Transcript showCR:font |
595 | 96 |
[exEnd] |
97 |
||
98 |
||
99 |
full setup; setting a filter to only present iso fonts |
|
100 |
and callBack action: |
|
101 |
[exBegin] |
|
0 | 102 |
|
585 | 103 |
|panel| |
77 | 104 |
|
585 | 105 |
panel := FontPanel new. |
595 | 106 |
panel label:'hi there - which iso font ?'. |
107 |
panel filter:[:fd | fd encoding notNil |
|
108 |
and:[fd encoding startsWith:'iso']]. |
|
109 |
panel action:[:family :face :style :size | |
|
655 | 110 |
Transcript showCR:'family:' , family. |
111 |
Transcript showCR:'face:' , face. |
|
112 |
Transcript showCR:'style:' , style. |
|
113 |
Transcript showCR:'size:' , size printString. |
|
595 | 114 |
]. |
115 |
panel open |
|
116 |
[exEnd] |
|
77 | 117 |
" |
118 |
! ! |
|
0 | 119 |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
120 |
!FontPanel class methodsFor:'defaults'! |
0 | 121 |
|
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
122 |
defaultAsciiSampleString |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
123 |
^ (self sampleStringWithAllLetters) , ' |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
124 |
|
4944 | 125 |
ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz |
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
126 |
1234567890 !!@#$%^&*(){}[]:"~;,./<>? |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
127 |
' |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
128 |
! |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
129 |
|
197 | 130 |
defaultExtent |
571 | 131 |
"return the default extent of my instances. |
132 |
The value returned here is usually ignored, and |
|
133 |
the value from preferredExtent taken instead." |
|
134 |
||
4944 | 135 |
^ (Screen current pixelPerMillimeter * (200 @ 150)) rounded |
571 | 136 |
|
137 |
"Modified: 22.4.1996 / 23:36:19 / cg" |
|
197 | 138 |
! |
139 |
||
2860 | 140 |
defaultJIS0201SampleString |
141 |
"return the sample jis preview text" |
|
142 |
||
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
143 |
^ (self defaultLatin1SampleString). |
2860 | 144 |
! |
145 |
||
382 | 146 |
defaultJISSampleString |
595 | 147 |
"return the sample jis preview text" |
148 |
||
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
149 |
^ |
2888 | 150 |
'The quick brown fox |
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
151 |
jumps over the lazy dog. |
2860 | 152 |
|
2939 | 153 |
' , #(16r65E5 16r672C 16r8A9E) asUnicodeString |
382 | 154 |
! |
155 |
||
2847 | 156 |
defaultLatin1SampleString |
157 |
"return the sample latin1 preview text" |
|
158 |
||
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 |
|
2849 | 484 |
|encoding| |
485 |
||
128 | 486 |
selectedFont := aFont. |
5008 | 487 |
currentFamily := aFont family. |
488 |
currentFace := aFont face. |
|
489 |
currentStyle := aFont style. |
|
490 |
currentSize := aFont size. |
|
491 |
currentFaceAndStyle := currentFace,'-',currentStyle. |
|
492 |
||
4983 | 493 |
self xftFontsOnlyHolder value:(aFont isXftFont). |
2849 | 494 |
encoding := aFont encoding. |
3841 | 495 |
sizeUnit := aFont sizeUnit. |
496 |
||
2849 | 497 |
"/ self halt. |
498 |
encodingFilter contents:encoding. |
|
499 |
self encodingFilterSelected:encoding. |
|
382 | 500 |
self showSelectedFont. |
501 |
||
502 |
"Modified: 23.2.1996 / 00:51:32 / cg" |
|
4983 | 503 |
! |
504 |
||
505 |
xftFontsOnlyHolder |
|
506 |
xftFontsOnlyHolder isNil ifTrue:[ |
|
507 |
xftFontsOnlyHolder := true asValue |
|
508 |
]. |
|
509 |
^ xftFontsOnlyHolder |
|
101 | 510 |
! ! |
511 |
||
77 | 512 |
!FontPanel methodsFor:'initialization'! |
513 |
||
3740 | 514 |
enabled:aBoolean |
515 |
familyList enabled:aBoolean. |
|
516 |
faceList enabled:aBoolean. |
|
517 |
sizeList enabled:aBoolean. |
|
3817 | 518 |
encodingFilter notNil ifTrue:[ |
519 |
encodingFilter enabled:aBoolean. |
|
520 |
] |
|
3740 | 521 |
! |
522 |
||
77 | 523 |
initialize |
382 | 524 |
|familyLabel faceLabel sizeLabel panel fontBrowserView v1 v2 v3 |
5007 | 525 |
mm fH eH l box1 box2 showFontNameLabel xftCheckBox vPanel| |
77 | 526 |
|
527 |
super initialize. |
|
528 |
||
4982 | 529 |
showFontNameLabel := self graphicsDevice isWindowsPlatform not. |
3837 | 530 |
sizeUnit := #pt. |
2847 | 531 |
|
382 | 532 |
mm := ViewSpacing. |
533 |
||
1763 | 534 |
self addAbortAndOkButtons. |
77 | 535 |
|
390
1d54a9b41463
say Hello world in JIS font ;-)
Claus Gittinger <cg@exept.de>
parents:
382
diff
changeset
|
536 |
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
|
537 |
panel bottomInset:(buttonPanel preferredHeight |
2847 | 538 |
+ (mm*3) |
539 |
+ (showFontNameLabel ifTrue:24 ifFalse:0) ). |
|
77 | 540 |
|
150 | 541 |
label := resources string:'Font dialog'. |
77 | 542 |
|
3832 | 543 |
box1 := HorizontalPanelView in:panel. |
544 |
"/ box horizontalLayout:#leftFit. |
|
545 |
box1 horizontalLayout:#left. |
|
546 |
box1 origin:0.0@1.0 corner:0.8@1.0. |
|
2842 | 547 |
|
3832 | 548 |
box2 := HorizontalPanelView in:panel. |
549 |
"/ box horizontalLayout:#leftFit. |
|
550 |
box2 horizontalLayout:#right. |
|
551 |
box2 origin:0.8@1.0 corner:1.0@1.0. |
|
552 |
||
553 |
l := Label label:(resources string:'Encoding:') in:box1. |
|
2842 | 554 |
l borderWidth:0. |
555 |
l adjust:#left. |
|
556 |
||
3817 | 557 |
eH := 0. |
558 |
||
3832 | 559 |
encodingFilter := ComboBoxView in:box1. |
2942 | 560 |
"/ encodingFilter font:l font. |
2826 | 561 |
encodingFilter level:-1. |
562 |
encodingFilter contents:'*'. |
|
2842 | 563 |
encodingFilter list:(self listOfEncodingsInFilterCombo). |
2826 | 564 |
encodingFilter action:[:pattern | self encodingFilterSelected:pattern]. |
565 |
encodingFilter immediateAccept:true. |
|
2942 | 566 |
"/ encodingFilter editor font:l font. |
2842 | 567 |
|
3817 | 568 |
self showEncodingFilter ifTrue:[ |
569 |
eH := encodingFilter preferredHeight. |
|
3832 | 570 |
box1 topInset:(eH negated-4); horizontalInset:mm. |
3817 | 571 |
] ifFalse:[ |
572 |
encodingFilter beInvisible |
|
573 |
]. |
|
2842 | 574 |
|
2826 | 575 |
"/ encodingFilter acceptOnReturn:true. |
576 |
"/ encodingFilter acceptOnTab:true. |
|
577 |
"/ encodingFilter acceptOnLeave:true. |
|
578 |
"/ encodingFilter acceptOnLostFocus:true. |
|
579 |
"/ encodingFilter acceptOnPointerLeave:true. |
|
580 |
||
3832 | 581 |
encodingLabel := Label label:' ' in:box1. |
2842 | 582 |
"/ eH := encodingLabel preferredExtent y. |
3832 | 583 |
"/ encodingLabel origin:0.6@1.0 corner:1.0@1.0. |
584 |
"/ encodingLabel topInset:(eH negated); horizontalInset:mm. |
|
2842 | 585 |
encodingLabel level:0; adjust:#left. |
586 |
encodingLabel adjust:#right. |
|
3817 | 587 |
self showEncodingFilter ifFalse:[ |
588 |
encodingLabel beInvisible |
|
589 |
]. |
|
382 | 590 |
|
4944 | 591 |
XftFontDescription notNil ifTrue:[ |
4952 | 592 |
UserPreferences current useXftFontsOnly ifTrue:[ |
4983 | 593 |
self xftFontsOnlyHolder value: true. |
4952 | 594 |
] ifFalse:[ |
4983 | 595 |
self xftFontsOnlyHolder value: false. |
4952 | 596 |
xftCheckBox := CheckBox label:'XFT Fonts Only' in:box1. |
597 |
xftCheckBox model:xftFontsOnlyHolder. |
|
598 |
xftFontsOnlyHolder onChangeEvaluate:[ self xftFontsOnlyChanged ]. |
|
599 |
]. |
|
4944 | 600 |
]. |
601 |
||
4892 | 602 |
"/ sep := View in:box1. |
603 |
"/ sep width:10 height:10. |
|
3832 | 604 |
|
605 |
pixelPointSwitch := ComboListView in:box2. |
|
606 |
"/ encodingFilter font:l font. |
|
607 |
pixelPointSwitch level:-1. |
|
3841 | 608 |
pixelPointSwitch contents:'pt'. |
3837 | 609 |
pixelPointSwitch list:#(#pt #px). |
3832 | 610 |
pixelPointSwitch action:[:sizeUnit | self sizeUnitSelected:sizeUnit]. |
611 |
box2 topInset:(pixelPointSwitch preferredHeight negated-4); horizontalInset:mm. |
|
612 |
"/ encodingFilter editor font:l font. |
|
613 |
||
614 |
self showEncodingFilter ifTrue:[ |
|
615 |
eH := encodingFilter preferredHeight. |
|
616 |
box1 topInset:(eH negated-4); horizontalInset:mm. |
|
617 |
] ifFalse:[ |
|
618 |
encodingFilter beInvisible |
|
619 |
]. |
|
620 |
||
2847 | 621 |
showFontNameLabel ifTrue:[ |
622 |
nameLabel := Label label:'' in:self. |
|
623 |
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
|
624 |
nameLabel bottomInset:(buttonPanel preferredHeight + (mm*2)). |
242d08639bcc
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3604
diff
changeset
|
625 |
nameLabel topInset:(buttonPanel preferredHeight + (mm*2) + 24) negated; horizontalInset:mm. |
2847 | 626 |
nameLabel level:0; adjust:#left. |
627 |
nameLabel font:(FontDescription family:'helvetica' face:'medium' style:'roman' size:9). |
|
628 |
]. |
|
382 | 629 |
|
5007 | 630 |
vPanel := VariableVerticalPanel in:panel. |
631 |
vPanel origin:0.0@0.0 corner:1.0@1.0. |
|
632 |
||
633 |
previewField := HVScrollableView for:TextView in:vPanel. |
|
634 |
"/ previewField origin:0.0@0.0 corner:1.0@0.4. |
|
2842 | 635 |
previewField autoHideScrollBars:true. |
636 |
previewField := previewField scrolledView. |
|
382 | 637 |
previewField inset:mm. |
77 | 638 |
|
639 |
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
|
640 |
previewField level:-1. |
77 | 641 |
] ifFalse:[ |
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
642 |
previewField borderWidth:1. |
77 | 643 |
]. |
644 |
||
5007 | 645 |
fontBrowserView := View in:vPanel. |
646 |
"/ fontBrowserView origin:0.0@0.4 corner:1.0@1.0. |
|
382 | 647 |
fontBrowserView bottomInset:(eH + mm). |
77 | 648 |
|
649 |
v1 := View origin:0.0@0.0 corner:0.4@1.0 in:fontBrowserView. |
|
650 |
||
2842 | 651 |
familyLabel := Label label:(resources string:'Family') in:v1. |
77 | 652 |
familyLabel borderWidth:0. |
653 |
familyLabel origin:(0.0 @ 0.0) extent:(1.0 @ nil). |
|
3607
242d08639bcc
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3604
diff
changeset
|
654 |
fH := familyLabel preferredHeight. |
77 | 655 |
|
656 |
familyList := ScrollableView for:SelectionInListView in:v1. |
|
382 | 657 |
familyList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
658 |
familyList inset:mm. |
|
659 |
familyList topInset:fH. |
|
660 |
||
128 | 661 |
familyList := familyList scrolledView. |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
662 |
self makeTabable:familyList. |
77 | 663 |
|
664 |
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
|
665 |
in:fontBrowserView. |
77 | 666 |
|
2842 | 667 |
faceLabel := Label label:(resources string:'Typeface') in:v2. |
77 | 668 |
faceLabel borderWidth:0. |
669 |
faceLabel origin:(0.0 @ 0.0) extent:(1.0 @ nil). |
|
670 |
||
671 |
faceList := ScrollableView for:SelectionInListView in:v2. |
|
382 | 672 |
faceList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
673 |
faceList inset:mm. |
|
674 |
faceList topInset:fH. |
|
128 | 675 |
faceList := faceList scrolledView. |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
676 |
self makeTabable:faceList. |
77 | 677 |
|
2842 | 678 |
v3 := View origin:0.8@0.0 corner:1.0@1.0 in:fontBrowserView. |
77 | 679 |
|
3832 | 680 |
sizeLabelHolder := (resources string:'Size') asValue. |
681 |
sizeLabel := Label in:v3. |
|
682 |
sizeLabel labelChannel:sizeLabelHolder. |
|
77 | 683 |
sizeLabel borderWidth:0. |
684 |
sizeLabel origin:(0.0 @ 0.0)extent:(1.0 @ nil). |
|
685 |
||
686 |
sizeList := ScrollableView for:SelectionInListView in:v3. |
|
382 | 687 |
sizeList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
688 |
sizeList inset:mm. |
|
689 |
sizeList topInset:fH. |
|
128 | 690 |
sizeList := sizeList scrolledView. |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
691 |
self makeTabable:sizeList. |
77 | 692 |
|
693 |
familyList action:[:lineNr | self familySelected:(familyList selectionValue)]. |
|
694 |
faceList action:[:lineNr | self faceSelected:(faceList selectionValue)]. |
|
695 |
sizeList action:[:lineNr | self sizeSelected:(sizeList selectionValue)]. |
|
696 |
||
2852 | 697 |
previewField menuHolder:self previewMenu. |
698 |
||
77 | 699 |
" |
700 |
FontPanel new showAtPointer |
|
701 |
" |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
702 |
|
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
703 |
"Modified: 31.5.1996 / 22:01:45 / cg" |
77 | 704 |
! |
705 |
||
2842 | 706 |
listOfEncodingsInFilterCombo |
2878 | 707 |
|availableEncodings listPresentedToUser| |
2842 | 708 |
|
2878 | 709 |
listOfEncodings := OrderedCollection new. |
4982 | 710 |
self graphicsDevice isWindowsPlatform ifTrue:[ |
2878 | 711 |
listOfEncodings |
2849 | 712 |
addAll: |
713 |
#( |
|
714 |
'*' |
|
715 |
nil |
|
716 |
). |
|
717 |
] ifFalse:[ |
|
2878 | 718 |
listOfEncodings |
2849 | 719 |
addAll: |
720 |
#( |
|
721 |
'*' |
|
4429
671a2fc8798f
changed: #listOfEncodingsInFilterCombo
Stefan Vogel <sv@exept.de>
parents:
4161
diff
changeset
|
722 |
#'iso8859-1' |
671a2fc8798f
changed: #listOfEncodingsInFilterCombo
Stefan Vogel <sv@exept.de>
parents:
4161
diff
changeset
|
723 |
#'iso10646-1' |
2849 | 724 |
'jis*' |
725 |
nil |
|
726 |
). |
|
727 |
]. |
|
2842 | 728 |
|
729 |
availableEncodings := Set new. |
|
4897 | 730 |
self graphicsDevice listOfAvailableFonts do:[:f | availableEncodings add:(f encoding ? '?')]. |
2842 | 731 |
availableEncodings := availableEncodings asSortedCollection. |
2878 | 732 |
listOfEncodings addAll:availableEncodings. |
733 |
||
734 |
listPresentedToUser := listOfEncodings collect:[:enc | |
|
735 |
|encoder userFriendlyName| |
|
736 |
||
2938 | 737 |
"/ |
738 |
"/ disabled to avoid autoloading of encoders. |
|
739 |
"/ (enc notNil and:[enc ~= '*']) ifTrue:[ |
|
740 |
"/ encoder := CharacterEncoder encoderFor:enc ifAbsent:nil. |
|
741 |
"/ encoder notNil ifTrue:[ |
|
742 |
"/ userFriendlyName := encoder userFriendlyNameOfEncoding. |
|
743 |
"/ ]. |
|
744 |
"/ ]. |
|
2937 | 745 |
(userFriendlyName notNil and:[(userFriendlyName sameAs: enc) not]) ifTrue:[ |
2878 | 746 |
enc , ' (' , userFriendlyName , ')' |
747 |
] ifFalse:[ |
|
748 |
enc |
|
749 |
] |
|
750 |
]. |
|
751 |
^ listPresentedToUser. |
|
2842 | 752 |
! |
753 |
||
1277 | 754 |
postRealize |
197 | 755 |
"kludge for sco - xlsfont fails sometimes - try again here" |
756 |
||
415 | 757 |
self updateFamilyList. |
1277 | 758 |
super postRealize |
415 | 759 |
|
760 |
"Modified: 27.2.1996 / 01:40:47 / cg" |
|
1277 | 761 |
"Created: 24.7.1997 / 18:12:42 / cg" |
2852 | 762 |
! |
763 |
||
764 |
previewMenu |
|
765 |
<resource: #programMenu > |
|
766 |
||
767 |
|menu| |
|
768 |
||
3475 | 769 |
menu := Menu decodeFromLiteralArray:(self class previewMenu). |
2852 | 770 |
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
|
771 |
^ menu |
2875 | 772 |
|
3475 | 773 |
"Modified: / 27-03-2007 / 11:15:53 / cg" |
3817 | 774 |
! |
775 |
||
776 |
showEncodingFilter |
|
777 |
^ true |
|
77 | 778 |
! ! |
779 |
||
0 | 780 |
!FontPanel methodsFor:'private'! |
781 |
||
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
782 |
clearPreview |
595 | 783 |
"clear the preview subview" |
784 |
||
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
785 |
shown ifTrue:[ |
1297
f5ea02391a59
use #contents: instead of #clear
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
786 |
previewField contents:nil. |
3817 | 787 |
encodingLabel notNil ifTrue:[ |
788 |
encodingLabel label:''. |
|
789 |
]. |
|
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
790 |
]. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
791 |
|
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
792 |
"Created: 17.4.1996 / 15:19:16 / cg" |
1297
f5ea02391a59
use #contents: instead of #clear
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
793 |
"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
|
794 |
! |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
795 |
|
197 | 796 |
extractFaceAndStyleFrom:aString |
595 | 797 |
"given a string, extract currentFace and currentStyle" |
798 |
||
197 | 799 |
|index| |
800 |
||
801 |
index := aString indexOf:$-. |
|
4944 | 802 |
currentFaceAndStyle := aString. |
197 | 803 |
(index ~~ 0) ifTrue:[ |
595 | 804 |
currentFace := aString copyTo:(index - 1). |
805 |
currentStyle := aString copyFrom:(index + 1) |
|
4944 | 806 |
] ifFalse:[ |
807 |
currentFace := aString. |
|
808 |
currentStyle := nil. |
|
809 |
]. |
|
197 | 810 |
|
595 | 811 |
"Modified: 29.4.1996 / 09:41:47 / cg" |
197 | 812 |
! |
813 |
||
3817 | 814 |
fontForPreview |
815 |
"get the preview font" |
|
816 |
||
3837 | 817 |
|font allFonts fonts| |
3817 | 818 |
|
3853 | 819 |
currentSize isNil ifTrue:[ |
820 |
^ nil. |
|
821 |
]. |
|
3841 | 822 |
|
4983 | 823 |
font := (self xftFontsOnlyHolder value |
4944 | 824 |
ifTrue:[XftFontDescription] |
825 |
ifFalse:[Font]) |
|
826 |
family:currentFamily |
|
827 |
face:currentFace |
|
828 |
style:currentStyle |
|
829 |
size:currentSize |
|
830 |
sizeUnit:sizeUnit |
|
831 |
encoding:encoding. |
|
832 |
||
833 |
font notNil ifTrue:[^ font]. |
|
834 |
||
4897 | 835 |
allFonts := self graphicsDevice |
3837 | 836 |
fontsInFamily:(currentFamily ? '*') |
837 |
face:(currentFace ? '*') |
|
838 |
style:(currentStyle ? '*') |
|
4944 | 839 |
filtering:combinedFilter. |
3817 | 840 |
|
3837 | 841 |
sizeUnit == #px ifTrue:[ |
3834 | 842 |
fonts := allFonts select:[:f | f pixelSize = currentSize]. |
843 |
] ifFalse:[ |
|
844 |
fonts := allFonts select:[:f | f size = currentSize]. |
|
845 |
]. |
|
3817 | 846 |
fonts notEmpty ifTrue:[ |
847 |
font := fonts anElement. |
|
848 |
] ifFalse:[ |
|
849 |
"/ mhmh: |
|
850 |
"/ size=0 is returned for scalable fonts. |
|
851 |
"/ Any size is possible. |
|
852 |
"/ |
|
853 |
fonts := allFonts select:[:f | f size = 0]. |
|
854 |
fonts notEmpty ifTrue:[ |
|
855 |
font := Font family:currentFamily |
|
856 |
face:currentFace |
|
857 |
style:currentStyle |
|
3837 | 858 |
size:currentSize |
859 |
sizeUnit:sizeUnit |
|
3817 | 860 |
encoding:(fonts anElement encoding). |
861 |
] |
|
862 |
]. |
|
863 |
^ font |
|
864 |
! |
|
865 |
||
866 |
getFacesForFamily:aFamilyName filtering:filter |
|
867 |
"the list of font faces for a given family" |
|
868 |
||
4944 | 869 |
^ self graphicsDevice facesInFamily:aFamilyName filtering:filter. |
3817 | 870 |
! |
871 |
||
872 |
getFamilyList |
|
873 |
"the list of font families" |
|
874 |
||
4944 | 875 |
^ self graphicsDevice fontFamiliesFiltering:combinedFilter. |
3817 | 876 |
! |
877 |
||
878 |
getSizesInFamily:aFamilyName face:face style:style filtering:filter |
|
3837 | 879 |
sizeUnit == #px ifTrue:[ |
4897 | 880 |
^ self graphicsDevice |
3834 | 881 |
pixelSizesInFamily:(currentFamily ? '*') |
882 |
face:(currentFace ? '*') |
|
883 |
style:(currentStyle ? '*') |
|
884 |
filtering:filter. |
|
4944 | 885 |
] ifFalse:[ |
886 |
^ self graphicsDevice |
|
887 |
sizesInFamily:(currentFamily ? '*') |
|
888 |
face:(currentFace ? '*') |
|
889 |
style:(currentStyle ? '*') |
|
890 |
filtering:filter. |
|
3834 | 891 |
]. |
3817 | 892 |
! |
893 |
||
894 |
getStylesInFamily:aFamilyName face:aFace filtering:filter |
|
895 |
"the list of font styles for a given family-face" |
|
896 |
||
4897 | 897 |
^ self graphicsDevice stylesInFamily:aFamilyName face:aFace filtering:filter. |
3817 | 898 |
! |
899 |
||
197 | 900 |
showPreview |
595 | 901 |
"show the preview text" |
902 |
||
3817 | 903 |
|font deviceFont enc fontName| |
382 | 904 |
|
4949 | 905 |
"/ self clearPreview. |
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
906 |
|
197 | 907 |
" |
908 |
show a wait cursor: for some fonts (kanji etc) the |
|
2890 | 909 |
X-server needs quite some time to load the font |
197 | 910 |
" |
255 | 911 |
self withWaitCursorDo:[ |
3817 | 912 |
font := self fontForPreview. |
2843 | 913 |
font notNil ifTrue:[ |
4897 | 914 |
deviceFont := font onDevice:self graphicsDevice. |
2890 | 915 |
enc := deviceFont encoding. |
2916 | 916 |
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
|
917 |
|
2874 | 918 |
previewField font:deviceFont. |
919 |
previewField characterEncoding:enc. |
|
920 |
||
2287
b33ad40d7538
preview fixed when font is bad
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
921 |
encodingLabel label:enc. |
2843 | 922 |
currentEncoding := enc. |
923 |
fontName := deviceFont fullName. |
|
4925 | 924 |
(font isKindOf:XftFontDescription) ifTrue:[fontName := fontName,' (xft)']. |
4951 | 925 |
previewField contents:(font userFriendlyName,'\\' withCRs,(self class defaultSampleStringForEncoding:enc) asString). |
382 | 926 |
] ifFalse:[ |
2842 | 927 |
previewField contents:nil. |
928 |
encodingLabel label:nil. |
|
2843 | 929 |
currentEncoding := nil. |
2842 | 930 |
fontName := nil. |
382 | 931 |
]. |
2842 | 932 |
nameLabel notNil ifTrue:[nameLabel label:fontName]. |
197 | 933 |
] |
255 | 934 |
|
1257 | 935 |
"Modified: 30.6.1997 / 17:26:22 / cg" |
197 | 936 |
! |
937 |
||
128 | 938 |
showSelectedFont |
2843 | 939 |
|fam face faceAndStyle style sz| |
128 | 940 |
|
941 |
fam := selectedFont family. |
|
2843 | 942 |
currentEncoding := selectedFont encoding. |
943 |
||
2888 | 944 |
self familySelected:fam showPreview:false. |
128 | 945 |
fam notNil ifTrue:[ |
2842 | 946 |
face := selectedFont face. |
947 |
(face notNil and:[(style := selectedFont style) notNil]) ifTrue:[ |
|
948 |
faceAndStyle := face , '-' , style. |
|
949 |
]. |
|
2888 | 950 |
self faceSelected:faceAndStyle showPreview:false. |
2842 | 951 |
faceAndStyle notNil ifTrue:[ |
3841 | 952 |
sz := sizeUnit == #px ifTrue:[selectedFont pixelSize] ifFalse:[selectedFont size]. |
953 |
pixelPointSwitch contents:sizeUnit. |
|
2888 | 954 |
self sizeSelected:sz showPreview:false. |
2842 | 955 |
] |
956 |
]. |
|
2888 | 957 |
|
958 |
self showPreview |
|
2826 | 959 |
! |
960 |
||
961 |
updateFamilyList |
|
962 |
"update the list of font families" |
|
963 |
||
964 |
|families| |
|
965 |
||
966 |
familyList list isNil ifTrue:[ |
|
3817 | 967 |
families := self getFamilyList. |
2826 | 968 |
families notNil ifTrue:[ |
4943 | 969 |
families := families asNewOrderedCollection sort |
2826 | 970 |
]. |
971 |
familyList list:families |
|
972 |
]. |
|
973 |
selectedFont notNil ifTrue:[ |
|
974 |
self showSelectedFont |
|
975 |
]. |
|
976 |
||
977 |
"Modified: 27.2.1996 / 01:39:42 / cg" |
|
978 |
"Created: 27.2.1996 / 01:40:37 / cg" |
|
4944 | 979 |
! |
980 |
||
981 |
updateSizeList |
|
4947 | 982 |
|sizes sizeStrings oldSize| |
4944 | 983 |
|
984 |
sizes := self |
|
985 |
getSizesInFamily:(currentFamily ? '*') |
|
986 |
face:(currentFace ? '*') |
|
987 |
style:(currentStyle ? '*') |
|
988 |
filtering:combinedFilter. |
|
989 |
||
990 |
(sizes isEmptyOrNil) ifTrue:[ |
|
991 |
sizeList list:nil. |
|
992 |
currentSize := nil. |
|
993 |
"/ self halt. |
|
994 |
^ self |
|
995 |
]. |
|
996 |
||
997 |
sizes := sizes asOrderedCollection. |
|
998 |
selectedFont notNil ifTrue:[ |
|
4947 | 999 |
oldSize := currentSize. |
4944 | 1000 |
currentSize := (selectedFont sizeUnit == #px) |
1001 |
ifTrue:[ selectedFont pixelSize ] |
|
1002 |
ifFalse:[ selectedFont size ]. |
|
4947 | 1003 |
currentSize == 0 ifTrue:[ |
1004 |
currentSize := oldSize |
|
1005 |
]. |
|
4948 | 1006 |
currentSize notNil ifTrue:[ |
1007 |
(sizes includes:currentSize) ifFalse:[ |
|
1008 |
sizes add:currentSize |
|
1009 |
]. |
|
4944 | 1010 |
]. |
1011 |
]. |
|
1012 |
sizes sort. |
|
1013 |
||
1014 |
sizeStrings := sizes collect:[:entry | entry printString]. |
|
1015 |
sizeList list:sizeStrings. |
|
1016 |
currentSize notNil ifTrue:[ |
|
1017 |
(sizeStrings includes:(currentSize printString)) ifTrue:[ |
|
1018 |
sizeList setSelectElement:currentSize printString. |
|
1019 |
] |
|
1020 |
]. |
|
1021 |
! |
|
1022 |
||
1023 |
xftFontsOnlyChanged |
|
1024 |
self filter:filter. "/ will update combinedFilter |
|
197 | 1025 |
! ! |
128 | 1026 |
|
197 | 1027 |
!FontPanel methodsFor:'queries'! |
0 | 1028 |
|
3405
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
1029 |
characterSetViewClassAvailable |
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
1030 |
^ CharacterSetView notNil |
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 |
"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
|
1033 |
! |
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
1034 |
|
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
1035 |
characterSetViewClassAvailableOrOSIsUNIX |
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
1036 |
^ 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
|
1037 |
|
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
1038 |
"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
|
1039 |
! |
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
1040 |
|
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
1041 |
osIsUNIX |
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
1042 |
^ OperatingSystem isUNIXlike |
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 |
"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
|
1045 |
! |
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
1046 |
|
197 | 1047 |
preferredExtent |
595 | 1048 |
"return the boxes preferredExtent" |
572 | 1049 |
|
3769
758f8b0b6cf2
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3740
diff
changeset
|
1050 |
"/ If I have an explicit preferredExtent.. |
758f8b0b6cf2
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3740
diff
changeset
|
1051 |
explicitExtent notNil ifTrue:[ |
758f8b0b6cf2
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3740
diff
changeset
|
1052 |
^ explicitExtent |
758f8b0b6cf2
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3740
diff
changeset
|
1053 |
]. |
797 | 1054 |
|
3769
758f8b0b6cf2
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3740
diff
changeset
|
1055 |
"/ If I have a cached preferredExtent value.. |
713
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
1056 |
preferredExtent notNil ifTrue:[ |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
1057 |
^ preferredExtent |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
1058 |
]. |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
1059 |
|
4944 | 1060 |
"/ ^ 450@350 |
1061 |
^ self class defaultExtent. |
|
572 | 1062 |
|
797 | 1063 |
"Modified: 19.7.1996 / 20:44:08 / cg" |
0 | 1064 |
! ! |
77 | 1065 |
|
1066 |
!FontPanel methodsFor:'user interaction'! |
|
1067 |
||
3604 | 1068 |
copyFontName |
1069 |
self setClipboardText:(previewField font storeString). |
|
1070 |
! |
|
1071 |
||
2826 | 1072 |
encodingFilterSelected:anEncodingPattern |
1073 |
"another encoding was selected; find available fonts and update lists" |
|
1074 |
||
1075 |
|pattern| |
|
1076 |
||
2887 | 1077 |
anEncodingPattern isNil ifTrue:[ |
1078 |
self filter:nil. |
|
1079 |
^ self. |
|
1080 |
]. |
|
1081 |
||
2878 | 1082 |
pattern := (anEncodingPattern upTo:$( ) withoutSeparators. |
1083 |
||
1084 |
pattern = '?' ifTrue:[ |
|
2845 | 1085 |
pattern := '' |
1086 |
] ifFalse:[ |
|
2878 | 1087 |
pattern := (pattern isEmptyOrNil ifTrue:'*' ifFalse:pattern). |
2845 | 1088 |
]. |
2826 | 1089 |
self |
1090 |
filter: |
|
1091 |
[:f | |
|
3899
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1092 |
|doesMatch encoding| |
2826 | 1093 |
|
3899
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1094 |
"/ k&d hack for mswindows names... |
3848 | 1095 |
"/ Transcript showCR:f encoding. |
3899
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1096 |
encoding := f encoding ? ''. |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1097 |
doesMatch := (pattern match:encoding). |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1098 |
doesMatch ifFalse:[ |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1099 |
encoding = 'ms-ansi' ifTrue:[ |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1100 |
doesMatch := (pattern = 'iso8859-1') |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1101 |
or:[ (pattern = 'iso10646-1') |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1102 |
or:[ (pattern = 'unicode') ]] |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1103 |
]. |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1104 |
(encoding = 'iso8859-1' |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1105 |
or:[encoding = 'iso10646-1' |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1106 |
or:[encoding = 'unicode']]) ifTrue:[ |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1107 |
doesMatch := (pattern = 'ms-ansi') |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1108 |
]. |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1109 |
]. |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1110 |
doesMatch |
2826 | 1111 |
]. |
1112 |
! |
|
1113 |
||
197 | 1114 |
faceSelected:aFaceAndStyleName |
2826 | 1115 |
"a fonts face was selected; find available sizes and update lists" |
595 | 1116 |
|
2842 | 1117 |
self faceSelected:aFaceAndStyleName showPreview:true |
1118 |
! |
|
1119 |
||
1120 |
faceSelected:aFaceAndStyleName showPreview:showPreview |
|
1121 |
"a fonts face was selected; find available sizes and update lists" |
|
1122 |
||
3740 | 1123 |
|sizes sizeStrings didShow| |
197 | 1124 |
|
1125 |
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
|
1126 |
self extractFaceAndStyleFrom:aFaceAndStyleName. |
197 | 1127 |
]. |
4944 | 1128 |
self updateSizeList. |
1129 |
showPreview ifTrue:[ |
|
1130 |
self showPreview. |
|
197 | 1131 |
]. |
4944 | 1132 |
^ self. |
1133 |
"/ |
|
1134 |
"/ sizes := self |
|
1135 |
"/ getSizesInFamily:(currentFamily ? '*') |
|
1136 |
"/ face:(currentFace ? '*') |
|
1137 |
"/ style:(currentStyle ? '*') |
|
1138 |
"/ filtering:combinedFilter. |
|
1139 |
"/ |
|
1140 |
"/ (sizes isEmptyOrNil) ifTrue:[ |
|
1141 |
"/ sizeList list:nil. |
|
1142 |
"/ currentSize := nil. |
|
1143 |
"/ self breakPoint:#cg. |
|
1144 |
"/ showPreview ifTrue:[ |
|
1145 |
"/ self showPreview. |
|
1146 |
"/ ]. |
|
1147 |
"/ ^ self |
|
1148 |
"/ ]. |
|
1149 |
"/ |
|
1150 |
"/ didShow := false. |
|
1151 |
"/ |
|
1152 |
"/ sizes := sizes asOrderedCollection. |
|
1153 |
"/ selectedFont notNil ifTrue:[ |
|
1154 |
"/ (sizes includes:selectedFont size) ifFalse:[ |
|
1155 |
"/ sizes add:selectedFont size |
|
1156 |
"/ ]. |
|
1157 |
"/ ]. |
|
1158 |
"/ sizes sort. |
|
1159 |
"/ |
|
1160 |
"/ sizeStrings := sizes collect:[:entry | entry printString]. |
|
1161 |
"/ sizeList list:sizeStrings. |
|
1162 |
"/ currentSize notNil ifTrue:[ |
|
1163 |
"/ (sizeStrings includes:(currentSize printString)) ifTrue:[ |
|
1164 |
"/ sizeList setSelectElement:currentSize printString. |
|
1165 |
"/ showPreview ifTrue:[ |
|
1166 |
"/ self showPreview. |
|
1167 |
"/ didShow := true. |
|
1168 |
"/ ] |
|
1169 |
"/ ] |
|
1170 |
"/ ]. |
|
1171 |
"/ didShow ifFalse:[ |
|
1172 |
"/ self clearPreview |
|
1173 |
"/ ]. |
|
1174 |
"/ |
|
1257 | 1175 |
"Modified: 30.6.1997 / 17:25:46 / cg" |
197 | 1176 |
! |
1177 |
||
77 | 1178 |
familySelected:aFamilyName |
2826 | 1179 |
"a fonts family was selected; find available faces and update lists" |
595 | 1180 |
|
2842 | 1181 |
self familySelected:aFamilyName showPreview:true |
1182 |
! |
|
1183 |
||
1184 |
familySelected:aFamilyName showPreview:showPreview |
|
1185 |
"a fonts family was selected; find available faces and update lists" |
|
1186 |
||
77 | 1187 |
|faces styles list| |
1188 |
||
690 | 1189 |
familyList setSelectElement:aFamilyName. |
77 | 1190 |
|
1191 |
currentFamily := aFamilyName. |
|
4944 | 1192 |
faces := self getFacesForFamily:aFamilyName filtering:combinedFilter. |
3899
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1193 |
faces isEmptyOrNil ifTrue:[ |
415 | 1194 |
currentFace := currentStyle := currentFaceAndStyle := nil. |
1195 |
faceList list:nil. |
|
2842 | 1196 |
self faceSelected:nil showPreview:showPreview. |
415 | 1197 |
^ self. |
77 | 1198 |
]. |
1199 |
||
2353 | 1200 |
list := SortedCollection new. |
77 | 1201 |
faces do:[:aFace | |
4944 | 1202 |
styles := (self getStylesInFamily:aFamilyName face:aFace filtering:combinedFilter) ? #(). |
415 | 1203 |
styles do:[:aStyle | |
4944 | 1204 |
aFace isEmpty ifTrue:[ |
1205 |
list add:(aStyle) |
|
1206 |
] ifFalse:[ |
|
1207 |
list add:(aFace , '-' , aStyle) |
|
1208 |
] |
|
415 | 1209 |
] |
77 | 1210 |
]. |
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
1211 |
|
77 | 1212 |
faceList list:list. |
1213 |
currentFaceAndStyle notNil ifTrue:[ |
|
5008 | 1214 |
(list includes:currentFaceAndStyle) ifFalse:[ |
1215 |
currentFaceAndStyle = 'normal-roman' ifTrue:[ |
|
1216 |
(list includes:'regular-roman') ifTrue:[ |
|
1217 |
currentFaceAndStyle := 'regular-roman'. |
|
1218 |
currentFace := 'regular'. |
|
1219 |
currentStyle := 'roman'. |
|
1220 |
]. |
|
1221 |
(list includes:'medium-roman') ifTrue:[ |
|
1222 |
currentFaceAndStyle := 'medium-roman'. |
|
1223 |
currentFace := 'medium'. |
|
1224 |
currentStyle := 'roman'. |
|
1225 |
]. |
|
1226 |
]. |
|
1227 |
]. |
|
415 | 1228 |
(list includes:currentFaceAndStyle) ifTrue:[ |
690 | 1229 |
faceList setSelectElement:currentFaceAndStyle. |
2842 | 1230 |
self faceSelected:currentFaceAndStyle showPreview:showPreview. |
415 | 1231 |
^ self |
1232 |
] |
|
77 | 1233 |
]. |
5007 | 1234 |
list notEmptyOrNil ifTrue:[ |
1235 |
"/ faceList setSelectElement:(list first). |
|
1236 |
faceList selectElement:(list first). |
|
1237 |
self faceSelected:(list first) showPreview:showPreview. |
|
5008 | 1238 |
self updateSizeList. |
5007 | 1239 |
^ self |
1240 |
]. |
|
2842 | 1241 |
|
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
1242 |
sizeList list:nil. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
1243 |
self clearPreview. |
415 | 1244 |
|
690 | 1245 |
"Modified: 26.5.1996 / 15:04:29 / cg" |
77 | 1246 |
! |
1247 |
||
1248 |
okPressed |
|
595 | 1249 |
"ok was pressed; hide myself and evaluate the okAction, passing |
1250 |
family, face, style and size as arguments" |
|
1251 |
||
77 | 1252 |
self hide. |
1253 |
okAction notNil ifTrue:[ |
|
410 | 1254 |
currentFamily notNil ifTrue:[ |
4946 | 1255 |
okAction value: |
4983 | 1256 |
((self xftFontsOnlyHolder value |
4946 | 1257 |
ifTrue:[XftFontDescription] |
1258 |
ifFalse:[FontDescription]) |
|
1259 |
family:currentFamily |
|
1260 |
face:currentFace |
|
1261 |
style:currentStyle |
|
1262 |
size:currentSize |
|
1263 |
sizeUnit:(sizeUnit ? #pt) |
|
1264 |
encoding:(currentEncoding ? encoding)). |
|
410 | 1265 |
] |
77 | 1266 |
] |
410 | 1267 |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
1268 |
"Modified: 10.4.1997 / 09:51:31 / cg" |
77 | 1269 |
! |
1270 |
||
2852 | 1271 |
previewCopySelection |
1272 |
previewField copySelection. |
|
1273 |
! |
|
1274 |
||
2935 | 1275 |
previewInspectFont |
1276 |
previewField font inspect. |
|
1277 |
! |
|
1278 |
||
2852 | 1279 |
previewShowCharacterSet |
1280 |
CharacterSetView openOn:(previewField font) |
|
1281 |
! |
|
1282 |
||
2875 | 1283 |
previewShowCharacterSetUsingXFD |
2878 | 1284 |
[ |
1285 |
OperatingSystem executeCommand:'xfd -fn ' , previewField font fullName. |
|
1286 |
] fork. |
|
2875 | 1287 |
! |
1288 |
||
77 | 1289 |
sizeSelected:aNumberOrString |
2826 | 1290 |
"a size was selected; update preview" |
595 | 1291 |
|
2842 | 1292 |
self sizeSelected:aNumberOrString showPreview:true. |
1293 |
! |
|
1294 |
||
1295 |
sizeSelected:aNumberOrString showPreview:showPreview |
|
1296 |
"a size was selected; update preview" |
|
1297 |
||
77 | 1298 |
aNumberOrString isNumber ifTrue:[ |
595 | 1299 |
currentSize := aNumberOrString |
77 | 1300 |
] ifFalse:[ |
2826 | 1301 |
currentSize := Number readFromString:aNumberOrString onError:nil |
77 | 1302 |
]. |
2842 | 1303 |
showPreview ifTrue:[self showPreview] |
595 | 1304 |
|
1305 |
"Modified: 29.4.1996 / 09:43:23 / cg" |
|
3832 | 1306 |
! |
1307 |
||
1308 |
sizeUnitSelected:unitSymbol |
|
1309 |
sizeUnit := unitSymbol. |
|
1310 |
sizeLabelHolder value:(resources |
|
3837 | 1311 |
string:(sizeUnit == #px |
3832 | 1312 |
ifTrue:'Size (px)' |
1313 |
ifFalse:'Size')). |
|
3834 | 1314 |
|
1315 |
self showPreview |
|
77 | 1316 |
! ! |
197 | 1317 |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
1318 |
!FontPanel class methodsFor:'documentation'! |
243 | 1319 |
|
1320 |
version |
|
5008 | 1321 |
^ '$Header: /cvs/stx/stx/libwidg/FontPanel.st,v 1.126 2014-04-27 21:57:23 cg Exp $' |
4094 | 1322 |
! |
1323 |
||
1324 |
version_CVS |
|
5008 | 1325 |
^ '$Header: /cvs/stx/stx/libwidg/FontPanel.st,v 1.126 2014-04-27 21:57:23 cg Exp $' |
243 | 1326 |
! ! |
4660 | 1327 |