blob: a41964d5629f48c38fb991c847d04d39a498eb8a [file] [log] [blame]
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!--- The default skin class for Spark TextArea component. -->
<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
alpha.disabledStates="0.5">
<fx:Metadata>
<![CDATA[
/**
* @copy spark.skins.default.ApplicationSkin#hostComponent
*/
[HostComponent("spark.components.TextArea")]
]]>
</fx:Metadata>
<fx:Script>
<![CDATA[
private var lineBreakChanged:Boolean;
private var paddingChanged:Boolean;
private var verticalAlignChanged:Boolean;
/**
* @private
*/
override protected function commitProperties():void
{
super.commitProperties();
if (lineBreakChanged)
{
updateStringStyle("lineBreak");
lineBreakChanged = false;
}
if (paddingChanged)
{
updatePadding();
paddingChanged = false;
}
if (verticalAlignChanged)
{
updateStringStyle("verticalAlign");
verticalAlignChanged = false;
}
}
/**
* @private
*/
private function updatePadding():void
{
if (!textDisplay)
return;
// Push padding styles into the textDisplay
var padding:Number;
padding = getStyle("paddingLeft");
if (textDisplay.getStyle("paddingLeft") != padding)
textDisplay.setStyle("paddingLeft", padding);
padding = getStyle("paddingTop");
if (textDisplay.getStyle("paddingTop") != padding)
textDisplay.setStyle("paddingTop", padding);
padding = getStyle("paddingRight");
if (textDisplay.getStyle("paddingRight") != padding)
textDisplay.setStyle("paddingRight", padding);
padding = getStyle("paddingBottom");
if (textDisplay.getStyle("paddingBottom") != padding)
textDisplay.setStyle("paddingBottom", padding);
}
/**
* @private
*/
private function updateStringStyle(styleName:String):void
{
if (!textDisplay)
return;
// Push style into the textDisplay
var style:String;
style = getStyle(styleName);
if (textDisplay.getStyle(styleName) != style)
textDisplay.setStyle(styleName, style);
}
/**
* @private
*/
override public function styleChanged(styleProp:String):void
{
var allStyles:Boolean = !styleProp || styleProp == "styleName";
super.styleChanged(styleProp);
if (allStyles || styleProp.indexOf("lineBreak") == 0)
{
lineBreakChanged = true;
invalidateProperties();
}
if (allStyles || styleProp.indexOf("padding") == 0)
{
paddingChanged = true;
invalidateProperties();
}
if (allStyles || styleProp.indexOf("verticalAlign") == 0)
{
verticalAlignChanged = true;
invalidateProperties();
}
}
]]>
</fx:Script>
<s:states>
<s:State name="normal"/>
<s:State name="disabled" stateGroups="disabledStates"/>
<s:State name="normalWithPrompt"/>
<s:State name="disabledWithPrompt" stateGroups="disabledStates"/>
</s:states>
<!-- border -->
<s:Rect left="0" right="0" top="0" bottom="0">
<s:stroke>
<s:SolidColorStroke color="0x6a6a6a" weight="1"/>
</s:stroke>
</s:Rect>
<!-- fill -->
<!--- Defines the appearance of the TextArea component's background. -->
<s:Rect id="background" left="1" right="1" top="1" bottom="1">
<s:fill>
<!--- Defines the background fill color. -->
<s:SolidColor id="bgFill" color="0xCCCCCC" />
</s:fill>
</s:Rect>
<!-- shadow -->
<s:Rect left="1" top="1" right="1" height="1">
<s:fill>
<s:SolidColor color="0x000000" alpha="0.12" />
</s:fill>
</s:Rect>
<!--- Defines the scroller used to scroll the TextArea. -->
<s:Scroller id="scroller" left="0" top="0" right="0" bottom="0" minViewportInset="1" measuredSizeIncludesScrollBars="false">
<!--- @copy spark.components.supportClasses.SkinnableTextBase#textDisplay -->
<s:RichEditableText id="textDisplay"
heightInLines="10"
widthInChars="15" />
</s:Scroller>
</s:Skin>