ingo@27: package de.intevation.flys.client.client.ui; ingo@27: ingo@27: import com.google.gwt.core.client.GWT; ingo@27: import com.google.gwt.resources.client.ImageResource; ingo@27: ingo@27: import com.smartgwt.client.types.Alignment; ingo@27: import com.smartgwt.client.widgets.Img; ingo@27: import com.smartgwt.client.widgets.Label; ingo@27: import com.smartgwt.client.widgets.layout.HLayout; ingo@27: import com.smartgwt.client.widgets.layout.VLayout; ingo@27: ingo@211: import de.intevation.flys.client.client.FLYSConstants; ingo@27: ingo@27: ingo@27: /** ingo@27: * @author Ingo Weinzierl ingo@27: */ ingo@27: public class FLYSHeader extends HLayout { ingo@27: ingo@27: /** The interface that provides the message resources. */ ingo@211: private FLYSConstants MESSAGES = GWT.create(FLYSConstants.class); ingo@27: ingo@27: /** The height used for this header.*/ ingo@27: public static final int HEIGHT = 75; ingo@27: ingo@27: /** The height used for the images.*/ ingo@27: public static final int IMG_HEIGHT = 50; ingo@27: ingo@27: ingo@27: public FLYSHeader() { ingo@27: init(); ingo@27: } ingo@27: ingo@27: public void init() { ingo@27: setWidth100(); ingo@27: setHeight(HEIGHT); ingo@27: setLayoutLeftMargin(5); ingo@27: setLayoutRightMargin(5); ingo@27: raimund@1399: String baseUrl = GWT.getHostPageBaseURL(); ingo@27: ingo@27: Img flys = new Img( raimund@1399: baseUrl + MESSAGES.flysLogo(), raimund@1399: 50, ingo@27: IMG_HEIGHT); ingo@27: ingo@27: Img bfg = new Img( raimund@1399: baseUrl + MESSAGES.bfgLogo(), raimund@1399: 112, raimund@66: HEIGHT); ingo@27: ingo@27: Label fullname = new Label(MESSAGES.fullname()); ingo@27: fullname.setHeight(HEIGHT - IMG_HEIGHT); raimund@66: fullname.setStyleName ("fontNormalMid"); ingo@27: ingo@27: VLayout left = new VLayout(); ingo@27: left.addMember(flys); ingo@27: left.addMember(fullname); ingo@27: ingo@27: HLayout right = new HLayout(); ingo@27: right.setAlign(Alignment.RIGHT); ingo@27: right.addMember(bfg); ingo@27: ingo@27: addMember(left); ingo@27: addMember(right); ingo@27: } ingo@27: ingo@27: ingo@27: /** ingo@27: * This method calculates the wight of an image relative to the given ingo@27: * height. ingo@27: * ingo@27: * @param res The ImageResource that points to the image. ingo@27: * @param height The pre-defined height. ingo@27: * ingo@27: * @return the calculated width that should be used for the image. ingo@27: */ ingo@27: protected int calcWidth(ImageResource res, int height) { ingo@27: int widthOrig = res.getWidth(); ingo@27: int heightOrig = res.getHeight(); ingo@27: raimund@66: double factor = (double)heightOrig / height; raimund@66: double width = (double)widthOrig / factor; ingo@27: ingo@27: return (int) width * 10 / 10; ingo@27: } ingo@27: } ingo@27: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :