Example #1
0
void ImageResource::RenderPreview(wxPaintDC & dc, wxPanel & previewPanel, gd::Project & project)
{
    wxLogNull noLog; //We take care of errors.

    wxSize size = previewPanel.GetSize();

    //Checkerboard background
    dc.SetBrush(gd::CommonBitmapProvider::Get()->transparentBg);
    dc.DrawRectangle(0,0, size.GetWidth(), size.GetHeight());

    wxString fullFilename = GetAbsoluteFile(project);

    if ( !wxFile::Exists(fullFilename) )
        return;

    wxBitmap bmp( fullFilename, wxBITMAP_TYPE_ANY);
    if ( bmp.GetWidth() != 0 && bmp.GetHeight() != 0 && (bmp.GetWidth() > previewPanel.GetSize().x || bmp.GetHeight() > previewPanel.GetSize().y) )
    {
        //Rescale to fit in previewPanel
        float xFactor = static_cast<float>(previewPanel.GetSize().x)/static_cast<float>(bmp.GetWidth());
        float yFactor = static_cast<float>(previewPanel.GetSize().y)/static_cast<float>(bmp.GetHeight());
        float factor = std::min(xFactor, yFactor);

        wxImage image = bmp.ConvertToImage();
        if ( bmp.GetWidth()*factor >= 5 && bmp.GetHeight()*factor >= 5)
            bmp = wxBitmap(image.Scale(bmp.GetWidth()*factor, bmp.GetHeight()*factor));
    }

    //Display image in the center
    if ( bmp.IsOk() )
        dc.DrawBitmap(bmp,
                      (size.GetWidth() - bmp.GetWidth()) / 2,
                      (size.GetHeight() - bmp.GetHeight()) / 2,
                      true /* use mask */);
}
Example #2
0
void Board::DrawSquare (wxPaintDC &dc, int x, int y, Tetrominoes shape)
{
    static wxColour colors[] = { wxColour (0, 0, 0), wxColour (204, 102, 102),
                                 wxColour (102, 204, 102), wxColour (102, 102, 204),
                                 wxColour (204, 204, 102), wxColour (204, 102, 204),
                                 wxColour (102, 204, 204), wxColour (218, 170, 0)
                               };
    static wxColour light[] = { wxColour (0, 0, 0), wxColour (248, 159, 171),
                                wxColour (121, 252, 121), wxColour (121, 121, 252),
                                wxColour (252, 252, 121), wxColour (252, 121, 252),
                                wxColour (121, 252, 252), wxColour (252, 198, 0)
                              };
    static wxColour dark[] = { wxColour (0, 0, 0), wxColour (128, 59, 59),
                               wxColour (59, 128, 59), wxColour (59, 59, 128),
                               wxColour (128, 128, 59), wxColour (128, 59, 128),
                               wxColour (59, 128, 128), wxColour (128, 98, 0)
                             };
    wxPen pen (light[int (shape)]);
    pen.SetCap (wxCAP_PROJECTING);
    dc.SetPen (pen);
    dc.DrawLine (x, y + SquareHeight() - 1, x, y);
    dc.DrawLine (x, y, x + SquareWidth() - 1, y);
    wxPen darkpen (dark[int (shape)]);
    darkpen.SetCap (wxCAP_PROJECTING);
    dc.SetPen (darkpen);
    dc.DrawLine (x + 1, y + SquareHeight() - 1,
                 x + SquareWidth() - 1, y + SquareHeight() - 1);
    dc.DrawLine (x + SquareWidth() - 1,
                 y + SquareHeight() - 1, x + SquareWidth() - 1, y + 1);
    dc.SetPen (*wxTRANSPARENT_PEN);
    dc.SetBrush (wxBrush (colors[int (shape)]));
    dc.DrawRectangle (x + 1, y + 1, SquareWidth() - 2,
                      SquareHeight() - 2);
}
void TimeLogChart::DrawAxis(wxPaintDC &dc)
{
    const int MARKER_OFFSET = 5;

    dc.SetPen(*wxTRANSPARENT_PEN);
    dc.SetBrush(*wxWHITE_BRUSH);
    dc.DrawRectangle(m_axisBounds);
    dc.SetPen(wxPen(wxColour(*wxBLACK), 1, wxPENSTYLE_DOT));

    int topBound = m_axisBounds.GetTop();
    int leftBound = m_axisBounds.GetLeft();
    int rightBound = m_axisBounds.GetRight();
    int bottomBound = m_axisBounds.GetBottom();
    int dx = leftBound;

    wxFont savedFont = dc.GetFont();
    dc.SetFont(*m_valueFont);
    int n = m_logDuration -1;

    for (int i = 0; i <= n; i++)
    {
        dx = leftBound + (int)floor(i*m_axisBounds.GetWidth() / (double)n);
        if (i % m_logTickFrequency == 0)
        {
            dc.DrawLine(dx, topBound, dx, bottomBound);

            if (i % (m_logTickFrequency*2) == 0)
            {
                // draw axis marker
                wxString s = wxString::Format(wxT("%d secs"), (m_logDuration-i));
                wxSize ext = dc.GetTextExtent(s);
                dc.DrawText(s, dx - ext.GetWidth()/2, bottomBound + MARKER_OFFSET);
            }
        }
    }

    dc.DrawLine(dx, topBound, dx, bottomBound);

    int yValue = m_maxValue;
    int yValueSteps = (m_minValue-m_maxValue)/m_valueDivisions;
    int ySteps = ValueToPixel((m_maxValue - m_minValue)/m_valueDivisions);
    int dy = topBound;

    for (int n = 0; n < m_valueDivisions; n++)
    {
        dc.DrawLine(leftBound, dy, rightBound, dy);
        wxString s = wxString::Format(m_valueAxisFormat, (double)yValue/m_valueAxisScale);
        wxSize ext = dc.GetTextExtent(s);
        dc.DrawText(s, m_axisBounds.GetLeft()-ext.GetWidth() - MARKER_OFFSET, dy - ext.GetHeight()/2);

        dy += ySteps;
        yValue += yValueSteps;
    }

    dc.DrawLine(leftBound, bottomBound, rightBound, bottomBound);
    dc.SetFont(savedFont);
}
void SudokuSolverFrame::DrawBoardBackground(wxPaintDC &dc)
{
	unsigned int spSq = 0;
    unsigned int smallSide;
    unsigned int i,j;

    wxColour LGray;
    wxBrush LGrayBr;

    LGray.Set(210,210,210);
    LGrayBr.SetColour(LGray);

    wxSize sz = GameBoardPanel->GetClientSize();
    if (sz.x < sz.y)
        smallSide = sz.x;
    else
        smallSide = sz.y;

    spSq = smallSide / 9;
    smallSide -= 10;

        // Set the Brush and Pen to red
    dc.SetBrush( LGrayBr );
    dc.SetPen(*wxBLACK_PEN );
    // Draw rectangle 40 pixels wide and 40 high
    // with upper left corner at 10 , 10.

    for(i=0;i<9;i++)
        for(j=0;j<9;j++)
        {
            if(i == col && j == row)
                dc.SetBrush(*wxBLUE_BRUSH);
            else
                dc.SetBrush(LGrayBr);
            dc.DrawRectangle( 0 + spSq*i, 0 + spSq*j, spSq - 5, spSq - 5 );
        }

    wxColor Black(0,0,0);
    wxPen myBlackPen(Black,5,wxSOLID);
    dc.SetPen(myBlackPen);

    // Section Borders
    dc.DrawLine( 0, smallSide/3 - 2, smallSide, smallSide/3 - 2);
    dc.DrawLine( 0, smallSide*2/3 - 1, smallSide, smallSide*2/3 - 1);
    dc.DrawLine( smallSide/3 - 2, 0, smallSide/3 - 2, smallSide);
    dc.DrawLine( smallSide*2/3 - 1, 0, smallSide*2/3 - 1, smallSide);

    // Edge Borders
    dc.DrawLine( 0, 0, smallSide, 0);
    dc.DrawLine( 0, 0, 0, smallSide);
    dc.DrawLine( 0, smallSide, smallSide, smallSide);
    dc.DrawLine( smallSide, 0, smallSide, smallSide);

}
Example #5
0
void gcProgressBar::doHandPaint(wxPaintDC& dc)
{
	wxSize size = GetSize();
	uint32 w = size.GetWidth();
	uint32 h = size.GetHeight()-2;

	uint32 wp = w*m_uiProg/100;

	wxColour green(0, 255, 0);
	wxColour white(255, 255, 255);
	wxColour black(0, 0, 0);

	dc.SetPen(wxPen(green,1)); 
	dc.SetBrush(wxBrush(green));
	dc.DrawRectangle(0,0, wp, h);

	dc.SetPen(wxPen(white,1)); 
	dc.SetBrush(wxBrush(white));
	dc.DrawRectangle(wp,0, w, h);
}
Example #6
0
void THISCLASS::DrawTrigger(wxPaintDC &dc, int dw, int dh, double starttime, double stoptime) {
	int startx = ((starttime < 0) ? -5 : (int)floor(starttime * mViewScale + mViewOffset + 0.5));
	int stopx = ((stoptime < 0) ? dw + 5 : (int)floor(stoptime * mViewScale + mViewOffset + 0.5));
	dc.DrawRectangle(startx, 0, stopx - startx, dh);
}
void TimeLogChart::DrawBackground(wxPaintDC &dc)
{
    dc.SetPen(*wxGREY_PEN);
    dc.SetBackground(wxBrush(wxColour(0xffffff)));
    dc.DrawRectangle(m_backgroundBounds);
}