summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
Diffstat (limited to 'win')
-rw-r--r--win/tkWin32Dll.c90
-rw-r--r--win/tkWin3d.c354
-rw-r--r--win/tkWinButton.c868
-rw-r--r--win/tkWinClipboard.c171
-rw-r--r--win/tkWinColor.c223
-rw-r--r--win/tkWinConfig.c32
-rw-r--r--win/tkWinCursor.c87
-rw-r--r--win/tkWinDialog.c77
-rw-r--r--win/tkWinDraw.c533
-rw-r--r--win/tkWinEmbed.c697
-rw-r--r--win/tkWinFont.c1127
-rw-r--r--win/tkWinImage.c367
-rw-r--r--win/tkWinInit.c54
-rw-r--r--win/tkWinInt.h97
-rw-r--r--win/tkWinKey.c393
-rw-r--r--win/tkWinPixmap.c78
-rw-r--r--win/tkWinPointer.c218
-rw-r--r--win/tkWinRegion.c107
-rw-r--r--win/tkWinScrlbr.c372
-rw-r--r--win/tkWinSend.c663
-rw-r--r--win/tkWinTest.c143
-rw-r--r--win/tkWinWindow.c299
-rw-r--r--win/tkWinWm.c3527
-rw-r--r--win/tkWinX.c1129
-rw-r--r--win/winMain.c118
25 files changed, 6165 insertions, 5659 deletions
diff --git a/win/tkWin32Dll.c b/win/tkWin32Dll.c
index ed869fc..3978f1c 100644
--- a/win/tkWin32Dll.c
+++ b/win/tkWin32Dll.c
@@ -1,20 +1,21 @@
-/*
+/*
* tkWin32Dll.c --
*
* This file contains a stub dll entry point.
*
* Copyright (c) 1995 Sun Microsystems, Inc.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWin32Dll.c,v 1.11 2005/08/23 18:31:11 mdejong Exp $
+ * RCS: @(#) $Id: tkWin32Dll.c,v 1.12 2005/12/02 00:19:04 dkf Exp $
*/
#include "tkWinInt.h"
#ifndef STATIC_BUILD
#ifdef HAVE_NO_SEH
+
/*
* Unlike Borland and Microsoft, we don't register exception handlers by
* pushing registration records onto the runtime stack. Instead, we register
@@ -30,23 +31,23 @@ typedef struct EXCEPTION_REGISTRATION {
int status;
} EXCEPTION_REGISTRATION;
-/* Need to add noinline flag to DllMain declaration so that gcc -O3
- * does not inline asm code into DllEntryPoint and cause a
- * compile time error because of redefined local labels.
+/*
+ * Need to add noinline flag to DllMain declaration so that gcc -O3 does not
+ * inline asm code into DllEntryPoint and cause a compile time error because
+ * of redefined local labels.
*/
-BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason,
- LPVOID reserved)
- __attribute__ ((noinline));
+BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason,
+ LPVOID reserved) __attribute__ ((noinline));
-#else
+#else /* !HAVE_NO_SEH */
/*
* The following declaration is for the VC++ DLL entry point.
*/
-BOOL APIENTRY DllMain _ANSI_ARGS_((HINSTANCE hInst,
- DWORD reason, LPVOID reserved));
+BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason,
+ LPVOID reserved);
#endif /* HAVE_NO_SEH */
/*
@@ -54,9 +55,8 @@ BOOL APIENTRY DllMain _ANSI_ARGS_((HINSTANCE hInst,
*
* DllEntryPoint --
*
- * This wrapper function is used by Borland to invoke the
- * initialization code for Tk. It simply calls the DllMain
- * routine.
+ * This wrapper function is used by Borland to invoke the initialization
+ * code for Tk. It simply calls the DllMain routine.
*
* Results:
* See DllMain.
@@ -68,10 +68,10 @@ BOOL APIENTRY DllMain _ANSI_ARGS_((HINSTANCE hInst,
*/
BOOL APIENTRY
-DllEntryPoint(hInst, reason, reserved)
- HINSTANCE hInst; /* Library instance handle. */
- DWORD reason; /* Reason this function is being called. */
- LPVOID reserved; /* Not used. */
+DllEntryPoint(
+ HINSTANCE hInst, /* Library instance handle. */
+ DWORD reason, /* Reason this function is being called. */
+ LPVOID reserved) /* Not used. */
{
return DllMain(hInst, reason, reserved);
}
@@ -81,35 +81,35 @@ DllEntryPoint(hInst, reason, reserved)
*
* DllMain --
*
- * DLL entry point. It is only necessary to specify our dll here so
- * that resources are found correctly. Otherwise Tk will initialize
- * and clean up after itself through other methods, in order to be
- * consistent whether the build is static or dynamic.
+ * DLL entry point. It is only necessary to specify our dll here so that
+ * resources are found correctly. Otherwise Tk will initialize and clean
+ * up after itself through other methods, in order to be consistent
+ * whether the build is static or dynamic.
*
* Results:
* Always TRUE.
*
* Side effects:
- * This might call some sycronization functions, but MSDN
- * documentation states: "Waiting on synchronization objects in
- * DllMain can cause a deadlock."
+ * This might call some sycronization functions, but MSDN documentation
+ * states: "Waiting on synchronization objects in DllMain can cause a
+ * deadlock."
*
*----------------------------------------------------------------------
*/
BOOL APIENTRY
-DllMain(hInstance, reason, reserved)
- HINSTANCE hInstance;
- DWORD reason;
- LPVOID reserved;
+DllMain(
+ HINSTANCE hInstance,
+ DWORD reason,
+ LPVOID reserved)
{
#ifdef HAVE_NO_SEH
EXCEPTION_REGISTRATION registration;
#endif
/*
- * If we are attaching to the DLL from a new process, tell Tk about
- * the hInstance to use.
+ * If we are attaching to the DLL from a new process, tell Tk about the
+ * hInstance to use.
*/
switch (reason) {
@@ -120,9 +120,8 @@ DllMain(hInstance, reason, reserved)
case DLL_PROCESS_DETACH:
/*
- * Protect the call to TkFinalize in an SEH block. We can't
- * be guarenteed Tk is always being unloaded from a stable
- * condition.
+ * Protect the call to TkFinalize in an SEH block. We can't be
+ * guarenteed Tk is always being unloaded from a stable condition.
*/
#ifdef HAVE_NO_SEH
@@ -175,7 +174,7 @@ DllMain(hInstance, reason, reserved)
"movl 0x8(%%edx), %%edx" "\n"
- /*
+ /*
* Come here however we exited. Restore context from the
* EXCEPTION_REGISTRATION in case the stack is unbalanced.
*/
@@ -199,10 +198,10 @@ DllMain(hInstance, reason, reserved)
#else /* HAVE_NO_SEH */
__try {
/*
- * Run and remove our exit handlers, if they haven't already
- * been run. Just in case we are being unloaded prior to
- * Tcl (it can happen), we won't leave any dangling pointers
- * hanging around for when Tcl gets unloaded later.
+ * Run and remove our exit handlers, if they haven't already been
+ * run. Just in case we are being unloaded prior to Tcl (it can
+ * happen), we won't leave any dangling pointers hanging around
+ * for when Tcl gets unloaded later.
*/
TkFinalize(NULL);
@@ -217,4 +216,11 @@ DllMain(hInstance, reason, reserved)
}
#endif /* !STATIC_BUILD */
-
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/win/tkWin3d.c b/win/tkWin3d.c
index 3c97560..8d1002b 100644
--- a/win/tkWin3d.c
+++ b/win/tkWin3d.c
@@ -1,31 +1,30 @@
-/*
+/*
* tkWin3d.c --
*
- * This file contains the platform specific routines for
- * drawing 3d borders in the Windows 95 style.
+ * This file contains the platform specific routines for drawing 3D
+ * borders in the Windows 95 style.
*
* Copyright (c) 1996 by Sun Microsystems, Inc.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWin3d.c,v 1.7 2004/01/13 02:06:01 davygrvy Exp $
+ * RCS: @(#) $Id: tkWin3d.c,v 1.8 2005/12/02 00:19:04 dkf Exp $
*/
#include "tkWinInt.h"
#include "tk3d.h"
/*
- * This structure is used to keep track of the extra colors used by
- * Windows 3d borders.
+ * This structure is used to keep track of the extra colors used by Windows 3D
+ * borders.
*/
typedef struct {
TkBorder info;
- XColor *light2ColorPtr; /* System3dLight */
- XColor *dark2ColorPtr; /* System3dDarkShadow */
+ XColor *light2ColorPtr; /* System3dLight */
+ XColor *dark2ColorPtr; /* System3dDarkShadow */
} WinBorder;
-
/*
*----------------------------------------------------------------------
@@ -44,9 +43,10 @@ typedef struct {
*/
TkBorder *
-TkpGetBorder()
+TkpGetBorder(void)
{
WinBorder *borderPtr = (WinBorder *) ckalloc(sizeof(WinBorder));
+
borderPtr->light2ColorPtr = NULL;
borderPtr->dark2ColorPtr = NULL;
return (TkBorder *) borderPtr;
@@ -57,8 +57,8 @@ TkpGetBorder()
*
* TkpFreeBorder --
*
- * This function frees any colors allocated by the platform
- * specific part of this module.
+ * This function frees any colors allocated by the platform specific part
+ * of this module.
*
* Results:
* None.
@@ -70,8 +70,8 @@ TkpGetBorder()
*/
void
-TkpFreeBorder(borderPtr)
- TkBorder *borderPtr;
+TkpFreeBorder(
+ TkBorder *borderPtr)
{
WinBorder *winBorderPtr = (WinBorder *) borderPtr;
if (winBorderPtr->light2ColorPtr) {
@@ -87,18 +87,17 @@ TkpFreeBorder(borderPtr)
*
* Tk_3DVerticalBevel --
*
- * This procedure draws a vertical bevel along one side of
- * an object. The bevel is always rectangular in shape:
+ * This procedure draws a vertical bevel along one side of an object. The
+ * bevel is always rectangular in shape:
* |||
* |||
* |||
* |||
* |||
* |||
- * An appropriate shadow color is chosen for the bevel based
- * on the leftBevel and relief arguments. Normally this
- * procedure is called first, then Tk_3DHorizontalBevel is
- * called next to draw neat corners.
+ * An appropriate shadow color is chosen for the bevel based on the
+ * leftBevel and relief arguments. Normally this procedure is called
+ * first, then Tk_3DHorizontalBevel is called next to draw neat corners.
*
* Results:
* None.
@@ -110,19 +109,18 @@ TkpFreeBorder(borderPtr)
*/
void
-Tk_3DVerticalBevel(tkwin, drawable, border, x, y, width, height,
- leftBevel, relief)
- Tk_Window tkwin; /* Window for which border was allocated. */
- Drawable drawable; /* X window or pixmap in which to draw. */
- Tk_3DBorder border; /* Token for border to draw. */
- int x, y, width, height; /* Area of vertical bevel. */
- int leftBevel; /* Non-zero means this bevel forms the
- * left side of the object; 0 means it
- * forms the right side. */
- int relief; /* Kind of bevel to draw. For example,
- * TK_RELIEF_RAISED means interior of
- * object should appear higher than
- * exterior. */
+Tk_3DVerticalBevel(
+ Tk_Window tkwin, /* Window for which border was allocated. */
+ Drawable drawable, /* X window or pixmap in which to draw. */
+ Tk_3DBorder border, /* Token for border to draw. */
+ int x, int y, int width, int height,
+ /* Area of vertical bevel. */
+ int leftBevel, /* Non-zero means this bevel forms the left
+ * side of the object; 0 means it forms the
+ * right side. */
+ int relief) /* Kind of bevel to draw. For example,
+ * TK_RELIEF_RAISED means interior of object
+ * should appear higher than exterior. */
{
TkBorder *borderPtr = (TkBorder *) border;
int left, right;
@@ -136,36 +134,36 @@ Tk_3DVerticalBevel(tkwin, drawable, border, x, y, width, height,
}
switch (relief) {
- case TK_RELIEF_RAISED:
- left = (leftBevel)
+ case TK_RELIEF_RAISED:
+ left = (leftBevel)
? borderPtr->lightGC->foreground
: borderPtr->darkGC->foreground;
- right = (leftBevel)
+ right = (leftBevel)
? ((WinBorder *)borderPtr)->light2ColorPtr->pixel
: ((WinBorder *)borderPtr)->dark2ColorPtr->pixel;
- break;
- case TK_RELIEF_SUNKEN:
- left = (leftBevel)
+ break;
+ case TK_RELIEF_SUNKEN:
+ left = (leftBevel)
? borderPtr->darkGC->foreground
: ((WinBorder *)borderPtr)->light2ColorPtr->pixel;
- right = (leftBevel)
+ right = (leftBevel)
? ((WinBorder *)borderPtr)->dark2ColorPtr->pixel
: borderPtr->lightGC->foreground;
- break;
- case TK_RELIEF_RIDGE:
- left = borderPtr->lightGC->foreground;
- right = borderPtr->darkGC->foreground;
- break;
- case TK_RELIEF_GROOVE:
- left = borderPtr->darkGC->foreground;
- right = borderPtr->lightGC->foreground;
- break;
- case TK_RELIEF_FLAT:
- left = right = borderPtr->bgGC->foreground;
- break;
- case TK_RELIEF_SOLID:
- left = right = RGB(0,0,0);
- break;
+ break;
+ case TK_RELIEF_RIDGE:
+ left = borderPtr->lightGC->foreground;
+ right = borderPtr->darkGC->foreground;
+ break;
+ case TK_RELIEF_GROOVE:
+ left = borderPtr->darkGC->foreground;
+ right = borderPtr->lightGC->foreground;
+ break;
+ case TK_RELIEF_FLAT:
+ left = right = borderPtr->bgGC->foreground;
+ break;
+ case TK_RELIEF_SOLID:
+ left = right = RGB(0,0,0);
+ break;
}
half = width/2;
if (leftBevel && (width & 1)) {
@@ -181,9 +179,9 @@ Tk_3DVerticalBevel(tkwin, drawable, border, x, y, width, height,
*
* Tk_3DHorizontalBevel --
*
- * This procedure draws a horizontal bevel along one side of
- * an object. The bevel has mitered corners (depending on
- * leftIn and rightIn arguments).
+ * This procedure draws a horizontal bevel along one side of an object.
+ * The bevel has mitered corners (depending on leftIn and rightIn
+ * arguments).
*
* Results:
* None.
@@ -195,30 +193,28 @@ Tk_3DVerticalBevel(tkwin, drawable, border, x, y, width, height,
*/
void
-Tk_3DHorizontalBevel(tkwin, drawable, border, x, y, width, height,
- leftIn, rightIn, topBevel, relief)
- Tk_Window tkwin; /* Window for which border was allocated. */
- Drawable drawable; /* X window or pixmap in which to draw. */
- Tk_3DBorder border; /* Token for border to draw. */
- int x, y, width, height; /* Bounding box of area of bevel. Height
- * gives width of border. */
- int leftIn, rightIn; /* Describes whether the left and right
- * edges of the bevel angle in or out as
- * they go down. For example, if "leftIn"
- * is true, the left side of the bevel
- * looks like this:
+Tk_3DHorizontalBevel(
+ Tk_Window tkwin, /* Window for which border was allocated. */
+ Drawable drawable, /* X window or pixmap in which to draw. */
+ Tk_3DBorder border, /* Token for border to draw. */
+ int x, int y, int width, int height,
+ /* Bounding box of area of bevel. Height gives
+ * width of border. */
+ int leftIn, int rightIn, /* Describes whether the left and right edges
+ * of the bevel angle in or out as they go
+ * down. For example, if "leftIn" is true, the
+ * left side of the bevel looks like this:
* ___________
* __________
* _________
* ________
*/
- int topBevel; /* Non-zero means this bevel forms the
- * top side of the object; 0 means it
- * forms the bottom side. */
- int relief; /* Kind of bevel to draw. For example,
- * TK_RELIEF_RAISED means interior of
- * object should appear higher than
- * exterior. */
+ int topBevel, /* Non-zero means this bevel forms the top
+ * side of the object; 0 means it forms the
+ * bottom side. */
+ int relief) /* Kind of bevel to draw. For example,
+ * TK_RELIEF_RAISED means interior of object
+ * should appear higher than exterior. */
{
TkBorder *borderPtr = (TkBorder *) border;
Display *display = Tk_Display(tkwin);
@@ -232,40 +228,40 @@ Tk_3DHorizontalBevel(tkwin, drawable, border, x, y, width, height,
}
/*
- * Compute a GC for the top half of the bevel and a GC for the
- * bottom half (they're the same in many cases).
+ * Compute a GC for the top half of the bevel and a GC for the bottom half
+ * (they're the same in many cases).
*/
switch (relief) {
- case TK_RELIEF_RAISED:
- topColor = (topBevel)
+ case TK_RELIEF_RAISED:
+ topColor = (topBevel)
? borderPtr->lightGC->foreground
: borderPtr->darkGC->foreground;
- bottomColor = (topBevel)
+ bottomColor = (topBevel)
? ((WinBorder *)borderPtr)->light2ColorPtr->pixel
: ((WinBorder *)borderPtr)->dark2ColorPtr->pixel;
- break;
- case TK_RELIEF_SUNKEN:
- topColor = (topBevel)
+ break;
+ case TK_RELIEF_SUNKEN:
+ topColor = (topBevel)
? borderPtr->darkGC->foreground
: ((WinBorder *)borderPtr)->light2ColorPtr->pixel;
- bottomColor = (topBevel)
+ bottomColor = (topBevel)
? ((WinBorder *)borderPtr)->dark2ColorPtr->pixel
: borderPtr->lightGC->foreground;
- break;
- case TK_RELIEF_RIDGE:
- topColor = borderPtr->lightGC->foreground;
- bottomColor = borderPtr->darkGC->foreground;
- break;
- case TK_RELIEF_GROOVE:
- topColor = borderPtr->darkGC->foreground;
- bottomColor = borderPtr->lightGC->foreground;
- break;
- case TK_RELIEF_FLAT:
- topColor = bottomColor = borderPtr->bgGC->foreground;
- break;
- case TK_RELIEF_SOLID:
- topColor = bottomColor = RGB(0,0,0);
+ break;
+ case TK_RELIEF_RIDGE:
+ topColor = borderPtr->lightGC->foreground;
+ bottomColor = borderPtr->darkGC->foreground;
+ break;
+ case TK_RELIEF_GROOVE:
+ topColor = borderPtr->darkGC->foreground;
+ bottomColor = borderPtr->lightGC->foreground;
+ break;
+ case TK_RELIEF_FLAT:
+ topColor = bottomColor = borderPtr->bgGC->foreground;
+ break;
+ case TK_RELIEF_SOLID:
+ topColor = bottomColor = RGB(0,0,0);
}
/*
@@ -298,8 +294,7 @@ Tk_3DHorizontalBevel(tkwin, drawable, border, x, y, width, height,
for ( ; y < bottom; y++) {
/*
* In some weird cases (such as large border widths for skinny
- * rectangles) x1 can be >= x2. Don't draw the lines
- * in these cases.
+ * rectangles) x1 can be >= x2. Don't draw the lines in these cases.
*/
if (x1 < x2) {
@@ -317,27 +312,26 @@ Tk_3DHorizontalBevel(tkwin, drawable, border, x, y, width, height,
*
* TkpGetShadows --
*
- * This procedure computes the shadow colors for a 3-D border
- * and fills in the corresponding fields of the Border structure.
- * It's called lazily, so that the colors aren't allocated until
- * something is actually drawn with them. That way, if a border
- * is only used for flat backgrounds the shadow colors will
- * never be allocated.
+ * This procedure computes the shadow colors for a 3-D border and fills
+ * in the corresponding fields of the Border structure. It's called
+ * lazily, so that the colors aren't allocated until something is
+ * actually drawn with them. That way, if a border is only used for flat
+ * backgrounds the shadow colors will never be allocated.
*
* Results:
* None.
*
* Side effects:
- * The lightGC and darkGC fields in borderPtr get filled in,
- * if they weren't already.
+ * The lightGC and darkGC fields in borderPtr get filled in, if they
+ * weren't already.
*
*----------------------------------------------------------------------
*/
void
-TkpGetShadows(borderPtr, tkwin)
- TkBorder *borderPtr; /* Information about border. */
- Tk_Window tkwin; /* Window where border will be used for
+TkpGetShadows(
+ TkBorder *borderPtr, /* Information about border. */
+ Tk_Window tkwin) /* Window where border will be used for
* drawing. */
{
XColor lightColor, darkColor;
@@ -354,13 +348,13 @@ TkpGetShadows(borderPtr, tkwin)
*/
if ((TkWinIndexOfColor(borderPtr->bgColorPtr) == COLOR_3DFACE)
- || (TkWinIndexOfColor(borderPtr->bgColorPtr) == COLOR_WINDOW)) {
+ || (TkWinIndexOfColor(borderPtr->bgColorPtr) == COLOR_WINDOW)) {
borderPtr->darkColorPtr = Tk_GetColor(NULL, tkwin,
- Tk_GetUid("SystemButtonShadow"));
+ Tk_GetUid("SystemButtonShadow"));
gcValues.foreground = borderPtr->darkColorPtr->pixel;
borderPtr->darkGC = Tk_GetGC(tkwin, GCForeground, &gcValues);
borderPtr->lightColorPtr = Tk_GetColor(NULL, tkwin,
- Tk_GetUid("SystemButtonHighlight"));
+ Tk_GetUid("SystemButtonHighlight"));
gcValues.foreground = borderPtr->lightColorPtr->pixel;
borderPtr->lightGC = Tk_GetGC(tkwin, GCForeground, &gcValues);
((WinBorder*)borderPtr)->dark2ColorPtr = Tk_GetColor(NULL, tkwin,
@@ -368,45 +362,42 @@ TkpGetShadows(borderPtr, tkwin)
((WinBorder*)borderPtr)->light2ColorPtr = Tk_GetColor(NULL, tkwin,
Tk_GetUid("System3dLight"));
return;
- } else {
- darkColor.red = 0;
- darkColor.green = 0;
- darkColor.blue = 0;
- ((WinBorder*)borderPtr)->dark2ColorPtr = Tk_GetColorByValue(tkwin,
+ }
+ darkColor.red = 0;
+ darkColor.green = 0;
+ darkColor.blue = 0;
+ ((WinBorder*)borderPtr)->dark2ColorPtr = Tk_GetColorByValue(tkwin,
&darkColor);
- lightColor = *(borderPtr->bgColorPtr);
- ((WinBorder*)borderPtr)->light2ColorPtr = Tk_GetColorByValue(tkwin,
+ lightColor = *(borderPtr->bgColorPtr);
+ ((WinBorder*)borderPtr)->light2ColorPtr = Tk_GetColorByValue(tkwin,
&lightColor);
- }
-
+
/*
- * First, handle the case of a color display with lots of colors.
- * The shadow colors get computed using whichever formula results
- * in the greatest change in color:
- * 1. Lighter shadow is half-way to white, darker shadow is half
- * way to dark.
- * 2. Lighter shadow is 40% brighter than background, darker shadow
- * is 40% darker than background.
+ * First, handle the case of a color display with lots of colors. The
+ * shadow colors get computed using whichever formula results in the
+ * greatest change in color:
+ * 1. Lighter shadow is half-way to white, darker shadow is half way to
+ * dark.
+ * 2. Lighter shadow is 40% brighter than background, darker shadow is 40%
+ * darker than background.
*/
if (Tk_Depth(tkwin) >= 6) {
/*
- * This is a color display with lots of colors. For the dark
- * shadow, cut 40% from each of the background color components.
- * But if the background is already very dark, make the
- * dark color a little lighter than the background by increasing
- * each color component 1/4th of the way to MAX_INTENSITY.
+ * This is a color display with lots of colors. For the dark shadow,
+ * cut 40% from each of the background color components. But if the
+ * background is already very dark, make the dark color a little
+ * lighter than the background by increasing each color component
+ * 1/4th of the way to MAX_INTENSITY.
*
- * For the light shadow, boost each component by 40% or half-way
- * to white, whichever is greater (the first approach works
- * better for unsaturated colors, the second for saturated ones).
- * But if the background is already very bright, instead choose a
- * slightly darker color for the light shadow by reducing each
- * color component by 10%.
+ * For the light shadow, boost each component by 40% or half-way to
+ * white, whichever is greater (the first approach works better for
+ * unsaturated colors, the second for saturated ones). But if the
+ * background is already very bright, instead choose a slightly darker
+ * color for the light shadow by reducing each color component by 10%.
*
- * Compute the colors using integers, not using lightColor.red
- * etc.: these are shorts and may have problems with integer
- * overflow.
+ * Compute the colors using integers, not using lightColor.red etc.:
+ * these are shorts and may have problems with integer overflow.
*/
/*
@@ -463,7 +454,7 @@ TkpGetShadows(borderPtr, tkwin)
tmp2 = (MAX_INTENSITY + b)/2;
lightColor.blue = (tmp1 > tmp2) ? tmp1 : tmp2;
}
-
+
/*
* Allocate the light shadow color and its GC
*/
@@ -483,10 +474,10 @@ TkpGetShadows(borderPtr, tkwin)
}
if (borderPtr->visual->map_entries > 2) {
/*
- * This isn't a monochrome display, but the colormap either
- * ran out of entries or didn't have very many to begin with.
- * Generate the light shadows with a white stipple and the
- * dark shadows with a black stipple.
+ * This isn't a monochrome display, but the colormap either ran out of
+ * entries or didn't have very many to begin with. Generate the light
+ * shadows with a white stipple and the dark shadows with a black
+ * stipple.
*/
gcValues.foreground = borderPtr->bgColorPtr->pixel;
@@ -504,8 +495,8 @@ TkpGetShadows(borderPtr, tkwin)
/*
* This is just a measly monochrome display, hardly even worth its
- * existence on this earth. Make one shadow a 50% stipple and the
- * other the opposite of the background.
+ * existence on this earth. Make one shadow a 50% stipple and the other
+ * the opposite of the background.
*/
gcValues.foreground = WhitePixelOfScreen(borderPtr->screen);
@@ -529,8 +520,7 @@ TkpGetShadows(borderPtr, tkwin)
*
* TkWinGetBorderPixels --
*
- * This routine returns the 5 COLORREFs used to draw a given
- * 3d border.
+ * This routine returns the 5 COLORREFs used to draw a given 3d border.
*
* Results:
* Returns the colors in the specified array.
@@ -542,34 +532,42 @@ TkpGetShadows(borderPtr, tkwin)
*/
COLORREF
-TkWinGetBorderPixels(tkwin, border, which)
- Tk_Window tkwin;
- Tk_3DBorder border;
- int which; /* One of TK_3D_FLAT_GC, TK_3D_LIGHT_GC,
+TkWinGetBorderPixels(
+ Tk_Window tkwin,
+ Tk_3DBorder border,
+ int which) /* One of TK_3D_FLAT_GC, TK_3D_LIGHT_GC,
* TK_3D_DARK_GC, TK_3D_LIGHT2, TK_3D_DARK2 */
{
WinBorder *borderPtr = (WinBorder *) border;
-
+
if (borderPtr->info.lightGC == None) {
TkpGetShadows(&borderPtr->info, tkwin);
}
switch (which) {
- case TK_3D_FLAT_GC:
- return borderPtr->info.bgColorPtr->pixel;
- case TK_3D_LIGHT_GC:
- if (borderPtr->info.lightColorPtr == NULL) {
- return WhitePixelOfScreen(borderPtr->info.screen);
- }
- return borderPtr->info.lightColorPtr->pixel;
- case TK_3D_DARK_GC:
- if (borderPtr->info.darkColorPtr == NULL) {
- return BlackPixelOfScreen(borderPtr->info.screen);
- }
- return borderPtr->info.darkColorPtr->pixel;
- case TK_3D_LIGHT2:
- return borderPtr->light2ColorPtr->pixel;
- case TK_3D_DARK2:
- return borderPtr->dark2ColorPtr->pixel;
+ case TK_3D_FLAT_GC:
+ return borderPtr->info.bgColorPtr->pixel;
+ case TK_3D_LIGHT_GC:
+ if (borderPtr->info.lightColorPtr == NULL) {
+ return WhitePixelOfScreen(borderPtr->info.screen);
+ }
+ return borderPtr->info.lightColorPtr->pixel;
+ case TK_3D_DARK_GC:
+ if (borderPtr->info.darkColorPtr == NULL) {
+ return BlackPixelOfScreen(borderPtr->info.screen);
+ }
+ return borderPtr->info.darkColorPtr->pixel;
+ case TK_3D_LIGHT2:
+ return borderPtr->light2ColorPtr->pixel;
+ case TK_3D_DARK2:
+ return borderPtr->dark2ColorPtr->pixel;
}
return 0;
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/win/tkWinButton.c b/win/tkWinButton.c
index d9b10b5..bd9768c 100644
--- a/win/tkWinButton.c
+++ b/win/tkWinButton.c
@@ -1,4 +1,4 @@
-/*
+/*
* tkWinButton.c --
*
* This file implements the Windows specific portion of the button
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinButton.c,v 1.26 2004/06/16 19:53:40 a_kovalenko Exp $
+ * RCS: @(#) $Id: tkWinButton.c,v 1.27 2005/12/02 00:19:04 dkf Exp $
*/
#define OEMRESOURCE
@@ -21,9 +21,9 @@
*/
#define LABEL_STYLE (BS_OWNERDRAW | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS)
-#define PUSH_STYLE (BS_OWNERDRAW | BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS)
-#define CHECK_STYLE (BS_OWNERDRAW | BS_CHECKBOX | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS)
-#define RADIO_STYLE (BS_OWNERDRAW | BS_RADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS)
+#define PUSH_STYLE (LABEL_STYLE | BS_PUSHBUTTON)
+#define CHECK_STYLE (LABEL_STYLE | BS_CHECKBOX)
+#define RADIO_STYLE (LABEL_STYLE | BS_RADIOBUTTON)
/*
* Declaration of Windows specific button structure.
@@ -37,17 +37,16 @@ typedef struct WinButton {
DWORD style; /* Window style flags. */
} WinButton;
-
/*
- * The following macro reverses the order of RGB bytes to convert
- * between RGBQUAD and COLORREF values.
+ * The following macro reverses the order of RGB bytes to convert between
+ * RGBQUAD and COLORREF values.
*/
#define FlipColor(rgb) (RGB(GetBValue(rgb),GetGValue(rgb),GetRValue(rgb)))
/*
- * The following enumeration defines the meaning of the palette entries
- * in the "buttons" image used to draw checkbox and radiobutton indicators.
+ * The following enumeration defines the meaning of the palette entries in the
+ * "buttons" image used to draw checkbox and radiobutton indicators.
*/
enum {
@@ -61,17 +60,17 @@ enum {
};
/*
- * Cached information about the boxes bitmap, and the default border
- * width for a button in string form for use in Tk_OptionSpec for
- * the various button widget classes.
+ * Cached information about the boxes bitmap, and the default border width for
+ * a button in string form for use in Tk_OptionSpec for the various button
+ * widget classes.
*/
-typedef struct ThreadSpecificData {
- BITMAPINFOHEADER *boxesPtr; /* Information about the bitmap. */
- DWORD *boxesPalette; /* Pointer to color palette. */
- LPSTR boxesBits; /* Pointer to bitmap data. */
- DWORD boxHeight; /* Height of each sub-image. */
- DWORD boxWidth ; /* Width of each sub-image. */
+typedef struct ThreadSpecificData {
+ BITMAPINFOHEADER *boxesPtr; /* Information about the bitmap. */
+ DWORD *boxesPalette; /* Pointer to color palette. */
+ LPSTR boxesBits; /* Pointer to bitmap data. */
+ DWORD boxHeight; /* Height of each sub-image. */
+ DWORD boxWidth; /* Width of each sub-image. */
char defWidth[TCL_INTEGER_SPACE];
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
@@ -79,17 +78,18 @@ static Tcl_ThreadDataKey dataKey;
/*
* Declarations for functions defined in this file.
*/
-static LRESULT CALLBACK ButtonProc _ANSI_ARGS_((HWND hwnd, UINT message,
- WPARAM wParam, LPARAM lParam));
-static Window CreateProc _ANSI_ARGS_((Tk_Window tkwin,
- Window parent, ClientData instanceData));
-static void InitBoxes _ANSI_ARGS_((void));
+
+static LRESULT CALLBACK ButtonProc(HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam);
+static Window CreateProc(Tk_Window tkwin, Window parent,
+ ClientData instanceData);
+static void InitBoxes(void);
/*
* The class procedure table for the button widgets.
*/
-Tk_ClassProcs tkpButtonProcs = {
+Tk_ClassProcs tkpButtonProcs = {
sizeof(Tk_ClassProcs), /* size */
TkButtonWorldChanged, /* worldChangedProc */
CreateProc, /* createProc */
@@ -101,13 +101,13 @@ Tk_ClassProcs tkpButtonProcs = {
*
* InitBoxes --
*
- * This function load the Tk 3d button bitmap. "buttons" is a 16
- * color bitmap that is laid out such that the top row contains
- * the 4 checkbox images, and the bottom row contains the radio
- * button images. Note that the bitmap is stored in bottom-up
- * format. Also, the first seven palette entries are used to
- * identify the different parts of the bitmaps so we can do the
- * appropriate color mappings based on the current button colors.
+ * This function load the Tk 3d button bitmap. "buttons" is a 16 color
+ * bitmap that is laid out such that the top row contains the 4 checkbox
+ * images, and the bottom row contains the radio button images. Note that
+ * the bitmap is stored in bottom-up format. Also, the first seven
+ * palette entries are used to identify the different parts of the
+ * bitmaps so we can do the appropriate color mappings based on the
+ * current button colors.
*
* Results:
* None.
@@ -119,7 +119,7 @@ Tk_ClassProcs tkpButtonProcs = {
*/
static void
-InitBoxes()
+InitBoxes(void)
{
/*
* For DLLs like Tk, the HINSTANCE is the same as the HMODULE.
@@ -130,7 +130,7 @@ InitBoxes()
HGLOBAL hblk;
LPBITMAPINFOHEADER newBitmap;
DWORD size;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
hrsrc = FindResource(module, "buttons", RT_BITMAP);
@@ -145,14 +145,14 @@ InitBoxes()
if (tsdPtr->boxesPtr != NULL && !(tsdPtr->boxesPtr->biWidth % 4)
&& !(tsdPtr->boxesPtr->biHeight % 2)) {
- size = tsdPtr->boxesPtr->biSize + (1 << tsdPtr->boxesPtr->biBitCount)
+ size = tsdPtr->boxesPtr->biSize + (1 << tsdPtr->boxesPtr->biBitCount)
* sizeof(RGBQUAD) + tsdPtr->boxesPtr->biSizeImage;
newBitmap = (LPBITMAPINFOHEADER) ckalloc(size);
memcpy(newBitmap, tsdPtr->boxesPtr, size);
tsdPtr->boxesPtr = newBitmap;
tsdPtr->boxWidth = tsdPtr->boxesPtr->biWidth / 4;
tsdPtr->boxHeight = tsdPtr->boxesPtr->biHeight / 2;
- tsdPtr->boxesPalette = (DWORD*) (((LPSTR) tsdPtr->boxesPtr)
+ tsdPtr->boxesPalette = (DWORD*) (((LPSTR) tsdPtr->boxesPtr)
+ tsdPtr->boxesPtr->biSize);
tsdPtr->boxesBits = ((LPSTR) tsdPtr->boxesPalette)
+ ((1 << tsdPtr->boxesPtr->biBitCount) * sizeof(RGBQUAD));
@@ -167,8 +167,8 @@ InitBoxes()
* TkpButtonSetDefaults --
*
* This procedure is invoked before option tables are created for
- * buttons. It modifies some of the default values to match the
- * current values defined for this platform.
+ * buttons. It modifies some of the default values to match the current
+ * values defined for this platform.
*
* Results:
* Some of the default values in *specPtr are modified.
@@ -180,13 +180,13 @@ InitBoxes()
*/
void
-TkpButtonSetDefaults(specPtr)
- Tk_OptionSpec *specPtr; /* Points to an array of option specs,
+TkpButtonSetDefaults(
+ Tk_OptionSpec *specPtr) /* Points to an array of option specs,
* terminated by one with type
* TK_OPTION_END. */
{
int width;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (tsdPtr->defWidth[0] == 0) {
@@ -220,8 +220,8 @@ TkpButtonSetDefaults(specPtr)
*/
TkButton *
-TkpCreateButton(tkwin)
- Tk_Window tkwin;
+TkpCreateButton(
+ Tk_Window tkwin)
{
WinButton *butPtr;
@@ -235,8 +235,8 @@ TkpCreateButton(tkwin)
*
* CreateProc --
*
- * This function creates a new Button control, subclasses
- * the instance, and generates a new Window object.
+ * This function creates a new Button control, subclasses the instance,
+ * and generates a new Window object.
*
* Results:
* Returns the newly allocated Window object, or None on failure.
@@ -248,10 +248,10 @@ TkpCreateButton(tkwin)
*/
static Window
-CreateProc(tkwin, parentWin, instanceData)
- Tk_Window tkwin; /* Token for window. */
- Window parentWin; /* Parent of new window. */
- ClientData instanceData; /* Button instance data. */
+CreateProc(
+ Tk_Window tkwin, /* Token for window. */
+ Window parentWin, /* Parent of new window. */
+ ClientData instanceData) /* Button instance data. */
{
Window window;
HWND parent;
@@ -300,11 +300,12 @@ CreateProc(tkwin, parentWin, instanceData)
*/
void
-TkpDestroyButton(butPtr)
- TkButton *butPtr;
+TkpDestroyButton(
+ TkButton *butPtr)
{
WinButton *winButPtr = (WinButton *)butPtr;
HWND hwnd = winButPtr->hwnd;
+
if (hwnd) {
#ifdef _WIN64
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) winButPtr->oldProc);
@@ -319,22 +320,21 @@ TkpDestroyButton(butPtr)
*
* TkpDisplayButton --
*
- * This procedure is invoked to display a button widget. It is
- * normally invoked as an idle handler.
+ * This procedure is invoked to display a button widget. It is normally
+ * invoked as an idle handler.
*
* Results:
* None.
*
* Side effects:
- * Information appears on the screen. The REDRAW_PENDING flag
- * is cleared.
+ * Information appears on the screen. The REDRAW_PENDING flag is cleared.
*
*----------------------------------------------------------------------
*/
void
-TkpDisplayButton(clientData)
- ClientData clientData; /* Information about widget. */
+TkpDisplayButton(
+ ClientData clientData) /* Information about widget. */
{
TkWinDCState state;
HDC dc;
@@ -342,26 +342,27 @@ TkpDisplayButton(clientData)
GC gc;
Tk_3DBorder border;
Pixmap pixmap;
- int x = 0; /* Initialization only needed to stop
- * compiler warning. */
+ int x = 0; /* Initialization only needed to stop compiler
+ * warning. */
int y, relief;
register Tk_Window tkwin = butPtr->tkwin;
int width, height, haveImage = 0, haveText = 0, drawRing = 0;
RECT rect;
int defaultWidth; /* Width of default ring. */
- int offset; /* 0 means this is a label widget. 1 means
- * it is a flavor of button, so we offset
- * the text to make the button appear to
- * move up and down as the relief changes. */
- int textXOffset = 0, textYOffset = 0; /* text offsets for use with
- * compound buttons and focus ring */
+ int offset; /* 0 means this is a label widget. 1 means it
+ * is a flavor of button, so we offset the
+ * text to make the button appear to move up
+ * and down as the relief changes. */
+ int textXOffset = 0, textYOffset = 0;
+ /* Text offsets for use with compound buttons
+ * and focus ring. */
int imageWidth, imageHeight;
- int imageXOffset = 0, imageYOffset = 0; /* image information that will
- * be used to restrict disabled
- * pixmap as well */
+ int imageXOffset = 0, imageYOffset = 0;
+ /* Image information that will be used to
+ * restrict disabled pixmap as well. */
DWORD *boxesPalette;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
boxesPalette= tsdPtr->boxesPalette;
@@ -386,9 +387,8 @@ TkpDisplayButton(clientData)
}
/*
- * Override the relief specified for the button if this is a
- * checkbutton or radiobutton and there's no indicator. The new
- * relief is as follows:
+ * Override the relief specified for the button if this is a checkbutton
+ * or radiobutton and there's no indicator. The new relief is as follows:
* If the button is select --> "sunken"
* If relief==overrelief --> relief
* Otherwise --> overrelief
@@ -402,15 +402,15 @@ TkpDisplayButton(clientData)
* on no sunken
* on yes sunken
*
- * This is accomplished by configuring the checkbutton or radiobutton
- * like this:
+ * This is accomplished by configuring the checkbutton or radiobutton like
+ * this:
*
* -indicatoron 0 -overrelief raised -offrelief flat
*
* Bindings (see library/button.tcl) will copy the -overrelief into
- * -relief on mouseover. Hence, we can tell if we are in mouse-over by
- * comparing relief against overRelief. This is an aweful kludge, but
- * it gives use the desired behavior while keeping the code backwards
+ * -relief on mouseover. Hence, we can tell if we are in mouse-over by
+ * comparing relief against overRelief. This is an aweful kludge, but it
+ * gives use the desired behavior while keeping the code backwards
* compatible.
*/
@@ -441,10 +441,10 @@ TkpDisplayButton(clientData)
}
/*
- * In order to avoid screen flashes, this procedure redraws
- * the button in a pixmap, then copies the pixmap to the
- * screen in a single operation. This means that there's no
- * point in time where the on-sreen image has been cleared.
+ * In order to avoid screen flashes, this procedure redraws the button in
+ * a pixmap, then copies the pixmap to the screen in a single operation.
+ * This means that there's no point in time where the on-sreen image has
+ * been cleared.
*/
pixmap = Tk_GetPixmap(butPtr->display, Tk_WindowId(tkwin),
@@ -463,7 +463,7 @@ TkpDisplayButton(clientData)
Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height);
haveImage = 1;
}
- imageWidth = width;
+ imageWidth = width;
imageHeight = height;
haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0);
@@ -472,49 +472,58 @@ TkpDisplayButton(clientData)
int fullWidth = 0, fullHeight = 0;
switch ((enum compound) butPtr->compound) {
- case COMPOUND_TOP:
- case COMPOUND_BOTTOM: {
- /* Image is above or below text */
- if (butPtr->compound == COMPOUND_TOP) {
- textYOffset = height + butPtr->padY;
- } else {
- imageYOffset = butPtr->textHeight + butPtr->padY;
- }
- fullHeight = height + butPtr->textHeight + butPtr->padY;
- fullWidth = (width > butPtr->textWidth ? width :
- butPtr->textWidth);
- textXOffset = (fullWidth - butPtr->textWidth)/2;
- imageXOffset = (fullWidth - width)/2;
- break;
- }
- case COMPOUND_LEFT:
- case COMPOUND_RIGHT: {
- /* Image is left or right of text */
- if (butPtr->compound == COMPOUND_LEFT) {
- textXOffset = width + butPtr->padX;
- } else {
- imageXOffset = butPtr->textWidth + butPtr->padX;
- }
- fullWidth = butPtr->textWidth + butPtr->padX + width;
- fullHeight = (height > butPtr->textHeight ? height :
- butPtr->textHeight);
- textYOffset = (fullHeight - butPtr->textHeight)/2;
- imageYOffset = (fullHeight - height)/2;
- break;
+ case COMPOUND_TOP:
+ case COMPOUND_BOTTOM:
+ /*
+ * Image is above or below text.
+ */
+
+ if (butPtr->compound == COMPOUND_TOP) {
+ textYOffset = height + butPtr->padY;
+ } else {
+ imageYOffset = butPtr->textHeight + butPtr->padY;
}
- case COMPOUND_CENTER: {
- /* Image and text are superimposed */
- fullWidth = (width > butPtr->textWidth ? width :
- butPtr->textWidth);
- fullHeight = (height > butPtr->textHeight ? height :
- butPtr->textHeight);
- textXOffset = (fullWidth - butPtr->textWidth)/2;
- imageXOffset = (fullWidth - width)/2;
- textYOffset = (fullHeight - butPtr->textHeight)/2;
- imageYOffset = (fullHeight - height)/2;
- break;
+ fullHeight = height + butPtr->textHeight + butPtr->padY;
+ fullWidth = (width > butPtr->textWidth ? width :
+ butPtr->textWidth);
+ textXOffset = (fullWidth - butPtr->textWidth)/2;
+ imageXOffset = (fullWidth - width)/2;
+ break;
+
+ case COMPOUND_LEFT:
+ case COMPOUND_RIGHT:
+ /*
+ * Image is left or right of text.
+ */
+
+ if (butPtr->compound == COMPOUND_LEFT) {
+ textXOffset = width + butPtr->padX;
+ } else {
+ imageXOffset = butPtr->textWidth + butPtr->padX;
}
- case COMPOUND_NONE: {break;}
+ fullWidth = butPtr->textWidth + butPtr->padX + width;
+ fullHeight = (height > butPtr->textHeight ? height :
+ butPtr->textHeight);
+ textYOffset = (fullHeight - butPtr->textHeight)/2;
+ imageYOffset = (fullHeight - height)/2;
+ break;
+
+ case COMPOUND_CENTER:
+ /*
+ * Image and text are superimposed.
+ */
+
+ fullWidth = (width > butPtr->textWidth ? width :
+ butPtr->textWidth);
+ fullHeight = (height > butPtr->textHeight ? height :
+ butPtr->textHeight);
+ textXOffset = (fullWidth - butPtr->textWidth)/2;
+ imageXOffset = (fullWidth - width)/2;
+ textYOffset = (fullHeight - butPtr->textHeight)/2;
+ imageYOffset = (fullHeight - height)/2;
+ break;
+ case COMPOUND_NONE:
+ break;
}
TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY,
butPtr->indicatorSpace + fullWidth, fullHeight, &x, &y);
@@ -530,12 +539,13 @@ TkpDisplayButton(clientData)
if ((butPtr->selectImage != NULL) && (butPtr->flags & SELECTED)) {
Tk_RedrawImage(butPtr->selectImage, 0, 0,
width, height, pixmap, imageXOffset, imageYOffset);
- } else if ((butPtr->tristateImage != NULL) && (butPtr->flags & TRISTATED)) {
+ } else if ((butPtr->tristateImage != NULL)
+ && (butPtr->flags & TRISTATED)) {
Tk_RedrawImage(butPtr->tristateImage, 0, 0,
width, height, pixmap, imageXOffset, imageYOffset);
} else {
- Tk_RedrawImage(butPtr->image, 0, 0,
- width, height, pixmap, imageXOffset, imageYOffset);
+ Tk_RedrawImage(butPtr->image, 0, 0, width, height, pixmap,
+ imageXOffset, imageYOffset);
}
} else {
XSetClipOrigin(butPtr->display, gc, imageXOffset, imageYOffset);
@@ -547,6 +557,7 @@ TkpDisplayButton(clientData)
if ((butPtr->state == STATE_DISABLED) &&
(butPtr->disabledFg != NULL)) {
COLORREF oldFgColor = gc->foreground;
+
gc->foreground = GetSysColor(COLOR_3DHILIGHT);
Tk_DrawTextLayout(butPtr->display, pixmap, gc,
butPtr->textLayout, x + textXOffset + 1,
@@ -570,7 +581,7 @@ TkpDisplayButton(clientData)
TkComputeAnchor(butPtr->anchor, tkwin, 0, 0,
butPtr->indicatorSpace + width, height, &x, &y);
x += butPtr->indicatorSpace;
-
+
if (relief == TK_RELIEF_SUNKEN) {
x += offset;
y += offset;
@@ -602,7 +613,7 @@ TkpDisplayButton(clientData)
butPtr->textHeight, &x, &y);
x += butPtr->indicatorSpace;
-
+
if (relief == TK_RELIEF_SUNKEN) {
x += offset;
y += offset;
@@ -629,12 +640,12 @@ TkpDisplayButton(clientData)
}
/*
- * Draw the focus ring. If this is a push button then we need to
- * put it around the inner edge of the border, otherwise we put it
- * around the text. The text offsets are only non-zero when this
- * is a compound button.
+ * Draw the focus ring. If this is a push button then we need to put it
+ * around the inner edge of the border, otherwise we put it around the
+ * text. The text offsets are only non-zero when this is a compound
+ * button.
*/
-
+
if (drawRing && butPtr->flags & GOT_FOCUS && butPtr->type != TYPE_LABEL) {
dc = TkWinGetDrawableDC(butPtr->display, pixmap, &state);
if (butPtr->type == TYPE_BUTTON || !butPtr->indicatorOn) {
@@ -655,11 +666,10 @@ TkpDisplayButton(clientData)
}
y += height/2;
-
+
/*
- * Draw the indicator for check buttons and radio buttons. At this
- * point x and y refer to the top-left corner of the text or image
- * or bitmap.
+ * Draw the indicator for check buttons and radio buttons. At this point x
+ * and y refer to the top-left corner of the text or image or bitmap.
*/
if ((butPtr->type >= TYPE_CHECK_BUTTON) && butPtr->indicatorOn
@@ -677,11 +687,11 @@ TkpDisplayButton(clientData)
/*
* Update the palette in the boxes bitmap to reflect the current
- * button colors. Note that this code relies on the layout of the
- * bitmap's palette. Also, all of the colors used to draw the
- * bitmap must be in the palette that is selected into the DC of
- * the offscreen pixmap. This requires that the static colors
- * be placed into the palette.
+ * button colors. Note that this code relies on the layout of the
+ * bitmap's palette. Also, all of the colors used to draw the bitmap
+ * must be in the palette that is selected into the DC of the
+ * offscreen pixmap. This requires that the static colors be placed
+ * into the palette.
*/
if ((butPtr->state == STATE_DISABLED)
@@ -712,18 +722,18 @@ TkpDisplayButton(clientData)
border, TK_3D_FLAT_GC));
dc = TkWinGetDrawableDC(butPtr->display, pixmap, &state);
- StretchDIBits(dc, x, y, tsdPtr->boxWidth, tsdPtr->boxHeight,
- xSrc, ySrc, tsdPtr->boxWidth, tsdPtr->boxHeight,
- tsdPtr->boxesBits, (LPBITMAPINFO) tsdPtr->boxesPtr,
+ StretchDIBits(dc, x, y, tsdPtr->boxWidth, tsdPtr->boxHeight,
+ xSrc, ySrc, tsdPtr->boxWidth, tsdPtr->boxHeight,
+ tsdPtr->boxesBits, (LPBITMAPINFO) tsdPtr->boxesPtr,
DIB_RGB_COLORS, SRCCOPY);
TkWinReleaseDrawableDC(pixmap, dc, &state);
}
/*
* If the button is disabled with a stipple rather than a special
- * foreground color, generate the stippled effect. If the widget
- * is selected and we use a different background color when selected,
- * must temporarily modify the GC so the stippling is the right color.
+ * foreground color, generate the stippled effect. If the widget is
+ * selected and we use a different background color when selected, must
+ * temporarily modify the GC so the stippling is the right color.
*/
if ((butPtr->state == STATE_DISABLED)
@@ -733,10 +743,12 @@ TkpDisplayButton(clientData)
XSetForeground(butPtr->display, butPtr->stippleGC,
Tk_3DBorderColor(butPtr->selectBorder)->pixel);
}
+
/*
- * Stipple the whole button if no disabledFg was specified,
- * otherwise restrict stippling only to displayed image
+ * Stipple the whole button if no disabledFg was specified, otherwise
+ * restrict stippling only to displayed image
*/
+
if (butPtr->disabledFg == NULL) {
XFillRectangle(butPtr->display, pixmap, butPtr->stippleGC, 0, 0,
(unsigned) Tk_Width(tkwin), (unsigned) Tk_Height(tkwin));
@@ -753,8 +765,8 @@ TkpDisplayButton(clientData)
}
/*
- * Draw the border and traversal highlight last. This way, if the
- * button's contents overflow they'll be covered up by the border.
+ * Draw the border and traversal highlight last. This way, if the button's
+ * contents overflow they'll be covered up by the border.
*/
if (relief != TK_RELIEF_FLAT) {
@@ -784,8 +796,8 @@ TkpDisplayButton(clientData)
}
/*
- * Copy the information from the off-screen pixmap onto the screen,
- * then delete the pixmap.
+ * Copy the information from the off-screen pixmap onto the screen, then
+ * delete the pixmap.
*/
XCopyArea(butPtr->display, pixmap, Tk_WindowId(tkwin),
@@ -799,9 +811,9 @@ TkpDisplayButton(clientData)
*
* TkpComputeButtonGeometry --
*
- * After changes in a button's text or bitmap, this procedure
- * recomputes the button's geometry and passes this information
- * along to the geometry manager for the window.
+ * After changes in a button's text or bitmap, this procedure recomputes
+ * the button's geometry and passes this information along to the
+ * geometry manager for the window.
*
* Results:
* None.
@@ -813,21 +825,21 @@ TkpDisplayButton(clientData)
*/
void
-TkpComputeButtonGeometry(butPtr)
- register TkButton *butPtr; /* Button whose geometry may have changed. */
+TkpComputeButtonGeometry(
+ register TkButton *butPtr) /* Button whose geometry may have changed. */
{
- int txtWidth, txtHeight; /* Width and height of text */
- int imgWidth, imgHeight; /* Width and height of image */
- int width = 0, height = 0; /* Width and height of button */
+ int txtWidth, txtHeight; /* Width and height of text */
+ int imgWidth, imgHeight; /* Width and height of image */
+ int width = 0, height = 0; /* Width and height of button */
int haveImage, haveText;
int avgWidth;
int minWidth;
/* Vertical and horizontal dialog units size in pixels. */
double vDLU, hDLU;
Tk_FontMetrics fm;
-
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
- Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (butPtr->highlightWidth < 0) {
butPtr->highlightWidth = 0;
@@ -839,13 +851,16 @@ TkpComputeButtonGeometry(butPtr)
InitBoxes();
}
- /* Figure out image metrics */
+ /*
+ * Figure out image metrics.
+ */
+
if (butPtr->image != NULL) {
Tk_SizeOfImage(butPtr->image, &imgWidth, &imgHeight);
haveImage = 1;
} else if (butPtr->bitmap != None) {
Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap,
- &imgWidth, &imgHeight);
+ &imgWidth, &imgHeight);
haveImage = 1;
} else {
imgWidth = 0;
@@ -853,10 +868,11 @@ TkpComputeButtonGeometry(butPtr)
haveImage = 0;
}
- /*
+ /*
* Figure out font metrics (even if we don't have text because we need
* DLUs (based on font, not text) for some spacing calculations below).
*/
+
Tk_FreeTextLayout(butPtr->textLayout);
butPtr->textLayout = Tk_ComputeTextLayout(butPtr->tkfont,
Tcl_GetString(butPtr->textPtr), -1, butPtr->wrapLength,
@@ -870,7 +886,10 @@ TkpComputeButtonGeometry(butPtr)
52) + 26) / 52;
Tk_GetFontMetrics(butPtr->tkfont, &fm);
- /* Compute dialog units for layout calculations. */
+ /*
+ * Compute dialog units for layout calculations.
+ */
+
hDLU = avgWidth / 4.0;
vDLU = fm.linespace / 8.0;
@@ -887,179 +906,197 @@ TkpComputeButtonGeometry(butPtr)
/*
* Set width and height by button type; See User Experience table, p449.
- * These are text-based measurements, even if the text is "".
- * If there is an image, height will get set again later.
+ * These are text-based measurements, even if the text is "". If there is
+ * an image, height will get set again later.
*/
+
switch (butPtr->type) {
- case TYPE_BUTTON: {
- /*
- * First compute the minimum width of the button in
- * characters. MWUE says that the button should be
- * 50 DLUs. We allow 6 DLUs padding left and right.
- * (There is no rule but this is consistent with the
- * fact that button text is 8 DLUs high and buttons
- * are 14 DLUs high.)
- *
- * The width is specified in characters. A character
- * is, by definition, 4 DLUs wide. 11 char * 4 DLU
- * is 44 DLU + 6 DLU padding = 50 DLU. Therefore,
- * width = -11 -> MWUE compliant buttons.
- */
- if (butPtr->width < 0) {
- /* Min width in characters */
- minWidth = -(butPtr->width);
- /* Allow for characters */
- width = avgWidth * minWidth;
- /* Add for padding */
- width += (int)(0.5 + (6 * hDLU));
- }
+ case TYPE_BUTTON:
+ /*
+ * First compute the minimum width of the button in characters. MWUE
+ * says that the button should be 50 DLUs. We allow 6 DLUs padding
+ * left and right. (There is no rule but this is consistent with the
+ * fact that button text is 8 DLUs high and buttons are 14 DLUs high.)
+ *
+ * The width is specified in characters. A character is, by
+ * definition, 4 DLUs wide. 11 char * 4 DLU is 44 DLU + 6 DLU padding
+ * = 50 DLU. Therefore, width = -11 -> MWUE compliant buttons.
+ */
- /*
- * If shrink-wrapping was requested (width = 0) or
- * if the text is wider than the default button width,
- * adjust the button width up to suit.
- */
- if (butPtr->width == 0
- || (txtWidth + (int)(0.5 + (6 * hDLU)) > width)) {
- width = txtWidth + (int)(0.5 + (6 * hDLU));
- }
+ if (butPtr->width < 0) {
+ minWidth = -(butPtr->width); /* Min width in chars */
+ width = avgWidth * minWidth; /* Allow for characters */
+ width += (int)(0.5 + (6 * hDLU)); /* Add for padding */
+ }
+
+ /*
+ * If shrink-wrapping was requested (width = 0) or if the text is
+ * wider than the default button width, adjust the button width up to
+ * suit.
+ */
+
+ if (butPtr->width == 0
+ || (txtWidth + (int)(0.5 + (6 * hDLU)) > width)) {
+ width = txtWidth + (int)(0.5 + (6 * hDLU));
+ }
+
+ /*
+ * The User Experience says 14 DLUs. Since text is, by definition, 8
+ * DLU/line, this allows for multi-line text while working perfectly
+ * for single-line text.
+ */
+
+ height = txtHeight + (int)(0.5 + (6 * vDLU));
+
+ /*
+ * The above includes 6 DLUs of padding which should include defaults
+ * of 1 pixel of highlightwidth, 2 pixels of borderwidth, 1 pixel of
+ * padding and 1 pixel of extra inset on each side. Those will be
+ * added later so reduce width and height now to compensate.
+ */
+
+ width -= 10;
+ height -= 10;
+ if (!haveImage) {
/*
- * The User Experience says 14 DLUs. Since text is, by
- * definition, 8 DLU/line, this allows for multi-line text
- * while working perfectly for single-line text.
+ * Extra inset for the focus ring.
*/
- height = txtHeight + (int)(0.5 + (6 * vDLU));
+ butPtr->inset += 1;
+ }
+ break;
+
+ case TYPE_LABEL:
+ /*
+ * The User Experience says, "as wide as needed".
+ */
+
+ width = txtWidth;
+
+ /*
+ * The User Experience says, "8 (DLUs) per line of text". Since text
+ * is, by definition, 8 DLU/line, this allows for multi-line text
+ * while working perfectly for single-line text.
+ */
+
+ if (txtHeight) {
+ height = txtHeight;
+ } else {
/*
- * The above includes 6 DLUs of padding which should include
- * defaults of 1 pixel of highlightwidth, 2 pixels of
- * borderwidth, 1 pixel of padding and 1 pixel of extra inset
- * on each side. Those will be added later so reduce width
- * and height now to compensate.
+ * If there's no text, we want the height to be one linespace.
*/
- width -= 10;
- height -= 10;
-
- if (!haveImage) {
- /*
- * Extra inset for the focus ring.
- */
- butPtr->inset += 1;
- }
- break;
+ height = fm.linespace;
}
+ break;
- case TYPE_LABEL: {
- /*
- * The User Experience says, "as wide as needed".
- */
- width = txtWidth;
+ case TYPE_RADIO_BUTTON:
+ case TYPE_CHECK_BUTTON: {
+ /*
+ * See note for TYPE_LABEL.
+ */
- /*
- * The User Experience says, "8 (DLUs) per line of text."
- * Since text is, by definition, 8 DLU/line, this allows
- * for multi-line text while working perfectly for single-line
- * text.
- */
- if (txtHeight) {
- height = txtHeight;
- } else {
- /*
- * If there's no text, we want the height to be one linespace.
- */
- height = fm.linespace;
- }
- break;
- }
+ width = txtWidth;
- case TYPE_RADIO_BUTTON:
- case TYPE_CHECK_BUTTON: {
- /* See note for TYPE_LABEL */
- width = txtWidth;
- /*
- * The User Experience says 10 DLUs. (Is that one DLU above
- * and below for the focus ring?) See note above about
- * multi-line text and 8 DLU/line.
- */
- height = txtHeight + (int)(0.5 + (2.0 * vDLU));
-
- /*
- * The above includes 2 DLUs of padding which should include
- * defaults of 1 pixel of highlightwidth, 0 pixels of
- * borderwidth, and 1 pixel of padding on each side. Those
- * will be added later so reduce height now to compensate.
- */
- height -= 4;
-
- /*
- * Extra inset for the focus ring.
- */
- butPtr->inset += 1;
- break;
- }
+ /*
+ * The User Experience says 10 DLUs. (Is that one DLU above and below
+ * for the focus ring?) See note above about multi-line text and 8
+ * DLU/line.
+ */
+
+ height = txtHeight + (int)(0.5 + (2.0 * vDLU));
+
+ /*
+ * The above includes 2 DLUs of padding which should include defaults
+ * of 1 pixel of highlightwidth, 0 pixels of borderwidth, and 1 pixel
+ * of padding on each side. Those will be added later so reduce height
+ * now to compensate.
+ */
+
+ height -= 4;
+
+ /*
+ * Extra inset for the focus ring.
+ */
+ butPtr->inset += 1;
+ break;
+ }
}/* switch */
/*
- * At this point, the width and height are correct for a Tk text
- * button, excluding padding and inset, but we have to allow for
- * compound buttons. The image may be above, below, left, or right
- * of the text.
+ * At this point, the width and height are correct for a Tk text button,
+ * excluding padding and inset, but we have to allow for compound buttons.
+ * The image may be above, below, left, or right of the text.
*/
/*
- * If the button is compound (i.e., it shows both an image and text),
- * the new geometry is a combination of the image and text geometry.
- * We only honor the compound bit if the button has both text and an
- * image, because otherwise it is not really a compound button.
+ * If the button is compound (i.e., it shows both an image and text), the
+ * new geometry is a combination of the image and text geometry. We only
+ * honor the compound bit if the button has both text and an image,
+ * because otherwise it is not really a compound button.
*/
+
if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) {
switch ((enum compound) butPtr->compound) {
- case COMPOUND_TOP:
- case COMPOUND_BOTTOM: {
- /* Image is above or below text */
- if (imgWidth > width) {
- width = imgWidth;
- }
- height += imgHeight + butPtr->padY;
- break;
+ case COMPOUND_TOP:
+ case COMPOUND_BOTTOM:
+ /*
+ * Image is above or below text.
+ */
+
+ if (imgWidth > width) {
+ width = imgWidth;
}
- case COMPOUND_LEFT:
- case COMPOUND_RIGHT: {
- /* Image is left or right of text */
- /*
- * Only increase width of button if image doesn't fit in
- * slack space of default button width
- */
- if ((imgWidth + txtWidth + butPtr->padX) > width) {
- width = imgWidth + txtWidth + butPtr->padX;
- }
+ height += imgHeight + butPtr->padY;
+ break;
- if (imgHeight > height) {
- height = imgHeight;
- }
- break;
+ case COMPOUND_LEFT:
+ case COMPOUND_RIGHT:
+
+ /*
+ * Image is left or right of text.
+ *
+ * Only increase width of button if image doesn't fit in slack
+ * space of default button width
+ */
+
+ if ((imgWidth + txtWidth + butPtr->padX) > width) {
+ width = imgWidth + txtWidth + butPtr->padX;
}
- case COMPOUND_CENTER: {
- /* Image and text are superimposed */
- if (imgWidth > width) {
- width = imgWidth;
- }
- if (imgHeight > height) {
- height = imgHeight;
- }
- break;
+
+ if (imgHeight > height) {
+ height = imgHeight;
+ }
+ break;
+
+ case COMPOUND_CENTER:
+ /*
+ * Image and text are superimposed.
+ */
+
+ if (imgWidth > width) {
+ width = imgWidth;
+ }
+ if (imgHeight > height) {
+ height = imgHeight;
}
+ break;
} /* switch */
- /* Fix up for minimum width */
- if (butPtr->width < 0) {
- /* minWidth in pixels (because there's an image */
- minWidth = -(butPtr->width);
- if (width < minWidth) {
- width = minWidth;
- }
- } else if (butPtr->width > 0) {
+ /*
+ * Fix up for minimum width.
+ */
+
+ if (butPtr->width < 0) {
+ /*
+ * minWidth in pixels (because there's an image.
+ */
+
+ minWidth = -(butPtr->width);
+ if (width < minWidth) {
+ width = minWidth;
+ }
+ } else if (butPtr->width > 0) {
width = butPtr->width;
}
@@ -1081,68 +1118,76 @@ TkpComputeButtonGeometry(butPtr)
height = imgHeight;
}
} else {
- /* No image. May or may not be text. May or may not be compound. */
+ /*
+ * No image. May or may not be text. May or may not be compound.
+ */
/*
- * butPtr->width is in characters. We need to allow for that
- * many characters on the face, not in the over-all button width
+ * butPtr->width is in characters. We need to allow for that many
+ * characters on the face, not in the over-all button width
*/
+
if (butPtr->width > 0) {
width = butPtr->width * avgWidth;
}
/*
- * butPtr->height is in lines of text. We need to allow for
- * that many lines on the face, not in the over-all button
- * height.
+ * butPtr->height is in lines of text. We need to allow for that many
+ * lines on the face, not in the over-all button height.
*/
+
if (butPtr->height > 0) {
height = butPtr->height * fm.linespace;
/*
- * Make the same adjustments as above to get same height for
- * e.g. a one line text with -height 0 or 1. [Bug #565485]
+ * Make the same adjustments as above to get same height for e.g.
+ * a one line text with -height 0 or 1. [Bug #565485]
*/
switch (butPtr->type) {
- case TYPE_BUTTON: {
- height += (int)(0.5 + (6 * vDLU)) - 10;
- break;
- }
- case TYPE_RADIO_BUTTON:
- case TYPE_CHECK_BUTTON: {
- height += (int)(0.5 + (2.0 * vDLU)) - 4;
- break;
- }
+ case TYPE_BUTTON: {
+ height += (int)(0.5 + (6 * vDLU)) - 10;
+ break;
+ }
+ case TYPE_RADIO_BUTTON:
+ case TYPE_CHECK_BUTTON: {
+ height += (int)(0.5 + (2.0 * vDLU)) - 4;
+ break;
+ }
}
}
-
- width += 2 * butPtr->padX;
+
+ width += 2 * butPtr->padX;
height += 2 * butPtr->padY;
}
- /* Fix up width and height for indicator sizing and spacing */
+ /*
+ * Fix up width and height for indicator sizing and spacing.
+ */
+
if (butPtr->type == TYPE_RADIO_BUTTON
|| butPtr->type == TYPE_CHECK_BUTTON) {
if (butPtr->indicatorOn) {
butPtr->indicatorDiameter = tsdPtr->boxHeight;
- /*
- * Make sure we can see the whole indicator, even if the text
- * or image is very small.
+ /*
+ * Make sure we can see the whole indicator, even if the text or
+ * image is very small.
*/
+
if (height < butPtr->indicatorDiameter) {
height = butPtr->indicatorDiameter;
}
/*
- * There is no rule for space between the indicator and
- * the text (the two are atomic on 'Windows) but the User
- * Experience page 451 says leave 3 hDLUs between "text
- * labels and their associated controls".
+ * There is no rule for space between the indicator and the text
+ * (the two are atomic on 'Windows) but the User Experience page
+ * 451 says leave 3 hDLUs between "text labels and their
+ * associated controls".
*/
+
butPtr->indicatorSpace = butPtr->indicatorDiameter +
- (int)(0.5 + (3.0 * hDLU));
+ (int)(0.5 + (3.0 * hDLU));
width += butPtr->indicatorSpace;
}
}
@@ -1150,7 +1195,8 @@ TkpComputeButtonGeometry(butPtr)
/*
* Inset is always added to the size.
*/
- width += 2 * butPtr->inset;
+
+ width += 2 * butPtr->inset;
height += 2 * butPtr->inset;
Tk_GeometryRequest(butPtr->tkwin, width, height);
@@ -1162,8 +1208,8 @@ TkpComputeButtonGeometry(butPtr)
*
* ButtonProc --
*
- * This function is call by Windows whenever an event occurs on
- * a button control created by Tk.
+ * This function is call by Windows whenever an event occurs on a button
+ * control created by Tk.
*
* Results:
* Standard Windows return value.
@@ -1175,11 +1221,11 @@ TkpComputeButtonGeometry(butPtr)
*/
static LRESULT CALLBACK
-ButtonProc(hwnd, message, wParam, lParam)
- HWND hwnd;
- UINT message;
- WPARAM wParam;
- LPARAM lParam;
+ButtonProc(
+ HWND hwnd,
+ UINT message,
+ WPARAM wParam,
+ LPARAM lParam)
{
LRESULT result;
WinButton *butPtr;
@@ -1191,70 +1237,80 @@ ButtonProc(hwnd, message, wParam, lParam)
butPtr = (WinButton *)((TkWindow*)tkwin)->instanceData;
switch(message) {
- case WM_ERASEBKGND:
- return 0;
-
- case BM_GETCHECK:
- if (((butPtr->info.type == TYPE_CHECK_BUTTON)
- || (butPtr->info.type == TYPE_RADIO_BUTTON))
- && butPtr->info.indicatorOn) {
- return (butPtr->info.flags & SELECTED)
- ? BST_CHECKED : BST_UNCHECKED;
- }
- return 0;
-
- case BM_GETSTATE: {
- DWORD state = 0;
- if (((butPtr->info.type == TYPE_CHECK_BUTTON)
- || (butPtr->info.type == TYPE_RADIO_BUTTON))
- && butPtr->info.indicatorOn) {
- state = (butPtr->info.flags & SELECTED)
+ case WM_ERASEBKGND:
+ return 0;
+
+ case BM_GETCHECK:
+ if (((butPtr->info.type == TYPE_CHECK_BUTTON)
+ || (butPtr->info.type == TYPE_RADIO_BUTTON))
+ && butPtr->info.indicatorOn) {
+ return (butPtr->info.flags & SELECTED)
? BST_CHECKED : BST_UNCHECKED;
- }
- if (butPtr->info.flags & GOT_FOCUS) {
- state |= BST_FOCUS;
- }
- return state;
}
- case WM_ENABLE:
- break;
+ return 0;
- case WM_PAINT: {
- PAINTSTRUCT ps;
- BeginPaint(hwnd, &ps);
- EndPaint(hwnd, &ps);
- TkpDisplayButton((ClientData)butPtr);
+ case BM_GETSTATE: {
+ DWORD state = 0;
- /*
- * Special note: must cancel any existing idle handler
- * for TkpDisplayButton; it's no longer needed, and
- * TkpDisplayButton cleared the REDRAW_PENDING flag.
- */
-
- Tcl_CancelIdleCall(TkpDisplayButton, (ClientData)butPtr);
- return 0;
+ if (((butPtr->info.type == TYPE_CHECK_BUTTON)
+ || (butPtr->info.type == TYPE_RADIO_BUTTON))
+ && butPtr->info.indicatorOn) {
+ state = (butPtr->info.flags & SELECTED)
+ ? BST_CHECKED : BST_UNCHECKED;
}
- case BN_CLICKED: {
- int code;
- Tcl_Interp *interp = butPtr->info.interp;
- if (butPtr->info.state != STATE_DISABLED) {
- Tcl_Preserve((ClientData)interp);
- code = TkInvokeButton((TkButton*)butPtr);
- if (code != TCL_OK && code != TCL_CONTINUE
- && code != TCL_BREAK) {
- Tcl_AddErrorInfo(interp, "\n (button invoke)");
- Tcl_BackgroundError(interp);
- }
- Tcl_Release((ClientData)interp);
- }
- Tcl_ServiceAll();
- return 0;
+ if (butPtr->info.flags & GOT_FOCUS) {
+ state |= BST_FOCUS;
}
+ return state;
+ }
+ case WM_ENABLE:
+ break;
+
+ case WM_PAINT: {
+ PAINTSTRUCT ps;
+ BeginPaint(hwnd, &ps);
+ EndPaint(hwnd, &ps);
+ TkpDisplayButton((ClientData)butPtr);
- default:
- if (Tk_TranslateWinEvent(hwnd, message, wParam, lParam, &result)) {
- return result;
+ /*
+ * Special note: must cancel any existing idle handler for
+ * TkpDisplayButton; it's no longer needed, and TkpDisplayButton
+ * cleared the REDRAW_PENDING flag.
+ */
+
+ Tcl_CancelIdleCall(TkpDisplayButton, (ClientData)butPtr);
+ return 0;
+ }
+ case BN_CLICKED: {
+ int code;
+ Tcl_Interp *interp = butPtr->info.interp;
+
+ if (butPtr->info.state != STATE_DISABLED) {
+ Tcl_Preserve((ClientData)interp);
+ code = TkInvokeButton((TkButton*)butPtr);
+ if (code != TCL_OK && code != TCL_CONTINUE
+ && code != TCL_BREAK) {
+ Tcl_AddErrorInfo(interp, "\n (button invoke)");
+ Tcl_BackgroundError(interp);
}
+ Tcl_Release((ClientData)interp);
+ }
+ Tcl_ServiceAll();
+ return 0;
+ }
+
+ default:
+ if (Tk_TranslateWinEvent(hwnd, message, wParam, lParam, &result)) {
+ return result;
+ }
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c
index b08147a..bb91f4d 100644
--- a/win/tkWinClipboard.c
+++ b/win/tkWinClipboard.c
@@ -1,4 +1,4 @@
-/*
+/*
* tkWinClipboard.c --
*
* This file contains functions for managing the clipboard.
@@ -6,30 +6,30 @@
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
* Copyright (c) 1998-2000 by Scriptics Corporation.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinClipboard.c,v 1.7 2000/04/12 18:51:11 hobbs Exp $
+ * RCS: @(#) $Id: tkWinClipboard.c,v 1.8 2005/12/02 00:19:04 dkf Exp $
*/
#include "tkWinInt.h"
#include "tkSelect.h"
-static void UpdateClipboard _ANSI_ARGS_((HWND hwnd));
+static void UpdateClipboard(HWND hwnd);
/*
*----------------------------------------------------------------------
*
* TkSelGetSelection --
*
- * Retrieve the specified selection from another process. For
- * now, only fetching XA_STRING from CLIPBOARD is supported.
- * Eventually other types should be allowed.
- *
+ * Retrieve the specified selection from another process. For now, only
+ * fetching XA_STRING from CLIPBOARD is supported. Eventually other types
+ * should be allowed.
+ *
* Results:
- * The return value is a standard Tcl return value.
- * If an error occurs (such as no selection exists)
- * then an error message is left in the interp's result.
+ * The return value is a standard Tcl return value. If an error occurs
+ * (such as no selection exists) then an error message is left in the
+ * interp's result.
*
* Side effects:
* None.
@@ -38,18 +38,17 @@ static void UpdateClipboard _ANSI_ARGS_((HWND hwnd));
*/
int
-TkSelGetSelection(interp, tkwin, selection, target, proc, clientData)
- Tcl_Interp *interp; /* Interpreter to use for reporting
- * errors. */
- Tk_Window tkwin; /* Window on whose behalf to retrieve
- * the selection (determines display
- * from which to retrieve). */
- Atom selection; /* Selection to retrieve. */
- Atom target; /* Desired form in which selection
- * is to be returned. */
- Tk_GetSelProc *proc; /* Procedure to call to process the
- * selection, once it has been retrieved. */
- ClientData clientData; /* Arbitrary value to pass to proc. */
+TkSelGetSelection(
+ Tcl_Interp *interp, /* Interpreter to use for reporting errors. */
+ Tk_Window tkwin, /* Window on whose behalf to retrieve the
+ * selection (determines display from which to
+ * retrieve). */
+ Atom selection, /* Selection to retrieve. */
+ Atom target, /* Desired form in which selection is to be
+ * returned. */
+ Tk_GetSelProc *proc, /* Procedure to call to process the selection,
+ * once it has been retrieved. */
+ ClientData clientData) /* Arbitrary value to pass to proc. */
{
char *data, *destPtr;
Tcl_DString ds;
@@ -64,8 +63,8 @@ TkSelGetSelection(interp, tkwin, selection, target, proc, clientData)
}
/*
- * Attempt to get the data in Unicode form if available as this is
- * less work that CF_TEXT.
+ * Attempt to get the data in Unicode form if available as this is less
+ * work that CF_TEXT.
*/
result = TCL_ERROR;
@@ -93,19 +92,17 @@ TkSelGetSelection(interp, tkwin, selection, target, proc, clientData)
}
/*
- * Get the locale identifier, determine the proper code page
- * to use, and find the corresponding encoding.
+ * Get the locale identifier, determine the proper code page to
+ * use, and find the corresponding encoding.
*/
Tcl_DStringInit(&ds);
Tcl_DStringAppend(&ds, "cp######", -1);
data = GlobalLock(handle);
-
/*
- * Even though the documentation claims that GetLocaleInfo
- * expects an LCID, on Windows 9x it really seems to expect
- * a LanguageID.
+ * Even though the documentation claims that GetLocaleInfo expects
+ * an LCID, on Windows 9x it really seems to expect a LanguageID.
*/
locale = LANGIDFROMLCID(*((int*)data));
@@ -146,7 +143,7 @@ TkSelGetSelection(interp, tkwin, selection, target, proc, clientData)
/*
* Translate CR/LF to LF.
*/
-
+
data = destPtr = Tcl_DStringValue(&ds);
while (*data) {
if (data[0] == '\r' && data[1] == '\n') {
@@ -165,12 +162,11 @@ TkSelGetSelection(interp, tkwin, selection, target, proc, clientData)
Tcl_DStringFree(&ds);
CloseClipboard();
return result;
-
-error:
+
+ error:
Tcl_AppendResult(interp, Tk_GetAtomName(tkwin, selection),
" selection doesn't exist or form \"",
- Tk_GetAtomName(tkwin, target),
- "\" not defined", (char *) NULL);
+ Tk_GetAtomName(tkwin, target), "\" not defined", NULL);
return TCL_ERROR;
}
@@ -179,9 +175,8 @@ error:
*
* TkSetSelectionOwner --
*
- * This function claims ownership of the specified selection.
- * If the selection is CLIPBOARD, then we empty the system
- * clipboard.
+ * This function claims ownership of the specified selection. If the
+ * selection is CLIPBOARD, then we empty the system clipboard.
*
* Results:
* None.
@@ -193,27 +188,26 @@ error:
*/
void
-XSetSelectionOwner(display, selection, owner, time)
- Display* display;
- Atom selection;
- Window owner;
- Time time;
+XSetSelectionOwner(
+ Display *display,
+ Atom selection,
+ Window owner,
+ Time time)
{
HWND hwnd = owner ? TkWinGetHWND(owner) : NULL;
Tk_Window tkwin;
/*
- * This is a gross hack because the Tk_InternAtom interface is broken.
- * It expects a Tk_Window, even though it only needs a Tk_Display.
+ * This is a gross hack because the Tk_InternAtom interface is broken. It
+ * expects a Tk_Window, even though it only needs a Tk_Display.
*/
tkwin = (Tk_Window) TkGetMainInfoList()->winPtr;
if (selection == Tk_InternAtom(tkwin, "CLIPBOARD")) {
-
/*
- * Only claim and empty the clipboard if we aren't already the
- * owner of the clipboard.
+ * Only claim and empty the clipboard if we aren't already the owner
+ * of the clipboard.
*/
if (GetClipboardOwner() != hwnd) {
@@ -227,8 +221,8 @@ XSetSelectionOwner(display, selection, owner, time)
*
* TkWinClipboardRender --
*
- * This function supplies the contents of the clipboard in
- * response to a WM_RENDERFORMAT message.
+ * This function supplies the contents of the clipboard in response to a
+ * WM_RENDERFORMAT message.
*
* Results:
* None.
@@ -240,9 +234,9 @@ XSetSelectionOwner(display, selection, owner, time)
*/
void
-TkWinClipboardRender(dispPtr, format)
- TkDisplay *dispPtr;
- UINT format;
+TkWinClipboardRender(
+ TkDisplay *dispPtr,
+ UINT format)
{
TkClipboardTarget *targetPtr;
TkClipboardBuffer *cbPtr;
@@ -253,13 +247,14 @@ TkWinClipboardRender(dispPtr, format)
for (targetPtr = dispPtr->clipTargetPtr; targetPtr != NULL;
targetPtr = targetPtr->nextPtr) {
- if (targetPtr->type == XA_STRING)
+ if (targetPtr->type == XA_STRING) {
break;
+ }
}
/*
- * Count the number of newlines so we can add space for them in
- * the resulting string.
+ * Count the number of newlines so we can add space for them in the
+ * resulting string.
*/
length = 0;
@@ -296,8 +291,8 @@ TkWinClipboardRender(dispPtr, format)
*buffer = '\0';
/*
- * Depending on the platform, turn the data into Unicode or the
- * system encoding before placing it on the clipboard.
+ * Depending on the platform, turn the data into Unicode or the system
+ * encoding before placing it on the clipboard.
*/
if (TkWinGetPlatformId() == VER_PLATFORM_WIN32_NT) {
@@ -330,8 +325,6 @@ TkWinClipboardRender(dispPtr, format)
Tcl_DStringFree(&ds);
SetClipboardData(CF_TEXT, handle);
}
-
- return;
}
/*
@@ -339,8 +332,8 @@ TkWinClipboardRender(dispPtr, format)
*
* TkSelUpdateClipboard --
*
- * This function is called to force the clipboard to be updated
- * after new data is added.
+ * This function is called to force the clipboard to be updated after new
+ * data is added.
*
* Results:
* None.
@@ -352,9 +345,9 @@ TkWinClipboardRender(dispPtr, format)
*/
void
-TkSelUpdateClipboard(winPtr, targetPtr)
- TkWindow *winPtr;
- TkClipboardTarget *targetPtr;
+TkSelUpdateClipboard(
+ TkWindow *winPtr,
+ TkClipboardTarget *targetPtr)
{
HWND hwnd = TkWinGetHWND(winPtr->window);
UpdateClipboard(hwnd);
@@ -365,8 +358,8 @@ TkSelUpdateClipboard(winPtr, targetPtr)
*
* UpdateClipboard --
*
- * Take ownership of the clipboard, clear it, and indicate to the
- * system the supported formats.
+ * Take ownership of the clipboard, clear it, and indicate to the system
+ * the supported formats.
*
* Results:
* None.
@@ -378,16 +371,16 @@ TkSelUpdateClipboard(winPtr, targetPtr)
*/
static void
-UpdateClipboard(hwnd)
- HWND hwnd;
+UpdateClipboard(
+ HWND hwnd)
{
TkWinUpdatingClipboard(TRUE);
OpenClipboard(hwnd);
EmptyClipboard();
/*
- * CF_UNICODETEXT is only supported on NT, but it it is prefered
- * when possible.
+ * CF_UNICODETEXT is only supported on NT, but it it is prefered when
+ * possible.
*/
if (TkWinGetPlatformId() == VER_PLATFORM_WIN32_NT) {
@@ -404,25 +397,22 @@ UpdateClipboard(hwnd)
*
* TkSelEventProc --
*
- * This procedure is invoked whenever a selection-related
- * event occurs.
+ * This procedure is invoked whenever a selection-related event occurs.
*
* Results:
* None.
*
* Side effects:
- * Lots: depends on the type of event.
+ * Lots: depends on the type of event.
*
*--------------------------------------------------------------
*/
void
-TkSelEventProc(tkwin, eventPtr)
- Tk_Window tkwin; /* Window for which event was
- * targeted. */
- register XEvent *eventPtr; /* X event: either SelectionClear,
- * SelectionRequest, or
- * SelectionNotify. */
+TkSelEventProc(
+ Tk_Window tkwin, /* Window for which event was targeted. */
+ register XEvent *eventPtr) /* X event: either SelectionClear,
+ * SelectionRequest, or SelectionNotify. */
{
if (eventPtr->type == SelectionClear) {
TkSelClearSelection(tkwin, eventPtr);
@@ -434,9 +424,8 @@ TkSelEventProc(tkwin, eventPtr)
*
* TkSelPropProc --
*
- * This procedure is invoked when property-change events
- * occur on windows not known to the toolkit. This is a stub
- * function under Windows.
+ * This procedure is invoked when property-change events occur on windows
+ * not known to the toolkit. This is a stub function under Windows.
*
* Results:
* None.
@@ -448,7 +437,15 @@ TkSelEventProc(tkwin, eventPtr)
*/
void
-TkSelPropProc(eventPtr)
- register XEvent *eventPtr; /* X PropertyChange event. */
+TkSelPropProc(
+ register XEvent *eventPtr) /* X PropertyChange event. */
{
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/win/tkWinColor.c b/win/tkWinColor.c
index 134176f..ee033f3 100644
--- a/win/tkWinColor.c
+++ b/win/tkWinColor.c
@@ -1,4 +1,4 @@
-/*
+/*
* tkWinColor.c --
*
* Functions to map color names to system color values.
@@ -6,10 +6,10 @@
* Copyright (c) 1995 Sun Microsystems, Inc.
* Copyright (c) 1994 Software Research Associates, Inc.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinColor.c,v 1.7 2004/01/13 02:06:01 davygrvy Exp $
+ * RCS: @(#) $Id: tkWinColor.c,v 1.8 2005/12/02 00:19:04 dkf Exp $
*/
#include "tkWinInt.h"
@@ -22,15 +22,14 @@
typedef struct WinColor {
TkColor info; /* Generic color information. */
- int index; /* Index for GetSysColor(), -1 if color
- * is not a "live" system color. */
+ int index; /* Index for GetSysColor(), -1 if color is not
+ * a "live" system color. */
} WinColor;
/*
- * The sysColors array contains the names and index values for the
- * Windows indirect system color names. In use, all of the names
- * will have the string "System" prepended, but we omit it in the table
- * to save space.
+ * The sysColors array contains the names and index values for the Windows
+ * indirect system color names. In use, all of the names will have the string
+ * "System" prepended, but we omit it in the table to save space.
*/
typedef struct {
@@ -38,7 +37,6 @@ typedef struct {
int index;
} SystemColorEntry;
-
static SystemColorEntry sysColors[] = {
"3dDarkShadow", COLOR_3DDKSHADOW,
"3dLight", COLOR_3DLIGHT,
@@ -69,7 +67,7 @@ static SystemColorEntry sysColors[] = {
NULL, 0
};
-typedef struct ThreadSpecificData {
+typedef struct ThreadSpecificData {
int ncolors;
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
@@ -78,20 +76,20 @@ static Tcl_ThreadDataKey dataKey;
* Forward declarations for functions defined later in this file.
*/
-static int FindSystemColor _ANSI_ARGS_((const char *name,
- XColor *colorPtr, int *indexPtr));
+static int FindSystemColor(const char *name, XColor *colorPtr,
+ int *indexPtr);
/*
*----------------------------------------------------------------------
*
* FindSystemColor --
*
- * This routine finds the color entry that corresponds to the
- * specified color.
+ * This routine finds the color entry that corresponds to the specified
+ * color.
*
* Results:
- * Returns non-zero on success. The RGB values of the XColor
- * will be initialized to the proper values on success.
+ * Returns non-zero on success. The RGB values of the XColor will be
+ * initialized to the proper values on success.
*
* Side effects:
* None.
@@ -100,18 +98,18 @@ static int FindSystemColor _ANSI_ARGS_((const char *name,
*/
static int
-FindSystemColor(name, colorPtr, indexPtr)
- const char *name; /* Color name. */
- XColor *colorPtr; /* Where to store results. */
- int *indexPtr; /* Out parameter to store color index. */
+FindSystemColor(
+ const char *name, /* Color name. */
+ XColor *colorPtr, /* Where to store results. */
+ int *indexPtr) /* Out parameter to store color index. */
{
int l, u, r, i;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
- * Count the number of elements in the color array if we haven't
- * done so yet.
+ * Count the number of elements in the color array if we haven't done so
+ * yet.
*/
if (tsdPtr->ncolors == 0) {
@@ -154,10 +152,12 @@ FindSystemColor(name, colorPtr, indexPtr)
*indexPtr = sysColors[i].index;
colorPtr->pixel = GetSysColor(sysColors[i].index);
+
/*
- * x257 is (value<<8 + value) to get the properly bit shifted
- * and padded value. [Bug: 4919]
+ * x257 is (value<<8 + value) to get the properly bit shifted and padded
+ * value. [Bug: 4919]
*/
+
colorPtr->red = GetRValue(colorPtr->pixel) * 257;
colorPtr->green = GetGValue(colorPtr->pixel) * 257;
colorPtr->blue = GetBValue(colorPtr->pixel) * 257;
@@ -178,27 +178,26 @@ FindSystemColor(name, colorPtr, indexPtr)
*
* Side effects:
* May invalidate the colormap cache associated with tkwin upon
- * allocating a new colormap entry. Allocates a new TkColor
- * structure.
+ * allocating a new colormap entry. Allocates a new TkColor structure.
*
*----------------------------------------------------------------------
*/
TkColor *
-TkpGetColor(tkwin, name)
- Tk_Window tkwin; /* Window in which color will be used. */
- Tk_Uid name; /* Name of color to allocated (in form
+TkpGetColor(
+ Tk_Window tkwin, /* Window in which color will be used. */
+ Tk_Uid name) /* Name of color to allocated (in form
* suitable for passing to XParseColor). */
{
WinColor *winColPtr;
XColor color;
int index = -1; /* -1 indicates that this is not an indirect
- * sytem color. */
+ * system color. */
/*
- * Check to see if it is a system color or an X color string. If the
- * color is found, allocate a new WinColor and store the XColor and the
- * system color index.
+ * Check to see if it is a system color or an X color string. If the color
+ * is found, allocate a new WinColor and store the XColor and the system
+ * color index.
*/
if (((strncasecmp(name, "system", 6) == 0)
@@ -211,7 +210,7 @@ TkpGetColor(tkwin, name)
XAllocColor(Tk_Display(tkwin), Tk_Colormap(tkwin),
&winColPtr->info.color);
- return (TkColor *) winColPtr;
+ return (TkColor *) winColPtr;
}
return (TkColor *) NULL;
}
@@ -221,27 +220,26 @@ TkpGetColor(tkwin, name)
*
* TkpGetColorByValue --
*
- * Given a desired set of red-green-blue intensities for a color,
- * locate a pixel value to use to draw that color in a given
- * window.
+ * Given a desired set of red-green-blue intensities for a color, locate
+ * a pixel value to use to draw that color in a given window.
*
* Results:
- * The return value is a pointer to an TkColor structure that
- * indicates the closest red, blue, and green intensities available
- * to those specified in colorPtr, and also specifies a pixel
- * value to use to draw in that color.
+ * The return value is a pointer to an TkColor structure that indicates
+ * the closest red, blue, and green intensities available to those
+ * specified in colorPtr, and also specifies a pixel value to use to draw
+ * in that color.
*
* Side effects:
- * May invalidate the colormap cache for the specified window.
- * Allocates a new TkColor structure.
+ * May invalidate the colormap cache for the specified window. Allocates
+ * a new TkColor structure.
*
*----------------------------------------------------------------------
*/
TkColor *
-TkpGetColorByValue(tkwin, colorPtr)
- Tk_Window tkwin; /* Window in which color will be used. */
- XColor *colorPtr; /* Red, green, and blue fields indicate
+TkpGetColorByValue(
+ Tk_Window tkwin, /* Window in which color will be used. */
+ XColor *colorPtr) /* Red, green, and blue fields indicate
* desired color. */
{
WinColor *tkColPtr = (WinColor *) ckalloc(sizeof(WinColor));
@@ -266,15 +264,15 @@ TkpGetColorByValue(tkwin, colorPtr)
* None
*
* Side effects:
- * Invalidates the colormap cache for the colormap associated with
- * the given color.
+ * Invalidates the colormap cache for the colormap associated with the
+ * given color.
*
*----------------------------------------------------------------------
*/
void
-TkpFreeColor(tkColPtr)
- TkColor *tkColPtr; /* Color to be released. Must have been
+TkpFreeColor(
+ TkColor *tkColPtr) /* Color to be released. Must have been
* allocated by TkpGetColor or
* TkpGetColorByValue. */
{
@@ -289,13 +287,13 @@ TkpFreeColor(tkColPtr)
*
* TkWinIndexOfColor --
*
- * Given a color, return the system color index that was used
- * to create the color.
+ * Given a color, return the system color index that was used to create
+ * the color.
*
* Results:
- * If the color was allocated using a system indirect color name,
- * then the corresponding GetSysColor() index is returned.
- * Otherwise, -1 is returned.
+ * If the color was allocated using a system indirect color name, then
+ * the corresponding GetSysColor() index is returned. Otherwise, -1 is
+ * returned.
*
* Side effects:
* None.
@@ -304,13 +302,13 @@ TkpFreeColor(tkColPtr)
*/
int
-TkWinIndexOfColor(colorPtr)
- XColor *colorPtr;
+TkWinIndexOfColor(
+ XColor *colorPtr)
{
register WinColor *winColPtr = (WinColor *) colorPtr;
if (winColPtr->info.magic == COLOR_MAGIC) {
return winColPtr->index;
- }
+ }
return -1;
}
@@ -322,8 +320,8 @@ TkWinIndexOfColor(colorPtr)
* Find the closest available color to the specified XColor.
*
* Results:
- * Updates the color argument and returns 1 on success. Otherwise
- * returns 0.
+ * Updates the color argument and returns 1 on success. Otherwise returns
+ * 0.
*
* Side effects:
* Allocates a new color in the palette.
@@ -332,10 +330,10 @@ TkWinIndexOfColor(colorPtr)
*/
int
-XAllocColor(display, colormap, color)
- Display* display;
- Colormap colormap;
- XColor* color;
+XAllocColor(
+ Display *display,
+ Colormap colormap,
+ XColor *color)
{
TkWinColormap *cmap = (TkWinColormap *) colormap;
PALETTEENTRY entry, closeEntry;
@@ -356,7 +354,7 @@ XAllocColor(display, colormap, color)
/*
* Find the nearest existing palette entry.
*/
-
+
newPixel = RGB(entry.peRed, entry.peGreen, entry.peBlue);
index = GetNearestPaletteIndex(cmap->palette, newPixel);
GetPaletteEntries(cmap->palette, index, 1, &closeEntry);
@@ -364,15 +362,14 @@ XAllocColor(display, colormap, color)
closeEntry.peBlue);
/*
- * If this is not a duplicate, allocate a new entry. Note that
- * we may get values for index that are above the current size
- * of the palette. This happens because we don't shrink the size of
- * the palette object when we deallocate colors so there may be
- * stale values that match in the upper slots. We should ignore
- * those values and just put the new color in as if the colors
- * had not matched.
+ * If this is not a duplicate, allocate a new entry. Note that we may
+ * get values for index that are above the current size of the
+ * palette. This happens because we don't shrink the size of the
+ * palette object when we deallocate colors so there may be stale
+ * values that match in the upper slots. We should ignore those values
+ * and just put the new color in as if the colors had not matched.
*/
-
+
if ((index >= cmap->size) || (newPixel != closePixel)) {
if (cmap->size == sizePalette) {
color->red = closeEntry.peRed * 257;
@@ -399,11 +396,10 @@ XAllocColor(display, colormap, color)
}
Tcl_SetHashValue(entryPtr, (ClientData)refCount);
} else {
-
/*
* Determine what color will actually be used on non-colormap systems.
*/
-
+
color->pixel = GetNearestColor(dc,
RGB(entry.peRed, entry.peGreen, entry.peBlue));
color->red = GetRValue(color->pixel) * 257;
@@ -426,19 +422,19 @@ XAllocColor(display, colormap, color)
* None.
*
* Side effects:
- * Removes entries for the current palette and compacts the
- * remaining set.
+ * Removes entries for the current palette and compacts the remaining
+ * set.
*
*----------------------------------------------------------------------
*/
void
-XFreeColors(display, colormap, pixels, npixels, planes)
- Display* display;
- Colormap colormap;
- unsigned long* pixels;
- int npixels;
- unsigned long planes;
+XFreeColors(
+ Display *display,
+ Colormap colormap;,
+ unsigned long *pixels,
+ int npixels,
+ unsigned long planes)
{
TkWinColormap *cmap = (TkWinColormap *) colormap;
COLORREF cref;
@@ -451,16 +447,14 @@ XFreeColors(display, colormap, pixels, npixels, planes)
/*
* We don't have to do anything for non-palette devices.
*/
-
- if (GetDeviceCaps(dc, RASTERCAPS) & RC_PALETTE) {
+ if (GetDeviceCaps(dc, RASTERCAPS) & RC_PALETTE) {
/*
* This is really slow for large values of npixels.
*/
for (i = 0; i < npixels; i++) {
- entryPtr = Tcl_FindHashEntry(&cmap->refCounts,
- (char *) pixels[i]);
+ entryPtr = Tcl_FindHashEntry(&cmap->refCounts, (char *) pixels[i]);
if (!entryPtr) {
Tcl_Panic("Tried to free a color that isn't allocated.");
}
@@ -471,8 +465,8 @@ XFreeColors(display, colormap, pixels, npixels, planes)
GetPaletteEntries(cmap->palette, index, 1, &entry);
if (cref == RGB(entry.peRed, entry.peGreen, entry.peBlue)) {
count = cmap->size - index;
- entries = (PALETTEENTRY *) ckalloc(sizeof(PALETTEENTRY)
- * count);
+ entries = (PALETTEENTRY *)
+ ckalloc(sizeof(PALETTEENTRY) * count);
GetPaletteEntries(cmap->palette, index+1, count, entries);
SetPaletteEntries(cmap->palette, index, count, entries);
ckfree((char *) entries);
@@ -506,11 +500,11 @@ XFreeColors(display, colormap, pixels, npixels, planes)
*/
Colormap
-XCreateColormap(display, w, visual, alloc)
- Display* display;
- Window w;
- Visual* visual;
- int alloc;
+XCreateColormap(
+ Display *display,
+ Window w,
+ Visual *visual,
+ int alloc)
{
char logPalBuf[sizeof(LOGPALETTE) + 256 * sizeof(PALETTEENTRY)];
LOGPALETTE *logPalettePtr;
@@ -544,7 +538,7 @@ XCreateColormap(display, w, visual, alloc)
for (i = 0; i < logPalettePtr->palNumEntries; i++) {
entryPtr = logPalettePtr->palPalEntry + i;
hashPtr = Tcl_CreateHashEntry(&cmap->refCounts, (char*) PALETTERGB(
- entryPtr->peRed, entryPtr->peGreen, entryPtr->peBlue), &new);
+ entryPtr->peRed, entryPtr->peGreen, entryPtr->peBlue), &new);
Tcl_SetHashValue(hashPtr, (ClientData)1);
}
@@ -562,19 +556,19 @@ XCreateColormap(display, w, visual, alloc)
* None.
*
* Side effects:
- * Deletes the palette associated with the colormap. Note that
- * the palette must not be selected into a device context when
- * this occurs.
+ * Deletes the palette associated with the colormap. Note that the
+ * palette must not be selected into a device context when this occurs.
*
*----------------------------------------------------------------------
*/
void
-XFreeColormap(display, colormap)
- Display* display;
- Colormap colormap;
+XFreeColormap(
+ Display *display,
+ Colormap colormap)
{
TkWinColormap *cmap = (TkWinColormap *) colormap;
+
if (!DeleteObject(cmap->palette)) {
Tcl_Panic("Unable to free colormap, palette is still selected.");
}
@@ -587,10 +581,9 @@ XFreeColormap(display, colormap)
*
* TkWinSelectPalette --
*
- * This function sets up the specified device context with a
- * given palette. If the palette is stale, it realizes it in
- * the background unless the palette is the current global
- * palette.
+ * This function sets up the specified device context with a given
+ * palette. If the palette is stale, it realizes it in the background
+ * unless the palette is the current global palette.
*
* Results:
* Returns the previous palette selected into the device context.
@@ -602,9 +595,9 @@ XFreeColormap(display, colormap)
*/
HPALETTE
-TkWinSelectPalette(dc, colormap)
- HDC dc;
- Colormap colormap;
+TkWinSelectPalette(
+ HDC dc,
+ Colormap colormap)
{
TkWinColormap *cmap = (TkWinColormap *) colormap;
HPALETTE oldPalette;
@@ -614,3 +607,11 @@ TkWinSelectPalette(dc, colormap)
RealizePalette(dc);
return oldPalette;
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/win/tkWinConfig.c b/win/tkWinConfig.c
index 0e12ba2..967ee86 100644
--- a/win/tkWinConfig.c
+++ b/win/tkWinConfig.c
@@ -1,15 +1,15 @@
-/*
+/*
* tkWinConfig.c --
*
- * This module implements the Windows system defaults for
- * the configuration package.
+ * This module implements the Windows system defaults for the
+ * configuration package.
*
* Copyright (c) 1997 by Sun Microsystems, Inc.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinConfig.c,v 1.3 2002/08/05 04:30:41 dgp Exp $
+ * RCS: @(#) $Id: tkWinConfig.c,v 1.4 2005/12/02 00:19:04 dkf Exp $
*/
#include "tk.h"
@@ -22,13 +22,13 @@
*
* TkpGetSystemDefault --
*
- * Given a dbName and className for a configuration option,
- * return a string representation of the option.
+ * Given a dbName and className for a configuration option, return a
+ * string representation of the option.
*
* Results:
- * Returns a Tk_Uid that is the string identifier that identifies
- * this option. Returns NULL if there are no system defaults
- * that match this pair.
+ * Returns a Tk_Uid that is the string identifier that identifies this
+ * option. Returns NULL if there are no system defaults that match this
+ * pair.
*
* Side effects:
* None, once the package is initialized.
@@ -40,7 +40,7 @@ Tcl_Obj *
TkpGetSystemDefault(
Tk_Window tkwin, /* A window to use. */
CONST char *dbName, /* The option database name. */
- CONST char *className) /* The name of the option class. */
+ CONST char *className) /* The name of the option class. */
{
Tcl_Obj *valueObjPtr;
Tk_Uid classUid;
@@ -58,3 +58,11 @@ TkpGetSystemDefault(
return valueObjPtr;
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/win/tkWinCursor.c b/win/tkWinCursor.c
index 73ae25c..653fbbe 100644
--- a/win/tkWinCursor.c
+++ b/win/tkWinCursor.c
@@ -1,21 +1,21 @@
-/*
+/*
* tkWinCursor.c --
*
* This file contains Win32 specific cursor related routines.
*
* Copyright (c) 1995 Sun Microsystems, Inc.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinCursor.c,v 1.12 2003/07/24 02:10:01 patthoyts Exp $
+ * RCS: @(#) $Id: tkWinCursor.c,v 1.13 2005/12/02 00:19:04 dkf Exp $
*/
#include "tkWinInt.h"
/*
- * The following data structure contains the system specific data
- * necessary to control Windows cursors.
+ * The following data structure contains the system specific data necessary to
+ * control Windows cursors.
*/
typedef struct {
@@ -25,16 +25,17 @@ typedef struct {
} TkWinCursor;
/*
- * The HAND cursor is only present when WINVER >= 0x0500. If this is
- * not available at runtime, it will default to the unix-style cursor.
+ * The HAND cursor is only present when WINVER >= 0x0500. If this is not
+ * available at runtime, it will default to the unix-style cursor.
*/
+
#ifndef IDC_HAND
#define IDC_HAND MAKEINTRESOURCE(32649)
#endif
/*
- * The table below is used to map from the name of a predefined cursor
- * to its resource identifier.
+ * The table below is used to map from the name of a predefined cursor to its
+ * resource identifier.
*/
static struct CursorName {
@@ -76,10 +77,10 @@ static struct CursorName {
*
* TkGetCursorByName --
*
- * Retrieve a system cursor by name.
+ * Retrieve a system cursor by name.
*
* Results:
- * Returns a new cursor, or NULL on errors.
+ * Returns a new cursor, or NULL on errors.
*
* Side effects:
* Allocates a new cursor.
@@ -88,11 +89,11 @@ static struct CursorName {
*/
TkCursor *
-TkGetCursorByName(interp, tkwin, string)
- Tcl_Interp *interp; /* Interpreter to use for error reporting. */
- Tk_Window tkwin; /* Window in which cursor will be used. */
- Tk_Uid string; /* Description of cursor. See manual entry
- * for details on legal syntax. */
+TkGetCursorByName(
+ Tcl_Interp *interp, /* Interpreter to use for error reporting. */
+ Tk_Window tkwin, /* Window in which cursor will be used. */
+ Tk_Uid string) /* Description of cursor. See manual entry for
+ * details on legal syntax. */
{
struct CursorName *namePtr;
TkWinCursor *cursorPtr;
@@ -118,8 +119,8 @@ TkGetCursorByName(interp, tkwin, string)
if (argv[0][0] == '@') {
/*
- * Check for system cursor of type @<filename>, where only
- * the name is allowed. This accepts any of:
+ * Check for system cursor of type @<filename>, where only the name is
+ * allowed. This accepts any of:
* -cursor @/winnt/cursors/globe.ani
* -cursor @C:/Winnt/cursors/E_arrow.cur
* -cursor {@C:/Program\ Files/Cursors/bart.ani}
@@ -129,7 +130,7 @@ TkGetCursorByName(interp, tkwin, string)
if (Tcl_IsSafe(interp)) {
Tcl_AppendResult(interp, "can't get cursor from a file in",
- " a safe interpreter", (char *) NULL);
+ " a safe interpreter", NULL);
ckfree((char *) argv);
ckfree((char *) cursorPtr);
return NULL;
@@ -139,6 +140,7 @@ TkGetCursorByName(interp, tkwin, string)
/*
* Check for the cursor in the system cursor set.
*/
+
for (namePtr = cursorNames; namePtr->name != NULL; namePtr++) {
if (strcmp(namePtr->name, argv[0]) == 0) {
cursorPtr->winCursor = LoadCursor(NULL, namePtr->id);
@@ -148,9 +150,10 @@ TkGetCursorByName(interp, tkwin, string)
if (cursorPtr->winCursor == NULL) {
/*
- * Hmm, it is not in the system cursor set. Check to see
- * if it is one of our application resources.
+ * Hmm, it is not in the system cursor set. Check to see if it is
+ * one of our application resources.
*/
+
cursorPtr->winCursor = LoadCursor(Tk_GetHINSTANCE(), argv[0]);
} else {
cursorPtr->system = 1;
@@ -161,8 +164,7 @@ TkGetCursorByName(interp, tkwin, string)
ckfree((char *) cursorPtr);
badCursorSpec:
ckfree((char *) argv);
- Tcl_AppendResult(interp, "bad cursor spec \"", string, "\"",
- (char *) NULL);
+ Tcl_AppendResult(interp, "bad cursor spec \"", string, "\"", NULL);
return NULL;
} else {
ckfree((char *) argv);
@@ -187,15 +189,14 @@ TkGetCursorByName(interp, tkwin, string)
*/
TkCursor *
-TkCreateCursorFromData(tkwin, source, mask, width, height, xHot, yHot,
- fgColor, bgColor)
- Tk_Window tkwin; /* Window in which cursor will be used. */
- CONST char *source; /* Bitmap data for cursor shape. */
- CONST char *mask; /* Bitmap data for cursor mask. */
- int width, height; /* Dimensions of cursor. */
- int xHot, yHot; /* Location of hot-spot in cursor. */
- XColor fgColor; /* Foreground color for cursor. */
- XColor bgColor; /* Background color for cursor. */
+TkCreateCursorFromData(
+ Tk_Window tkwin, /* Window in which cursor will be used. */
+ CONST char *source, /* Bitmap data for cursor shape. */
+ CONST char *mask, /* Bitmap data for cursor mask. */
+ int width, int height, /* Dimensions of cursor. */
+ int xHot, int yHot, /* Location of hot-spot in cursor. */
+ XColor fgColor, /* Foreground color for cursor. */
+ XColor bgColor) /* Background color for cursor. */
{
return NULL;
}
@@ -218,8 +219,8 @@ TkCreateCursorFromData(tkwin, source, mask, width, height, xHot, yHot,
*/
void
-TkpFreeCursor(cursorPtr)
- TkCursor *cursorPtr;
+TkpFreeCursor(
+ TkCursor *cursorPtr)
{
TkWinCursor *winCursorPtr = (TkWinCursor *) cursorPtr;
}
@@ -229,8 +230,8 @@ TkpFreeCursor(cursorPtr)
*
* TkpSetCursor --
*
- * Set the global cursor. If the cursor is None, then use the
- * default Tk cursor.
+ * Set the global cursor. If the cursor is None, then use the default Tk
+ * cursor.
*
* Results:
* None.
@@ -242,8 +243,8 @@ TkpFreeCursor(cursorPtr)
*/
void
-TkpSetCursor(cursor)
- TkpCursor cursor;
+TkpSetCursor(
+ TkpCursor cursor)
{
HCURSOR hcursor;
TkWinCursor *winCursor = (TkWinCursor *) cursor;
@@ -258,3 +259,11 @@ TkpSetCursor(cursor)
SetCursor(hcursor);
}
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c
index 2664351..9183f20 100644
--- a/win/tkWinDialog.c
+++ b/win/tkWinDialog.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinDialog.c,v 1.42 2005/11/11 05:13:44 chengyemao Exp $
+ * RCS: @(#) $Id: tkWinDialog.c,v 1.43 2005/12/02 00:19:04 dkf Exp $
*
*/
@@ -121,6 +121,26 @@ static const struct {int type; int btnIds[3];} allowedTypes[] = {
#define NUM_TYPES (sizeof(allowedTypes) / sizeof(allowedTypes[0]))
/*
+ * Abstract trivial differences between Win32 and Win64.
+ */
+
+#ifdef _WIN64
+#define TkWinGetHInstance(from) \
+ ((HINSTANCE) GetWindowLongPtr((from), GWLP_HINSTANCE))
+#define TkWinGetUserData(from) \
+ GetWindowLongPtr((from), GWLP_USERDATA)
+#define TkWinSetUserData(to,what) \
+ SetWindowLongPtr((to), GWLP_USERDATA, (LPARAM)(what))
+#else
+#define TkWinGetHInstance(from) \
+ ((HINSTANCE) GetWindowLong((from), GWL_HINSTANCE))
+#define TkWinGetUserData(from) \
+ GetWindowLong((from), GWL_USERDATA)
+#define TkWinSetUserData(to,what) \
+ SetWindowLong((to), GWL_USERDATA, (LPARAM)(what))
+#endif
+
+/*
* The value of TK_MULTI_MAX_PATH dictactes how many files can be retrieved
* with tk_get*File -multiple 1. It must be allocated on the stack, so make it
* large enough but not too large. - hobbs
@@ -697,11 +717,7 @@ GetFileNameW(
ZeroMemory(&ofn, sizeof(OPENFILENAMEW));
ofn.lStructSize = sizeof(OPENFILENAMEW);
ofn.hwndOwner = hWnd;
-#ifdef _WIN64
- ofn.hInstance = (HINSTANCE) GetWindowLongPtr(ofn.hwndOwner,GWLP_HINSTANCE);
-#else
- ofn.hInstance = (HINSTANCE) GetWindowLong(ofn.hwndOwner, GWL_HINSTANCE);
-#endif
+ ofn.hInstance = TkWinGetHInstance(ofn.hwndOwner);
ofn.lpstrFile = (WCHAR *) file;
ofn.nMaxFile = TK_MULTI_MAX_PATH;
ofn.Flags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR
@@ -935,11 +951,7 @@ OFNHookProcW(
OPENFILENAMEW *ofnPtr;
if (uMsg == WM_INITDIALOG) {
-#ifdef _WIN64
- SetWindowLongPtr(hdlg, GWLP_USERDATA, lParam);
-#else
- SetWindowLong(hdlg, GWL_USERDATA, lParam);
-#endif
+ TkWinSetUserData(hdlg, lParam);
} else if (uMsg == WM_WINDOWPOSCHANGED) {
/*
* This message is delivered at the right time to enable Tk to set the
@@ -947,20 +959,12 @@ OFNHookProcW(
* information every time it gets a WM_WINDOWPOSCHANGED message.
*/
-#ifdef _WIN64
- ofnPtr = (OPENFILENAMEW *) GetWindowLongPtr(hdlg, GWLP_USERDATA);
-#else
- ofnPtr = (OPENFILENAMEW *) GetWindowLong(hdlg, GWL_USERDATA);
-#endif
+ ofnPtr = (OPENFILENAMEW *) TkWinGetUserData(hdlg);
if (ofnPtr != NULL) {
hdlg = GetParent(hdlg);
tsdPtr->debugInterp = (Tcl_Interp *) ofnPtr->lCustData;
Tcl_DoWhenIdle(SetTkDialog, (ClientData) hdlg);
-#ifdef _WIN64
- SetWindowLongPtr(hdlg, GWLP_USERDATA, (LPARAM) NULL);
-#else
- SetWindowLong(hdlg, GWL_USERDATA, (LPARAM) NULL);
-#endif
+ TkWinSetUserData(hdlg, NULL);
}
}
return 0;
@@ -1132,11 +1136,7 @@ GetFileNameA(
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hWnd;
-#ifdef _WIN64
- ofn.hInstance = (HINSTANCE) GetWindowLongPtr(ofn.hwndOwner,GWLP_HINSTANCE);
-#else
- ofn.hInstance = (HINSTANCE) GetWindowLong(ofn.hwndOwner, GWL_HINSTANCE);
-#endif
+ ofn.hInstance = TkWinGetHInstance(ofn.hwndOwner);
ofn.lpstrFilter = NULL;
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
@@ -1379,11 +1379,7 @@ OFNHookProc(
OPENFILENAME *ofnPtr;
if (uMsg == WM_INITDIALOG) {
-#ifdef _WIN64
- SetWindowLongPtr(hdlg, GWLP_USERDATA, lParam);
-#else
- SetWindowLong(hdlg, GWL_USERDATA, lParam);
-#endif
+ TkWinSetUserData(hdlg, lParam);
} else if (uMsg == WM_WINDOWPOSCHANGED) {
/*
* This message is delivered at the right time to both old-style and
@@ -1392,22 +1388,14 @@ OFNHookProc(
* every time it gets a WM_WINDOWPOSCHANGED message.
*/
-#ifdef _WIN64
- ofnPtr = (OPENFILENAME *) GetWindowLongPtr(hdlg, GWLP_USERDATA);
-#else
- ofnPtr = (OPENFILENAME *) GetWindowLong(hdlg, GWL_USERDATA);
-#endif
+ ofnPtr = (OPENFILENAME *) TkWinGetUserData(hdlg);
if (ofnPtr != NULL) {
if (ofnPtr->Flags & OFN_EXPLORER) {
hdlg = GetParent(hdlg);
}
tsdPtr->debugInterp = (Tcl_Interp *) ofnPtr->lCustData;
Tcl_DoWhenIdle(SetTkDialog, (ClientData) hdlg);
-#ifdef _WIN64
- SetWindowLongPtr(hdlg, GWLP_USERDATA, (LPARAM) NULL);
-#else
- SetWindowLong(hdlg, GWL_USERDATA, (LPARAM) NULL);
-#endif
+ TkWinSetUserData(hdlg, NULL);
}
}
return 0;
@@ -1859,11 +1847,7 @@ ChooseDirectoryValidateProc(
chooseDirSharedData = (CHOOSEDIRDATA *)lpData;
-#ifdef _WIN64
- SetWindowLongPtr(hwnd, GWLP_USERDATA, lpData);
-#else
- SetWindowLong(hwnd, GWL_USERDATA, lpData);
-#endif
+ TkWinSetUserData(hwnd, lpData);
if (tsdPtr->debugFlag) {
tsdPtr->debugInterp = (Tcl_Interp *) chooseDirSharedData->interp;
@@ -2264,6 +2248,7 @@ ConvertExternalFilename(
* Change the pathname to the Tcl "normalized" pathname, where back
* slashes are used instead of forward slashes
*/
+
if (*p == '\\') {
*p = '/';
}
diff --git a/win/tkWinDraw.c b/win/tkWinDraw.c
index e1ef315..cf97f8f 100644
--- a/win/tkWinDraw.c
+++ b/win/tkWinDraw.c
@@ -1,16 +1,16 @@
-/*
+/*
* tkWinDraw.c --
*
- * This file contains the Xlib emulation functions pertaining to
- * actually drawing objects on a window.
+ * This file contains the Xlib emulation functions pertaining to actually
+ * drawing objects on a window.
*
* Copyright (c) 1995 Sun Microsystems, Inc.
* Copyright (c) 1994 Software Research Associates, Inc.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinDraw.c,v 1.15 2005/08/09 07:39:23 das Exp $
+ * RCS: @(#) $Id: tkWinDraw.c,v 1.16 2005/12/02 00:19:04 dkf Exp $
*/
#include "tkWinInt.h"
@@ -46,9 +46,9 @@ int tkpWinRopModes[] = {
};
/*
- * Translation table between X gc functions and Win32 BitBlt op modes. Some
- * of the operations defined in X don't have names, so we have to construct
- * new opcodes for those functions. This is arcane and probably not all that
+ * Translation table between X gc functions and Win32 BitBlt op modes. Some of
+ * the operations defined in X don't have names, so we have to construct new
+ * opcodes for those functions. This is arcane and probably not all that
* useful, but at least it's accurate.
*/
@@ -77,9 +77,9 @@ int tkpWinBltModes[] = {
};
/*
- * The following raster op uses the source bitmap as a mask for the
- * pattern. This is used to draw in a foreground color but leave the
- * background color transparent.
+ * The following raster op uses the source bitmap as a mask for the pattern.
+ * This is used to draw in a foreground color but leave the background color
+ * transparent.
*/
#define MASKPAT 0x00E20746 /* dest = (src & pat) | (!src & dst) */
@@ -103,29 +103,27 @@ int tkpWinBltModes[] = {
* The followng typedef is used to pass Windows GDI drawing functions.
*/
-typedef BOOL (CALLBACK *WinDrawFunc) _ANSI_ARGS_((HDC dc,
- CONST POINT* points, int npoints));
+typedef BOOL (CALLBACK *WinDrawFunc)(HDC dc, CONST POINT* points, int npoints);
typedef struct ThreadSpecificData {
- POINT *winPoints; /* Array of points that is reused. */
- int nWinPoints; /* Current size of point array. */
+ POINT *winPoints; /* Array of points that is reused. */
+ int nWinPoints; /* Current size of point array. */
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
/*
- * Forward declarations for procedures defined in this file:
+ * Forward declarations for functions defined in this file:
*/
-static POINT * ConvertPoints _ANSI_ARGS_((XPoint *points, int npoints,
- int mode, RECT *bbox));
-static void DrawOrFillArc _ANSI_ARGS_((Display *display,
- Drawable d, GC gc, int x, int y,
- unsigned int width, unsigned int height,
- int start, int extent, int fill));
-static void RenderObject _ANSI_ARGS_((HDC dc, GC gc,
- XPoint* points, int npoints, int mode, HPEN pen,
- WinDrawFunc func));
-static HPEN SetUpGraphicsPort _ANSI_ARGS_((GC gc));
+static POINT * ConvertPoints(XPoint *points, int npoints, int mode,
+ RECT *bbox);
+static void DrawOrFillArc(Display *display, Drawable d, GC gc,
+ int x, int y, unsigned int width,
+ unsigned int height, int start, int extent,
+ int fill);
+static void RenderObject(HDC dc, GC gc, XPoint* points,
+ int npoints, int mode, HPEN pen, WinDrawFunc func);
+static HPEN SetUpGraphicsPort(GC gc);
/*
*----------------------------------------------------------------------
@@ -135,21 +133,21 @@ static HPEN SetUpGraphicsPort _ANSI_ARGS_((GC gc));
* Retrieve the DC from a drawable.
*
* Results:
- * Returns the window DC for windows. Returns a new memory DC
- * for pixmaps.
+ * Returns the window DC for windows. Returns a new memory DC for
+ * pixmaps.
*
* Side effects:
- * Sets up the palette for the device context, and saves the old
- * device context state in the passed in TkWinDCState structure.
+ * Sets up the palette for the device context, and saves the old device
+ * context state in the passed in TkWinDCState structure.
*
*----------------------------------------------------------------------
*/
HDC
-TkWinGetDrawableDC(display, d, state)
- Display *display;
- Drawable d;
- TkWinDCState* state;
+TkWinGetDrawableDC(
+ Display *display,
+ Drawable d,
+ TkWinDCState *state)
{
HDC dc;
TkWinDrawable *twdPtr = (TkWinDrawable *)d;
@@ -157,7 +155,7 @@ TkWinGetDrawableDC(display, d, state)
if (twdPtr->type == TWD_WINDOW) {
TkWindow *winPtr = twdPtr->window.winPtr;
-
+
dc = GetDC(twdPtr->window.handle);
if (winPtr == NULL) {
cmap = DefaultColormap(display, DefaultScreen(display));
@@ -194,12 +192,13 @@ TkWinGetDrawableDC(display, d, state)
*/
void
-TkWinReleaseDrawableDC(d, dc, state)
- Drawable d;
- HDC dc;
- TkWinDCState *state;
+TkWinReleaseDrawableDC(
+ Drawable d,
+ HDC dc,
+ TkWinDCState *state)
{
TkWinDrawable *twdPtr = (TkWinDrawable *)d;
+
SetBkMode(dc, state->bkmode);
SelectPalette(dc, state->palette, TRUE);
RealizePalette(dc);
@@ -221,26 +220,26 @@ TkWinReleaseDrawableDC(d, dc, state)
* Returns the converted array of POINTs.
*
* Side effects:
- * Allocates a block of memory in thread local storage that
- * should not be freed.
+ * Allocates a block of memory in thread local storage that should not be
+ * freed.
*
*----------------------------------------------------------------------
*/
static POINT *
-ConvertPoints(points, npoints, mode, bbox)
- XPoint *points;
- int npoints;
- int mode; /* CoordModeOrigin or CoordModePrevious. */
- RECT *bbox; /* Bounding box of points. */
+ConvertPoints(
+ XPoint *points,
+ int npoints,
+ int mode, /* CoordModeOrigin or CoordModePrevious. */
+ RECT *bbox) /* Bounding box of points. */
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
int i;
/*
- * To avoid paying the cost of a malloc on every drawing routine,
- * we reuse the last array if it is large enough.
+ * To avoid paying the cost of a malloc on every drawing routine, we reuse
+ * the last array if it is large enough.
*/
if (npoints > tsdPtr->nWinPoints) {
@@ -257,7 +256,7 @@ ConvertPoints(points, npoints, mode, bbox)
bbox->left = bbox->right = points[0].x;
bbox->top = bbox->bottom = points[0].y;
-
+
if (mode == CoordModeOrigin) {
for (i = 0; i < npoints; i++) {
tsdPtr->winPoints[i].x = points[i].x;
@@ -294,21 +293,20 @@ ConvertPoints(points, npoints, mode, bbox)
* None.
*
* Side effects:
- * Data is moved from a window or bitmap to a second window or
- * bitmap.
+ * Data is moved from a window or bitmap to a second window or bitmap.
*
*----------------------------------------------------------------------
*/
void
-XCopyArea(display, src, dest, gc, src_x, src_y, width, height, dest_x, dest_y)
- Display* display;
- Drawable src;
- Drawable dest;
- GC gc;
- int src_x, src_y;
- unsigned int width, height;
- int dest_x, dest_y;
+XCopyArea(
+ Display *display,
+ Drawable src,
+ Drawable dest,
+ GC gc,
+ int src_x, int src_y,
+ unsigned int width, unsigned int height,
+ int dest_x, int dest_y)
{
HDC srcDC, destDC;
TkWinDCState srcState, destState;
@@ -343,10 +341,9 @@ XCopyArea(display, src, dest, gc, src_x, src_y, width, height, dest_x, dest_y)
*
* XCopyPlane --
*
- * Copies a bitmap from a source drawable to a destination
- * drawable. The plane argument specifies which bit plane of
- * the source contains the bitmap. Note that this implementation
- * ignores the gc->function.
+ * Copies a bitmap from a source drawable to a destination drawable. The
+ * plane argument specifies which bit plane of the source contains the
+ * bitmap. Note that this implementation ignores the gc->function.
*
* Results:
* None.
@@ -358,16 +355,15 @@ XCopyArea(display, src, dest, gc, src_x, src_y, width, height, dest_x, dest_y)
*/
void
-XCopyPlane(display, src, dest, gc, src_x, src_y, width, height, dest_x,
- dest_y, plane)
- Display* display;
- Drawable src;
- Drawable dest;
- GC gc;
- int src_x, src_y;
- unsigned int width, height;
- int dest_x, dest_y;
- unsigned long plane;
+XCopyPlane(
+ Display *display,
+ Drawable src,
+ Drawable dest,
+ GC gc,
+ int src_x, int src_y,
+ unsigned int width, unsigned int height,
+ int dest_x, int dest_y,
+ unsigned long plane)
{
HDC srcDC, destDC;
TkWinDCState srcState, destState;
@@ -389,12 +385,10 @@ XCopyPlane(display, src, dest, gc, src_x, src_y, width, height, dest_x,
}
if (clipPtr == NULL || clipPtr->type == TKP_CLIP_REGION) {
-
/*
- * Case 1: opaque bitmaps. Windows handles the conversion
- * from one bit to multiple bits by setting 0 to the
- * foreground color, and 1 to the background color (seems
- * backwards, but there you are).
+ * Case 1: opaque bitmaps. Windows handles the conversion from one bit
+ * to multiple bits by setting 0 to the foreground color, and 1 to the
+ * background color (seems backwards, but there you are).
*/
if (clipPtr && clipPtr->type == TKP_CLIP_REGION) {
@@ -414,8 +408,8 @@ XCopyPlane(display, src, dest, gc, src_x, src_y, width, height, dest_x,
/*
* Case 2: transparent bitmaps are handled by setting the
- * destination to the foreground color whenever the source
- * pixel is set.
+ * destination to the foreground color whenever the source pixel
+ * is set.
*/
fgBrush = CreateSolidBrush(gc->foreground);
@@ -427,9 +421,9 @@ XCopyPlane(display, src, dest, gc, src_x, src_y, width, height, dest_x,
} else {
/*
- * Case 3: two arbitrary bitmaps. Copy the source rectangle
- * into a color pixmap. Use the result as a brush when
- * copying the clip mask into the destination.
+ * Case 3: two arbitrary bitmaps. Copy the source rectangle into a
+ * color pixmap. Use the result as a brush when copying the clip
+ * mask into the destination.
*/
HDC memDC, maskDC;
@@ -445,9 +439,9 @@ XCopyPlane(display, src, dest, gc, src_x, src_y, width, height, dest_x,
SelectObject(memDC, bitmap);
/*
- * Set foreground bits. We create a new bitmap containing
- * (source AND mask), then use it to set the foreground color
- * into the destination.
+ * Set foreground bits. We create a new bitmap containing (source
+ * AND mask), then use it to set the foreground color into the
+ * destination.
*/
BitBlt(memDC, 0, 0, width, height, srcDC, src_x, src_y, SRCCOPY);
@@ -459,8 +453,8 @@ XCopyPlane(display, src, dest, gc, src_x, src_y, width, height, dest_x,
MASKPAT);
/*
- * Set background bits. Same as foreground, except we use
- * ((NOT source) AND mask) and the background brush.
+ * Set background bits. Same as foreground, except we use ((NOT
+ * source) AND mask) and the background brush.
*/
BitBlt(memDC, 0, 0, width, height, srcDC, src_x, src_y,
@@ -491,8 +485,8 @@ XCopyPlane(display, src, dest, gc, src_x, src_y, width, height, dest_x,
*
* TkPutImage --
*
- * Copies a subimage from an in-memory image to a rectangle of
- * of the specified drawable.
+ * Copies a subimage from an in-memory image to a rectangle of of the
+ * specified drawable.
*
* Results:
* None.
@@ -504,19 +498,18 @@ XCopyPlane(display, src, dest, gc, src_x, src_y, width, height, dest_x,
*/
void
-TkPutImage(colors, ncolors, display, d, gc, image, src_x, src_y, dest_x,
- dest_y, width, height)
- unsigned long *colors; /* Array of pixel values used by this
- * image. May be NULL. */
- int ncolors; /* Number of colors used, or 0. */
- Display* display;
- Drawable d; /* Destination drawable. */
- GC gc;
- XImage* image; /* Source image. */
- int src_x, src_y; /* Offset of subimage. */
- int dest_x, dest_y; /* Position of subimage origin in
- * drawable. */
- unsigned int width, height; /* Dimensions of subimage. */
+TkPutImage(
+ unsigned long *colors, /* Array of pixel values used by this image.
+ * May be NULL. */
+ int ncolors, /* Number of colors used, or 0. */
+ Display *display,
+ Drawable d, /* Destination drawable. */
+ GC gc,
+ XImage *image, /* Source image. */
+ int src_x, int src_y, /* Offset of subimage. */
+ int dest_x, int dest_y, /* Position of subimage origin in drawable. */
+ unsigned int width, unsigned int height)
+ /* Dimensions of subimage. */
{
HDC dc, dcMem;
TkWinDCState state;
@@ -532,8 +525,8 @@ TkPutImage(colors, ncolors, display, d, gc, image, src_x, src_y, dest_x,
if (image->bits_per_pixel == 1) {
/*
- * If the image isn't in the right format, we have to copy
- * it into a new buffer in MSBFirst and word-aligned format.
+ * If the image isn't in the right format, we have to copy it into a
+ * new buffer in MSBFirst and word-aligned format.
*/
if ((image->bitmap_bit_order != MSBFirst)
@@ -547,22 +540,22 @@ TkPutImage(colors, ncolors, display, d, gc, image, src_x, src_y, dest_x,
}
SetTextColor(dc, gc->foreground);
SetBkColor(dc, gc->background);
- } else {
+ } else {
int i, usePalette;
/*
* Do not use a palette for TrueColor images.
*/
-
+
usePalette = (image->bits_per_pixel < 16);
-
+
if (usePalette) {
- infoPtr = (BITMAPINFO*) ckalloc(sizeof(BITMAPINFOHEADER)
+ infoPtr = (BITMAPINFO *) ckalloc(sizeof(BITMAPINFOHEADER)
+ sizeof(RGBQUAD)*ncolors);
} else {
- infoPtr = (BITMAPINFO*) ckalloc(sizeof(BITMAPINFOHEADER));
+ infoPtr = (BITMAPINFO *) ckalloc(sizeof(BITMAPINFOHEADER));
}
-
+
infoPtr->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
infoPtr->bmiHeader.biWidth = image->width;
infoPtr->bmiHeader.biHeight = -image->height; /* Top-down order */
@@ -589,7 +582,7 @@ TkPutImage(colors, ncolors, display, d, gc, image, src_x, src_y, dest_x,
image->data, infoPtr, DIB_RGB_COLORS);
ckfree((char *) infoPtr);
}
- if(!bitmap) {
+ if (!bitmap) {
Tcl_Panic("Fail to allocate bitmap\n");
DeleteDC(dcMem);
TkWinReleaseDrawableDC(d, dc, &state);
@@ -619,12 +612,12 @@ TkPutImage(colors, ncolors, display, d, gc, image, src_x, src_y, dest_x,
*/
void
-XFillRectangles(display, d, gc, rectangles, nrectangles)
- Display* display;
- Drawable d;
- GC gc;
- XRectangle* rectangles;
- int nrectangles;
+XFillRectangles(
+ Display *display,
+ Drawable d,
+ GC gc,
+ XRectangle *rectangles,
+ int nrectangles)
{
HDC dc;
int i;
@@ -656,7 +649,7 @@ XFillRectangles(display, d, gc, rectangles, nrectangles)
/*
* Select stipple pattern into destination dc.
*/
-
+
stipple = CreatePatternBrush(twdPtr->bitmap.handle);
SetBrushOrgEx(dc, gc->ts_x_origin, gc->ts_y_origin, NULL);
oldBrush = SelectObject(dc, stipple);
@@ -664,7 +657,7 @@ XFillRectangles(display, d, gc, rectangles, nrectangles)
/*
* For each rectangle, create a drawing surface which is the size of
- * the rectangle and fill it with the background color. Then merge the
+ * the rectangle and fill it with the background color. Then merge the
* result with the stipple pattern.
*/
@@ -688,7 +681,7 @@ XFillRectangles(display, d, gc, rectangles, nrectangles)
SelectObject(dcMem, oldBitmap);
DeleteObject(bitmap);
}
-
+
DeleteDC(dcMem);
SelectObject(dc, oldBrush);
DeleteObject(stipple);
@@ -706,7 +699,7 @@ XFillRectangles(display, d, gc, rectangles, nrectangles)
HPEN newPen = CreatePen(PS_NULL, 0, gc->foreground);
HPEN oldPen = SelectObject(dc, newPen);
oldBrush = SelectObject(dc, brush);
-
+
for (i = 0; i < nrectangles; i++) {
Rectangle(dc, rectangles[i].x, rectangles[i].y,
rectangles[i].x + rectangles[i].width + 1,
@@ -727,8 +720,8 @@ XFillRectangles(display, d, gc, rectangles, nrectangles)
*
* RenderObject --
*
- * This function draws a shape using a list of points, a
- * stipple pattern, and the specified drawing function.
+ * This function draws a shape using a list of points, a stipple pattern,
+ * and the specified drawing function.
*
* Results:
* None.
@@ -740,20 +733,20 @@ XFillRectangles(display, d, gc, rectangles, nrectangles)
*/
static void
-RenderObject(dc, gc, points, npoints, mode, pen, func)
- HDC dc;
- GC gc;
- XPoint* points;
- int npoints;
- int mode;
- HPEN pen;
- WinDrawFunc func;
+RenderObject(
+ HDC dc,
+ GC gc,
+ XPoint *points,
+ int npoints,
+ int mode,
+ HPEN pen,
+ WinDrawFunc func)
{
RECT rect;
HPEN oldPen;
HBRUSH oldBrush;
POINT *winPoints = ConvertPoints(points, npoints, mode, &rect);
-
+
if ((gc->fill_style == FillStippled
|| gc->fill_style == FillOpaqueStippled)
&& gc->stipple != None) {
@@ -764,7 +757,7 @@ RenderObject(dc, gc, points, npoints, mode, pen, func)
HBITMAP oldBitmap;
int i;
HBRUSH oldMemBrush;
-
+
if (twdPtr->type != TWD_BITMAP) {
Tcl_Panic("unexpected drawable type in stipple");
}
@@ -784,7 +777,7 @@ RenderObject(dc, gc, points, npoints, mode, pen, func)
/*
* Select stipple pattern into destination dc.
*/
-
+
SetBrushOrgEx(dc, gc->ts_x_origin, gc->ts_y_origin, NULL);
oldBrush = SelectObject(dc, CreatePatternBrush(twdPtr->bitmap.handle));
@@ -792,7 +785,7 @@ RenderObject(dc, gc, points, npoints, mode, pen, func)
* Create temporary drawing surface containing a copy of the
* destination equal in size to the bounding box of the object.
*/
-
+
dcMem = CreateCompatibleDC(dc);
oldBitmap = SelectObject(dcMem, CreateCompatibleBitmap(dc, width,
height));
@@ -801,7 +794,7 @@ RenderObject(dc, gc, points, npoints, mode, pen, func)
/*
* Translate the object for rendering in the temporary drawing
- * surface.
+ * surface.
*/
for (i = 0; i < npoints; i++) {
@@ -822,8 +815,8 @@ RenderObject(dc, gc, points, npoints, mode, pen, func)
/*
* If we are rendering an opaque stipple, then draw the polygon in the
- * background color and copy it to the destination wherever the pattern
- * is clear.
+ * background color and copy it to the destination wherever the
+ * pattern is clear.
*/
if (gc->fill_style == FillOpaqueStippled) {
@@ -870,18 +863,18 @@ RenderObject(dc, gc, points, npoints, mode, pen, func)
*/
void
-XDrawLines(display, d, gc, points, npoints, mode)
- Display* display;
- Drawable d;
- GC gc;
- XPoint* points;
- int npoints;
- int mode;
+XDrawLines(
+ Display *display,
+ Drawable d,
+ GC gc,
+ XPoint *points,
+ int npoints,
+ int mode)
{
HPEN pen;
TkWinDCState state;
HDC dc;
-
+
if (d == None) {
return;
}
@@ -892,7 +885,7 @@ XDrawLines(display, d, gc, points, npoints, mode)
SetBkMode(dc, TRANSPARENT);
RenderObject(dc, gc, points, npoints, mode, pen, Polyline);
DeleteObject(pen);
-
+
TkWinReleaseDrawableDC(d, dc, &state);
}
@@ -913,14 +906,14 @@ XDrawLines(display, d, gc, points, npoints, mode)
*/
void
-XFillPolygon(display, d, gc, points, npoints, shape, mode)
- Display* display;
- Drawable d;
- GC gc;
- XPoint* points;
- int npoints;
- int shape;
- int mode;
+XFillPolygon(
+ Display *display,
+ Drawable d,
+ GC gc,
+ XPoint *points,
+ int npoints,
+ int shape,
+ int mode)
{
HPEN pen;
TkWinDCState state;
@@ -955,14 +948,12 @@ XFillPolygon(display, d, gc, points, npoints, shape, mode)
*/
void
-XDrawRectangle(display, d, gc, x, y, width, height)
- Display* display;
- Drawable d;
- GC gc;
- int x;
- int y;
- unsigned int width;
- unsigned int height;
+XDrawRectangle(
+ Display *display,
+ Drawable d,
+ GC gc,
+ int x, int y,
+ unsigned int width, unsigned int height)
{
HPEN pen, oldPen;
TkWinDCState state;
@@ -1005,16 +996,13 @@ XDrawRectangle(display, d, gc, x, y, width, height)
*/
void
-XDrawArc(display, d, gc, x, y, width, height, start, extent)
- Display* display;
- Drawable d;
- GC gc;
- int x;
- int y;
- unsigned int width;
- unsigned int height;
- int start;
- int extent;
+XDrawArc(
+ Display *display,
+ Drawable d,
+ GC gc,
+ int x, int y,
+ unsigned int width, unsigned int height,
+ int start, int extent)
{
display->request++;
@@ -1038,16 +1026,13 @@ XDrawArc(display, d, gc, x, y, width, height, start, extent)
*/
void
-XFillArc(display, d, gc, x, y, width, height, start, extent)
- Display* display;
- Drawable d;
- GC gc;
- int x;
- int y;
- unsigned int width;
- unsigned int height;
- int start;
- int extent;
+XFillArc(
+ Display *display,
+ Drawable d,
+ GC gc,
+ int x, int y,
+ unsigned int width, unsigned int height,
+ int start, int extent)
{
display->request++;
@@ -1059,8 +1044,8 @@ XFillArc(display, d, gc, x, y, width, height, start, extent)
*
* DrawOrFillArc --
*
- * This procedure handles the rendering of drawn or filled
- * arcs and chords.
+ * This function handles the rendering of drawn or filled arcs and
+ * chords.
*
* Results:
* None.
@@ -1072,15 +1057,15 @@ XFillArc(display, d, gc, x, y, width, height, start, extent)
*/
static void
-DrawOrFillArc(display, d, gc, x, y, width, height, start, extent, fill)
- Display *display;
- Drawable d;
- GC gc;
- int x, y; /* left top */
- unsigned int width, height;
- int start; /* start: three-o'clock (deg*64) */
- int extent; /* extent: relative (deg*64) */
- int fill; /* ==0 draw, !=0 fill */
+DrawOrFillArc(
+ Display *display,
+ Drawable d,
+ GC gc,
+ int x, int y, /* left top */
+ unsigned int width, unsigned int height,
+ int start, /* start: three-o'clock (deg*64) */
+ int extent, /* extent: relative (deg*64) */
+ int fill) /* ==0 draw, !=0 fill */
{
HDC dc;
HBRUSH brush, oldBrush;
@@ -1121,7 +1106,7 @@ DrawOrFillArc(display, d, gc, x, y, width, height, start, extent, fill)
/*
* Now compute points on the radial lines that define the starting and
- * ending angles. Be sure to take into account that the y-coordinate
+ * ending angles. Be sure to take into account that the y-coordinate
* system is inverted.
*/
@@ -1133,18 +1118,18 @@ DrawOrFillArc(display, d, gc, x, y, width, height, start, extent, fill)
yend = (int)((yr + sin(-radian_end)*height/2.0) + 0.5);
/*
- * Now draw a filled or open figure. Note that we have to
- * increase the size of the bounding box by one to account for the
- * difference in pixel definitions between X and Windows.
+ * Now draw a filled or open figure. Note that we have to increase the
+ * size of the bounding box by one to account for the difference in pixel
+ * definitions between X and Windows.
*/
pen = SetUpGraphicsPort(gc);
oldPen = SelectObject(dc, pen);
if (!fill) {
/*
- * Note that this call will leave a gap of one pixel at the
- * end of the arc for thin arcs. We can't use ArcTo because
- * it's only supported under Windows NT.
+ * Note that this call will leave a gap of one pixel at the end of the
+ * arc for thin arcs. We can't use ArcTo because it's only supported
+ * under Windows NT.
*/
SetBkMode(dc, TRANSPARENT);
@@ -1180,8 +1165,8 @@ DrawOrFillArc(display, d, gc, x, y, width, height, start, extent, fill)
*/
static HPEN
-SetUpGraphicsPort(gc)
- GC gc;
+SetUpGraphicsPort(
+ GC gc)
{
DWORD style;
@@ -1190,10 +1175,9 @@ SetUpGraphicsPort(gc)
/* pointer to the dash-list */
/*
- * Below is a simple translation of serveral dash patterns
- * to valid windows pen types. Far from complete,
- * but I don't know how to do it better.
- * Any ideas: <mailto:j.nijtmans@chello.nl>
+ * Below is a simple translation of serveral dash patterns to valid
+ * windows pen types. Far from complete, but I don't know how to do it
+ * better. Any ideas: <mailto:j.nijtmans@chello.nl>
*/
if (p[1] && p[2]) {
@@ -1223,27 +1207,27 @@ SetUpGraphicsPort(gc)
style |= PS_GEOMETRIC;
switch (gc->cap_style) {
- case CapNotLast:
- case CapButt:
- style |= PS_ENDCAP_FLAT;
- break;
- case CapRound:
- style |= PS_ENDCAP_ROUND;
- break;
- default:
- style |= PS_ENDCAP_SQUARE;
- break;
+ case CapNotLast:
+ case CapButt:
+ style |= PS_ENDCAP_FLAT;
+ break;
+ case CapRound:
+ style |= PS_ENDCAP_ROUND;
+ break;
+ default:
+ style |= PS_ENDCAP_SQUARE;
+ break;
}
switch (gc->join_style) {
- case JoinMiter:
- style |= PS_JOIN_MITER;
- break;
- case JoinRound:
- style |= PS_JOIN_ROUND;
- break;
- default:
- style |= PS_JOIN_BEVEL;
- break;
+ case JoinMiter:
+ style |= PS_JOIN_MITER;
+ break;
+ case JoinRound:
+ style |= PS_JOIN_ROUND;
+ break;
+ default:
+ style |= PS_JOIN_BEVEL;
+ break;
}
return ExtCreatePen(style, gc->line_width, &lb, 0, NULL);
}
@@ -1254,13 +1238,13 @@ SetUpGraphicsPort(gc)
*
* TkScrollWindow --
*
- * Scroll a rectangle of the specified window and accumulate
- * a damage region.
+ * Scroll a rectangle of the specified window and accumulate a damage
+ * region.
*
* Results:
- * Returns 0 if the scroll genereated no additional damage.
- * Otherwise, sets the region that needs to be repainted after
- * scrolling and returns 1.
+ * Returns 0 if the scroll genereated no additional damage. Otherwise,
+ * sets the region that needs to be repainted after scrolling and returns
+ * 1.
*
* Side effects:
* Scrolls the bits in the window.
@@ -1269,12 +1253,13 @@ SetUpGraphicsPort(gc)
*/
int
-TkScrollWindow(tkwin, gc, x, y, width, height, dx, dy, damageRgn)
- Tk_Window tkwin; /* The window to be scrolled. */
- GC gc; /* GC for window to be scrolled. */
- int x, y, width, height; /* Position rectangle to be scrolled. */
- int dx, dy; /* Distance rectangle should be moved. */
- TkRegion damageRgn; /* Region to accumulate damage in. */
+TkScrollWindow(
+ Tk_Window tkwin, /* The window to be scrolled. */
+ GC gc, /* GC for window to be scrolled. */
+ int x, int y, int width, int height,
+ /* Position rectangle to be scrolled. */
+ int dx, int dy, /* Distance rectangle should be moved. */
+ TkRegion damageRgn) /* Region to accumulate damage in. */
{
HWND hwnd = TkWinGetHWND(Tk_WindowId(tkwin));
RECT scrollRect;
@@ -1292,9 +1277,9 @@ TkScrollWindow(tkwin, gc, x, y, width, height, dx, dy, damageRgn)
*
* TkWinFillRect --
*
- * This routine fills a rectangle with the foreground color
- * from the specified GC ignoring all other GC values. This
- * is the fastest way to fill a drawable with a solid color.
+ * This routine fills a rectangle with the foreground color from the
+ * specified GC ignoring all other GC values. This is the fastest way to
+ * fill a drawable with a solid color.
*
* Results:
* None.
@@ -1306,10 +1291,10 @@ TkScrollWindow(tkwin, gc, x, y, width, height, dx, dy, damageRgn)
*/
void
-TkWinFillRect(dc, x, y, width, height, pixel)
- HDC dc;
- int x, y, width, height;
- int pixel;
+TkWinFillRect(
+ HDC dc,
+ int x, int y, int width, int height,
+ int pixel)
{
RECT rect;
COLORREF oldColor;
@@ -1329,30 +1314,30 @@ TkWinFillRect(dc, x, y, width, height, pixel)
*
* TkpDrawHighlightBorder --
*
- * This procedure draws a rectangular ring around the outside of
- * a widget to indicate that it has received the input focus.
+ * This function draws a rectangular ring around the outside of a widget
+ * to indicate that it has received the input focus.
*
- * On Windows, we just draw the simple inset ring. On other sytems,
- * e.g. the Mac, the focus ring is a little more complicated, so we
- * need this abstraction.
+ * On Windows, we just draw the simple inset ring. On other sytems, e.g.
+ * the Mac, the focus ring is a little more complicated, so we need this
+ * abstraction.
*
* Results:
* None.
*
* Side effects:
- * A rectangle "width" pixels wide is drawn in "drawable",
- * corresponding to the outer area of "tkwin".
+ * A rectangle "width" pixels wide is drawn in "drawable", corresponding
+ * to the outer area of "tkwin".
*
*----------------------------------------------------------------------
*/
-void
-TkpDrawHighlightBorder(tkwin, fgGC, bgGC, highlightWidth, drawable)
- Tk_Window tkwin;
- GC fgGC;
- GC bgGC;
- int highlightWidth;
- Drawable drawable;
+void
+TkpDrawHighlightBorder(
+ Tk_Window tkwin,
+ GC fgGC,
+ GC bgGC,
+ int highlightWidth,
+ Drawable drawable)
{
TkDrawInsetFocusHighlight(tkwin, fgGC, highlightWidth, drawable, 0);
}
@@ -1362,7 +1347,7 @@ TkpDrawHighlightBorder(tkwin, fgGC, bgGC, highlightWidth, drawable)
*
* TkpDrawFrame --
*
- * This procedure draws the rectangular frame area.
+ * This function draws the rectangular frame area.
*
* Results:
* None.
@@ -1374,12 +1359,22 @@ TkpDrawHighlightBorder(tkwin, fgGC, bgGC, highlightWidth, drawable)
*/
void
-TkpDrawFrame (Tk_Window tkwin, Tk_3DBorder border,
- int highlightWidth, int borderWidth, int relief)
+TkpDrawFrame(
+ Tk_Window tkwin,
+ Tk_3DBorder border,
+ int highlightWidth,
+ int borderWidth,
+ int relief)
{
- Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin),
- border, highlightWidth, highlightWidth,
- Tk_Width(tkwin) - 2 * highlightWidth,
- Tk_Height(tkwin) - 2 * highlightWidth,
- borderWidth, relief);
+ Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), border, highlightWidth,
+ highlightWidth, Tk_Width(tkwin) - 2 * highlightWidth,
+ Tk_Height(tkwin) - 2 * highlightWidth, borderWidth, relief);
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/win/tkWinEmbed.c b/win/tkWinEmbed.c
index 40cbd3a..9b5150c 100644
--- a/win/tkWinEmbed.c
+++ b/win/tkWinEmbed.c
@@ -1,4 +1,4 @@
-/*
+/*
* tkWinEmbed.c --
*
* This file contains platform specific procedures for Windows platforms
@@ -8,52 +8,50 @@
*
* Copyright (c) 1996-1997 Sun Microsystems, Inc.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinEmbed.c,v 1.28 2005/01/27 15:29:22 chengyemao Exp $
+ * RCS: @(#) $Id: tkWinEmbed.c,v 1.29 2005/12/02 00:19:04 dkf Exp $
*/
#include "tkWinInt.h"
/*
* One of the following structures exists for each container in this
- * application. It keeps track of the container window and its
- * associated embedded window.
+ * application. It keeps track of the container window and its associated
+ * embedded window.
*/
typedef struct Container {
- HWND parentHWnd; /* Windows HWND to the parent window */
- TkWindow *parentPtr; /* Tk's information about the container
- * or NULL if the container isn't
- * in this process. */
- HWND embeddedHWnd; /* Windows HWND to the embedded window
- */
- TkWindow *embeddedPtr; /* Tk's information about the embedded
- * window, or NULL if the
- * embedded application isn't in
- * this process. */
- HWND embeddedMenuHWnd; /* Tk's embedded menu window handler */
- struct Container *nextPtr; /* Next in list of all containers in
- * this process. */
+ HWND parentHWnd; /* Windows HWND to the parent window */
+ TkWindow *parentPtr; /* Tk's information about the container or
+ * NULL if the container isn't in this
+ * process. */
+ HWND embeddedHWnd; /* Windows HWND to the embedded window. */
+ TkWindow *embeddedPtr; /* Tk's information about the embedded window,
+ * or NULL if the embedded application isn't
+ * in this process. */
+ HWND embeddedMenuHWnd; /* Tk's embedded menu window handler. */
+ struct Container *nextPtr; /* Next in list of all containers in this
+ * process. */
} Container;
typedef struct ThreadSpecificData {
- Container *firstContainerPtr; /* First in list of all containers
- * managed by this process. */
+ Container *firstContainerPtr;
+ /* First in list of all containers managed by
+ * this process. */
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
-static void ContainerEventProc _ANSI_ARGS_((ClientData clientData,
- XEvent *eventPtr));
-static void EmbeddedEventProc _ANSI_ARGS_((
- ClientData clientData, XEvent *eventPtr));
-static void EmbedGeometryRequest _ANSI_ARGS_((
- Container*containerPtr, int width, int height));
-static void EmbedWindowDeleted _ANSI_ARGS_((TkWindow *winPtr));
-static void Tk_MapEmbeddedWindow _ANSI_ARGS_((TkWindow* winPtr));
-HWND Tk_GetEmbeddedHWnd _ANSI_ARGS_((TkWindow* winPtr));
-
+static void ContainerEventProc(ClientData clientData,
+ XEvent *eventPtr);
+static void EmbeddedEventProc(ClientData clientData,
+ XEvent *eventPtr);
+static void EmbedGeometryRequest(Container *containerPtr,
+ int width, int height);
+static void EmbedWindowDeleted(TkWindow *winPtr);
+static void Tk_MapEmbeddedWindow(TkWindow* winPtr);
+HWND Tk_GetEmbeddedHWnd(TkWindow* winPtr);
/*
*----------------------------------------------------------------------
@@ -71,15 +69,15 @@ HWND Tk_GetEmbeddedHWnd _ANSI_ARGS_((TkWindow* winPtr));
*----------------------------------------------------------------------
*/
-void TkWinCleanupContainerList(void)
+void
+TkWinCleanupContainerList(void)
{
Container *nextPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
-
- for (;
- tsdPtr->firstContainerPtr != (Container *) NULL;
- tsdPtr->firstContainerPtr = nextPtr) {
+
+ for (; tsdPtr->firstContainerPtr != (Container *) NULL;
+ tsdPtr->firstContainerPtr = nextPtr) {
nextPtr = tsdPtr->firstContainerPtr->nextPtr;
ckfree((char *) tsdPtr->firstContainerPtr);
}
@@ -104,11 +102,11 @@ void TkWinCleanupContainerList(void)
/* ARGSUSED */
int
-TkpTestembedCmd(clientData, interp, argc, argv)
- ClientData clientData;
- Tcl_Interp *interp;
- int argc;
- CONST char **argv;
+TkpTestembedCmd(
+ ClientData clientData,
+ Tcl_Interp *interp,
+ int argc,
+ CONST char **argv)
{
return TCL_OK;
}
@@ -128,14 +126,15 @@ TkpTestembedCmd(clientData, interp, argc, argv)
*
*----------------------------------------------------------------------
*/
-static
-void Tk_DetachEmbeddedWindow(winPtr, detachFlag)
- TkWindow *winPtr; /* an embedded window */
- BOOL detachFlag; /* a flag of truely detaching */
+
+static
+void
+Tk_DetachEmbeddedWindow(
+ TkWindow *winPtr, /* an embedded window */
+ BOOL detachFlag) /* a flag of truely detaching */
{
TkpWinToplevelDetachWindow(winPtr);
- if(detachFlag)
- {
+ if(detachFlag) {
TkpWinToplevelOverrideRedirect(winPtr, 0);
}
}
@@ -145,9 +144,9 @@ void Tk_DetachEmbeddedWindow(winPtr, detachFlag)
*
* Tk_MapEmbeddedWindow --
*
- * This function is required for mapping an embedded window during
- * idle. The input winPtr must be preserved using Tcl_Preserve before
- * call this function and will be released by this function.
+ * This function is required for mapping an embedded window during idle.
+ * The input winPtr must be preserved using Tcl_Preserve before call this
+ * function and will be released by this function.
*
* Results:
* No return value. Map the embedded window if it is not dead.
@@ -157,66 +156,71 @@ void Tk_DetachEmbeddedWindow(winPtr, detachFlag)
*
*----------------------------------------------------------------------
*/
-static
-void Tk_MapEmbeddedWindow(winPtr)
- TkWindow *winPtr; /* Top-level window that's about to
- * be mapped. */
+
+static
+void Tk_MapEmbeddedWindow(
+ TkWindow *winPtr) /* Top-level window that's about to be
+ * mapped. */
{
if(!(winPtr->flags & TK_ALREADY_DEAD)) {
HWND hwnd = (HWND)winPtr->privatePtr;
int state = SendMessage(hwnd, TK_STATE, -1, -1) - 1;
- if(state < 0 || state > 3) {
+
+ if (state < 0 || state > 3) {
state = NormalState;
- }
- while(Tcl_DoOneEvent(TCL_IDLE_EVENTS));
- TkpWmSetState(winPtr, state);
+ }
+
+ while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {
+ /* empty body */
+ }
+
+ TkpWmSetState(winPtr, state);
TkWmMapWindow(winPtr);
}
Tcl_Release((ClientData)winPtr);
}
-
+
/*
*----------------------------------------------------------------------
*
* TkpUseWindow --
*
- * This procedure causes a Tk window to use a given Windows handle
- * for a window as its underlying window, rather than a new Windows
- * window being created automatically. It is invoked by an embedded
- * application to specify the window in which the application is
- * embedded.
+ * This procedure causes a Tk window to use a given Windows handle for a
+ * window as its underlying window, rather than a new Windows window
+ * being created automatically. It is invoked by an embedded application
+ * to specify the window in which the application is embedded.
*
- * This procedure uses a simple attachment protocol by sending
- * TK_INFO messages to the window to use with two sub messages:
+ * This procedure uses a simple attachment protocol by sending TK_INFO
+ * messages to the window to use with two sub messages:
*
- * TK_CONTAINER_VERIFY - if a window handles this message,
- * it should return either a (long)hwnd for a container or
- * a -(long)hwnd for a non-container.
+ * TK_CONTAINER_VERIFY - if a window handles this message, it should
+ * return either a (long)hwnd for a container or a -(long)hwnd
+ * for a non-container.
*
- * TK_CONTAINER_ISAVAILABLE - a container window should return
- * either a TRUE (non-zero) if it is available for use or
- * a FALSE (zero) othersize.
+ * TK_CONTAINER_ISAVAILABLE - a container window should return either
+ * a TRUE (non-zero) if it is available for use or a FALSE (zero)
+ * othersize.
*
- * The TK_INFO messages are required in order to verify if the window
- * to use is a valid container. Without an id verification, an invalid
+ * The TK_INFO messages are required in order to verify if the window to
+ * use is a valid container. Without an id verification, an invalid
* window attachment may cause unexpected crashes/panics (bug 1096074).
- * Additional sub messages may be definded/used in future for other
+ * Additional sub messages may be definded/used in future for other
* needs.
- *
- * We do not enforce the above protocol for the reason of backward
- * compatibility. If the window to use is unable to handle TK_INFO
- * messages (e.g., legacy Tk container applications before 8.5),
- * a dialog box with a warning message pops up and the user is asked
- * to confirm if the attachment should proceed. However, we may have
- * to enforce it in future.
- *
+ *
+ * We do not enforce the above protocol for the reason of backward
+ * compatibility. If the window to use is unable to handle TK_INFO
+ * messages (e.g., legacy Tk container applications before 8.5), a dialog
+ * box with a warning message pops up and the user is asked to confirm if
+ * the attachment should proceed. However, we may have to enforce it in
+ * future.
+ *
* Results:
- * The return value is normally TCL_OK. If an error occurred (such as
- * if the argument does not identify a legal Windows window handle or
- * it is already in use or a cancel button is pressed by a user in
- * confirming the use window as a Tk container) the return value is
- * TCL_ERROR and an error message is left in the the interp's result
- * if interp is not NULL.
+ * The return value is normally TCL_OK. If an error occurred (such as if
+ * the argument does not identify a legal Windows window handle or it is
+ * already in use or a cancel button is pressed by a user in confirming
+ * the use window as a Tk container) the return value is TCL_ERROR and an
+ * error message is left in the the interp's result if interp is not
+ * NULL.
*
* Side effects:
* None.
@@ -224,28 +228,30 @@ void Tk_MapEmbeddedWindow(winPtr)
*----------------------------------------------------------------------
*/
-int
-TkpUseWindow(interp, tkwin, string)
- Tcl_Interp *interp; /* If not NULL, used for error reporting
- * if string is bogus. */
- Tk_Window tkwin; /* Tk window that does not yet have an
+int
+TkpUseWindow(
+ Tcl_Interp *interp, /* If not NULL, used for error reporting if
+ * string is bogus. */
+ Tk_Window tkwin, /* Tk window that does not yet have an
* associated X window. */
- CONST char *string; /* String identifying an X window to use
- * for tkwin; must be an integer value. */
+ CONST char *string) /* String identifying an X window to use for
+ * tkwin; must be an integer value. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
int id;
HWND hwnd;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+
/*
- if(winPtr->window != None) {
- Tcl_AppendResult(interp, "can't modify container after widget is created", (char *) NULL);
+ if (winPtr->window != None) {
+ Tcl_AppendResult(interp, "can't modify container after widget is created", NULL);
return TCL_ERROR;
}
*/
- if(strcmp(string, "") == 0) {
- if(winPtr->flags & TK_EMBEDDED) {
+
+ if (strcmp(string, "") == 0) {
+ if (winPtr->flags & TK_EMBEDDED) {
Tk_DetachEmbeddedWindow(winPtr, TRUE);
}
return TCL_OK;
@@ -255,7 +261,9 @@ TkpUseWindow(interp, tkwin, string)
return TCL_ERROR;
}
hwnd = (HWND) id;
- if((HWND)winPtr->privatePtr == hwnd) return TCL_OK;
+ if ((HWND)winPtr->privatePtr == hwnd) {
+ return TCL_OK;
+ }
/*
* Check if the window is a valid handle. If it is invalid, return
@@ -264,32 +272,35 @@ TkpUseWindow(interp, tkwin, string)
*/
if (!IsWindow(hwnd)) {
- if (interp != (Tcl_Interp *) NULL) {
- Tcl_AppendResult(interp, "window \"", string,
- "\" doesn't exist", (char *) NULL);
+ if (interp != NULL) {
+ Tcl_AppendResult(interp, "window \"", string,
+ "\" doesn't exist", NULL);
}
return TCL_ERROR;
}
id = SendMessage(hwnd, TK_INFO, TK_CONTAINER_VERIFY, 0);
- if(id == (long)hwnd) {
- if(!SendMessage(hwnd, TK_INFO, TK_CONTAINER_ISAVAILABLE, 0)) {
+ if (id == (long)hwnd) {
+ if (!SendMessage(hwnd, TK_INFO, TK_CONTAINER_ISAVAILABLE, 0)) {
Tcl_AppendResult(interp, "The container is already in use", NULL);
return TCL_ERROR;
}
- } else if(id == -(long)hwnd) {
- Tcl_AppendResult(interp, "the window to use is not a Tk container", NULL);
- return TCL_ERROR;
+ } else if (id == -(long)hwnd) {
+ Tcl_AppendResult(interp, "the window to use is not a Tk container",
+ NULL);
+ return TCL_ERROR;
} else {
/*
- * Proceed if the user decide to do so because it can be a legacy
- * container application. However we may have to return a TCL_ERROR
- * in order to avoid bug 1096074 in future.
+ * Proceed if the user decide to do so because it can be a legacy
+ * container application. However we may have to return a TCL_ERROR in
+ * order to avoid bug 1096074 in future.
*/
+
char msg[256];
sprintf(msg, "Unable to get information of window \"%s\". Attach to this\nwindow may have unpredictable results if it is not a valid container.\n\nPress Ok to proceed or Cancel to abort attaching.", string);
- if(IDCANCEL == MessageBox(hwnd, msg, "Tk Warning", MB_OKCANCEL | MB_ICONWARNING)) {
- Tcl_SetResult(interp, "Operation has been canceled", TCL_STATIC);
+ if (IDCANCEL == MessageBox(hwnd, msg, "Tk Warning",
+ MB_OKCANCEL | MB_ICONWARNING)) {
+ Tcl_SetResult(interp, "Operation has been canceled", TCL_STATIC);
return TCL_ERROR;
}
}
@@ -306,9 +317,10 @@ TkpUseWindow(interp, tkwin, string)
winPtr->flags &= (~(TK_MAPPED));
/*
- * Preserve the winPtr and create an idle handler to
- * map the embedded window
- */
+ * Preserve the winPtr and create an idle handler to map the embedded
+ * window.
+ */
+
Tcl_Preserve((ClientData)winPtr);
Tcl_DoWhenIdle(Tk_MapEmbeddedWindow,(ClientData)winPtr);
@@ -320,10 +332,10 @@ TkpUseWindow(interp, tkwin, string)
*
* TkpMakeContainer --
*
- * This procedure is called to indicate that a particular window will
- * be a container for an embedded application. This changes certain
- * aspects of the window's behavior, such as whether it will receive
- * events anymore.
+ * This procedure is called to indicate that a particular window will be
+ * a container for an embedded application. This changes certain aspects
+ * of the window's behavior, such as whether it will receive events
+ * anymore.
*
* Results:
* None.
@@ -335,17 +347,17 @@ TkpUseWindow(interp, tkwin, string)
*/
void
-TkpMakeContainer(tkwin)
- Tk_Window tkwin;
+TkpMakeContainer(
+ Tk_Window tkwin)
{
TkWindow *winPtr = (TkWindow *) tkwin;
Container *containerPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
-
+
/*
- * Register the window as a container so that, for example, we can
- * find out later if the embedded app. is in the same process.
+ * Register the window as a container so that, for example, we can find
+ * out later if the embedded app. is in the same process.
*/
Tk_MakeWindowExist(tkwin);
@@ -360,18 +372,17 @@ TkpMakeContainer(tkwin)
winPtr->flags |= TK_CONTAINER;
/*
- * Unlike in tkUnixEmbed.c, we don't make any requests for events
- * in the embedded window here. Now we just allow the embedding
- * of another TK application into TK windows. When the embedded
- * window makes a request, that will be done by sending to the
- * container window a WM_USER message, which will be intercepted
- * by TkWinContainerProc.
+ * Unlike in tkUnixEmbed.c, we don't make any requests for events in the
+ * embedded window here. Now we just allow the embedding of another TK
+ * application into TK windows. When the embedded window makes a request,
+ * that will be done by sending to the container window a WM_USER message,
+ * which will be intercepted by TkWinContainerProc.
*
* We need to get structure events of the container itself, though.
*/
Tk_CreateEventHandler(tkwin, StructureNotifyMask,
- ContainerEventProc, (ClientData) containerPtr);
+ ContainerEventProc, (ClientData) containerPtr);
}
/*
@@ -380,8 +391,8 @@ TkpMakeContainer(tkwin)
* EmbeddedEventProc --
*
* This procedure is invoked by the Tk event dispatcher when various
- * useful events are received for a window that is embedded in
- * another application.
+ * useful events are received for a window that is embedded in another
+ * application.
*
* Results:
* None.
@@ -394,9 +405,9 @@ TkpMakeContainer(tkwin)
*/
static void
-EmbeddedEventProc(clientData, eventPtr)
- ClientData clientData; /* Token for container window. */
- XEvent *eventPtr; /* ResizeRequest event. */
+EmbeddedEventProc(
+ ClientData clientData, /* Token for container window. */
+ XEvent *eventPtr) /* ResizeRequest event. */
{
TkWindow *winPtr = (TkWindow *) clientData;
@@ -410,32 +421,31 @@ EmbeddedEventProc(clientData, eventPtr)
*
* TkWinEmbeddedEventProc --
*
- * This procedure is invoked by the Tk event dispatcher when
- * various useful events are received for the *children* of a
- * container window. It forwards relevant information, such as
- * geometry requests, from the events into the container's
- * application.
+ * This procedure is invoked by the Tk event dispatcher when various
+ * useful events are received for the *children* of a container window.
+ * It forwards relevant information, such as geometry requests, from the
+ * events into the container's application.
*
* Results:
* None.
*
* Side effects:
- * Depends on the event. For example, when ConfigureRequest events
- * occur, geometry information gets set for the container window.
+ * Depends on the event. For example, when ConfigureRequest events occur,
+ * geometry information gets set for the container window.
*
*----------------------------------------------------------------------
*/
LRESULT
-TkWinEmbeddedEventProc(hwnd, message, wParam, lParam)
- HWND hwnd;
- UINT message;
- WPARAM wParam;
- LPARAM lParam;
+TkWinEmbeddedEventProc(
+ HWND hwnd,
+ UINT message,
+ WPARAM wParam,
+ LPARAM lParam)
{
int result = 1;
Container *containerPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -454,76 +464,80 @@ TkWinEmbeddedEventProc(hwnd, message, wParam, lParam)
topwinPtr = containerPtr->parentPtr;
}
switch (message) {
- case TK_INFO:
- /* An embedded window may send this message for container
- * verification and availability before attach.
+ case TK_INFO:
+ /*
+ * An embedded window may send this message for container
+ * verification and availability before attach.
*
* wParam - a sub message
*
- * TK_CONTAINER_ISAVAILABLE - if the container is
- * available for use?
+ * TK_CONTAINER_ISAVAILABLE - if the container is available
+ * for use?
* result = 1 for yes and 0 for no;
*
- * TK_CONTAINER_VERIFY - request the container to
- * verify its identification
+ * TK_CONTAINER_VERIFY - request the container to verify its
+ * identification
* result = (long)hwnd if this window is a container
* -(long)hwnd otherwise
*
* lParam - N/A
*/
+
switch(wParam) {
- case TK_CONTAINER_ISAVAILABLE:
+ case TK_CONTAINER_ISAVAILABLE:
result = containerPtr->embeddedHWnd == NULL? 1:0;
break;
-
- case TK_CONTAINER_VERIFY:
+ case TK_CONTAINER_VERIFY:
result = (long)containerPtr->parentHWnd;
break;
-
- default:
+ default:
result = 0;
}
break;
- case TK_ATTACHWINDOW:
- /* An embedded window (either from this application or from
- * another application) is trying to attach to this container.
- * We attach it only if this container is not yet containing any
+ case TK_ATTACHWINDOW:
+ /*
+ * An embedded window (either from this application or from
+ * another application) is trying to attach to this container. We
+ * attach it only if this container is not yet containing any
* window.
*
* wParam - a handle of an embedded window
* lParam - N/A
*
* An embedded window may send this message with a wParam of NULL
- * to test if a window is able to provide embedding service. The
- * container returns its window handle for accepting the attachment
- * and identifying itself or a zero for being already in use.
+ * to test if a window is able to provide embedding service. The
+ * container returns its window handle for accepting the
+ * attachment and identifying itself or a zero for being already
+ * in use.
*
* Return value:
* 0 - the container is unable to be used.
- * hwnd - the container is ready to be used.
+ * hwnd - the container is ready to be used.
*/
if (containerPtr->embeddedHWnd == NULL) {
- if(wParam) {
- TkWindow* winPtr = (TkWindow*)Tk_HWNDToWindow((HWND)wParam);
- if(winPtr) {
+ if (wParam) {
+ TkWindow *winPtr = (TkWindow *)
+ Tk_HWNDToWindow((HWND) wParam);
+ if (winPtr) {
winPtr->flags |= TK_BOTH_HALVES;
containerPtr->embeddedPtr = winPtr;
containerPtr->parentPtr->flags |= TK_BOTH_HALVES;
}
containerPtr->embeddedHWnd = (HWND)wParam;
}
- result = (long)containerPtr->parentHWnd;
+ result = (long)containerPtr->parentHWnd;
} else {
result = 0;
}
break;
- case TK_DETACHWINDOW:
- /* An embedded window notifies the container that it is detached.
+ case TK_DETACHWINDOW:
+ /*
+ * An embedded window notifies the container that it is detached.
* The container should clearn the related variables and redraw
* its window.
- *
+ *
* wParam - N/A
* lParam - N/A
*
@@ -531,15 +545,19 @@ TkWinEmbeddedEventProc(hwnd, message, wParam, lParam)
* 0 - the message is not processed.
* others - the message is processed.
*/
+
containerPtr->embeddedMenuHWnd = NULL;
containerPtr->embeddedHWnd = NULL;
containerPtr->parentPtr->flags &= ~TK_BOTH_HALVES;
- if(topwinPtr) TkWinSetMenu((Tk_Window)topwinPtr, 0);
+ if (topwinPtr) {
+ TkWinSetMenu((Tk_Window) topwinPtr, 0);
+ }
InvalidateRect(hwnd, NULL, TRUE);
break;
- case TK_GEOMETRYREQ:
- /* An embedded window requests a window size change.
+ case TK_GEOMETRYREQ:
+ /*
+ * An embedded window requests a window size change.
*
* wParam - window width
* lParam - window height
@@ -548,41 +566,46 @@ TkWinEmbeddedEventProc(hwnd, message, wParam, lParam)
* 0 - the message is not processed.
* others - the message is processed.
*/
+
EmbedGeometryRequest(containerPtr, (int)wParam, lParam);
break;
- case TK_RAISEWINDOW:
- /* An embedded window requests to change its Z-order
- *
- * wParam - a window handle as a z-order stack reference
+ case TK_RAISEWINDOW:
+ /*
+ * An embedded window requests to change its Z-order.
+ *
+ * wParam - a window handle as a z-order stack reference
* lParam - a flag of above-below: 0 - above; 1 or others: - below
- *
+ *
* Return value:
* 0 - the message is not processed.
* others - the message is processed.
*/
- TkWinSetWindowPos(GetParent(containerPtr->parentHWnd), (HWND)wParam, (int)lParam);
+
+ TkWinSetWindowPos(GetParent(containerPtr->parentHWnd),
+ (HWND)wParam, (int)lParam);
break;
- case TK_GETFRAMEWID:
- /* An embedded window requests to get the frame window's id
+ case TK_GETFRAMEWID:
+ /*
+ * An embedded window requests to get the frame window's id.
*
* wParam - N/A
* lParam - N/A
*
* Return vlaue:
*
- * A handle of the frame window. If it is not availble, a
- * zeor is returned.
+ * A handle of the frame window. If it is not availble, a zero is
+ * returned.
*/
- if(topwinPtr) {
+ if (topwinPtr) {
result = (long)GetParent(containerPtr->parentHWnd);
} else {
topwinPtr = containerPtr->parentPtr;
while (!(topwinPtr->flags & TK_TOP_HIERARCHY)) {
topwinPtr = topwinPtr->parentPtr;
}
- if(topwinPtr && topwinPtr->window) {
+ if (topwinPtr && topwinPtr->window) {
result = (long)GetParent(Tk_GetHWND(topwinPtr->window));
} else {
result = 0;
@@ -590,26 +613,29 @@ TkWinEmbeddedEventProc(hwnd, message, wParam, lParam)
}
break;
- case TK_CLAIMFOCUS:
- /* An embedded window requests a focus
- *
- * wParam - a flag of forcing focus
+ case TK_CLAIMFOCUS:
+ /*
+ * An embedded window requests a focus.
+ *
+ * wParam - a flag of forcing focus
* lParam - N/A
*
* Return value:
* 0 - the message is not processed
* 1 - the message is processed
*/
- if(!SetFocus(containerPtr->embeddedHWnd) && wParam) {
+
+ if (!SetFocus(containerPtr->embeddedHWnd) && wParam) {
/*
* forcing focus TBD
*/
}
break;
- case TK_WITHDRAW:
- /* An embedded window requests withdraw
- *
+ case TK_WITHDRAW:
+ /*
+ * An embedded window requests withdraw.
+ *
* wParam - N/A
* lParam - N/A
*
@@ -617,15 +643,18 @@ TkWinEmbeddedEventProc(hwnd, message, wParam, lParam)
* 0 - the message is not processed
* 1 - the message is processed
*/
- if(topwinPtr)
+
+ if (topwinPtr) {
TkpWinToplevelWithDraw(topwinPtr);
- else
+ } else {
result = 0;
+ }
break;
- case TK_ICONIFY:
- /* An embedded window requests iconification
- *
+ case TK_ICONIFY:
+ /*
+ * An embedded window requests iconification.
+ *
* wParam - N/A
* lParam - N/A
*
@@ -633,15 +662,18 @@ TkWinEmbeddedEventProc(hwnd, message, wParam, lParam)
* 0 - the message is not processed
* 1 - the message is processed
*/
- if(topwinPtr)
+
+ if (topwinPtr) {
TkpWinToplevelIconify(topwinPtr);
- else
+ } else {
result = 0;
+ }
break;
- case TK_DEICONIFY:
- /* An embedded window requests deiconification
- *
+ case TK_DEICONIFY:
+ /*
+ * An embedded window requests deiconification.
+ *
* wParam - N/A
* lParam - N/A
*
@@ -649,31 +681,35 @@ TkWinEmbeddedEventProc(hwnd, message, wParam, lParam)
* 0 - the message is not processed
* 1 - the message is processed
*/
- if(topwinPtr)
+ if (topwinPtr) {
TkpWinToplevelDeiconify(topwinPtr);
- else
+ } else {
result = 0;
+ }
break;
- case TK_MOVEWINDOW:
- /* An embedded window requests to move position if
- * both wParam and lParam are greater or equal to 0.
+ case TK_MOVEWINDOW:
+ /*
+ * An embedded window requests to move position if both wParam and
+ * lParam are greater or equal to 0.
* wParam - x value of the frame's upper left
* lParam - y value of the frame's upper left
*
- * Otherwise an embedded window requests the current
- * position
+ * Otherwise an embedded window requests the current position
+ *
+ * Return value: an encoded window position in a 32bit long, i.e,
+ * ((x << 16) & 0xffff0000) | (y & 0xffff)
*
- * Return value: an encoded window position in a 32bit long,
- * i.e, ((x << 16) & 0xffff0000) | (y & 0xffff)
- *
* Only a toplevel container may move the embedded.
*/
- result = TkpWinToplevelMove(containerPtr->parentPtr, wParam, lParam);
+
+ result = TkpWinToplevelMove(containerPtr->parentPtr,
+ wParam, lParam);
break;
- case TK_OVERRIDEREDIRECT:
- /* An embedded window request overrideredirect.
+ case TK_OVERRIDEREDIRECT:
+ /*
+ * An embedded window request overrideredirect.
*
* wParam
* 0 - add a frame if there is no one
@@ -683,18 +719,19 @@ TkWinEmbeddedEventProc(hwnd, message, wParam, lParam)
* lParam - N/A
*
* Return value:
- * 1 + the current value of overrideredirect if the container is
- * a toplevel. Otherwise 0.
+ * 1 + the current value of overrideredirect if the container is a
+ * toplevel. Otherwise 0.
*/
- if(topwinPtr) {
- result = 1+TkpWinToplevelOverrideRedirect(topwinPtr, wParam);
+ if (topwinPtr) {
+ result = 1 + TkpWinToplevelOverrideRedirect(topwinPtr, wParam);
} else {
result = 0;
}
break;
- case TK_SETMENU:
- /* An embedded requests to set a menu
+ case TK_SETMENU:
+ /*
+ * An embedded requests to set a menu.
*
* wParam - a menu handle
* lParam - a menu window handle
@@ -703,7 +740,7 @@ TkWinEmbeddedEventProc(hwnd, message, wParam, lParam)
* 1 - the message is processed
* 0 - the message is not processed
*/
- if(topwinPtr) {
+ if (topwinPtr) {
containerPtr->embeddedMenuHWnd = (HWND)lParam;
TkWinSetMenu((Tk_Window)topwinPtr, (HMENU)wParam);
} else {
@@ -711,8 +748,9 @@ TkWinEmbeddedEventProc(hwnd, message, wParam, lParam)
}
break;
- case TK_STATE:
- /* An embedded window request set/get state services
+ case TK_STATE:
+ /*
+ * An embedded window request set/get state services.
*
* wParam - service directive
* 0 - 3 for setting state
@@ -727,8 +765,9 @@ TkWinEmbeddedEventProc(hwnd, message, wParam, lParam)
* Return value
* 1 + the current state or 0 if the container is not a toplevel
*/
- if(topwinPtr) {
- if(wParam >= 0 && wParam <= 3) {
+
+ if (topwinPtr) {
+ if (wParam >= 0 && wParam <= 3) {
TkpWmSetState(topwinPtr, wParam);
}
result = 1+TkpWmGetState(topwinPtr);
@@ -738,19 +777,19 @@ TkWinEmbeddedEventProc(hwnd, message, wParam, lParam)
break;
/*
- * Return 0 since the current Tk container implementation
- * is unable to provide following services.
- *
+ * Return 0 since the current Tk container implementation is
+ * unable to provide following services.
*/
- default:
- result = 0;
+ default:
+ result = 0;
break;
}
} else {
- if(message == TK_INFO && wParam == TK_CONTAINER_VERIFY) {
+ if ((message == TK_INFO) && (wParam == TK_CONTAINER_VERIFY)) {
/*
* Reply the message sender: this is not a Tk container
*/
+
return -(long)hwnd;
} else {
result = 0;
@@ -765,39 +804,40 @@ TkWinEmbeddedEventProc(hwnd, message, wParam, lParam)
*
* EmbedGeometryRequest --
*
- * This procedure is invoked when an embedded application requests
- * a particular size. It processes the request (which may or may
- * not actually resize the window) and reflects the results back
- * to the embedded application.
+ * This procedure is invoked when an embedded application requests a
+ * particular size. It processes the request (which may or may not
+ * actually resize the window) and reflects the results back to the
+ * embedded application.
*
* Results:
* None.
*
* Side effects:
- * If we deny the child's size change request, a Configure event
- * is synthesized to let the child know that the size is the same
- * as it used to be. Events get processed while we're waiting for
- * the geometry managers to do their thing.
+ * If we deny the child's size change request, a Configure event is
+ * synthesized to let the child know that the size is the same as it used
+ * to be. Events get processed while we're waiting for the geometry
+ * managers to do their thing.
*
*----------------------------------------------------------------------
*/
void
-EmbedGeometryRequest(containerPtr, width, height)
- Container *containerPtr; /* Information about the container window. */
- int width, height; /* Size that the child has requested. */
+EmbedGeometryRequest(
+ Container *containerPtr, /* Information about the container window. */
+ int width, int height) /* Size that the child has requested. */
{
- TkWindow * winPtr = containerPtr->parentPtr;
-
+ TkWindow *winPtr = containerPtr->parentPtr;
+
/*
- * Forward the requested size into our geometry management hierarchy
- * via the container window. We need to send a Configure event back
- * to the embedded application even if we decide not to resize
- * the window; to make this happen, process all idle event handlers
- * synchronously here (so that the geometry managers have had a
- * chance to do whatever they want to do), and if the window's size
- * didn't change then generate a configure event.
+ * Forward the requested size into our geometry management hierarchy via
+ * the container window. We need to send a Configure event back to the
+ * embedded application even if we decide not to resize the window; to
+ * make this happen, process all idle event handlers synchronously here
+ * (so that the geometry managers have had a chance to do whatever they
+ * want to do), and if the window's size didn't change then generate a
+ * configure event.
*/
+
Tk_GeometryRequest((Tk_Window)winPtr, width, height);
if (containerPtr->embeddedHWnd != NULL) {
@@ -805,8 +845,8 @@ EmbedGeometryRequest(containerPtr, width, height)
/* Empty loop body. */
}
- SetWindowPos(containerPtr->embeddedHWnd, NULL,
- 0, 0, winPtr->changes.width, winPtr->changes.height, SWP_NOZORDER);
+ SetWindowPos(containerPtr->embeddedHWnd, NULL, 0, 0,
+ winPtr->changes.width, winPtr->changes.height, SWP_NOZORDER);
}
}
@@ -815,35 +855,41 @@ EmbedGeometryRequest(containerPtr, width, height)
*
* ContainerEventProc --
*
- * This procedure is invoked by the Tk event dispatcher when
- * various useful events are received for the container window.
+ * This procedure is invoked by the Tk event dispatcher when various
+ * useful events are received for the container window.
*
* Results:
* None.
*
* Side effects:
- * Depends on the event. For example, when ConfigureRequest events
- * occur, geometry information gets set for the container window.
+ * Depends on the event. For example, when ConfigureRequest events occur,
+ * geometry information gets set for the container window.
*
*----------------------------------------------------------------------
*/
static void
-ContainerEventProc(clientData, eventPtr)
- ClientData clientData; /* Token for container window. */
- XEvent *eventPtr; /* ResizeRequest event. */
+ContainerEventProc(
+ ClientData clientData, /* Token for container window. */
+ XEvent *eventPtr) /* ResizeRequest event. */
{
Container *containerPtr = (Container *)clientData;
Tk_Window tkwin = (Tk_Window)containerPtr->parentPtr;
if (eventPtr->type == ConfigureNotify) {
- /* Resize the embedded window, if there is any */
+ /*
+ * Resize the embedded window, if there is any.
+ */
+
if (containerPtr->embeddedHWnd) {
- SetWindowPos(containerPtr->embeddedHWnd, NULL,
- 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), SWP_NOZORDER);
+ SetWindowPos(containerPtr->embeddedHWnd, NULL, 0, 0,
+ Tk_Width(tkwin), Tk_Height(tkwin), SWP_NOZORDER);
}
} else if (eventPtr->type == DestroyNotify) {
- /* The container is gone, remove it from the list */
+ /*
+ * The container is gone, remove it from the list.
+ */
+
EmbedWindowDeleted(containerPtr->parentPtr);
}
}
@@ -853,13 +899,13 @@ ContainerEventProc(clientData, eventPtr)
*
* TkpGetOtherWindow --
*
- * If both the container and embedded window are in the same
- * process, this procedure will return either one, given the other.
+ * If both the container and embedded window are in the same process,
+ * this procedure will return either one, given the other.
*
* Results:
* If winPtr is a container, the return value is the token for the
- * embedded window, and vice versa. If the "other" window isn't in
- * this process, NULL is returned.
+ * embedded window, and vice versa. If the "other" window isn't in this
+ * process, NULL is returned.
*
* Side effects:
* None.
@@ -868,12 +914,12 @@ ContainerEventProc(clientData, eventPtr)
*/
TkWindow *
-TkpGetOtherWindow(winPtr)
- TkWindow *winPtr; /* Tk's structure for a container or
- * embedded window. */
+TkpGetOtherWindow(
+ TkWindow *winPtr) /* Tk's structure for a container or embedded
+ * window. */
{
Container *containerPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
for (containerPtr = tsdPtr->firstContainerPtr; containerPtr != NULL;
@@ -906,11 +952,11 @@ TkpGetOtherWindow(winPtr)
*/
HWND
-Tk_GetEmbeddedHWnd(winPtr)
- TkWindow *winPtr;
+Tk_GetEmbeddedHWnd(
+ TkWindow *winPtr)
{
Container *containerPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
for (containerPtr = tsdPtr->firstContainerPtr; containerPtr != NULL;
@@ -940,12 +986,12 @@ Tk_GetEmbeddedHWnd(winPtr)
*/
HWND
-Tk_GetEmbeddedMenuHWND(tkwin)
- Tk_Window tkwin;
+Tk_GetEmbeddedMenuHWND(
+ Tk_Window tkwin)
{
TkWindow *winPtr = (TkWindow*)tkwin;
Container *containerPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
for (containerPtr = tsdPtr->firstContainerPtr; containerPtr != NULL;
@@ -962,10 +1008,10 @@ Tk_GetEmbeddedMenuHWND(tkwin)
*
* TkpClaimFocus --
*
- * This procedure is invoked when someone asks or the input focus
- * to be put on a window in an embedded application, but the
- * application doesn't currently have the focus. It requests the
- * input focus from the container application.
+ * This procedure is invoked when someone asks or the input focus to be
+ * put on a window in an embedded application, but the application
+ * doesn't currently have the focus. It requests the input focus from the
+ * container application.
*
* Results:
* None.
@@ -977,12 +1023,12 @@ Tk_GetEmbeddedMenuHWND(tkwin)
*/
void
-TkpClaimFocus(topLevelPtr, force)
- TkWindow *topLevelPtr; /* Top-level window containing desired
- * focus window; should be embedded. */
- int force; /* One means that the container should
- * claim the focus if it doesn't
- * currently have it. */
+TkpClaimFocus(
+ TkWindow *topLevelPtr, /* Top-level window containing desired focus
+ * window; should be embedded. */
+ int force) /* One means that the container should claim
+ * the focus if it doesn't currently have
+ * it. */
{
HWND hwnd = GetParent(Tk_GetHWND(topLevelPtr->window));
SendMessage(hwnd, TK_CLAIMFOCUS, (WPARAM) force, 0);
@@ -993,13 +1039,13 @@ TkpClaimFocus(topLevelPtr, force)
*
* TkpRedirectKeyEvent --
*
- * This procedure is invoked when a key press or release event
- * arrives for an application that does not believe it owns the
- * input focus. This can happen because of embedding; for example,
- * X can send an event to an embedded application when the real
- * focus window is in the container application and is an ancestor
- * of the container. This procedure's job is to forward the event
- * back to the application where it really belongs.
+ * This procedure is invoked when a key press or release event arrives
+ * for an application that does not believe it owns the input focus.
+ * This can happen because of embedding; for example, X can send an event
+ * to an embedded application when the real focus window is in the
+ * container application and is an ancestor of the container. This
+ * procedure's job is to forward the event back to the application where
+ * it really belongs.
*
* Results:
* None.
@@ -1011,11 +1057,11 @@ TkpClaimFocus(topLevelPtr, force)
*/
void
-TkpRedirectKeyEvent(winPtr, eventPtr)
- TkWindow *winPtr; /* Window to which the event was originally
+TkpRedirectKeyEvent(
+ TkWindow *winPtr, /* Window to which the event was originally
* reported. */
- XEvent *eventPtr; /* X event to redirect (should be KeyPress
- * or KeyRelease). */
+ XEvent *eventPtr) /* X event to redirect (should be KeyPress or
+ * KeyRelease). */
{
/* not implemented */
}
@@ -1025,9 +1071,9 @@ TkpRedirectKeyEvent(winPtr, eventPtr)
*
* EmbedWindowDeleted --
*
- * This procedure is invoked when a window involved in embedding
- * (as either the container or the embedded application) is
- * destroyed. It cleans up the Container structure for the window.
+ * This procedure is invoked when a window involved in embedding (as
+ * either the container or the embedded application) is destroyed. It
+ * cleans up the Container structure for the window.
*
* Results:
* None.
@@ -1039,19 +1085,18 @@ TkpRedirectKeyEvent(winPtr, eventPtr)
*/
static void
-EmbedWindowDeleted(winPtr)
- TkWindow *winPtr; /* Tk's information about window that
- * was deleted. */
+EmbedWindowDeleted(
+ TkWindow *winPtr) /* Tk's information about window that was
+ * deleted. */
{
Container *containerPtr, *prevPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
- * Find the Container structure for this window work. Delete the
+ * Find the Container structure for this window work. Delete the
* information about the embedded application and free the container's
- * record.
- * The main container may be null. [Bug #476176]
+ * record. The main container may be null. [Bug #476176]
*/
prevPtr = NULL;
@@ -1085,3 +1130,11 @@ EmbedWindowDeleted(winPtr)
ckfree((char *) containerPtr);
}
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/win/tkWinFont.c b/win/tkWinFont.c
index 98b24eb..35619c7 100644
--- a/win/tkWinFont.c
+++ b/win/tkWinFont.c
@@ -1,29 +1,29 @@
-/*
+/*
* tkWinFont.c --
*
- * Contains the Windows implementation of the platform-independant
- * font package interface.
+ * Contains the Windows implementation of the platform-independant font
+ * package interface.
*
- * Copyright (c) 1994 Software Research Associates, Inc.
+ * Copyright (c) 1994 Software Research Associates, Inc.
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
* Copyright (c) 1998-1999 by Scriptics Corporation.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinFont.c,v 1.25 2004/08/09 23:45:58 mdejong Exp $
+ * RCS: @(#) $Id: tkWinFont.c,v 1.26 2005/12/02 00:19:04 dkf Exp $
*/
#include "tkWinInt.h"
#include "tkFont.h"
/*
- * The following structure represents a font family. It is assumed that
- * all screen fonts constructed from the same "font family" share certain
- * properties; all screen fonts with the same "font family" point to a
- * shared instance of this structure. The most important shared property
- * is the character existence metrics, used to determine if a screen font
- * can display a given Unicode character.
+ * The following structure represents a font family. It is assumed that all
+ * screen fonts constructed from the same "font family" share certain
+ * properties; all screen fonts with the same "font family" point to a shared
+ * instance of this structure. The most important shared property is the
+ * character existence metrics, used to determine if a screen font can display
+ * a given Unicode character.
*
* Under Windows, a "font family" is uniquely identified by its face name.
*/
@@ -36,69 +36,69 @@
typedef struct FontFamily {
struct FontFamily *nextPtr; /* Next in list of all known font families. */
int refCount; /* How many SubFonts are referring to this
- * FontFamily. When the refCount drops to
+ * FontFamily. When the refCount drops to
* zero, this FontFamily may be freed. */
/*
* Key.
*/
-
+
Tk_Uid faceName; /* Face name key for this FontFamily. */
/*
* Derived properties.
*/
-
+
Tcl_Encoding encoding; /* Encoding for this font family. */
int isSymbolFont; /* Non-zero if this is a symbol font. */
- int isWideFont; /* 1 if this is a double-byte font, 0
+ int isWideFont; /* 1 if this is a double-byte font, 0
* otherwise. */
BOOL (WINAPI *textOutProc)(HDC, int, int, TCHAR *, int);
- /* The procedure to use to draw text after
- * it has been converted from UTF-8 to the
+ /* The procedure to use to draw text after it
+ * has been converted from UTF-8 to the
* encoding of this font. */
BOOL (WINAPI *getTextExtentPoint32Proc)(HDC, TCHAR *, int, LPSIZE);
/* The procedure to use to measure text after
- * it has been converted from UTF-8 to the
+ * it has been converted from UTF-8 to the
* encoding of this font. */
char *fontMap[FONTMAP_PAGES];
/* Two-level sparse table used to determine
* quickly if the specified character exists.
* As characters are encountered, more pages
- * in this table are dynamically added. The
+ * in this table are dynamically added. The
* contents of each page is a bitmask
* consisting of FONTMAP_BITSPERPAGE bits,
* representing whether this font can be used
* to display the given character at the
- * corresponding bit position. The high bits
+ * corresponding bit position. The high bits
* of the character are used to pick which
* page of the table is used. */
/*
* Cached Truetype font info.
*/
-
+
int segCount; /* The length of the following arrays. */
USHORT *startCount; /* Truetype information about the font, */
- USHORT *endCount; /* indicating which characters this font
- * can display (malloced). The format of
- * this information is (relatively) compact,
- * but would take longer to search than
- * indexing into the fontMap[][] table. */
+ USHORT *endCount; /* indicating which characters this font can
+ * display (malloced). The format of this
+ * information is (relatively) compact, but
+ * would take longer to search than indexing
+ * into the fontMap[][] table. */
} FontFamily;
/*
- * The following structure encapsulates an individual screen font. A font
+ * The following structure encapsulates an individual screen font. A font
* object is made up of however many SubFonts are necessary to display a
* stream of multilingual characters.
*/
typedef struct SubFont {
- char **fontMap; /* Pointer to font map from the FontFamily,
+ char **fontMap; /* Pointer to font map from the FontFamily,
* cached here to save a dereference. */
- HFONT hFont; /* The specific screen font that will be
- * used when displaying/measuring chars
- * belonging to the FontFamily. */
+ HFONT hFont; /* The specific screen font that will be used
+ * when displaying/measuring chars belonging
+ * to the FontFamily. */
FontFamily *familyPtr; /* The FontFamily for this SubFont. */
} SubFont;
@@ -111,18 +111,18 @@ typedef struct SubFont {
#define BASE_CHARS 128
typedef struct WinFont {
- TkFont font; /* Stuff used by generic font package. Must
- * be first in structure. */
+ TkFont font; /* Stuff used by generic font package. Must be
+ * first in structure. */
SubFont staticSubFonts[SUBFONT_SPACE];
/* Builtin space for a limited number of
* SubFonts. */
int numSubFonts; /* Length of following array. */
- SubFont *subFontArray; /* Array of SubFonts that have been loaded
- * in order to draw/measure all the characters
- * encountered by this font so far. All fonts
+ SubFont *subFontArray; /* Array of SubFonts that have been loaded in
+ * order to draw/measure all the characters
+ * encountered by this font so far. All fonts
* start off with one SubFont initialized by
* AllocFont() from the original set of font
- * attributes. Usually points to
+ * attributes. Usually points to
* staticSubFonts, but may point to malloced
* space if there are lots of SubFonts. */
@@ -131,10 +131,10 @@ typedef struct WinFont {
* offscreen measurements. */
int pixelSize; /* Original pixel size used when font was
* constructed. */
- int widths[BASE_CHARS]; /* Widths of first 128 chars in the base
- * font, for handling common case. The base
- * font is always used to draw characters
- * between 0x0000 and 0x007f. */
+ int widths[BASE_CHARS]; /* Widths of first 128 chars in the base font,
+ * for handling common case. The base font is
+ * always used to draw characters between
+ * 0x0000 and 0x007f. */
} WinFont;
/*
@@ -168,11 +168,11 @@ static TkStateMap systemMap[] = {
};
typedef struct ThreadSpecificData {
- FontFamily *fontFamilyList; /* The list of font families that are
- * currently loaded. As screen fonts
- * are loaded, this list grows to hold
- * information about what characters
- * exist in each font family. */
+ FontFamily *fontFamilyList; /* The list of font families that are
+ * currently loaded. As screen fonts are
+ * loaded, this list grows to hold information
+ * about what characters exist in each font
+ * family. */
Tcl_HashTable uidTable;
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
@@ -180,7 +180,7 @@ static Tcl_ThreadDataKey dataKey;
/*
* Information cached about the system at startup time.
*/
-
+
static Tcl_Encoding systemEncoding;
/*
@@ -188,10 +188,10 @@ static Tcl_Encoding systemEncoding;
*/
static FontFamily * AllocFontFamily(HDC hdc, HFONT hFont, int base);
-static SubFont * CanUseFallback(HDC hdc, WinFont *fontPtr,
+static SubFont * CanUseFallback(HDC hdc, WinFont *fontPtr,
char *fallbackName, int ch,
SubFont **subFontPtrPtr);
-static SubFont * CanUseFallbackWithAliases(HDC hdc, WinFont *fontPtr,
+static SubFont * CanUseFallbackWithAliases(HDC hdc, WinFont *fontPtr,
char *faceName, int ch, Tcl_DString *nameTriedPtr,
SubFont **subFontPtrPtr);
static int FamilyExists(HDC hdc, CONST char *faceName);
@@ -204,44 +204,44 @@ static int FontMapLookup(SubFont *subFontPtr, int ch);
static void FreeFontFamily(FontFamily *familyPtr);
static HFONT GetScreenFont(CONST TkFontAttributes *faPtr,
CONST char *faceName, int pixelSize);
-static void InitFont(Tk_Window tkwin, HFONT hFont,
+static void InitFont(Tk_Window tkwin, HFONT hFont,
int overstrike, WinFont *tkFontPtr);
-static void InitSubFont(HDC hdc, HFONT hFont, int base,
+static void InitSubFont(HDC hdc, HFONT hFont, int base,
SubFont *subFontPtr);
-static int LoadFontRanges(HDC hdc, HFONT hFont,
+static int LoadFontRanges(HDC hdc, HFONT hFont,
USHORT **startCount, USHORT **endCount,
int *symbolPtr);
-static void MultiFontTextOut(HDC hdc, WinFont *fontPtr,
+static void MultiFontTextOut(HDC hdc, WinFont *fontPtr,
CONST char *source, int numBytes, int x, int y);
static void ReleaseFont(WinFont *fontPtr);
static void ReleaseSubFont(SubFont *subFontPtr);
static int SeenName(CONST char *name, Tcl_DString *dsPtr);
static void SwapLong(PULONG p);
static void SwapShort(USHORT *p);
-static int CALLBACK WinFontCanUseProc(ENUMLOGFONT *lfPtr,
- NEWTEXTMETRIC *tmPtr, int fontType,
+static int CALLBACK WinFontCanUseProc(ENUMLOGFONT *lfPtr,
+ NEWTEXTMETRIC *tmPtr, int fontType,
LPARAM lParam);
-static int CALLBACK WinFontExistProc(ENUMLOGFONT *lfPtr,
- NEWTEXTMETRIC *tmPtr, int fontType,
+static int CALLBACK WinFontExistProc(ENUMLOGFONT *lfPtr,
+ NEWTEXTMETRIC *tmPtr, int fontType,
LPARAM lParam);
-static int CALLBACK WinFontFamilyEnumProc(ENUMLOGFONT *lfPtr,
- NEWTEXTMETRIC *tmPtr, int fontType,
+static int CALLBACK WinFontFamilyEnumProc(ENUMLOGFONT *lfPtr,
+ NEWTEXTMETRIC *tmPtr, int fontType,
LPARAM lParam);
/*
*-------------------------------------------------------------------------
- *
+ *
* TkpFontPkgInit --
*
- * This procedure is called when an application is created. It
- * initializes all the structures that are used by the
- * platform-dependent code on a per application basis.
+ * This procedure is called when an application is created. It
+ * initializes all the structures that are used by the platform-dependent
+ * code on a per application basis.
*
* Results:
- * None.
+ * None.
*
* Side effects:
- *
+ *
* None.
*
*-------------------------------------------------------------------------
@@ -253,9 +253,9 @@ TkpFontPkgInit(
{
if (TkWinGetPlatformId() == VER_PLATFORM_WIN32_NT) {
/*
- * If running NT, then we will be calling some Unicode functions
- * explictly. So, even if the Tcl system encoding isn't Unicode,
- * make sure we convert to/from the Unicode char set.
+ * If running NT, then we will be calling some Unicode functions
+ * explictly. So, even if the Tcl system encoding isn't Unicode, make
+ * sure we convert to/from the Unicode char set.
*/
systemEncoding = TkWinGetUnicodeEncoding();
@@ -270,17 +270,18 @@ TkpFontPkgInit(
* Map a platform-specific native font name to a TkFont.
*
* Results:
- * The return value is a pointer to a TkFont that represents the
- * native font. If a native font by the given name could not be
- * found, the return value is NULL.
+
+ * The return value is a pointer to a TkFont that represents the native
+ * font. If a native font by the given name could not be found, the
+ * return value is NULL.
*
- * Every call to this procedure returns a new TkFont structure,
- * even if the name has already been seen before. The caller should
- * call TkpDeleteFont() when the font is no longer needed.
+ * Every call to this procedure returns a new TkFont structure, even if
+ * the name has already been seen before. The caller should call
+ * TkpDeleteFont() when the font is no longer needed.
*
- * The caller is responsible for initializing the memory associated
- * with the generic TkFont when this function returns and releasing
- * the contents of the generic TkFont before calling TkpDeleteFont().
+ * The caller is responsible for initializing the memory associated with
+ * the generic TkFont when this function returns and releasing the
+ * contents of the generic TkFont before calling TkpDeleteFont().
*
* Side effects:
* Memory allocated.
@@ -311,25 +312,25 @@ TkpGetNativeFont(
/*
*---------------------------------------------------------------------------
*
- * TkpGetFontFromAttributes --
+ * TkpGetFontFromAttributes --
*
- * Given a desired set of attributes for a font, find a font with
- * the closest matching attributes.
+ * Given a desired set of attributes for a font, find a font with the
+ * closest matching attributes.
*
* Results:
- * The return value is a pointer to a TkFont that represents the
- * font with the desired attributes. If a font with the desired
- * attributes could not be constructed, some other font will be
- * substituted automatically. NULL is never returned.
+ * The return value is a pointer to a TkFont that represents the font
+ * with the desired attributes. If a font with the desired attributes
+ * could not be constructed, some other font will be substituted
+ * automatically. NULL is never returned.
*
- * Every call to this procedure returns a new TkFont structure,
- * even if the specified attributes have already been seen before.
- * The caller should call TkpDeleteFont() to free the platform-
- * specific data when the font is no longer needed.
+ * Every call to this procedure returns a new TkFont structure, even if
+ * the specified attributes have already been seen before. The caller
+ * should call TkpDeleteFont() to free the platform- specific data when
+ * the font is no longer needed.
*
- * The caller is responsible for initializing the memory associated
- * with the generic TkFont when this function returns and releasing
- * the contents of the generic TkFont before calling TkpDeleteFont().
+ * The caller is responsible for initializing the memory associated with
+ * the generic TkFont when this function returns and releasing the
+ * contents of the generic TkFont before calling TkpDeleteFont().
*
* Side effects:
* Memory allocated.
@@ -339,11 +340,11 @@ TkpGetNativeFont(
TkFont *
TkpGetFontFromAttributes(
- TkFont *tkFontPtr, /* If non-NULL, store the information in
- * this existing TkFont structure, rather than
+ TkFont *tkFontPtr, /* If non-NULL, store the information in this
+ * existing TkFont structure, rather than
* allocating a new structure to hold the
* font; the existing contents of the font
- * will be released. If NULL, a new TkFont
+ * will be released. If NULL, a new TkFont
* structure is allocated. */
Tk_Window tkwin, /* For display where font will be used. */
CONST TkFontAttributes *faPtr)
@@ -399,10 +400,11 @@ TkpGetFontFromAttributes(
}
}
- found:
+ found:
ReleaseDC(hwnd, hdc);
- hFont = GetScreenFont(faPtr, faceName, TkFontGetPixels(tkwin, faPtr->size));
+ hFont = GetScreenFont(faPtr, faceName,
+ TkFontGetPixels(tkwin, faPtr->size));
if (tkFontPtr == NULL) {
fontPtr = (WinFont *) ckalloc(sizeof(WinFont));
} else {
@@ -420,9 +422,9 @@ TkpGetFontFromAttributes(
* TkpDeleteFont --
*
* Called to release a font allocated by TkpGetNativeFont() or
- * TkpGetFontFromAttributes(). The caller should have already
- * released the fields of the TkFont that are used exclusively by
- * the generic TkFont code.
+ * TkpGetFontFromAttributes(). The caller should have already released
+ * the fields of the TkFont that are used exclusively by the generic
+ * TkFont code.
*
* Results:
* None.
@@ -448,8 +450,8 @@ TkpDeleteFont(
*
* TkpGetFontFamilies, WinFontFamilyEnumProc --
*
- * Return information about the font families that are available
- * on the display of the given window.
+ * Return information about the font families that are available on the
+ * display of the given window.
*
* Results:
* Modifies interp's result object to hold a list of all the available
@@ -460,12 +462,12 @@ TkpDeleteFont(
*
*---------------------------------------------------------------------------
*/
-
+
void
TkpGetFontFamilies(
Tcl_Interp *interp, /* Interp to hold result. */
Tk_Window tkwin) /* For display to query. */
-{
+{
HDC hdc;
HWND hwnd;
Window window;
@@ -475,18 +477,18 @@ TkpGetFontFamilies(
hdc = GetDC(hwnd);
/*
- * On any version NT, there may fonts with international names.
- * Use the NT-only Unicode version of EnumFontFamilies to get the
- * font names. If we used the ANSI version on a non-internationalized
- * version of NT, we would get font names with '?' replacing all
- * the international characters.
+ * On any version NT, there may fonts with international names. Use the
+ * NT-only Unicode version of EnumFontFamilies to get the font names. If
+ * we used the ANSI version on a non-internationalized version of NT, we
+ * would get font names with '?' replacing all the international
+ * characters.
*
- * On a non-internationalized verson of 95, fonts with international
- * names are not allowed, so the ANSI version of EnumFontFamilies will
- * work. On an internationalized version of 95, there may be fonts with
- * international names; the ANSI version will work, fetching the
- * name in the system code page. Can't use the Unicode version of
- * EnumFontFamilies because it only exists under NT.
+ * On a non-internationalized verson of 95, fonts with international names
+ * are not allowed, so the ANSI version of EnumFontFamilies will work. On
+ * an internationalized version of 95, there may be fonts with
+ * international names; the ANSI version will work, fetching the name in
+ * the system code page. Can't use the Unicode version of EnumFontFamilies
+ * because it only exists under NT.
*/
if (TkWinGetPlatformId() == VER_PLATFORM_WIN32_NT) {
@@ -495,10 +497,10 @@ TkpGetFontFamilies(
} else {
EnumFontFamiliesA(hdc, NULL, (FONTENUMPROCA) WinFontFamilyEnumProc,
(LPARAM) interp);
- }
+ }
ReleaseDC(hwnd, hdc);
}
-
+
static int CALLBACK
WinFontFamilyEnumProc(
ENUMLOGFONT *lfPtr, /* Logical-font data. */
@@ -526,19 +528,19 @@ WinFontFamilyEnumProc(
*
* TkpGetSubFonts --
*
- * A function used by the testing package for querying the actual
- * screen fonts that make up a font object.
+ * A function used by the testing package for querying the actual screen
+ * fonts that make up a font object.
*
* Results:
- * Modifies interp's result object to hold a list containing the
- * names of the screen fonts that make up the given font object.
+ * Modifies interp's result object to hold a list containing the names of
+ * the screen fonts that make up the given font object.
*
* Side effects:
* None.
*
*-------------------------------------------------------------------------
*/
-
+
void
TkpGetSubFonts(
Tcl_Interp *interp, /* Interp to hold result. */
@@ -549,7 +551,7 @@ TkpGetSubFonts(
FontFamily *familyPtr;
Tcl_Obj *resultPtr, *strPtr;
- resultPtr = Tcl_GetObjResult(interp);
+ resultPtr = Tcl_GetObjResult(interp);
fontPtr = (WinFont *) tkfont;
for (i = 0; i < fontPtr->numSubFonts; i++) {
familyPtr = fontPtr->subFontArray[i].familyPtr;
@@ -563,16 +565,14 @@ TkpGetSubFonts(
*
* Tk_MeasureChars --
*
- * Determine the number of bytes from the string that will fit
- * in the given horizontal span. The measurement is done under the
- * assumption that Tk_DrawChars() will be used to actually display
- * the characters.
+ * Determine the number of bytes from the string that will fit in the
+ * given horizontal span. The measurement is done under the assumption
+ * that Tk_DrawChars() will be used to actually display the characters.
*
* Results:
- * The return value is the number of bytes from source that
- * fit into the span that extends from 0 to maxLength. *lengthPtr is
- * filled with the x-coordinate of the right edge of the last
- * character that did fit.
+ * The return value is the number of bytes from source that fit into the
+ * span that extends from 0 to maxLength. *lengthPtr is filled with the
+ * x-coordinate of the right edge of the last character that did fit.
*
* Side effects:
* None.
@@ -583,25 +583,25 @@ TkpGetSubFonts(
int
Tk_MeasureChars(
Tk_Font tkfont, /* Font in which characters will be drawn. */
- CONST char *source, /* UTF-8 string to be displayed. Need not be
+ CONST char *source, /* UTF-8 string to be displayed. Need not be
* '\0' terminated. */
- int numBytes, /* Maximum number of bytes to consider
- * from source string. */
+ int numBytes, /* Maximum number of bytes to consider from
+ * source string. */
int maxLength, /* If >= 0, maxLength specifies the longest
* permissible line length in pixels; don't
* consider any character that would cross
- * this x-position. If < 0, then line length
+ * this x-position. If < 0, then line length
* is unbounded and the flags argument is
* ignored. */
int flags, /* Various flag bits OR-ed together:
* TK_PARTIAL_OK means include the last char
* which only partially fits on this line.
* TK_WHOLE_WORDS means stop on a word
- * boundary, if possible.
- * TK_AT_LEAST_ONE means return at least one
- * character (or at least the first partial
- * word in case TK_WHOLE_WORDS is also set)
- * even if no characters (words) fit. */
+ * boundary, if possible. TK_AT_LEAST_ONE
+ * means return at least one character (or at
+ * least the first partial word in case
+ * TK_WHOLE_WORDS is also set) even if no
+ * characters (words) fit. */
int *lengthPtr) /* Filled with x-location just after the
* terminating character. */
{
@@ -618,10 +618,9 @@ Tk_MeasureChars(
SubFont *lastSubFontPtr;
CONST char *p, *end, *next, *start;
-
if (numBytes == 0) {
- *lengthPtr = 0;
- return 0;
+ *lengthPtr = 0;
+ return 0;
}
fontPtr = (WinFont *) tkfont;
@@ -632,8 +631,8 @@ Tk_MeasureChars(
/*
* A three step process:
- * 1. Find a contiguous range of characters that can all be
- * represented by a single screen font.
+ * 1. Find a contiguous range of characters that can all be represented by
+ * a single screen font.
* 2. Convert those chars to the encoding of that font.
* 3. Measure converted chars.
*/
@@ -643,107 +642,103 @@ Tk_MeasureChars(
start = source;
end = start + numBytes;
for (p = start; p < end; ) {
- next = p + Tcl_UtfToUniChar(p, &ch);
- thisSubFontPtr = FindSubFontForChar(fontPtr, ch, &lastSubFontPtr);
- if (thisSubFontPtr != lastSubFontPtr) {
- familyPtr = lastSubFontPtr->familyPtr;
- Tcl_UtfToExternalDString(familyPtr->encoding, start,
- (int) (p - start), &runString);
- size.cx = 0;
- (*familyPtr->getTextExtentPoint32Proc)(hdc,
- Tcl_DStringValue(&runString),
- Tcl_DStringLength(&runString) >> familyPtr->isWideFont,
- &size);
- Tcl_DStringFree(&runString);
- if (maxLength >= 0 && (curX+size.cx) > maxLength) {
- moretomeasure = 1;
- break;
- }
- curX += size.cx;
- lastSubFontPtr = thisSubFontPtr;
- start = p;
-
- SelectObject(hdc, lastSubFontPtr->hFont);
- }
- p = next;
+ next = p + Tcl_UtfToUniChar(p, &ch);
+ thisSubFontPtr = FindSubFontForChar(fontPtr, ch, &lastSubFontPtr);
+ if (thisSubFontPtr != lastSubFontPtr) {
+ familyPtr = lastSubFontPtr->familyPtr;
+ Tcl_UtfToExternalDString(familyPtr->encoding, start,
+ (int) (p - start), &runString);
+ size.cx = 0;
+ (*familyPtr->getTextExtentPoint32Proc)(hdc,
+ Tcl_DStringValue(&runString),
+ Tcl_DStringLength(&runString) >> familyPtr->isWideFont,
+ &size);
+ Tcl_DStringFree(&runString);
+ if (maxLength >= 0 && (curX+size.cx) > maxLength) {
+ moretomeasure = 1;
+ break;
+ }
+ curX += size.cx;
+ lastSubFontPtr = thisSubFontPtr;
+ start = p;
+
+ SelectObject(hdc, lastSubFontPtr->hFont);
+ }
+ p = next;
}
if (!moretomeasure) {
- /*
- * We get here if the previous loop was just finished
- * normally, without a break. Just measure the last run and
- * that's it.
- */
+ /*
+ * We get here if the previous loop was just finished normally,
+ * without a break. Just measure the last run and that's it.
+ */
familyPtr = lastSubFontPtr->familyPtr;
- Tcl_UtfToExternalDString(familyPtr->encoding, start,
- (int) (p - start), &runString);
- size.cx = 0;
+ Tcl_UtfToExternalDString(familyPtr->encoding, start,
+ (int) (p - start), &runString);
+ size.cx = 0;
(*familyPtr->getTextExtentPoint32Proc)(hdc,
Tcl_DStringValue(&runString),
- Tcl_DStringLength(&runString) >> familyPtr->isWideFont,
+ Tcl_DStringLength(&runString) >> familyPtr->isWideFont,
&size);
- Tcl_DStringFree(&runString);
- if (maxLength >= 0 && (curX+size.cx) > maxLength) {
- moretomeasure = 1;
- } else {
+ Tcl_DStringFree(&runString);
+ if (maxLength >= 0 && (curX+size.cx) > maxLength) {
+ moretomeasure = 1;
+ } else {
curX += size.cx;
- p = end;
- }
+ p = end;
+ }
}
if (moretomeasure) {
/*
- * We get here if the measurement of the last run was over the
- * maxLength limit. We need to restart this run and do it
- * char by char, but always in context with the previous text
- * to account for kerning (especially italics).
+ * We get here if the measurement of the last run was over the
+ * maxLength limit. We need to restart this run and do it char by
+ * char, but always in context with the previous text to account for
+ * kerning (especially italics).
*/
- char buf[16];
- int dstWrote;
- int lastSize = 0;
+ char buf[16];
+ int dstWrote;
+ int lastSize = 0;
familyPtr = lastSubFontPtr->familyPtr;
- Tcl_DStringInit(&runString);
- for (p = start; p < end; ) {
- next = p + Tcl_UtfToUniChar(p, &ch);
- Tcl_UtfToExternal(NULL, familyPtr->encoding, p,
- (int) (next - p), 0, NULL, buf, sizeof(buf), NULL,
- &dstWrote, NULL);
- Tcl_DStringAppend(&runString,buf,dstWrote);
- size.cx = 0;
- (*familyPtr->getTextExtentPoint32Proc)(hdc,
- Tcl_DStringValue(&runString),
- Tcl_DStringLength(&runString) >> familyPtr->isWideFont,
- &size);
- if ((curX+size.cx) > maxLength) {
+ Tcl_DStringInit(&runString);
+ for (p = start; p < end; ) {
+ next = p + Tcl_UtfToUniChar(p, &ch);
+ Tcl_UtfToExternal(NULL, familyPtr->encoding, p,
+ (int) (next - p), 0, NULL, buf, sizeof(buf), NULL,
+ &dstWrote, NULL);
+ Tcl_DStringAppend(&runString,buf,dstWrote);
+ size.cx = 0;
+ (*familyPtr->getTextExtentPoint32Proc)(hdc,
+ Tcl_DStringValue(&runString),
+ Tcl_DStringLength(&runString) >> familyPtr->isWideFont,
+ &size);
+ if ((curX+size.cx) > maxLength) {
break;
}
- lastSize = size.cx;
+ lastSize = size.cx;
p = next;
}
- Tcl_DStringFree(&runString);
-
- /*
- * "p" points to the first character that doesn't fit in the
- * desired span. Look at the flags to figure out whether to
- * include this next character.
- */
-
- if ((p < end)
- && (((flags & TK_PARTIAL_OK) && (curX != maxLength))
- || ((p == source) && (flags & TK_AT_LEAST_ONE)
- && (curX == 0)))) {
-
- /*
- * Include the first character that didn't quite fit in
- * the desired span. The width returned will include the
- * width of that extra character.
- */
-
- p = next;
- curX += size.cx;
+ Tcl_DStringFree(&runString);
+
+ /*
+ * "p" points to the first character that doesn't fit in the desired
+ * span. Look at the flags to figure out whether to include this next
+ * character.
+ */
+
+ if ((p < end) && (((flags & TK_PARTIAL_OK) && (curX != maxLength))
+ || ((p==source) && (flags&TK_AT_LEAST_ONE) && (curX==0)))) {
+ /*
+ * Include the first character that didn't quite fit in the
+ * desired span. The width returned will include the width of that
+ * extra character.
+ */
+
+ p = next;
+ curX += size.cx;
} else {
curX += lastSize;
}
@@ -753,38 +748,36 @@ Tk_MeasureChars(
ReleaseDC(fontPtr->hwnd, hdc);
if ((flags & TK_WHOLE_WORDS) && (p < end)) {
+ /*
+ * Scan the string for the last word break and than repeat the whole
+ * procedure without the maxLength limit or any flags.
+ */
- /*
- * Scan the string for the last word break and than repeat the
- * whole procedure without the maxLength limit or any flags.
- */
-
- CONST char *lastWordBreak = NULL;
- Tcl_UniChar ch2;
-
- end = p;
- p = source;
- ch = ' ';
- while (p < end) {
- next = p + Tcl_UtfToUniChar(p, &ch2);
- if ((ch != ' ') && (ch2 == ' ')) {
- lastWordBreak = p;
- }
- p = next;
- ch = ch2;
- }
-
- if (lastWordBreak != NULL) {
- return Tk_MeasureChars(
- tkfont, source, lastWordBreak-source, -1, 0, lengthPtr);
- } else {
- if (flags & TK_AT_LEAST_ONE) {
- p = end;
- } else {
- p = source;
- curX = 0;
- }
- }
+ CONST char *lastWordBreak = NULL;
+ Tcl_UniChar ch2;
+
+ end = p;
+ p = source;
+ ch = ' ';
+ while (p < end) {
+ next = p + Tcl_UtfToUniChar(p, &ch2);
+ if ((ch != ' ') && (ch2 == ' ')) {
+ lastWordBreak = p;
+ }
+ p = next;
+ ch = ch2;
+ }
+
+ if (lastWordBreak != NULL) {
+ return Tk_MeasureChars(tkfont, source, lastWordBreak-source,
+ -1, 0, lengthPtr);
+ }
+ if (flags & TK_AT_LEAST_ONE) {
+ p = end;
+ } else {
+ p = source;
+ curX = 0;
+ }
}
*lengthPtr = curX;
@@ -796,7 +789,7 @@ Tk_MeasureChars(
*
* Tk_DrawChars --
*
- * Draw a string of characters on the screen.
+ * Draw a string of characters on the screen.
*
* Results:
* None.
@@ -814,12 +807,12 @@ Tk_DrawChars(
GC gc, /* Graphics context for drawing characters. */
Tk_Font tkfont, /* Font in which characters will be drawn;
* must be the same as font used in GC. */
- CONST char *source, /* UTF-8 string to be displayed. Need not be
- * '\0' terminated. All Tk meta-characters
+ CONST char *source, /* UTF-8 string to be displayed. Need not be
+ * '\0' terminated. All Tk meta-characters
* (tabs, control characters, and newlines)
* should be stripped out of the string that
- * is passed to this function. If they are
- * not stripped out, they will be displayed as
+ * is passed to this function. If they are not
+ * stripped out, they will be displayed as
* regular printing characters. */
int numBytes, /* Number of bytes in string. */
int x, int y) /* Coordinates at which to place origin of
@@ -839,10 +832,10 @@ Tk_DrawChars(
dc = TkWinGetDrawableDC(display, drawable, &state);
SetROP2(dc, tkpWinRopModes[gc->function]);
-
- if ((gc->clip_mask != None) &&
- ((TkpClipMask*)gc->clip_mask)->type == TKP_CLIP_REGION) {
- SelectClipRgn(dc, (HRGN)((TkpClipMask*)gc->clip_mask)->value.region);
+
+ if ((gc->clip_mask != None) &&
+ ((TkpClipMask*)gc->clip_mask)->type == TKP_CLIP_REGION) {
+ SelectClipRgn(dc, (HRGN)((TkpClipMask*)gc->clip_mask)->value.region);
}
if ((gc->fill_style == FillStippled
@@ -862,7 +855,7 @@ Tk_DrawChars(
/*
* Select stipple pattern into destination dc.
*/
-
+
dcMem = CreateCompatibleDC(dc);
stipple = CreatePatternBrush(twdPtr->bitmap.handle);
@@ -886,8 +879,8 @@ Tk_DrawChars(
/*
* The following code is tricky because fonts are rendered in multiple
- * colors. First we draw onto a black background and copy the white
- * bits. Then we draw onto a white background and copy the black bits.
+ * colors. First we draw onto a black background and copy the white
+ * bits. Then we draw onto a white background and copy the black bits.
* Both the foreground and background bits of the font are ANDed with
* the stipple pattern as they are copied.
*/
@@ -958,18 +951,17 @@ Tk_DrawChars(
*
* MultiFontTextOut --
*
- * Helper function for Tk_DrawChars. Draws characters, using the
- * various screen fonts in fontPtr to draw multilingual characters.
- * Note: No bidirectional support.
+ * Helper function for Tk_DrawChars. Draws characters, using the various
+ * screen fonts in fontPtr to draw multilingual characters. Note: No
+ * bidirectional support.
*
* Results:
* None.
*
* Side effects:
- * Information gets drawn on the screen.
- * Contents of fontPtr may be modified if more subfonts were loaded
- * in order to draw all the multilingual characters in the given
- * string.
+ * Information gets drawn on the screen. Contents of fontPtr may be
+ * modified if more subfonts were loaded in order to draw all the
+ * multilingual characters in the given string.
*
*-------------------------------------------------------------------------
*/
@@ -981,8 +973,8 @@ MultiFontTextOut(
* following string. */
CONST char *source, /* Potentially multilingual UTF-8 string. */
int numBytes, /* Length of string in bytes. */
- int x, int y) /* Coordinates at which to place origin *
- * of string when drawing. */
+ int x, int y) /* Coordinates at which to place origin of
+ * string when drawing. */
{
Tcl_UniChar ch;
SIZE size;
@@ -999,27 +991,27 @@ MultiFontTextOut(
end = source + numBytes;
for (p = source; p < end; ) {
- next = p + Tcl_UtfToUniChar(p, &ch);
- thisSubFontPtr = FindSubFontForChar(fontPtr, ch, &lastSubFontPtr);
- if (thisSubFontPtr != lastSubFontPtr) {
- if (p > source) {
+ next = p + Tcl_UtfToUniChar(p, &ch);
+ thisSubFontPtr = FindSubFontForChar(fontPtr, ch, &lastSubFontPtr);
+ if (thisSubFontPtr != lastSubFontPtr) {
+ if (p > source) {
familyPtr = lastSubFontPtr->familyPtr;
Tcl_UtfToExternalDString(familyPtr->encoding, source,
(int) (p - source), &runString);
- (*familyPtr->textOutProc)(hdc, x-(tm.tmOverhang/2), y,
+ (*familyPtr->textOutProc)(hdc, x-(tm.tmOverhang/2), y,
Tcl_DStringValue(&runString),
- Tcl_DStringLength(&runString) >> familyPtr->isWideFont);
- (*familyPtr->getTextExtentPoint32Proc)(hdc,
+ Tcl_DStringLength(&runString)>>familyPtr->isWideFont);
+ (*familyPtr->getTextExtentPoint32Proc)(hdc,
Tcl_DStringValue(&runString),
- Tcl_DStringLength(&runString) >> familyPtr->isWideFont,
+ Tcl_DStringLength(&runString) >> familyPtr->isWideFont,
&size);
x += size.cx;
Tcl_DStringFree(&runString);
}
- lastSubFontPtr = thisSubFontPtr;
- source = p;
+ lastSubFontPtr = thisSubFontPtr;
+ source = p;
SelectObject(hdc, lastSubFontPtr->hFont);
- GetTextMetrics(hdc, &tm);
+ GetTextMetrics(hdc, &tm);
}
p = next;
}
@@ -1028,7 +1020,7 @@ MultiFontTextOut(
Tcl_UtfToExternalDString(familyPtr->encoding, source,
(int) (p - source), &runString);
(*familyPtr->textOutProc)(hdc, x-(tm.tmOverhang/2), y,
- Tcl_DStringValue(&runString),
+ Tcl_DStringValue(&runString),
Tcl_DStringLength(&runString) >> familyPtr->isWideFont);
Tcl_DStringFree(&runString);
}
@@ -1041,12 +1033,12 @@ MultiFontTextOut(
* InitFont --
*
* Helper for TkpGetNativeFont() and TkpGetFontFromAttributes().
- * Initializes the memory for a new WinFont that wraps the
+ * Initializes the memory for a new WinFont that wraps the
* platform-specific data.
*
- * The caller is responsible for initializing the fields of the
- * WinFont that are used exclusively by the generic TkFont code, and
- * for releasing those fields before calling TkpDeleteFont().
+ * The caller is responsible for initializing the fields of the WinFont
+ * that are used exclusively by the generic TkFont code, and for
+ * releasing those fields before calling TkpDeleteFont().
*
* Results:
* Fills the WinFont structure.
@@ -1055,17 +1047,17 @@ MultiFontTextOut(
* Memory allocated.
*
*---------------------------------------------------------------------------
- */
+ */
static void
InitFont(
- Tk_Window tkwin, /* Main window of interp in which font will
- * be used, for getting HDC. */
+ Tk_Window tkwin, /* Main window of interp in which font will be
+ * used, for getting HDC. */
HFONT hFont, /* Windows token for font. */
- int overstrike, /* The overstrike attribute of logfont used
- * to allocate this font. For some reason,
- * the TEXTMETRICs may contain incorrect info
- * in the tmStruckOut field. */
+ int overstrike, /* The overstrike attribute of logfont used to
+ * allocate this font. For some reason, the
+ * TEXTMETRICs may contain incorrect info in
+ * the tmStruckOut field. */
WinFont *fontPtr) /* Filled with information constructed from
* the above arguments. */
{
@@ -1079,7 +1071,7 @@ InitFont(
Tcl_DString faceString;
TkFontAttributes *faPtr;
char buf[LF_FACESIZE * sizeof(WCHAR)];
-
+
window = Tk_WindowId(tkwin);
hwnd = (window == None) ? NULL : TkWinGetHWND(window);
hdc = GetDC(hwnd);
@@ -1088,18 +1080,18 @@ InitFont(
GetTextMetrics(hdc, &tm);
/*
- * On any version NT, there may fonts with international names.
- * Use the NT-only Unicode version of GetTextFace to get the font's
- * name. If we used the ANSI version on a non-internationalized
- * version of NT, we would get a font name with '?' replacing all
- * the international characters.
+ * On any version NT, there may fonts with international names. Use the
+ * NT-only Unicode version of GetTextFace to get the font's name. If we
+ * used the ANSI version on a non-internationalized version of NT, we
+ * would get a font name with '?' replacing all the international
+ * characters.
*
- * On a non-internationalized verson of 95, fonts with international
- * names are not allowed, so the ANSI version of GetTextFace will work.
- * On an internationalized version of 95, there may be fonts with
- * international names; the ANSI version will work, fetching the
- * name in the international system code page. Can't use the Unicode
- * version of GetTextFace because it only exists under NT.
+ * On a non-internationalized verson of 95, fonts with international names
+ * are not allowed, so the ANSI version of GetTextFace will work. On an
+ * internationalized version of 95, there may be fonts with international
+ * names; the ANSI version will work, fetching the name in the
+ * international system code page. Can't use the Unicode version of
+ * GetTextFace because it only exists under NT.
*/
if (TkWinGetPlatformId() == VER_PLATFORM_WIN32_NT) {
@@ -1113,12 +1105,14 @@ InitFont(
faPtr = &fontPtr->font.fa;
faPtr->family = Tk_GetUid(Tcl_DStringValue(&faceString));
- faPtr->size = TkFontGetPoints(tkwin, -(tm.tmHeight - tm.tmInternalLeading));
- faPtr->weight = (tm.tmWeight > FW_MEDIUM) ? TK_FW_BOLD : TK_FW_NORMAL;
+ faPtr->size =
+ TkFontGetPoints(tkwin, -(tm.tmHeight - tm.tmInternalLeading));
+ faPtr->weight =
+ (tm.tmWeight > FW_MEDIUM) ? TK_FW_BOLD : TK_FW_NORMAL;
faPtr->slant = (tm.tmItalic != 0) ? TK_FS_ITALIC : TK_FS_ROMAN;
faPtr->underline = (tm.tmUnderlined != 0) ? 1 : 0;
faPtr->overstrike = overstrike;
-
+
fmPtr = &fontPtr->font.fm;
fmPtr->ascent = tm.tmAscent;
fmPtr->descent = tm.tmDescent;
@@ -1137,7 +1131,7 @@ InitFont(
GetCharWidthW(hdc, 0, BASE_CHARS - 1, fontPtr->widths);
} else {
GetCharWidthA(hdc, 0, BASE_CHARS - 1, fontPtr->widths);
- }
+ }
Tcl_DStringFree(&faceString);
SelectObject(hdc, oldFont);
@@ -1148,10 +1142,9 @@ InitFont(
*-------------------------------------------------------------------------
*
* ReleaseFont --
- *
- * Called to release the windows-specific contents of a TkFont.
- * The caller is responsible for freeing the memory used by the
- * font itself.
+ *
+ * Called to release the windows-specific contents of a TkFont. The
+ * caller is responsible for freeing the memory used by the font itself.
*
* Results:
* None.
@@ -1161,7 +1154,7 @@ InitFont(
*
*---------------------------------------------------------------------------
*/
-
+
static void
ReleaseFont(
WinFont *fontPtr) /* The font to delete. */
@@ -1181,9 +1174,9 @@ ReleaseFont(
*
* InitSubFont --
*
- * Wrap a screen font and load the FontFamily that represents
- * it. Used to prepare a SubFont so that characters can be mapped
- * from UTF-8 to the charset of the font.
+ * Wrap a screen font and load the FontFamily that represents it. Used to
+ * prepare a SubFont so that characters can be mapped from UTF-8 to the
+ * charset of the font.
*
* Results:
* The subFontPtr is filled with information about the font.
@@ -1198,10 +1191,10 @@ static void
InitSubFont(
HDC hdc, /* HDC in which font can be selected. */
HFONT hFont, /* The screen font. */
- int base, /* Non-zero if this SubFont is being used
- * as the base font for a font object. */
- SubFont *subFontPtr) /* Filled with SubFont constructed from
- * above attributes. */
+ int base, /* Non-zero if this SubFont is being used as
+ * the base font for a font object. */
+ SubFont *subFontPtr) /* Filled with SubFont constructed from above
+ * attributes. */
{
subFontPtr->hFont = hFont;
subFontPtr->familyPtr = AllocFontFamily(hdc, hFont, base);
@@ -1213,8 +1206,8 @@ InitSubFont(
*
* ReleaseSubFont --
*
- * Called to release the contents of a SubFont. The caller is
- * responsible for freeing the memory used by the SubFont itself.
+ * Called to release the contents of a SubFont. The caller is responsible
+ * for freeing the memory used by the SubFont itself.
*
* Results:
* None.
@@ -1238,26 +1231,24 @@ ReleaseSubFont(
*
* AllocFontFamily --
*
- * Find the FontFamily structure associated with the given font
- * name. The information should be stored by the caller in a
- * SubFont and used when determining if that SubFont supports a
- * character.
+ * Find the FontFamily structure associated with the given font name.
+ * The information should be stored by the caller in a SubFont and used
+ * when determining if that SubFont supports a character.
*
- * Cannot use the string name used to construct the font as the
- * key, because the capitalization may not be canonical. Therefore
- * use the face name actually retrieved from the font metrics as
- * the key.
+ * Cannot use the string name used to construct the font as the key,
+ * because the capitalization may not be canonical. Therefore use the
+ * face name actually retrieved from the font metrics as the key.
*
* Results:
- * A pointer to a FontFamily. The reference count in the FontFamily
- * is automatically incremented. When the SubFont is released, the
- * reference count is decremented. When no SubFont is using this
- * FontFamily, it may be deleted.
+ * A pointer to a FontFamily. The reference count in the FontFamily is
+ * automatically incremented. When the SubFont is released, the reference
+ * count is decremented. When no SubFont is using this FontFamily, it may
+ * be deleted.
*
* Side effects:
- * A new FontFamily structure will be allocated if this font family
- * has not been seen. TrueType character existence metrics are
- * loaded into the FontFamily structure.
+ * A new FontFamily structure will be allocated if this font family has
+ * not been seen. TrueType character existence metrics are loaded into
+ * the FontFamily structure.
*
*-------------------------------------------------------------------------
*/
@@ -1267,16 +1258,16 @@ AllocFontFamily(
HDC hdc, /* HDC in which font can be selected. */
HFONT hFont, /* Screen font whose FontFamily is to be
* returned. */
- int base) /* Non-zero if this font family is to be
- * used in the base font of a font object. */
+ int base) /* Non-zero if this font family is to be used
+ * in the base font of a font object. */
{
Tk_Uid faceName;
FontFamily *familyPtr;
Tcl_DString faceString;
Tcl_Encoding encoding;
char buf[LF_FACESIZE * sizeof(WCHAR)];
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
- Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
hFont = SelectObject(hdc, hFont);
if (TkWinGetPlatformId() == VER_PLATFORM_WIN32_NT) {
@@ -1289,7 +1280,7 @@ AllocFontFamily(
Tcl_DStringFree(&faceString);
hFont = SelectObject(hdc, hFont);
- familyPtr = tsdPtr->fontFamilyList;
+ familyPtr = tsdPtr->fontFamilyList;
for ( ; familyPtr != NULL; familyPtr = familyPtr->nextPtr) {
if (familyPtr->faceName == faceName) {
familyPtr->refCount++;
@@ -1302,38 +1293,38 @@ AllocFontFamily(
familyPtr->nextPtr = tsdPtr->fontFamilyList;
tsdPtr->fontFamilyList = familyPtr;
- /*
- * Set key for this FontFamily.
+ /*
+ * Set key for this FontFamily.
*/
familyPtr->faceName = faceName;
- /*
- * An initial refCount of 2 means that FontFamily information will
- * persist even when the SubFont that loaded the FontFamily is released.
- * Change it to 1 to cause FontFamilies to be unloaded when not in use.
+ /*
+ * An initial refCount of 2 means that FontFamily information will persist
+ * even when the SubFont that loaded the FontFamily is released. Change it
+ * to 1 to cause FontFamilies to be unloaded when not in use.
*/
familyPtr->refCount = 2;
- familyPtr->segCount = LoadFontRanges(hdc, hFont, &familyPtr->startCount,
+ familyPtr->segCount = LoadFontRanges(hdc, hFont, &familyPtr->startCount,
&familyPtr->endCount, &familyPtr->isSymbolFont);
encoding = NULL;
if (familyPtr->isSymbolFont != 0) {
/*
- * Symbol fonts are handled specially. For instance, Unicode 0393
+ * Symbol fonts are handled specially. For instance, Unicode 0393
* (GREEK CAPITAL GAMMA) must be mapped to Symbol character 0047
- * (GREEK CAPITAL GAMMA), because the Symbol font doesn't have a
- * GREEK CAPITAL GAMMA at location 0393. If Tk interpreted the
- * Symbol font using the Unicode encoding, it would decide that
- * the Symbol font has no GREEK CAPITAL GAMMA, because the Symbol
- * encoding (of course) reports that character 0393 doesn't exist.
+ * (GREEK CAPITAL GAMMA), because the Symbol font doesn't have a GREEK
+ * CAPITAL GAMMA at location 0393. If Tk interpreted the Symbol font
+ * using the Unicode encoding, it would decide that the Symbol font
+ * has no GREEK CAPITAL GAMMA, because the Symbol encoding (of course)
+ * reports that character 0393 doesn't exist.
*
- * With non-symbol Windows fonts, such as Times New Roman, if the
- * font has a GREEK CAPITAL GAMMA, it will be found in the correct
- * Unicode location (0393); the GREEK CAPITAL GAMMA will not be off
- * hiding at some other location.
+ * With non-symbol Windows fonts, such as Times New Roman, if the font
+ * has a GREEK CAPITAL GAMMA, it will be found in the correct Unicode
+ * location (0393); the GREEK CAPITAL GAMMA will not be off hiding at
+ * some other location.
*/
encoding = Tcl_GetEncoding(NULL, faceName);
@@ -1343,16 +1334,16 @@ AllocFontFamily(
encoding = Tcl_GetEncoding(NULL, "unicode");
familyPtr->textOutProc =
(BOOL (WINAPI *)(HDC, int, int, TCHAR *, int)) TextOutW;
- familyPtr->getTextExtentPoint32Proc =
+ familyPtr->getTextExtentPoint32Proc =
(BOOL (WINAPI *)(HDC, TCHAR *, int, LPSIZE)) GetTextExtentPoint32W;
familyPtr->isWideFont = 1;
} else {
- familyPtr->textOutProc =
+ familyPtr->textOutProc =
(BOOL (WINAPI *)(HDC, int, int, TCHAR *, int)) TextOutA;
- familyPtr->getTextExtentPoint32Proc =
+ familyPtr->getTextExtentPoint32Proc =
(BOOL (WINAPI *)(HDC, TCHAR *, int, LPSIZE)) GetTextExtentPoint32A;
familyPtr->isWideFont = 0;
- }
+ }
familyPtr->encoding = encoding;
@@ -1376,27 +1367,27 @@ AllocFontFamily(
*
*-------------------------------------------------------------------------
*/
-
+
static void
FreeFontFamily(
FontFamily *familyPtr) /* The FontFamily to delete. */
{
int i;
FontFamily **familyPtrPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
- Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (familyPtr == NULL) {
- return;
+ return;
}
familyPtr->refCount--;
if (familyPtr->refCount > 0) {
return;
}
for (i = 0; i < FONTMAP_PAGES; i++) {
- if (familyPtr->fontMap[i] != NULL) {
- ckfree(familyPtr->fontMap[i]);
- }
+ if (familyPtr->fontMap[i] != NULL) {
+ ckfree(familyPtr->fontMap[i]);
+ }
}
if (familyPtr->startCount != NULL) {
ckfree((char *) familyPtr->startCount);
@@ -1407,19 +1398,19 @@ FreeFontFamily(
if (familyPtr->encoding != TkWinGetUnicodeEncoding()) {
Tcl_FreeEncoding(familyPtr->encoding);
}
-
- /*
- * Delete from list.
+
+ /*
+ * Delete from list.
*/
-
+
for (familyPtrPtr = &tsdPtr->fontFamilyList; ; ) {
- if (*familyPtrPtr == familyPtr) {
+ if (*familyPtrPtr == familyPtr) {
*familyPtrPtr = familyPtr->nextPtr;
break;
}
familyPtrPtr = &(*familyPtrPtr)->nextPtr;
}
-
+
ckfree((char *) familyPtr);
}
@@ -1428,19 +1419,17 @@ FreeFontFamily(
*
* FindSubFontForChar --
*
- * Determine which screen font is necessary to use to display the
- * given character. If the font object does not have a screen font
- * that can display the character, another screen font may be loaded
- * into the font object, following a set of preferred fallback rules.
+ * Determine which screen font is necessary to use to display the given
+ * character. If the font object does not have a screen font that can
+ * display the character, another screen font may be loaded into the font
+ * object, following a set of preferred fallback rules.
*
* Results:
- * The return value is the SubFont to use to display the given
- * character.
+ * The return value is the SubFont to use to display the given character.
*
* Side effects:
- * The contents of fontPtr are modified to cache the results
- * of the lookup and remember any SubFonts that were dynamically
- * loaded.
+ * The contents of fontPtr are modified to cache the results of the
+ * lookup and remember any SubFonts that were dynamically loaded.
*
*-------------------------------------------------------------------------
*/
@@ -1461,7 +1450,7 @@ FindSubFontForChar(
char *fallbackName;
SubFont *subFontPtr;
Tcl_DString ds;
-
+
if (ch < BASE_CHARS) {
return &fontPtr->subFontArray[0];
}
@@ -1473,13 +1462,13 @@ FindSubFontForChar(
}
/*
- * Keep track of all face names that we check, so we don't check some
- * name multiple times if it can be reached by multiple paths.
+ * Keep track of all face names that we check, so we don't check some name
+ * multiple times if it can be reached by multiple paths.
*/
-
+
Tcl_DStringInit(&ds);
hdc = GetDC(fontPtr->hwnd);
-
+
aliases = TkFontGetAliasList(fontPtr->font.fa.family);
fontFallbacks = TkFontGetFallbacks();
@@ -1493,25 +1482,25 @@ FindSubFontForChar(
goto tryfallbacks;
} else if (aliases != NULL) {
- /*
+ /*
* Or if an alias for the base font has a fallback...
*/
for (k = 0; aliases[k] != NULL; k++) {
if (strcasecmp(aliases[k], fallbackName) == 0) {
- goto tryfallbacks;
+ goto tryfallbacks;
}
}
}
}
continue;
- /*
- * ...then see if we can use one of the fallbacks, or an
- * alias for one of the fallbacks.
+ /*
+ * ...then see if we can use one of the fallbacks, or an alias for one
+ * of the fallbacks.
*/
- tryfallbacks:
+ tryfallbacks:
for (j = 0; fontFallbacks[i][j] != NULL; j++) {
fallbackName = fontFallbacks[i][j];
subFontPtr = CanUseFallbackWithAliases(hdc, fontPtr, fallbackName,
@@ -1523,13 +1512,13 @@ FindSubFontForChar(
}
/*
- * See if we can use something from the global fallback list.
+ * See if we can use something from the global fallback list.
*/
anyFallbacks = TkFontGetGlobalClass();
for (i = 0; anyFallbacks[i] != NULL; i++) {
fallbackName = anyFallbacks[i];
- subFontPtr = CanUseFallbackWithAliases(hdc, fontPtr, fallbackName,
+ subFontPtr = CanUseFallbackWithAliases(hdc, fontPtr, fallbackName,
ch, &ds, subFontPtrPtr);
if (subFontPtr != NULL) {
goto end;
@@ -1537,8 +1526,8 @@ FindSubFontForChar(
}
/*
- * Try all face names available in the whole system until we
- * find one that can be used.
+ * Try all face names available in the whole system until we find one that
+ * can be used.
*/
canUse.hdc = hdc;
@@ -1556,22 +1545,22 @@ FindSubFontForChar(
}
subFontPtr = canUse.subFontPtr;
- end:
+ end:
Tcl_DStringFree(&ds);
-
+
if (subFontPtr == NULL) {
- /*
- * No font can display this character. We will use the base font
- * and have it display the "unknown" character.
- */
+ /*
+ * No font can display this character. We will use the base font and
+ * have it display the "unknown" character.
+ */
subFontPtr = &fontPtr->subFontArray[0];
- FontMapInsert(subFontPtr, ch);
+ FontMapInsert(subFontPtr, ch);
}
ReleaseDC(fontPtr->hwnd, hdc);
return subFontPtr;
}
-
+
static int CALLBACK
WinFontCanUseProc(
ENUMLOGFONT *lfPtr, /* Logical-font data. */
@@ -1619,15 +1608,14 @@ WinFontCanUseProc(
* See if the screen font can display the given character.
*
* Results:
- * The return value is 0 if the screen font cannot display the
- * character, non-zero otherwise.
+ * The return value is 0 if the screen font cannot display the character,
+ * non-zero otherwise.
*
* Side effects:
- * New pages are added to the font mapping cache whenever the
- * character belongs to a page that hasn't been seen before.
- * When a page is loaded, information about all the characters on
- * that page is stored, not just for the single character in
- * question.
+ * New pages are added to the font mapping cache whenever the character
+ * belongs to a page that hasn't been seen before. When a page is loaded,
+ * information about all the characters on that page is stored, not just
+ * for the single character in question.
*
*-------------------------------------------------------------------------
*/
@@ -1653,29 +1641,28 @@ FontMapLookup(
*
* FontMapInsert --
*
- * Tell the font mapping cache that the given screen font should be
- * used to display the specified character. This is called when no
- * font on the system can be be found that can display that
- * character; we lie to the font and tell it that it can display
- * the character, otherwise we would end up re-searching the entire
- * fallback hierarchy every time that character was seen.
+ * Tell the font mapping cache that the given screen font should be used
+ * to display the specified character. This is called when no font on the
+ * system can be be found that can display that character; we lie to the
+ * font and tell it that it can display the character, otherwise we would
+ * end up re-searching the entire fallback hierarchy every time that
+ * character was seen.
*
* Results:
* None.
*
* Side effects:
- * New pages are added to the font mapping cache whenever the
- * character belongs to a page that hasn't been seen before.
- * When a page is loaded, information about all the characters on
- * that page is stored, not just for the single character in
- * question.
+ * New pages are added to the font mapping cache whenever the character
+ * belongs to a page that hasn't been seen before. When a page is loaded,
+ * information about all the characters on that page is stored, not just
+ * for the single character in question.
*
*-------------------------------------------------------------------------
*/
static void
FontMapInsert(
- SubFont *subFontPtr, /* Contains font mapping cache to be
+ SubFont *subFontPtr, /* Contains font mapping cache to be
* updated. */
int ch) /* Character to be added to cache. */
{
@@ -1694,10 +1681,10 @@ FontMapInsert(
*
* FontMapLoadPage --
*
- * Load information about all the characters on a given page.
- * This information consists of one bit per character that indicates
- * whether the associated HFONT can (1) or cannot (0) display the
- * characters on the page.
+ * Load information about all the characters on a given page. This
+ * information consists of one bit per character that indicates whether
+ * the associated HFONT can (1) or cannot (0) display the characters on
+ * the page.
*
* Results:
* None.
@@ -1707,12 +1694,13 @@ FontMapInsert(
*
*-------------------------------------------------------------------------
*/
-static void
+
+static void
FontMapLoadPage(
- SubFont *subFontPtr, /* Contains font mapping cache to be
+ SubFont *subFontPtr, /* Contains font mapping cache to be
* updated. */
- int row) /* Index of the page to be loaded into
- * the cache. */
+ int row) /* Index of the page to be loaded into the
+ * cache. */
{
FontFamily *familyPtr;
Tcl_Encoding encoding;
@@ -1728,9 +1716,9 @@ FontMapLoadPage(
if (familyPtr->encoding == TkWinGetUnicodeEncoding()) {
/*
- * Font is Unicode. Few fonts are going to have all characters, so
- * examine the TrueType character existence metrics to determine
- * what characters actually exist in this font.
+ * Font is Unicode. Few fonts are going to have all characters, so
+ * examine the TrueType character existence metrics to determine what
+ * characters actually exist in this font.
*/
segCount = familyPtr->segCount;
@@ -1752,24 +1740,23 @@ FontMapLoadPage(
}
} else if (familyPtr->isSymbolFont) {
/*
- * Assume that a symbol font with a known encoding has all the
- * characters that its encoding claims it supports.
- *
- * The test for "encoding == unicodeEncoding"
- * must occur before this case, to catch all symbol fonts (such
- * as {Comic Sans MS} or Wingdings) for which we don't have
- * encoding information; those symbol fonts are treated as if
- * they were in the Unicode encoding and their symbolic
- * character existence metrics are treated as if they were Unicode
- * character existence metrics. This way, although we don't know
- * the proper Unicode -> symbol font mapping, we can install the
- * symbol font as the base font and access its glyphs.
+ * Assume that a symbol font with a known encoding has all the
+ * characters that its encoding claims it supports.
+ *
+ * The test for "encoding == unicodeEncoding" must occur before this
+ * case, to catch all symbol fonts (such as {Comic Sans MS} or
+ * Wingdings) for which we don't have encoding information; those
+ * symbol fonts are treated as if they were in the Unicode encoding
+ * and their symbolic character existence metrics are treated as if
+ * they were Unicode character existence metrics. This way, although
+ * we don't know the proper Unicode -> symbol font mapping, we can
+ * install the symbol font as the base font and access its glyphs.
*/
- end = (row + 1) << FONTMAP_SHIFT;
+ end = (row + 1) << FONTMAP_SHIFT;
for (i = row << FONTMAP_SHIFT; i < end; i++) {
- if (Tcl_UtfToExternal(NULL, encoding, src,
- Tcl_UniCharToUtf(i, src), TCL_ENCODING_STOPONERROR, NULL,
+ if (Tcl_UtfToExternal(NULL, encoding, src,
+ Tcl_UniCharToUtf(i, src), TCL_ENCODING_STOPONERROR, NULL,
buf, sizeof(buf), NULL, NULL, NULL) != TCL_OK) {
continue;
}
@@ -1784,18 +1771,16 @@ FontMapLoadPage(
*
* CanUseFallbackWithAliases --
*
- * Helper function for FindSubFontForChar. Determine if the
- * specified face name (or an alias of the specified face name)
- * can be used to construct a screen font that can display the
- * given character.
+ * Helper function for FindSubFontForChar. Determine if the specified
+ * face name (or an alias of the specified face name) can be used to
+ * construct a screen font that can display the given character.
*
* Results:
* See CanUseFallback().
*
* Side effects:
- * If the name and/or one of its aliases was rejected, the
- * rejected string is recorded in nameTriedPtr so that it won't
- * be tried again.
+ * If the name and/or one of its aliases was rejected, the rejected
+ * string is recorded in nameTriedPtr so that it won't be tried again.
*
*---------------------------------------------------------------------------
*/
@@ -1806,11 +1791,11 @@ CanUseFallbackWithAliases(
WinFont *fontPtr, /* The font object that will own the new
* screen font. */
char *faceName, /* Desired face name for new screen font. */
- int ch, /* The Unicode character that the new
- * screen font must be able to display. */
- Tcl_DString *nameTriedPtr, /* Records face names that have already
- * been tried. It is possible for the same
- * face name to be queried multiple times when
+ int ch, /* The Unicode character that the new screen
+ * font must be able to display. */
+ Tcl_DString *nameTriedPtr, /* Records face names that have already been
+ * tried. It is possible for the same face
+ * name to be queried multiple times when
* trying to find a suitable screen font. */
SubFont **subFontPtrPtr) /* Variable to fixup if we reallocate the
* array of subfonts. */
@@ -1818,7 +1803,7 @@ CanUseFallbackWithAliases(
int i;
char **aliases;
SubFont *subFontPtr;
-
+
if (SeenName(faceName, nameTriedPtr) == 0) {
subFontPtr = CanUseFallback(hdc, fontPtr, faceName, ch, subFontPtrPtr);
if (subFontPtr != NULL) {
@@ -1845,9 +1830,9 @@ CanUseFallbackWithAliases(
*
* SeenName --
*
- * Used to determine we have already tried and rejected the given
- * face name when looking for a screen font that can support some
- * Unicode character.
+ * Used to determine we have already tried and rejected the given face
+ * name when looking for a screen font that can support some Unicode
+ * character.
*
* Results:
* The return value is 0 if this face name has not already been seen,
@@ -1884,21 +1869,21 @@ SeenName(
*
* CanUseFallback --
*
- * If the specified screen font has not already been loaded into
- * the font object, determine if it can display the given character.
+ * If the specified screen font has not already been loaded into the font
+ * object, determine if it can display the given character.
*
* Results:
- * The return value is a pointer to a newly allocated SubFont, owned
- * by the font object. This SubFont can be used to display the given
- * character. The SubFont represents the screen font with the base set
- * of font attributes from the font object, but using the specified
- * font name. NULL is returned if the font object already holds
- * a reference to the specified physical font or if the specified
- * physical font cannot display the given character.
- *
- * Side effects:
- * The font object's subFontArray is updated to contain a reference
- * to the newly allocated SubFont.
+ * The return value is a pointer to a newly allocated SubFont, owned by
+ * the font object. This SubFont can be used to display the given
+ * character. The SubFont represents the screen font with the base set of
+ * font attributes from the font object, but using the specified font
+ * name. NULL is returned if the font object already holds a reference to
+ * the specified physical font or if the specified physical font cannot
+ * display the given character.
+ *
+ * Side effects:
+ * The font object's subFontArray is updated to contain a reference to
+ * the newly allocated SubFont.
*
*-------------------------------------------------------------------------
*/
@@ -1909,8 +1894,8 @@ CanUseFallback(
WinFont *fontPtr, /* The font object that will own the new
* screen font. */
char *faceName, /* Desired face name for new screen font. */
- int ch, /* The Unicode character that the new
- * screen font must be able to display. */
+ int ch, /* The Unicode character that the new screen
+ * font must be able to display. */
SubFont **subFontPtrPtr) /* Variable to fix-up if we realloc the array
* of subfonts. */
{
@@ -1922,10 +1907,10 @@ CanUseFallback(
return NULL;
}
- /*
+ /*
* Skip all fonts we've already used.
*/
-
+
for (i = 0; i < fontPtr->numSubFonts; i++) {
if (faceName == fontPtr->subFontArray[i].familyPtr->faceName) {
return NULL;
@@ -1938,7 +1923,7 @@ CanUseFallback(
hFont = GetScreenFont(&fontPtr->font.fa, faceName, fontPtr->pixelSize);
InitSubFont(hdc, hFont, 0, &subFont);
- if (((ch < 256) && (subFont.familyPtr->isSymbolFont))
+ if (((ch < 256) && (subFont.familyPtr->isSymbolFont))
|| (FontMapLookup(&subFont, ch) == 0)) {
/*
* Don't use a symbol font as a fallback font for characters below
@@ -1952,17 +1937,19 @@ CanUseFallback(
if (fontPtr->numSubFonts >= SUBFONT_SPACE) {
SubFont *newPtr;
- newPtr = (SubFont *) ckalloc(sizeof(SubFont)
+ newPtr = (SubFont *) ckalloc(sizeof(SubFont)
* (fontPtr->numSubFonts + 1));
memcpy((char *) newPtr, fontPtr->subFontArray,
fontPtr->numSubFonts * sizeof(SubFont));
if (fontPtr->subFontArray != fontPtr->staticSubFonts) {
ckfree((char *) fontPtr->subFontArray);
}
+
/*
- * Fix up the variable pointed to by subFontPtrPtr so it still
- * points into the live array. [Bug 618872]
+ * Fix up the variable pointed to by subFontPtrPtr so it still points
+ * into the live array. [Bug 618872]
*/
+
*subFontPtrPtr = newPtr + (*subFontPtrPtr - fontPtr->subFontArray);
fontPtr->subFontArray = newPtr;
}
@@ -1976,9 +1963,8 @@ CanUseFallback(
*
* GetScreenFont --
*
- * Given the name and other attributes, construct an HFONT.
- * This is where all the alias and fallback substitution bottoms
- * out.
+ * Given the name and other attributes, construct an HFONT. This is where
+ * all the alias and fallback substitution bottoms out.
*
* Results:
* The screen font that corresponds to the attributes.
@@ -1989,13 +1975,13 @@ CanUseFallback(
*---------------------------------------------------------------------------
*/
-static HFONT
+static HFONT
GetScreenFont(
CONST TkFontAttributes *faPtr,
/* Desired font attributes for new HFONT. */
CONST char *faceName, /* Overrides font family specified in font
* attributes. */
- int pixelSize) /* Overrides size specified in font
+ int pixelSize) /* Overrides size specified in font
* attributes. */
{
Tcl_DString ds;
@@ -2007,7 +1993,7 @@ GetScreenFont(
lf.lfWidth = 0;
lf.lfEscapement = 0;
lf.lfOrientation = 0;
- lf.lfWeight = (faPtr->weight == TK_FW_NORMAL) ? FW_NORMAL : FW_BOLD;
+ lf.lfWeight = (faPtr->weight == TK_FW_NORMAL) ? FW_NORMAL : FW_BOLD;
lf.lfItalic = faPtr->slant;
lf.lfUnderline = faPtr->underline;
lf.lfStrikeOut = faPtr->overstrike;
@@ -2025,6 +2011,7 @@ GetScreenFont(
/*
* We can only store up to LF_FACESIZE wide characters
*/
+
if (Tcl_DStringLength(&ds) >= (LF_FACESIZE * sizeof(WCHAR))) {
Tcl_DStringSetLength(&ds, LF_FACESIZE);
}
@@ -2039,6 +2026,7 @@ GetScreenFont(
/*
* We can only store up to LF_FACESIZE characters
*/
+
if (Tcl_DStringLength(&ds) >= LF_FACESIZE) {
Tcl_DStringSetLength(&ds, LF_FACESIZE);
}
@@ -2054,10 +2042,9 @@ GetScreenFont(
*
* FamilyExists, FamilyOrAliasExists, WinFontExistsProc --
*
- * Determines if any physical screen font exists on the system with
- * the given family name. If the family exists, then it should be
- * possible to construct some physical screen font with that family
- * name.
+ * Determines if any physical screen font exists on the system with the
+ * given family name. If the family exists, then it should be possible to
+ * construct some physical screen font with that family name.
*
* Results:
* The return value is 0 if the specified font family does not exist,
@@ -2079,7 +2066,7 @@ FamilyExists(
/*
* Just immediately rule out the following fonts, because they look so
- * ugly on windows. The caller's fallback mechanism will cause the
+ * ugly on windows. The caller's fallback mechanism will cause the
* corresponding appropriate TrueType fonts to be selected.
*/
@@ -2092,18 +2079,18 @@ FamilyExists(
if (strcasecmp(faceName, "Helvetica") == 0) {
return 0;
}
-
+
Tcl_UtfToExternalDString(systemEncoding, faceName, -1, &faceString);
/*
- * If the family exists, WinFontExistProc() will be called and
- * EnumFontFamilies() will return whatever WinFontExistProc() returns.
- * If the family doesn't exist, EnumFontFamilies() will just return a
+ * If the family exists, WinFontExistProc() will be called and
+ * EnumFontFamilies() will return whatever WinFontExistProc() returns. If
+ * the family doesn't exist, EnumFontFamilies() will just return a
* non-zero value.
*/
if (TkWinGetPlatformId() == VER_PLATFORM_WIN32_NT) {
- result = EnumFontFamiliesW(hdc, (WCHAR *) Tcl_DStringValue(&faceString),
+ result = EnumFontFamiliesW(hdc, (WCHAR*) Tcl_DStringValue(&faceString),
(FONTENUMPROCW) WinFontExistProc, 0);
} else {
result = EnumFontFamiliesA(hdc, (char *) Tcl_DStringValue(&faceString),
@@ -2112,10 +2099,10 @@ FamilyExists(
Tcl_DStringFree(&faceString);
return (result == 0);
}
-
+
static char *
FamilyOrAliasExists(
- HDC hdc,
+ HDC hdc,
CONST char *faceName)
{
char **aliases;
@@ -2134,7 +2121,7 @@ FamilyOrAliasExists(
}
return NULL;
}
-
+
static int CALLBACK
WinFontExistProc(
ENUMLOGFONT *lfPtr, /* Logical-font data. */
@@ -2160,25 +2147,25 @@ typedef struct CMAPTABLE {
} CMAPTABLE;
typedef struct ENCODINGTABLE {
- USHORT platform; /* Platform for which data is targeted.
- * 3 means data is for Windows. */
- USHORT encoding; /* How characters in font are encoded.
- * 1 means that the following subtable is
- * keyed based on Unicode. */
- ULONG offset; /* Byte offset from beginning of CMAPTABLE
- * to the subtable for this encoding. */
+ USHORT platform; /* Platform for which data is targeted. 3
+ * means data is for Windows. */
+ USHORT encoding; /* How characters in font are encoded. 1 means
+ * that the following subtable is keyed based
+ * on Unicode. */
+ ULONG offset; /* Byte offset from beginning of CMAPTABLE to
+ * the subtable for this encoding. */
} ENCODINGTABLE;
typedef struct ANYTABLE {
USHORT format; /* Format number. */
- USHORT length; /* The actual length in bytes of this
+ USHORT length; /* The actual length in bytes of this
* subtable. */
USHORT version; /* Version number (starts at 0). */
} ANYTABLE;
typedef struct BYTETABLE {
USHORT format; /* Format number is set to 0. */
- USHORT length; /* The actual length in bytes of this
+ USHORT length; /* The actual length in bytes of this
* subtable. */
USHORT version; /* Version number (starts at 0). */
BYTE glyphIdArray[256]; /* Array that maps up to 256 single-byte char
@@ -2189,7 +2176,7 @@ typedef struct SUBHEADER {
USHORT firstCode; /* First valid low byte for subHeader. */
USHORT entryCount; /* Number valid low bytes for subHeader. */
SHORT idDelta; /* Constant adder to get base glyph index. */
- USHORT idRangeOffset; /* Byte offset from here to appropriate
+ USHORT idRangeOffset; /* Byte offset from here to appropriate
* glyphIndexArray. */
} SUBHEADER;
@@ -2198,12 +2185,12 @@ typedef struct HIBYTETABLE {
USHORT length; /* The actual length in bytes of this
* subtable. */
USHORT version; /* Version number (starts at 0). */
- USHORT subHeaderKeys[256]; /* Maps high bytes to subHeaders: value is
+ USHORT subHeaderKeys[256]; /* Maps high bytes to subHeaders: value is
* subHeader index * 8. */
#if 0
SUBHEADER subHeaders[]; /* Variable-length array of SUBHEADERs. */
- USHORT glyphIndexArray[]; /* Variable-length array containing subarrays
- * used for mapping the low byte of 2-byte
+ USHORT glyphIndexArray[]; /* Variable-length array containing subarrays
+ * used for mapping the low byte of 2-byte
* characters. */
#endif
} HIBYTETABLE;
@@ -2235,8 +2222,8 @@ typedef struct TRIMMEDTABLE {
USHORT firstCode; /* First character code of subrange. */
USHORT entryCount; /* Number of character codes in subrange. */
#if 0
- USHORT glyphIdArray[]; /* Array of glyph index values for
- character codes in the range. */
+ USHORT glyphIdArray[]; /* Array of glyph index values for
+ * character codes in the range. */
#endif
} TRIMMEDTABLE;
@@ -2255,16 +2242,16 @@ typedef union SUBTABLE {
*
* LoadFontRanges --
*
- * Given an HFONT, get the information about the characters that
- * this font can display.
+ * Given an HFONT, get the information about the characters that this
+ * font can display.
*
* Results:
- * If the font has no Unicode character information, the return value
- * is 0 and *startCountPtr and *endCountPtr are filled with NULL.
- * Otherwise, *startCountPtr and *endCountPtr are set to pointers to
- * arrays of TrueType character existence information and the return
- * value is the length of the arrays (the two arrays are always the
- * same length as each other).
+ * If the font has no Unicode character information, the return value is
+ * 0 and *startCountPtr and *endCountPtr are filled with NULL. Otherwise,
+ * *startCountPtr and *endCountPtr are set to pointers to arrays of
+ * TrueType character existence information and the return value is the
+ * length of the arrays (the two arrays are always the same length as
+ * each other).
*
* Side effects:
* None.
@@ -2276,10 +2263,10 @@ static int
LoadFontRanges(
HDC hdc, /* HDC into which font can be selected. */
HFONT hFont, /* HFONT to query. */
- USHORT **startCountPtr, /* Filled with malloced pointer to
- * character range information. */
- USHORT **endCountPtr, /* Filled with malloced pointer to
- * character range information. */
+ USHORT **startCountPtr, /* Filled with malloced pointer to character
+ * range information. */
+ USHORT **endCountPtr, /* Filled with malloced pointer to character
+ * range information. */
int *symbolPtr)
{
int n, i, swapped, offset, cbData, segCount;
@@ -2325,7 +2312,7 @@ LoadFontRanges(
SwapLong(&encTable.offset);
}
if (encTable.platform != 3) {
- /*
+ /*
* Not Microsoft encoding.
*/
@@ -2337,7 +2324,7 @@ LoadFontRanges(
continue;
}
- GetFontData(hdc, cmapKey, encTable.offset, &subTable,
+ GetFontData(hdc, cmapKey, encTable.offset, &subTable,
sizeof(subTable));
if (swapped) {
SwapShort(&subTable.any.format);
@@ -2364,16 +2351,15 @@ LoadFontRanges(
}
if (*symbolPtr != 0) {
/*
- * Empirically determined: When a symbol font is
- * loaded, the character existence metrics obtained
- * from the system are mildly wrong. If the real range
- * of the symbol font is from 0020 to 00FE, then the
- * metrics are reported as F020 to F0FE. When we load
- * a symbol font, we must fix the character existence
- * metrics.
+ * Empirically determined: When a symbol font is loaded,
+ * the character existence metrics obtained from the
+ * system are mildly wrong. If the real range of the
+ * symbol font is from 0020 to 00FE, then the metrics are
+ * reported as F020 to F0FE. When we load a symbol font,
+ * we must fix the character existence metrics.
*
- * Symbol fonts should only use the symbol encoding
- * for 8-bit characters [note Bug: 2406]
+ * Symbol fonts should only use the symbol encoding for
+ * 8-bit characters [note Bug: 2406]
*/
for (i = 0; i < segCount; i++) {
@@ -2388,9 +2374,10 @@ LoadFontRanges(
}
} else if (GetTextCharset(hdc) == ANSI_CHARSET) {
/*
- * Bitmap font. We should also support ranges for the other
- * *_CHARSET values.
+ * Bitmap font. We should also support ranges for the other *_CHARSET
+ * values.
*/
+
segCount = 1;
cbData = segCount * sizeof(USHORT);
startCount = (USHORT *) ckalloc(cbData);
@@ -2407,11 +2394,11 @@ LoadFontRanges(
/*
*-------------------------------------------------------------------------
- *
+ *
* SwapShort, SwapLong --
*
- * Helper functions to convert the data loaded from TrueType font
- * files to Intel byte ordering.
+ * Helper functions to convert the data loaded from TrueType font files
+ * to Intel byte ordering.
*
* Results:
* Bytes of input value are swapped and stored back in argument.
@@ -2423,14 +2410,16 @@ LoadFontRanges(
*/
static void
-SwapShort(PUSHORT p)
+SwapShort(
+ PUSHORT p)
{
*p = (SHORT)(HIBYTE(*p) + (LOBYTE(*p) << 8));
}
-static void
-SwapLong(PULONG p)
-{
+static void
+SwapLong(
+ PULONG p)
+{
ULONG temp;
temp = (LONG) ((BYTE) *p);
@@ -2448,3 +2437,11 @@ SwapLong(PULONG p)
temp += (LONG) ((BYTE) *p);
*p = temp;
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/win/tkWinImage.c b/win/tkWinImage.c
index 70d937c..e07fcdf 100644
--- a/win/tkWinImage.c
+++ b/win/tkWinImage.c
@@ -1,4 +1,4 @@
-/*
+/*
* tkWinImage.c --
*
* This file contains routines for manipulation full-color images.
@@ -8,23 +8,23 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinImage.c,v 1.8 2003/10/28 22:52:01 hobbs Exp $
+ * RCS: @(#) $Id: tkWinImage.c,v 1.9 2005/12/02 00:19:04 dkf Exp $
*/
#include "tkWinInt.h"
-static int DestroyImage _ANSI_ARGS_((XImage* data));
-static unsigned long ImageGetPixel _ANSI_ARGS_((XImage *image, int x, int y));
-static int PutPixel _ANSI_ARGS_((XImage *image, int x, int y,
- unsigned long pixel));
+static int DestroyImage(XImage* data);
+static unsigned long ImageGetPixel(XImage *image, int x, int y);
+static int PutPixel(XImage *image, int x, int y,
+ unsigned long pixel);
/*
*----------------------------------------------------------------------
*
* DestroyImage --
*
- * This is a trivial wrapper around ckfree to make it possible to
- * pass ckfree as a pointer.
+ * This is a trivial wrapper around ckfree to make it possible to pass
+ * ckfree as a pointer.
*
* Results:
* None.
@@ -36,8 +36,8 @@ static int PutPixel _ANSI_ARGS_((XImage *image, int x, int y,
*/
static int
-DestroyImage(imagePtr)
- XImage *imagePtr; /* image to free */
+DestroyImage(
+ XImage *imagePtr) /* Image to free. */
{
if (imagePtr) {
if (imagePtr->data) {
@@ -65,33 +65,33 @@ DestroyImage(imagePtr)
*/
static unsigned long
-ImageGetPixel(image, x, y)
- XImage *image;
- int x, y;
+ImageGetPixel(
+ XImage *image,
+ int x, int y)
{
unsigned long pixel = 0;
unsigned char *srcPtr = &(image->data[(y * image->bytes_per_line)
+ ((x * image->bits_per_pixel) / NBBY)]);
switch (image->bits_per_pixel) {
- case 32:
- case 24:
- pixel = RGB(srcPtr[2], srcPtr[1], srcPtr[0]);
- break;
- case 16:
- pixel = RGB(((((WORD*)srcPtr)[0]) >> 7) & 0xf8,
- ((((WORD*)srcPtr)[0]) >> 2) & 0xf8,
- ((((WORD*)srcPtr)[0]) << 3) & 0xf8);
- break;
- case 8:
- pixel = srcPtr[0];
- break;
- case 4:
- pixel = ((x%2) ? (*srcPtr) : ((*srcPtr) >> 4)) & 0x0f;
- break;
- case 1:
- pixel = ((*srcPtr) & (0x80 >> (x%8))) ? 1 : 0;
- break;
+ case 32:
+ case 24:
+ pixel = RGB(srcPtr[2], srcPtr[1], srcPtr[0]);
+ break;
+ case 16:
+ pixel = RGB(((((WORD*)srcPtr)[0]) >> 7) & 0xf8,
+ ((((WORD*)srcPtr)[0]) >> 2) & 0xf8,
+ ((((WORD*)srcPtr)[0]) << 3) & 0xf8);
+ break;
+ case 8:
+ pixel = srcPtr[0];
+ break;
+ case 4:
+ pixel = ((x%2) ? (*srcPtr) : ((*srcPtr) >> 4)) & 0x0f;
+ break;
+ case 1:
+ pixel = ((*srcPtr) & (0x80 >> (x%8))) ? 1 : 0;
+ break;
}
return pixel;
}
@@ -113,73 +113,74 @@ ImageGetPixel(image, x, y)
*/
static int
-PutPixel(image, x, y, pixel)
- XImage *image;
- int x, y;
- unsigned long pixel;
+PutPixel(
+ XImage *image,
+ int x, int y,
+ unsigned long pixel)
{
unsigned char *destPtr = &(image->data[(y * image->bytes_per_line)
+ ((x * image->bits_per_pixel) / NBBY)]);
switch (image->bits_per_pixel) {
- case 32:
- /*
- * Pixel is DWORD: 0x00BBGGRR
- */
+ case 32:
+ /*
+ * Pixel is DWORD: 0x00BBGGRR
+ */
- destPtr[3] = 0;
- case 24:
- /*
- * Pixel is triplet: 0xBBGGRR.
- */
+ destPtr[3] = 0;
+ case 24:
+ /*
+ * Pixel is triplet: 0xBBGGRR.
+ */
- destPtr[0] = (unsigned char) GetBValue(pixel);
- destPtr[1] = (unsigned char) GetGValue(pixel);
- destPtr[2] = (unsigned char) GetRValue(pixel);
- break;
- case 16:
- /*
- * Pixel is WORD: 5-5-5 (R-G-B)
- */
+ destPtr[0] = (unsigned char) GetBValue(pixel);
+ destPtr[1] = (unsigned char) GetGValue(pixel);
+ destPtr[2] = (unsigned char) GetRValue(pixel);
+ break;
+ case 16:
+ /*
+ * Pixel is WORD: 5-5-5 (R-G-B)
+ */
- (*(WORD*)destPtr) =
- ((GetRValue(pixel) & 0xf8) << 7)
+ (*(WORD*)destPtr) = ((GetRValue(pixel) & 0xf8) << 7)
| ((GetGValue(pixel) & 0xf8) <<2)
| ((GetBValue(pixel) & 0xf8) >> 3);
- break;
- case 8:
- /*
- * Pixel is 8-bit index into color table.
- */
+ break;
+ case 8:
+ /*
+ * Pixel is 8-bit index into color table.
+ */
- (*destPtr) = (unsigned char) pixel;
- break;
- case 4:
- /*
- * Pixel is 4-bit index in MSBFirst order.
- */
- if (x%2) {
- (*destPtr) = (unsigned char) (((*destPtr) & 0xf0)
+ (*destPtr) = (unsigned char) pixel;
+ break;
+ case 4:
+ /*
+ * Pixel is 4-bit index in MSBFirst order.
+ */
+
+ if (x%2) {
+ (*destPtr) = (unsigned char) (((*destPtr) & 0xf0)
| (pixel & 0x0f));
- } else {
- (*destPtr) = (unsigned char) (((*destPtr) & 0x0f)
+ } else {
+ (*destPtr) = (unsigned char) (((*destPtr) & 0x0f)
| ((pixel << 4) & 0xf0));
- }
- break;
- case 1: {
- /*
- * Pixel is bit in MSBFirst order.
- */
+ }
+ break;
+ case 1: {
+ /*
+ * Pixel is bit in MSBFirst order.
+ */
- int mask = (0x80 >> (x%8));
- if (pixel) {
- (*destPtr) |= mask;
- } else {
- (*destPtr) &= ~mask;
- }
+ int mask = (0x80 >> (x%8));
+
+ if (pixel) {
+ (*destPtr) |= mask;
+ } else {
+ (*destPtr) &= ~mask;
}
break;
}
+ }
return 0;
}
@@ -200,18 +201,17 @@ PutPixel(image, x, y, pixel)
*/
XImage *
-XCreateImage(display, visual, depth, format, offset, data, width, height,
- bitmap_pad, bytes_per_line)
- Display* display;
- Visual* visual;
- unsigned int depth;
- int format;
- int offset;
- char* data;
- unsigned int width;
- unsigned int height;
- int bitmap_pad;
- int bytes_per_line;
+XCreateImage(
+ Display *display,
+ Visual *visual,
+ unsigned int depth,
+ int format,
+ int offset,
+ char *data,
+ unsigned int width,
+ unsigned int height,
+ int bitmap_pad,
+ int bytes_per_line)
{
XImage* imagePtr = (XImage *) ckalloc(sizeof(XImage));
imagePtr->width = width;
@@ -255,40 +255,39 @@ XCreateImage(display, visual, depth, format, offset, data, width, height,
imagePtr->f.create_image = NULL;
imagePtr->f.sub_image = NULL;
imagePtr->f.add_pixel = NULL;
-
+
return imagePtr;
}
/*
*----------------------------------------------------------------------
+ *
* XGetImageZPixmap --
*
- * This function copies data from a pixmap or window into an
- * XImage. This handles the ZPixmap case only.
+ * This function copies data from a pixmap or window into an XImage. This
+ * handles the ZPixmap case only.
*
* Results:
- * Returns a newly allocated image containing the data from the
- * given rectangle of the given drawable.
+ * Returns a newly allocated image containing the data from the given
+ * rectangle of the given drawable.
*
* Side effects:
* None.
*
- * This procedure is adapted from the XGetImage implementation in TkNT.
- * That code is Copyright (c) 1994 Software Research Associates, Inc.
+ * This procedure is adapted from the XGetImage implementation in TkNT. That
+ * code is Copyright (c) 1994 Software Research Associates, Inc.
*
*----------------------------------------------------------------------
*/
static XImage *
-XGetImageZPixmap(display, d, x, y, width, height, plane_mask, format)
- Display* display;
- Drawable d;
- int x;
- int y;
- unsigned int width;
- unsigned int height;
- unsigned long plane_mask;
- int format;
+XGetImageZPixmap(
+ Display *display,
+ Drawable d,
+ int x, int y,
+ unsigned int width, unsigned int height,
+ unsigned long plane_mask,
+ int format)
{
TkWinDrawable *twdPtr = (TkWinDrawable *)d;
XImage *ret_image;
@@ -305,29 +304,32 @@ XGetImageZPixmap(display, d, x, y, width, height, plane_mask, format)
if (format != ZPixmap) {
TkpDisplayWarning(
- "XGetImageZPixmap: only ZPixmap types are implemented",
- "XGetImageZPixmap Failure");
+ "XGetImageZPixmap: only ZPixmap types are implemented",
+ "XGetImageZPixmap Failure");
return NULL;
}
hdc = TkWinGetDrawableDC(display, d, &state);
- /* Need to do a Blt operation to copy into a new bitmap */
+ /*
+ * Need to do a Blt operation to copy into a new bitmap.
+ */
+
hbmp = CreateCompatibleBitmap(hdc, width, height);
hdcMem = CreateCompatibleDC(hdc);
hbmpPrev = SelectObject(hdcMem, hbmp);
hPal = state.palette;
if (hPal) {
- hPalPrev1 = SelectPalette(hdcMem, hPal, FALSE);
- n = RealizePalette(hdcMem);
- if (n > 0) {
- UpdateColors (hdcMem);
- }
+ hPalPrev1 = SelectPalette(hdcMem, hPal, FALSE);
+ n = RealizePalette(hdcMem);
+ if (n > 0) {
+ UpdateColors (hdcMem);
+ }
hPalPrev2 = SelectPalette(hdc, hPal, FALSE);
- n = RealizePalette(hdc);
- if (n > 0) {
- UpdateColors (hdc);
- }
+ n = RealizePalette(hdc);
+ if (n > 0) {
+ UpdateColors (hdc);
+ }
}
ret = BitBlt(hdcMem, 0, 0, width, height, hdc, x, y, SRCCOPY);
@@ -351,20 +353,21 @@ XGetImageZPixmap(display, d, x, y, width, height, plane_mask, format)
}
bmInfo = (BITMAPINFO *) ckalloc(size);
- bmInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bmInfo->bmiHeader.biWidth = width;
- bmInfo->bmiHeader.biHeight = -(int) height;
- bmInfo->bmiHeader.biPlanes = 1;
- bmInfo->bmiHeader.biBitCount = depth;
- bmInfo->bmiHeader.biCompression = BI_RGB;
- bmInfo->bmiHeader.biSizeImage = 0;
- bmInfo->bmiHeader.biXPelsPerMeter = 0;
- bmInfo->bmiHeader.biYPelsPerMeter = 0;
- bmInfo->bmiHeader.biClrUsed = 0;
- bmInfo->bmiHeader.biClrImportant = 0;
+ bmInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ bmInfo->bmiHeader.biWidth = width;
+ bmInfo->bmiHeader.biHeight = -(int) height;
+ bmInfo->bmiHeader.biPlanes = 1;
+ bmInfo->bmiHeader.biBitCount = depth;
+ bmInfo->bmiHeader.biCompression = BI_RGB;
+ bmInfo->bmiHeader.biSizeImage = 0;
+ bmInfo->bmiHeader.biXPelsPerMeter = 0;
+ bmInfo->bmiHeader.biYPelsPerMeter = 0;
+ bmInfo->bmiHeader.biClrUsed = 0;
+ bmInfo->bmiHeader.biClrImportant = 0;
if (depth == 1) {
unsigned char *p, *pend;
+
GetDIBits(hdcMem, hbmp, 0, height, NULL, bmInfo, DIB_PAL_COLORS);
data = ckalloc(bmInfo->bmiHeader.biSizeImage);
if (!data) {
@@ -379,7 +382,10 @@ XGetImageZPixmap(display, d, x, y, width, height, plane_mask, format)
goto cleanup;
}
- /* Get the BITMAP info into the Image. */
+ /*
+ * Get the BITMAP info into the Image.
+ */
+
if (GetDIBits(hdcMem, hbmp, 0, height, data, bmInfo,
DIB_PAL_COLORS) == 0) {
ckfree((char *) ret_image->data);
@@ -412,7 +418,10 @@ XGetImageZPixmap(display, d, x, y, width, height, plane_mask, format)
goto cleanup;
}
- /* Get the BITMAP info into the Image. */
+ /*
+ * Get the BITMAP info into the Image.
+ */
+
if (GetDIBits(hdcMem, hbmp, 0, height, data, bmInfo,
DIB_PAL_COLORS) == 0) {
ckfree((char *) ret_image->data);
@@ -440,7 +449,10 @@ XGetImageZPixmap(display, d, x, y, width, height, plane_mask, format)
goto cleanup;
}
- /* Get the BITMAP info directly into the Image. */
+ /*
+ * Get the BITMAP info directly into the Image.
+ */
+
if (GetDIBits(hdcMem, hbmp, 0, height, ret_image->data, bmInfo,
DIB_RGB_COLORS) == 0) {
ckfree((char *) ret_image->data);
@@ -465,9 +477,10 @@ XGetImageZPixmap(display, d, x, y, width, height, plane_mask, format)
if (depth <= 24) {
/*
- * This used to handle 16 and 24 bpp, but now just handles 24.
- * It can likely be optimized for that. -- hobbs
+ * This used to handle 16 and 24 bpp, but now just handles 24. It
+ * can likely be optimized for that. -- hobbs
*/
+
unsigned char *smallBitData, *smallBitBase, *bigBitData;
unsigned int byte_width, h, w;
@@ -481,7 +494,10 @@ XGetImageZPixmap(display, d, x, y, width, height, plane_mask, format)
}
smallBitData = smallBitBase;
- /* Get the BITMAP info into the Image. */
+ /*
+ * Get the BITMAP info into the Image.
+ */
+
if (GetDIBits(hdcMem, hbmp, 0, height, smallBitData, bmInfo,
DIB_RGB_COLORS) == 0) {
ckfree((char *) ret_image->data);
@@ -491,11 +507,14 @@ XGetImageZPixmap(display, d, x, y, width, height, plane_mask, format)
goto cleanup;
}
- /* Copy the 24 Bit Pixmap to a 32-Bit one. */
+ /*
+ * Copy the 24 Bit Pixmap to a 32-Bit one.
+ */
+
for (h = 0; h < height; h++) {
bigBitData = ret_image->data + h * ret_image->bytes_per_line;
smallBitData = smallBitBase + h * byte_width;
-
+
for (w = 0; w < width; w++) {
*bigBitData++ = ((*smallBitData++));
*bigBitData++ = ((*smallBitData++));
@@ -503,10 +522,17 @@ XGetImageZPixmap(display, d, x, y, width, height, plane_mask, format)
*bigBitData++ = 0;
}
}
- /* Free the Device contexts, and the Bitmap */
+
+ /*
+ * Free the Device contexts, and the Bitmap.
+ */
+
ckfree((char *) smallBitBase);
} else {
- /* Get the BITMAP info directly into the Image. */
+ /*
+ * Get the BITMAP info directly into the Image.
+ */
+
if (GetDIBits(hdcMem, hbmp, 0, height, ret_image->data, bmInfo,
DIB_RGB_COLORS) == 0) {
ckfree((char *) ret_image->data);
@@ -535,12 +561,11 @@ XGetImageZPixmap(display, d, x, y, width, height, plane_mask, format)
*
* XGetImage --
*
- * This function copies data from a pixmap or window into an
- * XImage.
+ * This function copies data from a pixmap or window into an XImage.
*
* Results:
- * Returns a newly allocated image containing the data from the
- * given rectangle of the given drawable.
+ * Returns a newly allocated image containing the data from the given
+ * rectangle of the given drawable.
*
* Side effects:
* None.
@@ -549,15 +574,13 @@ XGetImageZPixmap(display, d, x, y, width, height, plane_mask, format)
*/
XImage *
-XGetImage(display, d, x, y, width, height, plane_mask, format)
- Display* display;
- Drawable d;
- int x;
- int y;
- unsigned int width;
- unsigned int height;
- unsigned long plane_mask;
- int format;
+XGetImage(
+ Display* display,
+ Drawable d,
+ int x, int y,
+ unsigned int width, unsigned int height,
+ unsigned long plane_mask,
+ int format)
{
TkWinDrawable *twdPtr = (TkWinDrawable *)d;
XImage *imagePtr;
@@ -569,26 +592,28 @@ XGetImage(display, d, x, y, width, height, plane_mask, format)
/*
* Avoid unmapped windows or bad drawables
*/
+
return NULL;
}
if (twdPtr->type != TWD_BITMAP) {
/*
* This handles TWD_WINDOW or TWD_WINDC, always creating a 32bit
- * image. If the window being copied isn't visible (unmapped or
- * obscured), we quietly stop copying (no user error).
- * The user will see black where the widget should be.
- * This branch is likely followed in favor of XGetImageZPixmap as
- * postscript printed widgets require RGB data.
+ * image. If the window being copied isn't visible (unmapped or
+ * obscured), we quietly stop copying (no user error). The user will
+ * see black where the widget should be. This branch is likely
+ * followed in favor of XGetImageZPixmap as postscript printed widgets
+ * require RGB data.
*/
+
TkWinDCState state;
unsigned int xx, yy, size;
COLORREF pixel;
dc = TkWinGetDrawableDC(display, d, &state);
- imagePtr = XCreateImage(display, NULL, 32,
- format, 0, NULL, width, height, 32, 0);
+ imagePtr = XCreateImage(display, NULL, 32, format, 0, NULL,
+ width, height, 32, 0);
size = imagePtr->bytes_per_line * imagePtr->height;
imagePtr->data = ckalloc(size);
ZeroMemory(imagePtr->data, size);
@@ -606,11 +631,12 @@ XGetImage(display, d, x, y, width, height, plane_mask, format)
TkWinReleaseDrawableDC(d, dc, &state);
} else if (format == ZPixmap) {
/*
- * This actually handles most TWD_WINDOW requests, but it varies
- * from the above in that it really does a screen capture of
- * an area, which is consistent with the Unix behavior, but does
- * not appear to handle all bit depths correctly. -- hobbs
+ * This actually handles most TWD_WINDOW requests, but it varies from
+ * the above in that it really does a screen capture of an area, which
+ * is consistent with the Unix behavior, but does not appear to handle
+ * all bit depths correctly. -- hobbs
*/
+
imagePtr = XGetImageZPixmap(display, d, x, y,
width, height, plane_mask, format);
} else {
@@ -629,6 +655,7 @@ XGetImage(display, d, x, y, width, height, plane_mask, format)
/*
* Do a soft warning for the unsupported XGetImage types.
*/
+
TkpDisplayWarning(errMsg, "XGetImage Failure");
return NULL;
}
@@ -661,3 +688,11 @@ XGetImage(display, d, x, y, width, height, plane_mask, format)
return imagePtr;
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/win/tkWinInit.c b/win/tkWinInit.c
index bdedb2b..71c98af 100644
--- a/win/tkWinInit.c
+++ b/win/tkWinInit.c
@@ -1,4 +1,4 @@
-/*
+/*
* tkWinInit.c --
*
* This file contains Windows-specific interpreter initialization
@@ -9,17 +9,17 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinInit.c,v 1.11 2003/02/18 19:18:33 hobbs Exp $
+ * RCS: @(#) $Id: tkWinInit.c,v 1.12 2005/12/02 00:19:04 dkf Exp $
*/
#include "tkWinInt.h"
/*
- * The Init script (common to Windows and Unix platforms) is
- * defined in tkInitScript.h
+ * The Init script (common to Windows and Unix platforms) is defined in
+ * tkInitScript.h
*/
-#include "tkInitScript.h"
+#include "tkInitScript.h"
/*
*----------------------------------------------------------------------
@@ -30,8 +30,8 @@
* tk_library variable.
*
* Results:
- * A standard Tcl completion code (TCL_OK or TCL_ERROR). Also
- * leaves information in the interp's result.
+ * A standard Tcl completion code (TCL_OK or TCL_ERROR). Also leaves
+ * information in the interp's result.
*
* Side effects:
* Sets "tk_library" Tcl variable, runs "tk.tcl" script.
@@ -40,13 +40,14 @@
*/
int
-TkpInit(interp)
- Tcl_Interp *interp;
+TkpInit(
+ Tcl_Interp *interp)
{
/*
* This is necessary for static initialization, and is ok otherwise
* because TkWinXInit flips a static bit to do its work just once.
*/
+
TkWinXInit(Tk_GetHINSTANCE());
return Tcl_Eval(interp, initScript);
}
@@ -56,9 +57,9 @@ TkpInit(interp)
*
* TkpGetAppName --
*
- * Retrieves the name of the current application from a platform
- * specific location. For Windows, the application name is the
- * root of the tail of the path contained in the tcl variable argv0.
+ * Retrieves the name of the current application from a platform specific
+ * location. For Windows, the application name is the root of the tail of
+ * the path contained in the tcl variable argv0.
*
* Results:
* Returns the application name in the given Tcl_DString.
@@ -70,9 +71,9 @@ TkpInit(interp)
*/
void
-TkpGetAppName(interp, namePtr)
- Tcl_Interp *interp;
- Tcl_DString *namePtr; /* A previously initialized Tcl_DString. */
+TkpGetAppName(
+ Tcl_Interp *interp,
+ Tcl_DString *namePtr) /* A previously initialized Tcl_DString. */
{
int argc, namelength;
CONST char **argv = NULL, *name, *p;
@@ -106,8 +107,8 @@ TkpGetAppName(interp, namePtr)
*
* TkpDisplayWarning --
*
- * This routines is called from Tk_Main to display warning
- * messages that occur during startup.
+ * This routines is called from Tk_Main to display warning messages that
+ * occur during startup.
*
* Results:
* None.
@@ -119,17 +120,18 @@ TkpGetAppName(interp, namePtr)
*/
void
-TkpDisplayWarning(msg, title)
- CONST char *msg; /* Message to be displayed. */
- CONST char *title; /* Title of warning. */
+TkpDisplayWarning(
+ CONST char *msg, /* Message to be displayed. */
+ CONST char *title) /* Title of warning. */
{
Tcl_DString msgString, titleString;
Tcl_Encoding unicodeEncoding = TkWinGetUnicodeEncoding();
/*
- * Truncate MessageBox string if it is too long to not overflow
- * the screen and cause possible oversized window error.
+ * Truncate MessageBox string if it is too long to not overflow the screen
+ * and cause possible oversized window error.
*/
+
#define TK_MAX_WARN_LEN (1024 * sizeof(WCHAR))
Tcl_UtfToExternalDString(unicodeEncoding, msg, -1, &msgString);
Tcl_UtfToExternalDString(unicodeEncoding, title, -1, &titleString);
@@ -144,3 +146,11 @@ TkpDisplayWarning(msg, title)
Tcl_DStringFree(&msgString);
Tcl_DStringFree(&titleString);
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/win/tkWinInt.h b/win/tkWinInt.h
index 50bbd52..eb04dec 100644
--- a/win/tkWinInt.h
+++ b/win/tkWinInt.h
@@ -2,16 +2,15 @@
* tkWinInt.h --
*
* This file contains declarations that are shared among the
- * Windows-specific parts of Tk, but aren't used by the rest of
- * Tk.
+ * Windows-specific parts of Tk, but aren't used by the rest of Tk.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
* Copyright (c) 1998-2000 by Scriptics Corporation.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinInt.h,v 1.24 2005/06/01 17:54:16 hobbs Exp $
+ * RCS: @(#) $Id: tkWinInt.h,v 1.25 2005/12/02 00:19:04 dkf Exp $
*/
#ifndef _TKWININT
@@ -33,18 +32,17 @@
#include "tkPort.h"
#endif
-
/*
* Define constants missing from older Win32 SDK header files.
*/
#ifndef WS_EX_TOOLWINDOW
-#define WS_EX_TOOLWINDOW 0x00000080L
+#define WS_EX_TOOLWINDOW 0x00000080L
#endif
/*
- * The TkWinDCState is used to save the state of a device context
- * so that it can be restored later.
+ * The TkWinDCState is used to save the state of a device context so that it
+ * can be restored later.
*/
typedef struct TkWinDCState {
@@ -53,8 +51,8 @@ typedef struct TkWinDCState {
} TkWinDCState;
/*
- * The TkWinDrawable is the internal implementation of an X Drawable (either
- * a Window or a Pixmap). The following constants define the valid Drawable
+ * The TkWinDrawable is the internal implementation of an X Drawable (either a
+ * Window or a Pixmap). The following constants define the valid Drawable
* types.
*/
@@ -105,11 +103,11 @@ typedef struct {
HPALETTE palette; /* Palette handle used when drawing. */
UINT size; /* Number of entries in the palette. */
int stale; /* 1 if palette needs to be realized,
- * otherwise 0. If the palette is stale,
- * then an idle handler is scheduled to
- * realize the palette. */
- Tcl_HashTable refCounts; /* Hash table of palette entry reference counts
- * indexed by pixel value. */
+ * otherwise 0. If the palette is stale, then
+ * an idle handler is scheduled to realize the
+ * palette. */
+ Tcl_HashTable refCounts; /* Hash table of palette entry reference
+ * counts indexed by pixel value. */
} TkWinColormap;
/*
@@ -135,8 +133,8 @@ extern int tkpWinRopModes[];
extern int tkpWinBltModes[];
/*
- * The following defines are used with TkWinGetBorderPixels to get the
- * extra 2 border colors from a Tk_3DBorder.
+ * The following defines are used with TkWinGetBorderPixels to get the extra 2
+ * border colors from a Tk_3DBorder.
*/
#define TK_3D_LIGHT2 TK_3D_DARK_GC+1
@@ -152,46 +150,51 @@ extern int tkpWinBltModes[];
* We need to specially add the TkWinChildProc because of the special
* prototype it has (doesn't fit into stubs schema)
*/
+
#ifdef BUILD_tk
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLEXPORT
#endif
-EXTERN LRESULT CALLBACK TkWinChildProc _ANSI_ARGS_((HWND hwnd, UINT message,
- WPARAM wParam, LPARAM lParam));
+EXTERN LRESULT CALLBACK TkWinChildProc(HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam);
/*
* Special proc needed as tsd accessor function between
* tkWinX.c:GenerateXEvent and tkWinClipboard.c:UpdateClipboard
*/
-EXTERN void TkWinUpdatingClipboard(int mode);
+
+EXTERN void TkWinUpdatingClipboard(int mode);
/*
* Used by tkWinDialog.c to associate the right icon with tk_messageBox
*/
-EXTERN HICON TkWinGetIcon(Tk_Window tkw, DWORD iconsize);
+
+EXTERN HICON TkWinGetIcon(Tk_Window tkw, DWORD iconsize);
/*
- * Used by tkWinX.c on for certain system display change messages
- * and cleanup up containers
+ * Used by tkWinX.c on for certain system display change messages and cleanup
+ * up containers
*/
-EXTERN void TkWinDisplayChanged(Display *display);
-void TkWinCleanupContainerList(void);
+
+EXTERN void TkWinDisplayChanged(Display *display);
+void TkWinCleanupContainerList(void);
/*
- * Used by tkWinWm.c for embedded menu handling. May become public.
+ * Used by tkWinWm.c for embedded menu handling. May become public.
*/
-EXTERN HWND Tk_GetMenuHWND(Tk_Window tkwin);
-EXTERN HWND Tk_GetEmbeddedMenuHWND(Tk_Window tkwin);
+
+EXTERN HWND Tk_GetMenuHWND(Tk_Window tkwin);
+EXTERN HWND Tk_GetEmbeddedMenuHWND(Tk_Window tkwin);
/*
- * The following structure keeps track of whether we are using the
- * multi-byte or the wide-character interfaces to the operating system.
- * System calls should be made through the following function table.
+ * The following structure keeps track of whether we are using the multi-byte
+ * or the wide-character interfaces to the operating system. System calls
+ * should be made through the following function table.
*
* While some system calls need to use this A/W jump-table, it is not
- * necessary for all calls to do it, which is why you won't see this
- * used throughout the Tk code, but only in key areas. -- hobbs
+ * necessary for all calls to do it, which is why you won't see this used
+ * throughout the Tk code, but only in key areas. -- hobbs
*/
typedef struct TkWinProcs {
@@ -221,24 +224,28 @@ EXTERN TkWinProcs *tkWinProcs;
*/
-extern Tcl_Encoding TkWinGetKeyInputEncoding _ANSI_ARGS_((void));
-extern Tcl_Encoding TkWinGetUnicodeEncoding _ANSI_ARGS_((void));
+extern Tcl_Encoding TkWinGetKeyInputEncoding(void);
+extern Tcl_Encoding TkWinGetUnicodeEncoding(void);
/*
* Values returned by TkWinGetPlatformTheme.
*/
+
#define TK_THEME_WIN_CLASSIC 1
#define TK_THEME_WIN_XP 2
/*
- * The following is implemented in tkWinWm and used by tkWinEmbed.c
+ * The following is implemented in tkWinWm and used by tkWinEmbed.c
*/
-void TkpWinToplevelWithDraw _ANSI_ARGS_((TkWindow *winPtr));
-void TkpWinToplevelIconify _ANSI_ARGS_((TkWindow *winPtr));
-void TkpWinToplevelDeiconify _ANSI_ARGS_((TkWindow *winPtr));
-long TkpWinToplevelIsControlledByWm _ANSI_ARGS_((TkWindow *winPtr));
-long TkpWinToplevelMove _ANSI_ARGS_((TkWindow *winPtr, int x, int y));
-long TkpWinToplevelOverrideRedirect _ANSI_ARGS_((TkWindow *winPtr, int reqValue));
-void TkpWinToplevelDetachWindow _ANSI_ARGS_((TkWindow *winPtr));
-int TkpWmGetState _ANSI_ARGS_((TkWindow *winPtr));
+
+void TkpWinToplevelWithDraw(TkWindow *winPtr);
+void TkpWinToplevelIconify(TkWindow *winPtr);
+void TkpWinToplevelDeiconify(TkWindow *winPtr);
+long TkpWinToplevelIsControlledByWm(TkWindow *winPtr);
+long TkpWinToplevelMove(TkWindow *winPtr, int x, int y);
+long TkpWinToplevelOverrideRedirect(TkWindow *winPtr,
+ int reqValue);
+void TkpWinToplevelDetachWindow(TkWindow *winPtr);
+int TkpWmGetState(TkWindow *winPtr);
+
#endif /* _TKWININT */
diff --git a/win/tkWinKey.c b/win/tkWinKey.c
index 7f5a338..f43c6e9 100644
--- a/win/tkWinKey.c
+++ b/win/tkWinKey.c
@@ -9,58 +9,60 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinKey.c,v 1.14 2001/05/30 22:41:11 hobbs Exp $
+ * RCS: @(#) $Id: tkWinKey.c,v 1.15 2005/12/02 00:19:04 dkf Exp $
*/
#include "tkWinInt.h"
+
/*
- * The keymap table holds mappings of Windows keycodes to X keysyms.
- * If Windows ever comes along and changes the value of their keycodes,
- * this will break all kinds of things. However, this table lookup is much
- * faster than the alternative, in which we walked a list of keycodes looking
- * for a match. Since this lookup is performed for every Windows keypress
- * event, it seems like a worthwhile improvement to use the table.
+ * The keymap table holds mappings of Windows keycodes to X keysyms. If
+ * Windows ever comes along and changes the value of their keycodes, this will
+ * break all kinds of things. However, this table lookup is much faster than
+ * the alternative, in which we walked a list of keycodes looking for a match.
+ * Since this lookup is performed for every Windows keypress event, it seems
+ * like a worthwhile improvement to use the table.
*/
+
#define MAX_KEYCODE 145 /* VK_SCROLL is the last entry in our table below */
static KeySym keymap[] = {
NoSymbol, NoSymbol, NoSymbol, XK_Cancel, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, XK_BackSpace, XK_Tab,
- NoSymbol, NoSymbol, XK_Clear, XK_Return, NoSymbol,
- NoSymbol, XK_Shift_L, XK_Control_L, XK_Alt_L, XK_Pause,
- XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, XK_Escape, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, XK_space, XK_Prior, XK_Next,
- XK_End, XK_Home, XK_Left, XK_Up, XK_Right,
- XK_Down, XK_Select, XK_Print, XK_Execute, NoSymbol,
- XK_Insert, XK_Delete, XK_Help, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, XK_Win_L, XK_Win_R, XK_App, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, XK_F1, XK_F2, XK_F3,
- XK_F4, XK_F5, XK_F6, XK_F7, XK_F8,
- XK_F9, XK_F10, XK_F11, XK_F12, XK_F13,
- XK_F14, XK_F15, XK_F16, XK_F17, XK_F18,
- XK_F19, XK_F20, XK_F21, XK_F22, XK_F23,
- XK_F24, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, XK_Num_Lock,
- XK_Scroll_Lock
+ NoSymbol, NoSymbol, NoSymbol, XK_BackSpace, XK_Tab,
+ NoSymbol, NoSymbol, XK_Clear, XK_Return, NoSymbol,
+ NoSymbol, XK_Shift_L, XK_Control_L, XK_Alt_L, XK_Pause,
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, XK_Escape, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, XK_space, XK_Prior, XK_Next,
+ XK_End, XK_Home, XK_Left, XK_Up, XK_Right,
+ XK_Down, XK_Select, XK_Print, XK_Execute, NoSymbol,
+ XK_Insert, XK_Delete, XK_Help, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, XK_Win_L, XK_Win_R, XK_App, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, XK_F1, XK_F2, XK_F3,
+ XK_F4, XK_F5, XK_F6, XK_F7, XK_F8,
+ XK_F9, XK_F10, XK_F11, XK_F12, XK_F13,
+ XK_F14, XK_F15, XK_F16, XK_F17, XK_F18,
+ XK_F19, XK_F20, XK_F21, XK_F22, XK_F23,
+ XK_F24, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, XK_Num_Lock,
+ XK_Scroll_Lock
};
/*
* Prototypes for local procedures defined in this file:
*/
-static KeySym KeycodeToKeysym _ANSI_ARGS_((unsigned int keycode,
- int state, int noascii));
+static KeySym KeycodeToKeysym(unsigned int keycode,
+ int state, int noascii);
/*
*----------------------------------------------------------------------
@@ -79,11 +81,11 @@ static KeySym KeycodeToKeysym _ANSI_ARGS_((unsigned int keycode,
*/
char *
-TkpGetString(winPtr, eventPtr, dsPtr)
- TkWindow *winPtr; /* Window where event occurred: needed to
- * get input context. */
- XEvent *eventPtr; /* X keyboard event. */
- Tcl_DString *dsPtr; /* Uninitialized or empty string to hold
+TkpGetString(
+ TkWindow *winPtr, /* Window where event occurred: needed to get
+ * input context. */
+ XEvent *eventPtr, /* X keyboard event. */
+ Tcl_DString *dsPtr) /* Uninitialized or empty string to hold
* result. */
{
KeySym keysym;
@@ -97,7 +99,7 @@ TkpGetString(winPtr, eventPtr, dsPtr)
}
} else if (eventPtr->xkey.send_event == -2) {
/*
- * Special case for win2000 multi-lingal IME input.
+ * Special case for win2000 multi-lingal IME input.
* xkey.trans_chars[] already contains a UNICODE char.
*/
@@ -112,19 +114,20 @@ TkpGetString(winPtr, eventPtr, dsPtr)
len = Tcl_UniCharToUtf((Tcl_UniChar) unichar, buf);
Tcl_DStringAppend(dsPtr, buf, len);
- } else {
+ } else {
/*
- * This is an event generated from generic code. It has no
- * nchars or trans_chars members.
+ * This is an event generated from generic code. It has no nchars or
+ * trans_chars members.
*/
keysym = KeycodeToKeysym(eventPtr->xkey.keycode,
eventPtr->xkey.state, 0);
- if (((keysym != NoSymbol) && (keysym > 0) && (keysym < 256))
- || (keysym == XK_Return)
- || (keysym == XK_Tab)) {
+ if (((keysym != NoSymbol) && (keysym > 0) && (keysym < 256))
+ || (keysym == XK_Return) || (keysym == XK_Tab)) {
char buf[TCL_UTF_MAX];
- int len = Tcl_UniCharToUtf((Tcl_UniChar) (keysym & 255), buf);
+ int len;
+
+ len = Tcl_UniCharToUtf((Tcl_UniChar) (keysym & 255), buf);
Tcl_DStringAppend(dsPtr, buf, len);
}
}
@@ -136,8 +139,8 @@ TkpGetString(winPtr, eventPtr, dsPtr)
*
* XKeycodeToKeysym --
*
- * Translate from a system-dependent keycode to a
- * system-independent keysym.
+ * Translate from a system-dependent keycode to a system-independent
+ * keysym.
*
* Results:
* Returns the translated keysym, or NoSymbol on failure.
@@ -149,10 +152,10 @@ TkpGetString(winPtr, eventPtr, dsPtr)
*/
KeySym
-XKeycodeToKeysym(display, keycode, index)
- Display* display;
- unsigned int keycode;
- int index;
+XKeycodeToKeysym(
+ Display *display,
+ unsigned int keycode,
+ int index)
{
int state = 0;
@@ -161,32 +164,30 @@ XKeycodeToKeysym(display, keycode, index)
}
return KeycodeToKeysym(keycode, state, 0);
}
-
-
/*
*----------------------------------------------------------------------
*
* KeycodeToKeysym --
*
- * Translate from a system-dependent keycode to a
- * system-independent keysym.
+ * Translate from a system-dependent keycode to a system-independent
+ * keysym.
*
* Results:
* Returns the translated keysym, or NoSymbol on failure.
*
* Side effects:
- * It may affect the internal state of the keyboard, such as
- * remembered dead key or lock indicator lamps.
+ * It may affect the internal state of the keyboard, such as remembered
+ * dead key or lock indicator lamps.
*
*----------------------------------------------------------------------
*/
static KeySym
-KeycodeToKeysym(keycode, state, noascii)
- unsigned int keycode;
- int state;
- int noascii;
+KeycodeToKeysym(
+ unsigned int keycode,
+ int state,
+ int noascii)
{
BYTE keys[256];
int result, deadkey, shift;
@@ -194,14 +195,15 @@ KeycodeToKeysym(keycode, state, noascii)
unsigned int scancode = MapVirtualKey(keycode, 0);
/*
- * Do not run keycodes of lock keys through ToAscii().
- * One of ToAscii()'s side effects is to handle the lights
- * on the keyboard, and we don't want to mess that up.
+ * Do not run keycodes of lock keys through ToAscii(). One of ToAscii()'s
+ * side effects is to handle the lights on the keyboard, and we don't want
+ * to mess that up.
*/
if (noascii || keycode == VK_CAPITAL || keycode == VK_SCROLL ||
- keycode == VK_NUMLOCK)
+ keycode == VK_NUMLOCK) {
goto skipToAscii;
+ }
/*
* Use MapVirtualKey() to detect some dead keys.
@@ -222,27 +224,28 @@ KeycodeToKeysym(keycode, state, noascii)
if (state & Mod2Mask)
keys[VK_MENU] = 0x80;
- /*
+ /*
* Make sure all lock button info is correct so we don't mess up the
- * lights
+ * lights.
*/
- if (state & LockMask)
+ if (state & LockMask) {
keys[VK_CAPITAL] = 1;
- if (state & Mod3Mask)
+ }
+ if (state & Mod3Mask) {
keys[VK_SCROLL] = 1;
- if (state & Mod1Mask)
+ }
+ if (state & Mod1Mask) {
keys[VK_NUMLOCK] = 1;
+ }
result = ToAscii(keycode, scancode, keys, (LPWORD) buf, 0);
if (result < 0) {
/*
- * Win95/98:
- * This was a dead char, which is now remembered by the keyboard.
- * Call ToAscii() again to forget it.
- * WinNT:
- * This was a dead char, overwriting any previously remembered
+ * Win95/98: This was a dead char, which is now remembered by the
+ * keyboard. Call ToAscii() again to forget it.
+ * WinNT: This was a dead char, overwriting any previously remembered
* key. Calling ToAscii() again does not affect anything.
*/
@@ -251,12 +254,10 @@ KeycodeToKeysym(keycode, state, noascii)
}
if (result == 2) {
/*
- * This was a dead char, and there were one previously remembered
- * by the keyboard.
- * Call ToAscii() again with proper parameters to restore it.
- */
-
- /*
+ * This was a dead char, and there were one previously remembered by
+ * the keyboard. Call ToAscii() again with proper parameters to
+ * restore it.
+ *
* Get information about the old char
*/
@@ -270,39 +271,42 @@ KeycodeToKeysym(keycode, state, noascii)
*/
memset(keys, 0, 256);
- if (shift & 1)
+ if (shift & 1) {
keys[VK_SHIFT] = 0x80;
- if (shift & 2)
+ }
+ if (shift & 2) {
keys[VK_CONTROL] = 0x80;
- if (shift & 4)
+ }
+ if (shift & 4) {
keys[VK_MENU] = 0x80;
+ }
ToAscii(deadkey, scancode, keys, (LPWORD) buf, 0);
return XK_Multi_key;
}
/*
- * Keycode mapped to a valid Latin-1 character. Since the keysyms
- * for alphanumeric characters map onto Latin-1, we just return it.
+ * Keycode mapped to a valid Latin-1 character. Since the keysyms for
+ * alphanumeric characters map onto Latin-1, we just return it.
*
- * We treat 0x7F as a special case mostly for backwards compatibility.
- * In versions of Tk<=8.2, Control-Backspace returned "XK_BackSpace"
- * as the X Keysym. This was due to the fact that we did not
- * initialize the keys array properly when we passed it to ToAscii, above.
- * We had previously not been setting the state bit for the Control key.
- * When we fixed that, we found that Control-Backspace on Windows is
- * interpreted as ASCII-127 (0x7F), which corresponds to the Delete key.
+ * We treat 0x7F as a special case mostly for backwards compatibility. In
+ * versions of Tk<=8.2, Control-Backspace returned "XK_BackSpace" as the X
+ * Keysym. This was due to the fact that we did not initialize the keys
+ * array properly when we passed it to ToAscii, above. We had previously
+ * not been setting the state bit for the Control key. When we fixed that,
+ * we found that Control-Backspace on Windows is interpreted as ASCII-127
+ * (0x7F), which corresponds to the Delete key.
*
- * Upon discovering this, we realized we had two choices: return XK_Delete
- * or return XK_BackSpace. If we returned XK_Delete, that could be
+ * Upon discovering this, we realized we had two choices: return XK_Delete
+ * or return XK_BackSpace. If we returned XK_Delete, that could be
* considered "more correct" (although the correctness would be dependant
* on whether you believe that ToAscii is doing the right thing in that
- * case); however, this would break backwards compatibility, and worse,
- * it would limit application programmers -- they would effectively be
- * unable to bind to <Control-Backspace> on Windows. We therefore chose
- * instead to return XK_BackSpace (handled here by letting the code
- * "fall-through" to the return statement below, which works because the
- * keycode for this event is VK_BACKSPACE, and the keymap table maps that
- * keycode to XK_BackSpace).
+ * case); however, this would break backwards compatibility, and worse, it
+ * would limit application programmers -- they would effectively be unable
+ * to bind to <Control-Backspace> on Windows. We therefore chose instead
+ * to return XK_BackSpace (handled here by letting the code "fall-through"
+ * to the return statement below, which works because the keycode for this
+ * event is VK_BACKSPACE, and the keymap table maps that keycode to
+ * XK_BackSpace).
*/
if (result == 1 && UCHAR(buf[0]) >= 0x20 && UCHAR(buf[0]) != 0x7F) {
@@ -313,69 +317,63 @@ KeycodeToKeysym(keycode, state, noascii)
* Keycode is a non-alphanumeric key, so we have to do the lookup.
*/
- skipToAscii:
+ skipToAscii:
if (keycode < 0 || keycode > MAX_KEYCODE) {
return NoSymbol;
}
switch (keycode) {
/*
- * Windows only gives us an undifferentiated VK_CONTROL
- * code (for example) when either Control key is pressed.
- * To distinguish between left and right, we have to query the
- * state of one of the two to determine which was actually
- * pressed. So if the keycode indicates Control, Shift, or Menu
- * (the key that everybody else calls Alt), do this extra test.
- * If the right-side key was pressed, return the appropriate
- * keycode. Otherwise, we fall through and rely on the
+ * Windows only gives us an undifferentiated VK_CONTROL code (for
+ * example) when either Control key is pressed. To distinguish between
+ * left and right, we have to query the state of one of the two to
+ * determine which was actually pressed. So if the keycode indicates
+ * Control, Shift, or Menu (the key that everybody else calls Alt), do
+ * this extra test. If the right-side key was pressed, return the
+ * appropriate keycode. Otherwise, we fall through and rely on the
* keymap table to hold the correct keysym value.
*/
- case VK_CONTROL: {
- if (GetKeyState(VK_RCONTROL) & 0x80) {
- return XK_Control_R;
- }
- break;
+ case VK_CONTROL:
+ if (GetKeyState(VK_RCONTROL) & 0x80) {
+ return XK_Control_R;
}
- case VK_SHIFT: {
- if (GetKeyState(VK_RSHIFT) & 0x80) {
- return XK_Shift_R;
- }
- break;
+ break;
+ case VK_SHIFT:
+ if (GetKeyState(VK_RSHIFT) & 0x80) {
+ return XK_Shift_R;
}
- case VK_MENU: {
- if (GetKeyState(VK_RMENU) & 0x80) {
- return XK_Alt_R;
- }
- break;
+ break;
+ case VK_MENU:
+ if (GetKeyState(VK_RMENU) & 0x80) {
+ return XK_Alt_R;
}
+ break;
}
return keymap[keycode];
}
-
/*
*----------------------------------------------------------------------
*
* TkpGetKeySym --
*
- * Given an X KeyPress or KeyRelease event, map the
- * keycode in the event into a KeySym.
+ * Given an X KeyPress or KeyRelease event, map the keycode in the event
+ * into a KeySym.
*
* Results:
- * The return value is the KeySym corresponding to
- * eventPtr, or NoSymbol if no matching Keysym could be
- * found.
+ * The return value is the KeySym corresponding to eventPtr, or NoSymbol
+ * if no matching Keysym could be found.
*
* Side effects:
- * In the first call for a given display, keycode-to-
- * KeySym maps get loaded.
+ * In the first call for a given display, keycode-to-KeySym maps get
+ * loaded.
*
*----------------------------------------------------------------------
*/
KeySym
-TkpGetKeySym(dispPtr, eventPtr)
- TkDisplay *dispPtr; /* Display in which to map keycode. */
- XEvent *eventPtr; /* Description of X event. */
+TkpGetKeySym(
+ TkDisplay *dispPtr, /* Display in which to map keycode. */
+ XEvent *eventPtr) /* Description of X event. */
{
KeySym sym;
int state = eventPtr->xkey.state;
@@ -391,16 +389,16 @@ TkpGetKeySym(dispPtr, eventPtr)
sym = KeycodeToKeysym(eventPtr->xkey.keycode, state, 0);
/*
- * Special handling: if this is a ctrl-alt or shifted key, and there
- * is no keysym defined, try without the modifiers.
+ * Special handling: if this is a ctrl-alt or shifted key, and there is no
+ * keysym defined, try without the modifiers.
*/
if ((sym == NoSymbol) && ((state & ControlMask) || (state & Mod2Mask))) {
- state &= ~(ControlMask | Mod2Mask);
+ state &= ~(ControlMask | Mod2Mask);
sym = KeycodeToKeysym(eventPtr->xkey.keycode, state, 0);
}
if ((sym == NoSymbol) && (state & ShiftMask)) {
- state &= ~ShiftMask;
+ state &= ~ShiftMask;
sym = KeycodeToKeysym(eventPtr->xkey.keycode, state, 0);
}
return sym;
@@ -411,10 +409,9 @@ TkpGetKeySym(dispPtr, eventPtr)
*
* TkpInitKeymapInfo --
*
- * This procedure is invoked to scan keymap information
- * to recompute stuff that's important for binding, such
- * as the modifier key (if any) that corresponds to "mode
- * switch".
+ * This procedure is invoked to scan keymap information to recompute
+ * stuff that's important for binding, such as the modifier key (if any)
+ * that corresponds to "mode switch".
*
* Results:
* None.
@@ -426,8 +423,8 @@ TkpGetKeySym(dispPtr, eventPtr)
*/
void
-TkpInitKeymapInfo(dispPtr)
- TkDisplay *dispPtr; /* Display for which to recompute keymap
+TkpInitKeymapInfo(
+ TkDisplay *dispPtr) /* Display for which to recompute keymap
* information. */
{
XModifierKeymap *modMapPtr;
@@ -440,9 +437,9 @@ TkpInitKeymapInfo(dispPtr)
modMapPtr = XGetModifierMapping(dispPtr->display);
/*
- * Check the keycodes associated with the Lock modifier. If
- * any of them is associated with the XK_Shift_Lock modifier,
- * then Lock has to be interpreted as Shift Lock, not Caps Lock.
+ * Check the keycodes associated with the Lock modifier. If any of them is
+ * associated with the XK_Shift_Lock modifier, then Lock has to be
+ * interpreted as Shift Lock, not Caps Lock.
*/
dispPtr->lockUsage = LU_IGNORE;
@@ -463,9 +460,9 @@ TkpInitKeymapInfo(dispPtr)
}
/*
- * Look through the keycodes associated with modifiers to see if
- * the the "mode switch", "meta", or "alt" keysyms are associated
- * with any modifiers. If so, remember their modifier mask bits.
+ * Look through the keycodes associated with modifiers to see if the the
+ * "mode switch", "meta", or "alt" keysyms are associated with any
+ * modifiers. If so, remember their modifier mask bits.
*/
dispPtr->modeModMask = 0;
@@ -518,7 +515,7 @@ TkpInitKeymapInfo(dispPtr)
KeyCode *new;
/*
- * Ran out of space in the array; grow it.
+ * Ran out of space in the array; grow it.
*/
arraySize *= 2;
@@ -537,34 +534,32 @@ TkpInitKeymapInfo(dispPtr)
}
/*
- * When mapping from a keysym to a keycode, need
- * information about the modifier state that should be used
- * so that when they call XKeycodeToKeysym taking into
- * account the xkey.state, they will get back the original
- * keysym.
+ * When mapping from a keysym to a keycode, need information about the
+ * modifier state that should be used so that when they call XKeycodeToKeysym
+ * taking into account the xkey.state, they will get back the original keysym.
*/
void
-TkpSetKeycodeAndState(tkwin, keySym, eventPtr)
- Tk_Window tkwin;
- KeySym keySym;
- XEvent *eventPtr;
+TkpSetKeycodeAndState(
+ Tk_Window tkwin,
+ KeySym keySym,
+ XEvent *eventPtr)
{
int i;
SHORT result;
int shift;
-
+
eventPtr->xkey.keycode = 0;
if (keySym == NoSymbol) {
return;
}
/*
- * We check our private map first for a virtual keycode,
- * as VkKeyScan will return values that don't map to X
- * for the "extended" Syms. This may be due to just casting
- * problems below, but this works.
+ * We check our private map first for a virtual keycode, as VkKeyScan will
+ * return values that don't map to X for the "extended" Syms. This may be
+ * due to just casting problems below, but this works.
*/
+
for (i = 0; i <= MAX_KEYCODE; i++) {
if (keymap[i] == keySym) {
eventPtr->xkey.keycode = i;
@@ -603,19 +598,19 @@ TkpSetKeycodeAndState(tkwin, keySym, eventPtr)
*/
KeyCode
-XKeysymToKeycode(display, keysym)
- Display* display;
- KeySym keysym;
+XKeysymToKeycode(
+ Display *display,
+ KeySym keysym)
{
int i;
SHORT result;
/*
- * We check our private map first for a virtual keycode,
- * as VkKeyScan will return values that don't map to X
- * for the "extended" Syms. This may be due to just casting
- * problems below, but this works.
+ * We check our private map first for a virtual keycode, as VkKeyScan will
+ * return values that don't map to X for the "extended" Syms. This may be
+ * due to just casting problems below, but this works.
*/
+
if (keysym == NoSymbol) {
return 0;
}
@@ -651,10 +646,11 @@ XKeysymToKeycode(display, keysym)
*/
XModifierKeymap *
-XGetModifierMapping(display)
- Display* display;
+XGetModifierMapping(
+ Display *display)
{
- XModifierKeymap *map = (XModifierKeymap *)ckalloc(sizeof(XModifierKeymap));
+ XModifierKeymap *map = (XModifierKeymap *)
+ ckalloc(sizeof(XModifierKeymap));
map->max_keypermod = 1;
map->modifiermap = (KeyCode *) ckalloc(sizeof(KeyCode)*8);
@@ -674,8 +670,7 @@ XGetModifierMapping(display)
*
* XFreeModifiermap --
*
- * Deallocate a modifier map that was created by
- * XGetModifierMapping.
+ * Deallocate a modifier map that was created by XGetModifierMapping.
*
* Results:
* None.
@@ -687,8 +682,8 @@ XGetModifierMapping(display)
*/
void
-XFreeModifiermap(modmap)
- XModifierKeymap* modmap;
+XFreeModifiermap(
+ XModifierKeymap *modmap)
{
ckfree((char *) modmap->modifiermap);
ckfree((char *) modmap);
@@ -699,11 +694,11 @@ XFreeModifiermap(modmap)
*
* XStringToKeysym --
*
- * Translate a keysym name to the matching keysym.
+ * Translate a keysym name to the matching keysym.
*
* Results:
- * Returns the keysym. Since this is already handled by
- * Tk's StringToKeysym function, we just return NoSymbol.
+ * Returns the keysym. Since this is already handled by Tk's
+ * StringToKeysym function, we just return NoSymbol.
*
* Side effects:
* None.
@@ -712,8 +707,8 @@ XFreeModifiermap(modmap)
*/
KeySym
-XStringToKeysym(string)
- _Xconst char *string;
+XStringToKeysym(
+ _Xconst char *string)
{
return NoSymbol;
}
@@ -735,8 +730,16 @@ XStringToKeysym(string)
*/
char *
-XKeysymToString(keysym)
- KeySym keysym;
+XKeysymToString(
+ KeySym keysym)
{
return NULL;
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/win/tkWinPixmap.c b/win/tkWinPixmap.c
index d1fc569..73882b1 100644
--- a/win/tkWinPixmap.c
+++ b/win/tkWinPixmap.c
@@ -1,15 +1,15 @@
-/*
+/*
* tkWinPixmap.c --
*
- * This file contains the Xlib emulation functions pertaining to
- * creating and destroying pixmaps.
+ * This file contains the Xlib emulation functions pertaining to creating
+ * and destroying pixmaps.
*
* Copyright (c) 1995 Sun Microsystems, Inc.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinPixmap.c,v 1.4 2004/01/13 02:06:02 davygrvy Exp $
+ * RCS: @(#) $Id: tkWinPixmap.c,v 1.5 2005/12/02 00:19:04 dkf Exp $
*/
#include "tkWinInt.h"
@@ -32,17 +32,17 @@
*/
Pixmap
-Tk_GetPixmap(display, d, width, height, depth)
- Display* display;
- Drawable d;
- int width;
- int height;
- int depth;
+Tk_GetPixmap(
+ Display *display,
+ Drawable d,
+ int width,
+ int height,
+ int depth)
{
TkWinDrawable *newTwdPtr, *twdPtr;
int planes;
Screen *screen;
-
+
display->request++;
newTwdPtr = (TkWinDrawable*) ckalloc(sizeof(TkWinDrawable));
@@ -65,13 +65,14 @@ Tk_GetPixmap(display, d, width, height, depth)
planes = (int) screen->ext_data;
depth /= planes;
}
- newTwdPtr->bitmap.handle = CreateBitmap(width, height, planes, depth, NULL);
+ newTwdPtr->bitmap.handle =
+ CreateBitmap(width, height, planes, depth, NULL);
if (newTwdPtr->bitmap.handle == NULL) {
ckfree((char *) newTwdPtr);
return None;
}
-
+
return (Pixmap)newTwdPtr;
}
@@ -92,9 +93,9 @@ Tk_GetPixmap(display, d, width, height, depth)
*/
void
-Tk_FreePixmap(display, pixmap)
- Display* display;
- Pixmap pixmap;
+Tk_FreePixmap(
+ Display *display,
+ Pixmap pixmap)
{
TkWinDrawable *twdPtr = (TkWinDrawable *) pixmap;
@@ -123,9 +124,9 @@ Tk_FreePixmap(display, pixmap)
*/
void
-TkSetPixmapColormap(pixmap, colormap)
- Pixmap pixmap;
- Colormap colormap;
+TkSetPixmapColormap(
+ Pixmap pixmap,
+ Colormap colormap)
{
TkWinDrawable *twdPtr = (TkWinDrawable *)pixmap;
twdPtr->bitmap.colormap = colormap;
@@ -136,9 +137,9 @@ TkSetPixmapColormap(pixmap, colormap)
*
* XGetGeometry --
*
- * Retrieve the geometry of the given drawable. Note that
- * this is a degenerate implementation that only returns the
- * size of a pixmap or window.
+ * Retrieve the geometry of the given drawable. Note that this is a
+ * degenerate implementation that only returns the size of a pixmap or
+ * window.
*
* Results:
* Returns 0.
@@ -150,17 +151,16 @@ TkSetPixmapColormap(pixmap, colormap)
*/
int
-XGetGeometry(display, d, root_return, x_return, y_return, width_return,
- height_return, border_width_return, depth_return)
- Display* display;
- Drawable d;
- Window* root_return;
- int* x_return;
- int* y_return;
- unsigned int* width_return;
- unsigned int* height_return;
- unsigned int* border_width_return;
- unsigned int* depth_return;
+XGetGeometry(
+ Display *display,
+ Drawable d,
+ Window *root_return,
+ int *x_return,
+ int *y_return,
+ unsigned int *width_return,
+ unsigned int *height_return,
+ unsigned int *border_width_return,
+ unsigned int *depth_return)
{
TkWinDrawable *twdPtr = (TkWinDrawable *)d;
@@ -196,3 +196,11 @@ XGetGeometry(display, d, root_return, x_return, y_return, width_return,
}
return 1;
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/win/tkWinPointer.c b/win/tkWinPointer.c
index 28591cd..6788c71 100644
--- a/win/tkWinPointer.c
+++ b/win/tkWinPointer.c
@@ -1,4 +1,4 @@
-/*
+/*
* tkWinPointer.c --
*
* Windows specific mouse tracking code.
@@ -6,10 +6,10 @@
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
* Copyright (c) 1998-1999 by Scriptics Corporation.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinPointer.c,v 1.9 2004/01/13 02:06:02 davygrvy Exp $
+ * RCS: @(#) $Id: tkWinPointer.c,v 1.10 2005/12/02 00:19:04 dkf Exp $
*/
#include "tkWinInt.h"
@@ -33,7 +33,7 @@ static int mouseTimerSet = 0; /* 1 if the mouse timer is active. */
* Forward declarations of procedures used in this file.
*/
-static void MouseTimerProc _ANSI_ARGS_((ClientData clientData));
+static void MouseTimerProc(ClientData clientData);
/*
*----------------------------------------------------------------------
@@ -52,7 +52,7 @@ static void MouseTimerProc _ANSI_ARGS_((ClientData clientData));
*/
int
-TkWinGetModifierState()
+TkWinGetModifierState(void)
{
int state = 0;
@@ -91,10 +91,9 @@ TkWinGetModifierState()
*
* Tk_PointerEvent --
*
- * This procedure is called for each pointer-related event.
- * It converts the position to root coords and updates the
- * global pointer state machine. It also ensures that the
- * mouse timer is scheduled.
+ * This procedure is called for each pointer-related event. It converts
+ * the position to root coords and updates the global pointer state
+ * machine. It also ensures that the mouse timer is scheduled.
*
* Results:
* None.
@@ -106,11 +105,11 @@ TkWinGetModifierState()
*/
void
-Tk_PointerEvent(hwnd, x, y)
- HWND hwnd; /* Window for coords, or NULL for
- * the root window. */
- int x, y; /* Coords relative to hwnd, or screen
- * if hwnd is NULL. */
+Tk_PointerEvent(
+ HWND hwnd, /* Window for coords, or NULL for the root
+ * window. */
+ int x, int y) /* Coords relative to hwnd, or screen if hwnd
+ * is NULL. */
{
POINT pos;
int state;
@@ -128,11 +127,11 @@ Tk_PointerEvent(hwnd, x, y)
}
/*
- * If the mouse is captured, Windows will report all pointer
- * events to the capture window. So, we need to determine which
- * window the mouse is really over and change the event. Note
- * that the computed hwnd may point to a window not owned by Tk,
- * or a toplevel decorative frame, so tkwin can be NULL.
+ * If the mouse is captured, Windows will report all pointer events to the
+ * capture window. So, we need to determine which window the mouse is
+ * really over and change the event. Note that the computed hwnd may point
+ * to a window not owned by Tk, or a toplevel decorative frame, so tkwin
+ * can be NULL.
*/
if (captured || hwnd == NULL) {
@@ -168,14 +167,13 @@ Tk_PointerEvent(hwnd, x, y)
*/
int
-XGrabKeyboard(display, grab_window, owner_events, pointer_mode,
- keyboard_mode, time)
- Display* display;
- Window grab_window;
- Bool owner_events;
- int pointer_mode;
- int keyboard_mode;
- Time time;
+XGrabKeyboard(
+ Display *display,
+ Window grab_window,
+ Bool owner_events,
+ int pointer_mode,
+ int keyboard_mode,
+ Time time)
{
keyboardWinPtr = TkWinGetWinPtr(grab_window);
return GrabSuccess;
@@ -198,9 +196,9 @@ XGrabKeyboard(display, grab_window, owner_events, pointer_mode,
*/
void
-XUngrabKeyboard(display, time)
- Display* display;
- Time time;
+XUngrabKeyboard(
+ Display *display,
+ Time time)
{
keyboardWinPtr = NULL;
}
@@ -210,8 +208,7 @@ XUngrabKeyboard(display, time)
*
* MouseTimerProc --
*
- * Check the current mouse position and look for enter/leave
- * events.
+ * Check the current mouse position and look for enter/leave events.
*
* Results:
* None.
@@ -223,16 +220,16 @@ XUngrabKeyboard(display, time)
*/
void
-MouseTimerProc(clientData)
- ClientData clientData;
+MouseTimerProc(
+ ClientData clientData)
{
POINT pos;
mouseTimerSet = 0;
/*
- * Get the current mouse position and window. Don't do anything
- * if the mouse hasn't moved since the last time we looked.
+ * Get the current mouse position and window. Don't do anything if the
+ * mouse hasn't moved since the last time we looked.
*/
GetCursorPos(&pos);
@@ -256,7 +253,7 @@ MouseTimerProc(clientData)
*/
void
-TkWinCancelMouseTimer()
+TkWinCancelMouseTimer(void)
{
if (mouseTimerSet) {
Tcl_DeleteTimerHandler(mouseTimer);
@@ -272,8 +269,8 @@ TkWinCancelMouseTimer()
* Fetch the position of the mouse pointer.
*
* Results:
- * *xPtr and *yPtr are filled in with the root coordinates
- * of the mouse pointer for the display.
+ * *xPtr and *yPtr are filled in with the root coordinates of the mouse
+ * pointer for the display.
*
* Side effects:
* None.
@@ -282,10 +279,10 @@ TkWinCancelMouseTimer()
*/
void
-TkGetPointerCoords(tkwin, xPtr, yPtr)
- Tk_Window tkwin; /* Window that identifies screen on which
+TkGetPointerCoords(
+ Tk_Window tkwin, /* Window that identifies screen on which
* lookup is to be done. */
- int *xPtr, *yPtr; /* Store pointer coordinates here. */
+ int *xPtr, int *yPtr) /* Store pointer coordinates here. */
{
POINT point;
@@ -299,13 +296,13 @@ TkGetPointerCoords(tkwin, xPtr, yPtr)
*
* XQueryPointer --
*
- * Check the current state of the mouse. This is not a complete
- * implementation of this function. It only computes the root
- * coordinates and the current mask.
+ * Check the current state of the mouse. This is not a complete
+ * implementation of this function. It only computes the root coordinates
+ * and the current mask.
*
* Results:
- * Sets root_x_return, root_y_return, and mask_return. Returns
- * true on success.
+ * Sets root_x_return, root_y_return, and mask_return. Returns true on
+ * success.
*
* Side effects:
* None.
@@ -314,17 +311,16 @@ TkGetPointerCoords(tkwin, xPtr, yPtr)
*/
Bool
-XQueryPointer(display, w, root_return, child_return, root_x_return,
- root_y_return, win_x_return, win_y_return, mask_return)
- Display* display;
- Window w;
- Window* root_return;
- Window* child_return;
- int* root_x_return;
- int* root_y_return;
- int* win_x_return;
- int* win_y_return;
- unsigned int* mask_return;
+XQueryPointer(
+ Display *display,
+ Window w,
+ Window *root_return,
+ Window *child_return,
+ int *root_x_return,
+ int *root_y_return,
+ int *win_x_return,
+ int *win_y_return,
+ unsigned int *mask_return)
{
display->request++;
TkGetPointerCoords(NULL, root_x_return, root_y_return);
@@ -337,8 +333,8 @@ XQueryPointer(display, w, root_return, child_return, root_x_return,
*
* XWarpPointer --
*
- * Move pointer to new location. This is not a complete
- * implementation of this function.
+ * Move pointer to new location. This is not a complete implementation of
+ * this function.
*
* Results:
* None.
@@ -350,22 +346,21 @@ XQueryPointer(display, w, root_return, child_return, root_x_return,
*/
void
-XWarpPointer(display, src_w, dest_w, src_x, src_y, src_width,
- src_height, dest_x, dest_y)
- Display* display;
- Window src_w;
- Window dest_w;
- int src_x;
- int src_y;
- unsigned int src_width;
- unsigned int src_height;
- int dest_x;
- int dest_y;
+XWarpPointer(
+ Display *display,
+ Window src_w,
+ Window dest_w,
+ int src_x,
+ int src_y,
+ unsigned int src_width,
+ unsigned int src_height,
+ int dest_x,
+ int dest_y)
{
RECT r;
GetWindowRect(Tk_GetHWND(dest_w), &r);
- SetCursorPos(r.left+dest_x, r.top+dest_y);
+ SetCursorPos(r.left+dest_x, r.top+dest_y);
}
/*
@@ -385,12 +380,13 @@ XWarpPointer(display, src_w, dest_w, src_x, src_y, src_width,
*/
void
-XGetInputFocus(display, focus_return, revert_to_return)
- Display *display;
- Window *focus_return;
- int *revert_to_return;
+XGetInputFocus(
+ Display *display,
+ Window *focus_return,
+ int *revert_to_return)
{
Tk_Window tkwin = Tk_HWNDToWindow(GetFocus());
+
*focus_return = tkwin ? Tk_WindowId(tkwin) : None;
*revert_to_return = RevertToParent;
display->request++;
@@ -414,11 +410,11 @@ XGetInputFocus(display, focus_return, revert_to_return)
*/
void
-XSetInputFocus(display, focus, revert_to, time)
- Display* display;
- Window focus;
- int revert_to;
- Time time;
+XSetInputFocus(
+ Display *display,
+ Window focus,
+ int revert_to,
+ Time time)
{
display->request++;
if (focus != None) {
@@ -431,29 +427,28 @@ XSetInputFocus(display, focus, revert_to, time)
*
* TkpChangeFocus --
*
- * This procedure is invoked to move the system focus from
- * one window to another.
+ * This procedure is invoked to move the system focus from one window to
+ * another.
*
* Results:
- * The return value is the serial number of the command that
- * changed the focus. It may be needed by the caller to filter
- * out focus change events that were queued before the command.
- * If the procedure doesn't actually change the focus then
- * it returns 0.
+ * The return value is the serial number of the command that changed the
+ * focus. It may be needed by the caller to filter out focus change
+ * events that were queued before the command. If the procedure doesn't
+ * actually change the focus then it returns 0.
*
* Side effects:
- * The official Windows focus window changes; the application's focus
+ * The official Windows focus window changes; the application's focus
* window isn't changed by this procedure.
*
*----------------------------------------------------------------------
*/
int
-TkpChangeFocus(winPtr, force)
- TkWindow *winPtr; /* Window that is to receive the X focus. */
- int force; /* Non-zero means claim the focus even
- * if it didn't originally belong to
- * topLevelPtr's application. */
+TkpChangeFocus(
+ TkWindow *winPtr, /* Window that is to receive the X focus. */
+ int force) /* Non-zero means claim the focus even if it
+ * didn't originally belong to topLevelPtr's
+ * application. */
{
TkDisplay *dispPtr = winPtr->dispPtr;
Window focusWindow;
@@ -471,10 +466,10 @@ TkpChangeFocus(winPtr, force)
if (winPtr->window == None) {
Tcl_Panic("ChangeXFocus got null X window");
}
-
+
/*
- * Change the foreground window so the focus window is raised to the top of
- * the system stacking order and gets the keyboard focus.
+ * Change the foreground window so the focus window is raised to the top
+ * of the system stacking order and gets the keyboard focus.
*/
if (force) {
@@ -484,10 +479,10 @@ TkpChangeFocus(winPtr, force)
CurrentTime);
/*
- * Remember the current serial number for the X server and issue
- * a dummy server request. This marks the position at which we
- * changed the focus, so we can distinguish FocusIn and FocusOut
- * events on either side of the mark.
+ * Remember the current serial number for the X server and issue a dummy
+ * server request. This marks the position at which we changed the focus,
+ * so we can distinguish FocusIn and FocusOut events on either side of the
+ * mark.
*/
serial = NextRequest(winPtr->display);
@@ -500,10 +495,9 @@ TkpChangeFocus(winPtr, force)
*
* TkpSetCapture --
*
- * This function captures the mouse so that all future events
- * will be reported to this window, even if the mouse is outside
- * the window. If the specified window is NULL, then the mouse
- * is released.
+ * This function captures the mouse so that all future events will be
+ * reported to this window, even if the mouse is outside the window. If
+ * the specified window is NULL, then the mouse is released.
*
* Results:
* None.
@@ -515,8 +509,8 @@ TkpChangeFocus(winPtr, force)
*/
void
-TkpSetCapture(winPtr)
- TkWindow *winPtr; /* Capture window, or NULL. */
+TkpSetCapture(
+ TkWindow *winPtr) /* Capture window, or NULL. */
{
if (winPtr) {
SetCapture(Tk_GetHWND(Tk_WindowId(winPtr)));
@@ -526,3 +520,11 @@ TkpSetCapture(winPtr)
ReleaseCapture();
}
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/win/tkWinRegion.c b/win/tkWinRegion.c
index c3914e2..7cbdb9d 100644
--- a/win/tkWinRegion.c
+++ b/win/tkWinRegion.c
@@ -1,14 +1,14 @@
-/*
+/*
* tkWinRegion.c --
*
* Tk Region emulation code.
*
* Copyright (c) 1995 Sun Microsystems, Inc.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinRegion.c,v 1.5 2004/10/26 14:07:57 patthoyts Exp $
+ * RCS: @(#) $Id: tkWinRegion.c,v 1.6 2005/12/02 00:19:04 dkf Exp $
*/
#include "tkWinInt.h"
@@ -31,7 +31,7 @@
*/
TkRegion
-TkCreateRegion()
+TkCreateRegion(void)
{
RECT rect;
memset(&rect, 0, sizeof(RECT));
@@ -55,8 +55,8 @@ TkCreateRegion()
*/
void
-TkDestroyRegion(r)
- TkRegion r;
+TkDestroyRegion(
+ TkRegion r)
{
DeleteObject((HRGN) r);
}
@@ -78,11 +78,12 @@ TkDestroyRegion(r)
*/
void
-TkClipBox(r, rect_return)
- TkRegion r;
- XRectangle* rect_return;
+TkClipBox(
+ TkRegion r,
+ XRectangle* rect_return)
{
RECT rect;
+
GetRgnBox((HRGN)r, &rect);
rect_return->x = (short) rect.left;
rect_return->y = (short) rect.top;
@@ -107,10 +108,10 @@ TkClipBox(r, rect_return)
*/
void
-TkIntersectRegion(sra, srb, dr_return)
- TkRegion sra;
- TkRegion srb;
- TkRegion dr_return;
+TkIntersectRegion(
+ TkRegion sra,
+ TkRegion srb,
+ TkRegion dr_return)
{
CombineRgn((HRGN) dr_return, (HRGN) sra, (HRGN) srb, RGN_AND);
}
@@ -132,13 +133,14 @@ TkIntersectRegion(sra, srb, dr_return)
*/
void
-TkUnionRectWithRegion(rectangle, src_region, dest_region_return)
- XRectangle* rectangle;
- TkRegion src_region;
- TkRegion dest_region_return;
+TkUnionRectWithRegion(
+ XRectangle *rectangle,
+ TkRegion src_region,
+ TkRegion dest_region_return)
{
HRGN rectRgn = CreateRectRgn(rectangle->x, rectangle->y,
rectangle->x + rectangle->width, rectangle->y + rectangle->height);
+
CombineRgn((HRGN) dest_region_return, (HRGN) src_region,
(HRGN) rectRgn, RGN_OR);
DeleteObject(rectRgn);
@@ -149,8 +151,8 @@ TkUnionRectWithRegion(rectangle, src_region, dest_region_return)
*
* TkpBuildRegionFromAlphaData --
*
- * Set up a rectangle of the given region based on the supplied
- * alpha data.
+ * Set up a rectangle of the given region based on the supplied alpha
+ * data.
*
* Results:
* None
@@ -162,16 +164,17 @@ TkUnionRectWithRegion(rectangle, src_region, dest_region_return)
*/
void
-TkpBuildRegionFromAlphaData(region, x, y, width, height, dataPtr,
- pixelStride, lineStride)
- TkRegion region;
- unsigned int x, y; /* Where in region to update. */
- unsigned int width, height; /* Size of rectangle to update. */
- unsigned char *dataPtr; /* Data to read from. */
- unsigned int pixelStride; /* num bytes from one piece of alpha
- * data to the next in the line. */
- unsigned int lineStride; /* num bytes from one line of alpha
- * data to the next line. */
+TkpBuildRegionFromAlphaData(
+ TkRegion region,
+ unsigned int x, unsigned int y,
+ /* Where in region to update. */
+ unsigned int width, unsigned int height,
+ /* Size of rectangle to update. */
+ unsigned char *dataPtr, /* Data to read from. */
+ unsigned int pixelStride, /* Num bytes from one piece of alpha data to
+ * the next in the line. */
+ unsigned int lineStride) /* Num bytes from one line of alpha data to
+ * the next line. */
{
unsigned char *lineDataPtr;
unsigned int x1, y1, end;
@@ -180,13 +183,20 @@ TkpBuildRegionFromAlphaData(region, x, y, width, height, dataPtr,
for (y1 = 0; y1 < height; y1++) {
lineDataPtr = dataPtr;
for (x1 = 0; x1 < width; x1 = end) {
- /* search for first non-transparent pixel */
+ /*
+ * Search for first non-transparent pixel.
+ */
+
while ((x1 < width) && !*lineDataPtr) {
x1++;
lineDataPtr += pixelStride;
}
end = x1;
- /* search for first transparent pixel */
+
+ /*
+ * Search for first transparent pixel.
+ */
+
while ((end < width) && *lineDataPtr) {
end++;
lineDataPtr += pixelStride;
@@ -195,6 +205,7 @@ TkpBuildRegionFromAlphaData(region, x, y, width, height, dataPtr,
/*
* Manipulate Win32 regions directly; it's more efficient.
*/
+
SetRectRgn(rectRgn, x+x1, y+y1, x+end, y+y1+1);
CombineRgn((HRGN) region, (HRGN) region, rectRgn, RGN_OR);
}
@@ -213,9 +224,8 @@ TkpBuildRegionFromAlphaData(region, x, y, width, height, dataPtr,
* Test whether a given rectangle overlaps with a region.
*
* Results:
- * Returns RectanglePart or RectangleOut. Note that this is
- * not a complete implementation since it doesn't test for
- * RectangleIn.
+ * Returns RectanglePart or RectangleOut. Note that this is not a
+ * complete implementation since it doesn't test for RectangleIn.
*
* Side effects:
* None.
@@ -224,12 +234,11 @@ TkpBuildRegionFromAlphaData(region, x, y, width, height, dataPtr,
*/
int
-TkRectInRegion(r, x, y, width, height)
- TkRegion r;
- int x;
- int y;
- unsigned int width;
- unsigned int height;
+TkRectInRegion(
+ TkRegion r, /* Region to inspect */
+ int x, int y, /* Top-left of rectangle */
+ unsigned int width, /* Width of rectangle */
+ unsigned int height) /* Height of rectangle */
{
RECT rect;
rect.top = y;
@@ -256,10 +265,18 @@ TkRectInRegion(r, x, y, width, height)
*/
void
-TkSubtractRegion(sra, srb, dr_return)
- TkRegion sra;
- TkRegion srb;
- TkRegion dr_return;
+TkSubtractRegion(
+ TkRegion sra,
+ TkRegion srb,
+ TkRegion dr_return)
{
CombineRgn((HRGN) dr_return, (HRGN) sra, (HRGN) srb, RGN_DIFF);
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/win/tkWinScrlbr.c b/win/tkWinScrlbr.c
index 7ad61d8..e76a299 100644
--- a/win/tkWinScrlbr.c
+++ b/win/tkWinScrlbr.c
@@ -1,4 +1,4 @@
-/*
+/*
* tkWinScrollbar.c --
*
* This file implements the Windows specific portion of the scrollbar
@@ -6,21 +6,20 @@
*
* Copyright (c) 1996 by Sun Microsystems, Inc.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinScrlbr.c,v 1.10 2004/01/13 02:06:02 davygrvy Exp $
+ * RCS: @(#) $Id: tkWinScrlbr.c,v 1.11 2005/12/02 00:19:04 dkf Exp $
*/
#include "tkWinInt.h"
#include "tkScrollbar.h"
-
/*
- * The following constant is used to specify the maximum scroll position.
- * This value is limited by the Win32 API to either 16-bits or 32-bits,
- * depending on the context. For now we'll just use a value small
- * enough to fit in 16-bits, but which gives us 4-digits of precision.
+ * The following constant is used to specify the maximum scroll position. This
+ * value is limited by the Win32 API to either 16-bits or 32-bits, depending
+ * on the context. For now we'll just use a value small enough to fit in
+ * 16-bits, but which gives us 4-digits of precision.
*/
#define MAX_SCROLL 10000
@@ -39,7 +38,7 @@ typedef struct WinScrollbar {
/*
* Flag bits for native scrollbars:
- *
+ *
* IN_MODAL_LOOP: Non-zero means this scrollbar is in the middle
* of a modal loop.
* ALREADY_DEAD: Non-zero means this scrollbar has been
@@ -60,8 +59,8 @@ static int vArrowWidth, vArrowHeight, vThumb; /* Vertical control metrics. */
TCL_DECLARE_MUTEX(winScrlbrMutex)
/*
- * This variable holds the default width for a scrollbar in string
- * form for use in a Tk_ConfigSpec.
+ * This variable holds the default width for a scrollbar in string form for
+ * use in a Tk_ConfigSpec.
*/
static char defWidth[TCL_INTEGER_SPACE];
@@ -70,18 +69,16 @@ static char defWidth[TCL_INTEGER_SPACE];
* Declarations for functions defined in this file.
*/
-static Window CreateProc _ANSI_ARGS_((Tk_Window tkwin,
- Window parent, ClientData instanceData));
-static void ModalLoopProc _ANSI_ARGS_((Tk_Window tkwin,
- XEvent *eventPtr));
-static int ScrollbarBindProc _ANSI_ARGS_((ClientData clientData,
+static Window CreateProc(Tk_Window tkwin, Window parent,
+ ClientData instanceData);
+static void ModalLoopProc(Tk_Window tkwin, XEvent *eventPtr);
+static int ScrollbarBindProc(ClientData clientData,
Tcl_Interp *interp, XEvent *eventPtr,
- Tk_Window tkwin, KeySym keySym));
-static LRESULT CALLBACK ScrollbarProc _ANSI_ARGS_((HWND hwnd, UINT message,
- WPARAM wParam, LPARAM lParam));
-static void UpdateScrollbar _ANSI_ARGS_((
- WinScrollbar *scrollPtr));
-static void UpdateScrollbarMetrics _ANSI_ARGS_((void));
+ Tk_Window tkwin, KeySym keySym);
+static LRESULT CALLBACK ScrollbarProc(HWND hwnd, UINT message, WPARAM wParam,
+ LPARAM lParam);
+static void UpdateScrollbar(WinScrollbar *scrollPtr);
+static void UpdateScrollbarMetrics(void);
/*
* The class procedure table for the scrollbar widget.
@@ -112,12 +109,12 @@ Tk_ClassProcs tkpScrollbarProcs = {
*/
TkScrollbar *
-TkpCreateScrollbar(tkwin)
- Tk_Window tkwin;
+TkpCreateScrollbar(
+ Tk_Window tkwin)
{
WinScrollbar *scrollPtr;
TkWindow *winPtr = (TkWindow *)tkwin;
-
+
if (!initialized) {
Tcl_MutexLock(&winScrlbrMutex);
UpdateScrollbarMetrics();
@@ -142,7 +139,7 @@ TkpCreateScrollbar(tkwin)
ScrollbarBindProc, NULL, NULL);
}
- return (TkScrollbar*) scrollPtr;
+ return (TkScrollbar *) scrollPtr;
}
/*
@@ -150,8 +147,8 @@ TkpCreateScrollbar(tkwin)
*
* UpdateScrollbar --
*
- * This function updates the position and size of the scrollbar
- * thumb based on the current settings.
+ * This function updates the position and size of the scrollbar thumb
+ * based on the current settings.
*
* Results:
* None.
@@ -163,8 +160,8 @@ TkpCreateScrollbar(tkwin)
*/
static void
-UpdateScrollbar(scrollPtr)
- WinScrollbar *scrollPtr;
+UpdateScrollbar(
+ WinScrollbar *scrollPtr)
{
SCROLLINFO scrollInfo;
double thumbSize;
@@ -181,15 +178,17 @@ UpdateScrollbar(scrollPtr)
scrollInfo.nPage = ((UINT) (thumbSize * (double) MAX_SCROLL)) + 1;
if (thumbSize < 1.0) {
scrollInfo.nPos = (int)
- ((scrollPtr->info.firstFraction / (1.0-thumbSize))
- * (MAX_SCROLL - (scrollInfo.nPage - 1)));
+ ((scrollPtr->info.firstFraction / (1.0-thumbSize))
+ * (MAX_SCROLL - (scrollInfo.nPage - 1)));
} else {
scrollInfo.nPos = 0;
+
/*
- * Disable the scrollbar when there is nothing to scroll.
- * This is standard Windows style (see eg Notepad).
- * Also prevents possible crash on XP+ systems [Bug #624116].
+ * Disable the scrollbar when there is nothing to scroll. This is
+ * standard Windows style (see eg Notepad). Also prevents possible
+ * crash on XP+ systems [Bug #624116].
*/
+
scrollInfo.fMask |= SIF_DISABLENOSCROLL;
}
SetScrollInfo(scrollPtr->hwnd, SB_CTL, &scrollInfo, TRUE);
@@ -200,8 +199,8 @@ UpdateScrollbar(scrollPtr)
*
* CreateProc --
*
- * This function creates a new Scrollbar control, subclasses
- * the instance, and generates a new Window object.
+ * This function creates a new Scrollbar control, subclasses the
+ * instance, and generates a new Window object.
*
* Results:
* Returns the newly allocated Window object, or None on failure.
@@ -213,10 +212,10 @@ UpdateScrollbar(scrollPtr)
*/
static Window
-CreateProc(tkwin, parentWin, instanceData)
- Tk_Window tkwin; /* Token for window. */
- Window parentWin; /* Parent of new window. */
- ClientData instanceData; /* Scrollbar instance data. */
+CreateProc(
+ Tk_Window tkwin, /* Token for window. */
+ Window parentWin, /* Parent of new window. */
+ ClientData instanceData) /* Scrollbar instance data. */
{
DWORD style;
Window window;
@@ -228,10 +227,10 @@ CreateProc(tkwin, parentWin, instanceData)
if (scrollPtr->info.vertical) {
style = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS
- | SBS_VERT | SBS_RIGHTALIGN;
+ | SBS_VERT | SBS_RIGHTALIGN;
} else {
style = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS
- | SBS_HORZ | SBS_BOTTOMALIGN;
+ | SBS_HORZ | SBS_BOTTOMALIGN;
}
scrollPtr->hwnd = CreateWindow("SCROLLBAR", NULL, style,
@@ -240,14 +239,14 @@ CreateProc(tkwin, parentWin, instanceData)
/*
* Ensure new window is inserted into the stacking order at the correct
- * place.
+ * place.
*/
SetWindowPos(scrollPtr->hwnd, HWND_TOP, 0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
for (winPtr = ((TkWindow*)tkwin)->nextPtr; winPtr != NULL;
- winPtr = winPtr->nextPtr) {
+ winPtr = winPtr->nextPtr) {
if ((winPtr->window != None) && !(winPtr->flags & TK_TOP_HIERARCHY)) {
TkWinSetWindowPos(scrollPtr->hwnd, Tk_GetHWND(winPtr->window),
Below);
@@ -274,9 +273,9 @@ CreateProc(tkwin, parentWin, instanceData)
*
* TkpDisplayScrollbar --
*
- * This procedure redraws the contents of a scrollbar window.
- * It is invoked as a do-when-idle handler, so it only runs
- * when there's nothing else for the application to do.
+ * This procedure redraws the contents of a scrollbar window. It is
+ * invoked as a do-when-idle handler, so it only runs when there's
+ * nothing else for the application to do.
*
* Results:
* None.
@@ -288,8 +287,8 @@ CreateProc(tkwin, parentWin, instanceData)
*/
void
-TkpDisplayScrollbar(clientData)
- ClientData clientData; /* Information about window. */
+TkpDisplayScrollbar(
+ ClientData clientData) /* Information about window. */
{
WinScrollbar *scrollPtr = (WinScrollbar *) clientData;
Tk_Window tkwin = scrollPtr->info.tkwin;
@@ -300,8 +299,8 @@ TkpDisplayScrollbar(clientData)
}
/*
- * Destroy and recreate the scrollbar control if the orientation
- * has changed.
+ * Destroy and recreate the scrollbar control if the orientation has
+ * changed.
*/
if (scrollPtr->lastVertical != scrollPtr->info.vertical) {
@@ -338,11 +337,12 @@ TkpDisplayScrollbar(clientData)
*/
void
-TkpDestroyScrollbar(scrollPtr)
- TkScrollbar *scrollPtr;
+TkpDestroyScrollbar(
+ TkScrollbar *scrollPtr)
{
WinScrollbar *winScrollPtr = (WinScrollbar *)scrollPtr;
HWND hwnd = winScrollPtr->hwnd;
+
if (hwnd) {
#ifdef _WIN64
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) winScrollPtr->oldProc);
@@ -362,8 +362,7 @@ TkpDestroyScrollbar(scrollPtr)
*
* UpdateScrollbarMetrics --
*
- * This function retrieves the current system metrics for a
- * scrollbar.
+ * This function retrieves the current system metrics for a scrollbar.
*
* Results:
* None.
@@ -375,7 +374,7 @@ TkpDestroyScrollbar(scrollPtr)
*/
void
-UpdateScrollbarMetrics()
+UpdateScrollbarMetrics(void)
{
Tk_ConfigSpec *specPtr;
@@ -399,9 +398,9 @@ UpdateScrollbarMetrics()
*
* TkpComputeScrollbarGeometry --
*
- * After changes in a scrollbar's size or configuration, this
- * procedure recomputes various geometry information used in
- * displaying the scrollbar.
+ * After changes in a scrollbar's size or configuration, this procedure
+ * recomputes various geometry information used in displaying the
+ * scrollbar.
*
* Results:
* None.
@@ -413,15 +412,16 @@ UpdateScrollbarMetrics()
*/
void
-TkpComputeScrollbarGeometry(scrollPtr)
- register TkScrollbar *scrollPtr; /* Scrollbar whose geometry may
- * have changed. */
+TkpComputeScrollbarGeometry(
+ register TkScrollbar *scrollPtr)
+ /* Scrollbar whose geometry may have
+ * changed. */
{
int fieldLength, minThumbSize;
/*
- * Windows doesn't use focus rings on scrollbars, but we still
- * perform basic sanity checks to appease backwards compatibility.
+ * Windows doesn't use focus rings on scrollbars, but we still perform
+ * basic sanity checks to appease backwards compatibility.
*/
if (scrollPtr->highlightWidth < 0) {
@@ -447,9 +447,9 @@ TkpComputeScrollbarGeometry(scrollPtr)
* scrollPtr->lastFraction);
/*
- * Adjust the slider so that some piece of it is always
- * displayed in the scrollbar and so that it has at least
- * a minimal width (so it can be grabbed with the mouse).
+ * Adjust the slider so that some piece of it is always displayed in the
+ * scrollbar and so that it has at least a minimal width (so it can be
+ * grabbed with the mouse).
*/
if (scrollPtr->sliderFirst > fieldLength) {
@@ -469,10 +469,9 @@ TkpComputeScrollbarGeometry(scrollPtr)
scrollPtr->sliderLast += scrollPtr->arrowLength;
/*
- * Register the desired geometry for the window (leave enough space
- * for the two arrows plus a minimum-size slider, plus border around
- * the whole window, if any). Then arrange for the window to be
- * redisplayed.
+ * Register the desired geometry for the window (leave enough space for
+ * the two arrows plus a minimum-size slider, plus border around the whole
+ * window, if any). Then arrange for the window to be redisplayed.
*/
if (scrollPtr->vertical) {
@@ -490,8 +489,8 @@ TkpComputeScrollbarGeometry(scrollPtr)
*
* ScrollbarProc --
*
- * This function is call by Windows whenever an event occurs on
- * a scrollbar control created by Tk.
+ * This function is call by Windows whenever an event occurs on a
+ * scrollbar control created by Tk.
*
* Results:
* Standard Windows return value.
@@ -503,11 +502,11 @@ TkpComputeScrollbarGeometry(scrollPtr)
*/
static LRESULT CALLBACK
-ScrollbarProc(hwnd, message, wParam, lParam)
- HWND hwnd;
- UINT message;
- WPARAM wParam;
- LPARAM lParam;
+ScrollbarProc(
+ HWND hwnd,
+ UINT message,
+ WPARAM wParam,
+ LPARAM lParam)
{
LRESULT result;
POINT point;
@@ -520,85 +519,84 @@ ScrollbarProc(hwnd, message, wParam, lParam)
scrollPtr = (WinScrollbar *)((TkWindow*)tkwin)->instanceData;
switch(message) {
- case WM_HSCROLL:
- case WM_VSCROLL: {
- Tcl_Interp *interp;
- Tcl_DString cmdString;
- int command = LOWORD(wParam);
- int code;
-
- GetCursorPos(&point);
- Tk_TranslateWinEvent(NULL, WM_MOUSEMOVE, 0,
- MAKELPARAM(point.x, point.y), &result);
-
- if (command == SB_ENDSCROLL) {
- return 0;
- }
-
- /*
- * Bail out immediately if there isn't a command to invoke.
- */
-
- if (scrollPtr->info.commandSize == 0) {
- Tcl_ServiceAll();
- return 0;
- }
-
- Tcl_DStringInit(&cmdString);
- Tcl_DStringAppend(&cmdString, scrollPtr->info.command,
- scrollPtr->info.commandSize);
-
- if (command == SB_LINELEFT || command == SB_LINERIGHT) {
- Tcl_DStringAppendElement(&cmdString, "scroll");
- Tcl_DStringAppendElement(&cmdString,
- (command == SB_LINELEFT ) ? "-1" : "1");
- Tcl_DStringAppendElement(&cmdString, "units");
- } else if (command == SB_PAGELEFT || command == SB_PAGERIGHT) {
- Tcl_DStringAppendElement(&cmdString, "scroll");
- Tcl_DStringAppendElement(&cmdString,
- (command == SB_PAGELEFT ) ? "-1" : "1");
- Tcl_DStringAppendElement(&cmdString, "pages");
- } else {
- char valueString[TCL_DOUBLE_SPACE];
- double pos = 0.0;
- switch (command) {
- case SB_THUMBPOSITION:
- pos = ((double)HIWORD(wParam)) / MAX_SCROLL;
- break;
-
- case SB_THUMBTRACK:
- pos = ((double)HIWORD(wParam)) / MAX_SCROLL;
- break;
-
- case SB_TOP:
- pos = 0.0;
- break;
-
- case SB_BOTTOM:
- pos = 1.0;
- break;
- }
- sprintf(valueString, "%g", pos);
- Tcl_DStringAppendElement(&cmdString, "moveto");
- Tcl_DStringAppendElement(&cmdString, valueString);
- }
+ case WM_HSCROLL:
+ case WM_VSCROLL: {
+ Tcl_Interp *interp;
+ Tcl_DString cmdString;
+ int command = LOWORD(wParam);
+ int code;
+
+ GetCursorPos(&point);
+ Tk_TranslateWinEvent(NULL, WM_MOUSEMOVE, 0,
+ MAKELPARAM(point.x, point.y), &result);
+
+ if (command == SB_ENDSCROLL) {
+ return 0;
+ }
- interp = scrollPtr->info.interp;
- code = Tcl_GlobalEval(interp, cmdString.string);
- if (code != TCL_OK && code != TCL_CONTINUE && code != TCL_BREAK) {
- Tcl_AddErrorInfo(interp, "\n (scrollbar command)");
- Tcl_BackgroundError(interp);
- }
- Tcl_DStringFree(&cmdString);
+ /*
+ * Bail out immediately if there isn't a command to invoke.
+ */
+ if (scrollPtr->info.commandSize == 0) {
Tcl_ServiceAll();
return 0;
}
- default:
- if (Tk_TranslateWinEvent(hwnd, message, wParam, lParam, &result)) {
- return result;
+ Tcl_DStringInit(&cmdString);
+ Tcl_DStringAppend(&cmdString, scrollPtr->info.command,
+ scrollPtr->info.commandSize);
+
+ if (command == SB_LINELEFT || command == SB_LINERIGHT) {
+ Tcl_DStringAppendElement(&cmdString, "scroll");
+ Tcl_DStringAppendElement(&cmdString,
+ (command == SB_LINELEFT ) ? "-1" : "1");
+ Tcl_DStringAppendElement(&cmdString, "units");
+ } else if (command == SB_PAGELEFT || command == SB_PAGERIGHT) {
+ Tcl_DStringAppendElement(&cmdString, "scroll");
+ Tcl_DStringAppendElement(&cmdString,
+ (command == SB_PAGELEFT ) ? "-1" : "1");
+ Tcl_DStringAppendElement(&cmdString, "pages");
+ } else {
+ char valueString[TCL_DOUBLE_SPACE];
+ double pos = 0.0;
+
+ switch (command) {
+ case SB_THUMBPOSITION:
+ pos = ((double)HIWORD(wParam)) / MAX_SCROLL;
+ break;
+ case SB_THUMBTRACK:
+ pos = ((double)HIWORD(wParam)) / MAX_SCROLL;
+ break;
+ case SB_TOP:
+ pos = 0.0;
+ break;
+ case SB_BOTTOM:
+ pos = 1.0;
+ break;
}
+
+ sprintf(valueString, "%g", pos);
+ Tcl_DStringAppendElement(&cmdString, "moveto");
+ Tcl_DStringAppendElement(&cmdString, valueString);
+ }
+
+ interp = scrollPtr->info.interp;
+ code = Tcl_GlobalEval(interp, cmdString.string);
+ if (code != TCL_OK && code != TCL_CONTINUE && code != TCL_BREAK) {
+ Tcl_AddErrorInfo(interp, "\n (scrollbar command)");
+ Tcl_BackgroundError(interp);
+ }
+ Tcl_DStringFree(&cmdString);
+
+ Tcl_ServiceAll();
+ return 0;
+ }
+
+ default:
+ if (Tk_TranslateWinEvent(hwnd, message, wParam, lParam, &result)) {
+ return result;
+ }
}
return CallWindowProc(scrollPtr->oldProc, hwnd, message, wParam, lParam);
}
@@ -609,8 +607,8 @@ ScrollbarProc(hwnd, message, wParam, lParam)
* TkpConfigureScrollbar --
*
* This procedure is called after the generic code has finished
- * processing configuration options, in order to configure
- * platform specific options.
+ * processing configuration options, in order to configure platform
+ * specific options.
*
* Results:
* None.
@@ -622,10 +620,10 @@ ScrollbarProc(hwnd, message, wParam, lParam)
*/
void
-TkpConfigureScrollbar(scrollPtr)
- register TkScrollbar *scrollPtr; /* Information about widget; may or
- * may not already have values for
- * some fields. */
+TkpConfigureScrollbar(
+ register TkScrollbar *scrollPtr)
+ /* Information about widget; may or may not
+ * already have values for some fields. */
{
}
@@ -634,8 +632,8 @@ TkpConfigureScrollbar(scrollPtr)
*
* ScrollbarBindProc --
*
- * This procedure is invoked when the default <ButtonPress>
- * binding on the Scrollbar bind tag fires.
+ * This procedure is invoked when the default <ButtonPress> binding on
+ * the Scrollbar bind tag fires.
*
* Results:
* None.
@@ -647,14 +645,15 @@ TkpConfigureScrollbar(scrollPtr)
*/
static int
-ScrollbarBindProc(clientData, interp, eventPtr, tkwin, keySym)
- ClientData clientData;
- Tcl_Interp *interp;
- XEvent *eventPtr;
- Tk_Window tkwin;
- KeySym keySym;
+ScrollbarBindProc(
+ ClientData clientData,
+ Tcl_Interp *interp,
+ XEvent *eventPtr,
+ Tk_Window tkwin,
+ KeySym keySym)
{
- TkWindow *winPtr = (TkWindow*)tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
+
if (eventPtr->type == ButtonPress) {
winPtr->flags |= TK_DEFER_MODAL;
}
@@ -666,9 +665,8 @@ ScrollbarBindProc(clientData, interp, eventPtr, tkwin, keySym)
*
* ModalLoopProc --
*
- * This function is invoked at the end of the event processing
- * whenever the ScrollbarBindProc has been invoked for a ButtonPress
- * event.
+ * This function is invoked at the end of the event processing whenever
+ * the ScrollbarBindProc has been invoked for a ButtonPress event.
*
* Results:
* None.
@@ -680,9 +678,9 @@ ScrollbarBindProc(clientData, interp, eventPtr, tkwin, keySym)
*/
static void
-ModalLoopProc(tkwin, eventPtr)
- Tk_Window tkwin;
- XEvent *eventPtr;
+ModalLoopProc(
+ Tk_Window tkwin,
+ XEvent *eventPtr)
{
TkWindow *winPtr = (TkWindow*)tkwin;
WinScrollbar *scrollPtr = (WinScrollbar *) winPtr->instanceData;
@@ -707,14 +705,12 @@ ModalLoopProc(tkwin, eventPtr)
*
* TkpScrollbarPosition --
*
- * Determine the scrollbar element corresponding to a
- * given position.
+ * Determine the scrollbar element corresponding to a given position.
*
* Results:
- * One of TOP_ARROW, TOP_GAP, etc., indicating which element
- * of the scrollbar covers the position given by (x, y). If
- * (x,y) is outside the scrollbar entirely, then OUTSIDE is
- * returned.
+ * One of TOP_ARROW, TOP_GAP, etc., indicating which element of the
+ * scrollbar covers the position given by (x, y). If (x,y) is outside the
+ * scrollbar entirely, then OUTSIDE is returned.
*
* Side effects:
* None.
@@ -723,10 +719,10 @@ ModalLoopProc(tkwin, eventPtr)
*/
int
-TkpScrollbarPosition(scrollPtr, x, y)
- register TkScrollbar *scrollPtr; /* Scrollbar widget record. */
- int x, y; /* Coordinates within scrollPtr's
- * window. */
+TkpScrollbarPosition(
+ register TkScrollbar *scrollPtr,
+ /* Scrollbar widget record. */
+ int x, int y) /* Coordinates within scrollPtr's window. */
{
int length, width, tmp;
@@ -748,7 +744,7 @@ TkpScrollbarPosition(scrollPtr, x, y)
/*
* All of the calculations in this procedure mirror those in
- * TkpDisplayScrollbar. Be sure to keep the two consistent.
+ * TkpDisplayScrollbar. Be sure to keep the two consistent.
*/
if (y < (scrollPtr->inset + scrollPtr->arrowLength)) {
@@ -765,3 +761,11 @@ TkpScrollbarPosition(scrollPtr, x, y)
}
return BOTTOM_GAP;
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/win/tkWinSend.c b/win/tkWinSend.c
index 51d947e..2269512 100644
--- a/win/tkWinSend.c
+++ b/win/tkWinSend.c
@@ -1,114 +1,120 @@
-/*
+/*
* tkWinSend.c --
*
- * This file provides procedures that implement the "send"
- * command, allowing commands to be passed from interpreter
- * to interpreter.
+ * This file provides functions that implement the "send" command,
+ * allowing commands to be passed from interpreter to interpreter.
*
* Copyright (c) 1997 by Sun Microsystems, Inc.
* Copyright (c) 2003 Pat Thoyts <patthoyts@users.sourceforge.net>
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinSend.c,v 1.10 2005/10/14 11:59:19 patthoyts Exp $
+ * RCS: @(#) $Id: tkWinSend.c,v 1.11 2005/12/02 00:19:04 dkf Exp $
*/
#include "tkWinSendCom.h"
-/* Should be defined in WTypes.h but mingw 1.0 is missing them */
+/*
+ * Should be defined in WTypes.h but mingw 1.0 is missing them.
+ */
+
#ifndef _ROTFLAGS_DEFINED
#define _ROTFLAGS_DEFINED
-#define ROTFLAGS_REGISTRATIONKEEPSALIVE 0x01
-#define ROTFLAGS_ALLOWANYCLIENT 0x02
+#define ROTFLAGS_REGISTRATIONKEEPSALIVE 0x01
+#define ROTFLAGS_ALLOWANYCLIENT 0x02
#endif /* ! _ROTFLAGS_DEFINED */
-#define TKWINSEND_CLASS_NAME "TclEval"
-#define TKWINSEND_REGISTRATION_BASE L"TclEval"
+#define TKWINSEND_CLASS_NAME "TclEval"
+#define TKWINSEND_REGISTRATION_BASE L"TclEval"
#define MK_E_MONIKERALREADYREGISTERED \
- MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x02A1)
+ MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x02A1)
/*
- * Package information structure.
- * This is used to keep interpreter specific details for use when releasing
- * the package resources upon interpreter deletion or package removal.
+ * Package information structure. This is used to keep interpreter specific
+ * details for use when releasing the package resources upon interpreter
+ * deletion or package removal.
*/
+
typedef struct {
- char *name; /* the registered application name */
- DWORD cookie; /* ROT cookie returned on registration */
- LPUNKNOWN obj; /* Interface for the registration object */
+ char *name; /* The registered application name */
+ DWORD cookie; /* ROT cookie returned on registration */
+ LPUNKNOWN obj; /* Interface for the registration object */
Tcl_Interp *interp;
- Tcl_Command token; /* Winsend command token */
+ Tcl_Command token; /* Winsend command token */
} RegisteredInterp;
typedef struct SendEvent {
- Tcl_Event header;
- Tcl_Interp *interp;
- Tcl_Obj *cmdPtr;
+ Tcl_Event header;
+ Tcl_Interp *interp;
+ Tcl_Obj *cmdPtr;
} SendEvent;
typedef struct {
- int initialized;
+ int initialized;
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
-static void CmdDeleteProc(ClientData clientData);
-static void InterpDeleteProc(ClientData clientData, Tcl_Interp *interp);
-static void RevokeObjectRegistration(RegisteredInterp *riPtr);
-static HRESULT BuildMoniker(CONST char *name, LPMONIKER *pmk);
-static HRESULT RegisterInterp(CONST char *name, RegisteredInterp *riPtr);
-static int FindInterpreterObject(Tcl_Interp *interp, CONST char *name,
- LPDISPATCH *ppdisp);
-static int Send(LPDISPATCH pdispInterp, Tcl_Interp *interp, int async,
- ClientData clientData, int objc, Tcl_Obj *CONST objv[]);
-static Tcl_Obj* Win32ErrorObj(HRESULT hrError);
-static void SendTrace(const char *format, ...);
-
-static Tcl_EventProc SendEventProc;
+/*
+ * Functions internal to this file.
+ */
+static void CmdDeleteProc(ClientData clientData);
+static void InterpDeleteProc(ClientData clientData,
+ Tcl_Interp *interp);
+static void RevokeObjectRegistration(RegisteredInterp *riPtr);
+static HRESULT BuildMoniker(CONST char *name, LPMONIKER *pmk);
+static HRESULT RegisterInterp(CONST char *name,
+ RegisteredInterp *riPtr);
+static int FindInterpreterObject(Tcl_Interp *interp,
+ CONST char *name, LPDISPATCH *ppdisp);
+static int Send(LPDISPATCH pdispInterp, Tcl_Interp *interp,
+ int async, ClientData clientData, int objc,
+ Tcl_Obj *CONST objv[]);
+static Tcl_Obj * Win32ErrorObj(HRESULT hrError);
+static void SendTrace(const char *format, ...);
+static Tcl_EventProc SendEventProc;
#if defined(DEBUG) || defined(_DEBUG)
#define TRACE SendTrace
#else
#define TRACE 1 ? ((void)0) : SendTrace
#endif
-
/*
*--------------------------------------------------------------
*
* Tk_SetAppName --
*
- * This procedure is called to associate an ASCII name with a Tk
- * application. If the application has already been named, the
- * name replaces the old one.
+ * This function is called to associate an ASCII name with a Tk
+ * application. If the application has already been named, the name
+ * replaces the old one.
*
* Results:
- * The return value is the name actually given to the application.
- * This will normally be the same as name, but if name was already
- * in use for an application then a name of the form "name #2" will
- * be chosen, with a high enough number to make the name unique.
+ * The return value is the name actually given to the application. This
+ * will normally be the same as name, but if name was already in use for
+ * an application then a name of the form "name #2" will be chosen, with
+ * a high enough number to make the name unique.
*
* Side effects:
- * Registration info is saved, thereby allowing the "send" command
- * to be used later to invoke commands in the application. In
- * addition, the "send" command is created in the application's
- * interpreter. The registration will be removed automatically
- * if the interpreter is deleted or the "send" command is removed.
+ * Registration info is saved, thereby allowing the "send" command to be
+ * used later to invoke commands in the application. In addition, the
+ * "send" command is created in the application's interpreter. The
+ * registration will be removed automatically if the interpreter is
+ * deleted or the "send" command is removed.
*
*--------------------------------------------------------------
*/
CONST char *
-Tk_SetAppName(tkwin, name)
- Tk_Window tkwin; /* Token for any window in the application
- * to be named: it is just used to identify
- * the application and the display. */
- CONST char *name; /* The name that will be used to
- * refer to the interpreter in later
- * "send" commands. Must be globally
- * unique. */
+Tk_SetAppName(
+ Tk_Window tkwin, /* Token for any window in the application to
+ * be named: it is just used to identify the
+ * application and the display. */
+ CONST char *name) /* The name that will be used to refer to the
+ * interpreter in later "send" commands. Must
+ * be globally unique. */
{
ThreadSpecificData *tsdPtr = NULL;
TkWindow *winPtr = (TkWindow *)tkwin;
@@ -118,59 +124,61 @@ Tk_SetAppName(tkwin, name)
interp = winPtr->mainPtr->interp;
+#ifndef TK_SEND_ENABLED_ON_WINDOWS
/*
* Temporarily disabled for bug #858822
*/
+
return name;
+#else /* TK_SEND_ENABLED_ON_WINDOWS */
tsdPtr = (ThreadSpecificData *)
- Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
- /*
+ /*
* Initialise the COM library for this interpreter just once.
*/
+
if (tsdPtr->initialized == 0) {
- hr = CoInitialize(0);
- if (FAILED(hr)) {
- Tcl_SetResult(interp,
- "failed to initialize the COM library", TCL_STATIC);
- return "";
- }
- tsdPtr->initialized = 1;
- TRACE("Initialized COM library for interp 0x%08X\n", (long)interp);
+ hr = CoInitialize(0);
+ if (FAILED(hr)) {
+ Tcl_SetResult(interp,
+ "failed to initialize the COM library", TCL_STATIC);
+ return "";
+ }
+ tsdPtr->initialized = 1;
+ TRACE("Initialized COM library for interp 0x%08X\n", (long)interp);
}
-
- /*
- * If the interp hasn't been registered before then we need to create
- * the registration structure and the COM object. If it has been
- * registered already then we can reuse all and just register the new
- * name.
+
+ /*
+ * If the interp hasn't been registered before then we need to create the
+ * registration structure and the COM object. If it has been registered
+ * already then we can reuse all and just register the new name.
*/
-
+
riPtr = Tcl_GetAssocData(interp, "tkWinSend::ri", NULL);
if (riPtr == NULL) {
-
- riPtr = (RegisteredInterp *)ckalloc(sizeof(RegisteredInterp));
- memset(riPtr, 0, sizeof(RegisteredInterp));
- riPtr->interp = interp;
-
- hr = TkWinSendCom_CreateInstance(interp, &IID_IUnknown,
- (void **)&riPtr->obj);
-
- Tcl_CreateObjCommand(interp, "send", Tk_SendObjCmd,
- (ClientData)riPtr, CmdDeleteProc);
- if (Tcl_IsSafe(interp)) {
- Tcl_HideCommand(interp, "send", "send");
- }
- Tcl_SetAssocData(interp, "tkWinSend::ri", NULL, (ClientData)riPtr);
-
+
+ riPtr = (RegisteredInterp *)ckalloc(sizeof(RegisteredInterp));
+ memset(riPtr, 0, sizeof(RegisteredInterp));
+ riPtr->interp = interp;
+
+ hr = TkWinSendCom_CreateInstance(interp, &IID_IUnknown,
+ (void **)&riPtr->obj);
+
+ Tcl_CreateObjCommand(interp, "send", Tk_SendObjCmd,
+ (ClientData)riPtr, CmdDeleteProc);
+ if (Tcl_IsSafe(interp)) {
+ Tcl_HideCommand(interp, "send", "send");
+ }
+ Tcl_SetAssocData(interp, "tkWinSend::ri", NULL, (ClientData)riPtr);
} else {
-
- RevokeObjectRegistration(riPtr);
+ RevokeObjectRegistration(riPtr);
}
-
+
RegisterInterp(name, riPtr);
- return (CONST char *)riPtr->name;
+ return (CONST char *) riPtr->name;
+#endif /* TK_SEND_ENABLED_ON_WINDOWS */
}
/*
@@ -178,15 +186,14 @@ Tk_SetAppName(tkwin, name)
*
* TkGetInterpNames --
*
- * This procedure is invoked to fetch a list of all the
- * interpreter names currently registered for the display
- * of a particular window.
+ * This function is invoked to fetch a list of all the interpreter names
+ * currently registered for the display of a particular window.
*
* Results:
- * A standard Tcl return value. Interp->result will be set
- * to hold a list of all the interpreter names defined for
- * tkwin's display. If an error occurs, then TCL_ERROR
- * is returned and interp->result will hold an error message.
+ * A standard Tcl return value. Interp->result will be set to hold a list
+ * of all the interpreter names defined for tkwin's display. If an error
+ * occurs, then TCL_ERROR is returned and interp->result will hold an
+ * error message.
*
* Side effects:
* None.
@@ -195,49 +202,56 @@ Tk_SetAppName(tkwin, name)
*/
int
-TkGetInterpNames(interp, tkwin)
- Tcl_Interp *interp; /* Interpreter for returning a result. */
- Tk_Window tkwin; /* Window whose display is to be used
- * for the lookup. */
+TkGetInterpNames(
+ Tcl_Interp *interp, /* Interpreter for returning a result. */
+ Tk_Window tkwin) /* Window whose display is to be used for the
+ * lookup. */
{
LPRUNNINGOBJECTTABLE pROT = NULL;
LPCOLESTR oleszStub = TKWINSEND_REGISTRATION_BASE;
HRESULT hr = S_OK;
Tcl_Obj *objList = NULL;
int result = TCL_OK;
-
+
+#ifndef TK_SEND_ENABLED_ON_WINDOWS
/*
* Temporarily disabled for bug #858822
*/
+
return TCL_OK;
+#else /* TK_SEND_ENABLED_ON_WINDOWS */
hr = GetRunningObjectTable(0, &pROT);
- if(SUCCEEDED(hr)) {
+ if (SUCCEEDED(hr)) {
IBindCtx* pBindCtx = NULL;
objList = Tcl_NewListObj(0, NULL);
hr = CreateBindCtx(0, &pBindCtx);
+
if (SUCCEEDED(hr)) {
-
IEnumMoniker* pEnum;
+
hr = pROT->lpVtbl->EnumRunning(pROT, &pEnum);
- if(SUCCEEDED(hr)) {
+ if (SUCCEEDED(hr)) {
IMoniker* pmk = NULL;
- while (pEnum->lpVtbl->Next(pEnum, 1, &pmk, (ULONG*)NULL)
- == S_OK) {
+
+ while (pEnum->lpVtbl->Next(pEnum, 1, &pmk, NULL) == S_OK) {
LPOLESTR olestr;
- hr = pmk->lpVtbl->GetDisplayName(pmk, pBindCtx,
- NULL, &olestr);
+
+ hr = pmk->lpVtbl->GetDisplayName(pmk, pBindCtx, NULL,
+ &olestr);
if (SUCCEEDED(hr)) {
IMalloc *pMalloc = NULL;
-
- if (wcsncmp(olestr, oleszStub, wcslen(oleszStub)) == 0) {
+
+ if (wcsncmp(olestr, oleszStub,
+ wcslen(oleszStub)) == 0) {
LPOLESTR p = olestr + wcslen(oleszStub);
+
if (*p) {
- result = Tcl_ListObjAppendElement(interp,
- objList, Tcl_NewUnicodeObj(p + 1, -1));
+ result = Tcl_ListObjAppendElement(interp,
+ objList, Tcl_NewUnicodeObj(p + 1, -1));
}
}
-
+
hr = CoGetMalloc(1, &pMalloc);
if (SUCCEEDED(hr)) {
pMalloc->lpVtbl->Free(pMalloc, (void*)olestr);
@@ -254,19 +268,23 @@ TkGetInterpNames(interp, tkwin)
}
if (FAILED(hr)) {
- /* expire the list if set */
- if (objList != NULL) {
- Tcl_DecrRefCount(objList);
- }
- Tcl_SetObjResult(interp, Win32ErrorObj(hr));
- result = TCL_ERROR;
+ /*
+ * Expire the list if set.
+ */
+
+ if (objList != NULL) {
+ Tcl_DecrRefCount(objList);
+ }
+ Tcl_SetObjResult(interp, Win32ErrorObj(hr));
+ result = TCL_ERROR;
}
-
+
if (result == TCL_OK) {
- Tcl_SetObjResult(interp, objList);
+ Tcl_SetObjResult(interp, objList);
}
-
+
return result;
+#endif /* TK_SEND_ENABLED_ON_WINDOWS */
}
/*
@@ -274,8 +292,8 @@ TkGetInterpNames(interp, tkwin)
*
* Tk_SendCmd --
*
- * This procedure is invoked to process the "send" Tcl command.
- * See the user documentation for details on what it does.
+ * This function is invoked to process the "send" Tcl command. See the
+ * user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
@@ -287,24 +305,27 @@ TkGetInterpNames(interp, tkwin)
*/
int
-Tk_SendObjCmd(clientData, interp, objc, objv)
- ClientData clientData; /* Information about sender (only
- * dispPtr field is used). */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument strings. */
+Tk_SendObjCmd(
+ ClientData clientData, /* Information about sender (only dispPtr
+ * field is used). */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *CONST objv[]) /* Argument strings. */
{
enum {
SEND_ASYNC, SEND_DISPLAYOF, SEND_LAST
};
static CONST char *sendOptions[] = {
- "-async", "-displayof", "--", (CONST char *)NULL
+ "-async", "-displayof", "--", NULL
};
int result = TCL_OK;
int i, optind, async = 0;
Tcl_Obj *displayPtr = NULL;
- /* process the command options */
+ /*
+ * Process the command options.
+ */
+
for (i = 1; i < objc; i++) {
if (Tcl_GetIndexFromObj(interp, objv[i], sendOptions,
"option", 0, &optind) != TCL_OK) {
@@ -319,12 +340,15 @@ Tk_SendObjCmd(clientData, interp, objc, objv)
break;
}
}
-
- /* ensure we still have a valid command */
+
+ /*
+ * Ensure we still have a valid command.
+ */
+
if ((objc - i) < 2) {
- Tcl_WrongNumArgs(interp, 1, objv,
+ Tcl_WrongNumArgs(interp, 1, objv,
"?-async? ?-displayof? ?--? interpName arg ?arg ...?");
- result = TCL_ERROR;
+ result = TCL_ERROR;
}
/*
@@ -333,24 +357,25 @@ Tk_SendObjCmd(clientData, interp, objc, objv)
if (displayPtr) {
Tcl_SetStringObj(Tcl_GetObjResult(interp),
- "option not implemented: \"displayof\" is not available "
- "for this platform.", -1);
+ "option not implemented: \"displayof\" is not available "
+ "for this platform.", -1);
result = TCL_ERROR;
}
-
- /* send the arguments to the foreign interp */
+
+ /*
+ * Send the arguments to the foreign interp.
+ */
/* FIX ME: we need to check for local interp */
if (result == TCL_OK) {
LPDISPATCH pdisp;
result = FindInterpreterObject(interp, Tcl_GetString(objv[i]), &pdisp);
if (result == TCL_OK) {
i++;
- result = Send(pdisp, interp, async, clientData,
- (objc - i), &objv[i]);
+ result = Send(pdisp, interp, async, clientData, objc-i, objv+i);
pdisp->lpVtbl->Release(pdisp);
}
}
-
+
return result;
}
@@ -359,16 +384,14 @@ Tk_SendObjCmd(clientData, interp, objc, objv)
*
* FindInterpreterObject --
*
- * Search the set of objects currently registered with the
- * Running Object Table for one which matches the registered
- * name. Tk objects are named using BuildMoniker by always
- * prefixing with TclEval.
+ * Search the set of objects currently registered with the Running Object
+ * Table for one which matches the registered name. Tk objects are named
+ * using BuildMoniker by always prefixing with TclEval.
*
* Results:
- * If a matching object registration is found, then the
- * registered IDispatch interface pointer is returned.
- * If not, then an error message is placed in the interpreter
- * and TCL_ERROR is returned.
+ * If a matching object registration is found, then the registered
+ * IDispatch interface pointer is returned. If not, then an error message
+ * is placed in the interpreter and TCL_ERROR is returned.
*
* Side effects:
* None.
@@ -377,19 +400,26 @@ Tk_SendObjCmd(clientData, interp, objc, objv)
*/
static int
-FindInterpreterObject(Tcl_Interp *interp, CONST char *name, LPDISPATCH *ppdisp)
+FindInterpreterObject(
+ Tcl_Interp *interp,
+ CONST char *name,
+ LPDISPATCH *ppdisp)
{
LPRUNNINGOBJECTTABLE pROT = NULL;
int result = TCL_OK;
HRESULT hr = GetRunningObjectTable(0, &pROT);
+
if (SUCCEEDED(hr)) {
IBindCtx* pBindCtx = NULL;
+
hr = CreateBindCtx(0, &pBindCtx);
if (SUCCEEDED(hr)) {
LPMONIKER pmk = NULL;
+
hr = BuildMoniker(name, &pmk);
if (SUCCEEDED(hr)) {
IUnknown* punkInterp = NULL;
+
hr = pROT->lpVtbl->IsRunning(pROT, pmk);
hr = pmk->lpVtbl->BindToObject(pmk, pBindCtx, NULL,
&IID_IUnknown, (void**)&punkInterp);
@@ -401,10 +431,10 @@ FindInterpreterObject(Tcl_Interp *interp, CONST char *name, LPDISPATCH *ppdisp)
} else {
Tcl_ResetResult(interp);
Tcl_AppendResult(interp,
- "no application named \"", name, "\"", NULL);
+ "no application named \"", name, "\"", NULL);
result = TCL_ERROR;
}
-
+
pmk->lpVtbl->Release(pmk);
}
pBindCtx->lpVtbl->Release(pBindCtx);
@@ -423,38 +453,50 @@ FindInterpreterObject(Tcl_Interp *interp, CONST char *name, LPDISPATCH *ppdisp)
*
* CmdDeleteProc --
*
- * This procedure is invoked by Tcl when the "send" command
- * is deleted in an interpreter. It unregisters the interpreter.
+ * This function is invoked by Tcl when the "send" command is deleted in
+ * an interpreter. It unregisters the interpreter.
*
* Results:
* None.
*
* Side effects:
- * The interpreter given by riPtr is unregistered, the
- * registration structure is free'd and the COM object
- * unregistered and released.
+ * The interpreter given by riPtr is unregistered, the registration
+ * structure is free'd and the COM object unregistered and released.
*
*--------------------------------------------------------------
*/
static void
-CmdDeleteProc(ClientData clientData)
+CmdDeleteProc(
+ ClientData clientData)
{
RegisteredInterp *riPtr = (RegisteredInterp *)clientData;
- /* Lock the package structure in memory */
+ /*
+ * Lock the package structure in memory.
+ */
+
Tcl_Preserve(clientData);
- /* Revoke the ROT registration */
+ /*
+ * Revoke the ROT registration.
+ */
+
RevokeObjectRegistration(riPtr);
- /* Release the registration object */
+ /*
+ * Release the registration object.
+ */
+
riPtr->obj->lpVtbl->Release(riPtr->obj);
riPtr->obj = NULL;
Tcl_DeleteAssocData(riPtr->interp, "tkWinSend::ri");
- /* unlock the package data structure. */
+ /*
+ * Unlock the package data structure.
+ */
+
Tcl_Release(clientData);
ckfree(clientData);
@@ -465,37 +507,42 @@ CmdDeleteProc(ClientData clientData)
*
* RevokeObjectRegistration --
*
- * Releases the interpreters registration object from the
- * Running Object Table.
+ * Releases the interpreters registration object from the Running Object
+ * Table.
*
* Results:
* None.
*
* Side effects:
- * The stored cookie value is zeroed and the name is free'd
- * and the pointer set to NULL.
+ * The stored cookie value is zeroed and the name is free'd and the
+ * pointer set to NULL.
*
*--------------------------------------------------------------
*/
static void
-RevokeObjectRegistration(RegisteredInterp *riPtr)
+RevokeObjectRegistration(
+ RegisteredInterp *riPtr)
{
LPRUNNINGOBJECTTABLE pROT = NULL;
HRESULT hr = S_OK;
+
if (riPtr->cookie != 0) {
- hr = GetRunningObjectTable(0, &pROT);
- if (SUCCEEDED(hr)) {
- hr = pROT->lpVtbl->Revoke(pROT, riPtr->cookie);
- pROT->lpVtbl->Release(pROT);
- riPtr->cookie = 0;
- }
+ hr = GetRunningObjectTable(0, &pROT);
+ if (SUCCEEDED(hr)) {
+ hr = pROT->lpVtbl->Revoke(pROT, riPtr->cookie);
+ pROT->lpVtbl->Release(pROT);
+ riPtr->cookie = 0;
+ }
}
- /* release the name storage */
+ /*
+ * Release the name storage.
+ */
+
if (riPtr->name != NULL) {
free(riPtr->name);
- riPtr->name = NULL;
+ riPtr->name = NULL;
}
}
@@ -504,8 +551,8 @@ RevokeObjectRegistration(RegisteredInterp *riPtr)
*
* InterpDeleteProc --
*
- * This is called when the interpreter is deleted and used to
- * unregister the COM libraries.
+ * This is called when the interpreter is deleted and used to unregister
+ * the COM libraries.
*
* Results:
* None.
@@ -517,7 +564,9 @@ RevokeObjectRegistration(RegisteredInterp *riPtr)
*/
static void
-InterpDeleteProc(ClientData clientData, Tcl_Interp *interp)
+InterpDeleteProc(
+ ClientData clientData,
+ Tcl_Interp *interp)
{
CoUninitialize();
}
@@ -526,13 +575,13 @@ InterpDeleteProc(ClientData clientData, Tcl_Interp *interp)
* ----------------------------------------------------------------------
*
* BuildMoniker --
- *
+ *
* Construct a moniker from the given name. This ensures that all our
* monikers have the same prefix.
*
* Results:
- * S_OK. If the name cannot be turned into a moniker then a
- * COM error code is returned.
+ * S_OK. If the name cannot be turned into a moniker then a COM error
+ * code is returned.
*
* Side effects:
* The moniker created is stored at the address given by ppmk.
@@ -541,23 +590,26 @@ InterpDeleteProc(ClientData clientData, Tcl_Interp *interp)
*/
static HRESULT
-BuildMoniker(CONST char *name, LPMONIKER *ppmk)
+BuildMoniker(
+ CONST char *name,
+ LPMONIKER *ppmk)
{
LPMONIKER pmkClass = NULL;
HRESULT hr = CreateFileMoniker(TKWINSEND_REGISTRATION_BASE, &pmkClass);
+
if (SUCCEEDED(hr)) {
- LPMONIKER pmkItem = NULL;
+ LPMONIKER pmkItem = NULL;
Tcl_DString dString;
Tcl_DStringInit(&dString);
Tcl_UtfToUniCharDString(name, -1, &dString);
- hr = CreateFileMoniker((LPOLESTR)Tcl_DStringValue(&dString), &pmkItem);
+ hr = CreateFileMoniker((LPOLESTR)Tcl_DStringValue(&dString), &pmkItem);
Tcl_DStringFree(&dString);
- if (SUCCEEDED(hr)) {
- hr = pmkClass->lpVtbl->ComposeWith(pmkClass, pmkItem, FALSE, ppmk);
+ if (SUCCEEDED(hr)) {
+ hr = pmkClass->lpVtbl->ComposeWith(pmkClass, pmkItem, FALSE, ppmk);
pmkItem->lpVtbl->Release(pmkItem);
- }
- pmkClass->lpVtbl->Release(pmkClass);
+ }
+ pmkClass->lpVtbl->Release(pmkClass);
}
return hr;
}
@@ -566,23 +618,25 @@ BuildMoniker(CONST char *name, LPMONIKER *ppmk)
* ----------------------------------------------------------------------
*
* RegisterInterp --
- *
- * Attempts to register the provided name for this interpreter.
- * If the given name is already in use, then a numeric suffix is
- * appended as " #n" until we identify a unique name.
- *
+ *
+ * Attempts to register the provided name for this interpreter. If the
+ * given name is already in use, then a numeric suffix is appended as
+ * " #n" until we identify a unique name.
+ *
* Results:
* Returns S_OK if successful, else a COM error code.
*
* Side effects:
- * Registration returns a cookie value which is stored. We also store
- * a copy of the name.
+ * Registration returns a cookie value which is stored. We also store a
+ * copy of the name.
*
* ----------------------------------------------------------------------
*/
static HRESULT
-RegisterInterp(CONST char *name, RegisteredInterp *riPtr)
+RegisterInterp(
+ CONST char *name,
+ RegisteredInterp *riPtr)
{
HRESULT hr = S_OK;
LPRUNNINGOBJECTTABLE pROT = NULL;
@@ -594,9 +648,7 @@ RegisterInterp(CONST char *name, RegisteredInterp *riPtr)
hr = GetRunningObjectTable(0, &pROT);
if (SUCCEEDED(hr)) {
-
offset = 0;
-
for (i = 1; SUCCEEDED(hr); i++) {
if (i > 1) {
if (i == 2) {
@@ -609,11 +661,11 @@ RegisterInterp(CONST char *name, RegisteredInterp *riPtr)
}
sprintf(Tcl_DStringValue(&dString) + offset, "%d", i);
}
-
+
hr = BuildMoniker(actualName, &pmk);
if (SUCCEEDED(hr)) {
- hr = pROT->lpVtbl->Register(pROT,
+ hr = pROT->lpVtbl->Register(pROT,
ROTFLAGS_REGISTRATIONKEEPSALIVE,
riPtr->obj, pmk, &riPtr->cookie);
@@ -621,17 +673,17 @@ RegisterInterp(CONST char *name, RegisteredInterp *riPtr)
}
if (hr == MK_S_MONIKERALREADYREGISTERED) {
- pROT->lpVtbl->Revoke(pROT, riPtr->cookie);
+ pROT->lpVtbl->Revoke(pROT, riPtr->cookie);
} else if (hr == S_OK) {
break;
}
}
-
+
pROT->lpVtbl->Release(pROT);
}
if (SUCCEEDED(hr)) {
- riPtr->name = strdup(actualName);
+ riPtr->name = strdup(actualName);
}
Tcl_DStringFree(&dString);
@@ -643,9 +695,9 @@ RegisterInterp(CONST char *name, RegisteredInterp *riPtr)
*
* Send --
*
- * Perform an interface call to the server object. We convert the
- * Tcl arguments into a BSTR using 'concat'. The result should be a
- * BSTR that we can set as the interp's result string.
+ * Perform an interface call to the server object. We convert the Tcl
+ * arguments into a BSTR using 'concat'. The result should be a BSTR that
+ * we can set as the interp's result string.
*
* Results:
* None.
@@ -654,15 +706,18 @@ RegisterInterp(CONST char *name, RegisteredInterp *riPtr)
* None.
*
* ----------------------------------------------------------------------
- */
+ */
static int
-Send(LPDISPATCH pdispInterp, /* pointer to the remote interp's COM object */
- Tcl_Interp *interp, /* the local interpreter */
- int async, /* flag for the calling style */
- ClientData clientData, /* the RegisteredInterp structure for this interp */
- int objc, /* number of arguments to be sent */
- Tcl_Obj *CONST objv[]) /* the arguments to be sent */
+Send(
+ LPDISPATCH pdispInterp, /* Pointer to the remote interp's COM
+ * object. */
+ Tcl_Interp *interp, /* The local interpreter. */
+ int async, /* Flag for the calling style. */
+ ClientData clientData, /* The RegisteredInterp structure for this
+ * interp. */
+ int objc, /* Number of arguments to be sent. */
+ Tcl_Obj *CONST objv[]) /* The arguments to be sent. */
{
VARIANT vCmd, vResult;
DISPPARAMS dp;
@@ -690,8 +745,7 @@ Send(LPDISPATCH pdispInterp, /* pointer to the remote interp's COM object */
dp.rgvarg = &vCmd;
/*
- * Select the method to use based upon the async flag and
- * call the method.
+ * Select the method to use based upon the async flag and call the method.
*/
dispid = async ? TKWINSENDCOM_DISPID_ASYNC : TKWINSENDCOM_DISPID_SEND;
@@ -703,36 +757,36 @@ Send(LPDISPATCH pdispInterp, /* pointer to the remote interp's COM object */
/*
* Convert the result into a string and place in the interps result.
*/
-
+
ehr = VariantChangeType(&vResult, &vResult, 0, VT_BSTR);
if (SUCCEEDED(ehr)) {
- Tcl_SetObjResult(interp, Tcl_NewUnicodeObj(vResult.bstrVal, -1));
+ Tcl_SetObjResult(interp, Tcl_NewUnicodeObj(vResult.bstrVal, -1));
}
/*
* Errors are returned as dispatch exceptions. If an error code was
- * returned then we decode the exception and setup the Tcl
- * error variables.
+ * returned then we decode the exception and setup the Tcl error
+ * variables.
*/
if (hr == DISP_E_EXCEPTION) {
- Tcl_Obj *opError, *opErrorCode, *opErrorInfo;
-
- if (ei.bstrSource != NULL) {
- int len;
- char * szErrorInfo;
-
- opError = Tcl_NewUnicodeObj(ei.bstrSource, -1);
- Tcl_ListObjIndex(interp, opError, 0, &opErrorCode);
- Tcl_SetObjErrorCode(interp, opErrorCode);
-
- Tcl_ListObjIndex(interp, opError, 1, &opErrorInfo);
- szErrorInfo = Tcl_GetStringFromObj(opErrorInfo, &len);
- Tcl_AddObjErrorInfo(interp, szErrorInfo, len);
- }
+ Tcl_Obj *opError, *opErrorCode, *opErrorInfo;
+
+ if (ei.bstrSource != NULL) {
+ int len;
+ char *szErrorInfo;
+
+ opError = Tcl_NewUnicodeObj(ei.bstrSource, -1);
+ Tcl_ListObjIndex(interp, opError, 0, &opErrorCode);
+ Tcl_SetObjErrorCode(interp, opErrorCode);
+
+ Tcl_ListObjIndex(interp, opError, 1, &opErrorInfo);
+ szErrorInfo = Tcl_GetStringFromObj(opErrorInfo, &len);
+ Tcl_AddObjErrorInfo(interp, szErrorInfo, len);
+ }
}
- /*
+ /*
* Clean up any COM allocated resources.
*/
@@ -749,8 +803,7 @@ Send(LPDISPATCH pdispInterp, /* pointer to the remote interp's COM object */
*
* Win32ErrorObj --
*
- * Returns a string object containing text from a COM or
- * Win32 error code
+ * Returns a string object containing text from a COM or Win32 error code
*
* Results:
* A Tcl_Obj containing the Win32 error message.
@@ -762,7 +815,8 @@ Send(LPDISPATCH pdispInterp, /* pointer to the remote interp's COM object */
*/
static Tcl_Obj*
-Win32ErrorObj(HRESULT hrError)
+Win32ErrorObj(
+ HRESULT hrError)
{
LPTSTR lpBuffer = NULL, p = NULL;
TCHAR sBuffer[30];
@@ -778,7 +832,7 @@ Win32ErrorObj(HRESULT hrError)
}
if ((p = _tcsrchr(lpBuffer, _T('\r'))) != NULL) {
- *p = _T('\0');
+ *p = _T('\0');
}
#ifdef _UNICODE
@@ -788,7 +842,7 @@ Win32ErrorObj(HRESULT hrError)
#endif
if (lpBuffer != sBuffer) {
- LocalFree((HLOCAL)lpBuffer);
+ LocalFree((HLOCAL)lpBuffer);
}
return errPtr;
@@ -800,8 +854,8 @@ Win32ErrorObj(HRESULT hrError)
* SetErrorInfo --
*
* Convert the error information from a Tcl interpreter into a COM
- * exception structure. This information is then registered with the
- * COM thread exception object so that it can be used for rich error
+ * exception structure. This information is then registered with the COM
+ * thread exception object so that it can be used for rich error
* reporting by COM clients.
*
* Results:
@@ -814,43 +868,47 @@ Win32ErrorObj(HRESULT hrError)
*/
void
-SetExcepInfo(Tcl_Interp* interp, EXCEPINFO *pExcepInfo)
+SetExcepInfo(
+ Tcl_Interp* interp,
+ EXCEPINFO *pExcepInfo)
{
if (pExcepInfo) {
- Tcl_Obj *opError, *opErrorInfo, *opErrorCode;
- ICreateErrorInfo *pCEI;
- IErrorInfo *pEI;
- HRESULT hr;
+ Tcl_Obj *opError, *opErrorInfo, *opErrorCode;
+ ICreateErrorInfo *pCEI;
+ IErrorInfo *pEI;
+ HRESULT hr;
- opError = Tcl_GetObjResult(interp);
- opErrorInfo = Tcl_GetVar2Ex(interp, "errorInfo", NULL, TCL_GLOBAL_ONLY);
- opErrorCode = Tcl_GetVar2Ex(interp, "errorCode", NULL, TCL_GLOBAL_ONLY);
+ opError = Tcl_GetObjResult(interp);
+ opErrorInfo = Tcl_GetVar2Ex(interp, "errorInfo",NULL, TCL_GLOBAL_ONLY);
+ opErrorCode = Tcl_GetVar2Ex(interp, "errorCode",NULL, TCL_GLOBAL_ONLY);
if (Tcl_IsShared(opErrorCode)) {
Tcl_Obj *ec = Tcl_DuplicateObj(opErrorCode);
+
Tcl_IncrRefCount(ec);
Tcl_DecrRefCount(opErrorCode);
opErrorCode = ec;
}
- Tcl_ListObjAppendElement(interp, opErrorCode, opErrorInfo);
-
- pExcepInfo->bstrDescription = SysAllocString(Tcl_GetUnicode(opError));
- pExcepInfo->bstrSource = SysAllocString(Tcl_GetUnicode(opErrorCode));
- pExcepInfo->scode = E_FAIL;
-
- hr = CreateErrorInfo(&pCEI);
- if (SUCCEEDED(hr)) {
- hr = pCEI->lpVtbl->SetGUID(pCEI, &IID_IDispatch);
- hr = pCEI->lpVtbl->SetDescription(pCEI, pExcepInfo->bstrDescription);
- hr = pCEI->lpVtbl->SetSource(pCEI, pExcepInfo->bstrSource);
- hr = pCEI->lpVtbl->QueryInterface(pCEI, &IID_IErrorInfo,
- (void**)&pEI);
- if (SUCCEEDED(hr)) {
- SetErrorInfo(0, pEI);
- pEI->lpVtbl->Release(pEI);
- }
- pCEI->lpVtbl->Release(pCEI);
- }
+ Tcl_ListObjAppendElement(interp, opErrorCode, opErrorInfo);
+
+ pExcepInfo->bstrDescription = SysAllocString(Tcl_GetUnicode(opError));
+ pExcepInfo->bstrSource = SysAllocString(Tcl_GetUnicode(opErrorCode));
+ pExcepInfo->scode = E_FAIL;
+
+ hr = CreateErrorInfo(&pCEI);
+ if (SUCCEEDED(hr)) {
+ hr = pCEI->lpVtbl->SetGUID(pCEI, &IID_IDispatch);
+ hr = pCEI->lpVtbl->SetDescription(pCEI,
+ pExcepInfo->bstrDescription);
+ hr = pCEI->lpVtbl->SetSource(pCEI, pExcepInfo->bstrSource);
+ hr = pCEI->lpVtbl->QueryInterface(pCEI, &IID_IErrorInfo,
+ (void**) &pEI);
+ if (SUCCEEDED(hr)) {
+ SetErrorInfo(0, pEI);
+ pEI->lpVtbl->Release(pEI);
+ }
+ pCEI->lpVtbl->Release(pCEI);
+ }
}
}
@@ -859,8 +917,8 @@ SetExcepInfo(Tcl_Interp* interp, EXCEPINFO *pExcepInfo)
*
* TkWinSend_QueueCommand --
*
- * Queue a script for asynchronous evaluation. This is called from
- * the COM objects Async method.
+ * Queue a script for asynchronous evaluation. This is called from the
+ * COM objects Async method.
*
* Results:
* None.
@@ -871,8 +929,10 @@ SetExcepInfo(Tcl_Interp* interp, EXCEPINFO *pExcepInfo)
* ----------------------------------------------------------------------
*/
-int
-TkWinSend_QueueCommand(Tcl_Interp *interp, Tcl_Obj *cmdPtr)
+int
+TkWinSend_QueueCommand(
+ Tcl_Interp *interp,
+ Tcl_Obj *cmdPtr)
{
SendEvent *evPtr;
@@ -885,10 +945,10 @@ TkWinSend_QueueCommand(Tcl_Interp *interp, Tcl_Obj *cmdPtr)
Tcl_Preserve(evPtr->interp);
if (Tcl_IsShared(cmdPtr)) {
- evPtr->cmdPtr = Tcl_DuplicateObj(cmdPtr);
+ evPtr->cmdPtr = Tcl_DuplicateObj(cmdPtr);
} else {
- evPtr->cmdPtr = cmdPtr;
- Tcl_IncrRefCount(evPtr->cmdPtr);
+ evPtr->cmdPtr = cmdPtr;
+ Tcl_IncrRefCount(evPtr->cmdPtr);
}
Tcl_QueueEvent((Tcl_Event *)evPtr, TCL_QUEUE_TAIL);
@@ -901,12 +961,12 @@ TkWinSend_QueueCommand(Tcl_Interp *interp, Tcl_Obj *cmdPtr)
*
* SendEventProc --
*
- * Handle a request for an asynchronous send. Nothing is returned
- * to the caller so the result is discarded.
+ * Handle a request for an asynchronous send. Nothing is returned to the
+ * caller so the result is discarded.
*
* Results:
- * Returns 1 if the event was handled or 0 to indicate it has
- * been deferred.
+ * Returns 1 if the event was handled or 0 to indicate it has been
+ * deferred.
*
* Side effects:
* The target interpreter's result will be modified.
@@ -915,16 +975,18 @@ TkWinSend_QueueCommand(Tcl_Interp *interp, Tcl_Obj *cmdPtr)
*/
static int
-SendEventProc(Tcl_Event *eventPtr, int flags)
+SendEventProc(
+ Tcl_Event *eventPtr,
+ int flags)
{
int result = TCL_OK;
SendEvent *evPtr = (SendEvent *)eventPtr;
TRACE("SendEventProc\n");
-
+
result = Tcl_EvalObjEx(evPtr->interp, evPtr->cmdPtr,
- TCL_EVAL_DIRECT | TCL_EVAL_GLOBAL);
-
+ TCL_EVAL_DIRECT | TCL_EVAL_GLOBAL);
+
Tcl_DecrRefCount(evPtr->cmdPtr);
Tcl_Release(evPtr->interp);
@@ -936,9 +998,9 @@ SendEventProc(Tcl_Event *eventPtr, int flags)
*
* SendTrace --
*
- * Provide trace information to the Windows debug stream.
- * To use this - use the TRACE macro, which compiles to nothing
- * when DEBUG is not defined.
+ * Provide trace information to the Windows debug stream. To use this -
+ * use the TRACE macro, which compiles to nothing when DEBUG is not
+ * defined.
*
* Results:
* None.
@@ -950,13 +1012,22 @@ SendEventProc(Tcl_Event *eventPtr, int flags)
*/
static void
-SendTrace(const char *format, ...)
+SendTrace(
+ const char *format, ...)
{
- va_list args;
+ va_list args;
static char buffer[1024];
- va_start (args, format);
+
+ va_start(args, format);
_vsnprintf(buffer, 1023, format, args);
OutputDebugString(buffer);
va_end(args);
}
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/win/tkWinTest.c b/win/tkWinTest.c
index ce7694d..600f490 100644
--- a/win/tkWinTest.c
+++ b/win/tkWinTest.c
@@ -1,41 +1,40 @@
-/*
+/*
* tkWinTest.c --
*
- * Contains commands for platform specific tests for
- * the Windows platform.
+ * Contains commands for platform specific tests for the Windows
+ * platform.
*
* Copyright (c) 1997 Sun Microsystems, Inc.
* Copyright (c) 2000 by Scriptics Corporation.
* Copyright (c) 2001 by ActiveState Corporation.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinTest.c,v 1.8 2005/11/27 02:36:16 das Exp $
+ * RCS: @(#) $Id: tkWinTest.c,v 1.9 2005/12/02 00:19:04 dkf Exp $
*/
#include "tkWinInt.h"
HWND tkWinCurrentDialog;
-
+
/*
- * Forward declarations of procedures defined later in this file:
+ * Forward declarations of functions defined later in this file:
*/
static int TestclipboardObjCmd(ClientData clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *CONST objv[]);
-static int TestwineventCmd(ClientData clientData,
+static int TestwineventCmd(ClientData clientData,
Tcl_Interp *interp, int argc, CONST char **argv);
-
/*
*----------------------------------------------------------------------
*
* TkplatformtestInit --
*
- * Defines commands that test platform specific functionality for
- * Unix platforms.
+ * Defines commands that test platform specific functionality for Windows
+ * platforms.
*
* Results:
* A standard Tcl result.
@@ -53,11 +52,11 @@ TkplatformtestInit(
/*
* Add commands for platform specific tests on MacOS here.
*/
-
+
Tcl_CreateObjCommand(interp, "testclipboard", TestclipboardObjCmd,
- (ClientData) Tk_MainWindow(interp), (Tcl_CmdDeleteProc *) NULL);
+ (ClientData) Tk_MainWindow(interp), NULL);
Tcl_CreateCommand(interp, "testwinevent", TestwineventCmd,
- (ClientData) Tk_MainWindow(interp), (Tcl_CmdDeleteProc *) NULL);
+ (ClientData) Tk_MainWindow(interp), NULL);
return TCL_OK;
}
@@ -67,8 +66,8 @@ TkplatformtestInit(
*
* AppendSystemError --
*
- * This routine formats a Windows system error message and places
- * it into the interpreter result. Originally from tclWinReg.c.
+ * This routine formats a Windows system error message and places it into
+ * the interpreter result. Originally from tclWinReg.c.
*
* Results:
* None.
@@ -129,6 +128,7 @@ AppendSystemError(
/*
* Trim the trailing CR/LF from the system message.
*/
+
if (msg[length-1] == '\n') {
msg[--length] = 0;
}
@@ -151,8 +151,8 @@ AppendSystemError(
*
* TestclipboardObjCmd --
*
- * This procedure implements the testclipboard command. It provides
- * a way to determine the actual contents of the Windows clipboard.
+ * This function implements the testclipboard command. It provides a way
+ * to determine the actual contents of the Windows clipboard.
*
* Results:
* A standard Tcl result.
@@ -164,11 +164,11 @@ AppendSystemError(
*/
static int
-TestclipboardObjCmd(clientData, interp, objc, objv)
- ClientData clientData; /* Main window for application. */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument values. */
+TestclipboardObjCmd(
+ ClientData clientData, /* Main window for application. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *CONST objv[]) /* Argument values. */
{
TkWindow *winPtr = (TkWindow *) clientData;
HGLOBAL handle;
@@ -176,29 +176,29 @@ TestclipboardObjCmd(clientData, interp, objc, objv)
int code = TCL_OK;
if (objc != 1) {
- Tcl_WrongNumArgs(interp, 1, objv, (char *) NULL);
+ Tcl_WrongNumArgs(interp, 1, objv, NULL);
return TCL_ERROR;
}
if (OpenClipboard(NULL)) {
/*
- * We could consider using CF_UNICODETEXT on NT, but then we
- * would have to convert it from External. Instead we'll just
- * take this and do "bytestring" at the Tcl level for Unicode
- * inclusive text
+ * We could consider using CF_UNICODETEXT on NT, but then we would
+ * have to convert it from External. Instead we'll just take this and
+ * do "bytestring" at the Tcl level for Unicode inclusive text
*/
+
handle = GetClipboardData(CF_TEXT);
if (handle != NULL) {
data = GlobalLock(handle);
- Tcl_AppendResult(interp, data, (char *) NULL);
+ Tcl_AppendResult(interp, data, NULL);
GlobalUnlock(handle);
} else {
- Tcl_AppendResult(interp, "null clipboard handle", (char *) NULL);
+ Tcl_AppendResult(interp, "null clipboard handle", NULL);
code = TCL_ERROR;
}
CloseClipboard();
return code;
} else {
- Tcl_AppendResult(interp, "couldn't open clipboard: ", (char *) NULL);
+ Tcl_AppendResult(interp, "couldn't open clipboard: ", NULL);
AppendSystemError(interp, GetLastError());
return TCL_ERROR;
}
@@ -210,8 +210,8 @@ TestclipboardObjCmd(clientData, interp, objc, objv)
*
* TestwineventCmd --
*
- * This procedure implements the testwinevent command. It provides
- * a way to send messages to windows dialogs.
+ * This function implements the testwinevent command. It provides a way
+ * to send messages to windows dialogs.
*
* Results:
* A standard Tcl result.
@@ -223,11 +223,11 @@ TestclipboardObjCmd(clientData, interp, objc, objv)
*/
static int
-TestwineventCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window for application. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- CONST char **argv; /* Argument strings. */
+TestwineventCmd(
+ ClientData clientData, /* Main window for application. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int argc, /* Number of arguments. */
+ CONST char **argv) /* Argument strings. */
{
HWND hwnd = 0;
int id;
@@ -262,9 +262,9 @@ TestwineventCmd(clientData, interp, argc, argv)
TkpScanWindowId(interp, argv[1], &id);
if (
#ifdef _WIN64
- (sscanf(string, "0x%p", &number) != 1) &&
-#endif
- Tcl_GetInt(interp, string, (int *)&number) != TCL_OK) {
+ (sscanf(string, "0x%p", &number) != 1) &&
+#endif /* _WIN64 */
+ Tcl_GetInt(interp, string, (int *)&number) != TCL_OK) {
return TCL_ERROR;
}
#endif
@@ -311,35 +311,40 @@ TestwineventCmd(clientData, interp, argc, argv)
}
switch (message) {
- case WM_GETTEXT: {
- Tcl_DString ds;
- char buf[256];
+ case WM_GETTEXT: {
+ Tcl_DString ds;
+ char buf[256];
- GetDlgItemText(hwnd, id, buf, 256);
- Tcl_ExternalToUtfDString(NULL, buf, -1, &ds);
- Tcl_AppendResult(interp, Tcl_DStringValue(&ds), NULL);
- Tcl_DStringFree(&ds);
- break;
- }
- case WM_SETTEXT: {
- Tcl_DString ds;
+ GetDlgItemText(hwnd, id, buf, 256);
+ Tcl_ExternalToUtfDString(NULL, buf, -1, &ds);
+ Tcl_AppendResult(interp, Tcl_DStringValue(&ds), NULL);
+ Tcl_DStringFree(&ds);
+ break;
+ }
+ case WM_SETTEXT: {
+ Tcl_DString ds;
- Tcl_UtfToExternalDString(NULL, argv[4], -1, &ds);
- SetDlgItemText(hwnd, id, Tcl_DStringValue(&ds));
- Tcl_DStringFree(&ds);
- break;
- }
- default: {
- char buf[TCL_INTEGER_SPACE];
-
- sprintf(buf, "%d",
- SendDlgItemMessage(hwnd, id, message, wParam, lParam));
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
- break;
- }
+ Tcl_UtfToExternalDString(NULL, argv[4], -1, &ds);
+ SetDlgItemText(hwnd, id, Tcl_DStringValue(&ds));
+ Tcl_DStringFree(&ds);
+ break;
+ }
+ default: {
+ char buf[TCL_INTEGER_SPACE];
+
+ sprintf(buf, "%d",
+ SendDlgItemMessage(hwnd, id, message, wParam, lParam));
+ Tcl_SetResult(interp, buf, TCL_VOLATILE);
+ break;
+ }
}
return TCL_OK;
}
-
-
-
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/win/tkWinWindow.c b/win/tkWinWindow.c
index da871c7..dccfd92 100644
--- a/win/tkWinWindow.c
+++ b/win/tkWinWindow.c
@@ -1,22 +1,22 @@
-/*
+/*
* tkWinWindow.c --
*
- * Xlib emulation routines for Windows related to creating,
- * displaying and destroying windows.
+ * Xlib emulation routines for Windows related to creating, displaying
+ * and destroying windows.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinWindow.c,v 1.10 2002/06/14 22:25:12 jenglish Exp $
+ * RCS: @(#) $Id: tkWinWindow.c,v 1.11 2005/12/02 00:19:04 dkf Exp $
*/
#include "tkWinInt.h"
typedef struct ThreadSpecificData {
int initialized; /* 0 means table below needs initializing. */
- Tcl_HashTable windowTable; /* The windowTable maps from HWND to
+ Tcl_HashTable windowTable; /* The windowTable maps from HWND to
* Tk_Window handles. */
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
@@ -25,36 +25,35 @@ static Tcl_ThreadDataKey dataKey;
* Forward declarations for procedures defined in this file:
*/
-static void NotifyVisibility _ANSI_ARGS_((XEvent *eventPtr,
- TkWindow *winPtr));
+static void NotifyVisibility(XEvent *eventPtr, TkWindow *winPtr);
/*
*----------------------------------------------------------------------
*
* Tk_AttachHWND --
*
- * This function binds an HWND and a reflection procedure to
- * the specified Tk_Window.
+ * This function binds an HWND and a reflection procedure to the
+ * specified Tk_Window.
*
* Results:
* Returns an X Window that encapsulates the HWND.
*
* Side effects:
- * May allocate a new X Window. Also enters the HWND into the
- * global window table.
+ * May allocate a new X Window. Also enters the HWND into the global
+ * window table.
*
*----------------------------------------------------------------------
*/
Window
-Tk_AttachHWND(tkwin, hwnd)
- Tk_Window tkwin;
- HWND hwnd;
+Tk_AttachHWND(
+ Tk_Window tkwin,
+ HWND hwnd)
{
int new;
Tcl_HashEntry *entryPtr;
TkWinDrawable *twdPtr = (TkWinDrawable *) Tk_WindowId(tkwin);
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!tsdPtr->initialized) {
@@ -63,12 +62,12 @@ Tk_AttachHWND(tkwin, hwnd)
}
/*
- * Allocate a new drawable if necessary. Otherwise, remove the
- * previous HWND from from the window table.
+ * Allocate a new drawable if necessary. Otherwise, remove the previous
+ * HWND from from the window table.
*/
if (twdPtr == NULL) {
- twdPtr = (TkWinDrawable*) ckalloc(sizeof(TkWinDrawable));
+ twdPtr = (TkWinDrawable *) ckalloc(sizeof(TkWinDrawable));
twdPtr->type = TWD_WINDOW;
twdPtr->window.winPtr = (TkWindow *) tkwin;
} else if (twdPtr->window.handle != NULL) {
@@ -93,8 +92,8 @@ Tk_AttachHWND(tkwin, hwnd)
*
* Tk_HWNDToWindow --
*
- * This function retrieves a Tk_Window from the window table
- * given an HWND.
+ * This function retrieves a Tk_Window from the window table given an
+ * HWND.
*
* Results:
* Returns the matching Tk_Window.
@@ -106,11 +105,11 @@ Tk_AttachHWND(tkwin, hwnd)
*/
Tk_Window
-Tk_HWNDToWindow(hwnd)
- HWND hwnd;
+Tk_HWNDToWindow(
+ HWND hwnd)
{
Tcl_HashEntry *entryPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!tsdPtr->initialized) {
@@ -141,8 +140,8 @@ Tk_HWNDToWindow(hwnd)
*/
HWND
-Tk_GetHWND(window)
- Window window;
+Tk_GetHWND(
+ Window window)
{
return ((TkWinDrawable *) window)->window.handle;
}
@@ -152,9 +151,8 @@ Tk_GetHWND(window)
*
* TkpPrintWindowId --
*
- * This routine stores the string representation of the
- * platform dependent window handle for an X Window in the
- * given buffer.
+ * This routine stores the string representation of the platform
+ * dependent window handle for an X Window in the given buffer.
*
* Results:
* Returns the result in the specified buffer.
@@ -166,16 +164,18 @@ Tk_GetHWND(window)
*/
void
-TkpPrintWindowId(buf, window)
- char *buf; /* Pointer to string large enough to hold
- * the hex representation of a pointer. */
- Window window; /* Window to be printed into buffer. */
+TkpPrintWindowId(
+ char *buf, /* Pointer to string large enough to hold the
+ * hex representation of a pointer. */
+ Window window) /* Window to be printed into buffer. */
{
HWND hwnd = (window) ? Tk_GetHWND(window) : 0;
+
/*
- * Use pointer representation, because Win64 is P64 (*not* LP64).
- * Windows doesn't print the 0x for %p, so we do it.
+ * Use pointer representation, because Win64 is P64 (*not* LP64). Windows
+ * doesn't print the 0x for %p, so we do it.
*/
+
sprintf(buf, "0x%p", hwnd);
}
@@ -184,16 +184,15 @@ TkpPrintWindowId(buf, window)
*
* TkpScanWindowId --
*
- * Given a string which represents the platform dependent window
- * handle, produce the X Window id for the window.
+ * Given a string which represents the platform dependent window handle,
+ * produce the X Window id for the window.
*
* Results:
- * The return value is normally TCL_OK; in this case *idPtr
- * will be set to the X Window id equivalent to string. If
- * string is improperly formed then TCL_ERROR is returned and
- * an error message will be left in the interp's result. If the
- * number does not correspond to a Tk Window, then *idPtr will
- * be set to None.
+ * The return value is normally TCL_OK; in this case *idPtr will be set
+ * to the X Window id equivalent to string. If string is improperly
+ * formed then TCL_ERROR is returned and an error message will be left in
+ * the interp's result. If the number does not correspond to a Tk Window,
+ * then *idPtr will be set to None.
*
* Side effects:
* None.
@@ -202,28 +201,29 @@ TkpPrintWindowId(buf, window)
*/
int
-TkpScanWindowId(interp, string, idPtr)
- Tcl_Interp *interp; /* Interpreter to use for error reporting. */
- CONST char *string; /* String containing a (possibly signed)
+TkpScanWindowId(
+ Tcl_Interp *interp, /* Interpreter to use for error reporting. */
+ CONST char *string, /* String containing a (possibly signed)
* integer in a form acceptable to strtol. */
- Window *idPtr; /* Place to store converted result. */
+ Window *idPtr) /* Place to store converted result. */
{
Tk_Window tkwin;
Window number;
/*
- * We want sscanf for the 64-bit check, but if that doesn't work,
- * then Tcl_GetInt manages the error correctly.
+ * We want sscanf for the 64-bit check, but if that doesn't work, then
+ * Tcl_GetInt manages the error correctly.
*/
+
if (
#ifdef _WIN64
(sscanf(string, "0x%p", &number) != 1) &&
#endif
- Tcl_GetInt(interp, string, (int *)&number) != TCL_OK) {
+ Tcl_GetInt(interp, string, (int *) &number) != TCL_OK) {
return TCL_ERROR;
}
- tkwin = Tk_HWNDToWindow((HWND)number);
+ tkwin = Tk_HWNDToWindow((HWND) number);
if (tkwin) {
*idPtr = Tk_WindowId(tkwin);
} else {
@@ -237,8 +237,8 @@ TkpScanWindowId(interp, string, idPtr)
*
* TkpMakeWindow --
*
- * Creates a Windows window object based on the current attributes
- * of the specified TkWindow.
+ * Creates a Windows window object based on the current attributes of the
+ * specified TkWindow.
*
* Results:
* Returns a pointer to a new TkWinDrawable cast to a Window.
@@ -250,14 +250,14 @@ TkpScanWindowId(interp, string, idPtr)
*/
Window
-TkpMakeWindow(winPtr, parent)
- TkWindow *winPtr;
- Window parent;
+TkpMakeWindow(
+ TkWindow *winPtr,
+ Window parent)
{
HWND parentWin;
int style;
HWND hwnd;
-
+
if (parent != None) {
parentWin = Tk_GetHWND(parent);
style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
@@ -267,15 +267,15 @@ TkpMakeWindow(winPtr, parent)
}
/*
- * Create the window, then ensure that it is at the top of the
- * stacking order.
+ * Create the window, then ensure that it is at the top of the stacking
+ * order.
*/
hwnd = CreateWindowEx(WS_EX_NOPARENTNOTIFY, TK_WIN_CHILD_CLASS_NAME, NULL,
style, Tk_X(winPtr), Tk_Y(winPtr), Tk_Width(winPtr),
Tk_Height(winPtr), parentWin, NULL, Tk_GetHINSTANCE(), NULL);
SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0,
- SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
+ SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
return Tk_AttachHWND((Tk_Window)winPtr, hwnd);
}
@@ -290,29 +290,29 @@ TkpMakeWindow(winPtr, parent)
* None.
*
* Side effects:
- * Sends the WM_DESTROY message to the window and then destroys
- * it the Win32 resources associated with the window.
+ * Sends the WM_DESTROY message to the window and then destroys it the
+ * Win32 resources associated with the window.
*
*----------------------------------------------------------------------
*/
void
-XDestroyWindow(display, w)
- Display* display;
- Window w;
+XDestroyWindow(
+ Display *display,
+ Window w)
{
Tcl_HashEntry *entryPtr;
TkWinDrawable *twdPtr = (TkWinDrawable *)w;
TkWindow *winPtr = TkWinGetWinPtr(w);
HWND hwnd = Tk_GetHWND(w);
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
display->request++;
/*
- * Remove references to the window in the pointer module then
- * release the drawable.
+ * Remove references to the window in the pointer module then release the
+ * drawable.
*/
TkPointerDeadWindow(winPtr);
@@ -325,8 +325,8 @@ XDestroyWindow(display, w)
ckfree((char *)twdPtr);
/*
- * Don't bother destroying the window if we are going to destroy
- * the parent later.
+ * Don't bother destroying the window if we are going to destroy the
+ * parent later.
*/
if (hwnd != NULL && !(winPtr->flags & TK_DONT_DESTROY_WINDOW)) {
@@ -345,16 +345,15 @@ XDestroyWindow(display, w)
* None
*
* Side effects:
- * Causes the window state to change, and generates a MapNotify
- * event.
+ * Causes the window state to change, and generates a MapNotify event.
*
*----------------------------------------------------------------------
*/
void
-XMapWindow(display, w)
- Display* display;
- Window w;
+XMapWindow(
+ Display *display,
+ Window w)
{
XEvent event;
TkWindow *parentPtr;
@@ -366,9 +365,9 @@ XMapWindow(display, w)
winPtr->flags |= TK_MAPPED;
/*
- * Check to see if this window is visible now. If all of the parent
- * windows up to the first toplevel are mapped, then this window and
- * its mapped children have just become visible.
+ * Check to see if this window is visible now. If all of the parent
+ * windows up to the first toplevel are mapped, then this window and its
+ * mapped children have just become visible.
*/
if (!(winPtr->flags & TK_TOP_HIERARCHY)) {
@@ -391,7 +390,7 @@ XMapWindow(display, w)
event.xmap.override_redirect = winPtr->atts.override_redirect;
Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
}
-
+
/*
* Generate VisibilityNotify events for this window and its mapped
* children.
@@ -412,10 +411,10 @@ XMapWindow(display, w)
* NotifyVisibility --
*
* This function recursively notifies the mapped children of the
- * specified window of a change in visibility. Note that we don't
- * properly report the visibility state, since Windows does not
- * provide that info. The eventPtr argument must point to an event
- * that has been completely initialized except for the window slot.
+ * specified window of a change in visibility. Note that we don't
+ * properly report the visibility state, since Windows does not provide
+ * that info. The eventPtr argument must point to an event that has been
+ * completely initialized except for the window slot.
*
* Results:
* None.
@@ -427,15 +426,15 @@ XMapWindow(display, w)
*/
static void
-NotifyVisibility(eventPtr, winPtr)
- XEvent *eventPtr; /* Initialized VisibilityNotify event. */
- TkWindow *winPtr; /* Window to notify. */
+NotifyVisibility(
+ XEvent *eventPtr, /* Initialized VisibilityNotify event. */
+ TkWindow *winPtr) /* Window to notify. */
{
if (winPtr->atts.event_mask & VisibilityChangeMask) {
eventPtr->xvisibility.window = winPtr->window;
Tk_QueueWindowEvent(eventPtr, TCL_QUEUE_TAIL);
}
- for (winPtr = winPtr->childList; winPtr != NULL;
+ for (winPtr = winPtr->childList; winPtr != NULL;
winPtr = winPtr->nextPtr) {
if (winPtr->flags & TK_MAPPED) {
NotifyVisibility(eventPtr, winPtr);
@@ -454,16 +453,15 @@ NotifyVisibility(eventPtr, winPtr)
* None
*
* Side effects:
- * Causes the window state to change, and generates an UnmapNotify
- * event.
+ * Causes the window state to change, and generates an UnmapNotify event.
*
*----------------------------------------------------------------------
*/
void
-XUnmapWindow(display, w)
- Display* display;
- Window w;
+XUnmapWindow(
+ Display *display,
+ Window w)
{
XEvent event;
TkWindow *winPtr = TkWinGetWinPtr(w);
@@ -471,8 +469,8 @@ XUnmapWindow(display, w)
display->request++;
/*
- * Bug fix: Don't short circuit this routine based on TK_MAPPED because
- * it will be cleared before XUnmapWindow is called.
+ * Bug fix: Don't short circuit this routine based on TK_MAPPED because it
+ * will be cleared before XUnmapWindow is called.
*/
ShowWindow(Tk_GetHWND(w), SW_HIDE);
@@ -507,13 +505,11 @@ XUnmapWindow(display, w)
*/
void
-XMoveResizeWindow(display, w, x, y, width, height)
- Display* display;
- Window w;
- int x; /* Position relative to parent. */
- int y;
- unsigned int width;
- unsigned int height;
+XMoveResizeWindow(
+ Display *display,
+ Window w,
+ int x, int y, /* Position relative to parent. */
+ unsigned int width, unsigned int height)
{
display->request++;
MoveWindow(Tk_GetHWND(w), x, y, width, height, TRUE);
@@ -536,11 +532,10 @@ XMoveResizeWindow(display, w, x, y, width, height)
*/
void
-XMoveWindow(display, w, x, y)
- Display* display;
- Window w;
- int x;
- int y;
+XMoveWindow(
+ Display *display,
+ Window w,
+ int x, int y)
{
TkWindow *winPtr = TkWinGetWinPtr(w);
@@ -567,11 +562,10 @@ XMoveWindow(display, w, x, y)
*/
void
-XResizeWindow(display, w, width, height)
- Display* display;
- Window w;
- unsigned int width;
- unsigned int height;
+XResizeWindow(
+ Display *display,
+ Window w,
+ unsigned int width, unsigned int height)
{
TkWindow *winPtr = TkWinGetWinPtr(w);
@@ -598,15 +592,14 @@ XResizeWindow(display, w, width, height)
*/
void
-XRaiseWindow(display, w)
- Display* display;
- Window w;
+XRaiseWindow(
+ Display *display,
+ Window w)
{
HWND window = Tk_GetHWND(w);
display->request++;
- SetWindowPos(window, HWND_TOPMOST, 0, 0, 0, 0,
- SWP_NOMOVE | SWP_NOSIZE);
+ SetWindowPos(window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
/*
@@ -621,19 +614,19 @@ XRaiseWindow(display, w)
* None.
*
* Side effects:
- * Changes the attributes of the specified window. Note that we
- * ignore the passed in values and use the values stored in the
- * TkWindow data structure.
+ * Changes the attributes of the specified window. Note that we ignore
+ * the passed in values and use the values stored in the TkWindow data
+ * structure.
*
*----------------------------------------------------------------------
*/
void
-XConfigureWindow(display, w, value_mask, values)
- Display* display;
- Window w;
- unsigned int value_mask;
- XWindowChanges* values;
+XConfigureWindow(
+ Display *display,
+ Window w,
+ unsigned int value_mask,
+ XWindowChanges *values)
{
TkWindow *winPtr = TkWinGetWinPtr(w);
HWND hwnd = Tk_GetHWND(w);
@@ -681,9 +674,9 @@ XConfigureWindow(display, w, value_mask, values)
*/
void
-XClearWindow(display, w)
- Display* display;
- Window w;
+XClearWindow(
+ Display *display,
+ Window w)
{
RECT rc;
HBRUSH brush;
@@ -715,9 +708,9 @@ XClearWindow(display, w)
*
* XChangeWindowAttributes --
*
- * This function is called when the attributes on a window are
- * updated. Since Tk maintains all of the window state, the only
- * relevant value is the cursor.
+ * This function is called when the attributes on a window are updated.
+ * Since Tk maintains all of the window state, the only relevant value is
+ * the cursor.
*
* Results:
* None.
@@ -729,11 +722,11 @@ XClearWindow(display, w)
*/
void
-XChangeWindowAttributes(display, w, valueMask, attributes)
- Display* display;
- Window w;
- unsigned long valueMask;
- XSetWindowAttributes* attributes;
+XChangeWindowAttributes(
+ Display *display,
+ Window w,
+ unsigned long valueMask,
+ XSetWindowAttributes* attributes)
{
if (valueMask & CWCursor) {
XDefineCursor(display, w, attributes->cursor);
@@ -745,8 +738,8 @@ XChangeWindowAttributes(display, w, valueMask, attributes)
*
* TkWinSetWindowPos --
*
- * Adjust the stacking order of a window relative to a second
- * window (or NULL).
+ * Adjust the stacking order of a window relative to a second window (or
+ * NULL).
*
* Results:
* None.
@@ -758,16 +751,16 @@ XChangeWindowAttributes(display, w, valueMask, attributes)
*/
void
-TkWinSetWindowPos(hwnd, siblingHwnd, pos)
- HWND hwnd; /* Window to restack. */
- HWND siblingHwnd; /* Sibling window. */
- int pos; /* One of Above or Below. */
+TkWinSetWindowPos(
+ HWND hwnd, /* Window to restack. */
+ HWND siblingHwnd, /* Sibling window. */
+ int pos) /* One of Above or Below. */
{
HWND temp;
/*
- * Since Windows does not support Above mode, we place the
- * specified window below the sibling and then swap them.
+ * Since Windows does not support Above mode, we place the specified
+ * window below the sibling and then swap them.
*/
if (siblingHwnd) {
@@ -792,8 +785,8 @@ TkWinSetWindowPos(hwnd, siblingHwnd, pos)
* TkpWindowWasRecentlyDeleted --
*
* Determines whether we know if the window given as argument was
- * recently deleted. Called by the generic code error handler to
- * handle BadWindow events.
+ * recently deleted. Called by the generic code error handler to handle
+ * BadWindow events.
*
* Results:
* Always 0. We do not keep this information on Windows.
@@ -805,9 +798,17 @@ TkWinSetWindowPos(hwnd, siblingHwnd, pos)
*/
int
-TkpWindowWasRecentlyDeleted(win, dispPtr)
- Window win;
- TkDisplay *dispPtr;
+TkpWindowWasRecentlyDeleted(
+ Window win,
+ TkDisplay *dispPtr)
{
return 0;
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/win/tkWinWm.c b/win/tkWinWm.c
index 3fbad34..2873794 100644
--- a/win/tkWinWm.c
+++ b/win/tkWinWm.c
@@ -2,17 +2,17 @@
* tkWinWm.c --
*
* This module takes care of the interactions between a Tk-based
- * application and the window manager. Among other things, it
- * implements the "wm" command and passes geometry information
- * to the window manager.
+ * application and the window manager. Among other things, it implements
+ * the "wm" command and passes geometry information to the window
+ * manager.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
* Copyright (c) 1998-2000 by Scriptics Corporation.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinWm.c,v 1.103 2005/12/01 07:34:20 hobbs Exp $
+ * RCS: @(#) $Id: tkWinWm.c,v 1.104 2005/12/02 00:19:04 dkf Exp $
*/
#include "tkWinInt.h"
@@ -21,6 +21,7 @@
/*
* These next two defines are only valid on Win2K/XP+.
*/
+
#ifndef WS_EX_LAYERED
#define WS_EX_LAYERED 0x00080000
#endif
@@ -29,9 +30,8 @@
#endif
/*
- * Event structure for synthetic activation events. These events are
- * placed on the event queue whenever a toplevel gets a WM_MOUSEACTIVATE
- * message.
+ * Event structure for synthetic activation events. These events are placed on
+ * the event queue whenever a toplevel gets a WM_MOUSEACTIVATE message.
*/
typedef struct ActivateEvent {
@@ -40,25 +40,23 @@ typedef struct ActivateEvent {
} ActivateEvent;
/*
- * A data structure of the following type holds information for
- * each window manager protocol (such as WM_DELETE_WINDOW) for
- * which a handler (i.e. a Tcl command) has been defined for a
- * particular top-level window.
+ * A data structure of the following type holds information for each window
+ * manager protocol (such as WM_DELETE_WINDOW) for which a handler (i.e. a Tcl
+ * command) has been defined for a particular top-level window.
*/
typedef struct ProtocolHandler {
Atom protocol; /* Identifies the protocol. */
struct ProtocolHandler *nextPtr;
- /* Next in list of protocol handlers for
- * the same top-level window, or NULL for
- * end of list. */
+ /* Next in list of protocol handlers for the
+ * same top-level window, or NULL for end of
+ * list. */
Tcl_Interp *interp; /* Interpreter in which to invoke command. */
- char command[4]; /* Tcl command to invoke when a client
- * message for this protocol arrives.
- * The actual size of the structure varies
- * to accommodate the needs of the actual
- * command. THIS MUST BE THE LAST FIELD OF
- * THE STRUCTURE. */
+ char command[4]; /* Tcl command to invoke when a client message
+ * for this protocol arrives. The actual size
+ * of the structure varies to accommodate the
+ * needs of the actual command. THIS MUST BE
+ * THE LAST FIELD OF THE STRUCTURE. */
} ProtocolHandler;
#define HANDLER_SIZE(cmdLength) \
@@ -67,81 +65,88 @@ typedef struct ProtocolHandler {
/*
* Helper type passed via lParam to TkWmStackorderToplevelEnumProc
*/
+
typedef struct TkWmStackorderToplevelPair {
Tcl_HashTable *table;
TkWindow **window_ptr;
} TkWmStackorderToplevelPair;
/*
- * This structure represents the contents of a icon, in terms of its
- * image. The HICON is an internal Windows format. Most of these
- * icon-specific-structures originated with the Winico extension.
- * We stripped out unused parts of that code, and integrated the
- * code more naturally with Tcl.
+ * This structure represents the contents of a icon, in terms of its image.
+ * The HICON is an internal Windows format. Most of these
+ * icon-specific-structures originated with the Winico extension. We stripped
+ * out unused parts of that code, and integrated the code more naturally with
+ * Tcl.
*/
+
typedef struct {
- UINT Width, Height, Colors; /* Width, Height and bpp */
- LPBYTE lpBits; /* ptr to DIB bits */
- DWORD dwNumBytes; /* how many bytes? */
- LPBITMAPINFO lpbi; /* ptr to header */
- LPBYTE lpXOR; /* ptr to XOR image bits */
- LPBYTE lpAND; /* ptr to AND image bits */
- HICON hIcon; /* DAS ICON */
+ UINT Width, Height, Colors; /* Width, Height and bpp */
+ LPBYTE lpBits; /* Ptr to DIB bits */
+ DWORD dwNumBytes; /* How many bytes? */
+ LPBITMAPINFO lpbi; /* Ptr to header */
+ LPBYTE lpXOR; /* Ptr to XOR image bits */
+ LPBYTE lpAND; /* Ptr to AND image bits */
+ HICON hIcon; /* DAS ICON */
} ICONIMAGE, *LPICONIMAGE;
+
/*
- * This structure is how we represent a block of the above
- * items. We will reallocate these structures according to
- * how many images they need to contain.
+ * This structure is how we represent a block of the above items. We will
+ * reallocate these structures according to how many images they need to
+ * contain.
*/
+
typedef struct {
- int nNumImages; /* How many images? */
- ICONIMAGE IconImages[1]; /* Image entries */
+ int nNumImages; /* How many images? */
+ ICONIMAGE IconImages[1]; /* Image entries */
} BlockOfIconImages, *BlockOfIconImagesPtr;
+
/*
- * These two structures are used to read in icons from an
- * 'icon directory' (i.e. the contents of a .icr file, say).
- * We only use these structures temporarily, since we copy
- * the information we want into a BlockOfIconImages.
+ * These two structures are used to read in icons from an 'icon directory'
+ * (i.e. the contents of a .icr file, say). We only use these structures
+ * temporarily, since we copy the information we want into a
+ * BlockOfIconImages.
*/
+
typedef struct {
- BYTE bWidth; /* Width of the image */
- BYTE bHeight; /* Height of the image (times 2) */
- BYTE bColorCount; /* Number of colors in image (0 if >=8bpp) */
- BYTE bReserved; /* Reserved */
- WORD wPlanes; /* Color Planes */
- WORD wBitCount; /* Bits per pixel */
- DWORD dwBytesInRes; /* how many bytes in this resource? */
- DWORD dwImageOffset; /* where in the file is this image */
+ BYTE bWidth; /* Width of the image */
+ BYTE bHeight; /* Height of the image (times 2) */
+ BYTE bColorCount; /* Number of colors in image (0 if >=8bpp) */
+ BYTE bReserved; /* Reserved */
+ WORD wPlanes; /* Color Planes */
+ WORD wBitCount; /* Bits per pixel */
+ DWORD dwBytesInRes; /* How many bytes in this resource? */
+ DWORD dwImageOffset; /* Where in the file is this image */
} ICONDIRENTRY, *LPICONDIRENTRY;
+
typedef struct {
- WORD idReserved; /* Reserved */
- WORD idType; /* resource type (1 for icons) */
- WORD idCount; /* how many images? */
- ICONDIRENTRY idEntries[1]; /* the entries for each image */
+ WORD idReserved; /* Reserved */
+ WORD idType; /* Resource type (1 for icons) */
+ WORD idCount; /* How many images? */
+ ICONDIRENTRY idEntries[1]; /* The entries for each image */
} ICONDIR, *LPICONDIR;
/*
- * A pointer to one of these strucutures is associated with each
- * toplevel. This allows us to free up all memory associated with icon
- * resources when a window is deleted or if the window's icon is
- * changed. They are simply reference counted according to:
+ * A pointer to one of these strucutures is associated with each toplevel.
+ * This allows us to free up all memory associated with icon resources when a
+ * window is deleted or if the window's icon is changed. They are simply
+ * reference counted according to:
*
- * (i) how many WmInfo structures point to this object
- * (ii) whether the ThreadSpecificData defined in this file contains
- * a pointer to this object.
+ * (1) How many WmInfo structures point to this object
+ * (2) Whether the ThreadSpecificData defined in this file contains a pointer
+ * to this object.
*
- * The former count is for windows whose icons are individually
- * set, and the latter is for the global default icon choice.
+ * The former count is for windows whose icons are individually set, and the
+ * latter is for the global default icon choice.
*
- * Icons loaded from .icr/.icr use the iconBlock field, icons
- * loaded from .exe/.dll use the hIcon field.
+ * Icons loaded from .icr/.icr use the iconBlock field, icons loaded from
+ * .exe/.dll use the hIcon field.
*/
+
typedef struct WinIconInstance {
- int refCount; /* Number of instances that share this
- * data structure. */
+ int refCount; /* Number of instances that share this data
+ * structure. */
BlockOfIconImagesPtr iconBlock;
- /* Pointer to icon resource data for
- * image. */
+ /* Pointer to icon resource data for image */
} WinIconInstance;
typedef struct WinIconInstance *WinIconPtr;
@@ -152,96 +157,95 @@ typedef struct WinIconInstance *WinIconPtr;
*/
typedef struct TkWmInfo {
- TkWindow *winPtr; /* Pointer to main Tk information for
- * this window. */
- HWND wrapper; /* This is the decorative frame window
- * created by the window manager to wrap
- * a toplevel window. This window is
- * a direct child of the root window. */
- char *title; /* Title to display in window caption. If
- * NULL, use name of widget. Malloced. */
- char *iconName; /* Name to display in icon. Malloced. */
- XWMHints hints; /* Various pieces of information for
- * window manager. */
+ TkWindow *winPtr; /* Pointer to main Tk information for this
+ * window. */
+ HWND wrapper; /* This is the decorative frame window created
+ * by the window manager to wrap a toplevel
+ * window. This window is a direct child of
+ * the root window. */
+ char *title; /* Title to display in window caption. If
+ * NULL, use name of widget. Malloced. */
+ char *iconName; /* Name to display in icon. Malloced. */
+ XWMHints hints; /* Various pieces of information for window
+ * manager. */
char *leaderName; /* Path name of leader of window group
* (corresponds to hints.window_group).
- * Malloc-ed. Note: this field doesn't
- * get updated if leader is destroyed. */
+ * Malloc-ed. Note: this field doesn't get
+ * updated if leader is destroyed. */
TkWindow *masterPtr; /* Master window for TRANSIENT_FOR property,
* or NULL. */
- Tk_Window icon; /* Window to use as icon for this window,
- * or NULL. */
+ Tk_Window icon; /* Window to use as icon for this window, or
+ * NULL. */
Tk_Window iconFor; /* Window for which this window is icon, or
* NULL if this isn't an icon for anyone. */
/*
- * Information used to construct an XSizeHints structure for
- * the window manager:
+ * Information used to construct an XSizeHints structure for the window
+ * manager:
*/
int defMinWidth, defMinHeight, defMaxWidth, defMaxHeight;
/* Default resize limits given by system. */
- int sizeHintsFlags; /* Flags word for XSizeHints structure.
- * If the PBaseSize flag is set then the
- * window is gridded; otherwise it isn't
- * gridded. */
- int minWidth, minHeight; /* Minimum dimensions of window, in
- * pixels or grid units. */
- int maxWidth, maxHeight; /* Maximum dimensions of window, in
- * pixels or grid units. 0 to default. */
+ int sizeHintsFlags; /* Flags word for XSizeHints structure. If the
+ * PBaseSize flag is set then the window is
+ * gridded; otherwise it isn't gridded. */
+ int minWidth, minHeight; /* Minimum dimensions of window, in pixels or
+ * grid units. */
+ int maxWidth, maxHeight; /* Maximum dimensions of window, in pixels or
+ * grid units. 0 to default. */
Tk_Window gridWin; /* Identifies the window that controls
- * gridding for this top-level, or NULL if
- * the top-level isn't currently gridded. */
- int widthInc, heightInc; /* Increments for size changes (# pixels
- * per step). */
+ * gridding for this top-level, or NULL if the
+ * top-level isn't currently gridded. */
+ int widthInc, heightInc; /* Increments for size changes (# pixels per
+ * step). */
struct {
int x; /* numerator */
int y; /* denominator */
} minAspect, maxAspect; /* Min/max aspect ratios for window. */
int reqGridWidth, reqGridHeight;
- /* The dimensions of the window (in
- * grid units) requested through
- * the geometry manager. */
+ /* The dimensions of the window (in grid
+ * units) requested through the geometry
+ * manager. */
int gravity; /* Desired window gravity. */
/*
* Information used to manage the size and location of a window.
*/
- int width, height; /* Desired dimensions of window, specified
- * in pixels or grid units. These values are
- * set by the "wm geometry" command and by
- * ConfigureNotify events (for when wm
- * resizes window). -1 means user hasn't
- * requested dimensions. */
+ int width, height; /* Desired dimensions of window, specified in
+ * pixels or grid units. These values are set
+ * by the "wm geometry" command and by
+ * ConfigureNotify events (for when wm resizes
+ * window). -1 means user hasn't requested
+ * dimensions. */
int x, y; /* Desired X and Y coordinates for window.
- * These values are set by "wm geometry",
- * plus by ConfigureNotify events (when wm
- * moves window). These numbers are
- * different than the numbers stored in
- * winPtr->changes because (a) they could be
- * measured from the right or bottom edge
- * of the screen (see WM_NEGATIVE_X and
- * WM_NEGATIVE_Y flags) and (b) if the window
- * has been reparented then they refer to the
- * parent rather than the window itself. */
+ * These values are set by "wm geometry", plus
+ * by ConfigureNotify events (when wm moves
+ * window). These numbers are different than
+ * the numbers stored in winPtr->changes
+ * because (a) they could be measured from the
+ * right or bottom edge of the screen (see
+ * WM_NEGATIVE_X and WM_NEGATIVE_Y flags) and
+ * (b) if the window has been reparented then
+ * they refer to the parent rather than the
+ * window itself. */
int borderWidth, borderHeight;
/* Width and height of window dressing, in
- * pixels for the current style/exStyle. This
+ * pixels for the current style/exStyle. This
* includes the border on both sides of the
* window. */
int configX, configY; /* x,y position of toplevel when window is
* switched into fullscreen state, */
int configWidth, configHeight;
/* Dimensions passed to last request that we
- * issued to change geometry of window. Used
- * to eliminate redundant resize operations. */
+ * issued to change geometry of window. Used
+ * to eliminate redundant resize operations */
HMENU hMenu; /* the hMenu associated with this menu */
DWORD style, exStyle; /* Style flags for the wrapper window. */
LONG styleConfig; /* Extra user requested style bits */
LONG exStyleConfig; /* Extra user requested extended style bits */
- double alpha; /* Alpha transparency level
- * 0.0 (fully transparent) .. 1.0 (opaque) */
+ double alpha; /* Alpha transparency level 0.0 (fully
+ * transparent) .. 1.0 (opaque) */
/*
* List of children of the toplevel which have private colormaps.
@@ -254,62 +258,58 @@ typedef struct TkWmInfo {
* Miscellaneous information.
*/
- ProtocolHandler *protPtr; /* First in list of protocol handlers for
- * this window (NULL means none). */
+ ProtocolHandler *protPtr; /* First in list of protocol handlers for this
+ * window (NULL means none). */
int cmdArgc; /* Number of elements in cmdArgv below. */
- CONST char **cmdArgv; /* Array of strings to store in the
- * WM_COMMAND property. NULL means nothing
- * available. */
+ CONST char **cmdArgv; /* Array of strings to store in the WM_COMMAND
+ * property. NULL means nothing available. */
char *clientMachine; /* String to store in WM_CLIENT_MACHINE
* property, or NULL. */
int flags; /* Miscellaneous flags, defined below. */
- int numTransients; /* number of transients on this window */
- WinIconPtr iconPtr; /* pointer to titlebar icon structure for
- * this window, or NULL. */
+ int numTransients; /* Number of transients on this window */
+ WinIconPtr iconPtr; /* Pointer to titlebar icon structure for this
+ * window, or NULL. */
struct TkWmInfo *nextPtr; /* Next in list of all top-level windows. */
} WmInfo;
/*
* Flag values for WmInfo structures:
*
- * WM_NEVER_MAPPED - non-zero means window has never been
- * mapped; need to update all info when
- * window is first mapped.
- * WM_UPDATE_PENDING - non-zero means a call to UpdateGeometryInfo
- * has already been scheduled for this
- * window; no need to schedule another one.
- * WM_NEGATIVE_X - non-zero means x-coordinate is measured in
- * pixels from right edge of screen, rather
- * than from left edge.
- * WM_NEGATIVE_Y - non-zero means y-coordinate is measured in
+ * WM_NEVER_MAPPED - Non-zero means window has never been mapped;
+ * need to update all info when window is first
+ * mapped.
+ * WM_UPDATE_PENDING - Non-zero means a call to UpdateGeometryInfo
+ * has already been scheduled for this window;
+ * no need to schedule another one.
+ * WM_NEGATIVE_X - Non-zero means x-coordinate is measured in
+ * pixels from right edge of screen, rather than
+ * from left edge.
+ * WM_NEGATIVE_Y - Non-zero means y-coordinate is measured in
* pixels up from bottom of screen, rather than
* down from top.
- * WM_UPDATE_SIZE_HINTS - non-zero means that new size hints need to be
+ * WM_UPDATE_SIZE_HINTS - Non-zero means that new size hints need to be
* propagated to window manager. Not used on Win.
- * WM_SYNC_PENDING - set to non-zero while waiting for the window
+ * WM_SYNC_PENDING - Set to non-zero while waiting for the window
* manager to respond to some state change.
- * WM_MOVE_PENDING - non-zero means the application has requested
- * a new position for the window, but it hasn't
- * been reflected through the window manager
- * yet.
- * WM_COLORMAPS_EXPLICIT - non-zero means the colormap windows were
- * set explicitly via "wm colormapwindows".
- * WM_ADDED_TOPLEVEL_COLORMAP - non-zero means that when "wm colormapwindows"
+ * WM_MOVE_PENDING - Non-zero means the application has requested a
+ * new position for the window, but it hasn't
+ * been reflected through the window manager yet.
+ * WM_COLORMAPS_EXPLICIT - Non-zero means the colormap windows were set
+ * explicitly via "wm colormapwindows".
+ * WM_ADDED_TOPLEVEL_COLORMAP - Non-zero means that when "wm colormapwindows"
* was called the top-level itself wasn't
- * specified, so we added it implicitly at
- * the end of the list.
- * WM_WIDTH_NOT_RESIZABLE - non-zero means that we're not supposed to
+ * specified, so we added it implicitly at the
+ * end of the list.
+ * WM_WIDTH_NOT_RESIZABLE - Non-zero means that we're not supposed to
* allow the user to change the width of the
- * window (controlled by "wm resizable"
- * command).
- * WM_HEIGHT_NOT_RESIZABLE - non-zero means that we're not supposed to
+ * window (controlled by "wm resizable" command).
+ * WM_HEIGHT_NOT_RESIZABLE - Non-zero means that we're not supposed to
* allow the user to change the height of the
- * window (controlled by "wm resizable"
- * command).
- * WM_WITHDRAWN - non-zero means that this window has explicitly
+ * window (controlled by "wm resizable" command).
+ * WM_WITHDRAWN - Non-zero means that this window has explicitly
* been withdrawn. If it's a transient, it should
* not mirror state changes in the master.
- * WM_FULLSCREEN - non-zero means that this window has been placed
+ * WM_FULLSCREEN - Non-zero means that this window has been placed
* in the full screen mode. It should be mapped at
* 0,0 and be the width and height of the screen.
*/
@@ -347,240 +347,229 @@ typedef struct TkWmInfo {
#define EX_TRANSIENT_STYLE (WS_EX_DLGMODALFRAME)
/*
- * The following structure is the official type record for geometry
- * management of top-level windows.
+ * The following structure is the official type record for geometry management
+ * of top-level windows.
*/
static void TopLevelReqProc(ClientData dummy, Tk_Window tkwin);
static Tk_GeomMgr wmMgrType = {
- "wm", /* name */
- TopLevelReqProc, /* requestProc */
- (Tk_GeomLostSlaveProc *) NULL, /* lostSlaveProc */
+ "wm", /* name */
+ TopLevelReqProc, /* requestProc */
+ NULL, /* lostSlaveProc */
};
typedef struct ThreadSpecificData {
- HPALETTE systemPalette; /* System palette; refers to the
- * currently installed foreground logical
- * palette. */
- TkWindow *createWindow; /* Window that is being constructed. This
- * value is set immediately before a
- * call to CreateWindowEx, and is used
- * by SetLimits. This is a gross hack
- * needed to work around Windows brain
- * damage where it sends the
- * WM_GETMINMAXINFO message before the
- * WM_CREATE window. */
- int initialized; /* Flag indicating whether thread-
- * specific elements of module have
- * been initialized. */
- int firstWindow; /* Flag, cleared when the first window
- * is mapped in a non-iconic state. */
- WinIconPtr iconPtr; /* IconPtr being used as default for all
- * toplevels, or NULL. */
+ HPALETTE systemPalette; /* System palette; refers to the currently
+ * installed foreground logical palette. */
+ TkWindow *createWindow; /* Window that is being constructed. This
+ * value is set immediately before a call to
+ * CreateWindowEx, and is used by SetLimits.
+ * This is a gross hack needed to work around
+ * Windows brain damage where it sends the
+ * WM_GETMINMAXINFO message before the
+ * WM_CREATE window. */
+ int initialized; /* Flag indicating whether thread-specific
+ * elements of module have been
+ * initialized. */
+ int firstWindow; /* Flag, cleared when the first window is
+ * mapped in a non-iconic state. */
+ WinIconPtr iconPtr; /* IconPtr being used as default for all
+ * toplevels, or NULL. */
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
/*
- * The following variables cannot be placed in thread local storage
- * because they must be shared across threads.
+ * The following variables cannot be placed in thread local storage because
+ * they must be shared across threads.
*/
-static int initialized; /* Flag indicating whether module has
- * been initialized. */
+static int initialized; /* Flag indicating whether module has been
+ * initialized. */
-/*
- * A pointer to a shell proc which allows us to extract icons from
- * any file. We just initialize this when we start up (if we can)
- * and then it never changes
+/*
+ * A pointer to a shell proc which allows us to extract icons from any file.
+ * We just initialize this when we start up (if we can) and then it never
+ * changes
*/
+
DWORD* (WINAPI *shgetfileinfoProc) (LPCTSTR pszPath, DWORD dwFileAttributes,
- SHFILEINFO* psfi, UINT cbFileInfo, UINT uFlags) = NULL;
+ SHFILEINFO* psfi, UINT cbFileInfo, UINT uFlags) = NULL;
/*
- * A pointer to SetLayeredWindowAttributes (user32.dll) which we
- * retrieve dynamically because it is only valid on Win2K+.
+ * A pointer to SetLayeredWindowAttributes (user32.dll) which we retrieve
+ * dynamically because it is only valid on Win2K+.
*/
+
BOOL (WINAPI *setLayeredWindowAttributesProc) (HWND hwnd, COLORREF crKey,
BYTE bAlpha, DWORD dwFlags) = NULL;
TCL_DECLARE_MUTEX(winWmMutex)
/*
- * Forward declarations for procedures defined in this file:
+ * Forward declarations for functions defined in this file:
*/
-static int ActivateWindow _ANSI_ARGS_((Tcl_Event *evPtr,
- int flags));
-static void ConfigureTopLevel _ANSI_ARGS_((WINDOWPOS *pos));
-static void GenerateConfigureNotify _ANSI_ARGS_((
- TkWindow *winPtr));
-static void GetMaxSize _ANSI_ARGS_((WmInfo *wmPtr,
- int *maxWidthPtr, int *maxHeightPtr));
-static void GetMinSize _ANSI_ARGS_((WmInfo *wmPtr,
- int *minWidthPtr, int *minHeightPtr));
-static TkWindow * GetTopLevel _ANSI_ARGS_((HWND hwnd));
-static void InitWm _ANSI_ARGS_((void));
-static int InstallColormaps _ANSI_ARGS_((HWND hwnd, int message,
- int isForemost));
-static void InvalidateSubTree _ANSI_ARGS_((TkWindow *winPtr,
- Colormap colormap));
-static void InvalidateSubTreeDepth _ANSI_ARGS_((TkWindow *winPtr));
-static int ParseGeometry _ANSI_ARGS_((Tcl_Interp *interp,
- char *string, TkWindow *winPtr));
-static void RefreshColormap _ANSI_ARGS_((Colormap colormap,
- TkDisplay *dispPtr));
-static void SetLimits _ANSI_ARGS_((HWND hwnd, MINMAXINFO *info));
-static void TkWmStackorderToplevelWrapperMap _ANSI_ARGS_((
- TkWindow *winPtr,
- Display *display,
- Tcl_HashTable *table));
-static LRESULT CALLBACK TopLevelProc _ANSI_ARGS_((HWND hwnd, UINT message,
- WPARAM wParam, LPARAM lParam));
-static void TopLevelEventProc _ANSI_ARGS_((ClientData clientData,
- XEvent *eventPtr));
-static void TopLevelReqProc _ANSI_ARGS_((ClientData dummy,
- Tk_Window tkwin));
-static void UpdateGeometryInfo _ANSI_ARGS_((
- ClientData clientData));
-static void UpdateWrapper _ANSI_ARGS_((TkWindow *winPtr));
-static LRESULT CALLBACK WmProc _ANSI_ARGS_((HWND hwnd, UINT message,
- WPARAM wParam, LPARAM lParam));
-static void WmWaitVisibilityOrMapProc _ANSI_ARGS_((
- ClientData clientData, XEvent *eventPtr));
-static BlockOfIconImagesPtr ReadIconOrCursorFromFile _ANSI_ARGS_((
- Tcl_Interp *interp, Tcl_Obj* fileName, BOOL isIcon));
-static WinIconPtr ReadIconFromFile _ANSI_ARGS_((
- Tcl_Interp *interp, Tcl_Obj *fileName));
-static WinIconPtr GetIconFromPixmap _ANSI_ARGS_((Display *dsPtr,
- Pixmap pixmap));
-static int ReadICOHeader _ANSI_ARGS_((Tcl_Channel channel));
-static BOOL AdjustIconImagePointers _ANSI_ARGS_((LPICONIMAGE lpImage));
-static HICON MakeIconOrCursorFromResource
- _ANSI_ARGS_((LPICONIMAGE lpIcon, BOOL isIcon));
-static HICON GetIcon _ANSI_ARGS_((WinIconPtr titlebaricon,
- int icon_size));
-static int WinSetIcon _ANSI_ARGS_((Tcl_Interp *interp,
- WinIconPtr titlebaricon, Tk_Window tkw));
-static void FreeIconBlock _ANSI_ARGS_((BlockOfIconImagesPtr lpIR));
-static void DecrIconRefCount _ANSI_ARGS_((WinIconPtr titlebaricon));
-
-static int WmAspectCmd _ANSI_ARGS_((Tk_Window tkwin,
+static int ActivateWindow(Tcl_Event *evPtr, int flags);
+static void ConfigureTopLevel(WINDOWPOS *pos);
+static void GenerateConfigureNotify(TkWindow *winPtr);
+static void GetMaxSize(WmInfo *wmPtr,
+ int *maxWidthPtr, int *maxHeightPtr);
+static void GetMinSize(WmInfo *wmPtr,
+ int *minWidthPtr, int *minHeightPtr);
+static TkWindow * GetTopLevel(HWND hwnd);
+static void InitWm(void);
+static int InstallColormaps(HWND hwnd, int message,
+ int isForemost);
+static void InvalidateSubTree(TkWindow *winPtr, Colormap colormap);
+static void InvalidateSubTreeDepth(TkWindow *winPtr);
+static int ParseGeometry(Tcl_Interp *interp, char *string,
+ TkWindow *winPtr);
+static void RefreshColormap(Colormap colormap, TkDisplay *dispPtr);
+static void SetLimits(HWND hwnd, MINMAXINFO *info);
+static void TkWmStackorderToplevelWrapperMap(TkWindow *winPtr,
+ Display *display, Tcl_HashTable *table);
+static LRESULT CALLBACK TopLevelProc(HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam);
+static void TopLevelEventProc(ClientData clientData,
+ XEvent *eventPtr);
+static void TopLevelReqProc(ClientData dummy, Tk_Window tkwin);
+static void UpdateGeometryInfo(ClientData clientData);
+static void UpdateWrapper(TkWindow *winPtr);
+static LRESULT CALLBACK WmProc(HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam);
+static void WmWaitVisibilityOrMapProc(ClientData clientData,
+ XEvent *eventPtr);
+static BlockOfIconImagesPtr ReadIconOrCursorFromFile(Tcl_Interp *interp,
+ Tcl_Obj* fileName, BOOL isIcon);
+static WinIconPtr ReadIconFromFile(Tcl_Interp *interp,
+ Tcl_Obj *fileName);
+static WinIconPtr GetIconFromPixmap(Display *dsPtr, Pixmap pixmap);
+static int ReadICOHeader(Tcl_Channel channel);
+static BOOL AdjustIconImagePointers(LPICONIMAGE lpImage);
+static HICON MakeIconOrCursorFromResource(LPICONIMAGE lpIcon,
+ BOOL isIcon);
+static HICON GetIcon(WinIconPtr titlebaricon, int icon_size);
+static int WinSetIcon(Tcl_Interp *interp,
+ WinIconPtr titlebaricon, Tk_Window tkw);
+static void FreeIconBlock(BlockOfIconImagesPtr lpIR);
+static void DecrIconRefCount(WinIconPtr titlebaricon);
+
+static int WmAspectCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmAttributesCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmAttributesCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmClientCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmClientCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmColormapwindowsCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmColormapwindowsCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmCommandCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmCommandCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmDeiconifyCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmDeiconifyCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmFocusmodelCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmFocusmodelCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmFrameCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmFrameCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmGeometryCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmGeometryCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmGridCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmGridCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmGroupCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmGroupCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmIconbitmapCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmIconbitmapCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmIconifyCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmIconifyCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmIconmaskCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmIconmaskCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmIconnameCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmIconnameCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmIconphotoCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmIconphotoCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmIconpositionCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmIconpositionCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmIconwindowCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmIconwindowCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmMaxsizeCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmMaxsizeCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmMinsizeCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmMinsizeCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmOverrideredirectCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmOverrideredirectCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmPositionfromCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmPositionfromCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmProtocolCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmProtocolCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmResizableCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmResizableCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmSizefromCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmSizefromCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmStackorderCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmStackorderCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmStateCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmStateCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmTitleCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmTitleCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmTransientCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmTransientCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static int WmWithdrawCmd _ANSI_ARGS_((Tk_Window tkwin,
+ Tcl_Obj *CONST objv[]);
+static int WmWithdrawCmd(Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static void WmUpdateGeom _ANSI_ARGS_((WmInfo *wmPtr,
- TkWindow *winPtr));
+ Tcl_Obj *CONST objv[]);
+static void WmUpdateGeom(WmInfo *wmPtr, TkWindow *winPtr);
-/* Used in BytesPerLine */
-#define WIDTHBYTES(bits) ((((bits) + 31)>>5)<<2)
+/*
+ * Used in BytesPerLine
+ */
+#define WIDTHBYTES(bits) ((((bits) + 31)>>5)<<2)
+
/*
*----------------------------------------------------------------------
*
* DIBNumColors --
*
- * Calculates the number of entries in the color table, given by
- * LPSTR lpbi - pointer to the CF_DIB memory block. Used by
- * titlebar icon code.
+ * Calculates the number of entries in the color table, given by LPSTR
+ * lpbi - pointer to the CF_DIB memory block. Used by titlebar icon code.
*
* Results:
- *
* WORD - Number of entries in the color table.
*
- * Side effects: None.
- *
- *
*----------------------------------------------------------------------
*/
-static WORD
-DIBNumColors( LPSTR lpbi )
+
+static WORD
+DIBNumColors(
+ LPSTR lpbi)
{
WORD wBitCount;
DWORD dwClrUsed;
@@ -592,12 +581,15 @@ DIBNumColors( LPSTR lpbi )
wBitCount = ((LPBITMAPINFOHEADER) lpbi)->biBitCount;
- switch (wBitCount)
- {
- case 1: return 2;
- case 4: return 16;
- case 8: return 256;
- default:return 0;
+ switch (wBitCount) {
+ case 1:
+ return 2;
+ case 4:
+ return 16;
+ case 8:
+ return 256;
+ default:
+ return 0;
}
}
@@ -606,22 +598,19 @@ DIBNumColors( LPSTR lpbi )
*
* PaletteSize --
*
- * Calculates the number of bytes in the color table, as given by
- * LPSTR lpbi - pointer to the CF_DIB memory block. Used by
- * titlebar icon code.
+ * Calculates the number of bytes in the color table, as given by LPSTR
+ * lpbi - pointer to the CF_DIB memory block. Used by titlebar icon code.
*
* Results:
- * number of bytes in the color table
- *
- * Side effects: None.
- *
+ * Number of bytes in the color table
*
*----------------------------------------------------------------------
*/
-static WORD
-PaletteSize( LPSTR lpbi )
+static WORD
+PaletteSize(
+ LPSTR lpbi)
{
- return ((WORD)( DIBNumColors( lpbi ) * sizeof( RGBQUAD )) );
+ return (WORD) (DIBNumColors(lpbi) * sizeof(RGBQUAD));
}
/*
@@ -629,9 +618,8 @@ PaletteSize( LPSTR lpbi )
*
* FindDIBits --
*
- * Locate the image bits in a CF_DIB format DIB, as given by
- * LPSTR lpbi - pointer to the CF_DIB memory block. Used by
- * titlebar icon code.
+ * Locate the image bits in a CF_DIB format DIB, as given by LPSTR lpbi -
+ * pointer to the CF_DIB memory block. Used by titlebar icon code.
*
* Results:
* pointer to the image bits
@@ -641,10 +629,12 @@ PaletteSize( LPSTR lpbi )
*
*----------------------------------------------------------------------
*/
-static LPSTR
-FindDIBBits( LPSTR lpbi )
+
+static LPSTR
+FindDIBBits(
+ LPSTR lpbi)
{
- return ( lpbi + *(LPDWORD)lpbi + PaletteSize( lpbi ) );
+ return lpbi + *(LPDWORD)lpbi + PaletteSize(lpbi);
}
/*
@@ -653,19 +643,18 @@ FindDIBBits( LPSTR lpbi )
* BytesPerLine --
*
* Calculates the number of bytes in one scan line, as given by
- * LPBITMAPINFOHEADER lpBMIH - pointer to the BITMAPINFOHEADER
- * that begins the CF_DIB block. Used by titlebar icon code.
+ * LPBITMAPINFOHEADER lpBMIH - pointer to the BITMAPINFOHEADER that
+ * begins the CF_DIB block. Used by titlebar icon code.
*
* Results:
* number of bytes in one scan line (DWORD aligned)
*
- * Side effects: None
- *
- *
*----------------------------------------------------------------------
*/
-static DWORD
-BytesPerLine( LPBITMAPINFOHEADER lpBMIH )
+
+static DWORD
+BytesPerLine(
+ LPBITMAPINFOHEADER lpBMIH)
{
return WIDTHBYTES(lpBMIH->biWidth * lpBMIH->biPlanes * lpBMIH->biBitCount);
}
@@ -675,39 +664,64 @@ BytesPerLine( LPBITMAPINFOHEADER lpBMIH )
*
* AdjustIconImagePointers --
*
- * Adjusts internal pointers in icon resource struct, as given
- * by LPICONIMAGE lpImage - the resource to handle. Used by
- * titlebar icon code.
+ * Adjusts internal pointers in icon resource struct, as given by
+ * LPICONIMAGE lpImage - the resource to handle. Used by titlebar icon
+ * code.
*
* Results:
* BOOL - TRUE for success, FALSE for failure
*
- * Side effects:
- *
- *
*----------------------------------------------------------------------
*/
-static BOOL
-AdjustIconImagePointers( LPICONIMAGE lpImage )
+
+static BOOL
+AdjustIconImagePointers(
+ LPICONIMAGE lpImage)
{
- /* Sanity check */
- if (lpImage==NULL)
+ /*
+ * Sanity check.
+ */
+
+ if (lpImage == NULL) {
return FALSE;
- /* BITMAPINFO is at beginning of bits */
+ }
+
+ /*
+ * BITMAPINFO is at beginning of bits.
+ */
+
lpImage->lpbi = (LPBITMAPINFO)lpImage->lpBits;
- /* Width - simple enough */
+
+ /*
+ * Width - simple enough.
+ */
+
lpImage->Width = lpImage->lpbi->bmiHeader.biWidth;
- /*
- * Icons are stored in funky format where height is doubled
- * so account for that
+
+ /*
+ * Icons are stored in funky format where height is doubled so account for
+ * that.
*/
+
lpImage->Height = (lpImage->lpbi->bmiHeader.biHeight)/2;
- /* How many colors? */
- lpImage->Colors = lpImage->lpbi->bmiHeader.biPlanes *
- lpImage->lpbi->bmiHeader.biBitCount;
- /* XOR bits follow the header and color table */
+
+ /*
+ * How many colors?
+ */
+
+ lpImage->Colors = lpImage->lpbi->bmiHeader.biPlanes
+ * lpImage->lpbi->bmiHeader.biBitCount;
+
+ /*
+ * XOR bits follow the header and color table.
+ */
+
lpImage->lpXOR = (LPBYTE)FindDIBBits(((LPSTR)lpImage->lpbi));
- /* AND bits follow the XOR bits */
+
+ /*
+ * AND bits follow the XOR bits.
+ */
+
lpImage->lpAND = lpImage->lpXOR + (lpImage->Height*
BytesPerLine((LPBITMAPINFOHEADER)(lpImage->lpbi)));
return TRUE;
@@ -718,50 +732,70 @@ AdjustIconImagePointers( LPICONIMAGE lpImage )
*
* MakeIconOrCursorFromResource --
*
- * Construct an actual HICON structure from the information
- * in a resource.
+ * Construct an actual HICON structure from the information in a
+ * resource.
*
* Results:
- *
- *
- * Side effects:
- *
+ * Icon
*
*----------------------------------------------------------------------
*/
-static HICON
-MakeIconOrCursorFromResource(LPICONIMAGE lpIcon, BOOL isIcon) {
+
+static HICON
+MakeIconOrCursorFromResource(
+ LPICONIMAGE lpIcon,
+ BOOL isIcon)
+{
HICON hIcon ;
static FARPROC pfnCreateIconFromResourceEx=NULL;
static int initinfo=0;
- /* Sanity Check */
- if (lpIcon == NULL)
+
+ /*
+ * Sanity Check
+ */
+
+ if (lpIcon == NULL) {
return NULL;
- if (lpIcon->lpBits == NULL)
+ }
+ if (lpIcon->lpBits == NULL) {
return NULL;
+ }
+
if (!initinfo) {
HMODULE hMod = GetModuleHandleA("USER32.DLL");
- initinfo=1;
+
+ initinfo = 1;
if (hMod){
- pfnCreateIconFromResourceEx =
- GetProcAddress(hMod, "CreateIconFromResourceEx");
+ pfnCreateIconFromResourceEx = GetProcAddress(hMod,
+ "CreateIconFromResourceEx");
}
}
- /* Let the OS do the real work :) */
- if (pfnCreateIconFromResourceEx!=NULL) {
- hIcon = (HICON) (pfnCreateIconFromResourceEx)
- (lpIcon->lpBits, lpIcon->dwNumBytes, isIcon, 0x00030000,
- (*(LPBITMAPINFOHEADER)(lpIcon->lpBits)).biWidth,
- (*(LPBITMAPINFOHEADER)(lpIcon->lpBits)).biHeight/2, 0);
+
+ /*
+ * Let the OS do the real work :)
+ */
+
+ if (pfnCreateIconFromResourceEx != NULL) {
+ hIcon = (HICON) (pfnCreateIconFromResourceEx) (lpIcon->lpBits,
+ lpIcon->dwNumBytes, isIcon, 0x00030000,
+ (*(LPBITMAPINFOHEADER)(lpIcon->lpBits)).biWidth,
+ (*(LPBITMAPINFOHEADER)(lpIcon->lpBits)).biHeight/2, 0);
} else {
hIcon = NULL;
}
- /* It failed, odds are good we're on NT so try the non-Ex way */
+
+ /*
+ * It failed, odds are good we're on NT so try the non-Ex way.
+ */
+
if (hIcon == NULL) {
- /* We would break on NT if we try with a 16bpp image */
+ /*
+ * We would break on NT if we try with a 16bpp image.
+ */
+
if (lpIcon->lpbi->bmiHeader.biBitCount != 16) {
- hIcon = CreateIconFromResource(lpIcon->lpBits, lpIcon->dwNumBytes,
- isIcon, 0x00030000);
+ hIcon = CreateIconFromResource(lpIcon->lpBits, lpIcon->dwNumBytes,
+ isIcon, 0x00030000);
}
}
return hIcon;
@@ -775,43 +809,56 @@ MakeIconOrCursorFromResource(LPICONIMAGE lpIcon, BOOL isIcon) {
* Reads the header from an ICO file, as specfied by channel.
*
* Results:
- * UINT - Number of images in file, -1 for failure.
- * If this succeeds, there is a decent chance this is a
- * valid icon file.
- *
- * Side effects:
- *
+ * UINT - Number of images in file, -1 for failure. If this succeeds,
+ * there is a decent chance this is a valid icon file.
*
*----------------------------------------------------------------------
*/
-static int
-ReadICOHeader( Tcl_Channel channel )
+
+static int
+ReadICOHeader(
+ Tcl_Channel channel)
{
- WORD Input;
- DWORD dwBytesRead;
+ WORD Input;
+ DWORD dwBytesRead;
- /* Read the 'reserved' WORD */
- dwBytesRead = Tcl_Read( channel, (char*)&Input, sizeof( WORD ));
- /* Did we get a WORD? */
- if (dwBytesRead != sizeof( WORD ))
+ /*
+ * Read the 'reserved' WORD, which should be a zero word.
+ */
+
+ dwBytesRead = Tcl_Read(channel, (char*) &Input, sizeof(WORD));
+ if (dwBytesRead != sizeof(WORD)) {
return -1;
- /* Was it 'reserved' ? (ie 0) */
- if (Input != 0)
+ }
+ if (Input != 0) {
return -1;
- /* Read the type WORD */
- dwBytesRead = Tcl_Read( channel, (char*)&Input, sizeof( WORD ));
- /* Did we get a WORD? */
- if (dwBytesRead != sizeof( WORD ))
+ }
+
+ /*
+ * Read the type WORD, which should be of type 1.
+ */
+
+ dwBytesRead = Tcl_Read(channel, (char*)&Input, sizeof(WORD));
+ if (dwBytesRead != sizeof(WORD)) {
return -1;
- /* Was it type 1? */
- if (Input != 1)
+ }
+ if (Input != 1) {
return -1;
- /* Get the count of images */
+ }
+
+ /*
+ * Get the count of images
+ */
+
dwBytesRead = Tcl_Read( channel, (char*)&Input, sizeof( WORD ));
- /* Did we get a WORD? */
- if (dwBytesRead != sizeof( WORD ))
+ if (dwBytesRead != sizeof(WORD)) {
return -1;
- /* Return the count */
+ }
+
+ /*
+ * Return the count
+ */
+
return (int)Input;
}
@@ -830,10 +877,12 @@ ReadICOHeader( Tcl_Channel channel )
*
*----------------------------------------------------------------------
*/
-static int
-InitWindowClass(WinIconPtr titlebaricon)
+
+static int
+InitWindowClass(
+ WinIconPtr titlebaricon)
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (! tsdPtr->initialized) {
@@ -851,37 +900,37 @@ InitWindowClass(WinIconPtr titlebaricon)
if (shgetfileinfoProc == NULL) {
HINSTANCE hInstance = LoadLibraryA("shell32");
if (hInstance != NULL) {
- shgetfileinfoProc =
- (DWORD* (WINAPI *) (LPCTSTR pszPath, DWORD dwFileAttributes,
- SHFILEINFO* psfi, UINT cbFileInfo, UINT uFlags)) GetProcAddress(hInstance,
- "SHGetFileInfo");
+ shgetfileinfoProc = (DWORD* (WINAPI *) (LPCTSTR pszPath,
+ DWORD dwFileAttributes, SHFILEINFO* psfi,
+ UINT cbFileInfo, UINT uFlags))
+ GetProcAddress(hInstance, "SHGetFileInfo");
FreeLibrary(hInstance);
}
}
if (setLayeredWindowAttributesProc == NULL) {
HINSTANCE hInstance = LoadLibraryA("user32");
if (hInstance != NULL) {
- setLayeredWindowAttributesProc =
- (BOOL (WINAPI *) (HWND hwnd, COLORREF crKey,
- BYTE bAlpha, DWORD dwFlags))
- GetProcAddress(hInstance,
- "SetLayeredWindowAttributes");
+ setLayeredWindowAttributesProc = (BOOL (WINAPI*)(HWND hwnd,
+ COLORREF crKey, BYTE bAlpha, DWORD dwFlags))
+ GetProcAddress(hInstance,"SetLayeredWindowAttributes");
FreeLibrary(hInstance);
}
}
+
/*
- * The only difference between WNDCLASSW and WNDCLASSA are
- * in pointers, so we can use the generic structure WNDCLASS.
+ * The only difference between WNDCLASSW and WNDCLASSA are in
+ * pointers, so we can use the generic structure WNDCLASS.
*/
+
ZeroMemory(&class, sizeof(WNDCLASS));
/*
- * When threads are enabled, we cannot use CLASSDC because
- * threads will then write into the same device context.
+ * When threads are enabled, we cannot use CLASSDC because threads
+ * will then write into the same device context.
*
- * This is a hack; we should add a subsystem that manages
- * device context on a per-thread basis. See also tkWinX.c,
- * which also initializes a WNDCLASS structure.
+ * This is a hack; we should add a subsystem that manages device
+ * context on a per-thread basis. See also tkWinX.c, which also
+ * initializes a WNDCLASS structure.
*/
#ifdef TCL_THREADS
@@ -900,10 +949,12 @@ InitWindowClass(WinIconPtr titlebaricon)
if (class.hIcon == NULL) {
return TCL_ERROR;
}
+
/*
- * Store pointer to default icon so we know when
- * we need to free that information
+ * Store pointer to default icon so we know when we need to
+ * free that information
*/
+
tsdPtr->iconPtr = titlebaricon;
}
class.hCursor = LoadCursor(NULL, IDC_ARROW);
@@ -914,9 +965,10 @@ InitWindowClass(WinIconPtr titlebaricon)
#ifndef TCL_THREADS
/*
- * Use of WS_EX_LAYERED disallows CS_CLASSDC, as does
- * TCL_THREADS usage, so only create this if necessary.
+ * Use of WS_EX_LAYERED disallows CS_CLASSDC, as does TCL_THREADS
+ * usage, so only create this if necessary.
*/
+
if (setLayeredWindowAttributesProc != NULL) {
class.style = CS_HREDRAW | CS_VREDRAW;
Tcl_DStringFree(&classString);
@@ -962,33 +1014,31 @@ InitWm(void)
*
* WinSetIcon --
*
- * Sets either the default toplevel titlebar icon, or the icon
- * for a specific toplevel (if tkw is given, then only that
- * window is used).
+ * Sets either the default toplevel titlebar icon, or the icon for a
+ * specific toplevel (if tkw is given, then only that window is used).
*
- * The ref-count of the titlebaricon is NOT changed. If this
- * function returns successfully, the caller should assume
- * the icon was used (and therefore the ref-count should
- * be adjusted to reflect that fact). If the function returned
- * an error, the caller should assume the icon was not used
- * (and may wish to free the memory associated with it).
+ * The ref-count of the titlebaricon is NOT changed. If this function
+ * returns successfully, the caller should assume the icon was used (and
+ * therefore the ref-count should be adjusted to reflect that fact). If
+ * the function returned an error, the caller should assume the icon was
+ * not used (and may wish to free the memory associated with it).
*
* Results:
* A standard Tcl return code.
*
* Side effects:
- * One or all windows may have their icon changed.
- * The Tcl result may be modified.
- * The window-manager will be initialised if it wasn't already.
+ * One or all windows may have their icon changed. The Tcl result may be
+ * modified. The window-manager will be initialised if it wasn't already.
* The given window will be forced into existence.
*
*----------------------------------------------------------------------
*/
+
static int
-WinSetIcon(interp, titlebaricon, tkw)
- Tcl_Interp *interp;
- WinIconPtr titlebaricon;
- Tk_Window tkw;
+WinSetIcon(
+ Tcl_Interp *interp,
+ WinIconPtr titlebaricon,
+ Tk_Window tkw)
{
WmInfo *wmPtr;
HWND hwnd;
@@ -1001,7 +1051,7 @@ WinSetIcon(interp, titlebaricon, tkw)
if (!(Tk_IsTopLevel(tkw))) {
Tcl_AppendResult(interp, "window \"", Tk_PathName(tkw),
- "\" isn't a top-level window", (char *) NULL);
+ "\" isn't a top-level window", NULL);
return TCL_ERROR;
}
if (Tk_WindowId(tkw) == None) {
@@ -1015,54 +1065,59 @@ WinSetIcon(interp, titlebaricon, tkw)
if (hwnd == NULL) {
/*
* I don't actually think this is ever the correct thing, unless
- * perhaps the window doesn't have a wrapper. But I believe all
+ * perhaps the window doesn't have a wrapper. But I believe all
* windows have wrappers.
*/
+
hwnd = Tk_GetHWND(Tk_WindowId(tkw));
}
+
/*
* If we aren't initialised, then just initialise with the user's
- * icon. Otherwise our icon choice will be ignored moments later
- * when Tk finishes initialising.
+ * icon. Otherwise our icon choice will be ignored moments later when
+ * Tk finishes initialising.
*/
+
if (!initialized) {
if (InitWindowClass(titlebaricon) != TCL_OK) {
- Tcl_AppendResult(interp,"Unable to set icon", (char*)NULL);
+ Tcl_AppendResult(interp, "Unable to set icon", NULL);
return TCL_ERROR;
}
} else {
ThreadSpecificData *tsdPtr;
+
if (
#ifdef _WIN64
- !SetClassLongPtr(hwnd, GCLP_HICONSM,
- (LPARAM)GetIcon(titlebaricon, ICON_SMALL))
+ !SetClassLongPtr(hwnd, GCLP_HICONSM,
+ (LPARAM)GetIcon(titlebaricon, ICON_SMALL))
#else
- !SetClassLong(hwnd, GCL_HICONSM,
- (LPARAM)GetIcon(titlebaricon, ICON_SMALL))
+ !SetClassLong(hwnd, GCL_HICONSM,
+ (LPARAM)GetIcon(titlebaricon, ICON_SMALL))
#endif
- ) {
+ ) {
/*
- * For some reason this triggers, even though it seems
- * to be successful This is probably related to the
- * WNDCLASS vs WNDCLASSEX difference. Anyway it seems
- * we have to ignore errors returned here.
+ * For some reason this triggers, even though it seems to be
+ * successful. This is probably related to the WNDCLASS vs
+ * WNDCLASSEX difference. Anyway it seems we have to ignore
+ * errors returned here.
*/
/*
- * Tcl_AppendResult(interp,"Unable to set new small icon", (char*)NULL);
- * return TCL_ERROR;
- */
+ Tcl_AppendResult(interp,"Unable to set new small icon",NULL);
+ return TCL_ERROR;
+ */
}
+
if (
#ifdef _WIN64
- !SetClassLongPtr(hwnd, GCLP_HICON,
- (LPARAM)GetIcon(titlebaricon, ICON_BIG))
+ !SetClassLongPtr(hwnd, GCLP_HICON,
+ (LPARAM)GetIcon(titlebaricon, ICON_BIG))
#else
- !SetClassLong(hwnd, GCL_HICON,
- (LPARAM)GetIcon(titlebaricon, ICON_BIG))
+ !SetClassLong(hwnd, GCL_HICON,
+ (LPARAM)GetIcon(titlebaricon, ICON_BIG))
#endif
- ) {
- Tcl_AppendResult(interp,"Unable to set new icon", (char*)NULL);
+ ) {
+ Tcl_AppendResult(interp, "Unable to set new icon", NULL);
return TCL_ERROR;
}
tsdPtr = (ThreadSpecificData *)
@@ -1075,31 +1130,34 @@ WinSetIcon(interp, titlebaricon, tkw)
} else {
if (!initialized) {
/*
- * Need to initialise the wm otherwise we will fail on
- * code which tries to set a toplevel's icon before that
- * happens. Ignore return result.
+ * Need to initialise the wm otherwise we will fail on code which
+ * tries to set a toplevel's icon before that happens. Ignore
+ * return result.
*/
- (void)InitWindowClass(NULL);
+
+ (void) InitWindowClass(NULL);
}
/*
* The following code is exercised if you do
*
* toplevel .t ; wm titlebaricon .t foo.icr
*
- * i.e. the wm hasn't had time to properly create
- * the '.t' window before you set the icon.
+ * i.e. the wm hasn't had time to properly create the '.t' window
+ * before you set the icon.
*/
+
if (hwnd == NULL) {
/*
- * This little snippet is copied from the 'Map' function,
- * and should probably be placed in one proper location
+ * This little snippet is copied from the 'Map' function, and
+ * should probably be placed in one proper location.
*/
+
UpdateWrapper(wmPtr->winPtr);
wmPtr = ((TkWindow*)tkw)->wmInfoPtr;
hwnd = wmPtr->wrapper;
if (hwnd == NULL) {
Tcl_AppendResult(interp,
- "Can't set icon; window has no wrapper.", (char*)NULL);
+ "Can't set icon; window has no wrapper.", NULL);
return TCL_ERROR;
}
}
@@ -1108,16 +1166,23 @@ WinSetIcon(interp, titlebaricon, tkw)
SendMessage(hwnd, WM_SETICON, ICON_BIG,
(LPARAM) GetIcon(titlebaricon, ICON_BIG));
- /* Update the iconPtr we keep for each WmInfo structure. */
+ /*
+ * Update the iconPtr we keep for each WmInfo structure.
+ */
+
if (wmPtr->iconPtr != NULL) {
- /* Free any old icon ptr which is associated with this window. */
+ /*
+ * Free any old icon ptr which is associated with this window.
+ */
+
DecrIconRefCount(wmPtr->iconPtr);
}
+
/*
- * We do not need to increment the ref count for the
- * titlebaricon, because it was already incremented when we
- * retrieved it.
+ * We do not need to increment the ref count for the titlebaricon,
+ * because it was already incremented when we retrieved it.
*/
+
wmPtr->iconPtr = titlebaricon;
}
return TCL_OK;
@@ -1128,8 +1193,8 @@ WinSetIcon(interp, titlebaricon, tkw)
*
* TkWinGetIcon --
*
- * Gets either the default toplevel titlebar icon, or the icon
- * for a specific toplevel (ICON_SMALL or ICON_BIG).
+ * Gets either the default toplevel titlebar icon, or the icon for a
+ * specific toplevel (ICON_SMALL or ICON_BIG).
*
* Results:
* A Windows HICON.
@@ -1140,21 +1205,27 @@ WinSetIcon(interp, titlebaricon, tkw)
*----------------------------------------------------------------------
*/
HICON
-TkWinGetIcon(Tk_Window tkwin, DWORD iconsize)
+TkWinGetIcon(
+ Tk_Window tkwin,
+ DWORD iconsize)
{
WmInfo *wmPtr;
HICON icon;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (tsdPtr->iconPtr != NULL) {
/*
* return default toplevel icon
*/
+
return GetIcon(tsdPtr->iconPtr, iconsize);
}
- /* ensure we operate on the toplevel, that has the icon refs */
+ /*
+ * Ensure we operate on the toplevel, that has the icon refs.
+ */
+
while (!Tk_IsTopLevel(tkwin)) {
tkwin = Tk_Parent(tkwin);
if (tkwin == NULL) {
@@ -1171,13 +1242,15 @@ TkWinGetIcon(Tk_Window tkwin, DWORD iconsize)
/*
* return window toplevel icon
*/
+
return GetIcon(wmPtr->iconPtr, iconsize);
}
/*
- * Find the icon otherwise associated with the toplevel, or
- * finally with the window class.
+ * Find the icon otherwise associated with the toplevel, or finally with
+ * the window class.
*/
+
icon = (HICON) SendMessage(wmPtr->wrapper, WM_GETICON, iconsize,
(LPARAM) NULL);
if (icon == (HICON) NULL) {
@@ -1197,42 +1270,42 @@ TkWinGetIcon(Tk_Window tkwin, DWORD iconsize)
*
* ReadIconFromFile --
*
- * Read the contents of a file (usually .ico, .icr) and extract an
- * icon resource, if possible, otherwise check if the shell has an
- * icon assigned to the given file and use that. If both of those
- * fail, then NULL is returned, and an error message will already be
- * in the interpreter.
- *
+ * Read the contents of a file (usually .ico, .icr) and extract an icon
+ * resource, if possible, otherwise check if the shell has an icon
+ * assigned to the given file and use that. If both of those fail, then
+ * NULL is returned, and an error message will already be in the
+ * interpreter.
+ *
* Results:
- * A WinIconPtr structure containing the icons in the file, with
- * its ref count already incremented. The calling procedure should
- * either place this structure inside a WmInfo structure, or it should
- * pass it on to DecrIconRefCount() to ensure no memory leaks occur.
+ * A WinIconPtr structure containing the icons in the file, with its ref
+ * count already incremented. The calling function should either place
+ * this structure inside a WmInfo structure, or it should pass it on to
+ * DecrIconRefCount() to ensure no memory leaks occur.
*
* If the given fileName did not contain a valid icon structure,
* return NULL.
*
* Side effects:
- * Memory is allocated for the returned structure and the icons
- * it contains. If the structure is not wanted, it should be
- * passed to DecrIconRefCount, and in any case a valid ref count
- * should be ensured to avoid memory leaks.
+ * Memory is allocated for the returned structure and the icons it
+ * contains. If the structure is not wanted, it should be passed to
+ * DecrIconRefCount, and in any case a valid ref count should be ensured
+ * to avoid memory leaks.
*
- * Currently icon resources are not shared, so the ref count of
- * one of these structures will always be 0 or 1. However all we
- * need do is implement some sort of lookup function between
- * filenames and WinIconPtr structures and no other code will need
- * to be changed. The pseudo-code for this is implemented below
- * in the 'if (0)' branch. It did not seem necessary to implement
- * this optimisation here, since moving to icon<->image
- * conversions will probably make it obsolete.
+ * Currently icon resources are not shared, so the ref count of one of
+ * these structures will always be 0 or 1. However all we need do is
+ * implement some sort of lookup function between filenames and
+ * WinIconPtr structures and no other code will need to be changed. The
+ * pseudo-code for this is implemented below in the 'if (0)' branch. It
+ * did not seem necessary to implement this optimisation here, since
+ * moving to icon<->image conversions will probably make it obsolete.
*
*----------------------------------------------------------------------
*/
+
static WinIconPtr
-ReadIconFromFile(interp, fileName)
- Tcl_Interp *interp;
- Tcl_Obj *fileName;
+ReadIconFromFile(
+ Tcl_Interp *interp,
+ Tcl_Obj *fileName)
{
WinIconPtr titlebaricon = NULL;
@@ -1241,15 +1314,19 @@ ReadIconFromFile(interp, fileName)
titlebaricon->refCount++;
return titlebaricon;
} else {
- /* First check if it is a .ico file */
+ /*
+ * First check if it is a .ico file.
+ */
+
BlockOfIconImagesPtr lpIR;
lpIR = ReadIconOrCursorFromFile(interp, fileName, TRUE);
/*
- * Then see if we can ask the shell for the icon for this file.
- * We want both the regular and small icons so that the Alt-Tab
- * (task-switching) display uses the right icon.
+ * Then see if we can ask the shell for the icon for this file. We
+ * want both the regular and small icons so that the Alt-Tab (task-
+ * switching) display uses the right icon.
*/
+
if (lpIR == NULL && shgetfileinfoProc != NULL) {
SHFILEINFO sfiSM;
Tcl_DString ds, ds2;
@@ -1257,7 +1334,9 @@ ReadIconFromFile(interp, fileName)
CONST char *file;
file = Tcl_TranslateFileName(interp, Tcl_GetString(fileName), &ds);
- if (file == NULL) { return NULL; }
+ if (file == NULL) {
+ return NULL;
+ }
Tcl_UtfToExternalDString(NULL, file, -1, &ds2);
Tcl_DStringFree(&ds);
res = (*shgetfileinfoProc)(Tcl_DStringValue(&ds2), 0, &sfiSM,
@@ -1271,9 +1350,12 @@ ReadIconFromFile(interp, fileName)
res = (*shgetfileinfoProc)(Tcl_DStringValue(&ds2), 0, &sfi,
sizeof(SHFILEINFO), SHGFI_ICON);
- /* Account for extra icon, if necessary */
- size = sizeof(BlockOfIconImages) +
- ((res != 0) ? sizeof(ICONIMAGE) : 0);
+ /*
+ * Account for extra icon, if necessary.
+ */
+
+ size = sizeof(BlockOfIconImages)
+ + ((res != 0) ? sizeof(ICONIMAGE) : 0);
lpIR = (BlockOfIconImagesPtr) ckalloc(size);
if (lpIR == NULL) {
if (res != 0) {
@@ -1290,7 +1372,10 @@ ReadIconFromFile(interp, fileName)
lpIR->IconImages[0].Height = 16;
lpIR->IconImages[0].Colors = 4;
lpIR->IconImages[0].hIcon = sfiSM.hIcon;
- /* All other IconImages fields are ignored */
+
+ /*
+ * All other IconImages fields are ignored.
+ */
if (res != 0) {
lpIR->IconImages[1].Width = 32;
@@ -1315,45 +1400,45 @@ ReadIconFromFile(interp, fileName)
*
* GetIconFromPixmap --
*
- * Turn a Tk Pixmap (i.e. a bitmap) into an icon resource, if
- * possible, otherwise NULL is returned.
+ * Turn a Tk Pixmap (i.e. a bitmap) into an icon resource, if possible,
+ * otherwise NULL is returned.
*
* Results:
- * A WinIconPtr structure containing a conversion of the given
- * bitmap into an icon, with its ref count already incremented. The
- * calling procedure should either place this structure inside a
- * WmInfo structure, or it should pass it on to DecrIconRefCount()
- * to ensure no memory leaks occur.
- *
- * If the given pixmap did not contain a valid icon structure,
- * return NULL.
+ * A WinIconPtr structure containing a conversion of the given bitmap
+ * into an icon, with its ref count already incremented. The calling
+ * function should either place this structure inside a WmInfo structure,
+ * or it should pass it on to DecrIconRefCount() to ensure no memory
+ * leaks occur.
+ *
+ * If the given pixmap did not contain a valid icon structure, return
+ * NULL.
*
* Side effects:
- * Memory is allocated for the returned structure and the icons
- * it contains. If the structure is not wanted, it should be
- * passed to DecrIconRefCount, and in any case a valid ref count
- * should be ensured to avoid memory leaks.
- *
- * Currently icon resources are not shared, so the ref count of
- * one of these structures will always be 0 or 1. However all we
- * need do is implement some sort of lookup function between
- * pixmaps and WinIconPtr structures and no other code will need
- * to be changed.
+ * Memory is allocated for the returned structure and the icons it
+ * contains. If the structure is not wanted, it should be passed to
+ * DecrIconRefCount, and in any case a valid ref count should be ensured
+ * to avoid memory leaks.
+ *
+ * Currently icon resources are not shared, so the ref count of one of
+ * these structures will always be 0 or 1. However all we need do is
+ * implement some sort of lookup function between pixmaps and WinIconPtr
+ * structures and no other code will need to be changed.
*
*----------------------------------------------------------------------
*/
-static WinIconPtr
-GetIconFromPixmap(dsPtr, pixmap)
- Display *dsPtr;
- Pixmap pixmap;
+
+static WinIconPtr
+GetIconFromPixmap(
+ Display *dsPtr,
+ Pixmap pixmap)
{
WinIconPtr titlebaricon = NULL;
TkWinDrawable* twdPtr = (TkWinDrawable*) pixmap;
-
+
if (twdPtr == NULL) {
return NULL;
}
-
+
if (0 /* If we already have an icon for this pixmap */) {
titlebaricon = NULL; /* Get the real value from a lookup */
titlebaricon->refCount++;
@@ -1388,7 +1473,11 @@ GetIconFromPixmap(dsPtr, pixmap)
lpIR->IconImages[0].Height = height;
lpIR->IconImages[0].Colors = 1 << twdPtr->bitmap.depth;
lpIR->IconImages[0].hIcon = hIcon;
- /* These fields are ignored */
+
+ /*
+ * These fields are ignored.
+ */
+
lpIR->IconImages[0].lpBits = 0;
lpIR->IconImages[0].dwNumBytes = 0;
lpIR->IconImages[0].lpXOR = 0;
@@ -1412,14 +1501,17 @@ GetIconFromPixmap(dsPtr, pixmap)
* None.
*
* Side effects:
- * If the ref count falls to zero, free the memory associated
- * with the icon resource structures. In this case the pointer
- * passed into this function is no longer valid.
+ * If the ref count falls to zero, free the memory associated with the
+ * icon resource structures. In this case the pointer passed into this
+ * function is no longer valid.
*
*----------------------------------------------------------------------
*/
-static void
-DecrIconRefCount(WinIconPtr titlebaricon) {
+
+static void
+DecrIconRefCount(
+ WinIconPtr titlebaricon)
+{
titlebaricon->refCount--;
if (titlebaricon->refCount <= 0) {
@@ -1437,9 +1529,8 @@ DecrIconRefCount(WinIconPtr titlebaricon) {
*
* FreeIconBlock --
*
- * Frees all memory associated with a previously loaded
- * titlebaricon. The icon block pointer is no longer
- * valid once this function returns.
+ * Frees all memory associated with a previously loaded titlebaricon.
+ * The icon block pointer is no longer valid once this function returns.
*
* Results:
* None.
@@ -1449,12 +1540,17 @@ DecrIconRefCount(WinIconPtr titlebaricon) {
*
*----------------------------------------------------------------------
*/
-static void
-FreeIconBlock(BlockOfIconImagesPtr lpIR)
+
+static void
+FreeIconBlock(
+ BlockOfIconImagesPtr lpIR)
{
int i;
- /* Free all the bits */
+ /*
+ * Free all the bits.
+ */
+
for (i=0; i< lpIR->nNumImages; i++) {
if (lpIR->IconImages[i].lpBits != NULL) {
ckfree((char*)lpIR->IconImages[i].lpBits);
@@ -1476,16 +1572,16 @@ FreeIconBlock(BlockOfIconImagesPtr lpIR)
* Results:
* Returns the icon, if found, else NULL.
*
- * Side effects:
- *
- *
*----------------------------------------------------------------------
*/
-static HICON
-GetIcon(WinIconPtr titlebaricon, int icon_size)
+
+static HICON
+GetIcon(
+ WinIconPtr titlebaricon,
+ int icon_size)
{
BlockOfIconImagesPtr lpIR;
-
+
if (titlebaricon == NULL) {
return NULL;
}
@@ -1498,7 +1594,10 @@ GetIcon(WinIconPtr titlebaricon, int icon_size)
int i;
for (i = 0; i < lpIR->nNumImages; i++) {
- /* Take the first or a 32x32 16 color icon*/
+ /*
+ * Take the first or a 32x32 16 color icon
+ */
+
if ((lpIR->IconImages[i].Height == size)
&& (lpIR->IconImages[i].Width == size)
&& (lpIR->IconImages[i].Colors >= 4)) {
@@ -1506,10 +1605,10 @@ GetIcon(WinIconPtr titlebaricon, int icon_size)
}
}
- /*
- * If we get here, then just return the first one,
- * it will have to do!
+ /*
+ * If we get here, then just return the first one, it will have to do!
*/
+
if (lpIR->nNumImages >= 1) {
return lpIR->IconImages[0].hIcon;
}
@@ -1517,12 +1616,14 @@ GetIcon(WinIconPtr titlebaricon, int icon_size)
return NULL;
}
-static HCURSOR
-TclWinReadCursorFromFile(Tcl_Interp* interp, Tcl_Obj* fileName)
+static HCURSOR
+TclWinReadCursorFromFile(
+ Tcl_Interp* interp,
+ Tcl_Obj* fileName)
{
BlockOfIconImagesPtr lpIR;
HICON res = NULL;
-
+
lpIR = ReadIconOrCursorFromFile(interp, fileName, FALSE);
if (lpIR == NULL) {
return NULL;
@@ -1539,9 +1640,8 @@ TclWinReadCursorFromFile(Tcl_Interp* interp, Tcl_Obj* fileName)
*
* ReadIconOrCursorFromFile --
*
- * Reads an Icon Resource from an ICO file, as given by
- * char* fileName - Name of the ICO file. This name should
- * be in Utf format.
+ * Reads an Icon Resource from an ICO file, as given by char* fileName -
+ * Name of the ICO file. This name should be in Utf format.
*
* Results:
* Returns an icon resource, if found, else NULL.
@@ -1551,21 +1651,27 @@ TclWinReadCursorFromFile(Tcl_Interp* interp, Tcl_Obj* fileName)
*
*----------------------------------------------------------------------
*/
-static BlockOfIconImagesPtr
-ReadIconOrCursorFromFile(Tcl_Interp* interp, Tcl_Obj* fileName, BOOL isIcon)
+
+static BlockOfIconImagesPtr
+ReadIconOrCursorFromFile(
+ Tcl_Interp *interp,
+ Tcl_Obj *fileName,
+ BOOL isIcon)
{
BlockOfIconImagesPtr lpIR, lpNew;
- Tcl_Channel channel;
- int i;
- DWORD dwBytesRead;
- LPICONDIRENTRY lpIDE;
+ Tcl_Channel channel;
+ int i;
+ DWORD dwBytesRead;
+ LPICONDIRENTRY lpIDE;
+
+ /*
+ * Open the file.
+ */
- /* Open the file */
channel = Tcl_FSOpenFileChannel(interp, fileName, "r", 0);
if (channel == NULL) {
- Tcl_AppendResult(interp,"Error opening file \"",
- Tcl_GetString(fileName),
- "\" for reading",(char*)NULL);
+ Tcl_AppendResult(interp,"Error opening file \"",
+ Tcl_GetString(fileName), "\" for reading", NULL);
return NULL;
}
if (Tcl_SetChannelOption(interp, channel, "-translation", "binary")
@@ -1578,23 +1684,35 @@ ReadIconOrCursorFromFile(Tcl_Interp* interp, Tcl_Obj* fileName, BOOL isIcon)
Tcl_Close(NULL, channel);
return NULL;
}
- /* Allocate memory for the resource structure */
+
+ /*
+ * Allocate memory for the resource structure
+ */
+
lpIR = (BlockOfIconImagesPtr) ckalloc(sizeof(BlockOfIconImages));
if (lpIR == NULL) {
Tcl_AppendResult(interp,"Error allocating memory",(char*)NULL);
Tcl_Close(NULL, channel);
return NULL;
}
- /* Read in the header */
+
+ /*
+ * Read in the header
+ */
+
if ((lpIR->nNumImages = ReadICOHeader( channel )) == -1) {
Tcl_AppendResult(interp,"Invalid file header",(char*)NULL);
Tcl_Close(NULL, channel);
ckfree((char*) lpIR );
return NULL;
}
- /* Adjust the size of the struct to account for the images */
- lpNew = (BlockOfIconImagesPtr) ckrealloc((char*)lpIR,
- sizeof(BlockOfIconImages) + ((lpIR->nNumImages-1) * sizeof(ICONIMAGE)));
+
+ /*
+ * Adjust the size of the struct to account for the images.
+ */
+
+ lpNew = (BlockOfIconImagesPtr) ckrealloc((char*)lpIR,
+ sizeof(BlockOfIconImages) + ((lpIR->nNumImages-1)*sizeof(ICONIMAGE)));
if (lpNew == NULL) {
Tcl_AppendResult(interp,"Error allocating memory",(char*)NULL);
Tcl_Close(NULL, channel);
@@ -1602,7 +1720,11 @@ ReadIconOrCursorFromFile(Tcl_Interp* interp, Tcl_Obj* fileName, BOOL isIcon)
return NULL;
}
lpIR = lpNew;
- /* Allocate enough memory for the icon directory entries */
+
+ /*
+ * Allocate enough memory for the icon directory entries.
+ */
+
lpIDE = (LPICONDIRENTRY) ckalloc(lpIR->nNumImages * sizeof(ICONDIRENTRY));
if (lpIDE == NULL) {
Tcl_AppendResult(interp,"Error allocating memory",(char*)NULL);
@@ -1610,67 +1732,99 @@ ReadIconOrCursorFromFile(Tcl_Interp* interp, Tcl_Obj* fileName, BOOL isIcon)
ckfree( (char*)lpIR );
return NULL;
}
- /* Read in the icon directory entries */
- dwBytesRead = Tcl_Read(channel, (char*)lpIDE,
- lpIR->nNumImages * sizeof( ICONDIRENTRY ));
+
+ /*
+ * Read in the icon directory entries.
+ */
+
+ dwBytesRead = Tcl_Read(channel, (char*)lpIDE,
+ lpIR->nNumImages * sizeof(ICONDIRENTRY));
if (dwBytesRead != lpIR->nNumImages * sizeof( ICONDIRENTRY )) {
- Tcl_AppendResult(interp,"Error reading file",(char*)NULL);
+ Tcl_AppendResult(interp, "Error reading file", NULL);
Tcl_Close(NULL, channel);
- ckfree( (char*)lpIR );
+ ckfree((char*) lpIR);
return NULL;
}
- /* NULL-out everything to make memory management easier */
- for( i = 0; i < lpIR->nNumImages; i++ ) {
+
+ /*
+ * NULL-out everything to make memory management easier.
+ */
+
+ for (i = 0; i < lpIR->nNumImages; i++) {
lpIR->IconImages[i].lpBits = NULL;
}
- /* Loop through and read in each image */
+
+ /*
+ * Loop through and read in each image.
+ */
+
for( i = 0; i < lpIR->nNumImages; i++ ) {
- /* Allocate memory for the resource */
+ /*
+ * Allocate memory for the resource.
+ */
+
lpIR->IconImages[i].lpBits = (LPBYTE) ckalloc(lpIDE[i].dwBytesInRes);
if (lpIR->IconImages[i].lpBits == NULL) {
- Tcl_AppendResult(interp,"Error allocating memory",(char*)NULL);
+ Tcl_AppendResult(interp, "Error allocating memory", NULL);
goto readError;
}
lpIR->IconImages[i].dwNumBytes = lpIDE[i].dwBytesInRes;
- /* Seek to beginning of this image */
+
+ /*
+ * Seek to beginning of this image.
+ */
+
if (Tcl_Seek(channel, lpIDE[i].dwImageOffset, FILE_BEGIN) == -1) {
- Tcl_AppendResult(interp,"Error seeking in file",(char*)NULL);
+ Tcl_AppendResult(interp, "Error seeking in file", NULL);
goto readError;
}
- /* Read it in */
- dwBytesRead = Tcl_Read( channel, lpIR->IconImages[i].lpBits,
- lpIDE[i].dwBytesInRes);
+
+ /*
+ * Read it in.
+ */
+
+ dwBytesRead = Tcl_Read( channel, lpIR->IconImages[i].lpBits,
+ lpIDE[i].dwBytesInRes);
if (dwBytesRead != lpIDE[i].dwBytesInRes) {
- Tcl_AppendResult(interp,"Error reading file",(char*)NULL);
+ Tcl_AppendResult(interp, "Error reading file", NULL);
goto readError;
}
- /* Set the internal pointers appropriately */
+
+ /*
+ * Set the internal pointers appropriately.
+ */
+
if (!AdjustIconImagePointers( &(lpIR->IconImages[i]))) {
- Tcl_AppendResult(interp,"Error converting to internal format",
- (char*)NULL);
+ Tcl_AppendResult(interp, "Error converting to internal format",
+ NULL);
goto readError;
}
lpIR->IconImages[i].hIcon =
MakeIconOrCursorFromResource(&(lpIR->IconImages[i]), isIcon);
}
- /* Clean up */
+
+ /*
+ * Clean up
+ */
+
ckfree((char*)lpIDE);
Tcl_Close(NULL, channel);
if (lpIR == NULL){
- Tcl_AppendResult(interp,"Reading of ", Tcl_GetString(fileName),
- " failed!",(char*)NULL);
+ Tcl_AppendResult(interp, "Reading of ", Tcl_GetString(fileName),
+ " failed!", NULL);
return NULL;
}
return lpIR;
+
readError:
Tcl_Close(NULL, channel);
- for( i = 0; i < lpIR->nNumImages; i++ ) {
+ for (i = 0; i < lpIR->nNumImages; i++) {
if (lpIR->IconImages[i].lpBits != NULL) {
- ckfree((char*)lpIR->IconImages[i].lpBits);
+ ckfree((char*) lpIR->IconImages[i].lpBits);
}
}
- ckfree((char*)lpIDE );
- ckfree((char*)lpIR );
+ ckfree((char*) lpIDE);
+ ckfree((char*) lpIR);
return NULL;
}
@@ -1679,8 +1833,7 @@ ReadIconOrCursorFromFile(Tcl_Interp* interp, Tcl_Obj* fileName, BOOL isIcon)
*
* GetTopLevel --
*
- * This function retrieves the TkWindow associated with the
- * given HWND.
+ * This function retrieves the TkWindow associated with the given HWND.
*
* Results:
* Returns the matching TkWindow.
@@ -1690,17 +1843,18 @@ ReadIconOrCursorFromFile(Tcl_Interp* interp, Tcl_Obj* fileName, BOOL isIcon)
*
*----------------------------------------------------------------------
*/
+
static TkWindow *
-GetTopLevel(hwnd)
- HWND hwnd;
+GetTopLevel(
+ HWND hwnd)
{
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
- * If this function is called before the CreateWindowEx call
- * has completed, then the user data slot will not have been
- * set yet, so we use the global createWindow variable.
+ * If this function is called before the CreateWindowEx call has
+ * completed, then the user data slot will not have been set yet, so we
+ * use the global createWindow variable.
*/
if (tsdPtr->createWindow) {
@@ -1724,16 +1878,16 @@ GetTopLevel(hwnd)
* None.
*
* Side effects:
- * Changes the values of the info pointer to reflect the current
- * minimum and maximum size values.
+ * Changes the values of the info pointer to reflect the current minimum
+ * and maximum size values.
*
*----------------------------------------------------------------------
*/
static void
-SetLimits(hwnd, info)
- HWND hwnd;
- MINMAXINFO *info;
+SetLimits(
+ HWND hwnd,
+ MINMAXINFO *info)
{
register WmInfo *wmPtr;
int maxWidth, maxHeight;
@@ -1783,8 +1937,8 @@ SetLimits(hwnd, info)
}
/*
- * If the window isn't supposed to be resizable, then set the
- * minimum and maximum dimensions to be the same as the current size.
+ * If the window isn't supposed to be resizable, then set the minimum and
+ * maximum dimensions to be the same as the current size.
*/
if (!(wmPtr->flags & WM_SYNC_PENDING)) {
@@ -1806,8 +1960,8 @@ SetLimits(hwnd, info)
*
* TkWinWmCleanup --
*
- * Unregisters classes registered by the window manager. This is
- * called from the DLL main entry point when the DLL is unloaded.
+ * Unregisters classes registered by the window manager. This is called
+ * from the DLL main entry point when the DLL is unloaded.
*
* Results:
* None.
@@ -1819,14 +1973,14 @@ SetLimits(hwnd, info)
*/
void
-TkWinWmCleanup(hInstance)
- HINSTANCE hInstance;
+TkWinWmCleanup(
+ HINSTANCE hInstance)
{
ThreadSpecificData *tsdPtr;
/*
- * If we're using stubs to access the Tcl library, and they
- * haven't been initialized, we can't call Tcl_GetThreadData.
+ * If we're using stubs to access the Tcl library, and they haven't been
+ * initialized, we can't call Tcl_GetThreadData.
*/
#ifdef USE_TCL_STUBS
@@ -1849,10 +2003,12 @@ TkWinWmCleanup(hInstance)
tsdPtr->initialized = 0;
UnregisterClass(TK_WIN_TOPLEVEL_CLASS_NAME, hInstance);
+
#ifndef TCL_THREADS
/*
* Clean up specialized class created for layered windows.
*/
+
if (setLayeredWindowAttributesProc != NULL) {
UnregisterClass(TK_WIN_TOPLEVEL_NOCDC_CLASS_NAME, hInstance);
setLayeredWindowAttributesProc = NULL;
@@ -1865,9 +2021,8 @@ TkWinWmCleanup(hInstance)
*
* TkWmNewWindow --
*
- * This procedure is invoked whenever a new top-level
- * window is created. Its job is to initialize the WmInfo
- * structure for the window.
+ * This function is invoked whenever a new top-level window is created.
+ * Its job is to initialize the WmInfo structure for the window.
*
* Results:
* None.
@@ -1879,8 +2034,8 @@ TkWinWmCleanup(hInstance)
*/
void
-TkWmNewWindow(winPtr)
- TkWindow *winPtr; /* Newly-created top-level window. */
+TkWmNewWindow(
+ TkWindow *winPtr) /* Newly-created top-level window. */
{
register WmInfo *wmPtr;
@@ -1889,6 +2044,7 @@ TkWmNewWindow(winPtr)
/*
* Initialize full structure, then set what isn't NULL
*/
+
ZeroMemory(wmPtr, sizeof(WmInfo));
winPtr->wmInfoPtr = wmPtr;
wmPtr->winPtr = winPtr;
@@ -1928,16 +2084,16 @@ TkWmNewWindow(winPtr)
winPtr->dispPtr->firstWmPtr = wmPtr;
/*
- * Tk must monitor structure events for top-level windows, in order
- * to detect size and position changes caused by window managers.
+ * Tk must monitor structure events for top-level windows, in order to
+ * detect size and position changes caused by window managers.
*/
Tk_CreateEventHandler((Tk_Window) winPtr, StructureNotifyMask,
TopLevelEventProc, (ClientData) winPtr);
/*
- * Arrange for geometry requests to be reflected from the window
- * to the window manager.
+ * Arrange for geometry requests to be reflected from the window to the
+ * window manager.
*/
Tk_ManageGeometry((Tk_Window) winPtr, &wmMgrType, (ClientData) 0);
@@ -1948,24 +2104,23 @@ TkWmNewWindow(winPtr)
*
* UpdateWrapper --
*
- * This function creates the wrapper window that contains the
- * window decorations and menus for a toplevel. This function
- * may be called after a window is mapped to change the window
- * style.
+ * This function creates the wrapper window that contains the window
+ * decorations and menus for a toplevel. This function may be called
+ * after a window is mapped to change the window style.
*
* Results:
* None.
*
* Side effects:
- * Destroys any old wrapper window and replaces it with a newly
- * created wrapper.
+ * Destroys any old wrapper window and replaces it with a newly created
+ * wrapper.
*
*----------------------------------------------------------------------
*/
static void
-UpdateWrapper(winPtr)
- TkWindow *winPtr; /* Top-level window to redecorate. */
+UpdateWrapper(
+ TkWindow *winPtr) /* Top-level window to redecorate. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
HWND parentHWND, oldWrapper = wmPtr->wrapper;
@@ -1983,15 +2138,18 @@ UpdateWrapper(winPtr)
/*
* Ensure existence of the window to update the wrapper for.
*/
+
Tk_MakeWindowExist((Tk_Window) winPtr);
}
child = TkWinGetHWND(winPtr->window);
parentHWND = NULL;
+
/*
- * nextHWND will help us maintain Z order.
- * focusHWND will help us maintain focus, if we had it.
+ * nextHWND will help us maintain Z order. focusHWND will help us maintain
+ * focus, if we had it.
*/
+
nextHWND = NULL;
focusHWND = GetFocus();
if ((oldWrapper == NULL) || (oldWrapper != GetForegroundWindow())) {
@@ -2009,13 +2167,13 @@ UpdateWrapper(winPtr)
} else {
/*
- * Pick the decorative frame style. Override redirect windows get
+ * Pick the decorative frame style. Override redirect windows get
* created as undecorated popups if they have no transient parent,
- * otherwise they are children. This allows splash screens to operate
+ * otherwise they are children. This allows splash screens to operate
* as an independent window, while having dropdows (like for a
- * combobox) not grab focus away from their parent. Transient windows
- * get a modal dialog frame. Neither override, nor transient windows
- * appear in the Windows taskbar. Note that a transient window does
+ * combobox) not grab focus away from their parent. Transient windows
+ * get a modal dialog frame. Neither override, nor transient windows
+ * appear in the Windows taskbar. Note that a transient window does
* not resize by default, so we need to explicitly add the
* WS_THICKFRAME style if we want it to be resizeable.
*/
@@ -2023,7 +2181,11 @@ UpdateWrapper(winPtr)
if (winPtr->atts.override_redirect) {
wmPtr->style = WM_OVERRIDE_STYLE;
wmPtr->exStyle = EX_OVERRIDE_STYLE;
- /* parent must be desktop even if we have a transient parent */
+
+ /*
+ * Parent must be desktop even if we have a transient parent.
+ */
+
parentHWND = GetDesktopWindow();
if (wmPtr->masterPtr) {
wmPtr->style |= WS_CHILD;
@@ -2067,9 +2229,9 @@ UpdateWrapper(winPtr)
/*
* Set the initial position from the user or program specified
- * location. If nothing has been specified, then let the system
- * pick a location. In full screen mode the x,y origin is 0,0
- * and the window width and height match that of the screen.
+ * location. If nothing has been specified, then let the system pick a
+ * location. In full screen mode the x,y origin is 0,0 and the window
+ * width and height match that of the screen.
*/
if (wmPtr->flags & WM_FULLSCREEN) {
@@ -2087,13 +2249,14 @@ UpdateWrapper(winPtr)
}
/*
- * Create the containing window, and set the user data to point
- * to the TkWindow.
+ * Create the containing window, and set the user data to point to the
+ * TkWindow.
*/
tsdPtr->createWindow = winPtr;
Tcl_WinUtfToTChar(((wmPtr->title != NULL) ?
wmPtr->title : winPtr->nameUid), -1, &titleString);
+
#ifndef TCL_THREADS
/*
* Transparent windows require a non-CS_CLASSDC window class.
@@ -2104,7 +2267,10 @@ UpdateWrapper(winPtr)
-1, &classString);
} else
#endif
+ {
Tcl_WinUtfToTChar(TK_WIN_TOPLEVEL_CLASS_NAME, -1, &classString);
+ }
+
wmPtr->wrapper = (*tkWinProcs->createWindowEx)(wmPtr->exStyle,
(LPCTSTR) Tcl_DStringValue(&classString),
(LPCTSTR) Tcl_DStringValue(&titleString),
@@ -2123,9 +2289,10 @@ UpdateWrapper(winPtr)
&& setLayeredWindowAttributesProc != NULL) {
/*
* The user supplies a double from [0..1], but Windows wants an
- * int (transparent) 0..255 (opaque), so do the translation.
- * Add the 0.5 to round the value.
+ * int (transparent) 0..255 (opaque), so do the translation. Add
+ * the 0.5 to round the value.
*/
+
setLayeredWindowAttributesProc((HWND) wmPtr->wrapper,
(COLORREF) NULL, (BYTE) (wmPtr->alpha * 255 + 0.5),
LWA_ALPHA);
@@ -2150,14 +2317,15 @@ UpdateWrapper(winPtr)
* We will adjust wrapper to have the same Z order as oldWrapper
* if it isn't a TOPMOST window.
*/
+
nextHWND = GetNextWindow(oldWrapper, GW_HWNDPREV);
}
}
/*
- * Now we need to reparent the contained window and set its
- * style appropriately. Be sure to update the style first so that
- * Windows doesn't try to set the focus to the child window.
+ * Now we need to reparent the contained window and set its style
+ * appropriately. Be sure to update the style first so that Windows
+ * doesn't try to set the focus to the child window.
*/
#ifdef _WIN64
@@ -2167,6 +2335,7 @@ UpdateWrapper(winPtr)
SetWindowLong(child, GWL_STYLE,
WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
#endif
+
if (winPtr->flags & TK_EMBEDDED) {
#ifdef _WIN64
SetWindowLongPtr(child, GWLP_WNDPROC, (LONG_PTR) TopLevelProc);
@@ -2174,6 +2343,7 @@ UpdateWrapper(winPtr)
SetWindowLong(child, GWL_WNDPROC, (LONG) TopLevelProc);
#endif
}
+
SetParent(child, wmPtr->wrapper);
if (oldWrapper) {
hSmallIcon = (HICON) SendMessage(oldWrapper, WM_GETICON, ICON_SMALL,
@@ -2195,21 +2365,22 @@ UpdateWrapper(winPtr)
* Unset the current wrapper as the parent for all transient
* children for whom this is the master
*/
+
WmInfo *wmPtr2;
- childStateInfo = (int *)ckalloc((unsigned) wmPtr->numTransients
- * sizeof(int));
+ childStateInfo = (int *)
+ ckalloc((unsigned) wmPtr->numTransients * sizeof(int));
state = 0;
for (wmPtr2 = winPtr->dispPtr->firstWmPtr; wmPtr2 != NULL;
- wmPtr2 = wmPtr2->nextPtr) {
- if (wmPtr2->masterPtr == winPtr) {
- if (!(wmPtr2->flags & WM_NEVER_MAPPED)) {
- childStateInfo[state++] = wmPtr2->hints.initial_state;
- SetParent(TkWinGetHWND(wmPtr2->winPtr->window), NULL);
- }
+ wmPtr2 = wmPtr2->nextPtr) {
+ if (wmPtr2->masterPtr == winPtr
+ && !(wmPtr2->flags & WM_NEVER_MAPPED)) {
+ childStateInfo[state++] = wmPtr2->hints.initial_state;
+ SetParent(TkWinGetHWND(wmPtr2->winPtr->window), NULL);
}
}
}
+
/*
* Remove the menubar before destroying the window so the menubar
* isn't destroyed.
@@ -2220,19 +2391,18 @@ UpdateWrapper(winPtr)
}
wmPtr->flags &= ~WM_NEVER_MAPPED;
- if (winPtr->flags & TK_EMBEDDED) {
- if(SendMessage(wmPtr->wrapper, TK_ATTACHWINDOW, (WPARAM) child, 0))
- {
- SendMessage(wmPtr->wrapper, TK_GEOMETRYREQ,
- Tk_ReqWidth((Tk_Window)winPtr), Tk_ReqHeight((Tk_Window)winPtr));
- SendMessage(wmPtr->wrapper, TK_SETMENU, (WPARAM)wmPtr->hMenu, (LPARAM)Tk_GetMenuHWND((Tk_Window)winPtr));
- }
+ if (winPtr->flags & TK_EMBEDDED
+ && SendMessage(wmPtr->wrapper, TK_ATTACHWINDOW, (WPARAM)child, 0)){
+ SendMessage(wmPtr->wrapper, TK_GEOMETRYREQ,
+ Tk_ReqWidth((Tk_Window)winPtr),
+ Tk_ReqHeight((Tk_Window)winPtr));
+ SendMessage(wmPtr->wrapper, TK_SETMENU, (WPARAM) wmPtr->hMenu,
+ (LPARAM) Tk_GetMenuHWND((Tk_Window) winPtr));
}
/*
- * Force an initial transition from withdrawn to the real
- * initial state. Set the Z order based on previous wrapper
- * before we set the state.
+ * Force an initial transition from withdrawn to the real initial state.
+ * Set the Z order based on previous wrapper before we set the state.
*/
state = wmPtr->hints.initial_state;
@@ -2253,12 +2423,11 @@ UpdateWrapper(winPtr)
}
/*
- * If we are embedded then force a mapping of the window now,
- * because we do not necessarily own the wrapper and may not
- * get another opportunity to map ourselves. We should not be
- * in either iconified or zoomed states when we get here, so
- * it is safe to just check for TK_EMBEDDED without checking
- * what state we are supposed to be in (default to NormalState).
+ * If we are embedded then force a mapping of the window now, because we
+ * do not necessarily own the wrapper and may not get another opportunity
+ * to map ourselves. We should not be in either iconified or zoomed states
+ * when we get here, so it is safe to just check for TK_EMBEDDED without
+ * checking what state we are supposed to be in (default to NormalState).
*/
if (winPtr->flags & TK_EMBEDDED) {
@@ -2282,18 +2451,18 @@ UpdateWrapper(winPtr)
if (childStateInfo) {
if (wmPtr->numTransients > 0) {
/*
- * Reset all transient children for whom this is the master
+ * Reset all transient children for whom this is the master.
*/
+
WmInfo *wmPtr2;
state = 0;
for (wmPtr2 = winPtr->dispPtr->firstWmPtr; wmPtr2 != NULL;
- wmPtr2 = wmPtr2->nextPtr) {
- if (wmPtr2->masterPtr == winPtr) {
- if ( !(wmPtr2->flags & WM_NEVER_MAPPED)) {
- UpdateWrapper(wmPtr2->winPtr);
- TkpWmSetState(wmPtr2->winPtr, childStateInfo[state++]);
- }
+ wmPtr2 = wmPtr2->nextPtr) {
+ if (wmPtr2->masterPtr == winPtr
+ && !(wmPtr2->flags & WM_NEVER_MAPPED)) {
+ UpdateWrapper(wmPtr2->winPtr);
+ TkpWmSetState(wmPtr2->winPtr, childStateInfo[state++]);
}
}
}
@@ -2302,11 +2471,11 @@ UpdateWrapper(winPtr)
}
/*
- * If this is the first window created by the application, then
- * we should activate the initial window. Otherwise, if this had
- * the focus, we need to restore that.
- * XXX: Rewrapping generates a <FocusOut> and <FocusIn> that would
- * XXX: best be avoided, if we could safely mask them.
+ * If this is the first window created by the application, then we should
+ * activate the initial window. Otherwise, if this had the focus, we need
+ * to restore that.
+ * XXX: Rewrapping generates a <FocusOut> and <FocusIn> that would best be
+ * XXX: avoided, if we could safely mask them.
*/
if (tsdPtr->firstWindow) {
@@ -2322,28 +2491,28 @@ UpdateWrapper(winPtr)
*
* TkWmMapWindow --
*
- * This procedure is invoked to map a top-level window. This
- * module gets a chance to update all window-manager-related
- * information in properties before the window manager sees
- * the map event and checks the properties. It also gets to
- * decide whether or not to even map the window after all.
+ * This function is invoked to map a top-level window. This module gets a
+ * chance to update all window-manager-related information in properties
+ * before the window manager sees the map event and checks the
+ * properties. It also gets to decide whether or not to even map the
+ * window after all.
*
* Results:
* None.
*
* Side effects:
- * Properties of winPtr may get updated to provide up-to-date
- * information to the window manager. The window may also get
- * mapped, but it may not be if this procedure decides that
- * isn't appropriate (e.g. because the window is withdrawn).
+ * Properties of winPtr may get updated to provide up-to-date information
+ * to the window manager. The window may also get mapped, but it may not
+ * be if this function decides that isn't appropriate (e.g. because the
+ * window is withdrawn).
*
*--------------------------------------------------------------
*/
void
-TkWmMapWindow(winPtr)
- TkWindow *winPtr; /* Top-level window that's about to
- * be mapped. */
+TkWmMapWindow(
+ TkWindow *winPtr) /* Top-level window that's about to be
+ * mapped. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
@@ -2369,7 +2538,7 @@ TkWmMapWindow(winPtr)
}
/*
- * Map the window in either the iconified or normal state. Note that
+ * Map the window in either the iconified or normal state. Note that
* we only send a map event if the window is in the normal state.
*/
@@ -2377,9 +2546,8 @@ TkWmMapWindow(winPtr)
}
/*
- * This is the first time this window has ever been mapped.
- * Store all the window-manager-related information for the
- * window.
+ * This is the first time this window has ever been mapped. Store all the
+ * window-manager-related information for the window.
*/
UpdateWrapper(winPtr);
@@ -2390,9 +2558,9 @@ TkWmMapWindow(winPtr)
*
* TkWmUnmapWindow --
*
- * This procedure is invoked to unmap a top-level window. The
- * only thing it does special is unmap the decorative frame before
- * unmapping the toplevel window.
+ * This function is invoked to unmap a top-level window. The only thing
+ * it does special is unmap the decorative frame before unmapping the
+ * toplevel window.
*
* Results:
* None.
@@ -2404,9 +2572,9 @@ TkWmMapWindow(winPtr)
*/
void
-TkWmUnmapWindow(winPtr)
- TkWindow *winPtr; /* Top-level window that's about to
- * be unmapped. */
+TkWmUnmapWindow(
+ TkWindow *winPtr) /* Top-level window that's about to be
+ * unmapped. */
{
TkpWmSetState(winPtr, WithdrawnState);
}
@@ -2416,8 +2584,8 @@ TkWmUnmapWindow(winPtr)
*
* TkpWmSetState --
*
- * Sets the window manager state for the wrapper window of a
- * given toplevel window.
+ * Sets the window manager state for the wrapper window of a given
+ * toplevel window.
*
* Results:
* None.
@@ -2429,9 +2597,9 @@ TkWmUnmapWindow(winPtr)
*/
void
-TkpWmSetState(winPtr, state)
- TkWindow *winPtr; /* Toplevel window to operate on. */
- int state; /* One of IconicState, ZoomState, NormalState,
+TkpWmSetState(
+ TkWindow *winPtr, /* Toplevel window to operate on. */
+ int state) /* One of IconicState, ZoomState, NormalState,
* or WithdrawnState. */
{
WmInfo *wmPtr = winPtr->wmInfoPtr;
@@ -2456,7 +2624,6 @@ TkpWmSetState(winPtr, state)
ShowWindow(wmPtr->wrapper, cmd);
wmPtr->flags &= ~WM_SYNC_PENDING;
}
-
/*
*----------------------------------------------------------------------
@@ -2474,11 +2641,10 @@ TkpWmSetState(winPtr, state)
*----------------------------------------------------------------------
*/
-static
-void
-TkpWmSetFullScreen(winPtr, full_screen_state)
- TkWindow *winPtr; /* Toplevel window to operate on. */
- int full_screen_state; /* True if window should be full screen */
+static void
+TkpWmSetFullScreen(
+ TkWindow *winPtr, /* Toplevel window to operate on. */
+ int full_screen_state) /* True if window should be full screen */
{
int changed = 0;
int full_screen = False;
@@ -2508,9 +2674,10 @@ TkpWmSetFullScreen(winPtr, full_screen_state)
wmPtr->y = wmPtr->configY;
}
- /* If the window has been mapped, then we need to
- * update the native wrapper window, and reset
- * the focus to the widget that had it before.
+ /*
+ * If the window has been mapped, then we need to update the native
+ * wrapper window, and reset the focus to the widget that had it
+ * before.
*/
if (!(wmPtr->flags & (WM_NEVER_MAPPED)
@@ -2520,7 +2687,7 @@ TkpWmSetFullScreen(winPtr, full_screen_state)
if (focusWinPtr = TkGetFocusWin(winPtr)) {
TkSetFocusWin(focusWinPtr, 1);
}
- }
+ }
}
}
@@ -2540,8 +2707,9 @@ TkpWmSetFullScreen(winPtr, full_screen_state)
*----------------------------------------------------------------------
*/
-int TkpWmGetState(winPtr)
- TkWindow *winPtr;
+int
+TkpWmGetState(
+ TkWindow *winPtr)
{
return winPtr->wmInfoPtr->hints.initial_state;
}
@@ -2551,9 +2719,8 @@ int TkpWmGetState(winPtr)
*
* TkWmDeadWindow --
*
- * This procedure is invoked when a top-level window is
- * about to be deleted. It cleans up the wm-related data
- * structures for the window.
+ * This function is invoked when a top-level window is about to be
+ * deleted. It cleans up the wm-related data structures for the window.
*
* Results:
* None.
@@ -2565,8 +2732,8 @@ int TkpWmGetState(winPtr)
*/
void
-TkWmDeadWindow(winPtr)
- TkWindow *winPtr; /* Top-level window that's being deleted. */
+TkWmDeadWindow(
+ TkWindow *winPtr) /* Top-level window that's being deleted. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
WmInfo *wmPtr2;
@@ -2658,10 +2825,11 @@ TkWmDeadWindow(winPtr)
}
if (wmPtr->masterPtr != NULL) {
wmPtr2 = wmPtr->masterPtr->wmInfoPtr;
+
/*
- * If we had a master, tell them that we aren't tied
- * to them anymore
+ * If we had a master, tell them that we aren't tied to them anymore.
*/
+
if (wmPtr2 != NULL) {
wmPtr2->numTransients--;
}
@@ -2688,10 +2856,11 @@ TkWmDeadWindow(winPtr)
}
if (wmPtr->iconPtr != NULL) {
/*
- * This may delete the icon resource data. I believe we
- * should do this after destroying the decorative frame,
- * because the decorative frame is using this icon.
+ * This may delete the icon resource data. I believe we should do this
+ * after destroying the decorative frame, because the decorative frame
+ * is using this icon.
*/
+
DecrIconRefCount(wmPtr->iconPtr);
}
@@ -2704,11 +2873,10 @@ TkWmDeadWindow(winPtr)
*
* TkWmSetClass --
*
- * This procedure is invoked whenever a top-level window's
- * class is changed. If the window has been mapped then this
- * procedure updates the window manager property for the
- * class. If the window hasn't been mapped, the update is
- * deferred until just before the first mapping.
+ * This function is invoked whenever a top-level window's class is
+ * changed. If the window has been mapped then this function updates the
+ * window manager property for the class. If the window hasn't been
+ * mapped, the update is deferred until just before the first mapping.
*
* Results:
* None.
@@ -2720,9 +2888,10 @@ TkWmDeadWindow(winPtr)
*/
void
-TkWmSetClass(winPtr)
- TkWindow *winPtr; /* Newly-created top-level window. */
+TkWmSetClass(
+ TkWindow *winPtr) /* Newly-created top-level window. */
{
+ /* Do nothing */
return;
}
@@ -2731,8 +2900,8 @@ TkWmSetClass(winPtr)
*
* Tk_WmObjCmd --
*
- * This procedure is invoked to process the "wm" Tcl command.
- * See the user documentation for details on what it does.
+ * This function is invoked to process the "wm" Tcl command. See the user
+ * documentation for details on what it does.
*
* Results:
* A standard Tcl result.
@@ -2745,12 +2914,11 @@ TkWmSetClass(winPtr)
/* ARGSUSED */
int
-Tk_WmObjCmd(clientData, interp, objc, objv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
+Tk_WmObjCmd(
+ ClientData clientData, /* Main window associated with interpreter. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *CONST objv[]) /* Argument objects. */
{
Tk_Window tkwin = (Tk_Window) clientData;
static CONST char *optionStrings[] = {
@@ -2762,7 +2930,8 @@ Tk_WmObjCmd(clientData, interp, objc, objv)
"iconwindow", "maxsize", "minsize", "overrideredirect",
"positionfrom", "protocol", "resizable", "sizefrom",
"stackorder", "state", "title", "transient",
- "withdraw", (char *) NULL };
+ "withdraw", NULL
+ };
enum options {
WMOPT_ASPECT, WMOPT_ATTRIBUTES, WMOPT_CLIENT, WMOPT_COLORMAPWINDOWS,
WMOPT_COMMAND, WMOPT_DEICONIFY, WMOPT_FOCUSMODEL, WMOPT_FRAME,
@@ -2772,14 +2941,15 @@ Tk_WmObjCmd(clientData, interp, objc, objv)
WMOPT_ICONWINDOW, WMOPT_MAXSIZE, WMOPT_MINSIZE, WMOPT_OVERRIDEREDIRECT,
WMOPT_POSITIONFROM, WMOPT_PROTOCOL, WMOPT_RESIZABLE, WMOPT_SIZEFROM,
WMOPT_STACKORDER, WMOPT_STATE, WMOPT_TITLE, WMOPT_TRANSIENT,
- WMOPT_WITHDRAW };
+ WMOPT_WITHDRAW
+ };
int index, length;
char *argv1;
TkWindow *winPtr;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
if (objc < 2) {
- wrongNumArgs:
+ wrongNumArgs:
Tcl_WrongNumArgs(interp, 1, objv, "option window ?arg ...?");
return TCL_ERROR;
}
@@ -2788,6 +2958,7 @@ Tk_WmObjCmd(clientData, interp, objc, objv)
if ((argv1[0] == 't') && (strncmp(argv1, "tracing", length) == 0)
&& (length >= 3)) {
int wmTracing;
+
if ((objc != 2) && (objc != 3)) {
Tcl_WrongNumArgs(interp, 2, objv, "?boolean?");
return TCL_ERROR;
@@ -2824,70 +2995,70 @@ Tk_WmObjCmd(clientData, interp, objc, objv)
}
if (!Tk_IsTopLevel(winPtr)) {
Tcl_AppendResult(interp, "window \"", winPtr->pathName,
- "\" isn't a top-level window", (char *) NULL);
+ "\" isn't a top-level window", NULL);
return TCL_ERROR;
}
switch ((enum options) index) {
- case WMOPT_ASPECT:
+ case WMOPT_ASPECT:
return WmAspectCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_ATTRIBUTES:
+ case WMOPT_ATTRIBUTES:
return WmAttributesCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_CLIENT:
+ case WMOPT_CLIENT:
return WmClientCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_COLORMAPWINDOWS:
+ case WMOPT_COLORMAPWINDOWS:
return WmColormapwindowsCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_COMMAND:
+ case WMOPT_COMMAND:
return WmCommandCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_DEICONIFY:
+ case WMOPT_DEICONIFY:
return WmDeiconifyCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_FOCUSMODEL:
+ case WMOPT_FOCUSMODEL:
return WmFocusmodelCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_FRAME:
+ case WMOPT_FRAME:
return WmFrameCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_GEOMETRY:
+ case WMOPT_GEOMETRY:
return WmGeometryCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_GRID:
+ case WMOPT_GRID:
return WmGridCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_GROUP:
+ case WMOPT_GROUP:
return WmGroupCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_ICONBITMAP:
+ case WMOPT_ICONBITMAP:
return WmIconbitmapCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_ICONIFY:
+ case WMOPT_ICONIFY:
return WmIconifyCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_ICONMASK:
+ case WMOPT_ICONMASK:
return WmIconmaskCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_ICONNAME:
+ case WMOPT_ICONNAME:
return WmIconnameCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_ICONPHOTO:
+ case WMOPT_ICONPHOTO:
return WmIconphotoCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_ICONPOSITION:
+ case WMOPT_ICONPOSITION:
return WmIconpositionCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_ICONWINDOW:
+ case WMOPT_ICONWINDOW:
return WmIconwindowCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_MAXSIZE:
+ case WMOPT_MAXSIZE:
return WmMaxsizeCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_MINSIZE:
+ case WMOPT_MINSIZE:
return WmMinsizeCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_OVERRIDEREDIRECT:
+ case WMOPT_OVERRIDEREDIRECT:
return WmOverrideredirectCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_POSITIONFROM:
+ case WMOPT_POSITIONFROM:
return WmPositionfromCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_PROTOCOL:
+ case WMOPT_PROTOCOL:
return WmProtocolCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_RESIZABLE:
+ case WMOPT_RESIZABLE:
return WmResizableCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_SIZEFROM:
+ case WMOPT_SIZEFROM:
return WmSizefromCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_STACKORDER:
+ case WMOPT_STACKORDER:
return WmStackorderCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_STATE:
+ case WMOPT_STATE:
return WmStateCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_TITLE:
+ case WMOPT_TITLE:
return WmTitleCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_TRANSIENT:
+ case WMOPT_TRANSIENT:
return WmTransientCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_WITHDRAW:
+ case WMOPT_WITHDRAW:
return WmWithdrawCmd(tkwin, winPtr, interp, objc, objv);
}
@@ -2900,8 +3071,8 @@ Tk_WmObjCmd(clientData, interp, objc, objv)
*
* WmAspectCmd --
*
- * This procedure is invoked to process the "wm aspect" Tcl command.
- * See the user documentation for details on what it does.
+ * This function is invoked to process the "wm aspect" Tcl command. See
+ * the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
@@ -2969,7 +3140,7 @@ WmAspectCmd(tkwin, winPtr, interp, objc, objv)
*
* WmAttributesCmd --
*
- * This procedure is invoked to process the "wm attributes" Tcl command.
+ * This function is invoked to process the "wm attributes" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
@@ -2997,7 +3168,7 @@ WmAttributesCmd(tkwin, winPtr, interp, objc, objv)
int fullscreen_attr_changed = 0, fullscreen_attr = 0;
if ((objc < 3) || ((objc > 5) && ((objc%2) == 0))) {
- configArgs:
+ configArgs:
Tcl_WrongNumArgs(interp, 2, objv,
"window"
" ?-alpha ?double??"
@@ -3057,8 +3228,7 @@ WmAttributesCmd(tkwin, winPtr, interp, objc, objv)
styleBit = WS_EX_TOPMOST;
if ((i < objc-1) && (winPtr->flags & TK_EMBEDDED)) {
Tcl_AppendResult(interp, "can't set topmost flag on ",
- winPtr->pathName, ": it is an embedded window",
- (char *) NULL);
+ winPtr->pathName, ": it is an embedded window", NULL);
return TCL_ERROR;
}
} else {
@@ -3075,11 +3245,13 @@ WmAttributesCmd(tkwin, winPtr, interp, objc, objv)
!= TCL_OK)) {
return TCL_ERROR;
}
+
/*
- * The user should give (transparent) 0 .. 1.0 (opaque),
- * but we ignore the setting of this (it will always be 1)
- * in the case that the API is not available.
+ * The user should give (transparent) 0 .. 1.0 (opaque), but
+ * we ignore the setting of this (it will always be 1) in the
+ * case that the API is not available.
*/
+
if (dval < 0.0) {
dval = 0;
} else if (dval > 1.0) {
@@ -3097,8 +3269,9 @@ WmAttributesCmd(tkwin, winPtr, interp, objc, objv)
* Set the window directly regardless of UpdateWrapper.
* The user supplies a double from [0..1], but Windows
* wants an int (transparent) 0..255 (opaque), so do the
- * translation. Add the 0.5 to round the value.
+ * translation. Add the 0.5 to round the value.
*/
+
setLayeredWindowAttributesProc((HWND) wmPtr->wrapper,
(COLORREF) NULL, (BYTE) (wmPtr->alpha * 255 + 0.5),
LWA_ALPHA);
@@ -3142,9 +3315,10 @@ WmAttributesCmd(tkwin, winPtr, interp, objc, objv)
}
if (wmPtr->styleConfig != style) {
/*
- * Currently this means only WS_DISABLED changed, which we can
- * effect with EnableWindow.
+ * Currently this means only WS_DISABLED changed, which we can effect
+ * with EnableWindow.
*/
+
wmPtr->styleConfig = style;
if ((wmPtr->exStyleConfig == exStyle)
&& !(wmPtr->flags & WM_NEVER_MAPPED)) {
@@ -3153,9 +3327,10 @@ WmAttributesCmd(tkwin, winPtr, interp, objc, objv)
}
if (wmPtr->exStyleConfig != exStyle) {
/*
- * UpdateWrapper ensure that all effects are properly handled,
- * such as TOOLWINDOW disappearing from the taskbar.
+ * UpdateWrapper ensure that all effects are properly handled, such as
+ * TOOLWINDOW disappearing from the taskbar.
*/
+
wmPtr->exStyleConfig = exStyle;
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
UpdateWrapper(winPtr);
@@ -3164,24 +3339,27 @@ WmAttributesCmd(tkwin, winPtr, interp, objc, objv)
if (fullscreen_attr_changed) {
if (fullscreen_attr) {
if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) {
- Tcl_AppendResult(interp, "can't set fullscreen attribute for \"",
- winPtr->pathName,
- "\": override-redirect flag is set",
- (char *) NULL);
+ Tcl_AppendResult(interp,
+ "can't set fullscreen attribute for \"",
+ winPtr->pathName, "\": override-redirect flag is set",
+ NULL);
return TCL_ERROR;
}
- /* Check max width and height if set by the user,
- * don't worry about the default values since they
- * will likely be smaller than screen width/height.
+
+ /*
+ * Check max width and height if set by the user, don't worry
+ * about the default values since they will likely be smaller than
+ * screen width/height.
*/
+
if (((wmPtr->maxWidth > 0) &&
(WidthOfScreen(Tk_Screen(winPtr)) > wmPtr->maxWidth)) ||
((wmPtr->maxHeight > 0) &&
(HeightOfScreen(Tk_Screen(winPtr)) > wmPtr->maxHeight))) {
- Tcl_AppendResult(interp, "can't set fullscreen attribute for \"",
- winPtr->pathName,
- "\": max width/height is too small",
- (char *) NULL);
+ Tcl_AppendResult(interp,
+ "can't set fullscreen attribute for \"",
+ winPtr->pathName, "\": max width/height is too small",
+ NULL);
return TCL_ERROR;
}
}
@@ -3197,8 +3375,8 @@ WmAttributesCmd(tkwin, winPtr, interp, objc, objv)
*
* WmClientCmd --
*
- * This procedure is invoked to process the "wm client" Tcl command.
- * See the user documentation for details on what it does.
+ * This function is invoked to process the "wm client" Tcl command. See
+ * the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
@@ -3238,8 +3416,7 @@ WmClientCmd(tkwin, winPtr, interp, objc, objv)
wmPtr->clientMachine = NULL;
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
XDeleteProperty(winPtr->display, winPtr->window,
- Tk_InternAtom((Tk_Window) winPtr,
- "WM_CLIENT_MACHINE"));
+ Tk_InternAtom((Tk_Window) winPtr,"WM_CLIENT_MACHINE"));
}
}
return TCL_OK;
@@ -3252,6 +3429,7 @@ WmClientCmd(tkwin, winPtr, interp, objc, objv)
strcpy(wmPtr->clientMachine, argv3);
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
XTextProperty textProp;
+
if (XStringListToTextProperty(&wmPtr->clientMachine, 1, &textProp)
!= 0) {
XSetWMClientMachine(winPtr->display, winPtr->window,
@@ -3267,9 +3445,8 @@ WmClientCmd(tkwin, winPtr, interp, objc, objv)
*
* WmColormapwindowsCmd --
*
- * This procedure is invoked to process the "wm colormapwindows"
- * Tcl command.
- * See the user documentation for details on what it does.
+ * This function is invoked to process the "wm colormapwindows" Tcl
+ * command. See the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
@@ -3362,8 +3539,8 @@ WmColormapwindowsCmd(tkwin, winPtr, interp, objc, objv)
*
* WmCommandCmd --
*
- * This procedure is invoked to process the "wm command" Tcl command.
- * See the user documentation for details on what it does.
+ * This function is invoked to process the "wm command" Tcl command. See
+ * the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
@@ -3394,8 +3571,7 @@ WmCommandCmd(tkwin, winPtr, interp, objc, objv)
if (objc == 3) {
if (wmPtr->cmdArgv != NULL) {
Tcl_SetResult(interp,
- Tcl_Merge(wmPtr->cmdArgc, wmPtr->cmdArgv),
- TCL_DYNAMIC);
+ Tcl_Merge(wmPtr->cmdArgc, wmPtr->cmdArgv), TCL_DYNAMIC);
}
return TCL_OK;
}
@@ -3430,7 +3606,7 @@ WmCommandCmd(tkwin, winPtr, interp, objc, objv)
*
* WmDeiconifyCmd --
*
- * This procedure is invoked to process the "wm deiconify" Tcl command.
+ * This function is invoked to process the "wm deiconify" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
@@ -3458,14 +3634,13 @@ WmDeiconifyCmd(tkwin, winPtr, interp, objc, objv)
}
if (wmPtr->iconFor != NULL) {
Tcl_AppendResult(interp, "can't deiconify ", Tcl_GetString(objv[2]),
- ": it is an icon for ", Tk_PathName(wmPtr->iconFor),
- (char *) NULL);
+ ": it is an icon for ", Tk_PathName(wmPtr->iconFor), NULL);
return TCL_ERROR;
}
if (winPtr->flags & TK_EMBEDDED) {
- if(!SendMessage(wmPtr->wrapper, TK_DEICONIFY, 0, 0)) {
+ if (!SendMessage(wmPtr->wrapper, TK_DEICONIFY, 0, 0)) {
Tcl_AppendResult(interp, "can't deiconify ", winPtr->pathName,
- ": the container does not support the request", (char *) NULL);
+ ": the container does not support the request", NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -3479,7 +3654,7 @@ WmDeiconifyCmd(tkwin, winPtr, interp, objc, objv)
*
* WmFocusmodelCmd --
*
- * This procedure is invoked to process the "wm focusmodel" Tcl command.
+ * This function is invoked to process the "wm focusmodel" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
@@ -3501,9 +3676,11 @@ WmFocusmodelCmd(tkwin, winPtr, interp, objc, objv)
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
static CONST char *optionStrings[] = {
- "active", "passive", (char *) NULL };
+ "active", "passive", NULL
+ };
enum options {
- OPT_ACTIVE, OPT_PASSIVE };
+ OPT_ACTIVE, OPT_PASSIVE
+ };
int index;
if ((objc != 3) && (objc != 4)) {
@@ -3533,8 +3710,8 @@ WmFocusmodelCmd(tkwin, winPtr, interp, objc, objv)
*
* WmFrameCmd --
*
- * This procedure is invoked to process the "wm frame" Tcl command.
- * See the user documentation for details on what it does.
+ * This function is invoked to process the "wm frame" Tcl command. See
+ * the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
@@ -3578,7 +3755,7 @@ WmFrameCmd(tkwin, winPtr, interp, objc, objv)
*
* WmGeometryCmd --
*
- * This procedure is invoked to process the "wm geometry" Tcl command.
+ * This function is invoked to process the "wm geometry" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
@@ -3610,6 +3787,7 @@ WmGeometryCmd(tkwin, winPtr, interp, objc, objv)
if (objc == 3) {
char buf[16 + TCL_INTEGER_SPACE * 4];
int x, y;
+
xSign = (wmPtr->flags & WM_NEGATIVE_X) ? '-' : '+';
ySign = (wmPtr->flags & WM_NEGATIVE_Y) ? '-' : '+';
if (wmPtr->gridWin != NULL) {
@@ -3625,7 +3803,7 @@ WmGeometryCmd(tkwin, winPtr, interp, objc, objv)
int result = SendMessage(wmPtr->wrapper, TK_MOVEWINDOW, -1, -1);
wmPtr->x = result >> 16;
wmPtr->y = result & 0x0000ffff;
- }
+ }
x = wmPtr->x;
y = wmPtr->y;
sprintf(buf, "%dx%d%c%d%c%d", width, height, xSign, x, ySign, y);
@@ -3647,8 +3825,8 @@ WmGeometryCmd(tkwin, winPtr, interp, objc, objv)
*
* WmGridCmd --
*
- * This procedure is invoked to process the "wm grid" Tcl command.
- * See the user documentation for details on what it does.
+ * This function is invoked to process the "wm grid" Tcl command. See the
+ * user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
@@ -3688,8 +3866,8 @@ WmGridCmd(tkwin, winPtr, interp, objc, objv)
}
if (*Tcl_GetString(objv[3]) == '\0') {
/*
- * Turn off gridding and reset the width and height
- * to make sense as ungridded numbers.
+ * Turn off gridding and reset the width and height to make sense as
+ * ungridded numbers.
*/
wmPtr->sizeHintsFlags &= ~(PBaseSize|PResizeInc);
@@ -3736,8 +3914,8 @@ WmGridCmd(tkwin, winPtr, interp, objc, objv)
*
* WmGroupCmd --
*
- * This procedure is invoked to process the "wm group" Tcl command.
- * See the user documentation for details on what it does.
+ * This function is invoked to process the "wm group" Tcl command. See
+ * the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
@@ -3799,7 +3977,7 @@ WmGroupCmd(tkwin, winPtr, interp, objc, objv)
*
* WmIconbitmapCmd --
*
- * This procedure is invoked to process the "wm iconbitmap" Tcl command.
+ * This function is invoked to process the "wm iconbitmap" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
@@ -3827,17 +4005,23 @@ WmIconbitmapCmd(tkwin, winPtr, interp, objc, objv)
Tcl_WrongNumArgs(interp, 2, objv, "window ?-default? ?image?");
return TCL_ERROR;
} else if (objc == 5) {
- /* If we have 5 arguments, we must have a '-default' flag */
+ /*
+ * If we have 5 arguments, we must have a '-default' flag.
+ */
+
char *argv3 = Tcl_GetString(objv[3]);
+
if (strcmp(argv3, "-default")) {
Tcl_AppendResult(interp, "illegal option \"",
- argv3, "\" must be \"-default\"",
- (char *) NULL);
+ argv3, "\" must be \"-default\"", NULL);
return TCL_ERROR;
}
useWinPtr = NULL;
} else if (objc == 3) {
- /* No arguments were given */
+ /*
+ * No arguments were given.
+ */
+
if (wmPtr->hints.flags & IconPixmapHint) {
Tcl_SetResult(interp, (char *)
Tk_NameOfBitmap(winPtr->display, wmPtr->hints.icon_pixmap),
@@ -3859,42 +4043,46 @@ WmIconbitmapCmd(tkwin, winPtr, interp, objc, objv)
} else {
/*
* In the future this block of code will use Tk's 'image'
- * functionality to allow all supported image formats.
- * However, this will require a change to the way icons are
- * handled. We will need to add icon<->image conversions
- * routines.
+ * functionality to allow all supported image formats. However, this
+ * will require a change to the way icons are handled. We will need to
+ * add icon<->image conversions routines.
*
- * Until that happens we simply try to find an icon in the
- * given argument, and if that fails, we use the older
- * bitmap code. We do things this way round (icon then
- * bitmap), because the bitmap code actually seems to have
- * no visible effect, so we want to give the icon code the
- * first try at doing something.
+ * Until that happens we simply try to find an icon in the given
+ * argument, and if that fails, we use the older bitmap code. We do
+ * things this way round (icon then bitmap), because the bitmap code
+ * actually seems to have no visible effect, so we want to give the
+ * icon code the first try at doing something.
*/
/*
- * Either return NULL, or return a valid titlebaricon with its
- * ref count already incremented.
+ * Either return NULL, or return a valid titlebaricon with its ref
+ * count already incremented.
*/
+
WinIconPtr titlebaricon = ReadIconFromFile(interp, objv[objc-1]);
if (titlebaricon != NULL) {
/*
- * Try to set the icon for the window. If it is a '-default'
- * icon, we must pass in NULL
+ * Try to set the icon for the window. If it is a '-default' icon,
+ * we must pass in NULL
*/
+
if (WinSetIcon(interp, titlebaricon, (Tk_Window) useWinPtr)
!= TCL_OK) {
- /* We didn't use the titlebaricon after all */
+ /*
+ * We didn't use the titlebaricon after all.
+ */
+
DecrIconRefCount(titlebaricon);
titlebaricon = NULL;
}
}
if (titlebaricon == NULL) {
/*
- * We didn't manage to handle the argument as a valid
- * icon. Try as a bitmap. First we must clear the
- * error message which was placed in the interpreter
+ * We didn't manage to handle the argument as a valid icon. Try as
+ * a bitmap. First we must clear the error message which was
+ * placed in the interpreter.
*/
+
Pixmap pixmap;
Tcl_ResetResult(interp);
pixmap = Tk_GetBitmap(interp, (Tk_Window) winPtr, string);
@@ -3904,13 +4092,14 @@ WmIconbitmapCmd(tkwin, winPtr, interp, objc, objv)
wmPtr->hints.icon_pixmap = pixmap;
wmPtr->hints.flags |= IconPixmapHint;
titlebaricon = GetIconFromPixmap(Tk_Display(winPtr), pixmap);
- if (titlebaricon != NULL) {
- if (WinSetIcon(interp, titlebaricon, (Tk_Window) useWinPtr)
- != TCL_OK) {
- /* We didn't use the titlebaricon after all */
- DecrIconRefCount(titlebaricon);
- titlebaricon = NULL;
- }
+ if (titlebaricon != NULL && WinSetIcon(interp, titlebaricon,
+ (Tk_Window) useWinPtr) != TCL_OK) {
+ /*
+ * We didn't use the titlebaricon after all.
+ */
+
+ DecrIconRefCount(titlebaricon);
+ titlebaricon = NULL;
}
}
}
@@ -3922,8 +4111,8 @@ WmIconbitmapCmd(tkwin, winPtr, interp, objc, objv)
*
* WmIconifyCmd --
*
- * This procedure is invoked to process the "wm iconify" Tcl command.
- * See the user documentation for details on what it does.
+ * This function is invoked to process the "wm iconify" Tcl command. See
+ * the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
@@ -3950,24 +4139,23 @@ WmIconifyCmd(tkwin, winPtr, interp, objc, objv)
if (winPtr->flags & TK_EMBEDDED) {
if(!SendMessage(wmPtr->wrapper, TK_ICONIFY, 0, 0)) {
Tcl_AppendResult(interp, "can't iconify ", winPtr->pathName,
- ": the container does not support the request", (char *) NULL);
+ ": the container does not support the request", NULL);
return TCL_ERROR;
}
}
if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) {
Tcl_AppendResult(interp, "can't iconify \"", winPtr->pathName,
- "\": override-redirect flag is set", (char *) NULL);
+ "\": override-redirect flag is set", NULL);
return TCL_ERROR;
}
if (wmPtr->masterPtr != NULL) {
Tcl_AppendResult(interp, "can't iconify \"", winPtr->pathName,
- "\": it is a transient", (char *) NULL);
+ "\": it is a transient", NULL);
return TCL_ERROR;
}
if (wmPtr->iconFor != NULL) {
Tcl_AppendResult(interp, "can't iconify ", winPtr->pathName,
- ": it is an icon for ", Tk_PathName(wmPtr->iconFor),
- (char *) NULL);
+ ": it is an icon for ", Tk_PathName(wmPtr->iconFor), NULL);
return TCL_ERROR;
}
TkpWmSetState(winPtr, IconicState);
@@ -3979,7 +4167,7 @@ WmIconifyCmd(tkwin, winPtr, interp, objc, objv)
*
* WmIconmaskCmd --
*
- * This procedure is invoked to process the "wm iconmask" Tcl command.
+ * This function is invoked to process the "wm iconmask" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
@@ -4037,7 +4225,7 @@ WmIconmaskCmd(tkwin, winPtr, interp, objc, objv)
*
* WmIconnameCmd --
*
- * This procedure is invoked to process the "wm iconname" Tcl command.
+ * This function is invoked to process the "wm iconname" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
@@ -4089,8 +4277,7 @@ WmIconnameCmd(tkwin, winPtr, interp, objc, objv)
*
* WmIconphotoCmd --
*
- * This procedure is invoked to process the "wm iconphoto"
- * Tcl command.
+ * This function is invoked to process the "wm iconphoto" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
@@ -4124,9 +4311,11 @@ WmIconphotoCmd(tkwin, winPtr, interp, objc, objv)
"window ?-default? image1 ?image2 ...?");
return TCL_ERROR;
}
+
/*
* Iterate over all images to validate their existence.
*/
+
if (strcmp(Tcl_GetString(objv[3]), "-default") == 0) {
useWinPtr = NULL;
startObj = 4;
@@ -4144,10 +4333,13 @@ WmIconphotoCmd(tkwin, winPtr, interp, objc, objv)
return TCL_ERROR;
}
}
- /* We have calculated the size of the data. Try to allocate the needed
- * memory space. */
- size = sizeof(BlockOfIconImages)
- + (sizeof(ICONIMAGE) * (objc - (startObj+1)));
+
+ /*
+ * We have calculated the size of the data. Try to allocate the needed
+ * memory space.
+ */
+
+ size = sizeof(BlockOfIconImages) + (sizeof(ICONIMAGE) * (objc-startObj-1));
lpIR = (BlockOfIconImagesPtr) Tcl_AttemptAlloc(size);
if (lpIR == NULL) {
return TCL_ERROR;
@@ -4163,13 +4355,17 @@ WmIconphotoCmd(tkwin, winPtr, interp, objc, objv)
/*
* Encode the image data into an HICON.
*/
+
hIcon = CreateIcon(Tk_GetHINSTANCE(), width, height, 1, 32,
NULL, (BYTE *) block.pixelPtr);
if (hIcon == NULL) {
- /* XXX should free up created icons */
+ /*
+ * XXX should free up created icons.
+ */
+
Tcl_Free((char *) lpIR);
Tcl_AppendResult(interp, "failed to create icon for \"",
- Tcl_GetString(objv[i]), "\"", (char *) NULL);
+ Tcl_GetString(objv[i]), "\"", NULL);
return TCL_ERROR;
}
lpIR->IconImages[i-startObj].Width = width;
@@ -4181,7 +4377,10 @@ WmIconphotoCmd(tkwin, winPtr, interp, objc, objv)
titlebaricon->iconBlock = lpIR;
titlebaricon->refCount = 1;
if (WinSetIcon(interp, titlebaricon, (Tk_Window) useWinPtr) != TCL_OK) {
- /* We didn't use the titlebaricon after all */
+ /*
+ * We didn't use the titlebaricon after all.
+ */
+
DecrIconRefCount(titlebaricon);
return TCL_ERROR;
}
@@ -4193,8 +4392,7 @@ WmIconphotoCmd(tkwin, winPtr, interp, objc, objv)
*
* WmIconpositionCmd --
*
- * This procedure is invoked to process the "wm iconposition"
- * Tcl command.
+ * This function is invoked to process the "wm iconposition" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
@@ -4250,7 +4448,7 @@ WmIconpositionCmd(tkwin, winPtr, interp, objc, objv)
*
* WmIconwindowCmd --
*
- * This procedure is invoked to process the "wm iconwindow" Tcl command.
+ * This function is invoked to process the "wm iconwindow" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
@@ -4289,8 +4487,8 @@ WmIconwindowCmd(tkwin, winPtr, interp, objc, objv)
wmPtr->hints.flags &= ~IconWindowHint;
if (wmPtr->icon != NULL) {
/*
- * Let the window use button events again, then remove
- * it as icon window.
+ * Let the window use button events again, then remove it as icon
+ * window.
*/
atts.event_mask = Tk_Attributes(wmPtr->icon)->event_mask
@@ -4307,14 +4505,14 @@ WmIconwindowCmd(tkwin, winPtr, interp, objc, objv)
}
if (!Tk_IsTopLevel(tkwin2)) {
Tcl_AppendResult(interp, "can't use ", Tcl_GetString(objv[3]),
- " as icon window: not at top level", (char *) NULL);
+ " as icon window: not at top level", NULL);
return TCL_ERROR;
}
wmPtr2 = ((TkWindow *) tkwin2)->wmInfoPtr;
if (wmPtr2->iconFor != NULL) {
Tcl_AppendResult(interp, Tcl_GetString(objv[3]),
- " is already an icon for ",
- Tk_PathName(wmPtr2->iconFor), (char *) NULL);
+ " is already an icon for ", Tk_PathName(wmPtr2->iconFor),
+ NULL);
return TCL_ERROR;
}
if (wmPtr->icon != NULL) {
@@ -4331,10 +4529,9 @@ WmIconwindowCmd(tkwin, winPtr, interp, objc, objv)
}
/*
- * Disable button events in the icon window: some window
- * managers (like olvwm) want to get the events themselves,
- * but X only allows one application at a time to receive
- * button events for a window.
+ * Disable button events in the icon window: some window managers
+ * (like olvwm) want to get the events themselves, but X only allows
+ * one application at a time to receive button events for a window.
*/
atts.event_mask = Tk_Attributes(tkwin2)->event_mask
@@ -4358,8 +4555,8 @@ WmIconwindowCmd(tkwin, winPtr, interp, objc, objv)
*
* WmMaxsizeCmd --
*
- * This procedure is invoked to process the "wm maxsize" Tcl command.
- * See the user documentation for details on what it does.
+ * This function is invoked to process the "wm maxsize" Tcl command. See
+ * the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
@@ -4408,8 +4605,8 @@ WmMaxsizeCmd(tkwin, winPtr, interp, objc, objv)
*
* WmMinsizeCmd --
*
- * This procedure is invoked to process the "wm minsize" Tcl command.
- * See the user documentation for details on what it does.
+ * This function is invoked to process the "wm minsize" Tcl command. See
+ * the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
@@ -4458,9 +4655,8 @@ WmMinsizeCmd(tkwin, winPtr, interp, objc, objv)
*
* WmOverrideredirectCmd --
*
- * This procedure is invoked to process the "wm overrideredirect"
- * Tcl command.
- * See the user documentation for details on what it does.
+ * This function is invoked to process the "wm overrideredirect" Tcl
+ * command. See the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
@@ -4508,12 +4704,13 @@ WmOverrideredirectCmd(tkwin, winPtr, interp, objc, objv)
SendMessage(wmPtr->wrapper, TK_OVERRIDEREDIRECT, boolean, 0);
} else {
/*
- * Only do this if we are really changing value, because it
- * causes some funky stuff to occur
+ * Only do this if we are really changing value, because it causes
+ * some funky stuff to occur.
*/
+
atts.override_redirect = (boolean) ? True : False;
Tk_ChangeWindowAttributes((Tk_Window) winPtr, CWOverrideRedirect,
- &atts);
+ &atts);
if (!(wmPtr->flags & (WM_NEVER_MAPPED))
&& !(winPtr->flags & TK_EMBEDDED)) {
UpdateWrapper(winPtr);
@@ -4528,8 +4725,7 @@ WmOverrideredirectCmd(tkwin, winPtr, interp, objc, objv)
*
* WmPositionfromCmd --
*
- * This procedure is invoked to process the "wm positionfrom"
- * Tcl command.
+ * This function is invoked to process the "wm positionfrom" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
@@ -4592,7 +4788,7 @@ WmPositionfromCmd(tkwin, winPtr, interp, objc, objv)
*
* WmProtocolCmd --
*
- * This procedure is invoked to process the "wm protocol" Tcl command.
+ * This function is invoked to process the "wm protocol" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
@@ -4626,6 +4822,7 @@ WmProtocolCmd(tkwin, winPtr, interp, objc, objv)
/*
* Return a list of all defined protocols for the window.
*/
+
for (protPtr = wmPtr->protPtr; protPtr != NULL;
protPtr = protPtr->nextPtr) {
Tcl_AppendElement(interp,
@@ -4638,6 +4835,7 @@ WmProtocolCmd(tkwin, winPtr, interp, objc, objv)
/*
* Return the command to handle a given protocol.
*/
+
for (protPtr = wmPtr->protPtr; protPtr != NULL;
protPtr = protPtr->nextPtr) {
if (protPtr->protocol == protocol) {
@@ -4649,13 +4847,12 @@ WmProtocolCmd(tkwin, winPtr, interp, objc, objv)
}
/*
- * Delete any current protocol handler, then create a new
- * one with the specified command, unless the command is
- * empty.
+ * Delete any current protocol handler, then create a new one with the
+ * specified command, unless the command is empty.
*/
for (protPtr = wmPtr->protPtr, prevPtr = NULL; protPtr != NULL;
- prevPtr = protPtr, protPtr = protPtr->nextPtr) {
+ prevPtr = protPtr, protPtr = protPtr->nextPtr) {
if (protPtr->protocol == protocol) {
if (prevPtr == NULL) {
wmPtr->protPtr = protPtr->nextPtr;
@@ -4683,7 +4880,7 @@ WmProtocolCmd(tkwin, winPtr, interp, objc, objv)
*
* WmResizableCmd --
*
- * This procedure is invoked to process the "wm resizable" Tcl command.
+ * This function is invoked to process the "wm resizable" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
@@ -4746,7 +4943,7 @@ WmResizableCmd(tkwin, winPtr, interp, objc, objv)
*
* WmSizefromCmd --
*
- * This procedure is invoked to process the "wm sizefrom" Tcl command.
+ * This function is invoked to process the "wm sizefrom" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
@@ -4768,9 +4965,11 @@ WmSizefromCmd(tkwin, winPtr, interp, objc, objv)
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
static CONST char *optionStrings[] = {
- "program", "user", (char *) NULL };
+ "program", "user", NULL
+ };
enum options {
- OPT_PROGRAM, OPT_USER };
+ OPT_PROGRAM, OPT_USER
+ };
int index;
if ((objc != 3) && (objc != 4)) {
@@ -4810,7 +5009,7 @@ WmSizefromCmd(tkwin, winPtr, interp, objc, objv)
*
* WmStackorderCmd --
*
- * This procedure is invoked to process the "wm stackorder" Tcl command.
+ * This function is invoked to process the "wm stackorder" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
@@ -4864,33 +5063,31 @@ WmStackorderCmd(tkwin, winPtr, interp, objc, objv)
if (!Tk_IsTopLevel(winPtr2)) {
Tcl_AppendResult(interp, "window \"", winPtr2->pathName,
- "\" isn't a top-level window", (char *) NULL);
+ "\" isn't a top-level window", NULL);
return TCL_ERROR;
}
if (!Tk_IsMapped(winPtr)) {
Tcl_AppendResult(interp, "window \"", winPtr->pathName,
- "\" isn't mapped", (char *) NULL);
+ "\" isn't mapped", NULL);
return TCL_ERROR;
}
if (!Tk_IsMapped(winPtr2)) {
Tcl_AppendResult(interp, "window \"", winPtr2->pathName,
- "\" isn't mapped", (char *) NULL);
+ "\" isn't mapped", NULL);
return TCL_ERROR;
}
/*
- * Lookup stacking order of all toplevels that are children
- * of "." and find the position of winPtr and winPtr2
- * in the stacking order.
+ * Lookup stacking order of all toplevels that are children of "." and
+ * find the position of winPtr and winPtr2 in the stacking order.
*/
windows = TkWmStackorderToplevel(winPtr->mainPtr->winPtr);
if (windows == NULL) {
- Tcl_AppendResult(interp, "TkWmStackorderToplevel failed",
- (char *) NULL);
+ Tcl_AppendResult(interp, "TkWmStackorderToplevel failed", NULL);
return TCL_ERROR;
} else {
for (window_ptr = windows; *window_ptr ; window_ptr++) {
@@ -4927,8 +5124,8 @@ WmStackorderCmd(tkwin, winPtr, interp, objc, objv)
*
* WmStateCmd --
*
- * This procedure is invoked to process the "wm state" Tcl command.
- * See the user documentation for details on what it does.
+ * This function is invoked to process the "wm state" Tcl command. See
+ * the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
@@ -4961,9 +5158,8 @@ WmStateCmd(tkwin, winPtr, interp, objc, objv)
if (objc == 4) {
if (wmPtr->iconFor != NULL) {
Tcl_AppendResult(interp, "can't change state of ",
- Tcl_GetString(objv[2]),
- ": it is an icon for ", Tk_PathName(wmPtr->iconFor),
- (char *) NULL);
+ Tcl_GetString(objv[2]), ": it is an icon for ",
+ Tk_PathName(wmPtr->iconFor), NULL);
return TCL_ERROR;
}
if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0,
@@ -4979,19 +5175,16 @@ WmStateCmd(tkwin, winPtr, interp, objc, objv)
if (winPtr->flags & TK_EMBEDDED) {
int state;
switch(index) {
- case OPT_NORMAL:
+ case OPT_NORMAL:
state = NormalState;
break;
-
- case OPT_ICONIC:
+ case OPT_ICONIC:
state = IconicState;
break;
-
- case OPT_WITHDRAWN:
+ case OPT_WITHDRAWN:
state = WithdrawnState;
break;
-
- case OPT_ZOOMED:
+ case OPT_ZOOMED:
state = ZoomState;
break;
}
@@ -5008,22 +5201,21 @@ WmStateCmd(tkwin, winPtr, interp, objc, objv)
if (index == OPT_NORMAL) {
wmPtr->flags &= ~WM_WITHDRAWN;
TkpWmSetState(winPtr, NormalState);
+
/*
- * This varies from 'wm deiconify' because it does not
- * force the window to be raised and receive focus
+ * This varies from 'wm deiconify' because it does not force the
+ * window to be raised and receive focus.
*/
} else if (index == OPT_ICONIC) {
if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) {
Tcl_AppendResult(interp, "can't iconify \"",
- winPtr->pathName,
- "\": override-redirect flag is set",
- (char *) NULL);
+ winPtr->pathName, "\": override-redirect flag is set",
+ NULL);
return TCL_ERROR;
}
if (wmPtr->masterPtr != NULL) {
Tcl_AppendResult(interp, "can't iconify \"",
- winPtr->pathName,
- "\": it is a transient", (char *) NULL);
+ winPtr->pathName, "\": it is a transient", NULL);
return TCL_ERROR;
}
TkpWmSetState(winPtr, IconicState);
@@ -5040,21 +5232,23 @@ WmStateCmd(tkwin, winPtr, interp, objc, objv)
Tcl_SetResult(interp, "icon", TCL_STATIC);
} else {
int state;
- if(winPtr->flags & TK_EMBEDDED)
+
+ if (winPtr->flags & TK_EMBEDDED) {
state = SendMessage(wmPtr->wrapper, TK_STATE, -1, -1)-1;
- else
+ } else {
state = wmPtr->hints.initial_state;
+ }
switch (state) {
- case NormalState:
+ case NormalState:
Tcl_SetResult(interp, "normal", TCL_STATIC);
break;
- case IconicState:
+ case IconicState:
Tcl_SetResult(interp, "iconic", TCL_STATIC);
break;
- case WithdrawnState:
+ case WithdrawnState:
Tcl_SetResult(interp, "withdrawn", TCL_STATIC);
break;
- case ZoomState:
+ case ZoomState:
Tcl_SetResult(interp, "zoomed", TCL_STATIC);
break;
}
@@ -5068,8 +5262,8 @@ WmStateCmd(tkwin, winPtr, interp, objc, objv)
*
* WmTitleCmd --
*
- * This procedure is invoked to process the "wm title" Tcl command.
- * See the user documentation for details on what it does.
+ * This function is invoked to process the "wm title" Tcl command. See
+ * the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
@@ -5104,18 +5298,18 @@ WmTitleCmd(tkwin, winPtr, interp, objc, objv)
wrapper = wmPtr->wrapper;
}
if (objc == 3) {
- if(wrapper) {
+ if (wrapper) {
char buf[512];
Tcl_DString titleString;
int size = tkWinProcs->useWide? 256:512;
(*tkWinProcs->getWindowText)(wrapper, (LPCTSTR)buf, size);
- Tcl_WinTCharToUtf(buf, -1, &titleString);
- Tcl_SetResult(interp, Tcl_DStringValue(&titleString), TCL_VOLATILE);
+ Tcl_WinTCharToUtf(buf, -1, &titleString);
+ Tcl_SetResult(interp, Tcl_DStringValue(&titleString),TCL_VOLATILE);
Tcl_DStringFree(&titleString);
} else {
Tcl_SetResult(interp, (char *)
- ((wmPtr->title != NULL) ? wmPtr->title : winPtr->nameUid),
- TCL_STATIC);
+ ((wmPtr->title != NULL) ? wmPtr->title : winPtr->nameUid),
+ TCL_STATIC);
}
} else {
if (wmPtr->title != NULL) {
@@ -5129,7 +5323,7 @@ WmTitleCmd(tkwin, winPtr, interp, objc, objv)
Tcl_DString titleString;
Tcl_WinUtfToTChar(wmPtr->title, -1, &titleString);
(*tkWinProcs->setWindowText)(wrapper,
- (LPCTSTR) Tcl_DStringValue(&titleString));
+ (LPCTSTR) Tcl_DStringValue(&titleString));
Tcl_DStringFree(&titleString);
}
}
@@ -5141,7 +5335,7 @@ WmTitleCmd(tkwin, winPtr, interp, objc, objv)
*
* WmTransientCmd --
*
- * This procedure is invoked to process the "wm transient" Tcl command.
+ * This function is invoked to process the "wm transient" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
@@ -5178,8 +5372,8 @@ WmTransientCmd(tkwin, winPtr, interp, objc, objv)
if (Tcl_GetString(objv[3])[0] == '\0') {
if (masterPtr != NULL) {
/*
- * If we had a master, tell them that we aren't tied
- * to them anymore
+ * If we had a master, tell them that we aren't tied to them
+ * anymore.
*/
masterPtr->wmInfoPtr->numTransients--;
@@ -5204,35 +5398,30 @@ WmTransientCmd(tkwin, winPtr, interp, objc, objv)
Tk_MakeWindowExist((Tk_Window) masterPtr);
if (wmPtr->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't make \"",
- Tcl_GetString(objv[2]),
+ Tcl_AppendResult(interp, "can't make \"", Tcl_GetString(objv[2]),
"\" a transient: it is an icon for ",
- Tk_PathName(wmPtr->iconFor),
- (char *) NULL);
+ Tk_PathName(wmPtr->iconFor), NULL);
return TCL_ERROR;
}
wmPtr2 = masterPtr->wmInfoPtr;
if (wmPtr2->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't make \"",
- Tcl_GetString(objv[3]),
+ Tcl_AppendResult(interp, "can't make \"", Tcl_GetString(objv[3]),
"\" a master: it is an icon for ",
- Tk_PathName(wmPtr2->iconFor),
- (char *) NULL);
+ Tk_PathName(wmPtr2->iconFor), NULL);
return TCL_ERROR;
}
if (masterPtr == winPtr) {
Tcl_AppendResult(interp, "can't make \"", Tk_PathName(winPtr),
- "\" its own master",
- (char *) NULL);
+ "\" its own master", NULL);
return TCL_ERROR;
} else if (masterPtr != wmPtr->masterPtr) {
/*
- * Remove old master map/unmap binding before setting
- * the new master. The event handler will ensure that
- * transient states reflect the state of the master.
+ * Remove old master map/unmap binding before setting the new
+ * master. The event handler will ensure that transient states
+ * reflect the state of the master.
*/
if (wmPtr->masterPtr != NULL) {
@@ -5267,7 +5456,7 @@ WmTransientCmd(tkwin, winPtr, interp, objc, objv)
*
* WmWithdrawCmd --
*
- * This procedure is invoked to process the "wm withdraw" Tcl command.
+ * This function is invoked to process the "wm withdraw" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
@@ -5295,15 +5484,14 @@ WmWithdrawCmd(tkwin, winPtr, interp, objc, objv)
}
if (wmPtr->iconFor != NULL) {
Tcl_AppendResult(interp, "can't withdraw ", Tcl_GetString(objv[2]),
- ": it is an icon for ", Tk_PathName(wmPtr->iconFor),
- (char *) NULL);
+ ": it is an icon for ", Tk_PathName(wmPtr->iconFor), NULL);
return TCL_ERROR;
}
- if(winPtr->flags & TK_EMBEDDED) {
- if(SendMessage(wmPtr->wrapper, TK_WITHDRAW, 0, 0) < 0) {
+ if (winPtr->flags & TK_EMBEDDED) {
+ if (SendMessage(wmPtr->wrapper, TK_WITHDRAW, 0, 0) < 0) {
Tcl_AppendResult(interp, "can't withdraw", Tcl_GetString(objv[2]),
- ": the container does not support the request", NULL);
+ ": the container does not support the request", NULL);
return TCL_ERROR;
}
} else {
@@ -5314,13 +5502,14 @@ WmWithdrawCmd(tkwin, winPtr, interp, objc, objv)
}
/*
- * Invoked by those wm subcommands that affect geometry.
- * Schedules a geometry update.
+ * Invoked by those wm subcommands that affect geometry. Schedules a geometry
+ * update.
*/
+
static void
-WmUpdateGeom(wmPtr, winPtr)
- WmInfo *wmPtr;
- TkWindow *winPtr;
+WmUpdateGeom(
+ WmInfo *wmPtr,
+ TkWindow *winPtr)
{
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {
Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr);
@@ -5330,9 +5519,9 @@ WmUpdateGeom(wmPtr, winPtr)
/*ARGSUSED*/
static void
-WmWaitVisibilityOrMapProc(clientData, eventPtr)
- ClientData clientData; /* Pointer to window. */
- XEvent *eventPtr; /* Information about event. */
+WmWaitVisibilityOrMapProc(
+ ClientData clientData, /* Pointer to window. */
+ XEvent *eventPtr) /* Information about event. */
{
TkWindow *winPtr = (TkWindow *) clientData;
TkWindow *masterPtr = winPtr->wmInfoPtr->masterPtr;
@@ -5364,34 +5553,34 @@ WmWaitVisibilityOrMapProc(clientData, eventPtr)
*
* Tk_SetGrid --
*
- * This procedure is invoked by a widget when it wishes to set a grid
- * coordinate system that controls the size of a top-level window.
- * It provides a C interface equivalent to the "wm grid" command and
- * is usually asscoiated with the -setgrid option.
+ * This function is invoked by a widget when it wishes to set a grid
+ * coordinate system that controls the size of a top-level window. It
+ * provides a C interface equivalent to the "wm grid" command and is
+ * usually asscoiated with the -setgrid option.
*
* Results:
* None.
*
* Side effects:
- * Grid-related information will be passed to the window manager, so
- * that the top-level window associated with tkwin will resize on
- * even grid units. If some other window already controls gridding
- * for the top-level window then this procedure call has no effect.
+ * Grid-related information will be passed to the window manager, so that
+ * the top-level window associated with tkwin will resize on even grid
+ * units. If some other window already controls gridding for the
+ * top-level window then this function call has no effect.
*
*----------------------------------------------------------------------
*/
void
-Tk_SetGrid(tkwin, reqWidth, reqHeight, widthInc, heightInc)
- Tk_Window tkwin; /* Token for window. New window mgr info
- * will be posted for the top-level window
+Tk_SetGrid(
+ Tk_Window tkwin, /* Token for window. New window mgr info will
+ * be posted for the top-level window
* associated with this window. */
- int reqWidth; /* Width (in grid units) corresponding to
- * the requested geometry for tkwin. */
- int reqHeight; /* Height (in grid units) corresponding to
- * the requested geometry for tkwin. */
- int widthInc, heightInc; /* Pixel increments corresponding to a
- * change of one grid unit. */
+ int reqWidth, /* Width (in grid units) corresponding to the
+ * requested geometry for tkwin. */
+ int reqHeight, /* Height (in grid units) corresponding to the
+ * requested geometry for tkwin. */
+ int widthInc, int heightInc)/* Pixel increments corresponding to a change
+ * of one grid unit. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
register WmInfo *wmPtr;
@@ -5399,6 +5588,7 @@ Tk_SetGrid(tkwin, reqWidth, reqHeight, widthInc, heightInc)
/*
* Ensure widthInc and heightInc are greater than 0
*/
+
if (widthInc <= 0) {
widthInc = 1;
}
@@ -5406,7 +5596,6 @@ Tk_SetGrid(tkwin, reqWidth, reqHeight, widthInc, heightInc)
heightInc = 1;
}
-
/*
* Find the top-level window for tkwin, plus the window manager
* information.
@@ -5434,15 +5623,15 @@ Tk_SetGrid(tkwin, reqWidth, reqHeight, widthInc, heightInc)
}
/*
- * If gridding was previously off, then forget about any window
- * size requests made by the user or via "wm geometry": these are
- * in pixel units and there's no easy way to translate them to
- * grid units since the new requested size of the top-level window in
- * pixels may not yet have been registered yet (it may filter up
- * the hierarchy in DoWhenIdle handlers). However, if the window
- * has never been mapped yet then just leave the window size alone:
- * assume that it is intended to be in grid units but just happened
- * to have been specified before this procedure was called.
+ * If gridding was previously off, then forget about any window size
+ * requests made by the user or via "wm geometry": these are in pixel
+ * units and there's no easy way to translate them to grid units since the
+ * new requested size of the top-level window in pixels may not yet have
+ * been registered yet (it may filter up the hierarchy in DoWhenIdle
+ * handlers). However, if the window has never been mapped yet then just
+ * leave the window size alone: assume that it is intended to be in grid
+ * units but just happened to have been specified before this function was
+ * called.
*/
if ((wmPtr->gridWin == NULL) && !(wmPtr->flags & WM_NEVER_MAPPED)) {
@@ -5451,8 +5640,8 @@ Tk_SetGrid(tkwin, reqWidth, reqHeight, widthInc, heightInc)
}
/*
- * Set the new gridding information, and start the process of passing
- * all of this information to the window manager.
+ * Set the new gridding information, and start the process of passing all
+ * of this information to the window manager.
*/
wmPtr->gridWin = tkwin;
@@ -5472,23 +5661,22 @@ Tk_SetGrid(tkwin, reqWidth, reqHeight, widthInc, heightInc)
*
* Tk_UnsetGrid --
*
- * This procedure cancels the effect of a previous call
- * to Tk_SetGrid.
+ * This function cancels the effect of a previous call to Tk_SetGrid.
*
* Results:
* None.
*
* Side effects:
* If tkwin currently controls gridding for its top-level window,
- * gridding is cancelled for that top-level window; if some other
- * window controls gridding then this procedure has no effect.
+ * gridding is cancelled for that top-level window; if some other window
+ * controls gridding then this function has no effect.
*
*----------------------------------------------------------------------
*/
void
-Tk_UnsetGrid(tkwin)
- Tk_Window tkwin; /* Token for window that is currently
+Tk_UnsetGrid(
+ Tk_Window tkwin) /* Token for window that is currently
* controlling gridding. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
@@ -5533,23 +5721,23 @@ Tk_UnsetGrid(tkwin)
*
* TopLevelEventProc --
*
- * This procedure is invoked when a top-level (or other externally-
- * managed window) is restructured in any way.
+ * This function is invoked when a top-level (or other externally-managed
+ * window) is restructured in any way.
*
* Results:
* None.
*
* Side effects:
- * Tk's internal data structures for the window get modified to
- * reflect the structural change.
+ * Tk's internal data structures for the window get modified to reflect
+ * the structural change.
*
*----------------------------------------------------------------------
*/
static void
-TopLevelEventProc(clientData, eventPtr)
- ClientData clientData; /* Window for which event occurred. */
- XEvent *eventPtr; /* Event that just happened. */
+TopLevelEventProc(
+ ClientData clientData, /* Window for which event occurred. */
+ XEvent *eventPtr) /* Event that just happened. */
{
register TkWindow *winPtr = (TkWindow *) clientData;
@@ -5559,8 +5747,8 @@ TopLevelEventProc(clientData, eventPtr)
if (!(winPtr->flags & TK_ALREADY_DEAD)) {
/*
* A top-level window was deleted externally (e.g., by the window
- * manager). This is probably not a good thing, but cleanup as
- * best we can. The error handler is needed because
+ * manager). This is probably not a good thing, but cleanup as
+ * best we can. The error handler is needed because
* Tk_DestroyWindow will try to destroy the window, but of course
* it's already gone.
*/
@@ -5578,24 +5766,24 @@ TopLevelEventProc(clientData, eventPtr)
*
* TopLevelReqProc --
*
- * This procedure is invoked by the geometry manager whenever
- * the requested size for a top-level window is changed.
+ * This function is invoked by the geometry manager whenever the
+ * requested size for a top-level window is changed.
*
* Results:
* None.
*
* Side effects:
- * Arrange for the window to be resized to satisfy the request
- * (this happens as a when-idle action).
+ * Arrange for the window to be resized to satisfy the request (this
+ * happens as a when-idle action).
*
*----------------------------------------------------------------------
*/
/* ARGSUSED */
static void
-TopLevelReqProc(dummy, tkwin)
- ClientData dummy; /* Not used. */
- Tk_Window tkwin; /* Information about window. */
+TopLevelReqProc(
+ ClientData dummy, /* Not used. */
+ Tk_Window tkwin) /* Information about window. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
WmInfo *wmPtr;
@@ -5616,26 +5804,25 @@ TopLevelReqProc(dummy, tkwin)
*
* UpdateGeometryInfo --
*
- * This procedure is invoked when a top-level window is first
- * mapped, and also as a when-idle procedure, to bring the
- * geometry and/or position of a top-level window back into
- * line with what has been requested by the user and/or widgets.
- * This procedure doesn't return until the system has
+ * This function is invoked when a top-level window is first mapped, and
+ * also as a when-idle function, to bring the geometry and/or position of
+ * a top-level window back into line with what has been requested by the
+ * user and/or widgets. This function doesn't return until the system has
* responded to the geometry change.
*
* Results:
* None.
*
* Side effects:
- * The window's size and location may change, unless the WM prevents
- * that from happening.
+ * The window's size and location may change, unless the WM prevents that
+ * from happening.
*
*----------------------------------------------------------------------
*/
static void
-UpdateGeometryInfo(clientData)
- ClientData clientData; /* Pointer to the window's record. */
+UpdateGeometryInfo(
+ ClientData clientData) /* Pointer to the window's record. */
{
int x, y; /* Position of border on desktop. */
int width, height; /* Size of client area. */
@@ -5647,10 +5834,10 @@ UpdateGeometryInfo(clientData)
wmPtr->flags &= ~WM_UPDATE_PENDING;
/*
- * If the window is minimized or maximized, we should not update
- * our geometry since it will end up with the wrong values.
- * ConfigureToplevel will reschedule UpdateGeometryInfo when the
- * state of the window changes.
+ * If the window is minimized or maximized, we should not update our
+ * geometry since it will end up with the wrong values. ConfigureToplevel
+ * will reschedule UpdateGeometryInfo when the state of the window
+ * changes.
*/
if (wmPtr->wrapper && (IsIconic(wmPtr->wrapper) ||
@@ -5659,12 +5846,11 @@ UpdateGeometryInfo(clientData)
}
/*
- * Compute the border size for the current window style. This
- * size will include the resize handles, the title bar and the
- * menubar. Note that this size will not be correct if the
- * menubar spans multiple lines. The height will be off by a
- * multiple of the menubar height. It really only measures the
- * minimum size of the border.
+ * Compute the border size for the current window style. This size will
+ * include the resize handles, the title bar and the menubar. Note that
+ * this size will not be correct if the menubar spans multiple lines. The
+ * height will be off by a multiple of the menubar height. It really only
+ * measures the minimum size of the border.
*/
rect.left = rect.right = rect.top = rect.bottom = 0;
@@ -5674,15 +5860,13 @@ UpdateGeometryInfo(clientData)
wmPtr->borderHeight = rect.bottom - rect.top;
/*
- * Compute the new size for the top-level window. See the
- * user documentation for details on this, but the size
- * requested depends on (a) the size requested internally
- * by the window's widgets, (b) the size requested by the
- * user in a "wm geometry" command or via wm-based interactive
- * resizing (if any), (c) whether or not the window is
- * gridded, and (d) the current min or max size for
- * the toplevel. Don't permit sizes <= 0 because this upsets
- * the X server.
+ * Compute the new size for the top-level window. See the user
+ * documentation for details on this, but the size requested depends on
+ * (a) the size requested internally by the window's widgets, (b) the size
+ * requested by the user in a "wm geometry" command or via wm-based
+ * interactive resizing (if any), (c) whether or not the window is
+ * gridded, and (d) the current min or max size for the toplevel. Don't
+ * permit sizes <= 0 because this upsets the X server.
*/
if (wmPtr->width == -1) {
@@ -5696,9 +5880,11 @@ UpdateGeometryInfo(clientData)
if (width <= 0) {
width = 1;
}
+
/*
* Account for window max/min width
*/
+
if (wmPtr->gridWin != NULL) {
min = winPtr->reqWidth
+ (wmPtr->minWidth - wmPtr->reqGridWidth)*wmPtr->widthInc;
@@ -5729,9 +5915,11 @@ UpdateGeometryInfo(clientData)
if (height <= 0) {
height = 1;
}
+
/*
* Account for window max/min height
*/
+
if (wmPtr->gridWin != NULL) {
min = winPtr->reqHeight
+ (wmPtr->minHeight - wmPtr->reqGridHeight)*wmPtr->heightInc;
@@ -5753,10 +5941,10 @@ UpdateGeometryInfo(clientData)
/*
* Compute the new position for the upper-left pixel of the window's
- * decorative frame. This is tricky, because we need to include the
- * border widths supplied by a reparented parent in this calculation,
- * but can't use the parent's current overall size since that may
- * change as a result of this code.
+ * decorative frame. This is tricky, because we need to include the border
+ * widths supplied by a reparented parent in this calculation, but can't
+ * use the parent's current overall size since that may change as a result
+ * of this code.
*/
if (wmPtr->flags & WM_NEGATIVE_X) {
@@ -5773,11 +5961,12 @@ UpdateGeometryInfo(clientData)
}
/*
- * Reconfigure the window if it isn't already configured correctly. Base
+ * Reconfigure the window if it isn't already configured correctly. Base
* the size check on what we *asked for* last time, not what we got.
* Return immediately if there have been no changes in the requested
* geometry of the toplevel.
*/
+
/* TODO: need to add flag for possible menu size change */
if (!((wmPtr->flags & WM_MOVE_PENDING)
@@ -5791,9 +5980,8 @@ UpdateGeometryInfo(clientData)
wmPtr->configHeight = height;
/*
- * Don't bother moving the window if we are in the process of
- * creating it. Just update the geometry info based on what
- * we asked for.
+ * Don't bother moving the window if we are in the process of creating it.
+ * Just update the geometry info based on what we asked for.
*/
if (wmPtr->flags & WM_CREATE_PENDING) {
@@ -5807,11 +5995,12 @@ UpdateGeometryInfo(clientData)
wmPtr->flags |= WM_SYNC_PENDING;
if (winPtr->flags & TK_EMBEDDED) {
/*
- * The wrapper window is in a different process, so we need
- * to send it a geometry request. This protocol assumes that
- * the other process understands this Tk message, otherwise
- * our requested geometry will be ignored.
+ * The wrapper window is in a different process, so we need to send it
+ * a geometry request. This protocol assumes that the other process
+ * understands this Tk message, otherwise our requested geometry will
+ * be ignored.
*/
+
SendMessage(wmPtr->wrapper, TK_MOVEWINDOW, x, y);
SendMessage(wmPtr->wrapper, TK_GEOMETRYREQ, width, height);
} else {
@@ -5821,15 +6010,13 @@ UpdateGeometryInfo(clientData)
int newHeight;
/*
- * We have to keep resizing the window until we get the
- * requested height in the client area. If the client
- * area has zero height, then the window rect is too
- * small by definition. Try increasing the border height
- * and try again. Once we have a positive size, then
- * we can adjust the height exactly. If the window
- * rect comes back smaller than we requested, we have
- * hit the maximum constraints that Windows imposes.
- * Once we find a positive client size, the next size
+ * We have to keep resizing the window until we get the requested
+ * height in the client area. If the client area has zero height, then
+ * the window rect is too small by definition. Try increasing the
+ * border height and try again. Once we have a positive size, then we
+ * can adjust the height exactly. If the window rect comes back
+ * smaller than we requested, we have hit the maximum constraints that
+ * Windows imposes. Once we find a positive client size, the next size
* is the one we try no matter what.
*/
@@ -5861,11 +6048,13 @@ UpdateGeometryInfo(clientData)
/*
* We're done.
*/
+
break;
} else if (newHeight > height) {
/*
* One last resize to get rid of the extra space.
*/
+
menuInc = newHeight - height;
reqHeight -= menuInc;
if (wmPtr->flags & WM_NEGATIVE_Y) {
@@ -5876,11 +6065,10 @@ UpdateGeometryInfo(clientData)
}
/*
- * We didn't get enough space to satisfy our requested
- * height, so the menu must have wrapped. Increase the
- * size of the window by one menu height and move the
- * window if it is positioned relative to the lower right
- * corner of the screen.
+ * We didn't get enough space to satisfy our requested height, so
+ * the menu must have wrapped. Increase the size of the window by
+ * one menu height and move the window if it is positioned
+ * relative to the lower right corner of the screen.
*/
reqHeight += menuInc;
@@ -5900,13 +6088,12 @@ UpdateGeometryInfo(clientData)
*
* ParseGeometry --
*
- * This procedure parses a geometry string and updates
- * information used to control the geometry of a top-level
- * window.
+ * This function parses a geometry string and updates information used to
+ * control the geometry of a top-level window.
*
* Results:
- * A standard Tcl return value, plus an error message in
- * the interp's result if an error occurs.
+ * A standard Tcl return value, plus an error message in the interp's
+ * result if an error occurs.
*
* Side effects:
* The size and/or location of winPtr may change.
@@ -5915,12 +6102,12 @@ UpdateGeometryInfo(clientData)
*/
static int
-ParseGeometry(interp, string, winPtr)
- Tcl_Interp *interp; /* Used for error reporting. */
- char *string; /* String containing new geometry. Has the
+ParseGeometry(
+ Tcl_Interp *interp, /* Used for error reporting. */
+ char *string, /* String containing new geometry. Has the
* standard form "=wxh+x+y". */
- TkWindow *winPtr; /* Pointer to top-level window whose
- * geometry is to be changed. */
+ TkWindow *winPtr) /* Pointer to top-level window whose geometry
+ * is to be changed. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
int x, y, width, height, flags;
@@ -5936,9 +6123,9 @@ ParseGeometry(interp, string, winPtr)
}
/*
- * Parse the width and height, if they are present. Don't
- * actually update any of the fields of wmPtr until we've
- * successfully parsed the entire geometry string.
+ * Parse the width and height, if they are present. Don't actually update
+ * any of the fields of wmPtr until we've successfully parsed the entire
+ * geometry string.
*/
width = wmPtr->width;
@@ -5992,10 +6179,10 @@ ParseGeometry(interp, string, winPtr)
}
/*
- * Assume that the geometry information came from the user,
- * unless an explicit source has been specified. Otherwise
- * most window managers assume that the size hints were
- * program-specified and they ignore them.
+ * Assume that the geometry information came from the user, unless an
+ * explicit source has been specified. Otherwise most window managers
+ * assume that the size hints were program-specified and they ignore
+ * them.
*/
if ((wmPtr->sizeHintsFlags & (USPosition|PPosition)) == 0) {
@@ -6004,9 +6191,9 @@ ParseGeometry(interp, string, winPtr)
}
/*
- * Everything was parsed OK. Update the fields of *wmPtr and
- * arrange for the appropriate information to be percolated out
- * to the window manager at the next idle moment.
+ * Everything was parsed OK. Update the fields of *wmPtr and arrange for
+ * the appropriate information to be percolated out to the window manager
+ * at the next idle moment.
*/
wmPtr->width = width;
@@ -6022,9 +6209,8 @@ ParseGeometry(interp, string, winPtr)
}
return TCL_OK;
- error:
- Tcl_AppendResult(interp, "bad geometry specifier \"",
- string, "\"", (char *) NULL);
+ error:
+ Tcl_AppendResult(interp, "bad geometry specifier \"", string, "\"", NULL);
return TCL_ERROR;
}
@@ -6033,13 +6219,13 @@ ParseGeometry(interp, string, winPtr)
*
* Tk_GetRootCoords --
*
- * Given a token for a window, this procedure traces through the
- * window's lineage to find the (virtual) root-window coordinates
- * corresponding to point (0,0) in the window.
+ * Given a token for a window, this function traces through the window's
+ * lineage to find the (virtual) root-window coordinates corresponding to
+ * point (0,0) in the window.
*
* Results:
- * The locations pointed to by xPtr and yPtr are filled in with
- * the root coordinates of the (0,0) point in tkwin.
+ * The locations pointed to by xPtr and yPtr are filled in with the root
+ * coordinates of the (0,0) point in tkwin.
*
* Side effects:
* None.
@@ -6048,10 +6234,10 @@ ParseGeometry(interp, string, winPtr)
*/
void
-Tk_GetRootCoords(tkwin, xPtr, yPtr)
- Tk_Window tkwin; /* Token for window. */
- int *xPtr; /* Where to store x-displacement of (0,0). */
- int *yPtr; /* Where to store y-displacement of (0,0). */
+Tk_GetRootCoords(
+ Tk_Window tkwin, /* Token for window. */
+ int *xPtr, /* Where to store x-displacement of (0,0). */
+ int *yPtr) /* Where to store y-displacement of (0,0). */
{
register TkWindow *winPtr = (TkWindow *) tkwin;
@@ -6081,13 +6267,13 @@ Tk_GetRootCoords(tkwin, xPtr, yPtr)
*
* Tk_CoordsToWindow --
*
- * Given the (virtual) root coordinates of a point, this procedure
- * returns the token for the top-most window covering that point,
- * if there exists such a window in this application.
+ * Given the (virtual) root coordinates of a point, this function returns
+ * the token for the top-most window covering that point, if there exists
+ * such a window in this application.
*
* Results:
- * The return result is either a token for the window corresponding
- * to rootX and rootY, or else NULL to indicate that there is no such
+ * The return result is either a token for the window corresponding to
+ * rootX and rootY, or else NULL to indicate that there is no such
* window.
*
* Side effects:
@@ -6097,13 +6283,13 @@ Tk_GetRootCoords(tkwin, xPtr, yPtr)
*/
Tk_Window
-Tk_CoordsToWindow(rootX, rootY, tkwin)
- int rootX, rootY; /* Coordinates of point in root window. If
- * a virtual-root window manager is in use,
+Tk_CoordsToWindow(
+ int rootX, int rootY, /* Coordinates of point in root window. If a
+ * virtual-root window manager is in use,
* these coordinates refer to the virtual
* root, not the real root. */
- Tk_Window tkwin; /* Token for any window in application;
- * used to identify the display. */
+ Tk_Window tkwin) /* Token for any window in application; used
+ * to identify the display. */
{
POINT pos;
HWND hwnd;
@@ -6125,16 +6311,15 @@ Tk_CoordsToWindow(rootX, rootY, tkwin)
*
* Tk_GetVRootGeometry --
*
- * This procedure returns information about the virtual root
- * window corresponding to a particular Tk window.
+ * This function returns information about the virtual root window
+ * corresponding to a particular Tk window.
*
* Results:
- * The values at xPtr, yPtr, widthPtr, and heightPtr are set
- * with the offset and dimensions of the root window corresponding
- * to tkwin. If tkwin is being managed by a virtual root window
- * manager these values correspond to the virtual root window being
- * used for tkwin; otherwise the offsets will be 0 and the
- * dimensions will be those of the screen.
+ * The values at xPtr, yPtr, widthPtr, and heightPtr are set with the
+ * offset and dimensions of the root window corresponding to tkwin. If
+ * tkwin is being managed by a virtual root window manager these values
+ * correspond to the virtual root window being used for tkwin; otherwise
+ * the offsets will be 0 and the dimensions will be those of the screen.
*
* Side effects:
* Vroot window information is refreshed if it is out of date.
@@ -6143,22 +6328,24 @@ Tk_CoordsToWindow(rootX, rootY, tkwin)
*/
void
-Tk_GetVRootGeometry(tkwin, xPtr, yPtr, widthPtr, heightPtr)
- Tk_Window tkwin; /* Window whose virtual root is to be
+Tk_GetVRootGeometry(
+ Tk_Window tkwin, /* Window whose virtual root is to be
* queried. */
- int *xPtr, *yPtr; /* Store x and y offsets of virtual root
+ int *xPtr, int *yPtr, /* Store x and y offsets of virtual root
* here. */
- int *widthPtr, *heightPtr; /* Store dimensions of virtual root here. */
+ int *widthPtr, int *heightPtr)
+ /* Store dimensions of virtual root here. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
/*
- * XXX: This is not correct for multiple monitors. There may be many
+ * XXX: This is not correct for multiple monitors. There may be many
* changes required to get this right, and it may effect existing
- * applications that don't consider possible <0 vroot. See
- * http://msdn.microsoft.com/library/en-us/gdi/monitor_3lrn.asp
- * for more info.
+ * applications that don't consider possible <0 vroot. See
+ * http://msdn.microsoft.com/library/en-us/gdi/monitor_3lrn.asp for more
+ * info.
*/
+
*xPtr = 0;
*yPtr = 0;
*widthPtr = DisplayWidth(winPtr->display, winPtr->screenNum);
@@ -6170,27 +6357,25 @@ Tk_GetVRootGeometry(tkwin, xPtr, yPtr, widthPtr, heightPtr)
*
* Tk_MoveToplevelWindow --
*
- * This procedure is called instead of Tk_MoveWindow to adjust
- * the x-y location of a top-level window. It delays the actual
- * move to a later time and keeps window-manager information
- * up-to-date with the move
+ * This function is called instead of Tk_MoveWindow to adjust the x-y
+ * location of a top-level window. It delays the actual move to a later
+ * time and keeps window-manager information up-to-date with the move
*
* Results:
* None.
*
* Side effects:
* The window is eventually moved so that its upper-left corner
- * (actually, the upper-left corner of the window's decorative
- * frame, if there is one) is at (x,y).
+ * (actually, the upper-left corner of the window's decorative frame, if
+ * there is one) is at (x,y).
*
*----------------------------------------------------------------------
*/
void
-Tk_MoveToplevelWindow(tkwin, x, y)
- Tk_Window tkwin; /* Window to move. */
- int x, y; /* New location for window (within
- * parent). */
+Tk_MoveToplevelWindow(
+ Tk_Window tkwin, /* Window to move. */
+ int x, int y) /* New location for window (within parent). */
{
TkWindow *winPtr = (TkWindow *) tkwin;
register WmInfo *wmPtr = winPtr->wmInfoPtr;
@@ -6208,9 +6393,8 @@ Tk_MoveToplevelWindow(tkwin, x, y)
/*
* If the window has already been mapped, must bring its geometry
- * up-to-date immediately, otherwise an event might arrive from the
- * server that would overwrite wmPtr->x and wmPtr->y and lose the
- * new position.
+ * up-to-date immediately, otherwise an event might arrive from the server
+ * that would overwrite wmPtr->x and wmPtr->y and lose the new position.
*/
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
@@ -6226,25 +6410,23 @@ Tk_MoveToplevelWindow(tkwin, x, y)
*
* TkWmProtocolEventProc --
*
- * This procedure is called by the Tk_HandleEvent whenever a
- * ClientMessage event arrives whose type is "WM_PROTOCOLS".
- * This procedure handles the message from the window manager
- * in an appropriate fashion.
+ * This function is called by the Tk_HandleEvent whenever a ClientMessage
+ * event arrives whose type is "WM_PROTOCOLS". This function handles the
+ * message from the window manager in an appropriate fashion.
*
* Results:
* None.
*
* Side effects:
- * Depends on what sort of handler, if any, was set up for the
- * protocol.
+ * Depends on what sort of handler, if any, was set up for the protocol.
*
*----------------------------------------------------------------------
*/
void
-TkWmProtocolEventProc(winPtr, eventPtr)
- TkWindow *winPtr; /* Window to which the event was sent. */
- XEvent *eventPtr; /* X event. */
+TkWmProtocolEventProc(
+ TkWindow *winPtr, /* Window to which the event was sent. */
+ XEvent *eventPtr) /* X event. */
{
WmInfo *wmPtr;
register ProtocolHandler *protPtr;
@@ -6261,9 +6443,10 @@ TkWmProtocolEventProc(winPtr, eventPtr)
protPtr = protPtr->nextPtr) {
if (protocol == protPtr->protocol) {
/*
- * Cache atom name, as we might destroy the window as a
- * result of the eval.
+ * Cache atom name, as we might destroy the window as a result of
+ * the eval.
*/
+
CONST char *name = Tk_GetAtomName((Tk_Window) winPtr, protocol);
Tcl_Preserve((ClientData) protPtr);
@@ -6283,8 +6466,8 @@ TkWmProtocolEventProc(winPtr, eventPtr)
}
/*
- * No handler was present for this protocol. If this is a
- * WM_DELETE_WINDOW message then just destroy the window.
+ * No handler was present for this protocol. If this is a WM_DELETE_WINDOW
+ * message then just destroy the window.
*/
if (protocol == Tk_InternAtom((Tk_Window) winPtr, "WM_DELETE_WINDOW")) {
@@ -6297,9 +6480,8 @@ TkWmProtocolEventProc(winPtr, eventPtr)
*
* TkWmStackorderToplevelEnumProc --
*
- * This procedure is invoked once for each HWND Window on the
- * display as a result of calling EnumWindows from
- * TkWmStackorderToplevel.
+ * This function is invoked once for each HWND Window on the display as a
+ * result of calling EnumWindows from TkWmStackorderToplevel.
*
* Results:
* TRUE to request further iteration.
@@ -6310,9 +6492,10 @@ TkWmProtocolEventProc(winPtr, eventPtr)
*----------------------------------------------------------------------
*/
-BOOL CALLBACK TkWmStackorderToplevelEnumProc(hwnd, lParam)
- HWND hwnd; /* handle to parent window */
- LPARAM lParam; /* application-defined value */
+BOOL CALLBACK
+TkWmStackorderToplevelEnumProc(
+ HWND hwnd, /* Handle to parent window */
+ LPARAM lParam) /* Application-defined value */
{
Tcl_HashEntry *hPtr;
TkWindow *childWinPtr;
@@ -6325,7 +6508,11 @@ BOOL CALLBACK TkWmStackorderToplevelEnumProc(hwnd, lParam)
hPtr = Tcl_FindHashEntry(pair->table, (char *) hwnd);
if (hPtr != NULL) {
childWinPtr = (TkWindow *) Tcl_GetHashValue(hPtr);
- /* Double check that same HWND does not get passed twice */
+
+ /*
+ * Double check that same HWND does not get passed twice.
+ */
+
if (childWinPtr == NULL) {
Tcl_Panic("duplicate HWND in TkWmStackorderToplevelEnumProc");
} else {
@@ -6343,8 +6530,8 @@ BOOL CALLBACK TkWmStackorderToplevelEnumProc(hwnd, lParam)
*
* TkWmStackorderToplevelWrapperMap --
*
- * This procedure will create a table that maps the wrapper
- * HWND id for a toplevel to the TkWindow structure that is wraps.
+ * This function will create a table that maps the wrapper HWND id for a
+ * toplevel to the TkWindow structure that is wraps.
*
* Results:
* None.
@@ -6356,10 +6543,10 @@ BOOL CALLBACK TkWmStackorderToplevelEnumProc(hwnd, lParam)
*/
static void
-TkWmStackorderToplevelWrapperMap(winPtr, display, table)
- TkWindow *winPtr; /* TkWindow to recurse on */
- Display *display; /* X display of parent window */
- Tcl_HashTable *table; /* Table to maps HWND to TkWindow */
+TkWmStackorderToplevelWrapperMap(
+ TkWindow *winPtr, /* TkWindow to recurse on */
+ Display *display, /* X display of parent window */
+ Tcl_HashTable *table) /* Table to maps HWND to TkWindow */
{
TkWindow *childPtr;
Tcl_HashEntry *hPtr;
@@ -6373,8 +6560,7 @@ TkWmStackorderToplevelWrapperMap(winPtr, display, table)
/*fprintf(stderr, "Mapped HWND %d to %x (%s)\n", wrapper,
winPtr, winPtr->pathName);*/
- hPtr = Tcl_CreateHashEntry(table,
- (char *) wrapper, &newEntry);
+ hPtr = Tcl_CreateHashEntry(table, (char *) wrapper, &newEntry);
Tcl_SetHashValue(hPtr, winPtr);
}
@@ -6388,11 +6574,11 @@ TkWmStackorderToplevelWrapperMap(winPtr, display, table)
*
* TkWmStackorderToplevel --
*
- * This procedure returns the stack order of toplevel windows.
+ * This function returns the stack order of toplevel windows.
*
* Results:
- * An array of pointers to tk window objects in stacking order
- * or else NULL if there was an error.
+ * An array of pointers to tk window objects in stacking order or else
+ * NULL if there was an error.
*
* Side effects:
* None.
@@ -6401,8 +6587,8 @@ TkWmStackorderToplevelWrapperMap(winPtr, display, table)
*/
TkWindow **
-TkWmStackorderToplevel(parentPtr)
- TkWindow *parentPtr; /* Parent toplevel window. */
+TkWmStackorderToplevel(
+ TkWindow *parentPtr) /* Parent toplevel window. */
{
TkWmStackorderToplevelPair pair;
TkWindow **windows;
@@ -6421,8 +6607,8 @@ TkWmStackorderToplevel(parentPtr)
* sizeof(TkWindow *));
/*
- * Special cases: If zero or one toplevels were mapped
- * there is no need to call EnumWindows.
+ * Special cases: If zero or one toplevels were mapped there is no need to
+ * call EnumWindows.
*/
switch (table.numEntries) {
@@ -6437,9 +6623,9 @@ TkWmStackorderToplevel(parentPtr)
}
/*
- * We will be inserting into the array starting at the end
- * and working our way to the beginning since EnumWindows
- * returns windows in highest to lowest order.
+ * We will be inserting into the array starting at the end and working our
+ * way to the beginning since EnumWindows returns windows in highest to
+ * lowest order.
*/
pair.table = &table;
@@ -6450,12 +6636,11 @@ TkWmStackorderToplevel(parentPtr)
(LPARAM) &pair) == 0) {
ckfree((char *) windows);
windows = NULL;
- } else {
- if (pair.window_ptr != (windows-1))
- Tcl_Panic("num matched toplevel windows does not equal num children");
+ } else if (pair.window_ptr != (windows-1)) {
+ Tcl_Panic("num matched toplevel windows does not equal num children");
}
- done:
+ done:
Tcl_DeleteHashTable(&table);
return windows;
}
@@ -6465,33 +6650,33 @@ TkWmStackorderToplevel(parentPtr)
*
* TkWmRestackToplevel --
*
- * This procedure restacks a top-level window.
+ * This function restacks a top-level window.
*
* Results:
* None.
*
* Side effects:
- * WinPtr gets restacked as specified by aboveBelow and otherPtr.
- * This procedure doesn't return until the restack has taken
- * effect and the ConfigureNotify event for it has been received.
+ * WinPtr gets restacked as specified by aboveBelow and otherPtr. This
+ * function doesn't return until the restack has taken effect and the
+ * ConfigureNotify event for it has been received.
*
*----------------------------------------------------------------------
*/
void
-TkWmRestackToplevel(winPtr, aboveBelow, otherPtr)
- TkWindow *winPtr; /* Window to restack. */
- int aboveBelow; /* Gives relative position for restacking;
+TkWmRestackToplevel(
+ TkWindow *winPtr, /* Window to restack. */
+ int aboveBelow, /* Gives relative position for restacking;
* must be Above or Below. */
- TkWindow *otherPtr; /* Window relative to which to restack;
- * if NULL, then winPtr gets restacked
- * above or below *all* siblings. */
+ TkWindow *otherPtr) /* Window relative to which to restack; if
+ * NULL, then winPtr gets restacked above or
+ * below *all* siblings. */
{
HWND hwnd, insertAfter;
/*
- * Can't set stacking order properly until the window is on the
- * screen (mapping it may give it a reparent window).
+ * Can't set stacking order properly until the window is on the screen
+ * (mapping it may give it a reparent window).
*/
if (winPtr->window == None) {
@@ -6511,13 +6696,14 @@ TkWmRestackToplevel(winPtr, aboveBelow, otherPtr)
TkWmMapWindow(otherPtr);
}
insertAfter = (otherPtr->wmInfoPtr->wrapper != NULL)
- ? otherPtr->wmInfoPtr->wrapper : Tk_GetHWND(otherPtr->window);
+ ? otherPtr->wmInfoPtr->wrapper : Tk_GetHWND(otherPtr->window);
} else {
insertAfter = NULL;
}
- if(winPtr->flags & TK_EMBEDDED) {
- SendMessage(winPtr->wmInfoPtr->wrapper, TK_RAISEWINDOW, (WPARAM)insertAfter, aboveBelow);
+ if (winPtr->flags & TK_EMBEDDED) {
+ SendMessage(winPtr->wmInfoPtr->wrapper, TK_RAISEWINDOW,
+ (WPARAM)insertAfter, aboveBelow);
} else {
TkWinSetWindowPos(hwnd, insertAfter, aboveBelow);
}
@@ -6528,28 +6714,27 @@ TkWmRestackToplevel(winPtr, aboveBelow, otherPtr)
*
* TkWmAddToColormapWindows --
*
- * This procedure is called to add a given window to the
- * WM_COLORMAP_WINDOWS property for its top-level, if it
- * isn't already there. It is invoked by the Tk code that
- * creates a new colormap, in order to make sure that colormap
- * information is propagated to the window manager by default.
+ * This function is called to add a given window to the
+ * WM_COLORMAP_WINDOWS property for its top-level, if it isn't already
+ * there. It is invoked by the Tk code that creates a new colormap, in
+ * order to make sure that colormap information is propagated to the
+ * window manager by default.
*
* Results:
* None.
*
* Side effects:
- * WinPtr's window gets added to the WM_COLORMAP_WINDOWS
- * property of its nearest top-level ancestor, unless the
- * colormaps have been set explicitly with the
- * "wm colormapwindows" command.
+ * WinPtr's window gets added to the WM_COLORMAP_WINDOWS property of its
+ * nearest top-level ancestor, unless the colormaps have been set
+ * explicitly with the "wm colormapwindows" command.
*
*----------------------------------------------------------------------
*/
void
-TkWmAddToColormapWindows(winPtr)
- TkWindow *winPtr; /* Window with a non-default colormap.
- * Should not be a top-level window. */
+TkWmAddToColormapWindows(
+ TkWindow *winPtr) /* Window with a non-default colormap. Should
+ * not be a top-level window. */
{
TkWindow *topPtr;
TkWindow **oldPtr, **newPtr;
@@ -6562,7 +6747,7 @@ TkWmAddToColormapWindows(winPtr)
for (topPtr = winPtr->parentPtr; ; topPtr = topPtr->parentPtr) {
if (topPtr == NULL) {
/*
- * Window is being deleted. Skip the whole operation.
+ * Window is being deleted. Skip the whole operation.
*/
return;
@@ -6594,8 +6779,7 @@ TkWmAddToColormapWindows(winPtr)
/*
* Make a new bigger array and use it to reset the property.
- * Automatically add the toplevel itself as the last element
- * of the list.
+ * Automatically add the toplevel itself as the last element of the list.
*/
newPtr = (TkWindow **) ckalloc((unsigned) ((count+2)*sizeof(TkWindow*)));
@@ -6630,26 +6814,26 @@ TkWmAddToColormapWindows(winPtr)
*
* TkWmRemoveFromColormapWindows --
*
- * This procedure is called to remove a given window from the
- * WM_COLORMAP_WINDOWS property for its top-level. It is invoked
- * when windows are deleted.
+ * This function is called to remove a given window from the
+ * WM_COLORMAP_WINDOWS property for its top-level. It is invoked when
+ * windows are deleted.
*
* Results:
* None.
*
* Side effects:
- * WinPtr's window gets removed from the WM_COLORMAP_WINDOWS
- * property of its nearest top-level ancestor, unless the
- * top-level itself is being deleted too.
+ * WinPtr's window gets removed from the WM_COLORMAP_WINDOWS property of
+ * its nearest top-level ancestor, unless the top-level itself is being
+ * deleted too.
*
*----------------------------------------------------------------------
*/
void
-TkWmRemoveFromColormapWindows(winPtr)
- TkWindow *winPtr; /* Window that may be present in
+TkWmRemoveFromColormapWindows(
+ TkWindow *winPtr) /* Window that may be present in
* WM_COLORMAP_WINDOWS property for its
- * top-level. Should not be a top-level
+ * top-level. Should not be a top-level
* window. */
{
TkWindow *topPtr;
@@ -6671,8 +6855,8 @@ TkWmRemoveFromColormapWindows(winPtr)
}
if (topPtr->flags & TK_ALREADY_DEAD) {
/*
- * Top-level is being deleted, so there's no need to cleanup
- * the WM_COLORMAP_WINDOWS property.
+ * Top-level is being deleted, so there's no need to cleanup the
+ * WM_COLORMAP_WINDOWS property.
*/
return;
@@ -6683,8 +6867,7 @@ TkWmRemoveFromColormapWindows(winPtr)
}
/*
- * Find the window and slide the following ones down to cover
- * it up.
+ * Find the window and slide the following ones down to cover it up.
*/
count = topPtr->wmInfoPtr->cmapCount;
@@ -6711,16 +6894,16 @@ TkWmRemoveFromColormapWindows(winPtr)
* None.
*
* Side effects:
- * The menu will end up being drawn in the window, and the geometry
- * of the window will have to be changed.
+ * The menu will end up being drawn in the window, and the geometry of
+ * the window will have to be changed.
*
*----------------------------------------------------------------------
*/
void
-TkWinSetMenu(tkwin, hMenu)
- Tk_Window tkwin; /* the window to put the menu in */
- HMENU hMenu; /* the menu to set */
+TkWinSetMenu(
+ Tk_Window tkwin, /* the window to put the menu in */
+ HMENU hMenu) /* the menu to set */
{
TkWindow *winPtr = (TkWindow *) tkwin;
WmInfo *wmPtr = winPtr->wmInfoPtr;
@@ -6742,7 +6925,7 @@ TkWinSetMenu(tkwin, hMenu)
}
} else {
SendMessage(wmPtr->wrapper, TK_SETMENU,
- (WPARAM)hMenu, (LPARAM)Tk_GetMenuHWND(tkwin));
+ (WPARAM)hMenu, (LPARAM)Tk_GetMenuHWND(tkwin));
}
}
@@ -6752,7 +6935,7 @@ TkWinSetMenu(tkwin, hMenu)
* ConfigureTopLevel --
*
* Generate a ConfigureNotify event based on the current position
- * information. This procedure is called by TopLevelProc.
+ * information. This function is called by TopLevelProc.
*
* Results:
* None.
@@ -6764,8 +6947,8 @@ TkWinSetMenu(tkwin, hMenu)
*/
static void
-ConfigureTopLevel(pos)
- WINDOWPOS *pos;
+ConfigureTopLevel(
+ WINDOWPOS *pos)
{
TkWindow *winPtr = GetTopLevel(pos->hwnd);
WmInfo *wmPtr;
@@ -6789,15 +6972,15 @@ ConfigureTopLevel(pos)
windowPos.length = sizeof(WINDOWPLACEMENT);
GetWindowPlacement(wmPtr->wrapper, &windowPos);
switch (windowPos.showCmd) {
- case SW_SHOWMAXIMIZED:
- state = ZoomState;
- break;
- case SW_SHOWMINIMIZED:
- state = IconicState;
- break;
- case SW_SHOWNORMAL:
- state = NormalState;
- break;
+ case SW_SHOWMAXIMIZED:
+ state = ZoomState;
+ break;
+ case SW_SHOWMINIMIZED:
+ state = IconicState;
+ break;
+ case SW_SHOWNORMAL:
+ state = NormalState;
+ break;
}
}
@@ -6809,27 +6992,26 @@ ConfigureTopLevel(pos)
if (wmPtr->hints.initial_state != state) {
wmPtr->hints.initial_state = state;
switch (state) {
- case WithdrawnState:
- case IconicState:
- XUnmapWindow(winPtr->display, winPtr->window);
- break;
+ case WithdrawnState:
+ case IconicState:
+ XUnmapWindow(winPtr->display, winPtr->window);
+ break;
- case NormalState:
- /*
- * Schedule a geometry update. Since we ignore geometry
- * requests while in any other state, the geometry info
- * may be stale.
- */
+ case NormalState:
+ /*
+ * Schedule a geometry update. Since we ignore geometry requests
+ * while in any other state, the geometry info may be stale.
+ */
- if (!(wmPtr->flags & WM_UPDATE_PENDING)) {
- Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr);
- wmPtr->flags |= WM_UPDATE_PENDING;
- }
- /* fall through */
- case ZoomState:
- XMapWindow(winPtr->display, winPtr->window);
- pos->flags |= SWP_NOMOVE | SWP_NOSIZE;
- break;
+ if (!(wmPtr->flags & WM_UPDATE_PENDING)) {
+ Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr);
+ wmPtr->flags |= WM_UPDATE_PENDING;
+ }
+ /* fall through */
+ case ZoomState:
+ XMapWindow(winPtr->display, winPtr->window);
+ pos->flags |= SWP_NOMOVE | SWP_NOSIZE;
+ break;
}
}
@@ -6843,8 +7025,8 @@ ConfigureTopLevel(pos)
/*
- * Compute the current geometry of the client area, reshape the
- * Tk window and generate a ConfigureNotify event.
+ * Compute the current geometry of the client area, reshape the Tk window
+ * and generate a ConfigureNotify event.
*/
GetClientRect(wmPtr->wrapper, &rect);
@@ -6864,16 +7046,16 @@ ConfigureTopLevel(pos)
if (state == NormalState) {
/*
- * Update size information from the event. There are a couple of
+ * Update size information from the event. There are a couple of
* tricky points here:
*
* 1. If the user changed the size externally then set wmPtr->width
* and wmPtr->height just as if a "wm geometry" command had been
* invoked with the same information.
- * 2. However, if the size is changing in response to a request
- * coming from us (sync is set), then don't set
- * wmPtr->width or wmPtr->height (otherwise the window will stop
- * tracking geometry manager requests).
+ * 2. However, if the size is changing in response to a request coming
+ * from us (sync is set), then don't set wmPtr->width or
+ * wmPtr->height (otherwise the window will stop tracking geometry
+ * manager requests).
*/
if (!(wmPtr->flags & WM_SYNC_PENDING)) {
@@ -6881,8 +7063,8 @@ ConfigureTopLevel(pos)
if ((wmPtr->width == -1)
&& (winPtr->changes.width == winPtr->reqWidth)) {
/*
- * Don't set external width, since the user didn't
- * change it from what the widgets asked for.
+ * Don't set external width, since the user didn't change
+ * it from what the widgets asked for.
*/
} else {
if (wmPtr->gridWin != NULL) {
@@ -6917,9 +7099,10 @@ ConfigureTopLevel(pos)
wmPtr->configWidth = winPtr->changes.width;
wmPtr->configHeight = winPtr->changes.height;
}
+
/*
- * If the user moved the window, we should switch back
- * to normal coordinates.
+ * If the user moved the window, we should switch back to normal
+ * coordinates.
*/
if (!(pos->flags & SWP_NOMOVE)) {
@@ -6933,15 +7116,15 @@ ConfigureTopLevel(pos)
if (wmPtr->flags & WM_NEGATIVE_X) {
wmPtr->x = DisplayWidth(winPtr->display, winPtr->screenNum)
- - winPtr->changes.x - (winPtr->changes.width
- + wmPtr->borderWidth);
+ - winPtr->changes.x - (winPtr->changes.width
+ + wmPtr->borderWidth);
} else {
wmPtr->x = winPtr->changes.x;
}
if (wmPtr->flags & WM_NEGATIVE_Y) {
wmPtr->y = DisplayHeight(winPtr->display, winPtr->screenNum)
- - winPtr->changes.y - (winPtr->changes.height
- + wmPtr->borderHeight);
+ - winPtr->changes.y - (winPtr->changes.height
+ + wmPtr->borderHeight);
} else {
wmPtr->y = winPtr->changes.y;
}
@@ -6953,8 +7136,8 @@ ConfigureTopLevel(pos)
*
* GenerateConfigureNotify --
*
- * Generate a ConfigureNotify event from the current geometry
- * information for the specified toplevel window.
+ * Generate a ConfigureNotify event from the current geometry information
+ * for the specified toplevel window.
*
* Results:
* None.
@@ -6966,8 +7149,8 @@ ConfigureTopLevel(pos)
*/
static void
-GenerateConfigureNotify(winPtr)
- TkWindow *winPtr;
+GenerateConfigureNotify(
+ TkWindow *winPtr)
{
XEvent event;
@@ -6996,8 +7179,8 @@ GenerateConfigureNotify(winPtr)
*
* InstallColormaps --
*
- * Installs the colormaps associated with the toplevel which is
- * currently active.
+ * Installs the colormaps associated with the toplevel which is currently
+ * active.
*
* Results:
* None.
@@ -7009,12 +7192,12 @@ GenerateConfigureNotify(winPtr)
*/
static int
-InstallColormaps(hwnd, message, isForemost)
- HWND hwnd; /* Toplevel wrapper window whose colormaps
+InstallColormaps(
+ HWND hwnd, /* Toplevel wrapper window whose colormaps
* should be installed. */
- int message; /* Either WM_PALETTECHANGED or
+ int message, /* Either WM_PALETTECHANGED or
* WM_QUERYNEWPALETTE */
- int isForemost; /* 1 if window is foremost, else 0 */
+ int isForemost) /* 1 if window is foremost, else 0 */
{
int i;
HDC dc;
@@ -7061,11 +7244,11 @@ InstallColormaps(hwnd, message, isForemost)
} else {
/*
- * Window is being notified of a change in the system palette.
- * If this window is the foreground window, then we should only
- * install the secondary palettes, since the primary was installed
- * in response to the WM_QUERYPALETTE message. Otherwise, install
- * all of the palettes.
+ * Window is being notified of a change in the system palette. If this
+ * window is the foreground window, then we should only install the
+ * secondary palettes, since the primary was installed in response to
+ * the WM_QUERYPALETTE message. Otherwise, install all of the
+ * palettes.
*/
@@ -7107,11 +7290,10 @@ InstallColormaps(hwnd, message, isForemost)
*
* RefreshColormap --
*
- * This function is called to force all of the windows that use
- * a given colormap to redraw themselves. The quickest way to
- * do this is to iterate over the toplevels, looking in the
- * cmapList for matches. This will quickly eliminate subtrees
- * that don't use a given colormap.
+ * This function is called to force all of the windows that use a given
+ * colormap to redraw themselves. The quickest way to do this is to
+ * iterate over the toplevels, looking in the cmapList for matches. This
+ * will quickly eliminate subtrees that don't use a given colormap.
*
* Results:
* None.
@@ -7123,9 +7305,9 @@ InstallColormaps(hwnd, message, isForemost)
*/
static void
-RefreshColormap(colormap, dispPtr)
- Colormap colormap;
- TkDisplay *dispPtr;
+RefreshColormap(
+ Colormap colormap,
+ TkDisplay *dispPtr)
{
WmInfo *wmPtr;
int i;
@@ -7150,9 +7332,9 @@ RefreshColormap(colormap, dispPtr)
*
* InvalidateSubTree --
*
- * This function recursively generates damage for a window and
- * all of its mapped children that belong to the same toplevel and
- * are using the specified colormap.
+ * This function recursively generates damage for a window and all of its
+ * mapped children that belong to the same toplevel and are using the
+ * specified colormap.
*
* Results:
* None.
@@ -7164,15 +7346,15 @@ RefreshColormap(colormap, dispPtr)
*/
static void
-InvalidateSubTree(winPtr, colormap)
- TkWindow *winPtr;
- Colormap colormap;
+InvalidateSubTree(
+ TkWindow *winPtr,
+ Colormap colormap)
{
TkWindow *childPtr;
/*
- * Generate damage for the current window if it is using the
- * specified colormap.
+ * Generate damage for the current window if it is using the specified
+ * colormap.
*/
if (winPtr->atts.colormap == colormap) {
@@ -7182,8 +7364,7 @@ InvalidateSubTree(winPtr, colormap)
for (childPtr = winPtr->childList; childPtr != NULL;
childPtr = childPtr->nextPtr) {
/*
- * We can stop the descent when we hit an unmapped or
- * toplevel window.
+ * We can stop the descent when we hit an unmapped or toplevel window.
*/
if (!Tk_TopWinHierarchy(childPtr) && Tk_IsMapped(childPtr)) {
@@ -7197,8 +7378,8 @@ InvalidateSubTree(winPtr, colormap)
*
* InvalidateSubTreeDepth --
*
- * This function recursively updates depth info for a window and
- * all of its children that belong to the same toplevel.
+ * This function recursively updates depth info for a window and all of
+ * its children that belong to the same toplevel.
*
* Results:
* None.
@@ -7210,8 +7391,8 @@ InvalidateSubTree(winPtr, colormap)
*/
static void
-InvalidateSubTreeDepth(winPtr)
- TkWindow *winPtr;
+InvalidateSubTreeDepth(
+ TkWindow *winPtr)
{
Display *display = Tk_Display(winPtr);
int screenNum = Tk_ScreenNumber(winPtr);
@@ -7221,10 +7402,10 @@ InvalidateSubTreeDepth(winPtr)
#if 0
/*
- * XXX: What other elements may require changes? Changing just
- * the depth works for standard windows and 16/24/32-bpp changes.
- * I suspect 8-bit (palettized) displays may require colormap and/or
- * visual changes as well.
+ * XXX: What other elements may require changes? Changing just the depth
+ * works for standard windows and 16/24/32-bpp changes. I suspect 8-bit
+ * (palettized) displays may require colormap and/or visual changes as
+ * well.
*/
if (winPtr->window) {
@@ -7238,7 +7419,7 @@ InvalidateSubTreeDepth(winPtr)
for (childPtr = winPtr->childList; childPtr != NULL;
childPtr = childPtr->nextPtr) {
/*
- * We can stop the descent when we hit a non-embedded toplevel window,
+ * We can stop the descent when we hit a non-embedded toplevel window,
* as it should get its own message.
*/
@@ -7256,8 +7437,8 @@ InvalidateSubTreeDepth(winPtr)
* Retrieves the currently installed foreground palette.
*
* Results:
- * Returns the global foreground palette, if there is one.
- * Otherwise, returns NULL.
+ * Returns the global foreground palette, if there is one. Otherwise,
+ * returns NULL.
*
* Side effects:
* None.
@@ -7266,7 +7447,7 @@ InvalidateSubTreeDepth(winPtr)
*/
HPALETTE
-TkWinGetSystemPalette()
+TkWinGetSystemPalette(void)
{
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
@@ -7279,17 +7460,16 @@ TkWinGetSystemPalette()
*
* GetMinSize --
*
- * This procedure computes the current minWidth and minHeight
- * values for a window, taking into account the possibility
- * that they may be defaulted.
+ * This function computes the current minWidth and minHeight values for a
+ * window, taking into account the possibility that they may be
+ * defaulted.
*
* Results:
- * The values at *minWidthPtr and *minHeightPtr are filled
- * in with the minimum allowable dimensions of wmPtr's window,
- * in grid units. If the requested minimum is smaller than the
- * system required minimum, then this procedure computes the
- * smallest size that will satisfy both the system and the
- * grid constraints.
+ * The values at *minWidthPtr and *minHeightPtr are filled in with the
+ * minimum allowable dimensions of wmPtr's window, in grid units. If the
+ * requested minimum is smaller than the system required minimum, then
+ * this function computes the smallest size that will satisfy both the
+ * system and the grid constraints.
*
* Side effects:
* None.
@@ -7298,21 +7478,21 @@ TkWinGetSystemPalette()
*/
static void
-GetMinSize(wmPtr, minWidthPtr, minHeightPtr)
- WmInfo *wmPtr; /* Window manager information for the
+GetMinSize(
+ WmInfo *wmPtr, /* Window manager information for the
* window. */
- int *minWidthPtr; /* Where to store the current minimum
- * width of the window. */
- int *minHeightPtr; /* Where to store the current minimum
- * height of the window. */
+ int *minWidthPtr, /* Where to store the current minimum width of
+ * the window. */
+ int *minHeightPtr) /* Where to store the current minimum height
+ * of the window. */
{
int tmp, base;
TkWindow *winPtr = wmPtr->winPtr;
/*
- * Compute the minimum width by taking the default client size
- * and rounding it up to the nearest grid unit. Return the greater
- * of the default minimum and the specified minimum.
+ * Compute the minimum width by taking the default client size and
+ * rounding it up to the nearest grid unit. Return the greater of the
+ * default minimum and the specified minimum.
*/
tmp = wmPtr->defMinWidth - wmPtr->borderWidth;
@@ -7357,15 +7537,15 @@ GetMinSize(wmPtr, minWidthPtr, minHeightPtr)
*
* GetMaxSize --
*
- * This procedure computes the current maxWidth and maxHeight
- * values for a window, taking into account the possibility
- * that they may be defaulted.
+ * This function computes the current maxWidth and maxHeight values for a
+ * window, taking into account the possibility that they may be
+ * defaulted.
*
* Results:
* The values at *maxWidthPtr and *maxHeightPtr are filled
* in with the maximum allowable dimensions of wmPtr's window,
* in grid units. If no maximum has been specified for the
- * window, then this procedure computes the largest sizes that
+ * window, then this function computes the largest sizes that
* will fit on the screen.
*
* Side effects:
@@ -7375,13 +7555,13 @@ GetMinSize(wmPtr, minWidthPtr, minHeightPtr)
*/
static void
-GetMaxSize(wmPtr, maxWidthPtr, maxHeightPtr)
- WmInfo *wmPtr; /* Window manager information for the
+GetMaxSize(
+ WmInfo *wmPtr, /* Window manager information for the
* window. */
- int *maxWidthPtr; /* Where to store the current maximum
- * width of the window. */
- int *maxHeightPtr; /* Where to store the current maximum
- * height of the window. */
+ int *maxWidthPtr, /* Where to store the current maximum width of
+ * the window. */
+ int *maxHeightPtr) /* Where to store the current maximum height
+ * of the window. */
{
int tmp;
@@ -7389,14 +7569,14 @@ GetMaxSize(wmPtr, maxWidthPtr, maxHeightPtr)
*maxWidthPtr = wmPtr->maxWidth;
} else {
/*
- * Must compute a default width. Fill up the display, leaving a
- * bit of extra space for the window manager's borders.
+ * Must compute a default width. Fill up the display, leaving a bit of
+ * extra space for the window manager's borders.
*/
tmp = wmPtr->defMaxWidth - wmPtr->borderWidth;
if (wmPtr->gridWin != NULL) {
/*
- * Gridding is turned on; convert from pixels to grid units.
+ * Gridding is turned on; convert from pixels to grid units.
*/
tmp = wmPtr->reqGridWidth
@@ -7421,8 +7601,7 @@ GetMaxSize(wmPtr, maxWidthPtr, maxHeightPtr)
*
* TopLevelProc --
*
- * Callback from Windows whenever an event occurs on a top level
- * window.
+ * Callback from Windows whenever an event occurs on a top level window.
*
* Results:
* Standard Windows return value.
@@ -7434,11 +7613,11 @@ GetMaxSize(wmPtr, maxWidthPtr, maxHeightPtr)
*/
static LRESULT CALLBACK
-TopLevelProc(hwnd, message, wParam, lParam)
- HWND hwnd;
- UINT message;
- WPARAM wParam;
- LPARAM lParam;
+TopLevelProc(
+ HWND hwnd,
+ UINT message,
+ WPARAM wParam,
+ LPARAM lParam)
{
if (message == WM_WINDOWPOSCHANGED || message == WM_WINDOWPOSCHANGING) {
WINDOWPOS *pos = (WINDOWPOS *) lParam;
@@ -7457,7 +7636,8 @@ TopLevelProc(hwnd, message, wParam, lParam)
winPtr->changes.height = pos->cy;
}
if (!(pos->flags & SWP_NOMOVE)) {
- long result = SendMessage(winPtr->wmInfoPtr->wrapper, TK_MOVEWINDOW, -1, -1);
+ long result = SendMessage(winPtr->wmInfoPtr->wrapper,
+ TK_MOVEWINDOW, -1, -1);
winPtr->wmInfoPtr->x = winPtr->changes.x = result >> 16;
winPtr->wmInfoPtr->y = winPtr->changes.y = result & 0xffff;
}
@@ -7488,189 +7668,195 @@ TopLevelProc(hwnd, message, wParam, lParam)
*/
static LRESULT CALLBACK
-WmProc(hwnd, message, wParam, lParam)
- HWND hwnd;
- UINT message;
- WPARAM wParam;
- LPARAM lParam;
+WmProc(
+ HWND hwnd,
+ UINT message,
+ WPARAM wParam,
+ LPARAM lParam)
{
static int inMoveSize = 0;
- static int oldMode; /* This static is set upon entering move/size mode
- * and is used to reset the service mode after
- * leaving move/size mode. Note that this mechanism
- * assumes move/size is only one level deep. */
+ static int oldMode; /* This static is set upon entering move/size
+ * mode and is used to reset the service mode
+ * after leaving move/size mode. Note that
+ * this mechanism assumes move/size is only
+ * one level deep. */
LRESULT result;
TkWindow *winPtr = NULL;
switch (message) {
- case WM_KILLFOCUS:
- case WM_ERASEBKGND:
- result = 0;
- goto done;
-
- case WM_ENTERSIZEMOVE:
- inMoveSize = 1;
-
- /*
- * Cancel any current mouse timer. If the mouse timer
- * fires during the size/move mouse capture, it will
- * release the capture, which is wrong.
- */
+ case WM_KILLFOCUS:
+ case WM_ERASEBKGND:
+ result = 0;
+ goto done;
- TkWinCancelMouseTimer();
+ case WM_ENTERSIZEMOVE:
+ inMoveSize = 1;
- oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
- break;
-
- case WM_ACTIVATE:
- case WM_EXITSIZEMOVE:
- if (inMoveSize) {
- inMoveSize = 0;
- Tcl_SetServiceMode(oldMode);
- }
- break;
+ /*
+ * Cancel any current mouse timer. If the mouse timer fires during the
+ * size/move mouse capture, it will release the capture, which is
+ * wrong.
+ */
- case WM_GETMINMAXINFO:
- SetLimits(hwnd, (MINMAXINFO *) lParam);
- result = 0;
- goto done;
+ TkWinCancelMouseTimer();
- case WM_DISPLAYCHANGE:
- /* display and/or color resolution changed */
- winPtr = GetTopLevel(hwnd);
- if (winPtr) {
- Screen *screen = Tk_Screen(winPtr);
- if (screen->root_depth != (int) wParam) {
- /*
- * Color resolution changed, so do extensive rebuild of
- * display parameters. This will affect the display for
- * all Tk windows. We will receive this event for each
- * toplevel, but this check makes us update only once, for
- * the first toplevel that receives the message.
- */
- TkWinDisplayChanged(Tk_Display(winPtr));
- } else {
- HDC dc = GetDC(NULL);
- screen->width = LOWORD(lParam); /* horizontal res */
- screen->height = HIWORD(lParam); /* vertical res */
- screen->mwidth = MulDiv(screen->width, 254,
- GetDeviceCaps(dc, LOGPIXELSX) * 10);
- screen->mheight = MulDiv(screen->height, 254,
- GetDeviceCaps(dc, LOGPIXELSY) * 10);
- ReleaseDC(NULL, dc);
- }
- if (Tk_Depth(winPtr) != (int) wParam) {
- /*
- * Defer the window depth check to here so that each
- * toplevel will properly update depth info.
- */
- InvalidateSubTreeDepth(winPtr);
- }
- }
- result = 0;
- goto done;
+ oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
+ break;
- case WM_SYSCOLORCHANGE:
- /*
- * XXX: Called when system color changes. We need to
- * update any widgets that use a system color.
- */
- break;
+ case WM_ACTIVATE:
+ case WM_EXITSIZEMOVE:
+ if (inMoveSize) {
+ inMoveSize = 0;
+ Tcl_SetServiceMode(oldMode);
+ }
+ break;
- case WM_PALETTECHANGED:
- result = InstallColormaps(hwnd, WM_PALETTECHANGED,
- hwnd == (HWND)wParam);
- goto done;
+ case WM_GETMINMAXINFO:
+ SetLimits(hwnd, (MINMAXINFO *) lParam);
+ result = 0;
+ goto done;
- case WM_QUERYNEWPALETTE:
- result = InstallColormaps(hwnd, WM_QUERYNEWPALETTE, TRUE);
- goto done;
+ case WM_DISPLAYCHANGE:
+ /*
+ * Display and/or color resolution changed.
+ */
- case WM_WINDOWPOSCHANGED:
- ConfigureTopLevel((WINDOWPOS *) lParam);
- result = 0;
- goto done;
+ winPtr = GetTopLevel(hwnd);
+ if (winPtr) {
+ Screen *screen = Tk_Screen(winPtr);
+ if (screen->root_depth != (int) wParam) {
+ /*
+ * Color resolution changed, so do extensive rebuild of
+ * display parameters. This will affect the display for all Tk
+ * windows. We will receive this event for each toplevel, but
+ * this check makes us update only once, for the first
+ * toplevel that receives the message.
+ */
- case WM_NCHITTEST: {
- winPtr = GetTopLevel(hwnd);
- if (winPtr && (TkGrabState(winPtr) == TK_GRAB_EXCLUDED)) {
+ TkWinDisplayChanged(Tk_Display(winPtr));
+ } else {
+ HDC dc = GetDC(NULL);
+
+ screen->width = LOWORD(lParam); /* horizontal res */
+ screen->height = HIWORD(lParam); /* vertical res */
+ screen->mwidth = MulDiv(screen->width, 254,
+ GetDeviceCaps(dc, LOGPIXELSX) * 10);
+ screen->mheight = MulDiv(screen->height, 254,
+ GetDeviceCaps(dc, LOGPIXELSY) * 10);
+ ReleaseDC(NULL, dc);
+ }
+ if (Tk_Depth(winPtr) != (int) wParam) {
/*
- * This window is outside the grab heirarchy, so don't let any
- * of the normal non-client processing occur. Note that this
- * implementation is not strictly correct because the grab
- * might change between now and when the event would have been
- * processed by Tk, but it's close enough.
+ * Defer the window depth check to here so that each toplevel
+ * will properly update depth info.
*/
- result = HTCLIENT;
- goto done;
+ InvalidateSubTreeDepth(winPtr);
}
- break;
}
+ result = 0;
+ goto done;
- case WM_MOUSEACTIVATE: {
- ActivateEvent *eventPtr;
- winPtr = GetTopLevel((HWND) wParam);
+ case WM_SYSCOLORCHANGE:
+ /*
+ * XXX: Called when system color changes. We need to update any
+ * widgets that use a system color.
+ */
- if (winPtr && (TkGrabState(winPtr) != TK_GRAB_EXCLUDED)) {
- /*
- * This allows us to pass the message onto the
- * native menus [Bug: 2272]
- */
- result = (*tkWinProcs->defWindowProc)(hwnd, message,
- wParam, lParam);
- goto done;
- }
+ break;
+
+ case WM_PALETTECHANGED:
+ result = InstallColormaps(hwnd, WM_PALETTECHANGED,
+ hwnd == (HWND)wParam);
+ goto done;
+
+ case WM_QUERYNEWPALETTE:
+ result = InstallColormaps(hwnd, WM_QUERYNEWPALETTE, TRUE);
+ goto done;
+ case WM_WINDOWPOSCHANGED:
+ ConfigureTopLevel((WINDOWPOS *) lParam);
+ result = 0;
+ goto done;
+
+ case WM_NCHITTEST: {
+ winPtr = GetTopLevel(hwnd);
+ if (winPtr && (TkGrabState(winPtr) == TK_GRAB_EXCLUDED)) {
/*
- * Don't activate the window yet since there is a grab
- * that takes precedence. Instead we need to queue
- * an event so we can check the grab state right before we
- * handle the mouse event.
+ * This window is outside the grab heirarchy, so don't let any of
+ * the normal non-client processing occur. Note that this
+ * implementation is not strictly correct because the grab might
+ * change between now and when the event would have been processed
+ * by Tk, but it's close enough.
*/
- if (winPtr) {
- eventPtr = (ActivateEvent *)ckalloc(sizeof(ActivateEvent));
- eventPtr->ev.proc = ActivateWindow;
- eventPtr->winPtr = winPtr;
- Tcl_QueueEvent((Tcl_Event*)eventPtr, TCL_QUEUE_TAIL);
- }
- result = MA_NOACTIVATE;
+ result = HTCLIENT;
goto done;
}
+ break;
+ }
- default:
- break;
+ case WM_MOUSEACTIVATE: {
+ ActivateEvent *eventPtr;
+ winPtr = GetTopLevel((HWND) wParam);
+
+ if (winPtr && (TkGrabState(winPtr) != TK_GRAB_EXCLUDED)) {
+ /*
+ * This allows us to pass the message onto the native menus [Bug:
+ * 2272]
+ */
+
+ result = (*tkWinProcs->defWindowProc)(hwnd, message,
+ wParam, lParam);
+ goto done;
+ }
+
+ /*
+ * Don't activate the window yet since there is a grab that takes
+ * precedence. Instead we need to queue an event so we can check the
+ * grab state right before we handle the mouse event.
+ */
+
+ if (winPtr) {
+ eventPtr = (ActivateEvent *)ckalloc(sizeof(ActivateEvent));
+ eventPtr->ev.proc = ActivateWindow;
+ eventPtr->winPtr = winPtr;
+ Tcl_QueueEvent((Tcl_Event*)eventPtr, TCL_QUEUE_TAIL);
+ }
+ result = MA_NOACTIVATE;
+ goto done;
+ }
+
+ default:
+ break;
}
winPtr = GetTopLevel(hwnd);
switch(message) {
- case WM_SYSCOMMAND:
- case WM_INITMENU:
- case WM_COMMAND:
- case WM_MENUCHAR:
- case WM_MEASUREITEM:
- case WM_DRAWITEM:
- case WM_MENUSELECT:
- case WM_ENTERIDLE:
- case WM_INITMENUPOPUP:
- {
- HWND hMenuHWnd = Tk_GetEmbeddedMenuHWND((Tk_Window)winPtr);
- if(hMenuHWnd) {
- if(SendMessage(hMenuHWnd, message, wParam, lParam)) {
- goto done;
- }
- } else {
- if (TkWinHandleMenuEvent(&hwnd, &message, &wParam, &lParam, &result)) {
- goto done;
- }
+ case WM_SYSCOMMAND:
+ case WM_INITMENU:
+ case WM_COMMAND:
+ case WM_MENUCHAR:
+ case WM_MEASUREITEM:
+ case WM_DRAWITEM:
+ case WM_MENUSELECT:
+ case WM_ENTERIDLE:
+ case WM_INITMENUPOPUP: {
+ HWND hMenuHWnd = Tk_GetEmbeddedMenuHWND((Tk_Window)winPtr);
+ if (hMenuHWnd) {
+ if (SendMessage(hMenuHWnd, message, wParam, lParam)) {
+ goto done;
}
+ } else if (TkWinHandleMenuEvent(&hwnd, &message, &wParam, &lParam,
+ &result)) {
+ goto done;
}
break;
}
if (winPtr && winPtr->window) {
HWND child = Tk_GetHWND(winPtr->window);
+
if (message == WM_SETFOCUS) {
SetFocus(child);
result = 0;
@@ -7683,7 +7869,7 @@ WmProc(hwnd, message, wParam, lParam)
result = (*tkWinProcs->defWindowProc)(hwnd, message, wParam, lParam);
}
- done:
+ done:
Tcl_ServiceAll();
return result;
}
@@ -7693,8 +7879,8 @@ WmProc(hwnd, message, wParam, lParam)
*
* TkpMakeMenuWindow --
*
- * Configure the window to be either a pull-down (or pop-up)
- * menu, or as a toplevel (torn-off) menu or palette.
+ * Configure the window to be either a pull-down (or pop-up) menu, or as
+ * a toplevel (torn-off) menu or palette.
*
* Results:
* None.
@@ -7706,12 +7892,12 @@ WmProc(hwnd, message, wParam, lParam)
*/
void
-TkpMakeMenuWindow(tkwin, transient)
- Tk_Window tkwin; /* New window. */
- int transient; /* 1 means menu is only posted briefly as
- * a popup or pulldown or cascade. 0 means
- * menu is always visible, e.g. as a torn-off
- * menu. Determines whether save_under and
+TkpMakeMenuWindow(
+ Tk_Window tkwin, /* New window. */
+ int transient) /* 1 means menu is only posted briefly as a
+ * popup or pulldown or cascade. 0 means menu
+ * is always visible, e.g. as a torn-off menu.
+ * Determines whether save_under and
* override_redirect should be set. */
{
XSetWindowAttributes atts;
@@ -7755,23 +7941,21 @@ TkWinGetWrapperWindow(
TkWindow *winPtr = (TkWindow *)tkwin;
return (winPtr->wmInfoPtr->wrapper);
}
-
/*
*----------------------------------------------------------------------
*
* TkWmFocusToplevel --
*
- * This is a utility procedure invoked by focus-management code. It
- * exists because of the extra wrapper windows that exist under
- * Unix; its job is to map from wrapper windows to the
- * corresponding toplevel windows. On PCs and Macs there are no
- * wrapper windows so no mapping is necessary; this procedure just
- * determines whether a window is a toplevel or not.
+ * This is a utility function invoked by focus-management code. It exists
+ * because of the extra wrapper windows that exist under Unix; its job is
+ * to map from wrapper windows to the corresponding toplevel windows. On
+ * PCs and Macs there are no wrapper windows so no mapping is necessary;
+ * this function just determines whether a window is a toplevel or not.
*
* Results:
- * If winPtr is a toplevel window, returns the pointer to the
- * window; otherwise returns NULL.
+ * If winPtr is a toplevel window, returns the pointer to the window;
+ * otherwise returns NULL.
*
* Side effects:
* None.
@@ -7780,8 +7964,8 @@ TkWinGetWrapperWindow(
*/
TkWindow *
-TkWmFocusToplevel(winPtr)
- TkWindow *winPtr; /* Window that received a focus-related
+TkWmFocusToplevel(
+ TkWindow *winPtr) /* Window that received a focus-related
* event. */
{
if (!(winPtr->flags & TK_TOP_HIERARCHY)) {
@@ -7789,19 +7973,19 @@ TkWmFocusToplevel(winPtr)
}
return winPtr;
}
-
+
/*
*----------------------------------------------------------------------
*
* TkpGetWrapperWindow --
*
- * This is a utility procedure invoked by focus-management code. It
- * maps to the wrapper for a top-level, which is just the same
- * as the top-level on Macs and PCs.
+ * This is a utility function invoked by focus-management code. It maps
+ * to the wrapper for a top-level, which is just the same as the
+ * top-level on Macs and PCs.
*
* Results:
- * If winPtr is a toplevel window, returns the pointer to the
- * window; otherwise returns NULL.
+ * If winPtr is a toplevel window, returns the pointer to the window;
+ * otherwise returns NULL.
*
* Side effects:
* None.
@@ -7850,8 +8034,8 @@ ActivateWindow(
winPtr = ((ActivateEvent *) evPtr)->winPtr;
/*
- * If the window is excluded by a grab, call SetFocus on the
- * grabbed window instead. [Bug 220908]
+ * If the window is excluded by a grab, call SetFocus on the grabbed
+ * window instead. [Bug 220908]
*/
if (winPtr) {
@@ -7864,16 +8048,14 @@ ActivateWindow(
return 1;
}
-
/*
*----------------------------------------------------------------------
*
* TkWinSetForegroundWindow --
*
- * This function is a wrapper for SetForegroundWindow, calling
- * it on the wrapper window because it has no affect on child
- * windows.
+ * This function is a wrapper for SetForegroundWindow, calling it on the
+ * wrapper window because it has no affect on child windows.
*
* Results:
* none
@@ -7885,8 +8067,8 @@ ActivateWindow(
*/
void
-TkWinSetForegroundWindow(winPtr)
- TkWindow *winPtr;
+TkWinSetForegroundWindow(
+ TkWindow *winPtr)
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
@@ -7896,14 +8078,14 @@ TkWinSetForegroundWindow(winPtr)
SetForegroundWindow(Tk_GetHWND(winPtr->window));
}
}
-
+
/*
*----------------------------------------------------------------------
*
* TkpWinToplevelWithdraw --
*
- * This function is to be used by a window manage to withdraw
- * a toplevel window.
+ * This function is to be used by a window manage to withdraw a toplevel
+ * window.
*
* Results:
* none
@@ -7913,7 +8095,8 @@ TkWinSetForegroundWindow(winPtr)
*
*----------------------------------------------------------------------
*/
-void
+
+void
TkpWinToplevelWithDraw(winPtr)
TkWindow *winPtr;
{
@@ -7927,8 +8110,8 @@ TkpWinToplevelWithDraw(winPtr)
*
* TkpWinToplevelIconify --
*
- * This function is to be used by a window manage to iconify
- * a toplevel window.
+ * This function is to be used by a window manage to iconify a toplevel
+ * window.
*
* Results:
* none
@@ -7938,19 +8121,20 @@ TkpWinToplevelWithDraw(winPtr)
*
*----------------------------------------------------------------------
*/
-void TkpWinToplevelIconify(winPtr)
- TkWindow *winPtr;
+
+void TkpWinToplevelIconify(
+ TkWindow *winPtr)
{
TkpWmSetState(winPtr, IconicState);
}
-
+
/*
*----------------------------------------------------------------------
*
* TkpWinToplevelDeiconify --
*
- * This function is to be used by a window manage to deiconify
- * a toplevel window.
+ * This function is to be used by a window manage to deiconify a toplevel
+ * window.
*
* Results:
* none
@@ -7960,19 +8144,20 @@ void TkpWinToplevelIconify(winPtr)
*
*----------------------------------------------------------------------
*/
-void TkpWinToplevelDeiconify(winPtr)
- TkWindow *winPtr;
+
+void TkpWinToplevelDeiconify(
+ TkWindow *winPtr)
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
wmPtr->flags &= ~WM_WITHDRAWN;
/*
- * If WM_UPDATE_PENDING is true, a pending UpdateGeometryInfo may
- * need to be called first to update a withdrawn toplevel's geometry
- * before it is deiconified by TkpWmSetState.
- * Don't bother if we've never been mapped.
+ * If WM_UPDATE_PENDING is true, a pending UpdateGeometryInfo may need to
+ * be called first to update a withdrawn toplevel's geometry before it is
+ * deiconified by TkpWmSetState. Don't bother if we've never been mapped.
*/
+
if ((wmPtr->flags & WM_UPDATE_PENDING) &&
!(wmPtr->flags & WM_NEVER_MAPPED)) {
Tcl_CancelIdleCall(UpdateGeometryInfo, (ClientData) winPtr);
@@ -7980,9 +8165,10 @@ void TkpWinToplevelDeiconify(winPtr)
}
/*
- * If we were in the ZoomState (maximized), 'wm deiconify'
- * should not cause the window to shrink
+ * If we were in the ZoomState (maximized), 'wm deiconify' should not
+ * cause the window to shrink
*/
+
if (wmPtr->hints.initial_state == ZoomState) {
TkpWmSetState(winPtr, ZoomState);
} else {
@@ -7990,10 +8176,10 @@ void TkpWinToplevelDeiconify(winPtr)
}
/*
- * An unmapped window will be mapped at idle time
- * by a call to MapFrame. That calls CreateWrapper
- * which sets the focus and raises the window.
+ * An unmapped window will be mapped at idle time by a call to MapFrame.
+ * That calls CreateWrapper which sets the focus and raises the window.
*/
+
if (wmPtr->flags & WM_NEVER_MAPPED) {
return;
}
@@ -8001,19 +8187,20 @@ void TkpWinToplevelDeiconify(winPtr)
/*
* Follow Windows-like style here, raising the window to the top.
*/
+
TkWmRestackToplevel(winPtr, Above, NULL);
if (!(Tk_Attributes((Tk_Window) winPtr)->override_redirect)) {
TkSetFocusWin(winPtr, 1);
}
}
-
+
/*
*----------------------------------------------------------------------
*
* TkpWinGeometryIsControlledByWm --
*
- * This function is to be used by a window manage to see if
- * wm has canceled geometry control.
+ * This function is to be used by a window manage to see if wm has
+ * canceled geometry control.
*
* Results:
* 0 - if the window manager has canceled its control
@@ -8024,27 +8211,29 @@ void TkpWinToplevelDeiconify(winPtr)
*
*----------------------------------------------------------------------
*/
-long TkpWinToplevelIsControlledByWm(winPtr)
- TkWindow *winPtr;
+
+long
+TkpWinToplevelIsControlledByWm(
+ TkWindow *winPtr)
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
- if(wmPtr) {
+
+ if (wmPtr) {
return ((wmPtr->width != -1) && (wmPtr->height != -1))? 1:0;
} else {
return 0;
}
}
-
+
/*
*----------------------------------------------------------------------
*
* TkpWinToplevelMove --
*
- * This function is to be used by a container to move
- * an embedded window.
+ * This function is to be used by a container to move an embedded window.
*
* Results:
- * position of the upper left frame in a 32-bit long:
+ * position of the upper left frame in a 32-bit long:
* 16-MSBits - x; 16-LSBits - y
*
* Side effects:
@@ -8052,24 +8241,28 @@ long TkpWinToplevelIsControlledByWm(winPtr)
*
*----------------------------------------------------------------------
*/
-long TkpWinToplevelMove(winPtr, x, y)
- TkWindow *winPtr;
- int x, y;
+
+long
+TkpWinToplevelMove(
+ TkWindow *winPtr,
+ int x, int y)
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
- if(wmPtr && x >= 0 && y >= 0 && !TkpWinToplevelIsControlledByWm(winPtr)) {
+
+ if (wmPtr && x >= 0 && y >= 0 && !TkpWinToplevelIsControlledByWm(winPtr)) {
Tk_MoveToplevelWindow((Tk_Window)winPtr, x, y);
}
- return ((winPtr->changes.x << 16) & 0xffff0000) | (winPtr->changes.y & 0xffff);
+ return ((winPtr->changes.x << 16) & 0xffff0000)
+ | (winPtr->changes.y & 0xffff);
}
-
+
/*
*----------------------------------------------------------------------
*
* TkpWinToplevelOverrideRedirect --
*
- * This function is to be used by a container to overrideredirect
- * the contaner's frame window.
+ * This function is to be used by a container to overrideredirect the
+ * contaner's frame window.
*
* Results:
* The current overrideredirect value
@@ -8079,9 +8272,11 @@ long TkpWinToplevelMove(winPtr, x, y)
*
*----------------------------------------------------------------------
*/
-long TkpWinToplevelOverrideRedirect(winPtr, reqValue)
- TkWindow *winPtr;
- int reqValue;
+
+long
+TkpWinToplevelOverrideRedirect(
+ TkWindow *winPtr,
+ int reqValue)
{
int curValue;
register WmInfo *wmPtr = winPtr->wmInfoPtr;
@@ -8091,21 +8286,23 @@ long TkpWinToplevelOverrideRedirect(winPtr, reqValue)
if (curValue != reqValue) {
XSetWindowAttributes atts;
+
/*
- * Only do this if we are really changing value, because it
- * causes some funky stuff to occur
+ * Only do this if we are really changing value, because it causes
+ * some funky stuff to occur
*/
+
atts.override_redirect = reqValue ? True : False;
Tk_ChangeWindowAttributes((Tk_Window) winPtr, CWOverrideRedirect,
&atts);
if (!(wmPtr->flags & (WM_NEVER_MAPPED))
- && !(winPtr->flags & TK_EMBEDDED)) {
+ && !(winPtr->flags & TK_EMBEDDED)) {
UpdateWrapper(winPtr);
}
}
return reqValue;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -8123,19 +8320,33 @@ long TkpWinToplevelOverrideRedirect(winPtr, reqValue)
*----------------------------------------------------------------------
*/
-void TkpWinToplevelDetachWindow(winPtr)
- TkWindow *winPtr;
+void
+TkpWinToplevelDetachWindow(
+ TkWindow *winPtr)
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
- if(winPtr->flags & TK_EMBEDDED) {
- int state = SendMessage(wmPtr->wrapper, TK_STATE, -1, -1)-1;
+
+ if (winPtr->flags & TK_EMBEDDED) {
+ int state = SendMessage(wmPtr->wrapper, TK_STATE, -1, -1) - 1;
+
SendMessage(wmPtr->wrapper, TK_SETMENU, 0, 0);
SendMessage(wmPtr->wrapper, TK_DETACHWINDOW, 0, 0);
winPtr->flags &= ~TK_EMBEDDED;
winPtr->privatePtr = NULL;
wmPtr->wrapper = None;
- if(state >= 0 && state <= 3) wmPtr->hints.initial_state = state;
+ if (state >= 0 && state <= 3) {
+ wmPtr->hints.initial_state = state;
+ }
}
- if(winPtr->flags & TK_TOP_LEVEL)
+ if (winPtr->flags & TK_TOP_LEVEL) {
TkpWinToplevelOverrideRedirect(winPtr, 1);
+ }
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/win/tkWinX.c b/win/tkWinX.c
index d13e59a..1ee8171 100644
--- a/win/tkWinX.c
+++ b/win/tkWinX.c
@@ -1,16 +1,16 @@
-/*
+/*
* tkWinX.c --
*
- * This file contains Windows emulation procedures for X routines.
+ * This file contains Windows emulation procedures for X routines.
*
* Copyright (c) 1995-1996 Sun Microsystems, Inc.
* Copyright (c) 1994 Software Research Associates, Inc.
* Copyright (c) 1998-2000 by Scriptics Corporation.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinX.c,v 1.49 2005/08/21 03:29:22 mistachkin Exp $
+ * RCS: @(#) $Id: tkWinX.c,v 1.50 2005/12/02 00:19:04 dkf Exp $
*/
/*
@@ -24,9 +24,9 @@
#include "tkWinInt.h"
/*
- * The w32api 1.1 package (included in Mingw 1.1) does not define _WIN32_IE
- * by default. Define it here to gain access to the InitCommonControlsEx API
- * in commctrl.h.
+ * The w32api 1.1 package (included in Mingw 1.1) does not define _WIN32_IE by
+ * default. Define it here to gain access to the InitCommonControlsEx API in
+ * commctrl.h.
*/
#ifndef _WIN32_IE
@@ -109,38 +109,37 @@ static int keyInputCharset = -1; /* The Win32 CHARSET for the keyboard
static Tcl_Encoding unicodeEncoding = NULL; /* unicode encoding */
/*
- * Thread local storage. Notice that now each thread must have its
- * own TkDisplay structure, since this structure contains most of
- * the thread-specific date for threads.
+ * Thread local storage. Notice that now each thread must have its own
+ * TkDisplay structure, since this structure contains most of the
+ * thread-specific date for threads.
*/
+
typedef struct ThreadSpecificData {
- TkDisplay *winDisplay; /* TkDisplay structure that *
- * represents Windows screen. */
- int updatingClipboard; /* If 1, we are updating the clipboard */
+ TkDisplay *winDisplay; /* TkDisplay structure that represents Windows
+ * screen. */
+ int updatingClipboard; /* If 1, we are updating the clipboard. */
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
/*
- * Forward declarations of procedures used in this file.
+ * Forward declarations of functions used in this file.
*/
-static void GenerateXEvent _ANSI_ARGS_((HWND hwnd, UINT message,
- WPARAM wParam, LPARAM lParam));
-static unsigned int GetState _ANSI_ARGS_((UINT message, WPARAM wParam,
- LPARAM lParam));
-static void GetTranslatedKey _ANSI_ARGS_((XKeyEvent *xkey));
-static void UpdateInputLanguage _ANSI_ARGS_((int charset));
-static int HandleIMEComposition _ANSI_ARGS_((HWND hwnd,
- LPARAM lParam));
+static void GenerateXEvent(HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam);
+static unsigned int GetState(UINT message, WPARAM wParam, LPARAM lParam);
+static void GetTranslatedKey(XKeyEvent *xkey);
+static void UpdateInputLanguage(int charset);
+static int HandleIMEComposition(HWND hwnd, LPARAM lParam);
/*
*----------------------------------------------------------------------
*
* TkGetServerInfo --
*
- * Given a window, this procedure returns information about
- * the window server for that window. This procedure provides
- * the guts of the "winfo server" command.
+ * Given a window, this function returns information about the window
+ * server for that window. This function provides the guts of the "winfo
+ * server" command.
*
* Results:
* None.
@@ -152,11 +151,11 @@ static int HandleIMEComposition _ANSI_ARGS_((HWND hwnd,
*/
void
-TkGetServerInfo(interp, tkwin)
- Tcl_Interp *interp; /* The server information is returned in
- * this interpreter's result. */
- Tk_Window tkwin; /* Token for window; this selects a
- * particular display and server. */
+TkGetServerInfo(
+ Tcl_Interp *interp, /* The server information is returned in this
+ * interpreter's result. */
+ Tk_Window tkwin) /* Token for window; this selects a particular
+ * display and server. */
{
char buffer[60];
OSVERSIONINFO os;
@@ -170,7 +169,7 @@ TkGetServerInfo(interp, tkwin)
#else
"Win32"
#endif
- );
+ );
Tcl_SetResult(interp, buffer, TCL_VOLATILE);
}
@@ -191,7 +190,7 @@ TkGetServerInfo(interp, tkwin)
*/
HINSTANCE
-Tk_GetHINSTANCE()
+Tk_GetHINSTANCE(vpod)
{
if (tkInstance == NULL) {
tkInstance = GetModuleHandle(NULL);
@@ -204,8 +203,8 @@ Tk_GetHINSTANCE()
*
* TkWinSetHINSTANCE --
*
- * Sets the global instance handle used by the Tk library.
- * This should be called by DllMain.
+ * Sets the global instance handle used by the Tk library. This should be
+ * called by DllMain.
*
* Results:
* None.
@@ -217,8 +216,8 @@ Tk_GetHINSTANCE()
*/
void
-TkWinSetHINSTANCE(hInstance)
- HINSTANCE hInstance;
+TkWinSetHINSTANCE(
+ HINSTANCE hInstance)
{
tkInstance = hInstance;
}
@@ -240,8 +239,8 @@ TkWinSetHINSTANCE(hInstance)
*/
void
-TkWinXInit(hInstance)
- HINSTANCE hInstance;
+TkWinXInit(
+ HINSTANCE hInstance)
{
INITCOMMONCONTROLSEX comctl;
@@ -263,12 +262,12 @@ TkWinXInit(hInstance)
}
/*
- * When threads are enabled, we cannot use CLASSDC because
- * threads will then write into the same device context.
- *
- * This is a hack; we should add a subsystem that manages
- * device context on a per-thread basis. See also tkWinWm.c,
- * which also initializes a WNDCLASS structure.
+ * When threads are enabled, we cannot use CLASSDC because threads will
+ * then write into the same device context.
+ *
+ * This is a hack; we should add a subsystem that manages device context
+ * on a per-thread basis. See also tkWinWm.c, which also initializes a
+ * WNDCLASS structure.
*/
#ifdef TCL_THREADS
@@ -299,6 +298,7 @@ TkWinXInit(hInstance)
/*
* Make sure we cleanup on finalize.
*/
+
TkCreateExitHandler(TkWinXCleanup, (ClientData) hInstance);
}
@@ -319,14 +319,15 @@ TkWinXInit(hInstance)
*/
void
-TkWinXCleanup(clientData)
- ClientData clientData;
+TkWinXCleanup(
+ ClientData clientData)
{
HINSTANCE hInstance = (HINSTANCE) clientData;
+
/*
* Clean up our own class.
*/
-
+
if (childClassInitialized) {
childClassInitialized = 0;
UnregisterClass(TK_WIN_CHILD_CLASS_NAME, hInstance);
@@ -340,7 +341,7 @@ TkWinXCleanup(clientData)
/*
* And let the window manager clean up its own class(es).
*/
-
+
TkWinWmCleanup(hInstance);
TkWinCleanupContainerList();
}
@@ -350,12 +351,12 @@ TkWinXCleanup(clientData)
*
* TkWinGetPlatformId --
*
- * Determines whether running under NT, 95, or Win32s, to allow
- * runtime conditional code. Win32s is no longer supported.
+ * Determines whether running under NT, 95, or Win32s, to allow runtime
+ * conditional code. Win32s is no longer supported.
*
* Results:
* The return value is one of:
- * VER_PLATFORM_WIN32s Win32s on Windows 3.1.
+ * VER_PLATFORM_WIN32s Win32s on Windows 3.1.
* VER_PLATFORM_WIN32_WINDOWS Win32 on Windows 95.
* VER_PLATFORM_WIN32_NT Win32 on Windows NT
*
@@ -366,7 +367,7 @@ TkWinXCleanup(clientData)
*/
int
-TkWinGetPlatformId()
+TkWinGetPlatformId(vpod
{
if (tkPlatformId == 0) {
OSVERSIONINFO os;
@@ -374,17 +375,20 @@ TkWinGetPlatformId()
os.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&os);
tkPlatformId = os.dwPlatformId;
-
- /* Set tkWinTheme to be TK_THEME_WIN_XP or TK_THEME_WIN_CLASSIC.
- * The TK_THEME_WIN_CLASSIC could be set even when running
- * under XP if the windows classic theme was selected. */
+
+ /*
+ * Set tkWinTheme to be TK_THEME_WIN_XP or TK_THEME_WIN_CLASSIC. The
+ * TK_THEME_WIN_CLASSIC could be set even when running under XP if the
+ * windows classic theme was selected.
+ */
if ((os.dwPlatformId == VER_PLATFORM_WIN32_NT) &&
(os.dwMajorVersion == 5 && os.dwMinorVersion == 1)) {
- HKEY hKey;
+ HKEY hKey;
LPCSTR szSubKey = TEXT("Control Panel\\Appearance");
LPCSTR szCurrent = TEXT("Current");
- DWORD dwSize = 200;
+ DWORD dwSize = 200;
char pBuffer[200];
+
memset(pBuffer, 0, dwSize);
if (RegOpenKeyEx(HKEY_CURRENT_USER, szSubKey, 0L,
KEY_READ, &hKey) != ERROR_SUCCESS) {
@@ -414,8 +418,8 @@ TkWinGetPlatformId()
*
* Results:
* The return value is one of:
- * TK_THEME_WIN_CLASSIC 95/98/NT or XP in classic mode
- * TK_THEME_WIN_XP XP not in classic mode
+ * TK_THEME_WIN_CLASSIC 95/98/NT or XP in classic mode
+ * TK_THEME_WIN_XP XP not in classic mode
*
* Side effects:
* Could invoke TkWinGetPlatformId.
@@ -424,7 +428,7 @@ TkWinGetPlatformId()
*/
int
-TkWinGetPlatformTheme()
+TkWinGetPlatformTheme(void)
{
if (tkPlatformId == 0) {
TkWinGetPlatformId();
@@ -450,9 +454,9 @@ TkWinGetPlatformTheme()
*/
CONST char *
-TkGetDefaultScreenName(interp, screenName)
- Tcl_Interp *interp; /* Not used. */
- CONST char *screenName; /* If NULL, use default string. */
+TkGetDefaultScreenName(
+ Tcl_Interp *interp, /* Not used. */
+ CONST char *screenName) /* If NULL, use default string. */
{
if ((screenName == NULL) || (screenName[0] == '\0')) {
screenName = winScreenName;
@@ -478,7 +482,8 @@ TkGetDefaultScreenName(interp, screenName)
*/
void
-TkWinDisplayChanged(Display *display)
+TkWinDisplayChanged(
+ Display *display)
{
HDC dc;
Screen *screen;
@@ -499,9 +504,9 @@ TkWinDisplayChanged(Display *display)
/*
* On windows, when creating a color bitmap, need two pieces of
* information: the number of color planes and the number of pixels per
- * plane. Need to remember both quantities so that when constructing an
+ * plane. Need to remember both quantities so that when constructing an
* HBITMAP for offscreen rendering, we can specify the correct value for
- * the number of planes. Otherwise the HBITMAP won't be compatible with
+ * the number of planes. Otherwise the HBITMAP won't be compatible with
* the HWND and we'll just get blank spots copied onto the screen.
*/
@@ -559,8 +564,8 @@ TkWinDisplayChanged(Display *display)
*
* TkpOpenDisplay --
*
- * Create the Display structure and fill it with device
- * specific information.
+ * Create the Display structure and fill it with device specific
+ * information.
*
* Results:
* Returns a TkDisplay structure on success or NULL on failure.
@@ -572,17 +577,17 @@ TkWinDisplayChanged(Display *display)
*/
TkDisplay *
-TkpOpenDisplay(display_name)
- CONST char *display_name;
+TkpOpenDisplay(
+ CONST char *display_name)
{
Screen *screen;
TkWinDrawable *twdPtr;
Display *display;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (tsdPtr->winDisplay != NULL) {
- if (strcmp(tsdPtr->winDisplay->display->display_name, display_name)
+ if (strcmp(tsdPtr->winDisplay->display->display_name, display_name)
== 0) {
return tsdPtr->winDisplay;
} else {
@@ -658,11 +663,11 @@ TkpOpenDisplay(display_name)
*/
void
-TkpCloseDisplay(dispPtr)
- TkDisplay *dispPtr;
+TkpCloseDisplay(
+ TkDisplay *dispPtr)
{
Display *display = dispPtr->display;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (dispPtr != tsdPtr->winDisplay) {
@@ -695,11 +700,10 @@ TkpCloseDisplay(dispPtr)
*
* TkClipCleanup --
*
- * This procedure is called to cleanup resources associated with
- * claiming clipboard ownership and for receiving selection get
- * results. This function is called in tkWindow.c. This has to be
- * called by the display cleanup function because we still need the
- * access display elements.
+ * This function is called to cleanup resources associated with claiming
+ * clipboard ownership and for receiving selection get results. This
+ * function is called in tkWindow.c. This has to be called by the display
+ * cleanup function because we still need the access display elements.
*
* Results:
* None.
@@ -711,8 +715,8 @@ TkpCloseDisplay(dispPtr)
*/
void
-TkClipCleanup(dispPtr)
- TkDisplay *dispPtr; /* display associated with clipboard */
+TkClipCleanup(
+ TkDisplay *dispPtr) /* Display associated with clipboard. */
{
if (dispPtr->clipWindow != NULL) {
/*
@@ -720,6 +724,7 @@ TkClipCleanup(dispPtr)
*/
HWND hwnd = Tk_GetHWND(Tk_WindowId(dispPtr->clipWindow));
+
if (GetClipboardOwner() == hwnd) {
OpenClipboard(hwnd);
EmptyClipboard();
@@ -755,9 +760,9 @@ TkClipCleanup(dispPtr)
*/
void
-XBell(display, percent)
- Display* display;
- int percent;
+XBell(
+ Display *display,
+ int percent)
{
MessageBeep(MB_OK);
}
@@ -767,8 +772,7 @@ XBell(display, percent)
*
* TkWinChildProc --
*
- * Callback from Windows whenever an event occurs on a child
- * window.
+ * Callback from Windows whenever an event occurs on a child window.
*
* Results:
* Standard Windows return value.
@@ -780,69 +784,68 @@ XBell(display, percent)
*/
LRESULT CALLBACK
-TkWinChildProc(hwnd, message, wParam, lParam)
- HWND hwnd;
- UINT message;
- WPARAM wParam;
- LPARAM lParam;
+TkWinChildProc(
+ HWND hwnd,
+ UINT message,
+ WPARAM wParam,
+ LPARAM lParam)
{
LRESULT result;
switch (message) {
- case WM_INPUTLANGCHANGE:
- UpdateInputLanguage(wParam);
- result = 1;
- break;
-
- case WM_IME_COMPOSITION:
- result = 0;
- if (HandleIMEComposition(hwnd, lParam) == 0) {
- result = DefWindowProc(hwnd, message, wParam, lParam);
- }
- break;
-
- case WM_SETCURSOR:
- /*
- * Short circuit the WM_SETCURSOR message since we set
- * the cursor elsewhere.
- */
-
- result = TRUE;
- break;
-
- case WM_CREATE:
- case WM_ERASEBKGND:
- result = 0;
- break;
-
- case WM_PAINT:
- GenerateXEvent(hwnd, message, wParam, lParam);
+ case WM_INPUTLANGCHANGE:
+ UpdateInputLanguage(wParam);
+ result = 1;
+ break;
+
+ case WM_IME_COMPOSITION:
+ result = 0;
+ if (HandleIMEComposition(hwnd, lParam) == 0) {
result = DefWindowProc(hwnd, message, wParam, lParam);
- break;
+ }
+ break;
- case TK_CLAIMFOCUS:
- case TK_GEOMETRYREQ:
- case TK_ATTACHWINDOW:
- case TK_DETACHWINDOW:
- case TK_ICONIFY:
- case TK_DEICONIFY:
- case TK_MOVEWINDOW:
- case TK_WITHDRAW:
- case TK_RAISEWINDOW:
- case TK_GETFRAMEWID:
- case TK_OVERRIDEREDIRECT:
- case TK_SETMENU:
- case TK_STATE:
- case TK_INFO:
- result = TkWinEmbeddedEventProc(hwnd, message, wParam, lParam);
- break;
+ case WM_SETCURSOR:
+ /*
+ * Short circuit the WM_SETCURSOR message since we set the cursor
+ * elsewhere.
+ */
- default:
- if (!Tk_TranslateWinEvent(hwnd, message, wParam, lParam,
- &result)) {
- result = DefWindowProc(hwnd, message, wParam, lParam);
- }
- break;
+ result = TRUE;
+ break;
+
+ case WM_CREATE:
+ case WM_ERASEBKGND:
+ result = 0;
+ break;
+
+ case WM_PAINT:
+ GenerateXEvent(hwnd, message, wParam, lParam);
+ result = DefWindowProc(hwnd, message, wParam, lParam);
+ break;
+
+ case TK_CLAIMFOCUS:
+ case TK_GEOMETRYREQ:
+ case TK_ATTACHWINDOW:
+ case TK_DETACHWINDOW:
+ case TK_ICONIFY:
+ case TK_DEICONIFY:
+ case TK_MOVEWINDOW:
+ case TK_WITHDRAW:
+ case TK_RAISEWINDOW:
+ case TK_GETFRAMEWID:
+ case TK_OVERRIDEREDIRECT:
+ case TK_SETMENU:
+ case TK_STATE:
+ case TK_INFO:
+ result = TkWinEmbeddedEventProc(hwnd, message, wParam, lParam);
+ break;
+
+ default:
+ if (!Tk_TranslateWinEvent(hwnd, message, wParam, lParam, &result)) {
+ result = DefWindowProc(hwnd, message, wParam, lParam);
+ }
+ break;
}
/*
@@ -858,8 +861,8 @@ TkWinChildProc(hwnd, message, wParam, lParam)
*
* Tk_TranslateWinEvent --
*
- * This function is called by widget window procedures to handle
- * the translation from Win32 events to Tk events.
+ * This function is called by widget window functions to handle the
+ * translation from Win32 events to Tk events.
*
* Results:
* Returns 1 if the event was handled, else 0.
@@ -871,74 +874,79 @@ TkWinChildProc(hwnd, message, wParam, lParam)
*/
int
-Tk_TranslateWinEvent(hwnd, message, wParam, lParam, resultPtr)
- HWND hwnd;
- UINT message;
- WPARAM wParam;
- LPARAM lParam;
- LRESULT *resultPtr;
+Tk_TranslateWinEvent(
+ HWND hwnd,
+ UINT message,
+ WPARAM wParam,
+ LPARAM lParam,
+ LRESULT *resultPtr)
{
*resultPtr = 0;
switch (message) {
- case WM_RENDERFORMAT: {
- TkWindow *winPtr = (TkWindow *) Tk_HWNDToWindow(hwnd);
- if (winPtr) {
- TkWinClipboardRender(winPtr->dispPtr, wParam);
- }
- return 1;
+ case WM_RENDERFORMAT: {
+ TkWindow *winPtr = (TkWindow *) Tk_HWNDToWindow(hwnd);
+
+ if (winPtr) {
+ TkWinClipboardRender(winPtr->dispPtr, wParam);
}
+ return 1;
+ }
- case WM_COMMAND:
- case WM_NOTIFY:
- case WM_VSCROLL:
- case WM_HSCROLL: {
- /*
- * Reflect these messages back to the sender so that they
- * can be handled by the window proc for the control. Note
- * that we need to be careful not to reflect a message that
- * is targeted to this window, or we will loop.
- */
+ case WM_COMMAND:
+ case WM_NOTIFY:
+ case WM_VSCROLL:
+ case WM_HSCROLL: {
+ /*
+ * Reflect these messages back to the sender so that they can be
+ * handled by the window proc for the control. Note that we need to be
+ * careful not to reflect a message that is targeted to this window,
+ * or we will loop.
+ */
- HWND target = (message == WM_NOTIFY)
+ HWND target = (message == WM_NOTIFY)
? ((NMHDR*)lParam)->hwndFrom : (HWND) lParam;
- if (target && target != hwnd) {
- *resultPtr = SendMessage(target, message, wParam, lParam);
- return 1;
- }
- break;
- }
- case WM_LBUTTONDOWN:
- case WM_LBUTTONDBLCLK:
- case WM_MBUTTONDOWN:
- case WM_MBUTTONDBLCLK:
- case WM_RBUTTONDOWN:
- case WM_RBUTTONDBLCLK:
- case WM_LBUTTONUP:
- case WM_MBUTTONUP:
- case WM_RBUTTONUP:
- case WM_MOUSEMOVE:
- Tk_PointerEvent(hwnd, (short) LOWORD(lParam),
- (short) HIWORD(lParam));
+ if (target && target != hwnd) {
+ *resultPtr = SendMessage(target, message, wParam, lParam);
return 1;
+ }
+ break;
+ }
- case WM_CLOSE:
- case WM_SETFOCUS:
- case WM_KILLFOCUS:
- case WM_DESTROYCLIPBOARD:
- case WM_CHAR:
- case WM_SYSKEYDOWN:
- case WM_SYSKEYUP:
- case WM_KEYDOWN:
- case WM_KEYUP:
- case WM_MOUSEWHEEL:
- GenerateXEvent(hwnd, message, wParam, lParam);
- return 1;
- case WM_MENUCHAR:
- GenerateXEvent(hwnd, message, wParam, lParam);
- /* MNC_CLOSE is the only one that looks right. This is a hack. */
- *resultPtr = MAKELONG (0, MNC_CLOSE);
- return 1;
+ case WM_LBUTTONDOWN:
+ case WM_LBUTTONDBLCLK:
+ case WM_MBUTTONDOWN:
+ case WM_MBUTTONDBLCLK:
+ case WM_RBUTTONDOWN:
+ case WM_RBUTTONDBLCLK:
+ case WM_LBUTTONUP:
+ case WM_MBUTTONUP:
+ case WM_RBUTTONUP:
+ case WM_MOUSEMOVE:
+ Tk_PointerEvent(hwnd, (short) LOWORD(lParam), (short) HIWORD(lParam));
+ return 1;
+
+ case WM_CLOSE:
+ case WM_SETFOCUS:
+ case WM_KILLFOCUS:
+ case WM_DESTROYCLIPBOARD:
+ case WM_CHAR:
+ case WM_SYSKEYDOWN:
+ case WM_SYSKEYUP:
+ case WM_KEYDOWN:
+ case WM_KEYUP:
+ case WM_MOUSEWHEEL:
+ GenerateXEvent(hwnd, message, wParam, lParam);
+ return 1;
+ case WM_MENUCHAR:
+ GenerateXEvent(hwnd, message, wParam, lParam);
+
+ /*
+ * MNC_CLOSE is the only one that looks right. This is a hack.
+ */
+
+ *resultPtr = MAKELONG (0, MNC_CLOSE);
+ return 1;
}
return 0;
}
@@ -948,8 +956,8 @@ Tk_TranslateWinEvent(hwnd, message, wParam, lParam, resultPtr)
*
* GenerateXEvent --
*
- * This routine generates an X event from the corresponding
- * Windows event.
+ * This routine generates an X event from the corresponding Windows
+ * event.
*
* Results:
* None.
@@ -961,15 +969,15 @@ Tk_TranslateWinEvent(hwnd, message, wParam, lParam, resultPtr)
*/
static void
-GenerateXEvent(hwnd, message, wParam, lParam)
- HWND hwnd;
- UINT message;
- WPARAM wParam;
- LPARAM lParam;
+GenerateXEvent(
+ HWND hwnd,
+ UINT message,
+ WPARAM wParam,
+ LPARAM lParam)
{
XEvent event;
TkWindow *winPtr = (TkWindow *)Tk_HWNDToWindow(hwnd);
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!winPtr || winPtr->window == None) {
@@ -982,243 +990,237 @@ GenerateXEvent(hwnd, message, wParam, lParam)
event.xany.window = winPtr->window;
switch (message) {
- case WM_PAINT: {
- PAINTSTRUCT ps;
-
- event.type = Expose;
- BeginPaint(hwnd, &ps);
- event.xexpose.x = ps.rcPaint.left;
- event.xexpose.y = ps.rcPaint.top;
- event.xexpose.width = ps.rcPaint.right - ps.rcPaint.left;
- event.xexpose.height = ps.rcPaint.bottom - ps.rcPaint.top;
- EndPaint(hwnd, &ps);
- event.xexpose.count = 0;
- break;
- }
+ case WM_PAINT: {
+ PAINTSTRUCT ps;
+
+ event.type = Expose;
+ BeginPaint(hwnd, &ps);
+ event.xexpose.x = ps.rcPaint.left;
+ event.xexpose.y = ps.rcPaint.top;
+ event.xexpose.width = ps.rcPaint.right - ps.rcPaint.left;
+ event.xexpose.height = ps.rcPaint.bottom - ps.rcPaint.top;
+ EndPaint(hwnd, &ps);
+ event.xexpose.count = 0;
+ break;
+ }
- case WM_CLOSE:
- event.type = ClientMessage;
- event.xclient.message_type =
+ case WM_CLOSE:
+ event.type = ClientMessage;
+ event.xclient.message_type =
Tk_InternAtom((Tk_Window) winPtr, "WM_PROTOCOLS");
- event.xclient.format = 32;
- event.xclient.data.l[0] =
+ event.xclient.format = 32;
+ event.xclient.data.l[0] =
Tk_InternAtom((Tk_Window) winPtr, "WM_DELETE_WINDOW");
- break;
+ break;
- case WM_SETFOCUS:
- case WM_KILLFOCUS: {
- TkWindow *otherWinPtr = (TkWindow *)Tk_HWNDToWindow((HWND) wParam);
-
- /*
- * Compare toplevel windows to avoid reporting focus
- * changes within the same toplevel.
- */
+ case WM_SETFOCUS:
+ case WM_KILLFOCUS: {
+ TkWindow *otherWinPtr = (TkWindow *)Tk_HWNDToWindow((HWND) wParam);
- while (!(winPtr->flags & TK_TOP_LEVEL)) {
- winPtr = winPtr->parentPtr;
- if (winPtr == NULL) {
- return;
- }
- }
- while (otherWinPtr && !(otherWinPtr->flags & TK_TOP_LEVEL)) {
- otherWinPtr = otherWinPtr->parentPtr;
- }
-
- /*
- * Do a catch-all Tk_SetCaretPos here to make sure that the
- * window receiving focus sets the caret at least once.
- */
- if (message == WM_SETFOCUS) {
- Tk_SetCaretPos((Tk_Window) winPtr, 0, 0, 0);
- }
+ /*
+ * Compare toplevel windows to avoid reporting focus changes within
+ * the same toplevel.
+ */
- if (otherWinPtr == winPtr) {
+ while (!(winPtr->flags & TK_TOP_LEVEL)) {
+ winPtr = winPtr->parentPtr;
+ if (winPtr == NULL) {
return;
}
+ }
+ while (otherWinPtr && !(otherWinPtr->flags & TK_TOP_LEVEL)) {
+ otherWinPtr = otherWinPtr->parentPtr;
+ }
- event.xany.window = winPtr->window;
- event.type = (message == WM_SETFOCUS) ? FocusIn : FocusOut;
- event.xfocus.mode = NotifyNormal;
- event.xfocus.detail = NotifyNonlinear;
+ /*
+ * Do a catch-all Tk_SetCaretPos here to make sure that the window
+ * receiving focus sets the caret at least once.
+ */
+ if (message == WM_SETFOCUS) {
+ Tk_SetCaretPos((Tk_Window) winPtr, 0, 0, 0);
+ }
+
+ if (otherWinPtr == winPtr) {
+ return;
+ }
+
+ event.xany.window = winPtr->window;
+ event.type = (message == WM_SETFOCUS) ? FocusIn : FocusOut;
+ event.xfocus.mode = NotifyNormal;
+ event.xfocus.detail = NotifyNonlinear;
+
+ /*
+ * Destroy the caret if we own it. If we are moving to another Tk
+ * window, it will reclaim and reposition it with Tk_SetCaretPos.
+ */
+
+ if (message == WM_KILLFOCUS) {
+ DestroyCaret();
+ }
+ break;
+ }
+
+ case WM_DESTROYCLIPBOARD:
+ if (tsdPtr->updatingClipboard == TRUE) {
/*
- * Destroy the caret if we own it. If we are moving to another Tk
- * window, it will reclaim and reposition it with Tk_SetCaretPos.
+ * We want to avoid this event if we are the ones that caused this
+ * event.
*/
- if (message == WM_KILLFOCUS) {
- DestroyCaret();
- }
- break;
- }
- case WM_DESTROYCLIPBOARD:
- if (tsdPtr->updatingClipboard == TRUE) {
- /*
- * We want to avoid this event if we are the ones that caused
- * this event.
- */
- return;
- }
- event.type = SelectionClear;
- event.xselectionclear.selection =
+ return;
+ }
+ event.type = SelectionClear;
+ event.xselectionclear.selection =
Tk_InternAtom((Tk_Window)winPtr, "CLIPBOARD");
- event.xselectionclear.time = TkpGetMS();
- break;
+ event.xselectionclear.time = TkpGetMS();
+ break;
+
+ case WM_MOUSEWHEEL:
+ /*
+ * The mouse wheel event is closer to a key event than a mouse event
+ * in that the message is sent to the window that has focus.
+ */
+
+ case WM_CHAR:
+ case WM_SYSKEYDOWN:
+ case WM_SYSKEYUP:
+ case WM_KEYDOWN:
+ case WM_KEYUP: {
+ unsigned int state = GetState(message, wParam, lParam);
+ Time time = TkpGetMS();
+ POINT clientPoint;
+ POINTS rootPoint; /* Note: POINT and POINTS are different */
+ DWORD msgPos;
+
+ /*
+ * Compute the screen and window coordinates of the event.
+ */
+
+ msgPos = GetMessagePos();
+ rootPoint = MAKEPOINTS(msgPos);
+ clientPoint.x = rootPoint.x;
+ clientPoint.y = rootPoint.y;
+ ScreenToClient(hwnd, &clientPoint);
+
+ /*
+ * Set up the common event fields.
+ */
+ event.xbutton.root = RootWindow(winPtr->display, winPtr->screenNum);
+ event.xbutton.subwindow = None;
+ event.xbutton.x = clientPoint.x;
+ event.xbutton.y = clientPoint.y;
+ event.xbutton.x_root = rootPoint.x;
+ event.xbutton.y_root = rootPoint.y;
+ event.xbutton.state = state;
+ event.xbutton.time = time;
+ event.xbutton.same_screen = True;
+
+ /*
+ * Now set up event specific fields.
+ */
+
+ switch (message) {
case WM_MOUSEWHEEL:
/*
- * The mouse wheel event is closer to a key event than a
- * mouse event in that the message is sent to the window
- * that has focus.
+ * We have invented a new X event type to handle this event. It
+ * still uses the KeyPress struct. However, the keycode field has
+ * been overloaded to hold the zDelta of the wheel. Set nbytes to
+ * 0 to prevent conversion of the keycode to a keysym in
+ * TkpGetString. [Bug 1118340].
*/
- case WM_CHAR:
+ event.type = MouseWheelEvent;
+ event.xany.send_event = -1;
+ event.xkey.nbytes = 0;
+ event.xkey.keycode = (short) HIWORD(wParam);
+ break;
case WM_SYSKEYDOWN:
- case WM_SYSKEYUP:
case WM_KEYDOWN:
- case WM_KEYUP: {
- unsigned int state = GetState(message, wParam, lParam);
- Time time = TkpGetMS();
- POINT clientPoint;
- POINTS rootPoint; /* Note: POINT and POINTS are different */
- DWORD msgPos;
-
/*
- * Compute the screen and window coordinates of the event.
+ * Check for translated characters in the event queue. Setting
+ * xany.send_event to -1 indicates to the Windows implementation
+ * of TkpGetString() that this event was generated by windows and
+ * that the Windows extension xkey.trans_chars is filled with the
+ * MBCS characters that came from the TranslateMessage call.
*/
- msgPos = GetMessagePos();
- rootPoint = MAKEPOINTS(msgPos);
- clientPoint.x = rootPoint.x;
- clientPoint.y = rootPoint.y;
- ScreenToClient(hwnd, &clientPoint);
+ event.type = KeyPress;
+ event.xany.send_event = -1;
+ event.xkey.keycode = wParam;
+ GetTranslatedKey(&event.xkey);
+ break;
+ case WM_SYSKEYUP:
+ case WM_KEYUP:
/*
- * Set up the common event fields.
+ * We don't check for translated characters on keyup because Tk
+ * won't know what to do with them. Instead, we wait for the
+ * WM_CHAR messages which will follow.
*/
- event.xbutton.root = RootWindow(winPtr->display,
- winPtr->screenNum);
- event.xbutton.subwindow = None;
- event.xbutton.x = clientPoint.x;
- event.xbutton.y = clientPoint.y;
- event.xbutton.x_root = rootPoint.x;
- event.xbutton.y_root = rootPoint.y;
- event.xbutton.state = state;
- event.xbutton.time = time;
- event.xbutton.same_screen = True;
+ event.type = KeyRelease;
+ event.xkey.keycode = wParam;
+ event.xkey.nbytes = 0;
+ break;
+ case WM_CHAR:
/*
- * Now set up event specific fields.
+ * Synthesize both a KeyPress and a KeyRelease. Strings generated
+ * by Input Method Editor are handled in the following manner:
+ * 1. A series of WM_KEYDOWN & WM_KEYUP messages that cause
+ * GetTranslatedKey() to be called and return immediately
+ * because the WM_KEYDOWNs have no associated WM_CHAR messages
+ * -- the IME window is accumulating the characters and
+ * translating them itself. In the "bind" command, you get an
+ * event with a mystery keysym and %A == "" for each WM_KEYDOWN
+ * that actually was meant for the IME.
+ * 2. A WM_KEYDOWN corresponding to the "confirm typing"
+ * character. This causes GetTranslatedKey() to be called.
+ * 3. A WM_IME_NOTIFY message saying that the IME is done. A side
+ * effect of this message is that GetTranslatedKey() thinks
+ * this means that there are no WM_CHAR messages and returns
+ * immediately. In the "bind" command, you get an another event
+ * with a mystery keysym and %A == "".
+ * 4. A sequence of WM_CHAR messages that correspond to the
+ * characters in the IME window. A bunch of simulated
+ * KeyPress/KeyRelease events will be generated, one for each
+ * character. Adjacent WM_CHAR messages may actually specify
+ * the high and low bytes of a multi-byte character -- in that
+ * case the two WM_CHAR messages will be combined into one
+ * event. It is the event-consumer's responsibility to convert
+ * the string returned from XLookupString from system encoding
+ * to UTF-8.
+ * 5. And finally we get the WM_KEYUP for the "confirm typing"
+ * character.
*/
- switch (message) {
- case WM_MOUSEWHEEL:
- /*
- * We have invented a new X event type to handle
- * this event. It still uses the KeyPress struct.
- * However, the keycode field has been overloaded
- * to hold the zDelta of the wheel. Set nbytes to 0
- * to prevent conversion of the keycode to a keysym
- * in TkpGetString. [Bug 1118340].
- */
-
- event.type = MouseWheelEvent;
- event.xany.send_event = -1;
- event.xkey.nbytes = 0;
- event.xkey.keycode = (short) HIWORD(wParam);
- break;
- case WM_SYSKEYDOWN:
- case WM_KEYDOWN:
- /*
- * Check for translated characters in the event queue.
- * Setting xany.send_event to -1 indicates to the
- * Windows implementation of TkpGetString() that this
- * event was generated by windows and that the Windows
- * extension xkey.trans_chars is filled with the
- * MBCS characters that came from the TranslateMessage
- * call.
- */
-
- event.type = KeyPress;
- event.xany.send_event = -1;
- event.xkey.keycode = wParam;
- GetTranslatedKey(&event.xkey);
- break;
+ event.type = KeyPress;
+ event.xany.send_event = -1;
+ event.xkey.keycode = 0;
+ event.xkey.nbytes = 1;
+ event.xkey.trans_chars[0] = (char) wParam;
- case WM_SYSKEYUP:
- case WM_KEYUP:
- /*
- * We don't check for translated characters on keyup
- * because Tk won't know what to do with them. Instead, we
- * wait for the WM_CHAR messages which will follow.
- */
- event.type = KeyRelease;
- event.xkey.keycode = wParam;
- event.xkey.nbytes = 0;
- break;
+ if (IsDBCSLeadByte((BYTE) wParam)) {
+ MSG msg;
- case WM_CHAR:
- /*
- * Synthesize both a KeyPress and a KeyRelease.
- * Strings generated by Input Method Editor are handled
- * in the following manner:
- * 1. A series of WM_KEYDOWN & WM_KEYUP messages that
- * cause GetTranslatedKey() to be called and return
- * immediately because the WM_KEYDOWNs have no
- * associated WM_CHAR messages -- the IME window is
- * accumulating the characters and translating them
- * itself. In the "bind" command, you get an event
- * with a mystery keysym and %A == "" for each
- * WM_KEYDOWN that actually was meant for the IME.
- * 2. A WM_KEYDOWN corresponding to the "confirm typing"
- * character. This causes GetTranslatedKey() to be
- * called.
- * 3. A WM_IME_NOTIFY message saying that the IME is
- * done. A side effect of this message is that
- * GetTranslatedKey() thinks this means that there
- * are no WM_CHAR messages and returns immediately.
- * In the "bind" command, you get an another event
- * with a mystery keysym and %A == "".
- * 4. A sequence of WM_CHAR messages that correspond to
- * the characters in the IME window. A bunch of
- * simulated KeyPress/KeyRelease events will be
- * generated, one for each character. Adjacent
- * WM_CHAR messages may actually specify the high
- * and low bytes of a multi-byte character -- in that
- * case the two WM_CHAR messages will be combined into
- * one event. It is the event-consumer's
- * responsibility to convert the string returned from
- * XLookupString from system encoding to UTF-8.
- * 5. And finally we get the WM_KEYUP for the "confirm
- * typing" character.
- */
-
- event.type = KeyPress;
- event.xany.send_event = -1;
- event.xkey.keycode = 0;
- event.xkey.nbytes = 1;
- event.xkey.trans_chars[0] = (char) wParam;
-
- if (IsDBCSLeadByte((BYTE) wParam)) {
- MSG msg;
-
- if ((PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) != 0)
- && (msg.message == WM_CHAR)) {
- GetMessage(&msg, NULL, 0, 0);
- event.xkey.nbytes = 2;
- event.xkey.trans_chars[1] = (char) msg.wParam;
- }
- }
- Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
- event.type = KeyRelease;
- break;
+ if ((PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) != 0)
+ && (msg.message == WM_CHAR)) {
+ GetMessage(&msg, NULL, 0, 0);
+ event.xkey.nbytes = 2;
+ event.xkey.trans_chars[1] = (char) msg.wParam;
+ }
}
+ Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
+ event.type = KeyRelease;
break;
}
+ break;
+ }
- default:
- return;
+ default:
+ return;
}
Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
}
@@ -1228,12 +1230,12 @@ GenerateXEvent(hwnd, message, wParam, lParam)
*
* GetState --
*
- * This function constructs a state mask for the mouse buttons
- * and modifier keys as they were before the event occured.
+ * This function constructs a state mask for the mouse buttons and
+ * modifier keys as they were before the event occured.
*
* Results:
- * Returns a composite value of all the modifier and button state
- * flags that were set at the time the event occurred.
+ * Returns a composite value of all the modifier and button state flags
+ * that were set at the time the event occurred.
*
* Side effects:
* None.
@@ -1242,18 +1244,18 @@ GenerateXEvent(hwnd, message, wParam, lParam)
*/
static unsigned int
-GetState(message, wParam, lParam)
- UINT message; /* Win32 message type */
- WPARAM wParam; /* wParam of message, used if key message */
- LPARAM lParam; /* lParam of message, used if key message */
+GetState(
+ UINT message, /* Win32 message type */
+ WPARAM wParam, /* wParam of message, used if key message */
+ LPARAM lParam) /* lParam of message, used if key message */
{
int mask;
int prevState; /* 1 if key was previously down */
unsigned int state = TkWinGetModifierState();
/*
- * If the event is a key press or release, we check for modifier
- * keys so we can report the state of the world before the event.
+ * If the event is a key press or release, we check for modifier keys so
+ * we can report the state of the world before the event.
*/
if (message == WM_SYSKEYDOWN || message == WM_KEYDOWN
@@ -1261,33 +1263,33 @@ GetState(message, wParam, lParam)
mask = 0;
prevState = HIWORD(lParam) & KF_REPEAT;
switch(wParam) {
- case VK_SHIFT:
- mask = ShiftMask;
- break;
- case VK_CONTROL:
- mask = ControlMask;
- break;
- case VK_MENU:
- mask = ALT_MASK;
- break;
- case VK_CAPITAL:
- if (message == WM_SYSKEYDOWN || message == WM_KEYDOWN) {
- mask = LockMask;
- prevState = ((state & mask) ^ prevState) ? 0 : 1;
- }
- break;
- case VK_NUMLOCK:
- if (message == WM_SYSKEYDOWN || message == WM_KEYDOWN) {
- mask = Mod1Mask;
- prevState = ((state & mask) ^ prevState) ? 0 : 1;
- }
- break;
- case VK_SCROLL:
- if (message == WM_SYSKEYDOWN || message == WM_KEYDOWN) {
- mask = Mod3Mask;
- prevState = ((state & mask) ^ prevState) ? 0 : 1;
- }
- break;
+ case VK_SHIFT:
+ mask = ShiftMask;
+ break;
+ case VK_CONTROL:
+ mask = ControlMask;
+ break;
+ case VK_MENU:
+ mask = ALT_MASK;
+ break;
+ case VK_CAPITAL:
+ if (message == WM_SYSKEYDOWN || message == WM_KEYDOWN) {
+ mask = LockMask;
+ prevState = ((state & mask) ^ prevState) ? 0 : 1;
+ }
+ break;
+ case VK_NUMLOCK:
+ if (message == WM_SYSKEYDOWN || message == WM_KEYDOWN) {
+ mask = Mod1Mask;
+ prevState = ((state & mask) ^ prevState) ? 0 : 1;
+ }
+ break;
+ case VK_SCROLL:
+ if (message == WM_SYSKEYDOWN || message == WM_KEYDOWN) {
+ mask = Mod3Mask;
+ prevState = ((state & mask) ^ prevState) ? 0 : 1;
+ }
+ break;
}
if (prevState) {
state |= mask;
@@ -1310,26 +1312,26 @@ GetState(message, wParam, lParam)
*
* GetTranslatedKey --
*
- * Retrieves WM_CHAR messages that are placed on the system queue
- * by the TranslateMessage system call and places them in the
- * given KeyPress event.
+ * Retrieves WM_CHAR messages that are placed on the system queue by the
+ * TranslateMessage system call and places them in the given KeyPress
+ * event.
*
* Results:
* Sets the trans_chars and nbytes member of the key event.
*
* Side effects:
- * Removes any WM_CHAR messages waiting on the top of the system
- * event queue.
+ * Removes any WM_CHAR messages waiting on the top of the system event
+ * queue.
*
*----------------------------------------------------------------------
*/
static void
-GetTranslatedKey(xkey)
- XKeyEvent *xkey;
+GetTranslatedKey(
+ XKeyEvent *xkey)
{
MSG msg;
-
+
xkey->nbytes = 0;
while ((xkey->nbytes < XMaxTransChars)
@@ -1338,11 +1340,10 @@ GetTranslatedKey(xkey)
GetMessage(&msg, NULL, 0, 0);
/*
- * If this is a normal character message, we may need to strip
- * off the Alt modifier (e.g. Alt-digits). Note that we don't
- * want to do this for system messages, because those were
- * presumably generated as an Alt-char sequence (e.g. accelerator
- * keys).
+ * If this is a normal character message, we may need to strip off
+ * the Alt modifier (e.g. Alt-digits). Note that we don't want to
+ * do this for system messages, because those were presumably
+ * generated as an Alt-char sequence (e.g. accelerator keys).
*/
if ((msg.message == WM_CHAR) && (msg.lParam & 0x20000000)) {
@@ -1353,11 +1354,10 @@ GetTranslatedKey(xkey)
if (((unsigned short) msg.wParam) > ((unsigned short) 0xff)) {
/*
- * Some "addon" input devices, such as the popular
- * PenPower Chinese writing pad, generate 16 bit
- * values in WM_CHAR messages (instead of passing them
- * in two separate WM_CHAR messages containing two
- * 8-bit values.
+ * Some "addon" input devices, such as the popular PenPower
+ * Chinese writing pad, generate 16 bit values in WM_CHAR
+ * messages (instead of passing them in two separate WM_CHAR
+ * messages containing two 8-bit values.
*/
xkey->trans_chars[xkey->nbytes] = (char) (msg.wParam >> 8);
@@ -1374,13 +1374,12 @@ GetTranslatedKey(xkey)
*
* UpdateInputLanguage --
*
- * Gets called when a WM_INPUTLANGCHANGE message is received
- * by the TK child window procedure. This message is sent
- * by the Input Method Editor system when the user chooses
- * a different input method. All subsequent WM_CHAR
- * messages will contain characters in the new encoding. We record
- * the new encoding so that TkpGetString() knows how to
- * correctly translate the WM_CHAR into unicode.
+ * Gets called when a WM_INPUTLANGCHANGE message is received by the TK
+ * child window function. This message is sent by the Input Method Editor
+ * system when the user chooses a different input method. All subsequent
+ * WM_CHAR messages will contain characters in the new encoding. We
+ * record the new encoding so that TkpGetString() knows how to correctly
+ * translate the WM_CHAR into unicode.
*
* Results:
* Records the new encoding in keyInputEncoding.
@@ -1392,8 +1391,8 @@ GetTranslatedKey(xkey)
*/
static void
-UpdateInputLanguage(charset)
- int charset;
+UpdateInputLanguage(
+ int charset)
{
CHARSETINFO charsetInfo;
Tcl_Encoding encoding;
@@ -1434,8 +1433,8 @@ UpdateInputLanguage(charset)
*
* TkWinGetKeyInputEncoding --
*
- * Returns the current keyboard input encoding selected by the
- * user (with WM_INPUTLANGCHANGE events).
+ * Returns the current keyboard input encoding selected by the user (with
+ * WM_INPUTLANGCHANGE events).
*
* Results:
* The current keyboard input encoding.
@@ -1447,7 +1446,7 @@ UpdateInputLanguage(charset)
*/
Tcl_Encoding
-TkWinGetKeyInputEncoding()
+TkWinGetKeyInputEncoding(void)
{
return keyInputEncoding;
}
@@ -1469,7 +1468,7 @@ TkWinGetKeyInputEncoding()
*/
Tcl_Encoding
-TkWinGetUnicodeEncoding()
+TkWinGetUnicodeEncoding(void)
{
if (unicodeEncoding == NULL) {
unicodeEncoding = Tcl_GetEncoding(NULL, "unicode");
@@ -1482,19 +1481,18 @@ TkWinGetUnicodeEncoding()
*
* HandleIMEComposition --
*
- * This function works around a definciency in some versions
- * of Windows 2000 to make it possible to entry multi-lingual
- * characters under all versions of Windows 2000.
+ * This function works around a definciency in some versions of Windows
+ * 2000 to make it possible to entry multi-lingual characters under all
+ * versions of Windows 2000.
*
- * When an Input Method Editor (IME) is ready to send input
- * characters to an application, it sends a WM_IME_COMPOSITION
- * message with the GCS_RESULTSTR. However, The DefWindowProc()
- * on English Windows 2000 arbitrarily converts all non-Latin-1
- * characters in the composition to "?".
+ * When an Input Method Editor (IME) is ready to send input characters to
+ * an application, it sends a WM_IME_COMPOSITION message with the
+ * GCS_RESULTSTR. However, The DefWindowProc() on English Windows 2000
+ * arbitrarily converts all non-Latin-1 characters in the composition to
+ * "?".
*
- * This function correctly processes the composition data and
- * sends the UNICODE values of the composed characters to
- * TK's event queue.
+ * This function correctly processes the composition data and sends the
+ * UNICODE values of the composed characters to TK's event queue.
*
* Results:
* If this function has processed the composition data, returns 1.
@@ -1507,10 +1505,9 @@ TkWinGetUnicodeEncoding()
*/
static int
-HandleIMEComposition(hwnd, lParam)
- HWND hwnd; /* Window receiving the message. */
- LPARAM lParam; /* Flags for the WM_IME_COMPOSITION
- * message */
+HandleIMEComposition(
+ HWND hwnd, /* Window receiving the message. */
+ LPARAM lParam) /* Flags for the WM_IME_COMPOSITION message */
{
HIMC hIMC;
int i, n;
@@ -1551,10 +1548,11 @@ HandleIMEComposition(hwnd, lParam)
i = Tcl_DStringLength(&unicodeString);
if (n < i) {
/*
- * Only alloc more space if we need, otherwise just
- * use what we've created. Don't realloc as that may
- * copy data we no longer need.
+ * Only alloc more space if we need, otherwise just use
+ * what we've created. Don't realloc as that may copy data
+ * we no longer need.
*/
+
ckfree((char *) buff);
buff = (char *) ckalloc(i);
}
@@ -1568,9 +1566,9 @@ HandleIMEComposition(hwnd, lParam)
* Set up the fields pertinent to key event.
*
* We set send_event to the special value of -2, so that
- * TkpGetString() in tkWinKey.c knows that trans_chars[]
- * already contains a UNICODE char and there's no need to
- * do encoding conversion.
+ * TkpGetString in tkWinKey.c knows that trans_chars[] already
+ * contains a UNICODE char and there's no need to do encoding
+ * conversion.
*/
winPtr = (TkWindow *)Tk_HWNDToWindow(hwnd);
@@ -1589,8 +1587,8 @@ HandleIMEComposition(hwnd, lParam)
for (i=0; i<n;) {
/*
- * Simulate a pair of KeyPress and KeyRelease events
- * for each UNICODE character in the composition.
+ * Simulate a pair of KeyPress and KeyRelease events for each
+ * UNICODE character in the composition.
*/
event.xkey.trans_chars[0] = (char) buff[i++];
@@ -1629,9 +1627,9 @@ HandleIMEComposition(hwnd, lParam)
*/
void
-Tk_FreeXId(display, xid)
- Display *display;
- XID xid;
+Tk_FreeXId(
+ Display *display,
+ XID xid)
{
}
@@ -1641,22 +1639,22 @@ Tk_FreeXId(display, xid)
* TkWinResendEvent --
*
* This function converts an X event into a Windows event and
- * invokes the specified windo procedure.
+ * invokes the specified windo function.
*
* Results:
* A standard Windows result.
*
* Side effects:
- * Invokes the window procedure
+ * Invokes the window function
*
*----------------------------------------------------------------------
*/
LRESULT
-TkWinResendEvent(wndproc, hwnd, eventPtr)
- WNDPROC wndproc;
- HWND hwnd;
- XEvent *eventPtr;
+TkWinResendEvent(
+ WNDPROC wndproc,
+ HWND hwnd,
+ XEvent *eventPtr)
{
UINT msg;
WPARAM wparam;
@@ -1664,20 +1662,20 @@ TkWinResendEvent(wndproc, hwnd, eventPtr)
if (eventPtr->type == ButtonPress) {
switch (eventPtr->xbutton.button) {
- case Button1:
- msg = WM_LBUTTONDOWN;
- wparam = MK_LBUTTON;
- break;
- case Button2:
- msg = WM_MBUTTONDOWN;
- wparam = MK_MBUTTON;
- break;
- case Button3:
- msg = WM_RBUTTONDOWN;
- wparam = MK_RBUTTON;
- break;
- default:
- return 0;
+ case Button1:
+ msg = WM_LBUTTONDOWN;
+ wparam = MK_LBUTTON;
+ break;
+ case Button2:
+ msg = WM_MBUTTONDOWN;
+ wparam = MK_MBUTTON;
+ break;
+ case Button3:
+ msg = WM_RBUTTONDOWN;
+ wparam = MK_RBUTTON;
+ break;
+ default:
+ return 0;
}
if (eventPtr->xbutton.state & Button1Mask) {
wparam |= MK_LBUTTON;
@@ -1707,8 +1705,8 @@ TkWinResendEvent(wndproc, hwnd, eventPtr)
*
* TkpGetMS --
*
- * Return a relative time in milliseconds. It doesn't matter
- * when the epoch was.
+ * Return a relative time in milliseconds. It doesn't matter when the
+ * epoch was.
*
* Results:
* Number of milliseconds.
@@ -1720,7 +1718,7 @@ TkWinResendEvent(wndproc, hwnd, eventPtr)
*/
unsigned long
-TkpGetMS()
+TkpGetMS(void)
{
return GetTickCount();
}
@@ -1741,9 +1739,10 @@ TkpGetMS()
*/
void
-TkWinUpdatingClipboard(int mode)
+TkWinUpdatingClipboard(
+ int mode)
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
tsdPtr->updatingClipboard = mode;
@@ -1754,17 +1753,17 @@ TkWinUpdatingClipboard(int mode)
*
* Tk_SetCaretPos --
*
- * This enables correct movement of focus in the MS Magnifier, as well
- * as allowing us to correctly position the IME Window. The following
- * Win32 APIs are used to work with MS caret:
+ * This enables correct movement of focus in the MS Magnifier, as well as
+ * allowing us to correctly position the IME Window. The following Win32
+ * APIs are used to work with MS caret:
*
* CreateCaret DestroyCaret SetCaretPos GetCaretPos
*
- * Only one instance of caret can be active at any time
- * (e.g. DestroyCaret API does not take any argument such as handle).
- * Since do-it-right approach requires to track the create/destroy
- * caret status all the time in a global scope among windows (or
- * widgets), we just implement this minimal setup to get the job done.
+ * Only one instance of caret can be active at any time (e.g.
+ * DestroyCaret API does not take any argument such as handle). Since
+ * do-it-right approach requires to track the create/destroy caret status
+ * all the time in a global scope among windows (or widgets), we just
+ * implement this minimal setup to get the job done.
*
* Results:
* None
@@ -1776,16 +1775,20 @@ TkWinUpdatingClipboard(int mode)
*/
void
-Tk_SetCaretPos(Tk_Window tkwin, int x, int y, int height)
+Tk_SetCaretPos(
+ Tk_Window tkwin,
+ int x, int y,
+ int height)
{
static HWND caretHWND = NULL;
TkCaret *caretPtr = &(((TkWindow *) tkwin)->dispPtr->caret);
Window win;
/*
- * Prevent processing anything if the values haven't changed.
- * Windows only has one display, so we can do this with statics.
+ * Prevent processing anything if the values haven't changed. Windows only
+ * has one display, so we can do this with statics.
*/
+
if ((caretPtr->winPtr == ((TkWindow *) tkwin))
&& (caretPtr->x == x) && (caretPtr->y == y)) {
return;
@@ -1797,9 +1800,8 @@ Tk_SetCaretPos(Tk_Window tkwin, int x, int y, int height)
caretPtr->height = height;
/*
- * We adjust to the toplevel to get the coords right, as setting
- * the IME composition window is based on the toplevel hwnd, so
- * ignore height.
+ * We adjust to the toplevel to get the coords right, as setting the IME
+ * composition window is based on the toplevel hwnd, so ignore height.
*/
while (!Tk_IsTopLevel(tkwin)) {
@@ -1834,6 +1836,7 @@ Tk_SetCaretPos(Tk_Window tkwin, int x, int y, int height)
* be converted to the final characters and the other clauses still
* stay on the composition window. -- yamamoto
*/
+
hIMC = ImmGetContext(hwnd);
if (hIMC) {
COMPOSITIONFORM cform;
@@ -1855,26 +1858,28 @@ Tk_SetCaretPos(Tk_Window tkwin, int x, int y, int height)
*
* Results:
* Milliseconds of user inactive time or -1 if the user32.dll doesn't
- * have the symbol GetLastInputInfo or GetLastInputInfo returns an
- * error.
+ * have the symbol GetLastInputInfo or GetLastInputInfo returns an error.
*
* Side effects:
* None.
+ *
*----------------------------------------------------------------------
*/
long
-Tk_GetUserInactiveTime(dpy)
- Display *dpy; /* Ignored on Windows */
+Tk_GetUserInactiveTime(
+ Display *dpy) /* Ignored on Windows */
{
struct tagLASTINPUTINFO {
UINT cbSize;
DWORD dwTime;
} li;
+
/*
- * Multiple settings of either of these variables should be OK;
- * any thread hazards should just cause inefficiency...
+ * Multiple settings of either of these variables should be OK; any thread
+ * hazards should just cause inefficiency...
*/
+
static FARPROC pfnGetLastInputInfo = NULL;
static int initinfo = 0;
@@ -1894,7 +1899,11 @@ Tk_GetUserInactiveTime(dpy)
if (!(BOOL)(pfnGetLastInputInfo)(&li)) {
return -1;
}
- /* last input info is in milliseconds, since restart time. */
+
+ /*
+ * Last input info is in milliseconds, since restart time.
+ */
+
return (GetTickCount()-li.dwTime);
}
@@ -1909,15 +1918,15 @@ Tk_GetUserInactiveTime(dpy)
* none
*
* Side effects:
- * The user inactivity timer of the underlaying windowing system
- * is reset to zero.
+ * The user inactivity timer of the underlaying windowing system is reset
+ * to zero.
*
*----------------------------------------------------------------------
*/
void
-Tk_ResetUserInactiveTime(dpy)
- Display *dpy;
+Tk_ResetUserInactiveTime(
+ Display *dpy)
{
INPUT inp;
@@ -1931,3 +1940,11 @@ Tk_ResetUserInactiveTime(dpy)
SendInput(1, &inp, sizeof(inp));
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/win/winMain.c b/win/winMain.c
index 4f89b2c..5176a00 100644
--- a/win/winMain.c
+++ b/win/winMain.c
@@ -1,4 +1,4 @@
-/*
+/*
* winMain.c --
*
* Main entry point for wish and other Tk-based applications.
@@ -6,10 +6,10 @@
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
* Copyright (c) 1998-1999 by Scriptics Corporation.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: winMain.c,v 1.22 2005/09/13 21:25:21 dgp Exp $
+ * RCS: @(#) $Id: winMain.c,v 1.23 2005/12/02 00:19:04 dkf Exp $
*/
#include <tk.h>
@@ -21,16 +21,15 @@
#include "tkInt.h"
/*
- * The following declarations refer to internal Tk routines. These
- * interfaces are available for use, but are not supported.
+ * The following declarations refer to internal Tk routines. These interfaces
+ * are available for use, but are not supported.
*/
-
/*
* Forward declarations for procedures defined later in this file:
*/
-static void WishPanic _ANSI_ARGS_((CONST char *format, ...));
+static void WishPanic(CONST char *format, ...);
#ifdef TK_TEST
extern int Tktest_Init(Tcl_Interp *interp);
#endif /* TK_TEST */
@@ -38,27 +37,25 @@ extern int Tktest_Init(Tcl_Interp *interp);
static BOOL consoleRequired = TRUE;
/*
- * The following #if block allows you to change the AppInit
- * function by using a #define of TCL_LOCAL_APPINIT instead
- * of rewriting this entire file. The #if checks for that
- * #define and uses Tcl_AppInit if it doesn't exist.
+ * The following #if block allows you to change the AppInit function by using
+ * a #define of TCL_LOCAL_APPINIT instead of rewriting this entire file. The
+ * #if checks for that #define and uses Tcl_AppInit if it doesn't exist.
*/
-
+
#ifndef TK_LOCAL_APPINIT
-#define TK_LOCAL_APPINIT Tcl_AppInit
+#define TK_LOCAL_APPINIT Tcl_AppInit
#endif
-extern int TK_LOCAL_APPINIT _ANSI_ARGS_((Tcl_Interp *interp));
-
+extern int TK_LOCAL_APPINIT(Tcl_Interp *interp);
+
/*
* The following #if block allows you to change how Tcl finds the startup
- * script, prime the library or encoding paths, fiddle with the argv,
- * etc., without needing to rewrite Tk_Main()
+ * script, prime the library or encoding paths, fiddle with the argv, etc.,
+ * without needing to rewrite Tk_Main()
*/
#ifdef TK_LOCAL_MAIN_HOOK
-extern int TK_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv));
+extern int TK_LOCAL_MAIN_HOOK(int *argc, char ***argv);
#endif
-
/*
*----------------------------------------------------------------------
@@ -68,8 +65,7 @@ extern int TK_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv));
* Main entry point from Windows.
*
* Results:
- * Returns false if initialization fails, otherwise it never
- * returns.
+ * Returns false if initialization fails, otherwise it never returns.
*
* Side effects:
* Just about anything, since from here we call arbitrary Tcl code.
@@ -78,11 +74,11 @@ extern int TK_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv));
*/
int APIENTRY
-WinMain(hInstance, hPrevInstance, lpszCmdLine, nCmdShow)
- HINSTANCE hInstance;
- HINSTANCE hPrevInstance;
- LPSTR lpszCmdLine;
- int nCmdShow;
+WinMain(
+ HINSTANCE hInstance,
+ HINSTANCE hPrevInstance,
+ LPSTR lpszCmdLine,
+ int nCmdShow)
{
char **argv;
int argc;
@@ -91,22 +87,22 @@ WinMain(hInstance, hPrevInstance, lpszCmdLine, nCmdShow)
Tcl_SetPanicProc(WishPanic);
/*
- * Create the console channels and install them as the standard
- * channels. All I/O will be discarded until Tk_CreateConsoleWindow is
- * called to attach the console to a text widget.
+ * Create the console channels and install them as the standard channels.
+ * All I/O will be discarded until Tk_CreateConsoleWindow is called to
+ * attach the console to a text widget.
*/
consoleRequired = TRUE;
/*
- * Set up the default locale to be standard "C" locale so parsing
- * is performed correctly.
+ * Set up the default locale to be standard "C" locale so parsing is
+ * performed correctly.
*/
setlocale(LC_ALL, "C");
/*
- * Get our args from the c-runtime. Ignore lpszCmdLine.
+ * Get our args from the c-runtime. Ignore lpszCmdLine.
*/
argc = __argc;
@@ -129,20 +125,19 @@ WinMain(hInstance, hPrevInstance, lpszCmdLine, nCmdShow)
Tk_Main(argc, argv, TK_LOCAL_APPINIT);
return 1;
}
-
/*
*----------------------------------------------------------------------
*
* Tcl_AppInit --
*
- * This procedure performs application-specific initialization.
- * Most applications, especially those that incorporate additional
- * packages, will have their own version of this procedure.
+ * This procedure performs application-specific initialization. Most
+ * applications, especially those that incorporate additional packages,
+ * will have their own version of this procedure.
*
* Results:
- * Returns a standard Tcl completion code, and leaves an error
- * message in the interp's result if an error occurs.
+ * Returns a standard Tcl completion code, and leaves an error message in
+ * the interp's result if an error occurs.
*
* Side effects:
* Depends on the startup script.
@@ -151,8 +146,8 @@ WinMain(hInstance, hPrevInstance, lpszCmdLine, nCmdShow)
*/
int
-Tcl_AppInit(interp)
- Tcl_Interp *interp; /* Interpreter for application. */
+Tcl_AppInit(
+ Tcl_Interp *interp) /* Interpreter for application. */
{
if (Tcl_Init(interp) == TCL_ERROR) {
goto error;
@@ -193,8 +188,7 @@ Tcl_AppInit(interp)
if (Tktest_Init(interp) == TCL_ERROR) {
goto error;
}
- Tcl_StaticPackage(interp, "Tktest", Tktest_Init,
- (Tcl_PackageInitProc *) NULL);
+ Tcl_StaticPackage(interp, "Tktest", Tktest_Init, NULL);
#endif /* TK_TEST */
Tcl_SetVar(interp, "tcl_rcFileName", "~/wishrc.tcl", TCL_GLOBAL_ONLY);
@@ -205,7 +199,11 @@ error:
MessageBox(NULL, Tcl_GetStringResult(interp), "Error in Wish",
MB_ICONSTOP | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND);
ExitProcess(1);
- /* we won't reach this, but we need the return */
+
+ /*
+ * We won't reach this, but we need the return.
+ */
+
return TCL_ERROR;
}
@@ -226,11 +224,12 @@ error:
*/
void
-WishPanic(CONST char *format, ...)
+WishPanic(
+ CONST char *format, ...)
{
va_list argList;
char buf[1024];
-
+
va_start(argList, format);
vsprintf(buf, format, argList);
@@ -252,8 +251,8 @@ WishPanic(CONST char *format, ...)
* Main entry point from the console.
*
* Results:
- * None: Tk_Main never returns here, so this procedure never
- * returns either.
+ * None: Tk_Main never returns here, so this procedure never returns
+ * either.
*
* Side effects:
* Whatever the applications does.
@@ -261,21 +260,24 @@ WishPanic(CONST char *format, ...)
*----------------------------------------------------------------------
*/
-int main(int argc, char **argv)
+int
+main(
+ int argc,
+ char **argv)
{
Tcl_SetPanicProc(WishPanic);
/*
- * Set up the default locale to be standard "C" locale so parsing
- * is performed correctly.
+ * Set up the default locale to be standard "C" locale so parsing is
+ * performed correctly.
*/
setlocale(LC_ALL, "C");
/*
- * Create the console channels and install them as the standard
- * channels. All I/O will be discarded until Tk_CreateConsoleWindow is
- * called to attach the console to a text widget.
+ * Create the console channels and install them as the standard channels.
+ * All I/O will be discarded until Tk_CreateConsoleWindow is called to
+ * attach the console to a text widget.
*/
consoleRequired = FALSE;
@@ -284,3 +286,11 @@ int main(int argc, char **argv)
return 0;
}
#endif /* !__GNUC__ || TK_TEST */
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */