ChckTggle.st
author Claus Gittinger <cg@exept.de>
Sat, 27 Apr 1996 20:21:37 +0200
changeset 593 86dd024ed773
parent 585 8f395aba0173
child 655 acad3ef3a46c
permissions -rw-r--r--
examples
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     1
"
4
88eb91574867 *** empty log message ***
claus
parents: 2
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
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    13
Toggle subclass:#CheckToggle
375
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
    14
	instanceVariableNames:''
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
    15
	classVariableNames:'DefaultCheckForm DefaultCheckColor DefaultActiveFGColor
265
76336839475b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    16
		DefaultActiveBGColor DefaultFGColor DefaultBGColor
76336839475b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    17
		DefaultActiveLevel DefaultPassiveLevel DefaultBorderWidth'
375
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
    18
	poolDictionaries:''
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
    19
	category:'Views-Interactors'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    20
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    21
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 18
diff changeset
    22
!CheckToggle class methodsFor:'documentation'!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 18
diff changeset
    23
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 18
diff changeset
    24
copyright
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 18
diff changeset
    25
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 18
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: 18
diff changeset
    29
 This software is furnished under a license and may be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 18
diff changeset
    30
 only in accordance with the terms of that license and with the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 18
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 18
diff changeset
    32
 be provided or otherwise made available to, or used by, any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 18
diff changeset
    33
 other person.  No title to or ownership of the software is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 18
diff changeset
    34
 hereby transferred.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 18
diff changeset
    35
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 18
diff changeset
    36
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    37
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 18
diff changeset
    38
documentation
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 18
diff changeset
    39
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 18
diff changeset
    40
    CheckButtons are like Toggles in toggling their state when pressed.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 18
diff changeset
    41
    However, they show an ok-marker if on; nothing if off.
118
claus
parents: 77
diff changeset
    42
    CheckButtons are mostly used as part of a checkBox (since normally,
147
claus
parents: 146
diff changeset
    43
    you want to have some label along the check) and often grouped for
claus
parents: 146
diff changeset
    44
    many-in-many or one-in-many setups.
130
claus
parents: 128
diff changeset
    45
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
    46
    [StyleSheet values:]
130
claus
parents: 128
diff changeset
    47
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
    48
        checkToggleCheckColor   <Color>         color to draw check-image with.
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
    49
                                                defaults to value of #buttonActiveForegroundColor.
130
claus
parents: 128
diff changeset
    50
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
    51
        checkToggleActiveBackgroundColor        background color to draw active checki-image with
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
    52
        checkToggleForegroundColor              foreground color to use if off
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
    53
        checkToggleBackgroundColor              background color to use if off
130
claus
parents: 128
diff changeset
    54
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
    55
        checkToggleBitmapFile   <String>        name of bitmap file for check-image
130
claus
parents: 128
diff changeset
    56
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
    57
        checkToggleStyle        <Symbol>        default checkForm style.
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
    58
                                                used if above is nil or file not readable
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
    59
                                                can be #cross or #check; defaults to #check 
130
claus
parents: 128
diff changeset
    60
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
    61
        checkToggleAvtiveLevel  <Number>        active level - defaults to value of #buttonPassiveLevel
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
    62
        checkTogglePassiveLevel <Number>        active level - defaults to value of #buttonPassiveLevel
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
    63
        checkToggleBorderWidth  <Number>        borderWidth - defaults buttons default
130
claus
parents: 128
diff changeset
    64
139
claus
parents: 136
diff changeset
    65
    (if not set in the styleSheet, Toggle values are taken)
claus
parents: 136
diff changeset
    66
130
claus
parents: 128
diff changeset
    67
    See examples.
claus
parents: 128
diff changeset
    68
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
    69
    [author:]
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
    70
        Claus Gittinger
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
    71
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
    72
    [see also:]
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    73
        CheckBox RadioButton RadioButtonGroup Toggle Button
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    74
        Dialog
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    75
        ValueHolder TriggerValue
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    76
        Block
