You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(99) |
Jul
(26) |
Aug
(23) |
Sep
(23) |
Oct
|
Nov
|
Dec
(6) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(18) |
Feb
(12) |
Mar
(5) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(9) |
Oct
(17) |
Nov
|
Dec
|
| 2005 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
(3) |
Jul
(2) |
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
(1) |
| 2006 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(12) |
Oct
(3) |
Nov
(5) |
Dec
|
| 2007 |
Jan
|
Feb
|
Mar
(1) |
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Wes B. <wb...@us...> - 2007-04-19 23:04:01
|
Update of /cvsroot/synclast/client/src/com/synclast/ui In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv17502 Modified Files: WordWrapLabel.java Log Message: Was not properly accounting for inset width (need to multiply by two to get both left and right sides). Index: WordWrapLabel.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/WordWrapLabel.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WordWrapLabel.java 1 Nov 2006 23:04:03 -0000 1.3 --- WordWrapLabel.java 19 Apr 2007 23:03:57 -0000 1.4 *************** *** 21,25 **** import javax.microedition.lcdui.Font; - import javax.microedition.lcdui.Graphics; /** --- 21,24 ---- *************** *** 85,93 **** public void validate() { // If in a fixed-width container, word wrap if necessary ! if ((container.fixedW != 0) && ((x + getTotalInset() + w) > container.fixedW)) { StringBuffer buffer = new StringBuffer(originalText); ! int max = container.fixedW - getTotalInset(); // Time to wrap ! int xpos = x + getTotalInset(); int lastSpace = -1; char ch; --- 84,92 ---- public void validate() { // If in a fixed-width container, word wrap if necessary ! if ((container.fixedW != 0) && ((x + 2 * getTotalInset() + w) > container.fixedW)) { StringBuffer buffer = new StringBuffer(originalText); ! int max = container.fixedW - 2 * getTotalInset(); // Time to wrap ! int xpos = x + 2 * getTotalInset(); int lastSpace = -1; char ch; |
|
From: Wes B. <wb...@us...> - 2007-04-13 13:27:49
|
Update of /cvsroot/synclast/client In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv21895 Modified Files: CHANGES README Log Message: Updating changelog for snapshotting. Index: README =================================================================== RCS file: /cvsroot/synclast/client/README,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** README 19 Mar 2007 14:15:20 -0000 1.4 --- README 13 Apr 2007 13:27:34 -0000 1.5 *************** *** 38,44 **** 2) Pass -Dwtk.home=... to Ant. Works like the above. ! The build script has been designed for use with Sun's Wireless ToolKit ! 1.0.4, 2.0 and 2.1, and should work with many OEM vendors' versions as ! well. To build synclast-ui.jar in the dist subdirectory, execute: --- 38,44 ---- 2) Pass -Dwtk.home=... to Ant. Works like the above. ! The build script has been designed for use with Sun's Wireless ToolKit ! (most recently tested with version 2.5), and should work with many OEM ! vendors' versions as well. To build synclast-ui.jar in the dist subdirectory, execute: *************** *** 52,56 **** Current platformName settings are: ! NokiaUI -- builds the SynclastFullCanvas class with the library API DOCUMENTATION --- 52,56 ---- Current platformName settings are: ! NokiaUI -- builds the SynclastFullCanvas class with the library API DOCUMENTATION *************** *** 100,109 **** individuals: ! Wes Biggs, Synclast ! Harry Evans, Synclast ! Fred Grott, ShareMe Technologies (http://www.freeroller.net/page/shareme/) If you'd like to contribute, please join us by subscribing to the synclast-devel mailing list. For details and subscription info, see http://sourceforge.net/mail/?group_id=83391. - --- 100,108 ---- individuals: ! Wes Biggs (project admin) ! Harry Evans (project admin) ! Fred Grott If you'd like to contribute, please join us by subscribing to the synclast-devel mailing list. For details and subscription info, see http://sourceforge.net/mail/?group_id=83391. Index: CHANGES =================================================================== RCS file: /cvsroot/synclast/client/CHANGES,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CHANGES 5 Feb 2004 01:55:07 -0000 1.3 --- CHANGES 13 Apr 2007 13:27:34 -0000 1.4 *************** *** 1,3 **** ! Current Version: 20040204 Snapshot Release This release adds the following features: --- 1,39 ---- ! Current Version: 20070413 Snapshot Release ! ! This release adds the following features: ! * A text-based stylesheet mechanism based on CSS. See the FormMIDlet ! example, and the com.synclast.StyleSheet and com.synclast.ui.Style ! classes. ! * Added method Container.replace(Widget, Widget). ! * Added method Container.removeAll(). ! * Added method Label.setText(String). ! * Blurring and refocusing on a Menu preserves the focused item. ! * Added method Menu.focus(int); ! * Added a WordWrapLabel widget that wraps text on whitespace. ! * Added a GridMenu widget for image-based menus. ! ! This release fixes the following bugs: ! ! * Several focus issues with Container were fixed, including an error ! condition resulting from the remove() function, an issue with focus ! passing back to the top of a Container, and an infinite loop with ! Containers that had no focusable items. ! * Menu.keyPressed() will ensure that the Menu is realigned before the ! event is fired. ! * The repaint() (no-arg) method for non-top-level Containers did not ! correctly translate coordinates. ! * Fixed a layout bug with BoxContainer and alignment center/forward. ! * Better support for fixed size containers. ! ! In addition: ! * The RadioButton drawing code has been updated to attempt to make it ! look a bit nicer. ! * Some new examples have been added. ! * The build script now looks for WTK_HOME, not J2ME_HOME, to align with ! other tools (e.g. Antenna). ! ! ------------------------------------------------------------------ ! ! Previous Version: 20040204 Snapshot Release This release adds the following features: |
|
From: Wes B. <wb...@us...> - 2007-03-19 14:16:42
|
Update of /cvsroot/synclast/client In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv4598 Modified Files: README build.xml Log Message: Change to use WTK_HOME instead of J2ME_HOME as the environment variable to align with other tools (Antenna, etc.) Index: README =================================================================== RCS file: /cvsroot/synclast/client/README,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** README 5 Feb 2004 01:55:07 -0000 1.3 --- README 19 Mar 2007 14:15:20 -0000 1.4 *************** *** 33,40 **** build script at it in a few different ways: ! 1) Set environment variable J2ME_HOME before invoking Ant. Ant will ! look for the MIDP libraries in $J2ME_HOME/lib. -or- ! 2) Pass -Dj2me.home=J2ME_HOME to Ant. Works like the above. The build script has been designed for use with Sun's Wireless ToolKit --- 33,40 ---- build script at it in a few different ways: ! 1) Set environment variable WTK_HOME before invoking Ant. Ant will ! look for the MIDP libraries in $WTK_HOME/lib. -or- ! 2) Pass -Dwtk.home=... to Ant. Works like the above. The build script has been designed for use with Sun's Wireless ToolKit Index: build.xml =================================================================== RCS file: /cvsroot/synclast/client/build.xml,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** build.xml 1 Oct 2004 21:24:52 -0000 1.19 --- build.xml 19 Mar 2007 14:15:20 -0000 1.20 *************** *** 4,10 **** Build file for Jakarta Ant 1.5 ! To invoke this script, set the environment variable J2ME_HOME to the top-level directory of your Sun or OEM-provided Wireless ToolKit or ! invoke ant with -Dj2me.home=... --> --- 4,10 ---- Build file for Jakarta Ant 1.5 ! To invoke this script, set the environment variable WTK_HOME to the top-level directory of your Sun or OEM-provided Wireless ToolKit or ! invoke ant with -Dwtk.home=... --> *************** *** 13,17 **** <property environment="env."/> <property name="app.name" value="synclast" /> ! <property name="j2me.home" value="${env.J2ME_HOME}"/> <property name="doc" value="docs"/> <property name="javadoc.path" value="javadoc.path"/> --- 13,17 ---- <property environment="env."/> <property name="app.name" value="synclast" /> ! <property name="wtk.home" value="${env.WTK_HOME}"/> <property name="doc" value="docs"/> <property name="javadoc.path" value="javadoc.path"/> *************** *** 19,27 **** <path id="wtk.path"> <!-- These exist in WTK 2.1 --> ! <pathelement location="${j2me.home}/lib/cldcapi10.jar" /> ! <!-- <pathelement location="${j2me.home}/lib/midpapi10.jar" /> --> ! <pathelement location="${j2me.home}/lib/midpapi20.jar" /> <!-- This exists in WTK 1.04 --> ! <pathelement location="${j2me.home}/lib/midpapi.zip" /> <!-- This is where you can put any OEM-specific JARs --> <fileset dir="ext"> --- 19,27 ---- <path id="wtk.path"> <!-- These exist in WTK 2.1 --> ! <pathelement location="${wtk.home}/lib/cldcapi10.jar" /> ! <!-- <pathelement location="${wtk.home}/lib/midpapi10.jar" /> --> ! <pathelement location="${wtk.home}/lib/midpapi20.jar" /> <!-- This exists in WTK 1.04 --> ! <pathelement location="${wtk.home}/lib/midpapi.zip" /> <!-- This is where you can put any OEM-specific JARs --> <fileset dir="ext"> *************** *** 73,76 **** --- 73,77 ---- <target name="compile" description="Compile Synclast UI classes"> + <mkdir dir="ext" /> <mkdir dir="build" /> <copy todir="build"> *************** *** 98,107 **** <target name="demo" description="Copy demo application to WTK apps directory" depends="dist"> ! <copy todir="${j2me.home}/apps"> <fileset dir="examples"> <include name="SynclastUIDemo/**" /> </fileset> </copy> ! <copy todir="${j2me.home}/apps/SynclastUIDemo/lib" file="dist/synclast-ui.jar" /> </target> --- 99,108 ---- <target name="demo" description="Copy demo application to WTK apps directory" depends="dist"> ! <copy todir="${wtk.home}/apps"> <fileset dir="examples"> <include name="SynclastUIDemo/**" /> </fileset> </copy> ! <copy todir="${wtk.home}/apps/SynclastUIDemo/lib" file="dist/synclast-ui.jar" /> </target> |
|
From: Harry E. <har...@us...> - 2006-11-03 00:38:35
|
Update of /cvsroot/synclast/client/src/com/synclast/ui In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv28014 Modified Files: Button.java Log Message: Fixed the validate on button when it only has an image, so that it will not shrink below the image bounds. If it has text, regardless of background image status, it will always size to the text. Damn Neil, what more you want from me? Index: Button.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/Button.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Button.java 20 Sep 2006 12:19:52 -0000 1.14 --- Button.java 3 Nov 2006 00:38:26 -0000 1.15 *************** *** 98,100 **** --- 98,111 ---- return "button"; } + + /** + * If we have a background image, and no text, size to the size of the image, else size to the size of the text. This means that if you have a background Image and text, it will size to the text, not the image. C'est la vie. + */ + protected void validate() { + if(backgroundImage != null && text.length() == 0) { + invalid = false; + } else { + super.validate(); + } + } } |
|
From: Harry E. <har...@us...> - 2006-11-01 23:45:19
|
Update of /cvsroot/synclast/client/src/com/synclast/ui In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv20405 Modified Files: Widget.java Log Message: Kinda sorta fixed setPosition. The basic concept of this method is kinda broken, but this should fix it enough to get by with for now, until I can rip it out completely, and put in something better. Index: Widget.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/Widget.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** Widget.java 20 Sep 2006 12:19:53 -0000 1.25 --- Widget.java 1 Nov 2006 23:45:16 -0000 1.26 *************** *** 268,273 **** --- 268,284 ---- * cause the ALIGN value to be set to the value specified, as a side * effect of this call. + * Be careful, this method has issues, and a race condition. If it doesn't + * work as expected, you have been warned. + * TODO: Fix this method */ public void setPosition(int x, int y, int align) { + //Ugly hack to kinda make this whole method work. + //Not sure what can be done to make it work the way you would expect + //given that, if this widget (subclass) changes its size, all the math + //below will be completely invalid. + //TODO: Fix this crazy method to resemble proper functioning + if(invalid) { + validate(); + } set(ALIGN, align); if ((align & Graphics.LEFT) != 0) { |
|
From: Harry E. <har...@us...> - 2006-11-01 23:04:16
|
Update of /cvsroot/synclast/client/src/com/synclast/ui In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv3259 Modified Files: WordWrapLabel.java Log Message: Fixed a static initializer error having to do with stylesheets getting applied before text has been set. Hope this is the last of these. Also fixed an order of operation issue with stylesheets getting applied in one of the constructors. Index: WordWrapLabel.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/WordWrapLabel.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WordWrapLabel.java 18 Sep 2006 07:59:05 -0000 1.2 --- WordWrapLabel.java 1 Nov 2006 23:04:03 -0000 1.3 *************** *** 40,44 **** */ public WordWrapLabel(String text) { ! this(text, Font.getDefaultFont()); } --- 40,45 ---- */ public WordWrapLabel(String text) { ! super(text); ! originalText = text; } *************** *** 62,65 **** --- 63,71 ---- private void calcSize() { + //handle initialization by _class static variable + if(text == null) { + w = h = 0; + return; + } char[] fullText = text.toCharArray(); int startOfLine = 0; |
|
From: Harry E. <har...@us...> - 2006-11-01 23:01:57
|
Update of /cvsroot/synclast/client/src/com/synclast/ui In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv2539 Modified Files: Container.java Log Message: Container, like BoxContainer, FlowContainer, and TableContainer, now supports fixed size. Now Neil can stop complaining. Index: Container.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/Container.java,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** Container.java 3 Oct 2006 18:55:56 -0000 1.42 --- Container.java 1 Nov 2006 23:01:50 -0000 1.43 *************** *** 234,250 **** // Recalculate width and height w = h = 0; ! for (int i = widgets.size() - 1; i >= 0; --i) { ! Widget widget = (Widget) widgets.elementAt(i); ! if (fixedW != 0) { ! borderLayout(widget, fixedW, fixedH); ! } ! w = Math.max(w, widget.x + widget.w ); ! h = Math.max(h, widget.y + widget.h); } - int offset = 2 * getTotalInset(); - w += offset; - h += offset; } --- 234,255 ---- // Recalculate width and height w = h = 0; ! if(fixedW != 0) { ! w = fixedW; ! h = fixedH; ! } else { ! for (int i = widgets.size() - 1; i >= 0; --i) { ! Widget widget = (Widget) widgets.elementAt(i); ! /* if (fixedW != 0) { ! borderLayout(widget, fixedW, fixedH); ! }*/ ! w = Math.max(w, widget.x + widget.w ); ! h = Math.max(h, widget.y + widget.h); ! } ! int offset = 2 * getTotalInset(); ! w += offset; ! h += offset; } } |
|
From: Harry E. <har...@us...> - 2006-11-01 22:58:41
|
Update of /cvsroot/synclast/client/src/com/synclast/ui In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv1115 Modified Files: Label.java Log Message: Fixed copy paste bugs on Label style sheet names. Index: Label.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/Label.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Label.java 20 Sep 2006 12:19:53 -0000 1.18 --- Label.java 1 Nov 2006 22:58:37 -0000 1.19 *************** *** 33,40 **** Style.FONT_STYLE); protected static final Style FONT_FACE = ! new Style("font-size", -1, Style.CASCADE, Style.FONT_FACE); protected static final Style FONT_SIZE = ! new Style("font-face", -1, Style.CASCADE, Style.FONT_SIZE); --- 33,40 ---- Style.FONT_STYLE); protected static final Style FONT_FACE = ! new Style("font-face", -1, Style.CASCADE, Style.FONT_FACE); protected static final Style FONT_SIZE = ! new Style("font-size", -1, Style.CASCADE, Style.FONT_SIZE); |
|
From: Harry E. <har...@us...> - 2006-10-04 01:47:31
|
Update of /cvsroot/synclast/client/src/com/synclast/ui In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv26449 Modified Files: Container.java Log Message: It appears I missed a couple of cases when doing this patch. This now also handles the case where focussed is not the thing that was removed, but an item thats index will shift downwards from removing the widget under consideration. Index: Container.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/Container.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** Container.java 3 Oct 2006 10:11:06 -0000 1.40 --- Container.java 3 Oct 2006 18:37:30 -0000 1.41 *************** *** 335,341 **** } //fix focus if necessary ! if(index >= 0 && focused == index) { focused = -1; passFocus(1); } invalidate(); --- 335,345 ---- } //fix focus if necessary ! //if focussed is the widget removed or anything in widgets after us ! //we have to fix focus ! if(focused == index) { focused = -1; passFocus(1); + } else if(focused > index) { + focused--; } invalidate(); |
|
From: Harry E. <har...@us...> - 2006-10-04 01:42:32
|
Update of /cvsroot/synclast/client/src/com/synclast/ui In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv836 Modified Files: Container.java Log Message: And now replace works as well. Fiddling with the focussed pointer is such a pain. Perhaps this should be an object reference instead? But then we would have to make sure to free it, so that we didn't cause a memory leak. Hmmm..... Index: Container.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/Container.java,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** Container.java 3 Oct 2006 18:37:30 -0000 1.41 --- Container.java 3 Oct 2006 18:55:56 -0000 1.42 *************** *** 303,306 **** --- 303,309 ---- if (pos != -1) { widgets.insertElementAt(widget, pos); + if(focused >= pos) { + focused++; + } remove(old); } |
|
From: Harry E. <har...@us...> - 2006-10-04 01:42:10
|
Update of /cvsroot/synclast/client/src/com/synclast/ui In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv13816 Modified Files: Container.java Log Message: Fixed a major focus bug with remove. Basically, when a widget was removed from Container, the focusable count in container was being updated, but the focused index was not. If the widget that was removed was the one with focus, this would be a problem, since either a different widget or no widget would now be considered "focussed". If the widget was the last widget in the Container, or the widget that was after it in the Widget vector was not a KeyEventListener, calls that interact with focus, such as hideNotify(), would result in either a ArrayIndexOutOfBoundsException or a ClassCastException respectively. This was a hard bug to duplicate. This bug might also be present in the replace logic, where the new widget replacing the old widget is not a KeyEventListener, and the old one was, and had focus. I am still testing this case. Index: Container.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/Container.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** Container.java 20 Sep 2006 12:19:53 -0000 1.39 --- Container.java 3 Oct 2006 10:11:06 -0000 1.40 *************** *** 317,320 **** --- 317,322 ---- */ public void remove(Widget widget) { + //record index so we can fix focus later (if necessary) + int index = widgets.indexOf(widget); if(widgets.removeElement(widget)) { UIContext context = getContext(); *************** *** 332,335 **** --- 334,342 ---- setFocusable(-1); } + //fix focus if necessary + if(index >= 0 && focused == index) { + focused = -1; + passFocus(1); + } invalidate(); } |
|
From: Harry E. <har...@us...> - 2006-09-20 12:19:58
|
Update of /cvsroot/synclast/client/src/com/synclast/ui In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv17424/src/com/synclast/ui Modified Files: Button.java Checkbox.java ColoredWidget.java Container.java GridMenu.java Input.java Label.java Menu.java RadioButton.java Style.java SynclastCanvas.java Widget.java Log Message: New version of styles using applyStyleSheet instead of init. This saves a few nonsensical applications of the StyleSheet, and saves looking up the UIContext for every single style application, since the stylesheet is handed to the call instead. Index: Widget.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/Widget.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Widget.java 18 Sep 2006 11:06:53 -0000 1.24 --- Widget.java 20 Sep 2006 12:19:53 -0000 1.25 *************** *** 27,30 **** --- 27,31 ---- import com.synclast.Event; import com.synclast.Styled; + import com.synclast.StyleSheet; /** *************** *** 73,78 **** */ protected Widget() { ! init(); setBits = 0L; } --- 74,81 ---- */ protected Widget() { ! //set bits to 0 before calling init, so that widgets that set ! //non default values in their init call don't get their values wiped out setBits = 0L; + init(); } *************** *** 99,103 **** properties = new int [getPropertyCount()]; } ! ALIGN.set(this, Graphics.LEFT | Graphics.TOP); } --- 102,107 ---- properties = new int [getPropertyCount()]; } ! //would prefer to not call this here, except that applyStyleSheet causes the default values for styles to get set, and many widgets need them to be set, even before being added to a container, since they use these values for logic in other areas of the app. ! applyStyleSheet(findStyleSheet()); } *************** *** 188,197 **** * via the set() method. */ ! public void applyStyleSheet() {//StyleSheet sheet) { /* if (sheet != null) { sheet.applyTo(this); } else {*/ ! init(); ! setBits = 0L; // } invalidate(); --- 192,202 ---- * via the set() method. */ ! protected void applyStyleSheet(StyleSheet sheet) { ! ALIGN.set(this, Graphics.LEFT | Graphics.TOP, sheet); /* if (sheet != null) { sheet.applyTo(this); } else {*/ ! // init(); ! // setBits = 0L; // } invalidate(); *************** *** 350,357 **** (!classStyleName.equals(aStyleName))) { classStyleName = aStyleName; ! init(); } //just like set, allow this method to be chained return this; } } --- 355,372 ---- (!classStyleName.equals(aStyleName))) { classStyleName = aStyleName; ! applyStyleSheet(findStyleSheet()); } //just like set, allow this method to be chained return this; } + + protected StyleSheet findStyleSheet() { + if(container != null) { + UIContext context = container.getContext(); + if(context != null) { + return context.getStyleSheet(); + } + } + return null; + } } Index: SynclastCanvas.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/SynclastCanvas.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** SynclastCanvas.java 18 Sep 2006 07:59:05 -0000 1.24 --- SynclastCanvas.java 20 Sep 2006 12:19:53 -0000 1.25 *************** *** 107,111 **** // Apply the old stylesheet to the new container this.container = container; ! container.applyStyleSheet();//styleSheet); } --- 107,111 ---- // Apply the old stylesheet to the new container this.container = container; ! container.applyStyleSheet(styleSheet); } *************** *** 123,127 **** public void setStyleSheet(StyleSheet styleSheet) { this.styleSheet = styleSheet; ! container.applyStyleSheet();//styleSheet); } --- 123,127 ---- public void setStyleSheet(StyleSheet styleSheet) { this.styleSheet = styleSheet; ! container.applyStyleSheet(styleSheet); } Index: RadioButton.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/RadioButton.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** RadioButton.java 18 Sep 2006 07:59:05 -0000 1.10 --- RadioButton.java 20 Sep 2006 12:19:53 -0000 1.11 *************** *** 21,24 **** --- 21,25 ---- import com.synclast.Event; + import com.synclast.StyleSheet; import javax.microedition.lcdui.Graphics; *************** *** 51,60 **** } ! protected void init() { ! super.init(); ! BACKGROUND_COLOR.set(this, Color.LIGHT_GRAY); ! BORDER_COLOR.set(this, Color.BLACK); ! BORDER_ARC.set(this, 90); ! BORDER_WIDTH.set(this, 1); } --- 52,61 ---- } ! protected void applyStyleSheet(StyleSheet sheet) { ! super.applyStyleSheet(sheet); ! BACKGROUND_COLOR.set(this, Color.LIGHT_GRAY, sheet); ! BORDER_COLOR.set(this, Color.BLACK, sheet); ! BORDER_ARC.set(this, 90, sheet); ! BORDER_WIDTH.set(this, 1, sheet); } Index: Menu.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/Menu.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Menu.java 18 Sep 2006 07:59:05 -0000 1.20 --- Menu.java 20 Sep 2006 12:19:53 -0000 1.21 *************** *** 27,30 **** --- 27,31 ---- import com.synclast.Event; + import com.synclast.StyleSheet; import com.synclast.SynclastTask; *************** *** 127,145 **** private SynclastTask scrollTask; ! protected void init() { ! super.init(); ! SELECTED_COLOR.set(this, 0); ! ITEM_ALIGN.set(this, Graphics.HCENTER); ! SCROLL_DELAY.set(this, 2000); ! SCROLL_PERIOD.set(this, 50); ! int dFace = DEFAULT_FONT_FACE.get(this, Font.FACE_PROPORTIONAL); ! int dStyle = DEFAULT_FONT_STYLE.get(this, Font.STYLE_PLAIN); ! int dSize = DEFAULT_FONT_SIZE.get(this, Font.SIZE_MEDIUM); setDefault(DEFAULT_FONT, Style.getFontValue(Font.getFont(dFace, dStyle, dSize))); ! int sFace = DEFAULT_FONT_FACE.get(this, Font.FACE_PROPORTIONAL); ! int sStyle = DEFAULT_FONT_STYLE.get(this, Font.STYLE_BOLD); ! int sSize = DEFAULT_FONT_SIZE.get(this, Font.SIZE_MEDIUM); setDefault(SELECTED_FONT, Style.getFontValue(Font.getFont(sFace, sStyle, sSize))); ! INSET_WIDTH.set(this, 2); } --- 128,146 ---- private SynclastTask scrollTask; ! protected void applyStyleSheet(StyleSheet sheet) { ! super.applyStyleSheet(sheet); ! SELECTED_COLOR.set(this, 0, sheet); ! ITEM_ALIGN.set(this, Graphics.HCENTER, sheet); ! SCROLL_DELAY.set(this, 2000, sheet); ! SCROLL_PERIOD.set(this, 50, sheet); ! int dFace = DEFAULT_FONT_FACE.get(this, Font.FACE_PROPORTIONAL, sheet); ! int dStyle = DEFAULT_FONT_STYLE.get(this, Font.STYLE_PLAIN, sheet); ! int dSize = DEFAULT_FONT_SIZE.get(this, Font.SIZE_MEDIUM, sheet); setDefault(DEFAULT_FONT, Style.getFontValue(Font.getFont(dFace, dStyle, dSize))); ! int sFace = DEFAULT_FONT_FACE.get(this, Font.FACE_PROPORTIONAL, sheet); ! int sStyle = DEFAULT_FONT_STYLE.get(this, Font.STYLE_BOLD, sheet); ! int sSize = DEFAULT_FONT_SIZE.get(this, Font.SIZE_MEDIUM, sheet); setDefault(SELECTED_FONT, Style.getFontValue(Font.getFont(sFace, sStyle, sSize))); ! INSET_WIDTH.set(this, 2, sheet); } Index: Button.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/Button.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Button.java 18 Sep 2006 07:59:05 -0000 1.13 --- Button.java 20 Sep 2006 12:19:52 -0000 1.14 *************** *** 21,24 **** --- 21,25 ---- import com.synclast.Event; + import com.synclast.StyleSheet; import javax.microedition.lcdui.Canvas; *************** *** 50,58 **** } ! protected void init() { ! super.init(); ! BORDER_COLOR.set(this, Color.BLACK); ! BORDER_WIDTH.set(this, 1); ! INSET_WIDTH.set(this, 2); } --- 51,59 ---- } ! protected void applyStyleSheet(StyleSheet sheet) { ! super.applyStyleSheet(sheet); ! BORDER_COLOR.set(this, Color.BLACK, sheet); ! BORDER_WIDTH.set(this, 1, sheet); ! INSET_WIDTH.set(this, 2, sheet); } Index: ColoredWidget.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/ColoredWidget.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** ColoredWidget.java 18 Sep 2006 07:59:05 -0000 1.21 --- ColoredWidget.java 20 Sep 2006 12:19:53 -0000 1.22 *************** *** 23,26 **** --- 23,27 ---- import javax.microedition.lcdui.Graphics; import javax.microedition.lcdui.Image; + import com.synclast.StyleSheet; /** *************** *** 74,86 **** } ! protected void init() { ! super.init(); ! FOREGROUND_COLOR.set(this, 0x000000); ! BACKGROUND_COLOR.set(this, Color.TRANSPARENT); ! BORDER_COLOR.set(this, Color.TRANSPARENT); ! BORDER_ARC.set(this, 0); ! BORDER_WIDTH.set(this, 0); ! IMAGE_MODE.set(this, TILED); ! INSET_WIDTH.set(this, 0); } --- 75,87 ---- } ! protected void applyStyleSheet(StyleSheet sheet) { ! super.applyStyleSheet(sheet); ! FOREGROUND_COLOR.set(this, 0x000000, sheet); ! BACKGROUND_COLOR.set(this, Color.TRANSPARENT, sheet); ! BORDER_COLOR.set(this, Color.TRANSPARENT, sheet); ! BORDER_ARC.set(this, 0, sheet); ! BORDER_WIDTH.set(this, 0, sheet); ! IMAGE_MODE.set(this, TILED, sheet); ! INSET_WIDTH.set(this, 0, sheet); } Index: Container.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/Container.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** Container.java 18 Sep 2006 11:31:26 -0000 1.38 --- Container.java 20 Sep 2006 12:19:53 -0000 1.39 *************** *** 25,28 **** --- 25,29 ---- import com.synclast.Event; + import com.synclast.StyleSheet; /** *************** *** 185,196 **** * components may have been resized. */ ! public void applyStyleSheet() {//StyleSheet sheet) { ! super.applyStyleSheet();//sheet); // Apply just the new styleSheet to contained widgets Widget widget; ! for (int i = widgets.size() - 1; i >= 0; --i) { ! widget = (Widget) widgets.elementAt(i); ! widget.applyStyleSheet();//sheet); } } --- 186,206 ---- * components may have been resized. */ ! protected void applyStyleSheet(StyleSheet sheet) { ! super.applyStyleSheet(sheet); // Apply just the new styleSheet to contained widgets Widget widget; ! //avoid NullPointerExeption where widgets Vector is currently null ! //static initialization case, where instance variables have not ! //been initialized can leave widgets == null; ! //this happens because Widget constructor gets called before Container ! //constructor, but Widget constructor calls applyStyleSheet, which ! //causes this method to get called before our constructor (or instance ! //initialization) has run. Weird edge case, but applicable ! if(widgets != null) { ! for (int i = widgets.size() - 1; i >= 0; --i) { ! widget = (Widget) widgets.elementAt(i); ! widget.applyStyleSheet(sheet); ! } } } *************** *** 262,268 **** widgets.addElement(widget); } if (context != null) { ! widget.applyStyleSheet();//context.getStyleSheet()); } if (context != null && context.isShown()) { widget.showNotify(); --- 272,281 ---- widgets.addElement(widget); } + //applyStyleSheet even if null, so we at least get default values + StyleSheet sheet = null; if (context != null) { ! sheet = context.getStyleSheet(); } + widget.applyStyleSheet(sheet); if (context != null && context.isShown()) { widget.showNotify(); Index: Checkbox.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/Checkbox.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Checkbox.java 18 Sep 2006 07:59:05 -0000 1.11 --- Checkbox.java 20 Sep 2006 12:19:53 -0000 1.12 *************** *** 25,28 **** --- 25,29 ---- import com.synclast.Event; + import com.synclast.StyleSheet; /** *************** *** 40,48 **** } ! protected void init() { ! super.init(); ! BORDER_WIDTH.set(this, 1); ! BORDER_COLOR.set(this, Color.BLACK); ! BACKGROUND_COLOR.set(this, Color.LIGHT_GRAY); } --- 41,49 ---- } ! protected void applyStyleSheet(StyleSheet sheet) { ! super.applyStyleSheet(sheet); ! BORDER_WIDTH.set(this, 1, sheet); ! BORDER_COLOR.set(this, Color.BLACK, sheet); ! BACKGROUND_COLOR.set(this, Color.LIGHT_GRAY, sheet); } Index: Input.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/Input.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Input.java 18 Sep 2006 07:59:05 -0000 1.21 --- Input.java 20 Sep 2006 12:19:53 -0000 1.22 *************** *** 29,32 **** --- 29,33 ---- import com.synclast.Event; + import com.synclast.StyleSheet; import com.synclast.SynclastTask; import com.synclast.SynclastManager; *************** *** 115,135 **** } ! protected void init() { ! super.init(); ! MASK_CHAR.set(this, 0); ! CURSOR_BLINK_DELAY.set(this, 500); ! MAX_SIZE.set(this, 10); //WIDTH.set(this, 10); Font defaultFont = Font.getDefaultFont(); ! int fFace = FONT_FACE.get(this, defaultFont.getFace()); ! int fStyle = FONT_STYLE.get(this, defaultFont.getStyle()); ! int fSize = FONT_SIZE.get(this, defaultFont.getSize()); setDefault(FONT, Style.getFontValue(Font.getFont(fFace, fStyle, fSize))); ! BORDER_WIDTH.set(this, 1); ! BORDER_COLOR.set(this, Color.BLACK); ! INSET_WIDTH.set(this, 2); } --- 116,136 ---- } ! protected void applyStyleSheet(StyleSheet sheet) { ! super.applyStyleSheet(sheet); ! MASK_CHAR.set(this, 0, sheet); ! CURSOR_BLINK_DELAY.set(this, 500, sheet); ! MAX_SIZE.set(this, 10, sheet); //WIDTH.set(this, 10); Font defaultFont = Font.getDefaultFont(); ! int fFace = FONT_FACE.get(this, defaultFont.getFace(), sheet); ! int fStyle = FONT_STYLE.get(this, defaultFont.getStyle(), sheet); ! int fSize = FONT_SIZE.get(this, defaultFont.getSize(), sheet); setDefault(FONT, Style.getFontValue(Font.getFont(fFace, fStyle, fSize))); ! BORDER_WIDTH.set(this, 1, sheet); ! BORDER_COLOR.set(this, Color.BLACK, sheet); ! INSET_WIDTH.set(this, 2, sheet); } Index: Style.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/Style.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Style.java 18 Sep 2006 11:15:36 -0000 1.3 --- Style.java 20 Sep 2006 12:19:53 -0000 1.4 *************** *** 286,291 **** * Method to get the "parsed" value from this Style. Usually you will want to call Style.set(Widget). You should only call this if you need to do special handling with the returned value, instead of setting it directly on the widget. */ ! public int get(Widget widget, int defaultValue) { ! String value = getString(widget, defaultValue); //parseValue handles null return parseValue(value, defaultValue); --- 286,291 ---- * Method to get the "parsed" value from this Style. Usually you will want to call Style.set(Widget). You should only call this if you need to do special handling with the returned value, instead of setting it directly on the widget. */ ! public int get(Widget widget, int defaultValue, StyleSheet styleSheet) { ! String value = getString(widget, defaultValue, styleSheet); //parseValue handles null return parseValue(value, defaultValue); *************** *** 295,299 **** * Method to get the "raw" StyleSheet value for this Style. Calling this method will avoid any "parsing" being done on the value returned from the StyleSheet. Use this method if you know Style cannot handle the "raw" StyleSheet value in its parse method (such as style values that are not parsable to an int). This method still handles looking up the Stylesheet and gettng the cascaded value properly. Normally you will call Style.set(Widget) instead of this method. */ ! public String getString(Widget widget, int defaultValue) { if(widget == null) return null; Container parent = widget.container; --- 295,299 ---- * Method to get the "raw" StyleSheet value for this Style. Calling this method will avoid any "parsing" being done on the value returned from the StyleSheet. Use this method if you know Style cannot handle the "raw" StyleSheet value in its parse method (such as style values that are not parsable to an int). This method still handles looking up the Stylesheet and gettng the cascaded value properly. Normally you will call Style.set(Widget) instead of this method. */ ! /* public String getString(Widget widget, int defaultValue) { if(widget == null) return null; Container parent = widget.container; *************** *** 306,309 **** --- 306,313 ---- } } + return getString(widget, defaultValue, styleSheet); + } + */ + public String getString(Widget widget, int defaultValue, StyleSheet styleSheet) { String value = null; if(styleSheet != null) { *************** *** 316,321 **** * Method for getting the StyleSheet value, and setting it on the specified Widget. This is the normal method call on a Style. The Style will use the widget's current containement hierarchy to get the proper StyleSheet and to determine the proper cascade order for getting the Stylesheet vaalue. It will then parse this "raw" StyleSheet value, and set it on the widget, using the Style's id, and the parsed value, by calling Widget.set(int, int). This method is usually only called form inside Widget, and subclasses of Widget. */ ! public void set(Widget widget, int defaultValue) { ! int parsedValue = get(widget, defaultValue); widget.setDefault(id, parsedValue); } --- 320,325 ---- * Method for getting the StyleSheet value, and setting it on the specified Widget. This is the normal method call on a Style. The Style will use the widget's current containement hierarchy to get the proper StyleSheet and to determine the proper cascade order for getting the Stylesheet vaalue. It will then parse this "raw" StyleSheet value, and set it on the widget, using the Style's id, and the parsed value, by calling Widget.set(int, int). This method is usually only called form inside Widget, and subclasses of Widget. */ ! public void set(Widget widget, int defaultValue, StyleSheet styleSheet) { ! int parsedValue = get(widget, defaultValue, styleSheet); widget.setDefault(id, parsedValue); } Index: Label.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/Label.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Label.java 18 Sep 2006 11:09:10 -0000 1.17 --- Label.java 20 Sep 2006 12:19:53 -0000 1.18 *************** *** 22,25 **** --- 22,26 ---- import javax.microedition.lcdui.Font; import javax.microedition.lcdui.Graphics; + import com.synclast.StyleSheet; /** *************** *** 68,80 **** } ! protected void init() { ! super.init(); Font defaultFont = Font.getDefaultFont(); ! int fFace = FONT_FACE.get(this, defaultFont.getFace()); ! int fStyle = FONT_STYLE.get(this, defaultFont.getStyle()); ! int fSize = FONT_SIZE.get(this, defaultFont.getSize()); setDefault(FONT, Style.getFontValue(Font.getFont(fFace, fStyle, fSize))); ! INSET_WIDTH.set(this, 2); } --- 69,81 ---- } ! protected void applyStyleSheet(StyleSheet sheet) { ! super.applyStyleSheet(sheet); Font defaultFont = Font.getDefaultFont(); ! int fFace = FONT_FACE.get(this, defaultFont.getFace(), sheet); ! int fStyle = FONT_STYLE.get(this, defaultFont.getStyle(), sheet); ! int fSize = FONT_SIZE.get(this, defaultFont.getSize(), sheet); setDefault(FONT, Style.getFontValue(Font.getFont(fFace, fStyle, fSize))); ! INSET_WIDTH.set(this, 2, sheet); } Index: GridMenu.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/GridMenu.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** GridMenu.java 18 Sep 2006 07:59:05 -0000 1.2 --- GridMenu.java 20 Sep 2006 12:19:53 -0000 1.3 *************** *** 27,30 **** --- 27,31 ---- import com.synclast.Event; + import com.synclast.StyleSheet; import com.synclast.SynclastTask; *************** *** 86,93 **** } ! protected void init() { ! super.init(); ! SELECTED_COLOR.set(this, 0x000000); ! INSET_WIDTH.set(this, 2); } --- 87,94 ---- } ! protected void applyStyleSheet(StyleSheet sheet) { ! super.applyStyleSheet(sheet); ! SELECTED_COLOR.set(this, 0x000000, sheet); ! INSET_WIDTH.set(this, 2, sheet); } |
|
From: Harry E. <har...@us...> - 2006-09-18 11:31:30
|
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(); + } } |
|
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); } } |
|
From: Harry E. <har...@us...> - 2006-09-18 11:31:29
|
Update of /cvsroot/synclast/client/examples/SynclastUIDemo/bin In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv18107/examples/SynclastUIDemo/bin Modified Files: MANIFEST.MF SynclastUIDemo.jad 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: MANIFEST.MF =================================================================== RCS file: /cvsroot/synclast/client/examples/SynclastUIDemo/bin/MANIFEST.MF,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MANIFEST.MF 3 Aug 2003 21:16:25 -0000 1.3 --- MANIFEST.MF 18 Sep 2006 11:31:26 -0000 1.4 *************** *** 4,7 **** --- 4,8 ---- MIDlet-4: RasterEffect, , RasterMIDlet MIDlet-5: Table, , TableMIDlet + MIDlet-6: FixedSize, , FixedSizeMIDlet MIDlet-Name: SynclastUIDemo MIDlet-Vendor: Synclast Index: SynclastUIDemo.jad =================================================================== RCS file: /cvsroot/synclast/client/examples/SynclastUIDemo/bin/SynclastUIDemo.jad,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SynclastUIDemo.jad 5 Feb 2004 01:55:07 -0000 1.7 --- SynclastUIDemo.jad 18 Sep 2006 11:31:26 -0000 1.8 *************** *** 4,7 **** --- 4,8 ---- MIDlet-4: RasterEffect, , RasterMIDlet MIDlet-5: Table, , TableMIDlet + MIDlet-6: FixedSize, , FixedSizeMIDlet MIDlet-Jar-Size: 100 MIDlet-Jar-URL: SynclastUIDemo.jar |
|
From: Harry E. <har...@us...> - 2006-09-18 11:15:42
|
Update of /cvsroot/synclast/client/src/com/synclast/ui In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv13733/ui Modified Files: Style.java Log Message: Added license header to these recent classes Index: Style.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/Style.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Style.java 18 Sep 2006 11:06:53 -0000 1.2 --- Style.java 18 Sep 2006 11:15:36 -0000 1.3 *************** *** 1,2 **** --- 1,21 ---- + /* + $Id$ + + This file is part of the Synclast UI API. + + The Synclast UI API is free software; you can redistribute it + and/or modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + The Synclast UI API is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the Synclast UI API; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ package com.synclast.ui; |
|
From: Harry E. <har...@us...> - 2006-09-18 11:15:40
|
Update of /cvsroot/synclast/client/src/com/synclast In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv13733 Modified Files: StyleSheet.java SynclastException.java Log Message: Added license header to these recent classes Index: StyleSheet.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/StyleSheet.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** StyleSheet.java 18 Sep 2006 07:59:04 -0000 1.13 --- StyleSheet.java 18 Sep 2006 11:15:36 -0000 1.14 *************** *** 1,2 **** --- 1,21 ---- + /* + $Id$ + + This file is part of the Synclast UI API. + + The Synclast UI API is free software; you can redistribute it + and/or modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + The Synclast UI API is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the Synclast UI API; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ package com.synclast; Index: SynclastException.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/SynclastException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SynclastException.java 18 Sep 2006 07:59:04 -0000 1.1 --- SynclastException.java 18 Sep 2006 11:15:36 -0000 1.2 *************** *** 1,2 **** --- 1,21 ---- + /* + $Id$ + + This file is part of the Synclast UI API. + + The Synclast UI API is free software; you can redistribute it + and/or modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + The Synclast UI API is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the Synclast UI API; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ package com.synclast; |
|
From: Harry E. <har...@us...> - 2006-09-18 11:09:15
|
Update of /cvsroot/synclast/client/src/com/synclast/ui In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv10581/src/com/synclast/ui Modified Files: Label.java Log Message: Changed the way that Label's constructor worked. Before, Label was ALWAYS using the default Font if none was specified. Now, if none is specified iin the constructor, it will at least try to use the value specified in the style sheet, defaulting to the default font in cases where nothing is known. Index: Label.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/Label.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Label.java 18 Sep 2006 07:59:05 -0000 1.16 --- Label.java 18 Sep 2006 11:09:10 -0000 1.17 *************** *** 55,59 **** */ public Label(String text) { ! this(text, Font.getDefaultFont()); } --- 55,59 ---- */ public Label(String text) { ! this.text = text; } *************** *** 64,70 **** */ public Label(String text, Font font) { ! this.text = text; set(FONT, Style.getFontValue(font)); - //changeFont(font); } --- 64,69 ---- */ public Label(String text, Font font) { ! this(text); set(FONT, Style.getFontValue(font)); } |
|
From: Harry E. <har...@us...> - 2006-09-18 11:07:02
|
Update of /cvsroot/synclast/client/src/com/synclast/ui In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv9729/src/com/synclast/ui Modified Files: Style.java Widget.java Log Message: Fixed a type in the FONT_STYLE hashtable in Style ("smalle"=>"small") Made setClassStyleName return a Widget (this) so that it can be changed like the set(property, value) call. Index: Widget.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/Widget.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** Widget.java 18 Sep 2006 07:59:05 -0000 1.23 --- Widget.java 18 Sep 2006 11:06:53 -0000 1.24 *************** *** 338,343 **** * A selector for styles that allows additional styling of a widget beyond the styling avialable from getStyleName(). See <code>StyleSheet</code> for a more detailed explanation of how the classStyleName effects widget styling. Since settinng this value causes the classStyleName, and hence the styling for the widget to change, this operation may be expensive, as it triggers a refetching of all applicably widget styles, an invalidation of the widget, and if a container, the same set of steps for all contained widgets. * @param aStyleName the new classStyleName to use for this widget. */ ! public void setClassStyleName(String aStyleName) { //Go through all this effort below, to avoid calling init unless //absolutely necessary (because it is so expensive) --- 338,344 ---- * A selector for styles that allows additional styling of a widget beyond the styling avialable from getStyleName(). See <code>StyleSheet</code> for a more detailed explanation of how the classStyleName effects widget styling. Since settinng this value causes the classStyleName, and hence the styling for the widget to change, this operation may be expensive, as it triggers a refetching of all applicably widget styles, an invalidation of the widget, and if a container, the same set of steps for all contained widgets. * @param aStyleName the new classStyleName to use for this widget. + * @return this Widget, to allow it to be used in chained calls, like set() */ ! public Widget setClassStyleName(String aStyleName) { //Go through all this effort below, to avoid calling init unless //absolutely necessary (because it is so expensive) *************** *** 345,349 **** //if they are both null, then nothing to do //also avoid null case for later checks. - return; } else if((classStyleName == null && aStyleName != null) || (classStyleName != null && aStyleName == null) || --- 346,349 ---- *************** *** 352,355 **** --- 352,357 ---- init(); } + //just like set, allow this method to be chained + return this; } } Index: Style.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/Style.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Style.java 18 Sep 2006 07:59:05 -0000 1.1 --- Style.java 18 Sep 2006 11:06:53 -0000 1.2 *************** *** 123,127 **** FONT_SIZE.put("large", new Integer(Font.SIZE_LARGE)); FONT_SIZE.put("medium", new Integer(Font.SIZE_MEDIUM)); ! FONT_SIZE.put("smalle", new Integer(Font.SIZE_SMALL)); FONT_FACE = new Hashtable(); FONT_FACE.put("monospace", new Integer(Font.FACE_MONOSPACE)); --- 123,127 ---- FONT_SIZE.put("large", new Integer(Font.SIZE_LARGE)); FONT_SIZE.put("medium", new Integer(Font.SIZE_MEDIUM)); ! FONT_SIZE.put("small", new Integer(Font.SIZE_SMALL)); FONT_FACE = new Hashtable(); FONT_FACE.put("monospace", new Integer(Font.FACE_MONOSPACE)); |
|
From: Harry E. <har...@us...> - 2006-09-18 07:59:09
|
Update of /cvsroot/synclast/client/src/com/synclast In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv31295/src/com/synclast Modified Files: StyleSheet.java Styled.java Added Files: SynclastException.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: StyleSheet.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/StyleSheet.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** StyleSheet.java 6 Oct 2004 22:51:48 -0000 1.12 --- StyleSheet.java 18 Sep 2006 07:59:04 -0000 1.13 *************** *** 1,257 **** - /* - $Id$ - - This file is part of the Synclast UI API. - - The Synclast UI API is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The Synclast UI API is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied - warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the Synclast UI API; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ package com.synclast; import java.util.Vector; import javax.microedition.lcdui.Font; /** ! * Provides a simple mechanism for setting user interface styles ! * that can be applied to objects that implement the Styled interface. ! * <P> ! * The toolkit has a default stylesheet that Styled classes may ! * register their default settings with (typically in a static ! * initialization block). ! * <P> ! * For simplicity and minimal size, all styles are defined in terms of ! * integer values. A class implementing Styled is free to choose ! * arbitrary constants for both properties and values; a suggested ! * convention is the use of "public static final int" constant ! * declarations. In addition, this class provides a pair of utility ! * methods for converting MIDP Font objects to and from integers. ! * <P> ! * Sample usage: ! * <pre> ! * StyleSheet sheet = new StyleSheet(); ! * sheet.setStyle(ColoredWidget.class, // or ._class for MIDP 1.0 ! * ColoredWidget.BORDER_COLOR, Color.BLUE) ! * .setStyle(InputWidget.class, InputWidget.BORDER_COLOR, ! * Color.GREEN); ! * SynclastCanvas myCanvas = new SynclastCanvas(sheet); ! * </pre> */ public class StyleSheet { ! private static StyleSheet DEFAULT; ! /** Returns the current default stylesheet. */ ! public static synchronized StyleSheet getDefault() { ! if (DEFAULT == null) { ! DEFAULT = new StyleSheet("Default"); } - return DEFAULT; } ! /** Sets the current default stylesheet. */ ! public static void setDefault(StyleSheet newDefault) { ! DEFAULT = newDefault; ! } ! ! // Parallel vectors (order is important) ! private Vector classes = new Vector(); ! // Vector of Vectors ! private Vector styleSets = new Vector(); ! ! /** ! * Creates a new style sheet based on the default style sheet. ! */ ! public StyleSheet() { ! this(getDefault()); } ! /** ! * Creates a new style sheet by looking up settings from the MIDlet ! * environment. ! */ ! public StyleSheet(String name) { ! String styles = SynclastManager.getProperty("Style-" + name); ! int p1, p2, p3, pos = 0; ! ! if (styles != null) { ! ! // This is the most inelegant code I've written in a long ! // time. Please help me improve it. ! // The format is "ClassName1:propNo1=value1,propNo2=value2;ClassName2:propNo1=value1[,...;...] ! do { ! p1 = styles.indexOf(';', pos); ! p2 = styles.indexOf(':', pos); ! Class clazz = null; ! try { ! clazz = Class.forName(styles.substring(pos, p2)); ! } catch (Exception e) { ! e.printStackTrace(); ! } ! p3 = p2 + 1; ! pos = p1; ! if (pos == -1) { pos = styles.length(); } ! do { ! p3 = styles.indexOf(',', p2 + 1); ! String nameVal; ! if ((p3 != -1) && (p3 < pos)) { ! nameVal = styles.substring(p2 + 1, p3); ! } else { ! if (p1 != -1) { ! nameVal = styles.substring(p2 + 1, p1); ! } else { ! nameVal = styles.substring(p2 + 1); ! } ! } ! ! // Now split nameVal... ! int p4 = nameVal.indexOf('='); ! // Set the indicated style ! setStyle(clazz, ! Integer.parseInt(nameVal.substring(0,p4)), ! Integer.parseInt(nameVal.substring(p4+1))); ! ! p2 = p3; ! } while ((p3 != -1) && (p3 < pos)); ! pos = p1 + 1; ! } while (p1 != -1); } } /** ! * Creates a new style sheet with the given source style sheet. */ ! public StyleSheet(StyleSheet source) { ! if (source != null) { ! update(source); ! } } /** ! * Copies all the values from the other stylesheet into this one. */ ! public void update(StyleSheet other) { ! int len = other.classes.size(); ! for (int i = 0; i < len; i++) { ! Class type = (Class) other.classes.elementAt(i); ! Vector styles = (Vector) other.styleSets.elementAt(i); ! int jlen = styles.size(); ! for (int j = 0; j < jlen; j++) { ! int[] propVal = (int[]) styles.elementAt(j); ! setStyle(type, propVal[0], propVal[1]); } } ! } ! ! /** ! * Sets a single style property to the designated value. The ! * value will be applied to instances of the specified Java class ! * and its subclasses only. ! */ ! public synchronized StyleSheet setStyle(Class type, int property, int value) { ! int pos = classes.indexOf(type); ! Vector styles; ! if (pos == -1) { ! // Need to add a new entry to both vectors ! int len = classes.size(); ! Class clazz; ! while (++pos < len) { ! // Insert it BEFORE anything that is a subclass of it. ! clazz = (Class) classes.elementAt(pos); ! if (type.isAssignableFrom(clazz)) { break; - } } ! classes.insertElementAt(type, pos); ! styles = new Vector(); ! styleSets.insertElementAt(styles, pos); ! } else { ! styles = (Vector) styleSets.elementAt(pos); ! } ! // There can be only one entry for a given Class/property combo ! int vlen = styles.size(); ! int j = 0; ! for (; j < vlen; j++) { ! int[] style = (int[]) styles.elementAt(j); ! if (style[0] == property) { ! style[1] = value; ! return this; } } ! styles.addElement(new int[] { property, value }); ! return this; } ! ! /** ! * Convenience method. Equivalent to calling ! * setStyle(type, property, StyleSheet.getFontValue(font)). */ ! public StyleSheet setStyle(Class type, int property, Font font) { ! return setStyle(type, property, getFontValue(font)); } /** ! * Retrieves the style value for the designated class and property. ! * If no value has been registered, the constant -1 is returned. */ ! public int getStyle(Class type, int property) { ! int pos = classes.indexOf(type); ! if (pos == -1) { ! Vector v = (Vector) styleSets.elementAt(pos); ! int len = v.size(); ! int[] style; ! for (int i = 0; i < len; i++) { ! style = (int[]) v.elementAt(i); ! if (style[0] == property) { ! return style[1]; ! } ! } } - return -1; } /** ! * Applies this stylesheet to the argument object. ! * This will trigger 0 or more calls to Styled.setDefault(property, value) ! * depending on the properties that have been registered with this ! * stylesheet for the particular Styled class. */ ! public void applyTo(Styled styled) { ! int len = classes.size(); ! for (int i = 0; i < len; i++) { ! Class clazz = (Class) classes.elementAt(i); ! if (clazz.isAssignableFrom(styled.getClass())) { ! Vector v = (Vector) styleSets.elementAt(i); ! int vlen = v.size(); ! for (int j = 0; j < vlen; j++) { ! int[] style = (int[]) v.elementAt(j); ! styled.setDefault(style[0], style[1]); ! } ! } ! } } /** ! * Returns a single int representing a MIDP Font, for ! * use with font style properties. */ ! public static int getFontValue(Font font) { ! return font.getStyle() | font.getSize() | font.getFace(); } /** ! * Returns the font represented by an integer value, the ! * inverse operation of getFontValue(). */ ! public static Font getFont(int value) { ! return Font.getFont(value & 96, value & 7, value & 24); } } --- 1,426 ---- package com.synclast; + import com.synclast.SynclastException; + import com.synclast.Styled; + import java.io.InputStreamReader; + import java.io.IOException; + import java.util.Hashtable; import java.util.Vector; import javax.microedition.lcdui.Font; /** ! * New StyleSheet mechanism for synclast. This class handles "CSS-like" styles of the format: ! <pre> ! [ ! [whitespace|newline]*[type_name(not whitespace or newline)][whitespace]*[{] ! [ ! [whitespace|newline]*[style_name(not whitespace or newline)][whitespace]*[:] ! [whitespace(not newline)*][style_value(not whitespace or newline)][;] ! ]* ! [whitespace|newline]*[}] ! [whitespace|newline]* ! ] ! </pre> ! For example: ! <pre> ! label { ! font-size: small; font-style: bold,underline; ! background-color: 0xff0000; ! } ! box { ! background-color: 0x00ff00; ! color: 0x000000; ! border-width: 2; ! } ! .foo { background-color: ffffff; border-color: 000000; } ! .bar { color: 0x0000ff; border-width: 1; border-color: 0x0f0f0f;} ! </pre> ! This should give you an idea about what type of formatting is allowed in stylesheets.<br/> ! Stylesheets are created by setting the string value of the stylesheet to be parsed in the constructor of the stylesheet. Other mechanisms can handle loading stylesheets from elsewhere, such as reading the value from the network or a jar, and then using the resulting string to create a stylesheet.<br/> ! Stylesheets can only be set on a SynclastCanvas. This automatically makes it available to all the widgets placed on that canvas. Setting a new stylesheet on a canvas will cause all widgets on that canvas to get the new value in that stylesheet, and forget all their old values. Since styles can effect sizing, this also causes all widgets and containers to re-layout themselves. Since this can be a relatively expensive operation, use with care. Also, since paint can be called at any time, it is recommended that you do not set a new stylesheet on a displayed canvas, since intermediate values might also be displayed (race condition).<br/> ! Widgets by default get their styles based on the styleName they declare (getStyleName). If a particular style is not found, the same value will be looked for in the container containing this widget, recursively. <code>label</code> and <code>box</code> are examples of this way of declaring styles. You may also specify that a widget get special styling by setting a <code>classStyleName</code> (<code>widget.setClassStyleName(String)</code>). This will be looked at before the standard style information for that widget. <code>.foo</code> and <code>.bar</code> are examples of this way of declaring styles. Please note that you declare a <code>classStyleName</code> in the stylesheet as <i><code>.foo</code></i> but you set it on a widget as <code>setCLassStyleName("foo")</code>. In addition, classStyleNames also cascade. The full rule set for finding the style for a widget follows these steps: ! <ol> ! <li>For each style:<ol> ! <li>Get value for classStyleName</li> ! <li>If value is null, get value for styleName</li> ! <li>if value is null, get container</li> ! <li>repeat above until non null value, or null container</li> ! <li>if value is null, use Style default value</li> ! <li>invalidate self</li> ! </ol> ! <li>If container, repeat for all contained widgets</li> ! </ol> ! Using the stylesheet above, if you have the following code snippet: ! <pre> ! BoxContainer parentBox = new BoxContainer(Graphics.LEFT); ! BoxContainer childBox = new BoxContainer(Graphics.TOP); ! Label label = new Label("Hello"); ! parentBox.add(childBox); ! childBox.add(label); ! </pre> ! (assuming parentBox is added to a SynclastCanvas), then <code>label</code> would have the following values: ! <ul> ! <li>font-size: small</li> ! <li>font-style: bold,underline</li> ! <li>background-color: 0xff0000</li> ! <li>color: 0x000000</li> ! <li>border-width: 2</li> ! </ul> ! However, if we add: ! <pre> ! label.setClassStyleName("foo"); ! </pre> ! the <code>label</code> properties now look like: ! <ul> ! <li>font-size: small</li> ! <li>font-style: bold,underline</li> ! <li><b>background-color: ffffff</b>(changed value due to .foo)</li> ! <li>color: 0x000000</li> ! <li>border-width: 2</li> ! <li><b>border-color: 000000</b>(new value from .foo)</li> ! </ul> ! and if we add: ! <pre> ! childBox.setClassStyleName("bar"); ! </pre> ! the <code>label</code> properties now look like: ! <ul> ! <li>font-size: small</li> ! <li>font-style: bold,underline</li> ! <li>background-color: ffffff</li> ! <li><b>color: 0x0000ff</b>(value from .bar on childbox)</li> ! <li><b>border-width: 1</b>(value from .bar on childbox)</li> ! <li><b>border-color: 000000</b>(does not change because value from .foo on label is more specific than value from .bar on childbox)</li> ! </ul> ! <code>classStyleName</code>s can be set on any widget. <code>styleName</code>s are declared by each non abstract widget. The name a widget uses for the StyleSheet, and the set of styles a widget declares, are documented on each widget. For a detailed description of how to make new styles for a widget subclass, see <code>Style</code>.<br> ! Normal usage is: ! <pre> ! //... read stylesheet string from somewhere (jar, network, etc)... ! StyleSheet styleSheet = new StyleSheet(styleSheetString); ! mySynclastCanvas.setStyleSheet(styleSheet); ! //... add widgets, which will automatically get styles from stylesheet ... ! //... display mySynclastCanvas ... ! </pre> ! @author Harry Evans ! */ public class StyleSheet { ! private static StyleSheet DEFAULT_STYLESHEET = null; ! private Hashtable styleMap; ! /** ! * Create a new stylesheet with a String that conforms to the StyleSheet syntax. ! * @param String the stylesheet String to parse for styles. ! */ ! public StyleSheet(String css) { ! styleMap = parseCss(css); ! if(DEFAULT_STYLESHEET == null) { ! DEFAULT_STYLESHEET = this; } } ! public StyleSheet(Class clazz, String resourceName) { ! this(readResource(clazz, resourceName)); } ! protected static String readResource(Class clazz, String resourceName) { ! try { ! InputStreamReader reader = new InputStreamReader(clazz.getResourceAsStream(resourceName)); ! int length = 0; ! char[] charArray = new char[128]; ! StringBuffer buf = new StringBuffer(); ! while((length = reader.read(charArray)) != -1) { ! buf.append(charArray, 0, length); ! } ! reader.close(); ! return buf.toString(); ! } catch(IOException e) { ! throw new SynclastException("Error reading resource. Class: " + clazz.getName() + " resourceName: " + resourceName, e); } } + /** Internal parse state constant */ + protected static final int STATE_START_STYLE = 1; + /** Internal parse state constant */ + protected static final int STATE_STYLE = 7; + /** Internal parse state constant */ + protected static final int STATE_END_STYLE = 2; + /** Internal parse state constant */ + protected static final int STATE_START_NAME = 3; + /** Internal parse state constant */ + protected static final int STATE_NAME = 8; + /** Internal parse state constant */ + protected static final int STATE_END_NAME = 4; + /** Internal parse state constant */ + protected static final int STATE_START_VALUE = 5; + /** Internal parse state constant */ + protected static final int STATE_VALUE = 9; + /** Internal parse state constant */ + protected static final int STATE_END_VALUE = 6; + /** Internal parse state constant */ + protected static final int STATE_ERROR = -1; + /** ! * Internal helper method to get the set of parsed styles */ ! protected Hashtable getStyleMap() { ! return styleMap; } /** ! * Main parse method for turning a stylesheet string into a set of styles to be used by widgets. This is very delicate. Modify at your own risk. Parsing errors will be printed on System.err, and the input ignored. ! * @param css the string to parse. ! * @return the Hashtable containing the parsed styles. */ ! protected static Hashtable parseCss(String css) { ! Hashtable map = new Hashtable(); ! StringBuffer style = null; ! StringBuffer name = null; ! StringBuffer value = null; ! String errorString = null; ! int idx = 0; ! int length = css.length(); ! int state = STATE_START_STYLE; ! char currentChar = 'z'; ! for(idx = 0; idx < length && STATE_ERROR != state; idx++) { ! currentChar = css.charAt(idx); ! //state machine ! switch(state) { ! case STATE_START_STYLE: ! if(!isWhitespace(currentChar) && !isNewline(currentChar)) { ! style = new StringBuffer().append(currentChar); ! state = STATE_STYLE; ! } ! //ignore whitespace and newlines ! break; ! case STATE_STYLE: ! if( '{' == currentChar) { ! //style name done ! state = STATE_START_NAME; ! } else if(isNewline(currentChar)) { ! errorString = "Newline after style without '{'"; ! state = STATE_ERROR; ! } else if(!isWhitespace(currentChar)) { ! style.append(currentChar); ! } else { ! state = STATE_END_STYLE; ! } ! break; ! case STATE_END_STYLE: ! if( '{' == currentChar) { ! state = STATE_START_NAME; ! } else if(!isWhitespace(currentChar)) { ! errorString = "Newline after style without '{'"; ! state = STATE_ERROR; ! } ! //ignore whitespace ! break; ! case STATE_START_NAME: ! if( '}' == currentChar) { ! state = STATE_START_STYLE; ! } else if(!isWhitespace(currentChar) && !isNewline(currentChar)) { ! name = new StringBuffer().append(currentChar); ! state = STATE_NAME; ! } ! //ignore whitespace and newline ! break; ! case STATE_NAME: ! if( ':' == currentChar) { ! state = STATE_START_VALUE; ! } else if(isNewline(currentChar)) { ! errorString = "Newline after name without ':'"; ! state = STATE_ERROR; ! } else if(!isWhitespace(currentChar)) { ! name.append(currentChar); ! } else { ! state = STATE_END_NAME; ! } ! break; ! case STATE_END_NAME: ! if( ':' == currentChar) { ! state = STATE_START_VALUE; ! } else if(!isWhitespace(currentChar)) { ! //newline or character is an error ! errorString = "Newline after name without ':'"; ! state = STATE_ERROR; ! } ! //ignore whitespace ! break; ! case STATE_START_VALUE: ! if(isNewline(currentChar)) { ! errorString = "Newline after ':' without value"; ! state = STATE_ERROR; ! } else if( !isWhitespace(currentChar)) { ! value = new StringBuffer().append(currentChar); ! state = STATE_VALUE; ! } ! //ignore whitespace ! break; ! case STATE_VALUE: ! if( ';' == currentChar) { ! storeStyleNameValue(map, style, name, value); ! state = STATE_START_NAME; ! } else if(isNewline(currentChar)) { ! errorString = "Newline after value without ';'"; ! state = STATE_ERROR; ! } else if(!isWhitespace(currentChar)) { ! value.append(currentChar); ! } else { ! state = STATE_END_VALUE; ! } ! break; ! case STATE_END_VALUE: ! if( ';' == currentChar) { ! storeStyleNameValue(map, style, name, value); ! state = STATE_START_NAME; ! } else if(isNewline(currentChar)) { ! errorString = "Newline after value without ';'"; ! state = STATE_ERROR; ! } else if(!isWhitespace(currentChar)) { ! errorString = "Text after whitespace in value (expected ';')"; ! state = STATE_ERROR; ! } ! //ignore whitespace ! break; ! default: ! //hitting default is an error ! errorString = "Unknown error (Shouldn't get here)"; ! state = STATE_ERROR; ! break; } } ! if(STATE_START_STYLE != state) { ! switch(state) { ! case STATE_STYLE: ! case STATE_END_STYLE: ! errorString = "style has no '{'"; ! break; ! case STATE_START_NAME: ! errorString = "Missing '}' on style"; ! break; ! case STATE_NAME: ! case STATE_END_NAME: ! errorString = "File ends in name (no ':', value, ';' or '}')"; ! break; ! case STATE_START_VALUE: ! errorString = "File ends after name's ':' (no value, ';' or '}')"; ! break; ! case STATE_VALUE: ! case STATE_END_VALUE: ! errorString = "File ends after value (no ';' or '}')"; ! break; ! case STATE_ERROR: ! //should have already set errorString ! break; ! default: ! errorString = "Unknown state on exit"; break; } ! //error condition. throw exception ! StringBuffer buf = new StringBuffer("Exiting parsing in invalid state."); ! buf.append("\nReason:").append(errorString); ! buf.append("\nState: ").append(state); ! buf.append("\nStyle: ").append((style == null) ? "null" : style.toString()); ! buf.append("\nName: ").append((name == null) ? "null" : name.toString()); ! buf.append("\nValue: ").append((value == null) ? "null" : value.toString()); ! buf.append("\nchar: "); ! if(isNewline(currentChar)) { ! buf.append("<newline>"); ! } else if(isWhitespace(currentChar)) { ! buf.append("<whitespace>"); ! } else { ! buf.append(currentChar); } + buf.append("\nindex: ").append(idx); + // throw new SynclastException(buf.toString()); + //Throwing an exception seems pretty heavy weight and unexpected. + //Instead we will print an error to standard error, and return an + //empty map. Stuff will still run, but not be styled by the input + //we got. + System.err.println("StyleSheet Parsing error. No values will be stored in stylesheet. Error: " + buf.toString()); + map.clear(); + return map; + } ! return map; } ! /** ! * Helper method for parsing stylesheet string */ ! protected static boolean isWhitespace(char c) { ! switch(c) { ! case ' ': ! case '\t': ! return true; ! default: ! return false; ! } } /** ! * Helper method for parsing stylesheet string */ ! protected static boolean isNewline(char c) { ! switch(c) { ! case '\r': ! case '\n': ! return true; ! default: ! return false; } } /** ! * Helper method for parsing stylesheet string */ ! protected static void storeStyleNameValue(Hashtable map, StringBuffer style, StringBuffer name, StringBuffer value) { ! String key = style.toString() + "/" + name.toString(); ! map.put(key, value.toString()); } /** ! * Principal method for get values from the stylesheet. This value returns the "raw" string value from the parsed stylesheet string. It is up to the caller (usually style) to parse this string value into a usable form (usually an int). Usually it is an error to call this method directly. You should instead be calling Style.set(Widget) or Style.get(Widget), and letting the Style class handle value parsing. This method also does all the cascade logic for fetching the style value, including both styleName and classStyleName, and all container calls. ! * @param name the name of the style to fetch ("font-style") ! * @param widget the widget this style is for ("Label") ! * @return the "raw" String value for this style. */ ! public String getStyleValue(String name, boolean cascade, Styled widget) { ! //We'll end up looping through the containment hierarchy for each ! //call to this. Previous implementation generated a list of the ! //style names in reverse containment order, that could be used for ! //each call. This made the call slightly faster, but created an ! //additional vector for each widget, making it somewhat expensive ! //memory wise. Gotta love tradeoffs ! Styled currentWidget = widget; ! //preallocate loop variables ! String value = null; ! String classStyleSelector = null; ! while(currentWidget != null) { ! //first with classStyle, then with styleName ! //since we don't track classStyles already checked, ! //we might check the same one on every loop. This is the same as ! //remembering, and having to check THAT list, and this way uses less ! //memory ! classStyleSelector = currentWidget.getClassStyleName(); ! if(classStyleSelector != null) { ! value = (String)styleMap.get("." + classStyleSelector + "/" + name); ! if(value != null) return value; ! } ! value = (String)styleMap.get(currentWidget.getStyleName() + "/" + name); ! if(value != null) return value; ! else if(!cascade) return value; ! //if we hit !cascade we are probably null, but whatever :) ! currentWidget = currentWidget.getCascadeContainer(); ! //classStyleSelector will be nulled by next call, if applicable ! //value has to be null if we reached here ! } ! return null; } /** ! * Get the default stylesheet. Useful only if you set a default stylesheet. ! * @return the default stylesheet, or null. */ ! public static StyleSheet getDefault() { ! return DEFAULT_STYLESHEET; } } --- NEW FILE: SynclastException.java --- package com.synclast; public class SynclastException extends RuntimeException { protected Throwable cause; public SynclastException() { super(); } public SynclastException(String message) { super(message); } public SynclastException(Throwable cause) { super(); this.cause = cause; } public SynclastException(String message, Throwable cause) { super(message); this.cause = cause; } public void printStackTrace() { super.printStackTrace(); if(cause != null) { System.err.println("Caused by:"); cause.printStackTrace(); } } } Index: Styled.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/Styled.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Styled.java 19 Sep 2003 06:51:09 -0000 1.5 --- Styled.java 18 Sep 2006 07:59:04 -0000 1.6 *************** *** 32,34 **** --- 32,37 ---- */ public void setDefault(int property, int value); + public Styled getCascadeContainer(); + public String getStyleName(); + public String getClassStyleName(); } |
Update of /cvsroot/synclast/client/src/com/synclast/ui In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv31295/src/com/synclast/ui Modified Files: BoxContainer.java Button.java Checkbox.java ColoredWidget.java Container.java FlowContainer.java GridMenu.java Input.java Label.java Menu.java Popup.java RadioButton.java SynclastCanvas.java SynclastImage.java TableContainer.java TapInputAdapter.java Widget.java WordWrapLabel.java Added Files: Style.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: Widget.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/Widget.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** Widget.java 23 Oct 2004 00:22:17 -0000 1.22 --- Widget.java 18 Sep 2006 07:59:05 -0000 1.23 *************** *** 27,31 **** import com.synclast.Event; import com.synclast.Styled; - import com.synclast.StyleSheet; /** --- 27,30 ---- *************** *** 51,57 **** public abstract class Widget implements Styled { /** Constant for style sheet property. */ ! public static final int ALIGN = 0; ! protected static final int LAST_PROPERTY = ALIGN; // X,Y coordinates are in container's coordinate system --- 50,56 ---- public abstract class Widget implements Styled { /** Constant for style sheet property. */ ! public static final Style ALIGN = new Style("align", 0, Style.CASCADE, Style.ALIGNMENT_COMBO_TABLE); ! protected static final int LAST_PROPERTY = ALIGN.getId(); // X,Y coordinates are in container's coordinate system *************** *** 65,68 **** --- 64,68 ---- protected boolean invisible; boolean invalid; + protected String classStyleName; /** *************** *** 77,80 **** --- 77,84 ---- } + public Styled getCascadeContainer() { + return container; + } + protected int getPropertyCount() { return LAST_PROPERTY + 1; *************** *** 92,96 **** */ protected void init() { ! properties = new int [getPropertyCount()]; } --- 96,103 ---- */ protected void init() { ! if(properties == null) { ! properties = new int [getPropertyCount()]; ! } ! ALIGN.set(this, Graphics.LEFT | Graphics.TOP); } *************** *** 181,191 **** * via the set() method. */ ! public void applyStyleSheet(StyleSheet sheet) { ! if (sheet != null) { sheet.applyTo(this); ! } else { init(); setBits = 0L; ! } invalidate(); } --- 188,198 ---- * via the set() method. */ ! public void applyStyleSheet() {//StyleSheet sheet) { ! /* if (sheet != null) { sheet.applyTo(this); ! } else {*/ init(); setBits = 0L; ! // } invalidate(); } *************** *** 205,208 **** --- 212,227 ---- } + public final void setDefault(Style style, int value) { + if(style != null) { + setDefault(style.getId(), value); + } + } + + public int get(Style style) { + int id = style.getId(); + return properties[id]; + //let the arrayIndexOutofbounds exception happen. + //what else can we do? + } /** * Sets a specified property to the given value. Subclasses *************** *** 217,226 **** } ! /** ! * Convenience method; equivalent to calling ! * set(property, StyleSheet.getFontValue(font)). ! */ ! public Widget set(int property, Font font) { ! return set(property, StyleSheet.getFontValue(font)); } --- 236,245 ---- } ! public Widget set(Style style, int value) { ! if(style != null) { ! return set(style.getId(), value); ! } else { ! return this; ! } } *************** *** 241,247 **** * constants for positioning from the MIDP Graphics class * and specifies which position on the widget's clipping region ! * corresponds to the (x,y) point. */ public void setPosition(int x, int y, int align) { if ((align & Graphics.LEFT) != 0) { this.x = x; --- 260,269 ---- * constants for positioning from the MIDP Graphics class * and specifies which position on the widget's clipping region ! * corresponds to the (x,y) point. A call to this method will also ! * cause the ALIGN value to be set to the value specified, as a side ! * effect of this call. */ public void setPosition(int x, int y, int align) { + set(ALIGN, align); if ((align & Graphics.LEFT) != 0) { this.x = x; *************** *** 299,301 **** --- 321,355 ---- */ protected void hideNotify() { } + + /** + * Subclasses should implement this method to declare the name they use in stylesheets. + */ + public abstract String getStyleName(); + + /** + * A selector for styles that allows additional styling of a widget beyond the styling availble from getStyleName(). See <code>StyleSheet</code> for a more detailed explanation of how classStyleName effects widget styling. + * @returnt eh classStyleName set on this widget, or null, if no classStyleName has been set. + */ + public String getClassStyleName() { + return classStyleName; + } + + /** + * A selector for styles that allows additional styling of a widget beyond the styling avialable from getStyleName(). See <code>StyleSheet</code> for a more detailed explanation of how the classStyleName effects widget styling. Since settinng this value causes the classStyleName, and hence the styling for the widget to change, this operation may be expensive, as it triggers a refetching of all applicably widget styles, an invalidation of the widget, and if a container, the same set of steps for all contained widgets. + * @param aStyleName the new classStyleName to use for this widget. + */ + public void setClassStyleName(String aStyleName) { + //Go through all this effort below, to avoid calling init unless + //absolutely necessary (because it is so expensive) + if(classStyleName == null && aStyleName == null) { + //if they are both null, then nothing to do + //also avoid null case for later checks. + return; + } else if((classStyleName == null && aStyleName != null) || + (classStyleName != null && aStyleName == null) || + (!classStyleName.equals(aStyleName))) { + classStyleName = aStyleName; + init(); + } + } } Index: SynclastCanvas.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/SynclastCanvas.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** SynclastCanvas.java 23 Oct 2004 00:22:53 -0000 1.23 --- SynclastCanvas.java 18 Sep 2006 07:59:05 -0000 1.24 *************** *** 107,111 **** // Apply the old stylesheet to the new container this.container = container; ! container.applyStyleSheet(styleSheet); } --- 107,111 ---- // Apply the old stylesheet to the new container this.container = container; ! container.applyStyleSheet();//styleSheet); } *************** *** 123,127 **** public void setStyleSheet(StyleSheet styleSheet) { this.styleSheet = styleSheet; ! container.applyStyleSheet(styleSheet); } --- 123,127 ---- public void setStyleSheet(StyleSheet styleSheet) { this.styleSheet = styleSheet; ! container.applyStyleSheet();//styleSheet); } *************** *** 166,171 **** } // Translate for container if necessary ! int align = container.properties[Widget.ALIGN]; ! // Default is top left int dx = 0; --- 166,170 ---- } // Translate for container if necessary ! int align = container.properties[Widget.ALIGN.getId()]; // Default is top left int dx = 0; Index: BoxContainer.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/BoxContainer.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** BoxContainer.java 6 Mar 2006 06:43:36 -0000 1.14 --- BoxContainer.java 18 Sep 2006 07:59:05 -0000 1.15 *************** *** 193,197 **** private void layout(Widget widget) { ! int childAlign = widget.properties[Widget.ALIGN]; if(orientation == HORIZONTAL) { widget.x = nextX; --- 193,197 ---- private void layout(Widget widget) { ! int childAlign = widget.properties[Widget.ALIGN.getId()]; if(orientation == HORIZONTAL) { widget.x = nextX; *************** *** 231,233 **** --- 231,237 ---- } } + + public String getStyleName() { + return "box"; + } } Index: WordWrapLabel.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/WordWrapLabel.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WordWrapLabel.java 17 Sep 2004 23:19:40 -0000 1.1 --- WordWrapLabel.java 18 Sep 2006 07:59:05 -0000 1.2 *************** *** 22,26 **** import javax.microedition.lcdui.Font; import javax.microedition.lcdui.Graphics; - import com.synclast.StyleSheet; /** --- 22,25 ---- *************** *** 114,116 **** --- 113,119 ---- super.validate(); } + + public String getStyleName() { + return "wordwraplabel"; + } } Index: Menu.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/Menu.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Menu.java 11 Jul 2005 16:12:45 -0000 1.19 --- Menu.java 18 Sep 2006 07:59:05 -0000 1.20 *************** *** 27,31 **** import com.synclast.Event; - import com.synclast.StyleSheet; import com.synclast.SynclastTask; --- 27,30 ---- *************** *** 65,75 **** */ public class Menu extends ColoredWidget implements KeyEventListener, Runnable { ! public static final int SELECTED_COLOR = ColoredWidget.LAST_PROPERTY + 1; ! public static final int ITEM_ALIGN = ColoredWidget.LAST_PROPERTY + 2; ! public static final int SCROLL_DELAY = ColoredWidget.LAST_PROPERTY + 3; ! public static final int SCROLL_PERIOD = ColoredWidget.LAST_PROPERTY + 4; ! public static final int DEFAULT_FONT = ColoredWidget.LAST_PROPERTY + 5; ! public static final int SELECTED_FONT = ColoredWidget.LAST_PROPERTY + 6; ! protected static final int LAST_PROPERTY = SELECTED_FONT; // Workaround for MIDP 1.0 .class access --- 64,97 ---- */ public class Menu extends ColoredWidget implements KeyEventListener, Runnable { ! public static final Style SELECTED_COLOR = new Style( ! Style.STYLE_TYPE_COLOR, "selected-color", ! ColoredWidget.LAST_PROPERTY + 1, Style.NO_CASCADE); ! public static final Style ITEM_ALIGN = new Style( ! "item-align", ColoredWidget.LAST_PROPERTY + 2, Style.NO_CASCADE, ! Style.H_ALIGNMENT_TABLE); ! public static final Style SCROLL_DELAY = new Style( ! Style.STYLE_TYPE_SIZE, "scroll-delay", ! ColoredWidget.LAST_PROPERTY + 3, Style.NO_CASCADE); ! public static final Style SCROLL_PERIOD = new Style( ! Style.STYLE_TYPE_SIZE, "scroll-period", ! ColoredWidget.LAST_PROPERTY + 4, Style.NO_CASCADE); ! public static final Style DEFAULT_FONT = new Style( ! Style.STYLE_TYPE_SIZE, "", ColoredWidget.LAST_PROPERTY + 5, Style.CASCADE); ! public static final Style SELECTED_FONT = new Style( ! Style.STYLE_TYPE_SIZE, "", ColoredWidget.LAST_PROPERTY + 6, Style.CASCADE); ! protected static final Style DEFAULT_FONT_FACE = new Style( ! "font-face", -1, Style.CASCADE, Style.FONT_FACE); ! protected static final Style DEFAULT_FONT_STYLE = Style.getAggregatedEnumerationStyle( ! "font-style", -1, Style.CASCADE, Style.FONT_STYLE); ! protected static final Style DEFAULT_FONT_SIZE = new Style( ! "font-size", -1, Style.CASCADE, Style.FONT_SIZE); ! protected static final Style SELECTED_FONT_FACE = new Style( ! "selected-font-face", -1, Style.CASCADE, Style.FONT_FACE); ! protected static final Style SELECTED_FONT_STYLE = Style.getAggregatedEnumerationStyle( ! "selected-font-style", -1, Style.CASCADE, Style.FONT_STYLE); ! protected static final Style SELECTED_FONT_SIZE = new Style( ! "selected-font-size", -1, Style.CASCADE, Style.FONT_SIZE); ! ! protected static final int LAST_PROPERTY = SELECTED_FONT.getId(); // Workaround for MIDP 1.0 .class access *************** *** 81,85 **** h = defaultFont.getHeight() * (size - 1) + selectedFont.getHeight() ! + 2 * properties[INSET_WIDTH]; } --- 103,107 ---- h = defaultFont.getHeight() * (size - 1) + selectedFont.getHeight() ! + 2 * properties[INSET_WIDTH.getId()]; } *************** *** 107,123 **** protected void init() { super.init(); ! set(INSET_WIDTH, 2); ! set(ITEM_ALIGN, Graphics.HCENTER); ! set(SCROLL_PERIOD, 50); // 50ms between scrolling each pixel ! set(SCROLL_DELAY, 2000); // 2s delay before scrolling starts ! set(SELECTED_FONT, Font.FACE_PROPORTIONAL | Font.STYLE_BOLD | Font.SIZE_MEDIUM); ! set(DEFAULT_FONT, Font.FACE_PROPORTIONAL | Font.STYLE_PLAIN | Font.SIZE_MEDIUM); } public Widget set(int property, int value) { ! if (property == DEFAULT_FONT) { ! defaultFont = StyleSheet.getFont(value); ! } else if (property == SELECTED_FONT) { ! selectedFont = StyleSheet.getFont(value); } return super.set(property,value); --- 129,152 ---- protected void init() { super.init(); ! SELECTED_COLOR.set(this, 0); ! ITEM_ALIGN.set(this, Graphics.HCENTER); ! SCROLL_DELAY.set(this, 2000); ! SCROLL_PERIOD.set(this, 50); ! int dFace = DEFAULT_FONT_FACE.get(this, Font.FACE_PROPORTIONAL); ! int dStyle = DEFAULT_FONT_STYLE.get(this, Font.STYLE_PLAIN); ! int dSize = DEFAULT_FONT_SIZE.get(this, Font.SIZE_MEDIUM); ! setDefault(DEFAULT_FONT, Style.getFontValue(Font.getFont(dFace, dStyle, dSize))); ! int sFace = DEFAULT_FONT_FACE.get(this, Font.FACE_PROPORTIONAL); ! int sStyle = DEFAULT_FONT_STYLE.get(this, Font.STYLE_BOLD); ! int sSize = DEFAULT_FONT_SIZE.get(this, Font.SIZE_MEDIUM); ! setDefault(SELECTED_FONT, Style.getFontValue(Font.getFont(sFace, sStyle, sSize))); ! INSET_WIDTH.set(this, 2); } public Widget set(int property, int value) { ! if (property == DEFAULT_FONT.getId()) { ! defaultFont = Style.getFont(value); ! } else if (property == SELECTED_FONT.getId()) { ! selectedFont = Style.getFont(value); } return super.set(property,value); *************** *** 141,152 **** int ypos = 0; for (int i = topIndex; i < topIndex + sz; i++) { ! graphics.setColor(i == selected ? properties[SELECTED_COLOR] ! : properties[FOREGROUND_COLOR]); Font toUse = (i == selected) ? selectedFont : defaultFont; graphics.setFont(toUse); int hpos = 0; ! if (properties[ITEM_ALIGN] == Graphics.HCENTER) { hpos = (w - 2 * getTotalInset()) / 2; ! } else if (properties[ITEM_ALIGN] == Graphics.RIGHT) { hpos = w - 2 * getTotalInset(); } --- 170,181 ---- int ypos = 0; for (int i = topIndex; i < topIndex + sz; i++) { ! graphics.setColor(i == selected ? properties[SELECTED_COLOR.getId()] ! : properties[FOREGROUND_COLOR.getId()]); Font toUse = (i == selected) ? selectedFont : defaultFont; graphics.setFont(toUse); int hpos = 0; ! if (properties[ITEM_ALIGN.getId()] == Graphics.HCENTER) { hpos = (w - 2 * getTotalInset()) / 2; ! } else if (properties[ITEM_ALIGN.getId()] == Graphics.RIGHT) { hpos = w - 2 * getTotalInset(); } *************** *** 154,158 **** graphics.drawString((String) items.elementAt(i % items.size()), hpos, ypos, ! properties[ITEM_ALIGN] | Graphics.TOP); ypos += toUse.getHeight(); } --- 183,187 ---- graphics.drawString((String) items.elementAt(i % items.size()), hpos, ypos, ! properties[ITEM_ALIGN.getId()] | Graphics.TOP); ypos += toUse.getHeight(); } *************** *** 229,233 **** if ((container.fixedW > 0) && (selectedFont.stringWidth(getString(selected)) > container.fixedW)) { if (scrollTask == null) { ! scrollTask = new SynclastTask(this, properties[SCROLL_DELAY], properties[SCROLL_PERIOD], true); } } --- 258,262 ---- if ((container.fixedW > 0) && (selectedFont.stringWidth(getString(selected)) > container.fixedW)) { if (scrollTask == null) { ! scrollTask = new SynclastTask(this, properties[SCROLL_DELAY.getId()], properties[SCROLL_PERIOD.getId()], true); } } *************** *** 281,283 **** --- 310,315 ---- } + public String getStyleName() { + return "menu"; + } } Index: Button.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/Button.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Button.java 17 Sep 2004 23:12:42 -0000 1.12 --- Button.java 18 Sep 2006 07:59:05 -0000 1.13 *************** *** 20,24 **** package com.synclast.ui; - import com.synclast.StyleSheet; import com.synclast.Event; --- 20,23 ---- *************** *** 53,70 **** protected void init() { super.init(); ! set(BORDER_COLOR, Color.BLACK); ! set(BORDER_WIDTH, 1); ! set(INSET_WIDTH, 2); } public void focus() { ! properties[BORDER_WIDTH]++; ! properties[INSET_WIDTH]--; repaint(); } public void blur() { ! properties[BORDER_WIDTH]--; ! properties[INSET_WIDTH]++; repaint(); } --- 52,69 ---- protected void init() { super.init(); ! BORDER_COLOR.set(this, Color.BLACK); ! BORDER_WIDTH.set(this, 1); ! INSET_WIDTH.set(this, 2); } public void focus() { ! properties[BORDER_WIDTH.getId()]++; ! properties[INSET_WIDTH.getId()]--; repaint(); } public void blur() { ! properties[BORDER_WIDTH.getId()]--; ! properties[INSET_WIDTH.getId()]++; repaint(); } *************** *** 94,96 **** --- 93,99 ---- public boolean pointerDragged(int x, int y) { return false; } public boolean pointerReleased(int x, int y) { return false; } + + public String getStyleName() { + return "button"; + } } Index: SynclastImage.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/SynclastImage.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SynclastImage.java 28 Jan 2004 02:33:01 -0000 1.8 --- SynclastImage.java 18 Sep 2006 07:59:05 -0000 1.9 *************** *** 35,37 **** --- 35,41 ---- h = image.getHeight(); } + + public String getStyleName() { + return "image"; + } } Index: ColoredWidget.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/ColoredWidget.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** ColoredWidget.java 17 Sep 2004 23:13:34 -0000 1.20 --- ColoredWidget.java 18 Sep 2006 07:59:05 -0000 1.21 *************** *** 20,28 **** package com.synclast.ui; import javax.microedition.lcdui.Graphics; import javax.microedition.lcdui.Image; - import com.synclast.StyleSheet; - /** * Base class for widgets that are rectangular or rounded and have --- 20,27 ---- package com.synclast.ui; + import java.util.Hashtable; import javax.microedition.lcdui.Graphics; import javax.microedition.lcdui.Image; /** * Base class for widgets that are rectangular or rounded and have *************** *** 38,65 **** */ public class ColoredWidget extends Widget { ! /** Constant for style sheet property. */ ! public static final int FOREGROUND_COLOR = Widget.LAST_PROPERTY + 1; ! /** Constant for style sheet property. */ ! public static final int BACKGROUND_COLOR = Widget.LAST_PROPERTY + 2; ! /** Constant for style sheet property. */ ! public static final int BORDER_COLOR = Widget.LAST_PROPERTY + 3; ! /** Constant for style sheet property. */ ! public static final int BORDER_ARC = Widget.LAST_PROPERTY + 4; ! /** Constant for style sheet property. */ ! public static final int BORDER_WIDTH = Widget.LAST_PROPERTY + 5; ! /** Constant for style sheet property. */ ! public static final int IMAGE_MODE = Widget.LAST_PROPERTY + 6; ! /** Constant for style sheet property. */ ! public static final int INSET_WIDTH = Widget.LAST_PROPERTY + 7; ! protected static final int LAST_PROPERTY = INSET_WIDTH; // Workaround for MIDP 1.0 .class access public static Class _class = new ColoredWidget().getClass(); - /** Constant for IMAGE_MODE property. */ - public static final int TILED = 0; - /** Constant for IMAGE_MODE property. */ - public static final int CENTERED = 1; protected Image backgroundImage; --- 37,63 ---- */ public class ColoredWidget extends Widget { ! /** Constant for IMAGE_MODE property. */ ! public static final int TILED = 0; ! /** Constant for IMAGE_MODE property. */ ! public static final int CENTERED = 1; ! public static final Style FOREGROUND_COLOR = new Style(Style.STYLE_TYPE_COLOR, "color", Widget.LAST_PROPERTY + 1, Style.CASCADE); ! public static final Style BACKGROUND_COLOR = new Style(Style.STYLE_TYPE_COLOR, "background-color", Widget.LAST_PROPERTY + 2, Style.CASCADE); ! public static final Style BORDER_COLOR = new Style(Style.STYLE_TYPE_COLOR, "border-color", Widget.LAST_PROPERTY + 3, Style.NO_CASCADE); ! public static final Style BORDER_ARC = new Style(Style.STYLE_TYPE_SIZE, "border-arc", Widget.LAST_PROPERTY + 4, Style.NO_CASCADE); ! public static final Style BORDER_WIDTH = new Style(Style.STYLE_TYPE_SIZE, "border-width", Widget.LAST_PROPERTY + 5, Style.NO_CASCADE); ! protected static final Style IMAGE_MODE; ! static { ! Hashtable imageModeMap = new Hashtable(); ! imageModeMap.put("tiled", new Integer(TILED)); ! imageModeMap.put("centered", new Integer(CENTERED)); ! IMAGE_MODE = new Style("image-mode", Widget.LAST_PROPERTY + 6, Style.NO_CASCADE, imageModeMap); ! } ! public static final Style INSET_WIDTH = new Style(Style.STYLE_TYPE_SIZE, "inset-width", Widget.LAST_PROPERTY + 7, Style.NO_CASCADE); ! protected static final int LAST_PROPERTY = INSET_WIDTH.getId(); // Workaround for MIDP 1.0 .class access public static Class _class = new ColoredWidget().getClass(); protected Image backgroundImage; *************** *** 78,83 **** protected void init() { super.init(); ! set(BACKGROUND_COLOR, Color.TRANSPARENT); ! set(BORDER_COLOR, Color.TRANSPARENT); } --- 76,86 ---- protected void init() { super.init(); ! FOREGROUND_COLOR.set(this, 0x000000); ! BACKGROUND_COLOR.set(this, Color.TRANSPARENT); ! BORDER_COLOR.set(this, Color.TRANSPARENT); ! BORDER_ARC.set(this, 0); ! BORDER_WIDTH.set(this, 0); ! IMAGE_MODE.set(this, TILED); ! INSET_WIDTH.set(this, 0); } *************** *** 91,107 **** */ public void paint(Graphics graphics) { ! int borderWidth = properties[BORDER_WIDTH]; ! if (backgroundImage == null || properties[IMAGE_MODE] == CENTERED) { ! if (properties[BACKGROUND_COLOR] != Color.TRANSPARENT) { ! graphics.setColor(properties[BACKGROUND_COLOR]); graphics.fillRoundRect(borderWidth, borderWidth, w - borderWidth * 2, h - borderWidth * 2, ! properties[BORDER_ARC], ! properties[BORDER_ARC]); } } if (backgroundImage != null) { ! switch (properties[IMAGE_MODE]) { case CENTERED: graphics.drawImage(backgroundImage, w/2, h/2, --- 94,110 ---- */ public void paint(Graphics graphics) { ! int borderWidth = properties[BORDER_WIDTH.getId()]; ! if (backgroundImage == null || properties[IMAGE_MODE.getId()] == CENTERED) { ! if (properties[BACKGROUND_COLOR.getId()] != Color.TRANSPARENT) { ! graphics.setColor(properties[BACKGROUND_COLOR.getId()]); graphics.fillRoundRect(borderWidth, borderWidth, w - borderWidth * 2, h - borderWidth * 2, ! properties[BORDER_ARC.getId()], ! properties[BORDER_ARC.getId()]); } } if (backgroundImage != null) { ! switch (properties[IMAGE_MODE.getId()]) { case CENTERED: graphics.drawImage(backgroundImage, w/2, h/2, *************** *** 128,137 **** } if (borderWidth > 0) { ! if (properties[BORDER_COLOR] != Color.TRANSPARENT) { ! graphics.setColor(properties[BORDER_COLOR]); for (int i = 0; i < borderWidth; i++) { graphics.drawRoundRect(i,i,w-1-i*2,h-1-i*2, ! properties[BORDER_ARC] - i * 2, ! properties[BORDER_ARC] - i * 2); } } --- 131,140 ---- } if (borderWidth > 0) { ! if (properties[BORDER_COLOR.getId()] != Color.TRANSPARENT) { ! graphics.setColor(properties[BORDER_COLOR.getId()]); for (int i = 0; i < borderWidth; i++) { graphics.drawRoundRect(i,i,w-1-i*2,h-1-i*2, ! properties[BORDER_ARC.getId()] - i * 2, ! properties[BORDER_ARC.getId()] - i * 2); } } *************** *** 144,148 **** graphics.translate(totalInset, totalInset); } ! graphics.setColor(properties[FOREGROUND_COLOR]); } --- 147,151 ---- graphics.translate(totalInset, totalInset); } ! graphics.setColor(properties[FOREGROUND_COLOR.getId()]); } *************** *** 157,165 **** protected int getTotalInset() { ! return properties[BORDER_WIDTH] + properties[INSET_WIDTH]; } public Widget set(int property, int value) { ! if ((property == BORDER_WIDTH) || (property == INSET_WIDTH)) { int delta = 2 * (value - properties[property]); w += delta; --- 160,169 ---- protected int getTotalInset() { ! return properties[BORDER_WIDTH.getId()] + ! properties[INSET_WIDTH.getId()]; } public Widget set(int property, int value) { ! if ((property == BORDER_WIDTH.getId()) || (property == INSET_WIDTH.getId())) { int delta = 2 * (value - properties[property]); w += delta; *************** *** 168,170 **** --- 172,179 ---- return super.set(property, value); } + + public String getStyleName() { + //in general you shouldn't be using a ColoredWidget for styling. But it is possible, so... + return "coloredwidget"; + } } Index: Container.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/Container.java,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** Container.java 12 Feb 2006 03:39:21 -0000 1.36 --- Container.java 18 Sep 2006 07:59:05 -0000 1.37 *************** *** 25,29 **** import com.synclast.Event; - import com.synclast.StyleSheet; /** --- 25,28 ---- *************** *** 181,186 **** * components may have been resized. */ ! public void applyStyleSheet(StyleSheet sheet) { ! super.applyStyleSheet(sheet); // Apply just the new styleSheet to contained widgets --- 180,185 ---- * components may have been resized. */ ! public void applyStyleSheet() {//StyleSheet sheet) { ! super.applyStyleSheet();//sheet); // Apply just the new styleSheet to contained widgets *************** *** 188,192 **** for (int i = widgets.size() - 1; i >= 0; --i) { widget = (Widget) widgets.elementAt(i); ! widget.applyStyleSheet(sheet); } } --- 187,191 ---- for (int i = widgets.size() - 1; i >= 0; --i) { widget = (Widget) widgets.elementAt(i); ! widget.applyStyleSheet();//sheet); } } *************** *** 197,201 **** */ protected void borderLayout(Widget widget, int width, int height) { ! int align = widget.properties[Widget.ALIGN]; if ((align & VERTICAL) != 0) { --- 196,200 ---- */ protected void borderLayout(Widget widget, int width, int height) { ! int align = widget.properties[Widget.ALIGN.getId()]; if ((align & VERTICAL) != 0) { *************** *** 253,263 **** // Apply style sheet, if available UIContext context = getContext(); ! if (context != null) { ! widget.applyStyleSheet(context.getStyleSheet()); ! } widget.setContainer(this); if(!widgets.contains(widget)) { widgets.addElement(widget); } if (context != null && context.isShown()) { widget.showNotify(); --- 252,263 ---- // Apply style sheet, if available UIContext context = getContext(); ! //add to containment, then style, so cascade works properly. widget.setContainer(this); if(!widgets.contains(widget)) { widgets.addElement(widget); } + if (context != null) { + widget.applyStyleSheet();//context.getStyleSheet()); + } if (context != null && context.isShown()) { widget.showNotify(); *************** *** 566,568 **** --- 566,572 ---- ((context != null) && context.fireEvent(event)); } + + public String getStyleName() { + return "container"; + } } Index: TapInputAdapter.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/TapInputAdapter.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TapInputAdapter.java 5 Feb 2004 01:35:33 -0000 1.6 --- TapInputAdapter.java 18 Sep 2006 07:59:05 -0000 1.7 *************** *** 23,28 **** import javax.microedition.lcdui.Graphics; - import com.synclast.StyleSheet; - /** * Implements the "multitap" method of text entry. Each digit key is mapped --- 23,26 ---- Index: Checkbox.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/Checkbox.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Checkbox.java 17 Sep 2004 23:12:42 -0000 1.10 --- Checkbox.java 18 Sep 2006 07:59:05 -0000 1.11 *************** *** 25,29 **** import com.synclast.Event; - import com.synclast.StyleSheet; /** --- 25,28 ---- *************** *** 43,49 **** protected void init() { super.init(); ! set(BORDER_WIDTH, 1); ! set(BORDER_COLOR, Color.BLACK); ! set(BACKGROUND_COLOR, Color.LIGHT_GRAY); } --- 42,48 ---- protected void init() { super.init(); ! BORDER_WIDTH.set(this, 1); ! BORDER_COLOR.set(this, Color.BLACK); ! BACKGROUND_COLOR.set(this, Color.LIGHT_GRAY); } *************** *** 53,62 **** public void focus() { ! properties[BORDER_WIDTH]++; repaint(); } public void blur() { ! properties[BORDER_WIDTH]--; repaint(); } --- 52,61 ---- public void focus() { ! properties[BORDER_WIDTH.getId()]++; repaint(); } public void blur() { ! properties[BORDER_WIDTH.getId()]--; repaint(); } *************** *** 105,107 **** --- 104,110 ---- public boolean pointerDragged(int x, int y) { return false; } public boolean pointerReleased(int x, int y) { return false; } + + public String getStyleName() { + return "checkbox"; + } } Index: TableContainer.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/TableContainer.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TableContainer.java 28 Jan 2004 02:33:01 -0000 1.5 --- TableContainer.java 18 Sep 2006 07:59:05 -0000 1.6 *************** *** 206,208 **** --- 206,212 ---- } } + + public String getStyleName() { + return "table"; + } } Index: Input.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/Input.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Input.java 17 Sep 2004 23:14:26 -0000 1.20 --- Input.java 18 Sep 2006 07:59:05 -0000 1.21 *************** *** 20,23 **** --- 20,24 ---- package com.synclast.ui; + import java.util.Hashtable; import java.util.Vector; *************** *** 28,32 **** import com.synclast.Event; - import com.synclast.StyleSheet; import com.synclast.SynclastTask; import com.synclast.SynclastManager; --- 29,32 ---- *************** *** 46,51 **** public class Input extends ColoredWidget implements KeyEventListener, PointerEventListener, InputHandler, Runnable { - // Workaround for MIDP 1.0 .class access - public static Class _class = new Input().getClass(); /** --- 46,49 ---- *************** *** 54,65 **** * in the text. */ ! public static final int MASK_CHAR = ColoredWidget.LAST_PROPERTY + 1; - public static final int FONT = ColoredWidget.LAST_PROPERTY + 2; - public static final int CURSOR_BLINK_DELAY = ColoredWidget.LAST_PROPERTY + 3; - public static final int MAX_SIZE = ColoredWidget.LAST_PROPERTY + 4; - public static final int WIDTH = ColoredWidget.LAST_PROPERTY + 5; ! protected static final int LAST_PROPERTY = WIDTH; private SynclastTask cursor; --- 52,86 ---- * in the text. */ ! public static final Style MASK_CHAR = new Style( ! Style.STYLE_TYPE_CHAR, "mask-char", ! ColoredWidget.LAST_PROPERTY + 1, Style.NO_CASCADE); ! public static final Style FONT = new Style( ! Style.STYLE_TYPE_SIZE, "", ! ColoredWidget.LAST_PROPERTY + 2, Style.CASCADE); ! public static final Style CURSOR_BLINK_DELAY = new Style( ! Style.STYLE_TYPE_SIZE, "cursor-blink-delay", ! ColoredWidget.LAST_PROPERTY + 3, Style.NO_CASCADE); ! public static final Style MAX_SIZE = new Style( ! Style.STYLE_TYPE_SIZE, "max-size", ! ColoredWidget.LAST_PROPERTY + 4, Style.NO_CASCADE); ! public static final Style WIDTH = new Style( ! Style.STYLE_TYPE_SIZE, "width", ! ColoredWidget.LAST_PROPERTY + 5, Style.NO_CASCADE); ! protected static final Style FONT_STYLE = ! Style.getAggregatedEnumerationStyle("font-style", -1, Style.CASCADE, ! Style.FONT_STYLE); ! protected static final Style FONT_FACE = ! new Style("font-size", -1, Style.CASCADE, ! Style.FONT_FACE); ! protected static final Style FONT_SIZE = ! new Style("font-face", -1, Style.CASCADE, ! Style.FONT_SIZE); ! ! protected static final int LAST_PROPERTY = WIDTH.getId(); ! ! // Workaround for MIDP 1.0 .class access ! public static Class _class = new Input().getClass(); private SynclastTask cursor; *************** *** 96,105 **** protected void init() { super.init(); ! set(BORDER_WIDTH, 1) ! .set(BORDER_COLOR, Color.BLACK) ! .set(INSET_WIDTH, 2) ! .set(CURSOR_BLINK_DELAY, 500) ! .set(MAX_SIZE, 10) ! .set(FONT, StyleSheet.getFontValue(Font.getDefaultFont())); } --- 117,135 ---- protected void init() { super.init(); ! MASK_CHAR.set(this, 0); ! CURSOR_BLINK_DELAY.set(this, 500); ! MAX_SIZE.set(this, 10); ! //WIDTH.set(this, 10); ! ! ! Font defaultFont = Font.getDefaultFont(); ! int fFace = FONT_FACE.get(this, defaultFont.getFace()); ! int fStyle = FONT_STYLE.get(this, defaultFont.getStyle()); ! int fSize = FONT_SIZE.get(this, defaultFont.getSize()); ! setDefault(FONT, Style.getFontValue(Font.getFont(fFace, fStyle, fSize))); ! ! BORDER_WIDTH.set(this, 1); ! BORDER_COLOR.set(this, Color.BLACK); ! INSET_WIDTH.set(this, 2); } *************** *** 135,139 **** public int getMaxSize() { ! return properties[MAX_SIZE]; } --- 165,169 ---- public int getMaxSize() { ! return properties[MAX_SIZE.getId()]; } *************** *** 148,154 **** if (text.length() > 0) { char[] temp = text.toString().toCharArray(); ! if (properties[MASK_CHAR] != 0) { for (int i = 0; i < temp.length; i++) { ! temp[i] = (char) properties[MASK_CHAR]; } } --- 178,184 ---- if (text.length() > 0) { char[] temp = text.toString().toCharArray(); ! if (properties[MASK_CHAR.getId()] != 0) { for (int i = 0; i < temp.length; i++) { ! temp[i] = (char) properties[MASK_CHAR.getId()]; } } *************** *** 168,173 **** public void backspace() { if (pos != 0) { ! pixelOffset -= font.charWidth(properties[MASK_CHAR] != 0 ? ! (char) properties[MASK_CHAR] : text.charAt(pos - 1)); text.deleteCharAt(--pos); --- 198,203 ---- public void backspace() { if (pos != 0) { ! pixelOffset -= font.charWidth(properties[MASK_CHAR.getId()] != 0 ? ! (char) properties[MASK_CHAR.getId()] : text.charAt(pos - 1)); text.deleteCharAt(--pos); *************** *** 177,184 **** public void addCharacter(char ch) { ! if (pos < properties[MAX_SIZE]) { text.insert(pos++, ch); ! if (properties[MASK_CHAR] != 0) { ! ch = (char) properties[MASK_CHAR]; } pixelOffset += font.charWidth(ch); --- 207,214 ---- public void addCharacter(char ch) { ! if (pos < properties[MAX_SIZE.getId()]) { text.insert(pos++, ch); ! if (properties[MASK_CHAR.getId()] != 0) { ! ch = (char) properties[MASK_CHAR.getId()]; } pixelOffset += font.charWidth(ch); *************** *** 227,232 **** if (pos > 0) { --pos; ! pixelOffset -= font.charWidth(properties[MASK_CHAR] != 0 ? ! (char) properties[MASK_CHAR] : text.charAt(pos)); } --- 257,262 ---- if (pos > 0) { --pos; ! pixelOffset -= font.charWidth(properties[MASK_CHAR.getId()] != 0 ? ! (char) properties[MASK_CHAR.getId()] : text.charAt(pos)); } *************** *** 235,240 **** while (direction > 0) { if (pos < text.length()) { ! pixelOffset += font.charWidth(properties[MASK_CHAR] != 0 ? ! (char) properties[MASK_CHAR] : text.charAt(pos)); pos++; --- 265,270 ---- while (direction > 0) { if (pos < text.length()) { ! pixelOffset += font.charWidth(properties[MASK_CHAR.getId()] != 0 ? ! (char) properties[MASK_CHAR.getId()] : text.charAt(pos)); pos++; *************** *** 258,265 **** public void focus() { on = true; ! properties[BORDER_WIDTH]++; ! properties[INSET_WIDTH]--; repaint(); ! int delay = properties[CURSOR_BLINK_DELAY]; if (delay > 0) { cursor = new SynclastTask(this, delay, delay, true); --- 288,295 ---- public void focus() { on = true; ! properties[BORDER_WIDTH.getId()]++; ! properties[INSET_WIDTH.getId()]--; repaint(); ! int delay = properties[CURSOR_BLINK_DELAY.getId()]; if (delay > 0) { cursor = new SynclastTask(this, delay, delay, true); *************** *** 271,276 **** public void blur() { ! properties[BORDER_WIDTH]--; ! properties[INSET_WIDTH]++; if (cursor != null) { cursor.cancel(); --- 301,306 ---- public void blur() { ! properties[BORDER_WIDTH.getId()]--; ! properties[INSET_WIDTH.getId()]++; if (cursor != null) { cursor.cancel(); *************** *** 282,312 **** public Widget set(int property, int value) { ! if (property == FONT) { if (font != null) { ! if (properties[WIDTH] == 0) { ! w -= properties[MAX_SIZE] * font.charWidth('x'); } h -= font.getHeight(); } ! font = StyleSheet.getFont(value); ! if (properties[WIDTH] == 0) { ! w += properties[MAX_SIZE] * font.charWidth('x'); } h += font.getHeight(); // Recalculate pixelOffset if (text != null) { ! if (properties[MASK_CHAR] == 0) { pixelOffset = font.substringWidth(text.toString(), 0, pos); } else { ! pixelOffset = pos * font.charWidth((char) properties[MASK_CHAR]); } } invalidate(); ! } else if (property == WIDTH) { w = value; invalidate(); ! } else if (property == MAX_SIZE) { ! if ((font != null) && (properties[WIDTH] == 0)) { ! w -= properties[MAX_SIZE] * font.charWidth('x'); w += value * font.charWidth('x'); invalidate(); --- 312,342 ---- public Widget set(int property, int value) { ! if (property == FONT.getId()) { if (font != null) { ! if (properties[WIDTH.getId()] == 0) { ! w -= properties[MAX_SIZE.getId()] * font.charWidth('x'); } h -= font.getHeight(); } ! font = Style.getFont(value); ! if (properties[WIDTH.getId()] == 0) { ! w += properties[MAX_SIZE.getId()] * font.charWidth('x'); } h += font.getHeight(); // Recalculate pixelOffset if (text != null) { ! if (properties[MASK_CHAR.getId()] == 0) { pixelOffset = font.substringWidth(text.toString(), 0, pos); } else { ! pixelOffset = pos * font.charWidth((char) properties[MASK_CHAR.getId()]); } } invalidate(); ! } else if (property == WIDTH.getId()) { w = value; invalidate(); ! } else if (property == MAX_SIZE.getId()) { ! if ((font != null) && (properties[WIDTH.getId()] == 0)) { ! w -= properties[MAX_SIZE.getId()] * font.charWidth('x'); w += value * font.charWidth('x'); invalidate(); *************** *** 326,334 **** pos = pixelOffset = 0; ! while ((pos < text.length()) && (pixelOffset < (x - properties[INSET_WIDTH] - properties[BORDER_WIDTH]))) { ! if (properties[MASK_CHAR] == 0) { pixelOffset += font.charWidth(text.charAt(pos++)); } else { ! pixelOffset += font.charWidth((char) properties[MASK_CHAR]); pos++; } --- 356,364 ---- pos = pixelOffset = 0; ! while ((pos < text.length()) && (pixelOffset < (x - properties[INSET_WIDTH.getId()] - properties[BORDER_WIDTH.getId()]))) { ! if (properties[MASK_CHAR.getId()] == 0) { pixelOffset += font.charWidth(text.charAt(pos++)); } else { ! pixelOffset += font.charWidth((char) properties[MASK_CHAR.getId()]); pos++; } *************** *** 338,340 **** --- 368,374 ---- public boolean pointerDragged(int x, int y) { return false; } public boolean pointerReleased(int x, int y) { return false; } + + public String getStyleName() { + return "input"; + } } --- NEW FILE: Style.java --- package com.synclast.ui; import com.synclast.StyleSheet; import java.util.Enumeration; import java.util.Hashtable; import java.util.Vector; import javax.microedition.lcdui.Font; import javax.microedition.lcdui.Graphics; /** * Style handles parsing string values from stylesheet for use by widgets. Style fulfills two prinicipal roles: * <ol> * <li>Act as a prototype for each style attribute a widget can expose, including<ol> * <li>name of style in the stylesheet</li> * <li>the type of style this instance represents, such as:<ul> * <li>a color</li> * <li>a number</li> * <li>a character</li> * <li>a set of enumerated values</li> * </ul> * <li>a numeric id for this style prototype for use by the Widget.set method</li> * <li>a default value for this style if none is found in the current stylesheet</li> * </ol> * <li>Handle the parsing of style values from the "raw" value contained by the stylesheet, into the actual value useful to the widget. Parsing is accomplished by using the type information.</li> * </ol> * This class does not define the <i>actual</i> styles the widgets have. Instead it defines the types of Styles that are possible, and each Widget declares zero or more styles that it knows how to handle. Widgets also inherit Styles from their superclasses.<br/> * Everytime a widget is added to a container, or a new stylesheet is set on the Canvas containing a widget, the style class will be used to reparse the values for that widget, based on the current stylesheet and containment hierarchy. See <code>StyleSheet</code> for a detailed explanation on how the StyleSheet mechanism cascade works. The name a widget uses for the StyleSheet, and the set of styles a widget declares, are documented on each widget. * @author Harry Evans */ public class Style { /** * The token used by aggregate styles. For example, font-style: bold,italic has a comma, that separates the aggregate values for the style "font-style". */ public static final char AGGREGATE_TOKEN = ','; /** * A simple numeric value style, used for widths and other sizes. Can be used for any simple numeric style type. */ public static final int STYLE_TYPE_SIZE = 0; /** * A style to denote colors, in hex notation. It assumes values are in AARRGGBB base 16 notation (alpha, red, grean, and blue), for example 00FF00AA, with an optional 0x prefix allows (0xFF00AA). If leading values are 0's, they can be ommitted (0x0000FF66 == 0xFF66). */ public static final int STYLE_TYPE_COLOR = 1; /** * A style to denote a single character, such as an input mask char. Will take the firct character as its returned value (so "c" == 'c' and "cat" == 'c'). */ public static final int STYLE_TYPE_CHAR = 2; /** * A style to denote a fixed set of possible values. When this style is constructed, it takes a map of possible keys, with each key mapping to a specific numeric value. This can be used, for example, as a set of "friendly" color names. k:"Red" v:"16711680", k:"Green" v:"65280", k:"Blue" v:"255" would allow friendly color names for a style. Can also map to alignment or other types. */ public static final int STYLE_TYPE_ENUMERATION = 3; /** * A style to denote a fixed set of possible values, but where there can be more than one value per key. For example, "font-style: bold,italic,underline" can be defined as an aggegated enumeration, with k:"bold" v:"Font.STYLE_BOLD" k:"italic" v:"Font.STYLE_ITALIC", k:"underline" v:"Font.STYLE_UNDERLINE". The returned value will be Font.STYLE_BOLD | Font.STYLE_ITALIC | Font.STYLE_UNDERLINE. */ public static final int STYLE_TYPE_AGGREGATED_ENUMERATION = 4; private static final String[] NAMES = { "STYLE_TYPE_SIZE", "STYLE_TYPE_COLOR", "STYLE_TYPE_CHAR", "STYLE_TYPE_ENUMERATION", "STYLE_TYPE_AGGREGATED_ENUMERATION" }; /** * Convenience table for enumerated style types, to prevent the multiple definitions of horizontal alignment types. Uses the values defined in javax.microedition.lcdui.Graphics for horizintal alignment values (LEFT, RIGHT, and CENTER). */ public static final Hashtable H_ALIGNMENT_TABLE; /** * Convenience table for enumerated style types, to prevent the multiple definitions of vertical alignment types. Uses the values defined in javax.microedition.lcdui.Graphics for vertical alignment values (TOP, VCENTER, and BOTTOM). */ public static final Hashtable V_ALIGNMENT_TABLE; /** * Convenience table for enumerated style types, to prevent the multiple definitions of horizontal and vertical alignment types. Uses the values defined in javax.microedition.lcdui.Graphics for horizontal and vertical alignment values (LEFT, CENTER, RIGHT, TOP, VCENTER, and BOTTOM). */ public static final Hashtable ALIGNMENT_COMBO_TABLE; //set of tables for font styles public static final Hashtable FONT_FACE; public static final Hashtable FONT_STYLE; public static final Hashtable FONT_SIZE; static { H_ALIGNMENT_TABLE = new Hashtable(); H_ALIGNMENT_TABLE.put("left", new Integer(Graphics.LEFT)); H_ALIGNMENT_TABLE.put("right", new Integer(Graphics.RIGHT)); H_ALIGNMENT_TABLE.put("hcenter", new Integer(Graphics.HCENTER)); V_ALIGNMENT_TABLE = new Hashtable(); V_ALIGNMENT_TABLE.put("top", new Integer(Graphics.TOP)); V_ALIGNMENT_TABLE.put("bottom", new Integer(Graphics.BOTTOM)); V_ALIGNMENT_TABLE.put("vcenter", new Integer(Graphics.VCENTER)); //there is probably a better way to do this, but for now, //just do all 24 combinations of alignments Hashtable act = new Hashtable(24); act.put("top", new Integer(Graphics.TOP)); act.put("top,left", new Integer(Graphics.TOP|Graphics.LEFT)); act.put("top,center", new Integer(Graphics.TOP|Graphics.HCENTER)); act.put("top,right", new Integer(Graphics.TOP|Graphics.RIGHT)); act.put("vcenter", new Integer(Graphics.VCENTER)); act.put("vcenter,left", new Integer(Graphics.VCENTER|Graphics.LEFT)); act.put("vcenter,center", new Integer(Graphics.VCENTER|Graphics.HCENTER)); act.put("vcenter,right", new Integer(Graphics.VCENTER|Graphics.RIGHT)); act.put("bottom", new Integer(Graphics.BOTTOM)); act.put("bottom,left", new Integer(Graphics.BOTTOM|Graphics.LEFT)); act.put("bottom,center", new Integer(Graphics.BOTTOM|Graphics.HCENTER)); act.put("bottom,right", new Integer(Graphics.BOTTOM|Graphics.RIGHT)); act.put("left", new Integer(Graphics.LEFT)); act.put("left,top", new Integer(Graphics.LEFT|Graphics.TOP)); act.put("left,vcenter", new Integer(Graphics.LEFT|Graphics.VCENTER)); act.put("left,bottom", new Integer(Graphics.LEFT|Graphics.BOTTOM)); act.put("center", new Integer(Graphics.HCENTER)); act.put("center,top", new Integer(Graphics.HCENTER|Graphics.TOP)); act.put("center,vcenter", new Integer(Graphics.HCENTER|Graphics.VCENTER)); act.put("center,bottom", new Integer(Graphics.HCENTER|Graphics.BOTTOM)); act.put("right", new Integer(Graphics.RIGHT)); act.put("right,top", new Integer(Graphics.RIGHT|Graphics.TOP)); act.put("right,vcenter", new Integer(Graphics.RIGHT|Graphics.VCENTER)); act.put("right,bottom", new Integer(Graphics.RIGHT|Graphics.BOTTOM)); ALIGNMENT_COMBO_TABLE = act; FONT_STYLE = new Hashtable(); FONT_STYLE.put("bold", new Integer(Font.STYLE_BOLD)); FONT_STYLE.put("italic", new Integer(Font.STYLE_ITALIC)); FONT_STYLE.put("plain", new Integer(Font.STYLE_PLAIN)); FONT_STYLE.put("underlined", new Integer(Font.STYLE_UNDERLINED)); FONT_SIZE = new Hashtable(); FONT_SIZE.put("large", new Integer(Font.SIZE_LARGE)); FONT_SIZE.put("medium", new Integer(Font.SIZE_MEDIUM)); FONT_SIZE.put("smalle", new Integer(Font.SIZE_SMALL)); FONT_FACE = new Hashtable(); FONT_FACE.put("monospace", new Integer(Font.FACE_MONOSPACE)); FONT_FACE.put("proportional", new Integer(Font.FACE_PROPORTIONAL)); FONT_FACE.put("system", new Integer(Font.FACE_SYSTEM)); } public static final boolean CASCADE = true; public static final boolean NO_CASCADE = false; private int type; private int id; private String name; private Hashtable enumMap; private boolean cascade; /** * Make a new Style object. In general, this is only done by widgets, not application code, and the Styles created are static final on the widget they are declared on, since style does not store instance information, and it is therefore pointless to declare it for each widget instance. * @param aType the type of this Style. One of the STYLE_XXX constants declared on this class. * @param aName the name this style will have in a StyleSheet when it is parsed. * @param anId the id used by the widget that is declaring this style. */ public Style(int aType, String aName, int anId, boolean aCascade) { type = aType; id = anId; name = aName; cascade = aCascade; } /** * Construct a Style for enumerated values. This will make a style with type= STYLE_TYPE_ENUMERATION. The hashtable passed in needs to be specially constructed. It must have keys of type String, and values of type int. When the StyleSheet value is parsed, if the resulting value is a key in this hashtable, the Integer value in this hashtable will be used. If it is not a key, the default value will be used. All keys in the <code>someValues</code> hashtable will be trimmed and changed to lowercase to make key lookup predicatable from values in the parsed stylesheet. */ public Style(String aName, int anId, boolean aCascade, Hashtable someValues) { this(STYLE_TYPE_ENUMERATION, aName, anId, aCascade); enumMap = new Hashtable(); for(Enumeration e = someValues.keys(); e.hasMoreElements();) { String key = (String)e.nextElement(); String newKey = (key == null) ? null : key.trim().toLowerCase(); enumMap.put(newKey, someValues.get(key)); } } public static Style getAggregatedEnumerationStyle(String aName, int anId, boolean aCascade, Hashtable someValues) { Style aStyle = new Style(aName, anId, aCascade, someValues); aStyle.type = STYLE_TYPE_AGGREGATED_ENUMERATION; return aStyle; } public int getType() { return type; } public int getId() { return id; } public String getName() { return name; } public boolean getCascade() { return cascade; } public String toString() { StringBuffer buf = new StringBuffer("Style["); buf.append("Type=\"").append(NAMES[type]).append("\","); buf.append("Name=\"").append(name).append("\","); buf.append("Id=\"").append(id).append("\","); buf.append("Cascade=\"").append(cascade).append("\"]"); return buf.toString(); } /** * Given a "raw" StyleSheet value, use the type for this Style to parse a useful value from it. For example, colors may be specified as "AARRGGBB" or 0xAARRGGBB", but if type is STYLE_TYPE_COLOR, will be returned as their integer value. If you are implementing a widget, and you know Style cannot parse your value, call Style.getString(Widget) to get the "raw" StyleSheet value directly. */ public int parseValue(String value, int defaultValue) { if(value == null) { return... [truncated message content] |
|
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")); |
|
From: Harry E. <har...@us...> - 2006-09-18 07:59:08
|
Update of /cvsroot/synclast/client/examples/SynclastUIDemo/res In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv31295/examples/SynclastUIDemo/res Added Files: form_midlet.css table_midlet.css 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. --- NEW FILE: form_midlet.css --- input { background-color: 0xcccccc; } checkbox { background-color: 0xcccccc; border-color: 0xff0000; color: 0xff0000; } label { color: 0xffffff; } button { color: 0x000000; background-color: 0xcccccc; } --- NEW FILE: table_midlet.css --- table { border-width: 1; border-color: 0x000000; } coloredwidget { border-width: 0; } |
|
From: Harry E. <har...@us...> - 2006-03-06 06:43:40
|
Update of /cvsroot/synclast/client/src/com/synclast/ui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13001 Modified Files: BoxContainer.java Log Message: Fixed a bug in the layout logic for BoxContainer. It has to do a full pass to determine its size, before it layouts anything. The old way caused it to incorrectly align things, if the first component was smaller than the second component, and the alignment was center or forward. I.E. a Vcentered box, with child 1 with h=10, and child 2 with h=20 would result in child 1 having a y=0 instead of a y=5. This was a nasty bug, becuase if you reverse the child order, everything worked great. Works now. Index: BoxContainer.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/BoxContainer.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** BoxContainer.java 23 Oct 2004 00:21:09 -0000 1.13 --- BoxContainer.java 6 Mar 2006 06:43:36 -0000 1.14 *************** *** 178,184 **** --- 178,191 ---- int size = widgets.size(); + //size first, then position. + //If we position while we size, we will use the wrong values for + //the child position, if we are center or forward aligned, unless the + //first component is the buggest. for(int i = 0; i < size; i++) { Widget widget = (Widget)widgets.elementAt(i); alterSize(widget); + } + for(int i = 0; i < size; i++) { + Widget widget = (Widget)widgets.elementAt(i); layout(widget); } |
|
From: Harry E. <har...@us...> - 2006-02-12 03:39:32
|
Update of /cvsroot/synclast/client/src/com/synclast/ui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24694 Modified Files: Container.java Log Message: Fixed the big that would cause an infinite focus loop if you added a subcontainer to a container and the subcontainer had no focusable items. Modified add(widget) and remove(widget) to not blindly assume that an added Container was focusable. Now, it will only think a Container is focusable if it has sub items that are focuable. The weird thing is that I thought I need to modify setFocusable(int delta) as well, but it already had the needed logic. It is as if this was partially implemented. Works now. Please report any bugs you might run into. Index: Container.java =================================================================== RCS file: /cvsroot/synclast/client/src/com/synclast/ui/Container.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** Container.java 7 Dec 2005 05:38:46 -0000 1.35 --- Container.java 12 Feb 2006 03:39:21 -0000 1.36 *************** *** 264,268 **** } // Update focusable status of the container as a whole ! if (widget instanceof KeyEventListener) { setFocusable(1); } --- 264,274 ---- } // Update focusable status of the container as a whole ! if(widget instanceof Container) { ! Container c = (Container)widget; ! //Containers only count as focusable if they have focuable children ! if(c.focusable > 0) { ! setFocusable(1); ! } ! } else if (widget instanceof KeyEventListener) { setFocusable(1); } *************** *** 299,303 **** } widget.setContainer(null); ! if (widget instanceof KeyEventListener) { setFocusable(-1); } --- 305,315 ---- } widget.setContainer(null); ! if(widget instanceof Container) { ! Container c = (Container)widget; ! //Containers only count as focusable if they have focuable children ! if(c.focusable > 0) { ! setFocusable(-1); ! } ! } else if (widget instanceof KeyEventListener) { setFocusable(-1); } *************** *** 416,419 **** --- 428,434 ---- private void setFocusable(int delta) { this.focusable += delta; + //handle parent case + //if we had no focusable children, and gained one, let our parent container know we are now focusable. + //if we had focusable chidlren, and lost all of them, let our parent container know we are no longer focusable. if ((container != null) && (((delta == -1) && (focusable == 0)) |