Repository: flex-examples Updated Branches: refs/heads/develop eb3b97acb -> dad386f5b
http://git-wip-us.apache.org/repos/asf/flex-examples/blob/8ccec1f5/tourdeflexmobile/src/spark/skins/android4/ViewMenuItemSkin.as ---------------------------------------------------------------------- diff --git a/tourdeflexmobile/src/spark/skins/android4/ViewMenuItemSkin.as b/tourdeflexmobile/src/spark/skins/android4/ViewMenuItemSkin.as deleted file mode 100644 index ae9a68e..0000000 --- a/tourdeflexmobile/src/spark/skins/android4/ViewMenuItemSkin.as +++ /dev/null @@ -1,238 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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. -// -//////////////////////////////////////////////////////////////////////////////// -package spark.skins.android4 -{ - import flash.display.GradientType; - import flash.display.Graphics; - - import mx.core.DPIClassification; - import mx.core.mx_internal; - - import spark.components.IconPlacement; - import spark.skins.mobile.assets.ViewMenuItem_down; - import spark.skins.mobile.assets.ViewMenuItem_showsCaret; - import spark.skins.mobile.assets.ViewMenuItem_up; - import spark.skins.mobile.supportClasses.ButtonSkinBase; - import spark.skins.mobile120.assets.ViewMenuItem_down; - import spark.skins.mobile120.assets.ViewMenuItem_showsCaret; - import spark.skins.mobile120.assets.ViewMenuItem_up; - import spark.skins.mobile320.assets.ViewMenuItem_down; - import spark.skins.mobile320.assets.ViewMenuItem_showsCaret; - import spark.skins.mobile320.assets.ViewMenuItem_up; -// import spark.skins.mobile480.assets.ViewMenuItem_down; - //import spark.skins.mobile480.assets.ViewMenuItem_showsCaret; - //import spark.skins.mobile480.assets.ViewMenuItem_up; - import spark.skins.mobile640.assets.ViewMenuItem_down; - import spark.skins.mobile640.assets.ViewMenuItem_showsCaret; - import spark.skins.mobile640.assets.ViewMenuItem_up; - - - use namespace mx_internal; - - /** - * Default skin for ViewMenuItem. Supports a label, icon and iconPlacement and draws a background. - * - * @langversion 3.0 - * @playerversion Flash 10 - * @playerversion AIR 2.5 - * @productversion Flex 4.5 - */ - public class ViewMenuItemSkin extends ButtonSkin - { - /** - * Constructor. - * - * @langversion 3.0 - * @playerversion Flash 10 - * @playerversion AIR 2.5 - * @productversion Flex 4.5 - */ - public function ViewMenuItemSkin() - { - super(); - - switch (applicationDPI) - { - case DPIClassification.DPI_640: - { - - upBorderSkin = spark.skins.mobile640.assets.ViewMenuItem_up; - downBorderSkin = spark.skins.mobile640.assets.ViewMenuItem_down; - showsCaretBorderSkin = spark.skins.mobile640.assets.ViewMenuItem_showsCaret; - - layoutGap = 24; - layoutPaddingLeft = 24; - layoutPaddingRight = 24; - layoutPaddingTop = 24; - layoutPaddingBottom = 24; - layoutBorderSize = 3; - - break; - } - case DPIClassification.DPI_480: - { - // Note provisional may need changes - upBorderSkin = spark.skins.mobile.assets.ViewMenuItem_up; - downBorderSkin = spark.skins.mobile.assets.ViewMenuItem_down; - showsCaretBorderSkin = spark.skins.mobile.assets.ViewMenuItem_showsCaret; - - layoutGap = 16; - layoutPaddingLeft = 16; - layoutPaddingRight = 16; - layoutPaddingTop = 16; - layoutPaddingBottom = 16; - layoutBorderSize = 2; - - break; - - } - case DPIClassification.DPI_320: - { - - upBorderSkin = spark.skins.mobile320.assets.ViewMenuItem_up; - downBorderSkin = spark.skins.mobile320.assets.ViewMenuItem_down; - showsCaretBorderSkin = spark.skins.mobile320.assets.ViewMenuItem_showsCaret; - - layoutGap = 12; - layoutPaddingLeft = 12; - layoutPaddingRight = 12; - layoutPaddingTop = 12; - layoutPaddingBottom = 12; - layoutBorderSize = 2; - - - break; - } - case DPIClassification.DPI_240: - { - upBorderSkin = spark.skins.mobile.assets.ViewMenuItem_up; - downBorderSkin = spark.skins.mobile.assets.ViewMenuItem_down; - showsCaretBorderSkin = spark.skins.mobile.assets.ViewMenuItem_showsCaret; - - layoutGap = 8; - layoutPaddingLeft = 8; - layoutPaddingRight = 8; - layoutPaddingTop = 8; - layoutPaddingBottom = 8; - layoutBorderSize = 1; - - break; - - } - case DPIClassification.DPI_120: - { - upBorderSkin = spark.skins.mobile120.assets.ViewMenuItem_up; - downBorderSkin = spark.skins.mobile120.assets.ViewMenuItem_down; - showsCaretBorderSkin = spark.skins.mobile120.assets.ViewMenuItem_showsCaret; - - layoutGap = 4; - layoutPaddingLeft = 4; - layoutPaddingRight = 4; - layoutPaddingTop = 4; - layoutPaddingBottom = 4; - layoutBorderSize = 1; - - break; - - } - default: - { - upBorderSkin = spark.skins.mobile.assets.ViewMenuItem_up; - downBorderSkin = spark.skins.mobile.assets.ViewMenuItem_down; - showsCaretBorderSkin = spark.skins.mobile.assets.ViewMenuItem_showsCaret; - - layoutGap = 6; - layoutPaddingLeft = 6; - layoutPaddingRight = 6; - layoutPaddingTop = 6; - layoutPaddingBottom = 6; - layoutBorderSize = 1; - } - } - - } - - /** - * Class to use for the border in the showsCaret state. - * - * @langversion 3.0 - * @playerversion Flash 10 - * @playerversion AIR 2.5 - * @productversion Flex 4.5 - * - * @default Button_down - */ - protected var showsCaretBorderSkin:Class; - - /** - * @private - */ - override protected function getBorderClassForCurrentState():Class - { - var borderClass:Class = super.getBorderClassForCurrentState(); - - if (currentState == "showsCaret") - borderClass = showsCaretBorderSkin; - - return borderClass; - } - - /** - * @private - */ - override protected function layoutContents(unscaledWidth:Number, unscaledHeight:Number):void - { - var iconPlacement:String = getStyle("iconPlacement"); - useCenterAlignment = (iconPlacement == IconPlacement.LEFT) - || (iconPlacement == IconPlacement.RIGHT); - - super.layoutContents(unscaledWidth, unscaledHeight); - } - - /** - * @private - */ - override protected function drawBackground(unscaledWidth:Number, unscaledHeight:Number):void - { - // omit call to super.drawBackground(), drawRect instead - - if (currentState == "showsCaret" || currentState == "down") - { - graphics.beginFill(getStyle("focusColor")); - } - else - { - colorMatrix.createGradientBox(unscaledWidth, - unscaledHeight, - Math.PI / 2, 0, 0); - var chromeColor:uint = getStyle("chromeColor"); - - graphics.beginGradientFill(GradientType.LINEAR, - [chromeColor, chromeColor], - [1.0, 1.0], - [0, 255], - colorMatrix); - } - graphics.drawRect(0,0,unscaledWidth,unscaledHeight); - graphics.lineStyle(0.5,0,0.2); - graphics.drawRect(0,unscaledHeight,unscaledWidth,0.5); - graphics.endFill(); - } - } -} http://git-wip-us.apache.org/repos/asf/flex-examples/blob/8ccec1f5/tourdeflexmobile/src/spark/skins/android4/ViewMenuSkin.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmobile/src/spark/skins/android4/ViewMenuSkin.mxml b/tourdeflexmobile/src/spark/skins/android4/ViewMenuSkin.mxml deleted file mode 100644 index 36feed6..0000000 --- a/tourdeflexmobile/src/spark/skins/android4/ViewMenuSkin.mxml +++ /dev/null @@ -1,184 +0,0 @@ -<?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 a Spark ViewMenu in a mobile application. - -@see spark.components.ViewMenu - -@langversion 3.0 -@playerversion Flash 10 -@playerversion AIR 1.5 -@productversion Flex 4 ---> -<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" - xmlns:fb="http://ns.adobe.com/flashbuilder/2009" alpha.disabled="0.5"> - - <fx:Metadata> - <![CDATA[ - /** - * @copy spark.skins.spark.ApplicationSkin#hostComponent - */ - [HostComponent("spark.components.ViewMenu")] - ]]> - </fx:Metadata> - - <fx:Script fb:purpose="styling"> - <![CDATA[ - import mx.core.DPIClassification; - import mx.core.FlexGlobals; - import spark.effects.easing.Power; - - - /** - * @private - */ - override protected function initializationComplete():void - { - useChromeColor = false; - super.initializationComplete(); - } - - /** - * @copy spark.skins.mobile.supportClasses.MobileSkin#applicationDPI - */ - public function get applicationDPI():int - { - return FlexGlobals.topLevelApplication.applicationDPI; - } - - /** - * @private - */ - override protected function measure():void - { - super.measure(); - - // not actually used in normal situations, but - // is here to prevent bug 28950 if ViewMenu is misused - measuredHeight = 200; - } - - /** - * @private - */ - override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void - { - super.updateDisplayList(unscaledWidth, unscaledHeight); - - var strokeWeight:Number = (applicationDPI == DPIClassification.DPI_640 || applicationDPI == DPIClassification.DPI_480 || applicationDPI == DPIClassification.DPI_320) ? 2 : 1; - var separatorWeight:Number = 1; - - if (applicationDPI == DPIClassification.DPI_640) - separatorWeight = 6; - else if (applicationDPI == DPIClassification.DPI_480) - separatorWeight = 4; - else if (applicationDPI == DPIClassification.DPI_320) - separatorWeight = 3; - else if (applicationDPI == DPIClassification.DPI_240) - separatorWeight = 2; - else if (applicationDPI == DPIClassification.DPI_120) - separatorWeight = 1; - - contentGroup.top = strokeWeight + separatorWeight; - contentGroup.bottom = separatorWeight; - contentGroupLayout.gap = separatorWeight; - } - - ]]> - </fx:Script> - - <s:states> - <s:State name="normal" stateGroups="openedGroup"/> - <s:State name="closed" stateGroups="closedGroup"/> - <s:State name="disabled" stateGroups="openedGroup"/> - <s:State name="normalAndLandscape" stateGroups="openedGroup, landscapeGroup"/> - <s:State name="closedAndLandscape" stateGroups="closedGroup, landscapeGroup"/> - <s:State name="disabledAndLandscape" stateGroups="openedGroup, landscapeGroup" /> - </s:states> - - <s:transitions> - <s:Transition fromState="closed" toState="normal" autoReverse="true"> - <s:Parallel> - <s:Fade target="{chromeGroup}" duration="150" easer="{new Power(0.5, 3)}" /> - <s:Move target="{chromeGroup}" duration="150" disableLayout="true" easer="{new Power(0, 5)}"/> - </s:Parallel> - </s:Transition> - - <s:Transition fromState="closedAndLandscape" toState="normalAndLandscape" autoReverse="true"> - <s:Parallel> - <s:Fade target="{chromeGroup}" duration="150" easer="{new Power(0.5, 3)}" /> - <s:Move target="{chromeGroup}" duration="150" disableLayout="true" easer="{new Power(0, 5)}"/> - </s:Parallel> - </s:Transition> - - <s:Transition fromState="normal" toState="closed" autoReverse="true"> - <s:Parallel> - <s:Fade target="{chromeGroup}" duration="100"/> - <s:Move target="{chromeGroup}" duration="100" disableLayout="true"/> - </s:Parallel> - </s:Transition> - - <s:Transition fromState="normalAndLandscape" toState="closedAndLandscape" autoReverse="true"> - <s:Parallel> - <s:Fade target="{chromeGroup}" duration="100"/> - <s:Move target="{chromeGroup}" duration="100" disableLayout="true"/> - </s:Parallel> - </s:Transition> - </s:transitions> - - <!-- The ViewMenu and its skin are sized to the application. - The menu chrome is a separate group that is anchored to the bottom of the skin. --> - - - <s:Group id="chromeGroup" - left="0" - right="0" - top.closedGroup="{hostComponent.height - chromeGroup.height / 2}" - bottom.openedGroup="0" - visible.closedGroup="false"> - - <s:Rect id="backgroundRect" left="18" right="18" top="1" bottom="0"> - <s:fill> - <s:SolidColor color="#FFFFFF" /> - </s:fill> - <s:stroke> - <s:SolidColorStroke weight="0.5" alpha="0.2" /> - </s:stroke> - <s:filters> - <s:DropShadowFilter alpha="0.5" /> - </s:filters> - </s:Rect> - - <!-- - Note: setting the minimum size to 0 here so that changes to the host component's - size will not be thwarted by this skin part's minimum size. This is a compromise, - more about it here: http://bugs.adobe.com/jira/browse/SDK-21143 - --> - <!--- @copy spark.components.SkinnableContainer#contentGroup --> - <s:Group id="contentGroup" left="20" right="20" top="3" bottom="2" minWidth="0" minHeight="0"> - <s:layout> - <s:VerticalLayout gap="-1" id="contentGroupLayout" horizontalAlign="contentJustify" > - </s:VerticalLayout> - </s:layout> - </s:Group> - </s:Group> -</s:SparkSkin> - http://git-wip-us.apache.org/repos/asf/flex-examples/blob/8ccec1f5/tourdeflexmobile/src/spark/skins/android4/supportClasses/CalloutArrow.as ---------------------------------------------------------------------- diff --git a/tourdeflexmobile/src/spark/skins/android4/supportClasses/CalloutArrow.as b/tourdeflexmobile/src/spark/skins/android4/supportClasses/CalloutArrow.as deleted file mode 100644 index cf30796..0000000 --- a/tourdeflexmobile/src/spark/skins/android4/supportClasses/CalloutArrow.as +++ /dev/null @@ -1,457 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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. -// -//////////////////////////////////////////////////////////////////////////////// - -package spark.skins.android4.supportClasses -{ - import flash.display.BlendMode; - import flash.display.GradientType; - import flash.display.Graphics; - import flash.display.GraphicsPathCommand; - import flash.display.Sprite; - - import mx.core.DPIClassification; - import mx.core.FlexGlobals; - import mx.core.IVisualElement; - import mx.core.UIComponent; - import mx.core.mx_internal; - import mx.utils.ColorUtil; - - import spark.components.Application; - import spark.components.ArrowDirection; - import spark.components.Callout; - import spark.skins.android4.CalloutSkin; - import spark.skins.mobile.supportClasses.MobileSkin; - - use namespace mx_internal; - - /** - * The arrow skin part for CalloutSkin. - * - * @see spark.skin.mobile.CalloutSkin - * - * @langversion 3.0 - * @playerversion AIR 3 - * @productversion Flex 4.6 - */ - public class CalloutArrow extends UIComponent - { - public function CalloutArrow() - { - super(); - - useBackgroundGradient = true; - - var applicationDPI:Number = DPIClassification.DPI_160; - if (FlexGlobals.topLevelApplication is Application) - { - applicationDPI = Application(FlexGlobals.topLevelApplication).applicationDPI; - } - - // Copy DPI-specific values from CalloutSkin - switch (applicationDPI) - { - case DPIClassification.DPI_640: - { - // Note provisional may need changes - gap = 32; - backgroundGradientHeight = 440; - highlightWeight = 4; - - break; - } - case DPIClassification.DPI_480: - { - // Note provisional may need changes - gap = 24; - backgroundGradientHeight = 330; - highlightWeight = 3; - - break; - } - case DPIClassification.DPI_320: - { - gap = 16; - backgroundGradientHeight = 220; - highlightWeight = 2; - - break; - } - case DPIClassification.DPI_240: - { - gap = 12; - backgroundGradientHeight = 165; - highlightWeight = 1; - - break; - } - case DPIClassification.DPI_120: - { - // Note provisional may need changes - gap = 6; - backgroundGradientHeight = 83; - highlightWeight = 1; - - break; - } - default: - { - // default DPI_160 - gap = 8; - backgroundGradientHeight = 110; - highlightWeight = 1; - - break; - } - } - } - - /** - * A gap on the frame-adjacent side of the arrow graphic to avoid - * drawing past the CalloutSkin backgroundCornerRadius. - * - * <p>The default implementation matches the gap value with the - * <code>backgroundCornerRadius</code> value in <code>CalloutSkin</code>.</p> - * - * @see spark.skins.mobile.CalloutSkin#backgroundCornerRadius - * - * @langversion 3.0 - * @playerversion AIR 3 - * @productversion Flex 4.6 - */ - protected var gap:Number; - - /** - * @copy spark.skins.mobile.CalloutSkin#backgroundGradientHeight - */ - protected var backgroundGradientHeight:Number; - - /** - * @copy spark.skins.mobile.CalloutSkin#highlightWeight - */ - private var highlightWeight:Number; - - /** - * @copy spark.skins.mobile.CalloutSkin#useBackgroundGradient - */ - protected var useBackgroundGradient:Boolean; - - /** - * @copy spark.skins.mobile.CalloutSkin#borderColor - */ - protected var borderColor:Number = -1; // if not set - - /** - * @copy spark.skins.mobile.CalloutSkin#borderThickness - */ - protected var borderThickness:Number = -1 ; // marker that borderThickness was not set directly - - /** - * @private - * A sibling of the arrow used to erase the drop shadow in CalloutSkin - */ - private var eraseFill:Sprite; - - /* helper private accessors */ - - /* returns borderThickness from style if member is -1, or borderThickness. Returns 0 if NaN */ - private function get actualBorderThickness():Number - { - return calloutSkin.actualBorderThickness; - } - - private function get actualBorderColor():uint - { - return calloutSkin.actualBorderColor; - } - - protected function get calloutSkin():CalloutSkin - { - return parent as CalloutSkin ; - } - - protected function get calloutHostComponent():Callout { - return calloutSkin.hostComponent; - } - - /** - * @private - */ - - override protected function createChildren():void - { - super.createChildren(); - - // eraseFill has the same position and arrow shape in order to erase - // the drop shadow under the arrow when backgroundAlpha < 1 - eraseFill = new Sprite(); - eraseFill.blendMode = BlendMode.ERASE; - - // layer eraseFill below the arrow - parent.addChildAt(eraseFill, parent.getChildIndex(this)); - } - - /** - * @private - */ - override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void - { - super.updateDisplayList(unscaledWidth, unscaledHeight); - - graphics.clear(); - eraseFill.graphics.clear(); - var hostComponent: Callout = calloutHostComponent; - var arrowDirection:String = hostComponent.arrowDirection; - - if (arrowDirection == ArrowDirection.NONE) - return; - - // when drawing the arrow, compensate for cornerRadius via padding - var arrowGraphics:Graphics = this.graphics; - var eraseGraphics:Graphics = eraseFill.graphics; - var arrowWidth:Number = unscaledWidth; - var arrowHeight:Number = unscaledHeight; - var arrowX:Number = 0; - var arrowY:Number = 0; - var arrowTipX:Number = 0; - var arrowTipY:Number = 0; - var arrowEndX:Number = 0; - var arrowEndY:Number = 0; - - var borderWeight:Number = actualBorderThickness; - var showBorder:Boolean = borderWeight > 0; - - var borderHalf:Number = borderWeight / 2; - var isHorizontal:Boolean = false; - - if ((arrowDirection == ArrowDirection.LEFT) || - (arrowDirection == ArrowDirection.RIGHT)) - { - isHorizontal = true; - - arrowX = -borderHalf; - arrowY = gap; - arrowHeight = arrowHeight - (gap * 2); - - arrowTipX = arrowWidth - borderHalf; - arrowTipY = arrowY + (arrowHeight / 2); - - arrowEndX = arrowX; - arrowEndY = arrowY + arrowHeight; - - // flip coordinates to point left - if (arrowDirection == ArrowDirection.LEFT) - { - arrowX = arrowWidth - arrowX; - arrowTipX = arrowWidth - arrowTipX; - arrowEndX = arrowWidth - arrowEndX; - } - } - else - { - arrowX = gap; - arrowY = -borderHalf; - arrowWidth = arrowWidth - (gap * 2); - - arrowTipX = arrowX + (arrowWidth / 2); - arrowTipY = arrowHeight - borderHalf; - - arrowEndX = arrowX + arrowWidth; - arrowEndY = arrowY; - - // flip coordinates to point up - if (hostComponent.arrowDirection == ArrowDirection.UP) - { - arrowY = arrowHeight - arrowY; - arrowTipY = arrowHeight - arrowTipY; - arrowEndY = arrowHeight - arrowEndY; - } - } - - var commands:Vector.<int> = new Vector.<int>(3, true); - commands[0] = GraphicsPathCommand.MOVE_TO; - commands[1] = GraphicsPathCommand.LINE_TO; - commands[2] = GraphicsPathCommand.LINE_TO; - - var coords:Vector.<Number> = new Vector.<Number>(6, true); - coords[0] = arrowX; - coords[1] = arrowY; - coords[2] = arrowTipX - coords[3] = arrowTipY; - coords[4] = arrowEndX - coords[5] = arrowEndY; - - var backgroundColor:Number = getStyle("backgroundColor"); - var backgroundAlpha:Number = getStyle("backgroundAlpha"); - - if (useBackgroundGradient) - { - var backgroundColorTop:Number = ColorUtil.adjustBrightness2(backgroundColor, - CalloutSkin.BACKGROUND_GRADIENT_BRIGHTNESS_TOP); - var backgroundColorBottom:Number = ColorUtil.adjustBrightness2(backgroundColor, - CalloutSkin.BACKGROUND_GRADIENT_BRIGHTNESS_BOTTOM); - - // translate the gradient based on the arrow position - MobileSkin.colorMatrix.createGradientBox(unscaledWidth, - backgroundGradientHeight, Math.PI / 2, 0, -getLayoutBoundsY()); - - arrowGraphics.beginGradientFill(GradientType.LINEAR, - [backgroundColorTop, backgroundColorBottom], - [backgroundAlpha, backgroundAlpha], - [0, 255], - MobileSkin.colorMatrix); - } - else - { - arrowGraphics.beginFill(backgroundColor, backgroundAlpha); - } - - // cover the adjacent border from the callout frame - if (showBorder) - { - var coverX:Number = 0; - var coverY:Number = 0; - var coverWidth:Number = 0; - var coverHeight:Number = 0; - - switch (arrowDirection) - { - case ArrowDirection.UP: - { - coverX = arrowX; - coverY = arrowY; - coverWidth = arrowWidth; - coverHeight = borderWeight; - break; - } - case ArrowDirection.DOWN: - { - coverX = arrowX; - coverY = -borderWeight; - coverWidth = arrowWidth; - coverHeight = borderWeight; - break; - } - case ArrowDirection.LEFT: - { - coverX = arrowX; - coverY = arrowY; - coverWidth = borderWeight; - coverHeight = arrowHeight; - break; - } - case ArrowDirection.RIGHT: - { - coverX = -borderWeight; - coverY = arrowY; - coverWidth = borderWeight; - coverHeight = arrowHeight; - break; - } - } - - arrowGraphics.drawRect(coverX, coverY, coverWidth, coverHeight); - } - - // erase the drop shadow from the CalloutSkin - if (backgroundAlpha < 1) - { - // move eraseFill to the same position as the arrow - eraseFill.x = getLayoutBoundsX() - eraseFill.y = getLayoutBoundsY(); - - // draw the arrow shape - eraseGraphics.beginFill(0, 1); - eraseGraphics.drawPath(commands, coords); - eraseGraphics.endFill(); - } - - // draw arrow path - if (showBorder) - arrowGraphics.lineStyle(borderWeight, actualBorderColor, 1, true); - - arrowGraphics.drawPath(commands, coords); - arrowGraphics.endFill(); - - // adjust the highlight position to the origin of the callout - var isArrowUp:Boolean = (arrowDirection == ArrowDirection.UP); - var offsetY:Number = (isArrowUp) ? unscaledHeight : -getLayoutBoundsY(); - - // highlight starts after the backgroundCornerRadius - var highlightX:Number = gap - getLayoutBoundsX(); - - // highlight Y position is based on the stroke weight - var highlightOffset:Number = (highlightWeight * 1.5); - var highlightY:Number = highlightOffset + offsetY; - - // highlight width spans the callout width minus the corner radius - var highlightWidth:Number = IVisualElement(calloutSkin).getLayoutBoundsWidth() - (gap * 2); - - if (isHorizontal) - { - highlightWidth -= arrowWidth; - - if (arrowDirection == ArrowDirection.LEFT) - highlightX += arrowWidth; - } - - // highlight on the top edge is drawn in the arrow only in the UP direction - if (useBackgroundGradient) - { - if (isArrowUp) - { - // highlight follows the top edge, including the arrow - var rightWidth:Number = highlightWidth - arrowWidth; - - // highlight style - arrowGraphics.lineStyle(highlightWeight, 0xFFFFFF, 0.2 * backgroundAlpha); - - // in the arrow coordinate space, the highlightX must be less than 0 - if (highlightX < 0) - { - arrowGraphics.moveTo(highlightX, highlightY); - arrowGraphics.lineTo(arrowX, highlightY); - - // compute the remaining highlight - rightWidth -= (arrowX - highlightX); - } - - // arrow highlight (adjust Y downward) - coords[1] = arrowY + highlightOffset; - coords[3] = arrowTipY + highlightOffset; - coords[5] = arrowEndY + highlightOffset; - arrowGraphics.drawPath(commands, coords); - - // right side - if (rightWidth > 0) - { - arrowGraphics.moveTo(arrowEndX, highlightY); - arrowGraphics.lineTo(arrowEndX + rightWidth, highlightY); - } - } - else - { - // straight line across the top - arrowGraphics.lineStyle(highlightWeight, 0xFFFFFF, 0.2 * backgroundAlpha); - arrowGraphics.moveTo(highlightX, highlightY); - arrowGraphics.lineTo(highlightX + highlightWidth, highlightY); - } - } - } - } -} http://git-wip-us.apache.org/repos/asf/flex-examples/blob/8ccec1f5/tourdeflexmobile/src/spark/skins/android4/supportClasses/StageTextSkinBase.as ---------------------------------------------------------------------- diff --git a/tourdeflexmobile/src/spark/skins/android4/supportClasses/StageTextSkinBase.as b/tourdeflexmobile/src/spark/skins/android4/supportClasses/StageTextSkinBase.as deleted file mode 100644 index bef04b5..0000000 --- a/tourdeflexmobile/src/spark/skins/android4/supportClasses/StageTextSkinBase.as +++ /dev/null @@ -1,402 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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. -// -//////////////////////////////////////////////////////////////////////////////// -package spark.skins.android4.supportClasses -{ - import flash.display.DisplayObject; - import flash.events.FocusEvent; - - import mx.core.DPIClassification; - import mx.core.mx_internal; - - import spark.components.supportClasses.IStyleableEditableText; - import spark.components.supportClasses.SkinnableTextBase; - import spark.components.supportClasses.StyleableStageText; - import spark.components.supportClasses.StyleableTextField; - import spark.core.IDisplayText; - import spark.skins.mobile.supportClasses.MobileSkin; - - use namespace mx_internal; - - /** - * ActionScript-based skin for text input controls in mobile applications. - * - * @langversion 3.0 - * @playerversion AIR 3.0 - * @productversion Flex 4.6 - */ - public class StageTextSkinBase extends MobileSkin - { - //-------------------------------------------------------------------------- - // - // Constructor - // - //-------------------------------------------------------------------------- - - /** - * Constructor. - * - * @langversion 3.0 - * @playerversion AIR 3.0 - * @productversion Flex 4.6 - * - */ - public function StageTextSkinBase() - { - super(); - - switch (applicationDPI) - { - case DPIClassification.DPI_640: - { - measuredDefaultWidth = 1200; - measuredDefaultHeight = 132; - layoutBorderSize = 4; - flatheight = 9; - break; - } - case DPIClassification.DPI_480: - { - measuredDefaultWidth = 880; - measuredDefaultHeight = 100; - layoutBorderSize = 3; - flatheight = 7; - break; - } - case DPIClassification.DPI_320: - { - measuredDefaultWidth = 600; - measuredDefaultHeight = 66; - layoutBorderSize = 2; - flatheight = 6; - break; - } - case DPIClassification.DPI_240: - { - measuredDefaultWidth = 440; - measuredDefaultHeight = 50; - layoutBorderSize = 2; - flatheight = 5; - break; - } - case DPIClassification.DPI_120: - { - measuredDefaultWidth = 220; - measuredDefaultHeight = 25; - layoutBorderSize = 1; - flatheight = 2; - break; - } - default: - { - measuredDefaultWidth = 300; - measuredDefaultHeight = 33; - layoutBorderSize = 1; - flatheight = 3; - break; - } - - } - addEventListener(FocusEvent.FOCUS_IN, focusChangeHandler); - addEventListener(FocusEvent.FOCUS_OUT, focusChangeHandler); - } - - //-------------------------------------------------------------------------- - // - // Graphics variables - // - //-------------------------------------------------------------------------- - - - //-------------------------------------------------------------------------- - // - // Layout variables - // - //-------------------------------------------------------------------------- - - /** - * Defines the border's thickness. - * - * @langversion 3.0 - * @playerversion AIR 3.0 - * @productversion Flex 4.6 - */ - protected var layoutBorderSize:uint; - - protected var flatheight:uint; - - //-------------------------------------------------------------------------- - // - // Variables - // - //-------------------------------------------------------------------------- - - protected var isFocused:Boolean = false; - - /** - * @private - * - * Instance of the border graphics. - */ - protected var border:DisplayObject; - - private var borderVisibleChanged:Boolean = false; - - /** - * @private - * - * Multiline flag. - */ - protected var multiline:Boolean = false; - - //-------------------------------------------------------------------------- - // - // Skin parts - // - //-------------------------------------------------------------------------- - - /** - * textDisplay skin part. - * - * @langversion 3.0 - * @playerversion AIR 3.0 - * @productversion Flex 4.6 - */ - public var textDisplay:IStyleableEditableText; - - [Bindable] - /** - * Bindable promptDisplay skin part. Bindings fire when promptDisplay is - * removed and added for proper updating by the SkinnableTextBase. - * - * @langversion 3.0 - * @playerversion AIR 3.0 - * @productversion Flex 4.6 - */ - public var promptDisplay:IDisplayText; - - //-------------------------------------------------------------------------- - // - // Overridden methods - // - //-------------------------------------------------------------------------- - - /** - * @private - */ - override protected function createChildren():void - { - super.createChildren(); - - if (!textDisplay) - { - textDisplay = createTextDisplay(); - textDisplay.editable = true; - textDisplay.styleName = this; - this.addChild(DisplayObject(textDisplay)); - } - } - - /** Could be overridden by subclasses - * - * @return instance of IStyleableEditableText - */ - protected function createTextDisplay():IStyleableEditableText - { - return new StyleableStageText(multiline); - } - - /** - * @private - */ - override protected function drawBackground(unscaledWidth:Number, unscaledHeight:Number):void - { - super.drawBackground(unscaledWidth, unscaledHeight); - - var contentBackgroundColor:uint = getStyle("contentBackgroundColor"); - var contentBackgroundAlpha:Number = getStyle("contentBackgroundAlpha"); - //change border color and thickness when in focus - var borderColor:uint = isFocused ? getStyle("focusColor") : getStyle("borderColor"); - var selectWidth:uint = isFocused ? layoutBorderSize + 1 : layoutBorderSize; - if (isNaN(contentBackgroundAlpha)) - { - contentBackgroundAlpha = 1; - } - var halfGap:int = flatheight * 2; - // change the border type - if (getStyle("contentBackgroundBorder") == "flat") - { - //background - graphics.beginFill(contentBackgroundColor, contentBackgroundAlpha); - graphics.drawRect(0, 0, unscaledWidth, unscaledHeight - flatheight); - graphics.endFill(); - //begin flat border - graphics.beginFill(borderColor, 1); - //left half border - graphics.drawRect(0, unscaledHeight - halfGap, selectWidth, flatheight ); - //bottom border - graphics.drawRect(0, unscaledHeight - flatheight, unscaledWidth, selectWidth); - //right border - graphics.drawRect(unscaledWidth - selectWidth, unscaledHeight - halfGap, selectWidth, flatheight); - graphics.endFill(); - } - else if (getStyle("contentBackgroundBorder") == "rectangle") - { - var borderWidth:uint = layoutBorderSize * 2; - //rectangle border and background - graphics.lineStyle(selectWidth, borderColor, 1); - graphics.beginFill(contentBackgroundColor, contentBackgroundAlpha); - graphics.drawRect(layoutBorderSize, layoutBorderSize, unscaledWidth - borderWidth, unscaledHeight - borderWidth); - graphics.endFill(); - } - } - - /** - * @private - */ - override public function styleChanged(styleProp:String):void - { - var allStyles:Boolean = !styleProp || styleProp == "styleName"; - - if (allStyles || styleProp == "borderVisible") - { - borderVisibleChanged = true; - invalidateProperties(); - } - - if (allStyles || styleProp.indexOf("padding") == 0) - { - invalidateDisplayList(); - } - super.styleChanged(styleProp); - } - - /** - * @private - */ - override protected function commitCurrentState():void - { - super.commitCurrentState(); - - alpha = currentState.indexOf("disabled") == -1 ? 1 : 0.5; - - var showPrompt:Boolean = currentState.indexOf("WithPrompt") != -1; - - if (showPrompt && !promptDisplay) - { - promptDisplay = createPromptDisplay(); - promptDisplay.addEventListener(FocusEvent.FOCUS_IN, promptDisplay_focusInHandler); - } - else if (!showPrompt && promptDisplay) - { - promptDisplay.removeEventListener(FocusEvent.FOCUS_IN, promptDisplay_focusInHandler); - removeChild(promptDisplay as DisplayObject); - promptDisplay = null; - } - super.commitCurrentState(); - - invalidateDisplayList(); - } - - //-------------------------------------------------------------------------- - // - // Methods - // - //-------------------------------------------------------------------------- - - /** - * @private - * Create a control appropriate for displaying the prompt text in a mobile - * input field. - */ - protected function createPromptDisplay():IDisplayText - { - var prompt:StyleableTextField = StyleableTextField(createInFontContext(StyleableTextField)); - prompt.styleName = this; - prompt.editable = false; - prompt.mouseEnabled = false; - prompt.useTightTextBounds = false; - // StageText objects appear in their own layer on top of the display - // list. So, even though this prompt may be created after the StageText - // for textDisplay, textDisplay will still be on top. - addChild(prompt); - - return prompt; - } - - /** - * @private - * Utility function used by subclasses' measure functions to measure their - * text host components. - */ - protected function measureTextComponent(hostComponent:SkinnableTextBase):void - { - var paddingLeft:Number = getStyle("paddingLeft"); - var paddingRight:Number = getStyle("paddingRight"); - var paddingTop:Number = getStyle("paddingTop"); - var paddingBottom:Number = getStyle("paddingBottom"); - var textHeight:Number = getStyle("fontSize"); - - if (textDisplay) - { - textHeight = getElementPreferredHeight(textDisplay); - } - // width is based on maxChars (if set) - if (hostComponent && hostComponent.maxChars) - { - // Grab the fontSize and subtract 2 as the pixel value for each character. - // This is just an approximation, but it appears to be a reasonable one - // for most input and most font. - var characterWidth:int = Math.max(1, (textHeight - 2)); - measuredWidth = (characterWidth * hostComponent.maxChars) + paddingLeft + paddingRight; - } - - measuredHeight = paddingTop + textHeight + paddingBottom; - } - - //-------------------------------------------------------------------------- - // - // Event handlers - // - //-------------------------------------------------------------------------- - - /** - * Listen to see if the component gains focus then change the style to selected - */ - private function focusChangeHandler(event:FocusEvent):void - { - isFocused = event.type == FocusEvent.FOCUS_IN; - invalidateDisplayList(); - } - - /** - * If the prompt is focused, we need to move focus to the textDisplay - * StageText. This needs to happen outside of the process of setting focus - * to the prompt, so we use callLater to do that. - */ - private function focusTextDisplay():void - { - textDisplay.setFocus(); - } - - private function promptDisplay_focusInHandler(event:FocusEvent):void - { - callLater(focusTextDisplay); - } - } -} http://git-wip-us.apache.org/repos/asf/flex-examples/blob/8ccec1f5/tourdeflexmobile/src/spark/skins/android4/supportClasses/TextSkinBase.as ---------------------------------------------------------------------- diff --git a/tourdeflexmobile/src/spark/skins/android4/supportClasses/TextSkinBase.as b/tourdeflexmobile/src/spark/skins/android4/supportClasses/TextSkinBase.as deleted file mode 100644 index 70e0294..0000000 --- a/tourdeflexmobile/src/spark/skins/android4/supportClasses/TextSkinBase.as +++ /dev/null @@ -1,213 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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. -// -//////////////////////////////////////////////////////////////////////////////// - -package spark.skins.android4.supportClasses -{ - - import flash.display.DisplayObject; - - import mx.core.mx_internal; - - import spark.components.supportClasses.StyleableTextField; - import spark.skins.mobile.supportClasses.MobileSkin; - - use namespace mx_internal; - - /** - * ActionScript-based skin for text input controls in mobile applications that - * uses a StyleableTextField class for the text display. - * - * @see spark.components.supportClasses.StyleableTextField - * - * @langversion 3.0 - * @playerversion Flash 10 - * @playerversion AIR 2.5 - * @productversion Flex 4.5 - */ - public class TextSkinBase extends MobileSkin - { - //-------------------------------------------------------------------------- - // - // Constructor - // - //-------------------------------------------------------------------------- - /** - * Constructor. - * - * @langversion 3.0 - * @playerversion Flash 10 - * @playerversion AIR 2.5 - * @productversion Flex 4.5 - * - */ - public function TextSkinBase() - { - super(); - } - - //-------------------------------------------------------------------------- - // - // Graphics variables - // - //-------------------------------------------------------------------------- - - /** - * Defines the border. - * - * @langversion 3.0 - * @playerversion Flash 10 - * @playerversion AIR 2.5 - * @productversion Flex 4.5 - */ - - //-------------------------------------------------------------------------- - // - // Layout variables - // - //-------------------------------------------------------------------------- - - /** - * Defines the corner radius. - * - * @langversion 3.0 - * @playerversion Flash 10 - * @playerversion AIR 2.5 - * @productversion Flex 4.5 - */ - - protected var layoutBorderSize:uint; - - //-------------------------------------------------------------------------- - // - // Variables - // - //-------------------------------------------------------------------------- - - /** - * @private - * - * Instance of the border graphics. - */ - protected var border:DisplayObject; - - private var borderVisibleChanged:Boolean = false; - - //-------------------------------------------------------------------------- - // - // Skin parts - // - //-------------------------------------------------------------------------- - - /** - * textDisplay skin part. - */ - public var textDisplay:StyleableTextField; - - [Bindable] - /** - * Bindable promptDisplay skin part. Bindings fire when promptDisplay is - * removed and added for proper updating by the SkinnableTextBase. - */ - public var promptDisplay:StyleableTextField; - - //-------------------------------------------------------------------------- - // - // Overridden methods - // - //-------------------------------------------------------------------------- - - /** - * @private - */ - override protected function createChildren():void - { - super.createChildren(); - - if (!textDisplay) - { - textDisplay = StyleableTextField(createInFontContext(StyleableTextField)); - textDisplay.styleName = this; - textDisplay.editable = true; - textDisplay.useTightTextBounds = false; - addChild(textDisplay); - } - } - - /** - * @private - */ - protected function createPromptDisplay():StyleableTextField - { - var prompt:StyleableTextField = StyleableTextField(createInFontContext(StyleableTextField)); - prompt.styleName = this; - prompt.editable = false; - prompt.mouseEnabled = false; - prompt.useTightTextBounds = false; - prompt.focusEnabled = false; - return prompt; - } - - /** - * @private - */ - - override public function styleChanged(styleProp:String):void - { - var allStyles:Boolean = !styleProp || styleProp == "styleName"; - - if (allStyles || styleProp == "borderVisible") - { - borderVisibleChanged = true; - invalidateProperties(); - } - - if (allStyles || styleProp.indexOf("padding") == 0) - { - invalidateDisplayList(); - } - - super.styleChanged(styleProp); - } - - /** - * @private - */ - override protected function commitCurrentState():void - { - super.commitCurrentState(); - - alpha = currentState.indexOf("disabled") == -1 ? 1 : 0.5; - - var showPrompt:Boolean = currentState.indexOf("WithPrompt") >= 0; - - if (showPrompt && !promptDisplay) - { - promptDisplay = createPromptDisplay(); - addChild(promptDisplay); - } - else if (!showPrompt && promptDisplay) - { - removeChild(promptDisplay); - promptDisplay = null; - } - - invalidateDisplayList(); - } - } -}
