//====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.5 nt/src/imaging/WinSCanv.cpp, odimaging, od96nt, odnt9712d 7/15/96 17:52:02 [ 3/21/97 17:19:09 ]
/********************************************************************/
/*  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 Created.                                    */
/*                                                                  */
/********************************************************************/

#ifndef SOM_Module_winscanv_Source
#define SOM_Module_winscanv_Source
#endif
#define ODWin32StandardCanvas_Class_Source
#define VARIABLE_MACROS



#ifndef SOM_ODWin32StandardCanvas_xih
#include "winscanv.xih"
#endif


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

#ifndef _ODDEBUG_
#include <ODDebug.h>
#endif

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



SOM_Scope void  SOMLINK ODWin32StandardCanvasInitPlatformCanvas( ODWin32StandardCanvas* somSelf,
                                                         Environment *ev,
                                                         HDC hdc )
{
    ODWin32StandardCanvasData *somThis = ODWin32StandardCanvasGetData(somSelf);
    ODWin32StandardCanvasMethodDebug("ODWin32StandardCanvas","ODWin32StandardCanvasInitPlatformCanvas");

    if ( !_fInitialized ) 
    {
       SOM_TRY

          ASSERT_NOT_NULL( hdc );

          // Need to verify the HDC is valid. 
          // Note: Can also use GetDeviceCaps with
          //       an index of TECHNOLOGY to determine
          //       what device the HDC is associated 
          //       with.
          DWORD ret = GetObjectType( (HGDIOBJ) hdc );

          switch( ret ) {

            // Any of the following return values means
            // hdc was a valid HDC.
            case OBJ_DC:
            case OBJ_MEMDC:
            case OBJ_METADC:
            case OBJ_ENHMETADC:
              break;

            default:
              THROW( kODErrInvalidParameter );
          }

          somSelf->InitObject(ev);
          _fHdc = hdc;
          _fInitialized = kODTrue;
          _fMetafileExtent.cx = _fMetafileExtent.cy = kODNULL;
          _fMetafileExtentValid = kODFalse;
       SOM_CATCH_ALL
       SOM_ENDTRY
    }                 
}



SOM_Scope ODPlatformCanvasType  SOMLINK ODWin32StandardCanvasGetPlatformCanvasType( ODWin32StandardCanvas *somSelf, 
                                                          Environment *ev ) 
{
    ODWin32StandardCanvasMethodDebug("ODWin32StandardCanvas","ODWin32StandardCanvasGetPlatformCanvasType");

    return kODPlatformStandardCanvas;
}



SOM_Scope HDC  SOMLINK ODWin32StandardCanvasGetDC( ODWin32StandardCanvas* somSelf,
                                                   Environment *ev )
{
    ODWin32StandardCanvasData *somThis = ODWin32StandardCanvasGetData(somSelf);
    ODWin32StandardCanvasMethodDebug("ODWin32StandardCanvas","ODWin32StandardCanvasGetDC");

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




SOM_Scope void  SOMLINK ODWin32StandardCanvasReleaseDC( ODWin32StandardCanvas* somSelf,
                                                        Environment *ev )
{
    /* ODWin32StandardCanvasData *somThis = ODWin32StandardCanvasGetData(somSelf);  */
    ODWin32StandardCanvasMethodDebug("ODWin32StandardCanvas","ODWin32StandardCanvasReleaseDC");

   // On the Windows platform, releasing this type of DC is not 
   // meaningful and may cause system errors with certain types
   // of non-window DC's.  It's just a noop in this class.

}





SOM_Scope ODBoolean  SOMLINK ODWin32StandardCanvasHasWindow( ODWin32StandardCanvas *somSelf, 
                                                             Environment *ev ) 
{
    ODWin32StandardCanvasData *somThis = ODWin32StandardCanvasGetData(somSelf);
    ODWin32StandardCanvasMethodDebug("ODWin32StandardCanvas","ODWin32StandardCanvasHasWindow");

    return kODFalse;
}


SOM_Scope HWND SOMLINK ODWin32StandardCanvasGetWindow( ODWin32StandardCanvas *somSelf, 
                                                       Environment *ev ) 
{
    ODWin32StandardCanvasData *somThis = ODWin32StandardCanvasGetData(somSelf);
    ODWin32StandardCanvasMethodDebug("ODWin32StandardCanvas","ODWin32StandardCanvasGetWindow");

    ODSetSOMException( ev, kODErrInvalidObjectType );
    return kODNULL;
}


SOM_Scope ODBoolean  SOMLINK ODWin32StandardCanvasIsInitialized( ODWin32StandardCanvas *somSelf, 
                                                                 Environment *ev ) 
{
    ODWin32StandardCanvasData *somThis = ODWin32StandardCanvasGetData(somSelf);
    ODWin32StandardCanvasMethodDebug("ODWin32StandardCanvas","ODWin32StandardCanvasIsInitialized");

    return _fInitialized;
}



SOM_Scope void  SOMLINK ODWin32StandardCanvasInitPlatformWindowCanvas( ODWin32StandardCanvas* somSelf,
                                                                       Environment *ev,
                                                                       HWND hwnd )
{
    ODWin32StandardCanvasData *somThis = ODWin32StandardCanvasGetData(somSelf);
    ODWin32StandardCanvasMethodDebug("ODWin32StandardCanvas","ODWin32StandardCanvasInitPlatformWindowCanvas");

    ODSetSOMException( ev, kODErrInvalidObjectType );
}



SOM_Scope ODBoolean SOMLINK ODWin32StandardCanvasGetMetafileExtent( ODWin32StandardCanvas *somSelf,
                                                                    Environment *ev,
                                                                    SIZE *metafileExtent )
{
    ODWin32StandardCanvasData *somThis = ODWin32StandardCanvasGetData(somSelf);
    ODWin32StandardCanvasMethodDebug("ODWin32StandardCanvas","ODWin32StandardCanvasGetMetafileExtent");

    *metafileExtent = _fMetafileExtent;
    return _fMetafileExtentValid;
}



SOM_Scope void  SOMLINK ODWin32StandardCanvasSetMetafileExtent( ODWin32StandardCanvas* somSelf,
                                                                Environment *ev,
                                                                SIZE *metafileExtent)
{
    ODWin32StandardCanvasData *somThis = ODWin32StandardCanvasGetData(somSelf);
    ODWin32StandardCanvasMethodDebug("ODWin32StandardCanvas","ODWin32StandardCanvasSetMetafileExtent");

    if( metafileExtent ) {
        _fMetafileExtent = *metafileExtent;
        _fMetafileExtentValid = kODTrue;
    }
    else {
        _fMetafileExtent.cx = _fMetafileExtent.cy = kODNULL;
        _fMetafileExtentValid = kODFalse;
    }
      
}





