-
Notifications
You must be signed in to change notification settings - Fork 0
/
XPen.cc
84 lines (59 loc) · 2.01 KB
/
XPen.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
-------------------------------------------------------------------------
OBJECT NAME: XPen.cc
FULL NAME: Plot canvas
DESCRIPTION:
COPYRIGHT: University Corporation for Atmospheric Research, 1997
-------------------------------------------------------------------------
*/
#include "XPen.h"
/* -------------------------------------------------------------------- */
XPen::XPen(Widget w)
{
Arg args[4];
Cardinal n;
unsigned long valuemask;
XGCValues values;
dpy = XtDisplay(w);
n = 0;
XtSetArg(args[n], XtNforeground, &values.foreground); ++n;
XtSetArg(args[n], XtNbackground, &values.background); ++n;
XtGetValues(w, args, n);
valuemask = GCForeground | GCBackground;
gc = XCreateGC(dpy, RootWindowOfScreen(XtScreen(w)), valuemask, &values);
lineWidth = 1;
} /* END CONSTRUCTOR */
/* -------------------------------------------------------------------- */
void XPen::SetClipping(int x, int y, int h, int w)
{
XRectangle clip_area[1];
/* Set clipping so that graph data cannot exceed box boundries
*/
clip_area[0].x = x;
clip_area[0].y = y;
clip_area[0].width = h;
clip_area[0].height = w;
XSetClipRectangles(dpy, gc, 0, 0, clip_area, 1, Unsorted);
} /* END SETCLIPPING */
/* -------------------------------------------------------------------- */
void XPen::SetDash(int n)
{
char dashList[4];
XSetLineAttributes(dpy, gc, lineWidth, LineOnOffDash, CapButt, JoinMiter);
dashList[0] = (n + 1) * 6;
dashList[1] = (n + 1) * 3;
XSetDashes(dpy, gc, 0, dashList, 2);
} /* END SETDASH */
/* -------------------------------------------------------------------- */
XImage *XPen::GetImage(Drawable canvas, int x, int y, int width, int height)
{
return(XGetImage(dpy, canvas, x, y, width, height, 0xffffffff, XYPixmap));
}
/* -------------------------------------------------------------------- */
unsigned long XPen::GetBackground()
{
XGCValues v;
XGetGCValues(dpy, gc, GCBackground, &v);
return(v.background);
} /* END GETBACKGROUND */
/* END XPEN.CC */