comparison dwtx/draw2d/SimpleEtchedBorder.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.SimpleEtchedBorder;
14
15 import dwt.dwthelper.utils;
16
17 import dwtx.draw2d.geometry.Insets;
18 import dwtx.draw2d.geometry.Rectangle;
19 import dwtx.draw2d.SchemeBorder;
20 import dwtx.draw2d.Border;
21 import dwtx.draw2d.IFigure;
22 import dwtx.draw2d.Graphics;
23 import dwtx.draw2d.FigureUtilities;
24
25 /**
26 * Provides a two pixel wide constant sized border, having an etched look.
27 */
28 public final class SimpleEtchedBorder
29 : SchemeBorder
30 {
31
32 /** The singleton instance of this class */
33 public static const Border singleton;
34
35 /** The insets */
36 protected static const Insets INSETS;
37
38 static this(){
39 singleton = new SimpleEtchedBorder();
40 INSETS = new Insets(2);
41 }
42 /**
43 * Constructs a default border having a two pixel wide border.
44 *
45 * @since 2.0
46 */
47 protected this() { }
48
49 /**
50 * Returns the Insets used by this border. This is a constant value of two pixels in each
51 * direction.
52 * @see Border#getInsets(IFigure)
53 */
54 public Insets getInsets(IFigure figure) {
55 return new Insets(INSETS);
56 }
57
58 /**
59 * Returns the opaque state of this border. This border is opaque and takes responsibility
60 * to fill the region it encloses.
61 * @see Border#isOpaque()
62 */
63 public bool isOpaque() {
64 return true;
65 }
66
67 /**
68 * @see Border#paint(IFigure, Graphics, Insets)
69 */
70 public void paint(IFigure figure, Graphics g, Insets insets) {
71 Rectangle rect = getPaintRectangle(figure, insets);
72 FigureUtilities.paintEtchedBorder(g, rect);
73 }
74
75 }