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