PopUpList.st
author Claus Gittinger <cg@exept.de>
Fri, 19 Jul 1996 20:57:13 +0200
changeset 799 64f8700489a4
parent 714 5ff02d2d9fa7
child 998 ab1890b4e157
permissions -rw-r--r--
*** empty log message ***
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
799
64f8700489a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 714
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
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'.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   113
     p action:[:what | Transcript showCR:'you selected: ' , what].
77
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'.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   125
     p action:[:what | Transcript show:'you selected: '; showCR:what].
119
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'.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   146
     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
   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'.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   178
     p action:[:what | Transcript show:'you selected: '; showCR:what].
119
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).
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   190
     p action:[:what | Transcript show:'you selected: '; showCR:what].
77
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.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   232
     model respondTo:#eat: with:[:val | Transcript showCR:'eat: ' , val].
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   233
     model respondTo:#drink: with:[:val | Transcript showCR:'drink: ' , val].
121
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
799
64f8700489a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   255
!PopUpList  class methodsFor:'defaults'!
125
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
684
015c23130d7b selection: / setSelection:
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
   278
    "Modified: 25.5.1996 / 14:20:57 / cg"
205
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
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   281
list
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   282
    "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
   283
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   284
    ^ menu labels
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
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   287
list:aList
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   288
    "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
   289
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   290
    self createMenuFor:aList.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   291
    realized ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   292
	self computeLabelSize
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
    "
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   296
     |p|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   297
     p := PopUpList label:'fruit ?'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   298
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   299
     p action:[:val | Transcript showCR:'selected: ' , val printString].   
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   300
     p open
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
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   304
selection:indexOrString
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   305
    "set (force) a selection - usually done to set
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   306
     an initial selection without updating others"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   307
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   308
    |index wasFix|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   309
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   310
    index := menu indexOf:indexOrString.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   311
    index == 0 ifTrue:[^ self].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   312
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   313
    "kludge: dont want label to resize ..."
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   314
    wasFix := fixSize. fixSize := true.
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   315
    self label:(menu labels at:index) printString.
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   316
    fixSize := wasFix
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
    "
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   319
     |p|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   320
     p := PopUpList label:'what fruit ?'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   321
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   322
     p selection:'grape'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   323
     p open 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   324
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   325
     |p|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   326
     p := PopUpList label:'what fruit ?'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   327
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   328
     p selection:'blabla'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   329
     p open
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   330
    "
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   331
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   332
    "Modified: 8.2.1996 / 12:55:01 / cg"
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   333
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   334
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   335
values:aList
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   336
    "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
   337
     the labe strings."
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   338
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   339
    values := aList.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   340
    menu args:(1 to:aList size).
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   341
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   342
    "
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   343
     |p|
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   344
     p := PopUpList label:'fruit ?'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   345
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   346
     p values:#(1 2 3 4 'mhmh - good').
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   347
     p action:[:val | Transcript showCR:'selected: ' , val printString].   
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   348
     p open.
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
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   352
!PopUpList methodsFor:'accessing-behavior'!
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   353
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   354
action:aOneArgBlock
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   355
    "set the action to be performed on selection changes;
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   356
     the argument, aOneArgBlock will be evaluated with the
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   357
     selection-value as argument"
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   358
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   359
    menuAction := aOneArgBlock
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   360
!
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   361
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   362
useIndex:aBoolean 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   363
    "tell the popuplist to pass the index (instead of the value)
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   364
     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
   365
     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
   366
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   367
    useIndex := aBoolean
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
    "
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   370
     |p|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   371
     p := PopUpList label:'fruit ?'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   372
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   373
     p action:[:val | Transcript showCR:'selected: ' , val printString].   
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   374
     p open.
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
    "
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   377
     |p|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   378
     p := PopUpList label:'fruit ?'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   379
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   380
     p action:[:val | Transcript showCR:'selected: ' , val printString].   
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   381
     p useIndex:true.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   382
     p open.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   383
    "
125
claus
parents: 121
diff changeset
   384
! !
claus
parents: 121
diff changeset
   385
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   386
!PopUpList methodsFor:'accessing-mvc'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   387
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   388
addModelInterfaceTo:aDictionary
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   389
    "see comment in View>>modelInterface"
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
    super addModelInterfaceTo:aDictionary.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   392
    aDictionary at:#listMessage put:listMsg
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
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   395
getListFromModel
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   396
    "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
   397
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   398
    (model notNil 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   399
    and:[listMsg notNil]) ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   400
	self list:(model perform:listMsg).
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
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   404
getSelectionFromModel
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   405
    "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
   406
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   407
    (model notNil 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   408
    and:[aspectMsg notNil]) ifTrue:[
684
015c23130d7b selection: / setSelection:
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
   409
        menu isNil ifTrue:[
015c23130d7b selection: / setSelection:
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
   410
            self getListFromModel
015c23130d7b selection: / setSelection:
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
   411
        ].
015c23130d7b selection: / setSelection:
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
   412
        self selection:(model perform:aspectMsg).
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   413
    ].
