📄 device.h
字号:
/* note: don't use palette indices if the palette may * be reloaded. Use the RGB values instead. */#define BLACK PALINDEX(0) /* 0, 0, 0*/#define BLUE PALINDEX(1)#define GREEN PALINDEX(2)#define CYAN PALINDEX(3)#define RED PALINDEX(4)#define MAGENTA PALINDEX(5)#define BROWN PALINDEX(6)#define LTGRAY PALINDEX(7) /* 192, 192, 192*/#define GRAY PALINDEX(8) /* 128, 128, 128*/#define LTBLUE PALINDEX(9)#define LTGREEN PALINDEX(10)#define LTCYAN PALINDEX(11)#define LTRED PALINDEX(12)#define LTMAGENTA PALINDEX(13)#define YELLOW PALINDEX(14)#define WHITE PALINDEX(15) /* 255, 255, 255*/#endif/* GdMakePaletteConversionTable bLoadType types*/#define LOADPALETTE 1 /* load image palette into system palette*/#define MERGEPALETTE 2 /* merge image palette into system palette*//* entry points*//* devdraw.c*/PSD GdOpenScreen(void);void GdCloseScreen(PSD psd);int GdSetPortraitMode(PSD psd, int portraitmode);int GdSetMode(int mode);MWBOOL GdSetUseBackground(MWBOOL flag);MWPIXELVAL GdSetForegroundPixelVal(PSD psd, MWPIXELVAL fg);MWPIXELVAL GdSetBackgroundPixelVal(PSD psd, MWPIXELVAL bg);MWPIXELVAL GdSetForegroundColor(PSD psd, MWCOLORVAL fg);MWPIXELVAL GdSetBackgroundColor(PSD psd, MWCOLORVAL bg);void GdResetPalette(void);void GdSetPalette(PSD psd,int first, int count, MWPALENTRY *palette);int GdGetPalette(PSD psd,int first, int count, MWPALENTRY *palette);MWCOLORVAL GdGetColorRGB(PSD psd, MWPIXELVAL pixel);MWPIXELVAL GdFindColor(PSD psd, MWCOLORVAL c);MWPIXELVAL GdFindNearestColor(MWPALENTRY *pal, int size, MWCOLORVAL cr);int GdCaptureScreen(char *path);void GdGetScreenInfo(PSD psd,PMWSCREENINFO psi);void GdPoint(PSD psd,MWCOORD x, MWCOORD y);void GdLine(PSD psd,MWCOORD x1,MWCOORD y1,MWCOORD x2,MWCOORD y2, MWBOOL bDrawLastPoint);void GdRect(PSD psd,MWCOORD x, MWCOORD y, MWCOORD width, MWCOORD height);void GdFillRect(PSD psd,MWCOORD x, MWCOORD y, MWCOORD width, MWCOORD height);void GdBitmap(PSD psd,MWCOORD x,MWCOORD y,MWCOORD width,MWCOORD height, const MWIMAGEBITS *imagebits);MWBOOL GdColorInPalette(MWCOLORVAL cr,MWPALENTRY *palette,int palsize);void GdMakePaletteConversionTable(PSD psd,MWPALENTRY *palette,int palsize, MWPIXELVAL *convtable,int fLoadType);void GdDrawImage(PSD psd,MWCOORD x, MWCOORD y, PMWIMAGEHDR pimage);void GdPoly(PSD psd,int count, MWPOINT *points);void GdFillPoly(PSD psd,int count, MWPOINT *points);void GdReadArea(PSD psd,MWCOORD x,MWCOORD y,MWCOORD width,MWCOORD height, MWPIXELVAL *pixels);void GdArea(PSD psd,MWCOORD x,MWCOORD y,MWCOORD width,MWCOORD height, void *pixels, int pixtype);void GdDrawAreaInternal(PSD psd, driver_gc_t * gc, int op);void GdTranslateArea(MWCOORD width, MWCOORD height, void *in, int inpixtype, MWCOORD inpitch, void *out, int outpixtype, int outpitch);void GdCopyArea(PSD psd,MWCOORD srcx,MWCOORD srcy,MWCOORD width, MWCOORD height, MWCOORD destx, MWCOORD desty);void GdBlit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD width, MWCOORD height,PSD srcpsd,MWCOORD srcx,MWCOORD srcy,long rop);void GdStretchBlit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD dstw, MWCOORD dsth, PSD srcpsd, MWCOORD srcx, MWCOORD srcy, MWCOORD srcw, MWCOORD srch, long rop);void GdStretchBlitEx(PSD dstpsd, MWCOORD d1_x, MWCOORD d1_y, MWCOORD d2_x, MWCOORD d2_y, PSD srcpsd, MWCOORD s1_x, MWCOORD s1_y, MWCOORD s2_x, MWCOORD s2_y, long rop);int GdCalcMemGCAlloc(PSD psd, unsigned int width, unsigned int height, int planes, int bpp, int *size, int *linelen);void drawbitmap(PSD psd, MWCOORD x, MWCOORD y, MWCOORD width, MWCOORD height, const MWIMAGEBITS *imagebits);void drawpoint(PSD psd, MWCOORD x, MWCOORD y);void drawrow(PSD psd, MWCOORD x1, MWCOORD x2, MWCOORD y);extern SCREENDEVICE scrdev;/* devarc.c*//* requires float*/void GdArcAngle(PSD psd, MWCOORD x0, MWCOORD y0, MWCOORD rx, MWCOORD ry, MWCOORD angle1, MWCOORD angle2, int type);/* integer only*/void GdArc(PSD psd, MWCOORD x0, MWCOORD y0, MWCOORD rx, MWCOORD ry, MWCOORD ax, MWCOORD ay, MWCOORD bx, MWCOORD by, int type);void GdEllipse(PSD psd,MWCOORD x, MWCOORD y, MWCOORD rx, MWCOORD ry, MWBOOL fill);/* devfont.c*/void GdClearFontList(void);int GdAddFont(char *fndry, char *family, char *fontname, PMWLOGFONT lf, unsigned int flags);PMWFONT GdSetFont(PMWFONT pfont);PMWFONT GdCreateFont(PSD psd, const char *name, MWCOORD height, const PMWLOGFONT plogfont);MWCOORD GdSetFontSize(PMWFONT pfont, MWCOORD fontsize);void GdGetFontList(MWFONTLIST ***list, int *num);void GdFreeFontList(MWFONTLIST ***list, int num);int GdSetFontRotation(PMWFONT pfont, int tenthdegrees);int GdSetFontAttr(PMWFONT pfont, int setflags, int clrflags);void GdDestroyFont(PMWFONT pfont);MWBOOL GdGetFontInfo(PMWFONT pfont, PMWFONTINFO pfontinfo);int GdConvertEncoding(const void *istr, MWTEXTFLAGS iflags, int cc, void *ostr, MWTEXTFLAGS oflags);void GdGetTextSize(PMWFONT pfont, const void *str, int cc, MWCOORD *pwidth, MWCOORD *pheight, MWCOORD *pbase, MWTEXTFLAGS flags);int GdGetTextSizeEx(PMWFONT pfont, const void *str, int cc, int nMaxExtent, int *lpnFit, int *alpDx, MWCOORD *pwidth, MWCOORD *pheight, MWCOORD *pbase, MWTEXTFLAGS flags); void GdText(PSD psd,MWCOORD x,MWCOORD y,const void *str,int count, MWTEXTFLAGS flags);PMWFONT GdCreateFontFromBuffer(PSD psd, const unsigned char *buffer, unsigned length, const char *format, MWCOORD height);PMWFONT GdDuplicateFont(PSD psd, PMWFONT psrcfont, MWCOORD fontsize);/* devclip1.c*/void GdSetClipRects(PSD psd,int count,MWCLIPRECT *table);MWBOOL GdClipPoint(PSD psd,MWCOORD x,MWCOORD y);int GdClipArea(PSD psd,MWCOORD x1, MWCOORD y1, MWCOORD x2, MWCOORD y2);extern MWCOORD clipminx, clipminy, clipmaxx, clipmaxy;/* devclip2.c*/void GdSetClipRegion(PSD psd, MWCLIPREGION *reg);/* devrgn.c - multi-rectangle region entry points*/MWBOOL GdPtInRegion(MWCLIPREGION *rgn, MWCOORD x, MWCOORD y);int GdRectInRegion(MWCLIPREGION *rgn, const MWRECT *rect);MWBOOL GdEqualRegion(MWCLIPREGION *r1, MWCLIPREGION *r2);MWBOOL GdEmptyRegion(MWCLIPREGION *rgn);MWCLIPREGION *GdAllocRegion(void);MWCLIPREGION *GdAllocRectRegion(MWCOORD left,MWCOORD top,MWCOORD right,MWCOORD bottom);MWCLIPREGION *GdAllocRectRegionIndirect(MWRECT *prc);void GdSetRectRegion(MWCLIPREGION *rgn, MWCOORD left, MWCOORD top, MWCOORD right, MWCOORD bottom);void GdSetRectRegionIndirect(MWCLIPREGION *rgn, MWRECT *prc);void GdDestroyRegion(MWCLIPREGION *rgn);void GdOffsetRegion(MWCLIPREGION *rgn, MWCOORD x, MWCOORD y);int GdGetRegionBox(MWCLIPREGION *rgn, MWRECT *prc);void GdUnionRectWithRegion(const MWRECT *rect, MWCLIPREGION *rgn);void GdSubtractRectFromRegion(const MWRECT *rect, MWCLIPREGION *rgn);void GdCopyRegion(MWCLIPREGION *d, MWCLIPREGION *s);void GdIntersectRegion(MWCLIPREGION *d, MWCLIPREGION *s1, MWCLIPREGION *s2);void GdUnionRegion(MWCLIPREGION *d, MWCLIPREGION *s1, MWCLIPREGION *s2);void GdSubtractRegion(MWCLIPREGION *d, MWCLIPREGION *s1, MWCLIPREGION *s2);void GdXorRegion(MWCLIPREGION *d, MWCLIPREGION *s1, MWCLIPREGION *s2);MWCLIPREGION *GdAllocBitmapRegion(MWIMAGEBITS *bitmap, MWCOORD width, MWCOORD height);/* devrgn2.c*/MWCLIPREGION *GdAllocPolygonRegion(MWPOINT *points, int count, int mode);MWCLIPREGION *GdAllocPolyPolygonRegion(MWPOINT *points, int *count, int nbpolygons, int mode);/* devmouse.c*/int GdOpenMouse(void);void GdCloseMouse(void);void GdGetButtonInfo(int *buttons);void GdRestrictMouse(MWCOORD newminx,MWCOORD newminy,MWCOORD newmaxx, MWCOORD newmaxy);void GdSetAccelMouse(int newthresh, int newscale);void GdMoveMouse(MWCOORD newx, MWCOORD newy);int GdReadMouse(MWCOORD *px, MWCOORD *py, int *pb);void GdMoveCursor(MWCOORD x, MWCOORD y);MWBOOL GdGetCursorPos(MWCOORD *px, MWCOORD *py);void GdSetCursor(PMWCURSOR pcursor);int GdShowCursor(PSD psd);int GdHideCursor(PSD psd);void GdCheckCursor(PSD psd,MWCOORD x1,MWCOORD y1,MWCOORD x2,MWCOORD y2);void GdFixCursor(PSD psd);void GdSetTransform(MWTRANSFORM *);extern MOUSEDEVICE mousedev;/* devkbd.c*/int GdOpenKeyboard(void);void GdCloseKeyboard(void);void GdGetModifierInfo(MWKEYMOD *modifiers, MWKEYMOD *curmodifiers);int GdReadKeyboard(MWKEY *buf, MWKEYMOD *modifiers, MWSCANCODE *scancode);extern KBDDEVICE kbddev;#ifdef MW_FEATURE_TWO_KEYBOARDSint GdOpenKeyboard2(void);extern KBDDEVICE kbddev2;#endif/* devimage.c */#if MW_FEATURE_IMAGESint GdLoadImageFromBuffer(PSD psd, void *buffer, int size, int flags);void GdDrawImageFromBuffer(PSD psd, MWCOORD x, MWCOORD y, MWCOORD width, MWCOORD height, void *buffer, int size, int flags);void GdDrawImageFromFile(PSD psd, MWCOORD x, MWCOORD y, MWCOORD width, MWCOORD height, char *path, int flags);int GdLoadImageFromFile(PSD psd, char *path, int flags);void GdDrawImageToFit(PSD psd, MWCOORD x, MWCOORD y, MWCOORD width, MWCOORD height, int id);void GdFreeImage(int id);MWBOOL GdGetImageInfo(int id, PMWIMAGEINFO pii);void GdStretchImage(PMWIMAGEHDR src, MWCLIPRECT *srcrect, PMWIMAGEHDR dst, MWCLIPRECT *dstrect);void GdComputeImagePitch(int bpp, int width, int *pitch, int *bytesperpixel);/* Buffered input functions to replace stdio functions*/typedef struct { /* structure for reading images from buffer */ unsigned char *start; /* The pointer to the beginning of the buffer */ unsigned long offset; /* The current offset within the buffer */ unsigned long size; /* The total size of the buffer */} buffer_t;void GdImageBufferInit(buffer_t *buffer, void *startdata, int size);void GdImageBufferSeekTo(buffer_t *buffer, unsigned long offset);int GdImageBufferRead(buffer_t *buffer, void *dest, unsigned long size);int GdImageBufferGetChar(buffer_t *buffer);char * GdImageBufferGetString(buffer_t *buffer, char *dest, unsigned int size);int GdImageBufferEOF(buffer_t *buffer);/* individual decoders*/#ifdef HAVE_BMP_SUPPORTint GdDecodeBMP(buffer_t *src, PMWIMAGEHDR pimage);#endif#ifdef HAVE_JPEG_SUPPORTint GdDecodeJPEG(buffer_t *src, PMWIMAGEHDR pimage, PSD psd, MWBOOL fast_grayscale);#endif#ifdef HAVE_PNG_SUPPORTint GdDecodePNG(buffer_t *src, PMWIMAGEHDR pimage);#endif#ifdef HAVE_GIF_SUPPORTint GdDecodeGIF(buffer_t *src, PMWIMAGEHDR pimage);#endif#ifdef HAVE_PNM_SUPPORTint GdDecodePNM(buffer_t *src, PMWIMAGEHDR pimage);#endif#ifdef HAVE_XPM_SUPPORTint GdDecodeXPM(buffer_t *src, PMWIMAGEHDR pimage, PSD psd);#endif#ifdef HAVE_TIFF_SUPPORTint GdDecodeTIFF(char *path, PMWIMAGEHDR pimage);#endif#endif /* MW_FEATURE_IMAGES *//* devlist.c*//* field offset*/#define MWITEM_OFFSET(type, field) ((long)&(((type *)0)->field))void * GdItemAlloc(unsigned int size);void GdListAdd(PMWLISTHEAD pHead,PMWLIST pItem);void GdListInsert(PMWLISTHEAD pHead,PMWLIST pItem);void GdListRemove(PMWLISTHEAD pHead,PMWLIST pItem);#define GdItemNew(type) ((type *)GdItemAlloc(sizeof(type)))#define GdItemFree(ptr) free((void *)ptr)/* devstipple.c */void GdSetDash(unsigned long *mask, int *count);void GdSetStippleBitmap(MWIMAGEBITS *stipple, MWCOORD width, MWCOORD height);void GdSetTSOffset(int xoff, int yoff);int GdSetFillMode(int mode);void GdSetTilePixmap(PSD src, MWCOORD width, MWCOORD height);void ts_drawpoint(PSD psd, MWCOORD x, MWCOORD y);void ts_drawrow(PSD psd, MWCOORD x1, MWCOORD x2, MWCOORD y);void ts_fillrect(PSD psd, MWCOORD x, MWCOORD y, MWCOORD w, MWCOORD h);void set_ts_origin(int x, int y);/* return base item address from list ptr*/#define GdItemAddr(p,type,list) ((type *)((long)p - MWITEM_OFFSET(type,list)))#if MW_FEATURE_TIMERS#include <sys/time.h>typedef void (*MWTIMERCB)(void *);#define MWTIMER_ONESHOT 0 #define MWTIMER_PERIODIC 1typedef struct mw_timer MWTIMER;struct mw_timer { struct timeval timeout; MWTIMERCB callback; void *arg; MWTIMER *next; MWTIMER *prev; int type; /* MWTIMER_ONESHOT or MWTIMER_PERIODIC */ MWTIMEOUT period;};MWTIMER *GdAddTimer(MWTIMEOUT timeout, MWTIMERCB callback, void *arg);MWTIMER *GdAddPeriodicTimer(MWTIMEOUT timeout, MWTIMERCB callback, void *arg);void GdDestroyTimer(MWTIMER *timer);MWTIMER *GdFindTimer(void *arg);MWBOOL GdGetNextTimeout(struct timeval *tv, MWTIMEOUT timeout);MWBOOL GdTimeout(void);#endif /* MW_FEATURE_TIMERS *//* error.c*/int GdError(const char *format, ...);int GdErrorNull(const char *format, ...); /* doesn't print msgs */#if USE_ALLOCA/* alloca() is available, so use it for better performance */#define ALLOCA(size) alloca(size)#define FREEA(pmem)#else/* no alloca(), so use malloc()/free() instead */#define ALLOCA(size) malloc(size)#define FREEA(pmem) free(pmem)#endif/* no assert() in MSDOS or ELKS...*/#if MSDOS | ELKS#undef assert#define assert(x)#endif/* RTEMS requires rtems_main()*/#if __rtems__#define main rtems_main#endif#if !_MINIX#ifndef __rtems__#define HAVESELECT 1 /* has select system call*/#endif#endif#endif /*_DEVICE_H*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -