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