| Index: tools/dom/src/chrome/app.window.dart
|
| diff --git a/tools/dom/src/chrome/app.window.dart b/tools/dom/src/chrome/app.window.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e34e3ca190a89db4663aa3687669f77806adfdc7
|
| --- /dev/null
|
| +++ b/tools/dom/src/chrome/app.window.dart
|
| @@ -0,0 +1,622 @@
|
| +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
| +// for details. All rights reserved. Use of this source code is governed by a
|
| +// BSD-style license that can be found in the LICENSE file.
|
| +
|
| +// from app.window.idl
|
| +part of chrome;
|
| +
|
| +/**
|
| + * Types
|
| + */
|
| +class CreateWindowOptions extends ChromeObject {
|
| + // Id to identify the window. This will be used to remember the size
|
| + // and position of the window and restore that geometry when a window
|
| + // with the same id (and no explicit size or position) is later opened.
|
| + String _id;
|
| +
|
| + // Default width of the window. (Deprecated; regular bounds act like this
|
| + // now.)
|
| + int _defaultWidth;
|
| +
|
| + // Default height of the window. (Deprecated; regular bounds act like this
|
| + // now.)
|
| + int _defaultHeight;
|
| +
|
| + // Default X coordinate of the window. (Deprecated; regular bounds act like
|
| + // this now.)
|
| + int _defaultLeft;
|
| +
|
| + // Default Y coordinate of the window. (Deprecated; regular bounds act like
|
| + // this now.)
|
| + int _defaultTop;
|
| +
|
| + // Width of the window. (Deprecated; use 'bounds'.)
|
| + int _width;
|
| +
|
| + // Height of the window. (Deprecated; use 'bounds'.)
|
| + int _height;
|
| +
|
| + // X coordinate of the window. (Deprecated; use 'bounds'.)
|
| + int _left;
|
| +
|
| + // Y coordinate of the window. (Deprecated; use 'bounds'.)
|
| + int _top;
|
| +
|
| + // Minimium width of the window.
|
| + int _minWidth;
|
| +
|
| + // Minimum height of the window.
|
| + int _minHeight;
|
| +
|
| + // Maximum width of the window.
|
| + int _maxWidth;
|
| +
|
| + // Maximum height of the window.
|
| + int _maxHeight;
|
| +
|
| + // Window type: 'shell' (the default) is the only currently supported value.
|
| + String _type;
|
| +
|
| + // Frame type: 'none' or 'chrome' (defaults to 'chrome').
|
| + String _frame;
|
| +
|
| + // Size of the content in the window (excluding the titlebar). If specified
|
| + // in addition to any of the left/top/width/height parameters, this field
|
| + // takes precedence. If a frameBounds is specified, the frameBounds take
|
| + // precedence.
|
| + Bounds _bounds;
|
| +
|
| + // If true, the window will be created in a hidden state. Call show() on
|
| + // the window to show it once it has been created. Defaults to false.
|
| + bool _hidden;
|
| +
|
| + /*
|
| + * Public constructor
|
| + */
|
| + CreateWindowOptions({
|
| + String id,
|
| + int defaultWidth,
|
| + int defaultHeight,
|
| + int defaultLeft,
|
| + int defaultTop,
|
| + int width,
|
| + int height,
|
| + int left,
|
| + int top,
|
| + int minWidth,
|
| + int minHeight,
|
| + int maxWidth,
|
| + int maxHeight,
|
| + String type,
|
| + String frame,
|
| + Bounds bounds,
|
| + bool hidden
|
| + }) :
|
| + _id = id,
|
| + _defaultWidth = defaultWidth,
|
| + _defaultHeight = defaultHeight,
|
| + _defaultLeft = defaultLeft,
|
| + _defaultTop = defaultTop,
|
| + _width = width,
|
| + _height = height,
|
| + _left = left,
|
| + _top = top,
|
| + _minWidth = minWidth,
|
| + _minHeight = minHeight,
|
| + _maxWidth = maxWidth,
|
| + _maxHeight = maxHeight,
|
| + _type = type,
|
| + _frame = frame,
|
| + _bounds = bounds,
|
| + _hidden = hidden
|
| + ;
|
| +
|
| + /*
|
| + * Private constructor
|
| + */
|
| + CreateWindowOptions._proxy(_jsObject)
|
| + : super._proxy(_jsObject);
|
| +
|
| + /*
|
| + * Serialisation method
|
| + */
|
| + Map _toMap() {
|
| + Map m = {};
|
| + if (id != null) m['id'] = id;
|
| + if (defaultWidth != null) m['defaultWidth'] = defaultWidth;
|
| + if (defaultHeight != null) m['defaultHeight'] = defaultHeight;
|
| + if (defaultLeft != null) m['defaultLeft'] = defaultLeft;
|
| + if (defaultTop != null) m['defaultTop'] = defaultTop;
|
| + if (width != null) m['width'] = width;
|
| + if (height != null) m['height'] = height;
|
| + if (left != null) m['left'] = left;
|
| + if (top != null) m['top'] = top;
|
| + if (minWidth != null) m['minWidth'] = minWidth;
|
| + if (minHeight != null) m['minHeight'] = minHeight;
|
| + if (maxWidth != null) m['maxWidth'] = maxWidth;
|
| + if (maxHeight != null) m['maxHeight'] = maxHeight;
|
| + if (type != null) m['type'] = type;
|
| + if (frame != null) m['frame'] = frame;
|
| + if (bounds != null) m['bounds'] = bounds;
|
| + if (hidden != null) m['hidden'] = hidden;
|
| + return m;
|
| + }
|
| +
|
| + /*
|
| + * Public accessors
|
| + */
|
| + String get id {
|
| + if (!this._hasProxy())
|
| + return this._id;
|
| + return JS('String', '#.id', this._jsObject);
|
| + }
|
| +
|
| + void set id(String id) {
|
| + if (!this._hasProxy())
|
| + this._id = id;
|
| + else
|
| + JS('void', '#.id = #', this._jsObject, convertArgument(id));
|
| + }
|
| +
|
| + int get defaultWidth {
|
| + if (!this._hasProxy())
|
| + return this._defaultWidth;
|
| + return JS('int', '#.defaultWidth', this._jsObject);
|
| + }
|
| +
|
| + void set defaultWidth(int defaultWidth) {
|
| + if (!this._hasProxy())
|
| + this._defaultWidth = defaultWidth;
|
| + else
|
| + JS('void', '#.defaultWidth = #', this._jsObject, convertArgument(defaultWidth));
|
| + }
|
| +
|
| + int get defaultHeight {
|
| + if (!this._hasProxy())
|
| + return this._defaultHeight;
|
| + return JS('int', '#.defaultHeight', this._jsObject);
|
| + }
|
| +
|
| + void set defaultHeight(int defaultHeight) {
|
| + if (!this._hasProxy())
|
| + this._defaultHeight = defaultHeight;
|
| + else
|
| + JS('void', '#.defaultHeight = #', this._jsObject, convertArgument(defaultHeight));
|
| + }
|
| +
|
| + int get defaultLeft {
|
| + if (!this._hasProxy())
|
| + return this._defaultLeft;
|
| + return JS('int', '#.defaultLeft', this._jsObject);
|
| + }
|
| +
|
| + void set defaultLeft(int defaultLeft) {
|
| + if (!this._hasProxy())
|
| + this._defaultLeft = defaultLeft;
|
| + else
|
| + JS('void', '#.defaultLeft = #', this._jsObject, convertArgument(defaultLeft));
|
| + }
|
| +
|
| + int get defaultTop {
|
| + if (!this._hasProxy())
|
| + return this._defaultTop;
|
| + return JS('int', '#.defaultTop', this._jsObject);
|
| + }
|
| +
|
| + void set defaultTop(int defaultTop) {
|
| + if (!this._hasProxy())
|
| + this._defaultTop = defaultTop;
|
| + else
|
| + JS('void', '#.defaultTop = #', this._jsObject, convertArgument(defaultTop));
|
| + }
|
| +
|
| + int get width {
|
| + if (!this._hasProxy())
|
| + return this._width;
|
| + return JS('int', '#.width', this._jsObject);
|
| + }
|
| +
|
| + void set width(int width) {
|
| + if (!this._hasProxy())
|
| + this._width = width;
|
| + else
|
| + JS('void', '#.width = #', this._jsObject, convertArgument(width));
|
| + }
|
| +
|
| + int get height {
|
| + if (!this._hasProxy())
|
| + return this._height;
|
| + return JS('int', '#.height', this._jsObject);
|
| + }
|
| +
|
| + void set height(int height) {
|
| + if (!this._hasProxy())
|
| + this._height = height;
|
| + else
|
| + JS('void', '#.height = #', this._jsObject, convertArgument(height));
|
| + }
|
| +
|
| + int get left {
|
| + if (!this._hasProxy())
|
| + return this._left;
|
| + return JS('int', '#.left', this._jsObject);
|
| + }
|
| +
|
| + void set left(int left) {
|
| + if (!this._hasProxy())
|
| + this._left = left;
|
| + else
|
| + JS('void', '#.left = #', this._jsObject, convertArgument(left));
|
| + }
|
| +
|
| + int get top {
|
| + if (!this._hasProxy())
|
| + return this._top;
|
| + return JS('int', '#.top', this._jsObject);
|
| + }
|
| +
|
| + void set top(int top) {
|
| + if (!this._hasProxy())
|
| + this._top = top;
|
| + else
|
| + JS('void', '#.top = #', this._jsObject, convertArgument(top));
|
| + }
|
| +
|
| + int get minWidth {
|
| + if (!this._hasProxy())
|
| + return this._minWidth;
|
| + return JS('int', '#.minWidth', this._jsObject);
|
| + }
|
| +
|
| + void set minWidth(int minWidth) {
|
| + if (!this._hasProxy())
|
| + this._minWidth = minWidth;
|
| + else
|
| + JS('void', '#.minWidth = #', this._jsObject, convertArgument(minWidth));
|
| + }
|
| +
|
| + int get minHeight {
|
| + if (!this._hasProxy())
|
| + return this._minHeight;
|
| + return JS('int', '#.minHeight', this._jsObject);
|
| + }
|
| +
|
| + void set minHeight(int minHeight) {
|
| + if (!this._hasProxy())
|
| + this._minHeight = minHeight;
|
| + else
|
| + JS('void', '#.minHeight = #', this._jsObject, convertArgument(minHeight));
|
| + }
|
| +
|
| + int get maxWidth {
|
| + if (!this._hasProxy())
|
| + return this._maxWidth;
|
| + return JS('int', '#.maxWidth', this._jsObject);
|
| + }
|
| +
|
| + void set maxWidth(int maxWidth) {
|
| + if (!this._hasProxy())
|
| + this._maxWidth = maxWidth;
|
| + else
|
| + JS('void', '#.maxWidth = #', this._jsObject, convertArgument(maxWidth));
|
| + }
|
| +
|
| + int get maxHeight {
|
| + if (!this._hasProxy())
|
| + return this._maxHeight;
|
| + return JS('int', '#.maxHeight', this._jsObject);
|
| + }
|
| +
|
| + void set maxHeight(int maxHeight) {
|
| + if (!this._hasProxy())
|
| + this._maxHeight = maxHeight;
|
| + else
|
| + JS('void', '#.maxHeight = #', this._jsObject, convertArgument(maxHeight));
|
| + }
|
| +
|
| + String get type {
|
| + if (!this._hasProxy())
|
| + return this._type;
|
| + return JS('String', '#.type', this._jsObject);
|
| + }
|
| +
|
| + void set type(String type) {
|
| + if (!this._hasProxy())
|
| + this._type = type;
|
| + else
|
| + JS('void', '#.type = #', this._jsObject, convertArgument(type));
|
| + }
|
| +
|
| + String get frame {
|
| + if (!this._hasProxy())
|
| + return this._frame;
|
| + return JS('String', '#.frame', this._jsObject);
|
| + }
|
| +
|
| + void set frame(String frame) {
|
| + if (!this._hasProxy())
|
| + this._frame = frame;
|
| + else
|
| + JS('void', '#.frame = #', this._jsObject, convertArgument(frame));
|
| + }
|
| +
|
| + Bounds get bounds {
|
| + if (!this._hasProxy())
|
| + return this._bounds;
|
| + return new Bounds._proxy(JS('Bounds', '#.bounds', this._jsObject));
|
| + }
|
| +
|
| + void set bounds(Bounds bounds) {
|
| + if (!this._hasProxy())
|
| + this._bounds = bounds;
|
| + else
|
| + JS('void', '#.bounds = #', this._jsObject, convertArgument(bounds));
|
| + }
|
| +
|
| + bool get hidden {
|
| + if (!this._hasProxy())
|
| + return this._hidden;
|
| + return JS('String', '#.hidden', this._jsObject);
|
| + }
|
| +
|
| + void set hidden(bool hidden) {
|
| + if (!this._hasProxy())
|
| + this._hidden = hidden;
|
| + else
|
| + JS('void', '#.hidden = #', this._jsObject, convertArgument(hidden));
|
| + }
|
| +}
|
| +
|
| +class Bounds extends ChromeObject {
|
| + int _left;
|
| + int _top;
|
| + int _width;
|
| + int _height;
|
| +
|
| + /*
|
| + * Public constructor
|
| + */
|
| + Bounds({
|
| + int left,
|
| + int top,
|
| + int width,
|
| + int height
|
| + }) :
|
| + _left = left,
|
| + _top = top,
|
| + _width = width,
|
| + _height = height
|
| + ;
|
| +
|
| +
|
| + /*
|
| + * Private constructor
|
| + */
|
| + Bounds._proxy(_jsObject)
|
| + : super._proxy(_jsObject);
|
| +
|
| + /*
|
| + * Serialisation method
|
| + */
|
| + Map _toMap() {
|
| + Map m = {};
|
| + if (left != null) m['left'] = left;
|
| + if (top != null) m['top'] = top;
|
| + if (width != null) m['width'] = width;
|
| + if (height != null) m['height'] = height;
|
| + return m;
|
| + }
|
| +
|
| + /*
|
| + * Public accessors
|
| + */
|
| + int get width {
|
| + if (!this._hasProxy())
|
| + return this._width;
|
| + return JS('int', '#.width', this._jsObject);
|
| + }
|
| +
|
| + void set width(int width) {
|
| + if (!this._hasProxy())
|
| + this._width = width;
|
| + else
|
| + JS('void', '#.width = #', this._jsObject, convertArgument(width));
|
| + }
|
| +
|
| + int get height {
|
| + if (!this._hasProxy())
|
| + return this._height;
|
| + return JS('int', '#.height', this._jsObject);
|
| + }
|
| +
|
| + void set height(int height) {
|
| + if (!this._hasProxy())
|
| + this._height = height;
|
| + else
|
| + JS('void', '#.height = #', this._jsObject, convertArgument(height));
|
| + }
|
| +
|
| + int get left {
|
| + if (!this._hasProxy())
|
| + return this._left;
|
| + return JS('int', '#.left', this._jsObject);
|
| + }
|
| +
|
| + void set left(int left) {
|
| + if (!this._hasProxy())
|
| + this._left = left;
|
| + else
|
| + JS('void', '#.left = #', this._jsObject, convertArgument(left));
|
| + }
|
| +
|
| + int get top {
|
| + if (!this._hasProxy())
|
| + return this._top;
|
| + return JS('int', '#.top', this._jsObject);
|
| + }
|
| +
|
| + void set top(int top) {
|
| + if (!this._hasProxy())
|
| + this._top = top;
|
| + else
|
| + JS('void', '#.top = #', this._jsObject, convertArgument(top));
|
| + }
|
| +}
|
| +
|
| +class AppWindow extends ChromeObject {
|
| + /*
|
| + * Public constructor
|
| + * TODO(sashab): Does it make sense to be able to create a new AppWindow this way?
|
| + */
|
| + //AppWindow();
|
| +
|
| + /*
|
| + * Private constructor
|
| + */
|
| + AppWindow._proxy(jsObject)
|
| + : super._proxy(jsObject);
|
| +
|
| + /*
|
| + * Serialisation method
|
| + */
|
| + Map _toMap() {
|
| + return {};
|
| + }
|
| +
|
| + /*
|
| + * Public accessors
|
| + */
|
| + // The JavaScript 'window' object for the created child.
|
| + // TODO(sashab, sra): Detect whether this is the current window, or an
|
| + // external one, and return an appropriately-typed object
|
| + WindowBase get contentWindow {
|
| + return JS("Window", "#.contentWindow", this._jsObject);
|
| + }
|
| +
|
| + /*
|
| + * Functions
|
| + */
|
| +
|
| + // Focus the window.
|
| + void focus() =>
|
| + JS("void", "#.focus()", this._jsObject);
|
| +
|
| + // Minimize the window.
|
| + void minimize() =>
|
| + JS("void", "#.minimize()", this._jsObject);
|
| +
|
| + // Is the window minimized?
|
| + bool isMinimized() =>
|
| + JS("bool", "#.isMinimized()", this._jsObject);
|
| +
|
| + // Maximize the window.
|
| + void maximize() =>
|
| + JS("void", "#.maximize()", this._jsObject);
|
| +
|
| + // Is the window maximized?
|
| + bool isMaximized() =>
|
| + JS("bool", "c#.isMaximized()", this._jsObject);
|
| +
|
| + // Restore the window.
|
| + void restore() =>
|
| + JS("void", "#.restore()", this._jsObject);
|
| +
|
| + // Move the window to the position (|left|, |top|).
|
| + void moveTo(int left, int top) =>
|
| + JS("void", "#.moveTo(#, #)", this._jsObject, left, top);
|
| +
|
| + // Resize the window to |width|x|height| pixels in size.
|
| + void resizeTo(int width, int height) =>
|
| + JS("void", "#.resizeTo(#, #)", this._jsObject, width, height);
|
| +
|
| + // Draw attention to the window.
|
| + void drawAttention() =>
|
| + JS("void", "#.drawAttention()", this._jsObject);
|
| +
|
| + // Clear attention to the window.
|
| + void clearAttention() =>
|
| + JS("void", "#.clearAttention()", this._jsObject);
|
| +
|
| + // Close the window.
|
| + void close() =>
|
| + JS("void", "#.close()", this._jsObject);
|
| +
|
| + // Show the window. Does nothing if the window is already visible.
|
| + void show() =>
|
| + JS("void", "#.show()", this._jsObject);
|
| +
|
| + // Hide the window. Does nothing if the window is already hidden.
|
| + void hide() =>
|
| + JS("void", "#.hide()", this._jsObject);
|
| +
|
| + // Set the window's bounds.
|
| + void setBounds(Bounds bounds) =>
|
| + JS("void", "#.setBounds(#)", this._jsObject, convertArgument(bounds));
|
| +
|
| +}
|
| +
|
| +/**
|
| + * Functions
|
| + */
|
| +class $API_ChromeAppWindow {
|
| + /**
|
| + * JS object
|
| + */
|
| + Object _jsObject;
|
| +
|
| + /**
|
| + * Constructor
|
| + */
|
| + $API_ChromeAppWindow(this._jsObject);
|
| +
|
| + /**
|
| + * Functions
|
| + */
|
| +
|
| + // Returns an <a href="#type-AppWindow">AppWindow</a> object for the
|
| + // current script context (ie JavaScript 'window' object). This can also be
|
| + // called on a handle to a script context for another page, for example:
|
| + // otherWindow.chrome.app.window.current().
|
| + AppWindow current() =>
|
| + new AppWindow._proxy(JS("Object", "#.current()", this._jsObject));
|
| +
|
| + // The size and position of a window can be specified in a number of
|
| + // different ways. The most simple option is not specifying anything at
|
| + // all, in which case a default size and platform dependent position will
|
| + // be used.
|
| + //
|
| + // Another option is to use the top/left and width/height properties,
|
| + // which will always put the window at the specified coordinates with the
|
| + // specified size.
|
| + //
|
| + // Yet another option is to give the window a (unique) id. This id is then
|
| + // used to remember the size and position of the window whenever it is
|
| + // moved or resized. This size and position is then used instead of the
|
| + // specified bounds on subsequent opening of a window with the same id. If
|
| + // you need to open a window with an id at a location other than the
|
| + // remembered default, you can create it hidden, move it to the desired
|
| + // location, then show it.
|
| + //
|
| + // You can also combine these various options, explicitly specifying for
|
| + // example the size while having the position be remembered or other
|
| + // combinations like that. Size and position are dealt with seperately,
|
| + // but individual coordinates are not. So if you specify a top (or left)
|
| + // coordinate, you should also specify a left (or top) coordinate, and
|
| + // similar for size.
|
| + //
|
| + // If you specify both a regular and a default value for the same option
|
| + // the regular value is the only one that takes effect.
|
| + void create(String url, [ CreateWindowOptions options, void callback(AppWindow created_window) ]) {
|
| + void __proxy_callback(Object created_window) {
|
| + if (?callback)
|
| + callback(new AppWindow._proxy(created_window));
|
| + }
|
| +
|
| + JS("void", "#.create(#, #, #)",
|
| + this._jsObject,
|
| + url,
|
| + convertArgument(options),
|
| + convertDartClosureToJS(__proxy_callback, 1)
|
| + );
|
| + }
|
| +}
|
|
|