129
|
1 |
"{ Package: 'stx:goodies/monticello' }"
|
|
2 |
|
|
3 |
Object subclass:#MCTool
|
|
4 |
instanceVariableNames:'morph label modal modalValue'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
692
|
7 |
category:'SCM-Monticello-UI'
|
129
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!MCTool methodsFor:'morphic ui'!
|
|
12 |
|
|
13 |
answer: anObject
|
|
14 |
modalValue _ anObject.
|
|
15 |
self close.
|
|
16 |
!
|
|
17 |
|
|
18 |
arrowKey: aCharacter from: aPluggableListMorph
|
|
19 |
"backstop"
|
|
20 |
!
|
|
21 |
|
|
22 |
buildWindow
|
|
23 |
| window |
|
|
24 |
window _ SystemWindow labelled: self label.
|
|
25 |
window model: self.
|
|
26 |
self widgetSpecs do:
|
|
27 |
[:pair | |send fractions offsets|
|
|
28 |
send _ pair first.
|
|
29 |
fractions _ pair at: 2 ifAbsent: [#(0 0 1 1)].
|
|
30 |
offsets _ pair at: 3 ifAbsent: [#(0 0 0 0)].
|
|
31 |
window
|
|
32 |
addMorph: (self perform: send first withArguments: send allButFirst )
|
|
33 |
fullFrame:
|
|
34 |
(LayoutFrame
|
|
35 |
fractions:
|
|
36 |
((fractions first)@(fractions second) corner:
|
|
37 |
(fractions third)@(fractions fourth))
|
|
38 |
offsets:
|
|
39 |
((offsets first)@(offsets second) corner:
|
|
40 |
(offsets third)@(offsets fourth)))].
|
|
41 |
^ window
|
|
42 |
!
|
|
43 |
|
|
44 |
buildWith: builder
|
|
45 |
| windowBuilder |
|
|
46 |
|
|
47 |
windowBuilder _ MCToolWindowBuilder builder: builder tool: self.
|
|
48 |
self widgetSpecs do:
|
|
49 |
[:spec | | send fractions offsets origin corner |
|
|
50 |
send _ spec first.
|
|
51 |
fractions _ spec at: 2 ifAbsent: [#(0 0 1 1)].
|
|
52 |
offsets _ spec at: 3 ifAbsent: [#(0 0 0 0)].
|
|
53 |
origin _ (offsets first @ offsets second)
|
|
54 |
/ self defaultExtent asFloatPoint
|
|
55 |
+ (fractions first @ fractions second).
|
|
56 |
corner _ (offsets third @ offsets fourth)
|
|
57 |
/ self defaultExtent asFloatPoint
|
|
58 |
+ (fractions third @ fractions fourth).
|
|
59 |
windowBuilder frame: (origin corner: corner).
|
|
60 |
windowBuilder perform: send first withArguments: send allButFirst].
|
|
61 |
|
|
62 |
^ windowBuilder build
|
|
63 |
!
|
|
64 |
|
|
65 |
buttonEnabled
|
|
66 |
^ true
|
|
67 |
!
|
|
68 |
|
|
69 |
buttonRow
|
|
70 |
^ self buttonRow: self buttonSpecs
|
|
71 |
!
|
|
72 |
|
|
73 |
buttonRow: specArray
|
|
74 |
| aRow aButton enabled selected |
|
|
75 |
aRow _ AlignmentMorph newRow.
|
|
76 |
aRow
|
|
77 |
color: (Display depth <= 8 ifTrue: [Color transparent] ifFalse: [Color gray alpha: 0.2]);
|
|
78 |
borderWidth: 0.
|
|
79 |
|
|
80 |
aRow hResizing: #spaceFill; vResizing: #spaceFill; rubberBandCells: true.
|
|
81 |
aRow clipSubmorphs: true.
|
|
82 |
aRow layoutInset: 5@2; cellInset: 3.
|
|
83 |
aRow wrapCentering: #center; cellPositioning: #leftCenter.
|
|
84 |
specArray do:
|
|
85 |
[:triplet |
|
|
86 |
enabled _ triplet at: 4 ifAbsent: [#buttonEnabled].
|
|
87 |
selected _ triplet at: 5 ifAbsent: [enabled].
|
|
88 |
aButton _ PluggableButtonMorph
|
|
89 |
on: self
|
|
90 |
getState: selected
|
|
91 |
action: #performButtonAction:enabled:.
|
|
92 |
aButton
|
|
93 |
hResizing: #spaceFill;
|
|
94 |
vResizing: #spaceFill;
|
|
95 |
useRoundedCorners;
|
|
96 |
label: triplet first asString;
|
|
97 |
arguments: (Array with: triplet second with: enabled);
|
|
98 |
onColor: Color transparent offColor: Color white.
|
|
99 |
aRow addMorphBack: aButton.
|
|
100 |
aButton setBalloonText: triplet third].
|
|
101 |
|
|
102 |
Preferences alternativeWindowLook ifTrue:[
|
|
103 |
aRow color: Color transparent.
|
|
104 |
aRow submorphsDo:[:m| m borderWidth: 2; borderColor: #raised].
|
|
105 |
].
|
|
106 |
|
|
107 |
^ aRow
|
|
108 |
!
|
|
109 |
|
|
110 |
buttonSelected
|
|
111 |
^ false
|
|
112 |
!
|
|
113 |
|
|
114 |
buttonSpecs
|
|
115 |
^ #()
|
|
116 |
!
|
|
117 |
|
|
118 |
buttonState
|
|
119 |
^ true
|
|
120 |
!
|
|
121 |
|
|
122 |
close
|
|
123 |
self window delete
|
|
124 |
!
|
|
125 |
|
|
126 |
defaultAnnotationPaneHeight
|
|
127 |
"Answer the receiver's preferred default height for new annotation panes."
|
|
128 |
^ Preferences parameterAt: #defaultAnnotationPaneHeight ifAbsentPut: [25]
|
|
129 |
!
|
|
130 |
|
|
131 |
defaultBackgroundColor
|
|
132 |
^ (Color r: 0.627 g: 0.69 b: 0.976)
|
|
133 |
!
|
|
134 |
|
|
135 |
defaultButtonPaneHeight
|
|
136 |
"Answer the user's preferred default height for new button panes."
|
|
137 |
|
|
138 |
^ Preferences parameterAt: #defaultButtonPaneHeight ifAbsentPut: [25]
|
|
139 |
!
|
|
140 |
|
|
141 |
defaultExtent
|
|
142 |
^ 500@500
|
|
143 |
!
|
|
144 |
|
|
145 |
defaultLabel
|
|
146 |
^ self class name
|
|
147 |
!
|
|
148 |
|
|
149 |
fillMenu: aMenu fromSpecs: anArray
|
|
150 |
anArray do:
|
|
151 |
[:pair |
|
|
152 |
aMenu add: pair first target: self selector: pair second].
|
|
153 |
^ aMenu
|
|
154 |
!
|
|
155 |
|
|
156 |
findListMorph: aSymbol
|
|
157 |
^ morph submorphs detect: [:ea | (ea respondsTo: #getListSelector) and: [ea getListSelector = aSymbol]] ifNone: []
|
|
158 |
!
|
|
159 |
|
|
160 |
findTextMorph: aSymbol
|
|
161 |
^ morph submorphs detect: [:ea | (ea respondsTo: #getTextSelector) and: [ea getTextSelector = aSymbol]] ifNone: []
|
|
162 |
!
|
|
163 |
|
|
164 |
getMenu: aMenu
|
|
165 |
^aMenu
|
|
166 |
!
|
|
167 |
|
|
168 |
label
|
|
169 |
^ label ifNil: [self defaultLabel]
|
|
170 |
!
|
|
171 |
|
|
172 |
label: aString
|
|
173 |
label _ aString
|
|
174 |
!
|
|
175 |
|
|
176 |
listMorph: listSymbol
|
|
177 |
^ self
|
|
178 |
listMorph: (listSymbol, 'List') asSymbol
|
|
179 |
selection: (listSymbol, 'Selection') asSymbol
|
|
180 |
menu: (listSymbol, 'ListMenu:') asSymbol
|
|
181 |
!
|
|
182 |
|
|
183 |
listMorph: listSymbol keystroke: keystrokeSymbol
|
|
184 |
^ (self
|
|
185 |
listMorph: (listSymbol, 'List') asSymbol
|
|
186 |
selection: (listSymbol, 'Selection') asSymbol
|
|
187 |
menu: (listSymbol, 'ListMenu:') asSymbol)
|
|
188 |
keystrokeActionSelector: keystrokeSymbol;
|
|
189 |
yourself
|
|
190 |
!
|
|
191 |
|
|
192 |
listMorph: listSymbol selection: selectionSymbol
|
|
193 |
^ PluggableListMorph
|
|
194 |
on: self
|
|
195 |
list: listSymbol
|
|
196 |
selected: selectionSymbol
|
|
197 |
changeSelected: (selectionSymbol, ':') asSymbol
|
|
198 |
!
|
|
199 |
|
|
200 |
listMorph: listSymbol selection: selectionSymbol menu: menuSymbol
|
|
201 |
^ PluggableListMorph
|
|
202 |
on: self
|
|
203 |
list: listSymbol
|
|
204 |
selected: selectionSymbol
|
|
205 |
changeSelected: (selectionSymbol, ':') asSymbol
|
|
206 |
menu: menuSymbol
|
|
207 |
!
|
|
208 |
|
|
209 |
listMorph: listSymbol selection: selectionSymbol menu: menuSymbol keystroke: keystrokeSymbol
|
|
210 |
^ (PluggableListMorph
|
|
211 |
on: self
|
|
212 |
list: listSymbol
|
|
213 |
selected: selectionSymbol
|
|
214 |
changeSelected: (selectionSymbol, ':') asSymbol
|
|
215 |
menu: menuSymbol)
|
|
216 |
keystrokeActionSelector: keystrokeSymbol;
|
|
217 |
yourself
|
|
218 |
!
|
|
219 |
|
|
220 |
multiListMorph: listSymbol selection: selectionSymbol listSelection: listSelectionSymbol menu: menuSymbol
|
|
221 |
^ PluggableListMorphOfMany
|
|
222 |
on: self
|
|
223 |
list: listSymbol
|
|
224 |
primarySelection: selectionSymbol
|
|
225 |
changePrimarySelection: (selectionSymbol, ':') asSymbol
|
|
226 |
listSelection: listSelectionSymbol
|
|
227 |
changeListSelection: (listSelectionSymbol, 'put:') asSymbol
|
|
228 |
menu: menuSymbol
|
|
229 |
!
|
|
230 |
|
|
231 |
perform: selector orSendTo: otherTarget
|
|
232 |
"Selector was just chosen from a menu by a user. If can respond, then
|
|
233 |
perform it on myself. If not, send it to otherTarget, presumably the
|
|
234 |
editPane from which the menu was invoked."
|
|
235 |
|
|
236 |
(self respondsTo: selector)
|
|
237 |
ifTrue: [^ self perform: selector]
|
|
238 |
ifFalse: [^ otherTarget perform: selector]
|
|
239 |
!
|
|
240 |
|
|
241 |
performButtonAction: anActionSelector enabled: anEnabledSelector
|
|
242 |
(self perform: anEnabledSelector)
|
|
243 |
ifTrue: [ self perform: anActionSelector ]
|
|
244 |
!
|
|
245 |
|
|
246 |
show
|
|
247 |
modal _ false.
|
|
248 |
Smalltalk at: #ToolBuilder ifPresent: [:tb | tb open: self. ^ self].
|
|
249 |
^self window openInWorldExtent: self defaultExtent; yourself
|
|
250 |
!
|
|
251 |
|
|
252 |
showLabelled: labelString
|
|
253 |
modal _ false.
|
|
254 |
self label: labelString.
|
|
255 |
^(self window)
|
|
256 |
openInWorldExtent: self defaultExtent;
|
|
257 |
yourself
|
|
258 |
!
|
|
259 |
|
|
260 |
showModally
|
|
261 |
modal _ true.
|
|
262 |
self window openInWorldExtent: (400@400).
|
|
263 |
[self window world notNil] whileTrue: [
|
|
264 |
self window outermostWorldMorph doOneCycle.
|
|
265 |
].
|
|
266 |
morph _ nil.
|
|
267 |
^ modalValue
|
|
268 |
!
|
|
269 |
|
|
270 |
step
|
|
271 |
!
|
|
272 |
|
|
273 |
textMorph: aSymbol
|
|
274 |
^ PluggableTextMorph on: self text: aSymbol accept: (aSymbol, ':') asSymbol
|
|
275 |
!
|
|
276 |
|
|
277 |
treeMorph: listSymbol
|
|
278 |
^ self
|
|
279 |
treeMorph: (listSymbol, 'Tree') asSymbol
|
|
280 |
selection: (listSymbol, 'SelectionWrapper') asSymbol
|
|
281 |
menu: (listSymbol, 'TreeMenu:') asSymbol
|
|
282 |
!
|
|
283 |
|
|
284 |
treeMorph: listSymbol selection: selectionSymbol menu: menuSymbol
|
|
285 |
^ SimpleHierarchicalListMorph
|
|
286 |
on: self
|
|
287 |
list: listSymbol
|
|
288 |
selected: selectionSymbol
|
|
289 |
changeSelected: (selectionSymbol, ':') asSymbol
|
|
290 |
menu: menuSymbol
|
|
291 |
keystroke: nil
|
|
292 |
!
|
|
293 |
|
|
294 |
treeOrListMorph: aSymbol
|
|
295 |
^ self treeMorph: aSymbol
|
|
296 |
!
|
|
297 |
|
|
298 |
widgetSpecs
|
|
299 |
^ #()
|
|
300 |
!
|
|
301 |
|
|
302 |
window
|
|
303 |
^ morph ifNil: [morph _ self buildWindow]
|
|
304 |
! !
|
|
305 |
|
|
306 |
!MCTool class methodsFor:'documentation'!
|
|
307 |
|
|
308 |
version
|
692
|
309 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCTool.st,v 1.2 2012-09-11 21:29:48 cg Exp $'
|
129
|
310 |
! !
|