UIObjectView.st
changeset 113 1854c2e61c4e
parent 100 01775d3d8489
child 119 39acd704ad51
equal deleted inserted replaced
112:6fe6c4d1672e 113:1854c2e61c4e
   124 !UIObjectView class methodsFor:'queries'!
   124 !UIObjectView class methodsFor:'queries'!
   125 
   125 
   126 layoutType:aView
   126 layoutType:aView
   127     "returns layout type of aView or nil
   127     "returns layout type of aView or nil
   128     "
   128     "
   129     |layout spec|
   129     |layout spec superView|
   130 
   130 
   131     layout := aView geometryLayout.
   131     aView notNil ifTrue:[
   132 
   132         layout := aView geometryLayout.
   133     layout notNil ifTrue:[
   133         layout notNil ifTrue:[
   134         layout isLayout ifTrue:[
   134             layout isLayout ifTrue:[
   135             layout isLayoutFrame        ifTrue:[ ^ #LayoutFrame ].
   135                 layout isLayoutFrame        ifTrue:[ ^ #LayoutFrame ].
   136             layout isAlignmentOrigin    ifTrue:[ ^ #AlignmentOrigin ].
   136                 layout isAlignmentOrigin    ifTrue:[ ^ #AlignmentOrigin ].
   137             layout isLayoutOrigin       ifTrue:[ ^ #LayoutOrigin ].
   137                 layout isLayoutOrigin       ifTrue:[ ^ #LayoutOrigin ].
       
   138             ] ifFalse:[
       
   139                 layout isRectangle          ifTrue:[ ^ #Rectangle ].
       
   140                 layout isPoint              ifTrue:[ ^ #Point ].
       
   141             ]
   138         ] ifFalse:[
   142         ] ifFalse:[
   139             layout isRectangle          ifTrue:[ ^ #Rectangle ].
   143             (superView := aView superView) notNil ifTrue:[
   140             layout isPoint              ifTrue:[ ^ #Point ].
   144                 spec := superView specClass.
       
   145                 spec canResizeSubComponents ifTrue:[
       
   146                     ^ #Extent
       
   147                 ]
       
   148             ]
   141         ]
   149         ]
   142     ] ifFalse:[
       
   143         spec := aView superView specClass.
       
   144 
       
   145         spec canResizeSubComponents     ifTrue:[ ^ #Extent ].
       
   146     ].
   150     ].
   147     ^ nil
   151     ^ nil
   148 
   152 
   149     "Modified: 28.2.1997 / 13:02:16 / cg"
   153     "Modified: 28.2.1997 / 13:02:16 / cg"
   150 ! !
   154 ! !
   151 
   155 
   152 !UIObjectView methodsFor:'accessing'!
   156 !UIObjectView methodsFor:'accessing'!
       
   157 
       
   158 canModify
       
   159     ^ testMode not
       
   160 !
       
   161 
       
   162 canModify:aBool
       
   163     self testMode:(aBool not)
       
   164 !
   153 
   165 
   154 gridAlign
   166 gridAlign
   155     "returns state of aligning to grid
   167     "returns state of aligning to grid
   156     "
   168     "
   157     ^ aligning
   169     ^ aligning
   230             self unselect.
   242             self unselect.
   231             inputView unrealize
   243             inputView unrealize
   232         ] ifFalse:[
   244         ] ifFalse:[
   233             inputView raise.
   245             inputView raise.
   234             inputView realize
   246             inputView realize
   235         ]
   247         ].
       
   248         self changed:#canModify
   236     ]
   249     ]
   237 
   250 
   238 
   251 
   239 ! !
   252 ! !
   240 
   253 
   515     object := actionData object.
   528     object := actionData object.
   516     self invertOutlineOf:object.
   529     self invertOutlineOf:object.
   517     inputView raise.
   530     inputView raise.
   518 
   531 
   519     self setupInitialLayoutFor:object.
   532     self setupInitialLayoutFor:object.
   520     self changed:#tree.
       
   521     self select:object.
   533     self select:object.
   522     actionData := nil.
   534     actionData := nil.
   523 
   535 
   524     self setDefaultActions.
   536     self setDefaultActions.
   525 
   537 
  1190 addToSelection:something
  1202 addToSelection:something
  1191     "add something to selection
  1203     "add something to selection
  1192     "
  1204     "
  1193     (self canSelect:something) ifTrue:[
  1205     (self canSelect:something) ifTrue:[
  1194         super addToSelection:something.
  1206         super addToSelection:something.
  1195         self changed:#selection.
  1207         self selectionChanged.
  1196     ]
  1208     ]
  1197 !
  1209 !
  1198 
  1210 
  1199 numberOfSelections
  1211 numberOfSelections
  1200     "return the number of selected entries
  1212     "return the number of selected entries
  1208 !
  1220 !
  1209 
  1221 
  1210 removeFromSelection:something
  1222 removeFromSelection:something
  1211     "remove something from selection
  1223     "remove something from selection
  1212     "
  1224     "
  1213     super removeFromSelection:something.
  1225     something notNil ifTrue:[
  1214     self changed:#selection
  1226         super removeFromSelection:something.
       
  1227         self selectionChanged
       
  1228     ].
  1215 
  1229 
  1216 !
  1230 !
  1217 
  1231 
  1218 select:something
  1232 select:something
  1219     "change selection to something
  1233     "change selection to something
  1220     "
  1234     "
  1221     (self canSelect:something) ifTrue:[
  1235     (self canSelect:something) ifTrue:[
  1222         super select:something.
  1236         super select:something.
  1223         self changed:#selection
  1237         self selectionChanged
  1224     ]
  1238     ]
       
  1239 
       
  1240 
  1225 
  1241 
  1226 !
  1242 !
  1227 
  1243 
  1228 selection
  1244 selection
  1229     "returns selection
  1245     "returns selection
  1230     "
  1246     "
  1231     ^ selection
  1247     ^ selection
  1232 
  1248 
       
  1249 
       
  1250 !
       
  1251 
       
  1252 selectionChanged
       
  1253     "called whenever the selection changed
       
  1254     "
       
  1255     self subclassResponsibility
  1233 
  1256 
  1234 !
  1257 !
  1235 
  1258 
  1236 showSelection
  1259 showSelection
  1237     selectionHiddenLevel == 0 ifTrue:[
  1260     selectionHiddenLevel == 0 ifTrue:[
  1262 unselect
  1285 unselect
  1263     "clear selection
  1286     "clear selection
  1264     "
  1287     "
  1265     selection notNil ifTrue:[
  1288     selection notNil ifTrue:[
  1266         super unselect.
  1289         super unselect.
  1267         self changed:#selection
  1290         self selectionChanged
  1268     ]
  1291     ]
       
  1292 
  1269 
  1293 
  1270 !
  1294 !
  1271 
  1295 
  1272 withSelectionHiddenDo:aBlock
  1296 withSelectionHiddenDo:aBlock
  1273     "apply block with selection hidden (no handles)
  1297     "apply block with selection hidden (no handles)
  1602 
  1626 
  1603 ! !
  1627 ! !
  1604 
  1628 
  1605 !UIObjectView methodsFor:'user actions - move'!
  1629 !UIObjectView methodsFor:'user actions - move'!
  1606 
  1630 
  1607 moveSelectionDown:aNumber
  1631 moveSelectionDown
  1608     "move selection down
  1632     "move selection down
  1609     "
  1633     "
  1610     |gridY|
  1634     |gridY n|
  1611 
  1635 
  1612     (self canMove:selection) ifTrue:[
  1636     (self canMove:selection) ifTrue:[
  1613         gridAlign notNil ifTrue:[gridY := gridAlign y].
  1637         gridAlign notNil ifTrue:[gridY := gridAlign y].
  1614 
  1638 
  1615         self withSelectionHiddenDo:[
  1639         self withSelectionHiddenDo:[
  1616             self transaction:#moveDown selectionDo:[:aView|
  1640             self selectionDo:[:aView|
  1617                 |n d|
       
  1618 
       
  1619                 n := aNumber.
       
  1620 
       
  1621                 aligning ifTrue:[
  1641                 aligning ifTrue:[
  1622                     d := ((aView computeCorner y) \\ gridY).
  1642                     n := ((aView computeCorner y) \\ gridY).
  1623                     n := n * gridY.
  1643 
  1624 
  1644                     n ~~ 0 ifTrue:[
  1625                     d ~~ 0 ifTrue:[
  1645                         n := gridY - n + 1.
  1626                         n := n - d + 1.
  1646                     ] ifFalse:[
       
  1647                         n := gridY
  1627                     ]
  1648                     ]
       
  1649                 ] ifFalse:[
       
  1650                     n := 1
  1628                 ].
  1651                 ].
  1629                 self shiftLayout:aView top:n bottom:n
  1652                 self shiftLayout:aView top:n bottom:n
  1630             ]
  1653             ]
  1631         ].
  1654         ].
  1632         self changed:#layout
  1655         self changed:#layout
  1633     ]
  1656     ]
  1634 
  1657 
  1635 !
  1658 !
  1636 
  1659 
  1637 moveSelectionLeft:aNumber
  1660 moveSelectionLeft
  1638     "move selection left
  1661     "move selection left
  1639     "
  1662     "
  1640     |gridX|
  1663     |gridX n|
  1641 
  1664 
  1642     (self canMove:selection) ifTrue:[
  1665     (self canMove:selection) ifTrue:[
  1643         gridAlign notNil ifTrue:[gridX := gridAlign x].
  1666         gridAlign notNil ifTrue:[gridX := gridAlign x].
  1644 
  1667 
  1645         self withSelectionHiddenDo:[
  1668         self withSelectionHiddenDo:[
  1646             self transaction:#moveLeft selectionDo:[:aView|
  1669             self selectionDo:[:aView|
  1647                 |n d|
       
  1648 
       
  1649                 n := aNumber.
       
  1650 
       
  1651                 aligning ifTrue:[
  1670                 aligning ifTrue:[
  1652                     d := ((aView computeOrigin x) \\ gridX).
  1671                     n := ((aView computeOrigin x) \\ gridX).
  1653                     d ~~ 0 ifTrue:[
  1672                     n == 0 ifTrue:[n := gridX].
  1654                         n := n-1.
  1673                     n := n negated.
  1655                     ].
  1674                 ] ifFalse:[
  1656                     n := (n * gridX) + d.
  1675                     n := -1
  1657                 ].
       
  1658                 n := n negated.
       
  1659                 self shiftLayout:aView left:n right:n
       
  1660             ]
       
  1661         ].
       
  1662         self changed:#layout
       
  1663     ]
       
  1664 !
       
  1665 
       
  1666 moveSelectionRight:aNumber
       
  1667     "move selection right
       
  1668     "
       
  1669     |gridX|
       
  1670 
       
  1671     (self canMove:selection) ifTrue:[
       
  1672         gridAlign notNil ifTrue:[gridX := gridAlign x].
       
  1673 
       
  1674         self withSelectionHiddenDo:[
       
  1675             self transaction:#moveRight selectionDo:[:aView|
       
  1676                 |n d|
       
  1677 
       
  1678                 n := aNumber.
       
  1679 
       
  1680                 aligning ifTrue:[
       
  1681                     d := ((aView computeCorner x) \\ gridX).
       
  1682                     n := n * gridX.
       
  1683 
       
  1684                     d ~~ 0 ifTrue:[
       
  1685                         n := n - d + 1.
       
  1686                     ]
       
  1687                 ].
  1676                 ].
  1688                 self shiftLayout:aView left:n right:n
  1677                 self shiftLayout:aView left:n right:n
  1689             ]
  1678             ]
  1690         ].
  1679         ].
  1691         self changed:#layout
  1680         self changed:#layout
  1692     ]
  1681     ]
  1693 !
  1682 !
  1694 
  1683 
  1695 moveSelectionUp:aNumber
  1684 moveSelectionRight
       
  1685     "move selection right
       
  1686     "
       
  1687     |gridX n|
       
  1688 
       
  1689     (self canMove:selection) ifTrue:[
       
  1690         gridAlign notNil ifTrue:[gridX := gridAlign x].
       
  1691 
       
  1692         self withSelectionHiddenDo:[
       
  1693             self selectionDo:[:aView|
       
  1694                 aligning ifTrue:[
       
  1695                     n := ((aView computeCorner x) \\ gridX).
       
  1696 
       
  1697                     n ~~ 0 ifTrue:[n := n negated]
       
  1698                           ifFalse:[n := gridX]
       
  1699                 ] ifFalse:[
       
  1700                     n := 1
       
  1701                 ].
       
  1702                 self shiftLayout:aView left:n right:n
       
  1703             ]
       
  1704         ].
       
  1705         self changed:#layout
       
  1706     ]
       
  1707 !
       
  1708 
       
  1709 moveSelectionUp
  1696     "move selection up
  1710     "move selection up
  1697     "
  1711     "
  1698     |gridY|
  1712     |gridY n|
  1699 
  1713 
  1700     (self canMove:selection) ifTrue:[
  1714     (self canMove:selection) ifTrue:[
  1701         gridAlign notNil ifTrue:[gridY := gridAlign y].
  1715         gridAlign notNil ifTrue:[gridY := gridAlign y].
  1702 
  1716 
  1703         self withSelectionHiddenDo:[
  1717         self withSelectionHiddenDo:[
  1704             self transaction:#moveUp selectionDo:[:aView|
  1718             self selectionDo:[:aView|
  1705                 |n d|
       
  1706 
       
  1707                 n := aNumber.
       
  1708 
       
  1709                 aligning ifTrue:[
  1719                 aligning ifTrue:[
  1710                     d := ((aView computeOrigin x) \\ gridY).
  1720                     n := ((aView computeOrigin x) \\ gridY).
  1711                     d ~~ 0 ifTrue:[
  1721                     n == 0 ifTrue:[n := gridY].
  1712                         n := n-1.
  1722                     n := n negated.
  1713                     ].
  1723                 ] ifFalse:[
  1714                     n := (n * gridY) + d.
  1724                     n := -1
  1715                 ].
  1725                 ].
  1716                 n := n negated.
       
  1717                 self shiftLayout:aView top:n bottom:n
  1726                 self shiftLayout:aView top:n bottom:n
  1718             ]
  1727             ]
  1719         ].
  1728         ].
  1720         self changed:#layout
  1729         self changed:#layout
  1721     ]
  1730     ]
  2167     self unselect.
  2176     self unselect.
  2168 
  2177 
  2169     self withSelectionHiddenDo:[
  2178     self withSelectionHiddenDo:[
  2170         undoHistory openUndoMenu
  2179         undoHistory openUndoMenu
  2171     ].
  2180     ].
  2172     self changed:#tree
       
  2173 
  2181 
  2174 !
  2182 !
  2175 
  2183 
  2176 removeUndoHistory
  2184 removeUndoHistory
  2177     "delete total undo history
  2185     "delete total undo history
  2185     self unselect.
  2193     self unselect.
  2186 
  2194 
  2187     self withSelectionHiddenDo:[
  2195     self withSelectionHiddenDo:[
  2188         undoHistory undoLast:1
  2196         undoHistory undoLast:1
  2189     ].
  2197     ].
  2190     self changed:#tree
  2198 
  2191 ! !
  2199 ! !
  2192 
  2200 
  2193 !UIObjectView::UndoHistory class methodsFor:'constants'!
  2201 !UIObjectView::UndoHistory class methodsFor:'constants'!
  2194 
  2202 
  2195 maxHistorySize
  2203 maxHistorySize