version 1.3, 2000/01/18 12:24:18 |
version 1.4, 2000/10/10 05:23:20 |
|
|
/* $OpenXM: OpenXM/src/ox_toolkit/glib.c,v 1.2 1999/12/16 12:22:47 ohara Exp $ */ |
/* $OpenXM: OpenXM/src/ox_toolkit/glib.c,v 1.3 2000/01/18 12:24:18 takayama Exp $ */ |
#include <X11/Xlib.h> |
#include <X11/Xlib.h> |
#include <X11/Xutil.h> |
#include <X11/Xutil.h> |
#include <stdio.h> |
#include <stdio.h> |
|
|
#ifdef TEST |
#ifdef TEST |
int main() |
int main() |
{ |
{ |
int k; |
int k; |
gopen(); |
gopen(); |
for (k=10; k<=500; k++) { |
for (k=10; k<=500; k++) { |
setpixel(k,k); |
setpixel(k,k); |
} |
} |
moveto(100,50); |
moveto(100,50); |
lineto(400,50); |
lineto(400,50); |
for (k=10; k<=300; k += 20) { |
for (k=10; k<=300; k += 20) { |
lineto(k,2*k); |
lineto(k,2*k); |
} |
} |
gFlush(); |
gFlush(); |
gclose(); |
gclose(); |
getchar(); |
getchar(); |
} |
} |
|
|
#endif |
#endif |
Line 39 static int glib_y = 0; |
|
Line 39 static int glib_y = 0; |
|
/* functions exported */ |
/* functions exported */ |
int gopen() |
int gopen() |
{ |
{ |
glib_d = XOpenDisplay(NULL); |
glib_d = XOpenDisplay(NULL); |
glib_w = XCreateSimpleWindow(glib_d,RootWindow(glib_d,0),100,100, |
glib_w = XCreateSimpleWindow(glib_d,RootWindow(glib_d,0),100,100, |
XSIZE,YSIZE,2,0,BlackPixel(glib_d,0)); |
XSIZE,YSIZE,2,0,BlackPixel(glib_d,0)); |
glib_a.override_redirect = 1; |
glib_a.override_redirect = 1; |
XChangeWindowAttributes(glib_d,glib_w,CWOverrideRedirect, &glib_a); |
XChangeWindowAttributes(glib_d,glib_w,CWOverrideRedirect, &glib_a); |
XMapWindow(glib_d,glib_w); |
XMapWindow(glib_d,glib_w); |
glib_gc = XCreateGC(glib_d,glib_w,0,0); |
glib_gc = XCreateGC(glib_d,glib_w,0,0); |
|
|
XSetBackground(glib_d, glib_gc, BlackPixel(glib_d, 0)); |
XSetBackground(glib_d, glib_gc, BlackPixel(glib_d, 0)); |
XSetForeground(glib_d, glib_gc, WhitePixel(glib_d, 0)); |
XSetForeground(glib_d, glib_gc, WhitePixel(glib_d, 0)); |
|
|
/* intialize line attributes */ |
/* intialize line attributes */ |
XSetLineAttributes(glib_d,glib_gc,1,LineSolid,CapButt,JoinMiter); |
XSetLineAttributes(glib_d,glib_gc,1,LineSolid,CapButt,JoinMiter); |
} |
} |
|
|
int gclose() |
int gclose() |
{ |
{ |
XFlush(glib_d); |
XFlush(glib_d); |
} |
} |
|
|
int gFlush() |
int gFlush() |
{ |
{ |
XFlush(glib_d); |
XFlush(glib_d); |
} |
} |
|
|
|
|
int moveto(int x, int y) |
int moveto(int x, int y) |
{ |
{ |
glib_x = x; |
glib_x = x; |
glib_y = y; |
glib_y = y; |
} |
} |
|
|
int lineto(int x, int y) |
int lineto(int x, int y) |
{ |
{ |
XDrawLine(glib_d,glib_w,glib_gc,glib_x,glib_y,x,y); |
XDrawLine(glib_d,glib_w,glib_gc,glib_x,glib_y,x,y); |
glib_x = x; glib_y = y; |
glib_x = x; glib_y = y; |
} |
} |
|
|
int setpixel(int x, int y) |
int setpixel(int x, int y) |
{ |
{ |
XDrawPoint(glib_d,glib_w,glib_gc,x,y); |
XDrawPoint(glib_d,glib_w,glib_gc,x,y); |
} |
} |
|
|