Quintiq file version 2.0
#parent: CustomDrawComponentContainer/Minimap
Response OnDrawLegend () id:Response_CustomDrawComponentContainer_Minimap_OnDrawLegend
{
  #keys: '[139164.4.307828177]'
  Body:
  [*
    if( not isnull( DataHolderRun.Data() ) )
    {
      max_x := max( DataHolderRun.Data(), Component.UIGraphNode, node, node.X() + node.Width() / 2 );
      max_y := max( DataHolderRun.Data(), Component.UIGraphNode, node, node.Y() + node.Height() / 2 );
      
      offset := 5;
      width := region.Width() - offset * 2;
      height := region.Height() - offset * 2;
      
      scale := minvalue( width / max_x, height / max_y );
      
      offset_x := ( width - max_x * scale ) / 2 + offset;
      offset_y := ( height - max_y * scale ) / 2 + offset;
      
      surface.Pen().Color( Color::Color( Color::Black(), 0.5 ) );
      traverse( DataHolderRun.Data(), Component, component )
      {
        color := Form.GetColor( component );
        
        node := component.UIGraphNode();
        surface.Brush().Color( Color::Color( color, 0.5 ) );
        surface.Draw( Rect::Construct( [Number] ( ( node.X() - node.Width() / 2 ) * scale + offset_x ),
                                       [Number] ( ( node.Y() - node.Height() / 2 ) * scale + offset_y ),
                                       [Number] ( node.Width() * scale ),
                                       [Number] ( node.Height() * scale ) ) );
      }
    }
  *]
  CanBindMultiple: false
  DefinitionID: 'Responsedef_CustomDrawLegendLayer_OnDrawLegend'
}
