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