From 4715a1d53f04d1fa9c34fa682157bdd3ac6ab369 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Risto=20Yrj=C3=A4n=C3=A4?= Date: Wed, 12 Nov 2008 12:14:48 +0000 Subject: [PATCH] Fixed problems with the new layouts not showing svn changeset:5877/svn branch:trunk --- .../terminal/gwt/client/ui/IPopupView.java | 91 +++++++++++++------ src/com/itmill/toolkit/ui/PopupView.java | 6 +- 2 files changed, 64 insertions(+), 33 deletions(-) diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupView.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupView.java index be18720328..633dc82a81 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupView.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupView.java @@ -74,6 +74,7 @@ public class IPopupView extends HTML implements Paintable { }); popup.setAnimationEnabled(true); + } /** @@ -106,8 +107,10 @@ public class IPopupView extends HTML implements Paintable { if (hostPopupVisible) { UIDL popupUIDL = uidl.getChildUIDL(0); + // showPopupOnTop(popup, hostReference); + preparePopup(popup, hostReference); popup.updateFromUIDL(popupUIDL, client); - showPopupOnTop(popup, hostReference); + showPopup(popup, hostReference); // The popup isn't visible so we should remove its child. The popup // handles hiding so we don't need to hide it here. @@ -128,6 +131,37 @@ public class IPopupView extends HTML implements Paintable { } } + private void preparePopup(final CustomPopup popup, final Widget host) { + popup.setVisible(false); + popup.show(); + } + + private void showPopup(final CustomPopup popup, final Widget host) { + int offsetWidth = popup.getOffsetWidth(); + int offsetHeight = popup.getOffsetHeight(); + + int hostHorizontalCenter = host.getAbsoluteLeft() + + host.getOffsetWidth() / 2; + int hostVerticalCenter = host.getAbsoluteTop() + host.getOffsetHeight() + / 2; + + int left = hostHorizontalCenter - offsetWidth / 2; + int top = hostVerticalCenter - offsetHeight / 2; + + // Superclass takes care of top and left + if ((left + offsetWidth) > windowRight) { + left -= (left + offsetWidth) - windowRight; + } + + if ((top + offsetHeight) > windowBottom) { + top -= (top + offsetHeight) - windowBottom; + } + + popup.setPopupPosition(left, top); + + setVisible(true); + } + /** * This shows the popup on top of the widget below. This function allows us * to position the popup before making it visible. @@ -137,31 +171,30 @@ public class IPopupView extends HTML implements Paintable { * @param host * the widget to draw the popup on */ - private void showPopupOnTop(final CustomPopup popup, final Widget host) { - popup.setPopupPositionAndShow(new PopupPanel.PositionCallback() { - public void setPosition(int offsetWidth, int offsetHeight) { - int hostHorizontalCenter = host.getAbsoluteLeft() - + host.getOffsetWidth() / 2; - int hostVerticalCenter = host.getAbsoluteTop() - + host.getOffsetHeight() / 2; - - int left = hostHorizontalCenter - offsetWidth / 2; - int top = hostVerticalCenter - offsetHeight / 2; - - // Superclass takes care of top and left - if ((left + offsetWidth) > windowRight) { - left -= (left + offsetWidth) - windowRight; - } - - if ((top + offsetHeight) > windowBottom) { - top -= (top + offsetHeight) - windowBottom; - } - - popup.setPopupPosition(left, top); - } - }); - } - + // private void showPopupOnTop(final CustomPopup popup, final Widget host) { + // popup.setPopupPositionAndShow(new PopupPanel.PositionCallback() { + // public void setPosition(int offsetWidth, int offsetHeight) { + // int hostHorizontalCenter = host.getAbsoluteLeft() + // + host.getOffsetWidth() / 2; + // int hostVerticalCenter = host.getAbsoluteTop() + // + host.getOffsetHeight() / 2; + // + // int left = hostHorizontalCenter - offsetWidth / 2; + // int top = hostVerticalCenter - offsetHeight / 2; + // + // // Superclass takes care of top and left + // if ((left + offsetWidth) > windowRight) { + // left -= (left + offsetWidth) - windowRight; + // } + // + // if ((top + offsetHeight) > windowBottom) { + // top -= (top + offsetHeight) - windowBottom; + // } + // + // popup.setPopupPosition(left, top); + // } + // }); + // } public void updateWindowSize() { windowTop = RootPanel.get().getAbsoluteTop(); windowLeft = RootPanel.get().getAbsoluteLeft(); @@ -313,13 +346,11 @@ public class IPopupView extends HTML implements Paintable { } public boolean requestLayout(Set child) { - // TODO Auto-generated method stub - return false; + return true; } public RenderSpace getAllocatedSpace(Widget child) { - // TODO Auto-generated method stub - return null; + return new RenderSpace(windowRight, windowBottom); } }// class CustomPopup diff --git a/src/com/itmill/toolkit/ui/PopupView.java b/src/com/itmill/toolkit/ui/PopupView.java index 252e137c21..0eb4049c86 100644 --- a/src/com/itmill/toolkit/ui/PopupView.java +++ b/src/com/itmill/toolkit/ui/PopupView.java @@ -9,7 +9,7 @@ import com.itmill.toolkit.terminal.PaintTarget; /** * - * A component for displaying a two different views to data. The minmized view + * A component for displaying a two different views to data. The minimized view * is normally used to render the component, and when it is clicked the full * view is displayed on a popup. The inner class {@link PopupView.Content} is * used to deliver contents to this component. @@ -56,9 +56,9 @@ public class PopupView extends AbstractComponentContainer { */ public PopupView(PopupView.Content content) { super(); - setContent(content); popupVisible = false; componentList = new ArrayList(1); + setContent(content); } /** @@ -111,7 +111,7 @@ public class PopupView extends AbstractComponentContainer { * * @see com.itmill.toolkit.ui.ComponentContainer#getComponentIterator() */ - public Iterator getComponentIterator() { + public Iterator getComponentIterator() { return componentList.iterator(); } -- 2.39.5