KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > rcp > composite > TightWrapperComposite


1 /*
2  * Created on Nov 30, 2004
3  * by alex
4  *
5  */

6 package com.nightlabs.rcp.composite;
7
8 import org.eclipse.swt.layout.GridData;
9 import org.eclipse.swt.layout.GridLayout;
10 import org.eclipse.swt.widgets.Composite;
11
12 /**
13  * A composite for wrapping other composites and no insets.
14  *
15  * @see com.nightlabs.rcp.composite.OrdinaryWrapperComposite
16  * @see TightWrapperComposite#TightWrapperComposite(Composite, int, boolean)
17  *
18  * @author Alexander Bieber <alex[AT]nightlabs[DOT]de>
19  */

20 public class TightWrapperComposite extends Composite {
21
22     /**
23      * Creates a new Composite with a {@link GridLayout} what wastes a minimum of space.
24      * If setLayoutData is set the newly created Composite
25      * will fit itself into an other GridLayout by setting ist layoutData.
26      *
27      * @param parent
28      * @param style
29      * @param setLayoutData
30      */

31     public TightWrapperComposite(Composite parent, int style, boolean setLayoutData) {
32         super(parent, style);
33         this.setForeground(parent.getForeground());
34         this.setBackground(parent.getBackground());
35         GridLayout layout = new GridLayout();
36         layout.horizontalSpacing = 0;
37         layout.verticalSpacing = 0;
38         layout.marginHeight = 0;
39         layout.marginWidth = 0;
40
41 // layout.marginLeft = 0;
42
// layout.marginRight = 0;
43
// layout.marginTop = 0;
44
// layout.marginBottom = 0;
45

46         setLayout(layout);
47         if (setLayoutData) {
48             GridData gridData = new GridData(GridData.FILL_BOTH);
49 // gridData.minimumHeight = 1;
50
// gridData.minimumWidth = 1;
51
setLayoutData(gridData);
52         }
53     }
54
55     /**
56      * @return Returns the same instance as <tt>Composite.getLayout()</tt>, but you don't need to cast anymore.
57      * @see Composite#getLayout()
58      */

59     public GridLayout getGridLayout()
60     {
61         return (GridLayout)getLayout();
62     }
63
64     /**
65      * @return Returns the same instance as <tt>Control.getLayoutData()</tt>, but you don't need to cast anymore.
66      * @see org.eclipse.swt.widgets.Control#getLayoutData()
67      */

68     public GridData getGridData()
69     {
70         return (GridData)getLayoutData();
71     }
72 }
73
Popular Tags