01: /*
02: * Copyright (C) 2004 TiongHiang Lee
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: *
18: * Email: thlee@onemindsoft.org
19: */
20:
21: package org.onemind.swingweb.client.gwt.widget;
22:
23: import com.google.gwt.user.client.DOM;
24: import com.google.gwt.user.client.Event;
25: import com.google.gwt.user.client.ui.*;
26:
27: public class MousePanel extends SimplePanel implements
28: SourcesMouseEvents {
29:
30: private MouseListenerCollection mouseListeners;
31:
32: public MousePanel() {
33: super ();
34: sinkEvents(Event.MOUSEEVENTS);
35: }
36:
37: public void addMouseListener(MouseListener listener) {
38: if (mouseListeners == null) {
39: mouseListeners = new MouseListenerCollection();
40: }
41: mouseListeners.add(listener);
42: }
43:
44: public void removeMouseListener(MouseListener listener) {
45: if (mouseListeners != null) {
46: mouseListeners.remove(listener);
47: }
48: }
49:
50: public void onBrowserEvent(Event event) {
51: switch (DOM.eventGetType(event)) {
52: case Event.ONMOUSEDOWN:
53: case Event.ONMOUSEUP:
54: case Event.ONMOUSEMOVE:
55: case Event.ONMOUSEOVER:
56: case Event.ONMOUSEOUT:
57: if (mouseListeners != null) {
58: mouseListeners.fireMouseEvent(this, event);
59: }
60: break;
61: }
62: }
63: }
|