Eclipse interface case (2) - Understand layout 1

xiaoxiao2021-03-06  55

The original text of this document is in the Eclipse website: http://www.eclipse.org/articles/understanding Layouts/understanding Layouts.htm

Winion translation Copyright © 2001 Object Technology International, Inc.

Summary

When using SWT to write an application, you usually need to use the layout Layouts to design a beautiful interface. A layout manages the size and position of subcompos on Composite. The layout class is a subclass of abstract layout. This document describes how to use standard layout classes, and how to write custom layout classes. Original author Carolyn Macleod, Oti March 22, 2001

Amended Shantha Ramachandran, Oti May 02, 2002

Translation Winion 2004.9.19 Section 1 Overview 1.1 Layout Overview When using standard part libraries (SWT), usually require usually need to use layout Layouts to design a beautiful interface. A layout manages the size and position of subcompos on Composite. SWT provides a layout class with a standard standard and can customize the layout class. In SWT, the position and size of the components are not automatically arranged. The application can calculate the size and position of the subcaps of Composite when initialized, or can be adjusted through the Resize listener. If there is no size for the stator component, then their size will be default 0, so it is displayed on the interface. The figure below shows several concepts commonly used in layout. A Composite (a TabFolder) has a location (Clientarea), a client area (ClientArea), and a modified area (TRIM). The size of the Composite is the size of the customer area plus the size of the modification area. This COMPOSITE has two subcomponents. Layout is used to manage the size and position of the subcomponents, which can define the distance between the subcomponents, spacing, sub-components, and boundaries. The size of Layout is consistent with the size of Composite's customer area. The preferred size of a component is the minimum size required to display large content. For the container, the size is the smallest rectangle containing all subcomponents. If the sub-assembly is placed by the application, the container calculates its preferred size according to the size and position of the sub-component. If the container places a sub-assembly using the layout class, it requires layout to calculate its client area size, and then add a modified area to give its preferred size. 1.2 Standard layout SWT Standard layout is: l FillLayout: Line in the same size or single column; L RowLayout: Use Fill, WRAP, SPACING, etc. in a single line or multi-line, etc. Arrange components in plaid; L formLayout (New Features of SWT 2.0): Arrange components by creating "attachments" on each side of the component. To use a standard layout class, you need to introduce the SWT layout class package: import org.eclipse.swt.layout. *; Layout is insertable. To set the layout of the Composite component, use the setLayout (Layout) method. The code demonstrates that a shell (subclass of Composite) uses RowLayout to lay out its subcomponents. Shell shell = new shell (); shell.setLayout (New RowLayout ()); a layout class can have a corresponding layout data class (subclass of Object), which can set a specific layout method for the specified sub-control. In order to use convenience, the name of the layout data class is obtained by replacing the layout class of Layout as DATA. For example, the layout data class of standard layout RowLayout is RowData, the layout data class of GridData, FormLayout is Formdata.

转载请注明原文地址:https://www.9cbs.com/read-115390.html

New Post(0)