|
Class: CheckToggle
Object
|
+--GraphicsMedium
|
+--DisplaySurface
|
+--SimpleView
|
+--View
|
+--Label
|
+--Button
|
+--Toggle
|
+--CheckToggle
- Package:
- stx:libwidg
- Category:
- Views-Interactors
- Version:
- rev:
1.83
date: 2024/03/21 15:08:32
- user: matilk
- file: CheckToggle.st directory: libwidg
- module: stx stc-classLibrary: libwidg
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.
copyrightCOPYRIGHT (c) 1991 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.
defaults
-
activeForm
-
DefaultActiveImage := nil.
self updateStyleCache
-
activeImage
-
-
checkBitsForStyle: aStyleSymbol
-
helper & public access to useful checkToggle images
Usage example(s):
self checkBitsForStyle:#cross
self checkBitsForStyle:#fatcross
self checkBitsForStyle:#borderedCross
self checkBitsForStyle:#borderedFatcross
|
-
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
|
-
checkImageForStyle: aStyleSymbol
-
helper & public access to useful checkToggle images
Usage example(s):
self checkImageForStyle:#cross
self checkImageForStyle:#fatcross
self checkImageForStyle:#borderedCross
self checkImageForStyle:#borderedFatcross
|
-
disabledActiveForm
-
DefaultDisabledActiveImage := nil.
self updateStyleCache
-
disabledActiveImage
-
-
disabledPassiveForm
-
DefaultDisabledPassiveImage := nil.
self updateStyleCache
-
disabledPassiveImage
-
-
enteredActiveForm
-
DefaultEnteredActiveImage := nil.
self updateStyleCache
-
enteredPassiveForm
-
DefaultEnteredPassiveImage := nil.
self updateStyleCache
-
passiveForm
-
DefaultPassiveImage := nil.
self updateStyleCache
-
passiveImage
-
-
smallCheckBitsForStyle: aStyleSymbol
-
helper & public access to useful checkToggle images
Usage example(s):
self smallCheckBitsForStyle:#cross
self smallCheckBitsForStyle:#fatcross
self smallCheckBitsForStyle:#borderedCross
self smallCheckBitsForStyle:#borderedFatcross
|
-
smallCheckImageForStyle: aStyleSymbol
-
helper & public access to useful checkToggle images
Usage example(s):
self smallCheckImageForStyle:#cross
self smallCheckImageForStyle:#fatcross
self smallCheckImageForStyle:#borderedCross
self smallCheckImageForStyle:#borderedFatcross
|
-
updateStyleCache
-
extract values from the styleSheet and cache them in class variables
Usage example(s):
accessing
-
isFlat
-
-
isFlat: something
-
accessing-look
-
allViewBackground: something if: condition
-
(comment from inherited method)
no longer ignored here
initialization
-
initStyle
-
setup viewStyle specifics
-
initialize
-
to let me compute some defaultExtent
queries
-
computePreferredExtent
-
If I have a frozen extent value...
-
label: something
-
redrawing
-
drawEdges
-
(comment from inherited method)
draw all of my 3D edges
-
drawWith: fg and: bg
-
viewBackground.
-
edgeDrawn: which
-
redraw my logo if it overlaps the edge
-
logoToDisplay
-
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
|
|