/* $Id: driversimp.h,v 1.1.1.1 1996/10/02 10:35:49 roitzsch Exp $ */

#ifndef DRIVERSIMP_H
#define DRIVERSIMP_H

const MAX_WINDOWS = 1;


#include "drivers.h"

#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/cursorfont.h>
#include <X11/keysym.h> 
#include <signal.h>
 

static const float psRed[]   = { 0, 1, 1, 0, 0, 0, 1, 1 };
static const float psGreen[] = { 0, 1, 0, 1, 0, 1, 0, 1 };
static const float psBlue[]  = { 0, 1, 0, 0, 1, 1, 1, 0 };


static const unsigned short XRed[COLORS] = {0, 65535, 65535,     0,
					    0,     0, 65535, 65535,
	                      		65535, 65535, 65535, 65535,
					65535, 65535, 65535, 65535,
  	                    		65535, 65535, 65535, 65535,
					65535, 65535, 65535, 65535,
        	             		65535, 65535, 65535, 65535,
					65535, 65535, 65535, 65535,
                	      		65535, 65535, 65535, 65535,
					65535, 65535, 65535, 65535,
                      			65535, 65535, 65535, 65535,
					65535, 65535, 65535, 65535,
                      			65535, 65535, 65535, 65535,
					65535, 65535, 65535, 65535,
        	             		65535, 65535, 65535, 65535,
					65535, 65535, 65535, 65535  };
       	              		      
static const unsigned short XGreen[COLORS]={0, 65535,     0, 65535,
					    0, 65535,     0, 65535,
                	      		65535, 65535, 65535, 65535,
					65535, 65535, 65535, 65535,
                      			65535, 65535, 65535, 65535,
					65535, 65535, 65535, 65535,
                       			65535, 65535, 65535, 65535,
					65535, 65535, 65535, 65535,
                   			65535, 65535, 65535, 65535,
					65535, 65535, 65535, 65535, 
                      			65535, 65535, 65535, 65535,
					65535, 65535, 65535, 65535,
                      			65535, 65535, 65535, 65535,
					65535, 65535, 65535, 65535,
                    			65535, 65535, 65535, 65535,
					65535, 65535, 65535, 65535  };
                     		      
static const unsigned short XBlue [COLORS]={0, 65535,     0,     0,
					65535, 65535, 65535,     0,
                     			65535, 65535, 65535, 65535,
					65535, 65535, 65535, 65535,
                     			65535, 65535, 65535, 65535,
					65535, 65535, 65535, 65535,
                      			65535, 65535, 65535, 65535,
					65535, 65535, 65535, 65535,
                     			65535, 65535, 65535, 65535,
					65535, 65535, 65535, 65535,
                     			65535, 65535, 65535, 65535,
					65535, 65535, 65535, 65535,
                     			65535, 65535, 65535, 65535,
					65535, 65535, 65535, 65535,
                     			65535, 65535, 65535, 65535,
					65535, 65535, 65535, 65535  };
//-------------------------------------------------------------------------


class PSDriverImp : public Driver
{

  public:


    PSDriverImp();
    virtual ~PSDriverImp() { };

    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 String (GRAPHIC *graph, char* string, int* length);

    void Clipping(GRAPHIC *graph);

  private:

    float red  [COLORS];
    float green[COLORS];
    float blue [COLORS];

    int   file;
    char fontName[2];  /* Helvetica */
};
//-------------------------------------------------------------------------


class XDriverImp : public Driver
{

  public:

    XDriverImp();
    virtual ~XDriverImp() { };

    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);


  private:

    Display  	*display;
    int  	screen;  
    Window  	window[MAX_WINDOWS];
    GC  	gc[MAX_WINDOWS];
    Font 	font[MAX_WINDOWS], mrkFont;
    Colormap  	colormap;
    
    XColor 	   color[COLORS];
    unsigned long  pixels[COLORS];

    int  	fonttyp;
    
    char 	input_queue[MAX_WINDOWS][MAX_STRING];
    int 	queue_pointer[MAX_WINDOWS];
    
    int  	mrk_fonttyp;

    unsigned short red  [COLORS];
    unsigned short green[COLORS];
    unsigned short blue [COLORS];
};

#endif
