Exemplo n.º 1
0
void
XPSDrawLine(Display *display, Drawable drawable, GC context,
            int x1, int y1, int x2, int y2)
{
    if (output_flag == XOUT)
    {
        XDrawLine(display, drawable, context, x1, y1, x2, y2);
    }
    else
    {
        /*
         * get the current foreground color from the graphics context
         */

        XGCValues values;

        XGetGCValues(display, context, GCForeground | GCLineWidth, &values);
        PSSetPixel(display, values.foreground);
        PSSetLineWidth(values.line_width);
        PSNewpath();
        PSMoveto(x1, y1);
        PSLineto(x2, y2);
        PSStroke();
    }
}
Exemplo n.º 2
0
int
DPSCAPCopyGCProc(
    Display *dpy,
    GC gc,
    XExtCodes *codes)
{
    XGCValues values;
    DPSCAPData my;
    XExtData *extData = XFindOnExtensionList(
      CSDPSHeadOfDpyExt(dpy),
      codes->extension);

    if (extData)
        my = (DPSCAPData) extData->private_data;
    else
        return(0);

    /* We change the GC unconditionally, since friggin' XCopyGC
       clears the dirty bits of the values that are copied! */

    DPSAssertWarn(XGetGCValues(dpy, gc, DPSGCBITS & ~(GCClipMask), &values),
	NULL, "DPS NX: XGetGCValues returned False\n");
    values.clip_mask = gc->values.clip_mask;
    DPSCAPChangeGC(my->agent, gc, DPSGCBITS, &values);
    /* We have to make sure that the agent completely processes
	the change to the GC.  If we allow the agent to update the
	GC in its own sweet time, the stupid client may delete the
	GC after the agent has already queued a request to, e.g.,
	copy the GC, but before the request is flushed. */
    XDPSLSync(dpy);
    return(1);
}
Exemplo n.º 3
0
//=========================================
// XColorSetup
//-----------------------------------------
XTColor XColorSetup (XInit xi,XTFont xt,Window win,Color col) {
	// ...
	// Create two pixmaps initially containing the background
	// of the window win and use them for drawing with double
	// buffering to avoid flickering while the string fade out
	// Create a XFT drawable needed to print text using xft
	// ---
	XGCValues values;
	XTColor xc;

	xc.FTcolor = (XftColor*)malloc(sizeof(XftColor));
	xc.PBack = XCreatePixmap (xi.dpy,win,xt.XTwidth,xt.XTheight,xi.DDepth);
	xc.PAint = XCreatePixmap (xi.dpy,win,xt.XTwidth,xt.XTheight,xi.DDepth);
	XCopyArea(
		xi.dpy,win,xc.PAint,xi.DGc,0,0,xt.XTwidth,xt.XTheight,0,0
	);
	XCopyArea(
		xi.dpy,win,xc.PBack,xi.DGc,0,0,xt.XTwidth,xt.XTheight,0,0
	);
	xc.color.red   = ((col.red   << 8) | col.red );
	xc.color.green = ((col.green << 8) | col.green);
	xc.color.blue  = ((col.blue  << 8) | col.blue );
	XAllocColor(xi.dpy,xi.DMap,&xc.color);
	XSetForeground(xi.dpy,xi.DGc,xc.color.pixel);

	XGetGCValues (xi.dpy, xi.DGc, GCForeground|GCBackground, &values);
	xc.FTdraw = XftDrawCreate (
		xi.dpy, xc.PAint, xi.DVisual, xi.DMap
	);
	xc.FTcolor->color.red   = xc.color.red;
	xc.FTcolor->color.green = xc.color.green;
	xc.FTcolor->color.blue  = xc.color.blue;
	return(xc);
}
Exemplo n.º 4
0
/*----------------------------------------------------------------------*/
/* extern */ void
XfeMenuItemEraseAccent(Widget			item,
					   unsigned char	accent_type,
					   Dimension		offset_left,
					   Dimension		offset_right,
					   Dimension		shadow_thickness,
					   Dimension		accent_thickness)
{
	Widget		pw;
	GC			gc;
	XGCValues	values;
	int			subwindow_mode;

	/* duh */
	if (accent_type == XmACCENT_NONE)
	{
		return;
	}

	assert( _XfeIsAlive(item) );
	assert( XmIsPushButton(item) || XmIsCascadeButton(item) );

	pw = _XfeParent(item);

	assert( XmIsRowColumn(pw) );

	gc = _XfemBackgroundGC(pw);

	/* Remember the old wubwindow mode values */
	XGetGCValues(XtDisplay(item),gc,GCSubwindowMode,&values);

	subwindow_mode = values.subwindow_mode;

	/* Force the subwindow mode to IncludeInferiors */
	XSetSubwindowMode(XtDisplay(item),gc,IncludeInferiors);

	switch(accent_type)
	{
	case XmACCENT_BOTTOM:
		AccentBottom(item,gc,None,offset_left,offset_right,
					 shadow_thickness,accent_thickness,ACCENT_ERASE);
		break;

	case XmACCENT_ALL:
		AccentAll(item,gc,None,offset_left,offset_right,
				  shadow_thickness,accent_thickness,ACCENT_ERASE);
		break;

	case XmACCENT_TOP:
		AccentTop(item,gc,None,offset_left,offset_right,
				  shadow_thickness,accent_thickness,ACCENT_ERASE);
		break;

	default:
		break;
	}

	/* Restore the old subwindow mode */
	XSetSubwindowMode(XtDisplay(item),gc,subwindow_mode);
}
Exemplo n.º 5
0
void getlinesettings(struct linesettingstype *lineinfo)
{
        XGCValues values;

        XGetGCValues(dpy, gc, GCLineStyle | GCLineWidth, &values);
        
        switch (values.line_style) {
                case LineSolid:
                        lineinfo->linestyle = SOLID_LINE;
                        break;
                case LineOnOffDash:
                        lineinfo->linestyle = DASHED_LINE;
                        break;
                default:
                        break;
        }
        switch (values.line_width) {
                case 0: case 1:
                        lineinfo->thickness = NORM_WIDTH;
                        break;
                case 3:
                        lineinfo->thickness = THICK_WIDTH;
                        break;
                default:
                        lineinfo->thickness = values.line_width;
                        break;
        }
}
Exemplo n.º 6
0
 void webclear(Widget iw_dum, XtPointer data, XtPointer call_data)
 {

 XGCValues    gcval;

 // Preserve current foreground
 XGetGCValues(idispl, icontx, GCForeground, &gcval);
 
 // Set clearing color
 if (icolorxb < 1) icolorxb = 0;
 XSetForeground(idispl,icontx,icolorxb);

 // Clear imagsav backing store 
 XFillRectangle(idispl,imagsav,icontx,0,0,iwidex,ihighx);

 // Clear displayed window
 XClearWindow(idispl,iwin);

 expos_cb(NULL,NULL,NULL);

 // Restore current color in icontx
 XSetForeground(idispl, icontx, gcval.foreground);

 // Should start next image at upper left corner 
 nbot       = ihighx;
 ntop       = ihighx;

 neednewmap = TRUE;

 return;
 }
