- 浏览: 39052 次
- 性别:
- 来自: 广州
最新评论
超级面板皮肤及其使用
- 博客分类:
- 技术杂绘
画出类似于遨游那样的最大化,最小化,关闭,还原按钮的皮肤。
使用path路径画笔进行绘制。
CloseButtonSkin:
flex/spark"
xmlns:fx="http://ns.adobe.com/mxml/2009">
[HostComponent("spark.components.Button ")]
MaximizeButtonSkin:
flex/spark"
xmlns:fx="http://ns.adobe.com/mxml/2009">
[HostComponent("spark.components.Button ")]
MinimizeButtonSkin:
flex/spark"
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:d="http://ns.adobe.com/fxg/2008/dt">
[HostComponent("spark.components.Button ")]
flex/spark"
xmlns:fx="http://ns.adobe.com/mxml/2009">
[HostComponent("spark.components.Button ")]
package
{
import events.FxWindowEvent;
import skins.FxWindowSkin;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
import mx.core.IVisualElementContainer;
import mx.managers.CursorManager;
import spark.components.Button;
import spark.components.Panel;
[Event(name="close", type="events.CzWindowEvent")]
[Event(name="maximize", type="events.CzWindowEvent")]
[Event(name="minimize", type="events.CzWindowEvent")]
[Event(name="restore", type="events.CzWindowEvent")]
[Event(name="focusstart", type="events.CzWindowEvent")]
[Event(name="focusend", type="events.CzWindowEvent")]
public class FxWindow extends Panel
{
[Embed(source="assets/resizeCursorH.gif")]
private static var DEFAULT_RESIZE_CURSOR_HORIZONTAL:Class;
[Embed(source="assets/resizeCursorTLBR.gif")]
private static var DEFAULT_RESIZE_CURSOR_TL_BR:Class;
[Embed(source="assets/resizeCursorTRBL.gif")]
private static var DEFAULT_RESIZE_CURSOR_TR_BL:Class;
[Embed(source="assets/resizeCursorV.gif")]
private static var DEFAULT_RESIZE_CURSOR_VERTICAL:Class;
public function FxWindow()
{
super();
setStyle("cornerRadius", 6);
setStyle("skinClass",FxWindowSkin);
windowState=FxWindowState.NORMAL;
}
//改变窗口尺寸的按钮=========start==============
[SkinPart(required="false")]
public var bottomLeftResizeButton:Button;
[SkinPart(required="false")]
public var bottomResizeButton:Button;
[SkinPart(required="false")]
public var bottomRightResizeButton:Button;
[SkinPart(required="false")]
public var leftResizeButton:Button;
[SkinPart(required="false")]
public var rightResizeButton:Button;
[SkinPart(required="false")]
public var topLeftResizeButton:Button;
[SkinPart(required="false")]
public var topResizeButton:Button;
[SkinPart(required="false")]
public var topRightResizeButton:Button;
//改变窗口尺寸的按钮=========end==============
//控制窗口状态的按钮=========start==============
[SkinPart(required="false")]
public var minimizeButton:Button;
[SkinPart(required="false")]
public var restoreButton:Button;
[SkinPart(required="false")]
public var maximizeButton:Button;
[SkinPart(required="false")]
public var closeButton:Button;
//控制窗口状态的按钮=========end==============
private var _hasFocus:Boolean;
private var _windowState:int;
private var currentResizeHandle:Button;
private var dragAmountX:Number;
private var dragAmountY:Number;
private var dragMaxX:Number;
private var dragMaxY:Number;
private var dragStartMouseX:Number;
private var dragStartMouseY:Number;
private var normalHeight:Number;
private var normalWidth:Number;
private var normalX:Number;
private var normalY:Number;
private var savedWindowRect:Rectangle;
private var _maximizable:Boolean=true;
private var _minimizable:Boolean=true;
private var _resizable:Boolean=true;
private var _closable:Boolean=true;
private var _dragable:Boolean=true;
public function get dragable():Boolean
{
return _dragable;
}
public function set dragable(value:Boolean):void
{
_dragable = value;
}
public function get closable():Boolean
{
return _closable;
}
public function set closable(value:Boolean):void
{
_closable = value;
}
public function get resizable():Boolean
{
return _resizable;
}
public function set resizable(value:Boolean):void
{
_resizable = value;
}
public function get minimizable():Boolean
{
return _minimizable;
}
public function set minimizable(value:Boolean):void
{
_minimizable = value;
}
public function get maximizable():Boolean
{
return _maximizable;
}
public function set maximizable(value:Boolean):void
{
_maximizable = value;
}
public function get hasFocus():Boolean
{
return _hasFocus;
}
public function set hasFocus(value:Boolean):void
{
if (_hasFocus == value)
{
return;
}
_hasFocus=value;
focusHandle();
}
private function focusHandle():void
{
if (hasFocus == true)
{
this.alpha=1;
IVisualElementContainer(parent).setElementIndex(th is, this.parent.numChildren - 1);
dispatchEvent(new FxWindowEvent(FxWindowEvent.FOCUS_START));
}
else
{
this.alpha=0.6;
dispatchEvent(new FxWindowEvent(FxWindowEvent.FOCUS_END));
}
}
/**
* 按住窗口标题开始移动时调用
*/
private function dragStart(event:MouseEvent):void
{
if (windowState == FxWindowState.NORMAL)
{
this.startDrag(false, new Rectangle(0, 0, parent.width - this.width, parent.height - this.height));
}
systemManager.addEventListener(MouseEvent.MOUSE_UP , dragStop);
systemManager.stage.addEventListener(Event.MOUSE_L EAVE, dragStop);
}
/**
* 按住窗口标题停止移动时调用
*/
private function dragStop(event:Event):void
{
this.stopDrag();
systemManager.removeEventListener(MouseEvent.MOUSE _UP, dragStop);
systemManager.stage.removeEventListener(Event.MOUS E_LEAVE, dragStop);
}
/**
* 派发最小化事件
*/
private function minimize(event:MouseEvent):void
{
dispatchEvent(new FxWindowEvent(FxWindowEvent.MINIMIZE));
}
/**
* 窗口向下还原时调用
*/
private function restore():void
{
if (windowState == FxWindowState.MAXIMIZED)
{
this.x=this.normalX;
this.y=this.normalY;
this.width=this.normalWidth;
this.height=this.normalHeight;
windowState=FxWindowState.NORMAL;
restoreButton.visible=false;
restoreButton.enabled=false;
maximizeButton.visible=true;
maximizeButton.enabled=true;
dispatchEvent(new FxWindowEvent(FxWindowEvent.RESTORE));
}
}
/**
* 窗口最大化时调用
*/
private function maximize():void
{
if (windowState == FxWindowState.NORMAL)
{
normalX=this.x;
normalY=this.y;
normalHeight=this.height;
normalWidth=this.width;
this.x=0;
this.y=0;
this.percentHeight=100;
this.percentWidth=100;
windowState=FxWindowState.MAXIMIZED;
maximizeButton.visible=false;
maximizeButton.enabled=false;
restoreButton.visible=true;
restoreButton.enabled=true;
dispatchEvent(new FxWindowEvent(FxWindowEvent.MAXIMIZE));
}
}
/**
* 派发关闭事件
*/
private function close(event:MouseEvent):void
{
dispatchEvent(new FxWindowEvent(FxWindowEvent.CLOSE));
}
/**
* 在窗口标题双击时调用
*/
private function titleDoubleClick(event:MouseEvent):void
{
if (windowState == FxWindowState.NORMAL)
{
maximize();
}
else
{
restore();
}
}
/**
* 窗口尺寸改变时调用
*/
private function resize(event:Event):void
{
dragAmountX=parent.mouseX - dragStartMouseX;
dragAmountY=parent.mouseY - dragStartMouseY;
if (currentResizeHandle == topResizeButton && parent.mouseY > 0)
{
this.y=Math.min(savedWindowRect.y + dragAmountY, dragMaxY);
this.height=Math.max(savedWindowRect.height - dragAmountY, this.skin.minHeight);
}
else if (currentResizeHandle == rightResizeButton)
{
this.width=Math.max(savedWindowRect.width + dragAmountX, this.skin.minWidth);
}
else if (currentResizeHandle == bottomResizeButton && parent.mouseY 0)
{
this.x=Math.min(savedWindowRect.x + dragAmountX, dragMaxX);
this.width=Math.max(savedWindowRect.width - dragAmountX, this.skin.minWidth);
}
else if (currentResizeHandle == topLeftResizeButton && parent.mouseX > 0 && parent.mouseY > 0)
{
this.x=Math.min(savedWindowRect.x + dragAmountX, dragMaxX);
this.y=Math.min(savedWindowRect.y + dragAmountY, dragMaxY);
this.width=Math.max(savedWindowRect.width - dragAmountX, this.skin.minWidth);
this.height=Math.max(savedWindowRect.height - dragAmountY, this.skin.minHeight);
}
else if (currentResizeHandle == topRightResizeButton && parent.mouseX 0)
{
this.y=Math.min(savedWindowRect.y + dragAmountY, dragMaxY);
this.width=Math.max(savedWindowRect.width + dragAmountX, this.skin.minWidth);
this.height=Math.max(savedWindowRect.height - dragAmountY, this.skin.minHeight);
}
else if (currentResizeHandle == bottomRightResizeButton && parent.mouseX 0 && parent.mouseY 加载皮肤
*/
override protected function partAdded(partName:String, instance:Object):void
{
super.partAdded(partName, instance);
if (instance == titleDisplay)
{
if(dragable)
{
titleDisplay.addEventListener(MouseEvent.MOUSE_DOW N, dragStart);
titleDisplay.addEventListener(MouseEvent.MOUSE_UP, dragStop);
}
if(maximizable)
{
titleDisplay.addEventListener(MouseEvent.DOUBLE_CL ICK, titleDoubleClick);
}
}
if (instance == closeButton)
{
if(closable)
{
closeButton.addEventListener(MouseEvent.CLICK, close);
}
else
{
closeButton.visible=false;
closeButton.enabled=false;
}
}
if (instance == maximizeButton)
{
if(maximizable)
{
maximizeButton.addEventListener(MouseEvent.CLICK, titleDoubleClick);
}
else
{
maximizeButton.visible=false;
maximizeButton.enabled=false;
}
}
if (instance == restoreButton)
{
restoreButton.visible=false;
restoreButton.enabled=false;
if(maximizable)
{
restoreButton.addEventListener(MouseEvent.CLICK, titleDoubleClick);
}
}
if (instance == minimizeButton)
{
if(minimizable)
{
minimizeButton.addEventListener(MouseEvent.CLICK, minimize);
}
else
{
minimizeButton.visible=false;
minimizeButton.enabled=false;
}
}
if (instance == topResizeButton)
{
if(resizable)
{
topResizeButton.addEventListener(MouseEvent.ROLL_O VER, resizeButtonRollOver);
topResizeButton.addEventListener(MouseEvent.MOUSE_ DOWN, resizeButtonDown);
topResizeButton.addEventListener(MouseEvent.ROLL_O UT, resizeButtonRollOut);
}
else
{
topResizeButton.visible=false;
topResizeButton.enabled=false;
}
}
if (instance == bottomResizeButton)
{
if(resizable)
{
bottomResizeButton.addEventListener(MouseEvent.ROL L_OVER, resizeButtonRollOver)
bottomResizeButton.addEventListener(MouseEvent.MOU SE_DOWN, resizeButtonDown)
bottomResizeButton.addEventListener(MouseEvent.ROL L_OUT, resizeButtonRollOut)
}
else
{
bottomResizeButton.visible=false;
bottomResizeButton.enabled=false;
}
}
if (instance == leftResizeButton)
{
if(resizable)
{
leftResizeButton.addEventListener(MouseEvent.ROLL_ OVER, resizeButtonRollOver);
leftResizeButton.addEventListener(MouseEvent.MOUSE _DOWN, resizeButtonDown);
leftResizeButton.addEventListener(MouseEvent.ROLL_ OUT, resizeButtonRollOut);
}
else
{
leftResizeButton.visible=false;
leftResizeButton.enabled=false;
}
}
if (instance == rightResizeButton)
{
if(resizable)
{
rightResizeButton.addEventListener(MouseEvent.ROLL _OVER, resizeButtonRollOver)
rightResizeButton.addEventListener(MouseEvent.MOUS E_DOWN, resizeButtonDown)
rightResizeButton.addEventListener(MouseEvent.ROLL _OUT, resizeButtonRollOut)
}
else
{
rightResizeButton.visible=false;
rightResizeButton.enabled=false;
}
}
if (instance == topLeftResizeButton)
{
if(resizable)
{
topLeftResizeButton.addEventListener(MouseEvent.RO LL_OVER, resizeButtonRollOver)
topLeftResizeButton.addEventListener(MouseEvent.MO USE_DOWN, resizeButtonDown)
topLeftResizeButton.addEventListener(MouseEvent.RO LL_OUT, resizeButtonRollOut)
}
else
{
topLeftResizeButton.visible=false;
topLeftResizeButton.enabled=false;
}
}
if (instance == topRightResizeButton)
{
if(resizable)
{
topRightResizeButton.addEventListener(MouseEvent.R OLL_OVER, resizeButtonRollOver);
topRightResizeButton.addEventListener(MouseEvent.M OUSE_DOWN, resizeButtonDown);
topRightResizeButton.addEventListener(MouseEvent.R OLL_OUT, resizeButtonRollOut);
}
else
{
topRightResizeButton.visible=false;
topRightResizeButton.enabled=false;
}
}
if (instance == bottomLeftResizeButton)
{
if(resizable)
{
bottomLeftResizeButton.addEventListener(MouseEvent .ROLL_OVER, resizeButtonRollOver);
bottomLeftResizeButton.addEventListener(MouseEvent .MOUSE_DOWN, resizeButtonDown);
bottomLeftResizeButton.addEventListener(MouseEvent .ROLL_OUT, resizeButtonRollOut);
}
else
{
bottomLeftResizeButton.visible=false;
bottomLeftResizeButton.enabled=false;
}
}
if (instance == bottomRightResizeButton)
{
if(resizable)
{
bottomRightResizeButton.addEventListener(MouseEven t.ROLL_OVER, resizeButtonRollOver);
bottomRightResizeButton.addEventListener(MouseEven t.MOUSE_DOWN, resizeButtonDown);
bottomRightResizeButton.addEventListener(MouseEven t.ROLL_OUT, resizeButtonRollOut);
}
else
{
bottomRightResizeButton.visible=false;
bottomRightResizeButton.enabled=false;
}
}
}
/**
* 窗口销毁时调用该函数卸载皮肤
*/
override protected function partRemoved(partName:String, instance:Object):void
{
super.partRemoved(partName, instance);
if (instance == titleDisplay)
{
titleDisplay.removeEventListener(MouseEvent.MOUSE_ DOWN, dragStart);
titleDisplay.removeEventListener(MouseEvent.MOUSE_ UP, dragStop);
titleDisplay.removeEventListener(MouseEvent.DOUBLE _CLICK, titleDoubleClick)
}
if (instance == closeButton)
{
closeButton.removeEventListener(MouseEvent.CLICK, close);
}
if (instance == restoreButton)
{
restoreButton.removeEventListener(MouseEvent.CLICK , maximize);
}
if (instance == maximizeButton)
{
maximizeButton.removeEventListener(MouseEvent.CLIC K, titleDoubleClick);
}
if (instance == minimizeButton)
{
minimizeButton.removeEventListener(MouseEvent.CLIC K, minimize);
}
if (instance == topResizeButton)
{
topResizeButton.removeEventListener(MouseEvent.ROL L_OVER, resizeButtonRollOver)
topResizeButton.removeEventListener(MouseEvent.MOU SE_DOWN, resizeButtonDown)
topResizeButton.removeEventListener(MouseEvent.ROL L_OUT, resizeButtonRollOut)
}
if (instance == bottomResizeButton)
{
bottomResizeButton.removeEventListener(MouseEvent. ROLL_OVER, resizeButtonRollOver)
bottomResizeButton.removeEventListener(MouseEvent. MOUSE_DOWN, resizeButtonDown)
bottomResizeButton.removeEventListener(MouseEvent. ROLL_OUT, resizeButtonRollOut)
}
if (instance == leftResizeButton)
{
leftResizeButton.removeEventListener(MouseEvent.RO LL_OVER, resizeButtonRollOver)
leftResizeButton.removeEventListener(MouseEvent.MO USE_DOWN, resizeButtonDown)
leftResizeButton.removeEventListener(MouseEvent.RO LL_OUT, resizeButtonRollOut)
}
if (instance == rightResizeButton)
{
rightResizeButton.removeEventListener(MouseEvent.R OLL_OVER, resizeButtonRollOver)
rightResizeButton.removeEventListener(MouseEvent.M OUSE_DOWN, resizeButtonDown)
rightResizeButton.removeEventListener(MouseEvent.R OLL_OUT, resizeButtonRollOut)
}
if (instance == topLeftResizeButton)
{
topLeftResizeButton.removeEventListener(MouseEvent .ROLL_OVER, resizeButtonRollOver)
topLeftResizeButton.removeEventListener(MouseEvent .MOUSE_DOWN, resizeButtonDown)
topLeftResizeButton.removeEventListener(MouseEvent .ROLL_OUT, resizeButtonRollOut)
}
if (instance == topRightResizeButton)
{
topRightResizeButton.removeEventListener(MouseEven t.ROLL_OVER, resizeButtonRollOver)
topRightResizeButton.removeEventListener(MouseEven t.MOUSE_DOWN, resizeButtonDown)
topRightResizeButton.removeEventListener(MouseEven t.ROLL_OUT, resizeButtonRollOut)
}
if (instance == bottomLeftResizeButton)
{
bottomLeftResizeButton.removeEventListener(MouseEv ent.ROLL_OVER, resizeButtonRollOver)
bottomLeftResizeButton.removeEventListener(MouseEv ent.MOUSE_DOWN, resizeButtonDown)
bottomLeftResizeButton.removeEventListener(MouseEv ent.ROLL_OUT, resizeButtonRollOut)
}
if (instance == bottomRightResizeButton)
{
bottomRightResizeButton.removeEventListener(MouseE vent.ROLL_OVER, resizeButtonRollOver)
bottomRightResizeButton.removeEventListener(MouseE vent.MOUSE_DOWN, resizeButtonDown)
bottomRightResizeButton.removeEventListener(MouseE vent.ROLL_OUT, resizeButtonRollOut)
}
}
private function get windowState():int
{
return _windowState;
}
private function set windowState(windowState:int):void
{
_windowState=windowState;
}
}
}
发表评论
-
分割字符串:strtok()函数
2012-07-06 09:51 718函数strtok将字符串分解为一系列标记(token)标记 ... -
正则表达式限制文本框只能输入数字,小数点,英文字母,汉字
2012-07-06 09:45 805正则表达式限制文本框只能输入数字,小数点,英文字母,汉 ... -
[转载]VI正则表达式
2012-07-06 09:37 620原文地址:http://wowtianwen.blog.h ... -
Windows Mobile Device Emulator In-Depth
2012-07-06 09:30 743模拟器在Windows Mobil ... -
Gridview中当鼠标经过数据行时弹出一个层显示数据
2012-07-05 20:45 726JS代码 页面源码 ... -
WinCE下使用Media Play 组件中使用
2012-07-03 13:43 676由于最近做的 ... -
Flex4与WebService通信
2012-07-02 10:41 559首先需要一个需要提供一个WebService服务。这里用一 ... -
flex 幸运大转盘 代码
2012-07-02 10:41 721>"+testT.originY) ... -
Flex连接WebService实例
2012-07-02 10:41 494- ... -
Flex 4 Canvas backgroundImage 问题
2012-07-02 10:41 416倾听,慎言,勇行,自省... ... -
DAMP环境搭建详解 DAMP----Debian Apache2 Mysql PHP5
2012-07-01 00:18 788DAMP环境搭建详解 DAMP----Debian ... -
主流地图API比较
2012-07-01 00:18 648最近因为工作关系,对市面上主流的地图API都进行了一遍了解 ... -
Android HAL 介绍
2012-07-01 00:17 732HAL 介绍 Android 的 HAL (硬件抽像层 ... -
纪念Rokon停止更新――从零开始用Rokon开发一个小游戏
2012-07-01 00:17 571懒骨头你给我听着:你有健康的家人~满意的工作~未知的女友~ ...
相关推荐
用skin++3.0控制的超级精美界面皮肤用skin++3.0控制的超级精美界面皮肤用skin++3.0控制的超级精美界面皮肤
Windows系统下超级控制面板开启工具 附超级用户权限取得方法
微软在Windows7系统中隐藏了某些功能,建立一个超级控制面板就可以查看到控制面板和系统设置的所有功能。
西门子操作面板AOP30使用说明zip,西门子操作面板AOP30使用说明
超级面板1.0.zip
中文书籍,详细介绍了面板数据模型及其在经济分析中的应用
面板列表 Beauty Retouch ·Beauty Retouching Kit ·Colors of the Year ·Coolorus 2.5.7.449 ·Delicious Retouch Plus ·Easy Panel ·Easy Retouch ·fonTags 1.3 ·GuideGuide ·ILM 2.1 ·InstaMask 1.0 ·...
行业资料-电子功用-用于太阳能发电面板的角位置调整装置及其使用方法
行业分类-设备装置-可检测触控笔的触控面板及其使用方法.zip
我们从Wind以及EPS等数据库下载的数据很多都是短面板数据,但是stata实证却要求使用长面板数据,这时候就需要面板数据转化,把短面板数据转化为我们需要的长面板数据,excel的数据透视虽然可以实现类似的操作,但是...
电信设备-触控面板结构、触控显示面板结构及其通讯装置.zip
超级实用的双面板布线技巧,双面板布线技巧
行业资料-交通装置-一种汽车中控面板套色装置及其使用方法.zip
超级面板1.0由以下3种面板合体制作而成(又名 UR3极限修图3.0): Ultimate Retouch终极修饰面板 Delicious Retouch人像美容磨皮 ILM一键动态亮度调整蒙版 不知道是哪位大神做出来的,把我们熟知的DR3/UR3/ILM亮度...
labview2个子面板切换使用
premiere pro—03.软件各个控制面板及其功能
SINAMICS V90驱动器的BOP面板使用说明书 BOP操作面板 使用手册
单面板设计单面板设计单面板设计单面板设计单面板设计单面板设计单面板设计单面板设计单面板设计单面板设计
介绍面板数据的聚类分析,如何实现,及其原理。