author | Claus Gittinger <cg@exept.de> |
Mon, 27 Jul 1998 09:58:47 +0200 | |
changeset 1006 | 786de97d72f9 |
parent 1004 | 6dc621535e26 |
child 1013 | 64f464903584 |
permissions | -rw-r--r-- |
756 | 1 |
" |
784 | 2 |
COPYRIGHT (c) 1997 by eXept Software AG |
756 | 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 |
||
753 | 15 |
ApplicationModel subclass:#ToolApplicationModel |
782 | 16 |
instanceVariableNames:'timeBlock' |
753 | 17 |
classVariableNames:'' |
18 |
poolDictionaries:'' |
|
834 | 19 |
category:'Interface-Framework' |
753 | 20 |
! |
21 |
||
850 | 22 |
ToolApplicationModel class instanceVariableNames:'history clipboard settings showHelp' |
753 | 23 |
|
24 |
" |
|
25 |
The following class instance variables are inherited by this class: |
|
26 |
||
27 |
ApplicationModel - ClassResources |
|
28 |
Model - |
|
29 |
Object - |
|
30 |
" |
|
31 |
! |
|
32 |
||
33 |
!ToolApplicationModel class methodsFor:'documentation'! |
|
34 |
||
756 | 35 |
copyright |
36 |
" |
|
784 | 37 |
COPYRIGHT (c) 1997 by eXept Software AG |
756 | 38 |
All Rights Reserved |
39 |
||
40 |
This software is furnished under a license and may be used |
|
41 |
only in accordance with the terms of that license and with the |
|
42 |
inclusion of the above copyright notice. This software may not |
|
43 |
be provided or otherwise made available to, or used by, any |
|
44 |
other person. No title to or ownership of the software is |
|
45 |
hereby transferred. |
|
46 |
" |
|
47 |
||
48 |
||
49 |
! |
|
50 |
||
753 | 51 |
documentation |
52 |
" |
|
869 | 53 |
Framework class for tool applications. |
54 |
Provides hooks for history management, |
|
782 | 55 |
showing help texts, about menu, help menu etc. |
753 | 56 |
|
57 |
[author:] |
|
876 | 58 |
Thomas Zwick, eXept Software AG |
753 | 59 |
" |
60 |
! ! |
|
61 |
||
62 |
!ToolApplicationModel class methodsFor:'accessing'! |
|
63 |
||
800 | 64 |
authorLinesForAboutBox |
907 | 65 |
"extracts the author(s) from the documentation method." |
800 | 66 |
|
67 |
|firstClassWithDocumentation src s line lines| |
|
753 | 68 |
|
800 | 69 |
firstClassWithDocumentation := self class withAllSuperclasses detect:[:metacls| metacls implements:#documentation]. |
70 |
firstClassWithDocumentation notNil ifTrue:[ |
|
71 |
(firstClassWithDocumentation inheritsFrom:ToolApplicationModel class) ifTrue:[ |
|
72 |
src := (firstClassWithDocumentation compiledMethodAt:#documentation) source. |
|
73 |
src notNil ifTrue:[ |
|
74 |
s := src readStream. |
|
75 |
s upToAll:'[author:]'. |
|
76 |
s nextLine. "/ skip to end |
|
77 |
line := s nextLine. "/ line after [author:] |
|
78 |
lines := OrderedCollection new. |
|
79 |
[line notNil and:[line notEmpty]] whileTrue:[ |
|
80 |
line := line trimBlanks. |
|
81 |
line size > 1 ifTrue:[ |
|
82 |
lines add:line trimBlanks. |
|
83 |
line := s nextLine. |
|
84 |
] ifFalse:[ |
|
85 |
line := nil |
|
86 |
] |
|
87 |
]. |
|
88 |
^ lines. |
|
89 |
] |
|
90 |
] |
|
91 |
]. |
|
92 |
^ #('unnown') |
|
93 |
||
94 |
"Created: / 1.2.1998 / 15:41:43 / cg" |
|
95 |
"Modified: / 1.2.1998 / 15:59:10 / cg" |
|
753 | 96 |
! |
97 |
||
98 |
label |
|
907 | 99 |
"returns the label for the tools of this class; |
100 |
extracted from the class name; |
|
101 |
can be redefined in subclasses" |
|
753 | 102 |
|
103 |
|label| |
|
104 |
label := ''. |
|
105 |
self name do: |
|
106 |
[:c| |
|
107 |
c isUppercase ifTrue: [label := label, $ ]. |
|
108 |
label := label, c |
|
109 |
]. |
|
110 |
^label trimBlanks |
|
782 | 111 |
! |
112 |
||
850 | 113 |
settings |
907 | 114 |
"returns the settings dictionary" |
850 | 115 |
|
872 | 116 |
settings isNil ifTrue: [settings := IdentityDictionary new]. |
117 |
^settings |
|
850 | 118 |
! |
119 |
||
782 | 120 |
showHelp |
907 | 121 |
"returns whether the active help is turned on" |
782 | 122 |
|
872 | 123 |
showHelp isNil ifTrue: [showHelp := true]. |
124 |
^showHelp |
|
782 | 125 |
! |
126 |
||
127 |
showHelp: aBoolean |
|
907 | 128 |
"sets the active help on aBoolean" |
782 | 129 |
|
130 |
^showHelp := aBoolean |
|
753 | 131 |
! ! |
132 |
||
756 | 133 |
!ToolApplicationModel class methodsFor:'clipboard'! |
134 |
||
135 |
clipboard |
|
907 | 136 |
"returns the clipboard of this tool class" |
756 | 137 |
|
138 |
^clipboard |
|
139 |
! |
|
140 |
||
141 |
clipboard: anEditObject |
|
907 | 142 |
"sets the clipboard for this tool class" |
756 | 143 |
|
144 |
clipboard := anEditObject |
|
145 |
! ! |
|
146 |
||
762 | 147 |
!ToolApplicationModel class methodsFor:'help specs'! |
148 |
||
149 |
helpSpec |
|
869 | 150 |
"This resource specification was automatically generated |
151 |
by the UIHelpTool of ST/X." |
|
152 |
||
153 |
"Do not manually edit this!! If it is corrupted, |
|
154 |
the UIHelpTool may not be able to read the specification." |
|
762 | 155 |
|
156 |
" |
|
869 | 157 |
UIHelpTool openOnClass:ToolApplicationModel |
762 | 158 |
" |
159 |
||
869 | 160 |
<resource: #help> |
161 |
||
162 |
^super helpSpec addPairsFrom:#( |
|
762 | 163 |
|
823 | 164 |
#about |
834 | 165 |
'About functions.' |
823 | 166 |
|
762 | 167 |
#aboutSTX |
910 | 168 |
'Open an InfoBox showing details of the running ST/X.' |
762 | 169 |
|
170 |
#aboutThisAppliaction |
|
910 | 171 |
'Open an InfoBox about that applications release and its author.' |
762 | 172 |
|
823 | 173 |
#add |
834 | 174 |
'Add functions.' |
823 | 175 |
|
176 |
#commitCancel |
|
910 | 177 |
'Cancels changes.' |
823 | 178 |
|
179 |
#commitOK |
|
910 | 180 |
'Commit changes.' |
823 | 181 |
|
182 |
#edit |
|
834 | 183 |
'Edit functions.' |
823 | 184 |
|
185 |
#editCopy |
|
910 | 186 |
'Copy the selected item(s) to the clipboard.' |
762 | 187 |
|
782 | 188 |
#editCut |
910 | 189 |
'Move the selected item(s) to the clipboard.' |
853 | 190 |
|
191 |
#editDelete |
|
910 | 192 |
'Delete the selected item(s).' |
782 | 193 |
|
823 | 194 |
#editMoveDown |
910 | 195 |
'Moves the selected item one step down in the order list.' |
823 | 196 |
|
197 |
#editMoveIn |
|
834 | 198 |
'Moves the selected item into next item as child item.' |
823 | 199 |
|
200 |
#editMoveOut |
|
910 | 201 |
'Moves the selected item out of its parent item.' |
823 | 202 |
|
203 |
#editMoveUp |
|
910 | 204 |
'Moves the selected item one step up in the order list.' |
782 | 205 |
|
206 |
#editPaste |
|
910 | 207 |
'Paste from the clipboard.' |
782 | 208 |
|
209 |
#editUndo |
|
910 | 210 |
'Undo the last action.' |
782 | 211 |
|
823 | 212 |
#file |
834 | 213 |
'File functions.' |
805 | 214 |
|
823 | 215 |
#fileBrowseClass |
910 | 216 |
'Open a System Browser on the current class and selector.' |
805 | 217 |
|
823 | 218 |
#fileDefineClass |
910 | 219 |
'Open a dialog to define the current class.' |
805 | 220 |
|
221 |
#fileDefineClassAndSelector |
|
910 | 222 |
'Open a dialog to define the current class and selector.' |
805 | 223 |
|
823 | 224 |
#fileExit |
910 | 225 |
'Exit this application.' |
823 | 226 |
|
922 | 227 |
#generate |
228 |
'Code generation.' |
|
229 |
||
823 | 230 |
#help |
834 | 231 |
'Help functions.' |
823 | 232 |
|
876 | 233 |
#helpHelpTool |
910 | 234 |
'Open an HTML-Browser showing the Help Tools documentation.' |
876 | 235 |
|
823 | 236 |
#helpShowHelp |
910 | 237 |
'Toggle display of help texts.' |
823 | 238 |
|
239 |
#helpTutorial |
|
910 | 240 |
'Open an HTML-Browser showing this applications documentation.' |
823 | 241 |
|
242 |
#history |
|
834 | 243 |
'History functions.' |
803 | 244 |
|
245 |
#historyEmptyMenu |
|
910 | 246 |
'Delete all items in the history.' |
803 | 247 |
|
823 | 248 |
#historyMenuItem |
910 | 249 |
'Evaluate the text of the menu item for loading.' |
762 | 250 |
|
893 | 251 |
#settings |
252 |
'Settings functions.' |
|
253 |
||
823 | 254 |
#test |
834 | 255 |
'Test functions.' |
762 | 256 |
|
257 |
) |
|
258 |
! ! |
|
259 |
||
753 | 260 |
!ToolApplicationModel class methodsFor:'history'! |
261 |
||
262 |
getHistory |
|
907 | 263 |
"returns the history for this tool class" |
753 | 264 |
|
761
cc0404f8aec6
#getHistory changed because here #? doesn't work correctly
tz
parents:
760
diff
changeset
|
265 |
history isNil ifTrue: [history := OrderedCollection new]. |
cc0404f8aec6
#getHistory changed because here #? doesn't work correctly
tz
parents:
760
diff
changeset
|
266 |
^history |
753 | 267 |
|
268 |
! |
|
269 |
||
270 |
historyMaxSize |
|
907 | 271 |
"returns the maximum size for the history of this tool class" |
753 | 272 |
|
273 |
^10 |
|
274 |
||
275 |
! ! |
|
276 |
||
869 | 277 |
!ToolApplicationModel class methodsFor:'image specs'! |
278 |
||
279 |
desktopIcon |
|
907 | 280 |
"returns the icon used for the desktop" |
869 | 281 |
|
282 |
^Icon |
|
283 |
constantNamed:#'ToolApplicationModel desktopIcon' |
|
284 |
ifAbsentPut: |
|
285 |
[ |
|
286 |
|desktopIcon| |
|
990 | 287 |
desktopIcon := Icon stxIcon. |
869 | 288 |
desktopIcon magnifiedBy: Display preferredIconSize/desktopIcon extent |
289 |
] |
|
290 |
||
291 |
||
292 |
||
293 |
||
294 |
! |
|
295 |
||
296 |
menuIcon |
|
907 | 297 |
"returns the icon used for the menu bar" |
869 | 298 |
|
299 |
^Icon |
|
300 |
constantNamed:#'ToolApplicationModel menuIcon' |
|
301 |
ifAbsentPut: |
|
302 |
[ |
|
303 |
|menuIcon| |
|
990 | 304 |
menuIcon := Icon stxIcon. |
869 | 305 |
menuIcon magnifiedBy: MenuPanel defaultFont height/menuIcon height |
306 |
] |
|
987 | 307 |
! ! |
869 | 308 |
|
753 | 309 |
!ToolApplicationModel class methodsFor:'interface specs'! |
310 |
||
797 | 311 |
windowSpecForCommit |
869 | 312 |
"This resource specification was automatically generated |
313 |
by the UIPainter of ST/X." |
|
314 |
||
315 |
"Do not manually edit this!! If it is corrupted, |
|
316 |
the UIPainter may not be able to read the specification." |
|
317 |
||
318 |
" |
|
319 |
UIPainter new openOnClass:ToolApplicationModel andSelector:#windowSpecForCommit |
|
320 |
ToolApplicationModel new openInterface:#windowSpecForCommit |
|
321 |
" |
|
797 | 322 |
|
323 |
<resource: #canvas> |
|
324 |
||
325 |
^ |
|
859 | 326 |
|
797 | 327 |
#(#FullSpec |
859 | 328 |
#window: |
797 | 329 |
#(#WindowSpec |
859 | 330 |
#name: 'Commit Buttons' |
869 | 331 |
#layout: #(#LayoutFrame 344 0 371 0 643 0 430 0) |
859 | 332 |
#label: 'Commit Buttons' |
333 |
#min: #(#Point 100 22) |
|
334 |
#max: #(#Point 1152 900) |
|
869 | 335 |
#bounds: #(#Rectangle 344 371 644 431) |
859 | 336 |
#usePreferredExtent: false |
797 | 337 |
) |
859 | 338 |
#component: |
797 | 339 |
#(#SpecCollection |
859 | 340 |
#collection: |
797 | 341 |
#( |
342 |
#(#ActionButtonSpec |
|
859 | 343 |
#name: 'cancelButton' |
344 |
#layout: #(#LayoutFrame 5 0 0 0 -2 0.5 0 1) |
|
345 |
#activeHelpKey: #commitCancel |
|
346 |
#label: 'Cancel' |
|
927 | 347 |
#translateLabel: true |
859 | 348 |
#tabable: true |
349 |
#model: #cancel |
|
350 |
#enableChannel: #valueOfEnablingCommitButtons |
|
797 | 351 |
) |
352 |
#(#ActionButtonSpec |
|
859 | 353 |
#name: 'okButton' |
354 |
#layout: #(#LayoutFrame 2 0.5 0 0.0 -5 1 0 1.0) |
|
355 |
#activeHelpKey: #commitOK |
|
356 |
#label: 'OK' |
|
927 | 357 |
#translateLabel: true |
859 | 358 |
#tabable: true |
359 |
#model: #accept |
|
360 |
#enableChannel: #valueOfEnablingCommitButtons |
|
797 | 361 |
) |
362 |
) |
|
363 |
) |
|
364 |
) |
|
927 | 365 |
|
366 |
"Modified: / 20.5.1998 / 03:31:54 / cg" |
|
797 | 367 |
! |
368 |
||
369 |
windowSpecForCommitWithoutChannels |
|
869 | 370 |
"This resource specification was automatically generated |
371 |
by the UIPainter of ST/X." |
|
372 |
||
373 |
"Do not manually edit this!! If it is corrupted, |
|
374 |
the UIPainter may not be able to read the specification." |
|
375 |
||
376 |
" |
|
377 |
UIPainter new openOnClass:ToolApplicationModel andSelector:#windowSpecForCommitWithoutChannels |
|
378 |
ToolApplicationModel new openInterface:#windowSpecForCommitWithoutChannels |
|
379 |
" |
|
797 | 380 |
|
381 |
<resource: #canvas> |
|
382 |
||
383 |
^ |
|
859 | 384 |
|
797 | 385 |
#(#FullSpec |
859 | 386 |
#window: |
797 | 387 |
#(#WindowSpec |
859 | 388 |
#name: 'Commit Buttons Without Channels' |
869 | 389 |
#layout: #(#LayoutFrame 500 0 326 0 799 0 385 0) |
859 | 390 |
#label: 'Commit Buttons Without Channels' |
391 |
#min: #(#Point 100 22) |
|
392 |
#max: #(#Point 1152 900) |
|
869 | 393 |
#bounds: #(#Rectangle 500 326 800 386) |
859 | 394 |
#usePreferredExtent: false |
797 | 395 |
) |
859 | 396 |
#component: |
797 | 397 |
#(#SpecCollection |
859 | 398 |
#collection: |
797 | 399 |
#( |
400 |
#(#ActionButtonSpec |
|
859 | 401 |
#name: 'cancelButton' |
402 |
#layout: #(#LayoutFrame 5 0 0 0 -2 0.5 0 1) |
|
403 |
#activeHelpKey: #commitCancel |
|
404 |
#label: 'Cancel' |
|
927 | 405 |
#translateLabel: true |
859 | 406 |
#tabable: true |
407 |
#model: #cancel |
|
797 | 408 |
) |
409 |
#(#ActionButtonSpec |
|
859 | 410 |
#name: 'okButton' |
411 |
#layout: #(#LayoutFrame 2 0.5 0 0.0 -5 1 0 1.0) |
|
412 |
#activeHelpKey: #commitOK |
|
413 |
#label: 'OK' |
|
927 | 414 |
#translateLabel: true |
859 | 415 |
#tabable: true |
416 |
#model: #accept |
|
797 | 417 |
) |
418 |
) |
|
419 |
) |
|
420 |
) |
|
927 | 421 |
|
422 |
"Modified: / 20.5.1998 / 03:30:09 / cg" |
|
797 | 423 |
! |
424 |
||
425 |
windowSpecForInfoBar |
|
869 | 426 |
"This resource specification was automatically generated |
427 |
by the UIPainter of ST/X." |
|
428 |
||
429 |
"Do not manually edit this!! If it is corrupted, |
|
430 |
the UIPainter may not be able to read the specification." |
|
431 |
||
432 |
" |
|
433 |
UIPainter new openOnClass:ToolApplicationModel andSelector:#windowSpecForInfoBar |
|
434 |
ToolApplicationModel new openInterface:#windowSpecForInfoBar |
|
435 |
" |
|
797 | 436 |
|
437 |
<resource: #canvas> |
|
438 |
||
439 |
^ |
|
859 | 440 |
|
797 | 441 |
#(#FullSpec |
859 | 442 |
#window: |
797 | 443 |
#(#WindowSpec |
859 | 444 |
#name: 'Info Bar' |
869 | 445 |
#layout: #(#LayoutFrame 233 0 218 0 732 0 563 0) |
859 | 446 |
#label: 'Info Bar' |
447 |
#min: #(#Point 400 320) |
|
448 |
#max: #(#Point 1152 900) |
|
869 | 449 |
#bounds: #(#Rectangle 233 218 733 564) |
859 | 450 |
#menu: #menu |
451 |
#usePreferredExtent: false |
|
797 | 452 |
) |
859 | 453 |
#component: |
797 | 454 |
#(#SpecCollection |
859 | 455 |
#collection: |
797 | 456 |
#( |
820 | 457 |
#(#ViewSpec |
859 | 458 |
#name: 'view' |
459 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
460 |
#component: |
|
820 | 461 |
#(#SpecCollection |
859 | 462 |
#collection: |
820 | 463 |
#( |
464 |
#(#LabelSpec |
|
859 | 465 |
#name: 'infoLabel' |
466 |
#layout: #(#LayoutFrame 2 0.0 1 0.0 -1 1.0 -1 1.0) |
|
467 |
#labelChannel: #valueOfInfoLabel |
|
468 |
#level: -1 |
|
469 |
#adjust: #left |
|
869 | 470 |
#resizeForLabel: false |
820 | 471 |
) |
472 |
) |
|
473 |
) |
|
797 | 474 |
) |
475 |
) |
|
476 |
) |
|
477 |
) |
|
478 |
! |
|
479 |
||
480 |
windowSpecForInfoBarWithClock |
|
869 | 481 |
"This resource specification was automatically generated |
482 |
by the UIPainter of ST/X." |
|
483 |
||
484 |
"Do not manually edit this!! If it is corrupted, |
|
485 |
the UIPainter may not be able to read the specification." |
|
486 |
||
487 |
" |
|
488 |
UIPainter new openOnClass:ToolApplicationModel andSelector:#windowSpecForInfoBarWithClock |
|
489 |
ToolApplicationModel new openInterface:#windowSpecForInfoBarWithClock |
|
490 |
" |
|
797 | 491 |
|
492 |
<resource: #canvas> |
|
493 |
||
494 |
^ |
|
859 | 495 |
|
797 | 496 |
#(#FullSpec |
859 | 497 |
#window: |
797 | 498 |
#(#WindowSpec |
859 | 499 |
#name: 'Info Bar' |
872 | 500 |
#layout: #(#LayoutFrame 160 0 423 0 659 0 453 0) |
859 | 501 |
#label: 'Info Bar' |
502 |
#min: #(#Point 400 320) |
|
503 |
#max: #(#Point 1152 900) |
|
872 | 504 |
#bounds: #(#Rectangle 160 423 660 454) |
859 | 505 |
#menu: #menu |
506 |
#usePreferredExtent: false |
|
797 | 507 |
) |
859 | 508 |
#component: |
797 | 509 |
#(#SpecCollection |
859 | 510 |
#collection: |
797 | 511 |
#( |
820 | 512 |
#(#ViewSpec |
859 | 513 |
#name: 'view' |
514 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
515 |
#component: |
|
820 | 516 |
#(#SpecCollection |
859 | 517 |
#collection: |
820 | 518 |
#( |
519 |
#(#LabelSpec |
|
859 | 520 |
#name: 'infoLabel' |
521 |
#layout: #(#LayoutFrame 2 0 1 0.0 -81 1 -1 1.0) |
|
522 |
#labelChannel: #valueOfInfoLabel |
|
523 |
#level: -1 |
|
524 |
#adjust: #left |
|
872 | 525 |
#resizeForLabel: false |
820 | 526 |
) |
527 |
#(#LabelSpec |
|
859 | 528 |
#name: 'timeLabel' |
529 |
#layout: #(#LayoutFrame -79 1 1 0.0 -1 1.0 -1 1.0) |
|
530 |
#labelChannel: #valueOfTimeLabel |
|
531 |
#level: -1 |
|
532 |
#adjust: #right |
|
872 | 533 |
#resizeForLabel: false |
820 | 534 |
) |
535 |
) |
|
536 |
) |
|
797 | 537 |
) |
538 |
) |
|
539 |
) |
|
540 |
) |
|
541 |
! ! |
|
542 |
||
543 |
!ToolApplicationModel class methodsFor:'menu specs'! |
|
544 |
||
753 | 545 |
menuAbout |
869 | 546 |
"This resource specification was automatically generated |
547 |
by the MenuEditor of ST/X." |
|
548 |
||
549 |
"Do not manually edit this!! If it is corrupted, |
|
550 |
the MenuEditor may not be able to read the specification." |
|
551 |
||
552 |
" |
|
553 |
MenuEditor new openOnClass:ToolApplicationModel andSelector:#menuAbout |
|
554 |
(Menu new fromLiteralArrayEncoding:(ToolApplicationModel menuAbout)) startUp |
|
555 |
" |
|
753 | 556 |
|
557 |
<resource: #menu> |
|
558 |
||
559 |
^ |
|
859 | 560 |
|
753 | 561 |
#(#Menu |
562 |
||
563 |
#( |
|
564 |
#(#MenuItem |
|
859 | 565 |
#label: 'About Smalltalk/X...' |
566 |
#translateLabel: true |
|
567 |
#value: #openAbout |
|
568 |
#activeHelpKey: #aboutSTX |
|
753 | 569 |
) |
570 |
#(#MenuItem |
|
859 | 571 |
#label: '-' |
753 | 572 |
) |
573 |
#(#MenuItem |
|
922 | 574 |
#label: 'About this Application...' |
859 | 575 |
#translateLabel: true |
576 |
#value: #openAboutThisApplication |
|
577 |
#activeHelpKey: #aboutThisAppliaction |
|
753 | 578 |
) |
579 |
) nil |
|
580 |
nil |
|
581 |
) |
|
922 | 582 |
|
583 |
"Modified: / 19.5.1998 / 21:44:09 / cg" |
|
753 | 584 |
! |
585 |
||
869 | 586 |
menuFont |
587 |
"This resource specification was automatically generated |
|
588 |
by the MenuEditor of ST/X." |
|
589 |
||
590 |
"Do not manually edit this!! If it is corrupted, |
|
591 |
the MenuEditor may not be able to read the specification." |
|
592 |
||
593 |
" |
|
594 |
MenuEditor new openOnClass:ToolApplicationModel andSelector:#menuFont |
|
595 |
(Menu new fromLiteralArrayEncoding:(ToolApplicationModel menuFont)) startUp |
|
596 |
" |
|
597 |
||
598 |
<resource: #menu> |
|
599 |
||
600 |
^ |
|
601 |
||
602 |
#(#Menu |
|
603 |
||
604 |
#( |
|
605 |
#(#MenuItem |
|
872 | 606 |
#label: 'Label...' |
869 | 607 |
#value: #chooseFont: |
608 |
#argument: 'Label Font' |
|
609 |
) |
|
610 |
#(#MenuItem |
|
872 | 611 |
#label: 'Button...' |
869 | 612 |
#value: #chooseFont: |
613 |
#argument: 'Button Font' |
|
614 |
) |
|
615 |
#(#MenuItem |
|
872 | 616 |
#label: 'Edit...' |
869 | 617 |
#value: #chooseFont: |
618 |
#argument: 'Edit Font' |
|
619 |
) |
|
620 |
#(#MenuItem |
|
872 | 621 |
#label: 'List...' |
869 | 622 |
#value: #chooseFont: |
623 |
#argument: 'List Font' |
|
624 |
) |
|
625 |
#(#MenuItem |
|
872 | 626 |
#label: 'Tree List...' |
869 | 627 |
#value: #chooseFont: |
628 |
#argument: 'Tree List Font' |
|
629 |
) |
|
630 |
#(#MenuItem |
|
872 | 631 |
#label: 'Note Book...' |
632 |
#value: #chooseFont: |
|
633 |
#argument: 'Note Book Font' |
|
634 |
) |
|
635 |
#(#MenuItem |
|
636 |
#label: 'Framed Box...' |
|
637 |
#value: #chooseFont: |
|
638 |
#argument: 'Framed Box Font' |
|
639 |
) |
|
640 |
#(#MenuItem |
|
869 | 641 |
#label: '-' |
642 |
) |
|
643 |
#(#MenuItem |
|
872 | 644 |
#label: 'Reset' |
869 | 645 |
#value: #resetFonts |
646 |
) |
|
647 |
) nil |
|
648 |
nil |
|
649 |
) |
|
650 |
! |
|
651 |
||
753 | 652 |
menuHelp |
869 | 653 |
"This resource specification was automatically generated |
654 |
by the MenuEditor of ST/X." |
|
655 |
||
656 |
"Do not manually edit this!! If it is corrupted, |
|
657 |
the MenuEditor may not be able to read the specification." |
|
658 |
||
659 |
" |
|
660 |
MenuEditor new openOnClass:ToolApplicationModel andSelector:#menuHelp |
|
661 |
(Menu new fromLiteralArrayEncoding:(ToolApplicationModel menuHelp)) startUp |
|
662 |
" |
|
753 | 663 |
|
664 |
<resource: #menu> |
|
665 |
||
666 |
^ |
|
859 | 667 |
|
753 | 668 |
#(#Menu |
669 |
||
670 |
#( |
|
671 |
#(#MenuItem |
|
876 | 672 |
#label: 'Documentation' |
859 | 673 |
#translateLabel: true |
674 |
#value: #openDocumentation |
|
675 |
#activeHelpKey: #helpTutorial |
|
907 | 676 |
#enabled: #valueOfHavingDocumentation |
753 | 677 |
) |
678 |
#(#MenuItem |
|
859 | 679 |
#label: '-' |
753 | 680 |
) |
681 |
#(#MenuItem |
|
859 | 682 |
#label: 'Show Help Texts' |
683 |
#translateLabel: true |
|
684 |
#activeHelpKey: #helpShowHelp |
|
685 |
#indication: #showHelp: |
|
753 | 686 |
) |
687 |
) nil |
|
688 |
nil |
|
689 |
) |
|
690 |
! ! |
|
691 |
||
907 | 692 |
!ToolApplicationModel class methodsFor:'queries'! |
693 |
||
987 | 694 |
getAllImageSelectorsFrom: aClass |
695 |
"returns all image selectors implementing an image spec in class aClass" |
|
696 |
||
697 |
|iconClass| |
|
698 |
||
699 |
aClass isSymbol |
|
700 |
ifTrue: [iconClass := Smalltalk at: aClass] |
|
701 |
ifFalse: [iconClass := aClass]. |
|
702 |
||
703 |
^((iconClass class methodDictionary values select: [:m| m category = 'image specs']) |
|
704 |
collect: [:m| m selector]) asSortedCollection asOrderedCollection |
|
705 |
||
706 |
! |
|
707 |
||
907 | 708 |
isVisualStartable |
709 |
"returns whether this application class can be started via #open" |
|
710 |
||
711 |
self == ToolApplicationModel ifTrue:[^false]. |
|
712 |
^super isVisualStartable |
|
713 |
||
714 |
! ! |
|
715 |
||
782 | 716 |
!ToolApplicationModel class methodsFor:'startup / release'! |
753 | 717 |
|
782 | 718 |
preSnapshot |
907 | 719 |
"removes the clipboard before snap shoting" |
753 | 720 |
|
782 | 721 |
clipboard := nil |
753 | 722 |
! |
723 |
||
782 | 724 |
uninitialize |
907 | 725 |
"resets the class instance variables" |
760 | 726 |
|
869 | 727 |
settings := showHelp := history := clipboard := nil |
753 | 728 |
! ! |
729 |
||
782 | 730 |
!ToolApplicationModel methodsFor:'aspects'! |
731 |
||
822 | 732 |
valueOfCanCopy |
907 | 733 |
"returns whether can copy as value holder" |
822 | 734 |
|
936 | 735 |
^ builder booleanValueAspectFor:#valueOfCanCopy |
822 | 736 |
|
936 | 737 |
"Modified: / 21.5.1998 / 03:39:05 / cg" |
822 | 738 |
! |
739 |
||
740 |
valueOfCanCut |
|
907 | 741 |
"returns whether can paste as value holder" |
822 | 742 |
|
936 | 743 |
^ builder booleanValueAspectFor:#valueOfCanCut |
822 | 744 |
|
936 | 745 |
"Modified: / 21.5.1998 / 03:39:13 / cg" |
822 | 746 |
! |
747 |
||
748 |
valueOfCanPaste |
|
907 | 749 |
"returns whether can paste as value holder" |
822 | 750 |
|
936 | 751 |
^ builder booleanValueAspectFor:#valueOfCanPaste |
822 | 752 |
|
936 | 753 |
"Modified: / 21.5.1998 / 03:39:22 / cg" |
822 | 754 |
! |
755 |
||
756 |
valueOfCanUndo |
|
907 | 757 |
"returns whether can undo as value holder" |
822 | 758 |
|
936 | 759 |
^ builder booleanValueAspectFor:#valueOfCanUndo |
822 | 760 |
|
936 | 761 |
"Modified: / 21.5.1998 / 03:39:31 / cg" |
822 | 762 |
! |
763 |
||
782 | 764 |
valueOfEnablingCommitButtons |
907 | 765 |
"returns the enabling of the commit of this tool as value holder" |
753 | 766 |
|
936 | 767 |
^ builder booleanValueAspectFor:#valueOfEnablingCommitButtons |
753 | 768 |
|
936 | 769 |
"Modified: / 21.5.1998 / 03:39:49 / cg" |
782 | 770 |
! |
771 |
||
858 | 772 |
valueOfHavingDocumentation |
1004 | 773 |
"returns the enabling of having documentation for this tool as value holder" |
803 | 774 |
|
1004 | 775 |
^ (builder booleanValueAspectFor:#valueOfEnablingCommitButtons) value: (self class implements: #openDocumentation) |
803 | 776 |
! |
777 |
||
782 | 778 |
valueOfInfoLabel |
907 | 779 |
"returns the info label as value holder" |
782 | 780 |
|
936 | 781 |
^ builder nilValueAspectFor:#valueOfInfoLabel |
753 | 782 |
|
936 | 783 |
"Modified: / 21.5.1998 / 03:40:34 / cg" |
782 | 784 |
! |
785 |
||
786 |
valueOfTimeLabel |
|
907 | 787 |
"returns the time label as value holder" |
753 | 788 |
|
936 | 789 |
^ builder nilValueAspectFor:#valueOfTimeLabel |
753 | 790 |
|
936 | 791 |
"Modified: / 21.5.1998 / 03:40:42 / cg" |
753 | 792 |
! ! |
793 |
||
782 | 794 |
!ToolApplicationModel methodsFor:'clipboard'! |
753 | 795 |
|
838 | 796 |
clipboard |
907 | 797 |
"returns the clipboard" |
838 | 798 |
|
799 |
^self class clipboard |
|
800 |
! |
|
801 |
||
782 | 802 |
clipboard: anEditObject |
907 | 803 |
"sets the clipboard and the value holder for can pasting" |
753 | 804 |
|
782 | 805 |
self class clipboard: anEditObject. |
753 | 806 |
|
869 | 807 |
self valueOfCanPaste value: anEditObject notNil |
782 | 808 |
! ! |
809 |
||
1006
786de97d72f9
allow redefinition of the about-boxes image.
Claus Gittinger <cg@exept.de>
parents:
1004
diff
changeset
|
810 |
!ToolApplicationModel methodsFor:'defaults'! |
786de97d72f9
allow redefinition of the about-boxes image.
Claus Gittinger <cg@exept.de>
parents:
1004
diff
changeset
|
811 |
|
786de97d72f9
allow redefinition of the about-boxes image.
Claus Gittinger <cg@exept.de>
parents:
1004
diff
changeset
|
812 |
aboutImage |
786de97d72f9
allow redefinition of the about-boxes image.
Claus Gittinger <cg@exept.de>
parents:
1004
diff
changeset
|
813 |
"the image to be displayed in my about-box; |
786de97d72f9
allow redefinition of the about-boxes image.
Claus Gittinger <cg@exept.de>
parents:
1004
diff
changeset
|
814 |
If nil is returned, thhe ST/X default image is used." |
786de97d72f9
allow redefinition of the about-boxes image.
Claus Gittinger <cg@exept.de>
parents:
1004
diff
changeset
|
815 |
|
786de97d72f9
allow redefinition of the about-boxes image.
Claus Gittinger <cg@exept.de>
parents:
1004
diff
changeset
|
816 |
^ nil |
786de97d72f9
allow redefinition of the about-boxes image.
Claus Gittinger <cg@exept.de>
parents:
1004
diff
changeset
|
817 |
|
786de97d72f9
allow redefinition of the about-boxes image.
Claus Gittinger <cg@exept.de>
parents:
1004
diff
changeset
|
818 |
"Created: / 25.7.1998 / 20:33:50 / cg" |
786de97d72f9
allow redefinition of the about-boxes image.
Claus Gittinger <cg@exept.de>
parents:
1004
diff
changeset
|
819 |
! ! |
786de97d72f9
allow redefinition of the about-boxes image.
Claus Gittinger <cg@exept.de>
parents:
1004
diff
changeset
|
820 |
|
782 | 821 |
!ToolApplicationModel methodsFor:'help'! |
753 | 822 |
|
762 | 823 |
defaultInfoLabel |
907 | 824 |
"returns the default info label; here an empty string" |
762 | 825 |
|
826 |
^'' |
|
827 |
! |
|
828 |
||
984 | 829 |
doShowHelp:aHelpText |
830 |
"displays aHelpText in the info label or if present detours it to its masterApplication" |
|
831 |
||
832 |
aHelpText isNil |
|
833 |
ifTrue: [self updateInfoLabel] |
|
834 |
ifFalse: [self valueOfInfoLabel value: (aHelpText asString printString readStream through: $.)]. |
|
835 |
||
836 |
"Created: / 20.6.1998 / 16:37:23 / cg" |
|
837 |
! |
|
838 |
||
753 | 839 |
openAbout |
907 | 840 |
"opens an about box" |
753 | 841 |
|
842 |
|box| |
|
843 |
||
844 |
box := AboutBox new. |
|
845 |
box autoHideAfter:10 with:[]. |
|
846 |
box showAtCenter |
|
847 |
||
1006
786de97d72f9
allow redefinition of the about-boxes image.
Claus Gittinger <cg@exept.de>
parents:
1004
diff
changeset
|
848 |
"Modified: / 25.7.1998 / 20:36:46 / cg" |
753 | 849 |
! |
850 |
||
851 |
openAboutThisApplication |
|
907 | 852 |
"opens an about this application box" |
753 | 853 |
|
1006
786de97d72f9
allow redefinition of the about-boxes image.
Claus Gittinger <cg@exept.de>
parents:
1004
diff
changeset
|
854 |
|rev box myClass clsRev image| |
936 | 855 |
|
753 | 856 |
rev := ''. |
936 | 857 |
myClass := self class. |
858 |
||
859 |
(clsRev := myClass revision) notNil ifTrue: [rev := ' (rev: ', clsRev printString, ')']. |
|
753 | 860 |
box := AboutBox title: |
800 | 861 |
'\The application\\' withCRs |
936 | 862 |
, myClass name asBoldText, rev |
850 | 863 |
, '\\has been designed and implemented by: \' withCRs |
864 |
, ((self class authorLinesForAboutBox collect:[:l | '- ' , l]) asStringWith:$\) withCRs |
|
800 | 865 |
, '\\' withCRs. |
753 | 866 |
|
1006
786de97d72f9
allow redefinition of the about-boxes image.
Claus Gittinger <cg@exept.de>
parents:
1004
diff
changeset
|
867 |
image := self aboutImage. |
786de97d72f9
allow redefinition of the about-boxes image.
Claus Gittinger <cg@exept.de>
parents:
1004
diff
changeset
|
868 |
image notNil ifTrue:[ |
786de97d72f9
allow redefinition of the about-boxes image.
Claus Gittinger <cg@exept.de>
parents:
1004
diff
changeset
|
869 |
box image:image |
786de97d72f9
allow redefinition of the about-boxes image.
Claus Gittinger <cg@exept.de>
parents:
1004
diff
changeset
|
870 |
]. |
786de97d72f9
allow redefinition of the about-boxes image.
Claus Gittinger <cg@exept.de>
parents:
1004
diff
changeset
|
871 |
box label:'About This Application'. |
786de97d72f9
allow redefinition of the about-boxes image.
Claus Gittinger <cg@exept.de>
parents:
1004
diff
changeset
|
872 |
box autoHideAfter:10 with:[]. |
786de97d72f9
allow redefinition of the about-boxes image.
Claus Gittinger <cg@exept.de>
parents:
1004
diff
changeset
|
873 |
box showAtCenter. |
936 | 874 |
|
1006
786de97d72f9
allow redefinition of the about-boxes image.
Claus Gittinger <cg@exept.de>
parents:
1004
diff
changeset
|
875 |
"Modified: / 25.7.1998 / 20:37:18 / cg" |
753 | 876 |
! |
877 |
||
858 | 878 |
openHTMLDocument: aHTMLFilename |
907 | 879 |
"opens a HTML browser on aHTMLFilename" |
858 | 880 |
|
881 |
HTMLDocumentView openFullOnDocumentationFile: aHTMLFilename |
|
882 |
! |
|
883 |
||
782 | 884 |
showHelp |
907 | 885 |
"returns whether showing help is turned on/off" |
782 | 886 |
|
783 | 887 |
|currentActiveHelp| |
858 | 888 |
|
783 | 889 |
currentActiveHelp := ActiveHelp currentHelpListener. |
890 |
||
891 |
^self class showHelp |
|
858 | 892 |
and: [currentActiveHelp notNil and: [masterApplication notNil |
893 |
ifFalse: [currentActiveHelp interestedIn: self window] |
|
894 |
ifTrue: [currentActiveHelp interestedIn: masterApplication window]]] |
|
782 | 895 |
! |
896 |
||
897 |
showHelp: aValue |
|
907 | 898 |
"toggles showing help" |
782 | 899 |
|
900 |
(self class showHelp: aValue) |
|
901 |
ifTrue: [ActiveHelp startFor: self] |
|
822 | 902 |
ifFalse: [ActiveHelp stopFor: self. self updateInfoLabel] |
782 | 903 |
! |
904 |
||
762 | 905 |
showHelp:aHelpText for:view |
984 | 906 |
"displays aHelpText in the info label or if present detours it to its masterApplication. |
907 |
Here, an event is pushed for myself to synchronize the helpDisplay |
|
908 |
with event handling." |
|
909 |
||
910 |
|wg mySensor| |
|
762 | 911 |
|
782 | 912 |
self showHelp ifFalse: [^true]. |
876 | 913 |
masterApplication notNil ifTrue: [masterApplication showHelp: aHelpText for:view]. |
984 | 914 |
|
915 |
"/ OLD: show it right here ... |
|
916 |
"/ aHelpText isNil |
|
917 |
"/ ifTrue: [self updateInfoLabel] |
|
918 |
"/ ifFalse: [self valueOfInfoLabel value: (aHelpText asString printString readStream through: $.)]. |
|
919 |
"/ the nil-tests should not be req'd - but thats a last-minute |
|
920 |
"/ change and I dont want to breaks the delivery ... |
|
921 |
||
922 |
"/ NEW: push it into the event queue, to have it displayed |
|
923 |
"/ syncronously with other events. |
|
924 |
"/ (also any errors are reported as occurring in my context; |
|
925 |
"/ instead of occurring in the activeHelp context). |
|
926 |
||
927 |
(wg := self windowGroup) notNil ifTrue:[ |
|
928 |
mySensor := wg sensor. |
|
929 |
mySensor notNil ifTrue:[ |
|
930 |
mySensor flushEventsFor:self withType:#doShowHelp:. |
|
931 |
mySensor pushUserEvent:#doShowHelp: for:self withArguments:(Array with:aHelpText). |
|
932 |
]. |
|
933 |
]. |
|
934 |
||
876 | 935 |
^true |
984 | 936 |
|
937 |
"Modified: / 20.6.1998 / 16:47:37 / cg" |
|
822 | 938 |
! |
939 |
||
940 |
updateInfoLabel |
|
907 | 941 |
"updates the info label at the bottom" |
822 | 942 |
|
943 |
self valueOfInfoLabel value: self defaultInfoLabel |
|
762 | 944 |
! ! |
945 |
||
753 | 946 |
!ToolApplicationModel methodsFor:'history'! |
947 |
||
948 |
addToHistory: aHistoryEntry |
|
907 | 949 |
"adds aHistoryEntry (format: loadMessage -> evalString) at the top of the history, |
950 |
and checks for maximum size of the history" |
|
753 | 951 |
|
782 | 952 |
aHistoryEntry key size = 0 ifTrue: [^nil]. |
753 | 953 |
self history remove: (self history detect: [:histEntry| histEntry key = aHistoryEntry key] ifNone: nil) ifAbsent: nil. |
954 |
self history addFirst: aHistoryEntry. |
|
955 |
[self history size > self class historyMaxSize] whileTrue: [self history removeLast] |
|
956 |
! |
|
957 |
||
958 |
emptyHistory |
|
907 | 959 |
"removes all history entries" |
753 | 960 |
|
961 |
^self history removeAll |
|
962 |
! |
|
963 |
||
964 |
history |
|
907 | 965 |
"returns the history from tool class" |
753 | 966 |
|
967 |
^self class getHistory |
|
968 |
! |
|
969 |
||
844 | 970 |
historyEntries |
907 | 971 |
"returns the history entries, i.e. the evaluatable values containing the information" |
844 | 972 |
|
973 |
^self history collect: [:asso| asso key] |
|
974 |
! |
|
975 |
||
753 | 976 |
menuHistory |
907 | 977 |
"returns a history submenu" |
753 | 978 |
|
893 | 979 |
|menu| |
920
6b72e4ce4406
must find gui resources (xlations in in history menu)
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
980 |
|
753 | 981 |
menu := Menu new receiver: self. |
982 |
(self history collect: [:histEntry| histEntry value]) asSet asOrderedCollection do: |
|
983 |
[:historyEntryType| |
|
893 | 984 |
menu addItemGroup: ((self history select: [:histEntry| histEntry value = historyEntryType]) collect: [:histEntry| MenuItem new label: histEntry key printString; value: histEntry value; argument: histEntry key; activeHelpKey: #historyMenuItem]). |
753 | 985 |
]. |
986 |
||
920
6b72e4ce4406
must find gui resources (xlations in in history menu)
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
987 |
menu addItem: (MenuItem new |
6b72e4ce4406
must find gui resources (xlations in in history menu)
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
988 |
label: 'Empty History'; |
6b72e4ce4406
must find gui resources (xlations in in history menu)
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
989 |
value: #emptyHistory; |
6b72e4ce4406
must find gui resources (xlations in in history menu)
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
990 |
activeHelpKey: #historyEmptyMenu; |
6b72e4ce4406
must find gui resources (xlations in in history menu)
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
991 |
translateLabel:true). |
6b72e4ce4406
must find gui resources (xlations in in history menu)
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
992 |
|
6b72e4ce4406
must find gui resources (xlations in in history menu)
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
993 |
menu findGuiResourcesIn:self. |
753 | 994 |
^menu |
920
6b72e4ce4406
must find gui resources (xlations in in history menu)
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
995 |
|
6b72e4ce4406
must find gui resources (xlations in in history menu)
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
996 |
"Modified: / 19.5.1998 / 19:17:34 / cg" |
753 | 997 |
! |
998 |
||
999 |
removeFromHistory: aHistoryEntry |
|
907 | 1000 |
"removes aHistoryEntry from the history" |
753 | 1001 |
|
1002 |
self history remove: (self history detect: [:histEntry| histEntry key = aHistoryEntry key] ifNone: nil) ifAbsent: nil. |
|
1003 |
[self history size > self class historyMaxSize] whileTrue: [self history removeLast] |
|
1004 |
! ! |
|
1005 |
||
982
807f440e0df7
bw. compatibility - needs builder early.
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
1006 |
!ToolApplicationModel methodsFor:'initialization'! |
807f440e0df7
bw. compatibility - needs builder early.
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
1007 |
|
807f440e0df7
bw. compatibility - needs builder early.
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
1008 |
initialize |
807f440e0df7
bw. compatibility - needs builder early.
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
1009 |
super initialize. |
807f440e0df7
bw. compatibility - needs builder early.
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
1010 |
self createBuilder |
807f440e0df7
bw. compatibility - needs builder early.
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
1011 |
|
807f440e0df7
bw. compatibility - needs builder early.
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
1012 |
"Created: / 20.6.1998 / 14:51:29 / cg" |
807f440e0df7
bw. compatibility - needs builder early.
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
1013 |
! ! |
807f440e0df7
bw. compatibility - needs builder early.
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
1014 |
|
782 | 1015 |
!ToolApplicationModel methodsFor:'queries'! |
1016 |
||
876 | 1017 |
allToolInstances |
907 | 1018 |
"returns all instances of this tool class" |
876 | 1019 |
|
1020 |
^self class settings at: #Instances ifAbsent: [^#()] |
|
1021 |
! |
|
1022 |
||
782 | 1023 |
preferredExtent |
1024 |
"preferred extent of my window; top/main menu and top toolbar (named by 'menuToolbarView') |
|
1025 |
will be considered" |
|
1026 |
||
1027 |
|window menu menuToolbarView preferredExtentOfWindow| |
|
1028 |
||
1029 |
window := self builder window. |
|
1030 |
menu := window subViews first. |
|
1031 |
menuToolbarView := builder componentAt: #menuToolbarView. |
|
1032 |
||
1033 |
preferredExtentOfWindow := window extent. |
|
1034 |
menu class = MenuPanel ifTrue: [preferredExtentOfWindow := preferredExtentOfWindow max: menu preferredExtent]. |
|
1035 |
menuToolbarView notNil ifTrue: [preferredExtentOfWindow := preferredExtentOfWindow max: menuToolbarView preferredExtent]. |
|
1036 |
||
1037 |
^window minExtent max: (preferredExtentOfWindow min: window maxExtent) |
|
1038 |
! ! |
|
1039 |
||
869 | 1040 |
!ToolApplicationModel methodsFor:'settings'! |
1041 |
||
872 | 1042 |
allFontViewsDo: aBlock |
892 | 1043 |
"evaluates aBlock for all views with fonts" |
872 | 1044 |
|
1045 |
|fontViews| |
|
1046 |
||
1047 |
fontViews := OrderedCollection new. |
|
1048 |
||
1049 |
self builder windowGroup views do: [:v| v class = MenuPanel ifTrue: [fontViews add: v]]. |
|
1050 |
||
1051 |
builder namedComponents do: |
|
1052 |
[:aView| |
|
1053 |
aView allSubViewsDo: |
|
1054 |
[:v| |
|
1055 |
v font notNil ifTrue: [fontViews add: v] |
|
1056 |
] |
|
1057 |
]. |
|
1058 |
fontViews do: aBlock |
|
1059 |
! |
|
1060 |
||
869 | 1061 |
chooseFont: viewFont |
892 | 1062 |
"chooses a font for viewFont and puts it into the settings dictionary; |
869 | 1063 |
finally update all my views" |
1064 |
||
1065 |
|defaultFont font| |
|
1066 |
||
872 | 1067 |
viewFont = 'Label Font' ifTrue: [defaultFont := Label defaultFont]. |
1068 |
viewFont = 'Button Font' ifTrue: [defaultFont := Button defaultFont]. |
|
1069 |
viewFont = 'Edit Font' ifTrue: [defaultFont := TextView defaultFont]. |
|
1070 |
viewFont = 'List Font' ifTrue: [defaultFont := ListView defaultFont]. |
|
1071 |
viewFont = 'Tree List Font' ifTrue: [defaultFont := SelectionInTreeView defaultFont]. |
|
892 | 1072 |
viewFont = 'Note Book Font' ifTrue: [defaultFont := NoteBookView defaultFont]. |
872 | 1073 |
viewFont = 'Framed Box Font' ifTrue: [defaultFont := FramedBox defaultFont]. |
869 | 1074 |
|
1075 |
(font := FontPanel |
|
1076 |
fontFromUserInitial: (self class settings at: viewFont asSymbol ifAbsent: nil) ? defaultFont |
|
1077 |
title: 'Choose ', viewFont) notNil |
|
1078 |
ifTrue: |
|
872 | 1079 |
[ |
869 | 1080 |
self class settings at: viewFont asSymbol put: (font on: device). |
1081 |
self updateFonts |
|
1082 |
]. |
|
1083 |
^font |
|
1084 |
! |
|
1085 |
||
1086 |
resetFonts |
|
892 | 1087 |
"sets the fonts in the settings to nil and resets the views to its default font" |
869 | 1088 |
|
872 | 1089 |
(self class settings) |
892 | 1090 |
at: #'Label Font' put: Label defaultFont; |
1091 |
at: #'Button Font' put: Button defaultFont; |
|
1092 |
at: #'Edit Font' put: TextView defaultFont; |
|
1093 |
at: #'List Font' put: ListView defaultFont; |
|
1094 |
at: #'Tree List Font' put: SelectionInTreeView defaultFont; |
|
1095 |
at: #'Note Book Font' put: NoteBookView defaultFont; |
|
1096 |
at: #'Framed Box Font' put: FramedBox defaultFont. |
|
1097 |
||
1098 |
self updateFonts. |
|
1099 |
||
1100 |
(self class settings) |
|
872 | 1101 |
removeKey: #'Label Font' ifAbsent: nil; |
1102 |
removeKey: #'Button Font' ifAbsent: nil; |
|
1103 |
removeKey: #'Edit Font' ifAbsent: nil; |
|
1104 |
removeKey: #'List Font' ifAbsent: nil; |
|
1105 |
removeKey: #'Tree List Font' ifAbsent: nil; |
|
1106 |
removeKey: #'Note Book Font' ifAbsent: nil; |
|
1107 |
removeKey: #'Framed Box Font' ifAbsent: nil. |
|
869 | 1108 |
|
1109 |
! |
|
1110 |
||
1111 |
updateFonts |
|
892 | 1112 |
"takes defined fonts from the settings and set them to the corresponding views" |
869 | 1113 |
|
892 | 1114 |
|settings labelFont buttonFont editFont listFont treeListFont noteBookFont framedBoxFont updateFontsBlock| |
871 | 1115 |
|
1116 |
settings := self class settings. |
|
869 | 1117 |
|
872 | 1118 |
labelFont := settings at: #'Label Font' ifAbsent: nil. |
1119 |
buttonFont := settings at: #'Button Font' ifAbsent: nil. |
|
1120 |
editFont := settings at: #'Edit Font' ifAbsent: nil. |
|
1121 |
listFont := settings at: #'List Font' ifAbsent: nil. |
|
1122 |
treeListFont := settings at: #'Tree List Font' ifAbsent: nil. |
|
1123 |
noteBookFont := settings at: #'Note Book Font' ifAbsent: nil. |
|
1124 |
framedBoxFont := settings at: #'Framed Box Font' ifAbsent: nil. |
|
869 | 1125 |
|
872 | 1126 |
updateFontsBlock := |
1127 |
[:v| |
|
1128 |
(labelFont notNil and: [v font ~= labelFont and: [(v class == Label) or: [v isKindOf: Toggle]]]) |
|
1129 |
ifTrue: [v font: labelFont; fixSize; sizeChanged:nil; invalidate]. |
|
1130 |
(buttonFont notNil and: [v font ~= buttonFont and: [v class == Button or: [v class == PopUpList]]]) |
|
876 | 1131 |
ifTrue: [v label isString ifTrue: [|e|e := v extent. v font: buttonFont; extent: e; invalidate]]. |
872 | 1132 |
(editFont notNil and: [v font ~= editFont and: [v isKindOf: TextView]]) |
1133 |
ifTrue: [v font: editFont; invalidate]. |
|
1134 |
(listFont notNil and: [v font ~= listFont and: [v class = SelectionInListView or: [v class = DataSetView]]]) |
|
1135 |
ifTrue: [v font: listFont. v invalidate]. |
|
1136 |
(treeListFont notNil and: [v font ~= treeListFont and: [v isKindOf: SelectionInTreeView]]) |
|
1137 |
ifTrue: [v font: treeListFont; invalidate]. |
|
1138 |
(noteBookFont notNil and: [v font ~= noteBookFont and: [v class == NoteBookView]]) |
|
1139 |
ifTrue: [v font: noteBookFont; invalidate]. |
|
1140 |
(framedBoxFont notNil and: [v font ~= framedBoxFont and: [v class == FramedBox]]) |
|
1141 |
ifTrue: [v font: framedBoxFont; invalidate] |
|
1142 |
]. |
|
1143 |
||
1144 |
self allFontViewsDo: [:v| updateFontsBlock value: v] |
|
1145 |
||
869 | 1146 |
! ! |
1147 |
||
753 | 1148 |
!ToolApplicationModel methodsFor:'startup / release'! |
1149 |
||
1150 |
close |
|
907 | 1151 |
"uninitializes and closes this tool" |
753 | 1152 |
|
756 | 1153 |
self uninitialize. |
1154 |
||
753 | 1155 |
super close |
1156 |
! |
|
1157 |
||
1158 |
closeRequest |
|
907 | 1159 |
"uninitializes this tool before requesting close" |
753 | 1160 |
|
756 | 1161 |
self uninitialize. |
1162 |
||
753 | 1163 |
super closeRequest |
1164 |
! |
|
1165 |
||
936 | 1166 |
postBuildWith:aBuilder |
1167 |
"sets the preferred extent and the label of the tool window before opening that" |
|
1168 |
||
971
a9d2fc9ebec9
handle the case of being postOpened as a subCanvas
Claus Gittinger <cg@exept.de>
parents:
936
diff
changeset
|
1169 |
|win| |
a9d2fc9ebec9
handle the case of being postOpened as a subCanvas
Claus Gittinger <cg@exept.de>
parents:
936
diff
changeset
|
1170 |
|
936 | 1171 |
super postBuildWith:aBuilder. |
1172 |
||
971
a9d2fc9ebec9
handle the case of being postOpened as a subCanvas
Claus Gittinger <cg@exept.de>
parents:
936
diff
changeset
|
1173 |
(win := aBuilder window) isTopView ifTrue:[ |
a9d2fc9ebec9
handle the case of being postOpened as a subCanvas
Claus Gittinger <cg@exept.de>
parents:
936
diff
changeset
|
1174 |
win |
a9d2fc9ebec9
handle the case of being postOpened as a subCanvas
Claus Gittinger <cg@exept.de>
parents:
936
diff
changeset
|
1175 |
extent: self preferredExtent; |
a9d2fc9ebec9
handle the case of being postOpened as a subCanvas
Claus Gittinger <cg@exept.de>
parents:
936
diff
changeset
|
1176 |
label: self class label. |
a9d2fc9ebec9
handle the case of being postOpened as a subCanvas
Claus Gittinger <cg@exept.de>
parents:
936
diff
changeset
|
1177 |
]. |
936 | 1178 |
|
1179 |
"Created: / 21.5.1998 / 02:49:09 / cg" |
|
971
a9d2fc9ebec9
handle the case of being postOpened as a subCanvas
Claus Gittinger <cg@exept.de>
parents:
936
diff
changeset
|
1180 |
"Modified: / 18.6.1998 / 20:16:25 / cg" |
936 | 1181 |
! |
1182 |
||
790 | 1183 |
postOpenWith:aBuilder |
907 | 1184 |
"starts the active help for this tool (if turned on in the settings) |
1185 |
and updates the info label and the fonts (from the settings)" |
|
790 | 1186 |
|
1187 |
super postOpenWith:aBuilder. |
|
1188 |
||
791 | 1189 |
self class showHelp ifTrue: [ActiveHelp startFor: self]. |
822 | 1190 |
self updateInfoLabel. |
876 | 1191 |
self updateFonts. |
1192 |
||
790 | 1193 |
! |
1194 |
||
853 | 1195 |
startClockOnTimedBlock: aBlock |
907 | 1196 |
"sets and starts the time block" |
853 | 1197 |
|
1198 |
timeBlock := aBlock. |
|
1199 |
aBlock value. |
|
1200 |
||
1201 |
! |
|
1202 |
||
756 | 1203 |
uninitialize |
907 | 1204 |
"stops the active help this tool and (if defined) removes the time block" |
756 | 1205 |
|
782 | 1206 |
self showHelp ifTrue: [ActiveHelp stopFor: self]. |
876 | 1207 |
timeBlock notNil ifTrue: [Processor removeTimedBlock:timeBlock. timeBlock := nil]. |
1208 |
||
753 | 1209 |
! ! |
1210 |
||
1211 |
!ToolApplicationModel class methodsFor:'documentation'! |
|
1212 |
||
1213 |
version |
|
1006
786de97d72f9
allow redefinition of the about-boxes image.
Claus Gittinger <cg@exept.de>
parents:
1004
diff
changeset
|
1214 |
^ '$Header: /cvs/stx/stx/libview2/ToolApplicationModel.st,v 1.65 1998-07-27 07:58:47 cg Exp $' |
753 | 1215 |
! ! |