Exemplo n.º 7
0
void
XPSFillArc(Display *display, Drawable drawable, GC context,
           int x, int y, int w, int h, int angle1, int angle2)
{
    if (output_flag == XOUT)
    {
        XFillArc(display, drawable, context, x, y, w, h, angle1, angle2);
    }
    else
    {
        XGCValues values;

        XGetGCValues(display, context, GCForeground | GCLineWidth
                     | GCArcMode, &values);
        PSNewpath();
        PSSetPixel(display, values.foreground);
        PSSetLineWidth(values.line_width);

        if (values.arc_mode == ArcPieSlice)
            PSMoveto(x + w / 2, y + h / 2);

        PSArc(x + w / 2.0, y + h / 2.0, w / 2.0, angle1 / 64.0,
              angle2 / 64.0);
        PSClosefill();
    }
}
Exemplo n.º 8
0
//=========================================
// setText
//-----------------------------------------
XImage* setText (Display* dpy,int screen,char* text, int* x, int* y) {
	Window root = RootWindow    ( dpy,screen );
	int DWidth  = DisplayWidth  ( dpy,screen );
	int DHeight = DisplayHeight ( dpy,screen );

	XftPattern *pattern = NULL;
	XftFont*  FTfont    = NULL;
	XftDraw*  FTdraw    = NULL;
	XftColor* FTcolor   = NULL;
	XImage*   Image     = NULL;

	XGlyphInfo FTinfo;
	XColor color;
	XGCValues values;
	int XTwidth;
	int XTheight;
	int x1,y1;

	pattern = XftNameParse (XFTFONT);
	pattern = XftFontMatch (dpy,screen,pattern,NULL);
	FTfont  = XftFontOpenPattern (dpy, pattern);
	XftTextExtentsUtf8 (
		dpy,FTfont,text,strlen(text),&FTinfo
	);
	XTwidth = FTinfo.xOff;
	XTheight= FTfont->height + 20;
	FTdraw  = XftDrawCreate (
		dpy, root, DefaultVisual(dpy,screen),DefaultColormap(dpy,screen)
	);
	FTcolor = (XftColor*)malloc(sizeof(XftColor));
	color.red   = 255 << 8;
	color.green = 255 << 8;
	color.blue  = 255 << 8;
	XAllocColor (dpy,DefaultColormap(dpy,screen),&color);
	XSetForeground(dpy,DefaultGC (dpy,screen),color.pixel);
	XGetGCValues (
		dpy, DefaultGC (dpy,screen),
		GCForeground | GCBackground, &values
	);
	FTcolor->color.red   = color.red;
	FTcolor->color.green = color.green;
	FTcolor->color.blue  = color.blue;
	FTcolor->color.alpha = 0xffff;

	x1 = (int)((DWidth  / 2) - (XTwidth  / 2));
	y1 = (int)((DHeight / 2) - (XTheight / 2));

	XftDrawStringUtf8 (
		FTdraw, FTcolor,FTfont,x1,y1,text,strlen(text)
	);
	XFlush (dpy);
	y1 = (int)((DHeight / 2) - XTheight);
	Image = XGetImage(
		dpy,root,x1,y1,XTwidth,XTheight,AllPlanes,XYPixmap
	);
	*x = x1;
	*y = y1;
	return (Image);
}
Exemplo n.º 9
0
void Gi::FloodFill(double X, double Y)
{
  XGCValues gcv;

  XGetGCValues(dpy, fill_gc, GCForeground, &gcv);

  floodfill(xcon(X), ycon(Y), gcv.foreground);
}
Exemplo n.º 10
0
static void
xftfont_get_colors (struct frame *f, struct face *face, GC gc,
		    struct xftface_info *xftface_info,
		    XftColor *fg, XftColor *bg)
{
  if (xftface_info && face->gc == gc)
    {
      *fg = xftface_info->xft_fg;
      if (bg)
	*bg = xftface_info->xft_bg;
    }
  else
    {
      XGCValues xgcv;
      bool fg_done = 0, bg_done = 0;

      block_input ();
      XGetGCValues (FRAME_X_DISPLAY (f), gc,
		    GCForeground | GCBackground, &xgcv);
      if (xftface_info)
	{
	  if (xgcv.foreground == face->foreground)
	    *fg = xftface_info->xft_fg, fg_done = 1;
	  else if (xgcv.foreground == face->background)
	    *fg = xftface_info->xft_bg, fg_done = 1;
	  if (! bg)
	    bg_done = 1;
	  else if (xgcv.background == face->background)
	    *bg = xftface_info->xft_bg, bg_done = 1;
	  else if (xgcv.background == face->foreground)
	    *bg = xftface_info->xft_fg, bg_done = 1;
	}

      if (! (fg_done & bg_done))
	{
	  XColor colors[2];

	  colors[0].pixel = fg->pixel = xgcv.foreground;
	  if (bg)
	    colors[1].pixel = bg->pixel = xgcv.background;
	  XQueryColors (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), colors,
			bg ? 2 : 1);
	  fg->color.alpha = 0xFFFF;
	  fg->color.red = colors[0].red;
	  fg->color.green = colors[0].green;
	  fg->color.blue = colors[0].blue;
	  if (bg)
	    {
	      bg->color.alpha = 0xFFFF;
	      bg->color.red = colors[1].red;
	      bg->color.green = colors[1].green;
	      bg->color.blue = colors[1].blue;
	    }
	}
      unblock_input ();
    }
}
Exemplo n.º 11
0
void load_font(){
	char *font_name=conf_get_string("font",FONT);

	Font font=XLoadFont(dpy,font_name);
	XSetFont(dpy,gc,font);

	XGCValues v;
	XGetGCValues(dpy,gc,GCFont,&v);
	sfont=XQueryFont(dpy,v.font);
}
Exemplo n.º 12
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);
}
Exemplo n.º 13
0
void Wind::stbknd(GC gc)
  {
  bknd=gc;
  if(on_flag)
    {
    XGCValues v;
    XGetGCValues(dsp,gc,GCForeground,&v);
    XSetWindowBackground(dsp,gtwin(),v.foreground);
    }
  }
