PopUpList.st
author Claus Gittinger <cg@exept.de>
Sat, 27 Apr 1996 20:21:37 +0200
changeset 593 86dd024ed773
parent 585 8f395aba0173
child 655 acad3ef3a46c
permissions -rw-r--r--
examples
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    14
	instanceVariableNames:'menu menuAction values useIndex listMsg'
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
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    20
!PopUpList class methodsFor:'documentation'!
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
121
claus
parents: 120
diff changeset
    44
    The default changeMessage used is #selection:, which allows a
claus
parents: 120
diff changeset
    45
    PopUpList to be used with a SelectionInList as model.
claus
parents: 120
diff changeset
    46
    (if used with some other model, either use an adaptor, or set the
125
claus
parents: 121
diff changeset
    47
     changeMessage to something else ..)
claus
parents: 121
diff changeset
    48
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 327
diff changeset
    49
    [Instance variables:]
125
claus
parents: 121
diff changeset
    50
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 327
diff changeset
    51
        menu                            helpers for the popup menu
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 327
diff changeset
    52
        menuAction 
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 327
diff changeset
    53
        values 
125
claus
parents: 121
diff changeset
    54
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 327
diff changeset
    55
        useIndex             <Boolean>  if true, the index of the selected entry
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 327
diff changeset
    56
                                        is passed to the action block and the
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 327
diff changeset
    57
                                        model in a change-message.
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 327
diff changeset
    58
                                        If false (the default), the value is passed.
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 327
diff changeset
    59
                                        Notice that the default changeMessage is
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 327
diff changeset
    60
                                        #selection:, which is not ok to be used
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 327
diff changeset
    61
                                        with useIndex:true and a selectionInList model.
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 327
diff changeset
    62
                                        (set the changeMessage to #selectionIndex: then)
125
claus
parents: 121
diff changeset
    63
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 327
diff changeset
    64
        listMsg              <Symbol>   message to aquire a new list from the
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 327
diff changeset
    65
                                        model. Default is #list.
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 327
diff changeset
    66
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 327
diff changeset
    67
    [see also:]
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 327
diff changeset
    68
        SelectionInListView
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 327
diff changeset
    69
        SelectionInList
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 327
diff changeset
    70
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 327
diff changeset
    71
    [author:]
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 327
diff changeset
    72
        Claus Gittinger
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    73
"
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    74
!
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    75
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    76
examples
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    77
"
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    78
    example use:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    79
                                                                        [exBegin]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    80
     |p|
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    81
     p := PopUpList label:'healthy fruit'.
119
claus
parents: 105
diff changeset
    82
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    83
     p open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    84
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    85
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    86
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    87
    with an initial selection:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    88
                                                                        [exBegin]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    89
     |p|
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    90
     p := PopUpList label:'dummy'.
119
claus
parents: 105
diff changeset
    91
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    92
     p selection:'apples'.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    93
     p open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    94
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    95
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    96
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    97
    with separating lines:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    98
                                                                        [exBegin]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    99
     |p|
119
claus
parents: 105
diff changeset
   100
     p := PopUpList label:'fruit'.
claus
parents: 105
diff changeset
   101
     p list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas').
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
   102
     p selection:'apples'.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
   103
     p open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   104
                                                                        [exEnd]
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   105
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   106
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   107
    with an action:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   108
                                                                        [exBegin]
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   109
     |p|
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   110
     p := PopUpList label:'dummy'.
119
claus
parents: 105
diff changeset
   111
     p list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas').
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   112
     p selection:'apples'.
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   113
     p action:[:what | Transcript showCr:'you selected: ' , what].
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   114
     p open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   115
                                                                        [exEnd]
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   116
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   117
119
claus
parents: 105
diff changeset
   118
    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
   119
    (notice, that the separating line counts, so you have to take care ...)
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   120
                                                                        [exBegin]
119
claus
parents: 105
diff changeset
   121
     |p|
claus
parents: 105
diff changeset
   122
     p := PopUpList label:'dummy'.
claus
parents: 105
diff changeset
   123
     p list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas').
claus
parents: 105
diff changeset
   124
     p selection:'apples'.
claus
parents: 105
diff changeset
   125
     p action:[:what | Transcript show:'you selected: '; showCr:what].
claus
parents: 105
diff changeset
   126
     p useIndex:true.
claus
parents: 105
diff changeset
   127
     p open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   128
                                                                        [exEnd]
119
claus
parents: 105
diff changeset
   129
claus
parents: 105
diff changeset
   130
claus
parents: 105
diff changeset
   131
    since the list is actually a popupMenu, you can add double-separators:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   132
                                                                        [exBegin]
119
claus
parents: 105
diff changeset
   133
     |p|
claus
parents: 105
diff changeset
   134
     p := PopUpList label:'dummy'.
claus
parents: 105
diff changeset
   135
     p list:#('apples' 'bananas' 'grape' 'lemon' 
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   136
              '=' 
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   137
              'margaritas' 'pina colada'
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   138
              '=' 
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   139
              'smalltalk' 'c++' 'eiffel' 'java').
