+++ /dev/null
-/*****************************************************************************
-** This is part of the CTSim program
-** Copyright (C) 1983-2000 Kevin Rosenberg
-**
-** $Id: driver_x11.cpp,v 1.2 2000/06/19 19:04:05 kevin Exp $
-** $Log: driver_x11.cpp,v $
-** Revision 1.2 2000/06/19 19:04:05 kevin
-** reorganized header files
-**
-** Revision 1.1 2000/06/19 18:05:03 kevin
-** initial cvs import
-**
-** Revision 1.1 2000/05/08 20:08:15 kevin
-** *** empty log message ***
-**
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License (version 2) as
-** published by the Free Software Foundation.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
-** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-******************************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include "ctsupport.h"
-#include "sgp.h"
-
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-
-struct sgp_x11_driver {
- Display *theDisplay;
- int theScreen;
- int theDepth;
-};
-
-typedef struct sgp_x11_driver SGP_X11_DRIVER;
-
-SGP_X11_DRIVER sgp_x11;
-
-sgpdrv_X11_init()
-{
- int i;
-
- sgp_x11.theDisplay = NULL;
- for (i = 0; i < 2 && theDisplay == NULL; i++)
- sgp_x11.theDisplay = XOpenDisplay( NULL );
-
- if ( sgp_x11.theDisplay == NULL ) {
- fprintf( stderr, "ERROR: Cannot establish a connection to the X Server %s\n", XDisplayName( NULL ));
- exit( 1 );
- }
-
- sgp_x11.theScreen = DefaultScreen( sgp_x11.theDisplay );
- sgp_x11.theDepth = DefaultDepth( sgp_x11.theDisplay, sgp_x11.theScreen );
-}
-
-sgpdrv_X11_info()
-{
- printf("%s version %d of the X Window System, X%d R%d\n",
- ServerVendor( sgp_x11.theDisplay ),
- VendorRelease( sgp_x11.theDisplay ),
- ProtocolVersion( sgp_x11.theDisplay ),
- ProtocolRevision( sgp_x11.theDisplay ) );
-
- if ( sgp_x11.theDepth == 1)
- printf( "Color plane depth....................%d (monochrome)\n", sgp_x11.theDepth );
- else
- printf( "Color plane depth....................%d\n", sgp_x11.theDepth);
-
- printf( "Display Width........................%d\n",
- DisplayWidth( sgp_x11.theDisplay, sgp_x11.theScreen ));
- printf( "Display Height.......................%d\n",
- DisplayHeight( theDisplay, theScreen ));
- printf( "The display %s\n", XDisplayName( sgp_x11.theDisplay ));
-}
-
-
-
-setlinestyle (LS_SOLID);
-setcolor (1);
-settext (XCHARSIZ, YCHARSIZ, 0.0, 0);
-setbackg (0);
-settextclr (1, 0);
-gp_set_aspect (CRTDEV, CRTASPT);
-gp_set_aspect (PRTDEV, 1.0);
-state.xndc = 10.; /* to guarntee a move */
-stylus (0.0,0.0,0); /* move to starting corner */
-
-
-int
-initdevice (int dev, int mode, int xsize, int ysize)
-{
- // crt.dotfunc = crt_wdot;
- // crt.linefunc = crt_line;
- crt.xmin = 0;
- crt.ymin = 0;
- crt.xmax = 319;
- crt.xsize = 320;
-}
-
-
-/* NAME
- * gp_closedev Close device for output
- *
- * SYNOPSIS
- * gp_closedev (dev)
- * int dev Device handle
- *
- * DESCRIPTION
- * Temporarily suspends output from going to a device
- */
-
-void sgpdrv_x11_term()
-{
-}
-
-void sgpdrv_x11_line()
-{
-}
-
-void sgpdrive_x11_point()
-{
-}
-
-void
-sgpdrv_x11_linestyle (int style)
-{
-
- state.linestyle = style;
-
- // crt_line_style (crt.style);
-}
-
-void
-sgpdrv_x11_linewidth (int wid)
-{
- state.linewidth = wid;
-}
-
-void
-sgpdrv_x11_textparam (
- double width,
- double height, /* size of character in NDC */
- double textangle, /* text angle */
- int font /* text font */
-)
-{
- double temp;
-
- CLIP(height, 0.0, 1.0);
- CLIP(width, 0.0, 1.0);
-/* textangle = textangle - (2 * PI * (int) (textangle / (2 * PI)));
-*/
- cspec.width = width;
- cspec.height = height;
- cspec.textangle = textangle;
- cspec.font = font;
-
- if (textangle > - HALFPI / 2 && textangle < HALFPI / 2) {
- cspec.updir = YPLUS;
- cspec.textdir = XPLUS;
- } else if (textangle > HALFPI / 2 && textangle < 3 * HALFPI / 2) {
- cspec.updir = XMINUS;
- cspec.textdir = YPLUS;
- } else if (textangle > 3 * HALFPI / 2 && textangle < 5 * HALFPI / 2) {
- cspec.updir = YMINUS;
- cspec.textdir = XMINUS;
- } else if (textangle > 5 * HALFPI / 2 && textangle < 7 * HALFPI / 2) {
- cspec.updir = XPLUS;
- cspec.textdir = YMINUS;
- } else {
- cspec.updir = YPLUS;
- cspec.textdir = XPLUS;
- }
-
- if (cspec.updir == XMINUS || cspec.updir == XPLUS) {
- temp = height;
- height = width;
- width = temp;
- }
-
- crt.icwidth = width * crt.xsize + 0.5;
- crt.icheight = height * crt.ysize + 0.5;
- crt.icwidth = iclip (crt.icwidth, 8, crt.xsize);
- crt.icheight = iclip (crt.icheight, 8, crt.ysize);
-
- prt.icwidth = width * prt.xsize + 0.5;
- prt.icheight = height * prt.ysize + 0.5;
- prt.icwidth = iclip (prt.icwidth, 8, prt.xsize);
- prt.icheight = iclip (prt.icheight, 8, prt.ysize);
-}
-
-void
-sgpdrv_textcolor (int fore, int back)
-{
- cspec.fore = fore;
- cspec.back = back;
- crt.cfore = fore;
- crt.cback = back;
- prt.cfore = iclip (fore, 0, prt.colormax);
- prt.cback = back;
-}
-
-void
-sgpdrv_color (int fore)
-{
- int back;
-
- state.foregnd = fore;
- back = state.backgnd;
- crtcolor (crt.mode, &fore, &back); /* set colors on crt */
-}
-
-void
-sgpdrv_backgroundg (int back)
-{
- int fore;
-
- state.backgnd = back;
- fore = state.foregnd;
- crtcolor (crt.mode, &fore, &back);
-}
-
-/*
- * INITMARKER (<SYMBOL>)
- *
- * Sets the current marker symbol (cross, square, diamond..)
- */
-void sgpdrv_marker (int marker, int color)
-{
- if (marker > NMARKERS || marker < 0)
- return(-1);
- else {
- state.marktype = marker;
- state.markcolor = color;
- }
- return(0);
-} /* end initmarker */
-
-/*
- * SETCHARDIR ( <DIRECTION> )
- *
- * indicates in which direction a string should be printed, e.g.:
- * direction = YPLUS -> print on the horizontal from left to right
- * direction = YMINUS -> print upside-down characters from right to left
- * direction = XMINUS -> print on the vertical from down to up
- * direction = XPLUS -> print on the vertical from up to down
- */
-void sgpdrv_x11_textdir (
- int direction /* direction flag */
-)
-{
- if (direction != XPLUS &&
- direction != XMINUS &&
- direction != YPLUS &&
- direction != YMINUS ) {
- printf("Error in character direction: %d\n", direction);
- return(-1);
- }
- cspec.textdir = direction;
- charsize (cspec.width, cspec.height);
-}
-
-int
-void sgpdrv_x11_charsize (double wid, double height)
-{
- settext (wid, height, cspec.textangle, cspec.font);
-}
-
-void
-sgpdrv_x11_textangle (double angle)
-{
- settext (cspec.width, cspec.height, angle, cspec.font);
-}
-
-