Exemple #1
0
Fichier : x.c Projet : Limsik/e17
static              Pixmap
_EWindowGetShapePixmap(Win win, unsigned int fg, unsigned int bg)
{
   Pixmap              mask;
   GC                  gc;
   int                 i;
   const XRectangle   *rect;

   if (win->num_rect == 0)	/* Not shaped */
      return None;

   mask = ECreatePixmap(win, win->w, win->h, 1);
   gc = EXCreateGC(mask, 0, NULL);

   XSetForeground(disp, gc, bg);
   XFillRectangle(disp, mask, gc, 0, 0, win->w, win->h);

   XSetForeground(disp, gc, fg);
   rect = win->rects;
   for (i = 0; i < win->num_rect; i++)
      XFillRectangle(disp, mask, gc, rect[i].x, rect[i].y,
		     rect[i].width, rect[i].height);

   EXFreeGC(gc);

   return mask;
}
Exemple #2
0
Fichier : x.c Projet : Limsik/e17
void
EXCopyArea(Drawable src, Drawable dst, int sx, int sy, unsigned int w,
	   unsigned int h, int dx, int dy)
{
   GC                  gc;

   gc = EXCreateGC(src, 0, NULL);
   XCopyArea(disp, src, dst, gc, sx, sy, w, h, dx, dy);
   EXFreeGC(gc);
}
Exemple #3
0
static void
ImagestateDrawNoImg(ImageState * is, Drawable draw, int x, int y, int w, int h)
{
   GC                  gc;

   ImagestateColorsAlloc(is);

   gc = EXCreateGC(draw, 0, NULL);
   XSetFillStyle(disp, gc, FillSolid);
   XSetForeground(disp, gc, is->bg_pixel);
   XFillRectangle(disp, draw, gc, x, y, w, h);
   if (is->bevelstyle != BEVEL_NONE)
      ImagestateDrawBevel(is, draw, gc, x, y, w, h);
   EXFreeGC(gc);
}
Exemple #4
0
Fichier : x.c Projet : Limsik/e17
Pixmap
EXCreatePixmapCopy(Pixmap src, unsigned int w, unsigned int h,
		   unsigned int depth)
{
   Pixmap              pmap;
   GC                  gc;

   pmap = XCreatePixmap(disp, src, w, h, depth);
   gc = EXCreateGC(src, 0, NULL);
   XCopyArea(disp, src, pmap, gc, 0, 0, w, h, 0, 0);
   EXFreeGC(gc);
#if DEBUG_PIXMAP
   Eprintf("%s: %#lx\n", __func__, pmap);
#endif
   return pmap;
}
Exemple #5
0
Fichier : x.c Projet : Limsik/e17
void
EXCopyAreaTiled(Drawable src, Pixmap mask, Drawable dst, int sx, int sy,
		unsigned int w, unsigned int h, int dx, int dy)
{
   GC                  gc;
   XGCValues           gcv;

   gcv.fill_style = FillTiled;
   gcv.tile = src;
   gcv.ts_x_origin = sx;
   gcv.ts_y_origin = sy;
   gcv.clip_mask = mask;
   gc = EXCreateGC(dst, GCFillStyle |
		   GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCClipMask,
		   &gcv);
   XFillRectangle(disp, dst, gc, dx, dy, w, h);
   EXFreeGC(gc);
}
Exemple #6
0
Fichier : x.c Projet : Limsik/e17
static void
EShapeCombineMaskTiled(Win win, int dest, int x, int y,
		       Pixmap pmap, int op, int w, int h)
{
   XGCValues           gcv;
   GC                  gc;
   Window              tm;

   gcv.fill_style = FillTiled;
   gcv.tile = pmap;
   gcv.ts_x_origin = 0;
   gcv.ts_y_origin = 0;
   tm = ECreatePixmap(win, w, h, 1);
   gc = EXCreateGC(tm, GCFillStyle | GCTile |
		   GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
   XFillRectangle(disp, tm, gc, 0, 0, w, h);
   EXFreeGC(gc);
   EShapeCombineMask(win, dest, x, y, tm, op);
   EFreePixmap(tm);
}
Exemple #7
0
static void
_ShapeDrawNontranslucent(EWin * ewin, int md, int firstlast,
                         int xn, int yn, int wn, int hn)
{
    ShapeData          *psd = (ShapeData *) ewin->shape_data;
    DrawFunc           *drf;

    if (firstlast == 0)
    {
        XGCValues           gcv;

        gcv.function = GXxor;
        gcv.foreground = Dpy.pixel_white;
        if (gcv.foreground == 0)
            gcv.foreground = Dpy.pixel_black;
        gcv.subwindow_mode = IncludeInferiors;
        psd->gc = EXCreateGC(psd->root,
                             GCFunction | GCForeground | GCSubwindowMode, &gcv);
    }

    drf = draw_functions[md - 1];

    if (firstlast > 0)
        drf(psd->root, psd->gc, psd->xo, psd->yo, psd->wo, psd->ho,
            psd->bl, psd->br, psd->bt, psd->bb);

    CoordsShow(ewin);

    if (firstlast < 2)
        drf(psd->root, psd->gc, xn, yn, wn, hn,
            psd->bl, psd->br, psd->bt, psd->bb);

    if (firstlast == 2)
    {
        EXFreeGC(psd->gc);
        psd->gc = NULL;
    }
}
Exemple #8
0
void
ITApply(Win win, ImageClass * ic, ImageState * is,
	int state, int active, int sticky, int image_type,
	TextClass * tc, TextState * ts, const char *text, int flags)
{
   int                 w, h;

   if (!win || !ic)
      return;

   w = WinGetW(win);
   h = WinGetH(win);
   if (w <= 0 || h <= 0)
      return;

   if (!is)
      is = ImageclassGetImageState(ic, state, active, sticky);
   if (!is)
      return;

   if (tc && text)
     {
	if (!ts)
	   ts = TextclassGetTextState(tc, state, active, sticky);
     }

   if (!is->im)
      ImagestateRealize(is);

   /* Imlib2 will not render pixmaps with dimensions > 8192 */
   if (is->im && w <= 8192 && h <= 8192)
     {
	PmapMask            pmm;

	ImagestateMakePmapMask(is, win, &pmm, IC_FLAG_MAKE_MASK, w, h,
			       image_type);

	if (pmm.pmap)
	  {
	     Pixmap              pmap = pmm.pmap;

	     if ((ts && text) || (is->bevelstyle != BEVEL_NONE) ||
		 (flags & ITA_BGPMAP))
	       {
		  if (pmm.type != 0)
		    {
		       pmap = EGetWindowBackgroundPixmap(win);
		       EXCopyAreaTiled(pmm.pmap, None, pmap, 0, 0, w, h, 0, 0);
		    }

		  if (is->bevelstyle != BEVEL_NONE)
		    {
		       GC                  gc;

		       gc = EXCreateGC(WinGetXwin(win), 0, NULL);
		       ImagestateDrawBevel(is, pmap, gc, 0, 0, w, h);
		       EXFreeGC(gc);
		    }

		  if (ts && text)
		     TextstateTextDraw(ts, win, pmap, text, 0, 0, w, h,
				       &(ic->padding), 0,
				       TextclassGetJustification(tc),
				       flags & ITA_JUSTV);
	       }

	     /* Set window pixmap */
	     if (pmap == pmm.pmap)
	       {
		  ESetWindowBackgroundPixmap(win, pmap);
		  EFreeWindowBackgroundPixmap(win);
	       }

	     if (pmm.w == w && pmm.h == h)
		EShapeSetMask(win, 0, 0, pmm.mask);
	     else if (pmm.mask)
		EShapeSetMaskTiled(win, 0, 0, pmm.mask, w, h);
	  }

	PmapMaskFree(&pmm);

	if ((is->unloadable) || (Conf.memory_paranoia))
	  {
	     EImageFree(is->im);
	     is->im = NULL;
	  }
     }
   else
     {
	ImagestateColorsAlloc(is);

	if (is->bevelstyle == BEVEL_NONE && !text)
	  {
	     ESetWindowBackground(win, is->bg_pixel);
	  }
	else
	  {
	     Pixmap              pmap;

	     pmap = EGetWindowBackgroundPixmap(win);
	     ImagestateDrawNoImg(is, pmap, 0, 0, w, h);
	     if (ts && text)
		TextstateTextDraw(ts, win, pmap, text, 0, 0, w, h,
				  &(ic->padding), 0,
				  TextclassGetJustification(tc),
				  flags & ITA_JUSTV);
	  }
     }
   EClearWindow(win);
}
Exemple #9
0
static void
MenuDrawItem(Menu * m, MenuItem * mi, char shape, int state)
{
   PmapMask           *mi_pmm;

   if (state >= 0)
      mi->state = state;
   mi_pmm = &(mi->pmm[(int)(mi->state)]);

   if (!mi_pmm->pmap)
     {
	int                 x, y, w, h;
	int                 item_type;
	ImageClass         *ic;
	GC                  gc;
	PmapMask            pmm;

	EGetGeometry(mi->win, NULL, &x, &y, &w, &h, NULL, NULL);

	mi_pmm->type = 0;
	mi_pmm->pmap = ECreatePixmap(mi->win, w, h, 0);
	mi_pmm->mask = None;

	ic = (mi->child) ? m->style->sub_iclass : m->style->item_iclass;
	item_type = (mi->state != STATE_NORMAL) ? ST_MENU_ITEM : ST_MENU;

	if (!m->style->use_item_bg)
	  {
	     gc = EXCreateGC(m->pmm.pmap, 0, NULL);
	     XCopyArea(disp, WinGetPmap(m->win), mi_pmm->pmap, gc, x, y, w, h,
		       0, 0);
	     if ((mi->state != STATE_NORMAL) || (mi->child))
	       {
		  ImageclassApplyCopy(ic, mi->win, w, h, 0, 0, mi->state, &pmm,
				      IC_FLAG_MAKE_MASK, item_type);
		  EXCopyAreaTiled(pmm.pmap, pmm.mask, mi_pmm->pmap,
				  0, 0, w, h, 0, 0);
		  PmapMaskFree(&pmm);
	       }
	     EXFreeGC(gc);
	  }
	else
	  {
	     ImageclassApplyCopy(ic, mi->win, w, h, 0, 0, mi->state, &pmm,
				 IC_FLAG_MAKE_MASK, item_type);
	     EXCopyAreaTiled(pmm.pmap, pmm.mask, mi_pmm->pmap,
			     0, 0, w, h, 0, 0);
	     PmapMaskFree(&pmm);
	  }

	if (mi->text)
	  {
	     TextDraw(m->style->tclass, mi->win, mi_pmm->pmap, 0, 0, mi->state,
		      _(mi->text), mi->text_x, mi->text_y, mi->text_w,
		      mi->text_h, 17,
		      TextclassGetJustification(m->style->tclass));
	  }
     }

   ESetWindowBackgroundPixmap(mi->win, mi_pmm->pmap);
   EShapeSetMask(mi->win, 0, 0, mi_pmm->mask);
   EClearWindow(mi->win);

   if ((shape) && (m->style->use_item_bg))
      EShapePropagate(m->win);
}
Exemple #10
0
static void
ImagestateDrawBevel(ImageState * is, EX_Drawable win,
		    int x, int y, int w, int h)
{
   GC                  gc;

   gc = EXCreateGC(win, 0, NULL);

   ImagestateColorsAlloc(is);

   switch (is->bevelstyle)
     {
     case BEVEL_AMIGA:
	XSetForeground(disp, gc, is->hihi_pixel);
	LINE(0, 0, w - 2, 0);
	LINE(0, 0, 0, h - 2);
	XSetForeground(disp, gc, is->lolo_pixel);
	LINE(1, h - 1, w - 1, h - 1);
	LINE(w - 1, 1, w - 1, h - 1);
	break;
     case BEVEL_MOTIF:
	XSetForeground(disp, gc, is->hi_pixel);
	LINE(0, 0, w - 1, 0);
	LINE(0, 0, 0, h - 1);
	LINE(1, 1, w - 2, 1);
	LINE(1, 1, 1, h - 2);
	XSetForeground(disp, gc, is->lo_pixel);
	LINE(0, h - 1, w - 1, h - 1);
	LINE(w - 1, 1, w - 1, h - 1);
	LINE(1, h - 2, w - 2, h - 2);
	LINE(w - 2, 2, w - 2, h - 2);
	break;
     case BEVEL_NEXT:
	XSetForeground(disp, gc, is->hihi_pixel);
	LINE(0, 0, w - 1, 0);
	LINE(0, 0, 0, h - 1);
	XSetForeground(disp, gc, is->hi_pixel);
	LINE(1, 1, w - 2, 1);
	LINE(1, 1, 1, h - 2);
	XSetForeground(disp, gc, is->lolo_pixel);
	LINE(1, h - 1, w - 1, h - 1);
	LINE(w - 1, 1, w - 1, h - 1);
	XSetForeground(disp, gc, is->lo_pixel);
	LINE(2, h - 2, w - 2, h - 2);
	LINE(w - 2, 2, w - 2, h - 2);
	break;
     case BEVEL_DOUBLE:
	XSetForeground(disp, gc, is->hi_pixel);
	LINE(0, 0, w - 2, 0);
	LINE(0, 0, 0, h - 2);
	XSetForeground(disp, gc, is->lo_pixel);
	LINE(1, 1, w - 3, 1);
	LINE(1, 1, 1, h - 3);
	XSetForeground(disp, gc, is->lo_pixel);
	LINE(1, h - 1, w - 1, h - 1);
	LINE(w - 1, 1, w - 1, h - 1);
	XSetForeground(disp, gc, is->hi_pixel);
	LINE(2, h - 2, w - 2, h - 2);
	LINE(w - 2, 2, w - 2, h - 2);
	break;
     case BEVEL_WIDEDOUBLE:
	XSetForeground(disp, gc, is->hihi_pixel);
	LINE(0, 0, w - 1, 0);
	LINE(0, 0, 0, h - 1);
	XSetForeground(disp, gc, is->hi_pixel);
	LINE(1, 1, w - 2, 1);
	LINE(1, 1, 1, h - 2);
	LINE(3, h - 4, w - 4, h - 4);
	LINE(w - 4, 3, w - 4, h - 4);
	XSetForeground(disp, gc, is->lolo_pixel);
	LINE(1, h - 1, w - 1, h - 1);
	LINE(w - 1, 1, w - 1, h - 1);
	XSetForeground(disp, gc, is->lo_pixel);
	LINE(2, h - 2, w - 2, h - 2);
	LINE(w - 2, 2, w - 2, h - 2);
	LINE(3, 3, w - 4, 3);
	LINE(3, 3, 3, h - 4);
	break;
     case BEVEL_THINPOINT:
	XSetForeground(disp, gc, is->hi_pixel);
	LINE(0, 0, w - 2, 0);
	LINE(0, 0, 0, h - 2);
	XSetForeground(disp, gc, is->lo_pixel);
	LINE(1, h - 1, w - 1, h - 1);
	LINE(w - 1, 1, w - 1, h - 1);
	XSetForeground(disp, gc, is->hihi_pixel);
	LINE(0, 0, 1, 0);
	LINE(0, 0, 0, 1);
	XSetForeground(disp, gc, is->lolo_pixel);
	LINE(w - 2, h - 1, w - 1, h - 1);
	LINE(w - 1, h - 2, w - 1, h - 1);
	break;
     case BEVEL_THICKPOINT:
	XSetForeground(disp, gc, is->hi_pixel);
	RECT(x, y, w - 1, h - 1);
	break;
     default:
	break;
     }

   EXFreeGC(gc);
}
Exemple #11
0
static void
IB_Animate_A(char iconify, EWin * ewin, EWin * ibox)
{
   EWin               *fr, *to;
   unsigned int        t0;
   double              a, aa, spd;
   int                 x, y, x1, y1, x2, y2, x3, y3, x4, y4, w, h;
   int                 fx, fy, fw, fh, tx, ty, tw, th;
   Window              root = WinGetXwin(VROOT);
   GC                  gc;
   XGCValues           gcv;

   /* Window: Extents, Iconbox: Center */
   if (iconify)
     {
	fr = ewin;
	to = ibox;
	fw = EoGetW(fr) + 4;
	fh = EoGetH(fr) + 4;
	fx = EoGetX(fr) - 2;
	fy = EoGetY(fr) - 2;
	tw = 4;
	th = 4;
	tx = EoGetX(to) + EoGetW(to) / 2 - 2;
	ty = EoGetY(to) + EoGetH(to) / 2 - 2;
     }
   else
     {
	fr = ibox;
	to = ewin;
	fw = 4;
	fh = 4;
	fx = EoGetX(fr) + EoGetW(fr) / 2 - 2;
	fy = EoGetY(fr) + EoGetH(fr) / 2 - 2;
	tw = EoGetW(to) + 4;
	th = EoGetH(to) + 4;
	tx = EoGetX(to) + 2;
	ty = EoGetY(to) + 2;
     }
   fx += EoGetX(EoGetDesk(fr));
   fy += EoGetY(EoGetDesk(fr));
   tx += EoGetX(EoGetDesk(to));
   ty += EoGetY(EoGetDesk(to));

   gcv.subwindow_mode = IncludeInferiors;
   gcv.function = GXxor;
   gcv.line_width = 2;
   gcv.foreground = Dpy.pixel_white;
   if (gcv.foreground == 0)
      gcv.foreground = Dpy.pixel_black;
   gc = EXCreateGC(root,
		   GCFunction | GCForeground | GCSubwindowMode | GCLineWidth,
		   &gcv);

   spd = (1. * IB_ANIM_STEP) / IB_ANIM_TIME;

   t0 = GetTimeMs();
   for (a = 0.0; a < 1.0; a += spd)
     {
	aa = 1.0 - a;

	x = (int)((fx * aa) + (tx * a));
	y = (int)((fy * aa) + (ty * a));
	w = (int)((fw * aa) + (tw * a));
	h = (int)((fh * aa) + (th * a));

	x = (2 * x + w) / 2;	/* x middle */
	y = (2 * y + h) / 2;	/* y middle */
	w /= 2;			/* width/2 */
	h /= 2;			/* height/2 */

	x1 = (int)(x + w * (1 - .5 * sin(3.14159 + a * 6.2831853072)));
	y1 = (int)(y + h * cos(a * 6.2831853072));
	x2 = (int)(x + w * (1 - .5 * sin(a * 6.2831853072)));
	y2 = (int)(y - h * cos(a * 6.2831853072));
	x3 = (int)(x - w * (1 - .5 * sin(3.14159 + a * 6.2831853072)));
	y3 = (int)(y - h * cos(a * 6.2831853072));
	x4 = (int)(x - w * (1 - .5 * sin(a * 6.2831853072)));
	y4 = (int)(y + h * cos(a * 6.2831853072));

	XDrawLine(disp, root, gc, x1, y1, x2, y2);
	XDrawLine(disp, root, gc, x2, y2, x3, y3);
	XDrawLine(disp, root, gc, x3, y3, x4, y4);
	XDrawLine(disp, root, gc, x4, y4, x1, y1);

	ESync(0);
	IB_Animate_Sleep(t0, a);

	XDrawLine(disp, root, gc, x1, y1, x2, y2);
	XDrawLine(disp, root, gc, x2, y2, x3, y3);
	XDrawLine(disp, root, gc, x3, y3, x4, y4);
	XDrawLine(disp, root, gc, x4, y4, x1, y1);
     }

   EXFreeGC(gc);
}
Exemple #12
0
static void
IB_Animate_B(char iconify, EWin * ewin, EWin * ibox)
{
   EWin               *fr, *to;
   unsigned int        t0;
   double              a, spd;
   int                 x, y, w, h;
   int                 fx, fy, fw, fh, tx, ty, tw, th;
   Window              root = WinGetXwin(VROOT);
   GC                  gc;
   XGCValues           gcv;

   if (iconify)
     {
	fr = ewin;
	to = ibox;
     }
   else
     {
	fr = ibox;
	to = ewin;
     }

   fx = EoGetX(fr) - 2;
   fy = EoGetY(fr) - 2;
   fw = EoGetW(fr) + 3;
   fh = EoGetH(fr) + 3;

   tx = EoGetX(to) - 2;
   ty = EoGetY(to) - 2;
   tw = EoGetW(to) + 3;
   th = EoGetH(to) + 3;

   fx += EoGetX(EoGetDesk(fr));
   fy += EoGetY(EoGetDesk(fr));
   tx += EoGetX(EoGetDesk(to));
   ty += EoGetY(EoGetDesk(to));

   gcv.subwindow_mode = IncludeInferiors;
   gcv.function = GXxor;
   gcv.fill_style = FillOpaqueStippled;
   gcv.foreground = Dpy.pixel_white;
   if (gcv.foreground == 0)
      gcv.foreground = Dpy.pixel_black;
   gc = EXCreateGC(root,
		   GCFunction | GCForeground | GCSubwindowMode | GCFillStyle,
		   &gcv);

   XDrawLine(disp, root, gc, fx, fy, tx, ty);
   XDrawLine(disp, root, gc, fx + fw, fy, tx + tw, ty);
   XDrawLine(disp, root, gc, fx, fy + fh, tx, ty + th);
   XDrawLine(disp, root, gc, fx + fw, fy + fh, tx + tw, ty + th);
   XDrawRectangle(disp, root, gc, tx, ty, tw, th);
   XDrawRectangle(disp, root, gc, fx, fy, fw, fh);

   spd = (1. * IB_ANIM_STEP) / IB_ANIM_TIME;

   t0 = GetTimeMs();
   for (a = 0.0; a < 1.0; a += spd)
     {
	x = (int)(fx + a * (tx - fx));
	w = (int)(fw + a * (tw - fw));
	y = (int)(fy + a * (ty - fy));
	h = (int)(fh + a * (th - fh));
	XDrawRectangle(disp, root, gc, x, y, w, h);

	ESync(0);
	IB_Animate_Sleep(t0, a);

	XDrawRectangle(disp, root, gc, x, y, w, h);
     }

   XDrawLine(disp, root, gc, fx, fy, tx, ty);
   XDrawLine(disp, root, gc, fx + fw, fy, tx + tw, ty);
   XDrawLine(disp, root, gc, fx, fy + fh, tx, ty + th);
   XDrawLine(disp, root, gc, fx + fw, fy + fh, tx + tw, ty + th);
   XDrawRectangle(disp, root, gc, tx, ty, tw, th);
   XDrawRectangle(disp, root, gc, fx, fy, fw, fh);

   EXFreeGC(gc);
}