Ejemplo n.º 1
0
void draw_rectangle (int x1, int y1, int x2, int y2, int color)
{
  int temp;
  int dx,dy;

  color = (int) ((color / 255.0) * (num_colors - 1));

  if (x1 > x2) {
    temp = x1;
    x1 = x2;
    x2 = temp;
  }

  if (y1 > y2) {
    temp = y1;
    y1 = y2;
    y2 = temp;
  }

  dx = x2 - x1 + 1;
  dy = y2 - y1 + 1;

  gcvalues.foreground = colors[color].pixel;
  XChangeGC (display, gc, GCForeground, &gcvalues);
  XFillRectangle (display, root, gc, x1 * psize, y1 * psize,
		  dx * psize, dy * psize);
}
Ejemplo n.º 2
0
/*++++++++++++++++++++++++ draw_remote_history() ++++++++++++++++++++++++*/
void
draw_remote_history(int pos, int type, int x, int y)
{
   int       i, x_offset, y_offset;
   XGCValues gc_values;

   x_offset = x + x_offset_log_history;
   y_offset = y + SPACE_ABOVE_LINE;

   for (i = (MAX_LOG_HISTORY - his_log_set); i < MAX_LOG_HISTORY; i++)
   {
      gc_values.foreground = color_pool[(int)connect_data[pos].log_history[type][i]];
      XChangeGC(display, color_gc, GCForeground, &gc_values);
      XFillRectangle(display, line_window, color_gc, x_offset, y_offset,
                     bar_thickness_3, bar_thickness_3);
      XDrawRectangle(display, line_window, default_bg_gc, x_offset, y_offset,
                     bar_thickness_3, bar_thickness_3);
      XFillRectangle(display, line_pixmap, color_gc, x_offset, y_offset,
                     bar_thickness_3, bar_thickness_3);
      XDrawRectangle(display, line_pixmap, default_bg_gc, x_offset, y_offset,
                     bar_thickness_3, bar_thickness_3);
      x_offset += bar_thickness_3;
   }

   return;
}
Ejemplo n.º 3
0
// Draw
void LineBox::_draw(Widget w, 
		    const BoxRegion& r, 
		    const BoxRegion& exposed, 
		    GC gc,
		    bool context_selected) const
{
    XGCValues gcvalues;

    // Set width and cap style; project beyond end point up to 1/2
    // line thickness
    gcvalues.line_width = _linethickness;
    gcvalues.cap_style = CapProjecting;
    XChangeGC(XtDisplay(w), gc, GCLineWidth | GCCapStyle, &gcvalues);

    // Keep an empty frame of 1/2 line thickness around R (X may cross
    // R's boundaries otherwise)
    BoxPoint origin = r.origin();
    BoxSize space   = r.space();
    origin += _linethickness / 2;
    space  -= _linethickness;

    // Draw children
    __draw(w, BoxRegion(origin, space), exposed, gc, context_selected);

    // Attention: We leave LINE_WIDTH and CAP_STYLE changed!
    // (Works within Box::draw(), but the used GC may be changed)
}
Ejemplo n.º 4
0
void get_root_pixmap()
{
    Pixmap ret = None;

    Atom pixmap_atoms[] = {server.atom._XROOTPMAP_ID, server.atom._XROOTMAP_ID};
    for (int i = 0; i < sizeof(pixmap_atoms) / sizeof(Atom); ++i) {
        unsigned long *res = (unsigned long *)server_get_property(server.root_win, pixmap_atoms[i], XA_PIXMAP, NULL);
        if (res) {
            ret = *((Pixmap *)res);
            XFree(res);
            break;
        }
    }
    server.root_pmap = ret;

    if (server.root_pmap == None) {
        fprintf(stderr, "tint2 : pixmap background detection failed\n");
    } else {
        XGCValues gcv;
        gcv.ts_x_origin = 0;
        gcv.ts_y_origin = 0;
        gcv.fill_style = FillTiled;
        uint mask = GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle | GCTile;

        gcv.tile = server.root_pmap;
        XChangeGC(server.display, server.gc, mask, &gcv);
    }
}
Ejemplo n.º 5
0
void setlinestyle(int linestyle, unsigned upattern, int thickness)
{
        XGCValues values;
        int dash_offset;
        
        dash_offset = 0;
        switch (linestyle) {
                case SOLID_LINE:
                        values.line_style = LineSolid;
                        break;
                case DOTTED_LINE:
                        values.line_style = LineOnOffDash;
                        XSetDashes(dpy, gc, dash_offset, dash_list[0],
                                   dash_list_length[0]);
                        break;
                case CENTER_LINE:
                        values.line_style = LineOnOffDash;
                        XSetDashes(dpy, gc, dash_offset, dash_list[1],
                                   dash_list_length[1]);
                        break;
                case DASHED_LINE:
                        values.line_style = LineOnOffDash;
                        XSetDashes(dpy, gc, dash_offset, dash_list[2],
                                   dash_list_length[2]);
                        break;
                default:
                        return;
        }
        values.line_width = thickness;
        XChangeGC(dpy, gc, GCLineWidth | GCLineStyle, &values);
}
Ejemplo n.º 6
0
int
InitCopyPlane(XParms xp, Parms p, int64_t reps)
{
    XGCValues   gcv;
    GC		pixgc;

    InitBltLines();
    InitCopyLocations(p->special, 1, 1, reps, &segsa, &segsb);

    /* Create pixmap to write stuff into, and initialize it */
    pix = XCreatePixmap(xp->d, xp->w, WIDTH, HEIGHT, 
	    p->font==NULL ? 1 : xp->vinfo.depth);
    gcv.graphics_exposures = False;
    gcv.foreground = 0;
    gcv.background = 1;
    pixgc = XCreateGC(xp->d, pix, 
		GCForeground | GCBackground | GCGraphicsExposures, &gcv);
    XFillRectangle(xp->d, pix, pixgc, 0, 0, WIDTH, HEIGHT);
    gcv.foreground = 1;
    gcv.background = 0;
    XChangeGC(xp->d, pixgc, GCForeground | GCBackground, &gcv);
    XDrawLines(xp->d, pix, pixgc, points, NUMPOINTS, CoordModeOrigin);
    XFreeGC(xp->d, pixgc);

    return reps;
}
Ejemplo n.º 7
0
static void
drawcell(ModeInfo * mi, int col, int row, unsigned char color)
{
	antfarmstruct *ap = &antfarms[MI_SCREEN(mi)];
	GC          gc;

	if (!color) {
		XSetForeground(MI_DISPLAY(mi), MI_GC(mi), MI_BLACK_PIXEL(mi));
		gc = MI_GC(mi);
	} else if (MI_NPIXELS(mi) > 2) {
		XSetForeground(MI_DISPLAY(mi), MI_GC(mi),
			MI_PIXEL(mi, ap->colors[color - 1]));
		gc = MI_GC(mi);
	} else {
		XGCValues   gcv;

		gcv.stipple = ap->pixmaps[color - 1];
		gcv.foreground = MI_WHITE_PIXEL(mi);
		gcv.background = MI_BLACK_PIXEL(mi);
		XChangeGC(MI_DISPLAY(mi), ap->stippledGC,
			  GCStipple | GCForeground | GCBackground, &gcv);
		gc = ap->stippledGC;
	}
	fillcell(mi, gc, col, row);
}
Ejemplo n.º 8
0
void iupDrawPolygon(IdrawCanvas* dc, int* points, int count, unsigned char r, unsigned char g, unsigned char b, int style)
{
    int i;
    XPoint* pnt = (XPoint*)malloc(count*sizeof(XPoint)); /* XPoint uses short for coordinates */

    for (i = 0; i < count; i++)
    {
        pnt[i].x = (short)points[2*i];
        pnt[i].y = (short)points[2*i+1];
    }

    XSetForeground(iupmot_display, dc->pixmap_gc, iupmotColorGetPixel(r, g, b));

    if (style==IUP_DRAW_FILL)
        XFillPolygon(iupmot_display, dc->pixmap, dc->pixmap_gc, pnt, count, Complex, CoordModeOrigin);
    else
    {
        XGCValues gcval;
        if (style==IUP_DRAW_STROKE_DASH)
            gcval.line_style = LineOnOffDash;
        else
            gcval.line_style = LineSolid;
        XChangeGC(iupmot_display, dc->pixmap_gc, GCLineStyle, &gcval);

        XDrawLines(iupmot_display, dc->pixmap, dc->pixmap_gc, pnt, count, CoordModeOrigin);
    }

    free(pnt);
}
Ejemplo n.º 9
0
void getimage(int left, int top, int right, int bottom, void *bitmap)
{
	int X;
	int Y;
	int width;
	int height;
	bgi_image *bm = (bgi_image*)bitmap;
	Pixmap pixmap;
	XGCValues op_gcv;
	GC op_gc;

	X = left + VPorigin.x;
	Y = top + VPorigin.y;
	width = right - left + 1;
	height = bottom - top + 1;
	
	pixmap = XCreatePixmap(dpy, window, width, height,
			       XDefaultDepth(dpy, DefaultScreen(dpy)));
	op_gc = XCreateGC(dpy, drawable, 0, NULL);
	XCopyGC(dpy, gc, (GCBackground | GCForeground | GCPlaneMask),
		op_gc);
	op_gcv.function = GXcopy;
	XChangeGC(dpy, op_gc, GCFunction, &op_gcv);
	
	XCopyArea(dpy, drawable, pixmap, op_gc, X, Y, width, height, 0, 0);
	bm->width = width;
	bm->height  = height;
	bm->pixmap = pixmap;
	XFreeGC(dpy, op_gc);
}
Ejemplo n.º 10
0
static inline void frame_drawable(RedDrawable_p* dest, const SpiceRect& area, rgb32_t color,
                                  const SpicePoint& offset)
{
    Drawable drawable = dest->source.x_drawable.drawable;
    GC gc = dest->source.x_drawable.gc;

    XLockDisplay(XPlatform::get_display());
    Colormap color_map = DefaultColormap(XPlatform::get_display(),
                                         DefaultScreen(XPlatform::get_display()));
    XColor x_color;
    x_color.red = (uint16_t)rgb32_get_red(color) << 8;
    x_color.green = (uint16_t)rgb32_get_green(color) << 8;
    x_color.blue = (uint16_t)rgb32_get_blue(color) << 8;
    x_color.flags = DoRed | DoGreen | DoBlue;
    //todo: optimize color map
    if (!XAllocColor(XPlatform::get_display(), color_map, &x_color)) {
        LOG_WARN("color map failed");
    }
    XUnlockDisplay(XPlatform::get_display());

    XGCValues gc_vals;
    gc_vals.foreground = x_color.pixel;
    gc_vals.function = GXcopy;
    gc_vals.fill_style = FillSolid;
    XChangeGC(XPlatform::get_display(), gc, GCFunction | GCForeground | GCFillStyle, &gc_vals);
    XFillRectangle(XPlatform::get_display(), drawable,
                   gc, area.left + offset.x, area.top + offset.y,
                   area.right - area.left, area.bottom - area.top);
}
Ejemplo n.º 11
0
/** Set the current color of the drawing system */
void CGWindow::SetColor(short r, short g, short b)
{
	Display *dpy = XtDisplay(m_Toplevel);
	int scr = DefaultScreen(dpy);
	Colormap cmap = DefaultColormap(dpy, scr);
 	XColor color;
  XGCValues vals;

	color.red = r;
	color.green = g;
	color.blue = b;

	if (!XAllocColor(dpy, cmap, &color)) {
		cerr << "Unable to allocate color (" << r << "," << g << "," << b << ")." << endl;
		color.pixel = BlackPixel(dpy, scr);
	}	

  /* Set the gc. */
  if (m_Debug) {
	  cout << "Setting the current color to pixel: "<< color.pixel << endl;
	}
  vals.foreground = color.pixel;
  XChangeGC(dpy, m_GC, GCForeground, &vals);

  this->Modified();

}
Ejemplo n.º 12
0
/*++++++++++++++++++++++++ draw_afd_identifier() ++++++++++++++++++++++++*/
void
draw_afd_identifier(int pos, int x, int y)
{
   XGCValues gc_values;

   /* Change color of letters when background color is to dark. */
   if ((connect_data[pos].connect_status == CONNECTING) ||
       (connect_data[pos].connect_status == NOT_WORKING2))
   {
      gc_values.foreground = color_pool[WHITE];
   }
   else
   {
      gc_values.foreground = color_pool[FG];
   }
   gc_values.background = color_pool[(int)connect_data[pos].connect_status];
   XChangeGC(display, color_letter_gc,
             GCForeground | GCBackground, &gc_values);

   XDrawImageString(display, line_window, color_letter_gc,
                    DEFAULT_FRAME_SPACE + x,
                    y + text_offset + SPACE_ABOVE_LINE,
                    connect_data[pos].afd_display_str,
                    MAX_AFDNAME_LENGTH);
   XDrawImageString(display, line_pixmap, color_letter_gc,
                    DEFAULT_FRAME_SPACE + x,
                    y + text_offset + SPACE_ABOVE_LINE,
                    connect_data[pos].afd_display_str,
                    MAX_AFDNAME_LENGTH);

   return;
}
Ejemplo n.º 13
0
void changeGC (KinoWidget w, XID font,
  KinoColor f, KinoColor b, int lineWidth)
{
  XGCValues values;
  Pixel fp, bp;

  fp = loadColor (XtDisplay ((Widget) w), f.red, f.green, f.blue);
  bp = loadColor (XtDisplay ((Widget) w), b.red, b.green, b.blue);
  if (w->kino.painter->gc == NULL)
  {
    /* if there was no previous GC, allocate a new one */

    w->kino.painter->gc = XCreateGC (XtDisplay (w), XtWindow (w), 0, NULL);
  }

  assert (w->kino.painter->gc != NULL);
  values.font = font;
  values.foreground = fp;
  values.background = bp;
  values.line_width = lineWidth;
  values.clip_mask = None;
  XChangeGC (XtDisplay (w),
    w->kino.painter->gc,
    GCFont | GCForeground | GCBackground | GCLineWidth | GCClipMask,
    &values);
  assert (w->kino.painter->gc != NULL);
}
Ejemplo n.º 14
0
static Bool
XCreateDrawable(struct drisw_drawable * pdp,
                Display * dpy, XID drawable, int visualid)
{
   XGCValues gcvalues;
   long visMask;
   XVisualInfo visTemp;
   int num_visuals;

   /* create GC's */
   pdp->gc = XCreateGC(dpy, drawable, 0, NULL);
   pdp->swapgc = XCreateGC(dpy, drawable, 0, NULL);

   gcvalues.function = GXcopy;
   gcvalues.graphics_exposures = False;
   XChangeGC(dpy, pdp->gc, GCFunction, &gcvalues);
   XChangeGC(dpy, pdp->swapgc, GCFunction, &gcvalues);
   XChangeGC(dpy, pdp->swapgc, GCGraphicsExposures, &gcvalues);

   /* visual */
   visTemp.visualid = visualid;
   visMask = VisualIDMask;
   pdp->visinfo = XGetVisualInfo(dpy, visMask, &visTemp, &num_visuals);

   if (!pdp->visinfo || num_visuals == 0)
      return False;

   /* create XImage */
   pdp->ximage = XCreateImage(dpy,
                              pdp->visinfo->visual,
                              pdp->visinfo->depth,
                              ZPixmap, 0,             /* format, offset */
                              NULL,                   /* data */
                              0, 0,                   /* width, height */
                              32,                     /* bitmap_pad */
                              0);                     /* bytes_per_line */

  /**
   * swrast does not handle 24-bit depth with 24 bpp, so let X do the
   * the conversion for us.
   */
  if (pdp->ximage->bits_per_pixel == 24)
     pdp->ximage->bits_per_pixel = 32;

   return True;
}
Ejemplo n.º 15
0
void draw_circle (int x, int y, int r, int color)
{
  color = (int) ((color / 255.0) * (num_colors - 1));

  gcvalues.foreground = colors[color].pixel;
  XChangeGC (display, gc, GCForeground, &gcvalues);
  XDrawArc (display, root, gc, x-r, y-r, r+r, r+r, 0, 360 * 64);
}
Ejemplo n.º 16
0
void drawObjects()
{
  int i=0;
  gcvalues.foreground = BG_COLOR;
  XChangeGC(dpy, context, GCForeground, &gcvalues);
  XFillRectangle(dpy, window, context, 0, 0, WSIZE*2, WSIZE*2);
  
  gcvalues.foreground = FG_COLOR;
  XChangeGC(dpy, context, GCForeground, &gcvalues);
  for(i=0;i<Nm;i++)
  {
    int XX, YY;
    XX=X[i]*WSIZE;
    YY=Y[i]*WSIZE;
    XFillArc(dpy, window, context, XX-R, YY-R, R*2*WSIZE, R*2*WSIZE, 0, 360*64);
  }
  XFlush(dpy);
}
Ejemplo n.º 17
0
void windrawstringxor(pdfapp_t *app, int x, int y, char *s)
{
	int prevfunction;
	XGCValues xgcv;

	XGetGCValues(xdpy, xgc, GCFunction, &xgcv);
	prevfunction = xgcv.function;
	xgcv.function = GXxor;
	XChangeGC(xdpy, xgc, GCFunction, &xgcv);

	XSetForeground(xdpy, xgc, WhitePixel(xdpy, DefaultScreen(xdpy)));

	XDrawString(xdpy, xwin, xgc, x, y, s, strlen(s));
	XFlush(xdpy);

	XGetGCValues(xdpy, xgc, GCFunction, &xgcv);
	xgcv.function = prevfunction;
	XChangeGC(xdpy, xgc, GCFunction, &xgcv);
}
Ejemplo n.º 18
0
void drawObjects()
{
  int i=0;
  gcvalues.foreground = BG_COLOR;
  XChangeGC(dpy, context, GCForeground, &gcvalues);
  XFillRectangle(dpy, window, context, 0, 0, WSIZE*2, WSIZE*2);
  
  gcvalues.foreground = FG_COLOR;
  XChangeGC(dpy, context, GCForeground, &gcvalues);
  for(i=0;i<n;i++)
  {
    int XX, YY;
    XX=X[i];
    YY=Y[i];
    //  printf("drawing at %d, %d\n", XX, YY);
    XFillArc(dpy, window, context, XX-R, YY-R, R*2, R*2, 0, 360*64);
  }
  XFlush(dpy);
}
Ejemplo n.º 19
0
/* Clear a shaped pixmap */
void
DASPClear(DAShapedPixmap *dasp)
{
    XGCValues gcv;

    assert(dasp != NULL);

    gcv.foreground = 0;
    XChangeGC(DADisplay, dasp->shapeGC, GCForeground, &gcv);

    /* Clear pixmaps */
    XFillRectangle(DADisplay, dasp->pixmap,
	    DAClearGC, 0, 0, dasp->geometry.width, dasp->geometry.height);
    XFillRectangle(DADisplay, dasp->shape,
	    dasp->shapeGC, 0, 0, dasp->geometry.width, dasp->geometry.height);

    gcv.foreground = 1;
    XChangeGC(DADisplay, dasp->shapeGC, GCForeground, &gcv);
}
Ejemplo n.º 20
0
static void CreateOrUpdateGoodyGC(void)
{
  XGCValues gcval;
  unsigned long gcmask;
  Pixel pfore;
  Pixel pback;

  if (colorset >= 0)
  {
    pfore = Colorset[colorset].fg;
    pback = Colorset[colorset].bg;
  }
  else
  {
    pfore = fore;
    pback = back;
  }
  gcmask = GCForeground | GCBackground | GCGraphicsExposures;
  gcval.foreground = pfore;
  gcval.background = pback;
  gcval.graphics_exposures = False;
  if (FStatusFont->font != NULL)
  {
    gcval.font = FStatusFont->font->fid;
    gcmask = GCFont;
  }
  if (statusgc)
    XChangeGC(dpy, statusgc, gcmask, &gcval);
  else
    statusgc = fvwmlib_XCreateGC(dpy, win, gcmask, &gcval);

  if (do_check_mail)
  {
    if (mailpix)
      XFreePixmap(dpy, mailpix);
    mailpix = XCreatePixmapFromBitmapData(
      dpy, win, (char *)minimail_bits, minimail_width, minimail_height,
      pfore, pback, Pdepth);
    if (wmailpix)
      XFreePixmap(dpy, wmailpix);
    wmailpix = XCreatePixmapFromBitmapData(
      dpy, win, (char *)minimail_bits, minimail_width, minimail_height,
      PictureBlackPixel(), PictureWhitePixel(), Pdepth);
    goodies_width += minimail_width + 7;
  }
  else if (do_display_clock)
  {
    goodies_width += 3;
  }
  else
  {
	  goodies_width += 0;
  }

}
Ejemplo n.º 21
0
Archivo: xftdraw.c Proyecto: aosm/X11
Bool
XftDrawSetClip (XftDraw	*draw,
		Region	r)
{
    Region			n = 0;

    if (!r && !draw->clip)
	return True;

    if (r)
    {
	n = XCreateRegion ();
	if (n)
	{
	    if (!XUnionRegion (n, r, n))
	    {
		XDestroyRegion (n);
		return False;
	    }
	}
    }
    if (draw->clip)
    {
	XDestroyRegion (draw->clip);
    }
    draw->clip = n;
    if (draw->render_able)
    {
	XRenderPictureAttributes	pa;
        if (n)
	{
	    XRenderSetPictureClipRegion (draw->dpy, draw->render.pict, n);
	}
	else
	{
	    pa.clip_mask = None;
	    XRenderChangePicture (draw->dpy, draw->render.pict,
				  CPClipMask, &pa);
	}
    }
    if (draw->core_set)
    {
	XGCValues   gv;
	
	if (n)
	    XSetRegion (draw->dpy, draw->core.draw_gc, n);
	else
	{
	    gv.clip_mask = None;
	    XChangeGC (draw->dpy, draw->core.draw_gc,
		       GCClipMask, &gv);
	}
    }
    return True;
}
Ejemplo n.º 22
0
Archivo: icon.c Proyecto: guns/subtle
VALUE
subIconDrawRect(int argc,
  VALUE *argv,
  VALUE self)
{
  VALUE data[7] = { Qnil };

  rb_scan_args(argc, argv, "43", &data[0], &data[1], &data[2], &data[3],
    &data[4], &data[5], &data[6]);

  /* Check object types */
  if(FIXNUM_P(data[0]) && FIXNUM_P(data[1]) &&
      FIXNUM_P(data[2]) && FIXNUM_P(data[3]))
    {
      SubtlextIcon *i = NULL;

      Data_Get_Struct(self, SubtlextIcon, i);
      if(i)
        {
          XGCValues gvals;

          /* Create on demand */
          if(0 == i->gc)
            i->gc = XCreateGC(display, i->pixmap, 0, NULL);

          /* Update GC */
          gvals.foreground = 1;
          gvals.background = 0;

          if(i->flags & ICON_PIXMAP)
            {
              if(!NIL_P(data[5]))
                gvals.foreground = subColorPixel(data[5], Qnil, Qnil, NULL);
              if(!NIL_P(data[6]))
                gvals.background = subColorPixel(data[6], Qnil, Qnil, NULL);
            }

          XChangeGC(display, i->gc, GCForeground|GCBackground, &gvals);

          /* Draw rect */
          if(Qtrue == data[4])
            {
              XFillRectangle(display, i->pixmap, i->gc, FIX2INT(data[0]),
                FIX2INT(data[1]), FIX2INT(data[2]), FIX2INT(data[3]));
            }
          else XDrawRectangle(display, i->pixmap, i->gc, FIX2INT(data[0]),
            FIX2INT(data[1]), FIX2INT(data[2]), FIX2INT(data[3]));

          XFlush(display);
        }
    }
  else rb_raise(rb_eArgError, "Unexpected value-types");

  return Qnil;
} /* }}} */
Ejemplo n.º 23
0
int		mlx_pixel_put(t_xvar *xvar,t_win_list *win,
			      int x,int y,int color)
{
   XGCValues	xgcv;
   
   xgcv.foreground = mlx_int_get_good_color(xvar,color);
   XChangeGC(xvar->display,win->gc,GCForeground,&xgcv);
   XDrawPoint(xvar->display,win->window,win->gc,x,y);
   if (xvar->do_flush)
     XFlush(xvar->display);
}
Ejemplo n.º 24
0
Archivo: do_arcs.c Proyecto: aosm/X11
int 
InitWideDoubleDashedEllipses(XParms xp, Parms p, int reps)
{
    int		size;
    XGCValues   gcv;
    char	dashes[2];

    GenerateWideEllipses(xp, p, False, True);
    size = p->special;
    size = (size + 9) / 10;

    /* Modify GCs to draw dashed */
    dashes[0] = 2*size;   dashes[1] = 2*size;
    gcv.line_style = LineDoubleDash;
    XChangeGC(xp->d, xp->ddfggc, GCLineStyle, &gcv);
    XChangeGC(xp->d, xp->ddbggc, GCLineStyle, &gcv);
    XSetDashes(xp->d, xp->ddfggc, 0, dashes, 2);
    XSetDashes(xp->d, xp->ddbggc, 0, dashes, 2);
    return reps;
}
Ejemplo n.º 25
0
static Bool
draw_state(ModeInfo * mi, int state)
{
	dragonstruct *dp = &dragons[MI_SCREEN(mi)];
	Display    *display = MI_DISPLAY(mi);
	GC          gc;
	CellList   *current;

	if (!state) {
		XSetForeground(display, MI_GC(mi), MI_WHITE_PIXEL(mi));
		gc = MI_GC(mi);
	} else if (state == 1) {
		XSetForeground(display, MI_GC(mi), MI_BLACK_PIXEL(mi));
		gc = MI_GC(mi);
	} else if (MI_NPIXELS(mi) > 2) {
		XSetForeground(display, MI_GC(mi), dp->color);
		gc = MI_GC(mi);
	} else {
		XGCValues   gcv;

		gcv.stipple = dp->graypix;
		gcv.foreground = MI_WHITE_PIXEL(mi);
		gcv.background = MI_BLACK_PIXEL(mi);
		XChangeGC(display, dp->stippledGC,
			  GCStipple | GCForeground | GCBackground, &gcv);
		gc = dp->stippledGC;
	}
	{	/* Draw right away, slow */
		current = dp->cellList[state];
		while (current) {
			int         col, row, ccol, crow;

			col = current->pt.x;
			row = current->pt.y;
			ccol = 2 * col + !(row & 1), crow = 2 * row;
			if (dp->vertical) {
				dp->hexagon[0].x = dp->xb + ccol * dp->xs;
				dp->hexagon[0].y = dp->yb + crow * dp->ys;
			} else {
				dp->hexagon[0].y = dp->xb + ccol * dp->xs;
				dp->hexagon[0].x = dp->yb + crow * dp->ys;
			}
			if (dp->xs == 1 && dp->ys == 1)
				XDrawPoint(display, MI_WINDOW(mi), gc,
					dp->hexagon[0].x, dp->hexagon[0].y);
			else
				XFillPolygon(display, MI_WINDOW(mi), gc,
					dp->hexagon, 6, Convex, CoordModePrevious);
			current = current->next;
		}
	}
	XFlush(MI_DISPLAY(mi));
	return True;
}
Ejemplo n.º 26
0
int		mlx_string_put(t_xvar *xvar,t_win_list *win,
			       int x,int y,int color,char *string)
{
   XGCValues	xgcv;
   
   xgcv.foreground = mlx_int_get_good_color(xvar,color);
   XChangeGC(xvar->display,win->gc,GCForeground,&xgcv);
   XDrawString(xvar->display,win->window,win->gc,x,y,string,strlen(string));
   if (xvar->do_flush)
     XFlush(xvar->display);
}
static void fill_rect(struct test_target *tt,
		      int alu, int color,
		      int x, int y, int w, int h)
{
	XGCValues val;

	val.function = alu;
	val.foreground = color;
	XChangeGC(tt->dpy->dpy, tt->gc, GCFunction | GCForeground, &val);

	XFillRectangle(tt->dpy->dpy, tt->draw, tt->gc, x, y, w, h);
}
Ejemplo n.º 28
0
int
XInitDither(Display *display, int screen, GC gc, unsigned long fg,
            unsigned long bg)
{

    char *bits;
    int count;
    int chars_bitmap = dither_char_bitmap();
    int bit;
    XGCValues xgcv;

    DITHERINIT = 1;

    /*
     * First thing I should do is load in the Pixmaps
     */
    bits = (char *) malloc(chars_bitmap * sizeof(char));

    for (count = 0; count < XDitherMax; count++) {

        /*
         * Load in the next bitmap
         */
        for (bit = 0; bit < chars_bitmap; bit++)
            bits[bit] = XDitherBits[count * chars_bitmap + bit];

        /*
         * Create it and put it into the Pixmap array
         */
        XDither[count] = XCreatePixmapFromBitmapData(display,
                                                RootWindow(display, screen),
                                                     bits,
                                                 XDitherWidth, XDitherWidth,
                                                BlackPixel(display, screen),
                                                WhitePixel(display, screen),
                                                     1);
    }

    /*
     * Now reset the gc values to be as I need them
     */
    xgcv.background = bg;
    xgcv.foreground = fg;
    xgcv.fill_style = FillOpaqueStippled;
    xgcv.stipple = XDither[4];

    XChangeGC(display, gc,
              GCForeground | GCBackground | GCFillStyle | GCStipple, &xgcv);

    return (XDitherMax);

}
Ejemplo n.º 29
0
  void drawPoint(XPoint point, Color point_color, int function){

    gc_vals.foreground = point_color;

    XChangeGC(display, gc, GCForeground, &gc_vals);

    XSync(display, false);

    XDrawPoint(display, curr_d, gc, point.x, point.y);

    XSync(display, false);

  }
Ejemplo n.º 30
0
void iupDrawLine(IdrawCanvas* dc, int x1, int y1, int x2, int y2, unsigned char r, unsigned char g, unsigned char b, int style)
{
    XGCValues gcval;
    if (style==IUP_DRAW_STROKE_DASH)
        gcval.line_style = LineOnOffDash;
    else
        gcval.line_style = LineSolid;
    XChangeGC(iupmot_display, dc->pixmap_gc, GCLineStyle, &gcval);

    XSetForeground(iupmot_display, dc->pixmap_gc, iupmotColorGetPixel(r, g, b));

    XDrawLine(iupmot_display, dc->pixmap, dc->pixmap_gc, x1, y1, x2, y2);
}