119
claus
parents: 105
diff changeset
   140
     p values:#(apples bananas grape lemon 
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   141
                nil 
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   142
                'mhmh - so good' 'makes headache'
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   143
                nil
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   144
                'great' 'another headache' 'not bad' 'neat').
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   145
     p selection:'apples'.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   146
     p action:[:what | Transcript show:'you selected: '; showCr:what].
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   147
     p open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   148
                                                                        [exEnd]
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   149
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   150
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   151
    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
   152
    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
   153
    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
   154
    (see ListEntry classes)
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   155
                                                                        [exBegin]
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   156
     |p l|
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   157
     p := PopUpList label:'dummy'.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   158
     l := OrderedCollection new.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   159
     l add:(ColoredListEntry string:'apples' color:Color red).
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   160
     l add:(ColoredListEntry string:'bananas' color:Color red).
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   161
     l add:(ColoredListEntry string:'grape' color:Color red).
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   162
     l add:(ColoredListEntry string:'lemon' color:Color red).
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   163
     l add:'='.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   164
     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
   165
     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
   166
     l add:'='.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   167
     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
   168
     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
   169
     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
   170
     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
   171
     p list:l.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   172
     p values:#(apples bananas grape lemon 
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   173
                nil 
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   174
                'mhmh - so good' 'makes headache'
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   175
                nil
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   176
                'great' 'another headache' 'not bad' 'neat').
119
claus
parents: 105
diff changeset
   177
     p selection:'apples'.
claus
parents: 105
diff changeset
   178
     p action:[:what | Transcript show:'you selected: '; showCr:what].
claus
parents: 105
diff changeset
   179
     p open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   180
                                                                        [exEnd]
119
claus
parents: 105
diff changeset
   181
claus
parents: 105
diff changeset
   182
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   183
    with values different from the label strings:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   184
                                                                        [exBegin]
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   185
     |p|
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   186
     p := PopUpList label:'dummy'.
119
claus
parents: 105
diff changeset
   187
     p list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas').
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   188
     p selection:'apples'.
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   189
     p values:#(10 20 30 40 nil 50).
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   190
     p action:[:what | Transcript show:'you selected: '; showCr:what].
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   191
     p open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   192
                                                                        [exEnd]
119
claus
parents: 105
diff changeset
   193
121
claus
parents: 120
diff changeset
   194
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   195
    with a model (see in the inspector, how the valueHolders index-value changes):
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   196
                                                                        [exBegin]
119
claus
parents: 105
diff changeset
   197
     |p model|
claus
parents: 105
diff changeset
   198
claus
parents: 105
diff changeset
   199
     model := SelectionInList with:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
claus
parents: 105
diff changeset
   200
claus
parents: 105
diff changeset
   201
     p := PopUpList label:'healthy fruit'.
claus
parents: 105
diff changeset
   202
     p model:model.
claus
parents: 105
diff changeset
   203
     p open.
121
claus
parents: 120
diff changeset
   204
     model selectionIndexHolder inspect
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   205
                                                                        [exEnd]
121
claus
parents: 120
diff changeset
   206
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   207
125
claus
parents: 121
diff changeset
   208
    a popupList and a SelectionInListView on the same model:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   209
                                                                        [exBegin]
125
claus
parents: 121
diff changeset
   210
     |p slv model|
