📄 client.c
字号:
* * @param wid the ID of the window to set the focus to * * @ingroup nanox_window */void GrSetFocus(GR_WINDOW_ID wid){ nxSetFocusReq *req; LOCK(&nxGlobalLock); req = AllocReq(SetFocus); req->windowid = wid; UNLOCK(&nxGlobalLock);}/** * 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. * * @param wid the ID of the window to set the cursor for * @param cid the cursor ID * * @ingroup nanox_cursor */voidGrSetWindowCursor(GR_WINDOW_ID wid, GR_CURSOR_ID cid){ nxSetWindowCursorReq *req; LOCK(&nxGlobalLock); req = AllocReq(SetWindowCursor); req->windowid = wid; req->cursorid = cid; UNLOCK(&nxGlobalLock);}/** * Creates a server-based cursor (mouse graphic) resource. * * @param width the width of the pointer bitmap * @param height the height of the pointer bitmap * @param hotx the X coordinate within the bitmap used as the target of the pointer * @param hoty the Y coordinate within the bitmap used as the target of the pointer * @param foreground the colour to use for the foreground of the pointer * @param background the colour to use for the background of the pointer * @param fgbitmap pointer to bitmap data specifying the foreground of the pointer * @param bgbitmap pointer to bitmap data specifying the background of the pointer * * @ingroup nanox_cursor */GR_CURSOR_IDGrNewCursor(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); LOCK(&nxGlobalLock); 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(TypedReadBlock(&cursorid, sizeof(cursorid), GrNumNewCursor) == -1) cursorid = 0; UNLOCK(&nxGlobalLock); return cursorid;}/** * 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. * * @param x the X coordinate to move the pointer to * @param y the Y coordinate to move the pointer to * * @ingroup nanox_cursor */void GrMoveCursor(GR_COORD x, GR_COORD y){ nxMoveCursorReq *req; LOCK(&nxGlobalLock); req = AllocReq(MoveCursor); req->x = x; req->y = y; UNLOCK(&nxGlobalLock);}/** * Changes the foreground colour of the specified graphics context to the * specified RGB colour. * * @param gc the ID of the graphics context to set the foreground colour of * @param foreground the RGB colour to use as the new foreground colour * * @ingroup nanox_draw */void GrSetGCForeground(GR_GC_ID gc, GR_COLOR foreground){ nxSetGCForegroundReq *req; LOCK(&nxGlobalLock); req = AllocReq(SetGCForeground); req->gcid = gc; req->color = foreground; UNLOCK(&nxGlobalLock);}/** * Changes the background colour of the specified graphics context to the * specified RGB colour. * * @param gc the ID of the graphics context to set the background colour of * @param background the RGB colour to use as the new background colour * * @ingroup nanox_draw */void GrSetGCBackground(GR_GC_ID gc, GR_COLOR background){ nxSetGCBackgroundReq *req; LOCK(&nxGlobalLock); req = AllocReq(SetGCBackground); req->gcid = gc; req->color = background; UNLOCK(&nxGlobalLock);}/** * Changes the foreground colour of the specified graphics context to the * specified hardware pixel value. * * @param gc The ID of the graphics context to set the foreground colour of. * @param foreground The GR_PIXELVAL (i.e. hardware pixel value) to use as the new * foreground colour. * * @ingroup nanox_draw */voidGrSetGCForegroundPixelVal(GR_GC_ID gc, GR_PIXELVAL foreground){ nxSetGCForegroundPixelValReq *req; LOCK(&nxGlobalLock); req = AllocReq(SetGCForegroundPixelVal); req->gcid = gc; req->pixelval = foreground; UNLOCK(&nxGlobalLock);}/** * Changes the background colour of the specified graphics context to the * specified hardware pixel value. * * @param gc the ID of the graphics context to set the background colour of * @param background the GR_PIXELVAL (i.e. hardware pixel value) to use as the new * background colour * * @ingroup nanox_draw */voidGrSetGCBackgroundPixelVal(GR_GC_ID gc, GR_PIXELVAL background){ nxSetGCBackgroundPixelValReq *req; LOCK(&nxGlobalLock); req = AllocReq(SetGCBackgroundPixelVal); req->gcid = gc; req->pixelval = background; UNLOCK(&nxGlobalLock);}/** * Changes the drawing mode (SET, XOR, OR, AND, etc.) of the specified * graphics context to the specified mode. * * @param gc the ID of the graphics context to set the drawing mode of * @param mode the new drawing mode * * @ingroup nanox_draw */void GrSetGCMode(GR_GC_ID gc, int mode){ nxSetGCModeReq *req; LOCK(&nxGlobalLock); req = AllocReq(SetGCMode); req->gcid = gc; req->mode = mode; UNLOCK(&nxGlobalLock);}/** * Changes the line style to either SOLID or ON OFF DASHED * * @param gc the ID of the graphics context to set the drawing mode of * @param linestyle The new style of the line * * @ingroup nanox_draw */void GrSetGCLineAttributes(GR_GC_ID gc, int linestyle){ nxSetGCLineAttributesReq *req; LOCK(&nxGlobalLock); req = AllocReq(SetGCLineAttributes); req->gcid = gc; req->linestyle = linestyle; UNLOCK(&nxGlobalLock);}/** * FIXME * * @param gc Graphics context ID. * @param dashes FIXME * @param count FIXME * * @todo FIXME document this * * @ingroup nanox_draw */void GrSetGCDash(GR_GC_ID gc, char *dashes, int count){ nxSetGCDashReq *req; int size; size = count * sizeof(char); LOCK(&nxGlobalLock); req = AllocReqExtra(SetGCDash, size); req->gcid = gc; req->count = count; memcpy(GetReqData(req), dashes, size); UNLOCK(&nxGlobalLock);}/** * FIXME * * @param gc FIXME * @param fillmode FIXME * * @todo FIXME document this * * @ingroup nanox_draw */voidGrSetGCFillMode(GR_GC_ID gc, int fillmode){ nxSetGCFillModeReq *req; LOCK(&nxGlobalLock); req = AllocReq(SetGCFillMode); req->gcid = gc; req->fillmode = fillmode; UNLOCK(&nxGlobalLock);}/** * FIXME * * @param gc FIXME * @param bitmap FIXME * @param width FIXME * @param height FIXME * * @todo FIXME document this * * @ingroup nanox_draw */voidGrSetGCStipple(GR_GC_ID gc, GR_BITMAP *bitmap, int width, int height){ nxSetGCStippleReq *req; int size; size = GR_BITMAP_SIZE(width, height) * sizeof(GR_BITMAP); LOCK(&nxGlobalLock); req = AllocReqExtra(SetGCStipple, size); req->gcid = gc; req->width = width; req->height = height; memcpy(GetReqData(req), bitmap, size); UNLOCK(&nxGlobalLock);}/** * FIXME * * @param gc FIXME * @param pixmap FIXME * @param width FIXME * @param height FIXME * * @todo FIXME document this * * @ingroup nanox_draw */voidGrSetGCTile(GR_GC_ID gc, GR_WINDOW_ID pixmap, int width, int height){ nxSetGCTileReq *req; LOCK(&nxGlobalLock); req = AllocReq(SetGCTile); req->gcid = gc; req->pixmap = pixmap; req->width = width; req->height = height; UNLOCK(&nxGlobalLock);}/** * FIXME * * @param gc FIXME * @param xoff FIXME * @param yoff FIXME * * @todo FIXME document this * * @ingroup nanox_draw */voidGrSetGCTSOffset(GR_GC_ID gc, int xoff, int yoff){ nxSetGCTSOffsetReq *req; LOCK(&nxGlobalLock); req = AllocReq(SetGCTSOffset); req->gcid = gc; req->xoffset = xoff; req->yoffset = yoff; UNLOCK(&nxGlobalLock);}/** * 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. * * @param gc the ID of the graphics context to change the "use background" flag of * @param flag flag specifying whether to use the background colour or not * * @ingroup nanox_draw */void GrSetGCUseBackground(GR_GC_ID gc, GR_BOOL flag){ nxSetGCUseBackgroundReq *req; LOCK(&nxGlobalLock); req = AllocReq(SetGCUseBackground); req->gcid = gc; req->flag = flag; UNLOCK(&nxGlobalLock);}/** * 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. * * @param name string containing the name of a built in font to look for * @param height the desired height of the font * @param plogfont pointer to a LOGFONT structure * @return a font ID number which can be used to refer to the font * * @ingroup nanox_font */GR_FONT_IDGrCreateFont(GR_CHAR *name, GR_COORD height, GR_LOGFONT *plogfont){ GR_FONT_ID fontid; LOCK(&nxGlobalLock); if (plogfont) { nxCreateLogFontReq *req; req = AllocReq(CreateLogFont); memcpy(&req->lf, plogfont, sizeof(*plogfont)); if (TypedReadBlock(&fontid, sizeof(fontid), GrNumCreateLogFont) == -1) fontid = 0; } else { nxCreateFontReq *req; if (!name) name = ""; req = AllocReqExtra(CreateFont, strlen(name) + 1); req->height = height; strcpy((char *)GetReqData(req), name); if (TypedReadBlock(&fontid, sizeof(fontid), GrNumCreateFont) == -1) fontid = 0; } UNLOCK(&nxGlobalLock); return fontid;}/** * Returns an array of strings containing the names of available fonts and an * integer that specifies the number of strings returned. * * @param fonts pointer used to return an array of font names. * @param numfonts pointer used to return the number of names found. * * @ingroup nanox_font */void GrGetFontList(GR_FONTLIST ***fonts, int *numfonts){ nxGetFontListReq *req; char *tmpstr; GR_FONTLIST **flist; int num, len, i; LOCK(&nxGlobalLock); req = AllocReq(GetFontList); if (TypedReadBlock(&num, sizeof(int), GrNumGetFontList) == -1) num = 0; *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++) { ReadBlock(&len, sizeof(int)); tmpstr = (char*)malloc(len * sizeof(char)); ReadBlock(tmpstr, len * sizeof(char)); flist[i]->ttname = tmpstr; ReadBlock(&len, sizeof(int)); tmpstr = (char*)malloc(len * sizeof(char)); ReadBlock(tmpstr, len * sizeof(char)); flist[i]->mwname = tmpstr; } *fonts = flist; UNLOCK(&nxGlobalLock);}/** * Frees the specified font list array. * * @param fonts Pointer to array returned by GrGetFontList(). * @param numfonts The number of font names in the array. * * @ingroup nanox_font */voidGrFreeFontList(GR_FONTLIST ***fonts, int numfonts){ int i; MWFONTLIST *g, **list = *fonts; LOCK(&nxGlobalLock); for (i = 0; i < numfonts; i++) { g = list[i]; if(g) { if(g->mwname) free(g->mwname); if(g->ttname) free(g->ttname); free(g); } } free(list); *fonts = 0; UNLOCK(&nxGlobalLock);}/** * Changes the size of the specified font to the specified size. * * @param fontid the ID number of the font to change the size of * @param size the size to change the font to * * @ingroup nanox_font */voidGrSetFontSize(GR_FONT_ID fontid, GR_COORD size){ nxSetFontSizeReq *req; LOCK(&nxGlobalLock); req = AllocReq(SetFontSize);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -