eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'OptionBox':

Home

everywhere
www.exept.de
for:
[back]

Class: OptionBox


Inheritance:

   Object
   |
   +--GraphicsContext
      |
      +--DeviceGraphicsContext
         |
         +--GraphicsMedium
            |
            +--DisplaySurface
               |
               +--SimpleView
                  |
                  +--View
                     |
                     +--TopView
                        |
                        +--StandardSystemView
                           |
                           +--ModalBox
                              |
                              +--DialogBox
                                 |
                                 +--OptionBox

Package:
stx:libwidg
Category:
Views-DialogBoxes
Version:
rev: 1.70 date: 2009/09/23 15:28:00
user: cg
file: OptionBox.st directory: libwidg
module: stx stc-classLibrary: libwidg
Author:
Claus Gittinger

Description:


CAVEAT: this is a leftover - functionality has been merged into DialogBox
PLEASE use one of the `Dialog chooseXXX' methods instead of OptionBox.


Historic note:
   originally, ST/X had separate classes for the various entry methods;
   there were YesNoBox, EnterBox, InfoBox and so on.
   In the meantime, the DialogBox class (and therefore its alias: Dialog)
   is going to duplicate most funcionality found in these classes.

   In the future, those existing subclasses' functionality is going to
   be moved fully into Dialog, and the subclasses will be replaced by dummy
   delegators. (They will be kept for backward compatibility, though).


 OptionBoxes are like YesNoBoxes but with as many buttons as you like;
 this will finally be a superclass of WarnBox and YesNoBox - or maybe merged
 all into DialogBox..
 Use them for multiway questions.
 For a consistent user interface, the rightmost button is the default return
 button (i.e. pressing return in the box performs this buttons function).


Related information:

    DialogBox

Class protocol:

easy startup
o  forRequest: title label: label image: anImage buttonLabels: labels values: values default: defaultValue
create a new optionBox and return it.
Does not open the box.

o  request: title buttonLabels: labels values: values
create a new optionBox, open it modal and return the value of
the corresponding values collection. Return nil if cancelled

o  request: title buttonLabels: labels values: values default: defaultValue
create a new optionBox, open it modal and return the value of
the corresponding values collection. Return nil if cancelled.

o  request: title label: label buttonLabels: labels values: values
create a new optionBox, open it modal and return the value of
the corresponding values collection. Return nil if cancelled

o  request: title label: label buttonLabels: labels values: values default: defaultValue
create a new optionBox, open it modal and return the value of
the corresponding values collection. Return nil if cancelled

o  request: title label: label buttonLabels: labels values: values default: defaultValue onCancel: cancelValue
create a new optionBox, open it modal and return the value of
the corresponding values collection. Return cancelValue if cancelled.

o  request: title label: label image: anImage buttonLabels: labels values: values
create a new optionBox, open it modal and return the value of
the corresponding values collection. Return nil, if cancelled.

o  request: title label: label image: anImage buttonLabels: labels values: values default: defaultValue
create a new optionBox, open it modal and return the value of
the corresponding values collection. Return nil if cancelled.

o  request: title label: label image: anImage buttonLabels: labels values: values default: defaultValue onCancel: cancelValue
create a new optionBox, open it modal and return the value of
the corresponding values collection. Return cancelValue if cancelled.

instance creation
o  title: titleString numberOfOptions: nOptions
create a new optionBox with title, aTitleString and nOptions options

obsolete
o  forRequest: title label: label form: anImage buttonLabels: labels values: values default: defaultValue
create a new optionBox and return it.
Does not open the box.

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  request: title label: label form: aForm buttonLabels: labels values: values
create a new optionBox, open it modal and return the value of
the corresponding values collection. Return nil, if cancelled.

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  request: title label: label form: aForm buttonLabels: labels values: values default: defaultValue
create a new optionBox, open it modal and return the value of
the corresponding values collection. Return nil if cancelled.

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  request: title label: label form: aForm buttonLabels: labels values: values default: defaultValue onCancel: cancelValue
create a new optionBox, open it modal and return the value of
the corresponding values collection. Return cancelValue if cancelled.

** This is an obsolete interface - do not use it (it may vanish in future versions) **


Instance protocol:

accessing
o  action: actionBlock
define a single the action for all buttons.
The action will be evaluated with the button index as argument.

o  actions: actionBlocks
define the actions

o  buttonTitles: titles actions: actionBlocks
define both button titles and actions

o  defaultButtonIndex: index
define which button is the default (i.e. return-) button.
By default, no returnButton is setup. The argument must be an
index 1..nButtons, or nil

o  numberOfOptions
return the number of options

o  numberOfOptions: nOptions
set the number of options - this is a private interface

accessing-components
o  addCheckBox: label on: aValueHolder

o  buttons
return the buttons collection

o  labelPanel

accessing-look
o  buttonTitles: titles
set the button titles

o  form: aFormOrImage
historical leftover - define a form to be displayed left of the title

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  formLabel
return the label-view which displays a bitmap

o  image: aFormOrImage
set the image shown in the label-view

o  textLabel
return the label-view which displays a message string

o  title: aString
set the boxes title

o  title: aString numberOfOptions: nOptions
set the boxes title and number of options

events
o  keyPress: aKey x: x y: y
return-key duplicates ok-function if acceptReturnAsOK is true

initialization
o  initFormBitmap

o  initialize

queries
o  preferredExtent
return a size to make everything fit into myself


Examples:



    |box|

    box := OptionBox title:'hello' numberOfOptions:4.
    box showAtPointer


    |box|
    box := OptionBox title:'hello' numberOfOptions:3.
    box buttonTitles:#('one' 'two' 'three').
    box showAtPointer
performing an action:


    |box|
    box := OptionBox title:'hello' numberOfOptions:3.
    box buttonTitles:#('one' 'two' 'three').
    box action:[:which | Transcript show:'button ';
                                    show: which;
                                    showCR:' was pressed'].
    box showAtPointer
returning a value:


    |what|

    what := OptionBox 
                  request:('text has not been accepted.\\Your modifications will be lost when continuing.') withCRs
                  label:' Attention'
                  image:(WarningBox iconBitmap)
                  buttonLabels:#('Abort' 'Accept' 'Continue')
                  values:#(#abort #accept #continue).
    Transcript showCR:what.
use callBack-hook to intercept creation:


    |what|

    AboutToOpenBoxNotificationSignal handle:[:ex |
        |box|

        box := ex parameter.
        box verticalPanel 
            add:(CheckBox label:'Do no show this Dialog again.'
                          model:false asValue).
        ex proceed.
    ] do:[
        what := OptionBox 
                      request:('bla bla bla bla.\\You must bla bla bla!') withCRs
                      label:' Attention'
                      image:(WarningBox iconBitmap)
                      buttonLabels:#('Abort' 'Accept' 'Continue')
                      values:#(#abort #accept #continue)
                      default:#continue.
    ].
    Transcript showCR:what.


ST/X 6.1.1; WebServer 1.620 at exept:8081; Tue, 22 May 2012 21:30:58 GMT