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.

Layout.java 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. * Copyright 2000-2018 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.ui;
  17. import java.io.Serializable;
  18. import com.vaadin.shared.ui.MarginInfo;
  19. /**
  20. * Extension to the {@link ComponentContainer} interface which adds the
  21. * layouting control to the elements in the container. This is required by the
  22. * various layout components to enable them to place other components in
  23. * specific locations in the UI.
  24. *
  25. * @author Vaadin Ltd.
  26. * @since 3.0
  27. */
  28. public interface Layout extends ComponentContainer {
  29. /**
  30. * AlignmentHandler is most commonly an advanced {@link Layout} that can
  31. * align its components.
  32. */
  33. public interface AlignmentHandler extends Serializable {
  34. /**
  35. * Set alignment for one contained component in this layout. Use
  36. * predefined alignments from Alignment class.
  37. *
  38. * Example: <code>
  39. * layout.setComponentAlignment(myComponent, Alignment.TOP_RIGHT);
  40. * </code>
  41. *
  42. * @param childComponent
  43. * the component to align within it's layout cell.
  44. * @param alignment
  45. * the Alignment value to be set
  46. */
  47. public void setComponentAlignment(Component childComponent,
  48. Alignment alignment);
  49. /**
  50. * Returns the current Alignment of given component.
  51. *
  52. * @param childComponent
  53. * @return the {@link Alignment}
  54. */
  55. public Alignment getComponentAlignment(Component childComponent);
  56. /**
  57. * Sets the alignment used for new components added to this layout. The
  58. * default is {@link Alignment#TOP_LEFT}.
  59. *
  60. * @param defaultComponentAlignment
  61. * The new default alignment
  62. */
  63. public void setDefaultComponentAlignment(
  64. Alignment defaultComponentAlignment);
  65. /**
  66. * Returns the alignment used for new components added to this layout.
  67. *
  68. * @return The default alignment
  69. */
  70. public Alignment getDefaultComponentAlignment();
  71. }
  72. /**
  73. * This type of layout supports automatic addition of space between its
  74. * components.
  75. *
  76. */
  77. public interface SpacingHandler extends Serializable {
  78. /**
  79. * Enable spacing between child components within this layout.
  80. *
  81. * <p>
  82. * <strong>NOTE:</strong> This will only affect the space between
  83. * components, not the space around all the components in the layout
  84. * (i.e. do not confuse this with the cellspacing attribute of a HTML
  85. * Table). Use {@link MarginHandler#setMargin(boolean)} to add space
  86. * around the layout.
  87. * </p>
  88. *
  89. * <p>
  90. * See the reference manual for more information about CSS rules for
  91. * defining the amount of spacing to use.
  92. * </p>
  93. *
  94. * @param enabled
  95. * true if spacing should be turned on, false if it should be
  96. * turned off
  97. */
  98. public void setSpacing(boolean enabled);
  99. /**
  100. *
  101. * @return true if spacing between child components within this layout
  102. * is enabled, false otherwise
  103. */
  104. public boolean isSpacing();
  105. }
  106. /**
  107. * This type of layout supports automatic addition of margins (space around
  108. * its components).
  109. */
  110. public interface MarginHandler extends Serializable {
  111. /**
  112. * Enable layout margins. Affects all four sides of the layout. This
  113. * will tell the client-side implementation to leave extra space around
  114. * the layout. The client-side implementation decides the actual amount,
  115. * and it can vary between themes.
  116. *
  117. * @param enabled
  118. * true if margins should be enabled on all sides, false to
  119. * disable all margins
  120. */
  121. public void setMargin(boolean enabled);
  122. /**
  123. * Enable margins for this layout.
  124. *
  125. * <p>
  126. * <strong>NOTE:</strong> This will only affect the space around the
  127. * components in the layout, not space between the components in the
  128. * layout. Use {@link SpacingHandler#setSpacing(boolean)} to add space
  129. * between the components in the layout.
  130. * </p>
  131. *
  132. * <p>
  133. * See the reference manual for more information about CSS rules for
  134. * defining the size of the margin.
  135. * </p>
  136. *
  137. * @param marginInfo
  138. * MarginInfo object containing the new margins.
  139. */
  140. public void setMargin(MarginInfo marginInfo);
  141. /**
  142. *
  143. * @return MarginInfo containing the currently enabled margins.
  144. */
  145. public MarginInfo getMargin();
  146. }
  147. }