ComboListView.st
author Claus Gittinger <cg@exept.de>
Tue, 11 May 2004 14:50:21 +0200
changeset 2704 0a09fd78eb54
parent 1826 080df5e45c3c
child 2825 b27f9e7776d7
permissions -rw-r--r--
ColorEditDialog made public
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1302
30c3d98bc450 Fix typo
Stefan Vogel <sv@exept.de>
parents: 1295
diff changeset
     1
"
332
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
     2
 COPYRIGHT (c) 1996 by eXept Software AG / Claus Gittinger
1295
acc5e8e85a7b Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
     3
              All Rights Reserved
332
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
     4
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
     5
 This software is furnished under a license and may be used
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
     6
 only in accordance with the terms of that license and with the
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
     8
 be provided or otherwise made available to, or used by, any
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
     9
 other person.  No title to or ownership of the software is
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    10
 hereby transferred.
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    11
"
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    12
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    13
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    14
1826
080df5e45c3c examples
Claus Gittinger <cg@exept.de>
parents: 1729
diff changeset
    15
"{ Package: 'stx:libwidg2' }"
080df5e45c3c examples
Claus Gittinger <cg@exept.de>
parents: 1729
diff changeset
    16
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
ComboView subclass:#ComboListView
1729
d08b46a88c4e tuned #value-sending
Claus Gittinger <cg@exept.de>
parents: 1302
diff changeset
    18
	instanceVariableNames:'useIndex values'
d08b46a88c4e tuned #value-sending
Claus Gittinger <cg@exept.de>
parents: 1302
diff changeset
    19
	classVariableNames:''
d08b46a88c4e tuned #value-sending
Claus Gittinger <cg@exept.de>
parents: 1302
diff changeset
    20
	poolDictionaries:''
d08b46a88c4e tuned #value-sending
Claus Gittinger <cg@exept.de>
parents: 1302
diff changeset
    21
	category:'Views-Interactors'
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
!
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
270
35558a88d500 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
    24
!ComboListView class methodsFor:'documentation'!
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
332
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    26
copyright
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    27
"
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    28
 COPYRIGHT (c) 1996 by eXept Software AG / Claus Gittinger
1295
acc5e8e85a7b Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
    29
              All Rights Reserved
332
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    30
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    31
 This software is furnished under a license and may be used
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    32
 only in accordance with the terms of that license and with the
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    33
 inclusion of the above copyright notice.   This software may not
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    34
 be provided or otherwise made available to, or used by, any
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    35
 other person.  No title to or ownership of the software is
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    36
 hereby transferred.
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    37
"
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    38
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    39
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    40
!
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    41
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
documentation
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
"
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    A ComboListView combines an label with a drop down list of default inputs;
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    choosing any from the pulled list sets the string in the label.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
    This is the same as a PopUpList or SelectionInListView, bit looks different.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
310
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
    49
    The preferred model is a SelectionInList, but a simple valueHolder
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
    50
    may also be used. 
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
    51
    If some other model is to be used, the changeMessage and aspectMessage 
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
    52
    should be defined as appropriate (or an aspectAdaptor should be used).
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
    53
    If a listHolder is set, that one is assumed to provide the list of
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
    54
    items in the popped menu; 
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
    55
    otherwise, if listMessage is nonNil, the model is assumed to also provide the
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
    56
    list as displayed in the popped menu.
275
da88b7732dff commentary
Claus Gittinger <cg@exept.de>
parents: 272
diff changeset
    57
da88b7732dff commentary
Claus Gittinger <cg@exept.de>
parents: 272
diff changeset
    58
    [author:]
1281
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1206
diff changeset
    59
        Claus Gittinger
275
da88b7732dff commentary
Claus Gittinger <cg@exept.de>
parents: 272
diff changeset
    60
da88b7732dff commentary
Claus Gittinger <cg@exept.de>
parents: 272
diff changeset
    61
    [see also:]
1281
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1206
diff changeset
    62
        ComboView
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1206
diff changeset
    63
        PopUpList SelectionInListView
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1206
diff changeset
    64
        ComboBoxView ExtendedComboBox
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1206
diff changeset
    65
        PullDownMenu Label EntryField
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
"
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
!
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
examples
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
"
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
    71
  non-MVC use; 
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
    72
    set the list explicitely:
