author | Claus Gittinger <cg@exept.de> |
Wed, 03 Dec 2003 12:48:56 +0100 | |
changeset 1869 | c6800c75b7d0 |
parent 1793 | eba6da749414 |
child 1881 | 22a568696a7b |
permissions | -rw-r--r-- |
366 | 1 |
" |
2 |
COPYRIGHT (c) 1996 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
||
1373 | 14 |
"{ Package: 'stx:libview2' }" |
15 |
||
366 | 16 |
ApplicationModel subclass:#SimpleDialog |
431 | 17 |
instanceVariableNames:'accept cancel close escapeIsCancel postBuildBlock postOpenBlock |
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
18 |
preBuildBlock closeAllowedChannel' |
366 | 19 |
classVariableNames:'' |
20 |
poolDictionaries:'' |
|
21 |
category:'Interface-Framework' |
|
22 |
! |
|
23 |
||
24 |
!SimpleDialog class methodsFor:'documentation'! |
|
25 |
||
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) 1996 by eXept Software AG |
|
29 |
All Rights Reserved |
|
30 |
||
31 |
This software is furnished under a license and may be used |
|
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
38 |
||
39 |
! |
|
40 |
||
41 |
documentation |
|
42 |
" |
|
1589 | 43 |
Use SimpleDialog to specify Dialogs with a windowSpec built by the GUI Builder. |
366 | 44 |
|
45 |
Notice: this class was implemented using protocol information |
|
46 |
from alpha testers and PD code - it may not be complete or compatible to |
|
47 |
the corresponding ST-80 class. If you encounter any incompatibilities, |
|
48 |
please forward a note to the ST/X team. |
|
49 |
||
50 |
[author:] |
|
51 |
Claus Gittinger |
|
52 |
||
53 |
[see also:] |
|
54 |
StandardSystemView |
|
55 |
WindowGroup DeviceWorkstation DialogBox |
|
56 |
" |
|
57 |
! ! |
|
58 |
||
906 | 59 |
!SimpleDialog class methodsFor:'queries'! |
60 |
||
61 |
isVisualStartable |
|
1427 | 62 |
"return true, if this application can be started via #open. |
63 |
(to allow start of a change browser via double-click in the browser)" |
|
906 | 64 |
|
65 |
self == SimpleDialog ifTrue:[^false]. |
|
66 |
^super isVisualStartable |
|
67 |
! ! |
|
68 |
||
976
dd0045c9fdd7
must create the builder ... (sigh)
Claus Gittinger <cg@exept.de>
parents:
935
diff
changeset
|
69 |
|
431 | 70 |
!SimpleDialog methodsFor:'accessing'! |
71 |
||
72 |
accept |
|
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
73 |
"return the valueholder which gets set by the accept button. |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
74 |
Also, when this valueHolder gets a true stuffed into it, the |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
75 |
dialog is closed." |
431 | 76 |
|
1640
5bd912083327
Initialize accept and cancel valueHolders
Stefan Vogel <sv@exept.de>
parents:
1598
diff
changeset
|
77 |
accept isNil ifTrue:[ |
5bd912083327
Initialize accept and cancel valueHolders
Stefan Vogel <sv@exept.de>
parents:
1598
diff
changeset
|
78 |
accept := false asValue. |
5bd912083327
Initialize accept and cancel valueHolders
Stefan Vogel <sv@exept.de>
parents:
1598
diff
changeset
|
79 |
]. |
5bd912083327
Initialize accept and cancel valueHolders
Stefan Vogel <sv@exept.de>
parents:
1598
diff
changeset
|
80 |
|
431 | 81 |
^ accept |
605 | 82 |
|
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
83 |
"Modified: / 20.5.1998 / 20:51:05 / cg" |
431 | 84 |
! |
85 |
||
1381 | 86 |
accepted |
87 |
"after the box has closed: |
|
88 |
return true if accepted, false if canceled" |
|
89 |
||
90 |
^ self accept value |
|
91 |
||
92 |
! |
|
93 |
||
431 | 94 |
bindings |
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
95 |
"return my builders bindings" |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
96 |
|
431 | 97 |
^ builder bindings |
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
98 |
|
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
99 |
"Modified: / 20.5.1998 / 20:51:15 / cg" |
431 | 100 |
! |
101 |
||
102 |
cancel |
|
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
103 |
"return the valueholder which gets set by the cancel button. |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
104 |
Also, when this valueHolder gets a true stuffed into it, the |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
105 |
dialog is closed." |
431 | 106 |
|
1640
5bd912083327
Initialize accept and cancel valueHolders
Stefan Vogel <sv@exept.de>
parents:
1598
diff
changeset
|
107 |
cancel isNil ifTrue:[ |
5bd912083327
Initialize accept and cancel valueHolders
Stefan Vogel <sv@exept.de>
parents:
1598
diff
changeset
|
108 |
cancel := false asValue. |
5bd912083327
Initialize accept and cancel valueHolders
Stefan Vogel <sv@exept.de>
parents:
1598
diff
changeset
|
109 |
]. |
431 | 110 |
^ cancel |
605 | 111 |
|
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
112 |
"Modified: / 20.5.1998 / 20:51:02 / cg" |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
113 |
! |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
114 |
|
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
115 |
closeAllowedChannel |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
116 |
"return the value-provider which controls if close is allowed. |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
117 |
This is initialized to true." |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
118 |
|
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
119 |
^ closeAllowedChannel |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
120 |
|
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
121 |
"Created: / 20.5.1998 / 21:52:32 / cg" |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
122 |
"Modified: / 20.5.1998 / 21:53:18 / cg" |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
123 |
! |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
124 |
|
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
125 |
closeAllowedChannel:aValueHolderOrBlock |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
126 |
"set a value-provider which controls if close is allowed." |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
127 |
|
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
128 |
^ closeAllowedChannel |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
129 |
|
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
130 |
"Created: / 20.5.1998 / 21:52:53 / cg" |
431 | 131 |
! |
132 |
||
133 |
closeChannel |
|
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
134 |
"return the closeChannel; If a true is stuffed into this valueHolder, |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
135 |
I will close myself." |
431 | 136 |
|
137 |
^ close |
|
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
138 |
|
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
139 |
"Modified: / 20.5.1998 / 20:52:29 / cg" |
431 | 140 |
! |
141 |
||
142 |
escapeIsCancel |
|
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
143 |
"return the escapeIsCancel setting" |
431 | 144 |
|
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
145 |
^ escapeIsCancel |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
146 |
|
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
147 |
"Modified: / 20.5.1998 / 20:52:44 / cg" |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
148 |
! |
431 | 149 |
|
150 |
escapeIsCancel:something |
|
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
151 |
"set/clear the escapeIsCancel option. |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
152 |
If on, an ESC-key will be treated like a cancel action." |
431 | 153 |
|
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
154 |
escapeIsCancel := something. |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
155 |
|
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
156 |
"Modified: / 20.5.1998 / 20:53:23 / cg" |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
157 |
! |
431 | 158 |
|
159 |
postBuildBlock:something |
|
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
160 |
"set postBuildBlock; if non-nil, this is evaluated after the build process" |
431 | 161 |
|
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
162 |
postBuildBlock := something. |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
163 |
|
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
164 |
"Modified: / 20.5.1998 / 20:54:06 / cg" |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
165 |
! |
431 | 166 |
|
167 |
postOpenBlock:something |
|
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
168 |
"set the postBuildBlock; if non-nil, this is evaluated after the view is opened" |
431 | 169 |
|
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
170 |
postOpenBlock := something. |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
171 |
|
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
172 |
"Modified: / 20.5.1998 / 20:54:23 / cg" |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
173 |
! |
431 | 174 |
|
175 |
preBuildBlock:something |
|
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
176 |
"set the preBuildBlock; if non-nil, this is evaluated before the view is constructed" |
431 | 177 |
|
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
178 |
preBuildBlock := something. |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
179 |
|
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
180 |
"Modified: / 20.5.1998 / 20:54:41 / cg" |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
181 |
! |
431 | 182 |
|
183 |
source:anApplication |
|
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
184 |
"define the application which provides resources, aspects etc." |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
185 |
|
1067
5b39cef366fe
also set the masterApplication when a simpleDialogs source
Claus Gittinger <cg@exept.de>
parents:
1053
diff
changeset
|
186 |
builder source:anApplication. |
5b39cef366fe
also set the masterApplication when a simpleDialogs source
Claus Gittinger <cg@exept.de>
parents:
1053
diff
changeset
|
187 |
masterApplication isNil ifTrue:[ |
1440
7a0b8cc86e87
added #openSpec:withBindings:
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
188 |
anApplication ~~ self ifTrue:[ |
7a0b8cc86e87
added #openSpec:withBindings:
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
189 |
masterApplication := anApplication |
7a0b8cc86e87
added #openSpec:withBindings:
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
190 |
] |
1067
5b39cef366fe
also set the masterApplication when a simpleDialogs source
Claus Gittinger <cg@exept.de>
parents:
1053
diff
changeset
|
191 |
]. |
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
192 |
|
1067
5b39cef366fe
also set the masterApplication when a simpleDialogs source
Claus Gittinger <cg@exept.de>
parents:
1053
diff
changeset
|
193 |
"Modified: / 8.9.1998 / 01:46:06 / cg" |
431 | 194 |
! ! |
195 |
||
1397 | 196 |
!SimpleDialog methodsFor:'accessing-window'! |
481 | 197 |
|
198 |
minWidth:nPixels |
|
199 |
|w box | |
|
200 |
||
201 |
w := builder window width. |
|
202 |
builder window width:(w max:nPixels). |
|
203 |
||
204 |
"/ box := builder window displayBox. |
|
205 |
"/ box width: (box width max: nPixels). |
|
206 |
"/ builder window displayBox: box |
|
207 |
||
208 |
"Modified: 3.3.1997 / 21:56:27 / cg" |
|
209 |
! ! |
|
210 |
||
431 | 211 |
!SimpleDialog methodsFor:'events'! |
212 |
||
213 |
closeAccept |
|
605 | 214 |
"accept was pressed. close the dialog" |
215 |
||
431 | 216 |
self requestForWindowClose ifTrue:[ |
1129 | 217 |
builder keyboardProcessor requestGlobalAutoAccept ifTrue:[ |
218 |
self closeWindow |
|
219 |
] |
|
431 | 220 |
] |
605 | 221 |
|
222 |
"Modified: 17.6.1997 / 14:10:23 / cg" |
|
431 | 223 |
! |
224 |
||
225 |
closeCancel |
|
605 | 226 |
"cancel was pressed. close the dialog" |
227 |
||
431 | 228 |
self requestForWindowClose ifTrue:[ |
229 |
self closeWindow |
|
230 |
] |
|
605 | 231 |
|
232 |
"Modified: 17.6.1997 / 14:10:29 / cg" |
|
431 | 233 |
! |
234 |
||
235 |
closeWindow |
|
605 | 236 |
"close the dialog" |
237 |
||
1053 | 238 |
|c| |
239 |
||
240 |
c := self closeChannel. |
|
241 |
c retractInterestsFor:self. |
|
242 |
c value:true. |
|
903 | 243 |
"/ must destroy - otherwise there is no #release to |
244 |
"/ the controllers (onChangeSend-dependency problem) |
|
902 | 245 |
builder window destroy. "/ hide |
605 | 246 |
|
1053 | 247 |
"Modified: / 24.8.1998 / 17:45:56 / cg" |
431 | 248 |
! |
249 |
||
250 |
requestForWindowClose |
|
1373 | 251 |
"the dialog is about to be closed - this method is invoked and may |
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
252 |
return false to suppress the close. |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
253 |
Here the value of closeAllowedChannel is returned, which is |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
254 |
set to true initially. |
1373 | 255 |
You may redefined this in a special dialog, and/or provide a boolean |
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
256 |
valueHolder or a boolean block via the #closeAllowedChannel: method." |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
257 |
|
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
258 |
^ closeAllowedChannel value |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
259 |
|
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
260 |
"Modified: / 20.5.1998 / 21:52:25 / cg" |
431 | 261 |
! ! |
262 |
||
713 | 263 |
!SimpleDialog methodsFor:'forced actions'! |
264 |
||
265 |
doAccept |
|
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
266 |
"force accept" |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
267 |
|
1640
5bd912083327
Initialize accept and cancel valueHolders
Stefan Vogel <sv@exept.de>
parents:
1598
diff
changeset
|
268 |
self accept value:true |
713 | 269 |
|
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
270 |
"Created: / 18.10.1997 / 05:18:09 / cg" |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
271 |
"Modified: / 20.5.1998 / 21:53:35 / cg" |
713 | 272 |
! |
273 |
||
1793
eba6da749414
extra hooks for ok/cancel via keyboard
Claus Gittinger <cg@exept.de>
parents:
1640
diff
changeset
|
274 |
doAcceptByReturnKey |
eba6da749414
extra hooks for ok/cancel via keyboard
Claus Gittinger <cg@exept.de>
parents:
1640
diff
changeset
|
275 |
self doAccept |
eba6da749414
extra hooks for ok/cancel via keyboard
Claus Gittinger <cg@exept.de>
parents:
1640
diff
changeset
|
276 |
! |
eba6da749414
extra hooks for ok/cancel via keyboard
Claus Gittinger <cg@exept.de>
parents:
1640
diff
changeset
|
277 |
|
713 | 278 |
doCancel |
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
279 |
"force cancel" |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
280 |
|
1640
5bd912083327
Initialize accept and cancel valueHolders
Stefan Vogel <sv@exept.de>
parents:
1598
diff
changeset
|
281 |
self cancel value:true |
713 | 282 |
|
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
283 |
"Created: / 18.10.1997 / 05:18:22 / cg" |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
284 |
"Modified: / 20.5.1998 / 21:53:40 / cg" |
1793
eba6da749414
extra hooks for ok/cancel via keyboard
Claus Gittinger <cg@exept.de>
parents:
1640
diff
changeset
|
285 |
! |
eba6da749414
extra hooks for ok/cancel via keyboard
Claus Gittinger <cg@exept.de>
parents:
1640
diff
changeset
|
286 |
|
eba6da749414
extra hooks for ok/cancel via keyboard
Claus Gittinger <cg@exept.de>
parents:
1640
diff
changeset
|
287 |
doCancelByEscapeKey |
eba6da749414
extra hooks for ok/cancel via keyboard
Claus Gittinger <cg@exept.de>
parents:
1640
diff
changeset
|
288 |
self doCancel |
713 | 289 |
! ! |
290 |
||
431 | 291 |
!SimpleDialog methodsFor:'initialization'! |
292 |
||
293 |
initialize |
|
935 | 294 |
accept := (ValueHolder with:false). |
295 |
close := (ValueHolder with:false). |
|
296 |
cancel := (ValueHolder with:false). |
|
978 | 297 |
self createBuilder. |
431 | 298 |
builder aspectAt:#accept put:accept. |
299 |
builder aspectAt:#close put:close. |
|
300 |
builder aspectAt:#cancel put:cancel. |
|
301 |
escapeIsCancel := true. |
|
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
302 |
closeAllowedChannel := true |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
303 |
|
978 | 304 |
"Modified: / 19.6.1998 / 03:35:48 / cg" |
476
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
305 |
! |
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
306 |
|
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
307 |
initializeBuilderFor:aView |
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
308 |
aView notNil ifTrue:[ |
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
309 |
builder window:aView. |
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
310 |
] |
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
311 |
|
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
312 |
"Created: 3.3.1997 / 16:23:04 / cg" |
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
313 |
! |
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
314 |
|
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
315 |
initializeWindowFor:aView |
679 | 316 |
|v| |
476
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
317 |
|
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
318 |
(v := aView) isNil ifTrue:[ |
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
319 |
v := ModalBox new. |
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
320 |
]. |
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
321 |
|
481 | 322 |
builder setupWindowFor:v. |
476
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
323 |
|
481 | 324 |
"Modified: 3.3.1997 / 20:39:46 / cg" |
431 | 325 |
! ! |
326 |
||
429 | 327 |
!SimpleDialog methodsFor:'interface opening'! |
328 |
||
431 | 329 |
allButOpenFrom:aSpec |
330 |
"create my views but do not open the main window" |
|
331 |
||
332 |
super allButOpenFrom:aSpec. |
|
333 |
self preOpen |
|
334 |
! |
|
335 |
||
429 | 336 |
openFor:anApplication interface:aSelector |
465 | 337 |
"open the dialog for some appModel from a given spec; |
338 |
Return true if accepted, false if canceled" |
|
339 |
||
464
25e6380399c6
allow additional bindings to be passed with #openDialogInterface
Claus Gittinger <cg@exept.de>
parents:
462
diff
changeset
|
340 |
^ self openFor:anApplication interface:aSelector withBindings:nil |
25e6380399c6
allow additional bindings to be passed with #openDialogInterface
Claus Gittinger <cg@exept.de>
parents:
462
diff
changeset
|
341 |
|
465 | 342 |
"Modified: 28.2.1997 / 16:22:08 / cg" |
464
25e6380399c6
allow additional bindings to be passed with #openDialogInterface
Claus Gittinger <cg@exept.de>
parents:
462
diff
changeset
|
343 |
! |
25e6380399c6
allow additional bindings to be passed with #openDialogInterface
Claus Gittinger <cg@exept.de>
parents:
462
diff
changeset
|
344 |
|
25e6380399c6
allow additional bindings to be passed with #openDialogInterface
Claus Gittinger <cg@exept.de>
parents:
462
diff
changeset
|
345 |
openFor:anApplication interface:aSelector withBindings:bindings |
713 | 346 |
"open the dialog for some appModel from a given specSymbol; |
347 |
the application must provide an interfaceSpec for that symbol. |
|
348 |
The bindings argument may provide overwriting bindings for the |
|
349 |
dialog. |
|
350 |
Return true if accepted, false if canceled" |
|
351 |
||
352 |
^ self |
|
353 |
openFor:anApplication |
|
354 |
interfaceSpec:(anApplication class interfaceSpecFor:aSelector) |
|
355 |
withBindings:bindings |
|
356 |
||
357 |
"Modified: 18.10.1997 / 04:43:13 / cg" |
|
358 |
! |
|
359 |
||
360 |
openFor:anApplication interfaceSpec:aSpec withBindings:bindings |
|
465 | 361 |
"open the dialog for some appModel from a given spec; |
362 |
the bindings argument may provide overwriting bindings for the |
|
363 |
dialog. |
|
364 |
Return true if accepted, false if canceled" |
|
365 |
||
1491 | 366 |
|app| |
367 |
||
464
25e6380399c6
allow additional bindings to be passed with #openDialogInterface
Claus Gittinger <cg@exept.de>
parents:
462
diff
changeset
|
368 |
builder addBindings:bindings. |
1491 | 369 |
(app := anApplication) isNil ifTrue:[ |
370 |
app := ApplicationModel new |
|
371 |
]. |
|
372 |
self source:app. |
|
713 | 373 |
^ self openFrom:aSpec |
429 | 374 |
|
465 | 375 |
"Modified: 28.2.1997 / 16:22:00 / cg" |
713 | 376 |
"Created: 18.10.1997 / 04:41:29 / cg" |
429 | 377 |
! |
378 |
||
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
379 |
openFor:anApplication spec:aSpec withBindings:bindings |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
380 |
"open the dialog for some appModel from a given spec. |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
381 |
The bindings argument may provide overwriting bindings for the |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
382 |
dialog. |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
383 |
Return true if accepted, false if canceled" |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
384 |
|
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
385 |
^ self |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
386 |
openFor:anApplication |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
387 |
interfaceSpec:aSpec |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
388 |
withBindings:bindings |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
389 |
|
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
390 |
"Modified: / 18.10.1997 / 04:43:13 / cg" |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
391 |
"Created: / 20.5.1998 / 20:28:29 / cg" |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
392 |
! |
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
393 |
|
429 | 394 |
openFrom:anInterfaceSpec |
466 | 395 |
"open the dialog from a given spec; |
396 |
return true if accepted, false if canceled" |
|
397 |
||
429 | 398 |
self allButOpenFrom:anInterfaceSpec. |
399 |
self openDialog. |
|
431 | 400 |
^ accept value |
401 |
||
466 | 402 |
"Modified: 28.2.1997 / 16:40:36 / cg" |
431 | 403 |
! |
404 |
||
1441 | 405 |
openInterface:aSymbol |
406 |
"open a standard interface. |
|
407 |
Redefined to return the accept value instead of the builder." |
|
408 |
||
409 |
super openInterfaceModal:aSymbol. |
|
410 |
^ accept value. |
|
411 |
||
412 |
"Created: / 23.1.1998 / 18:19:57 / cg" |
|
413 |
"Modified: / 20.5.1998 / 20:21:28 / cg" |
|
414 |
! |
|
415 |
||
416 |
openSpec:aWindowSpec |
|
417 |
"open a window spec. |
|
418 |
Redefned to open modal and to return the accept value instead |
|
419 |
of the builder." |
|
420 |
||
421 |
super openSpecModal:aWindowSpec. |
|
422 |
^ accept value. |
|
423 |
||
424 |
"Modified: / 22.4.1998 / 11:59:05 / cg" |
|
425 |
"Created: / 20.5.1998 / 20:21:17 / cg" |
|
426 |
! |
|
427 |
||
1440
7a0b8cc86e87
added #openSpec:withBindings:
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
428 |
openSpec:anInterfaceSpec withBindings:bindings |
7a0b8cc86e87
added #openSpec:withBindings:
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
429 |
"open the dialog with a given spec; |
7a0b8cc86e87
added #openSpec:withBindings:
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
430 |
The bindings argument is mandatory and provides aspect bindings for the |
7a0b8cc86e87
added #openSpec:withBindings:
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
431 |
dialog. |
7a0b8cc86e87
added #openSpec:withBindings:
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
432 |
Return true if accepted, false if canceled" |
7a0b8cc86e87
added #openSpec:withBindings:
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
433 |
|
7a0b8cc86e87
added #openSpec:withBindings:
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
434 |
^ self |
7a0b8cc86e87
added #openSpec:withBindings:
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
435 |
openFor:self |
7a0b8cc86e87
added #openSpec:withBindings:
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
436 |
interfaceSpec:anInterfaceSpec |
7a0b8cc86e87
added #openSpec:withBindings:
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
437 |
withBindings:bindings |
7a0b8cc86e87
added #openSpec:withBindings:
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
438 |
! |
7a0b8cc86e87
added #openSpec:withBindings:
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
439 |
|
713 | 440 |
postBuildWith:aBuilder |
441 |
"this is sent after the dialogs widgets have been created |
|
442 |
(but before the dialog is opened). |
|
443 |
If a postBuildBlock was set, evaluate it here." |
|
444 |
||
445 |
postBuildBlock notNil ifTrue:[ |
|
1551
f3428747591f
use new #valueWithOptionalArg
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
446 |
postBuildBlock valueWithOptionalArgument:aBuilder |
713 | 447 |
]. |
448 |
super postBuildWith:aBuilder |
|
449 |
||
450 |
"Created: 18.10.1997 / 05:17:12 / cg" |
|
451 |
! |
|
452 |
||
453 |
postOpenWith:aBuilder |
|
454 |
"this is sent after the dialogs main window is opened. |
|
455 |
If a postOpenBlock was set, evaluate it here." |
|
456 |
||
457 |
postOpenBlock notNil ifTrue:[ |
|
1551
f3428747591f
use new #valueWithOptionalArg
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
458 |
postOpenBlock valueWithOptionalArgument:aBuilder |
713 | 459 |
]. |
460 |
super postOpenWith:aBuilder |
|
461 |
||
462 |
"Created: 18.10.1997 / 05:15:48 / cg" |
|
463 |
! |
|
464 |
||
465 |
preBuildWith:aBuilder |
|
466 |
"this is sent before the dialogs widgets are created. |
|
467 |
If a preBuildBlock was set, evaluate it here." |
|
468 |
||
469 |
preBuildBlock notNil ifTrue:[ |
|
1551
f3428747591f
use new #valueWithOptionalArg
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
470 |
preBuildBlock valueWithOptionalArgument:aBuilder |
713 | 471 |
]. |
472 |
super preBuildWith:aBuilder |
|
473 |
||
474 |
"Created: 18.10.1997 / 15:02:27 / cg" |
|
475 |
! |
|
476 |
||
431 | 477 |
preOpen |
605 | 478 |
"arrange for #closeAccept & #closeCancel to be invoked when |
479 |
either accept or close is triggered |
|
480 |
(usually the models of corresponding buttons)" |
|
481 |
||
431 | 482 |
accept onChangeSend:#closeAccept to:self. |
483 |
cancel onChangeSend:#closeCancel to:self. |
|
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
484 |
close onChangeSend:#closeWindow to:self. |
429 | 485 |
|
932
f7b0ce4cc1d1
allow opening an interface by spec.
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
486 |
"Modified: / 20.5.1998 / 20:49:26 / cg" |
429 | 487 |
! ! |
488 |
||
366 | 489 |
!SimpleDialog methodsFor:'queries'! |
490 |
||
491 |
defaultWindowType |
|
492 |
"SimpleDialogs come up modal, by default" |
|
493 |
||
494 |
^ #dialog |
|
495 |
||
496 |
"Modified: 14.2.1997 / 22:17:20 / cg" |
|
497 |
! ! |
|
498 |
||
499 |
!SimpleDialog class methodsFor:'documentation'! |
|
500 |
||
501 |
version |
|
1793
eba6da749414
extra hooks for ok/cancel via keyboard
Claus Gittinger <cg@exept.de>
parents:
1640
diff
changeset
|
502 |
^ '$Header: /cvs/stx/stx/libview2/SimpleDialog.st,v 1.41 2003-08-19 17:55:33 cg Exp $' |
366 | 503 |
! ! |