home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 1999 November / SGI IRIX 6.5 Applications 1999 November.iso / dev / java_dev.idb / usr / demos / java / java-and-X / xdraw.c.z / xdraw.c
Encoding:
C/C++ Source or Header  |  1998-07-14  |  905 b   |  44 lines

  1. #include <X11/Intrinsic.h>
  2. #include <stdlib.h>
  3.  
  4. #include "MyCanvas.h"
  5. #include "monitor.h"
  6.  
  7. #define AWT_LOCK() awt_lock_enter()
  8. #define AWT_UNLOCK() awt_lock_exit()
  9.  
  10.  
  11. struct ComponentData {
  12.    Widget      widget;
  13.    int         repaintPending;
  14.    int         x1, y1, x2, y2;
  15. };
  16.  
  17. struct CanvasData {
  18.    struct ComponentData        comp;
  19.    Widget                      shell;
  20.    int                         flags;
  21. };
  22.  
  23. JNIEXPORT void JNICALL Java_MyCanvas_X11DrawLine
  24.   (JNIEnv *env, jobject this, jint pData, jint x0, jint y0, jint x1, jint y1)
  25. {
  26.  
  27.   struct CanvasData *wdata;
  28.   Window w;
  29.   Display *d;
  30.   GC gc;
  31.  
  32.   wdata = (struct CanvasData*)pData;
  33.   AWT_LOCK();
  34.   w = XtWindow(wdata->comp.widget);
  35.   d = XtDisplay(wdata->comp.widget);
  36.   gc = XCreateGC(d,w,0,0L);
  37.   XSetForeground(d, gc, WhitePixel(d,0));
  38.   XSetBackground(d, gc, BlackPixel(d,0));
  39.  
  40.   XDrawLine(d, w, gc, x0, y0, x1, y1);
  41.   AWT_UNLOCK();
  42.  
  43. }
  44.