Mercurial > projects > dwt-mac
comparison dwt/graphics/GlyphMetrics.d @ 32:b9226997409c
Ported dwt.graphics.Image*
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Fri, 12 Sep 2008 13:44:30 +0200 |
parents | a9ab4c738ed8 |
children | 7d135fe0caf2 |
comparison
equal
deleted
inserted
replaced
31:9a3047e87f1d | 32:b9226997409c |
---|---|
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 * |
8 * Contributors: | 8 * Contributors: |
9 * IBM Corporation - initial API and implementation | 9 * IBM Corporation - initial API and implementation |
10 * | |
11 * Port to the D programming language: | |
12 * Jacob Carlborg <jacob.carlborg@gmail.com> | |
10 *******************************************************************************/ | 13 *******************************************************************************/ |
11 module dwt.graphics.GlyphMetrics; | 14 module dwt.graphics.GlyphMetrics; |
12 | 15 |
16 import dwt.DWT; | |
17 | |
18 import tango.text.convert.Format; | |
19 | |
13 import dwt.dwthelper.utils; | 20 import dwt.dwthelper.utils; |
14 | |
15 import dwt.DWT; | |
16 | 21 |
17 /** | 22 /** |
18 * Instances of this class represent glyph metrics. | 23 * Instances of this class represent glyph metrics. |
19 * <p> | 24 * <p> |
20 * The hashCode() method in this class uses the values of the public | 25 * The hashCode() method in this class uses the values of the public |
75 * @param object the object to compare with this object | 80 * @param object the object to compare with this object |
76 * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise | 81 * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise |
77 * | 82 * |
78 * @see #hashCode() | 83 * @see #hashCode() |
79 */ | 84 */ |
80 public bool equals (Object object) { | 85 public bool opEquals (Object object) { |
81 if (object is this) return true; | 86 if (object is this) return true; |
82 if (!( null !is cast(GlyphMetrics)object )) return false; | 87 if (!( null !is cast(GlyphMetrics)object )) return false; |
83 GlyphMetrics metrics = cast(GlyphMetrics)object; | 88 GlyphMetrics metrics = cast(GlyphMetrics)object; |
84 return metrics.ascent is ascent && metrics.descent is descent && metrics.width is width; | 89 return metrics.ascent is ascent && metrics.descent is descent && metrics.width is width; |
85 } | 90 } |
91 | |
92 alias opEquals equals; | |
86 | 93 |
87 /** | 94 /** |
88 * Returns an integer hash code for the receiver. Any two | 95 * Returns an integer hash code for the receiver. Any two |
89 * objects that return <code>true</code> when passed to | 96 * objects that return <code>true</code> when passed to |
90 * <code>equals</code> must return the same value for this | 97 * <code>equals</code> must return the same value for this |
92 * | 99 * |
93 * @return the receiver's hash | 100 * @return the receiver's hash |
94 * | 101 * |
95 * @see #equals(Object) | 102 * @see #equals(Object) |
96 */ | 103 */ |
97 public int hashCode () { | 104 public hash_t toHash () { |
98 return ascent ^ descent ^ width; | 105 return ascent ^ descent ^ width; |
99 } | 106 } |
107 | |
108 alias toHash hashCode; | |
100 | 109 |
101 /** | 110 /** |
102 * Returns a string containing a concise, human-readable | 111 * Returns a string containing a concise, human-readable |
103 * description of the receiver. | 112 * description of the receiver. |
104 * | 113 * |
105 * @return a string representation of the <code>GlyphMetrics</code> | 114 * @return a string representation of the <code>GlyphMetrics</code> |
106 */ | 115 */ |
107 public String toString () { | 116 public String toString () { |
108 return "GlyphMetrics {" + ascent + ", " + descent + ", " + width + "}"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ | 117 return Format("GlyphMetrics {{}{}{}{}{}{}" , ascent , ", " , descent , ", " , width , "}"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
109 } | 118 } |
110 | 119 |
111 } | 120 } |