CheckBox.st
author Claus Gittinger <cg@exept.de>
Thu, 23 Nov 1995 19:18:39 +0100
changeset 100 3d33433f459c
parent 86 4d7dbb5f1719
child 112 bb2cb6c553d2
permissions -rw-r--r--
checkin from browser
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
44
97c1c943bef6 Initial revision
claus
parents:
diff changeset
     1
"
97c1c943bef6 Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
49
claus
parents: 44
diff changeset
     3
	      All Rights Reserved
44
97c1c943bef6 Initial revision
claus
parents:
diff changeset
     4
97c1c943bef6 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
97c1c943bef6 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
97c1c943bef6 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
97c1c943bef6 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
97c1c943bef6 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    11
"
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    12
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    13
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    14
HorizontalPanelView subclass:#CheckBox
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    15
	 instanceVariableNames:'toggleView labelView'
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    16
	 classVariableNames:''
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    17
	 poolDictionaries:''
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    18
	 category:'Views-Interactors'
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    19
!
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    20
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    21
!CheckBox class methodsFor:'documentation'!
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    22
100
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    23
copyright
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    24
"
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    25
 COPYRIGHT (c) 1995 by Claus Gittinger
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    26
	      All Rights Reserved
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    27
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    28
 This software is furnished under a license and may be used
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    29
 only in accordance with the terms of that license and with the
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    31
 be provided or otherwise made available to, or used by, any
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    32
 other person.  No title to or ownership of the software is
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    33
 hereby transferred.
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    34
"
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    35
44
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    36
!
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    37
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    38
documentation
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    39
"
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    40
    CheckBox has been added somwehat in a hurry 
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    41
    - obviously, much more protocol is needed.
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    42
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    43
    For now, set actions etc. via sends to the components,
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    44
    labelView and toggleView.
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    45
"
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    46
!
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    47
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    48
examples
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    49
"
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    50
  no-op checkBox:
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    51
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    52
     |b|
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    53
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    54
     b := CheckBox new.
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    55
     b label:'foo'.
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    56
     b open
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    57
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    58
56
claus
parents: 55
diff changeset
    59
  no-op checkBox, disabled:
claus
parents: 55
diff changeset
    60
claus
parents: 55
diff changeset
    61
     |b|
claus
parents: 55
diff changeset
    62
claus
parents: 55
diff changeset
    63
     b := CheckBox new.
claus
parents: 55
diff changeset
    64
     b label:'foo'.
claus
parents: 55
diff changeset
    65
     b disable.
claus
parents: 55
diff changeset
    66
     b open
claus
parents: 55
diff changeset
    67
claus
parents: 55
diff changeset
    68
claus
parents: 55
diff changeset
    69
  changing colors 
claus
parents: 55
diff changeset
    70
  (a demo only: it is no good style to fight the styleSheet):
44
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    71
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    72
     |panel b|
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    73
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    74
     panel := VerticalPanelView new.
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    75
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    76
     b := CheckBox in:panel.
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    77
     b label:'foo'.
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    78
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    79
     b := CheckBox in:panel.
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    80
     b label:'bar'.
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    81
     b labelView foregroundColor:Color red.
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    82
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    83
     b := CheckBox in:panel.
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    84
     b label:'baz'.
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    85
     b toggleView activeForegroundColor:Color blue.
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    86
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    87
     panel open
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    88
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    89
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    90
  using action-blocks:
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    91
49
claus
parents: 44
diff changeset
    92
     |b|
44
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    93
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    94
     b := CheckBox new.
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    95
     b label:'check'.
49
claus
parents: 44
diff changeset
    96
     b action:[:value | Transcript show:'set to: '; showCr:value].
44
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    97
     b open.
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    98
97c1c943bef6 Initial revision
claus
parents:
diff changeset
    99
