ListSelectionBox.st
author Claus Gittinger <cg@exept.de>
Sun, 26 May 1996 15:22:17 +0200
changeset 690 d579f684aa7e
parent 655 acad3ef3a46c
child 713 0c38ad51016d
permissions -rw-r--r--
checkin from browser
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     1
"
5
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1990 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
     3
	      All Rights Reserved
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     4
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    11
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    12
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    13
EnterBox subclass:#ListSelectionBox
371
ed0d15f84085 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 319
diff changeset
    14
	instanceVariableNames:'selectionList'
ed0d15f84085 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 319
diff changeset
    15
	classVariableNames:''
ed0d15f84085 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 319
diff changeset
    16
	poolDictionaries:''
ed0d15f84085 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 319
diff changeset
    17
	category:'Views-DialogBoxes'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    18
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    19
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 12
diff changeset
    20
!ListSelectionBox class methodsFor:'documentation'!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 12
diff changeset
    21
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 12
diff changeset
    22
copyright
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 12
diff changeset
    23
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 12
diff changeset
    24
 COPYRIGHT (c) 1990 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: 12
diff changeset
    26
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 12
diff changeset
    27
 This software is furnished under a license and may be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 12
diff changeset
    28
 only in accordance with the terms of that license and with the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 12
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 12
diff changeset
    30
 be provided or otherwise made available to, or used by, any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 12
diff changeset
    31
 other person.  No title to or ownership of the software is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 12
diff changeset
    32
 hereby transferred.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 12
diff changeset
    33
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 12
diff changeset
    34
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    35
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 12
diff changeset
    36
documentation
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 12
diff changeset
    37
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 12
diff changeset
    38
    this class implements boxes for selection from a list. It offers
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 12
diff changeset
    39
    both an ok- and abort-buttons. The ok-button, if pressed will
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 12
diff changeset
    40
    evaluate the okAction (see EnterBox>>action).
77
565b052f5277 *** empty log message ***
claus
parents: 59
diff changeset
    41
    see examples for typical uses.
565b052f5277 *** empty log message ***
claus
parents: 59
diff changeset
    42
565b052f5277 *** empty log message ***
claus
parents: 59
diff changeset
    43
    Notice, for file selections there is a specialized FileSelectionBox,
565b052f5277 *** empty log message ***
claus
parents: 59
diff changeset
    44
    which supports matchPatterns, changing directory etc.
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
    45
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
    46
    [author:]
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
    47
        Claus Gittinger
77
565b052f5277 *** empty log message ***
claus
parents: 59
diff changeset
    48
"
565b052f5277 *** empty log message ***
claus
parents: 59
diff changeset
    49
!
565b052f5277 *** empty log message ***
claus
parents: 59
diff changeset
    50
565b052f5277 *** empty log message ***
claus
parents: 59
diff changeset
    51
examples 
565b052f5277 *** empty log message ***
claus
parents: 59
diff changeset
    52
"
565b052f5277 *** empty log message ***
claus
parents: 59
diff changeset
    53
    simple:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    54
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    55
        |box|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 12
diff changeset
    56
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    57
        box := ListSelectionBox new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    58
        box title:'select something:'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    59
        box list:#('foo' 'bar' 'baz').
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 638
diff changeset
    60
        box okAction:[:sel | Transcript showCR:'the selection was:' , sel].
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    61
        box showAtPointer
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    62
                                                                        [exEnd]
77
565b052f5277 *** empty log message ***
claus
parents: 59
diff changeset
    63
155
claus
parents: 139
diff changeset
    64
77
565b052f5277 *** empty log message ***
claus
parents: 59
diff changeset
    65
    with a default:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    66
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    67
        |box|
77
565b052f5277 *** empty log message ***
claus
parents: 59
diff changeset
    68
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    69
        box := ListSelectionBox new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    70
        box title:'select something:'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    71
        box list:#('foo' 'bar' 'baz').
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 638
diff changeset
    72
        box okAction:[:sel | Transcript showCR:'the selection was:' , sel].
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    73
        box initialText:'foo'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    74
        box showAtPointer
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    75
                                                                        [exEnd]
155
claus
parents: 139
diff changeset
    76
claus
parents: 139
diff changeset
    77
claus
parents: 139
diff changeset
    78
    opening the box modeless (a stand-by box):
claus
parents: 139
diff changeset
    79
    (in this case, the default ok- and abortActions do not hide the box;
claus
parents: 139
diff changeset
    80
     therefore, we have to set those explicitely)
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    81
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    82
        |box|
155
claus
parents: 139
diff changeset
    83
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    84
        box := ListSelectionBox new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    85
        box title:'select something:'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    86
        box list:#('foo' 'bar' 'baz').
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    87
        box abortText:'close'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    88
        box okText:'apply'.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 638
