author | Claus Gittinger <cg@exept.de> |
Fri, 06 Feb 2004 14:46:35 +0100 | |
changeset 2845 | 075391fc5ed1 |
parent 2843 | 5c470e6254d0 |
child 2847 | 27017abf9298 |
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 |
||
147 |
defaultRomanSampleString |
|
595 | 148 |
"return the sample roman preview text" |
149 |
||
2275 | 150 |
|t| |
151 |
||
2286 | 152 |
Smalltalk language == #de ifTrue:[ |
2275 | 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 , ' |
|
110 | 160 |
1234567890 |
161 |
!!@#$%^&*(){}[]:"~;,./<>? |
|
162 |
' , |
|
398 | 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 |
|
2276 | 174 |
(Character value:169) asString. "/ copyright |
175 |
^ t |
|
398 | 176 |
|
595 | 177 |
"Modified: 29.4.1996 / 09:46:19 / cg" |
0 | 178 |
! ! |
179 |
||
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
180 |
!FontPanel class methodsFor:'startup'! |
0 | 181 |
|
182 |
fontFromUser |
|
77 | 183 |
"open a fontPanel and return the selected font, or nil |
184 |
if abort is pressed" |
|
185 |
||
410 | 186 |
^ self fontFromUserInitial:nil |
187 |
||
188 |
" |
|
189 |
FontPanel fontFromUser |
|
190 |
" |
|
191 |
||
192 |
"Modified: 27.2.1996 / 00:51:59 / cg" |
|
193 |
! |
|
194 |
||
195 |
fontFromUserInitial:aFont |
|
595 | 196 |
"open a fontPanel showing aFont initially, |
197 |
and return the selected font, or nil if abort is pressed" |
|
410 | 198 |
|
413 | 199 |
^ self fontFromUserInitial:aFont title:nil |
200 |
||
201 |
" |
|
202 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) |
|
203 |
" |
|
204 |
||
205 |
"Created: 27.2.1996 / 00:51:44 / cg" |
|
595 | 206 |
"Modified: 29.4.1996 / 09:45:52 / cg" |
413 | 207 |
! |
208 |
||
209 |
fontFromUserInitial:aFont title:someTitle |
|
595 | 210 |
"open a fontPanel with title and return the selected font, |
211 |
or nil if abort is pressed" |
|
413 | 212 |
|
415 | 213 |
^ self fontFromUserInitial:aFont title:someTitle filter:nil |
214 |
||
215 |
" |
|
216 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font' |
|
217 |
" |
|
218 |
||
219 |
"Created: 27.2.1996 / 00:59:46 / cg" |
|
595 | 220 |
"Modified: 29.4.1996 / 09:45:34 / cg" |
415 | 221 |
! |
222 |
||
223 |
fontFromUserInitial:aFont title:someTitle filter:aFilterBlock |
|
595 | 224 |
"open a fontPanel with title and font-filter |
225 |
and return the selected font, or nil if abort is pressed" |
|
415 | 226 |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
227 |
|fontPanel selectedFont| |
77 | 228 |
|
0 | 229 |
fontPanel := FontPanel new. |
415 | 230 |
fontPanel filter:aFilterBlock. |
413 | 231 |
someTitle notNil ifTrue:[ |
232 |
fontPanel label:someTitle |
|
233 |
]. |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
234 |
fontPanel action:[:aFontDescription | selectedFont := aFontDescription]. |
410 | 235 |
aFont notNil ifTrue:[ |
236 |
fontPanel initialFont:aFont. |
|
237 |
]. |
|
238 |
||
0 | 239 |
fontPanel showAtPointer. |
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
240 |
fontPanel destroy. |
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
241 |
^ selectedFont |
0 | 242 |
|
77 | 243 |
" |
413 | 244 |
FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font' |
77 | 245 |
" |
410 | 246 |
|
413 | 247 |
"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
|
248 |
"Modified: 10.4.1997 / 09:53:03 / cg" |
0 | 249 |
! ! |
250 |
||
251 |
!FontPanel methodsFor:'accessing'! |
|
252 |
||
595 | 253 |
action:aFourArgBlock |
254 |
"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
|
255 |
The block will be evaluated with family, face, style, size and encoding." |
595 | 256 |
|
257 |
okAction := aFourArgBlock |
|
258 |
||
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
259 |
"Modified: 10.4.1997 / 09:49:58 / cg" |
197 | 260 |
! |
261 |
||
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
262 |
encoding:aPattern |
595 | 263 |
"set the encoding goal" |
264 |
||
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
265 |
encoding := aPattern. |
2843 | 266 |
encodingFilter contents:encoding. |
267 |
||
268 |
self encodingFilterSelected:encoding. |
|
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
269 |
shown ifTrue:[ |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
270 |
self updateFamilyList |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
271 |
]. |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
272 |
|
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
273 |
"Created: 29.2.1996 / 04:05:31 / cg" |
595 | 274 |
"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
|
275 |
! |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
276 |
|
415 | 277 |
filter:aOneArgBlock |
595 | 278 |
"set a filter; if non-nil, only fonts for which the filterBlock |
279 |
returns true will be offered" |
|
280 |
||
415 | 281 |
filter := aOneArgBlock. |
2826 | 282 |
familyList list:nil. |
415 | 283 |
shown ifTrue:[ |
284 |
self updateFamilyList |
|
285 |
]. |
|
286 |
||
287 |
"Created: 27.2.1996 / 01:40:08 / cg" |
|
595 | 288 |
"Modified: 29.4.1996 / 09:40:49 / cg" |
415 | 289 |
! |
290 |
||
0 | 291 |
initialFont:aFont |
128 | 292 |
"set the font to be selected initially" |
0 | 293 |
|
128 | 294 |
selectedFont := aFont. |
2843 | 295 |
encodingFilter contents:aFont encoding. |
296 |
self encodingFilterSelected:aFont encoding. |
|
382 | 297 |
self showSelectedFont. |
298 |
self showPreview |
|
299 |
||
300 |
"Modified: 23.2.1996 / 00:51:32 / cg" |
|
101 | 301 |
! ! |
302 |
||
77 | 303 |
!FontPanel methodsFor:'initialization'! |
304 |
||
305 |
initialize |
|
382 | 306 |
|familyLabel faceLabel sizeLabel panel fontBrowserView v1 v2 v3 |
2842 | 307 |
mm fH eH l box| |
77 | 308 |
|
309 |
super initialize. |
|
310 |
||
382 | 311 |
mm := ViewSpacing. |
312 |
||
1763 | 313 |
self addAbortAndOkButtons. |
77 | 314 |
|
390
1d54a9b41463
say Hello world in JIS font ;-)
Claus Gittinger <cg@exept.de>
parents:
382
diff
changeset
|
315 |
panel := View origin:0.0@0.0 corner:1.0@1.0 in:self. |
2842 | 316 |
panel bottomInset:(buttonPanel preferredExtent y + (mm*3) + 24). |
77 | 317 |
|
150 | 318 |
label := resources string:'Font dialog'. |
77 | 319 |
|
2842 | 320 |
box := HorizontalPanelView in:panel. |
321 |
box horizontalLayout:#leftFit. |
|
322 |
box origin:0.0@1.0 corner:0.6@1.0. |
|
323 |
||
324 |
l := Label label:(resources string:'Encoding:') in:box. |
|
325 |
l borderWidth:0. |
|
326 |
l adjust:#left. |
|
327 |
||
328 |
encodingFilter := ComboBoxView in:box. |
|
2826 | 329 |
encodingFilter level:-1. |
330 |
encodingFilter contents:'*'. |
|
2842 | 331 |
encodingFilter list:(self listOfEncodingsInFilterCombo). |
2826 | 332 |
encodingFilter action:[:pattern | self encodingFilterSelected:pattern]. |
333 |
encodingFilter immediateAccept:true. |
|
2842 | 334 |
encodingFilter font:l font. |
335 |
encodingFilter editor font:l font. |
|
336 |
||
337 |
eH := encodingFilter preferredExtent y. |
|
338 |
box topInset:(eH negated-1); horizontalInset:mm. |
|
339 |
||
2826 | 340 |
"/ encodingFilter acceptOnReturn:true. |
341 |
"/ encodingFilter acceptOnTab:true. |
|
342 |
"/ encodingFilter acceptOnLeave:true. |
|
343 |
"/ encodingFilter acceptOnLostFocus:true. |
|
344 |
"/ encodingFilter acceptOnPointerLeave:true. |
|
345 |
||
382 | 346 |
encodingLabel := Label label:' ' in:panel. |
2842 | 347 |
"/ eH := encodingLabel preferredExtent y. |
348 |
encodingLabel origin:0.6@1.0 corner:1.0@1.0. |
|
382 | 349 |
encodingLabel topInset:(eH negated); horizontalInset:mm. |
2842 | 350 |
encodingLabel level:0; adjust:#left. |
351 |
encodingLabel adjust:#right. |
|
382 | 352 |
|
2842 | 353 |
nameLabel := Label label:'' in:self. |
354 |
nameLabel origin:0.0@1.0 corner:1.0@1.0. |
|
355 |
nameLabel bottomInset:(buttonPanel preferredExtent y + (mm*2)). |
|
356 |
nameLabel topInset:(buttonPanel preferredExtent y + (mm*2) + 24) negated; horizontalInset:mm. |
|
357 |
nameLabel level:0; adjust:#left. |
|
358 |
nameLabel font:(FontDescription family:'helvetica' face:'medium' style:'roman' size:9). |
|
382 | 359 |
|
2842 | 360 |
previewField := HVScrollableView for:TextView in:panel. |
361 |
previewField origin:0.0@0.0 corner:1.0@0.4. |
|
362 |
previewField autoHideScrollBars:true. |
|
363 |
previewField := previewField scrolledView. |
|
382 | 364 |
previewField inset:mm. |
77 | 365 |
|
366 |
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
|
367 |
previewField level:-1. |
77 | 368 |
] ifFalse:[ |
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
369 |
previewField borderWidth:1. |
77 | 370 |
]. |
371 |
||
390
1d54a9b41463
say Hello world in JIS font ;-)
Claus Gittinger <cg@exept.de>
parents:
382
diff
changeset
|
372 |
fontBrowserView := View origin:0.0@0.4 corner:1.0@1.0 in:panel. |
382 | 373 |
fontBrowserView bottomInset:(eH + mm). |
77 | 374 |
|
375 |
v1 := View origin:0.0@0.0 corner:0.4@1.0 in:fontBrowserView. |
|
376 |
||
2842 | 377 |
familyLabel := Label label:(resources string:'Family') in:v1. |
77 | 378 |
familyLabel borderWidth:0. |
379 |
familyLabel origin:(0.0 @ 0.0) extent:(1.0 @ nil). |
|
382 | 380 |
fH := familyLabel preferredExtent y. |
77 | 381 |
|
382 |
familyList := ScrollableView for:SelectionInListView in:v1. |
|
382 | 383 |
familyList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
384 |
familyList inset:mm. |
|
385 |
familyList topInset:fH. |
|
386 |
||
128 | 387 |
familyList := familyList scrolledView. |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
388 |
self makeTabable:familyList. |
77 | 389 |
|
390 |
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
|
391 |
in:fontBrowserView. |
77 | 392 |
|
2842 | 393 |
faceLabel := Label label:(resources string:'Typeface') in:v2. |
77 | 394 |
faceLabel borderWidth:0. |
395 |
faceLabel origin:(0.0 @ 0.0) extent:(1.0 @ nil). |
|
396 |
||
397 |
faceList := ScrollableView for:SelectionInListView in:v2. |
|
382 | 398 |
faceList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
399 |
faceList inset:mm. |
|
400 |
faceList topInset:fH. |
|
128 | 401 |
faceList := faceList scrolledView. |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
402 |
self makeTabable:faceList. |
77 | 403 |
|
2842 | 404 |
v3 := View origin:0.8@0.0 corner:1.0@1.0 in:fontBrowserView. |
77 | 405 |
|
2842 | 406 |
sizeLabel := Label label:(resources string:'Size') in:v3. |
77 | 407 |
sizeLabel borderWidth:0. |
408 |
sizeLabel origin:(0.0 @ 0.0)extent:(1.0 @ nil). |
|
409 |
||
410 |
sizeList := ScrollableView for:SelectionInListView in:v3. |
|
382 | 411 |
sizeList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
412 |
sizeList inset:mm. |
|
413 |
sizeList topInset:fH. |
|
128 | 414 |
sizeList := sizeList scrolledView. |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
415 |
self makeTabable:sizeList. |
77 | 416 |
|
417 |
familyList action:[:lineNr | self familySelected:(familyList selectionValue)]. |
|
418 |
faceList action:[:lineNr | self faceSelected:(faceList selectionValue)]. |
|
419 |
sizeList action:[:lineNr | self sizeSelected:(sizeList selectionValue)]. |
|
420 |
||
421 |
" |
|
422 |
FontPanel new showAtPointer |
|
423 |
" |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
424 |
|
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
425 |
"Modified: 31.5.1996 / 22:01:45 / cg" |
77 | 426 |
! |
427 |
||
2842 | 428 |
listOfEncodingsInFilterCombo |
429 |
|list availableEncodings| |
|
430 |
||
431 |
list := OrderedCollection new. |
|
432 |
list |
|
433 |
addAll: |
|
434 |
#( |
|
435 |
'*' |
|
436 |
'iso8859*' |
|
437 |
"/ 'iso8859-1' |
|
438 |
'iso10646-1' |
|
439 |
'koi8-r' |
|
440 |
'jis*' |
|
441 |
nil |
|
442 |
). |
|
443 |
||
444 |
availableEncodings := Set new. |
|
2845 | 445 |
device listOfAvailableFonts do:[:f | availableEncodings add:(f encoding ? '?')]. |
2842 | 446 |
availableEncodings := availableEncodings asSortedCollection. |
447 |
list addAll:availableEncodings. |
|
448 |
^ list. |
|
449 |
! |
|
450 |
||
1277 | 451 |
postRealize |
197 | 452 |
"kludge for sco - xlsfont fails sometimes - try again here" |
453 |
||
415 | 454 |
self updateFamilyList. |
1277 | 455 |
super postRealize |
415 | 456 |
|
457 |
"Modified: 27.2.1996 / 01:40:47 / cg" |
|
1277 | 458 |
"Created: 24.7.1997 / 18:12:42 / cg" |
77 | 459 |
! ! |
460 |
||
0 | 461 |
!FontPanel methodsFor:'private'! |
462 |
||
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
463 |
clearPreview |
595 | 464 |
"clear the preview subview" |
465 |
||
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
466 |
shown ifTrue:[ |
1297
f5ea02391a59
use #contents: instead of #clear
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
467 |
previewField contents:nil. |
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
468 |
encodingLabel label:''. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
469 |
]. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
470 |
|
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
471 |
"Created: 17.4.1996 / 15:19:16 / cg" |
1297
f5ea02391a59
use #contents: instead of #clear
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
472 |
"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
|
473 |
! |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
474 |
|
197 | 475 |
extractFaceAndStyleFrom:aString |
595 | 476 |
"given a string, extract currentFace and currentStyle" |
477 |
||
197 | 478 |
|index| |
479 |
||
480 |
index := aString indexOf:$-. |
|
481 |
(index ~~ 0) ifTrue:[ |
|
595 | 482 |
currentFaceAndStyle := aString. |
483 |
currentFace := aString copyTo:(index - 1). |
|
484 |
currentStyle := aString copyFrom:(index + 1) |
|
197 | 485 |
] |
486 |
||
595 | 487 |
"Modified: 29.4.1996 / 09:41:47 / cg" |
197 | 488 |
! |
489 |
||
490 |
showPreview |
|
595 | 491 |
"show the preview text" |
492 |
||
2843 | 493 |
|font deviceFont enc s allFonts fonts fontName| |
382 | 494 |
|
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
495 |
self clearPreview. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
496 |
|
197 | 497 |
" |
498 |
show a wait cursor: for some fonts (kanji etc) the |
|
499 |
X-server needs quites some time to load the font |
|
500 |
" |
|
255 | 501 |
self withWaitCursorDo:[ |
2842 | 502 |
allFonts := device |
1257 | 503 |
fontsInFamily:(currentFamily ? '*') |
504 |
face:(currentFace ? '*') |
|
505 |
style:(currentStyle ? '*') |
|
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
506 |
filtering:filter. |
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
507 |
|
2842 | 508 |
fonts := allFonts select:[:f | f size == currentSize]. |
450 | 509 |
fonts notEmpty ifTrue:[ |
2843 | 510 |
font := fonts anElement. |
450 | 511 |
] ifFalse:[ |
512 |
"/ mhmh |
|
513 |
"/ X returns size0 for scalable fonts. Any size is possible. |
|
514 |
"/ |
|
2842 | 515 |
fonts := allFonts select:[:f | f size == 0]. |
450 | 516 |
fonts notEmpty ifTrue:[ |
2843 | 517 |
font := Font family:currentFamily |
450 | 518 |
face:currentFace |
519 |
style:currentStyle |
|
520 |
size:currentSize |
|
521 |
encoding:(fonts anElement encoding). |
|
522 |
] |
|
523 |
]. |
|
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
524 |
|
2843 | 525 |
font notNil ifTrue:[ |
526 |
deviceFont := font onDevice:device. |
|
527 |
previewField font:deviceFont. |
|
434
22586d8221e1
dont get confused by same-name but different encoding
Claus Gittinger <cg@exept.de>
parents:
415
diff
changeset
|
528 |
|
2843 | 529 |
enc := font encoding. |
2287
b33ad40d7538
preview fixed when font is bad
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
530 |
enc isNil ifTrue:[enc := 'ascii ?']. |
b33ad40d7538
preview fixed when font is bad
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
531 |
encodingLabel label:enc. |
2843 | 532 |
currentEncoding := enc. |
533 |
fontName := deviceFont fullName. |
|
382 | 534 |
|
2842 | 535 |
(enc notNil and:[enc startsWith:'jis']) ifTrue:[ |
536 |
s := self class defaultJISSampleString |
|
537 |
] ifFalse:[ |
|
538 |
s := self class defaultRomanSampleString. |
|
539 |
]. |
|
540 |
previewField contents:s. |
|
382 | 541 |
] ifFalse:[ |
2842 | 542 |
previewField contents:nil. |
543 |
encodingLabel label:nil. |
|
2843 | 544 |
currentEncoding := nil. |
2842 | 545 |
fontName := nil. |
382 | 546 |
]. |
2842 | 547 |
nameLabel notNil ifTrue:[nameLabel label:fontName]. |
197 | 548 |
] |
255 | 549 |
|
1257 | 550 |
"Modified: 30.6.1997 / 17:26:22 / cg" |
197 | 551 |
! |
552 |
||
128 | 553 |
showSelectedFont |
2843 | 554 |
|fam face faceAndStyle style sz| |
128 | 555 |
|
556 |
fam := selectedFont family. |
|
2843 | 557 |
currentEncoding := selectedFont encoding. |
558 |
||
2842 | 559 |
self familySelected:fam. |
128 | 560 |
fam notNil ifTrue:[ |
2842 | 561 |
face := selectedFont face. |
562 |
(face notNil and:[(style := selectedFont style) notNil]) ifTrue:[ |
|
563 |
faceAndStyle := face , '-' , style. |
|
564 |
]. |
|
565 |
self faceSelected:faceAndStyle. |
|
566 |
faceAndStyle notNil ifTrue:[ |
|
567 |
sz := selectedFont size. |
|
568 |
self sizeSelected:sz. |
|
2843 | 569 |
|
2842 | 570 |
"/ sz notNil ifTrue:[ |
571 |
"/ enc := selectedFont encoding. |
|
572 |
"/ self encodingSelected:enc |
|
573 |
"/ ] |
|
574 |
] |
|
575 |
]. |
|
2826 | 576 |
! |
577 |
||
578 |
updateFamilyList |
|
579 |
"update the list of font families" |
|
580 |
||
581 |
|families| |
|
582 |
||
583 |
familyList list isNil ifTrue:[ |
|
584 |
families := device fontFamiliesFiltering:filter. |
|
585 |
families notNil ifTrue:[ |
|
586 |
families := families asOrderedCollection sort |
|
587 |
]. |
|
588 |
familyList list:families |
|
589 |
]. |
|
590 |
selectedFont notNil ifTrue:[ |
|
591 |
self showSelectedFont |
|
592 |
]. |
|
593 |
||
594 |
"Modified: 27.2.1996 / 01:39:42 / cg" |
|
595 |
"Created: 27.2.1996 / 01:40:37 / cg" |
|
197 | 596 |
! ! |
128 | 597 |
|
197 | 598 |
!FontPanel methodsFor:'queries'! |
0 | 599 |
|
197 | 600 |
preferredExtent |
595 | 601 |
"return the boxes preferredExtent" |
572 | 602 |
|
797 | 603 |
"/ If I have an explicit preferredExtent .. |
604 |
||
713
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
605 |
preferredExtent notNil ifTrue:[ |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
606 |
^ preferredExtent |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
607 |
]. |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
608 |
|
2842 | 609 |
^ 450@350 |
572 | 610 |
|
797 | 611 |
"Modified: 19.7.1996 / 20:44:08 / cg" |
0 | 612 |
! ! |
77 | 613 |
|
614 |
!FontPanel methodsFor:'user interaction'! |
|
615 |
||
2826 | 616 |
encodingFilterSelected:anEncodingPattern |
617 |
"another encoding was selected; find available fonts and update lists" |
|
618 |
||
619 |
|pattern| |
|
620 |
||
2845 | 621 |
anEncodingPattern = '?' ifTrue:[ |
622 |
pattern := '' |
|
623 |
] ifFalse:[ |
|
624 |
pattern := (anEncodingPattern isEmptyOrNil ifTrue:'*' ifFalse:anEncodingPattern). |
|
625 |
]. |
|
2826 | 626 |
self |
627 |
filter: |
|
628 |
[:f | |
|
629 |
|encoding| |
|
630 |
||
631 |
encoding := f encoding ? ''. |
|
632 |
pattern match:encoding |
|
633 |
]. |
|
634 |
! |
|
635 |
||
197 | 636 |
faceSelected:aFaceAndStyleName |
2826 | 637 |
"a fonts face was selected; find available sizes and update lists" |
595 | 638 |
|
2842 | 639 |
self faceSelected:aFaceAndStyleName showPreview:true |
640 |
! |
|
641 |
||
642 |
faceSelected:aFaceAndStyleName showPreview:showPreview |
|
643 |
"a fonts face was selected; find available sizes and update lists" |
|
644 |
||
197 | 645 |
|sizes| |
646 |
||
647 |
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
|
648 |
self extractFaceAndStyleFrom:aFaceAndStyleName. |
197 | 649 |
]. |
650 |
sizes := device |
|
1257 | 651 |
sizesInFamily:(currentFamily ? '*') |
652 |
face:(currentFace ? '*') |
|
653 |
style:(currentStyle ? '*') |
|
415 | 654 |
filtering:filter. |
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
655 |
|
197 | 656 |
(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
|
657 |
sizeList list:nil. |
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
658 |
currentSize := nil. |
2842 | 659 |
showPreview ifTrue:[ |
660 |
self showPreview. |
|
661 |
]. |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
662 |
^ self |
197 | 663 |
]. |
664 |
||
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
665 |
self clearPreview. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
666 |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
667 |
sizes := (sizes asOrderedCollection sort) collect:[:entry | entry printString]. |
197 | 668 |
sizeList list:sizes. |
669 |
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
|
670 |
(sizes includes:(currentSize printString)) ifTrue:[ |
2170 | 671 |
sizeList setSelectElement:currentSize printString. |
2842 | 672 |
showPreview ifTrue:[ |
673 |
self showPreview |
|
674 |
] |
|
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
675 |
] |
197 | 676 |
] |
251
25f76efaa547
oops - dont pass a collection of numbers to the size-view
Claus Gittinger <cg@exept.de>
parents:
243
diff
changeset
|
677 |
|
1257 | 678 |
"Modified: 30.6.1997 / 17:25:46 / cg" |
197 | 679 |
! |
680 |
||
77 | 681 |
familySelected:aFamilyName |
2826 | 682 |
"a fonts family was selected; find available faces and update lists" |
595 | 683 |
|
2842 | 684 |
self familySelected:aFamilyName showPreview:true |
685 |
! |
|
686 |
||
687 |
familySelected:aFamilyName showPreview:showPreview |
|
688 |
"a fonts family was selected; find available faces and update lists" |
|
689 |
||
77 | 690 |
|faces styles list| |
691 |
||
690 | 692 |
familyList setSelectElement:aFamilyName. |
77 | 693 |
|
694 |
currentFamily := aFamilyName. |
|
415 | 695 |
faces := device facesInFamily:aFamilyName filtering:filter. |
2353 | 696 |
(faces size = 0) ifTrue:[ |
415 | 697 |
currentFace := currentStyle := currentFaceAndStyle := nil. |
698 |
faceList list:nil. |
|
2842 | 699 |
self faceSelected:nil showPreview:showPreview. |
415 | 700 |
^ self. |
77 | 701 |
]. |
702 |
||
2353 | 703 |
list := SortedCollection new. |
77 | 704 |
faces do:[:aFace | |
415 | 705 |
styles := device stylesInFamily:aFamilyName face:aFace filtering:filter. |
706 |
styles do:[:aStyle | |
|
707 |
list add:(aFace , '-' , aStyle) |
|
708 |
] |
|
77 | 709 |
]. |
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
710 |
|
77 | 711 |
faceList list:list. |
712 |
currentFaceAndStyle notNil ifTrue:[ |
|
415 | 713 |
(list includes:currentFaceAndStyle) ifTrue:[ |
690 | 714 |
faceList setSelectElement:currentFaceAndStyle. |
2842 | 715 |
self faceSelected:currentFaceAndStyle showPreview:showPreview. |
415 | 716 |
^ self |
717 |
] |
|
77 | 718 |
]. |
2842 | 719 |
|
541
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
720 |
sizeList list:nil. |
76018ea821ca
clear preview & encoding when no font is shown
Claus Gittinger <cg@exept.de>
parents:
540
diff
changeset
|
721 |
self clearPreview. |
415 | 722 |
|
690 | 723 |
"Modified: 26.5.1996 / 15:04:29 / cg" |
77 | 724 |
! |
725 |
||
726 |
okPressed |
|
595 | 727 |
"ok was pressed; hide myself and evaluate the okAction, passing |
728 |
family, face, style and size as arguments" |
|
729 |
||
77 | 730 |
self hide. |
731 |
okAction notNil ifTrue:[ |
|
410 | 732 |
currentFamily notNil ifTrue:[ |
2842 | 733 |
okAction |
734 |
value:(FontDescription |
|
735 |
family:currentFamily |
|
736 |
face:currentFace |
|
737 |
style:currentStyle |
|
738 |
size:currentSize |
|
2843 | 739 |
encoding:(currentEncoding ? encoding)). |
410 | 740 |
] |
77 | 741 |
] |
410 | 742 |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
743 |
"Modified: 10.4.1997 / 09:51:31 / cg" |
77 | 744 |
! |
745 |
||
746 |
sizeSelected:aNumberOrString |
|
2826 | 747 |
"a size was selected; update preview" |
595 | 748 |
|
2842 | 749 |
self sizeSelected:aNumberOrString showPreview:true. |
750 |
! |
|
751 |
||
752 |
sizeSelected:aNumberOrString showPreview:showPreview |
|
753 |
"a size was selected; update preview" |
|
754 |
||
77 | 755 |
aNumberOrString isNumber ifTrue:[ |
595 | 756 |
currentSize := aNumberOrString |
77 | 757 |
] ifFalse:[ |
2826 | 758 |
currentSize := Number readFromString:aNumberOrString onError:nil |
77 | 759 |
]. |
2842 | 760 |
showPreview ifTrue:[self showPreview] |
595 | 761 |
|
762 |
"Modified: 29.4.1996 / 09:43:23 / cg" |
|
77 | 763 |
! ! |
197 | 764 |
|
1185
3b8bd5ea8d62
action block is evaluated with a fontDescription
Claus Gittinger <cg@exept.de>
parents:
797
diff
changeset
|
765 |
!FontPanel class methodsFor:'documentation'! |
243 | 766 |
|
767 |
version |
|
2845 | 768 |
^ '$Header: /cvs/stx/stx/libwidg/FontPanel.st,v 1.55 2004-02-06 13:46:35 cg Exp $' |
243 | 769 |
! ! |