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.ui.internal.forms.widgets;
11:
12: import java.util.Hashtable;
13:
14: import org.eclipse.swt.graphics.FontMetrics;
15: import org.eclipse.swt.graphics.GC;
16: import org.eclipse.swt.graphics.Rectangle;
17:
18: /**
19: * This segment serves as break within a paragraph. It has no data -
20: * just starts a new line and resets the locator.
21: */
22:
23: public class BreakSegment extends ParagraphSegment {
24: /* (non-Javadoc)
25: * @see org.eclipse.ui.forms.internal.widgets.ParagraphSegment#advanceLocator(org.eclipse.swt.graphics.GC, int, org.eclipse.ui.forms.internal.widgets.Locator, java.util.Hashtable)
26: */
27: public boolean advanceLocator(GC gc, int wHint, Locator locator,
28: Hashtable objectTable, boolean computeHeightOnly) {
29: if (locator.rowHeight == 0) {
30: FontMetrics fm = gc.getFontMetrics();
31: locator.rowHeight = fm.getHeight();
32: }
33: if (computeHeightOnly)
34: locator.collectHeights();
35: locator.x = locator.indent;
36: locator.y += locator.rowHeight;
37: locator.rowHeight = 0;
38: locator.leading = 0;
39: return true;
40: }
41:
42: public void paint(GC gc, boolean hover, Hashtable resourceTable,
43: boolean selected, SelectionData selData,
44: Rectangle repaintRegion) {
45: //nothing to paint
46: }
47:
48: public boolean contains(int x, int y) {
49: return false;
50: }
51:
52: public boolean intersects(Rectangle rect) {
53: return false;
54: }
55:
56: /* (non-Javadoc)
57: * @see org.eclipse.ui.internal.forms.widgets.ParagraphSegment#layout(org.eclipse.swt.graphics.GC, int, org.eclipse.ui.internal.forms.widgets.Locator, java.util.Hashtable, boolean, org.eclipse.ui.internal.forms.widgets.SelectionData)
58: */
59: public void layout(GC gc, int width, Locator locator,
60: Hashtable ResourceTable, boolean selected) {
61: locator.resetCaret();
62: if (locator.rowHeight == 0) {
63: FontMetrics fm = gc.getFontMetrics();
64: locator.rowHeight = fm.getHeight();
65: }
66: locator.y += locator.rowHeight;
67: locator.rowHeight = 0;
68: locator.rowCounter++;
69: }
70:
71: /* (non-Javadoc)
72: * @see org.eclipse.ui.internal.forms.widgets.ParagraphSegment#computeSelection(org.eclipse.swt.graphics.GC, java.util.Hashtable, boolean, org.eclipse.ui.internal.forms.widgets.SelectionData)
73: */
74: public void computeSelection(GC gc, Hashtable resourceTable,
75: SelectionData selData) {
76: selData.markNewLine();
77: }
78: }
|