17
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2005, 2007 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.jface.fieldassist.FieldDecoration;
|
|
14
|
|
15 import dwt.graphics.Image;
|
|
16
|
|
17 import dwt.dwthelper.utils;
|
|
18
|
|
19 /**
|
|
20 * FieldDecoration is a simple data structure class for specifying a decoration
|
|
21 * for a field. A decoration may be rendered in different ways depending on the
|
|
22 * type of field it is used with.
|
|
23 *
|
|
24 * @see FieldDecorationRegistry
|
|
25 *
|
|
26 * @since 3.2
|
|
27 */
|
|
28 public class FieldDecoration {
|
|
29
|
|
30 /*
|
|
31 * The image to be shown in the decoration.
|
|
32 */
|
|
33 private Image image;
|
|
34
|
|
35 /*
|
|
36 * The description to show in the decoration's hover.
|
|
37 */
|
|
38 private String description;
|
|
39
|
|
40 /**
|
|
41 * Create a decoration for a field with the specified image and description
|
|
42 * text.
|
|
43 *
|
|
44 * @param image
|
|
45 * the image shown in the decoration. A <code>null</code> image
|
|
46 * will result in a blank decoration, which may be used to
|
|
47 * reserve space near the field.
|
|
48 * @param description
|
|
49 * the description shown when the user hovers over the
|
|
50 * decoration. A <code>null</code> description indicates that
|
|
51 * there will be no hover for the decoration.
|
|
52 */
|
|
53 public this(Image image, String description) {
|
|
54 this.image = image;
|
|
55 this.description = description;
|
|
56 }
|
|
57
|
|
58 /**
|
|
59 * Return the image shown in the decoration, or <code>null</code> if no
|
|
60 * image is specified.
|
|
61 *
|
|
62 * @return the image shown in the decoration. A return value of
|
|
63 * <code>null</code> signifies a blank decoration.
|
|
64 */
|
|
65 public Image getImage() {
|
|
66 return image;
|
|
67 }
|
|
68
|
|
69 /**
|
|
70 * Set the image shown in the decoration, or <code>null</code> if no image
|
|
71 * is specified. It is up to the caller to update any decorated fields that
|
|
72 * are showing the description in order to display the new image.
|
|
73 *
|
|
74 * @param image
|
|
75 * the image shown in the decoration. A value of
|
|
76 * <code>null</code> signifies a blank decoration.
|
|
77 */
|
|
78 public void setImage(Image image) {
|
|
79 this.image = image;
|
|
80 }
|
|
81
|
|
82 /**
|
|
83 * Return the description for the decoration shown when the user hovers over
|
|
84 * the decoration.
|
|
85 *
|
|
86 * @return the String description of the decoration. A return value of
|
|
87 * <code>null</code> indicates that no description will be shown.
|
|
88 */
|
|
89 public String getDescription() {
|
|
90 return description;
|
|
91 }
|
|
92
|
|
93 /**
|
|
94 * Set the description for the decoration shown when the user hovers over
|
|
95 * the decoration. It is up to the caller to update any decorated fields
|
|
96 * showing the description.
|
|
97 *
|
|
98 * @param description
|
|
99 * the String description of the decoration. A value of
|
|
100 * <code>null</code> indicates that no description will be
|
|
101 * shown.
|
|
102 */
|
|
103 public void setDescription(String description) {
|
|
104 this.description = description;
|
|
105 }
|
|
106 }
|