author | Claus Gittinger <cg@exept.de> |
Wed, 12 Oct 2016 11:17:20 +0200 | |
changeset 5903 | 9f80a35511a4 |
parent 5900 | d880e4b3a36d |
child 5911 | c2619d90b1b1 |
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 |
||
3740 | 607 |
enabled:aBoolean |
608 |
familyList enabled:aBoolean. |
|
609 |
faceList enabled:aBoolean. |
|
610 |
sizeList enabled:aBoolean. |
|
5900 | 611 |
encodingFilterField notNil ifTrue:[ |
612 |
encodingFilterField enabled:aBoolean. |
|
5531 | 613 |
]. |
614 |
aBoolean ifTrue:[ |
|
615 |
self abortButton label:(resources string:'Cancel'). |
|
616 |
self okButton beVisible. |
|
617 |
] ifFalse:[ |
|
618 |
self abortButton label:(resources string:'Close'). |
|
619 |
self okButton beInvisible. |
|
620 |
]. |
|
621 |
||
622 |
" |
|
623 |
FontPanel openOn:(Font family:'courier' size:12) |
|
624 |
FontPanel openOn:MenuPanel defaultFont |
|
625 |
FontPanel fontFromUser |
|
626 |
" |
|
3740 | 627 |
! |
628 |
||
77 | 629 |
initialize |
5531 | 630 |
"sigh: hand-crafted box creation; TODO: rewrite using UI painter" |
631 |
||
5466 | 632 |
|familyLabel faceLabel sizeLabel panel panel2 fontBrowserView fp v1 v2 v3 |
5900 | 633 |
mm fH l box1 box2 box3 box4 showFontNameLabel xftCheckBox vPanel changeInAllCheckBox |
634 |
xftFlushFontList decorativeCheckBox nonDecorativeCheckBox monospacedCheckBox nonMonospacedCheckBox| |
|
77 | 635 |
|
636 |
super initialize. |
|
637 |
||
5626 | 638 |
showFontNameLabel := device isWindowsPlatform not. |
3837 | 639 |
sizeUnit := #pt. |
2847 | 640 |
|
382 | 641 |
mm := ViewSpacing. |
642 |
||
1763 | 643 |
self addAbortAndOkButtons. |
77 | 644 |
|
390
1d54a9b41463
say Hello world in JIS font ;-)
Claus Gittinger <cg@exept.de>
parents:
382
diff
changeset
|
645 |
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
|
646 |
panel bottomInset:(buttonPanel preferredHeight |
5466 | 647 |
+ (mm) |
648 |
"+ (showFontNameLabel ifTrue:24 ifFalse:0)" ). |
|
649 |
||
650 |
vPanel := VariableVerticalPanel in:panel. |
|
651 |
vPanel origin:0.0@0.0 corner:1.0@1.0. |
|
652 |
||
653 |
previewField := HVScrollableView for:TextView in:vPanel. |
|
654 |
fontBrowserView := View in:vPanel. |
|
655 |
fp := View in:fontBrowserView. |
|
656 |
fp layout:(0.0@0.0 corner:1.0@1.0) asFractionalLayout. |
|
5531 | 657 |
fp layout bottomOffset:-150. |
77 | 658 |
|
150 | 659 |
label := resources string:'Font dialog'. |
77 | 660 |
|
5466 | 661 |
panel2 := VerticalPanelView in:fontBrowserView. |
662 |
panel2 layout:(0.0@1.0 corner:1.0@1.0) asFractionalLayout. |
|
5531 | 663 |
panel2 layout topOffset:-150. |
5466 | 664 |
|
665 |
panel2 horizontalLayout:#fit. |
|
666 |
panel2 verticalLayout:#top. |
|
2842 | 667 |
|
5466 | 668 |
box1 := HorizontalPanelView in:panel2. |
669 |
box1 height:25. |
|
5900 | 670 |
box1 horizontalLayout:#rightFit. |
5466 | 671 |
|
5900 | 672 |
showFontNameLabel ifTrue:[ |
673 |
nameLabel := Label label:'' in:box1. |
|
674 |
"/ nameLabel origin:0.0@1.0 corner:1.0@1.0. |
|
675 |
"/ nameLabel bottomInset:(buttonPanel preferredHeight + (mm*2)). |
|
676 |
"/ nameLabel topInset:(buttonPanel preferredHeight + (mm*2) + 24) negated; horizontalInset:mm. |
|
677 |
nameLabel level:0; adjust:#left. |
|
678 |
]. |
|
679 |
||
680 |
pixelPointSwitch := ComboListView in:box1. |
|
681 |
"/ encodingFilter font:l font. |
|
682 |
pixelPointSwitch level:-1. |
|
683 |
pixelPointSwitch contents:'pt'. |
|
684 |
pixelPointSwitch list:#(#pt #px). |
|
685 |
pixelPointSwitch action:[:sizeUnit | self sizeUnitSelected:sizeUnit]. |
|
686 |
"/ box2 topInset:(pixelPointSwitch preferredHeight negated-4); horizontalInset:mm. |
|
687 |
"/ encodingFilter editor font:l font. |
|
2842 | 688 |
|
5900 | 689 |
panel2 add:(View new height:8). |
690 |
||
691 |
"/ self showEncodingFilter ifFalse:[ |
|
692 |
"/ encodingFilter beInvisible |
|
693 |
"/ ]. |
|
694 |
||
695 |
box2 := HorizontalPanelView in:panel2. |
|
696 |
box2 height:25. |
|
697 |
box2 horizontalLayout:#leftSpace. |
|
2842 | 698 |
|
5900 | 699 |
l := Label label:(resources string:'Encoding:') in:box2. |
700 |
l borderWidth:0. |
|
701 |
l adjust:#left. |
|
2842 | 702 |
|
5900 | 703 |
encodingFilterField := ComboBoxView in:box2. |
704 |
"/ encodingFilterField font:l font. |
|
705 |
encodingFilterField level:-1. |
|
706 |
encodingFilterField contents:'*'. |
|
707 |
encodingFilterField list:(self listOfEncodingsInFilterCombo). |
|
708 |
encodingFilterField action:[:pattern | self encodingFilterSelected:pattern]. |
|
709 |
encodingFilterField immediateAccept:true. |
|
710 |
"/ encodingFilterField editor font:l font. |
|
2826 | 711 |
|
5900 | 712 |
self showEncodingFilter ifFalse:[ |
713 |
encodingFilterField beInvisible |
|
714 |
]. |
|
5466 | 715 |
|
5900 | 716 |
"/ encodingFilterField acceptOnReturn:true. |
717 |
"/ encodingFilterField acceptOnTab:true. |
|
718 |
"/ encodingFilterField acceptOnLeave:true. |
|
719 |
"/ encodingFilterField acceptOnLostFocus:true. |
|
720 |
"/ encodingFilterField acceptOnPointerLeave:true. |
|
721 |
||
722 |
encodingLabel := Label label:' ' in:box2. |
|
382 | 723 |
|
5900 | 724 |
encodingLabel level:0; adjust:#left. |
725 |
encodingLabel adjust:#right. |
|
726 |
self showEncodingFilter ifFalse:[ |
|
727 |
encodingLabel beInvisible |
|
728 |
]. |
|
5548 | 729 |
|
5900 | 730 |
device supportsXftFonts ifTrue:[ |
731 |
self xftFontsOnlyHolder value: (UserPreferences current useXftFontsOnly). |
|
732 |
xftCheckBox := CheckBox label:(resources string:'XFT Fonts Only') in:box2. |
|
733 |
xftCheckBox model:xftFontsOnlyHolder. |
|
734 |
xftFontsOnlyHolder onChangeEvaluate:[ self xftFontsOnlyChanged ]. |
|
735 |
||
736 |
xftFlushFontList := Button label:(resources string:'Flush Cached List of Fonts') in:box2. |
|
737 |
xftFlushFontList action:[ self flushListOfAvailableFonts]. |
|
738 |
]. |
|
4944 | 739 |
|
5900 | 740 |
false ifTrue:[ |
741 |
decorativeCheckBox := CheckBox label:(resources string:'Decorative Fonts Only'). |
|
742 |
box3 := View new height:(decorativeCheckBox preferredHeight). |
|
743 |
panel2 add:box3. |
|
744 |
||
745 |
decorativeCheckBox origin:0.0@0.0 corner:0.5@1.0. |
|
746 |
box3 add:decorativeCheckBox. |
|
747 |
decorativeCheckBox model:self decorativeOnlyHolder. |
|
748 |
self decorativeOnlyHolder onChangeEvaluate:[ self filterChanged ]. |
|
749 |
||
750 |
nonDecorativeCheckBox := CheckBox label:(resources string:'Non Decorative Fonts Only') in:box3. |
|
751 |
nonDecorativeCheckBox origin:0.5@0.0 corner:1.0@1.0. |
|
752 |
nonDecorativeCheckBox model:self nonDecorativeOnlyHolder. |
|
753 |
self nonDecorativeOnlyHolder onChangeEvaluate:[ self filterChanged ]. |
|
3832 | 754 |
|
5900 | 755 |
monospacedCheckBox := CheckBox label:(resources string:'Monospaced Fonts Only'). |
756 |
box4 := View new height:(monospacedCheckBox preferredHeight). |
|
757 |
panel2 add:box4. |
|
3832 | 758 |
|
5900 | 759 |
monospacedCheckBox origin:0.0@0.0 corner:0.5@1.0. |
760 |
box4 add:monospacedCheckBox. |
|
761 |
monospacedCheckBox model:self monospacedOnlyHolder. |
|
762 |
self monospacedOnlyHolder onChangeEvaluate:[ self filterChanged ]. |
|
3832 | 763 |
|
5900 | 764 |
nonMonospacedCheckBox := CheckBox label:(resources string:'Non Monospaced Fonts Only') in:box4. |
765 |
nonMonospacedCheckBox origin:0.5@0.0 corner:1.0@1.0. |
|
766 |
nonMonospacedCheckBox model:self nonMonospacedOnlyHolder. |
|
767 |
self nonMonospacedOnlyHolder onChangeEvaluate:[ self filterChanged ]. |
|
768 |
]. |
|
769 |
||
5532 | 770 |
changeInAllCheckBox := CheckBox label:(resources string:'Change all Textviews and Default for New Views') in:panel2. |
5531 | 771 |
changeInAllCheckBox model:self changeFontInAllViewsHolder. |
772 |
changeInAllCheckBox visibilityChannel:self withChangeFontInAllViewsCheckBoxVisibleHolder. |
|
773 |
||
5007 | 774 |
"/ previewField origin:0.0@0.0 corner:1.0@0.4. |
2842 | 775 |
previewField autoHideScrollBars:true. |
776 |
previewField := previewField scrolledView. |
|
382 | 777 |
previewField inset:mm. |
77 | 778 |
|
779 |
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
|
780 |
previewField level:-1. |
77 | 781 |
] ifFalse:[ |
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
782 |
previewField borderWidth:1. |
77 | 783 |
]. |
784 |
||
5466 | 785 |
v1 := View origin:0.0@0.0 corner:0.4@1.0 in:fp. |
786 |
||
2842 | 787 |
familyLabel := Label label:(resources string:'Family') in:v1. |
77 | 788 |
familyLabel borderWidth:0. |
789 |
familyLabel origin:(0.0 @ 0.0) extent:(1.0 @ nil). |
|
3607
242d08639bcc
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3604
diff
changeset
|
790 |
fH := familyLabel preferredHeight. |
77 | 791 |
|
792 |
familyList := ScrollableView for:SelectionInListView in:v1. |
|
382 | 793 |
familyList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
794 |
familyList inset:mm. |
|
795 |
familyList topInset:fH. |
|
796 |
||
128 | 797 |
familyList := familyList scrolledView. |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
798 |
self makeTabable:familyList. |
77 | 799 |
|
5466 | 800 |
v2 := View origin:0.4@0.0 corner:0.8@1.0 in:fp. |
77 | 801 |
|
2842 | 802 |
faceLabel := Label label:(resources string:'Typeface') in:v2. |
77 | 803 |
faceLabel borderWidth:0. |
804 |
faceLabel origin:(0.0 @ 0.0) extent:(1.0 @ nil). |
|
805 |
||
806 |
faceList := ScrollableView for:SelectionInListView in:v2. |
|
382 | 807 |
faceList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
808 |
faceList inset:mm. |
|
809 |
faceList topInset:fH. |
|
128 | 810 |
faceList := faceList scrolledView. |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
811 |
self makeTabable:faceList. |
77 | 812 |
|
5466 | 813 |
v3 := View origin:0.8@0.0 corner:1.0@1.0 in:fp. |
77 | 814 |
|
3832 | 815 |
sizeLabelHolder := (resources string:'Size') asValue. |
816 |
sizeLabel := Label in:v3. |
|
817 |
sizeLabel labelChannel:sizeLabelHolder. |
|
77 | 818 |
sizeLabel borderWidth:0. |
819 |
sizeLabel origin:(0.0 @ 0.0)extent:(1.0 @ nil). |
|
820 |
||
821 |
sizeList := ScrollableView for:SelectionInListView in:v3. |
|
382 | 822 |
sizeList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
823 |
sizeList inset:mm. |
|
824 |
sizeList topInset:fH. |
|
128 | 825 |
sizeList := sizeList scrolledView. |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
826 |
self makeTabable:sizeList. |
77 | 827 |
|
828 |
familyList action:[:lineNr | self familySelected:(familyList selectionValue)]. |
|
829 |
faceList action:[:lineNr | self faceSelected:(faceList selectionValue)]. |
|
830 |
sizeList action:[:lineNr | self sizeSelected:(sizeList selectionValue)]. |
|
831 |
||
2852 | 832 |
previewField menuHolder:self previewMenu. |
833 |
||
77 | 834 |
" |
835 |
FontPanel new showAtPointer |
|
5466 | 836 |
FontPanel fontFromUser |
77 | 837 |
" |
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
838 |
|
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
839 |
"Modified: 31.5.1996 / 22:01:45 / cg" |
77 | 840 |
! |
841 |
||
2842 | 842 |
listOfEncodingsInFilterCombo |
2878 | 843 |
|availableEncodings listPresentedToUser| |
2842 | 844 |
|
2878 | 845 |
listOfEncodings := OrderedCollection new. |
5626 | 846 |
device isWindowsPlatform ifTrue:[ |
2878 | 847 |
listOfEncodings |
2849 | 848 |
addAll: |
849 |
#( |
|
850 |
'*' |
|
851 |
nil |
|
852 |
). |
|
853 |
] ifFalse:[ |
|
2878 | 854 |
listOfEncodings |
2849 | 855 |
addAll: |
856 |
#( |
|
857 |
'*' |
|
4429
671a2fc8798f
changed: #listOfEncodingsInFilterCombo
Stefan Vogel <sv@exept.de>
parents:
4161
diff
changeset
|
858 |
#'iso8859-1' |
671a2fc8798f
changed: #listOfEncodingsInFilterCombo
Stefan Vogel <sv@exept.de>
parents:
4161
diff
changeset
|
859 |
#'iso10646-1' |
2849 | 860 |
'jis*' |
861 |
nil |
|
862 |
). |
|
863 |
]. |
|
2842 | 864 |
|
865 |
availableEncodings := Set new. |
|
5626 | 866 |
device listOfAvailableFonts do:[:f | availableEncodings add:(f encoding ? '?')]. |
2842 | 867 |
availableEncodings := availableEncodings asSortedCollection. |
2878 | 868 |
listOfEncodings addAll:availableEncodings. |
869 |
||
870 |
listPresentedToUser := listOfEncodings collect:[:enc | |
|
871 |
|encoder userFriendlyName| |
|
872 |
||
2938 | 873 |
"/ |
874 |
"/ disabled to avoid autoloading of encoders. |
|
875 |
"/ (enc notNil and:[enc ~= '*']) ifTrue:[ |
|
876 |
"/ encoder := CharacterEncoder encoderFor:enc ifAbsent:nil. |
|
877 |
"/ encoder notNil ifTrue:[ |
|
878 |
"/ userFriendlyName := encoder userFriendlyNameOfEncoding. |
|
879 |
"/ ]. |
|
880 |
"/ ]. |
|
2937 | 881 |
(userFriendlyName notNil and:[(userFriendlyName sameAs: enc) not]) ifTrue:[ |
2878 | 882 |
enc , ' (' , userFriendlyName , ')' |
883 |
] ifFalse:[ |
|
884 |
enc |
|
885 |
] |
|
886 |
]. |
|
887 |
^ listPresentedToUser. |
|
2842 | 888 |
! |
889 |
||
1277 | 890 |
postRealize |
197 | 891 |
"kludge for sco - xlsfont fails sometimes - try again here" |
892 |
||
415 | 893 |
self updateFamilyList. |
1277 | 894 |
super postRealize |
415 | 895 |
|
896 |
"Modified: 27.2.1996 / 01:40:47 / cg" |
|
1277 | 897 |
"Created: 24.7.1997 / 18:12:42 / cg" |
2852 | 898 |
! |
899 |
||
900 |
previewMenu |
|
901 |
<resource: #programMenu > |
|
902 |
||
903 |
|menu| |
|
904 |
||
3475 | 905 |
menu := Menu decodeFromLiteralArray:(self class previewMenu). |
2852 | 906 |
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
|
907 |
^ menu |
2875 | 908 |
|
3475 | 909 |
"Modified: / 27-03-2007 / 11:15:53 / cg" |
3817 | 910 |
! |
911 |
||
912 |
showEncodingFilter |
|
913 |
^ true |
|
77 | 914 |
! ! |
915 |
||
0 | 916 |
!FontPanel methodsFor:'private'! |
917 |
||
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
918 |
clearPreview |
595 | 919 |
"clear the preview subview" |
920 |
||
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
921 |
shown ifTrue:[ |
1297
f5ea02391a59
use #contents: instead of #clear
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
922 |
previewField contents:nil. |
3817 | 923 |
encodingLabel notNil ifTrue:[ |
924 |
encodingLabel label:''. |
|
925 |
]. |
|
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
926 |
]. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
927 |
|
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
928 |
"Created: 17.4.1996 / 15:19:16 / cg" |
1297
f5ea02391a59
use #contents: instead of #clear
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
929 |
"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
|
930 |
! |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
931 |
|
197 | 932 |
extractFaceAndStyleFrom:aString |
595 | 933 |
"given a string, extract currentFace and currentStyle" |
934 |
||
197 | 935 |
|index| |
936 |
||
937 |
index := aString indexOf:$-. |
|
4944 | 938 |
currentFaceAndStyle := aString. |
197 | 939 |
(index ~~ 0) ifTrue:[ |
595 | 940 |
currentFace := aString copyTo:(index - 1). |
941 |
currentStyle := aString copyFrom:(index + 1) |
|
4944 | 942 |
] ifFalse:[ |
943 |
currentFace := aString. |
|
944 |
currentStyle := nil. |
|
945 |
]. |
|
197 | 946 |
|
595 | 947 |
"Modified: 29.4.1996 / 09:41:47 / cg" |
197 | 948 |
! |
949 |
||
3817 | 950 |
fontForPreview |
951 |
"get the preview font" |
|
952 |
||
5189 | 953 |
|fontShown familyFonts fonts sz szUnitUsed| |
3817 | 954 |
|
3853 | 955 |
currentSize isNil ifTrue:[ |
956 |
^ nil. |
|
957 |
]. |
|
5189 | 958 |
sz := Number readFrom:currentSize. |
5187 | 959 |
szUnitUsed := sizeUnit. |
5446 | 960 |
(currentSize endsWith:#px) ifTrue:[ |
5187 | 961 |
szUnitUsed := #px. |
962 |
]. |
|
3841 | 963 |
|
5189 | 964 |
familyFonts := fontsPerFamily at:currentFamily ifAbsent:nil. |
965 |
familyFonts isNil ifTrue:[ |
|
966 |
familyFonts := fontsPerFamily at:currentFamily asUppercaseFirst ifAbsent:nil. |
|
967 |
familyFonts isNil ifTrue:[ |
|
968 |
^ nil |
|
969 |
]. |
|
970 |
]. |
|
971 |
fonts := familyFonts |
|
5187 | 972 |
select:[:fntDescr | |
973 |
fntDescr face = currentFace |
|
5446 | 974 |
and:[fntDescr style = currentStyle |
975 |
and:[fntDescr isScaledFont |
|
976 |
or:[sz = (szUnitUsed == #px |
|
977 |
ifTrue:[fntDescr pixelSize] ifFalse:[fntDescr size])]]] |
|
5187 | 978 |
]. |
4944 | 979 |
|
5189 | 980 |
fonts isEmpty ifTrue:[ |
981 |
^ nil |
|
982 |
]. |
|
983 |
||
5187 | 984 |
fonts size > 1 ifTrue:[ |
985 |
'FontPanel [info]: huh - multiple entries: ' infoPrint. fonts infoPrintCR. |
|
5466 | 986 |
"/ self halt. |
5187 | 987 |
]. |
988 |
fontShown := fonts first. |
|
989 |
fontShown isScaledFont ifTrue:[ |
|
990 |
szUnitUsed == #px ifTrue:[ |
|
991 |
fontShown := fontShown asPixelSize:sz |
|
992 |
] ifFalse:[ |
|
993 |
fontShown := fontShown asSize:sz |
|
994 |
]. |
|
995 |
]. |
|
5626 | 996 |
^ fontShown onDevice:device |
3817 | 997 |
|
5187 | 998 |
"/ fontShown := |
999 |
"/ ((Screen current supportsXFTFonts and:[selectedFont isXftFont "self xftFontsOnlyHolder value" ]) |
|
1000 |
"/ ifTrue:[XftFontDescription] |
|
1001 |
"/ ifFalse:[Font]) |
|
1002 |
"/ family:currentFamily |
|
1003 |
"/ face:currentFace |
|
1004 |
"/ style:currentStyle |
|
1005 |
"/ size:currentSize |
|
1006 |
"/ sizeUnit:sizeUnit |
|
1007 |
"/ encoding:encoding. |
|
1008 |
"/ |
|
1009 |
"/ fontShown notNil ifTrue:[^ fontShown]. |
|
1010 |
"/ |
|
1011 |
"/ allFonts := self graphicsDevice |
|
1012 |
"/ fontsInFamily:(currentFamily ? '*') |
|
1013 |
"/ face:(currentFace ? '*') |
|
1014 |
"/ style:(currentStyle ? '*') |
|
1015 |
"/ filtering:combinedFilter. |
|
1016 |
"/ |
|
1017 |
"/ sizeUnit == #px ifTrue:[ |
|
1018 |
"/ fonts := allFonts select:[:f | f pixelSize = currentSize]. |
|
1019 |
"/ ] ifFalse:[ |
|
1020 |
"/ fonts := allFonts select:[:f | f size = currentSize]. |
|
1021 |
"/ ]. |
|
1022 |
"/ fonts notEmpty ifTrue:[ |
|
1023 |
"/ fontShown := fonts anElement. |
|
1024 |
"/ ] ifFalse:[ |
|
1025 |
"/ "/ mhmh: |
|
1026 |
"/ "/ size=0 is returned for scalable fonts. |
|
1027 |
"/ "/ Any size is possible. |
|
1028 |
"/ "/ |
|
1029 |
"/ fonts := allFonts select:[:f | f size = 0]. |
|
1030 |
"/ fonts notEmpty ifTrue:[ |
|
1031 |
"/ fontShown := Font family:currentFamily |
|
1032 |
"/ face:currentFace |
|
1033 |
"/ style:currentStyle |
|
1034 |
"/ size:currentSize |
|
1035 |
"/ sizeUnit:sizeUnit |
|
1036 |
"/ encoding:(fonts anElement encoding). |
|
1037 |
"/ ] |
|
1038 |
"/ ]. |
|
1039 |
"/ ^ fontShown |
|
3817 | 1040 |
! |
1041 |
||
1042 |
getFacesForFamily:aFamilyName filtering:filter |
|
1043 |
"the list of font faces for a given family" |
|
1044 |
||
5187 | 1045 |
|familyFonts| |
1046 |
||
1047 |
familyFonts := fontsPerFamily at:aFamilyName ifAbsent:nil. |
|
1048 |
familyFonts isEmptyOrNil ifTrue:[^ nil]. |
|
1049 |
||
1050 |
^ familyFonts |
|
1051 |
select:[:fntDescr | |
|
1052 |
(filter isNil or:[filter value:fntDescr]) |
|
1053 |
] |
|
1054 |
thenCollect:[:fntDescr | |
|
1055 |
fntDescr face. |
|
1056 |
] |
|
1057 |
||
1058 |
"/ ^ self graphicsDevice facesInFamily:aFamilyName filtering:filter. |
|
3817 | 1059 |
! |
1060 |
||
1061 |
getFamilyList |
|
1062 |
"the list of font families" |
|
1063 |
||
5466 | 1064 |
|d sav_useXftFontsOnly sav_useXFontsOnly| |
5187 | 1065 |
|
5466 | 1066 |
sav_useXftFontsOnly := UserPreferences current useXftFontsOnly. |
1067 |
sav_useXFontsOnly := UserPreferences current useXFontsOnly. |
|
1068 |
[ |
|
1069 |
UserPreferences current useXftFontsOnly:(xftFontsOnlyHolder value). |
|
1070 |
UserPreferences current useXFontsOnly:false. |
|
5626 | 1071 |
allFonts := device listOfAvailableFonts. |
5466 | 1072 |
] ensure:[ |
1073 |
UserPreferences current useXftFontsOnly:sav_useXftFontsOnly. |
|
1074 |
UserPreferences current useXFontsOnly:sav_useXFontsOnly. |
|
1075 |
]. |
|
5187 | 1076 |
allFonts isNil ifTrue:[^ nil]. |
1077 |
||
1078 |
d := Dictionary new. |
|
1079 |
allFonts do:[:fntDescr | |
|
1080 |
|family| |
|
1081 |
||
1082 |
(combinedFilter isNil or:[combinedFilter value:fntDescr]) ifTrue:[ |
|
1083 |
family := fntDescr family. |
|
1084 |
family isNil ifTrue:[ |
|
5190 | 1085 |
family := fntDescr name ? 'unnamed' |
5187 | 1086 |
]. |
1087 |
(d at:family ifAbsentPut:[Set new]) add:fntDescr |
|
1088 |
] |
|
1089 |
]. |
|
1090 |
fontsPerFamily := d. |
|
1091 |
^ d keys asOrderedCollection sort |
|
1092 |
"/ |
|
1093 |
"/ ^ self graphicsDevice fontFamiliesFiltering:combinedFilter. |
|
3817 | 1094 |
! |
1095 |
||
1096 |
getSizesInFamily:aFamilyName face:face style:style filtering:filter |
|
5187 | 1097 |
|familyFonts faceAndStyleFonts sizes hasScalableFont| |
1098 |
||
1099 |
familyFonts := fontsPerFamily at:aFamilyName ifAbsent:nil. |
|
1100 |
familyFonts isEmptyOrNil ifTrue:[^ nil]. |
|
1101 |
||
1102 |
hasScalableFont := false. |
|
1103 |
||
1104 |
faceAndStyleFonts := |
|
1105 |
familyFonts |
|
1106 |
select:[:fntDescr | |
|
1107 |
(filter isNil or:[filter value:fntDescr]) |
|
1108 |
and:[ fntDescr face = face |
|
1109 |
and:[ fntDescr style = style ]] |
|
1110 |
]. |
|
1111 |
||
1112 |
sizes := |
|
1113 |
faceAndStyleFonts |
|
1114 |
collect:[:fntDescr | |
|
1115 |
fntDescr isScaledFont ifTrue:[ |
|
1116 |
hasScalableFont := true. |
|
1117 |
]. |
|
1118 |
sizeUnit == #px |
|
1119 |
ifTrue:[ fntDescr pixelSize ] |
|
1120 |
ifFalse:[ fntDescr size ] |
|
1121 |
]. |
|
1122 |
||
1123 |
hasScalableFont ifTrue:[ |
|
1124 |
sizeUnit == #px ifTrue:[ |
|
1125 |
^ #(10 16 20 24 28 32 48 56 64 72 80 92 128) |
|
1126 |
]. |
|
1127 |
^ #(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 | 1128 |
]. |
5187 | 1129 |
(sizes size == 1 and:[sizes first == 0]) ifTrue:[ |
1130 |
"/ some font may only be available in certain pixel sizes... |
|
1131 |
sizeUnit == #pt ifTrue:[ |
|
1132 |
^ (faceAndStyleFonts collect:[:fontDescr | fontDescr pixelSize]) asOrderedCollection |
|
1133 |
sort collect:[:sz | sz asString , 'px' ]. |
|
1134 |
]. |
|
1135 |
^ (faceAndStyleFonts collect:[:fontDescr | fontDescr size]) asOrderedCollection |
|
1136 |
sort collect:[:sz | sz asString , 'pt' ]. |
|
1137 |
]. |
|
1138 |
||
1139 |
^ sizes asOrderedCollection sort. |
|
1140 |
||
1141 |
"/ sizeUnit == #px ifTrue:[ |
|
1142 |
"/ ^ self graphicsDevice |
|
1143 |
"/ pixelSizesInFamily:(currentFamily ? '*') |
|
1144 |
"/ face:(currentFace ? '*') |
|
1145 |
"/ style:(currentStyle ? '*') |
|
1146 |
"/ filtering:filter. |
|
1147 |
"/ ] ifFalse:[ |
|
1148 |
"/ ^ self graphicsDevice |
|
1149 |
"/ sizesInFamily:(currentFamily ? '*') |
|
1150 |
"/ face:(currentFace ? '*') |
|
1151 |
"/ style:(currentStyle ? '*') |
|
1152 |
"/ filtering:filter. |
|
1153 |
"/ ]. |
|
3817 | 1154 |
! |
1155 |
||
1156 |
getStylesInFamily:aFamilyName face:aFace filtering:filter |
|
1157 |
"the list of font styles for a given family-face" |
|
1158 |
||
5187 | 1159 |
|familyFonts| |
1160 |
||
1161 |
familyFonts := fontsPerFamily at:aFamilyName ifAbsent:nil. |
|
1162 |
familyFonts isEmptyOrNil ifTrue:[^ nil]. |
|
1163 |
||
1164 |
^ familyFonts |
|
1165 |
select:[:fntDescr | |
|
1166 |
(filter isNil or:[filter value:fntDescr]) |
|
1167 |
and:[fntDescr face = aFace] |
|
1168 |
] |
|
1169 |
thenCollect:[:fntDescr | |
|
1170 |
fntDescr style. |
|
1171 |
] |
|
1172 |
||
1173 |
"/ ^ self graphicsDevice stylesInFamily:aFamilyName face:aFace filtering:filter. |
|
3817 | 1174 |
! |
1175 |
||
197 | 1176 |
showPreview |
595 | 1177 |
"show the preview text" |
1178 |
||
3817 | 1179 |
|font deviceFont enc fontName| |
382 | 1180 |
|
4949 | 1181 |
"/ self clearPreview. |
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
1182 |
|
197 | 1183 |
" |
1184 |
show a wait cursor: for some fonts (kanji etc) the |
|
2890 | 1185 |
X-server needs quite some time to load the font |
197 | 1186 |
" |
255 | 1187 |
self withWaitCursorDo:[ |
3817 | 1188 |
font := self fontForPreview. |
2843 | 1189 |
font notNil ifTrue:[ |
5626 | 1190 |
deviceFont := font onDevice:device. |
2890 | 1191 |
enc := deviceFont encoding. |
2916 | 1192 |
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
|
1193 |
|
2874 | 1194 |
previewField font:deviceFont. |
1195 |
previewField characterEncoding:enc. |
|
1196 |
||
2287
b33ad40d7538
preview fixed when font is bad
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
1197 |
encodingLabel label:enc. |
2843 | 1198 |
currentEncoding := enc. |
1199 |
fontName := deviceFont fullName. |
|
5577 | 1200 |
font isXftFont ifTrue:[fontName := fontName,' (xft)']. |
4951 | 1201 |
previewField contents:(font userFriendlyName,'\\' withCRs,(self class defaultSampleStringForEncoding:enc) asString). |
382 | 1202 |
] ifFalse:[ |
2842 | 1203 |
previewField contents:nil. |
1204 |
encodingLabel label:nil. |
|
2843 | 1205 |
currentEncoding := nil. |
2842 | 1206 |
fontName := nil. |
382 | 1207 |
]. |
2842 | 1208 |
nameLabel notNil ifTrue:[nameLabel label:fontName]. |
197 | 1209 |
] |
255 | 1210 |
|
1257 | 1211 |
"Modified: 30.6.1997 / 17:26:22 / cg" |
197 | 1212 |
! |
1213 |
||
128 | 1214 |
showSelectedFont |
2843 | 1215 |
|fam face faceAndStyle style sz| |
128 | 1216 |
|
1217 |
fam := selectedFont family. |
|
2843 | 1218 |
currentEncoding := selectedFont encoding. |
1219 |
||
5188 | 1220 |
fontsPerFamily isNil ifTrue:[ |
5466 | 1221 |
self updateFamilyList |
1222 |
"/ self getFamilyList |
|
5188 | 1223 |
]. |
1224 |
||
2888 | 1225 |
self familySelected:fam showPreview:false. |
128 | 1226 |
fam notNil ifTrue:[ |
2842 | 1227 |
face := selectedFont face. |
1228 |
(face notNil and:[(style := selectedFont style) notNil]) ifTrue:[ |
|
1229 |
faceAndStyle := face , '-' , style. |
|
1230 |
]. |
|
2888 | 1231 |
self faceSelected:faceAndStyle showPreview:false. |
2842 | 1232 |
faceAndStyle notNil ifTrue:[ |
5188 | 1233 |
sz := sizeUnit == #px ifTrue:[selectedFont pixelSize asString,'px'] ifFalse:[selectedFont size asString]. |
3841 | 1234 |
pixelPointSwitch contents:sizeUnit. |
2888 | 1235 |
self sizeSelected:sz showPreview:false. |
2842 | 1236 |
] |
1237 |
]. |
|
2888 | 1238 |
|
1239 |
self showPreview |
|
2826 | 1240 |
! |
1241 |
||
1242 |
updateFamilyList |
|
1243 |
"update the list of font families" |
|
1244 |
||
1245 |
|families| |
|
1246 |
||
1247 |
familyList list isNil ifTrue:[ |
|
3817 | 1248 |
families := self getFamilyList. |
2826 | 1249 |
families notNil ifTrue:[ |
4943 | 1250 |
families := families asNewOrderedCollection sort |
2826 | 1251 |
]. |
1252 |
familyList list:families |
|
1253 |
]. |
|
1254 |
selectedFont notNil ifTrue:[ |
|
1255 |
self showSelectedFont |
|
1256 |
]. |
|
1257 |
||
1258 |
"Modified: 27.2.1996 / 01:39:42 / cg" |
|
1259 |
"Created: 27.2.1996 / 01:40:37 / cg" |
|
4944 | 1260 |
! |
1261 |
||
1262 |
updateSizeList |
|
5188 | 1263 |
|sizes sizeStrings oldSize newSize| |
4944 | 1264 |
|
1265 |
sizes := self |
|
1266 |
getSizesInFamily:(currentFamily ? '*') |
|
1267 |
face:(currentFace ? '*') |
|
1268 |
style:(currentStyle ? '*') |
|
1269 |
filtering:combinedFilter. |
|
1270 |
||
1271 |
(sizes isEmptyOrNil) ifTrue:[ |
|
1272 |
sizeList list:nil. |
|
1273 |
currentSize := nil. |
|
1274 |
"/ self halt. |
|
1275 |
^ self |
|
1276 |
]. |
|
1277 |
||
1278 |
sizes := sizes asOrderedCollection. |
|
1279 |
selectedFont notNil ifTrue:[ |
|
4947 | 1280 |
oldSize := currentSize. |
5188 | 1281 |
newSize := (selectedFont sizeUnit == #px) |
4944 | 1282 |
ifTrue:[ selectedFont pixelSize ] |
1283 |
ifFalse:[ selectedFont size ]. |
|
5188 | 1284 |
newSize == 0 ifTrue:[ |
4947 | 1285 |
currentSize := oldSize |
5188 | 1286 |
] ifFalse:[ |
1287 |
currentSize := newSize asString. |
|
1288 |
(selectedFont sizeUnit == #px) ifTrue:[ |
|
1289 |
currentSize := currentSize , 'px' |
|
1290 |
] |
|
4947 | 1291 |
]. |
5187 | 1292 |
"/ currentSize notNil ifTrue:[ |
1293 |
"/ (sizes includes:currentSize) ifFalse:[ |
|
1294 |
"/ sizes add:currentSize |
|
1295 |
"/ ]. |
|
1296 |
"/ ]. |
|
1297 |
]. |
|
1298 |
"/ sizes sort. |
|
1299 |
||
1300 |
sizeStrings := sizes collect:[:entry | entry asString]. |
|
1301 |
sizeList list:sizeStrings. |
|
1302 |
currentSize notNil ifTrue:[ |
|
1303 |
(sizeStrings includes:(currentSize asString)) ifTrue:[ |
|
1304 |
sizeList setSelectElement:currentSize asString. |
|
1305 |
] ifFalse:[ |
|
1306 |
sizeStrings notEmpty ifTrue:[ |
|
1307 |
sizeList setSelectElement:sizeStrings first. |
|
1308 |
currentSize := sizeStrings first. |
|
1309 |
] ifFalse:[ |
|
1310 |
currentSize := nil |
|
4948 | 1311 |
]. |
4944 | 1312 |
]. |
1313 |
]. |
|
1314 |
! |
|
1315 |
||
1316 |
xftFontsOnlyChanged |
|
5900 | 1317 |
self filterChanged. "/ will update combinedFilter |
197 | 1318 |
! ! |
128 | 1319 |
|
197 | 1320 |
!FontPanel methodsFor:'queries'! |
0 | 1321 |
|
3405
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
1322 |
characterSetViewClassAvailable |
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
1323 |
^ CharacterSetView notNil |
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
1324 |
|
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
1325 |
"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
|
1326 |
! |
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
1327 |
|
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
1328 |
characterSetViewClassAvailableOrOSIsUNIX |
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
1329 |
^ 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
|
1330 |
|
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
1331 |
"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
|
1332 |
! |
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
1333 |
|
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
1334 |
osIsUNIX |
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
1335 |
^ OperatingSystem isUNIXlike |
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 |
"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
|
1338 |
! |
9a03bc64e285
dont offer special-character display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3274
diff
changeset
|
1339 |
|
197 | 1340 |
preferredExtent |
595 | 1341 |
"return the boxes preferredExtent" |
572 | 1342 |
|
3769
758f8b0b6cf2
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3740
diff
changeset
|
1343 |
"/ If I have an explicit preferredExtent.. |
758f8b0b6cf2
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3740
diff
changeset
|
1344 |
explicitExtent notNil ifTrue:[ |
758f8b0b6cf2
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3740
diff
changeset
|
1345 |
^ explicitExtent |
758f8b0b6cf2
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3740
diff
changeset
|
1346 |
]. |
797 | 1347 |
|
3769
758f8b0b6cf2
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3740
diff
changeset
|
1348 |
"/ If I have a cached preferredExtent value.. |
713
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
1349 |
preferredExtent notNil ifTrue:[ |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
1350 |
^ preferredExtent |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
1351 |
]. |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
1352 |
|
4944 | 1353 |
"/ ^ 450@350 |
1354 |
^ self class defaultExtent. |
|
572 | 1355 |
|
797 | 1356 |
"Modified: 19.7.1996 / 20:44:08 / cg" |
0 | 1357 |
! ! |
77 | 1358 |
|
5531 | 1359 |
!FontPanel methodsFor:'startup'! |
1360 |
||
1361 |
fontFromUser |
|
1362 |
"open this fontPanel and return the selected font, |
|
1363 |
or nil if abort is pressed" |
|
1364 |
||
1365 |
^ self |
|
1366 |
fontFromUserInitial:nil |
|
1367 |
title:nil |
|
1368 |
filter:nil |
|
1369 |
encoding:nil |
|
1370 |
enabled:true |
|
5903 | 1371 |
withChangeAllOption:false |
5531 | 1372 |
|
1373 |
" |
|
1374 |
FontPanel fontFromUser |
|
1375 |
||
1376 |
FontPanel new |
|
1377 |
withChangeFontInViewsAllCheckBox:true; |
|
1378 |
fontFromUser |
|
1379 |
" |
|
1380 |
||
1381 |
"Modified: 27.2.1996 / 00:51:59 / cg" |
|
1382 |
! |
|
1383 |
||
1384 |
fontFromUserInitial:aFont |
|
1385 |
"open this fontPanel showing aFont initially, |
|
1386 |
and return the selected font, or nil if abort is pressed" |
|
1387 |
||
1388 |
^ self |
|
1389 |
fontFromUserInitial:aFont |
|
1390 |
title:nil |
|
1391 |
filter:nil |
|
1392 |
encoding:nil |
|
1393 |
enabled:true |
|
5903 | 1394 |
withChangeAllOption:false |
1395 |
||
5531 | 1396 |
" |
1397 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) |
|
1398 |
FontPanel fontFromUserInitial:MenuPanel defaultFont |
|
1399 |
" |
|
1400 |
! |
|
1401 |
||
1402 |
fontFromUserInitial:aFont title:someTitle |
|
1403 |
"open this fontPanel with title and return the selected font, |
|
1404 |
or nil if abort is pressed" |
|
1405 |
||
1406 |
^ self |
|
1407 |
fontFromUserInitial:aFont |
|
1408 |
title:someTitle |
|
1409 |
filter:nil |
|
1410 |
encoding:nil |
|
1411 |
enabled:true |
|
5903 | 1412 |
withChangeAllOption:false |
1413 |
||
5531 | 1414 |
" |
1415 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font' |
|
1416 |
" |
|
1417 |
||
1418 |
"Created: 27.2.1996 / 00:59:46 / cg" |
|
1419 |
"Modified: 29.4.1996 / 09:45:34 / cg" |
|
1420 |
! |
|
1421 |
||
1422 |
fontFromUserInitial:initialFont title:someTitle filter:aFilterBlock |
|
1423 |
"open this fontPanel with title and font-filter |
|
1424 |
and return the selected font, or nil if abort is pressed" |
|
1425 |
||
1426 |
^ self |
|
1427 |
fontFromUserInitial:initialFont |
|
1428 |
title:someTitle |
|
1429 |
filter:aFilterBlock |
|
1430 |
encoding:nil |
|
1431 |
enabled:true |
|
5903 | 1432 |
withChangeAllOption:false |
1433 |
||
5531 | 1434 |
" |
1435 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font' |
|
1436 |
" |
|
1437 |
||
1438 |
"Created: 27.2.1996 / 00:59:46 / cg" |
|
1439 |
"Modified: 10.4.1997 / 09:53:03 / cg" |
|
1440 |
! |
|
1441 |
||
1442 |
fontFromUserInitial:initialFont title:someTitle filter:aFilterBlock encoding:encoding |
|
1443 |
"open this fontPanel with title and font-filter |
|
1444 |
and return the selected font, or nil if abort is pressed" |
|
1445 |
||
1446 |
^ self |
|
1447 |
fontFromUserInitial:initialFont |
|
1448 |
title:someTitle |
|
1449 |
filter:aFilterBlock |
|
1450 |
encoding:encoding |
|
1451 |
enabled:true |
|
5903 | 1452 |
withChangeAllOption:false |
1453 |
||
5531 | 1454 |
" |
1455 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font' |
|
1456 |
" |
|
1457 |
! |
|
1458 |
||
1459 |
fontFromUserInitial:initialFont title:someTitle filter:aFilterBlock encoding:encoding enabled:enabled |
|
1460 |
"open this fontPanel with title and font-filter |
|
1461 |
and return the selected font, or nil if abort is pressed" |
|
1462 |
||
5903 | 1463 |
^ self |
1464 |
fontFromUserInitial:initialFont title:someTitle filter:aFilterBlock encoding:encoding enabled:enabled |
|
1465 |
withChangeAllOption:false |
|
1466 |
||
1467 |
" |
|
1468 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font'. |
|
1469 |
||
1470 |
FontPanel new |
|
1471 |
withChangeFontInViewsAllCheckBox:true; |
|
1472 |
fontFromUserInitial:(Font family:'courier' size:12) title:'select some font' |
|
1473 |
" |
|
1474 |
||
1475 |
"Created: 27.2.1996 / 00:59:46 / cg" |
|
1476 |
"Modified: 10.4.1997 / 09:53:03 / cg" |
|
1477 |
! |
|
1478 |
||
1479 |
fontFromUserInitial:initialFont title:someTitle filter:aFilterBlock encoding:encoding enabled:enabled withChangeAllOption:changeAllBoolean |
|
1480 |
"open this fontPanel with title and font-filter |
|
1481 |
and return the selected font, or nil if abort is pressed" |
|
1482 |
||
1483 |
|selectedFont initialFontsEncoding| |
|
5531 | 1484 |
|
5900 | 1485 |
self encodingFilter:aFilterBlock. |
5531 | 1486 |
someTitle notNil ifTrue:[ |
1487 |
self label:someTitle |
|
1488 |
]. |
|
1489 |
self action:[:aFontDescription | selectedFont := aFontDescription]. |
|
1490 |
initialFont notNil ifTrue:[ |
|
1491 |
self initialFont:initialFont. |
|
1492 |
]. |
|
1493 |
encoding notNil ifTrue:[ |
|
1494 |
self encoding:encoding. |
|
1495 |
] ifFalse:[ |
|
1496 |
initialFont notNil ifTrue:[ |
|
5903 | 1497 |
initialFontsEncoding := initialFont encoding. |
1498 |
((initialFontsEncoding = #'iso8859-1') |
|
1499 |
or:[ (initialFontsEncoding = #'iso10646-1') ]) ifFalse:[ |
|
1500 |
self encoding:initialFontsEncoding |
|
5900 | 1501 |
]. |
5531 | 1502 |
]. |
1503 |
]. |
|
1504 |
self enabled:enabled. |
|
5903 | 1505 |
self withChangeFontInAllViewsCheckBoxVisibleHolder value:changeAllBoolean. |
5531 | 1506 |
self showAtPointer. |
5903 | 1507 |
|
5531 | 1508 |
self destroy. |
1509 |
^ selectedFont |
|
1510 |
||
1511 |
" |
|
1512 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font'. |
|
1513 |
||
1514 |
FontPanel new |
|
1515 |
withChangeFontInViewsAllCheckBox:true; |
|
1516 |
fontFromUserInitial:(Font family:'courier' size:12) title:'select some font' |
|
1517 |
" |
|
1518 |
||
1519 |
"Created: 27.2.1996 / 00:59:46 / cg" |
|
1520 |
"Modified: 10.4.1997 / 09:53:03 / cg" |
|
1521 |
! ! |
|
1522 |
||
77 | 1523 |
!FontPanel methodsFor:'user interaction'! |
1524 |
||
3604 | 1525 |
copyFontName |
1526 |
self setClipboardText:(previewField font storeString). |
|
1527 |
! |
|
1528 |
||
2826 | 1529 |
encodingFilterSelected:anEncodingPattern |
1530 |
"another encoding was selected; find available fonts and update lists" |
|
1531 |
||
1532 |
|pattern| |
|
1533 |
||
2887 | 1534 |
anEncodingPattern isNil ifTrue:[ |
5900 | 1535 |
self encodingFilter:nil. |
2887 | 1536 |
^ self. |
1537 |
]. |
|
1538 |
||
2878 | 1539 |
pattern := (anEncodingPattern upTo:$( ) withoutSeparators. |
1540 |
||
1541 |
pattern = '?' ifTrue:[ |
|
2845 | 1542 |
pattern := '' |
1543 |
] ifFalse:[ |
|
2878 | 1544 |
pattern := (pattern isEmptyOrNil ifTrue:'*' ifFalse:pattern). |
2845 | 1545 |
]. |
2826 | 1546 |
self |
5900 | 1547 |
encodingFilter: |
2826 | 1548 |
[:f | |
3899
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1549 |
|doesMatch encoding| |
2826 | 1550 |
|
3899
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1551 |
"/ k&d hack for mswindows names... |
3848 | 1552 |
"/ Transcript showCR:f encoding. |
3899
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1553 |
encoding := f encoding ? ''. |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1554 |
doesMatch := (pattern match:encoding). |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1555 |
doesMatch ifFalse:[ |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1556 |
encoding = 'ms-ansi' ifTrue:[ |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1557 |
doesMatch := (pattern = 'iso8859-1') |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1558 |
or:[ (pattern = 'iso10646-1') |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1559 |
or:[ (pattern = 'unicode') ]] |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1560 |
]. |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1561 |
(encoding = 'iso8859-1' |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1562 |
or:[encoding = 'iso10646-1' |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1563 |
or:[encoding = 'unicode']]) ifTrue:[ |
5900 | 1564 |
doesMatch := (pattern = 'ms-ansi'). |
1565 |
"/ unicode can show all iso charas as well... |
|
1566 |
doesMatch := doesMatch or:[ pattern = 'iso8859-1' ]. |
|
1567 |
doesMatch := doesMatch or:[ pattern = 'ascii' ]. |
|
3899
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1568 |
]. |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1569 |
]. |
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1570 |
doesMatch |
2826 | 1571 |
]. |
1572 |
! |
|
1573 |
||
197 | 1574 |
faceSelected:aFaceAndStyleName |
2826 | 1575 |
"a fonts face was selected; find available sizes and update lists" |
595 | 1576 |
|
2842 | 1577 |
self faceSelected:aFaceAndStyleName showPreview:true |
1578 |
! |
|
1579 |
||
1580 |
faceSelected:aFaceAndStyleName showPreview:showPreview |
|
1581 |
"a fonts face was selected; find available sizes and update lists" |
|
1582 |
||
3740 | 1583 |
|sizes sizeStrings didShow| |
197 | 1584 |
|
1585 |
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
|
1586 |
self extractFaceAndStyleFrom:aFaceAndStyleName. |
197 | 1587 |
]. |
4944 | 1588 |
self updateSizeList. |
1589 |
showPreview ifTrue:[ |
|
1590 |
self showPreview. |
|
197 | 1591 |
]. |
4944 | 1592 |
^ self. |
1593 |
"/ |
|
1594 |
"/ sizes := self |
|
1595 |
"/ getSizesInFamily:(currentFamily ? '*') |
|
1596 |
"/ face:(currentFace ? '*') |
|
1597 |
"/ style:(currentStyle ? '*') |
|
1598 |
"/ filtering:combinedFilter. |
|
1599 |
"/ |
|
1600 |
"/ (sizes isEmptyOrNil) ifTrue:[ |
|
1601 |
"/ sizeList list:nil. |
|
1602 |
"/ currentSize := nil. |
|
1603 |
"/ self breakPoint:#cg. |
|
1604 |
"/ showPreview ifTrue:[ |
|
1605 |
"/ self showPreview. |
|
1606 |
"/ ]. |
|
1607 |
"/ ^ self |
|
1608 |
"/ ]. |
|
1609 |
"/ |
|
1610 |
"/ didShow := false. |
|
1611 |
"/ |
|
1612 |
"/ sizes := sizes asOrderedCollection. |
|
1613 |
"/ selectedFont notNil ifTrue:[ |
|
1614 |
"/ (sizes includes:selectedFont size) ifFalse:[ |
|
1615 |
"/ sizes add:selectedFont size |
|
1616 |
"/ ]. |
|
1617 |
"/ ]. |
|
1618 |
"/ sizes sort. |
|
1619 |
"/ |
|
1620 |
"/ sizeStrings := sizes collect:[:entry | entry printString]. |
|
1621 |
"/ sizeList list:sizeStrings. |
|
1622 |
"/ currentSize notNil ifTrue:[ |
|
1623 |
"/ (sizeStrings includes:(currentSize printString)) ifTrue:[ |
|
1624 |
"/ sizeList setSelectElement:currentSize printString. |
|
1625 |
"/ showPreview ifTrue:[ |
|
1626 |
"/ self showPreview. |
|
1627 |
"/ didShow := true. |
|
1628 |
"/ ] |
|
1629 |
"/ ] |
|
1630 |
"/ ]. |
|
1631 |
"/ didShow ifFalse:[ |
|
1632 |
"/ self clearPreview |
|
1633 |
"/ ]. |
|
1634 |
"/ |
|
1257 | 1635 |
"Modified: 30.6.1997 / 17:25:46 / cg" |
197 | 1636 |
! |
1637 |
||
77 | 1638 |
familySelected:aFamilyName |
2826 | 1639 |
"a fonts family was selected; find available faces and update lists" |
595 | 1640 |
|
2842 | 1641 |
self familySelected:aFamilyName showPreview:true |
1642 |
! |
|
1643 |
||
1644 |
familySelected:aFamilyName showPreview:showPreview |
|
1645 |
"a fonts family was selected; find available faces and update lists" |
|
1646 |
||
5466 | 1647 |
|familyNameUsed faces styles list idx| |
77 | 1648 |
|
5466 | 1649 |
familyNameUsed := aFamilyName. |
1650 |
||
1651 |
familyList setSelectElement:familyNameUsed. |
|
1652 |
familyList selection isNil ifTrue:[ |
|
1653 |
"/ mhm - maybe lowercase... |
|
1654 |
idx := familyList list indexOf:(familyNameUsed := aFamilyName asUppercaseFirst). |
|
1655 |
idx == 0 ifTrue:[ |
|
1656 |
idx := familyList list indexOf:(familyNameUsed := aFamilyName asLowercaseFirst). |
|
1657 |
]. |
|
1658 |
idx ~~ 0 ifTrue:[ |
|
1659 |
familyList selection:idx. |
|
1660 |
]. |
|
1661 |
]. |
|
1662 |
||
1663 |
currentFamily := familyNameUsed. |
|
1664 |
faces := self getFacesForFamily:currentFamily filtering:combinedFilter. |
|
3899
966270358179
care for different encoding names in windows
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
1665 |
faces isEmptyOrNil ifTrue:[ |
415 | 1666 |
currentFace := currentStyle := currentFaceAndStyle := nil. |
1667 |
faceList list:nil. |
|
2842 | 1668 |
self faceSelected:nil showPreview:showPreview. |
415 | 1669 |
^ self. |
77 | 1670 |
]. |
1671 |
||
2353 | 1672 |
list := SortedCollection new. |
77 | 1673 |
faces do:[:aFace | |
5466 | 1674 |
styles := (self getStylesInFamily:currentFamily face:aFace filtering:combinedFilter) ? #(). |
415 | 1675 |
styles do:[:aStyle | |
5524 | 1676 |
aFace isEmptyOrNil ifTrue:[ |
4944 | 1677 |
list add:(aStyle) |
1678 |
] ifFalse:[ |
|
1679 |
list add:(aFace , '-' , aStyle) |
|
1680 |
] |
|
415 | 1681 |
] |
77 | 1682 |
]. |
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
1683 |
|
77 | 1684 |
faceList list:list. |
1685 |
currentFaceAndStyle notNil ifTrue:[ |
|
5008 | 1686 |
(list includes:currentFaceAndStyle) ifFalse:[ |
1687 |
currentFaceAndStyle = 'normal-roman' ifTrue:[ |
|
1688 |
(list includes:'regular-roman') ifTrue:[ |
|
1689 |
currentFaceAndStyle := 'regular-roman'. |
|
1690 |
currentFace := 'regular'. |
|
1691 |
currentStyle := 'roman'. |
|
1692 |
]. |
|
1693 |
(list includes:'medium-roman') ifTrue:[ |
|
1694 |
currentFaceAndStyle := 'medium-roman'. |
|
1695 |
currentFace := 'medium'. |
|
1696 |
currentStyle := 'roman'. |
|
1697 |
]. |
|
1698 |
]. |
|
1699 |
]. |
|
415 | 1700 |
(list includes:currentFaceAndStyle) ifTrue:[ |
690 | 1701 |
faceList setSelectElement:currentFaceAndStyle. |
2842 | 1702 |
self faceSelected:currentFaceAndStyle showPreview:showPreview. |
415 | 1703 |
^ self |
1704 |
] |
|
77 | 1705 |
]. |
5007 | 1706 |
list notEmptyOrNil ifTrue:[ |
1707 |
"/ faceList setSelectElement:(list first). |
|
1708 |
faceList selectElement:(list first). |
|
1709 |
self faceSelected:(list first) showPreview:showPreview. |
|
5008 | 1710 |
self updateSizeList. |
5007 | 1711 |
^ self |
1712 |
]. |
|
2842 | 1713 |
|
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
1714 |
sizeList list:nil. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
1715 |
self clearPreview. |
415 | 1716 |
|
690 | 1717 |
"Modified: 26.5.1996 / 15:04:29 / cg" |
77 | 1718 |
! |
1719 |
||
5548 | 1720 |
flushListOfAvailableFonts |
5577 | 1721 |
self withWaitCursorDo:[ |
1722 |
"this may take some time, especially with X11 XFT fonts" |
|
5626 | 1723 |
device |
5577 | 1724 |
flushListOfAvailableFonts; |
1725 |
listOfAvailableFonts. |
|
1726 |
||
1727 |
familyList list:nil. |
|
1728 |
self updateFamilyList. |
|
1729 |
]. |
|
5548 | 1730 |
! |
1731 |
||
5900 | 1732 |
fontAttributeFilterChanged |
1733 |
"a filter toggled (decorative/monospaced etc.)" |
|
1734 |
||
1735 |
^ self. |
|
1736 |
! |
|
1737 |
||
77 | 1738 |
okPressed |
595 | 1739 |
"ok was pressed; hide myself and evaluate the okAction, passing |
1740 |
family, face, style and size as arguments" |
|
1741 |
||
5187 | 1742 |
|sz szUnitUsed| |
1743 |
||
1744 |
szUnitUsed := (sizeUnit ? #pt). |
|
1745 |
sz := Number readFrom:currentSize. |
|
5577 | 1746 |
(currentSize endsWith:#px) ifTrue:[ |
5187 | 1747 |
szUnitUsed := #px |
1748 |
]. |
|
1749 |
||
77 | 1750 |
self hide. |
1751 |
okAction notNil ifTrue:[ |
|
410 | 1752 |
currentFamily notNil ifTrue:[ |
4946 | 1753 |
okAction value: |
5626 | 1754 |
(((device supportsXftFonts and:[self xftFontsOnlyHolder value]) |
4946 | 1755 |
ifTrue:[XftFontDescription] |
1756 |
ifFalse:[FontDescription]) |
|
1757 |
family:currentFamily |
|
1758 |
face:currentFace |
|
1759 |
style:currentStyle |
|
5187 | 1760 |
size:sz |
1761 |
sizeUnit:szUnitUsed |
|
4946 | 1762 |
encoding:(currentEncoding ? encoding)). |
410 | 1763 |
] |
77 | 1764 |
] |
410 | 1765 |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
1766 |
"Modified: 10.4.1997 / 09:51:31 / cg" |
77 | 1767 |
! |
1768 |
||
2852 | 1769 |
previewCopySelection |
1770 |
previewField copySelection. |
|
1771 |
! |
|
1772 |
||
2935 | 1773 |
previewInspectFont |
1774 |
previewField font inspect. |
|
1775 |
! |
|
1776 |
||
2852 | 1777 |
previewShowCharacterSet |
1778 |
CharacterSetView openOn:(previewField font) |
|
1779 |
! |
|
1780 |
||
2875 | 1781 |
previewShowCharacterSetUsingXFD |
2878 | 1782 |
[ |
1783 |
OperatingSystem executeCommand:'xfd -fn ' , previewField font fullName. |
|
1784 |
] fork. |
|
2875 | 1785 |
! |
1786 |
||
77 | 1787 |
sizeSelected:aNumberOrString |
2826 | 1788 |
"a size was selected; update preview" |
595 | 1789 |
|
2842 | 1790 |
self sizeSelected:aNumberOrString showPreview:true. |
1791 |
! |
|
1792 |
||
1793 |
sizeSelected:aNumberOrString showPreview:showPreview |
|
1794 |
"a size was selected; update preview" |
|
1795 |
||
5187 | 1796 |
currentSize := aNumberOrString. |
1797 |
"/ aNumberOrString isNumber ifFalse:[ |
|
1798 |
"/ currentSize := Number readFromString:aNumberOrString onError:nil |
|
1799 |
"/ ]. |
|
2842 | 1800 |
showPreview ifTrue:[self showPreview] |
595 | 1801 |
|
1802 |
"Modified: 29.4.1996 / 09:43:23 / cg" |
|
3832 | 1803 |
! |
1804 |
||
1805 |
sizeUnitSelected:unitSymbol |
|
1806 |
sizeUnit := unitSymbol. |
|
1807 |
sizeLabelHolder value:(resources |
|
3837 | 1808 |
string:(sizeUnit == #px |
3832 | 1809 |
ifTrue:'Size (px)' |
1810 |
ifFalse:'Size')). |
|
3834 | 1811 |
|
1812 |
self showPreview |
|
77 | 1813 |
! ! |
197 | 1814 |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
1815 |
!FontPanel class methodsFor:'documentation'! |
243 | 1816 |
|
1817 |
version |
|
5446 | 1818 |
^ '$Header$' |
4094 | 1819 |
! |
1820 |
||
1821 |
version_CVS |
|
5446 | 1822 |
^ '$Header$' |
243 | 1823 |
! ! |
4660 | 1824 |