summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2005-11-13 21:00:17 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2005-11-13 21:00:17 (GMT)
commit73dbe3d8269035641d8ade47622376ebd3dd673d (patch)
tree2879d227ab09865277f9398506829d27b4299a7f
parent4557241d6c77454e3b74bff4343859949dbc7959 (diff)
downloadtk-73dbe3d8269035641d8ade47622376ebd3dd673d.zip
tk-73dbe3d8269035641d8ade47622376ebd3dd673d.tar.gz
tk-73dbe3d8269035641d8ade47622376ebd3dd673d.tar.bz2
ANSIfy
-rw-r--r--unix/tkUnix3d.c271
-rw-r--r--unix/tkUnixConfig.c36
-rw-r--r--unix/tkUnixDialog.c159
-rw-r--r--unix/tkUnixEvent.c289
-rw-r--r--unix/tkUnixMenu.c646
-rw-r--r--unix/tkUnixMenubu.c322
-rw-r--r--unix/tkUnixScrlbr.c127
7 files changed, 928 insertions, 922 deletions
diff --git a/unix/tkUnix3d.c b/unix/tkUnix3d.c
index 940d1bd..63e6161 100644
--- a/unix/tkUnix3d.c
+++ b/unix/tkUnix3d.c
@@ -1,15 +1,15 @@
-/*
+/*
* tkUnix3d.c --
*
- * This file contains the platform specific routines for
- * drawing 3d borders in the Motif style.
+ * This file contains the platform specific routines for drawing 3d
+ * borders in the Motif 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: tkUnix3d.c,v 1.9 2004/03/17 18:15:50 das Exp $
+ * RCS: @(#) $Id: tkUnix3d.c,v 1.10 2005/11/13 21:00:17 dkf Exp $
*/
#include <tk3d.h>
@@ -19,8 +19,8 @@
#endif
/*
- * This structure is used to keep track of the extra colors used
- * by Unix 3d borders.
+ * This structure is used to keep track of the extra colors used by Unix 3D
+ * borders.
*/
typedef struct {
@@ -45,21 +45,20 @@ typedef struct {
*/
TkBorder *
-TkpGetBorder()
+TkpGetBorder(void)
{
UnixBorder *borderPtr = (UnixBorder *) ckalloc(sizeof(UnixBorder));
borderPtr->solidGC = None;
return (TkBorder *) borderPtr;
}
-
/*
*----------------------------------------------------------------------
*
* 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.
@@ -71,8 +70,8 @@ TkpGetBorder()
*/
void
-TkpFreeBorder(borderPtr)
- TkBorder *borderPtr;
+TkpFreeBorder(
+ TkBorder *borderPtr)
{
UnixBorder *unixBorderPtr = (UnixBorder *) borderPtr;
Display *display = DisplayOfScreen(borderPtr->screen);
@@ -86,18 +85,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.
@@ -109,19 +107,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;
GC left, right;
@@ -132,11 +129,11 @@ Tk_3DVerticalBevel(tkwin, drawable, border, x, y, width, height,
}
if (relief == TK_RELIEF_RAISED) {
- XFillRectangle(display, drawable,
+ XFillRectangle(display, drawable,
(leftBevel) ? borderPtr->lightGC : borderPtr->darkGC,
x, y, (unsigned) width, (unsigned) height);
} else if (relief == TK_RELIEF_SUNKEN) {
- XFillRectangle(display, drawable,
+ XFillRectangle(display, drawable,
(leftBevel) ? borderPtr->darkGC : borderPtr->lightGC,
x, y, (unsigned) width, (unsigned) height);
} else if (relief == TK_RELIEF_RIDGE) {
@@ -144,7 +141,7 @@ Tk_3DVerticalBevel(tkwin, drawable, border, x, y, width, height,
left = borderPtr->lightGC;
right = borderPtr->darkGC;
- ridgeGroove:
+ ridgeGroove:
half = width/2;
if (!leftBevel && (width & 1)) {
half++;
@@ -178,9 +175,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.
@@ -192,30 +189,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);
@@ -231,41 +226,38 @@ 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_FLAT:
- topGC = bottomGC = borderPtr->bgGC;
- break;
- case TK_RELIEF_GROOVE:
- topGC = borderPtr->darkGC;
- bottomGC = borderPtr->lightGC;
- break;
- case TK_RELIEF_RAISED:
- topGC = bottomGC =
- (topBevel) ? borderPtr->lightGC : borderPtr->darkGC;
- break;
- case TK_RELIEF_RIDGE:
- topGC = borderPtr->lightGC;
- bottomGC = borderPtr->darkGC;
- break;
- case TK_RELIEF_SOLID:
- if (unixBorderPtr->solidGC == None) {
- XGCValues gcValues;
-
- gcValues.foreground = BlackPixelOfScreen(borderPtr->screen);
- unixBorderPtr->solidGC = Tk_GetGC(tkwin, GCForeground,
- &gcValues);
- }
- XFillRectangle(display, drawable, unixBorderPtr->solidGC, x, y,
+ case TK_RELIEF_FLAT:
+ topGC = bottomGC = borderPtr->bgGC;
+ break;
+ case TK_RELIEF_GROOVE:
+ topGC = borderPtr->darkGC;
+ bottomGC = borderPtr->lightGC;
+ break;
+ case TK_RELIEF_RAISED:
+ topGC = bottomGC = (topBevel? borderPtr->lightGC : borderPtr->darkGC);
+ break;
+ case TK_RELIEF_RIDGE:
+ topGC = borderPtr->lightGC;
+ bottomGC = borderPtr->darkGC;
+ break;
+ case TK_RELIEF_SOLID:
+ if (unixBorderPtr->solidGC == None) {
+ XGCValues gcValues;
+
+ gcValues.foreground = BlackPixelOfScreen(borderPtr->screen);
+ unixBorderPtr->solidGC = Tk_GetGC(tkwin, GCForeground, &gcValues);
+ }
+ XFillRectangle(display, drawable, unixBorderPtr->solidGC, x, y,
(unsigned) width, (unsigned) height);
- return;
- case TK_RELIEF_SUNKEN:
- topGC = bottomGC =
- (topBevel) ? borderPtr->darkGC : borderPtr->lightGC;
- break;
+ return;
+ case TK_RELIEF_SUNKEN:
+ topGC = bottomGC = (topBevel? borderPtr->darkGC : borderPtr->lightGC);
+ break;
}
/*
@@ -294,24 +286,26 @@ Tk_3DHorizontalBevel(tkwin, drawable, border, x, y, width, height,
for ( ; y < bottom; y++) {
/*
- * X Dimensions are 16-bit, so avoid wraparound or display errors
- * by limiting these here.
+ * X Dimensions are 16-bit, so avoid wraparound or display errors by
+ * limiting these here.
*/
- if (x1 < -32767)
+
+ if (x1 < -32767) {
x1 = -32767;
- if (x2 > 32767)
+ }
+ if (x2 > 32767) {
x2 = 32767;
+ }
/*
* 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) {
XFillRectangle(display, drawable,
- (y < halfway) ? topGC : bottomGC, x1, y,
- (unsigned) (x2-x1), (unsigned) 1);
+ (y < halfway) ? topGC : bottomGC, x1, y,
+ (unsigned) (x2-x1), (unsigned) 1);
}
x1 += x1Delta;
x2 += x2Delta;
@@ -323,27 +317,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;
@@ -357,33 +350,31 @@ TkpGetShadows(borderPtr, tkwin)
stressed = TkpCmapStressed(tkwin, borderPtr->colormap);
/*
- * 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 (!stressed && (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.
*/
/*
@@ -440,7 +431,7 @@ TkpGetShadows(borderPtr, tkwin)
tmp2 = (MAX_INTENSITY + b)/2;
lightColor.blue = (tmp1 > tmp2) ? tmp1 : tmp2;
}
-
+
/*
* Allocate the light shadow color and its GC
*/
@@ -460,10 +451,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;
@@ -480,8 +471,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);
@@ -499,3 +490,11 @@ TkpGetShadows(borderPtr, tkwin)
borderPtr->lightGC = Tk_GetGC(tkwin, GCForeground, &gcValues);
}
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/unix/tkUnixConfig.c b/unix/tkUnixConfig.c
index 601ae98..b063fb3 100644
--- a/unix/tkUnixConfig.c
+++ b/unix/tkUnixConfig.c
@@ -1,15 +1,15 @@
/*
* tkUnixConfig.c --
*
- * This module implements the Unix system defaults for
- * the configuration package.
+ * This module implements the Unix 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: tkUnixConfig.c,v 1.3 2002/08/05 04:30:40 dgp Exp $
+ * RCS: @(#) $Id: tkUnixConfig.c,v 1.4 2005/11/13 21:00:17 dkf Exp $
*/
#include "tk.h"
@@ -21,13 +21,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.
@@ -36,10 +36,18 @@
*/
Tcl_Obj *
-TkpGetSystemDefault(tkwin, dbName, className)
- Tk_Window tkwin; /* A window to use. */
- CONST char *dbName; /* The option database name. */
- CONST char *className; /* The name of the option class. */
+TkpGetSystemDefault(
+ Tk_Window tkwin, /* A window to use. */
+ CONST char *dbName, /* The option database name. */
+ CONST char *className) /* The name of the option class. */
{
return NULL;
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/unix/tkUnixDialog.c b/unix/tkUnixDialog.c
index 9e31fd9..e4a1d86 100644
--- a/unix/tkUnixDialog.c
+++ b/unix/tkUnixDialog.c
@@ -8,27 +8,30 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkUnixDialog.c,v 1.3 2001/08/01 16:21:12 dgp Exp $
+ * RCS: @(#) $Id: tkUnixDialog.c,v 1.4 2005/11/13 21:00:17 dkf Exp $
*
*/
-
+
#include "tkPort.h"
#include "tkInt.h"
#include "tkUnixInt.h"
/*
+ * The wrapper code for Unix is actually set up in library/tk.tcl these days;
+ * the procedure names used here are probably wrong too...
+ */
+
+#ifdef TK_OBSOLETE_UNIX_DIALOG_WRAPPERS
+
+/*
*----------------------------------------------------------------------
*
- * EvalArgv --
+ * EvalObjv --
*
- * Invokes the Tcl procedure with the arguments. argv[0] is set by
- * the caller of this function. It may be different than cmdName.
- * The TCL command will see argv[0], not cmdName, as its name if it
- * invokes [lindex [info level 0] 0]
+ * Invokes the Tcl procedure with the arguments.
*
* Results:
- * TCL_ERROR if the command does not exist and cannot be autoloaded.
- * Otherwise, return the result of the evaluation of the command.
+ * Returns the result of the evaluation of the command.
*
* Side effects:
* The command may be autoloaded.
@@ -36,54 +39,37 @@
*----------------------------------------------------------------------
*/
-static int EvalArgv(interp, cmdName, argc, argv)
- Tcl_Interp *interp; /* Current interpreter. */
- char * cmdName; /* Name of the TCL command to call */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
+static int
+EvalObjv(
+ Tcl_Interp *interp, /* Current interpreter. */
+ char *cmdName, /* Name of the TCL command to call */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *CONST *objv) /* Arguments. */
{
- Tcl_CmdInfo cmdInfo;
-
- if (!Tcl_GetCommandInfo(interp, cmdName, &cmdInfo)) {
- char * cmdArgv[2];
+ Tcl_Obj *cmdObj, **objs;
+ int result;
- /*
- * This comand is not in the interpreter yet -- looks like we
- * have to auto-load it
- */
- if (!Tcl_GetCommandInfo(interp, "auto_load", &cmdInfo)) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "cannot execute command \"auto_load\"",
- NULL);
- return TCL_ERROR;
- }
+ cmdObj = Tcl_NewStringObj(cmdName, -1);
+ Tcl_IncrRefCount(cmdObj);
+ objs = (Tcl_Obj **) ckalloc(sizeof(Tcl_Obj*) * (unsigned)(objc+1));
+ objs[0] = cmdObj;
+ memcpy(objs+1, objv, sizeof(Tcl_Obj *) * (unsigned)objc);
- cmdArgv[0] = "auto_load";
- cmdArgv[1] = cmdName;
+ result = Tcl_EvalObjv(interp, objc+1, objs, 0);
- if ((*cmdInfo.proc)(cmdInfo.clientData, interp, 2, cmdArgv)!= TCL_OK){
- return TCL_ERROR;
- }
+ Tcl_DecrRefCount(cmdObj);
+ ckfree((char *) objs);
- if (!Tcl_GetCommandInfo(interp, cmdName, &cmdInfo)) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "cannot auto-load command \"",
- cmdName, "\"",NULL);
- return TCL_ERROR;
- }
- }
-
- return (*cmdInfo.proc)(cmdInfo.clientData, interp, argc, argv);
+ return result;
}
/*
*----------------------------------------------------------------------
*
- * Tk_ChooseColorCmd --
+ * Tk_ChooseColorObjCmd --
*
- * This procedure implements the color dialog box for the Unix
- * platform. See the user documentation for details on what it
- * does.
+ * This procedure implements the color dialog box for the Unix platform.
+ * See the user documentation for details on what it does.
*
* Results:
* See user documentation.
@@ -97,13 +83,13 @@ static int EvalArgv(interp, cmdName, argc, argv)
*/
int
-Tk_ChooseColorCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
+Tk_ChooseColorObjCmd(
+ ClientData clientData, /* Main window associated with interpreter. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *CONST *objv) /* Arguments. */
{
- return EvalArgv(interp, "tk::ColorDialog", argc, argv);
+ return EvalObjv(interp, "tk::ColorDialog", objc-1, objv+1);
}
/*
@@ -111,35 +97,33 @@ Tk_ChooseColorCmd(clientData, interp, argc, argv)
*
* Tk_GetOpenFileCmd --
*
- * This procedure implements the "open file" dialog box for the
- * Unix platform. See the user documentation for details on what
- * it does.
+ * This procedure implements the "open file" dialog box for the Unix
+ * platform. See the user documentation for details on what it does.
*
* Results:
* See user documentation.
*
* Side effects:
- * A dialog window is created the first this procedure is called.
- * This window is not destroyed and will be reused the next time
- * the application invokes the "tk_getOpenFile" or
- * "tk_getSaveFile" command.
+ * A dialog window is created the first this procedure is called. This
+ * window is not destroyed and will be reused the next time the
+ * application invokes the "tk_getOpenFile" or "tk_getSaveFile" command.
*
*----------------------------------------------------------------------
*/
int
-Tk_GetOpenFileCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
+Tk_GetOpenFileObjCmd(
+ ClientData clientData, /* Main window associated with interpreter. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *CONST *objv) /* Arguments. */
{
Tk_Window tkwin = (Tk_Window)clientData;
if (Tk_StrictMotif(tkwin)) {
- return EvalArgv(interp, "tk::MotifFDialog", argc, argv);
+ return EvalObjv(interp, "tk::MotifOpenFDialog", objc-1, objv+1);
} else {
- return EvalArgv(interp, "tk::FDialog", argc, argv);
+ return EvalObjv(interp, "tk::OpenFDialog", objc-1, objv+1);
}
}
@@ -148,8 +132,7 @@ Tk_GetOpenFileCmd(clientData, interp, argc, argv)
*
* Tk_GetSaveFileCmd --
*
- * Same as Tk_GetOpenFileCmd but opens a "save file" dialog box
- * instead
+ * Same as Tk_GetOpenFileCmd but opens a "save file" dialog box instead.
*
* Results:
* Same as Tk_GetOpenFileCmd.
@@ -161,18 +144,18 @@ Tk_GetOpenFileCmd(clientData, interp, argc, argv)
*/
int
-Tk_GetSaveFileCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
+Tk_GetSaveFileObjCmd(
+ ClientData clientData, /* Main window associated with interpreter. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *CONST *objv) /* Arguments. */
{
Tk_Window tkwin = (Tk_Window)clientData;
if (Tk_StrictMotif(tkwin)) {
- return EvalArgv(interp, "tk::MotifFDialog", argc, argv);
+ return EvalObjv(interp, "tk::MotifSaveFDialog", objc-1, objv+1);
} else {
- return EvalArgv(interp, "tk::FDialog", argc, argv);
+ return EvalObjv(interp, "tk::SaveFDialog", objc-1, objv+1);
}
}
@@ -181,9 +164,8 @@ Tk_GetSaveFileCmd(clientData, interp, argc, argv)
*
* Tk_MessageBoxCmd --
*
- * This procedure implements the MessageBox window for the
- * Unix platform. See the user documentation for details on what
- * it does.
+ * This procedure implements the MessageBox window for the Unix
+ * platform. See the user documentation for details on what it does.
*
* Results:
* See user documentation.
@@ -196,12 +178,21 @@ Tk_GetSaveFileCmd(clientData, interp, argc, argv)
*/
int
-Tk_MessageBoxCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
+Tk_MessageBoxCmd(
+ ClientData clientData, /* Main window associated with interpreter. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *CONST *objv) /* Arguments. */
{
- return EvalArgv(interp, "tk::MessageBox", argc, argv);
+ return EvalObjv(interp, "tk::MessageBox", objc-1, objv+1);
}
+#endif /* TK_OBSOLETE_UNIX_DIALOG_WRAPPERS */
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/unix/tkUnixEvent.c b/unix/tkUnixEvent.c
index f06c0ca..1ce015c 100644
--- a/unix/tkUnixEvent.c
+++ b/unix/tkUnixEvent.c
@@ -1,4 +1,4 @@
-/*
+/*
* tkUnixEvent.c --
*
* This file implements an event source for X displays for the
@@ -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: tkUnixEvent.c,v 1.16 2004/05/03 22:28:45 hobbs Exp $
+ * RCS: @(#) $Id: tkUnixEvent.c,v 1.17 2005/11/13 21:00:17 dkf Exp $
*/
#include "tkInt.h"
@@ -28,40 +28,36 @@ static Tcl_ThreadDataKey dataKey;
#if defined(TK_USE_INPUT_METHODS) && defined(PEEK_XCLOSEIM)
/*
- * Structure used to peek into internal XIM data structure.
- * This is only known to work with XFree86.
+ * Structure used to peek into internal XIM data structure. This is only known
+ * to work with XFree86.
*/
+
struct XIMPeek {
void *junk1, *junk2;
- XIC ic_chain;
+ XIC ic_chain;
};
#endif
/*
- * Prototypes for procedures that are referenced only in this file:
+ * Prototypes for functions that are referenced only in this file:
*/
-static void DisplayCheckProc _ANSI_ARGS_((ClientData clientData,
- int flags));
-static void DisplayExitHandler _ANSI_ARGS_((
- ClientData clientData));
-static void DisplayFileProc _ANSI_ARGS_((ClientData clientData,
- int flags));
-static void DisplaySetupProc _ANSI_ARGS_((ClientData clientData,
- int flags));
-static void TransferXEventsToTcl _ANSI_ARGS_((Display *display));
+static void DisplayCheckProc(ClientData clientData, int flags);
+static void DisplayExitHandler(ClientData clientData);
+static void DisplayFileProc(ClientData clientData, int flags);
+static void DisplaySetupProc(ClientData clientData, int flags);
+static void TransferXEventsToTcl(Display *display);
#ifdef TK_USE_INPUT_METHODS
-static void OpenIM _ANSI_ARGS_((TkDisplay *dispPtr));
+static void OpenIM(TkDisplay *dispPtr);
#endif
-
/*
*----------------------------------------------------------------------
*
* TkCreateXEventSource --
*
- * This procedure is called during Tk initialization to create
- * the event source for X Window events.
+ * This function is called during Tk initialization to create the event
+ * source for X Window events.
*
* Results:
* None.
@@ -73,9 +69,9 @@ static void OpenIM _ANSI_ARGS_((TkDisplay *dispPtr));
*/
void
-TkCreateXEventSource()
+TkCreateXEventSource(void)
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!tsdPtr->initialized) {
@@ -90,8 +86,8 @@ TkCreateXEventSource()
*
* DisplayExitHandler --
*
- * This function is called during finalization to clean up the
- * display module.
+ * This function is called during finalization to clean up the display
+ * module.
*
* Results:
* None.
@@ -103,10 +99,10 @@ TkCreateXEventSource()
*/
static void
-DisplayExitHandler(clientData)
- ClientData clientData; /* Not used. */
+DisplayExitHandler(
+ ClientData clientData) /* Not used. */
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_DeleteEventSource(DisplaySetupProc, DisplayCheckProc, NULL);
@@ -118,8 +114,8 @@ DisplayExitHandler(clientData)
*
* TkpOpenDisplay --
*
- * Allocates a new TkDisplay, opens the X display, and establishes
- * the file handler for the connection.
+ * Allocates a new TkDisplay, opens the X display, and establishes the
+ * file handler for the connection.
*
* Results:
* A pointer to a Tk display structure.
@@ -131,11 +127,11 @@ DisplayExitHandler(clientData)
*/
TkDisplay *
-TkpOpenDisplay(display_name)
- CONST char *display_name;
+TkpOpenDisplay(
+ CONST char *displayNameStr)
{
TkDisplay *dispPtr;
- Display *display = XOpenDisplay(display_name);
+ Display *display = XOpenDisplay(displayNameStr);
if (display == NULL) {
return NULL;
@@ -156,7 +152,7 @@ TkpOpenDisplay(display_name)
*
* TkpCloseDisplay --
*
- * Cancels notifier callbacks and closes a display.
+ * Cancels notifier callbacks and closes a display.
*
* Results:
* None.
@@ -168,8 +164,8 @@ TkpOpenDisplay(display_name)
*/
void
-TkpCloseDisplay(dispPtr)
- TkDisplay *dispPtr;
+TkpCloseDisplay(
+ TkDisplay *dispPtr)
{
TkSendCleanup(dispPtr);
@@ -185,19 +181,16 @@ TkpCloseDisplay(dispPtr)
#endif
if (dispPtr->inputMethod) {
/*
- * Calling XCloseIM with an input context that has not
- * been freed can cause a crash. This crash has been
- * reproduced under Linux systems with XFree86 3.3
- * and may have also been seen under Solaris 2.3.
- * The crash is caused by a double free of memory
- * inside the X library. Memory that was already
- * deallocated may be accessed again inside XCloseIM.
- * This bug can be avoided by making sure that a
- * call to XDestroyIC is made for each XCreateIC call.
- * This bug has been fixed in XFree86 4.2.99.2.
- * The internal layout of the XIM structure changed
- * in the XFree86 4.2 release so the test should
- * not be run for with these new releases.
+ * Calling XCloseIM with an input context that has not been freed can
+ * cause a crash. This crash has been reproduced under Linux systems
+ * with XFree86 3.3 and may have also been seen under Solaris 2.3.
+ * The crash is caused by a double free of memory inside the X
+ * library. Memory that was already deallocated may be accessed again
+ * inside XCloseIM. This bug can be avoided by making sure that a call
+ * to XDestroyIC is made for each XCreateIC call. This bug has been
+ * fixed in XFree86 4.2.99.2. The internal layout of the XIM structure
+ * changed in the XFree86 4.2 release so the test should not be run
+ * for with these new releases.
*/
#if defined(TK_USE_INPUT_METHODS) && defined(PEEK_XCLOSEIM)
@@ -223,8 +216,9 @@ TkpCloseDisplay(dispPtr)
if (do_peek) {
peek = (struct XIMPeek *) dispPtr->inputMethod;
- if (peek->ic_chain != NULL)
+ if (peek->ic_chain != NULL) {
Tcl_Panic("input contexts not freed before XCloseIM");
+ }
}
#endif
XCloseIM(dispPtr->inputMethod);
@@ -243,11 +237,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.
@@ -259,8 +252,8 @@ TkpCloseDisplay(dispPtr)
*/
void
-TkClipCleanup(dispPtr)
- TkDisplay *dispPtr; /* display associated with clipboard */
+TkClipCleanup(
+ TkDisplay *dispPtr) /* Display associated with clipboard */
{
if (dispPtr->clipWindow != NULL) {
Tk_DeleteSelHandler(dispPtr->clipWindow, dispPtr->clipboardAtom,
@@ -279,25 +272,25 @@ TkClipCleanup(dispPtr)
*
* DisplaySetupProc --
*
- * This procedure implements the setup part of the UNIX X display
- * event source. It is invoked by Tcl_DoOneEvent before entering
- * the notifier to check for events on all displays.
+ * This function implements the setup part of the UNIX X display event
+ * source. It is invoked by Tcl_DoOneEvent before entering the notifier
+ * to check for events on all displays.
*
* Results:
* None.
*
* Side effects:
- * If data is queued on a display inside Xlib, then the maximum
- * block time will be set to 0 to ensure that the notifier returns
- * control to Tcl even if there is no more data on the X connection.
+ * If data is queued on a display inside Xlib, then the maximum block
+ * time will be set to 0 to ensure that the notifier returns control to
+ * Tcl even if there is no more data on the X connection.
*
*----------------------------------------------------------------------
*/
static void
-DisplaySetupProc(clientData, flags)
- ClientData clientData; /* Not used. */
- int flags;
+DisplaySetupProc(
+ ClientData clientData, /* Not used. */
+ int flags)
{
TkDisplay *dispPtr;
static Tcl_Time blockTime = { 0, 0 };
@@ -307,13 +300,11 @@ DisplaySetupProc(clientData, flags)
}
for (dispPtr = TkGetDisplayList(); dispPtr != NULL;
- dispPtr = dispPtr->nextPtr) {
-
+ dispPtr = dispPtr->nextPtr) {
/*
- * Flush the display. If data is pending on the X queue, set
- * the block time to zero. This ensures that we won't block
- * in the notifier if there is data in the X queue, but not on
- * the server socket.
+ * Flush the display. If data is pending on the X queue, set the block
+ * time to zero. This ensures that we won't block in the notifier if
+ * there is data in the X queue, but not on the server socket.
*/
XFlush(dispPtr->display);
@@ -340,8 +331,8 @@ DisplaySetupProc(clientData, flags)
*/
static void
-TransferXEventsToTcl(display)
- Display *display;
+TransferXEventsToTcl(
+ Display *display)
{
int numFound;
XEvent event;
@@ -364,8 +355,7 @@ TransferXEventsToTcl(display)
*
* DisplayCheckProc --
*
- * This procedure checks for events sitting in the X event
- * queue.
+ * This function checks for events sitting in the X event queue.
*
* Results:
* None.
@@ -377,9 +367,9 @@ TransferXEventsToTcl(display)
*/
static void
-DisplayCheckProc(clientData, flags)
- ClientData clientData; /* Not used. */
- int flags;
+DisplayCheckProc(
+ ClientData clientData, /* Not used. */
+ int flags)
{
TkDisplay *dispPtr;
@@ -388,7 +378,7 @@ DisplayCheckProc(clientData, flags)
}
for (dispPtr = TkGetDisplayList(); dispPtr != NULL;
- dispPtr = dispPtr->nextPtr) {
+ dispPtr = dispPtr->nextPtr) {
XFlush(dispPtr->display);
TransferXEventsToTcl(dispPtr->display);
}
@@ -399,22 +389,22 @@ DisplayCheckProc(clientData, flags)
*
* DisplayFileProc --
*
- * This procedure implements the file handler for the X connection.
+ * This function implements the file handler for the X connection.
*
* Results:
* None.
*
* Side effects:
- * Makes entries on the Tcl event queue for all the events available
- * from all the displays.
+ * Makes entries on the Tcl event queue for all the events available from
+ * all the displays.
*
*----------------------------------------------------------------------
*/
static void
-DisplayFileProc(clientData, flags)
- ClientData clientData; /* The display pointer. */
- int flags; /* Should be TCL_READABLE. */
+DisplayFileProc(
+ ClientData clientData, /* The display pointer. */
+ int flags) /* Should be TCL_READABLE. */
{
TkDisplay *dispPtr = (TkDisplay *) clientData;
Display *display = dispPtr->display;
@@ -423,38 +413,34 @@ DisplayFileProc(clientData, flags)
XFlush(display);
numFound = XEventsQueued(display, QueuedAfterReading);
if (numFound == 0) {
-
/*
- * Things are very tricky if there aren't any events readable
- * at this point (after all, there was supposedly data
- * available on the connection). A couple of things could
- * have occurred:
- *
- * One possibility is that there were only error events in the
- * input from the server. If this happens, we should return
- * (we don't want to go to sleep in XNextEvent below, since
- * this would block out other sources of input to the
- * process).
+ * Things are very tricky if there aren't any events readable at this
+ * point (after all, there was supposedly data available on the
+ * connection). A couple of things could have occurred:
+ *
+ * One possibility is that there were only error events in the input
+ * from the server. If this happens, we should return (we don't want
+ * to go to sleep in XNextEvent below, since this would block out
+ * other sources of input to the process).
*
- * Another possibility is that our connection to the server
- * has been closed. This will not necessarily be detected in
- * XEventsQueued (!!), so if we just return then there will be
- * an infinite loop. To detect such an error, generate a NoOp
- * protocol request to exercise the connection to the server,
- * then return. However, must disable SIGPIPE while sending
- * the request, or else the process will die from the signal
- * and won't invoke the X error function to print a nice (?!)
- * message.
+ * Another possibility is that our connection to the server has been
+ * closed. This will not necessarily be detected in XEventsQueued (!!)
+ * so if we just return then there will be an infinite loop. To detect
+ * such an error, generate a NoOp protocol request to exercise the
+ * connection to the server, then return. However, must disable
+ * SIGPIPE while sending the request, or else the process will die
+ * from the signal and won't invoke the X error function to print a
+ * nice (?!) message.
*/
-
+
void (*oldHandler)();
-
+
oldHandler = (void (*)()) signal(SIGPIPE, SIG_IGN);
XNoOp(display);
XFlush(display);
(void) signal(SIGPIPE, oldHandler);
}
-
+
TransferXEventsToTcl(display);
}
@@ -463,13 +449,12 @@ DisplayFileProc(clientData, flags)
*
* TkUnixDoOneXEvent --
*
- * This routine waits for an X event to be processed or for
- * a timeout to occur. The timeout is specified as an absolute
- * time. This routine is called when Tk needs to wait for a
- * particular X event without letting arbitrary events be
- * processed. The caller will typically call Tk_RestrictEvents
- * to set up an event filter before calling this routine. This
- * routine will service at most one event per invocation.
+ * This routine waits for an X event to be processed or for a timeout to
+ * occur. The timeout is specified as an absolute time. This routine is
+ * called when Tk needs to wait for a particular X event without letting
+ * arbitrary events be processed. The caller will typically call
+ * Tk_RestrictEvents to set up an event filter before calling this
+ * routine. This routine will service at most one event per invocation.
*
* Results:
* Returns 0 if the timeout has expired, otherwise returns 1.
@@ -481,9 +466,9 @@ DisplayFileProc(clientData, flags)
*/
int
-TkUnixDoOneXEvent(timePtr)
- Tcl_Time *timePtr; /* Specifies the absolute time when the
- * call should time out. */
+TkUnixDoOneXEvent(
+ Tcl_Time *timePtr) /* Specifies the absolute time when the call
+ * should time out. */
{
TkDisplay *dispPtr;
static fd_mask readMask[MASK_SIZE];
@@ -492,7 +477,7 @@ TkUnixDoOneXEvent(timePtr)
int fd, index, bit, numFound, numFdBits = 0;
/*
- * Look for queued events first.
+ * Look for queued events first.
*/
if (Tcl_ServiceEvent(TCL_WINDOW_EVENTS)) {
@@ -501,8 +486,8 @@ TkUnixDoOneXEvent(timePtr)
/*
* Compute the next block time and check to see if we have timed out.
- * Note that HP-UX defines tv_sec to be unsigned so we have to be
- * careful in our arithmetic.
+ * Note that HP-UX defines tv_sec to be unsigned so we have to be careful
+ * in our arithmetic.
*/
if (timePtr) {
@@ -525,8 +510,8 @@ TkUnixDoOneXEvent(timePtr)
}
/*
- * Set up the select mask for all of the displays. If a display has
- * data pending, then we want to poll instead of blocking.
+ * Set up the select mask for all of the displays. If a display has data
+ * pending, then we want to poll instead of blocking.
*/
memset((VOID *) readMask, 0, MASK_SIZE*sizeof(fd_mask));
@@ -550,8 +535,8 @@ TkUnixDoOneXEvent(timePtr)
timeoutPtr);
if (numFound <= 0) {
/*
- * Some systems don't clear the masks after an error, so
- * we have to do it here.
+ * Some systems don't clear the masks after an error, so we have to do
+ * it here.
*/
memset((VOID *) readMask, 0, MASK_SIZE*sizeof(fd_mask));
@@ -562,7 +547,7 @@ TkUnixDoOneXEvent(timePtr)
*/
for (dispPtr = TkGetDisplayList(); dispPtr != NULL;
- dispPtr = dispPtr->nextPtr) {
+ dispPtr = dispPtr->nextPtr) {
fd = ConnectionNumber(dispPtr->display);
index = fd/(NBBY*sizeof(fd_mask));
bit = 1 << (fd%(NBBY*sizeof(fd_mask)));
@@ -587,8 +572,8 @@ TkUnixDoOneXEvent(timePtr)
}
/*
- * We had an event but we did not generate a Tcl event from it. Behave
- * as though we dealt with it. (JYL&SS)
+ * We had an event but we did not generate a Tcl event from it. Behave as
+ * though we dealt with it. (JYL&SS)
*/
return 1;
@@ -599,9 +584,9 @@ TkUnixDoOneXEvent(timePtr)
*
* TkpSync --
*
- * This routine ensures that all pending X requests have been
- * seen by the server, and that any pending X events have been
- * moved onto the Tk event queue.
+ * This routine ensures that all pending X requests have been seen by the
+ * server, and that any pending X events have been moved onto the Tk
+ * event queue.
*
* Results:
* None.
@@ -613,30 +598,31 @@ TkUnixDoOneXEvent(timePtr)
*/
void
-TkpSync(display)
- Display *display; /* Display to sync. */
+TkpSync(
+ Display *display) /* Display to sync. */
{
XSync(display, False);
/*
* Transfer events from the X event queue to the Tk event queue.
*/
+
TransferXEventsToTcl(display);
}
#ifdef TK_USE_INPUT_METHODS
-/*
+/*
*--------------------------------------------------------------
*
* OpenIM --
*
- * Tries to open an X input method, associated with the
- * given display. Right now we can only deal with a bare-bones
- * input style: no preedit, and no status.
+ * Tries to open an X input method, associated with the given display.
+ * Right now we can only deal with a bare-bones input style: no preedit,
+ * and no status.
*
* Results:
- * Stores the input method in dispPtr->inputMethod; if there isn't
- * a suitable input method, then NULL is stored in dispPtr->inputMethod.
+ * Stores the input method in dispPtr->inputMethod; if there isn't a
+ * suitable input method, then NULL is stored in dispPtr->inputMethod.
*
* Side effects:
* An input method gets opened.
@@ -645,8 +631,8 @@ TkpSync(display)
*/
static void
-OpenIM(dispPtr)
- TkDisplay *dispPtr; /* Tk's structure for the display. */
+OpenIM(
+ TkDisplay *dispPtr) /* Tk's structure for the display. */
{
unsigned short i;
XIMStyles *stylePtr;
@@ -664,10 +650,11 @@ OpenIM(dispPtr)
NULL) != NULL) || (stylePtr == NULL)) {
goto error;
}
+
#if TK_XIM_SPOT
/*
- * If we want to do over-the-spot XIM, we have to check that this
- * mode is supported. If not we will fall-through to the check below.
+ * If we want to do over-the-spot XIM, we have to check that this mode is
+ * supported. If not we will fall-through to the check below.
*/
for (i = 0; i < stylePtr->count_styles; i++) {
if (stylePtr->supported_styles[i]
@@ -677,7 +664,8 @@ OpenIM(dispPtr)
return;
}
}
-#endif
+#endif /* TK_XIM_SPOT */
+
for (i = 0; i < stylePtr->count_styles; i++) {
if (stylePtr->supported_styles[i]
== (XIMPreeditNothing | XIMStatusNothing)) {
@@ -687,15 +675,24 @@ OpenIM(dispPtr)
}
XFree(stylePtr);
- error:
+ error:
if (dispPtr->inputMethod) {
/*
- * This call should not suffer from any core dumping problems
- * since we have not allocated any input contexts.
+ * This call should not suffer from any core dumping problems since we
+ * have not allocated any input contexts.
*/
+
XCloseIM(dispPtr->inputMethod);
dispPtr->inputMethod = NULL;
}
}
#endif /* TK_USE_INPUT_METHODS */
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/unix/tkUnixMenu.c b/unix/tkUnixMenu.c
index 74f6459..c44d8a1 100644
--- a/unix/tkUnixMenu.c
+++ b/unix/tkUnixMenu.c
@@ -1,14 +1,14 @@
-/*
+/*
* tkUnixMenu.c --
*
* This module implements the UNIX platform-specific features of menus.
*
* Copyright (c) 1996-1998 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: tkUnixMenu.c,v 1.11 2004/06/08 20:28:19 dgp Exp $
+ * RCS: @(#) $Id: tkUnixMenu.c,v 1.12 2005/11/13 21:00:17 dkf Exp $
*/
#include "tkPort.h"
@@ -34,14 +34,15 @@
* Shared with button widget.
*/
-extern void TkpDrawCheckIndicator _ANSI_ARGS_((
- Tk_Window tkwin, Display *display, Drawable d,
- int x, int y, Tk_3DBorder bgBorder,
- XColor *indicatorColor, XColor *selectColor,
- XColor *disColor, int on, int disabled, int mode));
+extern void TkpDrawCheckIndicator(Tk_Window tkwin,
+ Display *display, Drawable d, int x, int y,
+ Tk_3DBorder bgBorder, XColor *indicatorColor,
+ XColor *selectColor, XColor *disColor, int on,
+ int disabled, int mode);
/*
* Indicator Draw Modes
*/
+
#define CHECK_BUTTON 0
#define CHECK_MENU 1
#define RADIO_BUTTON 2
@@ -51,61 +52,57 @@ extern void TkpDrawCheckIndicator _ANSI_ARGS_((
* Procedures used internally.
*/
-static void SetHelpMenu _ANSI_ARGS_((TkMenu *menuPtr));
-static void DrawMenuEntryAccelerator _ANSI_ARGS_((
- TkMenu *menuPtr, TkMenuEntry *mePtr,
- Drawable d, GC gc, Tk_Font tkfont,
- CONST Tk_FontMetrics *fmPtr,
+static void SetHelpMenu(TkMenu *menuPtr);
+static void DrawMenuEntryAccelerator(TkMenu *menuPtr,
+ TkMenuEntry *mePtr, Drawable d, GC gc,
+ Tk_Font tkfont, CONST Tk_FontMetrics *fmPtr,
Tk_3DBorder activeBorder, int x, int y,
- int width, int height, int drawArrow));
-static void DrawMenuEntryBackground _ANSI_ARGS_((
- TkMenu *menuPtr, TkMenuEntry *mePtr,
- Drawable d, Tk_3DBorder activeBorder,
- Tk_3DBorder bgBorder, int x, int y,
- int width, int heigth));
-static void DrawMenuEntryIndicator _ANSI_ARGS_((
- TkMenu *menuPtr, TkMenuEntry *mePtr, Drawable d,
+ int width, int height, int drawArrow);
+static void DrawMenuEntryBackground(TkMenu *menuPtr,
+ TkMenuEntry *mePtr, Drawable d,
+ Tk_3DBorder activeBorder, Tk_3DBorder bgBorder,
+ int x, int y, int width, int heigth);
+static void DrawMenuEntryIndicator(TkMenu *menuPtr,
+ TkMenuEntry *mePtr, Drawable d,
Tk_3DBorder border, XColor *indicatorColor,
XColor *disableColor, Tk_Font tkfont,
CONST Tk_FontMetrics *fmPtr, int x, int y,
- int width, int height));
-static void DrawMenuEntryLabel _ANSI_ARGS_((
- TkMenu * menuPtr, TkMenuEntry *mePtr, Drawable d,
- GC gc, Tk_Font tkfont,
- CONST Tk_FontMetrics *fmPtr, int x, int y,
- int width, int height));
-static void DrawMenuSeparator _ANSI_ARGS_((TkMenu *menuPtr,
- TkMenuEntry *mePtr, Drawable d, GC gc,
- Tk_Font tkfont, CONST Tk_FontMetrics *fmPtr,
- int x, int y, int width, int height));
-static void DrawTearoffEntry _ANSI_ARGS_((TkMenu *menuPtr,
- TkMenuEntry *mePtr, Drawable d, GC gc,
- Tk_Font tkfont, CONST Tk_FontMetrics *fmPtr,
- int x, int y, int width, int height));
-static void DrawMenuUnderline _ANSI_ARGS_((TkMenu *menuPtr,
+ int width, int height);
+static void DrawMenuEntryLabel(TkMenu * menuPtr,
+ TkMenuEntry *mePtr, Drawable d, GC gc,
+ Tk_Font tkfont, CONST Tk_FontMetrics *fmPtr,
+ int x, int y, int width, int height);
+static void DrawMenuSeparator(TkMenu *menuPtr,
+ TkMenuEntry *mePtr, Drawable d, GC gc,
+ Tk_Font tkfont, CONST Tk_FontMetrics *fmPtr,
+ int x, int y, int width, int height);
+static void DrawTearoffEntry(TkMenu *menuPtr,
+ TkMenuEntry *mePtr, Drawable d, GC gc,
+ Tk_Font tkfont, CONST Tk_FontMetrics *fmPtr,
+ int x, int y, int width, int height);
+static void DrawMenuUnderline(TkMenu *menuPtr,
TkMenuEntry *mePtr, Drawable d, GC gc,
- Tk_Font tkfont, CONST Tk_FontMetrics *fmPtr, int x,
- int y, int width, int height));
-static void GetMenuAccelGeometry _ANSI_ARGS_((TkMenu *menuPtr,
+ Tk_Font tkfont, CONST Tk_FontMetrics *fmPtr,
+ int x, int y, int width, int height);
+static void GetMenuAccelGeometry(TkMenu *menuPtr,
TkMenuEntry *mePtr, Tk_Font tkfont,
CONST Tk_FontMetrics *fmPtr, int *widthPtr,
- int *heightPtr));
-static void GetMenuLabelGeometry _ANSI_ARGS_((TkMenuEntry *mePtr,
- Tk_Font tkfont, CONST Tk_FontMetrics *fmPtr,
- int *widthPtr, int *heightPtr));
-static void GetMenuIndicatorGeometry _ANSI_ARGS_((
- TkMenu *menuPtr, TkMenuEntry *mePtr,
- Tk_Font tkfont, CONST Tk_FontMetrics *fmPtr,
- int *widthPtr, int *heightPtr));
-static void GetMenuSeparatorGeometry _ANSI_ARGS_((
- TkMenu *menuPtr, TkMenuEntry *mePtr,
+ int *heightPtr);
+static void GetMenuLabelGeometry(TkMenuEntry *mePtr,
Tk_Font tkfont, CONST Tk_FontMetrics *fmPtr,
- int *widthPtr, int *heightPtr));
-static void GetTearoffEntryGeometry _ANSI_ARGS_((TkMenu *menuPtr,
+ int *widthPtr, int *heightPtr);
+static void GetMenuIndicatorGeometry(TkMenu *menuPtr,
+ TkMenuEntry *mePtr, Tk_Font tkfont,
+ CONST Tk_FontMetrics *fmPtr,
+ int *widthPtr, int *heightPtr);
+static void GetMenuSeparatorGeometry(TkMenu *menuPtr,
+ TkMenuEntry *mePtr, Tk_Font tkfont,
+ CONST Tk_FontMetrics *fmPtr,
+ int *widthPtr, int *heightPtr);
+static void GetTearoffEntryGeometry(TkMenu *menuPtr,
TkMenuEntry *mePtr, Tk_Font tkfont,
CONST Tk_FontMetrics *fmPtr, int *widthPtr,
- int *heightPtr));
-
+ int *heightPtr);
/*
*----------------------------------------------------------------------
@@ -119,15 +116,15 @@ static void GetTearoffEntryGeometry _ANSI_ARGS_((TkMenu *menuPtr,
* Standard TCL error.
*
* Side effects:
- * Allocates any platform specific allocations and places them
- * in the platformData field of the menuPtr.
+ * Allocates any platform specific allocations and places them in the
+ * platformData field of the menuPtr.
*
*----------------------------------------------------------------------
*/
int
-TkpNewMenu(menuPtr)
- TkMenu *menuPtr;
+TkpNewMenu(
+ TkMenu *menuPtr)
{
SetHelpMenu(menuPtr);
return TCL_OK;
@@ -138,8 +135,8 @@ TkpNewMenu(menuPtr)
*
* TkpDestroyMenu --
*
- * Destroys platform-specific menu structures. Called when the
- * generic menu structure is destroyed for the menu.
+ * Destroys platform-specific menu structures. Called when the generic
+ * menu structure is destroyed for the menu.
*
* Results:
* None.
@@ -151,8 +148,8 @@ TkpNewMenu(menuPtr)
*/
void
-TkpDestroyMenu(menuPtr)
- TkMenu *menuPtr;
+TkpDestroyMenu(
+ TkMenu *menuPtr)
{
/*
* Nothing to do.
@@ -164,8 +161,8 @@ TkpDestroyMenu(menuPtr)
*
* TkpDestroyMenuEntry --
*
- * Cleans up platform-specific menu entry items. Called when entry
- * is destroyed in the generic code.
+ * Cleans up platform-specific menu entry items. Called when entry is
+ * destroyed in the generic code.
*
* Results:
* None.
@@ -177,8 +174,8 @@ TkpDestroyMenu(menuPtr)
*/
void
-TkpDestroyMenuEntry(mEntryPtr)
- TkMenuEntry *mEntryPtr;
+TkpDestroyMenuEntry(
+ TkMenuEntry *mEntryPtr)
{
/*
* Nothing to do.
@@ -190,29 +187,28 @@ TkpDestroyMenuEntry(mEntryPtr)
*
* TkpConfigureMenuEntry --
*
- * Processes configuration options for menu entries. Called when
- * the generic options are processed for the menu.
+ * Processes configuration options for menu entries. Called when the
+ * generic options are processed for the menu.
*
* Results:
- * Returns standard TCL result. If TCL_ERROR is returned, then
- * the interp's result contains an error message.
+ * Returns standard TCL result. If TCL_ERROR is returned, then the
+ * interp's result contains an error message.
*
* Side effects:
- * Configuration information get set for mePtr; old resources
- * get freed, if any need it.
+ * Configuration information get set for mePtr; old resources get freed,
+ * if any need it.
*
*----------------------------------------------------------------------
*/
int
-TkpConfigureMenuEntry(mePtr)
- register TkMenuEntry *mePtr; /* Information about menu entry; may
- * or may not already have values for
- * some fields. */
+TkpConfigureMenuEntry(
+ register TkMenuEntry *mePtr)/* Information about menu entry; may or may
+ * not already have values for some fields. */
{
/*
- * If this is a cascade menu, and the child menu exists, check to
- * see if the child menu is a help menu.
+ * If this is a cascade menu, and the child menu exists, check to see if
+ * the child menu is a help menu.
*/
if ((mePtr->type == CASCADE_ENTRY) && (mePtr->namePtr != NULL)) {
@@ -233,9 +229,8 @@ TkpConfigureMenuEntry(mePtr)
* TkpMenuNewEntry --
*
* Called when a new entry is created in a menu. Fills in platform
- * specific data for the entry. The platformEntryData field
- * is used to store the indicator diameter for radio button
- * and check box entries.
+ * specific data for the entry. The platformEntryData field is used to
+ * store the indicator diameter for radio button and check box entries.
*
* Results:
* Standard TCL error.
@@ -247,8 +242,8 @@ TkpConfigureMenuEntry(mePtr)
*/
int
-TkpMenuNewEntry(mePtr)
- TkMenuEntry *mePtr;
+TkpMenuNewEntry(
+ TkMenuEntry *mePtr)
{
return TCL_OK;
}
@@ -270,9 +265,9 @@ TkpMenuNewEntry(mePtr)
*/
void
-TkpSetWindowMenuBar(tkwin, menuPtr)
- Tk_Window tkwin; /* The window we are setting */
- TkMenu *menuPtr; /* The menu we are setting */
+TkpSetWindowMenuBar(
+ Tk_Window tkwin, /* The window we are setting */
+ TkMenu *menuPtr) /* The menu we are setting */
{
if (menuPtr == NULL) {
TkUnixSetMenubar(tkwin, NULL);
@@ -286,9 +281,9 @@ TkpSetWindowMenuBar(tkwin, menuPtr)
*
* TkpSetMainMenuBar --
*
- * Called when a toplevel widget is brought to front. On the
- * Macintosh, sets up the menubar that goes accross the top
- * of the main monitor. On other platforms, nothing is necessary.
+ * Called when a toplevel widget is brought to front. On the Macintosh,
+ * sets up the menubar that goes accross the top of the main monitor. On
+ * other platforms, nothing is necessary.
*
* Results:
* None.
@@ -300,10 +295,10 @@ TkpSetWindowMenuBar(tkwin, menuPtr)
*/
void
-TkpSetMainMenubar(interp, tkwin, menuName)
- Tcl_Interp *interp;
- Tk_Window tkwin;
- char *menuName;
+TkpSetMainMenubar(
+ Tcl_Interp *interp,
+ Tk_Window tkwin,
+ char *menuName)
{
/*
* Nothing to do.
@@ -315,10 +310,9 @@ TkpSetMainMenubar(interp, tkwin, menuName)
*
* GetMenuIndicatorGeometry --
*
- * Fills out the geometry of the indicator in a menu item. Note
- * that the mePtr->height field must have already been filled in
- * by GetMenuLabelGeometry since this height depends on the label
- * height.
+ * Fills out the geometry of the indicator in a menu item. Note that the
+ * mePtr->height field must have already been filled in by
+ * GetMenuLabelGeometry since this height depends on the label height.
*
* Results:
* widthPtr and heightPtr point to the new geometry values.
@@ -330,13 +324,13 @@ TkpSetMainMenubar(interp, tkwin, menuName)
*/
static void
-GetMenuIndicatorGeometry(menuPtr, mePtr, tkfont, fmPtr, widthPtr, heightPtr)
- TkMenu *menuPtr; /* The menu we are drawing. */
- TkMenuEntry *mePtr; /* The entry we are interested in. */
- Tk_Font tkfont; /* The precalculated font */
- CONST Tk_FontMetrics *fmPtr; /* The precalculated metrics */
- int *widthPtr; /* The resulting width */
- int *heightPtr; /* The resulting height */
+GetMenuIndicatorGeometry(
+ TkMenu *menuPtr, /* The menu we are drawing. */
+ TkMenuEntry *mePtr, /* The entry we are interested in. */
+ Tk_Font tkfont, /* The precalculated font */
+ CONST Tk_FontMetrics *fmPtr,/* The precalculated metrics */
+ int *widthPtr, /* The resulting width */
+ int *heightPtr) /* The resulting height */
{
if ((mePtr->type == CHECK_BUTTON_ENTRY)
|| (mePtr->type == RADIO_BUTTON_ENTRY)) {
@@ -345,14 +339,14 @@ GetMenuIndicatorGeometry(menuPtr, mePtr, tkfont, fmPtr, widthPtr, heightPtr)
*widthPtr = (14 * mePtr->height) / 10;
*heightPtr = mePtr->height;
if (mePtr->type == CHECK_BUTTON_ENTRY) {
- mePtr->platformEntryData =
+ mePtr->platformEntryData =
(TkMenuPlatformEntryData) ((65 * mePtr->height)
/ 100);
} else {
- mePtr->platformEntryData =
+ mePtr->platformEntryData =
(TkMenuPlatformEntryData) ((75 * mePtr->height)
/ 100);
- }
+ }
} else {
*widthPtr = *heightPtr = mePtr->height;
if (mePtr->type == CHECK_BUTTON_ENTRY) {
@@ -399,13 +393,13 @@ GetMenuIndicatorGeometry(menuPtr, mePtr, tkfont, fmPtr, widthPtr, heightPtr)
*/
static void
-GetMenuAccelGeometry(menuPtr, mePtr, tkfont, fmPtr, widthPtr, heightPtr)
- TkMenu *menuPtr; /* The menu was are drawing */
- TkMenuEntry *mePtr; /* The entry we are getting the geometry for */
- Tk_Font tkfont; /* The precalculated font */
- CONST Tk_FontMetrics *fmPtr;/* The precalculated font metrics */
- int *widthPtr; /* The width of the acclerator area */
- int *heightPtr; /* The height of the accelerator area */
+GetMenuAccelGeometry(
+ TkMenu *menuPtr, /* The menu was are drawing */
+ TkMenuEntry *mePtr, /* The entry we are getting the geometry for */
+ Tk_Font tkfont, /* The precalculated font */
+ CONST Tk_FontMetrics *fmPtr,/* The precalculated font metrics */
+ int *widthPtr, /* The width of the acclerator area */
+ int *heightPtr) /* The height of the accelerator area */
{
*heightPtr = fmPtr->linespace;
if (mePtr->type == CASCADE_ENTRY) {
@@ -413,7 +407,7 @@ GetMenuAccelGeometry(menuPtr, mePtr, tkfont, fmPtr, widthPtr, heightPtr)
} else if ((menuPtr->menuType != MENUBAR)
&& (mePtr->accelPtr != NULL)) {
char *accel = Tcl_GetStringFromObj(mePtr->accelPtr, NULL);
-
+
*widthPtr = Tk_TextWidth(tkfont, accel, mePtr->accelLength);
} else {
*widthPtr = 0;
@@ -431,24 +425,22 @@ GetMenuAccelGeometry(menuPtr, mePtr, tkfont, fmPtr, widthPtr, heightPtr)
* None.
*
* Side effects:
- * Commands are output to X to display the menu in its
- * current mode.
+ * Commands are output to X to display the menu in its current mode.
*
*----------------------------------------------------------------------
*/
static void
-DrawMenuEntryBackground(menuPtr, mePtr, d, activeBorder, bgBorder, x, y,
- width, height)
- TkMenu *menuPtr; /* The menu we are drawing */
- TkMenuEntry *mePtr; /* The entry we are drawing. */
- Drawable d; /* The drawable we are drawing into */
- Tk_3DBorder activeBorder; /* The border for an active item */
- Tk_3DBorder bgBorder; /* The background border */
- int x; /* Left coordinate of entry rect */
- int y; /* Right coordinate of entry rect */
- int width; /* Width of entry rect */
- int height; /* Height of entry rect */
+DrawMenuEntryBackground(
+ TkMenu *menuPtr, /* The menu we are drawing */
+ TkMenuEntry *mePtr, /* The entry we are drawing. */
+ Drawable d, /* The drawable we are drawing into */
+ Tk_3DBorder activeBorder, /* The border for an active item */
+ Tk_3DBorder bgBorder, /* The background border */
+ int x, /* Left coordinate of entry rect */
+ int y, /* Right coordinate of entry rect */
+ int width, /* Width of entry rect */
+ int height) /* Height of entry rect */
{
if (mePtr->state == ENTRY_ACTIVE) {
int relief;
@@ -485,31 +477,29 @@ DrawMenuEntryBackground(menuPtr, mePtr, d, activeBorder, bgBorder, x, y,
* None.
*
* Side effects:
- * Commands are output to X to display the menu in its
- * current mode.
+ * Commands are output to X to display the menu in its current mode.
*
*----------------------------------------------------------------------
*/
static void
-DrawMenuEntryAccelerator(menuPtr, mePtr, d, gc, tkfont, fmPtr, activeBorder,
- x, y, width, height, drawArrow)
- TkMenu *menuPtr; /* The menu we are drawing */
- TkMenuEntry *mePtr; /* The entry we are drawing */
- Drawable d; /* The drawable we are drawing into */
- GC gc; /* The precalculated gc to draw with */
- Tk_Font tkfont; /* The precalculated font */
- CONST Tk_FontMetrics *fmPtr; /* The precalculated metrics */
- Tk_3DBorder activeBorder; /* The border for an active item */
- int x; /* Left coordinate of entry rect */
- int y; /* Top coordinate of entry rect */
- int width; /* Width of entry */
- int height; /* Height of entry */
- int drawArrow; /* Whether or not to draw arrow. */
+DrawMenuEntryAccelerator(
+ TkMenu *menuPtr, /* The menu we are drawing */
+ TkMenuEntry *mePtr, /* The entry we are drawing */
+ Drawable d, /* The drawable we are drawing into */
+ GC gc, /* The precalculated gc to draw with */
+ Tk_Font tkfont, /* The precalculated font */
+ CONST Tk_FontMetrics *fmPtr,/* The precalculated metrics */
+ Tk_3DBorder activeBorder, /* The border for an active item */
+ int x, /* Left coordinate of entry rect */
+ int y, /* Top coordinate of entry rect */
+ int width, /* Width of entry */
+ int height, /* Height of entry */
+ int drawArrow) /* Whether or not to draw arrow. */
{
XPoint points[3];
int borderWidth, activeBorderWidth;
-
+
/*
* Draw accelerator or cascade arrow.
*/
@@ -538,7 +528,7 @@ DrawMenuEntryAccelerator(menuPtr, mePtr, d, gc, tkfont, fmPtr, activeBorder,
char *accel = Tcl_GetStringFromObj(mePtr->accelPtr, NULL);
int left = x + mePtr->labelWidth + activeBorderWidth
+ mePtr->indicatorSpace;
-
+
if (menuPtr->menuType == MENUBAR) {
left += 5;
}
@@ -559,27 +549,25 @@ DrawMenuEntryAccelerator(menuPtr, mePtr, d, gc, tkfont, fmPtr, activeBorder,
* None.
*
* Side effects:
- * Commands are output to X to display the menu in its
- * current mode.
+ * Commands are output to X to display the menu in its current mode.
*
*----------------------------------------------------------------------
*/
static void
-DrawMenuEntryIndicator(menuPtr, mePtr, d, border, indicatorColor, disableColor,
- tkfont, fmPtr, x, y, width, height)
- TkMenu *menuPtr; /* The menu we are drawing */
- TkMenuEntry *mePtr; /* The entry we are drawing */
- Drawable d; /* The drawable to draw into */
- Tk_3DBorder border; /* The background color */
- XColor *indicatorColor; /* The color to draw indicators with */
- XColor *disableColor; /* The color use use when disabled */
- Tk_Font tkfont; /* The font to draw with */
- CONST Tk_FontMetrics *fmPtr; /* The font metrics of the font */
- int x; /* The left of the entry rect */
- int y; /* The top of the entry rect */
- int width; /* Width of menu entry */
- int height; /* Height of menu entry */
+DrawMenuEntryIndicator(
+ TkMenu *menuPtr, /* The menu we are drawing */
+ TkMenuEntry *mePtr, /* The entry we are drawing */
+ Drawable d, /* The drawable to draw into */
+ Tk_3DBorder border, /* The background color */
+ XColor *indicatorColor, /* The color to draw indicators with */
+ XColor *disableColor, /* The color use use when disabled */
+ Tk_Font tkfont, /* The font to draw with */
+ CONST Tk_FontMetrics *fmPtr,/* The font metrics of the font */
+ int x, /* The left of the entry rect */
+ int y, /* The top of the entry rect */
+ int width, /* Width of menu entry */
+ int height) /* Height of menu entry */
{
/*
* Draw check-button indicator.
@@ -599,7 +587,7 @@ DrawMenuEntryIndicator(menuPtr, mePtr, d, border, indicatorColor, disableColor,
+ mePtr->indicatorSpace/2;
TkpDrawCheckIndicator(menuPtr->tkwin, menuPtr->display, d, left, top,
- border, indicatorColor, bg, disableColor,
+ border, indicatorColor, bg, disableColor,
(mePtr->entryFlags & ENTRY_SELECTED), disabled, CHECK_MENU);
}
@@ -621,7 +609,7 @@ DrawMenuEntryIndicator(menuPtr, mePtr, d, border, indicatorColor, disableColor,
+ mePtr->indicatorSpace/2;
TkpDrawCheckIndicator(menuPtr->tkwin, menuPtr->display, d, left, top,
- border, indicatorColor, bg, disableColor,
+ border, indicatorColor, bg, disableColor,
(mePtr->entryFlags & ENTRY_SELECTED), disabled, RADIO_MENU);
}
}
@@ -637,24 +625,23 @@ DrawMenuEntryIndicator(menuPtr, mePtr, d, border, indicatorColor, disableColor,
* None.
*
* Side effects:
- * Commands are output to X to display the menu in its
- * current mode.
+ * Commands are output to X to display the menu in its current mode.
*
*----------------------------------------------------------------------
*/
static void
-DrawMenuSeparator(menuPtr, mePtr, d, gc, tkfont, fmPtr, x, y, width, height)
- TkMenu *menuPtr; /* The menu we are drawing */
- TkMenuEntry *mePtr; /* The entry we are drawing */
- Drawable d; /* The drawable we are using */
- GC gc; /* The gc to draw into */
- Tk_Font tkfont; /* The font to draw with */
- CONST Tk_FontMetrics *fmPtr; /* The font metrics from the font */
- int x;
- int y;
- int width;
- int height;
+DrawMenuSeparator(
+ TkMenu *menuPtr, /* The menu we are drawing */
+ TkMenuEntry *mePtr, /* The entry we are drawing */
+ Drawable d, /* The drawable we are using */
+ GC gc, /* The gc to draw into */
+ Tk_Font tkfont, /* The font to draw with */
+ CONST Tk_FontMetrics *fmPtr,/* The font metrics from the font */
+ int x,
+ int y,
+ int width,
+ int height)
{
XPoint points[2];
Tk_3DBorder border;
@@ -662,7 +649,7 @@ DrawMenuSeparator(menuPtr, mePtr, d, gc, tkfont, fmPtr, x, y, width, height)
if (menuPtr->menuType == MENUBAR) {
return;
}
-
+
points[0].x = x;
points[0].y = y + height/2;
points[1].x = width - 1;
@@ -683,24 +670,23 @@ DrawMenuSeparator(menuPtr, mePtr, d, gc, tkfont, fmPtr, x, y, width, height)
* None.
*
* Side effects:
- * Commands are output to X to display the menu in its
- * current mode.
+ * Commands are output to X to display the menu in its current mode.
*
*----------------------------------------------------------------------
*/
static void
-DrawMenuEntryLabel(menuPtr, mePtr, d, gc, tkfont, fmPtr, x, y, width, height)
- TkMenu *menuPtr; /* The menu we are drawing. */
- TkMenuEntry *mePtr; /* The entry we are drawing. */
- Drawable d; /* What we are drawing into. */
- GC gc; /* The gc we are drawing into.*/
- Tk_Font tkfont; /* The precalculated font. */
- CONST Tk_FontMetrics *fmPtr;/* The precalculated font metrics. */
- int x; /* Left edge. */
- int y; /* Top edge. */
- int width; /* width of entry. */
- int height; /* height of entry. */
+DrawMenuEntryLabel(
+ TkMenu *menuPtr, /* The menu we are drawing. */
+ TkMenuEntry *mePtr, /* The entry we are drawing. */
+ Drawable d, /* What we are drawing into. */
+ GC gc, /* The gc we are drawing into.*/
+ Tk_Font tkfont, /* The precalculated font. */
+ CONST Tk_FontMetrics *fmPtr,/* The precalculated font metrics. */
+ int x, /* Left edge. */
+ int y, /* Top edge. */
+ int width, /* width of entry. */
+ int height) /* height of entry. */
{
int indicatorSpace = mePtr->indicatorSpace;
int activeBorderWidth;
@@ -717,7 +703,7 @@ DrawMenuEntryLabel(menuPtr, mePtr, d, gc, tkfont, fmPtr, x, y, width, height)
if (menuPtr->menuType == MENUBAR) {
leftEdge += 5;
}
-
+
/*
* Work out what we will need to draw first.
*/
@@ -738,7 +724,7 @@ DrawMenuEntryLabel(menuPtr, mePtr, d, gc, tkfont, fmPtr, x, y, width, height)
haveText = 1;
}
}
-
+
/*
* Now work out what the relative positions are.
*/
@@ -746,55 +732,52 @@ DrawMenuEntryLabel(menuPtr, mePtr, d, gc, tkfont, fmPtr, x, y, width, height)
if (haveImage && haveText) {
int fullWidth = (imageWidth > textWidth ? imageWidth : textWidth);
switch ((enum compound) mePtr->compound) {
- case COMPOUND_TOP: {
- textXOffset = (fullWidth - textWidth)/2;
- textYOffset = imageHeight/2 + 2;
- imageXOffset = (fullWidth - imageWidth)/2;
- imageYOffset = -textHeight/2;
- break;
- }
- case COMPOUND_BOTTOM: {
- textXOffset = (fullWidth - textWidth)/2;
- textYOffset = -imageHeight/2;
- imageXOffset = (fullWidth - imageWidth)/2;
- imageYOffset = textHeight/2 + 2;
- break;
- }
- case COMPOUND_LEFT: {
- /*
- * Position image in the indicator space to the left of the
- * entries, unless this entry is a radio|check button because
- * then the indicator space will be used.
- */
- textXOffset = imageWidth + 2;
- textYOffset = 0;
- imageXOffset = 0;
- imageYOffset = 0;
- if ((mePtr->type != CHECK_BUTTON_ENTRY)
- && (mePtr->type != RADIO_BUTTON_ENTRY)) {
- textXOffset -= indicatorSpace;
- if (textXOffset < 0) {
- textXOffset = 0;
- }
- imageXOffset = -indicatorSpace;
+ case COMPOUND_TOP:
+ textXOffset = (fullWidth - textWidth)/2;
+ textYOffset = imageHeight/2 + 2;
+ imageXOffset = (fullWidth - imageWidth)/2;
+ imageYOffset = -textHeight/2;
+ break;
+ case COMPOUND_BOTTOM:
+ textXOffset = (fullWidth - textWidth)/2;
+ textYOffset = -imageHeight/2;
+ imageXOffset = (fullWidth - imageWidth)/2;
+ imageYOffset = textHeight/2 + 2;
+ break;
+ case COMPOUND_LEFT:
+ /*
+ * Position image in the indicator space to the left of the
+ * entries, unless this entry is a radio|check button because then
+ * the indicator space will be used.
+ */
+
+ textXOffset = imageWidth + 2;
+ textYOffset = 0;
+ imageXOffset = 0;
+ imageYOffset = 0;
+ if ((mePtr->type != CHECK_BUTTON_ENTRY)
+ && (mePtr->type != RADIO_BUTTON_ENTRY)) {
+ textXOffset -= indicatorSpace;
+ if (textXOffset < 0) {
+ textXOffset = 0;
}
- break;
- }
- case COMPOUND_RIGHT: {
- textXOffset = 0;
- textYOffset = 0;
- imageXOffset = textWidth + 2;
- imageYOffset = 0;
- break;
+ imageXOffset = -indicatorSpace;
}
- case COMPOUND_CENTER: {
- textXOffset = (fullWidth - textWidth)/2;
- textYOffset = 0;
- imageXOffset = (fullWidth - imageWidth)/2;
- imageYOffset = 0;
- break;
- }
- case COMPOUND_NONE: {break;}
+ break;
+ case COMPOUND_RIGHT:
+ textXOffset = 0;
+ textYOffset = 0;
+ imageXOffset = textWidth + 2;
+ imageYOffset = 0;
+ break;
+ case COMPOUND_CENTER:
+ textXOffset = (fullWidth - textWidth)/2;
+ textYOffset = 0;
+ imageXOffset = (fullWidth - imageWidth)/2;
+ imageYOffset = 0;
+ break;
+ case COMPOUND_NONE:
+ break;
}
} else {
textXOffset = 0;
@@ -802,7 +785,7 @@ DrawMenuEntryLabel(menuPtr, mePtr, d, gc, tkfont, fmPtr, x, y, width, height)
imageXOffset = 0;
imageYOffset = 0;
}
-
+
/*
* Draw label and/or bitmap or image for entry.
*/
@@ -812,16 +795,16 @@ DrawMenuEntryLabel(menuPtr, mePtr, d, gc, tkfont, fmPtr, x, y, width, height)
&& (mePtr->entryFlags & ENTRY_SELECTED)) {
Tk_RedrawImage(mePtr->selectImage, 0, 0,
imageWidth, imageHeight, d, leftEdge + imageXOffset,
- (int) (y + (mePtr->height - imageHeight)/2 + imageYOffset));
+ (int) (y + (mePtr->height-imageHeight)/2 + imageYOffset));
} else {
Tk_RedrawImage(mePtr->image, 0, 0, imageWidth,
imageHeight, d, leftEdge + imageXOffset,
- (int) (y + (mePtr->height - imageHeight)/2 + imageYOffset));
+ (int) (y + (mePtr->height-imageHeight)/2 + imageYOffset));
}
} else if (mePtr->bitmapPtr != None) {
Pixmap bitmap = Tk_GetBitmapFromObj(menuPtr->tkwin, mePtr->bitmapPtr);
- XCopyPlane(menuPtr->display, bitmap, d, gc, 0, 0,
- (unsigned) imageWidth, (unsigned) imageHeight,
+ XCopyPlane(menuPtr->display, bitmap, d, gc, 0, 0,
+ (unsigned) imageWidth, (unsigned) imageHeight,
leftEdge + imageXOffset,
(int) (y + (mePtr->height - imageHeight)/2 + imageYOffset), 1);
}
@@ -830,9 +813,9 @@ DrawMenuEntryLabel(menuPtr, mePtr, d, gc, tkfont, fmPtr, x, y, width, height)
if (mePtr->labelLength > 0) {
char *label = Tcl_GetStringFromObj(mePtr->labelPtr, NULL);
Tk_DrawChars(menuPtr->display, d, gc, tkfont, label,
- mePtr->labelLength, leftEdge + textXOffset,
+ mePtr->labelLength, leftEdge + textXOffset,
baseline + textYOffset);
- DrawMenuUnderline(menuPtr, mePtr, d, gc, tkfont, fmPtr,
+ DrawMenuUnderline(menuPtr, mePtr, d, gc, tkfont, fmPtr,
x + textXOffset, y + textYOffset,
width, height);
}
@@ -842,7 +825,7 @@ DrawMenuEntryLabel(menuPtr, mePtr, d, gc, tkfont, fmPtr, x, y, width, height)
if (menuPtr->disabledFgPtr == NULL) {
XFillRectangle(menuPtr->display, d, menuPtr->disabledGC, x, y,
(unsigned) width, (unsigned) height);
- } else if ((mePtr->image != NULL)
+ } else if ((mePtr->image != NULL)
&& (menuPtr->disabledImageGC != None)) {
XFillRectangle(menuPtr->display, d, menuPtr->disabledImageGC,
leftEdge + imageXOffset,
@@ -857,31 +840,29 @@ DrawMenuEntryLabel(menuPtr, mePtr, d, gc, tkfont, fmPtr, x, y, width, height)
*
* DrawMenuUnderline --
*
- * On appropriate platforms, draw the underline character for the
- * menu.
+ * On appropriate platforms, draw the underline character for the menu.
*
* Results:
* None.
*
* Side effects:
- * Commands are output to X to display the menu in its
- * current mode.
+ * Commands are output to X to display the menu in its current mode.
*
*----------------------------------------------------------------------
*/
static void
-DrawMenuUnderline(menuPtr, mePtr, d, gc, tkfont, fmPtr, x, y, width, height)
- TkMenu *menuPtr; /* The menu to draw into */
- TkMenuEntry *mePtr; /* The entry we are drawing */
- Drawable d; /* What we are drawing into */
- GC gc; /* The gc to draw into */
- Tk_Font tkfont; /* The precalculated font */
- CONST Tk_FontMetrics *fmPtr; /* The precalculated font metrics */
- int x;
- int y;
- int width;
- int height;
+DrawMenuUnderline(
+ TkMenu *menuPtr, /* The menu to draw into */
+ TkMenuEntry *mePtr, /* The entry we are drawing */
+ Drawable d, /* What we are drawing into */
+ GC gc, /* The gc to draw into */
+ Tk_Font tkfont, /* The precalculated font */
+ CONST Tk_FontMetrics *fmPtr,/* The precalculated font metrics */
+ int x,
+ int y,
+ int width,
+ int height)
{
int indicatorSpace = mePtr->indicatorSpace;
@@ -902,7 +883,7 @@ DrawMenuUnderline(menuPtr, mePtr, d, gc, tkfont, fmPtr, x, y, width, height)
Tk_UnderlineChars(menuPtr->display, d, gc, tkfont, label,
leftEdge, y + (height + fmPtr->ascent - fmPtr->descent) / 2,
start - label, end - label);
- }
+ }
}
/*
@@ -922,11 +903,11 @@ DrawMenuUnderline(menuPtr, mePtr, d, gc, tkfont, fmPtr, x, y, width, height)
*/
int
-TkpPostMenu(interp, menuPtr, x, y)
- Tcl_Interp *interp;
- TkMenu *menuPtr;
- int x;
- int y;
+TkpPostMenu(
+ Tcl_Interp *interp,
+ TkMenu *menuPtr,
+ int x,
+ int y)
{
return TkPostTearoffMenu(interp, menuPtr, x, y);
}
@@ -948,14 +929,13 @@ TkpPostMenu(interp, menuPtr, x, y)
*/
static void
-GetMenuSeparatorGeometry(menuPtr, mePtr, tkfont, fmPtr, widthPtr,
- heightPtr)
- TkMenu *menuPtr; /* The menu we are measuring */
- TkMenuEntry *mePtr; /* The entry we are measuring */
- Tk_Font tkfont; /* The precalculated font */
- CONST Tk_FontMetrics *fmPtr; /* The precalcualted font metrics */
- int *widthPtr; /* The resulting width */
- int *heightPtr; /* The resulting height */
+GetMenuSeparatorGeometry(
+ TkMenu *menuPtr, /* The menu we are measuring */
+ TkMenuEntry *mePtr, /* The entry we are measuring */
+ Tk_Font tkfont, /* The precalculated font */
+ CONST Tk_FontMetrics *fmPtr,/* The precalcualted font metrics */
+ int *widthPtr, /* The resulting width */
+ int *heightPtr) /* The resulting height */
{
*widthPtr = 0;
*heightPtr = fmPtr->linespace;
@@ -978,13 +958,13 @@ GetMenuSeparatorGeometry(menuPtr, mePtr, tkfont, fmPtr, widthPtr,
*/
static void
-GetTearoffEntryGeometry(menuPtr, mePtr, tkfont, fmPtr, widthPtr, heightPtr)
- TkMenu *menuPtr; /* The menu we are drawing */
- TkMenuEntry *mePtr; /* The entry we are measuring */
- Tk_Font tkfont; /* The precalculated font */
- CONST Tk_FontMetrics *fmPtr; /* The precalculated font metrics */
- int *widthPtr; /* The resulting width */
- int *heightPtr; /* The resulting height */
+GetTearoffEntryGeometry(
+ TkMenu *menuPtr, /* The menu we are drawing */
+ TkMenuEntry *mePtr, /* The entry we are measuring */
+ Tk_Font tkfont, /* The precalculated font */
+ CONST Tk_FontMetrics *fmPtr,/* The precalculated font metrics */
+ int *widthPtr, /* The resulting width */
+ int *heightPtr) /* The resulting height */
{
if (menuPtr->menuType != MASTER_MENU) {
*heightPtr = 0;
@@ -1000,23 +980,22 @@ GetTearoffEntryGeometry(menuPtr, mePtr, tkfont, fmPtr, widthPtr, heightPtr)
*
* TkpComputeMenubarGeometry --
*
- * This procedure is invoked to recompute the size and
- * layout of a menu that is a menubar clone.
+ * This procedure is invoked to recompute the size and layout of a menu
+ * that is a menubar clone.
*
* Results:
* None.
*
* Side effects:
- * Fields of menu entries are changed to reflect their
- * current positions, and the size of the menu window
- * itself may be changed.
+ * Fields of menu entries are changed to reflect their current positions,
+ * and the size of the menu window itself may be changed.
*
*--------------------------------------------------------------
*/
void
-TkpComputeMenubarGeometry(menuPtr)
- TkMenu *menuPtr; /* Structure describing menu. */
+TkpComputeMenubarGeometry(
+ TkMenu *menuPtr) /* Structure describing menu. */
{
Tk_Font tkfont;
Tk_FontMetrics menuMetrics, entryMetrics, *fmPtr;
@@ -1031,7 +1010,7 @@ TkpComputeMenubarGeometry(menuPtr)
Tk_Font menuFont;
int borderWidth;
int activeBorderWidth;
-
+
if (menuPtr->tkwin == NULL) {
return;
}
@@ -1045,7 +1024,7 @@ TkpComputeMenubarGeometry(menuPtr)
height = 0;
} else {
int borderWidth;
-
+
maxWindowWidth = Tk_Width(menuPtr->tkwin);
if (maxWindowWidth == 1) {
maxWindowWidth = 0x7ffffff;
@@ -1055,19 +1034,19 @@ TkpComputeMenubarGeometry(menuPtr)
&borderWidth);
x = y = borderWidth;
lastRowBreak = 0;
-
+
/*
- * On the Mac especially, getting font metrics can be quite slow,
- * so we want to do it intelligently. We are going to precalculate
- * them and pass them down to all of the measureing and drawing
- * routines. We will measure the font metrics of the menu once,
- * and if an entry has a font set, we will measure it as we come
- * to it, and then we decide which set to give the geometry routines.
+ * On the Mac especially, getting font metrics can be quite slow, so
+ * we want to do it intelligently. We are going to precalculate them
+ * and pass them down to all of the measureing and drawing routines.
+ * We will measure the font metrics of the menu once, and if an entry
+ * has a font set, we will measure it as we come to it, and then we
+ * decide which set to give the geometry routines.
*/
menuFont = Tk_GetFontFromObj(menuPtr->tkwin, menuPtr->fontPtr);
Tk_GetFontMetrics(menuFont, &menuMetrics);
-
+
for (i = 0; i < menuPtr->numEntries; i++) {
mePtr = menuPtr->entries[i];
mePtr->entryFlags &= ~ENTRY_LAST_COLUMN;
@@ -1083,11 +1062,10 @@ TkpComputeMenubarGeometry(menuPtr)
/*
* For every entry, we need to check to see whether or not we
* wrap. If we do wrap, then we have to adjust all of the previous
- * entries' height and y position, because when we see them
- * the first time, we don't know how big its neighbor might
- * be.
+ * entries' height and y position, because when we see them the
+ * first time, we don't know how big its neighbor might be.
*/
-
+
if ((mePtr->type == SEPARATOR_ENTRY)
|| (mePtr->type == TEAROFF_ENTRY)) {
mePtr->height = mePtr->width = 0;
@@ -1135,7 +1113,7 @@ TkpComputeMenubarGeometry(menuPtr)
if (mePtr->height > currentRowHeight) {
currentRowHeight = mePtr->height;
}
- }
+ }
}
lastEntry = menuPtr->numEntries - 1;
@@ -1156,7 +1134,7 @@ TkpComputeMenubarGeometry(menuPtr)
menuPtr->entries[j]->x = x;
x += menuPtr->entries[j]->width;
}
-
+
if (helpMenuIndex != -1) {
mePtr = menuPtr->entries[helpMenuIndex];
@@ -1172,11 +1150,11 @@ TkpComputeMenubarGeometry(menuPtr)
}
height = y + currentRowHeight + borderWidth;
}
- width = Tk_Width(menuPtr->tkwin);
+ width = Tk_Width(menuPtr->tkwin);
/*
- * The X server doesn't like zero dimensions, so round up to at least
- * 1 (a zero-sized menu should never really occur, anyway).
+ * The X server doesn't like zero dimensions, so round up to at least 1 (a
+ * zero-sized menu should never really occur, anyway).
*/
if (width <= 0) {
@@ -1200,8 +1178,7 @@ TkpComputeMenubarGeometry(menuPtr)
* None.
*
* Side effects:
- * Commands are output to X to display the menu in its
- * current mode.
+ * Commands are output to X to display the menu in its current mode.
*
*----------------------------------------------------------------------
*/
@@ -1226,7 +1203,7 @@ DrawTearoffEntry(menuPtr, mePtr, d, gc, tkfont, fmPtr, x, y, width, height)
if (menuPtr->menuType != MASTER_MENU) {
return;
}
-
+
points[0].x = x;
points[0].y = y + height/2;
points[1].y = points[0].y;
@@ -1339,7 +1316,7 @@ SetHelpMenu(menuPtr)
*/
void
-TkpDrawMenuEntry(mePtr, d, tkfont, menuMetricsPtr, x, y, width, height,
+TkpDrawMenuEntry(mePtr, d, tkfont, menuMetricsPtr, x, y, width, height,
strictMotif, drawArrow)
TkMenuEntry *mePtr; /* The entry to draw */
Drawable d; /* What to draw into */
@@ -1378,7 +1355,7 @@ TkpDrawMenuEntry(mePtr, d, tkfont, menuMetricsPtr, x, y, width, height,
} else {
TkMenuEntry *cascadeEntryPtr;
int parentDisabled = 0;
-
+
for (cascadeEntryPtr = menuPtr->menuRefPtr->parentEntryPtr;
cascadeEntryPtr != NULL;
cascadeEntryPtr = cascadeEntryPtr->nextCascadePtr) {
@@ -1449,12 +1426,12 @@ TkpDrawMenuEntry(mePtr, d, tkfont, menuMetricsPtr, x, y, width, height,
* for menubars, we have to draw the rest of the entry taking
* into account the padding.
*/
-
- DrawMenuEntryBackground(menuPtr, mePtr, d, activeBorder,
+
+ DrawMenuEntryBackground(menuPtr, mePtr, d, activeBorder,
bgBorder, x, y, width, height);
-
+
if (mePtr->type == SEPARATOR_ENTRY) {
- DrawMenuSeparator(menuPtr, mePtr, d, gc, tkfont,
+ DrawMenuSeparator(menuPtr, mePtr, d, gc, tkfont,
fmPtr, x, adjustedY, width, adjustedHeight);
} else if (mePtr->type == TEAROFF_ENTRY) {
DrawTearoffEntry(menuPtr, mePtr, d, gc, tkfont, fmPtr, x, adjustedY,
@@ -1504,7 +1481,7 @@ GetMenuLabelGeometry(mePtr, tkfont, fmPtr, widthPtr, heightPtr)
{
TkMenu *menuPtr = mePtr->menuPtr;
int haveImage = 0;
-
+
if (mePtr->image != NULL) {
Tk_SizeOfImage(mePtr->image, widthPtr, heightPtr);
haveImage = 1;
@@ -1516,7 +1493,7 @@ GetMenuLabelGeometry(mePtr, tkfont, fmPtr, widthPtr, heightPtr)
*heightPtr = 0;
*widthPtr = 0;
}
-
+
if (haveImage && (mePtr->compound == COMPOUND_NONE)) {
/* We don't care about the text in this case */
} else {
@@ -1525,7 +1502,7 @@ GetMenuLabelGeometry(mePtr, tkfont, fmPtr, widthPtr, heightPtr)
int textWidth;
char *label = Tcl_GetStringFromObj(mePtr->labelPtr, NULL);
textWidth = Tk_TextWidth(tkfont, label, mePtr->labelLength);
-
+
if ((mePtr->compound != COMPOUND_NONE) && haveImage) {
switch ((enum compound) mePtr->compound) {
case COMPOUND_TOP:
@@ -1601,7 +1578,7 @@ TkpComputeStandardMenuGeometry(
int i, j, lastColumnBreak = 0;
TkMenuEntry *mePtr;
int borderWidth, activeBorderWidth;
-
+
if (menuPtr->tkwin == NULL) {
return;
}
@@ -1665,12 +1642,12 @@ TkpComputeStandardMenuGeometry(
fmPtr, &width, &height);
mePtr->height = height;
} else if (mePtr->type == TEAROFF_ENTRY) {
- GetTearoffEntryGeometry(menuPtr, mePtr, tkfont,
+ GetTearoffEntryGeometry(menuPtr, mePtr, tkfont,
fmPtr, &width, &height);
mePtr->height = height;
labelWidth = width;
} else {
-
+
/*
* For each entry, compute the height required by that
* particular entry, plus three widths: the width of the
@@ -1680,7 +1657,7 @@ TkpComputeStandardMenuGeometry(
* (if any). These sizes depend, of course, on the type
* of the entry.
*/
-
+
GetMenuLabelGeometry(mePtr, tkfont, fmPtr, &width,
&height);
mePtr->height = height;
@@ -1690,7 +1667,7 @@ TkpComputeStandardMenuGeometry(
if (width > labelWidth) {
labelWidth = width;
}
-
+
GetMenuAccelGeometry(menuPtr, mePtr, tkfont,
fmPtr, &width, &height);
if (height > mePtr->height) {
@@ -1703,7 +1680,7 @@ TkpComputeStandardMenuGeometry(
accelWidth = width;
}
- GetMenuIndicatorGeometry(menuPtr, mePtr, tkfont,
+ GetMenuIndicatorGeometry(menuPtr, mePtr, tkfont,
fmPtr, &width, &height);
if (height > mePtr->height) {
mePtr->height = height;
@@ -1740,7 +1717,7 @@ TkpComputeStandardMenuGeometry(
windowHeight += borderWidth;
-
+
/*
* The X server doesn't like zero dimensions, so round up to at least
* 1 (a zero-sized menu should never really occur, anyway).
@@ -1777,7 +1754,7 @@ TkpComputeStandardMenuGeometry(
void
TkpMenuNotifyToplevelCreate(interp, menuName)
Tcl_Interp *interp; /* The interp the menu lives in. */
- char *menuName; /* The name of the menu to
+ char *menuName; /* The name of the menu to
* reconfigure. */
{
/*
@@ -1834,4 +1811,11 @@ TkpMenuThreadInit()
* Nothing to do.
*/
}
-
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/unix/tkUnixMenubu.c b/unix/tkUnixMenubu.c
index cdcc31c..c21608b 100644
--- a/unix/tkUnixMenubu.c
+++ b/unix/tkUnixMenubu.c
@@ -1,22 +1,22 @@
-/*
+/*
* tkUnixMenubu.c --
*
- * This file implements the Unix specific portion of the
- * menubutton widget.
+ * This file implements the Unix specific portion of the menubutton
+ * widget.
*
* Copyright (c) 1996-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: tkUnixMenubu.c,v 1.7 2003/11/17 23:12:44 hobbs Exp $
+ * RCS: @(#) $Id: tkUnixMenubu.c,v 1.8 2005/11/13 21:00:17 dkf Exp $
*/
#include "tkMenubutton.h"
/*
- * The structure below defines menubutton class behavior by means of
- * procedures that can be invoked from generic window code.
+ * The structure below defines menubutton class behavior by means of functions
+ * that can be invoked from generic window code.
*/
Tk_ClassProcs tkpMenubuttonClass = {
@@ -41,8 +41,8 @@ Tk_ClassProcs tkpMenubuttonClass = {
*/
TkMenuButton *
-TkpCreateMenuButton(tkwin)
- Tk_Window tkwin;
+TkpCreateMenuButton(
+ Tk_Window tkwin)
{
return (TkMenuButton *)ckalloc(sizeof(TkMenuButton));
}
@@ -52,35 +52,36 @@ TkpCreateMenuButton(tkwin)
*
* TkpDisplayMenuButton --
*
- * This procedure is invoked to display a menubutton widget.
+ * This function is invoked to display a menubutton widget.
*
* Results:
* None.
*
* Side effects:
- * Commands are output to X to display the menubutton in its
- * current mode.
+ * Commands are output to X to display the menubutton in its current
+ * mode.
*
*----------------------------------------------------------------------
*/
void
-TkpDisplayMenuButton(clientData)
- ClientData clientData; /* Information about widget. */
+TkpDisplayMenuButton(
+ ClientData clientData) /* Information about widget. */
{
register TkMenuButton *mbPtr = (TkMenuButton *) clientData;
GC gc;
Tk_3DBorder border;
Pixmap pixmap;
- int x = 0; /* Initialization needed only to stop
- * compiler warning. */
+ int x = 0; /* Initialization needed only to stop compiler
+ * warning. */
int y = 0;
register Tk_Window tkwin = mbPtr->tkwin;
int width, height, fullWidth, fullHeight;
int textXOffset, textYOffset;
int imageWidth, imageHeight;
- int imageXOffset, imageYOffset; /* image information that will be used to
- * restrict disabled pixmap as well */
+ int imageXOffset, imageYOffset;
+ /* Image information that will be used to
+ * restrict disabled pixmap as well */
int haveImage = 0, haveText = 0;
mbPtr->flags &= ~REDRAW_PENDING;
@@ -107,16 +108,16 @@ TkpDisplayMenuButton(clientData)
Tk_SizeOfBitmap(mbPtr->display, mbPtr->bitmap, &width, &height);
haveImage = 1;
}
- imageWidth = width;
+ imageWidth = width;
imageHeight = height;
haveText = (mbPtr->textWidth != 0 && mbPtr->textHeight != 0);
/*
- * In order to avoid screen flashes, this procedure redraws
- * the menu 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 function redraws the menu 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(mbPtr->display, Tk_WindowId(tkwin),
@@ -132,53 +133,58 @@ TkpDisplayMenuButton(clientData)
fullHeight = 0;
if (mbPtr->compound != COMPOUND_NONE && haveImage && haveText) {
- switch ((enum compound) mbPtr->compound) {
- case COMPOUND_TOP:
- case COMPOUND_BOTTOM: {
- /* Image is above or below text */
- if (mbPtr->compound == COMPOUND_TOP) {
- textYOffset = height + mbPtr->padY;
- } else {
- imageYOffset = mbPtr->textHeight + mbPtr->padY;
- }
- fullHeight = height + mbPtr->textHeight + mbPtr->padY;
- fullWidth = (width > mbPtr->textWidth ? width :
- mbPtr->textWidth);
- textXOffset = (fullWidth - mbPtr->textWidth)/2;
- imageXOffset = (fullWidth - width)/2;
- break;
- }
- case COMPOUND_LEFT:
- case COMPOUND_RIGHT: {
- /* Image is left or right of text */
- if (mbPtr->compound == COMPOUND_LEFT) {
- textXOffset = width + mbPtr->padX;
- } else {
- imageXOffset = mbPtr->textWidth + mbPtr->padX;
- }
- fullWidth = mbPtr->textWidth + mbPtr->padX + width;
- fullHeight = (height > mbPtr->textHeight ? height :
- mbPtr->textHeight);
- textYOffset = (fullHeight - mbPtr->textHeight)/2;
- imageYOffset = (fullHeight - height)/2;
- break;
- }
- case COMPOUND_CENTER: {
- /* Image and text are superimposed */
- fullWidth = (width > mbPtr->textWidth ? width :
- mbPtr->textWidth);
- fullHeight = (height > mbPtr->textHeight ? height :
- mbPtr->textHeight);
- textXOffset = (fullWidth - mbPtr->textWidth)/2;
- imageXOffset = (fullWidth - width)/2;
- textYOffset = (fullHeight - mbPtr->textHeight)/2;
- imageYOffset = (fullHeight - height)/2;
- break;
- }
- case COMPOUND_NONE: {break;}
- }
-
- TkComputeAnchor(mbPtr->anchor, tkwin, 0, 0,
+ switch ((enum compound) mbPtr->compound) {
+ case COMPOUND_TOP:
+ case COMPOUND_BOTTOM:
+ /*
+ * Image is above or below text.
+ */
+
+ if (mbPtr->compound == COMPOUND_TOP) {
+ textYOffset = height + mbPtr->padY;
+ } else {
+ imageYOffset = mbPtr->textHeight + mbPtr->padY;
+ }
+ fullHeight = height + mbPtr->textHeight + mbPtr->padY;
+ fullWidth = (width > mbPtr->textWidth ? width : mbPtr->textWidth);
+ textXOffset = (fullWidth - mbPtr->textWidth)/2;
+ imageXOffset = (fullWidth - width)/2;
+ break;
+ case COMPOUND_LEFT:
+ case COMPOUND_RIGHT:
+ /*
+ * Image is left or right of text.
+ */
+
+ if (mbPtr->compound == COMPOUND_LEFT) {
+ textXOffset = width + mbPtr->padX;
+ } else {
+ imageXOffset = mbPtr->textWidth + mbPtr->padX;
+ }
+ fullWidth = mbPtr->textWidth + mbPtr->padX + width;
+ fullHeight = (height > mbPtr->textHeight ? height :
+ mbPtr->textHeight);
+ textYOffset = (fullHeight - mbPtr->textHeight)/2;
+ imageYOffset = (fullHeight - height)/2;
+ break;
+ case COMPOUND_CENTER:
+ /*
+ * Image and text are superimposed.
+ */
+
+ fullWidth = (width > mbPtr->textWidth ? width : mbPtr->textWidth);
+ fullHeight = (height > mbPtr->textHeight ? height :
+ mbPtr->textHeight);
+ textXOffset = (fullWidth - mbPtr->textWidth)/2;
+ imageXOffset = (fullWidth - width)/2;
+ textYOffset = (fullHeight - mbPtr->textHeight)/2;
+ imageYOffset = (fullHeight - height)/2;
+ break;
+ case COMPOUND_NONE:
+ break;
+ }
+
+ TkComputeAnchor(mbPtr->anchor, tkwin, 0, 0,
mbPtr->indicatorWidth + fullWidth, fullHeight, &x, &y);
imageXOffset += x;
@@ -189,7 +195,7 @@ TkpDisplayMenuButton(clientData)
} else if (mbPtr->bitmap != None) {
XSetClipOrigin(mbPtr->display, gc, imageXOffset, imageYOffset);
XCopyPlane(mbPtr->display, mbPtr->bitmap, pixmap,
- gc, 0, 0, (unsigned) width, (unsigned) height,
+ gc, 0, 0, (unsigned) width, (unsigned) height,
imageXOffset, imageYOffset, 1);
XSetClipOrigin(mbPtr->display, gc, 0, 0);
}
@@ -209,7 +215,7 @@ TkpDisplayMenuButton(clientData)
} else if (mbPtr->bitmap != None) {
XSetClipOrigin(mbPtr->display, gc, x, y);
XCopyPlane(mbPtr->display, mbPtr->bitmap, pixmap,
- gc, 0, 0, (unsigned) width, (unsigned) height,
+ gc, 0, 0, (unsigned) width, (unsigned) height,
x, y, 1);
XSetClipOrigin(mbPtr->display, gc, 0, 0);
}
@@ -217,7 +223,7 @@ TkpDisplayMenuButton(clientData)
TkComputeAnchor(mbPtr->anchor, tkwin, mbPtr->padX, mbPtr->padY,
mbPtr->textWidth + mbPtr->indicatorWidth,
mbPtr->textHeight, &x, &y);
- Tk_DrawTextLayout(mbPtr->display, pixmap, gc, mbPtr->textLayout,
+ Tk_DrawTextLayout(mbPtr->display, pixmap, gc, mbPtr->textLayout,
x + textXOffset, y + textYOffset, 0, -1);
Tk_UnderlineTextLayout(mbPtr->display, pixmap, gc,
mbPtr->textLayout, x + textXOffset, y + textYOffset,
@@ -229,12 +235,13 @@ TkpDisplayMenuButton(clientData)
* foreground color, generate the stippled effect.
*/
- if ((mbPtr->state == STATE_DISABLED)
- && ((mbPtr->disabledFg == NULL) || (mbPtr->image != NULL))) {
+ if ((mbPtr->state == STATE_DISABLED)
+ && ((mbPtr->disabledFg == NULL) || (mbPtr->image != NULL))) {
/*
- * 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 (mbPtr->disabledFg == NULL) {
XFillRectangle(mbPtr->display, pixmap, mbPtr->stippleGC,
mbPtr->inset, mbPtr->inset,
@@ -248,8 +255,8 @@ TkpDisplayMenuButton(clientData)
}
/*
- * Draw the cascade indicator for the menu button on the
- * right side of the window, if desired.
+ * Draw the cascade indicator for the menu button on the right side of the
+ * window, if desired.
*/
if (mbPtr->indicatorOn) {
@@ -269,9 +276,9 @@ TkpDisplayMenuButton(clientData)
}
/*
- * Draw the border and traversal highlight last. This way, if the
- * menu button's contents overflow onto the border they'll be covered
- * up by the border.
+ * Draw the border and traversal highlight last. This way, if the menu
+ * button's contents overflow onto the border they'll be covered up by the
+ * border.
*/
if (mbPtr->relief != TK_RELIEF_FLAT) {
@@ -293,8 +300,8 @@ TkpDisplayMenuButton(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(mbPtr->display, pixmap, Tk_WindowId(tkwin),
@@ -320,8 +327,8 @@ TkpDisplayMenuButton(clientData)
*/
void
-TkpDestroyMenuButton(mbPtr)
- TkMenuButton *mbPtr;
+TkpDestroyMenuButton(
+ TkMenuButton *mbPtr)
{
}
@@ -330,7 +337,7 @@ TkpDestroyMenuButton(mbPtr)
*
* TkpComputeMenuButtonGeometry --
*
- * After changes in a menu button's text or bitmap, this procedure
+ * After changes in a menu button's text or bitmap, this function
* recomputes the menu button's geometry and passes this information
* along to the geometry manager for the window.
*
@@ -344,11 +351,11 @@ TkpDestroyMenuButton(mbPtr)
*/
void
-TkpComputeMenuButtonGeometry(mbPtr)
- TkMenuButton *mbPtr; /* Widget record for menu button. */
+TkpComputeMenuButtonGeometry(
+ TkMenuButton *mbPtr) /* Widget record for menu button. */
{
int width, height, mm, pixels;
- int avgWidth, txtWidth, txtHeight;
+ int avgWidth, txtWidth, txtHeight;
int haveImage = 0, haveText = 0;
Tk_FontMetrics fm;
@@ -376,88 +383,103 @@ TkpComputeMenuButtonGeometry(mbPtr)
&mbPtr->textHeight);
txtWidth = mbPtr->textWidth;
txtHeight = mbPtr->textHeight;
- avgWidth = Tk_TextWidth(mbPtr->tkfont, "0", 1);
- Tk_GetFontMetrics(mbPtr->tkfont, &fm);
- haveText = (txtWidth != 0 && txtHeight != 0);
+ avgWidth = Tk_TextWidth(mbPtr->tkfont, "0", 1);
+ Tk_GetFontMetrics(mbPtr->tkfont, &fm);
+ haveText = (txtWidth != 0 && txtHeight != 0);
}
/*
* If the menubutton is compound (ie, 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 menubutton has both text and
- * an image, because otherwise it is not really a compound menubutton.
+ * the new geometry is a combination of the image and text geometry. We
+ * only honor the compound bit if the menubutton has both text and an
+ * image, because otherwise it is not really a compound menubutton.
*/
if (mbPtr->compound != COMPOUND_NONE && haveImage && haveText) {
- switch ((enum compound) mbPtr->compound) {
- case COMPOUND_TOP:
- case COMPOUND_BOTTOM: {
- /* Image is above or below text */
- height += txtHeight + mbPtr->padY;
- width = (width > txtWidth ? width : txtWidth);
- break;
- }
- case COMPOUND_LEFT:
- case COMPOUND_RIGHT: {
- /* Image is left or right of text */
- width += txtWidth + mbPtr->padX;
- height = (height > txtHeight ? height : txtHeight);
- break;
- }
- case COMPOUND_CENTER: {
- /* Image and text are superimposed */
- width = (width > txtWidth ? width : txtWidth);
- height = (height > txtHeight ? height : txtHeight);
- break;
- }
- case COMPOUND_NONE: {break;}
- }
- if (mbPtr->width > 0) {
- width = mbPtr->width;
- }
- if (mbPtr->height > 0) {
- height = mbPtr->height;
- }
- width += 2*mbPtr->padX;
- height += 2*mbPtr->padY;
+ switch ((enum compound) mbPtr->compound) {
+ case COMPOUND_TOP:
+ case COMPOUND_BOTTOM:
+ /*
+ * Image is above or below text.
+ */
+
+ height += txtHeight + mbPtr->padY;
+ width = (width > txtWidth ? width : txtWidth);
+ break;
+ case COMPOUND_LEFT:
+ case COMPOUND_RIGHT:
+ /*
+ * Image is left or right of text.
+ */
+
+ width += txtWidth + mbPtr->padX;
+ height = (height > txtHeight ? height : txtHeight);
+ break;
+ case COMPOUND_CENTER:
+ /*
+ * Image and text are superimposed.
+ */
+
+ width = (width > txtWidth ? width : txtWidth);
+ height = (height > txtHeight ? height : txtHeight);
+ break;
+ case COMPOUND_NONE:
+ break;
+ }
+ if (mbPtr->width > 0) {
+ width = mbPtr->width;
+ }
+ if (mbPtr->height > 0) {
+ height = mbPtr->height;
+ }
+ width += 2*mbPtr->padX;
+ height += 2*mbPtr->padY;
} else {
if (haveImage) {
- if (mbPtr->width > 0) {
- width = mbPtr->width;
- }
- if (mbPtr->height > 0) {
- height = mbPtr->height;
- }
+ if (mbPtr->width > 0) {
+ width = mbPtr->width;
+ }
+ if (mbPtr->height > 0) {
+ height = mbPtr->height;
+ }
} else {
width = txtWidth;
height = txtHeight;
- if (mbPtr->width > 0) {
- width = mbPtr->width * avgWidth;
- }
- if (mbPtr->height > 0) {
- height = mbPtr->height * fm.linespace;
- }
+ if (mbPtr->width > 0) {
+ width = mbPtr->width * avgWidth;
+ }
+ if (mbPtr->height > 0) {
+ height = mbPtr->height * fm.linespace;
+ }
}
}
if (! haveImage) {
- width += 2*mbPtr->padX;
- height += 2*mbPtr->padY;
+ width += 2*mbPtr->padX;
+ height += 2*mbPtr->padY;
}
if (mbPtr->indicatorOn) {
- mm = WidthMMOfScreen(Tk_Screen(mbPtr->tkwin));
- pixels = WidthOfScreen(Tk_Screen(mbPtr->tkwin));
- mbPtr->indicatorHeight= (INDICATOR_HEIGHT * pixels)/(10*mm);
- mbPtr->indicatorWidth = (INDICATOR_WIDTH * pixels)/(10*mm)
- + 2*mbPtr->indicatorHeight;
- width += mbPtr->indicatorWidth;
+ mm = WidthMMOfScreen(Tk_Screen(mbPtr->tkwin));
+ pixels = WidthOfScreen(Tk_Screen(mbPtr->tkwin));
+ mbPtr->indicatorHeight= (INDICATOR_HEIGHT * pixels)/(10*mm);
+ mbPtr->indicatorWidth = (INDICATOR_WIDTH * pixels)/(10*mm)
+ + 2*mbPtr->indicatorHeight;
+ width += mbPtr->indicatorWidth;
} else {
- mbPtr->indicatorHeight = 0;
- mbPtr->indicatorWidth = 0;
+ mbPtr->indicatorHeight = 0;
+ mbPtr->indicatorWidth = 0;
}
Tk_GeometryRequest(mbPtr->tkwin, (int) (width + 2*mbPtr->inset),
(int) (height + 2*mbPtr->inset));
Tk_SetInternalBorder(mbPtr->tkwin, mbPtr->inset);
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/unix/tkUnixScrlbr.c b/unix/tkUnixScrlbr.c
index fc3e7f8..074fff3 100644
--- a/unix/tkUnixScrlbr.c
+++ b/unix/tkUnixScrlbr.c
@@ -1,4 +1,4 @@
-/*
+/*
* tkUnixScrollbar.c --
*
* This file implements the Unix specific portion of the scrollbar
@@ -6,17 +6,17 @@
*
* 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: tkUnixScrlbr.c,v 1.3 2000/11/22 01:49:38 ericm Exp $
+ * RCS: @(#) $Id: tkUnixScrlbr.c,v 1.4 2005/11/13 21:00:17 dkf Exp $
*/
#include "tkScrollbar.h"
/*
- * Minimum slider length, in pixels (designed to make sure that the slider
- * is always easy to grab with the mouse).
+ * Minimum slider length, in pixels (designed to make sure that the slider is
+ * always easy to grab with the mouse).
*/
#define MIN_SLIDER_LENGTH 5
@@ -32,15 +32,14 @@ typedef struct UnixScrollbar {
} UnixScrollbar;
/*
- * The class procedure table for the scrollbar widget. All fields except
- * size are left initialized to NULL, which should happen automatically
- * since the variable is declared at this scope.
+ * The class procedure table for the scrollbar widget. All fields except size
+ * are left initialized to NULL, which should happen automatically since the
+ * variable is declared at this scope.
*/
Tk_ClassProcs tkpScrollbarProcs = {
sizeof(Tk_ClassProcs) /* size */
};
-
/*
*----------------------------------------------------------------------
@@ -59,8 +58,8 @@ Tk_ClassProcs tkpScrollbarProcs = {
*/
TkScrollbar *
-TkpCreateScrollbar(tkwin)
- Tk_Window tkwin;
+TkpCreateScrollbar(
+ Tk_Window tkwin)
{
UnixScrollbar *scrollPtr = (UnixScrollbar *)ckalloc(sizeof(UnixScrollbar));
scrollPtr->troughGC = None;
@@ -78,9 +77,9 @@ TkpCreateScrollbar(tkwin)
*
* 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.
@@ -92,8 +91,8 @@ TkpCreateScrollbar(tkwin)
*/
void
-TkpDisplayScrollbar(clientData)
- ClientData clientData; /* Information about window. */
+TkpDisplayScrollbar(
+ ClientData clientData) /* Information about window. */
{
register TkScrollbar *scrollPtr = (TkScrollbar *) clientData;
register Tk_Window tkwin = scrollPtr->tkwin;
@@ -117,10 +116,10 @@ TkpDisplayScrollbar(clientData)
}
/*
- * In order to avoid screen flashes, this procedure redraws
- * the scrollbar 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 scrollbar
+ * 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(scrollPtr->display, Tk_WindowId(tkwin),
@@ -148,11 +147,11 @@ TkpDisplayScrollbar(clientData)
(unsigned) (Tk_Height(tkwin) - 2*scrollPtr->inset));
/*
- * Draw the top or left arrow. The coordinates of the polygon
- * points probably seem odd, but they were carefully chosen with
- * respect to X's rules for filling polygons. These point choices
- * cause the arrows to just fill the narrow dimension of the
- * scrollbar and be properly centered.
+ * Draw the top or left arrow. The coordinates of the polygon points
+ * probably seem odd, but they were carefully chosen with respect to X's
+ * rules for filling polygons. These point choices cause the arrows to
+ * just fill the narrow dimension of the scrollbar and be properly
+ * centered.
*/
if (scrollPtr->activeField == TOP_ARROW) {
@@ -242,8 +241,8 @@ TkpDisplayScrollbar(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(scrollPtr->display, pixmap, Tk_WindowId(tkwin),
@@ -251,7 +250,7 @@ TkpDisplayScrollbar(clientData)
(unsigned) Tk_Width(tkwin), (unsigned) Tk_Height(tkwin), 0, 0);
Tk_FreePixmap(scrollPtr->display, pixmap);
- done:
+ done:
scrollPtr->flags &= ~REDRAW_PENDING;
}
@@ -260,9 +259,9 @@ TkpDisplayScrollbar(clientData)
*
* 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.
@@ -274,9 +273,10 @@ TkpDisplayScrollbar(clientData)
*/
extern void
-TkpComputeScrollbarGeometry(scrollPtr)
- register TkScrollbar *scrollPtr; /* Scrollbar whose geometry may
- * have changed. */
+TkpComputeScrollbarGeometry(
+ register TkScrollbar *scrollPtr)
+ /* Scrollbar whose geometry may have
+ * changed. */
{
int width, fieldLength;
@@ -297,9 +297,9 @@ TkpComputeScrollbarGeometry(scrollPtr)
scrollPtr->sliderLast = fieldLength*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 - 2*scrollPtr->borderWidth)) {
@@ -319,10 +319,9 @@ TkpComputeScrollbarGeometry(scrollPtr)
scrollPtr->sliderLast += scrollPtr->arrowLength + scrollPtr->inset;
/*
- * 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) {
@@ -355,8 +354,8 @@ TkpComputeScrollbarGeometry(scrollPtr)
*/
void
-TkpDestroyScrollbar(scrollPtr)
- TkScrollbar *scrollPtr;
+TkpDestroyScrollbar(
+ TkScrollbar *scrollPtr)
{
UnixScrollbar *unixScrollPtr = (UnixScrollbar *)scrollPtr;
@@ -374,8 +373,8 @@ TkpDestroyScrollbar(scrollPtr)
* 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.
@@ -387,10 +386,10 @@ TkpDestroyScrollbar(scrollPtr)
*/
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. */
{
XGCValues gcValues;
GC new;
@@ -416,14 +415,12 @@ TkpConfigureScrollbar(scrollPtr)
*
* 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.
@@ -432,10 +429,10 @@ TkpConfigureScrollbar(scrollPtr)
*/
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;
@@ -457,7 +454,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)) {
@@ -474,3 +471,11 @@ TkpScrollbarPosition(scrollPtr, x, y)
}
return BOTTOM_GAP;
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */