diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwtx/draw2d/SimpleEtchedBorder.d	Sun Aug 03 00:52:14 2008 +0200
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
+ *******************************************************************************/
+module dwtx.draw2d.SimpleEtchedBorder;
+
+import dwt.dwthelper.utils;
+
+import dwtx.draw2d.geometry.Insets;
+import dwtx.draw2d.geometry.Rectangle;
+import dwtx.draw2d.SchemeBorder;
+import dwtx.draw2d.Border;
+import dwtx.draw2d.IFigure;
+import dwtx.draw2d.Graphics;
+import dwtx.draw2d.FigureUtilities;
+
+/**
+ * Provides a two pixel wide constant sized border, having an etched look.
+ */
+public final class SimpleEtchedBorder
+    : SchemeBorder
+{
+
+/** The singleton instance of this class */
+public static const Border singleton;
+
+/** The insets */
+protected static const Insets INSETS;
+
+static this(){
+    singleton = new SimpleEtchedBorder();
+    INSETS = new Insets(2);
+}
+/**
+ * Constructs a default border having a two pixel wide border.
+ *
+ * @since 2.0
+ */
+protected this() { }
+
+/**
+ * Returns the Insets used by this border. This is a constant value of two pixels in each
+ * direction.
+ * @see Border#getInsets(IFigure)
+ */
+public Insets getInsets(IFigure figure) {
+    return new Insets(INSETS);
+}
+
+/**
+ * Returns the opaque state of this border. This border is opaque and takes responsibility
+ * to fill the region it encloses.
+ * @see Border#isOpaque()
+ */
+public bool isOpaque() {
+    return true;
+}
+
+/**
+ * @see Border#paint(IFigure, Graphics, Insets)
+ */
+public void paint(IFigure figure, Graphics g, Insets insets) {
+    Rectangle rect = getPaintRectangle(figure, insets);
+    FigureUtilities.paintEtchedBorder(g, rect);
+}
+
+}