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 gwt.material.design.client.base.MaterialWidget; 024import gwt.material.design.client.base.HasIcon; 025import gwt.material.design.client.constants.IconPosition; 026import gwt.material.design.client.constants.IconSize; 027import gwt.material.design.client.constants.IconType; 028import gwt.material.design.client.ui.html.Span; 029 030import com.google.gwt.dom.client.Document; 031import com.google.gwt.dom.client.Style; 032import com.google.gwt.user.client.ui.HasText; 033 034//@formatter:off 035/** 036* Card Element for card title. 037* @author kevzlou7979 038* @author Ben Dol 039* @see <a href="http://gwt-material-demo.herokuapp.com/#cards">Material Cards</a> 040*/ 041//@formatter:on 042public class MaterialCardTitle extends MaterialWidget implements HasIcon, HasText { 043 044 private MaterialIcon icon = new MaterialIcon(); 045 private Span span = new Span(); 046 047 public MaterialCardTitle() { 048 super(Document.get().createSpanElement(), "card-title" , "activator"); 049 } 050 051 @Override 052 public String getText() { 053 return span.getText(); 054 } 055 056 @Override 057 public void setText(String text) { 058 span.setText(text); 059 add(span); 060 } 061 062 @Override 063 public MaterialIcon getIcon() { 064 return icon; 065 } 066 067 @Override 068 public void setIconType(IconType iconType) { 069 icon.setIconType(iconType); 070 add(icon); 071 } 072 073 @Override 074 public void setIconPosition(IconPosition position) { 075 icon.setIconPosition(position); 076 } 077 078 @Override 079 public void setIconSize(IconSize size) { 080 icon.setIconSize(size); 081 } 082 083 @Override 084 public void setIconFontSize(double size, Style.Unit unit) { 085 icon.setIconFontSize(size, unit); 086 } 087 088 @Override 089 public void setIconColor(String iconColor) { 090 icon.setIconColor(iconColor); 091 } 092 093 @Override 094 public void setIconPrefix(boolean prefix) { 095 icon.setIconPrefix(prefix); 096 } 097 098 @Override 099 public boolean isIconPrefix() { 100 return icon.isIconPrefix(); 101 } 102}