//====START_GENERATED_PROLOG======================================
//
//
//   COMPONENT_NAME: odimaging
//
//   CLASSES: none
//
//   ORIGINS: 27
//
//
//   (C) COPYRIGHT International Business Machines Corp. 1995,1996
//   All Rights Reserved
//   Licensed Materials - Property of IBM
//   US Government Users Restricted Rights - Use, duplication or
//   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
//   	
//   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
//   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
//   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
//   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
//   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
//   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
//   OR PERFORMANCE OF THIS SOFTWARE.
//
//====END_GENERATED_PROLOG========================================
//
// @(#) 1.6 nt/src/imaging/WinWCanv.cpp, odimaging, od96nt, odnt9712d 7/15/96 17:52:05 [ 3/21/97 17:13:52 ]
/********************************************************************/
/*  Licensed Materials - Property of IBM                            */
/*                                                                  */
/*                                                                  */
/* Copyright (C) International Business Machines Corp., 1994.       */
/* Copyright (C) Apple Computer, Inc., 1994                         */
/*                                                                  */
/*  US Government Users Restricted Rights -                         */
/*  Use, duplication, or disclosure restricted                      */
/*  by GSA ADP Schedule Contract with IBM Corp.                     */
/*                                                                  */
/*  IBM Change History (most recent first):                         */
/*                                                                  */
/*         05/10/96 jab Add MetafileExtents and clean up for code   */
/*                      review.                                     */
/*         03/20/96 jab Created.                                    */
/********************************************************************/

#ifndef SOM_Module_wndwcanv_Source
#define SOM_Module_wndwcanv_Source
#endif
#define ODWin32WindowCanvas_Class_Source
#define VARIABLE_MACROS



#ifndef SOM_ODWin32WindowCanvas_xih
#include "winwcanv.xih"
#endif

#ifndef _EXCEPT_
#include <Except.h>
#endif

#ifndef _ERRORDEF_
#include "ErrorDef.xh"
#endif

#ifndef _ODTYPES_
#include <ODTypes.h>
#endif





SOM_Scope void  SOMLINK ODWin32WindowCanvasInitPlatformWindowCanvas(ODWin32WindowCanvas* somSelf,
                                                                    Environment *ev,
                                                                    HWND hwnd)
{
    ODWin32WindowCanvasData *somThis = ODWin32WindowCanvasGetData(somSelf);
    ODWin32WindowCanvasMethodDebug("ODWin32WindowCanvas","ODWin32WindowCanvasInitPlatformWindowCanvas");

    SOM_TRY
       if ( !hwnd ) 
          THROW( kODErrIllegalNullInput );  

       if ( !_fInitialized ) {
          somSelf->InitObject( ev );

          // Check if hwnd is valid. 
          if( IsWindow( hwnd ) )  {
             _fHWND = hwnd;
             _fInitialized = kODTrue;
          }
          else {
             ODSetSOMException( ev, kODErrInvalidParameter );
          }   
       }
    SOM_CATCH_ALL
    SOM_ENDTRY

}



SOM_Scope ODPlatformCanvasType  SOMLINK ODWin32WindowCanvasGetPlatformCanvasType( ODWin32WindowCanvas *somSelf, 
                                                          Environment *ev ) 
{
    ODWin32WindowCanvasMethodDebug("ODWin32WindowCanvas","ODWin32WindowCanvasGetPlatformCanvasType");

    return kODPlatformWindowCanvas;
}



SOM_Scope void  SOMLINK ODWin32WindowCanvasInitPlatformCanvas( ODWin32WindowCanvas* somSelf,
                                                               Environment *ev,
                                                               HDC hdc )
{
    ODWin32WindowCanvasData *somThis = ODWin32WindowCanvasGetData(somSelf);
    ODWin32WindowCanvasMethodDebug("ODWin32WindowCanvas","ODWin32WindowCanvasInitPlatformCanvas");

    ODSetSOMException( ev, kODErrInvalidObjectType );
}



