ListSelectionBox.st
author claus
Sat, 08 Jan 1994 18:27:56 +0100
changeset 21 9ef599238fea
parent 12 1c8e8c53e8cf
child 38 4b9b70b2cc87
permissions -rw-r--r--
*** empty log message ***

"
 COPYRIGHT (c) 1990 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.
"

EnterBox subclass:#ListSelectionBox
       instanceVariableNames:'selectionList'
       classVariableNames:''
       poolDictionaries:''
       category:'Views-Interactors'
!

ListSelectionBox comment:'

COPYRIGHT (c) 1990 by Claus Gittinger
              All Rights Reserved

this class implements boxes for selection from a list

$Header: /cvs/stx/stx/libwidg/ListSelectionBox.st,v 1.4 1993-12-16 11:03:01 claus Exp $

written Jan 90 by claus
'!

!ListSelectionBox class methodsFor:'defaults'!

defaultExtent
    ^ (Display pixelPerMillimeter * (80 @ 100)) rounded
!

listViewType
    "return the type of listView 
     - for easier redefinition in subclasses"

    ^ SelectionInListView
! !

!ListSelectionBox class methodsFor:'instance creation'!

title:titleString okText:okText abortText:abortText list:aList action:aBlock
    "create and return a new listSelectionBox with list already defined"

    |newBox|

    newBox := super title:titleString okText:okText abortText:abortText
                    action:aBlock.
    ^ newBox list:aList
! !

!ListSelectionBox methodsFor:'initialization'!

initialize
    |space2 v|

    super initialize.

    "need more space than an enterBox"

    "self height:(height + (font height * 5)).  "

    space2 := 2 * ViewSpacing.

    v := ScrollableView for:(self class listViewType) in:self.

    "kludge: see note in EnterBox"
    v origin:(ViewSpacing
              @
              (enterField origin y + enterField height + ViewSpacing)).
    v extent:((width - space2 - (v borderWidth * 2))
              @ 
              (height  
               - ViewSpacing - labelField heightIncludingBorder
               - ViewSpacing - enterField heightIncludingBorder
               - buttonPanel heightIncludingBorder - ViewSpacing
               - space2)
             ).
    v origin:[ViewSpacing
              @
              (enterField origin y + enterField height + ViewSpacing)]
      extent:[(width - space2 - (v borderWidth * 2))
              @ 
              (height
               - ViewSpacing - labelField heightIncludingBorder
               - ViewSpacing - enterField heightIncludingBorder
               - buttonPanel heightIncludingBorder - ViewSpacing
               - space2)
             ].
    selectionList := v scrolledView.

    "self updateList."

    "selections in list get forwarded to enterfield"
    selectionList action:[:lineNr |
        enterField contents:(selectionList selectionValue)
    ].
    selectionList keyboardHandler:enterField
!

updateList
    "setup contents of list; nothing done here but redefined in subclasses"

    ^ self
!

realize
    self updateList.
    super realize
! !

!ListSelectionBox methodsFor:'private'!

resize
    "resize myself to make everything visible"

    |wWanted hWanted|

    wWanted := labelField width + ViewSpacing + ViewSpacing.
    (wWanted > width) ifFalse:[
        wWanted := width
    ].
    hWanted := ViewSpacing + labelField height +
               ViewSpacing + enterField height +
               ViewSpacing + selectionList height +
               ViewSpacing + buttonPanel height +
               ViewSpacing.

    (hWanted < height) ifTrue:[
        hWanted := height
    ].
    self extent:(wWanted @ hWanted)
! !

!ListSelectionBox methodsFor:'accessing'!

list:aList
    "set the list to be displayed in selection list"

    selectionList list:aList
! !