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

#ifndef _STAMPEVENT_H
#include "StampEvent.h"
#endif

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

////////////////////////////////////////////////////////////////////////////////
//
// StampEvent  -   
//
////////////////////////////////////////////////////////////////////////////////

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


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


//-------------------------------------------------------------------------------
//
// ---
BEGIN_EVENTSINK_MAP(StampEvent, BaseEvent)
	ON_EVENT (StampEvent, (unsigned int)-1, kdBeginEditStamp,     BeginEditStamp,     VTS_NONE)
	ON_EVENT (StampEvent, (unsigned int)-1, kdEndEditStamp,       EndEditStamp,       VTS_BOOL)
	ON_EVENT (StampEvent, (unsigned int)-1, kdStampCellDblClick,  StampCellDblClick,  VTS_I4)
	ON_EVENT (StampEvent, (unsigned int)-1, kdStampCellBeginEdit, StampCellBeginEdit, VTS_I4)
END_EVENTSINK_MAP()


//-----------------------------------------------------------------------------
// kdBeginEditStamp -   
// ---
afx_msg VARIANT_BOOL StampEvent::BeginEditStamp()
{
  if ( IsSelfAdvise() && theApp.m_mes_STAMP )
  {
    CString str( m_libName + " --> StampEvent::BeginEditStamp" );
    str += "\n  = " + GetDocName();
    return !!kompas->ksYesNo( str.GetBuffer(0) );
  }
  return true;
}


//-----------------------------------------------------------------------------
// kdEndEditStamp -   
// ---
afx_msg VARIANT_BOOL StampEvent::EndEditStamp( bool editResult )
{
  if ( IsSelfAdvise() && theApp.m_mes_STAMP )
  {
    CString str;
    str.Format( "%s --> StampEvent::EndEditStamp\neditResult = %s", m_libName, editResult ? "TRUE" : "FALSE" );
    str += "\n  = " + GetDocName();
    kompas->ksMessage( str.GetBuffer(0) );
  }
  return true;  
}


//-----------------------------------------------------------------------------
// kdStampCellDblClick -   
// ---
afx_msg VARIANT_BOOL StampEvent::StampCellDblClick( long number )
{
  if ( IsSelfAdvise() && theApp.m_mes_STAMP )
  {
    CString str;
    str.Format( "%s --> StampEvent::StampCellDblClick\nnumber = %i", m_libName, number );
    str += "\n  = " + GetDocName();
    return !!kompas->ksYesNo( str.GetBuffer(0) );
  }
  return true; 
}


//-----------------------------------------------------------------------------
// kdStampCellBeginEdit -    
// ---
afx_msg VARIANT_BOOL StampEvent::StampCellBeginEdit( long number )
{
  if ( IsSelfAdvise() && theApp.m_mes_STAMP )
  {
    CString str;
    str.Format( "%s --> StampEvent::StampCellBeginEdit\nnumber = %i", m_libName, number );
    str += "\n  = " + GetDocName();
    return !!kompas->ksYesNo( str.GetBuffer(0) );
  }
  return true; 
}