49
claus
parents: 44
diff changeset
   100
  with a model (default ST-80 behavior, sending #value: to the model):
claus
parents: 44
diff changeset
   101
  (see changing value in the inspector)
claus
parents: 44
diff changeset
   102
claus
parents: 44
diff changeset
   103
     |b model|
claus
parents: 44
diff changeset
   104
claus
parents: 44
diff changeset
   105
     model := ValueHolder newBoolean.
claus
parents: 44
diff changeset
   106
claus
parents: 44
diff changeset
   107
     b := CheckBox new.
claus
parents: 44
diff changeset
   108
     b label:'check'.
claus
parents: 44
diff changeset
   109
     b model:model.
claus
parents: 44
diff changeset
   110
     b open.
claus
parents: 44
diff changeset
   111
     model inspect.
claus
parents: 44
diff changeset
   112
56
claus
parents: 55
diff changeset
   113
49
claus
parents: 44
diff changeset
   114
  with a model and different changeSelector
claus
parents: 44
diff changeset
   115
  (using a plug here, for demonstration only):
44
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   116
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   117
     |b model|
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   118
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   119
     model := Plug new.
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   120
     model respondTo:#changeCheck: with:[:arg | Transcript showCr:'change to ' , arg printString].
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   121
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   122
     b := CheckBox new.
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   123
     b label:'check'.
59
claus
parents: 58
diff changeset
   124
     b model:model; changeMessage:#changeCheck:.
44
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   125
     b open.
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   126
56
claus
parents: 55
diff changeset
   127
claus
parents: 55
diff changeset
   128
  with models, one checkBox disabling the others:
claus
parents: 55
diff changeset
   129
claus
parents: 55
diff changeset
   130
     |dialog translator enableChannel val1 val2 val3 eBox box1 box2 box3|
claus
parents: 55
diff changeset
   131
claus
parents: 55
diff changeset
   132
     translator := Plug new.
claus
parents: 55
diff changeset
   133
     translator respondTo:#enableDisable 
79
Claus Gittinger <cg@exept.de>
parents: 78
diff changeset
   134
		with:[
Claus Gittinger <cg@exept.de>
parents: 78
diff changeset
   135
			enableChannel value
Claus Gittinger <cg@exept.de>
parents: 78
diff changeset
   136
			    ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 78
diff changeset
   137
				box1 enable.
Claus Gittinger <cg@exept.de>
parents: 78
diff changeset
   138
				box2 enable.
Claus Gittinger <cg@exept.de>
parents: 78
diff changeset
   139
				box3 enable.
Claus Gittinger <cg@exept.de>
parents: 78
diff changeset
   140
			    ]
Claus Gittinger <cg@exept.de>
parents: 78
diff changeset
   141
			    ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 78
diff changeset
   142
				box1 disable.
Claus Gittinger <cg@exept.de>
parents: 78
diff changeset
   143
				box2 disable.
Claus Gittinger <cg@exept.de>
parents: 78
diff changeset
   144
				box3 disable.
Claus Gittinger <cg@exept.de>
parents: 78
diff changeset
   145
			    ]
Claus Gittinger <cg@exept.de>
parents: 78
diff changeset
   146
		     ].
56
claus
parents: 55
diff changeset
   147
claus
parents: 55
diff changeset
   148
     enableChannel := true asValue.
claus
parents: 55
diff changeset
   149
     enableChannel onChangeSend:#enableDisable to:translator.
claus
parents: 55
diff changeset
   150
     val1 := true asValue.
claus
parents: 55
diff changeset
   151
     val2 := false asValue.
claus
parents: 55
diff changeset
   152
     val3 := true asValue.
claus
parents: 55
diff changeset
   153
claus
parents: 55
diff changeset
   154
     dialog := Dialog new.
claus
parents: 55
diff changeset
   155
     dialog addCheckBox:'enable' on:enableChannel.
claus
parents: 55
diff changeset
   156
     dialog addVerticalSpace.
claus
parents: 55
diff changeset
   157
     dialog leftIndent:30.
claus
parents: 55
diff changeset
   158
     box1 := dialog addCheckBox:'value1' on:val1.
claus
parents: 55
diff changeset
   159
     dialog addVerticalSpace.
claus
parents: 55
diff changeset
   160
     box2 := dialog addCheckBox:'value2' on:val2.
claus
parents: 55
diff changeset
   161
     dialog addVerticalSpace.
claus
parents: 55
diff changeset
   162
     box3 := dialog addCheckBox:'value3' on:val3.
claus
parents: 55
diff changeset
   163
     dialog addVerticalSpace.
