admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
Quintiq file version 2.0
#parent: CustomDrawComponentContainer/CustomDrawDataLayerLink
Response OnDrawObject (
  LibOpt_Link object
) id:Response_CustomDrawComponentContainer_CustomDrawDataLayerLink_OnDrawObject
{
  #keys: '[139164.3.980131598]'
  Body:
  [*
    scale_x := ValueHolderScaleX.Data();
    scale_y := ValueHolderScaleY.Data();
    
    // Fix issue that it thinks the Brush is already Black, but is actually White.
    // This prevents me from making the Brush black (as it thinks it is already Black).
    surface.Brush().Color( Color::White() );
    
    // Retrieve UI Color of Link
    color_string := object.TaskTransporter().UIColor();
    color := null( Color, owning );
    
    // Convert color code to Decimal, if its format is Hexadecimal
    if( color_string.SubString( 0, 1 ) = '#' )
    {
      color_num := LibOpt_Utility::GetColorFromHex( color_string.SubString( 1, color_string.Length() - 1 ) );
      color := Color::Color( color_num );
    }
    else
    {
      color := Color::Color( color_string );
    }
    
    // Set link color to grey, if the origin component cannot be called
    if( not object.GetOrigin().CanBeCalled() )
    {                               
      color := Color::Color( color, 0.5 );
    }  
    surface.Pen().Color( color );
    surface.Brush().Color( color );
    
    // Retrieve UI Style of Link
    style_string := object.TaskTransporter().UIStyle();
    style := PenSpecification::StyleNull();
    
    // Define the PenSpecification style depending on the UI Style of the Link
    if( style_string = 'Solid' )
    {
      style := PenSpecification::StyleSolid();
    }
    else if( style_string = 'Dashed' )
    {
      style := PenSpecification::StyleDashed();
    }
    else if( style_string = 'Dotted' )
    {
      style := PenSpecification::StyleDotted();
    }
    
    // Set the style of the Pen based on the PenSpecification style
    surface.Pen().Style( style );
    
    surface.Draw( shape );
    
    text := text.TrimBoth();
    if( text <> '' )
    {
      scale := minvalue( scale_x, scale_y );
      arrow_size := maxvalue( 3, 12 - maxvalue( 2, 2 / scale ) );
      arrow_size_x := [Number] ( arrow_size * scale / 2 / scale_x );
    
      // Get the relative X coordinate of the outgoing part
      x := object.First().First().X() - min( object, UIGraphArc.UIGraphArcPoint, p, p.X() - ifexpr( isnull( p.Next() ) and isnull( p.UIGraphArc().Next() ), arrow_size_x, 0 ) );
      
      origin := object.First().Origin()
      width := origin.Width() / ( origin.Outgoing( relsize ) + 1 );
      
      format := TextFormat::Construct();
      format.AlignCenter();
      format.AlignMiddle();
      
      surface.Fill( [Number] ( ( x - width / 2 ) * scale_x ),
                    0,
                    [Number] ( width * scale_x ),
                    [Number] ( 12 * scale_y ), Color::White() ); 
      
      surface.TextColor( color );
      surface.TextFit( [Number] ( ( x - width / 2 ) * scale_x ),
                       [Number] ( 2 * scale_y ),
                       [Number] ( width * scale_x ),
                       [Number] ( 10 * scale_y ),
                       text, 1, format );
    }
  *]
  CanBindMultiple: false
  DefinitionID: 'Responsedef_CustomDrawDataLayer_OnDrawObject'
}