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