comparison org.eclipse.draw2d/src/org/eclipse/draw2d/SimpleEtchedBorder.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.SimpleEtchedBorder;
14
15 import java.lang.all;
16
17 import org.eclipse.draw2d.geometry.Insets;
18 import org.eclipse.draw2d.geometry.Rectangle;
19 import org.eclipse.draw2d.SchemeBorder;
20 import org.eclipse.draw2d.Border;
21 import org.eclipse.draw2d.IFigure;
22 import org.eclipse.draw2d.Graphics;
23 import org.eclipse.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 private static Border singleton_;
34
35 /** The insets */
36 private static Insets INSETS_;
37
38 public static Border singleton(){
39 if( !initStaticCtor_done ) initStaticCtor();
40 assert(singleton_);
41 return singleton_;
42 }
43 protected static Insets INSETS(){
44 if( !initStaticCtor_done ) initStaticCtor();
45 assert(INSETS_);
46 return INSETS_;
47 }
48
49 private static bool initStaticCtor_done = false;
50 private static void initStaticCtor(){
51 synchronized( SimpleEtchedBorder.classinfo ){
52 if( !initStaticCtor_done ){
53 singleton_ = new SimpleEtchedBorder();
54 INSETS_ = new Insets(2);
55 initStaticCtor_done = true;
56 }
57 }
58 }
59
60
61
62
63 /**
64 * Constructs a default border having a two pixel wide border.
65 *
66 * @since 2.0
67 */
68 protected this() { }
69
70 /**
71 * Returns the Insets used by this border. This is a constant value of two pixels in each
72 * direction.
73 * @see Border#getInsets(IFigure)
74 */
75 public Insets getInsets(IFigure figure) {
76 return new Insets(INSETS);
77 }
78
79 /**
80 * Returns the opaque state of this border. This border is opaque and takes responsibility
81 * to fill the region it encloses.
82 * @see Border#isOpaque()
83 */
84 public bool isOpaque() {
85 return true;
86 }
87
88 /**
89 * @see Border#paint(IFigure, Graphics, Insets)
90 */
91 public void paint(IFigure figure, Graphics g, Insets insets) {
92 Rectangle rect = getPaintRectangle(figure, insets);
93 FigureUtilities.paintEtchedBorder(g, rect);
94 }
95
96 }