yanweiyuan3
2023-08-09 98db93a55d7079e89c706c18b15eeaecd0ec539a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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'
}