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