1
|
/*******************************************************************************
|
2
|
* Copyright (c) 2000, 2010 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
|
*******************************************************************************/
|
11
|
package org.eclipse.draw2d.text;
|
12
|
|
13
|
/**
|
14
|
* The context that a {@link FlowFigureLayout} uses to perform its layout.
|
15
|
*
|
16
|
* <P>
|
17
|
* WARNING: This interface is not intended to be implemented by clients. It
|
18
|
* exists to define the API between the layout and its context.
|
19
|
*/
|
20
|
public interface FlowContext {
|
21
|
|
22
|
/**
|
23
|
* Adds the given box into the current line.
|
24
|
*
|
25
|
* @param box
|
26
|
* the FlowBox to add
|
27
|
*/
|
28
|
void addToCurrentLine(FlowBox box);
|
29
|
|
30
|
/**
|
31
|
* Adds an entire line into the context. If there is a previous line, it is
|
32
|
* ended.
|
33
|
*
|
34
|
* @param box
|
35
|
* the line being added
|
36
|
* @since 3.1
|
37
|
*/
|
38
|
void addLine(CompositeBox box);
|
39
|
|
40
|
/**
|
41
|
* The current line should be committed if it is occupied, and then set to
|
42
|
* <code>null</code>. Otherwise, do nothing.
|
43
|
*/
|
44
|
void endLine();
|
45
|
|
46
|
/**
|
47
|
* This method can be used to query the amount of space left on the current
|
48
|
* line. It can help determine where to wrap during layout.
|
49
|
*
|
50
|
* @return the amount of space left on the current line
|
51
|
* @since 3.1
|
52
|
*/
|
53
|
int getRemainingLineWidth();
|
54
|
|
55
|
/**
|
56
|
* This method is used to convey layout state to different FlowFigures. This
|
57
|
* state is cleared when a fragment is added to the current line and once
|
58
|
* the layout is complete.
|
59
|
*
|
60
|
* @return <code>true</code> if the next fragment should be placed on the
|
61
|
* current line
|
62
|
* @since 3.1
|
63
|
* @see #setContinueOnSameLine(boolean)
|
64
|
*/
|
65
|
boolean getContinueOnSameLine();
|
66
|
|
67
|
/**
|
68
|
* This method looks ahead for line-breaks. When laying out, this method can
|
69
|
* be used to determine the next line-break across multiple figures.
|
70
|
*
|
71
|
* @param child
|
72
|
* the search will occur starting from the figure after the given
|
73
|
* child
|
74
|
* @param width
|
75
|
* the width before the next line-break (if one's found; all the
|
76
|
* width, otherwise) will be added on to the first int in the
|
77
|
* given array
|
78
|
* @since 3.1
|
79
|
*/
|
80
|
void getWidthLookahead(FlowFigure child, int width[]);
|
81
|
|
82
|
/**
|
83
|
* @return <code>true</code> if the current line contains any fragments
|
84
|
*/
|
85
|
boolean isCurrentLineOccupied();
|
86
|
|
87
|
/**
|
88
|
* This method is used to convey layout state to different FlowFigures. This
|
89
|
* state is cleared when a fragment is added and once the layout is
|
90
|
* complete.
|
91
|
*
|
92
|
* @param value
|
93
|
* <code>true</code> indicates that the first fragment of the
|
94
|
* next TextFlow should be laid out on the current line, and not
|
95
|
* a new one
|
96
|
* @since 3.1
|
97
|
* @see #getContinueOnSameLine()
|
98
|
*/
|
99
|
void setContinueOnSameLine(boolean value);
|
100
|
|
101
|
}
|