240
|
1 |
'From Smalltalk/X, Version:2.10.9 on 9-sep-1996 at 18:00:22' !
|
|
2 |
|
|
3 |
DialogBox subclass:#LicenceBox
|
|
4 |
instanceVariableNames:'accepted destroySemaphore'
|
|
5 |
classVariableNames:'LicenceRejectSignal'
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'Views-DialogBoxes'
|
|
8 |
!
|
|
9 |
|
|
10 |
!LicenceBox class methodsFor:'documentation'!
|
|
11 |
|
|
12 |
documentation
|
|
13 |
"
|
|
14 |
LicenceBox shows a licence text when opened, an returns true,
|
|
15 |
if the licence has been accepted, false otherwise.
|
|
16 |
"
|
|
17 |
!
|
|
18 |
|
|
19 |
examples
|
|
20 |
"
|
|
21 |
[exBegin]
|
|
22 |
LicenceRejectSignal handle:[:ex|
|
|
23 |
Transcript showCR:'Licence rejected'.
|
|
24 |
] do:[
|
|
25 |
LicenceBox open.
|
|
26 |
Transcript showCR:'Licence accepted'.
|
|
27 |
]
|
|
28 |
[exEnd]
|
|
29 |
"
|
|
30 |
!
|
|
31 |
|
|
32 |
history
|
|
33 |
|
|
34 |
"Created: 6.9.1996 / 13:29:15 / stefan"
|
|
35 |
"Modified: 9.9.1996 / 14:53:11 / stefan"
|
|
36 |
! !
|
|
37 |
|
|
38 |
!LicenceBox class methodsFor:'initialization'!
|
|
39 |
|
|
40 |
initialize
|
|
41 |
LicenceRejectSignal isNil ifTrue:[
|
|
42 |
LicenceRejectSignal := ErrorSignal newSignalMayProceed:true.
|
|
43 |
LicenceRejectSignal nameClass:self message:#licenceRejectSignal.
|
|
44 |
LicenceRejectSignal notifierString:'licence rejected by user'.
|
|
45 |
].
|
|
46 |
|
|
47 |
"
|
|
48 |
self initialize
|
|
49 |
"
|
|
50 |
! !
|
|
51 |
|
|
52 |
!LicenceBox class methodsFor:'instance creation'!
|
|
53 |
|
|
54 |
open
|
|
55 |
"open myself modal and return true if accepted, false otherwise"
|
|
56 |
|
|
57 |
^ super open accepted.
|
|
58 |
|
|
59 |
"
|
|
60 |
self open
|
|
61 |
"
|
|
62 |
|
|
63 |
"Modified: 9.9.1996 / 17:52:48 / stefan"
|
|
64 |
! !
|
|
65 |
|
|
66 |
!LicenceBox class methodsFor:'Signal constants'!
|
|
67 |
|
|
68 |
licenceRejectSignal
|
|
69 |
"licence has been rejected by user"
|
|
70 |
|
|
71 |
^ LicenceRejectSignal
|
|
72 |
|
|
73 |
! !
|
|
74 |
|
|
75 |
!LicenceBox methodsFor:'accessing'!
|
|
76 |
|
|
77 |
accepted
|
|
78 |
"return accepted"
|
|
79 |
|
|
80 |
^ accepted
|
|
81 |
|
|
82 |
"Created: 6.9.1996 / 13:24:44 / stefan"
|
|
83 |
!
|
|
84 |
|
|
85 |
accepted:something
|
|
86 |
"set accepted"
|
|
87 |
|
|
88 |
accepted := something.
|
|
89 |
|
|
90 |
"Created: 6.9.1996 / 13:24:44 / stefan"
|
|
91 |
! !
|
|
92 |
|
|
93 |
!LicenceBox methodsFor:'destroying'!
|
|
94 |
|
|
95 |
terminate
|
|
96 |
"this is the close from a windowmanager
|
|
97 |
(only if UseTransientViews == true).
|
|
98 |
Redefined, since ModalBox keeps the View alive (only hidden)"
|
|
99 |
|
|
100 |
self destroy.
|
|
101 |
|
|
102 |
"Created: 9.9.1996 / 15:15:31 / stefan"
|
|
103 |
! !
|
|
104 |
|
|
105 |
!LicenceBox methodsFor:'initialization'!
|
|
106 |
|
|
107 |
initialize
|
|
108 |
|textView|
|
|
109 |
|
|
110 |
super initialize.
|
|
111 |
accepted := false.
|
|
112 |
|
|
113 |
(self addTextLabel:(resources string:'Please read the licence terms:')) adjust:#left.
|
|
114 |
textView := self addTextBoxOn:nil
|
|
115 |
class:HTMLDocumentView
|
|
116 |
withNumberOfLines:40
|
|
117 |
hScrollable:true
|
|
118 |
vScrollable:true.
|
|
119 |
self width:(textView preferredExtentForLines:40 cols:70) x.
|
|
120 |
textView setText:(self licenceText).
|
|
121 |
self addAbortButtonLabelled:(resources string:'reject licence terms').
|
|
122 |
self addOkButtonLabelled:(resources string:'accept licence terms').
|
|
123 |
self abortAction:[self destroy. accepted := false. LicenceRejectSignal raise].
|
|
124 |
self okAction:[self destroy. accepted := true].
|
|
125 |
self stickAtBottomWithVariableHeight:textView.
|
|
126 |
|
|
127 |
"Modified: 9.9.1996 / 17:52:13 / stefan"
|
|
128 |
! !
|
|
129 |
|
|
130 |
!LicenceBox methodsFor:'private'!
|
|
131 |
|
|
132 |
licenceText
|
|
133 |
"get licence text"
|
|
134 |
|
|
135 |
^ (resources at:'LICENCEFILE') asFilename readStream contents.
|
|
136 |
|
|
137 |
"Created: 6.9.1996 / 12:17:07 / stefan"
|
|
138 |
! !
|
|
139 |
|
|
140 |
!LicenceBox class methodsFor:'documentation'!
|
|
141 |
|
|
142 |
version
|
|
143 |
^ '$Header: /cvs/stx/stx/libwidg2/LicenceBox.st,v 1.1 1996-09-09 17:06:46 stefan Exp $'
|
|
144 |
! !
|
|
145 |
LicenceBox initialize!
|