claus
parents: 121
diff changeset
   211
claus
parents: 121
diff changeset
   212
     model := SelectionInList with:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
claus
parents: 121
diff changeset
   213
     model selection:'apples'.
claus
parents: 121
diff changeset
   214
claus
parents: 121
diff changeset
   215
     p := PopUpList on:model.
126
claus
parents: 125
diff changeset
   216
     p useIndex:true; aspect:#selectionIndex; change:#selectionIndex:.
125
claus
parents: 121
diff changeset
   217
     p open.
claus
parents: 121
diff changeset
   218
claus
parents: 121
diff changeset
   219
     slv := SelectionInListView on:model.
claus
parents: 121
diff changeset
   220
     slv open.
claus
parents: 121
diff changeset
   221
126
claus
parents: 125
diff changeset
   222
     p inspect.
125
claus
parents: 121
diff changeset
   223
     model selectionIndexHolder inspect
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   224
                                                                        [exEnd]
125
claus
parents: 121
diff changeset
   225
claus
parents: 121
diff changeset
   226
127
claus
parents: 126
diff changeset
   227
    two PopUpLists on the same model, different aspects:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   228
                                                                        [exBegin]
121
claus
parents: 120
diff changeset
   229
     |top panel p model|
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   230
121
claus
parents: 120
diff changeset
   231
     model := Plug new.
claus
parents: 120
diff changeset
   232
     model respondTo:#eat: with:[:val | Transcript showCr:'eat: ' , val].
claus
parents: 120
diff changeset
   233
     model respondTo:#drink: with:[:val | Transcript showCr:'drink: ' , val].
claus
parents: 120
diff changeset
   234
     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
   235
     model respondTo:#drinks with:[#(margarita water corona)].
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   236
121
claus
parents: 120
diff changeset
   237
     top := StandardSystemView new.
claus
parents: 120
diff changeset
   238
     top extent:(100@100).
claus
parents: 120
diff changeset
   239
     panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
claus
parents: 120
diff changeset
   240
     panel horizontalLayout:#fitSpace.
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   241
121
claus
parents: 120
diff changeset
   242
     p := PopUpList label:'meals'.
126
claus
parents: 125
diff changeset
   243
     p model:model; listMessage:#meals; aspect:nil; change:#eat:.
121
claus
parents: 120
diff changeset
   244
     panel add:p.
119
claus
parents: 105
diff changeset
   245
121
claus
parents: 120
diff changeset
   246
     p := PopUpList label:'drinks'.
126
claus
parents: 125
diff changeset
   247
     p model:model; listMessage:#drinks; aspect:nil; change:#drink:.
121
claus
parents: 120
diff changeset
   248
     panel add:p.
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   249
121
claus
parents: 120
diff changeset
   250
     top open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   251
                                                                        [exEnd]
121
claus
parents: 120
diff changeset
   252
"
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   253
! !
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   254
125
claus
parents: 121
diff changeset
   255
!PopUpList class methodsFor:'defaults'!
claus
parents: 121
diff changeset
   256
claus
parents: 121
diff changeset
   257
defaultAspectMessage
claus
parents: 121
diff changeset
   258
    ^ #selection
claus
parents: 121
diff changeset
   259
!
claus
parents: 121
diff changeset
   260
claus
parents: 121
diff changeset
   261
defaultChangeMessage
claus
parents: 121
diff changeset
   262
    ^ #selection:
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   263
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   264
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   265
defaultListMessage
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   266
    ^ #list 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   267
