Example #1
0
//+++-S-cf-------------------------------------------------------------------
//  NAME:       DrawArrow()
//  DESC:       Draw arrow
//  PARAMETERS: CHART_HPAINT hp, 
//              int pos,
//              bool over
//  RETURN:     None
//----------------------------------------------------------------------E-+++
void wxLegend::DrawArrow(
    CHART_HPAINT hp, 
    int pos,
    bool over
)
{    
    //-----------------------------------------------------------------------
    // Get actual configuration
    //-----------------------------------------------------------------------
    wxBrush oldBrush = hp->GetBrush();
    wxPen oldPen = hp->GetPen();
    
    //-----------------------------------------------------------------------
    // if mouse over use different colours
    //-----------------------------------------------------------------------
    
    if (over)
    {        
        hp->SetBrush( *wxBLACK_BRUSH );
        hp->SetPen( *wxBLACK_PEN );
    }
    else
    {
        hp->SetBrush( *wxGREY_BRUSH );
        hp->SetPen( *wxBLACK_PEN );
    }
    
    if ( pos == ARROW_DOWN )
    {
        //-------------------------------------------------------------------
        // If mouse position has change than redraw arrow
        //-------------------------------------------------------------------
        if (m_ArrowDown.m_sel != over)
        {
            DrawArrow(hp, m_ArrowDown.m_x, m_ArrowDown.m_y, 8, pos, over);
        }
    }
    if ( pos == ARROW_UP )
    {
        //-------------------------------------------------------------------
        // If mouse position has change than redraw arrow
        //-------------------------------------------------------------------
        if (m_ArrowUp.m_sel != over)
        {
            DrawArrow(hp, m_ArrowUp.m_x, m_ArrowUp.m_y, 8, pos, over);
        }
    }
        
    //-----------------------------------------------------------------------
    // Set old colours
    //-----------------------------------------------------------------------
    hp->SetBrush( oldBrush );
    hp->SetPen( oldPen );
    
}
Example #2
0
//+++-S-cf-------------------------------------------------------------------
//	NAME:		Draw()
//	DESC:		Draw Label Area
//	PARAMETERS:	wxDC* dc,
//				int x,
//				int y,
//				ChartString lbl,
//				POSITION pos = UP
//	RETURN:		None
//----------------------------------------------------------------------E-+++
void wxLabel::Draw(
    CHART_HPAINT hp,
	int x,
	int y,
    ChartColor c,
	wxString& lbl,
	LABEL_POSITION pos
)
{
	//-----------------------------------------------------------------------
	// Get actual configuration
	//-----------------------------------------------------------------------
    wxFont oldFont = hp->GetFont();
    wxBrush oldBrush = hp->GetBrush();
    wxPen oldPen = hp->GetPen();

	//-----------------------------------------------------------------------
	// Set new values
	//-----------------------------------------------------------------------
	wxFont font( 8, wxROMAN, wxNORMAL, wxNORMAL );
    hp->SetFont( font );
    hp->SetBrush( wxBrush(c, wxSOLID) );
    hp->SetPen( wxPen(LBL_LINE_COL, 1, wxSOLID) );

	//-----------------------------------------------------------------------
	// Get the size of the label for the specify font
	//-----------------------------------------------------------------------
	int w, h;
    hp->GetTextExtent( lbl, &w, &h );

	//-----------------------------------------------------------------------
	// Add boarder
	//-----------------------------------------------------------------------
	w += 5;
	h += 5;

	//-----------------------------------------------------------------------
	// Get the left-top rectangle point
	//-----------------------------------------------------------------------
	int xr = x, yr = y;
	if ( pos & UP )
		yr -= LBL_GAP;
	if ( pos & DOWN )
		yr += LBL_GAP;
	if ( pos & LEFT )
		xr -= LBL_GAP;
	if ( pos & RIGHT )
		xr += LBL_GAP;

	//-----------------------------------------------------------------------
	// Draw all
	//-----------------------------------------------------------------------
    hp->DrawRectangle( xr, yr, w, h );
	if ( pos & DOWN )
        hp->DrawLine( x, y, xr + w/2, yr );
	else
        hp->DrawLine( x, y, xr + w/2, yr + h);
    hp->DrawText( lbl, xr+2, yr );


	//-----------------------------------------------------------------------
	// Set old configuration
	//-----------------------------------------------------------------------
    hp->SetFont( oldFont );
    hp->SetBrush( oldBrush );
    hp->SetPen( oldPen );
}