PopUpList.st
author Claus Gittinger <cg@exept.de>
Thu, 27 Feb 1997 10:05:15 +0100
changeset 1064 dba203683e94
parent 1063 b315e2580bc7
child 1065 01c863929ddc
permissions -rw-r--r--
checkin from browser
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
     1
"
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1994 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
     3
	      All Rights Reserved
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
     4
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
    11
"
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
    12
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
    13
Button subclass:#PopUpList
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    14
	instanceVariableNames:'menu menuAction values useIndex listMsg defaultLabel listHolder'
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    15
	classVariableNames:''
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    16
	poolDictionaries:''
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    17
	category:'Views-Interactors'
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
    18
!
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
    19
998
ab1890b4e157 specClass
ca
parents: 799
diff changeset
    20
!PopUpList class methodsFor:'documentation'!
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    21
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    22
copyright
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    23
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    24
 COPYRIGHT (c) 1994 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    25
	      All Rights Reserved
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    26
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    27
 This software is furnished under a license and may be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    28
 only in accordance with the terms of that license and with the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    30
 be provided or otherwise made available to, or used by, any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    31
 other person.  No title to or ownership of the software is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    32
 hereby transferred.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    33
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    34
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    35
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    36
documentation
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    37
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    38
    a PopUpList is basically a button with a popup menu.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    39
    The PopUpLists label is showing the current selection from the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    40
    list.
121
claus
parents: 120
diff changeset
    41
    When an entry is selected, an actionBlock (if nonNil) is evaluated
claus
parents: 120
diff changeset
    42
    and (if nonNil), the model is notified via the changeMessage.
