Back to index

plt-scheme  4.2.1
plxwd.h
Go to the documentation of this file.
00001 /* $Id: plxwd.h,v 1.1 2004/03/01 20:54:53 cozmic Exp $
00002 
00003        Holds system header includes, prototypes of xwin driver
00004        utility functions, and definition of the state structure.
00005 */
00006 
00007 #ifndef __PLXWD_H__
00008 #define __PLXWD_H__
00009 
00010 #include "plplot.h"
00011 #include "plstrm.h"
00012 #ifdef HAVE_PTHREAD
00013 #include <pthread.h>
00014 #endif
00015 
00016 /* System headers */
00017 
00018 #include <stdlib.h>
00019 #include <string.h>
00020 #include <sys/types.h>
00021 
00022 #include <X11/Xlib.h>
00023 #include <X11/Xutil.h>
00024 #include <X11/cursorfont.h>
00025 #include <X11/keysym.h>
00026 
00027 /* Specify max number of displays in use */
00028 
00029 #define PLXDISPLAYS 100
00030 
00031 /* Set constants for dealing with colormap.  In brief:
00032  *
00033  * ccmap             When set, turns on custom color map
00034  *
00035  * See Init_CustomCmap() and  Init_DefaultCmap() for more info.
00036  * Set ccmap at your own risk -- still under development.
00037  */
00038 
00039 static int plplot_ccmap = 0;
00040 
00041 
00042 /* One of these holds the display info, shared by all streams on a given */
00043 /* display */
00044 
00045 typedef struct {
00046     int              nstreams;            /* Number of streams using display */
00047     int              ixwd;                /* Specifies xwDisplay number */
00048     char      *displayName;        /* Name of X display */
00049     int              screen;                     /* X screen */
00050     Display   *display;            /* X display */
00051     Visual    *visual;             /* X Visual */
00052     GC        gcXor;               /* Graphics context for XOR draws */
00053     Colormap  map;                 /* Colormap */
00054     unsigned  depth;               /* display depth */
00055     int              color;               /* Set to 1 if a color output device */
00056     int              ncol0;               /* Number of cmap 0 colors allocated */
00057     int              ncol1;               /* Number of cmap 1 colors allocated */
00058     XColor    cmap0[16];           /* Color entries for cmap 0 */
00059     XColor    cmap1[256];          /* Color entries for cmap 1 */
00060     XColor    fgcolor;             /* Foreground color (if grayscale) */
00061     Cursor    xhair_cursor;        /* Crosshair cursor */
00062     int              rw_cmap;             /* Can we allocate r/w color cells? */
00063 } XwDisplay;
00064 
00065 /* One of these holds the X driver state information */
00066 
00067 typedef struct {
00068     XwDisplay *xwd;                /* Pointer to display info */
00069 
00070     int              is_main;             /* Set if the toplevel X window */
00071     Window    window;                     /* X window id */
00072     Pixmap    pixmap;                     /* Off-screen pixmap */
00073     GC        gc;                  /* Graphics context */
00074     XColor    curcolor;            /* Current pen color */
00075 
00076     long      event_mask;          /* Event mask */
00077     int              exit_eventloop;             /* Breaks the event loop when set */
00078     long      init_width;          /* Initial window width */
00079     long      init_height;         /* Initial window height */
00080 
00081     unsigned  width, height, border;      /* Current window dimensions */
00082 
00083     double    xscale_init;         /* initial pixels/lx (virt. coords) */
00084     double    yscale_init;         /* initial pixels/ly (virt. coords) */
00085     double    xscale;                     /* as above, but current value */
00086     double    yscale;                     /*  (after possible resizing)  */
00087 
00088     short     xlen, ylen;          /* Lengths of device coord space */
00089 
00090     int              write_to_window;     /* Set if plotting direct to window */
00091     int              write_to_pixmap;     /* Set if plotting to pixmap */
00092 
00093     int              instr;               /* Instruction timer */
00094     int              max_instr;           /* Limit before X server is queried */
00095 
00096     PLGraphicsIn gin;                     /* Graphics input structure */
00097 
00098     int              locate_mode;         /* Set while in locate mode */
00099     int              drawing_xhairs;             /* Set during xhair draws */
00100     XPoint    xhair_x[2], xhair_y[2];     /* Crosshair lines */
00101 
00102     void (*MasterEH) (PLStream *, XEvent *);     /* Master X event handler */
00103 #ifdef HAVE_PTHREAD
00104   pthread_t updater;                    /* The X events updater thread id */
00105 #endif
00106 } XwDev;
00107 
00108 #endif /* __PLXWD_H__ */