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

📄 tkwindraw.c

📁 linux系统下的音频通信
💻 C
📖 第 1 页 / 共 3 页
字号:
    }    DeleteObject(SelectObject(dc, oldBrush));}/* *---------------------------------------------------------------------- * * XDrawLines -- * *	Draw connected lines. * * Results: *	None. * * Side effects: *	Renders a series of connected lines. * *---------------------------------------------------------------------- */voidXDrawLines(display, d, gc, points, npoints, mode)    Display* display;    Drawable d;    GC gc;    XPoint* points;    int npoints;    int mode;{    HPEN pen;    TkWinDCState state;    HDC dc;        if (d == None) {	return;    }    dc = TkWinGetDrawableDC(display, d, &state);    if (!tkpIsWin32s && (gc->line_width > 1)) {	LOGBRUSH lb;	DWORD style;	lb.lbStyle = BS_SOLID;	lb.lbColor = gc->foreground;	lb.lbHatch = 0;	style = PS_GEOMETRIC|PS_COSMETIC;	switch (gc->cap_style) {	    case CapNotLast:	    case CapButt:		style |= PS_ENDCAP_FLAT; 		break;	    case CapRound:		style |= PS_ENDCAP_ROUND; 		break;	    default:		style |= PS_ENDCAP_SQUARE; 		break;	}	switch (gc->join_style) {	    case JoinMiter: 		style |= PS_JOIN_MITER; 		break;	    case JoinRound:		style |= PS_JOIN_ROUND; 		break;	    default:		style |= PS_JOIN_BEVEL; 		break;	}	pen = ExtCreatePen(style, gc->line_width, &lb, 0, NULL);    } else {	pen = CreatePen(PS_SOLID, gc->line_width, gc->foreground);    }    RenderObject(dc, gc, points, npoints, mode, pen, Polyline);    DeleteObject(pen);        TkWinReleaseDrawableDC(d, dc, &state);}/* *---------------------------------------------------------------------- * * XFillPolygon -- * *	Draws a filled polygon. * * Results: *	None. * * Side effects: *	Draws a filled polygon on the specified drawable. * *---------------------------------------------------------------------- */voidXFillPolygon(display, d, gc, points, npoints, shape, mode)    Display* display;    Drawable d;    GC gc;    XPoint* points;    int npoints;    int shape;    int mode;{    HPEN pen;    TkWinDCState state;    HDC dc;    if (d == None) {	return;    }    dc = TkWinGetDrawableDC(display, d, &state);    pen = GetStockObject(NULL_PEN);    RenderObject(dc, gc, points, npoints, mode, pen, Polygon);    TkWinReleaseDrawableDC(d, dc, &state);}/* *---------------------------------------------------------------------- * * XDrawRectangle -- * *	Draws a rectangle. * * Results: *	None. * * Side effects: *	Draws a rectangle on the specified drawable. * *---------------------------------------------------------------------- */voidXDrawRectangle(display, d, gc, x, y, width, height)    Display* display;    Drawable d;    GC gc;    int x;    int y;    unsigned int width;    unsigned int height;{    HPEN pen, oldPen;    TkWinDCState state;    HBRUSH oldBrush;    HDC dc;    if (d == None) {	return;    }    dc = TkWinGetDrawableDC(display, d, &state);    pen = CreatePen(PS_SOLID, gc->line_width, gc->foreground);    oldPen = SelectObject(dc, pen);    oldBrush = SelectObject(dc, GetStockObject(NULL_BRUSH));    SetROP2(dc, tkpWinRopModes[gc->function]);    Rectangle(dc, x, y, x+width+1, y+height+1);    DeleteObject(SelectObject(dc, oldPen));    SelectObject(dc, oldBrush);    TkWinReleaseDrawableDC(d, dc, &state);}/* *---------------------------------------------------------------------- * * XDrawArc -- * *	Draw an arc. * * Results: *	None. * * Side effects: *	Draws an arc on the specified drawable. * *---------------------------------------------------------------------- */voidXDrawArc(display, d, gc, x, y, width, height, start, extent)    Display* display;    Drawable d;    GC gc;    int x;    int y;    unsigned int width;    unsigned int height;    int start;    int extent;{    display->request++;    DrawOrFillArc(display, d, gc, x, y, width, height, start, extent, 0);}/* *---------------------------------------------------------------------- * * XFillArc -- * *	Draw a filled arc. * * Results: *	None. * * Side effects: *	Draws a filled arc on the specified drawable. * *---------------------------------------------------------------------- */voidXFillArc(display, d, gc, x, y, width, height, start, extent)    Display* display;    Drawable d;    GC gc;    int x;    int y;    unsigned int width;    unsigned int height;    int start;    int extent;{    display->request++;    DrawOrFillArc(display, d, gc, x, y, width, height, start, extent, 1);}/* *---------------------------------------------------------------------- * * DrawOrFillArc -- * *	This procedure handles the rendering of drawn or filled *	arcs and chords. * * Results: *	None. * * Side effects: *	Renders the requested arc. * *---------------------------------------------------------------------- */static voidDrawOrFillArc(display, d, gc, x, y, width, height, start, extent, fill)    Display *display;    Drawable d;    GC gc;    int x, y;			/* left top */    unsigned int width, height;    int start;			/* start: three-o'clock (deg*64) */    int extent;			/* extent: relative (deg*64) */    int fill;			/* ==0 draw, !=0 fill */{    HDC dc;    HBRUSH brush, oldBrush;    HPEN pen, oldPen;    TkWinDCState state;    int clockwise = (extent < 0); /* non-zero if clockwise */    int xstart, ystart, xend, yend;    double radian_start, radian_end, xr, yr;    if (d == None) {	return;    }    dc = TkWinGetDrawableDC(display, d, &state);    SetROP2(dc, tkpWinRopModes[gc->function]);    /*     * Compute the absolute starting and ending angles in normalized radians.     * Swap the start and end if drawing clockwise.     */    start = start % (64*360);    if (start < 0) {	start += (64*360);    }    extent = (start+extent) % (64*360);    if (extent < 0) {	extent += (64*360);    }    if (clockwise) {	int tmp = start;	start = extent;	extent = tmp;    }    radian_start = XAngleToRadians(start);    radian_end = XAngleToRadians(extent);    /*     * Now compute points on the radial lines that define the starting and     * ending angles.  Be sure to take into account that the y-coordinate     * system is inverted.     */    xr = x + width / 2.0;    yr = y + height / 2.0;    xstart = (int)((xr + cos(radian_start)*width/2.0) + 0.5);    ystart = (int)((yr + sin(-radian_start)*height/2.0) + 0.5);    xend = (int)((xr + cos(radian_end)*width/2.0) + 0.5);    yend = (int)((yr + sin(-radian_end)*height/2.0) + 0.5);    /*     * Now draw a filled or open figure.  Note that we have to     * increase the size of the bounding box by one to account for the     * difference in pixel definitions between X and Windows.     */    pen = CreatePen(PS_SOLID, gc->line_width, gc->foreground);    oldPen = SelectObject(dc, pen);    if (!fill) {	/*	 * Note that this call will leave a gap of one pixel at the	 * end of the arc for thin arcs.  We can't use ArcTo because	 * it's only supported under Windows NT.	 */	Arc(dc, x, y, x+width+1, y+height+1, xstart, ystart, xend, yend);    } else {	brush = CreateSolidBrush(gc->foreground);	oldBrush = SelectObject(dc, brush);	if (gc->arc_mode == ArcChord) {	    Chord(dc, x, y, x+width+1, y+height+1, xstart, ystart, xend, yend);	} else if ( gc->arc_mode == ArcPieSlice ) {	    Pie(dc, x, y, x+width+1, y+height+1, xstart, ystart, xend, yend);	}	DeleteObject(SelectObject(dc, oldBrush));    }    DeleteObject(SelectObject(dc, oldPen));    TkWinReleaseDrawableDC(d, dc, &state);}/* *---------------------------------------------------------------------- * * TkScrollWindow -- * *	Scroll a rectangle of the specified window and accumulate *	a damage region. * * Results: *	Returns 0 if the scroll genereated no additional damage. *	Otherwise, sets the region that needs to be repainted after *	scrolling and returns 1. * * Side effects: *	Scrolls the bits in the window. * *---------------------------------------------------------------------- */intTkScrollWindow(tkwin, gc, x, y, width, height, dx, dy, damageRgn)    Tk_Window tkwin;		/* The window to be scrolled. */    GC gc;			/* GC for window to be scrolled. */    int x, y, width, height;	/* Position rectangle to be scrolled. */    int dx, dy;			/* Distance rectangle should be moved. */    TkRegion damageRgn;		/* Region to accumulate damage in. */{    HWND hwnd = TkWinGetHWND(Tk_WindowId(tkwin));    RECT scrollRect;    scrollRect.left = x;    scrollRect.top = y;    scrollRect.right = x + width;    scrollRect.bottom = y + height;    return (ScrollWindowEx(hwnd, dx, dy, &scrollRect, NULL, (HRGN) damageRgn,	    NULL, 0) == NULLREGION) ? 0 : 1;}/* *---------------------------------------------------------------------- * * TkWinFillRect -- * *	This routine fills a rectangle with the foreground color *	from the specified GC ignoring all other GC values.  This *	is the fastest way to fill a drawable with a solid color. * * Results: *	None. * * Side effects: *	Modifies the contents of the DC drawing surface. * *---------------------------------------------------------------------- */voidTkWinFillRect(dc, x, y, width, height, pixel)    HDC dc;    int x, y, width, height;    int pixel;{    RECT rect;    COLORREF oldColor;    rect.left = x;    rect.top = y;    rect.right = x + width;    rect.bottom = y + height;    oldColor = SetBkColor(dc, (COLORREF)pixel);    SetBkMode(dc, OPAQUE);    ExtTextOut(dc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);    SetBkColor(dc, oldColor);}

⌨️ 快捷键说明

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