diff dwt/graphics/TextStyle.d @ 213:36f5cb12e1a2

Update to SWT 3.4M7
author Frank Benoit <benoit@tionex.de>
date Sat, 17 May 2008 17:34:28 +0200
parents ab60f3309436
children fd9c62a2998e
line wrap: on
line diff
--- a/dwt/graphics/TextStyle.d	Mon May 05 00:12:38 2008 +0200
+++ b/dwt/graphics/TextStyle.d	Sat May 17 17:34:28 2008 +0200
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2007 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
@@ -59,13 +59,40 @@
     public Color background;
 
     /**
-     * the underline flag of the style
+     * the underline flag of the style. The default underline
+     * style is <code>DWT.UNDERLINE_SINGLE</code>.
+     *
      *
      * @since 3.1
      */
     public bool underline;
 
     /**
+     * the underline color of the style
+     *
+     * @since 3.4
+     */
+    public Color underlineColor;
+
+    /**
+     * the underline style. This style is ignored when
+     * <code>underline</code> is false.
+     * <p>
+     * This value should be one of <code>DWT.UNDERLINE_SINGLE</code>,
+     * <code>DWT.UNDERLINE_DOUBLE</code>, <code>DWT.UNDERLINE_ERROR</code>,
+     * or <code>DWT.UNDERLINE_SQUIGGLE</code>.
+     * </p>
+     *
+     * @see DWT#UNDERLINE_SINGLE
+     * @see DWT#UNDERLINE_DOUBLE
+     * @see DWT#UNDERLINE_ERROR
+     * @see DWT#UNDERLINE_SQUIGGLE
+     *
+     * @since 3.4
+     */
+    public int underlineStyle;
+
+    /**
      * the strikeout flag of the style
      *
      * @since 3.1
@@ -73,6 +100,37 @@
     public bool strikeout;
 
     /**
+     * the strikeout color of the style
+     *
+     * @since 3.4
+     */
+    public Color strikeoutColor;
+
+    /**
+     * the border style. The default border style is <code>DWT.NONE</code>.
+     * <p>
+     * This value should be one of <code>DWT.BORDER_SOLID</code>,
+     * <code>DWT.BORDER_DASH</code>,<code>DWT.BORDER_DOT</code> or
+     * <code>DWT.NONE</code>.
+     * </p>
+     *
+     * @see DWT#BORDER_SOLID
+     * @see DWT#BORDER_DASH
+     * @see DWT#BORDER_DOT
+     * @see DWT#NONE
+     *
+     * @since 3.4
+     */
+    public int borderStyle;
+
+    /**
+     * the border color of the style
+     *
+     * @since 3.4
+     */
+    public Color borderColor;
+
+    /**
      * the GlyphMetrics of the style
      *
      * @since 3.2
@@ -86,17 +144,12 @@
      */
     public int rise;
 
-/++
- + DWT extension for clone implementation
- +/
-protected this( TextStyle other ){
-    font = other.font;
-    foreground = other.foreground;
-    background = other.background;
-    underline = other.underline;
-    strikeout = other.strikeout;
-    metrics = other.metrics;
-    rise = other.rise;
+/**
+ * Create an empty text style.
+ *
+ * @since 3.4
+ */
+public this () {
 }
 
 /**
@@ -116,6 +169,30 @@
     this.background = background;
 }
 
+
+/**
+ * Create a new text style from an existing text style.
+ *
+ *@param style the style to copy
+ *
+ * @since 3.4
+ */
+public this (TextStyle style) {
+    if (style is null) DWT.error (DWT.ERROR_INVALID_ARGUMENT);
+    font = style.font;
+    foreground = style.foreground;
+    background = style.background;
+    underline = style.underline;
+    underlineColor = style.underlineColor;
+    underlineStyle = style.underlineStyle;
+    strikeout = style.strikeout;
+    strikeoutColor = style.strikeoutColor;
+    borderStyle = style.borderStyle;
+    borderColor = style.borderColor;
+    metrics = style.metrics;
+    rise = style.rise;
+}
+
 /**
  * Compares the argument to the receiver, and returns true
  * if they represent the <em>same</em> object using a class
@@ -142,8 +219,20 @@
     } else if (style.font !is null) return false;
     if (metrics !is null || style.metrics !is null) return false;
     if (underline !is style.underline) return false;
+    if (underlineStyle !is style.underlineStyle) return false;
+    if (borderStyle !is style.borderStyle) return false;
     if (strikeout !is style.strikeout) return false;
     if (rise !is style.rise) return false;
+    if (underlineColor !is null) {
+        if (!underlineColor.equals(style.underlineColor)) return false;
+    } else if (style.underlineColor !is null) return false;
+    if (strikeoutColor !is null) {
+        if (!strikeoutColor.equals(style.strikeoutColor)) return false;
+    } else if (style.strikeoutColor !is null) return false;
+    if (underlineStyle !is style.underlineStyle) return false;
+    if (borderColor !is null) {
+        if (!borderColor.equals(style.borderColor)) return false;
+    } else if (style.borderColor !is null) return false;
     return true;
 }
 
@@ -166,9 +255,44 @@
     if (underline) hash ^= hash;
     if (strikeout) hash ^= hash;
     hash ^= rise;
+    if (underlineColor !is null) hash ^= underlineColor.hashCode();
+    if (strikeoutColor !is null) hash ^= strikeoutColor.hashCode();
+    if (borderColor !is null) hash ^= borderColor.hashCode();
+    hash ^= underlineStyle;
     return hash;
 }
 
+bool isAdherentBorder(TextStyle style) {
+    if (this is style) return true;
+    if (style is null) return false;
+    if (borderStyle !is style.borderStyle) return false;
+    if (borderColor !is null) {
+        if (!borderColor.equals(style.borderColor)) return false;
+    } else if (style.borderColor !is null) return false;
+    return true;
+}
+
+bool isAdherentUnderline(TextStyle style) {
+    if (this is style) return true;
+    if (style is null) return false;
+    if (underline !is style.underline) return false;
+    if (underlineStyle !is style.underlineStyle) return false;
+    if (underlineColor !is null) {
+        if (!underlineColor.equals(style.underlineColor)) return false;
+    } else if (style.underlineColor !is null) return false;
+    return true;
+}
+
+bool isAdherentStrikeout(TextStyle style) {
+    if (this is style) return true;
+    if (style is null) return false;
+    if (strikeout !is style.strikeout) return false;
+    if (strikeoutColor !is null) {
+        if (!strikeoutColor.equals(style.strikeoutColor)) return false;
+    } else if (style.strikeoutColor !is null) return false;
+    return true;
+}
+
 /**
  * Returns a string containing a concise, human-readable
  * description of the receiver.