KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Created on Jun 1, 2005
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 /**
14  * A Composite for wrapping other composites but with
15  * insets. Use this as your default base Composite when
16  * you do not have to do tight wrapping.
17  *
18  * @see com.nightlabs.rcp.composite.TightWrapperComposite
19  * @author Alexander Bieber <alex[AT]nightlabs[DOT]de>
20  *
21  */

22 public class OrdinaryWrapperComposite extends Composite {
23
24     public OrdinaryWrapperComposite(Composite parent, int style, boolean setLayoutData) {
25         super(parent, style);
26         this.setForeground(parent.getForeground());
27         this.setBackground(parent.getBackground());
28
29         GridLayout layout = new GridLayout();
30         setLayout(layout);
31         if (setLayoutData) {
32             GridData gridData = new GridData(GridData.FILL_BOTH);
33 // gridData.minimumHeight = 1;
34
// gridData.minimumWidth = 1;
35
setLayoutData(gridData);
36         }
37     }
38
39     /**
40      * @return Returns the same instance as <tt>Composite.getLayout()</tt>, but you don't need to cast anymore.
41      * @see Composite#getLayout()
42      */

43     public GridLayout getGridLayout()
44     {
45         return (GridLayout)getLayout();
46     }
47
48     /**
49      * @return Returns the same instance as <tt>Control.getLayoutData()</tt>, but you don't need to cast anymore.
50      * @see org.eclipse.swt.widgets.Control#getLayoutData()
51      */

52     public GridData getGridData()
53     {
54         return (GridData)getLayoutData();
55     }
56
57 }
58
Popular Tags