My favorites | Sign in
Project Logo
                
Search
for
Updated Sep 14, 2008 by spervine
GettingStarted  
Just a quick intro on how to use this.

Introduction

GStyle allows you to write your style sheets in Java and load them dynamically onto your GWT application. Currently, it's not too smart, and won't do anything clever around browser incompatibilities etc - but bear with us.

Details

Here's an example of how to get a style sheet into your application, and how to use it:

Define your style sheet - this may seem a lot of code, but breaking out common styling such as blackBorder below, can really simplify this. Also included is a series of statics on Palette, which just define colors - it's probably best to not use explicit color names here, but the likes of mainBorder etc.

import gstyle.*;

public class Styles extends AbstractStyleSheet {

    private static Styles currentStyle = new Styles();

    private Style body;
    private Style blackBorder;
    private Style flightFinder;
    private Style flightBooker;

    public Styles() {
        body = elementByType("body")
                .fontFamily("arial, verdana, tahoma")
                .backgroundColor("lightgray");
        blackBorder = styleClass()
                .border("1px solid")
                .borderColor(Palette.BLACK);
        flightFinder = styleClass()
                .inherits(blackBorder)
                .backgroundColor(Palette.LIGHT_BLUE)
                .marginBottom("5px");
        flightBooker = styleClass()
                .inherits(blackBorder)
                .backgroundColor(Palette.BROWN)
                .color(Palette.WHITE)
                .padding("2px");
    }

    public static Styles currentStyle() {
        return currentStyle;
    }

    public String flightFinder() {
        return flightFinder.css();
    }
}

Then add the style sheet to your entry point.

Styles.currentStyle().apply();

Then use the styles on the components in your application.

FlexTable panel = new FlexTable();
panel.setStyleName(Styles.currentStyle().flightFinder());

Comment by thuroot, Mar 30, 2009

jklnkljn


Sign in to add a comment
Hosted by Google Code