ResizableWindow source code

xiaoxiao2021-03-06  66

// ******************************************************** *****************************

// copyright and final interpretation right belongs to AOL

// Size can be dragged by the mouse by the WINDOW component

// Inherit by Mx.Containers.Window class

// ******************************************************** *****************************

Import mx.containers.window;

Import mx.controls.simplebutton;

Import mx.events.eventdispatcher;

[IConfile ("ResizableWindowicon.png")]]]

Class ResizableWindow Extends WINDOW

{

Static var symbolname: String = "resizablewindow";

Static var symbold (object = Object (resizablewindow);

Static var Version: String = "0.01";

// private var _maxwidth: Number;

// private var _maxheight: Number;

// private var _minwidth: Number;

// private var _minHeight: Number;

// private var _rangewidth: Number;

// private var _rangeheight: Number;

/ * Current class parameters

* And current class parent class parameter combination

* /

Var clipparameters: object = {// maxWidth: 1, MaxHeight: 1, MinWidth: 1, MinHeight: 1

}

Static var mergeclipparameters: boolean = uiObject.mergeclipparameters

mx.containers.window.prototype.clipparameters,

ResizableWindow.Prototype.clipparameters;

/ *

* Drag button

* /

Private var handle: SimpleButton;

/ *

* Mouse original position

* /

Private var _oldx: Number;

Private var _oldy: Number;

/ *

* The skin of the controllable size window button

* /

[Inspectable (verbose = 1, category = "skins")]]

Var SkinResize: string = "resizebutton";

// *

// * The maximum width of the controllable size window

// * /

// [INSPECTABLE (Name = "ResizableWindow Maximal Width" DefaultValue = 550 TYPE = "Number", category = "VALUES")]

// public function set maxwidth (val: number): Void

// {

//_maxwidth = val;

/ / _RANGEWIDTH = _MaxWidth - _MINWIDTH;

//}

// public function get maxwidth (): Number

// {

// return_maxwidth; //}

// *

// * Minimum width of the controllable size window

// * /

// [INSPECTABLE (Name = "ResizableWindow Minimum Width" DefaultValue = 20 TYPE = "Number", category = "VALUES")]

// public function set minWidth (VAL: Number): Void

// {

// _MINWIDTH = VAL;

/ / _RANGEWIDTH = _MaxWidth - _MINWIDTH;

//}

// public function get minWidth (): Number

// {

// Return_MINWIDTH;

//}

// *

// * Maximum height of the controllable size window

// * /

// [INSPECTABLE (Name = "ResizableWindow Maximal Height" defaultValue = 400 type = "number", category = "values")]

// public function set maxheight (val: number): Void

// {

//_maxheight = VAL;

/ / _RANGEHEIGHT = _MAXHEIGHT - _MINHEIGHT;

//}

// public function get maxheight (): NUMBER

// {

// Return_Maxheight;

//}

// *

// * Minimum height of the controllable size window

// * /

// [INSPECTABLE (Name = "ResizableWindow Minimum Height" DefaultValue = 40 TYPE = "Number", category = "VALUES")]

// public function set minheight (val: number): void

// {

//_Minheight = VAL;

/ / _RANGEHEIGHT = _MAXHEIGHT - _MINHEIGHT;

//}

// public function get minHeight (): Number

// {

// Return_Minheight;

//}

/ *

* Constructor

* /

Function mycomponent ()

{

}

/ * Method

* Initialization module

* /

Function init (void): void

{

Super.init ();

}

/ * Method

* Change the component size

* /

Function size (void): Void

{

Super.size ();

// Handle.setsize ();

}

/ *

* Establish a child

* ResizableWindow components have a child to build

* That is a button that makes Window can change

* /

Private function createchildren (void): VoID

{

Super.createChildren ();

Var resizeObj: Object = new object ();

ResizeObj.falseupskin = skinResize;

ResizeObj.falseoverskin = SkinResize;

ResizeObj.falsedownskin = SkinResize; Handle = CreateClassObject (SimpleButton, "Handle", 100, ResizeObj);

Handle.tabenabled = false;

Handle.onpress = startresize;

Handle.onRelease = STOPRESIZE

Handle.onReleaseoutside = stopRESize;

}

/ *

* Layout

* Arrange the location of the controllable window size button

* /

Private function DOLYOUT (VOID): Void

{

Super.dolayout ();

Handle.move (width-handle.width; Height-handle.height);

}

/ *

* Event processing method

* When the button is pressed, the size of the window begins to change

* /

Private function startResize (void): Void

{

// trace ("start");

THIS. ISEHANDCURSOR = True;

THIS._PARENT._OLDX = this._parent._xmouse;

THIS._PARENT._OLDY = this._parent._ymouse;

THIS._PARENT.ONMOUSEMOVE = this._parent.resize;

}

/ *

* Event processing method

* When the button is dragged, the size of the window changes

* /

Private function resize (void): Void

{

// trace ("resize);

VAR DX = _xmouse - _OLDX;

VAR DY = _YMOUSE - _OLDY;

IF ((Width> minwidth && height> minheight) || (DX> 0 && Dy> 0)))

Setsize (Width DX, Height DY);

_OLDX = _xmouse;

_OLDY = _YMOUSE;

}

/ *

* Event processing method

* When the button is released, the size of the window is stopped

* /

Private function stopresize (void): Void

{

THIS. ISEHANDCURSOR = FALSE;

Delete this._parent.onmousemove;

THIS._PARENT.RELESEFOCUS ();

}

}

转载请注明原文地址:https://www.9cbs.com/read-119876.html

New Post(0)