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.event.dom.client.*; 024import com.google.gwt.event.shared.HandlerRegistration; 025import gwt.material.design.client.base.HasWaves; 026 027import com.google.gwt.dom.client.Document; 028import com.google.gwt.user.client.ui.HasVisibility; 029import gwt.material.design.client.base.MaterialWidget; 030//@formatter:off 031/** 032 * MaterialColumn is panel that act as a fluid panel to easily sets your desired column.We are using 12 grid layout with screens small, medium and large. 033 * Just set grid='s12 m12 l12' to define your grid layout values. 034 * 035 * <p> 036 * <h4>UiBinder Usage:</h4> 037 * <pre> 038 * {@code 039 * <m:MaterialColumn grid='s12 m6 l4'/> 040 * Small Device - 12 grid 041 * Medium Device - 6 grid 042 * Large Device - 4 grid 043 * } 044 * </pre> 045 * 046 * @author kevzlou7979 047 * @author Ben Dol 048 * @see <a href="http://gwt-material-demo.herokuapp.com/#grid">Material Column</a> 049 */ 050//@formatter:on 051public class MaterialColumn extends MaterialWidget implements HasWaves, HasVisibility, HasClickHandlers, 052 HasAllMouseHandlers, HasDoubleClickHandlers { 053 054 public MaterialColumn() { 055 super(Document.get().createDivElement(), "col"); 056 } 057 058 public MaterialColumn(int small, int medium, int large) { 059 this(); 060 addStyleName("s"+small+" m"+medium + " l" + large); 061 } 062 063 @Override 064 public HandlerRegistration addClickHandler(final ClickHandler handler) { 065 return addDomHandler(new ClickHandler() { 066 @Override 067 public void onClick(ClickEvent event) { 068 if(isEnabled()){ 069 handler.onClick(event); 070 } 071 } 072 }, ClickEvent.getType()); 073 } 074 075 @Override 076 public HandlerRegistration addDoubleClickHandler(final DoubleClickHandler handler) { 077 return addDomHandler(new DoubleClickHandler() { 078 @Override 079 public void onDoubleClick(DoubleClickEvent event) { 080 if(isEnabled()){ 081 handler.onDoubleClick(event); 082 } 083 } 084 }, DoubleClickEvent.getType()); 085 } 086 087 @Override 088 public HandlerRegistration addMouseDownHandler(final MouseDownHandler handler) { 089 return addDomHandler(new MouseDownHandler() { 090 @Override 091 public void onMouseDown(MouseDownEvent event) { 092 handler.onMouseDown(event); 093 } 094 }, MouseDownEvent.getType()); 095 } 096 097 @Override 098 public HandlerRegistration addMouseMoveHandler(final MouseMoveHandler handler) { 099 return addDomHandler(new MouseMoveHandler() { 100 @Override 101 public void onMouseMove(MouseMoveEvent event) { 102 handler.onMouseMove(event); 103 } 104 }, MouseMoveEvent.getType()); 105 } 106 107 @Override 108 public HandlerRegistration addMouseOutHandler(final MouseOutHandler handler) { 109 return addDomHandler(new MouseOutHandler() { 110 @Override 111 public void onMouseOut(MouseOutEvent event) { 112 if(isEnabled()){ 113 handler.onMouseOut(event); 114 } 115 } 116 }, MouseOutEvent.getType()); 117 } 118 119 @Override 120 public HandlerRegistration addMouseOverHandler(final MouseOverHandler handler) { 121 return addDomHandler(new MouseOverHandler() { 122 @Override 123 public void onMouseOver(MouseOverEvent event) { 124 if(isEnabled()){ 125 handler.onMouseOver(event); 126 } 127 } 128 }, MouseOverEvent.getType()); 129 } 130 131 @Override 132 public HandlerRegistration addMouseUpHandler(final MouseUpHandler handler) { 133 return addDomHandler(new MouseUpHandler() { 134 @Override 135 public void onMouseUp(MouseUpEvent event) { 136 if(isEnabled()){ 137 handler.onMouseUp(event); 138 } 139 } 140 }, MouseUpEvent.getType()); 141 } 142 143 @Override 144 public HandlerRegistration addMouseWheelHandler(final MouseWheelHandler handler) { 145 return addDomHandler(new MouseWheelHandler() { 146 @Override 147 public void onMouseWheel(MouseWheelEvent event) { 148 if(isEnabled()){ 149 handler.onMouseWheel(event); 150 } 151 } 152 }, MouseWheelEvent.getType()); 153 } 154}