//
// C++ Implementation: gplane
//
// Description: 
//
//
// Author: Andre Roth <andre@dreamlab.net>, (C) 2005
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "gplane.h"
#include "wxg.h"
#include "graphicscontext.h"

using namespace goeland_wx;

BEGIN_EVENT_TABLE( gPlane, wxScrolledWindow )
	EVT_PAINT	( gPlane::OnPaint )
	EVT_LEFT_DOWN	( gPlane::OnMouseLeftDown )
	EVT_LEFT_UP	( gPlane::OnMouseLeftUp )
	EVT_MOTION	( gPlane::OnMouseMove )
END_EVENT_TABLE( )

gPlane::gPlane( wxGFrame *frame, wxWindowID id, const wxPoint &pos, const wxSize &size )
 : wxScrolledWindow( (wxWindow *) frame, id, pos, size, wxSUNKEN_BORDER)
{
	SetBackgroundColour( *wxWHITE );
	this->frame = frame;

}


gPlane::~gPlane()
{
}


void gPlane::OnMouseLeftDown( wxMouseEvent &event )
{
	int x = event.GetX( ), y = event.GetY( );
	printf( "Mouse Down\n" );
	frame->leonardo->ButtonPressed( 1, x, y, event.m_shiftDown );
}


void gPlane::OnMouseLeftUp( wxMouseEvent &event )
{
	int x = event.GetX( ), y = event.GetY( );
	printf( "Mouse Up\n" );
	frame->leonardo->ButtonReleased( 1, x, y, event.m_shiftDown );
}

void gPlane::OnMouseMove( wxMouseEvent &event )
{
	int x = event.GetX( ), y = event.GetY( );
// 	printf( "Mouse Move\n" );
	frame->leonardo->Motion( x, y, 1, event.m_shiftDown );
}

void gPlane::OnPaint( wxPaintEvent &WXUNUSED(event) )
{
	printf( "OnPaint\n" );
	goeland_base::GraphicsContext *gc = frame->leonardo->getGraphicsContext();
	if( gc )
	{
		gc->Start();
		frame->leonardo->draw( *gc );
		gc->Stop();
	}
}