684
015c23130d7b selection: / setSelection:
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
   414
015c23130d7b selection: / setSelection:
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
   415
    "Modified: 25.5.1996 / 14:21:07 / cg"
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   416
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   417
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   418
listMessage
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   419
    "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
   420
     Default is #list."
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
    ^ listMsg
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   423
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   424
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   425
listMessage:aSelector
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   426
    "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
   427
     Default is #list."
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
    listMsg := aSelector
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
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   432
!PopUpList methodsFor:'change & update'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   433
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   434
update:something with:aParameter from:changedObject
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   435
    changedObject == model ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   436
	(something == aspectMsg 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   437
	or:[something == #selectionIndex]) ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   438
	    self getSelectionFromModel.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   439
	    ^ self
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
	something == listMsg ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   442
	    self getListFromModel.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   443
	].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   444
	^ self
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
    super update:something with:aParameter from:changedObject
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
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   449
!PopUpList methodsFor:'drawing'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   450
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   451
drawWith:fgColor and:bgColor
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   452
    |mmH mmV mW mH|
136
claus
parents: 135
diff changeset
   453
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   454
    controller pressed ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   455
	super drawWith:enteredFgColor and:enteredBgColor
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   456
    ] ifFalse:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   457
	super drawWith:fgColor and:bgColor.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   458
    ].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   459
    mmH := device horizontalPixelPerMillimeter rounded.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   460
    mmV := device verticalPixelPerMillimeter rounded.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   461
    mW := (device horizontalPixelPerMillimeter * 2.5) rounded.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   462
    mH := (device verticalPixelPerMillimeter * 1.5) rounded.
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
    self drawEdgesForX:(width - mW - (hSpace*2)) y:(height - mmV // 2)
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   465
		 width:mW height:mH level:2
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   466
!
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
showActive
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   469
    "no need to redraw - will pop menu ontop of me anyway ..."
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
    ^ self
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   472
!
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
showPassive
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   475
    "no need to redraw - will redraw from unpopped menu anyway ..."
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
    ^ self
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
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   480
!PopUpList methodsFor:'event handling'!
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
popMenu
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   483
    |org mv w|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   484
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   485
    menu notNil ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   486
	self turnOffWithoutRedraw. 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   487
	menu font:font.
136
claus
parents: 135
diff changeset
   488
205
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
	 adjust the menus width to my current width
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   491
	"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   492
	mv := menu menuView.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   493
	mv create.      "/ stupid: it resizes itself upon first create
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   494
	w := mv width.  "/ to its preferred size.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   495
	w := w max:(self width - (2 * menu margin) - (menu borderWidth*2)).
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   496
	mv width:w.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   497
	mv level:0; borderWidth:0.
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
	"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   500
	 the popupMenu wants Display coordinates in its showAt: method
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   501
	"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   502
	org := device translatePoint:0@0 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   503
				from:(self id)
694
dfc7ec6d2e5c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 684
diff changeset
   504
				  to:(device rootView id).
205
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
	menu showAt:org "resizing:false"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   507
    ].
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
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   510
!PopUpList methodsFor:'initialization'!
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
defaultControllerClass
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   513
    ^ PopUpListController
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   514
!
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
initialize
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   517
    super initialize.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   518
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   519
    controller beTriggerOnDown.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   520
    controller action:[self popMenu].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   521
    self adjust:#left.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   522
    useIndex := false.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   523
    self label:'popup'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   524
    listMsg := self class defaultListMessage.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   525
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   526
    onLevel := offLevel.
136
claus
parents: 135
diff changeset
   527
! !
claus
parents: 135
diff changeset
   528
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   529
!PopUpList methodsFor:'private'!
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   530
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   531
computeLabelSize
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   532
    "compute the extent needed to hold the label plus the mark"
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   533
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   534
    |mmH mmV savedLogo longest longestWidth|
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   535
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   536
    menu isNil ifTrue:[
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   537
        super computeLabelSize
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   538
    ] ifFalse:[
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   539
        "hack: simulate logo change to longest menu entry"
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   540
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   541
        font := font on:device.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   542
        longest := logo.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   543
        longestWidth := font widthOf:logo.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   544
        menu labels do:[:entry |
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   545
            |this|
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   546
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   547
            this := font widthOf:entry printString.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   548
            this > longestWidth ifTrue:[
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   549
                longest := entry.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   550
                longestWidth := this
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   551
            ].
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   552
        ].
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   553
        savedLogo := logo.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   554
        logo := longest printString.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   555
        super computeLabelSize.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   556
        logo := savedLogo.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
   557
"self halt.     "
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   558
    ].
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   559
    mmH := device horizontalPixelPerMillimeter.
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   560
    mmV := device verticalPixelPerMillimeter.
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   561
    labelWidth := labelWidth + hSpace + (mmH * 2.5) rounded + hSpace.
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   562
    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
   563
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   564
    "Modified: 8.2.1996 / 13:00:33 / cg"
