nsIBaseWindow.idl 7.4 KB

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