Subversion Repository Public Repository

litesoft

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

Diff revisions: vs.
  @@ -1,119 +1,119 @@
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.nonpublic.external.*;
5 -
6 - import com.google.gwt.user.client.ui.*;
7 -
8 - public abstract class AbstractSizeableVerticalSplitPairPanel extends AbstractSizeableVerticalPanel {
9 - private VerticalSplitterDragger mDragger;
10 -
11 - @Override
12 - protected void initialize() {
13 - super.initialize();
14 - LLstretchableVertically();
15 - }
16 -
17 - public AbstractSizeableVerticalSplitPairPanel add( Widget pTopWidget, Widget pBottomWidget ) {
18 - add( pTopWidget );
19 - add( pBottomWidget );
20 - return this;
21 - }
22 -
23 - @Override
24 - protected boolean aboutToAdopt( Widget pWidget, int pBeforeIndex ) {
25 - if ( pWidget instanceof Splitter ) {
26 - throw new IllegalArgumentException( "Attempt to add Splitter directly" );
27 - }
28 - if ( !getSizeableWidget( pWidget ).getHeightHelper().isStretchable() ) {
29 - throw new IllegalArgumentException( "Attempt to add widget to Vertical Split Pair Panel that does NOT support Vertical Stretchability" );
30 - }
31 - if ( !isOur( pWidget ) && (getWidgetCount() == 3) ) {
32 - throw new IllegalArgumentException( "Vertical Split Pair Panel only supports TWO Vertical Stretchables" );
33 - }
34 - return super.aboutToAdopt( pWidget, pBeforeIndex );
35 - }
36 -
37 - @Override
38 - protected void justAdopted( Widget pWidget, int pWidgetIndex ) {
39 - super.justAdopted( pWidget, pWidgetIndex );
40 -
41 - // Since we only support 2 real widgets, they could be disordered in regards to the splitter
42 - dropSplitters();
43 - if ( getWidgetCount() == 2 ) {
44 - LLadopt( createSplitter( 1 ), 1 );
45 - }
46 - }
47 -
48 - @Override
49 - protected void justDisowned( Widget pWidget, int pWidgetIndex ) {
50 - super.justDisowned( pWidget, pWidgetIndex );
51 -
52 - // Since we only support 2 real widgets, any disowned should remove the splitter
53 - dropSplitters();
54 - }
55 -
56 - private void dropSplitters() {
57 - for ( int i = getWidgetCount(); --i >= 0; ) {
58 - Widget widget = getWidget( i );
59 - if ( widget instanceof Splitter ) {
60 - LLdisown( widget, i );
61 - }
62 - }
63 - }
64 -
65 - protected Widget createSplitter( int pIndex ) {
66 - Splitter result = new Splitter( "litesoft-SplitterForVerticalPair" );
67 - result.stretchableHorizontally();
68 - mDragger = new VerticalSplitterDragger( this, pIndex );
69 - result.addController( new DragController( new MousePerformanceFilter( new MouseDragHandler( mDragger ) ) ) );
70 - return result;
71 - }
72 -
73 - private class VerticalSplitterDragger extends AbstractSplitterDragger {
74 - public VerticalSplitterDragger( AbstractSizeableOneDimensionalPanel panel, int pIndex ) {
75 - super( panel, pIndex );
76 - }
77 -
78 - @Override
79 - protected boolean dragBy( int pDeltaX, int pDeltaY ) {
80 - return adjustSizesBy( getSizeableAt( mIndex - 1 ).getHeightHelper(), //
81 - getSizeableAt( mIndex + 1 ).getHeightHelper(), //
82 - pDeltaY );
83 - }
84 - }
85 -
86 - @Override
87 - public void setWidth( String width ) {
88 - super.setWidth( width ); // for stacktrace Debugging
89 - }
90 -
91 - @Override
92 - public void setHeight( String height ) {
93 - super.setHeight( height ); // for stacktrace Debugging
94 - }
95 -
96 - private boolean mFavorFirstWidget;
97 -
98 - protected void setFavorFirstWidget() {
99 - mFavorFirstWidget = true;
100 - }
101 -
102 - public boolean setFirstWidgetHeight( int pPixels ) {
103 - if ( (pPixels > 20) && anyChildren() ) {
104 - int zDimension = getHeightHelper().getDimension();
105 - if ( (zDimension > 20) && (zDimension != pPixels) ) {
106 - mDragger.dragBy( 0, pPixels - zDimension );
107 - return true;
108 - }
109 - }
110 - return false;
111 - }
112 -
113 - @Override
114 - protected void distributeToChildrenChangedHeight() {
115 - if ( anyChildren() ) {
116 - getHelper().distributeDimensionToChild( this, getHeightHelper(), mFavorFirstWidget ? getFirstWidget() : getLastWidget() );
117 - }
118 - }
119 - }
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.nonpublic.external.*;
5 +
6 + import com.google.gwt.user.client.ui.*;
7 +
8 + public abstract class AbstractSizeableVerticalSplitPairPanel extends AbstractSizeableVerticalPanel {
9 + private VerticalSplitterDragger mDragger;
10 +
11 + @Override
12 + protected void initialize() {
13 + super.initialize();
14 + LLstretchableVertically();
15 + }
16 +
17 + public AbstractSizeableVerticalSplitPairPanel add( Widget pTopWidget, Widget pBottomWidget ) {
18 + add( pTopWidget );
19 + add( pBottomWidget );
20 + return this;
21 + }
22 +
23 + @Override
24 + protected boolean aboutToAdopt( Widget pWidget, int pBeforeIndex ) {
25 + if ( pWidget instanceof Splitter ) {
26 + throw new IllegalArgumentException( "Attempt to add Splitter directly" );
27 + }
28 + if ( !getSizeableWidget( pWidget ).getHeightHelper().isStretchable() ) {
29 + throw new IllegalArgumentException( "Attempt to add widget to Vertical Split Pair Panel that does NOT support Vertical Stretchability" );
30 + }
31 + if ( !isOur( pWidget ) && (getWidgetCount() == 3) ) {
32 + throw new IllegalArgumentException( "Vertical Split Pair Panel only supports TWO Vertical Stretchables" );
33 + }
34 + return super.aboutToAdopt( pWidget, pBeforeIndex );
35 + }
36 +
37 + @Override
38 + protected void justAdopted( Widget pWidget, int pWidgetIndex ) {
39 + super.justAdopted( pWidget, pWidgetIndex );
40 +
41 + // Since we only support 2 real widgets, they could be disordered in regards to the splitter
42 + dropSplitters();
43 + if ( getWidgetCount() == 2 ) {
44 + LLadopt( createSplitter( 1 ), 1 );
45 + }
46 + }
47 +
48 + @Override
49 + protected void justDisowned( Widget pWidget, int pWidgetIndex ) {
50 + super.justDisowned( pWidget, pWidgetIndex );
51 +
52 + // Since we only support 2 real widgets, any disowned should remove the splitter
53 + dropSplitters();
54 + }
55 +
56 + private void dropSplitters() {
57 + for ( int i = getWidgetCount(); --i >= 0; ) {
58 + Widget widget = getWidget( i );
59 + if ( widget instanceof Splitter ) {
60 + LLdisown( widget, i );
61 + }
62 + }
63 + }
64 +
65 + protected Widget createSplitter( int pIndex ) {
66 + Splitter result = new Splitter( "litesoft-SplitterForVerticalPair" );
67 + result.stretchableHorizontally();
68 + mDragger = new VerticalSplitterDragger( this, pIndex );
69 + result.addController( new DragController( new MousePerformanceFilter( new MouseDragHandler( mDragger ) ) ) );
70 + return result;
71 + }
72 +
73 + private class VerticalSplitterDragger extends AbstractSplitterDragger {
74 + public VerticalSplitterDragger( AbstractSizeableOneDimensionalPanel panel, int pIndex ) {
75 + super( panel, pIndex );
76 + }
77 +
78 + @Override
79 + protected boolean dragBy( int pDeltaX, int pDeltaY ) {
80 + return adjustSizesBy( getSizeableAt( mIndex - 1 ).getHeightHelper(), //
81 + getSizeableAt( mIndex + 1 ).getHeightHelper(), //
82 + pDeltaY );
83 + }
84 + }
85 +
86 + @Override
87 + public void setWidth( String width ) {
88 + super.setWidth( width ); // for stacktrace Debugging
89 + }
90 +
91 + @Override
92 + public void setHeight( String height ) {
93 + super.setHeight( height ); // for stacktrace Debugging
94 + }
95 +
96 + private boolean mFavorFirstWidget;
97 +
98 + protected void setFavorFirstWidget() {
99 + mFavorFirstWidget = true;
100 + }
101 +
102 + public boolean setFirstWidgetHeight( int pPixels ) {
103 + if ( (pPixels > 20) && anyChildren() ) {
104 + int zDimension = getHeightHelper().getDimension();
105 + if ( (zDimension > 20) && (zDimension != pPixels) ) {
106 + mDragger.dragBy( 0, pPixels - zDimension );
107 + return true;
108 + }
109 + }
110 + return false;
111 + }
112 +
113 + @Override
114 + protected void distributeToChildrenChangedHeight() {
115 + if ( anyChildren() ) {
116 + getHelper().distributeDimensionToChild( this, getHeightHelper(), mFavorFirstWidget ? getFirstWidget() : getLastWidget() );
117 + }
118 + }
119 + }