Actual source code: ximpl.h

petsc-3.6.1 2015-08-06
Report Typos and Errors
  2: /*
  3:       Defines the internal data structures for the X-windows
  4:    implementation of the graphics functionality in PETSc.
  5: */

  7: #if !defined(_XIMPL_H)
  8: #define _XIMPL_H
  9: #include <petsc/private/drawimpl.h>

 11: #include <X11/Xlib.h>
 12: #include <X11/Xutil.h>

 14: typedef unsigned long PetscDrawXiPixVal;

 16: typedef struct {
 17:   GC                set;
 18:   PetscDrawXiPixVal cur_pix;
 19: } PetscDrawXiGC;

 21: typedef struct {
 22:   Font              fnt;
 23:   int               font_w,font_h;
 24:   int               font_descent;
 25:   PetscDrawXiPixVal font_pix;
 26: } PetscDrawXiFont;

 28: typedef struct {
 29:   Display           *disp;
 30:   int               screen;
 31:   Window            win;
 32:   Visual            *vis;            /* Graphics visual */
 33:   PetscDrawXiGC     gc;
 34:   PetscDrawXiFont   *font;
 35:   int               depth;           /* Depth of visual */
 36:   int               numcolors;       /* Number of available colors */
 37:   int               maxcolors;       /* Current number in use */
 38:   Colormap          cmap;
 39:   PetscDrawXiPixVal foreground,background;
 40:   PetscDrawXiPixVal cmapping[256];
 41:   int               x,y,w,h;      /* Size and location of window */
 42:   Drawable          drw;
 43: } PetscDraw_X;

 45: #define PetscDrawXiDrawable(w) ((w)->drw ? (w)->drw : (w)->win)

 47: #define PetscDrawXiSetColor(Win,icolor) \
 48:   { if (icolor >= 256 || icolor < 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Color value out of range"); \
 49:     if ((Win)->gc.cur_pix != (Win)->cmapping[icolor]) {                  \
 50:       XSetForeground((Win)->disp,(Win)->gc.set,(Win)->cmapping[icolor]); \
 51:       (Win)->gc.cur_pix = (Win)->cmapping[icolor]; \
 52:     }}

 54: #define PetscDrawXiSetPixVal(Win,pix) \
 55:   { if ((PetscDrawXiPixVal) (Win)->gc.cur_pix != pix) { \
 56:       XSetForeground((Win)->disp,(Win)->gc.set,pix);    \
 57:       (Win)->gc.cur_pix = pix; \
 58:     }}

 60: #endif