KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > forms > widgets > BreakSegment


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  *******************************************************************************/

11 package org.eclipse.ui.internal.forms.widgets;
12
13 import java.util.Hashtable JavaDoc;
14
15 import org.eclipse.swt.graphics.FontMetrics;
16 import org.eclipse.swt.graphics.GC;
17 import org.eclipse.swt.graphics.Rectangle;
18
19 /**
20  * This segment serves as break within a paragraph. It has no data -
21  * just starts a new line and resets the locator.
22  */

23
24 public class BreakSegment extends ParagraphSegment {
25     /* (non-Javadoc)
26      * @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)
27      */

28     public boolean advanceLocator(GC gc, int wHint, Locator locator,
29             Hashtable JavaDoc objectTable, boolean computeHeightOnly) {
30         if (locator.rowHeight==0) {
31             FontMetrics fm = gc.getFontMetrics();
32             locator.rowHeight = fm.getHeight();
33         }
34         if (computeHeightOnly) 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 JavaDoc resourceTable, boolean selected, SelectionData selData, Rectangle repaintRegion) {
43         //nothing to paint
44
}
45     public boolean contains(int x, int y) {
46         return false;
47     }
48     public boolean intersects(Rectangle rect) {
49         return false;
50     }
51     /* (non-Javadoc)
52      * @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)
53      */

54     public void layout(GC gc, int width, Locator locator, Hashtable JavaDoc ResourceTable,
55             boolean selected) {
56         locator.resetCaret();
57         if (locator.rowHeight==0) {
58             FontMetrics fm = gc.getFontMetrics();
59             locator.rowHeight = fm.getHeight();
60         }
61         locator.y += locator.rowHeight;
62         locator.rowHeight = 0;
63         locator.rowCounter++;
64     }
65
66     /* (non-Javadoc)
67      * @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)
68      */

69     public void computeSelection(GC gc, Hashtable JavaDoc resourceTable, SelectionData selData) {
70         selData.markNewLine();
71     }
72 }
73
Popular Tags