|
1 " |
|
2 COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger |
|
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 |
|
15 ApplicationModel subclass:#MenuEditor |
|
16 instanceVariableNames:'specClass tabSelection aspects slices' |
|
17 classVariableNames:'' |
|
18 poolDictionaries:'' |
|
19 category:'Interface-UIPainter' |
|
20 ! |
|
21 |
|
22 Object subclass:#Item |
|
23 instanceVariableNames:'activeHelpKey enabled label value nameKey indication shortcutKey |
|
24 accessCharaterPos retriever icon iconAndLabel' |
|
25 classVariableNames:'' |
|
26 poolDictionaries:'' |
|
27 privateIn:MenuEditor |
|
28 ! |
|
29 |
|
30 SelectionInTreeView subclass:#Painter |
|
31 instanceVariableNames:'' |
|
32 classVariableNames:'CopyBuffer' |
|
33 poolDictionaries:'' |
|
34 privateIn:MenuEditor |
|
35 ! |
|
36 |
|
37 !MenuEditor class methodsFor:'documentation'! |
|
38 |
|
39 copyright |
|
40 " |
|
41 COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger |
|
42 All Rights Reserved |
|
43 |
|
44 This software is furnished under a license and may be used |
|
45 only in accordance with the terms of that license and with the |
|
46 inclusion of the above copyright notice. This software may not |
|
47 be provided or otherwise made available to, or used by, any |
|
48 other person. No title to or ownership of the software is |
|
49 hereby transferred. |
|
50 " |
|
51 |
|
52 |
|
53 ! |
|
54 |
|
55 documentation |
|
56 " |
|
57 create and modify or inspect popup and pullDown menus of the |
|
58 new style( derives from Menu). |
|
59 |
|
60 [start with:] |
|
61 MenuEditor open |
|
62 MenuEditor new openOnClass:MenuEditor andSelector:#menuPullDown |
|
63 |
|
64 [see also:] |
|
65 UIPainter |
|
66 UIHelpTool |
|
67 UISpecificationTool |
|
68 SelectionInTreeView |
|
69 |
|
70 [author:] |
|
71 Claus Atzkern |
|
72 " |
|
73 |
|
74 ! ! |
|
75 |
|
76 !MenuEditor class methodsFor:'interface specs'! |
|
77 |
|
78 classAndMethodSpec |
|
79 "this window spec was automatically generated by the ST/X UIPainter" |
|
80 |
|
81 "do not manually edit this - the painter/builder may not be able to |
|
82 handle the specification if its corrupted." |
|
83 |
|
84 " |
|
85 UIPainter new openOnClass:MenuEditor andSelector:#classAndMethodSpec |
|
86 MenuEditor new openInterface:#classAndMethodSpec |
|
87 " |
|
88 |
|
89 <resource: #canvas> |
|
90 |
|
91 ^ |
|
92 |
|
93 #(#FullSpec |
|
94 #'window:' |
|
95 #(#WindowSpec |
|
96 #'name:' 'uIPainterView' |
|
97 #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
98 #'label:' 'Painter' |
|
99 #'bounds:' #(#Rectangle 0 0 391 170) |
|
100 ) |
|
101 #'component:' |
|
102 #(#SpecCollection |
|
103 #'collection:' |
|
104 #( |
|
105 #(#LabelSpec |
|
106 #'name:' 'classLabel' |
|
107 #'layout:' #(#AlignmentOrigin 45 0.11 51 0 1 0.5) |
|
108 #'label:' 'class:' |
|
109 #'adjust:' #right |
|
110 #'resizeForLabel:' true |
|
111 ) |
|
112 #(#LabelSpec |
|
113 #'name:' 'selectorLabel' |
|
114 #'layout:' #(#AlignmentOrigin 45 0.11 74 0 1 0.5) |
|
115 #'label:' 'selector:' |
|
116 #'adjust:' #right |
|
117 #'resizeForLabel:' true |
|
118 ) |
|
119 #(#InputFieldSpec |
|
120 #'name:' 'methodNameField' |
|
121 #'layout:' #(#LayoutFrame 47 0.11 64 0 -5 1.0 86 0) |
|
122 #'tabable:' true |
|
123 #'model:' #methodNameChannel |
|
124 ) |
|
125 #(#LabelSpec |
|
126 #'name:' 'boxLabel' |
|
127 #'layout:' #(#Point 5 10) |
|
128 #'label:' 'class & selector for code:' |
|
129 #'adjust:' #left |
|
130 #'resizeForLabel:' true |
|
131 ) |
|
132 #(#InputFieldSpec |
|
133 #'name:' 'classNameField' |
|
134 #'layout:' #(#LayoutFrame 47 0.11 39 0 -5 1.0 61 0) |
|
135 #'tabable:' true |
|
136 #'model:' #classNameChannel |
|
137 ) |
|
138 #(#HorizontalPanelViewSpec |
|
139 #'name:' 'commitPanel' |
|
140 #'layout:' #(#LayoutFrame 0 0.0 -24 1.0 0 1.0 0 1.0) |
|
141 #'component:' |
|
142 #(#SpecCollection |
|
143 #'collection:' |
|
144 #( |
|
145 #(#ActionButtonSpec |
|
146 #'name:' 'button1' |
|
147 #'label:' 'cancel' |
|
148 #'tabable:' true |
|
149 #'model:' #cancel |
|
150 #'extent:' #(#Point 191 24) |
|
151 ) |
|
152 #(#ActionButtonSpec |
|
153 #'name:' 'button2' |
|
154 #'label:' 'ok' |
|
155 #'tabable:' true |
|
156 #'isDefault:' true |
|
157 #'model:' #accept |
|
158 #'extent:' #(#Point 191 24) |
|
159 ) |
|
160 ) |
|
161 ) |
|
162 #'horizontalLayout:' #fitSpace |
|
163 #'verticalLayout:' #fit |
|
164 #'horizontalSpace:' 3 |
|
165 #'verticalSpace:' 3 |
|
166 ) |
|
167 ) |
|
168 ) |
|
169 ) |
|
170 ! |
|
171 |
|
172 classDefineSpec |
|
173 "this window spec was automatically generated by the ST/X UIPainter" |
|
174 |
|
175 "do not manually edit this - the painter/builder may not be able to |
|
176 handle the specification if its corrupted." |
|
177 |
|
178 " |
|
179 UIPainter new openOnClass:MenuEditor andSelector:#classDefineSpec |
|
180 MenuEditor new openInterface:#classDefineSpec |
|
181 " |
|
182 |
|
183 <resource: #canvas> |
|
184 |
|
185 ^ |
|
186 |
|
187 #(#FullSpec |
|
188 #'window:' |
|
189 #(#WindowSpec |
|
190 #'name:' 'uIPainterView' |
|
191 #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
192 #'label:' 'Painter' |
|
193 #'bounds:' #(#Rectangle 0 0 383 128) |
|
194 ) |
|
195 #'component:' |
|
196 #(#SpecCollection |
|
197 #'collection:' |
|
198 #( |
|
199 #(#LabelSpec |
|
200 #'name:' 'classLabel' |
|
201 #'layout:' #(#AlignmentOrigin 45 0.11 51 0 1 0.5) |
|
202 #'label:' 'class:' |
|
203 #'adjust:' #right |
|
204 #'resizeForLabel:' true |
|
205 ) |
|
206 #(#LabelSpec |
|
207 #'name:' 'boxLabel' |
|
208 #'layout:' #(#Point 5 10) |
|
209 #'label:' 'class for code:' |
|
210 #'adjust:' #left |
|
211 #'resizeForLabel:' true |
|
212 ) |
|
213 #(#InputFieldSpec |
|
214 #'name:' 'classNameField' |
|
215 #'layout:' #(#LayoutFrame 47 0.11 39 0 -5 1.0 61 0) |
|
216 #'tabable:' true |
|
217 #'model:' #classNameChannel |
|
218 ) |
|
219 #(#HorizontalPanelViewSpec |
|
220 #'name:' 'commitPanel' |
|
221 #'layout:' #(#LayoutFrame 0 0.0 -24 1.0 0 1.0 0 1.0) |
|
222 #'component:' |
|
223 #(#SpecCollection |
|
224 #'collection:' |
|
225 #( |
|
226 #(#ActionButtonSpec |
|
227 #'name:' 'button1' |
|
228 #'label:' 'cancel' |
|
229 #'tabable:' true |
|
230 #'model:' #cancel |
|
231 #'extent:' #(#Point 187 24) |
|
232 ) |
|
233 #(#ActionButtonSpec |
|
234 #'name:' 'button2' |
|
235 #'label:' 'ok' |
|
236 #'tabable:' true |
|
237 #'isDefault:' true |
|
238 #'model:' #accept |
|
239 #'extent:' #(#Point 187 24) |
|
240 ) |
|
241 ) |
|
242 ) |
|
243 #'horizontalLayout:' #fitSpace |
|
244 #'verticalLayout:' #fit |
|
245 #'horizontalSpace:' 3 |
|
246 #'verticalSpace:' 3 |
|
247 ) |
|
248 ) |
|
249 ) |
|
250 ) |
|
251 ! |
|
252 |
|
253 menuPullDown |
|
254 "this window spec was automatically generated by the ST/X MenuEditor" |
|
255 |
|
256 "do not manually edit this - the builder may not be able to |
|
257 handle the specification if its corrupted." |
|
258 |
|
259 " |
|
260 MenuEditor new openOnClass:MenuEditor andSelector:#menuPullDown |
|
261 (Menu new fromLiteralArrayEncoding:(MenuEditor menuPullDown)) startUp |
|
262 " |
|
263 |
|
264 <resource: #menu> |
|
265 |
|
266 ^ |
|
267 |
|
268 #(#Menu |
|
269 |
|
270 #( |
|
271 #(#MenuItem |
|
272 #'label:' 'file' |
|
273 #'value:' #file |
|
274 #'submenu:' |
|
275 #(#Menu |
|
276 |
|
277 #( |
|
278 #(#MenuItem |
|
279 #'label:' 'new' |
|
280 #'value:' #doNew |
|
281 ) |
|
282 #(#MenuItem |
|
283 #'label:' 'from class ...' |
|
284 #'value:' #doFromClass |
|
285 ) |
|
286 #(#MenuItem |
|
287 #'label:' 'pick a menu' |
|
288 #'value:' #doPickAMenu |
|
289 ) |
|
290 #(#MenuItem |
|
291 #'label:' '=' |
|
292 ) |
|
293 #(#MenuItem |
|
294 #'label:' 'quit' |
|
295 #'value:' #closeRequest |
|
296 ) |
|
297 ) nil |
|
298 nil |
|
299 ) |
|
300 ) |
|
301 #(#MenuItem |
|
302 #'label:' 'code' |
|
303 #'value:' #code |
|
304 #'submenu:' |
|
305 #(#Menu |
|
306 |
|
307 #( |
|
308 #(#MenuItem |
|
309 #'label:' 'class' |
|
310 #'value:' #doDefineClass |
|
311 ) |
|
312 #(#MenuItem |
|
313 #'label:' '-' |
|
314 ) |
|
315 #(#MenuItem |
|
316 #'label:' 'install window spec.' |
|
317 #'value:' #doInstallSpec |
|
318 ) |
|
319 #(#MenuItem |
|
320 #'label:' 'install help spec.' |
|
321 #'value:' #doInstallHelp |
|
322 ) |
|
323 #(#MenuItem |
|
324 #'label:' '=' |
|
325 ) |
|
326 #(#MenuItem |
|
327 #'label:' 'browse application' |
|
328 #'value:' #doBrowseAppClass |
|
329 ) |
|
330 ) nil |
|
331 nil |
|
332 ) |
|
333 ) |
|
334 #(#MenuItem |
|
335 #'label:' 'test' |
|
336 #'value:' #doTest |
|
337 ) |
|
338 ) nil |
|
339 nil |
|
340 ) |
|
341 ! |
|
342 |
|
343 windowSpec |
|
344 "this window spec was automatically generated by the ST/X UIPainter" |
|
345 |
|
346 "do not manually edit this - the painter/builder may not be able to |
|
347 handle the specification if its corrupted." |
|
348 |
|
349 " |
|
350 UIPainter new openOnClass:MenuEditor andSelector:#windowSpec |
|
351 MenuEditor new openInterface:#windowSpec |
|
352 " |
|
353 "MenuEditor open" |
|
354 |
|
355 <resource: #canvas> |
|
356 |
|
357 ^ |
|
358 |
|
359 #(#FullSpec |
|
360 #'window:' |
|
361 #(#WindowSpec |
|
362 #'name:' 'uIPainterView' |
|
363 #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
364 #'label:' 'Menu Builder' |
|
365 #'bounds:' #(#Rectangle 0 0 580 384) |
|
366 ) |
|
367 #'component:' |
|
368 #(#SpecCollection |
|
369 #'collection:' |
|
370 #( |
|
371 #(#ArbitraryComponentSpec |
|
372 #'name:' 'painterView' |
|
373 #'layout:' #(#LayoutFrame 0 0.0 25 0.0 0 0.5 0 1.0) |
|
374 #'component:' #painter |
|
375 #'hasHorizontalScrollBar:' true |
|
376 #'hasVerticalScrollBar:' true |
|
377 #'hasBorder:' false |
|
378 #'miniScrollerHorizontal:' false |
|
379 #'miniScrollerVertical:' false |
|
380 ) |
|
381 #(#NoteBookViewSpec |
|
382 #'name:' 'specificationView' |
|
383 #'layout:' #(#LayoutFrame 0 0.5 25 0.0 0 1.0 -25 1.0) |
|
384 #'menu:' #tabList |
|
385 #'model:' #tabModel |
|
386 #'tabWidget:' #Window |
|
387 #'useIndex:' true |
|
388 #'canvas:' #tabCanvas |
|
389 ) |
|
390 #(#HorizontalPanelViewSpec |
|
391 #'name:' 'confirmationPanel' |
|
392 #'layout:' #(#LayoutFrame 0 0.5 -24 1.0 0 1.0 0 1.0) |
|
393 #'component:' |
|
394 #(#SpecCollection |
|
395 #'collection:' |
|
396 #( |
|
397 #(#ActionButtonSpec |
|
398 #'name:' 'cancelButton' |
|
399 #'label:' 'cancel' |
|
400 #'model:' #cancel |
|
401 #'enableChannel:' #modifiedChannel |
|
402 #'extent:' #(#Point 140 24) |
|
403 ) |
|
404 #(#ActionButtonSpec |
|
405 #'name:' 'acceptButton' |
|
406 #'label:' 'ok' |
|
407 #'model:' #accept |
|
408 #'enableChannel:' #modifiedChannel |
|
409 #'extent:' #(#Point 141 24) |
|
410 ) |
|
411 ) |
|
412 ) |
|
413 #'horizontalLayout:' #fitSpace |
|
414 #'verticalLayout:' #fit |
|
415 #'horizontalSpace:' 3 |
|
416 #'verticalSpace:' 3 |
|
417 ) |
|
418 #(#MenuPanelSpec |
|
419 #'name:' 'pullDownMenu' |
|
420 #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 24 0) |
|
421 #'menu:' #menuPullDown |
|
422 ) |
|
423 ) |
|
424 ) |
|
425 ) |
|
426 ! ! |
|
427 |
|
428 !MenuEditor class methodsFor:'slices'! |
|
429 |
|
430 slicesItem |
|
431 ^#( |
|
432 (Basics basicsItemSpec) |
|
433 (Details detailsEditSpec) |
|
434 (Misc miscEditSpec) |
|
435 (Help help) |
|
436 ) |
|
437 |
|
438 ! |
|
439 |
|
440 slicesMenu |
|
441 ^#( |
|
442 (Basics basicsMenuSpec) |
|
443 (Details detailsEditSpec) |
|
444 (Misc miscEditSpec) |
|
445 (Help help) |
|
446 ) |
|
447 |
|
448 ! |
|
449 |
|
450 slicesRootMenu |
|
451 ^#( |
|
452 (Basics basicsRootSpec) |
|
453 ) |
|
454 |
|
455 ! |
|
456 |
|
457 slicesSeperatorMenu |
|
458 ^#( |
|
459 (Basics basicsSeperatorMenu) |
|
460 ) |
|
461 |
|
462 ! ! |
|
463 |
|
464 !MenuEditor class methodsFor:'specs'! |
|
465 |
|
466 basicsItemSpec |
|
467 "this window spec was automatically generated by the ST/X UIPainter" |
|
468 |
|
469 "do not manually edit this - the painter/builder may not be able to |
|
470 handle the specification if its corrupted." |
|
471 |
|
472 " |
|
473 UIPainter new openOnClass:MenuEditor andSelector:#basicsItemSpec |
|
474 MenuEditor new openInterface:#basicsItemSpec |
|
475 " |
|
476 |
|
477 <resource: #canvas> |
|
478 |
|
479 ^ |
|
480 |
|
481 #(#FullSpec |
|
482 #'window:' |
|
483 #(#WindowSpec |
|
484 #'name:' 'uIPainterView' |
|
485 #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
486 #'label:' 'unnamed canvas' |
|
487 #'bounds:' #(#Rectangle 0 0 267 319) |
|
488 ) |
|
489 #'component:' |
|
490 #(#SpecCollection |
|
491 #'collection:' |
|
492 #( |
|
493 #(#LabelSpec |
|
494 #'name:' 'nameKeyLabel' |
|
495 #'layout:' #(#AlignmentOrigin 87 0 26 0 1 0.5) |
|
496 #'label:' 'NameKey:' |
|
497 #'resizeForLabel:' true |
|
498 ) |
|
499 #(#InputFieldSpec |
|
500 #'name:' 'itemNameKey' |
|
501 #'layout:' #(#LayoutFrame 91 0 15 0 -5 1.0 37 0) |
|
502 #'tabable:' true |
|
503 #'model:' #nameKey |
|
504 #'type:' #symbolOrNil |
|
505 ) |
|
506 #(#LabelSpec |
|
507 #'name:' 'labelLabel' |
|
508 #'layout:' #(#AlignmentOrigin 87 0 53 0 1 0.5) |
|
509 #'label:' 'Label' |
|
510 #'resizeForLabel:' true |
|
511 ) |
|
512 #(#InputFieldSpec |
|
513 #'name:' 'itemLabel' |
|
514 #'layout:' #(#LayoutFrame 91 0 42 0 -5 1.0 64 0) |
|
515 #'tabable:' true |
|
516 #'model:' #label |
|
517 ) |
|
518 #(#LabelSpec |
|
519 #'name:' 'valueLabel' |
|
520 #'layout:' #(#AlignmentOrigin 87 0 79 0 1 0.5) |
|
521 #'label:' 'Value:' |
|
522 #'resizeForLabel:' true |
|
523 ) |
|
524 #(#InputFieldSpec |
|
525 #'name:' 'itemValue' |
|
526 #'layout:' #(#LayoutFrame 91 0 68 0 -5 1.0 90 0) |
|
527 #'tabable:' true |
|
528 #'model:' #value |
|
529 #'type:' #symbolOrNil |
|
530 ) |
|
531 #(#LabelSpec |
|
532 #'name:' 'indicationLabel' |
|
533 #'layout:' #(#AlignmentOrigin 87 0 139 0 1 0.5) |
|
534 #'label:' 'Indication:' |
|
535 #'resizeForLabel:' true |
|
536 ) |
|
537 #(#InputFieldSpec |
|
538 #'name:' 'indicationValue' |
|
539 #'layout:' #(#LayoutFrame 91 0 128 0 -5 1.0 150 0) |
|
540 #'tabable:' true |
|
541 #'model:' #indication |
|
542 #'type:' #symbolOrNil |
|
543 ) |
|
544 ) |
|
545 ) |
|
546 ) |
|
547 ! |
|
548 |
|
549 basicsMenuSpec |
|
550 "this window spec was automatically generated by the ST/X UIPainter" |
|
551 |
|
552 "do not manually edit this - the painter/builder may not be able to |
|
553 handle the specification if its corrupted." |
|
554 |
|
555 " |
|
556 UIPainter new openOnClass:MenuEditor andSelector:#basicsMenuSpec |
|
557 MenuEditor new openInterface:#basicsMenuSpec |
|
558 " |
|
559 |
|
560 <resource: #canvas> |
|
561 |
|
562 ^ |
|
563 |
|
564 #(#FullSpec |
|
565 #'window:' |
|
566 #(#WindowSpec |
|
567 #'name:' 'uIPainterView' |
|
568 #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
569 #'label:' 'unnamed canvas' |
|
570 #'bounds:' #(#Rectangle 0 0 267 319) |
|
571 ) |
|
572 #'component:' |
|
573 #(#SpecCollection |
|
574 #'collection:' |
|
575 #( |
|
576 #(#LabelSpec |
|
577 #'name:' 'nameKeyLabel' |
|
578 #'layout:' #(#AlignmentOrigin 87 0 26 0 1 0.5) |
|
579 #'label:' 'NameKey:' |
|
580 #'resizeForLabel:' true |
|
581 ) |
|
582 #(#InputFieldSpec |
|
583 #'name:' 'itemNameKey' |
|
584 #'layout:' #(#LayoutFrame 91 0 15 0 -5 1.0 37 0) |
|
585 #'tabable:' true |
|
586 #'model:' #nameKey |
|
587 #'type:' #symbolOrNil |
|
588 ) |
|
589 #(#LabelSpec |
|
590 #'name:' 'labelLabel' |
|
591 #'layout:' #(#AlignmentOrigin 87 0 53 0 1 0.5) |
|
592 #'label:' 'Label' |
|
593 #'resizeForLabel:' true |
|
594 ) |
|
595 #(#InputFieldSpec |
|
596 #'name:' 'itemLabel' |
|
597 #'layout:' #(#LayoutFrame 91 0 42 0 -5 1.0 64 0) |
|
598 #'tabable:' true |
|
599 #'model:' #label |
|
600 ) |
|
601 ) |
|
602 ) |
|
603 ) |
|
604 ! |
|
605 |
|
606 basicsRootSpec |
|
607 "this window spec was automatically generated by the ST/X UIPainter" |
|
608 |
|
609 "do not manually edit this - the painter/builder may not be able to |
|
610 handle the specification if its corrupted." |
|
611 |
|
612 " |
|
613 UIPainter new openOnClass:MenuEditor andSelector:#basicsRootSpec |
|
614 MenuEditor new openInterface:#basicsRootSpec |
|
615 " |
|
616 |
|
617 <resource: #canvas> |
|
618 |
|
619 ^ |
|
620 |
|
621 #(#FullSpec |
|
622 #'window:' |
|
623 #(#WindowSpec |
|
624 #'name:' 'uIPainterView' |
|
625 #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
626 #'label:' 'unnamed canvas' |
|
627 #'bounds:' #(#Rectangle 0 0 267 319) |
|
628 ) |
|
629 #'component:' |
|
630 #(#SpecCollection |
|
631 #'collection:' |
|
632 #( |
|
633 #(#LabelSpec |
|
634 #'name:' 'selectorLabel' |
|
635 #'layout:' #(#AlignmentOrigin 78 0 53 0 1 0.5) |
|
636 #'label:' 'Selector:' |
|
637 #'resizeForLabel:' true |
|
638 ) |
|
639 #(#InputFieldSpec |
|
640 #'name:' 'selector' |
|
641 #'layout:' #(#LayoutFrame 82 0 42 0 -14 1.0 64 0) |
|
642 #'tabable:' true |
|
643 #'model:' #label |
|
644 ) |
|
645 ) |
|
646 ) |
|
647 ) |
|
648 ! |
|
649 |
|
650 basicsSeperatorMenu |
|
651 "this window spec was automatically generated by the ST/X UIPainter" |
|
652 |
|
653 "do not manually edit this - the painter/builder may not be able to |
|
654 handle the specification if its corrupted." |
|
655 |
|
656 " |
|
657 UIPainter new openOnClass:MenuEditor andSelector:#basicsSeperatorMenu |
|
658 MenuEditor new openInterface:#basicsSeperatorMenu |
|
659 " |
|
660 |
|
661 <resource: #canvas> |
|
662 |
|
663 ^ |
|
664 |
|
665 #(#FullSpec |
|
666 #'window:' |
|
667 #(#WindowSpec |
|
668 #'name:' 'uIPainterView' |
|
669 #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
670 #'label:' 'unnamed canvas' |
|
671 #'bounds:' #(#Rectangle 0 0 267 319) |
|
672 ) |
|
673 #'component:' |
|
674 #(#SpecCollection |
|
675 #'collection:' |
|
676 #( |
|
677 #(#CheckBoxSpec |
|
678 #'name:' 'seperator' |
|
679 #'layout:' #(#AlignmentOrigin 19 0 48 0 0 0) |
|
680 #'tabable:' true |
|
681 #'model:' #doubleSeperator |
|
682 #'label:' 'Double Seperator' |
|
683 ) |
|
684 ) |
|
685 ) |
|
686 ) |
|
687 ! |
|
688 |
|
689 detailsEditSpec |
|
690 "this window spec was automatically generated by the ST/X UIPainter" |
|
691 |
|
692 "do not manually edit this - the painter/builder may not be able to |
|
693 handle the specification if its corrupted." |
|
694 |
|
695 " |
|
696 UIPainter new openOnClass:MenuEditor andSelector:#detailsEditSpec |
|
697 MenuEditor new openInterface:#detailsEditSpec |
|
698 " |
|
699 |
|
700 <resource: #canvas> |
|
701 |
|
702 ^ |
|
703 |
|
704 #(#FullSpec |
|
705 #'window:' |
|
706 #(#WindowSpec |
|
707 #'name:' 'uIPainterView' |
|
708 #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
709 #'label:' 'unnamed canvas' |
|
710 #'bounds:' #(#Rectangle 0 0 259 288) |
|
711 ) |
|
712 #'component:' |
|
713 #(#SpecCollection |
|
714 #'collection:' |
|
715 #( |
|
716 #(#LabelSpec |
|
717 #'name:' 'enabledLabel' |
|
718 #'layout:' #(#AlignmentOrigin 87 0 59 0 1 0.5) |
|
719 #'label:' 'Enabled:' |
|
720 #'resizeForLabel:' true |
|
721 ) |
|
722 #(#InputFieldSpec |
|
723 #'name:' 'enabled' |
|
724 #'layout:' #(#LayoutFrame 91 0 48 0 -5 1.0 70 0) |
|
725 #'tabable:' true |
|
726 #'model:' #enabled |
|
727 #'type:' #symbolOrNil |
|
728 ) |
|
729 #(#LabelSpec |
|
730 #'name:' 'shortcutKeyLabel' |
|
731 #'layout:' #(#AlignmentOrigin 87 0 33 0 1 0.5) |
|
732 #'label:' 'Accelerator:' |
|
733 #'resizeForLabel:' true |
|
734 ) |
|
735 #(#InputFieldSpec |
|
736 #'name:' 'accelerator' |
|
737 #'layout:' #(#LayoutFrame 91 0 22 0 -5 1.0 44 0) |
|
738 #'tabable:' true |
|
739 #'model:' #shortcutKey |
|
740 #'type:' #symbolOrNil |
|
741 ) |
|
742 #(#LabelSpec |
|
743 #'name:' 'accessCharPosLabel' |
|
744 #'layout:' #(#AlignmentOrigin 181 0 127 0 1 0.5) |
|
745 #'label:' 'Access Character Position:' |
|
746 #'resizeForLabel:' true |
|
747 ) |
|
748 #(#InputFieldSpec |
|
749 #'name:' 'accessCharaterPos' |
|
750 #'layout:' #(#LayoutFrame 184 0 116 0 -5 1.0 138 0) |
|
751 #'tabable:' true |
|
752 #'model:' #accessCharaterPos |
|
753 #'type:' #numberOrNil |
|
754 ) |
|
755 ) |
|
756 ) |
|
757 ) |
|
758 ! |
|
759 |
|
760 miscEditSpec |
|
761 "this window spec was automatically generated by the ST/X UIPainter" |
|
762 |
|
763 "do not manually edit this - the painter/builder may not be able to |
|
764 handle the specification if its corrupted." |
|
765 |
|
766 " |
|
767 UIPainter new openOnClass:MenuEditor andSelector:#miscEditSpec |
|
768 MenuEditor new openInterface:#miscEditSpec |
|
769 " |
|
770 |
|
771 <resource: #canvas> |
|
772 |
|
773 ^ |
|
774 |
|
775 #(#FullSpec |
|
776 #'window:' |
|
777 #(#WindowSpec |
|
778 #'name:' 'uIPainterView' |
|
779 #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
780 #'label:' 'unnamed canvas' |
|
781 #'bounds:' #(#Rectangle 0 0 245 142) |
|
782 ) |
|
783 #'component:' |
|
784 #(#SpecCollection |
|
785 #'collection:' |
|
786 #( |
|
787 #(#LabelSpec |
|
788 #'name:' 'retrieverLabel' |
|
789 #'layout:' #(#AlignmentOrigin 77 0 26 0 1 0.5) |
|
790 #'label:' 'Retriever:' |
|
791 #'resizeForLabel:' true |
|
792 ) |
|
793 #(#InputFieldSpec |
|
794 #'name:' 'retriever' |
|
795 #'layout:' #(#LayoutFrame 81 0 15 0 -8 1.0 37 0) |
|
796 #'tabable:' true |
|
797 #'model:' #retriever |
|
798 #'type:' #symbolOrNil |
|
799 ) |
|
800 #(#LabelSpec |
|
801 #'name:' 'iconLabel' |
|
802 #'layout:' #(#AlignmentOrigin 77 0 50 0 1 0.5) |
|
803 #'label:' 'Icon:' |
|
804 #'resizeForLabel:' true |
|
805 ) |
|
806 #(#InputFieldSpec |
|
807 #'name:' 'icon' |
|
808 #'layout:' #(#LayoutFrame 81 0 39 0 -8 1.0 61 0) |
|
809 #'tabable:' true |
|
810 #'model:' #icon |
|
811 #'type:' #symbolOrNil |
|
812 ) |
|
813 #(#CheckBoxSpec |
|
814 #'name:' 'iconAndLabel' |
|
815 #'layout:' #(#AlignmentOrigin 15 0 100 0 0 0.5) |
|
816 #'tabable:' true |
|
817 #'model:' #iconAndLabel |
|
818 #'label:' 'Icon & Label' |
|
819 ) |
|
820 ) |
|
821 ) |
|
822 ) |
|
823 ! |
|
824 |
|
825 seperatorSpec |
|
826 "this window spec was automatically generated by the ST/X UIPainter" |
|
827 |
|
828 "do not manually edit this - the painter/builder may not be able to |
|
829 handle the specification if its corrupted." |
|
830 |
|
831 " |
|
832 UIPainter new openOnClass:MenuEditor andSelector:#seperatorSpec |
|
833 MenuEditor new openInterface:#seperatorSpec |
|
834 " |
|
835 |
|
836 <resource: #canvas> |
|
837 |
|
838 ^ |
|
839 |
|
840 #(#FullSpec |
|
841 #'window:' |
|
842 #(#WindowSpec |
|
843 #'name:' 'uIPainterView' |
|
844 #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
845 #'label:' 'unnamed canvas' |
|
846 #'bounds:' #(#Rectangle 0 0 267 319) |
|
847 ) |
|
848 #'component:' |
|
849 #(#SpecCollection |
|
850 #'collection:' |
|
851 #( |
|
852 #(#CheckBoxSpec |
|
853 #'name:' 'seperator' |
|
854 #'layout:' #(#AlignmentOrigin 19 0 48 0 0 0) |
|
855 #'tabable:' true |
|
856 #'model:' #doubleSeperator |
|
857 #'label:' 'Double Seperator' |
|
858 ) |
|
859 ) |
|
860 ) |
|
861 ) |
|
862 ! ! |
|
863 |
|
864 !MenuEditor methodsFor:'accessing'! |
|
865 |
|
866 specClass |
|
867 ^ specClass |
|
868 ! |
|
869 |
|
870 specClass:aClass |
|
871 aClass isBehavior ifTrue:[specClass := aClass name] |
|
872 ifFalse:[specClass := aClass]. |
|
873 ! ! |
|
874 |
|
875 !MenuEditor methodsFor:'actions'! |
|
876 |
|
877 accept |
|
878 "automatically generated by UIPainter ..." |
|
879 |
|
880 |node cont| |
|
881 |
|
882 node := self painter selectedNode. |
|
883 |
|
884 node notNil ifTrue:[ |
|
885 self isHelpToolSelected ifTrue:[ |
|
886 self helpTool accept |
|
887 ]. |
|
888 cont := node contents buildFromAspects:aspects. |
|
889 self painter selectedNodeChanged |
|
890 ]. |
|
891 self modifiedChannel value:false. |
|
892 ! |
|
893 |
|
894 cancel |
|
895 |node| |
|
896 |
|
897 (node := self painter selectedNode) notNil ifTrue:[ |
|
898 aspects do:[:anAspect| anAspect value:nil ]. |
|
899 node contents toAspects:aspects. |
|
900 ]. |
|
901 self modifiedChannel value:false. |
|
902 |
|
903 ! ! |
|
904 |
|
905 !MenuEditor methodsFor:'aspects'! |
|
906 |
|
907 aspectFor:aKey |
|
908 "returns aspect for a key or nil |
|
909 " |
|
910 ^ aspects at:aKey ifAbsent:[ super aspectFor:aKey ] |
|
911 |
|
912 |
|
913 ! |
|
914 |
|
915 menuPullDown |
|
916 |menu| |
|
917 |
|
918 menu := Menu new. |
|
919 menu fromLiteralArrayEncoding:(self class menuPullDown). |
|
920 menu receiver:self. |
|
921 ^ menu |
|
922 |
|
923 |
|
924 ! |
|
925 |
|
926 modifiedChannel |
|
927 "automatically generated by UIPainter ..." |
|
928 |
|
929 |holder| |
|
930 |
|
931 (holder := builder bindingAt:#modifiedChannel) isNil ifTrue:[ |
|
932 builder aspectAt:#modifiedChannel put:(holder := false asValue). |
|
933 ]. |
|
934 ^ holder |
|
935 ! |
|
936 |
|
937 tabCanvas |
|
938 "automatically generated by UIPainter ..." |
|
939 |
|
940 |holder| |
|
941 |
|
942 (holder := builder bindingAt:#tabCanvas) isNil ifTrue:[ |
|
943 builder aspectAt:#tabCanvas put:(holder := SubCanvas new). |
|
944 ]. |
|
945 ^ holder |
|
946 ! |
|
947 |
|
948 tabList |
|
949 "automatically generated by UIPainter ..." |
|
950 |
|
951 |holder| |
|
952 |
|
953 (holder := builder bindingAt:#tabList) isNil ifTrue:[ |
|
954 builder aspectAt:#tabList put:(holder := ValueHolder new) |
|
955 ]. |
|
956 ^ holder |
|
957 ! |
|
958 |
|
959 tabModel |
|
960 "automatically generated by UIPainter ..." |
|
961 |
|
962 |holder| |
|
963 |
|
964 (holder := builder bindingAt:#tabModel) isNil ifTrue:[ |
|
965 holder := AspectAdaptor new subject:self; forAspect:#tabSelection. |
|
966 builder aspectAt:#tabModel put:holder. |
|
967 ]. |
|
968 ^ holder |
|
969 |
|
970 ! ! |
|
971 |
|
972 !MenuEditor methodsFor:'change & update'! |
|
973 |
|
974 update:something with:aParameter from:changedObject |
|
975 "one of my models changed its value |
|
976 " |
|
977 self modifiedChannel value:true |
|
978 ! ! |
|
979 |
|
980 !MenuEditor methodsFor:'queries'! |
|
981 |
|
982 isHelpToolSelected |
|
983 "returns true if current selection is help tool |
|
984 " |
|
985 (slices notNil and:[tabSelection notNil]) ifTrue:[ |
|
986 ^ (slices at:tabSelection) last == #help |
|
987 ]. |
|
988 ^ false |
|
989 ! ! |
|
990 |
|
991 !MenuEditor methodsFor:'selection'! |
|
992 |
|
993 menuChanged |
|
994 |node item slc sel| |
|
995 |
|
996 (node := self painter selectedNode) notNil ifTrue:[ |
|
997 aspects do:[:anAspect| anAspect value:nil ]. |
|
998 item := node contents. |
|
999 item toAspects:aspects. |
|
1000 |
|
1001 item isSeperator ifFalse:[ |
|
1002 node parent isNil ifFalse:[ |
|
1003 node hasChildren ifTrue:[slc := #slicesMenu] |
|
1004 ifFalse:[slc := #slicesItem]. |
|
1005 ] ifTrue:[ |
|
1006 slc := #slicesRootMenu |
|
1007 ] |
|
1008 ] ifTrue:[ |
|
1009 slc := #slicesSeperatorMenu |
|
1010 ]. |
|
1011 slc := self class perform:slc. |
|
1012 ]. |
|
1013 self modifiedChannel value:false. |
|
1014 |
|
1015 slc ~= slices ifTrue:[ |
|
1016 (slices := slc) notNil ifTrue:[ |
|
1017 tabSelection notNil ifTrue:[sel := tabSelection min:(slices size)] |
|
1018 ifFalse:[sel := 1]. |
|
1019 |
|
1020 self tabList value:(slices collect:[:s| s first]). |
|
1021 self tabModel setValue:nil. |
|
1022 self tabModel value:sel. |
|
1023 ] ifFalse:[ |
|
1024 self tabList value:nil. |
|
1025 self tabSelection:nil. |
|
1026 ] |
|
1027 ]. |
|
1028 ! |
|
1029 |
|
1030 tabSelection |
|
1031 ^ tabSelection |
|
1032 ! |
|
1033 |
|
1034 tabSelection:aSelection |
|
1035 |tool sel| |
|
1036 |
|
1037 tabSelection == aSelection ifTrue:[ |
|
1038 ^ self |
|
1039 ]. |
|
1040 |
|
1041 (tabSelection := aSelection) isNil ifTrue:[ |
|
1042 ^ self tabCanvas client:nil |
|
1043 ]. |
|
1044 self isHelpToolSelected ifTrue:[ |
|
1045 self tabCanvas client:(tool := self helpTool). |
|
1046 tool model:(self aspectFor:#activeHelpKey) |
|
1047 ] ifFalse:[ |
|
1048 sel := (slices at:tabSelection) last. |
|
1049 self tabCanvas client:self spec:(self class perform:sel) builder:builder |
|
1050 ] |
|
1051 ! ! |
|
1052 |
|
1053 !MenuEditor methodsFor:'startup / release'! |
|
1054 |
|
1055 buildFrom:aClass andSelector:aSelector |
|
1056 |oldClass newClass| |
|
1057 |
|
1058 oldClass := self specClass. |
|
1059 self specClass:aClass. |
|
1060 newClass := self specClass. |
|
1061 |
|
1062 oldClass ~= newClass ifTrue:[ |
|
1063 self helpTool helpSpecFrom:newClass |
|
1064 ]. |
|
1065 self painter buildFrom:newClass andSelector:aSelector. |
|
1066 ! |
|
1067 |
|
1068 initialize |
|
1069 "initialize channels |
|
1070 " |
|
1071 super initialize. |
|
1072 aspects := IdentityDictionary new. |
|
1073 |
|
1074 #( |
|
1075 label |
|
1076 accessCharaterPos |
|
1077 activeHelpKey |
|
1078 enabled |
|
1079 value |
|
1080 nameKey |
|
1081 indication |
|
1082 shortcutKey |
|
1083 doubleSeperator |
|
1084 retriever |
|
1085 iconAndLabel |
|
1086 icon |
|
1087 |
|
1088 ) do:[:aKey||holder| |
|
1089 holder := ValueHolder new. |
|
1090 holder addDependent:self. |
|
1091 aspects at:aKey put:holder. |
|
1092 ]. |
|
1093 |
|
1094 |
|
1095 |
|
1096 ! |
|
1097 |
|
1098 openInterface |
|
1099 super openInterface. |
|
1100 self buildFrom:nil andSelector:nil. |
|
1101 ! |
|
1102 |
|
1103 openOnClass:aClass andSelector:aSelector |
|
1104 super openInterface. |
|
1105 self buildFrom:aClass andSelector:aSelector. |
|
1106 ! ! |
|
1107 |
|
1108 !MenuEditor methodsFor:'user interactions'! |
|
1109 |
|
1110 doBrowseAppClass |
|
1111 "open a browser on the class" |
|
1112 |
|
1113 |cls| |
|
1114 |
|
1115 (cls := self specClass) isNil ifTrue:[ |
|
1116 ^ self information:'no class yet'. |
|
1117 ]. |
|
1118 |
|
1119 cls isBehavior ifFalse:[ |
|
1120 (cls := Smalltalk at:cls asSymbol) isNil ifTrue:[ |
|
1121 ^ self information:'no valid class defined'. |
|
1122 ] |
|
1123 ]. |
|
1124 SystemBrowser openInClass:cls |
|
1125 |
|
1126 ! |
|
1127 |
|
1128 doDefineClass |
|
1129 |
|
1130 aspects at:#classNameChannel put:(self specClass asValue). |
|
1131 |
|
1132 (self openDialogInterface:#classDefineSpec) ifTrue:[ |
|
1133 self specClass:((aspects at:#classNameChannel) value) |
|
1134 ]. |
|
1135 |
|
1136 ! |
|
1137 |
|
1138 doFromClass |
|
1139 |
|
1140 aspects at:#classNameChannel put:(self specClass asValue). |
|
1141 aspects at:#methodNameChannel put:(self painter selectorName asValue). |
|
1142 |
|
1143 (self openDialogInterface:#classAndMethodSpec) ifTrue:[ |
|
1144 self buildFrom:(aspects at:#classNameChannel) value |
|
1145 andSelector:(aspects at:#methodNameChannel) value |
|
1146 ]. |
|
1147 ! |
|
1148 |
|
1149 doInstallHelp |
|
1150 "install help text |
|
1151 " |
|
1152 self helpTool installHelpSpecInto:(self specClass) |
|
1153 ! |
|
1154 |
|
1155 doInstallSpec |
|
1156 |cls selector painter menu spec mthd category code| |
|
1157 |
|
1158 (cls := self specClass) isNil ifTrue:[ |
|
1159 ^ self information:'no class yet'. |
|
1160 ]. |
|
1161 |
|
1162 cls isBehavior ifFalse:[ |
|
1163 (cls := Smalltalk at:cls asSymbol) isNil ifTrue:[ |
|
1164 ^ self information:'no valid class defined'. |
|
1165 ] |
|
1166 ]. |
|
1167 painter := self painter. |
|
1168 selector := painter selectorName. |
|
1169 menu := painter asMenu. |
|
1170 |
|
1171 menu isNil ifTrue:[ |
|
1172 ^ self information:'no menu defined' |
|
1173 ]. |
|
1174 menu := menu literalArrayEncoding. |
|
1175 spec := WriteStream on:String new. |
|
1176 UISpecification prettyPrintSpecArray:menu on:spec indent:5. |
|
1177 spec := spec contents. |
|
1178 |
|
1179 "/ if that method already exists, do not overwrite the category |
|
1180 |
|
1181 category := 'interface specs'. |
|
1182 (mthd := cls class compiledMethodAt:selector) notNil ifTrue:[ |
|
1183 category := mthd category. |
|
1184 ]. |
|
1185 |
|
1186 code := Character excla asString |
|
1187 , cls name , ' class methodsFor:' , category storeString |
|
1188 , Character excla asString , '\\' |
|
1189 |
|
1190 , selector , '\' |
|
1191 , ' "this window spec was automatically generated by the ST/X MenuEditor"\\' |
|
1192 , ' "do not manually edit this - the builder may not be able to\' |
|
1193 , ' handle the specification if its corrupted."\\' |
|
1194 , ' "\' |
|
1195 , ' MenuEditor new openOnClass:' , cls name , ' andSelector:#' , selector , '\' |
|
1196 , ' (Menu new fromLiteralArrayEncoding:(' , cls name , ' ' , selector , ')) startUp\' |
|
1197 , ' "\'. |
|
1198 |
|
1199 code := code |
|
1200 , '\' |
|
1201 , ' <resource: #menu>\\' |
|
1202 , ' ^\' |
|
1203 , ' ', spec |
|
1204 , '\' |
|
1205 , Character excla asString |
|
1206 , ' ' |
|
1207 , Character excla asString |
|
1208 , '\\'. |
|
1209 |
|
1210 code := code withCRs. |
|
1211 (ReadStream on:code) fileIn. |
|
1212 |
|
1213 ! |
|
1214 |
|
1215 doNew |
|
1216 self buildFrom:nil andSelector:(self painter selectorName) |
|
1217 ! |
|
1218 |
|
1219 doPickAMenu |
|
1220 |
|
1221 |menu| |
|
1222 |
|
1223 menu := Screen current viewFromUser. |
|
1224 |
|
1225 (menu isNil or:[menu == Screen current rootView]) ifTrue:[ |
|
1226 ^ self |
|
1227 ]. |
|
1228 (menu isKindOf:MenuPanel) ifTrue:[ |
|
1229 ^ self painter buildFromMenu:(menu asMenu) |
|
1230 ]. |
|
1231 ! |
|
1232 |
|
1233 doTest |
|
1234 "open current editing menu |
|
1235 " |
|
1236 |menu value| |
|
1237 |
|
1238 menu := self painter asMenu. |
|
1239 |
|
1240 menu notNil ifTrue:[ |
|
1241 menu receiver:nil. |
|
1242 value := menu startUp. |
|
1243 Transcript showCR:'result from test: ', value printString |
|
1244 ] |
|
1245 |
|
1246 |
|
1247 ! ! |
|
1248 |
|
1249 !MenuEditor methodsFor:'values'! |
|
1250 |
|
1251 helpTool |
|
1252 |tool| |
|
1253 |
|
1254 (tool := builder bindingAt:#helpTool) isNil ifTrue:[ |
|
1255 tool := UIHelpTool new. |
|
1256 tool masterApplication:self. |
|
1257 builder aspectAt:#helpTool put:tool |
|
1258 ]. |
|
1259 ^ tool |
|
1260 ! |
|
1261 |
|
1262 painter |
|
1263 "automatically generated by UIPainter ..." |
|
1264 |
|
1265 |painter| |
|
1266 |
|
1267 (painter := builder bindingAt:#painter) isNil ifTrue:[ |
|
1268 painter := Painter new. |
|
1269 painter action:[:dummy| self menuChanged ]. |
|
1270 builder aspectAt:#painter put:painter. |
|
1271 ]. |
|
1272 ^ painter |
|
1273 ! ! |
|
1274 |
|
1275 !MenuEditor::Item class methodsFor:'documentation'! |
|
1276 |
|
1277 documentation |
|
1278 " |
|
1279 implements the contents assigned to a HierarchyNode. An instance |
|
1280 is associated with one item and keeps all its information |
|
1281 |
|
1282 [see also:] |
|
1283 HierarchyNode |
|
1284 MenuEditor |
|
1285 |
|
1286 [author:] |
|
1287 Claus Atzkern |
|
1288 " |
|
1289 |
|
1290 |
|
1291 ! ! |
|
1292 |
|
1293 !MenuEditor::Item methodsFor:'accessing'! |
|
1294 |
|
1295 label |
|
1296 "return the value of the instance variable 'label' (automatically generated)" |
|
1297 |
|
1298 ^ label! |
|
1299 |
|
1300 label:something |
|
1301 "set the value of the instance variable 'label' (automatically generated)" |
|
1302 |
|
1303 label := something.! ! |
|
1304 |
|
1305 !MenuEditor::Item methodsFor:'conversion'! |
|
1306 |
|
1307 asMenuItem |
|
1308 "converts self to a menu item |
|
1309 " |
|
1310 |item rcv| |
|
1311 |
|
1312 item := MenuItem labeled:(label ? '-'). |
|
1313 |
|
1314 self isSeperator ifFalse:[ |
|
1315 item activeHelpKey:activeHelpKey. |
|
1316 item enabled:enabled. |
|
1317 item accessCharacterPosition:accessCharaterPos. |
|
1318 item nameKey:nameKey. |
|
1319 item shortcutKeyCharacter:shortcutKey. |
|
1320 item value:value. |
|
1321 item indication:indication. |
|
1322 |
|
1323 icon notNil ifTrue:[ |
|
1324 rcv := ResourceRetriever new. |
|
1325 rcv className:retriever. |
|
1326 rcv selector:icon. |
|
1327 iconAndLabel == true ifTrue:[ |
|
1328 rcv labelText:label |
|
1329 ]. |
|
1330 item labelImage:rcv |
|
1331 ] |
|
1332 ]. |
|
1333 ^ item. |
|
1334 ! |
|
1335 |
|
1336 buildFromAspects:aspects |
|
1337 |name| |
|
1338 |
|
1339 self isSeperator ifFalse:[ |
|
1340 name := label. |
|
1341 label := (aspects at:#label) value. |
|
1342 |
|
1343 self isSeperator ifTrue:[ |
|
1344 (aspects at:#label) value:(label := name) |
|
1345 ]. |
|
1346 |
|
1347 activeHelpKey := (aspects at:#activeHelpKey) value. |
|
1348 enabled := (aspects at:#enabled) value. |
|
1349 value := (aspects at:#value) value. |
|
1350 nameKey := (aspects at:#nameKey) value. |
|
1351 indication := (aspects at:#indication) value. |
|
1352 shortcutKey := (aspects at:#shortcutKey) value. |
|
1353 accessCharaterPos := (aspects at:#accessCharaterPos) value. |
|
1354 retriever := (aspects at:#retriever) value. |
|
1355 icon := (aspects at:#icon) value. |
|
1356 iconAndLabel := (aspects at:#iconAndLabel) value. |
|
1357 ] ifTrue:[ |
|
1358 (aspects at:#doubleSeperator) value ifTrue:[label := '='] |
|
1359 ifFalse:[label := nil]. |
|
1360 ] |
|
1361 ! |
|
1362 |
|
1363 buildFromMenuItem:anItem |
|
1364 |rtv| |
|
1365 |
|
1366 label := anItem label. |
|
1367 activeHelpKey := anItem activeHelpKey. |
|
1368 |
|
1369 (enabled := anItem enabled) isSymbol ifFalse:[ |
|
1370 enabled := nil |
|
1371 ]. |
|
1372 |
|
1373 (value := anItem value) isSymbol ifFalse:[ |
|
1374 value := nil. |
|
1375 ]. |
|
1376 |
|
1377 (indication := anItem indication) isSymbol ifFalse:[ |
|
1378 indication := nil |
|
1379 ]. |
|
1380 |
|
1381 nameKey := anItem nameKey. |
|
1382 shortcutKey := anItem shortcutKeyCharacter. |
|
1383 accessCharaterPos := anItem accessCharacterPosition. |
|
1384 |
|
1385 ( ((rtv := anItem adornment) notNil) |
|
1386 and:[(rtv := rtv labelImage) isKindOf:ResourceRetriever] |
|
1387 ) ifTrue:[ |
|
1388 retriever := rtv className. |
|
1389 icon := rtv selector. |
|
1390 |
|
1391 (iconAndLabel := rtv labelText notNil) ifTrue:[ |
|
1392 label := rtv labelText. |
|
1393 ] |
|
1394 ] |
|
1395 ! |
|
1396 |
|
1397 toAspects:aspects |
|
1398 |
|
1399 self isSeperator ifTrue:[ |
|
1400 (aspects at:#doubleSeperator) value:(label notNil). |
|
1401 ] ifFalse:[ |
|
1402 (aspects at:#label) value:label. |
|
1403 (aspects at:#activeHelpKey) value:activeHelpKey. |
|
1404 (aspects at:#enabled) value:enabled. |
|
1405 (aspects at:#value) value:value. |
|
1406 (aspects at:#nameKey) value:nameKey. |
|
1407 (aspects at:#indication) value:indication. |
|
1408 (aspects at:#shortcutKey) value:shortcutKey. |
|
1409 (aspects at:#accessCharaterPos) value:accessCharaterPos. |
|
1410 (aspects at:#retriever) value:retriever. |
|
1411 (aspects at:#icon) value:icon. |
|
1412 (aspects at:#iconAndLabel) value:iconAndLabel. |
|
1413 ] |
|
1414 ! ! |
|
1415 |
|
1416 !MenuEditor::Item methodsFor:'queries'! |
|
1417 |
|
1418 isSeperator |
|
1419 |c| |
|
1420 |
|
1421 label size > 1 ifTrue:[^ false]. |
|
1422 label size == 1 ifTrue:[ |
|
1423 (c := label first) == $= ifTrue:[ |
|
1424 ^ true |
|
1425 ]. |
|
1426 c == $- ifFalse:[ |
|
1427 ^ false |
|
1428 ]. |
|
1429 ]. |
|
1430 label := nil. |
|
1431 ^ true |
|
1432 |
|
1433 ! |
|
1434 |
|
1435 isSimpleSeperator |
|
1436 ^ label isNil |
|
1437 ! ! |
|
1438 |
|
1439 !MenuEditor::Painter class methodsFor:'defaults'! |
|
1440 |
|
1441 defaultMenuMessage |
|
1442 "This message is the default yo be sent to the menuHolder to get a menu |
|
1443 " |
|
1444 ^ #menu |
|
1445 |
|
1446 |
|
1447 ! ! |
|
1448 |
|
1449 !MenuEditor::Painter class methodsFor:'documentation'! |
|
1450 |
|
1451 documentation |
|
1452 " |
|
1453 menu selection list |
|
1454 |
|
1455 [see also:] |
|
1456 SelectionInTreeView |
|
1457 SelectionInHierarchy |
|
1458 HierarchyNode |
|
1459 |
|
1460 [author:] |
|
1461 Claus Atzkern |
|
1462 " |
|
1463 |
|
1464 |
|
1465 ! ! |
|
1466 |
|
1467 !MenuEditor::Painter methodsFor:'accessing'! |
|
1468 |
|
1469 root |
|
1470 ^ listOfNodes first |
|
1471 ! |
|
1472 |
|
1473 selectorName |
|
1474 ^ (listOfNodes first contents label) asSymbol |
|
1475 ! ! |
|
1476 |
|
1477 !MenuEditor::Painter methodsFor:'building'! |
|
1478 |
|
1479 buildFrom:aClass andSelector:aSelector |
|
1480 |spec cls menu node| |
|
1481 |
|
1482 (aClass notNil and:[aSelector notNil]) ifTrue:[ |
|
1483 aClass isBehavior ifFalse:[cls := Smalltalk at:aClass asSymbol] |
|
1484 ifTrue:[cls := aClass]. |
|
1485 |
|
1486 (cls respondsTo:aSelector) ifTrue:[ |
|
1487 spec := cls perform:aSelector |
|
1488 ] |
|
1489 ]. |
|
1490 spec isNil ifFalse:[ |
|
1491 menu := Menu new fromLiteralArrayEncoding:spec. |
|
1492 node := self nodeLabel:(aSelector asString) level:1. |
|
1493 self subMenu:menu parent:node. |
|
1494 ] ifTrue:[ |
|
1495 aSelector notNil ifTrue:[cls := aSelector asString] |
|
1496 ifFalse:[cls := 'menu']. |
|
1497 |
|
1498 node := self nodeLabel:cls level:1. |
|
1499 ]. |
|
1500 |
|
1501 node hasChildren ifFalse:[ |
|
1502 node addChild:(self nodeLabel:'undefined' level:1) |
|
1503 ]. |
|
1504 model root:node. |
|
1505 model setHideToChildren:true startingAt:node. |
|
1506 |
|
1507 ! |
|
1508 |
|
1509 buildFromMenu:aMenu |
|
1510 |
|
1511 |spec cls node| |
|
1512 |
|
1513 node := self nodeLabel:'menu' level:1. |
|
1514 self subMenu:aMenu parent:node. |
|
1515 |
|
1516 node hasChildren ifFalse:[ |
|
1517 node addChild:(self nodeLabel:'undefined' level:1) |
|
1518 ]. |
|
1519 model root:node. |
|
1520 model setHideToChildren:true startingAt:node. |
|
1521 |
|
1522 ! |
|
1523 |
|
1524 item:anItem level:aLevel |
|
1525 |
|
1526 |level node submenu grp ctr sep| |
|
1527 |
|
1528 node := self nodeLabel:(anItem label) level:aLevel. |
|
1529 node contents buildFromMenuItem:anItem. |
|
1530 node name:(node contents label). |
|
1531 node hide:true. |
|
1532 self subMenu:(anItem submenu) parent:node. |
|
1533 ^ node. |
|
1534 |
|
1535 |
|
1536 ! |
|
1537 |
|
1538 subMenu:aMenu parent:aParent |
|
1539 |lvl grp sep| |
|
1540 |
|
1541 aMenu isNil ifFalse:[ |
|
1542 lvl := (aParent level) + 1. |
|
1543 grp := aMenu groupSizes. |
|
1544 |
|
1545 aMenu itemsDo:[:i| aParent addChild:(self item:i level:lvl)]. |
|
1546 |
|
1547 grp notNil ifTrue:[ |
|
1548 sep := self nodeLabel:nil level:lvl. |
|
1549 lvl := 0. |
|
1550 |
|
1551 grp do:[:i| |
|
1552 lvl := lvl + i + 1. |
|
1553 aParent addChildAndSubChildren:sep at:lvl |
|
1554 ] |
|
1555 ] |
|
1556 ] |
|
1557 ! ! |
|
1558 |
|
1559 !MenuEditor::Painter methodsFor:'conversion'! |
|
1560 |
|
1561 asMenu |
|
1562 |menu root| |
|
1563 |
|
1564 root := self root. |
|
1565 |
|
1566 root hasChildren ifTrue:[ |
|
1567 menu := Menu new. |
|
1568 root children do:[:aChild| menu addItem:(self asMenuItem:aChild)]. |
|
1569 ]. |
|
1570 ^ menu |
|
1571 ! |
|
1572 |
|
1573 asMenuItem:aNode |
|
1574 |
|
1575 |menu item| |
|
1576 |
|
1577 item := aNode contents asMenuItem. |
|
1578 |
|
1579 aNode hasChildren ifTrue:[ |
|
1580 menu := Menu new. |
|
1581 aNode children do:[:aChild| menu addItem:(self asMenuItem:aChild)]. |
|
1582 item submenu:menu |
|
1583 ]. |
|
1584 ^ item |
|
1585 |
|
1586 ! ! |
|
1587 |
|
1588 !MenuEditor::Painter methodsFor:'drawing basics'! |
|
1589 |
|
1590 drawLabelIndex:anIndex atX:x y:yCenter |
|
1591 "draw text label assigned to a node at x y( center) |
|
1592 " |
|
1593 |y w item| |
|
1594 |
|
1595 item := (listOfNodes at:anIndex) contents. |
|
1596 |
|
1597 item isSeperator ifFalse:[ |
|
1598 ^ super drawLabelIndex:anIndex atX:x y:yCenter |
|
1599 ]. |
|
1600 self displayLineFromX:x y:yCenter toX:(x + 80) y:yCenter. |
|
1601 |
|
1602 item isSimpleSeperator ifFalse:[ |
|
1603 self displayLineFromX:x y:(yCenter + 2) toX:(x + 80) y:(yCenter + 2). |
|
1604 ] |
|
1605 |
|
1606 ! ! |
|
1607 |
|
1608 !MenuEditor::Painter methodsFor:'initialization'! |
|
1609 |
|
1610 initialize |
|
1611 super initialize. |
|
1612 super model:(SelectionInHierarchy new). |
|
1613 |
|
1614 |
|
1615 ! ! |
|
1616 |
|
1617 !MenuEditor::Painter methodsFor:'menus'! |
|
1618 |
|
1619 doCopy |
|
1620 CopyBuffer := listOfNodes at:selection. |
|
1621 |
|
1622 |
|
1623 ! |
|
1624 |
|
1625 doCreateItem |
|
1626 self addNode:(self nodeLabel:'undefined' level:1) |
|
1627 ! |
|
1628 |
|
1629 doCreateMenu |
|
1630 |node| |
|
1631 |
|
1632 node := self nodeLabel:'undefined' level:1. |
|
1633 node addChild:(self nodeLabel:'undefined' level:2). |
|
1634 self addNode:node |
|
1635 |
|
1636 ! |
|
1637 |
|
1638 doCreateSep |
|
1639 self addNode:(self nodeLabel:nil level:1) |
|
1640 |
|
1641 ! |
|
1642 |
|
1643 doCut |
|
1644 self doCopy. |
|
1645 model removeIndex:selection. |
|
1646 self selection:nil. |
|
1647 |
|
1648 |
|
1649 ! |
|
1650 |
|
1651 doPaste |
|
1652 self addNode:CopyBuffer |
|
1653 ! |
|
1654 |
|
1655 menu |
|
1656 |menu subm| |
|
1657 |
|
1658 selection isNumber ifFalse:[ |
|
1659 ^ nil |
|
1660 ]. |
|
1661 |
|
1662 menu := PopUpMenu labels:#( 'copy' 'cut' 'paste' '-' 'create' ) |
|
1663 selectors:#( #doCopy #doCut #doPaste nil #create ) |
|
1664 receiver:self. |
|
1665 |
|
1666 selection == 1 ifTrue:[ |
|
1667 menu disable:#doCopy. |
|
1668 menu disable:#doCut. |
|
1669 ]. |
|
1670 subm := PopUpMenu labels:#( 'menu' 'item' 'seperator' ) |
|
1671 selectors:#( #doCreateMenu #doCreateItem #doCreateSep ) |
|
1672 receiver:self. |
|
1673 |
|
1674 menu subMenuAt:#create put:subm. |
|
1675 |
|
1676 ^ menu. |
|
1677 |
|
1678 |
|
1679 ! ! |
|
1680 |
|
1681 !MenuEditor::Painter methodsFor:'private'! |
|
1682 |
|
1683 addNode:aNode |
|
1684 |node parent| |
|
1685 |
|
1686 (aNode notNil and:[(node := self selectedNode) notNil]) ifFalse:[ |
|
1687 ^ self |
|
1688 ]. |
|
1689 |
|
1690 (node isCollapsable or:[node parent isNil]) ifTrue:[ |
|
1691 model addChildAndSubChildren:aNode below:node at:1 |
|
1692 ] ifFalse:[ |
|
1693 model addChildAndSubChildren:aNode below:(node parent) after:node |
|
1694 ] |
|
1695 |
|
1696 |
|
1697 ! |
|
1698 |
|
1699 nodeLabel:aLabel level:aLevel |
|
1700 |node| |
|
1701 |
|
1702 node := HierarchyNode new. |
|
1703 node childCollectionClass:OrderedCollection. |
|
1704 node name:aLabel. |
|
1705 node level:aLevel. |
|
1706 node contents:(MenuEditor::Item new label:aLabel). |
|
1707 ^ node |
|
1708 ! ! |
|
1709 |
|
1710 !MenuEditor::Painter methodsFor:'selection'! |
|
1711 |
|
1712 selectedNodeChanged |
|
1713 |node name| |
|
1714 |
|
1715 (node := self selectedNode) isNil ifTrue:[^ self]. |
|
1716 name := node contents label. |
|
1717 |
|
1718 list at:selection put:name. |
|
1719 node name:name. |
|
1720 self redrawLine:selection. |
|
1721 ! ! |
|
1722 |
|
1723 !MenuEditor class methodsFor:'documentation'! |
|
1724 |
|
1725 version |
|
1726 ^ '$Header$' |
|
1727 ! ! |