1826
080df5e45c3c examples
Claus Gittinger <cg@exept.de>
parents: 1729
diff changeset
    73
                                                                [exBegin]
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    74
     |top comboList|
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    75
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    76
     top := StandardSystemView new.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    77
     top extent:(300 @ 200).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    78
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    79
     comboList := ComboListView in:top.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    80
     comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    81
     comboList bottomInset:(comboList preferredExtent y negated).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    82
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    83
     comboList list:#('hello' 'world' 'this' 'is' 'st/x').
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    84
     top open.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    85
                                                                [exEnd]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    86
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    87
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    88
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    89
    with callBack:
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    90
                                                                [exBegin]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    91
     |top comboList|
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
     top := StandardSystemView new.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
     top extent:(300 @ 200).
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    96
     comboList := ComboListView in:top.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    97
     comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    98
     comboList bottomInset:(comboList preferredExtent y negated).
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   100
     comboList list:#('hello' 'world' 'this' 'is' 'st/x').
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   101
     comboList action:[:selected | Transcript showCR:selected].
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
     top open.
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   103
                                                                [exEnd]
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   107
    with separating lines:
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   108
                                                                [exBegin]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   109
     |top comboList|
305
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
   110
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   111
     top := StandardSystemView label:'fruit chooser'.
305
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
   112
     top extent:(300 @ 200).
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
   113
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   114
     comboList := ComboListView in:top.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   115
     comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   116
     comboList bottomInset:(comboList preferredExtent y negated).
305
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
   117
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   118
     comboList label:'fruit'.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   119
     comboList list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas').
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   120
     comboList action:[:selected | Transcript showCR:selected].
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   121
     top open
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   122
                                                                [exEnd]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   123
