From 314211c65ad89e388be469f44f49203cffeb8c25 Mon Sep 17 00:00:00 2001 From: Deepika Udayagiri Date: Tue, 13 Aug 2024 15:21:08 +0530 Subject: [PATCH] Moving TabFolderLayout into SWT. Updated as per review comments. Fixes https://github.com/eclipse-platform/eclipse.platform.swt/issues/1317 --- .../eclipse/swt/layout/TabFolderLayout.java | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/TabFolderLayout.java diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/TabFolderLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/TabFolderLayout.java new file mode 100644 index 00000000000..c31113e52b0 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/TabFolderLayout.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.swt.layout; + +import org.eclipse.swt.*; +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.widgets.*; + +/** + * This layout controls the position and size of the children of a tab folder. + * In addition this layout can be used for any component that wants + * TabFolder-Like behaviour (e.g. only showing all component at the full size + * of the composite stacked onto each other) + * + * @since 3.128 + */ +public class TabFolderLayout extends Layout { + + @Override + protected Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache) { + if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) + return new Point(wHint, hHint); + + Control [] children = composite.getChildren (); + int count = children.length; + int maxWidth = 0, maxHeight = 0; + for (int i=0; i