001package gwt.material.design.client.ui;
002
003/*
004 * #%L
005 * GwtMaterial
006 * %%
007 * Copyright (C) 2015 GwtMaterialDesign
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 * 
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023import com.google.gwt.dom.client.Document;
024import com.google.gwt.user.client.ui.HasText;
025import gwt.material.design.client.base.*;
026
027import com.google.gwt.dom.client.Style.Unit;
028import gwt.material.design.client.base.mixin.ColorsMixin;
029import gwt.material.design.client.base.mixin.FontSizeMixin;
030import gwt.material.design.client.base.mixin.GridMixin;
031import gwt.material.design.client.base.mixin.SeparatorMixin;
032
033//@formatter:off
034/**
035 * Material Label will extend to GWT Label functionality with other material specifications
036 *
037 * <h3>UiBinder Usage:</h3>
038 * <pre>
039 *{@code<m:MaterialLabel text="I love material design" />}
040 * </pre>
041 *
042 * @author kevzlou7979
043 * @author Ben Dol
044 * @see <a href="http://gwt-material-demo.herokuapp.com/#buttons">Material Link</a>
045 */
046//@formatter:on
047public class MaterialLabel extends MaterialWidget implements HasGrid, HasSeparator, HasColors, HasFontSize, HasText {
048
049    private final ColorsMixin<MaterialLabel> colorsMixin = new ColorsMixin<>(this);
050    private final GridMixin<MaterialLabel> gridMixin = new GridMixin<>(this);
051    private final SeparatorMixin<MaterialLabel> separatorMixin = new SeparatorMixin<>(this);
052    private final FontSizeMixin<MaterialLabel> fontSizeMixin = new FontSizeMixin<>(this);
053
054    public MaterialLabel() {
055        super(Document.get().createSpanElement(), "material-label");
056    }
057
058    public MaterialLabel(String text) {
059        this();
060        setText(text);
061    }
062
063    @Override
064    public void setFontSize(String fontSize) {
065        fontSizeMixin.setFontSize(fontSize);
066    }
067
068    @Override
069    public String getFontSize() {
070        return fontSizeMixin.getFontSize();
071    }
072
073    @Override
074    public void setFontSize(double fontSize, Unit unit) {
075        fontSizeMixin.setFontSize(fontSize, unit);
076    }
077
078    @Override
079    public void setSeparator(boolean separator) {
080        separatorMixin.setSeparator(separator);
081    }
082
083    @Override
084    public boolean isSeparator() {
085        return separatorMixin.isSeparator();
086    }
087
088    @Override
089    public void setGrid(String grid) {
090        gridMixin.setGrid(grid);
091    }
092
093    @Override
094    public void setOffset(String offset) {
095        gridMixin.setOffset(offset);
096    }
097
098    @Override
099    public String getBackgroundColor() {
100        return colorsMixin.getBackgroundColor();
101    }
102
103    @Override
104    public void setBackgroundColor(String bgColor) {
105        colorsMixin.setBackgroundColor(bgColor);
106    }
107
108    @Override
109    public String getTextColor() {
110        return colorsMixin.getTextColor();
111    }
112
113    @Override
114    public void setTextColor(String textColor) {
115        colorsMixin.setTextColor(textColor);
116    }
117
118    @Override
119    public String getText() {
120        return getElement().getInnerHTML();
121    }
122
123    @Override
124    public void setText(String text) {
125        getElement().setInnerHTML(text);
126    }
127}