class org.aswing.AsWingUtils

A collection of utility methods for AsWing. @author paling

Class Fields

static var BOTTOM:Float

A fast access to AsWingConstants Constant @see org.aswing.AsWingConstants

static var CENTER:Float

A fast access to ASWingConstants Constant @see org.aswing.ASWingConstants

static var HORIZONTAL:Float

A fast access to AsWingConstants Constant @see org.aswing.AsWingConstants

static var LEFT:Float

A fast access to AsWingConstants Constant @see org.aswing.AsWingConstants

static var RIGHT:Float

A fast access to AsWingConstants Constant @see org.aswing.AsWingConstants

static var TOP:Float

A fast access to AsWingConstants Constant @see org.aswing.AsWingConstants

static var VERTICAL:Float

A fast access to AsWingConstants Constant @see org.aswing.AsWingConstants

static function applyTextColor(text:TextField, color:ASColor): Void

static function applyTextFont(text:TextField, font:ASFont): Void

static function applyTextFontAndColor(text:TextField, font:ASFont, color:ASColor): Void

Apply the font and color to the textfield.

text
font
null

color

static function applyTextFormat(text:TextField, textFormat:TextFormat): Void

static function as<T>(v:Dynamic, c:Class<T>): Null<T>

Create a sprite at specified parent with specified name. The created sprite default property is mouseEnabled=false.

returns

the sprite

static function centerLocate(popup:JPopup): Void

Locate the popup at center of the stage.

popup

the popup to be located.

static function computeMultilineStringHeightWithFont(font:ASFont, str:String, width:Float, ?includeGutters:Bool = true): Int

Computes the text size of specified font, text. @return the computed size of the text

tf

the font of the text

str

the text to be computes

includeGutters

whether or not include the 2-pixels gutters in the result *

static function computeStringSize(tf:TextFormat, str:String, ?includeGutters:Bool = true, ?textField:TextField = null): IntDimension

Computes the text size of specified textFormat, text, and textfield. @return the computed size of the text

tf

the textformat of the text

str

the text to be computes

includeGutters

whether or not include the 2-pixels gutters in the result

textField

if a textField is specifed, the embedFonts, antiAliasType, gridFitType, sharpness, and thickness properties of this textField will take effects.

 * 

static function computeStringSizeWithFont(font:ASFont, str:String, ?includeGutters:Bool = true): IntDimension

Computes the text size of specified font, text. @return the computed size of the text

tf

the font of the text

str

the text to be computes

includeGutters

whether or not include the 2-pixels gutters in the result *

static function createLabel(?parent:DisplayObjectContainer = null, ?name:String = null): TextField

Create a disabled TextField at specified parent with specified name. The created sprite default property is mouseEnabled=false, selecteable=false, editable=false TextFieldAutoSize.LEFT etc.

returns

the textfield

static function createPaneToHold(com:Component, layout:LayoutManager, ?constraints:Dynamic = null): Container

Creates and return a pane to hold the component with specified layout manager and constraints.

static function createShape(?parent:DisplayObjectContainer = null, ?name:String = null): Shape

Create a shape.

returns

the sprite

static function createSprite(?parent:DisplayObjectContainer = null, ?name:String = null): Sprite

static function getOwnerAncestor(c:Component): DisplayObjectContainer

Returns the first popup ancestor or display object root of c, or null if can't find the ancestor

returns

the first popup ancestor or display object root of c, or null if can't find the ancestor

static function getOwnerComponent(dis:DisplayObject): Component

Returns the component owner of specified obj.

returns

the component owner of specified obj.

static function getPopupAncestor(c:Component): JPopup

Returns the MCPanel ancestor of c, or null if it is not contained inside a mcpanel yet

returns

the first MCPanel ancestor of c, or null.

static function getScreenCenterPosition(): IntPoint

Returns the center position in the stage.

static function getStageMousePosition(?stage:Stage = null): IntPoint

static function getVisibleMaximizedBounds(?dis:DisplayObject = null): IntRectangle

Returns the currently visible maximized bounds in a display object(viewable the stage area).

Note : your stage must be StageAlign.TOP_LEFT align unless this returned value may not be right. </>

dis

the display object, default is stage

static function initAsStandard(): Void

static function isAncestor(ancestor:Component, child:Component): Bool

Returns whether or not the ancestor is the child's display ancestor.

returns

whether or not the ancestor is the child's display ancestor.

static function isAncestorComponent(ancestor:Component, child:Component): Bool

Returns whether or not the ancestor is the child's component ancestor.

returns

whether or not the ancestor is the child's component ancestor.

static function isAncestorDisplayObject(ancestor:DisplayObjectContainer, child:DisplayObject): Bool

Returns whether or not the ancestor is the child's ancestor.

returns

whether or not the ancestor is the child's ancestor.

static function isDisplayObjectShowing(dis:DisplayObject): Bool

Returns whethor or not the display object is showing, which means that it is visible and it's ancestors(parent, parent's parent ...) is visible and on stage too.

returns

trun if showing, not then false.

static function layoutCompoundLabel(c:Component, f:ASFont, text:String, icon:Icon, verticalAlignment:Int, horizontalAlignment:Int, verticalTextPosition:Int, horizontalTextPosition:Int, viewR:IntRectangle, iconR:IntRectangle, textR:IntRectangle, textIconGap:Int): String

Compute and return the location of the icons origin, the location of origin of the text baseline, and a possibly clipped version of the compound labels string. Locations are computed relative to the viewR rectangle.

static function layoutCompoundMultilineLabel(c:Component, f:ASFont, text:String, icon:Icon, verticalAlignment:Int, horizontalAlignment:Int, verticalTextPosition:Int, horizontalTextPosition:Int, viewR:IntRectangle, iconR:IntRectangle, textR:IntRectangle, textIconGap:Int): String

static function layoutText(f:ASFont, text:String, verticalAlignment:Float, horizontalAlignment:Float, viewR:IntRectangle, textR:IntRectangle): String

Compute and return the location of origin of the text baseline, and a possibly clipped version of the text string. Locations are computed relative to the viewR rectangle.

static function updateAllComponentUI(?stage:Stage = null): Void

When call setLookAndFeel it will not change the UIs at created components. Call this method to update all UIs of components that is on display list or popups. @see #updateAllComponentUIInMemory() @see #updateChildrenUI() @see #updateComponentTreeUI() @see org.aswing.Component#updateUI()

static function updateAllComponentUIInMemory(): Void

When call setLookAndFeel it will not change the UIs at created components. Call this method to update all UIs of all components in memory whether it is displayable or not. Take care to call this method, because there's may many component in memory since the garbage collector may have not collected some useless components, so it many take a long time to complete updating. @see #updateAllComponentUI() @see org.aswing.Component#updateUI()

static function updateChildrenUI(dis:DisplayObject): Void

Asks every component that is not a ui element containsed in the display object to updateUI(). This function will search all components contained in the specified object. @see org.aswing.Component#isUIElement()

dis

the display object

static function updateComponentTreeUI(c:Component): Void

A simple minded look and feel change: ask each node in the tree to updateUI() -- that is, to initialize its UI property with the current look and feel. @see org.aswing.Component#updateUI() @see #updateChildrenUI()

c

the component used to search its owner ancestor