RadioButtonGroup.st
author Claus Gittinger <cg@exept.de>
Thu, 09 Nov 2017 20:09:30 +0100
changeset 6225 0122e4e6c587
parent 2661 98a32f29fa08
permissions -rw-r--r--
#FEATURE by cg class: GenericToolbarIconLibrary class added: #hideFilter16x16Icon
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     1
"
5
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1991 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
     3
	      All Rights Reserved
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     4
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    11
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    12
2449
b9bf97bf089d category included a space
Claus Gittinger <cg@exept.de>
parents: 2144
diff changeset
    13
"{ Package: 'stx:libwidg' }"
b9bf97bf089d category included a space
Claus Gittinger <cg@exept.de>
parents: 2144
diff changeset
    14
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
    15
ValueHolder subclass:#RadioButtonGroup
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
    16
	instanceVariableNames:'numberOfValues'
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 198
diff changeset
    17
	classVariableNames:''
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 198
diff changeset
    18
	poolDictionaries:''
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 198
diff changeset
    19
	category:'Views-Support'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    20
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    21
2449
b9bf97bf089d category included a space
Claus Gittinger <cg@exept.de>
parents: 2144
diff changeset
    22
!RadioButtonGroup class methodsFor:'documentation'!
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 7
diff changeset
    23
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 7
diff changeset
    24
copyright
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 7
diff changeset
    25
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 7
diff changeset
    26
 COPYRIGHT (c) 1991 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    27
	      All Rights Reserved
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    28
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 7
diff changeset
    29
 This software is furnished under a license and may be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 7
diff changeset
    30
 only in accordance with the terms of that license and with the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 7
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 7
diff changeset
    32
 be provided or otherwise made available to, or used by, any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 7
diff changeset
    33
 other person.  No title to or ownership of the software is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 7
diff changeset
    34
 hereby transferred.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 7
diff changeset
    35
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 7
diff changeset
    36
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 7
diff changeset
    37
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 7
diff changeset
    38
documentation
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 7
diff changeset
    39
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 7
diff changeset
    40
    RadioButtonGroups control the interaction between RadioButtons
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 7
diff changeset
    41
    turning off other button(s) when one of the group is pressed.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    42
    To group some buttons (and have one-on behavior) use:
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    43
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 198
diff changeset
    44
        |g|
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    45
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 198
diff changeset
    46
        g := RadioButtonGroup new.
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 198
diff changeset
    47
        ...
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 198
diff changeset
    48
        b1 := RadioButton label:....
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 198
diff changeset
    49
        g add:b1
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 198
diff changeset
    50
        ...
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 198
diff changeset
    51
        b2 := RadioButton label:....
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 198
diff changeset
    52
        g add:b2
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 198
diff changeset
    53
        ...
116
claus
parents: 105
diff changeset
    54
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
    55
    A radioButtonGroup is itself usable as a model, holding the index of
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
    56
    the selected button. It can be used as a selectionIndexHolder of a
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
    57
    SelectionInList instance.
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 198
diff changeset
    58
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 198
diff changeset
    59
    [author:]
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 198
diff changeset
    60
        Claus Gittinger
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
    61
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
    62
    [see also:]
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
    63
        RadioButton Toggle CheckBox CheckToggle Button
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
    64
        Model ValueHolder SelectionInList
131
claus
parents: 130
diff changeset
    65
"
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 198
diff changeset
    66
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
    67
    "Modified: 1.3.1997 / 14:11:57 / cg"
131
claus
parents: 130
diff changeset
    68
!
claus
parents: 130
diff changeset
    69
claus
parents: 130
diff changeset
    70
examples 
claus
parents: 130
diff changeset
    71
"
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
    72
    using Toggles for 'at most one-on behavior':
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
    73
                                                                        [exBegin]
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
    74
        |top panel b group|
116
claus
parents: 105
diff changeset
    75
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
    76
        top := StandardSystemView label:'toggles'.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
    77
        panel := HorizontalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
    78
        group := RadioButtonGroup new.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
    79
        b := Toggle label:'one' in:panel.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
    80
        group add:b.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
    81
        b := Toggle label:'two' in:panel.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
    82
        group add:b.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
    83
        b := Toggle label:'three' in:panel.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
    84
        group add:b.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
    85
        top extent:(panel preferredExtent).
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
    86
        top open.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
    87
                                                                        [exEnd]
