📄 client.c
字号:
int
GrGetRegionBox(GR_REGION_ID region, GR_RECT *rect)
{
nxGetRegionBoxReq *req;
unsigned short ret_value;
if (!rect)
return GR_FALSE;
req = AllocReq(GetRegionBox);
req->regionid = region;
if(GrTypedReadBlock(rect, sizeof(*rect), GrNumGetRegionBox) == -1)
return GR_FALSE;
if(GrTypedReadBlock(&ret_value, sizeof(ret_value),
GrNumGetRegionBox) == -1)
return GR_FALSE;
return ret_value;
}
/**
* GrNewPolygonRegion:
* @mode: the polygon mode to use (GR_POLY_EVENODD or GR_POLY_WINDING)
* @count: the number of points in the polygon
* @points: pointer to an array of point structures describing the polygon
* @Returns: the ID of the newly allocated region structure, or 0 on error
*
* Creates a new region structure, fills it with the region described by the
* specified polygon, and returns the ID used to refer to it.
*/
GR_REGION_ID
GrNewPolygonRegion(int mode, GR_COUNT count, GR_POINT *points)
{
nxNewPolygonRegionReq *req;
long size;
GR_REGION_ID region;
if(count == 0)
return GrNewRegion();
if(points == NULL)
return 0;
size = (long)count * sizeof(GR_POINT);
req = AllocReqExtra(NewPolygonRegion, size);
req->mode = mode;
/* FIXME: unportable method, depends on sizeof(int) in GR_POINT*/
memcpy(GetReqData(req), points, size);
if(GrTypedReadBlock(®ion, sizeof(region),
GrNumNewPolygonRegion) == -1)
return 0;
return region;
}
/**
* GrMapWindow:
* @wid: the ID of the window to map
*
* Recursively maps (makes visible) the specified window and all of the
* child windows which have a sufficient map count. The border and background
* of the window are painted, and an exposure event is generated for the
* window and every child which becomes visible.
*/
void
GrMapWindow(GR_WINDOW_ID wid)
{
nxMapWindowReq *req;
req = AllocReq(MapWindow);
req->windowid = wid;
}
/**
* GrUnmapWindow:
* @wid: the ID of the window to unmap
*
* Recursively unmaps (makes invisible) the specified window and all of the
* child windows.
*/
void
GrUnmapWindow(GR_WINDOW_ID wid)
{
nxUnmapWindowReq *req;
req = AllocReq(UnmapWindow);
req->windowid = wid;
}
/**
* GrRaiseWindow:
* @wid: the ID of the window to raise
*
* Places the specified window at the top of its parents drawing stack, above
* all of its sibling windows.
*/
void
GrRaiseWindow(GR_WINDOW_ID wid)
{
nxRaiseWindowReq *req;
req = AllocReq(RaiseWindow);
req->windowid = wid;
}
/**
* GrLowerWindow:
* @wid: the ID of the window to lower
*
* Places the specified window at the bottom of its parents drawing stack,
* below all of its sibling windows.
*/
void
GrLowerWindow(GR_WINDOW_ID wid)
{
nxLowerWindowReq *req;
req = AllocReq(LowerWindow);
req->windowid = wid;
}
/**
* GrMoveWindow:
* @wid: the ID of the window to move
* @x: the X coordinate to move the window to relative to its parent.
* @y: the Y coordinate to move the window to relative to its parent.
*
* Moves the specified window to the specified position relative to its
* parent window.
*/
void
GrMoveWindow(GR_WINDOW_ID wid, GR_COORD x, GR_COORD y)
{
nxMoveWindowReq *req;
req = AllocReq(MoveWindow);
req->windowid = wid;
req->x = x;
req->y = y;
}
/**
* GrResizeWindow:
* @wid: the ID of the window to resize
* @width: the width to resize the window to
* @height: the height to resize the window to
*
* Resizes the specified window to be the specified width and height.
*/
void
GrResizeWindow(GR_WINDOW_ID wid, GR_SIZE width, GR_SIZE height)
{
nxResizeWindowReq *req;
req = AllocReq(ResizeWindow);
req->windowid = wid;
req->width = width;
req->height = height;
}
/**
* GrReparentWindow:
* @wid: the ID of the window to reparent
* @pwid: the ID of the new parent window
* @x: the X coordinate to place the window at relative to the new parent
* @y: the Y coordinate to place the window at relative to the new parent
*
* Changes the parent window of the specified window to the specified parent
* window and places it at the specified coordinates relative to the new
* parent.
*/
void
GrReparentWindow(GR_WINDOW_ID wid, GR_WINDOW_ID pwid, GR_COORD x, GR_COORD y)
{
nxReparentWindowReq *req;
req = AllocReq(ReparentWindow);
req->windowid = wid;
req->parentid = pwid;
req->x = x;
req->y = y;
}
/**
* GrClearArea:
* @wid: window ID
* @exposeflag: a flag indicating whether to also generate an exposure event
*
* Clears the specified window by to its background color or pixmap.
* If exposeflag is non zero, an exposure event is generated for
* the window after it has been cleared.
*/
void
GrClearArea(GR_WINDOW_ID wid, GR_COORD x, GR_COORD y, GR_SIZE width,
GR_SIZE height, GR_BOOL exposeflag)
{
nxClearAreaReq *req;
req = AllocReq(ClearArea);
req->windowid = wid;
req->x = x;
req->y = y;
req->width = width;
req->height = height;
req->exposeflag = exposeflag;
}
/**
* GrGetFocus:
* @Returns: the ID of the window which currently has the keyboard focus
*
* Returns the ID of the window which currently has the keyboard focus.
*/
GR_WINDOW_ID
GrGetFocus(void)
{
GR_WINDOW_ID wid;
AllocReq(GetFocus);
if(GrTypedReadBlock(&wid, sizeof(wid), GrNumGetFocus) == -1)
return 0;
return wid;
}
/**
* GrSetFocus:
* @wid: the ID of the window to set the focus to
*
* Sets the keyboard focus to the specified window.
*/
void
GrSetFocus(GR_WINDOW_ID wid)
{
nxSetFocusReq *req;
req = AllocReq(SetFocus);
req->windowid = wid;
}
/**
* GrSetWindowCursor:
* @wid: the ID of the window to set the cursor for
* @cid: the cursor ID
*
* Specify a cursor for a window.
* This cursor will only be used within that window, and by default
* for its new children. If the cursor is currently within this
* window, it will be changed to the new one immediately.
* If the new cursor ID is 0, revert to the root window cursor.
*/
void
GrSetWindowCursor(GR_WINDOW_ID wid, GR_CURSOR_ID cid)
{
nxSetWindowCursorReq *req;
req = AllocReq(SetWindowCursor);
req->windowid = wid;
req->cursorid = cid;
}
/**
* GrNewCursor:
* @width: the width of the pointer bitmap
* @height: the height of the pointer bitmap
* @hotx: the X coordinate within the bitmap used as the target of the pointer
* @hoty: the Y coordinate within the bitmap used as the target of the pointer
* @foreground: the colour to use for the foreground of the pointer
* @background: the colour to use for the background of the pointer
* @fgbitmap: pointer to bitmap data specifying the foreground of the pointer
* @bgbitmap: pointer to bitmap data specifying the background of the pointer
*
* Creates a server-based cursor (mouse graphic) resource.
*/
GR_CURSOR_ID
GrNewCursor(GR_SIZE width, GR_SIZE height, GR_COORD hotx, GR_COORD hoty,
GR_COLOR foreground, GR_COLOR background,
GR_BITMAP *fgbitmap, GR_BITMAP *bgbitmap)
{
nxNewCursorReq *req;
int bitmapsize;
char * data;
GR_CURSOR_ID cursorid;
bitmapsize = GR_BITMAP_SIZE(width, height) * sizeof(GR_BITMAP);
req = AllocReqExtra(NewCursor, bitmapsize*2);
req->width = width;
req->height = height;
req->hotx = hotx;
req->hoty = hoty;
req->fgcolor = foreground;
req->bgcolor = background;
data = GetReqData(req);
memcpy(data, fgbitmap, bitmapsize);
memcpy(data+bitmapsize, bgbitmap, bitmapsize);
if(GrTypedReadBlock(&cursorid, sizeof(cursorid), GrNumNewCursor) == -1)
return 0;
return cursorid;
}
/**
* GrMoveCursor:
* @x: the X coordinate to move the pointer to
* @y: the Y coordinate to move the pointer to
*
* Moves the cursor (mouse pointer) to the specified coordinates.
* The coordinates are relative to the root window, where (0,0) is the upper
* left hand corner of the screen. The reference point used for the pointer
* is that of the "hot spot". After moving the pointer, the graphic used for
* the pointer will change to the graphic defined for use in the window which
* it is over.
*/
void
GrMoveCursor(GR_COORD x, GR_COORD y)
{
nxMoveCursorReq *req;
req = AllocReq(MoveCursor);
req->x = x;
req->y = y;
}
/**
* GrSetGCForeground:
* @gc: the ID of the graphics context to set the foreground colour of
* @foreground: the colour to use as the new foreground colour
*
* Changes the foreground colour of the specified graphics context to the
* specified colour.
*/
void
GrSetGCForeground(GR_GC_ID gc, GR_COLOR foreground)
{
nxSetGCForegroundReq *req;
req = AllocReq(SetGCForeground);
req->gcid = gc;
req->color = foreground;
}
/**
* GrSetGCBackground:
* @gc: the ID of the graphics context to set the background colour of
* @background: the colour to use as the new background colour
*
* Changes the background colour of the specified graphics context to the
* specified colour.
*/
void
GrSetGCBackground(GR_GC_ID gc, GR_COLOR background)
{
nxSetGCBackgroundReq *req;
req = AllocReq(SetGCBackground);
req->gcid = gc;
req->color = background;
}
/**
* GrSetGCMode:
* @gc: the ID of the graphics context to set the drawing mode of
* @mode: the new drawing mode
*
* Changes the drawing mode (SET, XOR, OR, AND, etc.) of the specified
* graphics context to the specified mode.
*/
void
GrSetGCMode(GR_GC_ID gc, int mode)
{
nxSetGCModeReq *req;
req = AllocReq(SetGCMode);
req->gcid = gc;
req->mode = mode;
}
/**
* GrSetGCUseBackground:
* @gc: the ID of the graphics context to change the "use background" flag of
* @flag: flag specifying whether to use the background colour or not
*
* Sets the flag which chooses whether or not the background colour is used
* when drawing bitmaps and text using the specified graphics context to the
* specified value.
*/
void
GrSetGCUseBackground(GR_GC_ID gc, GR_BOOL flag)
{
nxSetGCUseBackgroundReq *req;
req = AllocReq(SetGCUseBackground);
req->gcid = gc;
req->flag = flag;
}
/**
* GrCreateFont:
* @name: string containing the name of a built in font to look for
* @height: the desired height of the font
* @plogfont: pointer to a LOGFONT structure
* @Returns: a font ID number which can be used to refer to the font
*
* Attempts to locate a font with the desired attributes and returns a font
* ID number which can be used to refer to it. If the plogfont argument is
* not NULL, the values in that structure will be used to choose a font.
* Otherwise, if the height is non zero, the built in font with the closest
* height to that specified will be used. If the height is zero, the built
* in font with the specified name will be used. If the desired font is not
* found, the first built in font will be returned as a last resort.
*/
GR_FONT_ID
GrCreateFont(GR_CHAR *name, GR_COORD height, GR_LOGFONT *plogfont)
{
nxCreateFontReq *req;
GR_FONT_ID fontid;
req = AllocReq(CreateFont);
if (plogfont) {
memcpy(&req->lf, plogfont, sizeof(*plogfont));
req->height = 0;
req->lf_used = 1;
} else {
if (name)
strcpy(req->lf.lfFaceName, name);
else req->lf.lfFaceName[0] = '\0';
req->height = height;
req->lf_used = 0;
}
if(GrTypedReadBlock(&fontid, sizeof(fontid),GrNumCreateFont) == -1)
return 0;
return fontid;
}
/**
* GrGetFontList:
* @fonts: pointer used to return an array of font names.
* @numfonts: pointer used to return the number of names found.
*
* Returns an array of strings containing the names of available fonts and an
* integer that specifies the number of strings returned.
*/
void
GrGetFontList(GR_FONTLIST ***fonts, int *numfonts)
{
nxGetFontListReq *req;
char *tmpstr;
GR_FONTLIST **flist;
int num, len, i;
req = AllocReq(GetFontList);
GrTypedReadBlock(&num, sizeof(int), GrNumGetFontList);
*numfonts = num;
if(num == -1)
return;
flist = (GR_FONTLIST**)malloc(num * sizeof(GR_FONTLIST*));
for(i = 0; i < num; i++)
flist[i] = (GR_FONTLIST*)malloc(sizeof(GR_FONTLIST*));
for(i = 0; i < num; i++) {
GrReadBlock(&len, sizeof(int));
tmpstr = (char*)malloc(len * sizeof(char));
GrReadBlock(tmpstr, len * sizeof(char));
flist[i]->ttname = tmpstr;
GrReadBlock(&len, sizeof(int));
tmpstr = (char*)malloc(len * sizeof(char));
GrReadBlock(tmpstr, len * sizeof(char));
flist[i]->mwname = tmpstr;
}
*fonts = flist;
}
/**
* GrFreeFontList:
* @fonts: pointer to array returned by GrGetFontList
* @numfonts: the number of font names in the array
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -