001: /*******************************************************************************
002: * Copyright (c) 2003, 2005 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.ui.internal.forms.widgets;
011:
012: import java.util.Hashtable;
013:
014: import org.eclipse.swt.graphics.*;
015:
016: public class ImageHyperlinkSegment extends ImageSegment implements
017: IHyperlinkSegment {
018: private String href;
019: private String text;
020:
021: private String tooltipText;
022:
023: public ImageHyperlinkSegment() {
024: }
025:
026: /*
027: * (non-Javadoc)
028: *
029: * @see org.eclipse.ui.internal.forms.widgets.IHyperlinkSegment#setHref(java.lang.String)
030: */
031: public void setHref(String href) {
032: this .href = href;
033: }
034:
035: /*
036: * (non-Javadoc)
037: *
038: * @see org.eclipse.ui.internal.forms.widgets.IHyperlinkSegment#getHref()
039: */
040: public String getHref() {
041: return href;
042: }
043:
044: public void paintFocus(GC gc, Color bg, Color fg, boolean selected,
045: Rectangle repaintRegion) {
046: Rectangle bounds = getBounds();
047: if (bounds == null)
048: return;
049: if (selected) {
050: gc.setBackground(bg);
051: gc.setForeground(fg);
052: gc.drawFocus(bounds.x, bounds.y, bounds.width,
053: bounds.height);
054: } else {
055: gc.setForeground(bg);
056: gc.drawRectangle(bounds.x, bounds.y, bounds.width - 1,
057: bounds.height - 1);
058: }
059: }
060:
061: /*
062: * (non-Javadoc)
063: *
064: * @see org.eclipse.ui.internal.forms.widgets.IHyperlinkSegment#isWordWrapAllowed()
065: */
066: public boolean isWordWrapAllowed() {
067: return !isNowrap();
068: }
069:
070: /*
071: * (non-Javadoc)
072: *
073: * @see org.eclipse.ui.internal.forms.widgets.IHyperlinkSegment#setWordWrapAllowed(boolean)
074: */
075: public void setWordWrapAllowed(boolean value) {
076: setNowrap(!value);
077: }
078:
079: /*
080: * (non-Javadoc)
081: *
082: * @see org.eclipse.ui.internal.forms.widgets.IHyperlinkSegment#getText()
083: */
084: public String getText() {
085: return text != null ? text : ""; //$NON-NLS-1$
086: }
087:
088: public void setText(String text) {
089: this .text = text;
090: }
091:
092: /**
093: * @return Returns the tooltipText.
094: */
095: public String getTooltipText() {
096: return tooltipText;
097: }
098:
099: /**
100: * @param tooltipText
101: * The tooltipText to set.
102: */
103: public void setTooltipText(String tooltipText) {
104: this .tooltipText = tooltipText;
105: }
106:
107: public boolean isSelectable() {
108: return true;
109: }
110:
111: public boolean isFocusSelectable(Hashtable resourceTable) {
112: return true;
113: }
114:
115: public boolean setFocus(Hashtable resourceTable, boolean direction) {
116: return true;
117: }
118: }
|