scigraphics::wcoord scigraphics::legend::drawGraphLegend( painter &Painter, wcoord y, const graph &Graph, const textStyle &Style ) { const wcoord TextHeight = Painter.textHeight( Graph.legend(), Style ); const wcoord XForExample = getRectangle().left() + textHorizontalIndent(); const wcoord ExampleWidth = Graph.legendExampleWidth(); const wcoord GraphLegendHeight = std::max( Graph.legendExampleHeight(), TextHeight ); Graph.drawLegendExample( Painter, wrectangle( wpoint( XForExample, y-GraphLegendHeight ), wpoint(XForExample+ExampleWidth,y) ) ); const wcoord XForText = XForExample + ExampleWidth + textHorizontalIndent(); Painter.drawTextW( Graph.legend(), wpoint( XForText, y-GraphLegendHeight/2 ), painter::HLeft|painter::VCenter, Style ); return GraphLegendHeight; }
bool scigraphics::legend::shouldDrawGraphLegend( const graph &Graph ) { if ( ! Graph.showLegend() ) return false; if ( Graph.legend().empty() ) return false; return true; }