001 
002 /*
003  *  JScripter Standard 1.0 - To Script In Java
004  *  Copyright (C) 2008-2011  J.J.Liu<jianjunliu@126.com> <http://www.jscripter.org>
005  *  
006  *  This program is free software: you can redistribute it and/or modify
007  *  it under the terms of the GNU Affero General Public License as published by
008  *  the Free Software Foundation, either version 3 of the License, or
009  *  (at your option) any later version.
010  *  
011  *  This program is distributed in the hope that it will be useful,
012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014  *  GNU Affero General Public License for more details.
015  *  
016  *  You should have received a copy of the GNU Affero General Public License
017  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
018  */
019 
020 package js.user;
021 
022 import js.*;
023 import js.core.*;
024 
025 /**
026  * <p>An <b>opaque</b> class representing JavaScript client-side objects of the global 
027  * {@link JsClient#Screen} class.</p>
028  * {@link JsWindow#screen} property of every {@link JsWindow} object refers to a {@link JsScreen} 
029  * object. The properties of this global object contain information about the screen on 
030  * which the browser is displayed. This information can be used to optimize the output 
031  * for the user's display capabilities. A program can choose between large and small 
032  * images based on the display size and between 8-bit and 16-bit color images based on 
033  * the screen's color depth. It can also use the information about the size of the 
034  * screen to center new browser windows on the screen.</p>
035  *
036  * @author <a href="mailto:jianjunliu@126.com">J.J.Liu (Jianjun Liu)</a> at <a href="http://www.jscripter.org" target="_blank">http://www.jscripter.org</a>
037  * @see JsWindow#screen
038  *
039  * @javascript <b>Opaque</b> types can be resolved but no class objects for them can be
040  * generated into the target codes. Re-compilers must exit with error on the operations of
041  * accessing that kind of class objects.
042  * The <tt>checkcast</tt> operation to the class literal of this interface must be ignored
043  * and <tt>instanceof</tt> to it always <tt>true</tt>.
044  */
045 public class JsScreen extends JsClient.Screen.Prototype
046 {
047     /**
048      * <p>An <b>internal</b> class containing membership data for its enclosing
049      * opaque class.</p>
050      * <p>This class is only used inside of <b>opaque</b> or <b>internal</b> classes or
051      * class members.</p>
052      *
053      * @author <a href="mailto:jianjunliu@126.com">J.J.Liu (Jianjun Liu)</a> at <a href="http://www.jscripter.org" target="_blank">http://www.jscripter.org</a>
054      * 
055      * @javascript Re-compilers must report error on resolving an <b>internal</b> class.
056      */
057     protected static abstract class Members extends JsClient.Screen.Prototype.Members
058     {
059         /**
060          * <p>An <b>internal</b> static field defining a member ID of the field name and
061          * used internally to define a member of the same name.</p>
062          * @since 1.0
063          * @see JsScreen#availHeight
064          * @see JsScreen.Member#availHeight
065          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
066          */
067         public final static Mid availHeight = id("availHeight");
068         /**
069          * <p>An <b>internal</b> static field defining a member ID of the field name and
070          * used internally to define a member of the same name.</p>
071          * @since 1.0
072          * @see JsScreen#availWidth
073          * @see JsScreen.Member#availWidth
074          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
075          */
076         public final static Mid availWidth  = id("availWidth" );
077         /**
078          * <p>An <b>internal</b> static field defining a member ID of the field name and
079          * used internally to define a member of the same name.</p>
080          * @since 1.0
081          * @see JsScreen#colorDepth
082          * @see JsScreen.Member#colorDepth
083          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
084          */
085         public final static Mid colorDepth  = id("colorDepth" );
086         /**
087          * <p>An <b>internal</b> static field defining a member ID of the field name and
088          * used internally to define a member of the same name.</p>
089          * @since 1.0
090          * @see JsScreen#height
091          * @see JsScreen.Member#height
092          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
093          */
094         public final static Mid height      = id("height"     );
095         /**
096          * <p>An <b>internal</b> static field defining a member ID of the field name and
097          * used internally to define a member of the same name.</p>
098          * @since 1.0
099          * @see JsScreen#width
100          * @see JsScreen.Member#width
101          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
102          */
103         public final static Mid width       = id("width"      );
104     }
105     /**
106      * <p>An <b>opaque</b> class representing members of its enclosing <b>opaque</b> type.</p>
107      * <p>Note that, this class is <b>opaque</b> but its constructors are all <b>internal</b>. 
108      * This class and the subclasses of this class are used to declare either <b>opaque</b> 
109      * <tt>public</tt> instance fields of the opaque type {@link js.Var.Member} or the 
110      * <b>opaque</b> <tt>public</tt> static fields of other <b>opaque</b> types while their 
111      * constructors are used to define the fields inside <b>opaque</b> classes. Under 
112      * either circumstance, the field names must be exactly same as the member names, as 
113      * the <b>opaque</b> fields of <b>opaque</b> types are resolved by re-compilers directly 
114      * based on the field names.</p>
115      *
116      * @author <a href="mailto:jianjunliu@126.com">J.J.Liu (Jianjun Liu)</a> at <a href="http://www.jscripter.org" target="_blank">http://www.jscripter.org</a>
117      * 
118      * @javascript <b>Opaque</b> types can be resolved but no class objects for them can be created
119      * in the target codes. Re-compilers must exit with error on operations accessing that kind 
120      * of class objects.
121      * Re-compilers must resolve an <b>opaque</b> instance field declared by this class in
122      * {@link js.Var.Member} or its subclasses to the JavaScript identifier: 
123      * <pre>q.m</pre>
124      * where <tt>m</tt> is the identifier of the field name and <tt>q</tt> is the identifier
125      * resolved from the instance of the enclosing member. Re-compilers must resolve an 
126      * <b>opaque</b> static field declared by this class in <b>opaque</b> types other than 
127      * {@link js.Var.Member} and its subclasses to the JavaScript identifier: 
128      * <pre>m</pre>
129      * where <tt>m</tt> is the identifier of the field name. And re-compilers must report
130      * error on the access to <b>opaque</b> fields declared by this class under any other 
131      * circumstances.
132      */
133     public static class Member extends JsClient.Screen.Prototype.Member
134     {
135         /**
136          * <p>Internally constructs a member based on a qualifying member.</p>
137          * <p>This constructor is <b>internal</b> and only called inside of <b>opaque</b>
138          * or <b>internal</b> classes or class members.</p>
139          * <p>Note that, this constructor is <b>internal</b> but its declaring class is
140          * <b>opaque</b>. This constructor is used to define <b>opaque</b> instance fields 
141          * declared in the declaring class of this constructor itself or its subclasses. 
142          * Under this circumstance, the field names must be exactly same as the member 
143          * names, as the <b>opaque</b> instance fields of the <b>opaque</b> type 
144          * {@link js.Var.Member} or its subclasses are resolved by re-compilers directly
145          * to their names appending to the name resolved from the specified qualifying 
146          * member with a dot in between.</p>
147          * @param q A qualifying member
148          * @param mid The ID of the member to construct
149          * @since 1.0
150          * @javascript Re-compilers must report error on the invocation to an <b>internal</b> constructor.
151          */
152         public Member(JsObject.Member q, Mid mid) {
153             super(q, mid);
154         }
155         /**
156          * <p>Internally constructs a member without a qualifying member.</p>
157          * <p>This constructor is <b>internal</b> and only called inside of <b>opaque</b>
158          * or <b>internal</b> classes or class members.</p>
159          * <p>Note that, this constructor is <b>internal</b> but its declaring class is
160          * <b>opaque</b>. This constructor is used to define <b>opaque</b> static fields, 
161          * declared in <b>opaque</b> types other than the declaring class of this constructor 
162          * itself and its subclasses. Under this circumstance, the field names must be
163          * exactly same as the member names, as the <b>opaque</b> static fields of <b>opaque</b>
164          * types are generally resolved by re-compilers directly to identifiers of their names.</p>
165          * @param mid The ID of the member to construct
166          * @since 1.0
167          * @javascript Re-compilers must report error on the invocation to an <b>internal</b> constructor.
168          */
169         public Member(Mid mid) {
170             super(mid);
171         }
172         @Override
173         /**
174          * <p>Evaluates the property, represented by the current member instance, of the
175          * argument object.</p>
176          * @param o The argument object
177          * @return The value of the current member based on the object argument.
178          * @since 1.0
179          * @javascript Re-compilers must convert the instance invocation of this method into
180          * the JavaScript expression: 
181          * <pre>o.m</pre>
182          * where <tt>m</tt> is the identifier name resolved from the current member
183          * instance of the invocation.
184          */
185         public JsScreen with(ObjectLike o) {
186             return new JsScreen(super.with(o));
187         }
188         /**
189          * <p>Evaluates a property, represented by the current member instance, of the
190          * JavaScript global object, that is, evaluates the member to a global identifier.</p>
191          * @return The value of the current member based on the JavaScript global object.
192          * @since 1.0
193          * @javascript Re-compilers must convert the instance invocation of this method into
194          * the JavaScript expression: 
195          * <pre>m</pre>
196          * where <tt>m</tt> is the identifier name resolved from the current member
197          * instance of the invocation.
198          */
199         public JsScreen with() {
200             return with(Js.win());
201         }
202         /**
203          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
204          * name of this field, qualified by the current member instance of the field, and 
205          * to access the property of the name on an object.</p>
206          * <p>The property, identified by this member, of a {@link JsScreen} object 
207          * refers to read-only number specifying the available height, in pixels, of the 
208          * screen on which the web browser is displayed. On operating systems such as 
209          * Windows, this available height does not include vertical space allocated to 
210          * semipermanent features, such as the task bar at the bottom of the screen.</p>
211          * @since 1.0
212          * @javascript Re-compilers must resolve the member of this instance field to the
213          * identifier of the field name appending to the identifier resolved from its 
214          * qualifying member with a dot in between.
215          */
216         public final Value.Number.Member availHeight = new Value.Number.Member(this, Members.availHeight);
217         /**
218          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
219          * name of this field, qualified by the current member instance of the field, and 
220          * to access the property of the name on an object.</p>
221          * <p>The property, identified by this member, of a {@link JsScreen} object 
222          * refers to read-only number specifying the available width, in pixels, of the 
223          * screen on which the web browser is displayed. On operating systems such as 
224          * Windows, this available width does not include horizontal space allocated to 
225          * semipermanent features, such as application shortcut bars.</p>
226          * @since 1.0
227          * @javascript Re-compilers must resolve the member of this instance field to the
228          * identifier of the field name appending to the identifier resolved from its 
229          * qualifying member with a dot in between.
230          */
231         public final Value.Number.Member availWidth  = new Value.Number.Member(this, Members.availWidth );
232         /**
233          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
234          * name of this field, qualified by the current member instance of the field, and 
235          * to access the property of the name on an object.</p>
236          * <p>The property, identified by this member, of a {@link JsScreen} object 
237          * refers to read-only number specifying the color depth of the screen in bits 
238          * per pixel.</p>
239          * @since 1.0
240          * @javascript Re-compilers must resolve the member of this instance field to the
241          * identifier of the field name appending to the identifier resolved from its 
242          * qualifying member with a dot in between.
243          */
244         public final Value.Number.Member colorDepth  = new Value.Number.Member(this, Members.colorDepth );
245         /**
246          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
247          * name of this field, qualified by the current member instance of the field, and 
248          * to access the property of the name on an object.</p>
249          * <p>The property, identified by this member, of a {@link JsScreen} object 
250          * refers to read-only number specifying the total height, in pixels, of the 
251          * screen on which the web browser is displayed.</p>
252          * @since 1.0
253          * @see #availHeight
254          * @javascript Re-compilers must resolve the member of this instance field to the
255          * identifier of the field name appending to the identifier resolved from its 
256          * qualifying member with a dot in between.
257          */
258         public final Value.Number.Member height      = new Value.Number.Member(this, Members.height     );
259         /**
260          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
261          * name of this field, qualified by the current member instance of the field, and 
262          * to access the property of the name on an object.</p>
263          * <p>The property, identified by this member, of a {@link JsScreen} object 
264          * refers to read-only number specifying the total width, in pixels, of the 
265          * screen on which the web browser is displayed.</p>
266          * @since 1.0
267          * @see #availWidth
268          * @javascript Re-compilers must resolve the member of this instance field to the
269          * identifier of the field name appending to the identifier resolved from its 
270          * qualifying member with a dot in between.
271          */
272         public final Value.Number.Member width       = new Value.Number.Member(this, Members.width      );
273     }
274 
275     /**
276      * <p>Casts an <b>opaque</b> object to the current <b>opaque</b> type by wrapping it
277      * with the wrapping constructor.</p>
278      * @param var The argument of an <b>opaque</b> object.
279      * @since 1.0
280      * @javascript Re-compilers must ignore the construction operation of this constructor,
281      * that is, replacing it with its only argument.
282      */
283     public JsScreen(JsObject var) {
284         super(var);
285     }
286 
287     /**
288      * <p>An <b>opaque</b> static field defining a member that is named by the field name
289      * without a qualifying member and to access the property of the name on an object.</p>
290      * <p>The property, identified by this member, of a {@link JsScreen} object 
291      * refers to read-only number specifying the available height, in pixels, of the 
292      * screen on which the web browser is displayed. On operating systems such as 
293      * Windows, this available height does not include vertical space allocated to 
294      * semipermanent features, such as the task bar at the bottom of the screen.</p>
295      * @since 1.0
296      * @javascript Re-compilers must resolve the member of this static field to the
297      * identifier of the field name.
298      */
299     public static final Value.Number.Member availHeight = new Value.Number.Member(Members.availHeight);
300     /**
301      * <p>An <b>opaque</b> static field defining a member that is named by the field name
302      * without a qualifying member and to access the property of the name on an object.</p>
303      * <p>The property, identified by this member, of a {@link JsScreen} object 
304      * refers to read-only number specifying the available width, in pixels, of the 
305      * screen on which the web browser is displayed. On operating systems such as 
306      * Windows, this available width does not include horizontal space allocated to 
307      * semipermanent features, such as application shortcut bars.</p>
308      * @since 1.0
309      * @javascript Re-compilers must resolve the member of this static field to the
310      * identifier of the field name.
311      */
312     public static final Value.Number.Member availWidth  = new Value.Number.Member(Members.availWidth );
313     /**
314      * <p>An <b>opaque</b> static field defining a member that is named by the field name
315      * without a qualifying member and to access the property of the name on an object.</p>
316      * <p>The property, identified by this member, of a {@link JsScreen} object 
317      * refers to read-only number specifying the color depth of the screen in bits 
318      * per pixel.</p>
319      * @since 1.0
320      * @javascript Re-compilers must resolve the member of this static field to the
321      * identifier of the field name.
322      */
323     public static final Value.Number.Member colorDepth  = new Value.Number.Member(Members.colorDepth );
324     /**
325      * <p>An <b>opaque</b> static field defining a member that is named by the field name
326      * without a qualifying member and to access the property of the name on an object.</p>
327      * <p>The property, identified by this member, of a {@link JsScreen} object 
328      * refers to read-only number specifying the total height, in pixels, of the 
329      * screen on which the web browser is displayed.</p>
330      * @since 1.0
331      * @see #availHeight
332      * @javascript Re-compilers must resolve the member of this static field to the
333      * identifier of the field name.
334      */
335     public static final Value.Number.Member height      = new Value.Number.Member(Members.height     );
336     /**
337      * <p>An <b>opaque</b> static field defining a member that is named by the field name
338      * without a qualifying member and to access the property of the name on an object.</p>
339      * <p>The property, identified by this member, of a {@link JsScreen} object 
340      * refers to read-only number specifying the total width, in pixels, of the 
341      * screen on which the web browser is displayed.</p>
342      * @since 1.0
343      * @see #availWidth
344      * @javascript Re-compilers must resolve the member of this static field to the
345      * identifier of the field name.
346      */
347     public static final Value.Number.Member width       = new Value.Number.Member(Members.width      );
348 
349     @Override
350     /**
351      * <p>Returns the primitive value associated with the current instance, if there is one.
352      * This invocation simply returns the instance itself for the current instance is an 
353      * object and there is no primitive value for it.</p>
354      * @return The current object itself.
355      * @since 1.0
356      * @javascript Re-compilers must convert the instance invocation of this method directly
357      * into a JavaScript invocation on its current object instance without changing the 
358      * method name, but expanding variable arguments, if any, into comma-separated values. 
359      */
360     public JsScreen valueOf() {
361         return new JsScreen((JsObject)var().valueOf());
362     }
363 }