comparison dwtx/draw2d/AbstractBorder.d @ 98:95307ad235d9

Added Draw2d code, still work in progress
author Frank Benoit <benoit@tionex.de>
date Sun, 03 Aug 2008 00:52:14 +0200
parents
children 2d6540440fe6
comparison
equal deleted inserted replaced
96:b492ba44e44d 98:95307ad235d9
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 dwtx.draw2d.AbstractBorder;
14
15 import dwt.dwthelper.utils;
16
17 import dwtx.draw2d.Border;
18 import dwtx.draw2d.IFigure;
19
20 import dwtx.draw2d.geometry.Dimension;
21 import dwtx.draw2d.geometry.Insets;
22 import dwtx.draw2d.geometry.Rectangle;
23
24 /**
25 * Provides generic support for borders.
26 * @author hudsonr
27 */
28 public abstract class AbstractBorder
29 : Border
30 {
31
32 private static const Dimension EMPTY;
33
34 /** A temporary Rectangle*/
35 protected static Rectangle tempRect;
36
37 static this(){
38 EMPTY = new Dimension();
39 tempRect = new Rectangle();
40 }
41
42 /**
43 * Returns a temporary rectangle representing the figure's bounds cropped by the specified
44 * insets. This method exists for convenience and performance; the method does not new
45 * any Objects and returns a rectangle which the caller can manipulate.
46 * @since 2.0
47 * @param figure Figure for which the paintable rectangle is needed
48 * @param insets The insets
49 * @return The paintable region on the Figure f
50 */
51 protected static final Rectangle getPaintRectangle(IFigure figure, Insets insets) {
52 tempRect.setBounds(figure.getBounds());
53 return tempRect.crop(insets);
54 }
55
56 /**
57 * @see dwtx.draw2d.Border#getPreferredSize(IFigure)
58 */
59 public Dimension getPreferredSize(IFigure f) {
60 return EMPTY;
61 }
62
63 /**
64 * @see dwtx.draw2d.Border#isOpaque()
65 */
66 public bool isOpaque() {
67 return false;
68 }
69
70 }