#include <windows.h>
#include <stdio.h>
#include <bncs_string.h>
#include <bncs_config.h>
#include "MDScripted.h"

bncs_string strUMDText;
bncs_string strSourceName;

// this nasty little macro to make our class visible to the outside world
EXPORT_BNCS_SCRIPT( MDScripted )

// constructor - equivalent to ApplCore STARTUP
MDScripted::MDScripted( bncs_client_callback * parent, const char * path ) : bncs_script_helper( parent, path )
{
	// show a panel from file p1.bncs_ui and we'll know it as our panel 1
	panelShow( 1, "p1.bncs_ui" );

	routerRegister(15,1,12);
	routerPoll(15,1,12);


	infoRegister(6,1,3);
	infoPoll(6,1,3);

	// you may need this call to set the size of this component 
	//  if it's used in a popup window 
//	setSize( 1024,668 );		// set the size explicitly
//	setSize( 1 );				// set the size to the same as the specified panel
}

// destructor - equivalent to ApplCore CLOSEDOWN
MDScripted::~MDScripted()
{
}

// all button pushes and notifications come here
void MDScripted::buttonCallback( buttonNotify *b )
{
	if( b->panel() == 1 )
	{
		switch( b->id() )
		{
			case 111:			
				textGet( "text", 1, 121, strUMDText );
				infoWrite(6,strUMDText,1);
				break;
			case 112:			
				textGet( "text", 1, 121, strUMDText );
				infoWrite(6,strUMDText,2);		
				break;
			case 113:			
				textGet( "text", 1, 121, strUMDText );
				infoWrite(6,strUMDText,3);		
				break;
			
			}
	}
}

// all revertives come here
int MDScripted::revertiveCallback( revertiveNotify * r )
{
	
	switch( r->device() )
	{
		
		case 15:
			
			strSourceName = r->sInfo();
			
			switch ( r->index() )
			{
				
				case 1:
					textPut("text",strSourceName,1,215);
					break;
			
				case 2:
					textPut("text",strSourceName,1,216);
					break;
			}

			break;

	}
	return 0;
}

// all database name changes come back here
void MDScripted::databaseCallback( revertiveNotify * r )
{
}

// all parent notifications come here i.e. when this script is just one 
//  component of another dialog then our host might want to tell us things
bncs_string MDScripted::parentCallback( parentNotify *p )
{
	return "";
}

// timer events come here
void MDScripted::timerCallback( int id )
{
}
