Quintiq file version 2.0
|
#parent: CustomDrawComponent/CustomDrawDataLayerLabels
|
Response OnDrawObject (
|
Node object
|
) id:Response_CustomDrawComponent_CustomDrawDataLayerLabels_OnDrawObject
|
{
|
#keys: '[11660.0.305008485]'
|
Body:
|
[*
|
// Draw node labels
|
if ( not isnull( DataHolderView.Data() ) )
|
{
|
//Set font color
|
surface.Font().Name( DataHolderView.Data().FontName() );
|
surface.Font().Size(DataHolderView.Data().FontSize() )
|
surface.Font().Bold( true );
|
|
color := Color::Color(0, 0, 0);
|
if ( object.TextColor() <> '' )
|
{
|
color := guard( Color::Color( object.TextColor() ), ColorScheme.NodeText() );
|
}
|
surface.TextColor( color );
|
|
if ( text = '' )
|
{
|
text := object.Name();
|
}
|
|
fontheight := DataHolderView.Data().FontSize() + 3; // +3 needed to make text actually fit in fontheight
|
fontheight := ceil( fontheight / CustomDrawComponent.ZoomY() ) // Make fontheight independent of zoom level
|
rows := text.Tokenize( String::NewLine() ).Size();
|
maxlength := max( text.Tokenize( String::NewLine() ), Elements, e, e.Length() )
|
width := region.Width();
|
totalwidth := width * ceil( maxlength / 2 ) ; //assume each width only fits 3 chars
|
offset := [Number] ( ( totalwidth - width ) / 2 );
|
|
y := region.Height();
|
if ( object.IsTextTop() )
|
{
|
y := region.Top() - ( rows * fontheight );
|
}
|
|
if( object.IsNameVisible() )
|
{
|
textformat := TextFormat::Construct();
|
textformat.AlignMiddle().AlignCenter().NoEndEllipsis();
|
|
surface.Text( region.Left() - offset, y , totalwidth, ( fontheight * rows ), text, textformat )
|
}
|
}
|
*]
|
DefinitionID: 'Responsedef_CustomDrawDataLayer_OnDrawObject'
|
}
|