Rectangle childBounds = shell.getBounds();
int heightOneThird = parentBounds.height / 3;
+ int widthDockingArea = 30;
+ int widthIntersectRegion = 5;
/* right-middle */
- Rectangle attachBounds1 = new Rectangle(
- (parentBounds.x + parentBounds.width) - 5,
+ Rectangle attachBoundsRC = new Rectangle(
+ (parentBounds.x + parentBounds.width) - widthIntersectRegion,
parentBounds.y + heightOneThird,
- 30, heightOneThird);
+ widthDockingArea, heightOneThird);
/* right-top */
- Rectangle attachBounds2 = new Rectangle(
- (parentBounds.x + parentBounds.width) - 5,
+ Rectangle attachBoundsRT = new Rectangle(
+ (parentBounds.x + parentBounds.width) - widthIntersectRegion,
parentBounds.y,
- 30, heightOneThird);
+ widthDockingArea, heightOneThird);
/* right-bottom */
- Rectangle attachBounds3 = new Rectangle(
- (parentBounds.x + parentBounds.width) - 5,
+ Rectangle attachBoundsRB = new Rectangle(
+ (parentBounds.x + parentBounds.width) - widthIntersectRegion,
parentBounds.y + (heightOneThird * 2),
- 30, heightOneThird);
+ widthDockingArea, heightOneThird);
- if (childBounds.intersects(attachBounds1) == true) {
+ /* left-middle */
+ Rectangle attachBoundsLC = new Rectangle(
+ parentBounds.x - (widthDockingArea - widthIntersectRegion),
+ parentBounds.y + heightOneThird,
+ widthDockingArea, heightOneThird);
+ /* left-top */
+ Rectangle attachBoundsLT = new Rectangle(
+ parentBounds.x - (widthDockingArea - widthIntersectRegion),
+ parentBounds.y,
+ widthDockingArea, heightOneThird);
+ /* left-bottom */
+ Rectangle attachBoundsLB = new Rectangle(
+ parentBounds.x - (widthDockingArea - widthIntersectRegion),
+ parentBounds.y + (heightOneThird * 2),
+ widthDockingArea, heightOneThird);
+
+ if (childBounds.intersects(attachBoundsRC) == true) {
dock(SWT.RIGHT | SWT.CENTER, false, true);
- } else if (childBounds.intersects(attachBounds2) == true) {
+ } else if (childBounds.intersects(attachBoundsRT) == true) {
dock(SWT.RIGHT | SWT.TOP, false, true);
- } else if (childBounds.intersects(attachBounds3) == true) {
+ } else if (childBounds.intersects(attachBoundsRB) == true) {
dock(SWT.RIGHT | SWT.BOTTOM, false, true);
+ } else if (childBounds.intersects(attachBoundsLC) == true) {
+ dock(SWT.LEFT | SWT.CENTER, false, true);
+ } else if (childBounds.intersects(attachBoundsLT) == true) {
+ dock(SWT.LEFT | SWT.TOP, false, true);
+ } else if (childBounds.intersects(attachBoundsLB) == true) {
+ dock(SWT.LEFT | SWT.BOTTOM, false, true);
} else {
dock(SWT.NONE, false, true);
}
x += shift;
parent.setLocation(parentBounds.x + shift, parentBounds.y);
}*/
- } else { /* SWT.RIGHT | SWT.CENTER */
+ }
+ else if (dockPosition == (SWT.LEFT | SWT.CENTER)) {
+ x = parentBounds.x - childBounds.width;
+ y = parentBounds.y + (parentBounds.height / 2) -
+ (childBounds.height / 2);
+ } else if (dockPosition == (SWT.LEFT | SWT.TOP)) {
+ x = parentBounds.x - childBounds.width;
+ y = parentBounds.y;
+ } else if (dockPosition == (SWT.LEFT | SWT.BOTTOM)) {
+ x = parentBounds.x - childBounds.width;
+ y = parentBounds.y + parentBounds.height - childBounds.height;
+ }
+ else { /* SWT.RIGHT | SWT.CENTER */
x = parentBounds.x + parentBounds.width;
y = parentBounds.y + (parentBounds.height / 2) -
(childBounds.height / 2);