|
From: Harry E. <har...@us...> - 2006-09-18 11:31:29
|
Update of /cvsroot/synclast/client/examples/SynclastUIDemo/src In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv18107/examples/SynclastUIDemo/src Added Files: FixedSizeMIDlet.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 :) --- NEW FILE: FixedSizeMIDlet.java --- import com.synclast.*; import com.synclast.ui.*; import javax.microedition.lcdui.*; public class FixedSizeMIDlet extends BaseMIDlet { public Canvas createCanvas() { StyleSheet styleSheet = new StyleSheet("label { inset-width: 0; border-width: 1; border-color: 0x000000; }\n.title { font-size: small; font-style: italic; align: right; }"); //what it would look like normally BoxContainer before = new BoxContainer(Graphics.LEFT); before.add(new Label("Simple Label 1")); before.add(new Label("Simple Label 2")); before.set(before.BACKGROUND_COLOR, Color.LIGHT_GRAY); //what it looks like with fixed size BoxContainer after = new BoxContainer(Graphics.LEFT); after.add(new Label("Simple Label 1")); after.add(new Label("Simple Lable 2")); after.set(after.BACKGROUND_COLOR, Color.LIGHT_GRAY); after.setFixedSize(30, 25); TableContainer tBefore = new TableContainer(); tBefore.add(new Label("Cell 1")); tBefore.add(new Label("Cell 2")); tBefore.nextRow(); tBefore.add(new Label("Cell 3")); tBefore.add(new Label("Cell 4")); tBefore.nextRow(); tBefore.set(tBefore.BACKGROUND_COLOR, Color.LIGHT_GRAY); TableContainer tAfter = new TableContainer(); tAfter.add(new Label("Cell 1")); tAfter.add(new Label("Cell 2")); tAfter.nextRow(); tAfter.add(new Label("Cell 3")); tAfter.add(new Label("Cell 4")); tAfter.nextRow(); tAfter.set(tAfter.BACKGROUND_COLOR, Color.LIGHT_GRAY); tAfter.setFixedSize(30, 25); //Flow Containers FlowContainer fBefore = new FlowContainer(Graphics.TOP); fBefore.add(new Label("Item 1")); fBefore.add(new Label("Item 2")); fBefore.nextRow(); fBefore.add(new Label("Next Row 3")); fBefore.set(fBefore.BACKGROUND_COLOR, Color.LIGHT_GRAY); FlowContainer fAfter = new FlowContainer(Graphics.TOP); fAfter.add(new Label("Item 1")); fAfter.add(new Label("Item 2")); fAfter.nextRow(); fAfter.add(new Label("Next Row 3")); fAfter.set(fAfter.BACKGROUND_COLOR, Color.LIGHT_GRAY); fAfter.setFixedSize(30, 25); //now something to hold this all, and show what's going on TableContainer outer = new TableContainer(); outer.set(outer.BACKGROUND_COLOR, 0x99ccff); outer.add(new Label("Box Before Fixed Size").setClassStyleName("title")); outer.add(before); outer.nextRow(); outer.add(new ColoredWidget(5, 5).set(ColoredWidget.BACKGROUND_COLOR, Color.RED)); outer.add(new ColoredWidget(5, 5).set(ColoredWidget.BACKGROUND_COLOR, Color.RED)); outer.nextRow(); outer.add(new Label("Box FixedSize w=30 h=25").setClassStyleName("title")); outer.add(after); outer.nextRow(); outer.add(new ColoredWidget(5, 5).set(ColoredWidget.BACKGROUND_COLOR, Color.RED)); outer.add(new ColoredWidget(5, 5).set(ColoredWidget.BACKGROUND_COLOR, Color.RED)); outer.nextRow(); outer.add(new Label("Table Before Fixed Size").setClassStyleName("title")); outer.add(tBefore); outer.nextRow(); outer.add(new ColoredWidget(5, 5).set(ColoredWidget.BACKGROUND_COLOR, Color.RED)); outer.add(new ColoredWidget(5, 5).set(ColoredWidget.BACKGROUND_COLOR, Color.RED)); outer.nextRow(); outer.add(new Label("Table FixedSize w=30 h=25").setClassStyleName("title")); outer.add(tAfter); outer.nextRow(); outer.add(new ColoredWidget(5, 5).set(ColoredWidget.BACKGROUND_COLOR, Color.RED)); outer.add(new ColoredWidget(5, 5).set(ColoredWidget.BACKGROUND_COLOR, Color.RED)); outer.nextRow(); outer.add(new Label("Flow Before Fixed Size").setClassStyleName("title")); outer.add(fBefore); outer.nextRow(); outer.add(new ColoredWidget(5, 5).set(ColoredWidget.BACKGROUND_COLOR, Color.RED)); outer.add(new ColoredWidget(5, 5).set(ColoredWidget.BACKGROUND_COLOR, Color.RED)); outer.nextRow(); outer.add(new Label("Flow FixedSize w=30 h=25").setClassStyleName("title")); outer.add(fAfter); outer.nextRow(); outer.add(new ColoredWidget(5, 5).set(ColoredWidget.BACKGROUND_COLOR, Color.RED)); outer.add(new ColoredWidget(5, 5).set(ColoredWidget.BACKGROUND_COLOR, Color.RED)); outer.nextRow(); outer.add(new Label("Red Squares are spacers").setClassStyleName("title")); outer.add(new Label("Done")); outer.nextRow(); BoxContainer main = new BoxContainer(Graphics.LEFT); main.add(outer); return new SynclastCanvas(main, styleSheet); } } |