421
|
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 |
|
|
13 |
|
|
14 |
|
1808
|
15 |
"{ Package: 'stx:libtool2' }"
|
|
16 |
|
412
|
17 |
MenuPanel subclass:#FontMenu
|
2189
|
18 |
instanceVariableNames:'fontAspects enabledChannel'
|
412
|
19 |
classVariableNames:''
|
|
20 |
poolDictionaries:''
|
|
21 |
category:'Interface-UIPainter'
|
|
22 |
!
|
|
23 |
|
|
24 |
!FontMenu class methodsFor:'documentation'!
|
|
25 |
|
421
|
26 |
copyright
|
|
27 |
"
|
|
28 |
COPYRIGHT (c) 1995 by eXept Software AG
|
|
29 |
All Rights Reserved
|
|
30 |
|
|
31 |
This software is furnished under a license and may be used
|
|
32 |
only in accordance with the terms of that license and with the
|
|
33 |
inclusion of the above copyright notice. This software may not
|
|
34 |
be provided or otherwise made available to, or used by, any
|
|
35 |
other person. No title to or ownership of the software is
|
|
36 |
hereby transferred.
|
|
37 |
"
|
|
38 |
|
|
39 |
|
|
40 |
!
|
|
41 |
|
412
|
42 |
documentation
|
|
43 |
"
|
|
44 |
FontMenu used by UIPainter
|
|
45 |
|
421
|
46 |
[author:]
|
|
47 |
Claus Atzkern
|
|
48 |
|
412
|
49 |
[see also:]
|
|
50 |
UIPainter
|
|
51 |
FontMenuSpec
|
|
52 |
"
|
|
53 |
|
|
54 |
|
|
55 |
!
|
|
56 |
|
|
57 |
examples
|
|
58 |
"
|
|
59 |
simple example
|
|
60 |
[exBegin]
|
2189
|
61 |
|top menu model|
|
412
|
62 |
|
|
63 |
top := StandardSystemView new.
|
2189
|
64 |
top extent:250@200.
|
|
65 |
menu := FontMenu origin:0.0@0.4 extent:1.0@30 in:top.
|
|
66 |
model := nil asValue.
|
|
67 |
menu model:model.
|
412
|
68 |
top open.
|
2189
|
69 |
top waitUntilVisible.
|
|
70 |
|
|
71 |
[ |new old|
|
|
72 |
|
|
73 |
old := model value.
|
|
74 |
[ top shown] whileTrue:[
|
|
75 |
new := model value.
|
|
76 |
new ~= old ifTrue:[
|
|
77 |
old := new.
|
|
78 |
old notNil ifTrue:[ Transcript showCR:(old userFriendlyName) ]
|
|
79 |
ifFalse:[ Transcript showCR:'---------' ]
|
|
80 |
].
|
|
81 |
Delay waitForSeconds:0.2.
|
|
82 |
]
|
|
83 |
|
|
84 |
] forkAt:8.
|
412
|
85 |
[exEnd]
|
|
86 |
"
|
|
87 |
! !
|
|
88 |
|
|
89 |
!FontMenu class methodsFor:'menu spec'!
|
|
90 |
|
|
91 |
menu
|
2189
|
92 |
"This resource specification was automatically generated
|
|
93 |
by the MenuEditor of ST/X."
|
|
94 |
|
|
95 |
"Do not manually edit this!! If it is corrupted,
|
|
96 |
the MenuEditor may not be able to read the specification."
|
|
97 |
|
|
98 |
"
|
|
99 |
MenuEditor new openOnClass:FontMenu andSelector:#menu
|
|
100 |
(Menu new fromLiteralArrayEncoding:(FontMenu menu)) startUp
|
|
101 |
"
|
799
|
102 |
|
583
|
103 |
<resource: #menu>
|
412
|
104 |
|
2189
|
105 |
^
|
2749
|
106 |
#(Menu
|
|
107 |
(
|
|
108 |
(MenuItem
|
|
109 |
label: 'enabled'
|
|
110 |
itemValue: updateModel
|
|
111 |
translateLabel: true
|
|
112 |
indication: enabledChannel
|
|
113 |
labelImage: (ResourceRetriever SystemBrowser emptyIcon)
|
2189
|
114 |
)
|
2749
|
115 |
(MenuItem
|
|
116 |
enabled: enabledChannel
|
|
117 |
label: 'Family'
|
|
118 |
nameKey: fontFamily
|
|
119 |
translateLabel: true
|
|
120 |
isButton: true
|
|
121 |
submenu:
|
|
122 |
(Menu
|
|
123 |
(
|
|
124 |
(MenuItem
|
|
125 |
label: 'helvetica'
|
|
126 |
itemValue: fontFamily:
|
|
127 |
translateLabel: true
|
|
128 |
argument: helvetica
|
|
129 |
)
|
|
130 |
(MenuItem
|
|
131 |
label: 'courier'
|
|
132 |
itemValue: fontFamily:
|
|
133 |
translateLabel: true
|
|
134 |
argument: courier
|
2189
|
135 |
)
|
2749
|
136 |
(MenuItem
|
|
137 |
label: 'times'
|
|
138 |
itemValue: fontFamily:
|
|
139 |
translateLabel: true
|
|
140 |
argument: times
|
2189
|
141 |
)
|
2749
|
142 |
(MenuItem
|
|
143 |
label: 'clean'
|
|
144 |
itemValue: fontFamily:
|
|
145 |
translateLabel: true
|
|
146 |
argument: clean
|
2189
|
147 |
)
|
2749
|
148 |
(MenuItem
|
|
149 |
label: 'fixed'
|
|
150 |
itemValue: fontFamily:
|
|
151 |
translateLabel: true
|
|
152 |
argument: fixed
|
2189
|
153 |
)
|
2749
|
154 |
(MenuItem
|
|
155 |
label: 'lucida'
|
|
156 |
itemValue: fontFamily:
|
|
157 |
translateLabel: true
|
|
158 |
argument: lucida
|
412
|
159 |
)
|
2749
|
160 |
(MenuItem
|
|
161 |
label: '-'
|
|
162 |
)
|
|
163 |
(MenuItem
|
|
164 |
label: 'Other...'
|
|
165 |
itemValue: launchFontFamilyDialog
|
|
166 |
translateLabel: true
|
2189
|
167 |
)
|
|
168 |
)
|
|
169 |
nil
|
|
170 |
nil
|
799
|
171 |
)
|
2189
|
172 |
)
|
2749
|
173 |
(MenuItem
|
|
174 |
enabled: enabledChannel
|
|
175 |
label: 'Face'
|
|
176 |
nameKey: fontFace
|
|
177 |
translateLabel: true
|
|
178 |
isButton: true
|
|
179 |
submenu:
|
|
180 |
(Menu
|
|
181 |
(
|
|
182 |
(MenuItem
|
|
183 |
label: 'bold'
|
|
184 |
itemValue: fontFace:
|
|
185 |
translateLabel: true
|
|
186 |
argument: bold
|
2189
|
187 |
)
|
2749
|
188 |
(MenuItem
|
|
189 |
label: 'medium'
|
|
190 |
itemValue: fontFace:
|
|
191 |
translateLabel: true
|
|
192 |
argument: medium
|
|
193 |
)
|
|
194 |
(MenuItem
|
|
195 |
label: '-'
|
|
196 |
)
|
|
197 |
(MenuItem
|
|
198 |
label: 'Other...'
|
|
199 |
itemValue: launchFontFaceDialog
|
|
200 |
translateLabel: true
|
2189
|
201 |
)
|
|
202 |
)
|
|
203 |
nil
|
|
204 |
nil
|
|
205 |
)
|
|
206 |
)
|
2749
|
207 |
(MenuItem
|
|
208 |
enabled: enabledChannel
|
|
209 |
label: 'Style'
|
|
210 |
nameKey: fontStyle
|
|
211 |
translateLabel: true
|
|
212 |
isButton: true
|
|
213 |
submenu:
|
|
214 |
(Menu
|
|
215 |
(
|
|
216 |
(MenuItem
|
|
217 |
label: 'roman'
|
|
218 |
itemValue: fontStyle:
|
|
219 |
translateLabel: true
|
|
220 |
argument: roman
|
412
|
221 |
)
|
2749
|
222 |
(MenuItem
|
|
223 |
label: 'italic'
|
|
224 |
itemValue: fontStyle:
|
|
225 |
translateLabel: true
|
|
226 |
argument: italic
|
412
|
227 |
)
|
2749
|
228 |
(MenuItem
|
|
229 |
label: 'oblique'
|
|
230 |
itemValue: fontStyle:
|
|
231 |
translateLabel: true
|
|
232 |
argument: oblique
|
|
233 |
)
|
|
234 |
(MenuItem
|
|
235 |
label: '-'
|
|
236 |
)
|
|
237 |
(MenuItem
|
|
238 |
label: 'Other...'
|
|
239 |
itemValue: launchFontStyleDialog
|
|
240 |
translateLabel: true
|
2189
|
241 |
)
|
|
242 |
)
|
|
243 |
nil
|
|
244 |
nil
|
799
|
245 |
)
|
2189
|
246 |
)
|
2749
|
247 |
(MenuItem
|
|
248 |
enabled: enabledChannel
|
|
249 |
label: 'Size'
|
|
250 |
nameKey: fontSize
|
|
251 |
translateLabel: true
|
|
252 |
isButton: true
|
|
253 |
submenu:
|
|
254 |
(Menu
|
|
255 |
(
|
|
256 |
(MenuItem
|
|
257 |
label: '6'
|
|
258 |
itemValue: fontSize:
|
|
259 |
translateLabel: true
|
|
260 |
argument: 6
|
|
261 |
)
|
|
262 |
(MenuItem
|
|
263 |
label: '8'
|
|
264 |
itemValue: fontSize:
|
|
265 |
translateLabel: true
|
|
266 |
argument: 8
|
2189
|
267 |
)
|
2749
|
268 |
(MenuItem
|
|
269 |
label: '10'
|
|
270 |
itemValue: fontSize:
|
|
271 |
translateLabel: true
|
|
272 |
argument: 10
|
|
273 |
)
|
|
274 |
(MenuItem
|
|
275 |
label: '12'
|
|
276 |
itemValue: fontSize:
|
|
277 |
translateLabel: true
|
|
278 |
argument: 12
|
2189
|
279 |
)
|
2749
|
280 |
(MenuItem
|
|
281 |
label: '14'
|
|
282 |
itemValue: fontSize:
|
|
283 |
translateLabel: true
|
|
284 |
argument: 14
|
|
285 |
)
|
|
286 |
(MenuItem
|
|
287 |
label: '16'
|
|
288 |
itemValue: fontSize:
|
|
289 |
translateLabel: true
|
|
290 |
argument: 16
|
2189
|
291 |
)
|
2749
|
292 |
(MenuItem
|
|
293 |
label: '18'
|
|
294 |
itemValue: fontSize:
|
|
295 |
translateLabel: true
|
|
296 |
argument: 18
|
412
|
297 |
)
|
2749
|
298 |
(MenuItem
|
|
299 |
label: '-'
|
|
300 |
)
|
|
301 |
(MenuItem
|
|
302 |
label: 'Other...'
|
|
303 |
itemValue: launchFontSizeDialog
|
|
304 |
translateLabel: true
|
2189
|
305 |
)
|
2749
|
306 |
)
|
|
307 |
nil
|
|
308 |
nil
|
|
309 |
)
|
|
310 |
)
|
|
311 |
(MenuItem
|
|
312 |
enabled: enabledChannel
|
|
313 |
label: 'Encoding'
|
|
314 |
nameKey: fontEncoding
|
|
315 |
translateLabel: true
|
|
316 |
isButton: true
|
|
317 |
submenu:
|
|
318 |
(Menu
|
|
319 |
(
|
|
320 |
(MenuItem
|
|
321 |
label: 'latin-1'
|
|
322 |
itemValue: fontEncoding:
|
|
323 |
translateLabel: true
|
|
324 |
argument: #'iso8859-1'
|
2189
|
325 |
)
|
2749
|
326 |
(MenuItem
|
|
327 |
label: 'unicode'
|
|
328 |
itemValue: fontEncoding:
|
|
329 |
translateLabel: true
|
|
330 |
argument: #'iso10646-1'
|
2189
|
331 |
)
|
2749
|
332 |
(MenuItem
|
|
333 |
label: '-'
|
|
334 |
)
|
|
335 |
(MenuItem
|
|
336 |
label: 'Other...'
|
|
337 |
itemValue: launchFontEncodingDialog
|
|
338 |
translateLabel: true
|
2189
|
339 |
)
|
|
340 |
)
|
|
341 |
nil
|
|
342 |
nil
|
799
|
343 |
)
|
2189
|
344 |
)
|
|
345 |
)
|
|
346 |
nil
|
|
347 |
nil
|
799
|
348 |
)
|
412
|
349 |
! !
|
|
350 |
|
2189
|
351 |
!FontMenu methodsFor:'accessing'!
|
412
|
352 |
|
2189
|
353 |
fontDescription
|
|
354 |
"get font description
|
412
|
355 |
"
|
2189
|
356 |
enabledChannel value ifFalse:[^ nil].
|
412
|
357 |
|
2749
|
358 |
^ FontDescription
|
|
359 |
family:(fontAspects at:#fontFamily)
|
|
360 |
face:(fontAspects at:#fontFace)
|
|
361 |
style:(fontAspects at:#fontStyle)
|
|
362 |
size:(fontAspects at:#fontSize)
|
|
363 |
encoding:(fontAspects at:#fontEncoding)
|
2189
|
364 |
!
|
412
|
365 |
|
2189
|
366 |
fontDescription:aFontDesc
|
|
367 |
"set font description
|
|
368 |
"
|
|
369 |
|saveModel|
|
|
370 |
|
|
371 |
aFontDesc ifNil:[
|
|
372 |
enabledChannel value:false.
|
2459
|
373 |
^ self
|
412
|
374 |
].
|
|
375 |
|
2189
|
376 |
self disabledRedrawDo:[
|
|
377 |
saveModel := model. "/ do not inform the model
|
|
378 |
model := nil.
|
|
379 |
|
|
380 |
enabledChannel value:true.
|
|
381 |
|
|
382 |
(aFontDesc isSymbol or:[aFontDesc isString]) ifFalse:[
|
|
383 |
self fontFamily:(aFontDesc family).
|
2749
|
384 |
self fontFace:(aFontDesc face).
|
|
385 |
self fontStyle:(aFontDesc style).
|
|
386 |
self fontSize:(aFontDesc size).
|
|
387 |
self fontEncoding:(aFontDesc encoding ? #'iso10646-1').
|
2189
|
388 |
].
|
|
389 |
model := saveModel.
|
|
390 |
]
|
|
391 |
! !
|
|
392 |
|
|
393 |
!FontMenu methodsFor:'accessing-aspects'!
|
|
394 |
|
|
395 |
fontAspectAt:key put:value
|
|
396 |
(value isNil or:[value == (fontAspects at:key)]) ifTrue:[
|
412
|
397 |
^ self
|
|
398 |
].
|
2189
|
399 |
fontAspects at:key put:value.
|
|
400 |
(self itemAt:key) label:value.
|
412
|
401 |
|
2189
|
402 |
self updateModel.
|
|
403 |
!
|
|
404 |
|
2749
|
405 |
fontEncoding:anEncodingSymbol
|
|
406 |
^ self fontAspectAt:#fontEncoding put:anEncodingSymbol
|
|
407 |
!
|
|
408 |
|
2189
|
409 |
fontFace:aFace
|
|
410 |
^ self fontAspectAt:#fontFace put:aFace
|
412
|
411 |
!
|
|
412 |
|
2189
|
413 |
fontFamily:aFamily
|
|
414 |
^ self fontAspectAt:#fontFamily put:aFamily
|
|
415 |
!
|
|
416 |
|
|
417 |
fontSize:aSize
|
|
418 |
^ self fontAspectAt:#fontSize put:aSize
|
|
419 |
!
|
|
420 |
|
|
421 |
fontStyle:aStyle
|
|
422 |
^ self fontAspectAt:#fontStyle put:aStyle
|
|
423 |
!
|
|
424 |
|
2749
|
425 |
launchFontEncodingDialog
|
|
426 |
"launch dialog to get a font encoding"
|
|
427 |
|
|
428 |
|string|
|
|
429 |
|
|
430 |
string := EnterBox request:'Encoding: '.
|
|
431 |
|
|
432 |
string size ~~ 0 ifTrue:[
|
|
433 |
self fontEncoding:string asSymbol
|
|
434 |
].
|
|
435 |
!
|
|
436 |
|
|
437 |
launchFontFaceDialog
|
|
438 |
"launch dialog to get a font face"
|
|
439 |
|
|
440 |
|string|
|
|
441 |
|
|
442 |
string := EnterBox request:'Face: '.
|
|
443 |
|
|
444 |
string size ~~ 0 ifTrue:[
|
|
445 |
self fontFace:string
|
|
446 |
].
|
|
447 |
!
|
|
448 |
|
|
449 |
launchFontFamilyDialog
|
|
450 |
"launch dialog to get a font family"
|
|
451 |
|
|
452 |
|string|
|
|
453 |
|
|
454 |
string := EnterBox request:'Family: '.
|
|
455 |
|
|
456 |
string size ~~ 0 ifTrue:[
|
|
457 |
self fontFamily:string
|
|
458 |
].
|
|
459 |
!
|
|
460 |
|
2189
|
461 |
launchFontSizeDialog
|
2749
|
462 |
"launch dialog to get a font size"
|
|
463 |
|
412
|
464 |
|size string|
|
|
465 |
|
|
466 |
string := EnterBox request:'size: '.
|
|
467 |
|
|
468 |
string size ~~ 0 ifTrue:[
|
|
469 |
size := SmallInteger readFrom:string onError:nil.
|
|
470 |
|
2749
|
471 |
(size notNil and:[size >= 1 and:[size <= 128]]) ifTrue:[
|
2189
|
472 |
self fontSize:size
|
412
|
473 |
]
|
|
474 |
].
|
2749
|
475 |
!
|
|
476 |
|
|
477 |
launchFontStyleDialog
|
|
478 |
"launch dialog to get a font style"
|
|
479 |
|
|
480 |
|string|
|
|
481 |
|
|
482 |
string := EnterBox request:'Style: '.
|
|
483 |
|
|
484 |
string size ~~ 0 ifTrue:[
|
|
485 |
self fontFace:string
|
|
486 |
].
|
412
|
487 |
! !
|
|
488 |
|
1818
|
489 |
!FontMenu methodsFor:'accessing-channels'!
|
412
|
490 |
|
2189
|
491 |
enabledChannel
|
|
492 |
^ enabledChannel
|
|
493 |
!
|
|
494 |
|
412
|
495 |
model:aValueHolder
|
2749
|
496 |
"set my model"
|
|
497 |
|
2184
|
498 |
super model:aValueHolder.
|
2189
|
499 |
model ifNotNil:[
|
2186
|
500 |
self updateFromModel
|
412
|
501 |
].
|
|
502 |
! !
|
|
503 |
|
|
504 |
!FontMenu methodsFor:'change & update'!
|
|
505 |
|
2186
|
506 |
updateFromModel
|
2184
|
507 |
self fontDescription:(model value)
|
2189
|
508 |
!
|
|
509 |
|
|
510 |
updateModel
|
|
511 |
model ifNotNil:[
|
|
512 |
model value:(self fontDescription) withoutNotifying:self
|
|
513 |
].
|
412
|
514 |
! !
|
|
515 |
|
|
516 |
!FontMenu methodsFor:'initialization'!
|
|
517 |
|
|
518 |
destroy
|
2749
|
519 |
"release dependencies"
|
|
520 |
|
412
|
521 |
self model:nil.
|
2189
|
522 |
enabledChannel removeDependent:self.
|
412
|
523 |
super destroy.
|
|
524 |
!
|
|
525 |
|
|
526 |
initialize
|
2749
|
527 |
"setup menu"
|
|
528 |
|
412
|
529 |
super initialize.
|
2189
|
530 |
|
|
531 |
fontAspects := IdentityDictionary new.
|
|
532 |
enabledChannel := false asValue.
|
|
533 |
|
2749
|
534 |
#( #fontFamily #fontFace #fontStyle #fontSize #fontEncoding) do:[:k|
|
2189
|
535 |
fontAspects at:k put:(nil asValue)
|
|
536 |
].
|
412
|
537 |
self verticalLayout:false.
|
|
538 |
self menu:(self class menu).
|
|
539 |
enabledChannel := false asValue.
|
2189
|
540 |
receiver := self.
|
412
|
541 |
|
|
542 |
self fontDescription:(self font).
|
|
543 |
! !
|
|
544 |
|
|
545 |
!FontMenu class methodsFor:'documentation'!
|
|
546 |
|
|
547 |
version
|
2749
|
548 |
^ '$Header: /cvs/stx/stx/libwidg2/FontMenu.st,v 1.15 2004-10-01 11:20:55 cg Exp $'
|
412
|
549 |
! !
|