Skip to main content
summaryrefslogtreecommitdiffstats
blob: f3568f200b91620ead946502eac6ff7786cea7f2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*******************************************************************************
 * Copyright (c) 2006 Sybase, Inc. and others.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     Sybase, Inc. - initial API and implementation
 *******************************************************************************/
package org.eclipse.jst.pagedesigner.css2.layout;

import org.eclipse.draw2d.FigureUtilities;
import org.eclipse.jst.pagedesigner.css2.font.CSSFont;
import org.eclipse.jst.pagedesigner.css2.font.CSSFontManager;
import org.eclipse.swt.graphics.Font;

/**
 * A block layout which requires no FlowContext to perform its layout. This
 * class is used by {@link FlowPage}.
 * <p>
 * WARNING: This class is not intended to be subclassed by clients.
 */
public class PageFlowLayout extends BlockFlowLayout {

	/**
	 * Creates a new PageFlowLayout with the given FlowPage
	 * 
	 * @param page
	 *            the FlowPage
	 */
	public PageFlowLayout(FlowPage page) {
		super(page);
	}

	/**
	 * @see BlockFlowLayout#endBlock()
	 */
	protected void endBlock() {
        // do nothing
	}

	/**
	 * 
	 */
	public void postValidate() {
       // TODO: This method is not being called.
	}

	protected void setupLine(LineBox line, int topMargin) {
		super.setupLine(line, topMargin);

		CSSFontManager fontManager = CSSFontManager.getInstance();
		Font font = fontManager.getSwtFont((CSSFont) fontManager
				.createDefaultFont());
		line.setFontMetrics(FigureUtilities.getFontMetrics(font));
	}

	/**
	 * Setup blockBox to the initial bounds of the Page
	 */
	protected void setupBlock() {
		// Remove all current Fragments
		_blockBox.clear();

		// Setup the one fragment for this Block with the correct X and
		// available width
		_blockBox.setRecommendedWidth(((FlowPage) getFlowFigure())
				.getRecommendedWidth());
		_blockBox._x = 0;
	}

}

Back to the top