156
|
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 |
|
148
|
15 |
ApplicationModel subclass:#UIHelpTool
|
|
16 |
instanceVariableNames:'dictionary list model'
|
|
17 |
classVariableNames:''
|
|
18 |
poolDictionaries:''
|
|
19 |
category:'Interface-UIPainter'
|
|
20 |
!
|
|
21 |
|
|
22 |
!UIHelpTool class methodsFor:'documentation'!
|
|
23 |
|
156
|
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 |
|
148
|
40 |
documentation
|
|
41 |
"
|
|
42 |
used by the UIPainter to add help text to any component which will be shown
|
|
43 |
during runing an application with enabled activeHelp mode.
|
156
|
44 |
|
|
45 |
[author:]
|
|
46 |
Claus Atzkern
|
148
|
47 |
"
|
|
48 |
! !
|
|
49 |
|
151
|
50 |
!UIHelpTool class methodsFor:'help specs'!
|
|
51 |
|
|
52 |
helpSpec
|
|
53 |
"return a dictionary filled with helpKey -> helptext associations.
|
172
|
54 |
These are used by the activeHelp tool.
|
|
55 |
"
|
|
56 |
^ super helpSpec addPairsFrom:#(
|
151
|
57 |
|
172
|
58 |
#activeHelpAccessKey
|
|
59 |
'This ID is used to access an active
|
|
60 |
help text for the selected component'
|
|
61 |
|
|
62 |
)
|
|
63 |
|
151
|
64 |
! !
|
|
65 |
|
148
|
66 |
!UIHelpTool class methodsFor:'interface specs'!
|
|
67 |
|
|
68 |
windowSpec
|
|
69 |
"this window spec was automatically generated by the ST/X UIPainter"
|
|
70 |
|
|
71 |
"do not manually edit this - the painter/builder may not be able to
|
|
72 |
handle the specification if its corrupted."
|
|
73 |
|
|
74 |
"
|
151
|
75 |
UIPainter new openOnClass:UIHelpTool andSelector:#windowSpec
|
|
76 |
UIHelpTool new openInterface:#windowSpec
|
148
|
77 |
"
|
151
|
78 |
"UIHelpTool open"
|
148
|
79 |
|
|
80 |
<resource: #canvas>
|
|
81 |
|
|
82 |
^
|
|
83 |
|
|
84 |
#(#FullSpec
|
|
85 |
#'window:'
|
|
86 |
#(#WindowSpec
|
|
87 |
#'name:' 'uIPainterView'
|
|
88 |
#'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
|
|
89 |
#'label:' 'unnamed canvas'
|
|
90 |
#'bounds:' #(#Rectangle 0 0 286 272)
|
|
91 |
)
|
|
92 |
#'component:'
|
|
93 |
#(#SpecCollection
|
|
94 |
#'collection:'
|
|
95 |
#(
|
|
96 |
#(#TextEditorSpec
|
|
97 |
#'name:' 'textView'
|
|
98 |
#'layout:' #(#LayoutFrame 46 0 25 0.0 0 1.0 0 1.0)
|
|
99 |
#'model:' #textChannel
|
|
100 |
#'hasHorizontalScrollBar:' true
|
|
101 |
#'hasVerticalScrollBar:' true
|
|
102 |
#'miniScrollerHorizontal:' true
|
|
103 |
#'miniScrollerVertical:' true
|
|
104 |
)
|
|
105 |
#(#LabelSpec
|
|
106 |
#'name:' 'keyLabel'
|
|
107 |
#'layout:' #(#LayoutFrame 0 0.0 1 0.0 41 0 21 0)
|
|
108 |
#'label:' 'Key:'
|
|
109 |
#'adjust:' #left
|
|
110 |
#'resizeForLabel:' false
|
|
111 |
)
|
|
112 |
#(#ComboBoxSpec
|
|
113 |
#'name:' 'comboBox'
|
261
|
114 |
#'layout:' #(#LayoutFrame 48 0 1 0 0 1.0 23 0)
|
151
|
115 |
#'activeHelpKey:' #activeHelpAccessKey
|
148
|
116 |
#'tabable:' true
|
|
117 |
#'comboList:' #listChannel
|
|
118 |
)
|
|
119 |
#(#LabelSpec
|
|
120 |
#'name:' 'textLabel'
|
|
121 |
#'layout:' #(#LayoutFrame 0 0.0 25 0.0 41 0 45 0)
|
|
122 |
#'label:' 'Text:'
|
|
123 |
#'adjust:' #left
|
|
124 |
#'resizeForLabel:' false
|
|
125 |
)
|
|
126 |
)
|
|
127 |
)
|
|
128 |
)
|
261
|
129 |
|
|
130 |
"Modified: 28.7.1997 / 14:15:27 / cg"
|
148
|
131 |
! !
|
|
132 |
|
196
|
133 |
!UIHelpTool class methodsFor:'misc'!
|
|
134 |
|
|
135 |
applicationClassAssociatedWith:aClass
|
|
136 |
"get application class keeping the associated help text or nil
|
|
137 |
"
|
|
138 |
|cls|
|
|
139 |
|
|
140 |
aClass notNil ifTrue:[
|
|
141 |
aClass isBehavior ifFalse:[cls := Smalltalk at:aClass asSymbol]
|
|
142 |
ifTrue:[cls := aClass].
|
|
143 |
|
|
144 |
(cls notNil and:[cls includesBehavior:UISpecification]) ifTrue:[
|
|
145 |
^ UISpecificationTool
|
|
146 |
]
|
|
147 |
].
|
|
148 |
^ cls
|
|
149 |
|
|
150 |
! !
|
|
151 |
|
148
|
152 |
!UIHelpTool methodsFor:'accessing'!
|
|
153 |
|
151
|
154 |
dictionary
|
|
155 |
"return the value of the instance variable 'dictionary' (automatically generated)"
|
|
156 |
|
|
157 |
^ dictionary!
|
|
158 |
|
|
159 |
dictionary:aDictionary
|
|
160 |
"set the value of the instance variable 'dictionary' (automatically generated)"
|
|
161 |
|
|
162 |
(dictionary := aDictionary) notNil ifTrue:[
|
|
163 |
list := dictionary keys asOrderedCollection
|
|
164 |
] ifFalse:[
|
204
|
165 |
dictionary := IdentityDictionary new.
|
151
|
166 |
list := nil
|
|
167 |
].
|
|
168 |
!
|
|
169 |
|
196
|
170 |
helpSpecFrom:aClass
|
|
171 |
"read help text from an application associated with the class
|
|
172 |
"
|
|
173 |
|help cls|
|
|
174 |
|
|
175 |
cls := self class applicationClassAssociatedWith:aClass.
|
|
176 |
|
|
177 |
(cls respondsTo:#helpSpec) ifTrue:[
|
|
178 |
help := cls helpSpec
|
|
179 |
].
|
|
180 |
self dictionary:help
|
|
181 |
!
|
|
182 |
|
148
|
183 |
key
|
|
184 |
"get the key from the edit field as symbol or nil
|
|
185 |
"
|
|
186 |
|key|
|
|
187 |
|
|
188 |
key := model value.
|
|
189 |
|
|
190 |
( key size ~~ 0
|
|
191 |
and:[(key indexOfSeparatorStartingAt:1) == 0
|
|
192 |
or:[(key := key withoutSeparators) notEmpty]]
|
|
193 |
) ifTrue:[
|
|
194 |
^ key asSymbol
|
|
195 |
].
|
|
196 |
^ nil
|
|
197 |
!
|
|
198 |
|
|
199 |
model:aKeyHolder
|
|
200 |
"set the model on the edit field
|
|
201 |
"
|
|
202 |
model notNil ifTrue:[
|
|
203 |
model removeDependent:self
|
|
204 |
].
|
|
205 |
(model := aKeyHolder) notNil ifTrue:[
|
|
206 |
model addDependent:self
|
|
207 |
].
|
|
208 |
(builder componentAt:#comboBox) model:model.
|
151
|
209 |
self update:nil with:#model from:model.
|
148
|
210 |
! !
|
|
211 |
|
|
212 |
!UIHelpTool methodsFor:'actions'!
|
|
213 |
|
|
214 |
accept
|
|
215 |
"accept the text
|
|
216 |
"
|
|
217 |
|key txt|
|
|
218 |
|
|
219 |
key := self key.
|
|
220 |
txt := self textChannel.
|
|
221 |
|
|
222 |
key notNil ifTrue:[
|
|
223 |
txt dependentsDo:[:edt| edt accept].
|
|
224 |
|
|
225 |
(dictionary at:key ifAbsent:nil) isNil ifTrue:[
|
|
226 |
list add:key.
|
|
227 |
self listChannel value:list
|
|
228 |
].
|
|
229 |
dictionary at:key put:(txt value)
|
|
230 |
] ifFalse:[
|
|
231 |
key := nil.
|
|
232 |
txt value:nil.
|
|
233 |
].
|
|
234 |
|
|
235 |
model notNil ifTrue:[
|
|
236 |
model value:key
|
|
237 |
]
|
196
|
238 |
!
|
|
239 |
|
|
240 |
installHelpSpecInto:aClass
|
|
241 |
"install help text
|
|
242 |
"
|
|
243 |
|cls src|
|
|
244 |
|
|
245 |
cls := self class applicationClassAssociatedWith:aClass.
|
|
246 |
|
|
247 |
cls isNil ifTrue:[
|
|
248 |
^ self information:'no application class defined'.
|
|
249 |
].
|
|
250 |
dictionary isEmpty ifTrue:[
|
|
251 |
^ self information:'no help text defined'
|
|
252 |
].
|
|
253 |
src := '' writeStream.
|
|
254 |
|
|
255 |
src nextPutAll:
|
|
256 |
|
|
257 |
'helpSpec
|
|
258 |
"return a dictionary filled with helpKey -> helptext associations.
|
|
259 |
These are used by the activeHelp tool.
|
|
260 |
"
|
|
261 |
^ super helpSpec addPairsFrom:#(
|
|
262 |
|
|
263 |
'.
|
|
264 |
|
|
265 |
dictionary keysAndValuesDo:[:key :txt|
|
|
266 |
|t|
|
|
267 |
src nextPutLine:key storeString.
|
|
268 |
|
|
269 |
t := txt asString.
|
|
270 |
(t endsWith:Character cr) ifTrue:[
|
|
271 |
t := t copyWithoutLast:1
|
|
272 |
].
|
|
273 |
src nextPutLine:t storeString; cr.
|
|
274 |
].
|
|
275 |
src nextPutLine:')'.
|
|
276 |
|
|
277 |
Compiler compile:(src contents)
|
|
278 |
forClass:cls class
|
|
279 |
inCategory:'help specs'
|
|
280 |
|
148
|
281 |
! !
|
|
282 |
|
|
283 |
!UIHelpTool methodsFor:'aspects'!
|
|
284 |
|
|
285 |
listChannel
|
|
286 |
"automatically generated by UIPainter ..."
|
|
287 |
|
|
288 |
|holder|
|
|
289 |
|
|
290 |
(holder := builder bindingAt:#listChannel) isNil ifTrue:[
|
|
291 |
builder aspectAt:#listChannel put:(holder := ValueHolder new).
|
196
|
292 |
holder value:list.
|
148
|
293 |
].
|
|
294 |
^ holder
|
|
295 |
!
|
|
296 |
|
|
297 |
textChannel
|
|
298 |
"automatically generated by UIPainter ..."
|
|
299 |
|
|
300 |
|holder|
|
|
301 |
|
|
302 |
(holder := builder bindingAt:#textChannel) isNil ifTrue:[
|
|
303 |
builder aspectAt:#textChannel put:(holder := ValueHolder new).
|
|
304 |
].
|
|
305 |
^ holder
|
|
306 |
! !
|
|
307 |
|
|
308 |
!UIHelpTool methodsFor:'change & update'!
|
|
309 |
|
|
310 |
update:something with:aParameter from:someObject
|
|
311 |
"model might change
|
|
312 |
"
|
|
313 |
|text key|
|
|
314 |
|
|
315 |
(key := self key) notNil ifTrue:[
|
|
316 |
(text := dictionary at:key ifAbsent:nil) notNil ifTrue:[
|
|
317 |
self textChannel value:text
|
|
318 |
]
|
|
319 |
]
|
|
320 |
! !
|
|
321 |
|
|
322 |
!UIHelpTool methodsFor:'initialization'!
|
|
323 |
|
|
324 |
initialize
|
|
325 |
"setup instance attributes
|
|
326 |
"
|
|
327 |
super initialize.
|
|
328 |
dictionary := IdentityDictionary new.
|
|
329 |
list := OrderedCollection new.
|
|
330 |
! !
|
|
331 |
|
|
332 |
!UIHelpTool class methodsFor:'documentation'!
|
|
333 |
|
|
334 |
version
|
|
335 |
^ '$Header$'
|
|
336 |
! !
|