Mercurial > projects > dwt-addons
annotate dwtx/ui/internal/forms/widgets/TextHyperlinkSegment.d @ 90:7ffeace6c47f
Update 3.4M7 to 3.4
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 06 Jul 2008 23:30:07 +0200 |
parents | 26c6c9dfd13c |
children | 04b47443bb01 |
rev | line source |
---|---|
75 | 1 /******************************************************************************* |
90 | 2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
75 | 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.ui.internal.forms.widgets.TextHyperlinkSegment; | |
14 | |
76 | 15 import dwtx.ui.internal.forms.widgets.TextSegment; |
16 import dwtx.ui.internal.forms.widgets.IHyperlinkSegment; | |
17 import dwtx.ui.internal.forms.widgets.SelectionData; | |
75 | 18 |
19 import dwt.graphics.Color; | |
20 import dwt.graphics.GC; | |
21 import dwt.graphics.Rectangle; | |
22 import dwtx.ui.forms.HyperlinkSettings; | |
23 | |
76 | 24 import dwt.dwthelper.utils; |
25 //import tango.util.collection.HashMap; | |
26 | |
75 | 27 /** |
28 * @version 1.0 | |
29 * @author | |
30 */ | |
76 | 31 public class TextHyperlinkSegment : TextSegment, |
75 | 32 IHyperlinkSegment { |
33 private String href; | |
34 | |
35 private String tooltipText; | |
36 | |
37 //private static final String LINK_FG = "c.___link_fg"; | |
38 | |
39 private HyperlinkSettings settings; | |
40 | |
77
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
76
diff
changeset
|
41 // reimpl for interface |
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
76
diff
changeset
|
42 String getText(){ |
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
76
diff
changeset
|
43 return super.getText(); |
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
76
diff
changeset
|
44 } |
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
76
diff
changeset
|
45 void paintFocus(GC gc, Color bg, Color fg, bool selected, Rectangle repaintRegion){ |
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
76
diff
changeset
|
46 super.paintFocus(gc,bg,fg,selected,repaintRegion); |
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
76
diff
changeset
|
47 } |
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
76
diff
changeset
|
48 bool contains(int x, int y){ |
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
76
diff
changeset
|
49 return super.contains(x,y); |
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
76
diff
changeset
|
50 } |
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
76
diff
changeset
|
51 bool intersects(Rectangle rect){ |
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
76
diff
changeset
|
52 return super.intersects(rect); |
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
76
diff
changeset
|
53 } |
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
76
diff
changeset
|
54 |
76 | 55 public this(String text, HyperlinkSettings settings, |
75 | 56 String fontId) { |
57 super(text, fontId); | |
58 this.settings = settings; | |
59 underline = settings.getHyperlinkUnderlineMode() is HyperlinkSettings.UNDERLINE_ALWAYS; | |
60 } | |
61 | |
62 /* | |
63 * @see IObjectReference#getObjectId() | |
64 */ | |
65 public String getHref() { | |
66 return href; | |
67 } | |
68 | |
69 public void setHref(String href) { | |
70 this.href = href; | |
71 } | |
72 | |
73 /* | |
74 * public void paint(GC gc, int width, Locator locator, Hashtable | |
75 * resourceTable, bool selected, SelectionData selData) { | |
76 * resourceTable.put(LINK_FG, settings.getForeground()); | |
77 * setColorId(LINK_FG); super.paint(gc, width, locator, resourceTable, | |
78 * selected, selData); } | |
79 */ | |
80 | |
81 public void paint(GC gc, bool hover, Hashtable resourceTable, | |
82 bool selected, SelectionData selData, Rectangle repaintRegion) { | |
83 bool rolloverMode = settings.getHyperlinkUnderlineMode() is HyperlinkSettings.UNDERLINE_HOVER; | |
84 Color savedFg = gc.getForeground(); | |
85 Color newFg = hover ? settings.getActiveForeground() : settings | |
86 .getForeground(); | |
76 | 87 if (newFg !is null) |
88 gc.setForeground(newFg); | |
75 | 89 super.paint(gc, hover, resourceTable, selected, rolloverMode, selData, |
90 repaintRegion); | |
91 gc.setForeground(savedFg); | |
92 } | |
90 | 93 |
94 protected void drawString(GC gc, String s, int clipX, int clipY) { | |
95 gc.drawString(s, clipX, clipY, false); | |
96 } | |
75 | 97 |
98 public String getTooltipText() { | |
99 return tooltipText; | |
100 } | |
101 | |
102 public void setTooltipText(String tooltip) { | |
103 this.tooltipText = tooltip; | |
104 } | |
76 | 105 |
75 | 106 public bool isSelectable() { |
107 return true; | |
108 } | |
109 | |
110 public bool isFocusSelectable(Hashtable resourceTable) { | |
111 return true; | |
112 } | |
113 | |
114 public bool setFocus(Hashtable resourceTable, bool direction) { | |
115 return true; | |
116 } | |
117 } |