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