118
claus
parents: 77
diff changeset
    77
"
claus
parents: 77
diff changeset
    78
!
claus
parents: 77
diff changeset
    79
claus
parents: 77
diff changeset
    80
examples 
claus
parents: 77
diff changeset
    81
"
claus
parents: 77
diff changeset
    82
    checkToggle alone:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    83
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    84
        |top check|
118
claus
parents: 77
diff changeset
    85
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    86
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    87
        top extent:100@100.
118
claus
parents: 77
diff changeset
    88
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    89
        check := CheckToggle in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    90
        check origin:10@10.
118
claus
parents: 77
diff changeset
    91
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    92
        top open
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    93
                                                                        [exEnd]
118
claus
parents: 77
diff changeset
    94
claus
parents: 77
diff changeset
    95
claus
parents: 77
diff changeset
    96
    give it an action:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    97
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    98
        |top check|
118
claus
parents: 77
diff changeset
    99
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   100
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   101
        top extent:100@100.
118
claus
parents: 77
diff changeset
   102
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   103
        check := CheckToggle in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   104
        check origin:10@10.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   105
        check action:[:value | Transcript showCr:'changed to: ' , value printString].
118
claus
parents: 77
diff changeset
   106
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   107
        top open
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   108
                                                                        [exEnd]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   109
118
claus
parents: 77
diff changeset
   110
claus
parents: 77
diff changeset
   111
    give it a model:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   112
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   113
        |top check model|
118
claus
parents: 77
diff changeset
   114
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   115
        model := false asValue.
118
claus
parents: 77
diff changeset
   116
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   117
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   118
        top extent:100@100.
118
claus
parents: 77
diff changeset
   119
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   120
        check := CheckToggle in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   121
        check origin:10@10.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   122
        check model:model.
118
claus
parents: 77
diff changeset
   123
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   124
        top openModal.
118
claus
parents: 77
diff changeset
   125
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   126
        Transcript showCr:'value after closing box: ' , model value printString
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   127
                                                                        [exEnd]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   128
118
claus
parents: 77
diff changeset
   129
claus
parents: 77
diff changeset
   130
    multiple checks on a single model (with different change selectors):
claus
parents: 77
diff changeset
   131
    (using a checkBox here, for the demonstration ...)
147
claus
parents: 146
diff changeset
   132
    (this is a typical many-in-many setup)
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   133
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   134
        |top model panel ext1 ext2
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   135
         readFlag writeFlag executeFlag|
118
claus
parents: 77
diff changeset
   136
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   137
        readFlag := writeFlag := true.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   138
        executeFlag := false.
118
claus
parents: 77
diff changeset
   139
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   140
        model := Plug new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   141
        model respondTo:#read with:[readFlag].
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   142
        model respondTo:#write with:[writeFlag].
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   143
        model respondTo:#execute with:[executeFlag].
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   144
        model respondTo:#read: with:[:val | readFlag := val].
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   145
        model respondTo:#write: with:[:val | writeFlag := val].
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   146
        model respondTo:#execute: with:[:val | executeFlag := val].
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   147
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   148
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   149
        top extent:200@200.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   150
        top label:'File permissions:'.
118
claus
parents: 77
diff changeset
   151
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   152
        panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   153
        panel horizontalLayout:#leftSpace.
118
claus
parents: 77
diff changeset
   154
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   155
        #(read write execute) do:[:sym |
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   156
            |check|
118
claus
parents: 77
diff changeset
   157
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   158
            check := CheckBox in:panel.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   159
            check label:sym.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   160
            check model:model; aspect:sym; changeMessage:(sym , ':') asSymbol.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   161
        ].
118
claus
parents: 77
diff changeset
   162
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   163
        top openModal.
118
claus
parents: 77
diff changeset
   164
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   165
        Transcript showCr:'settings after closing box:'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   166
        Transcript showCr:'  read -> ' , readFlag printString.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   167
        Transcript showCr:'  write -> ' , writeFlag printString.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   168
        Transcript showCr:'  execute -> ' , executeFlag printString.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   169
                                                                        [exEnd]
