Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3255122
  • 博文数量: 530
  • 博客积分: 13360
  • 博客等级: 上将
  • 技术积分: 5473
  • 用 户 组: 普通用户
  • 注册时间: 2006-07-13 13:32
文章分类

全部博文(530)

文章存档

2017年(1)

2015年(2)

2013年(24)

2012年(20)

2011年(97)

2010年(240)

2009年(117)

2008年(12)

2007年(8)

2006年(9)

分类: 系统运维

2012-07-12 10:15:53

package mx.managers
{
import mx.core.IUIComponent;
import mx.core.Singleton;
import mx.core.mx_internal;

//--------------------------------------
//  Styles
//--------------------------------------

/**
 *  定义了the busy cursor的皮肤
 *  @default mx.skins.halo.BusyCursor
 */
[Style(name="busyCursor", type="Class", inherit="no")]

/**
 *  定义了the busy cursor background的皮肤背景.
 *  默认值 "cursorStretch" symbol from the Assets.swf file.
 */
[Style(name="busyCursorBackground", type="Class", inherit="no")]

/**
 CursorManager 类控制光标的优先级列表,在该列表中,具有最高优先级的光标是当前可见的光标。如果光标列表中有多个光标具有同一优先级,则光标管理器将显示最近创建的光标。

例如,如果应用程序正在执行的处理过程要求用户等待处理完成,则可以对光标进行更改,使其反映等待期。在这种情况下,您可以将光标更改为沙漏或其它图像。

您可能还希望将光标更改为可以向用户提供反馈,用来指示用户可以执行的操作。例如,您可以使用一个光标图像来指示已 启用用户输入,使用另一个光标图像来指示已禁用用户输入。您可以使用 JPEG、GIF、PNG 或 SVG 图像、Sprite 对象或者 SWF 文件来作为光标图像。

CursorManager 的所有方法和属性都是静态的,因此不需要为其创建实例。

在 AIR 中,每个 mx.core.Window 实例都使用自己的 CursorManager 类的实例。不直接引用 CursorManager 类的静态方法和属性,而是使用 Window.cursorManager 属性引用 Window 实例的 CursorManager 实例。

*/
public class CursorManager
{
    include "../core/Version.as";

    //--------------------------------------------------------------------------
    //  Class 构造型
    //--------------------------------------------------------------------------
   
    /**
     *  为currentCursorID属性的常量值
     *  该值表示当前正使用系统的光标,CursorManager没有管理任何光标
     */
    public static const NO_CURSOR:int = 0;
   
    //--------------------------------------------------------------------------
    //  Class 变量
    //--------------------------------------------------------------------------

    /**
     *  @private
     *  Linker dependency on implementation class.
     */
    private static var implClassDependency:CursorManagerImpl;

    /**
     *  @private
     *  Storage for the impl getter.
     *  This gets initialized on first access,
     *  not at static initialization time, in order to ensure
     *  that the Singleton registry has already been initialized.
     */
    private static var _impl:ICursorManager;
   
    /**
     *  @private
     *  The singleton instance of CursorManagerImpl which was
     *  registered as implementing the ICursorManager interface.
     */
    private static function get impl():ICursorManager
    {
        if (!_impl)
        {
            _impl = ICursorManager(
                Singleton.getInstance("mx.managers::ICursorManager"));
        }

        return _impl;
    }
   
    /**
     *  Each mx.core.Window instance in an AIR application has its own CursorManager instance.
     *  This method returns the CursorManager instance for the main Window instance. 
     *
     *  @return The CursorManager instance for the main Window instance in an AIR application. 
     * 
     *  @langversion 3.0
     *  @playerversion Flash 9
     *  @playerversion AIR 1.1
     *  @productversion Flex 3
     */
    public static function getInstance():ICursorManager
    {
        return impl;
    }

    //--------------------------------------------------------------------------
    //  Class 属性
    //--------------------------------------------------------------------------

    //----------------------------------
    //  currentCursorID
    //----------------------------------

    /**
     *  当前用户自定义光标ID
        如果使用了系统光标,则该值为NO_CURSOR
     */
    public static function get currentCursorID():int
    {
        return impl.currentCursorID;
    }
   
    /**
     *  静态,表示任何人都可以设置当前光标ID
     */
    public static function set currentCursorID(value:int):void
    {
        impl.currentCursorID = value;
    }

    //----------------------------------
    //  currentCursorXOffset
    //----------------------------------

    /**
     *  自定义光标随鼠标指针变化的 x 偏移(以像素为单位)
     *  默认值为 0
     */
    public static function get currentCursorXOffset():Number
    {
        return impl.currentCursorXOffset;
    }

    public static function set currentCursorXOffset(value:Number):void
    {
        impl.currentCursorXOffset = value;
    }

    //----------------------------------
    //  currentCursorYOffset
    //----------------------------------

    /**
     *  自定义光标随鼠标指针变化的 y 偏移(以像素为单位)。
     *  @default 0
     */
    public static function get currentCursorYOffset():Number
    {
        return impl.currentCursorYOffset;
    }
   
    public static function set currentCursorYOffset(value:Number):void
    {
        impl.currentCursorYOffset = value;
    }

    //--------------------------------------------------------------------------
    //  Class 方法
    //--------------------------------------------------------------------------
   
    /**
     *  使光标可见
     *  Cursor 可见不是引用计数的
     *  不管调用了多少次hideCursor(),只要一次调用showCursor()就显示光标
     *  使用Mouse.show()和Mouse.hide(),直接控制系统光标
     */
    public static function showCursor():void
    {
        impl.showCursor();
    }
   
    /**
     *  使光标不可见
     */
    public static function hideCursor():void
    {
        impl.hideCursor();
    }

    /**
     *  创建新光标并为此光标设置可选优先级。
     *  添加新光标到光标列表中
     *
     *  @param cursorClass 显示光标的图象类
     *
     *  @param priority 整数,描述光标优级级
     *  分别为CursorManagerPriority.HIGH、CursorManagerPriority.MEDIUM、CursorManagerPriority.LOW
     *
     *  @param xOffset 自定义光标随鼠标指针变化的 x 偏移(以像素为单位)
     *
     *  @param yOffset 自定义光标随鼠标指针变化的 y 偏移(以像素为单位)
     *
     *  @return 返回光标的ID
     */
    public static function setCursor(cursorClass:Class, priority:int = 2,
                                     xOffset:Number = 0,
                                     yOffset:Number = 0):int
    {
        return impl.setCursor(cursorClass, priority, xOffset, yOffset);
    }
   
    /**
     *  从光标列表中移除光标
     *  如果该光标为当前显示光标,则CursorManager显示列表中的下一个光标,如果列表为空,则显示系统默认光标
     *
     *  @param cursorID 移除的光标ID
     */
    public static function removeCursor(cursorID:int):void
    {
        impl.removeCursor(cursorID);
    }
   
    /**
     *  移除光标列中所有光标,恢复成系统光标
     */
    public static function removeAllCursors():void
    {
        impl.removeAllCursors();
    }

    /**
     *  Displays the busy cursor.
     *  The busy cursor has a priority of CursorManagerPriority.LOW.
     *  Therefore, if the cursor list contains a cursor
     *  with a higher priority, the busy cursor is not displayed
     *  until you remove the higher priority cursor.
     *  To create a busy cursor at a higher priority level,
     *  use the setCursor() method.
     */
    public static function setBusyCursor():void
    {
        impl.setBusyCursor();
    }

    /**
     *  Removes the busy cursor from the cursor list.
     *  If other busy cursor requests are still active in the cursor list,
     *  which means you called the setBusyCursor() method more than once,
     *  a busy cursor does not disappear until you remove
     *  all busy cursors from the list.
     * 
     *  @langversion 3.0
     *  @playerversion Flash 9
     *  @playerversion AIR 1.1
     *  @productversion Flex 3
     */
    public static function removeBusyCursor():void
    {
        impl.removeBusyCursor();
    }
           
   
    /**
     *  @private
     *  Called by other components if they want to display
     *  the busy cursor during progress events.
     */
    mx_internal static function registerToUseBusyCursor(source:Object):void
    {
        impl.registerToUseBusyCursor(source);
    }

    /**
     *  @private
     *  Called by other components to unregister
     *  a busy cursor from the progress events.
     */
    mx_internal static function unRegisterToUseBusyCursor(source:Object):void
    {
        impl.unRegisterToUseBusyCursor(source);
    }
   
}

}
       

阅读(1689) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~