Exemplo n.º 14
0
void GraphicWindow::clear()
{
   XClearWindow(display, win);

   XGCValues vals;
   XGetGCValues(display, xgc, GCForeground, &vals);
   unsigned long color = WhitePixel(display, screen_num);
   unsigned long fg = vals.foreground;
   XSetForeground(display, xgc, color);
   XFillRectangle(display, _ppm, xgc, 0, 0, DEF_WIDTH + 1, DEF_HEIGHT + 1);
   XSetForeground(display, xgc, fg);
}
Exemplo n.º 15
0
Arquivo: List.c Projeto: aosm/X11
static void
XawListDestroy(Widget w)
{
    ListWidget lw = (ListWidget)w;
    XGCValues values;
    
    XGetGCValues(XtDisplay(w), lw->list.graygc, GCTile, &values);
    XmuReleaseStippledPixmap(XtScreen(w), values.tile);
    XtReleaseGC(w, lw->list.graygc);
    XtReleaseGC(w, lw->list.revgc);
    XtReleaseGC(w, lw->list.normgc);
}
Exemplo n.º 16
0
// Return XFontStruct for given font name NAME
XFontStruct *FontTable::operator[](const string& name)
{
    int i = hash(name.chars());
    while (table[i].font != 0 && name != table[i].name)
    {
	assert (i < MAX_FONTS);   // Too many fonts
	i = (i >= MAX_FONTS) ? 0 : i + 1;
    }

    if (table[i].font == 0 && name != table[i].name)
    {
	// Insert new font
	table[i].name = name;
	table[i].font = XLoadQueryFont(_display, name.chars());

	if (table[i].font == 0)
	{
	    std::cerr << "Warning: Could not load font \"" << name << "\"";

	    // Try default font
	    GC default_gc = 
		DefaultGCOfScreen(DefaultScreenOfDisplay(_display));
	    XGCValues gc_values;
	    if (XGetGCValues(_display, default_gc, GCFont, &gc_values))
	    {
		const Font& font_id = gc_values.font;
		XFontStruct *font = XQueryFont(_display, font_id);
		if (font != 0)
		{
		    std::cerr << ", using default font instead\n";
		    table[i].font = font;
		}
	    }
	}

	if (table[i].font == 0)
	{
	    // Try "fixed" font
	    XFontStruct *font = XLoadQueryFont(_display, "fixed");
	    if (font != 0)
	    {
		std::cerr << ", using font \"fixed\" instead\n";
		table[i].font = font;
	    }
	}

	if (table[i].font == 0)
	    std::cerr << "\n";
    }

    return table[i].font;
}
Exemplo n.º 17
0
int
DPSCAPFlushGCProc(
    Display *dpy,
    GC gc,
    XExtCodes *codes)
{
    XGCValues values;
    DPSCAPData my;
    XExtData *extData;
    unsigned long int dirty;

    /* When GC is created, it is flushed with no dirty bits set,
       so we have to notice that situation. */

    if (gc->dirty)
        {
	if (XDPSLGetGCFlushMode(dpy) == XDPSNX_GC_UPDATES_FAST
	   || !(gc->dirty & DPSGCBITS))
	    return(0);
	}
    extData = XFindOnExtensionList(CSDPSHeadOfDpyExt(dpy), codes->extension);
    if (extData)
        my = (DPSCAPData) extData->private_data;
    else
        return(0);
    /* HERE IF (gc->dirty & DPSGCBITS || !gc->dirty) */
    dirty = gc->dirty;
    DPSAssertWarn(XGetGCValues(dpy, gc, DPSGCBITS & ~(GCClipMask), &values),
	NULL, "NX: XGetGCValues returned False\n");
    values.clip_mask = gc->values.clip_mask;
    /* Must guarantee that gc change is registered by X server
       before notification is sent to agent. */
    XSync(dpy, False);
    DPSCAPChangeGC(my->agent, gc, DPSGCBITS, &values);
    /* We have to make sure that the agent completely processes
       the change to the GC.  If we allow the agent to update the
       GC in its own sweet time, the stupid client may delete the
       GC after the agent has already queued a request to, e.g.,
       copy the GC, but before the request is flushed. */
    if (gNXSyncGCMode == DPSNXSYNCGCMODE_SYNC)
        XDPSLSync(dpy);
    else
        XDPSLFlush(dpy);
#ifdef CSDPSDEBUG
    if (dirty)
        ++gcCountFlushedDirty;
    else
        ++gcCountFlushedClean;
#endif /* CSDPSDEBUG */
    return(1);
}
Exemplo n.º 18
0
static void drawSwatch (Pixel pix) {
    XGCValues savedValues;
    XWindowAttributes winAttr;
    Window w = XtWindow (rgbSwatch);

    XGetGCValues (theDisplay, theGC, GCForeground, &savedValues);
    XGetWindowAttributes (theDisplay, w, &winAttr);

    XSetForeground(theDisplay, theGC, pix);
    XFillRectangle (theDisplay, XtWindow(rgbSwatch), 
			theGC, 0, 0, winAttr.width, winAttr.height);

    XSetForeground (theDisplay, theGC, savedValues.foreground);
}
Exemplo n.º 19
0
void
XUtf8DrawImageString(
        Display         *display,
        Drawable        d,
        XUtf8FontStruct         *font_set,
        GC              gc,
        int             x,
        int             y,
        const char      *string,
        int             num_bytes)
{
	/* FIXME: must be improved ! */
	int w;
	int fill_style;
	unsigned long foreground;
	unsigned long background;
	int function;
	XGCValues xgcv;

	w = XUtf8TextWidth(font_set, string, num_bytes);
	
	XGetGCValues(display, gc, 
		GCFunction|GCForeground|GCBackground|GCFillStyle, &xgcv);
	
	function = xgcv.function;
	fill_style = xgcv.fill_style;
	foreground = xgcv.foreground;
	background = xgcv.background;

	xgcv.function = GXcopy;
	xgcv.foreground = background;
	xgcv.background = foreground;
	xgcv.fill_style = FillSolid;

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

	XFillRectangle(display, d, gc, x, y - font_set->ascent, 
		(unsigned)w, (unsigned)(font_set->ascent + font_set->descent));

	xgcv.function = function;
	xgcv.foreground = foreground;
	xgcv.background = background;
	xgcv.fill_style = fill_style;

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

	XUtf8DrawString(display, d, font_set, gc, x, y, string, num_bytes);
}
Exemplo n.º 20
0
void
XPSFillPolygon(Display *display, Drawable drawable, GC context,
               Coord *coord, int ncoords, int shape, int mode)
{
    int i;
    int pcount;

    if (output_flag == XOUT)
    {
        XFillPolygon(display, drawable, context,
                     (XPoint *)coord, ncoords, shape, mode);
    }
    else
    {
        XGCValues values;

        XGetGCValues(display, context, GCForeground | GCLineWidth, &values);

        if (ncoords <= 0)
        {
            return;
        }

        PSNewpath();
        PSSetPixel(display, values.foreground);
        PSMoveto(coord[0].x, coord[0].y);
        pcount = 0;

        for (i = 1; i < ncoords; i++)
        {
            PSLineto(coord[i].x, coord[i].y);

            /*
             * break it up into managable cuhnks
             */

            if (pcount > MAXSTROKES)
            {
                PSClosefill();
                PSMoveto(coord[i].x, coord[i].y);
                pcount = 0;
            }

            pcount++;
        }

        PSClosefill();
    }
}
Exemplo n.º 21
0
void
setPointerColor(GC color)
{
	XGCValues gcv;
	XColor fcolor, bcolor;

	XGetGCValues(DADisplay, color, GCForeground, &gcv);

	fcolor.pixel = gcv.foreground;
	fcolor.flags = DoRed | DoGreen | DoBlue;

	bcolor.red = 0;
	bcolor.green = 0;
	bcolor.blue = 0;

	XRecolorCursor(DADisplay, pointer, &fcolor, &bcolor);
}
Exemplo n.º 22
0
void
XPSDrawDot(Display *display, Drawable drawable, GC context, int x1, int y1)
{
    if (output_flag == XOUT)
    {
        XDrawLine(display, drawable, context, x1, y1, x1, y1 + 1);
    }
    else
    {
        /* Hack: this isn't a good way to draw PS dots */
        XGCValues values;

        XGetGCValues(display, context, GCForeground | GCLineWidth, &values);
        PSSetPixel(display, values.foreground);
        PSSetLineWidth(values.line_width);
        PSNewpath();
        PSMoveto(x1, y1);
        PSLineto(x1, y1 + 1);
        PSStroke();
    }
}
Exemplo n.º 23
0
void
XPSDrawArc(Display *display, Drawable drawable, GC context,
           int x, int y, int w, int h, int angle1, int angle2)
{
    if (output_flag == XOUT)
    {
        XDrawArc(display, drawable, context, x, y, w, h, angle1, angle2);
    }
    else
    {
        XGCValues values;

        XGetGCValues(display, context, GCForeground | GCLineWidth, &values);
        PSNewpath();
        PSSetPixel(display, values.foreground);
        PSSetLineWidth(values.line_width);
        PSArc(x + w / 2.0, y + h / 2.0, w / 2.0, angle1 / 64.0,
              angle2 / 64.0);
        PSStroke();
    }
}
Exemplo n.º 24
0
void
XPSFillRectangle(Display *display, Drawable drawable, GC context,
                 int x, int y, int w, int h)
{
    if (output_flag == XOUT)
    {
        XFillRectangle(display, drawable, context, x, y, w, h);
    }
    else
    {
        XGCValues values;

        XGetGCValues(display, context, GCForeground | GCLineWidth, &values);
        PSSetPixel(display, values.foreground);
        PSNewpath();
        PSMoveto(x, y);
        PSLineto(x + w, y);
        PSLineto(x + w, y + h);
        PSLineto(x, y + h);
        PSClosefill();
    }
}
Exemplo n.º 25
0
/* show a short message on the window */
void ShowTM ()
{
  /* should clear the window */

  XGCValues gcvalues,tmp_val;
  int mask;
  char s1[]="Bacci Cantalupo Ravazzolo";
  char s2[]="Riaudo Pesciullesi";
  char s3[]="Aldinucci Coppola Torquati";
  
  mask=GCForeground|GCFunction;
  XGetGCValues(display,gc,mask,&tmp_val);
  gcvalues.foreground=1;
  gcvalues.function=GXcopy;
  XChangeGC(display,gc,mask,&gcvalues);
  XDrawString(display,window,gc,5,10,"QSW PISA are:",12);
  XDrawString(display,window,gc,10,25,s1,strlen(s1));
  XDrawString(display,window,gc,10,40,s2,strlen(s2));
  XDrawString(display,window,gc,10,55,s3,strlen(s3));
  /* Restore Graphic Context */
  XChangeGC(display,gc,mask,&tmp_val);

}
Exemplo n.º 26
0
void DrawDragDropRect(Draw& draw, const Rect& rc_old, const Rect& rc_new, int width, Color c1, Color c2)
{
#ifdef PLATFORM_WIN32
#ifdef SYSTEMDRAW
	SystemDraw *w = dynamic_cast<SystemDraw *>(&draw);
	if(w) { SystemDraw& draw = *w;
#endif
	static const word halftone[] = { 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa };
	HBITMAP bitmap = CreateBitmap(8, 8, 1, 1, halftone);
	HBRUSH brush = CreatePatternBrush(bitmap);
	DeleteObject(bitmap);
	draw.BeginGdi();
	SetTextColor(draw, c1);
	SetBkColor(draw, c2);
	if(!IsNull(rc_old))
		DrawDragDropRectRaw(draw, rc_old, brush, width);
	if(!IsNull(rc_new))
		DrawDragDropRectRaw(draw, rc_new, brush, width);
	DeleteObject(brush);
	draw.EndGdi();
#ifdef SYSTEMDRAW
	}
#endif
#endif
#ifdef PLATFORM_X11
	XGCValues gcv_old, gcv_new;
	XGetGCValues(Xdisplay, draw.GetGC(), GCForeground | GCFunction, &gcv_old);
	gcv_new.function = X11_ROP2_XOR;
	gcv_new.foreground = GetXPixel(c1);
	XChangeGC(Xdisplay, draw.GetGC(), GCForeground | GCFunction, &gcv_new);
	if(!IsNull(rc_old))
		DrawDragDropRectRaw(draw, rc_old, width);
	if(!IsNull(rc_new))
		DrawDragDropRectRaw(draw, rc_new, width);
	XChangeGC(Xdisplay, draw.GetGC(), GCForeground | GCFunction, &gcv_old);
#endif
}
Exemplo n.º 27
0
void clearviewport(void)
{
        GC temp_gc;
        XGCValues current_values;
        XGCValues temp_values;

        XGetGCValues(dpy, gc, GCBackground, &current_values);

        temp_values.fill_style = FillSolid;
        temp_values.foreground = current_values.background;
        temp_gc = XCreateGC(dpy, drawable, GCForeground, &temp_values);
        XFillRectangle(dpy, drawable, temp_gc, xrectangle.x, xrectangle.y,
                       xrectangle.width, xrectangle.height);
	if (visual_page == active_page)
		XFillRectangle(dpy, window, temp_gc, xrectangle.x, xrectangle.y,
			       xrectangle.width, xrectangle.height);

        XFreeGC(dpy, temp_gc);

        CP.x = 0;
        CP.y = 0;
	
	XFlush(dpy);
}
Exemplo n.º 28
0
void
XmuFillRoundedRectangle(Display *dpy, Drawable draw, GC gc,
			int x, int y, int w, int h, int ew, int eh)
{
	XArc	arcs[4];
	XRectangle rects[3];
	XGCValues vals;
  int ew2, eh2;

	XGetGCValues(dpy, gc, GCArcMode, &vals);
	if (vals.arc_mode != ArcPieSlice)
	    XSetArcMode(dpy, gc, ArcPieSlice);

  if ((ew2 = (ew << 1)) > w)
    ew2 = ew = 0;
  if ((eh2 = (eh << 1)) > h)
    eh2 = eh = 0;

	arcs[0].x = x;
	arcs[0].y = y;
  arcs[0].width = ew2;
  arcs[0].height = eh2;
  arcs[0].angle1 = 180 * 64;
  arcs[0].angle2 = -90 * 64;

  arcs[1].x = x + w - ew2 - 1;
	arcs[1].y = y;
  arcs[1].width = ew2;
  arcs[1].height = eh2;
  arcs[1].angle1 = 90 * 64;
  arcs[1].angle2 = -90 * 64;

  arcs[2].x = x + w - ew2 - 1;
  arcs[2].y = y + h - eh2 - 1;
  arcs[2].width = ew2;
  arcs[2].height = eh2;
	arcs[2].angle1 = 0;
  arcs[2].angle2 = -90 * 64;

	arcs[3].x = x;
  arcs[3].y = y + h - eh2 - 1;
  arcs[3].width = ew2;
  arcs[3].height = eh2;
  arcs[3].angle1 = 270 * 64;
  arcs[3].angle2 = -90 * 64;

  XFillArcs(dpy, draw, gc, arcs, 4);

	rects[0].x = x + ew;
	rects[0].y = y;
  rects[0].width = w - ew2;
	rects[0].height = h;

	rects[1].x = x;
	rects[1].y = y + eh;
	rects[1].width = ew;
  rects[1].height = h - eh2;

	rects[2].x = x + w - ew;
	rects[2].y = y + eh;
	rects[2].width = ew;
  rects[2].height = h - eh2;

  XFillRectangles(dpy, draw, gc, rects, 3);

	if (vals.arc_mode != ArcPieSlice)
	    XSetArcMode(dpy, gc, vals.arc_mode);
}
Exemplo n.º 29
0
gint
nsFreeTypeXImage::DrawString(nsRenderingContextGTK* aContext,
                            nsDrawingSurfaceGTK* aSurface, nscoord aX,
                            nscoord aY, const PRUnichar* aString,
                            PRUint32 aLength)
{

#if DEBUG_SHOW_GLYPH_BOX
  PRUint32 x, y;
  // grey shows image size
  // red shows character cells
  // green box shows text ink
#endif

  if (aLength < 1) {
    return 0;
  }

  // get the face/size from the FreeType cache
  FT_Face face = getFTFace();
  NS_ASSERTION(face, "failed to get face/size");
  if (!face)
    return 0;

  nsresult rslt;
  PRInt32 leftBearing, rightBearing, ascent, descent, width;
  rslt = doGetBoundingMetrics(aString, aLength, &leftBearing, &rightBearing,
                              &ascent, &descent, &width);
  if (NS_FAILED(rslt))
    return 0;

  // make sure we bring down enough background for blending
  rightBearing = PR_MAX(rightBearing, width+1);

  // offset in the ximage to the x origin
  PRInt32 x_origin = PR_MAX(0, -leftBearing);
  // offset in the ximage to the x origin
  PRInt32 y_origin = ascent;
  PRInt32 x_pos = x_origin;

  int image_width  = x_origin + rightBearing;
  int image_height = y_origin + PR_MAX(descent, 0);
  if ((image_width<=0) || (image_height<=0)) {
    // if we do not have any pixels then no point in trying to draw
    // eg: the space char has 0 height
    NS_ASSERTION(width>=0, "Negative width");
    return width;
  }
  Display *dpy = GDK_DISPLAY();
  Drawable win = GDK_WINDOW_XWINDOW(aSurface->GetDrawable());
  GC gc = GDK_GC_XGC(aContext->GetGC());
  XGCValues values;
  if (!XGetGCValues(dpy, gc, GCForeground, &values)) {
    NS_ERROR("failed to get foreground pixel");
    return 0;
  }
  nscolor color = nsX11AlphaBlend::PixelToNSColor(values.foreground);

#if DEBUG_SHOW_GLYPH_BOX
  // show X/Y origin
  XDrawLine(dpy, win, DefaultGC(dpy, 0), aX-2, aY, aX+2, aY);
  XDrawLine(dpy, win, DefaultGC(dpy, 0), aX, aY-2, aX, aY+2);
  // show width
  XDrawLine(dpy, win, DefaultGC(dpy, 0), aX-x_origin,  aY-y_origin-2,
                                         aX+rightBearing, aY-y_origin-2);
#endif

  //
  // Get the background
  //
  XImage *sub_image = nsX11AlphaBlend::GetBackground(dpy, DefaultScreen(dpy),
                                 win, aX-x_origin, aY-y_origin,
                                 image_width, image_height);
  if (sub_image==nsnull) {
#ifdef DEBUG
    int screen = DefaultScreen(dpy);
    // complain if the requested area is not completely off screen
    int win_width = DisplayWidth(dpy, screen);
    int win_height = DisplayHeight(dpy, screen);
    if (((int)(aX-leftBearing+image_width) > 0)  // not hidden to left
        && ((int)(aX-leftBearing) < win_width)   // not hidden to right
        && ((int)(aY-ascent+image_height) > 0)// not hidden to top
        && ((int)(aY-ascent) < win_height))   // not hidden to bottom
    {
      NS_ASSERTION(sub_image, "failed to get the image");
    }
#endif
    return 0;
  }

#if DEBUG_SHOW_GLYPH_BOX
  DEBUG_AADRAWBOX(sub_image,0,0,image_width,image_height,0,0,0,255/4);
  nscolor black NS_RGB(0,255,0);
  blendPixel blendPixelFunc = nsX11AlphaBlend::GetBlendPixel();
  // x origin
  for (x=0; x<(unsigned int)image_height; x++)
    if (x%4==0) (*blendPixelFunc)(sub_image, x_origin, x, black, 255/2);
  // y origin
  for (y=0; y<(unsigned int)image_width; y++)
    if (y%4==0) (*blendPixelFunc)(sub_image, y, ascent-1, black, 255/2);
#endif

  FTC_Image_Cache icache;
  mFt2->GetImageCache(&icache);
  if (!icache)
    return 0;

  //
  // Get aa glyphs and blend with background
  //
  blendGlyph blendGlyph = nsX11AlphaBlend::GetBlendGlyph();
  PRUint32 i, extraSurrogateLength;
  for (i=0; i<aLength; i+=1+extraSurrogateLength) {
    FT_UInt glyph_index;
    FT_Glyph glyph;
    nsresult rv;
    FT_BBox glyph_bbox;
    FT_ULong code_point = aString[i];
    extraSurrogateLength = 0;

    if(i<aLength-1 && IS_HIGH_SURROGATE(code_point) && IS_LOW_SURROGATE(aString[i+1])) {
      // if surrogate, make UCS4 code point from high aString[i] surrogate and
      // low surrogate aString[i+1]
      code_point = SURROGATE_TO_UCS4(code_point, aString[i+1]);

      // skip aString[i+1], it is already used as low surrogate
      extraSurrogateLength = 1;
    }

    mFt2->GetCharIndex(face, code_point, &glyph_index);
    if (glyph_index) {
      rv = mFt2->ImageCacheLookup(icache, &mImageDesc, glyph_index, &glyph);
    }
    if ((glyph_index) && (NS_SUCCEEDED(rv))) {
      mFt2->GlyphGetCBox(glyph, ft_glyph_bbox_pixels, &glyph_bbox);
    }
    else {
      // draw an empty box for the missing glyphs
      GetFallbackGlyphMetrics(&glyph_bbox, face);
      int x, y, w = glyph_bbox.xMax, h = glyph_bbox.yMax;
      for (x=1; x<w; x++) {
        XPutPixel(sub_image, x_pos+x, ascent-1,   values.foreground);
        XPutPixel(sub_image, x_pos+x, ascent-h, values.foreground);
      }
      for (y=1; y<h; y++) {
        XPutPixel(sub_image, x_pos+1, ascent-y, values.foreground);
        XPutPixel(sub_image, x_pos+w-1, ascent-y, values.foreground);
        x = (y*(w-2))/h;
        XPutPixel(sub_image, x_pos+x+1, ascent-y,   values.foreground);
      }
      x_pos += w + 1;
      continue;
    }

    FT_BitmapGlyph slot = (FT_BitmapGlyph)glyph;
    nsAntiAliasedGlyph aaglyph(glyph_bbox.xMax-glyph_bbox.xMin,
                               glyph_bbox.yMax-glyph_bbox.yMin, 0);
    PRUint8 buf[IMAGE_BUFFER_SIZE]; // try to use the stack for data
    if (!aaglyph.WrapFreeType(&glyph_bbox, slot, buf, IMAGE_BUFFER_SIZE)) {
      NS_ERROR("failed to wrap freetype image");
      XDestroyImage(sub_image);
      return 0;
    }

    //
    // blend the aa-glyph onto the background
    //
    NS_ASSERTION(ascent>=glyph_bbox.yMax,"glyph too tall");
    NS_ASSERTION(x_pos>=-aaglyph.GetLBearing(),"glyph extends too far to left");

#if DEBUG_SHOW_GLYPH_BOX
  // draw box around part of glyph that extends to the left
  // of the main area (negative LBearing)
  if (aaglyph.GetLBearing() < 0) {
    DEBUG_AADRAWBOX(sub_image, x_pos + aaglyph.GetLBearing(),
                    ascent-glyph_bbox.yMax,
                    -aaglyph.GetLBearing(), glyph_bbox.yMax, 255,0,0, 255/4);
  }
  // draw box around main glyph area
  DEBUG_AADRAWBOX(sub_image, x_pos, ascent-glyph_bbox.yMax,
                  aaglyph.GetAdvance(), glyph_bbox.yMax, 0,255,0, 255/4);
  // draw box around part of glyph that extends to the right
  // of the main area (negative LBearing)
  if (aaglyph.GetRBearing() > (int)aaglyph.GetAdvance()) {
    DEBUG_AADRAWBOX(sub_image, x_pos + aaglyph.GetAdvance(),
                    ascent-glyph_bbox.yMax,
                    aaglyph.GetRBearing()-aaglyph.GetAdvance(),
                    glyph_bbox.yMax, 0,0,255, 255/4);
  }
#endif
    (*blendGlyph)(sub_image, &aaglyph, sLinearWeightTable, color,
                  x_pos + aaglyph.GetLBearing(), ascent-glyph_bbox.yMax);

    x_pos += aaglyph.GetAdvance();
  }

  //
  // Send it to the display
  //
  XPutImage(dpy, win, gc, sub_image, 0, 0, aX-x_origin , aY-ascent,
            image_width, image_height);
  XDestroyImage(sub_image);

  return width;
}
Exemplo n.º 30
0
Arquivo: List.c Projeto: aosm/X11
/*ARGSUSED*/
static Boolean 
XawListSetValues(Widget current, Widget request, Widget cnew,
		 ArgList args, Cardinal *num_args)
{
    ListWidget cl = (ListWidget)current;
    ListWidget rl = (ListWidget)request;
    ListWidget nl = (ListWidget)cnew;
    Bool redraw = False;
    XFontSetExtents *ext = XExtentsOfFontSet(nl->list.fontset);

    /* If the request height/width is different, lock it.  Unless its 0. If
       neither new nor 0, leave it as it was.  Not in R5 */
    if (XtWidth(nl) != XtWidth(cl))
	nl->list.freedoms |= WidthLock;
    if (XtWidth(nl) == 0)
	nl->list.freedoms &= ~WidthLock;

    if (XtHeight(nl) != XtHeight(cl))
	nl->list.freedoms |= HeightLock;
    if (XtHeight(nl) == 0)
	nl->list.freedoms &= ~HeightLock;

    if (nl->list.longest != cl->list.longest)
	nl->list.freedoms |= LongestLock;
    if (nl->list.longest == 0)
	nl->list.freedoms &= ~LongestLock;

    if (cl->list.foreground != nl->list.foreground ||
	cl->core.background_pixel != nl->core.background_pixel ||
	cl->list.font != nl->list.font) {
	XGCValues values;

	XGetGCValues(XtDisplay(current), cl->list.graygc, GCTile, &values);
	XmuReleaseStippledPixmap(XtScreen(current), values.tile);
	XtReleaseGC(current, cl->list.graygc);
	XtReleaseGC(current, cl->list.revgc);
	XtReleaseGC(current, cl->list.normgc);
	GetGCs(cnew);
	redraw = True;
    }

    if (cl->list.font != nl->list.font && cl->simple.international == False)
	nl->list.row_height = nl->list.font->max_bounds.ascent
			    + nl->list.font->max_bounds.descent
			    + nl->list.row_space;
    else if (cl->list.fontset != nl->list.fontset
	&& cl->simple.international == True)
	nl->list.row_height = ext->max_ink_extent.height + nl->list.row_space;

    /* ...If the above two font(set) change checkers above both failed, check
       if row_space was altered.  If one of the above passed, row_height will
       already have been re-calculated */
    else if (cl->list.row_space != nl->list.row_space) {
	if (cl->simple.international == True)
	    nl->list.row_height = ext->max_ink_extent.height + nl->list.row_space;
	else
	    nl->list.row_height = nl->list.font->max_bounds.ascent
				+ nl->list.font->max_bounds.descent
				+ nl->list.row_space;
    }

    if (XtWidth(cl) != XtWidth(nl) || XtHeight(cl) != XtHeight(nl)
	|| cl->list.internal_width != nl->list.internal_width
	|| cl->list.internal_height != nl->list.internal_height
	|| cl->list.column_space != nl->list.column_space
	|| cl->list.row_space != nl->list.row_space
	|| cl->list.default_cols != nl->list.default_cols
	|| (cl->list.force_cols != nl->list.force_cols
	    && rl->list.force_cols != nl->list.ncols)
	|| cl->list.vertical_cols != nl->list.vertical_cols
	|| cl->list.longest != nl->list.longest
	|| cl->list.nitems != nl->list.nitems
	|| cl->list.font != nl->list.font
	/* Equiv. fontsets might have different values, but the same fonts,
	   so the next comparison is sloppy but not dangerous  */
	|| cl->list.fontset != nl->list.fontset
	|| cl->list.list != nl->list.list) {
	CalculatedValues(cnew);
	Layout(cnew, WidthFree(nl), HeightFree(nl),
	       &nl->core.width, &nl->core.height);
	redraw = True;
    }

    if (cl->list.list != nl->list.list || cl->list.nitems != nl->list.nitems)
	nl->list.is_highlighted = nl->list.highlight = NO_HIGHLIGHT;

    if (cl->core.sensitive != nl->core.sensitive
	|| cl->core.ancestor_sensitive != nl->core.ancestor_sensitive) {
	nl->list.highlight = NO_HIGHLIGHT;
	redraw = True;
    }
    
    return (redraw);
}