MenuView.st
changeset 497 072d3b8507fd
parent 495 d993f23ea658
child 508 7b0bffe113a0
equal deleted inserted replaced
496:f22ac16a5093 497:072d3b8507fd
  1118 
  1118 
  1119     |i newSubMenus|
  1119     |i newSubMenus|
  1120 
  1120 
  1121     i := self indexOf:indexOrName.
  1121     i := self indexOf:indexOrName.
  1122     i == 0 ifTrue:[^ nil].
  1122     i == 0 ifTrue:[^ nil].
       
  1123 
  1123     subMenus size < i ifTrue:[
  1124     subMenus size < i ifTrue:[
  1124 	newSubMenus := Array new:(list size max:i).
  1125         newSubMenus := Array new:(list size max:i).
  1125 	subMenus notNil ifTrue:[
  1126         subMenus notNil ifTrue:[
  1126 	    newSubMenus replaceFrom:1 with:subMenus.
  1127             newSubMenus replaceFrom:1 with:subMenus.
  1127 	].
  1128         ].
  1128 	subMenus := newSubMenus.
  1129         subMenus := newSubMenus.
  1129 	shown ifTrue:[
  1130         shown ifTrue:[
  1130 	    self resize
  1131             self resize
  1131 	] ifFalse:[
  1132         ] ifFalse:[
  1132 	    needResize := true
  1133             needResize := true
  1133 	]
  1134         ]
  1134     ].
  1135     ].
  1135     subMenus at:i put:aPopUpMenu
  1136     subMenus at:i put:aPopUpMenu.
       
  1137 
       
  1138     (receiver notNil and:[aPopUpMenu receiver isNil]) ifTrue:[
       
  1139         aPopUpMenu receiver:receiver
       
  1140     ].
       
  1141 
       
  1142     "Modified: 8.3.1996 / 14:42:51 / cg"
  1136 !
  1143 !
  1137 
  1144 
  1138 subMenuShown
  1145 subMenuShown
  1139     "return the currently visible submenu - or nil if there is none"
  1146     "return the currently visible submenu - or nil if there is none"
  1140 
  1147 
  1423             ].
  1430             ].
  1424             self performSelectedAction.
  1431             self performSelectedAction.
  1425         ]
  1432         ]
  1426     ].
  1433     ].
  1427 
  1434 
       
  1435     "/
       
  1436     "/ not within mySelf
       
  1437     "/
       
  1438 
  1428     superMenu notNil ifTrue:[
  1439     superMenu notNil ifTrue:[
  1429         hide := hideOnRelease.
  1440         hide := hideOnRelease.
  1430         hide ifFalse:[
  1441         hide ifFalse:[
  1431             superMenu shown not ifTrue:[
  1442             superMenu shown not ifTrue:[
  1432                 superView notNil ifTrue:[
  1443                 superView notNil ifTrue:[
  1446 "/        superView regainControl.
  1457 "/        superView regainControl.
  1447 "/        superView getKeyboardFocus.
  1458 "/        superView getKeyboardFocus.
  1448 "/        superView hide
  1459 "/        superView hide
  1449 "/    ]
  1460 "/    ]
  1450 
  1461 
  1451     "Modified: 4.3.1996 / 23:14:53 / cg"
  1462     "Modified: 8.3.1996 / 14:06:15 / cg"
  1452 !
  1463 !
  1453 
  1464 
  1454 keyPress:aKey x:x y:y
  1465 keyPress:aKey x:x y:y
  1455 
  1466 
  1456     <resource: #keyboard (#Return #MenuSelect #Escape)>
  1467     <resource: #keyboard (#Return #MenuSelect #Escape)>
  1716 
  1727 
  1717 !MenuView methodsFor:'private'!
  1728 !MenuView methodsFor:'private'!
  1718 
  1729 
  1719 hideSubmenu
  1730 hideSubmenu
  1720     subMenuShown notNil ifTrue:[
  1731     subMenuShown notNil ifTrue:[
  1721 	subMenuShown hide.
  1732         subMenuShown hide.
  1722 	subMenuShown := nil
  1733         subMenuShown := nil.
  1723     ].
  1734         self deselect.
       
  1735     ].
       
  1736 
       
  1737     "Modified: 8.3.1996 / 14:16:09 / cg"
  1724 !
  1738 !
  1725 
  1739 
  1726 isCheckItem:line
  1740 isCheckItem:line
  1727     line notNil ifTrue:[
  1741     line notNil ifTrue:[
  1728         (line includesString:'\c') ifTrue:[^ true].
  1742         (line includesString:'\c') ifTrue:[^ true].
  1874 
  1888 
  1875     (x < 0 
  1889     (x < 0 
  1876     or:[x >= width
  1890     or:[x >= width
  1877     or:[y < 0
  1891     or:[y < 0
  1878     or:[y >= height]]]) ifTrue:[
  1892     or:[y >= height]]]) ifTrue:[
  1879 	"
  1893         "
  1880 	 moved outside submenu, but not within self
  1894          moved outside submenu, but not within self
  1881 	"
  1895         "
  1882 	subMenuShown notNil ifTrue:[
  1896         subMenuShown notNil ifTrue:[
  1883 	    ^ self
  1897             ^ self
  1884 	].
  1898         ].
  1885 	superMenu notNil ifTrue:[
  1899         superMenu notNil ifTrue:[
  1886 	    superMenu regainControl
  1900             superMenu regainControl
  1887 	].
  1901         ].
  1888     ].
  1902     ].
  1889 
  1903 
  1890     newSelection := self positionToSelectionX:x y:y.
  1904     newSelection := self positionToSelectionX:x y:y.
  1891     newSelection ~= selection ifTrue:[
  1905     newSelection ~= selection ifTrue:[
  1892 	newSelection notNil ifTrue:[
  1906         newSelection notNil ifTrue:[
  1893 	    (enableFlags at:newSelection) ifFalse:[
  1907             (enableFlags at:newSelection) ifFalse:[
  1894 		newSelection := nil
  1908                 newSelection := nil
  1895 	    ]
  1909             ]
  1896 	].
  1910         ].
  1897 
  1911 
  1898 	self selection:newSelection.
  1912         subMenuShown notNil ifTrue:[
  1899 
  1913             self hideSubmenu.
  1900 	subMenuShown notNil ifTrue:[
  1914         ].
  1901 	    self hideSubmenu.
  1915 
  1902 	].
  1916         self selection:newSelection.
  1903     ].
  1917     ].
  1904 
  1918 
  1905     subMenu := nil.
  1919     subMenu := nil.
  1906     selection notNil ifTrue:[
  1920     selection notNil ifTrue:[
  1907 	subMenus notNil ifTrue:[
  1921         subMenus notNil ifTrue:[
  1908 	    x > (width // 2) ifTrue:[
  1922             x > (width // 2) ifTrue:[
  1909 		subMenu := (subMenus at:selection)
  1923                 subMenu := (subMenus at:selection)
  1910 	    ]
  1924             ]
  1911 	]
  1925         ]
  1912     ].
  1926     ].
  1913     subMenu notNil ifTrue:[
  1927     subMenu notNil ifTrue:[
  1914 	self showSubmenu:selection.
  1928         self showSubmenu:selection.
  1915     ] ifFalse:[
  1929     ] ifFalse:[
  1916 	subMenuShown notNil ifTrue:[
  1930         subMenuShown notNil ifTrue:[
  1917 	    self hideSubmenu.
  1931             self hideSubmenu.
  1918 	].
  1932         ].
  1919 	subMenuShown := nil
  1933         subMenuShown := nil
  1920     ]
  1934     ]
       
  1935 
       
  1936     "Modified: 8.3.1996 / 14:20:59 / cg"
  1921 !
  1937 !
  1922 
  1938 
  1923 showSubmenu:index
  1939 showSubmenu:index
  1924     "show subMenu at index"
  1940     "show subMenu at index"
  1925 
  1941 
  2376 ! !
  2392 ! !
  2377 
  2393 
  2378 !MenuView class methodsFor:'documentation'!
  2394 !MenuView class methodsFor:'documentation'!
  2379 
  2395 
  2380 version
  2396 version
  2381     ^ '$Header: /cvs/stx/stx/libwidg/MenuView.st,v 1.61 1996-03-07 18:49:04 cg Exp $'
  2397     ^ '$Header: /cvs/stx/stx/libwidg/MenuView.st,v 1.62 1996-03-08 13:44:36 cg Exp $'
  2382 ! !
  2398 ! !