LicenceBox.st
changeset 1365 138d2a797a62
parent 1364 61457de0e18b
child 1626 614d6e8db98d
--- a/LicenceBox.st	Thu May 06 11:09:23 1999 +0200
+++ b/LicenceBox.st	Thu May 06 11:23:30 1999 +0200
@@ -11,7 +11,7 @@
 "
 
 DialogBox subclass:#LicenceBox
-	instanceVariableNames:'accepted destroySemaphore fileName'
+	instanceVariableNames:'accepted destroySemaphore fileName textView'
 	classVariableNames:'LicenceRejectSignal'
 	poolDictionaries:''
 	category:'Views-DialogBoxes'
@@ -88,6 +88,43 @@
     "
 
     "Modified: 9.9.1996 / 17:52:48 / stefan"
+!
+
+openOnFile:aFileName
+    "like open, but show the HTML-text found in aFileName.
+     Can be used for end-user applications which want to display
+     there own licence text."
+
+    |box f fn text dir|
+
+    box := self new.
+
+    (f := aFileName asFilename) exists ifTrue:[
+	text := f contents.
+	dir := f directoryName.
+    ] ifFalse:[
+	fn := Smalltalk getSystemFileName:aFileName.
+	fn notNil ifTrue:[
+	    f := fn asFilename.
+	    text := f contents.
+	    dir := f directoryName.
+	]
+    ].
+    text notNil ifTrue:[
+	box licenceText:text.
+	box topDirectory:dir.
+    ].
+    box open
+
+    "
+     LicenceBox openOnFile:'doc/online/english/TOP.html'
+
+     (LicenceBox licenceRejectSignal catch:[
+	LicenceBox openOnFile:'doc/online/english/TOP.html'
+     ]) ifTrue:[
+	self information:'rejected'
+      ]
+    "
 ! !
 
 !LicenceBox class methodsFor:'Signal constants'!
@@ -115,6 +152,19 @@
     accepted := something.
 
     "Created: 6.9.1996 / 13:24:44 / stefan"
+!
+
+licenceText:someHTMLText
+    "set the text which is shown in the box"
+
+    textView setText:someHTMLText.
+!
+
+topDirectory:aDirectoryName
+    "set the topDirectory, which is required for hyperlinks
+     to work (in the html text)"
+
+    textView setTopDirectoryName:aDirectoryName.
 ! !
 
 !LicenceBox methodsFor:'destroying'!
@@ -132,7 +182,7 @@
 !LicenceBox methodsFor:'initialization'!
 
 initialize    
-    |textView nLines displayHeight|
+    |nLines displayHeight|
 
     super initialize.
 
@@ -250,6 +300,6 @@
 !LicenceBox class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/LicenceBox.st,v 1.15 1999-05-06 09:09:23 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/LicenceBox.st,v 1.16 1999-05-06 09:23:30 cg Exp $'
 ! !
 LicenceBox initialize!