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 |
|
412
|
15 |
MenuPanel subclass:#FontMenu
|
|
16 |
instanceVariableNames:'model enabledChannel fontFamily fontFace fontStyle fontSize'
|
|
17 |
classVariableNames:''
|
|
18 |
poolDictionaries:''
|
|
19 |
category:'Interface-UIPainter'
|
|
20 |
!
|
|
21 |
|
|
22 |
!FontMenu class methodsFor:'documentation'!
|
|
23 |
|
421
|
24 |
copyright
|
|
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 |
"
|
|
36 |
|
|
37 |
|
|
38 |
!
|
|
39 |
|
412
|
40 |
documentation
|
|
41 |
"
|
|
42 |
FontMenu used by UIPainter
|
|
43 |
|
421
|
44 |
[author:]
|
|
45 |
Claus Atzkern
|
|
46 |
|
412
|
47 |
[see also:]
|
|
48 |
UIPainter
|
|
49 |
FontMenuSpec
|
|
50 |
"
|
|
51 |
|
|
52 |
|
|
53 |
!
|
|
54 |
|
|
55 |
examples
|
|
56 |
"
|
|
57 |
simple example
|
|
58 |
[exBegin]
|
|
59 |
|top|
|
|
60 |
|
|
61 |
top := StandardSystemView new.
|
|
62 |
top extent:250@30.
|
|
63 |
self origin:0.0@0.0 corner:1.0@1.0 in:top.
|
|
64 |
top open.
|
|
65 |
[exEnd]
|
|
66 |
"
|
|
67 |
! !
|
|
68 |
|
|
69 |
!FontMenu class methodsFor:'menu spec'!
|
|
70 |
|
|
71 |
menu
|
799
|
72 |
|
583
|
73 |
<resource: #menu>
|
412
|
74 |
|
799
|
75 |
^
|
|
76 |
|
|
77 |
#(#Menu
|
|
78 |
|
|
79 |
#(
|
|
80 |
#(#MenuItem
|
|
81 |
#label: ''
|
|
82 |
#indication: false
|
|
83 |
)
|
|
84 |
#(#MenuItem
|
|
85 |
#label: '-'
|
|
86 |
)
|
|
87 |
(#MenuItem
|
|
88 |
#label: 'family'
|
|
89 |
#value: #fontFamily:
|
|
90 |
#isButton: true
|
|
91 |
#submenu:
|
|
92 |
#(#Menu #( #(#MenuItem #label: 'helvetica' value:#helvetica)
|
|
93 |
#(#MenuItem #label: 'courier' value:#courier)
|
|
94 |
#(#MenuItem #label: 'times' value:#times)
|
|
95 |
#(#MenuItem #label: 'clean' value:#clean)
|
|
96 |
#(#MenuItem #label: 'fixed' value:#fixed)
|
|
97 |
#(#MenuItem #label: 'lucida' value:#lucida)
|
412
|
98 |
)
|
|
99 |
nil
|
|
100 |
nil
|
|
101 |
)
|
799
|
102 |
)
|
|
103 |
(#MenuItem
|
|
104 |
#label: 'face'
|
|
105 |
#value: #fontFace:
|
|
106 |
#isButton: true
|
|
107 |
#submenu:
|
|
108 |
#(#Menu #( #(#MenuItem #label: 'bold' value:#bold)
|
|
109 |
#(#MenuItem #label: 'medium' value:#medium)
|
412
|
110 |
)
|
|
111 |
nil
|
|
112 |
nil
|
|
113 |
)
|
799
|
114 |
)
|
|
115 |
(#MenuItem
|
|
116 |
#label: 'style'
|
|
117 |
#value: #fontStyle:
|
|
118 |
#isButton: true
|
|
119 |
#submenu:
|
|
120 |
#(#Menu #( #(#MenuItem #label: 'roman' value:#roman)
|
|
121 |
#(#MenuItem #label: 'italic' value:#italic)
|
|
122 |
#(#MenuItem #label: 'oblique' value:#oblique)
|
|
123 |
)
|
412
|
124 |
nil
|
|
125 |
nil
|
|
126 |
)
|
799
|
127 |
)
|
|
128 |
(#MenuItem
|
|
129 |
#label: 'size'
|
|
130 |
#value: #fontSize:
|
|
131 |
#isButton: true
|
|
132 |
#submenu:
|
|
133 |
#(#Menu #( #(#MenuItem #label: '6' value:6)
|
|
134 |
#(#MenuItem #label: '8' value:8)
|
|
135 |
#(#MenuItem #label: '10' value:10)
|
|
136 |
#(#MenuItem #label: '12' value:12)
|
|
137 |
#(#MenuItem #label: '14' value:14)
|
|
138 |
#(#MenuItem #label: '16' value:16)
|
|
139 |
#(#MenuItem #label: '18' value:18)
|
412
|
140 |
#(#MenuItem #label: 'other ...' value:#size)
|
|
141 |
)
|
|
142 |
nil
|
|
143 |
nil
|
|
144 |
)
|
799
|
145 |
)
|
|
146 |
) nil
|
|
147 |
nil
|
|
148 |
)
|
412
|
149 |
! !
|
|
150 |
|
|
151 |
!FontMenu methodsFor:'accept'!
|
|
152 |
|
|
153 |
accept:anItem
|
|
154 |
"accept current selected item
|
|
155 |
"
|
|
156 |
|item selector arg|
|
|
157 |
|
|
158 |
selector := self selection value.
|
|
159 |
|
|
160 |
(item := super accept:anItem) isNil ifTrue:[
|
|
161 |
^ self
|
|
162 |
].
|
|
163 |
|
|
164 |
(arg := item value) isNil ifTrue:[
|
|
165 |
model notNil ifTrue:[
|
|
166 |
enabledChannel value ifTrue:[
|
|
167 |
arg := self fontDescription
|
|
168 |
].
|
|
169 |
model value:arg
|
|
170 |
].
|
|
171 |
^ self
|
|
172 |
].
|
|
173 |
|
|
174 |
(arg == #size and:[(arg := self readSize) isNil]) ifTrue:[
|
|
175 |
^ self
|
|
176 |
].
|
|
177 |
|
|
178 |
(self perform:selector with:arg) ifTrue:[
|
|
179 |
model notNil ifTrue:[model value:(self fontDescription)]
|
|
180 |
]
|
|
181 |
!
|
|
182 |
|
|
183 |
readSize
|
|
184 |
"read a size; in case of cancel nil is returned otherwise a number.
|
|
185 |
"
|
|
186 |
|size string|
|
|
187 |
|
|
188 |
string := EnterBox request:'size: '.
|
|
189 |
|
|
190 |
string size ~~ 0 ifTrue:[
|
|
191 |
size := SmallInteger readFrom:string onError:nil.
|
|
192 |
|
|
193 |
(size notNil and:[size >= 6 and:[size <= 48]]) ifTrue:[
|
|
194 |
^ size
|
|
195 |
]
|
|
196 |
].
|
|
197 |
^ nil
|
|
198 |
! !
|
|
199 |
|
|
200 |
!FontMenu methodsFor:'accessing'!
|
|
201 |
|
|
202 |
fontDescription
|
|
203 |
"get font description
|
|
204 |
"
|
|
205 |
^ FontDescription family:fontFamily face:fontFace style:fontStyle size:fontSize
|
|
206 |
!
|
|
207 |
|
|
208 |
fontDescription:aFontDesc
|
|
209 |
"set font description
|
|
210 |
"
|
|
211 |
aFontDesc isNil ifTrue:[
|
|
212 |
enabledChannel value:false.
|
|
213 |
] ifFalse:[
|
|
214 |
self disabledRedrawDo:[
|
|
215 |
enabledChannel value:true.
|
1427
|
216 |
(aFontDesc isSymbol or:[aFontDesc isString]) ifFalse:[
|
615
|
217 |
self fontFamily:(aFontDesc family).
|
|
218 |
self fontFace:(aFontDesc face).
|
|
219 |
self fontStyle:(aFontDesc style).
|
|
220 |
self fontSize:(aFontDesc size).
|
|
221 |
]
|
412
|
222 |
]
|
|
223 |
]
|
|
224 |
!
|
|
225 |
|
|
226 |
fontFace
|
|
227 |
"get face, a string
|
|
228 |
"
|
|
229 |
^ fontFace
|
|
230 |
!
|
|
231 |
|
|
232 |
fontFace:aFace
|
|
233 |
"set face, a string; update item.
|
|
234 |
if the face changed true is returned otherwise nil
|
|
235 |
"
|
|
236 |
(aFace notNil and:[aFace ~= fontFace]) ifTrue:[
|
|
237 |
(self itemAt:#fontFace:) label:(fontFace := aFace).
|
|
238 |
^ true
|
|
239 |
].
|
|
240 |
^ false
|
|
241 |
!
|
|
242 |
|
|
243 |
fontFamily
|
|
244 |
"get family, a string
|
|
245 |
"
|
|
246 |
^ fontFamily
|
|
247 |
!
|
|
248 |
|
|
249 |
fontFamily:aFamily
|
|
250 |
"set family, a string; update item
|
|
251 |
if the family changed true is returned otherwise nil
|
|
252 |
"
|
|
253 |
(aFamily notNil and:[aFamily ~= fontFamily]) ifTrue:[
|
|
254 |
(self itemAt:#fontFamily:) label:(fontFamily := aFamily).
|
|
255 |
^ true
|
|
256 |
].
|
|
257 |
^ false
|
|
258 |
|
|
259 |
!
|
|
260 |
|
|
261 |
fontSize
|
|
262 |
"get size, a number
|
|
263 |
"
|
|
264 |
^ fontSize
|
|
265 |
!
|
|
266 |
|
|
267 |
fontSize:aSize
|
|
268 |
"set size, a number; update item
|
|
269 |
if the size changed true is returned otherwise nil
|
|
270 |
"
|
|
271 |
(aSize notNil and:[aSize ~= fontSize]) ifTrue:[
|
|
272 |
fontSize := aSize.
|
|
273 |
(self itemAt:#fontSize:) label:(aSize printString).
|
|
274 |
^ true
|
|
275 |
].
|
|
276 |
^ false
|
|
277 |
!
|
|
278 |
|
|
279 |
fontStyle
|
|
280 |
"get style, a string
|
|
281 |
"
|
|
282 |
^ fontStyle
|
|
283 |
|
|
284 |
!
|
|
285 |
|
|
286 |
fontStyle:aStyle
|
|
287 |
"set style, a string; update item
|
|
288 |
if the style changed true is returned otherwise nil
|
|
289 |
"
|
|
290 |
(aStyle notNil and:[aStyle ~= fontStyle]) ifTrue:[
|
|
291 |
(self itemAt:#fontStyle:) label:(fontStyle := aStyle).
|
|
292 |
^ true
|
|
293 |
].
|
|
294 |
^ false
|
|
295 |
! !
|
|
296 |
|
|
297 |
!FontMenu methodsFor:'accessing channels'!
|
|
298 |
|
|
299 |
model
|
|
300 |
"get my model
|
|
301 |
"
|
|
302 |
^ model
|
|
303 |
!
|
|
304 |
|
|
305 |
model:aValueHolder
|
|
306 |
"set my model
|
|
307 |
"
|
|
308 |
model notNil ifTrue:[
|
|
309 |
model removeDependent:self.
|
|
310 |
].
|
|
311 |
model := aValueHolder.
|
|
312 |
|
|
313 |
model notNil ifTrue:[
|
|
314 |
model addDependent:self.
|
|
315 |
self fontDescription:(model value)
|
|
316 |
].
|
|
317 |
! !
|
|
318 |
|
|
319 |
!FontMenu methodsFor:'change & update'!
|
|
320 |
|
|
321 |
update:something with:aParameter from:changedObject
|
|
322 |
"one of my models changed its value
|
|
323 |
"
|
|
324 |
changedObject == model ifTrue:[
|
|
325 |
^ self fontDescription:(model value)
|
|
326 |
].
|
|
327 |
super update:something with:aParameter from:changedObject
|
|
328 |
|
|
329 |
! !
|
|
330 |
|
|
331 |
!FontMenu methodsFor:'initialization'!
|
|
332 |
|
|
333 |
destroy
|
|
334 |
"release dependencies
|
|
335 |
"
|
|
336 |
self model:nil.
|
|
337 |
super destroy.
|
|
338 |
|
|
339 |
!
|
|
340 |
|
|
341 |
initialize
|
|
342 |
"setup menu
|
|
343 |
"
|
|
344 |
super initialize.
|
|
345 |
self verticalLayout:false.
|
|
346 |
self fitFirstPanel:false.
|
|
347 |
self menu:(self class menu).
|
|
348 |
enabledChannel := false asValue.
|
|
349 |
|
|
350 |
self fontDescription:(self font).
|
|
351 |
|
|
352 |
self do:[:anItem|
|
|
353 |
anItem hasIndication ifFalse:[
|
|
354 |
anItem enabled:enabledChannel
|
|
355 |
] ifTrue:[
|
|
356 |
anItem indication:enabledChannel
|
|
357 |
]
|
|
358 |
].
|
|
359 |
|
|
360 |
|
|
361 |
! !
|
|
362 |
|
|
363 |
!FontMenu class methodsFor:'documentation'!
|
|
364 |
|
|
365 |
version
|
1427
|
366 |
^ '$Header: /cvs/stx/stx/libwidg2/FontMenu.st,v 1.8 1999-07-02 09:53:18 cg Exp $'
|
412
|
367 |
! !
|