| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 // from app.window.idl | |
| 6 part of chrome; | |
| 7 | |
| 8 /** | |
| 9 * Types | |
| 10 */ | |
| 11 class CreateWindowOptions extends ChromeObject { | |
| 12 /* | |
| 13 * Public constructor | |
| 14 */ | |
| 15 CreateWindowOptions({String id, int defaultWidth, int defaultHeight, | |
| 16 int defaultLeft, int defaultTop, int width, int height, int left, int top, | |
| 17 int minWidth, int minHeight, int maxWidth, int maxHeight, String type, | |
| 18 String frame, Bounds bounds, bool hidden}) { | |
| 19 this.id = id; | |
| 20 this.defaultWidth = defaultWidth; | |
| 21 this.defaultHeight = defaultHeight; | |
| 22 this.defaultLeft = defaultLeft; | |
| 23 this.defaultTop = defaultTop; | |
| 24 this.width = width; | |
| 25 this.height = height; | |
| 26 this.left = left; | |
| 27 this.top = top; | |
| 28 this.minWidth = minWidth; | |
| 29 this.minHeight = minHeight; | |
| 30 this.maxWidth = maxWidth; | |
| 31 this.maxHeight = maxHeight; | |
| 32 this.type = type; | |
| 33 this.frame = frame; | |
| 34 this.bounds = bounds; | |
| 35 this.hidden = hidden; | |
| 36 } | |
| 37 | |
| 38 /* | |
| 39 * Private constructor | |
| 40 */ | |
| 41 CreateWindowOptions._proxy(_jsObject) : super._proxy(_jsObject); | |
| 42 | |
| 43 /* | |
| 44 * Public accessors | |
| 45 */ | |
| 46 /// Id to identify the window. This will be used to remember the size | |
| 47 /// and position of the window and restore that geometry when a window | |
| 48 /// with the same id (and no explicit size or position) is later opened. | |
| 49 String get id => JS('String', '#.id', this._jsObject); | |
| 50 | |
| 51 void set id(String id) { | |
| 52 JS('void', '#.id = #', this._jsObject, id); | |
| 53 } | |
| 54 | |
| 55 /// Default width of the window. (Deprecated; regular bounds act like this | |
| 56 /// now.) | |
| 57 int get defaultWidth => JS('int', '#.defaultWidth', this._jsObject); | |
| 58 | |
| 59 void set defaultWidth(int defaultWidth) { | |
| 60 JS('void', '#.defaultWidth = #', this._jsObject, defaultWidth); | |
| 61 } | |
| 62 | |
| 63 /// Default height of the window. (Deprecated; regular bounds act like this | |
| 64 /// now.) | |
| 65 int get defaultHeight => JS('int', '#.defaultHeight', this._jsObject); | |
| 66 | |
| 67 void set defaultHeight(int defaultHeight) { | |
| 68 JS('void', '#.defaultHeight = #', this._jsObject, defaultHeight); | |
| 69 } | |
| 70 | |
| 71 /// Default X coordinate of the window. (Deprecated; regular bounds act like | |
| 72 /// this now.) | |
| 73 int get defaultLeft => JS('int', '#.defaultLeft', this._jsObject); | |
| 74 | |
| 75 void set defaultLeft(int defaultLeft) { | |
| 76 JS('void', '#.defaultLeft = #', this._jsObject, defaultLeft); | |
| 77 } | |
| 78 | |
| 79 /// Default Y coordinate of the window. (Deprecated; regular bounds act like | |
| 80 /// this now.) | |
| 81 int get defaultTop => JS('int', '#.defaultTop', this._jsObject); | |
| 82 | |
| 83 void set defaultTop(int defaultTop) { | |
| 84 JS('void', '#.defaultTop = #', this._jsObject, defaultTop); | |
| 85 } | |
| 86 | |
| 87 /// Width of the window. (Deprecated; use 'bounds'.) | |
| 88 int get width => JS('int', '#.width', this._jsObject); | |
| 89 | |
| 90 void set width(int width) { | |
| 91 JS('void', '#.width = #', this._jsObject, width); | |
| 92 } | |
| 93 | |
| 94 /// Height of the window. (Deprecated; use 'bounds'.) | |
| 95 int get height => JS('int', '#.height', this._jsObject); | |
| 96 | |
| 97 void set height(int height) { | |
| 98 JS('void', '#.height = #', this._jsObject, height); | |
| 99 } | |
| 100 | |
| 101 /// X coordinate of the window. (Deprecated; use 'bounds'.) | |
| 102 int get left => JS('int', '#.left', this._jsObject); | |
| 103 | |
| 104 void set left(int left) { | |
| 105 JS('void', '#.left = #', this._jsObject, left); | |
| 106 } | |
| 107 | |
| 108 /// Y coordinate of the window. (Deprecated; use 'bounds'.) | |
| 109 int get top => JS('int', '#.top', this._jsObject); | |
| 110 | |
| 111 void set top(int top) { | |
| 112 JS('void', '#.top = #', this._jsObject, top); | |
| 113 } | |
| 114 | |
| 115 /// Minimium width of the window. | |
| 116 int get minWidth => JS('int', '#.minWidth', this._jsObject); | |
| 117 | |
| 118 void set minWidth(int minWidth) { | |
| 119 JS('void', '#.minWidth = #', this._jsObject, minWidth); | |
| 120 } | |
| 121 | |
| 122 /// Minimum height of the window. | |
| 123 int get minHeight => JS('int', '#.minHeight', this._jsObject); | |
| 124 | |
| 125 void set minHeight(int minHeight) { | |
| 126 JS('void', '#.minHeight = #', this._jsObject, minHeight); | |
| 127 } | |
| 128 | |
| 129 /// Maximum width of the window. | |
| 130 int get maxWidth => JS('int', '#.maxWidth', this._jsObject); | |
| 131 | |
| 132 void set maxWidth(int maxWidth) { | |
| 133 JS('void', '#.maxWidth = #', this._jsObject, maxWidth); | |
| 134 } | |
| 135 | |
| 136 /// Maximum height of the window. | |
| 137 int get maxHeight => JS('int', '#.maxHeight', this._jsObject); | |
| 138 | |
| 139 void set maxHeight(int maxHeight) { | |
| 140 JS('void', '#.maxHeight = #', this._jsObject, maxHeight); | |
| 141 } | |
| 142 | |
| 143 /// Window type: 'shell' (the default) is the only currently supported value. | |
| 144 String get type => JS('String', '#.type', this._jsObject); | |
| 145 | |
| 146 void set type(String type) { | |
| 147 JS('void', '#.type = #', this._jsObject, type); | |
| 148 } | |
| 149 | |
| 150 /// Frame type: 'none' or 'chrome' (defaults to 'chrome'). | |
| 151 String get frame => JS('String', '#.frame', this._jsObject); | |
| 152 | |
| 153 void set frame(String frame) { | |
| 154 JS('void', '#.frame = #', this._jsObject, frame); | |
| 155 } | |
| 156 | |
| 157 /// Size of the content in the window (excluding the titlebar). If specified | |
| 158 /// in addition to any of the left/top/width/height parameters, this field | |
| 159 /// takes precedence. If a frameBounds is specified, the frameBounds take | |
| 160 /// precedence. | |
| 161 Bounds get bounds => | |
| 162 new Bounds._proxy(JS('Bounds', '#.bounds', this._jsObject)); | |
| 163 | |
| 164 void set bounds(Bounds bounds) { | |
| 165 JS('void', '#.bounds = #', this._jsObject, convertArgument(bounds)); | |
| 166 } | |
| 167 | |
| 168 /// If true, the window will be created in a hidden state. Call show() on | |
| 169 /// the window to show it once it has been created. Defaults to false. | |
| 170 bool get hidden => JS('bool', '#.hidden', this._jsObject); | |
| 171 | |
| 172 void set hidden(bool hidden) { | |
| 173 JS('void', '#.hidden = #', this._jsObject, hidden); | |
| 174 } | |
| 175 } | |
| 176 | |
| 177 class Bounds extends ChromeObject { | |
| 178 /* | |
| 179 * Public constructor | |
| 180 */ | |
| 181 Bounds({int left, int top, int width, int height}) { | |
| 182 this.left = left; | |
| 183 this.top = top; | |
| 184 this.width = width; | |
| 185 this.height = height; | |
| 186 } | |
| 187 | |
| 188 /* | |
| 189 * Private constructor | |
| 190 */ | |
| 191 Bounds._proxy(_jsObject) : super._proxy(_jsObject); | |
| 192 | |
| 193 /* | |
| 194 * Public accessors | |
| 195 */ | |
| 196 int get left => JS('int', '#.left', this._jsObject); | |
| 197 | |
| 198 void set left(int left) { | |
| 199 JS('void', '#.left = #', this._jsObject, left); | |
| 200 } | |
| 201 | |
| 202 int get top => JS('int', '#.top', this._jsObject); | |
| 203 | |
| 204 void set top(int top) { | |
| 205 JS('void', '#.top = #', this._jsObject, top); | |
| 206 } | |
| 207 | |
| 208 int get width => JS('int', '#.width', this._jsObject); | |
| 209 | |
| 210 void set width(int width) { | |
| 211 JS('void', '#.width = #', this._jsObject, width); | |
| 212 } | |
| 213 | |
| 214 int get height => JS('int', '#.height', this._jsObject); | |
| 215 | |
| 216 void set height(int height) { | |
| 217 JS('void', '#.height = #', this._jsObject, height); | |
| 218 } | |
| 219 } | |
| 220 | |
| 221 class AppWindow extends ChromeObject { | |
| 222 /* | |
| 223 * Public constructor | |
| 224 * TODO(sashab): Does it make sense to be able to create a new AppWindow this | |
| 225 * way? | |
| 226 */ | |
| 227 //AppWindow(); | |
| 228 | |
| 229 /* | |
| 230 * Private constructor | |
| 231 */ | |
| 232 AppWindow._proxy(jsObject) : super._proxy(jsObject); | |
| 233 | |
| 234 /* | |
| 235 * Public accessors | |
| 236 */ | |
| 237 /// The JavaScript 'window' object for the created child. | |
| 238 // TODO(sashab, sra): Detect whether this is the current window, or an | |
| 239 // external one, and return an appropriately-typed object | |
| 240 WindowBase get contentWindow => | |
| 241 JS("Window", "#.contentWindow", this._jsObject); | |
| 242 | |
| 243 /* | |
| 244 * Functions | |
| 245 */ | |
| 246 | |
| 247 /// Focus the window. | |
| 248 void focus() => JS("void", "#.focus()", this._jsObject); | |
| 249 | |
| 250 /// Minimize the window. | |
| 251 void minimize() => JS("void", "#.minimize()", this._jsObject); | |
| 252 | |
| 253 /// Is the window minimized? | |
| 254 bool isMinimized() => JS("bool", "#.isMinimized()", this._jsObject); | |
| 255 | |
| 256 /// Maximize the window. | |
| 257 void maximize() => JS("void", "#.maximize()", this._jsObject); | |
| 258 | |
| 259 /// Is the window maximized? | |
| 260 bool isMaximized() => JS("bool", "c#.isMaximized()", this._jsObject); | |
| 261 | |
| 262 /// Restore the window. | |
| 263 void restore() => JS("void", "#.restore()", this._jsObject); | |
| 264 | |
| 265 /// Move the window to the position (|left|, |top|). | |
| 266 void moveTo(int left, int top) => | |
| 267 JS("void", "#.moveTo(#, #)", this._jsObject, left, top); | |
| 268 | |
| 269 /// Resize the window to |width|x|height| pixels in size. | |
| 270 void resizeTo(int width, int height) => | |
| 271 JS("void", "#.resizeTo(#, #)", this._jsObject, width, height); | |
| 272 | |
| 273 /// Draw attention to the window. | |
| 274 void drawAttention() => JS("void", "#.drawAttention()", this._jsObject); | |
| 275 | |
| 276 /// Clear attention to the window. | |
| 277 void clearAttention() => JS("void", "#.clearAttention()", this._jsObject); | |
| 278 | |
| 279 /// Close the window. | |
| 280 void close() => JS("void", "#.close()", this._jsObject); | |
| 281 | |
| 282 /// Show the window. Does nothing if the window is already visible. | |
| 283 void show() => JS("void", "#.show()", this._jsObject); | |
| 284 | |
| 285 /// Hide the window. Does nothing if the window is already hidden. | |
| 286 void hide() => JS("void", "#.hide()", this._jsObject); | |
| 287 | |
| 288 /// Set the window's bounds. | |
| 289 void setBounds(Bounds bounds) => | |
| 290 JS("void", "#.setBounds(#)", this._jsObject, convertArgument(bounds)); | |
| 291 | |
| 292 } | |
| 293 | |
| 294 /** | |
| 295 * Functions | |
| 296 */ | |
| 297 class API_ChromeAppWindow { | |
| 298 /** | |
| 299 * JS object | |
| 300 */ | |
| 301 Object _jsObject; | |
| 302 | |
| 303 /** | |
| 304 * Constructor | |
| 305 */ | |
| 306 API_ChromeAppWindow(this._jsObject); | |
| 307 | |
| 308 /** | |
| 309 * Functions | |
| 310 */ | |
| 311 | |
| 312 /// Returns an <a href="#type-AppWindow">AppWindow</a> object for the | |
| 313 /// current script context (ie JavaScript 'window' object). This can also be | |
| 314 /// called on a handle to a script context for another page, for example: | |
| 315 /// otherWindow.chrome.app.window.current(). | |
| 316 AppWindow current() => | |
| 317 new AppWindow._proxy(JS("Object", "#.current()", this._jsObject)); | |
| 318 | |
| 319 /// The size and position of a window can be specified in a number of | |
| 320 /// different ways. The most simple option is not specifying anything at | |
| 321 /// all, in which case a default size and platform dependent position will | |
| 322 /// be used. | |
| 323 /// | |
| 324 /// Another option is to use the top/left and width/height properties, | |
| 325 /// which will always put the window at the specified coordinates with the | |
| 326 /// specified size. | |
| 327 /// | |
| 328 /// Yet another option is to give the window a (unique) id. This id is then | |
| 329 /// used to remember the size and position of the window whenever it is | |
| 330 /// moved or resized. This size and position is then used instead of the | |
| 331 /// specified bounds on subsequent opening of a window with the same id. If | |
| 332 /// you need to open a window with an id at a location other than the | |
| 333 /// remembered default, you can create it hidden, move it to the desired | |
| 334 /// location, then show it. | |
| 335 /// | |
| 336 /// You can also combine these various options, explicitly specifying for | |
| 337 /// example the size while having the position be remembered or other | |
| 338 /// combinations like that. Size and position are dealt with seperately, | |
| 339 /// but individual coordinates are not. So if you specify a top (or left) | |
| 340 /// coordinate, you should also specify a left (or top) coordinate, and | |
| 341 /// similar for size. | |
| 342 /// | |
| 343 /// If you specify both a regular and a default value for the same option | |
| 344 /// the regular value is the only one that takes effect. | |
| 345 void create(String url, [CreateWindowOptions options, | |
| 346 void callback(AppWindow created_window)]) { | |
| 347 void __proxy_callback(Object created_window) { | |
| 348 if (?callback) | |
| 349 callback(new AppWindow._proxy(created_window)); | |
| 350 } | |
| 351 | |
| 352 JS("void", "#.create(#, #, #)", | |
| 353 this._jsObject, | |
| 354 url, | |
| 355 convertArgument(options), | |
| 356 convertDartClosureToJS(__proxy_callback, 1) | |
| 357 ); | |
| 358 } | |
| 359 } | |
| OLD | NEW |