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

📄 misc.c

📁 su 的源代码库
💻 C
字号:
/* Copyright (c) Colorado School of Mines, 2006.*//* All rights reserved.                       *//* MISC: $Revision: 1.5 $ ; $Date: 1997/07/30 21:14:57 $	*//*********************** self documentation **********************//*****************************************************************************MISC - Miscellaneous X-Toolkit functionsXtcwpDrawString90	Draw a string rotated 90 degrees counter-clockwise******************************************************************************Function Prototype:void XtcwpDrawString90 (Display *dpy, Drawable d, GC gc,	int x, int y, char *string, int count);******************************************************************************Input:dpy		X displayd		X drawablegc		X graphics contextx,y		coordinates of baseline starting position of the stringstring		array[count] of characters to be drawncount		number of characters in string******************************************************************************Author:  Dave Hale, Advance Geophysical, 06/03/93*****************************************************************************//**************** end self doc ********************************/#include <Xtcwp/Xtcwp.h>/* An X error handler that does nothing */static int doNothingErrorHandler (Display* dpy, XErrorEvent* event){	if(event - event) doNothingErrorHandler(dpy,event); /* keep compiler happy */	return EXIT_SUCCESS;}void XtcwpDrawString90 (Display *dpy, Drawable d, GC gc,	int x, int y, char *string, int count)/*****************************************************************************Draw a string rotated 90 degrees counter-clockwise******************************************************************************Input:dpy		X displayd		X drawablegc		X graphics contextx,y		coordinates of baseline starting position of the stringstring		array[count] of characters to be drawncount		number of characters in string******************************************************************************Author:  Dave Hale, Advance Geophysical, 06/03/93*****************************************************************************/{	int sa,sd,sw,sh,rw,rh,i,j;	unsigned int width,height,depth;	XFontStruct *fs;	XCharStruct cs;	Pixmap hpix;	XImage *himage,*vimage;	int idummy;	unsigned int uidummy;	Window wdummy;	int (*eh)(Display*,XErrorEvent*);	/* If count is too small */	if (count<1) return;	/* Width, height, and depth of drawable */	XGetGeometry(dpy,d,&wdummy,&idummy,&idummy,&width,&height,		&uidummy,&depth);	/* String width and height before and after rotation */	fs = XQueryFont(dpy,XGContextFromGC(gc));	XTextExtents(fs,string,count,&idummy,&idummy,&idummy,&cs);	sa = cs.ascent;	sd = cs.descent;	sw = cs.width;	sh = cs.ascent+cs.descent;	rw = sh;	rh = sw;	/* If rotated string will not be entirely inside drawable, return */	if (x-sa<0 || x+sd>width-1 || y-sw<0 || y>height-1) {		XFreeFontInfo(NULL,fs,1);		return;	}	/* Set error handler to catch BadMatch errors from GetImage,	 * if Drawable is a Window, when rotated string would not	 * be viewable or entirely on the screen.  No way to prevent	 * this error, since we can't tell if the Drawable is a Pixmap 	 * or a Window. */	eh = XSetErrorHandler(doNothingErrorHandler);	/* Get vertical XImage from Drawable */	vimage = XGetImage(dpy,d,x-sa,y-sw,rw,rh,AllPlanes,ZPixmap);	/* Restore previous error handler */	XSetErrorHandler(eh);	/* If any problem in XGetImage, free font info and return */	if (vimage==NULL) {	  XFreeFontInfo(NULL,fs,1);	  return;	}	/* Rotate vertical image to horizontal Pixmap */	hpix = XCreatePixmap(dpy,d,sw,sh,depth);	himage = XGetImage(dpy,hpix,0,0,sw,sh,AllPlanes,ZPixmap);	for (i=0; i<sw; ++i)		for (j=0; j<sh; ++j)			XPutPixel(himage,i,j,XGetPixel(vimage,j,sw-1-i));	XPutImage(dpy,hpix,gc,himage,0,0,0,0,sw,sh);	/* Draw string in horizontal Pixmap */	XDrawString(dpy,hpix,gc,0,sa,string,count);	/* Rotate horizontal Pixmap to vertical XImage */	XDestroyImage(himage);	himage = XGetImage(dpy,hpix,0,0,sw,sh,AllPlanes,ZPixmap);	XFreePixmap(dpy,hpix);	for (i=0; i<sw; ++i)		for (j=0; j<sh; ++j)			XPutPixel(vimage,j,sw-1-i,XGetPixel(himage,i,j));	XDestroyImage(himage);	/* Put vertical XImage to Drawable */	XPutImage(dpy,d,gc,vimage,0,0,x-sa,y-sw,rw,rh);	XDestroyImage(vimage);	/* Free font information */	XFreeFontInfo(NULL,fs,1);}

⌨️ 快捷键说明

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