Repository: flex-asjs Updated Branches: refs/heads/develop 5deb8544e -> da54e7ef9
Moved new CheckBox and RadioButton icon classes to supportClasses. Fixed minor bug WRT RadioButton. Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/da54e7ef Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/da54e7ef Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/da54e7ef Branch: refs/heads/develop Commit: da54e7ef941a0a4ff830dad4bc2c06d9513552d2 Parents: 5deb854 Author: Peter Ent <[email protected]> Authored: Thu Jun 16 13:03:32 2016 -0400 Committer: Peter Ent <[email protected]> Committed: Thu Jun 16 13:03:32 2016 -0400 ---------------------------------------------------------------------- .../projects/HTML/src/main/flex/HTMLClasses.as | 1 + .../main/flex/org/apache/flex/html/CheckBox.as | 2 +- .../flex/org/apache/flex/html/DateChooser.as | 18 +-- .../src/main/flex/org/apache/flex/html/Label.as | 39 ++--- .../flex/org/apache/flex/html/RadioButton.as | 12 +- .../flex/org/apache/flex/html/TextButton.as | 1 + .../flex/html/accessories/CheckBoxIcon.as | 92 ----------- .../flex/html/accessories/RadioButtonIcon.as | 111 -------------- .../apache/flex/html/beads/DateChooserView.as | 153 +++++++++++-------- .../flex/html/beads/layouts/TileLayout.as | 70 ++++----- .../flex/html/supportClasses/CheckBoxIcon.as | 92 +++++++++++ .../html/supportClasses/DateChooserButton.as | 12 +- .../html/supportClasses/DateHeaderButton.as | 48 ++++++ .../flex/html/supportClasses/RadioButtonIcon.as | 111 ++++++++++++++ .../HTML/src/main/resources/basic-manifest.xml | 2 - 15 files changed, 422 insertions(+), 342 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/da54e7ef/frameworks/projects/HTML/src/main/flex/HTMLClasses.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/HTMLClasses.as b/frameworks/projects/HTML/src/main/flex/HTMLClasses.as index 86a7e1f..76481bd 100644 --- a/frameworks/projects/HTML/src/main/flex/HTMLClasses.as +++ b/frameworks/projects/HTML/src/main/flex/HTMLClasses.as @@ -165,6 +165,7 @@ internal class HTMLClasses import org.apache.flex.html.beads.controllers.RangeStepperMouseController; RangeStepperMouseController; import org.apache.flex.html.supportClasses.DataGridColumn; DataGridColumn; import org.apache.flex.html.supportClasses.DateChooserButton; DateChooserButton; + import org.apache.flex.html.supportClasses.DateHeaderButton; DateHeaderButton; import org.apache.flex.html.supportClasses.GraphicsItemRenderer; GraphicsItemRenderer; import org.apache.flex.html.beads.TitleBarView; TitleBarView; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/da54e7ef/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/CheckBox.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/CheckBox.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/CheckBox.as index d65cd5e..6ea2d0d 100644 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/CheckBox.as +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/CheckBox.as @@ -34,7 +34,7 @@ package org.apache.flex.html { import org.apache.flex.core.UIBase; import org.apache.flex.core.WrappedHTMLElement; - import org.apache.flex.html.accessories.CheckBoxIcon; + import org.apache.flex.html.supportClasses.CheckBoxIcon; } import org.apache.flex.events.Event; import org.apache.flex.events.MouseEvent; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/da54e7ef/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DateChooser.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DateChooser.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DateChooser.as index 33615ea..62b5a3e 100644 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DateChooser.as +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DateChooser.as @@ -20,15 +20,15 @@ package org.apache.flex.html { import org.apache.flex.core.IDateChooserModel; import org.apache.flex.core.UIBase; - + /** * The change event is dispatched when the selectedDate is changed. */ [Event(name="change", type="org.apache.flex.events.Event")] - + /** * The DateChooser class is a component that displays a calendar. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -38,7 +38,7 @@ package org.apache.flex.html { /** * constructor. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -48,15 +48,15 @@ package org.apache.flex.html { super(); className = "DateChooser"; - + // fix the DateChooser's size -// width = 280; -// height = 240; + width = 280; + height = 240; } - + /** * The currently selected date (or null if no date has been selected). - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/da54e7ef/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Label.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Label.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Label.as index 9365099..b811ec5 100644 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Label.as +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Label.as @@ -25,7 +25,7 @@ package org.apache.flex.html import org.apache.flex.events.IEventDispatcher; COMPILE::JS { - import org.apache.flex.core.WrappedHTMLElement; + import org.apache.flex.core.WrappedHTMLElement; } /* @@ -38,18 +38,18 @@ package org.apache.flex.html /** * The Label class implements the basic control for labeling - * other controls. - * + * other controls. + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 * @productversion FlexJS 0.0 - */ + */ public class Label extends UIBase { /** * Constructor. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -59,11 +59,11 @@ package org.apache.flex.html { super(); } - + [Bindable("textChange")] /** * The text to display in the label. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -72,7 +72,7 @@ package org.apache.flex.html public function get text():String { COMPILE::SWF - { + { return ITextModel(model).text; } COMPILE::JS @@ -88,20 +88,20 @@ package org.apache.flex.html { COMPILE::SWF { - ITextModel(model).text = value; + ITextModel(model).text = value; } COMPILE::JS { this.element.innerHTML = value; - this.dispatchEvent('textChange'); + this.dispatchEvent('textChange'); } } - + [Bindable("htmlChange")] /** * The html-formatted text to display in the label. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -111,7 +111,7 @@ package org.apache.flex.html { COMPILE::SWF { - return ITextModel(model).html; + return ITextModel(model).html; } COMPILE::JS { @@ -126,16 +126,16 @@ package org.apache.flex.html { COMPILE::SWF { - ITextModel(model).html = value; + ITextModel(model).html = value; } COMPILE::JS { this.element.innerHTML = value; - this.dispatchEvent('textChange'); + this.dispatchEvent('textChange'); } } - + /** * @private */ @@ -146,7 +146,7 @@ package org.apache.flex.html model.addEventListener("textChange", repeaterListener); model.addEventListener("htmlChange", repeaterListener); } - + /** * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement */ @@ -157,8 +157,11 @@ package org.apache.flex.html positioner = element; element.flexjs_wrapper = this; element.style.whiteSpace = "nowrap"; + + className = "Label"; + typeNames = "Label"; return element; - } + } } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/da54e7ef/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/RadioButton.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/RadioButton.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/RadioButton.as index fc65985..1329be4 100644 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/RadioButton.as +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/RadioButton.as @@ -35,7 +35,7 @@ package org.apache.flex.html { import org.apache.flex.core.UIBase; import org.apache.flex.core.WrappedHTMLElement; - import org.apache.flex.html.accessories.RadioButtonIcon; + import org.apache.flex.html.supportClasses.RadioButtonIcon; } import org.apache.flex.events.Event; import org.apache.flex.events.MouseEvent; @@ -226,7 +226,6 @@ package org.apache.flex.html { public static var radioCounter:int = 0; - private var input:HTMLInputElement; private var labelFor:HTMLLabelElement; private var textNode:Text; private var icon:RadioButtonIcon; @@ -242,7 +241,6 @@ package org.apache.flex.html icon = new RadioButtonIcon() icon.id = '_radio_' + RadioButton.radioCounter++; - textNode = document.createTextNode('radio button') as Text; labelFor = document.createElement('label') as HTMLLabelElement; @@ -300,11 +298,11 @@ package org.apache.flex.html public function get value():Object { - return input.value; + return (icon.element as HTMLInputElement).value; } public function set value(v:Object):void { - input.value = v as String; + (icon.element as HTMLInputElement).value = v as String; } public function get selectedValue():Object @@ -314,7 +312,7 @@ package org.apache.flex.html var i:int; var n:int; - groupName = input.name as String; + groupName = (icon.element as HTMLInputElement).name as String; buttons = document.getElementsByName(groupName); n = buttons.length; @@ -336,7 +334,7 @@ package org.apache.flex.html var i:int; var n:int; - groupName = input.name as String; + groupName = (icon.element as HTMLInputElement).name as String; buttons = document.getElementsByName(groupName); n = buttons.length; for (i = 0; i < n; i++) { http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/da54e7ef/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/TextButton.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/TextButton.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/TextButton.as index f8c8c8f..ec052c7 100644 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/TextButton.as +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/TextButton.as @@ -128,6 +128,7 @@ package org.apache.flex.html override protected function createElement():WrappedHTMLElement { var element:WrappedHTMLElement = super.createElement(); + className = "TextButton"; typeNames = "TextButton"; return element; } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/da54e7ef/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/accessories/CheckBoxIcon.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/accessories/CheckBoxIcon.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/accessories/CheckBoxIcon.as deleted file mode 100644 index 627e70d..0000000 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/accessories/CheckBoxIcon.as +++ /dev/null @@ -1,92 +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.accessories -{ - COMPILE::JS { - import org.apache.flex.core.WrappedHTMLElement; - } - - public class CheckBoxIcon - { - public function CheckBoxIcon() - { - COMPILE::JS { - createElement(); - } - - className = 'CheckBoxIcon'; - } - - COMPILE::JS { - public var element:WrappedHTMLElement; - public var positioner:WrappedHTMLElement; - } - - private var _className:String; - - public function get className():String - { - return _className; - } - public function set className(value:String):void - { - _className = value; - - COMPILE::JS { - element.className = value; - } - } - - private var _id:String; - - public function get id():String - { - return _id; - } - public function set id(value:String):void - { - _id = value; - - COMPILE::JS { - element.id = value; - } - } - - /** - * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement - * @flexjsignorecoercion HTMLInputElement - * @flexjsignorecoercion Text - */ - COMPILE::JS - protected function createElement():WrappedHTMLElement - { - var input:HTMLInputElement = document.createElement('input') as HTMLInputElement; - input.type = 'checkbox'; - - element = input as WrappedHTMLElement; - - positioner = element; - positioner.style.position = 'relative'; - - (element as WrappedHTMLElement).flexjs_wrapper = this; - - return element; - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/da54e7ef/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/accessories/RadioButtonIcon.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/accessories/RadioButtonIcon.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/accessories/RadioButtonIcon.as deleted file mode 100644 index cbcf427..0000000 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/accessories/RadioButtonIcon.as +++ /dev/null @@ -1,111 +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.accessories -{ - COMPILE::JS { - import org.apache.flex.core.WrappedHTMLElement; - } - - /** - * The RadioButton class is a component that displays a selectable Button. RadioButtons - * are typically used in groups, identified by the groupName property. RadioButton use - * the following beads: - * - * org.apache.flex.core.IBeadModel: the data model, which includes the groupName. - * org.apache.flex.core.IBeadView: the bead that constructs the visual parts of the RadioButton.. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class RadioButtonIcon - { - public function RadioButtonIcon() - { - COMPILE::JS { - createElement(); - } - - className = 'RadioButtonIcon'; - } - - COMPILE::JS { - public var element:WrappedHTMLElement; - public var positioner:WrappedHTMLElement; - } - - private var _className:String; - - /** - * @private - */ - public function get className():String - { - return _className; - } - public function set className(value:String):void - { - _className = value; - - COMPILE::JS { - element.className = value; - } - } - - private var _id:String; - - /** - * @private - */ - public function get id():String - { - return _id; - } - public function set id(value:String):void - { - _id = value; - - COMPILE::JS { - element.id = value; - } - } - - /** - * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement - * @flexjsignorecoercion HTMLInputElement - * @flexjsignorecoercion Text - */ - COMPILE::JS - protected function createElement():WrappedHTMLElement - { - var input:HTMLInputElement = document.createElement('input') as HTMLInputElement; - input.type = 'radio'; - - element = input as WrappedHTMLElement; - - positioner = element; - positioner.style.position = 'relative'; - - (element as WrappedHTMLElement).flexjs_wrapper = this; - - return element; - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/da54e7ef/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DateChooserView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DateChooserView.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DateChooserView.as index 5abf4c4..b3eac7f 100644 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DateChooserView.as +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DateChooserView.as @@ -17,10 +17,11 @@ // //////////////////////////////////////////////////////////////////////////////// package org.apache.flex.html.beads -{ +{ import org.apache.flex.html.beads.models.DateChooserModel; import org.apache.flex.html.supportClasses.DateChooserButton; - + import org.apache.flex.html.supportClasses.DateHeaderButton; + import org.apache.flex.core.BeadViewBase; import org.apache.flex.core.IBeadModel; import org.apache.flex.core.IBeadView; @@ -32,7 +33,7 @@ package org.apache.flex.html.beads import org.apache.flex.html.beads.layouts.TileLayout; import org.apache.flex.html.Container; import org.apache.flex.html.TextButton; - + /** * The DateChooserView class is a view bead for the DateChooser. This class * creates the elements for the DateChooser: the buttons to move between @@ -43,7 +44,7 @@ package org.apache.flex.html.beads { /** * constructor - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -52,10 +53,10 @@ package org.apache.flex.html.beads public function DateChooserView() { } - + /** * @copy org.apache.flex.core.IBead#strand - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -64,7 +65,7 @@ package org.apache.flex.html.beads override public function set strand(value:IStrand):void { super.strand = value; - + // make sure there is a model. model = _strand.getBeadByType(IBeadModel) as DateChooserModel; if (model == null) { @@ -72,44 +73,49 @@ package org.apache.flex.html.beads } model.addEventListener("displayedMonthChanged",handleModelChange); model.addEventListener("displayedYearChanged",handleModelChange); - + + var host:UIBase = value as UIBase; + host.addEventListener("widthChanged", handleSizeChange); + host.addEventListener("heightChanged", handleSizeChange); + createChildren(); + layoutContents(); } - - private var _prevMonthButton:TextButton; - private var _nextMonthButton:TextButton; + + private var _prevMonthButton:DateHeaderButton; + private var _nextMonthButton:DateHeaderButton; private var _dayButtons:Array; - private var monthLabel:TextButton; + private var monthLabel:DateHeaderButton; private var dayContainer:Container; - + private var model:DateChooserModel; - + /** * The button that causes the previous month to be displayed by the DateChooser. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - public function get prevMonthButton():TextButton + public function get prevMonthButton():DateHeaderButton { return _prevMonthButton; } - + /** * The button that causes the next month to be displayed by the DateChooser. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - public function get nextMonthButton():TextButton + public function get nextMonthButton():DateHeaderButton { return _nextMonthButton; } - + /** * The array of DateChooserButton instances that represent each day of the month. */ @@ -117,51 +123,65 @@ package org.apache.flex.html.beads { return _dayButtons; } - + + private function handleSizeChange(event:Event):void + { + layoutContents(); + } + + private function layoutContents():void + { + var sw:Number = UIBase(_strand).width; + var sh:Number = UIBase(_strand).height; + + _prevMonthButton.x = 0; + _prevMonthButton.y = 0; + + _nextMonthButton.x = sw - _nextMonthButton.width; + _nextMonthButton.y = 0; + + monthLabel.x = (sw - monthLabel.width)/2; + monthLabel.y = 0; + + dayContainer.x = 0; + dayContainer.y = monthLabel.y + monthLabel.height + 5; + dayContainer.width = sw; + dayContainer.height = sh - (monthLabel.height+5); + + IEventDispatcher(_strand).dispatchEvent( new Event("layoutNeeded") ); + IEventDispatcher(dayContainer).dispatchEvent( new Event("layoutNeeded") ); + } + /** * @private */ private function createChildren():void { - _prevMonthButton = new TextButton(); + _prevMonthButton = new DateHeaderButton(); _prevMonthButton.width = 40; _prevMonthButton.height = 20; - _prevMonthButton.x = 0; - _prevMonthButton.y = 0; _prevMonthButton.text = "<"; UIBase(_strand).addElement(_prevMonthButton); - - _nextMonthButton = new TextButton(); + + _nextMonthButton = new DateHeaderButton(); _nextMonthButton.width = 40; _nextMonthButton.height = 20; - _nextMonthButton.x = UIBase(_strand).width - _nextMonthButton.width; - _nextMonthButton.y = 0; _nextMonthButton.text = ">"; UIBase(_strand).addElement(_nextMonthButton); - - monthLabel = new TextButton(); + + monthLabel = new DateHeaderButton(); monthLabel.text = "Month Here"; monthLabel.width = 100; monthLabel.height = 20; - monthLabel.x = (UIBase(_strand).width - monthLabel.width)/2; - monthLabel.y = 0; UIBase(_strand).addElement(monthLabel); - + dayContainer = new Container(); var tileLayout:TileLayout = new TileLayout(); dayContainer.addBead(tileLayout); UIBase(_strand).addElement(dayContainer, false); - + tileLayout.numColumns = 7; - dayContainer.x = 0; - dayContainer.y = monthLabel.y + monthLabel.height + 5; - - var sw:Number = UIBase(_strand).width; - var sh:Number = UIBase(_strand).height; - //trace("Strand's width x height is "+sw+" x "+sh); - dayContainer.width = sw; - dayContainer.height = sh - (monthLabel.height+5); - + // the calendar has 7 columns with 6 rows, the first row are the day names for(var i:int=0; i < 7; i++) { var dayName:DateChooserButton = new DateChooserButton(); @@ -169,23 +189,21 @@ package org.apache.flex.html.beads dayName.dayOfMonth = 0; dayContainer.addElement(dayName, false); } - + _dayButtons = new Array(); - + for(i=0; i < 42; i++) { var date:DateChooserButton = new DateChooserButton(); date.text = String(i+1); dayContainer.addElement(date, false); dayButtons.push(date); } - - IEventDispatcher(dayContainer).dispatchEvent( new Event("itemsCreated") ); - IEventDispatcher(_strand).dispatchEvent( new Event("layoutNeeded") ); - IEventDispatcher(dayContainer).dispatchEvent( new Event("layoutNeeded") ); - + + IEventDispatcher(dayContainer).dispatchEvent( new Event("itemsCreated") ); + updateCalendar(); } - + /** * @private */ @@ -193,26 +211,37 @@ package org.apache.flex.html.beads { monthLabel.text = model.monthNames[model.displayedMonth] + " " + String(model.displayedYear); - + var firstDay:Date = new Date(model.displayedYear,model.displayedMonth,1); - + // blank out the labels for the first firstDay.day-1 entries. for(var i:int=0; i < firstDay.getDay(); i++) { var dateButton:DateChooserButton = dayButtons[i] as DateChooserButton; dateButton.dayOfMonth = -1; dateButton.text = ""; } - + + // flag today + var today:Date = new Date(); + // renumber to the last day of the month var dayNumber:int = 1; var numDays:Number = numberOfDaysInMonth(model.displayedMonth, model.displayedYear); - + for(; i < dayButtons.length && dayNumber <= numDays; i++) { dateButton = dayButtons[i] as DateChooserButton; dateButton.dayOfMonth = dayNumber; dateButton.text = String(dayNumber++); + + if (model.displayedMonth == today.getMonth() && + model.displayedYear == today.getFullYear() && + (dayNumber-1) == today.getDate()) { + dateButton.id = "todayDateChooserButton"; + } else { + dateButton.id = ""; + } } - + // blank out the rest for(; i < dayButtons.length; i++) { dateButton = dayButtons[i] as DateChooserButton; @@ -220,14 +249,14 @@ package org.apache.flex.html.beads dateButton.text = ""; } } - + /** * @private */ private function numberOfDaysInMonth(month:Number, year:Number):Number { var n:int; - + if (month == 1) // Feb { if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) // leap year @@ -235,16 +264,16 @@ package org.apache.flex.html.beads else n = 28; } - + else if (month == 3 || month == 5 || month == 8 || month == 10) n = 30; - + else n = 31; - + return n; } - + /** * @private */ http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/da54e7ef/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/TileLayout.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/TileLayout.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/TileLayout.as index 848a769..a7917ff 100644 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/TileLayout.as +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/TileLayout.as @@ -17,7 +17,7 @@ // //////////////////////////////////////////////////////////////////////////////// package org.apache.flex.html.beads.layouts -{ +{ import org.apache.flex.core.IBeadLayout; import org.apache.flex.core.ILayoutHost; import org.apache.flex.core.IParentIUIBase; @@ -26,13 +26,13 @@ package org.apache.flex.html.beads.layouts import org.apache.flex.core.UIBase; import org.apache.flex.events.Event; import org.apache.flex.events.IEventDispatcher; - + /** * The TileLayout class bead sizes and positions the elements it manages into rows and columns. * The size of each element is determined either by setting TileLayout's columnWidth and rowHeight * properties, or having the tile size determined by factoring the numColumns into the area assigned * for the layout. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -42,7 +42,7 @@ package org.apache.flex.html.beads.layouts { /** * constructor. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -51,12 +51,12 @@ package org.apache.flex.html.beads.layouts public function TileLayout() { } - + private var _strand:IStrand; - + /** * @copy org.apache.flex.core.IBead#strand - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -64,16 +64,16 @@ package org.apache.flex.html.beads.layouts */ public function set strand(value:IStrand):void { - _strand = value; + _strand = value; } - + private var _numColumns:Number = 4; private var _columnWidth:Number = Number.NaN; private var _rowHeight:Number = Number.NaN; - + /** * The number of tiles to fit horizontally into the layout. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -87,12 +87,12 @@ package org.apache.flex.html.beads.layouts { _numColumns = value; } - + /** * The width of each column, in pixels. If left unspecified, the * columnWidth is determined by dividing the numColumns into the * strand's bounding box width. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -106,12 +106,12 @@ package org.apache.flex.html.beads.layouts { _columnWidth = value; } - + /** * The height of each row, in pixels. If left unspecified, the * rowHeight is determine by dividing the possible number of rows * into the strand's bounding box height. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -125,7 +125,7 @@ package org.apache.flex.html.beads.layouts { _rowHeight = value; } - + /** * @copy org.apache.flex.core.IBeadLayout#layout */ @@ -137,31 +137,31 @@ package org.apache.flex.html.beads.layouts var host:UIBase = _strand as UIBase; var p:ILayoutHost = _strand.getBeadByType(ILayoutHost) as ILayoutHost; var area:UIBase = p.contentView as UIBase; - + var xpos:Number = 0; var ypos:Number = 0; var useWidth:Number = columnWidth; var useHeight:Number = rowHeight; var n:Number = area.numElements; if (n == 0) return false; - + var realN:Number = n; for(var j:int=0; j < n; j++) { var testChild:IUIBase = area.getElementAt(i) as IUIBase; if (testChild && !testChild.visible) realN--; } - + if (isNaN(useWidth)) useWidth = Math.floor(host.width / numColumns); // + gap if (isNaN(useHeight)) { // given the width and total number of items, how many rows? var numRows:Number = Math.floor(realN/numColumns); useHeight = Math.floor(host.height / numRows); } - + var maxWidth:Number = useWidth; var maxHeight:Number = useHeight; - + for(var i:int=0; i < n; i++) { var child:IUIBase = area.getElementAt(i) as IUIBase; @@ -170,28 +170,28 @@ package org.apache.flex.html.beads.layouts child.height = useHeight; child.x = xpos; child.y = ypos; - + xpos += useWidth; maxWidth = Math.max(maxWidth,xpos); - + var test:Number = (i+1)%numColumns; - + if (test == 0) { xpos = 0; ypos += useHeight; maxHeight = Math.max(maxHeight,ypos); - } + } } - + maxWidth = Math.max(maxWidth, numColumns*useWidth); maxHeight = Math.max(maxHeight, numRows*useHeight); - + // Only return true if the contentView needs to be larger; that new // size is stored in the model. var sizeChanged:Boolean = true; - + IEventDispatcher(_strand).dispatchEvent( new Event("layoutComplete") ); - + return sizeChanged; } COMPILE::JS @@ -204,33 +204,35 @@ package org.apache.flex.html.beads.layouts var ypos:Number; var useWidth:Number; var useHeight:Number; - + var host:UIBase = _strand as UIBase; var viewBead:ILayoutHost = _strand.getBeadByType(ILayoutHost) as ILayoutHost; var contentView:IParentIUIBase = viewBead.contentView; children = contentView.internalChildren(); n = children.length; if (n === 0) return false; - + + viewBead.contentView.width = host.width; + var realN:int = n; for (i = 0; i < n; i++) { child = children[i].flexjs_wrapper; if (!child.visible) realN--; } - + xpos = 0; ypos = 0; useWidth = columnWidth; useHeight = rowHeight; - + if (isNaN(useWidth)) useWidth = Math.floor(host.width / numColumns); // + gap if (isNaN(useHeight)) { // given the width and total number of items, how many rows? var numRows:Number = Math.floor(realN / numColumns); useHeight = Math.floor(host.height / numRows); } - + for (i = 0; i < n; i++) { child = children[i].flexjs_wrapper; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/da54e7ef/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/CheckBoxIcon.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/CheckBoxIcon.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/CheckBoxIcon.as new file mode 100644 index 0000000..92c3f53 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/CheckBoxIcon.as @@ -0,0 +1,92 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.supportClasses +{ + COMPILE::JS { + import org.apache.flex.core.WrappedHTMLElement; + } + + public class CheckBoxIcon + { + public function CheckBoxIcon() + { + COMPILE::JS { + createElement(); + } + + className = 'CheckBoxIcon'; + } + + COMPILE::JS { + public var element:WrappedHTMLElement; + public var positioner:WrappedHTMLElement; + } + + private var _className:String; + + public function get className():String + { + return _className; + } + public function set className(value:String):void + { + _className = value; + + COMPILE::JS { + element.className = value; + } + } + + private var _id:String; + + public function get id():String + { + return _id; + } + public function set id(value:String):void + { + _id = value; + + COMPILE::JS { + element.id = value; + } + } + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + * @flexjsignorecoercion HTMLInputElement + * @flexjsignorecoercion Text + */ + COMPILE::JS + protected function createElement():WrappedHTMLElement + { + var input:HTMLInputElement = document.createElement('input') as HTMLInputElement; + input.type = 'checkbox'; + + element = input as WrappedHTMLElement; + + positioner = element; + positioner.style.position = 'relative'; + + (element as WrappedHTMLElement).flexjs_wrapper = this; + + return element; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/da54e7ef/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DateChooserButton.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DateChooserButton.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DateChooserButton.as index 2d80b2f..f493a45 100644 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DateChooserButton.as +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DateChooserButton.as @@ -19,11 +19,11 @@ package org.apache.flex.html.supportClasses { import org.apache.flex.html.TextButton; - + /** * The DateChooserButton class is used for each button in the DateChooser. The * button holds the day of the month the button is representing. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -33,7 +33,7 @@ package org.apache.flex.html.supportClasses { /** * constructor. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -44,12 +44,12 @@ package org.apache.flex.html.supportClasses super(); className = "DateChooserButton"; } - + private var _dayOfMonth:int; - + /** * The day of the month the button represents. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/da54e7ef/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DateHeaderButton.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DateHeaderButton.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DateHeaderButton.as new file mode 100644 index 0000000..4fbe70a --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DateHeaderButton.as @@ -0,0 +1,48 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.supportClasses +{ + import org.apache.flex.html.TextButton; + + /** + * The DateHeaderButton class is used for the buttons in the DateChooser's + * heading areas. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DateHeaderButton extends TextButton + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DateHeaderButton() + { + super(); + className = "DateHeaderButton"; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/da54e7ef/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/RadioButtonIcon.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/RadioButtonIcon.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/RadioButtonIcon.as new file mode 100644 index 0000000..119400f --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/RadioButtonIcon.as @@ -0,0 +1,111 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.supportClasses +{ + COMPILE::JS { + import org.apache.flex.core.WrappedHTMLElement; + } + + /** + * The RadioButton class is a component that displays a selectable Button. RadioButtons + * are typically used in groups, identified by the groupName property. RadioButton use + * the following beads: + * + * org.apache.flex.core.IBeadModel: the data model, which includes the groupName. + * org.apache.flex.core.IBeadView: the bead that constructs the visual parts of the RadioButton.. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class RadioButtonIcon + { + public function RadioButtonIcon() + { + COMPILE::JS { + createElement(); + } + + className = 'RadioButtonIcon'; + } + + COMPILE::JS { + public var element:WrappedHTMLElement; + public var positioner:WrappedHTMLElement; + } + + private var _className:String; + + /** + * @private + */ + public function get className():String + { + return _className; + } + public function set className(value:String):void + { + _className = value; + + COMPILE::JS { + element.className = value; + } + } + + private var _id:String; + + /** + * @private + */ + public function get id():String + { + return _id; + } + public function set id(value:String):void + { + _id = value; + + COMPILE::JS { + element.id = value; + } + } + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + * @flexjsignorecoercion HTMLInputElement + * @flexjsignorecoercion Text + */ + COMPILE::JS + protected function createElement():WrappedHTMLElement + { + var input:HTMLInputElement = document.createElement('input') as HTMLInputElement; + input.type = 'radio'; + + element = input as WrappedHTMLElement; + + positioner = element; + positioner.style.position = 'relative'; + + (element as WrappedHTMLElement).flexjs_wrapper = this; + + return element; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/da54e7ef/frameworks/projects/HTML/src/main/resources/basic-manifest.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/resources/basic-manifest.xml b/frameworks/projects/HTML/src/main/resources/basic-manifest.xml index 5fd72c0..8904c6e 100644 --- a/frameworks/projects/HTML/src/main/resources/basic-manifest.xml +++ b/frameworks/projects/HTML/src/main/resources/basic-manifest.xml @@ -37,9 +37,7 @@ <component id="List" class="org.apache.flex.html.List"/> <component id="SimpleList" class="org.apache.flex.html.SimpleList"/> <component id="CheckBox" class="org.apache.flex.html.CheckBox"/> - <component id="CheckBoxIcon" class="org.apache.flex.html.accessories.CheckBoxIcon" /> <component id="RadioButton" class="org.apache.flex.html.RadioButton"/> - <component id="RadioButtonIcon" class="org.apache.flex.html.accessories.RadioButtonIcon"/> <component id="ComboBox" class="org.apache.flex.html.ComboBox"/> <component id="Container" class="org.apache.flex.html.Container"/> <component id="HContainer" class="org.apache.flex.html.HContainer"/>
