author | Claus Gittinger <cg@exept.de> |
Thu, 25 Apr 1996 18:36:01 +0200 | |
changeset 582 | e151eeae2c9a |
parent 572 | 121735c2aff6 |
child 585 | 8f395aba0173 |
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 |
||
15 |
DialogBox subclass:#FontPanel |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
16 |
instanceVariableNames:'previewField familyList faceList sizeList revertButton |
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
17 |
currentFamily currentFace currentStyle currentFaceAndStyle |
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
18 |
currentSize selectedFont nameLabel 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 |
||
77 | 24 |
!FontPanel class methodsFor:'documentation'! |
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 |
||
46 |
usage: |
|
0 | 47 |
|
77 | 48 |
|panel| |
49 |
||
50 |
panel := FontPanel new. |
|
51 |
panel action:[:aFont | Transcript showCR:'the font is' , aFont printString]. |
|
52 |
panel show |
|
53 |
||
54 |
or simply: |
|
55 |
||
56 |
font := FontPanel fontFromUser |
|
57 |
" |
|
58 |
||
59 |
! ! |
|
0 | 60 |
|
61 |
!FontPanel class methodsFor:'defaults'! |
|
62 |
||
197 | 63 |
defaultExtent |
571 | 64 |
"return the default extent of my instances. |
65 |
The value returned here is usually ignored, and |
|
66 |
the value from preferredExtent taken instead." |
|
67 |
||
197 | 68 |
^ (Screen current pixelPerMillimeter * (120 @ 100)) rounded |
571 | 69 |
|
70 |
"Modified: 22.4.1996 / 23:36:19 / cg" |
|
197 | 71 |
! |
72 |
||
382 | 73 |
defaultJISSampleString |
74 |
^ ('The quick brown fox |
|
75 |
jumps over the lazy dog |
|
76 |
1234567890 |
|
77 |
!!@#$%^&*(){}[]:"~;,./<>? |
|
390
1d54a9b41463
say Hello world in JIS font ;-)
Claus Gittinger <cg@exept.de>
parents:
382
diff
changeset
|
78 |
|
1d54a9b41463
say Hello world in JIS font ;-)
Claus Gittinger <cg@exept.de>
parents:
382
diff
changeset
|
79 |
\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
|
80 |
' withEscapes decodeFrom:#jis7) |
1d54a9b41463
say Hello world in JIS font ;-)
Claus Gittinger <cg@exept.de>
parents:
382
diff
changeset
|
81 |
|
1d54a9b41463
say Hello world in JIS font ;-)
Claus Gittinger <cg@exept.de>
parents:
382
diff
changeset
|
82 |
"Modified: 23.2.1996 / 23:33:37 / cg" |
382 | 83 |
! |
84 |
||
85 |
defaultRomanSampleString |
|
110 | 86 |
^ 'The quick brown fox |
87 |
jumps over the lazy dog |
|
88 |
1234567890 |
|
89 |
!!@#$%^&*(){}[]:"~;,./<>? |
|
90 |
' , |
|
398 | 91 |
(Character value:16rE4) asString , "/ umlaut a |
92 |
(Character value:16rF6) asString , "/ umlaut o |
|
93 |
(Character value:16rFC) asString , "/ umlaut u |
|
94 |
(Character value:16rC4) asString , "/ umlaut A |
|
95 |
(Character value:16rD6) asString , "/ umlaut O |
|
96 |
(Character value:16rDC) asString , "/ umlaut U |
|
97 |
(Character value:16rDF) asString , "/ sz |
|
98 |
(Character value:233) asString , "/ e-degu |
|
99 |
(Character value:232) asString , "/ e-grave |
|
100 |
(Character value:234) asString , "/ e-circonflex |
|
101 |
(Character value:197) asString , "/ A |
|
102 |
(Character value:169) asString "/ copyright |
|
103 |
||
104 |
"Modified: 24.2.1996 / 22:45:16 / cg" |
|
0 | 105 |
! ! |
106 |
||
107 |
!FontPanel class methodsFor:'startup'! |
|
108 |
||
109 |
fontFromUser |
|
77 | 110 |
"open a fontPanel and return the selected font, or nil |
111 |
if abort is pressed" |
|
112 |
||
410 | 113 |
^ self fontFromUserInitial:nil |
114 |
||
115 |
" |
|
116 |
FontPanel fontFromUser |
|
117 |
" |
|
118 |
||
119 |
"Modified: 27.2.1996 / 00:51:59 / cg" |
|
120 |
! |
|
121 |
||
122 |
fontFromUserInitial:aFont |
|
123 |
"open a fontPanel and return the selected font, or nil |
|
124 |
if abort is pressed" |
|
125 |
||
413 | 126 |
^ self fontFromUserInitial:aFont title:nil |
127 |
||
128 |
" |
|
129 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) |
|
130 |
" |
|
131 |
||
132 |
"Created: 27.2.1996 / 00:51:44 / cg" |
|
133 |
"Modified: 27.2.1996 / 01:00:03 / cg" |
|
134 |
! |
|
135 |
||
136 |
fontFromUserInitial:aFont title:someTitle |
|
137 |
"open a fontPanel and return the selected font, or nil |
|
138 |
if abort is pressed" |
|
139 |
||
415 | 140 |
^ self fontFromUserInitial:aFont title:someTitle filter:nil |
141 |
||
142 |
" |
|
143 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font' |
|
144 |
" |
|
145 |
||
146 |
"Created: 27.2.1996 / 00:59:46 / cg" |
|
147 |
"Modified: 27.2.1996 / 01:00:12 / cg" |
|
148 |
! |
|
149 |
||
150 |
fontFromUserInitial:aFont title:someTitle filter:aFilterBlock |
|
151 |
"open a fontPanel and return the selected font, or nil |
|
152 |
if abort is pressed" |
|
153 |
||
0 | 154 |
|fontPanel| |
77 | 155 |
|
0 | 156 |
fontPanel := FontPanel new. |
415 | 157 |
fontPanel filter:aFilterBlock. |
413 | 158 |
someTitle notNil ifTrue:[ |
159 |
fontPanel label:someTitle |
|
160 |
]. |
|
0 | 161 |
fontPanel action:[:family :face :style :size | |
410 | 162 |
^ (Font family:family |
163 |
face:face |
|
164 |
style:style |
|
165 |
size:size) |
|
0 | 166 |
]. |
410 | 167 |
aFont notNil ifTrue:[ |
168 |
fontPanel initialFont:aFont. |
|
169 |
]. |
|
170 |
||
0 | 171 |
fontPanel showAtPointer. |
172 |
^ nil |
|
173 |
||
77 | 174 |
" |
413 | 175 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font' |
77 | 176 |
" |
410 | 177 |
|
413 | 178 |
"Created: 27.2.1996 / 00:59:46 / cg" |
179 |
"Modified: 27.2.1996 / 01:00:12 / cg" |
|
0 | 180 |
! ! |
181 |
||
182 |
!FontPanel methodsFor:'accessing'! |
|
183 |
||
197 | 184 |
action:aBlock |
185 |
okAction := aBlock |
|
186 |
! |
|
187 |
||
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
188 |
encoding:aPattern |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
189 |
encoding := aPattern. |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
190 |
shown ifTrue:[ |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
191 |
self updateFamilyList |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
192 |
]. |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
193 |
|
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
194 |
"Modified: 27.2.1996 / 01:41:33 / cg" |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
195 |
"Created: 29.2.1996 / 04:05:31 / cg" |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
196 |
! |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
197 |
|
415 | 198 |
filter:aOneArgBlock |
199 |
filter := aOneArgBlock. |
|
200 |
shown ifTrue:[ |
|
201 |
self updateFamilyList |
|
202 |
]. |
|
203 |
||
204 |
"Created: 27.2.1996 / 01:40:08 / cg" |
|
205 |
"Modified: 27.2.1996 / 01:41:33 / cg" |
|
206 |
! |
|
207 |
||
0 | 208 |
initialFont:aFont |
128 | 209 |
"set the font to be selected initially" |
0 | 210 |
|
128 | 211 |
selectedFont := aFont. |
382 | 212 |
self showSelectedFont. |
213 |
self showPreview |
|
214 |
||
215 |
"Modified: 23.2.1996 / 00:51:32 / cg" |
|
101 | 216 |
! ! |
217 |
||
77 | 218 |
!FontPanel methodsFor:'initialization'! |
219 |
||
197 | 220 |
focusSequence |
221 |
|a| |
|
77 | 222 |
|
197 | 223 |
a := Array new:5. |
224 |
a at:1 put:familyList. |
|
225 |
a at:2 put:faceList. |
|
226 |
a at:3 put:sizeList. |
|
227 |
a at:4 put:abortButton. |
|
228 |
a at:5 put:okButton. |
|
229 |
^ a |
|
77 | 230 |
! |
231 |
||
232 |
initialize |
|
382 | 233 |
|familyLabel faceLabel sizeLabel panel fontBrowserView v1 v2 v3 |
234 |
mm fH eH| |
|
77 | 235 |
|
236 |
super initialize. |
|
237 |
||
382 | 238 |
mm := ViewSpacing. |
239 |
||
77 | 240 |
self addAbortButton. |
241 |
self addOkButton. |
|
242 |
||
390
1d54a9b41463
say Hello world in JIS font ;-)
Claus Gittinger <cg@exept.de>
parents:
382
diff
changeset
|
243 |
panel := View origin:0.0@0.0 corner:1.0@1.0 in:self. |
382 | 244 |
panel bottomInset:(buttonPanel preferredExtent y + (mm*3)). |
77 | 245 |
|
150 | 246 |
label := resources string:'Font dialog'. |
77 | 247 |
|
382 | 248 |
encodingLabel := Label label:' ' in:panel. |
249 |
eH := encodingLabel preferredExtent y. |
|
250 |
encodingLabel origin:0.7@1.0 corner:1.0@1.0. |
|
251 |
encodingLabel topInset:(eH negated); horizontalInset:mm. |
|
252 |
encodingLabel level:-1; adjust:#left. |
|
253 |
||
254 |
"/ nameLabel := Label label:' ' in:panel. |
|
255 |
"/ nameLabel origin:0.0@1.0 corner:0.7@1.0. |
|
256 |
"/ nameLabel topInset:(eH negated); horizontalInset:mm. |
|
257 |
"/ nameLabel level:-1; adjust:#left. |
|
258 |
||
390
1d54a9b41463
say Hello world in JIS font ;-)
Claus Gittinger <cg@exept.de>
parents:
382
diff
changeset
|
259 |
previewField := TextView origin:0.0@0.0 corner:1.0@0.4 in:panel. |
382 | 260 |
previewField inset:mm. |
77 | 261 |
|
382 | 262 |
"/ previewField contents:self class defaultSampleString. |
77 | 263 |
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
|
264 |
previewField level:-1. |
77 | 265 |
] ifFalse:[ |
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
266 |
previewField borderWidth:1. |
77 | 267 |
]. |
268 |
||
390
1d54a9b41463
say Hello world in JIS font ;-)
Claus Gittinger <cg@exept.de>
parents:
382
diff
changeset
|
269 |
fontBrowserView := View origin:0.0@0.4 corner:1.0@1.0 in:panel. |
382 | 270 |
fontBrowserView bottomInset:(eH + mm). |
77 | 271 |
|
272 |
v1 := View origin:0.0@0.0 corner:0.4@1.0 in:fontBrowserView. |
|
273 |
||
274 |
familyLabel := Label label:'Family' in:v1. |
|
275 |
familyLabel borderWidth:0. |
|
276 |
familyLabel origin:(0.0 @ 0.0) extent:(1.0 @ nil). |
|
382 | 277 |
fH := familyLabel preferredExtent y. |
77 | 278 |
|
279 |
familyList := ScrollableView for:SelectionInListView in:v1. |
|
382 | 280 |
familyList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
281 |
familyList inset:mm. |
|
282 |
familyList topInset:fH. |
|
283 |
||
128 | 284 |
familyList := familyList scrolledView. |
77 | 285 |
|
286 |
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
|
287 |
in:fontBrowserView. |
77 | 288 |
|
289 |
faceLabel := Label label:'Typeface' in:v2. |
|
290 |
faceLabel borderWidth:0. |
|
291 |
faceLabel origin:(0.0 @ 0.0) extent:(1.0 @ nil). |
|
292 |
||
293 |
faceList := ScrollableView for:SelectionInListView in:v2. |
|
382 | 294 |
faceList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
295 |
faceList inset:mm. |
|
296 |
faceList topInset:fH. |
|
128 | 297 |
faceList := faceList scrolledView. |
77 | 298 |
|
299 |
v3 := View origin:0.8@0.0 corner:1.0@1.0 |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
300 |
in:fontBrowserView. |
77 | 301 |
|
302 |
sizeLabel := Label label:'Size' in:v3. |
|
303 |
sizeLabel borderWidth:0. |
|
304 |
sizeLabel origin:(0.0 @ 0.0)extent:(1.0 @ nil). |
|
305 |
||
306 |
sizeList := ScrollableView for:SelectionInListView in:v3. |
|
382 | 307 |
sizeList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
308 |
sizeList inset:mm. |
|
309 |
sizeList topInset:fH. |
|
128 | 310 |
sizeList := sizeList scrolledView. |
77 | 311 |
|
312 |
familyList action:[:lineNr | self familySelected:(familyList selectionValue)]. |
|
313 |
faceList action:[:lineNr | self faceSelected:(faceList selectionValue)]. |
|
314 |
sizeList action:[:lineNr | self sizeSelected:(sizeList selectionValue)]. |
|
315 |
||
316 |
" |
|
317 |
FontPanel new showAtPointer |
|
318 |
" |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
319 |
|
390
1d54a9b41463
say Hello world in JIS font ;-)
Claus Gittinger <cg@exept.de>
parents:
382
diff
changeset
|
320 |
"Modified: 23.2.1996 / 23:36:01 / cg" |
77 | 321 |
! |
322 |
||
197 | 323 |
realize |
324 |
"kludge for sco - xlsfont fails sometimes - try again here" |
|
325 |
||
415 | 326 |
self updateFamilyList. |
327 |
super realize |
|
328 |
||
329 |
"Modified: 27.2.1996 / 01:40:47 / cg" |
|
330 |
! |
|
331 |
||
332 |
updateFamilyList |
|
333 |
"kludge for sco - xlsfont fails sometimes - try again here" |
|
334 |
||
197 | 335 |
|families| |
77 | 336 |
|
197 | 337 |
familyList list isNil ifTrue:[ |
415 | 338 |
families := device fontFamiliesFiltering:filter. |
339 |
families notNil ifTrue:[ |
|
340 |
families := families asOrderedCollection |
|
341 |
]. |
|
342 |
familyList list:families |
|
197 | 343 |
]. |
344 |
selectedFont notNil ifTrue:[ |
|
415 | 345 |
self showSelectedFont |
197 | 346 |
]. |
415 | 347 |
|
348 |
"Modified: 27.2.1996 / 01:39:42 / cg" |
|
349 |
"Created: 27.2.1996 / 01:40:37 / cg" |
|
77 | 350 |
! ! |
351 |
||
0 | 352 |
!FontPanel methodsFor:'private'! |
353 |
||
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
354 |
clearPreview |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
355 |
shown ifTrue:[ |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
356 |
previewField clear. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
357 |
encodingLabel label:''. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
358 |
]. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
359 |
|
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
360 |
"Created: 17.4.1996 / 15:19:16 / cg" |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
361 |
"Modified: 17.4.1996 / 15:20:56 / cg" |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
362 |
! |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
363 |
|
197 | 364 |
extractFaceAndStyleFrom:aString |
365 |
|index| |
|
366 |
||
367 |
index := aString indexOf:$-. |
|
368 |
(index ~~ 0) ifTrue:[ |
|
369 |
currentFaceAndStyle := aString. |
|
370 |
currentFace := aString copyTo:(index - 1). |
|
371 |
currentStyle := aString copyFrom:(index + 1) |
|
372 |
] |
|
373 |
||
374 |
! |
|
375 |
||
376 |
showPreview |
|
450 | 377 |
|f enc s all fonts scalable| |
382 | 378 |
|
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
379 |
self clearPreview. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
380 |
|
197 | 381 |
" |
382 |
show a wait cursor: for some fonts (kanji etc) the |
|
383 |
X-server needs quites some time to load the font |
|
384 |
" |
|
255 | 385 |
self withWaitCursorDo:[ |
450 | 386 |
all := fonts := device |
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
387 |
fontsInFamily:currentFamily |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
388 |
face:currentFace |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
389 |
style:currentStyle |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
390 |
filtering:filter. |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
391 |
|
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
392 |
fonts := fonts select:[:f | f size == currentSize]. |
450 | 393 |
fonts notEmpty ifTrue:[ |
394 |
f := fonts anElement. |
|
395 |
] ifFalse:[ |
|
396 |
"/ mhmh |
|
397 |
"/ X returns size0 for scalable fonts. Any size is possible. |
|
398 |
"/ |
|
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
399 |
|
450 | 400 |
fonts := all select:[:f | f size == 0]. |
401 |
fonts notEmpty ifTrue:[ |
|
402 |
f := Font family:currentFamily |
|
403 |
face:currentFace |
|
404 |
style:currentStyle |
|
405 |
size:currentSize |
|
406 |
encoding:(fonts anElement encoding). |
|
407 |
] ifFalse:[ |
|
408 |
^ self |
|
409 |
] |
|
410 |
]. |
|
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
411 |
|
540 | 412 |
f := f on:device. |
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
413 |
previewField font:f. |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
414 |
|
382 | 415 |
enc := f encoding. |
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
416 |
enc isNil ifTrue:[enc := 'ascii ?']. |
382 | 417 |
encodingLabel label:enc. |
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
418 |
|
382 | 419 |
nameLabel notNil ifTrue:[nameLabel label:(f fullName)]. |
420 |
||
399 | 421 |
(enc notNil and:[enc startsWith:'jis']) ifTrue:[ |
382 | 422 |
s := self class defaultJISSampleString |
423 |
] ifFalse:[ |
|
424 |
s := self class defaultRomanSampleString. |
|
425 |
]. |
|
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
426 |
previewField contents:s. |
197 | 427 |
] |
255 | 428 |
|
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
429 |
"Modified: 17.4.1996 / 15:19:29 / cg" |
197 | 430 |
! |
431 |
||
128 | 432 |
showSelectedFont |
433 |
|fam face style sz| |
|
434 |
||
435 |
fam := selectedFont family. |
|
436 |
fam notNil ifTrue:[ |
|
437 |
self familySelected:fam. |
|
438 |
face := selectedFont face. |
|
439 |
face notNil ifTrue:[ |
|
440 |
style := selectedFont style. |
|
441 |
style notNil ifTrue:[ |
|
442 |
self faceSelected:(face , '-' , style). |
|
443 |
sz := selectedFont size. |
|
444 |
sz notNil ifTrue:[ |
|
445 |
self sizeSelected:sz |
|
446 |
] |
|
447 |
] |
|
448 |
] |
|
449 |
] |
|
197 | 450 |
! ! |
128 | 451 |
|
197 | 452 |
!FontPanel methodsFor:'queries'! |
0 | 453 |
|
197 | 454 |
preferredExtent |
572 | 455 |
"compute the boxes preferredExtent" |
456 |
||
197 | 457 |
^ 400@350 |
572 | 458 |
|
459 |
"Modified: 23.4.1996 / 00:14:40 / cg" |
|
0 | 460 |
! ! |
77 | 461 |
|
462 |
!FontPanel methodsFor:'user interaction'! |
|
463 |
||
197 | 464 |
faceSelected:aFaceAndStyleName |
465 |
|sizes| |
|
466 |
||
467 |
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
|
468 |
self extractFaceAndStyleFrom:aFaceAndStyleName. |
197 | 469 |
]. |
470 |
sizes := device |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
471 |
sizesInFamily:currentFamily |
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
472 |
face:currentFace |
415 | 473 |
style:currentStyle |
474 |
filtering:filter. |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
475 |
|
197 | 476 |
(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
|
477 |
sizeList list:nil. |
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
478 |
currentSize := nil. |
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
479 |
self showPreview. |
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
480 |
^ self |
197 | 481 |
]. |
482 |
||
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
483 |
self clearPreview. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
484 |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
485 |
sizes := (sizes asOrderedCollection sort) collect:[:entry | entry printString]. |
197 | 486 |
sizeList list:sizes. |
487 |
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
|
488 |
(sizes includes:(currentSize printString)) ifTrue:[ |
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
489 |
sizeList selectElement:currentSize. |
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
490 |
self showPreview |
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
491 |
] |
197 | 492 |
] |
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
493 |
|
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
494 |
"Modified: 17.4.1996 / 15:20:20 / cg" |
197 | 495 |
! |
496 |
||
77 | 497 |
familySelected:aFamilyName |
498 |
|faces styles list| |
|
499 |
||
500 |
familyList selectElement:aFamilyName. |
|
501 |
||
502 |
currentFamily := aFamilyName. |
|
415 | 503 |
faces := device facesInFamily:aFamilyName filtering:filter. |
77 | 504 |
(faces isNil or:[faces isEmpty]) ifTrue:[ |
415 | 505 |
currentFace := currentStyle := currentFaceAndStyle := nil. |
506 |
faceList list:nil. |
|
507 |
self faceSelected:nil. |
|
508 |
^ self. |
|
77 | 509 |
]. |
510 |
||
511 |
list := OrderedCollection new. |
|
512 |
faces do:[:aFace | |
|
415 | 513 |
styles := device stylesInFamily:aFamilyName face:aFace filtering:filter. |
514 |
styles do:[:aStyle | |
|
515 |
list add:(aFace , '-' , aStyle) |
|
516 |
] |
|
77 | 517 |
]. |
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
518 |
|
77 | 519 |
faceList list:list. |
520 |
currentFaceAndStyle notNil ifTrue:[ |
|
415 | 521 |
(list includes:currentFaceAndStyle) ifTrue:[ |
522 |
faceList selectElement:currentFaceAndStyle. |
|
523 |
self faceSelected:currentFaceAndStyle. |
|
524 |
^ self |
|
525 |
] |
|
77 | 526 |
]. |
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
527 |
sizeList list:nil. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
528 |
self clearPreview. |
415 | 529 |
|
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
530 |
"Modified: 17.4.1996 / 15:20:04 / cg" |
77 | 531 |
! |
532 |
||
533 |
okPressed |
|
534 |
self hide. |
|
535 |
okAction notNil ifTrue:[ |
|
410 | 536 |
currentFamily notNil ifTrue:[ |
537 |
okAction value:currentFamily |
|
538 |
value:currentFace |
|
539 |
value:currentStyle |
|
540 |
value:currentSize |
|
541 |
] |
|
77 | 542 |
] |
410 | 543 |
|
544 |
"Modified: 27.2.1996 / 00:50:19 / cg" |
|
77 | 545 |
! |
546 |
||
547 |
sizeSelected:aNumberOrString |
|
548 |
aNumberOrString isNumber ifTrue:[ |
|
549 |
currentSize := aNumberOrString |
|
550 |
] ifFalse:[ |
|
551 |
currentSize := Number readFromString:aNumberOrString |
|
552 |
]. |
|
553 |
self showPreview |
|
554 |
! ! |
|
197 | 555 |
|
243 | 556 |
!FontPanel class methodsFor:'documentation'! |
557 |
||
558 |
version |
|
572 | 559 |
^ '$Header: /cvs/stx/stx/libwidg/FontPanel.st,v 1.31 1996-04-22 22:20:22 cg Exp $' |
243 | 560 |
! ! |