⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xlib.c

📁 rxvt经典的linux下的终端.小巧实用
💻 C
📖 第 1 页 / 共 5 页
字号:
				ntw->y = CW_USEDEFAULT;			}		}		else if (ntw->x == -1 && ntw->y == -1)		{			GetClientRect(ntw->parent->w,&rect);			ntw->x = rect.left;			ntw->y = rect.top;			ntw->wdth = rect.right-rect.left;			ntw->hght = rect.bottom - rect.top;		}		ntw->hDC = INVALID_HANDLE;				if (ntw->parent->w == INVALID_HANDLE)		{			XMapWindow(display, (Window)ntw->parent);		}		ntw->w = NT_create_window(title,frame_style,								 ntw->x,ntw->y,ntw->wdth,ntw->hght,								 ntw->parent->w);		if (ntw->w==NULL) NT_dispError("create window1");		hDC = cjh_get_dc(ntw);		PostMessage(ntw->w,USR_MapNotify,0,0);	}	if (IsWindowVisible(ntw->w)==0)	{		ShowWindow(ntw->w, SW_SHOW);		PostMessage(ntw->w,USR_MapNotify,0,0);	}	UpdateWindow(ntw->w);	return 0;}intXIconifyWindow(Display *display,    Window w,    int screen_number){	xtrace("XIconifyWindow\n");	return 0;}/*****************************************************************\	Function: XCreateGC	Inputs:   display, window, mask of setup values, setup values.	Returned: GC pointer.	Comments: Fills out a GC structure with the X defaults unless		  the caller specifies otherwise.\*****************************************************************/GCXCreateGC(display, window, mask, gc_values)Display *display;Drawable window;unsigned long mask;XGCValues *gc_values;{	GC	local_gc;	int	size;	char	*ptr;	xtrace("XCreateGC\n");	size = sizeof(GC);	ptr = (char *)allocateMemory((size_t)1000);	local_gc = (GC)ptr;	local_gc->ext_data = NULL;	local_gc->gid=(GContext) window;	local_gc->rects=FALSE;	local_gc->dashes=FALSE;	if (mask&GCArcMode)		local_gc->values.arc_mode=gc_values->arc_mode;	else		local_gc->values.arc_mode=ArcPieSlice;	if (mask&GCBackground)		local_gc->values.background=gc_values->background;	else		local_gc->values.background=display->screens->white_pixel;	if (mask&GCCapStyle)		local_gc->values.cap_style=gc_values->cap_style;	else		local_gc->values.cap_style=CapButt;	if (mask&GCClipMask)		local_gc->values.clip_mask=gc_values->clip_mask;	else		local_gc->values.clip_mask=None;	if (mask&GCClipXOrigin)		local_gc->values.clip_x_origin=gc_values->clip_x_origin;	else		local_gc->values.clip_x_origin=0;	if (mask&GCClipYOrigin)		local_gc->values.clip_y_origin=gc_values->clip_y_origin;	else		local_gc->values.clip_y_origin=0;	if (mask&GCDashList)		local_gc->values.dashes=gc_values->dashes;	else		local_gc->values.dashes=4;	if (mask&GCDashOffset)		local_gc->values.dash_offset=gc_values->dash_offset;	else		local_gc->values.dash_offset=0;	if (mask&GCFillRule)		local_gc->values.fill_rule=gc_values->fill_rule;	else		local_gc->values.fill_rule=EvenOddRule;	if (mask&GCFillStyle)		local_gc->values.fill_style=gc_values->fill_style;	else		local_gc->values.fill_style=FillSolid;	if (mask&GCFont)		local_gc->values.font=gc_values->font;	else		local_gc->values.font= 999;/*"fixed";*/	if (mask&GCForeground)		local_gc->values.foreground=gc_values->foreground;	else		local_gc->values.foreground=display->screens->black_pixel;	if (mask&GCFunction)		local_gc->values.function=gc_values->function;	else		local_gc->values.function=GXcopy;	if (mask&GCGraphicsExposures)		local_gc->values.graphics_exposures=gc_values->graphics_exposures;	else		local_gc->values.graphics_exposures=True;	if (mask&GCJoinStyle)		local_gc->values.join_style=gc_values->join_style;	else		local_gc->values.join_style=JoinMiter;	if (mask&GCLineStyle)		local_gc->values.line_style=gc_values->line_style;	else		local_gc->values.line_style=LineSolid;	if (mask&GCLineWidth)		local_gc->values.line_width=gc_values->line_width;	else		local_gc->values.line_width=0;	if (mask&GCPlaneMask)		local_gc->values.plane_mask=gc_values->plane_mask;	else		local_gc->values.plane_mask=255;	if (mask&GCStipple)		local_gc->values.stipple=gc_values->stipple;	else		local_gc->values.stipple=0;	if (mask&GCSubwindowMode)		local_gc->values.subwindow_mode=gc_values->subwindow_mode;	else		local_gc->values.subwindow_mode=ClipByChildren;	if (mask&GCTile)		local_gc->values.tile=gc_values->tile;	else		local_gc->values.tile=0;	if (mask&GCTileStipXOrigin)		local_gc->values.ts_x_origin=gc_values->ts_x_origin;	else		local_gc->values.ts_x_origin=0;	if (mask&GCTileStipYOrigin)		local_gc->values.ts_y_origin=gc_values->ts_y_origin;	else		local_gc->values.ts_y_origin=0;	local_gc->dirty = ~0;	return (local_gc);}intXFreeGC(display, gc)Display *display;GC gc;{	freeMemory(gc);}/*****************************************************************\	Function: XSetForeground	Inputs:   display, gc, colour.	Comments: Colour is an RGB triple (24bits).\*****************************************************************/intXSetForeground(display, gc, color)Display *display;GC gc;unsigned long    color;{	xtrace("XSetForegrond\n");	gc->values.foreground=color;	gc->dirty |= GCForeground;	return 0;}/*****************************************************************\	Function: XDrawString	Inputs:   display, window, gc, position, string, length of string.	Comments: Writes text to the screen in the manner of X windows.		  Note that the y origin is on the text baseline, ie.		  the lowest part of a letter o rests on the baseline and		  descenders fall below it.		  The text is transparent.\*****************************************************************/intXDrawString(Display *display, Drawable window,    GC gc, int x, int y, const char* str, int len){	HDC          hDC;	TEXTMETRIC   tmet;	HFONT old;	xtrace("XDrawString\n");	if (VALID_WINDOW(window))	{		hDC = drawableGetDC(window);		SetBkMode(hDC,TRANSPARENT);		SetTextColor(hDC,CNUMTORGB(gc->values.foreground));		old=SelectObject(hDC,(HFONT)gc->values.font);		GetTextMetrics(hDC,&tmet);		TextOut(hDC,x,y-tmet.tmAscent,str,len);		SelectObject(hDC,old);		drawableRelDC(window,hDC);	}	return 0;}intXDrawString16(Display *display, Drawable window,    GC gc, int x, int y,    const XChar2b* str,    int len){	xtrace("XDrawString16\n");	XDrawString(display, window, gc, x, y, (const char*)str, len*2);	return 0;}XDrawImageString(	Display* display,	Drawable d,	GC gc,	int x,	int y,	const char* string,	int length){	HDC hDC = NULL;	TEXTMETRIC   tmet;	HFONT old;	xtrace("XDrawImageString\n");	if (VALID_WINDOW(d))	{	    hDC = drawableGetDC(d);	    SetBkMode(hDC,TRANSPARENT);	    SetBkColor(hDC, CNUMTORGB(gc->values.background));		    SetTextColor(hDC,CNUMTORGB(gc->values.foreground));	    old=SelectObject(hDC,(HFONT)gc->values.font);	    if (GetTextMetrics(hDC,&tmet) && length>0) {		RECT fill;		fill.top = y-tmet.tmAscent;		fill.bottom = y+tmet.tmDescent;		fill.left = x;		fill.right = x + (tmet.tmAveCharWidth * length);		FillRect( hDC, &fill, NT_get_GC_bgbrush(hDC,gc));	    }	    TextOut( hDC, x, y-tmet.tmAscent, string, length ); 	    SelectObject(hDC,old);	    drawableRelDC(d,hDC);	}		return 0;}intXDrawImageString16(Display *display, Drawable window,    GC gc, int x, int y,    const XChar2b* str,    int len){	xtrace("XDrawImageString16\n");	XDrawImageString(display, window, gc, x, y, (const char*)str, len*2);	return 0;}/*****************************************************************\	Function: XFillRectangle	Inputs:   display, window, gc, geometry.	Comments: fills rectangles in uniform colours.  No tiles/Pixmaps		  are implemented yet.\*****************************************************************/intXFillRectangle (display,window,gc,x,y,w,h)Display *display;Drawable window;GC gc;int x,y;unsigned int w,h;{	RECT rct;	HBRUSH hbrush;	HDC hDC;	HANDLE oldObj;	int ret;	xtrace("XFillRectangle\n");	if (VALID_WINDOW(window))	{		hDC = drawableGetDC(window);		NT_set_rop(hDC,gc);		hbrush = NT_get_GC_brush(hDC,gc);		oldObj = SelectObject(hDC, hbrush);		rct.left=(LONG) x;		rct.right=(LONG) (x+w);		rct.top=(LONG) y;		rct.bottom=(LONG) (y+h);		ret=FillRect(hDC, &rct, hbrush);		SelectObject(hDC, oldObj);		drawableRelDC(window,hDC);	}	return (ret);}/*****************************************************************\	Function: XClearArea	Inputs:   display, geometry, exposure events allowed.	Comments: Straightforward.\*****************************************************************/intXClearArea(display,w,x,y,width,height,exposures)Display *display;Window w;int x,y;unsigned int width,height;BoolDef exposures;{	NT_window *ntw = (NT_window *)w;	RECT rct;	HBRUSH hbrush;	HDC hDC;	HANDLE oldObj;	int oldROP;	xtrace("XClearArea\n");	if (VALID_WINDOW(ntw))	{		hDC = cjh_get_dc(ntw);		oldROP = SetROP2(hDC,R2_COPYPEN);		hbrush=ntw->bg;		oldObj = SelectObject(hDC,hbrush);		GetClientRect(ntw->w,&rct);		if ((width != 0) && (height != 0))		{			rct.left=(LONG)x;			rct.right=(LONG)(x+width);			rct.top=(LONG)y;			rct.bottom=(LONG)(y+height);			FillRect(hDC,&rct,hbrush);		}		SelectObject(hDC, oldObj);		// DeleteObject(hbrush);		SetROP2(hDC,oldROP);		cjh_rel_dc(ntw,hDC);	}	return 0;}RegionXCreateRegion(){	HRGN hrgn;	xtrace("XCreateRegion\n");	hrgn=CreateRectRgn(0,0,1,1);	return ((Region)hrgn);}/* Untested.  The Region stuff needs thinking about. */intXClipBox(hrgn,rect)Region hrgn;XRectangle *rect;{	RECT rct;	xtrace("XClipBox\n");	GetRgnBox((HRGN)hrgn,&rct);	rect->x=(short)rct.left;	rect->y=(short)rct.top;	rect->width=(unsigned short)(rct.right-rct.left);	rect->height=(unsigned short)(rct.bottom-rct.top);	return TRUE;/*(rect);*/}intXSetRegion(display,gc,hrgn)Display *display;GC gc;Region hrgn;{	/* What to do here ? */	xtrace("XSetRegion\n");	return 0;}intXDestroyRegion(hrgn)Region hrgn;{	xtrace("XDestroyRegion\n");	DeleteObject(hrgn);	return 0;}intXUnionRectWithRegion(rect,hrgnsrc,hrgndest)XRectangle *rect;Region hrgnsrc,hrgndest;{	HRGN temp;	xtrace("XUnionRectWithRegion\n");	temp=CreateRectRgn(rect->x,rect->y,rect->x+rect->width,				rect->y+rect->height);	CombineRgn((HRGN)hrgndest,(HRGN)hrgnsrc,temp,RGN_OR);	return 0;}/*****************************************************************\	Function: XDrawArc	Inputs:   display, window, gc, bounding box geometry, arc angles.	Comments: Works fine.\*****************************************************************/intXDrawArc(display,w,gc,x,y,width,height,a1,a2)Display *display;Drawable w;GC gc;int x,y;unsigned int width,height;int a1,a2;{	HDC hDC;	HPEN hpen;	int tmp;	double NT_deg64_to_rad();	HANDLE oldObj;	xtrace("XDrawArc\n");	if (a2>=0)		a2+=a1;	else	{		tmp=a1;		a1-=a2;		a2=tmp;	}	if (VALID_WINDOW(w))	{		hDC = drawableGetDC(w);		hpen = NT_get_GC_pen(hDC,gc);		oldObj = SelectObject(hDC,hpen);		Arc(hDC,x,y,x+width-1,y+height-1,			(int) (x+width/2+width*cos(NT_deg64_to_rad(a1))),			(int) (y+height/2-height*sin(NT_deg64_to_rad(a1))),			(int) (x+width/2+width*cos(NT_deg64_to_rad(a2))),			(int) (y+height/2-height*sin(NT_deg64_to_rad(a2))));		SelectObject(hDC, oldObj);		drawableRelDC(w,hDC);	}	return 0;}/*****************************************************************\	Function: XFillArc	Inputs:   display, window, gc, geometry as above.	Comments: Not tested at all, but should work.\*****************************************************************/intXFillArc(display,w,gc,x,y,width,height,a1,a2)Display *display;Drawable w;GC gc;int x,y;unsigned int width,height;int a1,a2;{	HDC hDC;	HBRUSH hbrush;	int tmp;        HANDLE oldObj;		xtrace("XFillArc\n");	if (a2>=0)		a2+=a1;	else	{		tmp=a1;		a1-=a2;		a2=tmp;	}	if (VALID_WINDOW(w))	{		hDC = drawableGetDC(w);		hbrush = NT_get_GC_brush(hDC,gc);		oldObj = SelectObject(hDC,hbrush);		if (gc->values.arc_mode==ArcChord)		{			Chord(hDC,x,y,x+width,y+height,				  (int) (x+width/2+width*cos(NT_deg64_to_rad(a1))),				  (int) (y+height/2+height*sin(NT_deg64_to_rad(a1))),				  (int) (x+width/2+width*cos(NT_deg64_to_rad(a2))),				  (int) (y+height/2+height*sin(NT_deg64_to_rad(a2))));		}		else		{			Pie(hDC,x,y,x+width,y+height,				(int) (x+width/2+width*cos(NT_deg64_to_rad(a1))),				(int) (y+height/2+height*sin(NT_deg64_to_rad(a1))),				(int) (x+width/2+width*cos(NT_deg64_to_rad(a2))),				(int) (y+height/2+height*sin(NT_deg64_to_rad(a2))));		}		SelectObject(hDC, oldObj);		drawableRelDC(w,hDC);	}	return 0;}/*****************************************************************\	Function: XFillPolygon	Inputs:   display, window, gc, points list, number of points,		  shape hint, relative drawing mode.	Comments: Works for convex polygons.  Untested on otherwise.	          Optimisation hints are unused, as is the mode.\*****************************************************************/intXFillPolygon(display,w,gc,points,nps,shape,mode)Display *display;Drawable w;GC gc;XPoint *points;int nps,shape,mode;{	HBRUSH hbrush;	int n;	POINT ntps[1000];	HDC hDC;	HANDLE oldObj;	xtrace("XFillPolygon\n"); 	/*ntps=allocateMemory(sizeof(POINT)*nps);*/	if (VALID_WINDOW(w))	{		hDC = drawableGetDC(w);		hbrush = NT_get_GC_brush(hDC,gc);		oldObj = SelectObject(hDC,hbrush);		for (n=0;n<nps;++n)		{			(ntps+n)->x=(LONG)points->x;			(ntps+n)->y=(LONG)(points++)->y;		}		Polygon(hDC,ntps,nps);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -