void kwxAngularMeter::ConstructBackground()
{
    m_BackgroundDc.SelectObject(*membitmap);
    m_BackgroundDc.SetBackground(GetBackgroundColour());
    m_BackgroundDc.Clear();
    m_BackgroundDc.SetPen(*wxRED_PEN);
    //m_BackgroundDc.SetBrush(*wxTRANSPARENT_BRUSH);
    m_BackgroundDc.SetBrush(*wxTheBrushList->FindOrCreateBrush(*wxRED,wxSOLID));

    int w,h ;
    GetClientSize(&w,&h);

    ///////////////////

	//Rectangle

	//m_BackgroundDc.SetPen(*wxThePenList->FindOrCreatePen(m_cBorderColour, 1, wxSOLID));
	//m_BackgroundDc.DrawRectangle(0,0,w,h);

	//Fields
	DrawSectors(m_BackgroundDc) ;
	//Ticks
	if (m_nTick > 0)
		DrawTicks(m_BackgroundDc);
}
void kwxAngularMeter::OnPaint(wxPaintEvent& WXUNUSED(event))
{
	wxPaintDC old_dc(this);
	
	int w,h ;
	
	GetClientSize(&w,&h);

	/////////////////


	// Create a memory DC
	wxMemoryDC dc;
	dc.SelectObject(*membitmap);

	dc.SetBackground(*wxTheBrushList->FindOrCreateBrush(m_cBackColour,wxSOLID));
	dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(m_cBackColour,wxSOLID));
	dc.Clear();



    if (m_pPreviewBmp && m_pPreviewBmp->Ok())
		dc.DrawBitmap( *m_pPreviewBmp, 1, 1 );



	///////////////////

	//Rettangolo

	dc.SetPen(*wxThePenList->FindOrCreatePen(m_cBorderColour, 1, wxSOLID));
	dc.DrawRectangle(0,0,w,h);
	
	//settori
	DrawSectors(dc) ;

	//tacche
	if (m_nTick > 0)
		DrawTicks(dc);

	//indicatore lancetta

	DrawNeedle(dc);

	
	//testo valore
	if (m_bDrawCurrent) 
	{
		wxString valuetext;
		valuetext.Printf("%d",m_nRealVal);
		dc.SetFont(m_Font);
		dc.DrawText(valuetext, (w / 2) - 10, (h / 2) + 10);
	}

	// We can now draw into the memory DC...
	// Copy from this DC to another DC.
	old_dc.Blit(0, 0, w, h, &dc, 0, 0);
}
示例#3
0
void AngularMeter::OnPaint(wxPaintEvent &event)
{

	wxPaintDC old_dc(this);

//	wxPaintDC dc((wxWindow *) this);

	int w,h ;
	GetClientSize(&w,&h);

	if (w != _currentWidth || h != _currentHeight){
		delete (_memBitmap);
		_currentWidth = w;
		_currentHeight = h;
		_memBitmap = new wxBitmap(_currentWidth, _currentHeight);
	}
	/////////////////
	// Create a memory DC
	wxMemoryDC dc;
	dc.SelectObject(*_memBitmap);

	dc.SetBackground(*wxTheBrushList->FindOrCreateBrush(_backgroundColor,wxSOLID));
	dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(_backgroundColor,wxSOLID));
	dc.Clear();

	///////////////////
	//Rettangolo

	dc.SetPen(*wxThePenList->FindOrCreatePen(_borderColor, 1, wxSOLID));
	dc.DrawRectangle(0,0,w,h);

	//settori
	DrawSectors(dc) ;

	//tacche
	DrawTicks( dc );

	//indicatore lancetta


	DrawLabel(dc);

	//testo valore
	if (_shouldDrawCurrent) DrawValue(dc);

	DrawNeedle(dc);

	//blit into the real DC
	old_dc.Blit(0,0,_currentWidth,_currentHeight,&dc,0,0);
}
kwxAngularMeter::kwxAngularMeter(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size)
	: wxWindow(parent, id, pos, size, 0)
{

  if (parent)
    SetBackgroundColour(parent->GetBackgroundColour());
  else
    SetBackgroundColour(*wxLIGHT_GREY);

    //SetSize(size);
    SetAutoLayout(TRUE);
	Refresh();

	m_id = id;

	//Default values

	m_nScaledVal = 0;		//degrees
	m_nRealVal = 0;
	m_nTick = 0;	//number of notches
	m_nSec = 1;		//default number of sectors
	m_nRangeStart = 0;
	m_nRangeEnd = 220;
	m_nAngleStart = -20;
	m_nAngleEnd = 200;
	m_aSectorColor[0] = *wxWHITE;
//	m_cBackColour = *wxLIGHT_GREY;
	m_cBackColour = GetBackgroundColour() ;		//default background application
	m_cNeedleColour = *wxRED;	//indicator
	m_cBorderColour = GetBackgroundColour() ;
	m_dPI = 4.0 * atan(1.0);
	m_Font = *wxSWISS_FONT;	//font
	m_bDrawCurrent = true ;

	membitmap = new wxBitmap(size.GetWidth(), size.GetHeight()) ;

    m_BackgroundDc.SelectObject(*membitmap);
    m_BackgroundDc.SetBackground(parent->GetBackgroundColour());
    m_BackgroundDc.Clear();
    m_BackgroundDc.SetPen(*wxRED_PEN);
    //m_BackgroundDc.SetBrush(*wxTRANSPARENT_BRUSH);
    m_BackgroundDc.SetBrush(*wxTheBrushList->FindOrCreateBrush(*wxRED,wxSOLID));

    int w,h ;
    GetClientSize(&w,&h);

    ///////////////////

	//Rectangle

	//m_BackgroundDc.SetPen(*wxThePenList->FindOrCreatePen(m_cBorderColour, 1, wxSOLID));
	//m_BackgroundDc.DrawRectangle(0,0,w,h);

	//Fields
	DrawSectors(m_BackgroundDc) ;

	//Ticks
	if (m_nTick > 0)
		DrawTicks(m_BackgroundDc);



    //m_BackgroundDc.DrawRectangle(wxRect(10, 10, 100, 100));

	/////////////// TODO : Test for BMP image loading /////////////////
/*

	m_pPreviewBmp = NULL ;

    wxBitmap bitmap( 300, 300 );
    wxImage image = bitmap.ConvertToImage();

    image.Destroy();

    if ( !image.LoadFile( "thumbnail.bmp", wxBITMAP_TYPE_BMP ) )
        wxLogError(wxT("Can't load BMP image"));
    else
        m_pPreviewBmp = new wxBitmap( image );
*/
    m_bNeedRedrawBackground = false;

}