use of org.eclipse.swt.widgets.Sash in project translationstudio8 by heartsome.
the class TermDbManagerDialog method createSash.
/**
* Create the sash with right control on the right. Note that this method assumes GridData for the layout data of
* the rightControl.
* @param composite
* @param rightControl
* @return Sash
*/
protected Sash createSash(final Composite composite, final Control rightControl) {
final Sash sash = new Sash(composite, SWT.VERTICAL);
sash.setLayoutData(new GridData(GridData.FILL_VERTICAL));
sash.setBackground(composite.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
// the following listener resizes the tree control based on sash deltas.
// If necessary, it will also grow/shrink the dialog.
sash.addListener(SWT.Selection, new Listener() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt. widgets.Event)
*/
public void handleEvent(Event event) {
if (event.detail == SWT.DRAG) {
return;
}
int shift = event.x - sash.getBounds().x;
GridData data = (GridData) rightControl.getLayoutData();
int newWidthHint = data.widthHint + shift;
if (newWidthHint < 20) {
return;
}
Point computedSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
Point currentSize = getShell().getSize();
// if the dialog wasn't of a custom size we know we can shrink
// it if necessary based on sash movement.
boolean customSize = !computedSize.equals(currentSize);
data.widthHint = newWidthHint;
setLastTreeWidth(newWidthHint);
composite.layout(true);
// recompute based on new widget size
computedSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
// necessary.
if (customSize) {
computedSize.x = Math.max(computedSize.x, currentSize.x);
}
computedSize.y = Math.max(computedSize.y, currentSize.y);
if (computedSize.equals(currentSize)) {
return;
}
setShellSize(computedSize.x, computedSize.y);
lastShellSize = getShell().getSize();
}
});
return sash;
}
use of org.eclipse.swt.widgets.Sash in project translationstudio8 by heartsome.
the class TmDbManagerDialog method createSash.
/**
* Create the sash with right control on the right. Note that this method assumes GridData for the layout data of
* the rightControl.
* @param composite
* @param rightControl
* @return Sash
*/
protected Sash createSash(final Composite composite, final Control rightControl) {
final Sash sash = new Sash(composite, SWT.VERTICAL);
sash.setLayoutData(new GridData(GridData.FILL_VERTICAL));
sash.setBackground(composite.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
// the following listener resizes the tree control based on sash deltas.
// If necessary, it will also grow/shrink the dialog.
sash.addListener(SWT.Selection, new Listener() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt. widgets.Event)
*/
public void handleEvent(Event event) {
if (event.detail == SWT.DRAG) {
return;
}
int shift = event.x - sash.getBounds().x;
GridData data = (GridData) rightControl.getLayoutData();
int newWidthHint = data.widthHint + shift;
if (newWidthHint < 20) {
return;
}
Point computedSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
Point currentSize = getShell().getSize();
// if the dialog wasn't of a custom size we know we can shrink
// it if necessary based on sash movement.
boolean customSize = !computedSize.equals(currentSize);
data.widthHint = newWidthHint;
setLastTreeWidth(newWidthHint);
composite.layout(true);
// recompute based on new widget size
computedSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
// necessary.
if (customSize) {
computedSize.x = Math.max(computedSize.x, currentSize.x);
}
computedSize.y = Math.max(computedSize.y, currentSize.y);
if (computedSize.equals(currentSize)) {
return;
}
setShellSize(computedSize.x, computedSize.y);
lastShellSize = getShell().getSize();
}
});
return sash;
}
use of org.eclipse.swt.widgets.Sash in project bndtools by bndtools.
the class SashHighlightForm method setSashForeground.
public void setSashForeground(Color color) {
try {
Field fgfield = SashForm.class.getDeclaredField("foreground");
fgfield.setAccessible(true);
fgfield.set(this, color);
Field sashesField = SashForm.class.getDeclaredField("sashes");
sashesField.setAccessible(true);
Sash[] sashes = (Sash[]) sashesField.get(this);
for (Sash sash : sashes) {
sash.setForeground(color);
}
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
use of org.eclipse.swt.widgets.Sash in project bndtools by bndtools.
the class MDSashForm method hookSashListeners.
private void hookSashListeners() {
purgeSashes();
Control[] children = getChildren();
for (int i = 0; i < children.length; i++) {
if (children[i] instanceof Sash) {
Sash sash = (Sash) children[i];
if (sashes.contains(sash))
continue;
sash.addListener(SWT.Paint, listener);
sash.addListener(SWT.MouseEnter, listener);
sash.addListener(SWT.MouseExit, listener);
sashes.add(sash);
}
}
}
use of org.eclipse.swt.widgets.Sash in project bndtools by bndtools.
the class MDSashForm method onSashPaint.
private void onSashPaint(Event e) {
Sash sash = (Sash) e.widget;
boolean vertical = (sash.getStyle() & SWT.VERTICAL) != 0;
GC gc = e.gc;
//$NON-NLS-1$
Boolean hover = (Boolean) sash.getData("hover");
gc.setBackground(bg);
gc.setForeground(fg);
Point size = sash.getSize();
if (vertical) {
if (hover != null)
gc.fillRectangle(0, 0, size.x, size.y);
// else
// gc.drawLine(1, 0, 1, size.y-1);
} else {
if (hover != null)
gc.fillRectangle(0, 0, size.x, size.y);
// else
// gc.drawLine(0, 1, size.x-1, 1);
}
}
Aggregations