author | ca |
Wed, 10 Mar 2004 16:46:12 +0100 | |
changeset 2936 | 896c043be258 |
parent 2935 | a710dcaf4651 |
child 2937 | cee2b9a5e360 |
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 |
" |
|
12 |
||
77 | 13 |
|
14 |
||
2275 | 15 |
"{ Package: 'stx:libwidg' }" |
16 |
||
77 | 17 |
DialogBox subclass:#FontPanel |
2878 | 18 |
instanceVariableNames:'previewField listOfEncodings familyList faceList sizeList |
19 |
revertButton currentFamily currentFace currentStyle |
|
20 |
currentFaceAndStyle currentSize currentEncoding selectedFont |
|
21 |
nameLabel encodingFilter encodingLabel filter encoding' |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
22 |
classVariableNames:'' |
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
23 |
poolDictionaries:'' |
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
24 |
category:'Views-DialogBoxes' |
0 | 25 |
! |
26 |
||
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
27 |
!FontPanel class methodsFor:'documentation'! |
77 | 28 |
|
197 | 29 |
copyright |
30 |
" |
|
31 |
COPYRIGHT (c) 1991 by Claus Gittinger |
|
32 |
All Rights Reserved |
|
33 |
||
34 |
This software is furnished under a license and may be used |
|
35 |
only in accordance with the terms of that license and with the |
|
36 |
inclusion of the above copyright notice. This software may not |
|
37 |
be provided or otherwise made available to, or used by, any |
|
38 |
other person. No title to or ownership of the software is |
|
39 |
hereby transferred. |
|
40 |
" |
|
41 |
||
42 |
||
77 | 43 |
! |
44 |
||
45 |
documentation |
|
46 |
" |
|
47 |
this class implements a font chooser. |
|
48 |
||
2826 | 49 |
Notice: |
50 |
this is a very old dialog; |
|
51 |
it was written before the UI-framework was available and is completely |
|
52 |
setup manually (initialize method). |
|
53 |
Therefore, it desperately asks to be rewritten using the UIPainter... |
|
54 |
||
595 | 55 |
[author:] |
56 |
Claus Gittinger |
|
57 |
||
58 |
[see also:] |
|
59 |
Font FontDescription |
|
60 |
View Dialog |
|
61 |
" |
|
62 |
! |
|
63 |
||
64 |
examples |
|
65 |
" |
|
66 |
very simple: |
|
67 |
[exBegin] |
|
68 |
|font| |
|
69 |
||
70 |
font := FontPanel fontFromUser. |
|
655 | 71 |
Transcript showCR:font |
595 | 72 |
[exEnd] |
73 |
||
74 |
||
75 |
with initial font: |
|
76 |
[exBegin] |
|
77 |
|font| |
|
78 |
||
79 |
font := FontPanel |
|
80 |
fontFromUserInitial:(Font |
|
81 |
family:'courier' |
|
82 |
size:12). |
|
655 | 83 |
Transcript showCR:font |
595 | 84 |
[exEnd] |
85 |
||
86 |
||
87 |
with initial font & title: |
|
88 |
[exBegin] |
|
89 |
|font| |
|
90 |
||
91 |
font := FontPanel |
|
92 |
fontFromUserInitial:(Font |
|
93 |
family:'courier' |
|
94 |
size:12) |
|
95 |
title:'select a fooBar font'. |
|
655 | 96 |
Transcript showCR:font |
595 | 97 |
[exEnd] |
98 |
||
99 |
||
100 |
full setup; setting a filter to only present iso fonts |
|
101 |
and callBack action: |
|
102 |
[exBegin] |
|
0 | 103 |
|
585 | 104 |
|panel| |
77 | 105 |
|
585 | 106 |
panel := FontPanel new. |
595 | 107 |
panel label:'hi there - which iso font ?'. |
108 |
panel filter:[:fd | fd encoding notNil |
|
109 |
and:[fd encoding startsWith:'iso']]. |
|
110 |
panel action:[:family :face :style :size | |
|
655 | 111 |
Transcript showCR:'family:' , family. |
112 |
Transcript showCR:'face:' , face. |
|
113 |
Transcript showCR:'style:' , style. |
|
114 |
Transcript showCR:'size:' , size printString. |
|
595 | 115 |
]. |
116 |
panel open |
|
117 |
[exEnd] |
|
77 | 118 |
" |
119 |
! ! |
|
0 | 120 |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
121 |
!FontPanel class methodsFor:'defaults'! |
0 | 122 |
|
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
123 |
defaultAsciiSampleString |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
124 |
^ (self sampleStringWithAllLetters) , ' |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
125 |
|
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
126 |
ABCDEFGHIJKLMNOPQRSTUVWXYZ |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
127 |
abcdefghijklmnopqrstuvwxyz |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
128 |
1234567890 !!@#$%^&*(){}[]:"~;,./<>? |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
129 |
' |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
130 |
! |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
131 |
|
197 | 132 |
defaultExtent |
571 | 133 |
"return the default extent of my instances. |
134 |
The value returned here is usually ignored, and |
|
135 |
the value from preferredExtent taken instead." |
|
136 |
||
2842 | 137 |
^ (Screen current pixelPerMillimeter * (150 @ 100)) rounded |
571 | 138 |
|
139 |
"Modified: 22.4.1996 / 23:36:19 / cg" |
|
197 | 140 |
! |
141 |
||
2860 | 142 |
defaultJIS0201SampleString |
143 |
"return the sample jis preview text" |
|
144 |
||
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
145 |
^ (self defaultLatin1SampleString). |
2860 | 146 |
! |
147 |
||
382 | 148 |
defaultJISSampleString |
595 | 149 |
"return the sample jis preview text" |
150 |
||
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
151 |
^ |
2888 | 152 |
'The quick brown fox |
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
153 |
jumps over the lazy dog. |
2860 | 154 |
|
2936 | 155 |
' , (UnicodeString fromString:(#(16r65E5 16r672C 16r8A9E) collect:[:c | Character value:c])) |
382 | 156 |
! |
157 |
||
2847 | 158 |
defaultLatin1SampleString |
159 |
"return the sample latin1 preview text" |
|
160 |
||
2935 | 161 |
^ (self defaultAsciiSampleString) , 'äöüÄÖÜßéèêå©' |
2847 | 162 |
! |
163 |
||
2899 | 164 |
defaultSampleStringForEncoding:enc |
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
165 |
|string lines| |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
166 |
|
2899 | 167 |
enc notNil ifTrue:[ |
168 |
((enc startsWith:'unicode') or:[enc startsWith:'iso10646-']) ifTrue:[ |
|
169 |
^ self defaultUnicodeSampleString. |
|
170 |
]. |
|
171 |
(enc startsWith:'ms-ansi') ifTrue:[ |
|
172 |
^ self defaultUnicodeSampleString. |
|
173 |
]. |
|
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
174 |
|
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
175 |
(enc startsWith:'jis') ifTrue:[ |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
176 |
(enc includesString:'0201') ifTrue:[ |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
177 |
string := self defaultJIS0201SampleString |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
178 |
] ifFalse:[ |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
179 |
string := self defaultJISSampleString |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
180 |
] |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
181 |
] ifFalse:[ |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
182 |
] |
2899 | 183 |
]. |
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
184 |
string isNil ifTrue:[ |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
185 |
string := self defaultLatin1SampleString. |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
186 |
]. |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
187 |
lines := string asStringCollection. |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
188 |
Error handle:[:ex | |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
189 |
] do:[ |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
190 |
lines := lines encodeFrom:#unicode into:enc |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
191 |
]. |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
192 |
^ lines. |
2899 | 193 |
! |
194 |
||
2847 | 195 |
defaultUnicodeSampleString |
196 |
"return the sample unicode preview text" |
|
595 | 197 |
|
2275 | 198 |
|t| |
199 |
||
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
200 |
t := (self defaultAsciiSampleString) , ' |
2935 | 201 |
diaresis: äöüÄÖÜß |
202 |
accent: éèêåÅ |
|
2936 | 203 |
cyrillic: ' , (UnicodeString fromString:(#(16r420 16r443 16r441 16r441 16r43A 16r43E) collect:[:c | Character value:c])) , ' |
2933 | 204 |
greek: ' , |
205 |
(UnicodeString fromString:(#(16r395 16r3BB 16r3BB 16r3B7 16r3BD 16r3B9 16r3BA 16r3AC) collect:[:c | Character value:c])) , |
|
206 |
' |
|
207 |
japanese: ' , |
|
208 |
(UnicodeString fromString:(#(16r65E5 16r672C 16r8A9E) collect:[:c | Character value:c])) , |
|
209 |
' |
|
210 |
'. |
|
2276 | 211 |
^ t |
2933 | 212 |
|
213 |
"Modified: 29.4.1996 / 09:46:19 / cg" |
|
2930
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
214 |
! |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
215 |
|
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
216 |
sampleStringWithAllLetters |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
217 |
^ (self classResources at:'CHARSET_TEST_SENTENCE' ifAbsent:'The quick brown fox jumps over the lazy dog') withCRs |
0 | 218 |
! ! |
219 |
||
2852 | 220 |
!FontPanel class methodsFor:'menu specs'! |
221 |
||
222 |
previewMenu |
|
223 |
"This resource specification was automatically generated |
|
224 |
by the MenuEditor of ST/X." |
|
225 |
||
226 |
"Do not manually edit this!! If it is corrupted, |
|
227 |
the MenuEditor may not be able to read the specification." |
|
228 |
||
229 |
" |
|
230 |
MenuEditor new openOnClass:FontPanel andSelector:#previewMenu |
|
231 |
(Menu new fromLiteralArrayEncoding:(FontPanel previewMenu)) startUp |
|
232 |
" |
|
233 |
||
234 |
<resource: #menu> |
|
235 |
||
236 |
^ |
|
237 |
#(Menu |
|
238 |
( |
|
239 |
(MenuItem |
|
240 |
label: 'Copy' |
|
241 |
itemValue: previewCopySelection |
|
242 |
translateLabel: true |
|
243 |
) |
|
244 |
(MenuItem |
|
245 |
label: '-' |
|
246 |
) |
|
247 |
(MenuItem |
|
248 |
label: 'Show Character Set' |
|
249 |
itemValue: previewShowCharacterSet |
|
250 |
translateLabel: true |
|
251 |
) |
|
2875 | 252 |
(MenuItem |
253 |
label: 'Show Character Set (Using xfd)' |
|
254 |
itemValue: previewShowCharacterSetUsingXFD |
|
255 |
translateLabel: true |
|
256 |
isVisible: false |
|
257 |
) |
|
2935 | 258 |
(MenuItem |
259 |
label: '-' |
|
260 |
) |
|
261 |
(MenuItem |
|
262 |
label: 'Inspect Font' |
|
263 |
itemValue: previewInspectFont |
|
264 |
translateLabel: true |
|
265 |
) |
|
2852 | 266 |
) |
267 |
nil |
|
268 |
nil |
|
269 |
) |
|
270 |
! ! |
|
271 |
||
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
272 |
!FontPanel class methodsFor:'startup'! |
0 | 273 |
|
274 |
fontFromUser |
|
77 | 275 |
"open a fontPanel and return the selected font, or nil |
276 |
if abort is pressed" |
|
277 |
||
410 | 278 |
^ self fontFromUserInitial:nil |
279 |
||
280 |
" |
|
281 |
FontPanel fontFromUser |
|
282 |
" |
|
283 |
||
284 |
"Modified: 27.2.1996 / 00:51:59 / cg" |
|
285 |
! |
|
286 |
||
287 |
fontFromUserInitial:aFont |
|
595 | 288 |
"open a fontPanel showing aFont initially, |
289 |
and return the selected font, or nil if abort is pressed" |
|
410 | 290 |
|
413 | 291 |
^ self fontFromUserInitial:aFont title:nil |
292 |
||
293 |
" |
|
294 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) |
|
295 |
" |
|
296 |
||
297 |
"Created: 27.2.1996 / 00:51:44 / cg" |
|
595 | 298 |
"Modified: 29.4.1996 / 09:45:52 / cg" |
413 | 299 |
! |
300 |
||
301 |
fontFromUserInitial:aFont title:someTitle |
|
595 | 302 |
"open a fontPanel with title and return the selected font, |
303 |
or nil if abort is pressed" |
|
413 | 304 |
|
415 | 305 |
^ self fontFromUserInitial:aFont title:someTitle filter:nil |
306 |
||
307 |
" |
|
308 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font' |
|
309 |
" |
|
310 |
||
311 |
"Created: 27.2.1996 / 00:59:46 / cg" |
|
595 | 312 |
"Modified: 29.4.1996 / 09:45:34 / cg" |
415 | 313 |
! |
314 |
||
2849 | 315 |
fontFromUserInitial:initialFont title:someTitle filter:aFilterBlock |
595 | 316 |
"open a fontPanel with title and font-filter |
317 |
and return the selected font, or nil if abort is pressed" |
|
415 | 318 |
|
2887 | 319 |
^ self fontFromUserInitial:initialFont title:someTitle filter:aFilterBlock encoding:nil |
320 |
||
321 |
" |
|
322 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font' |
|
323 |
" |
|
324 |
||
325 |
"Created: 27.2.1996 / 00:59:46 / cg" |
|
326 |
"Modified: 10.4.1997 / 09:53:03 / cg" |
|
327 |
! |
|
328 |
||
329 |
fontFromUserInitial:initialFont title:someTitle filter:aFilterBlock encoding:encoding |
|
330 |
"open a fontPanel with title and font-filter |
|
331 |
and return the selected font, or nil if abort is pressed" |
|
332 |
||
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
333 |
|fontPanel selectedFont| |
77 | 334 |
|
0 | 335 |
fontPanel := FontPanel new. |
415 | 336 |
fontPanel filter:aFilterBlock. |
413 | 337 |
someTitle notNil ifTrue:[ |
338 |
fontPanel label:someTitle |
|
339 |
]. |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
340 |
fontPanel action:[:aFontDescription | selectedFont := aFontDescription]. |
2849 | 341 |
initialFont notNil ifTrue:[ |
342 |
fontPanel initialFont:initialFont. |
|
410 | 343 |
]. |
2888 | 344 |
encoding notNil ifTrue:[ |
345 |
fontPanel encoding:encoding. |
|
346 |
]. |
|
410 | 347 |
|
0 | 348 |
fontPanel showAtPointer. |
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
349 |
fontPanel destroy. |
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
350 |
^ selectedFont |
0 | 351 |
|
77 | 352 |
" |
413 | 353 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font' |
77 | 354 |
" |
410 | 355 |
|
413 | 356 |
"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
|
357 |
"Modified: 10.4.1997 / 09:53:03 / cg" |
0 | 358 |
! ! |
359 |
||
360 |
!FontPanel methodsFor:'accessing'! |
|
361 |
||
595 | 362 |
action:aFourArgBlock |
363 |
"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
|
364 |
The block will be evaluated with family, face, style, size and encoding." |
595 | 365 |
|
366 |
okAction := aFourArgBlock |
|
367 |
||
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
368 |
"Modified: 10.4.1997 / 09:49:58 / cg" |
197 | 369 |
! |
370 |
||
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
371 |
encoding:aPattern |
595 | 372 |
"set the encoding goal" |
373 |
||
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
374 |
encoding := aPattern. |
2843 | 375 |
encodingFilter contents:encoding. |
376 |
||
377 |
self encodingFilterSelected:encoding. |
|
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
378 |
shown ifTrue:[ |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
379 |
self updateFamilyList |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
380 |
]. |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
381 |
|
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
382 |
"Created: 29.2.1996 / 04:05:31 / cg" |
595 | 383 |
"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
|
384 |
! |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
385 |
|
415 | 386 |
filter:aOneArgBlock |
595 | 387 |
"set a filter; if non-nil, only fonts for which the filterBlock |
388 |
returns true will be offered" |
|
389 |
||
415 | 390 |
filter := aOneArgBlock. |
2826 | 391 |
familyList list:nil. |
415 | 392 |
shown ifTrue:[ |
393 |
self updateFamilyList |
|
394 |
]. |
|
395 |
||
396 |
"Created: 27.2.1996 / 01:40:08 / cg" |
|
595 | 397 |
"Modified: 29.4.1996 / 09:40:49 / cg" |
415 | 398 |
! |
399 |
||
0 | 400 |
initialFont:aFont |
128 | 401 |
"set the font to be selected initially" |
0 | 402 |
|
2849 | 403 |
|encoding| |
404 |
||
128 | 405 |
selectedFont := aFont. |
2849 | 406 |
encoding := aFont encoding. |
407 |
"/ self halt. |
|
408 |
encodingFilter contents:encoding. |
|
409 |
self encodingFilterSelected:encoding. |
|
382 | 410 |
self showSelectedFont. |
411 |
self showPreview |
|
412 |
||
413 |
"Modified: 23.2.1996 / 00:51:32 / cg" |
|
101 | 414 |
! ! |
415 |
||
77 | 416 |
!FontPanel methodsFor:'initialization'! |
417 |
||
418 |
initialize |
|
382 | 419 |
|familyLabel faceLabel sizeLabel panel fontBrowserView v1 v2 v3 |
2847 | 420 |
mm fH eH l box showFontNameLabel| |
77 | 421 |
|
422 |
super initialize. |
|
423 |
||
2847 | 424 |
showFontNameLabel := device platformName ~= 'WIN32'. |
425 |
||
382 | 426 |
mm := ViewSpacing. |
427 |
||
1763 | 428 |
self addAbortAndOkButtons. |
77 | 429 |
|
390
1d54a9b41463
say Hello world in JIS font ;-)
Claus Gittinger <cg@exept.de>
parents:
382
diff
changeset
|
430 |
panel := View origin:0.0@0.0 corner:1.0@1.0 in:self. |
2847 | 431 |
panel bottomInset:(buttonPanel preferredExtent y |
432 |
+ (mm*3) |
|
433 |
+ (showFontNameLabel ifTrue:24 ifFalse:0) ). |
|
77 | 434 |
|
150 | 435 |
label := resources string:'Font dialog'. |
77 | 436 |
|
2842 | 437 |
box := HorizontalPanelView in:panel. |
438 |
box horizontalLayout:#leftFit. |
|
439 |
box origin:0.0@1.0 corner:0.6@1.0. |
|
440 |
||
441 |
l := Label label:(resources string:'Encoding:') in:box. |
|
442 |
l borderWidth:0. |
|
443 |
l adjust:#left. |
|
444 |
||
445 |
encodingFilter := ComboBoxView in:box. |
|
2826 | 446 |
encodingFilter level:-1. |
447 |
encodingFilter contents:'*'. |
|
2842 | 448 |
encodingFilter list:(self listOfEncodingsInFilterCombo). |
2826 | 449 |
encodingFilter action:[:pattern | self encodingFilterSelected:pattern]. |
450 |
encodingFilter immediateAccept:true. |
|
2842 | 451 |
encodingFilter font:l font. |
452 |
encodingFilter editor font:l font. |
|
453 |
||
454 |
eH := encodingFilter preferredExtent y. |
|
455 |
box topInset:(eH negated-1); horizontalInset:mm. |
|
456 |
||
2826 | 457 |
"/ encodingFilter acceptOnReturn:true. |
458 |
"/ encodingFilter acceptOnTab:true. |
|
459 |
"/ encodingFilter acceptOnLeave:true. |
|
460 |
"/ encodingFilter acceptOnLostFocus:true. |
|
461 |
"/ encodingFilter acceptOnPointerLeave:true. |
|
462 |
||
382 | 463 |
encodingLabel := Label label:' ' in:panel. |
2842 | 464 |
"/ eH := encodingLabel preferredExtent y. |
465 |
encodingLabel origin:0.6@1.0 corner:1.0@1.0. |
|
382 | 466 |
encodingLabel topInset:(eH negated); horizontalInset:mm. |
2842 | 467 |
encodingLabel level:0; adjust:#left. |
468 |
encodingLabel adjust:#right. |
|
382 | 469 |
|
2847 | 470 |
showFontNameLabel ifTrue:[ |
471 |
nameLabel := Label label:'' in:self. |
|
472 |
nameLabel origin:0.0@1.0 corner:1.0@1.0. |
|
473 |
nameLabel bottomInset:(buttonPanel preferredExtent y + (mm*2)). |
|
474 |
nameLabel topInset:(buttonPanel preferredExtent y + (mm*2) + 24) negated; horizontalInset:mm. |
|
475 |
nameLabel level:0; adjust:#left. |
|
476 |
nameLabel font:(FontDescription family:'helvetica' face:'medium' style:'roman' size:9). |
|
477 |
]. |
|
382 | 478 |
|
2842 | 479 |
previewField := HVScrollableView for:TextView in:panel. |
480 |
previewField origin:0.0@0.0 corner:1.0@0.4. |
|
481 |
previewField autoHideScrollBars:true. |
|
482 |
previewField := previewField scrolledView. |
|
382 | 483 |
previewField inset:mm. |
77 | 484 |
|
485 |
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
|
486 |
previewField level:-1. |
77 | 487 |
] ifFalse:[ |
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
488 |
previewField borderWidth:1. |
77 | 489 |
]. |
490 |
||
390
1d54a9b41463
say Hello world in JIS font ;-)
Claus Gittinger <cg@exept.de>
parents:
382
diff
changeset
|
491 |
fontBrowserView := View origin:0.0@0.4 corner:1.0@1.0 in:panel. |
382 | 492 |
fontBrowserView bottomInset:(eH + mm). |
77 | 493 |
|
494 |
v1 := View origin:0.0@0.0 corner:0.4@1.0 in:fontBrowserView. |
|
495 |
||
2842 | 496 |
familyLabel := Label label:(resources string:'Family') in:v1. |
77 | 497 |
familyLabel borderWidth:0. |
498 |
familyLabel origin:(0.0 @ 0.0) extent:(1.0 @ nil). |
|
382 | 499 |
fH := familyLabel preferredExtent y. |
77 | 500 |
|
501 |
familyList := ScrollableView for:SelectionInListView in:v1. |
|
382 | 502 |
familyList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
503 |
familyList inset:mm. |
|
504 |
familyList topInset:fH. |
|
505 |
||
128 | 506 |
familyList := familyList scrolledView. |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
507 |
self makeTabable:familyList. |
77 | 508 |
|
509 |
v2 := View origin:0.4@0.0 corner:0.8@1.0 |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
510 |
in:fontBrowserView. |
77 | 511 |
|
2842 | 512 |
faceLabel := Label label:(resources string:'Typeface') in:v2. |
77 | 513 |
faceLabel borderWidth:0. |
514 |
faceLabel origin:(0.0 @ 0.0) extent:(1.0 @ nil). |
|
515 |
||
516 |
faceList := ScrollableView for:SelectionInListView in:v2. |
|
382 | 517 |
faceList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
518 |
faceList inset:mm. |
|
519 |
faceList topInset:fH. |
|
128 | 520 |
faceList := faceList scrolledView. |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
521 |
self makeTabable:faceList. |
77 | 522 |
|
2842 | 523 |
v3 := View origin:0.8@0.0 corner:1.0@1.0 in:fontBrowserView. |
77 | 524 |
|
2842 | 525 |
sizeLabel := Label label:(resources string:'Size') in:v3. |
77 | 526 |
sizeLabel borderWidth:0. |
527 |
sizeLabel origin:(0.0 @ 0.0)extent:(1.0 @ nil). |
|
528 |
||
529 |
sizeList := ScrollableView for:SelectionInListView in:v3. |
|
382 | 530 |
sizeList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
531 |
sizeList inset:mm. |
|
532 |
sizeList topInset:fH. |
|
128 | 533 |
sizeList := sizeList scrolledView. |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
534 |
self makeTabable:sizeList. |
77 | 535 |
|
536 |
familyList action:[:lineNr | self familySelected:(familyList selectionValue)]. |
|
537 |
faceList action:[:lineNr | self faceSelected:(faceList selectionValue)]. |
|
538 |
sizeList action:[:lineNr | self sizeSelected:(sizeList selectionValue)]. |
|
539 |
||
2852 | 540 |
previewField menuHolder:self previewMenu. |
541 |
||
77 | 542 |
" |
543 |
FontPanel new showAtPointer |
|
544 |
" |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
545 |
|
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
546 |
"Modified: 31.5.1996 / 22:01:45 / cg" |
77 | 547 |
! |
548 |
||
2842 | 549 |
listOfEncodingsInFilterCombo |
2878 | 550 |
|availableEncodings listPresentedToUser| |
2842 | 551 |
|
2878 | 552 |
listOfEncodings := OrderedCollection new. |
2849 | 553 |
device platformName = 'WIN32' ifTrue:[ |
2878 | 554 |
listOfEncodings |
2849 | 555 |
addAll: |
556 |
#( |
|
557 |
'*' |
|
558 |
'ANSI' |
|
559 |
nil |
|
560 |
). |
|
561 |
] ifFalse:[ |
|
2878 | 562 |
listOfEncodings |
2849 | 563 |
addAll: |
564 |
#( |
|
565 |
'*' |
|
566 |
'iso8859*' |
|
567 |
'iso10646-1' |
|
568 |
'jis*' |
|
569 |
nil |
|
570 |
). |
|
571 |
]. |
|
2842 | 572 |
|
573 |
availableEncodings := Set new. |
|
2845 | 574 |
device listOfAvailableFonts do:[:f | availableEncodings add:(f encoding ? '?')]. |
2842 | 575 |
availableEncodings := availableEncodings asSortedCollection. |
2878 | 576 |
listOfEncodings addAll:availableEncodings. |
577 |
||
578 |
listPresentedToUser := listOfEncodings collect:[:enc | |
|
579 |
|encoder userFriendlyName| |
|
580 |
||
2896 | 581 |
(enc notNil and:[enc ~= '*']) ifTrue:[ |
2888 | 582 |
encoder := CharacterEncoder encoderFor:enc ifAbsent:nil. |
2878 | 583 |
encoder notNil ifTrue:[ |
2895 | 584 |
userFriendlyName := encoder userFriendlyNameOfEncoding. |
2878 | 585 |
]. |
586 |
]. |
|
587 |
(userFriendlyName notNil and:[userFriendlyName ~= enc]) ifTrue:[ |
|
588 |
enc , ' (' , userFriendlyName , ')' |
|
589 |
] ifFalse:[ |
|
590 |
enc |
|
591 |
] |
|
592 |
]. |
|
593 |
^ listPresentedToUser. |
|
2842 | 594 |
! |
595 |
||
1277 | 596 |
postRealize |
197 | 597 |
"kludge for sco - xlsfont fails sometimes - try again here" |
598 |
||
415 | 599 |
self updateFamilyList. |
1277 | 600 |
super postRealize |
415 | 601 |
|
602 |
"Modified: 27.2.1996 / 01:40:47 / cg" |
|
1277 | 603 |
"Created: 24.7.1997 / 18:12:42 / cg" |
2852 | 604 |
! |
605 |
||
606 |
previewMenu |
|
607 |
<resource: #programMenu > |
|
608 |
||
609 |
|menu| |
|
610 |
||
611 |
menu := Menu new fromLiteralArrayEncoding:self class previewMenu. |
|
612 |
menu findGuiResourcesIn:self. |
|
613 |
menu receiver:self. |
|
2875 | 614 |
|
615 |
OperatingSystem isUNIXlike ifTrue:[ |
|
616 |
(menu menuItemWithValue:#previewShowCharacterSetUsingXFD) isVisible: true |
|
617 |
]. |
|
2852 | 618 |
^ menu |
77 | 619 |
! ! |
620 |
||
0 | 621 |
!FontPanel methodsFor:'private'! |
622 |
||
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
623 |
clearPreview |
595 | 624 |
"clear the preview subview" |
625 |
||
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
626 |
shown ifTrue:[ |
1297
f5ea02391a59
use #contents: instead of #clear
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
627 |
previewField contents:nil. |
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
628 |
encodingLabel label:''. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
629 |
]. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
630 |
|
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
631 |
"Created: 17.4.1996 / 15:19:16 / cg" |
1297
f5ea02391a59
use #contents: instead of #clear
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
632 |
"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
|
633 |
! |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
634 |
|
197 | 635 |
extractFaceAndStyleFrom:aString |
595 | 636 |
"given a string, extract currentFace and currentStyle" |
637 |
||
197 | 638 |
|index| |
639 |
||
640 |
index := aString indexOf:$-. |
|
641 |
(index ~~ 0) ifTrue:[ |
|
595 | 642 |
currentFaceAndStyle := aString. |
643 |
currentFace := aString copyTo:(index - 1). |
|
644 |
currentStyle := aString copyFrom:(index + 1) |
|
197 | 645 |
] |
646 |
||
595 | 647 |
"Modified: 29.4.1996 / 09:41:47 / cg" |
197 | 648 |
! |
649 |
||
650 |
showPreview |
|
595 | 651 |
"show the preview text" |
652 |
||
2899 | 653 |
|font deviceFont enc allFonts fonts fontName| |
382 | 654 |
|
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
655 |
self clearPreview. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
656 |
|
197 | 657 |
" |
658 |
show a wait cursor: for some fonts (kanji etc) the |
|
2890 | 659 |
X-server needs quite some time to load the font |
197 | 660 |
" |
255 | 661 |
self withWaitCursorDo:[ |
2842 | 662 |
allFonts := device |
1257 | 663 |
fontsInFamily:(currentFamily ? '*') |
664 |
face:(currentFace ? '*') |
|
665 |
style:(currentStyle ? '*') |
|
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
666 |
filtering:filter. |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
667 |
|
2848 | 668 |
fonts := allFonts select:[:f | f size = currentSize]. |
450 | 669 |
fonts notEmpty ifTrue:[ |
2843 | 670 |
font := fonts anElement. |
450 | 671 |
] ifFalse:[ |
2848 | 672 |
"/ mhmh: |
673 |
"/ size=0 is returned for scalable fonts. |
|
674 |
"/ Any size is possible. |
|
450 | 675 |
"/ |
2848 | 676 |
fonts := allFonts select:[:f | f size = 0]. |
450 | 677 |
fonts notEmpty ifTrue:[ |
2843 | 678 |
font := Font family:currentFamily |
450 | 679 |
face:currentFace |
680 |
style:currentStyle |
|
681 |
size:currentSize |
|
682 |
encoding:(fonts anElement encoding). |
|
683 |
] |
|
684 |
]. |
|
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
685 |
|
2843 | 686 |
font notNil ifTrue:[ |
2890 | 687 |
deviceFont := font onDevice:device. |
688 |
enc := deviceFont encoding. |
|
2916 | 689 |
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
|
690 |
|
2874 | 691 |
previewField font:deviceFont. |
692 |
previewField characterEncoding:enc. |
|
693 |
||
2287
b33ad40d7538
preview fixed when font is bad
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
694 |
encodingLabel label:enc. |
2843 | 695 |
currentEncoding := enc. |
696 |
fontName := deviceFont fullName. |
|
2899 | 697 |
previewField contents:(self class defaultSampleStringForEncoding:enc). |
382 | 698 |
] ifFalse:[ |
2842 | 699 |
previewField contents:nil. |
700 |
encodingLabel label:nil. |
|
2843 | 701 |
currentEncoding := nil. |
2842 | 702 |
fontName := nil. |
382 | 703 |
]. |
2842 | 704 |
nameLabel notNil ifTrue:[nameLabel label:fontName]. |
197 | 705 |
] |
255 | 706 |
|
1257 | 707 |
"Modified: 30.6.1997 / 17:26:22 / cg" |
197 | 708 |
! |
709 |
||
128 | 710 |
showSelectedFont |
2843 | 711 |
|fam face faceAndStyle style sz| |
128 | 712 |
|
713 |
fam := selectedFont family. |
|
2843 | 714 |
currentEncoding := selectedFont encoding. |
715 |
||
2888 | 716 |
self familySelected:fam showPreview:false. |
128 | 717 |
fam notNil ifTrue:[ |
2842 | 718 |
face := selectedFont face. |
719 |
(face notNil and:[(style := selectedFont style) notNil]) ifTrue:[ |
|
720 |
faceAndStyle := face , '-' , style. |
|
721 |
]. |
|
2888 | 722 |
self faceSelected:faceAndStyle showPreview:false. |
2842 | 723 |
faceAndStyle notNil ifTrue:[ |
724 |
sz := selectedFont size. |
|
2888 | 725 |
self sizeSelected:sz showPreview:false. |
2842 | 726 |
] |
727 |
]. |
|
2888 | 728 |
|
729 |
self showPreview |
|
2826 | 730 |
! |
731 |
||
732 |
updateFamilyList |
|
733 |
"update the list of font families" |
|
734 |
||
735 |
|families| |
|
736 |
||
737 |
familyList list isNil ifTrue:[ |
|
738 |
families := device fontFamiliesFiltering:filter. |
|
739 |
families notNil ifTrue:[ |
|
740 |
families := families asOrderedCollection sort |
|
741 |
]. |
|
742 |
familyList list:families |
|
743 |
]. |
|
744 |
selectedFont notNil ifTrue:[ |
|
745 |
self showSelectedFont |
|
746 |
]. |
|
747 |
||
748 |
"Modified: 27.2.1996 / 01:39:42 / cg" |
|
749 |
"Created: 27.2.1996 / 01:40:37 / cg" |
|
197 | 750 |
! ! |
128 | 751 |
|
197 | 752 |
!FontPanel methodsFor:'queries'! |
0 | 753 |
|
197 | 754 |
preferredExtent |
595 | 755 |
"return the boxes preferredExtent" |
572 | 756 |
|
797 | 757 |
"/ If I have an explicit preferredExtent .. |
758 |
||
713
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
759 |
preferredExtent notNil ifTrue:[ |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
760 |
^ preferredExtent |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
761 |
]. |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
762 |
|
2842 | 763 |
^ 450@350 |
572 | 764 |
|
797 | 765 |
"Modified: 19.7.1996 / 20:44:08 / cg" |
0 | 766 |
! ! |
77 | 767 |
|
768 |
!FontPanel methodsFor:'user interaction'! |
|
769 |
||
2826 | 770 |
encodingFilterSelected:anEncodingPattern |
771 |
"another encoding was selected; find available fonts and update lists" |
|
772 |
||
773 |
|pattern| |
|
774 |
||
2887 | 775 |
anEncodingPattern isNil ifTrue:[ |
776 |
self filter:nil. |
|
777 |
^ self. |
|
778 |
]. |
|
779 |
||
2878 | 780 |
pattern := (anEncodingPattern upTo:$( ) withoutSeparators. |
781 |
||
782 |
pattern = '?' ifTrue:[ |
|
2845 | 783 |
pattern := '' |
784 |
] ifFalse:[ |
|
2878 | 785 |
pattern := (pattern isEmptyOrNil ifTrue:'*' ifFalse:pattern). |
2845 | 786 |
]. |
2826 | 787 |
self |
788 |
filter: |
|
789 |
[:f | |
|
790 |
|encoding| |
|
791 |
||
792 |
encoding := f encoding ? ''. |
|
793 |
pattern match:encoding |
|
794 |
]. |
|
795 |
! |
|
796 |
||
197 | 797 |
faceSelected:aFaceAndStyleName |
2826 | 798 |
"a fonts face was selected; find available sizes and update lists" |
595 | 799 |
|
2842 | 800 |
self faceSelected:aFaceAndStyleName showPreview:true |
801 |
! |
|
802 |
||
803 |
faceSelected:aFaceAndStyleName showPreview:showPreview |
|
804 |
"a fonts face was selected; find available sizes and update lists" |
|
805 |
||
2890 | 806 |
|sizes didShow| |
197 | 807 |
|
808 |
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
|
809 |
self extractFaceAndStyleFrom:aFaceAndStyleName. |
197 | 810 |
]. |
811 |
sizes := device |
|
1257 | 812 |
sizesInFamily:(currentFamily ? '*') |
813 |
face:(currentFace ? '*') |
|
814 |
style:(currentStyle ? '*') |
|
415 | 815 |
filtering:filter. |
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
816 |
|
197 | 817 |
(sizes isNil or:[sizes isEmpty]) ifTrue:[ |
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
818 |
sizeList list:nil. |
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
819 |
currentSize := nil. |
2842 | 820 |
showPreview ifTrue:[ |
821 |
self showPreview. |
|
822 |
]. |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
823 |
^ self |
197 | 824 |
]. |
825 |
||
2890 | 826 |
didShow := false. |
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
827 |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
828 |
sizes := (sizes asOrderedCollection sort) collect:[:entry | entry printString]. |
197 | 829 |
sizeList list:sizes. |
830 |
currentSize notNil ifTrue:[ |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
831 |
(sizes includes:(currentSize printString)) ifTrue:[ |
2170 | 832 |
sizeList setSelectElement:currentSize printString. |
2842 | 833 |
showPreview ifTrue:[ |
2890 | 834 |
self showPreview. |
835 |
didShow := true. |
|
2842 | 836 |
] |
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
837 |
] |
2890 | 838 |
]. |
839 |
didShow ifFalse:[ |
|
840 |
self clearPreview |
|
841 |
]. |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
842 |
|
1257 | 843 |
"Modified: 30.6.1997 / 17:25:46 / cg" |
197 | 844 |
! |
845 |
||
77 | 846 |
familySelected:aFamilyName |
2826 | 847 |
"a fonts family was selected; find available faces and update lists" |
595 | 848 |
|
2842 | 849 |
self familySelected:aFamilyName showPreview:true |
850 |
! |
|
851 |
||
852 |
familySelected:aFamilyName showPreview:showPreview |
|
853 |
"a fonts family was selected; find available faces and update lists" |
|
854 |
||
77 | 855 |
|faces styles list| |
856 |
||
690 | 857 |
familyList setSelectElement:aFamilyName. |
77 | 858 |
|
859 |
currentFamily := aFamilyName. |
|
415 | 860 |
faces := device facesInFamily:aFamilyName filtering:filter. |
2353 | 861 |
(faces size = 0) ifTrue:[ |
415 | 862 |
currentFace := currentStyle := currentFaceAndStyle := nil. |
863 |
faceList list:nil. |
|
2842 | 864 |
self faceSelected:nil showPreview:showPreview. |
415 | 865 |
^ self. |
77 | 866 |
]. |
867 |
||
2353 | 868 |
list := SortedCollection new. |
77 | 869 |
faces do:[:aFace | |
415 | 870 |
styles := device stylesInFamily:aFamilyName face:aFace filtering:filter. |
871 |
styles do:[:aStyle | |
|
872 |
list add:(aFace , '-' , aStyle) |
|
873 |
] |
|
77 | 874 |
]. |
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
875 |
|
77 | 876 |
faceList list:list. |
877 |
currentFaceAndStyle notNil ifTrue:[ |
|
415 | 878 |
(list includes:currentFaceAndStyle) ifTrue:[ |
690 | 879 |
faceList setSelectElement:currentFaceAndStyle. |
2842 | 880 |
self faceSelected:currentFaceAndStyle showPreview:showPreview. |
415 | 881 |
^ self |
882 |
] |
|
77 | 883 |
]. |
2842 | 884 |
|
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
885 |
sizeList list:nil. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
886 |
self clearPreview. |
415 | 887 |
|
690 | 888 |
"Modified: 26.5.1996 / 15:04:29 / cg" |
77 | 889 |
! |
890 |
||
891 |
okPressed |
|
595 | 892 |
"ok was pressed; hide myself and evaluate the okAction, passing |
893 |
family, face, style and size as arguments" |
|
894 |
||
77 | 895 |
self hide. |
896 |
okAction notNil ifTrue:[ |
|
410 | 897 |
currentFamily notNil ifTrue:[ |
2842 | 898 |
okAction |
899 |
value:(FontDescription |
|
900 |
family:currentFamily |
|
901 |
face:currentFace |
|
902 |
style:currentStyle |
|
903 |
size:currentSize |
|
2843 | 904 |
encoding:(currentEncoding ? encoding)). |
410 | 905 |
] |
77 | 906 |
] |
410 | 907 |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
908 |
"Modified: 10.4.1997 / 09:51:31 / cg" |
77 | 909 |
! |
910 |
||
2852 | 911 |
previewCopySelection |
912 |
previewField copySelection. |
|
913 |
! |
|
914 |
||
2935 | 915 |
previewInspectFont |
916 |
previewField font inspect. |
|
917 |
! |
|
918 |
||
2852 | 919 |
previewShowCharacterSet |
920 |
CharacterSetView openOn:(previewField font) |
|
921 |
! |
|
922 |
||
2875 | 923 |
previewShowCharacterSetUsingXFD |
2878 | 924 |
[ |
925 |
OperatingSystem executeCommand:'xfd -fn ' , previewField font fullName. |
|
926 |
] fork. |
|
2875 | 927 |
! |
928 |
||
77 | 929 |
sizeSelected:aNumberOrString |
2826 | 930 |
"a size was selected; update preview" |
595 | 931 |
|
2842 | 932 |
self sizeSelected:aNumberOrString showPreview:true. |
933 |
! |
|
934 |
||
935 |
sizeSelected:aNumberOrString showPreview:showPreview |
|
936 |
"a size was selected; update preview" |
|
937 |
||
77 | 938 |
aNumberOrString isNumber ifTrue:[ |
595 | 939 |
currentSize := aNumberOrString |
77 | 940 |
] ifFalse:[ |
2826 | 941 |
currentSize := Number readFromString:aNumberOrString onError:nil |
77 | 942 |
]. |
2842 | 943 |
showPreview ifTrue:[self showPreview] |
595 | 944 |
|
945 |
"Modified: 29.4.1996 / 09:43:23 / cg" |
|
77 | 946 |
! ! |
197 | 947 |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
948 |
!FontPanel class methodsFor:'documentation'! |
243 | 949 |
|
950 |
version |
|
2936 | 951 |
^ '$Header: /cvs/stx/stx/libwidg/FontPanel.st,v 1.80 2004-03-10 15:46:12 ca Exp $' |
243 | 952 |
! ! |