121
claus
parents: 120
diff changeset
   565
!
claus
parents: 120
diff changeset
   566
claus
parents: 120
diff changeset
   567
createMenuFor:aList
claus
parents: 120
diff changeset
   568
    menu := PopUpMenu
claus
parents: 120
diff changeset
   569
		  labels:aList
claus
parents: 120
diff changeset
   570
	       selectors:#select:
claus
parents: 120
diff changeset
   571
		    args:(1 to:aList size) 
claus
parents: 120
diff changeset
   572
		receiver:self
claus
parents: 120
diff changeset
   573
		     for:self.
128
claus
parents: 127
diff changeset
   574
!
claus
parents: 127
diff changeset
   575
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   576
realize
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   577
    super realize.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   578
    model notNil ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   579
	self getListFromModel.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   580
	self getSelectionFromModel.
121
claus
parents: 120
diff changeset
   581
    ].
claus
parents: 120
diff changeset
   582
! !
claus
parents: 120
diff changeset
   583
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   584
!PopUpList methodsFor:'private-controller access'!
121
claus
parents: 120
diff changeset
   585
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   586
menu
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   587
    "return the menu component"
125
claus
parents: 121
diff changeset
   588
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   589
    ^ menu
126
claus
parents: 125
diff changeset
   590
! !
claus
parents: 125
diff changeset
   591
136
claus
parents: 135
diff changeset
   592
!PopUpList methodsFor:'queries'!
claus
parents: 135
diff changeset
   593
claus
parents: 135
diff changeset
   594
preferredExtent
claus
parents: 135
diff changeset
   595
    "redefined to make certain that the menu is fully defined"
claus
parents: 135
diff changeset
   596
799
64f8700489a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   597
    "/ If I have an explicit preferredExtent ..
64f8700489a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   598
714
5ff02d2d9fa7 care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents: 694
diff changeset
   599
    preferredExtent notNil ifTrue:[
5ff02d2d9fa7 care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents: 694
diff changeset
   600
        ^ preferredExtent
5ff02d2d9fa7 care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents: 694
diff changeset
   601
    ].
5ff02d2d9fa7 care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents: 694
diff changeset
   602
136
claus
parents: 135
diff changeset
   603
    menu isNil ifTrue:[
714
5ff02d2d9fa7 care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents: 694
diff changeset
   604
        self getListFromModel
136
claus
parents: 135
diff changeset
   605
    ].
claus
parents: 135
diff changeset
   606
    self computeLabelSize.
claus
parents: 135
diff changeset
   607
    ^ super preferredExtent.
714
5ff02d2d9fa7 care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents: 694
diff changeset
   608
799
64f8700489a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   609
    "Modified: 19.7.1996 / 20:45:16 / cg"
155
claus
parents: 136
diff changeset
   610
!
claus
parents: 136
diff changeset
   611
claus
parents: 136
diff changeset
   612
specClass
claus
parents: 136
diff changeset
   613
    self class == PopUpList ifTrue:[^ PopUpListSpec].
claus
parents: 136
diff changeset
   614
    ^ nil
136
claus
parents: 135
diff changeset
   615
! !
claus
parents: 135
diff changeset
   616
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   617
!PopUpList methodsFor:'user actions'!
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   618
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   619
select:anEntry
119
claus
parents: 105
diff changeset
   620
    "this is sent from the popupmenu when an entry was selected"
claus
parents: 105
diff changeset
   621
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   622
    |value label|
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   623
119
claus
parents: 105
diff changeset
   624
    label := menu labels at:anEntry.
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   625
    values isNil ifTrue:[
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   626
        value := anEntry.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   627
        useIndex ifFalse:[
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   628
            value := menu labels at:anEntry.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   629
        ]
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   630
    ] ifFalse:[
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   631
        value := values at:anEntry
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   632
    ].
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   633
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   634
    menuAction notNil ifTrue:[
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   635
        menuAction value:value.
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   636
    ].
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   637
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   638
    self sizeFixed:true.
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   639
    self label:label printString.
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   640
119
claus
parents: 105
diff changeset
   641
    "
121
claus
parents: 120
diff changeset
   642
     tell my model - if any
119
claus
parents: 105
diff changeset
   643
    "
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   644
    self sendChangeMessageWith:value
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   645
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   646
    "Modified: 8.2.1996 / 11:58:51 / cg"
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   647
! !
121
claus
parents: 120
diff changeset
   648
799
64f8700489a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   649
!PopUpList  class methodsFor:'documentation'!
121
claus
parents: 120
diff changeset
   650
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   651
version
799
64f8700489a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
   652
    ^ '$Header: /cvs/stx/stx/libwidg/PopUpList.st,v 1.28 1996-07-19 18:55:38 cg Exp $'
121
claus
parents: 120
diff changeset
   653
! !