857 ] |
857 ] |
858 ] |
858 ] |
859 ! |
859 ! |
860 |
860 |
861 startSelectOrMove:aPoint |
861 startSelectOrMove:aPoint |
862 "a button is pressed at a point; start moving or selection |
862 "a button is pressed at a point; start moving or selecting" |
863 " |
863 |
864 |aView b v| |
864 |selectedView containerOfSelectedView |
|
865 clickedView viewOperatedUpon b pView| |
865 |
866 |
866 self enabled ifFalse:[^ self]. |
867 self enabled ifFalse:[^ self]. |
867 |
868 |
868 aView := self singleSelection. |
869 selectedView := self singleSelection. |
869 |
870 clickedView := self findObjectAt:aPoint. |
870 aView notNil ifTrue:[ |
871 |
871 v := self findContainerOfView:aView. |
872 (clickedView isComponentOf:selectedView) ifTrue:[ |
872 |
873 self unselect. |
873 v specClass canResizeSubComponents ifTrue:[ |
874 selectedView := nil. |
874 b := self whichHandleOf:aView isHitBy:aPoint. |
875 ]. |
875 |
876 |
876 (b notNil and:[b ~~ #view]) ifTrue:[ |
877 selectedView notNil ifTrue:[ |
877 ^ self startResizeBorder:b of:aView. |
878 containerOfSelectedView := self findContainerOfView:selectedView. |
878 ] |
879 |
879 ]. |
880 containerOfSelectedView specClass canResizeSubComponents ifTrue:[ |
880 |
881 b := self whichHandleOf:selectedView isHitBy:aPoint. |
881 (self sensor ctrlDown and:[self canChangeLayoutOfView:aView]) ifFalse:[ |
882 (b notNil and:[b ~~ #view]) ifTrue:[ |
882 aView := nil |
883 self startResizeBorder:b of:selectedView. |
883 ] |
884 ^ self |
884 ]. |
885 ] |
885 |
886 ]. |
886 aView isNil ifTrue:[ |
887 viewOperatedUpon := selectedView. |
887 (aView := self findObjectAt:aPoint) isNil ifTrue:[ |
888 |
888 ^ self select:nil |
889 pView := device translatePoint:aPoint fromView:self toView:selectedView superView. |
889 ]. |
890 (selectedView bounds containsPoint:pView) ifFalse:[ |
890 |
891 "/ clicked outside the selection |
891 (self canChangeLayoutOfView:aView) ifFalse:[ |
892 (self sensor ctrlDown and:[self canChangeLayoutOfView:selectedView]) ifFalse:[ |
892 ^ self select:aView |
893 viewOperatedUpon := nil |
893 ] |
894 ] |
894 ]. |
895 ] |
895 |
896 ]. |
896 (self isSelected:aView) ifFalse:[ |
897 |
897 self select:aView. |
898 viewOperatedUpon isNil ifTrue:[ |
|
899 clickedView isNil ifTrue:[ |
|
900 self select:nil. |
|
901 ^ self. |
|
902 ]. |
|
903 |
|
904 (self canChangeLayoutOfView:clickedView) ifFalse:[ |
|
905 self select:clickedView. |
|
906 ^ self |
|
907 ]. |
|
908 viewOperatedUpon := clickedView |
|
909 ]. |
|
910 |
|
911 (self isSelected:viewOperatedUpon) ifFalse:[ |
|
912 self select:viewOperatedUpon. |
898 ]. |
913 ]. |
899 |
914 |
900 (self numberOfSelections ~~ 1) ifTrue:[ |
915 (self numberOfSelections ~~ 1) ifTrue:[ |
901 releaseAction := [ |
916 releaseAction := |
902 self setDefaultActions. |
917 [ |
903 self select:aView |
918 self setDefaultActions. |
904 ] |
919 self select:viewOperatedUpon |
|
920 ] |
905 ] ifFalse:[ |
921 ] ifFalse:[ |
906 releaseAction := [self setDefaultActions] |
922 releaseAction := [self setDefaultActions] |
907 ]. |
923 ]. |
908 |
924 |
909 "prepare move operation for an object |
925 "prepare move operation for an object" |
910 " |
926 motionAction := |
911 |
927 [:movePoint| |
912 motionAction := [:movePoint| |
928 (aPoint dist:movePoint) > 4.0 ifTrue:[ |
913 (aPoint dist:movePoint) > 8.0 ifTrue:[ |
929 self startObjectMoveAt:aPoint |
914 self startObjectMoveAt:aPoint |
930 ] |
915 ] |
931 ]. |
916 ]. |
|
917 ! ! |
932 ! ! |
918 |
933 |
919 !UIObjectView methodsFor:'object resize'! |
934 !UIObjectView methodsFor:'object resize'! |
920 |
935 |
921 actionResize:anObject selector:aSelector |
936 actionResize:anObject selector:aSelector |
1374 ] |
1387 ] |
1375 |
1388 |
1376 |
1389 |
1377 ! ! |
1390 ! ! |
1378 |
1391 |
1379 !UIObjectView methodsFor:'selections basic'! |
|
1380 |
|
1381 setSelection:newSelection withRedraw:doRedraw |
|
1382 "set a new selection without change notifications" |
|
1383 |
|
1384 | sel | |
|
1385 |
|
1386 (sel := newSelection) == self ifTrue:[ |
|
1387 sel := nil |
|
1388 ]. |
|
1389 |
|
1390 doRedraw ifTrue:[ |
|
1391 self hideSelection. |
|
1392 selection := sel. |
|
1393 |
|
1394 self forEach:selection do:[:aView | |
|
1395 |superView| |
|
1396 |
|
1397 superView := aView superView. |
|
1398 self recomputeShapeIfTransparentBox:superView. |
|
1399 ]. |
|
1400 self showSelection. |
|
1401 ] ifFalse:[ |
|
1402 selection := sel |
|
1403 ] |
|
1404 ! ! |
|
1405 |
|
1406 !UIObjectView methodsFor:'selections-basic'! |
1392 !UIObjectView methodsFor:'selections-basic'! |
1407 |
1393 |
1408 recursiveRepair:theDamages startIn:aView |
1394 recursiveRepair:theDamages startIn:aView |
1409 "repair all views and contained views, which intersects the damage. |
1395 "repair all views and contained views, which intersects the damage. |
1410 !!!! all damages repaired are removed from the list of damages !!!! |
1396 !!!! all damages repaired are removed from the list of damages !!!! |
1769 "perform a move operation |
1780 "perform a move operation |
1770 " |
1781 " |
1771 |sensor tm| |
1782 |sensor tm| |
1772 |
1783 |
1773 self moveableSelection isNil ifTrue:[ |
1784 self moveableSelection isNil ifTrue:[ |
1774 ^ self |
1785 ^ self |
1775 ]. |
1786 ]. |
1776 sensor := self sensor. |
1787 sensor := self sensor. |
1777 |
1788 |
1778 tm := 0.15. |
1789 tm := 0.15. |
1779 |
1790 |
1780 self withSelectionHiddenDo:[ |
1791 self withSelectionHiddenDo:[ |
1781 self transaction:#move selectionDo:[:aView|self createUndoLayout:aView]. |
1792 self transaction:#move selectionDo:[:aView|self createUndoLayout:aView]. |
1782 |
1793 |
1783 [ |
1794 [ |
1784 self selectionDo:[:aView| aOneArgBlock value:aView ]. |
1795 self selectionDo:[:aView| aOneArgBlock value:aView ]. |
1785 Delay waitForSeconds:tm. |
1796 Delay waitForSeconds:tm. |
1786 tm := 0.02. |
1797 tm := 0.02. |
1787 self layoutChanged. |
1798 self layoutChanged. |
1788 sensor leftButtonPressed. |
1799 sensor leftButtonPressed. |
1789 ] whileTrue. |
1800 ] whileTrue. |
1790 |
1801 |
1791 "/ handle any expose events (for subcomponents) before |
1802 "/ handle any expose events (for subcomponents) before |
1792 "/ redrawing the handles. |
1803 "/ redrawing the handles. |
1793 Delay waitForSeconds:0.05. |
1804 Delay waitForSeconds:0.1. |
1794 [self sensor hasExposeEventFor:nil] whileTrue:[ |
1805 [self sensor hasExposeEventFor:nil] whileTrue:[ |
1795 self windowGroup processExposeEvents |
1806 self windowGroup processExposeEvents |
1796 ] |
1807 ] |
1797 ]. |
1808 ]. |
1798 ! |
1809 ! |
1799 |
1810 |
1800 moveSelectionDown |
1811 moveSelectionDown |
1801 "move selection down |
1812 "move selection down |
1856 self shiftLayout:aView left:n right:n |
1867 self shiftLayout:aView left:n right:n |
1857 ] |
1868 ] |
1858 ! |
1869 ! |
1859 |
1870 |
1860 moveSelectionRight |
1871 moveSelectionRight |
1861 "move selection right |
1872 "move the selection to the right" |
1862 " |
1873 |
1863 self moveSelectionRight:1 |
1874 self moveSelectionRight:1 |
1864 |
|
1865 ! |
1875 ! |
1866 |
1876 |
1867 moveSelectionRight:howMany |
1877 moveSelectionRight:howMany |
1868 "move selection right |
1878 "move selection to the right by howMany pixels" |
1869 " |
1879 |
1870 |gridX n| |
1880 |gridX n| |
1871 |
1881 |
1872 gridAlign notNil ifTrue:[gridX := gridAlign x] |
1882 gridAlign notNil ifTrue:[gridX := gridAlign x] |
1873 ifFalse:[gridX := 1]. |
1883 ifFalse:[gridX := 1]. |
1874 |
1884 |