Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: tools/dom/src/chrome/app.window.dart

Issue 12049030: Initial commit for Chrome.* APIs in Dart (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012, 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 // Id to identify the window. This will be used to remember the size
13 // and position of the window and restore that geometry when a window
14 // with the same id (and no explicit size or position) is later opened.
15 String _id;
16
17 // Default width of the window. (Deprecated; regular bounds act like this
18 // now.)
19 int _defaultWidth;
20
21 // Default height of the window. (Deprecated; regular bounds act like this
22 // now.)
23 int _defaultHeight;
24
25 // Default X coordinate of the window. (Deprecated; regular bounds act like
26 // this now.)
27 int _defaultLeft;
28
29 // Default Y coordinate of the window. (Deprecated; regular bounds act like
30 // this now.)
31 int _defaultTop;
32
33 // Width of the window. (Deprecated; use 'bounds'.)
34 int _width;
35
36 // Height of the window. (Deprecated; use 'bounds'.)
37 int _height;
38
39 // X coordinate of the window. (Deprecated; use 'bounds'.)
40 int _left;
41
42 // Y coordinate of the window. (Deprecated; use 'bounds'.)
43 int _top;
44
45 // Minimium width of the window.
46 int _minWidth;
47
48 // Minimum height of the window.
49 int _minHeight;
50
51 // Maximum width of the window.
52 int _maxWidth;
53
54 // Maximum height of the window.
55 int _maxHeight;
56
57 // Window type: 'shell' (the default) is the only currently supported value.
58 String _type;
59
60 // Frame type: 'none' or 'chrome' (defaults to 'chrome').
61 String _frame;
62
63 // Size of the content in the window (excluding the titlebar). If specified
64 // in addition to any of the left/top/width/height parameters, this field
65 // takes precedence. If a frameBounds is specified, the frameBounds take
66 // precedence.
67 Bounds _bounds;
68
69 // If true, the window will be created in a hidden state. Call show() on
70 // the window to show it once it has been created. Defaults to false.
71 bool _hidden;
72
73 /*
74 * Public constructor
75 */
76 CreateWindowOptions({
77 String id,
78 int defaultWidth,
79 int defaultHeight,
80 int defaultLeft,
81 int defaultTop,
82 int width,
83 int height,
84 int left,
85 int top,
86 int minWidth,
87 int minHeight,
88 int maxWidth,
89 int maxHeight,
90 String type,
91 String frame,
92 Bounds bounds,
93 bool hidden
94 }) :
95 _id = id,
96 _defaultWidth = defaultWidth,
97 _defaultHeight = defaultHeight,
98 _defaultLeft = defaultLeft,
99 _defaultTop = defaultTop,
100 _width = width,
101 _height = height,
102 _left = left,
103 _top = top,
104 _minWidth = minWidth,
105 _minHeight = minHeight,
106 _maxWidth = maxWidth,
107 _maxHeight = maxHeight,
108 _type = type,
109 _frame = frame,
110 _bounds = bounds,
111 _hidden = hidden
112 ;
113
114 /*
115 * Private constructor
116 */
117 CreateWindowOptions._proxy(_jsObject)
118 : super._proxy(_jsObject);
119
120 /*
121 * Serialisation method
122 */
123 Map _toMap() {
124 Map m = {};
125 if (id != null) m['id'] = id;
126 if (defaultWidth != null) m['defaultWidth'] = defaultWidth;
127 if (defaultHeight != null) m['defaultHeight'] = defaultHeight;
128 if (defaultLeft != null) m['defaultLeft'] = defaultLeft;
129 if (defaultTop != null) m['defaultTop'] = defaultTop;
130 if (width != null) m['width'] = width;
131 if (height != null) m['height'] = height;
132 if (left != null) m['left'] = left;
133 if (top != null) m['top'] = top;
134 if (minWidth != null) m['minWidth'] = minWidth;
135 if (minHeight != null) m['minHeight'] = minHeight;
136 if (maxWidth != null) m['maxWidth'] = maxWidth;
137 if (maxHeight != null) m['maxHeight'] = maxHeight;
138 if (type != null) m['type'] = type;
139 if (frame != null) m['frame'] = frame;
140 if (bounds != null) m['bounds'] = bounds;
141 if (hidden != null) m['hidden'] = hidden;
142 return m;
143 }
144
145 /*
146 * Public accessors
147 */
148 String get id {
149 if (!this._hasProxy())
150 return this._id;
151 return JS('String', '#.id', this._jsObject);
152 }
153
154 void set id(String id) {
155 if (!this._hasProxy())
156 this._id = id;
157 else
158 JS('void', '#.id = #', this._jsObject, convertArgument(id));
159 }
160
161 int get defaultWidth {
162 if (!this._hasProxy())
163 return this._defaultWidth;
164 return JS('int', '#.defaultWidth', this._jsObject);
165 }
166
167 void set defaultWidth(int defaultWidth) {
168 if (!this._hasProxy())
169 this._defaultWidth = defaultWidth;
170 else
171 JS('void', '#.defaultWidth = #', this._jsObject, convertArgument(defaultWi dth));
172 }
173
174 int get defaultHeight {
175 if (!this._hasProxy())
176 return this._defaultHeight;
177 return JS('int', '#.defaultHeight', this._jsObject);
178 }
179
180 void set defaultHeight(int defaultHeight) {
181 if (!this._hasProxy())
182 this._defaultHeight = defaultHeight;
183 else
184 JS('void', '#.defaultHeight = #', this._jsObject, convertArgument(defaultH eight));
185 }
186
187 int get defaultLeft {
188 if (!this._hasProxy())
189 return this._defaultLeft;
190 return JS('int', '#.defaultLeft', this._jsObject);
191 }
192
193 void set defaultLeft(int defaultLeft) {
194 if (!this._hasProxy())
195 this._defaultLeft = defaultLeft;
196 else
197 JS('void', '#.defaultLeft = #', this._jsObject, convertArgument(defaultLef t));
198 }
199
200 int get defaultTop {
201 if (!this._hasProxy())
202 return this._defaultTop;
203 return JS('int', '#.defaultTop', this._jsObject);
204 }
205
206 void set defaultTop(int defaultTop) {
207 if (!this._hasProxy())
208 this._defaultTop = defaultTop;
209 else
210 JS('void', '#.defaultTop = #', this._jsObject, convertArgument(defaultTop) );
211 }
212
213 int get width {
214 if (!this._hasProxy())
215 return this._width;
216 return JS('int', '#.width', this._jsObject);
217 }
218
219 void set width(int width) {
220 if (!this._hasProxy())
221 this._width = width;
222 else
223 JS('void', '#.width = #', this._jsObject, convertArgument(width));
224 }
225
226 int get height {
227 if (!this._hasProxy())
228 return this._height;
229 return JS('int', '#.height', this._jsObject);
230 }
231
232 void set height(int height) {
233 if (!this._hasProxy())
234 this._height = height;
235 else
236 JS('void', '#.height = #', this._jsObject, convertArgument(height));
237 }
238
239 int get left {
240 if (!this._hasProxy())
241 return this._left;
242 return JS('int', '#.left', this._jsObject);
243 }
244
245 void set left(int left) {
246 if (!this._hasProxy())
247 this._left = left;
248 else
249 JS('void', '#.left = #', this._jsObject, convertArgument(left));
250 }
251
252 int get top {
253 if (!this._hasProxy())
254 return this._top;
255 return JS('int', '#.top', this._jsObject);
256 }
257
258 void set top(int top) {
259 if (!this._hasProxy())
260 this._top = top;
261 else
262 JS('void', '#.top = #', this._jsObject, convertArgument(top));
263 }
264
265 int get minWidth {
266 if (!this._hasProxy())
267 return this._minWidth;
268 return JS('int', '#.minWidth', this._jsObject);
269 }
270
271 void set minWidth(int minWidth) {
272 if (!this._hasProxy())
273 this._minWidth = minWidth;
274 else
275 JS('void', '#.minWidth = #', this._jsObject, convertArgument(minWidth));
276 }
277
278 int get minHeight {
279 if (!this._hasProxy())
280 return this._minHeight;
281 return JS('int', '#.minHeight', this._jsObject);
282 }
283
284 void set minHeight(int minHeight) {
285 if (!this._hasProxy())
286 this._minHeight = minHeight;
287 else
288 JS('void', '#.minHeight = #', this._jsObject, convertArgument(minHeight));
289 }
290
291 int get maxWidth {
292 if (!this._hasProxy())
293 return this._maxWidth;
294 return JS('int', '#.maxWidth', this._jsObject);
295 }
296
297 void set maxWidth(int maxWidth) {
298 if (!this._hasProxy())
299 this._maxWidth = maxWidth;
300 else
301 JS('void', '#.maxWidth = #', this._jsObject, convertArgument(maxWidth));
302 }
303
304 int get maxHeight {
305 if (!this._hasProxy())
306 return this._maxHeight;
307 return JS('int', '#.maxHeight', this._jsObject);
308 }
309
310 void set maxHeight(int maxHeight) {
311 if (!this._hasProxy())
312 this._maxHeight = maxHeight;
313 else
314 JS('void', '#.maxHeight = #', this._jsObject, convertArgument(maxHeight));
315 }
316
317 String get type {
318 if (!this._hasProxy())
319 return this._type;
320 return JS('String', '#.type', this._jsObject);
321 }
322
323 void set type(String type) {
324 if (!this._hasProxy())
325 this._type = type;
326 else
327 JS('void', '#.type = #', this._jsObject, convertArgument(type));
328 }
329
330 String get frame {
331 if (!this._hasProxy())
332 return this._frame;
333 return JS('String', '#.frame', this._jsObject);
334 }
335
336 void set frame(String frame) {
337 if (!this._hasProxy())
338 this._frame = frame;
339 else
340 JS('void', '#.frame = #', this._jsObject, convertArgument(frame));
341 }
342
343 Bounds get bounds {
344 if (!this._hasProxy())
345 return this._bounds;
346 return new Bounds._proxy(JS('Bounds', '#.bounds', this._jsObject));
347 }
348
349 void set bounds(Bounds bounds) {
350 if (!this._hasProxy())
351 this._bounds = bounds;
352 else
353 JS('void', '#.bounds = #', this._jsObject, convertArgument(bounds));
354 }
355
356 bool get hidden {
357 if (!this._hasProxy())
358 return this._hidden;
359 return JS('String', '#.hidden', this._jsObject);
360 }
361
362 void set hidden(bool hidden) {
363 if (!this._hasProxy())
364 this._hidden = hidden;
365 else
366 JS('void', '#.hidden = #', this._jsObject, convertArgument(hidden));
367 }
368 }
369
370 class Bounds extends ChromeObject {
371 int _left;
372 int _top;
373 int _width;
374 int _height;
375
376 /*
377 * Public constructor
378 */
379 Bounds({
380 int left,
381 int top,
382 int width,
383 int height
384 }) :
385 _left = left,
386 _top = top,
387 _width = width,
388 _height = height
389 ;
390
391
392 /*
393 * Private constructor
394 */
395 Bounds._proxy(_jsObject)
396 : super._proxy(_jsObject);
397
398 /*
399 * Serialisation method
400 */
401 Map _toMap() {
402 Map m = {};
403 if (left != null) m['left'] = left;
404 if (top != null) m['top'] = top;
405 if (width != null) m['width'] = width;
406 if (height != null) m['height'] = height;
407 return m;
408 }
409
410 /*
411 * Public accessors
412 */
413 int get width {
414 if (!this._hasProxy())
415 return this._width;
416 return JS('int', '#.width', this._jsObject);
417 }
418
419 void set width(int width) {
420 if (!this._hasProxy())
421 this._width = width;
422 else
423 JS('void', '#.width = #', this._jsObject, convertArgument(width));
424 }
425
426 int get height {
427 if (!this._hasProxy())
428 return this._height;
429 return JS('int', '#.height', this._jsObject);
430 }
431
432 void set height(int height) {
433 if (!this._hasProxy())
434 this._height = height;
435 else
436 JS('void', '#.height = #', this._jsObject, convertArgument(height));
437 }
438
439 int get left {
440 if (!this._hasProxy())
441 return this._left;
442 return JS('int', '#.left', this._jsObject);
443 }
444
445 void set left(int left) {
446 if (!this._hasProxy())
447 this._left = left;
448 else
449 JS('void', '#.left = #', this._jsObject, convertArgument(left));
450 }
451
452 int get top {
453 if (!this._hasProxy())
454 return this._top;
455 return JS('int', '#.top', this._jsObject);
456 }
457
458 void set top(int top) {
459 if (!this._hasProxy())
460 this._top = top;
461 else
462 JS('void', '#.top = #', this._jsObject, convertArgument(top));
463 }
464 }
465
466 class AppWindow extends ChromeObject {
467 /*
468 * Public constructor
469 * TODO(sashab): Does it make sense to be able to create a new AppWindow this way?
470 */
471 //AppWindow();
472
473 /*
474 * Private constructor
475 */
476 AppWindow._proxy(jsObject)
477 : super._proxy(jsObject);
478
479 /*
480 * Serialisation method
481 */
482 Map _toMap() {
483 return {};
484 }
485
486 /*
487 * Public accessors
488 */
489 // The JavaScript 'window' object for the created child.
490 // TODO(sashab, sra): Detect whether this is the current window, or an
491 // external one, and return an appropriately-typed object
492 WindowBase get contentWindow {
493 return JS("Window", "#.contentWindow", this._jsObject);
494 }
495
496 /*
497 * Functions
498 */
499
500 // Focus the window.
501 void focus() =>
502 JS("void", "#.focus()", this._jsObject);
503
504 // Minimize the window.
505 void minimize() =>
506 JS("void", "#.minimize()", this._jsObject);
507
508 // Is the window minimized?
509 bool isMinimized() =>
510 JS("bool", "#.isMinimized()", this._jsObject);
511
512 // Maximize the window.
513 void maximize() =>
514 JS("void", "#.maximize()", this._jsObject);
515
516 // Is the window maximized?
517 bool isMaximized() =>
518 JS("bool", "c#.isMaximized()", this._jsObject);
519
520 // Restore the window.
521 void restore() =>
522 JS("void", "#.restore()", this._jsObject);
523
524 // Move the window to the position (|left|, |top|).
525 void moveTo(int left, int top) =>
526 JS("void", "#.moveTo(#, #)", this._jsObject, left, top);
527
528 // Resize the window to |width|x|height| pixels in size.
529 void resizeTo(int width, int height) =>
530 JS("void", "#.resizeTo(#, #)", this._jsObject, width, height);
531
532 // Draw attention to the window.
533 void drawAttention() =>
534 JS("void", "#.drawAttention()", this._jsObject);
535
536 // Clear attention to the window.
537 void clearAttention() =>
538 JS("void", "#.clearAttention()", this._jsObject);
539
540 // Close the window.
541 void close() =>
542 JS("void", "#.close()", this._jsObject);
543
544 // Show the window. Does nothing if the window is already visible.
545 void show() =>
546 JS("void", "#.show()", this._jsObject);
547
548 // Hide the window. Does nothing if the window is already hidden.
549 void hide() =>
550 JS("void", "#.hide()", this._jsObject);
551
552 // Set the window's bounds.
553 void setBounds(Bounds bounds) =>
554 JS("void", "#.setBounds(#)", this._jsObject, convertArgument(bounds));
555
556 }
557
558 /**
559 * Functions
560 */
561 class $API_ChromeAppWindow {
562 /**
563 * JS object
564 */
565 Object _jsObject;
566
567 /**
568 * Constructor
569 */
570 $API_ChromeAppWindow(this._jsObject);
571
572 /**
573 * Functions
574 */
575
576 // Returns an <a href="#type-AppWindow">AppWindow</a> object for the
577 // current script context (ie JavaScript 'window' object). This can also be
578 // called on a handle to a script context for another page, for example:
579 // otherWindow.chrome.app.window.current().
580 AppWindow current() =>
581 new AppWindow._proxy(JS("Object", "#.current()", this._jsObject));
582
583 // The size and position of a window can be specified in a number of
584 // different ways. The most simple option is not specifying anything at
585 // all, in which case a default size and platform dependent position will
586 // be used.
587 //
588 // Another option is to use the top/left and width/height properties,
589 // which will always put the window at the specified coordinates with the
590 // specified size.
591 //
592 // Yet another option is to give the window a (unique) id. This id is then
593 // used to remember the size and position of the window whenever it is
594 // moved or resized. This size and position is then used instead of the
595 // specified bounds on subsequent opening of a window with the same id. If
596 // you need to open a window with an id at a location other than the
597 // remembered default, you can create it hidden, move it to the desired
598 // location, then show it.
599 //
600 // You can also combine these various options, explicitly specifying for
601 // example the size while having the position be remembered or other
602 // combinations like that. Size and position are dealt with seperately,
603 // but individual coordinates are not. So if you specify a top (or left)
604 // coordinate, you should also specify a left (or top) coordinate, and
605 // similar for size.
606 //
607 // If you specify both a regular and a default value for the same option
608 // the regular value is the only one that takes effect.
609 void create(String url, [ CreateWindowOptions options, void callback(AppWindow created_window) ]) {
610 void __proxy_callback(Object created_window) {
611 if (?callback)
612 callback(new AppWindow._proxy(created_window));
613 }
614
615 JS("void", "#.create(#, #, #)",
616 this._jsObject,
617 url,
618 convertArgument(options),
619 convertDartClosureToJS(__proxy_callback, 1)
620 );
621 }
622 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698