Sorry, the patch didn't ignore white spaces, so here is another shorter one:
--- D:/BBrFx/BBrFoundation4/BBrFx/MobileControlsMAM/src/com/systar/fx/mobile/components/supportClasses/LabelItemRenderer.as Wed Sep 25 18:01:43 2013 +++ D:/BBrFx/BBrFoundation4/BBrFx/MobileControlsMAM/src/com/systar/fx/mobile/components/supportClasses/ItemRendererBase.as Thu Sep 26 01:28:15 2013 @@ -1,30 +1,9 @@ +/* monkey-patched from LabelItemRenderer, to remove the label */ package com.systar.fx.mobile.components.supportClasses { -//////////////////////////////////////////////////////////////////////////////// -// -// 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. -// -//////////////////////////////////////////////////////////////////////////////// - - import flash.display.GradientType; import flash.events.Event; import flash.geom.Matrix; - import flash.text.TextLineMetrics; - import mx.controls.listClasses.*; import mx.core.DPIClassification; import mx.core.FlexGlobals; import mx.core.IDataRenderer; @@ -34,9 +13,10 @@ import mx.core.mx_internal; import mx.events.FlexEvent; +import spark.components.DataGroup; +import spark.components.IItemRenderer; import spark.components.supportClasses.InteractionState; import spark.components.supportClasses.InteractionStateDetector; - import spark.components.supportClasses.StyleableTextField; use namespace mx_internal; @@ -64,8 +44,7 @@ // Styles //-------------------------------------- - include "../styles/metadata/PaddingStyles.as" - include "../styles/metadata/StyleableTextFieldTextStyles.as" +[Style(name="paddingLeft", type="Number", format="Length", inherit="no")] /** * @copy spark.components.supportClasses.GroupBase#style:alternatingItemColors @@ -178,79 +156,7 @@ [Exclude(name="focusBlendMode", kind="style")] [Exclude(name="focusThickness", kind="style")] - /** - * The LabelItemRenderer class defines the default item renderer - * for a list-based control in the mobile theme. - * This is a simple item renderer with a single text component. - * - * <p>The item renderer creates a single StyleableTextField control - * to display a String. - * The name of the StyleableTextField control in the item renderer is <code>labelDisplay</code>. - * Use the <code>labelField</code> property of the list-based control to specify - * a field of the data item to display in the StyleableTextField control.</p> - * - * <p>To create a custom item renderer for use on mobile devices, - * Adobe recommends that you create a new ActionScript item renderer - * that extends this class.</p> - * - * @mxml - * - * <p>The <code><s:LabelItemRenderer></code> tag inherits all of the tag - * attributes of its superclass and adds the following tag attributes:</p> - * - * <pre> - * <s:LabelItemRenderer - * <strong>Properties</strong> - * label="" - * - * <strong>Common Styles</strong> - * color="<i>Theme dependent</i>" - * downColor="<i>Theme dependent</i>" - * fontFamily="<i>Theme dependent</i>" - * fontSize="<i>Theme dependent</i>" - * fontStyle="normal" - * fontWeight="normal" - * leading="0" - * letterSpacing="0" - * paddingBottom="0" - * paddingLeft="0" - * paddingRight="0" - * paddingTop="5" - * rollOverColor="0xCEDBEF" - * selectionColor="0xB2B2B2" - * textAlign="left" - * textDecoration="none" - * textIndent="0" - * verticalAlign="center" - * - * <strong>Spark Styles</strong> - * alternatingItemColors="undefined" - * focusColor="0x70B2EE" - * symbolColor="0x000000" - * - * <strong>Mobile Styles</strong> - * alternatingItemColors="undefined" - * focusColor="0x70B2EE" - * symbolColor="0x000000" - * - * <b>Events</b> - * dataChange="<i>No default</i>" - * - * > - * </pre> - * - * @see spark.components.IconItemRenderer - * @see spark.components.List - * @see mx.core.IDataRenderer - * @see spark.components.IItemRenderer - * @see spark.components.supportClasses.ItemRenderer - * @includeExample examples/LabelItemRendererExample.mxml -noswf - * - * @langversion 3.0 - * @playerversion AIR 2.5 - * @productversion Flex 4.5 - */ - public class LabelItemRenderer extends UIComponent implements IDataRenderer, IItemRenderer { +public class ItemRendererBase extends UIComponent implements IDataRenderer, IItemRenderer { //-------------------------------------------------------------------------- // @@ -265,7 +171,7 @@ * @playerversion AIR 2.5 * @productversion Flex 4.5 */ - public function LabelItemRenderer() { + public function ItemRendererBase() { super(); switch (applicationDPI) { @@ -308,7 +214,7 @@ * @private * Helper class to help determine when we are in the hovered or down states */ - private var interactionStateDetector:InteractionStateDetector; + protected var interactionStateDetector:InteractionStateDetector; /** * @private @@ -318,27 +224,6 @@ //-------------------------------------------------------------------------- // - // Overridden properties: UIComponent - // - //-------------------------------------------------------------------------- - - //---------------------------------- - // baselinePosition - //---------------------------------- - - /** - * @private - */ - override public function get baselinePosition():Number { - // The text styles aren't known until there is a parent. - if (!parent) - return NaN; - - return labelDisplay.baselinePosition; - } - - //-------------------------------------------------------------------------- - // // Public Properties // //-------------------------------------------------------------------------- @@ -378,6 +263,8 @@ if (hasEventListener(FlexEvent.DATA_CHANGE)) dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE)); + + if (_data) onDataChanged(); } //---------------------------------- @@ -497,64 +384,13 @@ invalidateDisplayList(); } - //---------------------------------- - // label - //---------------------------------- - - /** - * @private - * Storage var for label - */ - private var _label:String = ""; - - /** - * The text component used to - * display the label data of the item renderer. - * - * @langversion 3.0 - * @playerversion AIR 2.5 - * @productversion Flex 4.5 - */ - protected var labelDisplay:StyleableTextField; - - /** - * @inheritDoc - * - * @default "" - * - * @langversion 3.0 - * @playerversion AIR 2.5 - * @productversion Flex 4.5 - */ public function get label():String { - return _label; + return ""; } - /** - * @private - */ public function set label(value:String):void { - if (value == _label) - return; - - _label = value; - - // Push the label down into the labelTextField, - // if it exists - if (labelDisplay) { - labelDisplay.text = _label; - invalidateSize(); } - } - - //---------------------------------- - // showsCaret - //---------------------------------- - /** - * @private - * Storage for the showsCaret property - */ private var _showsCaret:Boolean = false; /** @@ -590,6 +426,7 @@ * storage for the selected property */ private var _selected:Boolean = false; + private var _dragging:Boolean = false; /** * @inheritDoc @@ -658,81 +495,7 @@ return FlexGlobals.topLevelApplication.applicationDPI; } - //-------------------------------------------------------------------------- - // - // Overridden methods: UIComponent - // - //-------------------------------------------------------------------------- - - /** - * @private - */ - override protected function createChildren():void { - super.createChildren(); - - if (!labelDisplay) { - createLabelDisplay(); - labelDisplay.text = _label; - } - } - - /** - * Creates the labelDisplay component - * - * @langversion 3.0 - * @playerversion AIR 2.5 - * @productversion Flex 4.5 - */ - protected function createLabelDisplay():void { - labelDisplay = StyleableTextField(createInFontContext(StyleableTextField)); - labelDisplay.styleName = this; - labelDisplay.editable = false; - labelDisplay.selectable = false; - labelDisplay.multiline = false; - labelDisplay.wordWrap = false; - - addChild(labelDisplay); - } - /** - * Destroys the labelDisplay component - * - * @langversion 3.0 - * @playerversion AIR 2.5 - * @productversion Flex 4.5 - */ - protected function destroyLabelDisplay():void { - removeChild(labelDisplay); - labelDisplay = null; - } - - /** - * @private - */ - override protected function measure():void { - super.measure(); - - if (labelDisplay) { - // reset text if it was truncated before. - if (labelDisplay.isTruncated) - labelDisplay.text = label; - - var horizontalPadding:Number = getStyle("paddingLeft") + getStyle("paddingRight"); - var verticalPadding:Number = getStyle("paddingTop") + getStyle("paddingBottom"); - - // Text respects padding right, left, top, and bottom - labelDisplay.commitStyles(); - measuredWidth = getElementPreferredWidth(labelDisplay) + horizontalPadding; - // We only care about the "real" ascent - measuredHeight = getElementPreferredHeight(labelDisplay) + verticalPadding; - } - - measuredMinWidth = 0; - } - - /** - * @private - */ override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { // clear the graphics before calling super.updateDisplayList() graphics.clear(); @@ -844,7 +607,7 @@ } // Draw the separator for the item renderer - drawBorder(unscaledWidth, unscaledHeight); + drawBorder(unscaledWidth, unscaledHeight, alternatingColorsStyle != null); opaqueBackground = opaqueBackgroundColor; } @@ -870,12 +633,15 @@ * @playerversion AIR 3.0 * @productversion Flex 4.6 */ - protected function drawBorder(unscaledWidth:Number, unscaledHeight:Number):void { + protected function drawBorder(unscaledWidth:Number, unscaledHeight:Number, hasAlternatingColors:Boolean):void { var topSeparatorColor:uint; var topSeparatorAlpha:Number; var bottomSeparatorColor:uint; var bottomSeparatorAlpha:Number; + var borderWidth:Number = 1; + var drawBottomBorder:Boolean = !hasAlternatingColors; // if alternating colors, don't draw shadow + // separators are a highlight on the top and shadow on the bottom topSeparatorColor = 0xFFFFFF; topSeparatorAlpha = .3; @@ -887,21 +653,22 @@ // don't draw top separator for down and selected states if (!(selected || down)) { graphics.beginFill(topSeparatorColor, topSeparatorAlpha); - graphics.drawRect(0, 0, unscaledWidth, 1); + graphics.drawRect(0, 0, unscaledWidth, borderWidth); graphics.endFill(); } + if (drawBottomBorder) graphics.beginFill(bottomSeparatorColor, bottomSeparatorAlpha); - graphics.drawRect(0, unscaledHeight - (isLastItem ? 0 : 1), unscaledWidth, 1); + graphics.drawRect(0, unscaledHeight - (isLastItem ? 0 : borderWidth), unscaledWidth, borderWidth); graphics.endFill(); // add extra separators to the first and last items so that // the list looks correct during the scrolling bounce/pull effect // top - if (itemIndex == 0) { + if (itemIndex == 0 && drawBottomBorder) { graphics.beginFill(bottomSeparatorColor, bottomSeparatorAlpha); - graphics.drawRect(0, -1, unscaledWidth, 1); + graphics.drawRect(0, -borderWidth, unscaledWidth, borderWidth); graphics.endFill(); } @@ -911,7 +678,7 @@ // a double line at the bottom of the list if there's a // border graphics.beginFill(topSeparatorColor, topSeparatorAlpha); - graphics.drawRect(0, unscaledHeight + 1, unscaledWidth, 1); + graphics.drawRect(0, unscaledHeight + borderWidth, unscaledWidth, borderWidth); graphics.endFill(); } } @@ -938,68 +705,9 @@ * @productversion Flex 4.5 */ protected function layoutContents(unscaledWidth:Number, unscaledHeight:Number):void { - if (!labelDisplay) - return; - - var paddingLeft:Number = getStyle("paddingLeft"); - var paddingRight:Number = getStyle("paddingRight"); - var paddingTop:Number = getStyle("paddingTop"); - var paddingBottom:Number = getStyle("paddingBottom"); - var verticalAlign:String = getStyle("verticalAlign"); - - var viewWidth:Number = unscaledWidth - paddingLeft - paddingRight; - var viewHeight:Number = unscaledHeight - paddingTop - paddingBottom; - - var vAlign:Number; - if (verticalAlign == "top") - vAlign = 0; - else if (verticalAlign == "bottom") - vAlign = 1; - else // if (verticalAlign == "middle") - vAlign = 0.5; - - // measure the label component - // text should take up the rest of the space width-wise, but only let it take up - // its measured textHeight so we can position it later based on verticalAlign - var labelWidth:Number = Math.max(viewWidth, 0); - var labelHeight:Number = 0; - - if (label != "") { - labelDisplay.commitStyles(); - - // reset text if it was truncated before. - if (labelDisplay.isTruncated) - labelDisplay.text = label; - - labelHeight = getElementPreferredHeight(labelDisplay); - } - - setElementSize(labelDisplay, labelWidth, labelHeight); - - // We want to center using the "real" ascent - var labelY:Number = Math.round(vAlign * (viewHeight - labelHeight)) + paddingTop; - setElementPosition(labelDisplay, paddingLeft, labelY); - - // attempt to truncate the text now that we have its official width - labelDisplay.truncateToFit(); } - //-------------------------------------------------------------------------- - // - // Methods: Layout Helpers - // - //-------------------------------------------------------------------------- - - /** - * @copy spark.skins.mobile.supportClasses.MobileSkin#setElementPosition() - * - * @see #setElementSize - * - * @langversion 3.0 - * @playerversion AIR 2.5 - * @productversion Flex 4.5 - */ protected function setElementPosition(element:Object, x:Number, y:Number):void { if (element is ILayoutElement) { ILayoutElement(element).setLayoutBoundsPosition(x, y, false); -----Message d'origine----- De : Maurice Amsellem [mailto:maurice.amsel...@systar.com] Envoyé : jeudi 26 septembre 2013 01:36 À : dev@flex.apache.org Objet : RE: Flex Mobile DataGrid donation submission ___________ -----Message d'origine----- De : Maurice Amsellem [mailto:maurice.amsel...@systar.com] Envoyé : jeudi 26 septembre 2013 01:34 À : dev@flex.apache.org Objet : RE: Flex Mobile DataGrid donation submission Patch attached to the email (ItemRendererBase.patch) -----Message d'origine----- De : Maurice Amsellem [mailto:maurice.amsel...@systar.com] Envoyé : jeudi 26 septembre 2013 01:09 À : dev@flex.apache.org Objet : RE: Flex Mobile DataGrid donation submission I will do. -----Message d'origine----- De : Justin Mclean [mailto:jus...@classsoftware.com] Envoyé : jeudi 26 septembre 2013 00:20 À : dev@flex.apache.org Objet : Re: Flex Mobile DataGrid donation submission Hi, > 4) I had to monkey-patch ItemLabelRenderer to make some variables > protected, and abstract it (ie remove the default label and labelDisplay) so > that I it becomes "empty" base class for my renderers (typically > ListMultiPartItemRenderer). > To avoid code duplication, would it be possible to make some "neutral" > changes in ItemLabelRenderer, or even split it into ItemRendererBase (no > label) and ItemLabelRenderer. Can you provide a patch file showing these changes? Thanks, Justin