widget/nsIBaseWindow.idl

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
michael@0 2 *
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #include "nsISupports.idl"
michael@0 8 #include "nsrootidl.idl"
michael@0 9 /*#include "nsIWidget.idl" Boy this would be nice.*/
michael@0 10
michael@0 11 [ptr] native nsIWidget(nsIWidget);
michael@0 12 %{ C++
michael@0 13 class nsIWidget;
michael@0 14 %}
michael@0 15
michael@0 16 typedef voidPtr nativeWindow;
michael@0 17
michael@0 18 /**
michael@0 19 * The nsIBaseWindow describes a generic window and basic operations that
michael@0 20 * can be performed on it. This is not to be a complete windowing interface
michael@0 21 * but rather a common set that nearly all windowed objects support.
michael@0 22 */
michael@0 23
michael@0 24 [scriptable, uuid(9DA319F3-EEE6-4504-81A5-6A19CF6215BF)]
michael@0 25 interface nsIBaseWindow : nsISupports
michael@0 26 {
michael@0 27 /*
michael@0 28 Allows a client to initialize an object implementing this interface with
michael@0 29 the usually required window setup information.
michael@0 30 It is possible to pass null for both parentNativeWindow and parentWidget,
michael@0 31 but only docshells support this.
michael@0 32
michael@0 33 @param parentNativeWindow - This allows a system to pass in the parenting
michael@0 34 window as a native reference rather than relying on the calling
michael@0 35 application to have created the parent window as an nsIWidget. This
michael@0 36 value will be ignored (should be nullptr) if an nsIWidget is passed in to
michael@0 37 the parentWidget parameter.
michael@0 38
michael@0 39 @param parentWidget - This allows a system to pass in the parenting widget.
michael@0 40 This allows some objects to optimize themselves and rely on the view
michael@0 41 system for event flow rather than creating numerous native windows. If
michael@0 42 one of these is not available, nullptr should be passed.
michael@0 43
michael@0 44 @param x - This is the x co-ordinate relative to the parent to place the
michael@0 45 window.
michael@0 46
michael@0 47 @param y - This is the y co-ordinate relative to the parent to place the
michael@0 48 window.
michael@0 49
michael@0 50 @param cx - This is the width for the window to be.
michael@0 51
michael@0 52 @param cy - This is the height for the window to be.
michael@0 53
michael@0 54 @return NS_OK - Window Init succeeded without a problem.
michael@0 55 NS_ERROR_UNEXPECTED - Call was unexpected at this time. Most likely
michael@0 56 due to you calling it after create() has been called.
michael@0 57 NS_ERROR_INVALID_ARG - controls that require either a parentNativeWindow
michael@0 58 or a parentWidget may return invalid arg when they do not
michael@0 59 receive what they are needing.
michael@0 60 */
michael@0 61 [noscript]void initWindow(in nativeWindow parentNativeWindow,
michael@0 62 in nsIWidget parentWidget, in long x, in long y, in long cx, in long cy);
michael@0 63
michael@0 64 /*
michael@0 65 Tells the window that intialization and setup is complete. When this is
michael@0 66 called the window can actually create itself based on the setup
michael@0 67 information handed to it.
michael@0 68
michael@0 69 @return NS_OK - Creation was successfull.
michael@0 70 NS_ERROR_UNEXPECTED - This call was unexpected at this time.
michael@0 71 Perhaps create() had already been called or not all
michael@0 72 required initialization had been done.
michael@0 73 */
michael@0 74 void create();
michael@0 75
michael@0 76 /*
michael@0 77 Tell the window that it should destroy itself. This call should not be
michael@0 78 necessary as it will happen implictly when final release occurs on the
michael@0 79 object. If for some reaons you want the window destroyed prior to release
michael@0 80 due to cycle or ordering issues, then this call provides that ability.
michael@0 81
michael@0 82 @return NS_OK - Everything destroyed properly.
michael@0 83 NS_ERROR_UNEXPECTED - This call was unexpected at this time.
michael@0 84 Perhaps create() has not been called yet.
michael@0 85 */
michael@0 86 void destroy();
michael@0 87
michael@0 88 /*
michael@0 89 Sets the current x and y coordinates of the control. This is relative to
michael@0 90 the parent window.
michael@0 91 */
michael@0 92 void setPosition(in long x, in long y);
michael@0 93
michael@0 94 /*
michael@0 95 Gets the current x and y coordinates of the control. This is relatie to the
michael@0 96 parent window.
michael@0 97 */
michael@0 98 void getPosition(out long x, out long y);
michael@0 99
michael@0 100 /*
michael@0 101 Sets the width and height of the control.
michael@0 102 */
michael@0 103 void setSize(in long cx, in long cy, in boolean fRepaint);
michael@0 104
michael@0 105 /*
michael@0 106 Gets the width and height of the control.
michael@0 107 */
michael@0 108 void getSize(out long cx, out long cy);
michael@0 109
michael@0 110 /*
michael@0 111 Convenience function combining the SetPosition and SetSize into one call.
michael@0 112 Also is more efficient than calling both.
michael@0 113 */
michael@0 114 void setPositionAndSize(in long x, in long y, in long cx, in long cy,
michael@0 115 in boolean fRepaint);
michael@0 116
michael@0 117 /*
michael@0 118 Convenience function combining the GetPosition and GetSize into one call.
michael@0 119 Also is more efficient than calling both.
michael@0 120 */
michael@0 121 void getPositionAndSize(out long x, out long y, out long cx, out long cy);
michael@0 122
michael@0 123 /**
michael@0 124 * Tell the window to repaint itself
michael@0 125 * @param aForce - if true, repaint immediately
michael@0 126 * if false, the window may defer repainting as it sees fit.
michael@0 127 */
michael@0 128 void repaint(in boolean force);
michael@0 129
michael@0 130 /*
michael@0 131 This is the parenting widget for the control. This may be null if the
michael@0 132 native window was handed in for the parent during initialization.
michael@0 133 If this is returned, it should refer to the same object as
michael@0 134 parentNativeWindow.
michael@0 135
michael@0 136 Setting this after Create() has been called may not be supported by some
michael@0 137 implementations.
michael@0 138
michael@0 139 On controls that don't support widgets, setting this will return a
michael@0 140 NS_ERROR_NOT_IMPLEMENTED error.
michael@0 141 */
michael@0 142 [noscript] attribute nsIWidget parentWidget;
michael@0 143
michael@0 144 /*
michael@0 145 This is the native window parent of the control.
michael@0 146
michael@0 147 Setting this after Create() has been called may not be supported by some
michael@0 148 implementations.
michael@0 149
michael@0 150 On controls that don't support setting nativeWindow parents, setting this
michael@0 151 will return a NS_ERROR_NOT_IMPLEMENTED error.
michael@0 152 */
michael@0 153 attribute nativeWindow parentNativeWindow;
michael@0 154
michael@0 155 /*
michael@0 156 This is the handle (HWND, GdkWindow*, ...) to the native window of the
michael@0 157 control, exposed as a DOMString.
michael@0 158
michael@0 159 @return DOMString in hex format with "0x" prepended, or empty string if
michael@0 160 mainWidget undefined
michael@0 161
michael@0 162 @throws NS_ERROR_NOT_IMPLEMENTED for non-XULWindows
michael@0 163 */
michael@0 164 readonly attribute DOMString nativeHandle;
michael@0 165
michael@0 166 /*
michael@0 167 Attribute controls the visibility of the object behind this interface.
michael@0 168 Setting this attribute to false will hide the control. Setting it to
michael@0 169 true will show it.
michael@0 170 */
michael@0 171 attribute boolean visibility;
michael@0 172
michael@0 173 /*
michael@0 174 a disabled window should accept no user interaction; it's a dead window,
michael@0 175 like the parent of a modal window.
michael@0 176 */
michael@0 177 attribute boolean enabled;
michael@0 178
michael@0 179 /*
michael@0 180 Allows you to find out what the widget is of a given object. Depending
michael@0 181 on the object, this may return the parent widget in which this object
michael@0 182 lives if it has not had to create its own widget.
michael@0 183 */
michael@0 184 [noscript] readonly attribute nsIWidget mainWidget;
michael@0 185
michael@0 186 /*
michael@0 187 The number of device pixels per CSS pixel used on this window's current
michael@0 188 screen at the default zoom level.
michael@0 189 This is the value returned by GetDefaultScale() of the underlying widget.
michael@0 190 Note that this may change if the window is moved between screens with
michael@0 191 differing resolutions.
michael@0 192 */
michael@0 193 readonly attribute double unscaledDevicePixelsPerCSSPixel;
michael@0 194
michael@0 195 /**
michael@0 196 * Give the window focus.
michael@0 197 */
michael@0 198 void setFocus();
michael@0 199
michael@0 200 /*
michael@0 201 Title of the window.
michael@0 202 */
michael@0 203 attribute wstring title;
michael@0 204 };

mercurial