001/* 002 * #%L 003 * GwtMaterial 004 * %% 005 * Copyright (C) 2015 - 2017 GwtMaterialDesign 006 * %% 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 * #L% 019 */ 020package gwt.material.design.addins.client.menubar; 021 022import com.google.gwt.dom.client.Document; 023import gwt.material.design.addins.client.MaterialAddins; 024import gwt.material.design.addins.client.base.constants.AddinsCssName; 025import gwt.material.design.client.MaterialDesignBase; 026import gwt.material.design.client.base.MaterialWidget; 027 028import static gwt.material.design.jquery.client.api.JQuery.$; 029 030//@formatter:off 031 032/** 033 * Menu bar is a component that bring a good UI UX navigation for Desktop or tablet interface. 034 * It may require to have a dropdown components inside menu bar. 035 * <p> 036 * <h3>XML Namespace Declaration</h3> 037 * <pre> 038 * {@code 039 * xmlns:ma='urn:import:gwt.material.design.addins.client' 040 * } 041 * </pre> 042 * <p> 043 * <h3>UiBinder Usage:</h3> 044 * <pre> 045 * {@code 046 * <ma:menubar.MaterialMenuBar> 047 * <!-- Menu Bar link --> 048 * <m:MateriaLink text="File" activates="dp-edit"/> 049 * 050 * <!-- Edit Drop Down --> 051 * <m:MaterialDropDown activator="dp-edit" belowOrigin="true"> 052 * <m:MaterialLink text="Undo" iconType="UNDO" textColor="black"> 053 * <m:MaterialLabel text="Ctrl + Z" float="RIGHT"/> 054 * </m:MaterialLink> 055 * <m:MaterialLink text="Redo" iconType="REDO" textColor="black"> 056 * <m:MaterialLabel text="Ctrl + Y" float="RIGHT"/> 057 * </m:MaterialLink> 058 * </m:MaterialDropDown> 059 * </ma:menubar.MaterialMenuBar> 060 * } 061 * </pre> 062 * 063 * @author kevzlou7979 064 * @see <a href="http://gwtmaterialdesign.github.io/gwt-material-demo/#menubar">MenuBar</a> 065 * @see <a href="https://material.io/guidelines/components/menus.html">Material Design Specification</a> 066 */ 067//@formatter:on 068public class MaterialMenuBar extends MaterialWidget { 069 070 static { 071 if (MaterialAddins.isDebug()) { 072 MaterialDesignBase.injectCss(MaterialMenuBarDebugClientBundle.INSTANCE.menubarCssDebug()); 073 } else { 074 MaterialDesignBase.injectCss(MaterialMenuBarClientBundle.INSTANCE.menubarCss()); 075 } 076 } 077 078 private String minHeight; 079 080 public MaterialMenuBar() { 081 super(Document.get().createDivElement(), AddinsCssName.MENU_BAR); 082 } 083 084 @Override 085 protected void onLoad() { 086 super.onLoad(); 087 088 $(getElement()).find(".dropdown-content li").css("minHeight", minHeight); 089 $(getElement()).find(".dropdown-content li").css("lineHeight", minHeight); 090 $(getElement()).find(".dropdown-content li").css("maxHeight", minHeight); 091 } 092 093 public void setItemHeight(String minHeight) { 094 this.minHeight = minHeight; 095 } 096}