Actual source code: ximpl.h
petsc-3.3-p7 2013-05-11
2: /*
3: Defines the internal data structures for the X-windows
4: implementation of the graphics functionality in PETSc.
5: */
7: #include <../src/sys/draw/drawimpl.h>
9: #if !defined(_XIMPL_H)
10: #define _XIMPL_H
12: #include <sys/types.h>
13: #include <X11/Xlib.h>
14: #include <X11/Xutil.h>
16: typedef unsigned long PetscDrawXiPixVal;
18: typedef struct {
19: GC set;
20: PetscDrawXiPixVal cur_pix;
21: } PetscDrawXiGC;
23: typedef struct {
24: Font fnt;
25: int font_w,font_h;
26: int font_descent;
27: PetscDrawXiPixVal font_pix;
28: } PetscDrawXiFont;
30: typedef struct {
31: Display *disp;
32: int screen;
33: Window win;
34: Visual *vis; /* Graphics visual */
35: PetscDrawXiGC gc;
36: PetscDrawXiFont *font;
37: int depth; /* Depth of visual */
38: int numcolors, /* Number of available colors */
39: maxcolors; /* Current number in use */
40: Colormap cmap;
41: PetscDrawXiPixVal foreground,background;
42: PetscDrawXiPixVal cmapping[256];
43: int x,y,w,h; /* Size and location of window */
44: Drawable drw;
45: } PetscDraw_X;
47: #define PetscDrawXiDrawable(w) ((w)->drw ? (w)->drw : (w)->win)
49: #define PetscDrawXiSetColor(Win,icolor)\
50: {if (icolor >= 256 || icolor < 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Color value out of range");\
51: if ((Win)->gc.cur_pix != (Win)->cmapping[icolor]) { \
52: XSetForeground((Win)->disp,(Win)->gc.set,(Win)->cmapping[icolor]); \
53: (Win)->gc.cur_pix = (Win)->cmapping[icolor];\
54: }}
56: #define PetscDrawXiSetPixVal(Win,pix)\
57: {if ((PetscDrawXiPixVal) (Win)->gc.cur_pix != pix) { \
58: XSetForeground((Win)->disp,(Win)->gc.set,pix); \
59: (Win)->gc.cur_pix = pix;\
60: }}
62: #endif