Chromium Code Reviews| 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 // Generated from namespace: app.window | |
| 6 | |
| 7 part of chrome; | |
| 8 | |
| 9 /** | |
| 10 * Types | |
| 11 */ | |
| 12 | |
| 13 class Bounds extends ChromeObject { | |
| 14 /* | |
| 15 * Public constructor | |
| 16 */ | |
| 17 Bounds({int left, int top, int width, int height}) { | |
| 18 if (?left) | |
| 19 this.left = left; | |
| 20 if (?top) | |
| 21 this.top = top; | |
| 22 if (?width) | |
| 23 this.width = width; | |
| 24 if (?height) | |
| 25 this.height = height; | |
| 26 } | |
| 27 | |
| 28 /* | |
| 29 * Private constructor | |
| 30 */ | |
| 31 Bounds._proxy(_jsObject) : super._proxy(_jsObject); | |
| 32 | |
| 33 /* | |
| 34 * Public accessors | |
| 35 */ | |
| 36 | |
| 37 int get left => JS('int', '#.left', this._jsObject); | |
| 38 | |
| 39 void set left(int left) { | |
| 40 JS('void', '#.left = #', this._jsObject, left); | |
| 41 } | |
| 42 | |
| 43 int get top => JS('int', '#.top', this._jsObject); | |
| 44 | |
| 45 void set top(int top) { | |
| 46 JS('void', '#.top = #', this._jsObject, top); | |
| 47 } | |
| 48 | |
| 49 int get width => JS('int', '#.width', this._jsObject); | |
| 50 | |
| 51 void set width(int width) { | |
| 52 JS('void', '#.width = #', this._jsObject, width); | |
| 53 } | |
| 54 | |
| 55 int get height => JS('int', '#.height', this._jsObject); | |
| 56 | |
| 57 void set height(int height) { | |
| 58 JS('void', '#.height = #', this._jsObject, height); | |
| 59 } | |
| 60 } | |
| 61 | |
| 62 class CreateWindowOptions extends ChromeObject { | |
| 63 /* | |
| 64 * Public constructor | |
| 65 */ | |
| 66 CreateWindowOptions({String id, int defaultWidth, int defaultHeight, int defau ltLeft, int defaultTop, int width, int height, int left, int top, int minWidth, int minHeight, int maxWidth, int maxHeight, String type, String frame, Bounds bo unds, bool transparentBackground, bool hidden, bool singleton}) { | |
| 67 if (?id) | |
| 68 this.id = id; | |
| 69 if (?defaultWidth) | |
| 70 this.defaultWidth = defaultWidth; | |
| 71 if (?defaultHeight) | |
| 72 this.defaultHeight = defaultHeight; | |
| 73 if (?defaultLeft) | |
| 74 this.defaultLeft = defaultLeft; | |
| 75 if (?defaultTop) | |
| 76 this.defaultTop = defaultTop; | |
| 77 if (?width) | |
| 78 this.width = width; | |
| 79 if (?height) | |
| 80 this.height = height; | |
| 81 if (?left) | |
| 82 this.left = left; | |
| 83 if (?top) | |
| 84 this.top = top; | |
| 85 if (?minWidth) | |
| 86 this.minWidth = minWidth; | |
| 87 if (?minHeight) | |
| 88 this.minHeight = minHeight; | |
| 89 if (?maxWidth) | |
| 90 this.maxWidth = maxWidth; | |
| 91 if (?maxHeight) | |
| 92 this.maxHeight = maxHeight; | |
| 93 if (?type) | |
| 94 this.type = type; | |
| 95 if (?frame) | |
| 96 this.frame = frame; | |
| 97 if (?bounds) | |
| 98 this.bounds = bounds; | |
| 99 if (?transparentBackground) | |
| 100 this.transparentBackground = transparentBackground; | |
| 101 if (?hidden) | |
| 102 this.hidden = hidden; | |
| 103 if (?singleton) | |
| 104 this.singleton = singleton; | |
| 105 } | |
| 106 | |
| 107 /* | |
| 108 * Private constructor | |
| 109 */ | |
| 110 CreateWindowOptions._proxy(_jsObject) : super._proxy(_jsObject); | |
| 111 | |
| 112 /* | |
| 113 * Public accessors | |
| 114 */ | |
| 115 | |
| 116 /// Id to identify the window. This will be used to remember the size and | |
| 117 /// position of the window and restore that geometry when a window with the | |
| 118 /// same id (and no explicit size or position) is later opened. | |
| 119 String get id => JS('String', '#.id', this._jsObject); | |
| 120 | |
| 121 void set id(String id) { | |
| 122 JS('void', '#.id = #', this._jsObject, id); | |
| 123 } | |
| 124 | |
| 125 /// Default width of the window. (Deprecated; regular bounds act like this | |
| 126 /// now.) | |
| 127 int get defaultWidth => JS('int', '#.defaultWidth', this._jsObject); | |
| 128 | |
| 129 void set defaultWidth(int defaultWidth) { | |
| 130 JS('void', '#.defaultWidth = #', this._jsObject, defaultWidth); | |
| 131 } | |
| 132 | |
| 133 /// Default height of the window. (Deprecated; regular bounds act like this | |
| 134 /// now.) | |
| 135 int get defaultHeight => JS('int', '#.defaultHeight', this._jsObject); | |
| 136 | |
| 137 void set defaultHeight(int defaultHeight) { | |
| 138 JS('void', '#.defaultHeight = #', this._jsObject, defaultHeight); | |
| 139 } | |
| 140 | |
| 141 /// Default X coordinate of the window. (Deprecated; regular bounds act like | |
| 142 /// this now.) | |
| 143 int get defaultLeft => JS('int', '#.defaultLeft', this._jsObject); | |
| 144 | |
| 145 void set defaultLeft(int defaultLeft) { | |
| 146 JS('void', '#.defaultLeft = #', this._jsObject, defaultLeft); | |
| 147 } | |
| 148 | |
| 149 /// Default Y coordinate of the window. (Deprecated; regular bounds act like | |
| 150 /// this now.) | |
| 151 int get defaultTop => JS('int', '#.defaultTop', this._jsObject); | |
| 152 | |
| 153 void set defaultTop(int defaultTop) { | |
| 154 JS('void', '#.defaultTop = #', this._jsObject, defaultTop); | |
| 155 } | |
| 156 | |
| 157 /// Width of the window. (Deprecated; use 'bounds'.) | |
| 158 int get width => JS('int', '#.width', this._jsObject); | |
| 159 | |
| 160 void set width(int width) { | |
| 161 JS('void', '#.width = #', this._jsObject, width); | |
| 162 } | |
| 163 | |
| 164 /// Height of the window. (Deprecated; use 'bounds'.) | |
| 165 int get height => JS('int', '#.height', this._jsObject); | |
| 166 | |
| 167 void set height(int height) { | |
| 168 JS('void', '#.height = #', this._jsObject, height); | |
| 169 } | |
| 170 | |
| 171 /// X coordinate of the window. (Deprecated; use 'bounds'.) | |
|
blois
2013/02/08 00:08:04
These were here before, but is it possible to remo
benwells
2013/02/08 00:17:46
We have no way of automatically ignoring deprecate
| |
| 172 int get left => JS('int', '#.left', this._jsObject); | |
| 173 | |
| 174 void set left(int left) { | |
| 175 JS('void', '#.left = #', this._jsObject, left); | |
| 176 } | |
| 177 | |
| 178 /// Y coordinate of the window. (Deprecated; use 'bounds'.) | |
| 179 int get top => JS('int', '#.top', this._jsObject); | |
| 180 | |
| 181 void set top(int top) { | |
| 182 JS('void', '#.top = #', this._jsObject, top); | |
| 183 } | |
| 184 | |
| 185 /// Minimum width of the window. | |
| 186 int get minWidth => JS('int', '#.minWidth', this._jsObject); | |
| 187 | |
| 188 void set minWidth(int minWidth) { | |
| 189 JS('void', '#.minWidth = #', this._jsObject, minWidth); | |
| 190 } | |
| 191 | |
| 192 /// Minimum height of the window. | |
| 193 int get minHeight => JS('int', '#.minHeight', this._jsObject); | |
| 194 | |
| 195 void set minHeight(int minHeight) { | |
| 196 JS('void', '#.minHeight = #', this._jsObject, minHeight); | |
| 197 } | |
| 198 | |
| 199 /// Maximum width of the window. | |
| 200 int get maxWidth => JS('int', '#.maxWidth', this._jsObject); | |
| 201 | |
| 202 void set maxWidth(int maxWidth) { | |
| 203 JS('void', '#.maxWidth = #', this._jsObject, maxWidth); | |
| 204 } | |
| 205 | |
| 206 /// Maximum height of the window. | |
| 207 int get maxHeight => JS('int', '#.maxHeight', this._jsObject); | |
| 208 | |
| 209 void set maxHeight(int maxHeight) { | |
| 210 JS('void', '#.maxHeight = #', this._jsObject, maxHeight); | |
| 211 } | |
| 212 | |
| 213 /// Window type: 'shell' - the default window type 'panel' - a panel, manage d | |
| 214 /// by the OS (Currently experimental, Ash only) | |
| 215 String get type => JS('String', '#.type', this._jsObject); | |
| 216 | |
| 217 void set type(String type) { | |
| 218 JS('void', '#.type = #', this._jsObject, type); | |
| 219 } | |
| 220 | |
| 221 /// Frame type: 'none' or 'chrome' (defaults to 'chrome'). | |
| 222 String get frame => JS('String', '#.frame', this._jsObject); | |
| 223 | |
| 224 void set frame(String frame) { | |
| 225 JS('void', '#.frame = #', this._jsObject, frame); | |
| 226 } | |
| 227 | |
| 228 /// Size of the content in the window (excluding the titlebar). If specified i n | |
| 229 /// addition to any of the left/top/width/height parameters, this field takes | |
| 230 /// precedence. If a frameBounds is specified, the frameBounds take precedence . | |
| 231 Bounds get bounds => new Bounds._proxy(JS('', '#.bounds', this._jsObject)); | |
| 232 | |
| 233 void set bounds(Bounds bounds) { | |
| 234 JS('void', '#.bounds = #', this._jsObject, convertArgument(bounds)); | |
| 235 } | |
| 236 | |
| 237 /// Enable window background transparency. Only supported in ash. Requires | |
| 238 /// experimental API permission. | |
| 239 bool get transparentBackground => JS('bool', '#.transparentBackground', this._ jsObject); | |
| 240 | |
| 241 void set transparentBackground(bool transparentBackground) { | |
| 242 JS('void', '#.transparentBackground = #', this._jsObject, transparentBackgro und); | |
| 243 } | |
| 244 | |
| 245 /// If true, the window will be created in a hidden state. Call show() on the | |
| 246 /// window to show it once it has been created. Defaults to false. | |
| 247 bool get hidden => JS('bool', '#.hidden', this._jsObject); | |
| 248 | |
| 249 void set hidden(bool hidden) { | |
| 250 JS('void', '#.hidden = #', this._jsObject, hidden); | |
| 251 } | |
| 252 | |
| 253 /// By default if you specify an id for the window, the window will only be | |
| 254 /// created if another window with the same id doesn't already exist. If a | |
| 255 /// window with the same id already exists that window is activated instead. I f | |
| 256 /// you do want to create multiple windows with the same id, you can set this | |
| 257 /// property to false. | |
| 258 bool get singleton => JS('bool', '#.singleton', this._jsObject); | |
| 259 | |
| 260 void set singleton(bool singleton) { | |
| 261 JS('void', '#.singleton = #', this._jsObject, singleton); | |
| 262 } | |
| 263 } | |
| 264 | |
| 265 class AppWindow extends ChromeObject { | |
| 266 /* | |
| 267 * Private constructor | |
| 268 */ | |
| 269 AppWindow._proxy(_jsObject) : super._proxy(_jsObject); | |
| 270 | |
| 271 /* | |
| 272 * Public accessors | |
| 273 */ | |
| 274 | |
| 275 /// The JavaScript 'window' object for the created child. | |
| 276 // TODO(sashab, sra): Detect whether this is the current window, or an | |
| 277 // external one, and return an appropriately-typed object | |
| 278 WindowBase get contentWindow => | |
| 279 JS("Window", "#.contentWindow", this._jsObject); | |
| 280 | |
| 281 /* | |
| 282 * Methods | |
| 283 */ | |
| 284 /// Focus the window. | |
| 285 void focus() => JS('void', '#.focus()', this._jsObject); | |
| 286 /// Minimize the window. | |
| 287 void minimize() => JS('void', '#.minimize()', this._jsObject); | |
| 288 /// Is the window minimized? | |
| 289 void isMinimized() => JS('void', '#.isMinimized()', this._jsObject); | |
| 290 /// Maximize the window. | |
| 291 void maximize() => JS('void', '#.maximize()', this._jsObject); | |
| 292 /// Is the window maximized? | |
| 293 void isMaximized() => JS('void', '#.isMaximized()', this._jsObject); | |
| 294 /// Restore the window. | |
| 295 void restore() => JS('void', '#.restore()', this._jsObject); | |
| 296 /// Move the window to the position (|left|, |top|). | |
| 297 void moveTo(int left, int top) => JS('void', '#.moveTo(#, #)', this._jsObject, left, top); | |
| 298 /// Resize the window to |width|x|height| pixels in size. | |
| 299 void resizeTo(int width, int height) => JS('void', '#.resizeTo(#, #)', this._j sObject, width, height); | |
| 300 /// Draw attention to the window. | |
| 301 void drawAttention() => JS('void', '#.drawAttention()', this._jsObject); | |
| 302 /// Clear attention to the window. | |
| 303 void clearAttention() => JS('void', '#.clearAttention()', this._jsObject); | |
| 304 /// Close the window. | |
| 305 void close() => JS('void', '#.close()', this._jsObject); | |
| 306 /// Show the window. Does nothing if the window is already visible. | |
| 307 void show() => JS('void', '#.show()', this._jsObject); | |
| 308 /// Hide the window. Does nothing if the window is already hidden. | |
| 309 void hide() => JS('void', '#.hide()', this._jsObject); | |
| 310 /// Get the window's bounds as a $ref:Bounds object. | |
| 311 void getBounds() => JS('void', '#.getBounds()', this._jsObject); | |
| 312 /// Set the window's bounds. | |
| 313 void setBounds(Bounds bounds) => JS('void', '#.setBounds(#)', this._jsObject, convertArgument(bounds)); | |
| 314 /// Set the app icon for the window (experimental). Currently this is only | |
| 315 /// being implemented on Ash. TODO(stevenjb): Investigate implementing this on | |
| 316 /// Windows and OSX. | |
| 317 void setIcon(String icon_url) => JS('void', '#.setIcon(#)', this._jsObject, ic on_url); | |
| 318 } | |
| 319 | |
| 320 /** | |
| 321 * Events | |
| 322 */ | |
| 323 | |
| 324 /// Fired when the window is resized. | |
| 325 class Event_app_window_onBoundsChanged extends Event { | |
| 326 void addListener(void callback()) => super.addListener(callback); | |
| 327 | |
| 328 void removeListener(void callback()) => super.removeListener(callback); | |
| 329 | |
| 330 bool hasListener(void callback()) => super.hasListener(callback); | |
| 331 | |
| 332 Event_app_window_onBoundsChanged(jsObject) : super._(jsObject, 0); | |
| 333 } | |
| 334 | |
| 335 /// Fired when the window is closed. | |
| 336 class Event_app_window_onClosed extends Event { | |
| 337 void addListener(void callback()) => super.addListener(callback); | |
| 338 | |
| 339 void removeListener(void callback()) => super.removeListener(callback); | |
| 340 | |
| 341 bool hasListener(void callback()) => super.hasListener(callback); | |
| 342 | |
| 343 Event_app_window_onClosed(jsObject) : super._(jsObject, 0); | |
| 344 } | |
| 345 | |
| 346 /// Fired when the window is maximized. | |
| 347 class Event_app_window_onMaximized extends Event { | |
| 348 void addListener(void callback()) => super.addListener(callback); | |
| 349 | |
| 350 void removeListener(void callback()) => super.removeListener(callback); | |
| 351 | |
| 352 bool hasListener(void callback()) => super.hasListener(callback); | |
| 353 | |
| 354 Event_app_window_onMaximized(jsObject) : super._(jsObject, 0); | |
| 355 } | |
| 356 | |
| 357 /// Fired when the window is minimized. | |
| 358 class Event_app_window_onMinimized extends Event { | |
| 359 void addListener(void callback()) => super.addListener(callback); | |
| 360 | |
| 361 void removeListener(void callback()) => super.removeListener(callback); | |
| 362 | |
| 363 bool hasListener(void callback()) => super.hasListener(callback); | |
| 364 | |
| 365 Event_app_window_onMinimized(jsObject) : super._(jsObject, 0); | |
| 366 } | |
| 367 | |
| 368 /// Fired when the window is restored from being minimized or maximized. | |
| 369 class Event_app_window_onRestored extends Event { | |
| 370 void addListener(void callback()) => super.addListener(callback); | |
| 371 | |
| 372 void removeListener(void callback()) => super.removeListener(callback); | |
| 373 | |
| 374 bool hasListener(void callback()) => super.hasListener(callback); | |
| 375 | |
| 376 Event_app_window_onRestored(jsObject) : super._(jsObject, 0); | |
| 377 } | |
| 378 | |
| 379 /** | |
| 380 * Functions | |
| 381 */ | |
| 382 | |
| 383 class API_app_window { | |
| 384 /* | |
| 385 * API connection | |
| 386 */ | |
| 387 Object _jsObject; | |
| 388 | |
| 389 /* | |
| 390 * Events | |
| 391 */ | |
| 392 Event_app_window_onBoundsChanged onBoundsChanged; | |
| 393 Event_app_window_onClosed onClosed; | |
| 394 Event_app_window_onMaximized onMaximized; | |
| 395 Event_app_window_onMinimized onMinimized; | |
| 396 Event_app_window_onRestored onRestored; | |
| 397 | |
| 398 /* | |
| 399 * Functions | |
| 400 */ | |
| 401 | |
| 402 /// The size and position of a window can be specified in a number of differen t | |
| 403 /// ways. The most simple option is not specifying anything at all, in which | |
| 404 /// case a default size and platform dependent position will be used.<br/><br/ > | |
| 405 /// Another option is to use the top/left and width/height properties, which | |
| 406 /// will always put the window at the specified coordinates with the specified | |
| 407 /// size.<br/><br/> Yet another option is to give the window a (unique) id. | |
| 408 /// This id is then used to remember the size and position of the window | |
| 409 /// whenever it is moved or resized. This size and position is then used | |
| 410 /// instead of the specified bounds on subsequent opening of a window with the | |
| 411 /// same id. If you need to open a window with an id at a location other than | |
| 412 /// the remembered default, you can create it hidden, move it to the desired | |
| 413 /// location, then show it.<br/><br/> You can also combine these various | |
| 414 /// options, explicitly specifying for example the size while having the | |
| 415 /// position be remembered or other combinations like that. Size and position | |
| 416 /// are dealt with seperately, but individual coordinates are not. So if you | |
| 417 /// specify a top (or left) coordinate, you should also specify a left (or top ) | |
| 418 /// coordinate, and similar for size.<br/><br/> If you specify both a regular | |
| 419 /// and a default value for the same option the regular value is the only one | |
| 420 /// that takes effect. | |
| 421 void create(String url, [CreateWindowOptions options, void callback(AppWindow created_window)]) { | |
| 422 void __proxy_callback(created_window) { | |
| 423 if (?callback) { | |
| 424 callback(new AppWindow._proxy(created_window)); | |
| 425 } | |
| 426 } | |
| 427 JS('void', '#.create(#, #, #)', this._jsObject, url, convertArgument(options ), convertDartClosureToJS(__proxy_callback, 1)); | |
| 428 } | |
| 429 | |
| 430 /// Returns an $ref:AppWindow object for the current script context (ie | |
| 431 /// JavaScript 'window' object). This can also be called on a handle to a | |
| 432 /// script context for another page, for example: | |
| 433 /// otherWindow.chrome.app.window.current(). | |
| 434 void current() => JS('void', '#.current()', this._jsObject); | |
| 435 | |
| 436 void initializeAppWindow(Object state) => JS('void', '#.initializeAppWindow(#) ', this._jsObject, convertArgument(state)); | |
| 437 | |
| 438 API_app_window(this._jsObject) { | |
| 439 onBoundsChanged = new Event_app_window_onBoundsChanged(JS('', '#.onBoundsCha nged', this._jsObject)); | |
| 440 onClosed = new Event_app_window_onClosed(JS('', '#.onClosed', this._jsObject )); | |
| 441 onMaximized = new Event_app_window_onMaximized(JS('', '#.onMaximized', this. _jsObject)); | |
| 442 onMinimized = new Event_app_window_onMinimized(JS('', '#.onMinimized', this. _jsObject)); | |
| 443 onRestored = new Event_app_window_onRestored(JS('', '#.onRestored', this._js Object)); | |
| 444 } | |
| 445 } | |
| OLD | NEW |