/ftr-gwt-library-date/src/main/java/eu/future/earth/gwt/client/date/horizontal/BaseHorizontalRowPanel.java

http://ftr-gwt-library.googlecode.com/ · Java · 66 lines · 35 code · 16 blank · 15 comment · 0 complexity · 37c3e4d6f12d0bb73ef3c4f738cddd29 MD5 · raw file

  1. /*
  2. * Copyright 2007 Future Earth, info@future-earth.eu
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package eu.future.earth.gwt.client.date.horizontal;
  17. import com.google.gwt.user.client.ui.AbsolutePanel;
  18. import com.google.gwt.user.client.ui.FocusPanel;
  19. import com.google.gwt.user.client.ui.Widget;
  20. import eu.future.earth.gwt.client.FtrGwtDateCss;
  21. public abstract class BaseHorizontalRowPanel<T, M> extends FocusPanel {
  22. protected HorizontalDateRenderer<T, M> renderer;
  23. protected int startHour = 0;
  24. protected int endHour = 24;
  25. private ExtendedHorizontalAbsolutePanel<T, M> body = null;
  26. public BaseHorizontalRowPanel(HorizontalDateRenderer<T, M> newRenderer) {
  27. super();
  28. this.renderer = newRenderer;
  29. body = new ExtendedHorizontalAbsolutePanel<T, M>(this);
  30. this.setWidget(body);
  31. body.setStyleName(FtrGwtDateCss.DATE_DAY_FULL);
  32. startHour = renderer.getStartHour();
  33. endHour = renderer.getEndHour();
  34. }
  35. public HorizontalDateRenderer<T, M> getRenderer() {
  36. return renderer;
  37. }
  38. protected int getDailyIntervals() {
  39. return (endHour - startHour) * renderer.getIntervalsPerHour();
  40. }
  41. public boolean removeFromBody(Widget w) {
  42. return body.removeNormal(w);
  43. }
  44. public void add(Widget w, int left, int top) {
  45. body.addNormal(w, left, top);
  46. }
  47. public AbsolutePanel getBody() {
  48. return body;
  49. }
  50. }