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