tkWinInt.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. /*
  2. * tkWinInt.h --
  3. *
  4. * This file contains declarations that are shared among the
  5. * Windows-specific parts of Tk, but aren't used by the rest of Tk.
  6. *
  7. * Copyright (c) 1995-1997 Sun Microsystems, Inc.
  8. * Copyright (c) 1998-2000 by Scriptics Corporation.
  9. *
  10. * See the file "license.terms" for information on usage and redistribution of
  11. * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  12. */
  13. #ifndef _TKWININT
  14. #define _TKWININT
  15. #ifndef _TKINT
  16. #include "tkInt.h"
  17. #endif
  18. /*
  19. * Include platform specific public interfaces.
  20. */
  21. #ifndef _TKWIN
  22. #include "tkWin.h"
  23. #endif
  24. /*
  25. * Define constants missing from older Win32 SDK header files.
  26. */
  27. #ifndef WS_EX_TOOLWINDOW
  28. #define WS_EX_TOOLWINDOW 0x00000080L
  29. #endif
  30. #ifndef SPI_SETKEYBOARDCUES
  31. #define SPI_SETKEYBOARDCUES 0x100B
  32. #endif
  33. /*
  34. * The TkWinDCState is used to save the state of a device context so that it
  35. * can be restored later.
  36. */
  37. typedef struct TkWinDCState {
  38. HPALETTE palette;
  39. int bkmode;
  40. } TkWinDCState;
  41. /*
  42. * The TkWinDrawable is the internal implementation of an X Drawable (either a
  43. * Window or a Pixmap). The following constants define the valid Drawable
  44. * types.
  45. */
  46. #define TWD_BITMAP 1
  47. #define TWD_WINDOW 2
  48. #define TWD_WINDC 3
  49. typedef struct {
  50. int type;
  51. HWND handle;
  52. TkWindow *winPtr;
  53. } TkWinWindow;
  54. typedef struct {
  55. int type;
  56. HBITMAP handle;
  57. Colormap colormap;
  58. int depth;
  59. } TkWinBitmap;
  60. typedef struct {
  61. int type;
  62. HDC hdc;
  63. }TkWinDC;
  64. typedef union {
  65. int type;
  66. TkWinWindow window;
  67. TkWinBitmap bitmap;
  68. TkWinDC winDC;
  69. } TkWinDrawable;
  70. /*
  71. * The following macros are used to retrieve internal values from a Drawable.
  72. */
  73. #define TkWinGetHWND(w) (((TkWinDrawable *) w)->window.handle)
  74. #define TkWinGetWinPtr(w) (((TkWinDrawable *) w)->window.winPtr)
  75. #define TkWinGetHBITMAP(w) (((TkWinDrawable *) w)->bitmap.handle)
  76. #define TkWinGetColormap(w) (((TkWinDrawable *) w)->bitmap.colormap)
  77. #define TkWinGetHDC(w) (((TkWinDrawable *) w)->winDC.hdc)
  78. /*
  79. * The following structure is used to encapsulate palette information.
  80. */
  81. typedef struct {
  82. HPALETTE palette; /* Palette handle used when drawing. */
  83. UINT size; /* Number of entries in the palette. */
  84. int stale; /* 1 if palette needs to be realized,
  85. * otherwise 0. If the palette is stale, then
  86. * an idle handler is scheduled to realize the
  87. * palette. */
  88. Tcl_HashTable refCounts; /* Hash table of palette entry reference
  89. * counts indexed by pixel value. */
  90. } TkWinColormap;
  91. /*
  92. * The following macro retrieves the Win32 palette from a colormap.
  93. */
  94. #define TkWinGetPalette(colormap) (((TkWinColormap *) colormap)->palette)
  95. /*
  96. * The following macros define the class names for Tk Window types.
  97. */
  98. #define TK_WIN_TOPLEVEL_CLASS_NAME L"TkTopLevel"
  99. #define TK_WIN_CHILD_CLASS_NAME L"TkChild"
  100. /*
  101. * The following variable is a translation table between X gc functions and
  102. * Win32 raster and BitBlt op modes.
  103. */
  104. MODULE_SCOPE const int tkpWinRopModes[];
  105. MODULE_SCOPE const int tkpWinBltModes[];
  106. /*
  107. * The following defines are used with TkWinGetBorderPixels to get the extra 2
  108. * border colors from a Tk_3DBorder.
  109. */
  110. #define TK_3D_LIGHT2 TK_3D_DARK_GC+1
  111. #define TK_3D_DARK2 TK_3D_DARK_GC+2
  112. /*
  113. * Internal functions used by more than one source file.
  114. */
  115. #include "tkIntPlatDecls.h"
  116. /*
  117. * Special proc needed as tsd accessor function between
  118. * tkWinX.c:GenerateXEvent and tkWinClipboard.c:UpdateClipboard
  119. */
  120. MODULE_SCOPE void TkWinUpdatingClipboard(int mode);
  121. /*
  122. * Used by tkWinDialog.c to associate the right icon with tk_messageBox
  123. */
  124. MODULE_SCOPE HICON TkWinGetIcon(Tk_Window tkw, DWORD iconsize);
  125. /*
  126. * Used by tkWinX.c on for certain system display change messages and cleanup
  127. * up containers
  128. */
  129. MODULE_SCOPE void TkWinDisplayChanged(Display *display);
  130. MODULE_SCOPE void TkWinCleanupContainerList(void);
  131. /*
  132. * Used by tkWinWm.c for embedded menu handling. May become public.
  133. */
  134. MODULE_SCOPE HWND Tk_GetMenuHWND(Tk_Window tkwin);
  135. MODULE_SCOPE HWND Tk_GetEmbeddedMenuHWND(Tk_Window tkwin);
  136. /*
  137. * The following allows us to cache these encoding for multiple functions.
  138. */
  139. MODULE_SCOPE Tcl_Encoding TkWinGetKeyInputEncoding(void);
  140. MODULE_SCOPE Tcl_Encoding TkWinGetUnicodeEncoding(void);
  141. MODULE_SCOPE void TkWinSetupSystemFonts(TkMainInfo *mainPtr);
  142. /*
  143. * Values returned by TkWinGetPlatformTheme.
  144. */
  145. #define TK_THEME_WIN_CLASSIC 1
  146. #define TK_THEME_WIN_XP 2
  147. #define TK_THEME_WIN_VISTA 3
  148. /*
  149. * The following is implemented in tkWinWm and used by tkWinEmbed.c
  150. */
  151. MODULE_SCOPE void TkpWinToplevelWithDraw(TkWindow *winPtr);
  152. MODULE_SCOPE void TkpWinToplevelIconify(TkWindow *winPtr);
  153. MODULE_SCOPE void TkpWinToplevelDeiconify(TkWindow *winPtr);
  154. MODULE_SCOPE long TkpWinToplevelIsControlledByWm(TkWindow *winPtr);
  155. MODULE_SCOPE long TkpWinToplevelMove(TkWindow *winPtr, int x, int y);
  156. MODULE_SCOPE long TkpWinToplevelOverrideRedirect(TkWindow *winPtr,
  157. int reqValue);
  158. MODULE_SCOPE void TkpWinToplevelDetachWindow(TkWindow *winPtr);
  159. MODULE_SCOPE int TkpWmGetState(TkWindow *winPtr);
  160. /*
  161. * The following is implemented in tkWinPointer.c and also used in tkWinWindow.c
  162. */
  163. MODULE_SCOPE void TkSetCursorPos(int x, int y);
  164. /*
  165. * Common routines used in Windows implementation
  166. */
  167. MODULE_SCOPE Tcl_Obj * TkWin32ErrorObj(HRESULT hrError);
  168. /*
  169. * The following functions are not present in old versions of Windows
  170. * API headers but are used in the Tk source to ensure 64bit
  171. * compatibility.
  172. */
  173. #ifndef GetClassLongPtr
  174. # define GetClassLongPtrW GetClassLongW
  175. # define SetClassLongPtrW SetClassLongW
  176. #endif /* !GetClassLongPtr */
  177. #ifndef GCLP_HICON
  178. # define GCLP_HICON GCL_HICON
  179. #endif /* !GCLP_HICON */
  180. #ifndef GCLP_HICONSM
  181. # define GCLP_HICONSM (-34)
  182. #endif /* !GCLP_HICONSM */
  183. #ifndef GetWindowLongPtr
  184. # define GetWindowLongPtrW GetWindowLongW
  185. # define SetWindowLongPtrW SetWindowLongW
  186. #endif /* !GetWindowLongPtr */
  187. #ifndef GWLP_WNDPROC
  188. #define GWLP_WNDPROC GWL_WNDPROC
  189. #define GWLP_HINSTANCE GWL_HINSTANCE
  190. #define GWLP_HWNDPARENT GWL_HWNDPARENT
  191. #define GWLP_USERDATA GWL_USERDATA
  192. #define GWLP_ID GWL_ID
  193. #endif /* !GWLP_WNDPROC */
  194. #endif /* _TKWININT */