1859 ) nil |
1644 ) nil |
1860 nil |
1645 nil |
1861 ) |
1646 ) |
1862 ! ! |
1647 ! ! |
1863 |
1648 |
1864 !UIPainter methodsFor:'accessing'! |
1649 !UIPainter methodsFor:'aspects'! |
|
1650 |
|
1651 aspectFor:aKey |
|
1652 "returns the aspect for aKey" |
|
1653 |
|
1654 ^aspects at:aKey ifAbsent:[ super aspectFor:aKey ] |
|
1655 ! |
|
1656 |
|
1657 canChangeOrderInContainer |
|
1658 "returns a boolean value holder which is true if the widget order can be changed |
|
1659 within their container" |
|
1660 |
|
1661 ^ builder booleanValueAspectFor:#canChangeOrderInContainer |
|
1662 ! |
|
1663 |
|
1664 canMoveOrAlignSelection |
|
1665 "returns a boolean value holder which is true in case that any selection exists |
|
1666 and all widgets in the selection can change its layout through to a move or |
|
1667 align operation" |
|
1668 |
|
1669 ^ builder booleanValueAspectFor:#canMoveOrAlignSelection |
|
1670 ! |
|
1671 |
|
1672 canMoveSelection |
|
1673 |
|
1674 ^self canChangeOrderInContainer value or: [ |
|
1675 self canMoveSelectionOutOfContainer value or: [ |
|
1676 self canMoveSelectionOutOfContainer value]] |
|
1677 ! |
|
1678 |
|
1679 canMoveSelectionIntoContainer |
|
1680 "returns a boolean value holder which is true in case that one widget is selected |
|
1681 and can change its container widget to the next element in the list which will have |
|
1682 the same container" |
|
1683 |
|
1684 ^ builder booleanValueAspectFor:#canMoveSelectionIntoContainer |
|
1685 ! |
|
1686 |
|
1687 canMoveSelectionOutOfContainer |
|
1688 "returns a boolean value holder which is true in case that one widget is selected |
|
1689 which is contained within another component" |
|
1690 |
|
1691 ^ builder booleanValueAspectFor:#canMoveSelectionOutOfContainer |
|
1692 ! |
|
1693 |
|
1694 enableChannel |
|
1695 "true if modifications are allowed otherwise running test" |
|
1696 |
|
1697 ^ self painter enableChannel |
|
1698 ! |
|
1699 |
|
1700 galleryShown |
|
1701 "returns a boolean value holder which is set to true if the gallery is shown" |
|
1702 |
|
1703 |holder| |
|
1704 |
|
1705 (holder := builder bindingAt:#galleryShown) isNil ifTrue:[ |
|
1706 builder aspectAt:#galleryShown put:(holder := true asValue). |
|
1707 holder addDependent:self |
|
1708 ]. |
|
1709 ^ holder |
|
1710 |
|
1711 ! |
|
1712 |
|
1713 hasOneSelectionOtherThanCanvas |
|
1714 "returns a value holder which is true in case that one widget is selected |
|
1715 other than the root" |
|
1716 |
|
1717 ^ builder booleanValueAspectFor:#hasOneSelectionOtherThanCanvas |
|
1718 ! |
|
1719 |
|
1720 modifiedChannel |
|
1721 "returns a boolean value holder which is set to true if something is modified |
|
1722 and not accepted" |
|
1723 |
|
1724 ^ builder booleanValueAspectFor:#modifiedChannel |
|
1725 ! |
|
1726 |
|
1727 noteBookView |
|
1728 "returns the notebook view; initialize the tools embedded in the notebook" |
|
1729 |
|
1730 |noteBook channel helpTool layoutTool specTool| |
|
1731 |
|
1732 (noteBook := builder bindingAt:#noteBookView) isNil ifTrue:[ |
|
1733 noteBook := View new. |
|
1734 layoutTool := UILayoutTool new. |
|
1735 helpTool := UIHelpTool new. |
|
1736 helpTool buildFromClass:specClass. |
|
1737 specTool := UISpecificationTool new. |
|
1738 channel := self modifiedChannel. |
|
1739 |
|
1740 layoutTool masterApplication:self. |
|
1741 specTool masterApplication:self. |
|
1742 helpTool masterApplication:self. |
|
1743 |
|
1744 layoutCanvas := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook. |
|
1745 helpCanvas := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook. |
|
1746 specCanvas := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook. |
|
1747 |
|
1748 layoutCanvas client:layoutTool. |
|
1749 helpCanvas client:helpTool. |
|
1750 specTool builder:(specCanvas client:specTool). |
|
1751 |
|
1752 layoutTool masterApplication:self. |
|
1753 specTool masterApplication:self. |
|
1754 helpTool masterApplication:self. |
|
1755 |
|
1756 layoutTool modifiedHolder:channel. |
|
1757 helpTool modifiedHolder:channel. |
|
1758 specTool modifiedHolder:channel. |
|
1759 |
|
1760 builder aspectAt:#noteBookView put:noteBook. |
|
1761 ]. |
|
1762 ^ noteBook |
|
1763 ! |
|
1764 |
|
1765 painterShown |
|
1766 "returns a boolean value holder which is set to true if the painter is shown" |
|
1767 |
|
1768 |holder| |
|
1769 |
|
1770 (holder := builder bindingAt:#painterShown) isNil ifTrue:[ |
|
1771 builder aspectAt:#painterShown put:(holder := true asValue). |
|
1772 holder addDependent:self |
|
1773 ]. |
|
1774 ^ holder |
|
1775 |
|
1776 ! |
|
1777 |
|
1778 tabList |
|
1779 "returns a value holder which keeps a list of the section labels in the notebook" |
|
1780 |
|
1781 |holder| |
|
1782 |
|
1783 (holder := builder bindingAt:#tabList) isNil ifTrue:[ |
|
1784 builder aspectAt:#tabList put:(holder := #(Basics Details Layout) asValue). |
|
1785 ]. |
|
1786 ^ holder |
|
1787 ! |
|
1788 |
|
1789 tabModel |
|
1790 "returns a value holder which keeps the label of the current section in the notebook" |
|
1791 |
|
1792 |holder| |
|
1793 |
|
1794 (holder := builder bindingAt:#tabModel) isNil ifTrue:[ |
|
1795 holder := AspectAdaptor new subject:self; forAspect:#tabSelection. |
|
1796 builder aspectAt:#tabModel put:holder. |
|
1797 ]. |
|
1798 ^ holder |
|
1799 ! |
|
1800 |
|
1801 treeView |
|
1802 "returns the tree view which holds all widget" |
|
1803 |
|
1804 ^ treeView |
|
1805 ! |
|
1806 |
|
1807 valueOfCanPasteWithKeepingLayout |
|
1808 |
|
1809 |holder| |
|
1810 (holder := builder bindingAt:#valueOfCanPasteWithKeepingLayout) isNil ifTrue:[ |
|
1811 builder aspectAt:#valueOfCanPasteWithKeepingLayout put:(holder := false asValue). |
|
1812 ]. |
|
1813 ^ holder |
|
1814 |
|
1815 |
|
1816 |
|
1817 ! ! |
|
1818 |
|
1819 !UIPainter methodsFor:'building editors'! |
|
1820 |
|
1821 openDataSetColumnEditor |
|
1822 "opens a Table Column Editor on current widget" |
|
1823 |
|
1824 |editor| |
|
1825 |
|
1826 (self resolveName:specClass) isNil ifTrue:[ |
|
1827 ^ self information:'No application class defined yet!!' |
|
1828 ]. |
|
1829 |
|
1830 editor := DataSetBuilder new. |
|
1831 editor masterApplication:self. |
|
1832 editor columns:self specTool specification columns fromView:(self layoutTool layoutView). |
|
1833 editor rowClassName:(self specTool specification rowClassName). |
|
1834 editor openModal. |
|
1835 |
|
1836 editor hasChanged ifTrue:[ |
|
1837 self specTool specification columns:(editor columns). |
|
1838 self specTool specification rowClassName:(editor rowClassName). |
|
1839 self modifiedChannel value:true. |
|
1840 ]. |
|
1841 ! |
|
1842 |
|
1843 openEditMenu |
|
1844 "opens a Menu Editor on current widget" |
|
1845 |
|
1846 |cls selectorOrMenu editor selectedSpec| |
|
1847 |
|
1848 (cls := self resolveName:specClass) isNil ifTrue:[ |
|
1849 ^ self warn:'No application class defined yet!!' |
|
1850 ]. |
|
1851 |
|
1852 cls notNil ifTrue:[ |
|
1853 (selectorOrMenu := self specTool specification menuSelector) notNil ifTrue:[ |
|
1854 selectorOrMenu := selectorOrMenu asSymbol |
|
1855 ] ifFalse:[ |
|
1856 "/ cg: q&d hack ... |
|
1857 |
|
1858 (selectedSpec := treeView propertySelected) notNil ifTrue:[ |
|
1859 Object errorSignal handle:[:ex | |
|
1860 selectorOrMenu := nil. |
|
1861 ] do:[ |
|
1862 selectorOrMenu := selectedSpec view asMenu. |
|
1863 ] |
|
1864 ]. |
|
1865 ]. |
|
1866 |
|
1867 editor := MenuEditor new. |
|
1868 editor masterApplication:self. |
|
1869 editor specClass: cls. |
|
1870 editor useHelpTool: self helpTool. |
|
1871 selectorOrMenu class ~~ Menu |
|
1872 ifTrue: [editor openModalOnClass:cls andSelector:selectorOrMenu] |
|
1873 ifFalse: [editor openModalOnMenu:selectorOrMenu]. |
|
1874 self helpTool updateList. |
|
1875 |
|
1876 editor specSelector ~= selectorOrMenu ifTrue:[ |
|
1877 editor hasSaved ifTrue:[ |
|
1878 self specTool specification menuSelector:editor specSelector. |
|
1879 self modifiedChannel value:true. |
|
1880 self accept |
|
1881 ] |
|
1882 ]. |
|
1883 ] |
|
1884 |
|
1885 "Modified: 31.7.1997 / 14:26:13 / cg" |
|
1886 ! |
|
1887 |
|
1888 openHierarchicalListEditor |
|
1889 "opens a Hierarchical List Editor on current widget" |
|
1890 |
|
1891 |selector editor| |
|
1892 |
|
1893 (self resolveName:specClass) isNil ifTrue:[ |
|
1894 ^ self information:'No application class defined yet!!' |
|
1895 ]. |
|
1896 |
|
1897 (selector := self specTool specification hierarchicalList) notNil ifTrue:[ |
|
1898 selector := selector asSymbol |
|
1899 ]. |
|
1900 |
|
1901 editor := HierarchicalListEditor new. |
|
1902 editor masterApplication:self. |
|
1903 editor openModalOnClass:specClass andSelector:selector. |
|
1904 |
|
1905 editor specSelector ~= selector ifTrue:[ |
|
1906 editor hasSaved ifTrue:[ |
|
1907 self specTool specification hierarchicalList:editor specSelector. |
|
1908 self modifiedChannel value:true. |
|
1909 self accept |
|
1910 ] |
|
1911 ] |
|
1912 ! |
|
1913 |
|
1914 openSubSpecGUIPainter |
|
1915 "opens a GUI Painter on the current subspecification" |
|
1916 |
|
1917 |spec cls meta sel| |
|
1918 |
|
1919 spec := self specTool specification. |
|
1920 cls := spec majorKey. |
|
1921 cls isNil ifTrue:[ |
|
1922 cls := specClass. |
|
1923 ]. |
|
1924 (cls isNil or:[(cls := self resolveName:cls) isNil]) ifTrue:[ |
|
1925 spec majorKey isNil ifTrue:[ |
|
1926 ^ self warn:'Cannot find class (no majorKey specified)'. |
|
1927 ]. |
|
1928 ^ self warn:'Cannot find class ', spec majorKey asBoldText, '!!'. |
|
1929 ]. |
|
1930 sel := spec minorKey. |
|
1931 meta := cls class whichClassIncludesSelector:sel. |
|
1932 meta isNil ifTrue:[ |
|
1933 ^ self warn:'Cannot find selector #', (sel ? '') asBoldText, ' in class ', cls name asBoldText, '!!' |
|
1934 ]. |
|
1935 |
|
1936 self class openOnClass:meta soleInstance andSelector:spec minorKey. |
|
1937 |
|
1938 ! |
|
1939 |
|
1940 openTabListEditor |
|
1941 "opens a Tab List Editor on current widget" |
|
1942 |
|
1943 |selector editor| |
|
1944 |
|
1945 (self resolveName:specClass) isNil ifTrue:[ |
|
1946 ^ self information:'No application class defined yet!!' |
|
1947 ]. |
|
1948 |
|
1949 selector := self specTool specification listSelector. |
|
1950 |
|
1951 editor := TabListEditor new. |
|
1952 editor masterApplication:self. |
|
1953 editor openModalOnClass:specClass andSelector:selector. |
|
1954 |
|
1955 editor specSelector ~= selector ifTrue:[ |
|
1956 editor hasSaved ifTrue:[ |
|
1957 self specTool specification listSelector:editor specSelector. |
|
1958 self modifiedChannel value:true. |
|
1959 self accept. |
|
1960 ] |
|
1961 ] |
|
1962 ! ! |
|
1963 |
|
1964 !UIPainter methodsFor:'change & update'! |
|
1965 |
|
1966 layoutChanged |
|
1967 "called by the painter/canvas whenever the layout of the current selected |
|
1968 widget has changed" |
|
1969 |
|
1970 self isModified ifFalse:[ |
|
1971 self layoutTool update. |
|
1972 self modifiedChannel value:false |
|
1973 ] |
|
1974 ! |
|
1975 |
|
1976 propertyChanged |
|
1977 "called by the painter/canvas whenever the property of the current selected |
|
1978 widget has changed" |
|
1979 |
|
1980 |property| |
|
1981 |
|
1982 (property := treeView propertySelected) notNil ifTrue:[ |
|
1983 self specTool specification:(property spec copy). |
|
1984 self setViewInLayoutTool:(property view). |
|
1985 self modifiedChannel value:false |
|
1986 ] ifFalse:[ |
|
1987 self layoutTool layoutView notNil ifTrue:[ |
|
1988 self modifiedChannel value:false. |
|
1989 self treeSelection |
|
1990 ] |
|
1991 ] |
|
1992 ! |
|
1993 |
|
1994 update:something with:aParameter from:someObject |
|
1995 "catches change notifications" |
|
1996 |
|
1997 someObject == treeView model ifTrue:[ |
|
1998 (something == #selection |
|
1999 or:[something == #selectionIndex]) ifTrue:[self treeSelection]. |
|
2000 ^ self |
|
2001 ]. |
|
2002 |
|
2003 self galleryShown == someObject ifTrue:[ |
|
2004 (self galleryShown value) ifTrue:[ |
|
2005 self raiseUIView:(selectionPanel window) |
|
2006 ] ifFalse:[ |
|
2007 self hideUIView:(selectionPanel window) |
|
2008 ]. |
|
2009 ^ self |
|
2010 ]. |
|
2011 |
|
2012 self painterShown == someObject ifTrue:[ |
|
2013 (self painterShown value) ifTrue:[ |
|
2014 self raiseUIView:(self painter topView) |
|
2015 ] ifFalse:[ |
|
2016 self hideUIView:(self painter topView) |
|
2017 ]. |
|
2018 ^ self |
|
2019 ]. |
|
2020 |
|
2021 "Modified: / 29.10.1997 / 17:48:19 / cg" |
|
2022 ! ! |
|
2023 |
|
2024 !UIPainter methodsFor:'event handling'! |
|
2025 |
|
2026 doesNotUnderstand:aMessage |
|
2027 "if does not understand incoming messages, detour them to painter" |
|
2028 |
|
2029 |painter| |
|
2030 |
|
2031 painter := self painter. |
|
2032 |
|
2033 (painter respondsTo:(aMessage selector)) ifTrue:[ |
|
2034 ^ aMessage sendTo:painter |
|
2035 ]. |
|
2036 super doesNotUnderstand:aMessage |
|
2037 |
|
2038 ! ! |
|
2039 |
|
2040 !UIPainter methodsFor:'help'! |
|
2041 |
|
2042 defaultInfoLabel |
|
2043 "returns the default info label" |
|
2044 |
|
2045 specClass isNil ifTrue: [^'No class and selector defined.']. |
|
2046 ^specClass printString, ' >> ', specSelector |
|
2047 ! ! |
|
2048 |
|
2049 !UIPainter methodsFor:'private'! |
|
2050 |
|
2051 askForModification |
|
2052 "asks for window spec modification" |
|
2053 |
|
2054 self askForSectionModification. |
|
2055 |
|
2056 (modified or: [self painter isModified or: [self helpTool modified]]) |
|
2057 ifTrue: |
|
2058 [ |
|
2059 ((YesNoBox title:'Window Spec was modified!!') |
|
2060 noText:'Cancel'; |
|
2061 yesText:'Waste it and proceed'; |
|
2062 showAtPointer; |
|
2063 accepted) ifFalse: [^false]. |
|
2064 modified := false. |
|
2065 self painter resetModification |
|
2066 ]. |
|
2067 ^true |
|
2068 ! |
|
2069 |
|
2070 askForSectionModification |
|
2071 "asks for section modification in the notebook" |
|
2072 |
|
2073 self isModified ifTrue:[ |
|
2074 (self confirm:'Accept modifications in section ' , tabSelection printString asBoldText, '?') ifTrue:[ |
|
2075 self accept |
|
2076 ] ifFalse: [ |
|
2077 self cancel |
|
2078 ] |
|
2079 ] |
|
2080 ! |
|
2081 |
|
2082 checkClassAndSelector |
|
2083 "checks for class & superclass" |
|
2084 |
|
2085 |superclass cls| |
|
2086 |
|
2087 specClass isNil ifTrue:[^ false]. |
|
2088 |
|
2089 cls := self resolveName:specClass. |
|
2090 |
|
2091 cls isNil ifTrue:[ |
|
2092 superclass := self resolveName:specSuperclass. |
|
2093 |
|
2094 superclass isNil ifTrue:[ |
|
2095 self warn:'No class named ' , specSuperclass , ' exists!!'. |
|
2096 ^ false. |
|
2097 ]. |
|
2098 (self confirm:'Create class ' , specClass asBoldText, '?') ifTrue:[ |
|
2099 superclass subclass:(specClass asSymbol) |
|
2100 instanceVariableNames:'' |
|
2101 classVariableNames:'' |
|
2102 poolDictionaries:'' |
|
2103 category:'Applications'. |
|
2104 ^ true. |
|
2105 ]. |
|
2106 ^ false. |
|
2107 ]. |
|
2108 cls isBehavior ifFalse:[ |
|
2109 self warn:'A global named ' , specClass , ' exists, but it is no class.'. |
|
2110 ^ false. |
|
2111 ]. |
|
2112 |
|
2113 specSuperclass isBehavior ifFalse:[ |
|
2114 specSuperclass isEmpty ifFalse:[ |
|
2115 superclass := self resolveName:specSuperclass |
|
2116 ] ifTrue:[ |
|
2117 specSuperclass := nil. |
|
2118 ] |
|
2119 ] ifTrue:[ |
|
2120 superclass := specSuperclass |
|
2121 ]. |
|
2122 |
|
2123 specSuperclass notNil ifTrue:[ |
|
2124 superclass isNil ifTrue:[ |
|
2125 self warn:'No class named ' , specSuperclass , ' exists!!'. |
|
2126 ^ false. |
|
2127 ]. |
|
2128 |
|
2129 (cls isSubclassOf:superclass) ifFalse:[ |
|
2130 self information:('A global named ' , specClass , ' exists,\' , |
|
2131 'but is not a subclass of ' , superclass name , '.\\' , |
|
2132 'Check and try again if that is not what you want.') withCRs. |
|
2133 ] |
|
2134 ]. |
|
2135 |
|
2136 superclass isNil ifTrue:[ |
|
2137 cls notNil ifTrue:[ |
|
2138 specSuperclass := cls superclass name |
|
2139 ] |
|
2140 ]. |
|
2141 |
|
2142 ^ true |
|
2143 |
|
2144 "Modified: 12.8.1997 / 23:39:10 / cg" |
|
2145 ! |
|
2146 |
|
2147 hideUIView:aView |
|
2148 "hides the view which is an application or top view" |
|
2149 |
|
2150 aView beIndependent. |
|
2151 aView unmap. |
|
2152 ! |
|
2153 |
|
2154 raiseTabView |
|
2155 |
|
2156 self isLayoutToolSelected ifTrue:[ |
|
2157 layoutCanvas raise |
|
2158 ] ifFalse:[ |
|
2159 self isHelpToolSelected ifTrue:[ |
|
2160 helpCanvas raise |
|
2161 ] ifFalse:[ |
|
2162 self specTool selection:tabSelection. |
|
2163 specCanvas raise |
|
2164 ] |
|
2165 ] |
|
2166 ! |
|
2167 |
|
2168 raiseUIView:aView |
|
2169 "raise the view which is an application or top view" |
|
2170 |
|
2171 aView map. |
|
2172 aView bePartner. |
|
2173 ! |
|
2174 |
|
2175 resourceMessage: aString |
|
2176 "reads the specClass and the specSelector by evaluating aString" |
|
2177 |
|
2178 (aString notNil and: [self askForModification]) |
|
2179 ifTrue: |
|
2180 [ |
|
2181 |msg cls sel| |
|
2182 msg := aString asCollectionOfWords. |
|
2183 (msg size == 2 and: |
|
2184 [(cls := self resolveName:(msg at:1)) notNil]) |
|
2185 ifTrue: |
|
2186 [ |
|
2187 self specClass:cls. |
|
2188 specSuperclass := cls superclass name. |
|
2189 specSelector := (msg at: 2) asSymbol. |
|
2190 ^true |
|
2191 ] |
|
2192 ]. |
|
2193 ^false |
|
2194 ! |
|
2195 |
|
2196 setClass:cls selector:selector |
|
2197 "sets the specClass and the specSelector under which the window spec should be saved" |
|
2198 |
|
2199 |clsName superClassName| |
|
2200 |
|
2201 clsName := cls name. |
|
2202 superClassName := cls superclass name. |
|
2203 |
|
2204 (self aspectFor:#classNameChannel) value:clsName. |
|
2205 (self aspectFor:#methodNameChannel) value:(selector ? ''). |
|
2206 (self aspectFor:#superclassNameChannel) value:superClassName. |
|
2207 |
|
2208 self painter |
|
2209 className:clsName |
|
2210 superclassName:superClassName |
|
2211 selector:(selector ? ''). |
|
2212 |
|
2213 self specClass:clsName. |
|
2214 specSelector := (selector ? ''). |
|
2215 specSuperclass := superClassName. |
|
2216 |
|
2217 specClass notNil & selector notNil ifTrue:[ |
|
2218 self addToHistory: (specClass, ' ', specSelector) -> #loadFromMessage:. |
|
2219 self updateInfoLabel |
|
2220 ]. |
|
2221 |
|
2222 "Modified: / 5.2.1998 / 09:44:58 / stefan" |
|
2223 ! |
|
2224 |
|
2225 setViewInLayoutTool:aView |
|
2226 "sets view for layout tool" |
|
2227 |
|
2228 |type| |
|
2229 |
|
2230 self painter topView == aView ifTrue:[ |
|
2231 type := #Extent |
|
2232 ]. |
|
2233 self layoutTool layoutView:aView type:type |
|
2234 |
|
2235 ! |
|
2236 |
|
2237 specClass:aClass |
|
2238 "sets the specClass and updates the Help Tool" |
|
2239 |
|
2240 specClass := aClass isBehavior ifTrue:[aClass name] |
|
2241 ifFalse:[aClass]. |
|
2242 |
|
2243 self helpTool buildFromClass:specClass. |
|
2244 self helpTool updateList. |
|
2245 self modifiedChannel value: false. |
|
2246 |
|
2247 ! ! |
|
2248 |
|
2249 !UIPainter methodsFor:'private tools'! |
|
2250 |
|
2251 helpTool |
|
2252 "returns the help tool" |
|
2253 |
|
2254 helpCanvas isNil ifTrue:[ |
|
2255 self noteBookView |
|
2256 ]. |
|
2257 ^ helpCanvas application |
|
2258 ! |
|
2259 |
|
2260 layoutTool |
|
2261 "returns the layout tool" |
|
2262 |
|
2263 layoutCanvas isNil ifTrue:[ |
|
2264 self noteBookView |
|
2265 ]. |
|
2266 ^ layoutCanvas application |
|
2267 ! |
|
2268 |
|
2269 painter |
|
2270 "returns the canvas view" |
|
2271 |
|
2272 ^ treeView canvas |
|
2273 ! |
|
2274 |
|
2275 specTool |
|
2276 "returns the spec tool" |
|
2277 |
|
2278 specCanvas isNil ifTrue:[ |
|
2279 self noteBookView |
|
2280 ]. |
|
2281 ^ specCanvas application |
|
2282 ! ! |
|
2283 |
|
2284 !UIPainter methodsFor:'queries'! |
|
2285 |
|
2286 hasSpecClass |
|
2287 "answers whether an application class is defined" |
|
2288 |
|
2289 ^ (self resolveName:specClass) notNil |
|
2290 ! |
|
2291 |
|
2292 hasSpecClassAndSelector |
|
2293 "answers whether an application class and a selector under which |
|
2294 the window spec is stored is defined" |
|
2295 |
|
2296 specSelector size > 1 ifTrue:[ |
|
2297 ^ self hasSpecClass |
|
2298 ]. |
|
2299 ^ false |
|
2300 ! |
|
2301 |
|
2302 isHelpToolSelected |
|
2303 "answers whether the current selected section in the noteBook is the Help Tool" |
|
2304 |
|
2305 ^ tabSelection = UIHelpTool label |
|
2306 ! |
|
2307 |
|
2308 isLayoutToolSelected |
|
2309 "answers whether the current selected section in the noteBook is the Layout Tool" |
|
2310 |
|
2311 ^ tabSelection = UILayoutTool label |
|
2312 ! |
|
2313 |
|
2314 isModified |
|
2315 "answers whether the current window spec or a layout is modified" |
|
2316 |
|
2317 ^ self modifiedChannel value |
|
2318 ! |
|
2319 |
|
2320 isPainterEnabled |
|
2321 "answers whether I am running in test mode" |
|
2322 |
|
2323 ^ self painter enabled |
|
2324 ! ! |
|
2325 |
|
2326 !UIPainter methodsFor:'selection'! |
|
2327 |
|
2328 tabSelection |
|
2329 "returns the label of the current section in the notebook" |
|
2330 |
|
2331 ^ tabSelection |
|
2332 ! |
|
2333 |
|
2334 tabSelection:something |
|
2335 "called whenever the section of the notebook has changed" |
|
2336 |
|
2337 |whatToDo| |
|
2338 |
|
2339 (something isNil or:[tabSelection = something]) ifTrue:[ |
|
2340 ^ self |
|
2341 ]. |
|
2342 |
|
2343 self isModified ifTrue:[ |
|
2344 whatToDo := DialogBox |
|
2345 confirmWithCancel:'Accept modifications in section ' , tabSelection printString asBoldText, '?' |
|
2346 labels:#('Cancel' 'Ignore' 'Accept') |
|
2347 default:3. |
|
2348 whatToDo isNil ifTrue:[^self]. |
|
2349 whatToDo == true ifTrue:[ |
|
2350 self accept |
|
2351 ] ifFalse:[ |
|
2352 self cancel |
|
2353 ] |
|
2354 ]. |
|
2355 |
|
2356 tabSelection := something. |
|
2357 self raiseTabView. |
|
2358 self cancel. |
|
2359 |
|
2360 ! |
|
2361 |
|
2362 treeSelection |
|
2363 "called whenever the selection of the treeview has changed" |
|
2364 |
|
2365 |view list spec slices size property tabComponent canCutOrCopy canPaste clipboard sel| |
|
2366 |
|
2367 self isModified ifTrue:[ |
|
2368 (self confirm:'Accept modifications in section ' , tabSelection printString asBoldText, '?') ifTrue:[ |
|
2369 self accept |
|
2370 ] |
|
2371 ]. |
|
2372 |
|
2373 self canMoveOrAlignSelection value:(treeView canMoveOrAlignSelection). |
|
2374 self canChangeOrderInContainer value:(treeView canChangeOrderInContainer). |
|
2375 self canMoveSelectionIntoContainer value:(treeView canMoveSelectionIntoContainer). |
|
2376 self canMoveSelectionOutOfContainer value:(treeView canMoveSelectionOutOfContainer). |
|
2377 self hasOneSelectionOtherThanCanvas value:(treeView hasOneSelectionOtherThanCanvas). |
|
2378 |
|
2379 treeView isCanvasSelected ifTrue:[ |
|
2380 spec := treeView canvasSpec. |
|
2381 view := self painter topView. |
|
2382 ] ifFalse:[ |
|
2383 (property := treeView propertySelected) notNil ifTrue:[ |
|
2384 treeView canResizeSelectedWidget ifTrue:[ |
|
2385 view := property view. |
|
2386 ]. |
|
2387 spec := property spec copy. |
|
2388 ] |
|
2389 ]. |
|
2390 tabComponent := builder componentAt:#noteBook. |
|
2391 self setViewInLayoutTool:view. |
|
2392 self specTool specification:spec. |
|
2393 |
|
2394 spec notNil ifTrue:[ |
|
2395 self helpTool helpKey:(spec activeHelpKey). |
|
2396 slices := spec class slices. |
|
2397 size := slices size. |
|
2398 |
|
2399 view notNil ifTrue:[ |
|
2400 self treeView isCanvasSelected |
|
2401 ifFalse: |
|
2402 [ |
|
2403 list := Array new:(size + 2). |
|
2404 list at:(size + 2) put:(UILayoutTool label). |
|
2405 ] |
|
2406 ifTrue: |
|
2407 [ |
|
2408 list := Array new:(size + 1). |
|
2409 list at:(size + 1) put:(UILayoutTool label). |
|
2410 ]. |
|
2411 ] ifFalse:[ |
|
2412 list := Array new:(size + 1). |
|
2413 ]. |
|
2414 |
|
2415 1 to:size do:[:i| list at:i put:((slices at:i) first asString)]. |
|
2416 self treeView isCanvasSelected ifFalse: [list at:(size + 1) put:(UIHelpTool label)]. |
|
2417 |
|
2418 self tabList value:list. |
|
2419 self showHelp:spec class name for:self. |
|
2420 tabComponent enabled:true. |
|
2421 |
|
2422 (tabSelection := tabComponent selection) isNil ifTrue:[ |
|
2423 tabComponent setSelection:(tabSelection := list first) |
|
2424 ]. |
|
2425 self raiseTabView |
|
2426 ] ifFalse:[ |
|
2427 self helpTool helpKey:nil. |
|
2428 tabComponent enabled:false. |
|
2429 self defaultInfoLabel. |
|
2430 ]. |
|
2431 self modifiedChannel value:false. |
|
2432 |
|
2433 treeView notNil |
|
2434 ifTrue: |
|
2435 [ |
|
2436 canCutOrCopy := treeView selection size >= 1 and:[treeView selection first ~~ 1]. |
|
2437 clipboard := self getSelection. |
|
2438 |
|
2439 clipboard isCollection ifTrue:[clipboard notEmpty ifTrue:[sel := clipboard first]] |
|
2440 ifFalse:[sel := clipboard]. |
|
2441 |
|
2442 canPaste := (sel isKindOf:UISpecification) and: |
|
2443 [treeView selection size = 1 |
|
2444 and:[treeView selection first == 1 |
|
2445 or: [self canPasteInto: treeView selectedNode contents view]]] |
|
2446 ]. |
|
2447 |
|
2448 self valueOfCanCut value: canCutOrCopy. |
|
2449 self valueOfCanCopy value: canCutOrCopy. |
|
2450 self valueOfCanPaste value: canPaste. |
|
2451 self valueOfCanPasteWithKeepingLayout value: (canPaste & self canKeepLayoutInSelection). |
|
2452 |
|
2453 |
|
2454 ! ! |
|
2455 |
|
2456 !UIPainter methodsFor:'settings'! |
1865 |
2457 |
1866 redefineAspectMethods |
2458 redefineAspectMethods |
1867 "redefine methods yes or no. If a method is defined in super class |
2459 "redefine methods yes or no. If a method is defined in super class |
1868 should the message be reinstalled ? |
2460 should the message be reinstalled ? |
1869 " |
2461 " |
1877 should the message be reinstalled ? |
2469 should the message be reinstalled ? |
1878 " |
2470 " |
1879 UIPainterView redefineAspectMethods:aBoolean |
2471 UIPainterView redefineAspectMethods:aBoolean |
1880 |
2472 |
1881 |
2473 |
1882 ! |
|
1883 |
|
1884 transcriptHelp |
|
1885 "answer whether the help transcript is turned on/off |
|
1886 " |
|
1887 ^self class settings at: #TranscriptHelp |
|
1888 ifAbsent: [self class settings at: #TranscriptHelp put: false] |
|
1889 ! |
|
1890 |
|
1891 transcriptHelp:aBoolean |
|
1892 "turn on/off the help transcript |
|
1893 " |
|
1894 self class settings at: #TranscriptHelp put: aBoolean |
|
1895 |
|
1896 ! ! |
2474 ! ! |
1897 |
2475 |
1898 !UIPainter methodsFor:'actions'! |
2476 !UIPainter methodsFor:'startup / release'! |
|
2477 |
|
2478 closeRequest |
|
2479 "close request" |
|
2480 |
|
2481 self askForModification ifFalse:[^self]. |
|
2482 |
|
2483 treeView model removeDependent:self. |
|
2484 self painter release. |
|
2485 |
|
2486 selectionPanel notNil ifTrue:[ |
|
2487 selectionPanel masterApplication:nil. |
|
2488 selectionPanel closeRequest |
|
2489 ]. |
|
2490 selectionPanel := nil. |
|
2491 treeView := nil. |
|
2492 |
|
2493 super closeRequest. |
|
2494 |
|
2495 ! |
|
2496 |
|
2497 closeRequestFor:aTopView |
|
2498 "handles a close request for a specific view" |
|
2499 |
|
2500 |topView| |
|
2501 |
|
2502 (topView := self window) == aTopView ifTrue:[ |
|
2503 super closeRequestFor:aTopView |
|
2504 ] ifFalse:[ |
|
2505 aTopView = selectionPanel window ifTrue:[ |
|
2506 self galleryShown value:false |
|
2507 ] ifFalse:[ |
|
2508 aTopView == (self painter topView) ifTrue:[ |
|
2509 self painterShown value:false |
|
2510 ] ifFalse:[ |
|
2511 aTopView closeRequest |
|
2512 ] |
|
2513 ]. |
|
2514 topView raise. |
|
2515 ]. |
|
2516 ! |
|
2517 |
|
2518 loadFromMessage: aMessage |
|
2519 "loads a window spec by evaluating aMessage" |
|
2520 |
|
2521 ((aMessage size > 0) and: [self askForModification]) |
|
2522 ifTrue: |
|
2523 [ |
|
2524 |readStream aClass aSelector| |
|
2525 readStream := aMessage readStream. |
|
2526 (aClass := Smalltalk at: (readStream upTo: $ ) asSymbol) notNil |
|
2527 ifTrue: |
|
2528 [ |
|
2529 aSelector := readStream upToEnd asSymbol. |
|
2530 self setClass: aClass selector: aSelector. |
|
2531 (aClass respondsTo:aSelector) |
|
2532 ifTrue: |
|
2533 [ |
|
2534 self painter setupFromSpec:(aClass perform:aSelector). |
|
2535 treeView selection: #(1). |
|
2536 ] |
|
2537 ] |
|
2538 ] |
|
2539 ! |
|
2540 |
|
2541 openInterface:aSymbol |
|
2542 "opens the interface on the selector aSymbol" |
|
2543 |
|
2544 |cls painterView painter topView| |
|
2545 |
|
2546 modified := false. |
|
2547 |
|
2548 aspects := IdentityDictionary new. |
|
2549 |
|
2550 aspects at:#classNameChannel put:( |
|
2551 (specClass notNil ifTrue:[specClass] |
|
2552 ifFalse:['NewApplication']) asValue |
|
2553 ). |
|
2554 specSuperclass isNil ifTrue:[ |
|
2555 specClass notNil ifTrue:[ |
|
2556 (cls := self resolveName:specClass) notNil ifTrue:[ |
|
2557 specSuperclass := cls superclass name. |
|
2558 ] |
|
2559 ] |
|
2560 ]. |
|
2561 aspects at:#superclassNameChannel put:( |
|
2562 (specSuperclass notNil ifTrue:[specSuperclass] |
|
2563 ifFalse:['ApplicationModel']) asValue |
|
2564 ). |
|
2565 aspects at:#superclassNameDefaults put:#('ApplicationModel' 'SimpleDialog') asValue. |
|
2566 aspects at:#methodNameChannel put:( |
|
2567 (specSelector notNil ifTrue:[specSelector asValue] |
|
2568 ifFalse:[#windowSpec]) asValue |
|
2569 ). |
|
2570 |
|
2571 treeView := TreeView new. |
|
2572 painterView := StandardSystemView new. |
|
2573 painterView name: self class defaultNameOfCanvas. |
|
2574 painterView label: self class defaultNameOfCanvas. |
|
2575 painterView extent:300@300. |
|
2576 |
|
2577 painter := UIPainterView in:painterView. |
|
2578 painter layout:(0.0 @ 0.0 corner:1.0 @ 1.0) asLayout. |
|
2579 |
|
2580 treeView := treeView canvas:painter. |
|
2581 painter treeView:treeView. |
|
2582 treeView model addDependent:self. |
|
2583 |
|
2584 super openInterface:aSymbol. |
|
2585 |
|
2586 topView := self window. |
|
2587 |
|
2588 topView label:'GUI Painter'. |
|
2589 |
|
2590 "take care for those who do close very quickly after launching" |
|
2591 Object errorSignal handle: [:ex|] do: |
|
2592 [ |
|
2593 painterView openInGroup:(topView windowGroup). |
|
2594 painterView open. |
|
2595 painterView application:self. |
|
2596 |
|
2597 painterView application:self. |
|
2598 selectionPanel := UISelectionPanel new. |
|
2599 selectionPanel allButOpenInterface:#windowSpec. |
|
2600 selectionPanel window openInGroup:(topView windowGroup). |
|
2601 |
|
2602 selectionPanel openWindow. |
|
2603 selectionPanel masterApplication:self. |
|
2604 |
|
2605 topView iconLabel:'GUI Painter'. |
|
2606 topView icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100). |
|
2607 |
|
2608 painterView iconLabel:'GUI Painter'. |
|
2609 painterView icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100). |
|
2610 |
|
2611 topView bePartner. |
|
2612 painterView bePartner. |
|
2613 selectionPanel window bePartner. |
|
2614 |
|
2615 selectionPanel window iconLabel:'GUI Painter'. |
|
2616 selectionPanel window icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100). |
|
2617 ] |
|
2618 ! |
|
2619 |
|
2620 openOnClass:aClass |
|
2621 "opens the GUI Painter on aClass and #windowSpec" |
|
2622 |
|
2623 self openOnClass:aClass andSelector:#windowSpec |
|
2624 ! |
|
2625 |
|
2626 openOnClass:aClass andSelector:aSelector |
|
2627 "opens the GUI Painter on aClass and aSelector" |
|
2628 |
|
2629 |painter| |
|
2630 |
|
2631 aClass isNil ifTrue:[ |
|
2632 (self confirm:'No class given to the GUI Painter (class was probably renamed?)\\Open anyway (to create a new window spec) ?' withCRs) |
|
2633 ifFalse:[^ nil]. |
|
2634 ]. |
|
2635 |
|
2636 self openInterface. |
|
2637 |
|
2638 "take care for those who do close very quickly after launching" |
|
2639 Object errorSignal handle: [:ex|] do: |
|
2640 [ |
|
2641 aClass notNil ifTrue:[ |
|
2642 painter := self painter. |
|
2643 self setClass:aClass selector:aSelector. |
|
2644 (aClass respondsTo:aSelector) ifTrue:[ |
|
2645 painter setupFromSpec:(aClass perform:aSelector). |
|
2646 treeView selection: #(1) |
|
2647 ] |
|
2648 ] |
|
2649 ] |
|
2650 ! |
|
2651 |
|
2652 postOpenWith: aBuilder |
|
2653 "sets the root of the tree view as first selection; |
|
2654 sets the grid parameters, if defined" |
|
2655 |
|
2656 |painter settings gridPara hspace vspace| |
|
2657 |
|
2658 super postOpenWith: aBuilder. |
|
2659 |
|
2660 "take care for those who do close very quickly after launching" |
|
2661 Object errorSignal handle: [:ex|] do: |
|
2662 [ |
|
2663 treeView selection: (Array with: 1). |
|
2664 |
|
2665 painter := self painter. |
|
2666 settings := self class settings. |
|
2667 gridPara := painter gridParameters copy. |
|
2668 hspace := settings at: #HGridSpace ifAbsent: [10]. |
|
2669 vspace := settings at: #VGridSpace ifAbsent: [10]. |
|
2670 gridPara at:1 put:hspace; at:2 put:vspace; at:5 put:hspace; at:6 put:vspace. |
|
2671 painter gridParameters:gridPara. |
|
2672 painter gridShown: (settings at: #GridShown ifAbsent: [false]). |
|
2673 painter gridAlign: (settings at: #GridAlign ifAbsent: [false]). |
|
2674 painter clear. |
|
2675 ] |
|
2676 |
|
2677 ! ! |
|
2678 |
|
2679 !UIPainter methodsFor:'user actions'! |
1899 |
2680 |
1900 accept |
2681 accept |
1901 "accept changes done to the specification. The component assigned to the |
2682 "accepts all modifications done to the attributes of the current section" |
1902 specification will change immediately dependant on the attributes derived |
2683 |
1903 from the specification. |
2684 |painter layout spec prop key layoutTool| |
1904 " |
2685 |
1905 |layout spec prop key layoutTool| |
2686 painter := self painter. |
1906 |
2687 |
1907 self isLayoutToolSelected ifTrue:[ |
2688 self isLayoutToolSelected ifTrue:[ |
1908 layoutTool := self layoutTool. |
2689 layoutTool := self layoutTool. |
1909 |
2690 |
1910 (layout := layoutTool layout) notNil ifTrue:[ |
2691 (layout := layoutTool layout) notNil ifTrue:[ |
1911 layoutTool layoutType == #Extent ifTrue:[ |
2692 layoutTool layoutType == #Extent ifTrue:[ |
1912 layoutTool layoutView == self painter topView ifTrue:[ |
2693 layoutTool layoutView == painter topView ifTrue:[ |
1913 layoutTool layoutView extent:layout |
2694 layoutTool layoutView extent:layout |
1914 ] ifFalse:[ |
2695 ] ifFalse:[ |
1915 self painter setExtent:layout |
2696 painter setExtent:layout |
1916 ] |
2697 ] |
1917 ] ifFalse:[ |
2698 ] ifFalse:[ |
1918 self painter setLayout:layout |
2699 painter setLayout:layout |
1919 ] |
2700 ] |
1920 ] |
2701 ] |
1921 ] ifFalse:[ |
2702 ] ifFalse:[ |
1922 spec := self specTool specification. |
2703 spec := self specTool specification. |
1923 |
2704 |
1993 self modifiedChannel value:false. |
2776 self modifiedChannel value:false. |
1994 modified := false |
2777 modified := false |
1995 ] |
2778 ] |
1996 ! |
2779 ! |
1997 |
2780 |
1998 inspectSpec |
|
1999 "inspect the selected specification" |
|
2000 |
|
2001 |spec| |
|
2002 |
|
2003 (spec := self specForSelection) isNil ifTrue:[ |
|
2004 treeView isCanvasSelected ifTrue:[ |
|
2005 spec := treeView canvasSpec. |
|
2006 ] |
|
2007 ]. |
|
2008 spec notNil ifTrue:[ |
|
2009 spec inspect |
|
2010 ] |
|
2011 |
|
2012 |
|
2013 ! |
|
2014 |
|
2015 inspectView |
|
2016 "inspect the view of the selected specification" |
|
2017 |
|
2018 |selection view| |
|
2019 |
|
2020 ((selection := self painter selection) isCollection and: [selection size >= 1]) ifTrue:[ |
|
2021 selection first inspect |
|
2022 ] ifFalse: [ |
|
2023 selection inspect |
|
2024 ] |
|
2025 |
|
2026 ! |
|
2027 |
|
2028 moveSelectionDown |
|
2029 "move selected components down |
|
2030 " |
|
2031 self painter moveSelectionDown |
|
2032 ! |
|
2033 |
|
2034 moveSelectionLeft |
|
2035 "move selected components left |
|
2036 " |
|
2037 self painter moveSelectionLeft |
|
2038 |
|
2039 ! |
|
2040 |
|
2041 moveSelectionRight |
|
2042 "move selected components right |
|
2043 " |
|
2044 self painter moveSelectionRight |
|
2045 |
|
2046 ! |
|
2047 |
|
2048 moveSelectionUp |
|
2049 "move selected components up |
|
2050 " |
|
2051 self painter moveSelectionUp |
|
2052 |
|
2053 ! |
|
2054 |
|
2055 openWidgetDocumentation |
|
2056 "open documentation for the selected widget" |
|
2057 |
|
2058 |spec document| |
|
2059 |
|
2060 (spec := self specForSelection) isNil ifTrue:[ |
|
2061 treeView isCanvasSelected ifTrue:[ |
|
2062 spec := nil |
|
2063 ] |
|
2064 ]. |
|
2065 spec notNil ifTrue:[ |
|
2066 document := 'tools/uipainter/Widgets/', spec userFriendlyName,'.html' |
|
2067 ] ifFalse: [ |
|
2068 document := 'tools/uipainter/TOP.html#THEWIDGETSANDHOWDOTHEYWORK' |
|
2069 ]. |
|
2070 HTMLDocumentView openFullOnDocumentationFile: document |
|
2071 |
|
2072 |
|
2073 ! ! |
|
2074 |
|
2075 !UIPainter methodsFor:'aspects'! |
|
2076 |
|
2077 aspectFor:aKey |
|
2078 "aspect for a key |
|
2079 " |
|
2080 ^ aspects at:aKey ifAbsent:[ super aspectFor:aKey ] |
|
2081 ! |
|
2082 |
|
2083 canChangeOrderInContainer |
|
2084 "returns a boolean value holder which is true if the component order can be changed within their container. |
|
2085 " |
|
2086 ^ builder booleanValueAspectFor:#canChangeOrderInContainer |
|
2087 ! |
|
2088 |
|
2089 canMoveOrAlignSelection |
|
2090 "returns a boolean value holder which is true in case that any selection exists |
|
2091 and all widgets in the selection can change its layout through to a move or |
|
2092 align operation |
|
2093 " |
|
2094 ^ builder booleanValueAspectFor:#canMoveOrAlignSelection |
|
2095 ! |
|
2096 |
|
2097 canMoveSelection |
|
2098 |
|
2099 ^self canChangeOrderInContainer value | |
|
2100 self canMoveSelectionOutOfContainer value | |
|
2101 self canMoveSelectionOutOfContainer value |
|
2102 ! |
|
2103 |
|
2104 canMoveSelectionIntoContainer |
|
2105 "returns a boolean value holder which is true in case that one component is selected |
|
2106 and can change its container widget to the next element in the list which will have |
|
2107 the same container. |
|
2108 " |
|
2109 ^ builder booleanValueAspectFor:#canMoveSelectionIntoContainer |
|
2110 ! |
|
2111 |
|
2112 canMoveSelectionOutOfContainer |
|
2113 "returns a boolean value holder which is true in case that one component is selected |
|
2114 which is contained within another component |
|
2115 " |
|
2116 ^ builder booleanValueAspectFor:#canMoveSelectionOutOfContainer |
|
2117 ! |
|
2118 |
|
2119 enableChannel |
|
2120 "true if modifications are allowed otherwise running test |
|
2121 " |
|
2122 ^ self painter enableChannel |
|
2123 ! |
|
2124 |
|
2125 galleryShown |
|
2126 "returns a boolean value holder which is set to true if the gallery is shown |
|
2127 " |
|
2128 |holder| |
|
2129 |
|
2130 (holder := builder bindingAt:#galleryShown) isNil ifTrue:[ |
|
2131 builder aspectAt:#galleryShown put:(holder := true asValue). |
|
2132 holder addDependent:self |
|
2133 ]. |
|
2134 ^ holder |
|
2135 |
|
2136 ! |
|
2137 |
|
2138 hasOneSelectionOtherThanCanvas |
|
2139 "returns a value holder which is true in case that one component is selected |
|
2140 other than the canvas. |
|
2141 " |
|
2142 ^ builder booleanValueAspectFor:#hasOneSelectionOtherThanCanvas |
|
2143 ! |
|
2144 |
|
2145 modifiedChannel |
|
2146 "returns a boolean value holder which is set to true if something is modified |
|
2147 and not accepted |
|
2148 " |
|
2149 ^ builder booleanValueAspectFor:#modifiedChannel |
|
2150 ! |
|
2151 |
|
2152 noteBookView |
|
2153 "returns the notebook view; initialize components within the notebook |
|
2154 " |
|
2155 |noteBook channel helpTool layoutTool specTool| |
|
2156 |
|
2157 (noteBook := builder bindingAt:#noteBookView) isNil ifTrue:[ |
|
2158 noteBook := View new. |
|
2159 layoutTool := UILayoutTool new. |
|
2160 helpTool := UIHelpTool new. |
|
2161 helpTool buildFromClass:specClass. |
|
2162 specTool := UISpecificationTool new. |
|
2163 channel := self modifiedChannel. |
|
2164 |
|
2165 layoutTool masterApplication:self. |
|
2166 specTool masterApplication:self. |
|
2167 helpTool masterApplication:self. |
|
2168 |
|
2169 layoutCanvas := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook. |
|
2170 helpCanvas := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook. |
|
2171 specCanvas := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook. |
|
2172 |
|
2173 layoutCanvas client:layoutTool. |
|
2174 helpCanvas client:helpTool. |
|
2175 specTool builder:(specCanvas client:specTool). |
|
2176 |
|
2177 layoutTool masterApplication:self. |
|
2178 specTool masterApplication:self. |
|
2179 helpTool masterApplication:self. |
|
2180 |
|
2181 layoutTool modifiedHolder:channel. |
|
2182 helpTool modifiedHolder:channel. |
|
2183 specTool modifiedHolder:channel. |
|
2184 |
|
2185 builder aspectAt:#noteBookView put:noteBook. |
|
2186 ]. |
|
2187 ^ noteBook |
|
2188 ! |
|
2189 |
|
2190 painterShown |
|
2191 "returns a boolean value holder which is set to true if the painter is shown |
|
2192 " |
|
2193 |holder| |
|
2194 |
|
2195 (holder := builder bindingAt:#painterShown) isNil ifTrue:[ |
|
2196 builder aspectAt:#painterShown put:(holder := true asValue). |
|
2197 holder addDependent:self |
|
2198 ]. |
|
2199 ^ holder |
|
2200 |
|
2201 ! |
|
2202 |
|
2203 tabList |
|
2204 "returns a value holder which keeps a list of labels assigned to the tabs |
|
2205 " |
|
2206 |holder| |
|
2207 |
|
2208 (holder := builder bindingAt:#tabList) isNil ifTrue:[ |
|
2209 builder aspectAt:#tabList put:(holder := #(Basics Details Layout) asValue). |
|
2210 ]. |
|
2211 ^ holder |
|
2212 ! |
|
2213 |
|
2214 tabModel |
|
2215 "returns a value holder which keeps the current name of the tab selected |
|
2216 " |
|
2217 |holder| |
|
2218 |
|
2219 (holder := builder bindingAt:#tabModel) isNil ifTrue:[ |
|
2220 holder := AspectAdaptor new subject:self; forAspect:#tabSelection. |
|
2221 builder aspectAt:#tabModel put:holder. |
|
2222 ]. |
|
2223 ^ holder |
|
2224 ! |
|
2225 |
|
2226 treeView |
|
2227 "returns the selection tree view which holds all widget identifiers |
|
2228 " |
|
2229 ^ treeView |
|
2230 ! |
|
2231 |
|
2232 valueOfCanPasteWithKeepingLayout |
|
2233 |
|
2234 |holder| |
|
2235 (holder := builder bindingAt:#valueOfCanPasteWithKeepingLayout) isNil ifTrue:[ |
|
2236 builder aspectAt:#valueOfCanPasteWithKeepingLayout put:(holder := false asValue). |
|
2237 ]. |
|
2238 ^ holder |
|
2239 |
|
2240 |
|
2241 |
|
2242 ! ! |
|
2243 |
|
2244 !UIPainter methodsFor:'building editors'! |
|
2245 |
|
2246 openDataSetColumnEditor |
|
2247 "opens a column editor |
|
2248 " |
|
2249 |cls aspect editor columns| |
|
2250 |
|
2251 cls := self resolveName:specClass. |
|
2252 |
|
2253 cls isNil ifTrue:[ |
|
2254 ^ self information:'No application class defined yet!!' |
|
2255 ]. |
|
2256 aspect := self specTool specification columns. |
|
2257 |
|
2258 editor := DataSetBuilder new. |
|
2259 editor masterApplication:self. |
|
2260 editor columns:aspect fromView:(self layoutTool layoutView). |
|
2261 editor rowClassName:(self specTool specification rowClassName). |
|
2262 editor openModal. |
|
2263 |
|
2264 editor hasChanged ifTrue:[ |
|
2265 self specTool specification columns:(editor columns). |
|
2266 self specTool specification rowClassName:(editor rowClassName). |
|
2267 self modifiedChannel value:true. |
|
2268 ]. |
|
2269 ! |
|
2270 |
|
2271 openEditMenu |
|
2272 "opens a menu editor on current widget |
|
2273 " |
|
2274 |cls selectorOrMenu editor selectedSpec| |
|
2275 |
|
2276 cls := self resolveName:specClass. |
|
2277 |
|
2278 cls isNil ifTrue:[ |
|
2279 ^ self warn:'No application class defined yet!!' |
|
2280 ]. |
|
2281 |
|
2282 cls notNil ifTrue:[ |
|
2283 (selectorOrMenu := self specTool specification menuSelector) notNil ifTrue:[ |
|
2284 selectorOrMenu := selectorOrMenu asSymbol |
|
2285 ] ifFalse:[ |
|
2286 "/ cg: q&d hack ... |
|
2287 |
|
2288 (selectedSpec := treeView propertySelected) notNil ifTrue:[ |
|
2289 Object errorSignal handle:[:ex | |
|
2290 selectorOrMenu := nil. |
|
2291 ] do:[ |
|
2292 selectorOrMenu := selectedSpec view asMenu. |
|
2293 ] |
|
2294 ]. |
|
2295 ]. |
|
2296 |
|
2297 editor := MenuEditor new. |
|
2298 editor masterApplication:self. |
|
2299 editor specClass: cls. |
|
2300 editor useHelpTool: self helpTool. |
|
2301 selectorOrMenu class ~~ Menu |
|
2302 ifTrue: [editor openModalOnClass:cls andSelector:selectorOrMenu] |
|
2303 ifFalse: [editor openModalOnMenu:selectorOrMenu]. |
|
2304 self helpTool updateList. |
|
2305 |
|
2306 editor specSelector ~= selectorOrMenu ifTrue:[ |
|
2307 editor hasSaved ifTrue:[ |
|
2308 self specTool specification menuSelector:editor specSelector. |
|
2309 self modifiedChannel value:true. |
|
2310 self accept |
|
2311 ] |
|
2312 ]. |
|
2313 ] |
|
2314 |
|
2315 "Modified: 31.7.1997 / 14:26:13 / cg" |
|
2316 ! |
|
2317 |
|
2318 openHierarchicalListEditor |
|
2319 "opens a hierarchical list editor editor on current widget |
|
2320 " |
|
2321 |cls aspect editor| |
|
2322 |
|
2323 cls := self resolveName:specClass. |
|
2324 |
|
2325 cls isNil ifTrue:[ |
|
2326 ^ self information:'No application class defined yet!!' |
|
2327 ]. |
|
2328 |
|
2329 (aspect := self specTool specification hierarchicalList) notNil ifTrue:[ |
|
2330 aspect := aspect asSymbol |
|
2331 ]. |
|
2332 |
|
2333 editor := HierarchicalListEditor new. |
|
2334 editor masterApplication:self. |
|
2335 editor openModalOnClass:cls andSelector:aspect. |
|
2336 |
|
2337 editor specSelector ~= aspect ifTrue:[ |
|
2338 editor hasSaved ifTrue:[ |
|
2339 self specTool specification hierarchicalList:editor specSelector. |
|
2340 self modifiedChannel value:true. |
|
2341 self accept |
|
2342 ] |
|
2343 ] |
|
2344 ! |
|
2345 |
|
2346 openSubSpecGUIPainter |
|
2347 "opens a GUI Painter on the current subspecification" |
|
2348 |
|
2349 |spec cls meta sel| |
|
2350 |
|
2351 spec := self specTool specification. |
|
2352 cls := spec majorKey. |
|
2353 cls isNil ifTrue:[ |
|
2354 cls := specClass. |
|
2355 ]. |
|
2356 (cls isNil or:[(cls := self resolveName:cls) isNil]) ifTrue:[ |
|
2357 spec majorKey isNil ifTrue:[ |
|
2358 ^ self warn:'Cannot find class (no majorKey specified)'. |
|
2359 ]. |
|
2360 ^ self warn:'Cannot find class ', spec majorKey asBoldText, '!!'. |
|
2361 ]. |
|
2362 sel := spec minorKey. |
|
2363 meta := cls class whichClassIncludesSelector:sel. |
|
2364 meta isNil ifTrue:[ |
|
2365 ^ self warn:'Cannot find selector #', (sel ? '') asBoldText, ' in class ', cls name asBoldText, '!!' |
|
2366 ]. |
|
2367 |
|
2368 self class openOnClass:meta soleInstance andSelector:spec minorKey. |
|
2369 |
|
2370 "Created: / 6.2.1998 / 13:03:59 / stefan" |
|
2371 "Modified: / 6.2.1998 / 13:59:30 / stefan" |
|
2372 ! |
|
2373 |
|
2374 openTabListEditor |
|
2375 "open a TabListEditor |
|
2376 " |
|
2377 |cls aspect editor columns| |
|
2378 |
|
2379 cls := self resolveName:specClass. |
|
2380 |
|
2381 cls isNil ifTrue:[ |
|
2382 ^ self information:'No application class defined yet!!' |
|
2383 ]. |
|
2384 aspect := self specTool specification listSelector. |
|
2385 |
|
2386 editor := TabListEditor new. |
|
2387 editor masterApplication:self. |
|
2388 editor openModalOnClass:cls andSelector:aspect. |
|
2389 |
|
2390 editor specSelector ~= aspect ifTrue:[ |
|
2391 editor hasSaved ifTrue:[ |
|
2392 self specTool specification listSelector:(editor specSelector). |
|
2393 self modifiedChannel value:true. |
|
2394 self accept. |
|
2395 ] |
|
2396 ] |
|
2397 ! ! |
|
2398 |
|
2399 !UIPainter methodsFor:'change & update'! |
|
2400 |
|
2401 layoutChanged |
|
2402 "called by the painter/canvas whenever the layout of the current selected |
|
2403 widget changed |
|
2404 " |
|
2405 self isModified ifFalse:[ |
|
2406 self layoutTool update. |
|
2407 self modifiedChannel value:false |
|
2408 ] |
|
2409 ! |
|
2410 |
|
2411 propertyChanged |
|
2412 "called by the painter/canvas whenever the property of the current selected |
|
2413 widget changed |
|
2414 " |
|
2415 |p| |
|
2416 |
|
2417 (p := treeView propertySelected) notNil ifTrue:[ |
|
2418 self specTool specification:(p spec copy). |
|
2419 self setViewInLayoutTool:(p view). |
|
2420 self modifiedChannel value:false |
|
2421 ] ifFalse:[ |
|
2422 self layoutTool layoutView notNil ifTrue:[ |
|
2423 self modifiedChannel value:false. |
|
2424 self treeSelection |
|
2425 ] |
|
2426 ] |
|
2427 ! |
|
2428 |
|
2429 update:something with:aParameter from:someObject |
|
2430 "catch change notifications |
|
2431 " |
|
2432 someObject == treeView model ifTrue:[ |
|
2433 (something == #selection |
|
2434 or:[something == #selectionIndex]) ifTrue:[self treeSelection]. |
|
2435 ^ self |
|
2436 ]. |
|
2437 |
|
2438 self galleryShown == someObject ifTrue:[ |
|
2439 (self galleryShown value) ifTrue:[ |
|
2440 self raiseUIView:(selectionPanel window) |
|
2441 ] ifFalse:[ |
|
2442 self hideUIView:(selectionPanel window) |
|
2443 ]. |
|
2444 ^ self |
|
2445 ]. |
|
2446 |
|
2447 self painterShown == someObject ifTrue:[ |
|
2448 (self painterShown value) ifTrue:[ |
|
2449 self raiseUIView:(self painter topView) |
|
2450 ] ifFalse:[ |
|
2451 self hideUIView:(self painter topView) |
|
2452 ]. |
|
2453 ^ self |
|
2454 ]. |
|
2455 |
|
2456 "Modified: / 29.10.1997 / 17:48:19 / cg" |
|
2457 ! ! |
|
2458 |
|
2459 !UIPainter methodsFor:'event handling'! |
|
2460 |
|
2461 doesNotUnderstand:aMessage |
|
2462 |
|
2463 |painter| |
|
2464 |
|
2465 painter := self painter. |
|
2466 |
|
2467 (painter respondsTo:(aMessage selector)) ifTrue:[ |
|
2468 ^ aMessage sendTo:painter |
|
2469 ]. |
|
2470 super doesNotUnderstand:aMessage |
|
2471 |
|
2472 ! ! |
|
2473 |
|
2474 !UIPainter methodsFor:'help'! |
|
2475 |
|
2476 defaultInfoLabel |
|
2477 |
|
2478 specClass isNil ifTrue: [^'No class and selector defined.']. |
|
2479 ^specClass printString, ' >> ', specSelector |
|
2480 ! |
|
2481 |
|
2482 show:aHelpText |
|
2483 |
|
2484 (self transcriptHelp and: [transcript notNil]) |
|
2485 ifFalse: |
|
2486 [ |
|
2487 super showHelp:aHelpText for:self |
|
2488 ] |
|
2489 ifTrue: |
|
2490 [ |
|
2491 transcript hideCursor; contents:aHelpText |
|
2492 ] |
|
2493 ! |
|
2494 |
|
2495 showHelp:aHelpText for:view |
|
2496 "display active help texts in my own info area." |
|
2497 |
|
2498 (self transcriptHelp and: [transcript notNil]) |
|
2499 ifFalse: |
|
2500 [ |
|
2501 ^super showHelp:aHelpText for:view. |
|
2502 ] |
|
2503 ifTrue: |
|
2504 [ |
|
2505 |txt| |
|
2506 aHelpText isNil ifTrue:[ |
|
2507 txt := nil |
|
2508 ] ifFalse:[ |
|
2509 txt := self class |
|
2510 convertString:(aHelpText asString) |
|
2511 maxLineSize:(transcript width // transcript font width) |
|
2512 skipLineFeed:true |
|
2513 ]. |
|
2514 transcript hideCursor; contents:txt. |
|
2515 ^true |
|
2516 ] |
|
2517 ! ! |
|
2518 |
|
2519 !UIPainter methodsFor:'private'! |
|
2520 |
|
2521 askForModification |
|
2522 "check interface modification |
|
2523 " |
|
2524 |
|
2525 self treeSelection. "accept modifications" |
|
2526 |
|
2527 (modified or: [self painter isModified or: [self helpTool modified]]) |
|
2528 ifTrue: |
|
2529 [ |
|
2530 ((YesNoBox title:'Window Spec was modified!!') |
|
2531 noText:'Cancel'; |
|
2532 yesText:'Waste it and proceed'; |
|
2533 showAtPointer; |
|
2534 accepted) ifFalse: [^false]. |
|
2535 modified := false. |
|
2536 self painter resetModification |
|
2537 ]. |
|
2538 ^true |
|
2539 ! |
|
2540 |
|
2541 checkClassAndSelector |
|
2542 "check for class & superclass" |
|
2543 |
|
2544 |superclass cls| |
|
2545 |
|
2546 specClass isNil ifTrue:[^ false]. |
|
2547 |
|
2548 cls := self resolveName:specClass. |
|
2549 |
|
2550 cls isNil ifTrue:[ |
|
2551 superclass := self resolveName:specSuperclass. |
|
2552 |
|
2553 superclass isNil ifTrue:[ |
|
2554 self warn:'No class named ' , specSuperclass , ' exists!!'. |
|
2555 ^ false. |
|
2556 ]. |
|
2557 (self confirm:'Create class ' , specClass asBoldText, '?') ifTrue:[ |
|
2558 superclass subclass:(specClass asSymbol) |
|
2559 instanceVariableNames:'' |
|
2560 classVariableNames:'' |
|
2561 poolDictionaries:'' |
|
2562 category:'Applications'. |
|
2563 ^ true. |
|
2564 ]. |
|
2565 ^ false. |
|
2566 ]. |
|
2567 cls isBehavior ifFalse:[ |
|
2568 self warn:'A global named ' , specClass , ' exists, but it is no class.'. |
|
2569 ^ false. |
|
2570 ]. |
|
2571 |
|
2572 specSuperclass isBehavior ifFalse:[ |
|
2573 specSuperclass isEmpty ifFalse:[ |
|
2574 superclass := self resolveName:specSuperclass |
|
2575 ] ifTrue:[ |
|
2576 specSuperclass := nil. |
|
2577 ] |
|
2578 ] ifTrue:[ |
|
2579 superclass := specSuperclass |
|
2580 ]. |
|
2581 |
|
2582 specSuperclass notNil ifTrue:[ |
|
2583 superclass isNil ifTrue:[ |
|
2584 self warn:'No class named ' , specSuperclass , ' exists!!'. |
|
2585 ^ false. |
|
2586 ]. |
|
2587 |
|
2588 (cls isSubclassOf:superclass) ifFalse:[ |
|
2589 self information:('A global named ' , specClass , ' exists,\' , |
|
2590 'but is not a subclass of ' , superclass name , '.\\' , |
|
2591 'Check and try again if that is not what you want.') withCRs. |
|
2592 ] |
|
2593 ]. |
|
2594 |
|
2595 superclass isNil ifTrue:[ |
|
2596 cls notNil ifTrue:[ |
|
2597 specSuperclass := cls superclass name |
|
2598 ] |
|
2599 ]. |
|
2600 |
|
2601 ^ true |
|
2602 |
|
2603 "Modified: 12.8.1997 / 23:39:10 / cg" |
|
2604 ! |
|
2605 |
|
2606 checkModified |
|
2607 "check interface modification |
|
2608 " |
|
2609 (self isModified and: [self isModified or: [self helpTool modified]]) |
|
2610 ifTrue: |
|
2611 [ |
|
2612 ((YesNoBox title:'Window Spec was modified!!') |
|
2613 noText:'Cancel'; |
|
2614 yesText:'Waste it and proceed'; |
|
2615 showAtPointer; |
|
2616 accepted) ifFalse: [^false]. |
|
2617 self painter resetModification |
|
2618 ]. |
|
2619 ^true |
|
2620 ! |
|
2621 |
|
2622 hideUIView:aView |
|
2623 "hide the view which is an application or top view |
|
2624 " |
|
2625 aView beIndependent. |
|
2626 aView unmap. |
|
2627 ! |
|
2628 |
|
2629 raiseTabView |
|
2630 |
|
2631 self isLayoutToolSelected ifTrue:[ |
|
2632 layoutCanvas raise |
|
2633 ] ifFalse:[ |
|
2634 self isHelpToolSelected ifTrue:[ |
|
2635 helpCanvas raise |
|
2636 ] ifFalse:[ |
|
2637 self specTool selection:tabSelection. |
|
2638 specCanvas raise |
|
2639 ] |
|
2640 ] |
|
2641 ! |
|
2642 |
|
2643 raiseUIView:aView |
|
2644 "raise the view which is an application or top view |
|
2645 " |
|
2646 aView map. |
|
2647 aView bePartner. |
|
2648 ! |
|
2649 |
|
2650 resourceMessage: aString |
|
2651 |
|
2652 (aString notNil and: [self askForModification]) |
|
2653 ifTrue: |
|
2654 [ |
|
2655 |msg cls sel| |
|
2656 msg := aString asCollectionOfWords. |
|
2657 (msg size == 2 and: |
|
2658 [(cls := self resolveName:(msg at:1)) notNil]) |
|
2659 ifTrue: |
|
2660 [ |
|
2661 self specClass:cls. |
|
2662 specSuperclass := cls superclass name. |
|
2663 specSelector := (msg at: 2) asSymbol. |
|
2664 ^true |
|
2665 ] |
|
2666 ]. |
|
2667 ^false |
|
2668 ! |
|
2669 |
|
2670 setClass:cls selector:selector |
|
2671 "set the application class and the selector under which the |
|
2672 window specification should be stored |
|
2673 " |
|
2674 |clsName superClassName| |
|
2675 |
|
2676 clsName := cls name. |
|
2677 superClassName := cls superclass name. |
|
2678 |
|
2679 (self aspectFor:#classNameChannel) value:clsName. |
|
2680 (self aspectFor:#methodNameChannel) value:(selector ? ''). |
|
2681 (self aspectFor:#superclassNameChannel) value:superClassName. |
|
2682 |
|
2683 self painter |
|
2684 className:clsName |
|
2685 superclassName:superClassName |
|
2686 selector:(selector ? ''). |
|
2687 |
|
2688 self specClass:clsName. |
|
2689 specSelector := (selector ? ''). |
|
2690 specSuperclass := superClassName. |
|
2691 |
|
2692 specClass notNil & selector notNil ifTrue:[ |
|
2693 self addToHistory: (specClass, ' ', specSelector) -> #loadFromMessage:. |
|
2694 self updateInfoLabel |
|
2695 ]. |
|
2696 |
|
2697 "Modified: / 5.2.1998 / 09:44:58 / stefan" |
|
2698 ! |
|
2699 |
|
2700 setViewInLayoutTool:aView |
|
2701 "set view for layout tool |
|
2702 " |
|
2703 |type| |
|
2704 |
|
2705 self painter topView == aView ifTrue:[ |
|
2706 type := #Extent |
|
2707 ]. |
|
2708 self layoutTool layoutView:aView type:type |
|
2709 |
|
2710 ! |
|
2711 |
|
2712 specClass:aClass |
|
2713 |
|
2714 specClass := aClass isBehavior ifTrue:[aClass name] |
|
2715 ifFalse:[aClass]. |
|
2716 |
|
2717 self helpTool buildFromClass:specClass. |
|
2718 self helpTool updateList. |
|
2719 self modifiedChannel value: false. |
|
2720 |
|
2721 ! ! |
|
2722 |
|
2723 !UIPainter methodsFor:'private tools'! |
|
2724 |
|
2725 helpTool |
|
2726 "returns the help tool |
|
2727 " |
|
2728 helpCanvas isNil ifTrue:[ |
|
2729 self noteBookView |
|
2730 ]. |
|
2731 ^ helpCanvas application |
|
2732 ! |
|
2733 |
|
2734 layoutTool |
|
2735 "returns the layout tool |
|
2736 " |
|
2737 layoutCanvas isNil ifTrue:[ |
|
2738 self noteBookView |
|
2739 ]. |
|
2740 ^ layoutCanvas application |
|
2741 ! |
|
2742 |
|
2743 painter |
|
2744 "returns the painter/canvas view |
|
2745 " |
|
2746 ^ treeView canvas |
|
2747 ! |
|
2748 |
|
2749 specTool |
|
2750 "returns the spec tool |
|
2751 " |
|
2752 specCanvas isNil ifTrue:[ |
|
2753 self noteBookView |
|
2754 ]. |
|
2755 ^ specCanvas application |
|
2756 ! ! |
|
2757 |
|
2758 !UIPainter methodsFor:'queries'! |
|
2759 |
|
2760 hasSpecClass |
|
2761 "checks whether an application class is defined |
|
2762 " |
|
2763 ^ (self resolveName:specClass) notNil |
|
2764 ! |
|
2765 |
|
2766 hasSpecClassAndSelector |
|
2767 "checks whether an application class and a selector under which |
|
2768 the window specification is stored is defined. |
|
2769 " |
|
2770 specSelector size > 1 ifTrue:[ |
|
2771 ^ self hasSpecClass |
|
2772 ]. |
|
2773 ^ false |
|
2774 ! |
|
2775 |
|
2776 isHelpToolSelected |
|
2777 "returns true if current selected tab in the noteBook is assigned |
|
2778 to the 'Help' tool |
|
2779 " |
|
2780 ^ tabSelection = UIHelpTool label |
|
2781 |
|
2782 ! |
|
2783 |
|
2784 isLayoutToolSelected |
|
2785 "returns true if current selected tab in the noteBook is assigned |
|
2786 to the 'Layout' tool |
|
2787 " |
|
2788 ^ tabSelection = UILayoutTool label |
|
2789 ! |
|
2790 |
|
2791 isModified |
|
2792 "return true if current specification or layout is modified |
|
2793 " |
|
2794 ^ self modifiedChannel value |
|
2795 ! |
|
2796 |
|
2797 isPainterEnabled |
|
2798 "returns true if not running in test mode |
|
2799 " |
|
2800 ^ self painter enabled |
|
2801 ! ! |
|
2802 |
|
2803 !UIPainter methodsFor:'selection'! |
|
2804 |
|
2805 tabSelection |
|
2806 "returns name of current selected tab in the notebook. |
|
2807 " |
|
2808 ^ tabSelection |
|
2809 ! |
|
2810 |
|
2811 tabSelection:something |
|
2812 "the tab selection of the notebook changed |
|
2813 " |
|
2814 |
|
2815 |whatToDo| |
|
2816 |
|
2817 (something isNil or:[tabSelection = something]) ifTrue:[ |
|
2818 ^ self |
|
2819 ]. |
|
2820 |
|
2821 self isModified ifTrue:[ |
|
2822 whatToDo := DialogBox |
|
2823 confirmWithCancel:'Accept modifications in section ' , tabSelection printString , '?' |
|
2824 labels:#('Cancel' 'Ignore' 'Accept') |
|
2825 default:3. |
|
2826 whatToDo isNil ifTrue:[^self]. |
|
2827 whatToDo == true ifTrue:[ |
|
2828 self accept |
|
2829 ] ifFalse:[ |
|
2830 self cancel |
|
2831 ] |
|
2832 ]. |
|
2833 |
|
2834 tabSelection := something. |
|
2835 self raiseTabView. |
|
2836 self cancel. |
|
2837 |
|
2838 ! |
|
2839 |
|
2840 treeSelection |
|
2841 "called whenever the selection of the treeview changed |
|
2842 " |
|
2843 |view list spec slices size property tabComponent canCutOrCopy canPaste clipboard sel| |
|
2844 |
|
2845 self isModified ifTrue:[ |
|
2846 (self confirm:'Accept modifications in section ' , tabSelection printString asBoldText, '?') ifTrue:[ |
|
2847 self accept |
|
2848 ] |
|
2849 ]. |
|
2850 |
|
2851 self canMoveOrAlignSelection value:(treeView canMoveOrAlignSelection). |
|
2852 self canChangeOrderInContainer value:(treeView canChangeOrderInContainer). |
|
2853 self canMoveSelectionIntoContainer value:(treeView canMoveSelectionIntoContainer). |
|
2854 self canMoveSelectionOutOfContainer value:(treeView canMoveSelectionOutOfContainer). |
|
2855 self hasOneSelectionOtherThanCanvas value:(treeView hasOneSelectionOtherThanCanvas). |
|
2856 |
|
2857 treeView isCanvasSelected ifTrue:[ |
|
2858 spec := treeView canvasSpec. |
|
2859 view := self painter topView. |
|
2860 ] ifFalse:[ |
|
2861 (property := treeView propertySelected) notNil ifTrue:[ |
|
2862 treeView canResizeSelectedWidget ifTrue:[ |
|
2863 view := property view. |
|
2864 ]. |
|
2865 spec := property spec copy. |
|
2866 ] |
|
2867 ]. |
|
2868 tabComponent := builder componentAt:#noteBook. |
|
2869 self setViewInLayoutTool:view. |
|
2870 self specTool specification:spec. |
|
2871 |
|
2872 spec notNil ifTrue:[ |
|
2873 self helpTool helpKey:(spec activeHelpKey). |
|
2874 slices := spec class slices. |
|
2875 size := slices size. |
|
2876 |
|
2877 view notNil ifTrue:[ |
|
2878 self treeView isCanvasSelected |
|
2879 ifFalse: |
|
2880 [ |
|
2881 list := Array new:(size + 2). |
|
2882 list at:(size + 2) put:(UILayoutTool label). |
|
2883 ] |
|
2884 ifTrue: |
|
2885 [ |
|
2886 list := Array new:(size + 1). |
|
2887 list at:(size + 1) put:(UILayoutTool label). |
|
2888 ]. |
|
2889 ] ifFalse:[ |
|
2890 list := Array new:(size + 1). |
|
2891 ]. |
|
2892 |
|
2893 1 to:size do:[:i| list at:i put:((slices at:i) first asString)]. |
|
2894 self treeView isCanvasSelected ifFalse: [list at:(size + 1) put:(UIHelpTool label)]. |
|
2895 |
|
2896 self tabList value:list. |
|
2897 self show:(spec class name). |
|
2898 tabComponent enabled:true. |
|
2899 |
|
2900 (tabSelection := tabComponent selection) isNil ifTrue:[ |
|
2901 tabComponent setSelection:(tabSelection := list first) |
|
2902 ]. |
|
2903 self raiseTabView |
|
2904 ] ifFalse:[ |
|
2905 self helpTool helpKey:nil. |
|
2906 tabComponent enabled:false. |
|
2907 self show:nil. |
|
2908 ]. |
|
2909 self modifiedChannel value:false. |
|
2910 |
|
2911 treeView notNil |
|
2912 ifTrue: |
|
2913 [ |
|
2914 canCutOrCopy := treeView selection size >= 1 and:[treeView selection first ~~ 1]. |
|
2915 clipboard := self getSelection. |
|
2916 |
|
2917 clipboard isCollection ifTrue:[clipboard notEmpty ifTrue:[sel := clipboard first]] |
|
2918 ifFalse:[sel := clipboard]. |
|
2919 |
|
2920 canPaste := (sel isKindOf:UISpecification) and: |
|
2921 [treeView selection size = 1 |
|
2922 and:[treeView selection first == 1 |
|
2923 or: [self canPasteInto: treeView selectedNode contents view]]] |
|
2924 ]. |
|
2925 |
|
2926 self valueOfCanCut value: canCutOrCopy. |
|
2927 self valueOfCanCopy value: canCutOrCopy. |
|
2928 self valueOfCanPaste value: canPaste. |
|
2929 self valueOfCanPasteWithKeepingLayout value: (canPaste & self canKeepLayoutInSelection). |
|
2930 |
|
2931 |
|
2932 ! ! |
|
2933 |
|
2934 !UIPainter methodsFor:'startup / release'! |
|
2935 |
|
2936 closeRequest |
|
2937 "close all windows open by builder |
|
2938 " |
|
2939 |
|
2940 self askForModification ifFalse:[^self]. |
|
2941 |
|
2942 treeView model removeDependent:self. |
|
2943 self painter release. |
|
2944 ColorMenu releaseResources. |
|
2945 |
|
2946 selectionPanel notNil ifTrue:[ |
|
2947 selectionPanel masterApplication:nil. |
|
2948 selectionPanel closeRequest |
|
2949 ]. |
|
2950 selectionPanel := nil. |
|
2951 treeView := nil. |
|
2952 |
|
2953 ActiveHelp stopFor:self. |
|
2954 |
|
2955 super closeRequest. |
|
2956 |
|
2957 "Modified: / 27.10.1997 / 00:01:30 / cg" |
|
2958 ! |
|
2959 |
|
2960 closeRequestFor:aTopView |
|
2961 "handle a close request for a specific view |
|
2962 " |
|
2963 |topView| |
|
2964 |
|
2965 topView := self window. |
|
2966 |
|
2967 topView == aTopView ifTrue:[ |
|
2968 super closeRequestFor:aTopView |
|
2969 ] ifFalse:[ |
|
2970 aTopView = selectionPanel window ifTrue:[ |
|
2971 self galleryShown value:false |
|
2972 ] ifFalse:[ |
|
2973 aTopView == (self painter topView) ifTrue:[ |
|
2974 self painterShown value:false |
|
2975 ] ifFalse:[ |
|
2976 aTopView closeRequest |
|
2977 ] |
|
2978 ]. |
|
2979 topView raise. |
|
2980 ]. |
|
2981 ! |
|
2982 |
|
2983 loadFromMessage: aMessage |
|
2984 |
|
2985 ((aMessage size > 0) and: [self askForModification]) |
|
2986 ifTrue: |
|
2987 [ |
|
2988 |readStream aClass aSelector| |
|
2989 readStream := aMessage readStream. |
|
2990 (aClass := Smalltalk at: (readStream upTo: $ ) asSymbol) notNil |
|
2991 ifTrue: |
|
2992 [ |
|
2993 aSelector := readStream upToEnd asSymbol. |
|
2994 self setClass: aClass selector: aSelector. |
|
2995 (aClass respondsTo:aSelector) |
|
2996 ifTrue: |
|
2997 [ |
|
2998 self painter setupFromSpec:(aClass perform:aSelector). |
|
2999 treeView selection: #(1). |
|
3000 ] |
|
3001 ] |
|
3002 ] |
|
3003 ! |
|
3004 |
|
3005 openInterface:aSymbol |
|
3006 "open interfaces |
|
3007 " |
|
3008 |painterView painter cls topView| |
|
3009 |
|
3010 modified := false. |
|
3011 |
|
3012 aspects := IdentityDictionary new. |
|
3013 |
|
3014 aspects at:#classNameChannel put:( |
|
3015 (specClass notNil ifTrue:[specClass] |
|
3016 ifFalse:['NewApplication']) asValue |
|
3017 ). |
|
3018 specSuperclass isNil ifTrue:[ |
|
3019 specClass notNil ifTrue:[ |
|
3020 (cls := self resolveName:specClass) notNil ifTrue:[ |
|
3021 specSuperclass := cls superclass name. |
|
3022 ] |
|
3023 ] |
|
3024 ]. |
|
3025 aspects at:#superclassNameChannel put:( |
|
3026 (specSuperclass notNil ifTrue:[specSuperclass] |
|
3027 ifFalse:['ApplicationModel']) asValue |
|
3028 ). |
|
3029 aspects at:#superclassNameDefaults put:#('ApplicationModel' 'SimpleDialog') asValue. |
|
3030 aspects at:#methodNameChannel put:( |
|
3031 (specSelector notNil ifTrue:[specSelector asValue] |
|
3032 ifFalse:[#windowSpec]) asValue |
|
3033 ). |
|
3034 |
|
3035 treeView := TreeView new. |
|
3036 painterView := StandardSystemView new. |
|
3037 painterView name: self class defaultNameOfCanvas. |
|
3038 painterView label: self class defaultNameOfCanvas. |
|
3039 painterView extent:300@300. |
|
3040 |
|
3041 painter := UIPainterView in:painterView. |
|
3042 painter layout:(0.0 @ 0.0 corner:1.0 @ 1.0) asLayout. |
|
3043 |
|
3044 treeView := treeView canvas:painter. |
|
3045 painter treeView:treeView. |
|
3046 treeView model addDependent:self. |
|
3047 |
|
3048 self transcriptHelp |
|
3049 ifFalse: |
|
3050 [ |
|
3051 super openInterface:aSymbol. |
|
3052 ] |
|
3053 ifTrue: |
|
3054 [ |
|
3055 super openInterface:#windowSpecWithTranscriptHelp. |
|
3056 transcript := (self builder componentAt:#HelpTranscript) scrolledView. |
|
3057 ]. |
|
3058 |
|
3059 topView := self window. |
|
3060 |
|
3061 topView label:'GUI Painter'. |
|
3062 |
|
3063 painterView openInGroup:(topView windowGroup). |
|
3064 painterView open. |
|
3065 painterView application:self. |
|
3066 |
|
3067 painterView application:self. |
|
3068 selectionPanel := UISelectionPanel new. |
|
3069 selectionPanel allButOpenInterface:#windowSpec. |
|
3070 selectionPanel window openInGroup:(topView windowGroup). |
|
3071 |
|
3072 selectionPanel openWindow. |
|
3073 selectionPanel masterApplication:self. |
|
3074 |
|
3075 topView iconLabel:'GUI Painter'. |
|
3076 topView icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100). |
|
3077 |
|
3078 painterView iconLabel:'GUI Painter'. |
|
3079 painterView icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100). |
|
3080 |
|
3081 topView bePartner. |
|
3082 painterView bePartner. |
|
3083 selectionPanel window bePartner. |
|
3084 |
|
3085 selectionPanel window iconLabel:'GUI Painter'. |
|
3086 selectionPanel window icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100). |
|
3087 |
|
3088 ! |
|
3089 |
|
3090 openOnClass:aClass |
|
3091 "open up an interface builder |
|
3092 " |
|
3093 self openOnClass:aClass andSelector:#windowSpec |
|
3094 ! |
|
3095 |
|
3096 openOnClass:aClass andSelector:aSelector |
|
3097 "open up an interface builder, fetching a spec from someClass |
|
3098 via some selector |
|
3099 " |
|
3100 |painter| |
|
3101 |
|
3102 aClass isNil ifTrue:[ |
|
3103 (self confirm:'No class given to the GUI Painter (class was probably renamed?)\\Open anyway (to create a new window spec) ?' withCRs) |
|
3104 ifFalse:[^ nil]. |
|
3105 ]. |
|
3106 |
|
3107 self openInterface. |
|
3108 |
|
3109 aClass notNil ifTrue:[ |
|
3110 painter := self painter. |
|
3111 self setClass:aClass selector:aSelector. |
|
3112 (aClass respondsTo:aSelector) ifTrue:[ |
|
3113 "take care for those who do close very quickly" |
|
3114 Object errorSignal handle: [:ex|] do: |
|
3115 [ |
|
3116 painter setupFromSpec:(aClass perform:aSelector). |
|
3117 treeView selection: #(1) |
|
3118 ]. |
|
3119 ] |
|
3120 ] |
|
3121 |
|
3122 "Modified: / 25.10.1997 / 19:11:51 / cg" |
|
3123 "Modified: / 5.2.1998 / 09:48:15 / stefan" |
|
3124 ! |
|
3125 |
|
3126 postOpenWith: aBuilder |
|
3127 |
|
3128 |painter settings gridPara hspace vspace| |
|
3129 |
|
3130 super postOpenWith: aBuilder. |
|
3131 |
|
3132 treeView selection: (Array with: 1). |
|
3133 self treeSelection. |
|
3134 |
|
3135 painter := self painter. |
|
3136 settings := self class settings. |
|
3137 gridPara := painter gridParameters copy. |
|
3138 hspace := settings at: #HGridSpace ifAbsent: [10]. |
|
3139 vspace := settings at: #VGridSpace ifAbsent: [10]. |
|
3140 gridPara at:1 put:hspace; at:2 put:vspace; at:5 put:hspace; at:6 put:vspace. |
|
3141 painter gridParameters:gridPara. |
|
3142 painter gridShown: (settings at: #GridShown ifAbsent: [false]). |
|
3143 painter gridAlign: (settings at: #GridAlign ifAbsent: [false]). |
|
3144 painter clear. |
|
3145 |
|
3146 |
|
3147 ! ! |
|
3148 |
|
3149 !UIPainter methodsFor:'user actions'! |
|
3150 |
|
3151 doBrowseAspectMethods |
2781 doBrowseAspectMethods |
3152 "open a browser on the aspect methods" |
2782 "opens a browser on the aspect methods" |
3153 |
2783 |
3154 |cls methods| |
2784 |methods| |
3155 |
2785 |
3156 self painter isModified ifTrue:[ |
2786 self painter isModified ifTrue:[ |
3157 self warn:'The current window spec has not yet been saved!!\\The System Browser may show the code of the old aspect methods.' withCRs. |
2787 self warn:'The current window spec has not yet been saved!!\\The System Browser may show the code of the old aspect methods.' withCRs. |
3158 ]. |
2788 ]. |
3159 cls := self resolveName:specClass. |
2789 |
3160 |
2790 (methods := self painter aspectMethods) isEmpty ifTrue:[ |
3161 cls notNil ifTrue:[ |
2791 self warn:'No aspect methods found!!'. |
3162 methods := self painter aspectMethods. |
2792 ^ self. |
3163 methods isEmpty ifTrue:[ |
2793 ]. |
3164 self warn:'No aspect methods have been saved yet!!'. |
2794 SystemBrowser browseMethods:methods title:'Aspect methods'. |
3165 ^ self. |
2795 |
3166 ]. |
|
3167 SystemBrowser browseMethods:methods title:'Aspect methods'. |
|
3168 ] ifFalse:[ |
|
3169 self information:'No class defined!!'. |
|
3170 ]. |
|
3171 |
|
3172 "Created: / 25.10.1997 / 19:07:55 / cg" |
|
3173 ! |
2796 ! |
3174 |
2797 |
3175 doBrowseClass |
2798 doBrowseClass |
3176 "open a System Browser on the class" |
2799 "opens a System Browser on the specClass" |
3177 |
|
3178 |cls| |
|
3179 |
2800 |
3180 self painter isModified ifTrue:[ |
2801 self painter isModified ifTrue:[ |
3181 self warn:'The current window spec has not yet been saved!!\\The System Browser will show the code of the old window spec.' withCRs. |
2802 self warn:'The current window spec has not yet been saved!!\\The System Browser will show the code of the old window spec.' withCRs. |
3182 ]. |
2803 ]. |
3183 cls := self resolveName:specClass. |
2804 |
3184 |
2805 SystemBrowser openInClass:(self resolveName:specClass) |
3185 cls notNil ifTrue:[ |
2806 |
3186 SystemBrowser openInClass:cls |
|
3187 ] ifFalse:[ |
|
3188 self information:'No class defined!!'. |
|
3189 ]. |
|
3190 |
|
3191 ! |
|
3192 |
|
3193 doChooseTreeViewFont |
|
3194 |
|
3195 |font| |
|
3196 (font := FontPanel |
|
3197 fontFromUserInitial: treeView class defaultFont |
|
3198 title: 'Choose Tree View Font') notNil |
|
3199 ifTrue: |
|
3200 [ |
|
3201 treeView class defaultFont: (font on: device). |
|
3202 treeView font: treeView class defaultFont |
|
3203 ] |
|
3204 ! |
2807 ! |
3205 |
2808 |
3206 doDefineClassAndSelector |
2809 doDefineClassAndSelector |
3207 "launch a dialog to define class, superclass, and selector" |
2810 "launches a dialog for defining class, superclass, and selector of the application" |
3208 |
2811 |
3209 |again tmp helpDict helpKey| |
2812 |again tmp helpDict helpKey| |
3210 |
2813 |
3211 [ |
2814 [ |
3212 again := false. |
2815 again := false. |