Browse Source

Window close and position management

svn changeset:843/svn branch:trunk
tags/6.7.0.beta1
Joonas Lehtinen 17 years ago
parent
commit
22d3109b72
1 changed files with 68 additions and 1 deletions
  1. 68
    1
      src/com/itmill/toolkit/ui/Window.java

+ 68
- 1
src/com/itmill/toolkit/ui/Window.java View File



/** Focused component */ /** Focused component */
private Focusable focusedComponent; private Focusable focusedComponent;
/** Distance of Window top border in pixels from top border of the containing (main window) or -1 if unspecified */
private int positionY = -1;

/** Distance of Window left border in pixels from left border of the containing (main window) or -1 if unspecified */
private int positionX = -1;



/* ********************************************************************* */ /* ********************************************************************* */


// Contents of the window panel is painted // Contents of the window panel is painted
super.paintContent(target); super.paintContent(target);


// Window position
target.addVariable(this, "positionx", getPositionX());
target.addVariable(this, "positiony", getPositionY());
// Window closing
target.addVariable(this, "close", false);

// Set focused component // Set focused component
if (this.focusedComponent != null) if (this.focusedComponent != null)
target.addVariable(this, "focused", "" target.addVariable(this, "focused", ""
// We ignore invalid focusable ids // We ignore invalid focusable ids
} }
} }

// Positioning
Integer positionx = (Integer) variables.get("positionx");
if (positionx != null) {
int x = positionx.intValue();
setPositionX(x<0?-1:x);
}
Integer positiony = (Integer) variables.get("positiony");
if (positiony != null) {
int y = positiony.intValue();
setPositionY(y<0?-1:y);
}
// Closing
Boolean close = (Boolean) variables.get("close");
if (close != null && close.booleanValue()) {
// TODO We should also throw an event to listeners
this.setVisible(false);
}
} }


/** /**
ref.clear(); ref.clear();
focusableComponents.remove(id); focusableComponents.remove(id);
} }

/** Get the distance of Window left border in pixels from left border of the containing (main window).
* @return Distance of Window left border in pixels from left border of the containing (main window). or -1 if unspecified.
* @since 4.0.0
*/
public int getPositionX() {
return positionX;
}

/** Set the distance of Window left border in pixels from left border of the containing (main window).
* @param positionX Distance of Window left border in pixels from left border of the containing (main window). or -1 if unspecified
* @since 4.0.0
*/
public void setPositionX(int positionX) {
this.positionX = positionX;
}

/** Get the distance of Window top border in pixels from top border of the containing (main window).
* @return Distance of Window top border in pixels from top border of the containing (main window). or -1 if unspecified
*
* @since 4.0.0
*/
public int getPositionY() {
return positionY;
}

/** Set the distance of Window top border in pixels from top border of the containing (main window).
* @param positionY of Window top border in pixels from top border of the containing (main window). or -1 if unspecified
*
* @since 4.0.0
*/
public void setPositionY(int positionY) {
this.positionY = positionY;
}
} }

Loading…
Cancel
Save