public class ControlEditor
extends java.lang.Object
Here is an example of using a ControlEditor:
Canvas canvas = new Canvas(shell, SWT.BORDER);
canvas.setBounds(10, 10, 300, 300);
Color color = new Color(null, 255, 0, 0);
canvas.setBackground(color);
ControlEditor editor = new ControlEditor (canvas);
// The editor will be a button in the bottom right corner of the canvas.
// When selected, it will launch a Color dialog that will change the background
// of the canvas.
Button button = new Button(canvas, SWT.PUSH);
button.setText("Select Color...");
button.addSelectionListener (new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
ColorDialog dialog = new ColorDialog(shell);
dialog.open();
RGB rgb = dialog.getRGB();
if (rgb != null) {
if (color != null) color.dispose();
color = new Color(null, rgb);
canvas.setBackground(color);
}
}
});
editor.horizontalAlignment = SWT.RIGHT;
editor.verticalAlignment = SWT.BOTTOM;
editor.grabHorizontal = false;
editor.grabVertical = false;
Point size = button.computeSize(SWT.DEFAULT, SWT.DEFAULT);
editor.minimumWidth = size.x;
editor.minimumHeight = size.y;
editor.setEditor (button);
Modifier and Type | Field and Description |
---|---|
private Listener |
controlListener |
(package private) Control |
editor |
private static int[] |
EVENTS |
boolean |
grabHorizontal
Specifies whether the editor should be sized to use the entire width of the control.
|
boolean |
grabVertical
Specifies whether the editor should be sized to use the entire height of the control.
|
private boolean |
hadFocus |
int |
horizontalAlignment
Specifies how the editor should be aligned relative to the control.
|
int |
minimumHeight
Specifies the minimum height the editor can have.
|
int |
minimumWidth
Specifies the minimum width the editor can have.
|
(package private) Composite |
parent |
private Listener |
scrollbarListener |
int |
verticalAlignment
Specifies how the editor should be aligned relative to the control.
|
Constructor and Description |
---|
ControlEditor(Composite parent)
Creates a ControlEditor for the specified Composite.
|
Modifier and Type | Method and Description |
---|---|
(package private) Rectangle |
computeBounds() |
void |
dispose()
Removes all associations between the Editor and the underlying composite.
|
Control |
getEditor()
Returns the Control that is displayed above the composite being edited.
|
void |
layout()
Lays out the control within the underlying composite.
|
(package private) void |
scroll(Event e) |
void |
setEditor(Control editor)
Specify the Control that is to be displayed.
|
public int horizontalAlignment
public boolean grabHorizontal
public int minimumWidth
public int verticalAlignment
public boolean grabVertical
public int minimumHeight
Composite parent
Control editor
private boolean hadFocus
private Listener controlListener
private Listener scrollbarListener
private static final int[] EVENTS
public ControlEditor(Composite parent)
parent
- the Composite above which this editor will be displayedRectangle computeBounds()
public void dispose()
public Control getEditor()
public void layout()
void scroll(Event e)
public void setEditor(Control editor)
Note: The Control provided as the editor must be created with its parent being the Composite specified in the ControlEditor constructor.
editor
- the Control that is displayed above the composite being edited