michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * 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: #include "nsrootidl.idl" michael@0: /*#include "nsIWidget.idl" Boy this would be nice.*/ michael@0: michael@0: [ptr] native nsIWidget(nsIWidget); michael@0: %{ C++ michael@0: class nsIWidget; michael@0: %} michael@0: michael@0: typedef voidPtr nativeWindow; michael@0: michael@0: /** michael@0: * The nsIBaseWindow describes a generic window and basic operations that michael@0: * can be performed on it. This is not to be a complete windowing interface michael@0: * but rather a common set that nearly all windowed objects support. michael@0: */ michael@0: michael@0: [scriptable, uuid(9DA319F3-EEE6-4504-81A5-6A19CF6215BF)] michael@0: interface nsIBaseWindow : nsISupports michael@0: { michael@0: /* michael@0: Allows a client to initialize an object implementing this interface with michael@0: the usually required window setup information. michael@0: It is possible to pass null for both parentNativeWindow and parentWidget, michael@0: but only docshells support this. michael@0: michael@0: @param parentNativeWindow - This allows a system to pass in the parenting michael@0: window as a native reference rather than relying on the calling michael@0: application to have created the parent window as an nsIWidget. This michael@0: value will be ignored (should be nullptr) if an nsIWidget is passed in to michael@0: the parentWidget parameter. michael@0: michael@0: @param parentWidget - This allows a system to pass in the parenting widget. michael@0: This allows some objects to optimize themselves and rely on the view michael@0: system for event flow rather than creating numerous native windows. If michael@0: one of these is not available, nullptr should be passed. michael@0: michael@0: @param x - This is the x co-ordinate relative to the parent to place the michael@0: window. michael@0: michael@0: @param y - This is the y co-ordinate relative to the parent to place the michael@0: window. michael@0: michael@0: @param cx - This is the width for the window to be. michael@0: michael@0: @param cy - This is the height for the window to be. michael@0: michael@0: @return NS_OK - Window Init succeeded without a problem. michael@0: NS_ERROR_UNEXPECTED - Call was unexpected at this time. Most likely michael@0: due to you calling it after create() has been called. michael@0: NS_ERROR_INVALID_ARG - controls that require either a parentNativeWindow michael@0: or a parentWidget may return invalid arg when they do not michael@0: receive what they are needing. michael@0: */ michael@0: [noscript]void initWindow(in nativeWindow parentNativeWindow, michael@0: in nsIWidget parentWidget, in long x, in long y, in long cx, in long cy); michael@0: michael@0: /* michael@0: Tells the window that intialization and setup is complete. When this is michael@0: called the window can actually create itself based on the setup michael@0: information handed to it. michael@0: michael@0: @return NS_OK - Creation was successfull. michael@0: NS_ERROR_UNEXPECTED - This call was unexpected at this time. michael@0: Perhaps create() had already been called or not all michael@0: required initialization had been done. michael@0: */ michael@0: void create(); michael@0: michael@0: /* michael@0: Tell the window that it should destroy itself. This call should not be michael@0: necessary as it will happen implictly when final release occurs on the michael@0: object. If for some reaons you want the window destroyed prior to release michael@0: due to cycle or ordering issues, then this call provides that ability. michael@0: michael@0: @return NS_OK - Everything destroyed properly. michael@0: NS_ERROR_UNEXPECTED - This call was unexpected at this time. michael@0: Perhaps create() has not been called yet. michael@0: */ michael@0: void destroy(); michael@0: michael@0: /* michael@0: Sets the current x and y coordinates of the control. This is relative to michael@0: the parent window. michael@0: */ michael@0: void setPosition(in long x, in long y); michael@0: michael@0: /* michael@0: Gets the current x and y coordinates of the control. This is relatie to the michael@0: parent window. michael@0: */ michael@0: void getPosition(out long x, out long y); michael@0: michael@0: /* michael@0: Sets the width and height of the control. michael@0: */ michael@0: void setSize(in long cx, in long cy, in boolean fRepaint); michael@0: michael@0: /* michael@0: Gets the width and height of the control. michael@0: */ michael@0: void getSize(out long cx, out long cy); michael@0: michael@0: /* michael@0: Convenience function combining the SetPosition and SetSize into one call. michael@0: Also is more efficient than calling both. michael@0: */ michael@0: void setPositionAndSize(in long x, in long y, in long cx, in long cy, michael@0: in boolean fRepaint); michael@0: michael@0: /* michael@0: Convenience function combining the GetPosition and GetSize into one call. michael@0: Also is more efficient than calling both. michael@0: */ michael@0: void getPositionAndSize(out long x, out long y, out long cx, out long cy); michael@0: michael@0: /** michael@0: * Tell the window to repaint itself michael@0: * @param aForce - if true, repaint immediately michael@0: * if false, the window may defer repainting as it sees fit. michael@0: */ michael@0: void repaint(in boolean force); michael@0: michael@0: /* michael@0: This is the parenting widget for the control. This may be null if the michael@0: native window was handed in for the parent during initialization. michael@0: If this is returned, it should refer to the same object as michael@0: parentNativeWindow. michael@0: michael@0: Setting this after Create() has been called may not be supported by some michael@0: implementations. michael@0: michael@0: On controls that don't support widgets, setting this will return a michael@0: NS_ERROR_NOT_IMPLEMENTED error. michael@0: */ michael@0: [noscript] attribute nsIWidget parentWidget; michael@0: michael@0: /* michael@0: This is the native window parent of the control. michael@0: michael@0: Setting this after Create() has been called may not be supported by some michael@0: implementations. michael@0: michael@0: On controls that don't support setting nativeWindow parents, setting this michael@0: will return a NS_ERROR_NOT_IMPLEMENTED error. michael@0: */ michael@0: attribute nativeWindow parentNativeWindow; michael@0: michael@0: /* michael@0: This is the handle (HWND, GdkWindow*, ...) to the native window of the michael@0: control, exposed as a DOMString. michael@0: michael@0: @return DOMString in hex format with "0x" prepended, or empty string if michael@0: mainWidget undefined michael@0: michael@0: @throws NS_ERROR_NOT_IMPLEMENTED for non-XULWindows michael@0: */ michael@0: readonly attribute DOMString nativeHandle; michael@0: michael@0: /* michael@0: Attribute controls the visibility of the object behind this interface. michael@0: Setting this attribute to false will hide the control. Setting it to michael@0: true will show it. michael@0: */ michael@0: attribute boolean visibility; michael@0: michael@0: /* michael@0: a disabled window should accept no user interaction; it's a dead window, michael@0: like the parent of a modal window. michael@0: */ michael@0: attribute boolean enabled; michael@0: michael@0: /* michael@0: Allows you to find out what the widget is of a given object. Depending michael@0: on the object, this may return the parent widget in which this object michael@0: lives if it has not had to create its own widget. michael@0: */ michael@0: [noscript] readonly attribute nsIWidget mainWidget; michael@0: michael@0: /* michael@0: The number of device pixels per CSS pixel used on this window's current michael@0: screen at the default zoom level. michael@0: This is the value returned by GetDefaultScale() of the underlying widget. michael@0: Note that this may change if the window is moved between screens with michael@0: differing resolutions. michael@0: */ michael@0: readonly attribute double unscaledDevicePixelsPerCSSPixel; michael@0: michael@0: /** michael@0: * Give the window focus. michael@0: */ michael@0: void setFocus(); michael@0: michael@0: /* michael@0: Title of the window. michael@0: */ michael@0: attribute wstring title; michael@0: };