author | ca |
Fri, 06 Feb 2004 18:11:13 +0100 | |
changeset 2848 | b8a4d793764c |
parent 2847 | 27017abf9298 |
child 2849 | f6b71b63b33c |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1991 by Claus Gittinger |
59 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
77 | 13 |
|
14 |
||
2275 | 15 |
"{ Package: 'stx:libwidg' }" |
16 |
||
77 | 17 |
DialogBox subclass:#FontPanel |
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
18 |
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
|
19 |
currentFamily currentFace currentStyle currentFaceAndStyle |
2843 | 20 |
currentSize currentEncoding selectedFont nameLabel encodingFilter |
21 |
encodingLabel filter encoding' |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
22 |
classVariableNames:'' |
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
23 |
poolDictionaries:'' |
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
24 |
category:'Views-DialogBoxes' |
0 | 25 |
! |
26 |
||
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
27 |
!FontPanel class methodsFor:'documentation'! |
77 | 28 |
|
197 | 29 |
copyright |
30 |
" |
|
31 |
COPYRIGHT (c) 1991 by Claus Gittinger |
|
32 |
All Rights Reserved |
|
33 |
||
34 |
This software is furnished under a license and may be used |
|
35 |
only in accordance with the terms of that license and with the |
|
36 |
inclusion of the above copyright notice. This software may not |
|
37 |
be provided or otherwise made available to, or used by, any |
|
38 |
other person. No title to or ownership of the software is |
|
39 |
hereby transferred. |
|
40 |
" |
|
41 |
||
42 |
||
77 | 43 |
! |
44 |
||
45 |
documentation |
|
46 |
" |
|
47 |
this class implements a font chooser. |
|
48 |
||
2826 | 49 |
Notice: |
50 |
this is a very old dialog; |
|
51 |
it was written before the UI-framework was available and is completely |
|
52 |
setup manually (initialize method). |
|
53 |
Therefore, it desperately asks to be rewritten using the UIPainter... |
|
54 |
||
595 | 55 |
[author:] |
56 |
Claus Gittinger |
|
57 |
||
58 |
[see also:] |
|
59 |
Font FontDescription |
|
60 |
View Dialog |
|
61 |
" |
|
62 |
! |
|
63 |
||
64 |
examples |
|
65 |
" |
|
66 |
very simple: |
|
67 |
[exBegin] |
|
68 |
|font| |
|
69 |
||
70 |
font := FontPanel fontFromUser. |
|
655 | 71 |
Transcript showCR:font |
595 | 72 |
[exEnd] |
73 |
||
74 |
||
75 |
with initial font: |
|
76 |
[exBegin] |
|
77 |
|font| |
|
78 |
||
79 |
font := FontPanel |
|
80 |
fontFromUserInitial:(Font |
|
81 |
family:'courier' |
|
82 |
size:12). |
|
655 | 83 |
Transcript showCR:font |
595 | 84 |
[exEnd] |
85 |
||
86 |
||
87 |
with initial font & title: |
|
88 |
[exBegin] |
|
89 |
|font| |
|
90 |
||
91 |
font := FontPanel |
|
92 |
fontFromUserInitial:(Font |
|
93 |
family:'courier' |
|
94 |
size:12) |
|
95 |
title:'select a fooBar font'. |
|
655 | 96 |
Transcript showCR:font |
595 | 97 |
[exEnd] |
98 |
||
99 |
||
100 |
full setup; setting a filter to only present iso fonts |
|
101 |
and callBack action: |
|
102 |
[exBegin] |
|
0 | 103 |
|
585 | 104 |
|panel| |
77 | 105 |
|
585 | 106 |
panel := FontPanel new. |
595 | 107 |
panel label:'hi there - which iso font ?'. |
108 |
panel filter:[:fd | fd encoding notNil |
|
109 |
and:[fd encoding startsWith:'iso']]. |
|
110 |
panel action:[:family :face :style :size | |
|
655 | 111 |
Transcript showCR:'family:' , family. |
112 |
Transcript showCR:'face:' , face. |
|
113 |
Transcript showCR:'style:' , style. |
|
114 |
Transcript showCR:'size:' , size printString. |
|
595 | 115 |
]. |
116 |
panel open |
|
117 |
[exEnd] |
|
77 | 118 |
" |
119 |
! ! |
|
0 | 120 |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
121 |
!FontPanel class methodsFor:'defaults'! |
0 | 122 |
|
197 | 123 |
defaultExtent |
571 | 124 |
"return the default extent of my instances. |
125 |
The value returned here is usually ignored, and |
|
126 |
the value from preferredExtent taken instead." |
|
127 |
||
2842 | 128 |
^ (Screen current pixelPerMillimeter * (150 @ 100)) rounded |
571 | 129 |
|
130 |
"Modified: 22.4.1996 / 23:36:19 / cg" |
|
197 | 131 |
! |
132 |
||
382 | 133 |
defaultJISSampleString |
595 | 134 |
"return the sample jis preview text" |
135 |
||
382 | 136 |
^ ('The quick brown fox |
137 |
jumps over the lazy dog |
|
138 |
1234567890 |
|
139 |
!!@#$%^&*(){}[]:"~;,./<>? |
|
390
1d54a9b41463
say Hello world in JIS font ;-)
Claus Gittinger <cg@exept.de>
parents:
382
diff
changeset
|
140 |
|
1d54a9b41463
say Hello world in JIS font ;-)
Claus Gittinger <cg@exept.de>
parents:
382
diff
changeset
|
141 |
\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
|
142 |
' withEscapes decodeFrom:#jis7) |
1d54a9b41463
say Hello world in JIS font ;-)
Claus Gittinger <cg@exept.de>
parents:
382
diff
changeset
|
143 |
|
595 | 144 |
"Modified: 29.4.1996 / 09:46:11 / cg" |
382 | 145 |
! |
146 |
||
2847 | 147 |
defaultLatin1SampleString |
148 |
"return the sample latin1 preview text" |
|
149 |
||
150 |
|t| |
|
151 |
||
152 |
Smalltalk language == #de ifTrue:[ |
|
153 |
t := 'Franz jagt im komplett verwahrlosten Taxi |
|
154 |
quer durch Bayern'. |
|
155 |
] ifFalse:[ |
|
156 |
t := 'The quick brown fox |
|
157 |
jumps over the lazy dog'. |
|
158 |
]. |
|
159 |
t := t , ' |
|
160 |
1234567890 |
|
161 |
!!@#$%^&*(){}[]:"~;,./<>? |
|
162 |
' , |
|
163 |
(Character value:16rE4) asString , "/ umlaut a |
|
164 |
(Character value:16rF6) asString , "/ umlaut o |
|
165 |
(Character value:16rFC) asString , "/ umlaut u |
|
166 |
(Character value:16rC4) asString , "/ umlaut A |
|
167 |
(Character value:16rD6) asString , "/ umlaut O |
|
168 |
(Character value:16rDC) asString , "/ umlaut U |
|
169 |
(Character value:16rDF) asString , "/ sz |
|
170 |
(Character value:233) asString , "/ e-degu |
|
171 |
(Character value:232) asString , "/ e-grave |
|
172 |
(Character value:234) asString , "/ e-circonflex |
|
173 |
(Character value:197) asString , "/ A |
|
174 |
(Character value:169) asString. "/ copyright |
|
175 |
^ t |
|
176 |
||
177 |
"Modified: 29.4.1996 / 09:46:19 / cg" |
|
178 |
! |
|
179 |
||
180 |
defaultUnicodeSampleString |
|
181 |
"return the sample unicode preview text" |
|
595 | 182 |
|
2275 | 183 |
|t| |
184 |
||
2286 | 185 |
Smalltalk language == #de ifTrue:[ |
2275 | 186 |
t := 'Franz jagt im komplett verwahrlosten Taxi |
187 |
quer durch Bayern'. |
|
188 |
] ifFalse:[ |
|
189 |
t := 'The quick brown fox |
|
190 |
jumps over the lazy dog'. |
|
191 |
]. |
|
192 |
t := t , ' |
|
110 | 193 |
1234567890 |
194 |
!!@#$%^&*(){}[]:"~;,./<>? |
|
195 |
' , |
|
398 | 196 |
(Character value:16rE4) asString , "/ umlaut a |
197 |
(Character value:16rF6) asString , "/ umlaut o |
|
198 |
(Character value:16rFC) asString , "/ umlaut u |
|
199 |
(Character value:16rC4) asString , "/ umlaut A |
|
200 |
(Character value:16rD6) asString , "/ umlaut O |
|
201 |
(Character value:16rDC) asString , "/ umlaut U |
|
202 |
(Character value:16rDF) asString , "/ sz |
|
203 |
(Character value:233) asString , "/ e-degu |
|
204 |
(Character value:232) asString , "/ e-grave |
|
205 |
(Character value:234) asString , "/ e-circonflex |
|
206 |
(Character value:197) asString , "/ A |
|
2276 | 207 |
(Character value:169) asString. "/ copyright |
208 |
^ t |
|
398 | 209 |
|
595 | 210 |
"Modified: 29.4.1996 / 09:46:19 / cg" |
0 | 211 |
! ! |
212 |
||
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
213 |
!FontPanel class methodsFor:'startup'! |
0 | 214 |
|
215 |
fontFromUser |
|
77 | 216 |
"open a fontPanel and return the selected font, or nil |
217 |
if abort is pressed" |
|
218 |
||
410 | 219 |
^ self fontFromUserInitial:nil |
220 |
||
221 |
" |
|
222 |
FontPanel fontFromUser |
|
223 |
" |
|
224 |
||
225 |
"Modified: 27.2.1996 / 00:51:59 / cg" |
|
226 |
! |
|
227 |
||
228 |
fontFromUserInitial:aFont |
|
595 | 229 |
"open a fontPanel showing aFont initially, |
230 |
and return the selected font, or nil if abort is pressed" |
|
410 | 231 |
|
413 | 232 |
^ self fontFromUserInitial:aFont title:nil |
233 |
||
234 |
" |
|
235 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) |
|
236 |
" |
|
237 |
||
238 |
"Created: 27.2.1996 / 00:51:44 / cg" |
|
595 | 239 |
"Modified: 29.4.1996 / 09:45:52 / cg" |
413 | 240 |
! |
241 |
||
242 |
fontFromUserInitial:aFont title:someTitle |
|
595 | 243 |
"open a fontPanel with title and return the selected font, |
244 |
or nil if abort is pressed" |
|
413 | 245 |
|
415 | 246 |
^ self fontFromUserInitial:aFont title:someTitle filter:nil |
247 |
||
248 |
" |
|
249 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font' |
|
250 |
" |
|
251 |
||
252 |
"Created: 27.2.1996 / 00:59:46 / cg" |
|
595 | 253 |
"Modified: 29.4.1996 / 09:45:34 / cg" |
415 | 254 |
! |
255 |
||
256 |
fontFromUserInitial:aFont title:someTitle filter:aFilterBlock |
|
595 | 257 |
"open a fontPanel with title and font-filter |
258 |
and return the selected font, or nil if abort is pressed" |
|
415 | 259 |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
260 |
|fontPanel selectedFont| |
77 | 261 |
|
0 | 262 |
fontPanel := FontPanel new. |
415 | 263 |
fontPanel filter:aFilterBlock. |
413 | 264 |
someTitle notNil ifTrue:[ |
265 |
fontPanel label:someTitle |
|
266 |
]. |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
267 |
fontPanel action:[:aFontDescription | selectedFont := aFontDescription]. |
410 | 268 |
aFont notNil ifTrue:[ |
269 |
fontPanel initialFont:aFont. |
|
270 |
]. |
|
271 |
||
0 | 272 |
fontPanel showAtPointer. |
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
273 |
fontPanel destroy. |
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
274 |
^ selectedFont |
0 | 275 |
|
77 | 276 |
" |
413 | 277 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font' |
77 | 278 |
" |
410 | 279 |
|
413 | 280 |
"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
|
281 |
"Modified: 10.4.1997 / 09:53:03 / cg" |
0 | 282 |
! ! |
283 |
||
284 |
!FontPanel methodsFor:'accessing'! |
|
285 |
||
595 | 286 |
action:aFourArgBlock |
287 |
"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
|
288 |
The block will be evaluated with family, face, style, size and encoding." |
595 | 289 |
|
290 |
okAction := aFourArgBlock |
|
291 |
||
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
292 |
"Modified: 10.4.1997 / 09:49:58 / cg" |
197 | 293 |
! |
294 |
||
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
295 |
encoding:aPattern |
595 | 296 |
"set the encoding goal" |
297 |
||
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
298 |
encoding := aPattern. |
2843 | 299 |
encodingFilter contents:encoding. |
300 |
||
301 |
self encodingFilterSelected:encoding. |
|
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
302 |
shown ifTrue:[ |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
303 |
self updateFamilyList |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
304 |
]. |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
305 |
|
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
306 |
"Created: 29.2.1996 / 04:05:31 / cg" |
595 | 307 |
"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
|
308 |
! |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
309 |
|
415 | 310 |
filter:aOneArgBlock |
595 | 311 |
"set a filter; if non-nil, only fonts for which the filterBlock |
312 |
returns true will be offered" |
|
313 |
||
415 | 314 |
filter := aOneArgBlock. |
2826 | 315 |
familyList list:nil. |
415 | 316 |
shown ifTrue:[ |
317 |
self updateFamilyList |
|
318 |
]. |
|
319 |
||
320 |
"Created: 27.2.1996 / 01:40:08 / cg" |
|
595 | 321 |
"Modified: 29.4.1996 / 09:40:49 / cg" |
415 | 322 |
! |
323 |
||
0 | 324 |
initialFont:aFont |
128 | 325 |
"set the font to be selected initially" |
0 | 326 |
|
128 | 327 |
selectedFont := aFont. |
2843 | 328 |
encodingFilter contents:aFont encoding. |
329 |
self encodingFilterSelected:aFont encoding. |
|
382 | 330 |
self showSelectedFont. |
331 |
self showPreview |
|
332 |
||
333 |
"Modified: 23.2.1996 / 00:51:32 / cg" |
|
101 | 334 |
! ! |
335 |
||
77 | 336 |
!FontPanel methodsFor:'initialization'! |
337 |
||
338 |
initialize |
|
382 | 339 |
|familyLabel faceLabel sizeLabel panel fontBrowserView v1 v2 v3 |
2847 | 340 |
mm fH eH l box showFontNameLabel| |
77 | 341 |
|
342 |
super initialize. |
|
343 |
||
2847 | 344 |
showFontNameLabel := device platformName ~= 'WIN32'. |
345 |
||
382 | 346 |
mm := ViewSpacing. |
347 |
||
1763 | 348 |
self addAbortAndOkButtons. |
77 | 349 |
|
390
1d54a9b41463
say Hello world in JIS font ;-)
Claus Gittinger <cg@exept.de>
parents:
382
diff
changeset
|
350 |
panel := View origin:0.0@0.0 corner:1.0@1.0 in:self. |
2847 | 351 |
panel bottomInset:(buttonPanel preferredExtent y |
352 |
+ (mm*3) |
|
353 |
+ (showFontNameLabel ifTrue:24 ifFalse:0) ). |
|
77 | 354 |
|
150 | 355 |
label := resources string:'Font dialog'. |
77 | 356 |
|
2842 | 357 |
box := HorizontalPanelView in:panel. |
358 |
box horizontalLayout:#leftFit. |
|
359 |
box origin:0.0@1.0 corner:0.6@1.0. |
|
360 |
||
361 |
l := Label label:(resources string:'Encoding:') in:box. |
|
362 |
l borderWidth:0. |
|
363 |
l adjust:#left. |
|
364 |
||
365 |
encodingFilter := ComboBoxView in:box. |
|
2826 | 366 |
encodingFilter level:-1. |
367 |
encodingFilter contents:'*'. |
|
2842 | 368 |
encodingFilter list:(self listOfEncodingsInFilterCombo). |
2826 | 369 |
encodingFilter action:[:pattern | self encodingFilterSelected:pattern]. |
370 |
encodingFilter immediateAccept:true. |
|
2842 | 371 |
encodingFilter font:l font. |
372 |
encodingFilter editor font:l font. |
|
373 |
||
374 |
eH := encodingFilter preferredExtent y. |
|
375 |
box topInset:(eH negated-1); horizontalInset:mm. |
|
376 |
||
2826 | 377 |
"/ encodingFilter acceptOnReturn:true. |
378 |
"/ encodingFilter acceptOnTab:true. |
|
379 |
"/ encodingFilter acceptOnLeave:true. |
|
380 |
"/ encodingFilter acceptOnLostFocus:true. |
|
381 |
"/ encodingFilter acceptOnPointerLeave:true. |
|
382 |
||
382 | 383 |
encodingLabel := Label label:' ' in:panel. |
2842 | 384 |
"/ eH := encodingLabel preferredExtent y. |
385 |
encodingLabel origin:0.6@1.0 corner:1.0@1.0. |
|
382 | 386 |
encodingLabel topInset:(eH negated); horizontalInset:mm. |
2842 | 387 |
encodingLabel level:0; adjust:#left. |
388 |
encodingLabel adjust:#right. |
|
382 | 389 |
|
2847 | 390 |
showFontNameLabel ifTrue:[ |
391 |
nameLabel := Label label:'' in:self. |
|
392 |
nameLabel origin:0.0@1.0 corner:1.0@1.0. |
|
393 |
nameLabel bottomInset:(buttonPanel preferredExtent y + (mm*2)). |
|
394 |
nameLabel topInset:(buttonPanel preferredExtent y + (mm*2) + 24) negated; horizontalInset:mm. |
|
395 |
nameLabel level:0; adjust:#left. |
|
396 |
nameLabel font:(FontDescription family:'helvetica' face:'medium' style:'roman' size:9). |
|
397 |
]. |
|
382 | 398 |
|
2842 | 399 |
previewField := HVScrollableView for:TextView in:panel. |
400 |
previewField origin:0.0@0.0 corner:1.0@0.4. |
|
401 |
previewField autoHideScrollBars:true. |
|
402 |
previewField := previewField scrolledView. |
|
382 | 403 |
previewField inset:mm. |
77 | 404 |
|
405 |
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
|
406 |
previewField level:-1. |
77 | 407 |
] ifFalse:[ |
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
408 |
previewField borderWidth:1. |
77 | 409 |
]. |
410 |
||
390
1d54a9b41463
say Hello world in JIS font ;-)
Claus Gittinger <cg@exept.de>
parents:
382
diff
changeset
|
411 |
fontBrowserView := View origin:0.0@0.4 corner:1.0@1.0 in:panel. |
382 | 412 |
fontBrowserView bottomInset:(eH + mm). |
77 | 413 |
|
414 |
v1 := View origin:0.0@0.0 corner:0.4@1.0 in:fontBrowserView. |
|
415 |
||
2842 | 416 |
familyLabel := Label label:(resources string:'Family') in:v1. |
77 | 417 |
familyLabel borderWidth:0. |
418 |
familyLabel origin:(0.0 @ 0.0) extent:(1.0 @ nil). |
|
382 | 419 |
fH := familyLabel preferredExtent y. |
77 | 420 |
|
421 |
familyList := ScrollableView for:SelectionInListView in:v1. |
|
382 | 422 |
familyList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
423 |
familyList inset:mm. |
|
424 |
familyList topInset:fH. |
|
425 |
||
128 | 426 |
familyList := familyList scrolledView. |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
427 |
self makeTabable:familyList. |
77 | 428 |
|
429 |
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
|
430 |
in:fontBrowserView. |
77 | 431 |
|
2842 | 432 |
faceLabel := Label label:(resources string:'Typeface') in:v2. |
77 | 433 |
faceLabel borderWidth:0. |
434 |
faceLabel origin:(0.0 @ 0.0) extent:(1.0 @ nil). |
|
435 |
||
436 |
faceList := ScrollableView for:SelectionInListView in:v2. |
|
382 | 437 |
faceList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
438 |
faceList inset:mm. |
|
439 |
faceList topInset:fH. |
|
128 | 440 |
faceList := faceList scrolledView. |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
441 |
self makeTabable:faceList. |
77 | 442 |
|
2842 | 443 |
v3 := View origin:0.8@0.0 corner:1.0@1.0 in:fontBrowserView. |
77 | 444 |
|
2842 | 445 |
sizeLabel := Label label:(resources string:'Size') in:v3. |
77 | 446 |
sizeLabel borderWidth:0. |
447 |
sizeLabel origin:(0.0 @ 0.0)extent:(1.0 @ nil). |
|
448 |
||
449 |
sizeList := ScrollableView for:SelectionInListView in:v3. |
|
382 | 450 |
sizeList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
451 |
sizeList inset:mm. |
|
452 |
sizeList topInset:fH. |
|
128 | 453 |
sizeList := sizeList scrolledView. |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
454 |
self makeTabable:sizeList. |
77 | 455 |
|
456 |
familyList action:[:lineNr | self familySelected:(familyList selectionValue)]. |
|
457 |
faceList action:[:lineNr | self faceSelected:(faceList selectionValue)]. |
|
458 |
sizeList action:[:lineNr | self sizeSelected:(sizeList selectionValue)]. |
|
459 |
||
460 |
" |
|
461 |
FontPanel new showAtPointer |
|
462 |
" |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
463 |
|
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
464 |
"Modified: 31.5.1996 / 22:01:45 / cg" |
77 | 465 |
! |
466 |
||
2842 | 467 |
listOfEncodingsInFilterCombo |
468 |
|list availableEncodings| |
|
469 |
||
470 |
list := OrderedCollection new. |
|
471 |
list |
|
472 |
addAll: |
|
473 |
#( |
|
474 |
'*' |
|
475 |
'iso8859*' |
|
476 |
"/ 'iso8859-1' |
|
477 |
'iso10646-1' |
|
478 |
'koi8-r' |
|
479 |
'jis*' |
|
480 |
nil |
|
481 |
). |
|
482 |
||
483 |
availableEncodings := Set new. |
|
2845 | 484 |
device listOfAvailableFonts do:[:f | availableEncodings add:(f encoding ? '?')]. |
2842 | 485 |
availableEncodings := availableEncodings asSortedCollection. |
486 |
list addAll:availableEncodings. |
|
487 |
^ list. |
|
488 |
! |
|
489 |
||
1277 | 490 |
postRealize |
197 | 491 |
"kludge for sco - xlsfont fails sometimes - try again here" |
492 |
||
415 | 493 |
self updateFamilyList. |
1277 | 494 |
super postRealize |
415 | 495 |
|
496 |
"Modified: 27.2.1996 / 01:40:47 / cg" |
|
1277 | 497 |
"Created: 24.7.1997 / 18:12:42 / cg" |
77 | 498 |
! ! |
499 |
||
0 | 500 |
!FontPanel methodsFor:'private'! |
501 |
||
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
502 |
clearPreview |
595 | 503 |
"clear the preview subview" |
504 |
||
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
505 |
shown ifTrue:[ |
1297
f5ea02391a59
use #contents: instead of #clear
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
506 |
previewField contents:nil. |
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
507 |
encodingLabel label:''. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
508 |
]. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
509 |
|
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
510 |
"Created: 17.4.1996 / 15:19:16 / cg" |
1297
f5ea02391a59
use #contents: instead of #clear
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
511 |
"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
|
512 |
! |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
513 |
|
197 | 514 |
extractFaceAndStyleFrom:aString |
595 | 515 |
"given a string, extract currentFace and currentStyle" |
516 |
||
197 | 517 |
|index| |
518 |
||
519 |
index := aString indexOf:$-. |
|
520 |
(index ~~ 0) ifTrue:[ |
|
595 | 521 |
currentFaceAndStyle := aString. |
522 |
currentFace := aString copyTo:(index - 1). |
|
523 |
currentStyle := aString copyFrom:(index + 1) |
|
197 | 524 |
] |
525 |
||
595 | 526 |
"Modified: 29.4.1996 / 09:41:47 / cg" |
197 | 527 |
! |
528 |
||
529 |
showPreview |
|
595 | 530 |
"show the preview text" |
531 |
||
2843 | 532 |
|font deviceFont enc s allFonts fonts fontName| |
382 | 533 |
|
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
534 |
self clearPreview. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
535 |
|
197 | 536 |
" |
537 |
show a wait cursor: for some fonts (kanji etc) the |
|
538 |
X-server needs quites some time to load the font |
|
539 |
" |
|
255 | 540 |
self withWaitCursorDo:[ |
2842 | 541 |
allFonts := device |
1257 | 542 |
fontsInFamily:(currentFamily ? '*') |
543 |
face:(currentFace ? '*') |
|
544 |
style:(currentStyle ? '*') |
|
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
545 |
filtering:filter. |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
546 |
|
2848 | 547 |
fonts := allFonts select:[:f | f size = currentSize]. |
450 | 548 |
fonts notEmpty ifTrue:[ |
2843 | 549 |
font := fonts anElement. |
450 | 550 |
] ifFalse:[ |
2848 | 551 |
"/ mhmh: |
552 |
"/ size=0 is returned for scalable fonts. |
|
553 |
"/ Any size is possible. |
|
450 | 554 |
"/ |
2848 | 555 |
fonts := allFonts select:[:f | f size = 0]. |
450 | 556 |
fonts notEmpty ifTrue:[ |
2843 | 557 |
font := Font family:currentFamily |
450 | 558 |
face:currentFace |
559 |
style:currentStyle |
|
560 |
size:currentSize |
|
561 |
encoding:(fonts anElement encoding). |
|
562 |
] |
|
563 |
]. |
|
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
564 |
|
2843 | 565 |
font notNil ifTrue:[ |
566 |
deviceFont := font onDevice:device. |
|
567 |
previewField font:deviceFont. |
|
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
568 |
|
2843 | 569 |
enc := font encoding. |
2287
b33ad40d7538
preview fixed when font is bad
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
570 |
enc isNil ifTrue:[enc := 'ascii ?']. |
b33ad40d7538
preview fixed when font is bad
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
571 |
encodingLabel label:enc. |
2843 | 572 |
currentEncoding := enc. |
573 |
fontName := deviceFont fullName. |
|
382 | 574 |
|
2842 | 575 |
(enc notNil and:[enc startsWith:'jis']) ifTrue:[ |
576 |
s := self class defaultJISSampleString |
|
577 |
] ifFalse:[ |
|
2847 | 578 |
s := self class defaultLatin1SampleString. |
2842 | 579 |
]. |
580 |
previewField contents:s. |
|
382 | 581 |
] ifFalse:[ |
2842 | 582 |
previewField contents:nil. |
583 |
encodingLabel label:nil. |
|
2843 | 584 |
currentEncoding := nil. |
2842 | 585 |
fontName := nil. |
382 | 586 |
]. |
2842 | 587 |
nameLabel notNil ifTrue:[nameLabel label:fontName]. |
197 | 588 |
] |
255 | 589 |
|
1257 | 590 |
"Modified: 30.6.1997 / 17:26:22 / cg" |
197 | 591 |
! |
592 |
||
128 | 593 |
showSelectedFont |
2843 | 594 |
|fam face faceAndStyle style sz| |
128 | 595 |
|
596 |
fam := selectedFont family. |
|
2843 | 597 |
currentEncoding := selectedFont encoding. |
598 |
||
2842 | 599 |
self familySelected:fam. |
128 | 600 |
fam notNil ifTrue:[ |
2842 | 601 |
face := selectedFont face. |
602 |
(face notNil and:[(style := selectedFont style) notNil]) ifTrue:[ |
|
603 |
faceAndStyle := face , '-' , style. |
|
604 |
]. |
|
605 |
self faceSelected:faceAndStyle. |
|
606 |
faceAndStyle notNil ifTrue:[ |
|
607 |
sz := selectedFont size. |
|
608 |
self sizeSelected:sz. |
|
2843 | 609 |
|
2842 | 610 |
"/ sz notNil ifTrue:[ |
611 |
"/ enc := selectedFont encoding. |
|
612 |
"/ self encodingSelected:enc |
|
613 |
"/ ] |
|
614 |
] |
|
615 |
]. |
|
2826 | 616 |
! |
617 |
||
618 |
updateFamilyList |
|
619 |
"update the list of font families" |
|
620 |
||
621 |
|families| |
|
622 |
||
623 |
familyList list isNil ifTrue:[ |
|
624 |
families := device fontFamiliesFiltering:filter. |
|
625 |
families notNil ifTrue:[ |
|
626 |
families := families asOrderedCollection sort |
|
627 |
]. |
|
628 |
familyList list:families |
|
629 |
]. |
|
630 |
selectedFont notNil ifTrue:[ |
|
631 |
self showSelectedFont |
|
632 |
]. |
|
633 |
||
634 |
"Modified: 27.2.1996 / 01:39:42 / cg" |
|
635 |
"Created: 27.2.1996 / 01:40:37 / cg" |
|
197 | 636 |
! ! |
128 | 637 |
|
197 | 638 |
!FontPanel methodsFor:'queries'! |
0 | 639 |
|
197 | 640 |
preferredExtent |
595 | 641 |
"return the boxes preferredExtent" |
572 | 642 |
|
797 | 643 |
"/ If I have an explicit preferredExtent .. |
644 |
||
713
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
645 |
preferredExtent notNil ifTrue:[ |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
646 |
^ preferredExtent |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
647 |
]. |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
648 |
|
2842 | 649 |
^ 450@350 |
572 | 650 |
|
797 | 651 |
"Modified: 19.7.1996 / 20:44:08 / cg" |
0 | 652 |
! ! |
77 | 653 |
|
654 |
!FontPanel methodsFor:'user interaction'! |
|
655 |
||
2826 | 656 |
encodingFilterSelected:anEncodingPattern |
657 |
"another encoding was selected; find available fonts and update lists" |
|
658 |
||
659 |
|pattern| |
|
660 |
||
2845 | 661 |
anEncodingPattern = '?' ifTrue:[ |
662 |
pattern := '' |
|
663 |
] ifFalse:[ |
|
664 |
pattern := (anEncodingPattern isEmptyOrNil ifTrue:'*' ifFalse:anEncodingPattern). |
|
665 |
]. |
|
2826 | 666 |
self |
667 |
filter: |
|
668 |
[:f | |
|
669 |
|encoding| |
|
670 |
||
671 |
encoding := f encoding ? ''. |
|
672 |
pattern match:encoding |
|
673 |
]. |
|
674 |
! |
|
675 |
||
197 | 676 |
faceSelected:aFaceAndStyleName |
2826 | 677 |
"a fonts face was selected; find available sizes and update lists" |
595 | 678 |
|
2842 | 679 |
self faceSelected:aFaceAndStyleName showPreview:true |
680 |
! |
|
681 |
||
682 |
faceSelected:aFaceAndStyleName showPreview:showPreview |
|
683 |
"a fonts face was selected; find available sizes and update lists" |
|
684 |
||
197 | 685 |
|sizes| |
686 |
||
687 |
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
|
688 |
self extractFaceAndStyleFrom:aFaceAndStyleName. |
197 | 689 |
]. |
690 |
sizes := device |
|
1257 | 691 |
sizesInFamily:(currentFamily ? '*') |
692 |
face:(currentFace ? '*') |
|
693 |
style:(currentStyle ? '*') |
|
415 | 694 |
filtering:filter. |
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
695 |
|
197 | 696 |
(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
|
697 |
sizeList list:nil. |
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
698 |
currentSize := nil. |
2842 | 699 |
showPreview ifTrue:[ |
700 |
self showPreview. |
|
701 |
]. |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
702 |
^ self |
197 | 703 |
]. |
704 |
||
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
705 |
self clearPreview. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
706 |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
707 |
sizes := (sizes asOrderedCollection sort) collect:[:entry | entry printString]. |
197 | 708 |
sizeList list:sizes. |
709 |
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
|
710 |
(sizes includes:(currentSize printString)) ifTrue:[ |
2170 | 711 |
sizeList setSelectElement:currentSize printString. |
2842 | 712 |
showPreview ifTrue:[ |
713 |
self showPreview |
|
714 |
] |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
715 |
] |
197 | 716 |
] |
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
717 |
|
1257 | 718 |
"Modified: 30.6.1997 / 17:25:46 / cg" |
197 | 719 |
! |
720 |
||
77 | 721 |
familySelected:aFamilyName |
2826 | 722 |
"a fonts family was selected; find available faces and update lists" |
595 | 723 |
|
2842 | 724 |
self familySelected:aFamilyName showPreview:true |
725 |
! |
|
726 |
||
727 |
familySelected:aFamilyName showPreview:showPreview |
|
728 |
"a fonts family was selected; find available faces and update lists" |
|
729 |
||
77 | 730 |
|faces styles list| |
731 |
||
690 | 732 |
familyList setSelectElement:aFamilyName. |
77 | 733 |
|
734 |
currentFamily := aFamilyName. |
|
415 | 735 |
faces := device facesInFamily:aFamilyName filtering:filter. |
2353 | 736 |
(faces size = 0) ifTrue:[ |
415 | 737 |
currentFace := currentStyle := currentFaceAndStyle := nil. |
738 |
faceList list:nil. |
|
2842 | 739 |
self faceSelected:nil showPreview:showPreview. |
415 | 740 |
^ self. |
77 | 741 |
]. |
742 |
||
2353 | 743 |
list := SortedCollection new. |
77 | 744 |
faces do:[:aFace | |
415 | 745 |
styles := device stylesInFamily:aFamilyName face:aFace filtering:filter. |
746 |
styles do:[:aStyle | |
|
747 |
list add:(aFace , '-' , aStyle) |
|
748 |
] |
|
77 | 749 |
]. |
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
750 |
|
77 | 751 |
faceList list:list. |
752 |
currentFaceAndStyle notNil ifTrue:[ |
|
415 | 753 |
(list includes:currentFaceAndStyle) ifTrue:[ |
690 | 754 |
faceList setSelectElement:currentFaceAndStyle. |
2842 | 755 |
self faceSelected:currentFaceAndStyle showPreview:showPreview. |
415 | 756 |
^ self |
757 |
] |
|
77 | 758 |
]. |
2842 | 759 |
|
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
760 |
sizeList list:nil. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
761 |
self clearPreview. |
415 | 762 |
|
690 | 763 |
"Modified: 26.5.1996 / 15:04:29 / cg" |
77 | 764 |
! |
765 |
||
766 |
okPressed |
|
595 | 767 |
"ok was pressed; hide myself and evaluate the okAction, passing |
768 |
family, face, style and size as arguments" |
|
769 |
||
77 | 770 |
self hide. |
771 |
okAction notNil ifTrue:[ |
|
410 | 772 |
currentFamily notNil ifTrue:[ |
2842 | 773 |
okAction |
774 |
value:(FontDescription |
|
775 |
family:currentFamily |
|
776 |
face:currentFace |
|
777 |
style:currentStyle |
|
778 |
size:currentSize |
|
2843 | 779 |
encoding:(currentEncoding ? encoding)). |
410 | 780 |
] |
77 | 781 |
] |
410 | 782 |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
783 |
"Modified: 10.4.1997 / 09:51:31 / cg" |
77 | 784 |
! |
785 |
||
786 |
sizeSelected:aNumberOrString |
|
2826 | 787 |
"a size was selected; update preview" |
595 | 788 |
|
2842 | 789 |
self sizeSelected:aNumberOrString showPreview:true. |
790 |
! |
|
791 |
||
792 |
sizeSelected:aNumberOrString showPreview:showPreview |
|
793 |
"a size was selected; update preview" |
|
794 |
||
77 | 795 |
aNumberOrString isNumber ifTrue:[ |
595 | 796 |
currentSize := aNumberOrString |
77 | 797 |
] ifFalse:[ |
2826 | 798 |
currentSize := Number readFromString:aNumberOrString onError:nil |
77 | 799 |
]. |
2842 | 800 |
showPreview ifTrue:[self showPreview] |
595 | 801 |
|
802 |
"Modified: 29.4.1996 / 09:43:23 / cg" |
|
77 | 803 |
! ! |
197 | 804 |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
805 |
!FontPanel class methodsFor:'documentation'! |
243 | 806 |
|
807 |
version |
|
2848 | 808 |
^ '$Header: /cvs/stx/stx/libwidg/FontPanel.st,v 1.57 2004-02-06 17:11:13 ca Exp $' |
243 | 809 |
! ! |