305
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
   124
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
   125
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
   126
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   127
    with values different from the label strings:
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   128
                                                                        [exBegin]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   129
     |top comboList|
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   130
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   131
     top := StandardSystemView label:'fruit chooser'.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   132
     top extent:(300 @ 200).
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   133
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   134
     comboList := ComboListView in:top.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   135
     comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   136
     comboList bottomInset:(comboList preferredExtent y negated).
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   137
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   138
     comboList label:'dummy'.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   139
     comboList list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas').
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   140
     comboList selection:'apples'.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   141
     comboList values:#(10 20 30 40 nil 50).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   142
     comboList action:[:what | Transcript show:'you selected: '; showCR:what].
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   143
     top open
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   144
                                                                        [exEnd]
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   145
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   146
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   147
    sometimes, you may like the index instead of the value:
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   148
    (notice, that the separating line counts, so you have to take care ...)
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   149
                                                                [exBegin]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   150
     |top comboList|
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   151
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   152
     top := StandardSystemView label:'fruit chooser'.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   153
     top extent:(300 @ 200).
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   154
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   155
     comboList := ComboListView in:top.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   156
     comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   157
     comboList bottomInset:(comboList preferredExtent y negated).
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   158
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   159
     comboList label:'dummy'.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   160
     comboList list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas').
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   161
     comboList selection:'apples'.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   162
     comboList action:[:what | Transcript show:'you selected: '; showCR:what].
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   163
     comboList useIndex:true.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   164
     top open
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   165
                                                                [exEnd]
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   166
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   167
    since the list is actually represented by a menuView,
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   168
    which itself is inheriting from listView, which itself can display
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   169
    things different from strings, arbitrary lists can be constructed:
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   170
    (see ListEntry, LabelAndIcon and Text classes)
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   171
                                                                        [exBegin]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   172
     |top comboList l|
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   173
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   174
     top := StandardSystemView label:'fruit chooser'.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   175
     top extent:(300 @ 200).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   176
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   177
     comboList := ComboListView in:top.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   178
     comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   179
     comboList bottomInset:(comboList preferredExtent y negated).
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   180
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   181
     l := OrderedCollection new.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   182
     l add:(Text string:'apples' color:Color red).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   183
     l add:(Text string:'bananas' color:Color red).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   184
     l add:(Text string:'grape' color:Color red).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   185
     l add:(Text string:'lemon' color:Color red).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   186
     l add:'='.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   187
     l add:(Text string:'margaritas' color:Color green darkened darkened).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   188
     l add:(Text string:'pina colada' color:Color green darkened darkened).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   189
     l add:'='.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   190
     l add:(Text string:'smalltalk' color:Color blue).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   191
     l add:(Text string:'c++' color:Color blue).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   192
     l add:(Text string:'eiffel' color:Color blue).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   193
     l add:(Text string:'java' color:Color blue).
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   194
     comboList list:l.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   195
     comboList values:#(apples bananas grape lemon 
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   196
                nil 
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   197
                'mhmh - so good' 'makes headache'
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   198
                nil
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   199
                'great' 'another headache' 'not bad' 'neat').
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   200
     comboList selection:'apples'.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   201
     comboList action:[:what | Transcript show:'you selected: '; showCR:what].
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   202
     top open
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   203
                                                                        [exEnd]
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   204
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   205
    with values different from the label strings:
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   206
                                                                        [exBegin]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   207
     |top comboList|
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   208
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   209
     top := StandardSystemView label:'language chooser'.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   210
     top extent:(300 @ 200).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   211
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   212
     comboList := ComboListView in:top.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   213
     comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   214
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   215
     comboList list:( #(
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   216
                'usa'
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   217
                'uk'
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   218
                'france'
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   219
                'germany'       
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   220
                'italy'
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   221
               ) collect:[:country |
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   222
                            LabelAndIcon 
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   223
                                icon:(Image fromFile:'bitmaps/xpmBitmaps/countries/' , country , '.xpm')
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   224
                                string:country
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   225
                         ]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   226
            ).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   227
     comboList values:#(us england france germany italy).
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   228
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   229
     comboList action:[:what | Transcript show:'you selected: '; showCR:what].
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   230
     comboList bottomInset:(comboList preferredExtent y negated).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   231
     top open
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   232
                                                                        [exEnd]
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   233
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   234
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   235
  with a model (see in the inspector, how the index-holders value changes)
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   236
  the defaults are setup to allow a SelectionInList directly as model:
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   237
                                                                        [exBegin]
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   238
     |p model|
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   239
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   240
     model := SelectionInList with:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   241
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   242
     p := ComboListView label:'healthy fruit'.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   243
     p model:model.
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   244
     p openAt:(Screen current center).
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   245
     model inspect
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   246
                                                                        [exEnd]
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   247
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   248
  model provides selection; list is explicit:
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   249
                                                                [exBegin]
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
     |model top b|
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
     model := 'foo' asValue.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
     top := StandardSystemView new.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
     top extent:(300 @ 200).
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
     b := ComboListView in:top.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
     b origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
     b bottomInset:(b preferredExtent y negated).
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
     b list:#('hello' 'world' 'this' 'is' 'st/x').
310
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   262
     b model:model.
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
     top openModal.
184
13a2f3677c68 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
   265
     Transcript showCR:('comboBox''s value: ' , model value).
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   266
                                                                [exEnd]
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   269
    a comboListView and a SelectionInListView on the same model:
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   270
                                                                        [exBegin]
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   271
     |p slv model|
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   272
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   273
     model := SelectionInList with:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   274
     model selection:'apples'.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   275
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   276
     p := ComboListView on:model.
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   277
     p openAt:(Screen current center).
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   278
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   279
     slv := SelectionInListView on:model.
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   280
     slv openAt:(Screen current center + (100@100)).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   281
                                                                        [exEnd]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   282
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   283
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   284
    like above, using index:
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   285
                                                                        [exBegin]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   286
     |p slv model|
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   287
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   288
     model := SelectionInList with:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   289
     model selection:'apples'.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   290
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   291
     p := ComboListView on:model.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   292
     p openAt:(Screen current center).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   293
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   294
     slv := SelectionInListView on:model.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   295
     slv openAt:(Screen current center + (100@100)).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   296
                                                                        [exEnd]
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   297
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   298
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   299
    two comboListViews on the same model, different aspects:
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   300
                                                                        [exBegin]
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   301
     |top panel p model|
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   302
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   303
     model := Plug new.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   304
     model respondTo:#eat: with:[:val | Transcript showCR:'eat: ' , val].
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   305
     model respondTo:#drink: with:[:val | Transcript showCR:'drink: ' , val].
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   306
     model respondTo:#meals with:[#(taco burrito enchilada)].
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   307
     model respondTo:#drinks with:[#(margarita water corona)].
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   308
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   309
     top := StandardSystemView label:'meal chooser'.
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   310
     top extent:(150@150).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   311
     panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   312
     panel horizontalLayout:#fitSpace.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   313
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   314
     p := ComboListView label:'meals'.
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   315
     p aspect:nil; model:model; listMessage:#meals; change:#eat:.
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   316
     panel add:p.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   317
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   318
     p := ComboListView label:'drinks'.
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   319
     p aspect:nil; model:model; listMessage:#drinks; change:#drink:.
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   320
     panel add:p.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   321
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   322
     top open
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   323
                                                                        [exEnd]
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   324
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   325
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   326
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   327
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   328
    with separate list- and indexHolders:
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   329
                                                                        [exBegin]
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   330
     |p selectionHolder listHolder|
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   331
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   332
     listHolder := #('apples' 'bananas' 'grape' 'lemon' 'margaritas') asValue.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   333
     selectionHolder := 'apples' asValue.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   334
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   335
     p := ComboListView label:'healthy fruit'.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   336
     p listHolder:listHolder.
