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#UIEvent} class.</p>
028  * <p>This class is a subclass of {@link JsEvent} and defines the type of {@link JsEvent} 
029  * object passed to events of type <tt>DOMFocusIn</tt>, <tt>DOMFocusOut</tt>, and 
030  * <tt>DOMActivate</tt>. These event types are not commonly used in web browsers, and 
031  * what is more important about the {@link JsUIEvent} is that it is the parent of 
032  * {@link JsMouseEvent}.</p>
033  * @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>
034  *
035  * @javascript <b>Opaque</b> types can be resolved but no class objects for them can be
036  * generated into the target codes. Re-compilers must exit with error on the operations of
037  * accessing that kind of class objects.
038  * The <tt>checkcast</tt> operation to the class literal of this interface must be ignored
039  * and <tt>instanceof</tt> to it always <tt>true</tt>.
040  */
041 public class JsUIEvent extends JsClient.UIEvent.Prototype
042 {
043     /**
044      * <p>An <b>internal</b> class containing membership data for its enclosing
045      * opaque class.</p>
046      * <p>This class is only used inside of <b>opaque</b> or <b>internal</b> classes or
047      * class members.</p>
048      *
049      * @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>
050      * 
051      * @javascript Re-compilers must report error on resolving an <b>internal</b> class.
052      */
053     protected static abstract class Members extends JsClient.UIEvent.Prototype.Members
054     {
055         /**
056          * <p>An <b>internal</b> static field defining a member ID of the field name and
057          * used internally to define a member of the same name.</p>
058          * @since 1.0
059          * @see JsUIEvent#detail
060          * @see JsUIEvent.Member#detail
061          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
062          */
063         public final static Mid detail = id("detail");
064         /**
065          * <p>An <b>internal</b> static field defining a member ID of the field name and
066          * used internally to define a member of the same name.</p>
067          * @since 1.0
068          * @see JsUIEvent#view
069          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
070          */
071         public final static Mid view   = id("view"  );
072     }
073 
074     /**
075      * <p>An <b>opaque</b> class representing members of its enclosing <b>opaque</b> type.</p>
076      * <p>Note that, this class is <b>opaque</b> but its constructors are all <b>internal</b>. 
077      * This class and the subclasses of this class are used to declare either <b>opaque</b> 
078      * <tt>public</tt> instance fields of the opaque type {@link js.Var.Member} or the 
079      * <b>opaque</b> <tt>public</tt> static fields of other <b>opaque</b> types while their 
080      * constructors are used to define the fields inside <b>opaque</b> classes. Under 
081      * either circumstance, the field names must be exactly same as the member names, as 
082      * the <b>opaque</b> fields of <b>opaque</b> types are resolved by re-compilers directly 
083      * based on the field names.</p>
084      *
085      * @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>
086      * 
087      * @javascript <b>Opaque</b> types can be resolved but no class objects for them can be created
088      * in the target codes. Re-compilers must exit with error on operations accessing that kind 
089      * of class objects.
090      * Re-compilers must resolve an <b>opaque</b> instance field declared by this class in
091      * {@link js.Var.Member} or its subclasses to the JavaScript identifier: 
092      * <pre>q.m</pre>
093      * where <tt>m</tt> is the identifier of the field name and <tt>q</tt> is the identifier
094      * resolved from the instance of the enclosing member. Re-compilers must resolve an 
095      * <b>opaque</b> static field declared by this class in <b>opaque</b> types other than 
096      * {@link js.Var.Member} and its subclasses to the JavaScript identifier: 
097      * <pre>m</pre>
098      * where <tt>m</tt> is the identifier of the field name. And re-compilers must report
099      * error on the access to <b>opaque</b> fields declared by this class under any other 
100      * circumstances.
101      */
102     public static class Member extends JsClient.UIEvent.Prototype.Member
103     {
104         /**
105          * <p>Internally constructs a member based on a qualifying member.</p>
106          * <p>This constructor is <b>internal</b> and only called inside of <b>opaque</b>
107          * or <b>internal</b> classes or class members.</p>
108          * <p>Note that, this constructor is <b>internal</b> but its declaring class is
109          * <b>opaque</b>. This constructor is used to define <b>opaque</b> instance fields 
110          * declared in the declaring class of this constructor itself or its subclasses. 
111          * Under this circumstance, the field names must be exactly same as the member 
112          * names, as the <b>opaque</b> instance fields of the <b>opaque</b> type 
113          * {@link js.Var.Member} or its subclasses are resolved by re-compilers directly
114          * to their names appending to the name resolved from the specified qualifying 
115          * member with a dot in between.</p>
116          * @param q A qualifying member
117          * @param mid The ID of the member to construct
118          * @since 1.0
119          * @javascript Re-compilers must report error on the invocation to an <b>internal</b> constructor.
120          */
121         public Member(JsObject.Member q, Mid mid) {
122             super(q, mid);
123         }
124         /**
125          * <p>Internally constructs a member without a qualifying member.</p>
126          * <p>This constructor is <b>internal</b> and only called inside of <b>opaque</b>
127          * or <b>internal</b> classes or class members.</p>
128          * <p>Note that, this constructor is <b>internal</b> but its declaring class is
129          * <b>opaque</b>. This constructor is used to define <b>opaque</b> static fields, 
130          * declared in <b>opaque</b> types other than the declaring class of this constructor 
131          * itself and its subclasses. Under this circumstance, the field names must be
132          * exactly same as the member names, as the <b>opaque</b> static fields of <b>opaque</b>
133          * types are generally resolved by re-compilers directly to identifiers of their names.</p>
134          * @param mid The ID of the member to construct
135          * @since 1.0
136          * @javascript Re-compilers must report error on the invocation to an <b>internal</b> constructor.
137          */
138         public Member(Mid mid) {
139             super(mid);
140         }
141         @Override
142         /**
143          * <p>Evaluates the property, represented by the current member instance, of the
144          * argument object.</p>
145          * @param o The argument object
146          * @return The value of the current member based on the object argument.
147          * @since 1.0
148          * @javascript Re-compilers must convert the instance invocation of this method into
149          * the JavaScript expression: 
150          * <pre>o.m</pre>
151          * where <tt>m</tt> is the identifier name resolved from the current member
152          * instance of the invocation.
153          */
154         public JsUIEvent with(ObjectLike o) {
155             return new JsUIEvent(super.with(o));
156         }
157 
158         /**
159          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
160          * name of this field, qualified by the current member instance of the field, and 
161          * to access the property of the name on an object.</p>
162          * <p>The property, identified by this member, of a {@link JsUIEvent} object 
163          * refers to a read-only numeric value specifying detail about the event. For 
164          * "click", "mousedown", and "mouseup" events (see {@link JsMouseEvent}), this 
165          * value is the click count: 1 for a single-click, 2 for a double-click, 3 for 
166          * a triple-click, and so on. For "DOMActivate" events, the value is 1 for a 
167          * normal activation or 2 for a "hyperactivation," such as a double-click or 
168          * Shift-Enter combination.</p> 
169          * @since 1.0
170          * @javascript Re-compilers must resolve the member of this instance field to the
171          * identifier of the field name appending to the identifier resolved from its 
172          * qualifying member with a dot in between.
173          */
174         public final Value.Number.Member detail = new Value.Number.Member(this, Members.detail);
175     }
176 
177     /**
178      * <p>Casts an <b>opaque</b> object to the current <b>opaque</b> type by wrapping it
179      * with the wrapping constructor.</p>
180      * @param var The argument of an <b>opaque</b> object.
181      * @since 1.0
182      * @javascript Re-compilers must ignore the construction operation of this constructor,
183      * that is, replacing it with its only argument.
184      */
185     public JsUIEvent(JsObject var) {
186         super(var);
187     }
188 
189     /**
190      * <p>An <b>opaque</b> static field defining a member that is named by the field name
191      * without a qualifying member and to access the property of the name on an object.</p>
192      * <p>The property, identified by this member, of a {@link JsUIEvent} object 
193      * refers to a read-only numeric value specifying detail about the event. For 
194      * "click", "mousedown", and "mouseup" events (see {@link JsMouseEvent}), this 
195      * value is the click count: 1 for a single-click, 2 for a double-click, 3 for 
196      * a triple-click, and so on. For "DOMActivate" events, the value is 1 for a 
197      * normal activation or 2 for a "hyperactivation," such as a double-click or 
198      * Shift-Enter combination.</p> 
199      * @since 1.0
200      * @javascript Re-compilers must resolve the member of this static field to the
201      * identifier of the field name.
202      */
203     public static final Value.Number.Member detail = new Value.Number.Member(Members.detail);
204     /**
205      * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
206      * name of this field, qualified by the current member instance of the field, and 
207      * to access the property of the name on an object.</p>
208      * <p>The property, identified by this member, of a {@link JsUIEvent} object is 
209      * a read-only reference to the {@link JsWindow} object or the "view" in which the 
210      * event was generated.</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 static final JsWindow.Member view = new JsWindow.Member(Members.view);
217 
218     @Override
219     /**
220      * <p>Returns the primitive value associated with the current instance, if there is one.
221      * This invocation simply returns the instance itself for the current instance is an 
222      * object and there is no primitive value for it.</p>
223      * @return The current object itself.
224      * @since 1.0
225      * @javascript Re-compilers must convert the instance invocation of this method directly
226      * into a JavaScript invocation on its current object instance without changing the 
227      * method name, but expanding variable arguments, if any, into comma-separated values. 
228      */
229     public JsUIEvent valueOf() {
230         return new JsUIEvent((JsObject)var().valueOf());
231     }
232 
233     /**
234      * <p>Initializes the properties of a newly created {@link JsUIEvent} object, 
235      * including the properties inherited from {@link JsEvent}.</p>
236      * <p>This method initializes the {@link #view} and {@link #detail} properties of 
237      * the {@link JsUIEvent} object and also the {@link #type}, {@link #bubbles}, and 
238      * {@link #cancelable} properties inherited from {@link JsEvent}. This method may 
239      * be called on newly created {@link JsUIEvent} objects only before they have been 
240      * passed to {@link JsElement#dispatchEvent(JsEvent)} method to dispatch.</p>
241      * @param eventType The type of event.
242      * @param canBubble Specifies whether the event will bubble.
243      * @param cancelable Specifies whether the event can be canceled with {@link JsEvent#preventDefault()}.
244      * @param view The {@link JsWindow} object in which the event occurred.
245      * @param detail The {@link #detail} property for the event.
246      * @since 1.0
247      * @see JsEvent#initEvent(String, Boolean, Boolean)
248      * @see JsDocument#createEvent(String)
249      * @see JsMouseEvent#initMouseEvent(String, Boolean, Boolean, JsWindow, Number, Number, Number, Number, Number, Boolean, Boolean, Boolean, Boolean, Number, JsElement)
250      * @javascript Re-compilers must convert the instance invocation of this method directly
251      * into a JavaScript invocation on its current object instance without changing the 
252      * method name, but expanding variable arguments, if any, into comma-separated values. 
253      */
254     public final void initUIEvent(String eventType, Boolean canBubble, Boolean cancelable, JsWindow view, Long detail) {
255         call(initUIEvent, new Vars<Object>().add(eventType).add(canBubble).add(cancelable).add(view).add(detail));
256     }
257 }