|
@@ -1,191 +1,191 @@ |
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.GWT.client.widgets.nonpublic.*; |
6 |
|
- |
import org.litesoft.ui.*; |
7 |
|
- |
|
8 |
|
- |
import com.google.gwt.user.client.*; |
9 |
|
- |
import com.google.gwt.user.client.ui.*; |
10 |
|
- |
|
11 |
|
- |
public class SizeableQBEboxedPanel extends AbstractSizeableSimplePanel { |
12 |
|
- |
private static final String STYLE = "NineCeller"; |
13 |
|
- |
|
14 |
|
- |
public static final int STANDARD_SIZE = 11; |
15 |
|
- |
public static final int LEFT_WIDTH = 36; |
16 |
|
- |
|
17 |
|
- |
private static final String QBEPOPUP_POINTER = "common/images/QBEpopup/pointer.gif"; |
18 |
|
- |
private static final int POINTER_HEIGHT = 32; |
19 |
|
- |
private static final int POINTER_WIDTH = 27; |
20 |
|
- |
|
21 |
|
- |
private Element mPointer; |
22 |
|
- |
private int mAt = 0; |
23 |
|
- |
private boolean mShowingPointer = true; |
24 |
|
- |
|
25 |
|
- |
public SizeableQBEboxedPanel() { |
26 |
|
- |
mPointer = createPointer(); |
27 |
|
- |
Element zGraphRoot = CommonElementHelper.createTable(); |
28 |
|
- |
Element zTBody = CommonElementHelper.appendToParent( DOM.createTBody(), zGraphRoot ); |
29 |
|
- |
addRow( zTBody, CompassPoint.NW, CompassPoint.N, CompassPoint.NE ); |
30 |
|
- |
Element zInnerElement = addRow( zTBody, CompassPoint.W, mPointer, CompassPoint.center, null, CompassPoint.E, createTransparentImg( STANDARD_SIZE ) ); |
31 |
|
- |
addRow( zTBody, CompassPoint.SW, CompassPoint.S, CompassPoint.SE ); |
32 |
|
- |
initializeElements( getHelper().create_OeTable_SeDiv_IeGraph( true, zGraphRoot, zInnerElement ), "LayoutSizeableQBEpopupPanel" ); |
33 |
|
- |
addStyleName( STYLE ); |
34 |
|
- |
show( false ); |
35 |
|
- |
} |
36 |
|
- |
|
37 |
|
- |
public SizeableQBEboxedPanel( Widget pWidget ) { |
38 |
|
- |
this(); |
39 |
|
- |
setWidget( pWidget ); |
40 |
|
- |
} |
41 |
|
- |
|
42 |
|
- |
public SizeableQBEboxedPanel style( String pStyleName ) { |
43 |
|
- |
addStyleName( pStyleName ); |
44 |
|
- |
return this; |
45 |
|
- |
} |
46 |
|
- |
|
47 |
|
- |
public SizeableQBEboxedPanel stretchable() { |
48 |
|
- |
LLstretchable(); |
49 |
|
- |
return this; |
50 |
|
- |
} |
51 |
|
- |
|
52 |
|
- |
public SizeableQBEboxedPanel stretchableVertically() { |
53 |
|
- |
LLstretchableVertically(); |
54 |
|
- |
return this; |
55 |
|
- |
} |
56 |
|
- |
|
57 |
|
- |
public SizeableQBEboxedPanel stretchableHorizontally() { |
58 |
|
- |
LLstretchableHorizontally(); |
59 |
|
- |
return this; |
60 |
|
- |
} |
61 |
|
- |
|
62 |
|
- |
@Override |
63 |
|
- |
public void setWidget( Widget pWidget ) { |
64 |
|
- |
Widget zWidget = getWidget(); |
65 |
|
- |
if ( zWidget == null ) { |
66 |
|
- |
super.setWidget( pWidget ); |
67 |
|
- |
} else { |
68 |
|
- |
int zWidth = zWidget.getOffsetWidth(); |
69 |
|
- |
int zHeight = zWidget.getOffsetHeight(); |
70 |
|
- |
super.setWidget( pWidget ); |
71 |
|
- |
pWidget.setWidth( "" + zWidth ); |
72 |
|
- |
pWidget.setHeight( "" + zHeight ); |
73 |
|
- |
} |
74 |
|
- |
} |
75 |
|
- |
|
76 |
|
- |
public void show( boolean pShow ) { |
77 |
|
- |
UtilsGwt.setHidden( this, !pShow ); |
78 |
|
- |
CommonElementHelper.setHidden( mPointer, !pShow ); |
79 |
|
- |
} |
80 |
|
- |
|
81 |
|
- |
public boolean isPointerShowing() { |
82 |
|
- |
return mShowingPointer; |
83 |
|
- |
} |
84 |
|
- |
|
85 |
|
- |
public int getPointsAt() { |
86 |
|
- |
return mAt + (POINTER_HEIGHT / 2); |
87 |
|
- |
} |
88 |
|
- |
|
89 |
|
- |
public void pointTo( Widget pWidget ) { |
90 |
|
- |
pointTo( pWidget, HasVerticalAlignment.ALIGN_MIDDLE ); |
91 |
|
- |
} |
92 |
|
- |
|
93 |
|
- |
public void pointTo( Widget pWidget, HasVerticalAlignment.VerticalAlignmentConstant pValign ) { |
94 |
|
- |
pointTo( pWidget.getElement(), pValign ); |
95 |
|
- |
} |
96 |
|
- |
|
97 |
|
- |
public void pointTo( Element pElement ) { |
98 |
|
- |
pointTo( pElement, HasVerticalAlignment.ALIGN_MIDDLE ); |
99 |
|
- |
} |
100 |
|
- |
|
101 |
|
- |
public void pointTo( Element pElement, HasVerticalAlignment.VerticalAlignmentConstant pValign ) { |
102 |
|
- |
int zAt = pElement.getAbsoluteTop(); |
103 |
|
- |
if ( pValign != HasVerticalAlignment.ALIGN_TOP ) { |
104 |
|
- |
int zHeight = pElement.getOffsetHeight(); |
105 |
|
- |
if ( pValign == HasVerticalAlignment.ALIGN_BOTTOM ) { |
106 |
|
- |
zAt += zHeight - 1; |
107 |
|
- |
} else // Assume Middle |
108 |
|
- |
{ |
109 |
|
- |
zAt += zHeight / 2; |
110 |
|
- |
} |
111 |
|
- |
} |
112 |
|
- |
pointTo( zAt ); |
113 |
|
- |
} |
114 |
|
- |
|
115 |
|
- |
public void pointTo( int pTopOfPageOffset ) { |
116 |
|
- |
int zPointerTDAt = mPointer.getParentElement().getAbsoluteTop(); |
117 |
|
- |
int zAt = pTopOfPageOffset - zPointerTDAt; // Make Relative to my TD |
118 |
|
- |
zAt -= POINTER_HEIGHT / 2; |
119 |
|
- |
setAt( constrainAt( zAt ), zAt ); |
120 |
|
- |
show( true ); |
121 |
|
- |
} |
122 |
|
- |
|
123 |
|
- |
private void setAt( int zAt, int zDesiredAt ) // PreConstrained |
124 |
|
- |
{ |
125 |
|
- |
mPointer.getStyle().setPropertyPx( "top", mAt = zAt ); |
126 |
|
- |
mShowingPointer = (zAt == zDesiredAt); |
127 |
|
- |
CommonElementHelper.setHidden( mPointer, !mShowingPointer ); |
128 |
|
- |
} |
129 |
|
- |
|
130 |
|
- |
private int constrainAt( int zAt ) { |
131 |
|
- |
int zMaxAt = mPointer.getParentElement().getOffsetHeight() - POINTER_HEIGHT; |
132 |
|
- |
zAt = Math.min( zAt, zMaxAt ); |
133 |
|
- |
zAt = Math.max( 0, zAt ); |
134 |
|
- |
return zAt; |
135 |
|
- |
} |
136 |
|
- |
|
137 |
|
- |
private Element createPointer() { |
138 |
|
- |
Element zElement = CommonElementHelper.setImgSrc( DOM.createImg(), QBEPOPUP_POINTER ); |
139 |
|
- |
zElement.getStyle().setProperty( "position", "relative" ); |
140 |
|
- |
zElement.getStyle().setPropertyPx( "width", POINTER_WIDTH ); |
141 |
|
- |
zElement.getStyle().setPropertyPx( "height", POINTER_HEIGHT ); |
142 |
|
- |
return zElement; |
143 |
|
- |
} |
144 |
|
- |
|
145 |
|
- |
private Element createTransparentImg( int pWidth ) { |
146 |
|
- |
Element zElement = CommonElementHelper.setImgSrc( DOM.createImg(), TransparentImage.URL ); |
147 |
|
- |
zElement.getStyle().setPropertyPx( "width", pWidth ); |
148 |
|
- |
zElement.getStyle().setPropertyPx( "height", STANDARD_SIZE ); |
149 |
|
- |
return zElement; |
150 |
|
- |
} |
151 |
|
- |
|
152 |
|
- |
/** |
153 |
|
- |
* @return Center TD |
154 |
|
- |
*/ |
155 |
|
- |
private Element addRow( Element pTBody, CompassPoint pLeftCP, Element pLeftElement, CompassPoint pCenterCP, Element pCenterElement, CompassPoint pRightCP, |
156 |
|
- |
Element pRightElement ) { |
157 |
|
- |
Element zTR = CommonElementHelper.appendToParent( DOM.createTR(), pTBody ); |
158 |
|
- |
CommonElementHelper.setTDvAlign( addTD( zTR, pLeftCP, pLeftElement ), HasVerticalAlignment.ALIGN_TOP ); |
159 |
|
- |
Element zCenterTD = addTD( zTR, pCenterCP, pCenterElement ); |
160 |
|
- |
addTD( zTR, pRightCP, pRightElement ); |
161 |
|
- |
return zCenterTD; |
162 |
|
- |
} |
163 |
|
- |
|
164 |
|
- |
private Element addTD( Element pTR, CompassPoint pCP, Element pElement ) { |
165 |
|
- |
Element zTD = CommonElementHelper.appendToParent( DOM.createTD(), pTR ); |
166 |
|
- |
if ( pElement != null ) { |
167 |
|
- |
zTD.appendChild( pElement ); |
168 |
|
- |
} |
169 |
|
- |
zTD.setClassName( "CP_" + pCP ); |
170 |
|
- |
return zTD; |
171 |
|
- |
} |
172 |
|
- |
|
173 |
|
- |
private void addRow( Element pTBody, CompassPoint pLeft, CompassPoint pCenter, CompassPoint pRight ) { |
174 |
|
- |
addRow( pTBody, pLeft, createTransparentImg( LEFT_WIDTH ), pCenter, createTransparentImg( STANDARD_SIZE ), pRight, |
175 |
|
- |
createTransparentImg( STANDARD_SIZE ) ); |
176 |
|
- |
} |
177 |
|
- |
|
178 |
|
- |
@Override |
179 |
|
- |
public void setWidth( String width ) { |
180 |
|
- |
super.setWidth( width ); |
181 |
|
- |
} |
182 |
|
- |
|
183 |
|
- |
@Override |
184 |
|
- |
public void setHeight( String height ) { |
185 |
|
- |
super.setHeight( height ); |
186 |
|
- |
int zAt = constrainAt( mAt ); |
187 |
|
- |
if ( zAt != mAt ) { |
188 |
|
- |
setAt( zAt, mAt ); |
189 |
|
- |
} |
190 |
|
- |
} |
191 |
|
- |
} |
|
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.GWT.client.widgets.nonpublic.*; |
|
6 |
+ |
import org.litesoft.ui.*; |
|
7 |
+ |
|
|
8 |
+ |
import com.google.gwt.user.client.*; |
|
9 |
+ |
import com.google.gwt.user.client.ui.*; |
|
10 |
+ |
|
|
11 |
+ |
public class SizeableQBEboxedPanel extends AbstractSizeableSimplePanel { |
|
12 |
+ |
private static final String STYLE = "NineCeller"; |
|
13 |
+ |
|
|
14 |
+ |
public static final int STANDARD_SIZE = 11; |
|
15 |
+ |
public static final int LEFT_WIDTH = 36; |
|
16 |
+ |
|
|
17 |
+ |
private static final String QBEPOPUP_POINTER = "common/images/QBEpopup/pointer.gif"; |
|
18 |
+ |
private static final int POINTER_HEIGHT = 32; |
|
19 |
+ |
private static final int POINTER_WIDTH = 27; |
|
20 |
+ |
|
|
21 |
+ |
private Element mPointer; |
|
22 |
+ |
private int mAt = 0; |
|
23 |
+ |
private boolean mShowingPointer = true; |
|
24 |
+ |
|
|
25 |
+ |
public SizeableQBEboxedPanel() { |
|
26 |
+ |
mPointer = createPointer(); |
|
27 |
+ |
Element zGraphRoot = CommonElementHelper.createTable(); |
|
28 |
+ |
Element zTBody = CommonElementHelper.appendToParent( DOM.createTBody(), zGraphRoot ); |
|
29 |
+ |
addRow( zTBody, CompassPoint.NW, CompassPoint.N, CompassPoint.NE ); |
|
30 |
+ |
Element zInnerElement = addRow( zTBody, CompassPoint.W, mPointer, CompassPoint.center, null, CompassPoint.E, createTransparentImg( STANDARD_SIZE ) ); |
|
31 |
+ |
addRow( zTBody, CompassPoint.SW, CompassPoint.S, CompassPoint.SE ); |
|
32 |
+ |
initializeElements( getHelper().create_OeTable_SeDiv_IeGraph( true, zGraphRoot, zInnerElement ), "LayoutSizeableQBEpopupPanel" ); |
|
33 |
+ |
addStyleName( STYLE ); |
|
34 |
+ |
show( false ); |
|
35 |
+ |
} |
|
36 |
+ |
|
|
37 |
+ |
public SizeableQBEboxedPanel( Widget pWidget ) { |
|
38 |
+ |
this(); |
|
39 |
+ |
setWidget( pWidget ); |
|
40 |
+ |
} |
|
41 |
+ |
|
|
42 |
+ |
public SizeableQBEboxedPanel style( String pStyleName ) { |
|
43 |
+ |
addStyleName( pStyleName ); |
|
44 |
+ |
return this; |
|
45 |
+ |
} |
|
46 |
+ |
|
|
47 |
+ |
public SizeableQBEboxedPanel stretchable() { |
|
48 |
+ |
LLstretchable(); |
|
49 |
+ |
return this; |
|
50 |
+ |
} |
|
51 |
+ |
|
|
52 |
+ |
public SizeableQBEboxedPanel stretchableVertically() { |
|
53 |
+ |
LLstretchableVertically(); |
|
54 |
+ |
return this; |
|
55 |
+ |
} |
|
56 |
+ |
|
|
57 |
+ |
public SizeableQBEboxedPanel stretchableHorizontally() { |
|
58 |
+ |
LLstretchableHorizontally(); |
|
59 |
+ |
return this; |
|
60 |
+ |
} |
|
61 |
+ |
|
|
62 |
+ |
@Override |
|
63 |
+ |
public void setWidget( Widget pWidget ) { |
|
64 |
+ |
Widget zWidget = getWidget(); |
|
65 |
+ |
if ( zWidget == null ) { |
|
66 |
+ |
super.setWidget( pWidget ); |
|
67 |
+ |
} else { |
|
68 |
+ |
int zWidth = zWidget.getOffsetWidth(); |
|
69 |
+ |
int zHeight = zWidget.getOffsetHeight(); |
|
70 |
+ |
super.setWidget( pWidget ); |
|
71 |
+ |
pWidget.setWidth( "" + zWidth ); |
|
72 |
+ |
pWidget.setHeight( "" + zHeight ); |
|
73 |
+ |
} |
|
74 |
+ |
} |
|
75 |
+ |
|
|
76 |
+ |
public void show( boolean pShow ) { |
|
77 |
+ |
UtilsGwt.setHidden( this, !pShow ); |
|
78 |
+ |
CommonElementHelper.setHidden( mPointer, !pShow ); |
|
79 |
+ |
} |
|
80 |
+ |
|
|
81 |
+ |
public boolean isPointerShowing() { |
|
82 |
+ |
return mShowingPointer; |
|
83 |
+ |
} |
|
84 |
+ |
|
|
85 |
+ |
public int getPointsAt() { |
|
86 |
+ |
return mAt + (POINTER_HEIGHT / 2); |
|
87 |
+ |
} |
|
88 |
+ |
|
|
89 |
+ |
public void pointTo( Widget pWidget ) { |
|
90 |
+ |
pointTo( pWidget, HasVerticalAlignment.ALIGN_MIDDLE ); |
|
91 |
+ |
} |
|
92 |
+ |
|
|
93 |
+ |
public void pointTo( Widget pWidget, HasVerticalAlignment.VerticalAlignmentConstant pValign ) { |
|
94 |
+ |
pointTo( pWidget.getElement(), pValign ); |
|
95 |
+ |
} |
|
96 |
+ |
|
|
97 |
+ |
public void pointTo( Element pElement ) { |
|
98 |
+ |
pointTo( pElement, HasVerticalAlignment.ALIGN_MIDDLE ); |
|
99 |
+ |
} |
|
100 |
+ |
|
|
101 |
+ |
public void pointTo( Element pElement, HasVerticalAlignment.VerticalAlignmentConstant pValign ) { |
|
102 |
+ |
int zAt = pElement.getAbsoluteTop(); |
|
103 |
+ |
if ( pValign != HasVerticalAlignment.ALIGN_TOP ) { |
|
104 |
+ |
int zHeight = pElement.getOffsetHeight(); |
|
105 |
+ |
if ( pValign == HasVerticalAlignment.ALIGN_BOTTOM ) { |
|
106 |
+ |
zAt += zHeight - 1; |
|
107 |
+ |
} else // Assume Middle |
|
108 |
+ |
{ |
|
109 |
+ |
zAt += zHeight / 2; |
|
110 |
+ |
} |
|
111 |
+ |
} |
|
112 |
+ |
pointTo( zAt ); |
|
113 |
+ |
} |
|
114 |
+ |
|
|
115 |
+ |
public void pointTo( int pTopOfPageOffset ) { |
|
116 |
+ |
int zPointerTDAt = mPointer.getParentElement().getAbsoluteTop(); |
|
117 |
+ |
int zAt = pTopOfPageOffset - zPointerTDAt; // Make Relative to my TD |
|
118 |
+ |
zAt -= POINTER_HEIGHT / 2; |
|
119 |
+ |
setAt( constrainAt( zAt ), zAt ); |
|
120 |
+ |
show( true ); |
|
121 |
+ |
} |
|
122 |
+ |
|
|
123 |
+ |
private void setAt( int zAt, int zDesiredAt ) // PreConstrained |
|
124 |
+ |
{ |
|
125 |
+ |
mPointer.getStyle().setPropertyPx( "top", mAt = zAt ); |
|
126 |
+ |
mShowingPointer = (zAt == zDesiredAt); |
|
127 |
+ |
CommonElementHelper.setHidden( mPointer, !mShowingPointer ); |
|
128 |
+ |
} |
|
129 |
+ |
|
|
130 |
+ |
private int constrainAt( int zAt ) { |
|
131 |
+ |
int zMaxAt = mPointer.getParentElement().getOffsetHeight() - POINTER_HEIGHT; |
|
132 |
+ |
zAt = Math.min( zAt, zMaxAt ); |
|
133 |
+ |
zAt = Math.max( 0, zAt ); |
|
134 |
+ |
return zAt; |
|
135 |
+ |
} |
|
136 |
+ |
|
|
137 |
+ |
private Element createPointer() { |
|
138 |
+ |
Element zElement = CommonElementHelper.setImgSrc( DOM.createImg(), QBEPOPUP_POINTER ); |
|
139 |
+ |
zElement.getStyle().setProperty( "position", "relative" ); |
|
140 |
+ |
zElement.getStyle().setPropertyPx( "width", POINTER_WIDTH ); |
|
141 |
+ |
zElement.getStyle().setPropertyPx( "height", POINTER_HEIGHT ); |
|
142 |
+ |
return zElement; |
|
143 |
+ |
} |
|
144 |
+ |
|
|
145 |
+ |
private Element createTransparentImg( int pWidth ) { |
|
146 |
+ |
Element zElement = CommonElementHelper.setImgSrc( DOM.createImg(), TransparentImage.URL ); |
|
147 |
+ |
zElement.getStyle().setPropertyPx( "width", pWidth ); |
|
148 |
+ |
zElement.getStyle().setPropertyPx( "height", STANDARD_SIZE ); |
|
149 |
+ |
return zElement; |
|
150 |
+ |
} |
|
151 |
+ |
|
|
152 |
+ |
/** |
|
153 |
+ |
* @return Center TD |
|
154 |
+ |
*/ |
|
155 |
+ |
private Element addRow( Element pTBody, CompassPoint pLeftCP, Element pLeftElement, CompassPoint pCenterCP, Element pCenterElement, CompassPoint pRightCP, |
|
156 |
+ |
Element pRightElement ) { |
|
157 |
+ |
Element zTR = CommonElementHelper.appendToParent( DOM.createTR(), pTBody ); |
|
158 |
+ |
CommonElementHelper.setTDvAlign( addTD( zTR, pLeftCP, pLeftElement ), HasVerticalAlignment.ALIGN_TOP ); |
|
159 |
+ |
Element zCenterTD = addTD( zTR, pCenterCP, pCenterElement ); |
|
160 |
+ |
addTD( zTR, pRightCP, pRightElement ); |
|
161 |
+ |
return zCenterTD; |
|
162 |
+ |
} |
|
163 |
+ |
|
|
164 |
+ |
private Element addTD( Element pTR, CompassPoint pCP, Element pElement ) { |
|
165 |
+ |
Element zTD = CommonElementHelper.appendToParent( DOM.createTD(), pTR ); |
|
166 |
+ |
if ( pElement != null ) { |
|
167 |
+ |
zTD.appendChild( pElement ); |
|
168 |
+ |
} |
|
169 |
+ |
zTD.setClassName( "CP_" + pCP ); |
|
170 |
+ |
return zTD; |
|
171 |
+ |
} |
|
172 |
+ |
|
|
173 |
+ |
private void addRow( Element pTBody, CompassPoint pLeft, CompassPoint pCenter, CompassPoint pRight ) { |
|
174 |
+ |
addRow( pTBody, pLeft, createTransparentImg( LEFT_WIDTH ), pCenter, createTransparentImg( STANDARD_SIZE ), pRight, |
|
175 |
+ |
createTransparentImg( STANDARD_SIZE ) ); |
|
176 |
+ |
} |
|
177 |
+ |
|
|
178 |
+ |
@Override |
|
179 |
+ |
public void setWidth( String width ) { |
|
180 |
+ |
super.setWidth( width ); |
|
181 |
+ |
} |
|
182 |
+ |
|
|
183 |
+ |
@Override |
|
184 |
+ |
public void setHeight( String height ) { |
|
185 |
+ |
super.setHeight( height ); |
|
186 |
+ |
int zAt = constrainAt( mAt ); |
|
187 |
+ |
if ( zAt != mAt ) { |
|
188 |
+ |
setAt( zAt, mAt ); |
|
189 |
+ |
} |
|
190 |
+ |
} |
|
191 |
+ |
} |