SOM_Scope HDC  SOMLINK ODWin32WindowCanvasGetDC( ODWin32WindowCanvas* somSelf,
                                                 Environment *ev )
{
    ODWin32WindowCanvasData *somThis = ODWin32WindowCanvasGetData(somSelf);
    ODWin32WindowCanvasMethodDebug("ODWin32WindowCanvas","ODWin32WindowCanvasGetDC");

    if ( !_fInitialized ) {
       ODSetSOMException( ev, kODErrObjectNotInitialized );
       return kODNULL;
    }
    else {
       if ( _fHdc ) 
          _fCachedDCRefCount++;
       else {
          _fHdc = GetDC( _fHWND );
          _fCachedDCRefCount = 1;
       }
       return _fHdc;
    }
}




SOM_Scope void  SOMLINK ODWin32WindowCanvasReleaseDC( ODWin32WindowCanvas* somSelf,
                                               Environment *ev )

{
    ODWin32WindowCanvasData *somThis = ODWin32WindowCanvasGetData(somSelf);  
    ODWin32WindowCanvasMethodDebug("ODWin32WindowCanvas","ODWin32WindowCanvasReleaseDC");

    if ( !_fInitialized )
       ODSetSOMException( ev, kODErrObjectNotInitialized );
    else {
       if ( _fCachedDCRefCount ) {
          if ( --_fCachedDCRefCount == 0 ) {
             ReleaseDC( _fHWND, _fHdc );
             _fHdc = 0;
          }
       }
    } 
}



SOM_Scope ODBoolean  SOMLINK ODWin32WindowCanvasHasWindow( ODWin32WindowCanvas *somSelf, 
                                                           Environment *ev ) 
{
    ODWin32WindowCanvasData *somThis = ODWin32WindowCanvasGetData(somSelf);
    ODWin32WindowCanvasMethodDebug("ODWin32WindowCanvas","ODWin32WindowCanvasHasWindow");

    if ( !_fInitialized ) {
       ODSetSOMException( ev, kODErrObjectNotInitialized );
       return kODFalse;
    }
    else
       return kODTrue;
}


SOM_Scope HWND  SOMLINK ODWin32WindowCanvasGetWindow( ODWin32WindowCanvas *somSelf, 
                                                           Environment *ev ) 
{
    ODWin32WindowCanvasData *somThis = ODWin32WindowCanvasGetData(somSelf);
    ODWin32WindowCanvasMethodDebug("ODWin32WindowCanvas","ODWin32WindowCanvasGetWindow");

    if ( !_fInitialized ) {
       ODSetSOMException( ev, kODErrObjectNotInitialized );
       return kODNULL;
    }
    else
       return _fHWND;
}


SOM_Scope ODBoolean  SOMLINK ODWin32WindowCanvasIsInitialized( ODWin32WindowCanvas *somSelf, 
                                                               Environment *ev ) 
{
    ODWin32WindowCanvasData *somThis = ODWin32WindowCanvasGetData(somSelf);
    ODWin32WindowCanvasMethodDebug("ODWin32WindowCanvas","ODWin32WindowCanvasIsInitialized");

    return _fInitialized;
}



SOM_Scope ODBoolean SOMLINK ODWin32WindowCanvasGetMetafileExtent( ODWin32WindowCanvas *somSelf,
                                                       Environment *ev,
                                                       SIZE *metafileExtent )
{
    ODWin32WindowCanvasMethodDebug("ODWin32WindowCanvas","ODWin32WindowCanvasGetMetafileExtent");

    ODSetSOMException( ev, kODErrInvalidObjectType );
    metafileExtent->cx = metafileExtent->cy = 0;
    return kODFalse;

}



SOM_Scope void  SOMLINK ODWin32WindowCanvasSetMetafileExtent( ODWin32WindowCanvas* somSelf,
                                                        Environment *ev,
                                                        SIZE *metafileExtent)
{
    ODWin32WindowCanvasMethodDebug("ODWin32WindowCanvas","ODWin32WindowCanvasSetMetafileExtent");

    ODSetSOMException( ev, kODErrInvalidObjectType );
}




