Mercurial > projects > dwt2
comparison org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/graphics/GlyphMetrics.d @ 0:6dd524f61e62
add dwt win and basic java stuff
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 02 Mar 2009 14:44:16 +0100 |
parents | |
children | 6bf2837c50fe |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:6dd524f61e62 |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2000, 2008 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module org.eclipse.swt.graphics.GlyphMetrics; | |
14 | |
15 import org.eclipse.swt.SWT; | |
16 import tango.text.convert.Format; | |
17 import java.lang.all; | |
18 | |
19 /** | |
20 * Instances of this class represent glyph metrics. | |
21 * <p> | |
22 * The hashCode() method in this class uses the values of the public | |
23 * fields to compute the hash value. When storing instances of the | |
24 * class in hashed collections, do not modify these fields after the | |
25 * object has been inserted. | |
26 * </p> | |
27 * <p> | |
28 * Application code does <em>not</em> need to explicitly release the | |
29 * resources managed by each instance when those instances are no longer | |
30 * required, and thus no <code>dispose()</code> method is provided. | |
31 * </p> | |
32 * | |
33 * @see TextStyle | |
34 * @see TextLayout | |
35 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> | |
36 * | |
37 * @since 3.2 | |
38 */ | |
39 public final class GlyphMetrics { | |
40 | |
41 /** | |
42 * the ascent of the GlyphMetrics | |
43 */ | |
44 public int ascent; | |
45 | |
46 /** | |
47 * the descent of the GlyphMetrics | |
48 */ | |
49 public int descent; | |
50 | |
51 /** | |
52 * the width of the GlyphMetrics | |
53 */ | |
54 public int width; | |
55 | |
56 /** | |
57 * Constructs an instance of this class with the given | |
58 * ascent, descent and width values. | |
59 * | |
60 * @param ascent the GlyphMetrics ascent | |
61 * @param descent the GlyphMetrics descent | |
62 * @param width the GlyphMetrics width | |
63 * | |
64 * @exception IllegalArgumentException <ul> | |
65 * <li>ERROR_INVALID_ARGUMENT - if the ascent, descent or width argument is negative</li> | |
66 * </ul> | |
67 */ | |
68 public this(int ascent, int descent, int width) { | |
69 if (ascent < 0 || descent < 0 || width < 0) { | |
70 SWT.error(SWT.ERROR_INVALID_ARGUMENT); | |
71 } | |
72 this.ascent = ascent; | |
73 this.descent = descent; | |
74 this.width = width; | |
75 } | |
76 | |
77 /** | |
78 * Compares the argument to the receiver, and returns true | |
79 * if they represent the <em>same</em> object using a class | |
80 * specific comparison. | |
81 * | |
82 * @param object the object to compare with this object | |
83 * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise | |
84 * | |
85 * @see #hashCode() | |
86 */ | |
87 public override int opEquals (Object object) { | |
88 if (object is this) return true; | |
89 if (auto metrics = cast(GlyphMetrics)object ){ | |
90 return metrics.ascent == ascent && metrics.descent == descent && metrics.width == width; | |
91 } | |
92 return false; | |
93 } | |
94 | |
95 | |
96 /** | |
97 * Returns an integer hash code for the receiver. Any two | |
98 * objects that return <code>true</code> when passed to | |
99 * <code>equals</code> must return the same value for this | |
100 * method. | |
101 * | |
102 * @return the receiver's hash | |
103 * | |
104 * @see #equals(Object) | |
105 */ | |
106 public override hash_t toHash () { | |
107 return ascent ^ descent ^ width; | |
108 } | |
109 | |
110 /** | |
111 * Returns a string containing a concise, human-readable | |
112 * description of the receiver. | |
113 * | |
114 * @return a string representation of the <code>GlyphMetrics</code> | |
115 */ | |
116 public override String toString () { | |
117 return Format( "GlyphMetrics {{{}, {}, {}}", ascent, descent, width ); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ | |
118 } | |
119 | |
120 } |