116
claus
parents: 105
diff changeset
    88
177
c06d27f8525f radioButton(group) fixes
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    89
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
    90
    using RadioButtons for 'one-on behavior':
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
    91
                                                                        [exBegin]
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
    92
        |top panel b group|
116
claus
parents: 105
diff changeset
    93
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
    94
        top := StandardSystemView label:'radio'.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
    95
        panel := HorizontalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
    96
        group := RadioButtonGroup new.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
    97
        b := RadioButton label:'one' in:panel.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
    98
        group add:b.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
    99
        b := RadioButton label:'two' in:panel.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   100
        group add:b.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   101
        b := RadioButton label:'three' in:panel.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   102
        group add:b.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   103
        top extent:(panel preferredExtent).
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   104
        top open.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   105
                                                                        [exEnd]
116
claus
parents: 105
diff changeset
   106
177
c06d27f8525f radioButton(group) fixes
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   107
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   108
    same, with initial selection:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   109
                                                                        [exBegin]
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   110
        |top panel b group|
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   111
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   112
        top := StandardSystemView label:'radio'.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   113
        panel := HorizontalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   114
        group := RadioButtonGroup new.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   115
        b := RadioButton label:'one' in:panel.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   116
        group add:b.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   117
        b := RadioButton label:'two' in:panel.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   118
        group add:b.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   119
        b := RadioButton label:'three' in:panel.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   120
        group add:b.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   121
        top extent:(panel preferredExtent).
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   122
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   123
        group value:1.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   124
        top open.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   125
                                                                        [exEnd]
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   126
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   127
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   128
    using Buttons for 'none-on behavior'; 
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   129
    buttons do not show the boolean state (they only fire);
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   130
    however, the groups value remembers the last pressed button:
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   131
                                                                        [exBegin]
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   132
        |top panel b group|
177
c06d27f8525f radioButton(group) fixes
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   133
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   134
        top := StandardSystemView new.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   135
        panel := HorizontalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   136
        group := RadioButtonGroup new.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   137
        b := Button label:'one' in:panel.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   138
        group add:b.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   139
        b := Button label:'two' in:panel.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   140
        group add:b.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   141
        b := Button label:'three' in:panel.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   142
        group add:b.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   143
        top extent:(panel preferredExtent).
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   144
        top open.
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   145
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   146
        group inspect
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   147
                                                                        [exEnd]
177
c06d27f8525f radioButton(group) fixes
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   148
c06d27f8525f radioButton(group) fixes
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   149
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   150
    using checkBoxes (these have a label included).
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   151
    notice, that we change their behavior to radioButton behavior:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   152
                                                                        [exBegin]
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   153
        |top panel b group|
163
claus
parents: 155
diff changeset
   154
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   155
        top := StandardSystemView new.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   156
        panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   157
        panel horizontalLayout:#left.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   158
        group := RadioButtonGroup new.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   159
        b := CheckBox label:'one' in:panel.
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   160
        b controller beRadioButton.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   161
        group add:b.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   162
        b := CheckBox label:'two' in:panel.
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   163
        b controller beRadioButton.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   164
        group add:b.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   165
        b := CheckBox label:'three' in:panel.
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   166
        b controller beRadioButton.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   167
        group add:b.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   168
        top extent:(panel preferredExtent).
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   169
        top open.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   170
                                                                        [exEnd]
163
claus
parents: 155
diff changeset
   171
claus
parents: 155
diff changeset
   172
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   173
    a small dialog
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   174
                                                                        [exBegin]
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   175
        |dialog group b|
