padysrini
unread,Dec 12, 2008, 9:02:38 PM12/12/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to gwt-datepicker
if anybody is interested...
Since I wanted the popup location to locate itself wherever space is
available based on the location of my datepicker field, I added this
code ( just incase anybody is interested...this code can be used for
any popup...just make sure show() is called before
setPopupPosition... ).
public void doAfterShowPopup(PopupCalendar popup) {
Point pt = getPopupLocation(this, popup.getOffsetWidth(),
popup.getOffsetHeight());
popup.setPopupPosition(pt.x, pt.y);
}
public static class Point {
public int x;
public int y;
}
public static Point getPopupLocation(Widget w, int offsetWidth,
int offsetHeight) {
int left = w.getAbsoluteLeft();
int top = w.getAbsoluteTop() + w.getOffsetHeight();
int availableRightWidth = Window.getClientWidth() -
w.getAbsoluteLeft()
+ w.getOffsetWidth();
int availableBottomHeight = Window.getClientHeight() -
w.getAbsoluteTop()
+ w.getOffsetHeight();
boolean availRight = availableRightWidth > offsetWidth;
boolean availLeft = w.getAbsoluteLeft() > offsetWidth;
boolean availBot = availableBottomHeight > offsetHeight;
boolean availTop = w.getAbsoluteTop() > offsetHeight;
Point p = new Point();
if ( availRight & availBot ) {
p.x = left; p.y = top;
}
else if ( availRight & availTop ) {
p.x = left+w.getOffsetWidth(); p.y = top-offsetHeight;
}
else if ( availLeft & availBot ) {
p.x = left+w.getOffsetWidth()-offsetWidth; p.y = top;
}
else if ( availLeft & availTop ) {
p.x = left-offsetWidth; p.y = top-offsetHeight;
}
return p;
}
Thx
-- pady