Re: [Xswt-developer] stylesheets
Brought to you by:
dvorme
|
From: <Yu...@no...> - 2006-07-06 07:11:20
|
Impressive and good job.=20 So I assume nested or cascading style sheets should work too? Yu You, Ph.D. Research Engineer Nokia Research Center, Tampere, FI =20 =20 >-----Original Message----- >From: xsw...@li...=20 >[mailto:xsw...@li...] On=20 >Behalf Of ext Hallvard Tr?tteberg >Sent: 06 July, 2006 00:48 >To: xsw...@li... >Subject: [Xswt-developer] stylesheets > >Hi, > >After implementing the tree builder, I've been working on the=20 >stylesheet mechanism, based on the design suggestions at=20 >http://www.coconut-palm-software.com/the_visual_editor/?page_id >=3D61. The current design is as follows: > >When the import/stylesheet tag is encountered, another=20 >instance of XSWT is used to load that stylesheet. Parsing a=20 >stylesheet differs somewhat from parsing an ordinary file, as=20 >it expects to find all the styles at the top level, and each=20 >must have an id. No objects are created, but the id map is=20 >used to "remember" the styles. What is important is that that=20 >XSWT instance keeps track of its own imports (and other state). > >When a style is referenced, the corresponding style=20 >tag/element/node is retrieved and parsed by the XSWT object=20 >that loaded it, but in the context of the referencing object. > >I think the basic design works, but haven't gone through all=20 >the details. >However, I've written the first test that works(!): > >public class StyleTest extends XSWTTestCase { > > public void testStyle() { > Label label =3D (Label)getChild(0, Label.class); > Color col =3D label.getBackground(); > assertEquals(255, col.getRed()); > assertEquals(0, col.getGreen()); > assertEquals(0, col.getBlue()); > assertTrue((label.getStyle() & SWT.BORDER) > 0); > } >=09 > public static void main(String[] args) { > doRun(StyleTest.class); > } >} > >StyleTest.xswt ><xswt xmlns:x=3D"http://sweet_swt.sf.net/xswt"> > <import xmlns=3D"http://sweet_swt.sf.net/xswt"> > <package name=3D"java.lang"/> > <package name=3D"org.eclipse.swt.widgets"/> > <package name=3D"com.swtworkbench.community.xswt.test"/> > <stylesheet x:id=3D"styles" relativeTo=3D"StyleTest" >path=3D"StyleTestStyles.xswt"/> > </import> > <x:children> > <label x:style=3D"styles.redLabel"/> > </x:children> ></xswt> > >StyleTestStyles.xswt: ><xswt xmlns:x=3D"http://sweet_swt.sf.net/xswt"> > <import xmlns=3D"http://sweet_swt.sf.net/xswt"> > <package name=3D"java.lang"/> > <package name=3D"org.eclipse.swt.widgets"/> > </import> > <label x:id=3D"redLabel" > x:style=3D"BORDER" > background=3D"Red"/> ></xswt> > >Note how the stylesheet has its own id and how the style in=20 >that stylesheet is referenced using <stylesheet-id>.<style-id>. > >Hallvard Tr=E6tteberg (ha...@id...,=20 >http://www.idi.ntnu.no/~hal) Associate Professor, IS group,=20 >Dept. of Computer and Information Sciences at the Norwegian=20 >Univ. of Science and Technology > > >Using Tomcat but need to do more? Need to support web=20 >services, security? >Get stuff done quickly with pre-integrated technology to make=20 >your job easier Download IBM WebSphere Application Server=20 >v.1.0.1 based on Apache Geronimo >http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&d >at=3D121642 >_______________________________________________ >Xswt-developer mailing list >Xsw...@li... >https://lists.sourceforge.net/lists/listinfo/xswt-developer > |