author | Claus Gittinger <cg@exept.de> |
Wed, 09 Feb 2011 14:03:29 +0100 | |
changeset 9750 | 1b2ef761d2d0 |
parent 8988 | 8a0410006a9c |
child 9801 | 536bda9c36ce |
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 |
" |
|
2700 | 12 |
"{ Package: 'stx:libtool' }" |
13 |
||
84 | 14 |
InfoBox subclass:#AboutBox |
451
35d5ba59ee0e
added access method for background color
Claus Gittinger <cg@exept.de>
parents:
248
diff
changeset
|
15 |
instanceVariableNames:'' |
2727 | 16 |
classVariableNames:'CachedIcon DefaultGreen' |
451
35d5ba59ee0e
added access method for background color
Claus Gittinger <cg@exept.de>
parents:
248
diff
changeset
|
17 |
poolDictionaries:'' |
35d5ba59ee0e
added access method for background color
Claus Gittinger <cg@exept.de>
parents:
248
diff
changeset
|
18 |
category:'Views-DialogBoxes' |
84 | 19 |
! |
20 |
||
879 | 21 |
!AboutBox class methodsFor:'documentation'! |
84 | 22 |
|
198 | 23 |
copyright |
24 |
" |
|
25 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
84 | 35 |
! |
36 |
||
37 |
documentation |
|
38 |
" |
|
2700 | 39 |
A box specialized to show the ST/X about-information (also usable for Applications). |
498 | 40 |
As a speciality, this box automatically closes if left |
41 |
alone for a while. |
|
84 | 42 |
|
498 | 43 |
Can be subclasses for your own aboutBoxes; to do so, redefine |
44 |
#defaultIcon and #aboutText. |
|
92 | 45 |
|
498 | 46 |
examples: |
47 |
AboutBox new open |
|
48 |
||
49 |
AboutBox new showAtPointer |
|
84 | 50 |
" |
2700 | 51 |
! |
52 |
||
53 |
examples |
|
54 |
" |
|
55 |
[exBegin] |
|
56 |
|box| |
|
57 |
||
58 |
box := AboutBox new. |
|
59 |
box autoHideAfter:10 with:[]. |
|
60 |
box showAtCenter |
|
61 |
[exEnd] |
|
62 |
||
63 |
[exBegin] |
|
64 |
|box| |
|
65 |
||
66 |
box := AboutBox title:'About me'. |
|
5333 | 67 |
box image:((Smalltalk |
68 |
bitmapFromFileNamed:'gifImages/claus.gif' |
|
69 |
inPackage:'stx:goodies') |
|
70 |
magnifiedTo:100@100). |
|
2700 | 71 |
box label:'Example'. |
72 |
box autoHideAfter:10 with:[]. |
|
73 |
box showAtPointer. |
|
74 |
[exEnd] |
|
75 |
" |
|
84 | 76 |
! ! |
77 |
||
879 | 78 |
!AboutBox class methodsFor:'defaults'! |
84 | 79 |
|
92 | 80 |
aboutText |
498 | 81 |
"return a string to be shown in the box. |
82 |
Can be redefined in custom subclasses." |
|
125 | 83 |
|
8701 | 84 |
|paddedLabelWith distributor expiration machine info resources| |
7795 | 85 |
|
86 |
resources := self classResources. |
|
179
f464e3c75104
if nonEmpty, display distributorString
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
87 |
|
8701 | 88 |
paddedLabelWith := |
89 |
[:label :value | |
|
90 |
(((resources string:label) , ' ') paddedTo:20 with:$.) , ' ' , value |
|
91 |
]. |
|
92 |
||
693 | 93 |
distributor := Smalltalk distributorString. |
94 |
distributor notEmpty ifTrue:[ |
|
8701 | 95 |
distributor := paddedLabelWith value:'Distributor' value:distributor |
708
f89ff543ea18
Display expiration time, if apropriate.
Stefan Vogel <sv@exept.de>
parents:
693
diff
changeset
|
96 |
]. |
f89ff543ea18
Display expiration time, if apropriate.
Stefan Vogel <sv@exept.de>
parents:
693
diff
changeset
|
97 |
expiration := Smalltalk expirationTime. |
f89ff543ea18
Display expiration time, if apropriate.
Stefan Vogel <sv@exept.de>
parents:
693
diff
changeset
|
98 |
expiration notNil ifTrue:[ |
8701 | 99 |
expiration := paddedLabelWith value:'Expires' value:expiration |
708
f89ff543ea18
Display expiration time, if apropriate.
Stefan Vogel <sv@exept.de>
parents:
693
diff
changeset
|
100 |
] ifFalse:[ |
f89ff543ea18
Display expiration time, if apropriate.
Stefan Vogel <sv@exept.de>
parents:
693
diff
changeset
|
101 |
expiration := ''. |
693 | 102 |
]. |
1797 | 103 |
machine := OperatingSystem getHostName. |
104 |
info := OperatingSystem getSystemInfo. |
|
105 |
(info includesKey:#machine) ifTrue:[ |
|
106 |
machine := machine , ' (' , (info at:#machine) , ')' |
|
107 |
]. |
|
179
f464e3c75104
if nonEmpty, display distributorString
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
108 |
|
92 | 109 |
^ |
7721 | 110 |
'Smalltalk/X |
92 | 111 |
|
8701 | 112 |
' , (paddedLabelWith value:'Version' value:Smalltalk versionString),'.', Smalltalk releaseNr printString , |
498 | 113 |
' (' , Smalltalk versionDate printString , ') |
708
f89ff543ea18
Display expiration time, if apropriate.
Stefan Vogel <sv@exept.de>
parents:
693
diff
changeset
|
114 |
', distributor, ' |
f89ff543ea18
Display expiration time, if apropriate.
Stefan Vogel <sv@exept.de>
parents:
693
diff
changeset
|
115 |
', expiration , ' |
8701 | 116 |
' , (paddedLabelWith value:'Release ID' value:Smalltalk releaseIdentification) , ' |
117 |
' , (paddedLabelWith value:'Configuration' value:Smalltalk configuration) , ' |
|
118 |
' , (paddedLabelWith value:'Running on' value:machine) , ' |
|
119 |
' , (paddedLabelWith value:'Started at' value:Smalltalk imageStartTime printString) , ' |
|
92 | 120 |
|
179
f464e3c75104
if nonEmpty, display distributorString
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
121 |
' , Smalltalk copyrightString , ' |
f464e3c75104
if nonEmpty, display distributorString
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
122 |
|
693 | 123 |
' |
179
f464e3c75104
if nonEmpty, display distributorString
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
124 |
|
7721 | 125 |
"Modified: / 06-09-1996 / 10:11:08 / stefan" |
7795 | 126 |
"Modified: / 16-04-2007 / 16:17:34 / cg" |
198 | 127 |
! |
128 |
||
2727 | 129 |
defaultGreen |
130 |
"return the boxes default green color (eXept green)." |
|
131 |
||
132 |
DefaultGreen notNil ifTrue:[^ DefaultGreen]. |
|
133 |
^ Color red:0 green:80 blue:20 |
|
134 |
! |
|
135 |
||
198 | 136 |
defaultIcon |
7839 | 137 |
<resource: #programImage> |
138 |
||
498 | 139 |
"return a smalltalk/X icon. |
140 |
Can be redefined in custom subclasses." |
|
198 | 141 |
|
142 |
CachedIcon isNil ifTrue:[ |
|
8988 | 143 |
CachedIcon := Icon stxIconTransparent3. |
2169 | 144 |
CachedIcon isNil ifTrue:[ |
2477 | 145 |
CachedIcon := Smalltalk imageFromFileNamed:'SmalltalkX.xbm' inPackage:'stx:libtool' |
2169 | 146 |
] |
198 | 147 |
]. |
148 |
^ CachedIcon |
|
498 | 149 |
|
8988 | 150 |
" |
151 |
CachedIcon := nil |
|
152 |
" |
|
153 |
||
7839 | 154 |
"Modified: / 17-09-2007 / 11:34:56 / cg" |
498 | 155 |
! |
156 |
||
157 |
defaultLabel |
|
158 |
"return the boxes default window title." |
|
159 |
||
6625 | 160 |
^ 'About...' |
498 | 161 |
|
162 |
"Modified: 23.4.1996 / 17:09:48 / cg" |
|
163 |
"Created: 23.4.1996 / 17:11:46 / cg" |
|
84 | 164 |
! ! |
165 |
||
8988 | 166 |
!AboutBox class methodsFor:'image specs'! |
167 |
||
168 |
stxIconTemplate |
|
169 |
"This resource specification was automatically generated |
|
170 |
by the ImageEditor of ST/X." |
|
171 |
||
172 |
"Do not manually edit this!! If it is corrupted, |
|
173 |
the ImageEditor may not be able to read the specification." |
|
174 |
||
175 |
" |
|
176 |
self stxIconTemplate inspect |
|
177 |
ImageEditor openOnClass:self andSelector:#stxIconTemplate |
|
178 |
Icon flushCachedIcons |
|
179 |
" |
|
180 |
||
181 |
<resource: #image> |
|
182 |
||
183 |
^Icon |
|
184 |
constantNamed:'AboutBox class stxIconTemplate' |
|
185 |
ifAbsentPut:[(Depth1Image new) width: 48; height: 48; photometric:(#palette); bitsPerSample:(#[1]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:' |
|
186 |
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
|
187 |
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
|
188 |
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
|
189 |
@@@@@@@@@@@@@@@@@@@@@@@@') ; colorMapFromArray:#[0 0 0]; mask:((Depth1Image new) width: 48; height: 48; photometric:(#blackIs0); bitsPerSample:(#[1]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:' |
|
190 |
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@G@@@A @@O @@C@@@O @@F@@@O @@L@@@O0@@\@@@O0@@8@@@G0@A0@@@G8@C @@@C8@G@@@@C<@N@@ |
|
191 |
@@A<@\@@@@A>@8@@@@@>A0@@@@@_C @@@@@_G @@@@@O/@@@@@@O>@@@@@@G<@@@@@@G8@@@@@@C8@@@@@@G8@@@@@@O<@@@@@@_<@@@@@@>^@@@@@A<N@@@ |
|
192 |
@@C8O@@@@@O0G @@@@_ C @@@@?@A0@@@A>@A0@@@C<@@8@@@O8@@\@@@_0@@L@@@? @@N@@@? @@F@@@?@@@C@@@^@@@A@@@@@@@@ @@@@@@@@@@@@@@@@@ |
|
193 |
@@@@@@@@@@@@@@@@@@@@@@@@') ; yourself); yourself] |
|
194 |
! ! |
|
195 |
||
84 | 196 |
!AboutBox methodsFor:'initialization'! |
197 |
||
498 | 198 |
initialize |
2727 | 199 |
"setup the box; change all of my components viewBackground to some darkish grey." |
498 | 200 |
|
107 | 201 |
|dark green lbl| |
84 | 202 |
|
203 |
super initialize. |
|
204 |
||
498 | 205 |
"/ self label:'About ...'. |
84 | 206 |
|
2727 | 207 |
green := self class defaultGreen. |
7961
f5545f9cf057
aboutToObenBoxNotification for aboutBox
Claus Gittinger <cg@exept.de>
parents:
7839
diff
changeset
|
208 |
dark := Color grey:20. |
2727 | 209 |
device hasColors ifFalse:[ |
210 |
device hasGrayscales ifTrue:[ |
|
211 |
green := Color brightness:(green brightness). |
|
212 |
dark := Color brightness:(dark brightness). |
|
213 |
] ifFalse:[ |
|
214 |
green := Color white. |
|
215 |
dark := Color black. |
|
216 |
] |
|
84 | 217 |
]. |
218 |
||
452
33ce1b3cd502
oops - the last one was wrong
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
219 |
self withAllSubViewsDo:[:s | s viewBackground:dark]. |
248 | 220 |
|
5834
2a6457a7d2d7
Use #image: instead of obsolete #form:
Stefan Vogel <sv@exept.de>
parents:
5554
diff
changeset
|
221 |
self image:(self class defaultIcon). |
452
33ce1b3cd502
oops - the last one was wrong
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
222 |
(lbl := self formLabel) viewBackground:dark. |
33ce1b3cd502
oops - the last one was wrong
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
223 |
lbl foregroundColor:green backgroundColor:dark. |
33ce1b3cd502
oops - the last one was wrong
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
224 |
(lbl := self textLabel) viewBackground:dark. |
33ce1b3cd502
oops - the last one was wrong
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
225 |
lbl foregroundColor:White backgroundColor:dark. |
33ce1b3cd502
oops - the last one was wrong
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
226 |
|
33ce1b3cd502
oops - the last one was wrong
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
227 |
self title:(self class aboutText). |
6625 | 228 |
self okText:(resources string:'Close'). |
452
33ce1b3cd502
oops - the last one was wrong
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
229 |
|
1592 | 230 |
"Modified: / 12.6.1998 / 11:48:23 / cg" |
84 | 231 |
! ! |
232 |
||
4864 | 233 |
!AboutBox methodsFor:'show & hide'! |
84 | 234 |
|
235 |
show |
|
498 | 236 |
"show the box. |
237 |
Redefined to automatically hide myself after some time" |
|
100 | 238 |
|
708
f89ff543ea18
Display expiration time, if apropriate.
Stefan Vogel <sv@exept.de>
parents:
693
diff
changeset
|
239 |
self autoHideAfter:15 with:[]. |
84 | 240 |
super showAtCenter. |
241 |
||
242 |
" |
|
243 |
AboutBox new show |
|
244 |
" |
|
498 | 245 |
|
246 |
"Modified: 23.4.1996 / 17:10:03 / cg" |
|
708
f89ff543ea18
Display expiration time, if apropriate.
Stefan Vogel <sv@exept.de>
parents:
693
diff
changeset
|
247 |
"Modified: 6.9.1996 / 09:47:10 / stefan" |
84 | 248 |
! ! |
249 |
||
879 | 250 |
!AboutBox class methodsFor:'documentation'! |
248 | 251 |
|
252 |
version |
|
8988 | 253 |
^ '$Header: /cvs/stx/stx/libtool/AboutBox.st,v 1.37 2009-10-14 14:07:02 cg Exp $' |
254 |
! |
|
255 |
||
256 |
version_CVS |
|
257 |
^ '$Header: /cvs/stx/stx/libtool/AboutBox.st,v 1.37 2009-10-14 14:07:02 cg Exp $' |
|
248 | 258 |
! ! |