125
claus
parents: 121
diff changeset
    43
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    44
    If no model is set, the list is assumed to be a static list, which
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    45
    is defined via #list:, and the popUpList evaluates the action block,
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    46
    as defined via #action:.
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    47
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    48
    If a model is provided, it should return the list from the listMessage
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    49
    (default is #list) and the current selected items index via the aspectMessage
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    50
    (default is #selection or: #selectionIndex, depending on the setting of useIndex).
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    51
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    52
    The defaults are set to allows a PopUpList to be used with a SelectionInList 
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    53
    as model without further setup.
121
claus
parents: 120
diff changeset
    54
    (if used with some other model, either use an adaptor, or set the
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    55
     change/aspect and/or listMessage to something else ..)
125
claus
parents: 121
diff changeset
    56
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 327
diff changeset
    57
    [Instance variables:]
125
claus
parents: 121
diff changeset
    58
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    59
        menu                            helpers for the popup menu
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    60
        menuAction 
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    61
        values 
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    62
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    63
        useIndex             <Boolean>  if true, the index of the selected entry
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    64
                                        is passed to the action block and the
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    65
                                        model in a change-message.
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    66
                                        If false (the default), the value is passed.
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    67
                                        Notice that the default changeMessage is
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    68
                                        #selection:, which is not ok to be used
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    69
                                        with useIndex:true and a selectionInList model.
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    70
                                        (set the changeMessage to #selectionIndex: then)
125
claus
parents: 121
diff changeset
    71
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    72
        listMsg              <Symbol>   message to aquire a new list from the
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    73
                                        model. Default is #list.
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    74
125
claus
parents: 121
diff changeset
    75
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    76
        listHolder           <Object>   if non-nil, this object is assumed to return the
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    77
                                        list via the listMsg (instead of the model).
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    78
                                        Default is nil.
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 327
diff changeset
    79
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 327
diff changeset
    80
    [see also:]
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    81
        SelectionInListView
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    82
        SelectionInList
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 327
diff changeset
    83
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 327
diff changeset
    84
    [author:]
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    85
        Claus Gittinger
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    86
"
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    87
!
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    88
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    89
examples
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    90
"
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    91
  non-MVC use:
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    92
                                                                        [exBegin]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    93
     |p|
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    94
     p := PopUpList label:'healthy fruit'.
119
claus
parents: 105
diff changeset
    95
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    96
     p open
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
    97
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    98
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    99
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
   100
    with an initial selection:
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   101
                                                                        [exBegin]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
   102
     |p|
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
   103
     p := PopUpList label:'dummy'.
119
claus
parents: 105
diff changeset
   104
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
   105
     p selection:'apples'.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
   106
     p open
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   107
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
   108
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
   109
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
   110
    with separating lines:
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   111
                                                                        [exBegin]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
   112
     |p|
119
claus
parents: 105
diff changeset
   113
     p := PopUpList label:'fruit'.
claus
parents: 105
diff changeset
   114
     p list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas').
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
   115
     p selection:'apples'.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
   116
     p open
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   117
                                                                        [exEnd]
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   118
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   119
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   120
    with an action:
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   121
                                                                        [exBegin]
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   122
     |p|
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   123
     p := PopUpList label:'dummy'.
119
claus
parents: 105
diff changeset
   124
     p list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas').
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   125
     p selection:'apples'.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   126
     p action:[:what | Transcript showCR:'you selected: ' , what].
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   127
     p open
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   128
                                                                        [exEnd]
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   129
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   130
119
claus
parents: 105
diff changeset
   131
    sometimes, you may like the index instead of the value:
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   132
    (notice, that the separating line counts, so you have to take care ...)
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   133
                                                                        [exBegin]
119
claus
parents: 105
diff changeset
   134
     |p|
claus
parents: 105
diff changeset
   135
     p := PopUpList label:'dummy'.
claus
parents: 105
diff changeset
   136
     p list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas').
claus
parents: 105
diff changeset
   137
     p selection:'apples'.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   138
     p action:[:what | Transcript show:'you selected: '; showCR:what].
119
claus
parents: 105
diff changeset
   139
     p useIndex:true.
claus
parents: 105
diff changeset
   140
     p open
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   141
                                                                        [exEnd]
119
claus
parents: 105
diff changeset
   142
claus
parents: 105
diff changeset
   143
claus
parents: 105
diff changeset
   144
    since the list is actually a popupMenu, you can add double-separators:
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   145
                                                                        [exBegin]
119
claus
parents: 105
diff changeset
   146
     |p|
claus
parents: 105
diff changeset
   147
     p := PopUpList label:'dummy'.
claus
parents: 105
diff changeset
   148
     p list:#('apples' 'bananas' 'grape' 'lemon' 
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   149
              '=' 
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   150
              'margaritas' 'pina colada'
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   151
              '=' 
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   152
              'smalltalk' 'c++' 'eiffel' 'java').
119
claus
parents: 105
diff changeset
   153
     p values:#(apples bananas grape lemon 
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   154
                nil 
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   155
                'mhmh - so good' 'makes headache'
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   156
                nil
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   157
                'great' 'another headache' 'not bad' 'neat').
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   158
     p selection:'apples'.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   159
     p action:[:what | Transcript show:'you selected: '; showCR:what].
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   160
     p open
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   161
                                                                        [exEnd]
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   162
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   163
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   164
    since the list is actually represented by a menuView,
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   165
    which itself is inheriting from listView, which itself can display
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   166
    things different from strings, arbitrary lists can be constructed:
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   167
    (see ListEntry classes)
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   168
                                                                        [exBegin]
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   169
     |p l|
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   170
     p := PopUpList label:'dummy'.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   171
     l := OrderedCollection new.
1064
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   172
     l add:(ColoredListEntry string:'apples' color:Color red).
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   173
     l add:(ColoredListEntry string:'bananas' color:Color red).
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   174
     l add:(ColoredListEntry string:'grape' color:Color red).
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   175
     l add:(ColoredListEntry string:'lemon' color:Color red).
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   176
     l add:'='.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   177
     l add:(ColoredListEntry string:'margaritas' color:Color green darkened darkened).
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   178
     l add:(ColoredListEntry string:'pina colada' color:Color green darkened darkened).
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   179
     l add:'='.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   180
     l add:(ColoredListEntry string:'smalltalk' color:Color blue).
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   181
     l add:(ColoredListEntry string:'c++' color:Color blue).
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   182
     l add:(ColoredListEntry string:'eiffel' color:Color blue).
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   183
     l add:(ColoredListEntry string:'java' color:Color blue).
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   184
     p list:l.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   185
     p values:#(apples bananas grape lemon 
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   186
                nil 
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   187
                'mhmh - so good' 'makes headache'
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   188
                nil
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   189
                'great' 'another headache' 'not bad' 'neat').
119
claus
parents: 105
diff changeset
   190
     p selection:'apples'.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   191
     p action:[:what | Transcript show:'you selected: '; showCR:what].
