AboutBox.st
author Stefan Vogel <sv@exept.de>
Thu, 11 Jan 2007 19:05:31 +0100
changeset 7577 9769c6225ff7
parent 6625 d8ceed41c361
child 7721 bbb68c4df2de
permissions -rw-r--r--
Rename nt.mak to bc.mak

"
 COPYRIGHT (c) 1995 by Claus Gittinger
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"

"{ Package: 'stx:libtool' }"

InfoBox subclass:#AboutBox
	instanceVariableNames:''
	classVariableNames:'CachedIcon DefaultGreen'
	poolDictionaries:''
	category:'Views-DialogBoxes'
!

!AboutBox class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1995 by Claus Gittinger
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
!

documentation
"
    A box specialized to show the ST/X about-information (also usable for Applications).
    As a speciality, this box automatically closes if left
    alone for a while.

    Can be subclasses for your own aboutBoxes; to do so, redefine
    #defaultIcon and #aboutText.

    examples:
        AboutBox new open

        AboutBox new showAtPointer
"
!

examples
"
                                                                [exBegin]
    |box|

    box := AboutBox new.
    box autoHideAfter:10 with:[].
    box showAtCenter
                                                                [exEnd]

                                                                [exBegin]
    |box|

    box := AboutBox title:'About me'.
    box image:((Smalltalk 
                    bitmapFromFileNamed:'gifImages/claus.gif' 
                    inPackage:'stx:goodies') 
                magnifiedTo:100@100).
    box label:'Example'.
    box autoHideAfter:10 with:[].
    box showAtPointer.
                                                                [exEnd]
"
! !

!AboutBox class methodsFor:'defaults'!

aboutText
    "return a string to be shown in the box.
     Can be redefined in custom subclasses."

    |distributor expiration machine info|

    distributor := Smalltalk distributorString.
    distributor notEmpty ifTrue:[
        distributor := (((self classResources string:'Distributor') , ' ') paddedTo:20 with:$.) , ' ' , distributor
    ].
    expiration := Smalltalk expirationTime.
    expiration notNil ifTrue:[
        expiration := (((self classResources string:'Expires') , ' ') paddedTo:20 with:$.) , ' ' , expiration
    ] ifFalse:[
        expiration := ''.
    ].
    machine := OperatingSystem getHostName.
    info := OperatingSystem getSystemInfo.
    (info includesKey:#machine) ifTrue:[
        machine := machine , ' (' , (info at:#machine) , ')'
    ].

    ^
'SmallTalk/X

' , (((self classResources string:'Version') , ' ') paddedTo:20 with:$.) , ' ', Smalltalk versionString , '.' , Smalltalk releaseNr printString ,
                      ' (' , Smalltalk versionDate printString , ')
', distributor, '
', expiration , '
' , (((self classResources string:'Release ID') , ' ') paddedTo:20 with:$.) , ' ' , Smalltalk releaseIdentification , '
' , (((self classResources string:'Configuration') , ' ') paddedTo:20 with:$.) , ' ' , Smalltalk configuration , '
' , (((self classResources string:'Running on') , ' ') paddedTo:20 with:$.) , ' ' , machine , '

' , Smalltalk copyrightString , '

'

    "Modified: / 6.9.1996 / 10:11:08 / stefan"
    "Modified: / 4.8.1998 / 02:28:29 / cg"
!

defaultGreen
    "return the boxes default green color (eXept green)."

    DefaultGreen notNil ifTrue:[^ DefaultGreen].
    ^ Color red:0 green:80 blue:20
!

defaultIcon
    "return a smalltalk/X icon.
     Can be redefined in custom subclasses."

    CachedIcon isNil ifTrue:[
        CachedIcon := Icon stxIcon.
        CachedIcon isNil ifTrue:[
            CachedIcon := Smalltalk imageFromFileNamed:'SmalltalkX.xbm' inPackage:'stx:libtool'
        ]
    ].
    ^ CachedIcon

    "Modified: / 25.5.1999 / 15:44:48 / cg"
!

defaultLabel
    "return the boxes default window title."

    ^ 'About...'

    "Modified: 23.4.1996 / 17:09:48 / cg"
    "Created: 23.4.1996 / 17:11:46 / cg"
! !

!AboutBox methodsFor:'initialization'!

initialize
    "setup the box; change all of my components viewBackground to some darkish grey."

    |dark green lbl|

    super initialize.

"/    self label:'About ...'.

    green := self class defaultGreen.    
    dark := Color grey:10.
    device hasColors ifFalse:[
        device hasGrayscales ifTrue:[
            green := Color brightness:(green brightness).    
            dark := Color brightness:(dark brightness).    
        ] ifFalse:[
            green := Color white.
            dark := Color black.
        ]
    ].

    self withAllSubViewsDo:[:s | s viewBackground:dark].

    self image:(self class defaultIcon).
    (lbl := self formLabel) viewBackground:dark.
    lbl foregroundColor:green backgroundColor:dark.
    (lbl := self textLabel) viewBackground:dark.
    lbl foregroundColor:White backgroundColor:dark.

    self title:(self class aboutText).
    self okText:(resources string:'Close').

    "Modified: / 12.6.1998 / 11:48:23 / cg"
! !

!AboutBox methodsFor:'show & hide'!

show
    "show the box.
     Redefined to automatically hide myself after some time"

    self autoHideAfter:15 with:[].
    super showAtCenter.

    "
     AboutBox new show
    "

    "Modified: 23.4.1996 / 17:10:03 / cg"
    "Modified: 6.9.1996 / 09:47:10 / stefan"
! !

!AboutBox class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libtool/AboutBox.st,v 1.31 2006-03-06 08:37:10 cg Exp $'
! !