//////////////////////////////////////////////////////////////////////////////// // // 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 mx.controls.advancedDataGridClasses { import flash.display.DisplayObject; import flash.text.TextLineMetrics; import mx.controls.AdvancedDataGrid; import mx.controls.advancedDataGridClasses.SortInfo; import mx.controls.listClasses.IDropInListItemRenderer; import mx.core.IUIComponent; import mx.core.IUITextField; import mx.core.UIComponent; import mx.core.UITextField; import mx.core.IFlexDisplayObject; import mx.styles.ISimpleStyleClient; import mx.core.mx_internal; use namespace mx_internal; //-------------------------------------- // Styles //-------------------------------------- include "../../styles/metadata/PaddingStyles.as"; /** * Gap between the label and icon, in pixels. * * @default 2 * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name="horizontalGap", type="Number", format="Length", inherit="no")] /** * Number of pixels between the column header's bottom border * and the bottom of the sort item renderer. * * @default 3 * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name="paddingBottom", type="Number", format="Length", inherit="no")] /** * Number of pixels between the column header's top border * and the top of the sort item renderer. * * @default 3 * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name="paddingTop", type="Number", format="Length", inherit="no")] /** * * Color of text when the sort is a proposed sort. * * @default 0x999999 * * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name="proposedColor", type="uint", format="Color", inherit="yes")] //-------------------------------------- // Skins //-------------------------------------- /** * The class to use as the skin for the arrow that indicates the column sort * direction. * *
The default skin class is based on the theme. For example, with the Halo theme,
* the default skin class is mx.skins.halo.DataGridSortArrow
. For the Spark theme, the default skin
* class is mx.skins.spark.DataGridSortArrow
.
You can override the default sort item renderer by creating a custom
* sort item renderer.
* There are no special requirements for the sort item renderer, but Adobe
* suggests that the sort item renderer call the getFieldSortInfo()
method
* in the override of the commitProperties()
method
* to fetch the sort information so that it can display the icon and text appropriately.
You can customize when the sorting gets triggered by dispatching the
* AdvancedDataGridEvent.SORT
event.
sortFontFamily
, sortFontSize
, sortFontStyle
,
* and sortFontWeight
.
*
* @langversion 3.0
* @playerversion Flash 9
* @playerversion AIR 1.1
* @productversion Flex 3
*/
protected function getFontStyles():void
{
// 1. If only there was binding between styles ...
// 2. Is there a way to avoid this in the sort item renderer itself so
// that custom sort item renderers get it for free as opposed to
// manually including it, similar to what we did for styleFunctions.
// - We considered subcomponent style hookups i.e. using a styleProxy
// mechanism, but it works only for non-inheriting styles.
var gridStyle:* = undefined;
if (grid)
{
gridStyle = grid.getStyle("sortFontFamily");
if (gridStyle !== undefined)
setStyle("fontFamily", gridStyle);
gridStyle = grid.getStyle("sortFontSize");
if (gridStyle !== undefined)
setStyle("fontSize", gridStyle);
gridStyle = grid.getStyle("sortFontStyle");
if (gridStyle !== undefined)
setStyle("fontStyle", gridStyle);
gridStyle = grid.getStyle("sortFontWeight");
if (gridStyle !== undefined)
setStyle("fontWeight", gridStyle);
}
}
/**
* Returns the sort information for this column from the AdvancedDataGrid control
* so that the control can display the column's number in the sort sequence,
* and whether the sort is ascending or descending.
* The sorting information is represented by an instance of the SortInfo class,
* where each column in the AdvancedDataGrid control has an associated
* SortInfo instance.
*
* @return A SortInfo instance.
*
* @see mx.controls.advancedDataGridClasses.SortInfo
*
* @langversion 3.0
* @playerversion Flash 9
* @playerversion AIR 1.1
* @productversion Flex 3
*/
protected function getFieldSortInfo():SortInfo
{
// Parent is the header renderer.
if (grid && parent is IDropInListItemRenderer)
{
var listData:AdvancedDataGridListData = (parent as IDropInListItemRenderer).listData
as AdvancedDataGridListData;
if (listData && listData.columnIndex != -1)
return grid.getFieldSortInfo(grid.columns[listData.columnIndex]);
}
return null;
}
/**
* Returns a reference to the associated AdvancedDataGrid control.
*
* @return The AdvancedDataGrid control instance.
*
* @langversion 3.0
* @playerversion Flash 9
* @playerversion AIR 1.1
* @productversion Flex 3
*/
protected function get grid():AdvancedDataGrid
{
if (parent && IUIComponent(parent).owner
&& IUIComponent(parent).owner is AdvancedDataGrid)
return IUIComponent(parent).owner as AdvancedDataGrid;
else
return null;
}
} // end class AdvancedDataGridSortItemRenderer
}