119
claus
parents: 105
diff changeset
   192
     p open
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   193
                                                                        [exEnd]
119
claus
parents: 105
diff changeset
   194
claus
parents: 105
diff changeset
   195
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   196
    with values different from the label strings:
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   197
                                                                        [exBegin]
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   198
     |p|
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   199
     p := PopUpList label:'dummy'.
119
claus
parents: 105
diff changeset
   200
     p list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas').
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   201
     p selection:'apples'.
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   202
     p values:#(10 20 30 40 nil 50).
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   203
     p action:[:what | Transcript show:'you selected: '; showCR:what].
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   204
     p open
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   205
                                                                        [exEnd]
119
claus
parents: 105
diff changeset
   206
121
claus
parents: 120
diff changeset
   207
1064
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   208
  with a model (see in the inspector, how the index-holders value changes)
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   209
  the defaults are setup to allow a SelectionInList directly as model:
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   210
                                                                        [exBegin]
119
claus
parents: 105
diff changeset
   211
     |p model|
claus
parents: 105
diff changeset
   212
claus
parents: 105
diff changeset
   213
     model := SelectionInList with:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
claus
parents: 105
diff changeset
   214
claus
parents: 105
diff changeset
   215
     p := PopUpList label:'healthy fruit'.
claus
parents: 105
diff changeset
   216
     p model:model.
claus
parents: 105
diff changeset
   217
     p open.
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   218
     model inspect
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   219
                                                                        [exEnd]
121
claus
parents: 120
diff changeset
   220
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   221
125
claus
parents: 121
diff changeset
   222
    a popupList and a SelectionInListView on the same model:
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   223
                                                                        [exBegin]
125
claus
parents: 121
diff changeset
   224
     |p slv model|
claus
parents: 121
diff changeset
   225
claus
parents: 121
diff changeset
   226
     model := SelectionInList with:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
claus
parents: 121
diff changeset
   227
     model selection:'apples'.
claus
parents: 121
diff changeset
   228
claus
parents: 121
diff changeset
   229
     p := PopUpList on:model.
1064
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   230
     p open.
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   231
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   232
     slv := SelectionInListView on:model.
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   233
     slv open.
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   234
                                                                        [exEnd]
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   235
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   236
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   237
    dynamically changing the list (click button(s) to change):
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   238
                                                                        [exBegin]
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   239
     |p slv model b|
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   240
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   241
     model := SelectionInList with:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   242
     model selection:'apples'.
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   243
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   244
     p := PopUpList on:model.
125
claus
parents: 121
diff changeset
   245
     p open.
claus
parents: 121
diff changeset
   246
claus
parents: 121
diff changeset
   247
     slv := SelectionInListView on:model.
claus
parents: 121
diff changeset
   248
     slv open.
claus
parents: 121
diff changeset
   249