130
claus
parents: 128
diff changeset
   170
claus
parents: 128
diff changeset
   171
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   172
    checkToggles in a group - now, they have RadioButton behavior.
147
claus
parents: 146
diff changeset
   173
    (this is a typical one-in-many setup)
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   174
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   175
        |top panel check1 check2 check3 grp|
130
claus
parents: 128
diff changeset
   176
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   177
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   178
        top extent:200@300.
130
claus
parents: 128
diff changeset
   179
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   180
        panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
130
claus
parents: 128
diff changeset
   181
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   182
        check1 := CheckToggle in:panel.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   183
        check2 := CheckToggle in:panel.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   184
        check3 := CheckToggle in:panel.
130
claus
parents: 128
diff changeset
   185
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   186
        grp := RadioButtonGroup new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   187
        grp add:check1.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   188
        grp add:check2.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   189
        grp add:check3.
130
claus
parents: 128
diff changeset
   190
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   191
        top open
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   192
                                                                        [exEnd]
146
claus
parents: 139
diff changeset
   193
claus
parents: 139
diff changeset
   194
claus
parents: 139
diff changeset
   195
     Channel operation 
claus
parents: 139
diff changeset
   196
     -----------------
claus
parents: 139
diff changeset
   197
claus
parents: 139
diff changeset
   198
       enabling other toggles via a toggle
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   199
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   200
        |top panel t enableChannel|
146
claus
parents: 139
diff changeset
   201
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   202
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   203
        top extent:(400 @ 200).
146
claus
parents: 139
diff changeset
   204
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   205
        panel := HorizontalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
146
claus
parents: 139
diff changeset
   206
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   207
        enableChannel := false asValue.
146
claus
parents: 139
diff changeset
   208
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   209
        1 to:10 do:[:i |
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   210
            t := CheckToggle in:panel.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   211
            t enableChannel:enableChannel.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   212
        ].
146
claus
parents: 139
diff changeset
   213
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   214
        t := Toggle in:panel.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   215
        t activeLogo:'enabled'; passiveLogo:'disabled'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   216
        t pressChannel:enableChannel.
146
claus
parents: 139
diff changeset
   217
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   218
        top open
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   219
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 18
diff changeset
   220
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 18
diff changeset
   221
! !
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   222
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   223
!CheckToggle class methodsFor:'defaults'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   224
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   225
checkFormOn:aDevice
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   226
    "return the form used when checkToggle is turned on.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   227
     Provided as public entry, to allow other views
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   228
     to share the same check-image."
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   229
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   230
    ^ DefaultCheckForm on:aDevice.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   231
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   232
128
claus
parents: 127
diff changeset
   233
updateStyleCache
440
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 375
diff changeset
   234
    "extract values from the styleSheet and cache them in class variables"
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 375
diff changeset
   235
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 375
diff changeset
   236
    <resource: #style (#checkToggleCheckColor
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 375
diff changeset
   237
                       #checkToggleBackgroundColor #checkToggleForegroundColor
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 375
diff changeset
   238
                       #checkToggleActiveBackgroundColor #checkTogglenActiveForegroundColor
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 375
diff changeset
   239
                       #checkToggleActiveLevel #checkTogglePassiveLevel
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 375
diff changeset
   240
                       #checkToggleBorderWidth 
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 375
diff changeset
   241
                       #checkToggleBitmapFile
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 375
diff changeset
   242
                       #checkToggleStyle)>
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 375
diff changeset
   243
375
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   244
    |checkFileName bits checkStyle|
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   245
130
claus
parents: 128
diff changeset
   246
    DefaultCheckColor := StyleSheet colorAt:'checkToggleCheckColor'.
139
claus
parents: 136
diff changeset
   247
    DefaultFGColor := StyleSheet colorAt:'checkToggleForegroundColor'.
