01: // @@
02: // @@
03: /*
04: * Wi.Ser Framework
05: *
06: * LGPL Version: 1.8.1, 20-September-2007
07: * Copyright (C) 2005-2006 Dirk von der Weiden <dvdw@imail.de>
08: *
09: * This library is free software; you can redistribute it and/or
10: * modify it under the terms of the GNU Lesser General Public
11: * License as published by the Free Software Foundation; either
12: * version 2 of the License, or (at your option) any later version.
13: *
14: * This library is distributed in the hope that it will be useful,
15: * but WITHOUT ANY WARRANTY; without even the implied warranty of
16: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17: * Lesser General Public License for more details.
18: *
19: * You should have received a copy of the GNU Lesser General Public
20: * License along with this library located in LGPL.txt in the
21: * license directory; if not, write to the
22: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23: * Boston, MA 02111-1307, USA.
24: *
25: * If this agreement does not cover your requirements, please contact us
26: * via email to get detailed information about the commercial license
27: * or our service offerings!
28: *
29: */
30: // @@
31: package de.ug2t.channel.ho.client.swing;
32:
33: import java.awt.*;
34: import java.awt.event.*;
35:
36: import javax.swing.*;
37:
38: public class HoSwingMouseEventDispatcher {
39: public static final char MOUSE_CLICKED = 'C';
40: public static final char MOUSE_PRESSED = 'P';
41: public static final char MOUSE_RELEASED = 'R';
42: public static final char MOUSE_ENTERED = 'E';
43: public static final char MOUSE_EXITED = 'X';
44:
45: public static Component pcmf_dispatch(MouseEvent e, char xType,
46: Container l_cont) {
47: Component l_ret = l_cont;
48:
49: if (l_cont.contains(e.getPoint())) {
50: MouseListener l_listen[] = l_cont.getMouseListeners();
51: for (int i = 0; i < l_listen.length; i++) {
52: switch (xType) {
53: case MOUSE_CLICKED:
54: l_listen[i].mouseClicked(e);
55: break;
56: case MOUSE_PRESSED:
57: l_listen[i].mousePressed(e);
58: break;
59: case MOUSE_RELEASED:
60: l_listen[i].mouseReleased(e);
61: break;
62: case MOUSE_ENTERED:
63: l_listen[i].mouseEntered(e);
64: break;
65: case MOUSE_EXITED:
66: l_listen[i].mouseExited(e);
67: break;
68: }
69: }
70: }
71: Component l_scomp = l_cont.getComponentAt(e.getPoint());
72: if (l_scomp != null && l_scomp != l_cont) {
73: JComponent l_comp = (JComponent) e.getSource();
74:
75: e.setSource(l_scomp);
76: Rectangle l_rect = l_scomp.getBounds();
77: e.translatePoint(-l_rect.x, -l_rect.y);
78:
79: l_ret = HoSwingMouseEventDispatcher.pcmf_dispatch(e, xType,
80: (Container) l_scomp);
81:
82: e.translatePoint(l_rect.x, l_rect.y);
83: e.setSource(l_comp);
84: }
85: return (l_ret);
86: }
87: }
|