01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.swt.custom;
11:
12: import org.eclipse.swt.events.*;
13:
14: /**
15: * This event is sent to BidiSegmentListeners when a line is to
16: * be measured or rendered in a bidi locale. The segments field is
17: * used to specify text ranges in the line that should be treated as
18: * separate segments for bidi reordering. Each segment will be reordered
19: * and rendered separately.
20: * <p>
21: * The elements in the segments field specify the start offset of
22: * a segment relative to the start of the line. They must follow
23: * the following rules:
24: * <ul>
25: * <li>first element must be 0
26: * <li>elements must be in ascending order and must not have duplicates
27: * <li>elements must not exceed the line length
28: * </ul>
29: * In addition, the last element may be set to the end of the line
30: * but this is not required.
31: *
32: * The segments field may be left null if the entire line should
33: * be reordered as is.
34: * </p>
35: * A BidiSegmentListener may be used when adjacent segments of
36: * right-to-left text should not be reordered relative to each other.
37: * For example, within a Java editor, you may wish multiple
38: * right-to-left string literals to be reordered differently than the
39: * bidi algorithm specifies.
40: *
41: * Example:
42: * <pre>
43: * stored line = "R1R2R3" + "R4R5R6"
44: * R1 to R6 are right-to-left characters. The quotation marks
45: * are part of the line text. The line is 13 characters long.
46: *
47: * segments = null:
48: * entire line will be reordered and thus the two R2L segments
49: * swapped (as per the bidi algorithm).
50: * visual line (rendered on screen) = "R6R5R4" + "R3R2R1"
51: *
52: * segments = [0, 5, 8]
53: * "R1R2R3" will be reordered, followed by [blank]+[blank] and
54: * "R4R5R6".
55: * visual line = "R3R2R1" + "R6R5R4"
56: * </pre>
57: */
58: public class BidiSegmentEvent extends TypedEvent {
59:
60: /**
61: * line start offset
62: */
63: public int lineOffset;
64:
65: /**
66: * line text
67: */
68: public String lineText;
69:
70: /**
71: * bidi segments, see above
72: */
73: public int[] segments;
74:
75: static final long serialVersionUID = 3257846571587547957L;
76:
77: BidiSegmentEvent(StyledTextEvent e) {
78: super(e);
79: lineOffset = e.detail;
80: lineText = e.text;
81: }
82: }
|