KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > layout > TrimLayoutData


1 /*******************************************************************************
2  * Copyright (c) 2004 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.layout;
12
13 import org.eclipse.swt.SWT;
14
15 /**
16  * TrimLayoutData can be attached to a control in a TrimLayout to configure how
17  * TrimLayout will arrange the control. TrimLayoutData can override
18  * the control's preferred size. This is useful for attaching trim objects with
19  * badly-behaved computeSize implementations. TrimLayoutData can also specify whether
20  * the control should be resized with the layout.
21  * <p>
22  * To create a fixed-size control based on its preferred size, use:
23  * <code>
24  * new TrimLayoutData(false, SWT.DEFAULT, SWT.DEFAULT)
25  * </code>
26  * </p>
27  *
28  * <p>
29  * To create a resizable control that will be resized according to the available
30  * space in the layout, use:
31  * <code>
32  * new TrimLayoutData();
33  * </code>
34  * </p>
35  *
36  * <p>
37  * To create a control with a predetermined fixed size (that overrides the preferred size
38  * of the control, use:
39  * <code>
40  * new TrimLayoutData(false, someFixedWidthInPixels, someFixedHeightInPixels);
41  * </code>
42  * </p>
43  *
44  * @since 3.0
45  */

46 public class TrimLayoutData {
47     /**
48      * Width of the control (or SWT.DEFAULT if the control's preferred width should be used)
49      */

50     int widthHint = SWT.DEFAULT;
51
52     /**
53      * Height of the control (or SWT.DEFAULT if the control's preferred height should be used)
54      */

55     int heightHint = SWT.DEFAULT;
56
57     /**
58      * Flag indicating whether the control should resize with the window. Note that
59      * available space is always divided equally among all resizable controls on the
60      * same side of the layout, regardless of their preferred size.
61      */

62     boolean resizable = true;
63
64     /**
65      * Creates a default TrimLayoutData. The default trim layout data is resizable.
66      */

67     public TrimLayoutData() {
68     }
69
70     /**
71      * Creates a TrimLayoutData with user-specified parameters.
72      *
73      * @param resizable if true, the control will be resized with the layout. If there
74      * is more than one resizable control on the same side of the layout, the available
75      * space will be divided equally among all the controls.
76      *
77      * @param widthHint overrides the preferred width of the control (pixels). If SWT.DEFAULT,
78      * then the control's preferred width will be used. This has no effect for
79      * horizontally resizable controls.
80      *
81      * @param heightHint overrides the preferred height of the control (pixels). If SWT.DEFAULT,
82      * then the control's preferred height will be used. This has no effect for
83      * vertically resizable controls.
84      */

85     public TrimLayoutData(boolean resizable, int widthHint, int heightHint) {
86         this.widthHint = widthHint;
87         this.heightHint = heightHint;
88         this.resizable = resizable;
89     }
90
91 }
92
Popular Tags