comparison dwtx/draw2d/text/FlowContext.d @ 98:95307ad235d9

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