Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields   Related Pages  

nano-X.h

00001 #ifndef _NANO_X_H
00002 #define _NANO_X_H
00003 /* Copyright (c) 1999, 2000, 2001, 2002, 2003 Greg Haerr <greg@censoft.com>
00004  * Portions Copyright (c) 2002 by Koninklijke Philips Electronics N.V.
00005  * Copyright (c) 2000 Alex Holden <alex@linuxhacker.org>
00006  * Copyright (c) 1991 David I. Bell
00007  * Permission is granted to use, distribute, or modify this source,
00008  * provided that this copyright notice remains intact.
00009  *
00010  * Nano-X public definition header file:  user applications should
00011  * include only this header file.
00012  */
00013 #ifdef __cplusplus
00014 extern "C" {
00015 #endif
00016 
00017 #include "mwtypes.h"                    /* exported engine MW* types*/
00018 
00019 /*
00020  * The following typedefs are inherited from the Microwindows
00021  * engine layer.
00022  */
00023 typedef MWCOORD         GR_COORD;       /* coordinate value */
00024 typedef MWCOORD         GR_SIZE;        /* size value */
00025 typedef MWCOLORVAL      GR_COLOR;       /* full color value */
00026 typedef MWPIXELVAL      GR_PIXELVAL;    /* hw pixel value */
00027 typedef MWIMAGEBITS     GR_BITMAP;      /* bitmap unit */
00028 typedef MWUCHAR         GR_CHAR;        /* filename, window title */
00029 typedef MWTEXTFLAGS     GR_TEXTFLAGS;   /* text encoding flags */
00030 typedef MWKEY           GR_KEY;         /* keystroke value */
00031 typedef MWSCANCODE      GR_SCANCODE;    /* oem keystroke scancode value */
00032 typedef MWKEYMOD        GR_KEYMOD;      /* keystroke modifiers */
00033 typedef MWSCREENINFO    GR_SCREEN_INFO; /* screen information */
00034 typedef MWWINDOWFBINFO  GR_WINDOW_FB_INFO; /* direct client-mapped window info */
00035 typedef MWFONTINFO      GR_FONT_INFO;   /* font information */
00036 typedef MWIMAGEINFO     GR_IMAGE_INFO;  /* image information */
00037 typedef MWIMAGEHDR      GR_IMAGE_HDR;   /* multicolor image representation */
00038 typedef MWLOGFONT       GR_LOGFONT;     /* logical font descriptor */
00039 typedef MWPALENTRY      GR_PALENTRY;    /* palette entry */
00040 typedef MWPOINT         GR_POINT;       /* definition of a point */
00041 typedef MWTIMEOUT       GR_TIMEOUT;     /* timeout value */
00042 typedef MWFONTLIST      GR_FONTLIST;    /* list of fonts */
00043 typedef MWKBINFO        GR_KBINFO;      /* keyboard information  */
00044 typedef MWSTIPPLE       GR_STIPPLE;     /* Stipple information   */
00045 typedef MWTRANSFORM     GR_TRANSFORM;   /* Transform information */
00046 
00047 /* Basic typedefs. */
00048 typedef int             GR_COUNT;       /* number of items */
00049 typedef unsigned char   GR_CHAR_WIDTH;  /* width of character */
00050 typedef unsigned int    GR_ID;          /* resource ids */
00051 typedef GR_ID           GR_DRAW_ID;     /* drawable id */
00052 typedef GR_DRAW_ID      GR_WINDOW_ID;   /* window or pixmap id */
00053 typedef GR_ID           GR_GC_ID;       /* graphics context id */
00054 typedef GR_ID           GR_REGION_ID;   /* region id */
00055 typedef GR_ID           GR_FONT_ID;     /* font id */
00056 typedef GR_ID           GR_IMAGE_ID;    /* image id */
00057 typedef GR_ID           GR_TIMER_ID;    /* timer id */
00058 typedef GR_ID           GR_CURSOR_ID;   /* cursor id */
00059 typedef unsigned short  GR_BOOL;        /* boolean value */
00060 typedef int             GR_ERROR;       /* error types */
00061 typedef int             GR_EVENT_TYPE;  /* event types */
00062 typedef int             GR_UPDATE_TYPE; /* window update types */
00063 typedef unsigned long   GR_EVENT_MASK;  /* event masks */
00064 typedef char            GR_FUNC_NAME[25];/* function name */
00065 typedef unsigned long   GR_WM_PROPS;    /* window property flags */
00066 typedef unsigned long   GR_SERIALNO;    /* Selection request ID number */
00067 typedef unsigned short  GR_MIMETYPE;    /* Index into mime type list */
00068 typedef unsigned long   GR_LENGTH;      /* Length of a block of data */
00069 typedef unsigned int    GR_BUTTON;      /* mouse button value */
00070 
00071 /** Nano-X rectangle, different from MWRECT */
00072 typedef struct {
00073         GR_COORD x;             /**< upper left x coordinate*/
00074         GR_COORD y;             /**< upper left y coordinate*/
00075         GR_SIZE  width;         /**< rectangle width*/
00076         GR_SIZE  height;        /**< rectangle height*/
00077 } GR_RECT;
00078 
00079 /* The root window id. */
00080 #define GR_ROOT_WINDOW_ID       ((GR_WINDOW_ID) 1)
00081 
00082 /* GR_COLOR color constructor */
00083 #define GR_RGB(r,g,b)           MWRGB(r,g,b)
00084 #define GR_ARGB(a,r,g,b)        MWARGB(a,r,g,b)
00085 
00086 /* Drawing modes for GrSetGCMode */
00087 #define GR_MODE_COPY            MWMODE_COPY             /* src*/
00088 #define GR_MODE_SET             MWMODE_COPY             /* obsolete, use GR_MODE_COPY*/
00089 #define GR_MODE_XOR             MWMODE_XOR              /* src ^ dst*/
00090 #define GR_MODE_OR              MWMODE_OR               /* src | dst*/
00091 #define GR_MODE_AND             MWMODE_AND              /* src & dst*/
00092 #define GR_MODE_CLEAR           MWMODE_CLEAR            /* 0*/
00093 #define GR_MODE_SETTO1          MWMODE_SETTO1           /* 11111111*/ /* will be GR_MODE_SET*/
00094 #define GR_MODE_EQUIV           MWMODE_EQUIV            /* ~(src ^ dst)*/
00095 #define GR_MODE_NOR             MWMODE_NOR              /* ~(src | dst)*/
00096 #define GR_MODE_NAND            MWMODE_NAND             /* ~(src & dst)*/
00097 #define GR_MODE_INVERT          MWMODE_INVERT           /* ~dst*/
00098 #define GR_MODE_COPYINVERTED    MWMODE_COPYINVERTED     /* ~src*/
00099 #define GR_MODE_ORINVERTED      MWMODE_ORINVERTED       /* ~src | dst*/
00100 #define GR_MODE_ANDINVERTED     MWMODE_ANDINVERTED      /* ~src & dst*/
00101 #define GR_MODE_ORREVERSE       MWMODE_ORREVERSE        /* src | ~dst*/
00102 #define GR_MODE_ANDREVERSE      MWMODE_ANDREVERSE       /* src & ~dst*/
00103 #define GR_MODE_NOOP            MWMODE_NOOP             /* dst*/
00104 
00105 #define GR_MODE_DRAWMASK        0x00FF
00106 #define GR_MODE_EXCLUDECHILDREN 0x0100          /* exclude children on clip*/
00107 
00108 /* Line modes */
00109 #define GR_LINE_SOLID           MWLINE_SOLID
00110 #define GR_LINE_ONOFF_DASH      MWLINE_ONOFF_DASH
00111 
00112 #define GR_FILL_SOLID           MWFILL_SOLID
00113 #define GR_FILL_STIPPLE         MWFILL_STIPPLE
00114 #define GR_FILL_OPAQUE_STIPPLE  MWFILL_OPAQUE_STIPPLE
00115 #define GR_FILL_TILE            MWFILL_TILE
00116 
00117 /* Polygon regions*/
00118 #define GR_POLY_EVENODD         MWPOLY_EVENODD
00119 #define GR_POLY_WINDING         MWPOLY_WINDING
00120 
00121 /* builtin font std names*/
00122 #define GR_FONT_SYSTEM_VAR      MWFONT_SYSTEM_VAR
00123 #define GR_FONT_SYSTEM_FIXED    MWFONT_SYSTEM_FIXED
00124 #define GR_FONT_GUI_VAR         MWFONT_GUI_VAR          /* deprecated*/
00125 #define GR_FONT_OEM_FIXED       MWFONT_OEM_FIXED        /* deprecated*/
00126 
00127 /* GrText/GrGetTextSize encoding flags*/
00128 #define GR_TFASCII              MWTF_ASCII
00129 #define GR_TFUTF8               MWTF_UTF8
00130 #define GR_TFUC16               MWTF_UC16
00131 #define GR_TFUC32               MWTF_UC32
00132 #define GR_TFXCHAR2B            MWTF_XCHAR2B
00133 #define GR_TFPACKMASK           MWTF_PACKMASK
00134 
00135 /* GrText alignment flags*/
00136 #define GR_TFTOP                MWTF_TOP
00137 #define GR_TFBASELINE           MWTF_BASELINE
00138 #define GR_TFBOTTOM             MWTF_BOTTOM
00139 
00140 /* GrSetFontAttr flags*/
00141 #define GR_TFKERNING            MWTF_KERNING
00142 #define GR_TFANTIALIAS          MWTF_ANTIALIAS
00143 #define GR_TFUNDERLINE          MWTF_UNDERLINE
00144 
00145 /* GrArc, GrArcAngle types*/
00146 #define GR_ARC          MWARC           /* arc only*/
00147 #define GR_ARCOUTLINE   MWARCOUTLINE    /* arc + outline*/
00148 #define GR_PIE          MWPIE           /* pie (filled)*/
00149 
00150 /* GrSetWindowRegion types*/
00151 #define GR_WINDOW_BOUNDING_MASK 0       /* outer border*/
00152 #define GR_WINDOW_CLIP_MASK     1       /* inner border*/
00153 
00154 /* Booleans */
00155 #define GR_FALSE                0
00156 #define GR_TRUE                 1
00157 
00158 /* Loadable Image support definition */
00159 #define GR_IMAGE_MAX_SIZE       (-1)
00160 
00161 /* Button flags */
00162 #define GR_BUTTON_R             MWBUTTON_R      /* right button*/
00163 #define GR_BUTTON_M             MWBUTTON_M      /* middle button*/
00164 #define GR_BUTTON_L             MWBUTTON_L      /* left button */
00165 #define GR_BUTTON_ANY           (MWBUTTON_R|MWBUTTON_M|MWBUTTON_L) /* any*/
00166 
00167 /* GrSetBackgroundPixmap flags */
00168 #define GR_BACKGROUND_TILE      0       /* Tile across the window */
00169 #define GR_BACKGROUND_CENTER    1       /* Draw in center of window */
00170 #define GR_BACKGROUND_TOPLEFT   2       /* Draw at top left of window */
00171 #define GR_BACKGROUND_STRETCH   4       /* Stretch image to fit window*/
00172 #define GR_BACKGROUND_TRANS     8       /* Don't fill in gaps */
00173 
00174 /* GrNewPixmapFromData flags*/
00175 #define GR_BMDATA_BYTEREVERSE   01      /* byte-reverse bitmap data*/
00176 #define GR_BMDATA_BYTESWAP      02      /* byte-swap bitmap data*/
00177 
00178 #if 0 /* don't define unimp'd flags*/
00179 /* Window property flags */
00180 #define GR_WM_PROP_NORESIZE     0x04    /* don't let user resize window */
00181 #define GR_WM_PROP_NOICONISE    0x08    /* don't let user iconise window */
00182 #define GR_WM_PROP_NOWINMENU    0x10    /* don't display a window menu button */
00183 #define GR_WM_PROP_NOROLLUP     0x20    /* don't let user roll window up */
00184 #define GR_WM_PROP_ONTOP        0x200   /* try to keep window always on top */
00185 #define GR_WM_PROP_STICKY       0x400   /* keep window after desktop change */
00186 #define GR_WM_PROP_DND          0x2000  /* accept drag and drop icons */
00187 #endif
00188 
00189 /* Window properties*/
00190 #define GR_WM_PROPS_NOBACKGROUND 0x00000001L/* Don't draw window background*/
00191 #define GR_WM_PROPS_NOFOCUS      0x00000002L /* Don't set focus to this window*/
00192 #define GR_WM_PROPS_NOMOVE       0x00000004L /* Don't let user move window*/
00193 #define GR_WM_PROPS_NORAISE      0x00000008L /* Don't let user raise window*/
00194 #define GR_WM_PROPS_NODECORATE   0x00000010L /* Don't redecorate window*/
00195 #define GR_WM_PROPS_NOAUTOMOVE   0x00000020L /* Don't move window on 1st map*/
00196 #define GR_WM_PROPS_NOAUTORESIZE 0x00000040L /* Don't resize window on 1st map*/
00197 
00198 /* default decoration style*/
00199 #define GR_WM_PROPS_APPWINDOW   0x00000000L /* Leave appearance to WM*/
00200 #define GR_WM_PROPS_APPMASK     0xF0000000L /* Appearance mask*/
00201 #define GR_WM_PROPS_BORDER      0x80000000L /* Single line border*/
00202 #define GR_WM_PROPS_APPFRAME    0x40000000L /* 3D app frame (overrides border)*/
00203 #define GR_WM_PROPS_CAPTION     0x20000000L /* Title bar*/
00204 #define GR_WM_PROPS_CLOSEBOX    0x10000000L /* Close box*/
00205 #define GR_WM_PROPS_MAXIMIZE    0x08000000L /* Application is maximized*/
00206 
00207 /* Flags for indicating valid bits in GrSetWMProperties call*/
00208 #define GR_WM_FLAGS_PROPS       0x0001  /* Properties*/
00209 #define GR_WM_FLAGS_TITLE       0x0002  /* Title*/
00210 #define GR_WM_FLAGS_BACKGROUND  0x0004  /* Background color*/
00211 #define GR_WM_FLAGS_BORDERSIZE  0x0008  /* Border size*/
00212 #define GR_WM_FLAGS_BORDERCOLOR 0x0010  /* Border color*/
00213 
00214 /* NOTE: this struct must be hand-packed to a DWORD boundary for nxproto.h*/
00215 /**
00216  * Window manager properties used by the GrGetWMProperties()/GrSetWMProperties() calls.
00217  */
00218 typedef struct {
00219   GR_WM_PROPS flags;            /**< Which properties valid in struct for set*/
00220   GR_WM_PROPS props;            /**< Window property bits*/
00221   GR_CHAR *title;               /**< Window title*/
00222   GR_COLOR background;          /**< Window background color*/
00223   GR_SIZE bordersize;           /**< Window border size*/
00224   GR_COLOR bordercolor;         /**< Window border color*/
00225 } GR_WM_PROPERTIES;
00226 
00227 /**
00228  * Window properties returned by the GrGetWindowInfo() call.
00229  */
00230 typedef struct {
00231   GR_WINDOW_ID wid;             /**< window id (or 0 if no such window) */
00232   GR_WINDOW_ID parent;          /**< parent window id */
00233   GR_WINDOW_ID child;           /**< first child window id (or 0) */
00234   GR_WINDOW_ID sibling;         /**< next sibling window id (or 0) */
00235   GR_BOOL inputonly;            /**< TRUE if window is input only */
00236   GR_BOOL mapped;               /**< TRUE if window is mapped */
00237   GR_BOOL realized;             /**< TRUE if window is mapped and visible */
00238   GR_COORD x;                   /**< parent-relative x position of window */
00239   GR_COORD y;                   /**< parent-relative  y position of window */
00240   GR_SIZE width;                /**< width of window */
00241   GR_SIZE height;               /**< height of window */
00242   GR_SIZE bordersize;           /**< size of border */
00243   GR_COLOR bordercolor;         /**< color of border */
00244   GR_COLOR background;          /**< background color */
00245   GR_EVENT_MASK eventmask;      /**< current event mask for this client */
00246   GR_WM_PROPS props;            /**< window properties */
00247   GR_CURSOR_ID cursor;          /**< cursor id*/
00248   unsigned long processid;      /**< process id of owner*/
00249 } GR_WINDOW_INFO;
00250 
00251 /**
00252  * Graphics context properties returned by the GrGetGCInfo() call.
00253  */
00254 typedef struct {
00255   GR_GC_ID gcid;                /**< GC id (or 0 if no such GC) */
00256   int mode;                     /**< drawing mode */
00257   GR_REGION_ID region;          /**< user region */
00258   int xoff;                     /**< x offset of user region */
00259   int yoff;                     /**< y offset of user region */
00260   GR_FONT_ID font;              /**< font number */
00261   GR_COLOR foreground;          /**< foreground RGB color or pixel value */
00262   GR_COLOR background;          /**< background RGB color or pixel value */
00263   GR_BOOL fgispixelval;         /**< TRUE if 'foreground' is actually a GR_PIXELVAL */
00264   GR_BOOL bgispixelval;         /**< TRUE if 'background' is actually a GR_PIXELVAL */
00265   GR_BOOL usebackground;        /**< use background in bitmaps */
00266   GR_BOOL exposure;             /**< send exposure events on GrCopyArea */
00267 } GR_GC_INFO;
00268 
00269 /**
00270  * color palette
00271  */
00272 typedef struct {
00273   GR_COUNT count;               /**< # valid entries */
00274   GR_PALENTRY palette[256];     /**< palette */
00275 } GR_PALETTE;
00276 
00277 /** Calibration data passed to GrCalcTransform */
00278 typedef struct {
00279   int xres;                     /**< X resolution of the screen */
00280   int yres;                     /**< Y resolution of the screen */
00281   int minx;                     /**< min raw X value */
00282   int miny;                     /**< min raw Y values */
00283   int maxx;                     /**< max raw X value */
00284   int maxy;                     /**< max raw Y value */
00285   GR_BOOL xswap;                /**< true if the x component should be swapped */
00286   GR_BOOL yswap;                /**< true if the y component should be swapped */
00287 } GR_CAL_DATA;
00288 
00289 /* Error codes */
00290 #define GR_ERROR_BAD_WINDOW_ID          1
00291 #define GR_ERROR_BAD_GC_ID              2
00292 #define GR_ERROR_BAD_CURSOR_SIZE        3
00293 #define GR_ERROR_MALLOC_FAILED          4
00294 #define GR_ERROR_BAD_WINDOW_SIZE        5
00295 #define GR_ERROR_KEYBOARD_ERROR         6
00296 #define GR_ERROR_MOUSE_ERROR            7
00297 #define GR_ERROR_INPUT_ONLY_WINDOW      8
00298 #define GR_ERROR_ILLEGAL_ON_ROOT_WINDOW 9
00299 #define GR_ERROR_TOO_MUCH_CLIPPING      10
00300 #define GR_ERROR_SCREEN_ERROR           11
00301 #define GR_ERROR_UNMAPPED_FOCUS_WINDOW  12
00302 #define GR_ERROR_BAD_DRAWING_MODE       13
00303 #define GR_ERROR_BAD_LINE_ATTRIBUTE     14
00304 #define GR_ERROR_BAD_FILL_MODE          15
00305 #define GR_ERROR_BAD_REGION_ID          16
00306 
00307 /* Event types.
00308  * Mouse motion is generated for every motion of the mouse, and is used to
00309  * track the entire history of the mouse (many events and lots of overhead).
00310  * Mouse position ignores the history of the motion, and only reports the
00311  * latest position of the mouse by only queuing the latest such event for
00312  * any single client (good for rubber-banding).
00313  */
00314 #define GR_EVENT_TYPE_ERROR             (-1)
00315 #define GR_EVENT_TYPE_NONE              0
00316 #define GR_EVENT_TYPE_EXPOSURE          1
00317 #define GR_EVENT_TYPE_BUTTON_DOWN       2
00318 #define GR_EVENT_TYPE_BUTTON_UP         3
00319 #define GR_EVENT_TYPE_MOUSE_ENTER       4
00320 #define GR_EVENT_TYPE_MOUSE_EXIT        5
00321 #define GR_EVENT_TYPE_MOUSE_MOTION      6
00322 #define GR_EVENT_TYPE_MOUSE_POSITION    7
00323 #define GR_EVENT_TYPE_KEY_DOWN          8
00324 #define GR_EVENT_TYPE_KEY_UP            9
00325 #define GR_EVENT_TYPE_FOCUS_IN          10
00326 #define GR_EVENT_TYPE_FOCUS_OUT         11
00327 #define GR_EVENT_TYPE_FDINPUT           12
00328 #define GR_EVENT_TYPE_UPDATE            13
00329 #define GR_EVENT_TYPE_CHLD_UPDATE       14
00330 #define GR_EVENT_TYPE_CLOSE_REQ         15
00331 #define GR_EVENT_TYPE_TIMEOUT           16
00332 #define GR_EVENT_TYPE_SCREENSAVER       17
00333 #define GR_EVENT_TYPE_CLIENT_DATA_REQ   18
00334 #define GR_EVENT_TYPE_CLIENT_DATA       19
00335 #define GR_EVENT_TYPE_SELECTION_CHANGED 20
00336 #define GR_EVENT_TYPE_TIMER             21
00337 #define GR_EVENT_TYPE_PORTRAIT_CHANGED  22
00338 #define GR_EVENT_TYPE_HOTKEY_DOWN       23
00339 #define GR_EVENT_TYPE_HOTKEY_UP         24
00340 
00341 /* Event masks */
00342 #define GR_EVENTMASK(n)                 (((GR_EVENT_MASK) 1) << (n))
00343 
00344 #define GR_EVENT_MASK_NONE              GR_EVENTMASK(GR_EVENT_TYPE_NONE)
00345 #define GR_EVENT_MASK_ERROR             0x80000000L
00346 #define GR_EVENT_MASK_EXPOSURE          GR_EVENTMASK(GR_EVENT_TYPE_EXPOSURE)
00347 #define GR_EVENT_MASK_BUTTON_DOWN       GR_EVENTMASK(GR_EVENT_TYPE_BUTTON_DOWN)
00348 #define GR_EVENT_MASK_BUTTON_UP         GR_EVENTMASK(GR_EVENT_TYPE_BUTTON_UP)
00349 #define GR_EVENT_MASK_MOUSE_ENTER       GR_EVENTMASK(GR_EVENT_TYPE_MOUSE_ENTER)
00350 #define GR_EVENT_MASK_MOUSE_EXIT        GR_EVENTMASK(GR_EVENT_TYPE_MOUSE_EXIT)
00351 #define GR_EVENT_MASK_MOUSE_MOTION      GR_EVENTMASK(GR_EVENT_TYPE_MOUSE_MOTION)
00352 #define GR_EVENT_MASK_MOUSE_POSITION    GR_EVENTMASK(GR_EVENT_TYPE_MOUSE_POSITION)
00353 #define GR_EVENT_MASK_KEY_DOWN          GR_EVENTMASK(GR_EVENT_TYPE_KEY_DOWN)
00354 #define GR_EVENT_MASK_KEY_UP            GR_EVENTMASK(GR_EVENT_TYPE_KEY_UP)
00355 #define GR_EVENT_MASK_FOCUS_IN          GR_EVENTMASK(GR_EVENT_TYPE_FOCUS_IN)
00356 #define GR_EVENT_MASK_FOCUS_OUT         GR_EVENTMASK(GR_EVENT_TYPE_FOCUS_OUT)
00357 #define GR_EVENT_MASK_FDINPUT           GR_EVENTMASK(GR_EVENT_TYPE_FDINPUT)
00358 #define GR_EVENT_MASK_UPDATE            GR_EVENTMASK(GR_EVENT_TYPE_UPDATE)
00359 #define GR_EVENT_MASK_CHLD_UPDATE       GR_EVENTMASK(GR_EVENT_TYPE_CHLD_UPDATE)
00360 #define GR_EVENT_MASK_CLOSE_REQ         GR_EVENTMASK(GR_EVENT_TYPE_CLOSE_REQ)
00361 #define GR_EVENT_MASK_TIMEOUT           GR_EVENTMASK(GR_EVENT_TYPE_TIMEOUT)
00362 #define GR_EVENT_MASK_SCREENSAVER       GR_EVENTMASK(GR_EVENT_TYPE_SCREENSAVER)
00363 #define GR_EVENT_MASK_CLIENT_DATA_REQ   GR_EVENTMASK(GR_EVENT_TYPE_CLIENT_DATA_REQ)
00364 #define GR_EVENT_MASK_CLIENT_DATA       GR_EVENTMASK(GR_EVENT_TYPE_CLIENT_DATA)
00365 #define GR_EVENT_MASK_SELECTION_CHANGED GR_EVENTMASK(GR_EVENT_TYPE_SELECTION_CHANGED)
00366 #define GR_EVENT_MASK_TIMER             GR_EVENTMASK(GR_EVENT_TYPE_TIMER)
00367 #define GR_EVENT_MASK_PORTRAIT_CHANGED  GR_EVENTMASK(GR_EVENT_TYPE_PORTRAIT_CHANGED)
00368 /* Event mask does not affect GR_EVENT_TYPE_HOTKEY_DOWN and
00369  * GR_EVENT_TYPE_HOTKEY_UP, hence no masks for those events. */
00370 
00371 #define GR_EVENT_MASK_ALL               ((GR_EVENT_MASK) -1L)
00372 
00373 /* update event types */
00374 #define GR_UPDATE_MAP           1
00375 #define GR_UPDATE_UNMAP         2
00376 #define GR_UPDATE_MOVE          3
00377 #define GR_UPDATE_SIZE          4
00378 #define GR_UPDATE_UNMAPTEMP     5       /* unmap during window move/resize*/
00379 #define GR_UPDATE_ACTIVATE      6       /* toplevel window [de]activate*/
00380 #define GR_UPDATE_DESTROY       7
00381 #define GR_UPDATE_REPARENT      8
00382 
00383 /**
00384  * Event for errors detected by the server.
00385  * These events are not delivered to GrGetNextEvent, but instead call
00386  * the user supplied error handling function.  Only the first one of
00387  * these errors at a time is saved for delivery to the client since
00388  * there is not much to be done about errors anyway except complain
00389  * and exit.
00390  */
00391 typedef struct {
00392   GR_EVENT_TYPE type;           /**< event type */
00393   GR_FUNC_NAME name;            /**< function name which failed */
00394   GR_ERROR code;                /**< error code */
00395   GR_ID id;                     /**< resource id (maybe useless) */
00396 } GR_EVENT_ERROR;
00397 
00398 /**
00399  * Event for a mouse button pressed down or released.
00400  */
00401 typedef struct {
00402   GR_EVENT_TYPE type;           /**< event type */
00403   GR_WINDOW_ID wid;             /**< window id event delivered to */
00404   GR_WINDOW_ID subwid;          /**< sub-window id (pointer was in) */
00405   GR_COORD rootx;               /**< root window x coordinate */
00406   GR_COORD rooty;               /**< root window y coordinate */
00407   GR_COORD x;                   /**< window x coordinate of mouse */
00408   GR_COORD y;                   /**< window y coordinate of mouse */
00409   GR_BUTTON buttons;            /**< current state of all buttons */
00410   GR_BUTTON changebuttons;      /**< buttons which went down or up */
00411   GR_KEYMOD modifiers;          /**< modifiers (MWKMOD_SHIFT, etc)*/
00412   GR_TIMEOUT time;              /**< tickcount time value*/
00413 } GR_EVENT_BUTTON;
00414 
00415 /**
00416  * Event for a keystroke typed for the window with has focus.
00417  */
00418 typedef struct {
00419   GR_EVENT_TYPE type;           /**< event type */
00420   GR_WINDOW_ID wid;             /**< window id event delived to */
00421   GR_WINDOW_ID subwid;          /**< sub-window id (pointer was in) */
00422   GR_COORD rootx;               /**< root window x coordinate */
00423   GR_COORD rooty;               /**< root window y coordinate */
00424   GR_COORD x;                   /**< window x coordinate of mouse */
00425   GR_COORD y;                   /**< window y coordinate of mouse */
00426   GR_BUTTON buttons;            /**< current state of buttons */
00427   GR_KEYMOD modifiers;          /**< modifiers (MWKMOD_SHIFT, etc)*/
00428   GR_KEY ch;                    /**< 16-bit unicode key value, MWKEY_xxx */
00429   GR_SCANCODE scancode;         /**< OEM scancode value if available*/
00430   GR_BOOL hotkey;               /**< TRUE if generated from GrGrabKey(GR_GRAB_HOTKEY_x) */
00431 } GR_EVENT_KEYSTROKE;
00432 
00433 /**
00434  * Event for exposure for a region of a window.
00435  */
00436 typedef struct {
00437   GR_EVENT_TYPE type;           /**< event type */
00438   GR_WINDOW_ID wid;             /**< window id */
00439   GR_COORD x;                   /**< window x coordinate of exposure */
00440   GR_COORD y;                   /**< window y coordinate of exposure */
00441   GR_SIZE width;                /**< width of exposure */
00442   GR_SIZE height;               /**< height of exposure */
00443 } GR_EVENT_EXPOSURE;
00444 
00445 /**
00446  * General events for focus in or focus out for a window, or mouse enter
00447  * or mouse exit from a window, or window unmapping or mapping, etc.
00448  * Server portrait mode changes are also sent using this event to
00449  * all windows that request it.
00450  */
00451 typedef struct {
00452   GR_EVENT_TYPE type;           /**< event type */
00453   GR_WINDOW_ID wid;             /**< window id */
00454   GR_WINDOW_ID otherid;         /**< new/old focus id for focus events*/
00455 } GR_EVENT_GENERAL;
00456 
00457 /**
00458  * Events for mouse motion or mouse position.
00459  */
00460 typedef struct {
00461   GR_EVENT_TYPE type;           /**< event type */
00462   GR_WINDOW_ID wid;             /**< window id event delivered to */
00463   GR_WINDOW_ID subwid;          /**< sub-window id (pointer was in) */
00464   GR_COORD rootx;               /**< root window x coordinate */
00465   GR_COORD rooty;               /**< root window y coordinate */
00466   GR_COORD x;                   /**< window x coordinate of mouse */
00467   GR_COORD y;                   /**< window y coordinate of mouse */
00468   GR_BUTTON buttons;            /**< current state of buttons */
00469   GR_KEYMOD modifiers;          /**< modifiers (MWKMOD_SHIFT, etc)*/
00470 } GR_EVENT_MOUSE;
00471 
00472 /**
00473  * GrRegisterInput() event.
00474  */
00475 typedef struct {
00476   GR_EVENT_TYPE type;           /**< event type */
00477   int           fd;             /**< input file descriptor*/
00478 } GR_EVENT_FDINPUT;
00479 
00480 /**
00481  * GR_EVENT_TYPE_UPDATE
00482  */
00483 typedef struct {
00484   GR_EVENT_TYPE type;           /**< event type */
00485   GR_WINDOW_ID wid;             /**< select window id*/
00486   GR_WINDOW_ID subwid;          /**< update window id (=wid for UPDATE event)*/
00487   GR_COORD x;                   /**< new window x coordinate */
00488   GR_COORD y;                   /**< new window y coordinate */
00489   GR_SIZE width;                /**< new width */
00490   GR_SIZE height;               /**< new height */
00491   GR_UPDATE_TYPE utype;         /**< update_type */
00492 } GR_EVENT_UPDATE;
00493 
00494 /**
00495  * GR_EVENT_TYPE_SCREENSAVER
00496  */
00497 typedef struct {
00498   GR_EVENT_TYPE type;           /**< event type */
00499   GR_BOOL activate;             /**< true = activate, false = deactivate */
00500 } GR_EVENT_SCREENSAVER;
00501 
00502 /**
00503  * GR_EVENT_TYPE_CLIENT_DATA_REQ
00504  */
00505 typedef struct {
00506   GR_EVENT_TYPE type;           /**< event type */
00507   GR_WINDOW_ID wid;             /**< ID of requested window */
00508   GR_WINDOW_ID rid;             /**< ID of window to send data to */
00509   GR_SERIALNO serial;           /**< Serial number of transaction */
00510   GR_MIMETYPE mimetype;         /**< Type to supply data as */
00511 } GR_EVENT_CLIENT_DATA_REQ;
00512 
00513 /**
00514  * GR_EVENT_TYPE_CLIENT_DATA
00515  */
00516 typedef struct {
00517   GR_EVENT_TYPE type;           /**< event type */
00518   GR_WINDOW_ID wid;             /**< ID of window data is destined for */
00519   GR_WINDOW_ID rid;             /**< ID of window data is from */
00520   GR_SERIALNO serial;           /**< Serial number of transaction */
00521   unsigned long len;            /**< Total length of data */
00522   unsigned long datalen;        /**< Length of following data */
00523   void *data;                   /**< Pointer to data (filled in on client side) */
00524 } GR_EVENT_CLIENT_DATA;
00525 
00526 /**
00527  * GR_EVENT_TYPE_SELECTION_CHANGED
00528  */
00529 typedef struct {
00530   GR_EVENT_TYPE type;           /**< event type */
00531   GR_WINDOW_ID new_owner;       /**< ID of new selection owner */
00532 } GR_EVENT_SELECTION_CHANGED;
00533 
00534 /**
00535  * GR_EVENT_TYPE_TIMER
00536  */
00537 typedef struct {
00538   GR_EVENT_TYPE  type;          /**< event type, GR_EVENT_TYPE_TIMER */
00539   GR_WINDOW_ID   wid;           /**< ID of window timer is destined for */
00540   GR_TIMER_ID    tid;           /**< ID of expired timer */
00541 } GR_EVENT_TIMER;
00542 
00543 /**
00544  * Union of all possible event structures.
00545  * This is the structure returned by GrGetNextEvent() and similar routines.
00546  */
00547 typedef union {
00548   GR_EVENT_TYPE type;                   /**< event type */
00549   GR_EVENT_ERROR error;                 /**< error event */
00550   GR_EVENT_GENERAL general;             /**< general window events */
00551   GR_EVENT_BUTTON button;               /**< button events */
00552   GR_EVENT_KEYSTROKE keystroke;         /**< keystroke events */
00553   GR_EVENT_EXPOSURE exposure;           /**< exposure events */
00554   GR_EVENT_MOUSE mouse;                 /**< mouse motion events */
00555   GR_EVENT_FDINPUT fdinput;             /**< fd input events*/
00556   GR_EVENT_UPDATE update;               /**< window update events */
00557   GR_EVENT_SCREENSAVER screensaver;     /**< Screen saver events */
00558   GR_EVENT_CLIENT_DATA_REQ clientdatareq; /**< Request for client data events */
00559   GR_EVENT_CLIENT_DATA clientdata;        /**< Client data events */
00560   GR_EVENT_SELECTION_CHANGED selectionchanged; /**< Selection owner changed */
00561   GR_EVENT_TIMER timer;                 /**< Timer events */
00562 } GR_EVENT;
00563 
00564 typedef void (*GR_FNCALLBACKEVENT)(GR_EVENT *);
00565 
00566 /* GR_BITMAP macros*/
00567 /* size of GR_BITMAP image in words*/
00568 #define GR_BITMAP_SIZE(width, height)   MWIMAGE_SIZE(width, height)
00569 #define GR_BITMAPBITS                   MWIMAGE_BITSPERIMAGE
00570 #define GR_BITVALUE(n)                  MWIMAGE_BITVALUE(n)
00571 #define GR_FIRSTBIT                     MWIMAGE_FIRSTBIT
00572 #define GR_NEXTBIT(m)                   MWIMAGE_NEXTBIT(m)
00573 #define GR_TESTBIT(m)                   MWIMAGE_TESTBIT(m)
00574 #define GR_SHIFTBIT(m)                  MWIMAGE_SHIFTBIT(m)
00575 
00576 /* GrGrabKey() types. */
00577 
00578 /**
00579  * Key reservation type for GrGrabKey() - a key is reserved exclusively,
00580  * and hotkey events are sent regardless of focus.
00581  *
00582  * Hotkey events are sent to the client that reserved the key.  The window
00583  * ID passed to the GrGrabKey() call is passed as the source window.
00584  *
00585  * This type of reservation is useful for implementing a "main menu" key
00586  * or similar hotkeys.
00587  *
00588  * This can be used to implement the MHP method
00589  * org.dvb.event.EventManager.addUserEventListener(listener,client,events).
00590  *
00591  * @see GrGrabKey()
00592  * @see GrUngrabKey()
00593  */
00594 #define GR_GRAB_HOTKEY_EXCLUSIVE        0
00595 
00596 /**
00597  * Key reservation type for GrGrabKey() - hotkey events are sent when a key
00598  * is pressed, regardless of focus.  This is not an exclusive reservation,
00599  * so the app that has the focus will get a normal key event.
00600  *
00601  * Hotkey events are sent to the client that reserved the key.  The window
00602  * ID passed to the GrGrabKey() call is passed as the source window.
00603  *
00604  * Note that because this is not an exclusive grab, it does not stop
00605  * other applications from grabbing the same key (using #GR_GRAB_HOTKEY
00606  * or any other grab mode).  If an application has an exclusive grab on
00607  * a key, then any grabs of type #GR_GRAB_HOTKEY will be ignored when
00608  * dispatching that key event.
00609  *
00610  * This can be used to implement the MHP method
00611  * org.dvb.event.EventManager.addUserEventListener(listener,events).
00612  *
00613  * @see GrGrabKey()
00614  * @see GrUngrabKey()
00615  */
00616 #define GR_GRAB_HOTKEY                  1
00617 
00618 /**
00619  * Key reservation type for GrGrabKey() - a key is reserved exclusively,
00620  * and normal key events are sent if the specified window has focus.
00621  *
00622  * This stops other applications from getting events on the specified key.
00623  *
00624  * For example, an application could use this to reserve the number
00625  * keys before asking the user for a PIN, to prevent other applications
00626  * stealing the PIN using #GR_GRAB_TYPE_HOTKEY.  (Note that this assumes
00627  * the applications are running in a controlled environment, such as
00628  * Java, so they can only interact with the platform in limited ways).
00629  *
00630  * This can be used to implement the MHP method
00631  * org.dvb.event.EventManager.addExclusiveAccessToAWTEvent(client,events).
00632  *
00633  * @see GrGrabKey()
00634  * @see GrUngrabKey()
00635  */
00636 #define GR_GRAB_EXCLUSIVE               2
00637 
00638 /**
00639  * Key reservation type for GrGrabKey() - a key is reserved exclusively,
00640  * and normal key events are sent if the specified window has focus,
00641  * or the mouse pointer is over the window.
00642  *
00643  * This stops other applications from getting events on the specified key.
00644  *
00645  * This is for compatibility with the first GrGrabKey() API, which only
00646  * supported this kind of reservation.
00647  *
00648  * @see GrGrabKey()
00649  * @see GrUngrabKey()
00650  */
00651 #define GR_GRAB_EXCLUSIVE_MOUSE       3
00652 
00653 /**
00654  * Highest legal value of any GR_GRAB_xxx constant.  (Lowest legal value 
00655  * must be 0).
00656  *
00657  * @internal
00658  */
00659 #define GR_GRAB_MAX                     GR_GRAB_EXCLUSIVE_MOUSE
00660 
00661 /* GrGetSysColor colors*/
00662 /* desktop background*/
00663 #define GR_COLOR_DESKTOP           0
00664 
00665 /* caption colors*/
00666 #define GR_COLOR_ACTIVECAPTION     1
00667 #define GR_COLOR_ACTIVECAPTIONTEXT 2
00668 #define GR_COLOR_INACTIVECAPTION   3
00669 #define GR_COLOR_INACTIVECAPTIONTEXT 4
00670 
00671 /* 3d border shades*/
00672 #define GR_COLOR_WINDOWFRAME       5
00673 #define GR_COLOR_BTNSHADOW         6
00674 #define GR_COLOR_3DLIGHT           7
00675 #define GR_COLOR_BTNHIGHLIGHT      8
00676 
00677 /* top level application window backgrounds/text*/
00678 #define GR_COLOR_APPWINDOW         9
00679 #define GR_COLOR_APPTEXT           10
00680 
00681 /* button control backgrounds/text (usually same as app window colors)*/
00682 #define GR_COLOR_BTNFACE           11
00683 #define GR_COLOR_BTNTEXT           12
00684 
00685 /* edit/listbox control backgrounds/text, selected highlights*/
00686 #define GR_COLOR_WINDOW            13
00687 #define GR_COLOR_WINDOWTEXT        14
00688 #define GR_COLOR_HIGHLIGHT         15
00689 #define GR_COLOR_HIGHLIGHTTEXT     16
00690 #define GR_COLOR_GRAYTEXT          17
00691 
00692 /* menu backgrounds/text*/
00693 #define GR_COLOR_MENUTEXT          18
00694 #define GR_COLOR_MENU              19
00695 
00696 /**
00697  * Error strings per error number
00698  */
00699 #define GR_ERROR_STRINGS                \
00700         "",                             \
00701         "Bad window id: %d\n",          \
00702         "Bad graphics context: %d\n",   \
00703         "Bad cursor size\n",            \
00704         "Out of server memory\n",       \
00705         "Bad window size: %d\n",        \
00706         "Keyboard error\n",             \
00707         "Mouse error\n",                \
00708         "Input only window: %d\n",      \
00709         "Illegal on root window: %d\n", \
00710         "Clipping overflow\n",          \
00711         "Screen error\n",               \
00712         "Unmapped focus window: %d\n",  \
00713         "Bad drawing mode gc: %d\n",    \
00714         "Bad line attribute gc: %d\n",  \
00715         "Bad fill mode gc: %d\n",       \
00716         "Bad region id: %d\n",
00717         
00718 extern char *nxErrorStrings[];
00719 
00720 /* Public graphics routines. */
00721 void            GrFlush(void);
00722 int             GrOpen(void);
00723 void            GrClose(void);
00724 void            GrDelay(GR_TIMEOUT msecs);
00725 void            GrGetScreenInfo(GR_SCREEN_INFO *sip);
00726 GR_COLOR        GrGetSysColor(int index);
00727 GR_WINDOW_ID    GrNewWindow(GR_WINDOW_ID parent, GR_COORD x, GR_COORD y,
00728                         GR_SIZE width, GR_SIZE height, GR_SIZE bordersize,
00729                         GR_COLOR background, GR_COLOR bordercolor);
00730 GR_WINDOW_ID    GrNewPixmap(GR_SIZE width, GR_SIZE height, void *pixels);
00731 GR_WINDOW_ID    GrNewInputWindow(GR_WINDOW_ID parent, GR_COORD x, GR_COORD y,
00732                                 GR_SIZE width, GR_SIZE height);
00733 void            GrDestroyWindow(GR_WINDOW_ID wid);
00734 GR_GC_ID        GrNewGC(void);
00735 GR_GC_ID        GrCopyGC(GR_GC_ID gc);
00736 void            GrGetGCInfo(GR_GC_ID gc, GR_GC_INFO *gcip);
00737 void            GrDestroyGC(GR_GC_ID gc);
00738 GR_REGION_ID    GrNewRegion(void);
00739 GR_REGION_ID    GrNewBitmapRegion(GR_BITMAP *bitmap, GR_SIZE width,
00740                         GR_SIZE height);
00741 GR_REGION_ID    GrNewPolygonRegion(int mode, GR_COUNT count, GR_POINT *points);
00742 void            GrDestroyRegion(GR_REGION_ID region);
00743 void            GrUnionRectWithRegion(GR_REGION_ID region, GR_RECT *rect);
00744 void            GrUnionRegion(GR_REGION_ID dst_rgn, GR_REGION_ID src_rgn1,
00745                         GR_REGION_ID src_rgn2);
00746 void            GrIntersectRegion(GR_REGION_ID dst_rgn, GR_REGION_ID src_rgn1,
00747                         GR_REGION_ID src_rgn2);
00748 void            GrSubtractRegion(GR_REGION_ID dst_rgn, GR_REGION_ID src_rgn1,
00749                         GR_REGION_ID src_rgn2);
00750 void            GrXorRegion(GR_REGION_ID dst_rgn, GR_REGION_ID src_rgn1,
00751                         GR_REGION_ID src_rgn2);
00752 void            GrSetGCRegion(GR_GC_ID gc, GR_REGION_ID region);
00753 void            GrSetGCClipOrigin(GR_GC_ID gc, int x, int y);
00754 GR_BOOL         GrPointInRegion(GR_REGION_ID region, GR_COORD x, GR_COORD y);
00755 int             GrRectInRegion(GR_REGION_ID region, GR_COORD x, GR_COORD y,
00756                         GR_COORD w, GR_COORD h);
00757 GR_BOOL         GrEmptyRegion(GR_REGION_ID region);
00758 GR_BOOL         GrEqualRegion(GR_REGION_ID rgn1, GR_REGION_ID rgn2);
00759 void            GrOffsetRegion(GR_REGION_ID region, GR_SIZE dx, GR_SIZE dy);
00760 int             GrGetRegionBox(GR_REGION_ID region, GR_RECT *rect);
00761 void            GrMapWindow(GR_WINDOW_ID wid);
00762 void            GrUnmapWindow(GR_WINDOW_ID wid);
00763 void            GrRaiseWindow(GR_WINDOW_ID wid);
00764 void            GrLowerWindow(GR_WINDOW_ID wid);
00765 void            GrMoveWindow(GR_WINDOW_ID wid, GR_COORD x, GR_COORD y);
00766 void            GrResizeWindow(GR_WINDOW_ID wid, GR_SIZE width, GR_SIZE height);
00767 void            GrReparentWindow(GR_WINDOW_ID wid, GR_WINDOW_ID pwid,
00768                         GR_COORD x, GR_COORD y);
00769 void            GrGetWindowInfo(GR_WINDOW_ID wid, GR_WINDOW_INFO *infoptr);
00770 void            GrSetWMProperties(GR_WINDOW_ID wid, GR_WM_PROPERTIES *props);
00771 void            GrGetWMProperties(GR_WINDOW_ID wid, GR_WM_PROPERTIES *props);
00772 GR_FONT_ID      GrCreateFont(GR_CHAR *name, GR_COORD height,
00773                         GR_LOGFONT *plogfont);
00774 GR_FONT_ID      GrCreateFontFromBuffer(const void *buffer, unsigned length,
00775                         const char *format, GR_COORD height);
00776 GR_FONT_ID      GrCopyFont(GR_FONT_ID fontid, GR_COORD height);
00777 void            GrGetFontList(GR_FONTLIST ***fonts, int *numfonts);
00778 void            GrFreeFontList(GR_FONTLIST ***fonts, int numfonts);
00779 void            GrSetFontSize(GR_FONT_ID fontid, GR_COORD size);
00780 void            GrSetFontRotation(GR_FONT_ID fontid, int tenthsdegrees);
00781 void            GrSetFontAttr(GR_FONT_ID fontid, int setflags, int clrflags);
00782 void            GrDestroyFont(GR_FONT_ID fontid);
00783 void            GrGetFontInfo(GR_FONT_ID font, GR_FONT_INFO *fip);
00784 GR_WINDOW_ID    GrGetFocus(void);
00785 void            GrSetFocus(GR_WINDOW_ID wid);
00786 void            GrClearArea(GR_WINDOW_ID wid, GR_COORD x, GR_COORD y,
00787                         GR_SIZE width, GR_SIZE height, GR_BOOL exposeflag);
00788 void            GrSelectEvents(GR_WINDOW_ID wid, GR_EVENT_MASK eventmask);
00789 void            GrGetNextEvent(GR_EVENT *ep);
00790 int             GrGetTypedEvent(GR_WINDOW_ID wid, GR_EVENT_MASK mask, 
00791                         GR_UPDATE_TYPE update, GR_EVENT *ep, GR_BOOL block);
00792 typedef GR_BOOL (*GR_TYPED_EVENT_CALLBACK)(GR_WINDOW_ID, GR_EVENT_MASK,
00793                         GR_UPDATE_TYPE, GR_EVENT *, void *);
00794 int             GrGetTypedEventPred(GR_WINDOW_ID wid, GR_EVENT_MASK mask, 
00795                         GR_UPDATE_TYPE update, GR_EVENT * ep, GR_BOOL block, 
00796                         GR_TYPED_EVENT_CALLBACK matchfn, void *arg);
00797 void            GrGetNextEventTimeout(GR_EVENT *ep, GR_TIMEOUT timeout);
00798 void            GrCheckNextEvent(GR_EVENT *ep);
00799 int             GrPeekEvent(GR_EVENT *ep);
00800 void            GrPeekWaitEvent(GR_EVENT *ep);
00801 void            GrLine(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x1, GR_COORD y1,
00802                         GR_COORD x2, GR_COORD y2);
00803 void            GrPoint(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y);
00804 void            GrPoints(GR_DRAW_ID id, GR_GC_ID gc, GR_COUNT count,
00805                         GR_POINT *pointtable);
00806 void            GrRect(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
00807                         GR_SIZE width, GR_SIZE height);
00808 void            GrFillRect(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
00809                         GR_SIZE width, GR_SIZE height);
00810 void            GrPoly(GR_DRAW_ID id, GR_GC_ID gc, GR_COUNT count,
00811                         GR_POINT *pointtable);
00812 void            GrFillPoly(GR_DRAW_ID id, GR_GC_ID gc, GR_COUNT count,
00813                         GR_POINT *pointtable);
00814 void            GrEllipse(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
00815                         GR_SIZE rx, GR_SIZE ry);
00816 void            GrFillEllipse(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x,
00817                         GR_COORD y, GR_SIZE rx, GR_SIZE ry);
00818 void            GrArc(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
00819                         GR_SIZE rx, GR_SIZE ry, GR_COORD ax, GR_COORD ay,
00820                         GR_COORD bx, GR_COORD by, int type);
00821 void            GrArcAngle(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
00822                         GR_SIZE rx, GR_SIZE ry, GR_COORD angle1,
00823                         GR_COORD angle2, int type); /* floating point required*/
00824 void            GrSetGCForeground(GR_GC_ID gc, GR_COLOR foreground);
00825 void            GrSetGCForegroundPixelVal(GR_GC_ID gc, GR_PIXELVAL foreground);
00826 void            GrSetGCBackground(GR_GC_ID gc, GR_COLOR background);
00827 void            GrSetGCBackgroundPixelVal(GR_GC_ID gc, GR_PIXELVAL background);
00828 void            GrSetGCUseBackground(GR_GC_ID gc, GR_BOOL flag);
00829 void            GrSetGCMode(GR_GC_ID gc, int mode);
00830 
00831 void            GrSetGCLineAttributes(GR_GC_ID, int);
00832 void            GrSetGCDash(GR_GC_ID, char *, int);
00833 void            GrSetGCFillMode(GR_GC_ID, int);
00834 void            GrSetGCStipple(GR_GC_ID, GR_BITMAP *, GR_SIZE, GR_SIZE);
00835 void            GrSetGCTile(GR_GC_ID, GR_WINDOW_ID, GR_SIZE, GR_SIZE);
00836 void            GrSetGCTSOffset(GR_GC_ID, GR_COORD, GR_COORD);
00837 
00838 void            GrSetGCGraphicsExposure(GR_GC_ID gc, GR_BOOL exposure);
00839 void            GrSetGCFont(GR_GC_ID gc, GR_FONT_ID font);
00840 void            GrGetGCTextSize(GR_GC_ID gc, void *str, int count,
00841                         GR_TEXTFLAGS flags, GR_SIZE *retwidth,
00842                         GR_SIZE *retheight,GR_SIZE *retbase);
00843 void            GrReadArea(GR_DRAW_ID id, GR_COORD x, GR_COORD y, GR_SIZE width,
00844                         GR_SIZE height, GR_PIXELVAL *pixels);
00845 void            GrArea(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
00846                         GR_SIZE width,GR_SIZE height,void *pixels,int pixtype);
00847 void            GrCopyArea(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
00848                         GR_SIZE width, GR_SIZE height, GR_DRAW_ID srcid,
00849                         GR_COORD srcx, GR_COORD srcy, unsigned long op);
00850 void            GrStretchArea(GR_DRAW_ID dstid, GR_GC_ID gc, GR_COORD dx1,
00851                         GR_COORD dy1, GR_COORD dx2, GR_COORD dy2,
00852                         GR_DRAW_ID srcid, GR_COORD sx1, GR_COORD sy1,
00853                         GR_COORD sx2, GR_COORD sy2, unsigned long op);
00854 void            GrBitmap(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
00855                         GR_SIZE width, GR_SIZE height, GR_BITMAP *imagebits);
00856 void            GrDrawImageBits(GR_DRAW_ID id,GR_GC_ID gc,GR_COORD x,GR_COORD y,
00857                         GR_IMAGE_HDR *pimage);
00858 void            GrDrawImageFromFile(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x,
00859                         GR_COORD y, GR_SIZE width, GR_SIZE height,
00860                         char *path, int flags);
00861 GR_IMAGE_ID     GrLoadImageFromFile(char *path, int flags);
00862 void            GrDrawImageFromBuffer(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x,
00863                         GR_COORD y, GR_SIZE width, GR_SIZE height,
00864                         void *buffer, int size, int flags);
00865 GR_IMAGE_ID     GrLoadImageFromBuffer(void *buffer, int size, int flags);
00866 void            GrDrawImageToFit(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x,
00867                         GR_COORD y, GR_SIZE width, GR_SIZE height,
00868                         GR_IMAGE_ID imageid);
00869 void            GrFreeImage(GR_IMAGE_ID id);
00870 void            GrGetImageInfo(GR_IMAGE_ID id, GR_IMAGE_INFO *iip);
00871 void            GrText(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
00872                         void *str, GR_COUNT count, GR_TEXTFLAGS flags);
00873 GR_CURSOR_ID    GrNewCursor(GR_SIZE width, GR_SIZE height, GR_COORD hotx,
00874                         GR_COORD hoty, GR_COLOR foreground, GR_COLOR background,
00875                         GR_BITMAP *fgbitmap, GR_BITMAP *bgbitmap);
00876 void            GrDestroyCursor(GR_CURSOR_ID cid);
00877 void            GrSetWindowCursor(GR_WINDOW_ID wid, GR_CURSOR_ID cid);
00878 void            GrSetWindowRegion(GR_WINDOW_ID wid, GR_REGION_ID rid, int type);
00879 void            GrMoveCursor(GR_COORD x, GR_COORD y);
00880 void            GrGetSystemPalette(GR_PALETTE *pal);
00881 void            GrSetSystemPalette(GR_COUNT first, GR_PALETTE *pal);
00882 void            GrFindColor(GR_COLOR c, GR_PIXELVAL *retpixel);
00883 void            GrReqShmCmds(long shmsize);
00884 void            GrInjectPointerEvent(MWCOORD x, MWCOORD y,
00885                         int button, int visible);
00886 void            GrInjectKeyboardEvent(GR_WINDOW_ID wid, GR_KEY keyvalue,
00887                         GR_KEYMOD modifiers, GR_SCANCODE scancode,
00888                         GR_BOOL pressed);
00889 void            GrCloseWindow(GR_WINDOW_ID wid);
00890 void            GrKillWindow(GR_WINDOW_ID wid);
00891 void            GrSetScreenSaverTimeout(GR_TIMEOUT timeout);
00892 void            GrSetSelectionOwner(GR_WINDOW_ID wid, GR_CHAR *typelist);
00893 GR_WINDOW_ID    GrGetSelectionOwner(GR_CHAR **typelist);
00894 void            GrRequestClientData(GR_WINDOW_ID wid, GR_WINDOW_ID rid,
00895                         GR_SERIALNO serial, GR_MIMETYPE mimetype);
00896 void            GrSendClientData(GR_WINDOW_ID wid, GR_WINDOW_ID did,
00897                         GR_SERIALNO serial, GR_LENGTH len, GR_LENGTH thislen,
00898                         void *data);
00899 void            GrBell(void);
00900 void            GrSetBackgroundPixmap(GR_WINDOW_ID wid, GR_WINDOW_ID pixmap,
00901                         int flags);
00902 void            GrQueryPointer(GR_WINDOW_ID *mwin, GR_COORD *x, GR_COORD *y,
00903                         GR_BUTTON *bmask);
00904 void            GrQueryTree(GR_WINDOW_ID wid, GR_WINDOW_ID *parentid,
00905                         GR_WINDOW_ID **children, GR_COUNT *nchildren);
00906 GR_BOOL         GrGrabKey(GR_WINDOW_ID wid, GR_KEY key, int type);
00907 void            GrUngrabKey(GR_WINDOW_ID wid, GR_KEY key);
00908 
00909 GR_TIMER_ID     GrCreateTimer(GR_WINDOW_ID wid, GR_TIMEOUT period);
00910 void            GrDestroyTimer(GR_TIMER_ID tid);
00911 void            GrSetPortraitMode(int portraitmode);
00912 
00913 void            GrRegisterInput(int fd);
00914 void            GrUnregisterInput(int fd);
00915 void            GrMainLoop(GR_FNCALLBACKEVENT fncb);
00916 GR_FNCALLBACKEVENT GrSetErrorHandler(GR_FNCALLBACKEVENT fncb);
00917 void            GrDefaultErrorHandler(GR_EVENT *ep);
00918 
00919 /* passive library entry points - available with client/server only*/
00920 void            GrPrepareSelect(int *maxfd,void *rfdset);
00921 void            GrServiceSelect(void *rfdset, GR_FNCALLBACKEVENT fncb);
00922 
00923 /* Client side queue count - available only with client/server */
00924 int             GrQueueLength(void);
00925 
00926 void            GrSetTransform(GR_TRANSFORM *);
00927 
00928 /* nxtransform.c - mouse utility routines (requires floating point)*/
00929 int             GrCalcTransform(GR_CAL_DATA *, GR_TRANSFORM *);
00930 int             GrLoadTransformData(char *filename, GR_TRANSFORM *);
00931 int             GrSaveTransformData(GR_TRANSFORM *, char *filename);
00932 
00933 /* nxutil.c - utility routines*/
00934 GR_WINDOW_ID    GrNewWindowEx(GR_WM_PROPS props, GR_CHAR *title,
00935                         GR_WINDOW_ID parent, GR_COORD x, GR_COORD y,
00936                         GR_SIZE width, GR_SIZE height, GR_COLOR background);
00937 void            GrDrawLines(GR_DRAW_ID w, GR_GC_ID gc, GR_POINT *points,
00938                         GR_COUNT count);
00939 GR_BITMAP *     GrNewBitmapFromData(GR_SIZE width, GR_SIZE height, GR_SIZE bits_width,
00940                         GR_SIZE bits_height, void *bits, int flags);
00941 GR_WINDOW_ID    GrNewPixmapFromData(GR_SIZE width, GR_SIZE height, 
00942                         GR_COLOR foreground, GR_COLOR background, void * bits,
00943                         int flags);
00944 GR_BITMAP *     GrNewBitmapFromPixmap(GR_WINDOW_ID pixmap, int x, int y, GR_SIZE width,
00945                         GR_SIZE height);
00946 GR_BITMAP *     GrNewBitmapFromPixmap(GR_WINDOW_ID pixmap, int x, int y,
00947                         GR_SIZE width, GR_SIZE height);
00948 GR_REGION_ID    GrNewRegionFromPixmap(GR_WINDOW_ID src, MWCOORD x, MWCOORD y,
00949                         GR_SIZE width, GR_SIZE height);
00950 
00951 /* direct client-side framebuffer mapping routines*/
00952 unsigned char * GrOpenClientFramebuffer(void);
00953 void            GrCloseClientFramebuffer(void);
00954 void            GrGetWindowFBInfo(GR_WINDOW_ID wid, GR_WINDOW_FB_INFO *fbinfo);
00955 
00956 /* retrofit - no longer used*/
00957 GR_CURSOR_ID    GrSetCursor(GR_WINDOW_ID wid, GR_SIZE width, GR_SIZE height,
00958                         GR_COORD hotx, GR_COORD hoty, GR_COLOR foreground,
00959                         GR_COLOR background, GR_BITMAP *fbbitmap,
00960                         GR_BITMAP *bgbitmap);
00961 #define GrSetBorderColor                GrSetWindowBorderColor  /* retrofit*/
00962 #define GrClearWindow(wid,exposeflag)   GrClearArea(wid,0,0,0,0,exposeflag) /* retrofit*/
00963 
00964 /* useful function macros*/
00965 #define GrSetWindowBackgroundColor(wid,color) \
00966                 {       GR_WM_PROPERTIES props; \
00967                         props.flags = GR_WM_FLAGS_BACKGROUND; \
00968                         props.background = color; \
00969                         GrSetWMProperties(wid, &props); \
00970                 }
00971 #define GrSetWindowBorderSize(wid,width) \
00972                 {       GR_WM_PROPERTIES props; \
00973                         props.flags = GR_WM_FLAGS_BORDERSIZE; \
00974                         props.bordersize = width; \
00975                         GrSetWMProperties(wid, &props); \
00976                 }
00977 #define GrSetWindowBorderColor(wid,color) \
00978                 {       GR_WM_PROPERTIES props; \
00979                         props.flags = GR_WM_FLAGS_BORDERCOLOR; \
00980                         props.bordercolor = color; \
00981                         GrSetWMProperties(wid, &props); \
00982                 }
00983 #define GrSetWindowTitle(wid,name) \
00984                 {       GR_WM_PROPERTIES props; \
00985                         props.flags = GR_WM_FLAGS_TITLE; \
00986                         props.title = (GR_CHAR *)name; \
00987                         GrSetWMProperties(wid, &props); \
00988                 }
00989 
00990 #ifdef __cplusplus
00991 }
00992 #endif
00993 
00994 /* RTEMS requires rtems_main()*/
00995 #if __rtems__
00996 #define main    rtems_main
00997 #endif
00998 
00999 /* client side event queue (client.c local)*/
01000 typedef struct event_list EVENT_LIST;
01001 struct event_list {
01002         EVENT_LIST *    next;
01003         GR_EVENT        event;
01004 };
01005 
01006 /* queued request buffer (nxproto.c local)*/
01007 typedef struct {
01008         unsigned char *bufptr;          /* next unused buffer location*/
01009         unsigned char *bufmax;          /* max buffer location*/
01010         unsigned char *buffer;          /* request buffer*/
01011 } REQBUF;
01012 
01013 #ifdef __ECOS
01014 #include <sys/select.h>
01015 #include <cyg/kernel/kapi.h>
01016 /*
01017  * In a single process, multi-threaded environment, we need to keep
01018  * all static data of shared code in a structure, with a pointer to
01019  * the structure to be stored in thread-local storage
01020  */
01021 typedef struct {                                /* Init to: */
01022     int                 _nxSocket;              /*  -1 */
01023     MWMUTEX             _nxGlobalLock;
01024     int                 _storedevent;           /* 0 */
01025     GR_EVENT            _storedevent_data;      /* no init(0) */
01026     int                 _regfdmax;              /* -1 */
01027     fd_set              _regfdset;              /* FD_ZERO */
01028     GR_FNCALLBACKEVENT  _GrErrorFunc;           /* GrDefaultErrorHandler */
01029     REQBUF              _reqbuf;
01030     EVENT_LIST          *_evlist;
01031 } ecos_nanox_client_data;
01032 
01033 extern int     ecos_nanox_client_data_index;
01034 
01035 #define ACCESS_PER_THREAD_DATA()                                        \
01036     ecos_nanox_client_data *data = (ecos_nanox_client_data*)            \
01037         cyg_thread_get_data((cyg_ucount32)ecos_nanox_client_data_index);
01038 
01039 #define INIT_PER_THREAD_DATA()                                                  \
01040     {                                                                           \
01041         ecos_nanox_client_data *dptr = malloc(sizeof(ecos_nanox_client_data));  \
01042         ecos_nanox_client_data_index = data;                                    \
01043         dptr->_nxSocket = -1;                                                   \
01044         dptr->nxGlobalLock = 0;
01045         dptr->_storedevent = 0;                                                 \
01046         dptr->_regfdmax = -1;                                                   \
01047         FD_ZERO(&dptr->_regfdset);                                              \
01048         dptr->_GrErrorFunc = GrDefaultErrorHandler;                             \
01049         dptr->_reqbuf.bufptr = NULL;                                            \
01050         dptr->_reqbuf.bufmax = NULL;                                            \
01051         dptr->_reqbuf.buffer = NULL;                                            \
01052         dptr->_evlist = NULL;                                                   \
01053         cyg_thread_set_data(ecos_nanox_client_data_index,(CYG_ADDRWORD)dptr);   \
01054     }
01055 
01056 #define nxSocket                (data->_nxSocket)
01057 #define nxGlobalLock            (data->_nxGlobalLock)
01058 #define storedevent             (data->_storedevent)
01059 #define storedevent_data        (data->_storedevent_data)
01060 #define regfdmax                (data->_regfdmax)
01061 #define regfdset                (data->_regfdset)
01062 #define ErrorFunc               (data->_GrErrorFunc)
01063 #define reqbuf                  (data->_reqbuf)
01064 #define evlist                  (data->_evlist)
01065 
01066 #else
01067 #define ACCESS_PER_THREAD_DATA()
01068 #endif
01069 
01070 #endif /* _NANO_X_H*/

Generated on Sun May 18 21:03:06 2003 for Microwindows Nano-X API by doxygen1.3