void wxLCDWindow::DrawSegment(wxDC* dc, int digit, int seg, bool state) { int sl = m_segLen; int sw = m_segWidth; int x = DigitX(digit); int y = DigitY(digit); wxBrush brushOn(m_lightColr, wxSOLID); wxBrush brushOff(m_grayColr, wxSOLID); if (state) { dc->SetBrush(brushOn); } else { dc->SetBrush(brushOff); } dc->SetPen(wxPen(GetBackgroundColour(), 1, wxSOLID)); wxPoint points[4]; switch(seg) { case 0: points[0].x = x; points[0].y = y; points[1].x = x + sl; points[1].y = y; points[2].x = x + sl - sw; points[2].y = y + sw; points[3].x = x + sw; points[3].y = y + sw; break; case 5: y += 2 * sl - sw; points[0].x = x + sw; points[0].y = y; points[1].x = x + sl - sw; points[1].y = y; points[2].x = x + sl; points[2].y = y + sw; points[3].x = x; points[3].y = y + sw; break; case 4: y += sl; x += sl - sw; points[0].x = x; points[0].y = y + sw / 2; points[1].x = x + sw; points[1].y = y; points[2].x = x + sw; points[2].y = y + sl; points[3].x = x; points[3].y = y + sl - sw; break; case 2: x += sl - sw; points[0].x = x; points[0].y = y + sw; points[1].x = x + sw; points[1].y = y; points[2].x = x + sw; points[2].y = y + sl; points[3].x = x; points[3].y = y + sl - sw / 2; break; case 3: y += sl; points[0].x = x; points[0].y = y; points[1].x = x; points[1].y = y + sl; points[2].x = x + sw; points[2].y = y + sl - sw; points[3].x = x + sw; points[3].y = y + sw - sw / 2; break; case 1: points[0].x = x; points[0].y = y; points[1].x = x; points[1].y = y + sl; points[2].x = x + sw; points[2].y = y + sl - sw / 2; points[3].x = x + sw; points[3].y = y + sw; break; case 6: default: break; } if (seg < 6) { dc->DrawPolygon(4, points); } if (seg == 6) { y += sl - sw / 2; wxPoint p6[6]; p6[0].x = x; p6[0].y = y + sw / 2; p6[1].x = x + sw; p6[1].y = y; p6[2].x = x + sl - sw; p6[2].y = y; p6[3].x = x + sl; p6[3].y = y + sw / 2; p6[4].x = x + sl - sw; p6[4].y = y + sw; p6[5].x = x + sw; p6[5].y = y + sw; dc->DrawPolygon(6, p6); } if (seg == 7) { y += 2 * sl; x += sl; dc->DrawEllipse(x + 1, y - sw, sw, sw); } }
void kwxLCDDisplay::DrawSegment( wxDC *dc, int digit, int segment, bool state ) { int sl = mSegmentLen; int sw = mSegmentWidth; // int sp = mSpace; int x = DigitX( digit ); int y = DigitY( digit ); wxBrush brushOn( mLightColour, wxSOLID ); wxBrush brushOff( mGrayColour, wxSOLID ); if( state ) dc->SetBrush( brushOn ); else dc->SetBrush( brushOff ); dc->SetPen( wxPen( GetBackgroundColour(), 1, wxSOLID ) ); wxPoint points[4]; wxPoint p6[6]; switch( segment ) { case 0: { points[0].x = x; points[0].y = y; points[1].x = x + sl; points[1].y = y; points[2].x = x + sl - sw; points[2].y = y + sw; points[3].x = x + sw; points[3].y = y + sw; break; } case 1: { points[0].x = x; points[0].y = y; points[1].x = x; points[1].y = y + sl; points[2].x = x + sw; points[2].y = y + sl - sw / 2; points[3].x = x + sw; points[3].y = y + sw; break; } case 2: { x += sl - sw; points[0].x = x; points[0].y = y + sw; points[1].x = x + sw; points[1].y = y; points[2].x = x + sw; points[2].y = y + sl; points[3].x = x; points[3].y = y + sl - sw / 2; break; } case 3: { y += sl; points[0].x = x; points[0].y = y; points[1].x = x; points[1].y = y + sl; points[2].x = x + sw; points[2].y = y + sl - sw; points[3].x = x + sw; points[3].y = y + sw - sw / 2; break; } case 4: { y += sl; x += sl - sw; points[0].x = x; points[0].y = y + sw / 2; points[1].x = x + sw; points[1].y = y; points[2].x = x + sw; points[2].y = y + sl; points[3].x = x; points[3].y = y + sl - sw; break; } case 5: { y += 2 * sl - sw; points[0].x = x + sw; points[0].y = y; points[1].x = x + sl - sw; points[1].y = y; points[2].x = x + sl; points[2].y = y + sw; points[3].x = x; points[3].y = y + sw; break; } case 6: { y += sl - sw / 2; p6[0].x = x; p6[0].y = y + sw / 2; p6[1].x = x + sw; p6[1].y = y; p6[2].x = x + sl - sw; p6[2].y = y; p6[3].x = x + sl; p6[3].y = y + sw / 2; p6[4].x = x + sl - sw; p6[4].y = y + sw; p6[5].x = x + sw; p6[5].y = y + sw; break ; } default: break; } if( segment < 6 ) //segmento normale dc->DrawPolygon( 4, points ); else if ( segment == 6 ) //segmento centrale a 6 lati dc->DrawPolygon( 6, p6 ); else //comma { y += 2 * sl; x += sl; dc->DrawEllipse( x + 1, y - sw, sw, sw ); } }