matlab没有flexgrid控件怎么办
1个回答
2016-07-25
展开全部
估计你要自己重写grid了。下面是以前写的设置标题行背景色不同(headerBackgroundSkin)。看下是不是可以改下,计算出当前点击的单元格的位置和大小,然后填充,如果成功能希望能共享下源码,到时候联系我,谢谢。
package com.component.HeaderStyleDataGrid
{
import flash.display.GradientType;
import flash.display.Graphics;
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Matrix;
import mx.controls.DataGrid;
import mx.controls.dataGridClasses.DataGridColumn;
import mx.controls.dataGridClasses.DataGridHeader;
import mx.controls.listClasses.IListItemRenderer;
import mx.core.mx_internal;
import mx.skins.halo.DataGridHeaderBackgroundSkin;
import mx.styles.StyleManager;
import mx.utils.UIDUtil;
use namespace mx_internal;
public class CustomDataGridHeaderBackgroundSkin extends DataGridHeaderBackgroundSkin
{
public function CustomDataGridHeaderBackgroundSkin()
{
super();
}
private var columnBackgroundMap:Object = new Object();
override protected function updateDisplayList(w:Number, h:Number):void
{
super.updateDisplayList(w,h);
if(w == 0)
return;
var dataGridHeader:DataGridHeader = DataGridHeader(parent.parent);
var dataGrid:DataGrid = DataGrid(dataGridHeader.owner);
var visibleColumns:Array = dataGrid.getAllVisibleColumns();
var headerItems:Array = dataGridHeader.rendererArray;
for each(var column:DataGridColumn in visibleColumns)
{
var colors:Array = column.getStyle("headerColors");
var headerItem:IListItemRenderer = headerItems[column.colNum]
var x:Number = headerItem.x;
w = column.width;
var uid:String = UIDUtil.getUID(column);
var sprite:Sprite = columnBackgroundMap[uid];
if(sprite == null)
{
sprite = new Sprite();
parent.addChild(sprite);
columnBackgroundMap[uid] = sprite;
}
sprite.x = x;
if(colors != null)
{
var g:Graphics = sprite.graphics;
g.clear();
var matrix:Matrix = new Matrix();
matrix.createGradientBox(w, h + 1, Math.PI/2, 0, 0);
StyleManager.getColorNames(colors);
colors = [ colors[0], colors[0], colors[1] ];
var ratios:Array = [ 0, 60, 255 ];
var alphas:Array = [ 1.0, 1.0, 1.0 ];
g.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, matrix);
g.lineStyle(0, 0x000000, 0);
g.moveTo(0, 0);
g.lineTo(w, 0);
g.lineTo(w, h - 0.5);
g.lineStyle(0, getStyle("borderColor"), 100);
g.lineTo(0, h - 0.5);
g.lineStyle(0, 0x000000, 0);
g.endFill();
}
column.addEventListener("widthChanged",columnWidthChangedHandler);
}
}
private function columnWidthChangedHandler(event:Event):void
{
invalidateDisplayList();
}
}
}
package com.component.HeaderStyleDataGrid
{
import flash.display.GradientType;
import flash.display.Graphics;
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Matrix;
import mx.controls.DataGrid;
import mx.controls.dataGridClasses.DataGridColumn;
import mx.controls.dataGridClasses.DataGridHeader;
import mx.controls.listClasses.IListItemRenderer;
import mx.core.mx_internal;
import mx.skins.halo.DataGridHeaderBackgroundSkin;
import mx.styles.StyleManager;
import mx.utils.UIDUtil;
use namespace mx_internal;
public class CustomDataGridHeaderBackgroundSkin extends DataGridHeaderBackgroundSkin
{
public function CustomDataGridHeaderBackgroundSkin()
{
super();
}
private var columnBackgroundMap:Object = new Object();
override protected function updateDisplayList(w:Number, h:Number):void
{
super.updateDisplayList(w,h);
if(w == 0)
return;
var dataGridHeader:DataGridHeader = DataGridHeader(parent.parent);
var dataGrid:DataGrid = DataGrid(dataGridHeader.owner);
var visibleColumns:Array = dataGrid.getAllVisibleColumns();
var headerItems:Array = dataGridHeader.rendererArray;
for each(var column:DataGridColumn in visibleColumns)
{
var colors:Array = column.getStyle("headerColors");
var headerItem:IListItemRenderer = headerItems[column.colNum]
var x:Number = headerItem.x;
w = column.width;
var uid:String = UIDUtil.getUID(column);
var sprite:Sprite = columnBackgroundMap[uid];
if(sprite == null)
{
sprite = new Sprite();
parent.addChild(sprite);
columnBackgroundMap[uid] = sprite;
}
sprite.x = x;
if(colors != null)
{
var g:Graphics = sprite.graphics;
g.clear();
var matrix:Matrix = new Matrix();
matrix.createGradientBox(w, h + 1, Math.PI/2, 0, 0);
StyleManager.getColorNames(colors);
colors = [ colors[0], colors[0], colors[1] ];
var ratios:Array = [ 0, 60, 255 ];
var alphas:Array = [ 1.0, 1.0, 1.0 ];
g.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, matrix);
g.lineStyle(0, 0x000000, 0);
g.moveTo(0, 0);
g.lineTo(w, 0);
g.lineTo(w, h - 0.5);
g.lineStyle(0, getStyle("borderColor"), 100);
g.lineTo(0, h - 0.5);
g.lineStyle(0, 0x000000, 0);
g.endFill();
}
column.addEventListener("widthChanged",columnWidthChangedHandler);
}
}
private function columnWidthChangedHandler(event:Event):void
{
invalidateDisplayList();
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询