home *** CD-ROM | disk | FTP | other *** search
/ PC Shareware 1999 March / PCShareware-3-99.iso / IMPLE / DJGPP.RAR / DJGPP2 / XLIB-SR0.ZIP / SRC / XLIBEMU / XLIBEMU.H < prev    next >
C/C++ Source or Header  |  1994-02-18  |  7KB  |  308 lines

  1. /* $Id: xlibemu.h 1.4 1994/01/30 18:48:06 ulrich Exp ulrich $ */
  2. /*
  3.  * Xlibemu.h
  4.  *
  5.  * Internal header file for Xlibemu.
  6.  */
  7. #include "copying.h"
  8.  
  9. #ifndef _XLIB_EMU_H_
  10. #define _XLIB_EMU_H_
  11.  
  12. #include <grx.h>
  13. #include <mousex.h>
  14.  
  15. /* include Xproto.h before all others.
  16.  * X11 resources (Window, Pixmap, ...) are defined and undefined
  17.  * in this header file.
  18.  */
  19. #define NEED_EVENTS
  20. #include <X11/Xproto.h>
  21.  
  22. /* include X.h before Xlibint.h includes it */
  23. #include <X11/X.h>
  24.  
  25. /* shadow typedefs from X.h */
  26. typedef struct _WWindowRec *    _WWindowPtr;
  27. typedef struct _WPixmapRec *    _WPixmapPtr;
  28. typedef GrCursor *        _WCursorPtr;
  29. typedef GrFont *        _WFontPtr;
  30. typedef union _WDrawableRec *    _WDrawablePtr;
  31.  
  32. #define Window        _WWindowPtr
  33. #define Pixmap        _WPixmapPtr
  34. #define Cursor        _WCursorPtr
  35. #define Font        _WFontPtr
  36. #define Drawable    _WDrawablePtr
  37.  
  38. /*
  39.  * External structures
  40.  */
  41. #include <X11/Xlib.h>
  42. #include <X11/Xutil.h>
  43. #include "region.h"
  44. /*
  45.  * Internal structures
  46.  */
  47. typedef struct {
  48.   void (*fillBox) ();
  49.   long fillArg;
  50. } _WFillGC;
  51.  
  52. /* Supported keycodes */
  53. #define MIN_KEYCODE 8
  54. #define MAX_KEYCODE 114
  55. #define NUM_KEYCODES (MAX_KEYCODE - MIN_KEYCODE + 1)
  56.  
  57. /* Number of display connections */
  58. #define MAX_CONN 8
  59.  
  60. typedef struct _WPixmapRec {
  61.   int        type;
  62.   GrContext*    context;
  63.   GrPattern*    pattern;
  64.   unsigned int    width;
  65.   unsigned int    height;
  66.   char*        data;
  67. } _WPixmap;
  68.  
  69. typedef struct _WWindowRec {
  70.   int        type;        /* Drawable type */
  71.   GrContext    *context;
  72.   GrContext    *context_save;
  73.  
  74.   Window    parent;
  75.   Window    top_child;
  76.   Window    bottom_child;
  77.   Window    lower_sibling;
  78.   Window    upper_sibling;
  79.  
  80.   int        x;
  81.   int        y;
  82.   unsigned int    width;
  83.   unsigned int    height;
  84.   unsigned int    border_width;
  85.  
  86.   int        depth;
  87.   unsigned int    class;
  88.   Visual*    visual;
  89.  
  90.   Bool        mapped;
  91.   Bool        viewable;
  92.   int        visibility;
  93.  
  94.   int        win_gravity;
  95.   int        bit_gravity;
  96.  
  97.   unsigned long flags;
  98.   long        event_mask;
  99.   long        event_masks[MAX_CONN];
  100.   long        do_not_propagate_mask;
  101.  
  102.   _WFillGC    background;
  103.   _WFillGC    border;
  104.  
  105.   Cursor    cursor;
  106.  
  107.   int        backing_store;
  108.   unsigned long    backing_planes;
  109.   unsigned long    backing_pixel;
  110.  
  111.   Bool        save_under;
  112.   Bool        override_redirect;
  113.  
  114.   Colormap    colormap;
  115.  
  116.   BoxRec    window_port;
  117.   BoxRec    border_port;
  118.   Region    visible_region;
  119.  
  120.   XPointer    ext_addr;
  121.  
  122. } _WWindow;
  123.  
  124. typedef union _WDrawableRec {
  125.   int        type;    /* 0=GrBitmap,
  126.                1=GrPixmap,
  127.                2=_WWindow
  128.                3=_WPixmap */
  129.   _WWindow    window;
  130.   _WPixmap    pixmap;
  131. } _WDrawable;
  132.  
  133.  
  134. typedef struct _WCursorRec {
  135.   int        shape;
  136.   int        refcount;
  137.   GrCursor    *cursor;
  138. } _WCursor;
  139.  
  140. typedef struct _WGC {
  141.   struct _XGC xgc;
  142.  
  143.   /*
  144.    * Xlibemu extensions to the _XGC structure
  145.    * I hope none of the X application programmers
  146.    * ever used the _XGC structure.
  147.    */
  148.   void    (*Plot)();
  149.   void  (*Line)();
  150.   void  (*Box)();
  151.   void  (*Circle)();
  152.   void  (*Ellipse)();
  153.   void  (*CircleArc)();
  154.   void  (*EllipseArc)();
  155.   void  (*PolyLine)();
  156.   void  (*Polygon)();
  157.  
  158.   void  (*FilledBox)();
  159.   void  (*FilledCircle)();
  160.   void  (*FilledEllipse)();
  161.   void  (*FilledCircleArc)();
  162.   void  (*FilledEllipseArc)();
  163.   void  (*FilledPolygon)();
  164.  
  165.   long    line_arg;
  166.   long    fill_arg;
  167.   GrLineOption line_opt;
  168.   GrLinePattern line_pat;
  169.   int    dash_len;
  170.   char    *dash_list;
  171.  
  172. } *WGC;
  173.  
  174. typedef struct _WPointerGrabRec {
  175.   int        active;
  176.   Display*    display;
  177.   Window    grab_window;
  178.   long        event_mask;
  179.   int        owner_events;
  180.   int        pointer_mode;
  181.   int        keyboard_mode;
  182.   Window    confine_to;
  183.   Cursor    cursor;
  184.   Time        time;
  185.   int        pointer_x;
  186.   int        pointer_y;
  187. } _WPointerGrab;
  188.  
  189. typedef struct _WKeyboardGrabRec {
  190.   int        active;
  191.   Display*    display;
  192.   Window    grab_window;
  193.   long        event_mask;
  194.   int        owner_events;
  195.   int        pointer_mode;
  196.   int        keyboard_mode;
  197.   Time        time;
  198. } _WKeyboardGrab;
  199.  
  200. typedef struct _WInputFocusRec {
  201.   Window    window;
  202.   int        revert_to;
  203.   Time        time;
  204. } _WInputFocus;
  205.  
  206. typedef struct _WQueueEventRec {
  207.   int  flags;            /* flags (see eventque.h) */
  208.   int  x,y;            /* coordinates */
  209.   int  buttons;            /* button state */
  210.   int  key;            /* key code from keyboard */
  211.   int  scan;            /* scan code from keyboard */
  212.   int  kbstat;            /* keybd status (ALT, CTRL, etc..) */
  213.   long time;            /* time stamp of the event */
  214. } _WQueueEvent;
  215.  
  216. /* eventque.c */
  217. void _WQueueUnInit(void);
  218. void _WQueueInit(void);
  219. void _WMouseSetSpeed(int speed);
  220. void _WMouseSetAccel(int thresh,int accel);
  221. void _WMouseSetLimits(int x1,int y1,int x2,int y2);
  222. void _WMouseGetLimits(int *x1,int *y1,int *x2,int *y2);
  223. void _WMouseWarp(int x,int y);
  224. void _WMouseSetCursor(GrCursor *cursor);
  225. void _WMouseSetColors(int fg,int bg);
  226. void _WMouseDisplayCursor(void);
  227. void _WMouseEraseCursor(void);
  228. int  _WMouseBlock(GrContext *c,int x1,int y1,int x2,int y2);
  229. void _WMouseUnBlock(int flags);
  230. void _WMouseEventEnable(int enable_kb,int enable_ms);
  231. void _WQueueGetEvent(int flags,_WQueueEvent *e);
  232. int  _WQueuePendingEvent(void);
  233. void _WQueueQuery (_WQueueEvent *e);
  234.  
  235. /*
  236.  * Internal functions
  237.  */
  238. int    _WError (Display *dpy, XID resourceid, int error_code, int request_code);
  239. void    _WGetWindowPort (Window w, BoxPtr p);
  240. void    _WGetBorderPort (Window w, BoxPtr p);
  241. int    _WClipPortByParents (Window w, BoxPtr p);
  242. int    _WClipBorderByParents (Window w, BoxPtr p);
  243. void    _WProcessEvent (XEvent* event, long event_mask);
  244. void    _WSetViewable (Window w, Bool viewable);
  245. void    _WSetMapping (Window w, Bool mapped);
  246. void    _WMapSubwindows (Window parent);
  247. Window    _WPointToWindow (Display *dpy, int x, int y);
  248. Window    _WPointToWindowBorder (Display *dpy, int x, int y);
  249. void    _WNewWindowContext (Window w);
  250. void    _WGetWindowOrigin (Window w, int* x, int* y);
  251. void    _WMoveBorder (XEvent *event,
  252.               BoxPtr result, int border_width, int border_color);
  253. Cursor    _WGetWindowCursor (Window w);
  254. Window    _WMaskEventWindow (Window w, unsigned long mask);
  255.  
  256. unsigned int _WButtonAndModifierState (_WQueueEvent *ev);
  257. void    _WDefineCursor (Cursor new_cursor);
  258.  
  259. int    _WSetVisibleRegion (Window w);
  260. void    _WSetVisibleSubwindows (Window w);
  261. int    _WInvalidateParent (Window w);
  262.  
  263. void    _WDummyFilledBox ();
  264.  
  265. int    _WDrawContext (Drawable d, GC gc);
  266. int    _WDrawScreenContext (Drawable d);
  267. void    _WDrawRegion (void (*prim)(), long a, long b, long c, long d, long e);
  268. void    _WDrawWindowBorder (Display *dpy, Window w, BoxPtr r, Bool exposures);
  269. void    _WDrawWindowBackground (Display* dpy, Window w, BoxPtr r, Bool exposures);
  270. void    _WDrawWindow (Display *dpy, Window w, BoxPtr r, Bool exposures);
  271. void    _WDrawSubwindows (Display *dpy, Window w, BoxPtr r, Bool exposures);
  272. void    _WDrawSiblingsBelow (Display *display, Window w, Bool exposures);
  273. Time    _WCurrentTime ();
  274. Time    _WConvertTime (long event_time);
  275. Bool    _WIsInferior (Window a, Window b);
  276.  
  277. Bool    _WCheckWindow (Display *dpy, Window window, int request_code);
  278.  
  279. void    _XEnq (Display *dpy, XEvent *ev);
  280.  
  281. /* dispatch.c */
  282. Window    _WFindEventWindow (Display *dpy, Window w, long event_mask);
  283. int    _WPropagateEvent (XEvent *ev, Window pointer_window);
  284. void    _WDispatchEvent (XEvent *ev);
  285.  
  286. /* globals.c */
  287. extern _WPointerGrab    _PointerGrab;
  288. extern _WKeyboardGrab    _KeyboardGrab;
  289. extern _WInputFocus    _Focus;
  290. extern Cursor        _Cursor;
  291. extern BoxRec        _ClipBox;
  292. extern unsigned long    _EventSerial;
  293.  
  294. extern _WQueueEvent    _LastMouseEvent;
  295. extern Window        _LastMouseWindow;
  296. extern Window        _LastEnterWindow;
  297. extern Window        _LastLeaveWindow;
  298.  
  299. extern int        _Xdebug;
  300.  
  301. extern Display *_ConnTable[];
  302.  
  303. extern XKeyboardState    _KeyboardState;
  304.  
  305. #include "Xlibint.h"
  306.  
  307. #endif
  308.