KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > texteditor > LinearLayouter


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.texteditor;
12
13 import org.eclipse.swt.graphics.Region;
14 import org.eclipse.swt.layout.GridData;
15 import org.eclipse.swt.layout.GridLayout;
16 import org.eclipse.swt.widgets.Layout;
17
18 /**
19  *
20  *
21  * @since 3.0
22  */

23 public class LinearLayouter {
24
25     private static final int ANNOTATION_SIZE= 14;
26     private static final int BORDER_WIDTH= 2;
27
28     public Layout getLayout(int itemCount) {
29         // simple layout: a row of items
30
GridLayout layout= new GridLayout(itemCount, true);
31         layout.horizontalSpacing= 1;
32         layout.verticalSpacing= 0;
33         layout.marginHeight= 1;
34         layout.marginWidth= 1;
35         return layout;
36     }
37
38     public Object JavaDoc getLayoutData() {
39         GridData gridData= new GridData(ANNOTATION_SIZE + 2 * BORDER_WIDTH, ANNOTATION_SIZE + 2 * BORDER_WIDTH);
40         gridData.horizontalAlignment= GridData.CENTER;
41         gridData.verticalAlignment= GridData.CENTER;
42         return gridData;
43     }
44
45     public int getAnnotationSize() {
46         return ANNOTATION_SIZE;
47     }
48
49     public int getBorderWidth() {
50         return BORDER_WIDTH;
51     }
52
53     public Region getShellRegion(int itemCount) {
54         // no special region - set to null for default shell size
55
return null;
56     }
57
58 }
59
Popular Tags