You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VPaintableLayoutSlot.java 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.terminal.gwt.client.ui.layout;
  5. import com.vaadin.terminal.gwt.client.LayoutManager;
  6. import com.vaadin.terminal.gwt.client.VCaption;
  7. import com.vaadin.terminal.gwt.client.ComponentConnector;
  8. import com.vaadin.terminal.gwt.client.ui.ManagedLayout;
  9. public class VPaintableLayoutSlot extends VLayoutSlot {
  10. final ComponentConnector paintable;
  11. private LayoutManager layoutManager;
  12. public VPaintableLayoutSlot(String baseClassName, ComponentConnector paintable) {
  13. super(baseClassName, paintable.getWidget());
  14. this.paintable = paintable;
  15. layoutManager = paintable.getLayoutManager();
  16. }
  17. public ComponentConnector getPaintable() {
  18. return paintable;
  19. }
  20. @Override
  21. protected int getCaptionHeight() {
  22. VCaption caption = getCaption();
  23. return caption != null ? layoutManager.getOuterHeight(caption
  24. .getElement()) : 0;
  25. }
  26. @Override
  27. protected int getCaptionWidth() {
  28. VCaption caption = getCaption();
  29. return caption != null ? layoutManager.getOuterWidth(caption
  30. .getElement()) : 0;
  31. }
  32. @Override
  33. public void setCaption(VCaption caption) {
  34. VCaption oldCaption = getCaption();
  35. if (oldCaption != null) {
  36. layoutManager.unregisterDependency(
  37. (ManagedLayout) paintable.getParent(),
  38. oldCaption.getElement());
  39. }
  40. super.setCaption(caption);
  41. if (caption != null) {
  42. layoutManager
  43. .registerDependency((ManagedLayout) paintable.getParent(),
  44. caption.getElement());
  45. }
  46. }
  47. @Override
  48. public int getWidgetHeight() {
  49. return layoutManager.getOuterHeight(paintable.getWidget()
  50. .getElement());
  51. }
  52. @Override
  53. public int getWidgetWidth() {
  54. return layoutManager.getOuterWidth(paintable.getWidget()
  55. .getElement());
  56. }
  57. @Override
  58. public boolean isUndefinedHeight() {
  59. return paintable.isUndefinedHeight();
  60. }
  61. @Override
  62. public boolean isUndefinedWidth() {
  63. return paintable.isUndefinedWidth();
  64. }
  65. @Override
  66. public boolean isRelativeHeight() {
  67. return paintable.isRelativeHeight();
  68. }
  69. @Override
  70. public boolean isRelativeWidth() {
  71. return paintable.isRelativeWidth();
  72. }
  73. }