310
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   337
     p model:selectionHolder.
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   338
     p openAt:(Screen current center).
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   339
     selectionHolder inspect
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   340
                                                                        [exEnd]
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   341
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   342
    using different values:
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   343
                                                                        [exBegin]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   344
     |p priceHolder listHolder prices priceField|
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   345
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   346
     listHolder := #('apples' 'bananas' 'grape' 'lemon' 'margaritas') asValue.
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   347
     prices := #(10 10 5 15 50).
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   348
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   349
     priceHolder := nil asValue.
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   350
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   351
     p := ComboListView new.
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   352
     p listHolder:listHolder.
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   353
     p model:priceHolder.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   354
     p values:prices.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   355
     p openAt:(Screen current center).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   356
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   357
     priceField := EditField new.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   358
     priceField readOnly:true.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   359
     priceField model:(TypeConverter onNumberValue:priceHolder).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   360
     priceField openAt:(Screen current center + (10@10)).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   361
                                                                        [exEnd]
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   362
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   363
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
  in a dialog:
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   365
                                                                [exBegin]
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
     |model1 model2 dialog b|
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
     model1 := 'foo' asValue.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   369
     model2 := 'bar' asValue.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
     dialog := Dialog new.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
     (dialog addTextLabel:'ComboList example:') adjust:#left.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
     dialog addVerticalSpace.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
     (b := dialog addComboListOn:model1 tabable:true).
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
     b list:#('fee' 'foe' 'foo').
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
     dialog addVerticalSpace.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
     (b := dialog addComboListOn:model2 tabable:true).
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
     b list:#('bar' 'baz' 'baloo').
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
     dialog addVerticalSpace.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
     dialog addOkButton.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
     dialog open.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
184
13a2f3677c68 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
   387
     Transcript showCR:('1st comboBox''s value: ' , model1 value).
13a2f3677c68 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
   388
     Transcript showCR:('2nd comboBox''s value: ' , model2 value).
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   389
                                                                [exEnd]
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
"
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
! !
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   393
!ComboListView class methodsFor:'defaults'!
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   394
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   395
defaultAspectMessage
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   396
    ^ #selection
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   397
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   398
    "Created: 27.2.1997 / 15:23:13 / cg"
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   399
!
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   400
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   401
defaultChangeMessage
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   402
    ^ #selection:
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   403
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   404
    "Created: 27.2.1997 / 15:23:18 / cg"
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   405
! !
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   406
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   407
!ComboListView methodsFor:'accessing-behavior'!
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   408
501
0f047737ba92 supports list & model or SelectionInList
ca
parents: 368
diff changeset
   409
useIndex
0f047737ba92 supports list & model or SelectionInList
ca
parents: 368
diff changeset
   410
    "specify, if the selected components value or its index in the
0f047737ba92 supports list & model or SelectionInList
ca
parents: 368
diff changeset
   411
     list should be sent to the model. The default is its value."
