From VisualWorks®, 7.6 of February 1, 2008 on February 1, 2008 at 1:11:53 pm (Dialog confirm: 'You are filing-in a Parcel source file!\\While this is possible it will not have\the same effect as loading the parcel.\None of the Parcel''s prerequisites will\be loaded and none of its load actions\will be performed.\\Are you sure you want to file-in?' withCRs) ifFalse: [self error: 'Parcel file-in abandoned. Choose terminate or close.'] <class> <name>MotifMenuController</name> <environment>UI</environment> <super>UI.MenuController</super> <private>false</private> none <imports></imports> <category>UILooks-Motif</category> <attributes> <package>MenuUICompatibility</package> </attributes> </class> <comment> UI.MotifMenuController
MotifMenuController defines behavior common for control of submenus with a MotifMenuView. It is used for the Motif look and feel style menus This class is private to the implementation of MenuView. Users should not use this class directly or subclass it. Class Variables: SubmenuAssumesSelection <Boolean> If true, allow a menu item with a submenu to assume selection. Otherwise no menu items with a submenu can be selected (standard OSF/Motif behavior).
</comment> <class> <name>MotifMenuFromMenuBarController</name> <environment>UI</environment> <super>UI.MotifMenuController</super> <private>false</private> none <imports></imports> <category>UIBasics-Controllers</category> <attributes> <package>MenuUICompatibility</package> </attributes> </class> <comment> UI.MotifMenuFromMenuBarController
A MotifMenuFromMenuBarController is the controller for a MotifMenuView that has been opened from a menu bar. It is used for the Motif look and feel. This class is private to the implementation of MenuView. Users should not use this class directly or subclass it.
</comment> <class> <name>MotifMenuAsSubmenuController</name> <environment>UI</environment> <super>UI.MotifMenuController</super> <private>false</private> none <imports></imports> <category>UIBasics-Controllers</category> <attributes> <package>MenuUICompatibility</package> </attributes> </class> <comment> UI.MotifMenuAsSubmenuController
A MotifMenuAsSubmenuController is the controller for a MotifMenuView that has been opened as a submenu from a parent MotifMenuItemView. It is used with the Motif look and feel. This class is private to the implementation of MenuView. Users should not use this class directly or subclass it.
</comment> <class> <name>MotifMenuItemController</name> <environment>UI</environment> <super>UI.MenuItemController</super> <private>false</private> none <imports></imports> <category>UILooks-Motif</category> <attributes> <package>MenuUICompatibility</package> </attributes> </class> <comment> UI.MotifMenuItemController
Instances of MotifMenuItemController are the standard Controller for MotifMenuItemViews. It is used for the Motif look and feel. This class is private to the implementation of MotifMenuItemView and MotifMenuView. Other users should not interface to this class and should not subclass it.
</comment> <name>SubmenuAssumesSelection</name> <environment>UI.Win95MenuController</environment> <private>false</private> <constant>false</constant> <category>setup</category> <initializer>true</initializer> <attributes> <package>MenuUICompatibility</package> </attributes> <name>SubmenuAssumesSelection</name> <environment>UI.MotifMenuController</environment> <private>false</private> <constant>false</constant> <category>setup</category> <initializer>true</initializer> <attributes> <package>MenuUICompatibility</package> </attributes> <methods> UI.MotifMenuController <category>events</category>
closeEvent: event "Don't shut down but allow a button pressed event to follow and possibily open another menu bar menu" self shutDownScrollProcess. ^nil
</methods> <methods> UI.MotifMenuController class <category>setup</category>
submenuAssumesSelection ^SubmenuAssumesSelection ifNil:[true]
submenuAssumesSelection: aBoolean "If true, extend OSF/Motif behavior and allow a menu item with a submenu to assume selection. If false, only a menu item without a submenu may assume selection (standard OSF/Motif behavior)" SubmenuAssumesSelection := aBoolean
</methods> <methods> UI.MotifMenuFromMenuBarController <category>events</category>
buttonPressedEvent: event state == #waitForMousePressed ifTrue: [state := #waitForReleaseToSelect]. (self viewHasCursorWithEvent: event) ifFalse: [self isControlWantedInMenuBarWithEvent: event. state := #finished. ^nil]. ^event
buttonReleasedEvent: event "Mouse button released between two menu items; no selection" (state ~~ #waitForReleaseToOpen or: [self viewHasCursorWithEvent: event]) ifFalse: [self view highlightedMenuItemView == nil ifTrue: [self view highlightSelectionMemoryMenuItem]. state := #waitForMousePressed]. state == #waitForReleaseToSelect ifTrue: [state := #finished. view noSelectedMenuItem. ^event]. ^nil
exposeEvent: event super exposeEvent: event. state := event anyButtonPressed ifTrue: [#waitForReleaseToOpen] ifFalse: [self view highlightedMenuItemView == nil ifTrue: [self view highlightSelectionMemoryMenuItem]. #waitForMousePressed]. ^nil
mouseMovedEvent: event super mouseMovedEvent: event. event anyButtonPressed ifTrue: [(self viewHasCursorWithEvent: event) ifTrue: [state == #waitForReleaseToOpen ifTrue: [state := #waitForReleaseToSelect]] ifFalse: [(self isControlWantedInMenuBarWithEvent: event) ifTrue: [state := #finished]]. ^event]. ^nil
</methods> <methods> UI.MotifMenuFromMenuBarController <category>privileged</category>
handlerToKeepForMouseEvent: aMouseEvent "If event targets any menu bar button then finish this submenu and answer nil. Otherwise answer the receiver" ^(self viewHasCursorWithEvent: aMouseEvent) ifTrue: [self] ifFalse: [self isControlWantedInMenuBarWithEvent: aMouseEvent. state := #finished. nil]
</methods> <methods> UI.MotifMenuFromMenuBarController <category>event driven</category>
releaseToOpen "Check if the user can and did use click-release to open this menu.Wait for and answer whether control is finally transferred from the menu bar button by the user releasing the mouse button (answer false if the user just moves off the menu bar button without releasing the menu bar button)." ^self view parentMenuBarButtonView canClickReleaseToOpenMenu
viewHasCursorWithEvent: event "Answer true if the cursor point of the receiver's sensor lies within the display box of the receiver's view. Controller|viewHasCursor is normally used in internal methods." view == nil ifTrue: [^false]. event hasPoint ifFalse: [^false]. ^(view bounds expandedBy: (Rectangle left: 0 right: 0 top: view insetWidthOfMenuBorder bottom: 0)) containsPoint: (self sensor mousePointForEvent: event)
</methods> <methods> UI.MotifMenuFromMenuBarController <category>cursor</category>
viewHasCursor "Answer true if the cursor point of the receiver's sensor lies within the display box of the receiver's view. Expand the bounds to include the border of a menu window pulled down from a menu bar." | sen | view == nil ifTrue: [^false]. sen := self sensor. ^sen isActive and: [(view bounds expandedBy: (Rectangle left: 0 right: 0 top: view borderTopThickness bottom: 0)) containsPoint: sen cursorPoint]
</methods> <methods> UI.MotifMenuAsSubmenuController <category>events</category>
buttonPressedEvent: event "If a button press is outside my bounds allow my parent menu to process it because the event might be intended to select an item in my parent menu" "Ignore bogus button pressed events caused by opening up the TransientWindow" state == #waitForReleaseToSelect ifTrue: [^nil]. (self handlerToKeepForMouseEvent: event) ifNotNil: [:targetController | targetController == self ifFalse: [| targetWindow | targetWindow := targetController view topComponent. targetWindow windowManager addEvent: (event window: targetWindow). ^event]]. state == #waitForMousePressed ifTrue: [state := #waitForReleaseToSelect. ^event]. ^nil
buttonReleasedEvent: event (self class submenuAssumesSelection and: [state == #waitForReleaseToSelect]) ifTrue: [state := #finished. view noSelectedMenuItem. ^event]. view highlightedMenuItemView ifNil: [state := #waitForMousePressed. view highlightNextMenuItem. ^event]. state == #waitForReleaseToSelect ifTrue: [(self parentViewHasCursorWithEvent: event) ifFalse: [state := #finished. view noSelectedMenuItem. ^event]. ^nil]. ^nil
exposeEvent: event super exposeEvent: event. state := event anyButtonPressed ifTrue: [#waitForReleaseToSelect] ifFalse: [#waitForMousePressed]. ^nil
mouseMovedEvent: event "If the cursor moves to a new item in a parent menu or menu bar close the submenu. Otherwise, keep the submenu open. Compensate for the global origin offset of the translating sensor" event anyButtonPressed ifTrue: [((view bounds expandedBy: self leftEdgeOffset @ 0) containsPoint: (sensor cursorPointFor: event)) ifFalse: [view parentMenuItemView ifNil: [^nil]. (self isControlWantedInMenuBarWithEvent: event) ifTrue: [self finishAllParents. ^event]. self finishOnNextParentItemWithEvent: event]. ^super mouseMovedEvent: event]. ^nil
</methods> <methods> UI.MotifMenuAsSubmenuController <category>privileged</category>
finishOnNextParentItemWithEvent: event "If the cursor has moved to a new item in any parent menu then finish this submenu and answer true" | parentItemView result | state = #finished ifTrue: [^true]. parentItemView := view parentMenuItemView. result := parentItemView isNil or: [parentItemView isOpen not or: [(parentItemView controller isChildControlActiveWithEvent: event) not and: [| parentMenuController | parentMenuController := parentItemView menuView controller. (parentMenuController isMenuItemControlActiveWithEvent: event) or: [parentMenuController finishOnNextParentItemWithEvent: event]]]]. result ifTrue: [state := #finished]. ^result
handlerToKeepForMouseEvent: event "If event targets any predecessor menu then finish this submenu and answer the target controller. Answer nil and finish all if the event lies outside all menus " | targetController | targetController := (self viewHasCursorWithEvent: event) ifTrue: [self] ifFalse: [view parentMenuItemView ifNotNil: [:parentItemView | parentItemView menuView controller handlerToKeepForMouseEvent: event]]. targetController == self ifFalse: [state := #finished]. ^targetController
parentViewHasCursorWithEvent: event "Answer whether the receiver should retain control of any predecessor menu. If the cursor is in any menu item view from whose ancestry the receiver view has opened then let the receiver retain control. Compare with MenuItemController>>isChildControlActiveWithEvent:" ^view parentMenuItemView ifNil: [false] ifNotNil: [:parentItemView | (parentItemView controller viewHasCursorWithEvent: event) or: [parentItemView menuView controller parentViewHasCursorWithEvent: event]]
</methods> <methods> UI.MotifMenuAsSubmenuController <category>initialize-release</category>
initialize "Initialize the receiver to assume the mouse is pressed." super initialize. state := #waitForMousePressed
</methods> <methods> UI.MotifMenuAsSubmenuController <category>private</category>
leftEdgeOffset ^3
</methods> <methods> UI.MotifMenuItemController <category>events</category>
mouseMovedEvent: event super mouseMovedEvent: event. (event anyButtonPressed and: [self view menuItem hasSubmenu]) ifTrue: [self view openSubMenu]
</methods> <methods> UI.MotifMenuItemView <category>privileged-selection</category>
assumeSelection "The receiver is to become the 'selected' highlighted menu item. Usually sent from the controller." self menuView highlightedMenuItemView: self.
</methods> <methods> UI.MotifMenuItemView <category>controller accessing</category>
defaultControllerClass "Answer the class of the default controller for the receiver." ^MotifMenuItemController
</methods> <methods> UI.MotifMenuItemView <category>privileged-selection</category>
openSubMenu self menuView controller waitToOpenSubmenu. super openSubMenu.
openSubMenuByKey "Open the submenu of this menu item with a default item highlighted." self upcastEvent: #triggerEvent: with: (Array with: #submenuOpened: with: model nameKey). (self subMenuViewClass model: model submenu) highlightSelectionMemoryMenuItem; openFromParentMenuItemView: self. self upcastEvent: #triggerEvent: with: (Array with: #submenuClosed: with: model nameKey).
</methods> <methods> UI.MacOSXMenuItemView <category>privileged-selection</category>
finalizeSelection "The user has indicated completion of menu item selection while over this menu item. So if this menu item is enabled, this is the selected menu item. This message is sent from the controller." self isEnabled ifTrue: [self menuView highlightMenuItemView: self flashRepeat: 1 delayedBy: 90. self menuView selectedMenuItem: self model] ifFalse: [self menuView noSelectedMenuItem].
</methods> <methods> UI.MenuItemController <category>events</category>
buttonReleasedEvent: event self view menuItem hasSubmenu ifFalse: [self sensorNoButtonPressed]
</methods> <methods> UI.Win95MenuController class <category>setup</category>
submenuAssumesSelection ^SubmenuAssumesSelection ifNil:[true]
submenuAssumesSelection: aBoolean "If true, extend MS Windows behavior and allow a menu item with a submenu to assume selection. If false, only a menu item without a submenu may assume selection (standard MS Windows behavior)" SubmenuAssumesSelection := aBoolean
</methods> <methods> UI.Win95MenuController <category>events</category>
finishAllParents (self class submenuAssumesSelection and: [self isMenuItemControlActive]) ifFalse: [super finishAllParents]
handleEvent: event "In the OS-Window System world, we only need to know if someone has hit outside of the menu which includes outside the window the menu is popped in" (event isWindowExit not or: [state == #waitForMouse or: [self viewHasCursorWithEvent: event]]) ifFalse: [self finishAllParents. self shutDownScrollProcess. ^event]. ^super handleEvent: event
</methods> <methods> UI.MacMenuItemView <category>privileged-selection</category>
assumeSelection "The receiver is to become the 'selected' highlighted menu item. Usually sent from the controller." self menuView highlightedMenuItemView: self. (self menuItem hasSubmenu and: [self isEnabled]) ifTrue: [self openSubMenuDelayedBy: 300]
assumeSelectionByKey "The receiver is to become the 'selected' highlighted menu item. Usually sent from the controller." self menuView highlightedMenuItemView: self.
finalizeSelection "The user has indicated completion of menu item selection while over this menu item. So if this menu item is enabled, this is the selected menu item. This message is sent from the controller." self isEnabled ifTrue: [self menuView highlightMenuItemView: self flashRepeat: 3 delayedBy: 40. self menuView selectedMenuItem: self model] ifFalse: [self menuView noSelectedMenuItem].
openSubMenuByKey "Open the submenu of this menu item." | submenuView | self upcastEvent: #triggerEvent: with: (Array with: #submenuOpened: with: model nameKey). (submenuView := self subMenuViewClass model: model submenu) highlightedMenuItemView: submenuView menuItemViewsAsCollection first; openFromParentMenuItemView: self. self upcastEvent: #triggerEvent: with: (Array with: #submenuClosed: with: model nameKey).
</methods> <methods> UI.Win95MenuAsSubmenuController <category>privileged</category>
finishAllParents "Finish and close all parent menus" view parentMenuItemView ifNotNil: [:parentItemView | parentItemView menuView controller finishAllParents]. super finishAllParents
finishOnNextParentItemWithEvent: event "If the cursor has moved to a new item in any parent menu then finish this submenu and answer true" | parentItemView result | state = #finished ifTrue: [^true]. parentItemView := view parentMenuItemView. result := parentItemView isNil or: [parentItemView isOpen not or: [(parentItemView controller isChildControlActiveWithEvent: event) not and: [| parentMenuController | parentMenuController := parentItemView menuView controller. (parentMenuController isMenuItemControlActiveWithEvent: event) or: [parentMenuController finishOnNextParentItemWithEvent: event]]]]. result ifTrue: [state := #finished]. ^result
</methods> <methods> UI.Win95MenuAsSubmenuController <category>events</category>
handleEvent: event (self class submenuAssumesSelection not and: [self parentViewHasCursorWithEvent: event]) ifTrue: [^nil]. ^super handleEvent: event
</methods> <methods> UI.Win95MenuAsSubmenuController <category>privileged</category>
parentViewHasCursorWithEvent: event "Answer whether the receiver should retain control of any ancestor menu. If the cursor is in any menu item view from whose ancestry the receiver view has opened then let the receiver retain control. Compare with MenuItemController>>isChildControlActiveWithEvent:" ^view parentMenuItemView ifNil: [false] ifNotNil: [:parentItemView | (parentItemView controller viewHasCursorWithEvent: event) or: [parentItemView menuView controller parentViewHasCursorWithEvent: event]]
</methods> <methods> UI.MenuView <category>privileged-current selection</category>
highlightFirstMenuItem "Hilight the first enabled menu item" highlightedMenuItemView ifNil: [self highlightNextMenuItem]
highlightMenuItemView: aMenuItemView flashRepeat: repeatTimes delayedBy: milliseconds | delay | delay := Delay forMilliseconds: milliseconds. repeatTimes timesRepeat: [self highlightedMenuItemView: aMenuItemView. delay wait. self highlightedMenuItemView: nil. delay wait]. self highlightedMenuItemView: aMenuItemView. delay wait.
</methods> <methods> UI.MenuView <category>private</category>
parentMenuBarButtonView "Answer the parent menu bar button view (or nil if none)." ^parentMenuBarButtonView ifNil: [parentMenuItemView ifNotNil: [parentMenuItemView menuView parentMenuBarButtonView]]
</methods> <methods> UI.MenuView <category>privileged-parent menu</category>
parentMenuItemSelected "Answer if the menu item that is the parent of the this menu is selected, or false if none exists" ^parentMenuItemView ifNil: [false] ifNotNil: [parentMenuItemView isSelection]
</methods> <methods> UI.MenuView <category>privileged-current selection</category>
returnToParentOrMenuToLeft "Close the receiver and return to the parent menu item view or the menu to the left on the menu bar." self noSelectedMenuItem. parentMenuItemView ifNil: [self highlightPreviousMenuBarButton]
</methods> <methods> UI.MenuView <category>privileged-parent menu</category>
submenuClosed "A submenu of one of self's menu items has closed and it is notifying self. If the selection isn't finalized, I may have to worry about repairing damage on myself or my parent menu." self selectionFinalized ifTrue: [^self]. self topComponent ifNotNil: [:win | win repairDamages]. parentMenuItemView ifNotNil: [parentMenuItemView menuView submenuClosed]
</methods> <methods> UI.MenuController <category>events</category>
closeEvent: event self finishAllParents. self shutDownScrollProcess. ^nil
</methods> <methods> UI.MenuController <category>privileged</category>
finishAllParents state := #finished. self processEscape
finishOnNextParentItemWithEvent: aMouseEvent ^false
handlerToKeepForMouseEvent: aMouseEvent "If event targets any menu bar button then finish this submenu and answer nil. Otherwise answer the receiver" ^(self viewHasCursorWithEvent: aMouseEvent) ifTrue: [self] ifFalse: [state := #finished. nil]
parentViewHasCursorWithEvent: event ^false
</methods> <methods> UI.MenuController <category>protected-keyboard</category>
processRightKey "Perform the standard action when the right arrow is pressed." "By default, when the highlighted menu item hasSubmenu, then open the submenu." state := #waitForMouse. self view openSubMenuOrMenuToRight
</methods> <methods> UI.MenuController <category>privileged</category>
waitToOpenSubmenu state := #waitForMousePressed
</methods> <methods> UI.MenuItemView <category>selection-privileged</category>
openSubMenuDelayedBy: delayMilliseconds "Open the submenu of this menu item if it is still selected after delayMilliseconds" [(Delay forMilliseconds: delayMilliseconds) wait. [(self isSelection and: [self isOpen]) ifTrue: [self openSubMenu]] uiEvent] fork
</methods> <methods> UI.MacOSXMenuAsSubmenuController <category>events</category>
buttonPressedEvent: event "A button press toggles my mode. No button press outside my window will enter here in an event based control system" state == #waitForMousePressed ifTrue: [state := #waitForReleaseToSelect. ^event]. ^nil
</methods> <methods> UI.MacOSXMenuAsSubmenuController <category>privileged</category>
finishOnNextParentItemWithEvent: event "If the cursor has moved to a new item in any parent menu then finish this submenu and answer true" | parentItemView result | state = #finished ifTrue: [^true]. parentItemView := view parentMenuItemView. result := parentItemView isNil or: [parentItemView isOpen not or: [(parentItemView controller isChildControlActiveWithEvent: event) not and: [| parentMenuController | parentMenuController := parentItemView menuView controller. (parentMenuController isMenuItemControlActiveWithEvent: event) or: [parentMenuController finishOnNextParentItemWithEvent: event]]]]. result ifTrue: [state := #finished]. ^result
</methods> <methods> UI.MacOSXMenuAsSubmenuController <category>private</category>
leftEdgeOffset ^3
</methods> <methods> UI.MacOSXMenuAsSubmenuController <category>events</category>
mouseMovedEvent: event "If the cursor moves to a new item in a parent menu or menu bar close the submenu. Otherwise, keep the submenu open. Compensate for the global origin offset of the translating sensor" ((view bounds expandedBy: self leftEdgeOffset @ 0) containsPoint: (sensor cursorPointFor: event)) ifFalse: [view parentMenuItemView ifNil: [^nil]. (self isControlWantedInMenuBarWithEvent: event) ifTrue: [self finishAllParents. ^event]. self finishOnNextParentItemWithEvent: event]. ^super mouseMovedEvent: event
</methods> <methods> UI.Win95MenuFromMenuButtonController <category>events</category>
buttonPressedEvent: event hadFirstButtonPress := true. state == #waitForMousePressed ifTrue: [state := #waitForReleaseToSelect]. (self viewHasCursorWithEvent: event) ifFalse: [self isControlWantedInMenuBarWithEvent: event. state := #finished. ^nil]. ^event
</methods> <methods> UI.Win95MenuItemView <category>privileged-selection</category>
assumeSelection "The receiver is to become the 'selected' highlighted menu item. Usually sent from the controller." self menuView highlightedMenuItemView: self. (self menuItem hasSubmenu and: [self isEnabled]) ifTrue: [self openSubMenuDelayedBy: 300]
</methods> <methods> UI.MacMenuView <category>privileged-current selection</category>
highlightNextMenuItem "Hilight the next enabled menu item, if any (after the one currently highlighted). Don't wrap to first item in menu" | flatMenuViews nextHighlight | flatMenuViews := self menuItemViewsAsCollection. nextHighlight := highlightedMenuItemView == nil ifTrue: [1] ifFalse: [(flatMenuViews indexOf: highlightedMenuItemView) + 1]. nextHighlight to: flatMenuViews size do: [:index | | nextMenuItemView | (nextMenuItemView := flatMenuViews at: index) isEnabled ifTrue: [highlightedMenuItemView == nil ifFalse: [highlightedMenuItemView resignSelection]. nextMenuItemView assumeSelectionByKey. ^self]]
highlightPreviousMenuItem "Hilight the previous enabled menu item, if any (after the one currently highlighted). Don't wrap to last item in menu" | flatMenuViews nextHighlight | flatMenuViews := self menuItemViewsAsCollection. nextHighlight := highlightedMenuItemView == nil ifTrue: [flatMenuViews size] ifFalse: [(flatMenuViews indexOf: highlightedMenuItemView) - 1]. (nextHighlight to: 1 by: -1) do: [:index | | nextMenuItemView | (nextMenuItemView := flatMenuViews at: index) isEnabled ifTrue: [highlightedMenuItemView == nil ifFalse: [highlightedMenuItemView resignSelection]. nextMenuItemView assumeSelectionByKey. ^self]]
</methods> <methods> UI.MacMenuView <category>privileged-parent view</category>
openFromMenuBarButton: theParentMenuBarButtonView "Open the menu as a menu appearing from a menu button on a menu bar (the parentMenuBarButtonView). The user will be given the opportunity to make a selection. Answer the value object associated with the menu item that was selected (or nil if none)." | theScreen parentDisplayBox monitorRectangle wrappedMenu menuWindowBounds intoMonitor menuWindow | parentMenuBarButtonView := theParentMenuBarButtonView. self controller: MacOSXMenuFromMenuBarController new. (self prepareMenuItemViewsToMinWidth: 0) ifFalse: [^nil]. theScreen := theParentMenuBarButtonView graphicsDevice. parentDisplayBox := self displayBoxOfView: theParentMenuBarButtonView. monitorRectangle := (theScreen preferredRectangleToConstrain: parentDisplayBox) insetBy: 4. wrappedMenu := self withBoundedWrapper. menuWindowBounds := wrappedMenu preferredBounds. menuWindowBounds := menuWindowBounds align: menuWindowBounds topLeft with: parentDisplayBox bottomLeft. "Adjust to fit between left and right sides of monitor." intoMonitor := menuWindowBounds amountToTranslateWithin: monitorRectangle. menuWindowBounds := menuWindowBounds translatedBy: intoMonitor. menuWindowBounds := menuWindowBounds intersect: monitorRectangle. "Need to eventually adjust if the intersection makes the bounds too small." menuWindow := self menuWindowOn: theScreen in: menuWindowBounds. self setColorsInMenuWindow: menuWindow from: theParentMenuBarButtonView. wrappedMenu bounds: (0@0 extent: menuWindowBounds extent). menuWindow component: wrappedMenu. self mapAndStartupEventDriven: menuWindow. parentMenuBarButtonView topComponent becomeActive. ^self selectedValue
openFromParentMenuItemView: theParentMenuItemView "Open the receiver as a child menu of the given parent MenuItemView. Allow the user to make a selection. Answer the menu item that was selected (or nil if none)." | theScreen parentDisplayBox monitorRectangle wrappedMenu menuWindowBounds intoMonitor menuWindow theSelectionMemoryMenuItem positioningMenuItemView offsetForMenuItem | parentMenuItemView := theParentMenuItemView. self controller: MacOSXMenuAsSubmenuController new. (self prepareMenuItemViewsToMinWidth: 0) ifFalse: [^nil]. theScreen := theParentMenuItemView graphicsDevice. parentDisplayBox := self displayBoxOfView: parentMenuItemView. monitorRectangle := (theScreen preferredRectangleToConstrain: parentDisplayBox) insetBy: 4. wrappedMenu := self withBoundedWrapper. menuWindowBounds := wrappedMenu preferredBounds. menuWindowBounds height: (menuWindowBounds height min: monitorRectangle height). wrappedMenu bounds: (0 @ 0 extent: menuWindowBounds extent). menuWindow := self menuWindowOn: theScreen in: menuWindowBounds. menuWindow component: wrappedMenu. "Position last selected menu item next to parent menu item." theParentMenuItemView menuView usedSelectionMemory ifTrue: [usedSelectionMemory := true. theSelectionMemoryMenuItem := self menu selectionMemory. self menuItemViewsAsCollection do: [:each | each menuItem == theSelectionMemoryMenuItem ifTrue: [positioningMenuItemView := each]]]. positioningMenuItemView == nil ifTrue: [offsetForMenuItem := 0 @ 0] ifFalse: [offsetForMenuItem := positioningMenuItemView localPointToGlobal: positioningMenuItemView bounds origin]. menuWindow moveTo: parentDisplayBox topRight + self topRightOffsetAsChildMenu - offsetForMenuItem. "Adjust to fit between left and right sides of monitor." intoMonitor := menuWindow displayBox amountToTranslateWithin: monitorRectangle. "Better submenu accessibility at the right monitor border" intoMonitor x < 0 ifTrue: [menuWindow moveTo: monitorRectangle corner x @ menuWindow globalOrigin y. intoMonitor x: parentMenuItemView topComponent globalOrigin x - monitorRectangle corner x - (self bounds width - 9)]. "A Menu should be positioned inside the monitors bounds, and the beginning of the labels should be readable" menuWindow moveTo: (menuWindow globalOrigin x + intoMonitor x max: 0) @ (menuWindow globalOrigin y + intoMonitor y). self setColorsInMenuWindow: menuWindow from: theParentMenuItemView. self mapAndStartupEventDriven: menuWindow. self selectedValue ifNotNil: [:value | theParentMenuItemView menuView childSelectionValue: value]
</methods> <methods> UI.MacMenuView <category>privileged-current selection</category>
openSubMenuOrMenuToRight "Open the submenu (if there is one) otherwise close the receiver and open the menu to the right on the menu bar." highlightedMenuItemView ifNil: [self highlightNextMenuItem] ifNotNil: [(highlightedMenuItemView menuItem hasSubmenu and: [highlightedMenuItemView menuItem isEnabled]) ifTrue: [highlightedMenuItemView openSubMenuByKey] ifFalse: [self noSelectedMenuItem. self highlightNextMenuBarButton]]
</methods> <methods> UI.MenuAsSubmenuController <category>events</category>
buttonPressedEvent: event "If button down is not in my area, I need to give it to my parent menu because the press event might be intended to select an item in my parent menu" "Ignore bogus button pressed events caused by opening up the TransientWindow" state == #waitForReleaseToSelect ifTrue: [^nil]. (self handlerToKeepForMouseEvent: event) ifNil: [^nil]. state == #waitForMousePressed ifTrue: [state := #waitForReleaseToSelect. ^event]. ^nil
</methods> <methods> UI.MenuAsSubmenuController <category>privileged</category>
parentViewHasCursorWithEvent: event "Answer whether the receiver should retain control of any ancestor menu. If the cursor is in any menu item view from whose ancestry the receiver view has opened then let the receiver retain control. Compare with MenuItemController>>isChildControlActiveWithEvent:" ^view parentMenuItemView ifNil: [false] ifNotNil: [:parentItemView | (parentItemView controller viewHasCursorWithEvent: event) or: [parentItemView menuView controller parentViewHasCursorWithEvent: event]]
</methods> <methods> UI.MenuFromMenuButtonController <category>events</category>
buttonPressedEvent: event "A button press toggles my mode. No button press outside my window will enter here in an event based control system" state == #waitForReleaseToSelect ifTrue: [^nil]. state == #waitForMousePressed ifTrue: [state := #waitForReleaseToSelect. ^event]. ^nil
buttonReleasedEvent: event "Mouse button released between two menu items: no selection" state == #waitForReleaseToSelect ifTrue: [state := #finished. view noSelectedMenuItem. ^event]. ^nil
exposeEvent: event super exposeEvent: event. state := #waitForMousePressed. ^nil
handleEvent: event "In the OS-Window System world, we only need to know if someone has hit outside of the menu which includes outside the window the menu is popped in" (event isButtonPressedEvent not or:[self viewHasCursorWithEvent: event]) ifFalse: [self processEscape. self shutDownScrollProcess. ^event]. ^super handleEvent: event
</methods> <methods> UI.MenuBarButtonController <category>privileged</category>
isControlWantedByOtherMenuBarButton "Answer whether another menu bar button on the same menu bar wants control." self view menuBar menuButtons do: [:each | each == self view ifFalse: [((each bounds containsPoint: each controller sensor cursorPoint) and: [each isEnabled]) ifTrue: [self view menuBar highlightThisMenuBarButton: each. ^true]]]. ^false
</methods> <methods> UI.MacOSXMenuController <category>control defaults</category>
handleEvent: event "We test only if someone has hit outside of the menu which includes outside the window the menu is popped in" (event isButtonPressedEvent not or: [state == #waitForMouse or: [self viewHasCursorWithEvent: event]]) ifFalse: [self finishAllParents. self shutDownScrollProcess. ^event]. ^super handleEvent: event
</methods> <methods> UI.MacOSXMenuController <category>protected-keyboard</category>
processOtherKey: aKeyboardEvent "Tab to buttons left or right in the menu bar" (KeyboardProcessor new isBackTab: aKeyboardEvent) ifTrue: [^self view noSelectedMenuItem highlightPreviousMenuBarButton]. aKeyboardEvent keyValue == Character tab ifTrue: [^self view noSelectedMenuItem highlightNextMenuBarButton]. super processOtherKey: aKeyboardEvent
</methods> <methods> UI.MotifMenuView <category>privileged-current selection</category>
highlightNextMenuItem "Hilight the next enabled menu item (after the one currently highlighted). Wrap to the first item and beyond if necessary" | flatMenuViews nextHighlight itemsSize | flatMenuViews := self menuItemViewsAsCollection. itemsSize := flatMenuViews size. nextHighlight := highlightedMenuItemView == nil ifTrue: [1] ifFalse: [(flatMenuViews indexOf: highlightedMenuItemView) + 1]. nextHighlight to: nextHighlight + itemsSize do: [:step | | index nextMenuItemView | index := (step - 1) \\ itemsSize + 1. (nextMenuItemView := flatMenuViews at: index) isEnabled ifTrue: [highlightedMenuItemView == nil ifFalse: [highlightedMenuItemView resignSelection]. nextMenuItemView assumeSelection. ^self]]
highlightPreviousMenuItem "Hilight the previous enabled menu item (before the one currently highlighted). Wrap to the last item and beyond if necessary" | flatMenuViews nextHighlight itemsSize | flatMenuViews := self menuItemViewsAsCollection. itemsSize := flatMenuViews size. nextHighlight := highlightedMenuItemView == nil ifTrue: [itemsSize] ifFalse: [(flatMenuViews indexOf: highlightedMenuItemView) - 1]. (nextHighlight to: nextHighlight - itemsSize by: -1) do: [:step | | index nextMenuItemView | index := (step - 1) \\ itemsSize + 1. (nextMenuItemView := flatMenuViews at: index) isEnabled ifTrue: [highlightedMenuItemView == nil ifFalse: [highlightedMenuItemView resignSelection]. nextMenuItemView assumeSelection. ^self]]
</methods> <methods> UI.MotifMenuView <category>privileged-parent view</category>
openFromMenuBarButton: theParentMenuBarButtonView "Open the menu as a menu appearing from a menu button on a menu bar (the parentMenuBarButtonView). The user will be given the opportunity to make a selection. Answer the value object associated with the menu item that was selected (or nil if none)." | theScreen parentDisplayBox monitorRectangle wrappedMenu menuWindowBounds intoMonitor menuWindow | parentMenuBarButtonView := theParentMenuBarButtonView. self controller: MotifMenuFromMenuBarController new. (self prepareMenuItemViewsToMinWidth: 0) ifFalse: [^nil]. theScreen := theParentMenuBarButtonView graphicsDevice. parentDisplayBox := self displayBoxOfView: theParentMenuBarButtonView. monitorRectangle := (theScreen preferredRectangleToConstrain: parentDisplayBox) insetBy: 4. wrappedMenu := self withBoundedWrapper. menuWindowBounds := wrappedMenu preferredBounds. menuWindowBounds := menuWindowBounds align: menuWindowBounds topLeft with: parentDisplayBox bottomLeft. "Adjust to fit between left and right sides of monitor." intoMonitor := menuWindowBounds amountToTranslateWithin: monitorRectangle. menuWindowBounds := menuWindowBounds translatedBy: intoMonitor. menuWindowBounds := menuWindowBounds intersect: monitorRectangle. "Need to eventually adjust if the intersection makes the bounds too small." menuWindow := self menuWindowOn: theScreen in: menuWindowBounds. self setColorsInMenuWindow: menuWindow from: theParentMenuBarButtonView. wrappedMenu bounds: (0@0 extent: menuWindowBounds extent). menuWindow component: wrappedMenu. self mapAndStartupEventDriven: menuWindow. parentMenuBarButtonView topComponent becomeActive. ^self selectedValue
openFromParentMenuItemView: theParentMenuItemView "Open the receiver as a child menu of the given parent MenuItemView. Allow the user to make a selection. Answer the menu item that was selected (or nil if none)." | theScreen parentDisplayBox monitorRectangle wrappedMenu menuWindowBounds intoMonitor menuWindow theSelectionMemoryMenuItem positioningMenuItemView offsetForMenuItem | parentMenuItemView := theParentMenuItemView. self controller: MotifMenuAsSubmenuController new. (self prepareMenuItemViewsToMinWidth: 0) ifFalse: [^nil]. theScreen := theParentMenuItemView graphicsDevice. parentDisplayBox := self displayBoxOfView: parentMenuItemView. monitorRectangle := (theScreen preferredRectangleToConstrain: parentDisplayBox) insetBy: 4. wrappedMenu := self withBoundedWrapper. menuWindowBounds := wrappedMenu preferredBounds. menuWindowBounds height: (menuWindowBounds height min: monitorRectangle height). wrappedMenu bounds: (0 @ 0 extent: menuWindowBounds extent). menuWindow := self menuWindowOn: theScreen in: menuWindowBounds. menuWindow component: wrappedMenu. "Position last selected menu item next to parent menu item." theParentMenuItemView menuView usedSelectionMemory ifTrue: [usedSelectionMemory := true. theSelectionMemoryMenuItem := self menu selectionMemory. self menuItemViewsAsCollection do: [:eachView | eachView menuItem == theSelectionMemoryMenuItem ifTrue: [positioningMenuItemView := eachView]]]. offsetForMenuItem := positioningMenuItemView == nil ifTrue: [0 @ 0] ifFalse: [positioningMenuItemView localPointToGlobal: positioningMenuItemView bounds origin]. menuWindow moveTo: parentDisplayBox topRight + self topRightOffsetAsChildMenu - offsetForMenuItem. "Adjust to fit between left and right sides of monitor." intoMonitor := menuWindow displayBox amountToTranslateWithin: monitorRectangle. menuWindow moveTo: menuWindow globalOrigin + intoMonitor. self setColorsInMenuWindow: menuWindow from: theParentMenuItemView. self mapAndStartupEventDriven: menuWindow. selectionFinal == true ifTrue: [theParentMenuItemView menuView childSelectionValue: self selectedValue]
</methods> <methods> UI.MotifMenuView <category>privileged-current selection</category>
openSubMenuOrMenuToRight "Open the submenu (if there is one) otherwise close the receiver and open the menu to the right on the menu bar." (highlightedMenuItemView ~~ nil and: [highlightedMenuItemView menuItem hasSubmenu and: [highlightedMenuItemView menuItem isEnabled]]) ifTrue: [highlightedMenuItemView openSubMenuByKey] ifFalse: [self noSelectedMenuItem. self highlightNextMenuBarButton]
selectHighlightedMenuItem self highlightedMenuItemView ifNotNil: [:item | (item menuItem hasSubmenu and: [item isEnabled]) ifTrue: [item openSubMenuByKey] ifFalse: [super selectHighlightedMenuItem]]
</methods> <methods> UI.Win95MenuItemController <category>events</category>
buttonPressedEvent: event Win95MenuController submenuAssumesSelection ifTrue: [self view isSelection ifFalse: [self view assumeSelection]] ifFalse: [super buttonPressedEvent: event]. self view topMenuView controller buttonPressedEvent: event
buttonReleasedEvent: event Win95MenuController submenuAssumesSelection ifTrue: [self sensorNoButtonPressed] ifFalse: [super buttonReleasedEvent: event]
redButtonPressedEvent: event Win95MenuController submenuAssumesSelection ifTrue: [self view isSelection ifFalse: [self view assumeSelection]] ifFalse: [super redButtonPressedEvent: event]
redButtonReleasedEvent: event Win95MenuController submenuAssumesSelection ifTrue: [self sensorNoButtonPressed] ifFalse: [super redButtonReleasedEvent: event]
</methods> "Imported Classes:" self error: 'Attempting to file-in parcel imports. Choose terminate or close' <class> <name>MenuView</name> <environment>UI</environment> <super>UI.CompositeView</super> <private>false</private> none menuItemViews parentMenuItemView selectedValue selectionFinal highlightedMenuItemView usedSelectionMemory parentMenuBarButtonView commonTextIndent <imports></imports> <category>UIBasics-Components</category> <attributes> <package>UIBasics-Components</package> </attributes> </class> <class> <name>MacMenuView</name> <environment>UI</environment> <super>UI.MenuView</super> <private>false</private> none <imports></imports> <category>UILooks-Mac</category> <attributes> <package>UILooks-Mac</package> </attributes> </class> <class> <name>MenuItemController</name> <environment>UI</environment> <super>UI.Controller</super> <private>false</private> none <imports></imports> <category>UIBasics-Controllers</category> <attributes> <package>UIBasics-Controllers</package> </attributes> </class> <class> <name>MenuController</name> <environment>UI</environment> <super>UI.Controller</super> <private>false</private> none scrollWrapper state isEventDriven eventDispatcher scrollProcess <imports></imports> <category>UIBasics-Controllers</category> <attributes> <package>UIBasics-Controllers</package> </attributes> </class> <class> <name>MenuAsSubmenuController</name> <environment>UI</environment> <super>UI.MenuController</super> <private>false</private> none <imports></imports> <category>UIBasics-Controllers</category> <attributes> <package>UIBasics-Controllers</package> </attributes> </class> <class> <name>MenuItemView</name> <environment>UI</environment> <super>UI.View</super> <private>false</private> none menuView <imports></imports> <category>UIBasics-Components</category> <attributes> <package>UIBasics-Components</package> </attributes> </class> <class> <name>Win95MenuItemView</name> <environment>UI</environment> <super>UI.MenuItemView</super> <private>false</private> none composedLabel composedCharacter accessCharacter accessIndicator accessIndicatorThickness <imports></imports> <category>UILooks-MSWin</category> <attributes> <package>UILooks-MSWin</package> </attributes> </class> <class> <name>MotifMenuView</name> <environment>UI</environment> <super>UI.MenuView</super> <private>false</private> none usedAccessCharacters shortcutColumnIndent backgroundColor <imports></imports> <category>UILooks-Motif</category> <attributes> <package>UILooks-Motif</package> </attributes> </class> <class> <name>MotifMenuItemView</name> <environment>UI</environment> <super>UI.MenuItemView</super> <private>false</private> none composedLabel composedCharacter accessCharacter accessIndicator accessIndicatorThickness <imports></imports> <category>UILooks-Motif</category> <attributes> <package>UILooks-Motif</package> </attributes> </class> <class> <name>Win95MenuController</name> <environment>UI</environment> <super>UI.MenuController</super> <private>false</private> none <imports></imports> <category>UILooks-MSWin</category> <attributes> <package>UILooks-MSWin</package> </attributes> </class> <class> <name>Win95MenuItemController</name> <environment>UI</environment> <super>UI.MenuItemController</super> <private>false</private> none <imports></imports> <category>UILooks-MSWin</category> <attributes> <package>UILooks-MSWin</package> </attributes> </class> <class> <name>MenuFromMenuButtonController</name> <environment>UI</environment> <super>UI.MenuController</super> <private>false</private> none <imports></imports> <category>UIBasics-Controllers</category> <attributes> <package>UIBasics-Controllers</package> </attributes> </class> <class> <name>MacOSXMenuController</name> <environment>UI</environment> <super>UI.MenuController</super> <private>false</private> none <imports></imports> <category>UILooks-MacOSX</category> <attributes> <package>UILooks-MacOSX</package> </attributes> </class> <class> <name>MenuBarButtonController</name> <environment>UI</environment> <super>UI.Controller</super> <private>false</private> none <imports></imports> <category>UIBasics-Controllers</category> <attributes> <package>UIBasics-Controllers</package> </attributes> </class> <class> <name>MacMenuItemView</name> <environment>UI</environment> <super>UI.MenuItemView</super> <private>false</private> none composedLabel composedCharacter <imports></imports> <category>UILooks-Mac</category> <attributes> <package>UILooks-Mac</package> </attributes> </class> <class> <name>Win95MenuFromMenuButtonController</name> <environment>UI</environment> <super>UI.Win95MenuController</super> <private>false</private> none hadFirstButtonPress <imports></imports> <category>UILooks-MSWin</category> <attributes> <package>UILooks-MSWin</package> </attributes> </class> <class> <name>MacOSXMenuAsSubmenuController</name> <environment>UI</environment> <super>UI.MacOSXMenuController</super> <private>false</private> none <imports></imports> <category>UILooks-MacOSX</category> <attributes> <package>UILooks-MacOSX</package> </attributes> </class> <class> <name>Win95MenuAsSubmenuController</name> <environment>UI</environment> <super>UI.Win95MenuController</super> <private>false</private> none <imports></imports> <category>UILooks-MSWin</category> <attributes> <package>UILooks-MSWin</package> </attributes> </class> <class> <name>MacOSXMenuItemView</name> <environment>UI</environment> <super>UI.MacMenuItemView</super> <private>false</private> none <imports></imports> <category>UILooks-MacOSX</category> <attributes> <package>UILooks-MacOSX</package> </attributes> </class>