author | Claus Gittinger <cg@exept.de> |
Thu, 16 Oct 2008 10:39:36 +0200 | |
changeset 8334 | db98cf285160 |
parent 7961 | f5545f9cf057 |
child 8701 | 3e4346724b96 |
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 |
|
7795 | 84 |
|distributor expiration machine info resources| |
85 |
||
86 |
resources := self classResources. |
|
179
f464e3c75104
if nonEmpty, display distributorString
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
87 |
|
693 | 88 |
distributor := Smalltalk distributorString. |
89 |
distributor notEmpty ifTrue:[ |
|
7795 | 90 |
distributor := (((resources string:'Distributor') , ' ') paddedTo:20 with:$.) , ' ' , distributor |
708
f89ff543ea18
Display expiration time, if apropriate.
Stefan Vogel <sv@exept.de>
parents:
693
diff
changeset
|
91 |
]. |
f89ff543ea18
Display expiration time, if apropriate.
Stefan Vogel <sv@exept.de>
parents:
693
diff
changeset
|
92 |
expiration := Smalltalk expirationTime. |
f89ff543ea18
Display expiration time, if apropriate.
Stefan Vogel <sv@exept.de>
parents:
693
diff
changeset
|
93 |
expiration notNil ifTrue:[ |
7795 | 94 |
expiration := (((resources string:'Expires') , ' ') paddedTo:20 with:$.) , ' ' , expiration |
708
f89ff543ea18
Display expiration time, if apropriate.
Stefan Vogel <sv@exept.de>
parents:
693
diff
changeset
|
95 |
] ifFalse:[ |
f89ff543ea18
Display expiration time, if apropriate.
Stefan Vogel <sv@exept.de>
parents:
693
diff
changeset
|
96 |
expiration := ''. |
693 | 97 |
]. |
1797 | 98 |
machine := OperatingSystem getHostName. |
99 |
info := OperatingSystem getSystemInfo. |
|
100 |
(info includesKey:#machine) ifTrue:[ |
|
101 |
machine := machine , ' (' , (info at:#machine) , ')' |
|
102 |
]. |
|
179
f464e3c75104
if nonEmpty, display distributorString
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
103 |
|
92 | 104 |
^ |
7721 | 105 |
'Smalltalk/X |
92 | 106 |
|
7795 | 107 |
' , (((resources string:'Version') , ' ') paddedTo:20 with:$.) , ' ', Smalltalk versionString , '.' , Smalltalk releaseNr printString , |
498 | 108 |
' (' , Smalltalk versionDate printString , ') |
708
f89ff543ea18
Display expiration time, if apropriate.
Stefan Vogel <sv@exept.de>
parents:
693
diff
changeset
|
109 |
', distributor, ' |
f89ff543ea18
Display expiration time, if apropriate.
Stefan Vogel <sv@exept.de>
parents:
693
diff
changeset
|
110 |
', expiration , ' |
7795 | 111 |
' , (((resources string:'Release ID') , ' ') paddedTo:20 with:$.) , ' ' , Smalltalk releaseIdentification , ' |
112 |
' , (((resources string:'Configuration') , ' ') paddedTo:20 with:$.) , ' ' , Smalltalk configuration , ' |
|
113 |
' , (((resources string:'Running on') , ' ') paddedTo:20 with:$.) , ' ' , machine , ' |
|
114 |
' , (((resources string:'Started at') , ' ') paddedTo:20 with:$.) , ' ' , Smalltalk imageStartTime printString , ' |
|
92 | 115 |
|
179
f464e3c75104
if nonEmpty, display distributorString
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
116 |
' , Smalltalk copyrightString , ' |
f464e3c75104
if nonEmpty, display distributorString
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
117 |
|
693 | 118 |
' |
179
f464e3c75104
if nonEmpty, display distributorString
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
119 |
|
7721 | 120 |
"Modified: / 06-09-1996 / 10:11:08 / stefan" |
7795 | 121 |
"Modified: / 16-04-2007 / 16:17:34 / cg" |
198 | 122 |
! |
123 |
||
2727 | 124 |
defaultGreen |
125 |
"return the boxes default green color (eXept green)." |
|
126 |
||
127 |
DefaultGreen notNil ifTrue:[^ DefaultGreen]. |
|
128 |
^ Color red:0 green:80 blue:20 |
|
129 |
! |
|
130 |
||
198 | 131 |
defaultIcon |
7839 | 132 |
<resource: #programImage> |
133 |
||
498 | 134 |
"return a smalltalk/X icon. |
135 |
Can be redefined in custom subclasses." |
|
198 | 136 |
|
137 |
CachedIcon isNil ifTrue:[ |
|
2169 | 138 |
CachedIcon := Icon stxIcon. |
139 |
CachedIcon isNil ifTrue:[ |
|
2477 | 140 |
CachedIcon := Smalltalk imageFromFileNamed:'SmalltalkX.xbm' inPackage:'stx:libtool' |
2169 | 141 |
] |
198 | 142 |
]. |
143 |
^ CachedIcon |
|
498 | 144 |
|
7839 | 145 |
"Modified: / 17-09-2007 / 11:34:56 / cg" |
498 | 146 |
! |
147 |
||
148 |
defaultLabel |
|
149 |
"return the boxes default window title." |
|
150 |
||
6625 | 151 |
^ 'About...' |
498 | 152 |
|
153 |
"Modified: 23.4.1996 / 17:09:48 / cg" |
|
154 |
"Created: 23.4.1996 / 17:11:46 / cg" |
|
84 | 155 |
! ! |
156 |
||
157 |
!AboutBox methodsFor:'initialization'! |
|
158 |
||
498 | 159 |
initialize |
2727 | 160 |
"setup the box; change all of my components viewBackground to some darkish grey." |
498 | 161 |
|
107 | 162 |
|dark green lbl| |
84 | 163 |
|
164 |
super initialize. |
|
165 |
||
498 | 166 |
"/ self label:'About ...'. |
84 | 167 |
|
2727 | 168 |
green := self class defaultGreen. |
7961
f5545f9cf057
aboutToObenBoxNotification for aboutBox
Claus Gittinger <cg@exept.de>
parents:
7839
diff
changeset
|
169 |
dark := Color grey:20. |
2727 | 170 |
device hasColors ifFalse:[ |
171 |
device hasGrayscales ifTrue:[ |
|
172 |
green := Color brightness:(green brightness). |
|
173 |
dark := Color brightness:(dark brightness). |
|
174 |
] ifFalse:[ |
|
175 |
green := Color white. |
|
176 |
dark := Color black. |
|
177 |
] |
|
84 | 178 |
]. |
179 |
||
452
33ce1b3cd502
oops - the last one was wrong
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
180 |
self withAllSubViewsDo:[:s | s viewBackground:dark]. |
248 | 181 |
|
5834
2a6457a7d2d7
Use #image: instead of obsolete #form:
Stefan Vogel <sv@exept.de>
parents:
5554
diff
changeset
|
182 |
self image:(self class defaultIcon). |
452
33ce1b3cd502
oops - the last one was wrong
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
183 |
(lbl := self formLabel) viewBackground:dark. |
33ce1b3cd502
oops - the last one was wrong
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
184 |
lbl foregroundColor:green backgroundColor:dark. |
33ce1b3cd502
oops - the last one was wrong
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
185 |
(lbl := self textLabel) viewBackground:dark. |
33ce1b3cd502
oops - the last one was wrong
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
186 |
lbl foregroundColor:White backgroundColor:dark. |
33ce1b3cd502
oops - the last one was wrong
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
187 |
|
33ce1b3cd502
oops - the last one was wrong
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
188 |
self title:(self class aboutText). |
6625 | 189 |
self okText:(resources string:'Close'). |
452
33ce1b3cd502
oops - the last one was wrong
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
190 |
|
1592 | 191 |
"Modified: / 12.6.1998 / 11:48:23 / cg" |
84 | 192 |
! ! |
193 |
||
4864 | 194 |
!AboutBox methodsFor:'show & hide'! |
84 | 195 |
|
196 |
show |
|
498 | 197 |
"show the box. |
198 |
Redefined to automatically hide myself after some time" |
|
100 | 199 |
|
708
f89ff543ea18
Display expiration time, if apropriate.
Stefan Vogel <sv@exept.de>
parents:
693
diff
changeset
|
200 |
self autoHideAfter:15 with:[]. |
84 | 201 |
super showAtCenter. |
202 |
||
203 |
" |
|
204 |
AboutBox new show |
|
205 |
" |
|
498 | 206 |
|
207 |
"Modified: 23.4.1996 / 17:10:03 / cg" |
|
708
f89ff543ea18
Display expiration time, if apropriate.
Stefan Vogel <sv@exept.de>
parents:
693
diff
changeset
|
208 |
"Modified: 6.9.1996 / 09:47:10 / stefan" |
84 | 209 |
! ! |
210 |
||
879 | 211 |
!AboutBox class methodsFor:'documentation'! |
248 | 212 |
|
213 |
version |
|
7961
f5545f9cf057
aboutToObenBoxNotification for aboutBox
Claus Gittinger <cg@exept.de>
parents:
7839
diff
changeset
|
214 |
^ '$Header: /cvs/stx/stx/libtool/AboutBox.st,v 1.35 2008-02-04 15:37:02 cg Exp $' |
248 | 215 |
! ! |