////////////////////////////////////////////////////////////////////////////////
//
// 
//
////////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "eventCom.h"

#ifndef _DOCUMENTFRAMEEVENT_H
#include "DocumentFrameEvent.h"
#endif

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

//extern AFX_MODULE_STATE* pModuleState;

extern BaseEvent* NewDocumentEvent( reference doc );
//-------------------------------------------------------------------------------
//   
// ---
BaseEvent* NewDocumentFrameEvent( reference doc, LPUNKNOWN iObj ) {
	DocumentFrameEvent* res = NULL;
	if ( doc ) {
		if ( !BaseEvent::FindEvents( ntDocumentFrameNotify, doc, -1, iObj ) ) {
			NewDocumentEvent( doc ); //     
			res = new DocumentFrameEvent( doc, iObj );
			if ( !res->Advise() ) { 
				delete res;
				res = NULL;
			}
		}
	}
	return res;
}

////////////////////////////////////////////////////////////////////////////////
//
// DocumentFrameEvent  -     
//
////////////////////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------------------
//
// ---
DocumentFrameEvent::DocumentFrameEvent( reference doc, LPUNKNOWN iObj )
: BaseEvent( ntDocumentFrameNotify, NULL, 0, iObj, doc )
{
}


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

//-----------------------------------------------------------------------------
//
// ---
LPUNKNOWN DocumentFrameEvent::GetUnknown(){
  m_xDocumentFrameNotify.AddRef();
  return &m_xDocumentFrameNotify;
}

//-----------------------------------------------------------------------------
//
// ---
STDMETHODIMP_(ULONG) DocumentFrameEvent::XDocumentFrameNotify::Release()
{
	METHOD_PROLOGUE_EX_(DocumentFrameEvent, DocumentFrameNotify)
	return (ULONG)pThis->InternalRelease();
}

//-----------------------------------------------------------------------------
//
// ---
STDMETHODIMP_(ULONG) DocumentFrameEvent::XDocumentFrameNotify::AddRef()
{
	METHOD_PROLOGUE_EX_(DocumentFrameEvent, DocumentFrameNotify )
	return (ULONG)pThis->InternalAddRef();
}

//-----------------------------------------------------------------------------
//
// ---
STDMETHODIMP DocumentFrameEvent::XDocumentFrameNotify::QueryInterface(
	REFIID iid, LPVOID* ppvObj)
{
	METHOD_PROLOGUE_EX_(DocumentFrameEvent, DocumentFrameNotify)

	ASSERT(AfxIsValidAddress(ppvObj, sizeof(LPVOID), FALSE));

	if ( IsEqualIID(iid, IID_IUnknown) ||
		   IsEqualIID(iid, IID_IDocumentFrameNotify) )
	{
		*ppvObj = this;
		AddRef();
		return S_OK;
	}

	return E_NOINTERFACE;
}

//-----------------------------------------------------------------------------
//      notifyType
// ---
STDMETHODIMP_(VARIANT_BOOL) DocumentFrameEvent::XDocumentFrameNotify::IsNotifyProcess( int notifyType )
{
//	METHOD_PROLOGUE_EX_(DocumentFrameEvent, DocumentFrameNotify)
	return  notifyType >= frBeginPaint && notifyType <= frCloseFrame;
}

//-----------------------------------------------------------------------------
//   
// ---
void DocumentFrameEvent::ShowEventName( LPCTSTR eventName ) {
// 	if ( theApp.m_mes_SELECT ) {
		::_ShowEventName(eventName);
// 	}
}

//-----------------------------------------------------------------------------
//  
// ---
CString DocumentFrameEvent::EventCaption() {
	CString res = _T("DocumentFrameEvent");
	res += GetDocumentParam( refDoc );
	return res;
}


/////////////////////////////////////////////////////////////////////////////
// DocumentFrameEvent message handlers
//-------------------------------------------------------------------------------
// frBeginPaint          -   
// ---
VARIANT_BOOL DocumentFrameEvent::XDocumentFrameNotify::BeginPaint( IUnknown* paintObj ) {
  METHOD_PROLOGUE_EX_(DocumentFrameEvent, DocumentFrameNotify )
  pThis->ShowEventName(_T("DocumentFrameEvent::BeginPaint") );
  return true;
}


//-------------------------------------------------------------------------------
// frClosePaint          -   
// ---
VARIANT_BOOL DocumentFrameEvent::XDocumentFrameNotify::ClosePaint( IUnknown* paintObj ) {
  METHOD_PROLOGUE_EX_(DocumentFrameEvent, DocumentFrameNotify )
  pThis->ShowEventName( _T("DocumentFrameEvent::ClosePaint") );
  return true;
}


//-------------------------------------------------------------------------------
// frMouseDown           -   
// ---
VARIANT_BOOL DocumentFrameEvent::XDocumentFrameNotify::MouseDown( short nButton, short nShiftState, long x, long y ) {
  METHOD_PROLOGUE_EX_(DocumentFrameEvent, DocumentFrameNotify )
  pThis->ShowEventName( _T("DocumentFrameEvent::MouseDown") );
  return true;
}


