#ifndef __OOL_XGRAPHDEV_H__
#define __OOL_XGRAPHDEV_H__

/*===========================================================================*/
/* OOL ------------------- the Open Object Library ------------- OS/2 Beta 1 */
/*===========================================================================*/
/*                              class: XGraphicDevice                        */
/*                       derived from: XObject                               */
/*                        last update: 12/96                                 */
/*                      programmed by: Stefan von Brauk (sbrauk@gwdg.de)     */
/*===========================================================================*/


#include "xcolor.h"

class XWindow;
class XGraphicObject;
class XColor;
class XPoint;
class XFont;
class XRect;

#ifdef OOL_FOR_OS2_X86
	#define XGRAPH_PELS			PU_PELS
	#define XGRAPH_LOMETRIC		PU_LOMETRIC
	#define XGRAPH_HIMETRIC		PU_HIMETRIC
	#define XGRAPH_LOENGLISH	PU_LOENGLISH
	#define XGRAPH_HIENGLISH	PU_HIENGLISH
	#define XGRAPH_TWIPS			PU_TWIPS
#endif

class _export_ XGraphicDevice: public XObject
{
      friend class XLine;
      friend class XCircle;
      friend XGraphicObject;
      friend class XArc;
      friend class XFont;
      friend class XText;
      friend class XBox;
      friend class XMarker;
      friend class XBitmap;
      friend class XBitmapShadow;		
   private:
      HAB hab;
      HWND hwnd;
      LONG backCol;
		char fonts;
		XFont ** fontList;
		void RegisterFont( XFont* );
	protected:
		XGraphicDevice( LONG mode);
		void EnableFont( XFont*, LONG);
      HPS hps;
		HDC hdc;
		LONG mode;
      XGraphicObject * first, *last;
      LONG aktColor, xOffset, yOffset;
      char aktLineEnding;
      char aktLineJoining;
      LONG aktLineWidth;
      SHORT aktLineType;
      SHORT aktFontSize;
		SHORT aktPattern;
      char aktFont;
      SHORT markerType;
      LONG width, height;
      BOOL fill;
   public:
      XGraphicDevice( const XWindow*, const BOOL createInMemory = FALSE, const BOOL fillBackground = TRUE, LONG mode = PU_PELS);
      virtual ~XGraphicDevice();
      void AddObject ( const XGraphicObject*);
      void Copy( const XGraphicDevice *, const XRect *, const XRect * = NULL);
      void Draw( void );
		void Empty(void);
      XGraphicObject * FindObject( const LONG x, const LONG y, const XGraphicObject * searchBehind = NULL);
      void GetBackgroundColor( XColor * c) const { c->SetColor( backCol); }
		HDC GetHDC() { return hdc; }
		HPS GetHPS() { return hps; }
      BOOL RemoveObject( XGraphicObject*, const BOOL destroyObject = TRUE);
      void ResetFont( void );
      void SetBackgroundColor( const XColor * c);
		virtual void SetColor( LONG c) { aktColor = c; GpiSetColor( hps, c); }  
      virtual void SetFont( XFont * );
      void SetHeight( const LONG h) { height = h; }
      void SetLineEnd( const char lineEnd) { GpiSetLineEnd( hps, lineEnd ); aktLineEnding = lineEnd; }
      void SetLineJoin( const char lineJoin ) { GpiSetLineJoin( hps, lineJoin); aktLineJoining = lineJoin; }
      void SetLineWidth( const LONG width);
      void SetLineType( const SHORT type ) { GpiSetLineType( hps, type); aktLineType = type; }
		void SetPattern( SHORT p) { aktPattern = p; GpiSetPattern(hps, p);}
      void SetWidth( const LONG h) { width = h; }
      void SetXOffset( const LONG x) { xOffset = x; }
      void SetYOffset( const LONG y) { yOffset = y; }
};

#endif
