UIObjectView.st
changeset 1222 bcb8b0ec295c
parent 1120 230fe13c4e51
child 1230 23e5d0c133e8
equal deleted inserted replaced
1221:473547d0dad1 1222:bcb8b0ec295c
    19 	classVariableNames:''
    19 	classVariableNames:''
    20 	poolDictionaries:''
    20 	poolDictionaries:''
    21 	category:'Interface-UIPainter'
    21 	category:'Interface-UIPainter'
    22 !
    22 !
    23 
    23 
       
    24 Object subclass:#UndoHistory
       
    25 	instanceVariableNames:'startIdentifier identifier painter history transaction enabled'
       
    26 	classVariableNames:''
       
    27 	poolDictionaries:''
       
    28 	privateIn:UIObjectView
       
    29 !
       
    30 
       
    31 Object subclass:#Transaction
       
    32 	instanceVariableNames:'identifier type text actions'
       
    33 	classVariableNames:''
       
    34 	poolDictionaries:''
       
    35 	privateIn:UIObjectView::UndoHistory
       
    36 !
       
    37 
    24 Object subclass:#ResizeData
    38 Object subclass:#ResizeData
    25 	instanceVariableNames:'object selector delta'
    39 	instanceVariableNames:'object selector delta'
    26 	classVariableNames:''
    40 	classVariableNames:''
    27 	poolDictionaries:''
    41 	poolDictionaries:''
    28 	privateIn:UIObjectView
    42 	privateIn:UIObjectView
    29 !
       
    30 
       
    31 Object subclass:#UndoHistory
       
    32 	instanceVariableNames:'startIdentifier identifier painter history transaction enabled'
       
    33 	classVariableNames:''
       
    34 	poolDictionaries:''
       
    35 	privateIn:UIObjectView
       
    36 !
       
    37 
       
    38 Object subclass:#Transaction
       
    39 	instanceVariableNames:'identifier type text actions'
       
    40 	classVariableNames:''
       
    41 	poolDictionaries:''
       
    42 	privateIn:UIObjectView::UndoHistory
       
    43 !
    43 !
    44 
    44 
    45 !UIObjectView class methodsFor:'documentation'!
    45 !UIObjectView class methodsFor:'documentation'!
    46 
    46 
    47 copyright
    47 copyright
   501 
   501 
   502 keyPress:key x:x y:y
   502 keyPress:key x:x y:y
   503     "any key pressed
   503     "any key pressed
   504     "
   504     "
   505     <resource: #keyboard ( #CursorUp #CursorDown #CursorLeft #CursorRight
   505     <resource: #keyboard ( #CursorUp #CursorDown #CursorLeft #CursorRight
   506 			   #Delete #BackSpace #Cut #Copy #Paste #Cmdu ) >
   506                            #Delete #BackSpace #Cut #Copy #Paste #Cmdu ) >
       
   507 
       
   508     |n sensor|
   507 
   509 
   508     (key == #Cut or:[key == #Delete or:[key == #BackSpace]]) ifTrue: [
   510     (key == #Cut or:[key == #Delete or:[key == #BackSpace]]) ifTrue: [
   509 	^ self deleteSelection
   511         ^ self deleteSelection
   510     ].
   512     ].
   511     key == #Copy  ifTrue:[ ^ self copySelection].
   513     key == #Copy  ifTrue:[ ^ self copySelection].
   512     key == #Paste ifTrue:[ ^ self pasteBuffer].
   514     key == #Paste ifTrue:[ ^ self pasteBuffer].
   513     key == #Cmdu  ifTrue:[ ^ self undoLast ].           "/ #Undo
   515     key == #Cmdu  ifTrue:[ ^ self undoLast ].           "/ #Undo
   514 
   516 
   515     key == #CursorUp ifTrue:[^self moveSelectionUp].
   517     ( #(CursorUp CursorDown CursorRight CursorLeft)
   516     key == #CursorDown ifTrue:[^self moveSelectionDown].
   518     includes:key) ifTrue:[
   517     key == #CursorRight ifTrue:[^self moveSelectionRight].
   519         (sensor := self sensor) isNil ifTrue:[
   518     key == #CursorLeft ifTrue:[^self moveSelectionLeft].
   520             n := 1
   519 
   521         ] ifFalse:[
       
   522             n := 1 + (sensor compressKeyPressEventsWithKey:key).
       
   523             sensor shiftDown ifTrue:[
       
   524                 n := n * 10.
       
   525             ].
       
   526         ].
       
   527 
       
   528         key == #CursorUp ifTrue:[
       
   529             ^ self moveSelectionUp:n
       
   530         ].
       
   531         key == #CursorDown ifTrue:[
       
   532             ^ self moveSelectionDown:n
       
   533         ].
       
   534         key == #CursorRight ifTrue:[
       
   535             ^ self moveSelectionRight:n
       
   536         ].
       
   537         key == #CursorLeft ifTrue:[
       
   538             ^ self moveSelectionLeft:n
       
   539         ].
       
   540     ].
   520     super keyPress:key x:x y:y
   541     super keyPress:key x:x y:y
   521 
   542 
   522     "Modified: / 6.3.1999 / 22:47:48 / cg"
   543     "Modified: / 6.3.1999 / 22:47:48 / cg"
   523 !
   544 !
   524 
   545 
  1660 !
  1681 !
  1661 
  1682 
  1662 moveSelectionDown
  1683 moveSelectionDown
  1663     "move selection down
  1684     "move selection down
  1664     "
  1685     "
       
  1686     self moveSelectionDown:1
       
  1687 
       
  1688 !
       
  1689 
       
  1690 moveSelectionDown:howMany
       
  1691     "move selection down
       
  1692     "
  1665     |gridY n|
  1693     |gridY n|
  1666 
  1694 
  1667     gridAlign notNil ifTrue:[gridY := gridAlign y]
  1695     gridAlign notNil ifTrue:[gridY := gridAlign y]
  1668 		    ifFalse:[gridY := 1].
  1696                     ifFalse:[gridY := 1].
  1669 
  1697 
  1670     self moveDo:[:aView|
  1698     self moveDo:[:aView|
  1671 	aligning ifTrue:[
  1699         aligning ifTrue:[
  1672 	    n := ((aView computeCorner y) \\ gridY).
  1700             n := ((aView computeCorner y) \\ gridY).
  1673 
  1701 
  1674 	    n ~~ 0 ifTrue:[
  1702             n ~~ 0 ifTrue:[
  1675 		n := gridY - n + 1.
  1703                 n := gridY - n + 1.
  1676 	    ] ifFalse:[
  1704             ] ifFalse:[
  1677 		n := gridY
  1705                 n := gridY
  1678 	    ]
  1706             ]
  1679 	] ifFalse:[
  1707         ] ifFalse:[
  1680 	    n := 1
  1708             n := 1
  1681 	].
  1709         ].
  1682 	self shiftLayout:aView top:n bottom:n
  1710         n := n * howMany.
       
  1711         self shiftLayout:aView top:n bottom:n
  1683     ]
  1712     ]
  1684 !
  1713 !
  1685 
  1714 
  1686 moveSelectionLeft
  1715 moveSelectionLeft
  1687     "move selection left
  1716     "move selection left
  1688     "
  1717     "
       
  1718     self moveSelectionLeft:1
       
  1719 
       
  1720 !
       
  1721 
       
  1722 moveSelectionLeft:howMany
       
  1723     "move selection left
       
  1724     "
  1689     |gridX n|
  1725     |gridX n|
  1690 
  1726 
  1691     gridAlign notNil ifTrue:[gridX := gridAlign x]
  1727     gridAlign notNil ifTrue:[gridX := gridAlign x]
  1692 		    ifFalse:[gridX := 1].
  1728                     ifFalse:[gridX := 1].
  1693 
  1729 
  1694     self moveDo:[:aView|
  1730     self moveDo:[:aView|
  1695 	aligning ifTrue:[
  1731         aligning ifTrue:[
  1696 	    n := ((aView computeOrigin x) \\ gridX).
  1732             n := ((aView computeOrigin x) \\ gridX).
  1697 	    n == 0 ifTrue:[n := gridX].
  1733             n == 0 ifTrue:[n := gridX].
  1698 	    n := n negated.
  1734             n := n negated.
  1699 	] ifFalse:[
  1735         ] ifFalse:[
  1700 	    n := -1
  1736             n := -1
  1701 	].
  1737         ].
  1702 	self shiftLayout:aView left:n right:n
  1738         n := n * howMany.
       
  1739         self shiftLayout:aView left:n right:n
  1703     ]
  1740     ]
  1704 !
  1741 !
  1705 
  1742 
  1706 moveSelectionRight
  1743 moveSelectionRight
  1707     "move selection right
  1744     "move selection right
  1708     "
  1745     "
       
  1746     self moveSelectionRight:1
       
  1747 
       
  1748 !
       
  1749 
       
  1750 moveSelectionRight:howMany
       
  1751     "move selection right
       
  1752     "
  1709     |gridX n|
  1753     |gridX n|
  1710 
  1754 
  1711     gridAlign notNil ifTrue:[gridX := gridAlign x]
  1755     gridAlign notNil ifTrue:[gridX := gridAlign x]
  1712 		    ifFalse:[gridX := 1].
  1756                     ifFalse:[gridX := 1].
  1713 
  1757 
  1714     self moveDo:[:aView|
  1758     self moveDo:[:aView|
  1715 	aligning ifTrue:[
  1759         aligning ifTrue:[
  1716 	    n := ((aView computeCorner x) \\ gridX).
  1760             n := ((aView computeCorner x) \\ gridX).
  1717 
  1761 
  1718 	    n ~~ 0 ifTrue:[n := n negated]
  1762             n ~~ 0 ifTrue:[n := n negated]
  1719 		  ifFalse:[n := gridX]
  1763                   ifFalse:[n := gridX]
  1720 	] ifFalse:[
  1764         ] ifFalse:[
  1721 	    n := 1
  1765             n := 1
  1722 	].
  1766         ].
  1723 	self shiftLayout:aView left:n right:n
  1767         n := n * howMany.
       
  1768         self shiftLayout:aView left:n right:n
  1724     ]
  1769     ]
  1725 !
  1770 !
  1726 
  1771 
  1727 moveSelectionUp
  1772 moveSelectionUp
  1728     "move selection up
  1773     "move selection up
  1729     "
  1774     "
       
  1775     self moveSelectionUp:1
       
  1776 !
       
  1777 
       
  1778 moveSelectionUp:howMany
       
  1779     "move selection up
       
  1780     "
  1730     |gridY n|
  1781     |gridY n|
  1731 
  1782 
  1732     gridAlign notNil ifTrue:[gridY := gridAlign y]
  1783     gridAlign notNil ifTrue:[gridY := gridAlign y]
  1733 		    ifFalse:[gridY := 1].
  1784                     ifFalse:[gridY := 1].
  1734 
  1785 
  1735     self moveDo:[:aView|
  1786     self moveDo:[:aView|
  1736 	aligning ifTrue:[
  1787         aligning ifTrue:[
  1737 	    n := ((aView computeOrigin x) \\ gridY).
  1788             n := ((aView computeOrigin x) \\ gridY).
  1738 	    n == 0 ifTrue:[n := gridY].
  1789             n == 0 ifTrue:[n := gridY].
  1739 	    n := n negated.
  1790             n := n negated.
  1740 	] ifFalse:[
  1791         ] ifFalse:[
  1741 	    n := -1
  1792             n := -1
  1742 	].
  1793         ].
  1743 	self shiftLayout:aView top:n bottom:n
  1794         n := n * howMany.
       
  1795         self shiftLayout:aView top:n bottom:n
  1744     ]
  1796     ]
  1745 
  1797 
  1746 ! !
  1798 ! !
  1747 
  1799 
  1748 !UIObjectView methodsFor:'user actions - position'!
  1800 !UIObjectView methodsFor:'user actions - position'!
  2229 	    self select:newSel.
  2281 	    self select:newSel.
  2230 	]
  2282 	]
  2231     ].
  2283     ].
  2232 ! !
  2284 ! !
  2233 
  2285 
  2234 !UIObjectView::ResizeData methodsFor:'accessing'!
       
  2235 
       
  2236 delta
       
  2237     ^ delta
       
  2238 
       
  2239     "Created: / 2.2.1998 / 13:40:32 / cg"
       
  2240 !
       
  2241 
       
  2242 object
       
  2243     ^ object
       
  2244 
       
  2245     "Created: / 2.2.1998 / 13:40:24 / cg"
       
  2246 !
       
  2247 
       
  2248 object:anObject selector:aSymbol delta:anInteger
       
  2249     object := anObject.
       
  2250     selector := aSymbol.
       
  2251     delta := anInteger.
       
  2252 
       
  2253     "Created: / 2.2.1998 / 13:39:22 / cg"
       
  2254 !
       
  2255 
       
  2256 selector
       
  2257     ^ selector
       
  2258 
       
  2259     "Created: / 2.2.1998 / 13:40:42 / cg"
       
  2260 ! !
       
  2261 
       
  2262 !UIObjectView::UndoHistory class methodsFor:'constants'!
  2286 !UIObjectView::UndoHistory class methodsFor:'constants'!
  2263 
  2287 
  2264 maxHistorySize
  2288 maxHistorySize
  2265     "returns maximum size of history before removing oldest
  2289     "returns maximum size of history before removing oldest
  2266      record
  2290      record
  2595     "returns true if no undo action is registered
  2619     "returns true if no undo action is registered
  2596     "
  2620     "
  2597     ^ actions isNil
  2621     ^ actions isNil
  2598 ! !
  2622 ! !
  2599 
  2623 
       
  2624 !UIObjectView::ResizeData methodsFor:'accessing'!
       
  2625 
       
  2626 delta
       
  2627     ^ delta
       
  2628 
       
  2629     "Created: / 2.2.1998 / 13:40:32 / cg"
       
  2630 !
       
  2631 
       
  2632 object
       
  2633     ^ object
       
  2634 
       
  2635     "Created: / 2.2.1998 / 13:40:24 / cg"
       
  2636 !
       
  2637 
       
  2638 object:anObject selector:aSymbol delta:anInteger
       
  2639     object := anObject.
       
  2640     selector := aSymbol.
       
  2641     delta := anInteger.
       
  2642 
       
  2643     "Created: / 2.2.1998 / 13:39:22 / cg"
       
  2644 !
       
  2645 
       
  2646 selector
       
  2647     ^ selector
       
  2648 
       
  2649     "Created: / 2.2.1998 / 13:40:42 / cg"
       
  2650 ! !
       
  2651 
  2600 !UIObjectView class methodsFor:'documentation'!
  2652 !UIObjectView class methodsFor:'documentation'!
  2601 
  2653 
  2602 version
  2654 version
  2603     ^ '$Header$'
  2655     ^ '$Header$'
  2604 ! !
  2656 ! !