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