michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: interface nsIDOMElement; michael@0: interface nsIDOMNode; michael@0: interface nsIDOMEvent; michael@0: interface nsIDOMClientRect; michael@0: michael@0: [scriptable, uuid(b1192cac-467b-42ca-88d6-fcdec5bb4ef7)] michael@0: interface nsIPopupBoxObject : nsISupports michael@0: { michael@0: /** michael@0: * This method is deprecated. Use openPopup or openPopupAtScreen instead. michael@0: */ michael@0: void showPopup(in nsIDOMElement srcContent, in nsIDOMElement popupContent, michael@0: in long xpos, in long ypos, michael@0: in wstring popupType, in wstring anchorAlignment, michael@0: in wstring popupAlignment); michael@0: michael@0: /** michael@0: * Hide the popup if it is open. michael@0: */ michael@0: void hidePopup(); michael@0: michael@0: /** michael@0: * Allow the popup to automatically position itself. michael@0: */ michael@0: attribute boolean autoPosition; michael@0: michael@0: /** michael@0: * If keyboard navigation is enabled, the keyboard may be used to navigate michael@0: * the menuitems on the popup. Enabling keyboard navigation is the default michael@0: * behaviour and will install capturing key event listeners on the popup michael@0: * that do not propagate key events to the contents. If you wish to place michael@0: * elements in a popup which accept key events, such as textboxes, keyboard michael@0: * navigation should be disabled. michael@0: * michael@0: * Setting ignorekeys="true" on the popup element also disables keyboard michael@0: * navigation, and is recommended over calling this method. michael@0: */ michael@0: void enableKeyboardNavigator(in boolean enableKeyboardNavigator); michael@0: michael@0: /** michael@0: * Enable automatic popup dismissal. This only has effect when called michael@0: * on an open popup. michael@0: */ michael@0: void enableRollup(in boolean enableRollup); michael@0: michael@0: /** michael@0: * Control whether the event that caused the popup to be automatically michael@0: * dismissed ("rolled up") should be consumed, or dispatched as a michael@0: * normal event. This should be set immediately before calling showPopup() michael@0: * if non-default behavior is desired. michael@0: */ michael@0: const uint32_t ROLLUP_DEFAULT = 0; /* widget/platform default */ michael@0: const uint32_t ROLLUP_CONSUME = 1; /* consume the rollup event */ michael@0: const uint32_t ROLLUP_NO_CONSUME = 2; /* don't consume the rollup event */ michael@0: void setConsumeRollupEvent(in uint32_t consume); michael@0: michael@0: /** michael@0: * Size the popup to the given dimensions michael@0: */ michael@0: void sizeTo(in long width, in long height); michael@0: michael@0: /** michael@0: * Move the popup to a point on screen in CSS pixels. michael@0: */ michael@0: void moveTo(in long left, in long top); michael@0: michael@0: /** michael@0: * Open the popup relative to a specified node at a specific location. michael@0: * michael@0: * The popup may be either anchored to another node or opened freely. michael@0: * To anchor a popup to a node, supply an anchor node and set the position michael@0: * to a string indicating the manner in which the popup should be anchored. michael@0: * Possible values for position are: michael@0: * before_start, before_end, after_start, after_end, michael@0: * start_before, start_after, end_before, end_after, michael@0: * overlap, after_pointer michael@0: * michael@0: * The anchor node does not need to be in the same document as the popup. michael@0: * michael@0: * If the attributesOverride argument is true, the popupanchor, popupalign michael@0: * and position attributes on the popup node override the position value michael@0: * argument. If attributesOverride is false, the attributes are only used michael@0: * if position is empty. michael@0: * michael@0: * For an anchored popup, the x and y arguments may be used to offset the michael@0: * popup from its anchored position by some distance, measured in CSS pixels. michael@0: * x increases to the right and y increases down. Negative values may also michael@0: * be used to move to the left and upwards respectively. michael@0: * michael@0: * Unanchored popups may be created by supplying null as the anchor node. michael@0: * An unanchored popup appears at the position specified by x and y, michael@0: * relative to the viewport of the document containing the popup node. In michael@0: * this case, position and attributesOverride are ignored. michael@0: * michael@0: * @param anchorElement the node to anchor the popup to, may be null michael@0: * @param position manner is which to anchor the popup to node michael@0: * @param x horizontal offset michael@0: * @param y vertical offset michael@0: * @param isContextMenu true for context menus, false for other popups michael@0: * @param attributesOverride true if popup node attributes override position michael@0: * @param triggerEvent the event that triggered this popup (mouse click for example) michael@0: */ michael@0: void openPopup(in nsIDOMElement anchorElement, michael@0: in AString position, michael@0: in long x, in long y, michael@0: in boolean isContextMenu, michael@0: in boolean attributesOverride, michael@0: in nsIDOMEvent triggerEvent); michael@0: michael@0: /** michael@0: * Open the popup at a specific screen position specified by x and y. This michael@0: * position may be adjusted if it would cause the popup to be off of the michael@0: * screen. The x and y coordinates are measured in CSS pixels, and like all michael@0: * screen coordinates, are given relative to the top left of the primary michael@0: * screen. michael@0: * michael@0: * @param isContextMenu true for context menus, false for other popups michael@0: * @param x horizontal screen position michael@0: * @param y vertical screen position michael@0: * @param triggerEvent the event that triggered this popup (mouse click for example) michael@0: */ michael@0: void openPopupAtScreen(in long x, in long y, michael@0: in boolean isContextMenu, michael@0: in nsIDOMEvent triggerEvent); michael@0: michael@0: /** michael@0: * Returns the state of the popup: michael@0: * closed - the popup is closed michael@0: * open - the popup is open michael@0: * showing - the popup is in the process of being shown michael@0: * hiding - the popup is in the process of being hidden michael@0: */ michael@0: readonly attribute AString popupState; michael@0: michael@0: /** michael@0: * The node that triggered the popup. If the popup is not open, will return michael@0: * null. michael@0: */ michael@0: readonly attribute nsIDOMNode triggerNode; michael@0: michael@0: /** michael@0: * Retrieve the anchor that was specified to openPopup or for menupopups in a michael@0: * menu, the parent menu. michael@0: */ michael@0: readonly attribute nsIDOMElement anchorNode; michael@0: michael@0: /** michael@0: * Retrieve the screen rectangle of the popup, including the area occupied by michael@0: * any titlebar or borders present. michael@0: */ michael@0: nsIDOMClientRect getOuterScreenRect(); michael@0: michael@0: /** michael@0: * Move an open popup to the given anchor position. The arguments have the same michael@0: * meaning as the corresponding argument to openPopup. This method has no effect michael@0: * on popups that are not open. michael@0: */ michael@0: void moveToAnchor(in nsIDOMElement anchorElement, michael@0: in AString position, michael@0: in long x, in long y, michael@0: in boolean attributesOverride); michael@0: michael@0: /** Returns the alignment position where the popup has appeared relative to its michael@0: * anchor node or point, accounting for any flipping that occurred. michael@0: */ michael@0: readonly attribute AString alignmentPosition; michael@0: readonly attribute long alignmentOffset; michael@0: }; michael@0: michael@0: %{C++ michael@0: class nsIBoxObject; michael@0: michael@0: nsresult michael@0: NS_NewPopupBoxObject(nsIBoxObject** aResult); michael@0: michael@0: %}