|
From: Harry E. <har...@us...> - 2006-09-18 07:59:08
|
Update of /cvsroot/synclast/client/examples/SynclastUIDemo/src In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv31295/examples/SynclastUIDemo/src Modified Files: FormMIDlet.java RasterWidget.java TableMIDlet.java WallpaperMIDlet.java Log Message: This is a complete revamp of the style mechanism in Synclast. The new mechanism works kind alike CSS layer 1 applied to widgets. You create a stylesheet with a string of text that looks like a css file (see examples/SynclastUIDemo/res/*.css for examples). You set the Stylesheet on a canvas. Widgets added to that canvas will automatically pick up the styling information assoiciated with that canvas. Styles cascade according to containment, ie, if a widget doe not have a background color style but its parent does, it will get the same background. Some styles cascade, and some do not. Styles only set the "default" values for a widget. Basically, calling set() to set a widget property wil ALWAYS override any value in the stylesheet. Stylesheets can be set on a canvas before or after it is constructed, and all widgets should end up properly getting styled in either case. This means you can also change the stylesheet on a canvas at any time you want. Since Stylesheets are just parsed from a string, they can come from anywhere (the jar, constructed on the fly, downloaded from the network, etc). Though Styles are designed to be efficient, treat them with care since very complicated pages might need non trivial time to derive all their values. Style documentation on each widget still needs to be added, along with default value and cascade information. Right now, the code IS the documentation in this regard. Please report bugs as you find them. Index: FormMIDlet.java =================================================================== RCS file: /cvsroot/synclast/client/examples/SynclastUIDemo/src/FormMIDlet.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** FormMIDlet.java 30 Jan 2004 03:43:49 -0000 1.5 --- FormMIDlet.java 18 Sep 2006 07:59:04 -0000 1.6 *************** *** 9,19 **** public class FormMIDlet extends BaseMIDlet { public Canvas createCanvas() { ! StyleSheet local = new StyleSheet() ! .setStyle(Input._class, Input.BACKGROUND_COLOR, Color.LIGHT_GRAY) ! .setStyle(Checkbox._class, Checkbox.BACKGROUND_COLOR, Color.LIGHT_GRAY) ! .setStyle(Label._class, Label.FOREGROUND_COLOR, Color.WHITE) ! .setStyle(Button._class, Button.BACKGROUND_COLOR, Color.LIGHT_GRAY) ! .setStyle(Button._class, Label.FOREGROUND_COLOR, Color.BLACK); ! FlowContainer flow = new FlowContainer(Graphics.TOP); flow.add(new ColoredWidget(1,5)); --- 9,13 ---- public class FormMIDlet extends BaseMIDlet { public Canvas createCanvas() { ! StyleSheet local = new StyleSheet(getClass(), "/form_midlet.css"); FlowContainer flow = new FlowContainer(Graphics.TOP); flow.add(new ColoredWidget(1,5)); Index: TableMIDlet.java =================================================================== RCS file: /cvsroot/synclast/client/examples/SynclastUIDemo/src/TableMIDlet.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TableMIDlet.java 28 Jan 2004 05:11:19 -0000 1.4 --- TableMIDlet.java 18 Sep 2006 07:59:04 -0000 1.5 *************** *** 14,21 **** public Canvas createCanvas() { ! StyleSheet local = new StyleSheet() ! .setStyle(TableContainer._class, TableContainer.BORDER_WIDTH, 1) ! .setStyle(TableContainer._class, TableContainer.BORDER_COLOR, Color.BLACK); ! TableContainer fixedTable = createFixedTable(); TableContainer dynamicTable = createDynamicTable(); --- 14,18 ---- public Canvas createCanvas() { ! StyleSheet local = new StyleSheet(getClass(), "/table_midlet.css"); TableContainer fixedTable = createFixedTable(); TableContainer dynamicTable = createDynamicTable(); Index: RasterWidget.java =================================================================== RCS file: /cvsroot/synclast/client/examples/SynclastUIDemo/src/RasterWidget.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RasterWidget.java 5 Feb 2004 02:08:01 -0000 1.3 --- RasterWidget.java 18 Sep 2006 07:59:04 -0000 1.4 *************** *** 1,5 **** import javax.microedition.lcdui.Graphics; import java.util.Random; - import com.synclast.StyleSheet; import com.synclast.SynclastTask; import com.synclast.ui.Color; --- 1,4 ---- *************** *** 31,35 **** w, h); for (int i = 0; i < h; i++) { ! graphics.setColor(random.nextInt() & properties[FOREGROUND_COLOR]); graphics.drawRect(0, i, w, i); } --- 30,34 ---- w, h); for (int i = 0; i < h; i++) { ! graphics.setColor(random.nextInt() & properties[FOREGROUND_COLOR.getId()]); graphics.drawRect(0, i, w, i); } Index: WallpaperMIDlet.java =================================================================== RCS file: /cvsroot/synclast/client/examples/SynclastUIDemo/src/WallpaperMIDlet.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WallpaperMIDlet.java 19 Sep 2003 06:53:48 -0000 1.2 --- WallpaperMIDlet.java 18 Sep 2006 07:59:04 -0000 1.3 *************** *** 11,15 **** canvas.add(marble); ColoredWidget checker = new ColoredWidget(canvas.getWidth(), canvas.getHeight() / 2); ! checker.setPosition(0, canvas.getHeight() / 2, Graphics.TOP | Graphics.LEFT); checker.setBackgroundImage(getImage("/checker.png")); --- 11,15 ---- canvas.add(marble); ColoredWidget checker = new ColoredWidget(canvas.getWidth(), canvas.getHeight() / 2); ! checker.setPosition(0, canvas.getHeight() / 2, Graphics.BOTTOM | Graphics.LEFT); checker.setBackgroundImage(getImage("/checker.png")); |