diff changeset
    89
        box okAction:[:sel | Transcript showCR:'the selection was:' , sel].
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    90
        box abortAction:[:dummy | box hide].
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    91
        box openModeless
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    92
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 12
diff changeset
    93
"
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    94
! !
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    95
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    96
!ListSelectionBox class methodsFor:'instance creation'!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    97
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    98
title:titleString okText:okText abortText:abortText list:aList action:aBlock
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    99
    "create and return a new listSelectionBox with list already defined"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   100
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   101
    |newBox|
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   102
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   103
    newBox := super title:titleString okText:okText abortText:abortText
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   104
		    action:aBlock.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   105
    ^ newBox list:aList
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 12
diff changeset
   106
! !
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   107
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   108
!ListSelectionBox class methodsFor:'defaults'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   109
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   110
defaultExtent
571
ddc5d56bd636 commentary
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
   111
    "return the default extent of my instances.
ddc5d56bd636 commentary
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
   112
     The value returned here is usually ignored, and
ddc5d56bd636 commentary
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
   113
     the value from preferredExtent taken instead."
ddc5d56bd636 commentary
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
   114
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   115
    ^ (Display pixelPerMillimeter * (80 @ 100)) rounded
571
ddc5d56bd636 commentary
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
   116
ddc5d56bd636 commentary
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
   117
    "Modified: 22.4.1996 / 23:36:49 / cg"
12
1c8e8c53e8cf *** empty log message ***
claus
parents: 5
diff changeset
   118
!
1c8e8c53e8cf *** empty log message ***
claus
parents: 5
diff changeset
   119
1c8e8c53e8cf *** empty log message ***
claus
parents: 5
diff changeset
   120
listViewType
1c8e8c53e8cf *** empty log message ***
claus
parents: 5
diff changeset
   121
    "return the type of listView 
1c8e8c53e8cf *** empty log message ***
claus
parents: 5
diff changeset
   122
     - for easier redefinition in subclasses"
1c8e8c53e8cf *** empty log message ***
claus
parents: 5
diff changeset
   123
1c8e8c53e8cf *** empty log message ***
claus
parents: 5
diff changeset
   124
    ^ SelectionInListView
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   125
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   126
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   127
!ListSelectionBox methodsFor:'accessing'!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   128
402
ed4a635f43c6 oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   129
contents
ed4a635f43c6 oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   130
    "return my contents"
ed4a635f43c6 oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   131
ed4a635f43c6 oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   132
    enterField isNil ifTrue:[
ed4a635f43c6 oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   133
        ^ selectionList selectionValue
ed4a635f43c6 oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   134
    ].
ed4a635f43c6 oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   135
    ^ super contents
ed4a635f43c6 oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   136
ed4a635f43c6 oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   137
    "Created: 26.2.1996 / 20:05:47 / cg"
ed4a635f43c6 oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   138
!
ed4a635f43c6 oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   139
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   140
initialText:someString
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   141
    "in addition to showing the initial text, also select it in the list"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   142
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   143
    super initialText:someString.
690
d579f684aa7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
   144
    selectionList setSelectElement:someString.
d579f684aa7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
   145
d579f684aa7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
   146
    "Modified: 26.5.1996 / 15:03:37 / cg"
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   147
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   148
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   149
list:aList
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   150
    "set the list to be displayed in selection list"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   151
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   152
    selectionList list:aList
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   153
! !
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   154
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   155
!ListSelectionBox methodsFor:'accessing-components'!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   156
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   157
listView
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   158
    "return the listView component"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   159
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   160
    ^ selectionList
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   161
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   162
    "Created: 26.10.1995 / 17:08:32 / cg"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   163
! !
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   164
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   165
!ListSelectionBox methodsFor:'accessing-look'!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   166
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   167
noEnterField
638
72c3d36df4d8 comments
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   168
    "suppress the enterField - now only existing items are selectable;
72c3d36df4d8 comments
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   169
     the default is to present an enterField."
72c3d36df4d8 comments
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   170
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   171
    enterField destroy.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   172
    enterField := nil
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   173
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   174
    "Created: 26.10.1995 / 17:12:38 / cg"
638
72c3d36df4d8 comments
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   175
    "Modified: 12.5.1996 / 21:49:14 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   176
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   177
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   178
!ListSelectionBox methodsFor:'initialization'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   179
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   180
focusSequence
638
72c3d36df4d8 comments
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   181
    "return a sequence for tabbing through my components"
72c3d36df4d8 comments
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   182
72c3d36df4d8 comments
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   183
    ^ Array with:enterField with:selectionList with:abortButton with:okButton
