﻿// JScript 文件

var ltWindow=new Object();

ltWindow.WndClassName = "ltWindowDefaule";
ltWindow.objWnd = new MyScreen();
ltWindow.showTitle = true;//default show TitleBar
// wnd default stlye
ltWindow.m_hWnd = null;//window handle
ltWindow.selfRff = null;
ltWindow.m_TitleText = "";// title text
ltWindow.m_PosLeft = "0px";// wnd point by left
ltWindow.m_PosTop = "0px";
ltWindow.m_width = "200px";
ltWindow.m_height = "200px";
ltWindow.m_borderStyle = "";
ltWindow.m_Alpha = 100;
ltWindow.m_Color = "";
ltWindow.m_mousedown = false;

//建立窗体方法
ltWindow.Windows = function(left,top,width,height,borderStyle,BgColor,Alpha)
{
   ltWindow.selfRff = this;   
   if(left)ltWindow.m_PosLeft = left;
      if(top)ltWindow.m_PosTop = top;
          if(width)ltWindow.m_width = width;
            if(height)ltWindow.m_height = height;
             if(borderStyle)ltWindow.m_borderStyle = borderStyle;
              if(BgColor) ltWindow.m_Color = BgColor;
                if(Alpha)ltWindow.m_Alpha = Alpha;
}
//建立一个窗体
ltWindow.Windows.prototype.CreateWnd = function()
{
   if(!ltWindow.m_hWnd)
   {      
      ltWindow.m_hWnd=ltWindow.objWnd.Window(3,ltWindow.WndClassName,ltWindow.m_PosTop,ltWindow.m_PosLeft,ltWindow.m_width,ltWindow.m_height,ltWindow.m_Color,ltWindow.m_Alpha,ltWindow.m_borderStyle);
      //ltWindow.selfRff.OnEvent();
   }
}
//移动窗体
ltWindow.Windows.prototype.MoveWindow = function(left,top)
{
  if(ltWindow.m_hWnd)
  {
    var style = ltWindow.m_hWnd.style;
    style.left = left;
    style.top = top;
  }
} 
//设定背景色
ltWindow.Windows.prototype.SetBkColor = function(sColor)
{
   if(ltWindow.m_hWnd)
  {
    var style = ltWindow.m_hWnd.style;    
    style.background = sColor;
    
  }
}
ltWindow.Windows.prototype.SetClass = function(sClass)
{
   if(ltWindow.m_hWnd)
  {
    //var style = ltWindow.m_hWnd.style;    
    //style.background = sColor;
    ltWindow.m_hWnd.className = sClass;
  }
}


//设置窗体边框风格
ltWindow.Windows.prototype.SetBorder = function(borderStyle)
{
   if(ltWindow.m_hWnd)
  {
    var style = ltWindow.m_hWnd.style;    
    style.border = borderStyle;
    
  }
}
//设置窗体大小
ltWindow.Windows.prototype.SetSize = function(width,heigth)
{
   if(ltWindow.m_hWnd)
  {
    var style = ltWindow.m_hWnd.style;    
    style.width = width;
    style.height = heigth;
    
  }
}

//设置窗体HTML文本
ltWindow.Windows.prototype.SetHTML = function(HtmlText)
{
   if(ltWindow.m_hWnd)
  {
     ltWindow.m_hWnd.innerHTML = HtmlText;
  }
}
//设置窗体透明度
ltWindow.Windows.prototype.SetAlpha = function(Alpha)
{
   if(ltWindow.m_hWnd)
  {
     ltWindow.m_hWnd.style.filter = "alpha(opacity="+Alpha+")";
  }
}
ltWindow.Windows.prototype.OnEvent = function()
{
  if(ltWindow.m_hWnd)
  {
       //ltWindow.m_hWnd.onmouseout = ltWindow.selfRff.Close;
       ltWindow.m_hWnd.onmousemove = ltWndExOnDrog;
       ltWindow.m_hWnd.onmousedown = ltWndExOnMouseDown;
       ltWindow.m_hWnd.onmouseup = ltWndExOnMouseUp;
  }
}

//隐藏窗体
ltWindow.Windows.prototype.Show=function()
{
 if(ltWindow.m_hWnd)
  {  
    var style = ltWindow.m_hWnd.style;    
    style. visibility="visible";
    
  }
}
//隐藏窗体
ltWindow.Windows.prototype.Hide=function()
{
 if(ltWindow.m_hWnd)
  {  
    var style = ltWindow.m_hWnd.style;    
    style. visibility="hidden";
    
  }
}
//关闭窗体
ltWindow.Windows.prototype.Close=function()
{
 if(ltWindow.m_hWnd)
  {  
    document.body.removeChild(ltWindow.m_hWnd);
    ltWindow.m_hWnd = null;
  }
}


//窗体扩展功能
function ltWndExOnDrog()
{
  if(ltWindow.m_mousedown)
  {
       var xoffset,yoffset;
       var currPos;
       currPos = getElementPos(ltWindow.WndClassName);
       
       xoffset =  window.event.x - currPos.x;
       yoffset =  window.event.y - currPos.y;
       
       ltWindow.m_PosLeft = (window.event.x - 40)+"px";
       ltWindow.m_PosTop = (window.event.y - 40)+"px";   
       
       ltWindow.selfRff.MoveWindow(ltWindow.m_PosLeft,ltWindow.m_PosTop);
  
   }
}

function ltWndExOnMouseDown()
{
   ltWindow.m_mousedown = true;
}
function ltWndExOnMouseUp()
{
   ltWindow.m_mousedown = false;
}
