Update of /cvsroot/synclast/client/src/com/synclast/ui
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv18107/src/com/synclast/ui
Modified Files:
BoxContainer.java Container.java FlowContainer.java
TableContainer.java
Log Message:
Fixed size fixes. Containers now always respect the values set in setFixedSize(width, height).
BoxContainer, FlowContainer, and TableContainer have all been modded to properly respect the fixedW and fixedH varaibles.
Container now calls layout when setFixedSize(width, height) is called.
Added a FixedSizeMIDlet to examples, and modded the jad and MANIFEST to expose it. This MIDlet is ugly, but demonstrates proper function. Without these changes, the widgets only draw themselves in the area defined by fixedW and fixedH, but leave their full amount of space around (coded the midlet before the changes to verify this :)
Index: FlowContainer.java
===================================================================
RCS file: /cvsroot/synclast/client/src/com/synclast/ui/FlowContainer.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** FlowContainer.java 18 Sep 2006 07:59:05 -0000 1.11
--- FlowContainer.java 18 Sep 2006 11:31:26 -0000 1.12
***************
*** 134,139 ****
}
} // for each widget
! w += 2 * getTotalInset();
! h += 2 * getTotalInset();
}
public String getStyleName() {
--- 134,144 ----
}
} // for each widget
! if(fixedW != 0) {
! w = fixedW;
! h = fixedH;
! } else {
! w += 2 * getTotalInset();
! h += 2 * getTotalInset();
! }
}
public String getStyleName() {
Index: BoxContainer.java
===================================================================
RCS file: /cvsroot/synclast/client/src/com/synclast/ui/BoxContainer.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** BoxContainer.java 18 Sep 2006 07:59:05 -0000 1.15
--- BoxContainer.java 18 Sep 2006 11:31:26 -0000 1.16
***************
*** 175,179 ****
nextX = 0;
nextY = 0;
! w = h = 2 * getTotalInset();
int size = widgets.size();
--- 175,184 ----
nextX = 0;
nextY = 0;
! if(fixedW != 0) {
! w = fixedW;
! h = fixedH;
! } else {
! w = h = 2 * getTotalInset();
! }
int size = widgets.size();
***************
*** 223,232 ****
private void alterSize(Widget widget) {
! if(orientation == HORIZONTAL) {
! w += widget.w;
! h = Math.max(h, widget.h + 2 * getTotalInset());
! } else {
! w = Math.max(w, widget.w + 2 * getTotalInset());
! h += widget.h;
}
}
--- 228,239 ----
private void alterSize(Widget widget) {
! if(fixedW == 0) {
! if(orientation == HORIZONTAL) {
! w += widget.w;
! h = Math.max(h, widget.h + 2 * getTotalInset());
! } else {
! w = Math.max(w, widget.w + 2 * getTotalInset());
! h += widget.h;
! }
}
}
Index: TableContainer.java
===================================================================
RCS file: /cvsroot/synclast/client/src/com/synclast/ui/TableContainer.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** TableContainer.java 18 Sep 2006 07:59:05 -0000 1.6
--- TableContainer.java 18 Sep 2006 11:31:26 -0000 1.7
***************
*** 182,194 ****
// TODO allow borders, spacing, etc.
// This part turns columnWidths/columnHeights into absolute positions (running totals).
! w = h = 2 * getTotalInset();
! for (int x = 1; x < cols; x++) {
! columnWidths[x] = columnWidths[x - 1] + columnWidths[x];
! }
! w += columnWidths[cols - 1];
! for (int y = 1; y < rows; y++) {
! rowHeights[y] = rowHeights[y - 1] + rowHeights[y];
}
- h += rowHeights[rows - 1];
int xpos = 0;
--- 182,199 ----
// TODO allow borders, spacing, etc.
// This part turns columnWidths/columnHeights into absolute positions (running totals).
! if(fixedW != 0) {
! w = fixedW;
! h = fixedH;
! } else {
! w = h = 2 * getTotalInset();
! for (int x = 1; x < cols; x++) {
! columnWidths[x] = columnWidths[x - 1] + columnWidths[x];
! }
! w += columnWidths[cols - 1];
! for (int y = 1; y < rows; y++) {
! rowHeights[y] = rowHeights[y - 1] + rowHeights[y];
! }
! h += rowHeights[rows - 1];
}
int xpos = 0;
Index: Container.java
===================================================================
RCS file: /cvsroot/synclast/client/src/com/synclast/ui/Container.java,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -d -r1.37 -r1.38
*** Container.java 18 Sep 2006 07:59:05 -0000 1.37
--- Container.java 18 Sep 2006 11:31:26 -0000 1.38
***************
*** 70,73 ****
--- 70,78 ----
this.fixedW = width;
this.fixedH = height;
+ //need to call layout after this since our size most likely changed
+ //expensive but necessary
+ if(getContext() != null) {
+ layout();
+ }
}
|