! !
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   268
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   269
!PopUpList methodsFor:'accessing'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   270
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   271
contents
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   272
    ^ self label
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   273
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   274
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   275
contents:con
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   276
    ^ self selection:con
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   277
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   278
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   279
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   280
list
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   281
    "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
   282
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   283
    ^ menu labels
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   284
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   285
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   286
list:aList
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   287
    "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
   288
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   289
    self createMenuFor:aList.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   290
    realized ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   291
	self computeLabelSize
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   292
    ]
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   293
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   294
    "
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   295
     |p|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   296
     p := PopUpList label:'fruit ?'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   297
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   298
     p action:[:val | Transcript showCr:'selected: ' , val printString].   
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   299
     p open
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   300
    "
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   301
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   302
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   303
selection:indexOrString
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   304
    "set (force) a selection - usually done to set
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   305
     an initial selection without updating others"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   306
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   307
    |index wasFix|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   308
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   309
    index := menu indexOf:indexOrString.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   310
    index == 0 ifTrue:[^ self].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   311
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   312
    "kludge: dont want label to resize ..."
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   313
    wasFix := fixSize. fixSize := true.
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   314
    self label:(menu labels at:index) printString.
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   315
    fixSize := wasFix
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   316
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   317
    "
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   318
     |p|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   319
     p := PopUpList label:'what fruit ?'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   320
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   321
     p selection:'grape'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   322
     p open 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   323
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   324
     |p|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   325
     p := PopUpList label:'what fruit ?'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   326
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   327
     p selection:'blabla'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   328
     p open
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   329
    "
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   330
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   331
    "Modified: 8.2.1996 / 12:55:01 / cg"
205
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
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   334
values:aList
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   335
    "set a value list - these are reported via the action or changeSymbol instead of
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   336
     the labe strings."
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   337
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   338
    values := aList.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   339
    menu args:(1 to:aList size).
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   340
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   341
    "
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   342
     |p|
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   343
     p := PopUpList label:'fruit ?'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   344
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   345
     p values:#(1 2 3 4 'mhmh - good').
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   346
     p action:[:val | Transcript showCr:'selected: ' , val printString].   
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   347
     p open.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   348
    "
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   349
! !
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   350
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   351
!PopUpList methodsFor:'accessing-behavior'!
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   352
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   353
action:aOneArgBlock
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   354
    "set the action to be performed on selection changes;
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   355
     the argument, aOneArgBlock will be evaluated with the
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   356
     selection-value as argument"
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   357
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   358
    menuAction := aOneArgBlock
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   359
!
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   360
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   361
useIndex:aBoolean 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   362
    "tell the popuplist to pass the index (instead of the value)
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   363
     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
   364
     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
   365
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   366
    useIndex := aBoolean
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   367
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   368
    "
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   369
     |p|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   370
     p := PopUpList label:'fruit ?'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   371
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   372
     p action:[:val | Transcript showCr:'selected: ' , val printString].   
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   373
     p open.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   374
    "
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   375
    "
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   376
     |p|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   377
     p := PopUpList label:'fruit ?'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   378
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   379
     p action:[:val | Transcript showCr:'selected: ' , val printString].   
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   380
     p useIndex:true.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   381
     p open.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   382
    "
125
claus
parents: 121
diff changeset
   383
! !
claus
parents: 121
diff changeset
   384
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   385
!PopUpList methodsFor:'accessing-mvc'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   386
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   387
addModelInterfaceTo:aDictionary
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   388
    "see comment in View>>modelInterface"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   389
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   390
    super addModelInterfaceTo:aDictionary.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   391
    aDictionary at:#listMessage put:listMsg
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   392
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   393
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   394
getListFromModel
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   395
    "if I have a model and a listMsg, get my list from it"
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
    (model notNil 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   398
    and:[listMsg notNil]) ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   399
	self list:(model perform:listMsg).
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   400
    ].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   401
!
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
getSelectionFromModel
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   404
    "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
   405
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   406
    (model notNil 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   407
    and:[aspectMsg notNil]) ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   408
	menu isNil ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   409
	    self getListFromModel
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   410
	].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   411
	self selection:(model perform:aspectMsg).
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   412
    ].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   413
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   414
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   415
listMessage
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   416
    "return the selector by which we ask the model for the list.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   417
     Default is #list."
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   418
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   419
    ^ listMsg
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   420
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   421
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   422
listMessage:aSelector
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   423
    "set the selector by which we ask the model for the list.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   424
     Default is #list."
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   425
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   426
    listMsg := aSelector
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   427
! !
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   428
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   429
!PopUpList methodsFor:'change & update'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   430
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   431
update:something with:aParameter from:changedObject
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   432
    changedObject == model ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   433
	(something == aspectMsg 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   434
	or:[something == #selectionIndex]) ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   435
	    self getSelectionFromModel.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   436
	    ^ self
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   437
	].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   438
	something == listMsg ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   439
	    self getListFromModel.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   440
	].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   441
	^ self
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   442
    ].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   443
    super update:something with:aParameter from:changedObject
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
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   446
!PopUpList methodsFor:'drawing'!
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
drawWith:fgColor and:bgColor
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   449
    |mmH mmV mW mH|
