Mercurial > projects > dwt-linux
comparison dwt/graphics/TextStyle.d @ 240:ce446666f5a2
Update to SWT 3.4M7
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 12 May 2008 19:13:01 +0200 |
parents | 380bad9f6852 |
children | c0d810de7093 |
comparison
equal
deleted
inserted
replaced
239:06a1f6829310 | 240:ce446666f5a2 |
---|---|
1 /******************************************************************************* | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2006 IBM Corporation and others. | 2 * Copyright (c) 2000, 2007 IBM Corporation and others. |
3 * All rights reserved. This program and the accompanying materials | 3 * All rights reserved. This program and the accompanying materials |
4 * are made available under the terms of the Eclipse Public License v1.0 | 4 * are made available under the terms of the Eclipse Public License v1.0 |
5 * which accompanies this distribution, and is available at | 5 * which accompanies this distribution, and is available at |
6 * http://www.eclipse.org/legal/epl-v10.html | 6 * http://www.eclipse.org/legal/epl-v10.html |
7 * | 7 * |
57 * the background of the style | 57 * the background of the style |
58 */ | 58 */ |
59 public Color background; | 59 public Color background; |
60 | 60 |
61 /** | 61 /** |
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 * | |
63 * | 65 * |
64 * @since 3.1 | 66 * @since 3.1 |
65 */ | 67 */ |
66 public bool underline; | 68 public bool underline; |
67 | 69 |
68 /** | 70 /** |
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 /** | |
69 * the strikeout flag of the style | 96 * the strikeout flag of the style |
70 * | 97 * |
71 * @since 3.1 | 98 * @since 3.1 |
72 */ | 99 */ |
73 public bool strikeout; | 100 public bool strikeout; |
74 | 101 |
75 /** | 102 /** |
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 /** | |
76 * the GlyphMetrics of the style | 134 * the GlyphMetrics of the style |
77 * | 135 * |
78 * @since 3.2 | 136 * @since 3.2 |
79 */ | 137 */ |
80 public GlyphMetrics metrics; | 138 public GlyphMetrics metrics; |
84 * | 142 * |
85 * @since 3.2 | 143 * @since 3.2 |
86 */ | 144 */ |
87 public int rise; | 145 public int rise; |
88 | 146 |
89 /++ | 147 /** |
90 + DWT extension for clone implementation | 148 * Create an empty text style. |
91 +/ | 149 * |
92 protected this( TextStyle other ){ | 150 * @since 3.4 |
93 font = other.font; | 151 */ |
94 foreground = other.foreground; | 152 public this () { |
95 background = other.background; | |
96 underline = other.underline; | |
97 strikeout = other.strikeout; | |
98 metrics = other.metrics; | |
99 rise = other.rise; | |
100 } | 153 } |
101 | 154 |
102 /** | 155 /** |
103 * Create a new text style with the specified font, foreground | 156 * Create a new text style with the specified font, foreground |
104 * and background. | 157 * and background. |
112 if (foreground !is null && foreground.isDisposed()) DWT.error (DWT.ERROR_INVALID_ARGUMENT); | 165 if (foreground !is null && foreground.isDisposed()) DWT.error (DWT.ERROR_INVALID_ARGUMENT); |
113 if (background !is null && background.isDisposed()) DWT.error (DWT.ERROR_INVALID_ARGUMENT); | 166 if (background !is null && background.isDisposed()) DWT.error (DWT.ERROR_INVALID_ARGUMENT); |
114 this.font = font; | 167 this.font = font; |
115 this.foreground = foreground; | 168 this.foreground = foreground; |
116 this.background = background; | 169 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 */ | |
180 public 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; | |
117 } | 194 } |
118 | 195 |
119 /** | 196 /** |
120 * Compares the argument to the receiver, and returns true | 197 * Compares the argument to the receiver, and returns true |
121 * if they represent the <em>same</em> object using a class | 198 * if they represent the <em>same</em> object using a class |
140 if (font !is null) { | 217 if (font !is null) { |
141 if (font !is style.font) return false; | 218 if (font !is style.font) return false; |
142 } else if (style.font !is null) return false; | 219 } else if (style.font !is null) return false; |
143 if (metrics !is null || style.metrics !is null) return false; | 220 if (metrics !is null || style.metrics !is null) return false; |
144 if (underline !is style.underline) return false; | 221 if (underline !is style.underline) return false; |
222 if (underlineStyle !is style.underlineStyle) return false; | |
223 if (borderStyle !is style.borderStyle) return false; | |
145 if (strikeout !is style.strikeout) return false; | 224 if (strikeout !is style.strikeout) return false; |
146 if (rise !is style.rise) return false; | 225 if (rise !is style.rise) return false; |
226 if (underlineColor !is null) { | |
227 if (!underlineColor.opEquals(style.underlineColor)) return false; | |
228 } else if (style.underlineColor !is null) return false; | |
229 if (strikeoutColor !is null) { | |
230 if (!strikeoutColor.opEquals(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.opEquals(style.borderColor)) return false; | |
235 } else if (style.borderColor !is null) return false; | |
147 return true; | 236 return true; |
148 } | 237 } |
149 | 238 |
150 /** | 239 /** |
151 * Returns an integer hash code for the receiver. Any two | 240 * Returns an integer hash code for the receiver. Any two |
164 if (font !is null) hash ^= font.toHash(); | 253 if (font !is null) hash ^= font.toHash(); |
165 if (metrics !is null) hash ^= metrics.toHash(); | 254 if (metrics !is null) hash ^= metrics.toHash(); |
166 if (underline) hash ^= hash; | 255 if (underline) hash ^= hash; |
167 if (strikeout) hash ^= hash; | 256 if (strikeout) hash ^= hash; |
168 hash ^= rise; | 257 hash ^= rise; |
258 if (underlineColor !is null) hash ^= underlineColor.toHash(); | |
259 if (strikeoutColor !is null) hash ^= strikeoutColor.toHash(); | |
260 if (borderColor !is null) hash ^= borderColor.toHash(); | |
261 hash ^= underlineStyle; | |
169 return hash; | 262 return hash; |
263 } | |
264 | |
265 bool 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.opEquals(style.borderColor)) return false; | |
271 } else if (style.borderColor !is null) return false; | |
272 return true; | |
273 } | |
274 | |
275 bool 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.opEquals(style.underlineColor)) return false; | |
282 } else if (style.underlineColor !is null) return false; | |
283 return true; | |
284 } | |
285 | |
286 bool 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.opEquals(style.strikeoutColor)) return false; | |
292 } else if (style.strikeoutColor !is null) return false; | |
293 return true; | |
170 } | 294 } |
171 | 295 |
172 /** | 296 /** |
173 * Returns a string containing a concise, human-readable | 297 * Returns a string containing a concise, human-readable |
174 * description of the receiver. | 298 * description of the receiver. |