Mercurial > projects > dwt-mac
comparison dwt/custom/BidiSegmentEvent.d @ 41:6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Tue, 07 Oct 2008 16:29:55 +0200 |
parents | f565d3a95c0a |
children |
comparison
equal
deleted
inserted
replaced
40:fbe68c33eeee | 41:6337764516f1 |
---|---|
1 /******************************************************************************* | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2005 IBM Corporation and others. | 2 * Copyright (c) 2000, 2008 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 * |
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: | 10 * Port to the D programming language: |
12 * Jacob Carlborg <jacob.carlborg@gmail.com> | 11 * Frank Benoit <benoit@tionex.de> |
13 *******************************************************************************/ | 12 *******************************************************************************/ |
14 module dwt.custom.BidiSegmentEvent; | 13 module dwt.custom.BidiSegmentEvent; |
15 | 14 |
15 import dwt.dwthelper.utils; | |
16 | |
17 | |
18 import dwt.events.TypedEvent; | |
16 import dwt.custom.StyledTextEvent; | 19 import dwt.custom.StyledTextEvent; |
17 import dwt.events.TypedEvent; | |
18 | |
19 import dwt.dwthelper.string; | |
20 | 20 |
21 /** | 21 /** |
22 * This event is sent to BidiSegmentListeners when a line is to | 22 * This event is sent to BidiSegmentListeners when a line is to |
23 * be measured or rendered in a bidi locale. The segments field is | 23 * be measured or rendered in a bidi locale. The segments field is |
24 * used to specify text ranges in the line that should be treated as | 24 * used to specify text ranges in the line that should be treated as |
25 * separate segments for bidi reordering. Each segment will be reordered | 25 * separate segments for bidi reordering. Each segment will be reordered |
26 * and rendered separately. | 26 * and rendered separately. |
27 * <p> | 27 * <p> |
28 * The elements in the segments field specify the start offset of | 28 * The elements in the segments field specify the start offset of |
29 * a segment relative to the start of the line. They must follow | 29 * a segment relative to the start of the line. They must follow |
30 * the following rules: | 30 * the following rules: |
31 * <ul> | 31 * <ul> |
32 * <li>first element must be 0 | 32 * <li>first element must be 0 |
33 * <li>elements must be in ascending order and must not have duplicates | 33 * <li>elements must be in ascending order and must not have duplicates |
34 * <li>elements must not exceed the line length | 34 * <li>elements must not exceed the line length |
35 * </ul> | 35 * </ul> |
36 * In addition, the last element may be set to the end of the line | 36 * In addition, the last element may be set to the end of the line |
37 * but this is not required. | 37 * but this is not required. |
38 * | 38 * |
39 * The segments field may be left null if the entire line should | 39 * The segments field may be left null if the entire line should |
40 * be reordered as is. | 40 * be reordered as is. |
41 * </p> | 41 * </p> |
42 * A BidiSegmentListener may be used when adjacent segments of | 42 * A BidiSegmentListener may be used when adjacent segments of |
43 * right-to-left text should not be reordered relative to each other. | 43 * right-to-left text should not be reordered relative to each other. |
44 * For example, within a Java editor, you may wish multiple | 44 * For example, within a Java editor, you may wish multiple |
45 * right-to-left String literals to be reordered differently than the | 45 * right-to-left string literals to be reordered differently than the |
46 * bidi algorithm specifies. | 46 * bidi algorithm specifies. |
47 * | 47 * |
48 * Example: | 48 * Example: |
49 * <pre> | 49 * <pre> |
50 * stored line = "R1R2R3" + "R4R5R6" | 50 * stored line = "R1R2R3" + "R4R5R6" |
51 * R1 to R6 are right-to-left characters. The quotation marks | 51 * R1 to R6 are right-to-left characters. The quotation marks |
52 * are part of the line text. The line is 13 characters long. | 52 * are part of the line text. The line is 13 characters long. |
53 * | 53 * |
54 * segments = null: | 54 * segments = null: |
55 * entire line will be reordered and thus the two R2L segments | 55 * entire line will be reordered and thus the two R2L segments |
56 * swapped (as per the bidi algorithm). | 56 * swapped (as per the bidi algorithm). |
57 * visual line (rendered on screen) = "R6R5R4" + "R3R2R1" | 57 * visual line (rendered on screen) = "R6R5R4" + "R3R2R1" |
58 * | 58 * |
59 * segments = [0, 5, 8] | 59 * segments = [0, 5, 8] |
60 * "R1R2R3" will be reordered, followed by [blank]+[blank] and | 60 * "R1R2R3" will be reordered, followed by [blank]+[blank] and |
61 * "R4R5R6". | 61 * "R4R5R6". |
62 * visual line = "R3R2R1" + "R6R5R4" | 62 * visual line = "R3R2R1" + "R6R5R4" |
63 * </pre> | 63 * </pre> |
64 * | |
65 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> | |
64 */ | 66 */ |
65 public class BidiSegmentEvent : TypedEvent { | 67 public class BidiSegmentEvent : TypedEvent { |
66 | 68 |
67 /** | 69 /** |
68 * line start offset | 70 * line start offset |
69 */ | 71 */ |
70 public int lineOffset; | 72 public int lineOffset; |
71 | 73 |
72 /** | 74 /** |
73 * line text | 75 * line text |
74 */ | 76 */ |
75 public String lineText; | 77 public String lineText; |
76 | 78 |
77 /** | 79 /** |
78 * bidi segments, see above | 80 * bidi segments, see above |
79 */ | 81 */ |
80 public int[] segments; | 82 public int[] segments; |
81 | 83 |
82 static final long serialVersionUID = 3257846571587547957L; | 84 this(StyledTextEvent e) { |
83 | 85 super(cast(Object)e); |
84 this (StyledTextEvent e) { | 86 lineOffset = e.detail; |
85 super(e); | 87 lineText = e.text; |
86 lineOffset = e.detail; | |
87 lineText = e.text; | |
88 } | |
89 } | 88 } |
89 } |