0
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1990-93 by Claus Gittinger
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
EnterBox subclass:#ListSelectionBox
|
|
14 |
instanceVariableNames:'selectionList'
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Views-Interactors'
|
|
18 |
!
|
|
19 |
|
|
20 |
ListSelectionBox comment:'
|
|
21 |
|
|
22 |
COPYRIGHT (c) 1990-93 by Claus Gittinger
|
|
23 |
All Rights Reserved
|
|
24 |
|
|
25 |
this class implements boxes for selection from a list
|
|
26 |
|
3
|
27 |
$Header: /cvs/stx/stx/libwidg/ListSelectionBox.st,v 1.2 1993-10-13 01:02:43 claus Exp $
|
0
|
28 |
|
|
29 |
written Jan 90 by claus
|
|
30 |
'!
|
|
31 |
|
|
32 |
!ListSelectionBox class methodsFor:'defaults'!
|
|
33 |
|
|
34 |
defaultExtent
|
|
35 |
^ (Display pixelPerMillimeter * (80 @ 100)) rounded
|
|
36 |
! !
|
|
37 |
|
|
38 |
!ListSelectionBox class methodsFor:'instance creation'!
|
|
39 |
|
|
40 |
title:titleString okText:okText abortText:abortText list:aList action:aBlock
|
|
41 |
"create and return a new listSelectionBox with list already defined"
|
|
42 |
|
|
43 |
|newBox|
|
|
44 |
|
|
45 |
newBox := super title:titleString okText:okText abortText:abortText
|
|
46 |
action:aBlock.
|
|
47 |
^ newBox list:aList
|
|
48 |
! !
|
|
49 |
|
|
50 |
!ListSelectionBox methodsFor:'initialization'!
|
|
51 |
|
|
52 |
initialize
|
|
53 |
|space2 v|
|
|
54 |
|
|
55 |
super initialize.
|
|
56 |
|
|
57 |
"need more space than an enterBox"
|
|
58 |
|
|
59 |
"self height:(height + (font height * 5)). "
|
|
60 |
|
|
61 |
space2 := 2 * ViewSpacing.
|
|
62 |
|
|
63 |
v := ScrollableView for:SelectionInListView in:self.
|
|
64 |
|
|
65 |
"kludge: see note in EnterBox"
|
|
66 |
v origin:(ViewSpacing
|
|
67 |
@
|
|
68 |
(enterField origin y + enterField height + ViewSpacing)).
|
|
69 |
v extent:((width - space2 - (v borderWidth * 2))
|
|
70 |
@
|
|
71 |
(height
|
|
72 |
- ViewSpacing - labelField heightIncludingBorder
|
|
73 |
- ViewSpacing - enterField heightIncludingBorder
|
|
74 |
- buttonPanel heightIncludingBorder - ViewSpacing
|
|
75 |
- space2)
|
|
76 |
).
|
|
77 |
v origin:[ViewSpacing
|
|
78 |
@
|
|
79 |
(enterField origin y + enterField height + ViewSpacing)]
|
|
80 |
extent:[(width - space2 - (v borderWidth * 2))
|
|
81 |
@
|
|
82 |
(height
|
|
83 |
- ViewSpacing - labelField heightIncludingBorder
|
|
84 |
- ViewSpacing - enterField heightIncludingBorder
|
|
85 |
- buttonPanel heightIncludingBorder - ViewSpacing
|
|
86 |
- space2)
|
|
87 |
].
|
|
88 |
selectionList := v scrolledView.
|
|
89 |
|
|
90 |
"self updateList."
|
|
91 |
|
|
92 |
"selections in list get forwarded to enterfield"
|
|
93 |
selectionList action:[:lineNr |
|
|
94 |
enterField contents:(selectionList selectionValue)
|
|
95 |
].
|
|
96 |
selectionList keyboardHandler:enterField
|
|
97 |
!
|
|
98 |
|
|
99 |
updateList
|
|
100 |
"setup contents of list; nothing done here but redefined in subclasses"
|
|
101 |
|
|
102 |
^ self
|
|
103 |
!
|
|
104 |
|
|
105 |
realize
|
|
106 |
self updateList.
|
|
107 |
super realize
|
|
108 |
! !
|
|
109 |
|
|
110 |
!ListSelectionBox methodsFor:'private'!
|
|
111 |
|
|
112 |
resize
|
|
113 |
"resize myself to make everything visible"
|
|
114 |
|
|
115 |
|wWanted hWanted|
|
|
116 |
|
|
117 |
wWanted := labelField width + ViewSpacing + ViewSpacing.
|
|
118 |
(wWanted > width) ifFalse:[
|
|
119 |
wWanted := width
|
|
120 |
].
|
|
121 |
hWanted := ViewSpacing + labelField height +
|
|
122 |
ViewSpacing + enterField height +
|
|
123 |
ViewSpacing + selectionList height +
|
|
124 |
ViewSpacing + buttonPanel height +
|
|
125 |
ViewSpacing.
|
|
126 |
|
|
127 |
(hWanted < height) ifTrue:[
|
|
128 |
hWanted := height
|
|
129 |
].
|
|
130 |
self extent:(wWanted @ hWanted)
|
|
131 |
! !
|
|
132 |
|
|
133 |
!ListSelectionBox methodsFor:'accessing'!
|
|
134 |
|
|
135 |
list:aList
|
|
136 |
"set the list to be displayed in selection list"
|
|
137 |
|
|
138 |
selectionList list:aList
|
|
139 |
! !
|