author | Claus Gittinger <cg@exept.de> |
Mon, 06 Mar 2006 09:37:10 +0100 | |
changeset 6625 | d8ceed41c361 |
parent 5834 | 2a6457a7d2d7 |
child 7721 | bbb68c4df2de |
permissions | -rw-r--r-- |
84 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
92 | 3 |
All Rights Reserved |
84 | 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 |
||
2700 | 13 |
"{ Package: 'stx:libtool' }" |
14 |
||
84 | 15 |
InfoBox subclass:#AboutBox |
451
35d5ba59ee0e
added access method for background color
Claus Gittinger <cg@exept.de>
parents:
248
diff
changeset
|
16 |
instanceVariableNames:'' |
2727 | 17 |
classVariableNames:'CachedIcon DefaultGreen' |
451
35d5ba59ee0e
added access method for background color
Claus Gittinger <cg@exept.de>
parents:
248
diff
changeset
|
18 |
poolDictionaries:'' |
35d5ba59ee0e
added access method for background color
Claus Gittinger <cg@exept.de>
parents:
248
diff
changeset
|
19 |
category:'Views-DialogBoxes' |
84 | 20 |
! |
21 |
||
879 | 22 |
!AboutBox class methodsFor:'documentation'! |
84 | 23 |
|
198 | 24 |
copyright |
25 |
" |
|
26 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
27 |
All Rights Reserved |
|
28 |
||
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
84 | 36 |
! |
37 |
||
38 |
documentation |
|
39 |
" |
|
2700 | 40 |
A box specialized to show the ST/X about-information (also usable for Applications). |
498 | 41 |
As a speciality, this box automatically closes if left |
42 |
alone for a while. |
|
84 | 43 |
|
498 | 44 |
Can be subclasses for your own aboutBoxes; to do so, redefine |
45 |
#defaultIcon and #aboutText. |
|
92 | 46 |
|
498 | 47 |
examples: |
48 |
AboutBox new open |
|
49 |
||
50 |
AboutBox new showAtPointer |
|
84 | 51 |
" |
2700 | 52 |
! |
53 |
||
54 |
examples |
|
55 |
" |
|
56 |
[exBegin] |
|
57 |
|box| |
|
58 |
||
59 |
box := AboutBox new. |
|
60 |
box autoHideAfter:10 with:[]. |
|
61 |
box showAtCenter |
|
62 |
[exEnd] |
|
63 |
||
64 |
[exBegin] |
|
65 |
|box| |
|
66 |
||
67 |
box := AboutBox title:'About me'. |
|
5333 | 68 |
box image:((Smalltalk |
69 |
bitmapFromFileNamed:'gifImages/claus.gif' |
|
70 |
inPackage:'stx:goodies') |
|
71 |
magnifiedTo:100@100). |
|
2700 | 72 |
box label:'Example'. |
73 |
box autoHideAfter:10 with:[]. |
|
74 |
box showAtPointer. |
|
75 |
[exEnd] |
|
76 |
" |
|
84 | 77 |
! ! |
78 |
||
879 | 79 |
!AboutBox class methodsFor:'defaults'! |
84 | 80 |
|
92 | 81 |
aboutText |
498 | 82 |
"return a string to be shown in the box. |
83 |
Can be redefined in custom subclasses." |
|
125 | 84 |
|
1797 | 85 |
|distributor expiration machine info| |
179
f464e3c75104
if nonEmpty, display distributorString
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
86 |
|
693 | 87 |
distributor := Smalltalk distributorString. |
88 |
distributor notEmpty ifTrue:[ |
|
5554 | 89 |
distributor := (((self classResources string:'Distributor') , ' ') paddedTo:20 with:$.) , ' ' , distributor |
708
f89ff543ea18
Display expiration time, if apropriate.
Stefan Vogel <sv@exept.de>
parents:
693
diff
changeset
|
90 |
]. |
f89ff543ea18
Display expiration time, if apropriate.
Stefan Vogel <sv@exept.de>
parents:
693
diff
changeset
|
91 |
expiration := Smalltalk expirationTime. |
f89ff543ea18
Display expiration time, if apropriate.
Stefan Vogel <sv@exept.de>
parents:
693
diff
changeset
|
92 |
expiration notNil ifTrue:[ |
5554 | 93 |
expiration := (((self classResources string:'Expires') , ' ') paddedTo:20 with:$.) , ' ' , expiration |
708
f89ff543ea18
Display expiration time, if apropriate.
Stefan Vogel <sv@exept.de>
parents:
693
diff
changeset
|
94 |
] ifFalse:[ |
f89ff543ea18
Display expiration time, if apropriate.
Stefan Vogel <sv@exept.de>
parents:
693
diff
changeset
|
95 |
expiration := ''. |
693 | 96 |
]. |
1797 | 97 |
machine := OperatingSystem getHostName. |
98 |
info := OperatingSystem getSystemInfo. |
|
99 |
(info includesKey:#machine) ifTrue:[ |
|
100 |
machine := machine , ' (' , (info at:#machine) , ')' |
|
101 |
]. |
|
179
f464e3c75104
if nonEmpty, display distributorString
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
102 |
|
92 | 103 |
^ |
179
f464e3c75104
if nonEmpty, display distributorString
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
104 |
'SmallTalk/X |
92 | 105 |
|
5554 | 106 |
' , (((self classResources string:'Version') , ' ') paddedTo:20 with:$.) , ' ', Smalltalk versionString , '.' , Smalltalk releaseNr printString , |
498 | 107 |
' (' , Smalltalk versionDate printString , ') |
708
f89ff543ea18
Display expiration time, if apropriate.
Stefan Vogel <sv@exept.de>
parents:
693
diff
changeset
|
108 |
', distributor, ' |
f89ff543ea18
Display expiration time, if apropriate.
Stefan Vogel <sv@exept.de>
parents:
693
diff
changeset
|
109 |
', expiration , ' |
5554 | 110 |
' , (((self classResources string:'Release ID') , ' ') paddedTo:20 with:$.) , ' ' , Smalltalk releaseIdentification , ' |
111 |
' , (((self classResources string:'Configuration') , ' ') paddedTo:20 with:$.) , ' ' , Smalltalk configuration , ' |
|
112 |
' , (((self classResources string:'Running on') , ' ') paddedTo:20 with:$.) , ' ' , machine , ' |
|
92 | 113 |
|
179
f464e3c75104
if nonEmpty, display distributorString
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
114 |
' , Smalltalk copyrightString , ' |
f464e3c75104
if nonEmpty, display distributorString
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
115 |
|
693 | 116 |
' |
179
f464e3c75104
if nonEmpty, display distributorString
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
117 |
|
1797 | 118 |
"Modified: / 6.9.1996 / 10:11:08 / stefan" |
119 |
"Modified: / 4.8.1998 / 02:28:29 / cg" |
|
198 | 120 |
! |
121 |
||
2727 | 122 |
defaultGreen |
123 |
"return the boxes default green color (eXept green)." |
|
124 |
||
125 |
DefaultGreen notNil ifTrue:[^ DefaultGreen]. |
|
126 |
^ Color red:0 green:80 blue:20 |
|
127 |
! |
|
128 |
||
198 | 129 |
defaultIcon |
498 | 130 |
"return a smalltalk/X icon. |
131 |
Can be redefined in custom subclasses." |
|
198 | 132 |
|
133 |
CachedIcon isNil ifTrue:[ |
|
2169 | 134 |
CachedIcon := Icon stxIcon. |
135 |
CachedIcon isNil ifTrue:[ |
|
2477 | 136 |
CachedIcon := Smalltalk imageFromFileNamed:'SmalltalkX.xbm' inPackage:'stx:libtool' |
2169 | 137 |
] |
198 | 138 |
]. |
139 |
^ CachedIcon |
|
498 | 140 |
|
2169 | 141 |
"Modified: / 25.5.1999 / 15:44:48 / cg" |
498 | 142 |
! |
143 |
||
144 |
defaultLabel |
|
145 |
"return the boxes default window title." |
|
146 |
||
6625 | 147 |
^ 'About...' |
498 | 148 |
|
149 |
"Modified: 23.4.1996 / 17:09:48 / cg" |
|
150 |
"Created: 23.4.1996 / 17:11:46 / cg" |
|
84 | 151 |
! ! |
152 |
||
153 |
!AboutBox methodsFor:'initialization'! |
|
154 |
||
498 | 155 |
initialize |
2727 | 156 |
"setup the box; change all of my components viewBackground to some darkish grey." |
498 | 157 |
|
107 | 158 |
|dark green lbl| |
84 | 159 |
|
160 |
super initialize. |
|
161 |
||
498 | 162 |
"/ self label:'About ...'. |
84 | 163 |
|
2727 | 164 |
green := self class defaultGreen. |
165 |
dark := Color grey:10. |
|
166 |
device hasColors ifFalse:[ |
|
167 |
device hasGrayscales ifTrue:[ |
|
168 |
green := Color brightness:(green brightness). |
|
169 |
dark := Color brightness:(dark brightness). |
|
170 |
] ifFalse:[ |
|
171 |
green := Color white. |
|
172 |
dark := Color black. |
|
173 |
] |
|
84 | 174 |
]. |
175 |
||
452
33ce1b3cd502
oops - the last one was wrong
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
176 |
self withAllSubViewsDo:[:s | s viewBackground:dark]. |
248 | 177 |
|
5834
2a6457a7d2d7
Use #image: instead of obsolete #form:
Stefan Vogel <sv@exept.de>
parents:
5554
diff
changeset
|
178 |
self image:(self class defaultIcon). |
452
33ce1b3cd502
oops - the last one was wrong
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
179 |
(lbl := self formLabel) viewBackground:dark. |
33ce1b3cd502
oops - the last one was wrong
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
180 |
lbl foregroundColor:green backgroundColor:dark. |
33ce1b3cd502
oops - the last one was wrong
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
181 |
(lbl := self textLabel) viewBackground:dark. |
33ce1b3cd502
oops - the last one was wrong
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
182 |
lbl foregroundColor:White backgroundColor:dark. |
33ce1b3cd502
oops - the last one was wrong
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
183 |
|
33ce1b3cd502
oops - the last one was wrong
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
184 |
self title:(self class aboutText). |
6625 | 185 |
self okText:(resources string:'Close'). |
452
33ce1b3cd502
oops - the last one was wrong
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
186 |
|
1592 | 187 |
"Modified: / 12.6.1998 / 11:48:23 / cg" |
84 | 188 |
! ! |
189 |
||
4864 | 190 |
!AboutBox methodsFor:'show & hide'! |
84 | 191 |
|
192 |
show |
|
498 | 193 |
"show the box. |
194 |
Redefined to automatically hide myself after some time" |
|
100 | 195 |
|
708
f89ff543ea18
Display expiration time, if apropriate.
Stefan Vogel <sv@exept.de>
parents:
693
diff
changeset
|
196 |
self autoHideAfter:15 with:[]. |
84 | 197 |
super showAtCenter. |
198 |
||
199 |
" |
|
200 |
AboutBox new show |
|
201 |
" |
|
498 | 202 |
|
203 |
"Modified: 23.4.1996 / 17:10:03 / cg" |
|
708
f89ff543ea18
Display expiration time, if apropriate.
Stefan Vogel <sv@exept.de>
parents:
693
diff
changeset
|
204 |
"Modified: 6.9.1996 / 09:47:10 / stefan" |
84 | 205 |
! ! |
206 |
||
879 | 207 |
!AboutBox class methodsFor:'documentation'! |
248 | 208 |
|
209 |
version |
|
6625 | 210 |
^ '$Header: /cvs/stx/stx/libtool/AboutBox.st,v 1.31 2006-03-06 08:37:10 cg Exp $' |
248 | 211 |
! ! |