1/*
2 *  Licensed to the Apache Software Foundation (ASF) under one or more
3 *  contributor license agreements.  See the NOTICE file distributed with
4 *  this work for additional information regarding copyright ownership.
5 *  The ASF licenses this file to You under the Apache License, Version 2.0
6 *  (the "License"); you may not use this file except in compliance with
7 *  the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 */
17/**
18 * @author Michael Danilov
19 * @version $Revision$
20 */
21package java.awt.event;
22
23
24//???AWT
25//import java.awt.Window;
26//import java.awt.Frame;
27
28/**
29 * This class is not supported in Android 1.0. It is merely provided to maintain
30 * interface compatibility with desktop Java implementations.
31 *
32 * @since Android 1.0
33 */
34public class WindowEvent extends ComponentEvent {
35
36    private static final long serialVersionUID = -1567959133147912127L;
37
38    public static final int WINDOW_FIRST = 200;
39
40    public static final int WINDOW_OPENED = 200;
41
42    public static final int WINDOW_CLOSING = 201;
43
44    public static final int WINDOW_CLOSED = 202;
45
46    public static final int WINDOW_ICONIFIED = 203;
47
48    public static final int WINDOW_DEICONIFIED = 204;
49
50    public static final int WINDOW_ACTIVATED = 205;
51
52    public static final int WINDOW_DEACTIVATED = 206;
53
54    public static final int WINDOW_GAINED_FOCUS = 207;
55
56    public static final int WINDOW_LOST_FOCUS = 208;
57
58    public static final int WINDOW_STATE_CHANGED = 209;
59
60    public static final int WINDOW_LAST = 209;
61
62    //???AWT: private Window oppositeWindow;
63    private int oldState;
64    private int newState;
65
66    //???AWT
67    /*
68    public WindowEvent(Window source, int id) {
69        this(source, id, null);
70    }
71
72    public WindowEvent(Window source, int id, Window opposite) {
73        this(source, id, opposite, Frame.NORMAL, Frame.NORMAL);
74    }
75
76    public WindowEvent(Window source, int id, int oldState, int newState) {
77        this(source, id, null, oldState, newState);
78    }
79
80    public WindowEvent(Window source, int id, Window opposite,
81                       int oldState, int newState) {
82        super(source, id);
83
84        oppositeWindow = opposite;
85        this.oldState = oldState;
86        this.newState = newState;
87    }
88    */
89    //???AWT: Fake constructor
90    public WindowEvent() {
91        super(null, 0);
92    }
93
94    public int getNewState() {
95        return newState;
96    }
97
98    public int getOldState() {
99        return oldState;
100    }
101
102    //???AWT
103    /*
104    public Window getOppositeWindow() {
105        return oppositeWindow;
106    }
107
108    public Window getWindow() {
109        return (Window) source;
110    }
111    */
112
113    @Override
114    public String paramString() {
115        /* The format is based on 1.5 release behavior
116         * which can be revealed by the following code:
117         *
118         * WindowEvent e = new WindowEvent(new Frame(),
119         *          WindowEvent.WINDOW_OPENED);
120         * System.out.println(e);
121         */
122
123        String typeString = null;
124
125        switch (id) {
126        case WINDOW_OPENED:
127            typeString = "WINDOW_OPENED"; //$NON-NLS-1$
128            break;
129        case WINDOW_CLOSING:
130            typeString = "WINDOW_CLOSING"; //$NON-NLS-1$
131            break;
132        case WINDOW_CLOSED:
133            typeString = "WINDOW_CLOSED"; //$NON-NLS-1$
134            break;
135        case WINDOW_ICONIFIED:
136            typeString = "WINDOW_ICONIFIED"; //$NON-NLS-1$
137            break;
138        case WINDOW_DEICONIFIED:
139            typeString = "WINDOW_DEICONIFIED"; //$NON-NLS-1$
140            break;
141        case WINDOW_ACTIVATED:
142            typeString = "WINDOW_ACTIVATED"; //$NON-NLS-1$
143            break;
144        case WINDOW_DEACTIVATED:
145            typeString = "WINDOW_DEACTIVATED"; //$NON-NLS-1$
146            break;
147        case WINDOW_GAINED_FOCUS:
148            typeString = "WINDOW_GAINED_FOCUS"; //$NON-NLS-1$
149            break;
150        case WINDOW_LOST_FOCUS:
151            typeString = "WINDOW_LOST_FOCUS"; //$NON-NLS-1$
152            break;
153        case WINDOW_STATE_CHANGED:
154            typeString = "WINDOW_STATE_CHANGED"; //$NON-NLS-1$
155            break;
156        default:
157            typeString = "unknown type"; //$NON-NLS-1$
158        }
159
160        //???AWT
161        /*
162        return typeString + ",opposite=" + oppositeWindow + //$NON-NLS-1$
163                ",oldState=" + oldState + ",newState=" + newState; //$NON-NLS-1$ //$NON-NLS-2$
164        */
165        return typeString;
166    }
167
168}
169