131
claus
parents: 130
diff changeset
   176
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   177
        dialog := Dialog new.
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   178
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   179
        group := RadioButtonGroup new.
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   180
        group add:(b := dialog addCheckBox:'one' on:nil).
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   181
        b controller beRadioButton.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   182
        group add:(b := dialog addCheckBox:'two' on:nil).
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   183
        b controller beRadioButton.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   184
        group add:(b := dialog addCheckBox:'three' on:nil).
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   185
        b controller beRadioButton.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   186
        group value:2.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   187
        dialog addAbortButton; addOkButton.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   188
        dialog open.
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   189
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   190
        dialog accepted ifTrue:[
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   191
            Transcript showCR:'you selected: ' , group value printString
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   192
        ] ifFalse:[
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   193
            Transcript showCR:'aborted'
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   194
        ]
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   195
                                                                        [exEnd]
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   196
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   197
  as a selectionIndexHolder of a selectionInList
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   198
  (i.e. a selectionInListView and a group displaying the same selection):
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   199
                                                                        [exBegin]
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   200
    |top top2 panel b sv group selectionInList|
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   201
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   202
    top := StandardSystemView extent:200@200.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   203
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   204
    panel := HorizontalPanelView
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   205
                origin:0.0@0.0 corner:1.0@1.0 in:top.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   206
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   207
    group := RadioButtonGroup new.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   208
    selectionInList := SelectionInList new.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   209
    selectionInList list:#('am' 'fm' 'off').
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   210
    selectionInList selectionIndexHolder:group.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   211
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   212
    b := RadioButton label:'am' in:panel.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   213
    group add:b.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   214
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   215
    b := RadioButton label:'fm' in:panel.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   216
    group add:b.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   217
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   218
    b := RadioButton label:'off' in:panel.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   219
    group add:b.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   220
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   221
    group value:1.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   222
    top open.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   223
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   224
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   225
    top2 := StandardSystemView extent:200@200.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   226
    sv := SelectionInListView in:top2.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   227
    sv model:selectionInList.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   228
    sv origin:0.0@0.0 corner:1.0@1.0.
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   229
    top2 open.
1377
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   230
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 7
diff changeset
   231
"
178
5c28593c2a3b turnOn/ turnOff changed back - now added turnOn/OffWithAction (sorry stefan)
Claus Gittinger <cg@exept.de>
parents: 177
diff changeset
   232
1377
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   233
    "Created: / 15.11.1995 / 17:14:53 / cg"
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   234
    "Modified: / 30.10.1997 / 20:18:25 / cg"
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   235
! !
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   236
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   237
!RadioButtonGroup class methodsFor:'helpers'!
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   238
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   239
adaptorFor:someValueHolder value:buttonValue
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   240
    "create and return an adaptor for a radioButton"
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   241
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   242
    |adaptor|
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   243
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   244
    adaptor := PluggableAdaptor on:someValueHolder.
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   245
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   246
    "/ the adapter plays boolean-value holder towards
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   247
    "/ the radioButton, returning true iff the groups
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   248
    "/ value is the same as the buttons index-value; false otherwise.
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   249
    "/ Likewise, a true-store from the button sets the group value
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   250
    "/ to the buttons index.
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   251
1815
e3a6c8e93fd1 react on equal value (used to be identical)
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
   252
    adaptor getBlock:[:m | (m value = buttonValue) ]
1377
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   253
            putBlock:[:m :onOff | 
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   254
                           onOff ifTrue:[
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   255
                               m value:buttonValue
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   256
                           ] ifFalse:[
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   257
                                "/ support for toggles
1815
e3a6c8e93fd1 react on equal value (used to be identical)
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
   258
                                buttonValue = m value ifTrue:[
1377
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   259
                                   m value:nil 
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   260
                                ]
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   261
                           ]
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   262
                     ]
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   263
         updateBlock:[:m :a :v | true].
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   264
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   265
    ^ adaptor
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   266
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   267
    "Created: / 30.10.1997 / 19:45:34 / cg"
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   268
    "Modified: / 30.10.1997 / 20:14:25 / cg"
131
claus
parents: 130
diff changeset
   269
! !
claus
parents: 130
diff changeset
   270
2144
8cfc21c91319 category rename
Claus Gittinger <cg@exept.de>
parents: 1815
diff changeset
   271
!RadioButtonGroup methodsFor:'adding & removing'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   272
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   273
add:aRadioButton
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   274
    "add a radioButton to the group - actually, this name is misleading;
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   275
     it simple creates an adaptor, which converts my value into a boolean,
1245
162b71744f37 value assigned to value holder can be defined
ca
parents: 1088
diff changeset
   276
     depending on the buttons index-number
162b71744f37 value assigned to value holder can be defined
ca
parents: 1088
diff changeset
   277
    "
162b71744f37 value assigned to value holder can be defined
ca
parents: 1088
diff changeset
   278
    self add:aRadioButton value:nil
162b71744f37 value assigned to value holder can be defined
ca
parents: 1088
diff changeset
   279