136
claus
parents: 135
diff changeset
   450
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   451
    controller pressed ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   452
	super drawWith:enteredFgColor and:enteredBgColor
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   453
    ] ifFalse:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   454
	super drawWith:fgColor and:bgColor.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   455
    ].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   456
    mmH := device horizontalPixelPerMillimeter rounded.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   457
    mmV := device verticalPixelPerMillimeter rounded.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   458
    mW := (device horizontalPixelPerMillimeter * 2.5) rounded.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   459
    mH := (device verticalPixelPerMillimeter * 1.5) rounded.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   460
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   461
    self drawEdgesForX:(width - mW - (hSpace*2)) y:(height - mmV // 2)
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   462
		 width:mW height:mH level:2
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   463
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   464
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   465
showActive
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   466
    "no need to redraw - will pop menu ontop of me anyway ..."
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   467
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   468
    ^ self
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   469
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   470
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   471
showPassive
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   472
    "no need to redraw - will redraw from unpopped menu anyway ..."
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
    ^ self
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   475
! !
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   476
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   477
!PopUpList methodsFor:'event handling'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   478
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   479
popMenu
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   480
    |org mv w|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   481
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   482
    menu notNil ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   483
	self turnOffWithoutRedraw. 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   484
	menu font:font.
136
claus
parents: 135
diff changeset
   485
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   486
	"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   487
	 adjust the menus width to my current width
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
	mv := menu menuView.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   490
	mv create.      "/ stupid: it resizes itself upon first create
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   491
	w := mv width.  "/ to its preferred size.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   492
	w := w max:(self width - (2 * menu margin) - (menu borderWidth*2)).
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   493
	mv width:w.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   494
	mv level:0; borderWidth:0.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   495
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   496
	"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   497
	 the popupMenu wants Display coordinates in its showAt: method
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   498
	"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   499
	org := device translatePoint:0@0 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   500
				from:(self id)
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   501
				  to:(DisplayRootView new id).
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   502
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   503
	menu showAt:org "resizing:false"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   504
    ].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   505
! !
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   506
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   507
!PopUpList methodsFor:'initialization'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   508
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   509
defaultControllerClass
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   510
    ^ PopUpListController
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   511
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   512
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   513
initialize
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   514
    super initialize.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   515
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   516
    controller beTriggerOnDown.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   517
    controller action:[self popMenu].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   518
    self adjust:#left.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   519
    useIndex := false.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   520
    self label:'popup'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   521
    listMsg := self class defaultListMessage.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   522
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   523
    onLevel := offLevel.
136
claus
parents: 135
diff changeset
   524
! !
claus
parents: 135
diff changeset
   525
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   526
!PopUpList methodsFor:'private'!
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   527
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   528
computeLabelSize
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   529
    "compute the extent needed to hold the label plus the mark"
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   530
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   531
    |mmH mmV savedLogo longest longestWidth|
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   532
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   533
    menu isNil ifTrue:[
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   534
        super computeLabelSize
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   535
    ] ifFalse:[
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   536
        "hack: simulate logo change to longest menu entry"
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   537
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   538
        font := font on:device.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   539
        longest := logo.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   540
        longestWidth := font widthOf:logo.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   541
        menu labels do:[:entry |
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   542
            |this|
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   543
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   544
            this := font widthOf:entry printString.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   545
            this > longestWidth ifTrue:[
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   546
                longest := entry.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   547
                longestWidth := this
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   548
            ].
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   549
        ].
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   550
        savedLogo := logo.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   551
        logo := longest printString.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   552
        super computeLabelSize.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   553
        logo := savedLogo.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
   554
"self halt.     "
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   555
    ].
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   556
    mmH := device horizontalPixelPerMillimeter.
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   557
    mmV := device verticalPixelPerMillimeter.
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   558
    labelWidth := labelWidth + hSpace + (mmH * 2.5) rounded + hSpace.
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   559
    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
   560
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   561
    "Modified: 8.2.1996 / 13:00:33 / cg"
