equal
deleted
inserted
replaced
23 |
23 |
24 !UIObjectView class methodsFor:'documentation'! |
24 !UIObjectView class methodsFor:'documentation'! |
25 |
25 |
26 documentation |
26 documentation |
27 " |
27 " |
28 buildIn view used by the UIPainter; from this view, the layout of the |
28 buildIn view used by the UIPainter; it provides all services for creating, deleting |
29 new application derives from. |
29 moving and changing layouts of painted components on a canvas. |
30 |
30 |
31 [see also:] |
31 [see also:] |
32 UIBuilder |
32 UIBuilder |
33 UIPainterView |
33 UIPainterView |
34 " |
34 " |
244 enabled:aState |
244 enabled:aState |
245 "set the modification / test mode |
245 "set the modification / test mode |
246 " |
246 " |
247 (aState == enableChannel value) ifFalse:[ |
247 (aState == enableChannel value) ifFalse:[ |
248 aState ifFalse:[ |
248 aState ifFalse:[ |
249 saveSelection := self selection copy. |
249 saveSelection := self selection. |
250 self unselect. |
250 self select:nil. |
251 enableChannel value:aState. |
251 enableChannel value:aState. |
252 inputView unrealize. |
252 inputView unrealize. |
253 ] ifTrue:[ |
253 ] ifTrue:[ |
254 inputView raise. |
254 inputView raise. |
255 inputView realize. |
255 inputView realize. |
580 startCreate:aPoint |
580 startCreate:aPoint |
581 "start a widget create |
581 "start a widget create |
582 " |
582 " |
583 |widget object start frame delta| |
583 |widget object start frame delta| |
584 |
584 |
585 self unselect. |
585 self select:nil. |
586 widget := self findContainerViewAt:aPoint. |
586 widget := self findContainerViewAt:aPoint. |
587 |
587 |
588 motionAction := [:movePoint| self doDragCreate:movePoint]. |
588 motionAction := [:movePoint| self doDragCreate:movePoint]. |
589 releaseAction := [ self endCreate]. |
589 releaseAction := [ self endCreate]. |
590 |
590 |
721 ] |
721 ] |
722 ]. |
722 ]. |
723 |
723 |
724 aView isNil ifTrue:[ |
724 aView isNil ifTrue:[ |
725 (aView := self findObjectAt:aPoint) isNil ifTrue:[ |
725 (aView := self findObjectAt:aPoint) isNil ifTrue:[ |
726 ^ self unselect |
726 ^ self select:nil |
727 ]. |
727 ]. |
728 |
728 |
729 (self canMove:aView) ifFalse:[ |
729 (self canMove:aView) ifFalse:[ |
730 ^ self select:aView |
730 ^ self select:aView |
731 ] |
731 ] |
897 |
897 |
898 showUnselected:aComponent |
898 showUnselected:aComponent |
899 "show object unselected |
899 "show object unselected |
900 " |
900 " |
901 |wasClipped delta r oldPaint| |
901 |wasClipped delta r oldPaint| |
902 |
|
903 r := aComponent origin extent:8@8. |
|
904 |
902 |
905 (wasClipped := clipChildren) ifTrue:[ |
903 (wasClipped := clipChildren) ifTrue:[ |
906 self clippedByChildren:(clipChildren := false). |
904 self clippedByChildren:(clipChildren := false). |
907 ]. |
905 ]. |
908 |
906 |
1198 |
1196 |
1199 ! ! |
1197 ! ! |
1200 |
1198 |
1201 !UIObjectView methodsFor:'selections'! |
1199 !UIObjectView methodsFor:'selections'! |
1202 |
1200 |
1203 addToSelection:anObject |
|
1204 "add anObject to selection |
|
1205 " |
|
1206 |coll| |
|
1207 |
|
1208 self enabled ifTrue:[ |
|
1209 self hasSelection ifFalse:[ |
|
1210 self select:anObject |
|
1211 ] ifTrue:[ |
|
1212 (self isSelected:anObject) ifFalse:[ |
|
1213 (coll := self selection) isCollection ifFalse:[ |
|
1214 coll := OrderedCollection with:coll |
|
1215 ]. |
|
1216 coll add:anObject. |
|
1217 self setSelection:coll withRedraw:false. |
|
1218 self showSelected:anObject. |
|
1219 self selectionChanged. |
|
1220 ] |
|
1221 ] |
|
1222 ] |
|
1223 ! |
|
1224 |
|
1225 moveableSelection |
1201 moveableSelection |
1226 "tests whether all selected objects are moveable and in case |
1202 "checks whether the selection is not empty and all selected instances |
1227 of true the selection is returned, otherwise nil |
1203 can be moved. If true the selection is returned otherwise nil |
1228 " |
1204 " |
1229 |coll| |
1205 |coll| |
1230 |
1206 |
1231 self hasSelection ifTrue:[ |
1207 self hasSelection ifTrue:[ |
1232 (self canMove:(coll := self selection)) ifTrue:[ |
1208 (self canMove:(coll := self selection)) ifTrue:[ |
1235 ]. |
1211 ]. |
1236 ^ nil |
1212 ^ nil |
1237 ! |
1213 ! |
1238 |
1214 |
1239 numberOfSelections |
1215 numberOfSelections |
1240 "return the number of selected entries |
1216 "return the number of selected instances |
1241 " |
1217 " |
1242 |coll size| |
1218 |coll size| |
1243 |
1219 |
1244 coll := self selection. |
1220 coll := self selection. |
1245 size := coll size. |
1221 size := coll size. |
1246 |
1222 |
1247 (size ~~ 0 or:[coll isNil]) ifTrue:[^ size]. |
1223 (size ~~ 0 or:[coll isNil]) ifTrue:[^ size]. |
1248 ^ 1 |
1224 ^ 1 |
1249 ! |
|
1250 |
|
1251 removeFromSelection:anObject |
|
1252 "remove anObject from selection |
|
1253 " |
|
1254 |sel| |
|
1255 |
|
1256 (self isSelected:anObject) ifFalse:[ |
|
1257 ^ self |
|
1258 ]. |
|
1259 |
|
1260 sel := self selection. |
|
1261 |
|
1262 sel size > 1 ifTrue:[ |
|
1263 sel := sel copy. |
|
1264 sel remove:anObject ifAbsent:nil. |
|
1265 ] ifFalse:[ |
|
1266 sel := nil |
|
1267 ]. |
|
1268 self setSelection:sel withRedraw:true. |
|
1269 self selectionChanged. |
|
1270 ! |
1225 ! |
1271 |
1226 |
1272 select:something |
1227 select:something |
1273 "change selection to something |
1228 "change selection to something |
1274 " |
1229 " |
1279 |
1234 |
1280 |
1235 |
1281 |
1236 |
1282 ! |
1237 ! |
1283 |
1238 |
1284 selection |
|
1285 "returns selection |
|
1286 " |
|
1287 ^ selection |
|
1288 |
|
1289 |
|
1290 ! |
|
1291 |
|
1292 selectionChanged |
1239 selectionChanged |
1293 "called whenever the selection changed |
1240 "called whenever the selection changed |
1294 " |
1241 " |
1295 self subclassResponsibility |
1242 self subclassResponsibility |
1296 |
1243 |
1302 self forEach:(self selection) do:aBlock |
1249 self forEach:(self selection) do:aBlock |
1303 |
1250 |
1304 |
1251 |
1305 ! |
1252 ! |
1306 |
1253 |
1307 setSelection:aNewSelection withRedraw:doRedraw |
|
1308 "set a new selection |
|
1309 " |
|
1310 doRedraw ifTrue:[ |
|
1311 self hideSelection. |
|
1312 selection := aNewSelection. |
|
1313 self showSelection |
|
1314 ] ifFalse:[ |
|
1315 selection := aNewSelection |
|
1316 ] |
|
1317 ! |
|
1318 |
|
1319 showSelection |
1254 showSelection |
1320 "show the selection - draw handles |
1255 "show the selection - draw handles |
1321 " |
1256 " |
1322 selectionHiddenLevel == 0 ifTrue:[ |
1257 selectionHiddenLevel == 0 ifTrue:[ |
1323 self selectionDo:[:el| self showSelected:el ] |
1258 self selectionDo:[:el| self showSelected:el ] |
1324 ]. |
1259 ]. |
1325 ! |
1260 ! |
1326 |
1261 |
1327 singleSelection |
1262 singleSelection |
1328 "returns single selection or nil |
1263 "checks whether one element is selected; in this case the element is |
|
1264 returned otherwise nil |
1329 " |
1265 " |
1330 |coll| |
1266 |coll| |
1331 |
1267 |
1332 (coll := self selection) isCollection ifFalse:[ |
1268 (coll := self selection) isCollection ifFalse:[ |
1333 ^ coll |
1269 ^ coll |
1336 coll size == 1 ifTrue:[ ^ coll first]. |
1272 coll size == 1 ifTrue:[ ^ coll first]. |
1337 ^ nil |
1273 ^ nil |
1338 ! |
1274 ! |
1339 |
1275 |
1340 singleSelectionDo:aBlock |
1276 singleSelectionDo:aBlock |
1341 "perform block with argument a view in case of one selection |
1277 "checks whether one element is selected; in this case the block |
|
1278 with argument the selected instance will be processed |
1342 " |
1279 " |
1343 |view| |
1280 |view| |
1344 |
1281 |
1345 (view := self singleSelection) notNil ifTrue:[ |
1282 (view := self singleSelection) notNil ifTrue:[ |
1346 aBlock value:view |
1283 aBlock value:view |
1392 aBlock value. |
1329 aBlock value. |
1393 self setSelection:sel withRedraw:true. |
1330 self setSelection:sel withRedraw:true. |
1394 ] |
1331 ] |
1395 |
1332 |
1396 |
1333 |
|
1334 ! ! |
|
1335 |
|
1336 !UIObjectView methodsFor:'selections basic'! |
|
1337 |
|
1338 addToSelection:anObject |
|
1339 "add an object to the selection |
|
1340 " |
|
1341 (self enabled and:[(self isSelected:anObject) not]) ifTrue:[ |
|
1342 selection isCollection ifFalse:[ |
|
1343 selection isNil ifTrue:[ |
|
1344 selection := anObject |
|
1345 ] ifFalse:[ |
|
1346 selection := OrderedCollection with:selection with:anObject |
|
1347 ] |
|
1348 ] ifTrue:[ |
|
1349 selection add:anObject |
|
1350 ]. |
|
1351 self showSelected:anObject. |
|
1352 self selectionChanged. |
|
1353 ] |
|
1354 ! |
|
1355 |
|
1356 removeFromSelection:anObject |
|
1357 "remove an object from the selection |
|
1358 " |
|
1359 (self isSelected:anObject) ifTrue:[ |
|
1360 self showUnselected:anObject. |
|
1361 |
|
1362 selection size > 1 ifTrue:[ |
|
1363 selection remove:anObject ifAbsent:nil. |
|
1364 self showSelection. |
|
1365 ] ifFalse:[ |
|
1366 selection := nil |
|
1367 ]. |
|
1368 self selectionChanged. |
|
1369 ] |
|
1370 ! |
|
1371 |
|
1372 selection |
|
1373 "returns the current selection |
|
1374 " |
|
1375 ^ selection |
|
1376 |
|
1377 |
|
1378 ! |
|
1379 |
|
1380 setSelection:aNewSelection withRedraw:doRedraw |
|
1381 "set a new selection without change notifications |
|
1382 " |
|
1383 doRedraw ifTrue:[ |
|
1384 self hideSelection. |
|
1385 selection := aNewSelection. |
|
1386 self showSelection |
|
1387 ] ifFalse:[ |
|
1388 selection := aNewSelection |
|
1389 ] |
1397 ! ! |
1390 ! ! |
1398 |
1391 |
1399 !UIObjectView methodsFor:'testing'! |
1392 !UIObjectView methodsFor:'testing'! |
1400 |
1393 |
1401 canMove:something |
1394 canMove:something |
2245 ! |
2238 ! |
2246 |
2239 |
2247 openUndoMenu |
2240 openUndoMenu |
2248 "open undo menu |
2241 "open undo menu |
2249 " |
2242 " |
2250 self unselect. |
2243 self select:nil. |
2251 |
2244 |
2252 self withSelectionHiddenDo:[ |
2245 self withSelectionHiddenDo:[ |
2253 undoHistory openUndoMenu |
2246 undoHistory openUndoMenu |
2254 ]. |
2247 ]. |
2255 |
2248 |
2262 ! |
2255 ! |
2263 |
2256 |
2264 undoLast |
2257 undoLast |
2265 "undo last action |
2258 "undo last action |
2266 " |
2259 " |
2267 self unselect. |
2260 self select:nil. |
2268 |
2261 |
2269 self withSelectionHiddenDo:[ |
2262 self withSelectionHiddenDo:[ |
2270 undoHistory undoLast:1 |
2263 undoHistory undoLast:1 |
2271 ]. |
2264 ]. |
2272 |
2265 |
2277 maxHistorySize |
2270 maxHistorySize |
2278 "returns maximum size of history before removing oldest |
2271 "returns maximum size of history before removing oldest |
2279 record |
2272 record |
2280 " |
2273 " |
2281 ^ 50 |
2274 ^ 50 |
|
2275 |
|
2276 |
|
2277 ! ! |
|
2278 |
|
2279 !UIObjectView::UndoHistory class methodsFor:'documentation'! |
|
2280 |
|
2281 documentation |
|
2282 " |
|
2283 undo history used by the UIPainter-Tool; to each operation, an undo block |
|
2284 and some text is stored. In case of a required undo, the corresponding |
|
2285 undo block will be performed. |
|
2286 |
|
2287 [see also:] |
|
2288 UIObjectView |
|
2289 UIPainterView |
|
2290 " |
2282 |
2291 |
2283 |
2292 |
2284 ! ! |
2293 ! ! |
2285 |
2294 |
2286 !UIObjectView::UndoHistory class methodsFor:'instance creation'! |
2295 !UIObjectView::UndoHistory class methodsFor:'instance creation'! |
2469 |
2478 |
2470 ! ! |
2479 ! ! |
2471 |
2480 |
2472 !UIObjectView::UndoHistory::Transaction class methodsFor:'documentation'! |
2481 !UIObjectView::UndoHistory::Transaction class methodsFor:'documentation'! |
2473 |
2482 |
2474 version |
2483 documentation |
2475 ^ '$Header$' |
2484 " |
|
2485 represents one undo record, keeping the associated type and printable text |
|
2486 and the undo action performed on an undo request |
|
2487 |
|
2488 [see also:] |
|
2489 UndoHistory |
|
2490 " |
|
2491 |
2476 ! ! |
2492 ! ! |
2477 |
2493 |
2478 !UIObjectView::UndoHistory::Transaction class methodsFor:'instance creation'! |
2494 !UIObjectView::UndoHistory::Transaction class methodsFor:'instance creation'! |
2479 |
2495 |
2480 type:aType text:aTextOrNil |
2496 type:aType text:aTextOrNil |