comparison org.eclipse.draw2d/src/org/eclipse/draw2d/Layer.d @ 12:bc29606a740c

Added dwt-addons in original directory structure of eclipse.org
author Frank Benoit <benoit@tionex.de>
date Sat, 14 Mar 2009 18:23:29 +0100
parents
children
comparison
equal deleted inserted replaced
11:43904fec5dca 12:bc29606a740c
1 /*******************************************************************************
2 * Copyright (c) 2000, 2005 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 * Port to the D programming language:
11 * Frank Benoit <benoit@tionex.de>
12 *******************************************************************************/
13 module org.eclipse.draw2d.Layer;
14
15 import java.lang.all;
16
17 import org.eclipse.draw2d.geometry.Point;
18 import org.eclipse.draw2d.Figure;
19 import org.eclipse.draw2d.IFigure;
20 import org.eclipse.draw2d.TreeSearch;
21
22
23 /**
24 * A transparent figure intended to be added exclusively to a {@link LayeredPane}, who has
25 * the responsibilty of managing its layers.
26 */
27 public class Layer
28 : Figure
29 {
30
31 /**
32 * Overridden to implement transparent behavior.
33 * @see IFigure#containsPoint(int, int)
34 *
35 */
36 public bool containsPoint(int x, int y) {
37 if (isOpaque())
38 return super.containsPoint(x, y);
39 Point pt = new Point(x, y);
40 translateFromParent(pt);
41 for (int i = 0; i < getChildren().size(); i++) {
42 IFigure child = cast(IFigure)getChildren().get(i);
43 if (child.containsPoint(pt.x, pt.y))
44 return true;
45 }
46 return false;
47 }
48
49 /**
50 * Overridden to implement transparency.
51 * @see IFigure#findFigureAt(int, int, TreeSearch)
52 */
53 public IFigure findFigureAt(int x, int y, TreeSearch search) {
54 if (!isEnabled())
55 return null;
56 if (isOpaque())
57 return super.findFigureAt(x, y, search);
58
59 IFigure f = super.findFigureAt(x, y, search);
60 if (f is this)
61 return null;
62 return f;
63 }
64
65 }