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