0f047737ba92 supports list & model or SelectionInList
ca
parents: 368
diff changeset
   412
0f047737ba92 supports list & model or SelectionInList
ca
parents: 368
diff changeset
   413
    ^ useIndex
0f047737ba92 supports list & model or SelectionInList
ca
parents: 368
diff changeset
   414
!
0f047737ba92 supports list & model or SelectionInList
ca
parents: 368
diff changeset
   415
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   416
useIndex:aBoolean
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   417
    "specify, if the selected components value or its index in the
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   418
     list should be sent to the model. The default is its value."
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   419
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   420
    useIndex := aBoolean.
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   421
684
707ce2f663f0 useIndex ...
ca
parents: 682
diff changeset
   422
"/    "/ change the aspectMessage - but only if it has not yet been
707ce2f663f0 useIndex ...
ca
parents: 682
diff changeset
   423
"/    "/ changed explicitly
707ce2f663f0 useIndex ...
ca
parents: 682
diff changeset
   424
"/    useIndex ifTrue:[
707ce2f663f0 useIndex ...
ca
parents: 682
diff changeset
   425
"/        changeMsg == #selection: ifTrue:[
707ce2f663f0 useIndex ...
ca
parents: 682
diff changeset
   426
"/            changeMsg := #selectionIndex:.
707ce2f663f0 useIndex ...
ca
parents: 682
diff changeset
   427
"/            aspectMsg := #selectionIndex.
707ce2f663f0 useIndex ...
ca
parents: 682
diff changeset
   428
"/        ]
707ce2f663f0 useIndex ...
ca
parents: 682
diff changeset
   429
"/    ] ifFalse:[
707ce2f663f0 useIndex ...
ca
parents: 682
diff changeset
   430
"/        changeMsg == #selectionIndex: ifTrue:[
707ce2f663f0 useIndex ...
ca
parents: 682
diff changeset
   431
"/            changeMsg := #selection:.
707ce2f663f0 useIndex ...
ca
parents: 682
diff changeset
   432
"/            aspectMsg := #selection.
707ce2f663f0 useIndex ...
ca
parents: 682
diff changeset
   433
"/        ]
707ce2f663f0 useIndex ...
ca
parents: 682
diff changeset
   434
"/    ].
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   435
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   436
    "Created: 26.7.1996 / 17:44:18 / cg"
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   437
    "Modified: / 24.1.1998 / 19:06:41 / cg"
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   438
!
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   439
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   440
values:aCollection
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   441
    "specify, which values are to be stuffed into the model or
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   442
     passed via the actionBlock."
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   443
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   444
    values := aCollection.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   445
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   446
    "Created: 27.2.1997 / 15:10:12 / cg"
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   447
! !
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   448
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   449
!ComboListView methodsFor:'accessing-components'!
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   450
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
label 
181
31e8f8ab2fb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 131
diff changeset
   452
    "return the label component"
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   454
    ^ field
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
    "Modified: 28.2.1996 / 15:10:50 / cg"
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
    "Created: 28.2.1996 / 15:13:51 / cg"
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
! !
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   459
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   460
!ComboListView methodsFor:'accessing-contents'!
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   461
536
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   462
contents
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   463
    "get the current value - either in the fields model
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   464
     or directly"
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   465
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   466
    |m|
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   467
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   468
    (m := field model) notNil ifTrue:[
1295
acc5e8e85a7b Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   469
        ^ m value
536
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   470
    ] ifFalse:[
1295
acc5e8e85a7b Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   471
        ^ field label
536
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   472
    ]
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   473
!
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   474
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   475
contents:something
272
6c6466cd4ea1 commentary
Claus Gittinger <cg@exept.de>
parents: 270
diff changeset
   476
    "set the current value - either in the fields model
6c6466cd4ea1 commentary
Claus Gittinger <cg@exept.de>
parents: 270
diff changeset
   477
     or directly"
6c6466cd4ea1 commentary
Claus Gittinger <cg@exept.de>
parents: 270
diff changeset
   478
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   479
    |m|
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   480
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   481
    (m := field model) notNil ifTrue:[
1295
acc5e8e85a7b Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   482
        m value:something
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   483
    ] ifFalse:[
1295
acc5e8e85a7b Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   484
        field label:something
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   485
    ]
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   486
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   487
    "Created: 15.7.1996 / 13:16:49 / cg"
