Subversion Repository Public Repository

litesoft

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

Diff revisions: vs.
  @@ -1,94 +1,94 @@
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.commonfoundation.typeutils.*;
5 -
6 - import com.google.gwt.user.client.*;
7 - import com.google.gwt.user.client.ui.*;
8 -
9 - public class TwoDimensionalChildHelper {
10 - private Element mTBody;
11 - private int mColsPerRow;
12 - private Cell[] mEmptyRow;
13 - private Row[] mRows = NO_ROWS;
14 -
15 - public TwoDimensionalChildHelper( Element pTBody, int pColsPerRow ) {
16 - Objects.assertNotNull( "TBODY", mTBody = pTBody );
17 - if ( (mColsPerRow = pColsPerRow) < 1 ) {
18 - throw new IllegalArgumentException( "Must have at least 1 column, but was given: " + pColsPerRow );
19 - }
20 - }
21 -
22 - public void add( Widget pWidget ) {
23 - if ( pWidget != null ) {
24 - Cell zCell = findEmptyCell();
25 - }
26 - }
27 -
28 - private Cell findEmptyCell() {
29 - return null; // todo...
30 - }
31 -
32 - private Cell getCell( int pRow, int pCol ) {
33 - return null; // todo...
34 - }
35 -
36 - private class Row {
37 - private int mIndex;
38 - private Element mTR;
39 - private Cell[] mCells;
40 -
41 - public Row( int pIndex ) {
42 - mIndex = pIndex;
43 - DOM.appendChild( mTBody, mTR = DOM.createTR() );
44 - mCells = new Cell[mColsPerRow];
45 - for ( int i = 0; i < mCells.length; i++ ) {
46 - mCells[i] = new Cell( this, i );
47 - }
48 - }
49 -
50 - public int getIndex() {
51 - return mIndex;
52 - }
53 -
54 - public Element getTR() {
55 - return mTR;
56 - }
57 - }
58 -
59 - private class Cell {
60 - private Row mRow;
61 - private int mIndex;
62 - private int mAdditionalRightCells = 0;
63 - private int mAdditionalDownCells = 0;
64 - private Cell mSpannedFrom = null;
65 - private Element mTD = null;
66 - private Widget mContent = null;
67 -
68 - public Cell( Row pRow, int pIndex ) {
69 - mRow = pRow;
70 - mIndex = pIndex;
71 - int zRowIndex = mRow.getIndex();
72 - if ( zRowIndex != 0 ) {
73 - Cell zPotentialSpanFromCell = getCell( zRowIndex - 1, mIndex );
74 - while ( zPotentialSpanFromCell.mSpannedFrom != null ) {
75 - zPotentialSpanFromCell = zPotentialSpanFromCell.mSpannedFrom;
76 - }
77 - if ( zPotentialSpanFromCell.coverageIncludes( zRowIndex, pIndex ) ) {
78 - mSpannedFrom = zPotentialSpanFromCell;
79 - }
80 - }
81 - }
82 -
83 - public Row getRow() {
84 - return mRow;
85 - }
86 -
87 - private boolean coverageIncludes( int pRow, int pCol ) {
88 - int zRowIndex = mRow.getIndex();
89 - return (zRowIndex <= pRow) && (pRow <= (zRowIndex + mAdditionalDownCells)) && (mIndex <= pCol) && (pCol <= (mIndex + mAdditionalRightCells));
90 - }
91 - }
92 -
93 - private static final Row[] NO_ROWS = new Row[0];
94 - }
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.commonfoundation.base.*;
5 +
6 + import com.google.gwt.user.client.*;
7 + import com.google.gwt.user.client.ui.*;
8 +
9 + public class TwoDimensionalChildHelper {
10 + private Element mTBody;
11 + private int mColsPerRow;
12 + private Cell[] mEmptyRow;
13 + private Row[] mRows = NO_ROWS;
14 +
15 + public TwoDimensionalChildHelper( Element pTBody, int pColsPerRow ) {
16 + Confirm.isNotNull( "TBODY", mTBody = pTBody );
17 + if ( (mColsPerRow = pColsPerRow) < 1 ) {
18 + throw new IllegalArgumentException( "Must have at least 1 column, but was given: " + pColsPerRow );
19 + }
20 + }
21 +
22 + public void add( Widget pWidget ) {
23 + if ( pWidget != null ) {
24 + Cell zCell = findEmptyCell();
25 + }
26 + }
27 +
28 + private Cell findEmptyCell() {
29 + return null; // todo...
30 + }
31 +
32 + private Cell getCell( int pRow, int pCol ) {
33 + return null; // todo...
34 + }
35 +
36 + private class Row {
37 + private int mIndex;
38 + private Element mTR;
39 + private Cell[] mCells;
40 +
41 + public Row( int pIndex ) {
42 + mIndex = pIndex;
43 + DOM.appendChild( mTBody, mTR = DOM.createTR() );
44 + mCells = new Cell[mColsPerRow];
45 + for ( int i = 0; i < mCells.length; i++ ) {
46 + mCells[i] = new Cell( this, i );
47 + }
48 + }
49 +
50 + public int getIndex() {
51 + return mIndex;
52 + }
53 +
54 + public Element getTR() {
55 + return mTR;
56 + }
57 + }
58 +
59 + private class Cell {
60 + private Row mRow;
61 + private int mIndex;
62 + private int mAdditionalRightCells = 0;
63 + private int mAdditionalDownCells = 0;
64 + private Cell mSpannedFrom = null;
65 + private Element mTD = null;
66 + private Widget mContent = null;
67 +
68 + public Cell( Row pRow, int pIndex ) {
69 + mRow = pRow;
70 + mIndex = pIndex;
71 + int zRowIndex = mRow.getIndex();
72 + if ( zRowIndex != 0 ) {
73 + Cell zPotentialSpanFromCell = getCell( zRowIndex - 1, mIndex );
74 + while ( zPotentialSpanFromCell.mSpannedFrom != null ) {
75 + zPotentialSpanFromCell = zPotentialSpanFromCell.mSpannedFrom;
76 + }
77 + if ( zPotentialSpanFromCell.coverageIncludes( zRowIndex, pIndex ) ) {
78 + mSpannedFrom = zPotentialSpanFromCell;
79 + }
80 + }
81 + }
82 +
83 + public Row getRow() {
84 + return mRow;
85 + }
86 +
87 + private boolean coverageIncludes( int pRow, int pCol ) {
88 + int zRowIndex = mRow.getIndex();
89 + return (zRowIndex <= pRow) && (pRow <= (zRowIndex + mAdditionalDownCells)) && (mIndex <= pCol) && (pCol <= (mIndex + mAdditionalRightCells));
90 + }
91 + }
92 +
93 + private static final Row[] NO_ROWS = new Row[0];
94 + }