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 6 * Tk. 7 * 8 * Copyright (c) 1995-1997 Sun Microsystems, Inc. 9 * Copyright (c) 1998-2000 by Scriptics Corporation. 10 * 11 * See the file "license.terms" for information on usage and redistribution 12 * of this file, and for a DISCLAIMER OF ALL WARRANTIES. 13 * 14 * RCS: @(#) $Id: tkWinInt.h,v 1.14.2.6 2007/12/05 19:18:08 hobbs Exp $ 15 */ 16 17#ifndef _TKWININT 18#define _TKWININT 19 20#ifndef _TKINT 21#include "tkInt.h" 22#endif 23 24/* 25 * Include platform specific public interfaces. 26 */ 27 28#ifndef _TKWIN 29#include "tkWin.h" 30#endif 31 32#ifndef _TKPORT 33#include "tkPort.h" 34#endif 35 36 37/* 38 * Define constants missing from older Win32 SDK header files. 39 */ 40 41#ifndef WS_EX_TOOLWINDOW 42#define WS_EX_TOOLWINDOW 0x00000080L 43#endif 44 45/* 46 * The TkWinDCState is used to save the state of a device context 47 * so that it can be restored later. 48 */ 49 50typedef struct TkWinDCState { 51 HPALETTE palette; 52 int bkmode; 53} TkWinDCState; 54 55/* 56 * The TkWinDrawable is the internal implementation of an X Drawable (either 57 * a Window or a Pixmap). The following constants define the valid Drawable 58 * types. 59 */ 60 61#define TWD_BITMAP 1 62#define TWD_WINDOW 2 63#define TWD_WINDC 3 64 65typedef struct { 66 int type; 67 HWND handle; 68 TkWindow *winPtr; 69} TkWinWindow; 70 71typedef struct { 72 int type; 73 HBITMAP handle; 74 Colormap colormap; 75 int depth; 76} TkWinBitmap; 77 78typedef struct { 79 int type; 80 HDC hdc; 81}TkWinDC; 82 83typedef union { 84 int type; 85 TkWinWindow window; 86 TkWinBitmap bitmap; 87 TkWinDC winDC; 88} TkWinDrawable; 89 90/* 91 * The following macros are used to retrieve internal values from a Drawable. 92 */ 93 94#define TkWinGetHWND(w) (((TkWinDrawable *) w)->window.handle) 95#define TkWinGetWinPtr(w) (((TkWinDrawable *) w)->window.winPtr) 96#define TkWinGetHBITMAP(w) (((TkWinDrawable *) w)->bitmap.handle) 97#define TkWinGetColormap(w) (((TkWinDrawable *) w)->bitmap.colormap) 98#define TkWinGetHDC(w) (((TkWinDrawable *) w)->winDC.hdc) 99 100/* 101 * The following structure is used to encapsulate palette information. 102 */ 103 104typedef struct { 105 HPALETTE palette; /* Palette handle used when drawing. */ 106 UINT size; /* Number of entries in the palette. */ 107 int stale; /* 1 if palette needs to be realized, 108 * otherwise 0. If the palette is stale, 109 * then an idle handler is scheduled to 110 * realize the palette. */ 111 Tcl_HashTable refCounts; /* Hash table of palette entry reference counts 112 * indexed by pixel value. */ 113} TkWinColormap; 114 115/* 116 * The following macro retrieves the Win32 palette from a colormap. 117 */ 118 119#define TkWinGetPalette(colormap) (((TkWinColormap *) colormap)->palette) 120 121/* 122 * The following macros define the class names for Tk Window types. 123 */ 124 125#define TK_WIN_TOPLEVEL_CLASS_NAME "TkTopLevel" 126#define TK_WIN_CHILD_CLASS_NAME "TkChild" 127 128/* 129 * The following variable is a translation table between X gc functions and 130 * Win32 raster and BitBlt op modes. 131 */ 132 133extern int tkpWinRopModes[]; 134extern int tkpWinBltModes[]; 135 136/* 137 * The following defines are used with TkWinGetBorderPixels to get the 138 * extra 2 border colors from a Tk_3DBorder. 139 */ 140 141#define TK_3D_LIGHT2 TK_3D_DARK_GC+1 142#define TK_3D_DARK2 TK_3D_DARK_GC+2 143 144/* 145 * Internal procedures used by more than one source file. 146 */ 147 148#include "tkIntPlatDecls.h" 149 150/* 151 * We need to specially add the TkWinChildProc because of the special 152 * prototype it has (doesn't fit into stubs schema) 153 */ 154#ifdef BUILD_tk 155#undef TCL_STORAGE_CLASS 156#define TCL_STORAGE_CLASS DLLEXPORT 157#endif 158 159EXTERN LRESULT CALLBACK TkWinChildProc _ANSI_ARGS_((HWND hwnd, UINT message, 160 WPARAM wParam, LPARAM lParam)); 161 162/* 163 * Special proc needed as tsd accessor function between 164 * tkWinX.c:GenerateXEvent and tkWinClipboard.c:UpdateClipboard 165 */ 166EXTERN void TkWinUpdatingClipboard(int mode); 167 168/* 169 * Used by tkWinDialog.c to associate the right icon with tk_messageBox 170 */ 171EXTERN HICON TkWinGetIcon(Tk_Window tkw, DWORD iconsize); 172 173/* 174 * Used by tkWinX.c on for certain system display change messages 175 */ 176EXTERN void TkWinDisplayChanged(Display *display); 177 178/* 179 * The following structure keeps track of whether we are using the 180 * multi-byte or the wide-character interfaces to the operating system. 181 * System calls should be made through the following function table. 182 * 183 * While some system calls need to use this A/W jump-table, it is not 184 * necessary for all calls to do it, which is why you won't see this 185 * used throughout the Tk code, but only in key areas. -- hobbs 186 */ 187 188typedef struct TkWinProcs { 189 int useWide; 190 LRESULT (WINAPI *callWindowProc)(WNDPROC lpPrevWndFunc, HWND hWnd, 191 UINT Msg, WPARAM wParam, LPARAM lParam); 192 LRESULT (WINAPI *defWindowProc)(HWND hWnd, UINT Msg, WPARAM wParam, 193 LPARAM lParam); 194 ATOM (WINAPI *registerClass)(CONST WNDCLASS *lpWndClass); 195 BOOL (WINAPI *setWindowText)(HWND hWnd, LPCTSTR lpString); 196 HWND (WINAPI *createWindowEx)(DWORD dwExStyle, LPCTSTR lpClassName, 197 LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, 198 int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, 199 HINSTANCE hInstance, LPVOID lpParam); 200 BOOL (WINAPI *insertMenu)(HMENU hMenu, UINT uPosition, UINT uFlags, 201 UINT uIDNewItem, LPCTSTR lpNewItem); 202} TkWinProcs; 203 204EXTERN TkWinProcs *tkWinProcs; 205 206#undef TCL_STORAGE_CLASS 207#define TCL_STORAGE_CLASS DLLIMPORT 208 209/* 210 * The following allows us to cache these encoding for multiple functions. 211 */ 212 213 214extern Tcl_Encoding TkWinGetKeyInputEncoding _ANSI_ARGS_((void)); 215extern Tcl_Encoding TkWinGetUnicodeEncoding _ANSI_ARGS_((void)); 216 217/* 218 * Values returned by TkWinGetPlatformTheme. 219 */ 220#define TK_THEME_WIN_CLASSIC 1 221#define TK_THEME_WIN_XP 2 222 223#endif /* _TKWININT */ 224 225