954 ! ! |
969 ! ! |
955 |
970 |
956 !UIObjectView methodsFor:'object resize'! |
971 !UIObjectView methodsFor:'object resize'! |
957 |
972 |
958 actionResize:anObject selector:aSelector |
973 actionResize:anObject selector:aSelector |
959 "create and initialize action for resize |
974 "create and initialize action for resize" |
960 " |
975 |
961 |selector delta| |
976 |delta| |
962 |
977 |
963 delta := anObject container originRelativeTo:self. |
978 delta := anObject container originRelativeTo:self. |
964 selector := ('resize:', aSelector, ':') asSymbol. |
|
965 |
|
966 resizeData := ResizeData new |
979 resizeData := ResizeData new |
967 object:anObject selector:selector delta:delta. |
980 object:anObject |
|
981 selector:aSelector |
|
982 delta:delta. |
968 |
983 |
969 "can change cursor dependent on vertical/horizontal resizing |
984 "can change cursor dependent on vertical/horizontal resizing |
970 " |
985 " |
971 oldCursor := cursor. |
986 oldCursor := cursor. |
972 self cursor:(Cursor leftHand). |
987 self cursor:(Cursor leftHand). |
973 |
988 |
974 "Modified: / 2.2.1998 / 13:40:55 / cg" |
989 "Modified: / 2.2.1998 / 13:40:55 / cg" |
975 ! |
990 ! |
976 |
991 |
977 doDragResize:aPoint |
992 doDragResize:aPoint |
978 "do a widget resize drag |
993 "do a widget resize drag" |
979 " |
994 |
980 |p object| |
995 |p object| |
981 |
996 |
982 object := resizeData object. |
997 object := resizeData object. |
|
998 p := (self alignToGrid:aPoint) - (resizeData delta). |
|
999 |
|
1000 (self resize:object handle:(resizeData selector) to:p check:true) ifFalse:[ |
|
1001 ^ self "/ no real change (due to align) |
|
1002 ]. |
983 |
1003 |
984 self hideSelection. |
1004 self hideSelection. |
985 |
1005 |
986 self invertOutlineOf:object. |
1006 self invertOutlineOf:object. |
987 p := (self alignToGrid:aPoint) - (resizeData delta). |
1007 |
988 |
1008 self resize:object handle:(resizeData selector) to:p check:false. |
989 self perform:(resizeData selector) with:object with:p. |
1009 |
990 Delay waitForSeconds:0.05. |
1010 Delay waitForSeconds:0.05. |
991 [self sensor hasExposeEventFor:nil] whileTrue:[ |
1011 [self sensor hasExposeEventFor:nil] whileTrue:[ |
992 self windowGroup processExposeEvents |
1012 self windowGroup processExposeEvents |
993 ]. |
1013 ]. |
994 |
1014 |
997 |
1017 |
998 self showSelection. |
1018 self showSelection. |
999 ! |
1019 ! |
1000 |
1020 |
1001 endResize |
1021 endResize |
1002 "cleanup after object resize |
1022 "cleanup after object resize" |
1003 " |
1023 |
1004 |object savedSelection| |
1024 |object savedSelection anyLayoutWrapper anyTransparentBox| |
1005 |
1025 |
1006 object := resizeData object. |
1026 object := resizeData object. |
1007 resizeData := nil. |
1027 resizeData := nil. |
1008 |
1028 |
1009 self invertOutlineOf:object. |
1029 "/ container objects might want to rearrange their elements after a size change; |
1010 |
1030 "/ therefore, we hide the handles while this is possibly done. |
1011 "/ temporarily hide the selection, in order to allow the container to move the |
1031 "/ however, to avoid flicker, we check for containers first. |
1012 "/ element around... |
1032 anyLayoutWrapper := anyTransparentBox := false. |
1013 savedSelection := selection. |
1033 self forEach:object do:[:aViewOrComponent | |
1014 self selection:nil. |
1034 aViewOrComponent isLayoutWrapper ifTrue:[ anyLayoutWrapper := true ]. |
1015 "/ handle any expose events (for subcomponents) before |
1035 aViewOrComponent isTransparentBox ifTrue:[ anyTransparentBox := true ]. |
1016 "/ redrawing the handles. |
1036 ]. |
1017 self windowGroup processExposeEvents. |
1037 |
1018 |
1038 (anyLayoutWrapper or:[anyTransparentBox]) ifTrue:[ |
|
1039 |
|
1040 self invertOutlineOf:object. |
|
1041 |
|
1042 "/ temporarily hide the selection, in order to allow the container to move the |
|
1043 "/ element around... |
|
1044 savedSelection := selection. |
|
1045 self setSelection:nil withRedraw:true. |
|
1046 |
|
1047 "/ handle any expose events (for subcomponents) before |
|
1048 "/ redrawing the handles. |
|
1049 self windowGroup processExposeEvents. |
|
1050 |
|
1051 self elementChangedSize:object. |
|
1052 |
|
1053 "/ handle any expose events (for subcomponents) before |
|
1054 "/ redrawing the handles. |
|
1055 Delay waitForSeconds:0.05. |
|
1056 [self sensor hasExposeEventFor:nil] whileTrue:[ |
|
1057 self windowGroup processExposeEvents |
|
1058 ]. |
|
1059 |
|
1060 self forEach:savedSelection do:[:aView | |
|
1061 self recomputeShapeIfTransparentBox:aView. |
|
1062 ]. |
|
1063 |
|
1064 self setSelection:object withRedraw:true. |
|
1065 ]. |
|
1066 |
|
1067 self layoutChanged. |
1019 self setDefaultActions. |
1068 self setDefaultActions. |
1020 self elementChangedSize:object. |
|
1021 |
|
1022 "/ handle any expose events (for subcomponents) before |
|
1023 "/ redrawing the handles. |
|
1024 Delay waitForSeconds:0.05. |
|
1025 [self sensor hasExposeEventFor:nil] whileTrue:[ |
|
1026 self windowGroup processExposeEvents |
|
1027 ]. |
|
1028 |
|
1029 self forEach:savedSelection do:[:aView | |
|
1030 self recomputeShapeIfTransparentBox:aView. |
|
1031 ]. |
|
1032 self layoutChanged. |
|
1033 |
|
1034 self selection:savedSelection. |
|
1035 self setSelection:object withRedraw:true. |
|
1036 ! |
1069 ! |
1037 |
1070 |
1038 layoutChanged |
1071 layoutChanged |
|
1072 ! |
|
1073 |
|
1074 resize:aView bottom:aPoint |
|
1075 "obsolete: resize a views bottom" |
|
1076 |
|
1077 self resize:aView handle:#bottom to:aPoint check:false. |
|
1078 "/ undoHistory withoutTransactionDo:[ |
|
1079 "/ self shiftLayout:aView top:0 bottom:((aPoint y) - (aView computeCorner y)) |
|
1080 "/ ]. |
|
1081 ! |
|
1082 |
|
1083 resize:aView bottomLeft:aPoint |
|
1084 "obsolete: resize a views bottom and left" |
|
1085 |
|
1086 self resize:aView handle:#bottomLeft to:aPoint check:false. |
|
1087 "/ undoHistory withoutTransactionDo:[ |
|
1088 "/ self shiftLayout:aView top:0 |
|
1089 "/ bottom:((aPoint y) - (aView computeCorner y)) |
|
1090 "/ left:((aPoint x) - (aView computeOrigin x)) |
|
1091 "/ right:0 |
|
1092 "/ |
|
1093 "/ ] |
|
1094 ! |
|
1095 |
|
1096 resize:aView corner:aPoint |
|
1097 "obsolete: resize a views corner" |
|
1098 |
|
1099 self resize:aView handle:#corner to:aPoint check:false. |
|
1100 "/ |delta| |
|
1101 "/ |
|
1102 "/ delta := aPoint - aView computeCorner. |
|
1103 "/ undoHistory withoutTransactionDo:[ |
|
1104 "/ self shiftLayout:aView top:0 bottom:(delta y) left:0 right:(delta x) |
|
1105 "/ ] |
|
1106 ! |
|
1107 |
|
1108 resize:aComponent endPoint:newEndPoint |
|
1109 "obsolete: move a component's endPoint" |
|
1110 |
|
1111 self resize:aComponent handle:#endPoint to:newEndPoint check:false |
|
1112 |
|
1113 "/ undoHistory |
|
1114 "/ withoutTransactionDo:[ |
|
1115 "/ self shiftLayout:aComponent startPoint:0 endPoint:(newEndPoint - (aComponent endPoint)) |
|
1116 "/ ] |
|
1117 ! |
|
1118 |
|
1119 resize:aComponent handle:aSymbol to:aPoint check:doCheck |
|
1120 "resize a views handle - if doCheck is true, only check if the handle would change |
|
1121 (used to avoid flicker, when an aligned move would actually not move anything)" |
|
1122 |
|
1123 |newX newY oldBottom oldTop oldLeft oldRight |
|
1124 oldOrigin oldCorner shiftTop shiftBottom shiftLeft shiftRight| |
|
1125 |
|
1126 aSymbol == #startPoint ifTrue:[ |
|
1127 doCheck ifTrue:[ |
|
1128 ^ aPoint ~= (aComponent startPoint) |
|
1129 ]. |
|
1130 self |
|
1131 shiftLayout:aComponent |
|
1132 startPoint:(aPoint - (aComponent startPoint)) endPoint:0. |
|
1133 ^ self. |
|
1134 ]. |
|
1135 aSymbol == #endPoint ifTrue:[ |
|
1136 doCheck ifTrue:[ |
|
1137 ^ aPoint ~= (aComponent endPoint) |
|
1138 ]. |
|
1139 self |
|
1140 shiftLayout:aComponent |
|
1141 startPoint:0 endPoint:(aPoint - (aComponent endPoint)). |
|
1142 ^ self. |
|
1143 ]. |
|
1144 |
|
1145 newX := aPoint x. |
|
1146 newY := aPoint y. |
|
1147 shiftTop := shiftBottom := shiftLeft := shiftRight := 0. |
|
1148 |
|
1149 oldOrigin := aComponent computeOrigin. |
|
1150 oldCorner := aComponent computeCorner. |
|
1151 |
|
1152 oldTop := oldOrigin y. |
|
1153 oldBottom := oldCorner y. |
|
1154 oldLeft := oldOrigin x. |
|
1155 oldRight := oldCorner x. |
|
1156 |
|
1157 aSymbol == #bottom ifTrue:[ |
|
1158 shiftBottom := newY - oldBottom. |
|
1159 ]. |
|
1160 aSymbol == #top ifTrue:[ |
|
1161 shiftTop := newY - oldTop. |
|
1162 ]. |
|
1163 aSymbol == #left ifTrue:[ |
|
1164 shiftLeft := newX - oldLeft. |
|
1165 ]. |
|
1166 aSymbol == #right ifTrue:[ |
|
1167 shiftRight := newX - oldRight. |
|
1168 ]. |
|
1169 aSymbol == #origin ifTrue:[ |
|
1170 shiftLeft := newX - oldLeft. |
|
1171 shiftTop := newY - oldTop. |
|
1172 ]. |
|
1173 aSymbol == #topRight ifTrue:[ |
|
1174 shiftRight := newX - oldRight. |
|
1175 shiftTop := newY - oldTop. |
|
1176 ]. |
|
1177 aSymbol == #corner ifTrue:[ |
|
1178 shiftRight := newX - oldRight. |
|
1179 shiftBottom := newY - oldBottom. |
|
1180 ]. |
|
1181 aSymbol == #bottomLeft ifTrue:[ |
|
1182 shiftLeft := newX - oldLeft. |
|
1183 shiftBottom := newY - oldBottom. |
|
1184 ]. |
|
1185 |
|
1186 doCheck ifTrue:[ |
|
1187 ^ (shiftTop ~= 0) or:[ shiftBottom ~= 0 or:[ shiftLeft ~= 0 or:[ shiftRight ~= 0 ]]] |
|
1188 ]. |
|
1189 |
|
1190 undoHistory withoutTransactionDo:[ |
|
1191 self |
|
1192 shiftLayout:aComponent |
|
1193 top:shiftTop bottom:shiftBottom |
|
1194 left:shiftLeft right:shiftRight |
|
1195 ]. |
|
1196 ! |
|
1197 |
|
1198 resize:aView left:aPoint |
|
1199 "obsolete: resize a views left" |
|
1200 |
|
1201 self resize:aView handle:#left to:aPoint check:false. |
|
1202 "/ undoHistory withoutTransactionDo:[ |
|
1203 "/ self shiftLayout:aView left:((aPoint x) - (aView computeOrigin x)) right:0 |
|
1204 "/ ] |
|
1205 ! |
|
1206 |
|
1207 resize:aView origin:aPoint |
|
1208 "obsolete: resize a views origin" |
|
1209 |
|
1210 self resize:aView handle:#origin to:aPoint check:false. |
|
1211 "/ |delta| |
|
1212 "/ |
|
1213 "/ delta := aPoint - aView computeOrigin. |
|
1214 "/ undoHistory withoutTransactionDo:[ |
|
1215 "/ self shiftLayout:aView top:(delta y) bottom:0 left:(delta x) right:0 |
|
1216 "/ ] |
|
1217 ! |
|
1218 |
|
1219 resize:aView right:aPoint |
|
1220 "obsolete: resize a views right" |
|
1221 |
|
1222 self resize:aView handle:#right to:aPoint check:false. |
|
1223 "/ undoHistory withoutTransactionDo:[ |
|
1224 "/ self shiftLayout:aView left:0 right:((aPoint x) - (aView computeCorner x)) |
|
1225 "/ ] |
|
1226 ! |
|
1227 |
|
1228 resize:aComponent startPoint:newStartPoint |
|
1229 "obsolete: move a component's startPoint" |
|
1230 |
|
1231 self resize:aComponent handle:#startPoint to:newStartPoint check:false |
|
1232 "/ undoHistory |
|
1233 "/ withoutTransactionDo:[ |
|
1234 "/ self shiftLayout:aComponent startPoint:(newStartPoint - (aComponent startPoint)) endPoint:0 |
|
1235 "/ ] |
|
1236 ! |
|
1237 |
|
1238 resize:aView top:aPoint |
|
1239 "obsolete: resize a views top" |
|
1240 |
|
1241 self resize:aView handle:#top to:aPoint check:false. |
|
1242 "/ undoHistory withoutTransactionDo:[ |
|
1243 "/ self shiftLayout:aView |
|
1244 "/ top:((aPoint y) - (aView computeOrigin y)) |
|
1245 "/ bottom:0 |
|
1246 "/ ] |
|
1247 ! |
|
1248 |
|
1249 resize:aView topRight:aPoint |
|
1250 "obsolete: resize a views top and right" |
|
1251 |
|
1252 self resize:aView handle:#topRight to:aPoint check:false. |
|
1253 "/ undoHistory withoutTransactionDo:[ |
|
1254 "/ self shiftLayout:aView |
|
1255 "/ top:((aPoint y) - (aView computeOrigin y)) |
|
1256 "/ bottom:0 |
|
1257 "/ left:0 |
|
1258 "/ right:((aPoint x) - (aView computeCorner x)) |
|
1259 "/ ] |
1039 ! |
1260 ! |
1040 |
1261 |
1041 startResizeBorder:borderHandleSelector |
1262 startResizeBorder:borderHandleSelector |
1042 "start resizing the selected view at the given borderHandle" |
1263 "start resizing the selected view at the given borderHandle" |
1043 |
1264 |
1097 recomputeShapeIfTransparentBox:aView |
1318 recomputeShapeIfTransparentBox:aView |
1098 (aView notNil and:[aView isTransparentBox]) ifTrue:[ |
1319 (aView notNil and:[aView isTransparentBox]) ifTrue:[ |
1099 aView computeShape. |
1320 aView computeShape. |
1100 aView clear; redraw |
1321 aView clear; redraw |
1101 ]. |
1322 ]. |
1102 ! |
|
1103 |
|
1104 resize:aView bottom:aPoint |
|
1105 "resize a views bottom" |
|
1106 |
|
1107 undoHistory withoutTransactionDo:[ |
|
1108 self shiftLayout:aView top:0 bottom:((aPoint y) - (aView computeCorner y)) |
|
1109 ]. |
|
1110 ! |
|
1111 |
|
1112 resize:aView bottomLeft:aPoint |
|
1113 "resize a views bottom and left" |
|
1114 |
|
1115 undoHistory withoutTransactionDo:[ |
|
1116 self shiftLayout:aView top:0 |
|
1117 bottom:((aPoint y) - (aView computeCorner y)) |
|
1118 left:((aPoint x) - (aView computeOrigin x)) |
|
1119 right:0 |
|
1120 |
|
1121 ] |
|
1122 ! |
|
1123 |
|
1124 resize:aView corner:aPoint |
|
1125 "resize a views corner" |
|
1126 |
|
1127 |delta| |
|
1128 |
|
1129 delta := aPoint - aView computeCorner. |
|
1130 |
|
1131 undoHistory withoutTransactionDo:[ |
|
1132 self shiftLayout:aView top:0 bottom:(delta y) left:0 right:(delta x) |
|
1133 ] |
|
1134 ! |
|
1135 |
|
1136 resize:aComponent endPoint:newEndPoint |
|
1137 "move a component's endPoint" |
|
1138 |
|
1139 undoHistory |
|
1140 withoutTransactionDo:[ |
|
1141 self shiftLayout:aComponent startPoint:0 endPoint:(newEndPoint - (aComponent endPoint)) |
|
1142 ] |
|
1143 ! |
|
1144 |
|
1145 resize:aView left:aPoint |
|
1146 "resize a views left" |
|
1147 |
|
1148 undoHistory withoutTransactionDo:[ |
|
1149 self shiftLayout:aView left:((aPoint x) - (aView computeOrigin x)) right:0 |
|
1150 ] |
|
1151 ! |
|
1152 |
|
1153 resize:aView origin:aPoint |
|
1154 "resize a views origin" |
|
1155 |
|
1156 |delta| |
|
1157 |
|
1158 delta := aPoint - aView computeOrigin. |
|
1159 |
|
1160 undoHistory withoutTransactionDo:[ |
|
1161 self shiftLayout:aView top:(delta y) bottom:0 left:(delta x) right:0 |
|
1162 ] |
|
1163 ! |
|
1164 |
|
1165 resize:aView right:aPoint |
|
1166 "resize a views right" |
|
1167 |
|
1168 undoHistory withoutTransactionDo:[ |
|
1169 self shiftLayout:aView left:0 right:((aPoint x) - (aView computeCorner x)) |
|
1170 ] |
|
1171 ! |
|
1172 |
|
1173 resize:aComponent startPoint:newStartPoint |
|
1174 "move a component's startPoint" |
|
1175 |
|
1176 undoHistory |
|
1177 withoutTransactionDo:[ |
|
1178 self shiftLayout:aComponent startPoint:(newStartPoint - (aComponent startPoint)) endPoint:0 |
|
1179 ] |
|
1180 ! |
|
1181 |
|
1182 resize:aView top:aPoint |
|
1183 "resize a views top" |
|
1184 |
|
1185 undoHistory withoutTransactionDo:[ |
|
1186 self shiftLayout:aView |
|
1187 top:((aPoint y) - (aView computeOrigin y)) |
|
1188 bottom:0 |
|
1189 ] |
|
1190 ! |
|
1191 |
|
1192 resize:aView topRight:aPoint |
|
1193 "resize a views top and right" |
|
1194 |
|
1195 undoHistory withoutTransactionDo:[ |
|
1196 self shiftLayout:aView |
|
1197 top:((aPoint y) - (aView computeOrigin y)) |
|
1198 bottom:0 |
|
1199 left:0 |
|
1200 right:((aPoint x) - (aView computeCorner x)) |
|
1201 |
|
1202 ] |
|
1203 ! ! |
1323 ! ! |
1204 |
1324 |
1205 !UIObjectView methodsFor:'private-shift layout'! |
1325 !UIObjectView methodsFor:'private-shift layout'! |
1206 |
1326 |
1207 shiftLayout:aViewOrComponent horizontal:n |
1327 shiftLayout:aViewOrComponent horizontal:n |
1242 ! |
1362 ! |
1243 |
1363 |
1244 shiftLayout:aView top:t bottom:b left:l right:r |
1364 shiftLayout:aView top:t bottom:b left:l right:r |
1245 "shift layout for a view; in case of an open transaction, the undo action is registered" |
1365 "shift layout for a view; in case of an open transaction, the undo action is registered" |
1246 |
1366 |
1247 |type layout oldExt| |
1367 |type layout oldExt dX dY| |
1248 |
1368 |
1249 type := self class layoutType:aView. |
1369 type := self class layoutType:aView. |
1250 |
1370 type isNil ifTrue:[ ^ self ]. |
1251 type notNil ifTrue:[ |
1371 |
1252 self createUndoLayout:aView. |
1372 self createUndoLayout:aView. |
1253 |
1373 |
1254 type == #Extent ifTrue:[ |
1374 type == #Extent ifTrue:[ |
1255 oldExt := aView extent. |
1375 oldExt := aView extent. |
1256 aView extent:(oldExt + ((r-l) @ (b-t))). |
1376 dX := r-l. |
1257 ^ self |
1377 dY := b-t. |
1258 ]. |
1378 aView extent:(oldExt + (dX @ dY)). |
1259 |
1379 ^ self |
1260 layout := aView geometryLayout copy. |
1380 ]. |
1261 |
1381 |
1262 layout isLayout ifTrue:[ |
1382 layout := aView geometryLayout copy. |
1263 layout leftOffset:(layout leftOffset + l) |
1383 layout isLayout ifTrue:[ |
1264 topOffset:(layout topOffset + t). |
1384 layout leftOffset:(layout leftOffset + l) |
1265 |
1385 topOffset:(layout topOffset + t). |
1266 type == #LayoutFrame ifTrue:[ |
1386 |
1267 layout bottomOffset:(layout bottomOffset + b). |
1387 type == #LayoutFrame ifTrue:[ |
1268 layout rightOffset:(layout rightOffset + r). |
1388 layout bottomOffset:(layout bottomOffset + b). |
1269 ] |
1389 layout rightOffset:(layout rightOffset + r). |
1270 ] ifFalse:[ |
1390 ] |
1271 type == #Rectangle ifTrue:[ |
1391 ] ifFalse:[ |
1272 layout left:(layout left + l) |
1392 type == #Rectangle ifTrue:[ |
1273 right:(layout right + r) |
1393 layout left:(layout left + l) |
1274 top:(layout top + t) |
1394 right:(layout right + r) |
1275 bottom:(layout bottom + b). |
1395 top:(layout top + t) |
1276 ] ifFalse:[ "POINT" |
1396 bottom:(layout bottom + b). |
1277 layout x:(layout x + l) y:(layout y + t). |
1397 ] ifFalse:[ "POINT" |
1278 ] |
1398 layout x:(layout x + l) y:(layout y + t). |
1279 ]. |
1399 ] |
1280 aView geometryLayout:layout |
1400 ]. |
1281 ] |
1401 aView geometryLayout:layout |
1282 ! |
1402 ! |
1283 |
1403 |
1284 shiftLayout:aViewOrComponent vertical:n |
1404 shiftLayout:aViewOrComponent vertical:n |
1285 "shift layout for a view; in case of an open transaction, the undo action is registered" |
1405 "shift layout for a view; in case of an open transaction, the undo action is registered" |
1286 |
1406 |