272
6c6466cd4ea1 commentary
Claus Gittinger <cg@exept.de>
parents: 270
diff changeset
   488
    "Modified: 5.1.1997 / 00:05:04 / cg"
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   489
!
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   490
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   491
selection:something
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   492
    "set the contents of my field; questionable"
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   493
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   494
    self contents:something
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   495
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   496
    "Created: 27.2.1997 / 15:07:37 / cg"
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   497
! !
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   498
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   499
!ComboListView methodsFor:'initialization'!
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   500
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   501
initialize
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   502
    useIndex isNil ifTrue:[useIndex := false].
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   503
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   504
    super initialize.
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   505
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   506
    "Created: 26.7.1996 / 17:44:57 / cg"
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   507
    "Modified: 27.2.1997 / 15:23:24 / cg"
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   508
!
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   509
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   510
initializeField
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   511
    field := Label in:self.
519
9ab4fc771a7f better look with 2D styles
Claus Gittinger <cg@exept.de>
parents: 501
diff changeset
   512
    field level:-1; borderWidth:0.
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   513
    field adjust:#left.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   514
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   515
    "
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   516
     |b|
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   517
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   518
     b := ComboListView new.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   519
     b list:#('hello' 'world' 'this' 'is' 'st/x').
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   520
     b open
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   521
    "
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   522
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   523
    "Created: 28.2.1996 / 15:13:46 / cg"
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   524
    "Modified: 28.2.1996 / 15:18:40 / cg"
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   525
! !
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   526
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   527
!ComboListView methodsFor:'private'!
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   528
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   529
getValueFromModel
1206
a739c9a8a42f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 684
diff changeset
   530
    |selection idx aspect newContents|
278
4a22889a5730 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 275
diff changeset
   531
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   532
    (model notNil and:[aspectMsg notNil]) ifTrue:[
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   533
        "/ kludge - try #value if aspect is the default and
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   534
        "/ not understood by the model
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   535
        "/ this allows a valueHolder to be used, even
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   536
        "/ if the aspectMessage was not setup correctly.
309
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   537
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   538
        aspect := aspectMsg.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   539
        aspect == self class defaultAspectMessage ifTrue:[
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   540
            (model respondsTo:aspect) ifFalse:[
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   541
                aspect := #value
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   542
            ]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   543
        ].
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   544
1729
d08b46a88c4e tuned #value-sending
Claus Gittinger <cg@exept.de>
parents: 1302
diff changeset
   545
        aspect == #value ifTrue:[
d08b46a88c4e tuned #value-sending
Claus Gittinger <cg@exept.de>
parents: 1302
diff changeset
   546
            selection := model value
d08b46a88c4e tuned #value-sending
Claus Gittinger <cg@exept.de>
parents: 1302
diff changeset
   547
        ] ifFalse:[
d08b46a88c4e tuned #value-sending
Claus Gittinger <cg@exept.de>
parents: 1302
diff changeset
   548
            selection := model perform:aspect.
d08b46a88c4e tuned #value-sending
Claus Gittinger <cg@exept.de>
parents: 1302
diff changeset
   549
        ].
309
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   550
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   551
        selection notNil ifTrue:[
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   552
            values notNil ifTrue:[
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   553
                idx := values indexOf:selection
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   554
            ] ifFalse:[
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   555
                useIndex ifTrue:[
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   556
                    idx := selection
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   557
                ] ifFalse:[
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   558
                    self contents:selection.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   559
                    ^ self.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   560
                ]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   561
            ].
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   562
1206
a739c9a8a42f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 684
diff changeset
   563
            newContents := list at:idx ifAbsent:nil.
a739c9a8a42f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 684
diff changeset
   564
        ].
a739c9a8a42f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 684
diff changeset
   565
        self contents:newContents
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   566
    ].
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   567
1729
d08b46a88c4e tuned #value-sending
Claus Gittinger <cg@exept.de>
parents: 1302
diff changeset
   568
    "Created: / 15.7.1996 / 12:28:53 / cg"