claus
parents: 55
diff changeset
   164
     dialog addOkButton.
claus
parents: 55
diff changeset
   165
claus
parents: 55
diff changeset
   166
     dialog open.
claus
parents: 55
diff changeset
   167
claus
parents: 55
diff changeset
   168
49
claus
parents: 44
diff changeset
   169
  multiple checkBoxes on a single model (using different aspects)
claus
parents: 44
diff changeset
   170
79
Claus Gittinger <cg@exept.de>
parents: 78
diff changeset
   171
     |top panel b model value1 value2|
49
claus
parents: 44
diff changeset
   172
claus
parents: 44
diff changeset
   173
     value1 := true.
claus
parents: 44
diff changeset
   174
     value2 := false.
claus
parents: 44
diff changeset
   175
     model := Plug new.
claus
parents: 44
diff changeset
   176
     model respondTo:#value1 with:[value1].
claus
parents: 44
diff changeset
   177
     model respondTo:#value1: with:[:val | value1 := val].
claus
parents: 44
diff changeset
   178
     model respondTo:#value2 with:[value2].
claus
parents: 44
diff changeset
   179
     model respondTo:#value2: with:[:val | value2 := val].
claus
parents: 44
diff changeset
   180
claus
parents: 44
diff changeset
   181
     top := DialogBox new.
claus
parents: 44
diff changeset
   182
     top extent:200@300.
claus
parents: 44
diff changeset
   183
claus
parents: 44
diff changeset
   184
     panel := VerticalPanelView new.
claus
parents: 44
diff changeset
   185
claus
parents: 44
diff changeset
   186
     b := CheckBox in:panel.
claus
parents: 44
diff changeset
   187
     b label:'check1'.
59
claus
parents: 58
diff changeset
   188
     b model:model; aspect:#value1; changeMessage:#value1:.
49
claus
parents: 44
diff changeset
   189
claus
parents: 44
diff changeset
   190
     b := CheckBox in:panel.
claus
parents: 44
diff changeset
   191
     b label:'check2'.
59
claus
parents: 58
diff changeset
   192
     b model:model; aspect:#value2; changeMessage:#value2:.
49
claus
parents: 44
diff changeset
   193
claus
parents: 44
diff changeset
   194
     top addComponent:panel.
claus
parents: 44
diff changeset
   195
     top addAbortButton; addOkButton.
claus
parents: 44
diff changeset
   196
     top openModal.
claus
parents: 44
diff changeset
   197
79
Claus Gittinger <cg@exept.de>
parents: 78
diff changeset
   198
     top accepted ifTrue:[
49
claus
parents: 44
diff changeset
   199
	 Transcript show:'value1: '; showCr:model value1.
claus
parents: 44
diff changeset
   200
	 Transcript show:'value2: '; showCr:model value2.
claus
parents: 44
diff changeset
   201
     ]
44
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   202
"
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   203
! !
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   204
62
claus
parents: 59
diff changeset
   205
!CheckBox class methodsFor:'instance creation'!
claus
parents: 59
diff changeset
   206
76
claus
parents: 66
diff changeset
   207
label:aStringOrImage model:aModel
claus
parents: 66
diff changeset
   208
    "create & return a new checkBox, on aModel (typically a ValueHolder),
claus
parents: 66
diff changeset
   209
     with aStringOrImage as label."
claus
parents: 66
diff changeset
   210
claus
parents: 66
diff changeset
   211
    ^ (self new model:aModel) label:aStringOrImage
claus
parents: 66
diff changeset
   212
claus
parents: 66
diff changeset
   213
    "Created: 17.9.1995 / 14:20:58 / claus"
44
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   214
!
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   215
55
claus
parents: 49
diff changeset
   216
model:aModel
100
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   217
    "create & return a new checkBox, on aModel (typically a ValueHolder)"
79
Claus Gittinger <cg@exept.de>
parents: 78
diff changeset
   218
100
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   219
    ^ self new model:aModel
56
claus
parents: 55
diff changeset
   220
! !
claus
parents: 55
diff changeset
   221
claus
parents: 55
diff changeset
   222
!CheckBox methodsFor:'accessing'!
claus
parents: 55
diff changeset
   223
