# Copyright 2009 Autodesk, Inc.  All rights reserved.
# Use of this software is subject to the terms of the Autodesk license agreement 
# provided at the time of installation or download, or which otherwise accompanies
# this software in either electronic or hard copy form.
#
# Script description:
# Create a tool with an empty layout (with border) and shows how to register clalback (idle, input, paint, resize, show)
# 
# Topic: FBLayout
# 

from pyfbsdk import *
from pyfbsdk_additions import *

def OnEventCb(control,event):
    print event.Name

def OnInputCb(control,event):
    print event.Name, event.InputType

def PopulateLayout(mainLyt):
    lyt = FBLayout()
    x = FBAddRegionParam(10,FBAttachType.kFBAttachLeft,"")
    y = FBAddRegionParam(10,FBAttachType.kFBAttachTop,"")
    w = FBAddRegionParam(400,FBAttachType.kFBAttachNone,"")
    h = FBAddRegionParam(40,FBAttachType.kFBAttachNone,"")
    lyt.AddRegion("Border1","Border2", x, y, w, h)
    lyt.SetBorder("Border1",FBBorderStyle.kFBStandardBorder,True, True,1,0,90,0)

    #lyt.OnIdle.Add(OnEventCb)
    lyt.OnInput.Add(OnInputCb)
    #lyt.OnPaint.Add(OnEventCb)
    lyt.OnResize.Add(OnEventCb)
    lyt.OnShow.Add(OnEventCb)


    x = FBAddRegionParam(10,FBAttachType.kFBAttachLeft,"")
    y = FBAddRegionParam(10,FBAttachType.kFBAttachTop,"")
    w = FBAddRegionParam(-10,FBAttachType.kFBAttachRight,"")
    h = FBAddRegionParam(-10,FBAttachType.kFBAttachBottom,"")
    mainLyt.AddRegion("Reg","Reg", x, y, w, h)
    mainLyt.SetControl("Reg",lyt)

def CreateTool():
    # Tool creation will serve as the hub for all other controls
    t = CreateUniqueTool("Tool Layout")

    PopulateLayout(t)
    ShowTool(t)


CreateTool()