SimpleDialog.st
author Claus Gittinger <cg@exept.de>
Tue, 17 Jun 1997 14:13:27 +0200
changeset 605 9e9445252e25
parent 485 9326c85fdf6f
child 679 0f94c493751c
permissions -rw-r--r--
checkin from browser

"
 COPYRIGHT (c) 1996 by eXept Software AG
              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.
"


ApplicationModel subclass:#SimpleDialog
	instanceVariableNames:'accept cancel close escapeIsCancel postBuildBlock postOpenBlock
		preBuildBlock'
	classVariableNames:''
	poolDictionaries:''
	category:'Interface-Framework'
!

!SimpleDialog class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1996 by eXept Software AG
              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
"
    Since many ST-80 classes are subclasses of SompleDialog, this class
    is provided here to allow easier porting of ST-80 code.

    It does not (currently) provide much functionality and is NOT
    compatible to the corresponding ST80 class; therefore, manual
    changes have to be made to get those applications to run under ST/X.
    (but at least, this enables you to fileIn that code and have a superclass
     for them)

    However, as time goes by, ST/X applications may be converted to use the
    ApplicationModel / SimpleDialog framework as well.

    Notice: this class was implemented using protocol information
    from alpha testers and PD code - it may not be complete or compatible to
    the corresponding ST-80 class. If you encounter any incompatibilities,
    please forward a note to the ST/X team.


    [author:]
        Claus Gittinger

    [see also:]
        StandardSystemView
        WindowGroup DeviceWorkstation DialogBox
"

! !

!SimpleDialog methodsFor:'accessing'!

accept
    "return the valueholder which gets set by the accept button"

    ^ accept

    "Modified: 17.6.1997 / 14:09:48 / cg"
!

bindings
    ^ builder bindings
!

cancel
    "return the valueholder which gets set by the cancel button"

    ^ cancel

    "Modified: 17.6.1997 / 14:09:55 / cg"
!

closeChannel
    "return the value of the instance variable 'close' (automatically generated)"

    ^ close
!

escapeIsCancel
    "return the value of the instance variable 'escapeIsCancel' (automatically generated)"

    ^ escapeIsCancel!

escapeIsCancel:something
    "set the value of the instance variable 'escapeIsCancel' (automatically generated)"

    escapeIsCancel := something.!

postBuildBlock:something
    "set the value of the instance variable 'postBuildBlock' (automatically generated)"

    postBuildBlock := something.!

postOpenBlock:something
    "set the value of the instance variable 'postOpenBlock' (automatically generated)"

    postOpenBlock := something.!

preBuildBlock:something
    "set the value of the instance variable 'preBuildBlock' (automatically generated)"

    preBuildBlock := something.!

source:anApplication
    builder source:anApplication
! !

!SimpleDialog methodsFor:'accessing - window'!

minWidth:nPixels
    |w box |

    w := builder window width.
    builder window width:(w max:nPixels).

"/    box := builder window displayBox.
"/    box width: (box width max: nPixels).
"/    builder window displayBox: box

    "Modified: 3.3.1997 / 21:56:27 / cg"
! !

!SimpleDialog methodsFor:'events'!

closeAccept
    "accept was pressed. close the dialog"

    self requestForWindowClose ifTrue:[
        self closeWindow
    ]

    "Modified: 17.6.1997 / 14:10:23 / cg"
!

closeCancel
    "cancel was pressed. close the dialog"

    self requestForWindowClose ifTrue:[
        self closeWindow
    ]

    "Modified: 17.6.1997 / 14:10:29 / cg"
!

closeWindow
    "close the dialog"

    self closeChannel value:true.
    builder window hide

    "Modified: 17.6.1997 / 14:10:38 / cg"
!

requestForWindowClose
    ^ true
! !

!SimpleDialog methodsFor:'initialization'!

initialize
    accept := false asValue.
    close := false asValue.
    cancel := false asValue.
    builder aspectAt:#accept put:accept.
    builder aspectAt:#close put:close.
    builder aspectAt:#cancel put:cancel.
    escapeIsCancel := true.
!

initializeBuilderFor:aView 
    aView notNil ifTrue:[
        builder window:aView.
    ]

    "Created: 3.3.1997 / 16:23:04 / cg"
!

initializeWindowFor:aView
    |v ext|

    (v := aView) isNil ifTrue:[
        v := ModalBox new.
    ].

    builder setupWindowFor:v.

    "Modified: 3.3.1997 / 20:39:46 / cg"
! !

!SimpleDialog methodsFor:'interface opening'!

allButOpenFrom:aSpec
    "create my views but do not open the main window"

    super allButOpenFrom:aSpec.
    self preOpen
!

openFor:anApplication interface:aSelector
    "open the dialog for some appModel from a given spec;
     Return true if accepted, false if canceled"

    ^ self openFor:anApplication interface:aSelector withBindings:nil

    "Modified: 28.2.1997 / 16:22:08 / cg"
!

openFor:anApplication interface:aSelector withBindings:bindings
    "open the dialog for some appModel from a given spec;
     the bindings argument may provide overwriting bindings for the
     dialog.
     Return true if accepted, false if canceled"

    builder addBindings:bindings.
    self source:anApplication.
    ^ self openFrom:(anApplication class interfaceSpecFor:aSelector)

    "Created: 28.2.1997 / 14:09:06 / cg"
    "Modified: 28.2.1997 / 16:22:00 / cg"
!

openFrom:anInterfaceSpec
    "open the dialog from a given spec;
     return true if accepted, false if canceled"

    self allButOpenFrom:anInterfaceSpec.
    self openDialog.
    ^ accept value

    "Modified: 28.2.1997 / 16:40:36 / cg"
!

preOpen
    "arrange for #closeAccept & #closeCancel to be invoked when
     either accept or close is triggered
     (usually the models of corresponding buttons)"

    accept onChangeSend:#closeAccept to:self.
    cancel onChangeSend:#closeCancel to:self.

    "Modified: 17.6.1997 / 14:13:16 / cg"
! !

!SimpleDialog methodsFor:'queries'!

defaultWindowType
    "SimpleDialogs come up modal, by default"

    ^ #dialog

    "Modified: 14.2.1997 / 22:17:20 / cg"
! !

!SimpleDialog class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libview2/SimpleDialog.st,v 1.11 1997-06-17 12:13:27 cg Exp $'
! !