author | Claus Gittinger <cg@exept.de> |
Thu, 06 May 1999 11:09:23 +0200 | |
changeset 1364 | 61457de0e18b |
parent 1310 | 9463cb991065 |
child 1365 | 138d2a797a62 |
permissions | -rw-r--r-- |
245 | 1 |
" |
2 |
COPYRIGHT (c) 1996 by eXept Software AG |
|
250 | 3 |
All Rights Reserved |
245 | 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 |
||
240 | 13 |
DialogBox subclass:#LicenceBox |
249
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
14 |
instanceVariableNames:'accepted destroySemaphore fileName' |
240 | 15 |
classVariableNames:'LicenceRejectSignal' |
16 |
poolDictionaries:'' |
|
17 |
category:'Views-DialogBoxes' |
|
18 |
! |
|
19 |
||
875 | 20 |
!LicenceBox class methodsFor:'documentation'! |
240 | 21 |
|
244 | 22 |
copyright |
23 |
" |
|
24 |
COPYRIGHT (c) 1996 by eXept Software AG |
|
250 | 25 |
All Rights Reserved |
244 | 26 |
|
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
243 | 35 |
|
240 | 36 |
documentation |
37 |
" |
|
38 |
LicenceBox shows a licence text when opened, an returns true, |
|
39 |
if the licence has been accepted, false otherwise. |
|
244 | 40 |
|
41 |
[author:] |
|
42 |
Stefan Vogel |
|
43 |
||
1364
61457de0e18b
compute the height from the displays height
Claus Gittinger <cg@exept.de>
parents:
1310
diff
changeset
|
44 |
[start with:] |
61457de0e18b
compute the height from the displays height
Claus Gittinger <cg@exept.de>
parents:
1310
diff
changeset
|
45 |
LicenceBox open |
61457de0e18b
compute the height from the displays height
Claus Gittinger <cg@exept.de>
parents:
1310
diff
changeset
|
46 |
|
244 | 47 |
[see also:] |
48 |
AboutBox |
|
240 | 49 |
" |
50 |
! |
|
51 |
||
52 |
examples |
|
53 |
" |
|
244 | 54 |
[exBegin] |
240 | 55 |
LicenceRejectSignal handle:[:ex| |
244 | 56 |
Transcript showCR:'Licence rejected'. |
240 | 57 |
] do:[ |
244 | 58 |
LicenceBox open. |
59 |
Transcript showCR:'Licence accepted'. |
|
240 | 60 |
] |
244 | 61 |
[exEnd] |
240 | 62 |
" |
63 |
! ! |
|
64 |
||
875 | 65 |
!LicenceBox class methodsFor:'initialization'! |
240 | 66 |
|
67 |
initialize |
|
68 |
LicenceRejectSignal isNil ifTrue:[ |
|
244 | 69 |
LicenceRejectSignal := ErrorSignal newSignalMayProceed:true. |
70 |
LicenceRejectSignal nameClass:self message:#licenceRejectSignal. |
|
71 |
LicenceRejectSignal notifierString:'licence rejected by user'. |
|
240 | 72 |
]. |
73 |
||
74 |
" |
|
75 |
self initialize |
|
76 |
" |
|
77 |
! ! |
|
78 |
||
875 | 79 |
!LicenceBox class methodsFor:'instance creation'! |
240 | 80 |
|
81 |
open |
|
82 |
"open myself modal and return true if accepted, false otherwise" |
|
83 |
||
84 |
^ super open accepted. |
|
85 |
||
86 |
" |
|
250 | 87 |
LicenceBox open |
240 | 88 |
" |
89 |
||
90 |
"Modified: 9.9.1996 / 17:52:48 / stefan" |
|
91 |
! ! |
|
92 |
||
875 | 93 |
!LicenceBox class methodsFor:'Signal constants'! |
240 | 94 |
|
95 |
licenceRejectSignal |
|
96 |
"licence has been rejected by user" |
|
97 |
||
98 |
^ LicenceRejectSignal |
|
99 |
||
100 |
! ! |
|
101 |
||
102 |
!LicenceBox methodsFor:'accessing'! |
|
103 |
||
104 |
accepted |
|
105 |
"return accepted" |
|
106 |
||
107 |
^ accepted |
|
108 |
||
109 |
"Created: 6.9.1996 / 13:24:44 / stefan" |
|
110 |
! |
|
111 |
||
112 |
accepted:something |
|
113 |
"set accepted" |
|
114 |
||
115 |
accepted := something. |
|
116 |
||
117 |
"Created: 6.9.1996 / 13:24:44 / stefan" |
|
118 |
! ! |
|
119 |
||
120 |
!LicenceBox methodsFor:'destroying'! |
|
121 |
||
122 |
terminate |
|
123 |
"this is the close from a windowmanager |
|
124 |
(only if UseTransientViews == true). |
|
125 |
Redefined, since ModalBox keeps the View alive (only hidden)" |
|
126 |
||
127 |
self destroy. |
|
128 |
||
129 |
"Created: 9.9.1996 / 15:15:31 / stefan" |
|
130 |
! ! |
|
131 |
||
132 |
!LicenceBox methodsFor:'initialization'! |
|
133 |
||
134 |
initialize |
|
1364
61457de0e18b
compute the height from the displays height
Claus Gittinger <cg@exept.de>
parents:
1310
diff
changeset
|
135 |
|textView nLines displayHeight| |
240 | 136 |
|
137 |
super initialize. |
|
1239
ae99d201a28d
smaller lic-box on small screens
Claus Gittinger <cg@exept.de>
parents:
875
diff
changeset
|
138 |
|
1364
61457de0e18b
compute the height from the displays height
Claus Gittinger <cg@exept.de>
parents:
1310
diff
changeset
|
139 |
displayHeight := Display usableExtent y. |
61457de0e18b
compute the height from the displays height
Claus Gittinger <cg@exept.de>
parents:
1310
diff
changeset
|
140 |
nLines := displayHeight // 25. |
61457de0e18b
compute the height from the displays height
Claus Gittinger <cg@exept.de>
parents:
1310
diff
changeset
|
141 |
|
61457de0e18b
compute the height from the displays height
Claus Gittinger <cg@exept.de>
parents:
1310
diff
changeset
|
142 |
"/ (displayHeight < 800) ifTrue:[ |
61457de0e18b
compute the height from the displays height
Claus Gittinger <cg@exept.de>
parents:
1310
diff
changeset
|
143 |
"/ (displayHeight < 500) ifTrue:[ |
61457de0e18b
compute the height from the displays height
Claus Gittinger <cg@exept.de>
parents:
1310
diff
changeset
|
144 |
"/ nLines := 20 |
61457de0e18b
compute the height from the displays height
Claus Gittinger <cg@exept.de>
parents:
1310
diff
changeset
|
145 |
"/ ] ifFalse:[ |
61457de0e18b
compute the height from the displays height
Claus Gittinger <cg@exept.de>
parents:
1310
diff
changeset
|
146 |
"/ nLines := 30 |
61457de0e18b
compute the height from the displays height
Claus Gittinger <cg@exept.de>
parents:
1310
diff
changeset
|
147 |
"/ ] |
61457de0e18b
compute the height from the displays height
Claus Gittinger <cg@exept.de>
parents:
1310
diff
changeset
|
148 |
"/ ] ifFalse:[ |
61457de0e18b
compute the height from the displays height
Claus Gittinger <cg@exept.de>
parents:
1310
diff
changeset
|
149 |
"/ nLines := 40 |
61457de0e18b
compute the height from the displays height
Claus Gittinger <cg@exept.de>
parents:
1310
diff
changeset
|
150 |
"/ ]. |
1239
ae99d201a28d
smaller lic-box on small screens
Claus Gittinger <cg@exept.de>
parents:
875
diff
changeset
|
151 |
|
240 | 152 |
accepted := false. |
153 |
||
154 |
(self addTextLabel:(resources string:'Please read the licence terms:')) adjust:#left. |
|
155 |
textView := self addTextBoxOn:nil |
|
250 | 156 |
class:HTMLDocumentView |
1239
ae99d201a28d
smaller lic-box on small screens
Claus Gittinger <cg@exept.de>
parents:
875
diff
changeset
|
157 |
withNumberOfLines:nLines |
250 | 158 |
hScrollable:true |
159 |
vScrollable:true. |
|
160 |
||
1239
ae99d201a28d
smaller lic-box on small screens
Claus Gittinger <cg@exept.de>
parents:
875
diff
changeset
|
161 |
self width:(textView preferredExtentForLines:nLines cols:70) x. |
240 | 162 |
textView setText:(self licenceText). |
249
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
163 |
textView setTopDirectoryName:(self topDirectory). |
240 | 164 |
self addAbortButtonLabelled:(resources string:'reject licence terms'). |
165 |
self addOkButtonLabelled:(resources string:'accept licence terms'). |
|
166 |
self abortAction:[self destroy. accepted := false. LicenceRejectSignal raise]. |
|
167 |
self okAction:[self destroy. accepted := true]. |
|
168 |
self stickAtBottomWithVariableHeight:textView. |
|
169 |
||
170 |
"Modified: 9.9.1996 / 17:52:13 / stefan" |
|
171 |
! ! |
|
172 |
||
173 |
!LicenceBox methodsFor:'private'! |
|
174 |
||
249
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
175 |
licenceFile |
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
176 |
"get filename of licence file" |
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
177 |
|
1266 | 178 |
|fn| |
249
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
179 |
|
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
180 |
fileName isNil ifTrue:[ |
1242 | 181 |
fileName := fn := resources at:'LICENCEFILE' default:nil. |
182 |
fileName isNil ifTrue:[ |
|
183 |
Smalltalk releaseIdentification = 'ST/X_free_demo_vsn' ifTrue:[ |
|
184 |
fn := 'doc/online/english/LICENCE_DEMO_STX.html'. |
|
185 |
] ifFalse:[ |
|
186 |
fn := 'doc/online/english/LICENCE_STX.html'. |
|
187 |
]. |
|
188 |
fileName := fn. |
|
189 |
]. |
|
875 | 190 |
|
1242 | 191 |
fileName asFilename exists ifFalse:[ |
192 |
fileName := Smalltalk getSystemFileName:fileName. |
|
193 |
fileName isNil ifTrue:[ |
|
194 |
fileName := '../../' , fn. |
|
195 |
fileName asFilename exists ifFalse:[ |
|
196 |
fileName := Smalltalk getSystemFileName:'doc/online/german/LICENCE_STX.html'. |
|
197 |
fileName isNil ifTrue:[ |
|
198 |
fileName := '../../doc/online/german/LICENCE_STX.html'. |
|
199 |
] |
|
200 |
]. |
|
201 |
]. |
|
202 |
]. |
|
203 |
fileName asFilename exists ifFalse:[ |
|
204 |
fileName := nil |
|
205 |
]. |
|
249
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
206 |
]. |
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
207 |
^ fileName |
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
208 |
|
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
209 |
" |
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
210 |
LicenceBox new licenceFile |
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
211 |
" |
875 | 212 |
|
213 |
"Modified: / 23.4.1998 / 11:40:25 / cg" |
|
249
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
214 |
! |
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
215 |
|
240 | 216 |
licenceText |
245 | 217 |
"get licence text" |
240 | 218 |
|
249
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
219 |
|file| |
241 | 220 |
|
249
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
221 |
file := self licenceFile. |
245 | 222 |
file isNil ifTrue:[ |
1310 | 223 |
^ 'oops - you are not supposed to remove the LICENSE file !!' |
245 | 224 |
]. |
249
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
225 |
^ file asFilename contents. |
240 | 226 |
|
245 | 227 |
" |
249
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
228 |
LicenceBox new licenceText |
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
229 |
" |
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
230 |
|
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
231 |
! |
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
232 |
|
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
233 |
topDirectory |
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
234 |
"get name of top directory" |
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
235 |
|
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
236 |
|file| |
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
237 |
|
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
238 |
file := self licenceFile. |
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
239 |
file isNil ifTrue:[ |
250 | 240 |
^ '' |
249
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
241 |
]. |
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
242 |
^ file asFilename directoryName. |
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
243 |
|
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
244 |
" |
6698113011ea
Set top directory for relative HREFs.
Stefan Vogel <sv@exept.de>
parents:
245
diff
changeset
|
245 |
LicenceBox new topDirectory |
245 | 246 |
" |
247 |
||
240 | 248 |
! ! |
249 |
||
875 | 250 |
!LicenceBox class methodsFor:'documentation'! |
245 | 251 |
|
252 |
version |
|
1364
61457de0e18b
compute the height from the displays height
Claus Gittinger <cg@exept.de>
parents:
1310
diff
changeset
|
253 |
^ '$Header: /cvs/stx/stx/libwidg2/LicenceBox.st,v 1.15 1999-05-06 09:09:23 cg Exp $' |
245 | 254 |
! ! |
240 | 255 |
LicenceBox initialize! |