private Menu contextMenu;
private MenuItem panelItem; /* key window menu */
- public ControlPanel controlPanel;
+ public ControlPanel keyWindow;
public Color colorPairTag;
public Canvas pairTagCanvas;
public CustomProgressBar bootingProgress;
screenShotDialog = null;
}
- /* close the control panel window */
- if (null != controlPanel) {
- Shell cpShell = controlPanel.getShell();
- if (!cpShell.isDisposed()) {
- cpShell.close();
+ /* close the Key Window */
+ if (null != keyWindow) {
+ Shell keyWindowShell = keyWindow.getShell();
+ if (!keyWindowShell.isDisposed()) {
+ keyWindowShell.close();
}
- controlPanel = null;
+ keyWindow = null;
if (colorPairTag != null) {
colorPairTag.dispose();
logger.info("gain focus");
if (isOnTop == false && isControlPanel == true) {
- if (controlPanel != null &&
- controlPanel.isAttach() != SWT.NONE) {
- controlPanel.getShell().moveAbove(shell);
+ if (keyWindow != null &&
+ keyWindow.getDockPosition() != SWT.NONE) {
+ keyWindow.getShell().moveAbove(shell);
}
}
}
return isControlPanel;
}
- public void openKeyWindow(int attach) {
- if (controlPanel != null) {
- controlPanel.getShell().setVisible(true);
- SkinUtil.setTopMost(controlPanel.getShell(), isOnTop);
- controlPanel.setAttach(attach);
+ public void openKeyWindow(int dockValue) {
+ if (keyWindow != null) {
+ keyWindow.getShell().setVisible(true);
+ SkinUtil.setTopMost(keyWindow.getShell(), isOnTop);
pairTagCanvas.setVisible(true);
return;
}
try {
- controlPanel = new ControlPanel(this, shell, colorPairTag,
+ keyWindow = new ControlPanel(this, shell, colorPairTag,
communicator, keyMapList);
- SkinUtil.setTopMost(controlPanel.getShell(), isOnTop);
+ SkinUtil.setTopMost(keyWindow.getShell(), isOnTop);
- //colorPairTag = controlPanel.getPairTagColor();
+ //colorPairTag = keyWindow.getPairTagColor();
pairTagCanvas.setVisible(true);
- controlPanel.open();
+ keyWindow.open(dockValue);
/* do not add at this line */
} finally {
- controlPanel = null;
+ keyWindow = null;
}
}
public void hideKeyWindow() {
- controlPanel.getShell().setVisible(false);
+ keyWindow.getShell().setVisible(false);
pairTagCanvas.setVisible(false);
}
if (SkinUtil.setTopMost(shell, isOnTop) == false) {
logger.info("failed to Always On Top");
} else {
- if (controlPanel != null) {
- SkinUtil.setTopMost(controlPanel.getShell(), isOnTop);
+ if (keyWindow != null) {
+ SkinUtil.setTopMost(keyWindow.getShell(), isOnTop);
}
}
}
setIsControlPanel(isControlPanel);
if (isControlPanel == true) {
- openKeyWindow((controlPanel == null) ?
- SWT.NONE : controlPanel.isAttach());
+ openKeyWindow((keyWindow == null) ?
+ SWT.RIGHT | SWT.CENTER : keyWindow.getDockPosition());
} else { /* hide a key window */
- if (controlPanel != null &&
- controlPanel.isAttach() != SWT.NONE) {
+ if (keyWindow != null &&
+ keyWindow.getDockPosition() != SWT.NONE) {
+ /* Close the Key Window if it is docked to Main Window */
pairTagCanvas.setVisible(false);
- controlPanel.getShell().close();
+ keyWindow.getShell().close();
} else {
hideKeyWindow();
}
@Override
public void mouseDown(MouseEvent e) {
if (skin.getIsControlPanel() == true) {
- if (skin.controlPanel != null) {
- skin.controlPanel.getShell().close();
+ if (skin.keyWindow != null) {
+ skin.keyWindow.getShell().close();
}
skin.setIsControlPanel(false);
skin.openKeyWindow(SWT.RIGHT | SWT.CENTER);
/* move a key window to right of the emulator window */
- if (skin.controlPanel != null) {
- skin.controlPanel.setShellPosition(
+ if (skin.keyWindow != null) {
+ skin.keyWindow.dock(
SWT.RIGHT | SWT.CENTER, true, false);
}
}
e.gc.drawImage(currentState.getCurrentImage(), 0, 0);
}
- if (skin.controlPanel != null &&
- skin.controlPanel.isAttach() != SWT.NONE) {
- skin.controlPanel.setShellPosition(
- skin.controlPanel.isAttach(), false, false);
+ if (skin.keyWindow != null &&
+ skin.keyWindow.getDockPosition() != SWT.NONE) {
+ skin.keyWindow.dock(
+ skin.keyWindow.getDockPosition(), false, false);
}
}
};
shell.setLocation(x, y);
- if (skin.controlPanel != null &&
- skin.controlPanel.isAttach() != SWT.NONE) {
- skin.controlPanel.setShellPosition(
- skin.controlPanel.isAttach(), false, false);
+ if (skin.keyWindow != null &&
+ skin.keyWindow.getDockPosition() != SWT.NONE) {
+ skin.keyWindow.dock(
+ skin.keyWindow.getDockPosition(), false, false);
}
}
}
isGrabbedShell = false;
grabPosition.x = grabPosition.y = 0;
- if (skin.controlPanel != null &&
- skin.controlPanel.isAttach() != SWT.NONE) {
- skin.controlPanel.setShellPosition(
- skin.controlPanel.isAttach(), false, true);
+ if (skin.keyWindow != null &&
+ skin.keyWindow.getDockPosition() != SWT.NONE) {
+ skin.keyWindow.dock(
+ skin.keyWindow.getDockPosition(), false, true);
}
}
}
30, heightOneThird);
if (childBounds.intersects(attachBounds1) == true) {
- setShellPosition(SWT.RIGHT | SWT.CENTER, false, true);
- isAttach = SWT.RIGHT | SWT.CENTER;
+ dock(SWT.RIGHT | SWT.CENTER, false, true);
} else if (childBounds.intersects(attachBounds2) == true) {
- setShellPosition(SWT.RIGHT | SWT.TOP, false, true);
- isAttach = SWT.RIGHT | SWT.TOP;
+ dock(SWT.RIGHT | SWT.TOP, false, true);
} else if (childBounds.intersects(attachBounds3) == true) {
- setShellPosition(SWT.RIGHT | SWT.BOTTOM, false, true);
- isAttach = SWT.RIGHT | SWT.BOTTOM;
+ dock(SWT.RIGHT | SWT.BOTTOM, false, true);
} else {
- isAttach = SWT.NONE;
+ dock(SWT.NONE, false, true);
}
}
}
skin.pairTagCanvas.setVisible(false);
}
skin.setIsControlPanel(false);
- skin.controlPanel = null;
+ skin.keyWindow = null;
if (null != shellPaintListener) {
shell.removePaintListener(shellPaintListener);
protected Shell shell;
protected Shell parent;
- private int shellPositionType;
- protected int isAttach;
+ private int dockPosition;
- public SkinWindow(Shell parent, int shellPositionType) {
+ public SkinWindow(Shell parent, int dockPosition) {
this.parent = parent;
- this.shellPositionType = shellPositionType;
- this.isAttach = SWT.NONE;
+ this.dockPosition = dockPosition;
}
public Shell getShell() {
return shell;
}
- public void open() {
+ public void open(int dockValue) {
if (shell.isDisposed()) {
return;
}
- setShellPosition(shellPositionType, true, true);
- isAttach = SWT.RIGHT | SWT.CENTER;
+ dock(dockValue, true, true);
shell.open();
}
}
- public void setShellPosition(int shellPositionType,
+ public void dock(int dockValue,
boolean correction, boolean enableLogger) {
int x = 0;
int y = 0;
logger.info("current child shell bounds : " + childBounds);
}
- if (shellPositionType == (SWT.RIGHT | SWT.TOP)) {
+ dockPosition = dockValue;
+
+ if (dockPosition == SWT.NONE){
+ logger.info("undock");
+ /* do nothing */
+
+ return;
+ } else if (dockPosition == (SWT.RIGHT | SWT.TOP)) {
x = parentBounds.x + parentBounds.width;
y = parentBounds.y;
/* correction of location */
-// if ((x + childBounds.width) >
-// (monitorBounds.x + monitorBounds.width)) {
-// x = parentBounds.x - childBounds.width;
-// }
- } else if (shellPositionType == (SWT.RIGHT | SWT.BOTTOM)) {
+ /*if ((x + childBounds.width) >
+ (monitorBounds.x + monitorBounds.width)) {
+ x = parentBounds.x - childBounds.width;
+ }*/
+ } else if (dockPosition == (SWT.RIGHT | SWT.BOTTOM)) {
x = parentBounds.x + parentBounds.width;
y = parentBounds.y + parentBounds.height - childBounds.height;
/* correction of location */
-// int shift = (monitorBounds.x + monitorBounds.width) -
-// (x + childBounds.width);
-// if (shift < 0) {
-// x += shift;
-// parent.setLocation(parentBounds.x + shift, parentBounds.y);
-// }
+ /*int shift = (monitorBounds.x + monitorBounds.width) -
+ (x + childBounds.width);
+ if (shift < 0) {
+ x += shift;
+ parent.setLocation(parentBounds.x + shift, parentBounds.y);
+ }*/
} else { /* SWT.RIGHT | SWT.CENTER */
x = parentBounds.x + parentBounds.width;
y = parentBounds.y + (parentBounds.height / 2) -
shell.setLocation(x, y);
}
- public void setAttach(int attach) {
- isAttach = attach;
- }
-
- public int isAttach() {
- return isAttach;
+ public int getDockPosition() {
+ return dockPosition;
}
}