?? device.h
字號:
#ifndef _DEVICE_H#define _DEVICE_H/* * Copyright (c) 1999, 2000 Greg Haerr <greg@censoft.com> * * Engine-level Screen, Mouse and Keyboard device driver API's and types * * Contents of this file are not for general export */#include "mwtypes.h" /* public export typedefs*/#include <pkgconf/microwindows.h> /* CYGBLD_MICROWINDOWS_VNC_DRIVERS *//* Changeable limits and options*/#define ALPHABLEND 1 /* =1 to include blending code*/#define DYNAMICREGIONS 1 /* =1 to use MWCLIPREGIONS*/#define HAVEFLOAT 1 /* =1 incl float, GdArcAngle*/#define POLYREGIONS 1 /* =1 includes polygon regions*/#define ANIMATEPALETTE 0 /* =1 animated palette test*/#define FONTMAPPER 0 /* =1 for Morten's font mapper*/#define USE_ALLOCA 1 /* alloca() is available */#define EPRINTF GdError /* error output*/#define DPRINTF GdErrorNull /* debug output*//* max char height/width must be >= 16 and a multiple of sizeof(MWIMAGEBITS)*/#define MAX_CHAR_HEIGHT 128 /* maximum text bitmap height*/#define MAX_CHAR_WIDTH 128 /* maximum text bitmap width*/#define MIN_MWCOORD ((MWCOORD) -32768) /* minimum coordinate value */#define MAX_MWCOORD ((MWCOORD) 32767) /* maximum coordinate value */#define MAX_CLIPRECTS 200 /* max clip rects (obsolete)*/typedef struct _mwscreendevice *PSD;/* builtin C-based proportional/fixed font structure*/typedef struct { char * name; /* font name*/ int maxwidth; /* max width in pixels*/ int height; /* height in pixels*/ int ascent; /* ascent (baseline) height*/ int firstchar; /* first character in bitmap*/ int size; /* font size in characters*/ MWIMAGEBITS * bits; /* 16-bit right-padded bitmap data*/ unsigned short *offset; /* 256 offsets into bitmap data*/ unsigned char * width; /* 256 character widths or 0 if fixed*/} MWCFONT, *PMWCFONT;/* draw procs associated with fonts. Strings are [re]packed using defencoding*/typedef struct { int encoding; /* routines expect this encoding*/ MWBOOL (*GetFontInfo)(PMWFONT pfont, PMWFONTINFO pfontinfo); void (*GetTextSize)(PMWFONT pfont, const void *text, int cc, MWCOORD *pwidth, MWCOORD *pheight, MWCOORD *pbase); void (*GetTextBits)(PMWFONT pfont, int ch, MWIMAGEBITS *retmap, MWCOORD *pwidth, MWCOORD *pheight, MWCOORD *pbase); void (*DestroyFont)(PMWFONT pfont); void (*DrawText)(PMWFONT pfont, PSD psd, MWCOORD x, MWCOORD y, const void *str, int count, int flags); void (*SetFontSize)(PMWFONT pfont, MWCOORD fontsize); void (*SetFontRotation)(PMWFONT pfont, int tenthdegrees); void (*SetFontAttr)(PMWFONT pfont, int setflags, int clrflags);} MWFONTPROCS, *PMWFONTPROCS;/* new multi-renderer font struct*/typedef struct _mwfont { /* common hdr for all font structures*/ PMWFONTPROCS fontprocs; /* font-specific rendering routines*/ MWCOORD fontsize; /* font height in pixels*/ int fontrotation; /* font rotation*/ int fontattr; /* font attributes: kerning/antialias*/ /* font-specific rendering data here*/} MWFONT;/* fontattr flags*/#define FS_FREETYPE 0x0800/* builtin core font struct*/typedef struct { PMWFONTPROCS fontprocs; /* common hdr*/ MWCOORD fontsize; int fontrotation; int fontattr; char * name; /* Microwindows font name*/ PMWCFONT cfont; /* builtin font data*/} MWCOREFONT, *PMWCOREFONT;/* This structure is used to pass parameters into the low * level device driver functions. */typedef struct { MWCOORD dstx, dsty, dstw, dsth, dst_linelen; MWCOORD srcx, srcy, src_linelen; void *pixels, *misc; MWPIXELVAL bg_color, fg_color; int gr_usebg;} driver_gc_t;/* Operations for the Blitter/Area functions */#define PSDOP_COPY 0#define PSDOP_COPYALL 1#define PSDOP_COPYTRANS 2#define PSDOP_ALPHAMAP 3#define PSDOP_ALPHACOL 4#define PSDOP_PIXMAP_COPYALL 5/* common blitter parameter structure*/typedef struct { PSD dstpsd; /* dst drawable*/ MWCOORD dstx, dsty; /* dst x,y,w,h*/ MWCOORD dstw, dsth; MWCOORD srcx, srcy; /* src x,y*/ MWCOORD srcw, srch; /* src w,h if stretchblit*/ PSD srcpsd; /* src drawable*/ unsigned long rop; /* raster opcode*/ PSD alphachan; /* alpha chan for MWROP_BLENDCHANNEL*/ MWPIXELVAL fgcolor; /* fg/bg color for MWROP_BLENDFGBG*/ MWPIXELVAL bgcolor; MWPIXELVAL transcolor; /* trans color for MWROP_SRCTRANSCOPY*/} MWBLITARGS, *PMWBLITARGS;/* screen subdriver entry points: one required for each draw function*//* NOTE: currently used for fb driver only*/typedef struct { int (*Init)(PSD psd); void (*DrawPixel)(PSD psd, MWCOORD x, MWCOORD y, MWPIXELVAL c); MWPIXELVAL (*ReadPixel)(PSD psd, MWCOORD x, MWCOORD y); void (*DrawHorzLine)(PSD psd, MWCOORD x1, MWCOORD x2, MWCOORD y, MWPIXELVAL c); void (*DrawVertLine)(PSD psd, MWCOORD x, MWCOORD y1, MWCOORD y2, MWPIXELVAL c); void (*FillRect)(PSD psd,MWCOORD x1,MWCOORD y1,MWCOORD x2, MWCOORD y2,MWPIXELVAL c); void (*Blit)(PSD destpsd, MWCOORD destx, MWCOORD desty, MWCOORD w, MWCOORD h,PSD srcpsd,MWCOORD srcx,MWCOORD srcy,long op); void (*DrawArea)(PSD psd, driver_gc_t *gc, int op); void (*StretchBlit)(PSD destpsd, MWCOORD destx, MWCOORD desty, MWCOORD dstw, MWCOORD dsth, PSD srcpsd, MWCOORD srcx, MWCOORD srcy, MWCOORD srcw, MWCOORD srch, long op);} SUBDRIVER, *PSUBDRIVER;/* * Interface to Screen Device Driver * This structure is also allocated for memory (offscreen) drawing and blitting. */typedef struct _mwscreendevice { MWCOORD xres; /* X screen res (real) */ MWCOORD yres; /* Y screen res (real) */ MWCOORD xvirtres; /* X drawing res (will be flipped in portrait mode) */ MWCOORD yvirtres; /* Y drawing res (will be flipped in portrait mode) */ int planes; /* # planes*/ int bpp; /* # bpp*/ int linelen; /* line length in bytes for bpp 1,2,4,8*/ /* line length in pixels for bpp 16, 24, 32*/ int size; /* size of memory allocated*/ long ncolors; /* # screen colors*/ int pixtype; /* format of pixel value*/ int flags; /* device flags*/ void * addr; /* address of memory allocated (memdc or fb)*/ PSD (*Open)(PSD psd); void (*Close)(PSD psd); void (*GetScreenInfo)(PSD psd,PMWSCREENINFO psi); void (*SetPalette)(PSD psd,int first,int count,MWPALENTRY *pal); void (*DrawPixel)(PSD psd,MWCOORD x,MWCOORD y,MWPIXELVAL c); MWPIXELVAL (*ReadPixel)(PSD psd,MWCOORD x,MWCOORD y); void (*DrawHorzLine)(PSD psd,MWCOORD x1,MWCOORD x2,MWCOORD y, MWPIXELVAL c); void (*DrawVertLine)(PSD psd,MWCOORD x,MWCOORD y1,MWCOORD y2, MWPIXELVAL c); void (*FillRect)(PSD psd,MWCOORD x1,MWCOORD y1,MWCOORD x2,MWCOORD y2, MWPIXELVAL c); PMWCOREFONT builtin_fonts; /***void (*DrawText)(PSD psd,MWCOORD x,MWCOORD y,const MWUCHAR *str, int count, MWPIXELVAL fg, PMWFONT pfont);***/ void (*Blit)(PSD destpsd,MWCOORD destx,MWCOORD desty,MWCOORD w, MWCOORD h,PSD srcpsd,MWCOORD srcx,MWCOORD srcy,long op); void (*PreSelect)(PSD psd); void (*DrawArea)(PSD psd, driver_gc_t *gc, int op); int (*SetIOPermissions)(PSD psd); PSD (*AllocateMemGC)(PSD psd); MWBOOL (*MapMemGC)(PSD mempsd,MWCOORD w,MWCOORD h,int planes,int bpp, int linelen,int size,void *addr); void (*FreeMemGC)(PSD mempsd); void (*StretchBlit)(PSD destpsd,MWCOORD destx,MWCOORD desty, MWCOORD destw,MWCOORD desth,PSD srcpsd,MWCOORD srcx, MWCOORD srcy,MWCOORD srcw,MWCOORD srch,long op); void (*SetPortrait)(PSD psd,int portraitmode); int portrait; /* screen portrait mode*/ PSUBDRIVER orgsubdriver; /* original subdriver for portrait modes*/} SCREENDEVICE;/* PSD flags*/#define PSF_SCREEN 0x0001 /* screen device*/#define PSF_MEMORY 0x0002 /* memory device*/#define PSF_HAVEBLIT 0x0004 /* have bitblit*/#define PSF_HAVEOP_COPY 0x0008 /* psd->DrawArea can do area copy*/#define PSF_ADDRMALLOC 0x0010 /* psd->addr was malloc'd*/#define PSF_ADDRSHAREDMEM 0x0020 /* psd->addr is shared memory*//* Interface to Mouse Device Driver*/typedef struct _mousedevice { int (*Open)(struct _mousedevice *); void (*Close)(void); int (*GetButtonInfo)(void); void (*GetDefaultAccel)(int *pscale,int *pthresh); int (*Read)(MWCOORD *dx,MWCOORD *dy,MWCOORD *dz,int *bp); int (*Poll)(void); /* not required if have select()*/} MOUSEDEVICE;/* Interface to Keyboard Device Driver*/typedef struct _kbddevice { int (*Open)(struct _kbddevice *pkd); void (*Close)(void); void (*GetModifierInfo)(MWKEYMOD *modifiers, MWKEYMOD *curmodifiers); int (*Read)(MWKEY *buf,MWKEYMOD *modifiers,MWSCANCODE *scancode); int (*Poll)(void); /* not required if have select()*/} KBDDEVICE;/* Clip areas*/#define CLIP_VISIBLE 0#define CLIP_INVISIBLE 1#define CLIP_PARTIAL 2/* static clip rectangle: drawing allowed if point within rectangle*/typedef struct { MWCOORD x; /* x coordinate of top left corner */ MWCOORD y; /* y coordinate of top left corner */ MWCOORD width; /* width of rectangle */ MWCOORD height; /* height of rectangle */} MWCLIPRECT;#ifndef TRUE#define TRUE 1#endif#ifndef FALSE#define FALSE 0#endif#define MWMIN(a,b) ((a) < (b) ? (a) : (b))#define MWMAX(a,b) ((a) > (b) ? (a) : (b))/* MWIMAGEBITS macros*/#define MWIMAGE_SIZE(width, height) ((height) * (((width) + MWIMAGE_BITSPERIMAGE - 1) / MWIMAGE_BITSPERIMAGE))#define MWIMAGE_WORDS(x) (((x)+15)/16)#define MWIMAGE_BYTES(x) (((x)+7)/8)#define MWIMAGE_BITSPERIMAGE (sizeof(MWIMAGEBITS) * 8)#define MWIMAGE_FIRSTBIT ((MWIMAGEBITS) 0x8000)#define MWIMAGE_NEXTBIT(m) ((MWIMAGEBITS) ((m) >> 1))#define MWIMAGE_TESTBIT(m) ((m) & MWIMAGE_FIRSTBIT) /* use with shiftbit*/#define MWIMAGE_SHIFTBIT(m) ((MWIMAGEBITS) ((m) << 1)) /* for testbit*//* color and palette defines*/#define RGBDEF(r,g,b) {r, g, b}#define GETPALENTRY(pal,index) ((unsigned long)(pal[index].r |\ (pal[index].g << 8) | (pal[index].b << 16)))/*#define GETPALENTRY(pal,index) ((*(unsigned long *)&pal[index])&0x00ffffff)*/#define REDVALUE(rgb) ((rgb) & 0xff)#define GREENVALUE(rgb) (((rgb) >> 8) & 0xff)#define BLUEVALUE(rgb) (((rgb) >> 16) & 0xff)/* Truecolor color conversion and extraction macros*//* * Conversion from RGB to MWPIXELVAL *//* create 24 bit 8/8/8 format pixel (0x00RRGGBB) from RGB triplet*/#define RGB2PIXEL888(r,g,b) \ (((r) << 16) | ((g) << 8) | (b))/* create 16 bit 5/6/5 format pixel from RGB triplet */#define RGB2PIXEL565(r,g,b) \ ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))/* create 16 bit 5/5/5 format pixel from RGB triplet */#define RGB2PIXEL555(r,g,b) \ ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3))/* create 8 bit 3/3/2 format pixel from RGB triplet*/#define RGB2PIXEL332(r,g,b) \ (((r) & 0xe0) | (((g) & 0xe0) >> 3) | (((b) & 0xc0) >> 6))/* create 8 bit 2/3/3 format pixel from RBG triplet*/#define RGB2PIXEL233(r,g,b) \ ((((r) & 0xe0) >> 5) | (((g) & 0xe0) >> 2) | (((b) & 0xc0) >> 0))/* * Conversion from MWCOLORVAL to MWPIXELVAL *//* create 24 bit 8/8/8 format pixel from RGB colorval (0x00BBGGRR)*/#define COLOR2PIXEL888(c) \ ((((c) & 0xff) << 16) | ((c) & 0xff00) | (((c) & 0xff0000) >> 16))/* create 16 bit 5/6/5 format pixel from RGB colorval (0x00BBGGRR)*/#define COLOR2PIXEL565(c) \ ((((c) & 0xf8) << 8) | (((c) & 0xfc00) >> 5) | (((c) & 0xf80000) >> 19))/* create 16 bit 5/5/5 format pixel from RGB colorval (0x00BBGGRR)*/#ifdef CYGBLD_MICROWINDOWS_VNC_DRIVERS /* Real RGB555 data is required for VNC drivers */#define COLOR2PIXEL555(c) \ ((((c) & 0xf8) << 7) | (((c) & 0xf800) >> 6) | (((c) & 0xf80000) >> 19))#else /* BGR555 data is required strongarm LCD */#define COLOR2PIXEL555(c) \ ((((c) & 0xf8) >> (3-0)) | (((c) & 0xf800) >> (11-5)) | (((c) & 0xf80000) >> (19-10)))#endif/* create 8 bit 3/3/2 format pixel from RGB colorval (0x00BBGGRR)*/#define COLOR2PIXEL332(c) \ ((((c) & 0xe0) >> 5) | (((c) & 0xe000) >> 9) | (((c) & 0xc00000) >> 16))/* create 8 bit 2/3/3 format pixel from RGB colorval (0x00BBGGRR)*/#define COLOR2PIXEL233(c) \ ((((c) & 0xC00000) >> 16) | (((c) & 0x00E000) >> 10) | (((c) & 0xE0) >> 5))/* * Conversion from MWPIXELVAL to red, green or blue components *//* return 8/8/8 bit r, g or b component of 24 bit pixelval*/#define PIXEL888RED(pixelval) (((pixelval) >> 16) & 0xff)#define PIXEL888GREEN(pixelval) (((pixelval) >> 8) & 0xff)#define PIXEL888BLUE(pixelval) ((pixelval) & 0xff)/* return 5/6/5 bit r, g or b component of 16 bit pixelval*/#define PIXEL565RED(pixelval) (((pixelval) >> 11) & 0x1f)#define PIXEL565GREEN(pixelval) (((pixelval) >> 5) & 0x3f)#define PIXEL565BLUE(pixelval) ((pixelval) & 0x1f)/* return 5/5/5 bit r, g or b component of 16 bit pixelval*/#define PIXEL555RED(pixelval) (((pixelval) >> 10) & 0x1f)#define PIXEL555GREEN(pixelval) (((pixelval) >> 5) & 0x1f)#define PIXEL555BLUE(pixelval) ((pixelval) & 0x1f)/* return 3/3/2 bit r, g or b component of 8 bit pixelval*/#define PIXEL332RED(pixelval) (((pixelval) >> 5) & 0x07)#define PIXEL332GREEN(pixelval) (((pixelval) >> 2) & 0x07)#define PIXEL332BLUE(pixelval) ((pixelval) & 0x03)/* return 2/3/3 bit b, g, r component of 8 bit pixelval*/#define PIXEL233RED(pixelval) ((pixelval) & 0x07)#define PIXEL233GREEN(pixelval) (((pixelval) >> 3) & 0x07)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -