annotate dwt/custom/StyleRange.d @ 154:535243e6d16a

Fixes to make dwt compile with ldc
author Jacob Carlborg <doob@me.com>
date Sat, 13 Jun 2009 00:25:05 +0200
parents 6337764516f1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
1 /*******************************************************************************
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
2 * Copyright (c) 2000, 2008 IBM Corporation and others.
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
3 * All rights reserved. This program and the accompanying materials
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
4 * are made available under the terms of the Eclipse Public License v1.0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
5 * which accompanies this distribution, and is available at
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
6 * http://www.eclipse.org/legal/epl-v10.html
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
7 *
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
8 * Contributors:
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
9 * IBM Corporation - initial API and implementation
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
10 * Port to the D programming language:
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
11 * Frank Benoit <benoit@tionex.de>
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
12 *******************************************************************************/
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
13 module dwt.custom.StyleRange;
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
14
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
15 import dwt.dwthelper.utils;
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
16
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
17
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
18 import dwt.DWT;
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
19 import dwt.graphics.Color;
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
20 import dwt.graphics.TextStyle;
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
21 import dwt.internal.CloneableCompatibility;
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
22 import dwt.custom.StyleRange;
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
23 import dwt.custom.TextChangedEvent;
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
24 import dwt.custom.TextChangingEvent;
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
25
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
26 static import tango.text.Text;
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
27 alias tango.text.Text.Text!(char) StringBuffer;
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
28
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
29 /**
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
30 * <code>StyleRange</code> defines a set of styles for a specified
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
31 * range of text.
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
32 * <p>
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
33 * The hashCode() method in this class uses the values of the public
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
34 * fields to compute the hash value. When storing instances of the
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
35 * class in hashed collections, do not modify these fields after the
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
36 * object has been inserted.
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
37 * </p>
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
38 *
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
39 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
40 */
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
41 public class StyleRange : TextStyle, CloneableCompatibility {
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
42
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
43 /**
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
44 * the start offset of the range, zero-based from the document start
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
45 */
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
46 public int start;
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
47
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
48 /**
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
49 * the length of the range
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
50 */
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
51 public int length;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
52
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
53 /**
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
54 * the font style of the range. It may be a combination of
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
55 * DWT.NORMAL, DWT.ITALIC or DWT.BOLD
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
56 *
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
57 * Note: the font style is not used if the <code>font</code> attribute
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
58 * is set
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
59 */
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
60 public int fontStyle = DWT.NORMAL;
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
61
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
62 /**
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
63 * Create a new style range with no styles
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
64 *
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
65 * @since 3.2
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
66 */
5
1a8b3cb347e0 Fix Ctors to 'this'
Frank Benoit <benoit@tionex.de>
parents: 0
diff changeset
67 public this() {
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
68 }
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
69 /++
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
70 + DWT extension for clone implementation
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
71 +/
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
72 protected this( StyleRange other ){
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
73 super( other );
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
74 start = other.start;
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
75 length = other.length;
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
76 fontStyle = other.fontStyle;
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
77 }
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
78
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
79 /**
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
80 * Create a new style range from an existing text style.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
81 *
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
82 * @param style the text style to copy
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
83 *
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
84 * @since 3.4
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
85 */
5
1a8b3cb347e0 Fix Ctors to 'this'
Frank Benoit <benoit@tionex.de>
parents: 0
diff changeset
86 public this(TextStyle style) {
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
87 super(style);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
88 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
89
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
90 /**
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
91 * Create a new style range.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
92 *
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
93 * @param start start offset of the style
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
94 * @param length length of the style
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
95 * @param foreground foreground color of the style, null if none
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
96 * @param background background color of the style, null if none
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
97 */
5
1a8b3cb347e0 Fix Ctors to 'this'
Frank Benoit <benoit@tionex.de>
parents: 0
diff changeset
98 public this(int start, int length, Color foreground, Color background) {
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
99 super(null, foreground, background);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
100 this.start = start;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
101 this.length = length;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
102 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
103
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
104 /**
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
105 * Create a new style range.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
106 *
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
107 * @param start start offset of the style
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
108 * @param length length of the style
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
109 * @param foreground foreground color of the style, null if none
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
110 * @param background background color of the style, null if none
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
111 * @param fontStyle font style of the style, may be DWT.NORMAL, DWT.ITALIC or DWT.BOLD
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
112 */
5
1a8b3cb347e0 Fix Ctors to 'this'
Frank Benoit <benoit@tionex.de>
parents: 0
diff changeset
113 public this(int start, int length, Color foreground, Color background, int fontStyle) {
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
114 this(start, length, foreground, background);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
115 this.fontStyle = fontStyle;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
116 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
117
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
118 /**
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
119 * Compares the argument to the receiver, and returns true
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
120 * if they represent the <em>same</em> object using a class
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
121 * specific comparison.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
122 *
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
123 * @param object the object to compare with this object
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
124 * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
125 *
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
126 * @see #hashCode()
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
127 */
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
128 public override int opEquals(Object object) {
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
129 if (object is this) return true;
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
130 if (auto style = cast(StyleRange) object ) {
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
131 if (start !is style.start) return false;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
132 if (length !is style.length) return false;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
133 return similarTo(style);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
134 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
135 return false;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
136 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
137
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
138 /**
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
139 * Returns an integer hash code for the receiver. Any two
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
140 * objects that return <code>true</code> when passed to
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
141 * <code>equals</code> must return the same value for this
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
142 * method.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
143 *
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
144 * @return the receiver's hash
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
145 *
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
146 * @see #equals(Object)
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
147 */
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
148 public override hash_t toHash() {
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
149 return super.toHash() ^ fontStyle;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
150 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
151 bool isVariableHeight() {
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
152 return font !is null || metrics !is null || rise !is 0;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
153 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
154 /**
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
155 * Returns whether or not the receiver is unstyled (i.e., does not have any
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
156 * style attributes specified).
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
157 *
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
158 * @return true if the receiver is unstyled, false otherwise.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
159 */
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
160 public bool isUnstyled() {
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
161 if (font !is null) return false;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
162 if (rise !is 0) return false;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
163 if (metrics !is null) return false;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
164 if (foreground !is null) return false;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
165 if (background !is null) return false;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
166 if (fontStyle !is DWT.NORMAL) return false;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
167 if (underline) return false;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
168 if (strikeout) return false;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
169 if (borderStyle !is DWT.NONE) return false;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
170 return true;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
171 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
172
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
173 /**
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
174 * Compares the specified object to this StyleRange and answer if the two
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
175 * are similar. The object must be an instance of StyleRange and have the
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
176 * same field values for except for start and length.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
177 *
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
178 * @param style the object to compare with this object
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
179 * @return true if the objects are similar, false otherwise
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
180 */
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
181 public bool similarTo(StyleRange style) {
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
182 if (!super.opEquals(style)) return false;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
183 if (fontStyle !is style.fontStyle) return false;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
184 return true;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
185 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
186
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
187 /**
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
188 * Returns a new StyleRange with the same values as this StyleRange.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
189 *
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
190 * @return a shallow copy of this StyleRange
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
191 */
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
192 public /+override+/ Object clone() {
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
193 return new StyleRange( this );
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
194 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
195
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
196 /**
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
197 * Returns a string containing a concise, human-readable
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
198 * description of the receiver.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
199 *
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
200 * @return a string representation of the StyleRange
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
201 */
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
202 public override String toString() {
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
203 StringBuffer buffer = new StringBuffer();
154
535243e6d16a Fixes to make dwt compile with ldc
Jacob Carlborg <doob@me.com>
parents: 41
diff changeset
204 buffer.format("{}", "StyleRange {");
535243e6d16a Fixes to make dwt compile with ldc
Jacob Carlborg <doob@me.com>
parents: 41
diff changeset
205 buffer.format("{}", start);
535243e6d16a Fixes to make dwt compile with ldc
Jacob Carlborg <doob@me.com>
parents: 41
diff changeset
206 buffer.format("{}", ", ");
535243e6d16a Fixes to make dwt compile with ldc
Jacob Carlborg <doob@me.com>
parents: 41
diff changeset
207 buffer.format("{}", length);
535243e6d16a Fixes to make dwt compile with ldc
Jacob Carlborg <doob@me.com>
parents: 41
diff changeset
208 buffer.format("{}", ", fontStyle=");
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
209 switch (fontStyle) {
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
210 case DWT.BOLD:
154
535243e6d16a Fixes to make dwt compile with ldc
Jacob Carlborg <doob@me.com>
parents: 41
diff changeset
211 buffer.format("{}", "bold");
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
212 break;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
213 case DWT.ITALIC:
154
535243e6d16a Fixes to make dwt compile with ldc
Jacob Carlborg <doob@me.com>
parents: 41
diff changeset
214 buffer.format("{}", "italic");
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
215 break;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
216 case DWT.BOLD | DWT.ITALIC:
154
535243e6d16a Fixes to make dwt compile with ldc
Jacob Carlborg <doob@me.com>
parents: 41
diff changeset
217 buffer.format("{}", "bold-italic");
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
218 break;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
219 default:
154
535243e6d16a Fixes to make dwt compile with ldc
Jacob Carlborg <doob@me.com>
parents: 41
diff changeset
220 buffer.format("{}", "normal");
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
221 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
222 String str = super.toString();
41
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
223 int index = tango.text.Util.locate( str, '{');
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
224 if( index is str.length ) index = -1;
6337764516f1 Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents: 8
diff changeset
225 str = str[ index + 1 .. $ ];
154
535243e6d16a Fixes to make dwt compile with ldc
Jacob Carlborg <doob@me.com>
parents: 41
diff changeset
226 if (str.length > 1) buffer.format("{}", ", ");
535243e6d16a Fixes to make dwt compile with ldc
Jacob Carlborg <doob@me.com>
parents: 41
diff changeset
227 buffer.format("{}", str);
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
228 return buffer.toString();
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
229 }
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
230 }