Actual source code: ximpl.h
petsc-3.12.5 2020-03-29
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: PETSC_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)
51: #define PetscDrawXiValidColor(W,color) \
52: do { if (PetscUnlikely((color)<0||(color)>=PETSC_DRAW_MAXCOLOR)) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Color value %D out of range [0..%d]",(PetscInt)(color),PETSC_DRAW_MAXCOLOR-1); } while (0)
53: #else
54: #define PetscDrawXiValidColor(W,color) do {} while (0)
55: #endif
57: #define PetscDrawXiSetColor(W,color) do { PetscDrawXiValidColor(W,color); PetscDrawXiSetPixVal(W,(W)->cmapping[(color)]); } while (0)
59: PETSC_INTERN PetscErrorCode PetscDrawXiInit(PetscDraw_X*,const char[]);
60: PETSC_INTERN PetscErrorCode PetscDrawXiClose(PetscDraw_X*);
61: PETSC_INTERN PetscErrorCode PetscDrawXiFontFixed(PetscDraw_X*,int,int,PetscDrawXiFont**);
62: PETSC_INTERN PetscErrorCode PetscDrawXiColormap(PetscDraw_X*);
63: PETSC_INTERN PetscErrorCode PetscDrawXiQuickWindow(PetscDraw_X*,char*,int,int,int,int);
64: PETSC_INTERN PetscErrorCode PetscDrawXiQuickWindowFromWindow(PetscDraw_X*,Window);
65: PETSC_INTERN PetscErrorCode PetscDrawXiQuickPixmap(PetscDraw_X*);
66: PETSC_INTERN PetscErrorCode PetscDrawXiResizeWindow(PetscDraw_X*,int,int);
67: PETSC_INTERN PetscErrorCode PetscDrawXiGetGeometry(PetscDraw_X*,int*,int*,int*,int*);
69: #endif