/* $Id: drivers.h,v 1.2 1996/10/04 15:06:31 roitzsch Exp $ */

#ifndef DRIVERS_H
#define DRIVERS_H

#include <math.h>
#include <stream.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

#include "minigraph.h"


struct coor  { int x, y; };

//-------------------------------------------------------------------------


class Driver

{
  public:

    virtual ~Driver() { };

    virtual int Init(GRAPHIC* graph, float size=0.5) = 0;
    virtual int OpenPort(GRAPHIC* graph) = 0;
    virtual int Color(int col_no, int rVal, int gVal, int bVal) = 0;
    virtual int Fill(GRAPHIC *graph, float* x, float* y, int n) = 0;
    virtual int PLine(GRAPHIC *graph, float* x, float* y,int n) = 0;
    virtual int PMarker(GRAPHIC *graph, float* x, float* y,int n) = 0;

    virtual int Fill(GRAPHIC *graph, double* x, double* y, int n) = 0;
    virtual int PLine(GRAPHIC *graph, double* x, double* y, int n) = 0;
    virtual int PMarker(GRAPHIC *graph, double* x, double* y, int n) = 0;

    virtual int Settings(GRAPHIC *graph, int type, int iVal) = 0;
    virtual int Settings(GRAPHIC *graph, int type, char* str) = 0;

    virtual int Text(GRAPHIC *graph, double x, double y, char *s) = 0;
    virtual int NewPict(GRAPHIC *graph)	 = 0;
    virtual int Close(GRAPHIC *graph)	 = 0;

    virtual int Gin (GRAPHIC* /*graph*/, int /*geo*/, void* /*x1koordAdr*/, 
	void* /*y1koordAdr*/, void* /*x2koordAdr*/, void* /*y2koordAdr*/)	
	{ notImplementedError(); return 0;}  
    virtual int Event (GRAPHIC* /*graph*/, int* /*typAdr*/, int* /*buttonAdr*/, 
		void* /*xkoordAdr*/, void* /*ykoordAdr*/, int* /*chAdr*/)
	{ notImplementedError(); return 0;}
    virtual int Wait(GRAPHIC* /*graph*/, int* /*typAdr*/, int* /*buttonAdr*/, 
			void* /*xkoordAdr*/, void* /*ykoordAdr*/, int* /*chAdr*/)
	{ notImplementedError(); return 0;}
    virtual int String (GRAPHIC* /*graph*/, char* /*string*/, int* /*length*/)
	{ notImplementedError(); return 0;}
    virtual void geometric(GRAPHIC* /*graph*/, int /*geo*/, coor /*org*/, coor /*vec*/)
	{ notImplementedError(); return;  }
    virtual SelFont(GRAPHIC* /*graph*/)	
	{ notImplementedError(); return 0;}
    virtual void FlushDisplay() 
	{ notImplementedError(); return;  }

    /*
      PROC   PLine, PMarker, Text, Fill, Color, Settings, 
      		NewPict, OpenPort, Close, Gin, Event, Wait, String;
    */

  private:
    void notImplementedError()  { }
    	// { printf("\n\n *** function not implemented for called driver \n"); }


};
//-------------------------------------------------------------------------

class PSDriverImp;


class PSDriver : public Driver
{
  private:

    PSDriverImp* imp;

  public:

    PSDriver();
    virtual ~PSDriver();

    Init (GRAPHIC* graph, float size=0.5);
    int OpenPort(GRAPHIC *graph);
    int Color(int col_no, int rVal, int gVal, int bVal);

    int Fill(GRAPHIC *graph, float* x, float* y, int n);
    int PLine(GRAPHIC *graph, float* x, float* y, int n);
    int PMarker(GRAPHIC *graph, float* x, float* y, int n);

    int Fill(GRAPHIC *graph, double* x, double* y, int n);
    int PLine(GRAPHIC *graph, double* x, double* y, int n);
    int PMarker(GRAPHIC *graph, double* x, double* y, int n);

    int Settings(GRAPHIC *graph, int type, int iVal);
    int Settings(GRAPHIC *graph, int type, char* str);
    int Text(GRAPHIC *graph, double x, double y, char *s);
    int NewPict(GRAPHIC *graph);
    int Close(GRAPHIC *graph);
    // int String (GRAPHIC *graph, char* string, int* length);

    void Clipping(GRAPHIC *graph); 
};
/*-------------------------------------------------------------------------*/

class XDriverImp;


class XDriver : public Driver
{

  private:

    XDriverImp* imp;

  public:

    XDriver();
    virtual ~XDriver();

    int Init(GRAPHIC* graph, float size=0.5);

    int OpenPort(GRAPHIC *graph);
    int Color(int col_no, int rVal, int gVal, int bVal);

    int Fill(GRAPHIC *graph, float* x, float* y, int n);
    int PLine(GRAPHIC *graph, float* x, float* y, int n);
    int PMarker(GRAPHIC *graph, float* x, float* y, int n);

    int Fill(GRAPHIC *graph, double* x, double* y, int n);
    int PLine(GRAPHIC *graph, double* x, double* y, int n);
    int PMarker(GRAPHIC *graph, double* x, double* y, int n);

    int Settings(GRAPHIC *graph, int type, int iVal);
    int Settings(GRAPHIC *graph, int type, char* str);

    int Text(GRAPHIC *graph, double x, double y, char *s);
    int NewPict(GRAPHIC *graph);
    int Close(GRAPHIC *graph);
    int Gin (GRAPHIC *graph, int geo, void* x1koordAdr, 
		       void* y1koordAdr, void* x2koordAdr, void* y2koordAdr);
    int Event (GRAPHIC *graph, int* typAdr, int* buttonAdr, 
			 void* xkoordAdr, void* ykoordAdr, int* chAdr);
    int Wait (GRAPHIC* graph, int* typAdr, int* buttonAdr, 
			void* xkoordAdr, void* ykoordAdr, int* chAdr);
    int String (GRAPHIC *graph, char* string, int* length);
    void geometric(GRAPHIC *graph, int geo, coor org, coor vec);

    void FlushDisplay();  	
    SelFont(GRAPHIC *graph);	
};

#endif