44
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   224
labelView
49
claus
parents: 44
diff changeset
   225
    "return the labelView; allows manipulation of the
claus
parents: 44
diff changeset
   226
     labels attributes (colors etc.)"
claus
parents: 44
diff changeset
   227
44
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   228
    ^ labelView
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   229
!
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   230
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   231
toggleView
49
claus
parents: 44
diff changeset
   232
    "return the toggleView; allows manipulation of the
claus
parents: 44
diff changeset
   233
     toggles attributes (colors etc.)"
claus
parents: 44
diff changeset
   234
44
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   235
    ^ toggleView
56
claus
parents: 55
diff changeset
   236
! !
claus
parents: 55
diff changeset
   237
100
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   238
!CheckBox methodsFor:'accessing-behavior'!
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   239
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   240
action:aBlock
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   241
    "forward to toggle"
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   242
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   243
    toggleView action:aBlock
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   244
!
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   245
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   246
disable
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   247
    "forward to toggle & change labels color"
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   248
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   249
    toggleView disable.
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   250
    labelView foregroundColor:(toggleView disabledForegroundColor).
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   251
!
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   252
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   253
enable
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   254
    "forward to toggle & change labels color"
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   255
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   256
    toggleView enable.
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   257
    labelView foregroundColor:(toggleView foregroundColor).
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   258
!
78
claus
parents: 76
diff changeset
   259
100
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   260
pressAction:aBlock
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   261
    toggleView pressAction:aBlock.
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   262
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   263
    "Created: 22.9.1995 / 15:54:04 / claus"
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   264
!
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   265
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   266
releaseAction:aBlock
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   267
    toggleView releaseAction:aBlock.
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   268
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   269
    "Created: 22.9.1995 / 15:54:11 / claus"
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   270
!
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   271
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   272
turnOff
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   273
    "forward to toggle"
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   274
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   275
    toggleView turnOff
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   276
!
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   277
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   278
turnOn
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   279
    "forward to toggle"
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   280
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   281
    toggleView turnOn
78
claus
parents: 76
diff changeset
   282
! !
claus
parents: 76
diff changeset
   283
56
claus
parents: 55
diff changeset
   284
!CheckBox methodsFor:'accessing-look'!
44
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   285
100
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   286
activeLogo:anImageOrString
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   287
    toggleView activeLogo:anImageOrString
56
claus
parents: 55
diff changeset
   288
100
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   289
    "Created: 22.9.1995 / 15:44:08 / claus"
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   290
!
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   291
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   292
font
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   293
    "forward from label"
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   294
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   295
    ^ labelView font
49
claus
parents: 44
diff changeset
   296
!
44
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   297
56
claus
parents: 55
diff changeset
   298
font:aFont
claus
parents: 55
diff changeset
   299
    "forward to label & resize"
55
claus
parents: 49
diff changeset
   300
56
claus
parents: 55
diff changeset
   301
    labelView font:aFont.
claus
parents: 55
diff changeset
   302
    labelView forceResize.
79
Claus Gittinger <cg@exept.de>
parents: 78
diff changeset
   303
    self layoutChanged.
Claus Gittinger <cg@exept.de>
parents: 78
diff changeset
   304
    self resize.
49
claus
parents: 44
diff changeset
   305
!
claus
parents: 44
diff changeset
   306
56
claus
parents: 55
diff changeset
   307
label
claus
parents: 55
diff changeset
   308
    "forward from label"
claus
parents: 55
diff changeset
   309
claus
parents: 55
diff changeset
   310
    ^ labelView label
79
Claus Gittinger <cg@exept.de>
parents: 78
diff changeset
   311
!
Claus Gittinger <cg@exept.de>
parents: 78
diff changeset
   312
100
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   313
label:aString
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   314
    "forward to label & resize"
79
Claus Gittinger <cg@exept.de>
parents: 78
diff changeset
   315
100
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   316
    labelView label:aString.
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   317
    labelView forceResize.
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   318
    self layoutChanged.
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   319
    self resize.
79
Claus Gittinger <cg@exept.de>
parents: 78
diff changeset
   320
!
Claus Gittinger <cg@exept.de>
parents: 78
diff changeset
   321
Claus Gittinger <cg@exept.de>
parents: 78
diff changeset
   322
