Skip to content

Commit 0324a13

Browse files
deepika-uakurtakov
authored andcommitted
Moving TabFolderLayout into SWT. Updated as per review comments.
Fixes eclipse-platform#1317
1 parent 8056739 commit 0324a13

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2000, 2005 IBM Corporation and others.
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* IBM Corporation - initial API and implementation
13+
*******************************************************************************/
14+
15+
package org.eclipse.swt.layout;
16+
17+
import org.eclipse.swt.*;
18+
import org.eclipse.swt.graphics.*;
19+
import org.eclipse.swt.widgets.*;
20+
21+
/**
22+
* This layout controls the position and size of the children of a tab folder.
23+
* In addition this layout can be used for any component that wants
24+
* TabFolder-Like behaviour (e.g. only showing all component at the full size
25+
* of the composite stacked onto each other)
26+
*
27+
* @since 3.128
28+
*/
29+
public class TabFolderLayout extends Layout {
30+
31+
@Override
32+
protected Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache) {
33+
if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT)
34+
return new Point(wHint, hHint);
35+
36+
Control [] children = composite.getChildren ();
37+
int count = children.length;
38+
int maxWidth = 0, maxHeight = 0;
39+
for (int i=0; i<count; i++) {
40+
Control child = children [i];
41+
Point pt = child.computeSize (SWT.DEFAULT, SWT.DEFAULT, flushCache);
42+
maxWidth = Math.max (maxWidth, pt.x);
43+
maxHeight = Math.max (maxHeight, pt.y);
44+
}
45+
46+
if (wHint != SWT.DEFAULT)
47+
maxWidth= wHint;
48+
if (hHint != SWT.DEFAULT)
49+
maxHeight= hHint;
50+
51+
return new Point(maxWidth, maxHeight);
52+
53+
}
54+
55+
@Override
56+
protected void layout (Composite composite, boolean flushCache) {
57+
Rectangle rect= composite.getClientArea();
58+
59+
Control[] children = composite.getChildren();
60+
for (Control c : children) {
61+
c.setBounds(rect);
62+
}
63+
}
64+
}

0 commit comments

Comments
 (0)