130
claus
parents: 128
diff changeset
   248
    DefaultBGColor := StyleSheet colorAt:'checkToggleBackgroundColor'.
139
claus
parents: 136
diff changeset
   249
    DefaultActiveFGColor := StyleSheet colorAt:'checkToggleActiveForegroundColor'.
130
claus
parents: 128
diff changeset
   250
    DefaultActiveBGColor := StyleSheet colorAt:'checkToggleActiveBackgroundColor'.
claus
parents: 128
diff changeset
   251
    DefaultActiveLevel := StyleSheet at:'checkToggleActiveLevel'.
claus
parents: 128
diff changeset
   252
    DefaultPassiveLevel := StyleSheet at:'checkTogglePassiveLevel'.
claus
parents: 128
diff changeset
   253
    DefaultBorderWidth := StyleSheet at:'checkToggleBorderWidth'.
claus
parents: 128
diff changeset
   254
136
claus
parents: 133
diff changeset
   255
    DefaultCheckForm := nil.
128
claus
parents: 127
diff changeset
   256
    checkFileName := StyleSheet at:'checkToggleBitmapFile' default:'CheckOn.xbm'.
claus
parents: 127
diff changeset
   257
    checkFileName notNil ifTrue:[
375
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   258
        DefaultCheckForm := Form fromFile:checkFileName 
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   259
                               resolution:100
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   260
                                       on:Display.
130
claus
parents: 128
diff changeset
   261
    ].
claus
parents: 128
diff changeset
   262
    DefaultCheckForm isNil ifTrue:[
375
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   263
        checkStyle := StyleSheet at:'checkToggleStyle' default:#check.
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   264
        checkStyle == #cross ifTrue:[
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   265
            bits := #[2r10000000 2r00000001
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   266
                      2r01000000 2r00000010
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   267
                      2r00100000 2r00000100
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   268
                      2r00010000 2r00001000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   269
                      2r00001000 2r00010000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   270
                      2r00000100 2r00100000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   271
                      2r00000010 2r01000000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   272
                      2r00000001 2r10000000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   273
                      2r00000001 2r10000000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   274
                      2r00000010 2r01000000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   275
                      2r00000100 2r00100000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   276
                      2r00001000 2r00010000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   277
                      2r00010000 2r00001000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   278
                      2r00100000 2r00000100
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   279
                      2r01000000 2r00000010
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   280
                      2r10000000 2r00000001]
128
claus
parents: 127
diff changeset
   281
375
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   282
        ] ifFalse:[
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   283
            checkStyle == #fatcross ifTrue:[
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   284
                bits := #[2r11000000 2r00000011
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   285
                          2r11100000 2r00000111
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   286
                          2r01110000 2r00001110
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   287
                          2r00111000 2r00011100
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   288
                          2r00011100 2r00111000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   289
                          2r00001110 2r01110000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   290
                          2r00000111 2r11100000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   291
                          2r00000011 2r11000000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   292
                          2r00000011 2r11000000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   293
                          2r00000111 2r11100000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   294
                          2r00001110 2r01110000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   295
                          2r00011100 2r00111000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   296
                          2r00111000 2r00011100
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   297
                          2r01110000 2r00001110
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   298
                          2r11100000 2r00000111
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   299
                          2r11000000 2r00000011]
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   300
            ] ifFalse:[
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   301
                bits := #[2r00000000 2r00000000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   302
                          2r00000000 2r00000010
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   303
                          2r00000000 2r00000010
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   304
                          2r00000000 2r00000100
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   305
                          2r00000000 2r00000100
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   306
                          2r00000000 2r00001000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   307
                          2r00000000 2r00001000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   308
                          2r00000000 2r00010000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   309
                          2r01000000 2r00110000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   310
                          2r00100000 2r01100000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   311
                          2r00011000 2r01100000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   312
                          2r00001110 2r11000000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   313
                          2r00000111 2r11000000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   314
                          2r00000011 2r10000000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   315
                          2r00000001 2r10000000
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   316
                          2r00000000 2r00000000]
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   317
            ]
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   318
        ].
