View Full Version : DataGrid , Header Titles and Embed Fonts
Nicolas Prof
09-24-2008, 03:23 PM
I set Style to Headers by this code
somrDataGrid.setStyle("headerTextFormat", someTextFormat);
But how use Embed Fonts in Header Titles???
This doesnt work :
somrDataGrid.setStyle("embedFonts", true);
Nicolas Prof
10-01-2008, 10:32 AM
ok.
This is my solution:
package prof.ui.datagrid {
import fl.controls.dataGridClasses.HeaderRenderer;
/**
* @author Nicolas Prof
*/
public class HeaderRendererWithEmbed extends HeaderRenderer {
public function HeaderRendererWithEmbed() {
super();
}
override protected function drawLayout() : void {
var txtPad:Number = Number(getStyleValue("textPadding"));
textField.height = textField.textHeight + 4;
textField.visible = (label.length > 0);
textField.embedFonts = true;
var txtW:Number = textField.textWidth + 4;
var txtH:Number = textField.textHeight + 4;
var paddedIconW:Number = (icon == null) ? 0 : icon.width + 4;
var tmpWidth:Number = Math.max(0, Math.min(txtW, width - 2 * txtPad - paddedIconW));
if (icon != null) {
icon.x = width - txtPad - icon.width - 2;
icon.y = Math.round((height - icon.height) / 2);
}
textField.width = tmpWidth;
textField.x = txtPad;
textField.y = Math.round((height - textField.height) / 2);
background.width = width;
background.height = height;
}
}
}
Then:
var dg:DataGrid= new DataGrid();
_dg.setStyle("headerRenderer", HeaderRendererWithEmbed);
Enjoy!
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.