////////////////////////////////////////////////////////////////////////////////
//
// SpecificationEvent  -    
//
////////////////////////////////////////////////////////////////////////////////
#include "stdafx.h" 
#include "eventsAuto.h"

#ifndef _SPECIFICATIONEVENT_H
#include "SpecificationEvent.h"
#endif

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif  

////////////////////////////////////////////////////////////////////////////////
//
// SpecificationEvent  -    
//
////////////////////////////////////////////////////////////////////////////////

//-------------------------------------------------------------------------------
//
// ---
SpecificationEvent::SpecificationEvent( LPUNKNOWN pObject, LPDISPATCH doc, bool selfAdvise /*true*/ )
  : BaseEvent( pObject, DIID_ksSpecificationNotify, doc, -1, NULL, selfAdvise )
{  
}


//-------------------------------------------------------------------------------
//
// ---
SpecificationEvent::~SpecificationEvent()
{
}


//-------------------------------------------------------------------------------
//
// ---
BEGIN_EVENTSINK_MAP(SpecificationEvent, BaseEvent)
	ON_EVENT (SpecificationEvent, (unsigned int)-1, ssTuningSpcStyleBeginChange,   TuningSpcStyleBeginChange,   VTS_BSTR VTS_I4)      
	ON_EVENT (SpecificationEvent, (unsigned int)-1, ssTuningSpcStyleChange,        TuningSpcStyleChange,        VTS_BSTR VTS_I4 VTS_BOOL)     
	ON_EVENT (SpecificationEvent, (unsigned int)-1, ssChangeCurrentSpcDescription, ChangeCurrentSpcDescription, VTS_BSTR VTS_I4)    
	ON_EVENT (SpecificationEvent, (unsigned int)-1, ssSpcDescriptionAdd,           SpcDescriptionAdd,           VTS_BSTR VTS_I4)              
	ON_EVENT (SpecificationEvent, (unsigned int)-1, ssSpcDescriptionRemove,        SpcDescriptionRemove,        VTS_BSTR VTS_I4)           
	ON_EVENT (SpecificationEvent, (unsigned int)-1, ssSpcDescriptionBeginEdit,     SpcDescriptionBeginEdit,     VTS_BSTR VTS_I4)        
	ON_EVENT (SpecificationEvent, (unsigned int)-1, ssSpcDescriptionEdit,          SpcDescriptionEdit,          VTS_BSTR VTS_I4 VTS_BOOL)       
	ON_EVENT (SpecificationEvent, (unsigned int)-1, ssSynchronizationBegin,        SynchronizationBegin,        VTS_NONE)
  ON_EVENT (SpecificationEvent, (unsigned int)-1, ssSynchronization,             Synchronization,             VTS_NONE)
  ON_EVENT (SpecificationEvent, (unsigned int)-1, ssBeginCalcPositions,          BeginCalcPositions,          VTS_NONE)
  ON_EVENT (SpecificationEvent, (unsigned int)-1, ssCalcPositions,               CalcPositions,               VTS_NONE)
  ON_EVENT (SpecificationEvent, (unsigned int)-1, ssBeginCreateObject,           BeginCreateObject,           VTS_I4)
END_EVENTSINK_MAP() 


//-------------------------------------------------------------------------------
// ssTuningSpcStyleBeginChange -    
// ---
VARIANT_BOOL SpecificationEvent::TuningSpcStyleBeginChange( LPCTSTR libName, long numb )
{ 
  if ( IsSelfAdvise() && theApp.m_mes_SPC )
  {
    CString str;
    str.Format( "%s --> SpecificationEvent::TuningSpcStyleBeginChange\nlibName = %s\nnumb = %i", m_libName, libName, numb ); 
    str += "\n  = " + GetDocName();
    return !!kompas->ksYesNo( str.GetBuffer(0) ); 
  }
  return true; 
}


//-------------------------------------------------------------------------------
// ssTuningSpcStyleChange -   
// ---
VARIANT_BOOL SpecificationEvent::TuningSpcStyleChange( LPCTSTR libName, long numb, BOOL isOk )
{
  if ( IsSelfAdvise() && theApp.m_mes_SPC )
  {
    CString str;
    str.Format( "%s --> SpecificationEvent::TuningSpcStyleChange\nlibName = %s\nnumb = %i\nisOk = %s", m_libName, libName, numb, isOk ? "TRUE" : "FALSE" );
    str += "\n  = " + GetDocName();
    kompas->ksMessage( str.GetBuffer(0) );
  }
  return true;      
}


//-------------------------------------------------------------------------------
// ssChangeCurrentSpcDescription -    
// ---
VARIANT_BOOL SpecificationEvent::ChangeCurrentSpcDescription( LPCTSTR libName, long numb )
{ 
  if ( IsSelfAdvise() && theApp.m_mes_SPC )
  {
    CString str;
    str.Format( "%s --> SpecificationEvent::ChangeCurrentSpcDescription\nlibName = %s\nnumb = %i", m_libName, libName, numb ); 
    str += "\n  = " + GetDocName();
    kompas->ksMessage( str.GetBuffer(0) );
  }
  return true; 
}


