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