property pWinPtr,pWinRect,pFileName,pWinType,pAddOn,pModal,pTitle

on new me,hSize,vSize,center,offH,offV,winName,winType,dirName,
 oldRect,isModal,hasTitle,fullScreen
  mSetAddThree(me)
  
    set pWinPtr   = window winName
    set pFileName = dirName & pAddOn
    set pWinType  = winType
    set pModal    = isModal
    set pTitle    = hasTitle
    
    if NOT(voidP(oldRect)) AND oldRect <> EMPTY then
      mSetRect(me,oldRect)
    else
      mSetRect(me,mGetRect(me,hSize,vSize,center,offH,offV,fullScreen))
    end if
    
    set the rect of pWinPtr to pWinRect
    set the filename of pWinPtr to pFileName
    set the windowType of pWinPtr to pWinType
    set the modal of pWinPtr to pModal
    set the titleVisible of pWinPtr to pTitle
    
    mOpenWin(me)
    
    return me
  end new
  
  
  on mTalkToMe me,wichOne
    do "tell pWinPtr to " & wichOne
  end mTalkToMe
  
  
  on mGetRect me,hSize,vSize,center,offH,offV,fullScreen
    set mA = 0
    set mB = 0
    set mC = 0
    set mD = 0
    
    if fullScreen then
      set stageH = getAt(getAt(the deskTopRectList,1),3)
      set stageV = getAt(getAt(the deskTopRectList,1),4)
    else
      if the machineType = 256 AND the runMode = "Projector" then
        set stageH = the stageRight - the stageLeft
        set stageV = the stageBottom - the stageTop
      else
        set stageH = 2 * (the stageLeft + (the stageRight - 
        the stageLeft) / 2)
        set stageV = 2 * (the stageTop + (the stageBottom - 
        the stageTop) / 2)
      end if
    end if
    
    if center then
      set mA = stageH / 2 - hSize / 2
      set mB = stageV / 2 - vSize / 2
      set mC = stageH / 2 + hSize / 2
      set mD = stageV / 2 + vSize / 2
    else
      set mA = offH
      set mB = offV
      set mC = offH + hSize
      set mD = offV + vSize
    end if
    
    return rect(mA,mB,mC,mD)
  end mGetRect
  
  
  on mSetRect me,wichOne
    set pWinRect = wichOne
    set the rect of pWinPtr to pWinRect
  end mSetRect
  
  
  on mOpenWin me
    mCloseWin(me)
    open pWinPtr
    moveToFront pWinPtr
  end mOpenWin  
  
  
  on mCloseWin me
    if objectP(pWinPtr) then
      set pWinRect = the rect of pWinPtr
      close pWinPtr
    end if
  end mCloseWin  
  
  
  on mKillWin me
    mCloseWin(me)
    if objectP(pWinPtr) then
      forget pWinPtr
    end if
    set pWinPtr = EMPTY
   
   return pWinRect
 end mKillWin  
 
 
 on mSetAddThree me
   if the runMode = "Author" then
     put symbol(".dir") into pAddOn
   else
     put symbol(".dxr") into pAddOn
   end if
 end mSetAddThree

