# 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 labels and set all their properties.
# 
# Topic: FBLabel, FBTextJustify, FBTextStyle
# 

from pyfbsdk import *
from pyfbsdk_additions import *

def PopulateLayout(mainLyt):
    lyt = VBoxLayout()
    x = FBAddRegionParam(0,FBAttachType.kFBAttachLeft,"")
    y = FBAddRegionParam(0,FBAttachType.kFBAttachTop,"")
    w = FBAddRegionParam(50,FBAttachType.kFBAttachNone,"")
    h = FBAddRegionParam(0,FBAttachType.kFBAttachBottom,"")
    mainLyt.AddRegion("main","main", x, y, w, h)
    mainLyt.SetControl("main",lyt);

    l = FBLabel()
    l.Caption = "This is a label!!!!"
    l.Style = FBTextStyle.kFBTextStyleBold
    l.WordWrap = True
    lyt.Add(l, 25)

    #FBTextJustify.kFBTextJustifyLeft
    #FBTextJustify.kFBTextJustifyRight
    #FBTextJustify.kFBTextJustifyCenter    

    #FBTextStyle.kFBTextStyleNone
    #FBTextStyle.kFBTextStyleBold
    #FBTextStyle.kFBTextStyleItalic
    #FBTextStyle.kFBTextStyleUnderlined 

    l = FBLabel()
    l.Caption = "left"
    l.Style = FBTextStyle.kFBTextStyleItalic
    l.Justify = FBTextJustify.kFBTextJustifyLeft
    lyt.Add(l, 25)

    l = FBLabel()
    l.Caption = "center"
    l.Style = FBTextStyle.kFBTextStyleUnderlined
    l.Justify = FBTextJustify.kFBTextJustifyCenter
    lyt.Add(l, 25)

    l = FBLabel()
    l.Caption = "right"
    l.Justify = FBTextJustify.kFBTextJustifyRight
    lyt.Add(l, 25)


def CreateTool():
    # Tool creation will serve as the hub for all other controls    
    t = CreateUniqueTool("Label Example")
    t.StartSizeX = 400
    t.StartSizeY = 400
    PopulateLayout(t)
    ShowTool(t)


CreateTool()