home *** CD-ROM | disk | FTP | other *** search
- package com.livebrush.ui
- {
- import com.livebrush.events.ConsolEvent;
- import flash.display.Sprite;
- import flash.events.EventPhase;
- import flash.events.MouseEvent;
-
- public class Panel extends Sprite
- {
- private var _bg:Sprite;
-
- private var _isRemovable:Boolean = true;
-
- public var _label:String = "Panel";
-
- private var _titlebar:PanelTitleBar;
-
- public var helpID:String;
-
- public var isDragable:Boolean = true;
-
- public function Panel()
- {
- super();
- }
-
- private function titlebarDownListener(e:MouseEvent) : void
- {
- if(this.isDragable)
- {
- startDrag();
- }
- }
-
- public function set isRemovable(b:Boolean) : void
- {
- this._isRemovable = this._titlebar.showClose = b;
- }
-
- public function close() : void
- {
- parent.removeChild(this);
- }
-
- private function closeBtnListener(e:MouseEvent) : void
- {
- if(e.eventPhase == EventPhase.AT_TARGET)
- {
- if(this._isRemovable)
- {
- this.close();
- }
- }
- }
-
- public function set label(l:String) : void
- {
- this._titlebar.label.text = this._label = l.toUpperCase();
- }
-
- public function outputToConsol(output:String) : void
- {
- dispatchEvent(new ConsolEvent(ConsolEvent.OUTPUT,true,false,output));
- }
-
- private function helpBtnListener(e:MouseEvent) : void
- {
- if(e.eventPhase == EventPhase.AT_TARGET)
- {
- this.getHelp({
- "context":this.label,
- "id":this.helpID
- });
- }
- }
-
- public function getHelp(o:Object) : void
- {
- }
-
- private function titlebarUpListener(e:MouseEvent) : void
- {
- if(this.isDragable)
- {
- stopDrag();
- }
- }
-
- public function get label() : String
- {
- return this._label;
- }
-
- internal function setup() : void
- {
- this._bg = Sprite(getChildByName("bg"));
- this._titlebar = PanelTitleBar(getChildByName("titlebar"));
- this._titlebar.setWidth(this._bg.width);
- this._titlebar.closeBtn.addEventListener(MouseEvent.CLICK,this.closeBtnListener);
- this._titlebar.helpBtn.addEventListener(MouseEvent.CLICK,this.helpBtnListener);
- this._titlebar.bg.addEventListener(MouseEvent.MOUSE_DOWN,this.titlebarDownListener);
- this._titlebar.bg.addEventListener(MouseEvent.MOUSE_UP,this.titlebarUpListener);
- }
- }
- }
-
-