PageRenderTime 55ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/src/simx.h

#
C Header | 154 lines | 76 code | 25 blank | 53 comment | 4 complexity | 341c96fbb4f8ff90e1a113266e4bc60b MD5 | raw file
  1. /*
  2. * Copyright (C) 1989-95 GROUPE BULL
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to
  6. * deal in the Software without restriction, including without limitation the
  7. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. * sell copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  18. * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  19. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20. *
  21. * Except as contained in this notice, the name of GROUPE BULL shall not be
  22. * used in advertising or otherwise to promote the sale, use or other dealings
  23. * in this Software without prior written authorization from GROUPE BULL.
  24. */
  25. /*****************************************************************************\
  26. * simx.h: 0.1a *
  27. * *
  28. * This emulates some Xlib functionality for MSW. It's not a general solution, *
  29. * it is close related to XPM-lib. It is only intended to satisfy what is need *
  30. * there. Thus allowing to read XPM files under MS windows. *
  31. * *
  32. * Developed by HeDu 3/94 (hedu@cul-ipn.uni-kiel.de) *
  33. \*****************************************************************************/
  34. #ifndef _SIMX_H
  35. #define _SIMX_H
  36. #ifdef FOR_MSW
  37. #include "windows.h" /* MS windows GDI types */
  38. #define _XFUNCPROTOBEGIN
  39. #define _XFUNCPROTOEND
  40. #define NO_ZPIPE
  41. /*
  42. * minimal portability layer between ansi and KR C
  43. */
  44. /* this comes from xpm.h, and is here again, to avoid complicated
  45. includes, since this is included from xpm.h */
  46. /* these defines get undefed at the end of this file */
  47. #if __STDC__ || defined(__cplusplus) || defined(c_plusplus)
  48. /* ANSI || C++ */
  49. #define FUNC(f, t, p) extern t f p
  50. #define LFUNC(f, t, p) static t f p
  51. #else /* k&R */
  52. #define FUNC(f, t, p) extern t f()
  53. #define LFUNC(f, t, p) static t f()
  54. #endif
  55. FUNC(boundCheckingMalloc, void *, (long s));
  56. FUNC(boundCheckingCalloc, void *, (long num, long s));
  57. FUNC(boundCheckingRealloc, void *, (void *p, long s));
  58. /* define MSW types for X window types,
  59. I don't know much about MSW, but the following defines do the job */
  60. typedef HDC Display; /* this should be similar */
  61. typedef void *Screen; /* not used */
  62. typedef void *Visual; /* not used yet, is for GRAY, COLOR,
  63. * MONO */
  64. typedef void *Colormap; /* should be COLORPALETTE, not done
  65. * yet */
  66. typedef COLORREF Pixel;
  67. #define PIXEL_ALREADY_TYPEDEFED /* to let xpm.h know about it */
  68. typedef struct {
  69. Pixel pixel;
  70. BYTE red, green, blue;
  71. } XColor;
  72. typedef struct {
  73. HBITMAP bitmap;
  74. unsigned int width;
  75. unsigned int height;
  76. unsigned int depth;
  77. } XImage;
  78. #if defined(__cplusplus) || defined(c_plusplus)
  79. extern "C" {
  80. #endif
  81. /* some replacements for X... functions */
  82. /* XDefaultXXX */
  83. FUNC(XDefaultVisual, Visual *, (Display *display, Screen *screen));
  84. FUNC(XDefaultScreen, Screen *, (Display *d));
  85. FUNC(XDefaultColormap, Colormap *, (Display *display, Screen *screen));
  86. FUNC(XDefaultDepth, int, (Display *d, Screen *s));
  87. /* color related */
  88. FUNC(XParseColor, int, (Display *, Colormap *, char *, XColor *));
  89. FUNC(XAllocColor, int, (Display *, Colormap, XColor *));
  90. FUNC(XQueryColors, void, (Display *display, Colormap *colormap,
  91. XColor *xcolors, int ncolors));
  92. FUNC(XFreeColors, int, (Display *d, Colormap cmap,
  93. unsigned long pixels[],
  94. int npixels, unsigned long planes));
  95. /* XImage */
  96. FUNC(XCreateImage, XImage *, (Display *, Visual *, int depth, int format,
  97. int x, int y, int width, int height,
  98. int pad, int foo));
  99. /* free and destroy bitmap */
  100. FUNC(XDestroyImage, void /* ? */ , (XImage *));
  101. /* free only, bitmap remains */
  102. FUNC(XImageFree, void, (XImage *));
  103. #if defined(__cplusplus) || defined(c_plusplus)
  104. } /* end of extern "C" */
  105. #endif /* cplusplus */
  106. #define ZPixmap 1 /* not really used */
  107. #define XYBitmap 1 /* not really used */
  108. #ifndef True
  109. #define True 1
  110. #define False 0
  111. #endif
  112. #ifndef Bool
  113. typedef BOOL Bool; /* take MSW bool */
  114. #endif
  115. /* make these local here, simx.c gets the same from xpm.h */
  116. #undef LFUNC
  117. #undef FUNC
  118. /* Some functions and constants that have non-standard names in the
  119. MS library. */
  120. #define bzero(addr,sz) memset(addr, 0, sz)
  121. #define close _close
  122. #define fdopen _fdopen
  123. #define index strchr
  124. #define open _open
  125. #define O_RDONLY _O_RDONLY
  126. #define rindex strrchr
  127. #define strdup _strdup
  128. #endif /* def FOR_MSW */
  129. #endif /* _SIMX_H */