Package com.zaranux.os.client.ui

Source Code of com.zaranux.os.client.ui.View

package com.zaranux.os.client.ui;

import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.events.MouseDownEvent;
import com.smartgwt.client.widgets.events.MouseDownHandler;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.TextItem;

import com.google.gwt.user.client.ui.Widget;

import java.util.Vector;
import com.allen_sauer.gwt.log.client.Log;
import com.allen_sauer.gwt.log.client.DivLogger;
public class View {

  private Canvas canvas = new Canvas();
  private int viewNumber = -1;
  //private Vector<ZWindow> windows = new Vector<ZWindow>();
  final DynamicForm dummyForm = new DynamicForm();

 
  public View(int viewNumber)
  {
    canvas.addMouseDownHandler(new MouseDownHandler()
    {
      public void onMouseDown(MouseDownEvent event)
      {
        focus();
      }
    });
   
    canvas.setWidth100();
    canvas.setHeight100();
    //canvas.setHeight("100%");
   
    // kalak rashti to get keyboard focus from iframe apps ..(e.g. zoho)
    TextItem dummy = new TextItem("");
    dummy.setShowTitle(false);
    dummy.setWidth(0);
    dummy.setHeight(0);
    dummy.setSelectOnFocus(true);
    dummyForm.setFields(dummy);
    dummyForm.setAutoFocus(true);
    dummyForm.setVisible(false);

    //dummyForm.setWidth(0);
    //dummyForm.setHeight(0);
    canvas.addChild(dummyForm);
   
    DivLogger dl = Log.getDivLogger();
    if(dl != null)
    {
      dl.getWidget().removeFromParent();
      Widget widget = dl.getWidget();
      canvas.addChild(widget);
    }

   
    //canvas.draw();

    this.viewNumber = viewNumber;
  }
 
  public void focus()
  {
    dummyForm.setVisible(true);
    dummyForm.focus();
    dummyForm.setVisible(false);
  }

//  public void setWidget(Canvas widget, int left, int top)
//  {
//    canvas.addChild(widget);
    //canvas.draw();
//    widget.moveTo(left, top);
//  }
 
  public void addWindow(ZWindow window, int left, int top)
  {
    canvas.addChild(window);
    window.moveTo(left, top);
    window.setView(this);
    //canvas.draw();
    //windows.add(window);
  }
 
  public void addWidget(Widget widget)
  {
    canvas.addChild(widget);
  }
 
//  void remove(ZWindow window)
//  {
//    windows.remove(window);
//  }
 
  public int getViewNumber()
  {
    return viewNumber;
  }
  public void hide()
  {
    canvas.hide();
  }
 
  public void show()
  {
    canvas.show();
  }


  public int getWidth()
  {
    return canvas.getWidth();
  }
 
  public int getHeight()
  {
    return canvas.getHeight();
  }
 
//  public void destroy()
//  {
//    for(ZWindow window : windows)
//    {
//      window.close();
//    }
//  }
}
TOP

Related Classes of com.zaranux.os.client.ui.View

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.