UIPainterView.st
changeset 165 f7df2a53d042
parent 162 d3f0d5dd53b1
child 175 0b0b4d99e3e7
equal deleted inserted replaced
164:1bc26edd0d3e 165:f7df2a53d042
    15 	classVariableNames:'HandCursor'
    15 	classVariableNames:'HandCursor'
    16 	poolDictionaries:''
    16 	poolDictionaries:''
    17 	category:'Interface-UIPainter'
    17 	category:'Interface-UIPainter'
    18 !
    18 !
    19 
    19 
       
    20 Object subclass:#ViewProperty
       
    21 	instanceVariableNames:'view spec identifier'
       
    22 	classVariableNames:'Identifier'
       
    23 	poolDictionaries:''
       
    24 	privateIn:UIPainterView
       
    25 !
       
    26 
    20 MultiSelectionInList subclass:#ListHolder
    27 MultiSelectionInList subclass:#ListHolder
    21 	instanceVariableNames:'painter propertyList masterElement disabledChanged'
    28 	instanceVariableNames:'painter propertyList masterElement disabledChanged'
    22 	classVariableNames:''
    29 	classVariableNames:''
    23 	poolDictionaries:''
       
    24 	privateIn:UIPainterView
       
    25 !
       
    26 
       
    27 Object subclass:#ViewProperty
       
    28 	instanceVariableNames:'view spec identifier'
       
    29 	classVariableNames:'Identifier'
       
    30 	poolDictionaries:''
    30 	poolDictionaries:''
    31 	privateIn:UIPainterView
    31 	privateIn:UIPainterView
    32 !
    32 !
    33 
    33 
    34 !UIPainterView class methodsFor:'documentation'!
    34 !UIPainterView class methodsFor:'documentation'!
   432     |paste frame pasteOrigin pasteOffset builder newSel|
   432     |paste frame pasteOrigin pasteOffset builder newSel|
   433 
   433 
   434     (self canPaste:aSpecificationOrList) ifFalse:[
   434     (self canPaste:aSpecificationOrList) ifFalse:[
   435         ^ self
   435         ^ self
   436     ].
   436     ].
   437     aSpecificationOrList isCollection ifTrue:[
       
   438         paste := aSpecificationOrList
       
   439     ] ifFalse:[
       
   440         paste := Array with:aSpecificationOrList
       
   441     ].
       
   442     frame := self singleSelection.
       
   443 
       
   444     (self canPasteInto:frame) ifFalse:[
       
   445         frame := self
       
   446     ].
       
   447     self select:nil.
       
   448 
       
   449     newSel  := OrderedCollection new.
       
   450     builder := UIBuilder new.
       
   451 
       
   452     keepLayout ifFalse:[
       
   453         pasteOffset := 0@0.
       
   454         pasteOrigin := self sensor mousePoint.
       
   455         pasteOrigin := device translatePoint:pasteOrigin from:device rootView id to:frame id.
       
   456     ].
       
   457 
       
   458     listHolder disableNotificationsWhileEvaluating:[
   437     listHolder disableNotificationsWhileEvaluating:[
   459         paste do:[:aSpec|
   438         aSpecificationOrList isCollection ifTrue:[
   460             |view|
   439             paste := aSpecificationOrList
   461 
   440         ] ifFalse:[
   462             view := self addSpec:aSpec builder:builder in:frame.
   441             paste := Array with:aSpecificationOrList
   463 
   442         ].
   464             keepLayout ifFalse:[
   443         frame := self singleSelection.
   465                 (frame bounds containsPoint:pasteOrigin) ifFalse:[
   444 
   466                     self moveObject:view to:pasteOffset.
   445         (self canPasteInto:frame) ifFalse:[
   467                 ] ifTrue:[
   446             frame := self
   468                     self moveObject:view to:pasteOrigin + pasteOffset.
   447         ].
       
   448         self setSelection:nil withRedraw:true.
       
   449 
       
   450         newSel  := OrderedCollection new.
       
   451         builder := UIBuilder new.
       
   452 
       
   453         keepLayout ifFalse:[
       
   454             pasteOffset := 0@0.
       
   455             pasteOrigin := self sensor mousePoint.
       
   456             pasteOrigin := device translatePoint:pasteOrigin from:device rootView id to:frame id.
       
   457         ].
       
   458 
       
   459         listHolder disableNotificationsWhileEvaluating:[
       
   460             paste do:[:aSpec|
       
   461                 |view|
       
   462 
       
   463                 view := self addSpec:aSpec builder:builder in:frame.
       
   464 
       
   465                 keepLayout ifFalse:[
       
   466                     (frame bounds containsPoint:pasteOrigin) ifFalse:[
       
   467                         self moveObject:view to:pasteOffset.
       
   468                     ] ifTrue:[
       
   469                         self moveObject:view to:pasteOrigin + pasteOffset.
       
   470                     ].
       
   471                     pasteOffset := pasteOffset + 4
   469                 ].
   472                 ].
   470                 pasteOffset := pasteOffset + 4
   473                 view realize.
       
   474                 newSel add:view.
   471             ].
   475             ].
   472             view realize.
   476         ].
   473             newSel add:view.
   477 
   474         ].
   478         self withinTransaction:#paste objects:newSel do:[
   475     ].
   479             undoHistory addUndoSelector:#undoCreate:
   476 
   480                                withArgs:(newSel collect:[:v|(self propertyOfView:v) identifier])
   477     self withinTransaction:#paste objects:newSel do:[
   481         ].
   478         undoHistory addUndoSelector:#undoCreate:
   482 
   479                            withArgs:(newSel collect:[:v|(self propertyOfView:v) identifier])
   483         newSel size == 1 ifTrue:[
   480     ].
   484             newSel := newSel at:1
   481 
   485         ].
   482     newSel size == 1 ifTrue:[
   486         self realizeAllSubViews.
   483         newSel := newSel at:1
   487         inputView raise.
   484     ].
   488         self select:newSel.
   485     self realizeAllSubViews.
   489         self elementChangedSize:frame.
   486     inputView raise.
   490     ]
   487     self select:newSel.
       
   488     self elementChangedSize:frame.
       
   489 !
   491 !
   490 
   492 
   491 pasteWithLayout
   493 pasteWithLayout
   492     "add the objects in the paste-buffer to the object view; don't change the
   494     "add the objects in the paste-buffer to the object view; don't change the
   493      layout
   495      layout
  1455         listHolder propertyChanged:props.
  1457         listHolder propertyChanged:props.
  1456     ]
  1458     ]
  1457 
  1459 
  1458 ! !
  1460 ! !
  1459 
  1461 
       
  1462 !UIPainterView::ViewProperty class methodsFor:'documentation'!
       
  1463 
       
  1464 version
       
  1465     ^ '$Header$'
       
  1466 ! !
       
  1467 
       
  1468 !UIPainterView::ViewProperty class methodsFor:'instance creation'!
       
  1469 
       
  1470 new
       
  1471     Identifier notNil ifTrue:[Identifier := Identifier + 1]
       
  1472                      ifFalse:[Identifier := 1].
       
  1473 
       
  1474   ^ self basicNew initialize
       
  1475 ! !
       
  1476 
       
  1477 !UIPainterView::ViewProperty methodsFor:'accessing'!
       
  1478 
       
  1479 identifier
       
  1480     "return the unique identifier assigned to property
       
  1481     "
       
  1482     ^ identifier
       
  1483 !
       
  1484 
       
  1485 identifier:anIdentifier
       
  1486     "set the unique identifier assigned to property; called after an restore of
       
  1487      a deleted instance
       
  1488     "
       
  1489     identifier := anIdentifier
       
  1490 !
       
  1491 
       
  1492 spec
       
  1493     "return the value of the instance variable 'spec' (automatically generated)"
       
  1494 
       
  1495     ^ spec!
       
  1496 
       
  1497 spec:something
       
  1498     "set the value of the instance variable 'spec' (automatically generated)"
       
  1499 
       
  1500     spec := something.!
       
  1501 
       
  1502 view
       
  1503     "return the value of the instance variable 'view' (automatically generated)"
       
  1504 
       
  1505     ^ view!
       
  1506 
       
  1507 view:something
       
  1508     "set the value of the instance variable 'view' (automatically generated)"
       
  1509 
       
  1510     view := something.! !
       
  1511 
       
  1512 !UIPainterView::ViewProperty methodsFor:'initialization'!
       
  1513 
       
  1514 initialize
       
  1515     super initialize.
       
  1516     identifier := Identifier
       
  1517 ! !
       
  1518 
       
  1519 !UIPainterView::ViewProperty methodsFor:'misc'!
       
  1520 
       
  1521 extractNumberStartingAt:anIndex
       
  1522     "return the number from the name starting at anIndex or 0.
       
  1523     "
       
  1524     |val|
       
  1525 
       
  1526     val := 0.
       
  1527 
       
  1528     self name from:anIndex do:[:c|
       
  1529         c isDigit ifTrue:[val := val * 10 + c digitValue]
       
  1530                  ifFalse:[^ 0]
       
  1531     ].
       
  1532     ^ val
       
  1533         
       
  1534 ! !
       
  1535 
       
  1536 !UIPainterView::ViewProperty methodsFor:'spec messages'!
       
  1537 
       
  1538 doesNotUnderstand:aMessage
       
  1539     spec notNil ifTrue:[
       
  1540         (spec respondsTo:(aMessage selector)) ifTrue:[^ aMessage sendTo:spec]
       
  1541     ].
       
  1542     ^ nil
       
  1543 !
       
  1544 
       
  1545 layout
       
  1546     spec layout
       
  1547 !
       
  1548 
       
  1549 layout:aLayout
       
  1550     spec layout:aLayout
       
  1551 !
       
  1552 
       
  1553 name
       
  1554     ^ spec name
       
  1555 !
       
  1556 
       
  1557 name:aName
       
  1558     spec name:aName
       
  1559 ! !
       
  1560 
  1460 !UIPainterView::ListHolder class methodsFor:'instance creation'!
  1561 !UIPainterView::ListHolder class methodsFor:'instance creation'!
  1461 
  1562 
  1462 for:aPainter
  1563 for:aPainter
  1463     ^ self new for:aPainter
  1564     ^ self new for:aPainter
  1464 ! !
  1565 ! !
  1788 
  1889 
  1789     self masterElement:masterIndex.
  1890     self masterElement:masterIndex.
  1790     super selectionIndex:aSel
  1891     super selectionIndex:aSel
  1791 ! !
  1892 ! !
  1792 
  1893 
  1793 !UIPainterView::ViewProperty class methodsFor:'documentation'!
  1894 !UIPainterView class methodsFor:'documentation'!
  1794 
  1895 
  1795 version
  1896 version
  1796     ^ '$Header$'
  1897     ^ '$Header$'
  1797 ! !
  1898 ! !
  1798 
       
  1799 !UIPainterView::ViewProperty class methodsFor:'instance creation'!
       
  1800 
       
  1801 new
       
  1802     Identifier notNil ifTrue:[Identifier := Identifier + 1]
       
  1803                      ifFalse:[Identifier := 1].
       
  1804 
       
  1805   ^ self basicNew initialize
       
  1806 ! !
       
  1807 
       
  1808 !UIPainterView::ViewProperty methodsFor:'accessing'!
       
  1809 
       
  1810 identifier
       
  1811     "return the unique identifier assigned to property
       
  1812     "
       
  1813     ^ identifier
       
  1814 !
       
  1815 
       
  1816 identifier:anIdentifier
       
  1817     "set the unique identifier assigned to property; called after an restore of
       
  1818      a deleted instance
       
  1819     "
       
  1820     identifier := anIdentifier
       
  1821 !
       
  1822 
       
  1823 spec
       
  1824     "return the value of the instance variable 'spec' (automatically generated)"
       
  1825 
       
  1826     ^ spec!
       
  1827 
       
  1828 spec:something
       
  1829     "set the value of the instance variable 'spec' (automatically generated)"
       
  1830 
       
  1831     spec := something.!
       
  1832 
       
  1833 view
       
  1834     "return the value of the instance variable 'view' (automatically generated)"
       
  1835 
       
  1836     ^ view!
       
  1837 
       
  1838 view:something
       
  1839     "set the value of the instance variable 'view' (automatically generated)"
       
  1840 
       
  1841     view := something.! !
       
  1842 
       
  1843 !UIPainterView::ViewProperty methodsFor:'initialization'!
       
  1844 
       
  1845 initialize
       
  1846     super initialize.
       
  1847     identifier := Identifier
       
  1848 ! !
       
  1849 
       
  1850 !UIPainterView::ViewProperty methodsFor:'misc'!
       
  1851 
       
  1852 extractNumberStartingAt:anIndex
       
  1853     "return the number from the name starting at anIndex or 0.
       
  1854     "
       
  1855     |val|
       
  1856 
       
  1857     val := 0.
       
  1858 
       
  1859     self name from:anIndex do:[:c|
       
  1860         c isDigit ifTrue:[val := val * 10 + c digitValue]
       
  1861                  ifFalse:[^ 0]
       
  1862     ].
       
  1863     ^ val
       
  1864         
       
  1865 ! !
       
  1866 
       
  1867 !UIPainterView::ViewProperty methodsFor:'spec messages'!
       
  1868 
       
  1869 doesNotUnderstand:aMessage
       
  1870     spec notNil ifTrue:[
       
  1871         (spec respondsTo:(aMessage selector)) ifTrue:[^ aMessage sendTo:spec]
       
  1872     ].
       
  1873     ^ nil
       
  1874 !
       
  1875 
       
  1876 layout
       
  1877     spec layout
       
  1878 !
       
  1879 
       
  1880 layout:aLayout
       
  1881     spec layout:aLayout
       
  1882 !
       
  1883 
       
  1884 name
       
  1885     ^ spec name
       
  1886 !
       
  1887 
       
  1888 name:aName
       
  1889     spec name:aName
       
  1890 ! !
       
  1891 
       
  1892 !UIPainterView class methodsFor:'documentation'!
       
  1893 
       
  1894 version
       
  1895     ^ '$Header$'
       
  1896 ! !