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