UI/Border.py

UI/Border.py
1 # Copyright 2009 Autodesk, Inc. All rights reserved.
2 # Use of this software is subject to the terms of the Autodesk license agreement
3 # provided at the time of installation or download, or which otherwise accompanies
4 # this software in either electronic or hard copy form.
5 #
6 # Script description:
7 # Create a tool that shows all kind of different borders in FBLayout
8 #
9 # Topic: FBLayout, FBBorderStyle
10 
11 from pyfbsdk import *
12 from pyfbsdk_additions import *
13 
14 regionStyles = {
15  "No Border" : FBBorderStyle.kFBNoBorder,
16  "Standard" : FBBorderStyle.kFBStandardBorder,
17  "Emboss" : FBBorderStyle.kFBEmbossBorder,
18  "EmbossEdgeSmooth" : FBBorderStyle.kFBEmbossEdgeSmoothBorder,
19  "EmbossSmooth" : FBBorderStyle.kFBEmbossSmoothBorder,
20  "EmbossSmoothEdge" : FBBorderStyle.kFBEmbossSmoothEdgeBorder,
21  "Highlight" : FBBorderStyle.kFBHighlightBorder,
22  "Picking" : FBBorderStyle.kFBPickingBorder,
23  "Standard (again)" : FBBorderStyle.kFBStandardBorder,
24  "StandardEdgeSmooth" : FBBorderStyle.kFBStandardEdgeSmoothBorder,
25  "StandardSmooth" : FBBorderStyle.kFBStandardSmoothBorder,
26  "StandardSmoothEdge" : FBBorderStyle.kFBStandardSmoothEdgeBorder
27  }
28 
29 def OnInset(control,event):
30  for name, style in regionStyles.iteritems():
31  regionLyt.SetBorder(name,style,True, control.State,2,2,90,0)
32 
33 # Button creation
34 def PopulateLayout(mainLyt):
35  x = FBAddRegionParam(10, FBAttachType.kFBAttachLeft, "")
36  y = FBAddRegionParam(10, FBAttachType.kFBAttachTop, "")
37  w = FBAddRegionParam(120,FBAttachType.kFBAttachNone,"")
38  h = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")
39  cb = FBButton()
40  cb.Style = FBButtonStyle.kFBCheckbox
41  cb.Caption = "Inset"
42  cb.OnClick.Add(OnInset)
43 
44  # Create a check box that will turn on/off Inset
45  mainLyt.AddRegion("Inset", "Inset",x,y,w,h)
46  mainLyt.SetControl("Inset",cb)
47 
48  global regionLyt
49  regionLyt = mainLyt
50 
51  regionNames = regionStyles.keys()
52 
53  yAttach = FBAttachType.kFBAttachBottom
54  yAttachTo = "Inset"
55  for i in range(3):
56  xAttach = FBAttachType.kFBAttachLeft
57  xAttachTo = ""
58  for j in range(4):
59  x = FBAddRegionParam(10, xAttach, xAttachTo)
60  y = FBAddRegionParam(10, yAttach, yAttachTo)
61  w = FBAddRegionParam(120,FBAttachType.kFBAttachNone,"")
62  h = FBAddRegionParam(100,FBAttachType.kFBAttachNone,"")
63 
64  regionName = regionNames[i * 4 + j]
65 
66  mainLyt.AddRegion(regionName,regionName, x, y, w, h)
67  mainLyt.SetBorder(regionName,regionStyles[regionName],True, False,2,2,90,0)
68 
69  xAttach = FBAttachType.kFBAttachRight
70  xAttachTo = regionName
71 
72  yAttach = FBAttachType.kFBAttachBottom
73  yAttachTo = regionName
74 
75 def CreateTool():
76  # Tool creation will serve as the hub for all other controls
77  t = FBCreateUniqueTool("Regions")
78  t.StartSizeX = 600
79  t.StartSizeY = 400
80  PopulateLayout(t)
81  ShowTool(t)
82 
83 
84 CreateTool()