4, complex control
(1) ExpandableComposite
l The Web page is a general theme with a part of the page content.
l Eclipse Form also provides such a control: ExpandableComposite
l The following code snippet is an example of using ExpandableComposite:
ExpandableComposite EC = Toolkit.createExpandableComposite (Body,
ExpandableComposite.Tree_Node
| ExpandableComposite.Client_indent);
Ec.Settext ("Expandable Composite Title");
String ctext = "WE WILL now CREATE A Somewhat Long Text So That"
"We can Use it as content for the expandable composite."
"Expandable Composite Is Used to Hide Or Show The Text Using To"
"Toggle Control";
Label Client = Toolkit.createLabel (EC, CText, SWT.WRAP);
Ec.SETCLIENT (Client);
TD = New TableWrapData ();
Td.colspan = 2;
Ec.setLayOutdata (TD);
Ec.addexpansionListener (New ExpansionAdapter () {
Public void ExpansionStateChanged (ExpansionEvent E) {
Form.reflow (TRUE);
}
});
l This control has a lot of styles, Tree_Node makes the control with the expansion and contracting function of the tree node; and Twistie makes the control with triangular arrow style
l Expanded makes initial expansion
l Client_indent makes client content indented
l ExpandableComposite is presented as activation controls and titles, and can be expanded, and the contracted content is called Client.
l Client must be expandable composite (the above case is the Label control)
l Need to add an Expansion listener to the status change, Reflow Form (ie, repositioning and updating the scroll bar according to the new size)
l The following is the result of the above example:
(2) Section
l Eclipse Form The most commonly used custom control is section (visible in PDE)
l Section Extend ExpandableComposite, but has the following new features:
N has a separate control below the title
N The following can have a description text under the separated control
l The following code segment is an example of using section, code and ExpandableComposite are not too big, here is a TWistie style:
Section section = Toolkit.createSecion (body, section.description
| Section.twistie | section.expanded; TD = New TableWrapData (TableWrapData.fill);
Td.colspan = 2;
Section.setLayOutdata (TD);
Section.addexpansionListener (New ExpansionAdapter () {
Public void ExpansionStateChanged (ExpansionEvent E) {
Form.reflow (TRUE);
}
});
Section.Settext ("Section Title");
Toolkit.createCompositSeparator (section);
section
.SETDESCRIPTION ("This Is The Description That Goes Below The Title";
Composite SectionClient = Toolkit.createComposite;
SectionClient.setLayout (New GridLayout ());
Button = Toolkit.createButton (SectionClient, "Radio 1", SWT.RADIO);
Button = Toolkit.createButton (SectionClient, "Radio 2", SWT.RADIO);
Section.setClient (SectionClient);
l The following is the result of the above example: