author | Stefan Vogel <sv@exept.de> |
Fri, 07 Jan 2005 11:22:50 +0100 | |
changeset 3117 | 6d0c7aa281f2 |
parent 2942 | a0ef008a69f3 |
child 3187 | ad89ff271e5a |
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 |
|
2939 | 155 |
' , #(16r65E5 16r672C 16r8A9E) asUnicodeString |
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: éèêåÅ |
|
2939 | 203 |
cyrillic: ' , |
204 |
#(16r440 16r443 16r441 16r441 16r43A 16r438 16r439 16r20 16r44F 16r437 16r44B 16r43A) asUnicodeString , ' |
|
2933 | 205 |
greek: ' , |
2939 | 206 |
#(16r395 16r3BB 16r3BB 16r3B7 16r3BD 16r3B9 16r3BA 16r3AC) asUnicodeString , |
2933 | 207 |
' |
208 |
japanese: ' , |
|
2939 | 209 |
#(16r65E5 16r672C 16r8A9E) asUnicodeString , |
2933 | 210 |
' |
211 |
'. |
|
2276 | 212 |
^ t |
2933 | 213 |
|
214 |
"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
|
215 |
! |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
216 |
|
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
217 |
sampleStringWithAllLetters |
576e73803b46
correct display of non-unicode, non-8859 encoded fonts
Claus Gittinger <cg@exept.de>
parents:
2921
diff
changeset
|
218 |
^ (self classResources at:'CHARSET_TEST_SENTENCE' ifAbsent:'The quick brown fox jumps over the lazy dog') withCRs |
0 | 219 |
! ! |
220 |
||
2852 | 221 |
!FontPanel class methodsFor:'menu specs'! |
222 |
||
223 |
previewMenu |
|
224 |
"This resource specification was automatically generated |
|
225 |
by the MenuEditor of ST/X." |
|
226 |
||
227 |
"Do not manually edit this!! If it is corrupted, |
|
228 |
the MenuEditor may not be able to read the specification." |
|
229 |
||
230 |
" |
|
231 |
MenuEditor new openOnClass:FontPanel andSelector:#previewMenu |
|
232 |
(Menu new fromLiteralArrayEncoding:(FontPanel previewMenu)) startUp |
|
233 |
" |
|
234 |
||
235 |
<resource: #menu> |
|
236 |
||
237 |
^ |
|
238 |
#(Menu |
|
239 |
( |
|
240 |
(MenuItem |
|
241 |
label: 'Copy' |
|
242 |
itemValue: previewCopySelection |
|
243 |
translateLabel: true |
|
244 |
) |
|
245 |
(MenuItem |
|
246 |
label: '-' |
|
247 |
) |
|
248 |
(MenuItem |
|
249 |
label: 'Show Character Set' |
|
250 |
itemValue: previewShowCharacterSet |
|
251 |
translateLabel: true |
|
252 |
) |
|
2875 | 253 |
(MenuItem |
254 |
label: 'Show Character Set (Using xfd)' |
|
255 |
itemValue: previewShowCharacterSetUsingXFD |
|
256 |
translateLabel: true |
|
257 |
isVisible: false |
|
258 |
) |
|
2935 | 259 |
(MenuItem |
260 |
label: '-' |
|
261 |
) |
|
262 |
(MenuItem |
|
263 |
label: 'Inspect Font' |
|
264 |
itemValue: previewInspectFont |
|
265 |
translateLabel: true |
|
266 |
) |
|
2852 | 267 |
) |
268 |
nil |
|
269 |
nil |
|
270 |
) |
|
271 |
! ! |
|
272 |
||
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
273 |
!FontPanel class methodsFor:'startup'! |
0 | 274 |
|
275 |
fontFromUser |
|
77 | 276 |
"open a fontPanel and return the selected font, or nil |
277 |
if abort is pressed" |
|
278 |
||
410 | 279 |
^ self fontFromUserInitial:nil |
280 |
||
281 |
" |
|
282 |
FontPanel fontFromUser |
|
283 |
" |
|
284 |
||
285 |
"Modified: 27.2.1996 / 00:51:59 / cg" |
|
286 |
! |
|
287 |
||
288 |
fontFromUserInitial:aFont |
|
595 | 289 |
"open a fontPanel showing aFont initially, |
290 |
and return the selected font, or nil if abort is pressed" |
|
410 | 291 |
|
413 | 292 |
^ self fontFromUserInitial:aFont title:nil |
293 |
||
294 |
" |
|
295 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) |
|
296 |
" |
|
297 |
||
298 |
"Created: 27.2.1996 / 00:51:44 / cg" |
|
595 | 299 |
"Modified: 29.4.1996 / 09:45:52 / cg" |
413 | 300 |
! |
301 |
||
302 |
fontFromUserInitial:aFont title:someTitle |
|
595 | 303 |
"open a fontPanel with title and return the selected font, |
304 |
or nil if abort is pressed" |
|
413 | 305 |
|
415 | 306 |
^ self fontFromUserInitial:aFont title:someTitle filter:nil |
307 |
||
308 |
" |
|
309 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font' |
|
310 |
" |
|
311 |
||
312 |
"Created: 27.2.1996 / 00:59:46 / cg" |
|
595 | 313 |
"Modified: 29.4.1996 / 09:45:34 / cg" |
415 | 314 |
! |
315 |
||
2849 | 316 |
fontFromUserInitial:initialFont title:someTitle filter:aFilterBlock |
595 | 317 |
"open a fontPanel with title and font-filter |
318 |
and return the selected font, or nil if abort is pressed" |
|
415 | 319 |
|
2887 | 320 |
^ self fontFromUserInitial:initialFont title:someTitle filter:aFilterBlock encoding:nil |
321 |
||
322 |
" |
|
323 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font' |
|
324 |
" |
|
325 |
||
326 |
"Created: 27.2.1996 / 00:59:46 / cg" |
|
327 |
"Modified: 10.4.1997 / 09:53:03 / cg" |
|
328 |
! |
|
329 |
||
330 |
fontFromUserInitial:initialFont title:someTitle filter:aFilterBlock encoding:encoding |
|
331 |
"open a fontPanel with title and font-filter |
|
332 |
and return the selected font, or nil if abort is pressed" |
|
333 |
||
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
334 |
|fontPanel selectedFont| |
77 | 335 |
|
0 | 336 |
fontPanel := FontPanel new. |
415 | 337 |
fontPanel filter:aFilterBlock. |
413 | 338 |
someTitle notNil ifTrue:[ |
339 |
fontPanel label:someTitle |
|
340 |
]. |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
341 |
fontPanel action:[:aFontDescription | selectedFont := aFontDescription]. |
2849 | 342 |
initialFont notNil ifTrue:[ |
343 |
fontPanel initialFont:initialFont. |
|
410 | 344 |
]. |
2888 | 345 |
encoding notNil ifTrue:[ |
346 |
fontPanel encoding:encoding. |
|
2937 | 347 |
] ifFalse:[ |
348 |
initialFont notNil ifTrue:[ |
|
349 |
fontPanel encoding:initialFont encoding |
|
350 |
]. |
|
2888 | 351 |
]. |
0 | 352 |
fontPanel showAtPointer. |
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
353 |
fontPanel destroy. |
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
354 |
^ selectedFont |
0 | 355 |
|
77 | 356 |
" |
413 | 357 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font' |
77 | 358 |
" |
410 | 359 |
|
413 | 360 |
"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
|
361 |
"Modified: 10.4.1997 / 09:53:03 / cg" |
0 | 362 |
! ! |
363 |
||
364 |
!FontPanel methodsFor:'accessing'! |
|
365 |
||
595 | 366 |
action:aFourArgBlock |
367 |
"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
|
368 |
The block will be evaluated with family, face, style, size and encoding." |
595 | 369 |
|
370 |
okAction := aFourArgBlock |
|
371 |
||
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
372 |
"Modified: 10.4.1997 / 09:49:58 / cg" |
197 | 373 |
! |
374 |
||
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
375 |
encoding:aPattern |
595 | 376 |
"set the encoding goal" |
377 |
||
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
378 |
encoding := aPattern. |
2843 | 379 |
encodingFilter contents:encoding. |
380 |
||
381 |
self encodingFilterSelected:encoding. |
|
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
382 |
shown ifTrue:[ |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
383 |
self updateFamilyList |
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 |
|
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
386 |
"Created: 29.2.1996 / 04:05:31 / cg" |
595 | 387 |
"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
|
388 |
! |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
389 |
|
415 | 390 |
filter:aOneArgBlock |
595 | 391 |
"set a filter; if non-nil, only fonts for which the filterBlock |
392 |
returns true will be offered" |
|
393 |
||
415 | 394 |
filter := aOneArgBlock. |
2826 | 395 |
familyList list:nil. |
415 | 396 |
shown ifTrue:[ |
397 |
self updateFamilyList |
|
398 |
]. |
|
399 |
||
400 |
"Created: 27.2.1996 / 01:40:08 / cg" |
|
595 | 401 |
"Modified: 29.4.1996 / 09:40:49 / cg" |
415 | 402 |
! |
403 |
||
0 | 404 |
initialFont:aFont |
128 | 405 |
"set the font to be selected initially" |
0 | 406 |
|
2849 | 407 |
|encoding| |
408 |
||
128 | 409 |
selectedFont := aFont. |
2849 | 410 |
encoding := aFont encoding. |
411 |
"/ self halt. |
|
412 |
encodingFilter contents:encoding. |
|
413 |
self encodingFilterSelected:encoding. |
|
382 | 414 |
self showSelectedFont. |
415 |
||
416 |
"Modified: 23.2.1996 / 00:51:32 / cg" |
|
101 | 417 |
! ! |
418 |
||
77 | 419 |
!FontPanel methodsFor:'initialization'! |
420 |
||
421 |
initialize |
|
382 | 422 |
|familyLabel faceLabel sizeLabel panel fontBrowserView v1 v2 v3 |
2847 | 423 |
mm fH eH l box showFontNameLabel| |
77 | 424 |
|
425 |
super initialize. |
|
426 |
||
2847 | 427 |
showFontNameLabel := device platformName ~= 'WIN32'. |
428 |
||
382 | 429 |
mm := ViewSpacing. |
430 |
||
1763 | 431 |
self addAbortAndOkButtons. |
77 | 432 |
|
390
1d54a9b41463
say Hello world in JIS font ;-)
Claus Gittinger <cg@exept.de>
parents:
382
diff
changeset
|
433 |
panel := View origin:0.0@0.0 corner:1.0@1.0 in:self. |
2847 | 434 |
panel bottomInset:(buttonPanel preferredExtent y |
435 |
+ (mm*3) |
|
436 |
+ (showFontNameLabel ifTrue:24 ifFalse:0) ). |
|
77 | 437 |
|
150 | 438 |
label := resources string:'Font dialog'. |
77 | 439 |
|
2842 | 440 |
box := HorizontalPanelView in:panel. |
441 |
box horizontalLayout:#leftFit. |
|
442 |
box origin:0.0@1.0 corner:0.6@1.0. |
|
443 |
||
444 |
l := Label label:(resources string:'Encoding:') in:box. |
|
445 |
l borderWidth:0. |
|
446 |
l adjust:#left. |
|
447 |
||
448 |
encodingFilter := ComboBoxView in:box. |
|
2942 | 449 |
"/ encodingFilter font:l font. |
2826 | 450 |
encodingFilter level:-1. |
451 |
encodingFilter contents:'*'. |
|
2842 | 452 |
encodingFilter list:(self listOfEncodingsInFilterCombo). |
2826 | 453 |
encodingFilter action:[:pattern | self encodingFilterSelected:pattern]. |
454 |
encodingFilter immediateAccept:true. |
|
2942 | 455 |
"/ encodingFilter editor font:l font. |
2842 | 456 |
|
457 |
eH := encodingFilter preferredExtent y. |
|
2942 | 458 |
box topInset:(eH negated-4); horizontalInset:mm. |
2842 | 459 |
|
2826 | 460 |
"/ encodingFilter acceptOnReturn:true. |
461 |
"/ encodingFilter acceptOnTab:true. |
|
462 |
"/ encodingFilter acceptOnLeave:true. |
|
463 |
"/ encodingFilter acceptOnLostFocus:true. |
|
464 |
"/ encodingFilter acceptOnPointerLeave:true. |
|
465 |
||
382 | 466 |
encodingLabel := Label label:' ' in:panel. |
2842 | 467 |
"/ eH := encodingLabel preferredExtent y. |
468 |
encodingLabel origin:0.6@1.0 corner:1.0@1.0. |
|
382 | 469 |
encodingLabel topInset:(eH negated); horizontalInset:mm. |
2842 | 470 |
encodingLabel level:0; adjust:#left. |
471 |
encodingLabel adjust:#right. |
|
382 | 472 |
|
2847 | 473 |
showFontNameLabel ifTrue:[ |
474 |
nameLabel := Label label:'' in:self. |
|
475 |
nameLabel origin:0.0@1.0 corner:1.0@1.0. |
|
476 |
nameLabel bottomInset:(buttonPanel preferredExtent y + (mm*2)). |
|
477 |
nameLabel topInset:(buttonPanel preferredExtent y + (mm*2) + 24) negated; horizontalInset:mm. |
|
478 |
nameLabel level:0; adjust:#left. |
|
479 |
nameLabel font:(FontDescription family:'helvetica' face:'medium' style:'roman' size:9). |
|
480 |
]. |
|
382 | 481 |
|
2842 | 482 |
previewField := HVScrollableView for:TextView in:panel. |
483 |
previewField origin:0.0@0.0 corner:1.0@0.4. |
|
484 |
previewField autoHideScrollBars:true. |
|
485 |
previewField := previewField scrolledView. |
|
382 | 486 |
previewField inset:mm. |
77 | 487 |
|
488 |
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
|
489 |
previewField level:-1. |
77 | 490 |
] ifFalse:[ |
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
491 |
previewField borderWidth:1. |
77 | 492 |
]. |
493 |
||
390
1d54a9b41463
say Hello world in JIS font ;-)
Claus Gittinger <cg@exept.de>
parents:
382
diff
changeset
|
494 |
fontBrowserView := View origin:0.0@0.4 corner:1.0@1.0 in:panel. |
382 | 495 |
fontBrowserView bottomInset:(eH + mm). |
77 | 496 |
|
497 |
v1 := View origin:0.0@0.0 corner:0.4@1.0 in:fontBrowserView. |
|
498 |
||
2842 | 499 |
familyLabel := Label label:(resources string:'Family') in:v1. |
77 | 500 |
familyLabel borderWidth:0. |
501 |
familyLabel origin:(0.0 @ 0.0) extent:(1.0 @ nil). |
|
382 | 502 |
fH := familyLabel preferredExtent y. |
77 | 503 |
|
504 |
familyList := ScrollableView for:SelectionInListView in:v1. |
|
382 | 505 |
familyList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
506 |
familyList inset:mm. |
|
507 |
familyList topInset:fH. |
|
508 |
||
128 | 509 |
familyList := familyList scrolledView. |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
510 |
self makeTabable:familyList. |
77 | 511 |
|
512 |
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
|
513 |
in:fontBrowserView. |
77 | 514 |
|
2842 | 515 |
faceLabel := Label label:(resources string:'Typeface') in:v2. |
77 | 516 |
faceLabel borderWidth:0. |
517 |
faceLabel origin:(0.0 @ 0.0) extent:(1.0 @ nil). |
|
518 |
||
519 |
faceList := ScrollableView for:SelectionInListView in:v2. |
|
382 | 520 |
faceList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
521 |
faceList inset:mm. |
|
522 |
faceList topInset:fH. |
|
128 | 523 |
faceList := faceList scrolledView. |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
524 |
self makeTabable:faceList. |
77 | 525 |
|
2842 | 526 |
v3 := View origin:0.8@0.0 corner:1.0@1.0 in:fontBrowserView. |
77 | 527 |
|
2842 | 528 |
sizeLabel := Label label:(resources string:'Size') in:v3. |
77 | 529 |
sizeLabel borderWidth:0. |
530 |
sizeLabel origin:(0.0 @ 0.0)extent:(1.0 @ nil). |
|
531 |
||
532 |
sizeList := ScrollableView for:SelectionInListView in:v3. |
|
382 | 533 |
sizeList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
534 |
sizeList inset:mm. |
|
535 |
sizeList topInset:fH. |
|
128 | 536 |
sizeList := sizeList scrolledView. |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
537 |
self makeTabable:sizeList. |
77 | 538 |
|
539 |
familyList action:[:lineNr | self familySelected:(familyList selectionValue)]. |
|
540 |
faceList action:[:lineNr | self faceSelected:(faceList selectionValue)]. |
|
541 |
sizeList action:[:lineNr | self sizeSelected:(sizeList selectionValue)]. |
|
542 |
||
2852 | 543 |
previewField menuHolder:self previewMenu. |
544 |
||
77 | 545 |
" |
546 |
FontPanel new showAtPointer |
|
547 |
" |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
548 |
|
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
549 |
"Modified: 31.5.1996 / 22:01:45 / cg" |
77 | 550 |
! |
551 |
||
2842 | 552 |
listOfEncodingsInFilterCombo |
2878 | 553 |
|availableEncodings listPresentedToUser| |
2842 | 554 |
|
2878 | 555 |
listOfEncodings := OrderedCollection new. |
2849 | 556 |
device platformName = 'WIN32' ifTrue:[ |
2878 | 557 |
listOfEncodings |
2849 | 558 |
addAll: |
559 |
#( |
|
560 |
'*' |
|
561 |
nil |
|
562 |
). |
|
563 |
] ifFalse:[ |
|
2878 | 564 |
listOfEncodings |
2849 | 565 |
addAll: |
566 |
#( |
|
567 |
'*' |
|
568 |
'iso8859*' |
|
569 |
'iso10646-1' |
|
570 |
'jis*' |
|
571 |
nil |
|
572 |
). |
|
573 |
]. |
|
2842 | 574 |
|
575 |
availableEncodings := Set new. |
|
2845 | 576 |
device listOfAvailableFonts do:[:f | availableEncodings add:(f encoding ? '?')]. |
2842 | 577 |
availableEncodings := availableEncodings asSortedCollection. |
2878 | 578 |
listOfEncodings addAll:availableEncodings. |
579 |
||
580 |
listPresentedToUser := listOfEncodings collect:[:enc | |
|
581 |
|encoder userFriendlyName| |
|
582 |
||
2938 | 583 |
"/ |
584 |
"/ disabled to avoid autoloading of encoders. |
|
585 |
"/ (enc notNil and:[enc ~= '*']) ifTrue:[ |
|
586 |
"/ encoder := CharacterEncoder encoderFor:enc ifAbsent:nil. |
|
587 |
"/ encoder notNil ifTrue:[ |
|
588 |
"/ userFriendlyName := encoder userFriendlyNameOfEncoding. |
|
589 |
"/ ]. |
|
590 |
"/ ]. |
|
2937 | 591 |
(userFriendlyName notNil and:[(userFriendlyName sameAs: enc) not]) ifTrue:[ |
2878 | 592 |
enc , ' (' , userFriendlyName , ')' |
593 |
] ifFalse:[ |
|
594 |
enc |
|
595 |
] |
|
596 |
]. |
|
597 |
^ listPresentedToUser. |
|
2842 | 598 |
! |
599 |
||
1277 | 600 |
postRealize |
197 | 601 |
"kludge for sco - xlsfont fails sometimes - try again here" |
602 |
||
415 | 603 |
self updateFamilyList. |
1277 | 604 |
super postRealize |
415 | 605 |
|
606 |
"Modified: 27.2.1996 / 01:40:47 / cg" |
|
1277 | 607 |
"Created: 24.7.1997 / 18:12:42 / cg" |
2852 | 608 |
! |
609 |
||
610 |
previewMenu |
|
611 |
<resource: #programMenu > |
|
612 |
||
613 |
|menu| |
|
614 |
||
615 |
menu := Menu new fromLiteralArrayEncoding:self class previewMenu. |
|
616 |
menu findGuiResourcesIn:self. |
|
617 |
menu receiver:self. |
|
2875 | 618 |
|
619 |
OperatingSystem isUNIXlike ifTrue:[ |
|
620 |
(menu menuItemWithValue:#previewShowCharacterSetUsingXFD) isVisible: true |
|
621 |
]. |
|
2852 | 622 |
^ menu |
77 | 623 |
! ! |
624 |
||
0 | 625 |
!FontPanel methodsFor:'private'! |
626 |
||
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
627 |
clearPreview |
595 | 628 |
"clear the preview subview" |
629 |
||
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
630 |
shown ifTrue:[ |
1297
f5ea02391a59
use #contents: instead of #clear
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
631 |
previewField contents:nil. |
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
632 |
encodingLabel label:''. |
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 |
|
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
635 |
"Created: 17.4.1996 / 15:19:16 / cg" |
1297
f5ea02391a59
use #contents: instead of #clear
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
636 |
"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
|
637 |
! |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
638 |
|
197 | 639 |
extractFaceAndStyleFrom:aString |
595 | 640 |
"given a string, extract currentFace and currentStyle" |
641 |
||
197 | 642 |
|index| |
643 |
||
644 |
index := aString indexOf:$-. |
|
645 |
(index ~~ 0) ifTrue:[ |
|
595 | 646 |
currentFaceAndStyle := aString. |
647 |
currentFace := aString copyTo:(index - 1). |
|
648 |
currentStyle := aString copyFrom:(index + 1) |
|
197 | 649 |
] |
650 |
||
595 | 651 |
"Modified: 29.4.1996 / 09:41:47 / cg" |
197 | 652 |
! |
653 |
||
654 |
showPreview |
|
595 | 655 |
"show the preview text" |
656 |
||
2899 | 657 |
|font deviceFont enc allFonts fonts fontName| |
382 | 658 |
|
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
659 |
self clearPreview. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
660 |
|
197 | 661 |
" |
662 |
show a wait cursor: for some fonts (kanji etc) the |
|
2890 | 663 |
X-server needs quite some time to load the font |
197 | 664 |
" |
255 | 665 |
self withWaitCursorDo:[ |
2842 | 666 |
allFonts := device |
1257 | 667 |
fontsInFamily:(currentFamily ? '*') |
668 |
face:(currentFace ? '*') |
|
669 |
style:(currentStyle ? '*') |
|
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
670 |
filtering:filter. |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
671 |
|
2848 | 672 |
fonts := allFonts select:[:f | f size = currentSize]. |
450 | 673 |
fonts notEmpty ifTrue:[ |
2843 | 674 |
font := fonts anElement. |
450 | 675 |
] ifFalse:[ |
2848 | 676 |
"/ mhmh: |
677 |
"/ size=0 is returned for scalable fonts. |
|
678 |
"/ Any size is possible. |
|
450 | 679 |
"/ |
2848 | 680 |
fonts := allFonts select:[:f | f size = 0]. |
450 | 681 |
fonts notEmpty ifTrue:[ |
2843 | 682 |
font := Font family:currentFamily |
450 | 683 |
face:currentFace |
684 |
style:currentStyle |
|
685 |
size:currentSize |
|
686 |
encoding:(fonts anElement encoding). |
|
687 |
] |
|
688 |
]. |
|
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
689 |
|
2843 | 690 |
font notNil ifTrue:[ |
2890 | 691 |
deviceFont := font onDevice:device. |
692 |
enc := deviceFont encoding. |
|
2916 | 693 |
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
|
694 |
|
2874 | 695 |
previewField font:deviceFont. |
696 |
previewField characterEncoding:enc. |
|
697 |
||
2287
b33ad40d7538
preview fixed when font is bad
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
698 |
encodingLabel label:enc. |
2843 | 699 |
currentEncoding := enc. |
700 |
fontName := deviceFont fullName. |
|
2899 | 701 |
previewField contents:(self class defaultSampleStringForEncoding:enc). |
382 | 702 |
] ifFalse:[ |
2842 | 703 |
previewField contents:nil. |
704 |
encodingLabel label:nil. |
|
2843 | 705 |
currentEncoding := nil. |
2842 | 706 |
fontName := nil. |
382 | 707 |
]. |
2842 | 708 |
nameLabel notNil ifTrue:[nameLabel label:fontName]. |
197 | 709 |
] |
255 | 710 |
|
1257 | 711 |
"Modified: 30.6.1997 / 17:26:22 / cg" |
197 | 712 |
! |
713 |
||
128 | 714 |
showSelectedFont |
2843 | 715 |
|fam face faceAndStyle style sz| |
128 | 716 |
|
717 |
fam := selectedFont family. |
|
2843 | 718 |
currentEncoding := selectedFont encoding. |
719 |
||
2888 | 720 |
self familySelected:fam showPreview:false. |
128 | 721 |
fam notNil ifTrue:[ |
2842 | 722 |
face := selectedFont face. |
723 |
(face notNil and:[(style := selectedFont style) notNil]) ifTrue:[ |
|
724 |
faceAndStyle := face , '-' , style. |
|
725 |
]. |
|
2888 | 726 |
self faceSelected:faceAndStyle showPreview:false. |
2842 | 727 |
faceAndStyle notNil ifTrue:[ |
728 |
sz := selectedFont size. |
|
2888 | 729 |
self sizeSelected:sz showPreview:false. |
2842 | 730 |
] |
731 |
]. |
|
2888 | 732 |
|
733 |
self showPreview |
|
2826 | 734 |
! |
735 |
||
736 |
updateFamilyList |
|
737 |
"update the list of font families" |
|
738 |
||
739 |
|families| |
|
740 |
||
741 |
familyList list isNil ifTrue:[ |
|
742 |
families := device fontFamiliesFiltering:filter. |
|
743 |
families notNil ifTrue:[ |
|
744 |
families := families asOrderedCollection sort |
|
745 |
]. |
|
746 |
familyList list:families |
|
747 |
]. |
|
748 |
selectedFont notNil ifTrue:[ |
|
749 |
self showSelectedFont |
|
750 |
]. |
|
751 |
||
752 |
"Modified: 27.2.1996 / 01:39:42 / cg" |
|
753 |
"Created: 27.2.1996 / 01:40:37 / cg" |
|
197 | 754 |
! ! |
128 | 755 |
|
197 | 756 |
!FontPanel methodsFor:'queries'! |
0 | 757 |
|
197 | 758 |
preferredExtent |
595 | 759 |
"return the boxes preferredExtent" |
572 | 760 |
|
797 | 761 |
"/ If I have an explicit preferredExtent .. |
762 |
||
713
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
763 |
preferredExtent notNil ifTrue:[ |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
764 |
^ preferredExtent |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
765 |
]. |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
766 |
|
2842 | 767 |
^ 450@350 |
572 | 768 |
|
797 | 769 |
"Modified: 19.7.1996 / 20:44:08 / cg" |
0 | 770 |
! ! |
77 | 771 |
|
772 |
!FontPanel methodsFor:'user interaction'! |
|
773 |
||
2826 | 774 |
encodingFilterSelected:anEncodingPattern |
775 |
"another encoding was selected; find available fonts and update lists" |
|
776 |
||
777 |
|pattern| |
|
778 |
||
2887 | 779 |
anEncodingPattern isNil ifTrue:[ |
780 |
self filter:nil. |
|
781 |
^ self. |
|
782 |
]. |
|
783 |
||
2878 | 784 |
pattern := (anEncodingPattern upTo:$( ) withoutSeparators. |
785 |
||
786 |
pattern = '?' ifTrue:[ |
|
2845 | 787 |
pattern := '' |
788 |
] ifFalse:[ |
|
2878 | 789 |
pattern := (pattern isEmptyOrNil ifTrue:'*' ifFalse:pattern). |
2845 | 790 |
]. |
2826 | 791 |
self |
792 |
filter: |
|
793 |
[:f | |
|
794 |
|encoding| |
|
795 |
||
796 |
encoding := f encoding ? ''. |
|
797 |
pattern match:encoding |
|
798 |
]. |
|
799 |
! |
|
800 |
||
197 | 801 |
faceSelected:aFaceAndStyleName |
2826 | 802 |
"a fonts face was selected; find available sizes and update lists" |
595 | 803 |
|
2842 | 804 |
self faceSelected:aFaceAndStyleName showPreview:true |
805 |
! |
|
806 |
||
807 |
faceSelected:aFaceAndStyleName showPreview:showPreview |
|
808 |
"a fonts face was selected; find available sizes and update lists" |
|
809 |
||
2890 | 810 |
|sizes didShow| |
197 | 811 |
|
812 |
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
|
813 |
self extractFaceAndStyleFrom:aFaceAndStyleName. |
197 | 814 |
]. |
815 |
sizes := device |
|
1257 | 816 |
sizesInFamily:(currentFamily ? '*') |
817 |
face:(currentFace ? '*') |
|
818 |
style:(currentStyle ? '*') |
|
415 | 819 |
filtering:filter. |
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
820 |
|
197 | 821 |
(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
|
822 |
sizeList list:nil. |
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
823 |
currentSize := nil. |
2842 | 824 |
showPreview ifTrue:[ |
825 |
self showPreview. |
|
826 |
]. |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
827 |
^ self |
197 | 828 |
]. |
829 |
||
2890 | 830 |
didShow := false. |
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
831 |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
832 |
sizes := (sizes asOrderedCollection sort) collect:[:entry | entry printString]. |
197 | 833 |
sizeList list:sizes. |
834 |
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
|
835 |
(sizes includes:(currentSize printString)) ifTrue:[ |
2170 | 836 |
sizeList setSelectElement:currentSize printString. |
2842 | 837 |
showPreview ifTrue:[ |
2890 | 838 |
self showPreview. |
839 |
didShow := true. |
|
2842 | 840 |
] |
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
841 |
] |
2890 | 842 |
]. |
843 |
didShow ifFalse:[ |
|
844 |
self clearPreview |
|
845 |
]. |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
846 |
|
1257 | 847 |
"Modified: 30.6.1997 / 17:25:46 / cg" |
197 | 848 |
! |
849 |
||
77 | 850 |
familySelected:aFamilyName |
2826 | 851 |
"a fonts family was selected; find available faces and update lists" |
595 | 852 |
|
2842 | 853 |
self familySelected:aFamilyName showPreview:true |
854 |
! |
|
855 |
||
856 |
familySelected:aFamilyName showPreview:showPreview |
|
857 |
"a fonts family was selected; find available faces and update lists" |
|
858 |
||
77 | 859 |
|faces styles list| |
860 |
||
690 | 861 |
familyList setSelectElement:aFamilyName. |
77 | 862 |
|
863 |
currentFamily := aFamilyName. |
|
415 | 864 |
faces := device facesInFamily:aFamilyName filtering:filter. |
2353 | 865 |
(faces size = 0) ifTrue:[ |
415 | 866 |
currentFace := currentStyle := currentFaceAndStyle := nil. |
867 |
faceList list:nil. |
|
2842 | 868 |
self faceSelected:nil showPreview:showPreview. |
415 | 869 |
^ self. |
77 | 870 |
]. |
871 |
||
2353 | 872 |
list := SortedCollection new. |
77 | 873 |
faces do:[:aFace | |
415 | 874 |
styles := device stylesInFamily:aFamilyName face:aFace filtering:filter. |
875 |
styles do:[:aStyle | |
|
876 |
list add:(aFace , '-' , aStyle) |
|
877 |
] |
|
77 | 878 |
]. |
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
879 |
|
77 | 880 |
faceList list:list. |
881 |
currentFaceAndStyle notNil ifTrue:[ |
|
415 | 882 |
(list includes:currentFaceAndStyle) ifTrue:[ |
690 | 883 |
faceList setSelectElement:currentFaceAndStyle. |
2842 | 884 |
self faceSelected:currentFaceAndStyle showPreview:showPreview. |
415 | 885 |
^ self |
886 |
] |
|
77 | 887 |
]. |
2842 | 888 |
|
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
889 |
sizeList list:nil. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
890 |
self clearPreview. |
415 | 891 |
|
690 | 892 |
"Modified: 26.5.1996 / 15:04:29 / cg" |
77 | 893 |
! |
894 |
||
895 |
okPressed |
|
595 | 896 |
"ok was pressed; hide myself and evaluate the okAction, passing |
897 |
family, face, style and size as arguments" |
|
898 |
||
77 | 899 |
self hide. |
900 |
okAction notNil ifTrue:[ |
|
410 | 901 |
currentFamily notNil ifTrue:[ |
2842 | 902 |
okAction |
903 |
value:(FontDescription |
|
904 |
family:currentFamily |
|
905 |
face:currentFace |
|
906 |
style:currentStyle |
|
907 |
size:currentSize |
|
2843 | 908 |
encoding:(currentEncoding ? encoding)). |
410 | 909 |
] |
77 | 910 |
] |
410 | 911 |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
912 |
"Modified: 10.4.1997 / 09:51:31 / cg" |
77 | 913 |
! |
914 |
||
2852 | 915 |
previewCopySelection |
916 |
previewField copySelection. |
|
917 |
! |
|
918 |
||
2935 | 919 |
previewInspectFont |
920 |
previewField font inspect. |
|
921 |
! |
|
922 |
||
2852 | 923 |
previewShowCharacterSet |
924 |
CharacterSetView openOn:(previewField font) |
|
925 |
! |
|
926 |
||
2875 | 927 |
previewShowCharacterSetUsingXFD |
2878 | 928 |
[ |
929 |
OperatingSystem executeCommand:'xfd -fn ' , previewField font fullName. |
|
930 |
] fork. |
|
2875 | 931 |
! |
932 |
||
77 | 933 |
sizeSelected:aNumberOrString |
2826 | 934 |
"a size was selected; update preview" |
595 | 935 |
|
2842 | 936 |
self sizeSelected:aNumberOrString showPreview:true. |
937 |
! |
|
938 |
||
939 |
sizeSelected:aNumberOrString showPreview:showPreview |
|
940 |
"a size was selected; update preview" |
|
941 |
||
77 | 942 |
aNumberOrString isNumber ifTrue:[ |
595 | 943 |
currentSize := aNumberOrString |
77 | 944 |
] ifFalse:[ |
2826 | 945 |
currentSize := Number readFromString:aNumberOrString onError:nil |
77 | 946 |
]. |
2842 | 947 |
showPreview ifTrue:[self showPreview] |
595 | 948 |
|
949 |
"Modified: 29.4.1996 / 09:43:23 / cg" |
|
77 | 950 |
! ! |
197 | 951 |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
952 |
!FontPanel class methodsFor:'documentation'! |
243 | 953 |
|
954 |
version |
|
2942 | 955 |
^ '$Header: /cvs/stx/stx/libwidg/FontPanel.st,v 1.84 2004-03-12 18:05:38 cg Exp $' |
243 | 956 |
! ! |