|
@@ -1,110 +1,110 @@ |
1 |
|
- |
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
|
- |
package org.litesoft.GWT.client.widgets.nonpublic; |
3 |
|
- |
|
4 |
|
- |
import com.google.gwt.user.client.*; |
5 |
|
- |
import com.google.gwt.user.client.ui.*; |
6 |
|
- |
|
7 |
|
- |
public abstract class AbstractSizeableHasAlignmentPanel extends AbstractSizeablePanel implements HasAlignment { |
8 |
|
- |
private HorizontalAlignmentConstant mHorzAlign = ALIGN_LEFT; |
9 |
|
- |
private VerticalAlignmentConstant mVertAlign = ALIGN_TOP; |
10 |
|
- |
|
11 |
|
- |
// vvvvvvvvvvv HasAlignment |
12 |
|
- |
|
13 |
|
- |
@Override |
14 |
|
- |
public HorizontalAlignmentConstant getHorizontalAlignment() { |
15 |
|
- |
return mHorzAlign; |
16 |
|
- |
} |
17 |
|
- |
|
18 |
|
- |
@Override |
19 |
|
- |
public VerticalAlignmentConstant getVerticalAlignment() { |
20 |
|
- |
return mVertAlign; |
21 |
|
- |
} |
22 |
|
- |
|
23 |
|
- |
/** |
24 |
|
- |
* Sets the default horizontal alignment to be used for widgets added to this |
25 |
|
- |
* panel. It only applies to widgets added after this property is set. |
26 |
|
- |
* |
27 |
|
- |
* @see HasHorizontalAlignment#setHorizontalAlignment(HorizontalAlignmentConstant) |
28 |
|
- |
*/ |
29 |
|
- |
@Override |
30 |
|
- |
public void setHorizontalAlignment( HorizontalAlignmentConstant pAlign ) { |
31 |
|
- |
if ( pAlign != null ) { |
32 |
|
- |
mHorzAlign = pAlign; |
33 |
|
- |
} |
34 |
|
- |
} |
35 |
|
- |
|
36 |
|
- |
/** |
37 |
|
- |
* Sets the default vertical alignment to be used for widgets added to this |
38 |
|
- |
* panel. It only applies to widgets added after this property is set. |
39 |
|
- |
* |
40 |
|
- |
* @see HasVerticalAlignment#setVerticalAlignment(VerticalAlignmentConstant) |
41 |
|
- |
*/ |
42 |
|
- |
@Override |
43 |
|
- |
public void setVerticalAlignment( VerticalAlignmentConstant pAlign ) { |
44 |
|
- |
if ( pAlign != null ) { |
45 |
|
- |
mVertAlign = pAlign; |
46 |
|
- |
} |
47 |
|
- |
} |
48 |
|
- |
|
49 |
|
- |
// ^^^^^^^^^^^ HasAlignment |
50 |
|
- |
|
51 |
|
- |
/** |
52 |
|
- |
* Sets the horizontal alignment of the given widget within its cell. |
53 |
|
- |
* |
54 |
|
- |
* @param pWidget the widget whose horizontal alignment is to be set |
55 |
|
- |
* @param pAlign the widget's horizontal alignment, as defined in |
56 |
|
- |
* {@link HasHorizontalAlignment}. |
57 |
|
- |
*/ |
58 |
|
- |
public void setCellHorizontalAlignment( Widget pWidget, HorizontalAlignmentConstant pAlign ) { |
59 |
|
- |
if ( pAlign != null ) { |
60 |
|
- |
Element td = getOurWidgetTd( pWidget ); |
61 |
|
- |
if ( td != null ) { |
62 |
|
- |
setAlignment( td, pAlign ); |
63 |
|
- |
} |
64 |
|
- |
} |
65 |
|
- |
} |
66 |
|
- |
|
67 |
|
- |
/** |
68 |
|
- |
* Sets the vertical alignment of the given widget within its cell. |
69 |
|
- |
* |
70 |
|
- |
* @param pWidget the widget whose vertical alignment is to be set |
71 |
|
- |
* @param pAlign the widget's vertical alignment, as defined in |
72 |
|
- |
* {@link HasVerticalAlignment}. |
73 |
|
- |
*/ |
74 |
|
- |
public void setCellVerticalAlignment( Widget pWidget, VerticalAlignmentConstant pAlign ) { |
75 |
|
- |
if ( pAlign != null ) { |
76 |
|
- |
Element td = getOurWidgetTd( pWidget ); |
77 |
|
- |
if ( td != null ) { |
78 |
|
- |
setAlignment( td, pAlign ); |
79 |
|
- |
} |
80 |
|
- |
} |
81 |
|
- |
} |
82 |
|
- |
|
83 |
|
- |
@Override |
84 |
|
- |
protected Element adopt( Widget w, Element container ) { |
85 |
|
- |
Element rv = super.adopt( w, container ); |
86 |
|
- |
setAlignment( getWidgetTd( w ) ); |
87 |
|
- |
return rv; |
88 |
|
- |
} |
89 |
|
- |
|
90 |
|
- |
private void setAlignment( Element pTD ) { |
91 |
|
- |
setAlignment( pTD, mHorzAlign ); |
92 |
|
- |
setAlignment( pTD, mVertAlign ); |
93 |
|
- |
} |
94 |
|
- |
|
95 |
|
- |
private void setAlignment( Element pTD, HorizontalAlignmentConstant pAlign ) { |
96 |
|
- |
CommonElementHelper.setTDalign( pTD, pAlign ); |
97 |
|
- |
} |
98 |
|
- |
|
99 |
|
- |
private void setAlignment( Element pTD, VerticalAlignmentConstant pAlign ) { |
100 |
|
- |
CommonElementHelper.setTDvAlign( pTD, pAlign ); |
101 |
|
- |
} |
102 |
|
- |
|
103 |
|
- |
protected Element getOurWidgetTd( Widget pWidget ) { |
104 |
|
- |
return isOur( pWidget ) ? getWidgetTd( pWidget ) : null; |
105 |
|
- |
} |
106 |
|
- |
|
107 |
|
- |
protected Element getWidgetTd( Widget pWidget ) { |
108 |
|
- |
return DOM.getParent( pWidget.getElement() ); |
109 |
|
- |
} |
110 |
|
- |
} |
|
1 |
+ |
// This Source Code is in the Public Domain per: http://unlicense.org |
|
2 |
+ |
package org.litesoft.GWT.client.widgets.nonpublic; |
|
3 |
+ |
|
|
4 |
+ |
import com.google.gwt.user.client.*; |
|
5 |
+ |
import com.google.gwt.user.client.ui.*; |
|
6 |
+ |
|
|
7 |
+ |
public abstract class AbstractSizeableHasAlignmentPanel extends AbstractSizeablePanel implements HasAlignment { |
|
8 |
+ |
private HorizontalAlignmentConstant mHorzAlign = ALIGN_LEFT; |
|
9 |
+ |
private VerticalAlignmentConstant mVertAlign = ALIGN_TOP; |
|
10 |
+ |
|
|
11 |
+ |
// vvvvvvvvvvv HasAlignment |
|
12 |
+ |
|
|
13 |
+ |
@Override |
|
14 |
+ |
public HorizontalAlignmentConstant getHorizontalAlignment() { |
|
15 |
+ |
return mHorzAlign; |
|
16 |
+ |
} |
|
17 |
+ |
|
|
18 |
+ |
@Override |
|
19 |
+ |
public VerticalAlignmentConstant getVerticalAlignment() { |
|
20 |
+ |
return mVertAlign; |
|
21 |
+ |
} |
|
22 |
+ |
|
|
23 |
+ |
/** |
|
24 |
+ |
* Sets the default horizontal alignment to be used for widgets added to this |
|
25 |
+ |
* panel. It only applies to widgets added after this property is set. |
|
26 |
+ |
* |
|
27 |
+ |
* @see HasHorizontalAlignment#setHorizontalAlignment(HorizontalAlignmentConstant) |
|
28 |
+ |
*/ |
|
29 |
+ |
@Override |
|
30 |
+ |
public void setHorizontalAlignment( HorizontalAlignmentConstant pAlign ) { |
|
31 |
+ |
if ( pAlign != null ) { |
|
32 |
+ |
mHorzAlign = pAlign; |
|
33 |
+ |
} |
|
34 |
+ |
} |
|
35 |
+ |
|
|
36 |
+ |
/** |
|
37 |
+ |
* Sets the default vertical alignment to be used for widgets added to this |
|
38 |
+ |
* panel. It only applies to widgets added after this property is set. |
|
39 |
+ |
* |
|
40 |
+ |
* @see HasVerticalAlignment#setVerticalAlignment(VerticalAlignmentConstant) |
|
41 |
+ |
*/ |
|
42 |
+ |
@Override |
|
43 |
+ |
public void setVerticalAlignment( VerticalAlignmentConstant pAlign ) { |
|
44 |
+ |
if ( pAlign != null ) { |
|
45 |
+ |
mVertAlign = pAlign; |
|
46 |
+ |
} |
|
47 |
+ |
} |
|
48 |
+ |
|
|
49 |
+ |
// ^^^^^^^^^^^ HasAlignment |
|
50 |
+ |
|
|
51 |
+ |
/** |
|
52 |
+ |
* Sets the horizontal alignment of the given widget within its cell. |
|
53 |
+ |
* |
|
54 |
+ |
* @param pWidget the widget whose horizontal alignment is to be set |
|
55 |
+ |
* @param pAlign the widget's horizontal alignment, as defined in |
|
56 |
+ |
* {@link HasHorizontalAlignment}. |
|
57 |
+ |
*/ |
|
58 |
+ |
public void setCellHorizontalAlignment( Widget pWidget, HorizontalAlignmentConstant pAlign ) { |
|
59 |
+ |
if ( pAlign != null ) { |
|
60 |
+ |
Element td = getOurWidgetTd( pWidget ); |
|
61 |
+ |
if ( td != null ) { |
|
62 |
+ |
setAlignment( td, pAlign ); |
|
63 |
+ |
} |
|
64 |
+ |
} |
|
65 |
+ |
} |
|
66 |
+ |
|
|
67 |
+ |
/** |
|
68 |
+ |
* Sets the vertical alignment of the given widget within its cell. |
|
69 |
+ |
* |
|
70 |
+ |
* @param pWidget the widget whose vertical alignment is to be set |
|
71 |
+ |
* @param pAlign the widget's vertical alignment, as defined in |
|
72 |
+ |
* {@link HasVerticalAlignment}. |
|
73 |
+ |
*/ |
|
74 |
+ |
public void setCellVerticalAlignment( Widget pWidget, VerticalAlignmentConstant pAlign ) { |
|
75 |
+ |
if ( pAlign != null ) { |
|
76 |
+ |
Element td = getOurWidgetTd( pWidget ); |
|
77 |
+ |
if ( td != null ) { |
|
78 |
+ |
setAlignment( td, pAlign ); |
|
79 |
+ |
} |
|
80 |
+ |
} |
|
81 |
+ |
} |
|
82 |
+ |
|
|
83 |
+ |
@Override |
|
84 |
+ |
protected Element adopt( Widget w, Element container ) { |
|
85 |
+ |
Element rv = super.adopt( w, container ); |
|
86 |
+ |
setAlignment( getWidgetTd( w ) ); |
|
87 |
+ |
return rv; |
|
88 |
+ |
} |
|
89 |
+ |
|
|
90 |
+ |
private void setAlignment( Element pTD ) { |
|
91 |
+ |
setAlignment( pTD, mHorzAlign ); |
|
92 |
+ |
setAlignment( pTD, mVertAlign ); |
|
93 |
+ |
} |
|
94 |
+ |
|
|
95 |
+ |
private void setAlignment( Element pTD, HorizontalAlignmentConstant pAlign ) { |
|
96 |
+ |
CommonElementHelper.setTDalign( pTD, pAlign ); |
|
97 |
+ |
} |
|
98 |
+ |
|
|
99 |
+ |
private void setAlignment( Element pTD, VerticalAlignmentConstant pAlign ) { |
|
100 |
+ |
CommonElementHelper.setTDvAlign( pTD, pAlign ); |
|
101 |
+ |
} |
|
102 |
+ |
|
|
103 |
+ |
protected Element getOurWidgetTd( Widget pWidget ) { |
|
104 |
+ |
return isOur( pWidget ) ? getWidgetTd( pWidget ) : null; |
|
105 |
+ |
} |
|
106 |
+ |
|
|
107 |
+ |
protected Element getWidgetTd( Widget pWidget ) { |
|
108 |
+ |
return DOM.getParent( pWidget.getElement() ); |
|
109 |
+ |
} |
|
110 |
+ |
} |