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