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 14 #ifndef _TKWININT 15 #define _TKWININT 16 17 #ifndef _TKINT 18 #include "tkInt.h" 19 #endif 20 21 /* 22 * Include platform specific public interfaces. 23 */ 24 25 #ifndef _TKWIN 26 #include "tkWin.h" 27 #endif 28 29 /* 30 * Define constants missing from older Win32 SDK header files. 31 */ 32 33 #ifndef WS_EX_TOOLWINDOW 34 #define WS_EX_TOOLWINDOW 0x00000080L 35 #endif 36 #ifndef SPI_SETKEYBOARDCUES 37 #define SPI_SETKEYBOARDCUES 0x100B 38 #endif 39 40 /* 41 * The TkWinDCState is used to save the state of a device context so that it 42 * can be restored later. 43 */ 44 45 typedef struct TkWinDCState { 46 HPALETTE palette; 47 int bkmode; 48 } TkWinDCState; 49 50 /* 51 * The TkWinDrawable is the internal implementation of an X Drawable (either a 52 * Window or a Pixmap). The following constants define the valid Drawable 53 * types. 54 */ 55 56 #define TWD_BITMAP 1 57 #define TWD_WINDOW 2 58 #define TWD_WINDC 3 59 60 typedef struct { 61 int type; 62 HWND handle; 63 TkWindow *winPtr; 64 } TkWinWindow; 65 66 typedef struct { 67 int type; 68 HBITMAP handle; 69 Colormap colormap; 70 int depth; 71 } TkWinBitmap; 72 73 typedef struct { 74 int type; 75 HDC hdc; 76 }TkWinDC; 77 78 typedef union { 79 int type; 80 TkWinWindow window; 81 TkWinBitmap bitmap; 82 TkWinDC winDC; 83 } TkWinDrawable; 84 85 /* 86 * The following macros are used to retrieve internal values from a Drawable. 87 */ 88 89 #define TkWinGetHWND(w) (((TkWinDrawable *) w)->window.handle) 90 #define TkWinGetWinPtr(w) (((TkWinDrawable *) w)->window.winPtr) 91 #define TkWinGetHBITMAP(w) (((TkWinDrawable *) w)->bitmap.handle) 92 #define TkWinGetColormap(w) (((TkWinDrawable *) w)->bitmap.colormap) 93 #define TkWinGetHDC(w) (((TkWinDrawable *) w)->winDC.hdc) 94 95 /* 96 * The following structure is used to encapsulate palette information. 97 */ 98 99 typedef struct { 100 HPALETTE palette; /* Palette handle used when drawing. */ 101 UINT size; /* Number of entries in the palette. */ 102 int stale; /* 1 if palette needs to be realized, 103 * otherwise 0. If the palette is stale, then 104 * an idle handler is scheduled to realize the 105 * palette. */ 106 Tcl_HashTable refCounts; /* Hash table of palette entry reference 107 * counts indexed by pixel value. */ 108 } TkWinColormap; 109 110 /* 111 * The following macro retrieves the Win32 palette from a colormap. 112 */ 113 114 #define TkWinGetPalette(colormap) (((TkWinColormap *) colormap)->palette) 115 116 /* 117 * The following macros define the class names for Tk Window types. 118 */ 119 120 #define TK_WIN_TOPLEVEL_CLASS_NAME TEXT("TkTopLevel") 121 #define TK_WIN_CHILD_CLASS_NAME TEXT("TkChild") 122 123 /* 124 * The following variable is a translation table between X gc functions and 125 * Win32 raster and BitBlt op modes. 126 */ 127 128 MODULE_SCOPE const int tkpWinRopModes[]; 129 MODULE_SCOPE const int tkpWinBltModes[]; 130 131 /* 132 * The following defines are used with TkWinGetBorderPixels to get the extra 2 133 * border colors from a Tk_3DBorder. 134 */ 135 136 #define TK_3D_LIGHT2 TK_3D_DARK_GC+1 137 #define TK_3D_DARK2 TK_3D_DARK_GC+2 138 139 /* 140 * Internal functions used by more than one source file. 141 */ 142 143 #include "tkIntPlatDecls.h" 144 145 /* 146 * Special proc needed as tsd accessor function between 147 * tkWinX.c:GenerateXEvent and tkWinClipboard.c:UpdateClipboard 148 */ 149 150 MODULE_SCOPE void TkWinUpdatingClipboard(int mode); 151 152 /* 153 * Used by tkWinDialog.c to associate the right icon with tk_messageBox 154 */ 155 156 MODULE_SCOPE HICON TkWinGetIcon(Tk_Window tkw, DWORD iconsize); 157 158 /* 159 * Used by tkWinX.c on for certain system display change messages and cleanup 160 * up containers 161 */ 162 163 MODULE_SCOPE void TkWinDisplayChanged(Display *display); 164 MODULE_SCOPE void TkWinCleanupContainerList(void); 165 166 /* 167 * Used by tkWinWm.c for embedded menu handling. May become public. 168 */ 169 170 MODULE_SCOPE HWND Tk_GetMenuHWND(Tk_Window tkwin); 171 MODULE_SCOPE HWND Tk_GetEmbeddedMenuHWND(Tk_Window tkwin); 172 173 /* 174 * The following allows us to cache these encoding for multiple functions. 175 */ 176 177 178 MODULE_SCOPE Tcl_Encoding TkWinGetKeyInputEncoding(void); 179 MODULE_SCOPE Tcl_Encoding TkWinGetUnicodeEncoding(void); 180 MODULE_SCOPE void TkWinSetupSystemFonts(TkMainInfo *mainPtr); 181 182 /* 183 * Values returned by TkWinGetPlatformTheme. 184 */ 185 186 #define TK_THEME_WIN_CLASSIC 1 187 #define TK_THEME_WIN_XP 2 188 189 /* 190 * The following is implemented in tkWinWm and used by tkWinEmbed.c 191 */ 192 193 MODULE_SCOPE void TkpWinToplevelWithDraw(TkWindow *winPtr); 194 MODULE_SCOPE void TkpWinToplevelIconify(TkWindow *winPtr); 195 MODULE_SCOPE void TkpWinToplevelDeiconify(TkWindow *winPtr); 196 MODULE_SCOPE long TkpWinToplevelIsControlledByWm(TkWindow *winPtr); 197 MODULE_SCOPE long TkpWinToplevelMove(TkWindow *winPtr, int x, int y); 198 MODULE_SCOPE long TkpWinToplevelOverrideRedirect(TkWindow *winPtr, 199 int reqValue); 200 MODULE_SCOPE void TkpWinToplevelDetachWindow(TkWindow *winPtr); 201 MODULE_SCOPE int TkpWmGetState(TkWindow *winPtr); 202 203 /* 204 * The following functions are not present in old versions of Windows 205 * API headers but are used in the Tk source to ensure 64bit 206 * compatability. 207 */ 208 209 #ifndef GetClassLongPtr 210 # define GetClassLongPtrA GetClassLongA 211 # define GetClassLongPtrW GetClassLongW 212 # define SetClassLongPtrA SetClassLongA 213 # define SetClassLongPtrW SetClassLongW 214 # ifdef UNICODE 215 # define GetClassLongPtr GetClassLongPtrW 216 # define SetClassLongPtr SetClassLongPtrW 217 # else 218 # define GetClassLongPtr GetClassLongPtrA 219 # define SetClassLongPtr SetClassLongPtrA 220 # endif /* !UNICODE */ 221 #endif /* !GetClassLongPtr */ 222 #ifndef GCLP_HICON 223 # define GCLP_HICON GCL_HICON 224 #endif /* !GCLP_HICON */ 225 #ifndef GCLP_HICONSM 226 # define GCLP_HICONSM (-34) 227 #endif /* !GCLP_HICONSM */ 228 229 #ifndef GetWindowLongPtr 230 # define GetWindowLongPtrA GetWindowLongA 231 # define GetWindowLongPtrW GetWindowLongW 232 # define SetWindowLongPtrA SetWindowLongA 233 # define SetWindowLongPtrW SetWindowLongW 234 # ifdef UNICODE 235 # define GetWindowLongPtr GetWindowLongPtrW 236 # define SetWindowLongPtr SetWindowLongPtrW 237 # else 238 # define GetWindowLongPtr GetWindowLongPtrW 239 # define SetWindowLongPtr SetWindowLongPtrW 240 # endif /* !UNICODE */ 241 #endif /* !GetWindowLongPtr */ 242 #ifndef GWLP_WNDPROC 243 #define GWLP_WNDPROC GWL_WNDPROC 244 #define GWLP_HINSTANCE GWL_HINSTANCE 245 #define GWLP_HWNDPARENT GWL_HWNDPARENT 246 #define GWLP_USERDATA GWL_USERDATA 247 #define GWLP_ID GWL_ID 248 #endif /* !GWLP_WNDPROC */ 249 250 #endif /* _TKWININT */ 251