Thursday, May 27, 2010

Re: How to parse CSS

Hi Amine,

when you want to get the font-size value, you should do an @def for
this value

.css

@def myFontSize 40px;
..
.testsize {
font-size: myFontSize;
}

.java
..
label1.setText(resources.css().myFontSize());

or you do it like the way a1decor it does

.css
@eval MyFontSize my.classesWithStaticFunctions.getFontSize();
..
.testsize {
font-size: MyFontSize;
}

.java
my.classesWithStaticFunctions.getFontSize() {return "40px";}
...
label1.setText(my.classesWithStaticFunctions.getFontSize());

With the later you are able to change it before injecting the css.

Stefan Bachert
http://gwtworld.de


On 27 Mai, 17:19, Amine Ouahman <amine.aitouah...@gmail.com> wrote:
> I already read the hole doc but still cannot find a solution to my
> problem, I'm surely missing something.
> here is why I've done : this is an exemple of how I used the
> CSSResource feature to retrieve a constant from the css file and use
> it in the java side, and it works
>
> public interface Resources extends ClientBundle{
>         @Source("TestParser.css")
>         public MyCSSResources css();
>
> }
>
> public interface MyCSSResources extends CssResource{
>         String testsize();
>         String small();
>
> }
>
> TestParser.css =>
> @def small 1px;
> .testsize {
> font-size: 40px;
>
> }
>
> Somewhere in a java class =>
> Resources resources = GWT.create(Resources.class);
>                 label1.setStyleName(resources.css().testsize());
>                 label1.setText(resources.css().small());
>                 resources.css().ensureInjected();
>
> Now what I want to do somehow is to retrieve the "font-size" value
> instead of the constant!!
> A simple example plz will be great!
>
> Thanks

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment