Subversion Repository Public Repository

litesoft

Diff Revisions 949 vs 950 for /trunk/Java/GWT/Client/src/org/litesoft/GWT/client/widgets/nonpublic/AbstractSizableSimplePanel.java

Diff revisions: vs.
  @@ -1,244 +1,244 @@
1 - // This Source Code is in the Public Domain per: http://unlicense.org
2 - package org.litesoft.GWT.client.widgets.nonpublic;
3 -
4 - import org.litesoft.GWT.client.widgets.*;
5 - import org.litesoft.render.*;
6 - import org.litesoft.uispecification.*;
7 -
8 - import com.google.gwt.user.client.*;
9 - import com.google.gwt.user.client.ui.*;
10 -
11 - public abstract class AbstractSizableSimplePanel extends SimplePanel implements RenderableContainer,
12 - GwtRenderableRect,
13 - SingleWidgetContainer {
14 - private Element mStyleElement;
15 - private Element mContainerElement;
16 -
17 - private AbstractSizableSimplePanel( DIVconstrainer pDIVconstrainer, StyleSet pStyleSet, RenderContainmentApproach pContainmentApproachX,
18 - RenderContainmentApproach pContainmentApproachY ) {
19 - super( pDIVconstrainer.getOuterElement() );
20 - StyleContainerElements zSCEs = ContainerSupport.createSCEs( pDIVconstrainer.getInnerElement(), pStyleSet );
21 - mStyleElement = zSCEs.getStyleElement();
22 - Element zContainerParentElement = zSCEs.getContainerParentElement();
23 -
24 - pContainmentApproachX = RenderContainmentApproach.deNull( pContainmentApproachX );
25 - pContainmentApproachY = RenderContainmentApproach.deNull( pContainmentApproachY );
26 -
27 - Overflow zCombinedOverflow = ContainerSupport.getAppropriateCombinedOverflow( pContainmentApproachX, pContainmentApproachY );
28 - if ( zCombinedOverflow.isScrolledOrClipped() ) {
29 - mContainerElement = CommonElementHelper.appendToParent( DOM.createDiv(), zContainerParentElement );
30 - String zOverflowClass = CommonElementHelper.determineOverflowClass( zCombinedOverflow.isClipped() );
31 - CommonElementHelper.setStyleClass( mContainerElement, zOverflowClass );
32 - } else if ( zSCEs.hasStyleElement() ) {
33 - mContainerElement = CommonElementHelper.appendToParent( DOM.createDiv(), zContainerParentElement );
34 - } else {
35 - mContainerElement = zContainerParentElement; // Not Stylable & Overflow == _None
36 - }
37 -
38 - mRenderHelperX = new Gwt1dContainerRenderHelperX( this, pContainmentApproachX, RenderContainerChildrenPolicy.Propogate ) {
39 - @Override
40 - protected Object[] getChildObjects() {
41 - return getChildren();
42 - }
43 - };
44 - mRenderHelperY = new Gwt1dContainerRenderHelperY( this, pContainmentApproachY, RenderContainerChildrenPolicy.Propogate ) {
45 - @Override
46 - protected Object[] getChildObjects() {
47 - return getChildren();
48 - }
49 - };
50 - }
51 -
52 - protected AbstractSizableSimplePanel( StyleSet pStyleSet, RenderContainmentApproach pContainmentApproachX, RenderContainmentApproach pContainmentApproachY ) {
53 - this( CommonElementHelper.createDIVconstrainer(), pStyleSet, pContainmentApproachX, pContainmentApproachY );
54 - }
55 -
56 - protected AbstractSizableSimplePanel( StyleSet pStyleSet, RCApair pRCApair ) {
57 - this( pStyleSet, RCApair.deNull( pRCApair ).getRCA_X(), RCApair.deNull( pRCApair ).getRCA_Y() );
58 - }
59 -
60 - protected AbstractSizableSimplePanel( StyleSet pStyleSet, RenderContainmentApproach pContainmentApproach ) {
61 - this( pStyleSet, pContainmentApproach, pContainmentApproach );
62 - }
63 -
64 - protected final RenderContainerHelper mRenderHelperX;
65 - protected final RenderContainerHelper mRenderHelperY;
66 -
67 - private Widget[] getChildren() {
68 - Widget zWidget = getWidget();
69 - return (zWidget == null) ? NO_WIDGETS : new Widget[]{zWidget};
70 - }
71 -
72 - @Override
73 - protected Element getStyleElement() {
74 - return mStyleElement;
75 - }
76 -
77 - @Override
78 - protected Element getContainerElement() {
79 - return mContainerElement;
80 - }
81 -
82 - /**
83 - * This method is called to attach a widget browser's document (if there are any child widgets they are
84 - * also attached AFTER the attached flag is set).
85 - * <p/>
86 - * This method is normally overiden, and after a call to super, "renderingParticipationChanged()" is notified.
87 - *
88 - * @see Widget#onAttach()
89 - */
90 - @Override
91 - public void onAttach() {
92 - super.onAttach();
93 - renderingParticipationChanged();
94 - }
95 -
96 - /**
97 - * This method is called to detach the widget from the browser's document (if there are any child widgets
98 - * they are deattached BEFORE the attached flag is set).
99 - * <p/>
100 - * This method is normally overiden, and after a call to super, "renderingParticipationChanged()" is notified.
101 - *
102 - * @see Widget#onDetach()
103 - */
104 - @Override
105 - public void onDetach() {
106 - super.onDetach();
107 - renderingParticipationChanged();
108 - }
109 -
110 - /**
111 - * Sets whether this object is visible - normally overiden from "UIObject" so that "renderingParticipationChanged()" can be notified.
112 - *
113 - * @param pVisible <code>true</code> to show the object, <code>false</code>
114 - * to hide it
115 - */
116 - @Override
117 - public void setVisible( boolean pVisible ) {
118 - if ( isVisible() != pVisible ) {
119 - super.setVisible( pVisible );
120 - renderingParticipationChanged();
121 - }
122 - }
123 -
124 - /**
125 - * Sets the widget's width, overiding the method in "UIObject". Unlike the standard GWT "UIObject" method, the
126 - * pWidth is "assumed" to include ALL decorations (such as border, margin, and padding). This means that a
127 - * subsequent call to "getOffsetWidth()" will "eventually" return the value "set"!
128 - * <p/>
129 - * This method is normally delegated to the 'X' RenderHelper
130 - *
131 - * @param pWidth the Widget's new width, in CSS px (e.g. "10")
132 - */
133 - @Override
134 - public void setWidth( String pWidth ) {
135 - Parse.andSetSize( getRenderHelperX(), pWidth );
136 - }
137 -
138 - /**
139 - * Sets the widget's width, unlike the standard GWT "UIObject" method, this pWidth is "assumed" to include ALL
140 - * decorations (such as border, margin, and padding). This means that a subsequent call to "getOffsetWidth()"
141 - * will "eventually" return the value "set"!
142 - * <p/>
143 - * This method is used by the 'X' RenderHelper via the GwtRenderDimensionAdapterX to bypass the normal delegation
144 - * on "setWidth()" to the 'X' RenderHelper.
145 - *
146 - * @param pWidth the Widget's new width, in CSS px (e.g. "10")
147 - */
148 - @Override
149 - public void LLsetWidgetWidth( int pWidth ) {
150 - Size.set( this, GwtElementDimensionHelperX.INSTANCE, getContainerElement(), pWidth, getDecorationSizeX() );
151 - }
152 -
153 - /**
154 - * Remove the Widget's width, after this call subsequent calls to "getOffsetWidth()" will "eventually" return the
155 - * "natural" width of the Widget!
156 - */
157 - @Override
158 - public void clearWidth() {
159 - Size.clear( this, GwtElementDimensionHelperX.INSTANCE, getContainerElement() );
160 - }
161 -
162 - /**
163 - * Sets the widget's height, overiding the method in "UIObject". Unlike the standard GWT "UIObject" method, this
164 - * pHeight is "assumed" to include ALL decorations (such as border, margin, and padding). This means that a
165 - * subsequent call to "getOffsetHeight()" will "eventually" return the value "set"!
166 - * <p/>
167 - * This method is normally delegated to the 'Y' RenderHelper
168 - *
169 - * @param pHeight the Widget's new height, in CSS px (e.g. "10")
170 - */
171 - @Override
172 - public void setHeight( String pHeight ) {
173 - Parse.andSetSize( getRenderHelperY(), pHeight );
174 - }
175 -
176 - /**
177 - * Sets the widget's height, unlike the standard GWT "UIObject" method, this pHeight is "assumed" to include ALL
178 - * decorations (such as border, margin, and padding). This means that a subsequent call to "getOffsetHeight()"
179 - * will "eventually" return the value "set"!
180 - * <p/>
181 - * This method is used by the 'Y' RenderHelper via the GwtRenderDimensionAdapterY to bypass the normal delegation
182 - * on "setHeight()" to the 'Y' RenderHelper.
183 - *
184 - * @param pHeight the Widget's new height, in CSS px (e.g. "10")
185 - */
186 - @Override
187 - public void LLsetWidgetHeight( int pHeight ) {
188 - Size.set( this, GwtElementDimensionHelperY.INSTANCE, getContainerElement(), pHeight, getDecorationSizeY() );
189 - }
190 -
191 - /**
192 - * Remove the Widget's height, after this call subsequent calls to "getOffsetHeight()" will "eventually" return the
193 - * "natural" height of the Widget!
194 - */
195 - @Override
196 - public void clearHeight() {
197 - Size.clear( this, GwtElementDimensionHelperY.INSTANCE, getContainerElement() );
198 - }
199 -
200 - @Override
201 - public void renderingParticipationChanged() {
202 - RenderingParticipationChangedHelper.participationChanged( this, getWidget() );
203 - }
204 -
205 - @Override
206 - public RenderHelper getRenderHelperX() {
207 - return mRenderHelperX;
208 - }
209 -
210 - @Override
211 - public RenderHelper getRenderHelperY() {
212 - return mRenderHelperY;
213 - }
214 -
215 - /**
216 - * Get a Container's Decoration (or Overhead) Size in the 'X' dimension - the difference between the outside size and the inside size (what is available
217 - * for child widgets)
218 - * <p/>
219 - * Note: this will NOT be called until the Container is reporting proper sizes!
220 - */
221 - @Override
222 - public int getDecorationSizeX() {
223 - return DecorationSize.calculate( this, GwtElementDimensionHelperX.INSTANCE, //
224 - getElement(), getContainerElement() );
225 - }
226 -
227 - /**
228 - * Get a Container's Decoration (or Overhead) Size in the 'Y' dimension - the difference between the outside size and the inside size (what is available
229 - * for child widgets)
230 - * <p/>
231 - * Note: this will NOT be called until the Container is reporting proper sizes!
232 - */
233 - @Override
234 - public int getDecorationSizeY() {
235 - return DecorationSize.calculate( this, GwtElementDimensionHelperY.INSTANCE, //
236 - getElement(), getContainerElement() );
237 - }
238 -
239 - @Override
240 - public void relayout() {
241 - getRenderHelperX().layout();
242 - getRenderHelperY().layout();
243 - }
244 - }
1 + // This Source Code is in the Public Domain per: http://unlicense.org
2 + package org.litesoft.GWT.client.widgets.nonpublic;
3 +
4 + import org.litesoft.GWT.client.widgets.*;
5 + import org.litesoft.render.*;
6 + import org.litesoft.uispecification.*;
7 +
8 + import com.google.gwt.user.client.*;
9 + import com.google.gwt.user.client.ui.*;
10 +
11 + public abstract class AbstractSizableSimplePanel extends SimplePanel implements RenderableContainer,
12 + GwtRenderableRect,
13 + SingleWidgetContainer {
14 + private Element mStyleElement;
15 + private Element mContainerElement;
16 +
17 + private AbstractSizableSimplePanel( DIVconstrainer pDIVconstrainer, StyleSet pStyleSet, RenderContainmentApproach pContainmentApproachX,
18 + RenderContainmentApproach pContainmentApproachY ) {
19 + super( pDIVconstrainer.getOuterElement() );
20 + StyleContainerElements zSCEs = ContainerSupport.createSCEs( pDIVconstrainer.getInnerElement(), pStyleSet );
21 + mStyleElement = zSCEs.getStyleElement();
22 + Element zContainerParentElement = zSCEs.getContainerParentElement();
23 +
24 + pContainmentApproachX = RenderContainmentApproach.deNull( pContainmentApproachX );
25 + pContainmentApproachY = RenderContainmentApproach.deNull( pContainmentApproachY );
26 +
27 + Overflow zCombinedOverflow = ContainerSupport.getAppropriateCombinedOverflow( pContainmentApproachX, pContainmentApproachY );
28 + if ( zCombinedOverflow.isScrolledOrClipped() ) {
29 + mContainerElement = CommonElementHelper.appendToParent( DOM.createDiv(), zContainerParentElement );
30 + String zOverflowClass = CommonElementHelper.determineOverflowClass( zCombinedOverflow.isClipped() );
31 + CommonElementHelper.setStyleClass( mContainerElement, zOverflowClass );
32 + } else if ( zSCEs.hasStyleElement() ) {
33 + mContainerElement = CommonElementHelper.appendToParent( DOM.createDiv(), zContainerParentElement );
34 + } else {
35 + mContainerElement = zContainerParentElement; // Not Stylable & Overflow == _None
36 + }
37 +
38 + mRenderHelperX = new Gwt1dContainerRenderHelperX( this, pContainmentApproachX, RenderContainerChildrenPolicy.Propogate ) {
39 + @Override
40 + protected Object[] getChildObjects() {
41 + return getChildren();
42 + }
43 + };
44 + mRenderHelperY = new Gwt1dContainerRenderHelperY( this, pContainmentApproachY, RenderContainerChildrenPolicy.Propogate ) {
45 + @Override
46 + protected Object[] getChildObjects() {
47 + return getChildren();
48 + }
49 + };
50 + }
51 +
52 + protected AbstractSizableSimplePanel( StyleSet pStyleSet, RenderContainmentApproach pContainmentApproachX, RenderContainmentApproach pContainmentApproachY ) {
53 + this( CommonElementHelper.createDIVconstrainer(), pStyleSet, pContainmentApproachX, pContainmentApproachY );
54 + }
55 +
56 + protected AbstractSizableSimplePanel( StyleSet pStyleSet, RCApair pRCApair ) {
57 + this( pStyleSet, RCApair.deNull( pRCApair ).getRCA_X(), RCApair.deNull( pRCApair ).getRCA_Y() );
58 + }
59 +
60 + protected AbstractSizableSimplePanel( StyleSet pStyleSet, RenderContainmentApproach pContainmentApproach ) {
61 + this( pStyleSet, pContainmentApproach, pContainmentApproach );
62 + }
63 +
64 + protected final RenderContainerHelper mRenderHelperX;
65 + protected final RenderContainerHelper mRenderHelperY;
66 +
67 + private Widget[] getChildren() {
68 + Widget zWidget = getWidget();
69 + return (zWidget == null) ? NO_WIDGETS : new Widget[]{zWidget};
70 + }
71 +
72 + @Override
73 + protected Element getStyleElement() {
74 + return mStyleElement;
75 + }
76 +
77 + @Override
78 + protected Element getContainerElement() {
79 + return mContainerElement;
80 + }
81 +
82 + /**
83 + * This method is called to attach a widget browser's document (if there are any child widgets they are
84 + * also attached AFTER the attached flag is set).
85 + * <p/>
86 + * This method is normally overiden, and after a call to super, "renderingParticipationChanged()" is notified.
87 + *
88 + * @see Widget#onAttach()
89 + */
90 + @Override
91 + public void onAttach() {
92 + super.onAttach();
93 + renderingParticipationChanged();
94 + }
95 +
96 + /**
97 + * This method is called to detach the widget from the browser's document (if there are any child widgets
98 + * they are deattached BEFORE the attached flag is set).
99 + * <p/>
100 + * This method is normally overiden, and after a call to super, "renderingParticipationChanged()" is notified.
101 + *
102 + * @see Widget#onDetach()
103 + */
104 + @Override
105 + public void onDetach() {
106 + super.onDetach();
107 + renderingParticipationChanged();
108 + }
109 +
110 + /**
111 + * Sets whether this object is visible - normally overiden from "UIObject" so that "renderingParticipationChanged()" can be notified.
112 + *
113 + * @param pVisible <code>true</code> to show the object, <code>false</code>
114 + * to hide it
115 + */
116 + @Override
117 + public void setVisible( boolean pVisible ) {
118 + if ( isVisible() != pVisible ) {
119 + super.setVisible( pVisible );
120 + renderingParticipationChanged();
121 + }
122 + }
123 +
124 + /**
125 + * Sets the widget's width, overiding the method in "UIObject". Unlike the standard GWT "UIObject" method, the
126 + * pWidth is "assumed" to include ALL decorations (such as border, margin, and padding). This means that a
127 + * subsequent call to "getOffsetWidth()" will "eventually" return the value "set"!
128 + * <p/>
129 + * This method is normally delegated to the 'X' RenderHelper
130 + *
131 + * @param pWidth the Widget's new width, in CSS px (e.g. "10")
132 + */
133 + @Override
134 + public void setWidth( String pWidth ) {
135 + Parse.andSetSize( getRenderHelperX(), pWidth );
136 + }
137 +
138 + /**
139 + * Sets the widget's width, unlike the standard GWT "UIObject" method, this pWidth is "assumed" to include ALL
140 + * decorations (such as border, margin, and padding). This means that a subsequent call to "getOffsetWidth()"
141 + * will "eventually" return the value "set"!
142 + * <p/>
143 + * This method is used by the 'X' RenderHelper via the GwtRenderDimensionAdapterX to bypass the normal delegation
144 + * on "setWidth()" to the 'X' RenderHelper.
145 + *
146 + * @param pWidth the Widget's new width, in CSS px (e.g. "10")
147 + */
148 + @Override
149 + public void LLsetWidgetWidth( int pWidth ) {
150 + Size.set( this, GwtElementDimensionHelperX.INSTANCE, getContainerElement(), pWidth, getDecorationSizeX() );
151 + }
152 +
153 + /**
154 + * Remove the Widget's width, after this call subsequent calls to "getOffsetWidth()" will "eventually" return the
155 + * "natural" width of the Widget!
156 + */
157 + @Override
158 + public void clearWidth() {
159 + Size.clear( this, GwtElementDimensionHelperX.INSTANCE, getContainerElement() );
160 + }
161 +
162 + /**
163 + * Sets the widget's height, overiding the method in "UIObject". Unlike the standard GWT "UIObject" method, this
164 + * pHeight is "assumed" to include ALL decorations (such as border, margin, and padding). This means that a
165 + * subsequent call to "getOffsetHeight()" will "eventually" return the value "set"!
166 + * <p/>
167 + * This method is normally delegated to the 'Y' RenderHelper
168 + *
169 + * @param pHeight the Widget's new height, in CSS px (e.g. "10")
170 + */
171 + @Override
172 + public void setHeight( String pHeight ) {
173 + Parse.andSetSize( getRenderHelperY(), pHeight );
174 + }
175 +
176 + /**
177 + * Sets the widget's height, unlike the standard GWT "UIObject" method, this pHeight is "assumed" to include ALL
178 + * decorations (such as border, margin, and padding). This means that a subsequent call to "getOffsetHeight()"
179 + * will "eventually" return the value "set"!
180 + * <p/>
181 + * This method is used by the 'Y' RenderHelper via the GwtRenderDimensionAdapterY to bypass the normal delegation
182 + * on "setHeight()" to the 'Y' RenderHelper.
183 + *
184 + * @param pHeight the Widget's new height, in CSS px (e.g. "10")
185 + */
186 + @Override
187 + public void LLsetWidgetHeight( int pHeight ) {
188 + Size.set( this, GwtElementDimensionHelperY.INSTANCE, getContainerElement(), pHeight, getDecorationSizeY() );
189 + }
190 +
191 + /**
192 + * Remove the Widget's height, after this call subsequent calls to "getOffsetHeight()" will "eventually" return the
193 + * "natural" height of the Widget!
194 + */
195 + @Override
196 + public void clearHeight() {
197 + Size.clear( this, GwtElementDimensionHelperY.INSTANCE, getContainerElement() );
198 + }
199 +
200 + @Override
201 + public void renderingParticipationChanged() {
202 + RenderingParticipationChangedHelper.participationChanged( this, getWidget() );
203 + }
204 +
205 + @Override
206 + public RenderHelper getRenderHelperX() {
207 + return mRenderHelperX;
208 + }
209 +
210 + @Override
211 + public RenderHelper getRenderHelperY() {
212 + return mRenderHelperY;
213 + }
214 +
215 + /**
216 + * Get a Container's Decoration (or Overhead) Size in the 'X' dimension - the difference between the outside size and the inside size (what is available
217 + * for child widgets)
218 + * <p/>
219 + * Note: this will NOT be called until the Container is reporting proper sizes!
220 + */
221 + @Override
222 + public int getDecorationSizeX() {
223 + return DecorationSize.calculate( this, GwtElementDimensionHelperX.INSTANCE, //
224 + getElement(), getContainerElement() );
225 + }
226 +
227 + /**
228 + * Get a Container's Decoration (or Overhead) Size in the 'Y' dimension - the difference between the outside size and the inside size (what is available
229 + * for child widgets)
230 + * <p/>
231 + * Note: this will NOT be called until the Container is reporting proper sizes!
232 + */
233 + @Override
234 + public int getDecorationSizeY() {
235 + return DecorationSize.calculate( this, GwtElementDimensionHelperY.INSTANCE, //
236 + getElement(), getContainerElement() );
237 + }
238 +
239 + @Override
240 + public void relayout() {
241 + getRenderHelperX().layout();
242 + getRenderHelperY().layout();
243 + }
244 + }