72c3d36df4d8 comments
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   184
72c3d36df4d8 comments
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   185
    "Modified: 12.5.1996 / 21:49:37 / cg"
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   186
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   187
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   188
initialize
166
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   189
    |space2 halfSpace v vbw eH|
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   190
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   191
    super initialize.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   192
412
bb3d94d97b91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
   193
    label := resources string:'Select or enter'.
77
565b052f5277 *** empty log message ***
claus
parents: 59
diff changeset
   194
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   195
    "need more space than an enterBox"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   196
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   197
    "self height:(height + (font height * 5)).  "
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   198
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   199
    space2 := 2 * ViewSpacing.
125
claus
parents: 122
diff changeset
   200
    halfSpace := ViewSpacing // 2.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   201
12
1c8e8c53e8cf *** empty log message ***
claus
parents: 5
diff changeset
   202
    v := ScrollableView for:(self class listViewType) in:self.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   203
132
claus
parents: 130
diff changeset
   204
"/ old:
claus
parents: 130
diff changeset
   205
"/    v origin:[0.0
125
claus
parents: 122
diff changeset
   206
"/              @
132
claus
parents: 130
diff changeset
   207
"/              (enterField origin y + enterField height + ViewSpacing)]
claus
parents: 130
diff changeset
   208
"/      extent:[1.0
125
claus
parents: 122
diff changeset
   209
"/              @ 
132
claus
parents: 130
diff changeset
   210
"/              (height
125
claus
parents: 122
diff changeset
   211
"/               - ViewSpacing - labelField heightIncludingBorder
claus
parents: 122
diff changeset
   212
"/               - ViewSpacing - enterField heightIncludingBorder
claus
parents: 122
diff changeset
   213
"/               - buttonPanel heightIncludingBorder - ViewSpacing
claus
parents: 122
diff changeset
   214
"/               - space2)
132
claus
parents: 130
diff changeset
   215
"/             ].
claus
parents: 130
diff changeset
   216
claus
parents: 130
diff changeset
   217
"/ new:
166
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   218
    v origin:[enterField notNil ifTrue:[
412
bb3d94d97b91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
   219
                0.0 @ (enterField origin y + enterField height + ViewSpacing)
bb3d94d97b91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
   220
              ] ifFalse:[
bb3d94d97b91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
   221
                0.0 @ (labelField origin y + labelField height + ViewSpacing)
bb3d94d97b91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
   222
              ]
bb3d94d97b91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
   223
             ]
132
claus
parents: 130
diff changeset
   224
      corner:(1.0 @ 1.0).
claus
parents: 130
diff changeset
   225
    v bottomInset:(buttonPanel preferredExtent y + ViewSpacing).
claus
parents: 130
diff changeset
   226
139
claus
parents: 132
diff changeset
   227
    vbw := v borderWidth.
claus
parents: 132
diff changeset
   228
    v leftInset:halfSpace+vbw;
claus
parents: 132
diff changeset
   229
      rightInset:halfSpace+vbw.
110
eb59f6e31e84 *** empty log message ***
claus
parents: 77
diff changeset
   230
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   231
    selectionList := v scrolledView.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   232
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   233
    "self updateList."
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   234
132
claus
parents: 130
diff changeset
   235
    "I am interested in what is done int the selectionList
claus
parents: 130
diff changeset
   236
     (could also create a SelectionInList-model and catch its changes ...)"
claus
parents: 130
diff changeset
   237
    selectionList action:[:lineNr | self selectionChanged].
claus
parents: 130
diff changeset
   238
    selectionList doubleClickAction:[:lineNr | self doubleClick].
claus
parents: 130
diff changeset
   239
130
claus
parents: 128
diff changeset
   240
    enterField removeDependent:self. "dont want preferredExtent-changes"
128
claus
parents: 125
diff changeset
   241
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 12
diff changeset
   242
    "
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 12
diff changeset
   243
     mhm: the lists keyboard functions are disabled,
319
d78f5fbdee27 dont forward Cursor-motion to the enterField
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   244
     and input passed to the enterfield (except cursor keys)
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 12
diff changeset
   245
    "