6656f7e8ae20 added just another checkType: #fatcross
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   319
        DefaultCheckForm := Form width:16 height:16 fromArray:bits on:Display                                           
128
claus
parents: 127
diff changeset
   320
    ]
440
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 375
diff changeset
   321
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 375
diff changeset
   322
    "Modified: 1.3.1996 / 13:45:45 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   323
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   324
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   325
!CheckToggle methodsFor:'initialization'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   326
18
66bf62e27141 *** empty log message ***
claus
parents: 4
diff changeset
   327
initStyle
66bf62e27141 *** empty log message ***
claus
parents: 4
diff changeset
   328
    super initStyle.
66bf62e27141 *** empty log message ***
claus
parents: 4
diff changeset
   329
128
claus
parents: 127
diff changeset
   330
    onLevel := offLevel.
130
claus
parents: 128
diff changeset
   331
    DefaultActiveLevel notNil ifTrue:[onLevel := DefaultActiveLevel].
136
claus
parents: 133
diff changeset
   332
    DefaultPassiveLevel notNil ifTrue:[offLevel := DefaultPassiveLevel].
130
claus
parents: 128
diff changeset
   333
128
claus
parents: 127
diff changeset
   334
    activeLogo := DefaultCheckForm on:device.
claus
parents: 127
diff changeset
   335
    passiveLogo := nil.
claus
parents: 127
diff changeset
   336
139
claus
parents: 136
diff changeset
   337
    DefaultActiveFGColor notNil ifTrue:[self activeForegroundColor:DefaultActiveFGColor].
130
claus
parents: 128
diff changeset
   338
    DefaultCheckColor notNil ifTrue:[self activeForegroundColor:DefaultCheckColor].
claus
parents: 128
diff changeset
   339
    DefaultActiveBGColor notNil ifTrue:[self activeBackgroundColor:DefaultActiveBGColor].
139
claus
parents: 136
diff changeset
   340
    DefaultFGColor notNil ifTrue:[self foregroundColor:DefaultFGColor].
130
claus
parents: 128
diff changeset
   341
    DefaultBGColor notNil ifTrue:[self backgroundColor:DefaultBGColor].
claus
parents: 128
diff changeset
   342
128
claus
parents: 127
diff changeset
   343
    showLamp := false.
130
claus
parents: 128
diff changeset
   344
claus
parents: 128
diff changeset
   345
    DefaultBorderWidth notNil ifTrue:[self borderWidth:DefaultBorderWidth].
claus
parents: 128
diff changeset
   346
claus
parents: 128
diff changeset
   347
    offLevel ~~ level ifTrue:[self level:offLevel].
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   348
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   349
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   350
initialize
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   351
    super initialize.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   352
    passiveLogo := nil.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   353
    self form:activeLogo "/ to let me compute some defaultExtent
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   354
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   355
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   356
!CheckToggle methodsFor:'redrawing'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   357
133
claus
parents: 132
diff changeset
   358
drawWith:fg and:bg
265
76336839475b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   359
    controller pressed ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   360
	logo := activeLogo.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   361
    ] ifFalse:[
164
Claus Gittinger <cg@exept.de>
parents: 147
diff changeset
   362
	logo := passiveLogo.
133
claus
parents: 132
diff changeset
   363
    ].
claus
parents: 132
diff changeset
   364
    super drawWith:fg and:bg
164
Claus Gittinger <cg@exept.de>
parents: 147
diff changeset
   365
Claus Gittinger <cg@exept.de>
parents: 147
diff changeset
   366
    "Modified: 22.9.1995 / 15:45:02 / claus"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   367
! !
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   368
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   369
!CheckToggle class methodsFor:'documentation'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   370
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   371
version
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   372
    ^ '$Header: /cvs/stx/stx/libwidg/Attic/ChckTggle.st,v 1.25 1996-04-27 18:16:52 cg Exp $'
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   373
! !