8 be provided or otherwise made available to, or used by, any |
8 be provided or otherwise made available to, or used by, any |
9 other person. No title to or ownership of the software is |
9 other person. No title to or ownership of the software is |
10 hereby transferred. |
10 hereby transferred. |
11 " |
11 " |
12 |
12 |
13 'From Smalltalk/X, Version:3.1.4 on 25-feb-1997 at 2:17:29 pm' ! |
|
14 |
|
15 UIObjectView subclass:#UIPainterView |
13 UIObjectView subclass:#UIPainterView |
16 instanceVariableNames:'fontPanel viewProperties superclassName className methodName |
14 instanceVariableNames:'fontPanel viewProperties superclassName className methodName |
17 categoryName' |
15 categoryName' |
18 classVariableNames:'HandCursor' |
16 classVariableNames:'HandCursor' |
19 poolDictionaries:'' |
17 poolDictionaries:'' |
210 ]. |
208 ]. |
211 self unselect. |
209 self unselect. |
212 ! |
210 ! |
213 |
211 |
214 deleteSelection |
212 deleteSelection |
215 "delete the selection; not into the paste buffer (undo) |
213 "delete the selection; copy the selection into the cut&paste-buffer |
216 " |
214 and open a transaction |
217 |text| |
215 " |
|
216 |text specs| |
218 |
217 |
219 self numberOfSelections ~~ 0 ifTrue:[ |
218 self numberOfSelections ~~ 0 ifTrue:[ |
220 text := self transactionTextFor:selection. |
219 specs := self generateSpecFor:selection. |
|
220 text := self transactionTextFor:selection. |
221 |
221 |
222 undoHistory transaction:#cut text:text do:[ |
222 undoHistory transaction:#cut text:text do:[ |
223 super deleteSelection |
223 super deleteSelection |
224 ]. |
224 ]. |
|
225 self setSelection:specs |
225 ] |
226 ] |
226 ! |
227 ! |
227 |
228 |
228 pasteBuffer |
229 pasteBuffer |
229 "add the objects in the paste-buffer |
230 "add the objects in the paste-buffer to the object view |
230 " |
231 " |
231 |paste builder frame pasteOrigin pasteOffset| |
232 |paste builder frame pasteOrigin pasteOffset| |
232 |
233 |
233 paste := self getSelection. |
234 paste := self getSelection. |
234 |
235 |
235 (self canPaste:paste) ifFalse:[ ^ self]. |
236 (self canPaste:paste) ifFalse:[ ^ self]. |
236 (paste isCollection) ifFalse:[ paste := Array with:paste]. |
237 (paste isCollection) ifFalse:[ paste := Array with:paste]. |
237 |
238 |
238 frame := self singleSelection. |
239 frame := self singleSelection. |
239 |
240 |
240 (self supportsSubComponents:frame) ifFalse:[ |
241 (self canPasteInto:frame) ifFalse:[ |
241 frame := self |
242 frame := self |
242 ]. |
243 ]. |
243 self unselect. |
244 self unselect. |
244 |
245 |
245 builder := UIBuilder new. |
246 builder := UIBuilder new. |
403 ]. |
409 ]. |
404 |
410 |
405 code := ''. |
411 code := ''. |
406 |
412 |
407 viewProperties do:[:aProp | |
413 viewProperties do:[:aProp | |
408 |modelSelector protoSpec thisCode| |
414 |modelSelector menuSelector protoSpec thisCode| |
409 |
415 |
410 (modelSelector := aProp aspectSelector) notNil ifTrue:[ |
416 (modelSelector := aProp aspectSelector) notNil ifTrue:[ |
411 (cls implements:modelSelector asSymbol) ifFalse:[ |
417 (cls implements:modelSelector asSymbol) ifFalse:[ |
412 protoSpec := aProp view specClass basicNew. |
418 protoSpec := aProp view specClass basicNew. |
413 "/ kludge .. |
419 "/ kludge .. |
414 (protoSpec isMemberOf:ActionButtonSpec) ifTrue:[ |
420 (protoSpec isMemberOf:ActionButtonSpec) ifTrue:[ |
415 thisCode := (self generateActionMethodFor:modelSelector spec:protoSpec inClass:cls). |
421 thisCode := (self generateActionMethodFor:modelSelector spec:protoSpec inClass:cls). |
416 ] ifFalse:[ |
422 ] ifFalse:[ |
417 thisCode := (self generateAspectMethodFor:modelSelector spec:protoSpec inClass:cls). |
423 thisCode := (self generateAspectMethodFor:modelSelector spec:protoSpec inClass:cls). |
418 ]. |
424 ]. |
|
425 code := code , thisCode |
|
426 ]. |
|
427 ]. |
|
428 |
|
429 (menuSelector := aProp menuSelector) notNil ifTrue:[ |
|
430 (cls implements:menuSelector asSymbol) ifFalse:[ |
|
431 protoSpec := aProp view specClass basicNew. |
|
432 "/ kludge .. |
|
433 thisCode := (self generateAspectMethodFor:menuSelector spec:protoSpec inClass:cls). |
419 code := code , thisCode |
434 code := code , thisCode |
420 ] |
435 ] |
421 ] |
436 ] |
422 ]. |
437 ]. |
423 ^ code |
438 ^ code |
831 newSpec menu:menuSelector |
846 newSpec menu:menuSelector |
832 ]. |
847 ]. |
833 (labelSelector := props labelSelector) notNil ifTrue:[ |
848 (labelSelector := props labelSelector) notNil ifTrue:[ |
834 newSpec label:labelSelector |
849 newSpec label:labelSelector |
835 ]. |
850 ]. |
836 (tabable := props tabable) notNil ifTrue:[ |
851 (tabable := props tabable) == true ifTrue:[ |
837 newSpec tabable:tabable |
852 newSpec tabable:tabable |
838 ]. |
853 ]. |
839 (defaultable := props defaultable) notNil ifTrue:[ |
854 (defaultable := props defaultable) notNil ifTrue:[ |
840 newSpec defaultable:defaultable |
855 newSpec defaultable:defaultable |
841 ]. |
856 ]. |
887 (aView isKindOf:EditField) ifFalse:[ |
902 (aView isKindOf:EditField) ifFalse:[ |
888 self warn:'select EditFields only !!'. |
903 self warn:'select EditFields only !!'. |
889 ^ self |
904 ^ self |
890 ] |
905 ] |
891 ]. |
906 ]. |
892 self selectionHiddenDo:[ |
907 self withSelectionHiddenDo:[ |
893 group := EnterFieldGroup new. |
908 group := EnterFieldGroup new. |
894 |
909 |
895 props := GroupProperties new. |
910 props := GroupProperties new. |
896 props elementClass:EnterFieldGroup. |
911 props elementClass:EnterFieldGroup. |
897 props group:group. |
912 props group:group. |
920 (aView isKindOf:RadioButton) ifFalse:[ |
935 (aView isKindOf:RadioButton) ifFalse:[ |
921 self warn:'select RadioButtons only !!'. |
936 self warn:'select RadioButtons only !!'. |
922 ^ self |
937 ^ self |
923 ] |
938 ] |
924 ]. |
939 ]. |
925 self selectionHiddenDo:[ |
940 self withSelectionHiddenDo:[ |
926 group := RadioButtonGroup new. |
941 group := RadioButtonGroup new. |
927 |
942 |
928 props := GroupProperties new. |
943 props := GroupProperties new. |
929 props elementClass:RadioButtonGroup. |
944 props elementClass:RadioButtonGroup. |
930 props group:group. |
945 props group:group. |
1156 nil |
1175 nil |
1157 nil |
1176 nil |
1158 ) |
1177 ) |
1159 receiver:self. |
1178 receiver:self. |
1160 |
1179 |
1161 (canPaste and:[self supportsSubComponents:selection]) ifFalse:[ |
1180 (canPaste and:[self canPasteInto:selection]) ifFalse:[ |
1162 menu disable:#pasteBuffer |
1181 menu disable:#pasteBuffer |
1163 ]. |
1182 ]. |
1164 |
1183 |
1165 menu subMenuAt:#arrange put:(self subMenuArrange). |
1184 menu subMenuAt:#arrange put:(self subMenuArrange). |
1166 menu subMenuAt:#dimension put:(self subMenuDimension). |
1185 menu subMenuAt:#dimension put:(self subMenuDimension). |
1167 menu subMenuAt:#align put:(self subMenuAlign). |
1186 menu subMenuAt:#align put:(self subMenuAlign). |
1168 ^ menu |
1187 ^ menu |
|
1188 |
|
1189 |
1169 |
1190 |
1170 ! |
1191 ! |
1171 |
1192 |
1172 subMenuAlign |
1193 subMenuAlign |
1173 "returns submenu alignment |
1194 "returns submenu alignment |
1325 prop isNil ifTrue:[ |
1349 prop isNil ifTrue:[ |
1326 ^ self error:'no such view' |
1350 ^ self error:'no such view' |
1327 ]. |
1351 ]. |
1328 |
1352 |
1329 ((aView respondsTo:#label:) and:[aView label = prop name]) ifTrue:[ |
1353 ((aView respondsTo:#label:) and:[aView label = prop name]) ifTrue:[ |
1330 self selectionHiddenDo:[ |
1354 self withSelectionHiddenDo:[ |
1331 |layout| |
1355 |layout| |
1332 layout := aView geometryLayout copy. |
1356 layout := aView geometryLayout copy. |
1333 aView label:newName. |
1357 aView label:newName. |
1334 aView geometryLayout:layout. |
1358 aView geometryLayout:layout. |
1335 ] |
1359 ] |
1389 |
1413 |
1390 |
1414 |
1391 ! |
1415 ! |
1392 |
1416 |
1393 removeAll |
1417 removeAll |
1394 "remove the argument, anObject" |
1418 "remove all objects and properties |
1395 |
1419 " |
1396 self unselect. |
1420 self unselect. |
|
1421 viewProperties := OrderedCollection new. |
1397 |
1422 |
1398 subViews notNil ifTrue:[ |
1423 subViews notNil ifTrue:[ |
1399 subViews copy do:[:sub | |
1424 subViews copy do:[:sub | |
1400 sub ~~ inputView ifTrue:[ |
1425 sub ~~ inputView ifTrue:[ |
1401 self removeTreeFrom:sub |
1426 self removeTreeFrom:sub |
1402 ] |
1427 ] |
1403 ] |
1428 ] |
1404 ]. |
1429 ]. |
1405 viewProperties := OrderedCollection new. |
|
1406 undoHistory reinitialize. |
1430 undoHistory reinitialize. |
1407 self changed:#tree |
1431 self changed:#tree |
1408 ! |
1432 ! |
1409 |
1433 |
1410 removeObject:anObject |
1434 removeObject:anObject |
1420 self removeTreeFrom:anObject. |
1444 self removeTreeFrom:anObject. |
1421 self changed:#tree |
1445 self changed:#tree |
1422 ! |
1446 ! |
1423 |
1447 |
1424 removeTreeFrom:anObject |
1448 removeTreeFrom:anObject |
1425 "remove the argument, anObject and all of its children |
1449 "remove the argument, anObject and all of its subviews |
1426 " |
1450 " |
1427 |props| |
1451 |props| |
1428 |
1452 |
1429 anObject notNil ifTrue:[ |
1453 anObject notNil ifTrue:[ |
1430 (anObject subViews notNil) ifTrue:[ |
1454 (anObject subViews notNil) ifTrue:[ |
1472 ! ! |
1496 ! ! |
1473 |
1497 |
1474 !UIPainterView methodsFor:'seraching property'! |
1498 !UIPainterView methodsFor:'seraching property'! |
1475 |
1499 |
1476 propertyOf:something |
1500 propertyOf:something |
1477 |
1501 "returns property assigned to group or view |
|
1502 " |
1478 ^ viewProperties detect:[:p| (p view == something or:[p group == something])] |
1503 ^ viewProperties detect:[:p| (p view == something or:[p group == something])] |
1479 ifNone:nil |
1504 ifNone:nil |
1480 |
1505 |
1481 |
1506 |
1482 |
1507 |
1483 |
1508 |
1484 |
1509 |
1485 ! |
1510 ! |
1486 |
1511 |
1487 propertyOfGroup:aGroup |
1512 propertyOfGroup:aGroup |
1488 |
1513 "returns property assigned to group |
|
1514 " |
1489 ^ viewProperties detect:[:p| p group == aGroup] ifNone:nil |
1515 ^ viewProperties detect:[:p| p group == aGroup] ifNone:nil |
1490 ! |
1516 ! |
1491 |
1517 |
1492 propertyOfIdentifier:anId |
1518 propertyOfIdentifier:anId |
1493 |
1519 "returns property assigned to unique identifier |
|
1520 " |
1494 anId notNil ifTrue:[ |
1521 anId notNil ifTrue:[ |
1495 ^ viewProperties detect:[:p| p identifier == anId] ifNone:nil. |
1522 ^ viewProperties detect:[:p| p identifier == anId] ifNone:nil. |
1496 ]. |
1523 ]. |
1497 ^ nil |
1524 ^ nil |
1498 ! |
1525 ! |
1499 |
1526 |
1500 propertyOfName:aString |
1527 propertyOfName:aString |
1501 |
1528 "returns property assigned to name |
|
1529 " |
1502 aString = 'self' ifFalse:[ |
1530 aString = 'self' ifFalse:[ |
1503 ^ viewProperties detect:[:p| p name = aString] ifNone:nil |
1531 ^ viewProperties detect:[:p| p name = aString] ifNone:nil |
1504 ]. |
1532 ]. |
1505 ^ nil |
1533 ^ nil |
1506 ! |
1534 ! |
1507 |
1535 |
1508 propertyOfView:aView |
1536 propertyOfView:aView |
1509 |
1537 "returns property assigned to view |
|
1538 " |
1510 (aView isNil or:[aView == self]) ifFalse:[ |
1539 (aView isNil or:[aView == self]) ifFalse:[ |
1511 ^ viewProperties detect:[:p| p view == aView] ifNone:nil |
1540 ^ viewProperties detect:[:p| p view == aView] ifNone:nil |
1512 ]. |
1541 ]. |
1513 ^ nil |
1542 ^ nil |
1514 ! ! |
1543 ! ! |
1515 |
1544 |
1516 !UIPainterView methodsFor:'testing'! |
1545 !UIPainterView methodsFor:'testing'! |
1517 |
1546 |
1518 isHorizontalResizable:aComponent |
1547 isHorizontalResizable:aComponent |
1519 |
1548 "returns true if instance is horizontal resizeable |
|
1549 " |
1520 (aComponent isKindOf:ScrollBar) ifTrue:[ |
1550 (aComponent isKindOf:ScrollBar) ifTrue:[ |
1521 ^ aComponent orientation == #horizontal |
1551 ^ aComponent orientation == #horizontal |
1522 ]. |
1552 ]. |
1523 (aComponent isKindOf:Scroller) ifTrue:[ |
1553 (aComponent isKindOf:Scroller) ifTrue:[ |
1524 ^ aComponent orientation == #horizontal |
1554 ^ aComponent orientation == #horizontal |
1609 ] |
1642 ] |
1610 |
1643 |
1611 ! |
1644 ! |
1612 |
1645 |
1613 undoLayout:aViewId |
1646 undoLayout:aViewId |
1614 "undo method layout |
1647 "undo method when changing the layout (position or dimension) |
1615 " |
1648 " |
1616 |view layout| |
1649 |view layout extent| |
1617 |
1650 |
1618 (view := self findViewWithId:aViewId) notNil ifTrue:[ |
1651 (view := self findViewWithId:aViewId) notNil ifTrue:[ |
1619 layout := view geometryLayout copy. |
1652 (layout := view geometryLayout copy) isNil ifTrue:[ |
1620 view := nil. |
1653 extent := view extent copy |
1621 |
1654 ]. |
1622 layout notNil ifTrue:[ |
1655 undoHistory addUndoBlock:[ |
1623 undoHistory addUndoBlock:[ |
1656 (view := self findViewWithId:aViewId) notNil ifTrue:[ |
1624 (view := self findViewWithId:aViewId) notNil ifTrue:[ |
1657 layout notNil ifTrue:[view geometryLayout:layout] |
1625 view geometryLayout:layout |
1658 ifFalse:[view extent:extent] |
1626 ] |
|
1627 ] |
1659 ] |
1628 ] ifFalse:[ |
1660 ] |
1629 layout := view pixelOrigin. |
1661 ]. |
1630 |
1662 view := nil |
1631 undoHistory addUndoBlock:[ |
|
1632 (view := self findViewWithId:aViewId) notNil ifTrue:[ |
|
1633 view pixelOrigin:layout |
|
1634 ] |
|
1635 ] |
|
1636 ] |
|
1637 ] |
|
1638 ! |
1663 ! |
1639 |
1664 |
1640 undoLayoutView:aView |
1665 undoLayoutView:aView |
1641 "undo method for changing layout on a view |
1666 "undo method for changing layout on a view |
1642 " |
1667 " |
1649 ] |
1674 ] |
1650 ] |
1675 ] |
1651 ! |
1676 ! |
1652 |
1677 |
1653 undoRemove:aViewId |
1678 undoRemove:aViewId |
1654 "prepare undo method |
1679 "undo method when removing an object |
1655 " |
1680 " |
1656 |view prop spec parentId| |
1681 |view prop spec parentId| |
1657 |
1682 |
1658 (view := self findViewWithId:aViewId) notNil ifTrue:[ |
1683 (view := self findViewWithId:aViewId) notNil ifTrue:[ |
1659 spec := (self generateSpecFor:view) first. |
1684 spec := (self generateSpecFor:view) first. |
1660 view := view superView. |
1685 view := view superView. |
1661 |
1686 |
1662 (self supportsSubComponents:view) ifTrue:[ |
1687 (self canPasteInto:view) ifTrue:[ |
1663 prop := self propertyOfView:view. |
1688 (prop := self propertyOfView:view) notNil ifTrue:[ |
1664 |
|
1665 prop notNil ifTrue:[ |
|
1666 parentId := prop identifier |
1689 parentId := prop identifier |
1667 ] |
1690 ] |
1668 ]. |
1691 ]. |
1669 view := nil. |
1692 view := nil. |
1670 prop := nil. |
1693 prop := nil. |
1718 "update current selected view from specification |
1741 "update current selected view from specification |
1719 " |
1742 " |
1720 |props name builder| |
1743 |props name builder| |
1721 |
1744 |
1722 self singleSelection notNil ifTrue:[ |
1745 self singleSelection notNil ifTrue:[ |
1723 self selectionHiddenDo:[ |
1746 self withSelectionHiddenDo:[ |
1724 self transaction:#specification selectionDo:[:aView| |
1747 self transaction:#specification selectionDo:[:aView| |
1725 builder := UIBuilder new. |
1748 builder := UIBuilder new. |
1726 props := self propertyOfView:aView. |
1749 props := self propertyOfView:aView. |
1727 name := aSpec name. |
1750 name := aSpec name. |
1728 |
1751 |
1740 aSpec name:(aView name). |
1763 aSpec name:(aView name). |
1741 ] |
1764 ] |
1742 ]. |
1765 ]. |
1743 |
1766 |
1744 aSpec setAttributesIn:aView with:builder. |
1767 aSpec setAttributesIn:aView with:builder. |
1745 aView superView sizeChanged:nil. |
1768 self elementChangedSize:aView. |
1746 |
1769 |
1747 props tabable:aSpec tabable. |
1770 props tabable:aSpec tabable. |
1748 props defaultable:aSpec defaultable. |
1771 props defaultable:aSpec defaultable. |
1749 props initiallyInvisible:aSpec initiallyInvisible. |
1772 props initiallyInvisible:aSpec initiallyInvisible. |
1750 props aspectSelector:aSpec modelSelector. |
1773 props aspectSelector:aSpec modelSelector. |
1751 props changeSelector:aSpec changeSelector. |
1774 props changeSelector:aSpec changeSelector. |
1752 props labelSelector:aSpec labelSelector. |
1775 props labelSelector:aSpec labelSelector. |
1753 props menuSelector:aSpec menuSelector. |
1776 props menuSelector:aSpec menuSelector. |
1754 ]. |
1777 ] |
1755 self changed:#tree |
1778 ]. |
1756 ] |
1779 self changed:#tree |
1757 ]. |
1780 ]. |
1758 |
1781 |
1759 ! ! |
1782 ! ! |
1760 |
1783 |
1761 !UIPainterView::ViewProperty class methodsFor:'documentation'! |
1784 !UIPainterView::ViewProperty class methodsFor:'documentation'! |