!
131
claus
parents: 130
diff changeset
   280
1810
8aa2eca2f50f comment
Claus Gittinger <cg@exept.de>
parents: 1377
diff changeset
   281
add:aRadioButton value:aValueOrNil
1245
162b71744f37 value assigned to value holder can be defined
ca
parents: 1088
diff changeset
   282
    "add a radioButton to the group - actually, this name is misleading;
1810
8aa2eca2f50f comment
Claus Gittinger <cg@exept.de>
parents: 1377
diff changeset
   283
     it simply creates an adaptor, which converts my value into a boolean,
8aa2eca2f50f comment
Claus Gittinger <cg@exept.de>
parents: 1377
diff changeset
   284
     depending on the buttons index-number or aValueOrNil"
131
claus
parents: 130
diff changeset
   285
1810
8aa2eca2f50f comment
Claus Gittinger <cg@exept.de>
parents: 1377
diff changeset
   286
    |adaptor selectValue|
131
claus
parents: 130
diff changeset
   287
1367
660c8d594e4b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   288
    numberOfValues := (numberOfValues ? 0) + 1.
1810
8aa2eca2f50f comment
Claus Gittinger <cg@exept.de>
parents: 1377
diff changeset
   289
    selectValue  := aValueOrNil ? numberOfValues.
1245
162b71744f37 value assigned to value holder can be defined
ca
parents: 1088
diff changeset
   290
1367
660c8d594e4b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   291
    "/ the adapter plays boolean-value holder towards
660c8d594e4b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   292
    "/ the radioButton, returning true iff the groups
660c8d594e4b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   293
    "/ value is the same as the buttons index-value; false otherwise.
660c8d594e4b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   294
    "/ Likewise, a true-store from the button sets the group value
660c8d594e4b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   295
    "/ to the buttons index.
660c8d594e4b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   296
1810
8aa2eca2f50f comment
Claus Gittinger <cg@exept.de>
parents: 1377
diff changeset
   297
    adaptor := self class adaptorFor:self value:selectValue.
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   298
    aRadioButton isOn ifTrue:[
1810
8aa2eca2f50f comment
Claus Gittinger <cg@exept.de>
parents: 1377
diff changeset
   299
        self value:selectValue.
131
claus
parents: 130
diff changeset
   300
    ].
1088
40de2fe27607 completely rewritten;
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
   301
    aRadioButton model:adaptor.
1367
660c8d594e4b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
   302
1377
56fd9ea18a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   303
    "Modified: / 30.10.1997 / 20:14:54 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   304
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   305
2661
98a32f29fa08 access to number of choices
Claus Gittinger <cg@exept.de>
parents: 2449
diff changeset
   306
!RadioButtonGroup methodsFor:'queries'!
98a32f29fa08 access to number of choices
Claus Gittinger <cg@exept.de>
parents: 2449
diff changeset
   307
98a32f29fa08 access to number of choices
Claus Gittinger <cg@exept.de>
parents: 2449
diff changeset
   308
numberOfValues
98a32f29fa08 access to number of choices
Claus Gittinger <cg@exept.de>
parents: 2449
diff changeset
   309
    ^ numberOfValues
98a32f29fa08 access to number of choices
Claus Gittinger <cg@exept.de>
parents: 2449
diff changeset
   310
! !
98a32f29fa08 access to number of choices
Claus Gittinger <cg@exept.de>
parents: 2449
diff changeset
   311
2449
b9bf97bf089d category included a space
Claus Gittinger <cg@exept.de>
parents: 2144
diff changeset
   312
!RadioButtonGroup class methodsFor:'documentation'!
b9bf97bf089d category included a space
Claus Gittinger <cg@exept.de>
parents: 2144
diff changeset
   313
b9bf97bf089d category included a space
Claus Gittinger <cg@exept.de>
parents: 2144
diff changeset
   314
version
2661
98a32f29fa08 access to number of choices
Claus Gittinger <cg@exept.de>
parents: 2449
diff changeset
   315
    ^ '$Header: /cvs/stx/stx/libwidg/RadioButtonGroup.st,v 1.33 2002-11-11 09:49:19 cg Exp $'
2449
b9bf97bf089d category included a space
Claus Gittinger <cg@exept.de>
parents: 2144
diff changeset
   316
! !