comparison org.eclipse.ui.forms/src/org/eclipse/ui/internal/forms/widgets/ImageHyperlinkSegment.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 dbfb303e8fb0
comparison
equal deleted inserted replaced
11:43904fec5dca 12:bc29606a740c
1 /*******************************************************************************
2 * Copyright (c) 2003, 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.ui.internal.forms.widgets.ImageHyperlinkSegment;
14
15 import org.eclipse.ui.internal.forms.widgets.IHyperlinkSegment;
16 import org.eclipse.ui.internal.forms.widgets.ImageSegment;
17
18 //import java.util.Hashtable;
19
20 import org.eclipse.swt.graphics.Color;
21 import org.eclipse.swt.graphics.GC;
22 import org.eclipse.swt.graphics.Rectangle;
23
24 import java.lang.all;
25 import java.util.Set;
26
27 public class ImageHyperlinkSegment : ImageSegment,
28 IHyperlinkSegment {
29 private String href;
30 private String text;
31
32 private String tooltipText;
33
34 // reimpl for interface
35 bool contains(int x, int y){
36 return super.contains(x,y);
37 }
38 bool intersects(Rectangle rect){
39 return super.intersects(rect);
40 }
41
42 public this() {
43 }
44
45 /*
46 * (non-Javadoc)
47 *
48 * @see org.eclipse.ui.internal.forms.widgets.IHyperlinkSegment#setHref(java.lang.String)
49 */
50 public void setHref(String href) {
51 this.href = href;
52 }
53
54 /*
55 * (non-Javadoc)
56 *
57 * @see org.eclipse.ui.internal.forms.widgets.IHyperlinkSegment#getHref()
58 */
59 public String getHref() {
60 return href;
61 }
62
63 public void paintFocus(GC gc, Color bg, Color fg, bool selected,
64 Rectangle repaintRegion) {
65 Rectangle bounds = getBounds();
66 if (bounds is null)
67 return;
68 if (selected) {
69 gc.setBackground(bg);
70 gc.setForeground(fg);
71 gc.drawFocus(bounds.x, bounds.y, bounds.width, bounds.height);
72 } else {
73 gc.setForeground(bg);
74 gc.drawRectangle(bounds.x, bounds.y, bounds.width - 1,
75 bounds.height - 1);
76 }
77 }
78
79 /*
80 * (non-Javadoc)
81 *
82 * @see org.eclipse.ui.internal.forms.widgets.IHyperlinkSegment#isWordWrapAllowed()
83 */
84 public bool isWordWrapAllowed() {
85 return !isNowrap();
86 }
87
88 /*
89 * (non-Javadoc)
90 *
91 * @see org.eclipse.ui.internal.forms.widgets.IHyperlinkSegment#setWordWrapAllowed(bool)
92 */
93 public void setWordWrapAllowed(bool value) {
94 setNowrap(!value);
95 }
96
97 /*
98 * (non-Javadoc)
99 *
100 * @see org.eclipse.ui.internal.forms.widgets.IHyperlinkSegment#getText()
101 */
102 public String getText() {
103 return text !is null?text:""; //$NON-NLS-1$
104 }
105
106 public void setText(String text) {
107 this.text = text;
108 }
109
110 /**
111 * @return Returns the tooltipText.
112 */
113 public String getTooltipText() {
114 return tooltipText;
115 }
116
117 /**
118 * @param tooltipText
119 * The tooltipText to set.
120 */
121 public void setTooltipText(String tooltipText) {
122 this.tooltipText = tooltipText;
123 }
124
125 public bool isSelectable() {
126 return true;
127 }
128
129 public bool isFocusSelectable(Hashtable resourceTable) {
130 return true;
131 }
132
133 public bool setFocus(Hashtable resourceTable, bool direction) {
134 return true;
135 }
136 }