/tags/SN-NG4/tix/win/tixWCmpt.c

https://gitlab.com/OpenSourceMirror/sourcenav · C · 184 lines · 96 code · 20 blank · 68 comment · 8 complexity · 8e177460af51d9bf28ef711881581eeb MD5 · raw file

  1. /*
  2. * tixWCmpt.c --
  3. *
  4. * Windows compatibility module: implements missing functions in Windows.
  5. */
  6. #include <tkWinInt.h>
  7. #include <tixPort.h>
  8. #include <tixInt.h>
  9. #ifndef strcasecmp
  10. int strcasecmp(char * a, char *b)
  11. {
  12. while (1) {
  13. if (*a== 0 && *b==0) {
  14. return 0;
  15. }
  16. if (*a==0) {
  17. return (1);
  18. }
  19. if (*b==0) {
  20. return (-1);
  21. }
  22. if (tolower(*a)>tolower(*b)) {
  23. return (-1);
  24. }
  25. if (tolower(*b)>tolower(*a)) {
  26. return (1);
  27. }
  28. a++; b++;
  29. }
  30. }
  31. #endif
  32. /*
  33. *----------------------------------------------------------------------
  34. *
  35. * XLowerWindow --
  36. *
  37. * Change the stacking order of a window.
  38. *
  39. * Results:
  40. * None.
  41. *
  42. * Side effects:
  43. * Changes the stacking order of the specified window.
  44. *
  45. *----------------------------------------------------------------------
  46. */
  47. void
  48. XLowerWindow(display, w)
  49. Display* display;
  50. Window w;
  51. {
  52. HWND window = TkWinGetHWND(w);
  53. display->request++;
  54. SetWindowPos(window, HWND_TOPMOST, 0, 0, 0, 0,
  55. SWP_NOMOVE | SWP_NOSIZE);
  56. }
  57. #if 1
  58. void XDrawPoints(display, d, gc, points, npoints, mode)
  59. Display* display;
  60. Drawable d;
  61. GC gc;
  62. XPoint* points;
  63. int npoints;
  64. int mode;
  65. {
  66. int i;
  67. for (i=0; i<npoints; i++) {
  68. XDrawLine(display, d, gc, points[i].x, points[i].y,
  69. points[i].x, points[i].y);
  70. }
  71. }
  72. #endif
  73. #if 1
  74. /*
  75. * The following declaration is for the VC++ DLL entry point.
  76. */
  77. BOOL APIENTRY DllMain _ANSI_ARGS_((HINSTANCE hInst,
  78. DWORD reason, LPVOID reserved));
  79. /* CYGNUS LOCAL */
  80. #ifdef __CYGWIN32__
  81. /* cygwin32 requires an impure pointer variable, which must be
  82. explicitly initialized when the DLL starts up. */
  83. struct _reent *_impure_ptr;
  84. extern struct _reent *_imp__reent_data;
  85. #endif
  86. /* END CYGNUS LOCAL */
  87. /*
  88. *----------------------------------------------------------------------
  89. *
  90. * DllEntryPoint --
  91. *
  92. * This wrapper function is used by Borland to invoke the
  93. * initialization code for Tk. It simply calls the DllMain
  94. * routine.
  95. *
  96. * Results:
  97. * See DllMain.
  98. *
  99. * Side effects:
  100. * See DllMain.
  101. *
  102. *----------------------------------------------------------------------
  103. */
  104. BOOL APIENTRY
  105. DllEntryPoint(hInst, reason, reserved)
  106. HINSTANCE hInst; /* Library instance handle. */
  107. DWORD reason; /* Reason this function is being called. */
  108. LPVOID reserved; /* Not used. */
  109. {
  110. return DllMain(hInst, reason, reserved);
  111. }
  112. /*
  113. *----------------------------------------------------------------------
  114. *
  115. * DllMain --
  116. *
  117. * DLL entry point.
  118. *
  119. * Results:
  120. * TRUE on sucess, FALSE on failure.
  121. *
  122. * Side effects:
  123. * None.
  124. *
  125. *----------------------------------------------------------------------
  126. */
  127. BOOL APIENTRY
  128. DllMain(hInstance, reason, reserved)
  129. HINSTANCE hInstance;
  130. DWORD reason;
  131. LPVOID reserved;
  132. {
  133. /* CYGNUS LOCAL */
  134. #ifdef __CYGWIN32__
  135. /* cygwin32 requires the impure data pointer to be initialized
  136. when the DLL starts up. */
  137. _impure_ptr = _imp__reent_data;
  138. #endif
  139. /* END CYGNUS LOCAL */
  140. /*
  141. * If we are attaching to the DLL from a new process, tell Tk about
  142. * the hInstance to use. If we are detaching then clean up any
  143. * data structures related to this DLL.
  144. */
  145. return(TRUE);
  146. }
  147. #else
  148. #define DllExport __declspec( dllexport )
  149. DllExport
  150. DllEntryPoint(hInst, reason, reserved)
  151. HINSTANCE hInst; /* Library instance handle. */
  152. DWORD reason; /* Reason this function is being called. */
  153. LPVOID reserved; /* Not used. */
  154. {
  155. return TRUE;
  156. }
  157. #endif
  158. int TixPlatformInit(Tcl_Interp * interp)
  159. {
  160. return Tcl_GlobalEval(interp, "set tix(isWindows) 1");
  161. }