d08b46a88c4e tuned #value-sending
Claus Gittinger <cg@exept.de>
parents: 1302
diff changeset
   569
    "Modified: / 1.3.2000 / 15:20:24 / cg"
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   570
! !
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   571
291
65229309ad5e specClass
ca
parents: 283
diff changeset
   572
!ComboListView methodsFor:'queries'!
65229309ad5e specClass
ca
parents: 283
diff changeset
   573
65229309ad5e specClass
ca
parents: 283
diff changeset
   574
specClass
598
288e67e06da4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
   575
    "XXX no longer needed (inherited default works here)"
288e67e06da4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
   576
291
65229309ad5e specClass
ca
parents: 283
diff changeset
   577
    self class == ComboListView ifTrue:[
1295
acc5e8e85a7b Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   578
        ^ ComboListSpec
291
65229309ad5e specClass
ca
parents: 283
diff changeset
   579
    ].
301
edddd206a2e5 specClass query
ca
parents: 293
diff changeset
   580
    ^ super specClass
291
65229309ad5e specClass
ca
parents: 283
diff changeset
   581
598
288e67e06da4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
   582
    "Modified: / 31.10.1997 / 19:49:34 / cg"
291
65229309ad5e specClass
ca
parents: 283
diff changeset
   583
! !
65229309ad5e specClass
ca
parents: 283
diff changeset
   584
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   585
!ComboListView methodsFor:'user interaction'!
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   586
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   587
select:anIndex
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   588
    "sent from the popped menu, when an item was selected"
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   589
368
c99ef22c72f8 removed unused variable
Claus Gittinger <cg@exept.de>
parents: 332
diff changeset
   590
    |label value chg|
238
6be113228de3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 232
diff changeset
   591
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   592
    values isNil ifTrue:[
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   593
        value := anIndex.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   594
        useIndex ifFalse:[
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   595
            value := list at:anIndex.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   596
        ]
283
7441b4d65776 additional action hook - evaluated when selection changes
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
   597
    ] ifFalse:[
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   598
        value := values at:anIndex
283
7441b4d65776 additional action hook - evaluated when selection changes
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
   599
    ].
7441b4d65776 additional action hook - evaluated when selection changes
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
   600
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   601
    label := list at:anIndex.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   602
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   603
    field label:label.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   604
293
e707cc62ee30 first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   605
    "
e707cc62ee30 first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   606
     ST-80 style model notification ...
e707cc62ee30 first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   607
     this updates the model (typically, a ValueHolder)
e707cc62ee30 first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   608
    "
309
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   609
    (model notNil and:[changeMsg notNil]) ifTrue:[
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   610
        "/ kludge - try #value: if changeMsg is the default and
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   611
        "/ not understood by the model
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   612
        "/ this allows a valueHolder to be used, even
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   613
        "/ if the aspectMessage was not setup correctly.
309
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   614
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   615
        chg := changeMsg.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   616
        chg == self class defaultChangeMessage ifTrue:[
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   617
            (model respondsTo:chg) ifFalse:[
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   618
                chg := #value:
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   619
            ]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   620
        ].
309
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   621
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   622
        self sendChangeMessage:chg with:value
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   623
    ].
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   624
    pullDownButton turnOff.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   625
293
e707cc62ee30 first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   626
    "
e707cc62ee30 first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   627
     ST/X style actionBlock evaluation ...
e707cc62ee30 first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   628
    "
283
7441b4d65776 additional action hook - evaluated when selection changes
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
   629
    action notNil ifTrue:[
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   630
        action value:value
283
7441b4d65776 additional action hook - evaluated when selection changes
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
   631
    ].
7441b4d65776 additional action hook - evaluated when selection changes
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
   632
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   633
    "Created: 27.2.1997 / 15:18:44 / cg"
310
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   634
    "Modified: 28.2.1997 / 13:50:17 / cg"
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   635
! !
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   636
270
35558a88d500 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   637
!ComboListView class methodsFor:'documentation'!
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   638
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   639
version
1826
080df5e45c3c examples
Claus Gittinger <cg@exept.de>
parents: 1729
diff changeset
   640
    ^ '$Header: /cvs/stx/stx/libwidg2/ComboListView.st,v 1.37 2000-09-01 10:14:51 cg Exp $'
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   641
! !