//-------------------------------------------------------------------------------
// ssSpcDescriptionAdd -   
// ---
VARIANT_BOOL SpecificationEvent::SpcDescriptionAdd( LPCTSTR libName, long numb )
{ 
  if ( IsSelfAdvise() && theApp.m_mes_SPC )
  {
    CString str;
    str.Format( "%s --> SpecificationEvent::SpcDescriptionAdd\nlibName = %s\nnumb = %i", m_libName, libName, numb ); 
    str += "\n  = " + GetDocName();
    kompas->ksMessage( str.GetBuffer(0) );
  }
  return true;
}


//-------------------------------------------------------------------------------
// ssSpcDescriptionRemove -   
// ---
VARIANT_BOOL SpecificationEvent::SpcDescriptionRemove( LPCTSTR libName, long numb )
{ 
  if ( IsSelfAdvise() && theApp.m_mes_SPC )
  {
    CString str;
    str.Format( "%s --> SpecificationEvent::SpcDescriptionRemove\nlibName = %s\nnumb = %i", m_libName, libName, numb ); 
    str += "\n  = " + GetDocName();
    kompas->ksMessage( str.GetBuffer(0) );
  }
  return true;
}


//-------------------------------------------------------------------------------
// ssSpcDescriptionBeginEdit -    
// ---
VARIANT_BOOL SpecificationEvent::SpcDescriptionBeginEdit( LPCTSTR libName, long numb )
{ 
  if ( IsSelfAdvise() && theApp.m_mes_SPC )
  {
    CString str;
    str.Format( "%s --> SpecificationEvent::SpcDescriptionBeginEdit\nlibName = %s\nnumb = %i", m_libName, libName, numb ); 
    str += "\n  = " + GetDocName();
    return !!kompas->ksYesNo( str.GetBuffer(0) ); 
  }
  return true; 
}


//-------------------------------------------------------------------------------
// ssSpcDescriptionEdit -   
// ---
VARIANT_BOOL SpecificationEvent::SpcDescriptionEdit( LPCTSTR libName, long numb, BOOL isOk  )
{
  if ( IsSelfAdvise() && theApp.m_mes_SPC )
  {
    CString str;
    str.Format( "%s --> SpecificationEvent::SpcDescriptionEdit\nlibName = %s\nnumb = %i\nisOk = %s", m_libName, libName, numb, isOk ? "TRUE" : "FALSE" );
    str += "\n  = " + GetDocName();
    kompas->ksMessage( str.GetBuffer(0) );
  }
  return true; 
}


//-------------------------------------------------------------------------------
// ssSynchronizationBegin -  
// ---
VARIANT_BOOL SpecificationEvent::SynchronizationBegin()
{ 
  if ( IsSelfAdvise() && theApp.m_mes_SPC )
  {
    CString str( m_libName + " --> SpecificationEvent::SynchronizationBegin" );
    str += "\n  = " + GetDocName();
    return !!kompas->ksYesNo( str.GetBuffer(0) );
  }
  return true;
}


//-------------------------------------------------------------------------------
// ssSynchronization -  
// ---
VARIANT_BOOL SpecificationEvent::Synchronization()
{ 
  if ( IsSelfAdvise() && theApp.m_mes_SPC )
  {
    CString str( m_libName + " --> SpecificationEvent::Synchronization" );
    str += "\n  = " + GetDocName();
    kompas->ksMessage( str.GetBuffer(0) );
  }
  return true;
}


//-------------------------------------------------------------------------------
// ssBeginCalcPositions -    
// ---
VARIANT_BOOL SpecificationEvent::BeginCalcPositions()
{ 
  if ( IsSelfAdvise() && theApp.m_mes_SPC )
  {
    CString str( m_libName + " --> SpecificationEvent::BeginCalcPositions" );
    str += "\n  = " + GetDocName();
    return !!kompas->ksYesNo( str.GetBuffer(0) );
  }
  return true;
}


//-------------------------------------------------------------------------------
// ssCalcPositions -    
// ---
VARIANT_BOOL SpecificationEvent::CalcPositions()
{ 
  if ( IsSelfAdvise() && theApp.m_mes_SPC )
  {
    CString str( m_libName + " --> SpecificationEvent::CalcPositions" );
    str += "\n  = " + GetDocName();
    kompas->ksMessage( str.GetBuffer(0) );
  }
  return true;
}


//-------------------------------------------------------------------------------
// ssBeginCreateObject -     (    ) 
// ---
VARIANT_BOOL SpecificationEvent::BeginCreateObject( long typeObj )
{
  if ( IsSelfAdvise() && theApp.m_mes_SPC )
  {
    CString str;
    str.Format( "%s --> SpecificationEvent::BeginCreateObject\ntypeObj = %i", m_libName, typeObj );
    str += "\n  = " + GetDocName();
    return !!kompas->ksYesNo( str.GetBuffer(0) );
  }
  return true;
}
