Date: 2022-03-31T04:46:00+00:00

Actual source code: ximpl.h

      1: /*
      2:    Defines the internal data structures for the X-windows
      3:    implementation of the graphics functionality in PETSc.
      4: */

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

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

     13: typedef unsigned long PetscDrawXiPixVal;

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

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

     27: typedef struct {
     28:   Display           *disp;            /* Display */
     29:   int               screen;           /* Screen of display */
     30:   Visual            *vis;             /* Graphics visual */
     31:   int               depth;            /* Depth of visual */
     32:   PetscDrawXiGC     gc;               /* Graphics context */
     33:   PetscDrawXiFont   *font;            /* Current font */
     34:   Window            win;              /* Window */
     35:   Drawable          drw;              /* Pixmap */
     36:   Colormap          cmap;             /* Colormap */
     37:   int               cmapsize;         /* Number of allocated colors */
     38:   PetscDrawXiPixVal foreground;       /* Foreground pixel */
     39:   PetscDrawXiPixVal background;       /* Background pixel */
     40:   PetscDrawXiPixVal cmapping[PETSC_DRAW_MAXCOLOR];    /* Map color -> pixel value */
     41:   unsigned char     cpalette[PETSC_DRAW_MAXCOLOR][3]; /* Map color -> RGB value*/
     42:   int               x,y,w,h;          /* Location and size window */
     43: } PetscDraw_X;

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

     47: static inline void PetscDrawXiSetPixVal(PetscDraw_X *W,PetscDrawXiPixVal pix)
     48: { if (W->gc.cur_pix != pix) { XSetForeground(W->disp,W->gc.set,pix); W->gc.cur_pix = pix; } }

     50: #if defined(PETSC_USE_DEBUG)
     52: #else
     53: #define PetscDrawXiValidColor(W,color) do {} while (0)
     54: #endif

     56: #define PetscDrawXiSetColor(W,color) do { PetscDrawXiValidColor(W,color); PetscDrawXiSetPixVal(W,(W)->cmapping[(color)]); } while (0)

     58: PETSC_INTERN PetscErrorCode PetscDrawXiInit(PetscDraw_X*,const char[]);
     59: PETSC_INTERN PetscErrorCode PetscDrawXiClose(PetscDraw_X*);
     60: PETSC_INTERN PetscErrorCode PetscDrawXiFontFixed(PetscDraw_X*,int,int,PetscDrawXiFont**);
     61: PETSC_INTERN PetscErrorCode PetscDrawXiColormap(PetscDraw_X*);
     62: PETSC_INTERN PetscErrorCode PetscDrawXiQuickWindow(PetscDraw_X*,char*,int,int,int,int);
     63: PETSC_INTERN PetscErrorCode PetscDrawXiQuickWindowFromWindow(PetscDraw_X*,Window);
     64: PETSC_INTERN PetscErrorCode PetscDrawXiQuickPixmap(PetscDraw_X*);
     65: PETSC_INTERN PetscErrorCode PetscDrawXiResizeWindow(PetscDraw_X*,int,int);
     66: PETSC_INTERN PetscErrorCode PetscDrawXiGetGeometry(PetscDraw_X*,int*,int*,int*,int*);

     68: #endif