eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'CheckToggle':

Home

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

Class: CheckToggle


Inheritance:

   Object
   |
   +--GraphicsMedium
      |
      +--DisplaySurface
         |
         +--SimpleView
            |
            +--View
               |
               +--Label
                  |
                  +--Button
                     |
                     +--Toggle
                        |
                        +--CheckToggle

Package:
stx:libwidg
Category:
Views-Interactors
Version:
rev: 1.80 date: 2018/11/09 23:22:42
user: cg
file: CheckToggle.st directory: libwidg
module: stx stc-classLibrary: libwidg
Author:
Claus Gittinger

Description:


CheckButtons are like Toggles in toggling their state when pressed.
However, they show an ok-marker if on; nothing if off.
CheckButtons are mostly used as part of a checkBox (since normally,
you want to have some label along the check) and often grouped for
many-in-many or one-in-many setups.

[StyleSheet values:]

    checkToggleCheckColor   <Color>         color to draw check-image with.
                                            defaults to value of #buttonActiveForegroundColor.

    checkToggleActiveBackgroundColor        background color to draw active checki-image with
    checkToggleForegroundColor              foreground color to use if off
    checkToggleBackgroundColor              background color to use if off

    checkToggleBitmapFile   <String>        name of bitmap file for check-image

    checkToggleStyle        <Symbol>        default checkForm style.
                                            used if above is nil or file not readable
                                            can be #cross or #check; defaults to #check 

    checkToggleAvtiveLevel  <Number>        active level - defaults to value of #buttonPassiveLevel
    checkTogglePassiveLevel <Number>        active level - defaults to value of #buttonPassiveLevel
    checkToggleBorderWidth  <Number>        borderWidth - defaults buttons default

    checkToggleActiveImage  <Image>         image to draw when active; if non-nil,
                                            this overwrites activeColor & bitmapFile above.

    checkTogglePassiveImage <Image>         image to draw when passive; if non-nil,
                                            this overwrites passiveColor & bitmapFile above.

(if not set in the styleSheet, Toggle values are taken)

See examples.


Related information:

    CheckBox
    RadioButton
    RadioButtonGroup
    Toggle
    Button
    Dialog
    ValueHolder
    TriggerValue
    Block

Class protocol:

defaults
o  activeImage

o  checkBitsForStyle: aStyleSymbol
helper & public access to useful checkToggle images

usage example(s):

     self checkBitsForStyle:#cross
     self checkBitsForStyle:#fatcross
     self checkBitsForStyle:#borderedCross
     self checkBitsForStyle:#borderedFatcross

o  checkFormOn: aDevice
return the form used when checkToggle is turned on.
Provided as public entry, to allow other views
to share the same check-image.

usage example(s):

     CheckToggle checkFormOn:Display

o  checkImageForStyle: aStyleSymbol
helper & public access to useful checkToggle images

usage example(s):

     self checkImageForStyle:#cross
     self checkImageForStyle:#fatcross
     self checkImageForStyle:#borderedCross
     self checkImageForStyle:#borderedFatcross

o  disabledActiveImage

o  disabledPassiveImage

o  passiveImage

o  smallCheckBitsForStyle: aStyleSymbol
helper & public access to useful checkToggle images

usage example(s):

     self smallCheckBitsForStyle:#cross
     self smallCheckBitsForStyle:#fatcross
     self smallCheckBitsForStyle:#borderedCross
     self smallCheckBitsForStyle:#borderedFatcross

o  smallCheckImageForStyle: aStyleSymbol
helper & public access to useful checkToggle images

usage example(s):

     self smallCheckImageForStyle:#cross
     self smallCheckImageForStyle:#fatcross
     self smallCheckImageForStyle:#borderedCross
     self smallCheckImageForStyle:#borderedFatcross

o  updateStyleCache
extract values from the styleSheet and cache them in class variables

usage example(s):

     self updateStyleCache


Instance protocol:

accessing
o  isFlat

