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