passiveLogo:anImageOrString
Claus Gittinger <cg@exept.de>
parents: 78
diff changeset
   323
    toggleView passiveLogo:anImageOrString
Claus Gittinger <cg@exept.de>
parents: 78
diff changeset
   324
Claus Gittinger <cg@exept.de>
parents: 78
diff changeset
   325
    "Created: 22.9.1995 / 15:44:14 / claus"
56
claus
parents: 55
diff changeset
   326
! !
claus
parents: 55
diff changeset
   327
100
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   328
!CheckBox methodsFor:'accessing-mvc'!
63
claus
parents: 62
diff changeset
   329
100
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   330
aspectMessage:aspectSymbol
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   331
    "forward to label & toggle"
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   332
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   333
    labelView aspectMessage:aspectSymbol.
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   334
    toggleView aspectMessage:aspectSymbol
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   335
!
63
claus
parents: 62
diff changeset
   336
100
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   337
changeMessage:aChangeSelector
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   338
    "forward to toggle"
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   339
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   340
    toggleView changeMessage:aChangeSelector
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   341
!
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   342
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   343
model:aModel
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   344
    "forward to label & toggle"
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   345
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   346
    labelView model:aModel.
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   347
    toggleView model:aModel
63
claus
parents: 62
diff changeset
   348
! !
claus
parents: 62
diff changeset
   349
100
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   350
!CheckBox methodsFor:'accessing-state'!
55
claus
parents: 49
diff changeset
   351
100
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   352
isOn
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   353
    ^ toggleView isOn
44
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   354
! !
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   355
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   356
!CheckBox methodsFor:'initialization'!
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   357
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   358
initialize
56
claus
parents: 55
diff changeset
   359
    super initialize.
44
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   360
56
claus
parents: 55
diff changeset
   361
    borderWidth := 0.
44
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   362
49
claus
parents: 44
diff changeset
   363
    hLayout := #fixLeftSpace.
44
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   364
    vLayout := #center.
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   365
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   366
    toggleView := CheckToggle in:self.
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   367
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   368
    labelView := Label in:self.
58
claus
parents: 56
diff changeset
   369
    labelView label:'check'; borderWidth:0.
44
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   370
    labelView forceResize.
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   371
    labelView adjust:#left.
62
claus
parents: 59
diff changeset
   372
    self height:labelView preferredExtent y + ViewSpacing.
55
claus
parents: 49
diff changeset
   373
56
claus
parents: 55
diff changeset
   374
    "
claus
parents: 55
diff changeset
   375
     all of my input goes to the toggle
claus
parents: 55
diff changeset
   376
    "
claus
parents: 55
diff changeset
   377
    self delegate:(KeyboardForwarder toView:toggleView).
44
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   378
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   379
    "
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   380
     |b|
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   381
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   382
     b := CheckBox new.
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   383
     b label:'foo'.
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   384
     b open
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   385
    "
97c1c943bef6 Initial revision
claus
parents:
diff changeset
   386
! !
100
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   387
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   388
!CheckBox methodsFor:'private'!
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   389
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   390
sendChangeMessageWith:aValue
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   391
    "redefined to have mimic changes being sent from the toggle
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   392
     instead of myself"
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   393
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   394
    toggleView sendChangeMessageWith:aValue
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   395
! !
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   396
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   397
!CheckBox methodsFor:'queries'!
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   398
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   399
preferredExtent
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   400
    |prefCheck prefLabel bw2|
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   401
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   402
^ super preferredExtent + (10@0).
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   403
"/    prefCheck := toggleView preferredExtent.
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   404
"/    prefLabel := labelView preferredExtent.
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   405
"/    bw2 := borderWidth * 2.
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   406
"/    ^ (prefCheck x + prefLabel x + (3 * ViewSpacing)) @ ((prefCheck y max:prefLabel y) + bw2 + 2)
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   407
! !
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   408
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   409
!CheckBox class methodsFor:'documentation'!
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   410
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   411
version
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   412
    ^ '$Header: /cvs/stx/stx/libwidg2/CheckBox.st,v 1.14 1995-11-23 18:17:40 cg Exp $'
3d33433f459c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   413
! !