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 ButtonPanel::DrawButton(wxPaintDC &dc)
{
	int totalWidth=0;
	int maxHeight = m_playButton->GetSize().GetHeight();
	totalWidth+=m_playButton->GetSize().GetWidth();
	totalWidth+=m_previousButton->GetSize().GetWidth();
	totalWidth+=m_stopButton->GetSize().GetWidth();
	totalWidth+=m_nextButton->GetSize().GetWidth();
	totalWidth+=m_browseButton->GetSize().GetWidth();
	totalWidth+=m_slider->GetSize().GetWidth();
	totalWidth+=25;
	
	wxSize size = GetSize();

	// draw background
	wxBitmap bg = wxGetBitmapFromMemory(panel_background_bmp, 
			sizeof(panel_background_bmp));
	for(int x=0; x<size.GetWidth(); x+=bg.GetWidth())
		dc.DrawBitmap(bg, x, 0, true);
	
	// previous
	int x = (size.GetWidth()-totalWidth)/2;
	wxSize buttonSize = m_previousButton->GetSize();
	int y = (maxHeight-buttonSize.GetHeight())/2;
	m_previousButton->Move(wxPoint(x,y));

	// stop
	x = x + buttonSize.GetWidth()+5;
	buttonSize = m_stopButton->GetSize();
	y = (maxHeight-buttonSize.GetHeight())/2;
	m_stopButton->Move(wxPoint(x,y));
	
	// play
	x = x + buttonSize.GetWidth()+5;
	buttonSize = m_playButton->GetSize();
	y = (maxHeight-buttonSize.GetHeight())/2;
	m_playButton->Move(wxPoint(x,y));
	
	// next
	x = x + buttonSize.GetWidth()+5;
	buttonSize = m_nextButton->GetSize();
	y = (maxHeight-buttonSize.GetHeight())/2;
	m_nextButton->Move(wxPoint(x,y));
	
	// browse
	x = x + buttonSize.GetWidth()+10;
	buttonSize = m_browseButton->GetSize();
	y = (maxHeight-buttonSize.GetHeight())/2;
	m_browseButton->Move(wxPoint(x,y));
	
	// volume slider
	x = x + buttonSize.GetWidth()+20;
	buttonSize = m_slider->GetSize();
	y = (maxHeight-buttonSize.GetHeight())/2;
	m_slider->Move(wxPoint(x,y));
}
Example #3
0
void gcProgressBar::doImgPaint(wxPaintDC& dc)
{
	int h = GetSize().GetHeight();
	int w = GetSize().GetWidth();
#ifdef WIN32 // unused AFAIK
	int ih = m_imgProg->GetSize().GetHeight();
#endif
	int iw = m_imgProg->GetSize().GetWidth();

	uint32 wp = w*m_uiProg/100;

	wxImage scaled = m_imgProg->Scale(iw, h);
	wxBitmap norm = GetGCThemeManager()->getSprite(scaled, "progressbar", "Norm");
	wxBitmap nedge = GetGCThemeManager()->getSprite(scaled, "progressbar", "NormEdge");
	wxBitmap empty = GetGCThemeManager()->getSprite(scaled, "progressbar", "Empty");

	wxBitmap   tmpBmp(w, h);
	wxMemoryDC tmpDC(tmpBmp);

	tmpDC.SetBrush(wxBrush(wxColor(255,0,255)));
	tmpDC.SetPen( wxPen(wxColor(255,0,255),1) );
	tmpDC.DrawRectangle(0,0,w,h);


	uint32 neWidth = nedge.GetWidth();
	wxColor c(255,0,255);

	if (wp == 0)
	{
		//dont do any thing
	}
	else if (wp <= neWidth)
	{
		wxBitmap left = nedge.ConvertToImage().GetSubImage(wxRect(neWidth-wp,0,neWidth,h));
		tmpDC.DrawBitmap(left, 0, 0, true);
	}
	else
	{
		wxBitmap left(wp-neWidth, h);
		
		gcImage::tileImg(left, norm, &c);

		tmpDC.DrawBitmap(left, 0, 0, true);
		tmpDC.DrawBitmap(nedge, wp-neWidth, 0, true);
	}

	wxBitmap right(w-wp, h);
	gcImage::tileImg(right, empty, &c);
	tmpDC.DrawBitmap(right, wp,0,true);

	tmpDC.SelectObject(wxNullBitmap);

	doExtraImgPaint(tmpBmp, w, h);

	dc.DrawBitmap(tmpBmp, 0,0, true);
}
Example #4
0
void MyVideoCaptureWindow::DoPaint( wxPaintDC& dc )
{
    wxVideoCaptureWindowBase::DoPaint(dc);

    if (!IsDeviceConnected())
    {
        // The window is blank when disconnected so we might as well
        // give a hint to people that they need to connect first.
        wxBitmap bmp = wxArtProvider::GetBitmap(wxART_MISSING_IMAGE, wxART_OTHER, wxSize(32, 32));
        wxSize clientSize(GetClientSize());

        wxString txt(wxT("Please select a capture device"));
        wxSize txtSize = dc.GetTextExtent(txt);

        dc.DrawText(txt,   clientSize.GetWidth()/2  - txtSize.GetWidth()/2,
                           clientSize.GetHeight()/2 - txtSize.GetHeight());
        dc.DrawBitmap(bmp, clientSize.GetWidth()/2  - bmp.GetWidth()/2,
                           clientSize.GetHeight()/2 + 4);
    }
}
Example #5
0
void PeakMeter::OnSized( wxPaintDC& dc )
{
	m_colorBack.Set(wxT("#DDE1E6"));
	dc.SetBackground(wxBrush(m_colorBack));
	dc.Clear();

	wxRect rc = GetClientRect();

	int rw = rc.GetWidth();
	int rh = rc.GetHeight();

	// draw meter
	wxBitmap bmp = wxGetBitmapFromMemory(meter_bmp, sizeof(meter_bmp));
	int bw = bmp.GetWidth();
	int bh = bmp.GetHeight();

	m_meterBitmapX = (rw-bw)/2;
	m_meterBitmapY = (rh-bh)/2;
	dc.DrawBitmap(bmp, m_meterBitmapX, m_meterBitmapY, true);

	// draw repeat button
	int x = m_meterBitmapX+20;

	if ( m_repeatButton == NULL )
	{
		wxBitmap bmp1 = wxGetBitmapFromMemory(repeat_all_bmp,
											  sizeof(repeat_all_bmp));
		wxBitmap bmp2 = wxGetBitmapFromMemory(repeat_all_hover_bmp,
											  sizeof(repeat_all_hover_bmp));
		m_repeatButton= new GButton(this, wxID_ANY,
									wxDefaultPosition, bmp1, bmp2);
		m_repeatButton->SetToolTip(wxT("Choose Repeat mode (Repeat All)"));
		Connect(m_repeatButton->GetId(), wxEVT_COMMAND_GBUTTON,
				(wxObjectEventFunction) (wxEventFunction) &PeakMeter::OnRepeat);
	}
	m_repeatButton->Move(x, m_meterBitmapY+25);

	if ( m_playModeButton == NULL )
	{
		wxBitmap bmp1 = wxGetBitmapFromMemory(play_mode_normal_bmp,
											  sizeof(play_mode_normal_bmp));
		wxBitmap bmp2 = wxGetBitmapFromMemory(play_mode_normal_hover_bmp,
											  sizeof(play_mode_normal_hover_bmp));
		m_playModeButton= new GButton(this, wxID_ANY,
									  wxDefaultPosition, bmp1, bmp2);
		m_playModeButton->SetToolTip(wxT("Choose Play mode"));
	}
	m_playModeButton->Move(x, m_meterBitmapY+45);

	// draw convert button
	bmp = wxGetBitmapFromMemory(button_bmp, sizeof(button_bmp));
	int bw2 = bmp.GetWidth();
	bh = bmp.GetHeight();

	x = m_meterBitmapX-bw2-10;
	if ( m_convertButton == NULL )
	{
		wxBitmap bmp1 = wxGetBitmapFromMemory(convert_bmp,
											  sizeof(convert_bmp));
		wxBitmap bmp2 = wxGetBitmapFromMemory(convert_hover_bmp,
											  sizeof(convert_hover_bmp));
		wxBitmap bmp3 = wxGetBitmapFromMemory(convert_clicked_bmp,
											  sizeof(convert_clicked_bmp));
		m_convertButton= new GButton(this, wxID_ANY,
									 wxDefaultPosition, bmp1, bmp2, bmp3);
	}
	m_convertButton->Move(x, m_meterBitmapY+5);

	dc.DrawBitmap(bmp, x, m_meterBitmapY+40, true);

	x = m_meterBitmapX+bw+10;
	dc.DrawBitmap(bmp, x, m_meterBitmapY+5, true);
	dc.DrawBitmap(bmp, x, m_meterBitmapY+40, true);
}