author | Claus Gittinger <cg@exept.de> |
Thu, 18 Jan 1996 01:09:26 +0100 | |
changeset 294 | 667773990289 |
parent 203 | 8a38b0b03233 |
child 582 | e151eeae2c9a |
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 |
|
294
667773990289
merged all variablePanel code into a common class.
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
14 |
instanceVariableNames:'movedHandle prevPos startPos' |
104 | 15 |
classVariableNames:'' |
16 |
poolDictionaries:'' |
|
126 | 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. |
|
43 |
" |
|
104 | 44 |
! ! |
45 |
||
46 |
!VariablePanelController methodsFor:'event handling'! |
|
47 |
||
161 | 48 |
buttonMotion:state x:bx y:by |
104 | 49 |
"mouse-button was moved while pressed; |
50 |
clear prev handleBar and draw handle bar at new position" |
|
51 |
||
131 | 52 |
|pos limitMin limitMax subViews barHeight |
53 |
oldHx oldHy newHx newHy| |
|
104 | 54 |
|
55 |
movedHandle isNil ifTrue: [^ self]. "should not happen" |
|
56 |
||
57 |
"speedup - if there is already another movement, |
|
58 |
ignore thisone ... " |
|
59 |
||
60 |
view buttonMotionEventPending ifTrue:[^ self]. |
|
61 |
||
62 |
subViews := view subViews. |
|
63 |
barHeight := view barHeight. |
|
64 |
||
294
667773990289
merged all variablePanel code into a common class.
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
65 |
view orientation ~~ #vertical ifTrue:[ |
104 | 66 |
pos := bx - startPos. |
67 |
" |
|
68 |
the two lines below will not allow resizing down to zero |
|
69 |
(so that some is always visible) |
|
70 |
" |
|
71 |
"/ limitMin := barHeight // 2. |
|
72 |
"/ limitMax := view width - barHeight. |
|
73 |
" |
|
74 |
these allow resizing to zero - which is better ? |
|
75 |
" |
|
76 |
limitMin := 0. |
|
77 |
limitMax := view innerWidth. |
|
78 |
||
79 |
movedHandle > 1 ifTrue:[ |
|
80 |
limitMin := (subViews at:movedHandle) origin x + (barHeight // 2) |
|
81 |
]. |
|
82 |
movedHandle < (subViews size - 1) ifTrue:[ |
|
83 |
limitMax := (subViews at:(movedHandle + 2)) origin x - barHeight |
|
84 |
]. |
|
85 |
] ifFalse:[ |
|
86 |
pos := by - startPos. |
|
87 |
" |
|
88 |
the two lines below will not allow resizing down to zero |
|
89 |
(so that some is always visible) |
|
90 |
" |
|
91 |
"/ limitMin := barHeight // 2. |
|
92 |
"/ limitMax := view height - barHeight. |
|
93 |
" |
|
94 |
these allow resizing to zero - which is better ? |
|
95 |
" |
|
96 |
limitMin := 0. |
|
97 |
limitMax := view innerHeight. |
|
98 |
||
99 |
movedHandle > 1 ifTrue:[ |
|
100 |
limitMin := (subViews at:movedHandle) origin y + (barHeight // 2) |
|
101 |
]. |
|
102 |
movedHandle < (subViews size - 1) ifTrue:[ |
|
103 |
limitMax := (subViews at:(movedHandle + 2)) origin y - barHeight |
|
104 |
]. |
|
105 |
]. |
|
106 |
||
107 |
limitMax := limitMax - barHeight. |
|
108 |
(pos < limitMin) ifTrue:[ "check against view limits" |
|
109 |
pos := limitMin |
|
110 |
] ifFalse:[ |
|
111 |
(pos > limitMax) ifTrue:[ |
|
112 |
pos := limitMax |
|
113 |
] |
|
114 |
]. |
|
115 |
||
294
667773990289
merged all variablePanel code into a common class.
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
116 |
view orientation ~~ #vertical ifTrue:[ |
131 | 117 |
oldHx := prevPos. |
118 |
newHx := pos. |
|
119 |
oldHy := newHy := 0. |
|
104 | 120 |
] ifFalse:[ |
131 | 121 |
oldHy := prevPos. |
122 |
newHy := pos. |
|
123 |
oldHx := newHx := 0. |
|
104 | 124 |
]. |
131 | 125 |
view invertHandleBarAtX:oldHx y:oldHy. |
126 |
view invertHandleBarAtX:newHx y:newHy. |
|
127 |
||
104 | 128 |
prevPos := pos |
129 |
! |
|
130 |
||
200 | 131 |
buttonPress:button x:bx y:by |
132 |
"button was pressed - if it hits a handle, start move" |
|
133 |
||
134 |
|handle barHeight group| |
|
135 |
||
136 |
((button == 1) or:[button == #select]) ifTrue:[ |
|
137 |
handle := 1. |
|
138 |
barHeight := view barHeight. |
|
139 |
||
140 |
" |
|
141 |
search the handle, invert the first time |
|
142 |
" |
|
143 |
view handleOriginsDo:[:hPoint | |
|
144 |
|hx hy| |
|
145 |
||
294
667773990289
merged all variablePanel code into a common class.
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
146 |
view orientation ~~ #vertical ifTrue:[ |
200 | 147 |
hx := hPoint x. |
148 |
(bx between:hx and:(hx + barHeight)) ifTrue:[ |
|
149 |
movedHandle := handle. |
|
150 |
prevPos := hx. |
|
151 |
startPos := bx - hx. |
|
152 |
||
153 |
view invertHandleBarAtX:hx y:0. |
|
154 |
(group := view windowGroup) notNil ifTrue:[ |
|
155 |
group showCursor:view cursor |
|
156 |
]. |
|
157 |
^ self |
|
158 |
]. |
|
159 |
] ifFalse:[ |
|
160 |
hy := hPoint y. |
|
161 |
(by between:hy and:(hy + barHeight)) ifTrue:[ |
|
162 |
movedHandle := handle. |
|
163 |
prevPos := hy. |
|
164 |
startPos := by - hy. |
|
165 |
||
166 |
view invertHandleBarAtX:0 y:hy. |
|
167 |
(group := view windowGroup) notNil ifTrue:[ |
|
168 |
group showCursor:view cursor |
|
169 |
]. |
|
170 |
^ self |
|
171 |
]. |
|
172 |
]. |
|
173 |
handle := handle + 1 |
|
174 |
]. |
|
175 |
movedHandle := nil |
|
176 |
] ifFalse:[ |
|
177 |
super buttonPress:button x:bx y:by |
|
178 |
] |
|
179 |
! |
|
180 |
||
104 | 181 |
buttonRelease:button x:x y:y |
182 |
"end bar-move" |
|
183 |
||
184 |
|aboveView belowView aboveIndex belowIndex |
|
131 | 185 |
newPos oldPos group subViews |
186 |
relCornerAbove fromIndex toIndex| |
|
104 | 187 |
|
188 |
((button == 1) or:[button == #select]) ifTrue:[ |
|
189 |
movedHandle isNil ifTrue:[^ self]. |
|
190 |
||
191 |
(group := view windowGroup) notNil ifTrue:[ |
|
192 |
group restoreCursors |
|
193 |
]. |
|
194 |
||
195 |
"undo the last invert" |
|
196 |
||
294
667773990289
merged all variablePanel code into a common class.
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
197 |
view orientation ~~ #vertical ifTrue:[ |
104 | 198 |
view invertHandleBarAtX:prevPos y:0. |
199 |
] ifFalse:[ |
|
200 |
view invertHandleBarAtX:0 y:prevPos. |
|
201 |
]. |
|
202 |
||
203 |
"compute the new relative heights" |
|
204 |
||
205 |
aboveIndex := movedHandle. |
|
206 |
belowIndex := movedHandle + 1. |
|
207 |
movedHandle := nil. |
|
208 |
subViews := view subViews. |
|
209 |
||
210 |
aboveView := subViews at:aboveIndex. |
|
211 |
belowView := subViews at:belowIndex. |
|
212 |
||
131 | 213 |
relCornerAbove := aboveView relativeCorner. |
294
667773990289
merged all variablePanel code into a common class.
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
214 |
view orientation ~~ #vertical ifTrue:[ |
131 | 215 |
oldPos := relCornerAbove x. |
104 | 216 |
newPos := (prevPos + startPos / view width) asFloat. |
131 | 217 |
aboveView relativeCorner:newPos @ relCornerAbove y. |
104 | 218 |
belowView relativeOrigin:newPos @ belowView relativeOrigin y. |
219 |
] ifFalse:[ |
|
131 | 220 |
oldPos := relCornerAbove y. |
104 | 221 |
newPos := (prevPos + startPos / view height) asFloat. |
131 | 222 |
aboveView relativeCorner:relCornerAbove x @ newPos. |
104 | 223 |
belowView relativeOrigin:belowView relativeOrigin x @ newPos. |
224 |
]. |
|
225 |
||
226 |
view lockRedraw. |
|
227 |
||
228 |
oldPos > newPos ifTrue:[ |
|
131 | 229 |
fromIndex := aboveIndex. toIndex := belowIndex. |
104 | 230 |
] ifFalse:[ |
131 | 231 |
fromIndex := belowIndex. toIndex := aboveIndex. |
104 | 232 |
]. |
131 | 233 |
view resizeSubviewsFrom:fromIndex to:toIndex. |
104 | 234 |
view redrawHandlesFrom:aboveIndex to:belowIndex. |
235 |
view unlockRedraw. |
|
236 |
] ifFalse:[ |
|
237 |
super buttonRelease:button x:x y:y |
|
238 |
] |
|
200 | 239 |
! ! |
104 | 240 |
|
203 | 241 |
!VariablePanelController class methodsFor:'documentation'! |
242 |
||
243 |
version |
|
294
667773990289
merged all variablePanel code into a common class.
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
244 |
^ '$Header: /cvs/stx/stx/libwidg/VariablePanelController.st,v 1.9 1996-01-18 00:09:22 cg Exp $' |
203 | 245 |
! ! |