You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by pe...@apache.org on 2013/05/23 20:08:26 UTC
git commit: [flex-asjs] [refs/heads/develop] - Revised Panel and
TitleBar. TitleBar now extends Container and has a Label and Button for
children. Panel also extends Container and uses PanelBead to manage the
TitleBar.
Updated Branches:
refs/heads/develop 14e39059a -> c15c55ef8
Revised Panel and TitleBar. TitleBar now extends Container and has a Label and Button for children. Panel also extends Container and uses PanelBead to manage the TitleBar.
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/c15c55ef
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/c15c55ef
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/c15c55ef
Branch: refs/heads/develop
Commit: c15c55ef81d6d6b1eabb46379e4aff9c624dff2d
Parents: 14e3905
Author: Peter Ent <pe...@apache.org>
Authored: Thu May 23 14:08:16 2013 -0400
Committer: Peter Ent <pe...@apache.org>
Committed: Thu May 23 14:08:16 2013 -0400
----------------------------------------------------------------------
examples/StockQuote/src/MyInitialView.mxml | 17 +-
frameworks/as/basic-manifest.xml | 2 +
frameworks/as/defaults.css | 8 +-
frameworks/as/src/FlexJSUIClasses.as | 2 +
.../as/src/org/apache/flex/core/IPanelModel.as | 32 +++
.../as/src/org/apache/flex/core/ITitleBarBead.as | 4 +-
.../org/apache/flex/html/staticControls/Panel.as | 117 ++++++++
.../apache/flex/html/staticControls/TitleBar.as | 119 +++++++--
.../flex/html/staticControls/beads/IPanelBead.as | 27 ++
.../flex/html/staticControls/beads/PanelBead.as | 101 +-------
.../flex/html/staticControls/beads/TitleBarBead.as | 216 ---------------
.../html/staticControls/beads/models/PanelModel.as | 82 ++++++
.../staticControls/beads/models/TitleBarModel.as | 2 +-
13 files changed, 388 insertions(+), 341 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c15c55ef/examples/StockQuote/src/MyInitialView.mxml
----------------------------------------------------------------------
diff --git a/examples/StockQuote/src/MyInitialView.mxml b/examples/StockQuote/src/MyInitialView.mxml
index 09d9272..40ebc93 100644
--- a/examples/StockQuote/src/MyInitialView.mxml
+++ b/examples/StockQuote/src/MyInitialView.mxml
@@ -99,15 +99,9 @@ limitations under the License.
<basic:beads>
<basic:NonVirtualHorizontalLayout />
</basic:beads>
- <basic:Container className="leftSide">
+ <basic:Panel title="Left Side" className="leftSide">
<basic:beads>
<basic:NonVirtualVerticalLayout />
- <basic:PanelBead title="Left Side">
- <basic:controlBar>
- <basic:TextButton text="Get Quote" className="quoteButton"
- click="_symbol = symbolTI.text; dispatchEvent(new CustomEvent('buttonClicked'))" />
- </basic:controlBar>
- </basic:PanelBead>
</basic:beads>
<basic:TextInput id="symbolTI" >
<basic:beads>
@@ -126,11 +120,12 @@ limitations under the License.
destinationPropertyName="text" />
</basic:beads>
</basic:Label>
- </basic:Container>
- <basic:Container className="rightSide">
+ <basic:TextButton text="Get Quote" className="quoteButton"
+ click="_symbol = symbolTI.text; dispatchEvent(new CustomEvent('buttonClicked'))" />
+ </basic:Panel>
+ <basic:Panel title="Right Side" className="rightSide">
<basic:beads>
<basic:NonVirtualVerticalLayout />
- <basic:PanelBead title="Right Side" />
</basic:beads>
<basic:DropDownList id="list" width="100" height="17"
change="_symbol = list.selectedItem as String; dispatchEvent(new CustomEvent('listChanged'))">
@@ -146,7 +141,7 @@ limitations under the License.
<basic:RadioButton id="radio3" text="Day's High" value="DaysHigh" groupName="group1" change="radioChanged(event)"/>
<basic:RadioButton id="radio4" text="Day's Low" value="DaysLow" groupName="group1" change="radioChanged(event)"/>
<basic:CheckBox id="showAllData" text="Show All Data" />
- </basic:Container>
+ </basic:Panel>
</basic:Container>
<basic:TextArea id="ta" width="300" height="100">
<basic:beads>
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c15c55ef/frameworks/as/basic-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/as/basic-manifest.xml b/frameworks/as/basic-manifest.xml
index 50cdda6..764ecd8 100644
--- a/frameworks/as/basic-manifest.xml
+++ b/frameworks/as/basic-manifest.xml
@@ -45,8 +45,10 @@
<component id="ViewSourceContextMenuOption" class="org.apache.flex.utils.ViewSourceContextMenuOption"/>
<component id="BinaryUploader" class="org.apache.flex.net.BinaryUploader"/>
<component id="Container" class="org.apache.flex.html.staticControls.Container"/>
+ <component id="Panel" class="org.apache.flex.html.staticControls.Panel"/>
<component id="ControlBar" class="org.apache.flex.html.staticControls.ControlBar"/>
<component id="TitleBar" class="org.apache.flex.html.staticControls.TitleBar"/>
+ <component id="TitleBarModel" class="org.apache.flex.html.staticControls.beads.models.TitleBarModel"/>
<component id="NonVirtualVerticalLayout" class="org.apache.flex.html.staticControls.beads.layouts.NonVirtualVerticalLayout"/>
<component id="NonVirtualHorizontalLayout" class="org.apache.flex.html.staticControls.beads.layouts.NonVirtualHorizontalLayout"/>
<component id="PanelBead" class="org.apache.flex.html.staticControls.beads.PanelBead"/>
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c15c55ef/frameworks/as/defaults.css
----------------------------------------------------------------------
diff --git a/frameworks/as/defaults.css b/frameworks/as/defaults.css
index f0201be..ea7974b 100644
--- a/frameworks/as/defaults.css
+++ b/frameworks/as/defaults.css
@@ -121,8 +121,14 @@ TextInput
TitleBar
{
- ITitleBarBead: ClassReference("org.apache.flex.html.staticControls.beads.TitleBarBead");
ITitleBarModel: ClassReference("org.apache.flex.html.staticControls.beads.models.TitleBarModel");
+ ILayoutBead: ClassReference("org.apache.flex.html.staticControls.beads.layouts.NonVirtualHorizontalLayout");
+}
+
+Panel
+{
+ IPanelModel: ClassReference("org.apache.flex.html.staticControls.beads.models.PanelModel");
+ IPanelBead: ClassReference("org.apache.flex.html.staticControls.beads.PanelBead");
}
/* HTML5 */
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c15c55ef/frameworks/as/src/FlexJSUIClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/FlexJSUIClasses.as b/frameworks/as/src/FlexJSUIClasses.as
index c68fa15..d1d5400 100644
--- a/frameworks/as/src/FlexJSUIClasses.as
+++ b/frameworks/as/src/FlexJSUIClasses.as
@@ -39,12 +39,14 @@ internal class FlexJSUIClasses
import org.apache.flex.html.staticControls.beads.ComboBoxBead; ComboBoxBead;
import org.apache.flex.html.staticControls.beads.ContainerBead; ContainerBead;
import org.apache.flex.html.staticControls.beads.TitleBarBead; TitleBarBead;
+ import org.apache.flex.html.staticControls.beads.PanelBead; PanelBead;
import org.apache.flex.html.staticControls.beads.models.TextModel; TextModel;
import org.apache.flex.html.staticControls.beads.models.ComboBoxModel; ComboBoxModel;
import org.apache.flex.html.staticControls.beads.models.ToggleButtonModel; ToggleButtonModel;
import org.apache.flex.html.staticControls.beads.models.ValueToggleButtonModel; ValueToggleButtonModel;
import org.apache.flex.html.staticControls.beads.models.ArraySelectionModel; ArraySelectionModel;
import org.apache.flex.html.staticControls.beads.models.TitleBarModel; TitleBarModel;
+ import org.apache.flex.html.staticControls.beads.models.PanelModel; PanelModel;
import org.apache.flex.events.CustomEvent; CustomEvent;
import org.apache.flex.events.Event; Event;
import org.apache.flex.utils.Timer; Timer;
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c15c55ef/frameworks/as/src/org/apache/flex/core/IPanelModel.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/core/IPanelModel.as b/frameworks/as/src/org/apache/flex/core/IPanelModel.as
new file mode 100644
index 0000000..5abbe6d
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/core/IPanelModel.as
@@ -0,0 +1,32 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.core
+{
+ public interface IPanelModel extends IBeadModel
+ {
+ function get title():String;
+ function set title(value:String):void;
+
+ function get htmlTitle():String;
+ function set htmlTitle(value:String):void;
+
+ function get showCloseButton():Boolean;
+ function set showCloseButton(value:Boolean):void;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c15c55ef/frameworks/as/src/org/apache/flex/core/ITitleBarBead.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/core/ITitleBarBead.as b/frameworks/as/src/org/apache/flex/core/ITitleBarBead.as
index bae3b98..67d6af4 100644
--- a/frameworks/as/src/org/apache/flex/core/ITitleBarBead.as
+++ b/frameworks/as/src/org/apache/flex/core/ITitleBarBead.as
@@ -18,7 +18,9 @@
////////////////////////////////////////////////////////////////////////////////
package org.apache.flex.core
{
- public interface ITitleBarBead extends IBead
+ import org.apache.flex.html.staticControls.beads.IContainerBead;
+
+ public interface ITitleBarBead extends IContainerBead
{
function get text():String;
function set text(value:String):void;
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c15c55ef/frameworks/as/src/org/apache/flex/html/staticControls/Panel.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/Panel.as b/frameworks/as/src/org/apache/flex/html/staticControls/Panel.as
new file mode 100644
index 0000000..d1c8ac6
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/Panel.as
@@ -0,0 +1,117 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.html.staticControls
+{
+ import org.apache.flex.core.IBead;
+ import org.apache.flex.core.IPanelModel;
+ import org.apache.flex.core.ValuesManager;
+ import org.apache.flex.events.Event;
+ import org.apache.flex.html.staticControls.beads.IPanelBead;
+ import org.apache.flex.html.staticControls.beads.PanelBead;
+
+ [Event(name="close", type="org.apache.flex.events.Event")]
+
+ public class Panel extends Container
+ {
+ public function Panel()
+ {
+ super();
+ }
+
+ public function get title():String
+ {
+ return IPanelModel(model).title;
+ }
+ public function set title(value:String):void
+ {
+ IPanelModel(model).title = value;
+ }
+
+ public function get htmlTitle():String
+ {
+ return IPanelModel(model).htmlTitle;
+ }
+ public function set htmlTitle(value:String):void
+ {
+ IPanelModel(model).htmlTitle = value;
+ }
+
+ public function get showCloseButton():Boolean
+ {
+ return IPanelModel(model).showCloseButton;
+ }
+ public function set showCloseButton(value:Boolean):void
+ {
+ IPanelModel(model).showCloseButton = value;
+ }
+
+ public function get titleBar():TitleBar
+ {
+ var bead:PanelBead = getBeadByType(PanelBead) as PanelBead;
+ if( bead != null ) return bead.titleBar;
+ return null;
+ }
+
+ private var _controlBar:Array;
+ public function get controlBar():Array
+ {
+ return _controlBar;
+ }
+ public function set controlBar(value:Array):void
+ {
+ _controlBar = value;
+ }
+
+ override public function initModel():void
+ {
+ super.initModel();
+
+ if (getBeadByType(IPanelModel) == null)
+ addBead(new (ValuesManager.valuesImpl.getValue(this, "iPanelModel")) as IBead);
+
+ model.addEventListener('titleChange',handlePropertyChange);
+ model.addEventListener('htmlTitleChange',handlePropertyChange);
+ model.addEventListener('showCloseButtonChange',handlePropertyChange);
+ }
+
+ private function handlePropertyChange(event:Event):void
+ {
+ if( event.type == "titleChange" && titleBar ) {
+ titleBar.title = title;
+ }
+ else if( event.type == "htmlTitleChange" && titleBar ) {
+ titleBar.htmlTitle = title;
+ }
+ else if( event.type == "showCloseButtonChange" && titleBar ) {
+ titleBar.showCloseButton = showCloseButton;
+ }
+ }
+
+ override public function initSkin():void
+ {
+ super.initSkin();
+
+ if( getBeadByType(IPanelBead) == null) {
+ addBead(new (ValuesManager.valuesImpl.getValue(this,"iPanelBead")) as IBead);
+ }
+ titleBar.title = this.title;
+ titleBar.showCloseButton = this.showCloseButton;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c15c55ef/frameworks/as/src/org/apache/flex/html/staticControls/TitleBar.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/TitleBar.as b/frameworks/as/src/org/apache/flex/html/staticControls/TitleBar.as
index c53ec2b..ee6e4db 100644
--- a/frameworks/as/src/org/apache/flex/html/staticControls/TitleBar.as
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/TitleBar.as
@@ -18,60 +18,145 @@
////////////////////////////////////////////////////////////////////////////////
package org.apache.flex.html.staticControls
{
- import flash.display.DisplayObject;
+ import flash.display.Shape;
import org.apache.flex.core.IBead;
import org.apache.flex.core.ITitleBarModel;
- import org.apache.flex.core.ITitleBarBead;
- import org.apache.flex.core.UIBase;
import org.apache.flex.core.ValuesManager;
import org.apache.flex.events.Event;
- import org.apache.flex.events.IEventDispatcher;
+ import org.apache.flex.html.staticControls.beads.layouts.NonVirtualHorizontalLayout;
- public class TitleBar extends UIBase
+ public class TitleBar extends Container
{
public function TitleBar()
{
super();
- this.addEventListener('widthChanged',handleSizeChange);
- this.addEventListener('heightChanged',handleSizeChange);
}
- public function get text():String
+ public function get title():String
{
return ITitleBarModel(model).title;
}
- public function set text(value:String):void
+ public function set title(value:String):void
{
ITitleBarModel(model).title = value;
}
- public function get html():String
+ public function get htmlTitle():String
{
return ITitleBarModel(model).htmlTitle;
}
- public function set html(value:String):void
+ public function set htmlTitle(value:String):void
{
ITitleBarModel(model).htmlTitle = value;
}
+ public function get showCloseButton():Boolean
+ {
+ return ITitleBarModel(model).showCloseButton;
+ }
+ public function set showCloseButton(value:Boolean):void
+ {
+ ITitleBarModel(model).showCloseButton = value;
+ }
+
override public function initModel():void
{
if (getBeadByType(ITitleBarModel) == null)
addBead(new (ValuesManager.valuesImpl.getValue(this, "iTitleBarModel")) as IBead);
+
+ model.addEventListener('titleChange',handlePropertyChange);
+ model.addEventListener('htmlTitleChange',handlePropertyChange);
+ model.addEventListener('showCloseButtonChange',handlePropertyChange);
+ }
+
+ private var titleLabel:Label;
+ private var closeButton:Button;
+
+ override public function initSkin():void
+ {
+ super.initSkin();
+
+ if( getBeadByType(NonVirtualHorizontalLayout) == null )
+ addBead(new (ValuesManager.valuesImpl.getValue(this, "iLayoutBead")) as IBead);
+
+ // add the label for the title and the button for the close
+ titleLabel = createTitle();
+ titleLabel.className = className;
+ titleLabel.addToParent(this);
+
+ closeButton = createCloseButton();
+ closeButton.className = className;
+ closeButton.addToParent(this);
+
+ childrenAdded();
}
- public function initSkin():void
+ private function handlePropertyChange(event:Event):void
{
- if (getBeadByType(ITitleBarBead) == null)
- addBead(new (ValuesManager.valuesImpl.getValue(this, "iTitleBarBead")) as IBead);
+ if( event.type == "showCloseButtonChange" ) {
+ if( closeButton ) closeButton.visible = showCloseButton;
+ }
+ else if( event.type == "titleChange" ) {
+ if( titleLabel ) titleLabel.text = title;
+ }
+ else if( event.type == "htmlTitleChange" ) {
+ if( titleLabel ) titleLabel.html = htmlTitle;
+ }
+
+ dispatchEvent(new Event("widthChanged"));
+ }
+
+ protected function createTitle() : Label
+ {
+ var label:Label = new Label();
+ label.initModel();
+ label.initSkin();
+ label.text = title;
+ return label;
+ }
+
+ protected function createCloseButton() : Button
+ {
+ var upState:Shape = new Shape();
+ upState.graphics.clear();
+ upState.graphics.beginFill(0xCCCCCC);
+ upState.graphics.drawRect(0,0,11,11);
+ upState.graphics.endFill();
+
+ var overState:Shape = new Shape();
+ overState.graphics.clear();
+ overState.graphics.beginFill(0x999999);
+ overState.graphics.drawRect(0,0,11,11);
+ overState.graphics.endFill();
+
+ var downState:Shape = new Shape();
+ downState.graphics.clear();
+ downState.graphics.beginFill(0x666666);
+ downState.graphics.drawRect(0, 0, 11, 11);
+ downState.graphics.endFill();
+
+ var hitArea:Shape = new Shape();
+ hitArea.graphics.clear();
+ hitArea.graphics.beginFill(0x000000);
+ hitArea.graphics.drawRect(0, 0, 11, 11);
+ hitArea.graphics.endFill();
+
+ var button:Button = new Button(upState, overState, downState, hitArea);
+ button.initModel();
+ button.initSkin();
+ button.visible = showCloseButton;
+
+ button.addEventListener('click',closeButtonHandler);
+
+ return button;
}
- private function handleSizeChange(event:Event):void
+ private function closeButtonHandler(event:org.apache.flex.events.Event) : void
{
- IEventDispatcher(getBeadByType(ITitleBarModel)).dispatchEvent(new Event("widthChanged"));
- IEventDispatcher(getBeadByType(ITitleBarModel)).dispatchEvent(new Event("heightChanged"));
+ var newEvent:Event = new Event('close',true);
+ dispatchEvent(newEvent);
}
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c15c55ef/frameworks/as/src/org/apache/flex/html/staticControls/beads/IPanelBead.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/IPanelBead.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/IPanelBead.as
new file mode 100644
index 0000000..38331ee
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/IPanelBead.as
@@ -0,0 +1,27 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.html.staticControls.beads
+{
+ import org.apache.flex.core.IBead;
+
+ public interface IPanelBead extends IBead
+ {
+
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c15c55ef/frameworks/as/src/org/apache/flex/html/staticControls/beads/PanelBead.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/PanelBead.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/PanelBead.as
index ff24958..8ffa633 100644
--- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/PanelBead.as
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/PanelBead.as
@@ -18,84 +18,42 @@
////////////////////////////////////////////////////////////////////////////////
package org.apache.flex.html.staticControls.beads
{
- import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
import flash.display.Shape;
- import flash.display.SimpleButton;
import flash.display.Sprite;
- import flash.text.TextField;
- import flash.text.TextFieldAutoSize;
- import flash.text.TextFieldType;
import org.apache.flex.core.IBead;
- import org.apache.flex.core.IContainer;
import org.apache.flex.core.IStrand;
- import org.apache.flex.core.UIBase;
import org.apache.flex.core.ValuesManager;
import org.apache.flex.events.Event;
import org.apache.flex.events.IEventDispatcher;
import org.apache.flex.html.staticControls.Container;
import org.apache.flex.html.staticControls.ControlBar;
import org.apache.flex.html.staticControls.TitleBar;
- import org.apache.flex.html.staticControls.beads.layouts.NonVirtualHorizontalLayout;
- import org.apache.flex.html.staticControls.beads.layouts.NonVirtualVerticalLayout;
- import org.apache.flex.utils.MXMLDataInterpreter;
public class PanelBead implements IBead, IContainerBead
{
public function PanelBead()
{
- titleBar = new TitleBar();
- titleBar.initModel();
- titleBar.initSkin();
- titleBar.text = "Panel";
+ _titleBar = new TitleBar();
+ _titleBar.initModel();
+ _titleBar.initSkin();
}
- public function get title() : String
+ private var _titleBar:TitleBar;
+ public function get titleBar():TitleBar
{
- return titleBar.text;
- }
- public function set title(value:String):void
- {
- titleBar.text = value;
- }
-
- public function get showCloseButton() : Boolean
- {
-// return titleBar.showCloseButton;
- return false;
- }
- public function set showCloseButton(value:Boolean):void
- {
-// titleBar.showCloseButton = value;
+ return _titleBar;
}
- private var _controlBar:Array;
- public function get controlBar():Array
- {
- return _controlBar;
- }
- public function set controlBar(value:Array):void
- {
- _controlBar = value;
- }
-
-
private var _strand:IStrand;
public function set strand(value:IStrand):void
{
_strand = value;
- createTitleArea();
+ Container(_strand).addChild(titleBar);
- if( controlBar ) {
- createControlBar();
- }
- else {
- controlBarArea = null;
- }
-
var borderStyle:String;
var borderStyles:Object = ValuesManager.valuesImpl.getValue(value, "border");
if (borderStyles is Array)
@@ -163,7 +121,6 @@ package org.apache.flex.html.staticControls.beads
IEventDispatcher(_strand).addEventListener("childrenAdded", changeHandler);
}
- private var titleBar:TitleBar;
private var contentArea:DisplayObjectContainer;
private var controlBarArea:ControlBar;
private var controlBarBackground:Shape;
@@ -176,59 +133,15 @@ package org.apache.flex.html.staticControls.beads
contentArea.y = titleBar.height;
contentArea.width = Container(_strand).width;
- if( controlBar ) {
- layoutControlBar();
- }
-
IEventDispatcher(_strand).dispatchEvent(new Event('widthChanged'));
IEventDispatcher(_strand).dispatchEvent(new Event('heightChanged'));
}
- protected function createTitleArea() : void
- {
- Container(_strand).addChild(titleBar);
- }
-
- protected function createControlBar() : void
- {
- controlBarArea = new ControlBar();
- controlBarArea.addBead(new NonVirtualHorizontalLayout());
- Container(_strand).addChild(controlBarArea);
- }
-
protected function layoutTitleArea() : void
{
titleBar.x = 0;
titleBar.y = 0;
titleBar.width = Container(_strand).width;
- titleBar.height = 25;
- }
-
- protected function layoutControlBar() : void
- {
- controlBarArea.x = 0;
- controlBarArea.width = Container(_strand).width;
- controlBarArea.height = 25;
-
- if( Container(_strand).height > (contentArea.y+contentArea.height+controlBarArea.height) ) {
- controlBarArea.y = Container(_strand).height - controlBarArea.height;
- } else {
- controlBarArea.y = contentArea.y + contentArea.height;
- }
-
- for(var i:int=0; i < controlBar.length; i++)
- {
- var displayObject:DisplayObject = controlBar[i] as DisplayObject;
- if( displayObject is UIBase ) {
- var b:UIBase = displayObject as UIBase;
- b.addToParent(controlBarArea);
- }
- else {
- controlBarArea.addChild( controlBar[i] as DisplayObject );
- }
- }
-
- controlBarArea.childrenAdded();
}
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c15c55ef/frameworks/as/src/org/apache/flex/html/staticControls/beads/TitleBarBead.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TitleBarBead.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/TitleBarBead.as
deleted file mode 100644
index 8a87560..0000000
--- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TitleBarBead.as
+++ /dev/null
@@ -1,216 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to You under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-package org.apache.flex.html.staticControls.beads
-{
- import flash.display.DisplayObject;
- import flash.display.DisplayObjectContainer;
- import flash.display.SimpleButton;
- import flash.display.Sprite;
- import flash.text.TextFieldAutoSize;
- import flash.text.TextFieldType;
-
- import org.apache.flex.core.CSSTextField;
- import org.apache.flex.core.IBead;
- import org.apache.flex.core.IInitSkin;
- import org.apache.flex.core.IStrand;
- import org.apache.flex.core.ITitleBarModel;
- import org.apache.flex.core.ITitleBarBead;
- import org.apache.flex.events.Event;
-
- public class TitleBarBead implements ITitleBarBead,IInitSkin, IStrand
- {
- public function TitleBarBead()
- {
- _titleField = new CSSTextField();
- _titleField.type = TextFieldType.DYNAMIC;
- _titleField.autoSize = TextFieldAutoSize.LEFT;
-
- _closeButton = new SimpleButton();
- _closeButton.mouseEnabled = true;
- _closeButton.useHandCursor = true;
-
- var upState:Sprite = new Sprite();
- upState.graphics.clear();
- upState.graphics.beginFill(0xAAAAAA);
- upState.graphics.lineStyle(1,0x333333);
- upState.graphics.drawRect(0,0,9,9);
- upState.graphics.endFill();
- _closeButton.upState = upState;
-
- var overState:Sprite = new Sprite();
- overState.graphics.clear();
- overState.graphics.beginFill(0x999999);
- overState.graphics.lineStyle(1,0x333333);
- overState.graphics.drawRect(0,0,9,9);
- overState.graphics.endFill();
- _closeButton.overState = overState;
-
- var downState:Sprite = new Sprite();
- downState.graphics.clear();
- downState.graphics.beginFill(0x666666);
- downState.graphics.lineStyle(1,0x333333);
- downState.graphics.drawRect(0,0,9,9);
- downState.graphics.endFill();
- _closeButton.downState = downState;
- }
-
- private var _titleField:CSSTextField;
- private var _closeButton:SimpleButton;
-
- protected function get textField() : CSSTextField
- {
- return _titleField;
- }
-
- private var _titleBarModel:ITitleBarModel;
-
- public function get titleBarModel() : ITitleBarModel
- {
- return _titleBarModel;
- }
-
- private var _strand:IStrand;
-
- public function set strand(value:IStrand):void
- {
- _strand = value;
-
- _titleBarModel = value.getBeadByType(ITitleBarModel) as ITitleBarModel;
- titleBarModel.addEventListener("titleChange", titleChangeHandler);
- titleBarModel.addEventListener("htmlTitleChange", htmlTitleChangeHandler);
- titleBarModel.addEventListener("showCloseButtonChange", showCloseButtonChangeHandler);
- titleBarModel.addEventListener("widthChanged", sizeChangeHandler);
- titleBarModel.addEventListener("heightChanged", sizeChangeHandler);
-
- DisplayObjectContainer(value).addChild(_titleField);
-
- if (titleBarModel.title !== null)
- text = titleBarModel.title;
- if (titleBarModel.htmlTitle !== null)
- html = titleBarModel.htmlTitle;
-
- sizeChangeHandler(null);
- }
-
- public function initSkin():void
- {
- }
-
- public function get text():String
- {
- return _titleField.text;
- }
- public function set text(value:String):void
- {
- _titleField.text = value;
- }
-
- public function get html():String
- {
- return _titleField.htmlText;
- }
-
- public function set html(value:String):void
- {
- _titleField.htmlText = value;
- }
-
- private var _showCloseButton:Boolean = false;
- public function get showCloseButton() : Boolean
- {
- return _showCloseButton;
- }
- public function set showCloseButton(value:Boolean):void
- {
- _showCloseButton = value;
- if( value ) {
- DisplayObjectContainer(_strand).addChild(_closeButton);
- }
- else {
- DisplayObjectContainer(_strand).removeChild(_closeButton);
- }
- }
-
- private function titleChangeHandler(event:Event):void
- {
- text = titleBarModel.title;
- }
-
- private function htmlTitleChangeHandler(event:Event):void
- {
- html = titleBarModel.htmlTitle;
- }
-
- private function showCloseButtonChangeHandler(event:Event):void
- {
- sizeChangeHandler(event);
- }
-
- private function sizeChangeHandler(event:Event):void
- {
- _titleField.x = (DisplayObject(_strand).width - _titleField.width)/2;
- _titleField.y = (DisplayObject(_strand).height - _titleField.height)/2;
-
- trace("TitleBarBead. strand.width="+DisplayObject(_strand).width+"; titleField.width="+_titleField.width);
-
- if( showCloseButton ) {
- _closeButton. x = DisplayObject(_strand).width - _closeButton.width - 5;
- _closeButton.y = (DisplayObject(_strand).height - _closeButton.height)/2;
- }
- }
-
- // beads declared in MXML are added to the strand.
- // from AS, just call addBead()
- public var beads:Array;
-
- private var _beads:Vector.<IBead>;
- public function addBead(bead:IBead):void
- {
- if (!_beads)
- _beads = new Vector.<IBead>;
- _beads.push(bead);
- bead.strand = this;
- }
-
- public function getBeadByType(classOrInterface:Class):IBead
- {
- for each (var bead:IBead in _beads)
- {
- if (bead is classOrInterface)
- return bead;
- }
- return null;
- }
-
- public function removeBead(value:IBead):IBead
- {
- var n:int = _beads.length;
- for (var i:int = 0; i < n; i++)
- {
- var bead:IBead = _beads[i];
- if (bead == value)
- {
- _beads.splice(i, 1);
- return bead;
- }
- }
- return null;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c15c55ef/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/PanelModel.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/PanelModel.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/PanelModel.as
new file mode 100644
index 0000000..19c61aa
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/PanelModel.as
@@ -0,0 +1,82 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.html.staticControls.beads.models
+{
+ import org.apache.flex.core.IBead;
+ import org.apache.flex.core.IPanelModel;
+ import org.apache.flex.core.IStrand;
+ import org.apache.flex.events.Event;
+ import org.apache.flex.events.EventDispatcher;
+
+ public class PanelModel extends EventDispatcher implements IBead, IPanelModel
+ {
+ public function PanelModel()
+ {
+ super();
+ }
+ private var _strand:IStrand;
+
+ public function set strand(value:IStrand):void
+ {
+ _strand = value;
+ }
+
+ private var _title:String;
+ public function get title():String
+ {
+ return _title;
+ }
+
+ public function set title(value:String):void
+ {
+ if( value != _title ) {
+ _title = value;
+ dispatchEvent( new Event('titleChange') );
+ }
+ }
+
+ private var _htmlTitle:String;
+ public function get htmlTitle():String
+ {
+ return _htmlTitle;
+ }
+
+ public function set htmlTitle(value:String):void
+ {
+ if( value != _htmlTitle ) {
+ _htmlTitle = value;
+ dispatchEvent( new Event('htmlTitleChange') );
+ }
+ }
+
+ private var _showCloseButton:Boolean = false;
+ public function get showCloseButton():Boolean
+ {
+ return _showCloseButton;
+ }
+
+ public function set showCloseButton(value:Boolean):void
+ {
+ if( value != _showCloseButton ) {
+ _showCloseButton = value;
+ dispatchEvent( new Event('showCloseButtonChange') );
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c15c55ef/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/TitleBarModel.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/TitleBarModel.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/TitleBarModel.as
index 3727367..d72fab9 100644
--- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/TitleBarModel.as
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/TitleBarModel.as
@@ -66,7 +66,7 @@ package org.apache.flex.html.staticControls.beads.models
}
}
- private var _showCloseButton:Boolean;
+ private var _showCloseButton:Boolean = false;
public function get showCloseButton():Boolean
{
return _showCloseButton;