121
claus
parents: 120
diff changeset
   562
!
claus
parents: 120
diff changeset
   563
claus
parents: 120
diff changeset
   564
createMenuFor:aList
claus
parents: 120
diff changeset
   565
    menu := PopUpMenu
claus
parents: 120
diff changeset
   566
		  labels:aList
claus
parents: 120
diff changeset
   567
	       selectors:#select:
claus
parents: 120
diff changeset
   568
		    args:(1 to:aList size) 
claus
parents: 120
diff changeset
   569
		receiver:self
claus
parents: 120
diff changeset
   570
		     for:self.
128
claus
parents: 127
diff changeset
   571
!
claus
parents: 127
diff changeset
   572
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   573
realize
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   574
    super realize.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   575
    model notNil ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   576
	self getListFromModel.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   577
	self getSelectionFromModel.
121
claus
parents: 120
diff changeset
   578
    ].
claus
parents: 120
diff changeset
   579
! !
claus
parents: 120
diff changeset
   580
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   581
!PopUpList methodsFor:'private-controller access'!
121
claus
parents: 120
diff changeset
   582
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   583
menu
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   584
    "return the menu component"
125
claus
parents: 121
diff changeset
   585
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   586
    ^ menu
126
claus
parents: 125
diff changeset
   587
! !
claus
parents: 125
diff changeset
   588
136
claus
parents: 135
diff changeset
   589
!PopUpList methodsFor:'queries'!
claus
parents: 135
diff changeset
   590
claus
parents: 135
diff changeset
   591
preferredExtent
claus
parents: 135
diff changeset
   592
    "redefined to make certain that the menu is fully defined"
claus
parents: 135
diff changeset
   593
claus
parents: 135
diff changeset
   594
    menu isNil ifTrue:[
claus
parents: 135
diff changeset
   595
	self getListFromModel
claus
parents: 135
diff changeset
   596
    ].
claus
parents: 135
diff changeset
   597
    self computeLabelSize.
claus
parents: 135
diff changeset
   598
    ^ super preferredExtent.
155
claus
parents: 136
diff changeset
   599
!
claus
parents: 136
diff changeset
   600
claus
parents: 136
diff changeset
   601
specClass
claus
parents: 136
diff changeset
   602
    self class == PopUpList ifTrue:[^ PopUpListSpec].
claus
parents: 136
diff changeset
   603
    ^ nil
136
claus
parents: 135
diff changeset
   604
! !
claus
parents: 135
diff changeset
   605
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   606
!PopUpList methodsFor:'user actions'!
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   607
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   608
select:anEntry
119
claus
parents: 105
diff changeset
   609
    "this is sent from the popupmenu when an entry was selected"
claus
parents: 105
diff changeset
   610
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   611
    |value label|
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   612
119
claus
parents: 105
diff changeset
   613
    label := menu labels at:anEntry.
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   614
    values isNil ifTrue:[
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   615
        value := anEntry.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   616
        useIndex ifFalse:[
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   617
            value := menu labels at:anEntry.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   618
        ]
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   619
    ] ifFalse:[
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   620
        value := values at:anEntry
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   621
    ].
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   622
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   623
    menuAction notNil ifTrue:[
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   624
        menuAction value:value.
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   625
    ].
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   626
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   627
    self sizeFixed:true.
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   628
    self label:label printString.
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   629
119
claus
parents: 105
diff changeset
   630
    "
121
claus
parents: 120
diff changeset
   631
     tell my model - if any
119
claus
parents: 105
diff changeset
   632
    "
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   633
    self sendChangeMessageWith:value
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   634
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   635
    "Modified: 8.2.1996 / 11:58:51 / cg"
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   636
! !
121
claus
parents: 120
diff changeset
   637
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   638
!PopUpList class methodsFor:'documentation'!
121
claus
parents: 120
diff changeset
   639
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   640
version
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   641
    ^ '$Header: /cvs/stx/stx/libwidg/PopUpList.st,v 1.23 1996-04-27 18:18:33 cg Exp $'
121
claus
parents: 120
diff changeset
   642
! !