Mercurial > projects > dwt2
diff org.eclipse.ui.forms/src/org/eclipse/ui/forms/HyperlinkSettings.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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.eclipse.ui.forms/src/org/eclipse/ui/forms/HyperlinkSettings.d Sat Mar 14 18:23:29 2009 +0100 @@ -0,0 +1,191 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 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 org.eclipse.ui.forms.HyperlinkSettings; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Cursor; +import org.eclipse.swt.widgets.Display; +import org.eclipse.jface.resource.JFaceColors; +import org.eclipse.ui.internal.forms.widgets.FormsResources; + +import java.lang.all; +import java.util.Set; + +/** + * Manages color and underline mode settings for a group of hyperlinks. The + * class is extended by HyperlinkGroup but is otherwise not intended to be + * subclassed. + * + * @since 3.0 + * @noextend This class is not intended to be subclassed by clients. + */ +public class HyperlinkSettings { + /** + * Underline mode to be used when hyperlinks should not be underlined. + */ + public static const int UNDERLINE_NEVER = 1; + /** + * Underline mode to be used when hyperlinks should only be underlined on + * mouse hover. + */ + public static const int UNDERLINE_HOVER = 2; + /** + * Underline mode to be used when hyperlinks should always be underlined. + */ + public static const int UNDERLINE_ALWAYS = 3; + private int hyperlinkUnderlineMode = UNDERLINE_ALWAYS; + private Color background; + private Color foreground; + private Color activeBackground; + private Color activeForeground; + /** + * The constructor. + * + * @param display + * the display to use when creating colors. + */ + public this(Display display) { + initializeDefaultForegrounds(display); + } + /** + * Initializes the hyperlink foregrounds from the JFace defaults set for the + * entire workbench. + * + * @see JFaceColors + * @param display + * the display to use when creating colors + */ + public void initializeDefaultForegrounds(Display display) { + Color fg = JFaceColors.getHyperlinkText(display); + Color afg = JFaceColors.getActiveHyperlinkText(display); + if (fg is null) + fg = display.getSystemColor(SWT.COLOR_BLUE); + setForeground(fg); + setActiveForeground(afg); + } + /** + * Returns the background to use for the active hyperlink. + * + * @return active hyperlink background + */ + public Color getActiveBackground() { + return activeBackground; + } + /** + * Returns the foreground to use for the active hyperlink. + * + * @return active hyperlink foreground + */ + public Color getActiveForeground() { + return activeForeground; + } + /** + * Returns the background to use for the normal hyperlink. + * + * @return normal hyperlink background + */ + public Color getBackground() { + return background; + } + /** + * Returns the cursor to use when the hyperlink is active. This cursor will + * be shown before hyperlink listeners have been notified of hyperlink + * activation and hidden when the notification method returns. + * + * @return the busy cursor + */ + public Cursor getBusyCursor() { + return FormsResources.getBusyCursor(); + } + /** + * Returns the cursor to use when over text. + * + * @return the text cursor + */ + public Cursor getTextCursor() { + return FormsResources.getTextCursor(); + } + /** + * Returns the foreground to use for the normal hyperlink. + * + * @return the normal hyperlink foreground + */ + public Color getForeground() { + return foreground; + } + /** + * Returns the cursor to use when hovering over the hyperlink. + * + * @return the hyperlink cursor + */ + public Cursor getHyperlinkCursor() { + return FormsResources.getHandCursor(); + } + /** + * Returns the underline mode to be used for all the hyperlinks in this + * group. + * + * @return one of UNDERLINE_NEVER, UNDERLINE_ALWAYS, UNDERLINE_HOVER + */ + public int getHyperlinkUnderlineMode() { + return hyperlinkUnderlineMode; + } + /** + * Sets the new active hyperlink background for all the links. + * + * @param newActiveBackground + * the new active background + */ + public void setActiveBackground(Color newActiveBackground) { + activeBackground = newActiveBackground; + } + /** + * Sets the new active hyperlink foreground for all the links. + * + * @param newActiveForeground + * the new active foreground + */ + public void setActiveForeground(Color newActiveForeground) { + activeForeground = newActiveForeground; + } + /** + * Sets the new hyperlink background for all the links. + * + * @param newBackground + * the new hyperlink background + */ + public void setBackground(Color newBackground) { + background = newBackground; + } + /** + * Sets the new hyperlink foreground for all the links. + * + * @param newForeground + * the new hyperlink foreground + */ + public void setForeground(Color newForeground) { + foreground = newForeground; + } + /** + * Sets the new hyperlink underline mode for all the links in this group. + * + * @param mode + * one of <code>UNDERLINE_NEVER</code>, + * <code>UNDERLINE_HOVER</code> and + * <code>UNDERLINE_ALWAYS</code>. + */ + public void setHyperlinkUnderlineMode(int mode) { + hyperlinkUnderlineMode = mode; + } +}