import { ISequence } from '../algorithm/sequence'; import { Message } from '../core/messaging'; import { Keymap } from './keymap'; import { Menu } from './menu'; import { Title } from './title'; import { Widget } from './widget'; /** * A widget which displays menus as a canonical menu bar. */ export declare class MenuBar extends Widget { /** * Construct a new menu bar. * * @param options - The options for initializing the menu bar. */ constructor(options: MenuBar.IOptions); /** * Dispose of the resources held by the widget. */ dispose(): void; /** * Get the menu bar content node. * * #### Notes * This is the node which holds the menu title nodes. * * Modifying this node directly can lead to undefined behavior. * * This is a read-only property. */ readonly contentNode: HTMLUListElement; /** * The keymap used by the menu bar. * * #### Notes * This is a read-only property. */ readonly keymap: Keymap; /** * The renderer used by the menu bar. * * #### Notes * This is a read-only property. */ readonly renderer: MenuBar.IRenderer; /** * A read-only sequence of the menus in the menu bar. * * #### Notes * This is a read-only property. */ readonly menus: ISequence; /** * Get the child menu of the menu bar. * * #### Notes * This will be `null` if the menu bar does not have an open menu. * * This is a read-only property. */ readonly childMenu: Menu; /** * Get the currently active menu. * * #### Notes * This will be `null` if no menu is active. */ /** * Set the currently active menu. * * #### Notes * If the menu does not exist, the menu will be set to `null`. */ activeMenu: Menu; /** * Get the index of the currently active menu. * * #### Notes * This will be `-1` if no menu is active. */ /** * Set the index of the currently active menu. * * #### Notes * If the index is out of range, the index will be set to `-1`. */ activeIndex: number; /** * Open the active menu and activate its first menu item. * * #### Notes * If there is no active menu, this is a no-op. */ openActiveMenu(): void; /** * Add a menu to the end of the menu bar. * * @param menu - The menu to add to the menu bar. * * #### Notes * If the menu is already added to the menu bar, it will be moved. */ addMenu(menu: Menu): void; /** * Insert a menu into the menu bar at the specified index. * * @param index - The index at which to insert the menu. * * @param menu - The menu to insert into the menu bar. * * #### Notes * The index will be clamped to the bounds of the menus. * * If the menu is already added to the menu bar, it will be moved. */ insertMenu(index: number, menu: Menu): void; /** * Remove a menu from the menu bar. * * @param menu - The menu to remove from the menu bar. * * @returns The index occupied by the menu, or `-1` if the menu * was not contained in the menu bar. */ removeMenu(menu: Menu): number; /** * Remove the menu at a given index from the menu bar. * * @param index - The index of the menu to remove. * * @returns The menu occupying the index, or `null` if the index * is out of range. */ removeMenuAt(index: number): Menu; /** * Remove all menus from the menu bar. */ clearMenus(): void; /** * Handle the DOM events for the menu bar. * * @param event - The DOM event sent to the menu bar. * * #### Notes * This method implements the DOM `EventListener` interface and is * called in response to events on the menu bar's DOM nodes. It * should not be called directly by user code. */ handleEvent(event: Event): void; /** * A message handler invoked on an `'after-attach'` message. */ protected onAfterAttach(msg: Message): void; /** * A message handler invoked on a `'before-detach'` message. */ protected onBeforeDetach(msg: Message): void; /** * A message handler invoked on an `'activate-request'` message. */ protected onActivateRequest(msg: Message): void; /** * A message handler invoked on an `'update-request'` message. */ protected onUpdateRequest(msg: Message): void; /** * Handle the `'keydown'` event for the menu bar. */ private _evtKeyDown(event); /** * Handle the `'mousedown'` event for the menu bar. */ private _evtMouseDown(event); /** * Handle the `'mousemove'` event for the menu bar. */ private _evtMouseMove(event); /** * Handle the `'mouseleave'` event for the menu bar. */ private _evtMouseLeave(event); /** * Open the child menu at the active index immediately. * * If a different child menu is already open, it will be closed, * even if there is no active menu. */ private _openChildMenu(); /** * Close the child menu immediately. * * This is a no-op if a child menu is not open. */ private _closeChildMenu(); /** * Handle the `aboutToClose` signal of a menu. */ private _onMenuAboutToClose(sender); /** * Handle the `menuRequested` signal of a child menu. */ private _onMenuMenuRequested(sender, args); /** * Handle the `changed` signal of a title object. */ private _onTitleChanged(sender); private _keymap; private _activeIndex; private _childMenu; private _menus; private _nodes; private _renderer; } /** * The namespaces for the `MenuBar` class statics. */ export declare namespace MenuBar { /** * An options object for creating a menu bar. */ interface IOptions { /** * The keymap to use for the menu bar. * * The layout installed on the keymap is used to translate a * `'keydown'` event into a mnemonic for navigation purposes. */ keymap: Keymap; /** * A custom renderer for creating menu bar content. * * The default is a shared renderer instance. */ renderer?: IRenderer; } /** * A renderer for use with a menu bar. */ interface IRenderer { /** * Create a node for a menu bar item. * * @returns A new node for a menu bar item. * * #### Notes * The data in the node should be uninitialized. * * The `updateItemNode` method will be called for initialization. */ createItemNode(): HTMLLIElement; /** * Update an item node to reflect the state of a menu title. * * @param node - A node created by a call to `createItemNode`. * * @param title - The menu title holding the data for the node. * * #### Notes * This method should completely reset the state of the node to * reflect the data in the menu title. */ updateItemNode(node: HTMLLIElement, title: Title): void; } /** * The default implementation of `IRenderer`. */ class Renderer implements IRenderer { /** * Create a node for a menu bar item. * * @returns A new node for a menu bar item. */ createItemNode(): HTMLLIElement; /** * Update an item node to reflect the state of a menu title. * * @param node - A node created by a call to `createItemNode`. * * @param title - The menu title holding the data for the node. */ updateItemNode(node: HTMLLIElement, title: Title): void; /** * Format a label into HTML for display. * * @param label - The label text of interest. * * @param mnemonic - The index of the mnemonic character. * * @return The formatted label HTML for display. */ formatLabel(label: string, mnemonic: number): string; } /** * The default `Renderer` instance. */ const defaultRenderer: Renderer; }