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