diff dwtx/jface/fieldassist/FieldDecoration.d @ 17:f459f9147650

ImageAndMessgeDialog
author Frank Benoit <benoit@tionex.de>
date Tue, 01 Apr 2008 08:24:51 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwtx/jface/fieldassist/FieldDecoration.d	Tue Apr 01 08:24:51 2008 +0200
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 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.jface.fieldassist.FieldDecoration;
+
+import dwt.graphics.Image;
+
+import dwt.dwthelper.utils;
+
+/**
+ * FieldDecoration is a simple data structure class for specifying a decoration
+ * for a field. A decoration may be rendered in different ways depending on the
+ * type of field it is used with.
+ *
+ * @see FieldDecorationRegistry
+ *
+ * @since 3.2
+ */
+public class FieldDecoration {
+
+    /*
+     * The image to be shown in the decoration.
+     */
+    private Image image;
+
+    /*
+     * The description to show in the decoration's hover.
+     */
+    private String description;
+
+    /**
+     * Create a decoration for a field with the specified image and description
+     * text.
+     *
+     * @param image
+     *            the image shown in the decoration. A <code>null</code> image
+     *            will result in a blank decoration, which may be used to
+     *            reserve space near the field.
+     * @param description
+     *            the description shown when the user hovers over the
+     *            decoration. A <code>null</code> description indicates that
+     *            there will be no hover for the decoration.
+     */
+    public this(Image image, String description) {
+        this.image = image;
+        this.description = description;
+    }
+
+    /**
+     * Return the image shown in the decoration, or <code>null</code> if no
+     * image is specified.
+     *
+     * @return the image shown in the decoration. A return value of
+     *         <code>null</code> signifies a blank decoration.
+     */
+    public Image getImage() {
+        return image;
+    }
+
+    /**
+     * Set the image shown in the decoration, or <code>null</code> if no image
+     * is specified. It is up to the caller to update any decorated fields that
+     * are showing the description in order to display the new image.
+     *
+     * @param image
+     *            the image shown in the decoration. A value of
+     *            <code>null</code> signifies a blank decoration.
+     */
+    public void setImage(Image image) {
+        this.image = image;
+    }
+
+    /**
+     * Return the description for the decoration shown when the user hovers over
+     * the decoration.
+     *
+     * @return the String description of the decoration. A return value of
+     *         <code>null</code> indicates that no description will be shown.
+     */
+    public String getDescription() {
+        return description;
+    }
+
+    /**
+     * Set the description for the decoration shown when the user hovers over
+     * the decoration. It is up to the caller to update any decorated fields
+     * showing the description.
+     *
+     * @param description
+     *            the String description of the decoration. A value of
+     *            <code>null</code> indicates that no description will be
+     *            shown.
+     */
+    public void setDescription(String description) {
+        this.description = description;
+    }
+}