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