Java by API/org.eclipse.swt.custom/SashForm — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 14:43, 31 мая 2010
Содержание
SashForm: getMaximizedControl()
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.ruposite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class MainClass {
public static void main(String[] a) {
final Display d = new Display();
final Shell shell = new Shell(d);
shell.setSize(250, 200);
shell.setLayout(new GridLayout(1, false));
Composite sash = new Composite(shell, SWT.NONE);
sash.setLayout(new FillLayout());
sash.setLayoutData(new GridData(GridData.FILL_BOTH));
final SashForm sashForm = new SashForm(sash, SWT.HORIZONTAL);
sashForm.SASH_WIDTH = 5;
sashForm.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
final Button one = new Button(sashForm, SWT.PUSH);
one.setText("One");
one.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
maximizeHelper(one, sashForm);
}
});
final Button two = new Button(sashForm, SWT.PUSH);
two.setText("Two");
two.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
maximizeHelper(two, sashForm);
}
});
final Button three = new Button(sashForm, SWT.PUSH);
three.setText("Three");
three.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
maximizeHelper(three, sashForm);
}
});
shell.open();
while (!shell.isDisposed()) {
if (!d.readAndDispatch())
d.sleep();
}
d.dispose();
}
private static void maximizeHelper(Control control, SashForm sashForm) {
// See if the control is already maximized
if (control == sashForm.getMaximizedControl()) {
// Already maximized; restore it
sashForm.setMaximizedControl(null);
} else {
// Not yet maximized, so maximize it
sashForm.setMaximizedControl(control);
}
}
}
SashForm: SASH_WIDTH
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.ruposite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class MainClass {
public static void main(String[] a) {
final Display d = new Display();
final Shell shell = new Shell(d);
shell.setSize(250, 200);
shell.setLayout(new GridLayout(1, false));
Composite buttonBar = new Composite(shell, SWT.NONE);
buttonBar.setLayout(new RowLayout());
Button flip = new Button(buttonBar, SWT.PUSH);
flip.setText("Switch Orientation");
Button weights = new Button(buttonBar, SWT.PUSH);
weights.setText("Restore Weights");
Composite sash = new Composite(shell, SWT.NONE);
sash.setLayout(new FillLayout());
sash.setLayoutData(new GridData(GridData.FILL_BOTH));
final SashForm sashForm = new SashForm(sash, SWT.HORIZONTAL);
sashForm.SASH_WIDTH = 5;
sashForm.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
final Button one = new Button(sashForm, SWT.PUSH);
one.setText("One");
final Button two = new Button(sashForm, SWT.PUSH);
two.setText("Two");
final Button three = new Button(sashForm, SWT.PUSH);
three.setText("Three");
sashForm.setWeights(new int[] { 2, 2, 2});
flip.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
switch (sashForm.getOrientation()) {
case SWT.HORIZONTAL:
sashForm.setOrientation(SWT.VERTICAL);
break;
case SWT.VERTICAL:
sashForm.setOrientation(SWT.HORIZONTAL);
break;
}
}
});
weights.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
sashForm.setWeights(new int[] { 2, 2, 2});
}
});
shell.open();
while (!shell.isDisposed()) {
if (!d.readAndDispatch())
d.sleep();
}
d.dispose();
}
}
SashForm: setBackground(Color color)
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.ruposite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class MainClass {
public static void main(String[] a) {
final Display d = new Display();
final Shell shell = new Shell(d);
shell.setSize(250, 200);
shell.setLayout(new GridLayout(1, false));
Composite buttonBar = new Composite(shell, SWT.NONE);
buttonBar.setLayout(new RowLayout());
Button flip = new Button(buttonBar, SWT.PUSH);
flip.setText("Switch Orientation");
Button weights = new Button(buttonBar, SWT.PUSH);
weights.setText("Restore Weights");
Composite sash = new Composite(shell, SWT.NONE);
sash.setLayout(new FillLayout());
sash.setLayoutData(new GridData(GridData.FILL_BOTH));
final SashForm sashForm = new SashForm(sash, SWT.HORIZONTAL);
sashForm.SASH_WIDTH = 5;
sashForm.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
final Button one = new Button(sashForm, SWT.PUSH);
one.setText("One");
final Button two = new Button(sashForm, SWT.PUSH);
two.setText("Two");
final Button three = new Button(sashForm, SWT.PUSH);
three.setText("Three");
sashForm.setWeights(new int[] { 2, 2, 2});
flip.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
switch (sashForm.getOrientation()) {
case SWT.HORIZONTAL:
sashForm.setOrientation(SWT.VERTICAL);
break;
case SWT.VERTICAL:
sashForm.setOrientation(SWT.HORIZONTAL);
break;
}
}
});
weights.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
sashForm.setWeights(new int[] { 2, 2, 2});
}
});
shell.open();
while (!shell.isDisposed()) {
if (!d.readAndDispatch())
d.sleep();
}
d.dispose();
}
}
SashForm: setMaximizedControl(Control control)
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.ruposite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class MainClass {
public static void main(String[] a) {
final Display d = new Display();
final Shell shell = new Shell(d);
shell.setSize(250, 200);
shell.setLayout(new GridLayout(1, false));
Composite sash = new Composite(shell, SWT.NONE);
sash.setLayout(new FillLayout());
sash.setLayoutData(new GridData(GridData.FILL_BOTH));
final SashForm sashForm = new SashForm(sash, SWT.HORIZONTAL);
sashForm.SASH_WIDTH = 5;
sashForm.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
final Button one = new Button(sashForm, SWT.PUSH);
one.setText("One");
one.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
maximizeHelper(one, sashForm);
}
});
final Button two = new Button(sashForm, SWT.PUSH);
two.setText("Two");
two.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
maximizeHelper(two, sashForm);
}
});
final Button three = new Button(sashForm, SWT.PUSH);
three.setText("Three");
three.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
maximizeHelper(three, sashForm);
}
});
shell.open();
while (!shell.isDisposed()) {
if (!d.readAndDispatch())
d.sleep();
}
d.dispose();
}
private static void maximizeHelper(Control control, SashForm sashForm) {
// See if the control is already maximized
if (control == sashForm.getMaximizedControl()) {
// Already maximized; restore it
sashForm.setMaximizedControl(null);
} else {
// Not yet maximized, so maximize it
sashForm.setMaximizedControl(control);
}
}
}
SashForm: setOrientation(int o)
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.ruposite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class MainClass {
public static void main(String[] a) {
final Display d = new Display();
final Shell shell = new Shell(d);
shell.setSize(250, 200);
shell.setLayout(new GridLayout(1, false));
Composite buttonBar = new Composite(shell, SWT.NONE);
buttonBar.setLayout(new RowLayout());
Button flip = new Button(buttonBar, SWT.PUSH);
flip.setText("Switch Orientation");
Button weights = new Button(buttonBar, SWT.PUSH);
weights.setText("Restore Weights");
Composite sash = new Composite(shell, SWT.NONE);
sash.setLayout(new FillLayout());
sash.setLayoutData(new GridData(GridData.FILL_BOTH));
final SashForm sashForm = new SashForm(sash, SWT.HORIZONTAL);
sashForm.SASH_WIDTH = 5;
sashForm.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
final Button one = new Button(sashForm, SWT.PUSH);
one.setText("One");
final Button two = new Button(sashForm, SWT.PUSH);
two.setText("Two");
final Button three = new Button(sashForm, SWT.PUSH);
three.setText("Three");
sashForm.setWeights(new int[] { 2, 2, 2});
flip.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
switch (sashForm.getOrientation()) {
case SWT.HORIZONTAL:
sashForm.setOrientation(SWT.VERTICAL);
break;
case SWT.VERTICAL:
sashForm.setOrientation(SWT.HORIZONTAL);
break;
}
}
});
weights.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
sashForm.setWeights(new int[] { 2, 2, 2});
}
});
shell.open();
while (!shell.isDisposed()) {
if (!d.readAndDispatch())
d.sleep();
}
d.dispose();
}
}
SashForm: setWeights(int[] arg0)
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.ruposite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class MainClass {
public static void main(String[] a) {
final Display d = new Display();
final Shell shell = new Shell(d);
shell.setSize(250, 200);
shell.setLayout(new GridLayout(1, false));
Composite buttonBar = new Composite(shell, SWT.NONE);
buttonBar.setLayout(new RowLayout());
Button flip = new Button(buttonBar, SWT.PUSH);
flip.setText("Switch Orientation");
Button weights = new Button(buttonBar, SWT.PUSH);
weights.setText("Restore Weights");
Composite sash = new Composite(shell, SWT.NONE);
sash.setLayout(new FillLayout());
sash.setLayoutData(new GridData(GridData.FILL_BOTH));
final SashForm sashForm = new SashForm(sash, SWT.HORIZONTAL);
sashForm.SASH_WIDTH = 5;
sashForm.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
final Button one = new Button(sashForm, SWT.PUSH);
one.setText("One");
final Button two = new Button(sashForm, SWT.PUSH);
two.setText("Two");
final Button three = new Button(sashForm, SWT.PUSH);
three.setText("Three");
sashForm.setWeights(new int[] { 2, 2, 2});
flip.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
switch (sashForm.getOrientation()) {
case SWT.HORIZONTAL:
sashForm.setOrientation(SWT.VERTICAL);
break;
case SWT.VERTICAL:
sashForm.setOrientation(SWT.HORIZONTAL);
break;
}
}
});
weights.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
sashForm.setWeights(new int[] { 2, 2, 2});
}
});
shell.open();
while (!shell.isDisposed()) {
if (!d.readAndDispatch())
d.sleep();
}
d.dispose();
}
}