//-------------------------------------------------------------------------------
// frMouseUp             -   
// ---
VARIANT_BOOL DocumentFrameEvent::XDocumentFrameNotify::MouseUp( short nButton, short nShiftState, long x, long y ) {
  METHOD_PROLOGUE_EX_(DocumentFrameEvent, DocumentFrameNotify )
  pThis->ShowEventName( _T("DocumentFrameEvent::MouseUp") );
  return true;
}


//-------------------------------------------------------------------------------
// frMouseDblClick       -    
// ---
VARIANT_BOOL DocumentFrameEvent::XDocumentFrameNotify::MouseDblClick( short nButton, short nShiftState, long x, long y ) {
  METHOD_PROLOGUE_EX_(DocumentFrameEvent, DocumentFrameNotify )
  pThis->ShowEventName( _T("DocumentFrameEvent::MouseDblClick") );
  return true;
}


//-------------------------------------------------------------------------------
// frBeginCreateGLList   -      OpenGL
// ---
VARIANT_BOOL DocumentFrameEvent::XDocumentFrameNotify::BeginPaintGL( long drawMode ) {
  METHOD_PROLOGUE_EX_(DocumentFrameEvent, DocumentFrameNotify )
  pThis->ShowEventName( _T("DocumentFrameEvent::BeginCreateGLList") );
  return true;
}


//-------------------------------------------------------------------------------
// frCloseCreateGLList   -      OpenGL
// ---
VARIANT_BOOL DocumentFrameEvent::XDocumentFrameNotify::ClosePaintGL( long drawMode ) {
  METHOD_PROLOGUE_EX_(DocumentFrameEvent, DocumentFrameNotify )
  pThis->ShowEventName( _T("DocumentFrameEvent::CloseCreateGLList") );
  return true;
}


//-------------------------------------------------------------------------------
// frAddGabarit          -   
// ---
VARIANT_BOOL DocumentFrameEvent::XDocumentFrameNotify::AddGabarit( IUnknown* paintObj ) {
  METHOD_PROLOGUE_EX_(DocumentFrameEvent, DocumentFrameNotify )
  pThis->ShowEventName( _T("DocumentFrameEvent::AddGabarit") );
  return true;
}


//-------------------------------------------------------------------------------
// frBeginCurrentProcess -   
// ---
VARIANT_BOOL DocumentFrameEvent::XDocumentFrameNotify::BeginCurrentProcess( long id ) {
  METHOD_PROLOGUE_EX_(DocumentFrameEvent, DocumentFrameNotify )
  pThis->ShowEventName( _T("DocumentFrameEvent::BeginCurrentProcess") );
  return true;
}


//-------------------------------------------------------------------------------
// frStopCurrentProcess  -   
// ---
VARIANT_BOOL DocumentFrameEvent::XDocumentFrameNotify::StopCurrentProcess( long id ) {
  METHOD_PROLOGUE_EX_(DocumentFrameEvent, DocumentFrameNotify )
  pThis->ShowEventName( _T("DocumentFrameEvent::StopCurrentProcess") );
  return true;
}


//-------------------------------------------------------------------------------
// frActivate            -  
// ---
VARIANT_BOOL DocumentFrameEvent::XDocumentFrameNotify::Activate() {
  METHOD_PROLOGUE_EX_(DocumentFrameEvent, DocumentFrameNotify )
  pThis->ShowEventName( _T("DocumentFrameEvent::Activate") );
  return true;
}


//-------------------------------------------------------------------------------
// frDeactivate          -  
// ---
VARIANT_BOOL DocumentFrameEvent::XDocumentFrameNotify::Deactivate() {
  METHOD_PROLOGUE_EX_(DocumentFrameEvent, DocumentFrameNotify )
  pThis->ShowEventName( _T("DocumentFrameEvent::Deactivate") );
  return true;
}


//-------------------------------------------------------------------------------
// frCloseFrame          -  
// ---
VARIANT_BOOL DocumentFrameEvent::XDocumentFrameNotify::CloseFrame() {
  METHOD_PROLOGUE_EX_(DocumentFrameEvent, DocumentFrameNotify )
  pThis->ShowEventName( _T("DocumentFrameEvent::CloseFrame") );
  pThis->Disconnect();
  return true;
}

//-------------------------------------------------------------------------------
// frMouseMove           -  
// ---
VARIANT_BOOL DocumentFrameEvent::XDocumentFrameNotify::MouseMove( short nShiftState, long x, long y )
{
//  METHOD_PROLOGUE_EX_(DocumentFrameEvent, DocumentFrameNotify )
  return true;
}

// frShowOcxTree         - 
VARIANT_BOOL DocumentFrameEvent::XDocumentFrameNotify::ShowOcxTree( IUnknown * tree,  VARIANT_BOOL show )
{
  return true;
}

