|
@@ -1,98 +1,98 @@ |
1 |
|
- |
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
|
- |
package org.litesoft.GWT.client.widgets; |
3 |
|
- |
|
4 |
|
- |
import org.litesoft.GWT.client.*; |
5 |
|
- |
import org.litesoft.core.delayed.*; |
6 |
|
- |
|
7 |
|
- |
import com.google.gwt.user.client.ui.*; |
8 |
|
- |
|
9 |
|
- |
public class ContentSizeableSimplePanel extends ClippingSimplePanel { |
10 |
|
- |
public ContentSizeableSimplePanel() { |
11 |
|
- |
this( null, null ); |
12 |
|
- |
} |
13 |
|
- |
|
14 |
|
- |
public ContentSizeableSimplePanel( Widget pWidget ) { |
15 |
|
- |
this( null, pWidget ); |
16 |
|
- |
} |
17 |
|
- |
|
18 |
|
- |
/** |
19 |
|
- |
* @param pNoSizeAffectingCSS_StyleClassname a style name or null |
20 |
|
- |
* @param pWidget a widget or null. Call {@link #setWidget(Widget)} if this is null. |
21 |
|
- |
*/ |
22 |
|
- |
public ContentSizeableSimplePanel( String pNoSizeAffectingCSS_StyleClassname, Widget pWidget ) { |
23 |
|
- |
super( pNoSizeAffectingCSS_StyleClassname ); |
24 |
|
- |
if ( pWidget != null ) { |
25 |
|
- |
setWidget( pWidget ); |
26 |
|
- |
} |
27 |
|
- |
} |
28 |
|
- |
|
29 |
|
- |
@Override |
30 |
|
- |
public void setWidget( Widget pWidget ) { |
31 |
|
- |
super.setWidget( pWidget ); |
32 |
|
- |
updateChildSize(); |
33 |
|
- |
} |
34 |
|
- |
|
35 |
|
- |
@Override |
36 |
|
- |
protected void onAttach() { |
37 |
|
- |
super.onAttach(); |
38 |
|
- |
updateChildSize(); |
39 |
|
- |
} |
40 |
|
- |
|
41 |
|
- |
@Override |
42 |
|
- |
public void setVisible( boolean visible ) { |
43 |
|
- |
super.setVisible( visible ); |
44 |
|
- |
updateChildSize(); |
45 |
|
- |
} |
46 |
|
- |
|
47 |
|
- |
protected void updateChildSize() { |
48 |
|
- |
if ( !LLupdateChildSize() ) { |
49 |
|
- |
LLupdateChildSizeLater(); |
50 |
|
- |
} |
51 |
|
- |
} |
52 |
|
- |
|
53 |
|
- |
private boolean LLupdateChildSize() { |
54 |
|
- |
Widget zWidget = getWidget(); |
55 |
|
- |
if ( isVisible() && isAttached() && (zWidget != null) ) { |
56 |
|
- |
int zWidth = getOffsetWidth(); |
57 |
|
- |
int zHeight = getOffsetHeight(); |
58 |
|
- |
if ( (10 > zWidth) || (10 > zHeight) ) { |
59 |
|
- |
return false; |
60 |
|
- |
} |
61 |
|
- |
LLupdateChildWidth( zWidget, zWidth ); |
62 |
|
- |
LLupdateChildHeight( zWidget, zHeight ); |
63 |
|
- |
} |
64 |
|
- |
return true; |
65 |
|
- |
} |
66 |
|
- |
|
67 |
|
- |
protected void LLupdateChildHeight( Widget pWidget, int pHeight ) { |
68 |
|
- |
pWidget.setHeight( "" + pHeight ); |
69 |
|
- |
} |
70 |
|
- |
|
71 |
|
- |
protected void LLupdateChildWidth( Widget pWidget, int pWidth ) { |
72 |
|
- |
pWidget.setWidth( "" + pWidth ); |
73 |
|
- |
} |
74 |
|
- |
|
75 |
|
- |
private void LLupdateChildSizeLater() { |
76 |
|
- |
if ( !mUpdateChildSizeDeffered ) { |
77 |
|
- |
mUpdateChildSizeDeffered = true; |
78 |
|
- |
TimedRunnableManager.INSTANCE.runIn( mLaterUpdateChildSize, 50 ); |
79 |
|
- |
} |
80 |
|
- |
} |
81 |
|
- |
|
82 |
|
- |
private boolean mUpdateChildSizeDeffered = false; |
83 |
|
- |
private TimedRunnable mLaterUpdateChildSize = new TimedRunnable() { |
84 |
|
- |
@Override |
85 |
|
- |
public Again runOnce() { |
86 |
|
- |
try { |
87 |
|
- |
if ( !LLupdateChildSize() ) { |
88 |
|
- |
return new RunAgainIn( 100 ); |
89 |
|
- |
} |
90 |
|
- |
} |
91 |
|
- |
catch ( RuntimeException e ) { |
92 |
|
- |
e.printStackTrace(); |
93 |
|
- |
} |
94 |
|
- |
mUpdateChildSizeDeffered = false; |
95 |
|
- |
return null; |
96 |
|
- |
} |
97 |
|
- |
}; |
98 |
|
- |
} |
|
1 |
+ |
// This Source Code is in the Public Domain per: http://unlicense.org |
|
2 |
+ |
package org.litesoft.GWT.client.widgets; |
|
3 |
+ |
|
|
4 |
+ |
import org.litesoft.GWT.client.*; |
|
5 |
+ |
import org.litesoft.core.delayed.*; |
|
6 |
+ |
|
|
7 |
+ |
import com.google.gwt.user.client.ui.*; |
|
8 |
+ |
|
|
9 |
+ |
public class ContentSizeableSimplePanel extends ClippingSimplePanel { |
|
10 |
+ |
public ContentSizeableSimplePanel() { |
|
11 |
+ |
this( null, null ); |
|
12 |
+ |
} |
|
13 |
+ |
|
|
14 |
+ |
public ContentSizeableSimplePanel( Widget pWidget ) { |
|
15 |
+ |
this( null, pWidget ); |
|
16 |
+ |
} |
|
17 |
+ |
|
|
18 |
+ |
/** |
|
19 |
+ |
* @param pNoSizeAffectingCSS_StyleClassname a style name or null |
|
20 |
+ |
* @param pWidget a widget or null. Call {@link #setWidget(Widget)} if this is null. |
|
21 |
+ |
*/ |
|
22 |
+ |
public ContentSizeableSimplePanel( String pNoSizeAffectingCSS_StyleClassname, Widget pWidget ) { |
|
23 |
+ |
super( pNoSizeAffectingCSS_StyleClassname ); |
|
24 |
+ |
if ( pWidget != null ) { |
|
25 |
+ |
setWidget( pWidget ); |
|
26 |
+ |
} |
|
27 |
+ |
} |
|
28 |
+ |
|
|
29 |
+ |
@Override |
|
30 |
+ |
public void setWidget( Widget pWidget ) { |
|
31 |
+ |
super.setWidget( pWidget ); |
|
32 |
+ |
updateChildSize(); |
|
33 |
+ |
} |
|
34 |
+ |
|
|
35 |
+ |
@Override |
|
36 |
+ |
protected void onAttach() { |
|
37 |
+ |
super.onAttach(); |
|
38 |
+ |
updateChildSize(); |
|
39 |
+ |
} |
|
40 |
+ |
|
|
41 |
+ |
@Override |
|
42 |
+ |
public void setVisible( boolean visible ) { |
|
43 |
+ |
super.setVisible( visible ); |
|
44 |
+ |
updateChildSize(); |
|
45 |
+ |
} |
|
46 |
+ |
|
|
47 |
+ |
protected void updateChildSize() { |
|
48 |
+ |
if ( !LLupdateChildSize() ) { |
|
49 |
+ |
LLupdateChildSizeLater(); |
|
50 |
+ |
} |
|
51 |
+ |
} |
|
52 |
+ |
|
|
53 |
+ |
private boolean LLupdateChildSize() { |
|
54 |
+ |
Widget zWidget = getWidget(); |
|
55 |
+ |
if ( isVisible() && isAttached() && (zWidget != null) ) { |
|
56 |
+ |
int zWidth = getOffsetWidth(); |
|
57 |
+ |
int zHeight = getOffsetHeight(); |
|
58 |
+ |
if ( (10 > zWidth) || (10 > zHeight) ) { |
|
59 |
+ |
return false; |
|
60 |
+ |
} |
|
61 |
+ |
LLupdateChildWidth( zWidget, zWidth ); |
|
62 |
+ |
LLupdateChildHeight( zWidget, zHeight ); |
|
63 |
+ |
} |
|
64 |
+ |
return true; |
|
65 |
+ |
} |
|
66 |
+ |
|
|
67 |
+ |
protected void LLupdateChildHeight( Widget pWidget, int pHeight ) { |
|
68 |
+ |
pWidget.setHeight( "" + pHeight ); |
|
69 |
+ |
} |
|
70 |
+ |
|
|
71 |
+ |
protected void LLupdateChildWidth( Widget pWidget, int pWidth ) { |
|
72 |
+ |
pWidget.setWidth( "" + pWidth ); |
|
73 |
+ |
} |
|
74 |
+ |
|
|
75 |
+ |
private void LLupdateChildSizeLater() { |
|
76 |
+ |
if ( !mUpdateChildSizeDeffered ) { |
|
77 |
+ |
mUpdateChildSizeDeffered = true; |
|
78 |
+ |
TimedRunnableManager.INSTANCE.runIn( mLaterUpdateChildSize, 50 ); |
|
79 |
+ |
} |
|
80 |
+ |
} |
|
81 |
+ |
|
|
82 |
+ |
private boolean mUpdateChildSizeDeffered = false; |
|
83 |
+ |
private TimedRunnable mLaterUpdateChildSize = new TimedRunnable() { |
|
84 |
+ |
@Override |
|
85 |
+ |
public Again runOnce() { |
|
86 |
+ |
try { |
|
87 |
+ |
if ( !LLupdateChildSize() ) { |
|
88 |
+ |
return new RunAgainIn( 100 ); |
|
89 |
+ |
} |
|
90 |
+ |
} |
|
91 |
+ |
catch ( RuntimeException e ) { |
|
92 |
+ |
e.printStackTrace(); |
|
93 |
+ |
} |
|
94 |
+ |
mUpdateChildSizeDeffered = false; |
|
95 |
+ |
return null; |
|
96 |
+ |
} |
|
97 |
+ |
}; |
|
98 |
+ |
} |