|
1 /* |
|
2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 package com.nokia.microedition.m2g; |
|
20 |
|
21 import org.w3c.dom.events.*; |
|
22 import org.w3c.dom.svg.SVGElement; |
|
23 |
|
24 /** |
|
25 * The Event interface is used to provide contextual information about an event to the handler |
|
26 * processing the event. An object which implements the Event interface is passed as the first |
|
27 * parameter to the {@link org.w3c.dom.events.EventListener#handleEvent handleEvent} call. |
|
28 */ |
|
29 public class M2GEvent implements Event |
|
30 { |
|
31 public static final boolean EVENT_TARGET = false; |
|
32 public static final boolean WRAPPED_EVENT_TARGET = true; |
|
33 //-------------------------------------------------- |
|
34 // VARIABLES |
|
35 //-------------------------------------------------- |
|
36 private String iEventType; |
|
37 private EventTarget iTarget; |
|
38 private boolean iWrappedTarget; |
|
39 |
|
40 //-------------------------------------------------- |
|
41 // METHODS |
|
42 //-------------------------------------------------- |
|
43 /** |
|
44 * Constructor |
|
45 * @param aEventType Type |
|
46 * @param aTarget Target |
|
47 * @param aWrappedTarget If WRAPPED_EVENT_TARGET then <code>getCurrentTarget</code> |
|
48 * method returns a wrapped event target (which base class is NOT <code>Node</code>. |
|
49 * Otherwise normal event target (which base class is <code>Node</code>) is returned. |
|
50 */ |
|
51 public M2GEvent(String aEventType, EventTarget aTarget, boolean aWrappedTarget) |
|
52 { |
|
53 iEventType = aEventType; |
|
54 iTarget = aTarget; |
|
55 iWrappedTarget = aWrappedTarget; |
|
56 } |
|
57 |
|
58 /** |
|
59 * @see org.w3c.dom.events.Event#getCurrentTarget() |
|
60 * @see M2GEvent() |
|
61 */ |
|
62 public EventTarget getCurrentTarget() |
|
63 { |
|
64 if (iWrappedTarget) |
|
65 { |
|
66 if ((iTarget != null) && (iTarget instanceof M2GSVGElement)) |
|
67 { |
|
68 return new M2GSVGElementWrapper((M2GSVGElement)iTarget); |
|
69 } |
|
70 return null; |
|
71 } |
|
72 return iTarget; |
|
73 } |
|
74 |
|
75 /** |
|
76 * @see org.w3c.dom.events.Event#getType() |
|
77 */ |
|
78 public String getType() |
|
79 { |
|
80 return iEventType; |
|
81 } |
|
82 } |