📄 client.c
字号:
*
* free's the specified array.
*/
void
GrFreeFontList(GR_FONTLIST ***fonts, int n)
{
int i;
MWFONTLIST *g, **list = *fonts;
for (i = 0; i < n; i++) {
g = list[i];
if(g) {
if(g->mwname)
free(g->mwname);
if(g->ttname)
free(g->ttname);
free(g);
}
}
free(list);
*fonts = 0;
}
/**
* GrSetFontSize:
* @fontid: the ID number of the font to change the size of
* @fontsize: the size to change the font to
*
* Changes the size of the specified font to the specified size.
*/
void
GrSetFontSize(GR_FONT_ID fontid, GR_COORD fontsize)
{
nxSetFontSizeReq *req;
req = AllocReq(SetFontSize);
req->fontid = fontid;
req->fontsize = fontsize;
}
/**
* GrSetFontRotation:
* @fontid: the ID number of the font to rotate
* @tenthdegrees: the angle to set the rotation to in tenths of a degree
*
* Changes the rotation of the specified font to the specified angle.
*/
void
GrSetFontRotation(GR_FONT_ID fontid, int tenthdegrees)
{
nxSetFontRotationReq *req;
req = AllocReq(SetFontRotation);
req->fontid = fontid;
req->tenthdegrees = tenthdegrees;
}
/**
* GrSetFontAttr:
* @fontid: the ID of the font to set the attributes of
* @setflags: mask specifying attribute flags to set
* @clrflags: mask specifying attribute flags to clear
*
* Changes the attributes (GR_TFKERNING, GR_TFANTIALIAS, GR_TFUNDERLINE, etc.)
* of the specified font according to the set and clear mask arguments.
*/
void
GrSetFontAttr(GR_FONT_ID fontid, int setflags, int clrflags)
{
nxSetFontAttrReq *req;
req = AllocReq(SetFontAttr);
req->fontid = fontid;
req->setflags = setflags;
req->clrflags = clrflags;
}
/**
* GrDestroyFont:
* @fontid: the ID of the font to destroy
*
* Frees all resources associated with the specified font ID, and if the font
* is a non built in type and this is the last ID referring to it, unloads the
* font from memory.
*/
void
GrDestroyFont(GR_FONT_ID fontid)
{
nxDestroyFontReq *req;
req = AllocReq(DestroyFont);
req->fontid = fontid;
}
/**
* GrSetGCFont:
* @gc: the ID of the graphics context to set the font of
* @font: the ID of the font
*
* Sets the font to be used for text drawing in the specified graphics
* context to the specified font ID.
*/
void
GrSetGCFont(GR_GC_ID gc, GR_FONT_ID font)
{
nxSetGCFontReq *req;
req = AllocReq(SetGCFont);
req->gcid = gc;
req->fontid = font;
}
/**
* GrLine:
* @id: the ID of the drawable to draw the line on
* @gc: the ID of the graphics context to use when drawing the line
* @x1: the X coordinate of the start of the line relative to the drawable
* @y1: the Y coordinate of the start of the line relative to the drawable
* @x2: the X coordinate of the end of the line relative to the drawable
* @y2: the Y coordinate of the end of the line relative to the drawable
*
* Draws a line using the specified graphics context on the specified drawable
* from (x1, y1) to (x2, y2), with coordinates given relative to the drawable.
*/
void
GrLine(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x1, GR_COORD y1, GR_COORD x2,
GR_COORD y2)
{
nxLineReq *req;
req = AllocReq(Line);
req->drawid = id;
req->gcid = gc;
req->x1 = x1;
req->y1 = y1;
req->x2 = x2;
req->y2 = y2;
}
/**
* GrRect:
* @id: the ID of the drawable to draw the rectangle on
* @gc: the ID of the graphics context to use when drawing the rectangle
* @x: the X coordinate of the rectangle relative to the drawable
* @y: the Y coordinate of the rectangle relative to the drawable
* @width: the width of the rectangle
* @height: the height of the rectangle
*
* Draw the boundary of a rectangle of the specified dimensions and position
* on the specified drawable using the specified graphics context.
*/
void
GrRect(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y, GR_SIZE width,
GR_SIZE height)
{
nxRectReq *req;
req = AllocReq(Rect);
req->drawid = id;
req->gcid = gc;
req->x = x;
req->y = y;
req->width = width;
req->height = height;
}
/**
* GrFillRect:
* @id: the ID of the drawable to draw the rectangle on
* @gc: the ID of the graphics context to use when drawing the rectangle
* @x: the X coordinate of the rectangle relative to the drawable
* @y: the Y coordinate of the rectangle relative to the drawable
* @width: the width of the rectangle
* @height: the height of the rectangle
*
* Draw a filled rectangle of the specified dimensions and position on the
* specified drawable using the specified graphics context.
*/
void
GrFillRect(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
GR_SIZE width, GR_SIZE height)
{
nxFillRectReq *req;
req = AllocReq(FillRect);
req->drawid = id;
req->gcid = gc;
req->x = x;
req->y = y;
req->width = width;
req->height = height;
}
/**
* GrEllipse:
* @id: the ID of the drawable to draw the ellipse on
* @gc: the ID of the graphics context to use when drawing the ellipse
* @x: the X coordinate to draw the ellipse at relative to the drawable
* @y: the Y coordinate to draw the ellipse at relative to the drawable
* @rx: the radius of the ellipse on the X axis
* @ry: the radius of the ellipse on the Y axis
*
* Draws the boundary of ellipse at the specified position using the specified
* dimensions and graphics context on the specified drawable.
*/
void
GrEllipse(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y, GR_SIZE rx,
GR_SIZE ry)
{
nxEllipseReq *req;
req = AllocReq(Ellipse);
req->drawid = id;
req->gcid = gc;
req->x = x;
req->y = y;
req->rx = rx;
req->ry = ry;
}
/**
* GrFillEllipse:
* @id: the ID of the drawable to draw the filled ellipse on
* @gc: the ID of the graphics context to use when drawing the ellipse
* @x: the X coordinate to draw the ellipse at relative to the drawable
* @y: the Y coordinate to draw the ellipse at relative to the drawable
* @rx: the radius of the ellipse on the X axis
* @ry: the radius of the ellipse on the Y axis
*
* Draws a filled ellipse at the specified position using the specified
* dimensions and graphics context on the specified drawable.
*/
void
GrFillEllipse(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
GR_SIZE rx, GR_SIZE ry)
{
nxFillEllipseReq *req;
req = AllocReq(FillEllipse);
req->drawid = id;
req->gcid = gc;
req->x = x;
req->y = y;
req->rx = rx;
req->ry = ry;
}
/**
* GrArc:
* @id: the ID of the drawable to draw the arc on
* @gc: the graphics context to use when drawing the arc
* @x: the X coordinate to draw the arc at relative to the drawable
* @y: the Y coordinate to draw the arc at relative to the drawable
* @rx: the radius of the arc on the X axis
* @ry: the radius of the arc on the Y axis
* @ax: the X coordinate of the start of the arc relative to the drawable
* @ay: the Y coordinate of the start of the arc relative to the drawable
* @bx: the X coordinate of the end of the arc relative to the drawable
* @by: the Y coordinate of the end of the arc relative to the drawable
* @type: the fill style to use when drawing the arc
*
* Draws an arc with the specified dimensions at the specified position
* on the specified drawable using the specified graphics context.
* The type specifies the fill type. Possible values include GR_ARC and
* GR_PIE.
*/
void
GrArc(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
GR_SIZE rx, GR_SIZE ry, GR_COORD ax, GR_COORD ay,
GR_COORD bx, GR_COORD by, int type)
{
nxArcReq *req;
req = AllocReq(Arc);
req->drawid = id;
req->gcid = gc;
req->x = x;
req->y = y;
req->rx = rx;
req->ry = ry;
req->ax = ax;
req->ay = ay;
req->bx = bx;
req->by = by;
req->type = type;
}
/**
* GrArcAngle:
* @id: the ID of the drawable to draw the arc on
* @gc: the graphics context to use when drawing the arc
* @x: the X coordinate to draw the arc at relative to the drawable
* @y: the Y coordinate to draw the arc at relative to the drawable
* @rx: the radius of the arc on the X axis
* @ry: the radius of the arc on the Y axis
* @angle1: the angle of the start of the arc
* @angle2: the angle of the end of the arc
* @type: the fill style to use when drawing the arc
*
* Draws an arc with the specified dimensions at the specified position
* on the specified drawable using the specified graphics context.
* The type specifies the fill type. Possible values include GR_ARC and
* GR_PIE. This function requires floating point support, and is slightly
* slower than the GrArc() function which does not require floating point.
*/
void
GrArcAngle(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
GR_SIZE rx, GR_SIZE ry, GR_COORD angle1, GR_COORD angle2, int type)
{
nxArcAngleReq *req;
req = AllocReq(ArcAngle);
req->drawid = id;
req->gcid = gc;
req->x = x;
req->y = y;
req->rx = rx;
req->ry = ry;
req->angle1 = angle1;
req->angle2 = angle2;
req->type = type;
}
/**
* GrBitmap:
* @id: the ID of the drawable to draw the bitmap onto
* @gc: the ID of the graphics context to use when drawing the bitmap
* @x: the X coordinate to draw the bitmap at relative to the drawable
* @y: the Y coordinate to draw the bitmap at relative to the drawable
* @width: the width of the bitmap
* @height: the height of the bitmap
* @bitmaptable: pointer to the bitmap data
*
* Draws the monochrome bitmap data provided in the bitmaptable argument
* at the specified position on the specified drawable using the specified
* graphics context. Note that the bitmap data should be an array of aligned
* 16 bit words. The usebackground flag in the graphics context specifies
* whether to draw the background colour wherever a bit value is zero.
*/
void
GrBitmap(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y, GR_SIZE width,
GR_SIZE height, GR_BITMAP *bitmaptable)
{
nxBitmapReq *req;
long bitmapsize;
bitmapsize = (long)GR_BITMAP_SIZE(width, height) * sizeof(GR_BITMAP);
req = AllocReqExtra(Bitmap, bitmapsize);
req->drawid = id;
req->gcid = gc;
req->x = x;
req->y = y;
req->width = width;
req->height = height;
memcpy(GetReqData(req), bitmaptable, bitmapsize);
}
/**
* GrDrawImageBits:
* @id: the ID of the drawable to draw the image onto
* @gc: the ID of the graphics context to use when drawing the image
* @x: the X coordinate to draw the image at relative to the drawable
* @y: the Y coordinate to draw the image at relative to the drawable
* @pimage: pointer to the image structure
*
* Draws the image contained in the specified image structure onto the
* specified drawable at the specified coordinates using the specified
* graphics context.
*/
void
GrDrawImageBits(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
GR_IMAGE_HDR *pimage)
{
nxDrawImageBitsReq *req;
int imagesize;
int palsize;
char *addr;
imagesize = pimage->pitch * pimage->height;
palsize = pimage->palsize * sizeof(MWPALENTRY);
req = AllocReqExtra(DrawImageBits, imagesize + palsize);
req->drawid = id;
req->gcid = gc;
req->x = x;
req->y = y;
/* fill MWIMAGEHDR items passed externally*/
req->width = pimage->width;
req->height = pimage->height;
req->planes = pimage->planes;
req->bpp = pimage->bpp;
req->pitch = pimage->pitch;
req->bytesperpixel = pimage->bytesperpixel;
req->compression = pimage->compression;
req->palsize = pimage->palsize;
req->transcolor = pimage->transcolor;
addr = GetReqData(req);
memcpy(addr, pimage->imagebits, imagesize);
memcpy(addr+imagesize, pimage->palette, palsize);
}
/**
* GrDrawImageFromFile:
* @id: the ID of the drawable to draw the image onto
* @gc: the ID of the graphics context to use when drawing the image
* @x: the X coordinate to draw the image at relative to the drawable
* @y: the Y coordinate to draw the image at relative to the drawable
* @width: the maximum image width
* @height: the maximum image height
* @path: string containing the filename of the image to load
* @flags: flags specific to the particular image loader
*
* Loads the specified image file and draws it at the specified position
* on the specified drawable using the specified graphics context. The
* width and height values specify the size of the image to draw- if the
* actual image is a different size, it will be scaled to fit. The image type
* is automatically detected using the magic numbers in the image header (ie.
* the filename extension is irrelevant). The currently supported image types
* include GIF, JPEG, Windows BMP, PNG, XPM, and both ascii and binary
* variants of PBM, PGM, and PPM. However the image types supported by a
* particular server depend on which image types were enabled in the server
* configuration at build time.
*/
void
GrDrawImageFromFile(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
GR_SIZE width, GR_SIZE height, char* path, int flags)
{
nxDrawImageFromFileReq *req;
req = AllocReqExtra(DrawImageFromFile, strlen(path)+1);
req->drawid = id;
req->gcid = gc;
req->x = x;
req->y = y;
req->width = width;
req->height = height;
req->flags = flags;
memcpy(GetReqData(req), path, strlen(path)+1);
}
/**
* GrLoadImageFromFile:
* @path: string containing the filename of the image to load
* @flags: flags specific to the particular image loader
* @Returns: ID of the image buffer the image was loaded into
*
* Loads the specified image file into a newly created server image buffer
* and returns the ID of the buffer. The image type is automatically detected
* using the magic numbers in the image header (ie. the filename extension is
* irrelevant). The currently supported image types include GIF, JPEG, Windows
* BMP, PNG, XPM, and both ascii and binary variants of PBM, PGM, and PPM.
* However the image types supported by a particular server depend on which
* image types were enabled in the server configuration at build time.
*/
GR_IMAGE_ID
GrLoadImageFromFile(char *path, int flags)
{
nxLoadImageFromFileReq *req;
GR_IMAGE_ID imageid;
req = AllocReqExtra(LoadImageFromFile, strlen(path)+1);
req->flags = flags;
memcpy(GetReqData(req), path, strlen(path)+1);
if(GrTypedReadBlock(&imageid, sizeof(imageid),
GrNumLoadImageFromFile) == -1)
return 0;
return imageid;
}
/**
* GrDrawImageToFit:
* @id: the ID of the drawable to draw the image onto
* @gc: the ID of the graphics context to use when drawing the image
* @x: the X coordinate to draw the image at relative to the drawable
* @y: the Y coordinate to draw the image at relative to the drawable
* @width: the maximum image width
* @height: the maximum image height
* @imageid: the ID of the image buffer containing the image to display
*
* Draws the image from the specified image buffer at the specified position
* on the specified drawable using the specified graphics context. The
* width and height values specify the size of the image to dra
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -