# 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 witha  Memo and shows how to sets its content
# and retrieve its lines.
#
# Topic: FBStringList, FBMemo
#

from pyfbsdk import *
from pyfbsdk_additions import *

def OnChange(control,event):
        print control.Text

def PopulateLayout(mainLyt):
    #create Spread
    m = FBMemo()

    x = FBAddRegionParam(0,FBAttachType.kFBAttachLeft,"")
    y = FBAddRegionParam(0,FBAttachType.kFBAttachTop,"")
    w = FBAddRegionParam(0,FBAttachType.kFBAttachRight,"")
    h = FBAddRegionParam(0,FBAttachType.kFBAttachBottom,"")

    mainLyt.AddRegion("memo","memo", x, y, w, h)

    mainLyt.SetControl("memo",m)

    sl = FBStringList()
    sl.Add ("String 1")
    sl.Add ("String 2")

    m.SetStrings(sl)

    sl2 = FBStringList()
    m.GetStrings(sl2)
    print "printing string list"
    for s in sl2:
        print s

    m.OnChange.Add(OnChange)

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

    t.StartSizeX = 300
    t.StartSizeY = 300

    PopulateLayout(t)
    ShowTool(t)


CreateTool()