319
d78f5fbdee27 dont forward Cursor-motion to the enterField
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   246
    selectionList delegate:(
412
bb3d94d97b91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
   247
        KeyboardForwarder 
bb3d94d97b91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
   248
            toView:enterField 
bb3d94d97b91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
   249
            condition:#noFocus
bb3d94d97b91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
   250
            filter:[:key | (key ~~ #CursorUp) and:[key ~~ #CursorDown]]
bb3d94d97b91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
   251
        )
166
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   252
412
bb3d94d97b91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 402
diff changeset
   253
    "Modified: 27.2.1996 / 01:11:41 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   254
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   255
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   256
realize
638
72c3d36df4d8 comments
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   257
    "redefined to update the list now.
72c3d36df4d8 comments
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   258
     This was not done in #initialize to allow settings to be changed before,
72c3d36df4d8 comments
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   259
     in case list-updating is a slow operation - such as reading a directory"
72c3d36df4d8 comments
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   260
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   261
    self updateList.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   262
    super realize
638
72c3d36df4d8 comments
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   263
72c3d36df4d8 comments
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   264
    "Modified: 12.5.1996 / 21:50:50 / cg"
77
565b052f5277 *** empty log message ***
claus
parents: 59
diff changeset
   265
!
565b052f5277 *** empty log message ***
claus
parents: 59
diff changeset
   266
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   267
updateList
638
72c3d36df4d8 comments
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   268
    "setup contents of list; 
72c3d36df4d8 comments
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   269
     nothing done here but typically redefined in subclasses."
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   270
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   271
    ^ self
638
72c3d36df4d8 comments
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   272
72c3d36df4d8 comments
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   273
    "Modified: 12.5.1996 / 21:51:10 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   274
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   275
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   276
!ListSelectionBox methodsFor:'queries'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   277
130
claus
parents: 128
diff changeset
   278
preferredExtent
claus
parents: 128
diff changeset
   279
    "return my preferred extent - thats the minimum size 
125
claus
parents: 122
diff changeset
   280
     I like to have, to make everything visible"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   281
371
ed0d15f84085 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 319
diff changeset
   282
    |wWanted hWanted eH mm|
ed0d15f84085 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 319
diff changeset
   283
ed0d15f84085 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 319
diff changeset
   284
    mm := ViewSpacing.
125
claus
parents: 122
diff changeset
   285
371
ed0d15f84085 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 319
diff changeset
   286
    wWanted := mm + labelField width + mm.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   287
    (wWanted > width) ifFalse:[
371
ed0d15f84085 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 319
diff changeset
   288
        wWanted := width
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   289
    ].
125
claus
parents: 122
diff changeset
   290
166
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   291
    enterField notNil ifTrue:[
371
ed0d15f84085 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 319
diff changeset
   292
        eH := enterField height + mm
166
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   293
    ] ifFalse:[
371
ed0d15f84085 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 319
diff changeset
   294
        eH := 0
166
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   295
    ].
371
ed0d15f84085 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 319
diff changeset
   296
    hWanted := mm + labelField height +
ed0d15f84085 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 319
diff changeset
   297
               eH +
ed0d15f84085 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 319
diff changeset
   298
               mm + selectionList height +
ed0d15f84085 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 319
diff changeset
   299
               mm + buttonPanel preferredExtent y +
ed0d15f84085 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 319
diff changeset
   300
               mm - (mm * 2).
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   301
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   302
    (hWanted < height) ifTrue:[
371
ed0d15f84085 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 319
diff changeset
   303
        hWanted := height
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   304
    ].
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   305
    ^ (wWanted @ hWanted)
166
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   306
371
ed0d15f84085 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 319
diff changeset
   307
    "Modified: 21.2.1996 / 01:01:02 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   308
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   309
132
claus
parents: 130
diff changeset
   310
!ListSelectionBox methodsFor:'user actions'!
claus
parents: 130
diff changeset
   311
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   312
doubleClick
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   313
    "doubleClick on an entry is select & ok"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   314
402
ed4a635f43c6 oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   315
    enterField notNil ifTrue:[
ed4a635f43c6 oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   316
        enterField contents:(selectionList selectionValue).
ed4a635f43c6 oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   317
    ].
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   318
    self okPressed
402
ed4a635f43c6 oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   319
ed4a635f43c6 oops - fixed access to non existing enterField (if noEnterField)
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
   320
    "Modified: 26.2.1996 / 20:05:45 / cg"
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   321
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   322
132
claus
parents: 130
diff changeset
   323
selectionChanged
claus
parents: 130
diff changeset
   324
    "selections in list get forwarded to enterfield"
claus
parents: 130
diff changeset
   325
166
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   326
    enterField notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   327
	enterField contents:(selectionList selectionValue)
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   328
    ]
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   329
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   330
    "Modified: 26.10.1995 / 17:20:06 / cg"
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   331
! !
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   332
243
5c411425097d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   333
!ListSelectionBox class methodsFor:'documentation'!
5c411425097d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   334
5c411425097d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   335
version
690
d579f684aa7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
   336
    ^ '$Header: /cvs/stx/stx/libwidg/ListSelectionBox.st,v 1.31 1996-05-26 13:22:17 cg Exp $'
243
5c411425097d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   337
! !