Show
Ignore:
Timestamp:
05/17/08 11:34:28 (8 months ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

Update to SWT 3.4M7

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/graphics/TextStyle.d

    r212 r213  
    11/******************************************************************************* 
    2  * Copyright (c) 2000, 2006 IBM Corporation and others. 
     2 * Copyright (c) 2000, 2007 IBM Corporation and others. 
    33 * All rights reserved. This program and the accompanying materials 
    44 * are made available under the terms of the Eclipse Public License v1.0 
     
    6060 
    6161    /** 
    62      * the underline flag of the style 
     62     * the underline flag of the style. The default underline 
     63     * style is <code>DWT.UNDERLINE_SINGLE</code>. 
     64     * 
    6365     * 
    6466     * @since 3.1 
     
    6769 
    6870    /** 
     71     * the underline color of the style 
     72     * 
     73     * @since 3.4 
     74     */ 
     75    public Color underlineColor; 
     76 
     77    /** 
     78     * the underline style. This style is ignored when 
     79     * <code>underline</code> is false. 
     80     * <p> 
     81     * This value should be one of <code>DWT.UNDERLINE_SINGLE</code>, 
     82     * <code>DWT.UNDERLINE_DOUBLE</code>, <code>DWT.UNDERLINE_ERROR</code>, 
     83     * or <code>DWT.UNDERLINE_SQUIGGLE</code>. 
     84     * </p> 
     85     * 
     86     * @see DWT#UNDERLINE_SINGLE 
     87     * @see DWT#UNDERLINE_DOUBLE 
     88     * @see DWT#UNDERLINE_ERROR 
     89     * @see DWT#UNDERLINE_SQUIGGLE 
     90     * 
     91     * @since 3.4 
     92     */ 
     93    public int underlineStyle; 
     94 
     95    /** 
    6996     * the strikeout flag of the style 
    7097     * 
     
    74101 
    75102    /** 
     103     * the strikeout color of the style 
     104     * 
     105     * @since 3.4 
     106     */ 
     107    public Color strikeoutColor; 
     108 
     109    /** 
     110     * the border style. The default border style is <code>DWT.NONE</code>. 
     111     * <p> 
     112     * This value should be one of <code>DWT.BORDER_SOLID</code>, 
     113     * <code>DWT.BORDER_DASH</code>,<code>DWT.BORDER_DOT</code> or 
     114     * <code>DWT.NONE</code>. 
     115     * </p> 
     116     * 
     117     * @see DWT#BORDER_SOLID 
     118     * @see DWT#BORDER_DASH 
     119     * @see DWT#BORDER_DOT 
     120     * @see DWT#NONE 
     121     * 
     122     * @since 3.4 
     123     */ 
     124    public int borderStyle; 
     125 
     126    /** 
     127     * the border color of the style 
     128     * 
     129     * @since 3.4 
     130     */ 
     131    public Color borderColor; 
     132 
     133    /** 
    76134     * the GlyphMetrics of the style 
    77135     * 
     
    87145    public int rise; 
    88146 
    89 /++ 
    90  + DWT extension for clone implementation 
    91  +/ 
    92 protected this( TextStyle other ){ 
    93     font = other.font; 
    94     foreground = other.foreground; 
    95     background = other.background; 
    96     underline = other.underline; 
    97     strikeout = other.strikeout; 
    98     metrics = other.metrics; 
    99     rise = other.rise; 
     147/** 
     148 * Create an empty text style. 
     149 * 
     150 * @since 3.4 
     151 */ 
     152public this () { 
    100153} 
    101154 
     
    115168    this.foreground = foreground; 
    116169    this.background = background; 
     170} 
     171 
     172 
     173/** 
     174 * Create a new text style from an existing text style. 
     175 * 
     176 *@param style the style to copy 
     177 * 
     178 * @since 3.4 
     179 */ 
     180public this (TextStyle style) { 
     181    if (style is null) DWT.error (DWT.ERROR_INVALID_ARGUMENT); 
     182    font = style.font; 
     183    foreground = style.foreground; 
     184    background = style.background; 
     185    underline = style.underline; 
     186    underlineColor = style.underlineColor; 
     187    underlineStyle = style.underlineStyle; 
     188    strikeout = style.strikeout; 
     189    strikeoutColor = style.strikeoutColor; 
     190    borderStyle = style.borderStyle; 
     191    borderColor = style.borderColor; 
     192    metrics = style.metrics; 
     193    rise = style.rise; 
    117194} 
    118195 
     
    143220    if (metrics !is null || style.metrics !is null) return false; 
    144221    if (underline !is style.underline) return false; 
     222    if (underlineStyle !is style.underlineStyle) return false; 
     223    if (borderStyle !is style.borderStyle) return false; 
    145224    if (strikeout !is style.strikeout) return false; 
    146225    if (rise !is style.rise) return false; 
     226    if (underlineColor !is null) { 
     227        if (!underlineColor.equals(style.underlineColor)) return false; 
     228    } else if (style.underlineColor !is null) return false; 
     229    if (strikeoutColor !is null) { 
     230        if (!strikeoutColor.equals(style.strikeoutColor)) return false; 
     231    } else if (style.strikeoutColor !is null) return false; 
     232    if (underlineStyle !is style.underlineStyle) return false; 
     233    if (borderColor !is null) { 
     234        if (!borderColor.equals(style.borderColor)) return false; 
     235    } else if (style.borderColor !is null) return false; 
    147236    return true; 
    148237} 
     
    167256    if (strikeout) hash ^= hash; 
    168257    hash ^= rise; 
     258    if (underlineColor !is null) hash ^= underlineColor.hashCode(); 
     259    if (strikeoutColor !is null) hash ^= strikeoutColor.hashCode(); 
     260    if (borderColor !is null) hash ^= borderColor.hashCode(); 
     261    hash ^= underlineStyle; 
    169262    return hash; 
     263} 
     264 
     265bool isAdherentBorder(TextStyle style) { 
     266    if (this is style) return true; 
     267    if (style is null) return false; 
     268    if (borderStyle !is style.borderStyle) return false; 
     269    if (borderColor !is null) { 
     270        if (!borderColor.equals(style.borderColor)) return false; 
     271    } else if (style.borderColor !is null) return false; 
     272    return true; 
     273} 
     274 
     275bool isAdherentUnderline(TextStyle style) { 
     276    if (this is style) return true; 
     277    if (style is null) return false; 
     278    if (underline !is style.underline) return false; 
     279    if (underlineStyle !is style.underlineStyle) return false; 
     280    if (underlineColor !is null) { 
     281        if (!underlineColor.equals(style.underlineColor)) return false; 
     282    } else if (style.underlineColor !is null) return false; 
     283    return true; 
     284} 
     285 
     286bool isAdherentStrikeout(TextStyle style) { 
     287    if (this is style) return true; 
     288    if (style is null) return false; 
     289    if (strikeout !is style.strikeout) return false; 
     290    if (strikeoutColor !is null) { 
     291        if (!strikeoutColor.equals(style.strikeoutColor)) return false; 
     292    } else if (style.strikeoutColor !is null) return false; 
     293    return true; 
    170294} 
    171295