author | Claus Gittinger <cg@exept.de> |
Thu, 21 Nov 1996 17:44:41 +0100 | |
changeset 890 | abd28e2f66ca |
parent 872 | 3cdb211615e2 |
child 1215 | 0d9e67bdfbe4 |
permissions | -rw-r--r-- |
104 | 1 |
" |
2 |
COPYRIGHT (c) 1995 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 |
Controller subclass:#VariablePanelController |
|
582 | 14 |
instanceVariableNames:'movedHandle prevPos startPos' |
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Interface-Support-Controllers' |
|
104 | 18 |
! |
19 |
||
20 |
!VariablePanelController class methodsFor:'documentation'! |
|
21 |
||
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
25 |
All Rights Reserved |
|
26 |
||
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
150 | 36 |
documentation |
37 |
" |
|
38 |
An abstract class for variablePanel controllers; |
|
39 |
normally, not used directly by applications, these are created automatically |
|
40 |
whenever a variablePanel is created. |
|
41 |
Instances are responsible for tracking the mouse pointer and resize the |
|
42 |
views (a panel) subviews as appropriate. |
|
582 | 43 |
|
44 |
[author:] |
|
45 |
Claus Gittinger |
|
150 | 46 |
" |
104 | 47 |
! ! |
48 |
||
49 |
!VariablePanelController methodsFor:'event handling'! |
|
50 |
||
161 | 51 |
buttonMotion:state x:bx y:by |
104 | 52 |
"mouse-button was moved while pressed; |
53 |
clear prev handleBar and draw handle bar at new position" |
|
54 |
||
131 | 55 |
|pos limitMin limitMax subViews barHeight |
56 |
oldHx oldHy newHx newHy| |
|
104 | 57 |
|
58 |
movedHandle isNil ifTrue: [^ self]. "should not happen" |
|
59 |
||
60 |
"speedup - if there is already another movement, |
|
61 |
ignore thisone ... " |
|
62 |
||
63 |
view buttonMotionEventPending ifTrue:[^ self]. |
|
64 |
||
65 |
subViews := view subViews. |
|
66 |
barHeight := view barHeight. |
|
67 |
||
294
667773990289
merged all variablePanel code into a common class.
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
68 |
view orientation ~~ #vertical ifTrue:[ |
104 | 69 |
pos := bx - startPos. |
70 |
" |
|
71 |
the two lines below will not allow resizing down to zero |
|
72 |
(so that some is always visible) |
|
73 |
" |
|
74 |
"/ limitMin := barHeight // 2. |
|
75 |
"/ limitMax := view width - barHeight. |
|
76 |
" |
|
77 |
these allow resizing to zero - which is better ? |
|
78 |
" |
|
79 |
limitMin := 0. |
|
80 |
limitMax := view innerWidth. |
|
81 |
||
82 |
movedHandle > 1 ifTrue:[ |
|
83 |
limitMin := (subViews at:movedHandle) origin x + (barHeight // 2) |
|
84 |
]. |
|
85 |
movedHandle < (subViews size - 1) ifTrue:[ |
|
86 |
limitMax := (subViews at:(movedHandle + 2)) origin x - barHeight |
|
87 |
]. |
|
88 |
] ifFalse:[ |
|
89 |
pos := by - startPos. |
|
90 |
" |
|
91 |
the two lines below will not allow resizing down to zero |
|
92 |
(so that some is always visible) |
|
93 |
" |
|
94 |
"/ limitMin := barHeight // 2. |
|
95 |
"/ limitMax := view height - barHeight. |
|
96 |
" |
|
97 |
these allow resizing to zero - which is better ? |
|
98 |
" |
|
99 |
limitMin := 0. |
|
100 |
limitMax := view innerHeight. |
|
101 |
||
102 |
movedHandle > 1 ifTrue:[ |
|
103 |
limitMin := (subViews at:movedHandle) origin y + (barHeight // 2) |
|
104 |
]. |
|
105 |
movedHandle < (subViews size - 1) ifTrue:[ |
|
106 |
limitMax := (subViews at:(movedHandle + 2)) origin y - barHeight |
|
107 |
]. |
|
108 |
]. |
|
109 |
||
110 |
limitMax := limitMax - barHeight. |
|
111 |
(pos < limitMin) ifTrue:[ "check against view limits" |
|
112 |
pos := limitMin |
|
113 |
] ifFalse:[ |
|
114 |
(pos > limitMax) ifTrue:[ |
|
115 |
pos := limitMax |
|
116 |
] |
|
117 |
]. |
|
118 |
||
294
667773990289
merged all variablePanel code into a common class.
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
119 |
view orientation ~~ #vertical ifTrue:[ |
131 | 120 |
oldHx := prevPos. |
121 |
newHx := pos. |
|
122 |
oldHy := newHy := 0. |
|
104 | 123 |
] ifFalse:[ |
131 | 124 |
oldHy := prevPos. |
125 |
newHy := pos. |
|
126 |
oldHx := newHx := 0. |
|
104 | 127 |
]. |
131 | 128 |
view invertHandleBarAtX:oldHx y:oldHy. |
129 |
view invertHandleBarAtX:newHx y:newHy. |
|
130 |
||
104 | 131 |
prevPos := pos |
132 |
! |
|
133 |
||
200 | 134 |
buttonPress:button x:bx y:by |
135 |
"button was pressed - if it hits a handle, start move" |
|
136 |
||
137 |
|handle barHeight group| |
|
138 |
||
139 |
((button == 1) or:[button == #select]) ifTrue:[ |
|
872 | 140 |
handle := 1. |
141 |
barHeight := view barHeight. |
|
200 | 142 |
|
872 | 143 |
" |
144 |
search the handle, invert the first time |
|
145 |
" |
|
146 |
view handleOriginsWithIndexDo:[:hPoint :hIndex | |
|
147 |
|hx hy| |
|
200 | 148 |
|
872 | 149 |
view orientation ~~ #vertical ifTrue:[ |
150 |
hx := hPoint x. |
|
151 |
(bx between:hx and:(hx + barHeight)) ifTrue:[ |
|
152 |
movedHandle := handle. |
|
153 |
prevPos := hx. |
|
154 |
startPos := bx - hx. |
|
200 | 155 |
|
872 | 156 |
view grabPointer. |
157 |
view invertHandleBarAtX:hx y:0. |
|
158 |
(group := view windowGroup) notNil ifTrue:[ |
|
159 |
group showCursor:view cursor |
|
160 |
]. |
|
161 |
^ self |
|
162 |
]. |
|
163 |
] ifFalse:[ |
|
164 |
hy := hPoint y. |
|
165 |
(by between:hy and:(hy + barHeight)) ifTrue:[ |
|
166 |
movedHandle := handle. |
|
167 |
prevPos := hy. |
|
168 |
startPos := by - hy. |
|
200 | 169 |
|
872 | 170 |
view grabPointer. |
171 |
view invertHandleBarAtX:0 y:hy. |
|
172 |
(group := view windowGroup) notNil ifTrue:[ |
|
173 |
group showCursor:view cursor |
|
174 |
]. |
|
175 |
^ self |
|
176 |
]. |
|
177 |
]. |
|
178 |
handle := handle + 1 |
|
179 |
]. |
|
180 |
movedHandle := nil |
|
200 | 181 |
] ifFalse:[ |
872 | 182 |
super buttonPress:button x:bx y:by |
200 | 183 |
] |
184 |
! |
|
185 |
||
104 | 186 |
buttonRelease:button x:x y:y |
187 |
"end bar-move" |
|
188 |
||
189 |
|aboveView belowView aboveIndex belowIndex |
|
131 | 190 |
newPos oldPos group subViews |
191 |
relCornerAbove fromIndex toIndex| |
|
104 | 192 |
|
193 |
((button == 1) or:[button == #select]) ifTrue:[ |
|
194 |
movedHandle isNil ifTrue:[^ self]. |
|
195 |
||
821 | 196 |
view ungrabPointer. |
104 | 197 |
(group := view windowGroup) notNil ifTrue:[ |
198 |
group restoreCursors |
|
199 |
]. |
|
200 |
||
201 |
"undo the last invert" |
|
202 |
||
294
667773990289
merged all variablePanel code into a common class.
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
203 |
view orientation ~~ #vertical ifTrue:[ |
104 | 204 |
view invertHandleBarAtX:prevPos y:0. |
205 |
] ifFalse:[ |
|
206 |
view invertHandleBarAtX:0 y:prevPos. |
|
207 |
]. |
|
208 |
||
209 |
"compute the new relative heights" |
|
210 |
||
211 |
aboveIndex := movedHandle. |
|
212 |
belowIndex := movedHandle + 1. |
|
213 |
movedHandle := nil. |
|
214 |
subViews := view subViews. |
|
215 |
||
216 |
aboveView := subViews at:aboveIndex. |
|
217 |
belowView := subViews at:belowIndex. |
|
218 |
||
131 | 219 |
relCornerAbove := aboveView relativeCorner. |
294
667773990289
merged all variablePanel code into a common class.
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
220 |
view orientation ~~ #vertical ifTrue:[ |
131 | 221 |
oldPos := relCornerAbove x. |
104 | 222 |
newPos := (prevPos + startPos / view width) asFloat. |
131 | 223 |
aboveView relativeCorner:newPos @ relCornerAbove y. |
104 | 224 |
belowView relativeOrigin:newPos @ belowView relativeOrigin y. |
225 |
] ifFalse:[ |
|
131 | 226 |
oldPos := relCornerAbove y. |
104 | 227 |
newPos := (prevPos + startPos / view height) asFloat. |
131 | 228 |
aboveView relativeCorner:relCornerAbove x @ newPos. |
104 | 229 |
belowView relativeOrigin:belowView relativeOrigin x @ newPos. |
230 |
]. |
|
231 |
||
232 |
view lockRedraw. |
|
233 |
||
234 |
oldPos > newPos ifTrue:[ |
|
131 | 235 |
fromIndex := aboveIndex. toIndex := belowIndex. |
104 | 236 |
] ifFalse:[ |
131 | 237 |
fromIndex := belowIndex. toIndex := aboveIndex. |
104 | 238 |
]. |
131 | 239 |
view resizeSubviewsFrom:fromIndex to:toIndex. |
104 | 240 |
view redrawHandlesFrom:aboveIndex to:belowIndex. |
241 |
view unlockRedraw. |
|
242 |
] ifFalse:[ |
|
243 |
super buttonRelease:button x:x y:y |
|
244 |
] |
|
200 | 245 |
! ! |
104 | 246 |
|
203 | 247 |
!VariablePanelController class methodsFor:'documentation'! |
248 |
||
249 |
version |
|
872 | 250 |
^ '$Header: /cvs/stx/stx/libwidg/Attic/VarPanelC.st,v 1.12 1996-11-07 14:06:02 ca Exp $' |
203 | 251 |
! ! |