Example #1
0
 void drawRectangles(Rectangle[] rects, boolean stippled) {
   int xDisplay = display.xDisplay;
   int color = OS.XWhitePixel(xDisplay, 0);
   int xWindow = OS.XDefaultRootWindow(xDisplay);
   if (parent != null) {
     xWindow = OS.XtWindow(parent.handle);
     if (xWindow == 0) return;
     int foreground = parent.getForegroundPixel();
     Control control = parent.findBackgroundControl();
     if (control == null) control = parent;
     int background = control.getBackgroundPixel();
     color = foreground ^ background;
   }
   int gc = OS.XCreateGC(xDisplay, xWindow, 0, null);
   OS.XSetForeground(xDisplay, gc, color);
   OS.XSetSubwindowMode(xDisplay, gc, OS.IncludeInferiors);
   OS.XSetFunction(xDisplay, gc, OS.GXxor);
   int stipplePixmap = 0;
   if (stippled) {
     byte[] bits = {-86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0};
     stipplePixmap = OS.XCreateBitmapFromData(xDisplay, xWindow, bits, 8, 8);
     OS.XSetStipple(xDisplay, gc, stipplePixmap);
     OS.XSetFillStyle(xDisplay, gc, OS.FillStippled);
     OS.XSetLineAttributes(xDisplay, gc, 3, OS.LineSolid, OS.CapButt, OS.JoinMiter);
   }
   for (int i = 0; i < rects.length; i++) {
     Rectangle rect = rects[i];
     OS.XDrawRectangle(xDisplay, xWindow, gc, rect.x, rect.y, rect.width, rect.height);
   }
   if (stippled) {
     OS.XFreePixmap(xDisplay, stipplePixmap);
   }
   OS.XFreeGC(xDisplay, gc);
 }
Example #2
0
 void drawBand(int x, int y, int width, int height) {
   if ((style & SWT.SMOOTH) != 0) return;
   int display = OS.XtDisplay(parent.handle);
   if (display == 0) return;
   int window = OS.XtWindow(parent.handle);
   if (window == 0) return;
   int foreground = parent.getForegroundPixel();
   Control control = parent.findBackgroundControl();
   if (control == null) control = parent;
   int background = control.getBackgroundPixel();
   int color = foreground ^ background;
   byte[] bits = {-86, 85, -86, 85, -86, 85, -86, 85};
   int stipplePixmap = OS.XCreateBitmapFromData(display, window, bits, 8, 8);
   int gc = OS.XCreateGC(display, window, 0, null);
   OS.XSetForeground(display, gc, color);
   OS.XSetStipple(display, gc, stipplePixmap);
   OS.XSetSubwindowMode(display, gc, OS.IncludeInferiors);
   OS.XSetFillStyle(display, gc, OS.FillStippled);
   OS.XSetFunction(display, gc, OS.GXxor);
   OS.XFillRectangle(display, window, gc, x, y, width, height);
   OS.XFreePixmap(display, stipplePixmap);
   OS.XFreeGC(display, gc);
 }