1064
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   250
     b := Button label:'long list' action:[model list:#('1' '2' '3' '4' '5' '6')].
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   251
     b open.
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   252
     b := Button label:'short list' action:[model list:#('1' '2' '3')].
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   253
     b open.
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   254
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   255
                                                                        [exEnd]
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   256
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   257
125
claus
parents: 121
diff changeset
   258
127
claus
parents: 126
diff changeset
   259
    two PopUpLists on the same model, different aspects:
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   260
                                                                        [exBegin]
121
claus
parents: 120
diff changeset
   261
     |top panel p model|
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   262
121
claus
parents: 120
diff changeset
   263
     model := Plug new.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   264
     model respondTo:#eat: with:[:val | Transcript showCR:'eat: ' , val].
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   265
     model respondTo:#drink: with:[:val | Transcript showCR:'drink: ' , val].
121
claus
parents: 120
diff changeset
   266
     model respondTo:#meals with:[#(taco burrito enchilada)].
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   267
     model respondTo:#drinks with:[#(margarita water corona)].
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   268
121
claus
parents: 120
diff changeset
   269
     top := StandardSystemView new.
claus
parents: 120
diff changeset
   270
     top extent:(100@100).
claus
parents: 120
diff changeset
   271
     panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
claus
parents: 120
diff changeset
   272
     panel horizontalLayout:#fitSpace.
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   273
121
claus
parents: 120
diff changeset
   274
     p := PopUpList label:'meals'.
126
claus
parents: 125
diff changeset
   275
     p model:model; listMessage:#meals; aspect:nil; change:#eat:.
121
claus
parents: 120
diff changeset
   276
     panel add:p.
119
claus
parents: 105
diff changeset
   277
121
claus
parents: 120
diff changeset
   278
     p := PopUpList label:'drinks'.
126
claus
parents: 125
diff changeset
   279
     p model:model; listMessage:#drinks; aspect:nil; change:#drink:.
121
claus
parents: 120
diff changeset
   280
     panel add:p.
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   281
121
claus
parents: 120
diff changeset
   282
     top open
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   283
                                                                        [exEnd]
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   284
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   285
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   286
    with separate list- and indexHolders:
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   287
                                                                        [exBegin]
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   288
     |p selectionHolder listHolder|
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   289
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   290
     listHolder := #('apples' 'bananas' 'grape' 'lemon' 'margaritas') asValue.
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   291
     selectionHolder := 'apples' asValue.
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   292
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   293
     p := PopUpList label:'healthy fruit'.
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   294
     p listHolder:listHolder.
1064
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   295
     p selectionHolder:selectionHolder.
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   296
     p open.
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   297
     selectionHolder inspect
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   298
                                                                        [exEnd]
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   299
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   300
    same, using index:
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   301
                                                                        [exBegin]
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   302
     |p selectionIndexHolder listHolder|
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   303
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   304
     listHolder := #('apples' 'bananas' 'grape' 'lemon' 'margaritas') asValue.
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   305
     selectionIndexHolder := 3 asValue.
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   306
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   307
     p := PopUpList new.
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   308
     p listHolder:listHolder.
1064
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   309
     p selectionHolder:selectionIndexHolder.
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   310
     p useIndex:true.
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   311
     p open.
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   312
     selectionIndexHolder inspect
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   313
                                                                        [exEnd]
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   314
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   315
121
claus
parents: 120
diff changeset
   316
"
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   317
! !
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   318
998
ab1890b4e157 specClass
ca
parents: 799
diff changeset
   319
!PopUpList class methodsFor:'defaults'!
125
claus
parents: 121
diff changeset
   320
claus
parents: 121
diff changeset
   321
defaultAspectMessage
claus
parents: 121
diff changeset
   322
    ^ #selection
claus
parents: 121
diff changeset
   323
!
claus
parents: 121
diff changeset
   324
claus
parents: 121
diff changeset
   325
defaultChangeMessage
claus
parents: 121
diff changeset
   326
    ^ #selection:
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   327
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   328
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   329
defaultListMessage
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   330
    ^ #list 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   331
! !
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   332
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   333
!PopUpList methodsFor:'accessing'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   334
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   335
contents
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   336
    ^ self label
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   337
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   338
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   339
contents:con
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   340
    ^ self selection:con
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   341
684
015c23130d7b selection: / setSelection:
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
   342
    "Modified: 25.5.1996 / 14:20:57 / cg"
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   343
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   344
1035
c7cfaead1621 dont pop menu if there are no list items.
ca
parents: 1012
diff changeset
   345
defaultLabel:aString
c7cfaead1621 dont pop menu if there are no list items.
ca
parents: 1012
diff changeset
   346
    "set the defaultLabel, to be shown if nothing is selected"
c7cfaead1621 dont pop menu if there are no list items.
ca
parents: 1012
diff changeset
   347
c7cfaead1621 dont pop menu if there are no list items.
ca
parents: 1012
diff changeset
   348
    defaultLabel := aString
c7cfaead1621 dont pop menu if there are no list items.
ca
parents: 1012
diff changeset
   349
!
c7cfaead1621 dont pop menu if there are no list items.
ca
parents: 1012
diff changeset
   350
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   351
list
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   352
    "return the list - i.e. the values shown in the pop-up list"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   353
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   354
    ^ menu labels
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   355
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   356
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   357
list:aList
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   358
    "set the list - i.e. the values shown in the pop-up list"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   359
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   360
    self createMenuFor:aList.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   361
    realized ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   362
	self computeLabelSize
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   363
    ]
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   364
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   365
    "
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   366
     |p|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   367
     p := PopUpList label:'fruit ?'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   368
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   369
     p action:[:val | Transcript showCR:'selected: ' , val printString].   
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   370
     p open
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   371
    "
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   372
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   373
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   374
selection:indexOrString
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   375
    "set (force) a selection - usually done to set
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   376
     an initial selection without updating others"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   377
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   378
    |index wasFix|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   379
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   380
    menu isNil ifTrue:[
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   381
	self getListFromModel.
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   382
    ].
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   383
    menu isNil ifTrue:[^ self].
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   384
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   385
    index := menu indexOf:indexOrString.
1035
c7cfaead1621 dont pop menu if there are no list items.
ca
parents: 1012
diff changeset
   386
    index == 0 ifTrue:[
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   387
	self label:defaultLabel.
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   388
	^ self
1035
c7cfaead1621 dont pop menu if there are no list items.
ca
parents: 1012
diff changeset
   389
    ].
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   390
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   391
    "kludge: dont want label to resize ..."
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   392
    wasFix := fixSize. fixSize := true.
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   393
    self label:(menu labels at:index) printString.
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   394
    fixSize := wasFix
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   395
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   396
    "
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   397
     |p|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   398
     p := PopUpList label:'what fruit ?'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   399
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   400
     p selection:'grape'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   401
     p open 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   402
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   403
     |p|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   404
     p := PopUpList label:'what fruit ?'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   405
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   406
     p selection:'blabla'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   407
     p open
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   408
    "
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   409
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   410
    "Modified: 8.2.1996 / 12:55:01 / cg"
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   411
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   412
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   413
values:aList
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   414
    "set a value list - these are reported via the action or changeSymbol instead of
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   415
     the label strings."
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   416
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   417
    values := aList.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   418
    menu args:(1 to:aList size).
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   419
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   420
    "
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   421
     |p|
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   422
     p := PopUpList label:'fruit ?'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   423
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   424
     p values:#(1 2 3 4 'mhmh - good').
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   425
     p action:[:val | Transcript showCR:'selected: ' , val printString].   
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   426
     p open.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   427
    "
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   428
! !
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   429
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   430
!PopUpList methodsFor:'accessing-behavior'!
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   431
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   432
action:aOneArgBlock
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   433
    "set the action to be performed on selection changes;
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   434
     the argument, aOneArgBlock will be evaluated with the
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   435
     selection-value as argument"
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   436
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   437
    menuAction := aOneArgBlock
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   438
!
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   439
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   440
useIndex:aBoolean 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   441
    "tell the popuplist to pass the index (instead of the value)
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   442
     to both the actionBlock and model. Notice, that if you use a model,
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   443
     the default changeSelector is not ok for using index and a SelectionInList"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   444
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   445
    useIndex := aBoolean
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   446
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   447
    "
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   448
     |p|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   449
     p := PopUpList label:'fruit ?'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   450
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   451
     p action:[:val | Transcript showCR:'selected: ' , val printString].   
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   452
     p open.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   453
    "
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   454
    "
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   455
     |p|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   456
     p := PopUpList label:'fruit ?'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   457
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   458
     p action:[:val | Transcript showCR:'selected: ' , val printString].   
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   459
     p useIndex:true.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   460
     p open.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   461
    "
125
claus
parents: 121
diff changeset
   462
! !
claus
parents: 121
diff changeset
   463
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   464
!PopUpList methodsFor:'accessing-mvc'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   465
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   466
addModelInterfaceTo:aDictionary
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   467
    "see comment in View>>modelInterface"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   468
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   469
    super addModelInterfaceTo:aDictionary.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   470
    aDictionary at:#listMessage put:listMsg
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   471
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   472
    "Modified: 26.2.1997 / 19:08:04 / cg"
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   473
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   474
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   475
getListFromModel
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   476
    "if I have a listHolder, ask it for the list;
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   477
     otherwise, if I have a model and a listMsg, get my list from there"
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   478
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   479
    listHolder notNil ifTrue:[
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   480
        self list:listHolder value
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   481
    ] ifFalse:[
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   482
        (listMsg notNil and:[model notNil]) ifTrue:[
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   483
            self list:(model perform:listMsg).
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   484
        ].
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   485
    ]
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   486
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   487
    "Modified: 26.2.1997 / 19:07:36 / cg"
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   488
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   489
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   490
getSelectionFromModel
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   491
    "if I have a model and an aspectMsg, get my current value from it"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   492
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   493
    (model notNil and:[aspectMsg notNil]) ifTrue:[
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   494
        self selection:(model perform:aspectMsg)
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   495
    ].
684
015c23130d7b selection: / setSelection:
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
   496
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   497
    "Modified: 26.2.1997 / 18:21:59 / cg"
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   498
!
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   499
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   500
listHolder
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   501
    "return the listHolder if any"
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   502
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   503
    ^ listHolder
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   504
!
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   505
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   506
listHolder:aValueHolder
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   507
    "set the listHolder - if non nil, that one is assumed to provide the
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   508
     list via #value.
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   509
     If a listHolder was defined, the model is never asked for the list."
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   510
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   511
    listHolder notNil ifTrue:[
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   512
        listHolder removeDependent:self.
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   513
    ].
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   514
    listHolder := aValueHolder.
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   515
    listHolder notNil ifTrue:[
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   516
        listHolder addDependent:self.
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   517
    ].
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   518
    shown ifTrue:[
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   519
        self getListFromModel
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   520
    ]
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   521
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   522
    "Modified: 26.2.1997 / 19:06:01 / cg"
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   523
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   524
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   525
listMessage
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   526
    "return the selector by which we ask the model or listHolder for the list.
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   527
     The default is #list. 
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   528
     If a listHolder was defined, the model is never asked for the list."
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   529
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   530
    ^ listMsg
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   531
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   532
    "Modified: 26.2.1997 / 19:05:27 / cg"
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   533
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   534
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   535
listMessage:aSelector
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   536
    "set the selector by which we ask the model for the list.
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   537
     The default is #list. 
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   538
     If a listHolder was defined, the model is never asked for the list."
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   539
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   540
    listMsg := aSelector
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   541
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   542
    "Modified: 26.2.1997 / 19:05:18 / cg"
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   543
! !
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   544
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   545
!PopUpList methodsFor:'change & update'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   546
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   547
update:something with:aParameter from:changedObject
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   548
    changedObject == listHolder ifTrue:[
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   549
        self getListFromModel.
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   550
        ^ self
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   551
    ].
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   552
    changedObject == model ifTrue:[
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   553
        (something == aspectMsg 
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   554
        or:[something == #selectionIndex]) ifTrue:[
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   555
            self getSelectionFromModel.
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   556
            ^ self
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   557
        ].
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   558
        something == listMsg ifTrue:[
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   559
            self getListFromModel.
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   560
        ].
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   561
        ^ self
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   562
    ].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   563
    super update:something with:aParameter from:changedObject
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   564
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   565
    "Modified: 26.2.1997 / 18:23:27 / cg"
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   566
! !
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   567
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   568
!PopUpList methodsFor:'drawing'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   569
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   570
drawWith:fgColor and:bgColor
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   571
    |mmH mmV mW mH|
136
claus
parents: 135
diff changeset
   572
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   573
    controller pressed ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   574
	super drawWith:enteredFgColor and:enteredBgColor
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   575
    ] ifFalse:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   576
	super drawWith:fgColor and:bgColor.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   577
    ].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   578
    mmH := device horizontalPixelPerMillimeter rounded.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   579
    mmV := device verticalPixelPerMillimeter rounded.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   580
    mW := (device horizontalPixelPerMillimeter * 2.5) rounded.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   581
    mH := (device verticalPixelPerMillimeter * 1.5) rounded.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   582
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   583
    self drawEdgesForX:(width - mW - (hSpace*2)) y:(height - mmV // 2)
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   584
		 width:mW height:mH level:2
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   585
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   586
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   587
showActive
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   588
    "no need to redraw - will pop menu ontop of me anyway ..."
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   589
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   590
    ^ self
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   591
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   592
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   593
showPassive
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   594
    "no need to redraw - will redraw from unpopped menu anyway ..."
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   595
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   596
    ^ self
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   597
! !
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   598
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   599
!PopUpList methodsFor:'event handling'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   600
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   601
popMenu
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   602
    |org mv w|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   603
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   604
    menu notNil ifTrue:[
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   605
	self turnOffWithoutRedraw. 
1035
c7cfaead1621 dont pop menu if there are no list items.
ca
parents: 1012
diff changeset
   606
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   607
	menu labels size == 0 ifTrue:[
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   608
	    ^ self
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   609
	].
1035
c7cfaead1621 dont pop menu if there are no list items.
ca
parents: 1012
diff changeset
   610
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   611
	menu font:font.
136
claus
parents: 135
diff changeset
   612
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   613
	"
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   614
	 adjust the menus width to my current width
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   615
	"
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   616
	mv := menu menuView.
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   617
	mv create.      "/ stupid: it resizes itself upon first create
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   618
	w := mv width.  "/ to its preferred size.
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   619
	w := w max:(self width - (2 * menu margin) - (menu borderWidth*2)).
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   620
	mv width:w.
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   621
	mv level:0; borderWidth:0.
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   622
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   623
	"
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   624
	 the popupMenu wants Display coordinates in its showAt: method
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   625
	"
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   626
	org := device translatePoint:0@0 
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   627
				from:(self id)
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   628
				  to:(device rootView id).
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   629
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   630
	menu showAt:org "resizing:false"
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   631
    ].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   632
! !
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   633
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   634
!PopUpList methodsFor:'initialization'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   635
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   636
defaultControllerClass
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   637
    ^ PopUpListController
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   638
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   639
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   640
initialize
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   641
    super initialize.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   642
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   643
    controller beTriggerOnDown.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   644
    controller action:[self popMenu].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   645
    self adjust:#left.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   646
    useIndex := false.
1035
c7cfaead1621 dont pop menu if there are no list items.
ca
parents: 1012
diff changeset
   647
    defaultLabel := 'popup'.
c7cfaead1621 dont pop menu if there are no list items.
ca
parents: 1012
diff changeset
   648
    self label:defaultLabel.
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   649
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   650
    listMsg := self class defaultListMessage.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   651
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   652
    onLevel := offLevel.
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   653
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   654
    "Modified: 26.2.1997 / 18:23:43 / cg"
136
claus
parents: 135
diff changeset
   655
! !
claus
parents: 135
diff changeset
   656
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   657
!PopUpList methodsFor:'private'!
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   658
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   659
computeLabelSize
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   660
    "compute the extent needed to hold the label plus the mark"
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   661
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   662
    |mmH mmV savedLogo longest longestWidth labels|
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   663
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   664
    menu isNil ifTrue:[
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   665
	super computeLabelSize
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   666
    ] ifFalse:[
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   667
	"hack: simulate logo change to longest menu entry"
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   668
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   669
	font := font on:device.
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   670
	longest := logo.
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   671
	logo isNil ifTrue:[
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   672
	    longestWidth := 0
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   673
	] ifFalse:[
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   674
	    longestWidth := font widthOf:logo.
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   675
	].
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   676
	labels := menu labels.
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   677
	labels notNil ifTrue:[
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   678
	    labels do:[:entry |
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   679
		|this|
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   680
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   681
		this := font widthOf:entry printString.
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   682
		this > longestWidth ifTrue:[
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   683
		    longest := entry.
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   684
		    longestWidth := this
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   685
		].
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   686
	    ].
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   687
	].
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   688
	savedLogo := logo.
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   689
	logo := longest printString.
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   690
	super computeLabelSize.
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   691
	logo := savedLogo.
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   692
    ].
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   693
    mmH := device horizontalPixelPerMillimeter.
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   694
    mmV := device verticalPixelPerMillimeter.
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   695
    labelWidth := labelWidth + hSpace + (mmH * 2.5) rounded + hSpace.
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   696
    labelHeight := labelHeight max: (mmV * 2) rounded
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   697
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   698
    "Modified: 8.2.1996 / 13:00:33 / cg"
121
claus
parents: 120
diff changeset
   699
!
claus
parents: 120
diff changeset
   700
claus
parents: 120
diff changeset
   701
createMenuFor:aList
claus
parents: 120
diff changeset
   702
    menu := PopUpMenu
claus
parents: 120
diff changeset
   703
		  labels:aList
claus
parents: 120
diff changeset
   704
	       selectors:#select:
claus
parents: 120
diff changeset
   705
		    args:(1 to:aList size) 
claus
parents: 120
diff changeset
   706
		receiver:self
claus
parents: 120
diff changeset
   707
		     for:self.
128
claus
parents: 127
diff changeset
   708
!
claus
parents: 127
diff changeset
   709
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   710
realize
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   711
    super realize.
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   712
    (model notNil or:[listHolder notNil]) ifTrue:[
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   713
        self getListFromModel.
121
claus
parents: 120
diff changeset
   714
    ].
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   715
    model notNil ifTrue:[
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   716
        self getSelectionFromModel.
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   717
    ]
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   718
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   719
    "Modified: 26.2.1997 / 18:23:58 / cg"
121
claus
parents: 120
diff changeset
   720
! !
claus
parents: 120
diff changeset
   721
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   722
!PopUpList methodsFor:'private-controller access'!
121
claus
parents: 120
diff changeset
   723
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   724
menu
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   725
    "return the menu component"
125
claus
parents: 121
diff changeset
   726
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   727
    ^ menu
126
claus
parents: 125
diff changeset
   728
! !
claus
parents: 125
diff changeset
   729
136
claus
parents: 135
diff changeset
   730
!PopUpList methodsFor:'queries'!
claus
parents: 135
diff changeset
   731
claus
parents: 135
diff changeset
   732
preferredExtent
claus
parents: 135
diff changeset
   733
    "redefined to make certain that the menu is fully defined"
claus
parents: 135
diff changeset
   734
799
64f8700489a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   735
    "/ If I have an explicit preferredExtent ..
64f8700489a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   736
714
5ff02d2d9fa7 care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents: 694
diff changeset
   737
    preferredExtent notNil ifTrue:[
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   738
	^ preferredExtent
714
5ff02d2d9fa7 care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents: 694
diff changeset
   739
    ].
5ff02d2d9fa7 care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents: 694
diff changeset
   740
136
claus
parents: 135
diff changeset
   741
    menu isNil ifTrue:[
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   742
	self getListFromModel
136
claus
parents: 135
diff changeset
   743
    ].
claus
parents: 135
diff changeset
   744
    self computeLabelSize.
claus
parents: 135
diff changeset
   745
    ^ super preferredExtent.
714
5ff02d2d9fa7 care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents: 694
diff changeset
   746
799
64f8700489a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   747
    "Modified: 19.7.1996 / 20:45:16 / cg"
155
claus
parents: 136
diff changeset
   748
!
claus
parents: 136
diff changeset
   749
claus
parents: 136
diff changeset
   750
specClass
claus
parents: 136
diff changeset
   751
    self class == PopUpList ifTrue:[^ PopUpListSpec].
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   752
    ^ super specClass
136
claus
parents: 135
diff changeset
   753
! !
claus
parents: 135
diff changeset
   754
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   755
!PopUpList methodsFor:'user actions'!
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   756
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   757
select:anEntry
119
claus
parents: 105
diff changeset
   758
    "this is sent from the popupmenu when an entry was selected"
claus
parents: 105
diff changeset
   759
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   760
    |value label|
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   761
119
claus
parents: 105
diff changeset
   762
    label := menu labels at:anEntry.
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   763
    values isNil ifTrue:[
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   764
        value := anEntry.
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   765
        useIndex ifFalse:[
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   766
            value := menu labels at:anEntry.
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   767
        ]
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   768
    ] ifFalse:[
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   769
        value := values at:anEntry
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   770
    ].
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   771
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   772
    self sizeFixed:true.
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   773
    self label:label printString.
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   774
1012
36f7cb7862b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 998
diff changeset
   775
    "/
36f7cb7862b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 998
diff changeset
   776
    "/ ST-80 way of doing it
36f7cb7862b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 998
diff changeset
   777
    "/ tell my model - if any
36f7cb7862b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 998
diff changeset
   778
    "/
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   779
    self sendChangeMessageWith:value.
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   780
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   781
    "/
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   782
    "/ ST/X action blocks
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   783
    "/
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   784
    menuAction notNil ifTrue:[
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   785
        menuAction value:value.
1052
59f182d1304f added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   786
    ].
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   787
1063
b315e2580bc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
   788
    "Modified: 26.2.1997 / 18:24:16 / cg"
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   789
! !
121
claus
parents: 120
diff changeset
   790
998
ab1890b4e157 specClass
ca
parents: 799
diff changeset
   791
!PopUpList class methodsFor:'documentation'!
121
claus
parents: 120
diff changeset
   792
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   793
version
1064
dba203683e94 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1063
diff changeset
   794
    ^ '$Header: /cvs/stx/stx/libwidg/PopUpList.st,v 1.34 1997-02-27 09:05:15 cg Exp $'
121
claus
parents: 120
diff changeset
   795
! !