author | Claus Gittinger <cg@exept.de> |
Sat, 16 Nov 2019 16:53:30 +0100 | |
changeset 6185 | cdf3556a2bdd |
parent 6168 | 3eba11b4170f |
child 6210 | 607f13d508f8 |
permissions | -rw-r--r-- |
3399 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by eXept Software AG |
|
3 |
All Rights Reserved |
|
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 |
"{ Package: 'stx:libwidg2' }" |
|
13 |
||
4867 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
3399 | 16 |
MenuPanel subclass:#FontMenu |
3405 | 17 |
instanceVariableNames:'fontAspects enabledChannel labelsAreEmphasized |
4583 | 18 |
fontIsSymbolicHolder fontSymbol allowSymbolicFontsHolder |
19 |
applicationClass' |
|
3399 | 20 |
classVariableNames:'' |
21 |
poolDictionaries:'' |
|
22 |
category:'Interface-UIPainter' |
|
23 |
! |
|
24 |
||
25 |
!FontMenu class methodsFor:'documentation'! |
|
26 |
||
27 |
copyright |
|
421 | 28 |
" |
29 |
COPYRIGHT (c) 1995 by eXept Software AG |
|
30 |
All Rights Reserved |
|
31 |
||
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
3399 | 39 |
|
40 |
||
41 |
! |
|
42 |
||
43 |
documentation |
|
44 |
" |
|
45 |
FontMenu used by UIPainter |
|
46 |
||
47 |
[author:] |
|
48 |
Claus Atzkern |
|
49 |
||
50 |
[see also:] |
|
51 |
UIPainter |
|
52 |
FontMenuSpec |
|
53 |
" |
|
54 |
||
55 |
||
412 | 56 |
! |
57 |
||
3399 | 58 |
examples |
59 |
" |
|
60 |
simple example |
|
61 |
[exBegin] |
|
62 |
|top menu model| |
|
412 | 63 |
|
3405 | 64 |
model := #labelFont asValue. |
65 |
||
3399 | 66 |
top := StandardSystemView new. |
67 |
top extent:250@200. |
|
68 |
menu := FontMenu origin:0.0@0.4 extent:1.0@30 in:top. |
|
3405 | 69 |
menu allowSymbolicFonts:true. |
70 |
menu fontIsSymbolic:true. |
|
3399 | 71 |
menu model:model. |
72 |
top open. |
|
73 |
top waitUntilVisible. |
|
74 |
||
75 |
[ |new old| |
|
76 |
||
77 |
old := model value. |
|
78 |
[ top shown] whileTrue:[ |
|
79 |
new := model value. |
|
80 |
new ~= old ifTrue:[ |
|
81 |
old := new. |
|
82 |
old notNil ifTrue:[ Transcript showCR:(old userFriendlyName) ] |
|
83 |
ifFalse:[ Transcript showCR:'---------' ] |
|
84 |
]. |
|
85 |
Delay waitForSeconds:0.2. |
|
86 |
] |
|
87 |
||
88 |
] forkAt:8. |
|
89 |
[exEnd] |
|
90 |
" |
|
91 |
! ! |
|
92 |
||
4583 | 93 |
!FontMenu class methodsFor:'help specs'! |
94 |
||
95 |
helpSpec |
|
96 |
"This resource specification was automatically generated |
|
97 |
by the UIHelpTool of ST/X." |
|
98 |
||
99 |
"Do not manually edit this!! If it is corrupted, |
|
100 |
the UIHelpTool may not be able to read the specification." |
|
101 |
||
102 |
" |
|
103 |
UIHelpTool openOnClass:FontMenu |
|
104 |
" |
|
105 |
||
106 |
<resource: #help> |
|
107 |
||
108 |
^ super helpSpec addPairsFrom:#( |
|
109 |
||
110 |
#openFontChooser |
|
111 |
'' |
|
112 |
||
113 |
) |
|
114 |
! ! |
|
115 |
||
3399 | 116 |
!FontMenu class methodsFor:'menu specs'! |
117 |
||
118 |
menu |
|
119 |
"This resource specification was automatically generated |
|
120 |
by the MenuEditor of ST/X." |
|
121 |
||
122 |
"Do not manually edit this!! If it is corrupted, |
|
123 |
the MenuEditor may not be able to read the specification." |
|
124 |
||
4583 | 125 |
|
3399 | 126 |
" |
127 |
MenuEditor new openOnClass:FontMenu andSelector:#menu |
|
128 |
(Menu new fromLiteralArrayEncoding:(FontMenu menu)) startUp |
|
129 |
" |
|
130 |
||
131 |
<resource: #menu> |
|
132 |
||
133 |
^ |
|
134 |
#(Menu |
|
135 |
( |
|
136 |
(MenuItem |
|
3407 | 137 |
activeHelpKey: useDefaultFontToggle |
3399 | 138 |
label: 'enabled' |
139 |
itemValue: updateModel |
|
140 |
indication: enabledChannel |
|
141 |
labelImage: (ResourceRetriever SystemBrowser emptyIcon) |
|
142 |
) |
|
143 |
(MenuItem |
|
3407 | 144 |
activeHelpKey: toggleSymbolicFont |
3400 | 145 |
label: 'Symbolic' |
3405 | 146 |
isVisible: allowSymbolicFontsAndEnabledHolder |
3400 | 147 |
indication: fontIsSymbolicHolder |
148 |
) |
|
149 |
(MenuItem |
|
3407 | 150 |
label: '-' |
151 |
isVisible: allowSymbolicFontsAndEnabledHolder |
|
152 |
) |
|
153 |
(MenuItem |
|
3400 | 154 |
enabled: enabledChannel |
155 |
label: 'Symbolic Name' |
|
156 |
nameKey: fontSymbol |
|
157 |
isButton: true |
|
158 |
isVisible: allowSymbolicFontsAndFontIsSymbolicHolder |
|
4583 | 159 |
submenuChannel: symbolicFontsMenu |
3400 | 160 |
) |
161 |
(MenuItem |
|
3440 | 162 |
activeHelpKey: openFontChooser |
3399 | 163 |
enabled: enabledChannel |
3407 | 164 |
label: 'Choose...' |
165 |
itemValue: openFontChooser |
|
4583 | 166 |
isButton: true |
3407 | 167 |
isVisible: enabledAndFontIsNotSymbolicHolder |
168 |
labelImage: (ResourceRetriever XPToolbarIconLibrary fontIcon) |
|
169 |
) |
|
170 |
(MenuItem |
|
171 |
activeHelpKey: concreteFontsFamily |
|
172 |
enabled: enabledChannel |
|
3399 | 173 |
label: 'Family' |
174 |
nameKey: fontFamily |
|
175 |
isButton: true |
|
3400 | 176 |
isVisible: fontIsNotSymbolicHolder |
3399 | 177 |
submenu: |
178 |
(Menu |
|
179 |
( |
|
180 |
(MenuItem |
|
181 |
label: 'helvetica' |
|
182 |
itemValue: fontFamily: |
|
183 |
argument: helvetica |
|
184 |
) |
|
185 |
(MenuItem |
|
186 |
label: 'courier' |
|
187 |
itemValue: fontFamily: |
|
188 |
argument: courier |
|
189 |
) |
|
190 |
(MenuItem |
|
191 |
label: 'times' |
|
192 |
itemValue: fontFamily: |
|
193 |
argument: times |
|
194 |
) |
|
195 |
(MenuItem |
|
196 |
label: 'clean' |
|
197 |
itemValue: fontFamily: |
|
198 |
argument: clean |
|
199 |
) |
|
200 |
(MenuItem |
|
201 |
label: 'fixed' |
|
202 |
itemValue: fontFamily: |
|
203 |
argument: fixed |
|
204 |
) |
|
205 |
(MenuItem |
|
206 |
label: 'lucida' |
|
207 |
itemValue: fontFamily: |
|
208 |
argument: lucida |
|
209 |
) |
|
210 |
(MenuItem |
|
211 |
label: '-' |
|
212 |
) |
|
213 |
(MenuItem |
|
214 |
label: 'Other...' |
|
215 |
itemValue: launchFontFamilyDialog |
|
216 |
) |
|
217 |
) |
|
218 |
nil |
|
219 |
nil |
|
220 |
) |
|
221 |
) |
|
222 |
(MenuItem |
|
3407 | 223 |
activeHelpKey: concreteFontsFace |
3399 | 224 |
enabled: enabledChannel |
225 |
label: 'Face' |
|
226 |
nameKey: fontFace |
|
227 |
isButton: true |
|
3405 | 228 |
isVisible: fontIsNotSymbolicHolder |
3399 | 229 |
submenu: |
230 |
(Menu |
|
231 |
( |
|
232 |
(MenuItem |
|
233 |
label: 'bold' |
|
234 |
itemValue: fontFace: |
|
235 |
argument: bold |
|
236 |
) |
|
237 |
(MenuItem |
|
238 |
label: 'medium' |
|
239 |
itemValue: fontFace: |
|
240 |
argument: medium |
|
241 |
) |
|
242 |
(MenuItem |
|
243 |
label: '-' |
|
244 |
) |
|
245 |
(MenuItem |
|
246 |
label: 'Other...' |
|
247 |
itemValue: launchFontFaceDialog |
|
248 |
) |
|
249 |
) |
|
250 |
nil |
|
251 |
nil |
|
252 |
) |
|
253 |
) |
|
254 |
(MenuItem |
|
3407 | 255 |
activeHelpKey: concreteFontsStyle |
3399 | 256 |
enabled: enabledChannel |
257 |
label: 'Style' |
|
258 |
nameKey: fontStyle |
|
259 |
isButton: true |
|
3405 | 260 |
isVisible: fontIsNotSymbolicHolder |
3399 | 261 |
submenu: |
262 |
(Menu |
|
263 |
( |
|
264 |
(MenuItem |
|
265 |
label: 'roman' |
|
266 |
itemValue: fontStyle: |
|
267 |
argument: roman |
|
268 |
) |
|
269 |
(MenuItem |
|
270 |
label: 'italic' |
|
271 |
itemValue: fontStyle: |
|
272 |
argument: italic |
|
273 |
) |
|
274 |
(MenuItem |
|
275 |
label: 'oblique' |
|
276 |
itemValue: fontStyle: |
|
277 |
argument: oblique |
|
278 |
) |
|
279 |
(MenuItem |
|
280 |
label: '-' |
|
281 |
) |
|
282 |
(MenuItem |
|
283 |
label: 'Other...' |
|
284 |
itemValue: launchFontStyleDialog |
|
285 |
) |
|
286 |
) |
|
287 |
nil |
|
288 |
nil |
|
289 |
) |
|
290 |
) |
|
291 |
(MenuItem |
|
3407 | 292 |
activeHelpKey: concreteFontsSize |
3399 | 293 |
enabled: enabledChannel |
294 |
label: 'Size' |
|
295 |
nameKey: fontSize |
|
296 |
isButton: true |
|
3405 | 297 |
isVisible: fontIsNotSymbolicHolder |
3399 | 298 |
submenu: |
299 |
(Menu |
|
300 |
( |
|
301 |
(MenuItem |
|
302 |
label: '6' |
|
303 |
itemValue: fontSize: |
|
304 |
argument: 6 |
|
305 |
) |
|
306 |
(MenuItem |
|
307 |
label: '8' |
|
308 |
itemValue: fontSize: |
|
309 |
argument: 8 |
|
310 |
) |
|
311 |
(MenuItem |
|
312 |
label: '10' |
|
313 |
itemValue: fontSize: |
|
314 |
argument: 10 |
|
315 |
) |
|
316 |
(MenuItem |
|
317 |
label: '12' |
|
318 |
itemValue: fontSize: |
|
319 |
argument: 12 |
|
320 |
) |
|
321 |
(MenuItem |
|
322 |
label: '14' |
|
323 |
itemValue: fontSize: |
|
324 |
argument: 14 |
|
325 |
) |
|
326 |
(MenuItem |
|
327 |
label: '16' |
|
328 |
itemValue: fontSize: |
|
329 |
argument: 16 |
|
330 |
) |
|
331 |
(MenuItem |
|
332 |
label: '18' |
|
333 |
itemValue: fontSize: |
|
334 |
argument: 18 |
|
335 |
) |
|
336 |
(MenuItem |
|
3405 | 337 |
label: '24' |
338 |
itemValue: fontSize: |
|
339 |
argument: 24 |
|
340 |
) |
|
341 |
(MenuItem |
|
3407 | 342 |
label: '32' |
3405 | 343 |
itemValue: fontSize: |
3407 | 344 |
argument: 32 |
3405 | 345 |
) |
346 |
(MenuItem |
|
3399 | 347 |
label: '-' |
348 |
) |
|
349 |
(MenuItem |
|
350 |
label: 'Other...' |
|
351 |
itemValue: launchFontSizeDialog |
|
352 |
) |
|
353 |
) |
|
354 |
nil |
|
355 |
nil |
|
356 |
) |
|
357 |
) |
|
358 |
(MenuItem |
|
359 |
enabled: enabledChannel |
|
360 |
label: 'Encoding' |
|
361 |
nameKey: fontEncoding |
|
362 |
isButton: true |
|
3405 | 363 |
isVisible: fontIsNotSymbolicHolder |
3399 | 364 |
submenu: |
365 |
(Menu |
|
366 |
( |
|
367 |
(MenuItem |
|
368 |
label: 'latin-1' |
|
369 |
itemValue: fontEncoding: |
|
370 |
argument: #'iso8859-1' |
|
371 |
) |
|
372 |
(MenuItem |
|
373 |
label: 'unicode' |
|
374 |
itemValue: fontEncoding: |
|
375 |
argument: #'iso10646-1' |
|
376 |
) |
|
377 |
(MenuItem |
|
378 |
label: '-' |
|
379 |
) |
|
380 |
(MenuItem |
|
381 |
label: 'Other...' |
|
382 |
itemValue: launchFontEncodingDialog |
|
383 |
) |
|
384 |
) |
|
385 |
nil |
|
386 |
nil |
|
387 |
) |
|
388 |
) |
|
389 |
) |
|
390 |
nil |
|
391 |
nil |
|
392 |
) |
|
393 |
! ! |
|
412 | 394 |
|
2189 | 395 |
!FontMenu methodsFor:'accessing'! |
412 | 396 |
|
3398 | 397 |
allowSymbolicFonts |
3400 | 398 |
^ self allowSymbolicFontsHolder value |
2189 | 399 |
! |
412 | 400 |
|
3398 | 401 |
allowSymbolicFonts:aBoolean |
3400 | 402 |
self allowSymbolicFontsHolder value:aBoolean. |
403 |
! |
|
404 |
||
3399 | 405 |
fontDescription |
3407 | 406 |
"get the current font description" |
407 |
||
408 |
|fontSize| |
|
409 |
||
3399 | 410 |
enabledChannel value ifFalse:[^ nil]. |
411 |
||
3407 | 412 |
self fontIsSymbolic ifTrue:[ |
413 |
^ fontSymbol |
|
414 |
]. |
|
415 |
||
416 |
fontSize := fontAspects at:#fontSize. |
|
417 |
(fontSize isFloat and:[fontSize asInteger = fontSize]) ifTrue:[ |
|
418 |
fontSize := fontSize asInteger |
|
419 |
]. |
|
420 |
||
421 |
^ FontDescription |
|
3399 | 422 |
family:(fontAspects at:#fontFamily) |
423 |
face:(fontAspects at:#fontFace) |
|
424 |
style:(fontAspects at:#fontStyle) |
|
3407 | 425 |
size:fontSize |
3640 | 426 |
sizeUnit:#pt "(fontAspects at:#sizeUnit)" |
3399 | 427 |
encoding:(fontAspects at:#fontEncoding) |
428 |
! |
|
429 |
||
430 |
fontDescription:aFontDesc |
|
3407 | 431 |
"set the font description" |
432 |
||
433 |
|saveModel symbolic| |
|
3399 | 434 |
|
435 |
aFontDesc isNil ifTrue:[ |
|
436 |
enabledChannel value:false. |
|
437 |
^ self |
|
438 |
]. |
|
439 |
||
440 |
self disabledRedrawDo:[ |
|
441 |
saveModel := model. "/ do not inform the model |
|
442 |
model := nil. |
|
443 |
||
444 |
enabledChannel value:true. |
|
3407 | 445 |
symbolic := (aFontDesc isSymbol or:[aFontDesc isString]). |
3399 | 446 |
|
3407 | 447 |
self fontIsSymbolicHolder value:symbolic. |
448 |
symbolic ifTrue:[ |
|
3405 | 449 |
self fontSymbol:aFontDesc asSymbol. |
3399 | 450 |
] ifFalse:[ |
451 |
self fontFamily:(aFontDesc family). |
|
452 |
self fontFace:(aFontDesc face). |
|
453 |
self fontStyle:(aFontDesc style). |
|
454 |
self fontSize:(aFontDesc size). |
|
455 |
self fontEncoding:(aFontDesc encoding ? #'iso10646-1'). |
|
456 |
]. |
|
457 |
model := saveModel. |
|
458 |
] |
|
459 |
! |
|
460 |
||
3405 | 461 |
fontIsSymbolic |
462 |
^ self fontIsSymbolicHolder value |
|
463 |
! |
|
464 |
||
465 |
fontIsSymbolic:aBoolean |
|
466 |
self fontIsSymbolicHolder value:aBoolean. |
|
467 |
! |
|
468 |
||
469 |
fontSymbol |
|
470 |
^ fontSymbol |
|
471 |
! |
|
472 |
||
4583 | 473 |
fontSymbol:aSymbolOrMenuItem |
474 |
aSymbolOrMenuItem isSymbol ifTrue:[ |
|
475 |
fontSymbol := aSymbolOrMenuItem. |
|
476 |
] ifFalse:[ |
|
477 |
fontSymbol := aSymbolOrMenuItem label asSymbol. |
|
478 |
]. |
|
3407 | 479 |
|
3405 | 480 |
(self itemAt:#fontSymbol) label:fontSymbol. |
481 |
self updateModel. |
|
482 |
! |
|
483 |
||
484 |
labelsAreEmphasized |
|
485 |
^ labelsAreEmphasized |
|
486 |
! |
|
487 |
||
488 |
labelsAreEmphasized:aBoolean |
|
489 |
labelsAreEmphasized := aBoolean. |
|
490 |
! ! |
|
491 |
||
492 |
!FontMenu methodsFor:'accessing-channels'! |
|
493 |
||
494 |
allowSymbolicFontsAndEnabledHolder |
|
495 |
^ self allowSymbolicFontsHolder & self enabledChannel |
|
496 |
! |
|
497 |
||
498 |
allowSymbolicFontsAndFontIsSymbolicHolder |
|
499 |
^ self fontIsSymbolicHolder & self allowSymbolicFontsHolder |
|
500 |
! |
|
501 |
||
502 |
allowSymbolicFontsHolder |
|
503 |
allowSymbolicFontsHolder isNil ifTrue:[ |
|
504 |
allowSymbolicFontsHolder := BooleanValueHolder with:false |
|
505 |
]. |
|
506 |
^ allowSymbolicFontsHolder |
|
507 |
! |
|
508 |
||
3407 | 509 |
enabledAndFontIsNotSymbolicHolder |
510 |
^ self fontIsNotSymbolicHolder & self enabledChannel |
|
511 |
! |
|
512 |
||
3405 | 513 |
enabledChannel |
514 |
^ enabledChannel |
|
515 |
! |
|
516 |
||
4867 | 517 |
enabledChannel:aValueHolder |
518 |
enabledChannel := aValueHolder. |
|
519 |
! |
|
520 |
||
3400 | 521 |
fontIsNotSymbolicHolder |
3417
eeec9494d09d
cannot use not as selector - sigh !
Claus Gittinger <cg@exept.de>
parents:
3407
diff
changeset
|
522 |
^ self fontIsSymbolicHolder logicalNot |
3400 | 523 |
! |
524 |
||
525 |
fontIsSymbolicHolder |
|
526 |
fontIsSymbolicHolder isNil ifTrue:[ |
|
527 |
fontIsSymbolicHolder := BooleanValueHolder with:false |
|
528 |
]. |
|
529 |
^ fontIsSymbolicHolder |
|
530 |
! |
|
531 |
||
3405 | 532 |
model:aValueHolder |
533 |
"set my model" |
|
3400 | 534 |
|
3405 | 535 |
super model:aValueHolder. |
4091 | 536 |
model notNil ifTrue:[ |
3405 | 537 |
self updateFromModel |
538 |
]. |
|
4091 | 539 |
|
540 |
"Modified: / 29-11-2011 / 11:27:31 / cg" |
|
412 | 541 |
! ! |
542 |
||
3405 | 543 |
!FontMenu methodsFor:'aspects'! |
412 | 544 |
|
3399 | 545 |
fontAspectAt:key put:value |
3407 | 546 |
(value isNil or:[value = (fontAspects at:key)]) ifTrue:[ |
3399 | 547 |
^ self |
548 |
]. |
|
549 |
fontAspects at:key put:value. |
|
550 |
(self itemAt:key) label:value. |
|
551 |
||
552 |
self updateModel. |
|
553 |
! |
|
554 |
||
3407 | 555 |
fontEncoding |
556 |
^ fontAspects at:#fontEncoding |
|
557 |
! |
|
558 |
||
3399 | 559 |
fontEncoding:anEncodingSymbol |
560 |
^ self fontAspectAt:#fontEncoding put:anEncodingSymbol |
|
561 |
! |
|
562 |
||
3407 | 563 |
fontFace |
564 |
^ fontAspects at:#fontFace |
|
565 |
! |
|
566 |
||
3399 | 567 |
fontFace:aFace |
568 |
^ self fontAspectAt:#fontFace put:aFace |
|
569 |
! |
|
570 |
||
3407 | 571 |
fontFamily |
572 |
^ fontAspects at:#fontFamily |
|
573 |
! |
|
574 |
||
3399 | 575 |
fontFamily:aFamily |
576 |
^ self fontAspectAt:#fontFamily put:aFamily |
|
577 |
! |
|
578 |
||
3407 | 579 |
fontSize |
580 |
^ fontAspects at:#fontSize |
|
581 |
! |
|
582 |
||
3399 | 583 |
fontSize:aSize |
584 |
^ self fontAspectAt:#fontSize put:aSize |
|
585 |
! |
|
586 |
||
3407 | 587 |
fontStyle |
588 |
^ fontAspects at:#fontStyle |
|
3399 | 589 |
! |
590 |
||
3407 | 591 |
fontStyle:aStyle |
592 |
^ self fontAspectAt:#fontStyle put:aStyle |
|
3399 | 593 |
! ! |
594 |
||
595 |
!FontMenu methodsFor:'change & update'! |
|
596 |
||
597 |
updateFromModel |
|
598 |
self fontDescription:(model value) |
|
599 |
! |
|
600 |
||
601 |
updateModel |
|
4091 | 602 |
model notNil ifTrue:[ |
3399 | 603 |
model value:(self fontDescription) withoutNotifying:self |
604 |
]. |
|
4091 | 605 |
|
606 |
"Modified: / 29-11-2011 / 11:27:35 / cg" |
|
3399 | 607 |
! ! |
608 |
||
6168 | 609 |
!FontMenu methodsFor:'help specs'! |
3440 | 610 |
|
5678 | 611 |
helpSpec |
3440 | 612 |
"This resource specification was automatically generated |
613 |
by the UIHelpTool of ST/X." |
|
614 |
||
615 |
"Do not manually edit this!! If it is corrupted, |
|
616 |
the UIHelpTool may not be able to read the specification." |
|
617 |
||
618 |
" |
|
619 |
UIHelpTool openOnClass:ColorEditDialog |
|
620 |
" |
|
621 |
||
622 |
<resource: #help> |
|
623 |
||
5678 | 624 |
^ super helpSpec addPairsFrom:#( |
3440 | 625 |
|
626 |
#useDefaultFontToggle |
|
627 |
'Turn on, to specify the font here. Turn off to use the default' |
|
628 |
||
629 |
#toggleSymbolicFont |
|
630 |
'Turn on, to specify a symbolic font. Turn off to specify a concrete font' |
|
631 |
||
632 |
#openFontChooser |
|
633 |
'Open a font dialog' |
|
634 |
||
635 |
) |
|
636 |
! ! |
|
637 |
||
3399 | 638 |
!FontMenu methodsFor:'initialization'! |
639 |
||
640 |
destroy |
|
641 |
"release dependencies" |
|
642 |
||
643 |
self model:nil. |
|
644 |
enabledChannel removeDependent:self. |
|
645 |
super destroy. |
|
646 |
! |
|
647 |
||
648 |
initialize |
|
649 |
"setup menu" |
|
650 |
||
651 |
super initialize. |
|
652 |
||
653 |
fontAspects := IdentityDictionary new. |
|
654 |
enabledChannel := false asValue. |
|
655 |
labelsAreEmphasized := false. |
|
3405 | 656 |
self allowSymbolicFonts:false. |
3399 | 657 |
|
4583 | 658 |
#(fontFamily fontFace fontStyle fontSize fontEncoding) do:[:k| |
3399 | 659 |
fontAspects at:k put:(nil asValue) |
660 |
]. |
|
661 |
self verticalLayout:false. |
|
662 |
self menu:(self class menu). |
|
663 |
enabledChannel := false asValue. |
|
664 |
receiver := self. |
|
665 |
||
4583 | 666 |
self fontDescription:self font. |
667 |
applicationClass := UIPainter applicationClassQuery query ? ApplicationModel. |
|
668 |
! ! |
|
669 |
||
670 |
!FontMenu methodsFor:'menu spec'! |
|
671 |
||
672 |
symbolicFontsMenu |
|
5270 | 673 |
|symbolicFontSelectors bigFontSelectors smallFontSelectors normalFontSelectors |
674 |
selectors menu menuLabels menuItems| |
|
4583 | 675 |
|
5269 | 676 |
symbolicFontSelectors := (applicationClass methodsWithAnyResource:#(fontSpec)) |
677 |
collect:[:each| each selector]. |
|
4583 | 678 |
|
5270 | 679 |
bigFontSelectors := (symbolicFontSelectors select:[:nm | nm endsWith:'Big']) sort. |
680 |
smallFontSelectors := (symbolicFontSelectors select:[:nm | nm endsWith:'Small']) sort. |
|
681 |
normalFontSelectors := (symbolicFontSelectors reject:[:nm | nm endsWithAnyOf:#('Small' 'Big')]) sort. |
|
5269 | 682 |
symbolicFontSelectors := |
5270 | 683 |
normalFontSelectors , #(nil) , smallFontSelectors , #(nil) , bigFontSelectors. |
4583 | 684 |
|
5270 | 685 |
selectors := (Array new:normalFontSelectors size withAll:#fontSymbol:) |
686 |
, #( nil ) |
|
687 |
, (Array new:smallFontSelectors size withAll:#fontSymbol:) |
|
688 |
, #( nil ) |
|
689 |
, (Array new:bigFontSelectors size withAll:#fontSymbol:) |
|
690 |
, #(nil launchFontSymbolDialog). |
|
691 |
||
692 |
menuLabels := normalFontSelectors |
|
693 |
, #('-') |
|
694 |
, smallFontSelectors |
|
695 |
, #('-') |
|
696 |
, bigFontSelectors |
|
697 |
, #('-' 'Other...'). |
|
4583 | 698 |
|
699 |
menu := Menu labelArray:menuLabels values:selectors. |
|
700 |
menuItems := menu items. |
|
701 |
symbolicFontSelectors keysAndValuesDo:[:eachIndex :eachFontSelector| |
|
4584 | 702 |
|font| |
5270 | 703 |
eachFontSelector notNil ifTrue:[ font := applicationClass resolveFont:eachFontSelector ]. |
4584 | 704 |
font notNil ifTrue:[ |
705 |
(menuItems at:eachIndex) font:font. |
|
706 |
]. |
|
4583 | 707 |
]. |
708 |
||
709 |
^ menu |
|
3399 | 710 |
! ! |
711 |
||
3407 | 712 |
!FontMenu methodsFor:'user actions'! |
713 |
||
714 |
launchFontEncodingDialog |
|
715 |
"launch dialog to get a font encoding" |
|
716 |
||
717 |
|string| |
|
718 |
||
719 |
string := EnterBox |
|
720 |
request:(resources string:'Encoding:') |
|
721 |
initialAnswer:(self fontEncoding). |
|
722 |
||
723 |
string notEmptyOrNil ifTrue:[ |
|
724 |
self fontEncoding:string asSymbol |
|
725 |
]. |
|
726 |
! |
|
727 |
||
728 |
launchFontFaceDialog |
|
729 |
"launch dialog to get a font face" |
|
730 |
||
731 |
|string| |
|
732 |
||
733 |
string := EnterBox |
|
734 |
request:(resources string:'Face:') |
|
735 |
initialAnswer:(self fontFace). |
|
736 |
||
737 |
string notEmptyOrNil ifTrue:[ |
|
738 |
self fontFace:string |
|
739 |
]. |
|
740 |
! |
|
741 |
||
742 |
launchFontFamilyDialog |
|
743 |
"launch dialog to get a font family" |
|
744 |
||
745 |
|string| |
|
746 |
||
747 |
string := EnterBox |
|
748 |
request:(resources string:'Family:') |
|
749 |
initialAnswer:(self fontFamily). |
|
750 |
||
751 |
string notEmptyOrNil ifTrue:[ |
|
752 |
self fontFamily:string |
|
753 |
]. |
|
754 |
! |
|
755 |
||
756 |
launchFontSizeDialog |
|
757 |
"launch dialog to get a font size" |
|
758 |
||
759 |
|size string| |
|
760 |
||
761 |
string := EnterBox |
|
762 |
request:(resources string:'Size:') |
|
763 |
initialAnswer:(self fontSize printString). |
|
764 |
||
765 |
string notEmptyOrNil ifTrue:[ |
|
766 |
size := SmallInteger readFrom:string onError:nil. |
|
767 |
||
768 |
(size notNil and:[size >= 1 and:[size <= 128]]) ifTrue:[ |
|
769 |
self fontSize:size |
|
770 |
] |
|
771 |
]. |
|
772 |
! |
|
773 |
||
774 |
launchFontStyleDialog |
|
775 |
"launch dialog to get a font style" |
|
776 |
||
777 |
|string| |
|
778 |
||
779 |
string := EnterBox |
|
780 |
request:(resources string:'Style:') |
|
781 |
initialAnswer:(self fontStyle). |
|
782 |
||
783 |
string notEmptyOrNil ifTrue:[ |
|
784 |
self fontFace:string |
|
785 |
]. |
|
786 |
! |
|
787 |
||
788 |
launchFontSymbolDialog |
|
789 |
"launch dialog to get a font symbol" |
|
790 |
||
791 |
|string| |
|
792 |
||
793 |
string := EnterBox |
|
5270 | 794 |
request:(resources string:'Symbol (message to app, which returns the font):') |
3407 | 795 |
initialAnswer:(self fontSymbol). |
796 |
||
797 |
string notEmptyOrNil ifTrue:[ |
|
798 |
self fontSymbol:string asSymbol |
|
799 |
]. |
|
800 |
! |
|
801 |
||
802 |
openFontChooser |
|
803 |
|choosenFont| |
|
804 |
||
805 |
choosenFont := FontPanel fontFromUserInitial:(self fontDescription). |
|
806 |
choosenFont notNil ifTrue: [ |
|
807 |
self fontDescription:choosenFont. |
|
808 |
self updateModel. |
|
809 |
] |
|
810 |
! ! |
|
811 |
||
3399 | 812 |
!FontMenu class methodsFor:'documentation'! |
813 |
||
814 |
version |
|
4867 | 815 |
^ '$Header$' |
4002 | 816 |
! |
817 |
||
818 |
version_CVS |
|
4867 | 819 |
^ '$Header$' |
3399 | 820 |
! ! |
4583 | 821 |