o  isFlat: something

accessing-look
o  allViewBackground: something if: condition

initialization
o  initStyle
setup viewStyle specifics

o  initialize
to let me compute some defaultExtent

queries
o  computePreferredExtent
If I have a frozen extent value...

o  label: something

redrawing
o  drawEdges

o  drawWith: fg and: bg
viewBackground.

o  edgeDrawn: which
redraw my logo if it overlaps the edge

o  logoToDisplay


Examples:


checkToggle alone:
    |top check|

    top := StandardSystemView new.
    top extent:100@100.

    check := CheckToggle in:top.
    check origin:10@10.

    top open
give it an action:
    |top check|

    top := StandardSystemView new.
    top extent:100@100.

    check := CheckToggle in:top.
    check origin:10@10.
    check action:[:value | Transcript showCR:'changed to: ' , value printString].

    top open
give it a model:
    |top check model|

    model := false asValue.

    top := StandardSystemView new.
    top extent:100@100.

    check := CheckToggle in:top.
    check origin:10@10.
    check model:model.

    top openModal.

    Transcript showCR:'value after closing box: ' , model value printString
enableChannel & model:
    |top check1 check2 enableHolder model|

    enableHolder := false asValue.
    model := false asValue.

    top := StandardSystemView new.
    top extent:200@100.

    check1 := CheckToggle in:top.
    check1 origin:10@10.
    check1 model:enableHolder.
    (Label label:'Enable' in:top) origin:30@10.

    check2 := CheckToggle in:top.
    check2 origin:10@30.
    check2 model:model.
    check2 enableChannel:enableHolder.
    (Label label:'Model' in:top) origin:30@30.

    top open.
multiple checks on a single model (with different change selectors): (using a checkBox here, for the demonstration ...) (this is a typical many-in-many setup)
    |top model panel ext1 ext2
     readFlag writeFlag executeFlag|

    readFlag := writeFlag := true.
    executeFlag := false.

    model := Plug new.
    model respondTo:#read with:[readFlag].
    model respondTo:#write with:[writeFlag].
    model respondTo:#execute with:[executeFlag].
    model respondTo:#read: with:[:val | readFlag := val].
    model respondTo:#write: with:[:val | writeFlag := val].
    model respondTo:#execute: with:[:val | executeFlag := val].

    top := StandardSystemView new.
    top extent:200@200.
    top label:'File permissions:'.

    panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
    panel horizontalLayout:#leftSpace.

    #(read write execute) do:[:sym |
        |check|

        check := CheckBox in:panel.
        check label:sym.
        check model:model; aspect:sym; changeMessage:(sym , ':') asSymbol.
    ].

    top openModal.

    Transcript showCR:'settings after closing box:'.
    Transcript showCR:'  read -> ' , readFlag printString.
    Transcript showCR:'  write -> ' , writeFlag printString.
    Transcript showCR:'  execute -> ' , executeFlag printString.
checkToggles in a group - now, they have RadioButton behavior. (this is a typical one-in-many setup)
    |top panel check1 check2 check3 grp|

    top := StandardSystemView new.
    top extent:200@300.

    panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.

    check1 := CheckToggle in:panel.
    check2 := CheckToggle in:panel.
    check3 := CheckToggle in:panel.

    grp := RadioButtonGroup new.
    grp add:check1.
    grp add:check2.
    grp add:check3.

    top open
Channel operation ----------------- enabling other toggles via a toggle
    |top panel t enableChannel|

    top := StandardSystemView new.
    top extent:(400 @ 200).

    panel := HorizontalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.

    enableChannel := false asValue.

    1 to:10 do:[:i |
        t := CheckToggle in:panel.
        t enableChannel:enableChannel.
    ].

    t := Toggle in:panel.
    t activeLogo:'enabled'; passiveLogo:'disabled'.
    t pressChannel:enableChannel.

    top open


ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Wed, 24 Apr 2024 21:36:50 GMT