eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'OptionBox':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: OptionBox


Inheritance:

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

Package:
stx:libwidg
Category:
Views-DialogBoxes
Version:
rev: 1.83 date: 2017/11/28 13:33:49
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 functionality 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 canceled
usage example(s):
     OptionBox
        request:'please select any'
        buttonLabels:#('one' 'two' 'three')
        values:#(1 2 3)

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 canceled.
usage example(s):
     OptionBox
        request:'please select'
        buttonLabels:#('one' 'two' 'three')
        values:#(1 2 3)
        default:3

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 canceled
usage example(s):
     OptionBox
        request:'please select'
        label:'select any'
        buttonLabels:#('one' 'two' 'three')
        values:#(1 2 3)

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 canceled
usage example(s):
     OptionBox
        request:'please select'
        label:'select any'
        buttonLabels:#('one' 'two' 'three')
        values:#(1 2 3)
        default:3

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 canceled.
usage example(s):
     OptionBox
        request:'please select'
        label:'select any'
        buttonLabels:#('one' 'two' 'three')
        values:#(1 2 3)
        default:3
        onCancel:2

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 canceled.
usage example(s):
     OptionBox
        request:'please select'
        label:'select any'
        image:(WarningBox iconBitmap)
        buttonLabels:#('one' 'two' 'three')
        values:#(1 2 3)

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 canceled.
usage example(s):
     OptionBox
        request:'please select'
        label:'select any'
        image:(WarningBox iconBitmap)
        buttonLabels:#('one' 'two' 'three')
        values:#(1 2 3)
        default:3

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 canceled.
usage example(s):
     OptionBox
        request:'please select'
        label:'select any'
        image:(WarningBox iconBitmap)
        buttonLabels:#('one' 'two' 'three')
        values:#(1 2 3)
        default:3
        onCancel:nil

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 canceled.

** 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 canceled.

** 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 canceled.

** 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  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  initInfoBitmap

o  initWarnBitmap
WarnBitmap := Image fromFile:'bitmaps/Warning.xbm' resolution:100 on:Display

o  initYesNoBitmap

o  initialize
formLabel origin:(mm @ mm).

queries
o  preferredExtent
return a size to make everything fit into myself
usage example(s):
If I have an explicit preferredExtent..
usage example(s):
If I have a cached preferredExtent value..


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 7.1.0.0; WebServer 1.663 at exept.de:8081; Mon, 19 Nov 2018 21:44:31 GMT