Merge branch 'master' into history
[potlatch2.git] / net / systemeD / potlatch2 / skins / CustomFormItemSkin.mxml
1 <?xml version="1.0" encoding="utf-8"?>
2 <!--
3
4 ADOBE SYSTEMS INCORPORATED
5 Copyright 2010 Adobe Systems Incorporated
6 All Rights Reserved.
7
8 NOTICE: Adobe permits you to use, modify, and distribute this file
9 in accordance with the terms of the license agreement accompanying it.
10
11 -->
12
13 <!-- TODO
14 Move the indicator tooltip string to a resource bundle
15 -->
16
17 <!--- The default skin class for the Spark FormItem component.  
18
19 @see spark.components.FormItem
20
21 @langversion 3.0
22 @playerversion Flash 10
23 @playerversion AIR 1.5
24 @productversion Flex 4.5
25 -->
26 <s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009" 
27         xmlns:s="library://ns.adobe.com/flex/spark" 
28         xmlns:fb="http://ns.adobe.com/flashbuilder/2009"
29         alpha.disabledStates=".5">  
30     
31     <!-- host component -->
32     <fx:Metadata>
33         <![CDATA[ 
34         /** 
35         * @copy spark.skins.spark.ApplicationSkin#hostComponent
36         */
37         [HostComponent("spark.components.FormItem")]
38         ]]>
39     </fx:Metadata>
40     
41     <fx:Script fb:purpose="styling">
42         <![CDATA[                
43             /**
44              *  @private
45              */
46             override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number) : void
47             {
48                 // Push backgroundColor and backgroundAlpha directly.
49                 // Handle undefined backgroundColor by hiding the background object.
50                 if (isNaN(getStyle("backgroundColor")))
51                 {
52                     background.visible = false;
53                 }
54                 else
55                 {
56                     background.visible = true;
57                     bgFill.color = getStyle("backgroundColor");
58                     bgFill.alpha = getStyle("backgroundAlpha");
59                 }
60                 
61                 var indicatorSource:Object;
62                 if (currentState == "error" || currentState == "requiredAndError")
63                     indicatorSource = getStyle("errorIndicatorSource");
64                 else if (currentState == "required" || "requiredAndDisabled")
65                     indicatorSource = getStyle("requiredIndicatorSource");
66                 
67                 if (indicatorSource && indicatorDisplay)
68                 {
69                     indicatorDisplay.source = indicatorSource;
70                 }
71                 
72                 super.updateDisplayList(unscaledWidth, unscaledHeight);
73             }
74             
75             /**
76              *  @private
77              */
78             override public function setCurrentState(stateName:String, playTransition:Boolean=true):void
79             {
80                 super.setCurrentState(stateName, playTransition);
81                 invalidateDisplayList();
82             }
83         ]]>        
84     </fx:Script>
85     
86     <s:states>
87         <s:State name="normal" />
88         <s:State name="disabled" stateGroups="disabledStates"/> 
89         <s:State name="error" stateGroups="errorStates"/>   
90         <s:State name="required" stateGroups="requiredStates"/> 
91         <s:State name="requiredAndDisabled" stateGroups="requiredStates, disabledStates"/>
92         <s:State name="requiredAndError" stateGroups="requiredStates, errorStates"/>    
93     </s:states>
94     
95     <s:layout>
96         <s:FormItemLayout>
97             <s:constraintColumns>
98                 <!--- The column containing the sequence label. -->
99                 <s:ConstraintColumn id="sequenceCol" />
100                 <!--- The column containing the FormItem's label. -->
101                 <s:ConstraintColumn id="labelCol" />
102                 <!--- The column containing the FormItem's content. -->
103                 <s:ConstraintColumn id="contentCol" width="100%"/>
104                 <!--- The column containing the FormItem's help content. -->
105                 <s:ConstraintColumn id="helpCol" maxWidth="200"/>
106             </s:constraintColumns>         
107             <s:constraintRows>
108                 <!--- @private -->
109                 <s:ConstraintRow id="row1" baseline="maxAscent:0" height="100%"/>
110             </s:constraintRows>  
111         </s:FormItemLayout>
112     </s:layout>
113             
114     <!--- Defines the appearance of the FormItem's background. -->
115     <s:Rect id="background" left="0" right="0" top="0" bottom="0">
116         <s:fill>
117             <!--- @private -->
118             <s:SolidColor id="bgFill" color="#FFFFFF"/>
119         </s:fill>
120     </s:Rect>
121     
122     <!--- @copy spark.components.FormItem#sequenceLabelDisplay -->
123     <s:Label id="sequenceLabelDisplay" 
124              fontWeight="bold"
125              left="sequenceCol:0" right="sequenceCol:5"
126              bottom="row1:0" baseline="row1:0"/>
127     <!--- @copy spark.components.FormItem#labelDisplay -->
128     <s:Label id="labelDisplay"
129              fontWeight="bold"
130              left="labelCol:0" right="labelCol:5" 
131              bottom="row1:0" baseline="row1:0"/>  
132     <!--- @copy spark.components.SkinnableContainer#contentGroup -->
133     <!-- Don't show the error tip on the content elements -->
134     <s:Group id="contentGroup" showErrorTip="false" showErrorSkin="true"
135              left="contentCol:0" right="contentCol:1" 
136              baseline="row1:0" bottom="row1:10">
137         <s:layout>
138             <s:VerticalLayout/>
139         </s:layout>
140     </s:Group>
141     <!-- Don't include the indicator in layout since we position it ourselves -->
142     <s:Group x="{contentGroup.x + contentGroup.contentWidth + 4}" y="{contentGroup.y}"
143              height="{Math.max(indicatorDisplay.height, contentGroup.contentHeight)}" includeInLayout="false">
144         <!--- @private -->
145         <s:Image id="indicatorDisplay" verticalCenter="0"
146                        toolTip="Required" toolTip.errorStates=""
147                        includeIn="requiredStates,errorStates"/>
148     </s:Group>
149         
150     <!--- @copy spark.components.FormItem#helpContentGroup -->
151     <s:Group id="helpContentGroup" excludeFrom="errorStates"
152              fontStyle="italic" fontWeight="normal" color="0x666666"
153              left="helpCol:27" right="helpCol:10"
154              bottom="row1:0" baseline="row1:0"/>
155     <!--- @copy spark.components.FormItem#errorTextDisplay -->
156     <s:RichText id="errorTextDisplay" includeIn="errorStates"
157                 fontStyle="italic" fontWeight="normal" color="0xFE0000"
158                 left="helpCol:27" right="helpCol:10"
159                 bottom="row1:0" baseline="row1:0" 
160                 maxDisplayedLines="-1"/>    
161  </s:Skin>